@xopcai/xopc 0.0.411 → 0.0.413

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 (307) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-sGJnq-SA.js → agent-avatar-dicebear-BT6oqCMD.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BFmRRD_4.js +1 -0
  5. package/dist/gateway/static/root/assets/agents-Clwskw2J.js +77 -0
  6. package/dist/gateway/static/root/assets/{agents-admin-api-uGDeJR1f.js → agents-admin-api-CeBkHnl8.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-management-settings-panel-BdCgtTfT.js +1 -0
  8. package/dist/gateway/static/root/assets/appearance-settings-C3-hCFlF.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-DJbKg3va.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-CGdU_E5B.js → archive-plugin-BviFGCy4.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-BAPZY56r.js → automations-page-CfzazXE5.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-D_X0_1X3.js +8 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-B0ispXo2.js → binary-plugins-Dp-gtJEk.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-B9Ci-prO.js → block-editor-D-DEPdpi.js} +4 -4
  15. package/dist/gateway/static/root/assets/{browser-automation-inputs-D4-vQc4g.js → browser-automation-inputs-D1pDgMJu.js} +1 -1
  16. package/dist/gateway/static/root/assets/browser-automations-page-BI-ep6uM.js +3 -0
  17. package/dist/gateway/static/root/assets/browser-settings-page-BTyQ4-vN.js +3 -0
  18. package/dist/gateway/static/root/assets/capabilities-Bpeh6E22.js +1 -0
  19. package/dist/gateway/static/root/assets/capabilities-page-GNS95mG9.js +2 -0
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-DBiv1HN-.js +8 -0
  21. package/dist/gateway/static/root/assets/{capability-header-actions-Cic05oWh.js → capability-header-actions-CP2fI9Fe.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-DWlrUKBr.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-Bm-IGeDe.js → chat-terminal-dock-BL3tFntQ.js} +2 -2
  24. package/dist/gateway/static/root/assets/computer-settings-page-DEQ5GYfC.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-service-page-DcdASUU9.js → connector-service-page-CecwMnC5.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-BcpUvrtl.js +1 -0
  27. package/dist/gateway/static/root/assets/{date-picker-gVLWu9R0.js → date-picker-N5jnlvPs.js} +1 -1
  28. package/dist/gateway/static/root/assets/{dependency-picker-C0LARyok.js → dependency-picker-C4jddxFl.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-v_le3sCs.js → desktop-pet-BCbiUNQG.js} +1 -1
  30. package/dist/gateway/static/root/assets/desktop-pet-settings-CkKU0JMY.js +1 -0
  31. package/dist/gateway/static/root/assets/device-pairing-wizard--E2GQoY1.js +1 -0
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-CBefVUPR.js → directory-picker-path-field-CbMbPimD.js} +1 -1
  33. package/dist/gateway/static/root/assets/extension-debug-page-OE1nJMQ8.js +1 -0
  34. package/dist/gateway/static/root/assets/{extension-page-C0-oP7S_.js → extension-page-BEomiKhy.js} +1 -1
  35. package/dist/gateway/static/root/assets/extension-settings-page-BFOjQeSX.js +1 -0
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-BVqYVaGy.js → gateway-config-swr-DF_HV6NP.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-realtime-CY1LBGBS.js → gateway-realtime-DMAzNlm-.js} +1 -1
  38. package/dist/gateway/static/root/assets/gateway-realtime-store-CoIgC1Al.js +1 -0
  39. package/dist/gateway/static/root/assets/gateway-settings-CR4CsfNN.js +1 -0
  40. package/dist/gateway/static/root/assets/{gateway-startup-retry-CPKGkr6D.js → gateway-startup-retry-B91CBTzO.js} +1 -1
  41. package/dist/gateway/static/root/assets/highlight-code-6ONPRH5r.js +1 -0
  42. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-CN5PNRN3.js → highlighted-body-KQOG7T2V-EJ9Kg4iQ.js} +1 -1
  43. package/dist/gateway/static/root/assets/home-page-B9w3a6r2.js +2 -0
  44. package/dist/gateway/static/root/assets/{image-generation-api-DRLXG9Ws.js → image-generation-api-D0HNic89.js} +1 -1
  45. package/dist/gateway/static/root/assets/imports-page-bxTINe-2.js +1 -0
  46. package/dist/gateway/static/root/assets/index-D1oivYvN.js +710 -0
  47. package/dist/gateway/static/root/assets/index-D_7q1UkI.css +1 -0
  48. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Cmi-2SIh.js +1 -0
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-NGCmXpa_.js +1 -0
  50. package/dist/gateway/static/root/assets/{local-apps-page-BChE6nUD.js → local-apps-page-jgaogH9Z.js} +1 -1
  51. package/dist/gateway/static/root/assets/{local-session-drafts-BCaC-1rH.js → local-session-drafts-DvmwiLUx.js} +1 -1
  52. package/dist/gateway/static/root/assets/{locale-store-DAgpZxAS.js → locale-store-JogcXC4J.js} +1 -1
  53. package/dist/gateway/static/root/assets/logs-page-drrr-c2W.js +2 -0
  54. package/dist/gateway/static/root/assets/management-settings-Dc1opXVr.js +1 -0
  55. package/dist/gateway/static/root/assets/{media-plugins-BmLuWkkZ.js → media-plugins-BRS9puQV.js} +1 -1
  56. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-B--edI1I.js +1 -0
  57. package/dist/gateway/static/root/assets/{messages-DMXSIJUO.js → messages-RzwPiQNL.js} +2 -2
  58. package/dist/gateway/static/root/assets/note-detail-panel-C3s4-ytB.js +5 -0
  59. package/dist/gateway/static/root/assets/note-image-lightbox-D7q5-KuS.js +1 -0
  60. package/dist/gateway/static/root/assets/notes-page-qVxoErUS.js +8 -0
  61. package/dist/gateway/static/root/assets/{page-context-capture-button-B7rDRlS7.js → page-context-capture-button-D_VOB2_C.js} +1 -1
  62. package/dist/gateway/static/root/assets/personal-page-B-T8NzQo.js +1 -0
  63. package/dist/gateway/static/root/assets/personal-settings-panel-BKA4fbYH.js +1 -0
  64. package/dist/gateway/static/root/assets/phone-dependencies-card-DhEsfEUN.js +1 -0
  65. package/dist/gateway/static/root/assets/phone-model-picker-J4mFDk21.js +1 -0
  66. package/dist/gateway/static/root/assets/phone-settings-page-BLflz8CQ.js +1 -0
  67. package/dist/gateway/static/root/assets/plugin-details-dialog-1BwvmKZi.js +1 -0
  68. package/dist/gateway/static/root/assets/{preview-open-alternatives-Z4NM7_Dn.js → preview-open-alternatives-DaTaSKox.js} +1 -1
  69. package/dist/gateway/static/root/assets/{product-open-page-C5TcIaJj.js → product-open-page-wYlC0IVZ.js} +1 -1
  70. package/dist/gateway/static/root/assets/{product-preview-content-5xID6jIj.js → product-preview-content-Bxur-p6S.js} +1 -1
  71. package/dist/gateway/static/root/assets/project-detail-page-DwowzxzD.js +7 -0
  72. package/dist/gateway/static/root/assets/projects-page-Bwvn4i_e.js +1 -0
  73. package/dist/gateway/static/root/assets/{registry-api-B6kqbuw8.js → registry-api-BGqSwITi.js} +1 -1
  74. package/dist/gateway/static/root/assets/remote-access-hub-DrHisOUe.js +1 -0
  75. package/dist/gateway/static/root/assets/runtime-tools-api-CSm5SpnR.js +5 -0
  76. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-DXNidliV.js +1 -0
  77. package/dist/gateway/static/root/assets/{schema-form-DtPkiYwm.js → schema-form-DeSZ7SiO.js} +1 -1
  78. package/dist/gateway/static/root/assets/{session-api-D6-Vz8xK.js → session-api-DTxZyMta.js} +1 -1
  79. package/dist/gateway/static/root/assets/{session-manager-DWbcMHcj.js → session-manager-B2HDomj4.js} +1 -1
  80. package/dist/gateway/static/root/assets/sessions-page-seP7t0kv.js +1 -0
  81. package/dist/gateway/static/root/assets/settings-advanced-gate-VqBu7gHu.js +1 -0
  82. package/dist/gateway/static/root/assets/{settings-form-section-DD3iD5t5.js → settings-form-section-BNYQjZU4.js} +1 -1
  83. package/dist/gateway/static/root/assets/{settings-page-iLY3LRDq.js → settings-page-29Ix0jSQ.js} +1 -1
  84. package/dist/gateway/static/root/assets/{settings-page-layout-Dx5S-Msc.js → settings-page-header-CYpuTXUW.js} +1 -1
  85. package/dist/gateway/static/root/assets/settings-page-layout-B20AfmFG.js +1 -0
  86. package/dist/gateway/static/root/assets/setup-status-panel-COQZgKX9.js +1 -0
  87. package/dist/gateway/static/root/assets/{share-preview-page-B8h9lqDL.js → share-preview-page-CwMRULXc.js} +1 -1
  88. package/dist/gateway/static/root/assets/shares-settings-BWaykw9E.js +1 -0
  89. package/dist/gateway/static/root/assets/{skill-api-C9RsrvOp.js → skill-api-xfB5fUAh.js} +1 -1
  90. package/dist/gateway/static/root/assets/skill-reload-api-Bq-3_MCt.js +1 -0
  91. package/dist/gateway/static/root/assets/skills-page-C3LfWsAZ.js +2 -0
  92. package/dist/gateway/static/root/assets/system-settings-panel-DRJu1ehM.js +1 -0
  93. package/dist/gateway/static/root/assets/task-detail-page-XCJFP-Aa.js +2 -0
  94. package/dist/gateway/static/root/assets/{task-result-evidence-DjNWPpn_.js → task-result-evidence-C4o_Yue_.js} +1 -1
  95. package/dist/gateway/static/root/assets/tracing-settings-page-CYslh-Pu.js +1 -0
  96. package/dist/gateway/static/root/assets/{tunnel-api-C6XfsSWy.js → tunnel-api-Bi_kw6bv.js} +1 -1
  97. package/dist/gateway/static/root/assets/usage-page-CTTmklCs.js +1 -0
  98. package/dist/gateway/static/root/assets/{use-autosave-DO-Twmbm.js → use-autosave-BkB9uD93.js} +1 -1
  99. package/dist/gateway/static/root/assets/user-model-page-BDqguzRE.js +2 -0
  100. package/dist/gateway/static/root/assets/{voice-api-key-field-MGe3HkS_.js → voice-api-key-field-bt8_Agih.js} +1 -1
  101. package/dist/gateway/static/root/assets/{voice-config-api-CPKzUb4R.js → voice-config-api-D7xsWrdh.js} +1 -1
  102. package/dist/gateway/static/root/assets/{work-discovery-overlay-DptHqYh5.js → work-discovery-overlay-D3NG14dX.js} +1 -1
  103. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Y_UIryBH.js → xopc-cloud-account-card-B2OUKOQi.js} +1 -1
  104. package/dist/gateway/static/root/index.html +14 -14
  105. package/dist/package.js +1 -1
  106. package/dist/packages/gateway-contract/src/capabilities.js +1 -0
  107. package/dist/src/agent/agent-manager.js +1 -1
  108. package/dist/src/agent/background-review/prompts.js +4 -3
  109. package/dist/src/agent/background-review/run-background-review.js +1 -1
  110. package/dist/src/agent/embedded/run-turn.js +1 -1
  111. package/dist/src/agent/embedded/xopc-stream-bridge.js +7 -3
  112. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  113. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  114. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  115. package/dist/src/agent/prompt/system-prompt.js +1 -1
  116. package/dist/src/agent/service.js +1 -1
  117. package/dist/src/agent/skills/index.js +1 -1
  118. package/dist/src/agent/skills/managed-store.js +1 -1
  119. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  120. package/dist/src/agent/tool-manuals/index.js +7 -0
  121. package/dist/src/agent/tool-manuals/phone.d.ts +1 -0
  122. package/dist/src/agent/tool-manuals/phone.js +16 -0
  123. package/dist/src/agent/tools/factory.js +15 -0
  124. package/dist/src/agent/tools/knowledge-memory-tool.js +1 -1
  125. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  126. package/dist/src/agent/tools/personal-task-tool.d.ts +2 -1
  127. package/dist/src/agent/tools/personal-task-tool.js +43 -20
  128. package/dist/src/agent/tools/phone-use-tool.d.ts +8 -0
  129. package/dist/src/agent/tools/phone-use-tool.js +49 -0
  130. package/dist/src/agent/tools/session-recall-tool.js +2 -1
  131. package/dist/src/agent/tools/session-search-tool.js +11 -5
  132. package/dist/src/agent/tools/user-context-tool.js +1 -1
  133. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  134. package/dist/src/agent-catalog/capabilities.js +2 -2
  135. package/dist/src/agent-catalog/repository.js +5 -1
  136. package/dist/src/agent-config/index.js +2 -2
  137. package/dist/src/agent-config/resolver.js +5 -0
  138. package/dist/src/agent-config/schema.d.ts +24 -0
  139. package/dist/src/agent-config/schema.js +5 -2
  140. package/dist/src/automations/capabilities/drafts.js +1 -1
  141. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  142. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  143. package/dist/src/capabilities/runtime/product.js +1 -1
  144. package/dist/src/cli/command-manifest.js +1 -1
  145. package/dist/src/cli/commands/agents.js +1 -1
  146. package/dist/src/cli/commands/models.js +1 -1
  147. package/dist/src/cli/commands/onboard/model.js +1 -1
  148. package/dist/src/cli/commands/onboard.js +1 -1
  149. package/dist/src/cli/commands/runtime.js +32 -4
  150. package/dist/src/cli/utils/init-workspace-core.js +6 -4
  151. package/dist/src/computer/diagnostics.d.ts +1 -1
  152. package/dist/src/config/agent-profile.js +1 -1
  153. package/dist/src/config/config-file.d.ts +6 -0
  154. package/dist/src/config/config-file.js +35 -0
  155. package/dist/src/config/loader.js +5 -4
  156. package/dist/src/config/models-json.d.ts +36 -0
  157. package/dist/src/config/models-json.js +9 -0
  158. package/dist/src/config/schema.d.ts +12 -0
  159. package/dist/src/config/schema.js +6 -2
  160. package/dist/src/execution-environments/local-worktree-manager.js +1 -1
  161. package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
  162. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  163. package/dist/src/gateway/agent-builtin-tools.d.ts +7 -1
  164. package/dist/src/gateway/agent-builtin-tools.js +7 -0
  165. package/dist/src/gateway/agents-admin.js +2 -2
  166. package/dist/src/gateway/global-defaults-admin.js +2 -0
  167. package/dist/src/gateway/hono/lib/config-payload.d.ts +8 -0
  168. package/dist/src/gateway/hono/routes/agents.js +1 -1
  169. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  170. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  171. package/dist/src/gateway/hono/routes/models.js +3 -0
  172. package/dist/src/gateway/hono/routes/notes.js +2 -2
  173. package/dist/src/gateway/hono/routes/phone-dependencies.d.ts +3 -0
  174. package/dist/src/gateway/hono/routes/phone-dependencies.js +137 -0
  175. package/dist/src/gateway/hono/routes/phone.d.ts +4 -0
  176. package/dist/src/gateway/hono/routes/phone.js +445 -0
  177. package/dist/src/gateway/hono/routes/projects.js +2 -2
  178. package/dist/src/gateway/hono/routes/runtime-tools.js +2 -0
  179. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  180. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  181. package/dist/src/gateway/image-generation-setup.js +1 -1
  182. package/dist/src/gateway/server.js +1 -0
  183. package/dist/src/gateway/service/config-coordinator.d.ts +8 -0
  184. package/dist/src/gateway/service.d.ts +2 -0
  185. package/dist/src/gateway/service.js +17 -12
  186. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  187. package/dist/src/home-intelligence/host.js +2 -2
  188. package/dist/src/imports/importService.js +1 -1
  189. package/dist/src/knowledge-memory/repository.js +5 -0
  190. package/dist/src/local-apps/service.js +1 -1
  191. package/dist/src/memory-learning/forget-capture.js +12 -3
  192. package/dist/src/memory-learning/forgotten-history.d.ts +4 -0
  193. package/dist/src/memory-learning/forgotten-history.js +71 -4
  194. package/dist/src/memory-learning/work-capture.d.ts +1 -0
  195. package/dist/src/memory-learning/work-capture.js +28 -17
  196. package/dist/src/personal-agent/prompts.js +3 -2
  197. package/dist/src/personal-agent/service.js +1 -1
  198. package/dist/src/phone/adb-driver.d.ts +35 -0
  199. package/dist/src/phone/adb-driver.js +368 -0
  200. package/dist/src/phone/cloud-adb.d.ts +34 -0
  201. package/dist/src/phone/cloud-adb.js +223 -0
  202. package/dist/src/phone/cloud-phones.d.ts +29 -0
  203. package/dist/src/phone/cloud-phones.js +141 -0
  204. package/dist/src/phone/cloud-scrcpy.d.ts +20 -0
  205. package/dist/src/phone/cloud-scrcpy.js +122 -0
  206. package/dist/src/phone/contracts.d.ts +204 -0
  207. package/dist/src/phone/contracts.js +115 -0
  208. package/dist/src/phone/interactive-session.d.ts +34 -0
  209. package/dist/src/phone/interactive-session.js +164 -0
  210. package/dist/src/phone/live-provider.d.ts +57 -0
  211. package/dist/src/phone/live-provider.js +18 -0
  212. package/dist/src/phone/live-state.d.ts +28 -0
  213. package/dist/src/phone/live-state.js +71 -0
  214. package/dist/src/phone/model-adapter.d.ts +25 -0
  215. package/dist/src/phone/model-adapter.js +340 -0
  216. package/dist/src/phone/repository.d.ts +19 -0
  217. package/dist/src/phone/repository.js +100 -0
  218. package/dist/src/phone/runtime.d.ts +83 -0
  219. package/dist/src/phone/runtime.js +896 -0
  220. package/dist/src/phone/scrcpy.d.ts +62 -0
  221. package/dist/src/phone/scrcpy.js +345 -0
  222. package/dist/src/phone/stream-gateway.d.ts +26 -0
  223. package/dist/src/phone/stream-gateway.js +210 -0
  224. package/dist/src/process/phone-process.d.ts +4 -0
  225. package/dist/src/process/phone-process.js +38 -0
  226. package/dist/src/providers/extension-stream-bridge.js +8 -1
  227. package/dist/src/providers/model-call.js +6 -2
  228. package/dist/src/providers/model-catalog-persistence.js +3 -0
  229. package/dist/src/providers/model-catalog-types.d.ts +3 -0
  230. package/dist/src/providers/model-reference-auditor.js +5 -1
  231. package/dist/src/providers/model-registry.js +3 -0
  232. package/dist/src/runtime-tools/archive.d.ts +2 -2
  233. package/dist/src/runtime-tools/archive.js +1 -1
  234. package/dist/src/runtime-tools/downloader.d.ts +2 -2
  235. package/dist/src/runtime-tools/errors.d.ts +3 -3
  236. package/dist/src/runtime-tools/phone-dependencies.d.ts +40 -0
  237. package/dist/src/runtime-tools/phone-dependencies.js +188 -0
  238. package/dist/src/runtime-tools/phone-dependency-catalog.d.ts +16 -0
  239. package/dist/src/runtime-tools/phone-dependency-catalog.js +51 -0
  240. package/dist/src/runtime-tools/types.d.ts +1 -0
  241. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +1 -0
  242. package/dist/src/storage/sqlite/context-extraction-repository.js +12 -2
  243. package/dist/src/tasks/capabilities/read.js +2 -2
  244. package/dist/src/tasks/capabilities/write.js +1 -1
  245. package/dist/src/tasks/task-research-result.js +19 -2
  246. package/dist/src/tui/backends/embedded-backend.js +1 -1
  247. package/dist/src/usage/cloud-receipts.d.ts +5 -1
  248. package/dist/src/usage/cloud-receipts.js +10 -4
  249. package/dist/src/usage/cloud-wire.d.ts +37 -0
  250. package/dist/src/usage/cloud-wire.js +181 -0
  251. package/dist/src/usage/recorder.js +5 -4
  252. package/dist/src/user-model/capture/semantic.js +2 -2
  253. package/dist/src/voice/platform-catalog.d.ts +3 -0
  254. package/dist/src/voice/realtime/persona-context.js +1 -1
  255. package/package.json +9 -4
  256. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BI7OTo-T.js +0 -1
  257. package/dist/gateway/static/root/assets/agents-RIXL0p7_.js +0 -77
  258. package/dist/gateway/static/root/assets/app-management-settings-panel-BGzhSS6H.js +0 -1
  259. package/dist/gateway/static/root/assets/appearance-settings-DtEZq4b2.js +0 -1
  260. package/dist/gateway/static/root/assets/apps-page-DZqBof2D.js +0 -1
  261. package/dist/gateway/static/root/assets/automations-workspace-CI-yQnSj.js +0 -8
  262. package/dist/gateway/static/root/assets/browser-automations-page-Xzdif447.js +0 -3
  263. package/dist/gateway/static/root/assets/browser-settings-page-Bhu-83eC.js +0 -3
  264. package/dist/gateway/static/root/assets/capabilities-B9b5KCBb.js +0 -1
  265. package/dist/gateway/static/root/assets/capabilities-page-BIc0Zlsw.js +0 -2
  266. package/dist/gateway/static/root/assets/capabilities-settings-panel-CQEfpLdj.js +0 -8
  267. package/dist/gateway/static/root/assets/channels-DQbEoo_o.js +0 -1
  268. package/dist/gateway/static/root/assets/computer-settings-page-C9xMfwXK.js +0 -1
  269. package/dist/gateway/static/root/assets/connectors-page-eh-xpMPK.js +0 -1
  270. package/dist/gateway/static/root/assets/desktop-pet-settings-B_-j-D4W.js +0 -1
  271. package/dist/gateway/static/root/assets/device-pairing-wizard-CxG_FcQ6.js +0 -1
  272. package/dist/gateway/static/root/assets/extension-debug-page-CTe7Molh.js +0 -1
  273. package/dist/gateway/static/root/assets/extension-settings-page-DYJmgMUg.js +0 -1
  274. package/dist/gateway/static/root/assets/gateway-realtime-store-Dafw95ol.js +0 -1
  275. package/dist/gateway/static/root/assets/gateway-settings-C13P4lQd.js +0 -1
  276. package/dist/gateway/static/root/assets/highlight-code-CslBKXdS.js +0 -1
  277. package/dist/gateway/static/root/assets/home-page-B_XrkGmA.js +0 -2
  278. package/dist/gateway/static/root/assets/imports-page--cuF5vwU.js +0 -1
  279. package/dist/gateway/static/root/assets/index-6YjAt50A.js +0 -710
  280. package/dist/gateway/static/root/assets/index-caRW34rg.css +0 -1
  281. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-5g2PxgBs.js +0 -1
  282. package/dist/gateway/static/root/assets/local-app-workbench-page-B6U1HQpp.js +0 -1
  283. package/dist/gateway/static/root/assets/logs-page-B9mq03SK.js +0 -2
  284. package/dist/gateway/static/root/assets/management-settings-2W_qJsha.js +0 -1
  285. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-61Il2HQR.js +0 -1
  286. package/dist/gateway/static/root/assets/note-detail-panel-C4gZsNBL.js +0 -5
  287. package/dist/gateway/static/root/assets/note-image-lightbox-XqJIaaRV.js +0 -1
  288. package/dist/gateway/static/root/assets/notes-page-Chdwrjni.js +0 -8
  289. package/dist/gateway/static/root/assets/personal-page-mQl9BftY.js +0 -1
  290. package/dist/gateway/static/root/assets/personal-settings-panel-BgcJLmZN.js +0 -1
  291. package/dist/gateway/static/root/assets/plugin-details-dialog-FvwSxZPB.js +0 -1
  292. package/dist/gateway/static/root/assets/project-detail-page-CGOyx7zX.js +0 -7
  293. package/dist/gateway/static/root/assets/projects-page-Dd11tbRX.js +0 -1
  294. package/dist/gateway/static/root/assets/remote-access-hub-Bintk9nL.js +0 -1
  295. package/dist/gateway/static/root/assets/runtime-tools-api-CY3R7unQ.js +0 -5
  296. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-CbmiiLsq.js +0 -1
  297. package/dist/gateway/static/root/assets/sessions-page-BBlEP7y3.js +0 -1
  298. package/dist/gateway/static/root/assets/settings-advanced-gate-BCQUth4g.js +0 -1
  299. package/dist/gateway/static/root/assets/setup-status-panel-v4P0IAkG.js +0 -1
  300. package/dist/gateway/static/root/assets/shares-settings-DMzej6z2.js +0 -1
  301. package/dist/gateway/static/root/assets/skill-reload-api-B20x7EE9.js +0 -1
  302. package/dist/gateway/static/root/assets/skills-page-C_ulsnv7.js +0 -2
  303. package/dist/gateway/static/root/assets/system-settings-panel-PTRGMKkq.js +0 -1
  304. package/dist/gateway/static/root/assets/task-detail-page-DEPwo4vf.js +0 -2
  305. package/dist/gateway/static/root/assets/tracing-settings-page-CVJt7IXC.js +0 -1
  306. package/dist/gateway/static/root/assets/usage-page-DgqLD8Y5.js +0 -1
  307. package/dist/gateway/static/root/assets/user-model-page-BwK37aob.js +0 -2
