agentroam-runtime-darwin-arm64 0.2.0-preview.76 → 0.2.0-preview.77

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 (319) hide show
  1. package/manifest.json +2 -2
  2. package/package.json +1 -1
  3. package/runtime/.next/BUILD_ID +1 -1
  4. package/runtime/.next/app-path-routes-manifest.json +1 -1
  5. package/runtime/.next/build-manifest.json +2 -2
  6. package/runtime/.next/prerender-manifest.json +1 -1
  7. package/runtime/.next/server/app/_not-found.html +1 -1
  8. package/runtime/.next/server/app/_not-found.rsc +1 -1
  9. package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
  10. package/runtime/.next/server/app/api/agent/abort/route.js.nft.json +1 -1
  11. package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
  12. package/runtime/.next/server/app/api/agent/answer/route.js.nft.json +1 -1
  13. package/runtime/.next/server/app/api/agent/codex-sharing/route.js +1 -1
  14. package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
  15. package/runtime/.next/server/app/api/agent/harness/status/route.js.nft.json +1 -1
  16. package/runtime/.next/server/app/api/agent/model/route.js +1 -1
  17. package/runtime/.next/server/app/api/agent/model/route.js.nft.json +1 -1
  18. package/runtime/.next/server/app/api/agent/models/route.js +1 -1
  19. package/runtime/.next/server/app/api/agent/run/route.js +1 -1
  20. package/runtime/.next/server/app/api/agent/run/route.js.nft.json +1 -1
  21. package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
  22. package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
  23. package/runtime/.next/server/app/api/agent/steer/route.js.nft.json +1 -1
  24. package/runtime/.next/server/app/api/agent/stream/route.js +3 -3
  25. package/runtime/.next/server/app/api/agent/stream/route.js.nft.json +1 -1
  26. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
  27. package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js.nft.json +1 -1
  28. package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
  29. package/runtime/.next/server/app/api/agent-workspaces/route.js.nft.json +1 -1
  30. package/runtime/.next/server/app/api/business/route.js +1 -1
  31. package/runtime/.next/server/app/api/business/route.js.nft.json +1 -1
  32. package/runtime/.next/server/app/api/calendar/route.js +2 -2
  33. package/runtime/.next/server/app/api/client-logs/route.js +1 -1
  34. package/runtime/.next/server/app/api/collaboration/route.js +4 -4
  35. package/runtime/.next/server/app/api/collaboration/route.js.nft.json +1 -1
  36. package/runtime/.next/server/app/api/engine-threads/route.js +1 -1
  37. package/runtime/.next/server/app/api/engine-threads.body +1 -1
  38. package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
  39. package/runtime/.next/server/app/api/flow/v1/catalog/route.js.nft.json +1 -1
  40. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
  41. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js.nft.json +1 -1
  42. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +1 -1
  43. package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js.nft.json +1 -1
  44. package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
  45. package/runtime/.next/server/app/api/flow/v1/runs/route.js.nft.json +1 -1
  46. package/runtime/.next/server/app/api/internal/todo-bootstrap/route.js +1 -4
  47. package/runtime/.next/server/app/api/internal/todo-bootstrap/route.js.nft.json +1 -1
  48. package/runtime/.next/server/app/api/internal/todo-mcp/route.js +1 -1
  49. package/runtime/.next/server/app/api/internal/todo-mcp/route.js.nft.json +1 -1
  50. package/runtime/.next/server/app/api/notifications/[id]/ack/route.js +1 -1
  51. package/runtime/.next/server/app/api/notifications/[id]/ack/route.js.nft.json +1 -1
  52. package/runtime/.next/server/app/api/notifications/[id]/route.js +1 -1
  53. package/runtime/.next/server/app/api/notifications/[id]/route.js.nft.json +1 -1
  54. package/runtime/.next/server/app/api/notifications/route.js +1 -1
  55. package/runtime/.next/server/app/api/notifications/route.js.nft.json +1 -1
  56. package/runtime/.next/server/app/api/notifications/stream/route.js +1 -1
  57. package/runtime/.next/server/app/api/notifications/stream/route.js.nft.json +1 -1
  58. package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
  59. package/runtime/.next/server/app/api/plugins/load/route.js.nft.json +1 -1
  60. package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
  61. package/runtime/.next/server/app/api/push/subscribe/route.js.nft.json +1 -1
  62. package/runtime/.next/server/app/api/push/vapid/route.js +3 -3
  63. package/runtime/.next/server/app/api/push/vapid/route.js.nft.json +1 -1
  64. package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
  65. package/runtime/.next/server/app/api/remote-tools/register/route.js.nft.json +1 -1
  66. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/route.js +1 -1
  67. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/stop/route.js +1 -1
  68. package/runtime/.next/server/app/api/sessions/[id]/background-jobs/route.js +1 -1
  69. package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +3 -3
  70. package/runtime/.next/server/app/api/sessions/[id]/engine-switches/route.js +1 -1
  71. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
  72. package/runtime/.next/server/app/api/sessions/[id]/fork/route.js.nft.json +1 -1
  73. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -1
  74. package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js.nft.json +1 -1
  75. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
  76. package/runtime/.next/server/app/api/sessions/[id]/goals/route.js.nft.json +1 -1
  77. package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
  78. package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js +1 -1
  79. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
  80. package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js.nft.json +1 -1
  81. package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
  82. package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
  83. package/runtime/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
  84. package/runtime/.next/server/app/api/sessions/[id]/switch-engine/route.js +1 -1
  85. package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
  86. package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js.nft.json +1 -1
  87. package/runtime/.next/server/app/api/sessions/[id]/thread-history/route.js +1 -1
  88. package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
  89. package/runtime/.next/server/app/api/sessions/parallel/route.js +1 -1
  90. package/runtime/.next/server/app/api/sessions/parallel/route.js.nft.json +1 -1
  91. package/runtime/.next/server/app/api/sessions/route.js +1 -1
  92. package/runtime/.next/server/app/api/sessions/route.js.nft.json +1 -1
  93. package/runtime/.next/server/app/api/todos/[id]/commands/route.js +1 -1
  94. package/runtime/.next/server/app/api/todos/[id]/commands/route.js.nft.json +1 -1
  95. package/runtime/.next/server/app/api/todos/[id]/executions/route.js +1 -1
  96. package/runtime/.next/server/app/api/todos/[id]/executions/route.js.nft.json +1 -1
  97. package/runtime/.next/server/app/api/todos/[id]/route.js +1 -1
  98. package/runtime/.next/server/app/api/todos/[id]/route.js.nft.json +1 -1
  99. package/runtime/.next/server/app/api/todos/route.js +1 -1
  100. package/runtime/.next/server/app/api/todos/route.js.nft.json +1 -1
  101. package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
  102. package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js.nft.json +1 -1
  103. package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
  104. package/runtime/.next/server/app/api/tool-policies/route.js.nft.json +1 -1
  105. package/runtime/.next/server/app/api/tools/route.js +1 -1
  106. package/runtime/.next/server/app/api/tools/route.js.nft.json +1 -1
  107. package/runtime/.next/server/app-paths-manifest.json +36 -36
  108. package/runtime/.next/server/chunks/535.js +1 -0
  109. package/runtime/.next/server/chunks/5762.js +3 -3
  110. package/runtime/.next/server/chunks/5801.js +1 -1
  111. package/runtime/.next/server/chunks/5812.js +1 -0
  112. package/runtime/.next/server/chunks/685.js +1 -0
  113. package/runtime/.next/server/chunks/9119.js +4 -4
  114. package/runtime/.next/server/chunks/9457.js +1 -4
  115. package/runtime/.next/server/pages/404.html +1 -1
  116. package/runtime/.next/server/pages/500.html +1 -1
  117. package/runtime/.next/server/server-reference-manifest.json +1 -1
  118. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
  119. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
  120. package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
  121. package/runtime/node_modules/.package-lock.json +17 -17
  122. package/runtime/node_modules/@agent/core/dist/index.js +9 -4
  123. package/runtime/node_modules/@agent/native-runtime/dist/index.js +439 -90
  124. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +81 -85
  125. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +65 -65
  126. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-0vfvgmex.mjs +39 -0
  127. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-k19jejpn.mjs → core-3h0s3zzg.mjs} +2 -2
  128. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-a8ty0dnc.mjs → core-6w7w19rc.mjs} +2 -2
  129. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-8fprsbvz.mjs +42 -0
  130. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-avz7wgsg.mjs +23 -0
  131. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-b9ebje8h.mjs +20 -0
  132. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-kag24kjr.mjs → core-e1h3fbg3.mjs} +3 -3
  133. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-ae73vzp2.mjs → core-ge6en8c9.mjs} +4 -4
  134. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-e93r8awg.mjs → core-htcq9qj1.mjs} +2 -2
  135. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-v6sp3qjw.mjs → core-nv0a4kre.mjs} +4 -4
  136. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-y4qk5bdp.mjs +17 -0
  137. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-nfa6p2rw.mjs → core-yrdmz7je.mjs} +3 -3
  138. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-z276fcqp.mjs +28 -0
  139. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +12 -12
  140. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +21 -21
  141. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +25 -25
  142. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +23 -25
  143. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +85 -85
  144. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +72 -45
  145. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +13 -13
  146. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +13 -13
  147. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +72 -45
  148. package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +72 -45
  149. package/runtime/node_modules/mediabunny/dist/modules/src/input.js +6 -0
  150. package/runtime/node_modules/mediabunny/dist/modules/src/media-sink.js +52 -35
  151. package/runtime/node_modules/mediabunny/dist/modules/src/media-source.js +2 -0
  152. package/runtime/node_modules/mediabunny/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.js +7 -1
  153. package/runtime/node_modules/mediabunny/dist/modules/src/source.js +7 -4
  154. package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
  155. package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
  156. package/runtime/node_modules/mediabunny/dist/modules/src/wave/wave-demuxer.js +6 -6
  157. package/runtime/node_modules/mediabunny/package.json +1 -1
  158. package/runtime/node_modules/mediabunny/src/input.ts +7 -0
  159. package/runtime/node_modules/mediabunny/src/media-sink.ts +56 -37
  160. package/runtime/node_modules/mediabunny/src/media-source.ts +3 -0
  161. package/runtime/node_modules/mediabunny/src/mpeg-ts/mpeg-ts-demuxer.ts +6 -1
  162. package/runtime/node_modules/mediabunny/src/source.ts +7 -4
  163. package/runtime/node_modules/mediabunny/src/version.ts +1 -1
  164. package/runtime/node_modules/mediabunny/src/wave/wave-demuxer.ts +6 -6
  165. package/runtime/node_modules/source-map-js/lib/quick-sort.js +92 -22
  166. package/runtime/node_modules/source-map-js/package.json +1 -1
  167. package/runtime/package-lock.json +41 -65
  168. package/runtime/webapp/dist/assets/{AIHubView-DF0D5qd2.js → AIHubView-CrtJMKfW.js} +1 -1
  169. package/runtime/webapp/dist/assets/{AgentManager-Ccj6ZefC.js → AgentManager-C2O-Dacy.js} +1 -1
  170. package/runtime/webapp/dist/assets/{AiHubPane-3PRSxzO0.js → AiHubPane-D2XWxc9R.js} +1 -1
  171. package/runtime/webapp/dist/assets/App-Bum2L4_E.js +63 -0
  172. package/runtime/webapp/dist/assets/{BrowserLivePanel-BZDtF0ne.js → BrowserLivePanel-DkBugqrH.js} +13 -18
  173. package/runtime/webapp/dist/assets/{CalendarPage-B8Jo-3Da.js → CalendarPage-DzYWlqoZ.js} +1 -1
  174. package/runtime/webapp/dist/assets/CalendarView-BjjC_t12.css +1 -0
  175. package/runtime/webapp/dist/assets/CalendarView-HQls5G-1.js +31 -0
  176. package/runtime/webapp/dist/assets/{CollaborationCreateDialog-CU1t0iYL.js → CollaborationCreateDialog-BwiSJbjb.js} +1 -1
  177. package/runtime/webapp/dist/assets/{CollaborationDashboard-BZhWQXzn.js → CollaborationDashboard-CNHt31kl.js} +1 -1
  178. package/runtime/webapp/dist/assets/{CollaborationPage-BwRJN55v.js → CollaborationPage-C4l-tTvn.js} +2 -2
  179. package/runtime/webapp/dist/assets/{FilePreview-Oo8sZH0t.js → FilePreview-EGUAbGpH.js} +3 -3
  180. package/runtime/webapp/dist/assets/{FileTree-qJTRdDPQ.js → FileTree-aJGl1V0W.js} +1 -1
  181. package/runtime/webapp/dist/assets/{FileWorkspaceDrawer-D40WNAqC.js → FileWorkspaceDrawer-zpD91eB6.js} +1 -1
  182. package/runtime/webapp/dist/assets/{FlowStudioPane-C1tgSbGo.js → FlowStudioPane-K1o4pSkZ.js} +1 -1
  183. package/runtime/webapp/dist/assets/{HostProjectPicker-BEfXuqxT.js → HostProjectPicker-BvboCQ0a.js} +1 -1
  184. package/runtime/webapp/dist/assets/{LSPServerList-DQRv04aP.js → LSPServerList-BSLzGLtW.js} +1 -1
  185. package/runtime/webapp/dist/assets/{MCPServerList-BmsejJC9.js → MCPServerList-CeWTI1-m.js} +1 -1
  186. package/runtime/webapp/dist/assets/{MemoryViewer-qZMdVrli.js → MemoryViewer-YcceFawC.js} +1 -1
  187. package/runtime/webapp/dist/assets/NewSessionWindow-C_HCQQnW.js +1 -0
  188. package/runtime/webapp/dist/assets/NewSessionWindow-DOLG1XEp.css +1 -0
  189. package/runtime/webapp/dist/assets/{RemoteDesktopPage-Dz_6-rOL.js → RemoteDesktopPage-Cpzv8zH0.js} +1 -1
  190. package/runtime/webapp/dist/assets/{RunningSessionsIcon-DJxTmxZn.js → RunningSessionsIcon-DmCYwIYD.js} +1 -1
  191. package/runtime/webapp/dist/assets/{SessionDashboard-DuR9r_ZP.js → SessionDashboard-C58Mke8a.js} +1 -1
  192. package/runtime/webapp/dist/assets/{SessionDashboardBridge-BHVjvDHa.js → SessionDashboardBridge-BPsNDY5Y.js} +1 -1
  193. package/runtime/webapp/dist/assets/{SettingsPanel-B-g919uV.js → SettingsPanel-CPBIPT-Z.js} +1 -1
  194. package/runtime/webapp/dist/assets/{SkillManager-nrWIOtEO.js → SkillManager-_qaGEuOE.js} +1 -1
  195. package/runtime/webapp/dist/assets/{TerminalPane-C4HiD2IC.js → TerminalPane-mYe76Pgb.js} +1 -1
  196. package/runtime/webapp/dist/assets/TodoPage-DdF5_SkL.js +1 -0
  197. package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-BXRYzdBT.js → abnfDiagram-VCTEODGH-DLd8EeCY.js} +1 -1
  198. package/runtime/webapp/dist/assets/{arc-BeG7yjCw.js → arc-D4smlqs5.js} +1 -1
  199. package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-DIQbpqn7.js → architectureDiagram-5GKGNRK7-ByE3DRU4.js} +1 -1
  200. package/runtime/webapp/dist/assets/{arrow-right-B03zMFiC.js → arrow-right-BtIv2jiq.js} +1 -1
  201. package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-DvgKV01C.js → blockDiagram-I7D4REHJ-BvTUm5vA.js} +1 -1
  202. package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-DIr7nDIg.js → c4Diagram-7LVT6UL2-XKwj5RmQ.js} +1 -1
  203. package/runtime/webapp/dist/assets/{calendar-days-D1OJEOKr.js → calendar-days-BeI09qof.js} +1 -1
  204. package/runtime/webapp/dist/assets/channel-wxCRUEc2.js +1 -0
  205. package/runtime/webapp/dist/assets/{check-BDiCDSY5.js → check-BdadwkYj.js} +1 -1
  206. package/runtime/webapp/dist/assets/{chevron-down-DIt_NscV.js → chevron-down-DwzPFeq8.js} +1 -1
  207. package/runtime/webapp/dist/assets/{chevron-right-DVhYkZeF.js → chevron-right-kcIXzCMb.js} +1 -1
  208. package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-Cykdc4to.js → chunk-2Q5K7J3B-7A6CDWIw.js} +1 -1
  209. package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-DL-gBU30.js → chunk-5VM5RSS4-mkNEWbY6.js} +1 -1
  210. package/runtime/webapp/dist/assets/{chunk-F27PBJKO-z0F9O96j.js → chunk-F27PBJKO-DKG-1HL0.js} +1 -1
  211. package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-DcSgatN1.js → chunk-IMKFNOWR-kiJDyKM7.js} +1 -1
  212. package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-BmG1ozp9.js → chunk-JWPE2WC7-DS7C5_M7.js} +1 -1
  213. package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-BK2jifSN.js → chunk-POPQ4Y6H-DvgeK_lX.js} +1 -1
  214. package/runtime/webapp/dist/assets/{chunk-SVP7TREG-DtInGjiG.js → chunk-SVP7TREG-BLo_2ua-.js} +1 -1
  215. package/runtime/webapp/dist/assets/{chunk-TICWLB2K-DWdiL4Y6.js → chunk-TICWLB2K-CJT6Qkz4.js} +1 -1
  216. package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-w8UYxZUB.js → chunk-XXDRQBXY-D1OLqjNu.js} +1 -1
  217. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-Ct3Cgqrl.js +1 -0
  218. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-Ct3Cgqrl.js +1 -0
  219. package/runtime/webapp/dist/assets/{codeSyntax-Cprr1Nm9.js → codeSyntax-Dd0hAazb.js} +1 -1
  220. package/runtime/webapp/dist/assets/collaboration-CAgt9AiV.js +6 -0
  221. package/runtime/webapp/dist/assets/composer-file-routing-DSC2Eojr.js +6 -0
  222. package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-BJgwy7Y5.js → cose-bilkent-JH36ORCC-CI6EKHP8.js} +1 -1
  223. package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-BssWa1kU.js → cynefin-OW5HDTMX-CJTXYieX.js} +1 -1
  224. package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-Bv_-fuG_.js → cynefinDiagram-5FMLGOSQ-CPl1UVhy.js} +1 -1
  225. package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-BjA5n2Zi.js → dagre-GXQ25YYZ-Dq3ZQGTN.js} +1 -1
  226. package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-CCT38L0E.js → diagram-S7CK7UJ4-DJyU-2Di.js} +1 -1
  227. package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-4fLw8kje.js → diagram-UQ7AKVKN-Csg8hC8m.js} +1 -1
  228. package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-43_Qj0Se.js → diagram-VSXAHHWV-B14uLH_N.js} +1 -1
  229. package/runtime/webapp/dist/assets/{diagram-VX7I27RA-BHEXgMDZ.js → diagram-VX7I27RA-D2Ww2nHe.js} +1 -1
  230. package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-BRTSiXVr.js → diagram-Z3DM3KII-D_YC6AVP.js} +1 -1
  231. package/runtime/webapp/dist/assets/{download-CuYS63Ny.js → download-COWHIKec.js} +1 -1
  232. package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-B4GImY-o.js → ebnfDiagram-PWID7BFC-s66xVEGY.js} +1 -1
  233. package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-EmEsAxWS.js → erDiagram-RLTQ6QDP-CgZh5cEn.js} +1 -1
  234. package/runtime/webapp/dist/assets/{external-link-Baeyco26.js → external-link-T3kil1jt.js} +1 -1
  235. package/runtime/webapp/dist/assets/{file-types-CykGmGsd.js → file-types-0e-tNIVd.js} +1 -1
  236. package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-sky_wmbX.js → flowDiagram-HODETNUW-BISMKynN.js} +1 -1
  237. package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-Cc71xV1j.js → ganttDiagram-EL5Y4UJY-Cbyu0NcF.js} +1 -1
  238. package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-z7uQ8-8z.js → gitGraphDiagram-WWUBYQGX-Cs6IQGBz.js} +1 -1
  239. package/runtime/webapp/dist/assets/{history-C7WUwl_W.js → history-Df4LXw6L.js} +1 -1
  240. package/runtime/webapp/dist/assets/{image-plus-B2RK1ogI.js → image-plus-COHCHOpI.js} +1 -1
  241. package/runtime/webapp/dist/assets/index-CQTDnt74.css +1 -0
  242. package/runtime/webapp/dist/assets/{index-d8fS3JdV.js → index-CTJNAMck.js} +52 -52
  243. package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-DXLEePz0.js → infoDiagram-27XIBGKW-4f3bFqNV.js} +1 -1
  244. package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-DCFXm_zQ.js → ishikawaDiagram-5VMMS53U-D-cJ9vio.js} +1 -1
  245. package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-DHWCpvY6.js → journeyDiagram-3NMN7TZE-CeToS0Qx.js} +1 -1
  246. package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-D_uP81aw.js → kanban-definition-UXKFOSKX-DStbIUk1.js} +1 -1
  247. package/runtime/webapp/dist/assets/{layout-Bcu83-1p.js → layout-i2D4wlYd.js} +1 -1
  248. package/runtime/webapp/dist/assets/{linear-CPim5SQa.js → linear-BcJhiCv3.js} +1 -1
  249. package/runtime/webapp/dist/assets/{list-todo-F1W4yBLx.js → list-todo-7yETOqQe.js} +1 -1
  250. package/runtime/webapp/dist/assets/{loader-circle-DesEGpVH.js → loader-circle-CZdAfU-D.js} +1 -1
  251. package/runtime/webapp/dist/assets/{locate-fixed-UXM91vCS.js → locate-fixed-ByJuEKxC.js} +1 -1
  252. package/runtime/webapp/dist/assets/{mermaid.core-CyzKk3O2.js → mermaid.core-BjNFAB9I.js} +5 -5
  253. package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-0MHQpQro.js → mindmap-definition-YA3MSWOX-BUIHHUVG.js} +1 -1
  254. package/runtime/webapp/dist/assets/new-session-window-C7R76XMp.css +1 -0
  255. package/runtime/webapp/dist/assets/new-session-window-DwtkwFBQ.js +190 -0
  256. package/runtime/webapp/dist/assets/{page-C2e368Dx.js → page-9-9EC7QM.js} +3 -3
  257. package/runtime/webapp/dist/assets/{pause-_h6c8qPD.js → pause-DXyBDZlg.js} +1 -1
  258. package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-BNinoE-7.js → pegDiagram-XKGWAZYB-BY5Bio5e.js} +1 -1
  259. package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-CfPzV9yb.js → pieDiagram-E7YTZNPT-CF8DVW3F.js} +1 -1
  260. package/runtime/webapp/dist/assets/{pin-BcXr5230.js → pin-2YlrlSJv.js} +1 -1
  261. package/runtime/webapp/dist/assets/{play-BdB0D0rZ.js → play-BxEpdvoI.js} +1 -1
  262. package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-0qLb33lM.js → quadrantDiagram-AXDQQJYC-CXWHO3a-.js} +1 -1
  263. package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-DNU4eRJt.js → railroadDiagram-O6MQD6OU-C20JeJZ-.js} +1 -1
  264. package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-BWJRwKX8.js → requirementDiagram-BXWQKSXE-IYd9UrO9.js} +1 -1
  265. package/runtime/webapp/dist/assets/{rotate-ccw-BdZpOTYP.js → rotate-ccw-CFIRtbUD.js} +1 -1
  266. package/runtime/webapp/dist/assets/{rotate-cw-D-zPMe4i.js → rotate-cw-B_vFqNsz.js} +1 -1
  267. package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-CGW9pvun.js → sankeyDiagram-P5KCCOFB-ysBhpblA.js} +1 -1
  268. package/runtime/webapp/dist/assets/{send-DCVOqOap.js → send-DUE2vBoK.js} +1 -1
  269. package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-CeVAD519.js → sequenceDiagram-WJ2MYXX4-CQMmk6cu.js} +1 -1
  270. package/runtime/webapp/dist/assets/session-dashboard-DnFhQhBN.js +1 -0
  271. package/runtime/webapp/dist/assets/{shield-check-DrxVJwVC.js → shield-check-Btyos6Iv.js} +1 -1
  272. package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-Dj5SukiO.js → sizeCapture-INFHLROL-DekvKUn1.js} +1 -1
  273. package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-UtRSslyd.js → stateDiagram-D77RDMKH-Ds_FEmbr.js} +1 -1
  274. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-DxJ1ks_8.js +1 -0
  275. package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-DKbrz8SF.js → swimlanes-42K2YHIH-cjPcEO_T.js} +1 -1
  276. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-JGHIAQXy.js +8 -0
  277. package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-mtVdMOBL.js → timeline-definition-24CTP7MA-CEOprVt5.js} +1 -1
  278. package/runtime/webapp/dist/assets/{trash-2-Bbhd8-xd.js → trash-2-DLDxY6J7.js} +1 -1
  279. package/runtime/webapp/dist/assets/{types-CMhUwzwJ.js → types-CFAnlTif.js} +1 -1
  280. package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-ZcuGEhJx.js → vennDiagram-4TSXK5OY-D82uxYY9.js} +1 -1
  281. package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-CnAYI2ZE.js → wardleyDiagram-VM6X3IG4-JFt7Izt0.js} +1 -1
  282. package/runtime/webapp/dist/assets/{web-BH9JgWsL.js → web-BMqaP0jw.js} +1 -1
  283. package/runtime/webapp/dist/assets/{web-CBiaPgEe.js → web-Q9VPRftY.js} +1 -1
  284. package/runtime/webapp/dist/assets/{x-1GQMVfza.js → x-CeSbythI.js} +1 -1
  285. package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-B_uJt0Bg.js → xychartDiagram-S5SC5T6Z-1WCa4SfL.js} +1 -1
  286. package/runtime/webapp/dist/assets/{zoom-out-BNKdrTFD.js → zoom-out-CRr_o1NV.js} +8 -3
  287. package/runtime/webapp/dist/index.html +2 -2
  288. package/runtime/ws-server.mjs +11 -0
  289. package/runtime/.next/server/chunks/2480.js +0 -4
  290. package/runtime/.next/server/chunks/3604.js +0 -4
  291. package/runtime/.next/server/chunks/732.js +0 -1
  292. package/runtime/.next/server/chunks/7788.js +0 -1
  293. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-25bstexa.mjs +0 -17
  294. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-4ps8vwh1.mjs +0 -42
  295. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-9a7zb9bm.mjs +0 -53
  296. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-dsa3p77h.mjs +0 -18
  297. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-eqz9ara6.mjs +0 -18
  298. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-esw7xtkz.mjs +0 -17
  299. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-ey906mbk.mjs +0 -20
  300. package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-mhczx7zp.mjs +0 -18
  301. package/runtime/webapp/dist/assets/App-HomcUet2.js +0 -63
  302. package/runtime/webapp/dist/assets/CalendarView-BD7GhA0i.js +0 -36
  303. package/runtime/webapp/dist/assets/CalendarView-DHi-mzjY.css +0 -1
  304. package/runtime/webapp/dist/assets/NewSessionWindow-BOCZ0mXT.css +0 -1
  305. package/runtime/webapp/dist/assets/NewSessionWindow-uzVK5LVS.js +0 -1
  306. package/runtime/webapp/dist/assets/TodoPage-Bn6j6kR6.js +0 -1
  307. package/runtime/webapp/dist/assets/channel-Cchxg6Fx.js +0 -1
  308. package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BGv4sK1I.js +0 -1
  309. package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BGv4sK1I.js +0 -1
  310. package/runtime/webapp/dist/assets/collaboration-acdqOxaY.js +0 -6
  311. package/runtime/webapp/dist/assets/composer-file-routing-BsSxfxUa.js +0 -6
  312. package/runtime/webapp/dist/assets/index-B_fTpc5K.css +0 -1
  313. package/runtime/webapp/dist/assets/new-session-window-B4BJYrds.css +0 -1
  314. package/runtime/webapp/dist/assets/new-session-window-fsYu53Ht.js +0 -188
  315. package/runtime/webapp/dist/assets/session-dashboard-BAYi5acZ.js +0 -1
  316. package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-Se3lznH6.js +0 -1
  317. package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-C-Zsmae7.js +0 -8
  318. /package/runtime/.next/static/{q4ez_w8bVMUW1e57Cd7GC → alt-ud1W2PlWW6FLlkBcB}/_buildManifest.js +0 -0
  319. /package/runtime/.next/static/{q4ez_w8bVMUW1e57Cd7GC → alt-ud1W2PlWW6FLlkBcB}/_ssgManifest.js +0 -0
