@xopcai/xopc 0.0.423 → 0.0.425

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 (361) hide show
  1. package/dist/browser-ext/dist/assets/{page-context-BKnEwsOO.js → page-context-b-rB5vJC.js} +1 -1
  2. package/dist/browser-ext/dist/background.js +1 -1
  3. package/dist/browser-ext/dist/sidepanel.html +1 -1
  4. package/dist/browser-ext/dist/sidepanel.js +29 -1
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/gateway/static/root/assets/{activity-store-DNkXnatd.js → activity-store-CMw8qBuC.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DOnHjAY_.js → agent-avatar-dicebear-JI0YWOIm.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-display-C9Lu9LVl.js → agent-avatar-display-YqmwzOSa.js} +2 -2
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DlvjxWg6.js +1 -0
  11. package/dist/gateway/static/root/assets/{agent-plugin-dialog-sQNbqsGL.js → agent-plugin-dialog-OBueuQSc.js} +1 -1
  12. package/dist/gateway/static/root/assets/{agents-DZ77luyw.js → agents-Cp6_5OOQ.js} +4 -4
  13. package/dist/gateway/static/root/assets/{agents-admin-api-DIm_IHQL.js → agents-admin-api-DLnmdC1h.js} +1 -1
  14. package/dist/gateway/static/root/assets/{api-BUJQiCoX.js → api-Boc-CVh7.js} +1 -1
  15. package/dist/gateway/static/root/assets/{api-By0yX3z1.js → api-bL7sxjAF.js} +1 -1
  16. package/dist/gateway/static/root/assets/{app-management-settings-panel-PPgc1xaD.js → app-management-settings-panel-jIG5i7KE.js} +1 -1
  17. package/dist/gateway/static/root/assets/{appearance-settings-DbI9t4GS.js → appearance-settings-BnaQW9Xd.js} +1 -1
  18. package/dist/gateway/static/root/assets/{apps-page-DIC28vl4.js → apps-page-C2WKUwtN.js} +1 -1
  19. package/dist/gateway/static/root/assets/{archive-plugin-B5ZSQVw2.js → archive-plugin-DjboG3kA.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-api-CfjICuJK.js → automation-api-CZqL9l_d.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automation-result-state-DpQSVGNY.js → automation-result-state-DRd-X_Ai.js} +1 -1
  22. package/dist/gateway/static/root/assets/automation-task-card-wbnR5i6N.js +3 -0
  23. package/dist/gateway/static/root/assets/{automations-page-1NCQMSK1.js → automations-page-HyBQIfmn.js} +1 -1
  24. package/dist/gateway/static/root/assets/automations-workspace-D6cTOKr7.js +9 -0
  25. package/dist/gateway/static/root/assets/{binary-plugins-_riZg0hb.js → binary-plugins-Bg8ARZUH.js} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-BpYTVDaG.js → block-editor-DKohqFAW.js} +2 -2
  27. package/dist/gateway/static/root/assets/{browser-automation-inputs-DLbHyWE5.js → browser-automation-inputs-YeibTzw4.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-automations-page-BfOHr7er.js → browser-automations-page-BWNcbuz2.js} +1 -1
  29. package/dist/gateway/static/root/assets/{browser-control-api-CqjIQdQ4.js → browser-control-api-CDeuxy2x.js} +1 -1
  30. package/dist/gateway/static/root/assets/{browser-settings-page-CqjLefvt.js → browser-settings-page-L0nBjfhG.js} +1 -1
  31. package/dist/gateway/static/root/assets/{capabilities-BQ0bsu6d.js → capabilities-BcQa8c9n.js} +1 -1
  32. package/dist/gateway/static/root/assets/{capabilities-CTu4Y4Gc.js → capabilities-aT-QjNTl.js} +1 -1
  33. package/dist/gateway/static/root/assets/capabilities-page-DlpuHdHi.js +2 -0
  34. package/dist/gateway/static/root/assets/{capabilities-settings-panel-Cq28kvMr.js → capabilities-settings-panel-pvqkN2-2.js} +3 -3
  35. package/dist/gateway/static/root/assets/{channels-BPVkbqBI.js → channels-BUPtawh6.js} +1 -1
  36. package/dist/gateway/static/root/assets/{chat-agents-api-XnegLpGF.js → chat-agents-api-B8JO6Tcj.js} +1 -1
  37. package/dist/gateway/static/root/assets/{chat-chart-block-BJFCFZz2.js → chat-chart-block-DRtuFfF1.js} +1 -1
  38. package/dist/gateway/static/root/assets/chat-page-BP0huA-W.js +72 -0
  39. package/dist/gateway/static/root/assets/{chat-terminal-dock-B9KlHa8j.js → chat-terminal-dock-Dkqq5FSL.js} +1 -1
  40. package/dist/gateway/static/root/assets/{command-palette-api-DW7O6fME.js → command-palette-api-qujvNqkK.js} +1 -1
  41. package/dist/gateway/static/root/assets/{composer-payload-handoff-qheyxoAD.js → composer-payload-handoff-CYIhcczq.js} +1 -1
  42. package/dist/gateway/static/root/assets/{computer-settings-page-KmaJ2UVz.js → computer-settings-page-8q4hRmoo.js} +1 -1
  43. package/dist/gateway/static/root/assets/connected-providers-grid-CKZfhHSD.js +1 -0
  44. package/dist/gateway/static/root/assets/{connector-service-page-BgexZyHR.js → connector-service-page-DQaTI21R.js} +1 -1
  45. package/dist/gateway/static/root/assets/{connectors-api-DEYdFCdS.js → connectors-api-BjypBp2g.js} +1 -1
  46. package/dist/gateway/static/root/assets/connectors-page-Lf1ZzaVn.js +1 -0
  47. package/dist/gateway/static/root/assets/{date-picker-CSuiNiPU.js → date-picker-D_PSHGpe.js} +1 -1
  48. package/dist/gateway/static/root/assets/{dependency-picker-DHFVFI74.js → dependency-picker-UqKVJ9dv.js} +1 -1
  49. package/dist/gateway/static/root/assets/{desktop-pet-DK3tV5PW.js → desktop-pet-1Et9VqkM.js} +1 -1
  50. package/dist/gateway/static/root/assets/{desktop-pet-narrative-CS8qJpNO.js → desktop-pet-narrative-rADKU0FX.js} +1 -1
  51. package/dist/gateway/static/root/assets/{desktop-pet-settings-BKIcBnfQ.js → desktop-pet-settings-0fCGgaG7.js} +1 -1
  52. package/dist/gateway/static/root/assets/{dev-view-store-ZgXvR5Sl.js → dev-view-store-TTj_djD8.js} +1 -1
  53. package/dist/gateway/static/root/assets/device-pairing-wizard-ByEL5lvM.js +1 -0
  54. package/dist/gateway/static/root/assets/{directory-picker-path-field-C4N_kXUX.js → directory-picker-path-field-C07a7wYX.js} +1 -1
  55. package/dist/gateway/static/root/assets/{discussion-annotation-sync-CdbkKHiR.js → discussion-annotation-sync-BFqKm9ky.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-debug-page-vdSyb_US.js → extension-debug-page-DFaVlqas.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-iframe-host-D4w7-mf1.js → extension-iframe-host-BfzPfXBq.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-marketplace-api-BVMU-5FO.js → extension-marketplace-api-ow0K1Y4_.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-page-BE7FHMek.js → extension-page-CrDADV5W.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-provider-8RM98QmD.js → extension-provider-mnRoa63o.js} +1 -1
  61. package/dist/gateway/static/root/assets/{extension-settings-page--SP1Dy2l.js → extension-settings-page-BLl02GFY.js} +1 -1
  62. package/dist/gateway/static/root/assets/{file-preview-surface-CFFuUQVY.js → file-preview-surface-TGdKqhCf.js} +1 -1
  63. package/dist/gateway/static/root/assets/{gateway-config-swr-i6wzzdws.js → gateway-config-swr-DfPQIHOL.js} +1 -1
  64. package/dist/gateway/static/root/assets/{gateway-realtime-B1CCUrsG.js → gateway-realtime-67vWg_M2.js} +1 -1
  65. package/dist/gateway/static/root/assets/gateway-realtime-store-Bkt1z-xo.js +1 -0
  66. package/dist/gateway/static/root/assets/{gateway-restart-B3Odfu1z.js → gateway-restart-CLtR2wkL.js} +1 -1
  67. package/dist/gateway/static/root/assets/{gateway-settings-QIwB2Ld0.js → gateway-settings-COvC3r-l.js} +1 -1
  68. package/dist/gateway/static/root/assets/{gateway-startup-retry-DBpCoigO.js → gateway-startup-retry-9YQllbw2.js} +1 -1
  69. package/dist/gateway/static/root/assets/{global-defaults-api-GQG-5G20.js → global-defaults-api-DYMRjGvd.js} +1 -1
  70. package/dist/gateway/static/root/assets/{home-page-BsfeSXsZ.js → home-page-k9LFXcVa.js} +2 -2
  71. package/dist/gateway/static/root/assets/{image-generation-api-CaiTrM7V.js → image-generation-api-Dzydfvy8.js} +1 -1
  72. package/dist/gateway/static/root/assets/{imports-page-CLkhwelO.js → imports-page-Csd_YZXZ.js} +1 -1
  73. package/dist/gateway/static/root/assets/index-CpwPxKQ8.css +1 -0
  74. package/dist/gateway/static/root/assets/index-DKW7BeT_.js +11 -0
  75. package/dist/gateway/static/root/assets/{install-connector-dialog-B9YBBGhs.js → install-connector-dialog-CTQAKTPv.js} +1 -1
  76. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DrZQukhN.js → keyboard-shortcuts-settings-B201bMIa.js} +1 -1
  77. package/dist/gateway/static/root/assets/{local-app-workbench-page-CecbOjks.js → local-app-workbench-page-CD_8_gd_.js} +1 -1
  78. package/dist/gateway/static/root/assets/{local-apps-page-CkVtgVlJ.js → local-apps-page-BOwqNH0L.js} +1 -1
  79. package/dist/gateway/static/root/assets/local-session-drafts-DjmK-SM9.js +4 -0
  80. package/dist/gateway/static/root/assets/{locale-store-_-_QzAV0.js → locale-store-Bg_XR36n.js} +1 -1
  81. package/dist/gateway/static/root/assets/{logs-page-Dok7TpJ0.js → logs-page-gw3E9CMQ.js} +1 -1
  82. package/dist/gateway/static/root/assets/{management-settings-CNbeHUKa.js → management-settings-t_Z2mCyw.js} +1 -1
  83. package/dist/gateway/static/root/assets/{markdown-view-CFWJhIqU.js → markdown-view-BUpXJUPv.js} +1 -1
  84. package/dist/gateway/static/root/assets/{media-plugins-BEcCzwnv.js → media-plugins-_shnaEMY.js} +1 -1
  85. package/dist/gateway/static/root/assets/messages-DG4HLOER.js +3 -0
  86. package/dist/gateway/static/root/assets/model-selector-a7PIT1Lk.js +1 -0
  87. package/dist/gateway/static/root/assets/{models-hub-cache-B1dBNhhc.js → models-hub-cache-KOJC3z6Q.js} +1 -1
  88. package/dist/gateway/static/root/assets/note-detail-panel-BsHYUFgk.js +5 -0
  89. package/dist/gateway/static/root/assets/note-image-lightbox-B-bEtjhj.js +1 -0
  90. package/dist/gateway/static/root/assets/{notes-api-ja_AMIh6.js → notes-api-BSmikUKI.js} +1 -1
  91. package/dist/gateway/static/root/assets/{notes-page-_IG1mwIH.js → notes-page-CA0NRL8O.js} +1 -1
  92. package/dist/gateway/static/root/assets/{oauth-api-C0NG7Hgs.js → oauth-api-D2t9HXoC.js} +1 -1
  93. package/dist/gateway/static/root/assets/{oauth-provider-connect-DLQ6Jhjc.js → oauth-provider-connect-DGGGGtcB.js} +1 -1
  94. package/dist/gateway/static/root/assets/{page-context-capture-button-DBlILV5t.js → page-context-capture-button-BH54VO0V.js} +1 -1
  95. package/dist/gateway/static/root/assets/{page-context-draft-CcZSjlMa.js → page-context-draft-BS5y8Cx9.js} +1 -1
  96. package/dist/gateway/static/root/assets/page-header-store-BdZnUh-D.js +1 -0
  97. package/dist/gateway/static/root/assets/{personal-avatar-D3tjI4rK.js → personal-avatar-D8DtpDTa.js} +1 -1
  98. package/dist/gateway/static/root/assets/{personal-page-C1gIYjQo.js → personal-page-KJezmTKP.js} +1 -1
  99. package/dist/gateway/static/root/assets/{personal-settings-panel-Nm03jL4v.js → personal-settings-panel-9uDaNJy5.js} +1 -1
  100. package/dist/gateway/static/root/assets/{phone-dependencies-card-72RGs4eb.js → phone-dependencies-card-DLYrI0C4.js} +1 -1
  101. package/dist/gateway/static/root/assets/{phone-model-picker-CNxK_l_B.js → phone-model-picker-BbA2iI-3.js} +1 -1
  102. package/dist/gateway/static/root/assets/{phone-settings-page-D5PodpGU.js → phone-settings-page-Cg_BPss4.js} +1 -1
  103. package/dist/gateway/static/root/assets/{phone-workspace-store-Ci43KRd6.js → phone-workspace-store-CVDk80Bf.js} +1 -1
  104. package/dist/gateway/static/root/assets/plugin-details-dialog-DgibLkc3.js +1 -0
  105. package/dist/gateway/static/root/assets/{preference-select-fields-CyFvi9Es.js → preference-select-fields-BVoN-lAv.js} +1 -1
  106. package/dist/gateway/static/root/assets/{product-automation-feedback-BRdOheLC.js → product-automation-feedback-DCo90zGh.js} +2 -2
  107. package/dist/gateway/static/root/assets/{product-open-page-CIZj7rh-.js → product-open-page-OWl8IAoY.js} +1 -1
  108. package/dist/gateway/static/root/assets/{product-preview-content-yK-9po5S.js → product-preview-content-Cjas7UNe.js} +1 -1
  109. package/dist/gateway/static/root/assets/{product-preview-modal-CkdKPk-W.js → product-preview-modal-CPWRvBI9.js} +2 -2
  110. package/dist/gateway/static/root/assets/{project-detail-page-D_Kft8au.js → project-detail-page-B_HlZux_.js} +3 -3
  111. package/dist/gateway/static/root/assets/{project-understanding-6raciQr0.js → project-understanding-Ba02SFzB.js} +1 -1
  112. package/dist/gateway/static/root/assets/{projects-page-CNCw6Q5o.js → projects-page-CdfKjp95.js} +1 -1
  113. package/dist/gateway/static/root/assets/{providers-api-DGeFqpPL.js → providers-api-rwQ4LWzr.js} +1 -1
  114. package/dist/gateway/static/root/assets/{recording-upload-rA0Z6W2g.js → recording-upload-BSmvRrZQ.js} +1 -1
  115. package/dist/gateway/static/root/assets/{registry-api-5LqCHY-I.js → registry-api-Vy7LfH6E.js} +1 -1
  116. package/dist/gateway/static/root/assets/{remote-access-hub-DftT6xNt.js → remote-access-hub-UXrnpGev.js} +1 -1
  117. package/dist/gateway/static/root/assets/{resource-unavailable-CqP8gARc.js → resource-unavailable-f9OzSi4W.js} +1 -1
  118. package/dist/gateway/static/root/assets/route-preload-BtObM-co.js +2 -0
  119. package/dist/gateway/static/root/assets/{runtime-tools-api-CUzfEj0z.js → runtime-tools-api-Bt8t37z5.js} +1 -1
  120. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DU4UXnBm.js +1 -0
  121. package/dist/gateway/static/root/assets/{service-recommendation-list-Bo46zqXR.js → service-recommendation-list-CuYsRcBB.js} +1 -1
  122. package/dist/gateway/static/root/assets/{session-api-CZQ-wpwx.js → session-api-DJI9eSgw.js} +1 -1
  123. package/dist/gateway/static/root/assets/session-manager-CtKgACGl.js +23 -0
  124. package/dist/gateway/static/root/assets/sessions-page-BAsKzRHt.js +1 -0
  125. package/dist/gateway/static/root/assets/settings-advanced-gate-CjAFqg2U.js +1 -0
  126. package/dist/gateway/static/root/assets/{settings-advanced-section-CrqVxpan.js → settings-advanced-section-BxUuF_yi.js} +1 -1
  127. package/dist/gateway/static/root/assets/{settings-mode-store-D4AZlZDq.js → settings-mode-store-CaoRh2gt.js} +1 -1
  128. package/dist/gateway/static/root/assets/{settings-page-header-CoPd_JDb.js → settings-page-header-CyUHrn7c.js} +1 -1
  129. package/dist/gateway/static/root/assets/{settings-page-layout-D39EvFvm.js → settings-page-layout-DGVqXrlp.js} +1 -1
  130. package/dist/gateway/static/root/assets/{settings-page-D-X2rL2k.js → settings-page-qQ8-6dJ_.js} +1 -1
  131. package/dist/gateway/static/root/assets/setup-status-panel-BpaPb625.js +1 -0
  132. package/dist/gateway/static/root/assets/{share-link-dialog-D4oGzmxA.js → share-link-dialog-CQJ6Ykm2.js} +1 -1
  133. package/dist/gateway/static/root/assets/{share-preview-page-CArPpOZz.js → share-preview-page-Cem96FbB.js} +1 -1
  134. package/dist/gateway/static/root/assets/{shares-api-DbJOyf2K.js → shares-api-Dowes16l.js} +1 -1
  135. package/dist/gateway/static/root/assets/shares-settings-DZEkZDR0.js +1 -0
  136. package/dist/gateway/static/root/assets/{skill-api-CQxLO0sy.js → skill-api-D8ZwFEVe.js} +1 -1
  137. package/dist/gateway/static/root/assets/{skill-list-api-BkahlC5N.js → skill-list-api-B4gp00-f.js} +1 -1
  138. package/dist/gateway/static/root/assets/{skill-reload-api-DZQLAkSr.js → skill-reload-api-ClmaaDXo.js} +1 -1
  139. package/dist/gateway/static/root/assets/{skills-page-BBlJMOZU.js → skills-page-CV0X9rvG.js} +1 -1
  140. package/dist/gateway/static/root/assets/{system-settings-panel-b2h_YWsq.js → system-settings-panel-D095uacX.js} +1 -1
  141. package/dist/gateway/static/root/assets/task-detail-page-CY2C4AM2.js +2 -0
  142. package/dist/gateway/static/root/assets/{task-result-evidence-DLnPVj6x.js → task-result-evidence-LUrJlUhb.js} +1 -1
  143. package/dist/gateway/static/root/assets/{terminal-panel-store-Xmw-UfZa.js → terminal-panel-store-BqEDB1Vl.js} +1 -1
  144. package/dist/gateway/static/root/assets/{theme-store-DU_07f3M.js → theme-store-gAcojLgP.js} +1 -1
  145. package/dist/gateway/static/root/assets/tool-friendly-title-o6sxGVUu.js +1 -0
  146. package/dist/gateway/static/root/assets/tracing-settings-page-B1ZRh-Is.js +1 -0
  147. package/dist/gateway/static/root/assets/{tunnel-api-DD2HgB7G.js → tunnel-api-C9u9E3UQ.js} +1 -1
  148. package/dist/gateway/static/root/assets/{understanding-activity-store-CyQMYQhD.js → understanding-activity-store-BTrzsR6_.js} +1 -1
  149. package/dist/gateway/static/root/assets/{understanding-refresh-store-CTgQYLOe.js → understanding-refresh-store-5Qava3jh.js} +1 -1
  150. package/dist/gateway/static/root/assets/{usage-page-BUZLOZLg.js → usage-page-DFMLYKAc.js} +1 -1
  151. package/dist/gateway/static/root/assets/{use-autosave-BqTpwsvF.js → use-autosave-3O-X7x15.js} +1 -1
  152. package/dist/gateway/static/root/assets/{use-composer-attachments-DfP3JrD6.js → use-composer-attachments-BLc4dBfe.js} +1 -1
  153. package/dist/gateway/static/root/assets/{use-file-preview-expanded-D2m6BZLU.js → use-file-preview-expanded-BaOmTXsT.js} +2 -2
  154. package/dist/gateway/static/root/assets/{use-personal-profile-CmLuBSVu.js → use-personal-profile-MusPgljM.js} +1 -1
  155. package/dist/gateway/static/root/assets/{use-workspace-tree-DBvuHcas.js → use-workspace-tree-Ck_U2yTw.js} +1 -1
  156. package/dist/gateway/static/root/assets/user-model-page-Den5Lg-k.js +2 -0
  157. package/dist/gateway/static/root/assets/{voice-api-key-field-DGyL8PYB.js → voice-api-key-field-C5zJApoa.js} +1 -1
  158. package/dist/gateway/static/root/assets/{voice-config-api-CIRG9O8T.js → voice-config-api-DC1bYDt1.js} +1 -1
  159. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-DrVMpqDV.js → voice-input-shortcut-events-0SZjJdVV.js} +1 -1
  160. package/dist/gateway/static/root/assets/{voice-transcribe-api-H8o-xLEf.js → voice-transcribe-api-CxVeANPX.js} +1 -1
  161. package/dist/gateway/static/root/assets/{work-discovery-overlay-CobALTh0.js → work-discovery-overlay-DAQ8McVe.js} +1 -1
  162. package/dist/gateway/static/root/assets/{work-discovery-page-Dxf_Hrwx.js → work-discovery-page-DUQysEyb.js} +1 -1
  163. package/dist/gateway/static/root/assets/{working-directory-picker-modal-E9f8G3se.js → working-directory-picker-modal-BO9qdJyZ.js} +1 -1
  164. package/dist/gateway/static/root/assets/{workspace-api-N7bfM4a1.js → workspace-api-ZrN6yUER.js} +2 -2
  165. package/dist/gateway/static/root/assets/workspace-editor-agent-store-Bo5dwoWP.js +1 -0
  166. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BTQfAXNK.js → workspace-file-preview-dialog-Yj_kBWSb.js} +1 -1
  167. package/dist/gateway/static/root/assets/{workspace-open-location-menu-BOGOi-Ck.js → workspace-open-location-menu-yxT7wajO.js} +1 -1
  168. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Dqfy4Lwy.js → xopc-cloud-account-card-IcH9KDzx.js} +1 -1
  169. package/dist/gateway/static/root/index.html +82 -82
  170. package/dist/package.js +1 -1
  171. package/dist/packages/computer-control-contract/src/index.js +33 -3
  172. package/dist/packages/gateway-contract/src/clarification-questions.js +86 -0
  173. package/dist/packages/gateway-contract/src/clarifications.js +19 -0
  174. package/dist/packages/gateway-contract/src/index.js +1 -0
  175. package/dist/packages/gateway-contract/src/session-input-command.js +3 -0
  176. package/dist/src/agent/agent-manager.js +2 -2
  177. package/dist/src/agent/background-review/run-background-review.js +2 -2
  178. package/dist/src/agent/coding/repository-instructions.js +1 -1
  179. package/dist/src/agent/embedded/index.js +1 -1
  180. package/dist/src/agent/embedded/run-for-session.js +1 -1
  181. package/dist/src/agent/embedded/run-turn.js +67 -7
  182. package/dist/src/agent/embedded/session-tool-result-guard.js +2 -2
  183. package/dist/src/agent/embedded/tool-result-truncation.js +1 -1
  184. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  185. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  186. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  187. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  188. package/dist/src/agent/memory/compaction.js +1 -1
  189. package/dist/src/agent/memory/context-budget.js +1 -1
  190. package/dist/src/agent/memory/context-recovery.js +1 -1
  191. package/dist/src/agent/memory/user-message-text.js +1 -1
  192. package/dist/src/agent/service/btw-query.js +1 -1
  193. package/dist/src/agent/service/direct-turn-helpers.js +1 -1
  194. package/dist/src/agent/service/process-direct-streaming.js +2 -2
  195. package/dist/src/agent/service.js +1 -1
  196. package/dist/src/agent/skills/index.js +1 -1
  197. package/dist/src/agent/skills/managed-store.js +1 -1
  198. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  199. package/dist/src/agent/source-context/types.d.ts +1 -0
  200. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  201. package/dist/src/agent/tool-manuals/computer.js +6 -0
  202. package/dist/src/agent/tools/clarify-tool.js +43 -5
  203. package/dist/src/agent/tools/cli-clarify.js +1 -0
  204. package/dist/src/agent/tools/computer-use-tool.js +18 -5
  205. package/dist/src/agent/tools/dataBatch.js +1 -1
  206. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  207. package/dist/src/agent/tools/personal-task-tool.d.ts +1 -1
  208. package/dist/src/agent/tools/phone-use-tool.js +14 -4
  209. package/dist/src/agent/tools/session-search-tool.js +1 -1
  210. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  211. package/dist/src/agent-catalog/capabilities.js +2 -2
  212. package/dist/src/agent-catalog/repository.js +1 -1
  213. package/dist/src/automations/api/routes.js +2 -2
  214. package/dist/src/automations/capabilities/drafts.js +1 -1
  215. package/dist/src/automations/capabilities/write.js +1 -1
  216. package/dist/src/automations/configuration-conversation.js +1 -1
  217. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  218. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  219. package/dist/src/capabilities/runtime/product.js +1 -1
  220. package/dist/src/cli/commands/agent.js +1 -1
  221. package/dist/src/cli/commands/agents.js +1 -1
  222. package/dist/src/cli/commands/backup.js +1 -1
  223. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  224. package/dist/src/cli/commands/models.js +2 -2
  225. package/dist/src/cli/commands/onboard/model.js +1 -1
  226. package/dist/src/cli/commands/onboard.js +1 -1
  227. package/dist/src/cli/commands/platform.js +1 -1
  228. package/dist/src/cli/commands/profile.js +1 -1
  229. package/dist/src/cli/commands/tunnel.js +1 -1
  230. package/dist/src/cli/commands/update.js +1 -1
  231. package/dist/src/cli/extension-cli-register.js +1 -1
  232. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  233. package/dist/src/computer/agent-context.d.ts +21 -0
  234. package/dist/src/computer/agent-context.js +107 -0
  235. package/dist/src/computer/broker.d.ts +4 -2
  236. package/dist/src/computer/broker.js +26 -11
  237. package/dist/src/computer/diagnostics.d.ts +63 -9
  238. package/dist/src/computer/diagnostics.js +45 -4
  239. package/dist/src/computer/errors.d.ts +1 -1
  240. package/dist/src/computer/errors.js +4 -0
  241. package/dist/src/computer/evaluation.d.ts +4 -4
  242. package/dist/src/computer/native-timing.d.ts +15 -0
  243. package/dist/src/computer/native-timing.js +49 -0
  244. package/dist/src/computer/program-runtime.d.ts +22 -0
  245. package/dist/src/computer/program-runtime.js +105 -0
  246. package/dist/src/computer/runtime.d.ts +36 -2
  247. package/dist/src/computer/runtime.js +269 -58
  248. package/dist/src/config/agent-profile.js +1 -1
  249. package/dist/src/config/index.js +1 -1
  250. package/dist/src/config/schema.d.ts +18 -0
  251. package/dist/src/connectors/learning-coordinator.js +1 -1
  252. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  253. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  254. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  255. package/dist/src/gateway/agents-admin.js +2 -2
  256. package/dist/src/gateway/ephemeral-clarification-waiter.js +1 -0
  257. package/dist/src/gateway/global-defaults-admin.js +2 -2
  258. package/dist/src/gateway/hono/routes/agents.js +1 -1
  259. package/dist/src/gateway/hono/routes/composer-history.js +1 -1
  260. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  261. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  262. package/dist/src/gateway/hono/routes/home.js +1 -1
  263. package/dist/src/gateway/hono/routes/notes.js +2 -2
  264. package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
  265. package/dist/src/gateway/hono/routes/phone.js +31 -6
  266. package/dist/src/gateway/hono/routes/projects.js +2 -2
  267. package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
  268. package/dist/src/gateway/hono/routes/session-command-handler.js +1 -0
  269. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +6 -0
  270. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  271. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  272. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  273. package/dist/src/gateway/image-generation-setup.js +1 -1
  274. package/dist/src/gateway/next-turn-suggestions/snapshot.js +1 -1
  275. package/dist/src/gateway/service/agent-runner.js +8 -3
  276. package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
  277. package/dist/src/gateway/service/run-gateway-agent.js +1 -1
  278. package/dist/src/gateway/service/session-input-coordinator.js +5 -4
  279. package/dist/src/gateway/service.js +7 -7
  280. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  281. package/dist/src/home-intelligence/host.js +2 -2
  282. package/dist/src/imports/importService.js +1 -1
  283. package/dist/src/local-apps/service.js +1 -1
  284. package/dist/src/personal-agent/service.js +1 -1
  285. package/dist/src/phone/adb-driver.d.ts +15 -1
  286. package/dist/src/phone/adb-driver.js +104 -41
  287. package/dist/src/phone/assistance.js +3 -0
  288. package/dist/src/phone/autoglm-protocol.d.ts +36 -0
  289. package/dist/src/phone/autoglm-protocol.js +88 -0
  290. package/dist/src/phone/autoglm-upstream-prompt.d.ts +2 -0
  291. package/dist/src/phone/autoglm-upstream-prompt.js +5 -0
  292. package/dist/src/phone/autoglm-upstream.LICENSE +201 -0
  293. package/dist/src/phone/cloud-adb-connection.d.ts +3 -0
  294. package/dist/src/phone/cloud-adb-connection.js +102 -31
  295. package/dist/src/phone/cloud-adb.js +18 -6
  296. package/dist/src/phone/completion-recovery.d.ts +6 -0
  297. package/dist/src/phone/completion-recovery.js +30 -0
  298. package/dist/src/phone/contracts.d.ts +24 -0
  299. package/dist/src/phone/contracts.js +6 -0
  300. package/dist/src/phone/execution-trace.d.ts +51 -0
  301. package/dist/src/phone/execution-trace.js +78 -0
  302. package/dist/src/phone/model-adapter.d.ts +9 -1
  303. package/dist/src/phone/model-adapter.js +132 -61
  304. package/dist/src/phone/model-response.d.ts +5 -0
  305. package/dist/src/phone/model-response.js +118 -0
  306. package/dist/src/phone/runtime.d.ts +11 -1
  307. package/dist/src/phone/runtime.js +177 -40
  308. package/dist/src/phone/text-session.d.ts +14 -0
  309. package/dist/src/phone/text-session.js +39 -0
  310. package/dist/src/phone/ui-dump-binary.d.ts +1 -1
  311. package/dist/src/phone/ui-dump-binary.js +1 -1
  312. package/dist/src/phone/ui-session.d.ts +22 -0
  313. package/dist/src/phone/ui-session.js +191 -0
  314. package/dist/src/process/phone-process.d.ts +1 -0
  315. package/dist/src/process/phone-process.js +11 -1
  316. package/dist/src/routing/agent-session-key.js +1 -1
  317. package/dist/src/runtime-tools/archive.js +1 -1
  318. package/dist/src/session/session-context-for-llm.js +1 -0
  319. package/dist/src/session/session-title.js +1 -1
  320. package/dist/src/storage/sqlite/clarification-wait-repository.js +45 -4
  321. package/dist/src/storage/sqlite/index.js +6 -6
  322. package/dist/src/storage/sqlite/session-creation-repository.js +1 -1
  323. package/dist/src/storage/sqlite/session-repository.js +1 -1
  324. package/dist/src/tasks/capabilities/read.js +2 -2
  325. package/dist/src/tasks/capabilities/write.js +1 -1
  326. package/dist/src/tasks/home-query-service.js +1 -1
  327. package/dist/src/tasks/task-allocation-repository.js +1 -1
  328. package/dist/src/tui/backends/embedded-backend.js +2 -2
  329. package/dist/src/voice/realtime/persona-context.js +1 -1
  330. package/package.json +3 -1
  331. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-L6J-FYQS.js +0 -1
  332. package/dist/gateway/static/root/assets/automation-task-card-BV7hPwN1.js +0 -3
  333. package/dist/gateway/static/root/assets/automations-workspace-CPFYdI8m.js +0 -9
  334. package/dist/gateway/static/root/assets/capabilities-page-ljQTg4T5.js +0 -2
  335. package/dist/gateway/static/root/assets/chat-page-BpvlJdEr.js +0 -72
  336. package/dist/gateway/static/root/assets/connected-providers-grid-BIX82L4N.js +0 -1
  337. package/dist/gateway/static/root/assets/connectors-page-BawS0DUd.js +0 -1
  338. package/dist/gateway/static/root/assets/device-pairing-wizard-ZY_cdq5I.js +0 -1
  339. package/dist/gateway/static/root/assets/gateway-realtime-store-BFCA_TAU.js +0 -1
  340. package/dist/gateway/static/root/assets/index-Dv8mUlNN.css +0 -1
  341. package/dist/gateway/static/root/assets/index-GX_PTIj6.js +0 -11
  342. package/dist/gateway/static/root/assets/local-session-drafts-DVSVgTCK.js +0 -1
  343. package/dist/gateway/static/root/assets/messages-D1u8VsPq.js +0 -3
  344. package/dist/gateway/static/root/assets/model-selector-DKB20MJY.js +0 -1
  345. package/dist/gateway/static/root/assets/note-detail-panel-COp5zpe4.js +0 -5
  346. package/dist/gateway/static/root/assets/note-image-lightbox-DvtEn8dg.js +0 -1
  347. package/dist/gateway/static/root/assets/page-header-store-RgQRaRbH.js +0 -1
  348. package/dist/gateway/static/root/assets/plugin-details-dialog-D_Lkepqt.js +0 -1
  349. package/dist/gateway/static/root/assets/route-preload-Hr12PIMD.js +0 -2
  350. package/dist/gateway/static/root/assets/runtime-impact-DbySfhdp.js +0 -1
  351. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-VIFAEKJi.js +0 -1
  352. package/dist/gateway/static/root/assets/session-manager-DhoRfUGE.js +0 -23
  353. package/dist/gateway/static/root/assets/sessions-page-BISYL6iE.js +0 -1
  354. package/dist/gateway/static/root/assets/settings-advanced-gate-BLnNiubD.js +0 -1
  355. package/dist/gateway/static/root/assets/setup-status-panel-DyzdCgrb.js +0 -1
  356. package/dist/gateway/static/root/assets/shares-settings-BFLomErf.js +0 -1
  357. package/dist/gateway/static/root/assets/task-detail-page-BkvjB6fd.js +0 -2
  358. package/dist/gateway/static/root/assets/tool-friendly-title-DGmi7rCQ.js +0 -1
  359. package/dist/gateway/static/root/assets/tracing-settings-page-CemIMuec.js +0 -1
  360. package/dist/gateway/static/root/assets/user-model-page-BhX_Ahlu.js +0 -2
  361. package/dist/gateway/static/root/assets/workspace-editor-agent-store-Cb4TlnKX.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,m as a,t as o,u as s}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as c,l,n as u,o as d}from"./locale-store-Bg_XR36n.js";import{G as f,W as p,t as m,w as h}from"./chat-page-BP0huA-W.js";import{t as g}from"./arrow-left-D880xG-P.js";import{t as _}from"./calendar-clock-D-quYVPe.js";import{n as v,r as y}from"./popover-select-DD8fmrxH.js";import{t as b}from"./circle-check-C23XjkUj.js";import{t as x}from"./circle-x-DFsCKeya.js";import{t as S}from"./circle-BoO4YvTx.js";import{t as C}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{t as te}from"./folder-kanban-CpLlFI1o.js";import{t as w}from"./folder-open-CyzJ19I9.js";import{F as ne,N as T,V as E,z as D}from"./markdown-view-BUpXJUPv.js";import{t as O}from"./message-square-fVE7Ghj1.js";import{t as re}from"./pause-DuPxgSxk.js";import{t as ie}from"./play-kxZvpBg8.js";import{t as ae}from"./x-B_N4OPjy.js";import{t as k}from"./cn-0WouolD0.js";import{t as A}from"./button-CnRSIP6m.js";import{t as j}from"./skeleton-BI5TyibZ.js";import{s as oe}from"./file-preview-surface-TGdKqhCf.js";import{i as se,n as ce,o as M,r as le,s as N,t as ue}from"./dist-DfWfZ9iu.js";import{i as de}from"./vendor-swr-CdRzEUwF.js";import{at as fe,ot as pe}from"./session-manager-CtKgACGl.js";import{c as me}from"./api-Boc-CVh7.js";import{d as he,f as ge,h as _e,m as ve,p as ye,s as be}from"./composer-payload-handoff-CYIhcczq.js";import{C as xe,D as Se,T as Ce,d as we,f as Te,k as Ee,m as De,y as Oe}from"./use-composer-attachments-BLc4dBfe.js";import{t as ke}from"./page-header-store-BdZnUh-D.js";import{t as Ae}from"./agent-avatar-display-YqmwzOSa.js";import{t as je}from"./chat-agents-api-B8JO6Tcj.js";import{t as Me}from"./confirm-dialog-XGclfBqe.js";import{l as Ne,m as Pe,o as Fe,r as P,t as Ie,u as Le}from"./dist-D3lWNSe7.js";import{t as Re}from"./date-picker-D_PSHGpe.js";import{t as ze}from"./automation-api-CZqL9l_d.js";import{n as Be}from"./date-formatters-DukWSVwc.js";import{n as Ve,r as F,t as He}from"./task-result-evidence-LUrJlUhb.js";import{t as Ue}from"./page-context-capture-button-BH54VO0V.js";import{t as We}from"./dependency-picker-UqKVJ9dv.js";var I=n(),L=r();function Ge(e){let t=(0,I.c)(33),{changes:n,language:r}=e,i=r===`zh`,a;t[0]===i?a=t[1]:(a=i?{backlog:`待办池`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`},t[0]=i,t[1]=a);let o=a,s;t[2]===i?s=t[3]:(s=i?{board:`看板`,mobile:`移动端`,api:`手动操作`,runtime:`自动流转`,undo:`撤销`}:{board:`Board`,mobile:`Mobile`,api:`Manual update`,runtime:`Automatic`,undo:`Undo`},t[2]=i,t[3]=s);let c=s,l;t[4]===i?l=t[5]:(l=i?{done:`完成`,cancelled:`取消`,duplicate:`重复`,wont_do:`不做`}:{done:`Done`,cancelled:`Cancelled`,duplicate:`Duplicate`,wont_do:`Won’t do`},t[4]=i,t[5]=l);let u=l,d;t[6]===i?d=t[7]:(d=i?{user:`用户`,agent:`Agent`,system:`系统`,integration:`外部服务`}:{user:`User`,agent:`Agent`,system:`System`,integration:`Integration`},t[6]=i,t[7]=d);let f=d,p=i?`变更记录`:`Change log`,m;t[8]!==n.length||t[9]!==p?(m=(0,L.jsxs)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:[p,` (`,n.length,`)`]}),t[8]=n.length,t[9]=p,t[10]=m):m=t[10];let h;if(t[11]!==f||t[12]!==n||t[13]!==r||t[14]!==o||t[15]!==u||t[16]!==c){let e;t[18]!==f||t[19]!==r||t[20]!==o||t[21]!==u||t[22]!==c?(e=e=>(0,L.jsxs)(`li`,{className:`text-sm text-fg`,children:[(0,L.jsxs)(`div`,{children:[o[e.fromPhase],e.fromResolution?` · ${u[e.fromResolution]}`:``,` → `,o[e.toPhase],e.toResolution?` · ${u[e.toResolution]}`:``]}),(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[f[e.actor.kind],e.actor.id?` (${e.actor.id})`:``,` · `,c[e.source],` · `,(0,L.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),children:Be(e.createdAt,r)})]})]},e.id),t[18]=f,t[19]=r,t[20]=o,t[21]=u,t[22]=c,t[23]=e):e=t[23],h=[...n].reverse().map(e),t[11]=f,t[12]=n,t[13]=r,t[14]=o,t[15]=u,t[16]=c,t[17]=h}else h=t[17];let g;t[24]===h?g=t[25]:(g=(0,L.jsx)(`ol`,{className:`mt-3 max-h-80 space-y-3 overflow-y-auto`,children:h}),t[24]=h,t[25]=g);let _;t[26]!==n.length||t[27]!==i?(_=n.length?null:(0,L.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:i?`暂无阶段变更记录`:`No phase changes yet`}),t[26]=n.length,t[27]=i,t[28]=_):_=t[28];let v;return t[29]!==m||t[30]!==g||t[31]!==_?(v=(0,L.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[m,g,_]}),t[29]=m,t[30]=g,t[31]=_,t[32]=v):v=t[32],v}function Ke(e){let t=(0,I.c)(36),{detail:n,language:r,onUpdated:i}=e,a=r===`zh`,s;t[0]===n.waits?s=t[1]:(s=n.waits.find(Ye),t[0]=n.waits,t[1]=s);let c=s,l,u,d,f,p,m,h;if(t[2]!==n||t[3]!==r||t[4]!==i||t[5]!==c||t[6]!==a){l=n.allowedCommands.includes(`resolve_wait`)&&!c?n.waits.filter(Je):[];let e=l.length>0||n.attention.some(qe),s;t[14]===n?s=t[15]:(s=ge(n),t[14]=n,t[15]=s);let g=s,_=n.runs.some(R);d=c?.reason??n.waits[0]?.reason??(n.task.phase===`closed`?a?`任务已关闭,可查看交付物与执行结果。`:`The task is closed. Review its deliverables and results.`:n.task.phase===`review`?a?`请检查交付物与验收项,通过后确认完成。`:`Review the deliverables and acceptance criteria before completing the task.`:_?a?`Agent 正在执行任务,无需你操作。`:`The agent is working. No action is needed from you.`:g?.summary??(a?`任务尚未开始,可开始执行或设置执行时间。`:`Start the task or set an execution time.`)),u=n.attention.length>0?(0,L.jsx)(`ul`,{className:`mt-3 space-y-3`,children:n.attention.map((e,t)=>{let i=l.some(t=>e.kind===`input_required`&&t.kind===`user_input`||e.kind===`approval_required`&&t.kind===`approval`);return(0,L.jsxs)(`li`,{className:`text-sm leading-6 text-fg-muted`,children:[(0,L.jsx)(F,{content:e.summary,contentKey:`${n.task.id}:attention:${e.kind}:${t}`,language:r,markdown:!1,previewHeight:72}),!i&&(e.kind===`input_required`||e.kind===`approval_required`)?(0,L.jsx)(o,{className:`mt-2 inline-flex min-h-11 items-center rounded-lg bg-accent-soft px-3 font-medium text-accent-fg`,to:T(n.task.id),children:a?e.kind===`approval_required`?`查看并决定`:`补充信息`:e.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${e.kind}-${t}`)})}):null,f=a?`当前需要处理`:`Current action`,p=`rounded-xl border border-edge bg-surface-panel p-4`;let v=e?a?`需要你处理`:`Your action needed`:a?`当前进展`:`Current progress`,y=l.length>1?` · ${l.length}`:``;t[16]!==v||t[17]!==y?(m=(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[v,y]}),t[16]=v,t[17]=y,t[18]=m):m=t[18];let b;t[19]!==n||t[20]!==i||t[21]!==a?(b=e=>(0,L.jsx)(Ve,{wait:e,detail:n,zh:a,onUpdated:i},e.id),t[19]=n,t[20]=i,t[21]=a,t[22]=b):b=t[22],h=l.map(b),t[2]=n,t[3]=r,t[4]=i,t[5]=c,t[6]=a,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h}else l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13];let g;t[23]!==l.length||t[24]!==u||t[25]!==n.task||t[26]!==r||t[27]!==d||t[28]!==a?(g=l.length>0?u?(0,L.jsxs)(`details`,{className:`mt-3`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:a?`等待详情`:`Waiting details`}),u]}):null:u??(0,L.jsx)(F,{content:d,contentKey:`${n.task.id}:current-progress`,language:r,markdown:!1,previewHeight:72,className:`mt-2 text-sm leading-6 text-fg-muted`}),t[23]=l.length,t[24]=u,t[25]=n.task,t[26]=r,t[27]=d,t[28]=a,t[29]=g):g=t[29];let _;return t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==g?(_=(0,L.jsxs)(`section`,{"aria-label":f,className:p,children:[m,h,g]}),t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=g,t[35]=_):_=t[35],_}function R(e){return!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)}function qe(e){return e.kind===`input_required`||e.kind===`approval_required`}function Je(e){return(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`}function Ye(e){return e.kind===`paused`}var z=e(t(),1);function Xe(e){let t=(0,I.c)(17),{children:n,contentKey:r,language:i,className:o}=e,s=(0,z.useId)(),c=z.Children.toArray(n),[l,u]=a(),d;t[0]!==r||t[1]!==l?(d=l.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=l,t[2]=d):d=t[2];let f=d,p=f?c:c.slice(0,3),m;t[3]!==s||t[4]!==p?(m=(0,L.jsx)(`ul`,{id:s,className:`space-y-1.5`,children:p}),t[3]=s,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==r||t[7]!==f||t[8]!==s||t[9]!==c.length||t[10]!==i||t[11]!==u?(h=c.length>3?(0,L.jsx)(`button`,{type:`button`,"aria-expanded":f,"aria-controls":s,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>u(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);return t.delete(`taskExpanded`),n.forEach(e=>t.append(`taskExpanded`,e)),f||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:i===`zh`?f?`收起`:`查看全部(${c.length})`:f?`Show less`:`Show all (${c.length})`}):null,t[6]=r,t[7]=f,t[8]=s,t[9]=c.length,t[10]=i,t[11]=u,t[12]=h):h=t[12];let g;return t[13]!==o||t[14]!==m||t[15]!==h?(g=(0,L.jsxs)(`div`,{className:o,children:[m,h]}),t[13]=o,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function Ze({taskId:e}){let t=l(e=>e.conversationId),n=u(e=>e.language),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(null),[s,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)([]),[_,v]=(0,z.useState)(null),y=c(`/api/tasks/${encodeURIComponent(e)}/collaboration`),{data:b,error:x,mutate:S}=de([`task-collaboration`,e,t],()=>d(`${y}?recent=1`),{revalidateOnFocus:!0}),C=[...new Map([...h,...b?.items??[]].map(e=>[e.id,e])).values()].sort((e,t)=>e.sequence-t.sequence),ee=async()=>{let e=C[0];if(!(!e||p)){m(!0);try{let t=await d(`${y}?recent=1&beforeSequence=${e.sequence}`);g(e=>[...t.items,...e])}catch(e){v(e instanceof Error?e.message:String(e))}finally{m(!1)}}};(0,z.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.taskId||n.taskId===e)&&S()};return window.addEventListener(`task-collaboration-entry-added`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`task-collaboration-entry-added`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[S,e]);let te=async()=>{if(!(!r.trim()||s)){f(!0),v(null);try{await d(y,{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({kind:a?`answer`:`instruction`,body:r.trim(),...a?{causationId:a}:{}})}),i(``),o(null),await S()}catch(e){v(e instanceof Error?e.message:String(e))}finally{f(!1)}}};return(0,L.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n===`zh`?`任务留言`:`Task updates`}),(0,L.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto`,children:[!b&&!x?(0,L.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,L.jsx)(j,{className:`h-14 w-full`}),(0,L.jsx)(j,{className:`h-14 w-4/5`})]}):null,x?(0,L.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n===`zh`?`暂时无法读取留言`:`Updates unavailable`}):null,C[0]&&C[0].sequence>1?(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void ee(),className:`text-xs text-accent hover:underline disabled:opacity-50`,children:n===`zh`?`查看更早留言`:`Earlier updates`}):null,C.map(t=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-sm`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,L.jsx)(`span`,{children:t.authorKind===`worker_agent`?n===`zh`?`执行 Agent`:`Worker`:t.authorKind===`main_agent`?n===`zh`?`主 Agent`:`Main Agent`:t.authorKind===`system`?n===`zh`?`系统`:`System`:n===`zh`?`用户`:`You`}),(0,L.jsxs)(`span`,{children:[`· `,t.kind]}),t.deliveryStatus?(0,L.jsxs)(`span`,{children:[`· `,t.deliveryStatus]}):null]}),(0,L.jsx)(`div`,{className:`mt-1 min-w-0 text-fg`,"data-task-collaboration-body":!0,children:(0,L.jsx)(F,{content:t.body,contentKey:`${e}:update:${t.id}`,language:n,breaks:!0,previewHeight:120})}),t.kind===`question`&&t.authorKind===`worker_agent`?(0,L.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-accent hover:underline`,onClick:()=>o(t.id),children:n===`zh`?`回复问题`:`Reply`}):null]},t.id)),b&&!C.length?(0,L.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n===`zh`?`暂无进展留言`:`No updates yet`}):null]}),a?(0,L.jsxs)(`p`,{className:`mt-3 text-xs text-accent`,children:[n===`zh`?`正在回复执行 Agent 的问题`:`Replying to the worker`,(0,L.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:()=>o(null),children:n===`zh`?`取消`:`Cancel`})]}):null,(0,L.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),rows:2,"aria-label":n===`zh`?`任务留言`:`Task message`,placeholder:n===`zh`?`给执行 Agent 留言`:`Message the worker`,className:`mt-3 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),_?(0,L.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-danger`,children:_}):null,(0,L.jsx)(`button`,{type:`button`,disabled:!r.trim()||s,onClick:()=>void te(),className:`mt-2 rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white disabled:opacity-50`,children:s?n===`zh`?`发送中`:`Sending`:n===`zh`?`发送`:`Send`})]})}function Qe(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function $e(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}function B(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`})[e]}function et(){let e=(0,I.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,L.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,L.jsx)(j,{className:`h-32 rounded-2xl`}),(0,L.jsx)(j,{className:`h-52 rounded-2xl`}),(0,L.jsx)(j,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function tt(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function nt(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var rt=[`backlog`,`ready`,`active`,`review`,`closed`],it=[`low`,`normal`,`high`,`critical`],at=(0,z.memo)(function(e){let t=(0,I.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&!i&&!(e===`closed`?a:n===`closed`&&o),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,L.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=rt.map(e=>(0,L.jsx)(y,{value:e,disabled:d(e),children:B(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let h;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(h=(0,L.jsx)(v,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=h):h=t[16];let g;return t[17]!==f||t[18]!==h?(g=(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,h]}),t[17]=f,t[18]=h,t[19]=g):g=t[19],g}),ot=(0,z.memo)(function(e){let t=(0,I.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,L.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=it.map(e=>(0,L.jsx)(y,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,L.jsx)(v,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),st=(0,z.memo)(function(e){let t=(0,I.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,L.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,L.jsx)(Re,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),ct=(0,z.memo)(function(e){let t=(0,I.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,L.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,L.jsx)(y,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(H),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,L.jsxs)(v,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,L.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),lt=(0,z.memo)(function(e){let t=(0,I.c)(9),{candidates:n,selected:r,disabled:i,labels:a,getTaskHref:o,onChange:s}=e,c;t[0]===r?c=t[1]:(c=r.map(Ct),t[0]=r,t[1]=c);let l;return t[2]!==n||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,L.jsx)(We,{borderless:!0,candidates:n,selectedIds:c,disabled:i,getTaskHref:o,onChange:s,labels:a}),t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.getTaskHref===t.getTaskHref&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),ut=`xopc.taskDetail.chatPanelPercent`,dt=42;function ft(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?dt:Math.min(r,Math.max(n,e))}function pt(){try{let e=Number(window.localStorage.getItem(ut));return Number.isFinite(e)&&e>=30&&e<=60?e:dt}catch{return dt}}function mt(e){let t=(0,I.c)(13),{items:n,empty:r,contentKey:i}=e,a=u(gt);if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,L.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let o;t[2]===n?o=t[3]:(o=n.join(`
2
+ `),t[2]=n,t[3]=o);let s;t[4]===n?s=t[5]:(s=n.map(ht),t[4]=n,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,L.jsx)(`ul`,{className:`space-y-2`,children:s}),t[6]=s,t[7]=c);let l;return t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==c?(l=(0,L.jsx)(F,{content:o,contentKey:i,language:a,previewHeight:144,children:c}),t[8]=i,t[9]=a,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function ht(e){return(0,L.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,L.jsx)(S,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,L.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]},e)}function gt(e){return e.language}function _t({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=a(),c=s(),d=u(e=>e.language),v=l(e=>e.conversationId),y=(0,z.useMemo)(()=>he(d),[d]),ae=ke(e=>e.setPageHeader),j=ke(e=>e.clearPageHeader),se=oe(e=>e.panes),ce=h(e=>e.openForSession),{data:M,error:le,mutate:N,lastChange:ue,conversationLoading:be,conversationError:Re}=p(e),{data:Ve}=de(e?`task-detail-automations`:null,()=>ze.list()),[We,I]=(0,z.useState)(null),[R,qe]=(0,z.useState)(()=>new Set),[Je,Ye]=(0,z.useState)([]),[B,rt]=(0,z.useState)(null),[it,ht]=(0,z.useState)([]),[gt,_t]=(0,z.useState)(!1),[vt,yt]=(0,z.useState)(``),[bt,V]=(0,z.useState)(!1),[xt,St]=(0,z.useState)(``),[H,Ct]=(0,z.useState)(pt),[wt,Tt]=(0,z.useState)(!1),Et=(0,z.useRef)(null),Dt=(0,z.useRef)(null),Ot=(0,z.useRef)(null),kt=(0,z.useRef)(!1),At=(0,z.useRef)(!1),jt=(0,z.useRef)(``),Mt=(0,z.useRef)(null),Nt=(0,z.useRef)(null),Pt=(0,z.useRef)(null),U=(0,z.useRef)(M),[Ft,W]=(0,z.useState)(null),[It,Lt]=(0,z.useState)(null),[Rt,zt]=(0,z.useState)(!1),Bt=(0,z.useMemo)(()=>({link:y.linkDependencies,linked:y.linkedDependencies,searchPlaceholder:y.dependencySearchPlaceholder,noMatches:y.noDependencyMatches,noCandidates:y.noDependencyCandidates,remove:y.removeDependency}),[y.dependencySearchPlaceholder,y.linkDependencies,y.linkedDependencies,y.noDependencyCandidates,y.noDependencyMatches,y.removeDependency]),Vt=M?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,Ht=(0,z.useMemo)(()=>D(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]),Ut=(0,z.useCallback)(e=>t===`modal`&&n?ne(n,e):E(`/tasks/${encodeURIComponent(e)}`,Ht),[n,t,Ht]);U.current=M;let G=(0,z.useCallback)((e,t)=>{qe(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,z.useEffect)(()=>{I(null),W(null),_t(!1),Mt.current=null,V(!1),Lt(null),zt(!1)},[e]),(0,z.useEffect)(()=>{let e=!0;return je().then(t=>{e&&ht(t.items)}).catch(()=>void 0),()=>{e=!1}},[v]),(0,z.useEffect)(()=>{if(!ue||ue.source===`user`)return;Lt(ue);let e=window.setTimeout(()=>Lt(null),3500);return()=>window.clearTimeout(e)},[ue]),(0,z.useEffect)(()=>{let t=M?.task.projectId,n=M?.dependencies??[];if(!t){Pt.current=null,rt(null),Ye(n);return}Pt.current!==t&&(Pt.current=t,rt(null));let r=!0;return me(t).then(t=>{if(!r)return;rt(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});Ye([...i.values()])}).catch(()=>{r&&Ye(n)}),()=>{r=!1}},[Vt,M?.task.projectId,e]);let K=(0,z.useCallback)(async(t,n=`command`)=>{let r=U.current;if(r){G(n,!0),I(null);try{await N(await Te(e,t,r.task.version),{revalidate:!1})}catch{I(y.actionFailed)}finally{G(n,!1)}}},[y.actionFailed,N,G,e]),q=(0,z.useCallback)(async(t,n)=>{let r=U.current;if(!r)return!1;n&&G(n,!0),I(null);try{let n=Se(e,t,r.task.version);return await N(n,{optimisticData:$e(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return I(y.actionFailed),!1}finally{n&&G(n,!1)}},[y.actionFailed,N,G,e]),Wt=()=>{M&&(Mt.current={value:M.task.title,version:M.task.version},W(null),yt(M.task.title),_t(!0))},Gt=()=>{kt.current=!0,yt(U.current?.task.title??``),Mt.current=null,W(null),_t(!1),queueMicrotask(()=>{kt.current=!1})},Kt=async(e=!1)=>{if(kt.current){kt.current=!1;return}let t=U.current;if(!t||R.has(`title`))return;let n=vt.trim();if(!n){Gt();return}let r=Mt.current;if(!e&&Qe(r,t.task.version,t.task.title,n)){W(`title`);return}if(n===t.task.title){Gt();return}await q({title:n},`title`)&&(Mt.current=null,W(null),_t(!1))},qt=async()=>{if(!M)return;if(At.current){At.current=!1;return}let e=xt.trim(),t=Nt.current;if(Qe(t,M.task.version,M.task.body??``,e)){W(`description`);return}if(xt===jt.current||e===(M.task.body??``).trim()){V(!1);return}await q({body:fe(M.task.body??``,e)||null})&&(W(null),V(!1))},Jt=(0,z.useCallback)(async e=>{let t=U.current;!t||e===t.task.phase||await K({type:`move`,phase:e},`phase`)},[K]),Yt=(0,z.useCallback)(e=>{q({priority:e},`priority`)},[q]),Xt=(0,z.useCallback)(e=>{q({dueAt:nt(e)},`dueAt`)},[q]),Zt=(0,z.useCallback)(e=>{Ct(e);try{window.localStorage.setItem(ut,String(e))}catch{}},[]),Qt=(0,z.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=Ot.current?.clientWidth??0,n=e.key===`Home`?dt:H+(e.key===`ArrowLeft`?2:-2);Zt(ft(n,t))},[H,Zt]),$t=(0,z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=Ot.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),Tt(!0);let i=H,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=ft((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}Tt(!1),Zt(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[H,Zt]),en=(0,z.useCallback)(async t=>{let n=U.current;if(n){G(`dependencies`,!0),I(null);try{await N(await Ee(e,t,n.task.version),{revalidate:!1})}catch{I(y.dependencyUpdateFailed)}finally{G(`dependencies`,!1)}}},[y.dependencyUpdateFailed,N,G,e]),tn=(0,z.useCallback)(async t=>{let n=U.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){G(`delegateAgentId`,!0),I(null);try{await N(await Oe(e,t,n.task.version),{revalidate:!1})}catch{I(y.actionFailed)}finally{G(`delegateAgentId`,!1)}}},[y.actionFailed,N,G,e]),nn=(0,z.useCallback)(async()=>{G(`delete`,!0),I(null);try{await De(e),r?r():c(Ht,{replace:!0})}catch(e){I(e instanceof Error?e.message:y.actionFailed)}finally{G(`delete`,!1)}},[y.actionFailed,c,r,Ht,G,e]),rn=(0,z.useCallback)(async(t,n)=>{let r=U.current;if(r){G(`acceptance`,!0),I(null);try{await N(await xe(e,t,n,r.task.version,r.task.latestContractVersion),{revalidate:!1})}catch{I(y.actionFailed),await N()}finally{G(`acceptance`,!1)}}},[y.actionFailed,N,G,e]);if((0,z.useLayoutEffect)(()=>{if(t!==`modal`)return ae({startExtra:(0,L.jsx)(o,{to:Ht,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":y.backToWork,children:(0,L.jsx)(g,{className:`size-4`})}),main:M?(0,L.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${y.taskLabel}`:y.taskLabel}):null,end:null}),j},[j,y.backToWork,y.taskLabel,M,t,B,Ht,ae]),le&&!M)return(0,L.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:y.taskNotFound});if(!M)return(0,L.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,L.jsx)(et,{})});let J=M.waits[0],Y=_e(M),an=Y.length>0&&Y.every(e=>e.status===`passed`),on=M.waits.find(e=>e.kind===`paused`),X=ge(M),sn=ye(M),cn=y.detailStatuses[sn],ln=pe(M.task.body?.trim()||M.task.contract?.objective.trim()||``),un=M.allowedCommands.includes(`mark_ready`),dn=M.allowedCommands.includes(`start`),fn=M.allowedCommands.includes(`add_wait`),pn=!J&&an&&M.task.phase===`review`&&M.allowedCommands.includes(`close`),mn=M.allowedCommands.includes(`reopen`),Z=M.conversation.activeConversationId,Q=M.conversation.currentExecutorAgentId??M.task.delegateAgentId??M.task.ownerId,hn=it.find(e=>e.id===Q),gn=!!(Z&&se[Z]?.open),_n=M.context.filter(e=>e.role===`deliverable`),vn=new Set(M.runs.filter(e=>e.contractVersion===M.task.latestContractVersion).map(e=>e.id)),yn=[...new Map(M.receipts.filter(e=>vn.has(e.runId)).flatMap(e=>e.evidence.filter(e=>e.kind===`artifact`)).map(e=>[e.uri??e.title,e])).values()],bn=M.context.filter(e=>e.role!==`deliverable`),xn=Ve?.automations.filter(t=>t.action.kind===`task_command`&&t.action.taskId===e)??[],$=M.sessions.filter((e,t,n)=>n.findIndex(t=>t.conversationId===e.conversationId)===t),Sn=M.task.contract?.expectedOutputs??[],Cn=M.task.contract?.constraints??[],wn=M.task.contract?.approvalRequired??[],Tn=M.task.contract?.assumptions??[],En=M.task.contract?.risks??[],Dn=Cn.length>0||wn.length>0||Tn.length>0||En.length>0,On=(...e)=>!!It?.changedFields.some(t=>e.includes(t)),kn=M.allowedCommands.includes(`move`),An=R.has(`command`),jn=R.has(`delete`),Mn=M.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),Nn=Mn!==void 0,Pn=`/automations?action=create&taskId=${encodeURIComponent(M.task.id)}${M.task.projectId?`&projectId=${encodeURIComponent(M.task.projectId)}`:``}`,Fn=()=>{let e=Et.current;e&&(e.open=!0,e.scrollIntoView({block:`start`,behavior:`smooth`}),e.focus({preventScroll:!0}))},In=(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[un&&!dn&&!J&&M.task.phase!==`review`?(0,L.jsxs)(A,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:An,onClick:()=>void K({type:`mark_ready`}),children:[(0,L.jsx)(ie,{className:`size-4`}),y.scheduleTask]}):null,on&&M.allowedCommands.includes(`resolve_wait`)?(0,L.jsxs)(A,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:An,onClick:()=>void K({type:`resolve_wait`,waitId:on.id}),children:[(0,L.jsx)(ie,{className:`size-4`}),y.resumeTask]}):null,!J&&dn&&M.task.phase!==`review`&&Q?(0,L.jsxs)(A,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:An,onClick:()=>void K({type:`start`,executor:{kind:`agent`,agentId:Q}}),children:[(0,L.jsx)(ie,{className:`size-4`}),y.runTask]}):null,pn?(0,L.jsxs)(A,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:An,onClick:()=>void K({type:`close`,resolution:`done`}),children:[(0,L.jsx)(b,{className:`size-4`}),y.approveTask]}):null,mn?(0,L.jsxs)(A,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`ghost`,disabled:An,onClick:()=>void K({type:`reopen`,phase:`ready`}),children:[(0,L.jsx)(ie,{className:`size-4`}),y.reopenTask]}):null,!on&&fn?(0,L.jsxs)(A,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:An,onClick:()=>void K({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,L.jsx)(re,{className:`size-4`}),y.pauseTask]}):null,M.task.phase===`closed`?(0,L.jsx)(A,{variant:`primary`,className:`min-h-9 px-3 py-1.5 text-xs`,onClick:()=>{Dt.current?.scrollIntoView({block:`start`,behavior:`smooth`}),Dt.current?.focus({preventScroll:!0})},children:d===`zh`?`查看结果`:`View results`}):null,!J&&!Mn&&M.task.phase!==`closed`?(0,L.jsx)(A,{asChild:!0,variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,children:(0,L.jsxs)(o,{to:Pn,children:[(0,L.jsx)(_,{className:`size-4`}),d===`zh`?`设置执行时间`:`Set execution time`]})}):null,M.task.phase===`review`&&!pn&&!J?(0,L.jsx)(A,{variant:`primary`,className:`min-h-9 px-3 py-1.5 text-xs`,onClick:Fn,children:d===`zh`?`去验收`:`Review results`}):null,(0,L.jsxs)(Ne,{children:[(0,L.jsx)(Pe,{asChild:!0,children:(0,L.jsx)(A,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:An||jn,"aria-label":y.moreActions,children:(0,L.jsx)(C,{className:`size-4`,"aria-hidden":!0})})}),(0,L.jsx)(Fe,{children:(0,L.jsxs)(Ie,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[M.task.phase===`review`&&!J&&dn&&Q?(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:()=>void K({type:`start`,executor:{kind:`agent`,agentId:Q}}),children:y.runTask}):null,un&&(dn||J||M.task.phase===`review`)?(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none focus:bg-surface-hover`,onSelect:()=>void K({type:`mark_ready`}),children:y.scheduleTask}):null,Mn?(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{G(`command`,!0),I(null),N(we(e,Mn.id,Mn.version),{revalidate:!1}).catch(()=>I(y.actionFailed)).finally(()=>G(`command`,!1))},children:y.cancelActiveRun}):null,Mn?(0,L.jsx)(Le,{className:`my-1 h-px bg-edge`}):null,M.task.phase===`closed`?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void K({type:`close`,resolution:`cancelled`}),children:y.cancelTask}),(0,L.jsx)(Le,{className:`my-1 h-px bg-edge`})]}),(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(Nn){I(y.deleteActiveTaskBlocked);return}zt(!0)},children:y.deleteTask})]})})]})]});return(0,L.jsxs)(`div`,{ref:Ot,className:`flex h-full min-h-0 flex-col overflow-hidden ${wt?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${H}%`},children:[(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`task-detail-scroll flex min-w-0 shrink-0 flex-col lg:min-h-0 lg:flex-1 lg:shrink lg:overflow-y-auto lg:overscroll-contain`,children:[(0,L.jsxs)(`header`,{className:k(`shrink-0 border-b border-edge-subtle bg-surface-panel px-5 py-4 sm:px-6`,On(`title`)&&`task-detail-live-update`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-6 gap-y-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,L.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,B?(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`/`}):null,(0,L.jsx)(`span`,{children:y.taskLabel}),It?(0,L.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:It.source===`agent`?d===`zh`?`Agent 刚刚更新`:`Updated by Agent`:d===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),gt?(0,L.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,"aria-label":d===`zh`?`任务标题`:`Task title`,rows:2,value:vt,onFocus:e=>{Mt.current?.value===vt&&(e.currentTarget.setSelectionRange(0,0),e.currentTarget.scrollTop=0)},onChange:e=>yt(e.target.value),onBlur:()=>void Kt(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),Gt()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.blur()))},className:`mt-2 block max-h-56 min-h-14 w-full max-w-3xl resize-none overflow-y-auto bg-transparent p-0 text-xl font-semibold leading-7 text-fg outline-none [field-sizing:content]`}):(0,L.jsx)(F,{content:M.task.title,contentKey:`${e}:title`,language:d,previewHeight:56,className:`mt-2 max-w-3xl`,children:(0,L.jsx)(`h1`,{className:`break-words text-xl font-semibold leading-7 text-fg`,children:(0,L.jsx)(`button`,{type:`button`,className:`max-w-full whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-sm text-left outline-none hover:bg-surface-hover/60 focus-visible:ring-2 focus-visible:ring-accent/40`,title:M.task.title,onClick:Wt,children:M.task.title})})}),Ft===`title`?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,L.jsx)(`span`,{children:d===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:Gt,children:d===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,disabled:R.has(`title`),onClick:()=>void Kt(!0),children:d===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,L.jsx)(`span`,{className:k(`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium`,ve(sn)),children:cn})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[Q?(0,L.jsx)(Ae,{agentId:Q,avatar:hn?.avatar,size:20,className:`shrink-0`}):null,(0,L.jsxs)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:[y.executorLabel,` · `,hn?.name??Q??y.unassigned]})]}),(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:y.updatedAt.replace(`{{date}}`,Be(M.task.updatedAt,d))})]})]}),(0,L.jsxs)(`div`,{className:`sticky top-0 z-10 flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-edge-subtle bg-surface-panel px-4 py-2 sm:px-5`,"aria-label":d===`zh`?`任务操作`:`Task actions`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:[M.task.title,` · `,cn]}),In,We?(0,L.jsx)(`p`,{role:`alert`,className:`basis-full text-sm text-danger`,children:We}):null]}),(0,L.jsxs)(`section`,{className:`min-w-0 space-y-4 p-4 sm:p-5`,children:[(0,L.jsx)(Ke,{detail:M,language:d,onUpdated:e=>{N(e,{revalidate:!1})}}),(0,L.jsxs)(`section`,{ref:Dt,tabIndex:-1,"aria-labelledby":`task-results-heading`,className:`scroll-mt-24`,children:[(0,L.jsx)(`h2`,{id:`task-results-heading`,className:`mb-3 text-sm font-semibold text-fg`,children:d===`zh`?`结果与交付`:`Results and deliverables`}),_n.length>0||yn.length>0?(0,L.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:d===`zh`?`交付物`:`Deliverables`}),_n.length>0||yn.length>0?(0,L.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[_n.map(t=>(0,L.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,L.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:y.contextKindLabels[t.targetKind]}),t.targetKind===`url`&&/^https?:\/\//.test(t.targetId)?(0,L.jsx)(F,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:d,previewHeight:60,className:`mt-1`,children:(0,L.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.targetId,target:`_blank`,rel:`noreferrer`,children:t.title??t.targetId})}):(0,L.jsx)(F,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:d,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.id)),yn.map(t=>(0,L.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,L.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:d===`zh`?`执行产物(待检查)`:`Run artifact (review needed)`}),t.uri&&/^https?:\/\//.test(t.uri)?(0,L.jsx)(F,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:d,previewHeight:60,className:`mt-1`,children:(0,L.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.uri,target:`_blank`,rel:`noreferrer`,children:t.title})}):(0,L.jsx)(F,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:d,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.uri??t.title))]}):(0,L.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d===`zh`?`尚未关联交付物`:`No deliverables linked yet`})]}):null,X?(0,L.jsxs)(`section`,{className:k(`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5`,On(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.latestResult}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:d===`zh`?X.completionVerdict===`achieved`?`本次执行报告目标已达成,请结合下方验证依据验收。`:`这是阶段性结果,尚不能代表任务全部完成。`:X.completionVerdict===`achieved`?`The run reports the goal achieved. Review the evidence below.`:`This is a partial result; the task is not yet fully complete.`})]}),(0,L.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[y.receiptStatuses[X.status],` · `,y.verificationStatuses[X.verification.status]]})]}),(0,L.jsx)(F,{content:X.summary,contentKey:`${e}:result:${X.runId}`,language:d,className:`mt-3`}),X.remainingWork.length>0?(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.remainingWork}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(mt,{contentKey:`${e}:remaining:${X.runId}`,items:X.remainingWork,empty:y.noRemainingWork})})]}):null,X.nextAction?(0,L.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.nextAction}),(0,L.jsx)(F,{content:X.nextAction,contentKey:`${e}:next:${X.runId}`,language:d,markdown:!1,previewHeight:72,className:`mt-1 text-sm text-fg`})]}):null,(0,L.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(A,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void Ce(X.runId,`helpful`),children:y.doneWell}),(0,L.jsx)(A,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void Ce(X.runId,`not_helpful`),children:y.needsFix})]}),X.evidence.length>0?(0,L.jsxs)(`details`,{className:`mt-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:d===`zh`?`验证依据与执行产物`:`Evidence and run artifacts`}),(0,L.jsx)(He,{evidence:X.evidence,projectId:M.task.projectId,conversationId:Z??void 0,language:d})]}):null,M.receipts.length>1?(0,L.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.executionHistory.replace(`{{count}}`,String(M.receipts.length-1))}),(0,L.jsx)(`div`,{className:`mt-3 space-y-3`,children:M.receipts.slice(1).map(t=>(0,L.jsx)(`article`,{className:`rounded-lg bg-surface-hover p-3`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsx)(F,{content:t.summary,contentKey:`${e}:result:${t.runId}`,language:d,className:`min-w-0 flex-1`}),(0,L.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:y.receiptStatuses[t.status]})]})},t.runId))})]}):null]}):null,(0,L.jsxs)(`details`,{open:M.task.phase===`review`||!!X,ref:Et,tabIndex:-1,"aria-label":y.successDefinition,className:`scroll-mt-24 mb-4 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[(0,L.jsxs)(`summary`,{className:`cursor-pointer p-4 text-sm font-medium text-fg`,children:[y.successDefinition,` · `,Y.filter(e=>e.status===`passed`).length,`/`,Y.length]}),(0,L.jsx)(`div`,{className:`px-5 pb-5`,children:Y.length>0?(0,L.jsx)(`ul`,{className:`mt-3 space-y-3`,children:Y.map((t,n)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm leading-5 text-fg`,children:[(0,L.jsx)(t.status===`passed`?b:t.status===`failed`?x:S,{className:k(`mt-0.5 size-4 shrink-0`,t.status===`passed`?`text-success`:t.status===`failed`?`text-danger`:`text-fg-subtle`),"aria-hidden":!0}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(F,{content:t.text,contentKey:`${e}:criterion:${n}`,language:d,markdown:!1,previewHeight:60}),t.evidence.length>0?(0,L.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-xs leading-5 text-fg-muted`,children:[(0,L.jsx)(`span`,{children:d===`zh`?`依据:`:`Evidence:`}),t.evidence.map(e=>e.uri&&/^https?:\/\//.test(e.uri)?(0,L.jsx)(`a`,{className:`text-accent hover:underline`,href:e.uri,target:`_blank`,rel:`noreferrer`,children:e.title},e.title):(0,L.jsx)(`span`,{children:e.title},e.title))]}):null,t.review?(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[d===`zh`?`人工判定`:`Reviewed by user`,` · `,Be(t.review.reviewedAt,d)]}):null,t.method===`model_reviewed`?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:d===`zh`?`模型审阅:${t.verificationStatus===`passed`?`通过`:t.verificationStatus===`failed`?`未通过`:`未核验`}`:`Model review: ${t.verificationStatus===`passed`?`passed`:t.verificationStatus===`failed`?`failed`:`unverified`}`}):null,t.note?(0,L.jsx)(F,{content:t.note,contentKey:`${e}:criterion-note:${n}`,language:d,markdown:!1,previewHeight:60,className:`mt-1 text-xs text-fg-muted`}):null]}),M.task.phase!==`closed`&&M.task.contract?.acceptancePolicy!==`verified_auto`?(0,L.jsxs)(Ne,{children:[(0,L.jsx)(Pe,{asChild:!0,children:(0,L.jsx)(A,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:R.has(`acceptance`),children:d===`zh`?`判定`:`Review`})}),(0,L.jsx)(Fe,{children:(0,L.jsxs)(Ie,{align:`end`,sideOffset:4,className:`z-[100] min-w-32 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void rn(n,`passed`),children:d===`zh`?`确认通过`:`Mark passed`}),(0,L.jsx)(P,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void rn(n,`failed`),children:d===`zh`?`标记未通过`:`Mark failed`})]})})]}):null]},`${n}-${t.text}`))}):(0,L.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:y.noDefinition})})]}),!X&&_n.length===0&&yn.length===0?(0,L.jsx)(`p`,{className:`mb-3 text-sm text-fg-muted`,children:d===`zh`?`尚无执行结果`:`No execution results yet`}):null,(0,L.jsxs)(`details`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:d===`zh`?`执行与交付概览`:`Execution and delivery overview`}),(0,L.jsx)(f,{detail:M,language:d})]})]}),(0,L.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel divide-y divide-edge-subtle`,children:[(0,L.jsxs)(`div`,{className:`border-b border-edge-subtle p-5`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:d===`zh`?`任务目标`:`Task goal`}),(0,L.jsx)(F,{content:M.task.contract?.objective||M.task.title,contentKey:`${e}:goal`,language:d,markdown:!1,previewHeight:72,className:`mt-3 text-sm leading-6 text-fg`}),(0,L.jsxs)(A,{variant:`ghost`,className:`mt-2 min-h-9 px-2 text-xs`,onClick:Fn,children:[y.successDefinition,` · `,Y.length]})]}),Sn.length>0?(0,L.jsxs)(`div`,{className:`p-5`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.expectedOutputs}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(mt,{contentKey:`${e}:expectedOutputs`,items:Sn,empty:y.noDefinition})})]}):null,(0,L.jsxs)(`details`,{className:k(`p-5`,On(`body`)&&`task-detail-live-update`),children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:y.taskDescription}),bt?(0,L.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:xt,onChange:e=>St(e.target.value),onBlur:()=>void qt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),At.current=!0,St(pe(M.task.body??M.task.contract?.objective??``)),V(!1),queueMicrotask(()=>{At.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,L.jsxs)(`div`,{className:`mt-2`,children:[ln&&ln!==M.task.title?(0,L.jsx)(F,{content:ln,contentKey:`${e}:description`,language:d}):(0,L.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:y.noTaskDescription}),(0,L.jsx)(`button`,{type:`button`,className:`mt-2 rounded-md px-2 py-1 text-xs text-accent hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=pe(M.task.body??M.task.contract?.objective??``);jt.current=e,Nt.current={value:M.task.body??``,version:M.task.version},W(null),St(e),V(!0)},children:d===`zh`?`编辑说明`:`Edit description`})]}),Ft===`description`?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,L.jsx)(`span`,{children:d===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{St(pe(M.task.body??``)),W(null),V(!1)},children:d===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void q({body:fe(M.task.body??``,xt.trim())||null}).then(e=>{e&&(W(null),V(!1))}),children:d===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),Dn?(0,L.jsxs)(`section`,{className:k(`p-5`,On(`contract`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskDefinition}),(0,L.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:d===`zh`?`执行边界及补充背景`:`Execution boundaries and supporting context`}),Cn.length>0?(0,L.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.constraints}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(mt,{contentKey:`${e}:constraints`,items:Cn,empty:y.noDefinition})})]}):null,wn.length>0?(0,L.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.approvalRequired}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(mt,{contentKey:`${e}:approvalRequired`,items:wn,empty:y.noDefinition})})]}):null,Tn.length>0?(0,L.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.contextAssumptions}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(mt,{contentKey:`${e}:assumptions`,items:Tn,empty:y.noDefinition})})]}):null,En.length>0?(0,L.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.contextRisks}),(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(mt,{contentKey:`${e}:risks`,items:En,empty:y.noDefinition})})]}):null]}):null]}),(0,L.jsxs)(`section`,{"aria-labelledby":`task-management-heading`,children:[(0,L.jsx)(`h2`,{id:`task-management-heading`,className:`mb-3 text-sm font-semibold text-fg`,children:d===`zh`?`任务管理`:`Task management`}),(0,L.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,L.jsxs)(`section`,{className:k(`p-5`,On(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskProperties}),(0,L.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,L.jsx)(at,{value:M.task.phase,disabled:R.has(`phase`),canMove:kn,canApprove:pn,canReopen:mn,language:d,label:y.taskPhase,onChange:Jt}),(0,L.jsx)(ot,{value:M.task.priority,disabled:R.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Yt}),(0,L.jsx)(st,{value:tt(M.task.dueAt),disabled:R.has(`dueAt`),label:y.dueDate,onChange:Xt}),(0,L.jsx)(ct,{value:M.conversation.currentExecutorAgentId??``,disabled:R.has(`delegateAgentId`),label:y.executorLabel,unassignedLabel:y.unassigned,agents:it,onChange:tn})]})]}),(0,L.jsxs)(`details`,{className:k(`p-5`,On(`dependencies`)&&`task-detail-live-update`),children:[(0,L.jsxs)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:[y.taskRelations,` · `,M.dependencies.length,` / `,M.dependents.length]}),(0,L.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependencies}),(0,L.jsx)(lt,{candidates:Je,selected:M.dependencies,disabled:R.has(`dependencies`),labels:Bt,getTaskHref:Ut,onChange:en})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependents}),M.dependents.length>0?(0,L.jsx)(`div`,{className:`space-y-1.5`,children:M.dependents.map(t=>(0,L.jsx)(F,{content:t.title,contentKey:`${e}:dependent:${t.id}`,language:d,previewHeight:72,className:`rounded-lg bg-surface-hover p-2.5`,children:(0,L.jsx)(o,{to:Ut(t.id),className:`block break-words [overflow-wrap:anywhere] text-sm text-fg-muted transition-colors hover:text-fg`,children:t.title})},t.id))}):(0,L.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:y.noDependents})]})]})]})]}),M.task.phase===`closed`?null:(0,L.jsx)(A,{asChild:!0,variant:`ghost`,className:`my-3`,children:(0,L.jsxs)(o,{to:Pn,children:[(0,L.jsx)(_,{className:`size-4`}),y.scheduleRecurringTask]})}),(0,L.jsxs)(`details`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:d===`zh`?`关联内容`:`Related work`}),$.length>0||M.runs.length>0||xn.length>0||M.dependencies.length>0||M.dependents.length>0?(0,L.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[$.length>0?(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:d===`zh`?`对话 · ${$.length}`:`Conversations · ${$.length}`}),(0,L.jsx)(Xe,{contentKey:`${e}:sessions`,language:d,className:`mt-2`,children:$.map(t=>(0,L.jsx)(`li`,{children:(0,L.jsx)(o,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:t.conversationId===Z?T(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===Z?d===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?d===`zh`?`关联讨论`:`Linked discussion`:d===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})]}):null,xn.length>0?(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:d===`zh`?`自动化 · ${xn.length}`:`Automations · ${xn.length}`}),(0,L.jsx)(Xe,{contentKey:`${e}:automations`,language:d,className:`mt-2`,children:xn.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(o,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:`/automations?automation=${encodeURIComponent(e.id)}`,children:e.name})},e.id))})]}):null,M.dependencies.length>0||M.dependents.length>0?(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,L.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.taskRelations}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-fg`,children:d===`zh`?`${M.dependencies.length} 个前置任务 · ${M.dependents.length} 个后续任务`:`${M.dependencies.length} prerequisites · ${M.dependents.length} dependents`})]}):null]}):(0,L.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d===`zh`?`还没有关联内容`:`No related work yet`}),(0,L.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:(0,L.jsx)(Ue,{resource:{kind:`task`,id:M.task.id,revision:String(M.task.version)},disabled:gt||bt||R.size>0})})]}),bn.length>0?(0,L.jsxs)(`section`,{className:k(`p-5`,On(`context`)&&`task-detail-live-update`),children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.contextUsed}),(0,L.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:bn.map(e=>(0,L.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[y.contextRoleLabels[e.role],` · `,y.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,L.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,L.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,L.jsxs)(`details`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:d===`zh`?`活动记录与留言`:`Activity and updates`}),(0,L.jsxs)(`div`,{className:`mt-3 space-y-4`,children:[(0,L.jsx)(Ze,{taskId:e},e),(0,L.jsx)(Ge,{changes:M.phaseChanges,language:d})]})]})]})]}),(0,L.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":d===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(H),tabIndex:0,onPointerDown:$t,onKeyDown:Qt,onDoubleClick:()=>Zt(dt),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${wt?`bg-surface-hover`:``}`,children:(0,L.jsx)(`div`,{className:`w-px bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,L.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 shrink-0 flex-col border-t border-edge-subtle bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:border-t-0`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-medium text-fg-muted`,children:d===`zh`?`执行对话`:`Execution chat`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[$.length>1?(0,L.jsxs)(Ne,{children:[(0,L.jsx)(Pe,{asChild:!0,children:(0,L.jsx)(A,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:d===`zh`?`${$.length} 段对话`:`${$.length} conversations`})}),(0,L.jsx)(Fe,{children:(0,L.jsx)(Ie,{align:`end`,sideOffset:6,className:`z-[100] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:$.map(t=>(0,L.jsx)(P,{asChild:!0,children:(0,L.jsx)(o,{className:`block rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,to:t.conversationId===Z?T(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===Z?d===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?d===`zh`?`关联讨论`:`Linked discussion`:d===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})})]}):null,Z?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{type:`button`,variant:`ghost`,className:k(`size-8 p-0`,gn&&`bg-surface-hover text-fg`),"aria-label":d===`zh`?`项目文件`:`Project files`,"aria-pressed":gn,onClick:()=>{oe.getState().openFiles(Z),ce(Z)},children:(0,L.jsx)(w,{className:`size-4`,"aria-hidden":!0})}),(0,L.jsx)(A,{asChild:!0,variant:`ghost`,className:`size-8 p-0`,children:(0,L.jsx)(o,{to:T(e),"aria-label":d===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,L.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}):null]})]}),Z?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(m,{embedded:!0,conversationId:Z,taskId:e})}):be?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(O,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:d===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):Re?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(O,{className:`mx-auto size-8 text-danger`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:d===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,L.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:Re instanceof Error?Re.message:String(Re)})]})}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(O,{className:`mx-auto size-8 text-fg-subtle`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:d===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,L.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:d===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]}),(0,L.jsx)(Me,{open:Rt,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,M.task.title),confirmLabel:y.confirmDeleteTask,cancelLabel:y.keepTask,destructive:!0,onConfirm:()=>{zt(!1),nn()},onCancel:()=>zt(!1)})]})}function vt(){let e=(0,I.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,L.jsx)(_t,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function yt(e){let t=(0,I.c)(41),{taskId:n,backgroundPath:r,workspacePanelWidth:i,onClose:a}=e,o=i===void 0?0:i,s=u(St),c=be(xt),l=o>0,d;t[0]!==a||t[1]!==c?(d=e=>{e||(c(null),a())},t[0]=a,t[1]=c,t[2]=d):d=t[2];let f=s===`zh`?`关闭任务详情`:`Close task details`,p;t[3]!==a||t[4]!==c?(p=()=>{c(null),a()},t[3]=a,t[4]=c,t[5]=p):p=t[5];let m;t[6]!==f||t[7]!==p?(m=(0,L.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45`,"aria-label":f,onClick:p}),t[6]=f,t[7]=p,t[8]=m):m=t[8];let h=l?`true`:`false`,g=`${o/2}px`,_=`${o}px`,v;t[9]!==g||t[10]!==_?(v={"--task-detail-workspace-offset":g,"--task-detail-workspace-width":_},t[9]=g,t[10]=_,t[11]=v):v=t[11];let y=v,b=s===`zh`?`任务详情`:`Task details`,x;t[12]===b?x=t[13]:(x=(0,L.jsx)(N,{className:`font-medium text-fg`,children:b}),t[12]=b,t[13]=x);let S=s===`zh`?`查看并操作任务详情`:`View and manage task details`,C;t[14]===S?C=t[15]:(C=(0,L.jsx)(se,{className:`sr-only`,children:S}),t[14]=S,t[15]=C);let ee=s===`zh`?`关闭任务详情`:`Close task details`,te;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,L.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),t[16]=te):te=t[16];let w;t[17]===ee?w=t[18]:(w=(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,L.jsx)(ce,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":ee,children:te})}),t[17]=ee,t[18]=w);let ne;t[19]!==x||t[20]!==C||t[21]!==w?(ne=(0,L.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[x,C,w]}),t[19]=x,t[20]=C,t[21]=w,t[22]=ne):ne=t[22];let T;t[23]!==a||t[24]!==c?(T=()=>{c(null),a()},t[23]=a,t[24]=c,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==T||t[28]!==n?(E=(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,L.jsx)(_t,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:T})}),t[26]=r,t[27]=T,t[28]=n,t[29]=E):E=t[29];let D;t[30]!==y||t[31]!==ne||t[32]!==E||t[33]!==h?(D=(0,L.jsxs)(le,{className:`xopc-dialog-content task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,"data-workspace-panel-open":h,style:y,onEscapeKeyDown:V,onInteractOutside:bt,children:[ne,E]}),t[30]=y,t[31]=ne,t[32]=E,t[33]=h,t[34]=D):D=t[34];let O;t[35]!==D||t[36]!==m?(O=(0,L.jsxs)(M,{children:[m,D]}),t[35]=D,t[36]=m,t[37]=O):O=t[37];let re;return t[38]!==d||t[39]!==O?(re=(0,L.jsx)(ue,{modal:!1,open:!0,onOpenChange:d,children:O}),t[38]=d,t[39]=O,t[40]=re):re=t[40],re}function bt(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function V(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function xt(e){return e.setPath}function St(e){return e.language}function H(e){return(0,L.jsx)(y,{value:e.id,children:e.name||e.id},e.id)}function Ct(e){return e.id}export{yt as TaskDetailModal,vt as TaskDetailPage};
@@ -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,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./file-text-D12HbeVy.js";import{t as c}from"./markdown-view-CFWJhIqU.js";import{t as l}from"./cn-0WouolD0.js";import{t as u}from"./button-CnRSIP6m.js";import{it as d}from"./session-manager-DhoRfUGE.js";import{s as f}from"./composer-payload-handoff-qheyxoAD.js";import{f as p}from"./use-composer-attachments-DfP3JrD6.js";import{t as m}from"./activity-store-DNkXnatd.js";import{m as h,o as g}from"./shares-api-DbJOyf2K.js";var _=n(),v=e(t(),1),y=r();function b(e){let t=(0,_.c)(38),{content:n,contentKey:r,language:a,markdown:o,breaks:s,previewHeight:u,className:f,children:p}=e,m=o===void 0||o,h=s!==void 0&&s,g=u===void 0?240:u,b;t[0]===n?b=t[1]:(b=d(n),t[0]=n,t[1]=b),n=b;let x=(0,v.useId)(),S=(0,v.useRef)(null),[C,w]=(0,v.useState)(!1),[T,E]=i(),D;t[2]!==r||t[3]!==T?(D=T.getAll(`taskExpanded`).includes(r),t[2]=r,t[3]=T,t[4]=D):D=t[4];let O=D,k;t[5]===g?k=t[6]:(k=()=>{let e=S.current;if(!e)return;let t=()=>w(e.scrollHeight>g);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[5]=g,t[6]=k);let A;t[7]!==n||t[8]!==g?(A=[n,g],t[7]=n,t[8]=g,t[9]=A):A=t[9],(0,v.useLayoutEffect)(k,A);let j=C&&!O,M;t[10]===f?M=t[11]:(M=l(`min-w-0`,f),t[10]=f,t[11]=M);let N;t[12]!==j||t[13]!==g?(N=j?{maxHeight:g,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,g/3)}px), transparent)`}:void 0,t[12]=j,t[13]=g,t[14]=N):N=t[14];let P;t[15]!==h||t[16]!==p||t[17]!==n||t[18]!==m?(P=p??(m?(0,y.jsx)(c,{content:n,compact:!0,breaks:h,className:`text-sm leading-6 text-fg`}):(0,y.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[15]=h,t[16]=p,t[17]=n,t[18]=m,t[19]=P):P=t[19];let F;t[20]!==j||t[21]!==P?(F=(0,y.jsx)(`div`,{ref:S,inert:j,children:P}),t[20]=j,t[21]=P,t[22]=F):F=t[22];let I;t[23]!==x||t[24]!==F||t[25]!==N?(I=(0,y.jsx)(`div`,{id:x,style:N,children:F}),t[23]=x,t[24]=F,t[25]=N,t[26]=I):I=t[26];let L;t[27]!==r||t[28]!==O||t[29]!==x||t[30]!==a||t[31]!==C||t[32]!==E?(L=C?(0,y.jsx)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":x,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>E(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);t.delete(`taskExpanded`);for(let e of n)t.append(`taskExpanded`,e);return O||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:a===`zh`?O?`收起`:`查看更多`:O?`Show less`:`Show more`}):null,t[27]=r,t[28]=O,t[29]=x,t[30]=a,t[31]=C,t[32]=E,t[33]=L):L=t[33];let R;return t[34]!==I||t[35]!==L||t[36]!==M?(R=(0,y.jsxs)(`div`,{className:M,children:[I,L]}),t[34]=I,t[35]=L,t[36]=M,t[37]=R):R=t[37],R}function x({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[d,f]=(0,v.useState)(!1),h=(0,v.useRef)(null),g=e.kind===`approval`,_=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function b(a){if(!g&&!i.trim()||g&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);h.current?.signature!==c&&(h.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await p(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:g?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,h.current.key);f(!0),r(o),m({tone:`success`,title:g?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,y.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),b()},children:[g?(0,y.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,y.jsx)(`p`,{children:e.reason}),(0,y.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,y.jsx)(u,{type:`button`,variant:`primary`,disabled:o||d,onClick:()=>void b(`approve`),children:n?`批准`:`Approve`}),(0,y.jsx)(u,{type:`button`,disabled:o||d,onClick:()=>void b(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,y.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||d,onChange:e=>a(e.target.value)})]}),_.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,y.jsx)(u,{type:`button`,disabled:o||d,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,y.jsx)(u,{type:`submit`,variant:`primary`,disabled:o||d||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function S(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function C({uri:e,zh:t}){let[n,r]=(0,v.useState)(),[i,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``);async function m(){o(!0),d(``);try{let n=S(e,(await h()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?d(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?d(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?d(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(p(n.shareUrl),d(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):d(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{d(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{o(!1)}}async function _(){if(!(!n||i)){o(!0),d(``);try{let e=await g(n.id,864e5);p(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),d(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){d(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{o(!1)}}}return(0,y.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(u,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void m(),children:t?`检查链接状态`:`Check link`}),s&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,y.jsx)(u,{type:`button`,disabled:i,onClick:()=>void _(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,y.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),f&&(0,y.jsx)(`a`,{className:`block py-2 text-accent`,href:f,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),s&&(0,y.jsx)(a,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function w(e){let t=(0,_.c)(16),{evidence:n,projectId:r,conversationId:i,language:a,onOpenFile:c}=e,l=f(T);if(!n.length)return null;let u=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,d;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==l){let e;t[7]!==i||t[8]!==a||t[9]!==c||t[10]!==r||t[11]!==l?(e=(e,t)=>{let n=e.uri?.trim(),u=n&&/^https?:\/\//i.test(n),d=n&&!u&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),f=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,y.jsx)(b,{content:f,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:u?(0,y.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,y.jsx)(o,{className:`size-4 shrink-0`}),(0,y.jsx)(`span`,{className:`min-w-0 break-words`,children:f})]}):d&&(r||i)?(0,y.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,onClick:()=>c?c(n):l(n,null,r,i),children:[(0,y.jsx)(s,{className:`size-4 shrink-0`}),f]}):(0,y.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:f})}),u&&e.kind===`artifact`&&(0,y.jsx)(C,{uri:n,zh:a===`zh`},n),e.summary?(0,y.jsx)(b,{content:e.summary,contentKey:`${i??r}:evidence:${t}:${e.title}`,language:a,markdown:!1,previewHeight:80,className:`mt-1 text-xs leading-5 text-fg-muted`}):null,(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.provenance===`judge`?e.strength===`verified`?a===`zh`?`模型审阅通过`:`Model reviewed`:a===`zh`?`模型未确认,待核验`:`Not confirmed by review`:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[7]=i,t[8]=a,t[9]=c,t[10]=r,t[11]=l,t[12]=e):e=t[12],d=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=c,t[4]=r,t[5]=l,t[6]=d}else d=t[6];let p;return t[13]!==u||t[14]!==d?(p=(0,y.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":u,children:d}),t[13]=u,t[14]=d,t[15]=p):p=t[15],p}function T(e){return e.setPath}export{x as n,b as r,w 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{m as i,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./file-text-D12HbeVy.js";import{t as c}from"./markdown-view-BUpXJUPv.js";import{t as l}from"./cn-0WouolD0.js";import{t as u}from"./button-CnRSIP6m.js";import{ot as d}from"./session-manager-CtKgACGl.js";import{s as f}from"./composer-payload-handoff-CYIhcczq.js";import{f as p}from"./use-composer-attachments-BLc4dBfe.js";import{t as m}from"./activity-store-CMw8qBuC.js";import{m as h,o as g}from"./shares-api-Dowes16l.js";var _=n(),v=e(t(),1),y=r();function b(e){let t=(0,_.c)(38),{content:n,contentKey:r,language:a,markdown:o,breaks:s,previewHeight:u,className:f,children:p}=e,m=o===void 0||o,h=s!==void 0&&s,g=u===void 0?240:u,b;t[0]===n?b=t[1]:(b=d(n),t[0]=n,t[1]=b),n=b;let x=(0,v.useId)(),S=(0,v.useRef)(null),[C,w]=(0,v.useState)(!1),[T,E]=i(),D;t[2]!==r||t[3]!==T?(D=T.getAll(`taskExpanded`).includes(r),t[2]=r,t[3]=T,t[4]=D):D=t[4];let O=D,k;t[5]===g?k=t[6]:(k=()=>{let e=S.current;if(!e)return;let t=()=>w(e.scrollHeight>g);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[5]=g,t[6]=k);let A;t[7]!==n||t[8]!==g?(A=[n,g],t[7]=n,t[8]=g,t[9]=A):A=t[9],(0,v.useLayoutEffect)(k,A);let j=C&&!O,M;t[10]===f?M=t[11]:(M=l(`min-w-0`,f),t[10]=f,t[11]=M);let N;t[12]!==j||t[13]!==g?(N=j?{maxHeight:g,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,g/3)}px), transparent)`}:void 0,t[12]=j,t[13]=g,t[14]=N):N=t[14];let P;t[15]!==h||t[16]!==p||t[17]!==n||t[18]!==m?(P=p??(m?(0,y.jsx)(c,{content:n,compact:!0,breaks:h,className:`text-sm leading-6 text-fg`}):(0,y.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[15]=h,t[16]=p,t[17]=n,t[18]=m,t[19]=P):P=t[19];let F;t[20]!==j||t[21]!==P?(F=(0,y.jsx)(`div`,{ref:S,inert:j,children:P}),t[20]=j,t[21]=P,t[22]=F):F=t[22];let I;t[23]!==x||t[24]!==F||t[25]!==N?(I=(0,y.jsx)(`div`,{id:x,style:N,children:F}),t[23]=x,t[24]=F,t[25]=N,t[26]=I):I=t[26];let L;t[27]!==r||t[28]!==O||t[29]!==x||t[30]!==a||t[31]!==C||t[32]!==E?(L=C?(0,y.jsx)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":x,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>E(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);t.delete(`taskExpanded`);for(let e of n)t.append(`taskExpanded`,e);return O||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:a===`zh`?O?`收起`:`查看更多`:O?`Show less`:`Show more`}):null,t[27]=r,t[28]=O,t[29]=x,t[30]=a,t[31]=C,t[32]=E,t[33]=L):L=t[33];let R;return t[34]!==I||t[35]!==L||t[36]!==M?(R=(0,y.jsxs)(`div`,{className:M,children:[I,L]}),t[34]=I,t[35]=L,t[36]=M,t[37]=R):R=t[37],R}function x({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[d,f]=(0,v.useState)(!1),h=(0,v.useRef)(null),g=e.kind===`approval`,_=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function b(a){if(!g&&!i.trim()||g&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);h.current?.signature!==c&&(h.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await p(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:g?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,h.current.key);f(!0),r(o),m({tone:`success`,title:g?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,y.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),b()},children:[g?(0,y.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,y.jsx)(`p`,{children:e.reason}),(0,y.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,y.jsx)(u,{type:`button`,variant:`primary`,disabled:o||d,onClick:()=>void b(`approve`),children:n?`批准`:`Approve`}),(0,y.jsx)(u,{type:`button`,disabled:o||d,onClick:()=>void b(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,y.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||d,onChange:e=>a(e.target.value)})]}),_.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,y.jsx)(u,{type:`button`,disabled:o||d,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,y.jsx)(u,{type:`submit`,variant:`primary`,disabled:o||d||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,y.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function S(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function C({uri:e,zh:t}){let[n,r]=(0,v.useState)(),[i,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``);async function m(){o(!0),d(``);try{let n=S(e,(await h()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?d(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?d(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?d(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(p(n.shareUrl),d(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):d(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{d(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{o(!1)}}async function _(){if(!(!n||i)){o(!0),d(``);try{let e=await g(n.id,864e5);p(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),d(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){d(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{o(!1)}}}return(0,y.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(u,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void m(),children:t?`检查链接状态`:`Check link`}),s&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,y.jsx)(u,{type:`button`,disabled:i,onClick:()=>void _(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,y.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),f&&(0,y.jsx)(`a`,{className:`block py-2 text-accent`,href:f,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),s&&(0,y.jsx)(a,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function w(e){let t=(0,_.c)(16),{evidence:n,projectId:r,conversationId:i,language:a,onOpenFile:c}=e,l=f(T);if(!n.length)return null;let u=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,d;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==l){let e;t[7]!==i||t[8]!==a||t[9]!==c||t[10]!==r||t[11]!==l?(e=(e,t)=>{let n=e.uri?.trim(),u=n&&/^https?:\/\//i.test(n),d=n&&!u&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),f=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,y.jsx)(b,{content:f,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:u?(0,y.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,y.jsx)(o,{className:`size-4 shrink-0`}),(0,y.jsx)(`span`,{className:`min-w-0 break-words`,children:f})]}):d&&(r||i)?(0,y.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,onClick:()=>c?c(n):l(n,null,r,i),children:[(0,y.jsx)(s,{className:`size-4 shrink-0`}),f]}):(0,y.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:f})}),u&&e.kind===`artifact`&&(0,y.jsx)(C,{uri:n,zh:a===`zh`},n),e.summary?(0,y.jsx)(b,{content:e.summary,contentKey:`${i??r}:evidence:${t}:${e.title}`,language:a,markdown:!1,previewHeight:80,className:`mt-1 text-xs leading-5 text-fg-muted`}):null,(0,y.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.provenance===`judge`?e.strength===`verified`?a===`zh`?`模型审阅通过`:`Model reviewed`:a===`zh`?`模型未确认,待核验`:`Not confirmed by review`:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[7]=i,t[8]=a,t[9]=c,t[10]=r,t[11]=l,t[12]=e):e=t[12],d=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=c,t[4]=r,t[5]=l,t[6]=d}else d=t[6];let p;return t[13]!==u||t[14]!==d?(p=(0,y.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":u,children:d}),t[13]=u,t[14]=d,t[15]=p):p=t[15],p}function T(e){return e.setPath}export{x as n,b as r,w as t};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-_-_QzAV0.js";var t=[];function n(e,n){return e[n]??t}var r=0;function i(){return globalThis.crypto?.randomUUID?.()??`terminal-${Date.now()}-${++r}`}function a(e){let t=typeof window>`u`?640:Math.max(180,Math.floor(window.innerHeight*.65));return Math.min(640,t,Math.max(180,Math.round(e)))}var o=e((e,t)=>({openByConversationId:{},tabsByConversationId:{},activeTabKeyByConversationId:{},height:300,open:n=>{let r=t();if(r.tabsByConversationId[n]?.length){e({openByConversationId:{...r.openByConversationId,[n]:!0}});return}let a=i();e({openByConversationId:{...r.openByConversationId,[n]:!0},tabsByConversationId:{...r.tabsByConversationId,[n]:[{key:a}]},activeTabKeyByConversationId:{...r.activeTabKeyByConversationId,[n]:a}})},toggle:n=>{let r=t(),i=!r.openByConversationId[n];if(!i||r.tabsByConversationId[n]?.length){e({openByConversationId:{...r.openByConversationId,[n]:i}});return}r.open(n)},close:t=>e(e=>({openByConversationId:{...e.openByConversationId,[t]:!1}})),addTerminal:n=>{let r=t(),a=r.tabsByConversationId[n]??[];if(a.length>=8)return r.activeTabKeyByConversationId[n]??a[0].key;let o=i();return e({tabsByConversationId:{...r.tabsByConversationId,[n]:[...a,{key:o}]},activeTabKeyByConversationId:{...r.activeTabKeyByConversationId,[n]:o}}),o},closeTerminal:(t,n)=>e(e=>{let r=e.tabsByConversationId[t]??[],i=r.findIndex(e=>e.key===n);if(i<0)return e;let a=r.filter(e=>e.key!==n),o=e.activeTabKeyByConversationId[t],s=o===n?a[Math.min(i,a.length-1)]?.key:o;return{tabsByConversationId:{...e.tabsByConversationId,[t]:a},activeTabKeyByConversationId:{...e.activeTabKeyByConversationId,[t]:s}}}),setActiveTerminal:(t,n)=>e(e=>(e.tabsByConversationId[t]??[]).some(e=>e.key===n)?{activeTabKeyByConversationId:{...e.activeTabKeyByConversationId,[t]:n}}:e),setHeight:t=>e({height:a(t)})}));export{n,o as r,a as t};
1
+ import{p as e}from"./locale-store-Bg_XR36n.js";var t=[];function n(e,n){return e[n]??t}var r=0;function i(){return globalThis.crypto?.randomUUID?.()??`terminal-${Date.now()}-${++r}`}function a(e){let t=typeof window>`u`?640:Math.max(180,Math.floor(window.innerHeight*.65));return Math.min(640,t,Math.max(180,Math.round(e)))}var o=e((e,t)=>({openByConversationId:{},tabsByConversationId:{},activeTabKeyByConversationId:{},height:300,open:n=>{let r=t();if(r.tabsByConversationId[n]?.length){e({openByConversationId:{...r.openByConversationId,[n]:!0}});return}let a=i();e({openByConversationId:{...r.openByConversationId,[n]:!0},tabsByConversationId:{...r.tabsByConversationId,[n]:[{key:a}]},activeTabKeyByConversationId:{...r.activeTabKeyByConversationId,[n]:a}})},toggle:n=>{let r=t(),i=!r.openByConversationId[n];if(!i||r.tabsByConversationId[n]?.length){e({openByConversationId:{...r.openByConversationId,[n]:i}});return}r.open(n)},close:t=>e(e=>({openByConversationId:{...e.openByConversationId,[t]:!1}})),addTerminal:n=>{let r=t(),a=r.tabsByConversationId[n]??[];if(a.length>=8)return r.activeTabKeyByConversationId[n]??a[0].key;let o=i();return e({tabsByConversationId:{...r.tabsByConversationId,[n]:[...a,{key:o}]},activeTabKeyByConversationId:{...r.activeTabKeyByConversationId,[n]:o}}),o},closeTerminal:(t,n)=>e(e=>{let r=e.tabsByConversationId[t]??[],i=r.findIndex(e=>e.key===n);if(i<0)return e;let a=r.filter(e=>e.key!==n),o=e.activeTabKeyByConversationId[t],s=o===n?a[Math.min(i,a.length-1)]?.key:o;return{tabsByConversationId:{...e.tabsByConversationId,[t]:a},activeTabKeyByConversationId:{...e.activeTabKeyByConversationId,[t]:s}}}),setActiveTerminal:(t,n)=>e(e=>(e.tabsByConversationId[t]??[]).some(e=>e.key===n)?{activeTabKeyByConversationId:{...e.activeTabKeyByConversationId,[t]:n}}:e),setHeight:t=>e({height:a(t)})}));export{n,o as r,a as t};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-_-_QzAV0.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#f7f8fa`,emerald:`#f0fdf4`,clay:`#fffaf0`,dawn:`#accdec`,porcelain:`#f6f0e7`},dark:{default:`#14171c`,emerald:`#000000`,clay:`#0a1a1a`,dawn:`#172433`,porcelain:`#211c19`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e==="default"||e===`emerald`||e===`clay`||e===`dawn`||e===`porcelain`?e:n}function l(e){window.electronAPI?.theme?.setPreference(e).catch(()=>{})}function u(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function d(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}u(o(t),r,!1),l(t)}catch{u(o(`system`),`default`,!1)}}var f=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();u(r,a,r!==i),e({preference:n,resolved:r}),l(n)},setColorScheme:n=>{let{resolved:r}=t();u(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function p(){let{preference:e,colorScheme:t}=f.getState(),n=o(e);u(n,t,!1),f.setState({resolved:n}),l(e)}function m(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=f.getState();if(e!==`system`)return;let n=o(`system`),r=f.getState().resolved;u(n,t,n!==r),f.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{f as i,m as n,p as r,d as t};
1
+ import{p as e}from"./locale-store-Bg_XR36n.js";import{t}from"./middleware-Pd0e8Igk.js";var n=`default`,r={light:{default:`#f7f8fa`,emerald:`#f0fdf4`,clay:`#fffaf0`,dawn:`#accdec`,porcelain:`#f6f0e7`},dark:{default:`#14171c`,emerald:`#000000`,clay:`#0a1a1a`,dawn:`#172433`,porcelain:`#211c19`}};function i(e,t){let n=document.head;if(!n)return;let i=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);i||(i=document.createElement(`meta`),i.setAttribute(`name`,`theme-color`),i.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(i)),i.setAttribute(`content`,r[e][t])}function a(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function o(e){return e===`system`?a()?`dark`:`light`:e}function s(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function c(e){return e==="default"||e===`emerald`||e===`clay`||e===`dawn`||e===`porcelain`?e:n}function l(e){window.electronAPI?.theme?.setPreference(e).catch(()=>{})}function u(e,t,n){let r=document.documentElement,a=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,i(e,t)},o=document;n&&!s()&&typeof o.startViewTransition==`function`?o.startViewTransition(a):a()}function d(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,r=n;if(e){let n=JSON.parse(e);n.state?.preference&&(t=n.state.preference),n.state&&`colorScheme`in n.state&&(r=c(n.state.colorScheme))}u(o(t),r,!1),l(t)}catch{u(o(`system`),`default`,!1)}}var f=e(t((e,t)=>({preference:`system`,colorScheme:n,resolved:o(`system`),setPreference:n=>{let r=o(n),{resolved:i,colorScheme:a}=t();u(r,a,r!==i),e({preference:n,resolved:r}),l(n)},setColorScheme:n=>{let{resolved:r}=t();u(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:c(n.colorScheme)}}}));function p(){let{preference:e,colorScheme:t}=f.getState(),n=o(e);u(n,t,!1),f.setState({resolved:n}),l(e)}function m(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=f.getState();if(e!==`system`)return;let n=o(`system`),r=f.getState().resolved;u(n,t,n!==r),f.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}export{f as i,m as n,p as r,d as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./tool-activity-BtJkgjFf.js";function t(e){if(typeof e==`string`)try{return t(JSON.parse(e))}catch{return null}return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function n(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>t[n]??``)}function r(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)?.split(`.`).at(-1)??``}var i={automation:`automation`,browser_automation:`browser`,browser_use:`browser`,clarify:`clarification`,codemode:`codeExecution`,tool_search:`toolSearch`,computer_use:`computer`,create_desktop_pet:`desktopPet`,create_share:`share`,delegate_task:`delegation`,image_generate:`imageGeneration`,image:`imageInspection`,language_diagnostics:`diagnostics`,managed_job:`job`,memory_maintenance:`memoryMaintenance`,knowledge_get:`memoryRead`,knowledge_write:`memoryUpdate`,user_context_get:`memoryRead`,user_context_update:`memoryUpdate`,publish_artifacts:`publish`,update_plan:`planning`,read_media:`mediaRead`,review_workspace:`review`,send_media:`mediaSend`,send_message:`message`,session_recall:`sessionRecall`,session_search:`sessionSearch`,session_status:`sessionStatus`,skill_install:`skillInstall`,skill_manage:`skillManage`,skills_marketplace_search:`skillSearch`,skills_list:`skillSearch`,skill_view:`skillView`,text_to_speech:`speech`,structured_output:`structuredOutput`,todo:`todo`,tool_manual:`manual`,web_extract:`webExtract`,xopc_require_connection:`connection`};function a(e){let t=r(e);return t===`xopc_use`||t in i}function o(e,t,n,i,o){if(a(e.name))return x(e.name,r(e.name)===`xopc_use`?e.input:void 0,t,n,i,e.activity);let s=S(e.name,e.activity);return t===`running`?o[s]:s===`other`?n.fallback.completed.replace(/\{\{name\}\}/g,``).trim():C(e.name,i,e.activity)}var s=new Set([`list`,`get`,`get_card`,`history`,`list_milestones`,`list_updates`,`mail_sources`,`preview_edit`,`resolve_workspace`]),c=new Set([`create`,`create_milestone`,`create_update`,`follow_up`,`start`]),l=new Set([`add_context`,`append`,`command`,`remove_context`,`update`,`update_dependencies`,`update_follow_up`,`update_milestone`]),u=new Set([`delete`]),d=new Set([`run`,`resume`]),f=new Set([`cancel`,`pause`]),p=new Set([`check`,`validate`]),m=new Set([`open`]),h=new Set([`continue_card`]);function g(e){return s.has(e)?`inspect`:c.has(e)?`create`:l.has(e)?`update`:u.has(e)?`remove`:d.has(e)?`run`:f.has(e)?`stop`:p.has(e)?`validate`:m.has(e)?`open`:h.has(e)?`continue`:`use`}function _(e,t){return e===`project`&&t.includes(`milestone`)?`milestone`:e===`project`&&t.includes(`update`)?`projectUpdate`:e===`project`?`project`:e===`automation`?`automation`:e===`note`?`note`:e===`task`?`task`:e===`task_run`?`taskRun`:e===`local_app`?`localApp`:e===`settings`?`settings`:e===`context`?`context`:e===`chat_preview`?`chatPreview`:`productItem`}function v(e){return(e.trim().split(`__`).at(-1)?.split(`.`).at(-1)??e.trim()).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim()||`tool`}var y={list:`inspect`,get:`inspect`,read:`inspect`,fetch:`inspect`,find:`inspect`,search:`inspect`,query:`inspect`,create:`create`,add:`create`,generate:`create`,install:`create`,update:`update`,edit:`update`,write:`update`,append:`update`,set:`update`,delete:`remove`,remove:`remove`,uninstall:`remove`,run:`run`,execute:`run`,start:`run`,trigger:`run`,stop:`stop`,cancel:`stop`,pause:`stop`,validate:`validate`,check:`validate`,test:`validate`,verify:`validate`,analyze:`validate`,review:`validate`,open:`open`,navigate:`open`,continue:`continue`,resume:`continue`};function b(e,t,r){let[i,...a]=v(e).split(` `),o=y[i.toLowerCase()],s=a.join(` `).trim();return!o||!s?null:n(r.actions[o][t],{object:s})}function x(a,o,s,c,l,u){let d=r(a);if(d===`xopc_use`){let e=t(o),r=typeof e?.mode==`string`?e.mode.trim().toLowerCase():``,i=typeof e?.command==`string`?e.command.trim().toLowerCase():``,a=g(i),l=_(r,i);return n(c.actions[a][s],{object:c.objects[l]})}let f=i[d];if(f){let e=c.builtins[f][s],n=t(o),r=f===`skillView`?n?.name:void 0;return typeof r==`string`&&r.trim()?`${e} · ${r.trim().replace(/\s+/g,` `).slice(0,100)}`:e}let p=u??e(a,s===`running`?`running`:`completed`);return p.category!==`other`||p.action!==`use`?C(a,l,p):b(a,s,c)??n(c.fallback[s],{name:v(a)})}function S(t,n){if(t===`user_context_search`||t===`knowledge_search`)return`memorySearch`;let r=n??e(t,`running`);return r.category===`memory`&&r.action===`search`?`memorySearch`:r.category===`web`&&r.action===`search`?`webSearch`:r.category===`code`&&r.action===`search`?`codeSearch`:r.category===`other`&&r.action===`search`?`search`:r.category===`file`&&r.action===`read`?`readFile`:r.category===`file`&&r.action===`list`?`listDir`:r.category===`file`&&r.action===`write`?`writeFile`:r.category===`file`&&r.action===`edit`?`editFile`:r.category===`command`&&r.action===`execute`?`runCommand`:r.category===`navigation`&&r.action===`open`?`openUrl`:r.category===`web`&&r.action===`read`?`fetchUrl`:`other`}function C(t,n,r){let i=r??e(t,`running`);if(i.category===`planning`)return n.updatePlan??n.unknownTool.replace(`{{name}}`,t);let a=S(t,i);return a===`webSearch`?n.searchedWeb:a===`memorySearch`?n.searchedMemory??n.searched??n.searchedWeb:a===`codeSearch`?n.searchedCode??n.searched??n.searchedWeb:a===`search`?n.searched??n.searchedWeb:a===`readFile`?n.readFile:a===`runCommand`?n.runCommand:a===`listDir`?n.listDirectory:a===`writeFile`?n.writeFile:a===`editFile`?n.editFile:a===`openUrl`?n.openUrl:a===`fetchUrl`?n.fetchUrl:n.unknownTool.replace(`{{name}}`,t.trim()||`tool`)}export{C as n,o as r,S 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{i,n as ee,o as a}from"./locale-store-Bg_XR36n.js";import{t as o}from"./popover-select-DD8fmrxH.js";import{t as te}from"./secret-input-BQvFXqzz.js";import{t as s}from"./button-CnRSIP6m.js";import{t as c}from"./skeleton-BI5TyibZ.js";import{a as ne,i as l,n as re,o as ie,r as ae,s as oe,t as se}from"./dist-DfWfZ9iu.js";import{i as u}from"./vendor-swr-CdRzEUwF.js";import{t as ce}from"./sliding-tab-list-DuQyViqe.js";import{t as d}from"./number-input-El7Szeln.js";import{n as le,t as ue}from"./settings-page-header-CyUHrn7c.js";import"./settings-page-layout-DGVqXrlp.js";import{n as de,t as fe}from"./use-autosave-3O-X7x15.js";var f=e(t(),1),p=n(),m=e=>i(`/api/observability/${e}`);async function h(e,t=`GET`,n){return a(m(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}})}var g=r(),_=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,v=`space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,pe=(e=0)=>`${(e/1048576).toFixed(1)} MiB`;function y(){let e=(0,p.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,g.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,g.jsx)(c,{className:`h-48 rounded-xl`}),(0,g.jsx)(c,{className:`h-64 rounded-xl`})]}),e[0]=t):t=e[0],t}function me(e,t){let n=0,r=e,i=new Set;for(;r.parentSpanId&&n<12&&!i.has(r.spanId);){i.add(r.spanId);let e=t.find(e=>e.spanId===r.parentSpanId);if(!e)break;r=e,n++}return n}function he(e){let t=[],n=new Set;function r(i){n.has(i.spanId)||(n.add(i.spanId),t.push(i),e.filter(e=>e.parentSpanId===i.spanId).forEach(r))}return e.filter(t=>!t.parentSpanId||!e.some(e=>e.spanId===t.parentSpanId)).forEach(r),e.forEach(r),t}function b(){let e=ee(e=>e.language)===`zh`,t=(t,n)=>e?n:t,n=u(m(`tracing/settings`),()=>h(`tracing/settings`)),r=u(m(`tracing/status`),()=>h(`tracing/status`),{refreshInterval:1e4}),[i,a]=(0,f.useState)(),[p,b]=(0,f.useState)(),x=i??p??n.data?.config,[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(``),[ge,_e]=(0,f.useState)(0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(``),[ve,ye]=(0,f.useState)(!1),[A,be]=(0,f.useState)(``),[j,xe]=(0,f.useState)(`7`),[M,Se]=(0,f.useState)({conversationId:``,runId:``,agentId:``}),[N,P]=(0,f.useState)(`records`),[F,Ce]=(0,f.useState)(`10`),[we,I]=(0,f.useState)([``]),[L,R]=(0,f.useState)(0),[z,Te]=(0,f.useState)(()=>Date.now()+1),B=we[L],[V,H]=(0,f.useState)();function U(){I([``]),R(0),Te(Date.now()+1)}let[Ee,W]=(0,f.useState)(!1),G=new URLSearchParams({limit:F,from:String(z-Number(j)*864e5),to:String(z)});A&&G.set(`status`,A),B&&G.set(`cursor`,B);for(let[e,t]of Object.entries(M))t&&G.set(e,t);let De=`traces?${G}`,K=u(m(De),()=>h(De),{refreshInterval:B?0:1e4}),q=u(V?m(`traces/${V}`):null,()=>h(`traces/${V}`));function J(e){if(!x)return;let t=structuredClone(x);e(t),a(t)}async function Y(e,i=t(`Saved`,`已保存`)){D(!0),k(``),ye(!1);try{await e(),k(i),await Promise.all([n.mutate(),r.mutate(),K.mutate()])}catch(e){ye(!0),k(e instanceof Error?e.message:t(`Request failed`,`操作失败`))}finally{D(!1)}}let X=fe({value:x??null,dirty:!!(i&&JSON.stringify(i)!==JSON.stringify(p??n.data?.config)),validate:e=>{if([[`retentionDays`,1,90],[`maxStoreMiB`,16,4096],[`maxTraces`,10,1e5],[`maxSpans`,100,1e6],[`maxTraceKiB`,16,4096],[`maxWriteMiBPerMinute`,1,100]].some(([t,n,r])=>!Number.isInteger(e.local[t])||e.local[t]<n||e.local[t]>r))return t(`Enter valid storage limits before continuing.`,`请填写有效的存储限额。`);try{let t=new URL(e.langfuse.baseUrl);if(![`http:`,`https:`].includes(t.protocol)||e.langfuse.baseUrl.length>2048)throw Error()}catch{return t(`Enter a valid HTTP(S) Base URL.`,`请填写有效的 HTTP(S) Base URL。`)}return null},onSave:async e=>{let t=await h(`tracing/settings`,`PATCH`,e);b(t.config),a(t=>t&&JSON.stringify(t)===JSON.stringify(e)?void 0:t),await r.mutate().catch(()=>{})}}),Z=(0,f.useMemo)(()=>({publicKey:S.trim(),secretKey:w.trim()}),[S,w]),Q=fe({value:Z,dirty:!!(Z.publicKey||Z.secretKey),delayMs:1e3,validate:e=>e.publicKey.length>512||e.secretKey.length>512?t(`Credentials must be at most 512 characters.`,`凭证长度不能超过 512 个字符。`):null,onSave:async e=>{await h(`tracing/langfuse/credentials`,`PUT`,{...e.publicKey?{publicKey:e.publicKey}:{},...e.secretKey?{secretKey:e.secretKey}:{}}),C(t=>t.trim()===e.publicKey?``:t),T(t=>t.trim()===e.secretKey?``:t),_e(e=>e+1),await Promise.allSettled([n.mutate(),r.mutate()])}}),$=[X.status,Q.status].some(e=>e===`dirty`||e===`saving`);async function Oe(){V&&await Y(async()=>{let e=await h(`traces/${V}/export`),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`trace-${V}.json`,n.click(),URL.revokeObjectURL(t)},t(`Exported`,`已导出`))}return(0,g.jsxs)(le,{className:`space-y-6`,children:[(0,g.jsx)(ue,{title:t(`Runtime tracing`,`运行追踪`),subtitle:t(`Local diagnostics with bounded retention. Enable Langfuse to also export new traces.`,`默认保留有界本地记录;启用 Langfuse 后同时导出新采集的追踪。`),actions:N===`settings`?(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t(`Changes save automatically`,`修改后自动保存`)}),(0,g.jsx)(de,{status:X.status,error:X.error})]}):(0,g.jsx)(s,{disabled:K.isValidating,onClick:U,children:t(`Refresh records`,`刷新记录`)})}),O&&(0,g.jsx)(`p`,{role:ve?`alert`:`status`,className:`text-sm text-fg-muted`,children:O}),n.error&&(0,g.jsxs)(`div`,{role:`alert`,className:v,children:[(0,g.jsx)(`p`,{children:t(`Unable to load tracing settings.`,`无法加载追踪设置。`)}),(0,g.jsx)(s,{variant:`ghost`,onClick:()=>void n.mutate(),children:t(`Retry loading settings`,`重新加载设置`)})]}),(0,g.jsxs)(ce,{as:`nav`,"aria-label":t(`Tracing sections`,`追踪页面分区`),className:`flex gap-2 border-b border-edge pb-3`,children:[(0,g.jsx)(s,{"aria-pressed":N===`records`,variant:`ghost`,onClick:()=>P(`records`),children:t(`Execution records`,`执行记录`)}),(0,g.jsx)(s,{"aria-pressed":N===`settings`,variant:`ghost`,onClick:()=>P(`settings`),children:t(`Capture settings`,`采集设置`)})]}),N===`settings`&&(x?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`section`,{className:v,onBlurCapture:X.onBlurCapture,children:[(0,g.jsx)(`h2`,{className:`font-medium`,children:t(`Local recording`,`本地记录`)}),X.error&&(0,g.jsx)(s,{variant:`ghost`,onClick:X.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,g.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:x.enabled,onChange:e=>J(t=>{t.enabled=e.target.checked})}),t(`Record traces`,`记录运行追踪`)]}),(0,g.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Retention (days)`,`保留天数`),(0,g.jsx)(d,{className:_,type:`number`,min:1,max:90,value:x.local.retentionDays,onChange:e=>J(t=>{t.local.retentionDays=Number(e.target.value)})})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Storage budget (MiB)`,`存储上限(MiB)`),(0,g.jsx)(d,{className:_,type:`number`,min:16,max:4096,value:x.local.maxStoreMiB,onChange:e=>J(t=>{t.local.maxStoreMiB=Number(e.target.value)})})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Capture`,`采集内容`),(0,g.jsx)(o,{placeholder:t(`Choose`,`请选择`),allowEmpty:!1,value:x.capture,onChange:e=>J(t=>{t.capture=e}),options:[{value:`metadata`,label:t(`Metadata only`,`仅元数据`)},{value:`redacted`,label:t(`Redacted previews`,`脱敏摘要`)},{value:`detailed`,label:t(`Detailed · 30 minutes`,`详细记录 · 30 分钟`)}]})]})]}),(0,g.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Previews may contain personal content. Secrets and media are filtered; large values are truncated.`,`摘要可能包含个人内容。过滤凭证和媒体,超长内容会截断。`)}),x.detailedUntil&&(0,g.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Detailed capture expires: `,`详细采集截止:`),new Date(x.detailedUntil).toLocaleString()]}),(0,g.jsxs)(`details`,{children:[(0,g.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t(`Advanced limits`,`高级限制`)}),(0,g.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[[`maxTraces`,t(`Trace count`,`Trace 条数`)],[`maxSpans`,t(`Span count`,`Span 条数`)],[`maxTraceKiB`,t(`Per trace (KiB)`,`单 Trace 上限(KiB)`)],[`maxWriteMiBPerMinute`,t(`Write budget (MiB/minute)`,`写入额度(MiB/分钟)`)]].map(([e,t])=>(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t,(0,g.jsx)(d,{type:`number`,min:1,className:_,value:x.local[e],onChange:t=>J(n=>{n.local[e]=Number(t.target.value)})})]},e))})]}),r.data?(0,g.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Disk / payload`,`磁盘 / 数据`),`:`,pe(r.data.local.physicalBytes),` / `,pe(r.data.local.bytes),` · `,r.data.local.traces??0,` traces · `,r.data.local.spans??0,` spans · `,t(`Dropped`,`丢弃`),` `,Number(r.data.local.dropped??0)+Number(r.data.local.queueDropped??0),(r.data.local.paused||r.data.local.unavailable)&&` · ${t(`Recording paused`,`存储暂停`)}`]}):(0,g.jsx)(c,{className:`h-10`}),(r.error||r.data?.local.lastError)&&(0,g.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,g.jsx)(`p`,{role:`alert`,children:r.data?.local.lastError?t(`Trace recording is unavailable.`,`追踪记录异常。`):t(`Unable to load recording status.`,`无法获取记录状态。`)}),(0,g.jsx)(s,{variant:`ghost`,onClick:()=>void r.mutate(),children:t(`Refresh recording status`,`刷新记录状态`)}),(0,g.jsxs)(`details`,{children:[(0,g.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:t(`Technical details`,`技术详情`)}),(0,g.jsx)(`p`,{className:`mt-2 break-words text-fg-muted`,children:r.data?.local.lastError||String(r.error?.message)})]})]}),(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsx)(s,{disabled:E||$,onClick:()=>void Y(async()=>{await h(`traces/prune`,`POST`)}),children:t(`Clean expired`,`清理过期记录`)}),(0,g.jsx)(s,{disabled:E,onClick:()=>W(!0),children:t(`Clear local traces`,`清空本地追踪`)})]})]}),(0,g.jsxs)(`section`,{className:v,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,g.jsx)(`h2`,{className:`font-medium`,children:`Langfuse`}),(0,g.jsx)(de,{status:Q.status,error:Q.error})]}),Q.error&&(0,g.jsx)(s,{variant:`ghost`,onClick:Q.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,g.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:x.langfuse.enabled,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.enabled=e.target.checked})}),t(`Also export new traces to Langfuse`,`同时导出新采集的追踪到 Langfuse`)]}),(0,g.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-sm sm:col-span-2`,children:[`Base URL`,(0,g.jsx)(`input`,{className:_,type:`url`,value:x.langfuse.baseUrl,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.baseUrl=e.target.value})})]}),[`publicKey`,`secretKey`].map(e=>{let r=e===`publicKey`?`Public Key`:`Secret Key`,i=e===`publicKey`?S:w,ee=n.data?.credentials[e===`publicKey`?`publicKeyConfigured`:`secretKeyConfigured`];return(0,g.jsxs)(`div`,{className:`space-y-1 text-sm`,onBlurCapture:Q.onBlurCapture,children:[(0,g.jsx)(`label`,{htmlFor:`langfuse-${e}`,children:r}),(0,g.jsx)(te,{id:`langfuse-${e}`,value:i||(ee?`••••••••••••`:``),allowUnrevealedCopy:!0,onChange:t=>(e===`publicKey`?C:T)(t.replace(/^•+/,``)),placeholder:e===`publicKey`?`pk-lf-…`:`sk-lf-…`,labels:{show:t(`Show ${r}`,`查看 ${r}`),hide:t(`Hide ${r}`,`隐藏 ${r}`),copy:t(`Copy ${r}`,`复制 ${r}`),copied:t(`Copied`,`已复制`)},reveal:()=>h(`tracing/langfuse/credentials/${e}/reveal`,`POST`).then(e=>e.key),loadFailedLabel:t(`Unable to load the configured key.`,`无法读取已配置的 Key。`),notInConfigFile:t(`No configured key is available.`,`暂无已配置的 Key。`)},ge)]},e)})]}),(0,g.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Credential sources`,`凭证来源`),`:`,n.data?.credentials.publicKeySource,` / `,n.data?.credentials.secretKeySource,` · URL: `,n.data?.credentials.baseUrlSource]}),r.data&&(0,g.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[r.data.langfuse.state,` · `,t(`Pending`,`待发送`),` `,r.data.langfuse.pending,` · `,t(`Dropped`,`丢弃`),` `,r.data.langfuse.dropped,r.data.langfuse.lastSuccess?` · ${new Date(r.data.langfuse.lastSuccess).toLocaleString()}`:``]}),r.data?.langfuse.lastError&&(0,g.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,g.jsx)(`p`,{role:`alert`,children:t(`Unable to export traces.`,`无法导出追踪。`)}),(0,g.jsxs)(`details`,{children:[(0,g.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:t(`Technical details`,`技术详情`)}),(0,g.jsx)(`p`,{className:`mt-2 break-words text-fg-muted`,children:r.data.langfuse.lastError})]})]}),(0,g.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Changes save automatically. Historical traces are not uploaded. Offline exports may be dropped.`,`修改后自动保存。不会上传历史记录;断网或队列满时可能丢弃远端导出。`)}),(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsx)(s,{disabled:E||$,onClick:()=>void Y(async()=>{if(!(await h(`tracing/langfuse/test`,`POST`)).ok)throw Error(t(`Connection test failed. Check saved configuration and credentials.`,`连接测试失败,请检查已保存的配置和凭证。`))},t(`Diagnostic trace accepted by the ingestion endpoint`,`采集端已接受诊断追踪`)),children:t(`Test connection`,`测试连接`)}),(0,g.jsx)(s,{disabled:E||$,onClick:()=>void Y(async()=>{await h(`tracing/langfuse/credentials`,`DELETE`),C(``),T(``),_e(e=>e+1)}),children:t(`Remove saved credentials`,`移除已保存凭证`)})]})]})]}):(0,g.jsx)(y,{})),N===`records`&&(0,g.jsxs)(`section`,{className:v,children:[(0,g.jsx)(`h2`,{className:`font-medium`,children:t(`Recent runs`,`最近执行`)}),(0,g.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Status`,`执行状态`),(0,g.jsx)(o,{placeholder:t(`All statuses`,`全部状态`),allowEmpty:!1,value:A,onChange:e=>{be(e),U()},options:[{value:``,label:t(`All statuses`,`全部状态`)},...[`running`,`success`,`error`,`cancelled`,`suspended`,`interrupted`].map(e=>({value:e,label:t(e,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[e])}))]})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Time range`,`时间范围`),(0,g.jsx)(o,{placeholder:t(`Choose`,`请选择`),value:j,allowEmpty:!1,onChange:e=>{xe(e),U()},options:[`1`,`7`,`30`,`90`].map(e=>({value:e,label:`${e} ${t(`days`,`天`)}`}))})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Page size`,`每页条数`),(0,g.jsx)(o,{placeholder:t(`Choose`,`请选择`),value:F,allowEmpty:!1,onChange:e=>{Ce(e),U()},options:[`10`,`20`].map(e=>({value:e,label:`${e} ${t(`records`,`条`)}`}))})]})]}),(0,g.jsxs)(`details`,{children:[(0,g.jsxs)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:[t(`Advanced filters`,`高级筛选`),Object.values(M).some(Boolean)?` · ${t(`Active`,`已启用`)}`:``]}),(0,g.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[`conversationId`,`runId`,`agentId`].map(e=>(0,g.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[{conversationId:t(`Conversation ID`,`会话 ID`),runId:t(`Run ID`,`执行 ID`),agentId:t(`Agent ID`,`Agent ID`)}[e],(0,g.jsx)(`input`,{"aria-label":e,placeholder:t(`Exact ID`,`输入完整 ID`),className:_,value:M[e],onChange:t=>{Se({...M,[e]:t.target.value}),U()}})]},e))})]}),(0,g.jsxs)(`details`,{className:`text-xs text-fg-muted`,children:[(0,g.jsx)(`summary`,{className:`w-fit cursor-pointer rounded focus-visible:outline-accent`,children:t(`About costs`,`费用说明`)}),(0,g.jsxs)(`p`,{className:`mt-2 leading-5`,children:[t(`Amounts are shown in USD. Cloud charges use Credits receipts.`,`金额以美元显示,Cloud 扣费以 Credits 凭证为准。`),` `,(0,g.jsx)(`a`,{className:`text-accent-fg hover:underline`,href:`#/settings/usage`,children:t(`View usage`,`查看用量`)})]})]}),(0,g.jsxs)(`div`,{role:`region`,"aria-label":t(`Execution results`,`执行结果`),"aria-busy":K.isValidating,className:`h-[24rem] min-h-0 overflow-y-auto overscroll-contain rounded-lg border border-edge sm:h-[28rem]`,children:[K.error&&(0,g.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm`,children:[(0,g.jsx)(`p`,{children:t(`Unable to load execution records.`,`无法加载执行记录。`)}),(0,g.jsx)(s,{variant:`ghost`,onClick:()=>void K.mutate(),disabled:K.isValidating,children:t(`Retry loading records`,`重新加载记录`)})]}),!K.data&&!K.error?(0,g.jsx)(`div`,{className:`space-y-3 p-3`,children:[0,1,2,3,4].map(e=>(0,g.jsx)(c,{className:`h-16`},e))}):(0,g.jsxs)(`div`,{className:`divide-y divide-edge`,children:[K.data?.traces.length===0&&(0,g.jsx)(`p`,{className:`flex h-48 items-center justify-center px-4 text-sm text-fg-muted`,children:t(`No traces in this range`,`此时间范围内暂无记录`)}),K.data?.traces.map(n=>(0,g.jsxs)(`button`,{onClick:()=>H(n.traceId),className:`flex w-full flex-col gap-2 px-3 py-3 text-left text-sm hover:bg-surface-hover sm:flex-row sm:items-center sm:justify-between`,children:[(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.attributes[`xopc.agentId`]?` · ${n.attributes[`xopc.agentId`]}`:``]}),(0,g.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[new Date(n.startedAt).toLocaleString(e?`zh-CN`:`en-US`),` · `,n.traceId]}),n.stats&&(0,g.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n.stats.generations,` `,t(`model calls`,`次模型调用`),` · `,n.stats.tokens,` tokens · `,n.stats.unknownCostCalls>0?`${t(`Cost pending`,`费用待确认`)}${n.stats.knownCostUsd>0?` · ${t(`known portion`,`已知部分`)} ${n.stats.knownCostUsd.toFixed(4)}`:``}`:`$${n.stats.knownCostUsd.toFixed(4)}`]})]}),(0,g.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:[t(n.status,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[n.status]??n.status),` · `,n.endedAt?`${Math.round(n.endedAt-n.startedAt)} ms`:`—`,n.partialReason?` · ${t(`Partial`,`部分记录`)}`:``]})]},n.traceId))]})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,g.jsx)(`p`,{"aria-live":`polite`,className:`text-xs text-fg-muted`,children:t(`Page ${L+1} · ${K.data?.traces.length??0} records`,`第 ${L+1} 页 · ${K.data?.traces.length??0} 条`)}),(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsx)(s,{disabled:L===0||K.isValidating,onClick:()=>R(e=>Math.max(0,e-1)),children:t(`Previous page`,`上一页`)}),(0,g.jsx)(s,{disabled:!K.data?.nextCursor||K.isValidating,onClick:()=>{let e=K.data?.nextCursor;e&&(I(t=>[...t.slice(0,L+1),e]),R(e=>e+1))},children:t(`Next page`,`下一页`)})]})]})]}),(0,g.jsx)(se,{open:!!V,onOpenChange:e=>{e||H(void 0)},children:(0,g.jsxs)(ie,{children:[(0,g.jsx)(ne,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,g.jsxs)(ae,{className:`fixed left-1/2 top-1/2 z-[91] flex h-[min(44rem,calc(100vh-2rem))] w-[min(64rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4`,children:[(0,g.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,g.jsx)(oe,{className:`font-medium`,children:t(`Trace details`,`追踪详情`)}),(0,g.jsx)(re,{asChild:!0,children:(0,g.jsx)(s,{children:t(`Close`,`关闭`)})})]}),(0,g.jsx)(l,{className:`shrink-0 truncate text-xs text-fg-muted`,children:V}),(0,g.jsx)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-4`,children:q.error?(0,g.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,g.jsx)(`p`,{children:t(`Unable to load this record.`,`无法加载此记录。`)}),(0,g.jsx)(s,{variant:`ghost`,onClick:()=>void q.mutate(),children:t(`Retry loading record`,`重新加载此记录`)})]}):q.data?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`p`,{className:`text-sm`,children:[q.data.trace.status,` `,q.data.trace.partialReason&&` · ${q.data.trace.partialReason}`]}),he(q.data.spans).map(e=>(0,g.jsxs)(`details`,{style:{marginLeft:me(e,q.data.spans)*12},className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,g.jsxs)(`summary`,{className:`cursor-pointer`,children:[e.name,` · `,e.status,` · `,e.endedAt?`${Math.round(e.endedAt-e.startedAt)} ms`:`—`]}),(0,g.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs text-fg-muted`,children:JSON.stringify(e.attributes,null,2)})]},e.spanId))]}):(0,g.jsx)(y,{})}),(0,g.jsx)(`div`,{className:`shrink-0 border-t border-edge pt-3`,children:(0,g.jsx)(s,{disabled:!q.data||E,onClick:()=>void Oe(),children:t(`Export JSON`,`导出 JSON`)})})]})]})}),(0,g.jsx)(se,{open:Ee,onOpenChange:W,children:(0,g.jsxs)(ie,{children:[(0,g.jsx)(ne,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,g.jsxs)(ae,{className:`fixed left-1/2 top-1/2 z-[91] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 space-y-4 rounded-xl border border-edge bg-surface-overlay p-5`,children:[(0,g.jsx)(oe,{children:t(`Clear local traces?`,`清空本地追踪?`)}),(0,g.jsx)(l,{className:`text-sm text-fg-muted`,children:t(`Removes retained local traces. Conversations, usage records and Langfuse data remain available.`,`删除已保留的本地追踪。会话、用量记录及 Langfuse 数据仍保留。`)}),(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsx)(s,{disabled:E||$,onClick:()=>void Y(async()=>{await h(`traces`,`DELETE`),W(!1),H(void 0)}),children:t(`Clear`,`清空`)}),(0,g.jsx)(re,{asChild:!0,children:(0,g.jsx)(s,{children:t(`Cancel`,`取消`)})})]})]})]})})]})}export{b as TracingSettingsPage};
@@ -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{a as i,i as a,l as o,n as s,o as c}from"./locale-store-_-_QzAV0.js";import{t as l}from"./messages-D1u8VsPq.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as ee}from"./globe-DSSGFWFn.js";import{t as te}from"./loader-circle-CifKLtgG.js";import{t as d}from"./power-ZI-pBczI.js";import{t as f}from"./cn-0WouolD0.js";import{i as p}from"./vendor-swr-CdRzEUwF.js";import{t as m}from"./button-CnRSIP6m.js";import{t as h}from"./skeleton-BI5TyibZ.js";import{n as g,r as _}from"./gateway-config-swr-i6wzzdws.js";import{s as v}from"./form-field-width-DJw_jULe.js";import{u as y}from"./navigation-D62kPsA9.js";import{t as b}from"./copy-text-row-CYIv7RfP.js";import{n as ne,t as re}from"./settings-form-section-num14vSv.js";var x=e(t(),1),S=n(),C=r();function w(e){let t=(0,S.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=y(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=f(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,C.jsx)(u,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=c):c=t[5];let l;return t[6]!==r||t[7]!==o||t[8]!==s?(l=(0,C.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[6]=r,t[7]=o,t[8]=s,t[9]=l):l=t[9],l}async function T(){let e=await i(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function E(e=`serve`){let t=await i(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function D(){let e=await i(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var O=`https://tailscale.com/download`;function k(e){let t=(0,S.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,C.jsx)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function A({embedded:e=!1}){let t=s(e=>e.language),n=l(t).remoteAccess.tailscale,r=(0,x.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!o(e=>e.conversationId),[a,c]=(0,x.useState)(!1),[u,f]=(0,x.useState)(null),{data:g,mutate:_,isLoading:v}=p(i?`exposure-status`:null,T,{refreshInterval:3e4}),y=g?.tailscale.hostname,S=g?.tailscale.active===!0,O=g?.tailscale.cliAvailable!==!1,A=y?`https://${y}/`:null,ie=(0,x.useCallback)(async()=>{c(!0),f(null);try{await E(`serve`),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[_]),ae=(0,x.useCallback)(async()=>{c(!0),f(null);try{await D(),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[_]);if(!i)return null;let j=(0,C.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,C.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,C.jsxs)(`span`,{children:[n.stepInstallBefore,(0,C.jsx)(k,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,C.jsx)(`span`,{children:n.stepEnable})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,C.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&g?.tailscale.cliAvailable===!1?(0,C.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,C.jsx)(k,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,v&&!g?(0,C.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,C.jsx)(h,{className:`h-20 rounded-lg`}),(0,C.jsx)(h,{className:`h-20 rounded-lg`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(re,{children:[(0,C.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),A?(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(b,{text:A,labels:r})}):null,u?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,C.jsxs)(m,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void ae(),children:[a?(0,C.jsx)(te,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,C.jsxs)(m,{type:`button`,disabled:a||!O,onClick:()=>void ie(),children:[a?(0,C.jsx)(te,{className:`mr-1 size-4 animate-spin`}):(0,C.jsx)(d,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,C.jsx)(w,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?j:(0,C.jsxs)(re,{children:[(0,C.jsx)(ne,{icon:ee,title:n.title,subtitle:n.subtitle}),j]})}async function ie(e){let t=await i(a(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ae(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function j(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function oe(){return(0,x.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||j(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function se(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,v,`dark:border-edge`)}function ce(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function M(){let e=(0,S.c)(85),t=s(ue),n;e[0]===t?n=e[1]:(n=l(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!o(le),a=oe(),c=_(i).data?.payload?.config,u;e[2]===c?u=e[3]:(u=ce(c),e[2]=c,e[3]=u);let d=u,[p,h]=(0,x.useState)(``),v;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={busy:!1,result:null},e[4]=v):v=e[4];let[y,b]=(0,x.useState)(v),w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={busy:!1,error:null},e[5]=w):w=e[5];let[T,E]=(0,x.useState)(w),D,O;e[6]!==d||e[7]!==a||e[8]!==p?(D=()=>{p||(d?h(d):a&&h(a))},O=[d,a,p],e[6]=d,e[7]=a,e[8]=p,e[9]=D,e[10]=O):(D=e[9],O=e[10]),(0,x.useEffect)(D,O);let k;bb0:{let t;e[11]===p?t=e[12]:(t=p.trim(),e[11]=p,e[12]=t);let n=t;if(n){k=n;break bb0}k=d??a??``}let A=k,j=!d&&!!a&&A===a,M;e[13]!==p||e[14]!==A?(M=async()=>{let e=p.trim()||A;if(e){b({busy:!0,result:null});try{let t=await ie(e);b({busy:!1,result:t})}catch(e){let t=e;b({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=p,e[14]=A,e[15]=M):M=e[15];let fe=M,N;e[16]===A?N=e[17]:(N=async()=>{let e=A.trim();if(e){E({busy:!0,error:null});try{await ae(e),await g(),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=A,e[17]=N);let pe=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{E({busy:!0,error:null});try{await ae(null),await g(),h(``),b({busy:!1,result:null}),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let me=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,C.jsx)(ne,{icon:ee,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,C.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=f(se(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{h(e.target.value),b({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==p||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,C.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:p,onChange:R}),e[26]=p,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===fe?B=e[31]:(B=()=>void fe(),e[30]=fe,e[31]=B);let V;e[32]!==p||e[33]!==y.busy?(V=y.busy||!p.trim(),e[32]=p,e[33]=y.busy,e[34]=V):V=e[34];let H;e[35]===y.busy?H=e[36]:(H=y.busy?(0,C.jsx)(te,{className:`size-3.5 animate-spin`}):null,e[35]=y.busy,e[36]=H);let he=y.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,C.jsxs)(m,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==a||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&a?(0,C.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,C.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,C.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:a}),(0,C.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=a,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==y.result||e[53]!==r.probeStatus?(q=y.result?(0,C.jsx)(de,{result:y.result,labels:r.probeStatus}):null,e[52]=y.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==d||e[56]!==A||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==T.busy?(J=A&&d!==A?(0,C.jsxs)(m,{type:`button`,onClick:()=>void pe(),disabled:T.busy,children:[T.busy?(0,C.jsx)(te,{className:`size-3.5 animate-spin`}):null,T.busy?r.saving:r.saveAsDefault]}):null,e[55]=d,e[56]=A,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=T.busy,e[61]=J):J=e[61];let Y;e[62]!==d||e[63]!==r.clear||e[64]!==T.busy?(Y=d?(0,C.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:T.busy,children:r.clear}):null,e[62]=d,e[63]=r.clear,e[64]=T.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===T.error?Z=e[70]:(Z=T.error?(0,C.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:T.error}):null,e[69]=T.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,C.jsx)(`div`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,C.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,C.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,C.jsxs)(re,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function le(e){return e.conversationId}function ue(e){return e.language}function de(e){let t=(0,S.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,C.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,C.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,C.jsxs)(C.Fragment,{children:[` · `,(0,C.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,C.jsxs)(`div`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,C.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,C.jsxs)(C.Fragment,{children:[` — `,(0,C.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,C.jsxs)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-xs text-red-900 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function fe(){let e=await c(a(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function N(e){try{return{kind:`ready`,setup:(await c(a(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({targetKind:e})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function pe(e){return c(a(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await c(a(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await c(a(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await i(a(`/api/browser/extension/archive`));if(!e.ok)throw Error(`Browser extension download failed (${e.status})`);let t=e.headers.get(`Content-Disposition`)??``,n=/filename="([^"]+)"/.exec(t)?.[1]??`xopc-browser-extension.zip`,r=URL.createObjectURL(await e.blob());try{let e=document.createElement(`a`);e.href=r,e.download=n,e.click()}finally{URL.revokeObjectURL(r)}}var I=`https://console.xopc.ai/access/client`;function L(e){if(!e||typeof e!=`object`)return;let t=e.body;if(!t||typeof t!=`object`)return;let n=t.code;if(typeof n==`string`)return n;let r=t.error;if(!r||typeof r!=`object`)return;let i=r.code;return typeof i==`string`?i:void 0}function R(e){return L(e)===`TUNNEL_REGISTRATION_KEY_REJECTED`||e instanceof Error&&/\bTunnel register failed: 401\b/.test(e.message)}function z(e){return L(e)===`TUNNEL_RECOVERY_PROOF_REJECTED`||e instanceof Error&&e.message===`Active lease ownership proof required`}function B(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function V(){return c(a(`/api/tunnel/status`))}async function H(){await c(a(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function he(){await c(a(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function U(e){return c(a(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({recoverActiveLease:e?.recoverActiveLease===!0})})}async function W(e){return c(a(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function G(){let e=(await c(a(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function K(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{w as S,fe as _,H as a,A as b,W as c,z as d,R as f,F as g,me as h,he as i,L as l,N as m,V as n,G as o,P as p,K as r,U as s,I as t,B as u,pe as v,T as x,M as y};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,n as s,o as c}from"./locale-store-Bg_XR36n.js";import{t as l}from"./messages-DG4HLOER.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as ee}from"./globe-DSSGFWFn.js";import{t as te}from"./loader-circle-CifKLtgG.js";import{t as d}from"./power-ZI-pBczI.js";import{t as f}from"./cn-0WouolD0.js";import{t as p}from"./button-CnRSIP6m.js";import{t as m}from"./skeleton-BI5TyibZ.js";import{i as h}from"./vendor-swr-CdRzEUwF.js";import{n as g,r as _}from"./gateway-config-swr-DfPQIHOL.js";import{s as v}from"./form-field-width-DJw_jULe.js";import{u as y}from"./navigation-D62kPsA9.js";import{t as b}from"./copy-text-row-CYIv7RfP.js";import{n as ne,t as re}from"./settings-form-section-num14vSv.js";var x=e(t(),1),S=n(),C=r();function w(e){let t=(0,S.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=y(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=f(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=s);let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,C.jsx)(u,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=c):c=t[5];let l;return t[6]!==r||t[7]!==o||t[8]!==s?(l=(0,C.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[6]=r,t[7]=o,t[8]=s,t[9]=l):l=t[9],l}async function T(){let e=await i(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function E(e=`serve`){let t=await i(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function D(){let e=await i(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var O=`https://tailscale.com/download`;function k(e){let t=(0,S.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,C.jsx)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function A({embedded:e=!1}){let t=s(e=>e.language),n=l(t).remoteAccess.tailscale,r=(0,x.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:l(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!o(e=>e.conversationId),[a,c]=(0,x.useState)(!1),[u,f]=(0,x.useState)(null),{data:g,mutate:_,isLoading:v}=h(i?`exposure-status`:null,T,{refreshInterval:3e4}),y=g?.tailscale.hostname,S=g?.tailscale.active===!0,O=g?.tailscale.cliAvailable!==!1,A=y?`https://${y}/`:null,ie=(0,x.useCallback)(async()=>{c(!0),f(null);try{await E(`serve`),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[_]),ae=(0,x.useCallback)(async()=>{c(!0),f(null);try{await D(),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[_]);if(!i)return null;let j=(0,C.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,C.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,C.jsxs)(`span`,{children:[n.stepInstallBefore,(0,C.jsx)(k,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,C.jsx)(`span`,{children:n.stepEnable})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,C.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&g?.tailscale.cliAvailable===!1?(0,C.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,C.jsx)(k,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,v&&!g?(0,C.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,C.jsx)(m,{className:`h-20 rounded-lg`}),(0,C.jsx)(m,{className:`h-20 rounded-lg`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(re,{children:[(0,C.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),A?(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(b,{text:A,labels:r})}):null,u?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,C.jsxs)(p,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void ae(),children:[a?(0,C.jsx)(te,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,C.jsxs)(p,{type:`button`,disabled:a||!O,onClick:()=>void ie(),children:[a?(0,C.jsx)(te,{className:`mr-1 size-4 animate-spin`}):(0,C.jsx)(d,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,C.jsx)(w,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?j:(0,C.jsxs)(re,{children:[(0,C.jsx)(ne,{icon:ee,title:n.title,subtitle:n.subtitle}),j]})}async function ie(e){let t=await i(a(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ae(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function j(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function oe(){return(0,x.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||j(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function se(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,v,`dark:border-edge`)}function ce(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function M(){let e=(0,S.c)(85),t=s(ue),n;e[0]===t?n=e[1]:(n=l(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!o(le),a=oe(),c=_(i).data?.payload?.config,u;e[2]===c?u=e[3]:(u=ce(c),e[2]=c,e[3]=u);let d=u,[m,h]=(0,x.useState)(``),v;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={busy:!1,result:null},e[4]=v):v=e[4];let[y,b]=(0,x.useState)(v),w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={busy:!1,error:null},e[5]=w):w=e[5];let[T,E]=(0,x.useState)(w),D,O;e[6]!==d||e[7]!==a||e[8]!==m?(D=()=>{m||(d?h(d):a&&h(a))},O=[d,a,m],e[6]=d,e[7]=a,e[8]=m,e[9]=D,e[10]=O):(D=e[9],O=e[10]),(0,x.useEffect)(D,O);let k;bb0:{let t;e[11]===m?t=e[12]:(t=m.trim(),e[11]=m,e[12]=t);let n=t;if(n){k=n;break bb0}k=d??a??``}let A=k,j=!d&&!!a&&A===a,M;e[13]!==m||e[14]!==A?(M=async()=>{let e=m.trim()||A;if(e){b({busy:!0,result:null});try{let t=await ie(e);b({busy:!1,result:t})}catch(e){let t=e;b({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=m,e[14]=A,e[15]=M):M=e[15];let fe=M,N;e[16]===A?N=e[17]:(N=async()=>{let e=A.trim();if(e){E({busy:!0,error:null});try{await ae(e),await g(),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=A,e[17]=N);let pe=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{E({busy:!0,error:null});try{await ae(null),await g(),h(``),b({busy:!1,result:null}),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let me=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,C.jsx)(ne,{icon:ee,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,C.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=f(se(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{h(e.target.value),b({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==m||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,C.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:m,onChange:R}),e[26]=m,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===fe?B=e[31]:(B=()=>void fe(),e[30]=fe,e[31]=B);let V;e[32]!==m||e[33]!==y.busy?(V=y.busy||!m.trim(),e[32]=m,e[33]=y.busy,e[34]=V):V=e[34];let H;e[35]===y.busy?H=e[36]:(H=y.busy?(0,C.jsx)(te,{className:`size-3.5 animate-spin`}):null,e[35]=y.busy,e[36]=H);let he=y.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,C.jsxs)(p,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==a||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&a?(0,C.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,C.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,C.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:a}),(0,C.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=a,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==y.result||e[53]!==r.probeStatus?(q=y.result?(0,C.jsx)(de,{result:y.result,labels:r.probeStatus}):null,e[52]=y.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==d||e[56]!==A||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==T.busy?(J=A&&d!==A?(0,C.jsxs)(p,{type:`button`,onClick:()=>void pe(),disabled:T.busy,children:[T.busy?(0,C.jsx)(te,{className:`size-3.5 animate-spin`}):null,T.busy?r.saving:r.saveAsDefault]}):null,e[55]=d,e[56]=A,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=T.busy,e[61]=J):J=e[61];let Y;e[62]!==d||e[63]!==r.clear||e[64]!==T.busy?(Y=d?(0,C.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:T.busy,children:r.clear}):null,e[62]=d,e[63]=r.clear,e[64]=T.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===T.error?Z=e[70]:(Z=T.error?(0,C.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:T.error}):null,e[69]=T.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,C.jsx)(`div`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,C.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,C.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,C.jsxs)(re,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function le(e){return e.conversationId}function ue(e){return e.language}function de(e){let t=(0,S.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,C.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,C.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,C.jsxs)(C.Fragment,{children:[` · `,(0,C.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,C.jsxs)(`div`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,C.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,C.jsxs)(C.Fragment,{children:[` — `,(0,C.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,C.jsxs)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-xs text-red-900 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function fe(){let e=await c(a(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function N(e){try{return{kind:`ready`,setup:(await c(a(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({targetKind:e})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function pe(e){return c(a(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await c(a(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await c(a(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await i(a(`/api/browser/extension/archive`));if(!e.ok)throw Error(`Browser extension download failed (${e.status})`);let t=e.headers.get(`Content-Disposition`)??``,n=/filename="([^"]+)"/.exec(t)?.[1]??`xopc-browser-extension.zip`,r=URL.createObjectURL(await e.blob());try{let e=document.createElement(`a`);e.href=r,e.download=n,e.click()}finally{URL.revokeObjectURL(r)}}var I=`https://console.xopc.ai/access/client`;function L(e){if(!e||typeof e!=`object`)return;let t=e.body;if(!t||typeof t!=`object`)return;let n=t.code;if(typeof n==`string`)return n;let r=t.error;if(!r||typeof r!=`object`)return;let i=r.code;return typeof i==`string`?i:void 0}function R(e){return L(e)===`TUNNEL_REGISTRATION_KEY_REJECTED`||e instanceof Error&&/\bTunnel register failed: 401\b/.test(e.message)}function z(e){return L(e)===`TUNNEL_RECOVERY_PROOF_REJECTED`||e instanceof Error&&e.message===`Active lease ownership proof required`}function B(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function V(){return c(a(`/api/tunnel/status`))}async function H(){await c(a(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function he(){await c(a(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function U(e){return c(a(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({recoverActiveLease:e?.recoverActiveLease===!0})})}async function W(e){return c(a(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function G(){let e=(await c(a(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function K(e){await c(a(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{w as S,fe as _,H as a,A as b,W as c,z as d,R as f,F as g,me as h,he as i,L as l,N as m,V as n,G as o,P as p,K as r,U as s,I as t,B as u,pe as v,T as x,M as y};
@@ -1 +1 @@
1
- import{i as e,o as t,p as n}from"./locale-store-_-_QzAV0.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-Bg_XR36n.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-_-_QzAV0.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(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),u=i(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),d=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 f(){return n(t(`/api/user-model`))}async function p(){let e=await f();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 m(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 h(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function g(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:r})})}function _(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}/scope`),{method:`PATCH`,body:JSON.stringify({scope:r})})}function v(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({statement:r})})}function y(e,r){return n(t(`/api/user-model/priorities/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(r)})}function b(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 x(e,r){return n(t(`/api/user-model/rules/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:r})})}function S(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 C(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 w(e){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`DELETE`})}function T(e){return n(t(`/api/knowledge-memory/${encodeURIComponent(e)}`),{method:`DELETE`})}function E(e){return n(t(`/api/user-model/settings`),{method:`PATCH`,body:JSON.stringify(e)})}async function D(){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)}var O=e=>e.status===`queued`||e.status===`running`,k=new Set,A,j=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 A||(A=(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=>!O(e)&&o.get(e.id)!==e.status)&&a(`/api/user-model`);for(let e of i.sources)O(e)&&e.metadata.phase===`waiting_desktop`&&M(e)}catch(t){e({error:t instanceof Error?t.message:String(t)})}})().finally(()=>{A=void 0}),A)}}));async function M(e){let r=window.electronAPI?.understandingSources?.collect;if(!(!r||k.size>0)){k.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 j.getState().poll()}catch(e){j.setState({error:e instanceof Error?e.message:String(e)})}finally{k.delete(e.id)}}}export{o as C,s as S,m as _,w as a,l as b,D as c,C as d,_ as f,y as g,E as h,S as i,f as l,x as m,v as n,T as o,g as p,b as r,h as s,j as t,p as u,d as v,c as x,u as y};
1
+ import{a as e,i as t,o as n,p as r}from"./locale-store-Bg_XR36n.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(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),u=i(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),d=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 f(){return n(t(`/api/user-model`))}async function p(){let e=await f();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 m(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 h(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function g(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:r})})}function _(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}/scope`),{method:`PATCH`,body:JSON.stringify({scope:r})})}function v(e,r){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({statement:r})})}function y(e,r){return n(t(`/api/user-model/priorities/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(r)})}function b(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 x(e,r){return n(t(`/api/user-model/rules/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:r})})}function S(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 C(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 w(e){return n(t(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`DELETE`})}function T(e){return n(t(`/api/knowledge-memory/${encodeURIComponent(e)}`),{method:`DELETE`})}function E(e){return n(t(`/api/user-model/settings`),{method:`PATCH`,body:JSON.stringify(e)})}async function D(){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)}var O=e=>e.status===`queued`||e.status===`running`,k=new Set,A,j=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 A||(A=(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=>!O(e)&&o.get(e.id)!==e.status)&&a(`/api/user-model`);for(let e of i.sources)O(e)&&e.metadata.phase===`waiting_desktop`&&M(e)}catch(t){e({error:t instanceof Error?t.message:String(t)})}})().finally(()=>{A=void 0}),A)}}));async function M(e){let r=window.electronAPI?.understandingSources?.collect;if(!(!r||k.size>0)){k.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 j.getState().poll()}catch(e){j.setState({error:e instanceof Error?e.message:String(e)})}finally{k.delete(e.id)}}}export{o as C,s as S,m as _,w as a,l as b,D as c,C as d,_ as f,y as g,E as h,S as i,f as l,x as m,v as n,T as o,g as p,b as r,h as s,j as t,p as u,d as v,c as x,u 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-_-_QzAV0.js";import{t as c}from"./messages-D1u8VsPq.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./popover-select-DD8fmrxH.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{i as _}from"./vendor-swr-CdRzEUwF.js";import{t as v}from"./button-CnRSIP6m.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{t as b}from"./sliding-tab-list-DuQyViqe.js";import{n as x,t as S}from"./settings-page-header-CoPd_JDb.js";import"./settings-page-layout-D39EvFvm.js";import{t as ee}from"./xopc-cloud-account-card-Dqfy4Lwy.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)(y,{className:`h-52 rounded-xl`}),(0,O.jsx)(y,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(y,{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=_([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=_([`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)(v,{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)(v,{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)(v,{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)(v,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(v,{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)(v,{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)(y,{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)(v,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(v,{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)(v,{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-Bg_XR36n.js";import{t as c}from"./messages-DG4HLOER.js";import{t as l}from"./bot-DjLkhyZL.js";import{t as u}from"./popover-select-DD8fmrxH.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"./button-CnRSIP6m.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{i as y}from"./vendor-swr-CdRzEUwF.js";import{t as b}from"./sliding-tab-list-DuQyViqe.js";import{n as x,t as S}from"./settings-page-header-CyUHrn7c.js";import"./settings-page-layout-DGVqXrlp.js";import{t as ee}from"./xopc-cloud-account-card-IcH9KDzx.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)(v,{className:`h-52 rounded-xl`}),(0,O.jsx)(v,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(v,{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=y([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=y([`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)(_,{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)(_,{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)(_,{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)(_,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(_,{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)(_,{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)(v,{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)(_,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(_,{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)(_,{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-_-_QzAV0.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-Bg_XR36n.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};