@@ -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-BvcCCgTW.js";import{n as c,r as l}from"./popover-select-DGKUpVsz.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./external-link-DjqjBmc3.js";import{t as f}from"./cn-0WouolD0.js";import{i as p,l as m,n as h,o as g}from"./locale-store-JogcXC4J.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-aIC072nz.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{$s as b,$u as x,Ac as S,Bc as ee,Dd as C,Ed as w,Fc as te,Ga as ne,Hs as T,Ic as re,Lc as E,Ma as D,Mc as O,Oc as k,Qd as A,Rc as ie,Rd as j,Rs as ae,Vc as M,Vs as oe,Wl as se,Ws as ce,Ys as le,Zl as ue,aa as de,ac as fe,c as pe,ca as me,dd as he,ed as ge,fu as _e,hi as ve,io as ye,jc as be,la as xe,mi as Se,n as Ce,na as we,oa as Te,qc as Ee,ra as De,rc as Oe,sa as ke,sc as Ae,tc as je,ua as Me,ya as Ne}from"./index-D1oivYvN.js";import{n as Pe}from"./date-formatters-DukWSVwc.js";import{t as Fe}from"./date-picker-N5jnlvPs.js";import{i as Ie,n as Le,r as N,t as Re}from"./task-result-evidence-C4o_Yue_.js";import{t as ze}from"./page-context-capture-button-D_VOB2_C.js";import{t as Be}from"./dependency-picker-C4jddxFl.js";var P=n(),F=r();function Ve(e){let t=(0,P.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,F.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,F.jsxs)(`li`,{className:`text-sm text-fg`,children:[(0,F.jsxs)(`div`,{children:[o[e.fromPhase],e.fromResolution?` · ${u[e.fromResolution]}`:``,` → `,o[e.toPhase],e.toResolution?` · ${u[e.toResolution]}`:``]}),(0,F.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,F.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),children:Pe(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,F.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,F.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,F.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}var I=e(t(),1);function He(e){let t=(0,P.c)(17),{children:n,contentKey:r,language:i,className:o}=e,s=(0,I.useId)(),c=I.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,F.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,F.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,F.jsxs)(`div`,{className:o,children:[m,h]}),t[13]=o,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function Ue({taskId:e}){let t=m(e=>e.conversationId),n=h(e=>e.language),[r,i]=(0,I.useState)(``),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)([]),[v,b]=(0,I.useState)(null),x=p(`/api/tasks/${encodeURIComponent(e)}/collaboration`),{data:S,error:ee,mutate:C}=_([`task-collaboration`,e,t],()=>g(`${x}?recent=1`),{revalidateOnFocus:!0}),w=[...new Map([...d,...S?.items??[]].map(e=>[e.id,e])).values()].sort((e,t)=>e.sequence-t.sequence),te=async()=>{let e=w[0];if(!(!e||l)){u(!0);try{let t=await g(`${x}?recent=1&beforeSequence=${e.sequence}`);f(e=>[...t.items,...e])}catch(e){b(e instanceof Error?e.message:String(e))}finally{u(!1)}}};(0,I.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.taskId||n.taskId===e)&&C()};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)}},[C,e]);let ne=async()=>{if(!(!r.trim()||s)){c(!0),b(null);try{await g(x,{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({kind:a?`answer`:`instruction`,body:r.trim(),...a?{causationId:a}:{}})}),i(``),o(null),await C()}catch(e){b(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,F.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n===`zh`?`任务留言`:`Task updates`}),(0,F.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto`,children:[!S&&!ee?(0,F.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,F.jsx)(y,{className:`h-14 w-full`}),(0,F.jsx)(y,{className:`h-14 w-4/5`})]}):null,ee?(0,F.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n===`zh`?`暂时无法读取留言`:`Updates unavailable`}):null,w[0]&&w[0].sequence>1?(0,F.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void te(),className:`text-xs text-accent hover:underline disabled:opacity-50`,children:n===`zh`?`查看更早留言`:`Earlier updates`}):null,w.map(t=>(0,F.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-sm`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,F.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,F.jsxs)(`span`,{children:[`· `,t.kind]}),t.deliveryStatus?(0,F.jsxs)(`span`,{children:[`· `,t.deliveryStatus]}):null]}),(0,F.jsx)(`div`,{className:`mt-1 min-w-0 text-fg`,"data-task-collaboration-body":!0,children:(0,F.jsx)(N,{content:t.body,contentKey:`${e}:update:${t.id}`,language:n,breaks:!0,previewHeight:120})}),t.kind===`question`&&t.authorKind===`worker_agent`?(0,F.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-accent hover:underline`,onClick:()=>o(t.id),children:n===`zh`?`回复问题`:`Reply`}):null]},t.id)),S&&!w.length?(0,F.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n===`zh`?`暂无进展留言`:`No updates yet`}):null]}),a?(0,F.jsxs)(`p`,{className:`mt-3 text-xs text-accent`,children:[n===`zh`?`正在回复执行 Agent 的问题`:`Replying to the worker`,(0,F.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:()=>o(null),children:n===`zh`?`取消`:`Cancel`})]}):null,(0,F.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`}),v?(0,F.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-danger`,children:v}):null,(0,F.jsx)(`button`,{type:`button`,disabled:!r.trim()||s,onClick:()=>void ne(),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 We(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Ge(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 L(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`})[e]}function Ke(){let e=(0,P.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,F.jsx)(y,{className:`h-32 rounded-2xl`}),(0,F.jsx)(y,{className:`h-52 rounded-2xl`}),(0,F.jsx)(y,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function qe(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Je(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var R=[`backlog`,`ready`,`active`,`review`,`closed`],Ye=[`low`,`normal`,`high`,`critical`],Xe=(0,I.memo)(function(e){let t=(0,P.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:u,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&!i&&!(e===`closed`?a:n===`closed`&&o),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===u?m=t[6]:(m=(0,F.jsx)(`span`,{children:u}),t[5]=u,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==s||t[10]!==p?(g=R.map(e=>(0,F.jsx)(l,{value:e,disabled:p(e),children:L(e,s)},e)),t[9]=s,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,F.jsx)(c,{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:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let v;return t[17]!==m||t[18]!==_?(v=(0,F.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=v):v=t[19],v}),Ze=(0,I.memo)(function(e){let t=(0,P.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,F.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.value),t[2]=o,t[3]=u);let d;t[4]===a?d=t[5]:(d=Ye.map(e=>(0,F.jsx)(l,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==u||t[8]!==d||t[9]!==n?(f=(0,F.jsx)(c,{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:u,children:d}),t[6]=r,t[7]=u,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==s||t[12]!==f?(p=(0,F.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,f]}),t[11]=s,t[12]=f,t[13]=p):p=t[13],p}),Qe=(0,I.memo)(function(e){let t=(0,P.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,F.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,F.jsx)(Fe,{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,F.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}),$e=(0,I.memo)(function(e){let t=(0,P.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,u;t[0]===i?u=t[1]:(u=(0,F.jsx)(`span`,{children:i}),t[0]=i,t[1]=u);let d;t[2]===s?d=t[3]:(d=e=>s(e.target.value),t[2]=s,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,F.jsx)(l,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(ht),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,F.jsxs)(c,{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:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,F.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h}),et=(0,I.memo)(function(e){let t=(0,P.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(gt),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,F.jsx)(Be,{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)),tt=`xopc.taskDetail.chatPanelPercent`,nt=42;function rt(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?nt:Math.min(r,Math.max(n,e))}function it(){try{let e=Number(window.localStorage.getItem(tt));return Number.isFinite(e)&&e>=30&&e<=60?e:nt}catch{return nt}}function at(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.waits.some(e=>e.kind===`paused`)?`paused`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`ready`:e.operationalState}function ot(e){return e===`failed`?`bg-danger/10 text-danger`:e===`needsUser`||e===`blocked`?`bg-warning/10 text-warning`:e===`completed`?`bg-success-soft text-success`:e===`running`||e===`verifying`||e===`review`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function z(e){let t=(0,P.c)(13),{items:n,empty:r,contentKey:i}=e,a=h(ct);if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,F.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(st),t[4]=n,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,F.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,F.jsx)(N,{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 st(e){return(0,F.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,F.jsx)(w,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,F.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]},e)}function ct(e){return e.language}function B({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[i]=a(),c=s(),l=h(e=>e.language),p=m(e=>e.conversationId),g=(0,I.useMemo)(()=>Ae(l),[l]),y=ye(e=>e.setPageHeader),ee=ye(e=>e.clearPageHeader),te=De(e=>e.panes),re=ve(e=>e.openForSession),{data:E,error:ie,mutate:M,lastChange:Se,conversationLoading:Ee,conversationError:Fe}=ae(e),{data:Be}=_(e?`task-detail-automations`:null,()=>pe.list()),[P,L]=(0,I.useState)(null),[R,Ye]=(0,I.useState)(()=>new Set),[st,ct]=(0,I.useState)([]),[B,lt]=(0,I.useState)(null),[ut,dt]=(0,I.useState)([]),[ft,pt]=(0,I.useState)(!1),[mt,ht]=(0,I.useState)(``),[gt,V]=(0,I.useState)(!1),[_t,vt]=(0,I.useState)(``),[H,yt]=(0,I.useState)(it),[bt,xt]=(0,I.useState)(!1),St=(0,I.useRef)(null),Ct=(0,I.useRef)(!1),wt=(0,I.useRef)(!1),Tt=(0,I.useRef)(``),Et=(0,I.useRef)(null),Dt=(0,I.useRef)(null),Ot=(0,I.useRef)(null),U=(0,I.useRef)(E),[kt,W]=(0,I.useState)(null),[At,jt]=(0,I.useState)(null),[Mt,Nt]=(0,I.useState)(!1),Pt=(0,I.useMemo)(()=>({link:g.linkDependencies,linked:g.linkedDependencies,searchPlaceholder:g.dependencySearchPlaceholder,noMatches:g.noDependencyMatches,noCandidates:g.noDependencyCandidates,remove:g.removeDependency}),[g.dependencySearchPlaceholder,g.linkDependencies,g.linkedDependencies,g.noDependencyCandidates,g.noDependencyMatches,g.removeDependency]),Ft=E?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,It=(0,I.useMemo)(()=>be(i.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[i]),Lt=(0,I.useCallback)(e=>t===`modal`&&n?S(n,e):O(`/tasks/${encodeURIComponent(e)}`,It),[n,t,It]);U.current=E;let G=(0,I.useCallback)((e,t)=>{Ye(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,I.useEffect)(()=>{L(null),W(null),pt(!1),Et.current=null,V(!1),jt(null),Nt(!1)},[e]),(0,I.useEffect)(()=>{let e=!0;return Ne().then(t=>{e&&dt(t.items)}).catch(()=>void 0),()=>{e=!1}},[p]),(0,I.useEffect)(()=>{if(!Se||Se.source===`user`)return;jt(Se);let e=window.setTimeout(()=>jt(null),3500);return()=>window.clearTimeout(e)},[Se]),(0,I.useEffect)(()=>{let t=E?.task.projectId,n=E?.dependencies??[];if(!t){Ot.current=null,lt(null),ct(n);return}Ot.current!==t&&(Ot.current=t,lt(null));let r=!0;return D(t).then(t=>{if(!r)return;lt(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});ct([...i.values()])}).catch(()=>{r&&ct(n)}),()=>{r=!1}},[Ft,E?.task.projectId,e]);let K=(0,I.useCallback)(async(t,n=`command`)=>{let r=U.current;if(r){G(n,!0),L(null);try{await M(await T(e,t,r.task.version),{revalidate:!1})}catch{L(g.actionFailed)}finally{G(n,!1)}}},[g.actionFailed,M,G,e]),q=(0,I.useCallback)(async(t,n)=>{let r=U.current;if(!r)return!1;n&&G(n,!0),L(null);try{return await M(Oe(e,t,r.task.version),{optimisticData:Ge(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return L(g.actionFailed),!1}finally{n&&G(n,!1)}},[g.actionFailed,M,G,e]),Rt=()=>{E&&(Et.current={value:E.task.title,version:E.task.version},W(null),ht(E.task.title),pt(!0))},zt=()=>{Ct.current=!0,ht(U.current?.task.title??``),Et.current=null,W(null),pt(!1),queueMicrotask(()=>{Ct.current=!1})},Bt=async(e=!1)=>{if(Ct.current){Ct.current=!1;return}let t=U.current;if(!t||R.has(`title`))return;let n=mt.trim();if(!n){zt();return}let r=Et.current;if(!e&&We(r,t.task.version,t.task.title,n)){W(`title`);return}if(n===t.task.title){zt();return}await q({title:n},`title`)&&(Et.current=null,W(null),pt(!1))},Vt=async()=>{if(!E)return;if(wt.current){wt.current=!1;return}let e=_t.trim(),t=Dt.current;if(We(t,E.task.version,E.task.body??``,e)){W(`description`);return}if(_t===Tt.current||e===(E.task.body??``).trim()){V(!1);return}await q({body:e||null})&&(W(null),V(!1))},Ht=(0,I.useCallback)(async e=>{let t=U.current;!t||e===t.task.phase||await K({type:`move`,phase:e},`phase`)},[K]),Ut=(0,I.useCallback)(e=>{q({priority:e},`priority`)},[q]),Wt=(0,I.useCallback)(e=>{q({dueAt:Je(e)},`dueAt`)},[q]),Gt=(0,I.useCallback)(e=>{yt(e);try{window.localStorage.setItem(tt,String(e))}catch{}},[]),Kt=(0,I.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=St.current?.clientWidth??0;Gt(rt(e.key===`Home`?nt:H+(e.key===`ArrowLeft`?2:-2),t))},[H,Gt]),qt=(0,I.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=St.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),xt(!0);let i=H,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=rt((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{}xt(!1),Gt(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,Gt]),Jt=(0,I.useCallback)(async t=>{let n=U.current;if(n){G(`dependencies`,!0),L(null);try{await M(await fe(e,t,n.task.version),{revalidate:!1})}catch{L(g.dependencyUpdateFailed)}finally{G(`dependencies`,!1)}}},[g.dependencyUpdateFailed,M,G,e]),Yt=(0,I.useCallback)(async t=>{let n=U.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){G(`delegateAgentId`,!0),L(null);try{await M(await le(e,t,n.task.version),{revalidate:!1})}catch{L(g.actionFailed)}finally{G(`delegateAgentId`,!1)}}},[g.actionFailed,M,G,e]),Xt=(0,I.useCallback)(async()=>{G(`delete`,!0),L(null);try{await ce(e),r?r():c(It,{replace:!0})}catch(e){L(e instanceof Error?e.message:g.actionFailed)}finally{G(`delete`,!1)}},[g.actionFailed,c,r,It,G,e]),Zt=(0,I.useCallback)(async(t,n)=>{let r=U.current;if(r){G(`acceptance`,!0),L(null);try{await M(await b(e,t,n,r.task.version,r.task.latestContractVersion),{revalidate:!1})}catch{L(g.actionFailed),await M()}finally{G(`acceptance`,!1)}}},[g.actionFailed,M,G,e]);if((0,I.useLayoutEffect)(()=>{if(t!==`modal`)return y({startExtra:(0,F.jsx)(o,{to:It,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":g.backToWork,children:(0,F.jsx)(A,{className:`size-4`})}),main:E?(0,F.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${g.taskLabel}`:g.taskLabel}):null,end:null}),ee},[ee,g.backToWork,g.taskLabel,E,t,B,It,y]),ie&&!E)return(0,F.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:g.taskNotFound});if(!E)return(0,F.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,F.jsx)(Ke,{})});let Qt=E.waits[0],J=Ie(E),$t=J.length>0&&J.every(e=>e.status===`passed`),en=E.waits.find(e=>e.kind===`paused`),Y=E.receipts[0],tn=at(E),nn=g.detailStatuses[tn],rn=E.task.body?.trim()||E.task.contract?.objective.trim(),an=E.allowedCommands.includes(`mark_ready`),on=E.allowedCommands.includes(`start`),sn=E.allowedCommands.includes(`add_wait`),cn=!Qt&&$t&&E.task.phase===`review`&&E.allowedCommands.includes(`close`),ln=E.allowedCommands.includes(`reopen`),X=E.conversation.activeConversationId,un=E.conversation.currentExecutorAgentId??E.task.delegateAgentId??E.task.ownerId,dn=ut.find(e=>e.id===un),fn=!!(X&&te[X]?.open),pn=E.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),mn=J.filter(e=>e.status===`passed`).length,hn=E.context.filter(e=>e.role===`deliverable`),gn=new Set(E.runs.filter(e=>e.contractVersion===E.task.latestContractVersion).map(e=>e.id)),_n=[...new Map(E.receipts.filter(e=>gn.has(e.runId)).flatMap(e=>e.evidence.filter(e=>e.kind===`artifact`)).map(e=>[e.uri??e.title,e])).values()],vn=E.context.filter(e=>e.role!==`deliverable`),yn=Be?.automations.filter(t=>t.action.kind===`task_command`&&t.action.taskId===e)??[],Z=E.sessions.filter((e,t,n)=>n.findIndex(t=>t.conversationId===e.conversationId)===t),bn=E.task.contract?.expectedOutputs??[],xn=E.task.contract?.constraints??[],Sn=E.task.contract?.approvalRequired??[],Cn=E.task.contract?.assumptions??[],wn=E.task.contract?.risks??[],Tn=xn.length>0||Sn.length>0||Cn.length>0||wn.length>0,Q=(...e)=>!!At?.changedFields.some(t=>e.includes(t)),En=E.allowedCommands.includes(`move`),$=R.has(`command`),Dn=R.has(`delete`),On=E.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),kn=On!==void 0,An=`/automations?action=create&taskId=${encodeURIComponent(E.task.id)}${E.task.projectId?`&projectId=${encodeURIComponent(E.task.projectId)}`:``}`,jn=(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[an?(0,F.jsxs)(v,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`mark_ready`}),children:[(0,F.jsx)(se,{className:`size-4`}),g.scheduleTask]}):null,en&&E.allowedCommands.includes(`resolve_wait`)?(0,F.jsxs)(v,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`resolve_wait`,waitId:en.id}),children:[(0,F.jsx)(se,{className:`size-4`}),g.resumeTask]}):null,!Qt&&on&&un?(0,F.jsxs)(v,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`start`,executor:{kind:`agent`,agentId:un}}),children:[(0,F.jsx)(se,{className:`size-4`}),g.runTask]}):null,cn?(0,F.jsxs)(v,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`close`,resolution:`done`}),children:[(0,F.jsx)(u,{className:`size-4`}),g.approveTask]}):null,ln?(0,F.jsxs)(v,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`reopen`,phase:`ready`}),children:[(0,F.jsx)(se,{className:`size-4`}),g.reopenTask]}):null,!en&&sn?(0,F.jsxs)(v,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:$,onClick:()=>void K({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,F.jsx)(ue,{className:`size-4`}),g.pauseTask]}):null,E.task.phase===`closed`?null:(0,F.jsx)(v,{asChild:!0,variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,children:(0,F.jsxs)(o,{to:An,children:[(0,F.jsx)(j,{className:`size-4`}),g.scheduleRecurringTask]})}),(0,F.jsxs)(me,{children:[(0,F.jsx)(Me,{asChild:!0,children:(0,F.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||Dn,"aria-label":g.moreActions,children:(0,F.jsx)(he,{className:`size-4`,"aria-hidden":!0})})}),(0,F.jsx)(ke,{children:(0,F.jsxs)(de,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[On?(0,F.jsx)(Te,{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),L(null),M(oe(e,On.id,On.version),{revalidate:!1}).catch(()=>L(g.actionFailed)).finally(()=>G(`command`,!1))},children:g.cancelActiveRun}):null,On?(0,F.jsx)(xe,{className:`my-1 h-px bg-edge`}):null,E.task.phase===`closed`?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Te,{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:g.cancelTask}),(0,F.jsx)(xe,{className:`my-1 h-px bg-edge`})]}),(0,F.jsx)(Te,{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(kn){L(g.deleteActiveTaskBlocked);return}Nt(!0)},children:g.deleteTask})]})})]})]});return(0,F.jsxs)(`div`,{ref:St,className:`flex h-full min-h-0 flex-col overflow-hidden ${bt?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${H}%`},children:[(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,F.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,F.jsxs)(`header`,{className:f(`shrink-0 border-b border-edge-subtle bg-surface-panel px-5 py-4 sm:px-6`,Q(`title`)&&`task-detail-live-update`),children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-6 gap-y-3`,children:[(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,B?(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`/`}):null,(0,F.jsx)(`span`,{children:g.taskLabel}),At?(0,F.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:At.source===`agent`?l===`zh`?`Agent 刚刚更新`:`Updated by Agent`:l===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),ft?(0,F.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,"aria-label":l===`zh`?`任务标题`:`Task title`,rows:2,value:mt,onFocus:e=>{Et.current?.value===mt&&(e.currentTarget.setSelectionRange(0,0),e.currentTarget.scrollTop=0)},onChange:e=>ht(e.target.value),onBlur:()=>void Bt(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),zt()):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,F.jsx)(N,{content:E.task.title,contentKey:`${e}:title`,language:l,previewHeight:56,className:`mt-2 max-w-3xl`,children:(0,F.jsx)(`h1`,{className:`break-words text-xl font-semibold leading-7 text-fg`,children:(0,F.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:E.task.title,onClick:Rt,children:E.task.title})})}),kt===`title`?(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,F.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,F.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:zt,children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,F.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,disabled:R.has(`title`),onClick:()=>void Bt(!0),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,F.jsx)(`span`,{className:f(`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium`,ot(tn)),children:nn})]}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,F.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[un?(0,F.jsx)(ne,{agentId:un,avatar:dn?.avatar,size:20,className:`shrink-0`}):null,(0,F.jsxs)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:[g.executorLabel,` · `,dn?.name??un??g.unassigned]})]}),(0,F.jsx)(`span`,{className:`text-fg-subtle`,children:g.updatedAt.replace(`{{date}}`,Pe(E.task.updatedAt,l))})]}),(0,F.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:jn}),P?(0,F.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:P}):null]}),(0,F.jsxs)(`section`,{className:`min-w-0 p-5 sm:p-6`,children:[(0,F.jsxs)(`section`,{className:`mb-4 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[(0,F.jsxs)(`div`,{className:`border-b border-edge-subtle p-5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l===`zh`?`目标与验收`:`Goal and acceptance`}),J.length>0?(0,F.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:g.criteriaProgress.replace(`{{verified}}`,String(mn)).replace(`{{total}}`,String(J.length))}):null]}),(0,F.jsx)(N,{content:E.task.contract?.objective||E.task.title,contentKey:`${e}:goal`,language:l,markdown:!1,previewHeight:72,className:`mt-3 text-sm leading-6 text-fg`})]}),(0,F.jsxs)(`div`,{className:`p-5`,children:[(0,F.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:g.successDefinition}),J.length>0?(0,F.jsx)(`ul`,{className:`mt-3 space-y-3`,children:J.map((t,n)=>(0,F.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm leading-5 text-fg`,children:[(0,F.jsx)(t.status===`passed`?u:t.status===`failed`?C:w,{className:f(`mt-0.5 size-4 shrink-0`,t.status===`passed`?`text-success`:t.status===`failed`?`text-danger`:`text-fg-subtle`),"aria-hidden":!0}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(N,{content:t.text,contentKey:`${e}:criterion:${n}`,language:l,markdown:!1,previewHeight:60}),t.evidence.length>0?(0,F.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-xs leading-5 text-fg-muted`,children:[(0,F.jsx)(`span`,{children:l===`zh`?`依据:`:`Evidence:`}),t.evidence.map(e=>e.uri&&/^https?:\/\//.test(e.uri)?(0,F.jsx)(`a`,{className:`text-accent hover:underline`,href:e.uri,target:`_blank`,rel:`noreferrer`,children:e.title},e.title):(0,F.jsx)(`span`,{children:e.title},e.title))]}):null,t.review?(0,F.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[l===`zh`?`人工判定`:`Reviewed by user`,` · `,Pe(t.review.reviewedAt,l)]}):null,t.method===`model_reviewed`?(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l===`zh`?`模型审阅:${t.verificationStatus===`passed`?`通过`:t.verificationStatus===`failed`?`未通过`:`未核验`}`:`Model review: ${t.verificationStatus===`passed`?`passed`:t.verificationStatus===`failed`?`failed`:`unverified`}`}):null,t.note?(0,F.jsx)(N,{content:t.note,contentKey:`${e}:criterion-note:${n}`,language:l,markdown:!1,previewHeight:60,className:`mt-1 text-xs text-fg-muted`}):null]}),E.task.phase!==`closed`&&E.task.contract?.acceptancePolicy!==`verified_auto`?(0,F.jsxs)(me,{children:[(0,F.jsx)(Me,{asChild:!0,children:(0,F.jsx)(v,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:R.has(`acceptance`),children:l===`zh`?`判定`:`Review`})}),(0,F.jsx)(ke,{children:(0,F.jsxs)(de,{align:`end`,sideOffset:4,className:`z-[100] min-w-32 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,F.jsx)(Te,{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 Zt(n,`passed`),children:l===`zh`?`确认通过`:`Mark passed`}),(0,F.jsx)(Te,{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 Zt(n,`failed`),children:l===`zh`?`标记未通过`:`Mark failed`})]})})]}):null]},`${n}-${t.text}`))}):(0,F.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g.noDefinition})]})]}),E.attention.length>0?(0,F.jsxs)(`section`,{className:f(`mb-4 rounded-xl border border-warning/20 bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:pn?g.needsAttention:g.waitingStatus}),(0,F.jsx)(`ul`,{className:`mt-2 space-y-1.5 text-sm leading-6 text-fg-muted`,children:E.attention.map((t,n)=>(0,F.jsxs)(`li`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,F.jsx)(N,{content:t.summary,contentKey:`${e}:attention:${t.kind}:${n}`,language:l,markdown:!1,previewHeight:72,className:`min-w-0 flex-1`}),t.kind===`input_required`||t.kind===`approval_required`?(0,F.jsx)(o,{className:`inline-flex min-h-11 items-center rounded-lg bg-surface-panel px-3 text-sm font-medium text-accent`,to:k(e),children:l===`zh`?t.kind===`approval_required`?`查看并决定`:`补充信息`:t.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${t.kind}-${n}`))})]}):null,E.allowedCommands.includes(`resolve_wait`)&&!en&&E.waits.filter(e=>(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`).map(e=>(0,F.jsx)(Le,{wait:e,detail:E,zh:l===`zh`,onUpdated:e=>{M(e,{revalidate:!1})}},e.id)),(0,F.jsx)(`div`,{className:`mb-4`,children:(0,F.jsx)(Ve,{changes:E.phaseChanges,language:l})}),(0,F.jsx)(`div`,{className:`mb-4`,children:(0,F.jsx)(Ue,{taskId:e},e)}),hn.length>0||_n.length>0||bn.length>0?(0,F.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l===`zh`?`交付物`:`Deliverables`}),hn.length>0||_n.length>0?(0,F.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[hn.map(t=>(0,F.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,F.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:g.contextKindLabels[t.targetKind]}),t.targetKind===`url`&&/^https?:\/\//.test(t.targetId)?(0,F.jsx)(N,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:l,previewHeight:60,className:`mt-1`,children:(0,F.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.targetId,target:`_blank`,rel:`noreferrer`,children:t.title??t.targetId})}):(0,F.jsx)(N,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:l,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.id)),_n.map(t=>(0,F.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,F.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:l===`zh`?`执行产物`:`Run artifact`}),t.uri&&/^https?:\/\//.test(t.uri)?(0,F.jsx)(N,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:l,previewHeight:60,className:`mt-1`,children:(0,F.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.uri,target:`_blank`,rel:`noreferrer`,children:t.title})}):(0,F.jsx)(N,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:l,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.uri??t.title))]}):(0,F.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:l===`zh`?`尚未关联交付物`:`No deliverables linked yet`}),bn.length>0?(0,F.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,F.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:g.expectedOutputs}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(z,{contentKey:`${e}:expectedOutputs`,items:bn,empty:g.noDefinition})})]}):null]}):null,(0,F.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l===`zh`?`关联内容`:`Related work`}),Z.length>0||E.runs.length>0||yn.length>0||E.dependencies.length>0||E.dependents.length>0?(0,F.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Z.length>0?(0,F.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,F.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:l===`zh`?`对话 · ${Z.length}`:`Conversations · ${Z.length}`}),(0,F.jsx)(He,{contentKey:`${e}:sessions`,language:l,className:`mt-2`,children:Z.map(t=>(0,F.jsx)(`li`,{children:(0,F.jsx)(o,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:t.conversationId===X?k(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===X?l===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?l===`zh`?`关联讨论`:`Linked discussion`:l===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})]}):null,yn.length>0?(0,F.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,F.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:l===`zh`?`自动化 · ${yn.length}`:`Automations · ${yn.length}`}),(0,F.jsx)(He,{contentKey:`${e}:automations`,language:l,className:`mt-2`,children:yn.map(e=>(0,F.jsx)(`li`,{children:(0,F.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,E.dependencies.length>0||E.dependents.length>0?(0,F.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,F.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:g.taskRelations}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-fg`,children:l===`zh`?`${E.dependencies.length} 个前置任务 · ${E.dependents.length} 个后续任务`:`${E.dependencies.length} prerequisites · ${E.dependents.length} dependents`})]}):null]}):(0,F.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:l===`zh`?`还没有关联内容`:`No related work yet`}),(0,F.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:(0,F.jsx)(ze,{resource:{kind:`task`,id:E.task.id,revision:String(E.task.version)},disabled:ft||gt||R.size>0})})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,F.jsxs)(`main`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,F.jsxs)(`section`,{className:f(`p-5`,Q(`body`)&&`task-detail-live-update`),children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:g.taskDescription}),gt?(0,F.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:_t,onChange:e=>vt(e.target.value),onBlur:()=>void Vt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),wt.current=!0,vt(E.task.body??E.task.contract?.objective??``),V(!1),queueMicrotask(()=>{wt.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,F.jsxs)(`div`,{className:`mt-2`,children:[rn&&rn!==E.task.title?(0,F.jsx)(N,{content:rn,contentKey:`${e}:description`,language:l}):(0,F.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:g.noTaskDescription}),(0,F.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=E.task.body??E.task.contract?.objective??``;Tt.current=e,Dt.current={value:E.task.body??``,version:E.task.version},W(null),vt(e),V(!0)},children:l===`zh`?`编辑说明`:`Edit description`})]}),kt===`description`?(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,F.jsx)(`span`,{children:l===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,F.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{vt(E.task.body??``),W(null),V(!1)},children:l===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,F.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void q({body:_t.trim()||null}).then(e=>{e&&(W(null),V(!1))}),children:l===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),Tn?(0,F.jsxs)(`section`,{className:f(`p-5`,Q(`contract`)&&`task-detail-live-update`),children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:g.taskDefinition}),(0,F.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`执行边界及补充背景`:`Execution boundaries and supporting context`}),xn.length>0?(0,F.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:g.constraints}),(0,F.jsx)(`div`,{className:`mt-3`,children:(0,F.jsx)(z,{contentKey:`${e}:constraints`,items:xn,empty:g.noDefinition})})]}):null,Sn.length>0?(0,F.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:g.approvalRequired}),(0,F.jsx)(`div`,{className:`mt-3`,children:(0,F.jsx)(z,{contentKey:`${e}:approvalRequired`,items:Sn,empty:g.noDefinition})})]}):null,Cn.length>0?(0,F.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:g.contextAssumptions}),(0,F.jsx)(`div`,{className:`mt-3`,children:(0,F.jsx)(z,{contentKey:`${e}:assumptions`,items:Cn,empty:g.noDefinition})})]}):null,wn.length>0?(0,F.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:g.contextRisks}),(0,F.jsx)(`div`,{className:`mt-3`,children:(0,F.jsx)(z,{contentKey:`${e}:risks`,items:wn,empty:g.noDefinition})})]}):null]}):null,Y?(0,F.jsxs)(`section`,{className:f(`p-5`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:g.latestResult}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l===`zh`?Y.completionVerdict===`achieved`?`本次执行报告目标已达成,请结合下方验证依据验收。`:`这是阶段性结果,尚不能代表任务全部完成。`:Y.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,F.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[g.receiptStatuses[Y.status],` · `,g.verificationStatuses[Y.verification.status]]})]}),(0,F.jsx)(N,{content:Y.summary,contentKey:`${e}:result:${Y.runId}`,language:l,className:`mt-3`}),Y.remainingWork.length>0?(0,F.jsxs)(`div`,{className:`mt-4`,children:[(0,F.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:g.remainingWork}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(z,{contentKey:`${e}:remaining:${Y.runId}`,items:Y.remainingWork,empty:g.noRemainingWork})})]}):null,Y.nextAction?(0,F.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:g.nextAction}),(0,F.jsx)(N,{content:Y.nextAction,contentKey:`${e}:next:${Y.runId}`,language:l,markdown:!1,previewHeight:72,className:`mt-1 text-sm text-fg`})]}):null,(0,F.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(v,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void je(Y.runId,`helpful`),children:g.doneWell}),(0,F.jsx)(v,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void je(Y.runId,`not_helpful`),children:g.needsFix})]}),(0,F.jsx)(Re,{evidence:Y.evidence,projectId:E.task.projectId,conversationId:X??void 0,language:l}),E.receipts.length>1?(0,F.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:g.executionHistory.replace(`{{count}}`,String(E.receipts.length-1))}),(0,F.jsx)(`div`,{className:`mt-3 space-y-3`,children:E.receipts.slice(1).map(t=>(0,F.jsx)(`article`,{className:`rounded-lg bg-surface-hover p-3`,children:(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsx)(N,{content:t.summary,contentKey:`${e}:result:${t.runId}`,language:l,className:`min-w-0 flex-1`}),(0,F.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:g.receiptStatuses[t.status]})]})},t.runId))})]}):null]}):null,vn.length>0?(0,F.jsxs)(`section`,{className:f(`p-5`,Q(`context`)&&`task-detail-live-update`),children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:g.contextUsed}),(0,F.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:vn.map(e=>(0,F.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,F.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[g.contextRoleLabels[e.role],` · `,g.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,F.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,F.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,F.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,F.jsxs)(`section`,{className:f(`p-5`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:g.taskProperties}),(0,F.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,F.jsx)(Xe,{value:E.task.phase,disabled:R.has(`phase`),canMove:En,canApprove:cn,canReopen:ln,language:l,label:g.taskPhase,onChange:Ht}),(0,F.jsx)(Ze,{value:E.task.priority,disabled:R.has(`priority`),label:g.priority,labels:g.priorityLabels,onChange:Ut}),(0,F.jsx)(Qe,{value:qe(E.task.dueAt),disabled:R.has(`dueAt`),label:g.dueDate,onChange:Wt}),(0,F.jsx)($e,{value:E.conversation.currentExecutorAgentId??``,disabled:R.has(`delegateAgentId`),label:g.executorLabel,unassignedLabel:g.unassigned,agents:ut,onChange:Yt})]})]}),(0,F.jsxs)(`section`,{className:f(`p-5`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:g.taskRelations}),(0,F.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:g.dependencies}),(0,F.jsx)(et,{candidates:st,selected:E.dependencies,disabled:R.has(`dependencies`),labels:Pt,getTaskHref:Lt,onChange:Jt})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:g.dependents}),E.dependents.length>0?(0,F.jsx)(`div`,{className:`space-y-1.5`,children:E.dependents.map(t=>(0,F.jsx)(N,{content:t.title,contentKey:`${e}:dependent:${t.id}`,language:l,previewHeight:72,className:`rounded-lg bg-surface-hover p-2.5`,children:(0,F.jsx)(o,{to:Lt(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,F.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:g.noDependents})]})]})]})]})]})]})]}),(0,F.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":l===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(H),tabIndex:0,onPointerDown:qt,onKeyDown:Kt,onDoubleClick:()=>Gt(nt),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 ${bt?`bg-surface-hover`:``}`,children:(0,F.jsx)(`div`,{className:`w-px bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,F.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,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-medium text-fg-muted`,children:l===`zh`?`执行对话`:`Execution chat`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Z.length>1?(0,F.jsxs)(me,{children:[(0,F.jsx)(Me,{asChild:!0,children:(0,F.jsx)(v,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:l===`zh`?`${Z.length} 段对话`:`${Z.length} conversations`})}),(0,F.jsx)(ke,{children:(0,F.jsx)(de,{align:`end`,sideOffset:6,className:`z-[100] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:Z.map(t=>(0,F.jsx)(Te,{asChild:!0,children:(0,F.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===X?k(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===X?l===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?l===`zh`?`关联讨论`:`Linked discussion`:l===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})})]}):null,X?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(v,{type:`button`,variant:`ghost`,className:f(`size-8 p-0`,fn&&`bg-surface-hover text-fg`),"aria-label":l===`zh`?`项目文件`:`Project files`,"aria-pressed":fn,onClick:()=>{De.getState().openFiles(X),re(X)},children:(0,F.jsx)(x,{className:`size-4`,"aria-hidden":!0})}),(0,F.jsx)(v,{asChild:!0,variant:`ghost`,className:`size-8 p-0`,children:(0,F.jsx)(o,{to:k(e),"aria-label":l===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,F.jsx)(d,{className:`size-4`,"aria-hidden":!0})})})]}):null]})]}),X?(0,F.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,F.jsx)(Ce,{embedded:!0,conversationId:X,taskId:e})}):Ee?(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,F.jsxs)(`div`,{className:`max-w-xs`,children:[(0,F.jsx)(_e,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,F.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):Fe?(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,F.jsxs)(`div`,{className:`max-w-xs`,children:[(0,F.jsx)(_e,{className:`mx-auto size-8 text-danger`}),(0,F.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,F.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:Fe instanceof Error?Fe.message:String(Fe)})]})}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,F.jsxs)(`div`,{className:`max-w-xs`,children:[(0,F.jsx)(_e,{className:`mx-auto size-8 text-fg-subtle`}),(0,F.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:l===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,F.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:l===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]}),(0,F.jsx)(we,{open:Mt,title:g.deleteTaskTitle,description:g.deleteTaskDescription.replace(`{{title}}`,E.task.title),confirmLabel:g.confirmDeleteTask,cancelLabel:g.keepTask,destructive:!0,onConfirm:()=>{Nt(!1),Xt()},onCancel:()=>Nt(!1)})]})}function lt(){let e=(0,P.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,F.jsx)(B,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function ut(e){let t=(0,P.c)(41),{taskId:n,backgroundPath:r,workspacePanelWidth:i,onClose:a}=e,o=i===void 0?0:i,s=h(mt),c=Se(pt),l=o>0,u;t[0]!==a||t[1]!==c?(u=e=>{e||(c(null),a())},t[0]=a,t[1]=c,t[2]=u):u=t[2];let d=s===`zh`?`关闭任务详情`:`Close task details`,f;t[3]!==a||t[4]!==c?(f=()=>{c(null),a()},t[3]=a,t[4]=c,t[5]=f):f=t[5];let p;t[6]!==d||t[7]!==f?(p=(0,F.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45`,"aria-label":d,onClick:f}),t[6]=d,t[7]=f,t[8]=p):p=t[8];let m=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,F.jsx)(M,{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,F.jsx)(ie,{className:`sr-only`,children:S}),t[14]=S,t[15]=C);let w=s===`zh`?`关闭任务详情`:`Close task details`,ne;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,F.jsx)(Ee,{className:`size-4`,"aria-hidden":!0}),t[16]=ne):ne=t[16];let T;t[17]===w?T=t[18]:(T=(0,F.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,F.jsx)(re,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":w,children:ne})}),t[17]=w,t[18]=T);let D;t[19]!==x||t[20]!==C||t[21]!==T?(D=(0,F.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[x,C,T]}),t[19]=x,t[20]=C,t[21]=T,t[22]=D):D=t[22];let O;t[23]!==a||t[24]!==c?(O=()=>{c(null),a()},t[23]=a,t[24]=c,t[25]=O):O=t[25];let k;t[26]!==r||t[27]!==O||t[28]!==n?(k=(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,F.jsx)(B,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:O})}),t[26]=r,t[27]=O,t[28]=n,t[29]=k):k=t[29];let A;t[30]!==y||t[31]!==D||t[32]!==k||t[33]!==m?(A=(0,F.jsxs)(E,{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":m,style:y,onEscapeKeyDown:ft,onInteractOutside:dt,children:[D,k]}),t[30]=y,t[31]=D,t[32]=k,t[33]=m,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==p?(j=(0,F.jsxs)(ee,{children:[p,A]}),t[35]=A,t[36]=p,t[37]=j):j=t[37];let ae;return t[38]!==u||t[39]!==j?(ae=(0,F.jsx)(te,{modal:!1,open:!0,onOpenChange:u,children:j}),t[38]=u,t[39]=j,t[40]=ae):ae=t[40],ae}function dt(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function ft(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function pt(e){return e.setPath}function mt(e){return e.language}function ht(e){return(0,F.jsx)(l,{value:e.id,children:e.name||e.id},e.id)}function gt(e){return e.id}export{ut as TaskDetailModal,lt 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-BvcCCgTW.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./cn-0WouolD0.js";import{d as c}from"./tasks-TVRjEggr.js";import{t as l}from"./button-aIC072nz.js";import{Pi as u,Vs as d,Wo as f,bi as p,ki as m,rd as h,sc as g}from"./index-6YjAt50A.js";function _(e){let t=e.task.contract?.acceptanceCriteria??[],n=new Map(e.runs.map(e=>[e.id,e])),r=e.receipts.filter(t=>n.get(t.runId)?.contractVersion===e.task.latestContractVersion).sort((e,t)=>t.finalizedAt-e.finalizedAt);return t.map((t,n)=>{let i=e.criterionReviews.find(r=>r.criterionIndex===n&&r.contractVersion===e.task.latestContractVersion&&r.criterionText===t),a={text:t,status:`unverified`,evidence:[]};for(let e of r){let n=e.verification.checks.find(e=>e.criterion===t);if(!n)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&c(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}var v=n(),y=e(t(),1),b=r();function x(e){let t=(0,v.c)(36),{content:n,contentKey:r,language:a,markdown:o,breaks:c,previewHeight:l,className:u,children:d}=e,f=o===void 0?!0:o,p=c===void 0?!1:c,m=l===void 0?240:l,h=(0,y.useId)(),_=(0,y.useRef)(null),[x,S]=(0,y.useState)(!1),[C,w]=i(),T;t[0]!==r||t[1]!==C?(T=C.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=C,t[2]=T):T=t[2];let E=T,D;t[3]===m?D=t[4]:(D=()=>{let e=_.current;if(!e)return;let t=()=>S(e.scrollHeight>m);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[3]=m,t[4]=D);let O;t[5]!==n||t[6]!==m?(O=[n,m],t[5]=n,t[6]=m,t[7]=O):O=t[7],(0,y.useLayoutEffect)(D,O);let k=x&&!E,A;t[8]===u?A=t[9]:(A=s(`min-w-0`,u),t[8]=u,t[9]=A);let j;t[10]!==k||t[11]!==m?(j=k?{maxHeight:m,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,m/3)}px), transparent)`}:void 0,t[10]=k,t[11]=m,t[12]=j):j=t[12];let M;t[13]!==p||t[14]!==d||t[15]!==n||t[16]!==f?(M=d??(f?(0,b.jsx)(g,{content:n,compact:!0,breaks:p,className:`text-sm leading-6 text-fg`}):(0,b.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[13]=p,t[14]=d,t[15]=n,t[16]=f,t[17]=M):M=t[17];let N;t[18]!==k||t[19]!==M?(N=(0,b.jsx)(`div`,{ref:_,inert:k,children:M}),t[18]=k,t[19]=M,t[20]=N):N=t[20];let P;t[21]!==h||t[22]!==N||t[23]!==j?(P=(0,b.jsx)(`div`,{id:h,style:j,children:N}),t[21]=h,t[22]=N,t[23]=j,t[24]=P):P=t[24];let F;t[25]!==r||t[26]!==E||t[27]!==h||t[28]!==a||t[29]!==x||t[30]!==w?(F=x?(0,b.jsx)(`button`,{type:`button`,"aria-expanded":E,"aria-controls":h,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:()=>w(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 E||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:a===`zh`?E?`收起`:`查看更多`:E?`Show less`:`Show more`}):null,t[25]=r,t[26]=E,t[27]=h,t[28]=a,t[29]=x,t[30]=w,t[31]=F):F=t[31];let I;return t[32]!==P||t[33]!==F||t[34]!==A?(I=(0,b.jsxs)(`div`,{className:A,children:[P,F]}),t[32]=P,t[33]=F,t[34]=A,t[35]=I):I=t[35],I}function S({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,u]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),h=(0,y.useRef)(null),g=e.kind===`approval`,_=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function v(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),u(``);try{let o=await d(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);m(!0),r(o),f({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{u(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,b.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),v()},children:[g?(0,b.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,b.jsx)(`p`,{children:e.reason}),(0,b.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,b.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,b.jsx)(l,{type:`button`,variant:`primary`,disabled:o||p,onClick:()=>void v(`approve`),children:n?`批准`:`Approve`}),(0,b.jsx)(l,{type:`button`,disabled:o||p,onClick:()=>void v(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,b.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||p,onChange:e=>a(e.target.value)})]}),_.length>0&&(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,b.jsx)(l,{type:`button`,disabled:o||p,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,b.jsx)(l,{type:`submit`,variant:`primary`,disabled:o||p||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function C(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 w({uri:e,zh:t}){let[n,r]=(0,y.useState)(),[i,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[d,f]=(0,y.useState)(``),[p,h]=(0,y.useState)(``);async function g(){o(!0),f(``);try{let n=C(e,(await u()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?f(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?f(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?f(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(h(n.shareUrl),f(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):f(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{f(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{o(!1)}}async function _(){if(!(!n||i)){o(!0),f(``);try{let e=await m(n.id,864e5);h(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),f(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){f(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{o(!1)}}}return(0,b.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(l,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void g(),children:t?`检查链接状态`:`Check link`}),s&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,b.jsx)(l,{type:`button`,disabled:i,onClick:()=>void _(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),d&&(0,b.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:d}),p&&(0,b.jsx)(`a`,{className:`block py-2 text-accent`,href:p,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),s&&(0,b.jsx)(a,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function T(e){let t=(0,v.c)(16),{evidence:n,projectId:r,conversationId:i,language:a,onOpenFile:s}=e,c=p(E);if(!n.length)return null;let l=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,u;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==c){let e;t[7]!==i||t[8]!==a||t[9]!==s||t[10]!==r||t[11]!==c?(e=(e,t)=>{let n=e.uri?.trim(),l=n&&/^https?:\/\//i.test(n),u=n&&!l&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),d=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,b.jsx)(x,{content:d,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:l?(0,b.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,b.jsx)(o,{className:`size-4 shrink-0`}),(0,b.jsx)(`span`,{className:`min-w-0 break-words`,children:d})]}):u&&(r||i)?(0,b.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:()=>s?s(n):c(n,null,r,i),children:[(0,b.jsx)(h,{className:`size-4 shrink-0`}),d]}):(0,b.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:d})}),l&&e.kind===`artifact`&&(0,b.jsx)(w,{uri:n,zh:a===`zh`},n),e.summary?(0,b.jsx)(x,{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,b.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]=s,t[10]=r,t[11]=c,t[12]=e):e=t[12],u=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=s,t[4]=r,t[5]=c,t[6]=u}else u=t[6];let d;return t[13]!==l||t[14]!==u?(d=(0,b.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":l,children:u}),t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function E(e){return e.setPath}export{_ as i,S as n,x as r,T 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-BvcCCgTW.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./cn-0WouolD0.js";import{d as c}from"./tasks-TVRjEggr.js";import{t as l}from"./button-aIC072nz.js";import{Ci as u,Go as d,Hs as f,Oi as p,ad as m,cc as h,mi as g}from"./index-D1oivYvN.js";function _(e){let t=e.task.contract?.acceptanceCriteria??[],n=new Map(e.runs.map(e=>[e.id,e])),r=e.receipts.filter(t=>n.get(t.runId)?.contractVersion===e.task.latestContractVersion).sort((e,t)=>t.finalizedAt-e.finalizedAt);return t.map((t,n)=>{let i=e.criterionReviews.find(r=>r.criterionIndex===n&&r.contractVersion===e.task.latestContractVersion&&r.criterionText===t),a={text:t,status:`unverified`,evidence:[]};for(let e of r){let n=e.verification.checks.find(e=>e.criterion===t);if(!n)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&c(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}var v=n(),y=e(t(),1),b=r();function x(e){let t=(0,v.c)(36),{content:n,contentKey:r,language:a,markdown:o,breaks:c,previewHeight:l,className:u,children:d}=e,f=o===void 0?!0:o,p=c===void 0?!1:c,m=l===void 0?240:l,g=(0,y.useId)(),_=(0,y.useRef)(null),[x,S]=(0,y.useState)(!1),[C,w]=i(),T;t[0]!==r||t[1]!==C?(T=C.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=C,t[2]=T):T=t[2];let E=T,D;t[3]===m?D=t[4]:(D=()=>{let e=_.current;if(!e)return;let t=()=>S(e.scrollHeight>m);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[3]=m,t[4]=D);let O;t[5]!==n||t[6]!==m?(O=[n,m],t[5]=n,t[6]=m,t[7]=O):O=t[7],(0,y.useLayoutEffect)(D,O);let k=x&&!E,A;t[8]===u?A=t[9]:(A=s(`min-w-0`,u),t[8]=u,t[9]=A);let j;t[10]!==k||t[11]!==m?(j=k?{maxHeight:m,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,m/3)}px), transparent)`}:void 0,t[10]=k,t[11]=m,t[12]=j):j=t[12];let M;t[13]!==p||t[14]!==d||t[15]!==n||t[16]!==f?(M=d??(f?(0,b.jsx)(h,{content:n,compact:!0,breaks:p,className:`text-sm leading-6 text-fg`}):(0,b.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[13]=p,t[14]=d,t[15]=n,t[16]=f,t[17]=M):M=t[17];let N;t[18]!==k||t[19]!==M?(N=(0,b.jsx)(`div`,{ref:_,inert:k,children:M}),t[18]=k,t[19]=M,t[20]=N):N=t[20];let P;t[21]!==g||t[22]!==N||t[23]!==j?(P=(0,b.jsx)(`div`,{id:g,style:j,children:N}),t[21]=g,t[22]=N,t[23]=j,t[24]=P):P=t[24];let F;t[25]!==r||t[26]!==E||t[27]!==g||t[28]!==a||t[29]!==x||t[30]!==w?(F=x?(0,b.jsx)(`button`,{type:`button`,"aria-expanded":E,"aria-controls":g,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:()=>w(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 E||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:a===`zh`?E?`收起`:`查看更多`:E?`Show less`:`Show more`}):null,t[25]=r,t[26]=E,t[27]=g,t[28]=a,t[29]=x,t[30]=w,t[31]=F):F=t[31];let I;return t[32]!==P||t[33]!==F||t[34]!==A?(I=(0,b.jsxs)(`div`,{className:A,children:[P,F]}),t[32]=P,t[33]=F,t[34]=A,t[35]=I):I=t[35],I}function S({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,u]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),h=(0,y.useRef)(null),g=e.kind===`approval`,_=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function v(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),u(``);try{let o=await f(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);m(!0),r(o),d({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{u(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,b.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),v()},children:[g?(0,b.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,b.jsx)(`p`,{children:e.reason}),(0,b.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,b.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,b.jsx)(l,{type:`button`,variant:`primary`,disabled:o||p,onClick:()=>void v(`approve`),children:n?`批准`:`Approve`}),(0,b.jsx)(l,{type:`button`,disabled:o||p,onClick:()=>void v(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,b.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||p,onChange:e=>a(e.target.value)})]}),_.length>0&&(0,b.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,b.jsx)(l,{type:`button`,disabled:o||p,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,b.jsx)(l,{type:`submit`,variant:`primary`,disabled:o||p||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,b.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function C(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 w({uri:e,zh:t}){let[n,r]=(0,y.useState)(),[i,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[d,f]=(0,y.useState)(``),[m,h]=(0,y.useState)(``);async function g(){o(!0),f(``);try{let n=C(e,(await p()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?f(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?f(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?f(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(h(n.shareUrl),f(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):f(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{f(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{o(!1)}}async function _(){if(!(!n||i)){o(!0),f(``);try{let e=await u(n.id,864e5);h(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),f(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){f(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{o(!1)}}}return(0,b.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,b.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(l,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void g(),children:t?`检查链接状态`:`Check link`}),s&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,b.jsx)(l,{type:`button`,disabled:i,onClick:()=>void _(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),d&&(0,b.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:d}),m&&(0,b.jsx)(`a`,{className:`block py-2 text-accent`,href:m,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),s&&(0,b.jsx)(a,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function T(e){let t=(0,v.c)(16),{evidence:n,projectId:r,conversationId:i,language:a,onOpenFile:s}=e,c=g(E);if(!n.length)return null;let l=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,u;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==c){let e;t[7]!==i||t[8]!==a||t[9]!==s||t[10]!==r||t[11]!==c?(e=(e,t)=>{let n=e.uri?.trim(),l=n&&/^https?:\/\//i.test(n),u=n&&!l&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),d=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,b.jsx)(x,{content:d,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:l?(0,b.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,b.jsx)(o,{className:`size-4 shrink-0`}),(0,b.jsx)(`span`,{className:`min-w-0 break-words`,children:d})]}):u&&(r||i)?(0,b.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:()=>s?s(n):c(n,null,r,i),children:[(0,b.jsx)(m,{className:`size-4 shrink-0`}),d]}):(0,b.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:d})}),l&&e.kind===`artifact`&&(0,b.jsx)(w,{uri:n,zh:a===`zh`},n),e.summary?(0,b.jsx)(x,{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,b.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]=s,t[10]=r,t[11]=c,t[12]=e):e=t[12],u=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=s,t[4]=r,t[5]=c,t[6]=u}else u=t[6];let d;return t[13]!==l||t[14]!==u?(d=(0,b.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":l,children:u}),t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function E(e){return e.setPath}export{_ as i,S as n,x as r,T 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{t as i}from"./popover-select-DGKUpVsz.js";import{i as a,n as ee,o}from"./locale-store-JogcXC4J.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./button-aIC072nz.js";import{t as l}from"./skeleton-BI5TyibZ.js";import{Bc as te,Eo as ne,Fc as re,Ha as ie,Ic as ae,Lc as u,Rc as oe,Vc as se,zc as d}from"./index-D1oivYvN.js";import{t as f}from"./number-input-DDeqHK-G.js";import{n as ce,t as le}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";import{n as p,t as ue}from"./use-autosave-BkB9uD93.js";var m=e(t(),1),h=n(),g=e=>a(`/api/observability/${e}`);async function _(e,t=`GET`,n){return o(g(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}})}var v=r(),y=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,b=`space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,de=(e=0)=>`${(e/1048576).toFixed(1)} MiB`;function x(){let e=(0,h.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,v.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,v.jsx)(l,{className:`h-48 rounded-xl`}),(0,v.jsx)(l,{className:`h-64 rounded-xl`})]}),e[0]=t):t=e[0],t}function fe(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 pe(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 S(){let e=ee(e=>e.language)===`zh`,t=(t,n)=>e?n:t,n=s(g(`tracing/settings`),()=>_(`tracing/settings`)),r=s(g(`tracing/status`),()=>_(`tracing/status`),{refreshInterval:1e4}),[a,o]=(0,m.useState)(),[h,S]=(0,m.useState)(),C=a??h??n.data?.config,[w,T]=(0,m.useState)(``),[E,D]=(0,m.useState)(``),[me,he]=(0,m.useState)(0),[O,ge]=(0,m.useState)(!1),[k,A]=(0,m.useState)(``),[_e,j]=(0,m.useState)(!1),[M,ve]=(0,m.useState)(``),[N,ye]=(0,m.useState)(`7`),[P,be]=(0,m.useState)({conversationId:``,runId:``,agentId:``}),[F,I]=(0,m.useState)(`records`),[L,xe]=(0,m.useState)(`10`),[Se,Ce]=(0,m.useState)([``]),[R,z]=(0,m.useState)(0),[we,Te]=(0,m.useState)(()=>Date.now()+1),B=Se[R],[V,H]=(0,m.useState)();function U(){Ce([``]),z(0),Te(Date.now()+1)}let[Ee,W]=(0,m.useState)(!1),G=new URLSearchParams({limit:L,from:String(we-Number(N)*864e5),to:String(we)});M&&G.set(`status`,M),B&&G.set(`cursor`,B);for(let[e,t]of Object.entries(P))t&&G.set(e,t);let De=`traces?${G}`,K=s(g(De),()=>_(De),{refreshInterval:B?0:1e4}),q=s(V?g(`traces/${V}`):null,()=>_(`traces/${V}`));function J(e){if(!C)return;let t=structuredClone(C);e(t),o(t)}async function Y(e,i=t(`Saved`,`已保存`)){ge(!0),A(``),j(!1);try{await e(),A(i),await Promise.all([n.mutate(),r.mutate(),K.mutate()])}catch(e){j(!0),A(e instanceof Error?e.message:t(`Request failed`,`操作失败`))}finally{ge(!1)}}let X=ue({value:C??null,dirty:!!(a&&JSON.stringify(a)!==JSON.stringify(h??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=>{S((await _(`tracing/settings`,`PATCH`,e)).config),o(t=>t&&JSON.stringify(t)===JSON.stringify(e)?void 0:t),await r.mutate().catch(()=>{})}}),Z=(0,m.useMemo)(()=>({publicKey:w.trim(),secretKey:E.trim()}),[w,E]),Q=ue({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 _(`tracing/langfuse/credentials`,`PUT`,{...e.publicKey?{publicKey:e.publicKey}:{},...e.secretKey?{secretKey:e.secretKey}:{}}),T(t=>t.trim()===e.publicKey?``:t),D(t=>t.trim()===e.secretKey?``:t),he(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 _(`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,v.jsxs)(ce,{className:`space-y-6`,children:[(0,v.jsx)(le,{title:t(`Runtime tracing`,`运行追踪`),subtitle:t(`Local diagnostics with bounded retention. Enable Langfuse to also export new traces.`,`默认保留有界本地记录;启用 Langfuse 后同时导出新采集的追踪。`),actions:F===`settings`?(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t(`Changes save automatically`,`修改后自动保存`)}),(0,v.jsx)(p,{status:X.status,error:X.error})]}):(0,v.jsx)(c,{disabled:K.isValidating,onClick:U,children:t(`Refresh records`,`刷新记录`)})}),k&&(0,v.jsx)(`p`,{role:_e?`alert`:`status`,className:`text-sm text-fg-muted`,children:k}),n.error&&(0,v.jsx)(`p`,{role:`alert`,children:String(n.error.message)}),(0,v.jsxs)(ie,{as:`nav`,"aria-label":t(`Tracing sections`,`追踪页面分区`),className:`flex gap-2 border-b border-edge pb-3`,children:[(0,v.jsx)(c,{"aria-pressed":F===`records`,variant:`ghost`,onClick:()=>I(`records`),children:t(`Execution records`,`执行记录`)}),(0,v.jsx)(c,{"aria-pressed":F===`settings`,variant:`ghost`,onClick:()=>I(`settings`),children:t(`Capture settings`,`采集设置`)})]}),F===`settings`&&(C?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`section`,{className:b,onBlurCapture:X.onBlurCapture,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Local recording`,`本地记录`)}),X.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:X.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.enabled,onChange:e=>J(t=>{t.enabled=e.target.checked})}),t(`Record traces`,`记录运行追踪`)]}),(0,v.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Retention (days)`,`保留天数`),(0,v.jsx)(f,{className:y,type:`number`,min:1,max:90,value:C.local.retentionDays,onChange:e=>J(t=>{t.local.retentionDays=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Storage budget (MiB)`,`存储上限(MiB)`),(0,v.jsx)(f,{className:y,type:`number`,min:16,max:4096,value:C.local.maxStoreMiB,onChange:e=>J(t=>{t.local.maxStoreMiB=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Capture`,`采集内容`),(0,v.jsx)(i,{placeholder:t(`Choose`,`请选择`),allowEmpty:!1,value:C.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,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Previews may contain personal content. Secrets and media are filtered; large values are truncated.`,`摘要可能包含个人内容。过滤凭证和媒体,超长内容会截断。`)}),C.detailedUntil&&(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Detailed capture expires: `,`详细采集截止:`),new Date(C.detailedUntil).toLocaleString()]}),(0,v.jsxs)(`details`,{children:[(0,v.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t(`Advanced limits`,`高级限制`)}),(0,v.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,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t,(0,v.jsx)(f,{type:`number`,min:1,className:y,value:C.local[e],onChange:t=>J(n=>{n.local[e]=Number(t.target.value)})})]},e))})]}),r.data?(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Disk / payload`,`磁盘 / 数据`),`:`,de(r.data.local.physicalBytes),` / `,de(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,v.jsx)(l,{className:`h-10`}),(r.error||r.data?.local.lastError)&&(0,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data?.local.lastError||String(r.error.message)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:O||$,onClick:()=>void Y(async()=>{await _(`traces/prune`,`POST`)}),children:t(`Clean expired`,`清理过期记录`)}),(0,v.jsx)(c,{disabled:O,onClick:()=>W(!0),children:t(`Clear local traces`,`清空本地追踪`)})]})]}),(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:`Langfuse`}),(0,v.jsx)(p,{status:Q.status,error:Q.error})]}),Q.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:Q.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.langfuse.enabled,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.enabled=e.target.checked})}),t(`Also export new traces to Langfuse`,`同时导出新采集的追踪到 Langfuse`)]}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm sm:col-span-2`,children:[`Base URL`,(0,v.jsx)(`input`,{className:y,type:`url`,value:C.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`?w:E,a=n.data?.credentials[e===`publicKey`?`publicKeyConfigured`:`secretKeyConfigured`];return(0,v.jsxs)(`div`,{className:`space-y-1 text-sm`,onBlurCapture:Q.onBlurCapture,children:[(0,v.jsx)(`label`,{htmlFor:`langfuse-${e}`,children:r}),(0,v.jsx)(ne,{id:`langfuse-${e}`,value:i||(a?`••••••••••••`:``),allowUnrevealedCopy:!0,onChange:t=>(e===`publicKey`?T:D)(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:()=>_(`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。`)},me)]},e)})]}),(0,v.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,v.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,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data.langfuse.lastError}),(0,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Changes save automatically. Historical traces are not uploaded. Offline exports may be dropped.`,`修改后自动保存。不会上传历史记录;断网或队列满时可能丢弃远端导出。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:O||$,onClick:()=>void Y(async()=>{if(!(await _(`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,v.jsx)(c,{disabled:O||$,onClick:()=>void Y(async()=>{await _(`tracing/langfuse/credentials`,`DELETE`),T(``),D(``),he(e=>e+1)}),children:t(`Remove saved credentials`,`移除已保存凭证`)})]})]})]}):(0,v.jsx)(x,{})),F===`records`&&(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Recent runs`,`最近执行`)}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Status`,`执行状态`),(0,v.jsx)(i,{placeholder:t(`All statuses`,`全部状态`),allowEmpty:!1,value:M,onChange:e=>{ve(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,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Time range`,`时间范围`),(0,v.jsx)(i,{placeholder:t(`Choose`,`请选择`),value:N,allowEmpty:!1,onChange:e=>{ye(e),U()},options:[`1`,`7`,`30`,`90`].map(e=>({value:e,label:`${e} ${t(`days`,`天`)}`}))})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Page size`,`每页条数`),(0,v.jsx)(i,{placeholder:t(`Choose`,`请选择`),value:L,allowEmpty:!1,onChange:e=>{xe(e),U()},options:[`10`,`20`].map(e=>({value:e,label:`${e} ${t(`records`,`条`)}`}))})]})]}),(0,v.jsxs)(`details`,{children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:[t(`Advanced filters`,`高级筛选`),Object.values(P).some(Boolean)?` · ${t(`Active`,`已启用`)}`:``]}),(0,v.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[`conversationId`,`runId`,`agentId`].map(e=>(0,v.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,v.jsx)(`input`,{"aria-label":e,placeholder:t(`Exact ID`,`输入完整 ID`),className:y,value:P[e],onChange:t=>{be({...P,[e]:t.target.value}),U()}})]},e))})]}),(0,v.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,v.jsx)(`p`,{role:`alert`,className:`p-4 text-sm`,children:K.error.message}),!K.data&&!K.error?(0,v.jsx)(`div`,{className:`space-y-3 p-3`,children:[0,1,2,3,4].map(e=>(0,v.jsx)(l,{className:`h-16`},e))}):(0,v.jsxs)(`div`,{className:`divide-y divide-edge`,children:[K.data?.traces.length===0&&(0,v.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,v.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,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.attributes[`xopc.agentId`]?` · ${n.attributes[`xopc.agentId`]}`:``]}),(0,v.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,v.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n.stats.generations,` `,t(`model calls`,`次模型调用`),` · `,n.stats.tokens,` tokens · $`,n.stats.knownCostUsd.toFixed(4),n.stats.unknownCostCalls>0?` · ${t(`partial cost`,`部分成本未知`)}`:``]})]}),(0,v.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,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,v.jsx)(`p`,{"aria-live":`polite`,className:`text-xs text-fg-muted`,children:t(`Page ${R+1} · ${K.data?.traces.length??0} records`,`第 ${R+1} 页 · ${K.data?.traces.length??0} 条`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:R===0||K.isValidating,onClick:()=>z(e=>Math.max(0,e-1)),children:t(`Previous page`,`上一页`)}),(0,v.jsx)(c,{disabled:!K.data?.nextCursor||K.isValidating,onClick:()=>{let e=K.data?.nextCursor;e&&(Ce(t=>[...t.slice(0,R+1),e]),z(e=>e+1))},children:t(`Next page`,`下一页`)})]})]})]}),(0,v.jsx)(re,{open:!!V,onOpenChange:e=>{e||H(void 0)},children:(0,v.jsxs)(te,{children:[(0,v.jsx)(d,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(u,{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,v.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,v.jsx)(se,{className:`font-medium`,children:t(`Trace details`,`追踪详情`)}),(0,v.jsx)(ae,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Close`,`关闭`)})})]}),(0,v.jsx)(oe,{className:`shrink-0 truncate text-xs text-fg-muted`,children:V}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-4`,children:q.error?(0,v.jsx)(`p`,{role:`alert`,children:q.error.message}):q.data?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`p`,{className:`text-sm`,children:[q.data.trace.status,` `,q.data.trace.partialReason&&` · ${q.data.trace.partialReason}`]}),pe(q.data.spans).map(e=>(0,v.jsxs)(`details`,{style:{marginLeft:fe(e,q.data.spans)*12},className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer`,children:[e.name,` · `,e.status,` · `,e.endedAt?`${Math.round(e.endedAt-e.startedAt)} ms`:`—`]}),(0,v.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,v.jsx)(x,{})}),(0,v.jsx)(`div`,{className:`shrink-0 border-t border-edge pt-3`,children:(0,v.jsx)(c,{disabled:!q.data||O,onClick:()=>void Oe(),children:t(`Export JSON`,`导出 JSON`)})})]})]})}),(0,v.jsx)(re,{open:Ee,onOpenChange:W,children:(0,v.jsxs)(te,{children:[(0,v.jsx)(d,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(u,{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,v.jsx)(se,{children:t(`Clear local traces?`,`清空本地追踪?`)}),(0,v.jsx)(oe,{className:`text-sm text-fg-muted`,children:t(`Removes retained local traces. Conversations, usage records and Langfuse data remain available.`,`删除已保留的本地追踪。会话、用量记录及 Langfuse 数据仍保留。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:O||$,onClick:()=>void Y(async()=>{await _(`traces`,`DELETE`),W(!1),H(void 0)}),children:t(`Clear`,`清空`)}),(0,v.jsx)(ae,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Cancel`,`取消`)})})]})]})]})})]})}export{S 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{t as i}from"./external-link-DjqjBmc3.js";import{t as a}from"./globe-DSSGFWFn.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-DMXSIJUO.js";import{t as c}from"./cn-0WouolD0.js";import{a as l,i as u,l as d,n as ee,o as f}from"./locale-store-DAgpZxAS.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-aIC072nz.js";import{t as h}from"./skeleton-BI5TyibZ.js";import{n as g,r as _}from"./gateway-config-swr-BVqYVaGy.js";import{Ao as v,Hi as y,yo as b,zl as x}from"./index-6YjAt50A.js";import{n as te,t as ne}from"./settings-form-section-DD3iD5t5.js";var S=e(t(),1),C=n(),w=r();function T(e){let t=(0,C.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=b(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let l;t[3]===o?l=t[4]:(l=c(`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`,o),t[3]=o,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,w.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==s||t[8]!==l?(d=(0,w.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=s,t[8]=l,t[9]=d):d=t[9],d}async function E(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function D(e=`serve`){let t=await l(`/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 O(){let e=await l(`/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 k=`https://tailscale.com/download`;function A(e){let t=(0,C.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,w.jsx)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function j({embedded:e=!1}){let t=ee(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,S.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!d(e=>e.conversationId),[c,l]=(0,S.useState)(!1),[u,f]=(0,S.useState)(null),{data:g,mutate:_,isLoading:v}=p(i?`exposure-status`:null,E,{refreshInterval:3e4}),b=g?.tailscale.hostname,C=g?.tailscale.active===!0,k=g?.tailscale.cliAvailable!==!1,j=b?`https://${b}/`:null,re=(0,S.useCallback)(async()=>{l(!0),f(null);try{await D(`serve`),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[_]),ie=(0,S.useCallback)(async()=>{l(!0),f(null);try{await O(),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[_]);if(!i)return null;let M=(0,w.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,w.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsxs)(`span`,{children:[n.stepInstallBefore,(0,w.jsx)(A,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsx)(`span`,{children:n.stepEnable})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&g?.tailscale.cliAvailable===!1?(0,w.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,w.jsx)(A,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,v&&!g?(0,w.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,w.jsx)(h,{className:`h-20 rounded-lg`}),(0,w.jsx)(h,{className:`h-20 rounded-lg`})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(ne,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C?n.statusActive:n.statusOff}),j?(0,w.jsx)(`div`,{className:`mt-3`,children:(0,w.jsx)(y,{text:j,labels:r})}):null,u?(0,w.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,w.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:C?(0,w.jsxs)(m,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void ie(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,w.jsxs)(m,{type:`button`,disabled:c||!k,onClick:()=>void re(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,w.jsx)(x,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,w.jsx)(T,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?M:(0,w.jsxs)(ne,{children:[(0,w.jsx)(te,{icon:a,title:n.title,subtitle:n.subtitle}),M]})}async function re(e){let t=await l(u(`/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 ie(e){await f(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function M(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 ae(){return(0,S.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`)||M(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function oe(){return c(`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 se(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 N(){let e=(0,C.c)(85),t=ee(le),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!d(ce),l=ae(),u=_(i).data?.payload?.config,f;e[2]===u?f=e[3]:(f=se(u),e[2]=u,e[3]=f);let p=f,[h,v]=(0,S.useState)(``),y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y={busy:!1,result:null},e[4]=y):y=e[4];let[b,x]=(0,S.useState)(y),T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(T={busy:!1,error:null},e[5]=T):T=e[5];let[E,D]=(0,S.useState)(T),O,k;e[6]!==p||e[7]!==l||e[8]!==h?(O=()=>{h||(p?v(p):l&&v(l))},k=[p,l,h],e[6]=p,e[7]=l,e[8]=h,e[9]=O,e[10]=k):(O=e[9],k=e[10]),(0,S.useEffect)(O,k);let A;bb0:{let t;e[11]===h?t=e[12]:(t=h.trim(),e[11]=h,e[12]=t);let n=t;if(n){A=n;break bb0}A=p??l??``}let j=A,M=!p&&!!l&&j===l,N;e[13]!==h||e[14]!==j?(N=async()=>{let e=h.trim()||j;if(e){x({busy:!0,result:null});try{x({busy:!1,result:await re(e)})}catch(e){let t=e;x({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=h,e[14]=j,e[15]=N):N=e[15];let de=N,fe;e[16]===j?fe=e[17]:(fe=async()=>{let e=j.trim();if(e){D({busy:!0,error:null});try{await ie(e),await g(),D({busy:!1,error:null})}catch(e){let t=e;D({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=j,e[17]=fe);let pe=fe,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{D({busy:!0,error:null});try{await ie(null),await g(),v(``),x({busy:!1,result:null}),D({busy:!1,error:null})}catch(e){let t=e;D({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,w.jsx)(te,{icon:a,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,w.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=c(oe(),`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=>{v(e.target.value),x({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==h||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,w.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:h,onChange:R}),e[26]=h,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===de?B=e[31]:(B=()=>void de(),e[30]=de,e[31]=B);let V;e[32]!==h||e[33]!==b.busy?(V=b.busy||!h.trim(),e[32]=h,e[33]=b.busy,e[34]=V):V=e[34];let H;e[35]===b.busy?H=e[36]:(H=b.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=b.busy,e[36]=H);let he=b.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,w.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,w.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,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==l||e[48]!==M||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=M&&l?(0,w.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,w.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,w.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:l}),(0,w.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=l,e[48]=M,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==b.result||e[53]!==r.probeStatus?(q=b.result?(0,w.jsx)(ue,{result:b.result,labels:r.probeStatus}):null,e[52]=b.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==j||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==E.busy?(J=j&&p!==j?(0,w.jsxs)(m,{type:`button`,onClick:()=>void pe(),disabled:E.busy,children:[E.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,E.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=j,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=E.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==E.busy?(Y=p?(0,w.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:E.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=E.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,w.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]===E.error?Z=e[70]:(Z=E.error?(0,w.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:E.error}):null,e[69]=E.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,w.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,w.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,w.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,w.jsxs)(ne,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function ce(e){return e.conversationId}function le(e){return e.language}function ue(e){let t=(0,C.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,w.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,w.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,w.jsxs)(w.Fragment,{children:[` · `,(0,w.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,w.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,w.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,w.jsxs)(w.Fragment,{children:[` — `,(0,w.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,w.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 de(){let e=await f(u(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function fe(e){try{return{kind:`ready`,setup:(await f(u(`/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 f(u(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await f(u(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await f(u(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await l(u(`/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.error;if(!n||typeof n!=`object`)return;let r=n.code;return typeof r==`string`?r:void 0}function R(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function z(){return f(u(`/api/tunnel/status`))}async function B(){await f(u(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await f(u(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return f(u(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return f(u(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await f(u(`/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 W(e){await f(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{N as _,B as a,T as b,he as c,P as d,fe as f,pe as g,de as h,V as i,L as l,F as m,z as n,U as o,me as p,W as r,H as s,I as t,R as u,j as v,E 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{t as i}from"./external-link-DjqjBmc3.js";import{t as a}from"./globe-DSSGFWFn.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-RzwPiQNL.js";import{t as c}from"./cn-0WouolD0.js";import{a as l,i as u,l as d,n as ee,o as f}from"./locale-store-JogcXC4J.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{t as m}from"./button-aIC072nz.js";import{t as h}from"./skeleton-BI5TyibZ.js";import{n as g,r as _}from"./gateway-config-swr-DF_HV6NP.js";import{Bl as v,Ii as y,bo as b,jo as x}from"./index-D1oivYvN.js";import{n as te,t as ne}from"./settings-form-section-BNYQjZU4.js";var S=e(t(),1),C=n(),w=r();function T(e){let t=(0,C.c)(10),{language:n,label:r,section:a,className:o}=e,s;t[0]!==n||t[1]!==a?(s=b(n,a),t[0]=n,t[1]=a,t[2]=s):s=t[2];let l;t[3]===o?l=t[4]:(l=c(`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`,o),t[3]=o,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,w.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==s||t[8]!==l?(d=(0,w.jsxs)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=s,t[8]=l,t[9]=d):d=t[9],d}async function E(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function D(e=`serve`){let t=await l(`/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 O(){let e=await l(`/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 k=`https://tailscale.com/download`;function A(e){let t=(0,C.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,w.jsx)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function j({embedded:e=!1}){let t=ee(e=>e.language),n=s(t).remoteAccess.tailscale,r=(0,S.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:s(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!d(e=>e.conversationId),[c,l]=(0,S.useState)(!1),[u,f]=(0,S.useState)(null),{data:g,mutate:_,isLoading:b}=p(i?`exposure-status`:null,E,{refreshInterval:3e4}),x=g?.tailscale.hostname,C=g?.tailscale.active===!0,k=g?.tailscale.cliAvailable!==!1,j=x?`https://${x}/`:null,re=(0,S.useCallback)(async()=>{l(!0),f(null);try{await D(`serve`),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[_]),ie=(0,S.useCallback)(async()=>{l(!0),f(null);try{await O(),await _()}catch(e){f(e instanceof Error?e.message:String(e))}finally{l(!1)}},[_]);if(!i)return null;let M=(0,w.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,w.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsxs)(`span`,{children:[n.stepInstallBefore,(0,w.jsx)(A,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsx)(`span`,{children:n.stepEnable})]}),(0,w.jsxs)(`li`,{className:`flex gap-2`,children:[(0,w.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,w.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&g?.tailscale.cliAvailable===!1?(0,w.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,w.jsx)(A,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,b&&!g?(0,w.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,w.jsx)(h,{className:`h-20 rounded-lg`}),(0,w.jsx)(h,{className:`h-20 rounded-lg`})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(ne,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C?n.statusActive:n.statusOff}),j?(0,w.jsx)(`div`,{className:`mt-3`,children:(0,w.jsx)(y,{text:j,labels:r})}):null,u?(0,w.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,w.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:C?(0,w.jsxs)(m,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>void ie(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,w.jsxs)(m,{type:`button`,disabled:c||!k,onClick:()=>void re(),children:[c?(0,w.jsx)(o,{className:`mr-1 size-4 animate-spin`}):(0,w.jsx)(v,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,w.jsx)(T,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?M:(0,w.jsxs)(ne,{children:[(0,w.jsx)(te,{icon:a,title:n.title,subtitle:n.subtitle}),M]})}async function re(e){let t=await l(u(`/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 ie(e){await f(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function M(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 ae(){return(0,S.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`)||M(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function oe(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function se(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 N(){let e=(0,C.c)(85),t=ee(le),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!d(ce),l=ae(),u=_(i).data?.payload?.config,f;e[2]===u?f=e[3]:(f=se(u),e[2]=u,e[3]=f);let p=f,[h,v]=(0,S.useState)(``),y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y={busy:!1,result:null},e[4]=y):y=e[4];let[b,x]=(0,S.useState)(y),T;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(T={busy:!1,error:null},e[5]=T):T=e[5];let[E,D]=(0,S.useState)(T),O,k;e[6]!==p||e[7]!==l||e[8]!==h?(O=()=>{h||(p?v(p):l&&v(l))},k=[p,l,h],e[6]=p,e[7]=l,e[8]=h,e[9]=O,e[10]=k):(O=e[9],k=e[10]),(0,S.useEffect)(O,k);let A;bb0:{let t;e[11]===h?t=e[12]:(t=h.trim(),e[11]=h,e[12]=t);let n=t;if(n){A=n;break bb0}A=p??l??``}let j=A,M=!p&&!!l&&j===l,N;e[13]!==h||e[14]!==j?(N=async()=>{let e=h.trim()||j;if(e){x({busy:!0,result:null});try{x({busy:!1,result:await re(e)})}catch(e){let t=e;x({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=h,e[14]=j,e[15]=N):N=e[15];let de=N,fe;e[16]===j?fe=e[17]:(fe=async()=>{let e=j.trim();if(e){D({busy:!0,error:null});try{await ie(e),await g(),D({busy:!1,error:null})}catch(e){let t=e;D({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=j,e[17]=fe);let pe=fe,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{D({busy:!0,error:null});try{await ie(null),await g(),v(``),x({busy:!1,result:null}),D({busy:!1,error:null})}catch(e){let t=e;D({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,w.jsx)(te,{icon:a,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,w.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=c(oe(),`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=>{v(e.target.value),x({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==h||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,w.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:h,onChange:R}),e[26]=h,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===de?B=e[31]:(B=()=>void de(),e[30]=de,e[31]=B);let V;e[32]!==h||e[33]!==b.busy?(V=b.busy||!h.trim(),e[32]=h,e[33]=b.busy,e[34]=V):V=e[34];let H;e[35]===b.busy?H=e[36]:(H=b.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,e[35]=b.busy,e[36]=H);let he=b.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,w.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,w.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,w.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==l||e[48]!==M||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=M&&l?(0,w.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,w.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,w.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:l}),(0,w.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=l,e[48]=M,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==b.result||e[53]!==r.probeStatus?(q=b.result?(0,w.jsx)(ue,{result:b.result,labels:r.probeStatus}):null,e[52]=b.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==p||e[56]!==j||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==E.busy?(J=j&&p!==j?(0,w.jsxs)(m,{type:`button`,onClick:()=>void pe(),disabled:E.busy,children:[E.busy?(0,w.jsx)(o,{className:`size-3.5 animate-spin`}):null,E.busy?r.saving:r.saveAsDefault]}):null,e[55]=p,e[56]=j,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=E.busy,e[61]=J):J=e[61];let Y;e[62]!==p||e[63]!==r.clear||e[64]!==E.busy?(Y=p?(0,w.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:E.busy,children:r.clear}):null,e[62]=p,e[63]=r.clear,e[64]=E.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,w.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]===E.error?Z=e[70]:(Z=E.error?(0,w.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:E.error}):null,e[69]=E.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,w.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,w.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,w.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,w.jsxs)(ne,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function ce(e){return e.conversationId}function le(e){return e.language}function ue(e){let t=(0,C.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,w.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,w.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,w.jsxs)(w.Fragment,{children:[` · `,(0,w.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,w.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,w.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,w.jsxs)(w.Fragment,{children:[` — `,(0,w.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,w.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 de(){let e=await f(u(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function fe(e){try{return{kind:`ready`,setup:(await f(u(`/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 f(u(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await f(u(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await f(u(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await l(u(`/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.error;if(!n||typeof n!=`object`)return;let r=n.code;return typeof r==`string`?r:void 0}function R(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function z(){return f(u(`/api/tunnel/status`))}async function B(){await f(u(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await f(u(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return f(u(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return f(u(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await f(u(`/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 W(e){await f(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{N as _,B as a,T as b,he as c,P as d,fe as f,pe as g,de as h,V as i,L as l,F as m,z as n,U as o,me as p,W as r,H as s,I as t,R as u,j as v,E as y};
@@ -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{m as i}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as a}from"./popover-select-DGKUpVsz.js";import{t as o}from"./messages-RzwPiQNL.js";import{i as s,n as c,o as l}from"./locale-store-JogcXC4J.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{t as d}from"./button-aIC072nz.js";import{t as f}from"./skeleton-BI5TyibZ.js";import{Fl as p,Ha as m,Nd as h,Ud as g,Xu as _,al as v,md as y,vd as b}from"./index-D1oivYvN.js";import{n as x,t as ee}from"./settings-page-header-CYpuTXUW.js";import"./settings-page-layout-B20AfmFG.js";import{t as S}from"./xopc-cloud-account-card-B2OUKOQi.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 l(s(`/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),l(s(`/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 M(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 te(){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)(f,{className:`h-52 rounded-xl`}),(0,O.jsx)(f,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(f,{className:`h-24 rounded-xl`},e)}function P(){let e=c(e=>e.language),t=o(e).usage,[n,r]=i(),s=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,l=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(s)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(s),I),[s,I]),R=u([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=u([`usage-events`,L,N,l],()=>D(L,N,l),{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)(ee,{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)(a,{value:s,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)(d,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(s),children:(0,O.jsx)(p,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(te,{}):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)(h,{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)(d,{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:b},{label:t.knownCost,value:$(Z),icon:b},{label:t.calls,value:Z.calls.toLocaleString(),icon:_},{label:t.tokens,value:k(Z.totalTokens,e),icon:y}].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)(m,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(d,{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)(d,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(d,{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)(a,{value:String(l),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)(d,{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)(g,{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)(v,{className:`size-3`,"aria-hidden":!0}),M(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)(f,{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)(d,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(d,{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)(d,{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)(S,{labels:o(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{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-0WouolD0.js";import{n as s}from"./locale-store-DAgpZxAS.js";import{jd as c}from"./index-6YjAt50A.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(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=o(`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)(a,{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)(i,{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)(c,{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{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-0WouolD0.js";import{n as s}from"./locale-store-JogcXC4J.js";import{Nd as c}from"./index-D1oivYvN.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=s(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=o(`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)(a,{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)(i,{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)(c,{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};