@@ -1,63 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CalendarView-BD7GhA0i.js","./index-d8fS3JdV.js","./index-B_fTpc5K.css","./calendar-days-D1OJEOKr.js","./x-1GQMVfza.js","./chevron-right-DVhYkZeF.js","./locate-fixed-UXM91vCS.js","./check-BDiCDSY5.js","./pause-_h6c8qPD.js","./list-todo-F1W4yBLx.js","./chevron-down-DIt_NscV.js","./CalendarView-DHi-mzjY.css","./CollaborationDashboard-BZhWQXzn.js","./CollaborationTabBridge-Dxq4G1Uk.js","./CollaborationCreateDialog-CU1t0iYL.js","./types-CMhUwzwJ.js","./HostProjectPicker-BEfXuqxT.js","./file-types-CykGmGsd.js","./trash-2-Bbhd8-xd.js","./collaboration-acdqOxaY.js","./collaboration-DkVTQ-wS.css","./SessionDashboardBridge-BHVjvDHa.js","./arrow-right-B03zMFiC.js","./CollaborationDashboard-CCXC6JuQ.css","./CollaborationPage-BwRJN55v.js","./artifact-links-4m1A00GO.js","./composer-file-routing-BsSxfxUa.js","./loader-circle-DesEGpVH.js","./shield-check-DrxVJwVC.js","./history-C7WUwl_W.js","./image-plus-B2RK1ogI.js","./SessionDashboard-DuR9r_ZP.js","./session-dashboard-BAYi5acZ.js","./session-dashboard-D3n4eFut.css","./play-BdB0D0rZ.js","./SessionDashboard-CAYVDT8Z.css","./BrowserLivePanel-BZDtF0ne.js","./clipboard-BvwmdR4z.js","./rotate-ccw-BdZpOTYP.js","./zoom-out-BNKdrTFD.js","./external-link-Baeyco26.js","./AIHubView-DF0D5qd2.js","./new-session-window-fsYu53Ht.js","./RunningSessionsIcon-DJxTmxZn.js","./download-CuYS63Ny.js","./new-session-window-B4BJYrds.css","./send-DCVOqOap.js","./SettingsPanel-B-g919uV.js","./rotate-cw-D-zPMe4i.js","./pin-BcXr5230.js","./MCPServerList-BmsejJC9.js","./MemoryViewer-qZMdVrli.js","./SkillManager-nrWIOtEO.js","./AgentManager-Ccj6ZefC.js","./LSPServerList-DQRv04aP.js","./FileWorkspaceDrawer-D40WNAqC.js","./FilePreview-Oo8sZH0t.js","./FilePreview-B7Ab2X_E.css","./FileTree-qJTRdDPQ.js"])))=>i.map(i=>d[i]);
2
- import{c as _e,a9 as Yi,i as hn,r as s,a as Oe,j as e,A as gn,U as Xi,f as st,a8 as be,e as Ln,R as ks,aa as Dn,h as Lr,m as Lt,u as ve,ab as as,ac as Dr,G as Ji,ad as Qi,ae as Zi,af as eo,ag as to,ah as no,ai as so}from"./index-d8fS3JdV.js";import{t as ro,b as io,d as ms,S as Rt,e as oo,f as pr,g as ao,h as fr,i as co,s as lo,j as uo,k as po,l as fo,o as ho,m as cs,p as go,n as mo,q as ls,v as wo,w as hr,x as gr,c as bo,M as xo,y as yo,T as vo,z as ko,A as So,B as jo,D as Co,E as Io,F as Eo,G as Or,H as dn,I as un,J as Ao,K as To,L as No,N as Po,O as Ro,Q as ds,R as Lo,U as Pn,V as Kt,W as mr,X as Do,Y as Oo,u as _o,C as zo,Z as Mo,_ as Wo,$ as $o,a0 as Ho,a1 as Bo,a2 as Fo,a3 as qo,a4 as Vo,a5 as Uo}from"./new-session-window-fsYu53Ht.js";import{A as Ko,c as ht,U as Go}from"./collaboration-acdqOxaY.js";import{m as pn,c as _r,u as Yo,r as Xo,b as Jo,d as Qo,e as Zo,o as ea,D as ta,p as zr}from"./session-dashboard-BAYi5acZ.js";import{T as wr}from"./composer-file-routing-BsSxfxUa.js";import{X as gt}from"./x-1GQMVfza.js";import{S as On}from"./file-types-CykGmGsd.js";import{L as Xe}from"./loader-circle-DesEGpVH.js";import{L as na}from"./list-todo-F1W4yBLx.js";import{C as Ss}from"./calendar-days-D1OJEOKr.js";import{M as sa}from"./RunningSessionsIcon-DJxTmxZn.js";import{A as Mr,T as ra}from"./trash-2-Bbhd8-xd.js";import{R as js}from"./rotate-cw-D-zPMe4i.js";import{E as Wr}from"./external-link-Baeyco26.js";import{C as $r}from"./chevron-right-DVhYkZeF.js";import{P as ia}from"./pin-BcXr5230.js";import{C as oa}from"./CollaborationCreateDialog-CU1t0iYL.js";import{S as aa,c as ln,a as ca,r as br}from"./SessionDashboardBridge-BHVjvDHa.js";import{a as la,f as da}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{D as ua}from"./download-CuYS63Ny.js";import{C as pa}from"./check-BDiCDSY5.js";import{H as fa}from"./HostProjectPicker-BEfXuqxT.js";import{p as ha,r as ga,i as ma}from"./artifact-links-4m1A00GO.js";import{H as wa}from"./history-C7WUwl_W.js";/**
3
- * @license lucide-react v0.468.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const ba=_e("BellRing",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]);/**
8
- * @license lucide-react v0.468.0 - ISC
9
- *
10
- * This source code is licensed under the ISC license.
11
- * See the LICENSE file in the root directory of this source tree.
12
- */const xa=_e("Bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);/**
13
- * @license lucide-react v0.468.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */const ya=_e("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/**
18
- * @license lucide-react v0.468.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */const va=_e("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/**
23
- * @license lucide-react v0.468.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */const us=_e("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
28
- * @license lucide-react v0.468.0 - ISC
29
- *
30
- * This source code is licensed under the ISC license.
31
- * See the LICENSE file in the root directory of this source tree.
32
- */const ka=_e("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/**
33
- * @license lucide-react v0.468.0 - ISC
34
- *
35
- * This source code is licensed under the ISC license.
36
- * See the LICENSE file in the root directory of this source tree.
37
- */const xr=_e("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
38
- * @license lucide-react v0.468.0 - ISC
39
- *
40
- * This source code is licensed under the ISC license.
41
- * See the LICENSE file in the root directory of this source tree.
42
- */const Sa=_e("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
43
- * @license lucide-react v0.468.0 - ISC
44
- *
45
- * This source code is licensed under the ISC license.
46
- * See the LICENSE file in the root directory of this source tree.
47
- */const ja=_e("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
48
- * @license lucide-react v0.468.0 - ISC
49
- *
50
- * This source code is licensed under the ISC license.
51
- * See the LICENSE file in the root directory of this source tree.
52
- */const Ca=_e("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
53
- * @license lucide-react v0.468.0 - ISC
54
- *
55
- * This source code is licensed under the ISC license.
56
- * See the LICENSE file in the root directory of this source tree.
57
- */const Ia=_e("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
58
- * @license lucide-react v0.468.0 - ISC
59
- *
60
- * This source code is licensed under the ISC license.
61
- * See the LICENSE file in the root directory of this source tree.
62
- */const Ea=_e("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);function Aa(n,r){if(Object.is(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;if(n instanceof Map&&r instanceof Map){if(n.size!==r.size)return!1;for(const[i,c]of n)if(!Object.is(c,r.get(i)))return!1;return!0}if(n instanceof Set&&r instanceof Set){if(n.size!==r.size)return!1;for(const i of n)if(!r.has(i))return!1;return!0}const a=Object.keys(n);if(a.length!==Object.keys(r).length)return!1;for(const i of a)if(!Object.prototype.hasOwnProperty.call(r,i)||!Object.is(n[i],r[i]))return!1;return!0}const{useRef:Ta}=Yi;function Na(n){const r=Ta();return a=>{const i=n(a);return Aa(r.current,i)?r.current:r.current=i}}const ws="agentroam:task-pane-notification";function Pa(n){return!window.dispatchEvent(new CustomEvent(ws,{cancelable:!0,detail:{sessionId:n}}))}const Hr="agentroam.all-sessions.v1",Br=20;function bs(n){try{const r=n??(typeof window>"u"?void 0:window.localStorage),a=JSON.parse((r==null?void 0:r.getItem(Hr))??"null");return!qr(a)||a.version!==1||!Array.isArray(a.data)||!a.data.every(Ra)||typeof a.total!="number"||!Number.isSafeInteger(a.total)||a.total<a.data.length?null:{data:a.data.slice(0,Br),total:a.total}}catch{return null}}function Fr(n,r){try{const a=r??(typeof window>"u"?void 0:window.localStorage);a==null||a.setItem(Hr,JSON.stringify({version:1,data:n.data.slice(0,Br),total:n.total}))}catch{}}function qr(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Ra(n){return qr(n)&&typeof n.id=="string"&&hn(n.agentType)&&typeof n.title=="string"&&typeof n.cwd=="string"&&typeof n.updated=="string"&&typeof n.status=="string"&&["idle","running","completed","failed"].includes(n.status)&&typeof n.canResume=="boolean"&&(n.projectId===void 0||typeof n.projectId=="string")&&(n.readOnly===void 0||typeof n.readOnly=="boolean")&&(n.occupancy===void 0||typeof n.occupancy=="string"&&["available","owned-by-customer-agent","owned-externally"].includes(n.occupancy))}function La(n,r){const a=r.trim().toLocaleLowerCase();return n.filter(i=>`${i.title} ${i.cwd} ${i.agentType}`.toLocaleLowerCase().includes(a))}function Da({currentId:n,openIds:r,knownSessions:a=[],onChoose:i,onClose:c}){const[p,h]=s.useState(""),[m,g]=s.useState(()=>{var T;return pn(((T=bs())==null?void 0:T.data)??[],a)}),l=s.useRef(m),[u,y]=s.useState(null),[j,P]=s.useState(!0),[w,k]=s.useState(!1),[v,O]=s.useState(null),D=s.useRef(0),H=s.useRef(!0),Z=s.useRef(null),ee=s.useRef(),X=s.useRef(c);X.current=c;const M=async(T,R)=>{window.clearTimeout(ee.current);const B=++D.current;P(!0),O(null);try{const V=await ht({action:"sessionCatalog",query:T,cursor:R,limit:30,backgroundRefresh:!0});if(!H.current||B!==D.current)return;if(R&&V.nextCursor===R)throw new Error("会话分页已失效,请重新搜索");g(J=>R||V.refreshing?pn(J,V.data):V.data),l.current=!T&&!R&&!V.refreshing?V.data:pn(l.current,V.data),!T&&!R&&!V.refreshing&&Fr(V),y(V.nextCursor),k(V.refreshing===!0),V.refreshing&&(ee.current=window.setTimeout(()=>{M(T)},2e3))}catch(V){if(H.current&&B===D.current){k(!1);const J=V instanceof Error?V.message:"无法加载任务";O(/timeout|timed out/i.test(J)?"任务列表更新超时,请重试":J)}}finally{H.current&&B===D.current&&P(!1)}};return s.useEffect(()=>{var B;H.current=!0;const T=document.activeElement;(B=Z.current)==null||B.focus();const R=V=>{V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),X.current())};return document.addEventListener("keydown",R,!0),()=>{H.current=!1,D.current++,window.clearTimeout(ee.current),document.removeEventListener("keydown",R,!0),T!=null&&T.isConnected&&T.focus()}},[]),s.useEffect(()=>{D.current++,window.clearTimeout(ee.current),g(La(l.current,p)),y(null),P(!0),k(!1),O(null);const T=window.setTimeout(()=>{M(p.trim())},p?200:0);return()=>window.clearTimeout(T)},[p]),Oe.createPortal(e.jsx("div",{className:"task-picker-backdrop",onPointerDown:T=>{T.target===T.currentTarget&&c()},children:e.jsxs("section",{className:"task-picker",role:"dialog","aria-modal":"true","aria-label":"选择分屏任务",onKeyDown:T=>{if(T.key!=="Tab")return;const R=Array.from(T.currentTarget.querySelectorAll("button:not(:disabled), input")),B=R[0],V=R.at(-1);T.shiftKey&&document.activeElement===B?(T.preventDefault(),V==null||V.focus()):!T.shiftKey&&document.activeElement===V&&(T.preventDefault(),B==null||B.focus())},children:[e.jsxs("header",{children:[e.jsx("h2",{children:"选择任务"}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:c,"aria-label":"关闭任务选择",children:e.jsx(gt,{size:18})})]}),e.jsxs("label",{className:"task-picker-search",children:[e.jsx(On,{size:16,"aria-hidden":"true"}),e.jsx("input",{ref:Z,value:p,onChange:T=>h(T.target.value),placeholder:"搜索任务、目录或 Agent","aria-label":"搜索分屏任务"})]}),v&&e.jsxs("div",{className:"task-picker-error",role:"alert",children:[v,e.jsx("button",{type:"button",onClick:()=>void M(p.trim()),children:"重试"})]}),e.jsxs("div",{className:"task-picker-list","aria-busy":!m.length&&(j||w),children:[m.map(T=>e.jsxs("button",{type:"button",className:"task-picker-item",disabled:T.id===n,onClick:()=>i(T),children:[e.jsx(gn,{agentType:T.agentType,size:20}),e.jsxs("span",{children:[e.jsx("strong",{children:T.title||"未命名任务"}),e.jsxs("small",{children:[Ko[T.agentType]," · ",T.cwd||"未指定目录"]})]}),e.jsx("em",{children:T.id===n?"当前任务":r.has(T.id)?"已在分屏":T.status==="running"?"进行中":""})]},T.id)),!j&&!w&&!m.length&&!v&&e.jsx("p",{className:"task-picker-empty",children:"没有找到任务,试试其他关键词"}),(j||w)&&e.jsxs("p",{className:"task-picker-empty",role:"status",children:[e.jsx(Xe,{size:16,className:"task-split-spinner"}),m.length?"显示已有任务,正在后台更新…":"正在加载任务…"]}),u&&!j&&!w&&e.jsx("button",{className:"task-picker-more",type:"button",onClick:()=>void M(p.trim(),u),children:"加载更多任务"})]})]})}),document.body)}function Oa({node:n,renderPane:r,onResize:a,onSwap:i,maximizedPaneId:c}){const p=s.useRef(null),[h,m]=s.useState({width:0,height:0}),g=s.useRef(null),l=s.useRef(null),[u,y]=s.useState(null),j=ro(n,h.width,h.height);s.useLayoutEffect(()=>{const w=p.current;if(!w)return;const k=()=>m(O=>O.width===w.clientWidth&&O.height===w.clientHeight?O:{width:w.clientWidth,height:w.clientHeight});k();const v=new ResizeObserver(k);return v.observe(w),window.addEventListener("resize",k),()=>{v.disconnect(),window.removeEventListener("resize",k)}},[]);const P=(w,k)=>{const v=l.current;!v||v.pointerId!==w.pointerId||(l.current=null,y(null),w.currentTarget.hasPointerCapture(w.pointerId)&&w.currentTarget.releasePointerCapture(w.pointerId),k&&v.moved&&v.target&&(i==null||i(v.source,v.target)))};return e.jsxs("div",{ref:p,className:`task-split-layout${u?" is-reordering":""}`,onKeyDown:w=>{if(w.key!=="Escape"||!l.current)return;const k=l.current;l.current=null,y(null),w.stopPropagation(),k.element.hasPointerCapture(k.pointerId)&&k.element.releasePointerCapture(k.pointerId)},children:[j.panes.map(({paneId:w,rect:k})=>e.jsxs("div",{"data-task-slot":w,className:`task-split-pane${(u==null?void 0:u.source)===w?" is-moving":""}${(u==null?void 0:u.target)===w?" is-drop-target":""}`,style:c?{left:0,top:0,width:"100%",height:"100%",display:c===w?"flex":"none"}:{left:k.x,top:k.y,width:k.width,height:k.height},onPointerDownCapture:v=>{const O=v.target;v.button!==0||!i||c||j.panes.length<2||!O.closest(".chat-top-bar")||O.closest("button, input, textarea, select, a, [role='button'], [contenteditable='true']")||(v.preventDefault(),l.current={source:w,target:null,pointerId:v.pointerId,x:v.clientX,y:v.clientY,moved:!1,element:v.currentTarget},v.currentTarget.setPointerCapture(v.pointerId))},onPointerMove:v=>{var ee,X;const O=l.current,D=(ee=p.current)==null?void 0:ee.getBoundingClientRect();if(!O||O.pointerId!==v.pointerId||!D||!O.moved&&Math.hypot(v.clientX-O.x,v.clientY-O.y)<6)return;O.moved=!0;const H=v.clientX-D.left,Z=v.clientY-D.top;O.target=((X=j.panes.find(M=>M.paneId!==O.source&&H>=M.rect.x&&H<M.rect.x+M.rect.width&&Z>=M.rect.y&&Z<M.rect.y+M.rect.height))==null?void 0:X.paneId)??null,y(M=>(M==null?void 0:M.source)===O.source&&M.target===O.target?M:{source:O.source,target:O.target})},onPointerUp:v=>P(v,!0),onPointerCancel:v=>P(v,!1),onLostPointerCapture:v=>P(v,!1),children:[r(w),(u==null?void 0:u.target)===w&&e.jsx("span",{className:"task-pane-swap-hint",role:"status",children:"松开交换位置"})]},w)),j.separators.map(w=>e.jsx("div",{className:`task-split-separator task-split-separator--${w.axis}`,style:{left:w.rect.x,top:w.rect.y,width:w.rect.width,height:w.rect.height,display:c?"none":void 0},role:"separator",tabIndex:0,"aria-label":w.axis==="columns"?"调整左右任务宽度":"调整上下任务高度","aria-orientation":w.axis==="columns"?"vertical":"horizontal","aria-valuemin":10,"aria-valuemax":90,"aria-valuenow":Math.round(w.ratio*100),onPointerDown:k=>{if(k.button!==0)return;k.preventDefault();const v=w.axis==="columns";g.current={id:w.id,coordinate:v?k.clientX:k.clientY,ratio:w.ratio,extent:w.extent,columns:v},k.currentTarget.setPointerCapture(k.pointerId)},onPointerMove:k=>{const v=g.current;v&&a(v.id,io(v.ratio,(v.columns?k.clientX:k.clientY)-v.coordinate,v.extent))},onPointerUp:k=>{g.current=null,k.currentTarget.hasPointerCapture(k.pointerId)&&k.currentTarget.releasePointerCapture(k.pointerId)},onPointerCancel:()=>{g.current=null},onLostPointerCapture:()=>{g.current=null},onDoubleClick:()=>a(w.id,.5),onKeyDown:k=>{const v=w.axis==="columns"?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"];k.key===v[0]||k.key===v[1]?(k.preventDefault(),a(w.id,w.ratio+(k.key===v[0]?-.05:.05))):(k.key==="Home"||k.key==="End")&&(k.preventDefault(),a(w.id,k.key==="Home"?.1:.9))}},w.id))]})}const _a={"remote-desktop":sa,groups:Xi,dashboard:Sa,calendar:Ss};function yr({onTask:n,onDraft:r,onSurface:a}){return e.jsxs("div",{className:"task-pane-choices",children:[e.jsxs("button",{type:"button",onClick:n,children:[e.jsx(na,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"选择任务"})]}),e.jsxs("button",{type:"button",onClick:r,children:[e.jsx(Ea,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]}),Object.keys(ms).map(i=>{const c=_a[i];return e.jsxs("button",{type:"button",onClick:()=>a(i),children:[e.jsx(c,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:ms[i]})]},i)})]})}const za=s.lazy(()=>be(()=>import("./CalendarView-BD7GhA0i.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url)),Ma=s.lazy(()=>be(()=>import("./CollaborationDashboard-BZhWQXzn.js"),__vite__mapDeps([12,1,2,13,14,15,16,17,4,18,5,19,20,10,21,22,23]),import.meta.url)),Wa=s.lazy(()=>be(()=>import("./CollaborationPage-BwRJN55v.js"),__vite__mapDeps([24,1,2,25,26,27,4,21,28,19,20,15,13,29,30,7]),import.meta.url)),$a=s.lazy(()=>be(()=>import("./SessionDashboard-DuR9r_ZP.js"),__vite__mapDeps([31,1,2,21,32,19,20,33,4,22,10,28,34,8,35]),import.meta.url)),Ha=s.lazy(()=>be(()=>Promise.resolve().then(()=>wc),void 0,import.meta.url)),Ba=s.lazy(()=>be(()=>import("./BrowserLivePanel-BZDtF0ne.js"),__vite__mapDeps([36,1,2,27,10,37,38,4,39,40]),import.meta.url)),Fa=async(n,r)=>{var a;if(!((a=window.agentApi)!=null&&a.calendarOverview))throw new Error("当前服务不支持日历,请更新共享服务。");return window.agentApi.calendarOverview({from:n,to:r})};function qa({kind:n,cwd:r,onOpenSession:a,onNewSession:i,onChangeContent:c,onSelectSurface:p,onViewAgent:h,active:m=!0}){var u;const[g,l]=s.useState(null);return s.useEffect(()=>{l(null)},[n]),e.jsxs("div",{className:"task-pane-surface","data-pane-surface":n,children:[g&&e.jsxs("nav",{className:"task-pane-group-navigation","aria-label":"群聊导航",children:[e.jsxs("button",{type:"button",onClick:()=>l(null),children:[e.jsx(Mr,{size:14,"aria-hidden":"true"}),n==="dashboard"?"返回 Dashboard":"返回群聊列表"]}),e.jsx("span",{title:g.title,children:g.title})]}),e.jsx("div",{className:"task-pane-surface-body",children:e.jsx(s.Suspense,{fallback:e.jsx(Rt,{label:"正在打开面板"}),children:g?e.jsx(Wa,{groupId:g.id,initialDiscussionId:g.discussionId},`${g.id}:${g.discussionId??""}`):n==="calendar"?e.jsx(za,{loadOverview:Fa}):n==="remote-desktop"&&st()?e.jsx(Ba,{open:!0,active:m,embedded:!0,onClose:c}):n==="remote-desktop"?e.jsx("div",{className:"task-pane-remote-desktop",children:typeof window<"u"&&typeof((u=window.agentApi)==null?void 0:u.desktopLiveGetStatus)=="function"?e.jsx(Ha,{}):e.jsxs("div",{className:"task-pane-surface-unavailable",children:[e.jsx("p",{children:"当前客户端不支持远程桌面。"}),e.jsx("button",{type:"button",onClick:c,children:"选择其他内容"})]})}):n==="groups"?e.jsx(Ma,{cwd:r,onOpen:y=>l({id:y.id,title:y.name}),onViewDashboard:()=>p("dashboard")}):e.jsx($a,{onOpenGroup:y=>l({id:y.group.id,title:y.group.name,discussionId:y.discussionId}),onOpenSession:a,onNewSession:i,onViewAgent:h,onViewGroups:()=>p("groups")})})})]})}function Vr(n){try{const r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?r.toString():null}catch{return null}}function Va(n,r){const a="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox",i=Vr(n);return i&&r&&r!=="null"&&new URL(i).origin!==r?`${a} allow-same-origin`:a}function Ua({paneId:n,url:r,visible:a=!0,onFocus:i}){const c=Vr(r),p=Va(r,typeof window>"u"?void 0:window.location.origin),[h,m]=s.useState(0),[g,l]=s.useState("loading");s.useEffect(()=>{l("loading");const y=window.setTimeout(()=>l(j=>j==="loading"?"waiting":j),15e3);return()=>window.clearTimeout(y)},[r,h]);const u=()=>m(y=>y+1);return e.jsxs("div",{className:"task-pane-web-page task-pane-web-page--browser","aria-label":"网页","aria-hidden":!a,style:{visibility:a?void 0:"hidden"},onFocusCapture:i,onPointerDownCapture:i,children:[e.jsxs("div",{className:"task-pane-web-address",children:[e.jsx("span",{title:r,children:r}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"刷新网页",title:"刷新网页",disabled:!c,onClick:u,children:e.jsx(js,{size:14})}),c&&e.jsx("a",{className:"ui-icon-button",href:c,target:"_blank",rel:"noopener noreferrer","aria-label":"在新标签页打开",title:"在新标签页打开",children:e.jsx(Wr,{size:14})})]}),e.jsx("div",{className:"task-pane-web-embedding-note",children:"若网站限制内嵌或页面无法登录,请在新标签页打开。"}),e.jsxs("div",{className:"task-pane-web-content","aria-busy":!!(c&&g==="loading"),children:[c&&e.jsx("iframe",{className:"task-pane-web-frame",src:c,title:`网页:${r}`,sandbox:p,referrerPolicy:"no-referrer",onLoad:()=>l("loaded"),onError:()=>l("error")},`${n}:${r}:${h}`),(!c||g==="error")&&e.jsxs("div",{className:"task-pane-web-status",role:"alert",children:[e.jsx("span",{children:c?"网页未能载入,请重试或在新标签页打开。":"只能预览 HTTP 或 HTTPS 网页。"}),c&&e.jsx("button",{type:"button",onClick:u,children:"重试"})]}),c&&g==="loading"&&e.jsxs("div",{className:"task-pane-web-status task-pane-web-status--loading",role:"status",children:[e.jsx(Xe,{className:"task-split-spinner",size:20}),e.jsx("span",{children:"正在载入网页…"})]}),c&&g==="waiting"&&e.jsxs("div",{className:"task-pane-web-waiting",role:"status",children:[e.jsx("span",{children:"网页仍在载入,可继续等待或重试。"}),e.jsx("button",{type:"button",onClick:u,children:"重试"})]})]})]})}const Ka='dialog[open], [aria-modal="true"], [data-task-page-overlay], .collab-desktop-overlay, .appearance-panel, .header-action-menu-panel, .composer-workspace-picker-menu--portal, .composer-agent-picker-menu, .composer-model-menu';function Ga({paneId:n,url:r,visible:a=!0,onFocus:i}){const c=typeof window>"u"?void 0:window.agentApi,p=typeof(c==null?void 0:c.taskPageOpen)=="function",h=s.useRef(null),m=s.useRef(i);m.current=i;const[g,l]=s.useState("loading"),u=s.useRef({visible:a,state:g});u.current={visible:a,state:g};const y=s.useRef(""),j=s.useRef(()=>{}),P=s.useCallback(async()=>{if(!p||!c){l("error");return}l("loading");const w=await c.taskPageOpen(n,r).catch(()=>({ok:!1}));l(w.ok?"ready":"error")},[c,p,n,r]);return s.useEffect(()=>{if(!p||!c){l("error");return}const w=c.onHubEvent(k=>{var v;k.siteId===`task-pane-${n}`&&(k.type==="focused"&&((v=m.current)==null||v.call(m)),k.type==="loading"&&l("loading"),k.type==="loaded"&&l("ready"),k.type==="load-failed"&&l("error"))});return()=>{w(),c.taskPageClose(n)}},[c,p,n]),s.useEffect(()=>{P()},[P]),s.useEffect(()=>{if(!p||!c||!h.current)return;const w=h.current;let k=0;const v=()=>{const Z=w.getBoundingClientRect(),ee=Math.max(0,Z.left),X=Math.max(0,Z.top),M=Math.max(0,Math.min(window.innerWidth,Z.right)-ee),T=Math.max(0,Math.min(window.innerHeight,Z.bottom)-X),R=Array.from(document.querySelectorAll(Ka)).some(J=>{if(!J.getClientRects().length||getComputedStyle(J).visibility==="hidden")return!1;if(J.matches('dialog[open], [aria-modal="true"]'))return!0;const z=J.getBoundingClientRect();return z.left<ee+M&&z.right>ee&&z.top<X+T&&z.bottom>X}),B=u.current.visible&&u.current.state==="ready"&&w.getClientRects().length>0&&getComputedStyle(w).visibility==="visible"&&!w.closest('[inert], [aria-hidden="true"]')&&M>0&&T>0&&!R?{x:ee,y:X,width:M,height:T}:null,V=JSON.stringify(B);y.current!==V&&(y.current=V,c.taskPageSetBounds(n,B))},O=()=>{cancelAnimationFrame(k),k=requestAnimationFrame(v)};j.current=O;const D=new ResizeObserver(O);D.observe(w);const H=new MutationObserver(O);return H.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class","open","aria-hidden","hidden","inert"]}),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),O(),()=>{D.disconnect(),H.disconnect(),cancelAnimationFrame(k),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0),j.current=()=>{},y.current="",c.taskPageSetBounds(n,null)}},[c,p,n]),s.useEffect(()=>{j.current()},[g,a]),e.jsxs("div",{className:"task-pane-web-page","aria-label":"网页","aria-busy":g==="loading",children:[e.jsxs("div",{className:"task-pane-web-address",children:[e.jsx("span",{title:r,children:r}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"刷新网页",title:"刷新网页",onClick:()=>{if(g==="error"){P();return}c==null||c.taskPageReload(n)},children:e.jsx(js,{size:14})}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"在浏览器中打开",title:"在浏览器中打开",onClick:()=>{c==null||c.openExternal(r)},children:e.jsx(Wr,{size:14})})]}),e.jsx("div",{ref:h,className:"task-pane-web-content",children:g!=="ready"&&e.jsxs("div",{className:"task-pane-web-status",role:g==="error"?"alert":"status",children:[g==="loading"?e.jsx(Xe,{className:"task-split-spinner",size:20}):null,e.jsx("span",{children:g==="loading"?"正在打开网页…":p?"无法打开网页":"请重启桌面端以启用内嵌网页"}),g==="error"&&p&&e.jsx("button",{type:"button",onClick:()=>{P()},children:"重试"})]})})]})}function Ya(n){return st()?e.jsx(Ua,{...n}):e.jsx(Ga,{...n})}function Xa({enabled:n,children:r,onFocusSession:a,onNavigateSession:i,onSessionCreated:c,onOpenCalendar:p,onSplitChange:h}){var Dt,Ot,it,_t;const[m,g]=s.useState(!1),[l,u]=s.useState(null),[y,j]=s.useState(null),[P,w]=s.useState(null),[k,v]=s.useState(null),O=s.useRef(null),[D,H]=s.useState(!1),[Z,ee]=s.useState(null),[X,M]=s.useState({}),T=s.useRef(new Map),R=s.useRef(l);R.current=l;const B=s.useRef(m);B.current=m;const V=s.useRef(null),J=s.useRef(0),z=s.useRef(!1),q=s.useRef(new Map),Ie=s.useRef(0),me=s.useRef({onFocusSession:a,onNavigateSession:i,onSessionCreated:c});me.current={onFocusSession:a,onNavigateSession:i,onSessionCreated:c};const Pe=s.useRef(r.props.selectedSessionId),mt=s.useRef(r.props.focusComposerNonce),Ee=s.useRef(r.props);Ee.current=r.props,s.useEffect(()=>{h==null||h(n&&m)},[n,m,h]);const Je=f=>{if(!(!f||!V.current))try{localStorage.setItem(V.current,fo(f))}catch{}};s.useEffect(()=>{if(!n||!m||!l)return;const f=window.setTimeout(()=>Je(l),180);return()=>window.clearTimeout(f)},[n,m,l]),s.useEffect(()=>()=>{J.current++,q.current.clear()},[]),s.useEffect(()=>{n||(Je(R.current),J.current++,q.current.clear(),z.current=!1,B.current=!1,g(!1),H(!1),M({}),w(null),v(null),j(null))},[n]),s.useEffect(()=>{if(!k)return;const f=S=>{if(S.key==="Escape"){S.preventDefault(),v(null);return}if(S.key!=="Tab")return;const N=Array.from(document.querySelectorAll(".task-content-picker button:not(:disabled)")),I=N[0],E=N[N.length-1];S.shiftKey&&document.activeElement===I?(S.preventDefault(),E==null||E.focus()):!S.shiftKey&&document.activeElement===E&&(S.preventDefault(),I==null||I.focus())};return document.addEventListener("keydown",f),()=>{var S;document.removeEventListener("keydown",f),(S=O.current)!=null&&S.isConnected&&O.current.focus({preventScroll:!0})}},[k]),s.useEffect(()=>{if(!n||!m)return;const f=S=>{var E,F;if(S.defaultPrevented||z.current||!B.current||!R.current||!st()&&!((E=window.agentApi)!=null&&E.taskPageOpen))return;const N=(F=S.detail)==null?void 0:F.url;if(typeof N!="string")return;const I=ho(R.current,N);I&&(S.preventDefault(),q.current.delete(I.activePaneId),T.current.delete(I.activePaneId),M(G=>({...G,[I.activePaneId]:!1})),R.current=I,u(I),j(null))};return window.addEventListener(wr,f),()=>window.removeEventListener(wr,f)},[n,m]);const $=s.useCallback(f=>{var N,I;const S=(N=R.current)==null?void 0:N.panes.find(E=>E.id===f);!S||((I=R.current)==null?void 0:I.activePaneId)===f||(u(E=>E&&{...E,activePaneId:f}),j(E=>E?f:null),S.session&&me.current.onFocusSession(S.session))},[]),pe=(f,S,N)=>{const I=R.current;if(!I||!I.panes.some(F=>F.id===f))return;const E=I.panes.find(F=>{var G;return((G=F.session)==null?void 0:G.id)===S.id&&F.id!==f});if(E){$(E.id);return}u(F=>F&&So(F,f,S,N)),I.activePaneId===f&&me.current.onFocusSession(S)},oe=async(f,S,N)=>{if(!B.current||z.current)return;const I=++Ie.current;if(q.current.set(f,I),N){M(E=>({...E,[f]:!1})),pe(f,N);return}M(E=>({...E,[f]:!0})),ee(null);try{const E=await cs(S);if(q.current.get(f)!==I||!B.current||!E.session)return;pe(f,E.session,E.initialHistory)}catch(E){B.current&&q.current.get(f)===I&&ee(E instanceof Error?E.message:"无法更换任务")}finally{q.current.get(f)===I&&M(E=>({...E,[f]:!1}))}};s.useEffect(()=>{if(!n||!m)return;const f=S=>{var G;const N=(G=S.detail)==null?void 0:G.sessionId,I=R.current;if(S.defaultPrevented||!N||!I||z.current||!B.current)return;S.preventDefault();const E=I.activePaneId,F=++Ie.current;q.current.set(E,F),M(U=>({...U,[E]:!0})),ee(null),cs({id:N}).then(U=>{if(!B.current||q.current.get(E)!==F||!U.session||!R.current)return;const we=go(R.current,E,U.session,U.initialHistory);R.current=we,u(we),we.activePaneId===E&&(Pe.current=U.session.id,me.current.onFocusSession(U.session))}).catch(U=>{B.current&&q.current.get(E)===F&&ee(U instanceof Error?U.message:"无法打开通知会话")}).finally(()=>{q.current.get(E)===F&&M(U=>({...U,[E]:!1}))})};return window.addEventListener(ws,f),()=>window.removeEventListener(ws,f)},[n,m]);const Ae=async(f=!1)=>{var N,I,E,F;const S=++J.current;z.current=!0,w(null),v(null),q.current.clear(),M({}),B.current=!0,g(!0),H(!0),ee(null),j(null),Pe.current=Ee.current.selectedSessionId;try{if(st())V.current=`agentroam:web-task-split:v1:${window.location.origin}${window.location.pathname}`;else{const te=await window.sharedServiceApi.status(),xe=((N=te.selected)==null?void 0:N.dataDir)??((I=te.selected)==null?void 0:I.instanceId);if(!xe)throw new Error("请先连接 AgentRoam 服务");V.current=`agentroam:desktop-task-split:v1:${xe}`}let G=f?null:R.current;if(!f&&!G)try{G=mo(JSON.parse(localStorage.getItem(V.current)||"null"))}catch{}if(!G){const te=await ht({action:"dashboard"});if(te.discoveryError)throw new Error(te.discoveryError);const xe=[...new Map(te.agents.flatMap(fe=>fe.sessions).filter(fe=>fe.status!=="completed"&&fe.status!=="failed").map(fe=>[fe.id,ls(fe)])).values()],ye=Ee.current.sessionSummary;!xe.length&&ye&&xe.push(ye);const ot=xe.map(fe=>({id:crypto.randomUUID(),session:fe}));for(;ot.length<2;)ot.push({id:crypto.randomUUID(),session:null});G={panes:ot,layout:fr(ot.map(fe=>fe.id)),activePaneId:((E=ot.find(fe=>{var Yt;return((Yt=fe.session)==null?void 0:Yt.id)===(ye==null?void 0:ye.id)}))==null?void 0:E.id)??ot[0].id}}const U=await Promise.allSettled(G.panes.map(async te=>te.session?{...te,...await cs(te.session)}:te));if(S!==J.current||!B.current)return;let we=0;const L=U.map((te,xe)=>te.status==="fulfilled"?te.value:(we++,G.panes[xe])),ie={...G,panes:L};R.current=ie,u(ie);const he=(F=L.find(te=>te.id===ie.activePaneId))==null?void 0:F.session;he&&me.current.onFocusSession(he),we&&ee(`${we} 个任务暂未加载完成,可在对应格重试或更换任务`)}catch(G){S===J.current&&B.current&&ee(G instanceof Error?G.message:"无法打开任务分屏")}finally{S===J.current&&B.current&&(z.current=!1,H(!1))}},K=()=>{var S,N;Je(R.current),J.current++,z.current=!1,q.current.clear(),M({}),H(!1),B.current=!1,g(!1),w(null),v(null),j(null);const f=(N=(S=R.current)==null?void 0:S.panes.find(I=>{var E;return I.id===((E=R.current)==null?void 0:E.activePaneId)}))==null?void 0:N.session;f&&me.current.onNavigateSession(f)};if(s.useEffect(()=>{if(!n||!m||D)return;const f=r.props.selectedSessionId,S=r.props.sessionSummary;if(!f||f===Pe.current||(S==null?void 0:S.id)!==f||!R.current)return;Pe.current=f;const N=R.current.panes.find(I=>{var E;return((E=I.session)==null?void 0:E.id)===f});N?$(N.id):oe(R.current.activePaneId,S,S)},[n,m,D,r.props.selectedSessionId,r.props.sessionSummary,$]),s.useEffect(()=>{mt.current!==r.props.focusComposerNonce&&(mt.current=r.props.focusComposerNonce,m&&(Je(R.current),J.current++,q.current.clear(),M({}),B.current=!1,g(!1),w(null),v(null)))},[r.props.focusComposerNonce,m]),!n)return r;const Qe=async f=>{const S=P;if(w(null),!m||S==="single"){me.current.onNavigateSession(ls(f));return}const N=R.current;if(!N||!S)return;const I=N.panes.find(E=>{var F;return((F=E.session)==null?void 0:F.id)===f.id});if(I){$(I.id);return}if(S==="add"){const E=wo(N,ls(f),crypto.randomUUID());R.current=E.state,u(E.state),j(null),await oe(E.paneId,f)}else await oe(S,f)},Te=f=>{var G,U,we;const S=R.current;if(!S)return;if((U=(G=S.panes.find(L=>L.id===f))==null?void 0:G.notificationHistory)!=null&&U.length){q.current.delete(f),M(he=>({...he,[f]:!1}));const L=Co(S,f);R.current=L,u(L);const ie=L.panes.find(he=>he.id===f);S.activePaneId===f&&(ie!=null&&ie.session)&&(Pe.current=ie.session.id,me.current.onFocusSession(ie.session));return}if(S.panes.length===1){K();return}q.current.delete(f),T.current.delete(f),v(L=>L===f?null:L);const N=S.panes.filter(L=>L.id!==f),I=Io(S.layout,f),E={...S,panes:N,layout:I,activePaneId:S.activePaneId===f?N[0].id:S.activePaneId};R.current=E,u(E),j(null);const F=(we=N.find(L=>L.id===E.activePaneId))==null?void 0:we.session;F&&me.current.onFocusSession(F)},ne=r.props,wt=st(),rt=wt&&window.parent!==window,ke=l==null?void 0:l.panes.find(f=>f.id===l.activePaneId),Gt=((Dt=ke==null?void 0:ke.session)==null?void 0:Dt.agentType)??((Ot=ke==null?void 0:ke.draft)==null?void 0:Ot.agentType),Ge=(f,S)=>u(N=>N&&jo(N,f,S)),ze=(f,S)=>{var E;if(z.current)return;if(st()&&S&&"surface"in S&&S.surface==="remote-desktop"){const F=(E=R.current)==null?void 0:E.panes.find(G=>G.id!==f&&G.surface==="remote-desktop");if(F){v(null),$(F.id);return}}q.current.delete(f),T.current.delete(f),M(F=>({...F,[f]:!1}));const N=R.current;if(!N)return;const I=hr(N,f,S);R.current=I,u(I),v(null)},je=(f,S)=>{if(z.current)return;const N=R.current,I=N==null?void 0:N.panes.find(G=>G.surface===f);if(I){$(I.id);return}const E=N==null?void 0:N.panes.find(G=>G.id===N.activePaneId),F=E&&gr(E)?E:N==null?void 0:N.panes.find(gr);if(F)ze(F.id,{surface:f});else if(S)S();else if(N){const G=pr(N,crypto.randomUUID()),U=hr(G,G.activePaneId,{surface:f});R.current=U,u(U),j(null)}},Me=f=>{var N,I,E;if(z.current)return;const S=Ee.current;ze(f,null),Ge(f,{agentType:((N=S.sessionSummary)==null?void 0:N.agentType)??S.activeAgentType??"customer-agent",projectId:((I=S.sessionSummary)==null?void 0:I.projectId)??S.selectedProjectId??null,cwd:((E=S.sessionSummary)==null?void 0:E.cwd)??S.workspacePath??"",workspaceSource:S.workspaceSource})},bt=f=>{var U,we;const S=l==null?void 0:l.panes.find(L=>L.id===f);if(!S)return null;let N=T.current.get(f);N||(N=bo(),T.current.set(f,N));const I=S.session,E=S.draft,F=S.surface?ms[S.surface]:S.webUrl?"网页":(I==null?void 0:I.title)||(E?"新建会话":"空面板"),G=e.jsxs("div",{className:"task-pane-controls",children:[e.jsx("button",{type:"button",className:"ui-icon-button",onClick:L=>{O.current=L.currentTarget,v(f)},title:"切换面板内容","aria-label":"切换面板内容",children:e.jsx(xr,{size:15})}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>j(L=>L===f?null:f),title:y===f?"恢复分屏":"放大此格","aria-label":y===f?"恢复分屏":"放大此格",children:y===f?e.jsx(xo,{size:15}):e.jsx(yo,{size:15})}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>Te(f),title:(U=S.notificationHistory)!=null&&U.length?"关闭通知会话,返回之前的会话":"移除此格(任务继续运行)","aria-label":(we=S.notificationHistory)!=null&&we.length?"关闭通知会话,返回之前的会话":"移除此格",children:e.jsx(gt,{size:16})})]});return e.jsxs("section",{className:`task-pane${(l==null?void 0:l.activePaneId)===f?" is-active":""}${y===f?" is-maximized":""}`,"data-task-pane":f,"data-task-session":(I==null?void 0:I.id)??"","data-pane-content":S.surface??(S.webUrl?"web":I||E?"task":"empty"),"aria-label":F,onPointerDownCapture:()=>$(f),onFocusCapture:()=>$(f),children:[S.surface||S.webUrl?e.jsxs("div",{className:"task-pane-feature",children:[e.jsxs("header",{className:"chat-top-bar task-pane-feature-header",children:[e.jsx("strong",{children:F}),G]}),S.surface?e.jsx(qa,{kind:S.surface,cwd:ne.workspacePath??void 0,active:!y||y===f,onOpenSession:L=>{oe(f,L)},onNewSession:()=>Me(f),onChangeContent:()=>v(f),onViewAgent:()=>w(f),onSelectSurface:L=>ze(f,{surface:L})}):e.jsx(Ya,{paneId:f,url:S.webUrl,visible:!y||y===f,onFocus:()=>$(f)})]}):I||E?e.jsx(vo,{draft:E,onDraftChange:L=>Ge(f,L),children:s.cloneElement(r,{agentStore:N,desktopTaskPane:!0,desktopTaskOwnsSession:L=>{var he;if(!B.current)return!1;const ie=((he=R.current)==null?void 0:he.panes)??[];return ie.some(te=>{var xe;return te.id===f&&((xe=te.session)==null?void 0:xe.id)===L})||!ie.some(te=>{var xe;return((xe=te.session)==null?void 0:xe.id)===L})},activeAgentType:(I==null?void 0:I.agentType)??E.agentType,selectedProjectId:(I==null?void 0:I.projectId)??(E==null?void 0:E.projectId)??null,selectedSessionId:(I==null?void 0:I.id)??null,sessionSummary:I??void 0,sessionTitle:(I==null?void 0:I.title)??"新建会话",workspacePath:(I==null?void 0:I.cwd)??E.cwd,workspaceSource:void 0,initialSessionHistory:ko(S,ne.initialSessionHistory),onToggleSidebar:void 0,onReplaceTask:()=>w(f),paneControls:G,headerAppActions:void 0,onOpenTaskSplit:void 0,onSelectAgent:void 0,onSelectWorkspace:void 0,onPickWorkspaceFolder:void 0,voiceCommand:(l==null?void 0:l.activePaneId)===f?ne.voiceCommand:null,focusComposerNonce:E?1:void 0,onSelectSession:(L,ie)=>{oe(f,{id:L},ie)},onSessionCreated:(L,ie)=>{var he,te;oe(f,{id:L},ie),ie&&((te=(he=me.current).onSessionCreated)==null||te.call(he,ie))},onParallelSessionSelected:L=>{oe(f,L,L)}})}):e.jsxs("div",{className:"task-pane-empty",children:[e.jsx("div",{className:"task-pane-empty-controls",children:G}),e.jsx(us,{size:24,"aria-hidden":"true"}),e.jsx("p",{children:"选择这一列要展示的内容"}),e.jsx(yr,{onTask:()=>w(f),onDraft:()=>Me(f),onSurface:L=>ze(f,{surface:L})}),e.jsx("small",{children:"消息中的网页链接也会在空面板中打开"})]}),X[f]&&e.jsxs("div",{className:"task-pane-loading",role:"status",children:[e.jsx(Xe,{size:20,className:"task-split-spinner"}),"正在更换任务…"]})]},f)};return e.jsxs(e.Fragment,{children:[m?e.jsxs("div",{className:"desktop-task-workspace",children:[e.jsxs("header",{className:"task-workspace-toolbar",children:[ne.onToggleSidebar&&e.jsx("button",{className:"ui-icon-button",type:"button",onClick:ne.onToggleSidebar,"aria-label":"切换任务侧栏",children:e.jsx(oo,{size:17})}),e.jsxs("span",{className:"task-workspace-label",children:[e.jsx(us,{size:16}),"任务分屏",l?e.jsx("small",{children:l.panes.length}):null]}),e.jsxs("div",{className:"task-workspace-tools",children:[p&&e.jsxs("button",{type:"button",onClick:()=>je("calendar",p),title:"日历与待办","aria-label":"打开日历与待办",children:[e.jsx(Ss,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"日历 / 待办"})]}),e.jsxs("button",{type:"button",onClick:()=>w("add"),disabled:D||!l,title:"添加任务","aria-label":"添加分屏任务",children:[e.jsx(Ln,{size:16}),e.jsx("span",{children:"添加任务"})]}),e.jsxs("button",{type:"button",onClick:()=>{j(null),u(f=>f&&pr(f,crypto.randomUUID()))},disabled:D||!l,title:"在最右侧新增一列,保留现有布局比例","aria-label":"新增一列",children:[e.jsx(us,{size:16}),e.jsx("span",{children:"新增一列"})]}),e.jsxs("button",{type:"button",onClick:()=>{j(null),u(f=>f&&ao(f,()=>crypto.randomUUID()))},disabled:D||!l,title:"四列布局,空位会保留给新任务","aria-label":"四列布局","aria-pressed":(l==null?void 0:l.layoutMode)==="four-columns",children:[e.jsx(ka,{size:16}),e.jsx("span",{children:"四列"})]}),e.jsx("button",{type:"button",onClick:()=>{j(null),u(f=>f&&{...f,layoutMode:void 0,layout:fr(f.panes.map(S=>S.id))})},disabled:D||!l,title:"重新等分","aria-label":"重新等分任务",children:e.jsx(xr,{size:16})}),e.jsx("button",{type:"button",onClick:()=>{Ae(!0)},disabled:D,title:"重新载入进行中任务","aria-label":"重新载入进行中任务",children:e.jsx(ks,{size:16,className:D?"task-split-spinner":void 0})}),e.jsxs("button",{type:"button",onClick:K,title:"退出任务分屏","aria-label":"退出任务分屏",children:[e.jsx(Ca,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"退出分屏"})]})]}),ne.onOpenSettings&&ne.onHideToBackground&&ne.onToggleAppearance&&e.jsx(co,{appActions:ne.headerAppActions,appearanceOpen:!!ne.appearanceOpen,settingsOpen:!!ne.settingsOpen,showSettings:!wt||Gt==="customer-agent",onHideToBackground:ne.onHideToBackground,onToggleAppearance:ne.onToggleAppearance,onOpenSettings:ne.onOpenSettings,onOpenSessionDashboard:rt?void 0:()=>je("dashboard",ne.onOpenSessionDashboard),onOpenCollaborationDashboard:rt?void 0:()=>je("groups",ne.onOpenCollaborationDashboard),onOpenDesktopLive:rt?void 0:()=>je("remote-desktop",ne.onOpenDesktopLive),desktopLiveOpen:ne.desktopLiveOpen,onToggleFiles:ne.onToggleFiles,filesOpen:ne.fileDrawerOpen,onOpenHub:ne.onOpenHub})]}),Z&&e.jsxs("div",{className:"task-workspace-error",role:"alert",children:[e.jsx("span",{children:Z}),e.jsx("button",{type:"button",onClick:()=>{Ae()},children:"重试"})]}),e.jsxs("div",{className:"task-workspace-layout",children:[D&&!l?e.jsxs("div",{className:"task-workspace-loading",role:"status",children:[e.jsx(Xe,{className:"task-split-spinner",size:22}),"正在载入任务分屏…"]}):l?e.jsx("div",{className:`task-workspace-tree${y?" has-maximized-task":""}`,"data-maximized-pane":y??void 0,ref:f=>{f&&(f.inert=D)},"aria-hidden":D||void 0,children:e.jsx(Oa,{node:l.layout,renderPane:bt,maximizedPaneId:y,onResize:(f,S)=>u(N=>N&&{...N,layout:po(N.layout,f,S)}),onSwap:(f,S)=>u(N=>{if(!N)return N;const I=lo(N.layout,f,S);if(I===N.layout)return N;const E=new Map(N.panes.map(F=>[F.id,F]));return{...N,layout:I,panes:uo(I).map(F=>E.get(F))}})})}):null,D&&l&&e.jsxs("div",{className:"task-workspace-loading task-workspace-loading--overlay",role:"status",children:[e.jsx(Xe,{className:"task-split-spinner",size:22}),"正在重新载入…"]})]})]}):s.cloneElement(r,{onOpenTaskSplit:()=>{Ae()},onReplaceTask:()=>w("single")}),P&&e.jsx(Da,{currentId:P==="single"?ne.selectedSessionId??void 0:(_t=(it=l==null?void 0:l.panes.find(f=>f.id===P))==null?void 0:it.session)==null?void 0:_t.id,openIds:new Set(m?(l==null?void 0:l.panes.flatMap(f=>f.session?[f.session.id]:[]))??[]:[]),knownSessions:[...ne.sessionSummary?[ne.sessionSummary]:[],...(l==null?void 0:l.panes.flatMap(f=>f.session?[f.session]:[]))??[]].map(_r),onChoose:f=>{Qe(f)},onClose:()=>w(null)}),m&&k&&Oe.createPortal(e.jsx("div",{className:"task-picker-backdrop",onClick:f=>{f.target===f.currentTarget&&v(null)},children:e.jsxs("section",{className:"task-picker task-content-picker",role:"dialog","aria-modal":"true","aria-label":"选择面板内容",onKeyDown:f=>{f.key==="Escape"&&v(null)},children:[e.jsxs("header",{children:[e.jsx("h2",{children:"选择面板内容"}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"关闭内容选择",autoFocus:!0,onClick:()=>v(null),children:e.jsx(gt,{size:18})})]}),e.jsx(yr,{onTask:()=>{w(k),v(null)},onDraft:()=>Me(k),onSurface:f=>ze(k,{surface:f})}),e.jsx("button",{type:"button",className:"task-pane-clear",onClick:()=>ze(k,null),children:"清空此面板"})]})}),document.body)]})}function fn({session:n,deleteLabel:r="删除会话",onSelect:a,onPin:i,onDelete:c}){var p,h;return e.jsxs("div",{className:`sidebar-row sidebar-session-row${n.child?" sidebar-session-row--child":""}${n.active?" sidebar-row-active":""}`,children:[e.jsxs("button",{type:"button",className:"sidebar-session-button",onClick:a,"aria-pressed":n.active,"aria-expanded":n.hasChildren?!!n.expanded:void 0,title:[n.title,n.workspacePath].filter(Boolean).join(`
63
- `),children:[e.jsx("span",{className:`sidebar-status-dot is-${n.visualState}`,title:n.statusLabel,"aria-label":n.statusLabel}),e.jsx("span",{className:"sidebar-session-title",children:n.title}),n.agentType&&e.jsx("span",{className:"sidebar-session-agent",role:"img","aria-label":Dn[n.agentType],title:Dn[n.agentType],children:e.jsx(gn,{agentType:n.agentType,size:18})}),((p=n.compatibility)==null?void 0:p.status)==="checking"&&e.jsx("span",{className:"sidebar-session-compatibility",title:`Codex ${n.compatibility.producerVersion??"未知版本"} 会话兼容性待验证,打开会话时检查`,"aria-label":"会话兼容性待验证,打开会话时检查",children:e.jsx(Eo,{size:13,"aria-hidden":"true"})}),((h=n.compatibility)==null?void 0:h.status)==="incompatible"&&e.jsx("span",{className:"sidebar-session-compatibility",title:n.compatibility.reason??"Codex 版本不兼容","aria-label":"Codex 版本不兼容",children:e.jsx(Or,{size:13,"aria-hidden":"true"})}),n.occupiedExternally&&e.jsx("span",{className:"sidebar-session-lock",title:"原客户端正在使用,只读","aria-label":"原客户端正在使用,只读",children:e.jsx(ja,{size:13,"aria-hidden":"true"})}),n.hasChildren&&e.jsx($r,{size:13,className:`sidebar-session-disclosure${n.expanded?" is-expanded":""}`,"aria-hidden":"true"})]}),i&&!n.child&&e.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),i()},title:n.pinned?"取消置顶":"置顶会话","aria-label":`${n.pinned?"取消置顶":"置顶会话"}:${n.title}`,"aria-pressed":!!n.pinned,className:`sidebar-session-pin sidebar-row-action ui-icon-button ui-icon-button--small${n.pinned?" sidebar-row-action--accent":""}`,children:e.jsx(ia,{size:14,"aria-hidden":"true"})}),n.canDelete&&c&&e.jsx("button",{type:"button",onClick:m=>{m.stopPropagation();const g=m.currentTarget.getBoundingClientRect();c({top:g.top,left:g.left,width:g.width,height:g.height})},title:r,"aria-label":`${r}:${n.title}`,className:"sidebar-session-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",children:e.jsx(ra,{size:14,"aria-hidden":"true"})})]})}function Ur({loading:n,error:r,onRefresh:a,subject:i="目录"}){const c=n?`正在加载${i}`:r?`${i}加载失败,点击重试`:`刷新${i}`;return e.jsxs("button",{type:"button",disabled:n,onClick:a,title:r&&!n?`${c}:${r}`:c,"aria-label":c,"aria-busy":n,className:"ui-icon-button sidebar-directory-refresh",children:[e.jsx(ks,{size:17,className:n?"animate-spin":void 0,"aria-hidden":"true"}),r&&!n&&e.jsx(Or,{size:10,className:"sidebar-directory-refresh-error","aria-hidden":"true"})]})}function Ja(n){const r=Lr(),a=Yo(),[i]=s.useState(()=>bs()),[c,p]=s.useState((i==null?void 0:i.data)??[]),[h,m]=s.useState((i==null?void 0:i.total)??0),[g,l]=s.useState(i!==null),[u,y]=s.useState(""),[j,P]=s.useState(""),[w,k]=s.useState(null),[v,O]=s.useState(!1),[D,H]=s.useState(!1),[Z,ee]=s.useState(null),X=s.useRef(null),M=s.useRef(""),T=s.useRef(`${n.revision}:${n.runningSessionId}`),R=s.useRef({query:"",rows:(i==null?void 0:i.data)??[],cursor:null}),B=s.useRef(null),V=s.useRef(null),J=s.useRef(new Map),z=s.useRef(null);n.pendingSession&&n.pendingSession.id!==z.current&&(z.current=n.pendingSession.id,J.current.set(n.pendingSession.id,_r(n.pendingSession)),J.current.size>20&&J.current.delete(J.current.keys().next().value)),s.useEffect(()=>{const $=window.setTimeout(()=>P(u.trim()),250);return()=>window.clearTimeout($)},[u]);const q=s.useCallback(async $=>{var Ae;if(!Lt()||!$&&(X.current||!R.current.cursor)||X.current&&!X.current.signal.aborted&&M.current===j)return;$&&((Ae=X.current)==null||Ae.abort());const pe=new AbortController;X.current=pe,M.current=j;const oe=R.current;if(O(!0),ee(null),$&&oe.query!==j){const K=j?null:bs();R.current={query:j,rows:(K==null?void 0:K.data)??[],cursor:null},p((K==null?void 0:K.data)??[]),m((K==null?void 0:K.total)??0),k(null),l(K!==null)}try{let K;if($){const Te=B.current;if((Te==null?void 0:Te.query)===j)K=await Te.promise;else{const ne=ht({action:"sessionCatalog",query:j,limit:20,backgroundRefresh:!0}),wt={query:j,promise:ne};B.current=wt;try{K=await ne}finally{B.current===wt&&(B.current=null)}}if(pe.signal.aborted)return}else K=await Xo(Te=>ht({action:"sessionCatalog",query:j,limit:20,cursor:Te}),pe.signal,oe.cursor??void 0);for(const Te of K.data)J.current.delete(Te.id);const Qe=$&&oe.query===j?K.refreshing?{rows:pn(oe.rows,K.data),cursor:oe.cursor??K.nextCursor}:Jo(oe,K):{rows:$?K.data:pn(oe.rows,K.data),cursor:K.nextCursor};R.current={query:j,...Qe},p(Qe.rows),m(K.total),k(Qe.cursor),l(!1),$&&H(K.refreshing===!0),$&&!j&&!K.refreshing&&Fr(K),$&&oe.query!==j&&V.current&&(V.current.scrollTop=0)}catch(K){pe.signal.aborted||(H(!1),ee(K instanceof Error?K.message:"会话加载失败"))}finally{X.current===pe&&(X.current=null,O(!1))}},[j]);s.useEffect(()=>{if(!r)return;const $=`${n.revision}:${n.runningSessionId}`,pe=T.current!==$;T.current=$,(pe||R.current.query!==j||!X.current)&&q(!0);const oe=()=>{Lt()&&!X.current&&q(!0)},Ae=window.setInterval(oe,15e3);return window.addEventListener("focus",oe),()=>{var K;(K=X.current)==null||K.abort(),B.current=null,window.clearInterval(Ae),window.removeEventListener("focus",oe)}},[r,q,j,n.revision,n.runningSessionId]),s.useEffect(()=>{if(!r||!D)return;const $=window.setInterval(()=>{q(!0)},2e3);return()=>window.clearInterval($)},[r,D,q]);const Ie=[...n.needsInput,...n.runningSessionId?[n.runningSessionId]:[]],me=Qo(Zo(c,[...J.current.values()],j),a,j),Pe=ea(me,n.pinnedIds,Ie),mt=u.trim().toLocaleLowerCase(),Ee=Pe,Je=s.useMemo(()=>new Set(n.pinnedIds),[n.pinnedIds]);return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"sidebar-search-field all-sessions-search",children:[e.jsx(On,{size:15,"aria-hidden":"true"}),e.jsx("input",{"aria-label":"搜索所有 Agent 的会话",placeholder:"搜索会话或目录",value:u,onChange:$=>{y($.target.value)}})]}),e.jsxs("div",{className:"sidebar-project-toolbar",children:[e.jsxs("div",{className:"sidebar-project-heading",children:[e.jsx("span",{className:"sidebar-project-title",children:"所有会话"}),e.jsx("span",{className:"sidebar-project-count",children:Math.max(h,me.length)})]}),e.jsxs("div",{className:"sidebar-project-actions",children:[e.jsx("span",{className:"all-sessions-sort-label",children:"进行中优先"}),e.jsx(Ur,{loading:v,error:Z,subject:"所有会话",onRefresh:()=>void q(!0)})]})]}),e.jsxs("div",{ref:V,className:"app-sidebar-scroll all-sessions-list","aria-label":"所有 Agent 会话","aria-busy":(v||D)&&!g&&!Ee.length,onScroll:$=>{const pe=$.currentTarget;pe.scrollTop>0&&pe.scrollHeight-pe.scrollTop-pe.clientHeight<120&&q(!1)},children:[Z&&e.jsxs("div",{role:"alert",className:"sidebar-load-error",children:[e.jsx("span",{children:Z}),e.jsx("button",{onClick:()=>void q(!0),children:"重试"})]}),(v||D)&&!Ee.length&&!g&&e.jsx("p",{className:"all-sessions-empty",role:"status",children:"正在加载所有会话…"}),(!v||g)&&!D&&!Z&&!Ee.length&&e.jsx("p",{className:"all-sessions-empty",children:mt?"没有匹配的会话":"暂无会话,开始一个新任务吧"}),Ee.map($=>{const pe=n.needsInput.includes($.id)?"needs-input":n.runningSessionId===$.id?"running":$.status==="failed"?"error":$.status==="completed"?"idle":$.status,oe=un(pe);return e.jsx(fn,{session:{id:$.id,title:$.title,agentType:$.agentType,workspacePath:$.cwd,visualState:oe,statusLabel:dn[oe],active:n.selectedSessionId===$.id,pinned:Je.has($.id),occupiedExternally:$.agentType!=="codex"&&$.occupancy==="owned-externally",canDelete:pe!=="running"&&pe!=="needs-input"},onSelect:()=>n.onSelect($),onPin:()=>n.onPin($.id),onDelete:Ae=>n.onDelete($,Ae)},$.id)}),w&&e.jsx("button",{className:"all-sessions-more",disabled:v,onClick:()=>void q(!1),children:v?"正在加载…":"加载更早的会话"}),D&&Ee.length>0?e.jsx("p",{className:"sidebar-cache-state",role:"status",children:"正在后台同步会话…"}):g&&e.jsx("p",{className:"sidebar-cache-state",role:"status",children:v?"显示缓存,正在后台更新…":"当前显示缓存"})]})]})}function Qa({cursor:n,expanded:r,loading:a,error:i,nestedScroll:c,projectName:p,onLoadMore:h}){const m=s.useRef(null),g=s.useRef(null),l=s.useRef(h);if(l.current=h,s.useEffect(()=>{const y=m.current;if(!y||!n||!r||a||i||typeof IntersectionObserver>"u")return;const j=y.closest(c?".sidebar-project-sessions":".app-sidebar-scroll");if(!j)return;const P=new IntersectionObserver(w=>{!w.some(k=>k.isIntersecting)||g.current===n||(g.current=n,l.current())},{root:j,rootMargin:"0px 0px 80px 0px"});return P.observe(y),()=>P.disconnect()},[n,r,a,i,c]),!n)return null;const u=a?"正在加载历史会话...":i?"重试加载历史会话":"加载更早的会话";return e.jsxs("button",{ref:m,type:"button",className:"sidebar-session-load-more","aria-label":`${p}:${u}`,"aria-busy":a,disabled:a,title:i,onClick:()=>{g.current=n,h()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexShrink:0,minHeight:36,padding:"6px 10px",border:0,background:"transparent",color:i?"var(--danger)":"var(--text-muted)",fontSize:11,cursor:a?"default":"pointer"},children:[a&&e.jsx(Xe,{size:12,className:"animate-spin","aria-hidden":"true"}),u]})}function Za({refreshKey:n,onOpen:r}){const[a,i]=s.useState([]),c=s.useCallback(()=>{ht({action:"groups"}).then(i).catch(()=>{})},[]);return s.useEffect(()=>{c()},[c,n]),e.jsx(e.Fragment,{children:a.length>0&&e.jsxs("div",{className:"collab-group-list","aria-label":"协作群",children:[e.jsx("span",{className:"collab-eyebrow",children:"协作群"}),a.map(p=>e.jsxs("button",{title:p.name,onClick:()=>r(p),children:[e.jsx(Go,{size:15}),e.jsx("span",{children:p.name}),e.jsx($r,{size:14})]},p.id))]})})}function ec({onOpen:n}){var k,v,O;const r=Lr(),[a,i]=s.useState([]),[c,p]=s.useState(()=>new Set),h=a.length,m=a.some(D=>!c.has(D)),[g,l]=s.useState(""),[u,y]=s.useState(null),j=s.useRef(async()=>{}),P=s.useRef(new Set);s.useEffect(()=>{if(!r)return;let D=!0,H=!1;try{P.current=new Set(JSON.parse(localStorage.getItem("agentroam:supervision-notifications")??"[]"))}catch{}const Z=async()=>{if(!(H||!Lt())){H=!0;try{const X=await ht({action:"supervisionAlerts"});if(!D)return;i(X.filter(T=>T.incident.status==="waiting").map(T=>T.incident.id)),y(T=>T?X.find(R=>R.incident.id===T.incident.id&&R.incident.status==="waiting")??null:null);const M=X.filter(T=>!P.current.has(`${T.incident.id}:${T.incident.status}`));if(M.length){const T=M.at(-1);l(`${T.groupName} · ${T.incident.status==="waiting"?"需要你决策":T.incident.kind==="handoff"?"交接已衔接":T.incident.kind==="delivery"?"交付已确认":"异常已恢复"}`);const R=M.find(B=>B.incident.status==="waiting"&&B.target);R&&y(B=>B??R);for(const B of M)P.current.add(`${B.incident.id}:${B.incident.status}`);P.current=new Set([...P.current].slice(-300));try{localStorage.setItem("agentroam:supervision-notifications",JSON.stringify([...P.current]))}catch{}}}catch{}finally{H=!1}}};j.current=Z,Z();const ee=setInterval(()=>{Z()},7e3);return()=>{D=!1,clearInterval(ee)}},[r]),s.useEffect(()=>{if(!g||m)return;const D=setTimeout(()=>l(""),1e4);return()=>clearTimeout(D)},[g,m]);const w=()=>{p(D=>new Set([...D,...a])),y(null),l("")};return!m&&!g?null:e.jsxs("aside",{className:`supervision-notice${u?" is-expanded":""}`,"aria-label":"监工提醒",role:"status",children:[e.jsxs("div",{className:"supervision-notice-heading",children:[e.jsxs("button",{onClick:n,children:[e.jsx(xa,{size:16}),e.jsx("span",{children:m?`监工有 ${h} 项待你决策`:g})]}),e.jsx("button",{"aria-label":"关闭监工提醒",onClick:w,children:e.jsx(gt,{size:14})})]}),(u==null?void 0:u.target)&&e.jsxs("div",{className:"session-dashboard supervision-notice-content",children:[e.jsxs("strong",{children:[u.groupName," · ",u.incident.sessionTitle]}),e.jsx(ta,{text:u.incident.message,options:((k=u.incident.question)==null?void 0:k.options)??u.incident.options,recommendation:u.incident.recommendation,multiSelect:(v=u.incident.question)==null?void 0:v.multiSelect,sourceOnly:(O=u.incident.question)==null?void 0:O.requiresSource,onSource:()=>zr({kind:"session",session:u.target}),onAnswer:async(D,H)=>{await ht({action:"answerSupervision",groupId:u.incident.groupId,incidentId:u.incident.id,answer:D,selectedIndices:H}),y(null),l(""),await j.current()}})]})]})}function tc(n,r){const a=new URLSearchParams(n),i=a.get("session"),p=(i!=null&&i.startsWith("runtime:")?i.split(":")[1]:void 0)??a.get("agent");return{agentType:hn(p)?p:r,explicit:!!(i||a.get("newSession")==="1"||hn(p))}}function nc(n,r){const a=r==null?void 0:r.sessions.find(p=>p.id===n.id&&p.agentType===n.agentType);if(!a||!r)return;const i=r.workspaces.find(p=>p.agentType===n.agentType&&(p.workspaceId===a.projectId||p.roots.includes(a.cwd)));if(!i)return;const c={...a,title:n.title||a.title,projectId:i.workspaceId};return{session:c,snapshot:{workspaces:r.workspaces.filter(p=>p.agentType===n.agentType),sessions:[...r.sessions.filter(p=>p.agentType===n.agentType&&p.id!==n.id),c]}}}async function sc(n,r,a,i){a.throwIfAborted();const c=await n.getSession(r.id,r.agentType==="codex"?{limit:1,view:"core"}:{limit:Ao});a.throwIfAborted();const p=c;if(p!=null&&p.threadKey&&p.activeSessionId===c.id&&(r={...r,id:c.id,agentType:c.agentType}),!(c!=null&&c.id)||c.id!==r.id||c.agentType!==r.agentType)throw new Error("原会话身份不匹配,请刷新看板后重试");const h={workspaces:(i==null?void 0:i.workspaces.filter(H=>H.agentType===r.agentType))??[],sessions:(i==null?void 0:i.sessions.filter(H=>H.agentType===r.agentType&&H.id!==r.id))??[]},m=i==null?void 0:i.sessions.find(H=>H.id===r.id),g=c.projectId??(m==null?void 0:m.projectId)??r.projectId,l=()=>h.workspaces.find(H=>H.workspaceId===g)??h.workspaces.find(H=>H.roots.includes(c.cwd||r.cwd));let u=l(),y=null;const j=new Set;for(;!u;){const H=await n.listAgentWorkspaces(r.agentType,{cursor:y,limit:200});if(a.throwIfAborted(),H.stale)throw new Error("会话目录待刷新,请重试");if(h.workspaces=[...new Map([...h.workspaces,...H.data].map(Z=>[Z.workspaceId,Z])).values()],u=l(),y=H.nextCursor,u||!y)break;if(j.has(y))throw new Error("会话目录加载中断,请重试");j.add(y)}const P=(u==null?void 0:u.workspaceId)??g??`session-${c.id}`;u||h.workspaces.push({agentType:r.agentType,workspaceId:P,roots:[c.cwd||r.cwd],name:(c.cwd||r.cwd).split(/[\\/]/).filter(Boolean).at(-1)||"会话工作区",order:h.workspaces.length,source:"derived",canCreateSession:!1});const{messages:w,events:k,history:v,...O}=c,D={...O,cwd:c.cwd||r.cwd,projectId:P};return h.sessions.push(D),{session:D,snapshot:h,initialHistory:{sessionId:D.id,detail:c}}}function rc({groups:n,dashboardVisible:r,sessionDashboardVisible:a,activeId:i,onSelect:c,onClose:p}){const h=[{id:"assistant",name:"智能助手",closable:!1},...a?[{id:"sessions",name:"Dashboard",closable:!0}]:[],...r?[{id:"dashboard",name:"群聊列表",closable:!0}]:[],...n.map(m=>({id:m.id,name:m.name,closable:!0}))];return e.jsxs("nav",{className:"collab-desktop-tabs","aria-label":"工作页签",children:[h.map(m=>e.jsxs("div",{className:`collab-desktop-tab${i===m.id?" is-active":""}`,children:[e.jsx("button",{type:"button","aria-current":i===m.id?"page":void 0,onClick:()=>c(m.id),children:m.name}),m.closable&&e.jsx("button",{type:"button",className:"collab-desktop-tab-close","aria-label":`关闭${m.name}`,title:`关闭${m.name}页签`,onClick:()=>p(m.id),children:e.jsx(gt,{size:13,"aria-hidden":"true"})})]},m.id)),e.jsx("div",{className:"collab-desktop-tabs-drag-space","aria-hidden":"true"})]})}const Kr=new Set(["downloading","installing","reconnecting"]),ic=new Set(["checking",...Kr]),oc=6e3,ac=24e3;function cc(){const[n,r]=s.useState(null),[a,i]=s.useState(()=>sessionStorage.getItem("agentroam.dismissed-update"));if(s.useEffect(()=>{var w;let u=!0;const y=window.agentApi,j=((w=y.onUpdateStatus)==null?void 0:w.call(y,k=>{u&&r(k)}))??(()=>{});y.getUpdateStatus().then(k=>{u&&r(k)}).catch(()=>{});const P=window.setTimeout(()=>{y.checkForUpdate().then(k=>{u&&r(k)}).catch(()=>{})},oc+Math.floor(Math.random()*(ac+1)));return()=>{u=!1,window.clearTimeout(P),j()}},[]),s.useEffect(()=>{if(!n||!ic.has(n.phase))return;const u=window.setInterval(()=>{window.agentApi.getUpdateStatus().then(r).catch(()=>{})},1500);return()=>window.clearInterval(u)},[n==null?void 0:n.phase]),!n||["idle","checking","up-to-date","unavailable"].includes(n.phase)||n.phase==="available"&&n.targetVersion===a)return null;const c=Kr.has(n.phase),p=n.phase==="failed",h=n.phase==="complete",m=c?n.phase==="downloading"?`正在下载${n.progress!==void 0?` ${n.progress}%`:""}`:n.phase==="installing"?"正在安装":"正在重连":p?"更新失败,重试":h?n.message??"更新已就绪":`发现 AgentRoam ${n.targetVersion}`,g=async()=>{try{r(await window.agentApi.installUpdate())}catch(u){r({...n,phase:"failed",message:u instanceof Error?u.message:"更新失败"})}},l=()=>{n.targetVersion&&(sessionStorage.setItem("agentroam.dismissed-update",n.targetVersion),i(n.targetVersion))};return e.jsxs("aside",{className:`update-notice${p?" update-notice--failed":""}`,"aria-live":"polite",children:[e.jsxs("div",{className:"update-notice__content",children:[e.jsx("strong",{children:m}),!c&&!h&&e.jsx("span",{children:"点击后才会下载安装文件"}),p&&n.message&&e.jsx("span",{children:n.message})]}),!c&&!h&&e.jsxs("button",{className:"update-notice__action",type:"button",onClick:()=>void g(),title:p?"重试更新":"下载更新",children:[p?e.jsx(ks,{size:16}):e.jsx(ua,{size:16}),e.jsx("span",{children:p?"重试":"更新"})]}),!c&&e.jsx("button",{className:"update-notice__close",type:"button",onClick:l,title:"关闭更新提醒","aria-label":"关闭更新提醒",children:e.jsx(gt,{size:16})})]})}function lc(){const[n,r]=s.useState(null);s.useEffect(()=>{const p=window.agentApi;if(!(p!=null&&p.desktopLiveGetStatus)||!(p!=null&&p.onDesktopLiveStatus))return;let h=!0;p.desktopLiveGetStatus().then(g=>{h&&r(g)}).catch(()=>{});const m=p.onDesktopLiveStatus(g=>r(g));return()=>{h=!1,m()}},[]);const a=n==null?void 0:n.controlState;if(!((n==null?void 0:n.enabled)&&a!==null&&a!==void 0&&a!=="agent-controlled"))return null;const c=a==="return-requested"||a==="resyncing";return e.jsxs("div",{className:"desktop-live-control-banner",role:"status",style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 10px)",left:"50%",transform:"translateX(-50%)",zIndex:1300,display:"flex",alignItems:"center",gap:8,padding:"7px 14px",borderRadius:999,border:"1px solid rgba(251,191,36,0.45)",background:"rgba(69,49,10,0.92)",color:"#fcd34d",fontSize:13,fontWeight:600,backdropFilter:"blur(8px)",pointerEvents:"none"},children:[e.jsx("span",{"aria-hidden":"true",children:"●"}),c?"正在结束远程控制":"正在被远程控制"]})}function Cs(n,r){return n.map((a,i)=>({session:a,index:i})).sort((a,i)=>r(a.session,i.session)||a.index-i.index).map(({session:a})=>a)}function dc(n){return Cs(n,(r,a)=>a.created.localeCompare(r.created))}function xs(n,r){return r==="codex"?[...n]:dc(n)}function ys(n,r){return Cs(n,(a,i)=>Number(r(i))-Number(r(a)))}function uc(n,r){return Cs(n,(a,i)=>Number(r(i))-Number(r(a)))}const ps={projectId:null,sessionId:null};function vs(n){return typeof n=="string"&&n.trim()?n.trim():null}function Rn(n){return{projectId:vs(n),sessionId:null}}function fs(n,r){return{projectId:vs(n),sessionId:vs(r)}}function pc(n){return n.agentType==="customer-agent"?`确定永久删除会话“${n.title}”吗?此操作不可恢复。`:n.agentType==="codex"?`确定归档 Codex 会话“${n.title}”并从 AgentRoam 中移除吗?可在 Codex 的已归档会话中恢复。`:`确定从 AgentRoam 中移除会话“${n.title}”吗?原生客户端中的历史记录会保留。`}function fc(n,r){const a=new Set(r);return{...n,selectedSessionId:n.selectedSessionId&&a.has(n.selectedSessionId)?null:n.selectedSessionId,sessions:Object.fromEntries(Object.entries(n.sessions).map(([i,c])=>[i,{...c,data:c.data.filter(p=>!a.has(p.id))}]))}}function hc(n,r){const a=new Set(r);let i=!1;const c=Object.fromEntries(Object.entries(n).map(([p,h])=>{const m=h.filter(g=>!a.has(g.id));return m.length!==h.length&&(i=!0),[p,m.length===h.length?h:m]}));return i?c:n}function gc(n,r,a,i){const c=[i,...(r[i]??[]).map(m=>m.id)],p=new Set(c),h=Object.fromEntries(Object.entries(r).flatMap(([m,g])=>{if(p.has(m))return[];const l=g.filter(u=>!p.has(u.id));return[[m,l.length===g.length?g:l]]}));return{sessionsByProject:hc(n,c),childSessionsByParent:h,otherLocalSessions:a.filter(m=>!p.has(m.id)),removedIds:c}}const mc={fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},vr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",fontSize:13};function Gr({onboarding:n=!1}){const r=typeof window>"u"?void 0:window.agentApi,a=!!(r!=null&&r.desktopLiveGetStatus),[i,c]=s.useState(null),[p,h]=s.useState(!1),[m,g]=s.useState(null),[l,u]=s.useState(!0);s.useEffect(()=>{if(!(r!=null&&r.desktopLiveGetStatus)||!(r!=null&&r.onDesktopLiveStatus))return;let v=!0;r.desktopLiveSetup().then(D=>{v&&(c(D.status),u(D.supported))}).catch(()=>{});const O=r.onDesktopLiveStatus(D=>c(D));return()=>{v=!1,O()}},[r]);const y=async()=>{if(r!=null&&r.desktopLiveRecheck)try{c(await r.desktopLiveRecheck()),g(null)}catch(v){g(v instanceof Error?v.message:String(v))}};s.useEffect(()=>{if(!a||!l)return;let v=!0,O=!1;const D=async()=>{if(!O){O=!0;try{const Z=await r.desktopLiveRecheck();v&&c(Z)}catch{}finally{O=!1}}};window.addEventListener("focus",D);const H=i!=null&&i.enabled&&(i.permissionScreen!=="granted"||i.accessibilityTrusted!==!0)?window.setInterval(D,3e3):void 0;return()=>{v=!1,window.removeEventListener("focus",D),H&&window.clearInterval(H)}},[r,a,l,i==null?void 0:i.enabled,i==null?void 0:i.permissionScreen,i==null?void 0:i.accessibilityTrusted]);const j=async v=>{if(r){h(!0);try{c(await r.desktopLiveSetEnabled(!0)),await r.desktopLiveOpenPermission(v),g(null)}catch(O){g(O instanceof Error?O.message:String(O))}finally{h(!1)}}};if(!a)return null;const P=async()=>{if(r!=null&&r.desktopLiveSetEnabled){h(!0);try{c(await r.desktopLiveSetEnabled(!(i!=null&&i.enabled))),g(null)}catch(v){g(v instanceof Error?v.message:String(v))}finally{h(!1)}}},w=(i==null?void 0:i.permissionScreen)==="granted",k=(i==null?void 0:i.accessibilityTrusted)===!0;return e.jsxs("section",{className:"desktop-permission-settings",children:[e.jsx("h3",{style:mc,children:n?"设置桌面端权限":"桌面直播与远程控制"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"0 0 14px",lineHeight:1.6},children:n?"欢迎使用 AgentRoam。请为桌面端开启以下系统权限,完成后手机即可查看电脑画面;允许辅助功能后还可操作鼠标和键盘。":"开启后,已配对手机可查看电脑画面,并在授予辅助功能权限后操作鼠标和键盘。"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("button",{type:"button",onClick:()=>void P(),disabled:p||!l,style:{padding:"7px 16px",borderRadius:"var(--radius-sm)",border:`1px solid ${i!=null&&i.enabled?"rgba(244,63,94,0.35)":"var(--accent)"}`,background:i!=null&&i.enabled?"rgba(244,63,94,0.1)":"var(--accent-dim)",color:i!=null&&i.enabled?"var(--danger)":"var(--accent)",fontSize:13,fontWeight:600,cursor:"pointer"},children:p?"处理中…":i!=null&&i.enabled?n?"暂停手机查看":"关闭桌面直播":n?"开启手机查看":"开启桌面直播"}),(i==null?void 0:i.enabled)&&e.jsx("span",{style:{fontSize:12,color:i.sessionOnline?"var(--success)":"var(--text-muted)"},children:i.sessionOnline?"● 已连接,可从手机查看":"○ 未连接"})]}),!l&&e.jsx("p",{role:"status",children:"当前远程桌面仅支持 macOS,其他桌面功能可正常使用。"}),l&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{className:"desktop-permission-row",style:vr,children:[e.jsx("span",{children:"屏幕录制(画面采集)"}),e.jsx("span",{style:{color:w?"var(--success)":"var(--danger)",fontWeight:600},children:w?"已授权":"未授权"}),!w&&e.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:p,onClick:()=>void j("screen"),children:"去授权"})]}),e.jsxs("div",{className:"desktop-permission-row",style:vr,children:[e.jsx("span",{children:"辅助功能(键鼠控制)"}),e.jsx("span",{style:{color:k?"var(--success)":"var(--danger)",fontWeight:600},children:(i==null?void 0:i.accessibilityTrusted)===null?"待检测":k?"已授权":"未授权"}),!k&&e.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:p,onClick:()=>void j("accessibility"),children:"去授权"})]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginTop:14,fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:"点击对应权限的「去授权」,在系统设置中允许 AgentRoam,返回后自动检测。"}),e.jsxs("details",{className:"desktop-permission-more",children:[e.jsx("summary",{children:"更多操作"}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void y(),children:"重新检测"}),!w&&e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void(r==null?void 0:r.desktopLiveRestart()),children:"重启桌面端"})]})]})]}),m&&e.jsx("p",{role:"alert",style:{color:"var(--danger)"},children:m}),(i==null?void 0:i.error)&&e.jsx("div",{style:{marginTop:10,fontSize:12,color:"var(--danger)"},role:"alert",children:i.error})]})}const wc=Object.freeze(Object.defineProperty({__proto__:null,default:Gr},Symbol.toStringTag,{value:"Module"}));function bc({onClose:n}){const r=s.useRef(null);return s.useEffect(()=>{var a;(a=r.current)==null||a.showModal()},[]),Oe.createPortal(e.jsx("dialog",{ref:r,"aria-label":"桌面直播与远程控制",onCancel:n,onClick:a=>{a.target===a.currentTarget&&n()},style:{width:"min(680px, calc(100vw - 48px))",maxHeight:"calc(100vh - 48px)",padding:0,margin:"auto",inset:0,overflowY:"auto",color:"var(--text-primary)",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)"},children:e.jsxs("div",{style:{padding:24},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:e.jsx("button",{type:"button",onClick:n,"aria-label":"关闭桌面直播设置",className:"ui-icon-button ui-icon-button--close",children:"×"})}),e.jsx(Gr,{}),e.jsx("div",{className:"desktop-permission-footer",children:e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:n,children:"关闭"})})]})}),document.body)}function xc({trigger:n,heardText:r}){const[a,i]=s.useState(!1);return s.useEffect(()=>{if(n<=0)return;i(!0);const c=setTimeout(()=>i(!1),2400);return()=>clearTimeout(c)},[n]),a?Oe.createPortal(e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:3e4,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:22,background:"radial-gradient(circle at 50% 50%, var(--accent-glow), transparent 60%)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",animation:"fadeIn 0.3s var(--ease-out)",pointerEvents:"none",WebkitAppRegion:"no-drag"},children:[e.jsxs("div",{style:{position:"relative",width:120,height:120},children:[[0,.45,.9].map(c=>e.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"2px solid var(--accent)",animation:`wakeRing 1.6s ${c}s var(--ease-out) infinite`}},c)),e.jsx("div",{style:{position:"absolute",inset:30,borderRadius:"50%",background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",animation:"wakeCore 1.6s var(--ease-out) infinite"},children:e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-inverse)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})]}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",letterSpacing:"0.12em",animation:"wakeText 0.9s var(--ease-out) both",fontFamily:"var(--font-display)"},children:"已唤醒 · 随时待命"}),r&&e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",maxWidth:320,textAlign:"center",animation:"fadeIn 0.6s var(--ease-out) 0.3s both"},children:["“",r.slice(0,40),"”"]})]},n),document.body):null}const yc={completion:{label:"会话已完成",sound:"completion.wav"},approval:{label:"需要确认",sound:"approval.wav"},todo_reminder:{label:"待办提醒",sound:"reminder.wav"},todo_execution:{label:"定时待办",sound:"scheduled.wav"},todo_attention:{label:"待办需关注",sound:"attention.wav"},todo_error:{label:"待办执行异常",sound:"error.wav"}};function vc(n){let r=n.kind;return n.kind==="todo_execution"&&(n.title==="定时待办执行未完成"?r="todo_error":(n.title==="定时待办错过执行"||n.title==="定时待办需要核实")&&(r="todo_attention")),{type:r,...yc[r]}}function kr(n,r=180){const a=n.replace(/```[^\n]*\n?[\s\S]*?(?:```|$)/g," ").replace(/~~~[^\n]*\n?[\s\S]*?(?:~~~|$)/g," ").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\((?:[^)(]|\([^)]*\))*\)/g,"$1").replace(/`(?:\/|~\/|[A-Za-z]:\\)[^`]*`/g," ").replace(/(?:file:\/\/\/|\/(?:Users|home|tmp|private|var|Applications|Volumes)\/|~\/|[A-Za-z]:\\)[^\s<>`"',。;、))]+/g," ").replace(/^\s{0,3}(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/gm,"").replace(/(\*\*|__|~~)([\s\S]*?)\1/g,"$2").replace(/(^|\s)[*_]([^\s*_][^*_]*?)[*_](?=\s|[,。!?,.!?]|$)/g,"$1$2").replace(/`+/g,"").replace(/\s+/g," ").replace(/\s+([,。;、)])/g,"$1").trim(),i=Array.from(a);return i.length>r?`${i.slice(0,r-1).join("")}…`:a}const kc={completion:No,approval:Ia,todo_reminder:ba,todo_execution:ya,todo_attention:va,todo_error:To},Sc=new Set(["会话已完成","会话完成","任务完成","任务已完成","运行已结束","运行结束","已完成"]);function jc({items:n,onOpen:r,onDismiss:a,onClearAll:i}){return n.length===0?null:e.jsxs("aside",{className:"notification-toasts","aria-label":"通知",children:[n.length>1&&i&&e.jsx("button",{type:"button",className:"notification-toasts__clear",title:"全部标为已读并清除",onClick:c=>{c.stopPropagation(),i()},children:"全部清除"}),n.slice(0,3).map(c=>{const{type:p,label:h}=vc(c),m=kc[p],g=kr(c.title,100)||h,l=c.kind!=="completion"||!Sc.has(g.replace(/[\s。.!!::]+/g,"")),u=kr(c.body)||"点击查看详细内容";return e.jsxs("article",{className:`notification-toast notification-toast--${p}`,"data-notification-id":c.id,"data-notification-type":p,children:[e.jsxs("button",{type:"button",className:"notification-toast__content","aria-label":`${l?g:h},打开查看`,onClick:()=>r(c),children:[e.jsx("span",{className:"notification-toast__icon","aria-hidden":"true",children:e.jsx(m,{size:15,strokeWidth:1.8})}),e.jsxs("span",{className:"notification-toast__body",role:"status",children:[e.jsxs("span",{className:"notification-toast__meta",children:[e.jsx("span",{children:h}),e.jsx("span",{className:"notification-toast__dot","aria-hidden":"true"}),e.jsx("span",{className:"notification-toast__unread",children:"未读"})]}),l&&e.jsx("strong",{className:"notification-toast__title",children:g}),e.jsx("span",{className:"notification-toast__summary",children:u})]})]}),e.jsx("button",{type:"button",className:"notification-toast__close","aria-label":"关闭通知并标为已读",title:"关闭并标为已读",onClick:y=>{y.stopPropagation(),a(c)},children:e.jsx(gt,{size:14,"aria-hidden":"true"})})]},c.id)})]})}const Sr="agentroam.notification-read-pending.v1";function jr(n){if(!n.serviceId||!n.ownerId)throw new Error("通知来源缺失");return JSON.stringify([n.serviceId,n.ownerId])}function Cc(n,r){return n.kind==="completion"?(r==null?void 0:r.completionEnabled)!==!1:n.kind==="approval"?(r==null?void 0:r.approvalEnabled)!==!1:(r==null?void 0:r.todoEnabled)!==!1}class Ic{constructor(r,a,i=()=>{}){this.api=r,this.storage=a,this.warn=i,this.scope="",this.items=[],this.consumed=new Map,this.listeners=new Set,this.pending={};try{const c=JSON.parse((a==null?void 0:a.getItem(Sr))??"{}");if(c&&typeof c=="object"&&!Array.isArray(c))for(const[p,h]of Object.entries(c))Array.isArray(h)&&(this.pending[p]=h.filter(m=>typeof m=="string"))}catch(c){this.warn(c)}}subscribe(r){return this.listeners.add(r),r(this.items),()=>{this.listeners.delete(r)}}publish(r){this.items=r,this.listeners.forEach(a=>a(r))}save(){var r;try{(r=this.storage)==null||r.setItem(Sr,JSON.stringify(this.pending))}catch(a){this.warn(a)}}refresh(){return this.refreshing?this.refreshing:(this.refreshing=this.refreshOnce().finally(()=>{this.refreshing=void 0}),this.refreshing)}async refreshOnce(){try{const r=await this.api.list();this.scope=jr(r);const a=new Set([...this.pending[this.scope]??[],...this.consumed.get(this.scope)??[]]);this.publish(r.items.filter(i=>i.ownerId===r.ownerId&&!i.readAt&&!i.dismissedAt&&!a.has(i.id)&&Cc(i,r.preferences)).sort((i,c)=>c.createdAt-i.createdAt)),await this.syncReads(this.scope)}catch(r){this.warn(r)}}consume(r){return this.consumeItems([r])}consumeAll(){return this.consumeItems(this.items)}consumeItems(r){var p;if(!this.scope||!r.length)return Promise.resolve();const a=new Set(r.filter(h=>this.items.some(m=>m.id===h.id&&m.ownerId===h.ownerId)).map(h=>h.id));if(!a.size)return Promise.resolve();const i=this.scope,c=(p=this.pending)[i]??(p[i]=[]);for(const h of a)c.includes(h)||c.push(h);return this.save(),this.publish(this.items.filter(h=>!a.has(h.id))),this.syncReads(i)}syncReads(r){return this.syncing?this.syncing:(this.syncing=this.flushReads(r).finally(()=>{this.syncing=void 0}),this.syncing)}async flushReads(r){var a;try{for(;(a=this.pending[r])!=null&&a.length;){const i=await this.api.list();if(jr(i)!==r)return;const c=this.pending[r][0];i.items.some(m=>m.id===c&&(m.readAt||m.dismissedAt))||await this.api.read(c,{serviceId:i.serviceId,ownerId:i.ownerId});const h=this.consumed.get(r)??new Set;h.add(c),this.consumed.set(r,h),this.pending[r]=this.pending[r].filter(m=>m!==c),this.pending[r].length||delete this.pending[r],this.save()}}catch(i){this.warn(i)}}}function Ec(n){const[r,a]=s.useState([]),i=s.useRef();s.useEffect(()=>{var y;if(!n||!((y=window.agentApi)!=null&&y.notificationList)||!window.agentApi.notificationRead)return;let h;try{h=window.localStorage}catch{}const m=new Ic({list:async()=>await window.agentApi.notificationList(),read:(j,P)=>window.agentApi.notificationRead(j,P)},h,j=>console.warn("[notifications] read synchronization failed",j));i.current=m;const g=m.subscribe(a),l=()=>{m.refresh()};l();const u=window.setInterval(l,3e3);return window.addEventListener("focus",l),()=>{window.clearInterval(u),window.removeEventListener("focus",l),g(),i.current===m&&(i.current=void 0)}},[n]);const c=s.useCallback(h=>{var m;(m=i.current)==null||m.consume(h)},[]),p=s.useCallback(()=>{var h;(h=i.current)==null||h.consumeAll()},[]);return{items:r,consume:c,clearAll:p}}const Ac=[{value:"classic",description:"横向切换 Agent,按目录浏览"},{value:"agent-rail",description:"竖向 Agent 栏,聚焦当前工作区"},{value:"all-sessions",description:"汇总所有 Agent 的会话"}],Tc=typeof window>"u"?s.useEffect:s.useLayoutEffect;function Nc({value:n}){return e.jsxs("svg",{className:"sidebar-layout-preview",viewBox:"0 0 48 36",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"1",y:"1",width:"46",height:"34",rx:"5",stroke:"currentColor",strokeOpacity:".3"}),n==="classic"?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 8h16M6 20h13M6 25h10M6 30h12",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"}),[7,13,19,25,31,37].map(r=>e.jsx("rect",{x:r,y:"12",width:"4",height:"4",rx:"1",fill:"currentColor",opacity:".7"},r))]}):n==="agent-rail"?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 8h28M14 13v21",stroke:"currentColor",strokeOpacity:".3",strokeWidth:"2",strokeLinecap:"round"}),[16,22,28].map(r=>e.jsx("rect",{x:"6",y:r,width:"4",height:"4",rx:"1",fill:"currentColor",opacity:".7"},r)),e.jsx("path",{d:"M20 17h18M20 23h12M20 29h15",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 8h22",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"}),[16,22,28].map((r,a)=>e.jsxs("g",{children:[e.jsx("circle",{cx:"7",cy:r,r:"1.5",fill:"currentColor",opacity:".7"}),e.jsx("path",{d:`M12 ${r}h${a===1?18:25}`,stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"})]},r))]})]})}function Yr(){const n=ve(u=>u.navigationLayout),r=ve(u=>u.setNavigationLayout),[a,i]=s.useState(!1),[c,p]=s.useState({top:0,left:0}),h=s.useRef(null),m=s.useRef(null),g=s.useId();Tc(()=>{var y,j;if(!a)return;const u=()=>{var v;const P=(v=h.current)==null?void 0:v.getBoundingClientRect();if(!P||!m.current)return;const{offsetWidth:w,offsetHeight:k}=m.current;p({top:Math.max(8,Math.min(P.bottom+8,window.innerHeight-k-8)),left:Math.max(8,Math.min(P.right-w,window.innerWidth-w-8))})};return u(),(j=(y=m.current)==null?void 0:y.querySelector('[aria-checked="true"]'))==null||j.focus(),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[a]),s.useEffect(()=>{if(!a)return;const u=y=>{var P,w;const j=y.target;!((P=h.current)!=null&&P.contains(j))&&!((w=m.current)!=null&&w.contains(j))&&i(!1)};return document.addEventListener("pointerdown",u),()=>document.removeEventListener("pointerdown",u)},[a]);const l=u=>{var w,k,v;u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),i(!1),(w=h.current)==null||w.focus());const y=Array.from(((k=m.current)==null?void 0:k.querySelectorAll('[role="menuitemradio"]'))??[]),j=y.indexOf(document.activeElement),P=u.key==="ArrowDown"?(j+1)%y.length:u.key==="ArrowUp"?(j+y.length-1)%y.length:u.key==="Home"?0:u.key==="End"?y.length-1:null;P!==null&&(u.preventDefault(),(v=y[P])==null||v.focus())};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",className:"sidebar-layout-trigger","aria-label":"切换侧栏布局",title:`切换布局 · 当前:${as[n]}`,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?g:void 0,onClick:()=>i(u=>!u),onKeyDown:u=>{(u.key==="ArrowDown"||u.key==="ArrowUp")&&(u.preventDefault(),i(!0))},children:e.jsx(Po,{size:18,"aria-hidden":"true"})}),a&&Oe.createPortal(e.jsxs("div",{ref:m,id:g,role:"menu","aria-label":"侧栏布局",className:"sidebar-layout-menu",style:{position:"fixed",...c},onKeyDown:l,onBlur:u=>{var j;const y=u.relatedTarget;y&&!u.currentTarget.contains(y)&&!((j=h.current)!=null&&j.contains(y))&&i(!1)},children:[e.jsx("div",{className:"sidebar-layout-menu-title","aria-hidden":"true",children:"侧栏布局"}),Ac.map(u=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-label":as[u.value],"aria-checked":n===u.value,className:"sidebar-layout-option",onClick:()=>{i(!1),r(u.value),requestAnimationFrame(()=>{var y;return(y=document.querySelector(".sidebar-layout-trigger"))==null?void 0:y.focus()})},children:[e.jsx(Nc,{value:u.value}),e.jsxs("span",{className:"sidebar-layout-option-copy",children:[e.jsx("span",{children:as[u.value]}),e.jsx("small",{children:u.description})]}),n===u.value&&e.jsx(pa,{size:16,"aria-hidden":"true"})]},u.value))]}),document.body)]})}function Pc({value:n,health:r,onClose:a}){const i=r.find(h=>h.agentType===n),c=(i==null?void 0:i.available)===!1?"unavailable":i!=null&&i.available||n==="customer-agent"?"ready":"checking",p=c==="ready"?"本机已连接":c==="checking"?"正在检查运行时":"运行时暂不可用";return e.jsxs("header",{className:"sidebar-agent-header",children:[e.jsx("span",{className:"sidebar-agent-header-icon",children:e.jsx(gn,{agentType:n,size:23})}),e.jsxs("div",{className:"sidebar-agent-header-identity",children:[e.jsx("span",{className:"sidebar-agent-header-name",title:Dn[n],children:Dn[n]}),e.jsxs("span",{className:`sidebar-agent-header-status is-${c}`,title:i==null?void 0:i.error,children:[e.jsx("i",{"aria-hidden":"true"}),p]})]}),e.jsxs("div",{className:"sidebar-agent-header-actions",children:[e.jsx(Yr,{}),e.jsx("button",{type:"button",className:"ui-icon-button sidebar-agent-header-close",onClick:a,"aria-label":"收起会话列表",title:"收起会话列表",children:e.jsx(gt,{size:18,"aria-hidden":"true"})})]})]})}async function Rc(n,r,a){async function i(u){const y=[],j=new Set;let P=null;do{a.throwIfAborted();const w=await u(P);if(a.throwIfAborted(),w.stale)throw new Error("会话列表待刷新,请重试");if(y.push(...w.data),P=w.nextCursor,P&&j.has(P))throw new Error("会话列表加载中断,请重试");P&&j.add(P)}while(P);return y}const c=await i(u=>n.listAgentWorkspaces(r,{cursor:u,limit:200})),p=[...new Map(c.map(u=>[u.workspaceId,u])).values()],h=new Array(p.length);let m=0;await Promise.all(Array.from({length:Math.min(4,p.length)},async()=>{for(;m<p.length;){const u=m++,y=p[u];h[u]=(await i(j=>n.listAgentWorkspaceSessions(r,y.workspaceId,{cursor:j,limit:200}))).map(j=>({...j,projectId:y.workspaceId}))}}));const g=new Set,l=h.flat().filter(u=>g.has(u.id)?!1:(g.add(u.id),!0));return{workspaces:p,sessions:l}}function Lc({hidden:n,value:r,health:a,selectedSessionId:i,getActivity:c,onChange:p,onUnavailable:h,onNewSession:m,onSelect:g}){const[l,u]=s.useState(null),[y,j]=s.useState(null),[P,w]=s.useState(!1),[k,v]=s.useState(null),[O,D]=s.useState(""),[H,Z]=s.useState(0),ee=s.useRef(),X=s.useRef(null),M=s.useRef(new Map),T=()=>clearTimeout(ee.current),R=()=>{T(),u(null)},B=()=>{T(),ee.current=setTimeout(()=>u(null),180)};s.useEffect(()=>()=>clearTimeout(ee.current),[]),s.useEffect(()=>{n&&u(null)},[n]),s.useEffect(()=>{if(!l||n)return;const z=new AbortController;return D(""),j(l.unavailableMessage?null:M.current.get(l.agentType)??null),v(l.unavailableMessage??null),w(!l.unavailableMessage),l.unavailableMessage||Rc(window.agentApi,l.agentType,z.signal).then(q=>{z.signal.aborted||(M.current.set(l.agentType,q),j(q))}).catch(q=>{z.signal.aborted||v(q instanceof Error?q.message:"会话加载失败,请重试")}).finally(()=>{z.signal.aborted||w(!1)}),()=>z.abort()},[l==null?void 0:l.agentType,l==null?void 0:l.unavailableMessage,n,H]);const V=ys((y==null?void 0:y.sessions)??[],z=>{const q=c(z);return q==="running"||q==="needs-input"}).filter(z=>z.title.toLocaleLowerCase().includes(O.trim().toLocaleLowerCase())),J=z=>{var Ie;const q=z.relatedTarget;!z.currentTarget.contains(q)&&!((Ie=X.current)!=null&&Ie.contains(q))&&B()};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"sidebar-agent-rail","aria-label":"Agent 快捷栏","aria-hidden":n,ref:z=>{z&&(z.inert=n)},onPointerEnter:T,onPointerLeave:B,onBlur:J,onKeyDown:z=>{z.key==="Escape"&&R()},children:e.jsx(Dr,{vertical:!0,value:r,health:a,onChange:p,onUnavailable:h,onPreview:(z,q,Ie,me)=>{T(),(l==null?void 0:l.agentType)!==z&&j(null),u({agentType:z,label:q,top:Math.max(56,Math.min(Ie.top,window.innerHeight-380)),unavailableMessage:me})}})}),!n&&l&&Oe.createPortal(e.jsxs("div",{ref:X,className:"agent-session-flyout",style:{top:l.top,maxHeight:Math.min(600,window.innerHeight-l.top-12)},role:"dialog","aria-label":`${l.label} 会话`,onPointerEnter:T,onPointerLeave:B,onFocus:T,onBlur:J,onKeyDown:z=>{z.key==="Escape"&&R()},children:[e.jsxs("header",{children:[e.jsx(gn,{agentType:l.agentType,size:20}),e.jsx("strong",{children:l.label}),e.jsxs("span",{children:["会话 ",(y==null?void 0:y.sessions.length)??""]}),e.jsxs("button",{type:"button",className:"agent-session-flyout-new",disabled:!!l.unavailableMessage,"aria-label":`新建 ${l.label} 会话`,title:l.unavailableMessage??"在小窗口中新建会话",onClick:()=>{m(l.agentType),R()},children:[e.jsx(Ln,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]})]}),e.jsxs("label",{className:"agent-session-flyout-search",children:[e.jsx(On,{size:15,"aria-hidden":"true"}),e.jsx("input",{"aria-label":`搜索 ${l.label} 会话`,placeholder:"搜索会话",value:O,onChange:z=>D(z.target.value)})]}),e.jsxs("div",{className:"agent-session-flyout-list","aria-busy":P,children:[V.map(z=>{const q=un(c(z));return e.jsx(fn,{session:{id:z.id,title:z.title,visualState:q,statusLabel:dn[q],occupiedExternally:z.occupancy==="owned-externally",canDelete:!1,active:r===l.agentType&&i===z.id,compatibility:z.compatibility},onSelect:()=>{y&&g(z,y),R()}},z.id)}),P&&e.jsxs("p",{className:"agent-session-flyout-message",role:"status",children:[e.jsx(Xe,{size:15,className:"spin"}),"正在加载会话…"]}),k&&e.jsxs("p",{className:"agent-session-flyout-message",role:"alert",children:[k,!l.unavailableMessage&&e.jsx("button",{type:"button",onClick:()=>Z(z=>z+1),children:"重试"})]}),!P&&!k&&!V.length&&e.jsx("p",{className:"agent-session-flyout-message",children:O?"没有匹配的会话":"暂无会话"})]})]}),document.body)]})}function Cr({onOpenFlowStudio:n,onOpenCalendar:r,openingFlowStudio:a=!1}){return e.jsxs("div",{className:"desktop-app-actions",role:"toolbar","aria-label":"应用快捷操作",children:[r&&e.jsx("button",{type:"button",className:"ui-icon-button desktop-app-action desktop-app-action--calendar",onClick:r,title:"智能体日历","aria-label":"打开日历",children:e.jsx(Ss,{size:17,"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"ui-icon-button desktop-app-action desktop-app-action--flow-studio",onClick:n,disabled:a,title:"数字人 · Flow Studio","aria-label":"打开 Flow Studio","aria-busy":a,children:a?e.jsx(Xe,{className:"desktop-app-action-spinner",size:17,"aria-hidden":"true"}):e.jsx(Ji,{size:17,"aria-hidden":"true"})})]})}function Dc({entryUrl:n,onBack:r}){const a=typeof window<"u"?window.agentApi:void 0,i=typeof(a==null?void 0:a.flowStudioOpen)=="function",c=s.useRef(null),p=s.useRef(null),[h,m]=s.useState("loading"),g=s.useCallback(()=>{p.current&&(a==null||a.flowStudioSetBounds(p.current))},[a]),l=s.useCallback(async()=>{if(!i||!a){m("error");return}if(m("loading"),!(await a.flowStudioOpen(n).catch(()=>({ok:!1}))).ok){m("error");return}g()},[a,i,n,g]);return s.useEffect(()=>{if(!i||!a){m("error");return}const u=a.onFlowStudioEvent(y=>{y.siteId==="flow-studio"&&(y.type==="loading"&&m("loading"),y.type==="loaded"&&(m("ready"),g()),y.type==="load-failed"&&m("error"))});return l(),()=>{u(),a.flowStudioSetBounds(null)}},[a,i,l,g]),s.useEffect(()=>{if(!i||!a)return;const u=c.current;if(!u)return;let y=0;const j=()=>{const w=u.getBoundingClientRect(),k={x:w.x,y:w.y,width:w.width,height:w.height};p.current=k,a.flowStudioSetBounds(k)},P=new ResizeObserver(()=>{cancelAnimationFrame(y),y=requestAnimationFrame(j)});return P.observe(u),j(),()=>{P.disconnect(),cancelAnimationFrame(y)}},[a,i]),e.jsxs("section",{className:"desktop-flow-studio-view","aria-label":"Flow Studio","aria-busy":h==="loading",children:[e.jsx("header",{className:"desktop-flow-studio-topbar",children:e.jsx("button",{type:"button",className:"desktop-flow-studio-back ui-icon-button",onClick:r,title:"返回 AgentRoam","aria-label":"返回 AgentRoam",children:e.jsx(Mr,{size:18,"aria-hidden":"true"})})}),e.jsx("div",{ref:c,className:"desktop-flow-studio-content",children:h!=="ready"&&e.jsxs("div",{className:"desktop-flow-studio-status",role:h==="error"?"alert":"status","aria-live":"polite",children:[h==="loading"?e.jsx(Xe,{className:"desktop-flow-studio-spinner",size:20,"aria-hidden":"true"}):null,e.jsx("strong",{children:h==="error"?"无法打开 Flow Studio":"正在打开 Flow Studio"}),h==="error"&&e.jsxs("button",{type:"button",className:"desktop-flow-studio-retry",onClick:()=>void l(),children:[e.jsx(js,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"重试"})]})]})})]})}const hs=264,Ir=126;function Oc(n){const r=typeof window>"u"?1024:window.innerWidth,a=typeof window>"u"?768:window.innerHeight,i=Math.max(8,Math.min(n.left+n.width-hs,r-hs-8)),c=n.top+n.height+7,p=c+Ir<=a-8?c:Math.max(8,n.top-Ir-7);return{left:i,top:p,width:hs}}function Er({title:n,message:r,anchor:a,mobile:i,pending:c,onCancel:p,onConfirm:h}){const m=g=>g.stopPropagation();return e.jsx("div",{className:`sidebar-delete-confirmation-layer${i?" is-mobile":""}`,onClick:c?void 0:p,children:e.jsxs("div",{className:"sidebar-delete-confirmation",role:"alertdialog","aria-modal":"true","aria-labelledby":"sidebar-delete-confirmation-title","aria-describedby":"sidebar-delete-confirmation-message",style:i?void 0:Oc(a),onClick:m,children:[e.jsx("strong",{id:"sidebar-delete-confirmation-title",children:n??"删除会话"}),e.jsx("p",{id:"sidebar-delete-confirmation-message",children:r}),e.jsxs("div",{className:"sidebar-delete-confirmation-actions",children:[e.jsx("button",{type:"button",onClick:p,disabled:c,children:"取消"}),e.jsx("button",{type:"button",className:"is-danger",onClick:h,disabled:c,children:c?"正在删除...":"删除"})]})]})})}function _c({message:n,type:r}){return n?Oe.createPortal(e.jsxs("div",{className:`app-action-notice is-${r}`,role:r==="error"?"alert":"status","aria-live":r==="error"?"assertive":"polite",children:[e.jsx("span",{className:"app-action-notice-mark","aria-hidden":"true",children:r==="success"?"✓":r==="info"?"i":"!"}),e.jsx("span",{children:n})]}),document.body):null}function Xr(){const n=window;return n.SpeechRecognition??n.webkitSpeechRecognition??null}function zc(){if(typeof window>"u")return null;const n=window.agentApi;return typeof(n==null?void 0:n.dictationStart)!="function"||typeof n.dictationStop!="function"||typeof n.onDictation!="function"||typeof n.onDictationError!="function"?null:n}function Mc(){return zc()!==null||Xr()!==null}function Wc(n){var h;const r=Xr();if(!r)return(h=n.onError)==null||h.call(n,"当前环境不支持语音唤醒"),null;let a=!1,i=null,c=null;const p=()=>{if(!a){i=new r,i.lang=n.lang??"zh-CN",i.continuous=!0,i.interimResults=!0,i.onresult=m=>{var u,y,j;const g=m.results[m.results.length-1],l=(y=(u=g==null?void 0:g[0])==null?void 0:u.transcript)==null?void 0:y.trim();l&&(g.isFinal&&((j=n.onHeard)==null||j.call(n,l)),l.includes(n.wakeWord)&&n.onWake(l))},i.onerror=m=>{var g;m.error==="not-allowed"&&((g=n.onError)==null||g.call(n,"麦克风权限被拒绝,语音唤醒已停用"),a=!0)},i.onend=()=>{a||(c=setTimeout(p,400))};try{i.start()}catch{c=setTimeout(p,800)}}};return p(),{stop:()=>{a=!0,c&&clearTimeout(c);try{i==null||i.abort()}catch{}}}}function $c(n){return n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(n)}function Hc(n,r){if(r.webShell||r.isInvalid||!r.supported)return null;const a=n.description;return!a||/[\0\r\n]/.test(a)||!$c(a)?null:a}function Bc(n){return{request:(r,a)=>n.fileWorkspaceRequest(r,a),subscribe:(r,a)=>r!=="fs:event"?()=>{}:n.onFileWorkspaceEvent(a)}}function Fc(n){try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}}async function qc(){var n;try{const r=window.sharedServiceApi;if(!(r!=null&&r.request))return null;const a=await r.request("/api/flow-studio/config","GET");if(a.status!==200)return null;const i=(n=JSON.parse(a.body).entryUrl)==null?void 0:n.trim();return i?Fc(i):null}catch{return null}}function Vc({authoritativeStatus:n,locallyRunning:r,needsInput:a,stale:i}){return n==="failed"||n==="error"?"error":i&&!r?"stale":r||n==="running"?a?"needs-input":"running":"idle"}function Uc(n,r){const a=new Set;n&&a.add(n);for(const i of r)i&&a.add(i);return[...a]}function Kc(n,r,a){return[...n].filter(i=>!r.has(i)&&!a.has(i))}const Ar=220,Tr=480,Gc=180;function Yc(){const[n,r]=s.useState(300),[a,i]=s.useState(!1),[c,p]=s.useState(!1),h=s.useRef(null),m=s.useCallback(w=>{w.button!==0||!w.isPrimary||(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),h.current={pointerId:w.pointerId,startX:w.clientX,startWidth:n,target:w.currentTarget},p(!0))},[n]),g=s.useCallback(w=>{const k=h.current;if(!k||w.pointerId!==k.pointerId)return;const v=k.startWidth+w.clientX-k.startX,O=v<=Gc;i(O),r(O?k.startWidth:Math.min(Tr,Math.max(Ar,v)))},[]),l=s.useCallback(()=>{const w=h.current;w&&(h.current=null,p(!1),w.target.hasPointerCapture(w.pointerId)&&w.target.releasePointerCapture(w.pointerId))},[]),u=s.useCallback(w=>{var k;w.pointerId===((k=h.current)==null?void 0:k.pointerId)&&l()},[l]),y=s.useCallback(w=>{g(w),u(w)},[g,u]);s.useEffect(()=>{if(c)return window.addEventListener("pointerup",y),window.addEventListener("pointercancel",u),window.addEventListener("blur",l),()=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",u),window.removeEventListener("blur",l)}},[c,y,u,l]);const j=s.useCallback(w=>{w.key==="Enter"?(w.preventDefault(),i(!0)):(w.key==="ArrowLeft"||w.key==="ArrowRight")&&(w.preventDefault(),r(k=>Math.min(Tr,Math.max(Ar,k+(w.key==="ArrowLeft"?-20:20)))))},[]),P=s.useCallback(()=>i(w=>!w),[]);return{width:n,collapsed:a,dragging:c,toggle:P,resizeProps:{onPointerDown:m,onPointerMove:g,onPointerUp:y,onPointerCancel:u,onLostPointerCapture:u,onKeyDown:j}}}const Xc=s.lazy(()=>be(()=>import("./CollaborationDashboard-BZhWQXzn.js"),__vite__mapDeps([12,1,2,13,14,15,16,17,4,18,5,19,20,10,21,22,23]),import.meta.url)),Jc=s.lazy(()=>be(()=>import("./SessionDashboard-DuR9r_ZP.js"),__vite__mapDeps([31,1,2,21,32,19,20,33,4,22,10,28,34,8,35]),import.meta.url)),Qc=s.lazy(()=>be(()=>import("./CollaborationPage-BwRJN55v.js"),__vite__mapDeps([24,1,2,25,26,27,4,21,28,19,20,15,13,29,30,7]),import.meta.url)),Zc=s.lazy(()=>be(()=>import("./AIHubView-DF0D5qd2.js"),__vite__mapDeps([41,1,2,42,25,43,10,4,22,27,17,18,26,37,7,39,38,44,9,5,34,16,45,46]),import.meta.url)),el=s.lazy(()=>be(()=>import("./CalendarView-BD7GhA0i.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url)),tl=async(n,r)=>{const a=window.agentApi;if(!(a!=null&&a.calendarOverview))throw new Error("当前服务不支持日历,请更新共享服务。");return a.calendarOverview({from:n,to:r})},nl=s.lazy(()=>be(()=>import("./SettingsPanel-B-g919uV.js"),__vite__mapDeps([47,1,2,42,25,43,10,4,22,27,17,18,26,37,7,39,38,44,9,5,34,16,45,19,20,32,21,33,3,48,40,49,14,15,13,29]),import.meta.url)),sl=s.lazy(()=>be(()=>import("./MCPServerList-BmsejJC9.js"),__vite__mapDeps([50,1,2]),import.meta.url)),rl=s.lazy(()=>be(()=>import("./MemoryViewer-qZMdVrli.js"),__vite__mapDeps([51,1,2]),import.meta.url)),il=s.lazy(()=>be(()=>import("./SkillManager-nrWIOtEO.js"),__vite__mapDeps([52,1,2]),import.meta.url)),ol=s.lazy(()=>be(()=>import("./AgentManager-Ccj6ZefC.js"),__vite__mapDeps([53,1,2,42,25,43,10,4,22,27,17,18,26,37,7,39,38,44,9,5,34,16,45]),import.meta.url)),al=s.lazy(()=>be(()=>import("./LSPServerList-DQRv04aP.js"),__vite__mapDeps([54,1,2]),import.meta.url)),cl=s.lazy(()=>be(()=>import("./FileWorkspaceDrawer-D40WNAqC.js"),__vite__mapDeps([55,1,2,56,25,38,27,18,7,44,4,57,58,17,6,10,5]),import.meta.url));function Nr(n,r){var c;const a={},i={};for(const[p,h]of Object.entries(n)){const m=h.data;a[p]=xs(m.filter(g=>!g.parentSessionId),r);for(const g of m.filter(l=>l.parentSessionId))(i[c=g.parentSessionId]??(i[c]=[])).push(g)}for(const p of Object.values(i))p.sort((h,m)=>h.created.localeCompare(m.created));return{roots:a,children:i,projectIds:new Set(Object.entries(n).filter(([,p])=>p.loaded).map(([p])=>p))}}function ll(n,r,a){return n==="codex"&&(r==null?void 0:r.canCreateSession)!==!1?!0:a}function gs(n){return{id:n.workspaceId,name:n.name,description:n.roots[0]??"",created:n.updatedAt??"",updated:n.updatedAt??"",agentType:n.agentType,source:n.source,canCreateSession:n.canCreateSession}}function Pr(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4h8v2"}),e.jsx("path",{d:"M19 6l-1 14H6L5 6"}),e.jsx("path",{d:"M10 11v5M14 11v5"})]})}function Rr(n,r){r&&n.detail>0&&n.currentTarget.blur()}function dl(){const n=document.activeElement;n instanceof HTMLElement&&(n.matches("input, textarea, select")||n.isContentEditable)&&n.blur()}function ul(){var sr,rr,ir,or;const[n]=s.useState(Ro),[r]=s.useState(()=>tc(typeof window>"u"?"":window.location.search,n.activeAgent)),a=r.agentType,i=n.agents[a]??ds(),[c]=s.useState(()=>Nr(i.sessions,a)),p=s.useRef(n),[h,m]=s.useState(a),g=s.useRef(h);g.current=h;const[l,u]=s.useState(i.workspaces.map(gs)),[y,j]=s.useState(i.nextCursor),[P,w]=s.useState(i.watermark),[k,v]=s.useState(!1),[O,D]=s.useState(!1),[H,Z]=s.useState(null),[ee,X]=s.useState(!1),[M,T]=s.useState(c.roots),[R,B]=s.useState(""),[V,J]=s.useState(!1),[z,q]=s.useState(null),[Ie,me]=s.useState(!1),[Pe,mt]=s.useState(null);s.useEffect(()=>{if(!V||!window.agentApi)return;let t=!1;return me(!0),mt(null),window.agentApi.listSessions().then(o=>{t||q({agentType:h,sessions:o})}).catch(o=>{t||mt(o instanceof Error?o.message:"会话搜索加载失败")}).finally(()=>{t||me(!1)}),()=>{t=!0}},[V,h]);const[Ee,Je]=s.useState(10),[$,pe]=s.useState(null),[oe,Ae]=s.useState(!1),[K,Qe]=s.useState(null),[Te,ne]=s.useState(!1),[wt,rt]=s.useState(0),[ke,Gt]=s.useState([]),[Ge,ze]=s.useState(c.children),je=s.useRef(M),Me=s.useRef(Ge);je.current=M,Me.current=Ge;const[bt,Dt]=s.useState(c.projectIds),[Ot,it]=s.useState(new Set),[_t,f]=s.useState({}),[S,N]=s.useState(new Set),[I,E]=s.useState(Object.fromEntries(Object.entries(i.sessions).map(([t,o])=>[t,o.nextCursor]))),F=s.useRef(new Map),G=s.useRef(new Map),[U,we]=s.useState(i.selectedWorkspaceId),[L,ie]=s.useState(()=>r.explicit||ve.getState().navigationLayout==="all-sessions"?null:i.selectedSessionId),[he,te]=s.useState(null),xe=s.useRef(null);xe.current=he;const[ye,ot]=s.useState(null),fe=s.useRef(null),Yt=s.useRef(0);fe.current=ye;const mn=s.useCallback(async()=>{const t=++Yt.current;try{const o=await Lo();return t!==Yt.current?fe.current:(fe.current=o,ot(o),o)}catch{return fe.current}},[]);s.useEffect(()=>{mn();let t=!1;const o=()=>{!Lt()||t||(t=!0,mn().finally(()=>{t=!1}))},d=window.setInterval(o,3e4);return window.addEventListener("focus",o),()=>{window.clearInterval(d),window.removeEventListener("focus",o)}},[mn]),s.useEffect(()=>{if(!L)return;const t=ye==null?void 0:ye.get(L);if(!t||t.currentSessionId===L)return;const o=Pn(t);o&&(te(o),Qt(void 0),ie(o.id))},[ye,L]);const We=s.useRef(U),Ze=s.useRef(L);We.current=U,Ze.current=L;const[Jr,_n]=s.useState(new Set),[at,xt]=s.useState(new Set(i.expandedWorkspaceIds)),[yt,Is]=s.useState(new Set),[Es,wn]=s.useState(!1),[As,Ts]=s.useState(!1),[Xt,ct]=s.useState(!1),[Jt,$e]=s.useState(!1),[Qr,Ns]=s.useState(),[Zr,Ps]=s.useState(0),zn=()=>{ct(!1),Ns(void 0),Ps(t=>t+1),$e(!0)};s.useEffect(()=>{var x,A;let t=0;const o=C=>{var Y;if(!C.taskId&&!C.sessionId)return;const W=++t;if(ns(null),qe(!1),Fe(!1),Be(null),ct(!1),C.taskId)(Y=Ne.current)==null||Y.abort(),Ne.current=null,et.current=null,vt(null),Ns(C.taskId),$e(!0),Ps(re=>re+1);else if(C.sessionId){if($e(!1),Pa(C.sessionId))return;window.agentApi.getSession(C.sessionId,{limit:1}).then(re=>{if(W!==t)return;const se=re;Ve.current({kind:"session",session:{id:se.id,agentType:se.agentType??"customer-agent",title:se.title,cwd:se.cwd??"",projectId:se.projectId??void 0}})}).catch(()=>{})}},d=C=>o(C.detail);window.addEventListener("agentroam:notification-open",d);const b=(A=(x=window.agentApi)==null?void 0:x.onNotificationOpen)==null?void 0:A.call(x,o);return()=>{t++,window.removeEventListener("agentroam:notification-open",d),b==null||b()}},[]),s.useEffect(()=>{$e(!1)},[L,U]);const[Rs,Mn]=s.useState([]),[He,Be]=s.useState(null),[zt,Fe]=s.useState(!1),[Ls,Wn]=s.useState(!1),[Mt,qe]=s.useState(!1),[Ds,bn]=s.useState(!1);s.useEffect(()=>{var t,o;(o=(t=window.agentApi)==null?void 0:t.setNotificationVisible)==null||o.call(t,{sessionId:!Jt&&!Xt&&!Mt&&!zt&&!He?L??void 0:void 0})},[L,Jt,Xt,Mt,zt,He]);const[ei,ti]=s.useState(0),[ni,si]=s.useState(!1),[ri,Qt]=s.useState(),[$n,vt]=s.useState(null),Zt=s.useRef(null),[ii,oi]=s.useState({}),Ve=s.useRef(()=>{}),Ne=s.useRef(null),et=s.useRef(null),ai=s.useCallback((t,o)=>{const d=et.current;!d||d.sessionId!==t||d.seed!==o||Ne.current!==d.controller||d.controller.signal.aborted||(et.current=null,Ne.current=null,vt(null),window.parent!==window&&window.parent.postMessage({type:aa,sessionId:t},window.location.origin))},[]),ci=s.useRef(`${Date.now()}-${Math.random().toString(36).slice(2)}`),Hn=Ds||Ls||Rs.length>0,Bn=()=>{if($e(!1),st()&&window.parent!==window){window.parent.postMessage({type:ln,intent:{kind:"dashboard"}},window.location.origin);return}bn(!0),qe(!0),Fe(!1),Be(null)},Fn=()=>{$e(!1),Wn(!0),Fe(!0),Be(null),qe(!1)},[li,qn]=s.useState(!1),[Os,_s]=s.useState(0),xn=t=>{st()&&window.parent!==window?window.parent.postMessage({type:la,groupId:t.id,title:t.name},window.location.origin):(qe(!1),Fe(!1),Mn(o=>o.some(d=>d.id===t.id)?o:[...o,t]),Be(t.id))},[kt,di]=s.useState("settings"),zs=Kt(t=>t.setTodos),en=ve(t=>t.skin),tt=ve(t=>t.layout),Wt=ve(t=>t.navigationLayout),Ue=Wt==="all-sessions",St=ve(t=>t.wakeEnabled),jt=ve(t=>t.wakeWord),ui=ve(t=>t.setSkin),tn=ve(t=>t.setLayout),pi=ve(t=>t.setWakeEnabled),fi=ve(t=>t.setWakeWord),lt=ve(t=>t.runningFirst),hi=ve(t=>t.setRunningFirst),Ms=ve(t=>t.pinnedSessionIds),Vn=ve(t=>t.togglePinnedSession),gi=ve(t=>t.removePinnedSessions),nn=new Set(Ms),Un=Kt(t=>t.runningSessionId),Kn=Kt(Na(t=>Object.entries(t.messagesBySession).filter(([,o])=>Uo(o)).map(([o])=>o))),$t=s.useCallback((t,o=t.projectId)=>Vc({authoritativeStatus:t.status,locallyRunning:Un===t.id,needsInput:Kn.includes(t.id),stale:!!(t.agentType===h&&o&&(S.has(o)||_t[o]))}),[h,_t,Un,Kn,S]),Ws=s.useCallback(t=>{const o=$t(t);return o==="running"||o==="needs-input"},[$t]),mi=()=>{xt(new Set),_n(new Set(Object.keys(Ge)))},wi=()=>{const t=l.filter(d=>!yt.has(d.id)),o=t.map(d=>d.id);xt(new Set(o)),_n(new Set);for(const d of t){const b=d.id;if(Re.current.has(b))continue;const x=pt.current.has(b),A=ll(g.current,d,x);Le(b,{refresh:A,background:x})}},de=st(),Ht=Ec(!de);s.useEffect(()=>{if(!de||window.parent===window)return;const t=o=>{da(o,window.location.origin,window.parent)&&qn(!0)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[de]);const bi=Qi(),xi=Zi(),le=de&&bi,[Ct,Ke]=s.useState(!1),[sn,Gn]=s.useState(!1),[yi,Yn]=s.useState("files"),[$s,Xn]=s.useState(null),[vi,Hs]=s.useState(null),nt=s.useMemo(()=>{var t;return!de&&typeof((t=window.agentApi)==null?void 0:t.fileWorkspaceRequest)=="function"?Bc(window.agentApi):null},[de]),ki=s.useCallback(async t=>{if(de){ha(t);return}if(nt){if(t.startsWith("~/")){const{home:o}=await nt.request("hello"),d=ga(t,null,o);if(!d)return;t=d}Yn("files"),Gn(!0),Xn(t),Hs(o=>ma(t)?null:{path:t,requestId:((o==null?void 0:o.requestId)??0)+1})}},[nt,de]);s.useEffect(()=>{Xn(null),Hs(null)},[U]);const[yn,Jn]=s.useState(!1),[vn,Bs]=s.useState(null),[Si,Fs]=s.useState(0),[ji,qs]=s.useState(void 0),dt=s.useRef(null),It=s.useRef(!1),[Ci,Vs]=s.useState(null),Bt=s.useRef(null),Qn=s.useRef(!1),ut=s.useRef(l);ut.current=l;const Zn=s.useRef(yt);Zn.current=yt;const pt=s.useRef(bt);pt.current=bt;const Re=s.useRef(Ot);Re.current=Ot;const rn=s.useRef(null);s.useEffect(()=>{document.documentElement.setAttribute("data-skin",en)},[en]),s.useEffect(()=>{document.body.classList.toggle("layout-compact",tt==="compact")},[tt]),s.useEffect(()=>{var b;const t=l.map((x,A)=>({agentType:h,workspaceId:x.id,name:x.name,roots:x.description?[x.description]:[],order:A,updatedAt:x.updated||void 0,source:x.source??(x.agentType==="claude-code"?"derived":"native"),canCreateSession:x.canCreateSession})),o=Object.fromEntries(l.map(x=>[x.id,{data:[...M[x.id]??[],...Object.values(Ge).flat().filter(A=>(M[x.id]??[]).some(C=>C.id===A.parentSessionId))],nextCursor:I[x.id]??null,loaded:bt.has(x.id)}])),d={...p.current,version:2,activeAgent:h,agents:{...p.current.agents,[h]:{workspaces:t,nextCursor:y,watermark:P,expandedWorkspaceIds:[...at],selectedWorkspaceId:U,selectedSessionId:L,sidebarScrollTop:((b=rn.current)==null?void 0:b.scrollTop)??0,sessions:o}}};p.current=d,mr(d)},[h,Ge,at,bt,l,U,L,I,M,y,P]);const kn=s.useCallback(()=>{if(!window.agentApi||!St||It.current||dt.current)return;const t=()=>{Mc()&&!dt.current&&(dt.current=Wc({wakeWord:jt,onWake:o=>{var d;qs(o),Fs(b=>b+1),(d=window.agentApi)==null||d.showWindow()},onError:o=>console.warn("[wake]",o)}))};typeof window.agentApi.wakeStart=="function"?(It.current=!0,window.agentApi.wakeStart(jt).then(o=>{o.ok||(It.current=!1,t())}).catch(()=>{It.current=!1,t()})):t()},[St,jt]);s.useEffect(()=>{var t;if((t=window.agentApi)!=null&&t.onWake)return window.agentApi.onWake(o=>{It.current=!1,qs(o),Fs(d=>d+1)})},[]),s.useEffect(()=>{var t;if((t=window.agentApi)!=null&&t.onWakeAiHub)return window.agentApi.onWakeAiHub(()=>{$e(!1),ct(!0),tn("focus")})},[]),s.useEffect(()=>{var t;if((t=window.agentApi)!=null&&t.onWakeCommand)return window.agentApi.onWakeCommand(o=>{var A;const d=((o==null?void 0:o.text)||"").trim();if(!d)return;const b=Bt.current&&Date.now()<Bt.current.until?Bt.current:null;if(b){b.until=Date.now()+9e4,ie(b.sessionId),(A=window.agentApi)==null||A.wakeConversation(!0),Vs({text:d,projectId:null,sessionId:b.sessionId,nonce:Date.now()}),Q(`语音追问:${d.length>40?d.slice(0,40)+"…":d}`),ge("success"),setTimeout(()=>Q(null),4e3);return}const x=ut.current.find(C=>C.name&&d.includes(C.name)&&!Zn.current.has(C.id));x&&(we(x.id),xt(C=>{const W=new Set(C);return W.add(x.id),W})),ie(null),Qn.current=!0,Vs({text:d,projectId:(x==null?void 0:x.id)??null,nonce:Date.now()}),Q(`语音指令:${d.length>40?d.slice(0,40)+"…":d}${x?`(项目:${x.name})`:""}`),ge("success"),setTimeout(()=>Q(null),4e3)})},[]);const Ii=s.useCallback(async()=>{window.agentApi&&(kn(),await window.agentApi.hideWindow())},[kn]),Ei=s.useCallback(t=>{wn(!1),Bs({right:t.right,bottom:t.bottom}),Jn(o=>!o)},[]),Ai=s.useCallback(()=>{Jn(!1),wn(t=>!t)},[]);s.useEffect(()=>{if(!yn)return;const t=()=>{const d=document.querySelector(".chat-header-action--appearance");if(!d)return;const b=d.getBoundingClientRect();Bs(x=>(x==null?void 0:x.right)===b.right&&x.bottom===b.bottom?x:{right:b.right,bottom:b.bottom})},o=window.requestAnimationFrame(t);return window.addEventListener("resize",t),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",t)}},[tt,yn]),s.useEffect(()=>{window.agentApi&&kn()},[kn]),s.useEffect(()=>{const t=()=>{var o;(o=dt.current)==null||o.stop(),dt.current=null};return window.addEventListener("focus",t),()=>window.removeEventListener("focus",t)},[]),s.useEffect(()=>{var t,o;St||((t=dt.current)==null||t.stop(),dt.current=null,It.current=!1,(o=window.agentApi)==null||o.wakeStop())},[St]),s.useEffect(()=>{!St||!window.agentApi||It.current&&window.agentApi.wakeStart(jt)},[jt]),s.useEffect(()=>()=>{var t;(t=dt.current)==null||t.stop()},[]);const Ti=[...Object.values(M).flat(),...Object.values(Ge).flat()],Us=Do((z==null?void 0:z.agentType)===h?z.sessions:[],Ti,h).map(t=>{var o;return{...t,projectId:t.projectId??((o=l.find(d=>d.description===t.cwd))==null?void 0:o.id)}}),Sn=uc(Us,t=>nn.has(t.id)),Ni=Object.entries(M).flatMap(([t,o])=>o.filter(d=>nn.has(d.id)).map(d=>({projectId:t,session:d,created:d.created}))),Ks=xs(Ni,h),Gs=lt?ys(Ks,({session:t})=>Ws(t)):Ks,Pi=Us,Ri=s.useMemo(()=>Object.fromEntries(Object.entries(M).map(([t,o])=>[t,Oo(o,ye)])),[M,ye]),Et=R.trim().toLowerCase(),Ft=Et?Sn.filter(t=>t.title.toLowerCase().includes(Et)||(t.cwd||"").toLowerCase().includes(Et)):null,At=L?Pi.find(t=>t.id===L)??((he==null?void 0:he.id)===L?he:void 0)??(ye!=null&&ye.get(L)?Pn(ye.get(L)):void 0):void 0,Li=At==null?void 0:At.title,qt=(At==null?void 0:At.cwd)||((sr=l.find(t=>t.id===U))==null?void 0:sr.description)||null,es=l.filter(t=>!yt.has(t.id)).map(t=>t.id),Di=[...l.filter(t=>!yt.has(t.id)),...l.filter(t=>yt.has(t.id))],Tt=es.length>0&&es.every(t=>!at.has(t)),{width:jn,collapsed:Vt,dragging:ts,toggle:Cn,resizeProps:Oi}=Yc(),Nt=!le&&(Vt||tt==="focus"),[_i,Q]=s.useState(null),[zi,ge]=s.useState("success"),[ft,ns]=s.useState(null),[In,Ys]=s.useState(!1),Xs=s.useCallback(async()=>{if(!In){Ys(!0);try{const t=await qc();if(t){ct(!1),$e(!1),Ke(!1),ns(t);return}Q("Flow Studio 入口不可用,请检查服务配置"),ge("error"),setTimeout(()=>Q(null),4e3)}finally{Ys(!1)}}},[In]),Ce=t=>{var b;$e(!1);const o=t.sessionId?(b=fe.current)==null?void 0:b.get(t.sessionId):void 0,d=o?Pn(o):void 0;d&&(t={...t,sessionId:d.id},te(d)),We.current=t.projectId,Ze.current=t.sessionId,we(t.projectId),ie(t.sessionId),t.sessionId||zs([])},Ut=(t,o=!1)=>{var W;if(t===g.current&&!o)return;const d=g.current,b=p.current.agents[d];b&&(p.current={...p.current,agents:{...p.current.agents,[d]:{...b,sidebarScrollTop:((W=rn.current)==null?void 0:W.scrollTop)??b.sidebarScrollTop}}});const x=p.current.agents[t]??ds(),A=Nr(x.sessions,t),C=x.workspaces.map(gs);g.current=t,ut.current=C,m(t),u(C),j(x.nextCursor),w(x.watermark),v(!1),D(!1),Z(null),je.current=A.roots,Me.current=A.children,T(A.roots),ze(A.children),Dt(A.projectIds),pt.current=A.projectIds,it(new Set),Re.current=new Set,f({}),N(new Set),E(Object.fromEntries(Object.entries(x.sessions).map(([Y,re])=>[Y,re.nextCursor]))),xt(new Set(x.expandedWorkspaceIds)),Is(new Set),Ce({projectId:x.selectedWorkspaceId,sessionId:x.selectedSessionId}),window.requestAnimationFrame(()=>{rn.current&&(rn.current.scrollTop=x.sidebarScrollTop)}),Ue||Ye(t,{refresh:x.workspaces.length>0,since:x.watermark,refreshLoadedSessions:!Ue})},on=(t,o)=>{var re,se;(re=Ne.current)==null||re.abort(),Ne.current=null,et.current=null,vt(null),Qt(void 0);const d=t??g.current,b=qt;d!==g.current&&Ut(d);const x=p.current.agents[d],A=(x==null?void 0:x.workspaces)??[],C=b?A.find(_=>{var ae;return _.canCreateSession!==!1&&((ae=_.roots)==null?void 0:ae.includes(b))}):void 0,W=x!=null&&x.selectedWorkspaceId&&A.some(_=>_.canCreateSession!==!1&&_.workspaceId===x.selectedWorkspaceId)?x.selectedWorkspaceId:void 0,Y=o??(C==null?void 0:C.workspaceId)??W??((se=A.find(_=>_.canCreateSession!==!1))==null?void 0:se.workspaceId)??null;Zt.current=o||C||!b?null:{agentType:d,preferredPath:b},Ce({projectId:Y,sessionId:null}),Kt.setState({sessionId:null,messages:[]}),qe(!1),bn(!1),Fe(!1),Be(null),ct(!1),tt==="focus"&&tn("standard"),ti(_=>_+1),le&&Ke(!1)};s.useEffect(()=>{const t=Zt.current;if(!t)return;if(L!==null){Zt.current=null;return}if(h!==t.agentType)return;const o=t.preferredPath?l.find(d=>d.canCreateSession!==!1&&d.description===t.preferredPath):void 0;o&&(Zt.current=null,o.id!==U&&Ce(Rn(o.id)))},[h,l,U,L]);const ss=(t,o,d=!1)=>{const b=p.current.agents[t.agentType]??ds();p.current={...p.current,agents:{...p.current.agents,[t.agentType]:{...b,workspaces:o.workspaces,nextCursor:d?b.nextCursor:null,selectedWorkspaceId:t.projectId??null,selectedSessionId:t.id,expandedWorkspaceIds:[...new Set([...b.expandedWorkspaceIds,...t.projectId?[t.projectId]:[]])],sessions:Object.fromEntries(o.workspaces.map(x=>{var A,C;return[x.workspaceId,{data:o.sessions.filter(W=>W.projectId===x.workspaceId),loaded:d?((A=b.sessions[x.workspaceId])==null?void 0:A.loaded)??!1:!0,nextCursor:d?((C=b.sessions[x.workspaceId])==null?void 0:C.nextCursor)??null:null}]}))}}},Ut(t.agentType,!0),qe(!1),Fe(!1),Be(null),le&&Ke(!1)};Ve.current=t=>{var d;if(de&&window.parent!==window&&["dashboard","groups","group"].includes(t.kind)){window.parent.postMessage({type:ln,intent:t},window.location.origin);return}(d=Ne.current)==null||d.abort(),et.current=null;const o=new AbortController;Ne.current=o,vt(t.kind==="session"?t.session:null),t.kind==="session"&&(qe(!1),Fe(!1),Be(null),ct(!1),le&&Ke(!1)),(async()=>{if(t.kind==="dashboard"){Bn();return}if(t.kind==="groups"){Fn();return}if(t.kind==="new-session"){on();return}if(t.kind==="group"){const se=t.discussionId,_=await ht({action:"group",groupId:t.groupId});oi(ae=>({...ae,[_.id]:se})),xn(_);return}if(t.kind==="session"){const se=fe.current,_=se==null?void 0:se.get(t.session.id),ae=_?Pn(_):void 0;ae&&(t={...t,session:{...t.session,...ae}})}const b=t.kind==="agent"?t.agentType:t.session.agentType,x=ke.some(se=>se.agentType===b)?ke:await window.agentApi.getRuntimeHealth();if(o.signal.aborted)return;x!==ke&&Gt(x);const A=eo(b,x);if(A)throw new Error(A);if(t.kind==="agent"){Ut(t.agentType),qe(!1),Fe(!1),Be(null),B(""),J(!1),tt==="focus"&&tn("standard"),Vt&&Cn(),le&&Ke(!0);return}const C=p.current.agents[t.session.agentType],W=C?{workspaces:C.workspaces,sessions:Object.values(C.sessions).flatMap(se=>se.data)}:void 0,Y=Ze.current!==t.session.id&&Kt.getState().getMessagesForSession(t.session.id).length>0?nc(t.session,W):void 0;if(Y){Qt(void 0),et.current={controller:o,sessionId:Y.session.id},ss(Y.session,Y.snapshot,!0),vt(null);return}const re=await sc(window.agentApi,t.session,o.signal,W);o.signal.aborted||(Qt(re.initialHistory),ss(re.session,re.snapshot,!0),et.current={controller:o,sessionId:re.session.id,seed:re.initialHistory})})().catch(b=>{o.signal.aborted||b instanceof Error&&b.name==="AbortError"||(Q(b instanceof Error?b.message:"打开会话失败"),ge("error"),setTimeout(()=>Q(null),5e3))}).finally(()=>{var b;Ne.current===o&&((b=et.current)==null?void 0:b.controller)!==o&&(Ne.current=null,vt(null))})},s.useEffect(()=>{document.body.dataset.agentroamChatNavigation="ready";const t=A=>{const C=br({data:{type:ln,intent:A.detail},origin:window.location.origin,source:window},window.location.origin,window);C&&Ve.current(C)},o=A=>{const C=br(A,window.location.origin,window.parent!==window?window.parent:null);C&&Ve.current(C)};window.addEventListener(ln,t),window.addEventListener("message",o),window.parent!==window&&window.parent.postMessage({type:ca,instanceId:ci.current},window.location.origin);const d=new URLSearchParams(location.search),b=d.get("session"),x=d.get("agent");return b?window.agentApi.getSession(b,b.startsWith("runtime:codex:")?{limit:1,view:"core"}:{limit:1}).then(A=>{const C=A;C.id&&hn(C.agentType)&&Ve.current({kind:"session",session:C})}).catch(A=>{Q(A instanceof Error?A.message:"原会话不可访问"),ge("error")}):d.get("newSession")==="1"?on():hn(x)&&Ve.current({kind:"agent",agentType:x}),()=>{var A;delete document.body.dataset.agentroamChatNavigation,(A=Ne.current)==null||A.abort(),window.removeEventListener(ln,t),window.removeEventListener("message",o)}},[]);const[Js,Qs]=s.useState([]),En=s.useCallback(t=>{Qs(o=>o.filter(d=>d.id!==t))},[]),rs=s.useCallback(t=>{const o=crypto.randomUUID();Qs(d=>[...d,{...t,id:o}]),setTimeout(()=>En(o),12e3)},[En]);async function Ye(t=g.current,o={}){if(!window.agentApi)return;const d=(G.current.get(t)??0)+1;G.current.set(t,d),v(!0),Z(null);try{const b=await window.agentApi.listAgentWorkspaces(t,{cursor:o.cursor,limit:50,refresh:o.refresh,since:o.refresh?o.since??P:null});if(g.current!==t||G.current.get(t)!==d)return;const x=ut.current.map((_,ae)=>({agentType:t,workspaceId:_.id,name:_.name,roots:_.description?[_.description]:[],order:ae,updatedAt:_.updated,source:_.source??(t==="claude-code"?"derived":"native"),canCreateSession:_.canCreateSession})),C=Wo(x,b,!o.cursor,Ze.current?We.current:null).map(gs);ut.current=C,u(C),j(b.nextCursor),w(b.watermark),D(b.stale===!0);const W=new Set(C.map(_=>_.id)),Y=We.current;Y&&!W.has(Y)&&Ce(ps);const re=new Set([...pt.current].filter(_=>W.has(_)));if(Y&&W.has(Y)&&re.add(Y),T(_=>Object.fromEntries(Object.entries(_).filter(([ae])=>W.has(ae)))),Dt(_=>{const ae=new Set([..._].filter(ce=>W.has(ce)));return pt.current=ae,ae}),it(_=>{const ae=new Set([..._].filter(ce=>W.has(ce)));return Re.current=ae,ae}),f(_=>Object.fromEntries(Object.entries(_).filter(([ae])=>W.has(ae)))),Ue)return;const se=new Set;if(await Promise.all(C.map(async _=>{_.description&&!await window.agentApi.checkProjectPath(_.description)&&se.add(_.id)})),g.current!==t||G.current.get(t)!==d)return;if(Is(se),o.refreshLoadedSessions!==!1&&!Ue)for(const _ of re)se.has(_)||Re.current.has(_)||Le(_,{refresh:!0,background:!0})}catch(b){if(g.current!==t||G.current.get(t)!==d)return;ut.current.length>0&&D(!0),Z(b instanceof Error?b.message:"目录加载失败")}finally{g.current===t&&G.current.get(t)===d&&v(!1)}}async function Le(t,o={}){var C;const d=window.agentApi;if(!d||$o((C=p.current.agents[g.current])==null?void 0:C.workspaces.find(W=>W.workspaceId===t))||!o.force&&(o.cursor||o.background)&&Re.current.has(t))return;const b=g.current,x=`${b}:${t}`,A=(F.current.get(x)??0)+1;F.current.set(x,A),it(W=>{const Y=new Set(W).add(t);return Re.current=Y,Y}),f(W=>{if(!(t in W))return W;const Y={...W};return delete Y[t],Y});try{const W=await d.listAgentWorkspaceSessions(b,t,{cursor:o.cursor,limit:20,refresh:o.refresh});if(g.current!==b||F.current.get(x)!==A)return;const Y=je.current[t]??[],re=o.pendingSession?{...o.pendingSession,projectId:t}:void 0,se=re?[re,...Y.filter(Se=>Se.id!==re.id)]:Y,_=new Set(se.map(Se=>Se.id)),ae=[...se,...[..._].flatMap(Se=>Me.current[Se]??[])],ce=Se=>{var lr,dr,ur;if(g.current!==b||F.current.get(x)!==A)return;const Pt=Ho(ae,Se,!o.cursor,We.current===t?Ze.current:null).map(ue=>({...ue,projectId:ue.projectId??t})),Tn=xs(Pt.filter(ue=>!ue.parentSessionId),b),Ki=We.current,an=Ze.current,ar=Bo(Tn,re);Ki===t&&an&&((lr=xe.current)==null?void 0:lr.id)!==an&&!((dr=fe.current)!=null&&dr.has(an))&&!Pt.some(ue=>ue.id===an)&&!ar.some(ue=>ue.id===an)&&Ce(ps);const cn={};for(const ue of Pt.filter(De=>De.parentSessionId))(cn[ur=ue.parentSessionId]??(cn[ur]=[])).push(ue);for(const ue of Object.values(cn))ue.sort((De,Gi)=>De.created.localeCompare(Gi.created));E(ue=>({...ue,[t]:Fo(ae,Se,!o.cursor,ue[t])})),N(ue=>{const De=new Set(ue);return Se.stale?De.add(t):De.delete(t),De});const cr={...je.current,[t]:ar},Nn={...Me.current};for(const ue of _)delete Nn[ue];for(const[ue,De]of Object.entries(cn))Nn[ue]=De;je.current=cr,Me.current=Nn,T(cr),ze(Nn),Dt(ue=>{const De=new Set(ue).add(t);return pt.current=De,De})};if(ce(W),o.refresh&&!o.cursor){const Se=await qo(ae,W,Pt=>d.listAgentWorkspaceSessions(b,t,{cursor:Pt,limit:200,refresh:!1}),re==null?void 0:re.id);Se!==W&&ce(Se)}}catch(W){if(F.current.get(x)!==A)return;N(Y=>new Set(Y).add(t)),f(Y=>({...Y,[t]:W instanceof Error?W.message:"会话加载失败"}))}finally{F.current.get(x)===A&&it(W=>{const Y=new Set(W);return Y.delete(t),Re.current=Y,Y})}}const Mi=async t=>{if(!window.agentApi)return;const o=await window.agentApi.listChildSessions(t);ze(d=>({...d,[t]:o.sort((b,x)=>b.created<x.created?-1:1)}))},is=ni&&!Xt&&!Jt&&!Mt&&!zt&&!He,Wi=(t,o)=>{const d=ut.current.find(b=>b.id===t);if(!(!d||d.canCreateSession===!1)){if(is){os(o,d.description||void 0);return}on(o,t)}},os=(t=g.current,o=qt||void 0)=>{Vo({agentType:t,workspacePath:o}).catch(d=>{Q(d instanceof Error?d.message:"无法打开新会话窗口,请重试"),ge("error")})},Zs=()=>{is?os():zr({kind:"new-session"})};s.useEffect(()=>{var t;window.agentApi&&(Ye(g.current,{refresh:(((t=p.current.agents[g.current])==null?void 0:t.workspaces.length)??0)>0}),_o.getState().loadFromSystem(),window.agentApi.getRuntimeHealth().then(Gt).catch(()=>{}))},[]),s.useEffect(()=>{if(Ue)return;const t=window.setInterval(()=>{!Lt()||k||Ye(h,{refresh:!0,since:P,refreshLoadedSessions:!1})},15e3);return()=>window.clearInterval(t)},[h,Ue,k,P]),s.useEffect(()=>{if(!window.agentApi||Ue)return;let t=!1;const o=()=>{if(t||!Lt())return;const A=Uc(U,at),C=Kc(A,Zn.current,Re.current);for(const W of C)Le(W,{refresh:!0,background:pt.current.has(W)})},d=()=>{Lt()&&o()};le&&Ct&&o();const b=window.setInterval(o,1e4);window.addEventListener("focus",o),window.addEventListener("pageshow",o),document.addEventListener("visibilitychange",d);const x=de&&window.parent!==window?window.parent:null;return x==null||x.addEventListener("focus",o),x==null||x.addEventListener("pageshow",o),()=>{t=!0,window.clearInterval(b),window.removeEventListener("focus",o),window.removeEventListener("pageshow",o),document.removeEventListener("visibilitychange",d),x==null||x.removeEventListener("focus",o),x==null||x.removeEventListener("pageshow",o)}},[h,Ue,at,U,le,Ct,de]),s.useEffect(()=>{if(!U||!window.agentApi)return;const t=l.find(d=>d.id===U),o=t==null?void 0:t.description;o&&window.agentApi.setProjectWorkingDir(o)},[U,l]);const $i=t=>{Ce(Rn(t));const o=!at.has(t);if(xt(d=>{const b=new Set(d);return o?b.add(t):b.delete(t),b}),o){const d=pt.current.has(t);Le(t,{refresh:!0,background:d,force:!0})}},er=async t=>{if(!window.agentApi)throw new Error("agentApi 未就绪,请重启应用");const o=t.replace(/\\/g,"/"),d=o.split("/").filter(Boolean),b=d[d.length-1]||o||"导入的项目",x=await window.agentApi.importAgentWorkspace(g.current,o,b);await Ye(g.current,{refresh:!0,refreshLoadedSessions:!1}),Ce(Rn(x.workspace.workspaceId)),await Le(x.workspace.workspaceId,{refresh:!0}),xt(A=>{const C=new Set(A);return C.add(x.workspace.workspaceId),C}),Q(x.existing?"该文件夹已在当前 Agent 的目录中":`已导入:${x.workspace.name}`),ge(x.existing?"info":"success"),setTimeout(()=>Q(null),3e3)},tr=async()=>{try{if(!window.agentApi){Q("agentApi 未就绪,请重启应用"),ge("error");return}if(de){X(!0);return}const t=await window.agentApi.openFileDialog();if(console.log("[import] selectedPath:",t),!t)return;await er(t)}catch(t){console.error("[import] error:",t),Q(t instanceof Error?t.message:String(t)),ge("error"),setTimeout(()=>Q(null),5e3)}},Hi=async t=>{if(window.agentApi)try{await window.agentApi.deleteProject(t),U===t&&(we(null),ie(null),zs([])),Q("项目删除成功"),ge("success"),setTimeout(()=>Q(null),2500),await Ye()}catch(o){Q(o instanceof Error?o.message:"项目删除失败"),ge("error"),setTimeout(()=>Q(null),4e3)}},Bi=(t,o,d)=>{var A;const b=(A=window.agentApi)==null?void 0:A.showDirectoryContextMenu,x=Hc(o,{isInvalid:d,supported:typeof b=="function",webShell:de});!x||!b||(t.preventDefault(),b(x).catch(C=>{Q(C instanceof Error?C.message:"无法打开当前文件夹"),ge("error"),setTimeout(()=>Q(null),4e3)}))},An=(t,o)=>{pe({session:t,anchor:o})},Fi=(t,o)=>{const d=o.getBoundingClientRect();Qe({project:t,agentType:g.current,anchor:{top:d.top,left:d.left,width:d.width,height:d.height}})},qi=async()=>{if(!window.agentApi||!K||Te)return;const{project:t,agentType:o}=K;ne(!0);try{await window.agentApi.removeInvalidAgentWorkspace(o,t.id),g.current===o&&We.current===t.id&&Ce(ps),Q(`已移除失效目录「${t.name}」`),ge("success"),setTimeout(()=>Q(null),2500),g.current===o&&await Ye(o,{refresh:!0})}catch(d){Q(d instanceof Error?d.message:"目录删除失败"),ge("error"),setTimeout(()=>Q(null),4e3)}finally{ne(!1),Qe(null)}},Vi=async()=>{if(!window.agentApi||!$||oe)return;const{session:t}=$;Ae(!0);try{await window.agentApi.deleteSession(t.id);const o=t.projectId??We.current,d=t.agentType;if(o){const A=`${d}:${o}`;F.current.set(A,(F.current.get(A)??0)+1)}const b=gc(je.current,Me.current,[],t.id);je.current=b.sessionsByProject,Me.current=b.childSessionsByParent,T(b.sessionsByProject),ze(b.childSessionsByParent),gi(b.removedIds);const x=p.current.agents[d];if(x){const A={...p.current,agents:{...p.current.agents,[d]:fc(x,b.removedIds)}};p.current=A,mr(A)}Ze.current&&b.removedIds.includes(Ze.current)&&Ce({projectId:We.current,sessionId:null}),Q("会话删除成功"),ge("success"),setTimeout(()=>Q(null),2500),pe(null),rt(A=>A+1),o&&d===g.current&&Le(o,{refresh:!0,background:!0})}catch(o){Q(o instanceof Error?o.message:"会话删除失败"),ge("error"),setTimeout(()=>Q(null),4e3)}finally{Ae(!1)}},Ui=[{id:"settings",label:"设置"},{id:"mcp",label:"MCP"},{id:"memory",label:"记忆"},{id:"skill",label:"技能"},{id:"agent",label:"智能体"},{id:"lsp",label:"LSP"}],nr=(t,o)=>{const d=L===t.id,b=un($t(t,o)),x=Ge[t.id]??[],A=!Jr.has(t.id);return e.jsxs("div",{className:"sidebar-session-tree",children:[e.jsx(fn,{session:{id:t.id,title:t.title,visualState:b,statusLabel:dn[b],occupiedExternally:t.agentType!=="codex"&&t.occupancy==="owned-externally",canDelete:t.canDelete,active:d,hasChildren:x.length>0,expanded:A,compatibility:t.compatibility,pinned:nn.has(t.id)},onSelect:()=>{le&&Ke(!1),Ce(fs(o,t.id)),x.length>0&&_n(C=>{const W=new Set(C);return W.has(t.id)?W.delete(t.id):W.add(t.id),W})},onPin:()=>Vn(t.id),onDelete:C=>An(t,C)}),e.jsx("div",{className:"sidebar-child-sessions",style:{maxHeight:A?x.length*40:0,opacity:A?1:0},children:x.map(C=>{const W=un($t(C,o));return e.jsx(fn,{session:{id:C.id,title:C.title,visualState:W,statusLabel:dn[W],occupiedExternally:C.agentType!=="codex"&&C.occupancy==="owned-externally",canDelete:C.canDelete,active:L===C.id,child:!0,compatibility:C.compatibility},deleteLabel:"删除子会话",onSelect:()=>{le&&Ke(!1),Ce(fs(o,C.id))},onDelete:Y=>An(C,Y)},C.id)})})]},t.id)};return e.jsxs("div",{className:`app-shell${Nt?" is-sidebar-collapsed":""}${ts?" is-sidebar-dragging":""}${Hn?" has-workspace-tabs":""}`,"data-desktop-platform":!de&&/Mac/.test(navigator.platform)?"darwin":void 0,style:{display:"flex",height:de?"100dvh":"100vh",width:"100vw",background:"var(--bg-deepest)",position:"relative",overflow:"hidden",boxSizing:"border-box",paddingTop:Hn?52:0},children:[e.jsx(cc,{}),e.jsx(ec,{onOpen:Bn}),li&&Oe.createPortal(e.jsx(oa,{cwd:qt||void 0,health:ke,onClose:()=>qn(!1),onCreated:t=>{qn(!1),_s(o=>o+1),xn(t)}}),document.body),Hn&&e.jsx(rc,{groups:Rs,dashboardVisible:Ls,sessionDashboardVisible:Ds,activeId:Mt?"sessions":zt?"dashboard":He??"assistant",onSelect:t=>{qe(t==="sessions"),Fe(t==="dashboard"),Be(["assistant","dashboard","sessions"].includes(t)?null:t)},onClose:t=>{t==="sessions"?(bn(!1),qe(!1)):t==="dashboard"?(Wn(!1),Fe(!1)):(Mn(o=>o.filter(d=>d.id!==t)),He===t&&Be(null))}}),(He||zt||Mt)&&e.jsx("div",{className:"collab-desktop-overlay",children:e.jsx("div",{className:"collab-desktop-body",children:e.jsx(s.Suspense,{fallback:e.jsx(Rt,{label:"正在打开工作区"}),children:Mt?e.jsx(Jc,{onNewSession:Zs,onOpenGroup:t=>Ve.current({kind:"group",groupId:t.group.id,title:t.group.name,discussionId:t.discussionId}),onOpenSession:t=>Ve.current({kind:"session",session:t}),onViewAgent:t=>Ve.current({kind:"agent",agentType:t}),onViewGroups:Fn,onClose:()=>{qe(!1),bn(!1)}}):zt?e.jsx(Xc,{cwd:qt||void 0,onOpen:xn,onClose:()=>{Fe(!1),Wn(!1)},onChanged:(t,o)=>{_s(d=>d+1),Mn(d=>o?d.map(b=>b.id===t?o:b):d.filter(b=>b.id!==t)),!o&&He===t&&Be(null)}}):He&&e.jsx(Qc,{groupId:He,initialDiscussionId:ii[He]},`${He}-${Os}`)})})}),e.jsx(lc,{}),!le&&!ft&&e.jsx(Lc,{hidden:!Nt,value:h,health:ke,selectedSessionId:L,getActivity:$t,onChange:Ut,onUnavailable:t=>{Q(t),ge("info"),setTimeout(()=>Q(null),3e3)},onSelect:ss,onNewSession:t=>{is?os(t):on(t)}}),!ft&&le&&Ct&&e.jsx("div",{className:"mobile-drawer-scrim",onClick:()=>Ke(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:1150}}),!ft&&le&&!Ct&&e.jsx("button",{className:"mobile-drawer-toggle",onClick:()=>Ke(!0),"aria-label":"会话列表","aria-expanded":!1,style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 8px)",left:10,zIndex:1250,width:34,height:34,borderRadius:9,border:"1px solid var(--border-default)",background:"var(--bg-glass, rgba(18,20,28,.82))",color:"var(--text-secondary)",display:"grid",placeItems:"center",backdropFilter:"blur(8px)",WebkitAppRegion:"no-drag",cursor:"pointer"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M3 6h18M3 12h18M3 18h18"})})}),e.jsx("div",{className:"app-accent-glow",style:{position:"absolute",top:"-120px",left:"-80px",width:320,height:320,borderRadius:"50%",background:"radial-gradient(circle, var(--accent-glow) 0%, transparent 70%)",pointerEvents:"none",zIndex:0}}),tt!=="focus"&&!ft&&e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:`app-sidebar${Wt==="agent-rail"?" has-agent-navigation":""}${Ue?" has-all-sessions":""}`,id:"workspace-sidebar","aria-hidden":Nt||le&&!Ct,ref:t=>{t&&(t.inert=Nt||le&&!Ct)},style:{width:jn,flexShrink:0,marginLeft:Nt?-jn:0,display:"flex",flexDirection:"column",background:"var(--bg-surface)",borderRight:"1px solid var(--border-subtle)",padding:de?"12px 0 0":"56px 0 0",position:"relative",zIndex:10,overflow:"hidden",...le?{position:"fixed",top:0,bottom:0,left:0,width:"min(82vw, 320px)",zIndex:1200,transform:Ct?"translateX(0)":"translateX(-103%)",transition:"transform .24s ease",boxShadow:"12px 0 32px rgba(0,0,0,.5)",padding:"calc(env(safe-area-inset-top) + 12px) 0 0"}:{}},children:[!de&&e.jsx("div",{className:"sidebar-window-drag-region","aria-hidden":"true"}),Wt==="agent-rail"?e.jsx(Pc,{value:h,health:ke,onClose:()=>{le?Ke(!1):Cn()}}):e.jsx("div",{className:"app-sidebar-brand",style:{padding:"0 20px 10px"},children:e.jsxs("div",{className:"sidebar-brand-row",children:[e.jsx("div",{className:"sidebar-brand-mark","aria-hidden":"true",children:e.jsx(gn,{agentType:"customer-agent",size:24})}),e.jsx("span",{className:"sidebar-brand-name",children:"AgentRoam"}),e.jsxs("div",{className:"sidebar-brand-actions",children:[e.jsx(Yr,{}),!de&&Wt==="classic"&&e.jsx(Cr,{onOpenFlowStudio:Xs,onOpenCalendar:zn,openingFlowStudio:In})]})]})}),Ue?e.jsx(Ja,{selectedSessionId:L,pendingSession:he,runningSessionId:Un,needsInput:Kn,pinnedIds:Ms,revision:wt,onSelect:t=>Ve.current({kind:"session",session:t}),onPin:Vn,onDelete:(t,o)=>{window.agentApi.getSession(t.id,{limit:1}).then(d=>{const b=d;if(b.id!==t.id||b.agentType!==t.agentType)throw new Error("会话身份已变化,请刷新重试");if(!b.canDelete)throw new Error("当前会话暂不可删除");An(b,o)}).catch(d=>{Q(d instanceof Error?d.message:"无法读取会话"),ge("error")})}}):e.jsxs(e.Fragment,{children:[e.jsx(Dr,{vertical:Wt==="agent-rail",value:h,health:ke,onChange:Ut,onUnavailable:t=>{Q(t),ge("info"),setTimeout(()=>Q(null),3e3),window.agentApi.getRuntimeHealth().then(Gt).catch(()=>{})}}),e.jsxs("button",{type:"button",className:"sidebar-search-field",onClick:()=>{J(!0),Je(10)},title:"搜索会话","aria-label":"搜索会话",children:[e.jsx(On,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:"搜索会话"}),e.jsx("kbd",{children:"⌘ K"})]}),e.jsxs("div",{className:"sidebar-project-toolbar",children:[e.jsxs("div",{className:"sidebar-project-heading",children:[e.jsx("span",{className:"sidebar-project-title",children:"目录"}),e.jsx("span",{className:"sidebar-project-count","aria-label":`${l.length} 个目录`,children:l.length})]}),e.jsxs("div",{className:"sidebar-project-actions",children:[e.jsx("button",{type:"button",onClick:t=>{Tt?wi():mi(),Rr(t,Tt)},title:Tt?"展开全部会话":"折叠全部会话","aria-label":Tt?"展开全部会话":"折叠全部会话","aria-pressed":Tt,disabled:es.length===0,className:`ui-icon-button sidebar-collapse-all${Tt?" is-active":""}`,children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Tt?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m7 6 5 5 5-5"}),e.jsx("path",{d:"m7 13 5 5 5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m17 11-5-5-5 5"}),e.jsx("path",{d:"m17 18-5-5-5 5"})]})})}),e.jsx("button",{type:"button",onClick:t=>{hi(!lt),Rr(t,lt)},title:lt?"按新建时间排序":"进行中会话优先","aria-label":lt?"按新建时间排序":"进行中会话优先","aria-pressed":lt,className:`ui-icon-button sidebar-session-sort${lt?" is-active":""}`,children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h10M3 12h7M3 18h4"}),e.jsx("path",{d:"m15 9 3-3 3 3M18 6v12"})]})}),e.jsx(Ur,{loading:k,error:l.length>0?null:H,onRefresh:()=>void Ye(h,{refresh:!0})}),e.jsx("button",{type:"button",onClick:()=>void tr(),title:"导入目录","aria-label":"导入目录",className:"ui-icon-button",children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]})]}),e.jsx("div",{ref:rn,className:"app-sidebar-scroll",onPointerDownCapture:dl,onScroll:t=>{const o=t.currentTarget;if(o.scrollHeight-o.scrollTop-o.clientHeight<120&&y&&!k&&Ye(h,{cursor:y}),le){const b=o.getBoundingClientRect(),x=o.querySelectorAll("[data-sidebar-project-id]");for(const A of x){const C=A.dataset.sidebarProjectId;if(!C||!at.has(C))continue;const W=A.getBoundingClientRect();if(W.bottom<b.top||W.bottom>b.bottom+120)continue;const Y=I[C];Y&&!Re.current.has(C)&&Le(C,{cursor:Y})}}},style:{minHeight:0,flex:1,overflow:"auto",padding:"0 10px"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,marginBottom:12},children:[Gs.length>0&&e.jsxs("section",{className:"sidebar-pinned-section","aria-label":"置顶会话",children:[e.jsx("div",{className:"sidebar-pinned-heading",children:"置顶"}),Gs.map(({projectId:t,session:o})=>nr(o,t))]}),Di.map(t=>{var ae;const o=U===t.id&&L===null,d=at.has(t.id),b=bt.has(t.id),x=Ot.has(t.id),A=_t[t.id],C=Ri[t.id]??[],W=C.filter(ce=>!nn.has(ce.id)),re=lt?ys(W,Ws):W,se=re.length>10,_=yt.has(t.id);return e.jsxs("div",{className:"sidebar-project-block","data-sidebar-project-id":t.id,"aria-busy":x,children:[e.jsxs("div",{className:`sidebar-row sidebar-project-row${_?" sidebar-project-row--invalid":""} ${o&&!_?"sidebar-row-active":""}`,onContextMenu:ce=>Bi(ce,t,_),style:{paddingRight:4},children:[e.jsxs("button",{className:"sidebar-project-button",onClick:()=>{_||$i(t.id)},disabled:_,"aria-expanded":d,"aria-pressed":o,title:_?`路径不存在:${t.description}`:t.name,style:{flex:1,display:"flex",alignItems:"center",gap:8,minWidth:0,padding:"8px 10px",border:"none",background:"transparent",color:_?"var(--text-muted)":o?"var(--accent)":"var(--text-secondary)",fontSize:13,fontWeight:o&&!_?600:400,cursor:_?"not-allowed":"pointer",textAlign:"left",transition:"color 0.15s"},children:[_?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:.6},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):t.canCreateSession===!1?e.jsx(wa,{size:13,"aria-hidden":"true",style:{flexShrink:0,opacity:o?1:.5}}):e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:o?1:.5},children:d?e.jsx("path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6A2 2 0 0 1 18.46 20H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}):e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]}),h==="customer-agent"&&!de&&!_&&t.canCreateSession!==!1?e.jsx("button",{onClick:ce=>{ce.stopPropagation(),Hi(t.id)},title:"删除目录","aria-label":`删除目录:${t.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:e.jsx(Pr,{})}):_?e.jsx("button",{onClick:ce=>{ce.stopPropagation(),Fi(t,ce.currentTarget)},title:"删除失效目录","aria-label":`删除失效目录:${t.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:e.jsx(Pr,{})}):null,!_&&t.canCreateSession!==!1&&e.jsx("button",{type:"button",onClick:ce=>{ce.stopPropagation(),Wi(t.id,h)},title:`在 ${t.name} 中新建会话`,"aria-label":`在 ${t.name} 中新建会话`,disabled:_||((ae=ke.find(ce=>ce.agentType===h))==null?void 0:ae.available)===!1,className:"sidebar-runtime-create sidebar-project-add-action ui-icon-button ui-icon-button--small",children:e.jsx(Ln,{size:13,"aria-hidden":"true"})})]}),e.jsx("div",{style:{overflow:"hidden",maxHeight:d?le?1e5:se?300:800:0,opacity:d?1:0,transition:"max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease"},children:e.jsxs("div",{className:"sidebar-project-sessions",onScroll:ce=>{const Se=ce.currentTarget,Pt=Se.scrollHeight-Se.scrollTop-Se.clientHeight<80,Tn=I[t.id];Pt&&Tn&&!x&&Le(t.id,{cursor:Tn})},style:{display:"flex",flexDirection:"column",gap:1,marginTop:2,paddingLeft:10,paddingBottom:4,...se&&!le?{maxHeight:280,overflowY:"auto"}:{}},children:[re.map(ce=>nr(ce,t.id)),x&&!b&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"正在加载会话..."}),A&&!I[t.id]&&e.jsxs("div",{title:A,style:{display:"flex",alignItems:"center",gap:8,color:"var(--danger)",fontSize:11,padding:"4px 10px"},children:[e.jsx("span",{style:{flex:1},children:"会话加载失败"}),e.jsx("button",{type:"button",onClick:()=>void Le(t.id,{refresh:b,background:b}),style:{border:0,background:"transparent",color:"inherit",fontSize:11,cursor:"pointer",padding:0},children:"重试"})]}),S.has(t.id)&&!A&&e.jsx("div",{className:"sidebar-cache-state",children:"显示缓存,会话将在下次刷新时更新"}),C.length===0&&b&&!x&&!A&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"暂无会话"}),e.jsx(Qa,{cursor:I[t.id]??null,expanded:d&&b&&!_,loading:x,error:A,nestedScroll:se&&!le,projectName:t.name,onLoadMore:()=>{const ce=I[t.id];ce&&Le(t.id,{cursor:ce})}})]})})]},t.id)}),l.length===0&&k&&e.jsx("div",{className:"sidebar-directory-skeleton","aria-hidden":"true",children:[0,1,2].map(t=>e.jsxs("div",{children:[e.jsx("span",{}),e.jsx("span",{})]},t))}),l.length===0&&!k&&!H&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"24px 10px",textAlign:"center",opacity:.7},children:"暂无目录"}),H&&l.length>0&&e.jsxs("div",{className:"sidebar-cache-state sidebar-cache-state--action",role:"status",title:H,children:[e.jsx("span",{children:"当前显示缓存目录"}),!k&&e.jsx("button",{type:"button",onClick:()=>void Ye(h,{refresh:!0}),children:"重试"})]}),O&&!H&&e.jsx("div",{className:"sidebar-cache-state",children:"当前显示缓存目录"}),H&&l.length===0&&e.jsxs("div",{className:"sidebar-load-error",title:H,children:[e.jsx("span",{children:"目录加载失败"}),e.jsx("button",{type:"button",onClick:()=>void Ye(h,{refresh:!1}),children:"重试"})]})]})})]}),e.jsxs("div",{className:"sidebar-bottom-action",children:[!Ue&&e.jsx(Za,{refreshKey:Os,onOpen:xn}),e.jsxs("button",{type:"button",className:"sidebar-new-session-primary",title:"新建会话",onClick:Zs,children:[e.jsx(Ln,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]})]})]}),$&&e.jsx(Er,{message:pc($.session),anchor:$.anchor,mobile:le,pending:oe,onCancel:()=>pe(null),onConfirm:()=>void Vi()}),K&&e.jsx(Er,{title:"删除失效目录",message:`目录「${K.project.name}」的路径(${K.project.description||"未知"})已不存在。确定从目录列表移除?历史会话记录会保留。`,anchor:K.anchor,mobile:le,pending:Te,onCancel:()=>Qe(null),onConfirm:()=>void qi()}),!le&&e.jsx("div",{className:`app-sidebar-resizer${ts?" is-dragging":""}`,...Oi,role:"separator","aria-label":"调整目录与会话列表宽度","aria-controls":"workspace-sidebar","aria-orientation":"vertical","aria-valuemin":220,"aria-valuemax":480,"aria-valuenow":jn,tabIndex:Vt?-1:0,hidden:Vt&&!ts,style:{left:Vt?0:jn}}),V&&e.jsx("div",{onClick:()=>J(!1),style:{position:"fixed",inset:0,zIndex:1300,background:"rgba(17,24,39,0.34)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"12vh 16px 16px"},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{width:"min(560px, 100%)",maxHeight:"64vh",display:"flex",flexDirection:"column",borderRadius:12,border:"1px solid var(--border-default)",background:"var(--bg-surface)",boxShadow:"0 18px 48px rgba(17,24,39,0.28)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:10,borderBottom:"1px solid var(--border-subtle)"},children:e.jsx("input",{autoFocus:!0,value:R,onChange:t=>B(t.target.value),onKeyDown:t=>{t.key==="Escape"&&J(!1)},placeholder:"搜索所有会话(标题或目录)…","aria-label":"搜索所有会话",style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",boxSizing:"border-box"}})}),e.jsxs("div",{style:{overflowY:"auto",padding:8},children:[Ie&&e.jsx("div",{role:"status",children:"正在加载所有会话"}),Pe&&e.jsx("div",{role:"alert",children:Pe}),Et&&Ft&&Ft.length>0&&e.jsxs("div",{style:{padding:"4px 10px 3px",fontSize:9,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-muted)"},children:[Ft.length," 个结果"]}),!Ie&&!Pe&&Et&&Ft&&Ft.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"无匹配会话"}),!Ie&&!Pe&&!Et&&Sn.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"暂无会话"}),(Ft??Sn.slice(0,Ee)).map(t=>{const o=L===t.id,d=un($t(t));return e.jsx(fn,{session:{id:t.id,title:t.title,visualState:d,statusLabel:dn[d],occupiedExternally:t.agentType!=="codex"&&t.occupancy==="owned-externally",canDelete:t.canDelete,active:o,child:!!t.parentSessionId,compatibility:t.compatibility,pinned:nn.has(t.id)},onSelect:()=>{const b=t.projectId&&l.some(x=>x.id===t.projectId)?t.projectId:null;Ce(fs(b,t.id)),J(!1),le&&Ke(!1)},onPin:t.parentSessionId?void 0:()=>Vn(t.id),onDelete:b=>An(t,b)},t.id)}),!Et&&Sn.length>Ee&&e.jsx("button",{type:"button",onClick:()=>Je(t=>t+10),style:{width:"100%",padding:"8px 10px",border:0,borderTop:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-muted)",fontSize:12,cursor:"pointer",textAlign:"center"},children:"更多…"})]})]})})]}),e.jsx(_c,{message:_i,type:zi}),e.jsxs("main",{className:`app-main${nt?" file-workspace-capable":""}${sn&&nt?" file-workspace-open":""}${sn&&nt&&$s?" file-workspace-preview-open":""}`,style:{flex:1,minWidth:0,marginLeft:Nt&&!ft?56:0,overflow:"hidden",background:"var(--bg-workspace)",position:"relative",zIndex:5},children:[e.jsx("div",{className:"app-chat-surface","aria-hidden":$n?!0:void 0,ref:t=>{t&&(t.inert=!!$n)},style:{height:"100%",paddingTop:0,display:Xt||Jt?"none":void 0,background:"var(--chat-history-bg)"},children:e.jsx(Xa,{onSplitChange:si,enabled:xi||!de&&!to(),onOpenCalendar:zn,onFocusSession:t=>{Ze.current=t.id,We.current=t.projectId??null,te(t),ie(t.id),we(t.projectId??null)},onNavigateSession:t=>Ve.current({kind:"session",session:t}),onSessionCreated:t=>{if(t.projectId&&t.agentType===g.current){const o=t.projectId;T(d=>({...d,[o]:[t,...(d[o]??[]).filter(b=>b.id!==t.id)]}))}rt(o=>o+1)},children:e.jsx(zo,{sidebarCollapsed:Nt,onToggleSidebar:!le&&!ft?()=>{tt==="focus"?(tn("standard"),Vt&&Cn()):Cn()}:void 0,onOpenCollaborationDashboard:de?void 0:Fn,onOpenSessionDashboard:de?void 0:Bn,activeAgentType:h,selectedProjectId:U,selectedSessionId:L,sessionTitle:Li,sessionSummary:At,initialSessionHistory:ri,onSessionHistorySettled:ai,workspacePath:qt,workspaceSource:(rr=l.find(t=>t.id===U))==null?void 0:rr.source,runtimeHealth:ke,onSelectAgent:on,workspaces:l.map(t=>({id:t.id,name:t.name,path:t.description,canCreateSession:t.canCreateSession})),onSelectWorkspace:t=>{Zt.current=null,Ce(Rn(t)),xt(o=>new Set(o).add(t))},onPickWorkspaceFolder:()=>void tr(),focusComposerNonce:ei,voiceCommand:Ci,onOpenSettings:Ai,settingsOpen:Es,desktopLiveOpen:As,fileDrawerOpen:sn,onOpenArtifact:ki,onToggleFiles:nt?()=>{Gn(t=>!t),Yn("files")}:void 0,onOpenDesktopLive:!de&&((ir=window.agentApi)!=null&&ir.desktopLiveGetStatus)?()=>Ts(!0):void 0,onHideToBackground:()=>void Ii(),onOpenHub:(or=window.agentApi)!=null&&or.hubGetConfig?()=>{$e(!1),ct(!0)}:void 0,headerAppActions:!de&&Wt!=="classic"?e.jsx(Cr,{onOpenFlowStudio:Xs,onOpenCalendar:zn,openingFlowStudio:In}):void 0,onToggleAppearance:Ei,appearanceOpen:yn,hideToBackgroundTitle:St?`隐藏到后台(说“${jt}”唤醒)`:"隐藏到后台",onSessionCreated:(t,o)=>{var b;te(o??null);const d=We.current;if(d&&o){const x=`${o.agentType}:${d}`;F.current.set(x,(F.current.get(x)??0)+1),Re.current.delete(d),it(new Set(Re.current));const A={...je.current,[d]:[{...o,projectId:d},...(je.current[d]??[]).filter(C=>C.id!==t)]};je.current=A,T(A)}Ce({projectId:d,sessionId:t}),rt(x=>x+1),Qn.current&&(Qn.current=!1,Bt.current={sessionId:t,until:Date.now()+9e4},(b=window.agentApi)==null||b.wakeConversation(!0)),d&&g.current==="customer-agent"&&Le(d,{pendingSession:o,background:!0})},onSubSessionCreated:async t=>{await Mi(t)},onSelectSession:(t,o)=>{o&&te(o),ie(t),mn()},onParallelSessionSelected:t=>{var d;(d=Ne.current)==null||d.abort(),Ne.current=null,et.current=null,vt(null),Qt(void 0),g.current!==t.agentType&&Ut(t.agentType),te(t);const o=t.projectId&&ut.current.some(b=>b.id===t.projectId)?t.projectId:null;Ce({projectId:o,sessionId:t.id}),Kt.getState().setSessionId(t.id),rt(b=>b+1)},onSubAgentEvent:t=>{t.type==="started"?rs({type:"info",title:"子会话已启动",body:`${t.agentName}:${t.task.slice(0,60)}`,sessionId:t.subSessionId}):t.type==="completed"?rs({type:"success",title:"子会话已完成",body:`${t.agentName}:${t.task.slice(0,60)}`,sessionId:t.subSessionId}):rs({type:"error",title:"子会话出错",body:`${t.agentName}:${t.task.slice(0,60)}`,sessionId:t.subSessionId})},onMessageSent:(t,o)=>{T(d=>{const b={};for(const[x,A]of Object.entries(d))b[x]=A.map(C=>C.id===t?{...C,title:o.slice(0,60)||C.title}:C);return b})},onRunComplete:async(t,o)=>{var A;const d=Bt.current,b=Mo(d,o);Bt.current=b,b!==d&&((A=window.agentApi)==null||A.wakeConversation(!0));const x=t||U;x&&await Le(x,{refresh:!0,background:!0})}})})}),Jt&&e.jsx(s.Suspense,{fallback:e.jsx(Rt,{label:"正在打开日历"}),children:e.jsx(el,{loadOverview:tl,onClose:()=>$e(!1),initialTaskId:Qr,focusKey:Zr})}),$n&&e.jsx(Rt,{className:"session-navigation-loading"}),Xt&&e.jsx(s.Suspense,{fallback:e.jsx(Rt,{label:"正在打开 AI Hub"}),children:e.jsx(Zc,{conversationId:L,onExit:()=>ct(!1)})}),nt&&sn&&e.jsx(s.Suspense,{fallback:e.jsx(Rt,{label:"正在打开文件"}),children:e.jsx(cl,{open:sn,tab:yi,gateway:nt,cwd:qt,selectedPath:$s,revealRequest:vi,onTabChange:Yn,onSelectPath:Xn,onClose:()=>Gn(!1)})}),ft&&e.jsx(Dc,{entryUrl:ft,onBack:()=>ns(null)})]}),As&&e.jsx(bc,{onClose:()=>Ts(!1)}),Es&&Oe.createPortal(e.jsx("div",{"data-task-page-overlay":"",onClick:()=>wn(!1),style:{position:"fixed",inset:0,zIndex:10001,background:"rgba(17,24,39,0.18)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s var(--ease-out)",WebkitAppRegion:"no-drag"},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{width:"min(920px, calc(100vw - 48px))",height:"min(760px, calc(100vh - 48px))",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"var(--shadow-md)",overflow:"hidden",display:"flex",flexDirection:"column",animation:"fadeInUp 0.25s var(--ease-out)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)",padding:"8px 10px",background:"var(--bg-deepest)"},children:[e.jsx("div",{style:{display:"flex",gap:6},children:Ui.map(t=>e.jsx("button",{onClick:()=>di(t.id),className:`settings-tab ${kt===t.id?"settings-tab-active":""}`,children:t.label},t.id))}),e.jsx("button",{onClick:()=>wn(!1),title:"关闭",className:"ui-icon-button ui-icon-button--close ui-icon-button--danger",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsxs(s.Suspense,{fallback:e.jsx(Rt,{label:"正在打开设置"}),children:[kt==="settings"&&e.jsx(nl,{}),kt==="mcp"&&e.jsx(sl,{}),kt==="memory"&&e.jsx(rl,{}),kt==="skill"&&e.jsx(il,{}),kt==="agent"&&e.jsx(ol,{}),kt==="lsp"&&e.jsx(al,{})]})})]})}),document.body),e.jsx("div",{className:"noise-overlay"}),yn&&vn&&Oe.createPortal(e.jsx("div",{"data-task-page-overlay":"",onClick:()=>Jn(!1),style:{position:"fixed",inset:0,zIndex:1e4,WebkitAppRegion:"no-drag"},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),className:"appearance-panel",style:{position:"absolute",left:Math.max(12,Math.min(vn.right-320,window.innerWidth-332)),top:vn.bottom+8,width:320,maxHeight:`calc(100vh - ${vn.bottom+20}px)`,overflowY:"auto",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"16px",display:"flex",flexDirection:"column",gap:16,animation:"fadeInUp 0.2s var(--ease-out)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"皮肤"}),e.jsx("div",{className:"appearance-choices",children:no.map(t=>e.jsxs("button",{onClick:()=>ui(t.id),className:`appearance-choice ${en===t.id?"appearance-choice-active":""}`,children:[e.jsx("span",{className:"appearance-swatch",style:{background:`linear-gradient(135deg, ${t.preview[0]} 55%, ${t.preview[1]} 55%)`}}),e.jsx("span",{className:"appearance-choice-label",style:{fontWeight:en===t.id?600:400},children:t.label}),en===t.id&&e.jsx("svg",{className:"appearance-choice-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},t.id))})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"布局"}),e.jsx("div",{className:"appearance-segmented",children:so.map(t=>e.jsx("button",{onClick:()=>tn(t.id),title:t.description,className:`appearance-segment ${tt===t.id?"appearance-segment-active":""}`,children:t.label},t.id))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,borderTop:"1px solid var(--border-subtle)",paddingTop:12},children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"语音"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--text-secondary)",cursor:"pointer"},children:["隐藏后语音唤醒",e.jsx("input",{className:"appearance-switch",type:"checkbox",checked:St,onChange:t=>pi(t.target.checked)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-secondary)"},children:[e.jsx("span",{style:{flexShrink:0},children:"唤醒词"}),e.jsx("input",{value:jt,onChange:t=>fi(t.target.value||"小智"),style:{flex:1,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-deep)",color:"var(--text-primary)",fontSize:12}})]})]})]})}),document.body),e.jsx(fa,{open:ee,onCancel:()=>X(!1),onConfirm:async t=>{await er(t),X(!1)}}),e.jsx(xc,{trigger:Si,heardText:ji}),Ht.items.length>0&&Oe.createPortal(e.jsx(jc,{items:Ht.items,onDismiss:Ht.consume,onClearAll:Ht.clearAll,onOpen:t=>{Ht.consume(t),window.dispatchEvent(new CustomEvent("agentroam:notification-open",{detail:t}))}}),document.body),Js.length>0&&Ht.items.length===0&&Oe.createPortal(e.jsx("div",{style:{position:"fixed",bottom:24,right:24,zIndex:2e4,display:"flex",flexDirection:"column",gap:10,alignItems:"flex-end",pointerEvents:"none"},children:Js.map(t=>e.jsxs("div",{style:{pointerEvents:"auto",width:320,background:"var(--bg-surface)",border:`1px solid ${t.type==="error"?"rgba(220,38,38,0.25)":t.type==="success"?"rgba(5,150,105,0.25)":"var(--border-default)"}`,borderLeft:`3px solid ${t.type==="error"?"var(--danger)":t.type==="success"?"var(--success)":"var(--accent)"}`,borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"12px 14px",animation:"fadeInUp 0.22s var(--ease-out)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:t.type==="error"?"var(--danger)":t.type==="success"?"var(--success)":"var(--accent)",display:"flex",alignItems:"center",gap:5},children:[t.type==="error"?"✕":t.type==="success"?"✓":"◎"," ",t.title]}),e.jsx("button",{onClick:()=>En(t.id),title:"关闭",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:14,lineHeight:1,padding:"2px 4px",borderRadius:4,transition:"color 0.15s"},onMouseEnter:o=>o.currentTarget.style.color="var(--text-primary)",onMouseLeave:o=>o.currentTarget.style.color="var(--text-muted)",children:"×"})]}),e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--text-secondary)",lineHeight:1.5,wordBreak:"break-all"},children:t.body}),t.sessionId&&e.jsx("button",{onClick:()=>{ie(t.sessionId),En(t.id)},style:{marginTop:8,padding:"4px 10px",fontSize:11,fontWeight:500,background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--border-glow)",borderRadius:6,cursor:"pointer",transition:"background 0.15s",WebkitAppRegion:"no-drag"},onMouseEnter:o=>o.currentTarget.style.background="var(--accent-glow)",onMouseLeave:o=>o.currentTarget.style.background="var(--accent-dim)",children:"进入会话 →"})]},t.id))}),document.body)]})}const _l=Object.freeze(Object.defineProperty({__proto__:null,default:ul},Symbol.toStringTag,{value:"Module"}));export{_c as A,_l as a};
@@ -1,36 +0,0 @@
1
- import{c as g,r as n,j as e,n as Ce,R as Se}from"./index-d8fS3JdV.js";import{C as Ae}from"./calendar-days-D1OJEOKr.js";import{X as Y}from"./x-1GQMVfza.js";import{C as $e}from"./chevron-right-DVhYkZeF.js";import{L as ze}from"./locate-fixed-UXM91vCS.js";import{C as q}from"./check-BDiCDSY5.js";import{P as ue}from"./pause-_h6c8qPD.js";import{L as B}from"./list-todo-F1W4yBLx.js";import{C as De}from"./chevron-down-DIt_NscV.js";/**
2
- * @license lucide-react v0.468.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const me=g("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
7
- * @license lucide-react v0.468.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const pe=g("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
12
- * @license lucide-react v0.468.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const de=g("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
17
- * @license lucide-react v0.468.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const xe=g("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/**
22
- * @license lucide-react v0.468.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Me=g("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
27
- * @license lucide-react v0.468.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const P=g("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
32
- * @license lucide-react v0.468.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Le=g("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),V=["customer-agent","codex","claude","workbuddy","zcode","opencode","deepseek"],w={"customer-agent":"AgentRoam",codex:"Codex",claude:"Claude Code",workbuddy:"WorkBuddy",zcode:"ZCode",opencode:"OpenCode",deepseek:"DeepSeek"};function D(a){const l=new Date(a),u=`${l.getMonth()+1}`.padStart(2,"0"),x=`${l.getDate()}`.padStart(2,"0");return`${l.getFullYear()}-${u}-${x}`}const oe=["一","二","三","四","五","六","日"],he={all:"全部",cron:"定时",run:"执行",reminder:"提醒",due:"待办日期"},Ee={upcoming:"待执行",paused:"已暂停",completed:"已完成",failed:"失败",overdue:"已过期",pending:"待处理","in-progress":"进行中",unscheduled:"未排期"},Te=3e4;function Re(a){const l=new Date(a);return l.setHours(0,0,0,0),l.getTime()}function M(a){const l=new Date(a);return`${`${l.getHours()}`.padStart(2,"0")}:${`${l.getMinutes()}`.padStart(2,"0")}`}function Ie(a,l){return`${a}年${l+1}月`}function Fe(a,l){const u=new Date(a,l,1),x=(u.getDay()+6)%7,p=Re(u.getTime())-x*864e5;return Array.from({length:42},(W,L)=>{const N=p+L*864e5,v=new Date(N);return{key:D(N),day:v.getDate(),inMonth:v.getMonth()===l,ms:N}})}function Ke({kind:a,size:l=12}){return a==="cron"?e.jsx(xe,{size:l,"aria-hidden":"true"}):a==="run"?e.jsx(Le,{size:l,"aria-hidden":"true"}):e.jsx(pe,{size:l,"aria-hidden":"true"})}function Oe({state:a}){return a==="completed"?e.jsx(q,{size:12,className:"cal-mark is-done","aria-label":"已完成"}):a==="failed"?e.jsx(Y,{size:12,className:"cal-mark is-fail","aria-label":"失败"}):a==="in-progress"?e.jsx("span",{className:"cal-pulse","aria-label":"进行中"}):a==="paused"?e.jsx(ue,{size:11,className:"cal-mark is-pause","aria-label":"已暂停"}):null}function _e({entry:a,onClick:l,highlighted:u}){const x=`cal-chip kind-${a.kind} is-${a.state}${u?" is-highlight":""}`,p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cal-chip-dot","aria-hidden":"true"}),e.jsx("span",{className:"cal-chip-time",children:a.kind==="todo"?a.dueAt?M(a.dueAt):"待办":M(a.at)}),e.jsx("span",{className:"cal-chip-title",children:a.title}),e.jsx(Oe,{state:a.state}),a.state==="overdue"&&e.jsx("span",{className:"cal-tag is-overdue",children:"过期"}),a.state==="paused"&&e.jsx("span",{className:"cal-tag is-paused",children:"暂停"})]});return l?e.jsx("button",{type:"button",className:x,"data-source":a.source,onClick:l,title:`${w[a.source]} · ${a.title}`,children:p}):e.jsx("div",{className:x,"data-source":a.source,title:`${w[a.source]} · ${a.title}`,children:p})}function Ue({entry:a,highlighted:l}){return e.jsxs("article",{className:`cal-entry is-${a.state}${l?" is-highlight":""}`,"data-source":a.source,"data-task-id":a.taskId,children:[e.jsxs("div",{className:"cal-entry-top",children:[e.jsx("span",{className:"cal-entry-src","data-source":a.source,children:w[a.source]}),e.jsx("span",{className:`cal-entry-state is-${a.state}`,children:Ee[a.state]??a.state}),e.jsxs("span",{className:"cal-entry-time",children:[e.jsx(Ke,{kind:a.kind}),a.kind==="todo"?a.dueAt?M(a.dueAt):"无截止":M(a.at)]})]}),e.jsx("h4",{className:`cal-entry-title ${a.state==="completed"?"is-struck":""}`,children:a.title}),e.jsxs("div",{className:"cal-entry-meta",children:[a.scheduleLabel&&e.jsxs("span",{className:"cal-meta-pill",children:[e.jsx(me,{size:11}),a.scheduleLabel]}),a.recurring&&e.jsxs("span",{className:"cal-meta-pill",children:[e.jsx(xe,{size:11}),"循环"]}),a.sessionTitle&&e.jsxs("span",{className:"cal-meta-pill",title:a.sessionTitle,children:[e.jsx(B,{size:11}),a.sessionTitle]})]}),a.executedAt!==void 0&&e.jsxs("p",{className:"cal-entry-detail",children:["执行记录:",new Date(a.executedAt).toLocaleString("zh-CN",{hour12:!1})]}),a.kind==="cron"&&a.state==="overdue"&&e.jsx("p",{className:"cal-entry-detail",children:"计划时间已过,未找到执行结果;不代表执行成功或失败。"}),a.detail&&e.jsx("p",{className:"cal-entry-detail",children:a.detail}),a.cwd&&e.jsx("p",{className:"cal-entry-cwd",title:a.cwd,children:a.cwd})]})}function Xe({loadOverview:a,onClose:l,initialTaskId:u,focusKey:x=0}){const[p,W]=n.useState([]),[L,N]=n.useState(""),[v,je]=n.useState(""),[fe,ke]=n.useState(""),C=typeof window>"u"?void 0:window.agentApi,E=new Date,T=D(E.getTime()),[S,R]=n.useState({year:E.getFullYear(),month:E.getMonth()}),[d,ge]=n.useState(null),[Ne,G]=n.useState(!0),[Z,I]=n.useState(""),[ve,X]=n.useState(!1),[F,b]=n.useState(T),[m,J]=n.useState("all"),[j,Q]=n.useState(()=>new Set(V)),[K,O]=n.useState(!0),ee=n.useRef({from:"",to:""}),A=n.useRef(!0),$=n.useRef(0),se=n.useCallback(async s=>{const t=++$.current;J("all"),Q(c=>new Set([...c,"customer-agent"])),je(s);try{const c=C!=null&&C.todoGet?await C.todoGet(s):void 0;if(t!==$.current)return;const i=c==null?void 0:c.task.dueAt;if(i!==void 0){const r=new Date(i);R({year:r.getFullYear(),month:r.getMonth()}),b(D(r.getTime()))}else O(!0)}catch{t===$.current&&O(!0)}},[C]);n.useEffect(()=>(u&&se(u),()=>{$.current++}),[u,x,se]);const _=n.useMemo(()=>Fe(S.year,S.month),[S]),ae=_[0].key,te=_[41].key;ee.current={from:ae,to:te};const f=n.useCallback(async s=>{var i;const{from:t,to:c}=ee.current;s==="initial"?G(!0):X(!0);try{const r=typeof window>"u"?void 0:window.agentApi,[y,h]=await Promise.all([a(t,c),(i=r==null?void 0:r.todoList)==null?void 0:i.call(r,{limit:200}).catch(()=>{})]);if(h&&W(h.items.filter(o=>o.task.dueAt===void 0&&o.task.status!=="completed"&&o.task.status!=="cancelled")),!A.current)return;ge(y),I("")}catch(r){if(!A.current)return;I(r instanceof Error?r.message:"日历加载失败")}finally{A.current&&(G(!1),X(!1))}},[a]);n.useEffect(()=>{A.current=!0,f("initial");const s=setInterval(()=>{document.visibilityState==="visible"&&f("refresh")},Te),t=()=>{document.visibilityState==="visible"&&f("refresh")};return document.addEventListener("visibilitychange",t),()=>{A.current=!1,clearInterval(s),document.removeEventListener("visibilitychange",t)}},[f,ae,te]);const ce=s=>{R(t=>{const c=new Date(t.year,t.month+s,1);return{year:c.getFullYear(),month:c.getMonth()}})},le=()=>{const s=new Date;R({year:s.getFullYear(),month:s.getMonth()}),b(D(s.getTime()))},ne=n.useCallback(s=>s.kind!=="todo"&&j.has(s.source)&&(m==="all"||s.kind===m||m==="due"&&s.dueAt!==void 0||m==="run"&&s.executedAt!==void 0),[j,m]),ie=n.useMemo(()=>{const s=new Map;if(!d)return s;for(const[t,c]of Object.entries(d.days)){const i=c.filter(ne);i.length&&s.set(t,i)}return s},[d,ne]),k=n.useMemo(()=>{let s=0,t=0,c=0,i=0,r=0,y=0;const h=o=>{o.kind==="todo"||!j.has(o.source)||(o.kind==="cron"&&o.state==="upcoming"&&s++,o.state==="completed"&&t++,o.state==="overdue"&&c++,o.state==="paused"&&i++,o.state==="failed"&&r++,o.state==="in-progress"&&y++)};if(d)for(const o of Object.values(d.days))o.forEach(h);return{scheduled:s,completed:t,overdue:c,paused:i,failed:r,inProgress:y}},[d,j]),U=ie.get(F)??[],z=n.useMemo(()=>((d==null?void 0:d.unscheduledSchedules)??[]).filter(s=>j.has(s.source)&&(m==="all"||m==="cron")),[d,j,m]),re=n.useMemo(()=>d?V.filter(s=>{var t;return!((t=d.sources[s])!=null&&t.ok)}).map(s=>{var t;return{source:s,error:((t=d.sources[s])==null?void 0:t.error)??""}}):[],[d]),be=s=>{Q(t=>{const c=new Set(t);return c.has(s)?c.delete(s):c.add(s),c})},H=new Date(`${F}T00:00:00`),ye=`${H.getMonth()+1} 月 ${H.getDate()} 日 · 周${oe[(H.getDay()+6)%7]}`,we=async s=>{var t,c;N(s.task.id);try{await((c=(t=window.agentApi).todoCommand)==null?void 0:c.call(t,{type:"complete",taskId:s.task.id,expectedVersion:s.task.version},crypto.randomUUID())),await f("refresh")}catch(i){I(i instanceof Error?i.message:"待办更新失败")}finally{N("")}};return e.jsxs("div",{className:"cal-root",children:[e.jsx("div",{className:"cal-aurora","aria-hidden":"true"}),e.jsxs("header",{className:"cal-header",children:[e.jsxs("div",{className:"cal-title",children:[e.jsx("span",{className:"cal-title-icon",children:e.jsx(Ae,{size:20,"aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h1",{children:"智能体日历"}),e.jsx("p",{children:"定时任务、执行记录与待办提醒"})]})]}),e.jsxs("div",{className:"cal-nav",children:[l&&e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"返回聊天",title:"返回聊天",onClick:l,children:e.jsx(Y,{size:17})}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"上个月",onClick:()=>ce(-1),children:e.jsx(Ce,{size:17})}),e.jsx("button",{type:"button",className:"cal-month",onClick:le,title:"回到今天",children:Ie(S.year,S.month)}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"下个月",onClick:()=>ce(1),children:e.jsx($e,{size:17})}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"回到今天",title:"回到今天",onClick:le,children:e.jsx(ze,{size:17})}),e.jsx("button",{type:"button",className:`cal-refresh ${ve?"is-spinning":""}`,"aria-label":"刷新",title:"刷新",onClick:()=>void f("refresh"),children:e.jsx(Se,{size:17})})]})]}),e.jsxs("div",{className:"cal-stats",children:[e.jsxs("span",{className:"cal-stat is-scheduled",children:[e.jsx(Me,{size:14}),k.scheduled," 待执行"]}),e.jsxs("span",{className:"cal-stat is-progress",children:[e.jsx(pe,{size:14}),k.inProgress," 进行中"]}),e.jsxs("span",{className:"cal-stat is-done",children:[e.jsx(q,{size:14}),k.completed," 已完成"]}),e.jsxs("span",{className:"cal-stat is-overdue",children:[e.jsx(P,{size:14}),k.overdue," 过期"]}),e.jsxs("span",{className:"cal-stat is-paused",children:[e.jsx(ue,{size:14}),k.paused," 暂停"]}),k.failed>0&&e.jsxs("span",{className:"cal-stat is-fail",children:[e.jsx(Y,{size:14}),k.failed," 失败"]})]}),e.jsxs("div",{className:"cal-filters",children:[e.jsx("div",{className:"cal-sources",role:"group","aria-label":"按来源筛选",children:V.map(s=>{var t;return e.jsxs("button",{type:"button","data-source":s,className:`cal-source-chip ${j.has(s)?"is-on":"is-off"}`,onClick:()=>be(s),"aria-pressed":j.has(s),children:[e.jsx("span",{className:"cal-source-dot","aria-hidden":"true"}),w[s],d&&e.jsx("span",{className:"cal-source-n",children:((t=d.sources[s])==null?void 0:t.entries)||0})]},s)})}),e.jsx("div",{className:"cal-kind-seg",role:"group","aria-label":"按类型筛选",children:Object.keys(he).map(s=>e.jsx("button",{type:"button",className:m===s?"is-active":"",onClick:()=>J(s),"aria-pressed":m===s,children:he[s]},s))})]}),re.length>0&&e.jsx("div",{className:"cal-source-errors",role:"status",children:re.map(({source:s,error:t})=>e.jsxs("span",{className:"cal-source-error","data-source":s,title:t,children:[e.jsx(P,{size:12}),w[s]," 读取异常"]},s))}),Z&&e.jsxs("div",{className:"cal-error",role:"alert",children:[e.jsx(P,{size:16}),Z,e.jsx("button",{type:"button",onClick:()=>void f("initial"),children:"重试"})]}),e.jsxs("div",{className:"cal-body",children:[e.jsxs("div",{className:"cal-grid-wrap",children:[e.jsx("div",{className:"cal-weekdays",children:oe.map(s=>e.jsxs("span",{className:s==="六"||s==="日"?"is-weekend":"",children:["周",s]},s))}),Ne&&!d?e.jsx("div",{className:"cal-grid is-skeleton",children:Array.from({length:42},(s,t)=>e.jsxs("div",{className:"cal-cell cal-skeleton-cell",children:[e.jsx("span",{className:"cal-skel-bar"}),e.jsx("span",{className:"cal-skel-bar is-short"})]},t))}):e.jsx("div",{className:"cal-grid",children:_.map(s=>{const t=ie.get(s.key)??[],c=t.slice(0,3),i=t.length-c.length,r=t.some(h=>h.state==="overdue"),y=`cal-cell ${s.inMonth?"":"is-other"} ${s.key===T?"is-today":""} ${s.key===F?"is-selected":""} ${r?"has-overdue":""}`;return e.jsxs("div",{className:y,role:"button",tabIndex:0,onClick:()=>b(s.key),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),b(s.key))},children:[e.jsxs("div",{className:"cal-cell-head",children:[e.jsx("span",{className:"cal-cell-date",children:s.day}),s.key===T&&e.jsx("span",{className:"cal-today-pill",children:"今天"}),t.length>0&&e.jsx("span",{className:"cal-cell-n",children:t.length})]}),e.jsxs("div",{className:"cal-chips",children:[c.map(h=>e.jsx(_e,{entry:h,highlighted:h.taskId===v,onClick:()=>b(s.key)},h.id)),i>0&&e.jsxs("button",{type:"button",className:"cal-more",onClick:()=>b(s.key),children:["+",i," 更多"]})]})]},s.key)})})]}),e.jsxs("aside",{className:"cal-detail",children:[e.jsxs("div",{className:"cal-detail-head",children:[e.jsx("h2",{children:ye}),e.jsxs("span",{className:"cal-detail-n",children:[U.length," 项"]})]}),e.jsx("div",{className:"cal-detail-list",children:U.length===0?e.jsxs("div",{className:"cal-empty",children:[e.jsx(de,{size:28,strokeWidth:1.4}),e.jsx("p",{children:"这一天没有安排"}),e.jsx("small",{children:"点击其他日期查看安排与提醒"})]}):U.map(s=>e.jsx(Ue,{entry:s,highlighted:s.taskId===v},s.id))})]})]}),e.jsxs("section",{className:`cal-unscheduled ${K?"is-open":""}`,children:[e.jsxs("button",{type:"button",className:"cal-unscheduled-head",onClick:()=>O(s=>!s),"aria-expanded":K,children:[e.jsx(B,{size:16}),e.jsx("span",{children:"未安排"}),e.jsxs("span",{className:"cal-unscheduled-n",children:[p.length," 无日期待办 · ",z.length," 未排期任务"]}),e.jsx(De,{size:16,className:"cal-unscheduled-chev"})]}),K&&e.jsxs("div",{className:"cal-unscheduled-body",children:[p.length>0&&e.jsxs("div",{className:"cal-unsched-schedules",children:[e.jsxs("h3",{children:[e.jsx(B,{size:14}),"无日期待办"]}),e.jsx("div",{className:"cal-unsched-schedule-list",children:p.map(s=>{var i;const t=fe===s.task.id,c=s.task.status==="in_progress"?"进行中":s.task.status==="failed"?"执行失败":"待完成";return e.jsxs("div",{className:`cal-unsched-schedule ${s.task.id===v?"is-highlight":""}`,"data-source":"customer-agent",children:[e.jsxs("div",{className:"cal-unsched-row",children:[e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":`完成 ${s.task.title}`,disabled:!!L,onClick:()=>void we(s),children:e.jsx(q,{size:13})}),e.jsx("button",{type:"button",className:"cal-unsched-title","aria-expanded":t,title:t?"收起详情":"查看详情",onClick:()=>ke(t?"":s.task.id),children:s.task.title})]}),e.jsx("p",{children:c}),t&&e.jsxs("div",{className:"cal-unsched-expand",children:[s.task.description&&e.jsx("p",{children:s.task.description}),((i=s.schedule)==null?void 0:i.enabled)&&e.jsxs("p",{children:["下次执行:",s.schedule.nextFireAt?new Date(s.schedule.nextFireAt).toLocaleString("zh-CN",{hour12:!1}):"—"," · ",s.schedule.target.agentType]}),s.reminders.some(r=>r.enabled)&&e.jsx("p",{children:"已设置提醒"})]})]},s.task.id)})})]}),z.length>0&&e.jsxs("div",{className:"cal-unsched-schedules",children:[e.jsxs("h3",{children:[e.jsx(me,{size:14}),"未排期的定时任务"]}),e.jsx("div",{className:"cal-unsched-schedule-list",children:z.map(s=>e.jsxs("div",{className:"cal-unsched-schedule","data-source":s.source,children:[e.jsx("span",{className:"cal-entry-src","data-source":s.source,children:w[s.source]}),e.jsx("strong",{children:s.title}),s.detail&&e.jsx("p",{children:s.detail})]},s.id))})]}),p.length===0&&z.length===0&&e.jsxs("div",{className:"cal-empty is-inline",children:[e.jsx(de,{size:24,strokeWidth:1.4}),e.jsx("p",{children:"没有无日期待办或未排期任务"})]})]})]})]})}export{Xe as default};