agentroam-runtime-darwin-arm64 0.2.0-preview.70 → 0.2.0-preview.71
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.
- package/manifest.json +2 -2
- package/package.json +1 -1
- package/runtime/.next/BUILD_ID +1 -1
- package/runtime/.next/app-build-manifest.json +8 -8
- package/runtime/.next/app-path-routes-manifest.json +1 -1
- package/runtime/.next/build-manifest.json +3 -3
- package/runtime/.next/prerender-manifest.json +1 -1
- package/runtime/.next/required-server-files.json +1 -1
- package/runtime/.next/server/app/_not-found/page.js +1 -1
- package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app/_not-found.html +1 -1
- package/runtime/.next/server/app/_not-found.rsc +1 -1
- package/runtime/.next/server/app/api/agent/abort/route.js +1 -1
- package/runtime/.next/server/app/api/agent/answer/route.js +1 -1
- package/runtime/.next/server/app/api/agent/codex-sharing/route.js +1 -1
- package/runtime/.next/server/app/api/agent/harness/status/route.js +1 -1
- package/runtime/.next/server/app/api/agent/model/route.js +1 -1
- package/runtime/.next/server/app/api/agent/models/route.js +1 -1
- package/runtime/.next/server/app/api/agent/run/route.js +1 -1
- package/runtime/.next/server/app/api/agent/runtime-health/route.js +1 -1
- package/runtime/.next/server/app/api/agent/steer/route.js +1 -1
- package/runtime/.next/server/app/api/agent/stream/route.js +4 -4
- package/runtime/.next/server/app/api/agent-workspaces/[workspaceId]/sessions/route.js +1 -1
- package/runtime/.next/server/app/api/agent-workspaces/route.js +1 -1
- package/runtime/.next/server/app/api/auth/verify/route.js +1 -1
- package/runtime/.next/server/app/api/business/route.js +1 -1
- package/runtime/.next/server/app/api/client-logs/route.js +1 -1
- package/runtime/.next/server/app/api/collaboration/route.js +2 -2
- package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +3 -3
- package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
- package/runtime/.next/server/app/api/flow-studio/config/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/connect/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/disconnect/route.js +1 -1
- package/runtime/.next/server/app/api/mcp/servers/route.js +1 -1
- package/runtime/.next/server/app/api/memory/[key]/route.js +1 -1
- package/runtime/.next/server/app/api/memory/route.js +1 -1
- package/runtime/.next/server/app/api/plugins/load/route.js +1 -1
- package/runtime/.next/server/app/api/projects/[id]/route.js +1 -1
- package/runtime/.next/server/app/api/projects/check/route.js +1 -1
- package/runtime/.next/server/app/api/projects/directories/route.js +1 -1
- package/runtime/.next/server/app/api/projects/roots/route.js +1 -1
- package/runtime/.next/server/app/api/projects/route.js +1 -1
- package/runtime/.next/server/app/api/push/subscribe/route.js +2 -2
- package/runtime/.next/server/app/api/push/unsubscribe/route.js +3 -3
- package/runtime/.next/server/app/api/push/vapid/route.js +2 -2
- package/runtime/.next/server/app/api/push/vapid.body +1 -1
- package/runtime/.next/server/app/api/remote-tools/register/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/background-jobs/[jobId]/stop/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/background-jobs/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/changes/route.js +2 -2
- package/runtime/.next/server/app/api/sessions/[id]/fork/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/fork-at/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/goals/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/handoff/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/native-goal/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/query-index/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/release/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/thread-goal/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/[id]/tool-result/route.js +1 -1
- package/runtime/.next/server/app/api/sessions/route.js +1 -1
- package/runtime/.next/server/app/api/settings/route.js +1 -1
- package/runtime/.next/server/app/api/skills/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
- package/runtime/.next/server/app/api/tools/route.js +1 -1
- package/runtime/.next/server/app/api/update/check/route.js +1 -1
- package/runtime/.next/server/app/api/update/install/route.js +1 -1
- package/runtime/.next/server/app/api/update/status/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/login/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/logout/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/revoke-all/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/setup/route.js +1 -1
- package/runtime/.next/server/app/api/web-auth/status/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/bootstrap/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/computer-settings/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/computers/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/device-state/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/history/route.js +1 -1
- package/runtime/.next/server/app/api/web-console/preferences/route.js +1 -1
- package/runtime/.next/server/app/web/page.js +4 -4
- package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app-paths-manifest.json +33 -33
- package/runtime/.next/server/chunks/5303.js +2 -2
- package/runtime/.next/server/middleware-build-manifest.js +1 -1
- package/runtime/.next/server/pages/404.html +1 -1
- package/runtime/.next/server/pages/500.html +1 -1
- package/runtime/.next/server/server-reference-manifest.json +1 -1
- package/runtime/.next/static/chunks/app/web/{error-3acef50d100c88cd.js → error-6470e38a145095eb.js} +1 -1
- package/runtime/.next/static/chunks/app/web/layout-ecfb758d244808a4.js +1 -0
- package/runtime/.next/static/chunks/app/web/{page-cd202c384ebf79be.js → page-27145471bd2171c2.js} +1 -1
- package/runtime/.next/static/chunks/{main-app-1722010a0ff567d7.js → main-app-41078426602904fd.js} +1 -1
- package/runtime/lib/tunnel-control.mjs +32 -0
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/node_modules/.package-lock.json +20 -20
- package/runtime/node_modules/@agent/core/dist/index.js +13 -3
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/bridge.mjs +75 -73
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/browser-sdk.js +42 -40
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-07pvccxf.mjs +43 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-kzw924e6.mjs → core-0rjxgk9e.mjs} +3 -3
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-fpeb751h.mjs +33 -0
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/{core-bb8r6h44.mjs → core-jf0rbr11.mjs} +1 -1
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core.mjs +9 -9
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.json +19 -21
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/manifest.zst.json +23 -25
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/package.json +14 -14
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +61 -57
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +29701 -29485
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +20 -20
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +20 -20
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +29701 -29485
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +28904 -28688
- package/runtime/node_modules/mediabunny/dist/modules/src/codec-data.js +6 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/codec.js +35 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/conversion.js +90 -13
- package/runtime/node_modules/mediabunny/dist/modules/src/id3.js +6 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-boxes.js +23 -3
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-demuxer.js +12 -3
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-misc.js +1 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-muxer.js +29 -6
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/ebml.js +9 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-demuxer.js +10 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-muxer.js +16 -2
- package/runtime/node_modules/mediabunny/dist/modules/src/media-source.js +59 -36
- package/runtime/node_modules/mediabunny/dist/modules/src/metadata.js +5 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/output-format.js +10 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/sample.js +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/wave/wave-muxer.js +1 -0
- package/runtime/node_modules/mediabunny/package.json +1 -1
- package/runtime/node_modules/mediabunny/src/codec-data.ts +4 -0
- package/runtime/node_modules/mediabunny/src/codec.ts +38 -0
- package/runtime/node_modules/mediabunny/src/conversion.ts +128 -16
- package/runtime/node_modules/mediabunny/src/id3.ts +4 -0
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-boxes.ts +24 -4
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-demuxer.ts +18 -3
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-misc.ts +2 -0
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-muxer.ts +39 -7
- package/runtime/node_modules/mediabunny/src/matroska/ebml.ts +11 -0
- package/runtime/node_modules/mediabunny/src/matroska/matroska-demuxer.ts +11 -0
- package/runtime/node_modules/mediabunny/src/matroska/matroska-muxer.ts +20 -2
- package/runtime/node_modules/mediabunny/src/media-source.ts +77 -52
- package/runtime/node_modules/mediabunny/src/metadata.ts +13 -0
- package/runtime/node_modules/mediabunny/src/output-format.ts +13 -1
- package/runtime/node_modules/mediabunny/src/sample.ts +1 -1
- package/runtime/node_modules/mediabunny/src/version.ts +1 -1
- package/runtime/node_modules/mediabunny/src/wave/wave-muxer.ts +2 -1
- package/runtime/node_modules/tslib/README.md +3 -8
- package/runtime/node_modules/tslib/package.json +1 -1
- package/runtime/node_modules/tslib/tslib.es6.js +10 -1
- package/runtime/node_modules/tslib/tslib.es6.mjs +10 -1
- package/runtime/node_modules/tslib/tslib.js +10 -1
- package/runtime/node_modules/ws/README.md +21 -29
- package/runtime/node_modules/ws/lib/buffer-util.js +13 -2
- package/runtime/node_modules/ws/lib/sender.js +4 -1
- package/runtime/node_modules/ws/lib/websocket.js +8 -3
- package/runtime/node_modules/ws/package.json +1 -1
- package/runtime/package-lock.json +44 -44
- package/runtime/server.js +1 -1
- package/runtime/webapp/dist/assets/{AiHubPane-BQ8CJAQL.js → AiHubPane-Cp_tNJNR.js} +1 -1
- package/runtime/webapp/dist/assets/App-Cs8U1u-X.js +175 -0
- package/runtime/webapp/dist/assets/App-QWoPBMW0.css +1 -0
- package/runtime/webapp/dist/assets/{BrowserLivePanel-DxhSUu4j.js → BrowserLivePanel-B1zYRS_7.js} +1 -1
- package/runtime/webapp/dist/assets/{CollaborationDashboard-c_iNusPf.js → CollaborationDashboard-DIVa26zk.js} +1 -1
- package/runtime/webapp/dist/assets/{CollaborationPage-DRBPK_iH.js → CollaborationPage-Fsvkw8ZM.js} +1 -1
- package/runtime/webapp/dist/assets/{FilePreview-DScFSi_K.js → FilePreview-BjbfWw2s.js} +3 -3
- package/runtime/webapp/dist/assets/{FileTree-BB5xTMg6.js → FileTree-C6gg9p4m.js} +1 -1
- package/runtime/webapp/dist/assets/{FlowStudioPane-BBf0zyw1.js → FlowStudioPane-CCuxZBVJ.js} +1 -1
- package/runtime/webapp/dist/assets/{RemoteDesktopPage-CWW4T1QF.js → RemoteDesktopPage-DpoYuKhA.js} +1 -1
- package/runtime/webapp/dist/assets/SessionDashboard-CAoW5-uN.css +1 -0
- package/runtime/webapp/dist/assets/SessionDashboard-DOWjUIY1.js +26 -0
- package/runtime/webapp/dist/assets/SessionDashboardBridge-DYsMZhuH.js +1 -0
- package/runtime/webapp/dist/assets/{TerminalPane-DkEyD1ge.js → TerminalPane-CPOiBcye.js} +1 -1
- package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-Dlsyu96y.js → abnfDiagram-VCTEODGH-DCFFqJUU.js} +1 -1
- package/runtime/webapp/dist/assets/{arc-D0AvBRtK.js → arc-vjNW9DYV.js} +1 -1
- package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-BLAHjBcI.js → architectureDiagram-5GKGNRK7-DoK3A_n1.js} +1 -1
- package/runtime/webapp/dist/assets/{arrow-right-B15rGLIR.js → arrow-right-B0uCZ1Pd.js} +1 -1
- package/runtime/webapp/dist/assets/{artifact-links-BkoUldDR.js → artifact-links-nzx7joYs.js} +1 -1
- package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-CqIb0xz-.js → blockDiagram-I7D4REHJ-DgXszyX7.js} +1 -1
- package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-CG98ZTHr.js → c4Diagram-7LVT6UL2-q7KO4v1Q.js} +1 -1
- package/runtime/webapp/dist/assets/channel-CsnhvX8S.js +1 -0
- package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-DQh8kgcp.js → chunk-2Q5K7J3B-CH8lOKmL.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-BesfCxeX.js → chunk-5VM5RSS4-DwP7xEWd.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-F27PBJKO-BCXEjgx-.js → chunk-F27PBJKO-BV3TTaxI.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-ydMd7mT-.js → chunk-IMKFNOWR-BbaiG4yG.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-K3_myO-F.js → chunk-JWPE2WC7-Dv9x27hI.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-BtqLafwd.js → chunk-POPQ4Y6H-Uk-GiSLP.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-SVP7TREG-mKZUbHcv.js → chunk-SVP7TREG-lFcKEwyL.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-TICWLB2K-hDH9_eNh.js → chunk-TICWLB2K-DFZALWPC.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-B6wXA24N.js → chunk-XXDRQBXY-8jLPZkMb.js} +1 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-Bed40USf.js +1 -0
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-Bed40USf.js +1 -0
- package/runtime/webapp/dist/assets/{clipboard-CrmYgzo8.js → clipboard-BteN9-AC.js} +1 -1
- package/runtime/webapp/dist/assets/{codeSyntax-KyRYSqw_.js → codeSyntax-Dgv0FfoZ.js} +1 -1
- package/runtime/webapp/dist/assets/{collaboration-B7rPFZje.js → collaboration-f29NaKWy.js} +1 -1
- package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-MoeyZZ6x.js → cose-bilkent-JH36ORCC-86P-lxD4.js} +1 -1
- package/runtime/webapp/dist/assets/{crown-BKylWZLt.js → crown-y1qmM0NZ.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-BWYtTqVq.js → cynefin-OW5HDTMX-mtRVdchl.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-CoqnJ7eo.js → cynefinDiagram-5FMLGOSQ-DhqAIoq6.js} +1 -1
- package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-DMwZ_7F7.js → dagre-GXQ25YYZ-DD9olCTy.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-DJ2BAyzP.js → diagram-S7CK7UJ4-CLGKipLp.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-ChujnpjG.js → diagram-UQ7AKVKN-Dm7uGpUO.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-CDSAKYID.js → diagram-VSXAHHWV-OZYfwAth.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VX7I27RA-DXvCy8w-.js → diagram-VX7I27RA-BpQqNFxQ.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-BWrKegI9.js → diagram-Z3DM3KII-BrWsMYCU.js} +1 -1
- package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-CqDhPmpp.js → ebnfDiagram-PWID7BFC-BRH-K-J7.js} +1 -1
- package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-D5HR9ddP.js → erDiagram-RLTQ6QDP-BDNSVr6H.js} +1 -1
- package/runtime/webapp/dist/assets/{file-types-D_egQYAD.js → file-types-XHMBkbNr.js} +1 -1
- package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-Bz89eEJ2.js → flowDiagram-HODETNUW-DseLK02Y.js} +1 -1
- package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-Bw1lo_RG.js → ganttDiagram-EL5Y4UJY-v_uNZx1g.js} +1 -1
- package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-CMxwIm3p.js → gitGraphDiagram-WWUBYQGX-EdvVYEMk.js} +1 -1
- package/runtime/webapp/dist/assets/{index-CkVSxxim.js → index--zKd3rTs.js} +49 -49
- package/runtime/webapp/dist/assets/{index-6B8SDnzK.css → index-D0gsdpeQ.css} +1 -1
- package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-DEWyQUst.js → infoDiagram-27XIBGKW-Ck26xp1i.js} +1 -1
- package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-BfJdGhe_.js → ishikawaDiagram-5VMMS53U-DGnOVObq.js} +1 -1
- package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-C6gh2ejc.js → journeyDiagram-3NMN7TZE-S7oKAQs8.js} +1 -1
- package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-1UHi9Lfv.js → kanban-definition-UXKFOSKX-DcrYA4VY.js} +1 -1
- package/runtime/webapp/dist/assets/{layout-CKq-cSTm.js → layout-CYHINS_I.js} +1 -1
- package/runtime/webapp/dist/assets/{linear-DF4sJk10.js → linear-B-lEfto_.js} +1 -1
- package/runtime/webapp/dist/assets/{loader-circle-Dpjix4wZ.js → loader-circle-DMWQZenY.js} +1 -1
- package/runtime/webapp/dist/assets/{mermaid.core-OAHUFl3p.js → mermaid.core-B3fzlEw9.js} +5 -5
- package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-JiyyEKeC.js → mindmap-definition-YA3MSWOX-wJkCh55V.js} +1 -1
- package/runtime/webapp/dist/assets/{page-DqgtSgo3.js → page-Cc56wyOt.js} +8 -13
- package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-CpBwPi33.js → pegDiagram-XKGWAZYB-H4uk2OUO.js} +1 -1
- package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-BjM_PcYH.js → pieDiagram-E7YTZNPT-yLnU_MCb.js} +1 -1
- package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-Vdz77obz.js → quadrantDiagram-AXDQQJYC-DyD93O4P.js} +1 -1
- package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-DsQjNf1f.js → railroadDiagram-O6MQD6OU-DZ833xbw.js} +1 -1
- package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-TpfT8TjT.js → requirementDiagram-BXWQKSXE-DJV4nGui.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-ccw-wJiVuYlm.js → rotate-ccw-CKqo62Ra.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-cw-CtpBETpM.js → rotate-cw-D-M3ZDSa.js} +1 -1
- package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-Ckh_skQw.js → sankeyDiagram-P5KCCOFB-BeOYMFTR.js} +1 -1
- package/runtime/webapp/dist/assets/{send-DL0qj0xE.js → send-LvtpJMkk.js} +1 -1
- package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-CkKC0JEA.js → sequenceDiagram-WJ2MYXX4-BBcgqG33.js} +1 -1
- package/runtime/webapp/dist/assets/{shield-check-B5q8YhWs.js → shield-check-SeEkz1Nd.js} +1 -1
- package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-DB_NzdXU.js → sizeCapture-INFHLROL-B0GJZjw0.js} +1 -1
- package/runtime/webapp/dist/assets/{smartphone-DJEfFl42.js → smartphone-D7oS3YTz.js} +11 -6
- package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-Ch2r76jY.js → stateDiagram-D77RDMKH-BmSvB3vd.js} +1 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-CQ9wpJCJ.js +1 -0
- package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-BBMlDhHH.js → swimlanes-42K2YHIH-BAZdMUD6.js} +1 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-8XTJp3Fr.js +8 -0
- package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-BELJuISI.js → timeline-definition-24CTP7MA-BSgVFMNG.js} +1 -1
- package/runtime/webapp/dist/assets/{trash-2-D4LqA3q5.js → trash-2-CHYPyYDY.js} +1 -1
- package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-NSlXdmyy.js → vennDiagram-4TSXK5OY-C-brvbkB.js} +1 -1
- package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-BVbNDhZr.js → wardleyDiagram-VM6X3IG4-CeqqVR1s.js} +1 -1
- package/runtime/webapp/dist/assets/{web-CoxxvfFh.js → web-Dzd7NW_F.js} +1 -1
- package/runtime/webapp/dist/assets/{web-BpA_VIiS.js → web-aLPH3xFw.js} +1 -1
- package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-Bt3XghTc.js → xychartDiagram-S5SC5T6Z-mPizwpXM.js} +1 -1
- package/runtime/webapp/dist/index.html +2 -2
- package/runtime/ws-server.mjs +4 -0
- package/runtime/.next/static/chunks/app/web/layout-8ec7c101bbab1dc2.js +0 -1
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-a9vq6p1m.mjs +0 -31
- package/runtime/node_modules/@anthropic-ai/claude-agent-sdk/core-t4mxrz5y.mjs +0 -43
- package/runtime/webapp/dist/assets/App-CdrKKs1h.css +0 -1
- package/runtime/webapp/dist/assets/App-GXFFBAhW.js +0 -174
- package/runtime/webapp/dist/assets/SessionDashboard-BdGlakPd.js +0 -26
- package/runtime/webapp/dist/assets/SessionDashboard-CUCEDkCI.css +0 -1
- package/runtime/webapp/dist/assets/SessionDashboardBridge-8zrk0Bub.js +0 -1
- package/runtime/webapp/dist/assets/channel-Bw3F6pJc.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-By2XJYuW.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-By2XJYuW.js +0 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-BCjtOHJv.js +0 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CYzCynNs.js +0 -8
- /package/runtime/.next/static/{Ow_KjPn75TzR7WqdD4P9x → mGwTFWK2dzlY3HjsjZGzh}/_buildManifest.js +0 -0
- /package/runtime/.next/static/{Ow_KjPn75TzR7WqdD4P9x → mGwTFWK2dzlY3HjsjZGzh}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as oe}from"./chunk-XXDRQBXY-
|
|
1
|
+
import{g as oe}from"./chunk-XXDRQBXY-8jLPZkMb.js";import{s as ce}from"./chunk-POPQ4Y6H-Uk-GiSLP.js";import{_ as h,l as R,u as le,v as he,y as de,B as W,c as U,i as H,b4 as ge,ac as ue,ad as pe,ae as fe}from"./mermaid.core-B3fzlEw9.js";import"./index--zKd3rTs.js";const _=[];for(let t=0;t<256;++t)_.push((t+256).toString(16).slice(1));function me(t,e=0){return(_[t[e+0]]+_[t[e+1]]+_[t[e+2]]+_[t[e+3]]+"-"+_[t[e+4]]+_[t[e+5]]+"-"+_[t[e+6]]+_[t[e+7]]+"-"+_[t[e+8]]+_[t[e+9]]+"-"+_[t[e+10]]+_[t[e+11]]+_[t[e+12]]+_[t[e+13]]+_[t[e+14]]+_[t[e+15]]).toLowerCase()}const ye=new Uint8Array(16);function Ee(){return crypto.getRandomValues(ye)}function _e(t,e,o){return crypto.randomUUID?crypto.randomUUID():be(t)}function be(t,e,o){var n;t=t||{};const l=t.random??((n=t.rng)==null?void 0:n.call(t))??Ee();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,me(l)}var K=function(){var t=h(function(O,s,i,a){for(i=i||{},a=O.length;a--;i[O[a]]=s);return i},"o"),e=[1,4],o=[1,13],l=[1,12],n=[1,15],d=[1,16],p=[1,20],y=[1,19],E=[6,7,8],k=[1,26],L=[1,24],D=[1,25],b=[6,7,11],$=[1,6,13,15,16,19,22],f=[1,33],B=[1,34],P=[1,6,7,11,13,15,16,19,22],z={trace:h(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,MINDMAP:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,ICON:15,CLASS:16,nodeWithId:17,nodeWithoutId:18,NODE_DSTART:19,NODE_DESCR:20,NODE_DEND:21,NODE_ID:22,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"MINDMAP",11:"EOF",13:"SPACELIST",15:"ICON",16:"CLASS",19:"NODE_DSTART",20:"NODE_DESCR",21:"NODE_DEND",22:"NODE_ID"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[18,3],[17,1],[17,4]],performAction:h(function(s,i,a,c,u,r,M){var g=r.length-1;switch(u){case 6:case 7:return c;case 8:c.getLogger().trace("Stop NL ");break;case 9:c.getLogger().trace("Stop EOF ");break;case 11:c.getLogger().trace("Stop NL2 ");break;case 12:c.getLogger().trace("Stop EOF2 ");break;case 15:c.getLogger().info("Node: ",r[g].id),c.addNode(r[g-1].length,r[g].id,r[g].descr,r[g].type);break;case 16:c.getLogger().trace("Icon: ",r[g]),c.decorateNode({icon:r[g]});break;case 17:case 21:c.decorateNode({class:r[g]});break;case 18:c.getLogger().trace("SPACELIST");break;case 19:c.getLogger().trace("Node: ",r[g].id),c.addNode(0,r[g].id,r[g].descr,r[g].type);break;case 20:c.decorateNode({icon:r[g]});break;case 25:c.getLogger().trace("node found ..",r[g-2]),this.$={id:r[g-1],descr:r[g-1],type:c.getType(r[g-2],r[g])};break;case 26:this.$={id:r[g],descr:r[g],type:c.nodeType.DEFAULT};break;case 27:c.getLogger().trace("node found ..",r[g-3]),this.$={id:r[g-3],descr:r[g-1],type:c.getType(r[g-2],r[g])};break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:o,7:[1,10],9:9,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},t(E,[2,3]),{1:[2,2]},t(E,[2,4]),t(E,[2,5]),{1:[2,6],6:o,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},{6:o,9:22,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},{6:k,7:L,10:23,11:D},t(b,[2,22],{17:17,18:18,14:27,15:[1,28],16:[1,29],19:p,22:y}),t(b,[2,18]),t(b,[2,19]),t(b,[2,20]),t(b,[2,21]),t(b,[2,23]),t(b,[2,24]),t(b,[2,26],{19:[1,30]}),{20:[1,31]},{6:k,7:L,10:32,11:D},{1:[2,7],6:o,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:p,22:y},t($,[2,14],{7:f,11:B}),t(P,[2,8]),t(P,[2,9]),t(P,[2,10]),t(b,[2,15]),t(b,[2,16]),t(b,[2,17]),{20:[1,35]},{21:[1,36]},t($,[2,13],{7:f,11:B}),t(P,[2,11]),t(P,[2,12]),{21:[1,37]},t(b,[2,25]),t(b,[2,27])],defaultActions:{2:[2,1],6:[2,2]},parseError:h(function(s,i){if(i.recoverable)this.trace(s);else{var a=new Error(s);throw a.hash=i,a}},"parseError"),parse:h(function(s){var i=this,a=[0],c=[],u=[null],r=[],M=this.table,g="",F=0,Q=0,ie=2,Z=1,se=r.slice.call(arguments,1),m=Object.create(this.lexer),C={yy:{}};for(var X in this.yy)Object.prototype.hasOwnProperty.call(this.yy,X)&&(C.yy[X]=this.yy[X]);m.setInput(s,C.yy),C.yy.lexer=m,C.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var Y=m.yylloc;r.push(Y);var re=m.options&&m.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ae(x){a.length=a.length-2*x,u.length=u.length-x,r.length=r.length-x}h(ae,"popStack");function ee(){var x;return x=c.pop()||m.lex()||Z,typeof x!="number"&&(x instanceof Array&&(c=x,x=c.pop()),x=i.symbols_[x]||x),x}h(ee,"lex");for(var S,I,N,q,w={},G,v,te,j;;){if(I=a[a.length-1],this.defaultActions[I]?N=this.defaultActions[I]:((S===null||typeof S>"u")&&(S=ee()),N=M[I]&&M[I][S]),typeof N>"u"||!N.length||!N[0]){var J="";j=[];for(G in M[I])this.terminals_[G]&&G>ie&&j.push("'"+this.terminals_[G]+"'");m.showPosition?J="Parse error on line "+(F+1)+`:
|
|
2
2
|
`+m.showPosition()+`
|
|
3
3
|
Expecting `+j.join(", ")+", got '"+(this.terminals_[S]||S)+"'":J="Parse error on line "+(F+1)+": Unexpected "+(S==Z?"end of input":"'"+(this.terminals_[S]||S)+"'"),this.parseError(J,{text:m.match,token:this.terminals_[S]||S,line:m.yylineno,loc:Y,expected:j})}if(N[0]instanceof Array&&N.length>1)throw new Error("Parse Error: multiple actions possible at state: "+I+", token: "+S);switch(N[0]){case 1:a.push(S),u.push(m.yytext),r.push(m.yylloc),a.push(N[1]),S=null,Q=m.yyleng,g=m.yytext,F=m.yylineno,Y=m.yylloc;break;case 2:if(v=this.productions_[N[1]][1],w.$=u[u.length-v],w._$={first_line:r[r.length-(v||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(v||1)].first_column,last_column:r[r.length-1].last_column},re&&(w._$.range=[r[r.length-(v||1)].range[0],r[r.length-1].range[1]]),q=this.performAction.apply(w,[g,Q,F,C.yy,N[1],u,r].concat(se)),typeof q<"u")return q;v&&(a=a.slice(0,-1*v*2),u=u.slice(0,-1*v),r=r.slice(0,-1*v)),a.push(this.productions_[N[1]][0]),u.push(w.$),r.push(w._$),te=M[a[a.length-2]][a[a.length-1]],a.push(te);break;case 3:return!0}}return!0},"parse")},ne=function(){var O={EOF:1,parseError:h(function(i,a){if(this.yy.parser)this.yy.parser.parseError(i,a);else throw new Error(i)},"parseError"),setInput:h(function(s,i){return this.yy=i||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:h(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var i=s.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:h(function(s){var i=s.length,a=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var c=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),a.length-1&&(this.yylineno-=a.length-1);var u=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:a?(a.length===c.length?this.yylloc.first_column:0)+c[c.length-a.length].length-a[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[u[0],u[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},"unput"),more:h(function(){return this._more=!0,this},"more"),reject:h(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:h(function(s){this.unput(this.match.slice(s))},"less"),pastInput:h(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:h(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:h(function(){var s=this.pastInput(),i=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-
|
|
2
|
-
import{c as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-CPOiBcye.js","./index--zKd3rTs.js","./index-D0gsdpeQ.css","./clipboard-BteN9-AC.js","./smartphone-D7oS3YTz.js","./artifact-links-nzx7joYs.js","./trash-2-CHYPyYDY.js","./CollaborationTabBridge-Dxq4G1Uk.js","./SessionDashboardBridge-DYsMZhuH.js","./RemoteDesktopTabBridge-Cp9mLtcY.js","./TerminalPane-6GBZ9nXN.css","./FileTree-C6gg9p4m.js","./file-types-XHMBkbNr.js","./loader-circle-DMWQZenY.js","./FilePreview-BjbfWw2s.js","./rotate-ccw-CKqo62Ra.js","./FilePreview-B7Ab2X_E.css","./AiHubPane-Cp_tNJNR.js","./send-LvtpJMkk.js","./FlowStudioPane-CCuxZBVJ.js","./rotate-cw-D-M3ZDSa.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Pn,r as n,j as e,f as Ve,e as Ie,R as xe,X as Ee,n as cr,o as lr,p as De,s as In,q as dr,b as Me,t as He,v as ur,w as pr,x as ln,y as mr,d as fr,z as hr,U as xt,m as ct,P as An,D as gr,L as Dn,E as yt,F as br,G as wr,I as dn,J as xr,K as yr,N as vr,O as kr,Q as jr,S as Er,T as lt,V as Sr,Y as dt,Z as Cr,_ as ut,$ as Tr,a0 as it,a1 as Nr,a2 as Rr,a3 as Lr,a4 as Pr,a5 as Ir,a6 as un,a7 as Oe}from"./index--zKd3rTs.js";import{S as Mn,M as pn,G as pt,a as Ar,L as On,b as Dr,C as Mr,P as Or,c as zr}from"./smartphone-D7oS3YTz.js";import{C as mt,a as _r,r as Wr,i as mn}from"./artifact-links-nzx7joYs.js";import{T as vt,P as ft,C as Fr,A as $r,F as Ur}from"./trash-2-CHYPyYDY.js";import{E as kt,c as Br}from"./clipboard-BteN9-AC.js";import{r as qr,d as Hr,e as Vr}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{b as Kr,r as Yr,c as fn}from"./SessionDashboardBridge-DYsMZhuH.js";import{c as Gr,d as Jr,R as Xr,b as Qr}from"./RemoteDesktopTabBridge-Cp9mLtcY.js";/**
|
|
3
3
|
* @license lucide-react v0.468.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const Zr=Pn("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/**
|
|
8
8
|
* @license lucide-react v0.468.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const
|
|
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 Zr=xt("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);function ze(t,o){const a=n.lazy(t);return function(c){var u;return e.jsx(n.Suspense,{fallback:((u=o==null?void 0:o.loading)==null?void 0:u.call(o))??null,children:e.jsx(a,{...c})})}}const eo={background:"color-mix(in srgb, var(--ui-tab-accent) 88%, var(--ui-text))",borderColor:"color-mix(in srgb, var(--ui-tab-accent) 88%, var(--ui-text))",color:"var(--ui-primary-text)"};function to(){const[t,o]=n.useState(!1),[a,s]=n.useState(!1),[c,u]=n.useState(null),d=n.useRef(null);return n.useEffect(()=>{u(document.querySelector(".web-root")??document.body);const p=j=>{var R;return o(!!((R=j.detail)!=null&&R.installed))},k=()=>s(!0);return window.addEventListener("agentroam:pwa-state",p),window.addEventListener("agentroam:pwa-guide",k),window.dispatchEvent(new Event("agentroam:pwa-query")),()=>{window.removeEventListener("agentroam:pwa-state",p),window.removeEventListener("agentroam:pwa-guide",k)}},[]),n.useEffect(()=>{var p,k;a&&!((p=d.current)!=null&&p.open)&&((k=d.current)==null||k.showModal())},[a]),e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"file-drawer-toggle pwa-install-button",title:t?"已添加到主屏幕":"添加到主屏幕","aria-label":t?"已添加到主屏幕":"添加到主屏幕",onClick:()=>t?s(!0):window.dispatchEvent(new Event("agentroam:pwa-install")),children:e.jsxs("span",{style:{position:"relative",display:"flex"},children:[e.jsx(Mn,{size:17,"aria-hidden":"true"}),e.jsx(Ve,{size:9,strokeWidth:3,"aria-hidden":"true",style:{position:"absolute",right:-4,bottom:-2}})]})}),a&&c&&Ie.createPortal(e.jsxs("dialog",{ref:d,"data-toolbar-overlay":!0,onClose:()=>s(!1),"aria-labelledby":"pwa-install-title",style:{maxWidth:340,width:"calc(100% - 40px)",margin:"auto",padding:24,borderRadius:16,border:"1px solid var(--ui-tabbar-border)",background:"var(--ui-root-bg)",color:"var(--ui-text)",whiteSpace:"normal",font:"14px/1.8 system-ui"},children:[e.jsx("h2",{id:"pwa-install-title",style:{margin:"0 0 12px",fontSize:18},children:t?"已添加到主屏幕":"添加到主屏幕"}),t&&e.jsx("p",{children:"当前已在主屏幕应用中打开。"}),e.jsx("p",{children:"iPhone / iPad:在 Safari 点击分享按钮,选择“添加到主屏幕”,再点“添加”。"}),e.jsx("p",{children:"Android:打开浏览器菜单,选择“安装应用”或“添加到主屏幕”。"}),e.jsx("p",{style:{color:"var(--ui-muted-text)"},children:"浏览器需要你确认,网页无法自动添加。从主屏幕打开后,如提示未配对,请重新扫码。"}),e.jsx("button",{type:"button",style:{...eo,width:"100%",padding:"10px 14px",borderStyle:"solid",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:()=>{var p;return(p=d.current)==null?void 0:p.close()},children:"知道了"})]}),c)]})}const gn={shared:"已共享",independent:"独立后台",failed:"连接失败",stopped:"桌面未启动","not-installed":"桌面未安装",unsupported:"暂不支持"};function no({csrfToken:t}){const[o,a]=n.useState(null),[s,c]=n.useState(!1),u=n.useRef(!1),d=n.useRef(0),p=n.useCallback(async(l=!1,v=!1,S=!1)=>{var m;if(u.current)return;u.current=!0;const P=d.current;c(!0);try{const g=await fetch("/api/agent/codex-sharing",{method:l||v?"POST":"GET",credentials:"same-origin",cache:"no-store",headers:l||v?{"x-csrf-token":t,...v?{"content-type":"application/json"}:{}}:void 0,body:v?JSON.stringify({action:"share",restartConfirmed:S}):void 0,signal:AbortSignal.timeout(18e4)}),h=await g.json();if(!g.ok||!Object.hasOwn(gn,h==null?void 0:h.state))throw new Error(((m=h==null?void 0:h.error)==null?void 0:m.message)||"共享状态读取失败,请重试。");if(P!==d.current)return;a(h)}catch(g){if(P!==d.current)return;a({state:"failed",configured:!1,autoStart:!1,daemonReachable:!1,runtimeMode:null,message:g instanceof Error?g.message:"无法连接当前电脑。"})}finally{u.current=!1,P===d.current&&c(!1)}},[t]);n.useEffect(()=>{p();const l=()=>{document.hidden||p()},v=window.setInterval(l,15e3);return window.addEventListener("online",l),()=>{d.current++,window.clearInterval(v),window.removeEventListener("online",l)}},[p]);const k=o?gn[o.state]:"检查中",j=()=>{const l=(o==null?void 0:o.state)!=="stopped";l&&!window.confirm("切换将强制重启 Codex 桌面,中断桌面任务并可能丢失未发送内容,不再显示 Codex 退出确认框。共享后端和手机会话不会被结束。是否继续?")||p(!1,!0,l)},R=o&&o.state!=="unsupported"&&(o.state!=="shared"||!o.configured||!o.autoStart||!o.daemonReachable);return e.jsxs("div",{className:"codex-sharing",children:[e.jsx("style",{children:ro}),e.jsxs("div",{className:"codex-sharing-title",role:"status",children:[e.jsx("span",{className:"codex-sharing-indicator","aria-hidden":"true",children:e.jsx("span",{className:"codex-sharing-dot","data-state":o==null?void 0:o.state})}),e.jsxs("span",{children:["Codex · ",k]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx("p",{children:o.state==="shared"?"共享连接可用,启动配置需要修复。":o.message}),e.jsxs("div",{className:"codex-sharing-actions",children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{p()},"aria-label":"刷新 Codex 共享状态",children:[e.jsx(xe,{size:12}),"刷新"]}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{p(!0)},children:s?"正在修复…":"检查并修复"}),!["shared","not-installed"].includes(o.state)&&e.jsx("button",{type:"button",disabled:s,onClick:j,children:s?"正在处理…":o.state==="stopped"?"以共享模式启动 Codex":"切换到共享后端"})]})]})]})}const ro=`
|
|
12
|
+
*/const eo=Pn("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);function ze(t,o){const a=n.lazy(t);return function(c){var u;return e.jsx(n.Suspense,{fallback:((u=o==null?void 0:o.loading)==null?void 0:u.call(o))??null,children:e.jsx(a,{...c})})}}const to={background:"color-mix(in srgb, var(--ui-tab-accent) 88%, var(--ui-text))",borderColor:"color-mix(in srgb, var(--ui-tab-accent) 88%, var(--ui-text))",color:"var(--ui-primary-text)"};function no(){const[t,o]=n.useState(!1),[a,s]=n.useState(!1),[c,u]=n.useState(null),d=n.useRef(null);return n.useEffect(()=>{u(document.querySelector(".web-root")??document.body);const p=j=>{var R;return o(!!((R=j.detail)!=null&&R.installed))},k=()=>s(!0);return window.addEventListener("agentroam:pwa-state",p),window.addEventListener("agentroam:pwa-guide",k),window.dispatchEvent(new Event("agentroam:pwa-query")),()=>{window.removeEventListener("agentroam:pwa-state",p),window.removeEventListener("agentroam:pwa-guide",k)}},[]),n.useEffect(()=>{var p,k;a&&!((p=d.current)!=null&&p.open)&&((k=d.current)==null||k.showModal())},[a]),e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"file-drawer-toggle pwa-install-button",title:t?"已添加到主屏幕":"添加到主屏幕","aria-label":t?"已添加到主屏幕":"添加到主屏幕",onClick:()=>t?s(!0):window.dispatchEvent(new Event("agentroam:pwa-install")),children:e.jsxs("span",{style:{position:"relative",display:"flex"},children:[e.jsx(Mn,{size:17,"aria-hidden":"true"}),e.jsx(Ve,{size:9,strokeWidth:3,"aria-hidden":"true",style:{position:"absolute",right:-4,bottom:-2}})]})}),a&&c&&Ie.createPortal(e.jsxs("dialog",{ref:d,"data-toolbar-overlay":!0,onClose:()=>s(!1),"aria-labelledby":"pwa-install-title",style:{maxWidth:340,width:"calc(100% - 40px)",margin:"auto",padding:24,borderRadius:16,border:"1px solid var(--ui-tabbar-border)",background:"var(--ui-root-bg)",color:"var(--ui-text)",whiteSpace:"normal",font:"14px/1.8 system-ui"},children:[e.jsx("h2",{id:"pwa-install-title",style:{margin:"0 0 12px",fontSize:18},children:t?"已添加到主屏幕":"添加到主屏幕"}),t&&e.jsx("p",{children:"当前已在主屏幕应用中打开。"}),e.jsx("p",{children:"iPhone / iPad:在 Safari 点击分享按钮,选择“添加到主屏幕”,再点“添加”。"}),e.jsx("p",{children:"Android:打开浏览器菜单,选择“安装应用”或“添加到主屏幕”。"}),e.jsx("p",{style:{color:"var(--ui-muted-text)"},children:"浏览器需要你确认,网页无法自动添加。从主屏幕打开后,如提示未配对,请重新扫码。"}),e.jsx("button",{type:"button",style:{...to,width:"100%",padding:"10px 14px",borderStyle:"solid",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:()=>{var p;return(p=d.current)==null?void 0:p.close()},children:"知道了"})]}),c)]})}const hn={shared:"已共享",independent:"独立后台",failed:"连接失败",stopped:"桌面未启动","not-installed":"桌面未安装",unsupported:"暂不支持"};function ro({csrfToken:t}){const[o,a]=n.useState(null),[s,c]=n.useState(!1),u=n.useRef(!1),d=n.useRef(0),p=n.useCallback(async(l=!1,v=!1,S=!1)=>{var m;if(u.current)return;u.current=!0;const P=d.current;c(!0);try{const g=await fetch("/api/agent/codex-sharing",{method:l||v?"POST":"GET",credentials:"same-origin",cache:"no-store",headers:l||v?{"x-csrf-token":t,...v?{"content-type":"application/json"}:{}}:void 0,body:v?JSON.stringify({action:"share",restartConfirmed:S}):void 0,signal:AbortSignal.timeout(18e4)}),h=await g.json();if(!g.ok||!Object.hasOwn(hn,h==null?void 0:h.state))throw new Error(((m=h==null?void 0:h.error)==null?void 0:m.message)||"共享状态读取失败,请重试。");if(P!==d.current)return;a(h)}catch(g){if(P!==d.current)return;a({state:"failed",configured:!1,autoStart:!1,daemonReachable:!1,runtimeMode:null,message:g instanceof Error?g.message:"无法连接当前电脑。"})}finally{u.current=!1,P===d.current&&c(!1)}},[t]);n.useEffect(()=>{p();const l=()=>{document.hidden||p()},v=window.setInterval(l,15e3);return window.addEventListener("online",l),()=>{d.current++,window.clearInterval(v),window.removeEventListener("online",l)}},[p]);const k=o?hn[o.state]:"检查中",j=()=>{const l=(o==null?void 0:o.state)!=="stopped";l&&!window.confirm("切换将强制重启 Codex 桌面,中断桌面任务并可能丢失未发送内容,不再显示 Codex 退出确认框。共享后端和手机会话不会被结束。是否继续?")||p(!1,!0,l)},R=o&&o.state!=="unsupported"&&(o.state!=="shared"||!o.configured||!o.autoStart||!o.daemonReachable);return e.jsxs("div",{className:"codex-sharing",children:[e.jsx("style",{children:oo}),e.jsxs("div",{className:"codex-sharing-title",role:"status",children:[e.jsx("span",{className:"codex-sharing-indicator","aria-hidden":"true",children:e.jsx("span",{className:"codex-sharing-dot","data-state":o==null?void 0:o.state})}),e.jsxs("span",{children:["Codex · ",k]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx("p",{children:o.state==="shared"?"共享连接可用,启动配置需要修复。":o.message}),e.jsxs("div",{className:"codex-sharing-actions",children:[e.jsxs("button",{type:"button",disabled:s,onClick:()=>{p()},"aria-label":"刷新 Codex 共享状态",children:[e.jsx(xe,{size:12}),"刷新"]}),e.jsx("button",{type:"button",disabled:s,onClick:()=>{p(!0)},children:s?"正在修复…":"检查并修复"}),!["shared","not-installed"].includes(o.state)&&e.jsx("button",{type:"button",disabled:s,onClick:j,children:s?"正在处理…":o.state==="stopped"?"以共享模式启动 Codex":"切换到共享后端"})]})]})]})}const oo=`
|
|
18
13
|
.codex-sharing{padding:10px 14px;margin-bottom:6px;border-bottom:1px solid var(--ui-tabbar-border,#303442);color:var(--ui-text,#e8e8ee);font-size:13px;line-height:20px}
|
|
19
14
|
.codex-sharing-title{display:flex;align-items:center;gap:10px}
|
|
20
15
|
.codex-sharing-indicator{display:grid;place-items:center;flex:0 0 17px;height:17px}
|
|
@@ -28,7 +23,7 @@ import{c as xt,r as n,j as e,f as Ve,e as Ie,R as xe,X as Ee,n as cr,o as lr,p a
|
|
|
28
23
|
.codex-sharing-actions button:focus-visible{outline:2px solid var(--ui-tab-accent,#7aa2f7);outline-offset:3px}
|
|
29
24
|
.codex-sharing-actions button:disabled{opacity:.5;cursor:wait}
|
|
30
25
|
@media(pointer:coarse){.codex-sharing-actions button{min-height:44px}}
|
|
31
|
-
`;function oo({computerName:t,page:o,onClose:a,onSave:s}){const[c,u]=n.useState((o==null?void 0:o.name)??""),[d,p]=n.useState((o==null?void 0:o.url)??""),[k,j]=n.useState((o==null?void 0:o.openMode)??"current"),[R,l]=n.useState(!!o),[v,S]=n.useState(""),[P,m]=n.useState(!1),g=n.useRef(!1),h=n.useRef(null);return n.useEffect(()=>{var T,N;(N=(T=h.current)==null?void 0:T.querySelector("input"))==null||N.focus();const w=D=>{var H;if(D.key==="Escape"&&!g.current&&a(),D.key!=="Tab")return;const _=(H=h.current)==null?void 0:H.querySelectorAll("button:not(:disabled), input:not(:disabled), select:not(:disabled)");if(!(_!=null&&_.length))return;const ee=_[0],re=_[_.length-1];D.shiftKey&&document.activeElement===ee?(D.preventDefault(),re.focus()):!D.shiftKey&&document.activeElement===re&&(D.preventDefault(),ee.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:w=>{w.target===w.currentTarget&&!g.current&&a()},children:e.jsxs("section",{ref:h,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-page-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-page-title",children:o?"编辑页面":"添加页面"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",disabled:P,onClick:a,children:e.jsx(Ee,{size:20})})]}),e.jsxs("p",{className:"computer-hint",children:["所属电脑:",t]}),e.jsxs("form",{onSubmit:async w=>{if(w.preventDefault(),!g.current){g.current=!0,m(!0),S("");try{const T=lr(d),N=(o==null?void 0:o.id)??Array.from(crypto.getRandomValues(new Uint8Array(16)),D=>D.toString(16).padStart(2,"0")).join("");await s({id:N,name:c.trim(),url:T,openMode:k})}catch(T){S(T.message)}finally{g.current=!1,m(!1)}}},children:[e.jsx("label",{htmlFor:"computer-page-name",children:"页面名称"}),e.jsx("input",{id:"computer-page-name",maxLength:60,required:!0,disabled:P,value:c,onChange:w=>u(w.target.value),placeholder:"例如:Zcode / Qoder",autoComplete:"off"}),e.jsx("label",{htmlFor:"computer-page-url",children:"页面地址"}),e.jsx("input",{id:"computer-page-url",required:!0,disabled:P,value:d,onChange:w=>{p(w.target.value),R||j(cr(w.target.value))},placeholder:"https://…",autoComplete:"off",spellCheck:!1}),e.jsx("label",{htmlFor:"computer-page-mode",children:"打开方式"}),e.jsxs("select",{id:"computer-page-mode",disabled:P,value:k,onChange:w=>{j(w.target.value),l(!0)},children:[e.jsx("option",{value:"current",children:"当前页面打开,保留顶部图标栏"}),e.jsx("option",{value:"new-tab",children:"新页面打开,保留原会话页"})]}),e.jsx("p",{className:"computer-hint",children:"当前页面会显示网站自己的界面。若网站禁止内嵌(如 Qoder),可改为新页面打开。"}),v&&e.jsx("p",{className:"computer-error",role:"alert",children:v}),e.jsx("button",{type:"submit",className:"computer-action computer-primary",disabled:P||!c.trim()||!d.trim(),children:P?"正在保存…":"保存页面"})]})]})})}async function io(t,o){const a=new AbortController,s=()=>a.abort();if(o!=null&&o.aborted)return"offline";o==null||o.addEventListener("abort",s,{once:!0});const c=setTimeout(s,4e3);try{const u=new URL("/pwa/icon-192.png",t);u.searchParams.set("online",String(Date.now()));const d=await fetch(u,{mode:"no-cors",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",signal:a.signal});return d.type==="opaque"||d.ok?"online":"offline"}catch{return"offline"}finally{clearTimeout(c),o==null||o.removeEventListener("abort",s)}}const ao=20;function ht(t){if(!Array.isArray(t)||t.length>ao)throw new Error("最多可添加 20 台电脑。");const o=new Set;return t.map(a=>{if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(c=>!["origin","name"].includes(c))||typeof a.origin!="string"||a.origin.length>2048)throw new Error("电脑地址无效。");let s;try{s=new URL(a.origin)}catch{throw new Error("电脑地址无效。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password||s.pathname!=="/"||s.search||s.hash||o.has(s.origin))throw new Error("电脑地址无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("电脑名称需为 1–60 个字符。");return o.add(s.origin),{origin:s.origin,name:a.name.trim()}})}async function bn(t,o="GET",a){var u;const s=await fetch("/api/web-console/computers",{method:o,credentials:"same-origin",cache:"no-store",headers:a?{"content-type":"application/json","x-csrf-token":t}:void 0,body:a?JSON.stringify(a):void 0,signal:AbortSignal.timeout(15e3)}).catch(()=>{throw new Error("无法连接当前电脑,请检查连接后重试。")}),c=await s.json().catch(()=>null);if(!s.ok)throw new Error(((u=c==null?void 0:c.error)==null?void 0:u.message)??"电脑列表保存失败,请重试。");return ht(c==null?void 0:c.computers)}function so(t){const[o,a]=n.useState([]),[s,c]=n.useState(!1),[u,d]=n.useState(!1),[p,k]=n.useState(""),j=n.useRef(!0),R=n.useRef(!1),l=n.useRef(0),v=n.useRef(!1),S=n.useCallback(T=>{if(j.current){a(N=>N.length===T.length&&N.every((D,_)=>D.origin===T[_].origin&&D.name===T[_].name)?N:T),c(!0);try{const N=De();In(T.map(D=>({...N.find(_=>_.origin===D.origin),...D})))}catch{}}},[]),P=n.useCallback(async()=>{if(R.current)return;const T=++l.current;try{const N=v.current?void 0:dr(Me(),void 0).map(({origin:_,name:ee})=>({origin:_,name:ee})),D=await bn(t,N?"POST":"GET",N?{computers:N}:void 0);if(!j.current||T!==l.current)return;v.current=!0,S(D),k("")}catch(N){j.current&&T===l.current&&k(N instanceof Error?N.message:"无法读取电脑列表。")}},[S,t]);n.useEffect(()=>{j.current=!0,P();const T=()=>{document.hidden||P()};window.addEventListener("focus",T),window.addEventListener("pageshow",T);const N=window.setInterval(T,15e3);return()=>{j.current=!1,l.current++,window.removeEventListener("focus",T),window.removeEventListener("pageshow",T),window.clearInterval(N)}},[P]);const m=n.useCallback(async(T,N)=>{if(!s||R.current)throw new Error("电脑列表尚未就绪,请稍后重试。");R.current=!0,l.current++,d(!0),k("");try{S(await bn(t,T,N))}catch(D){const _=D instanceof Error?D.message:"电脑列表保存失败,请重试。";throw j.current&&k(_),new Error(_)}finally{R.current=!1,j.current&&d(!1)}},[S,t,s]),g=n.useCallback((T,N)=>m("PATCH",ht([{origin:T,name:N}])[0]),[m]),h=n.useCallback(async T=>{if(new URL(T).origin===Me())throw new Error("不能删除当前连接的电脑。");await m("DELETE",{origin:T})},[m]),w=n.useCallback((T,N)=>m("POST",{computers:ht([{origin:T,name:N}]),restore:!0}),[m]);return{computers:o,loaded:s,saving:u,error:p,reload:P,rename:g,remove:h,add:w}}let wn;function zn(){return window.jsQR?Promise.resolve():wn||(wn=new Promise((t,o)=>{const a=document.createElement("script");a.src="/pwa/qr-decoder.js";const s=()=>{clearTimeout(c),wn=null,a.remove(),o(new Error("二维码识别器加载失败,请重试。"))},c=setTimeout(s,1e4);a.onload=()=>{clearTimeout(c),t()},a.onerror=s,document.head.append(a)}))}function gt(){var t;return!!(window.isSecureContext&&((t=navigator.mediaDevices)!=null&&t.getUserMedia))}async function co(t){if(!t||t.type&&!t.type.startsWith("image/"))throw new Error("请选择二维码照片。");if(t.size>20*1024*1024)throw new Error("照片过大,请重新拍摄二维码。");await zn();const o=new Image,a=URL.createObjectURL(t);try{await new Promise((u,d)=>{const p=setTimeout(()=>d(new Error("照片加载超时,请重新拍摄。")),1e4);o.onload=()=>{clearTimeout(p),u()},o.onerror=()=>{clearTimeout(p),d(new Error("无法读取照片,请重新拍摄二维码。"))},o.src=a});const s=document.createElement("canvas"),c=s.getContext("2d",{willReadFrequently:!0});for(const u of[1600,1024,640]){const d=Math.min(1,u/Math.max(o.naturalWidth,o.naturalHeight));s.width=Math.max(1,Math.round(o.naturalWidth*d)),s.height=Math.max(1,Math.round(o.naturalHeight*d)),c.drawImage(o,0,0,s.width,s.height);const p=c.getImageData(0,0,s.width,s.height),k=window.jsQR(p.data,p.width,p.height);if(k)return k.data}throw new Error("照片中没有识别到二维码,请靠近电脑屏幕重新拍摄。")}finally{o.onload=null,o.onerror=null,URL.revokeObjectURL(a)}}function lo(t,o,a){let s,c=0,u;const d=()=>{c++,clearTimeout(u),s==null||s.getTracks().forEach(R=>R.stop()),s=null,t.srcObject=null},p=(R,l)=>{R===c&&(d(),a((l==null?void 0:l.name)==="NotAllowedError"?"相机权限未开启,请允许相机或粘贴二维码链接。":(l==null?void 0:l.message)||"无法启动扫码,请重试。"))},k=async()=>{d();const R=c;if(!gt()){a("实时扫码需要 HTTPS,请使用拍照扫码。");return}try{if(await zn(),R!==c)return;const l=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});if(R!==c){l.getTracks().forEach(g=>g.stop());return}s=l,t.srcObject=l;let v;try{await Promise.race([t.play(),new Promise((g,h)=>{v=setTimeout(()=>h(new Error("相机没有返回画面,请重试。")),1e4)})])}finally{clearTimeout(v)}if(R!==c)return;const S=document.createElement("canvas"),P=S.getContext("2d",{willReadFrequently:!0}),m=()=>{if(R===c)try{if(t.videoWidth&&t.videoHeight){S.width=Math.min(t.videoWidth,640),S.height=Math.round(t.videoHeight*S.width/t.videoWidth),P.drawImage(t,0,0,S.width,S.height);const g=P.getImageData(0,0,S.width,S.height),h=window.jsQR(g.data,g.width,g.height);if(h){d(),o(h.data);return}}u=setTimeout(m,250)}catch(g){d(),a((g==null?void 0:g.message)||"二维码识别失败,请重试。")}};m()}catch(l){p(R,l)}},j=()=>{document.hidden&&d()};return window.addEventListener("pagehide",d),document.addEventListener("visibilitychange",j),{start:k,stop:d,dispose(){d(),window.removeEventListener("pagehide",d),document.removeEventListener("visibilitychange",j)}}}const uo=[{id:"refresh",name:"刷新",Icon:xe},{id:"dashboard",name:"Dashboard",Icon:On},{id:"collaboration",name:"群聊列表",Icon:yt},{id:"remote",name:"远程桌面",Icon:ct},{id:"theme",name:"皮肤",Icon:An},{id:"files",name:"文件树",Icon:gr},{id:"ai-hub",name:"AI Hub",Icon:Dn},{id:"flow",name:"数字人",Icon:vt},{id:"install",name:"添加到主屏幕",Icon:Mn}];function po({username:t,connected:o,accent:a,accentText:s,selectedPageId:c,onSelectPage:u,onUpdatePage:d,configuration:p,csrfToken:k}){const j=n.useRef(null),R=n.useRef(null),l=so(k),v=l.computers,[S,P]=n.useState(""),[m,g]=n.useState(null),[h,w]=n.useState(!1),[T,N]=n.useState("home"),[D,_]=n.useState(!1),[ee,re]=n.useState({top:48,right:12}),[H,te]=n.useState(null),[I,C]=n.useState(null),[O,U]=n.useState(""),[B,z]=n.useState({}),x=v.find(b=>b.origin===S),W=p.settings.savedPages??[];n.useEffect(()=>{var b;p.loaded&&c&&d(((b=p.settings.savedPages)==null?void 0:b.find(M=>M.id===c))??null)},[p.loaded,p.settings.savedPages,c,d]),n.useEffect(()=>{var V;P(Me()),g(((V=j.current)==null?void 0:V.closest(".web-root"))??document.body);const b=window.matchMedia("(max-width: 600px)"),M=()=>_(b.matches);return M(),b.addEventListener("change",M),()=>{b.removeEventListener("change",M)}},[]),n.useEffect(()=>{if(!h)return;const b=q=>{var G,X;!((G=R.current)!=null&&G.contains(q.target))&&!((X=j.current)!=null&&X.contains(q.target))&&w(!1)},M=q=>{var Se,le;if(q.key==="Escape"&&(w(!1),(Se=j.current)==null||Se.focus()),!D||q.key!=="Tab")return;const G=(le=R.current)==null?void 0:le.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(G!=null&&G.length))return;const X=G[0],ce=G[G.length-1];q.shiftKey&&document.activeElement===X?(q.preventDefault(),ce.focus()):!q.shiftKey&&document.activeElement===ce&&(q.preventDefault(),X.focus())},V=()=>{var X;const q=(X=j.current)==null?void 0:X.getBoundingClientRect();if(!q)return;const G=Math.min(292,innerWidth-24);re({top:q.bottom+8,right:Math.max(12,Math.min(innerWidth-G-12,innerWidth-q.right))})};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",M),window.addEventListener("resize",V),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",M),window.removeEventListener("resize",V)}},[h,D]),n.useEffect(()=>{var b,M;h&&((M=(b=R.current)==null?void 0:b.querySelector("button"))==null||M.focus())},[h,T]),n.useEffect(()=>{if(!h)return;const b=new AbortController,M=()=>{for(const q of v)q.origin!==S&&io(q.origin,b.signal).then(G=>{b.signal.aborted||z(X=>({...X,[q.origin]:G}))})};M();const V=window.setInterval(M,15e3);return window.addEventListener("online",M),()=>{b.abort(),window.clearInterval(V),window.removeEventListener("online",M)}},[h,v,S]);const K=n.useCallback(()=>{var b;te(null),(b=j.current)==null||b.focus()},[]),A=n.useCallback(()=>{var b;C(null),(b=j.current)==null||b.focus()},[]),L=n.useCallback(async(b,M)=>{var X;if(He()){await He().pair(b);return}const V=ur(b),q={origin:V.origin,name:M.trim()||((X=v.find(ce=>ce.origin===V.origin))==null?void 0:X.name)||V.hostname},G=pr(b,dn(De(),v,[q]),M);await l.add(q.origin,q.name),location.assign(G)},[v,l.add]),se=n.useCallback(async b=>{await l.rename(Me(),b),K()},[K,l.rename]);return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:fo}),e.jsxs("div",{className:"theme-avatar-with-status",children:[e.jsx("button",{ref:j,type:"button",className:"theme-avatar","aria-label":`电脑与连接状态(${t})`,title:t,style:{border:`1px solid ${a}`,background:a,color:s},"aria-expanded":h,"aria-haspopup":"true",onClick:()=>{const b=j.current.getBoundingClientRect(),M=Math.min(292,innerWidth-24);re({top:b.bottom+8,right:Math.max(12,Math.min(innerWidth-M-12,innerWidth-b.right))}),h||(N("home"),U(""),p.reload(),l.reload()),w(V=>!V)},children:(t.trim()[0]??"?").toUpperCase()}),e.jsx("span",{className:"theme-avatar-status","data-connected":o,"aria-label":o?"已连接":"未连接"})]}),h&&m&&Ie.createPortal(e.jsx("div",{className:"computer-menu-backdrop","data-toolbar-overlay":!0,children:e.jsxs("div",{ref:R,className:"computer-menu",style:D?void 0:ee,role:"dialog","aria-modal":D,"aria-label":T==="tools"?"配置顶部工具":T==="computers"?"选择电脑":"电脑与保存页面",children:[e.jsx("div",{className:"computer-menu-grip","aria-hidden":"true"}),e.jsxs("div",{className:"computer-menu-heading",children:[T!=="home"&&e.jsx("button",{type:"button",className:"computer-close","aria-label":"返回电脑菜单",onClick:()=>N("home"),children:e.jsx(mr,{size:20})}),T==="home"?e.jsxs("button",{type:"button",className:"computer-menu-item computer-current","aria-label":"选择电脑",onClick:()=>N("computers"),children:[e.jsx(mn,{size:17}),e.jsxs("span",{children:[e.jsx("strong",{children:(x==null?void 0:x.name)||"当前电脑"}),e.jsx("small",{children:o?"当前 · 在线":"当前 · 未连接"})]}),e.jsx(fr,{size:16})]}):e.jsx("strong",{children:T==="tools"?`${(x==null?void 0:x.name)||"当前电脑"} · 顶部工具`:"选择电脑"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭电脑菜单",onClick:()=>{var b;w(!1),(b=j.current)==null||b.focus()},children:e.jsx(Ee,{size:20})})]}),T==="computers"&&e.jsxs(e.Fragment,{children:[!l.loaded&&e.jsx("p",{className:"computer-save-status",role:"status",children:l.error?"电脑列表尚未加载":"正在读取电脑列表…"}),v.map(b=>{const M=b.origin===S?o?"online":"offline":B[b.origin]??"checking",V=M==="online"?"在线":M==="offline"?"无法连接":"检测中";return e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","data-computer-origin":b.origin,"aria-label":`${b.name},${V}${b.origin===S?",当前电脑":""}`,"aria-current":b.origin===S?"true":void 0,onClick:()=>{if(b.origin===S)N("home");else try{const q=He();q?q.switchComputer(b.origin).catch(G=>U(G.message)):location.assign(hr(b.origin,dn(De(),v)))}catch(q){U(q.message)}},children:[e.jsx(mn,{size:17,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsx("small",{children:b.origin})]}),e.jsx("span",{className:"computer-status-dot","data-status":M,role:"img","aria-label":V,title:V}),b.origin===S&&e.jsx(pt,{size:16,"aria-label":"当前电脑"})]}),b.origin!==S&&e.jsx("button",{type:"button",className:"computer-page-control computer-delete-control","aria-label":`删除电脑:${b.name}`,title:`删除电脑:${b.name}`,disabled:l.saving,onClick:()=>{l.remove(b.origin).catch(()=>{})},children:e.jsx(kt,{size:15})})]},b.origin)}),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!l.loaded||l.saving,onClick:()=>{const b=He();b?b.scan().catch(M=>U(M.message)):(w(!1),te("add"))},children:[e.jsx(Ve,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"扫码添加电脑"})]}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!l.loaded||l.saving||!x,onClick:()=>{w(!1),te("rename")},children:[e.jsx(mt,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"修改当前电脑名称"})]}),l.error&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:l.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{l.reload()},children:[e.jsx(xe,{size:16}),e.jsx("span",{children:"重新加载电脑列表"})]})]})]}),T==="home"&&e.jsxs(e.Fragment,{children:[e.jsx(no,{csrfToken:k}),e.jsxs("div",{className:"computer-menu-label computer-pages-heading",children:[e.jsx("span",{children:"保存的页面"}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":"添加页面",disabled:!p.loaded||p.saving,onClick:()=>{w(!1),C({computer:x??{origin:S,name:"当前电脑"}})},children:e.jsx(Ve,{size:17})})]}),e.jsxs("button",{type:"button",className:"computer-menu-item","aria-current":c?void 0:"true",onClick:()=>{w(!1),u(null)},children:[e.jsx(Qr,{size:17}),e.jsx("span",{children:"电脑会话"}),!c&&e.jsx(pt,{size:16})]}),W.map(b=>e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","aria-label":`打开 ${b.name}`,"aria-current":c===b.id?"true":void 0,onClick:()=>{w(!1),u(b)},children:[e.jsx(ft,{size:15,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsxs("small",{children:[b.openMode==="current"?"当前页面":"新页面"," · ",new URL(b.url).hostname]})]}),b.openMode==="new-tab"&&e.jsx(jt,{size:13,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`编辑 ${b.name}`,disabled:p.saving,onClick:()=>{w(!1),C({computer:x??{origin:S,name:"当前电脑"},page:b})},children:e.jsx(mt,{size:14})}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`删除 ${b.name}`,disabled:p.saving,onClick:()=>{p.setSavedPages(W.filter(M=>M.id!==b.id)).catch(()=>{})},children:e.jsx(Ee,{size:15})})]},b.id)),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>N("tools"),children:[e.jsx(Ir,{size:17}),e.jsx("span",{children:"配置顶部工具"}),e.jsx(Wr,{size:16})]})]}),T==="tools"&&e.jsx("div",{className:"computer-tools-list",children:uo.map(({id:b,name:M,Icon:V})=>e.jsxs("label",{className:"computer-tool-option",children:[e.jsx(V,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:M}),e.jsx("input",{type:"checkbox","aria-label":`显示${M}`,checked:p.settings.visibleTools.includes(b),disabled:!p.loaded||p.saving,onChange:q=>{const G=p.settings.visibleTools;p.setVisibleTools(q.target.checked?[...G,b]:G.filter(X=>X!==b)).catch(()=>{})}})]},b))}),T!=="computers"&&e.jsx("p",{className:"computer-save-status",role:"status",children:p.loaded?p.saving?"正在保存…":p.notice:p.error?"配置尚未加载":"正在读取电脑配置…"}),p.error&&T!=="computers"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:p.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{p.reload()},children:[e.jsx(xe,{size:16}),e.jsx("span",{children:"重新加载配置"})]})]}),O&&e.jsx("p",{className:"computer-error",role:"alert",children:O})]})}),m),H&&m&&Ie.createPortal(e.jsx(mo,{mode:H,currentName:(x==null?void 0:x.name)||"",onClose:K,onNavigate:L,onRename:se}),m),I&&m&&Ie.createPortal(e.jsx(oo,{computerName:I.computer.name,page:I.page,onClose:A,onSave:async b=>{if(I.page&&!W.some(M=>M.id===b.id))throw new Error("这个页面已在其他设备删除,请重新添加。");await p.setSavedPages(I.page?W.map(M=>M.id===b.id?b:M):[...W,b]),A()}}),m)]})}function mo({mode:t,currentName:o,onClose:a,onNavigate:s,onRename:c}){const[u,d]=n.useState(t==="rename"?o:""),p=n.useRef(u);p.current=u;const[k,j]=n.useState(""),[R,l]=n.useState(""),[v,S]=n.useState(!1),[P,m]=n.useState(!1),[g,h]=n.useState(!1),[w,T]=n.useState(!1),N=n.useRef(null),D=n.useRef(null),_=n.useRef(0),ee=n.useRef(null),re=n.useRef(null),H=n.useRef(null),te=n.useCallback(async I=>{var C;S(!0),(C=H.current)==null||C.stop(),m(!1),l("");try{await s(I,p.current)}catch(O){l(O.message)}finally{S(!1)}},[s]);return n.useEffect(()=>{var O,U,B;h(gt()),t==="rename"?(O=ee.current)==null||O.focus():(B=(U=re.current)==null?void 0:U.querySelector("button"))==null||B.focus();const I=z=>{var A;if(z.key==="Escape"&&a(),z.key!=="Tab")return;const x=(A=re.current)==null?void 0:A.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(x!=null&&x.length))return;const W=x[0],K=x[x.length-1];z.shiftKey&&document.activeElement===W?(z.preventDefault(),K.focus()):!z.shiftKey&&document.activeElement===K&&(z.preventDefault(),W.focus())},C=()=>{document.hidden&&m(!1)};return document.addEventListener("keydown",I),document.addEventListener("visibilitychange",C),t==="add"&&N.current&&(H.current=lo(N.current,te,z=>{m(!1),l(z)})),()=>{var z;_.current++,document.removeEventListener("keydown",I),document.removeEventListener("visibilitychange",C),(z=H.current)==null||z.dispose(),H.current=null}},[t,te,a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:I=>{I.target===I.currentTarget&&a()},children:e.jsxs("section",{ref:re,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-dialog-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-dialog-title",children:t==="add"?"添加电脑":"修改电脑名称"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",onClick:a,children:e.jsx(Ee,{size:20})})]}),e.jsxs("form",{onSubmit:async I=>{if(I.preventDefault(),!v)if(t==="add")await te(k);else{S(!0);try{await c(u.trim())}catch(C){l(C.message)}finally{S(!1)}}},children:[e.jsxs("label",{htmlFor:"computer-name",children:["电脑名称",t==="add"?"(选填)":""]}),e.jsx("input",{ref:ee,id:"computer-name",maxLength:60,value:u,required:t==="rename",disabled:v,onChange:I=>d(I.target.value),placeholder:"例如:A 电脑 / 家里的电脑",autoComplete:"off"}),t==="add"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-hint",children:"扫描另一台电脑上的 AgentRoam 授权二维码,连接后会保留已有电脑。"}),e.jsx("input",{ref:D,type:"file",accept:"image/*",capture:"environment",hidden:!0,"aria-label":"拍摄授权二维码",onChange:async I=>{var U,B;const C=(U=I.currentTarget.files)==null?void 0:U[0];if(I.currentTarget.value="",!C)return;const O=++_.current;(B=H.current)==null||B.stop(),m(!1),T(!0),l("");try{const z=await co(C);O===_.current&&te(z)}catch(z){O===_.current&&l(z.message)}finally{O===_.current&&T(!1)}}}),e.jsx("video",{ref:N,playsInline:!0,muted:!0,hidden:!P,"aria-label":"扫码相机画面"}),e.jsxs("button",{className:"computer-action",type:"button",disabled:w,onClick:()=>{var I,C,O;l(""),P?((I=H.current)==null||I.stop(),m(!1)):gt()?(m(!0),(O=H.current)==null||O.start()):(C=D.current)==null||C.click()},children:[e.jsx(br,{size:17,"aria-hidden":"true"}),w?"正在识别二维码…":P?"取消扫码":g?"打开相机扫码":"拍照扫码"]}),g&&e.jsx("button",{className:"computer-action",type:"button",disabled:w,onClick:()=>{var I,C;(I=H.current)==null||I.stop(),m(!1),(C=D.current)==null||C.click()},children:"拍照识别二维码"}),e.jsx("label",{htmlFor:"computer-link",children:"或粘贴授权二维码链接"}),e.jsx("input",{id:"computer-link",value:k,onChange:I=>j(I.target.value),placeholder:"http(s)://…/pair#pair=…",autoComplete:"off",spellCheck:!1})]}),R&&e.jsx("p",{className:"computer-error",role:"alert",children:R}),e.jsx("button",{className:"computer-action computer-primary",type:"submit",disabled:v||(t==="add"?!k.trim()||w:!u.trim()),children:t==="add"?"连接这台电脑":v?"正在保存…":"保存名称"})]})]})})}const fo=`
|
|
26
|
+
`;function io({computerName:t,page:o,onClose:a,onSave:s}){const[c,u]=n.useState((o==null?void 0:o.name)??""),[d,p]=n.useState((o==null?void 0:o.url)??""),[k,j]=n.useState((o==null?void 0:o.openMode)??"current"),[R,l]=n.useState(!!o),[v,S]=n.useState(""),[P,m]=n.useState(!1),g=n.useRef(!1),h=n.useRef(null);return n.useEffect(()=>{var T,N;(N=(T=h.current)==null?void 0:T.querySelector("input"))==null||N.focus();const w=D=>{var H;if(D.key==="Escape"&&!g.current&&a(),D.key!=="Tab")return;const _=(H=h.current)==null?void 0:H.querySelectorAll("button:not(:disabled), input:not(:disabled), select:not(:disabled)");if(!(_!=null&&_.length))return;const ee=_[0],re=_[_.length-1];D.shiftKey&&document.activeElement===ee?(D.preventDefault(),re.focus()):!D.shiftKey&&document.activeElement===re&&(D.preventDefault(),ee.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:w=>{w.target===w.currentTarget&&!g.current&&a()},children:e.jsxs("section",{ref:h,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-page-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-page-title",children:o?"编辑页面":"添加页面"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",disabled:P,onClick:a,children:e.jsx(Ee,{size:20})})]}),e.jsxs("p",{className:"computer-hint",children:["所属电脑:",t]}),e.jsxs("form",{onSubmit:async w=>{if(w.preventDefault(),!g.current){g.current=!0,m(!0),S("");try{const T=lr(d),N=(o==null?void 0:o.id)??Array.from(crypto.getRandomValues(new Uint8Array(16)),D=>D.toString(16).padStart(2,"0")).join("");await s({id:N,name:c.trim(),url:T,openMode:k})}catch(T){S(T.message)}finally{g.current=!1,m(!1)}}},children:[e.jsx("label",{htmlFor:"computer-page-name",children:"页面名称"}),e.jsx("input",{id:"computer-page-name",maxLength:60,required:!0,disabled:P,value:c,onChange:w=>u(w.target.value),placeholder:"例如:Zcode / Qoder",autoComplete:"off"}),e.jsx("label",{htmlFor:"computer-page-url",children:"页面地址"}),e.jsx("input",{id:"computer-page-url",required:!0,disabled:P,value:d,onChange:w=>{p(w.target.value),R||j(cr(w.target.value))},placeholder:"https://…",autoComplete:"off",spellCheck:!1}),e.jsx("label",{htmlFor:"computer-page-mode",children:"打开方式"}),e.jsxs("select",{id:"computer-page-mode",disabled:P,value:k,onChange:w=>{j(w.target.value),l(!0)},children:[e.jsx("option",{value:"current",children:"当前页面打开,保留顶部图标栏"}),e.jsx("option",{value:"new-tab",children:"新页面打开,保留原会话页"})]}),e.jsx("p",{className:"computer-hint",children:"当前页面会显示网站自己的界面。若网站禁止内嵌(如 Qoder),可改为新页面打开。"}),v&&e.jsx("p",{className:"computer-error",role:"alert",children:v}),e.jsx("button",{type:"submit",className:"computer-action computer-primary",disabled:P||!c.trim()||!d.trim(),children:P?"正在保存…":"保存页面"})]})]})})}async function ao(t,o){const a=new AbortController,s=()=>a.abort();if(o!=null&&o.aborted)return"offline";o==null||o.addEventListener("abort",s,{once:!0});const c=setTimeout(s,4e3);try{const u=new URL("/pwa/icon-192.png",t);u.searchParams.set("online",String(Date.now()));const d=await fetch(u,{mode:"no-cors",credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",signal:a.signal});return d.type==="opaque"||d.ok?"online":"offline"}catch{return"offline"}finally{clearTimeout(c),o==null||o.removeEventListener("abort",s)}}const so=20;function ht(t){if(!Array.isArray(t)||t.length>so)throw new Error("最多可添加 20 台电脑。");const o=new Set;return t.map(a=>{if(!a||typeof a!="object"||Array.isArray(a)||Object.keys(a).some(c=>!["origin","name"].includes(c))||typeof a.origin!="string"||a.origin.length>2048)throw new Error("电脑地址无效。");let s;try{s=new URL(a.origin)}catch{throw new Error("电脑地址无效。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password||s.pathname!=="/"||s.search||s.hash||o.has(s.origin))throw new Error("电脑地址无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("电脑名称需为 1–60 个字符。");return o.add(s.origin),{origin:s.origin,name:a.name.trim()}})}async function gn(t,o="GET",a){var u;const s=await fetch("/api/web-console/computers",{method:o,credentials:"same-origin",cache:"no-store",headers:a?{"content-type":"application/json","x-csrf-token":t}:void 0,body:a?JSON.stringify(a):void 0,signal:AbortSignal.timeout(15e3)}).catch(()=>{throw new Error("无法连接当前电脑,请检查连接后重试。")}),c=await s.json().catch(()=>null);if(!s.ok)throw new Error(((u=c==null?void 0:c.error)==null?void 0:u.message)??"电脑列表保存失败,请重试。");return ht(c==null?void 0:c.computers)}function co(t){const[o,a]=n.useState([]),[s,c]=n.useState(!1),[u,d]=n.useState(!1),[p,k]=n.useState(""),j=n.useRef(!0),R=n.useRef(!1),l=n.useRef(0),v=n.useRef(!1),S=n.useCallback(T=>{if(j.current){a(N=>N.length===T.length&&N.every((D,_)=>D.origin===T[_].origin&&D.name===T[_].name)?N:T),c(!0);try{const N=De();In(T.map(D=>({...N.find(_=>_.origin===D.origin),...D})))}catch{}}},[]),P=n.useCallback(async()=>{if(R.current)return;const T=++l.current;try{const N=v.current?void 0:dr(Me(),void 0).map(({origin:_,name:ee})=>({origin:_,name:ee})),D=await gn(t,N?"POST":"GET",N?{computers:N}:void 0);if(!j.current||T!==l.current)return;v.current=!0,S(D),k("")}catch(N){j.current&&T===l.current&&k(N instanceof Error?N.message:"无法读取电脑列表。")}},[S,t]);n.useEffect(()=>{j.current=!0,P();const T=()=>{document.hidden||P()};window.addEventListener("focus",T),window.addEventListener("pageshow",T);const N=window.setInterval(T,15e3);return()=>{j.current=!1,l.current++,window.removeEventListener("focus",T),window.removeEventListener("pageshow",T),window.clearInterval(N)}},[P]);const m=n.useCallback(async(T,N)=>{if(!s||R.current)throw new Error("电脑列表尚未就绪,请稍后重试。");R.current=!0,l.current++,d(!0),k("");try{S(await gn(t,T,N))}catch(D){const _=D instanceof Error?D.message:"电脑列表保存失败,请重试。";throw j.current&&k(_),new Error(_)}finally{R.current=!1,j.current&&d(!1)}},[S,t,s]),g=n.useCallback((T,N)=>m("PATCH",ht([{origin:T,name:N}])[0]),[m]),h=n.useCallback(async T=>{if(new URL(T).origin===Me())throw new Error("不能删除当前连接的电脑。");await m("DELETE",{origin:T})},[m]),w=n.useCallback((T,N)=>m("POST",{computers:ht([{origin:T,name:N}]),restore:!0}),[m]);return{computers:o,loaded:s,saving:u,error:p,reload:P,rename:g,remove:h,add:w}}let bn;function zn(){return window.jsQR?Promise.resolve():bn||(bn=new Promise((t,o)=>{const a=document.createElement("script");a.src="/pwa/qr-decoder.js";const s=()=>{clearTimeout(c),bn=null,a.remove(),o(new Error("二维码识别器加载失败,请重试。"))},c=setTimeout(s,1e4);a.onload=()=>{clearTimeout(c),t()},a.onerror=s,document.head.append(a)}))}function gt(){var t;return!!(window.isSecureContext&&((t=navigator.mediaDevices)!=null&&t.getUserMedia))}async function lo(t){if(!t||t.type&&!t.type.startsWith("image/"))throw new Error("请选择二维码照片。");if(t.size>20*1024*1024)throw new Error("照片过大,请重新拍摄二维码。");await zn();const o=new Image,a=URL.createObjectURL(t);try{await new Promise((u,d)=>{const p=setTimeout(()=>d(new Error("照片加载超时,请重新拍摄。")),1e4);o.onload=()=>{clearTimeout(p),u()},o.onerror=()=>{clearTimeout(p),d(new Error("无法读取照片,请重新拍摄二维码。"))},o.src=a});const s=document.createElement("canvas"),c=s.getContext("2d",{willReadFrequently:!0});for(const u of[1600,1024,640]){const d=Math.min(1,u/Math.max(o.naturalWidth,o.naturalHeight));s.width=Math.max(1,Math.round(o.naturalWidth*d)),s.height=Math.max(1,Math.round(o.naturalHeight*d)),c.drawImage(o,0,0,s.width,s.height);const p=c.getImageData(0,0,s.width,s.height),k=window.jsQR(p.data,p.width,p.height);if(k)return k.data}throw new Error("照片中没有识别到二维码,请靠近电脑屏幕重新拍摄。")}finally{o.onload=null,o.onerror=null,URL.revokeObjectURL(a)}}function uo(t,o,a){let s,c=0,u;const d=()=>{c++,clearTimeout(u),s==null||s.getTracks().forEach(R=>R.stop()),s=null,t.srcObject=null},p=(R,l)=>{R===c&&(d(),a((l==null?void 0:l.name)==="NotAllowedError"?"相机权限未开启,请允许相机或粘贴二维码链接。":(l==null?void 0:l.message)||"无法启动扫码,请重试。"))},k=async()=>{d();const R=c;if(!gt()){a("实时扫码需要 HTTPS,请使用拍照扫码。");return}try{if(await zn(),R!==c)return;const l=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"}},audio:!1});if(R!==c){l.getTracks().forEach(g=>g.stop());return}s=l,t.srcObject=l;let v;try{await Promise.race([t.play(),new Promise((g,h)=>{v=setTimeout(()=>h(new Error("相机没有返回画面,请重试。")),1e4)})])}finally{clearTimeout(v)}if(R!==c)return;const S=document.createElement("canvas"),P=S.getContext("2d",{willReadFrequently:!0}),m=()=>{if(R===c)try{if(t.videoWidth&&t.videoHeight){S.width=Math.min(t.videoWidth,640),S.height=Math.round(t.videoHeight*S.width/t.videoWidth),P.drawImage(t,0,0,S.width,S.height);const g=P.getImageData(0,0,S.width,S.height),h=window.jsQR(g.data,g.width,g.height);if(h){d(),o(h.data);return}}u=setTimeout(m,250)}catch(g){d(),a((g==null?void 0:g.message)||"二维码识别失败,请重试。")}};m()}catch(l){p(R,l)}},j=()=>{document.hidden&&d()};return window.addEventListener("pagehide",d),document.addEventListener("visibilitychange",j),{start:k,stop:d,dispose(){d(),window.removeEventListener("pagehide",d),document.removeEventListener("visibilitychange",j)}}}const po=[{id:"refresh",name:"刷新",Icon:xe},{id:"dashboard",name:"Dashboard",Icon:On},{id:"collaboration",name:"群聊列表",Icon:xt},{id:"remote",name:"远程桌面",Icon:ct},{id:"theme",name:"皮肤",Icon:An},{id:"files",name:"文件树",Icon:gr},{id:"ai-hub",name:"AI Hub",Icon:Dn},{id:"flow",name:"数字人",Icon:yt},{id:"install",name:"添加到主屏幕",Icon:Mn}];function mo({username:t,connected:o,accent:a,accentText:s,selectedPageId:c,onSelectPage:u,onUpdatePage:d,configuration:p,csrfToken:k}){const j=n.useRef(null),R=n.useRef(null),l=co(k),v=l.computers,[S,P]=n.useState(""),[m,g]=n.useState(null),[h,w]=n.useState(!1),[T,N]=n.useState("home"),[D,_]=n.useState(!1),[ee,re]=n.useState({top:48,right:12}),[H,te]=n.useState(null),[I,C]=n.useState(null),[O,U]=n.useState(""),[B,z]=n.useState({}),x=v.find(b=>b.origin===S),W=p.settings.savedPages??[];n.useEffect(()=>{var b;p.loaded&&c&&d(((b=p.settings.savedPages)==null?void 0:b.find(M=>M.id===c))??null)},[p.loaded,p.settings.savedPages,c,d]),n.useEffect(()=>{var V;P(Me()),g(((V=j.current)==null?void 0:V.closest(".web-root"))??document.body);const b=window.matchMedia("(max-width: 600px)"),M=()=>_(b.matches);return M(),b.addEventListener("change",M),()=>{b.removeEventListener("change",M)}},[]),n.useEffect(()=>{if(!h)return;const b=q=>{var G,X;!((G=R.current)!=null&&G.contains(q.target))&&!((X=j.current)!=null&&X.contains(q.target))&&w(!1)},M=q=>{var Se,le;if(q.key==="Escape"&&(w(!1),(Se=j.current)==null||Se.focus()),!D||q.key!=="Tab")return;const G=(le=R.current)==null?void 0:le.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(G!=null&&G.length))return;const X=G[0],ce=G[G.length-1];q.shiftKey&&document.activeElement===X?(q.preventDefault(),ce.focus()):!q.shiftKey&&document.activeElement===ce&&(q.preventDefault(),X.focus())},V=()=>{var X;const q=(X=j.current)==null?void 0:X.getBoundingClientRect();if(!q)return;const G=Math.min(292,innerWidth-24);re({top:q.bottom+8,right:Math.max(12,Math.min(innerWidth-G-12,innerWidth-q.right))})};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",M),window.addEventListener("resize",V),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",M),window.removeEventListener("resize",V)}},[h,D]),n.useEffect(()=>{var b,M;h&&((M=(b=R.current)==null?void 0:b.querySelector("button"))==null||M.focus())},[h,T]),n.useEffect(()=>{if(!h)return;const b=new AbortController,M=()=>{for(const q of v)q.origin!==S&&ao(q.origin,b.signal).then(G=>{b.signal.aborted||z(X=>({...X,[q.origin]:G}))})};M();const V=window.setInterval(M,15e3);return window.addEventListener("online",M),()=>{b.abort(),window.clearInterval(V),window.removeEventListener("online",M)}},[h,v,S]);const K=n.useCallback(()=>{var b;te(null),(b=j.current)==null||b.focus()},[]),A=n.useCallback(()=>{var b;C(null),(b=j.current)==null||b.focus()},[]),L=n.useCallback(async(b,M)=>{var X;if(He()){await He().pair(b);return}const V=ur(b),q={origin:V.origin,name:M.trim()||((X=v.find(ce=>ce.origin===V.origin))==null?void 0:X.name)||V.hostname},G=pr(b,ln(De(),v,[q]),M);await l.add(q.origin,q.name),location.assign(G)},[v,l.add]),se=n.useCallback(async b=>{await l.rename(Me(),b),K()},[K,l.rename]);return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ho}),e.jsxs("div",{className:"theme-avatar-with-status",children:[e.jsx("button",{ref:j,type:"button",className:"theme-avatar","aria-label":`电脑与连接状态(${t})`,title:t,style:{border:`1px solid ${a}`,background:a,color:s},"aria-expanded":h,"aria-haspopup":"true",onClick:()=>{const b=j.current.getBoundingClientRect(),M=Math.min(292,innerWidth-24);re({top:b.bottom+8,right:Math.max(12,Math.min(innerWidth-M-12,innerWidth-b.right))}),h||(N("home"),U(""),p.reload(),l.reload()),w(V=>!V)},children:(t.trim()[0]??"?").toUpperCase()}),e.jsx("span",{className:"theme-avatar-status","data-connected":o,"aria-label":o?"已连接":"未连接"})]}),h&&m&&Ie.createPortal(e.jsx("div",{className:"computer-menu-backdrop","data-toolbar-overlay":!0,children:e.jsxs("div",{ref:R,className:"computer-menu",style:D?void 0:ee,role:"dialog","aria-modal":D,"aria-label":T==="tools"?"配置顶部工具":T==="computers"?"选择电脑":"电脑与保存页面",children:[e.jsx("div",{className:"computer-menu-grip","aria-hidden":"true"}),e.jsxs("div",{className:"computer-menu-heading",children:[T!=="home"&&e.jsx("button",{type:"button",className:"computer-close","aria-label":"返回电脑菜单",onClick:()=>N("home"),children:e.jsx(mr,{size:20})}),T==="home"?e.jsxs("button",{type:"button",className:"computer-menu-item computer-current","aria-label":"选择电脑",onClick:()=>N("computers"),children:[e.jsx(pn,{size:17}),e.jsxs("span",{children:[e.jsx("strong",{children:(x==null?void 0:x.name)||"当前电脑"}),e.jsx("small",{children:o?"当前 · 在线":"当前 · 未连接"})]}),e.jsx(fr,{size:16})]}):e.jsx("strong",{children:T==="tools"?`${(x==null?void 0:x.name)||"当前电脑"} · 顶部工具`:"选择电脑"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭电脑菜单",onClick:()=>{var b;w(!1),(b=j.current)==null||b.focus()},children:e.jsx(Ee,{size:20})})]}),T==="computers"&&e.jsxs(e.Fragment,{children:[!l.loaded&&e.jsx("p",{className:"computer-save-status",role:"status",children:l.error?"电脑列表尚未加载":"正在读取电脑列表…"}),v.map(b=>{const M=b.origin===S?o?"online":"offline":B[b.origin]??"checking",V=M==="online"?"在线":M==="offline"?"无法连接":"检测中";return e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","data-computer-origin":b.origin,"aria-label":`${b.name},${V}${b.origin===S?",当前电脑":""}`,"aria-current":b.origin===S?"true":void 0,onClick:()=>{if(b.origin===S)N("home");else try{const q=He();q?q.switchComputer(b.origin).catch(G=>U(G.message)):location.assign(hr(b.origin,ln(De(),v)))}catch(q){U(q.message)}},children:[e.jsx(pn,{size:17,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsx("small",{children:b.origin})]}),e.jsx("span",{className:"computer-status-dot","data-status":M,role:"img","aria-label":V,title:V}),b.origin===S&&e.jsx(mt,{size:16,"aria-label":"当前电脑"})]}),b.origin!==S&&e.jsx("button",{type:"button",className:"computer-page-control computer-delete-control","aria-label":`删除电脑:${b.name}`,title:`删除电脑:${b.name}`,disabled:l.saving,onClick:()=>{l.remove(b.origin).catch(()=>{})},children:e.jsx(vt,{size:15})})]},b.origin)}),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!l.loaded||l.saving,onClick:()=>{const b=He();b?b.scan().catch(M=>U(M.message)):(w(!1),te("add"))},children:[e.jsx(Ve,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"扫码添加电脑"})]}),e.jsxs("button",{type:"button",className:"computer-menu-item",disabled:!l.loaded||l.saving||!x,onClick:()=>{w(!1),te("rename")},children:[e.jsx(ft,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"修改当前电脑名称"})]}),l.error&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:l.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{l.reload()},children:[e.jsx(xe,{size:16}),e.jsx("span",{children:"重新加载电脑列表"})]})]})]}),T==="home"&&e.jsxs(e.Fragment,{children:[e.jsx(ro,{csrfToken:k}),e.jsxs("div",{className:"computer-menu-label computer-pages-heading",children:[e.jsx("span",{children:"保存的页面"}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":"添加页面",disabled:!p.loaded||p.saving,onClick:()=>{w(!1),C({computer:x??{origin:S,name:"当前电脑"}})},children:e.jsx(Ve,{size:17})})]}),e.jsxs("button",{type:"button",className:"computer-menu-item","aria-current":c?void 0:"true",onClick:()=>{w(!1),u(null)},children:[e.jsx(Zr,{size:17}),e.jsx("span",{children:"电脑会话"}),!c&&e.jsx(mt,{size:16})]}),W.map(b=>e.jsxs("div",{className:"computer-menu-row",children:[e.jsxs("button",{type:"button",className:"computer-menu-item","aria-label":`打开 ${b.name}`,"aria-current":c===b.id?"true":void 0,onClick:()=>{w(!1),u(b)},children:[e.jsx(pt,{size:15,"aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:b.name}),e.jsxs("small",{children:[b.openMode==="current"?"当前页面":"新页面"," · ",new URL(b.url).hostname]})]}),b.openMode==="new-tab"&&e.jsx(kt,{size:13,"aria-hidden":"true"})]}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`编辑 ${b.name}`,disabled:p.saving,onClick:()=>{w(!1),C({computer:x??{origin:S,name:"当前电脑"},page:b})},children:e.jsx(ft,{size:14})}),e.jsx("button",{type:"button",className:"computer-page-control","aria-label":`删除 ${b.name}`,disabled:p.saving,onClick:()=>{p.setSavedPages(W.filter(M=>M.id!==b.id)).catch(()=>{})},children:e.jsx(Ee,{size:15})})]},b.id)),e.jsx("div",{className:"computer-menu-divider"}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>N("tools"),children:[e.jsx(Ar,{size:17}),e.jsx("span",{children:"配置顶部工具"}),e.jsx(Fr,{size:16})]})]}),T==="tools"&&e.jsx("div",{className:"computer-tools-list",children:po.map(({id:b,name:M,Icon:V})=>e.jsxs("label",{className:"computer-tool-option",children:[e.jsx(V,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:M}),e.jsx("input",{type:"checkbox","aria-label":`显示${M}`,checked:p.settings.visibleTools.includes(b),disabled:!p.loaded||p.saving,onChange:q=>{const G=p.settings.visibleTools;p.setVisibleTools(q.target.checked?[...G,b]:G.filter(X=>X!==b)).catch(()=>{})}})]},b))}),T!=="computers"&&e.jsx("p",{className:"computer-save-status",role:"status",children:p.loaded?p.saving?"正在保存…":p.notice:p.error?"配置尚未加载":"正在读取电脑配置…"}),p.error&&T!=="computers"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-error",role:"alert",children:p.error}),e.jsxs("button",{type:"button",className:"computer-menu-item",onClick:()=>{p.reload()},children:[e.jsx(xe,{size:16}),e.jsx("span",{children:"重新加载配置"})]})]}),O&&e.jsx("p",{className:"computer-error",role:"alert",children:O})]})}),m),H&&m&&Ie.createPortal(e.jsx(fo,{mode:H,currentName:(x==null?void 0:x.name)||"",onClose:K,onNavigate:L,onRename:se}),m),I&&m&&Ie.createPortal(e.jsx(io,{computerName:I.computer.name,page:I.page,onClose:A,onSave:async b=>{if(I.page&&!W.some(M=>M.id===b.id))throw new Error("这个页面已在其他设备删除,请重新添加。");await p.setSavedPages(I.page?W.map(M=>M.id===b.id?b:M):[...W,b]),A()}}),m)]})}function fo({mode:t,currentName:o,onClose:a,onNavigate:s,onRename:c}){const[u,d]=n.useState(t==="rename"?o:""),p=n.useRef(u);p.current=u;const[k,j]=n.useState(""),[R,l]=n.useState(""),[v,S]=n.useState(!1),[P,m]=n.useState(!1),[g,h]=n.useState(!1),[w,T]=n.useState(!1),N=n.useRef(null),D=n.useRef(null),_=n.useRef(0),ee=n.useRef(null),re=n.useRef(null),H=n.useRef(null),te=n.useCallback(async I=>{var C;S(!0),(C=H.current)==null||C.stop(),m(!1),l("");try{await s(I,p.current)}catch(O){l(O.message)}finally{S(!1)}},[s]);return n.useEffect(()=>{var O,U,B;h(gt()),t==="rename"?(O=ee.current)==null||O.focus():(B=(U=re.current)==null?void 0:U.querySelector("button"))==null||B.focus();const I=z=>{var A;if(z.key==="Escape"&&a(),z.key!=="Tab")return;const x=(A=re.current)==null?void 0:A.querySelectorAll("button:not(:disabled), input:not(:disabled)");if(!(x!=null&&x.length))return;const W=x[0],K=x[x.length-1];z.shiftKey&&document.activeElement===W?(z.preventDefault(),K.focus()):!z.shiftKey&&document.activeElement===K&&(z.preventDefault(),W.focus())},C=()=>{document.hidden&&m(!1)};return document.addEventListener("keydown",I),document.addEventListener("visibilitychange",C),t==="add"&&N.current&&(H.current=uo(N.current,te,z=>{m(!1),l(z)})),()=>{var z;_.current++,document.removeEventListener("keydown",I),document.removeEventListener("visibilitychange",C),(z=H.current)==null||z.dispose(),H.current=null}},[t,te,a]),e.jsx("div",{className:"computer-dialog-backdrop","data-toolbar-overlay":!0,onClick:I=>{I.target===I.currentTarget&&a()},children:e.jsxs("section",{ref:re,className:"computer-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"computer-dialog-title",children:[e.jsxs("div",{className:"computer-dialog-heading",children:[e.jsx("h2",{id:"computer-dialog-title",children:t==="add"?"添加电脑":"修改电脑名称"}),e.jsx("button",{type:"button",className:"computer-close","aria-label":"关闭",onClick:a,children:e.jsx(Ee,{size:20})})]}),e.jsxs("form",{onSubmit:async I=>{if(I.preventDefault(),!v)if(t==="add")await te(k);else{S(!0);try{await c(u.trim())}catch(C){l(C.message)}finally{S(!1)}}},children:[e.jsxs("label",{htmlFor:"computer-name",children:["电脑名称",t==="add"?"(选填)":""]}),e.jsx("input",{ref:ee,id:"computer-name",maxLength:60,value:u,required:t==="rename",disabled:v,onChange:I=>d(I.target.value),placeholder:"例如:A 电脑 / 家里的电脑",autoComplete:"off"}),t==="add"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"computer-hint",children:"扫描另一台电脑上的 AgentRoam 授权二维码,连接后会保留已有电脑。"}),e.jsx("input",{ref:D,type:"file",accept:"image/*",capture:"environment",hidden:!0,"aria-label":"拍摄授权二维码",onChange:async I=>{var U,B;const C=(U=I.currentTarget.files)==null?void 0:U[0];if(I.currentTarget.value="",!C)return;const O=++_.current;(B=H.current)==null||B.stop(),m(!1),T(!0),l("");try{const z=await lo(C);O===_.current&&te(z)}catch(z){O===_.current&&l(z.message)}finally{O===_.current&&T(!1)}}}),e.jsx("video",{ref:N,playsInline:!0,muted:!0,hidden:!P,"aria-label":"扫码相机画面"}),e.jsxs("button",{className:"computer-action",type:"button",disabled:w,onClick:()=>{var I,C,O;l(""),P?((I=H.current)==null||I.stop(),m(!1)):gt()?(m(!0),(O=H.current)==null||O.start()):(C=D.current)==null||C.click()},children:[e.jsx(br,{size:17,"aria-hidden":"true"}),w?"正在识别二维码…":P?"取消扫码":g?"打开相机扫码":"拍照扫码"]}),g&&e.jsx("button",{className:"computer-action",type:"button",disabled:w,onClick:()=>{var I,C;(I=H.current)==null||I.stop(),m(!1),(C=D.current)==null||C.click()},children:"拍照识别二维码"}),e.jsx("label",{htmlFor:"computer-link",children:"或粘贴授权二维码链接"}),e.jsx("input",{id:"computer-link",value:k,onChange:I=>j(I.target.value),placeholder:"http(s)://…/pair#pair=…",autoComplete:"off",spellCheck:!1})]}),R&&e.jsx("p",{className:"computer-error",role:"alert",children:R}),e.jsx("button",{className:"computer-action computer-primary",type:"submit",disabled:v||(t==="add"?!k.trim()||w:!u.trim()),children:t==="add"?"连接这台电脑":v?"正在保存…":"保存名称"})]})]})})}const ho=`
|
|
32
27
|
.computer-menu-backdrop{position:fixed;inset:0;z-index:10000}
|
|
33
28
|
.computer-menu-heading{display:flex;align-items:center;gap:4px;padding:2px 4px}.computer-menu-heading>strong{flex:1;min-width:0;font-size:14px;font-weight:500;overflow-wrap:anywhere}.computer-menu-heading>.computer-current{flex:1;min-width:0}.computer-menu-heading>.computer-close{flex-shrink:0}
|
|
34
29
|
.computer-menu-grip{display:none}.computer-pages-heading{display:flex;align-items:center;justify-content:space-between}.computer-tool-option{display:flex;align-items:center;gap:12px;min-height:44px;padding:8px 12px;cursor:pointer}.computer-tool-option span{flex:1;font-size:14px}.computer-tool-option input{width:18px;height:18px;accent-color:var(--ui-tab-accent,#7aa2f7)}.computer-tool-option svg{flex-shrink:0}.computer-save-status{margin:6px 10px 2px;line-height:18px;color:var(--ui-muted-text,#999dab);font-size:12px}.computer-save-status:empty{display:none}.computer-menu button:disabled,.computer-tool-option:has(input:disabled){opacity:.55;cursor:default}
|
|
@@ -59,7 +54,7 @@ import{c as xt,r as n,j as e,f as Ve,e as Ie,R as xe,X as Ee,n as cr,o as lr,p a
|
|
|
59
54
|
.computer-dialog select{width:100%;padding:11px 8px;border:1px solid var(--ui-panel-input-border,#30303a);border-radius:8px;background:var(--ui-panel-input-bg,#0f0f15);color:inherit;font:inherit;font-size:14px}
|
|
60
55
|
.computer-hint{color:var(--ui-muted-text,#999dab);font-size:13px;line-height:1.7}.computer-action{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;padding:12px;margin-top:12px;border:1px solid var(--ui-panel-input-border,#30303a);border-radius:8px;background:var(--ui-tab-bg,#1b1e28);color:inherit;font:inherit;cursor:pointer}.computer-primary{background:var(--ui-tab-accent,#7aa2f7);color:var(--ui-root-bg,#0b0b10);border-color:transparent}.computer-action:disabled{opacity:.45;cursor:default}.computer-error{font-size:13px;line-height:1.6;color:var(--ui-danger,#ffb2a7);padding:0 8px}
|
|
61
56
|
@media(pointer:coarse){.computer-menu-item{min-height:44px}.computer-close{width:44px;height:44px}.computer-page-control{height:44px;flex-basis:36px;width:36px}}
|
|
62
|
-
`;function Ge({label:t="FLOW STUDIO",title:o="正在打开 Flow Studio",caption:a="即将进入你的创作空间",icon:s=e.jsx(
|
|
57
|
+
`;function Ge({label:t="FLOW STUDIO",title:o="正在打开 Flow Studio",caption:a="即将进入你的创作空间",icon:s=e.jsx(yt,{size:36,strokeWidth:1.5})}={}){return e.jsxs("div",{className:"flow-loading",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flow-loader-art","aria-hidden":"true",children:[e.jsx("div",{className:"flow-loader-halo"}),e.jsx("div",{className:"flow-loader-orbit orbit-outer",children:e.jsx("i",{})}),e.jsx("div",{className:"flow-loader-orbit orbit-inner",children:e.jsx("i",{})}),e.jsx("div",{className:"flow-loader-core",children:s}),e.jsx("span",{className:"flow-loader-node node-one"}),e.jsx("span",{className:"flow-loader-node node-two"}),e.jsx("span",{className:"flow-loader-node node-three"})]}),e.jsxs("div",{className:"flow-loader-copy",children:[e.jsx("span",{className:"flow-loader-label",children:t}),e.jsx("strong",{children:o}),e.jsx("span",{className:"flow-loader-caption",children:a})]}),e.jsx("div",{className:"flow-loader-track","aria-hidden":"true",children:e.jsx("span",{})}),e.jsx("style",{jsx:!0,children:`
|
|
63
58
|
.flow-loading { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; overflow:hidden; gap:26px; color:var(--ui-text, #e5e7eb); background:var(--ui-term-col-bg, #101014); animation:flow-appear 280ms ease-out both; }
|
|
64
59
|
.flow-loader-art { position:relative; width:200px; height:200px; flex-shrink:0; }
|
|
65
60
|
.flow-loader-halo { position:absolute; inset:-40px; border-radius:50%; background:radial-gradient(circle, #54e5cf26, #54e5cf08 45%, transparent 70%); animation:flow-breathe 3s ease-in-out infinite; }
|
|
@@ -84,7 +79,7 @@ import{c as xt,r as n,j as e,f as Ve,e as Ie,R as xe,X as Ee,n as cr,o as lr,p a
|
|
|
84
79
|
@keyframes flow-appear { from { opacity:0; } to { opacity:1; } }
|
|
85
80
|
@media (max-height:420px) { .flow-loading { gap:12px; } .flow-loader-art { width:200px; height:200px; zoom:.65; } }
|
|
86
81
|
@media (prefers-reduced-motion:reduce) { .flow-loading, .flow-loader-halo, .flow-loader-orbit, .flow-loader-core, .flow-loader-node, .flow-loader-track span { animation:none; } }
|
|
87
|
-
`})]})}function ho(t){const o=new URL(t).hostname;return o==="qoder.com"||o.endsWith(".qoder.com")}function go({page:t,reloadKey:o}){const[a,s]=n.useState(!0),[c,u]=n.useState(!1);return n.useEffect(()=>{s(!0),u(!1);const d=window.setTimeout(()=>u(!0),12e3);return()=>window.clearTimeout(d)},[t.id,t.url,o]),ho(t.url)?e.jsxs("main",{className:"computer-page-blocked",children:[e.jsx(ft,{size:36,strokeWidth:1.5,"aria-hidden":"true"}),e.jsxs("h2",{children:[t.name," 不允许内嵌"]}),e.jsx("p",{children:"这个网站限制了当前页面打开。可以在新页面使用,也可以在电脑菜单中修改打开方式。"}),e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(jt,{size:16,"aria-hidden":"true"}),"打开新页面"]})]}):e.jsxs("main",{className:"computer-page-pane","aria-label":t.name,"aria-busy":a,children:[e.jsx("iframe",{title:t.name,src:t.url,referrerPolicy:"no-referrer",allow:"clipboard-read; clipboard-write; microphone; camera",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads allow-modals",onLoad:()=>s(!1),onError:()=>{s(!1),u(!0)},style:{visibility:a?"hidden":"visible"}},`${t.id}:${o}`),a&&e.jsx(Ge,{label:"REMOTE PAGE",title:`正在打开 ${t.name}`,caption:"正在连接页面",icon:e.jsx(ft,{size:36,strokeWidth:1.5})}),c&&e.jsx("a",{className:"computer-page-fallback",href:t.url,target:"_blank",rel:"noopener noreferrer",children:"打开原页面"})]})}const at=["refresh","dashboard","collaboration","remote","theme","files","ai-hub","flow","install"],bo=["refresh","remote","theme","files"];function wo(t){return{userId:t,revision:0,visibleTools:[...bo],savedPages:null,updatedAt:""}}function _n(t){if(!Array.isArray(t)||t.length>at.length||t.some(o=>!at.includes(o)))throw new Error("顶部工具包含未知选项。");if(new Set(t).size!==t.length)throw new Error("顶部工具不能重复。");return at.filter(o=>t.includes(o))}function Wn(t){if(!Array.isArray(t)||t.length>20)throw new Error("每台电脑最多可添加 20 个页面。");const o=new Set;return t.map(a=>{if(!a||typeof a.id!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(a.id)||o.has(a.id))throw new Error("页面标识无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("页面名称需为 1–60 个字符。");if(!["current","new-tab"].includes(a.openMode))throw new Error("页面打开方式无效。");if(typeof a.url!="string"||a.url.length>8192)throw new Error("请填写有效的 http(s) 页面地址。");let s;try{s=new URL(a.url.trim())}catch{throw new Error("请填写有效的 http(s) 页面地址。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password)throw new Error("请填写无账号密码的 http(s) 页面地址。");return o.add(a.id),{id:a.id,name:a.name.trim(),url:s.href,openMode:a.openMode}})}class bt extends Error{constructor(o,a){super(o),this.status=a}}async function Pe(t,o){var c;const a=await fetch("/api/web-console/computer-settings",{method:o?"PATCH":"GET",credentials:"same-origin",cache:"no-store",headers:o?{"content-type":"application/json","x-csrf-token":t}:void 0,body:o?JSON.stringify(o):void 0,signal:AbortSignal.timeout(15e3)}).catch(u=>{throw new Error((u==null?void 0:u.name)==="TimeoutError"?"电脑响应超时,请检查连接后重试。":"无法连接当前电脑,请检查连接后重试。")}),s=await a.json().catch(()=>null);if(!a.ok)throw new bt(((c=s==null?void 0:s.error)==null?void 0:c.message)??"电脑配置保存失败,请检查连接后重试。",a.status);if(!(s!=null&&s.settings)||!Number.isSafeInteger(s.settings.revision))throw new Error("无法读取电脑配置,请重新加载。");return{...s.settings,visibleTools:_n(s.settings.visibleTools),savedPages:s.settings.savedPages===null?null:Wn(s.settings.savedPages)}}function xo(t){const[o,a]=n.useState(()=>wo("")),s=n.useRef(o),[c,u]=n.useState(!1),[d,p]=n.useState(!1),k=n.useRef(!1),j=n.useRef(!0),R=n.useRef(0),[l,v]=n.useState(""),[S,P]=n.useState(""),m=n.useCallback(w=>{s.current=w,j.current&&a(w)},[]),g=n.useCallback(async()=>{var T;if(k.current)return;const w=++R.current;v(""),P("");try{let N=await Pe(t);if(N.savedPages===null){const D=((T=De().find(_=>_.origin===location.origin))==null?void 0:T.pages)??[];try{N=await Pe(t,{expectedRevision:N.revision,initializePages:D})}catch(_){if(!(_ instanceof bt)||_.status!==409)throw _;if(N=await Pe(t),N.savedPages===null)throw new Error("电脑配置已更新,请重试旧页面导入。")}}if(!j.current||w!==R.current)return;m(N),u(!0);try{In(De().map(D=>{if(D.origin!==location.origin)return D;const{pages:_,...ee}=D;return{...ee,pagesMigrated:!0}}))}catch{}}catch(N){j.current&&w===R.current&&v(N instanceof Error?N.message:"无法读取电脑配置。")}},[m,t]);n.useEffect(()=>{j.current=!0,g();const w=()=>{g()};return window.addEventListener("focus",w),()=>{j.current=!1,R.current++,window.removeEventListener("focus",w)}},[g]);const h=n.useCallback(async w=>{if(!c||k.current)throw new Error("配置尚未就绪,请稍后重试。");k.current=!0,R.current++,p(!0),v(""),P("");const T=s.current;w.visibleTools&&m({...T,visibleTools:w.visibleTools});try{m(await Pe(t,{...w,expectedRevision:T.revision})),j.current&&P("已保存到当前电脑")}catch(N){if(m(T),N instanceof bt&&N.status===409)try{m(await Pe(t))}catch{}const D=N instanceof Error?N.message:"电脑配置保存失败,请重试。";throw j.current&&v(D),new Error(D)}finally{k.current=!1,j.current&&p(!1)}},[m,t,c]);return{settings:o,loaded:c,saving:d,error:l,notice:S,reload:g,setVisibleTools:w=>h({visibleTools:_n(w)}),setSavedPages:w=>h({savedPages:Wn(w)})}}const yo=["codex","claude agents","opencode","agent-tui"];function vo(){return yo.map((t,o)=>({id:`default-${o+1}`,command:t}))}async function ko(t,o,a,s){const c=a.find(d=>d&&d===t.source);if(!c)return!1;const u=wr(t,o,c);if(!u)return!1;try{const d=await s(u.method,u.payload);c.postMessage({type:un,id:u.id,ok:!0,result:d},o)}catch(d){const p=d;c.postMessage({type:un,id:u.id,ok:!1,error:p.message||"项目操作失败",code:p.code},o)}return!0}const jo=1,wt={watcherFrame:4,producerFrame:5},xn=10;function Eo(t){const o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(o.byteLength<xn||o[0]!==jo||o[1]!==wt.watcherFrame&&o[1]!==wt.producerFrame)return null;const a=new DataView(o.buffer,o.byteOffset,o.byteLength);return{type:o[1],channelId:a.getUint32(2,!1),sequence:a.getUint32(6,!1),payload:o.subarray(xn)}}function So(){return yr()}function Co(t,o,a){const[s,c]=n.useState({connected:!1,error:null}),[u,d]=n.useState(0),p=n.useRef(null),k=n.useRef(0),j=n.useRef(new Map),R=n.useRef([]),l=n.useRef(0),v=n.useRef(new Map),S=n.useRef(new Map),P=n.useRef(new Map),m=n.useRef(1e3),g=n.useRef(!1),h=n.useRef(null),w=n.useRef(t),T=n.useRef(o),N=n.useRef(a);w.current=t,T.current=o,N.current=a;const D=n.useCallback((C,O)=>{let U=v.current.get(C);return U||v.current.set(C,U=new Set),U.add(O),()=>U.delete(O)},[]),_=n.useCallback((C,O)=>{let U=S.current.get(C);return U||S.current.set(C,U=new Set),U.add(O),()=>U.delete(O)},[]),ee=n.useCallback((C,O)=>{let U=P.current.get(C);return U||P.current.set(C,U=new Set),U.add(O),()=>U.delete(O)},[]),re=n.useCallback((C,O)=>{const U=p.current;if(!U||U.readyState!==WebSocket.OPEN)return!1;const B=new TextEncoder().encode(O),z=new Uint8Array(6+B.byteLength),x=new DataView(z.buffer);return z[0]=1,z[1]=1,x.setUint32(2,C),z.set(B,6),U.send(z),!0},[]),H=n.useCallback(C=>{const O=p.current;(O==null?void 0:O.readyState)===WebSocket.OPEN?O.send(C):R.current.push(C)},[]),te=n.useCallback((C,O={},U=15e3)=>new Promise((B,z)=>{var K;if(C.startsWith("browser:")&&((K=p.current)==null?void 0:K.readyState)!==WebSocket.OPEN){z(Object.assign(new Error("远程连接已断开,请等待重新连接"),{code:"EOFFLINE"}));return}const x=++l.current,W=setTimeout(()=>{j.current.delete(x),z(new Error(`${C} timeout`))},U);j.current.set(x,{resolve:B,reject:z,timer:W,type:C}),H(JSON.stringify({type:C,_req:x,...O}))}),[H]),I=n.useCallback(async()=>{g.current=!1;const C=++k.current;h.current&&(clearInterval(h.current),h.current=null);const O=p.current;if(O){O.onopen=O.onmessage=O.onerror=O.onclose=null;try{O.close()}catch{}}let U;try{U=await T.current()}catch{C===k.current&&N.current();return}if(C!==k.current||g.current)return;let B;try{B=new WebSocket(`${So()}?nonce=${encodeURIComponent(U)}`)}catch(z){c({connected:!1,error:String(z)});return}B.binaryType="arraybuffer",p.current=B,B.onopen=()=>{if(C!==k.current||p.current!==B)return;m.current=1e3,c({connected:!0,error:null}),d(K=>K+1);const z=R.current.splice(0);for(const K of z)B.send(K);let x=Date.now();h.current=setInterval(()=>{if(p.current!==B||B.readyState!==WebSocket.OPEN){clearInterval(h.current),h.current=null;return}if(Date.now()-x>25e3){try{B.close()}catch{}return}try{B.send(JSON.stringify({type:"ping"}))}catch{}},1e4);const W=()=>{x=Date.now()};B.addEventListener("message",W),B.addEventListener("close",()=>B.removeEventListener("message",W),{once:!0})},B.onmessage=z=>{var W,K,A;if(C!==k.current||p.current!==B)return;if(typeof z.data!="string"){const L=new Uint8Array(z.data);if(L.byteLength>=6&&L[0]===1&&(L[1]===2||L[1]===6)){const se=new DataView(L.buffer,L.byteOffset,L.byteLength).getUint32(2);(W=S.current.get(se))==null||W.forEach(b=>b(L.subarray(6),L[1]===6))}else if(L.byteLength>=6&&L[0]===1&&L[1]===3){const se=new DataView(L.buffer,L.byteOffset,L.byteLength).getUint32(2);(K=P.current.get(se))==null||K.forEach(b=>b())}else w.current(L);return}let x;try{x=JSON.parse(z.data)}catch{return}if(x.type==="error"&&x.id!=null){const L=j.current.get(x.id);if(L){j.current.delete(x.id),clearTimeout(L.timer);const se=Object.assign(new Error(x.error||"gateway error"),{code:x.code});L.reject(se)}return}if(x.id!=null&&typeof x.type=="string"&&x.type.endsWith(":result")){const L=j.current.get(x.id);(L==null?void 0:L.type)==="fs:preview-open"&&typeof x.url=="string"&&(x.url=xr(x.url)),L&&(j.current.delete(x.id),clearTimeout(L.timer),L.resolve(x));return}(A=v.current.get(x.type))==null||A.forEach(L=>L(x))},B.onclose=z=>{if(C!==k.current||p.current!==B)return;h.current&&(clearInterval(h.current),h.current=null),p.current=null;for(const[W,K]of j.current)K.type.startsWith("browser:")&&(clearTimeout(K.timer),j.current.delete(W),K.reject(Object.assign(new Error("远程连接已断开,请重新接管"),{code:"EOFFLINE"})));if(c({connected:!1,error:null}),z.code===4001||z.code===4003){N.current();return}if(g.current)return;const x=m.current;m.current=Math.min(x*2,8e3),setTimeout(()=>{!g.current&&C===k.current&&I()},x)},B.onerror=()=>{}},[]);return n.useEffect(()=>(I(),()=>{g.current=!0,k.current++,h.current&&(clearInterval(h.current),h.current=null);const C=p.current;if(p.current=null,C){C.onopen=C.onmessage=C.onerror=C.onclose=null;try{C.close()}catch{}}}),[I]),{state:s,epoch:u,rpc:te,onEvent:D,onTerminalData:_,onTerminalReset:ee,sendTerminalInput:re,reconnect:I}}function To(){const[t,o]=n.useState("loading"),[a,s]=n.useState(null),[c]=n.useState("same-origin"),[u,d]=n.useState(null),p=n.useCallback(async()=>{o("loading"),d(null);try{const l=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if(l.status===401||l.status===423){window.location.reload();return}if(!l.ok)throw new Error(`HTTP ${l.status}`);const v=await l.json();s(v.user),o("authenticated")}catch{d("无法连接远程控制台"),o("needsLogin")}},[]);n.useEffect(()=>{p()},[p]);const k=n.useCallback(async()=>{const l=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if((l.status===401||l.status===423)&&window.location.reload(),!l.ok)throw new Error("bootstrap failed");const v=await l.json();return s(v.user),o("authenticated"),v.wsNonce},[]),j=n.useCallback(async()=>(window.location.reload(),!1),[]),R=n.useCallback(async()=>{const l=await fetch("/api/pairing/logout",{method:"POST",credentials:"same-origin"});l.ok||l.status===401||l.status===423?window.location.reload():d("退出失败,请重试")},[]);return{status:t,user:a,error:u,csrfToken:c,setup:j,login:j,logout:R,refresh:p,getWsNonce:k}}function No({children:t}){const o=To(),[a,s]=n.useState(!1),c=o.status==="authenticated",u=n.useCallback(()=>s(!0),[]);return n.useEffect(()=>{c||s(!1)},[c]),e.jsxs(e.Fragment,{children:[c?t(o,u):null,e.jsx(vr,{ready:c&&a,error:o.error,onRetry:()=>void o.refresh()})]})}function yn(t,o,a){const s=t.findIndex(p=>p.id===o),c=t.findIndex(p=>p.id===a);if(s<0||c<0||s===c)return[...t];const u=[...t],[d]=u.splice(s,1);return u.splice(c,0,d),u}function Ro(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16)),t=>t.toString(16).padStart(2,"0")).join("")}function Fn(t,o=Ro()){return{id:o,command:t.trim()}}function Lo({commands:t,onChange:o,onExecute:a}){const[s,c]=n.useState(null),[u,d]=n.useState(""),[p,k]=n.useState(null),j=n.useRef(null),R=()=>{if(!s)return;const m=s.value.trim();if(!m)return d("命令不能为空");if(m.length>1e3)return d("命令最多 1000 个字符");if(/[\r\n\0]/.test(m))return d("命令只能包含一行");s.id?o(t.map(g=>g.id===s.id?{...g,command:m}:g)):o([...t,Fn(m)]),c(null),d("")},l=(m,g)=>{m.preventDefault(),m.stopPropagation(),j.current=g,k(g),m.currentTarget.setPointerCapture(m.pointerId)},v=m=>{var w;if(!j.current)return;const g=(w=document.elementFromPoint(m.clientX,m.clientY))==null?void 0:w.closest("[data-pinned-id]"),h=g==null?void 0:g.dataset.pinnedId;h&&h!==j.current&&o(yn(t,j.current,h))},S=m=>{m.currentTarget.hasPointerCapture(m.pointerId)&&m.currentTarget.releasePointerCapture(m.pointerId),j.current=null,k(null)},P=(m,g)=>{if(m.key!=="ArrowUp"&&m.key!=="ArrowDown")return;m.preventDefault();const h=t.findIndex(T=>T.id===g),w=t[h+(m.key==="ArrowUp"?-1:1)];w&&o(yn(t,g,w.id))};return e.jsxs("section",{className:"pinned-commands","aria-labelledby":"pinned-command-title",children:[e.jsxs("div",{className:"pinned-command-head",children:[e.jsx("span",{id:"pinned-command-title",children:"置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:()=>{c({id:null,value:""}),d("")},"aria-label":"新增置顶命令",title:"新增置顶命令",children:e.jsx(Ve,{size:14,"aria-hidden":"true"})})]}),t.map(m=>(s==null?void 0:s.id)===m.id?e.jsx(vn,{editor:s,error:u,onChange:g=>{c({...s,value:g}),d("")},onSave:R,onCancel:()=>{c(null),d("")}},m.id):e.jsxs("div",{className:`pinned-command-row${p===m.id?" pinned-command-dragging":""}`,"data-pinned-id":m.id,role:"button",tabIndex:0,onClick:()=>a(m.command),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),a(m.command))},children:[e.jsx("button",{className:"pinned-command-grip",onPointerDown:g=>l(g,m.id),onPointerMove:v,onPointerUp:S,onPointerCancel:S,onKeyDown:g=>P(g,m.id),onClick:g=>g.stopPropagation(),"aria-label":`调整 ${m.command} 的顺序`,title:"拖动排序,或按上下方向键",children:e.jsx(Ar,{size:14,"aria-hidden":"true"})}),e.jsx("code",{children:m.command}),e.jsxs("div",{className:"pinned-command-actions",onClick:g=>g.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>{c({id:m.id,value:m.command}),d("")},"aria-label":`编辑 ${m.command}`,title:"编辑",children:e.jsx(mt,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>o(t.filter(g=>g.id!==m.id)),"aria-label":`删除 ${m.command}`,title:"删除",children:e.jsx(kt,{size:12,"aria-hidden":"true"})})]})]},m.id)),(s==null?void 0:s.id)===null&&e.jsx(vn,{editor:s,error:u,onChange:m=>{c({...s,value:m}),d("")},onSave:R,onCancel:()=>{c(null),d("")}})]})}function vn({editor:t,error:o,onChange:a,onSave:s,onCancel:c}){return e.jsxs("div",{className:"pinned-command-editor",children:[e.jsx("input",{autoFocus:!0,value:t.value,maxLength:1e3,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&s(),u.key==="Escape"&&c()},"aria-label":t.id?"编辑置顶命令":"新增置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:s,"aria-label":"保存命令",title:"保存",children:e.jsx(pt,{size:13,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",onClick:c,"aria-label":"取消编辑",title:"取消",children:e.jsx(Ee,{size:13,"aria-hidden":"true"})}),o&&e.jsx("small",{role:"alert",children:o})]})}function Po({csrfToken:t,terminalId:o,pinnedCommands:a,onPinnedCommandsChange:s,onFill:c,onExecute:u}){const[d,p]=n.useState([]),[k,j]=n.useState(""),[R,l]=n.useState(""),v=n.useCallback(async()=>{const h=new URLSearchParams({q:k,limit:"200"}),w=await fetch(`/api/web-console/history?${h}`,{credentials:"same-origin"});w.ok&&p((await w.json()).history)},[k]);n.useEffect(()=>{const h=setTimeout(v,200);return()=>clearTimeout(h)},[v]);const S=async h=>{await fetch("/api/web-console/history",{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":t},body:JSON.stringify({id:h})}),v()},P=h=>{o&&c(h)},m=n.useCallback(h=>{h==="[REDACTED]"||a.some(w=>w.command===h)||s([...a,Fn(h)])},[s,a]),g=async h=>{const w=await Ur(h);l(w?"已复制命令":"复制失败,请长按命令手动复制")};return e.jsxs("div",{className:"history-panel",children:[e.jsx(Lo,{commands:a,onChange:s,onExecute:u}),e.jsxs("div",{className:"history-search",children:[e.jsx("input",{value:k,onChange:h=>j(h.target.value),placeholder:"搜索命令"}),e.jsx("button",{className:"history-icon-button",onClick:v,"aria-label":"刷新历史",title:"刷新历史",children:e.jsx(xe,{size:13,"aria-hidden":"true"})})]}),R&&e.jsx("div",{className:"terminal-clipboard-notice",role:"status",children:R}),d.map(h=>e.jsxs("div",{className:`history-item${o?"":" history-item-disabled"}`,role:"button",tabIndex:o?0:-1,onClick:()=>P(h.command),onKeyDown:w=>{w.target===w.currentTarget&&(w.key==="Enter"||w.key===" ")&&o&&(w.preventDefault(),P(h.command))},children:[e.jsx("code",{children:h.command}),e.jsxs("small",{children:[h.cwd," · ",new Date(h.executedAt).toLocaleString()]}),e.jsxs("div",{className:"history-item-actions",onClick:w=>w.stopPropagation(),onPointerDown:w=>w.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>void g(h.command),"aria-label":"复制命令",title:"复制",children:e.jsx(Dr,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:!o,onClick:()=>P(h.command),"aria-label":"填入命令",title:"填入",children:e.jsx(Zr,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:h.command==="[REDACTED]"||a.some(w=>w.command===h.command),onClick:()=>m(h.command),"aria-label":"置顶命令",title:"置顶",children:e.jsx(Mr,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>S(h.id),"aria-label":"删除历史",title:"删除",children:e.jsx(kt,{size:12,"aria-hidden":"true"})})]})]},h.id)),!d.length&&e.jsx("div",{className:"history-empty",children:"暂无 Shell 命令历史"}),!o&&!!d.length&&e.jsx("div",{className:"history-empty",children:"请先打开一个终端页签"})]})}function Io(t,o,a){const s=t.bottom+6,c=s+o<=a-8?s:t.top-o-6;return Math.max(8,Math.min(c,a-o-8))}function kn({themeId:t,onThemeChange:o}){const[a,s]=n.useState(!1),c=n.useRef(null),u=n.useRef(null),d=n.useRef(null),[p,k]=n.useState(null),[j,R]=n.useState({top:-1e3,left:0});return n.useEffect(()=>{var l;k(((l=c.current)==null?void 0:l.closest(".web-root"))??document.body)},[]),n.useLayoutEffect(()=>{if(!a)return;const l=()=>{var g,h,w;const S=(g=u.current)==null?void 0:g.getBoundingClientRect();if(!S)return;const P=Math.min(176,innerWidth-16),m=(h=c.current)!=null&&h.closest(".compact-tools-panel, .glass-tools-sheet")?Io(S,((w=d.current)==null?void 0:w.offsetHeight)??0,innerHeight):S.bottom+6;R({top:m,left:Math.max(8,Math.min(innerWidth-P-8,S.right-P))})};l();const v=new ResizeObserver(l);return d.current&&v.observe(d.current),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{v.disconnect(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0)}},[a]),n.useEffect(()=>{if(!a)return;const l=S=>{var P,m;!((P=c.current)!=null&&P.contains(S.target))&&!((m=d.current)!=null&&m.contains(S.target))&&s(!1)},v=S=>{var P;S.key==="Escape"&&(s(!1),(P=u.current)==null||P.focus())};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",v)}},[a]),e.jsxs("div",{ref:c,className:"theme-picker",children:[e.jsx("button",{ref:u,type:"button",className:"file-drawer-toggle","aria-label":"换肤",title:"换肤","aria-expanded":a,"aria-haspopup":"dialog",onClick:()=>s(l=>!l),children:e.jsx(An,{size:17,"aria-hidden":"true"})}),a&&p&&Ie.createPortal(e.jsxs("div",{ref:d,className:"theme-popover",role:"dialog","aria-label":"选择皮肤","data-toolbar-overlay":!0,style:{position:"fixed",...j,zIndex:210,width:Math.min(176,innerWidth-16),maxHeight:"calc(100dvh - 16px)",overflowY:"auto",boxSizing:"border-box",padding:8,borderRadius:10,border:"1px solid var(--ui-tabbar-border, #282b36)",background:"var(--ui-tab-active-bg, #262b38)",boxShadow:"0 10px 28px rgba(0,0,0,.45)"},children:[e.jsx("div",{style:{fontSize:10,color:"var(--ui-connection-text, #777b8c)",margin:"2px 4px 6px",letterSpacing:.5},children:"皮肤"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:kr.map(l=>{const v=l.id===t;return e.jsxs("button",{type:"button",className:"theme-popover-item","aria-label":l.label,"aria-pressed":v,onPointerDown:S=>S.stopPropagation(),onClick:()=>{o(l.id),s(!1)},style:{background:v?"color-mix(in srgb, var(--ui-tab-accent, #7aa2f7) 14%, transparent)":"transparent"},children:[e.jsx("span",{style:{width:18,height:18,borderRadius:5,flexShrink:0,background:`linear-gradient(135deg, ${l.preview[0]} 55%, ${l.preview[1]} 55%)`,boxShadow:"inset 0 0 0 1px rgba(128,128,160,.25)"}}),e.jsx("span",{style:{flex:1,textAlign:"left",fontSize:12,fontWeight:v?600:400,color:v?"var(--ui-tab-active-text, #edf0f7)":"var(--ui-tab-text, #8f93a4)"},children:l.label}),v&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ui-tab-accent, #7aa2f7)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},l.id)})})]}),p)]})}function jn({value:t,onChange:o}){const a=t==="agent-rail";return e.jsx("button",{type:"button",className:"file-drawer-toggle navigation-layout-toggle","aria-label":"切换布局","aria-pressed":a,title:a?"单层抬头 · 切换到原布局":"原布局 · 切换到单层抬头",onClick:()=>o(jr(t)),children:e.jsx(Or,{size:17,"aria-hidden":"true"})})}const Ke="agent-ui-prefs";function Ao(t){var o;try{const a=JSON.parse((t==null?void 0:t.getItem(Ke))??"null");return Er((o=a==null?void 0:a.state)==null?void 0:o.navigationLayout)?a.state.navigationLayout:lt}catch{return lt}}function Do(t,o){try{let a;try{a=JSON.parse(t.getItem(Ke)??"null")}catch{a=null}const s=a&&typeof a=="object"&&!Array.isArray(a)?a:{},c=s.state&&typeof s.state=="object"&&!Array.isArray(s.state)?s.state:{};t.setItem(Ke,JSON.stringify({...s,version:s.version??4,state:{...c,navigationLayout:o}}))}catch{}}function Mo(t,o){return{height:Math.round((t==null?void 0:t.height)??o.height),width:Math.round((t==null?void 0:t.width)??o.width),top:Math.round((t==null?void 0:t.offsetTop)??0),left:Math.round((t==null?void 0:t.offsetLeft)??0)}}function Oo(t){t&&(t.scrollLeft=0)}const zo="agent-webapp:tab-swipe:v1";function _o(t){if(!t||typeof t!="object")return null;const o=t;return o.type!==zo||o.phase!=="move"&&o.phase!=="end"&&o.phase!=="cancel"||typeof o.deltaX!="number"||!Number.isFinite(o.deltaX)?null:o}function Wo(t,o,a){return t.origin!==o||t.source!==a?null:_o(t.data)}const En="agent-webapp:ready:v1";function Fo(t){return!t||typeof t!="object"||t.type!==En?null:{type:En}}function Sn(t,o,a){return t.origin!==o||t.source!==a?null:Fo(t.data)}function st({groupId:t,title:o,onFrame:a,onLoad:s,view:c,discussionId:u}){const d=n.useRef(null),[p,k]=n.useState("loading"),[j,R]=n.useState(0),l=t===void 0;return n.useEffect(()=>{const v=S=>{var P,m,g;if(c==="sessions"){S.origin===window.location.origin&&S.source===((P=d.current)==null?void 0:P.contentWindow)&&((m=S.data)==null?void 0:m.type)===Vr&&k("ready");return}Br(S,window.location.origin,((g=d.current)==null?void 0:g.contentWindow)??null,t??null)&&k("ready")};return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[t,c]),n.useEffect(()=>{if(p!=="loading")return;const v=window.setTimeout(()=>k(S=>S==="loading"?"error":S),3e4);return()=>window.clearTimeout(v)},[p,j]),e.jsxs("div",{className:"collaboration-pane","aria-busy":p==="loading",children:[e.jsx("iframe",{ref:v=>{d.current=v,a(v)},className:`webapp-frame collaboration-frame${p==="ready"?" is-ready":""}`,style:{visibility:p==="ready"?"visible":"hidden"},src:dt(c==="sessions"?"/app/?view=session-dashboard":l?"/app/?view=collaboration-dashboard":`/app/?view=collaboration&groupId=${encodeURIComponent(t)}${u?`&discussionId=${encodeURIComponent(u)}`:""}`),title:o,onLoad:s,onError:()=>k("error")},j),p==="loading"&&e.jsx(Ge,{label:"AGENT COLLABORATION",title:c==="sessions"?"正在打开会话 Dashboard":l?"正在打开群聊列表":"正在进入群聊",caption:c==="sessions"?"正在核对运行会话与待决策事项":l?"正在加载已保存的群聊":"正在加载群成员与聊天记录",icon:e.jsx(yt,{size:36,strokeWidth:1.5})}),p==="error"&&e.jsxs("div",{className:"collaboration-load-error",role:"alert",children:[e.jsx("strong",{children:c==="sessions"?"暂时无法打开会话 Dashboard":l?"暂时无法打开群聊列表":"暂时无法打开群聊"}),e.jsx("span",{children:"请检查连接后重试。"}),e.jsxs("button",{onClick:()=>{k("loading"),R(v=>v+1)},children:[e.jsx(xe,{size:15}),"重新加载"]})]}),e.jsx("style",{jsx:!0,children:`
|
|
82
|
+
`})]})}function go(t){const o=new URL(t).hostname;return o==="qoder.com"||o.endsWith(".qoder.com")}function bo({page:t,reloadKey:o}){const[a,s]=n.useState(!0),[c,u]=n.useState(!1);return n.useEffect(()=>{s(!0),u(!1);const d=window.setTimeout(()=>u(!0),12e3);return()=>window.clearTimeout(d)},[t.id,t.url,o]),go(t.url)?e.jsxs("main",{className:"computer-page-blocked",children:[e.jsx(pt,{size:36,strokeWidth:1.5,"aria-hidden":"true"}),e.jsxs("h2",{children:[t.name," 不允许内嵌"]}),e.jsx("p",{children:"这个网站限制了当前页面打开。可以在新页面使用,也可以在电脑菜单中修改打开方式。"}),e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(kt,{size:16,"aria-hidden":"true"}),"打开新页面"]})]}):e.jsxs("main",{className:"computer-page-pane","aria-label":t.name,"aria-busy":a,children:[e.jsx("iframe",{title:t.name,src:t.url,referrerPolicy:"no-referrer",allow:"clipboard-read; clipboard-write; microphone; camera",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads allow-modals",onLoad:()=>s(!1),onError:()=>{s(!1),u(!0)},style:{visibility:a?"hidden":"visible"}},`${t.id}:${o}`),a&&e.jsx(Ge,{label:"REMOTE PAGE",title:`正在打开 ${t.name}`,caption:"正在连接页面",icon:e.jsx(pt,{size:36,strokeWidth:1.5})}),c&&e.jsx("a",{className:"computer-page-fallback",href:t.url,target:"_blank",rel:"noopener noreferrer",children:"打开原页面"})]})}const at=["refresh","dashboard","collaboration","remote","theme","files","ai-hub","flow","install"],wo=["refresh","remote","theme","files"];function xo(t){return{userId:t,revision:0,visibleTools:[...wo],savedPages:null,updatedAt:""}}function _n(t){if(!Array.isArray(t)||t.length>at.length||t.some(o=>!at.includes(o)))throw new Error("顶部工具包含未知选项。");if(new Set(t).size!==t.length)throw new Error("顶部工具不能重复。");return at.filter(o=>t.includes(o))}function Wn(t){if(!Array.isArray(t)||t.length>20)throw new Error("每台电脑最多可添加 20 个页面。");const o=new Set;return t.map(a=>{if(!a||typeof a.id!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(a.id)||o.has(a.id))throw new Error("页面标识无效或重复。");if(typeof a.name!="string"||!a.name.trim()||a.name.trim().length>60)throw new Error("页面名称需为 1–60 个字符。");if(!["current","new-tab"].includes(a.openMode))throw new Error("页面打开方式无效。");if(typeof a.url!="string"||a.url.length>8192)throw new Error("请填写有效的 http(s) 页面地址。");let s;try{s=new URL(a.url.trim())}catch{throw new Error("请填写有效的 http(s) 页面地址。")}if(!["http:","https:"].includes(s.protocol)||s.username||s.password)throw new Error("请填写无账号密码的 http(s) 页面地址。");return o.add(a.id),{id:a.id,name:a.name.trim(),url:s.href,openMode:a.openMode}})}class bt extends Error{constructor(o,a){super(o),this.status=a}}async function Pe(t,o){var c;const a=await fetch("/api/web-console/computer-settings",{method:o?"PATCH":"GET",credentials:"same-origin",cache:"no-store",headers:o?{"content-type":"application/json","x-csrf-token":t}:void 0,body:o?JSON.stringify(o):void 0,signal:AbortSignal.timeout(15e3)}).catch(u=>{throw new Error((u==null?void 0:u.name)==="TimeoutError"?"电脑响应超时,请检查连接后重试。":"无法连接当前电脑,请检查连接后重试。")}),s=await a.json().catch(()=>null);if(!a.ok)throw new bt(((c=s==null?void 0:s.error)==null?void 0:c.message)??"电脑配置保存失败,请检查连接后重试。",a.status);if(!(s!=null&&s.settings)||!Number.isSafeInteger(s.settings.revision))throw new Error("无法读取电脑配置,请重新加载。");return{...s.settings,visibleTools:_n(s.settings.visibleTools),savedPages:s.settings.savedPages===null?null:Wn(s.settings.savedPages)}}function yo(t){const[o,a]=n.useState(()=>xo("")),s=n.useRef(o),[c,u]=n.useState(!1),[d,p]=n.useState(!1),k=n.useRef(!1),j=n.useRef(!0),R=n.useRef(0),[l,v]=n.useState(""),[S,P]=n.useState(""),m=n.useCallback(w=>{s.current=w,j.current&&a(w)},[]),g=n.useCallback(async()=>{var T;if(k.current)return;const w=++R.current;v(""),P("");try{let N=await Pe(t);if(N.savedPages===null){const D=((T=De().find(_=>_.origin===location.origin))==null?void 0:T.pages)??[];try{N=await Pe(t,{expectedRevision:N.revision,initializePages:D})}catch(_){if(!(_ instanceof bt)||_.status!==409)throw _;if(N=await Pe(t),N.savedPages===null)throw new Error("电脑配置已更新,请重试旧页面导入。")}}if(!j.current||w!==R.current)return;m(N),u(!0);try{In(De().map(D=>{if(D.origin!==location.origin)return D;const{pages:_,...ee}=D;return{...ee,pagesMigrated:!0}}))}catch{}}catch(N){j.current&&w===R.current&&v(N instanceof Error?N.message:"无法读取电脑配置。")}},[m,t]);n.useEffect(()=>{j.current=!0,g();const w=()=>{g()};return window.addEventListener("focus",w),()=>{j.current=!1,R.current++,window.removeEventListener("focus",w)}},[g]);const h=n.useCallback(async w=>{if(!c||k.current)throw new Error("配置尚未就绪,请稍后重试。");k.current=!0,R.current++,p(!0),v(""),P("");const T=s.current;w.visibleTools&&m({...T,visibleTools:w.visibleTools});try{m(await Pe(t,{...w,expectedRevision:T.revision})),j.current&&P("已保存到当前电脑")}catch(N){if(m(T),N instanceof bt&&N.status===409)try{m(await Pe(t))}catch{}const D=N instanceof Error?N.message:"电脑配置保存失败,请重试。";throw j.current&&v(D),new Error(D)}finally{k.current=!1,j.current&&p(!1)}},[m,t,c]);return{settings:o,loaded:c,saving:d,error:l,notice:S,reload:g,setVisibleTools:w=>h({visibleTools:_n(w)}),setSavedPages:w=>h({savedPages:Wn(w)})}}const vo=["codex","claude agents","opencode","agent-tui"];function ko(){return vo.map((t,o)=>({id:`default-${o+1}`,command:t}))}async function jo(t,o,a,s){const c=a.find(d=>d&&d===t.source);if(!c)return!1;const u=wr(t,o,c);if(!u)return!1;try{const d=await s(u.method,u.payload);c.postMessage({type:dn,id:u.id,ok:!0,result:d},o)}catch(d){const p=d;c.postMessage({type:dn,id:u.id,ok:!1,error:p.message||"项目操作失败",code:p.code},o)}return!0}const Eo=1,wt={watcherFrame:4,producerFrame:5},wn=10;function So(t){const o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(o.byteLength<wn||o[0]!==Eo||o[1]!==wt.watcherFrame&&o[1]!==wt.producerFrame)return null;const a=new DataView(o.buffer,o.byteOffset,o.byteLength);return{type:o[1],channelId:a.getUint32(2,!1),sequence:a.getUint32(6,!1),payload:o.subarray(wn)}}function Co(){return yr()}function To(t,o,a){const[s,c]=n.useState({connected:!1,error:null}),[u,d]=n.useState(0),p=n.useRef(null),k=n.useRef(0),j=n.useRef(new Map),R=n.useRef([]),l=n.useRef(0),v=n.useRef(new Map),S=n.useRef(new Map),P=n.useRef(new Map),m=n.useRef(1e3),g=n.useRef(!1),h=n.useRef(null),w=n.useRef(t),T=n.useRef(o),N=n.useRef(a);w.current=t,T.current=o,N.current=a;const D=n.useCallback((C,O)=>{let U=v.current.get(C);return U||v.current.set(C,U=new Set),U.add(O),()=>U.delete(O)},[]),_=n.useCallback((C,O)=>{let U=S.current.get(C);return U||S.current.set(C,U=new Set),U.add(O),()=>U.delete(O)},[]),ee=n.useCallback((C,O)=>{let U=P.current.get(C);return U||P.current.set(C,U=new Set),U.add(O),()=>U.delete(O)},[]),re=n.useCallback((C,O)=>{const U=p.current;if(!U||U.readyState!==WebSocket.OPEN)return!1;const B=new TextEncoder().encode(O),z=new Uint8Array(6+B.byteLength),x=new DataView(z.buffer);return z[0]=1,z[1]=1,x.setUint32(2,C),z.set(B,6),U.send(z),!0},[]),H=n.useCallback(C=>{const O=p.current;(O==null?void 0:O.readyState)===WebSocket.OPEN?O.send(C):R.current.push(C)},[]),te=n.useCallback((C,O={},U=15e3)=>new Promise((B,z)=>{var K;if(C.startsWith("browser:")&&((K=p.current)==null?void 0:K.readyState)!==WebSocket.OPEN){z(Object.assign(new Error("远程连接已断开,请等待重新连接"),{code:"EOFFLINE"}));return}const x=++l.current,W=setTimeout(()=>{j.current.delete(x),z(new Error(`${C} timeout`))},U);j.current.set(x,{resolve:B,reject:z,timer:W,type:C}),H(JSON.stringify({type:C,_req:x,...O}))}),[H]),I=n.useCallback(async()=>{g.current=!1;const C=++k.current;h.current&&(clearInterval(h.current),h.current=null);const O=p.current;if(O){O.onopen=O.onmessage=O.onerror=O.onclose=null;try{O.close()}catch{}}let U;try{U=await T.current()}catch{C===k.current&&N.current();return}if(C!==k.current||g.current)return;let B;try{B=new WebSocket(`${Co()}?nonce=${encodeURIComponent(U)}`)}catch(z){c({connected:!1,error:String(z)});return}B.binaryType="arraybuffer",p.current=B,B.onopen=()=>{if(C!==k.current||p.current!==B)return;m.current=1e3,c({connected:!0,error:null}),d(K=>K+1);const z=R.current.splice(0);for(const K of z)B.send(K);let x=Date.now();h.current=setInterval(()=>{if(p.current!==B||B.readyState!==WebSocket.OPEN){clearInterval(h.current),h.current=null;return}if(Date.now()-x>25e3){try{B.close()}catch{}return}try{B.send(JSON.stringify({type:"ping"}))}catch{}},1e4);const W=()=>{x=Date.now()};B.addEventListener("message",W),B.addEventListener("close",()=>B.removeEventListener("message",W),{once:!0})},B.onmessage=z=>{var W,K,A;if(C!==k.current||p.current!==B)return;if(typeof z.data!="string"){const L=new Uint8Array(z.data);if(L.byteLength>=6&&L[0]===1&&(L[1]===2||L[1]===6)){const se=new DataView(L.buffer,L.byteOffset,L.byteLength).getUint32(2);(W=S.current.get(se))==null||W.forEach(b=>b(L.subarray(6),L[1]===6))}else if(L.byteLength>=6&&L[0]===1&&L[1]===3){const se=new DataView(L.buffer,L.byteOffset,L.byteLength).getUint32(2);(K=P.current.get(se))==null||K.forEach(b=>b())}else w.current(L);return}let x;try{x=JSON.parse(z.data)}catch{return}if(x.type==="error"&&x.id!=null){const L=j.current.get(x.id);if(L){j.current.delete(x.id),clearTimeout(L.timer);const se=Object.assign(new Error(x.error||"gateway error"),{code:x.code});L.reject(se)}return}if(x.id!=null&&typeof x.type=="string"&&x.type.endsWith(":result")){const L=j.current.get(x.id);(L==null?void 0:L.type)==="fs:preview-open"&&typeof x.url=="string"&&(x.url=xr(x.url)),L&&(j.current.delete(x.id),clearTimeout(L.timer),L.resolve(x));return}(A=v.current.get(x.type))==null||A.forEach(L=>L(x))},B.onclose=z=>{if(C!==k.current||p.current!==B)return;h.current&&(clearInterval(h.current),h.current=null),p.current=null;for(const[W,K]of j.current)K.type.startsWith("browser:")&&(clearTimeout(K.timer),j.current.delete(W),K.reject(Object.assign(new Error("远程连接已断开,请重新接管"),{code:"EOFFLINE"})));if(c({connected:!1,error:null}),z.code===4001||z.code===4003){N.current();return}if(g.current)return;const x=m.current;m.current=Math.min(x*2,8e3),setTimeout(()=>{!g.current&&C===k.current&&I()},x)},B.onerror=()=>{}},[]);return n.useEffect(()=>(I(),()=>{g.current=!0,k.current++,h.current&&(clearInterval(h.current),h.current=null);const C=p.current;if(p.current=null,C){C.onopen=C.onmessage=C.onerror=C.onclose=null;try{C.close()}catch{}}}),[I]),{state:s,epoch:u,rpc:te,onEvent:D,onTerminalData:_,onTerminalReset:ee,sendTerminalInput:re,reconnect:I}}function No(){const[t,o]=n.useState("loading"),[a,s]=n.useState(null),[c]=n.useState("same-origin"),[u,d]=n.useState(null),p=n.useCallback(async()=>{o("loading"),d(null);try{const l=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if(l.status===401||l.status===423){window.location.reload();return}if(!l.ok)throw new Error(`HTTP ${l.status}`);const v=await l.json();s(v.user),o("authenticated")}catch{d("无法连接远程控制台"),o("needsLogin")}},[]);n.useEffect(()=>{p()},[p]);const k=n.useCallback(async()=>{const l=await fetch("/api/web-console/bootstrap",{credentials:"same-origin",cache:"no-store"});if((l.status===401||l.status===423)&&window.location.reload(),!l.ok)throw new Error("bootstrap failed");const v=await l.json();return s(v.user),o("authenticated"),v.wsNonce},[]),j=n.useCallback(async()=>(window.location.reload(),!1),[]),R=n.useCallback(async()=>{const l=await fetch("/api/pairing/logout",{method:"POST",credentials:"same-origin"});l.ok||l.status===401||l.status===423?window.location.reload():d("退出失败,请重试")},[]);return{status:t,user:a,error:u,csrfToken:c,setup:j,login:j,logout:R,refresh:p,getWsNonce:k}}function Ro({children:t}){const o=No(),[a,s]=n.useState(!1),c=o.status==="authenticated",u=n.useCallback(()=>s(!0),[]);return n.useEffect(()=>{c||s(!1)},[c]),e.jsxs(e.Fragment,{children:[c?t(o,u):null,e.jsx(vr,{ready:c&&a,error:o.error,onRetry:()=>void o.refresh()})]})}function xn(t,o,a){const s=t.findIndex(p=>p.id===o),c=t.findIndex(p=>p.id===a);if(s<0||c<0||s===c)return[...t];const u=[...t],[d]=u.splice(s,1);return u.splice(c,0,d),u}function Lo(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():Array.from(crypto.getRandomValues(new Uint8Array(16)),t=>t.toString(16).padStart(2,"0")).join("")}function Fn(t,o=Lo()){return{id:o,command:t.trim()}}function Po({commands:t,onChange:o,onExecute:a}){const[s,c]=n.useState(null),[u,d]=n.useState(""),[p,k]=n.useState(null),j=n.useRef(null),R=()=>{if(!s)return;const m=s.value.trim();if(!m)return d("命令不能为空");if(m.length>1e3)return d("命令最多 1000 个字符");if(/[\r\n\0]/.test(m))return d("命令只能包含一行");s.id?o(t.map(g=>g.id===s.id?{...g,command:m}:g)):o([...t,Fn(m)]),c(null),d("")},l=(m,g)=>{m.preventDefault(),m.stopPropagation(),j.current=g,k(g),m.currentTarget.setPointerCapture(m.pointerId)},v=m=>{var w;if(!j.current)return;const g=(w=document.elementFromPoint(m.clientX,m.clientY))==null?void 0:w.closest("[data-pinned-id]"),h=g==null?void 0:g.dataset.pinnedId;h&&h!==j.current&&o(xn(t,j.current,h))},S=m=>{m.currentTarget.hasPointerCapture(m.pointerId)&&m.currentTarget.releasePointerCapture(m.pointerId),j.current=null,k(null)},P=(m,g)=>{if(m.key!=="ArrowUp"&&m.key!=="ArrowDown")return;m.preventDefault();const h=t.findIndex(T=>T.id===g),w=t[h+(m.key==="ArrowUp"?-1:1)];w&&o(xn(t,g,w.id))};return e.jsxs("section",{className:"pinned-commands","aria-labelledby":"pinned-command-title",children:[e.jsxs("div",{className:"pinned-command-head",children:[e.jsx("span",{id:"pinned-command-title",children:"置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:()=>{c({id:null,value:""}),d("")},"aria-label":"新增置顶命令",title:"新增置顶命令",children:e.jsx(Ve,{size:14,"aria-hidden":"true"})})]}),t.map(m=>(s==null?void 0:s.id)===m.id?e.jsx(yn,{editor:s,error:u,onChange:g=>{c({...s,value:g}),d("")},onSave:R,onCancel:()=>{c(null),d("")}},m.id):e.jsxs("div",{className:`pinned-command-row${p===m.id?" pinned-command-dragging":""}`,"data-pinned-id":m.id,role:"button",tabIndex:0,onClick:()=>a(m.command),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),a(m.command))},children:[e.jsx("button",{className:"pinned-command-grip",onPointerDown:g=>l(g,m.id),onPointerMove:v,onPointerUp:S,onPointerCancel:S,onKeyDown:g=>P(g,m.id),onClick:g=>g.stopPropagation(),"aria-label":`调整 ${m.command} 的顺序`,title:"拖动排序,或按上下方向键",children:e.jsx(Dr,{size:14,"aria-hidden":"true"})}),e.jsx("code",{children:m.command}),e.jsxs("div",{className:"pinned-command-actions",onClick:g=>g.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>{c({id:m.id,value:m.command}),d("")},"aria-label":`编辑 ${m.command}`,title:"编辑",children:e.jsx(ft,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>o(t.filter(g=>g.id!==m.id)),"aria-label":`删除 ${m.command}`,title:"删除",children:e.jsx(vt,{size:12,"aria-hidden":"true"})})]})]},m.id)),(s==null?void 0:s.id)===null&&e.jsx(yn,{editor:s,error:u,onChange:m=>{c({...s,value:m}),d("")},onSave:R,onCancel:()=>{c(null),d("")}})]})}function yn({editor:t,error:o,onChange:a,onSave:s,onCancel:c}){return e.jsxs("div",{className:"pinned-command-editor",children:[e.jsx("input",{autoFocus:!0,value:t.value,maxLength:1e3,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&s(),u.key==="Escape"&&c()},"aria-label":t.id?"编辑置顶命令":"新增置顶命令"}),e.jsx("button",{className:"history-icon-button",onClick:s,"aria-label":"保存命令",title:"保存",children:e.jsx(mt,{size:13,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",onClick:c,"aria-label":"取消编辑",title:"取消",children:e.jsx(Ee,{size:13,"aria-hidden":"true"})}),o&&e.jsx("small",{role:"alert",children:o})]})}function Io({csrfToken:t,terminalId:o,pinnedCommands:a,onPinnedCommandsChange:s,onFill:c,onExecute:u}){const[d,p]=n.useState([]),[k,j]=n.useState(""),[R,l]=n.useState(""),v=n.useCallback(async()=>{const h=new URLSearchParams({q:k,limit:"200"}),w=await fetch(`/api/web-console/history?${h}`,{credentials:"same-origin"});w.ok&&p((await w.json()).history)},[k]);n.useEffect(()=>{const h=setTimeout(v,200);return()=>clearTimeout(h)},[v]);const S=async h=>{await fetch("/api/web-console/history",{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":t},body:JSON.stringify({id:h})}),v()},P=h=>{o&&c(h)},m=n.useCallback(h=>{h==="[REDACTED]"||a.some(w=>w.command===h)||s([...a,Fn(h)])},[s,a]),g=async h=>{const w=await Br(h);l(w?"已复制命令":"复制失败,请长按命令手动复制")};return e.jsxs("div",{className:"history-panel",children:[e.jsx(Po,{commands:a,onChange:s,onExecute:u}),e.jsxs("div",{className:"history-search",children:[e.jsx("input",{value:k,onChange:h=>j(h.target.value),placeholder:"搜索命令"}),e.jsx("button",{className:"history-icon-button",onClick:v,"aria-label":"刷新历史",title:"刷新历史",children:e.jsx(xe,{size:13,"aria-hidden":"true"})})]}),R&&e.jsx("div",{className:"terminal-clipboard-notice",role:"status",children:R}),d.map(h=>e.jsxs("div",{className:`history-item${o?"":" history-item-disabled"}`,role:"button",tabIndex:o?0:-1,onClick:()=>P(h.command),onKeyDown:w=>{w.target===w.currentTarget&&(w.key==="Enter"||w.key===" ")&&o&&(w.preventDefault(),P(h.command))},children:[e.jsx("code",{children:h.command}),e.jsxs("small",{children:[h.cwd," · ",new Date(h.executedAt).toLocaleString()]}),e.jsxs("div",{className:"history-item-actions",onClick:w=>w.stopPropagation(),onPointerDown:w=>w.stopPropagation(),children:[e.jsx("button",{className:"history-icon-button",onClick:()=>void g(h.command),"aria-label":"复制命令",title:"复制",children:e.jsx(Mr,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:!o,onClick:()=>P(h.command),"aria-label":"填入命令",title:"填入",children:e.jsx(eo,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button",disabled:h.command==="[REDACTED]"||a.some(w=>w.command===h.command),onClick:()=>m(h.command),"aria-label":"置顶命令",title:"置顶",children:e.jsx(Or,{size:12,"aria-hidden":"true"})}),e.jsx("button",{className:"history-icon-button history-icon-danger",onClick:()=>S(h.id),"aria-label":"删除历史",title:"删除",children:e.jsx(vt,{size:12,"aria-hidden":"true"})})]})]},h.id)),!d.length&&e.jsx("div",{className:"history-empty",children:"暂无 Shell 命令历史"}),!o&&!!d.length&&e.jsx("div",{className:"history-empty",children:"请先打开一个终端页签"})]})}function Ao(t,o,a){const s=t.bottom+6,c=s+o<=a-8?s:t.top-o-6;return Math.max(8,Math.min(c,a-o-8))}function vn({themeId:t,onThemeChange:o}){const[a,s]=n.useState(!1),c=n.useRef(null),u=n.useRef(null),d=n.useRef(null),[p,k]=n.useState(null),[j,R]=n.useState({top:-1e3,left:0});return n.useEffect(()=>{var l;k(((l=c.current)==null?void 0:l.closest(".web-root"))??document.body)},[]),n.useLayoutEffect(()=>{if(!a)return;const l=()=>{var g,h,w;const S=(g=u.current)==null?void 0:g.getBoundingClientRect();if(!S)return;const P=Math.min(176,innerWidth-16),m=(h=c.current)!=null&&h.closest(".compact-tools-panel, .glass-tools-sheet")?Ao(S,((w=d.current)==null?void 0:w.offsetHeight)??0,innerHeight):S.bottom+6;R({top:m,left:Math.max(8,Math.min(innerWidth-P-8,S.right-P))})};l();const v=new ResizeObserver(l);return d.current&&v.observe(d.current),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{v.disconnect(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0)}},[a]),n.useEffect(()=>{if(!a)return;const l=S=>{var P,m;!((P=c.current)!=null&&P.contains(S.target))&&!((m=d.current)!=null&&m.contains(S.target))&&s(!1)},v=S=>{var P;S.key==="Escape"&&(s(!1),(P=u.current)==null||P.focus())};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",v)}},[a]),e.jsxs("div",{ref:c,className:"theme-picker",children:[e.jsx("button",{ref:u,type:"button",className:"file-drawer-toggle","aria-label":"换肤",title:"换肤","aria-expanded":a,"aria-haspopup":"dialog",onClick:()=>s(l=>!l),children:e.jsx(An,{size:17,"aria-hidden":"true"})}),a&&p&&Ie.createPortal(e.jsxs("div",{ref:d,className:"theme-popover",role:"dialog","aria-label":"选择皮肤","data-toolbar-overlay":!0,style:{position:"fixed",...j,zIndex:210,width:Math.min(176,innerWidth-16),maxHeight:"calc(100dvh - 16px)",overflowY:"auto",boxSizing:"border-box",padding:8,borderRadius:10,border:"1px solid var(--ui-tabbar-border, #282b36)",background:"var(--ui-tab-active-bg, #262b38)",boxShadow:"0 10px 28px rgba(0,0,0,.45)"},children:[e.jsx("div",{style:{fontSize:10,color:"var(--ui-connection-text, #777b8c)",margin:"2px 4px 6px",letterSpacing:.5},children:"皮肤"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:kr.map(l=>{const v=l.id===t;return e.jsxs("button",{type:"button",className:"theme-popover-item","aria-label":l.label,"aria-pressed":v,onPointerDown:S=>S.stopPropagation(),onClick:()=>{o(l.id),s(!1)},style:{background:v?"color-mix(in srgb, var(--ui-tab-accent, #7aa2f7) 14%, transparent)":"transparent"},children:[e.jsx("span",{style:{width:18,height:18,borderRadius:5,flexShrink:0,background:`linear-gradient(135deg, ${l.preview[0]} 55%, ${l.preview[1]} 55%)`,boxShadow:"inset 0 0 0 1px rgba(128,128,160,.25)"}}),e.jsx("span",{style:{flex:1,textAlign:"left",fontSize:12,fontWeight:v?600:400,color:v?"var(--ui-tab-active-text, #edf0f7)":"var(--ui-tab-text, #8f93a4)"},children:l.label}),v&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ui-tab-accent, #7aa2f7)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},l.id)})})]}),p)]})}function kn({value:t,onChange:o}){return e.jsx("button",{type:"button",className:"file-drawer-toggle navigation-layout-toggle","aria-label":"切换布局","data-navigation-layout":t,title:Er(t),onClick:()=>o(jr(t)),children:e.jsx(zr,{size:17,"aria-hidden":"true"})})}const Ke="agent-ui-prefs";function Do(t){var o;try{const a=JSON.parse((t==null?void 0:t.getItem(Ke))??"null");return Sr((o=a==null?void 0:a.state)==null?void 0:o.navigationLayout)?a.state.navigationLayout:lt}catch{return lt}}function Mo(t,o){try{let a;try{a=JSON.parse(t.getItem(Ke)??"null")}catch{a=null}const s=a&&typeof a=="object"&&!Array.isArray(a)?a:{},c=s.state&&typeof s.state=="object"&&!Array.isArray(s.state)?s.state:{};t.setItem(Ke,JSON.stringify({...s,version:s.version??4,state:{...c,navigationLayout:o}}))}catch{}}function Oo(t,o){return{height:Math.round((t==null?void 0:t.height)??o.height),width:Math.round((t==null?void 0:t.width)??o.width),top:Math.round((t==null?void 0:t.offsetTop)??0),left:Math.round((t==null?void 0:t.offsetLeft)??0)}}function zo(t){t&&(t.scrollLeft=0)}const _o="agent-webapp:tab-swipe:v1";function Wo(t){if(!t||typeof t!="object")return null;const o=t;return o.type!==_o||o.phase!=="move"&&o.phase!=="end"&&o.phase!=="cancel"||typeof o.deltaX!="number"||!Number.isFinite(o.deltaX)?null:o}function Fo(t,o,a){return t.origin!==o||t.source!==a?null:Wo(t.data)}const jn="agent-webapp:ready:v1";function $o(t){return!t||typeof t!="object"||t.type!==jn?null:{type:jn}}function En(t,o,a){return t.origin!==o||t.source!==a?null:$o(t.data)}function st({groupId:t,title:o,onFrame:a,onLoad:s,view:c,discussionId:u}){const d=n.useRef(null),[p,k]=n.useState("loading"),[j,R]=n.useState(0),l=t===void 0;return n.useEffect(()=>{const v=S=>{var P,m,g;if(c==="sessions"){S.origin===window.location.origin&&S.source===((P=d.current)==null?void 0:P.contentWindow)&&((m=S.data)==null?void 0:m.type)===Kr&&k("ready");return}qr(S,window.location.origin,((g=d.current)==null?void 0:g.contentWindow)??null,t??null)&&k("ready")};return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[t,c]),n.useEffect(()=>{if(p!=="loading")return;const v=window.setTimeout(()=>k(S=>S==="loading"?"error":S),3e4);return()=>window.clearTimeout(v)},[p,j]),e.jsxs("div",{className:"collaboration-pane","aria-busy":p==="loading",children:[e.jsx("iframe",{ref:v=>{d.current=v,a(v)},className:`webapp-frame collaboration-frame${p==="ready"?" is-ready":""}`,style:{visibility:p==="ready"?"visible":"hidden"},src:dt(c==="sessions"?"/app/?view=session-dashboard":l?"/app/?view=collaboration-dashboard":`/app/?view=collaboration&groupId=${encodeURIComponent(t)}${u?`&discussionId=${encodeURIComponent(u)}`:""}`),title:o,onLoad:s,onError:()=>k("error")},j),p==="loading"&&e.jsx(Ge,{label:"AGENT COLLABORATION",title:c==="sessions"?"正在打开会话 Dashboard":l?"正在打开群聊列表":"正在进入群聊",caption:c==="sessions"?"正在核对运行会话与待决策事项":l?"正在加载已保存的群聊":"正在加载群成员与聊天记录",icon:e.jsx(xt,{size:36,strokeWidth:1.5})}),p==="error"&&e.jsxs("div",{className:"collaboration-load-error",role:"alert",children:[e.jsx("strong",{children:c==="sessions"?"暂时无法打开会话 Dashboard":l?"暂时无法打开群聊列表":"暂时无法打开群聊"}),e.jsx("span",{children:"请检查连接后重试。"}),e.jsxs("button",{onClick:()=>{k("loading"),R(v=>v+1)},children:[e.jsx(xe,{size:15}),"重新加载"]})]}),e.jsx("style",{jsx:!0,children:`
|
|
88
83
|
.collaboration-pane { position:relative; height:100%; background:var(--ui-term-col-bg, #101014); }
|
|
89
84
|
.collaboration-frame.is-ready { animation:collaboration-appear 220ms ease-out both; }
|
|
90
85
|
.collaboration-load-error { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; color:var(--ui-text, #e5e7eb); background:var(--ui-term-col-bg, #101014); padding:20px; text-align:center; }
|
|
@@ -93,4 +88,4 @@ import{c as xt,r as n,j as e,f as Ve,e as Ie,R as xe,X as Ee,n as cr,o as lr,p a
|
|
|
93
88
|
.collaboration-load-error button:focus-visible { outline:2px solid currentColor; outline-offset:3px; }
|
|
94
89
|
@keyframes collaboration-appear { from { opacity:0; } to { opacity:1; } }
|
|
95
90
|
@media (prefers-reduced-motion:reduce) { .collaboration-frame.is-ready { animation:none; } }
|
|
96
|
-
`})]})}function Cn(t){try{const o=JSON.parse(t||"null");if(!o||!Array.isArray(o.tabs))return null;const a=new Set,s=new Set(["webapp","aihub","flowstudio","remote-desktop","collaboration","collaboration-dashboard","session-dashboard"]),c=[];for(const u of o.tabs.slice(0,100))!u||typeof u.id!="string"||typeof u.title!="string"||a.has(u.id)||u.kind!==void 0&&!s.has(u.kind)||u.kind==="collaboration"&&typeof u.groupId!="string"||(a.add(u.id),c.push({id:u.id,title:u.title,...u.kind?{kind:u.kind}:{},...typeof u.groupId=="string"?{groupId:u.groupId}:{},...typeof u.discussionId=="string"&&/^[\w-]{1,200}$/.test(u.discussionId)?{discussionId:u.discussionId}:{}}));return{tabs:c,activeTerminalId:typeof o.activeTerminalId=="string"?o.activeTerminalId:null}}catch{return null}}function $o(t,o,a){const s=new Map(o.filter(d=>d.status==="active"||d.status==="detached").map(d=>[d.id,{id:d.id,title:d.title}])),c=[],u=new Set;for(const d of[...(t==null?void 0:t.tabs)??[],...a,...s.values()])u.has(d.id)||!d.kind&&!s.has(d.id)||(u.add(d.id),c.push(d.kind?d:s.get(d.id)));return c}const je={id:"remote-desktop",title:"远程桌面",kind:"remote-desktop"};function Tn(t){const o=t.find(a=>a.kind==="remote-desktop");return o?t.map(a=>a===o?{...je}:a):[...t,{...je}]}const Ae={id:"collaboration-dashboard",title:"群聊列表",kind:"collaboration-dashboard"};function Nn(t){return t.some(o=>o.id===Ae.id)?t:[...t,{...Ae}]}const Ye={id:"session-dashboard",title:"Dashboard",kind:"session-dashboard"};function Rn(t){return t.some(o=>o.id===Ye.id)?t:[...t,{...Ye}]}const Uo=ze(()=>Oe(()=>import("./TerminalPane-DkEyD1ge.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url),{ssr:!1}),Bo=ze(()=>Oe(()=>import("./FileTree-BB5xTMg6.js"),__vite__mapDeps([11,1,2,12,13,6]),import.meta.url),{ssr:!1}),qo=ze(()=>Oe(()=>import("./FilePreview-DScFSi_K.js").then(t=>t.b),__vite__mapDeps([14,1,2,5,15,13,6,16]),import.meta.url),{ssr:!1}),Ho=ze(()=>Oe(()=>import("./AiHubPane-BQ8CJAQL.js"),__vite__mapDeps([17,1,2,13,18]),import.meta.url),{ssr:!1}),Vo=ze(()=>Oe(()=>import("./FlowStudioPane-BBf0zyw1.js"),__vite__mapDeps([19,1,2,20,4,5,6,3,7,8,9]),import.meta.url),{ssr:!1,loading:()=>e.jsx(Ge,{})});function Ko(){return e.jsx(No,{children:(t,o)=>e.jsx(Jo,{auth:t,onWorkspaceReady:o})})}const ie={id:"webapp-agent",title:"智能助手",kind:"webapp"},Ln={id:"ai-hub",title:"AI Hub",kind:"aihub"},Pn={id:"flow-studio",title:"Flow Studio",kind:"flowstudio"};function Yo(){var t;return typeof document>"u"?Rr:ut((t=document.getElementById("web-theme-root"))==null?void 0:t.dataset.webTheme).id}const Go="agent-web-shell:skin:v1";function Jo({auth:t,onWorkspaceReady:o}){var $t,Ut,Bt,qt;const[a,s]=n.useState(null),[c,u]=n.useState(0),d=n.useCallback(r=>{if((r==null?void 0:r.openMode)==="new-tab"){window.open(r.url,"_blank","noopener,noreferrer");return}s(r)},[]),p=n.useCallback(r=>s((r==null?void 0:r.openMode)==="current"?r:null),[]),k=n.useRef(null),j=n.useRef(null),R=n.useRef(null),l=n.useRef(null),v=n.useRef(null),S=n.useRef(!1),[P,m]=n.useState({}),g=n.useRef(new Map),[h,w]=n.useState(0),[T,N]=n.useState(!1),[D,_]=n.useState(!1),ee=n.useRef(()=>{}),re=n.useCallback(r=>{var f;const i=Eo(r);if(!(!i||i.type!==wt.watcherFrame)){ee.current(i.channelId,i.sequence);for(const y of[k,j]){if(!((f=y.current)!=null&&f.contentWindow))continue;const E=i.payload.slice().buffer;y.current.contentWindow.postMessage({type:Sr,channelId:i.channelId,sequence:i.sequence,data:E},window.location.origin,[E])}}},[]),{state:H,epoch:te,rpc:I,onEvent:C,onTerminalData:O,onTerminalReset:U,sendTerminalInput:B}=Co(re,t.getWsNonce,t.refresh),z=n.useMemo(()=>({request:(r,i,f)=>I(r,i,f),subscribe:(r,i)=>C("fs:event",i)}),[C,I]);ee.current=(r,i)=>{I("browser:frame-ack",{channelId:r,sequence:i}).catch(()=>{})};const[x,W]=n.useState([{...ie}]),K=n.useRef(x);K.current=x;const[A,L]=n.useState(ie.id),[se,b]=n.useState({}),M=n.useRef(!1),[V,q]=n.useState(!1),[G,X]=n.useState(0),ce=`agentroam:workspace:${typeof window>"u"?"":Me()}:${(($t=t.user)==null?void 0:$t.id)??""}`,Se=n.useRef(null),le=n.useRef(new Map),_e=n.useRef(new Map),$n=n.useCallback((r,i)=>{le.current.set(r,i);const f=window.setTimeout(()=>{if(le.current.get(r)!==i)return;const y=_e.current.get(r);y&&(_e.current.delete(r),i(y,!0))},180);return()=>{window.clearTimeout(f),le.current.get(r)===i&&le.current.delete(r)}},[]),Un=n.useCallback(r=>{var f;if(!A||(f=x.find(y=>y.id===A))!=null&&f.kind)return;const i=le.current.get(A);i?i(r):I("term:input",{id:A,data:`${r}`}).catch(()=>{}),ue(!1)},[A,I,x]),[ye,Bn]=n.useState(!1),[Ce,Je]=n.useState({}),[pe,We]=n.useState(null),[de,ue]=n.useState(!1),[be,Fe]=n.useState("files"),[Te,Et]=n.useState(null),[Ne,St]=n.useState(!0),[qn,Hn]=n.useState(null),[Xe,Ct]=n.useState(!1),[Qe,Tt]=n.useState([]),[Ze,Nt]=n.useState(vo()),[me,et]=n.useState(Yo),[Re,Rt]=n.useState(lt),[Lt,Vn]=n.useState(!1);n.useEffect(()=>{const r=()=>{try{Rt(Ao(window.localStorage))}catch{}Vn(!0)},i=f=>{(f.key===Ke||f.key===null)&&r()};return r(),window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]);const Pt=n.useCallback(r=>{Rt(r);try{Do(window.localStorage,r)}catch{}},[]),[It,Kn]=n.useState(!1),$e=xo(t.csrfToken),[At,Yn]=n.useState(!1),ne=ut(me),ve=n.useRef(null),[Gn,tt]=n.useState(0),[Jn,nt]=n.useState(!1),rt=n.useRef(null),Dt=n.useRef(null),Mt=n.useCallback(r=>{var f;const i=[k.current,j.current,R.current,l.current,...g.current.values()];for(const y of i)(f=y==null?void 0:y.contentWindow)==null||f.postMessage({type:Go,skin:r},window.location.origin)},[]),oe=n.useCallback(()=>{var i;if(Mt(me),!Lt)return;const r=[k.current,j.current,R.current,l.current,...g.current.values()];for(const f of r)(i=f==null?void 0:f.contentWindow)==null||i.postMessage({type:Cr,navigationLayout:Re},window.location.origin)},[me,Re,Lt,Mt]);n.useEffect(()=>{oe()},[oe]),n.useEffect(()=>{const r=ne.cssVars["--ui-root-bg"],i=ne.cssVars["--ui-color-scheme"],f=document.getElementById("web-theme-root");for(const[E,$]of Object.entries(ne.cssVars))f==null||f.style.setProperty(E,$);f&&(f.dataset.webTheme=ne.id),document.documentElement.style.background=r,document.documentElement.style.colorScheme=i,document.body.style.background=r,document.body.style.colorScheme=i;let y=document.querySelector('meta[name="theme-color"]');y||(y=document.createElement("meta"),y.name="theme-color",document.head.append(y)),y.content=ne.cssVars["--ui-tabbar-bg"]},[ne]),n.useEffect(()=>{const r=i=>{var Ht,Vt,Kt,Yt,Gt,Jt,Xt,Qt,Zt,en,tn,nn,rn,on,an,sn,cn,ln;const f=((Ht=R.current)==null?void 0:Ht.contentWindow)??null,y=[(Vt=k.current)==null?void 0:Vt.contentWindow,f,(Kt=l.current)==null?void 0:Kt.contentWindow,...[...g.current.values()].map(F=>F.contentWindow)].find(F=>F&&F===i.source)??null,E=Kr(i,window.location.origin,y);if(E){if(s(null),E.kind==="dashboard")W(Rn),L(Ye.id);else if(E.kind==="groups")W(Nn),L(Ae.id);else if(E.kind==="group"){const F=`collaboration-${E.groupId}`,J={id:F,title:E.title,kind:"collaboration",groupId:E.groupId,discussionId:E.discussionId};W(ge=>ge.some(qe=>qe.id===F)?ge.map(qe=>qe.id===F?J:qe):[...ge,J]),L(F)}else S.current?(Gt=(Yt=k.current)==null?void 0:Yt.contentWindow)==null||Gt.postMessage({type:hn,intent:E},window.location.origin):v.current=E,L(ie.id);return}const $=qr(i,window.location.origin,f);if($){W(F=>$.deleted?F.filter(J=>J.groupId!==$.groupId):F.map(J=>J.groupId===$.groupId?{...J,title:$.title}:J)),$.deleted?L(F=>F===`collaboration-${$.groupId}`?Ae.id:F):m(F=>({...F,[$.groupId]:(F[$.groupId]||0)+1}));return}const Y=Hr(i,window.location.origin,i.source===f?f:((Jt=k.current)==null?void 0:Jt.contentWindow)??null);if(Y){const F=`collaboration-${Y.groupId}`;W(J=>J.some(ge=>ge.id===F)?J:[...J,{id:F,title:Y.title,kind:"collaboration",groupId:Y.groupId}]),L(F);return}const Q=((Xt=j.current)==null?void 0:Xt.contentWindow)??null,Z=Gr(i,window.location.origin,Q);if(Z!==null){N(Z);return}if(Sn(i,window.location.origin,Q)){N(!1),w(F=>F+1),_(!1),oe();return}if(Q&&i.origin===window.location.origin&&i.source===Q&&((Qt=i.data)==null?void 0:Qt.type)===Jr){_(!0);return}if(i.origin===window.location.origin&&i.source===Q&&Q&&((Zt=i.data)==null?void 0:Zt.type)===Xr){N(!1),I("browser:unwatch").catch(()=>{}),W(F=>F.filter(J=>J.kind!=="remote-desktop")),w(0),_(!1),L(ie.id);return}if(Lr(i,window.location.origin,((en=k.current)==null?void 0:en.contentWindow)??null)){W(Tn),L(je.id);return}if(Sn(i,window.location.origin,((tn=k.current)==null?void 0:tn.contentWindow)??null)){S.current=!0,Yn(!0),oe(),o(),v.current&&((rn=(nn=k.current)==null?void 0:nn.contentWindow)==null||rn.postMessage({type:hn,intent:v.current},window.location.origin),v.current=null);return}const sr=(on=[...g.current.values()].find(F=>F.contentWindow===i.source))==null?void 0:on.contentWindow,Le=zr(i,window.location.origin,sr??((an=k.current)==null?void 0:an.contentWindow)??null);if(Le){const F=J=>{Fe("files"),ue(!fn(J)),We(J),fn(J)||Hn({...Le,path:J})};Le.path.startsWith("~/")?I("hello").then(({home:J})=>{const ge=_r(Le.path,null,J);ge&&F(ge)}).catch(()=>{}):F(Le.path);return}const we=i.source===Q&&Q?Q:((sn=k.current)==null?void 0:sn.contentWindow)??null,ke=Pr(i,window.location.origin,we);if(ke){I(ke.method,{...ke.payload,...ke.method==="browser:watch"?{frameAck:!0}:{}}).then(F=>{we==null||we.postMessage({type:pn,id:ke.id,ok:!0,result:F},window.location.origin)},F=>{we==null||we.postMessage({type:pn,id:ke.id,ok:!1,error:F.message||"浏览器操作失败",code:F.code},window.location.origin)});return}ko(i,window.location.origin,[((cn=k.current)==null?void 0:cn.contentWindow)??null,f,((ln=l.current)==null?void 0:ln.contentWindow)??null,...[...g.current.values()].map(F=>F.contentWindow)],I)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[o,I,oe]),n.useEffect(()=>{const r=y=>{var E,$;for(const Y of[k,j])($=(E=Y.current)==null?void 0:E.contentWindow)==null||$.postMessage({type:it,event:y},window.location.origin)},f=["browser:session","browser:frame","browser:state","browser:closed","browser:webrtc"].map(y=>C(y,r));return()=>f.forEach(y=>y())},[C]),n.useEffect(()=>{var r,i;At&&((i=(r=k.current)==null?void 0:r.contentWindow)==null||i.postMessage({type:it,event:{type:"browser:connection",connected:H.connected,epoch:te}},window.location.origin))},[H.connected,te,At]),n.useEffect(()=>{var r,i;h&&((i=(r=j.current)==null?void 0:r.contentWindow)==null||i.postMessage({type:Yr,visible:A===je.id},window.location.origin))},[A,h]),n.useEffect(()=>{var r,i;h&&((i=(r=j.current)==null?void 0:r.contentWindow)==null||i.postMessage({type:it,event:{type:"browser:connection",connected:H.connected,epoch:te}},window.location.origin))},[H.connected,te,h]);const Ot=n.useRef(0),zt=A?se[A]??null:null;n.useEffect(()=>{const r=window.visualViewport;let i=null,f="";const y=()=>{const E=Mo(r,{height:window.innerHeight,width:window.innerWidth}),$=`${E.width}x${E.height}+${E.top}+${E.left}`;$!==f&&(f=$,document.documentElement.style.setProperty("--vv-height",`${E.height}px`),document.documentElement.style.setProperty("--vv-width",`${E.width}px`),document.documentElement.style.setProperty("--vv-top",`${E.top}px`),document.documentElement.style.setProperty("--vv-left",`${E.left}px`),i&&window.clearTimeout(i),i=window.setTimeout(y,250))};return y(),r==null||r.addEventListener("resize",y),r==null||r.addEventListener("scroll",y),window.addEventListener("orientationchange",y),window.addEventListener("resize",y),document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),()=>{r==null||r.removeEventListener("resize",y),r==null||r.removeEventListener("scroll",y),window.removeEventListener("orientationchange",y),window.removeEventListener("resize",y),document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y),i&&window.clearTimeout(i),document.documentElement.style.removeProperty("--vv-height"),document.documentElement.style.removeProperty("--vv-width"),document.documentElement.style.removeProperty("--vv-top"),document.documentElement.style.removeProperty("--vv-left")}},[]),n.useEffect(()=>{fetch("/api/web-console/preferences",{credentials:"same-origin"}).then(r=>r.json()).then(r=>{var i,f,y,E;typeof((i=r.preferences)==null?void 0:i.keybarHidden)=="boolean"&&Ct(r.preferences.keybarHidden),Array.isArray((f=r.preferences)==null?void 0:f.keyOrder)&&Tt(r.preferences.keyOrder),Array.isArray((y=r.preferences)==null?void 0:y.pinnedCommands)&&Nt(r.preferences.pinnedCommands),(E=r.preferences)!=null&&E.theme&&et(ut(r.preferences.theme).id)}).catch(()=>{}).finally(()=>Kn(!0)),fetch("/api/web-console/device-state",{credentials:"same-origin"}).then(r=>r.json()).then(r=>{const i=r.deviceState;i!=null&&i.drawerTab&&Fe(i.drawerTab),i!=null&&i.activeTerminalId&&(Se.current=i.activeTerminalId),typeof(i==null?void 0:i.drawerOpen)=="boolean"&&ue(i.drawerOpen),i!=null&&i.fileTreeRoot&&Et(i.fileTreeRoot),typeof(i==null?void 0:i.fileTreeFollowMode)=="boolean"&&St(i.fileTreeFollowMode),i!=null&&i.selectedFile&&We(i.selectedFile),i!=null&&i.terminalScroll&&typeof i.terminalScroll=="object"&&Je(i.terminalScroll)}).catch(()=>{}).finally(()=>Bn(!0))},[]);const _t=n.useCallback(r=>{fetch("/api/web-console/preferences",{method:"PATCH",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":t.csrfToken},body:JSON.stringify(r)}).catch(()=>{})},[t.csrfToken]);n.useEffect(()=>{if(!It)return;const r=setTimeout(()=>_t({keybarHidden:Xe,keyOrder:Qe,pinnedCommands:Ze,theme:me}),500);return()=>clearTimeout(r)},[Xe,Qe,Ze,me,It,_t]);const Ue=n.useCallback(r=>{t.csrfToken&&fetch("/api/web-console/device-state",{method:"PUT",credentials:"same-origin",keepalive:!0,headers:{"content-type":"application/json","x-csrf-token":t.csrfToken},body:JSON.stringify(r)}).catch(()=>{})},[t.csrfToken]);n.useEffect(()=>{if(!t.csrfToken||!V||!ye)return;const r=setTimeout(()=>Ue({activeTerminalId:A,drawerOpen:de,drawerTab:be,fileTreeRoot:Te,fileTreeFollowMode:Ne,selectedFile:pe,terminalScroll:Ce}),500);return()=>clearTimeout(r)},[A,de,be,Te,Ne,pe,Ce,t.csrfToken,Ue,V,ye]),n.useEffect(()=>{if(!t.csrfToken||!V||!ye)return;const r=()=>Ue({activeTerminalId:A,drawerOpen:de,drawerTab:be,fileTreeRoot:Te,fileTreeFollowMode:Ne,selectedFile:pe,terminalScroll:Ce});return window.addEventListener("pagehide",r),()=>window.removeEventListener("pagehide",r)},[A,de,be,Te,Ne,pe,Ce,t.csrfToken,Ue,V,ye]);const Xn=n.useCallback(r=>{We(r),ue(!1)},[]),Qn=n.useCallback(()=>{if(x.length>=8)return;const r=`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;W(i=>i.length>=8?i:[...i,{id:r,title:`Terminal ${i.length+1}`}]),L(r)},[x.length]),Zn=n.useCallback(r=>{const i=x.find(E=>E.id===A);if(i!=null&&i.kind&&i.kind!=="webapp")return;if(i&&!i.kind){const E=le.current.get(i.id);E?E(r,!0):_e.current.set(i.id,r),ue(!1);return}const f=x.length>=8?x.find(E=>!E.kind):null,y=(f==null?void 0:f.id)??`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;f?_e.current.set(y,r):W(E=>[...E,{id:y,title:`Terminal ${E.length+1}`,initialCommand:r}]),L(y),ue(!1)},[A,x]);n.useEffect(()=>{if(!H.connected||!ye||M.current)return;M.current=!0;let r=!1,i=!1,f;return I("term:list").then(y=>{if(r)return;let E=null;try{E=Cn(localStorage.getItem(ce))}catch{}const $=$o(E,y.tabs,K.current);W($),L(Y=>{const Q=K.current.find(he=>he.id===Y&&he.kind&&he.kind!=="webapp");if(Q)return Q.id;const Z=(E==null?void 0:E.activeTerminalId)||Se.current||Y||ie.id;return Z===ie.id?ie.id:$.some(he=>he.id===Z)?Z:ie.id}),i=!0,q(!0)}).catch(()=>{r||(M.current=!1,f=setTimeout(()=>X(y=>y+1),2e3))}),()=>{r=!0,clearTimeout(f),i||(M.current=!1)}},[H.connected,ye,I,ce,G]),n.useLayoutEffect(()=>{if(V)try{const r=Cn(JSON.stringify({tabs:x,activeTerminalId:A}));localStorage.setItem(ce,JSON.stringify(r))}catch{}},[x,A,V,ce]);const er=r=>{var f;if(r===ie.id)return;const i=(f=x.find(y=>y.id===r))==null?void 0:f.kind;i==="remote-desktop"&&(w(0),_(!1),I("browser:unwatch").catch(()=>{})),!(!i&&!window.confirm("关闭页签会终止该终端进程,确认关闭?"))&&(W(y=>{var $;const E=y.filter(Y=>Y.id!==r);return A===r&&L((($=E[0])==null?void 0:$.id)??null),E}),i||I("term:kill",{id:r}).catch(()=>{}))},tr=n.useCallback(()=>{W(r=>{const i=r.find(f=>f.kind==="aihub");return i?(L(i.id),r):(L(Ln.id),[...r,{...Ln}])})},[]),nr=n.useCallback(()=>{W(r=>{const i=r.find(f=>f.kind==="flowstudio");return i?(L(i.id),r):(L(Pn.id),[...r,{...Pn}])})},[]),rr=n.useCallback(()=>{W(Tn),L(je.id)},[]);n.useEffect(()=>{const r=C("term:exited",i=>{const f=i==null?void 0:i.id;f&&(W(y=>{const E=y.filter($=>$.id!==f);return L($=>{var Y;return $===f?((Y=E[0])==null?void 0:Y.id)??null:$}),E}),Je(y=>{if(!(f in y))return y;const E={...y};return delete E[f],E}))});return()=>{r()}},[C]);const Wt=n.useCallback(r=>{if(!A||x.length<2)return;const f=(x.findIndex(y=>y.id===A)+r+x.length)%x.length;L(x[f].id)},[A,x]),Ft=Math.max(0,x.findIndex(r=>r.id===A)),or=((Ut=x[Ft])==null?void 0:Ut.kind)==="webapp"?ne.cssVars["--ui-term-col-bg"]:ne.termHostBg,ir={...ae.root,...ne.cssVars,"--ui-active-content-bg":or,"--ui-terminal-bg":ne.termHostBg,"--ui-primary-text":ne.keybar.accentText,background:"var(--ui-root-bg)",color:"var(--ui-text)"},fe=n.useCallback(()=>{ve.current=null,tt(0),nt(!1)},[]),ot=n.useCallback(r=>{Math.abs(r)>=64&&x.length>1&&Wt(r<0?1:-1),fe()},[x.length,Wt,fe]),ar=r=>r instanceof Element&&!!r.closest(".terminal-screen");n.useEffect(()=>{const r=i=>{var y;if(A!==ie.id)return;const f=Wo(i,window.location.origin,((y=k.current)==null?void 0:y.contentWindow)??null);f&&(f.phase==="move"?(nt(!0),tt(f.deltaX)):f.phase==="end"?ot(f.deltaX):fe())};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[A,ot,fe]);const Be=n.useCallback((r="smooth")=>{const i=Dt.current;if(!i||!A)return;const f=i.querySelector(`[data-terminal-id="${A}"]`);if(!f)return;if(f===i.querySelector("[data-terminal-id]")){Oo(i);return}const y=i.querySelector(".terminal-connection"),E=(y==null?void 0:y.offsetWidth)??0,$=8,Y=f.offsetLeft,Q=Y+f.offsetWidth,Z=i.scrollLeft,he=Z+i.clientWidth-E;Y<Z+$?i.scrollTo({left:Math.max(0,Y-$),behavior:r}):Q>he-$&&i.scrollTo({left:Q-i.clientWidth+E+$,behavior:r})},[A]);return n.useLayoutEffect(()=>{if(!A)return;const r=x.length>Ot.current;Ot.current=x.length,Be(r?"auto":"smooth")},[A,x.length,Be]),n.useEffect(()=>{const r=()=>requestAnimationFrame(()=>Be("auto"));return window.addEventListener("pageshow",r),()=>window.removeEventListener("pageshow",r)},[Be]),e.jsxs("div",{className:`web-root ${T&&A===je.id&&!a?"is-remote-fullscreen":""}`,style:ir,children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Tr}}),e.jsxs("div",{className:"terminal-tabs",children:[a&&e.jsxs("div",{className:"computer-page-heading",children:[e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"返回电脑会话",title:"返回电脑会话",onClick:()=>s(null),children:e.jsx(Fr,{size:18})}),e.jsx("span",{children:a.name}),e.jsx("a",{className:"file-drawer-toggle",href:a.url,target:"_blank",rel:"noopener noreferrer","aria-label":"在新页面打开当前页面",title:"打开原页面",children:e.jsx(jt,{size:16})})]}),e.jsx("div",{className:"terminal-tab-list",ref:Dt,hidden:!!a,children:x.map(r=>e.jsxs("div",{"data-terminal-id":r.id,draggable:!0,className:`terminal-tab ${r.id===A?"active":""}`,onDragStart:()=>{rt.current=r.id},onDragOver:i=>i.preventDefault(),onDrop:i=>{i.preventDefault();const f=rt.current;rt.current=null,!(!f||f===r.id)&&W(y=>{const E=y.findIndex(Z=>Z.id===f),$=y.findIndex(Z=>Z.id===r.id);if(E<0||$<0)return y;const Y=[...y],[Q]=Y.splice(E,1);return Y.splice($,0,Q),I("term:reorder",{ids:Y.filter(Z=>!Z.kind).map(Z=>Z.id)}).catch(()=>{}),Y})},onClick:()=>L(r.id),onDoubleClick:()=>{var f;if(r.kind)return;const i=(f=window.prompt("页签名称",r.title))==null?void 0:f.trim();i&&I("term:rename",{id:r.id,title:i}).then(()=>W(y=>y.map(E=>E.id===r.id?{...E,title:i}:E))).catch(()=>{})},children:[e.jsx("span",{children:r.title}),r.kind!=="webapp"&&e.jsx("button",{tabIndex:-1,onClick:i=>{i.stopPropagation(),er(r.id)},children:"×"})]},r.id))}),e.jsx("button",{className:"terminal-add","aria-label":"新建终端页签",hidden:!!a,disabled:x.length>=8,onClick:Qn,children:"+"}),e.jsx("div",{className:"terminal-connection",children:e.jsx(Nr,{glass:me==="glass",compact:Re==="agent-rail",avatar:e.jsx(po,{username:((Bt=t.user)==null?void 0:Bt.username)??"?",connected:H.connected,accent:ne.keybar.accent,accentText:ne.keybar.accentText,selectedPageId:a==null?void 0:a.id,onSelectPage:d,onUpdatePage:p,configuration:$e,csrfToken:t.csrfToken}),items:[{id:"refresh",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"刷新页面",title:"刷新页面",onClick:()=>a?u(r=>r+1):window.location.reload(),children:e.jsx(xe,{size:17,"aria-hidden":"true"})})},{id:"dashboard",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开会话 Dashboard",title:"Dashboard · 会话总览",onClick:()=>{s(null),W(Rn),L(Ye.id)},children:e.jsx(On,{size:17,"aria-hidden":"true"})})},{id:"collaboration",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开群聊列表",title:"群聊列表",onClick:()=>{s(null),W(Nn),L(Ae.id)},children:e.jsx(yt,{size:17,"aria-hidden":"true"})})},{id:"install",content:e.jsx(to,{})},{id:"remote",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开远程桌面",title:"远程桌面 · 浏览器直播",onClick:()=>{s(null),rr()},children:e.jsx(ct,{size:17,"aria-hidden":"true"})})},{id:"ai-hub",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开 AI Hub",title:"AI Hub · 多模型对比",onClick:()=>{s(null),tr()},children:e.jsx(Dn,{size:17,"aria-hidden":"true"})})},{id:"flow",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开数字人",title:"数字人 · Flow Studio",onClick:()=>{s(null),nr()},children:e.jsx(vt,{size:17,"aria-hidden":"true"})})},{id:"theme",content:e.jsxs("div",{className:"web-appearance-controls",children:[e.jsx(kn,{themeId:me,onThemeChange:et}),e.jsx(jn,{value:Re,onChange:Pt})]}),compactItems:[{id:"theme",content:e.jsx(kn,{themeId:me,onThemeChange:et})},{id:"navigation-layout",content:e.jsx(jn,{value:Re,onChange:Pt})}]},{id:"files",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":de?"关闭我的文件":"打开我的文件",title:"我的文件","aria-expanded":de,onClick:()=>{s(null),ue(r=>!r)},children:e.jsx($r,{size:17,"aria-hidden":"true"})})}].filter(r=>$e.settings.visibleTools.some(i=>i===r.id)).sort((r,i)=>$e.settings.visibleTools.findIndex(f=>f===r.id)-$e.settings.visibleTools.findIndex(f=>f===i.id))})})]}),e.jsxs("main",{className:`workspace ${de?"show-tree":""} ${pe?"has-preview":""}`,hidden:!!a,style:ae.workspace,children:[e.jsx("section",{className:"term-col",style:ae.termCol,onPointerDownCapture:r=>{r.pointerType!=="touch"||!ar(r.target)||(fe(),ve.current={x:r.clientX,y:r.clientY,axis:"pending",pointerId:r.pointerId})},onPointerMoveCapture:r=>{const i=ve.current;if(!i||r.pointerId!==i.pointerId||r.pointerType!=="touch")return;const f=r.clientX-i.x,y=r.clientY-i.y;if(i.axis==="pending"){if(Math.max(Math.abs(f),Math.abs(y))<=8)return;if(Math.abs(y)>=Math.abs(f)*1.2){ve.current=null;return}i.axis="horizontal",nt(!0);const E=$=>{window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E),ve.current===i&&fe()};window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E)}i.axis==="horizontal"&&(r.preventDefault(),tt(f))},onPointerUpCapture:r=>{const i=ve.current;if(!i||r.pointerId!==i.pointerId)return;const f=r.clientX-i.x;i.axis==="horizontal"&&Math.abs(f)>=64?ot(f):fe()},onPointerCancelCapture:fe,children:e.jsx("div",{className:"terminal-track",style:{transform:`translate3d(calc(${-Ft*100}% + ${Gn}px),0,0)`,transition:Jn?"none":"transform 260ms cubic-bezier(.22,.8,.32,1)"},children:x.map(r=>e.jsx("div",{className:"terminal-slide",style:{position:"relative"},children:r.kind==="webapp"?e.jsx("iframe",{ref:k,className:"webapp-frame",src:dt("/app/"),title:r.title,onLoad:oe}):r.kind==="session-dashboard"?e.jsx(st,{view:"sessions",title:"会话 Dashboard",onFrame:i=>{l.current=i},onLoad:oe}):r.kind==="collaboration-dashboard"?e.jsx(st,{title:"群聊列表",onFrame:i=>{R.current=i},onLoad:oe}):r.kind==="collaboration"?e.jsx(st,{groupId:r.groupId||"",discussionId:r.discussionId,title:r.title,onFrame:i=>{i?g.current.set(r.id,i):g.current.delete(r.id)},onLoad:oe},`${r.id}-${r.discussionId??""}-${P[r.groupId||""]||0}`):r.kind==="remote-desktop"?e.jsxs("div",{style:{height:"100%",background:"var(--ui-term-col-bg, #101014)"},"aria-busy":!D,children:[e.jsx("iframe",{ref:j,className:"webapp-frame",style:{visibility:D?"visible":"hidden"},src:dt("/app/?view=remote-desktop"),title:"远程桌面",onLoad:oe}),!D&&e.jsx(Ge,{label:"REMOTE DESKTOP",title:"正在打开远程桌面",caption:"正在准备桌面与连接",icon:e.jsx(ct,{size:36,strokeWidth:1.5})})]}):r.kind==="aihub"?e.jsx(Ho,{visible:r.id===A,rpc:I}):r.kind==="flowstudio"?e.jsx(Vo,{visible:r.id===A}):e.jsx(Uo,{terminalId:r.id,title:r.title,initialCommand:r.initialCommand,visible:r.id===A,state:H,rpc:I,onEvent:C,onTerminalData:O,onTerminalReset:U,sendTerminalInput:B,keyOrder:Qe,keybarHidden:Xe,onKeyOrderChange:Tt,onKeybarHiddenChange:Ct,terminalTheme:ne,initialScrollLine:Ce[r.id]??null,onScrollLineChange:i=>Je(f=>f[r.id]===i?f:{...f,[r.id]:i}),onRegisterFill:i=>$n(r.id,i),onCwdChange:i=>i&&b(f=>({...f,[r.id]:i}))})},r.id))})}),de&&e.jsx("div",{className:"drawer-mask",onClick:()=>ue(!1)}),e.jsxs("aside",{className:`tree-col ${de?"tree-col-open":""}`,style:ae.treeCol,children:[e.jsxs("div",{className:"tree-head",style:ae.treeHead,children:[e.jsx("button",{className:be==="files"?"drawer-tab-active":"",onClick:()=>Fe("files"),children:"文件"}),e.jsx("button",{className:be==="history"?"drawer-tab-active":"",onClick:()=>Fe("history"),children:"历史"}),e.jsx("span",{className:"tree-cwd",style:ae.treeCwd,children:zt??""}),e.jsx("button",{style:{...ae.iconBtn,marginLeft:"auto",flexShrink:0},onClick:()=>ue(!1),"aria-label":"close drawer",children:e.jsx(Ee,{size:15,"aria-hidden":"true"})})]}),be==="files"?e.jsx(Bo,{ready:te>0,followCwd:!0,cwd:zt,gateway:z,onOpenFile:Xn,selectedPath:pe,initialRoot:Te,initialFollow:Ne,revealRequest:qn,onTreeStateChange:(r,i)=>{Et(r),St(i)}}):e.jsx(Po,{csrfToken:t.csrfToken,terminalId:((qt=x.find(r=>r.id===A))==null?void 0:qt.kind)==="webapp"?null:A,pinnedCommands:Ze,onPinnedCommandsChange:Nt,onFill:Un,onExecute:Zn}),e.jsxs("div",{className:"tree-foot",style:ae.treeFoot,children:[e.jsx("span",{style:ae.treeFootDot}),e.jsx("span",{children:"实时同步"})]})]}),pe&&e.jsx("section",{className:"preview-col",style:ae.previewCol,children:e.jsx(qo,{path:pe,gateway:z,onClose:()=>We(null)})})]}),a&&e.jsx(go,{page:a,reloadKey:c},a.id)]})}const ae={root:{height:"100dvh",display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif',overflow:"hidden"},iconBtn:{minWidth:28,height:28,borderRadius:7,border:"1px solid var(--ui-tabbar-border, #303442)",background:"var(--ui-tab-bg, #202029)",color:"var(--ui-tab-text, #aaaab8)",fontSize:13},workspace:{flex:1,minHeight:0,display:"grid",position:"relative"},treeCol:{background:"var(--ui-tree-bg, #121218)",minHeight:0,flexDirection:"column"},treeHead:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px 4px",fontSize:11,textTransform:"uppercase",letterSpacing:1,color:"#778",flexShrink:0},treeCwd:{fontSize:10,color:"#556",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:150,textTransform:"none",letterSpacing:0},treeFoot:{display:"flex",alignItems:"center",gap:7,minHeight:31,padding:"6px 11px calc(env(safe-area-inset-bottom) + 6px)",borderTop:"1px solid var(--ui-tabbar-border, #282832)",boxShadow:"0 -5px 16px rgba(0,0,0,.22)",background:"var(--ui-tab-bg, #15151c)",color:"var(--ui-connection-text, #777789)",fontSize:10.5,flexShrink:0},treeFootDot:{width:6,height:6,borderRadius:99,background:"var(--ui-success, #9ece6a)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--ui-success, #9ece6a) 12%, transparent)",flexShrink:0},termCol:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:"var(--ui-term-col-bg, #101014)",gridColumn:1,overflow:"hidden"},previewCol:{minWidth:0,minHeight:0}},ii=Object.freeze(Object.defineProperty({__proto__:null,default:Ko},Symbol.toStringTag,{value:"Module"}));export{Ge as F,ii as p,Oo as r};
|
|
91
|
+
`})]})}function Sn(t){try{const o=JSON.parse(t||"null");if(!o||!Array.isArray(o.tabs))return null;const a=new Set,s=new Set(["webapp","aihub","flowstudio","remote-desktop","collaboration","collaboration-dashboard","session-dashboard"]),c=[];for(const u of o.tabs.slice(0,100))!u||typeof u.id!="string"||typeof u.title!="string"||a.has(u.id)||u.kind!==void 0&&!s.has(u.kind)||u.kind==="collaboration"&&typeof u.groupId!="string"||(a.add(u.id),c.push({id:u.id,title:u.title,...u.kind?{kind:u.kind}:{},...typeof u.groupId=="string"?{groupId:u.groupId}:{},...typeof u.discussionId=="string"&&/^[\w-]{1,200}$/.test(u.discussionId)?{discussionId:u.discussionId}:{}}));return{tabs:c,activeTerminalId:typeof o.activeTerminalId=="string"?o.activeTerminalId:null}}catch{return null}}function Uo(t,o,a){const s=new Map(o.filter(d=>d.status==="active"||d.status==="detached").map(d=>[d.id,{id:d.id,title:d.title}])),c=[],u=new Set;for(const d of[...(t==null?void 0:t.tabs)??[],...a,...s.values()])u.has(d.id)||!d.kind&&!s.has(d.id)||(u.add(d.id),c.push(d.kind?d:s.get(d.id)));return c}const je={id:"remote-desktop",title:"远程桌面",kind:"remote-desktop"};function Cn(t){const o=t.find(a=>a.kind==="remote-desktop");return o?t.map(a=>a===o?{...je}:a):[...t,{...je}]}const Ae={id:"collaboration-dashboard",title:"群聊列表",kind:"collaboration-dashboard"};function Tn(t){return t.some(o=>o.id===Ae.id)?t:[...t,{...Ae}]}const Ye={id:"session-dashboard",title:"Dashboard",kind:"session-dashboard"};function Nn(t){return t.some(o=>o.id===Ye.id)?t:[...t,{...Ye}]}const Bo=ze(()=>Oe(()=>import("./TerminalPane-CPOiBcye.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url),{ssr:!1}),qo=ze(()=>Oe(()=>import("./FileTree-C6gg9p4m.js"),__vite__mapDeps([11,1,2,12,13,6]),import.meta.url),{ssr:!1}),Ho=ze(()=>Oe(()=>import("./FilePreview-BjbfWw2s.js").then(t=>t.b),__vite__mapDeps([14,1,2,5,15,13,6,16]),import.meta.url),{ssr:!1}),Vo=ze(()=>Oe(()=>import("./AiHubPane-Cp_tNJNR.js"),__vite__mapDeps([17,1,2,13,18]),import.meta.url),{ssr:!1}),Ko=ze(()=>Oe(()=>import("./FlowStudioPane-CCuxZBVJ.js"),__vite__mapDeps([19,1,2,20,4,5,6,3,7,8,9]),import.meta.url),{ssr:!1,loading:()=>e.jsx(Ge,{})});function Yo(){return e.jsx(Ro,{children:(t,o)=>e.jsx(Xo,{auth:t,onWorkspaceReady:o})})}const ie={id:"webapp-agent",title:"智能助手",kind:"webapp"},Rn={id:"ai-hub",title:"AI Hub",kind:"aihub"},Ln={id:"flow-studio",title:"Flow Studio",kind:"flowstudio"};function Go(){var t;return typeof document>"u"?Lr:ut((t=document.getElementById("web-theme-root"))==null?void 0:t.dataset.webTheme).id}const Jo="agent-web-shell:skin:v1";function Xo({auth:t,onWorkspaceReady:o}){var Ft,$t,Ut,Bt;const[a,s]=n.useState(null),[c,u]=n.useState(0),d=n.useCallback(r=>{if((r==null?void 0:r.openMode)==="new-tab"){window.open(r.url,"_blank","noopener,noreferrer");return}s(r)},[]),p=n.useCallback(r=>s((r==null?void 0:r.openMode)==="current"?r:null),[]),k=n.useRef(null),j=n.useRef(null),R=n.useRef(null),l=n.useRef(null),v=n.useRef(null),S=n.useRef(!1),[P,m]=n.useState({}),g=n.useRef(new Map),[h,w]=n.useState(0),[T,N]=n.useState(!1),[D,_]=n.useState(!1),ee=n.useRef(()=>{}),re=n.useCallback(r=>{var f;const i=So(r);if(!(!i||i.type!==wt.watcherFrame)){ee.current(i.channelId,i.sequence);for(const y of[k,j]){if(!((f=y.current)!=null&&f.contentWindow))continue;const E=i.payload.slice().buffer;y.current.contentWindow.postMessage({type:Cr,channelId:i.channelId,sequence:i.sequence,data:E},window.location.origin,[E])}}},[]),{state:H,epoch:te,rpc:I,onEvent:C,onTerminalData:O,onTerminalReset:U,sendTerminalInput:B}=To(re,t.getWsNonce,t.refresh),z=n.useMemo(()=>({request:(r,i,f)=>I(r,i,f),subscribe:(r,i)=>C("fs:event",i)}),[C,I]);ee.current=(r,i)=>{I("browser:frame-ack",{channelId:r,sequence:i}).catch(()=>{})};const[x,W]=n.useState([{...ie}]),K=n.useRef(x);K.current=x;const[A,L]=n.useState(ie.id),[se,b]=n.useState({}),M=n.useRef(!1),[V,q]=n.useState(!1),[G,X]=n.useState(0),ce=`agentroam:workspace:${typeof window>"u"?"":Me()}:${((Ft=t.user)==null?void 0:Ft.id)??""}`,Se=n.useRef(null),le=n.useRef(new Map),_e=n.useRef(new Map),$n=n.useCallback((r,i)=>{le.current.set(r,i);const f=window.setTimeout(()=>{if(le.current.get(r)!==i)return;const y=_e.current.get(r);y&&(_e.current.delete(r),i(y,!0))},180);return()=>{window.clearTimeout(f),le.current.get(r)===i&&le.current.delete(r)}},[]),Un=n.useCallback(r=>{var f;if(!A||(f=x.find(y=>y.id===A))!=null&&f.kind)return;const i=le.current.get(A);i?i(r):I("term:input",{id:A,data:`${r}`}).catch(()=>{}),ue(!1)},[A,I,x]),[ye,Bn]=n.useState(!1),[Ce,Je]=n.useState({}),[pe,We]=n.useState(null),[de,ue]=n.useState(!1),[be,Fe]=n.useState("files"),[Te,jt]=n.useState(null),[Ne,Et]=n.useState(!0),[qn,Hn]=n.useState(null),[Xe,St]=n.useState(!1),[Qe,Ct]=n.useState([]),[Ze,Tt]=n.useState(ko()),[me,et]=n.useState(Go),[Re,Nt]=n.useState(lt),[Rt,Vn]=n.useState(!1);n.useEffect(()=>{const r=()=>{try{Nt(Do(window.localStorage))}catch{}Vn(!0)},i=f=>{(f.key===Ke||f.key===null)&&r()};return r(),window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]);const Lt=n.useCallback(r=>{Nt(r);try{Mo(window.localStorage,r)}catch{}},[]),[Pt,Kn]=n.useState(!1),$e=yo(t.csrfToken),[It,Yn]=n.useState(!1),ne=ut(me),ve=n.useRef(null),[Gn,tt]=n.useState(0),[Jn,nt]=n.useState(!1),rt=n.useRef(null),At=n.useRef(null),Dt=n.useCallback(r=>{var f;const i=[k.current,j.current,R.current,l.current,...g.current.values()];for(const y of i)(f=y==null?void 0:y.contentWindow)==null||f.postMessage({type:Jo,skin:r},window.location.origin)},[]),oe=n.useCallback(()=>{var i;if(Dt(me),!Rt)return;const r=[k.current,j.current,R.current,l.current,...g.current.values()];for(const f of r)(i=f==null?void 0:f.contentWindow)==null||i.postMessage({type:Tr,navigationLayout:Re},window.location.origin)},[me,Re,Rt,Dt]);n.useEffect(()=>{oe()},[oe]),n.useEffect(()=>{const r=ne.cssVars["--ui-root-bg"],i=ne.cssVars["--ui-color-scheme"],f=document.getElementById("web-theme-root");for(const[E,$]of Object.entries(ne.cssVars))f==null||f.style.setProperty(E,$);f&&(f.dataset.webTheme=ne.id),document.documentElement.style.background=r,document.documentElement.style.colorScheme=i,document.body.style.background=r,document.body.style.colorScheme=i;let y=document.querySelector('meta[name="theme-color"]');y||(y=document.createElement("meta"),y.name="theme-color",document.head.append(y)),y.content=ne.cssVars["--ui-tabbar-bg"]},[ne]),n.useEffect(()=>{const r=i=>{var qt,Ht,Vt,Kt,Yt,Gt,Jt,Xt,Qt,Zt,en,tn,nn,rn,on,an,sn,cn;const f=((qt=R.current)==null?void 0:qt.contentWindow)??null,y=[(Ht=k.current)==null?void 0:Ht.contentWindow,f,(Vt=l.current)==null?void 0:Vt.contentWindow,...[...g.current.values()].map(F=>F.contentWindow)].find(F=>F&&F===i.source)??null,E=Yr(i,window.location.origin,y);if(E){if(s(null),E.kind==="dashboard")W(Nn),L(Ye.id);else if(E.kind==="groups")W(Tn),L(Ae.id);else if(E.kind==="group"){const F=`collaboration-${E.groupId}`,J={id:F,title:E.title,kind:"collaboration",groupId:E.groupId,discussionId:E.discussionId};W(ge=>ge.some(qe=>qe.id===F)?ge.map(qe=>qe.id===F?J:qe):[...ge,J]),L(F)}else S.current?(Yt=(Kt=k.current)==null?void 0:Kt.contentWindow)==null||Yt.postMessage({type:fn,intent:E},window.location.origin):v.current=E,L(ie.id);return}const $=Hr(i,window.location.origin,f);if($){W(F=>$.deleted?F.filter(J=>J.groupId!==$.groupId):F.map(J=>J.groupId===$.groupId?{...J,title:$.title}:J)),$.deleted?L(F=>F===`collaboration-${$.groupId}`?Ae.id:F):m(F=>({...F,[$.groupId]:(F[$.groupId]||0)+1}));return}const Y=Vr(i,window.location.origin,i.source===f?f:((Gt=k.current)==null?void 0:Gt.contentWindow)??null);if(Y){const F=`collaboration-${Y.groupId}`;W(J=>J.some(ge=>ge.id===F)?J:[...J,{id:F,title:Y.title,kind:"collaboration",groupId:Y.groupId}]),L(F);return}const Q=((Jt=j.current)==null?void 0:Jt.contentWindow)??null,Z=Jr(i,window.location.origin,Q);if(Z!==null){N(Z);return}if(En(i,window.location.origin,Q)){N(!1),w(F=>F+1),_(!1),oe();return}if(Q&&i.origin===window.location.origin&&i.source===Q&&((Xt=i.data)==null?void 0:Xt.type)===Xr){_(!0);return}if(i.origin===window.location.origin&&i.source===Q&&Q&&((Qt=i.data)==null?void 0:Qt.type)===Qr){N(!1),I("browser:unwatch").catch(()=>{}),W(F=>F.filter(J=>J.kind!=="remote-desktop")),w(0),_(!1),L(ie.id);return}if(Pr(i,window.location.origin,((Zt=k.current)==null?void 0:Zt.contentWindow)??null)){W(Cn),L(je.id);return}if(En(i,window.location.origin,((en=k.current)==null?void 0:en.contentWindow)??null)){S.current=!0,Yn(!0),oe(),o(),v.current&&((nn=(tn=k.current)==null?void 0:tn.contentWindow)==null||nn.postMessage({type:fn,intent:v.current},window.location.origin),v.current=null);return}const sr=(rn=[...g.current.values()].find(F=>F.contentWindow===i.source))==null?void 0:rn.contentWindow,Le=_r(i,window.location.origin,sr??((on=k.current)==null?void 0:on.contentWindow)??null);if(Le){const F=J=>{Fe("files"),ue(!mn(J)),We(J),mn(J)||Hn({...Le,path:J})};Le.path.startsWith("~/")?I("hello").then(({home:J})=>{const ge=Wr(Le.path,null,J);ge&&F(ge)}).catch(()=>{}):F(Le.path);return}const we=i.source===Q&&Q?Q:((an=k.current)==null?void 0:an.contentWindow)??null,ke=Ir(i,window.location.origin,we);if(ke){I(ke.method,{...ke.payload,...ke.method==="browser:watch"?{frameAck:!0}:{}}).then(F=>{we==null||we.postMessage({type:un,id:ke.id,ok:!0,result:F},window.location.origin)},F=>{we==null||we.postMessage({type:un,id:ke.id,ok:!1,error:F.message||"浏览器操作失败",code:F.code},window.location.origin)});return}jo(i,window.location.origin,[((sn=k.current)==null?void 0:sn.contentWindow)??null,f,((cn=l.current)==null?void 0:cn.contentWindow)??null,...[...g.current.values()].map(F=>F.contentWindow)],I)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[o,I,oe]),n.useEffect(()=>{const r=y=>{var E,$;for(const Y of[k,j])($=(E=Y.current)==null?void 0:E.contentWindow)==null||$.postMessage({type:it,event:y},window.location.origin)},f=["browser:session","browser:frame","browser:state","browser:closed","browser:webrtc"].map(y=>C(y,r));return()=>f.forEach(y=>y())},[C]),n.useEffect(()=>{var r,i;It&&((i=(r=k.current)==null?void 0:r.contentWindow)==null||i.postMessage({type:it,event:{type:"browser:connection",connected:H.connected,epoch:te}},window.location.origin))},[H.connected,te,It]),n.useEffect(()=>{var r,i;h&&((i=(r=j.current)==null?void 0:r.contentWindow)==null||i.postMessage({type:Gr,visible:A===je.id},window.location.origin))},[A,h]),n.useEffect(()=>{var r,i;h&&((i=(r=j.current)==null?void 0:r.contentWindow)==null||i.postMessage({type:it,event:{type:"browser:connection",connected:H.connected,epoch:te}},window.location.origin))},[H.connected,te,h]);const Mt=n.useRef(0),Ot=A?se[A]??null:null;n.useEffect(()=>{const r=window.visualViewport;let i=null,f="";const y=()=>{const E=Oo(r,{height:window.innerHeight,width:window.innerWidth}),$=`${E.width}x${E.height}+${E.top}+${E.left}`;$!==f&&(f=$,document.documentElement.style.setProperty("--vv-height",`${E.height}px`),document.documentElement.style.setProperty("--vv-width",`${E.width}px`),document.documentElement.style.setProperty("--vv-top",`${E.top}px`),document.documentElement.style.setProperty("--vv-left",`${E.left}px`),i&&window.clearTimeout(i),i=window.setTimeout(y,250))};return y(),r==null||r.addEventListener("resize",y),r==null||r.addEventListener("scroll",y),window.addEventListener("orientationchange",y),window.addEventListener("resize",y),document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),()=>{r==null||r.removeEventListener("resize",y),r==null||r.removeEventListener("scroll",y),window.removeEventListener("orientationchange",y),window.removeEventListener("resize",y),document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y),i&&window.clearTimeout(i),document.documentElement.style.removeProperty("--vv-height"),document.documentElement.style.removeProperty("--vv-width"),document.documentElement.style.removeProperty("--vv-top"),document.documentElement.style.removeProperty("--vv-left")}},[]),n.useEffect(()=>{fetch("/api/web-console/preferences",{credentials:"same-origin"}).then(r=>r.json()).then(r=>{var i,f,y,E;typeof((i=r.preferences)==null?void 0:i.keybarHidden)=="boolean"&&St(r.preferences.keybarHidden),Array.isArray((f=r.preferences)==null?void 0:f.keyOrder)&&Ct(r.preferences.keyOrder),Array.isArray((y=r.preferences)==null?void 0:y.pinnedCommands)&&Tt(r.preferences.pinnedCommands),(E=r.preferences)!=null&&E.theme&&et(ut(r.preferences.theme).id)}).catch(()=>{}).finally(()=>Kn(!0)),fetch("/api/web-console/device-state",{credentials:"same-origin"}).then(r=>r.json()).then(r=>{const i=r.deviceState;i!=null&&i.drawerTab&&Fe(i.drawerTab),i!=null&&i.activeTerminalId&&(Se.current=i.activeTerminalId),typeof(i==null?void 0:i.drawerOpen)=="boolean"&&ue(i.drawerOpen),i!=null&&i.fileTreeRoot&&jt(i.fileTreeRoot),typeof(i==null?void 0:i.fileTreeFollowMode)=="boolean"&&Et(i.fileTreeFollowMode),i!=null&&i.selectedFile&&We(i.selectedFile),i!=null&&i.terminalScroll&&typeof i.terminalScroll=="object"&&Je(i.terminalScroll)}).catch(()=>{}).finally(()=>Bn(!0))},[]);const zt=n.useCallback(r=>{fetch("/api/web-console/preferences",{method:"PATCH",credentials:"same-origin",headers:{"content-type":"application/json","x-csrf-token":t.csrfToken},body:JSON.stringify(r)}).catch(()=>{})},[t.csrfToken]);n.useEffect(()=>{if(!Pt)return;const r=setTimeout(()=>zt({keybarHidden:Xe,keyOrder:Qe,pinnedCommands:Ze,theme:me}),500);return()=>clearTimeout(r)},[Xe,Qe,Ze,me,Pt,zt]);const Ue=n.useCallback(r=>{t.csrfToken&&fetch("/api/web-console/device-state",{method:"PUT",credentials:"same-origin",keepalive:!0,headers:{"content-type":"application/json","x-csrf-token":t.csrfToken},body:JSON.stringify(r)}).catch(()=>{})},[t.csrfToken]);n.useEffect(()=>{if(!t.csrfToken||!V||!ye)return;const r=setTimeout(()=>Ue({activeTerminalId:A,drawerOpen:de,drawerTab:be,fileTreeRoot:Te,fileTreeFollowMode:Ne,selectedFile:pe,terminalScroll:Ce}),500);return()=>clearTimeout(r)},[A,de,be,Te,Ne,pe,Ce,t.csrfToken,Ue,V,ye]),n.useEffect(()=>{if(!t.csrfToken||!V||!ye)return;const r=()=>Ue({activeTerminalId:A,drawerOpen:de,drawerTab:be,fileTreeRoot:Te,fileTreeFollowMode:Ne,selectedFile:pe,terminalScroll:Ce});return window.addEventListener("pagehide",r),()=>window.removeEventListener("pagehide",r)},[A,de,be,Te,Ne,pe,Ce,t.csrfToken,Ue,V,ye]);const Xn=n.useCallback(r=>{We(r),ue(!1)},[]),Qn=n.useCallback(()=>{if(x.length>=8)return;const r=`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;W(i=>i.length>=8?i:[...i,{id:r,title:`Terminal ${i.length+1}`}]),L(r)},[x.length]),Zn=n.useCallback(r=>{const i=x.find(E=>E.id===A);if(i!=null&&i.kind&&i.kind!=="webapp")return;if(i&&!i.kind){const E=le.current.get(i.id);E?E(r,!0):_e.current.set(i.id,r),ue(!1);return}const f=x.length>=8?x.find(E=>!E.kind):null,y=(f==null?void 0:f.id)??`t-web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;f?_e.current.set(y,r):W(E=>[...E,{id:y,title:`Terminal ${E.length+1}`,initialCommand:r}]),L(y),ue(!1)},[A,x]);n.useEffect(()=>{if(!H.connected||!ye||M.current)return;M.current=!0;let r=!1,i=!1,f;return I("term:list").then(y=>{if(r)return;let E=null;try{E=Sn(localStorage.getItem(ce))}catch{}const $=Uo(E,y.tabs,K.current);W($),L(Y=>{const Q=K.current.find(he=>he.id===Y&&he.kind&&he.kind!=="webapp");if(Q)return Q.id;const Z=(E==null?void 0:E.activeTerminalId)||Se.current||Y||ie.id;return Z===ie.id?ie.id:$.some(he=>he.id===Z)?Z:ie.id}),i=!0,q(!0)}).catch(()=>{r||(M.current=!1,f=setTimeout(()=>X(y=>y+1),2e3))}),()=>{r=!0,clearTimeout(f),i||(M.current=!1)}},[H.connected,ye,I,ce,G]),n.useLayoutEffect(()=>{if(V)try{const r=Sn(JSON.stringify({tabs:x,activeTerminalId:A}));localStorage.setItem(ce,JSON.stringify(r))}catch{}},[x,A,V,ce]);const er=r=>{var f;if(r===ie.id)return;const i=(f=x.find(y=>y.id===r))==null?void 0:f.kind;i==="remote-desktop"&&(w(0),_(!1),I("browser:unwatch").catch(()=>{})),!(!i&&!window.confirm("关闭页签会终止该终端进程,确认关闭?"))&&(W(y=>{var $;const E=y.filter(Y=>Y.id!==r);return A===r&&L((($=E[0])==null?void 0:$.id)??null),E}),i||I("term:kill",{id:r}).catch(()=>{}))},tr=n.useCallback(()=>{W(r=>{const i=r.find(f=>f.kind==="aihub");return i?(L(i.id),r):(L(Rn.id),[...r,{...Rn}])})},[]),nr=n.useCallback(()=>{W(r=>{const i=r.find(f=>f.kind==="flowstudio");return i?(L(i.id),r):(L(Ln.id),[...r,{...Ln}])})},[]),rr=n.useCallback(()=>{W(Cn),L(je.id)},[]);n.useEffect(()=>{const r=C("term:exited",i=>{const f=i==null?void 0:i.id;f&&(W(y=>{const E=y.filter($=>$.id!==f);return L($=>{var Y;return $===f?((Y=E[0])==null?void 0:Y.id)??null:$}),E}),Je(y=>{if(!(f in y))return y;const E={...y};return delete E[f],E}))});return()=>{r()}},[C]);const _t=n.useCallback(r=>{if(!A||x.length<2)return;const f=(x.findIndex(y=>y.id===A)+r+x.length)%x.length;L(x[f].id)},[A,x]),Wt=Math.max(0,x.findIndex(r=>r.id===A)),or=(($t=x[Wt])==null?void 0:$t.kind)==="webapp"?ne.cssVars["--ui-term-col-bg"]:ne.termHostBg,ir={...ae.root,...ne.cssVars,"--ui-active-content-bg":or,"--ui-terminal-bg":ne.termHostBg,"--ui-primary-text":ne.keybar.accentText,background:"var(--ui-root-bg)",color:"var(--ui-text)"},fe=n.useCallback(()=>{ve.current=null,tt(0),nt(!1)},[]),ot=n.useCallback(r=>{Math.abs(r)>=64&&x.length>1&&_t(r<0?1:-1),fe()},[x.length,_t,fe]),ar=r=>r instanceof Element&&!!r.closest(".terminal-screen");n.useEffect(()=>{const r=i=>{var y;if(A!==ie.id)return;const f=Fo(i,window.location.origin,((y=k.current)==null?void 0:y.contentWindow)??null);f&&(f.phase==="move"?(nt(!0),tt(f.deltaX)):f.phase==="end"?ot(f.deltaX):fe())};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[A,ot,fe]);const Be=n.useCallback((r="smooth")=>{const i=At.current;if(!i||!A)return;const f=i.querySelector(`[data-terminal-id="${A}"]`);if(!f)return;if(f===i.querySelector("[data-terminal-id]")){zo(i);return}const y=i.querySelector(".terminal-connection"),E=(y==null?void 0:y.offsetWidth)??0,$=8,Y=f.offsetLeft,Q=Y+f.offsetWidth,Z=i.scrollLeft,he=Z+i.clientWidth-E;Y<Z+$?i.scrollTo({left:Math.max(0,Y-$),behavior:r}):Q>he-$&&i.scrollTo({left:Q-i.clientWidth+E+$,behavior:r})},[A]);return n.useLayoutEffect(()=>{if(!A)return;const r=x.length>Mt.current;Mt.current=x.length,Be(r?"auto":"smooth")},[A,x.length,Be]),n.useEffect(()=>{const r=()=>requestAnimationFrame(()=>Be("auto"));return window.addEventListener("pageshow",r),()=>window.removeEventListener("pageshow",r)},[Be]),e.jsxs("div",{className:`web-root ${T&&A===je.id&&!a?"is-remote-fullscreen":""}`,style:ir,children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Nr}}),e.jsxs("div",{className:"terminal-tabs",children:[a&&e.jsxs("div",{className:"computer-page-heading",children:[e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"返回电脑会话",title:"返回电脑会话",onClick:()=>s(null),children:e.jsx($r,{size:18})}),e.jsx("span",{children:a.name}),e.jsx("a",{className:"file-drawer-toggle",href:a.url,target:"_blank",rel:"noopener noreferrer","aria-label":"在新页面打开当前页面",title:"打开原页面",children:e.jsx(kt,{size:16})})]}),e.jsx("div",{className:"terminal-tab-list",ref:At,hidden:!!a,children:x.map(r=>e.jsxs("div",{"data-terminal-id":r.id,draggable:!0,className:`terminal-tab ${r.id===A?"active":""}`,onDragStart:()=>{rt.current=r.id},onDragOver:i=>i.preventDefault(),onDrop:i=>{i.preventDefault();const f=rt.current;rt.current=null,!(!f||f===r.id)&&W(y=>{const E=y.findIndex(Z=>Z.id===f),$=y.findIndex(Z=>Z.id===r.id);if(E<0||$<0)return y;const Y=[...y],[Q]=Y.splice(E,1);return Y.splice($,0,Q),I("term:reorder",{ids:Y.filter(Z=>!Z.kind).map(Z=>Z.id)}).catch(()=>{}),Y})},onClick:()=>L(r.id),onDoubleClick:()=>{var f;if(r.kind)return;const i=(f=window.prompt("页签名称",r.title))==null?void 0:f.trim();i&&I("term:rename",{id:r.id,title:i}).then(()=>W(y=>y.map(E=>E.id===r.id?{...E,title:i}:E))).catch(()=>{})},children:[e.jsx("span",{children:r.title}),r.kind!=="webapp"&&e.jsx("button",{tabIndex:-1,onClick:i=>{i.stopPropagation(),er(r.id)},children:"×"})]},r.id))}),e.jsx("button",{className:"terminal-add","aria-label":"新建终端页签",hidden:!!a,disabled:x.length>=8,onClick:Qn,children:"+"}),e.jsx("div",{className:"terminal-connection",children:e.jsx(Rr,{glass:me==="glass",compact:Re!=="classic",avatar:e.jsx(mo,{username:((Ut=t.user)==null?void 0:Ut.username)??"?",connected:H.connected,accent:ne.keybar.accent,accentText:ne.keybar.accentText,selectedPageId:a==null?void 0:a.id,onSelectPage:d,onUpdatePage:p,configuration:$e,csrfToken:t.csrfToken}),items:[{id:"refresh",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"刷新页面",title:"刷新页面",onClick:()=>a?u(r=>r+1):window.location.reload(),children:e.jsx(xe,{size:17,"aria-hidden":"true"})})},{id:"dashboard",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开会话 Dashboard",title:"Dashboard · 会话总览",onClick:()=>{s(null),W(Nn),L(Ye.id)},children:e.jsx(On,{size:17,"aria-hidden":"true"})})},{id:"collaboration",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开群聊列表",title:"群聊列表",onClick:()=>{s(null),W(Tn),L(Ae.id)},children:e.jsx(xt,{size:17,"aria-hidden":"true"})})},{id:"install",content:e.jsx(no,{})},{id:"remote",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开远程桌面",title:"远程桌面 · 浏览器直播",onClick:()=>{s(null),rr()},children:e.jsx(ct,{size:17,"aria-hidden":"true"})})},{id:"ai-hub",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开 AI Hub",title:"AI Hub · 多模型对比",onClick:()=>{s(null),tr()},children:e.jsx(Dn,{size:17,"aria-hidden":"true"})})},{id:"flow",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":"打开数字人",title:"数字人 · Flow Studio",onClick:()=>{s(null),nr()},children:e.jsx(yt,{size:17,"aria-hidden":"true"})})},{id:"theme",content:e.jsxs("div",{className:"web-appearance-controls",children:[e.jsx(vn,{themeId:me,onThemeChange:et}),e.jsx(kn,{value:Re,onChange:Lt})]}),compactItems:[{id:"theme",content:e.jsx(vn,{themeId:me,onThemeChange:et})},{id:"navigation-layout",content:e.jsx(kn,{value:Re,onChange:Lt})}]},{id:"files",content:e.jsx("button",{type:"button",className:"file-drawer-toggle","aria-label":de?"关闭我的文件":"打开我的文件",title:"我的文件","aria-expanded":de,onClick:()=>{s(null),ue(r=>!r)},children:e.jsx(Ur,{size:17,"aria-hidden":"true"})})}].filter(r=>$e.settings.visibleTools.some(i=>i===r.id)).sort((r,i)=>$e.settings.visibleTools.findIndex(f=>f===r.id)-$e.settings.visibleTools.findIndex(f=>f===i.id))})})]}),e.jsxs("main",{className:`workspace ${de?"show-tree":""} ${pe?"has-preview":""}`,hidden:!!a,style:ae.workspace,children:[e.jsx("section",{className:"term-col",style:ae.termCol,onPointerDownCapture:r=>{r.pointerType!=="touch"||!ar(r.target)||(fe(),ve.current={x:r.clientX,y:r.clientY,axis:"pending",pointerId:r.pointerId})},onPointerMoveCapture:r=>{const i=ve.current;if(!i||r.pointerId!==i.pointerId||r.pointerType!=="touch")return;const f=r.clientX-i.x,y=r.clientY-i.y;if(i.axis==="pending"){if(Math.max(Math.abs(f),Math.abs(y))<=8)return;if(Math.abs(y)>=Math.abs(f)*1.2){ve.current=null;return}i.axis="horizontal",nt(!0);const E=$=>{window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E),ve.current===i&&fe()};window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E)}i.axis==="horizontal"&&(r.preventDefault(),tt(f))},onPointerUpCapture:r=>{const i=ve.current;if(!i||r.pointerId!==i.pointerId)return;const f=r.clientX-i.x;i.axis==="horizontal"&&Math.abs(f)>=64?ot(f):fe()},onPointerCancelCapture:fe,children:e.jsx("div",{className:"terminal-track",style:{transform:`translate3d(calc(${-Wt*100}% + ${Gn}px),0,0)`,transition:Jn?"none":"transform 260ms cubic-bezier(.22,.8,.32,1)"},children:x.map(r=>e.jsx("div",{className:"terminal-slide",style:{position:"relative"},children:r.kind==="webapp"?e.jsx("iframe",{ref:k,className:"webapp-frame",src:dt("/app/"),title:r.title,onLoad:oe}):r.kind==="session-dashboard"?e.jsx(st,{view:"sessions",title:"会话 Dashboard",onFrame:i=>{l.current=i},onLoad:oe}):r.kind==="collaboration-dashboard"?e.jsx(st,{title:"群聊列表",onFrame:i=>{R.current=i},onLoad:oe}):r.kind==="collaboration"?e.jsx(st,{groupId:r.groupId||"",discussionId:r.discussionId,title:r.title,onFrame:i=>{i?g.current.set(r.id,i):g.current.delete(r.id)},onLoad:oe},`${r.id}-${r.discussionId??""}-${P[r.groupId||""]||0}`):r.kind==="remote-desktop"?e.jsxs("div",{style:{height:"100%",background:"var(--ui-term-col-bg, #101014)"},"aria-busy":!D,children:[e.jsx("iframe",{ref:j,className:"webapp-frame",style:{visibility:D?"visible":"hidden"},src:dt("/app/?view=remote-desktop"),title:"远程桌面",onLoad:oe}),!D&&e.jsx(Ge,{label:"REMOTE DESKTOP",title:"正在打开远程桌面",caption:"正在准备桌面与连接",icon:e.jsx(ct,{size:36,strokeWidth:1.5})})]}):r.kind==="aihub"?e.jsx(Vo,{visible:r.id===A,rpc:I}):r.kind==="flowstudio"?e.jsx(Ko,{visible:r.id===A}):e.jsx(Bo,{terminalId:r.id,title:r.title,initialCommand:r.initialCommand,visible:r.id===A,state:H,rpc:I,onEvent:C,onTerminalData:O,onTerminalReset:U,sendTerminalInput:B,keyOrder:Qe,keybarHidden:Xe,onKeyOrderChange:Ct,onKeybarHiddenChange:St,terminalTheme:ne,initialScrollLine:Ce[r.id]??null,onScrollLineChange:i=>Je(f=>f[r.id]===i?f:{...f,[r.id]:i}),onRegisterFill:i=>$n(r.id,i),onCwdChange:i=>i&&b(f=>({...f,[r.id]:i}))})},r.id))})}),de&&e.jsx("div",{className:"drawer-mask",onClick:()=>ue(!1)}),e.jsxs("aside",{className:`tree-col ${de?"tree-col-open":""}`,style:ae.treeCol,children:[e.jsxs("div",{className:"tree-head",style:ae.treeHead,children:[e.jsx("button",{className:be==="files"?"drawer-tab-active":"",onClick:()=>Fe("files"),children:"文件"}),e.jsx("button",{className:be==="history"?"drawer-tab-active":"",onClick:()=>Fe("history"),children:"历史"}),e.jsx("span",{className:"tree-cwd",style:ae.treeCwd,children:Ot??""}),e.jsx("button",{style:{...ae.iconBtn,marginLeft:"auto",flexShrink:0},onClick:()=>ue(!1),"aria-label":"close drawer",children:e.jsx(Ee,{size:15,"aria-hidden":"true"})})]}),be==="files"?e.jsx(qo,{ready:te>0,followCwd:!0,cwd:Ot,gateway:z,onOpenFile:Xn,selectedPath:pe,initialRoot:Te,initialFollow:Ne,revealRequest:qn,onTreeStateChange:(r,i)=>{jt(r),Et(i)}}):e.jsx(Io,{csrfToken:t.csrfToken,terminalId:((Bt=x.find(r=>r.id===A))==null?void 0:Bt.kind)==="webapp"?null:A,pinnedCommands:Ze,onPinnedCommandsChange:Tt,onFill:Un,onExecute:Zn}),e.jsxs("div",{className:"tree-foot",style:ae.treeFoot,children:[e.jsx("span",{style:ae.treeFootDot}),e.jsx("span",{children:"实时同步"})]})]}),pe&&e.jsx("section",{className:"preview-col",style:ae.previewCol,children:e.jsx(Ho,{path:pe,gateway:z,onClose:()=>We(null)})})]}),a&&e.jsx(bo,{page:a,reloadKey:c},a.id)]})}const ae={root:{height:"100dvh",display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif',overflow:"hidden"},iconBtn:{minWidth:28,height:28,borderRadius:7,border:"1px solid var(--ui-tabbar-border, #303442)",background:"var(--ui-tab-bg, #202029)",color:"var(--ui-tab-text, #aaaab8)",fontSize:13},workspace:{flex:1,minHeight:0,display:"grid",position:"relative"},treeCol:{background:"var(--ui-tree-bg, #121218)",minHeight:0,flexDirection:"column"},treeHead:{display:"flex",alignItems:"center",gap:8,padding:"10px 12px 4px",fontSize:11,textTransform:"uppercase",letterSpacing:1,color:"#778",flexShrink:0},treeCwd:{fontSize:10,color:"#556",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:150,textTransform:"none",letterSpacing:0},treeFoot:{display:"flex",alignItems:"center",gap:7,minHeight:31,padding:"6px 11px calc(env(safe-area-inset-bottom) + 6px)",borderTop:"1px solid var(--ui-tabbar-border, #282832)",boxShadow:"0 -5px 16px rgba(0,0,0,.22)",background:"var(--ui-tab-bg, #15151c)",color:"var(--ui-connection-text, #777789)",fontSize:10.5,flexShrink:0},treeFootDot:{width:6,height:6,borderRadius:99,background:"var(--ui-success, #9ece6a)",boxShadow:"0 0 0 2px color-mix(in srgb, var(--ui-success, #9ece6a) 12%, transparent)",flexShrink:0},termCol:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:"var(--ui-term-col-bg, #101014)",gridColumn:1,overflow:"hidden"},previewCol:{minWidth:0,minHeight:0}},ai=Object.freeze(Object.defineProperty({__proto__:null,default:Yo},Symbol.toStringTag,{value:"Module"}));export{Ge as F,ai as p,zo as r};
|