agentroam-runtime-darwin-arm64 0.2.0-preview.21 → 0.2.0-preview.22
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 +6 -6
- 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/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 +2 -2
- 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/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/remote-tools/register/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]/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]/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]/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/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/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 +2 -2
- package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app/web.html +1 -1
- package/runtime/.next/server/app/web.rsc +3 -3
- package/runtime/.next/server/app-paths-manifest.json +19 -19
- package/runtime/.next/server/chunks/1322.js +1 -1
- package/runtime/.next/server/chunks/2083.js +1 -1
- package/runtime/.next/server/chunks/5303.js +1 -1
- 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/pages-manifest.json +1 -1
- package/runtime/.next/server/server-reference-manifest.json +1 -1
- package/runtime/.next/static/chunks/app/web/{error-9b5f82c29dc27335.js → error-828d278147a0619d.js} +1 -1
- package/runtime/.next/static/chunks/app/web/{page-16895961b998f8df.js → page-93b87fd495171494.js} +1 -1
- package/runtime/.next/static/chunks/{main-app-e3fd18ce9c4c0d03.js → main-app-07d67f2d4e96ecb8.js} +1 -1
- package/runtime/lib/remote-control/remote-authorization.mjs +65 -12
- package/runtime/lib/remote-control/webrtc-video.mjs +12 -3
- package/runtime/native/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
- package/runtime/node_modules/.package-lock.json +84 -84
- package/runtime/node_modules/@agent/core/dist/domain/browser-live/BrowserLiveRegistry.d.ts +43 -0
- package/runtime/node_modules/@agent/core/dist/domain/browser-live/BrowserLiveRegistry.test.d.ts +2 -0
- package/runtime/node_modules/@agent/core/dist/domain/browser-live/entities.d.ts +57 -0
- package/runtime/node_modules/@agent/core/dist/domain/live-view/live-view-registry.d.ts.map +1 -1
- package/runtime/node_modules/@agent/core/dist/index.js +4 -2
- package/runtime/node_modules/@agent/core/dist/index.js.map +3 -3
- package/runtime/package-lock.json +213 -189
- package/runtime/webapp/dist/assets/App-C0GaUX7E.js +381 -0
- package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-BNxk5qEZ.js → abnfDiagram-VCTEODGH-DFIVS5-b.js} +1 -1
- package/runtime/webapp/dist/assets/{arc-7MQbjMvc.js → arc-BR_jY5YA.js} +1 -1
- package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-Dhg4Rz1D.js → architectureDiagram-5GKGNRK7-B_RjH8A7.js} +1 -1
- package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-DeJHr92S.js → blockDiagram-I7D4REHJ-BS7yaS6P.js} +1 -1
- package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-RA8xRbEK.js → c4Diagram-7LVT6UL2-CSFzzphk.js} +1 -1
- package/runtime/webapp/dist/assets/channel-D_GjJ9-f.js +1 -0
- package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-CzoEDy2v.js → chunk-2Q5K7J3B-lxf-31fr.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-IasmnKPT.js → chunk-5VM5RSS4-CealgGAH.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-F27PBJKO-ClQmWB2a.js → chunk-F27PBJKO-BVUWtnPQ.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-BeWBx5Wn.js → chunk-IMKFNOWR-C9CDXZmG.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-TcEEZ4Dp.js → chunk-JWPE2WC7-CBIKc-82.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-DuWXzzSb.js → chunk-POPQ4Y6H-H46jF2zC.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-SVP7TREG-D2X9Pa1W.js → chunk-SVP7TREG-BWLkgj_W.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-TICWLB2K-D_-XYQ_R.js → chunk-TICWLB2K-D4lbsBHo.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-B2mHmyk9.js → chunk-XXDRQBXY-DixiVi8X.js} +1 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BbKxNRrL.js +1 -0
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BbKxNRrL.js +1 -0
- package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-OmMALi3i.js → cose-bilkent-JH36ORCC-DApgY-7v.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-BVhxjnGZ.js → cynefin-OW5HDTMX-wPkyEnRo.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-8EafeZWa.js → cynefinDiagram-5FMLGOSQ-BL3nX8zr.js} +1 -1
- package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-BlMjveyN.js → dagre-GXQ25YYZ-C-ST5Gq6.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-BTgDeYAz.js → diagram-S7CK7UJ4-1Uf0VNoU.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-9m-QUpEs.js → diagram-UQ7AKVKN-BqQU5Gdv.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-BYWenf8W.js → diagram-VSXAHHWV-C59hTOGw.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VX7I27RA-DQ-PRQyX.js → diagram-VX7I27RA-9Q55OM5Y.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-BFCpyvaL.js → diagram-Z3DM3KII-CynlxwLb.js} +1 -1
- package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-Ds9oV_wz.js → ebnfDiagram-PWID7BFC-Clg7fTnt.js} +1 -1
- package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-ncaaStop.js → erDiagram-RLTQ6QDP-BRtMTjkq.js} +1 -1
- package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-wL7U3M2L.js → flowDiagram-HODETNUW-1NtZ9wGO.js} +1 -1
- package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-CVZIk8qz.js → ganttDiagram-EL5Y4UJY-BqtMVkoY.js} +1 -1
- package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-CGjtUEFY.js → gitGraphDiagram-WWUBYQGX-D-ugp1Bz.js} +1 -1
- package/runtime/webapp/dist/assets/{index-CixxJ3A7.js → index-Cg-anTNr.js} +29 -29
- package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-BqTzY6Bv.js → infoDiagram-27XIBGKW-BbmiUqFV.js} +1 -1
- package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-9AARy1zU.js → ishikawaDiagram-5VMMS53U-DvsCcWwa.js} +1 -1
- package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-D3w-levY.js → journeyDiagram-3NMN7TZE-yNHLBbVt.js} +1 -1
- package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-CNvdBbcg.js → kanban-definition-UXKFOSKX-C17XKWBo.js} +1 -1
- package/runtime/webapp/dist/assets/{layout-l0aDluv6.js → layout-Dhqc3tGq.js} +1 -1
- package/runtime/webapp/dist/assets/{linear-BlLgYv8s.js → linear-C2_mlhLl.js} +1 -1
- package/runtime/webapp/dist/assets/{mermaid.core-UNYsT27K.js → mermaid.core-CjC7QuvE.js} +5 -5
- package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-BiVsBQL9.js → mindmap-definition-YA3MSWOX-D7AKW2qI.js} +1 -1
- package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-kr19ZOFB.js → pegDiagram-XKGWAZYB-BAI26fj8.js} +1 -1
- package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-BKWCGLlM.js → pieDiagram-E7YTZNPT-C_4G2czx.js} +1 -1
- package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-B1oUT2Jo.js → quadrantDiagram-AXDQQJYC-BhOZnXFN.js} +1 -1
- package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-HSe2vXxQ.js → railroadDiagram-O6MQD6OU-760zGjdr.js} +1 -1
- package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-Cy8adj_C.js → requirementDiagram-BXWQKSXE-D0-agCrc.js} +1 -1
- package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-tnBEmP5l.js → sankeyDiagram-P5KCCOFB-CsHjbmcp.js} +1 -1
- package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-DvOTKmyz.js → sequenceDiagram-WJ2MYXX4-Ccp7FnLK.js} +1 -1
- package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-Da7A6hqr.js → sizeCapture-INFHLROL-DFCk9Vjd.js} +1 -1
- package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-BU17k_M-.js → stateDiagram-D77RDMKH-tFA-WlZT.js} +1 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-CA4qjX_b.js +1 -0
- package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-DZZPRxnW.js → swimlanes-42K2YHIH-Bh-owCha.js} +1 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-DrldJDwD.js +8 -0
- package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-26Xh93Et.js → timeline-definition-24CTP7MA-D5CQ3vgW.js} +1 -1
- package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-Q4-BkJH1.js → vennDiagram-4TSXK5OY-1m-k4Zip.js} +1 -1
- package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-DlUP-PlT.js → wardleyDiagram-VM6X3IG4-C5agAk3M.js} +1 -1
- package/runtime/webapp/dist/assets/{web-DWyw2SAG.js → web-CzXjoC1h.js} +1 -1
- package/runtime/webapp/dist/assets/{web-ueoOhAeL.js → web-DseRebF6.js} +1 -1
- package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-BQZRjKtR.js → xychartDiagram-S5SC5T6Z-EEKnPDSd.js} +1 -1
- package/runtime/webapp/dist/index.html +1 -1
- package/runtime/webapp/dist/assets/App-Cso_5v1O.js +0 -381
- package/runtime/webapp/dist/assets/channel-AsHr5ZE0.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BZj1pbnq.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BZj1pbnq.js +0 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-BROH63Ny.js +0 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-B4lr9wuD.js +0 -8
- /package/runtime/.next/static/{6OR2fRy79-A-DrqiN3FNa → aWNdihGfcWU3x-pPuMP1I}/_buildManifest.js +0 -0
- /package/runtime/.next/static/{6OR2fRy79-A-DrqiN3FNa → aWNdihGfcWU3x-pPuMP1I}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-CjC7QuvE.js","./index-Cg-anTNr.js","./index-DwNgokHq.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Uo=t=>{throw TypeError(t)};var Cc=(t,n,r)=>n.has(t)||Uo("Cannot "+r);var qo=(t,n,r)=>n.has(t)?Uo("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,r);var Vo=(t,n,r)=>(Cc(t,n,"access private method"),r);import{r as l,R as Rc,j as e,_ as Ac,b as Yt,d as Za,B as Mc,i as rr,O as Ko,u as Et,e as Ec,S as Tc,L as Nc}from"./index-Cg-anTNr.js";/**
|
|
3
|
+
* @license lucide-react v0.468.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const zc=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ja=(...t)=>t.filter((n,r,s)=>!!n&&n.trim()!==""&&s.indexOf(n)===r).join(" ").trim();/**
|
|
8
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/var Lc={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
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 _c=l.forwardRef(({color:t="currentColor",size:n=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:i="",children:a,iconNode:c,...d},u)=>l.createElement("svg",{ref:u,...Lc,width:n,height:n,stroke:t,strokeWidth:s?Number(r)*24/Number(n):r,className:Ja("lucide",i),...d},[...c.map(([h,g])=>l.createElement(h,g)),...Array.isArray(a)?a:[a]]));/**
|
|
18
|
+
* @license lucide-react v0.468.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const oe=(t,n)=>{const r=l.forwardRef(({className:s,...i},a)=>l.createElement(_c,{ref:a,iconNode:n,className:Ja(`lucide-${zc(t)}`,s),...i}));return r.displayName=`${t}`,r};/**
|
|
23
|
+
* @license lucide-react v0.468.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const Go=oe("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
|
|
28
|
+
* @license lucide-react v0.468.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Pc=oe("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
33
|
+
* @license lucide-react v0.468.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const Wc=oe("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
|
|
38
|
+
* @license lucide-react v0.468.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const Yi=oe("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
43
|
+
* @license lucide-react v0.468.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const Ur=oe("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
48
|
+
* @license lucide-react v0.468.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const Dc=oe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
53
|
+
* @license lucide-react v0.468.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const Vr=oe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
58
|
+
* @license lucide-react v0.468.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const el=oe("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
63
|
+
* @license lucide-react v0.468.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Bc=oe("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
68
|
+
* @license lucide-react v0.468.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const gi=oe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
73
|
+
* @license lucide-react v0.468.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const $c=oe("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/**
|
|
78
|
+
* @license lucide-react v0.468.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const Oc=oe("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
|
83
|
+
* @license lucide-react v0.468.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const tl=oe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
88
|
+
* @license lucide-react v0.468.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const Fc=oe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
|
93
|
+
* @license lucide-react v0.468.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const Hc=oe("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/**
|
|
98
|
+
* @license lucide-react v0.468.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const Uc=oe("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/**
|
|
103
|
+
* @license lucide-react v0.468.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const qc=oe("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
|
|
108
|
+
* @license lucide-react v0.468.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const Vc=oe("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/**
|
|
113
|
+
* @license lucide-react v0.468.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const Kc=oe("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
|
|
118
|
+
* @license lucide-react v0.468.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const Gc=oe("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/**
|
|
123
|
+
* @license lucide-react v0.468.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const Vs=oe("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
128
|
+
* @license lucide-react v0.468.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const Qc=oe("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/**
|
|
133
|
+
* @license lucide-react v0.468.0 - ISC
|
|
134
|
+
*
|
|
135
|
+
* This source code is licensed under the ISC license.
|
|
136
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
+
*/const Yc=oe("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
138
|
+
* @license lucide-react v0.468.0 - ISC
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the ISC license.
|
|
141
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/const Xc=oe("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
143
|
+
* @license lucide-react v0.468.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const Qo=oe("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
|
|
148
|
+
* @license lucide-react v0.468.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const Zc=oe("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
|
|
153
|
+
* @license lucide-react v0.468.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const Jc=oe("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
|
158
|
+
* @license lucide-react v0.468.0 - ISC
|
|
159
|
+
*
|
|
160
|
+
* This source code is licensed under the ISC license.
|
|
161
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
+
*/const xi=oe("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
|
|
163
|
+
* @license lucide-react v0.468.0 - ISC
|
|
164
|
+
*
|
|
165
|
+
* This source code is licensed under the ISC license.
|
|
166
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
+
*/const ed=oe("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
168
|
+
* @license lucide-react v0.468.0 - ISC
|
|
169
|
+
*
|
|
170
|
+
* This source code is licensed under the ISC license.
|
|
171
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
+
*/const td=oe("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
|
|
173
|
+
* @license lucide-react v0.468.0 - ISC
|
|
174
|
+
*
|
|
175
|
+
* This source code is licensed under the ISC license.
|
|
176
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
+
*/const nd=oe("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
178
|
+
* @license lucide-react v0.468.0 - ISC
|
|
179
|
+
*
|
|
180
|
+
* This source code is licensed under the ISC license.
|
|
181
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
+
*/const Dt=oe("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
183
|
+
* @license lucide-react v0.468.0 - ISC
|
|
184
|
+
*
|
|
185
|
+
* This source code is licensed under the ISC license.
|
|
186
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
+
*/const rd=oe("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
|
|
188
|
+
* @license lucide-react v0.468.0 - ISC
|
|
189
|
+
*
|
|
190
|
+
* This source code is licensed under the ISC license.
|
|
191
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
+
*/const sd=oe("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
193
|
+
* @license lucide-react v0.468.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/const id=oe("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
|
|
198
|
+
* @license lucide-react v0.468.0 - ISC
|
|
199
|
+
*
|
|
200
|
+
* This source code is licensed under the ISC license.
|
|
201
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
+
*/const od=oe("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
203
|
+
* @license lucide-react v0.468.0 - ISC
|
|
204
|
+
*
|
|
205
|
+
* This source code is licensed under the ISC license.
|
|
206
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
207
|
+
*/const ad=oe("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/**
|
|
208
|
+
* @license lucide-react v0.468.0 - ISC
|
|
209
|
+
*
|
|
210
|
+
* This source code is licensed under the ISC license.
|
|
211
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
212
|
+
*/const Yo=oe("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/**
|
|
213
|
+
* @license lucide-react v0.468.0 - ISC
|
|
214
|
+
*
|
|
215
|
+
* This source code is licensed under the ISC license.
|
|
216
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
217
|
+
*/const ld=oe("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
218
|
+
* @license lucide-react v0.468.0 - ISC
|
|
219
|
+
*
|
|
220
|
+
* This source code is licensed under the ISC license.
|
|
221
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
222
|
+
*/const cd=oe("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
|
|
223
|
+
* @license lucide-react v0.468.0 - ISC
|
|
224
|
+
*
|
|
225
|
+
* This source code is licensed under the ISC license.
|
|
226
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
227
|
+
*/const dd=oe("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/**
|
|
228
|
+
* @license lucide-react v0.468.0 - ISC
|
|
229
|
+
*
|
|
230
|
+
* This source code is licensed under the ISC license.
|
|
231
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
232
|
+
*/const ud=oe("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
|
|
233
|
+
* @license lucide-react v0.468.0 - ISC
|
|
234
|
+
*
|
|
235
|
+
* This source code is licensed under the ISC license.
|
|
236
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
237
|
+
*/const pd=oe("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
|
|
238
|
+
* @license lucide-react v0.468.0 - ISC
|
|
239
|
+
*
|
|
240
|
+
* This source code is licensed under the ISC license.
|
|
241
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
242
|
+
*/const nl=oe("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
243
|
+
* @license lucide-react v0.468.0 - ISC
|
|
244
|
+
*
|
|
245
|
+
* This source code is licensed under the ISC license.
|
|
246
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
247
|
+
*/const fd=oe("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/**
|
|
248
|
+
* @license lucide-react v0.468.0 - ISC
|
|
249
|
+
*
|
|
250
|
+
* This source code is licensed under the ISC license.
|
|
251
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
252
|
+
*/const Fi=oe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
253
|
+
* @license lucide-react v0.468.0 - ISC
|
|
254
|
+
*
|
|
255
|
+
* This source code is licensed under the ISC license.
|
|
256
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
257
|
+
*/const hd=oe("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/**
|
|
258
|
+
* @license lucide-react v0.468.0 - ISC
|
|
259
|
+
*
|
|
260
|
+
* This source code is licensed under the ISC license.
|
|
261
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
262
|
+
*/const Xi=oe("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
|
263
|
+
* @license lucide-react v0.468.0 - ISC
|
|
264
|
+
*
|
|
265
|
+
* This source code is licensed under the ISC license.
|
|
266
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
267
|
+
*/const rl=oe("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
268
|
+
* @license lucide-react v0.468.0 - ISC
|
|
269
|
+
*
|
|
270
|
+
* This source code is licensed under the ISC license.
|
|
271
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
272
|
+
*/const sl=oe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
273
|
+
* @license lucide-react v0.468.0 - ISC
|
|
274
|
+
*
|
|
275
|
+
* This source code is licensed under the ISC license.
|
|
276
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
277
|
+
*/const gd=oe("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
|
|
278
|
+
* @license lucide-react v0.468.0 - ISC
|
|
279
|
+
*
|
|
280
|
+
* This source code is licensed under the ISC license.
|
|
281
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
282
|
+
*/const xd=oe("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
283
|
+
* @license lucide-react v0.468.0 - ISC
|
|
284
|
+
*
|
|
285
|
+
* This source code is licensed under the ISC license.
|
|
286
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
287
|
+
*/const md=oe("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
|
|
288
|
+
* @license lucide-react v0.468.0 - ISC
|
|
289
|
+
*
|
|
290
|
+
* This source code is licensed under the ISC license.
|
|
291
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
292
|
+
*/const bd=oe("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
293
|
+
* @license lucide-react v0.468.0 - ISC
|
|
294
|
+
*
|
|
295
|
+
* This source code is licensed under the ISC license.
|
|
296
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
297
|
+
*/const mi=oe("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
298
|
+
* @license lucide-react v0.468.0 - ISC
|
|
299
|
+
*
|
|
300
|
+
* This source code is licensed under the ISC license.
|
|
301
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
302
|
+
*/const bs=oe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
303
|
+
* @license lucide-react v0.468.0 - ISC
|
|
304
|
+
*
|
|
305
|
+
* This source code is licensed under the ISC license.
|
|
306
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
307
|
+
*/const yd=oe("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/**
|
|
308
|
+
* @license lucide-react v0.468.0 - ISC
|
|
309
|
+
*
|
|
310
|
+
* This source code is licensed under the ISC license.
|
|
311
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
312
|
+
*/const vd=oe("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/**
|
|
313
|
+
* @license lucide-react v0.468.0 - ISC
|
|
314
|
+
*
|
|
315
|
+
* This source code is licensed under the ISC license.
|
|
316
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
317
|
+
*/const wd=oe("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
|
|
318
|
+
* @license lucide-react v0.468.0 - ISC
|
|
319
|
+
*
|
|
320
|
+
* This source code is licensed under the ISC license.
|
|
321
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
322
|
+
*/const jd=oe("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
|
|
323
|
+
* @license lucide-react v0.468.0 - ISC
|
|
324
|
+
*
|
|
325
|
+
* This source code is licensed under the ISC license.
|
|
326
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
327
|
+
*/const il=oe("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
|
|
328
|
+
* @license lucide-react v0.468.0 - ISC
|
|
329
|
+
*
|
|
330
|
+
* This source code is licensed under the ISC license.
|
|
331
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
332
|
+
*/const Kr=oe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
333
|
+
* @license lucide-react v0.468.0 - ISC
|
|
334
|
+
*
|
|
335
|
+
* This source code is licensed under the ISC license.
|
|
336
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
337
|
+
*/const ol=oe("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
|
|
338
|
+
* @license lucide-react v0.468.0 - ISC
|
|
339
|
+
*
|
|
340
|
+
* This source code is licensed under the ISC license.
|
|
341
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
342
|
+
*/const al=oe("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function kd(t,n){if(Object.is(t,n))return!0;if(typeof t!="object"||t===null||typeof n!="object"||n===null)return!1;if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(const[s,i]of t)if(!Object.is(i,n.get(s)))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(const s of t)if(!n.has(s))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(n).length)return!1;for(const s of r)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(t[s],n[s]))return!1;return!0}const{useRef:Sd}=Rc;function Id(t){const n=Sd();return r=>{const s=t(r);return kd(n.current,s)?n.current:n.current=s}}class Cd{constructor(){this.origin=null}start(n){this.origin=n.length===1?{clientX:n[0].clientX,clientY:n[0].clientY}:null}reset(){this.origin=null}move(n,r){if(n.length!==1)return this.reset(),!1;if(!this.origin)return!1;const s=n[0].clientX-this.origin.clientX,i=n[0].clientY-this.origin.clientY;return i<48||Math.abs(s)>=i||r>240?!1:(this.reset(),!0)}}const Rd="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z",Ad="M75.91 73.628V62.232c0-.96.36-1.68 1.199-2.16l22.912-13.194c3.119-1.8 6.838-2.639 10.676-2.639 14.394 0 23.511 11.157 23.511 23.032 0 .839 0 1.799-.12 2.758l-23.752-13.914c-1.439-.84-2.879-.84-4.318 0L75.91 73.627Zm53.499 44.383v-27.23c0-1.68-.72-2.88-2.159-3.719L97.142 69.55l9.836-5.638c.839-.48 1.559-.48 2.399 0l22.912 13.195c6.598 3.839 11.035 11.995 11.035 19.912 0 9.116-5.397 17.513-13.915 20.992v.001Zm-60.577-23.99-9.836-5.758c-.84-.48-1.2-1.2-1.2-2.16v-26.39c0-12.834 9.837-22.55 23.152-22.55 5.039 0 9.716 1.679 13.676 4.678L70.993 55.516c-1.44.84-2.16 2.039-2.16 3.719v34.787-.002Zm21.173 12.234L75.91 98.339V81.546l14.095-7.917 14.094 7.917v16.793l-14.094 7.916Zm9.056 36.467c-5.038 0-9.716-1.68-13.675-4.678l23.631-13.676c1.439-.839 2.159-2.038 2.159-3.718V85.863l9.956 5.757c.84.48 1.2 1.2 1.2 2.16v26.389c0 12.835-9.957 22.552-23.27 22.552v.001Zm-28.43-26.75L47.72 102.778c-6.599-3.84-11.036-11.996-11.036-19.913 0-9.236 5.518-17.513 14.034-20.992v27.35c0 1.68.72 2.879 2.16 3.718l29.989 17.393-9.837 5.638c-.84.48-1.56.48-2.399 0Zm-1.318 19.673c-13.555 0-23.512-10.196-23.512-22.792 0-.959.12-1.919.24-2.879l23.63 13.675c1.44.84 2.88.84 4.32 0l30.108-17.392v11.395c0 .96-.361 1.68-1.2 2.16l-22.912 13.194c-3.119 1.8-6.837 2.639-10.675 2.639Zm29.748 14.274c14.515 0 26.63-10.316 29.39-23.991 13.434-3.479 22.071-16.074 22.071-28.91 0-8.396-3.598-16.553-10.076-22.43.6-2.52.96-5.039.96-7.557 0-17.153-13.915-29.99-29.989-29.99-3.239 0-6.358.48-9.477 1.56-5.398-5.278-12.835-8.637-20.992-8.637-14.515 0-26.63 10.316-29.39 23.991-13.434 3.48-22.07 16.074-22.07 28.91 0 8.396 3.598 16.553 10.075 22.431-.6 2.519-.96 5.038-.96 7.556 0 17.154 13.915 29.989 29.99 29.989 3.238 0 6.357-.479 9.476-1.559 5.397 5.278 12.835 8.637 20.992 8.637Z";function Zi({agentType:t,size:n=16,className:r}){return t==="customer-agent"?e.jsxs("svg",{className:r,"data-agent-icon":t,width:n,height:n,viewBox:"50 48 180 180",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M76 187V90Q76 74 92 74H188Q204 74 204 90V187",stroke:"currentColor",strokeWidth:"18",strokeLinecap:"round"}),e.jsx("path",{d:"m108 116 26 24-26 24m47 0h22M100 207h80",stroke:"currentColor",strokeWidth:"14",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("circle",{cx:"204",cy:"207",r:"11",fill:"currentColor"})]}):t==="codex"?e.jsx("svg",{className:r,"data-agent-icon":t,width:n,height:n,viewBox:"29.487 29.964 121.035 119.954","aria-hidden":"true",children:e.jsx("path",{fill:"currentColor",d:Ad})}):t==="claude-code"?e.jsx("svg",{className:r,"data-agent-icon":t,width:n,height:n,viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fill:"currentColor",d:Rd})}):e.jsx("svg",{className:r,"data-agent-icon":t,width:n,height:n,viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fill:"currentColor",d:"M22 24H2V0h20zM17 4.8H7v14.4h10z",fillRule:"evenodd"})})}let Xo=Promise.resolve(),Md=0;function ll(t,n=!1){const r=Xo.then(async()=>{if(t.length>5e4)throw new Error("图表源码过长,请查看源码");const s=(await Ac(async()=>{const{default:a}=await import("./mermaid.core-CjC7QuvE.js").then(c=>c.cb);return{default:a}},__vite__mapDeps([0,1,2]),import.meta.url)).default;s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",suppressErrorRendering:!0,maxTextSize:5e4,maxEdges:500,...n?{htmlLabels:!1,flowchart:{htmlLabels:!1}}:{},secure:["secure","securityLevel","startOnLoad","maxTextSize","maxEdges","suppressErrorRendering",...n?["htmlLabels","flowchart"]:[]]});const i=document.createElement("div");i.style.cssText="position:fixed;left:-100000px;top:0;visibility:hidden;pointer-events:none",document.body.appendChild(i);try{const{svg:a}=await s.render(`agentroam-mermaid-${++Md}`,t,i);return a}finally{i.remove()}});return Xo=r.catch(()=>{}),r}function cl(t){var r;const n=(r=t.match(/<svg\b[^>]*\bviewBox=["']([^"']+)["']/i))==null?void 0:r[1].trim().split(/[\s,]+/).map(Number);return!n||n.length!==4||!n.every(Number.isFinite)||n[2]<=0||n[3]<=0?{width:640,height:480}:{width:n[2],height:n[3]}}function Ed(t,n,r){return Math.max(.001,Math.min(1,Math.max(1,n)/t.width,r===void 0?1:Math.max(1,r)/t.height))}function Zo(t,n){return Math.min(4,Math.max(Math.min(.1,n),t))}function Td(t){const n=Math.min(2,4096/t.width,4096/t.height);return{width:Math.max(1,Math.round(t.width*n)),height:Math.max(1,Math.round(t.height*n))}}async function Nd(t){const n=await ll(t,!0),r=new DOMParser().parseFromString(n,"image/svg+xml");if(r.querySelector("parsererror, foreignObject"))throw new Error("此图包含暂不支持导出的内容,请查看源码。");if([...r.querySelectorAll("image")].some(c=>!String(c.getAttribute("href")??c.getAttribute("xlink:href")??"").startsWith("data:")))throw new Error("此图包含外部图片,暂不能导出 PNG。");const s=Td(cl(n)),i=r.documentElement;i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",String(s.width)),i.setAttribute("height",String(s.height)),i.style.maxWidth="none",i.style.width=`${s.width}px`,i.style.height=`${s.height}px`;const a=URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(i)],{type:"image/svg+xml;charset=utf-8"}));try{const c=new Image;await new Promise((h,g)=>{c.onload=()=>h(),c.onerror=()=>g(new Error("图表图片转换失败,请重试。")),c.src=a});const d=window.document.createElement("canvas");d.width=s.width,d.height=s.height;const u=d.getContext("2d");if(!u)throw new Error("当前浏览器无法导出图片。");return u.fillStyle="#fff",u.fillRect(0,0,s.width,s.height),u.drawImage(c,0,0,s.width,s.height),await new Promise((h,g)=>{d.toBlob(y=>y?h(y):g(new Error("图片导出失败,请重试。")),"image/png")})}finally{URL.revokeObjectURL(a)}}function Jo({label:t,onClose:n,children:r}){const s=l.useRef(null);return l.useEffect(()=>{var c,d;const i=document.activeElement,a=document.body.style.overflow;return document.body.style.overflow="hidden",(d=(c=s.current)==null?void 0:c.querySelector("button"))==null||d.focus(),()=>{document.body.style.overflow=a,i instanceof HTMLElement&&i.isConnected&&i.focus()}},[]),Yt.createPortal(e.jsxs("div",{className:"mermaid-dialog","data-tab-swipe-ignore":!0,ref:s,role:"dialog","aria-modal":"true","aria-label":t,onKeyDown:i=>{var u;if(i.key==="Escape"&&(i.stopPropagation(),n()),i.key!=="Tab")return;const a=[...((u=s.current)==null?void 0:u.querySelectorAll('button:not(:disabled), a[href], [tabindex="0"]'))??[]],c=a[0],d=a[a.length-1];i.shiftKey&&document.activeElement===c?(i.preventDefault(),d==null||d.focus()):!i.shiftKey&&document.activeElement===d&&(i.preventDefault(),c==null||c.focus())},children:[e.jsxs("div",{className:"mermaid-dialog-header",children:[e.jsx("strong",{children:t}),e.jsx("button",{type:"button",className:"mermaid-control","aria-label":`关闭${t}`,onClick:n,children:e.jsx(Kr,{size:20})})]}),r]}),document.body)}function zd({svg:t,fullscreen:n,onFullscreen:r,onExport:s,exporting:i}){const a=l.useMemo(()=>cl(t),[t]),c=l.useRef(null),[d,u]=l.useState(a),[h,g]=l.useState(null),y=Ed(a,d.width,n?d.height:void 0),m=h===null?y:Zo(h,y),k=l.useRef(m);k.current=m;const C=l.useRef(!1),E=l.useRef(null);l.useLayoutEffect(()=>{const S=c.current;if(!S)return;const j=()=>u({width:Math.max(1,S.clientWidth-24),height:Math.max(1,S.clientHeight-24)});j();const v=new ResizeObserver(j);return v.observe(S),()=>v.disconnect()},[]);const A=l.useCallback((S,j)=>{const v=c.current;if(!v)return;const D=Zo(S,y),V=D/k.current,R=j??{x:v.clientWidth/2,y:v.clientHeight/2},T=(v.scrollLeft+R.x)*V-R.x,P=(v.scrollTop+R.y)*V-R.y;k.current=D,g(D),requestAnimationFrame(()=>{v.scrollLeft=T,v.scrollTop=P})},[y]);return l.useEffect(()=>{const S=c.current;if(!S)return;let j=null;const v=P=>Math.hypot(P[0].clientX-P[1].clientX,P[0].clientY-P[1].clientY),D=P=>{C.current=!1,P.touches.length===2&&(j={distance:Math.max(1,v(P.touches)),scale:k.current},C.current=!0)},V=P=>{if(C.current=!0,!j||P.touches.length!==2)return;P.preventDefault();const I=S.getBoundingClientRect();A(j.scale*v(P.touches)/j.distance,{x:(P.touches[0].clientX+P.touches[1].clientX)/2-I.left,y:(P.touches[0].clientY+P.touches[1].clientY)/2-I.top})},R=()=>{j=null},T=P=>{if(!P.ctrlKey&&!P.metaKey)return;P.preventDefault();const I=S.getBoundingClientRect();A(k.current*Math.exp(-P.deltaY*.01),{x:P.clientX-I.left,y:P.clientY-I.top})};return S.addEventListener("touchstart",D,{passive:!0}),S.addEventListener("touchmove",V,{passive:!1}),S.addEventListener("touchend",R),S.addEventListener("touchcancel",R),S.addEventListener("wheel",T,{passive:!1}),()=>{S.removeEventListener("touchstart",D),S.removeEventListener("touchmove",V),S.removeEventListener("touchend",R),S.removeEventListener("touchcancel",R),S.removeEventListener("wheel",T)}},[A]),e.jsxs("div",{className:`mermaid-viewer${n?" mermaid-viewer-fullscreen":""}`,children:[e.jsxs("div",{className:"mermaid-toolbar",role:"toolbar","aria-label":"图表操作",children:[e.jsx("button",{type:"button",className:"mermaid-control","aria-label":"缩小图表",title:"缩小",disabled:m<=Math.min(.1,y),onClick:()=>A(m/1.25),children:e.jsx(al,{size:18})}),e.jsxs("span",{className:"mermaid-zoom-value","aria-label":"缩放比例",children:[Math.round(m*100),"%"]}),e.jsx("button",{type:"button",className:"mermaid-control","aria-label":"放大图表",title:"放大",disabled:m>=4,onClick:()=>A(m*1.25),children:e.jsx(ol,{size:18})}),e.jsx("button",{type:"button",className:"mermaid-control","aria-label":"自适应图表",title:"自适应",onClick:()=>{var S;g(null),(S=c.current)==null||S.scrollTo(0,0)},children:e.jsx(rl,{size:18})}),e.jsx("button",{type:"button",className:"mermaid-control","aria-label":n?"退出图表全屏":"全屏查看图表",title:n?"退出全屏":"全屏",onClick:r,children:n?e.jsx(od,{size:18}):e.jsx(sd,{size:18})}),e.jsx("button",{type:"button",className:"mermaid-control","aria-label":"导出图表 PNG",title:"导出 PNG",disabled:i,onClick:s,children:e.jsx(tl,{size:18})})]}),e.jsx("div",{className:"mermaid-block-preview",ref:c,tabIndex:0,"aria-label":"图表预览,可滚动或双指缩放",onPointerDown:S=>{if(S.pointerType!=="mouse"||S.button!==0)return;const j=S.currentTarget;C.current=!1,E.current={x:S.clientX,y:S.clientY,left:j.scrollLeft,top:j.scrollTop}},onPointerMove:S=>{const j=E.current;j&&(Math.hypot(S.clientX-j.x,S.clientY-j.y)>4&&(C.current||S.currentTarget.setPointerCapture(S.pointerId),C.current=!0),S.currentTarget.scrollLeft=j.left-(S.clientX-j.x),S.currentTarget.scrollTop=j.top-(S.clientY-j.y))},onPointerUp:()=>{E.current=null},onPointerCancel:()=>{E.current=null},children:e.jsx("div",{className:"mermaid-diagram-canvas",style:{width:a.width*m,height:a.height*m},role:n?"img":"button","aria-label":n?"Mermaid 图表":"点击全屏查看 Mermaid 图表",tabIndex:n?void 0:0,onClick:()=>{!n&&!C.current&&r()},onKeyDown:S=>{!n&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),r())},dangerouslySetInnerHTML:{__html:t}})}),e.jsx("div",{className:"mermaid-viewer-hint",children:i?"正在生成完整 PNG…":n?"双指缩放 · 滑动查看 · 导出完整图片":"点击图表全屏 · 双指缩放"})]})}function Ld({code:t,svg:n}){const r=l.useRef(null),[s,i]=l.useState(!1),[a,c]=l.useState(!1),[d,u]=l.useState(null),[h,g]=l.useState(null),y=l.useRef(0),m=l.useCallback(()=>{i(!1),requestAnimationFrame(()=>{var A,S;return(S=(A=r.current)==null?void 0:A.querySelector('button[aria-label="全屏查看图表"]'))==null?void 0:S.focus()})},[]),k=l.useCallback(()=>u(null),[]);l.useEffect(()=>()=>{y.current++},[t]),l.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]);const C=async()=>{if(a)return;const A=y.current;c(!0),g(null);try{const S=await Nd(t);A===y.current&&u(URL.createObjectURL(S))}catch(S){A===y.current&&g(S instanceof Error?S.message:"图片导出失败,请重试。")}finally{A===y.current&&c(!1)}},E=e.jsx(zd,{svg:n,fullscreen:s,onFullscreen:()=>s?m():i(!0),onExport:()=>void C(),exporting:a});return e.jsxs("div",{className:"mermaid-diagram","data-tab-swipe-ignore":!0,ref:r,children:[s?e.jsxs(Jo,{label:"图表全屏",onClose:m,children:[E,h&&e.jsx("div",{className:"mermaid-block-status",role:"alert",children:h})]}):E,!s&&h&&e.jsx("div",{className:"mermaid-block-status",role:"alert",children:h}),d&&e.jsxs(Jo,{label:"导出图表图片",onClose:k,children:[e.jsxs("div",{className:"mermaid-export-actions",children:[e.jsx("span",{children:"手机可长按图片保存,或下载 PNG"}),e.jsx("a",{href:d,download:"mermaid-diagram.png",children:"下载 PNG"})]}),e.jsx("div",{className:"mermaid-export-preview",children:e.jsx("img",{src:d,alt:"完整 Mermaid 图表 PNG"})})]})]})}function _d({code:t,complete:n}){const[r,s]=l.useState(!1),[i,a]=l.useState(null),c=n&&(i==null?void 0:i.code)===t?i:null;l.useEffect(()=>{if(!n||!t.trim())return;let u=!1;const h=setTimeout(()=>{ll(t).then(g=>{u||a({code:t,svg:g})},()=>{u||a({code:t,error:"图表暂时无法渲染,请查看源码。"})})},150);return()=>{u=!0,clearTimeout(h)}},[t,n]);const d=n?t.trim()?(c==null?void 0:c.error)??(c!=null&&c.svg?null:"正在渲染图表…"):"暂无图表内容":"图表生成中…";return e.jsxs("div",{className:"mermaid-block",children:[e.jsxs("div",{className:"mermaid-block-header",children:[e.jsx("span",{children:"Mermaid"}),e.jsx("button",{type:"button","aria-pressed":r,onClick:()=>s(!r),children:r?"图表":"源码"})]}),d&&e.jsx("div",{className:"mermaid-block-status",role:"status",children:d}),r||!(c!=null&&c.svg)?e.jsx("pre",{className:"mermaid-block-source",children:e.jsx("code",{children:t})}):e.jsx(Ld,{code:t,svg:c.svg},t)]})}const dl="webapp.nativeAgentRunPrefs.v1",Pd=["codex","claude-code","opencode"];function ul(){try{const t=JSON.parse(localStorage.getItem(dl)??"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function Os(t){return Pd.includes(t)}function ea(t){return Os(t)?ul()[t]??{}:{}}function Wd(t,n){if(!Os(t))return;const r=ul();r[t]=n;try{localStorage.setItem(dl,JSON.stringify(r))}catch{}}function bi(t){return t.providerID?`${t.providerID}/${t.id}`:t.id}function Dd(t){const n=t.indexOf("/");return n>0?{providerID:t.slice(0,n),id:t.slice(n+1)}:{id:t}}function Fs(t,n){const r=t??[],s=r.findIndex(a=>a.itemId===n.itemId&&a.sectionIndex===n.sectionIndex);return(s<0?[...r,{itemId:n.itemId,sectionIndex:n.sectionIndex,text:n.delta}]:r.map((a,c)=>c===s?{...a,text:a.text+n.delta}:a)).sort((a,c)=>a.sectionIndex-c.sectionIndex)}function ta(t){let n=[];for(const r of t)if(r.type==="runtime_progress"){const{type:s,...i}=r;n=pl(n,i)}else(r.type==="done"||r.type==="turn_aborted"||r.type==="error")&&(n=[]);return n}function pl(t,n){const r=t.findIndex(s=>s.progressId===n.progressId);return r<0?[...t,n]:t.map((s,i)=>i===r?n:s)}function fl(t,n){return[...t].reverse().find(r=>r.toolCallId===n)}function Bd(t){return[...t].reverse().find(n=>!n.toolCallId)}function $d(t,n){var s,i,a;const r=[];for(let c=0;c<t.length;c+=1){const d=t[c];r.push(d);const u=d.role==="user"?(i=(s=d.presentation)==null?void 0:s.executionTrace)==null?void 0:i.turnId:void 0;if(!u)continue;const h=t[c+1];((a=h==null?void 0:h.executionTrace)==null?void 0:a.turnId)===u?(r.push({...h,executionTrace:{...h.executionTrace,turnId:u,revision:n}}),c+=1):r.push({id:`codex-execution-trace:${u}`,role:"assistant",content:"",executionTrace:{turnId:u,revision:n},timestamp:d.timestamp})}return r}function Od(t){var n,r,s,i;return t.role==="assistant"&&!!((n=t.toolCalls)!=null&&n.length||(s=(r=t.presentation)==null?void 0:r.reasoning)!=null&&s.length||((i=t.presentation)==null?void 0:i.agentMessagePhase)==="commentary")}function hl(t,n,r,s){return t.map(i=>{var a;return(a=i.toolCalls)!=null&&a.some(c=>c.id===n)?{...i,toolCalls:i.toolCalls.map(c=>c.id===n?{...c,result:r,isError:s}:c)}:i})}function Fd(t,n,r,s){if(n.type==="text_chunk"){if(!n.text||n.messagePhase!=="commentary")return[...t];const i=n.itemId?`codex-trace:${s}:agent:${n.itemId}`:`codex-live-commentary:${s}`,a=t.findIndex(c=>c.id===i);return a<0?[...t,{id:i,role:"assistant",content:n.text,presentation:{agentMessagePhase:"commentary"},timestamp:r}]:t.map((c,d)=>d===a?{...c,content:c.content+n.text}:c)}if(n.type==="reasoning_summary_delta"){const i=t.findIndex(a=>{var c,d;return(d=(c=a.presentation)==null?void 0:c.reasoning)==null?void 0:d.some(u=>u.itemId===n.itemId)});return i<0?[...t,{id:`codex-live-reasoning:${n.itemId}`,role:"assistant",content:"",presentation:{reasoning:Fs(void 0,n)},timestamp:r}]:t.map((a,c)=>{var d;return c===i?{...a,presentation:{...a.presentation,reasoning:Fs((d=a.presentation)==null?void 0:d.reasoning,n)}}:a})}if(n.type==="tool_call"){const i=t.findIndex(a=>{var c;return(c=a.toolCalls)==null?void 0:c.some(d=>d.id===n.toolCall.id)});return i>=0?t.map((a,c)=>{var d;return c===i?{...a,toolCalls:(d=a.toolCalls)==null?void 0:d.map(u=>u.id===n.toolCall.id?{...u,name:n.toolCall.name,arguments:n.toolCall.arguments}:u)}:a}):[...t,{id:`codex-live-tool:${n.toolCall.id}`,role:"assistant",content:"",toolCalls:[{...n.toolCall}],timestamp:r}]}return t.some(i=>{var a;return(a=i.toolCalls)==null?void 0:a.some(c=>c.id===n.result.toolCallId)})?hl(t,n.result.toolCallId,n.result.content,n.result.isError):[...t]}function Hi(t,n,r,s=Date.now()){var h;const i=t.findIndex(g=>{var y;return((y=g.executionTrace)==null?void 0:y.turnId)===n}),a=i>=0?((h=t[i].executionTrace)==null?void 0:h.liveMessages)??[]:[],c=Fd(a,r,s,n);if(c.length===0&&a.length===0)return[...t];if(i>=0)return t.map((g,y)=>y===i?{...g,executionTrace:{...g.executionTrace,liveMessages:c}}:g);if(c===a)return[...t];const d=t.findLastIndex(g=>g.role==="user"&&!g.isQueued);if(d<0)return[...t];const u={id:`codex-execution-trace:${n}`,role:"assistant",content:"",executionTrace:{turnId:n,revision:`live:${n}`,liveMessages:c},timestamp:s};return[...t.slice(0,d+1),u,...t.slice(d+1)]}function Ui(t,n){const r=new Map(t.map(s=>[`${s.itemId}:${s.sectionIndex}`,s]));for(const s of n){const i=`${s.itemId}:${s.sectionIndex}`,a=r.get(i),c=a?s.text.startsWith(a.text)?s.text:a.text.startsWith(s.text)?a.text:s.text:s.text;r.set(i,{...s,text:c})}return[...r.values()]}function na(t){var n,r;return[...((n=t.presentation)==null?void 0:n.agentMessagePhase)==="commentary"?[`agent:${t.id}`]:[],...(((r=t.presentation)==null?void 0:r.reasoning)??[]).map(s=>`reasoning:${s.itemId}:${s.sectionIndex}`),...(t.toolCalls??[]).map(s=>`tool:${s.id}`)]}function Hd(t,n){var r,s;return((r=t.presentation)==null?void 0:r.agentMessagePhase)==="commentary"&&((s=n.presentation)==null?void 0:s.agentMessagePhase)==="commentary"&&(t.id.startsWith("codex-live-commentary:")||n.id.startsWith("codex-live-commentary:"))&&(t.content.startsWith(n.content)||n.content.startsWith(t.content))}function Ud(t){var a,c,d,u,h,g,y,m,k,C,E;const n=[],r=new Map,s=new Map,i=new Map;for(const A of t){if(((a=A.presentation)==null?void 0:a.agentMessagePhase)==="commentary"){const R=r.get(A.id);if(R!==void 0){const T=n[R],P=A.content.startsWith(T.content)?A.content:T.content.startsWith(A.content)?T.content:A.content;n[R]={...T,...A,id:T.id,content:P};continue}}const S={...A,toolCalls:A.toolCalls?[]:void 0,presentation:(c=A.presentation)!=null&&c.reasoning?{...A.presentation,reasoning:[]}:A.presentation};for(const R of((d=A.presentation)==null?void 0:d.reasoning)??[]){const T=`${R.itemId}:${R.sectionIndex}`,P=s.get(T);if(P){const I=n[P.messageIndex],N=[...((u=I.presentation)==null?void 0:u.reasoning)??[]],G=N[P.sectionIndex];N[P.sectionIndex]=Ui([G],[R])[0],n[P.messageIndex]={...I,presentation:{...I.presentation,reasoning:N}}}else{const I=S.presentation.reasoning.findIndex(N=>N.itemId===R.itemId&&N.sectionIndex===R.sectionIndex);I>=0?S.presentation.reasoning[I]=Ui([S.presentation.reasoning[I]],[R])[0]:S.presentation.reasoning.push(R)}}for(const R of A.toolCalls??[]){const T=i.get(R.id);if(T){const P=n[T.messageIndex],I=[...P.toolCalls??[]];I[T.toolIndex]={...I[T.toolIndex],...R},n[T.messageIndex]={...P,toolCalls:I}}else{const P=S.toolCalls.findIndex(I=>I.id===R.id);P>=0?S.toolCalls[P]={...S.toolCalls[P],...R}:S.toolCalls.push(R)}}const j=((h=S.presentation)==null?void 0:h.agentMessagePhase)==="commentary",v=!!((y=(g=S.presentation)==null?void 0:g.reasoning)!=null&&y.length),D=!!((m=S.toolCalls)!=null&&m.length);if(!j&&!v&&!D)continue;const V=n.length;n.push(S),j&&r.set(S.id,V);for(let R=0;R<(((C=(k=S.presentation)==null?void 0:k.reasoning)==null?void 0:C.length)??0);R+=1){const T=S.presentation.reasoning[R];s.set(`${T.itemId}:${T.sectionIndex}`,{messageIndex:V,sectionIndex:R})}for(let R=0;R<(((E=S.toolCalls)==null?void 0:E.length)??0);R+=1)i.set(S.toolCalls[R].id,{messageIndex:V,toolIndex:R})}return n}function qd(t,n,r){if(t.length<2)return t;const s=new Map;t.forEach((A,S)=>{for(const j of na(A))s.set(j,S)});const i=A=>{for(const S of na(A)){const j=s.get(S);if(j!==void 0)return j}return t.findIndex(S=>Hd(S,A))},a=A=>{const S=[];for(const j of A){const v=i(j);v<0||S.at(-1)===v||S.push(v)}return S},c=a(n),d=a(r),u=Array.from({length:t.length},()=>new Set),h=Array.from({length:t.length},()=>0),g=A=>{for(let S=1;S<A.length;S+=1){const j=A[S-1],v=A[S];j===v||u[j].has(v)||(u[j].add(v),h[v]+=1)}};g(c),g(d);const y=new Map(c.map((A,S)=>[A,S])),m=new Map(d.map((A,S)=>[A,S])),k=(A,S)=>{const j=y.get(A)??Number.POSITIVE_INFINITY,v=y.get(S)??Number.POSITIVE_INFINITY;if(j!==v)return j-v;const D=m.get(A)??Number.POSITIVE_INFINITY,V=m.get(S)??Number.POSITIVE_INFINITY;return D!==V?D-V:A-S},C=h.flatMap((A,S)=>A===0?[S]:[]).sort(k),E=[];for(;C.length>0;){const A=C.shift();E.push(t[A]);for(const S of u[A])h[S]-=1,h[S]===0&&(C.push(S),C.sort(k))}return E.length===t.length?E:t}function Vd(t,n){var s,i,a,c,d;const r=t.map(u=>{var h,g;return{...u,toolCalls:(h=u.toolCalls)==null?void 0:h.map(y=>({...y})),presentation:(g=u.presentation)!=null&&g.reasoning?{...u.presentation,reasoning:[...u.presentation.reasoning]}:u.presentation}});for(const u of n){if(((s=u.presentation)==null?void 0:s.agentMessagePhase)==="commentary"){const g=r.findIndex(y=>{var m;return y.id===u.id||((m=y.presentation)==null?void 0:m.agentMessagePhase)==="commentary"&&(y.id.startsWith("codex-live-commentary:")||u.id.startsWith("codex-live-commentary:"))&&(u.content.startsWith(y.content)||y.content.startsWith(u.content))});if(g<0)r.push(u);else{const y=r[g],m=u.content.startsWith(y.content)?u.content:y.content.startsWith(u.content)?y.content:u.content;r[g]={...y,content:m,presentation:{...y.presentation,agentMessagePhase:"commentary"}}}continue}const h=(i=u.presentation)==null?void 0:i.reasoning;if(h!=null&&h.length){const g=r.findIndex(y=>{var m,k;return(k=(m=y.presentation)==null?void 0:m.reasoning)==null?void 0:k.some(C=>h.some(E=>E.itemId===C.itemId))});if(g>=0){const y=r[g];r[g]={...y,presentation:{...y.presentation,reasoning:Ui(((a=y.presentation)==null?void 0:a.reasoning)??[],h)}}}else r.push(u)}for(const g of u.toolCalls??[]){const y=r.findIndex(m=>{var k;return(k=m.toolCalls)==null?void 0:k.some(C=>C.id===g.id)});if(y>=0){const m=r[y];r[y]={...m,toolCalls:(c=m.toolCalls)==null?void 0:c.map(k=>k.id===g.id?{...k,...g}:k)}}else r.push({...u,id:(((d=u.toolCalls)==null?void 0:d.length)??0)>1?`${u.id}:tool:${g.id}`:u.id,presentation:void 0,toolCalls:[g]})}}return qd(Ud(r),t,n)}function ra(t){for(let n=t.length-1;n>=0;n--)if(t[n].type==="context_usage"&&t[n].usage)return t[n].usage}function sa(t){var r;const n=new Map;for(const s of t)s.type==="native_subagent_update"&&((r=s.activity)!=null&&r.parentToolCallId)&&n.set(s.activity.parentToolCallId,s.activity);return[...n.values()]}function gl(t){var n;return!!(t&&t.role==="assistant"&&!((n=t.toolCalls)!=null&&n.length)&&!t.widget&&!t.askUser&&!t.isCompactionSummary&&!t.executionTrace)}function ia(t,n){var r;if(n.role==="assistant"&&((r=n.toolCalls)!=null&&r.length)){const s=t[t.length-1];if(gl(s))return[...t.slice(0,-1),{...s,content:s.content,toolCalls:n.toolCalls}]}return[...t,n]}function Kd(t,n){if(!n)return t;const r=t[t.length-1];if(gl(r)){const s=[...t];return s[s.length-1]={...r,content:r.content+n},s}return[...t,{id:crypto.randomUUID(),role:"assistant",content:n,timestamp:Date.now()}]}function oa(t,n,r,s){return t.map(i=>{if(!i.toolCalls)return i;const a=i.toolCalls.map(c=>c.id===n?{...c,result:r,isError:s}:c);return{...i,toolCalls:a}})}function aa(t,n,r,s){return t.map(i=>{if(!i.toolCalls)return i;const a=i.toolCalls.map(c=>c.name==="dispatch_agent"&&c.arguments.subSessionId===n?{...c,arguments:{...c.arguments,subAgentStatus:r,subAgentDetail:s}}:c);return{...i,toolCalls:a}})}function la(t,n,r){return t.map(s=>{if(!s.toolCalls)return s;const i=s.toolCalls.map(a=>a.name==="dispatch_agent"&&a.arguments.subSessionId===n?{...a,arguments:{...a.arguments,subAgentProgress:(a.arguments.subAgentProgress?a.arguments.subAgentProgress+`
|
|
343
|
+
`+r:r).split(`
|
|
344
|
+
`).slice(-30).join(`
|
|
345
|
+
`)}}:a);return{...s,toolCalls:i}})}function ca(t,n,r){return t.map(s=>s.id===n?r(s):s)}function da(t,n){const r=t.findIndex(s=>{var i,a;return(a=(i=s.presentation)==null?void 0:i.reasoning)==null?void 0:a.some(c=>c.itemId===n.itemId)});return r<0?[...t,{id:`native-reasoning:${n.itemId}`,role:"assistant",content:"",presentation:{reasoning:Fs(void 0,n)},timestamp:Date.now()}]:t.map((s,i)=>{var a;return i===r?{...s,presentation:{...s.presentation,reasoning:Fs((a=s.presentation)==null?void 0:a.reasoning,n)}}:s})}const Le=Za((t,n)=>({messages:[],messagesBySession:{},contextUsageBySession:{},runtimeProgressBySession:{},nativeSubagentsBySession:{},runningSessionId:null,currentText:"",sessionId:null,todos:[],cronTasks:[],addMessage:(r,s)=>t(i=>{const a=s??i.sessionId??void 0,c=a&&a!==i.sessionId?i.messages:ia(i.messages,r),d=a?{...i.messagesBySession,[a]:ia(i.messagesBySession[a]??(a===i.sessionId?i.messages:[]),r)}:i.messagesBySession;return{messages:c,messagesBySession:d,currentText:a&&a!==i.sessionId?i.currentText:""}}),appendText:(r,s)=>t(i=>{if(!r)return i;const a=s??i.sessionId??void 0,c=!a||a===i.sessionId,d=Kd(c?i.messages:i.messagesBySession[a]??[],r),u=a?{...i.messagesBySession,[a]:d}:i.messagesBySession;return{messages:c?d:i.messages,messagesBySession:u,currentText:a&&a!==i.sessionId?i.currentText:i.currentText+r}}),setRunningSession:r=>t({runningSessionId:r}),setSessionId:r=>t(s=>s.sessionId===r?s:{sessionId:r,messages:s.messagesBySession[r]??[],currentText:""}),updateToolResult:(r,s,i,a)=>t(c=>{const d=a??c.sessionId??void 0,u=d&&d!==c.sessionId?c.messages:oa(c.messages,r,s,i),h=d?{...c.messagesBySession,[d]:oa(c.messagesBySession[d]??(d===c.sessionId?c.messages:[]),r,s,i)}:c.messagesBySession;return{messages:u,messagesBySession:h}}),setMessages:(r,s)=>t(i=>{const a=s??i.sessionId??void 0,c=!a||a===i.sessionId;return{messages:c?r:i.messages,messagesBySession:a?{...i.messagesBySession,[a]:r}:i.messagesBySession,currentText:c?"":i.currentText}}),getMessagesForSession:r=>n().messagesBySession[r]??[],setContextUsage:(r,s)=>t(i=>{const a=s??i.sessionId??void 0;return a?{contextUsageBySession:{...i.contextUsageBySession,[a]:r}}:i}),getContextUsageForSession:r=>n().contextUsageBySession[r],applyRuntimeProgress:(r,s)=>t(i=>{const a=s??i.sessionId??void 0;return a?{runtimeProgressBySession:{...i.runtimeProgressBySession,[a]:pl(i.runtimeProgressBySession[a]??[],r)}}:i}),setRuntimeProgress:(r,s)=>t(i=>{const a=s??i.sessionId??void 0;return a?{runtimeProgressBySession:{...i.runtimeProgressBySession,[a]:r}}:i}),clearRuntimeProgress:r=>t(s=>{var d;const i=r??s.sessionId??void 0;if(!i||!((d=s.runtimeProgressBySession[i])!=null&&d.length))return s;const{[i]:a,...c}=s.runtimeProgressBySession;return{runtimeProgressBySession:c}}),applyNativeSubagentActivity:(r,s)=>t(i=>{const a=s??i.sessionId??void 0;return a?{nativeSubagentsBySession:{...i.nativeSubagentsBySession,[a]:{...i.nativeSubagentsBySession[a]??{},[r.parentToolCallId]:r}}}:i}),setNativeSubagentActivities:(r,s)=>t(i=>{const a=s??i.sessionId??void 0;return a?{nativeSubagentsBySession:{...i.nativeSubagentsBySession,[a]:Object.fromEntries(r.map(c=>[c.parentToolCallId,c]))}}:i}),applyReasoningSummary:(r,s)=>t(i=>{const a=s??i.sessionId??void 0,c=a&&a!==i.sessionId?i.messages:da(i.messages,r),d=a?{...i.messagesBySession,[a]:da(i.messagesBySession[a]??(a===i.sessionId?i.messages:[]),r)}:i.messagesBySession;return{messages:c,messagesBySession:d}}),applyCodexExecutionEvent:(r,s,i)=>t(a=>{const c=i??a.sessionId??void 0,d=Date.now(),u=c&&c!==a.sessionId?a.messages:Hi(a.messages,r,s,d),h=c?{...a.messagesBySession,[c]:Hi(a.messagesBySession[c]??(c===a.sessionId?a.messages:[]),r,s,d)}:a.messagesBySession;return{messages:u,messagesBySession:h}}),updateMessage:(r,s,i)=>t(a=>{const c=i??a.sessionId??void 0,d=c&&c!==a.sessionId?a.messages:ca(a.messages,r,s),u=c?{...a.messagesBySession,[c]:ca(a.messagesBySession[c]??(c===a.sessionId?a.messages:[]),r,s)}:a.messagesBySession;return{messages:d,messagesBySession:u}}),updateSubAgentStatus:(r,s,i,a)=>t(c=>{const d=a??c.sessionId??void 0,u=d&&d!==c.sessionId?c.messages:aa(c.messages,r,s,i),h=d?{...c.messagesBySession,[d]:aa(c.messagesBySession[d]??(d===c.sessionId?c.messages:[]),r,s,i)}:c.messagesBySession;return{messages:u,messagesBySession:h}}),updateSubAgentProgress:(r,s,i)=>t(a=>{const c=i??a.sessionId??void 0,d=c&&c!==a.sessionId?a.messages:la(a.messages,r,s),u=c?{...a.messagesBySession,[c]:la(a.messagesBySession[c]??(c===a.sessionId?a.messages:[]),r,s)}:a.messagesBySession;return{messages:d,messagesBySession:u}}),clearMessages:r=>t(s=>{const i=r??s.sessionId??void 0;if(!i)return{messages:[],currentText:""};const{[i]:a,...c}=s.messagesBySession,{[i]:d,...u}=s.contextUsageBySession,{[i]:h,...g}=s.runtimeProgressBySession,{[i]:y,...m}=s.nativeSubagentsBySession;return{messages:i===s.sessionId?[]:s.messages,messagesBySession:c,contextUsageBySession:u,runtimeProgressBySession:g,nativeSubagentsBySession:m,currentText:i===s.sessionId?"":s.currentText}}),setTodos:r=>t({todos:r}),setCronTasks:r=>t({cronTasks:r})}));function Ji(){const t=window;return t.SpeechRecognition??t.webkitSpeechRecognition??null}function xl(){if(typeof window>"u")return null;const t=window.agentApi;return typeof(t==null?void 0:t.dictationStart)!="function"||typeof t.dictationStop!="function"||typeof t.onDictation!="function"||typeof t.onDictationError!="function"?null:t}function Gd(){return xl()!==null||Ji()!==null}function Qd(t){var a,c;const n=xl();if(n){let d=!1,u=()=>{},h=()=>{};const g=()=>{var y;d||(d=!0,u(),h(),(y=t.onEnd)==null||y.call(t))};return u=n.onDictation(({text:y,isFinal:m})=>{const k=y.trim();k&&(m?(t.onFinal(k),g()):t.onInterim(k))}),h=n.onDictationError(y=>{var m;(m=t.onError)==null||m.call(t,y),g()}),n.dictationStart().then(y=>{var m;y.ok||((m=t.onError)==null||m.call(t,y.reason||"无法启动语音识别"),g())}).catch(()=>{var y;(y=t.onError)==null||y.call(t,"无法启动语音识别"),g()}),{stop:()=>{n.dictationStop()}}}const r=Ji();if(!r)return(a=t.onError)==null||a.call(t,"当前环境不支持语音识别"),null;const s=new r;s.lang=t.lang??"zh-CN",s.continuous=!1,s.interimResults=!0;let i="";s.onresult=d=>{let u="";for(let h=d.resultIndex;h<d.results.length;h++){const g=d.results[h];g.isFinal?i+=g[0].transcript:u+=g[0].transcript}u&&t.onInterim(i+u)},s.onerror=d=>{var u;d.error!=="no-speech"&&d.error!=="aborted"&&((u=t.onError)==null||u.call(t,`语音识别失败:${d.error??"未知错误"}`))},s.onend=()=>{var d;i&&t.onFinal(i.trim()),(d=t.onEnd)==null||d.call(t)};try{s.start()}catch{return(c=t.onEnd)==null||c.call(t),null}return{stop:()=>s.stop()}}function Yd(t){var c;const n=Ji();if(!n)return(c=t.onError)==null||c.call(t,"当前环境不支持语音唤醒"),null;let r=!1,s=null,i=null;const a=()=>{if(!r){s=new n,s.lang=t.lang??"zh-CN",s.continuous=!0,s.interimResults=!0,s.onresult=d=>{var g,y,m;const u=d.results[d.results.length-1],h=(y=(g=u==null?void 0:u[0])==null?void 0:g.transcript)==null?void 0:y.trim();h&&(u.isFinal&&((m=t.onHeard)==null||m.call(t,h)),h.includes(t.wakeWord)&&t.onWake(h))},s.onerror=d=>{var u;d.error==="not-allowed"&&((u=t.onError)==null||u.call(t,"麦克风权限被拒绝,语音唤醒已停用"),r=!0)},s.onend=()=>{r||(i=setTimeout(a,400))};try{s.start()}catch{i=setTimeout(a,800)}}};return a(),{stop:()=>{r=!0,i&&clearTimeout(i);try{s==null||s.abort()}catch{}}}}function fs(){typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}function zs(t,n){return n(),typeof(t==null?void 0:t.ttsStop)=="function"?t.ttsStop().then(()=>{}):Promise.resolve()}const Xd={createContext:()=>new AudioContext,createNode:t=>new AudioWorkletNode(t,"pcm-stream-player",{numberOfInputs:0,numberOfOutputs:1,outputChannelCount:[1]}),workletUrl:"./pcm-audio-worklet.js"};function Zd(t){const n=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength%2!==0)throw new Error("PCM chunk contains an incomplete int16 sample");const r=new Float32Array(n.byteLength/2),s=new DataView(n.buffer,n.byteOffset,n.byteLength);for(let i=0;i<r.length;i+=1)r[i]=s.getInt16(i*2,!0)/32768;return r}class Jd{constructor(n,r=Xd){this.api=n,this.dependencies=r,this.context=null,this.node=null,this.ready=null,this.current=null}start(n){var s;this.current&&!this.current.acknowledged&&((s=this.node)==null||s.port.postMessage({type:"flush",generation:this.current.metadata.generation}));const r={metadata:n,pending:[],pendingSamples:0,finished:!1,acknowledged:!1};this.current=r,this.ensureReady().then(()=>{if(!(this.current!==r||!this.node)){this.node.port.postMessage({type:"start",generation:n.generation,sampleRate:n.sampleRate});for(const i of r.pending)this.postSamples(n.generation,i);r.pending=[],r.pendingSamples=0,r.finished&&this.node.port.postMessage({type:"finish",generation:n.generation})}}).catch(i=>this.fail(r,i))}enqueue(n,r){const s=this.current;if(!s||s.metadata.generation!==n||s.acknowledged)return;let i;try{i=Zd(r)}catch(a){this.fail(s,a);return}if(this.node){this.postSamples(n,i);return}if(s.pendingSamples+i.length>s.metadata.sampleRate){this.fail(s,new Error("TTS PCM queue overflow"));return}s.pending.push(i),s.pendingSamples+=i.length}finish(n){var s;const r=this.current;!r||r.metadata.generation!==n||r.acknowledged||(r.finished=!0,(s=this.node)==null||s.port.postMessage({type:"finish",generation:n}))}flush(n){var s;const r=this.current;!r||r.metadata.generation!==n||r.acknowledged||((s=this.node)==null||s.port.postMessage({type:"flush",generation:n}),r.pending=[],r.pendingSamples=0,this.acknowledge(r))}dispose(){var n,r;this.current&&this.flush(this.current.metadata.generation),(n=this.node)==null||n.disconnect(),this.node=null,(r=this.context)==null||r.close(),this.context=null,this.ready=null}ensureReady(){return this.ready?this.ready:(this.ready=(async()=>{const n=this.dependencies.createContext();this.context=n,await n.audioWorklet.addModule(this.dependencies.workletUrl);const r=this.dependencies.createNode(n);r.port.onmessage=s=>this.onWorkletMessage(s.data),r.connect(n.destination),this.node=r,n.state!=="running"&&await n.resume()})(),this.ready)}postSamples(n,r){var s;(s=this.node)==null||s.port.postMessage({type:"chunk",generation:n,samples:r},[r.buffer])}onWorkletMessage(n){const r=this.current;if(!(!r||n.generation!==r.metadata.generation)){if(n.type==="drained"||n.type==="stopped"){this.acknowledge(r);return}n.type==="overflow"&&this.fail(r,new Error("TTS AudioWorklet buffer overflow"))}}fail(n,r){this.current!==n||n.acknowledged||(console.error("[tts] PCM playback failed",r),n.acknowledged=!0,this.current=null,this.api.ttsStop(),this.api.ttsPlaybackEnded(n.metadata.generation))}acknowledge(n){this.current!==n||n.acknowledged||(n.acknowledged=!0,this.current=null,this.api.ttsPlaybackEnded(n.metadata.generation))}}async function eu(t,n,r,s=50){var d;const i=u=>t.getSession(n,{view:"trace",revision:u,turnId:r.turnId});try{return{detail:await i(r.revision),revision:r.revision,recovered:!1}}catch(u){if(u.code!=="STALE_SESSION_ANCHOR")throw u}const a=await t.getSession(n,{view:"core",limit:s}),c=(d=a==null?void 0:a.history)==null?void 0:d.revision;if(!c)throw new Error("会话内容已更新,请刷新后重试");return{detail:await i(c),revision:c,recovered:!0}}async function Or(t,n,r,s,i,a,c){if(r!=="codex"){const u=c?await c():await t.getSession(n,s);a()&&i(u,"full");return}const d=c?await c():await t.getSession(n,{...s,view:"core"});a()&&i(d,"core")}function ua(t,n,r,s){const i=r==="core"&&(s==null?void 0:s.delivery)!=="legacy-full"&&!!(s!=null&&s.revision),a=t.some(c=>!c.isQueued);return i&&a?tu(t,n):bl(t,n)}function tu(t,n){var S,j;if(n.length===0)return t;if(t.length===0)return n;let r=t.filter(v=>!v.isQueued);const s=t.filter(v=>v.isQueued),i=n.findLastIndex(v=>v.role==="user"&&!v.isCompactionSummary);if(i<0)return t;const a=n[i];let c=r.findLastIndex(v=>v.role==="user"&&!v.isCompactionSummary&&ir(v)===ir(a));if(c<0)return[...r,...n.slice(i),...s];const d=bl(r.slice(0,c),n.slice(0,i));r=[...d,...r.slice(c)],c=d.length;const u=r.findIndex((v,D)=>D>c&&v.role==="user"&&!v.isCompactionSummary),h=u<0?r.length:u,g=[];for(let v=c+1;v<h;v+=1)pa(r[v])&&g.push(v);const y=n.slice(i+1).filter(pa),m=(j=(S=n.find(v=>v.executionTrace))==null?void 0:S.executionTrace)==null?void 0:j.revision,k=r.map(v=>v.executionTrace&&m?{...v,executionTrace:{...v.executionTrace,revision:m}}:v),C=n.slice(i+1).find(v=>v.executionTrace),E=r.findIndex((v,D)=>{var V,R;return D>c&&D<h&&((V=v.executionTrace)==null?void 0:V.turnId)===((R=C==null?void 0:C.executionTrace)==null?void 0:R.turnId)});if(C&&E>=0){const v=r[E].executionTrace;k[E]={...C,id:r[E].id,timestamp:r[E].timestamp,executionTrace:{...C.executionTrace,...v!=null&&v.liveMessages?{liveMessages:v.liveMessages}:{}}}}const A=Math.min(g.length,y.length);for(let v=0;v<A;v+=1){const D=g[v],V=k[D],R=y[v];k[D]={...V,...R,id:R.id.startsWith("history-message.v1.")?R.id:V.id,timestamp:V.timestamp,images:R.images??V.images,presentation:R.presentation??V.presentation}}return y.length>A&&k.splice(h,0,...y.slice(A)),[...k,...s]}function pa(t){var n,r,s;return t.role==="assistant"&&!t.executionTrace&&!((n=t.toolCalls)!=null&&n.length)&&!t.askUser&&!t.isCompactionSummary&&!((s=(r=t.presentation)==null?void 0:r.reasoning)!=null&&s.length)}function Fr(t){var i,a;const n=((i=t==null?void 0:t.history)==null?void 0:i.delivery)==="core",r=ml(t,!n),s=(a=t==null?void 0:t.history)==null?void 0:a.revision;return!n||!s?r:au($d(r,s),(t==null?void 0:t.events)??[])}function nu(t){return ml(t).filter(Od)}function ml(t,n=!0){var y;const r=(t==null?void 0:t.messages)??[],s=(t==null?void 0:t.events)??[],i=new Set(s.filter(m=>m.type==="approval_resolved"&&m.questionId).map(m=>m.questionId)),a=new Map;for(const m of s)m.type==="tool_result"&&((y=m.result)!=null&&y.toolCallId)&&a.set(m.result.toolCallId,{content:m.result.content??"",isError:m.result.isError});const c=r.filter(m=>(m.role==="user"||m.role==="assistant"||m.role==="tool")&&m.name!=="__interrupt__").map(ou),d=new Map;for(const m of c)m.role==="tool"&&m.toolCallId&&d.set(m.toolCallId,m);let u=c.filter(m=>m.role!=="tool").map(m=>{var k;return m.isCompactionSummary?m:m.role==="assistant"&&((k=m.toolCalls)!=null&&k.length)?{...m,toolCalls:m.toolCalls.map(C=>{const E=d.get(C.id);if(E)return{...C,...E.toolResultRef?{resultRef:E.toolResultRef,isError:E.toolResultRef.isError}:{result:E.content}};const A=a.get(C.id);return A?{...C,result:A.content,isError:A.isError}:C})}:m.role==="user"&&m.name&&m.name!=="__compaction_checkpoint__"&&!m.name.startsWith("__native_")?{...m,agentName:m.name}:m});const h=lu(s,n);if(!u.some(m=>m.role==="assistant"&&!m.isCompactionSummary)&&h){const m=u.findLastIndex(k=>k.role==="user"&&!k.isCompactionSummary);u=m>=0?[...u.slice(0,m+1),h,...u.slice(m+1)]:[...u,h]}const g=new Set(u.flatMap(m=>{var k;return(k=m.askUser)!=null&&k.questionId?[m.askUser.questionId]:[]}));for(const m of s)m.type!=="ask_user"||!m.questionId||i.has(m.questionId)||g.has(m.questionId)||(g.add(m.questionId),u.push({id:crypto.randomUUID(),role:"assistant",content:"",askUser:{questionId:m.questionId,question:m.question??"",options:m.options,fields:m.fields,multiSelect:m.multiSelect},timestamp:Date.now()}));return u}function bl(t,n){if(n.length===0)return t;if(t.length===0)return n;const r=t.map(qi),s=n.map(qi),i=Math.max(0,t.length-n.length),a=su(t,n,i);let c={currentStart:i,length:0,distance:1/0};for(let m=0;m<r.length;m++)for(let k=0;k<s.length;k++){if(r[m]!==s[k])continue;const C=m-k;if(C<0)continue;let E=0;for(;m+E<r.length&&k+E<s.length&&r[m+E]===s[k+E];)E+=1;const A=Math.abs(C-i);(E>c.length||E===c.length&&A<c.distance)&&(c={currentStart:C,length:E,distance:A})}const d=a??(c.length>0?c.currentStart:i),u=n.map((m,k)=>{var S,j,v;const C=t[d+k];if(!C||!iu(C,m,s[k]))return m;const E=(j=(S=m.presentation)==null?void 0:S.attachments)==null?void 0:j.some(D=>D.dataUrl),A=(v=m.toolCalls)==null?void 0:v.map(D=>{var R;const V=(R=C.toolCalls)==null?void 0:R.find(T=>T.id===D.id);return(V==null?void 0:V.result)===void 0?D:{...D,result:V.result,isError:V.isError}});return{...m,id:m.id.startsWith("history-message.v1.")?m.id:C.id,timestamp:C.timestamp,images:E?void 0:m.images??C.images,...A?{toolCalls:A}:{}}}),h=t.filter(m=>m.isQueued),g=t.slice(d).filter(m=>!m.isQueued),y=ru(g,u);return[...t.slice(0,d).filter(m=>!m.isQueued),...y,...h]}function ru(t,n){const r=n.findLastIndex(C=>C.role==="user"&&!C.isQueued);if(r<0)return n;const s=ir(n[r]);let i=-1,a=1/0;for(let C=0;C<t.length;C+=1){const E=t[C];if(E.role!=="user"||E.isQueued||ir(E)!==s)continue;const A=Math.abs(C-r);A<a&&(i=C,a=A)}if(i<0)return n;const c=t.findIndex((C,E)=>E>i&&C.role==="user"&&!C.isQueued),d=t.slice(i+1,c<0?t.length:c),u=n.slice(r+1),h=fa(d),g=fa(u);if(h.length<=g.length||!h.startsWith(g))return n;const y=h.slice(g.length),m=n.findLastIndex((C,E)=>{var A;return E>r&&C.role==="assistant"&&!((A=C.toolCalls)!=null&&A.length)&&!C.askUser&&!C.isCompactionSummary});if(m>=0)return n.map((C,E)=>E===m?{...C,content:C.content+y}:C);const k=d.findLast(C=>C.role==="assistant"&&!!C.content&&!C.isCompactionSummary);return[...n,{id:(k==null?void 0:k.id)??crypto.randomUUID(),role:"assistant",content:y,timestamp:(k==null?void 0:k.timestamp)??Date.now()}]}function fa(t){return t.filter(n=>n.role==="assistant"&&!n.isCompactionSummary).map(n=>n.content).join("")}function su(t,n,r){const s=n[0];if((s==null?void 0:s.role)!=="user")return null;const i=ir(s);let a=null;for(let c=0;c<t.length;c+=1){if(t[c].role!=="user"||t[c].isQueued||ir(t[c])!==i)continue;const d=Math.abs(c-r);(!a||d<a.distance)&&(a={start:c,distance:d})}return(a==null?void 0:a.start)??null}function iu(t,n,r){var s,i;return qi(t)===r||t.role==="assistant"&&n.role==="assistant"&&t.content===n.content&&JSON.stringify(((s=t.toolCalls)==null?void 0:s.map(a=>a.id))??[])===JSON.stringify(((i=n.toolCalls)==null?void 0:i.map(a=>a.id))??[])?!0:t.role==="user"&&n.role==="user"&&ir(t)===ir(n)}function ir(t){var n;return JSON.stringify({role:t.role,content:t.content,name:(n=t.name)!=null&&n.startsWith("__native_")?void 0:t.name,agentName:t.agentName,isCompactionSummary:t.isCompactionSummary})}function qi(t){return JSON.stringify({role:t.role,content:t.content,toolCalls:t.toolCalls,toolCallId:t.toolCallId,toolResultRef:t.toolResultRef,name:t.name,agentName:t.agentName,presentation:t.role==="user"?void 0:t.presentation,isCompactionSummary:t.isCompactionSummary})}function ou(t){var n;if(t.name==="__compaction_checkpoint__"){let r="";try{r=JSON.parse(t.content??"{}").summary??""}catch{}return{id:crypto.randomUUID(),role:"user",content:r,name:t.name,isCompactionSummary:!0,timestamp:Date.now()}}return{id:t.historyId??crypto.randomUUID(),role:t.role,content:t.content??"",toolCalls:(n=t.toolCalls)!=null&&n.length?t.toolCalls:void 0,toolCallId:t.toolCallId,toolResultRef:t.toolResultRef,name:t.name,presentation:t.presentation,timestamp:Date.now()}}function au(t,n){return n.reduce((r,s)=>{var a;if(!s.turnId)return r;let i=null;return s.type==="text_chunk"&&s.messagePhase==="commentary"&&typeof s.text=="string"&&s.text?i={type:"text_chunk",text:s.text,turnId:s.turnId,itemId:s.itemId,messagePhase:"commentary"}:s.type==="reasoning_summary_delta"&&s.itemId&&Number.isSafeInteger(s.sectionIndex)&&typeof s.delta=="string"?i={type:"reasoning_summary_delta",turnId:s.turnId,itemId:s.itemId,sectionIndex:s.sectionIndex,delta:s.delta}:s.type==="tool_call"&&s.toolCall?i={type:"tool_call",turnId:s.turnId,toolCall:s.toolCall}:s.type==="tool_result"&&((a=s.result)!=null&&a.toolCallId)&&(i={type:"tool_result",turnId:s.turnId,result:{toolCallId:s.result.toolCallId,content:s.result.content??"",isError:s.result.isError}}),i?Hi(r,s.turnId,i):r},t)}function lu(t,n=!0){var a;let r="";const s=[],i=new Map;for(const c of t){if(c.type==="text_chunk"&&c.text&&(r+=c.text),n&&c.type==="tool_call"&&c.toolCall){const d={id:c.toolCall.id,name:c.toolCall.name,arguments:c.toolCall.arguments};s.push(d),i.set(d.id,d)}if(n&&c.type==="tool_result"&&((a=c.result)!=null&&a.toolCallId)){const d=i.get(c.result.toolCallId);d&&(d.result=c.result.content??"",d.isError=c.result.isError)}}return!r.trim()&&s.length===0?null:{id:crypto.randomUUID(),role:"assistant",content:r.trim(),toolCalls:s.length>0?s:void 0,timestamp:Date.now()}}class cu{constructor(){this.slot=null}prefetch(n,r,s){return this.getOrStart(n,r,s).promise}async consume(n,r,s){const i=this.getOrStart(n,r,s);try{return await i.promise}finally{this.slot===i&&(this.slot=null)}}invalidate(){this.slot=null}getOrStart(n,r,s){var c;if(((c=this.slot)==null?void 0:c.sessionId)===n&&this.slot.cursor===r)return this.slot;let i;try{i=s()}catch(d){i=Promise.reject(d)}const a={sessionId:n,cursor:r,promise:i};return this.slot=a,i.catch(()=>{this.slot===a&&(this.slot=null)}),a}}const yl=60,du=32,uu=240,pu=6,fu=10;function ha(t,n,r,s){if(s<=1||r<=0)return 0;const i=Math.max(0,Math.min(1,(t-n)/r));return Math.round(i*(s-1))}function hu(t){const n=Math.min(Math.max(0,t),yl);return n<=1?n===1?[0]:[]:Array.from({length:n},(r,s)=>Math.round(s/(n-1)*(t-1)))}function ga(t,n=pu){return Math.min(uu,Math.max(du,Math.min(Math.max(0,t),yl)*n))}function gu(t,n,r){if(r<=0)return null;const s=Math.max(5,Math.round(r/10));return n==="ArrowUp"||n==="ArrowLeft"?Math.max(0,t-1):n==="ArrowDown"||n==="ArrowRight"?Math.min(r-1,t+1):n==="PageUp"?Math.max(0,t-s):n==="PageDown"?Math.min(r-1,t+s):n==="Home"?0:n==="End"?r-1:null}function xu({entries:t,activeMessageId:n,loadingMessageId:r,onActivate:s}){const i=t.findIndex(A=>A.messageId===n),a=i>=0?i:Math.max(0,t.length-1),[c,d]=l.useState(a),[u,h]=l.useState(!1),g=l.useRef(!1),y=l.useMemo(()=>hu(t.length),[t.length]);if(l.useEffect(()=>d(a),[a]),t.length<2)return null;const m=Math.min(c,t.length-1),k=t[m],C=r===k.messageId,E=(A,S)=>{const j=S.getBoundingClientRect();d(ha(A,j.top,j.height,t.length))};return e.jsxs("div",{className:`query-navigation-rail${u?" query-navigation-rail--open":""}`,style:{"--query-navigation-rail-height":`${ga(t.length)}px`,"--query-navigation-rail-web-height":`${ga(t.length,fu)}px`},role:"slider",tabIndex:0,"aria-label":"用户消息导航","aria-orientation":"vertical","aria-valuemin":1,"aria-valuemax":t.length,"aria-valuenow":k.ordinal,"aria-valuetext":`第 ${k.ordinal} 条:${k.preview}`,"aria-busy":C||void 0,onPointerEnter:A=>{h(!0),E(A.clientY,A.currentTarget)},onPointerMove:A=>{A.pointerType==="touch"&&!g.current||E(A.clientY,A.currentTarget)},onPointerLeave:()=>{g.current||h(!1)},onPointerDown:A=>{g.current=!0,h(!0),A.currentTarget.setPointerCapture(A.pointerId),E(A.clientY,A.currentTarget)},onPointerUp:A=>{E(A.clientY,A.currentTarget);const S=ha(A.clientY,A.currentTarget.getBoundingClientRect().top,A.currentTarget.getBoundingClientRect().height,t.length);g.current=!1,A.currentTarget.releasePointerCapture(A.pointerId),s(t[S]),A.pointerType==="touch"&&h(!1)},onPointerCancel:()=>{g.current=!1,h(!1)},onFocus:()=>h(!0),onBlur:()=>h(!1),onKeyDown:A=>{if(A.key==="Enter"){A.preventDefault(),s(k);return}const S=gu(m,A.key,t.length);S!==null&&(A.preventDefault(),d(S))},children:[e.jsxs("div",{className:"query-navigation-rail__track","aria-hidden":"true",children:[y.map(A=>e.jsx("span",{className:`query-navigation-rail__tick${A===m?" is-selected":""}${t[A].messageId===n?" is-active":""}`},A)),e.jsx("span",{className:"query-navigation-rail__marker",style:{top:`${m/Math.max(1,t.length-1)*100}%`}})]}),C&&e.jsx("span",{className:"query-navigation-rail__loading",role:"status","aria-label":"正在定位消息",children:e.jsx(Dt,{size:14,"aria-hidden":"true"})}),u&&e.jsxs("div",{className:"query-navigation-rail__preview",role:"status",children:[e.jsxs("span",{children:[k.ordinal," / ",t.length]}),e.jsx("p",{children:k.preview})]})]})}const mu=/^(?:load failed|failed to fetch|network request failed|networkerror when attempting to fetch resource\.?|the network connection was lost\.?|fetch failed)$/i;function vl(t){return t instanceof Error&&t.name!=="AbortError"&&mu.test(t.message.trim())}function bu(t){return vl(t)?"网络连接中断,会话加载失败,请重新加载":t instanceof Error?t.message:"会话加载失败"}async function yu(t,n={}){const r=Math.max(1,Math.floor(n.maxAttempts??4)),s=Math.max(0,n.baseDelayMs??500),i=n.sleep??(a=>new Promise(c=>{setTimeout(c,a)}));for(let a=1;a<=r;a+=1)try{return await t()}catch(c){if(a===r||!vl(c))throw c;await i(s*2**(a-1))}throw new Error("会话加载失败")}const vu=2048,wu=2*1024*1024,ju=.85;function ku(t,n,r=vu){const s=Math.max(t,n);if(s<=r)return{width:t,height:n};const i=r/s;return{width:Math.max(1,Math.round(t*i)),height:Math.max(1,Math.round(n*i))}}async function xa(t,n=Su){if(t.type.toLowerCase()==="image/gif")return t;let r=null;try{r=await n.decode(t);const s=ku(r.width,r.height);if(!(s.width!==r.width||s.height!==r.height)&&t.size<=wu)return t;const a=t.type.toLowerCase()==="image/jpeg"?"image/jpeg":"image/webp",c=await n.encode(r,s.width,s.height,a,ju);return c&&c.size<t.size?c:t}catch{return t}finally{r==null||r.dispose()}}const Su={decode(t){return new Promise((n,r)=>{const s=URL.createObjectURL(t),i=new Image;let a=!1;const c=()=>URL.revokeObjectURL(s);i.onload=()=>{a=!0,n({source:i,width:i.naturalWidth,height:i.naturalHeight,dispose:c})},i.onerror=()=>{a||c(),r(new Error("无法解码图片"))},i.src=s})},encode(t,n,r,s,i){const a=document.createElement("canvas");a.width=n,a.height=r;const c=a.getContext("2d");return c?(c.drawImage(t.source,0,0,n,r),new Promise(d=>a.toBlob(d,s,i))):Promise.resolve(null)}};function Iu(t){return t==="customer-agent"||t==="claude-code"}function Cu(t){if(typeof document>"u"||!document.body||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly",""),Object.assign(n.style,{position:"fixed",top:"0",left:"-9999px",width:"1px",height:"1px",fontSize:"16px",opacity:"0",pointerEvents:"none"}),document.body.appendChild(n);try{return n.focus(),n.select(),n.setSelectionRange(0,n.value.length),document.execCommand("copy")}catch{return!1}finally{n.remove()}}async function yi(t){const n=typeof navigator>"u"?void 0:navigator.clipboard;if(typeof(n==null?void 0:n.writeText)=="function"&&(typeof isSecureContext>"u"||isSecureContext))try{return await n.writeText(t),!0}catch{}return Cu(t)}const Ru="agentroam:draft:";function Hs(t){return`${Ru}${t}`}function Au(t){if(!t||typeof window>"u")return"";try{return window.localStorage.getItem(Hs(t))??""}catch{return""}}function vi(t,n){if(!(!t||typeof window>"u"))try{n?window.localStorage.setItem(Hs(t),n):window.localStorage.removeItem(Hs(t))}catch{}}function Mu(t){if(!(!t||typeof window>"u"))try{window.localStorage.removeItem(Hs(t))}catch{}}const Eu="agent-webapp:artifact-open:v1";let ma=0;function ba(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(t)}function wl(t,n){const r=t.trim();if(!r||/[\0\r\n]/.test(r))return null;if(ba(r))return r;if(!n||!ba(n))return null;const s=r.replaceAll("\\","/").split("/").filter(a=>a&&a!==".");if(s.length===0||s.some(a=>a===".."))return null;const i=/^[A-Za-z]:[\\/]/.test(n)||n.startsWith("\\\\")?"\\":"/";return`${n.replace(/[\\/]+$/,"")}${i}${s.join(i)}`}function Sr(t,n=window){return n.parent===n?!1:(ma+=1,n.parent.postMessage({type:Eu,requestId:ma,path:t},n.location.origin),!0)}function Tu(t){var n;return((n=[...t].reverse().find(r=>r.role==="user"&&!r.isQueued))==null?void 0:n.id)??null}function Nu(t,n){const r=new Set(n.flatMap(s=>s.sourceMessageId?[s.sourceMessageId]:[]));return r.size===0?t:t.filter(s=>!r.has(s.id))}function wi(t,n){var c,d,u;const r=t.filter(h=>!h.isQueued),s=new Map(t.filter(h=>h.isQueued&&h.queueItemId).map(h=>[h.queueItemId,h])),i=((c=n.active)==null?void 0:c.kind)==="message"?n.active:null;if(i){const h=s.get(i.id),g=i.sourceMessageId||(h==null?void 0:h.id)||i.id,y=r.findLastIndex(E=>E.role==="user"),m=r.findLastIndex((E,A)=>E.id===g||E.queueItemId===i.id||!h&&A===y&&E.role==="user"&&E.content===i.objective),k=m>=0?r[m]:h,C={...k??{},id:(k==null?void 0:k.id)||g,role:"user",content:i.objective,timestamp:(k==null?void 0:k.timestamp)??i.createdAt,agentName:(k==null?void 0:k.agentName)??((d=i.messagePayload)==null?void 0:d.agentName),images:(k==null?void 0:k.images)??((u=i.messagePayload)==null?void 0:u.images),isQueued:!1,queueItemId:void 0};m>=0?r[m]=C:r.push(C)}const a=n.queued.filter(h=>h.kind==="message").map(h=>{var y,m;const g=s.get(h.id);return{...g??{},id:h.sourceMessageId||(g==null?void 0:g.id)||h.id,role:"user",content:h.objective,timestamp:(g==null?void 0:g.timestamp)??h.createdAt,agentName:(y=h.messagePayload)==null?void 0:y.agentName,images:(m=h.messagePayload)==null?void 0:m.images,isQueued:!0,queueItemId:h.id}});return[...r,...a]}function ya(t){var n;return{active:((n=t.active)==null?void 0:n.kind)==="message"?null:t.active,queued:t.queued.filter(r=>r.kind!=="message"),history:t.history.filter(r=>r.kind!=="message")}}function zu(t,n,r){if(n===r)return t;const s=t.filter(h=>h.isQueued),i=s.findIndex(h=>h.id===n),a=s.findIndex(h=>h.id===r);if(i<0||a<0)return t;const c=[...s],[d]=c.splice(i,1);c.splice(a,0,d);let u=0;return t.map(h=>h.isQueued?c[u++]:h)}function Lu(t,n){return((t==null?void 0:t.agentType)??n)!=="customer-agent"}function eo(t){return(t==null?void 0:t.agentType)!==void 0&&t.agentType!=="customer-agent"&&t.status==="running"}function _u(t){return eo(t)&&(t==null?void 0:t.occupancy)==="owned-externally"}function jl(t){return eo(t)&&(t==null?void 0:t.occupancy)!=="owned-externally"}function Pu(t){return(t==null?void 0:t.agentType)==="customer-agent"&&t.status==="active"}function Wu(t,n){return n||jl(t)}function Du(t,n,r){return!!(n&&t&&t.agentType!=="customer-agent")}function Ls(t,n){return t.find(r=>r.id===n)??null}const Ks=Za((t,n)=>({modelProvider:"anthropic",modelId:"claude-sonnet-4-6",apiKey:"",baseUrl:"",maxIterations:10,contextWindow:100,workingDirectory:"/",isConfigured:!1,profiles:[],activeProfileId:"",reasoningEffort:"off",setField:(r,s)=>t(i=>{const a={...i,[r]:s};return a.isConfigured=!!(a.apiKey&&a.modelId),a}),loadFromSystem:async()=>{if(window.agentApi)try{const r=await window.agentApi.getSettings(),s=r.profiles??[],i=r.activeProfileId??"",a=Ls(s,i);t({revision:r.revision,modelProvider:(a==null?void 0:a.provider)??r.modelProvider??"anthropic",modelId:(a==null?void 0:a.modelId)??r.modelId??"claude-sonnet-4-6",apiKey:(a==null?void 0:a.apiKey)??r.apiKey??"",baseUrl:(a==null?void 0:a.baseUrl)??r.baseUrl??"",maxIterations:r.maxIterations??10,contextWindow:r.contextWindow??100,workingDirectory:r.workingDirectory??"/",isConfigured:!!(((a==null?void 0:a.apiKey)??r.apiKey)&&((a==null?void 0:a.modelId)??r.modelId)),profiles:s,activeProfileId:i,reasoningEffort:["off","low","medium","high"].includes(r.reasoningEffort??"")?r.reasoningEffort:"off"})}catch(r){console.error("Failed to load settings:",r)}},saveToSystem:async()=>{if(!window.agentApi)return;const r=n();await window.agentApi.saveSettings({revision:r.revision,modelProvider:r.modelProvider,modelId:r.modelId,apiKey:r.apiKey,baseUrl:r.baseUrl,maxIterations:r.maxIterations,contextWindow:r.contextWindow,workingDirectory:r.workingDirectory,isConfigured:r.isConfigured,profiles:r.profiles,activeProfileId:r.activeProfileId,reasoningEffort:r.reasoningEffort}),await n().loadFromSystem()},addProfile:r=>{const i={id:crypto.randomUUID(),...r};t(a=>({profiles:[...a.profiles,i]}))},updateProfile:(r,s)=>{t(a=>({profiles:a.profiles.map(c=>c.id===r?{...c,...s}:c)}));const i=n();if(i.activeProfileId===r){const a=Ls(i.profiles,r);a&&t({modelProvider:a.provider,modelId:a.modelId,apiKey:a.apiKey,baseUrl:a.baseUrl,isConfigured:!!(a.apiKey&&a.modelId)})}},deleteProfile:r=>{t(s=>{var d;const i=s.profiles.filter(u=>u.id!==r),a=s.activeProfileId===r?((d=i[0])==null?void 0:d.id)??"":s.activeProfileId,c=Ls(i,a);return{profiles:i,activeProfileId:a,...c?{modelProvider:c.provider,modelId:c.modelId,apiKey:c.apiKey,baseUrl:c.baseUrl,isConfigured:!!(c.apiKey&&c.modelId)}:{},...c?{}:{modelProvider:"anthropic",modelId:"",apiKey:"",baseUrl:"",isConfigured:!1}}})},setActiveProfileLocal:r=>{const s=n(),i=Ls(s.profiles,r);i&&t({activeProfileId:r,modelProvider:i.provider,modelId:i.modelId,apiKey:i.apiKey,baseUrl:i.baseUrl,isConfigured:!!(i.apiKey&&i.modelId)})},switchActiveProfile:async r=>{window.agentApi&&(await window.agentApi.setActiveProfile(r),await n().loadFromSystem())}}));function Gr(t){return t.result!==void 0||t.resultRef!==void 0}function ji(t){return t.every(Gr)}const to=new Set(["shell","bash","Bash","execute_command","run_command","BashOutput","KillShell"]),kl=new Set(["Read","read_file","Write","write_file","Edit","MultiEdit","str_replace","apply_patch","NotebookEdit"]),Sl=new Set(["Glob","glob_search","Grep","grep_search","WebSearch","WebFetch"]),Bu=new Set(["Read","read_file"]),$u=new Set(["Write","write_file","Edit","MultiEdit","str_replace","apply_patch","NotebookEdit"]);function no(t){return to.has(t)?"command":kl.has(t)?"file":Sl.has(t)?"search":"generic"}function ro(t){switch(t){case"shell":case"bash":case"Bash":case"execute_command":case"run_command":return{done:"运行了命令",doing:"运行命令中"};case"BashOutput":case"KillShell":return{done:"查看了命令输出",doing:"查看输出中"};case"Read":case"read_file":return{done:"读取了文件",doing:"读取文件中"};case"Write":case"write_file":return{done:"写入了文件",doing:"写入文件中"};case"Edit":case"MultiEdit":case"str_replace":case"apply_patch":return{done:"修改了文件",doing:"修改文件中"};case"Glob":case"glob_search":return{done:"搜索了文件",doing:"搜索文件中"};case"Grep":case"grep_search":return{done:"搜索了内容",doing:"搜索内容中"};case"Skill":return{done:"调用了技能",doing:"调用技能中"};case"Task":return{done:"启动了子任务",doing:"启动子任务中"};case"WebSearch":return{done:"搜索了网络",doing:"搜索网络中"};case"WebFetch":return{done:"读取了网页",doing:"读取网页中"};case"TodoWrite":return{done:"更新了任务清单",doing:"更新任务清单中"};case"NotebookEdit":return{done:"编辑了 Notebook",doing:"编辑 Notebook 中"};default:return t.startsWith("mcp__")||t.includes(":")?{done:"调用了工具",doing:"调用工具中"}:null}}function Ou(t){var n;return((n=ro(t))==null?void 0:n.done)??null}function Il(t){return to.has(t)?"终端":Bu.has(t)?"查阅":$u.has(t)?"写入":Sl.has(t)?"查阅":t==="Skill"?"技能":t==="Task"||t==="dispatch_agent"||t==="Agent"?"子任务":t==="TodoWrite"?"任务":t.startsWith("mcp__")||t.includes(":")?"工具":null}function va(t){return t.replace(/\\/g,"/").split("/").pop()??t}function ki(t,n=60){const r=(t??"").split(`
|
|
346
|
+
`)[0].trim();return r.length>n?r.slice(0,n)+"…":r}function Fu(t,n){if(to.has(t))return ki(String(n.command??""));if(t==="apply_patch"){const s=(Array.isArray(n.changes)?n.changes:[]).map(i=>va(String((i==null?void 0:i.path)??""))).filter(Boolean);return s.length?s.length<=3?s.join("、"):`${s.slice(0,3).join("、")} 等 ${s.length} 个文件`:null}return kl.has(t)?n.file_path?va(String(n.file_path)):null:t==="Glob"||t==="glob_search"?String(n.pattern??"")||null:t==="Grep"||t==="grep_search"?String(n.pattern??n.query??"")||null:t==="Skill"?String(n.skill??"")||null:t==="Task"?ki(String(n.description??n.task??""),80)||null:t==="WebSearch"?ki(String(n.query??"")):t==="WebFetch"?String(n.url??"")||null:t.startsWith("mcp__")?t.split("__").slice(1).join("/"):t.includes(":")?t.split(":").slice(1).join(":"):null}function Hu(t,n){return Math.max(0,Math.floor((n-t)/1e3))}function so({startedAt:t}){const[n,r]=l.useState(()=>Date.now());return l.useEffect(()=>{r(Date.now());const s=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(s)},[t]),e.jsxs("span",{className:"activity-elapsed-time",children:[" · 持续了 ",Hu(t,n)," 秒"]})}function Cl({progress:t,compact:n=!1,startedAt:r}){const s=t.detail??(t.elapsedSeconds===void 0?void 0:`${Math.round(t.elapsedSeconds)} 秒`),i=[t.label,s].filter(Boolean).join(","),a=!n&&t.phase==="thinking",c=!n&&t.phase==="status",d=a&&r!==void 0&&s===void 0;return e.jsxs("div",{className:`runtime-progress-row${n?" runtime-progress-row--compact":""}`,role:"status","aria-live":"polite","aria-label":i,children:[a?e.jsx("span",{className:"runtime-progress-row__brain","aria-hidden":"true",children:e.jsx(Yi,{size:17,strokeWidth:1.8})}):c?e.jsx("span",{className:"runtime-progress-row__status-icon","aria-hidden":"true",children:e.jsx(Dt,{size:17,strokeWidth:1.8})}):e.jsx("span",{className:"runtime-progress-row__spinner","aria-hidden":"true"}),e.jsx("span",{className:"runtime-progress-row__label",children:t.label}),s&&e.jsx("span",{className:"runtime-progress-row__detail",children:s}),d&&e.jsx(so,{startedAt:r})]})}function Qr({isDone:t,isError:n,color:r,size:s=11}){return t?n?e.jsx(Bc,{size:s,color:r,strokeWidth:2.5,"aria-hidden":"true"}):e.jsx(Ur,{size:s,color:r,strokeWidth:2.5,"aria-hidden":"true"}):e.jsx(Dt,{size:s,color:r,strokeWidth:2.5,style:{animation:"spin 1s linear infinite",flexShrink:0},"aria-hidden":"true"})}function ws({name:t,color:n,size:r=14}){const s=no(t);return s==="command"?e.jsx(md,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):s==="search"?e.jsx(sl,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):s==="file"?t==="Read"||t==="read_file"?e.jsx(Vs,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):e.jsx(nl,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):t==="Skill"?e.jsx(xd,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):t==="TodoWrite"?e.jsx(nd,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):t==="Task"||t==="dispatch_agent"||t==="Agent"?e.jsx(vd,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"}):e.jsx(il,{size:r,color:n,strokeWidth:1.8,"aria-hidden":"true"})}function Gs({statusColor:t,isDone:n,expanded:r,onToggle:s,header:i,children:a,maxBodyHeight:c=600,primaryAction:d,primaryActionLabel:u,primaryActionTitle:h}){const g=e.jsxs("button",{type:"button",className:"tool-call-shell__header",...d?{onClick:d,"aria-label":u,title:h}:{onClick:s,"aria-expanded":r},style:{flex:1,border:"none",background:"var(--bg-deep)",cursor:"pointer",padding:"7px 10px 7px 9px",display:"flex",alignItems:"center",gap:7,fontFamily:"var(--font-body)",transition:"background 0.12s",textAlign:"left",minWidth:0},onMouseEnter:y=>y.currentTarget.style.background="var(--bg-elevated)",onMouseLeave:y=>y.currentTarget.style.background="var(--bg-deep)",children:[i,!d&&e.jsx(Vr,{className:"tool-call-shell__chevron",size:12,color:"var(--text-muted)",strokeWidth:2.2,style:{transition:"transform 0.25s var(--ease-out)",transform:r?"rotate(90deg)":"rotate(0deg)",flexShrink:0},"aria-hidden":"true"})]});return e.jsxs("div",{className:"tool-call-shell",style:{marginTop:4,borderRadius:9,border:"1px solid var(--border-subtle)",overflow:"hidden",background:"var(--bg-deepest)",fontSize:12,minWidth:0},children:[e.jsxs("div",{className:"tool-call-shell__row",style:{display:"flex",alignItems:"stretch"},children:[e.jsx("div",{className:"tool-call-shell__status",style:{width:3,flexShrink:0,background:t,animation:n?"none":"statusBarPulse 1.8s ease-in-out infinite",borderRadius:"9px 0 0 0"}}),g,d&&e.jsx("button",{type:"button",className:"tool-call-shell__disclosure",onClick:s,"aria-expanded":r,"aria-label":r?"收起工具详情":"展开工具详情",title:r?"收起工具详情":"展开工具详情",children:e.jsx(Vr,{className:"tool-call-shell__chevron",size:12,strokeWidth:2.2,style:{transition:"transform 0.25s var(--ease-out)",transform:r?"rotate(90deg)":"rotate(0deg)"},"aria-hidden":"true"})})]}),r&&e.jsx("div",{className:"tool-call-shell__body",style:{overflow:"hidden",maxHeight:c,opacity:1,transition:"max-height 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease"},children:e.jsx("div",{className:"tool-call-shell__body-content",style:{borderTop:"1px solid var(--border-subtle)",padding:"10px 12px",display:"flex",flexDirection:"column",gap:8,boxSizing:"border-box",maxWidth:"100%"},children:a})})]})}function vs({label:t,color:n="var(--text-muted)",bg:r="var(--bg-surface)"}){return e.jsx("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:20,background:r,color:n,fontWeight:500,flexShrink:0,whiteSpace:"nowrap"},children:t})}function Bn(t){return t.replace(/\\/g,"/").split("/").pop()??t}function Rl(t){return t?t.split(`
|
|
347
|
+
`).length:0}function Qs(t,n,r=!1){const[s,i]=l.useState(r),[a,c]=l.useState(!1),[d,u]=l.useState(null),h=async()=>{if(!(!t.resultRef||t.result!==void 0||a||!n)){c(!0),u(null);try{await n(t.resultRef)}catch(y){u(y instanceof Error?y.message:"工具结果加载失败")}finally{c(!1)}}};return{expanded:s,setExpanded:i,toggle:()=>{const y=!s;i(y),y&&h()},loadingResult:a,resultError:d,loadResult:h}}function Ys({toolCall:t,loading:n,error:r,retry:s}){return!t.resultRef||t.result!==void 0?null:r?e.jsx("button",{type:"button",onClick:()=>void s(),className:"ui-text-button",children:"重新加载工具结果"}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--text-muted)",fontSize:11},children:[e.jsx(Dt,{size:11,strokeWidth:2.2,style:{animation:n?"spin 1s linear infinite":"none"},"aria-hidden":"true"}),n?"正在加载工具结果":`${t.resultRef.byteSize.toLocaleString()} 字节,展开后加载`]})}function Al(t,n){const r=t.split(`
|
|
348
|
+
`),s=n.split(`
|
|
349
|
+
`);if(r.length*s.length>2e5)return s.map((k,C)=>({type:"added",text:k,lineNo:C+1}));const i=r.length,a=s.length,c=Array.from({length:i+1},()=>new Array(a+1).fill(0));for(let k=1;k<=i;k++)for(let C=1;C<=a;C++)c[k][C]=r[k-1]===s[C-1]?c[k-1][C-1]+1:Math.max(c[k-1][C],c[k][C-1]);const d=[];let u=i,h=a;for(;u>0&&h>0;)r[u-1]===s[h-1]?(d.unshift([u-1,h-1]),u--,h--):c[u-1][h]>=c[u][h-1]?u--:h--;const g=[];let y=0,m=0;for(const[k,C]of d){for(;y<k;)g.push({type:"removed",text:r[y],lineNo:y+1}),y++;for(;m<C;)g.push({type:"added",text:s[m],lineNo:m+1}),m++;g.push({type:"same",text:r[y],lineNo:y+1}),y++,m++}for(;y<i;)g.push({type:"removed",text:r[y],lineNo:y+1}),y++;for(;m<a;)g.push({type:"added",text:s[m],lineNo:m+1}),m++;return g}function Ml({content:t,maxHeight:n=320}){const r=t.split(`
|
|
350
|
+
`);return e.jsx("div",{style:{background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:n,fontFamily:"var(--font-mono)",fontSize:11,lineHeight:1.65},children:e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:40}}),e.jsx("col",{})]}),e.jsx("tbody",{children:r.map((s,i)=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"0 8px",color:"var(--text-muted)",textAlign:"right",userSelect:"none",borderRight:"1px solid var(--border-subtle)",background:"var(--bg-deep)",fontSize:10,minWidth:36},children:i+1}),e.jsx("td",{style:{padding:"0 12px",color:"var(--text-secondary)",wordBreak:"break-all",whiteSpace:"pre-wrap"},children:s||" "})]},i))})]})})}function El({diff:t,maxHeight:n=360}){if(t.filter(d=>d.type!=="same").length===0)return e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",padding:"10px 12px",fontFamily:"var(--font-mono)"},children:"内容未变化"});const s=new Set(t.map((d,u)=>d.type!=="same"?u:-1).filter(d=>d>=0)),i=new Set;s.forEach(d=>{for(let u=Math.max(0,d-3);u<=Math.min(t.length-1,d+3);u++)i.add(u)});const a=[];let c=-1;return[...i].sort((d,u)=>d-u).forEach(d=>{c>=0&&d>c+1&&a.push("ellipsis"),a.push({diffLine:t[d],diffIdx:d}),c=d}),e.jsx("div",{style:{background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderRadius:8,overflow:"auto",maxHeight:n,fontFamily:"var(--font-mono)",fontSize:11,lineHeight:1.65},children:e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:24}}),e.jsx("col",{style:{width:36}}),e.jsx("col",{})]}),e.jsx("tbody",{children:a.map((d,u)=>{if(d==="ellipsis")return e.jsx("tr",{children:e.jsx("td",{colSpan:3,style:{padding:"2px 12px",color:"var(--text-muted)",fontSize:10,background:"var(--bg-deep)",textAlign:"center"},children:"⋯"})},`e${u}`);const{diffLine:h}=d,g=h.type==="added"?"rgba(5,150,105,0.08)":h.type==="removed"?"rgba(220,38,38,0.07)":"transparent",y=h.type==="added"?"+":h.type==="removed"?"−":" ",m=h.type==="added"?"var(--success)":h.type==="removed"?"var(--danger)":"transparent",k=h.type==="added"?"#059669":h.type==="removed"?"var(--danger)":"var(--text-secondary)";return e.jsxs("tr",{style:{background:g},children:[e.jsx("td",{style:{padding:"0 4px",textAlign:"center",color:m,fontWeight:700,userSelect:"none"},children:y}),e.jsx("td",{style:{padding:"0 6px",color:"var(--text-muted)",textAlign:"right",fontSize:10,borderRight:"1px solid var(--border-subtle)",userSelect:"none"},children:h.lineNo}),e.jsx("td",{style:{padding:"0 12px",color:k,wordBreak:"break-all",whiteSpace:"pre-wrap"},children:h.text||" "})]},u)})})]})})}function Uu({toolCall:t,beforeContent:n,previewPath:r,onLoadResult:s}){const i=Qs(t,s),{expanded:a}=i,[c,d]=l.useState("content"),u=t.arguments.file_path??"",h=t.arguments.content??"",g=Rl(h),y=t.isError,m=Gr(t),k=m?y?"var(--danger)":"var(--success)":"var(--accent)",C=l.useMemo(()=>n&&h?Al(n,h):null,[n,h]),E=l.useMemo(()=>C?{added:C.filter(j=>j.type==="added").length,removed:C.filter(j=>j.type==="removed").length}:null,[C]),A=y?"var(--danger)":m?"var(--text-muted)":"var(--accent)",S=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tool-call-shell__icon",children:e.jsx(ws,{name:t.name,color:A})}),e.jsx("span",{className:"tool-call-shell__label",children:"写入"}),e.jsx("span",{className:"tool-call-shell__preview",style:{flex:1},title:u,children:Bn(u)}),e.jsx(vs,{label:`${g} 行`,color:"var(--accent)",bg:"var(--accent-dim)"}),E&&e.jsxs("span",{style:{display:"flex",gap:3,fontSize:10,flexShrink:0},children:[E.added>0&&e.jsxs("span",{style:{color:"var(--success)"},children:["+",E.added]}),E.removed>0&&e.jsxs("span",{style:{color:"var(--danger)"},children:["−",E.removed]})]}),(!m||y)&&e.jsxs("span",{className:"tool-call-shell__state",style:{color:k},children:[e.jsx(Qr,{isDone:m,isError:y,color:k}),y&&e.jsx("span",{children:"错误"})]})]});return e.jsxs(Gs,{statusColor:k,isDone:m,expanded:a,onToggle:i.toggle,header:S,primaryAction:r?()=>Sr(r):void 0,primaryActionLabel:r?`预览文件 ${Bn(r)}`:void 0,primaryActionTitle:r?`预览 ${r}`:void 0,children:[e.jsx(Ys,{toolCall:t,loading:i.loadingResult,error:i.resultError,retry:i.loadResult}),e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:u}),C&&e.jsx("div",{style:{display:"flex",gap:3},children:["content","diff"].map(j=>e.jsx("button",{onClick:()=>d(j),style:{padding:"2px 9px",borderRadius:5,border:"none",cursor:"pointer",fontSize:11,fontWeight:500,background:c===j?"var(--accent-dim)":"transparent",color:c===j?"var(--accent)":"var(--text-muted)",transition:"background 0.12s"},children:j==="content"?"文件内容":"变更行"},j))}),c==="diff"&&C?e.jsx(El,{diff:C}):e.jsx(Ml,{content:h}),y&&t.result&&e.jsx("div",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 12px",background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.15)",borderLeft:"3px solid var(--danger)",borderRadius:7},children:t.result})]})}function qu({toolCall:t,previewPath:n,onLoadResult:r}){const s=Qs(t,r),{expanded:i}=s,a=t.arguments.file_path??"",c=t.arguments.startLine,d=t.arguments.endLine,u=t.arguments.offset,h=t.arguments.limit,g=t.result??"",y=Rl(g),m=t.isError,k=Gr(t),C=k?m?"var(--danger)":"var(--success)":"var(--accent)",E=c!==void 0?`L${c}–${d??"?"}`:u!==void 0?`第${u}行起${h?` ×${h}`:""}`:null,A=m?"var(--danger)":k?"var(--text-muted)":"var(--accent)",S=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tool-call-shell__icon",children:e.jsx(ws,{name:t.name,color:A})}),e.jsx("span",{className:"tool-call-shell__label",children:"查阅"}),e.jsx("span",{className:"tool-call-shell__preview",style:{flex:1},title:a,children:Bn(a)}),E&&e.jsx(vs,{label:E,color:"var(--accent)",bg:"var(--accent-dim)"}),k&&!m&&e.jsx(vs,{label:`${y} 行`,color:"var(--text-muted)",bg:"var(--bg-surface)"}),(!k||m)&&e.jsxs("span",{className:"tool-call-shell__state",style:{color:C},children:[e.jsx(Qr,{isDone:k,isError:m,color:C}),m&&e.jsx("span",{children:"错误"})]})]});return e.jsxs(Gs,{statusColor:C,isDone:k,expanded:i,onToggle:s.toggle,header:S,maxBodyHeight:480,primaryAction:n?()=>Sr(n):void 0,primaryActionLabel:n?`预览文件 ${Bn(n)}`:void 0,primaryActionTitle:n?`预览 ${n}`:void 0,children:[e.jsx(Ys,{toolCall:t,loading:s.loadingResult,error:s.resultError,retry:s.loadResult}),e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:a}),k&&!m?e.jsx(Ml,{content:g}):k&&m&&e.jsx("div",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 12px",background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.15)",borderLeft:"3px solid var(--danger)",borderRadius:7},children:g})]})}function Vu({toolCall:t,previewPath:n,onLoadResult:r}){const s=Qs(t,r),{expanded:i}=s,a=t.arguments.file_path??"",c=t.arguments.old_string??"",d=t.arguments.new_string??"",u=t.isError,h=Gr(t),g=h?u?"var(--danger)":"var(--success)":"var(--accent)",y=u?"var(--danger)":h?"var(--text-muted)":"var(--accent)",m=l.useMemo(()=>c&&d?Al(c,d):null,[c,d]),k=l.useMemo(()=>m?{added:m.filter(E=>E.type==="added").length,removed:m.filter(E=>E.type==="removed").length}:null,[m]),C=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tool-call-shell__icon",children:e.jsx(ws,{name:t.name,color:y})}),e.jsx("span",{className:"tool-call-shell__label",children:"写入"}),e.jsx("span",{className:"tool-call-shell__preview",style:{flex:1},title:a,children:Bn(a)}),k&&e.jsxs("span",{style:{display:"flex",gap:3,fontSize:10,flexShrink:0},children:[k.added>0&&e.jsxs("span",{style:{color:"var(--success)"},children:["+",k.added]}),k.removed>0&&e.jsxs("span",{style:{color:"var(--danger)"},children:["−",k.removed]})]}),(!h||u)&&e.jsxs("span",{className:"tool-call-shell__state",style:{color:g},children:[e.jsx(Qr,{isDone:h,isError:u,color:g}),u&&e.jsx("span",{children:"错误"})]})]});return e.jsxs(Gs,{statusColor:g,isDone:h,expanded:i,onToggle:s.toggle,header:C,maxBodyHeight:480,primaryAction:n?()=>Sr(n):void 0,primaryActionLabel:n?`预览文件 ${Bn(n)}`:void 0,primaryActionTitle:n?`预览 ${n}`:void 0,children:[e.jsx(Ys,{toolCall:t,loading:s.loadingResult,error:s.resultError,retry:s.loadResult}),e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:a}),m?e.jsx(El,{diff:m}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("pre",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 10px",borderRadius:6,background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.12)",borderLeft:"3px solid var(--danger)",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:c}),e.jsx("pre",{style:{fontSize:11,color:"var(--success)",fontFamily:"var(--font-mono)",padding:"8px 10px",borderRadius:6,background:"rgba(5,150,105,0.04)",border:"1px solid rgba(5,150,105,0.12)",borderLeft:"3px solid var(--success)",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:d})]}),u&&t.result&&e.jsx("div",{style:{fontSize:11,color:"var(--danger)",fontFamily:"var(--font-mono)",padding:"8px 10px",background:"rgba(220,38,38,0.04)",border:"1px solid rgba(220,38,38,0.15)",borderLeft:"3px solid var(--danger)",borderRadius:7},children:t.result})]})}function qr({label:t,content:n,error:r,maxPreviewLines:s=8,maxPreviewHeight:i=200,maxExpandedHeight:a=2e3}){const[c,d]=l.useState(!1),u=n.split(`
|
|
351
|
+
`),h=u.length>s,g=h&&!c?u.slice(0,s).join(`
|
|
352
|
+
`)+`
|
|
353
|
+
...`:n;return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:5},children:t}),e.jsx("pre",{style:{fontSize:11,color:r?"var(--danger)":"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",padding:"9px 11px",borderRadius:7,boxSizing:"border-box",maxWidth:"100%",background:r?"rgba(220,38,38,0.04)":"var(--bg-surface)",border:r?"1px solid rgba(220,38,38,0.15)":"1px solid var(--border-subtle)",borderLeft:r?"3px solid var(--danger)":"3px solid var(--success)",maxHeight:c?a:i,overflow:"auto",margin:0,lineHeight:1.6},children:g}),h&&e.jsx("button",{onClick:()=>d(!c),style:{marginTop:4,padding:"2px 10px",borderRadius:5,border:"1px solid var(--border-subtle)",background:"var(--bg-deep)",color:"var(--text-muted)",fontSize:10,cursor:"pointer",fontWeight:500},children:c?"收起":`展开全部 (${u.length} 行)`})]})}function Ku({arguments:t}){var r;const n=t.task??"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,padding:"6px 0"},children:[e.jsxs("div",{style:{display:"flex",gap:8,fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",flexWrap:"wrap"},children:[e.jsx(vs,{label:`agent: ${t.agentName}`,color:"var(--accent)",bg:"var(--accent-dim)"}),e.jsx(vs,{label:`sid: ${(r=t.subSessionId)==null?void 0:r.slice(0,8)}…`,color:"var(--text-muted)",bg:"var(--bg-surface)"})]}),n&&e.jsx(qr,{label:"任务",content:n,error:!1,maxPreviewLines:3,maxPreviewHeight:80,maxExpandedHeight:2e3})]})}function Gu({raw:t}){const[n,r]=l.useState(!1);let s;try{const u=JSON.parse(t);delete u.subAgentProgress,delete u.subAgentStatus,delete u.subAgentDetail,s=JSON.stringify(u,null,2)}catch{s=t}const i=8,a=s.split(`
|
|
354
|
+
`),c=a.length>i,d=c&&!n?a.slice(0,i).join(`
|
|
355
|
+
`)+`
|
|
356
|
+
...`:s;return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:5},children:"参数"}),e.jsx("pre",{style:{fontSize:11,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",padding:"9px 11px",borderRadius:7,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",maxHeight:n?2e3:200,overflow:"auto",margin:0,lineHeight:1.6,boxSizing:"border-box",maxWidth:"100%"},children:d}),c&&e.jsx("button",{onClick:()=>r(!n),style:{marginTop:4,padding:"2px 10px",borderRadius:5,border:"1px solid var(--border-subtle)",background:"var(--bg-deep)",color:"var(--text-muted)",fontSize:10,cursor:"pointer",fontWeight:500},children:n?"收起":`展开全部 (${a.length} 行)`})]})}function Qu({activity:t,workspacePath:n,enableFilePreview:r}){const s=new Map(t.messages.flatMap(i=>i.role==="tool"&&i.toolCallId?[[i.toolCallId,{content:i.content,isError:i.name==="error"}]]:[]));return e.jsxs("div",{className:"native-subagent-activity",children:[e.jsxs("div",{className:"native-subagent-activity__meta",children:[t.elapsedSeconds!==void 0&&e.jsxs("span",{children:[t.elapsedSeconds," 秒"]}),t.toolUses!==void 0&&e.jsxs("span",{children:[t.toolUses," 次工具调用"]}),t.lastToolName&&e.jsxs("span",{children:["正在使用 ",t.lastToolName]})]}),t.messages.map((i,a)=>{var c;return e.jsxs("div",{className:"native-subagent-activity__entry",children:[i.role==="assistant"&&i.content&&e.jsx("pre",{className:"native-subagent-activity__text",children:i.content}),i.role==="assistant"&&((c=i.toolCalls)==null?void 0:c.map(d=>{const u=s.get(d.id);return e.jsxs("div",{className:"native-subagent-activity__tool",children:[e.jsx(Xs,{toolCall:{...d,...u?{result:u.content,isError:u.isError}:{}},workspacePath:n,enableFilePreview:r}),u&&e.jsx("pre",{className:`native-subagent-activity__tool-result${u.isError?" native-subagent-activity__tool-result--error":""}`,children:u.content})]},d.id)})),i.role==="tool"&&i.toolCallId&&!t.messages.some(d=>{var u;return(u=d.toolCalls)==null?void 0:u.some(h=>h.id===i.toolCallId)})&&e.jsx(qr,{label:"工具结果",content:i.content,error:i.name==="error",maxPreviewHeight:180})]},`${i.role}-${a}`)}),t.summary&&e.jsx(qr,{label:t.status==="failed"?"错误信息":"执行摘要",content:t.summary,error:t.status==="failed",maxPreviewHeight:180}),t.status==="running"&&t.messages.length===0&&!t.summary&&e.jsxs("div",{className:"native-subagent-activity__waiting",children:[e.jsx(Qr,{isDone:!1,color:"var(--accent)",size:10}),"子 agent 正在工作"]})]})}function Yu({toolCall:t,onSelectSession:n,nativeSubagent:r,previewPaths:s,workspacePath:i,enableFilePreview:a,onLoadResult:c}){const d=Le(ie=>ie.runningSessionId),u=Qs(t,c,!!r),{expanded:h,setExpanded:g}=u,y=t.name==="dispatch_agent",m=t.name==="Agent"&&!!r,k=t.arguments.subAgentStatus,C=t.arguments.subAgentDetail,E=t.arguments.subAgentProgress,A=Gr(t);l.useEffect(()=>{y&&!k&&E&&g(!0),m&&(r.messages.length>0||r.summary)&&g(!0)},[y,m,r,k,E]);const S=y?k==="failed":m?r.status==="failed":t.isError,j=y?!!k||A&&!d:m?r.status!=="running":A,v=j?S?"var(--danger)":"var(--success)":"var(--accent)",D=S?"var(--danger)":j?"var(--text-muted)":"var(--accent)",V=y?null:ro(t.name),R=S?"错误":V?"":m?r.status==="stopped"?"已停止":j?"已完成":"运行中":y?k==="failed"?"失败":j?"已完成":"运行中":j?"完成":"执行中",T=m?r.description:y?(()=>{const Ae=(t.arguments.task??"").split(`
|
|
357
|
+
`)[0];return Ae.length>80?Ae.slice(0,80)+"…":Ae})():Fu(t.name,t.arguments),P=m?`@${r.agentName??"agent"}`:y?`@${t.arguments.agentName??"agent"}`:Il(t.name)??t.name,I=no(t.name),N=!j||!!S||!!R,G=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tool-call-shell__icon",children:e.jsx(ws,{name:t.name,color:D})}),e.jsx("span",{className:"tool-call-shell__label",title:V?t.name:void 0,style:{fontFamily:V?"var(--font-body)":"var(--font-mono)",fontSize:11.5,color:"var(--text-primary)",fontWeight:600,flexShrink:0},children:P}),T&&e.jsx("span",{className:"tool-call-shell__preview",style:{fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T}),!T&&e.jsx("span",{style:{flex:1}}),N&&e.jsxs("span",{className:"tool-call-shell__state",style:{color:v},children:[e.jsx(Qr,{isDone:j,isError:!!S,color:v}),R&&e.jsx("span",{children:R})]})]});return e.jsxs(Gs,{statusColor:v,isDone:j,expanded:h,onToggle:u.toggle,header:G,maxBodyHeight:800,primaryAction:s.length===1?()=>Sr(s[0]):void 0,primaryActionLabel:s.length===1?`预览文件 ${Bn(s[0])}`:void 0,primaryActionTitle:s.length===1?`预览 ${s[0]}`:void 0,children:[e.jsx(Ys,{toolCall:t,loading:u.loadingResult,error:u.resultError,retry:u.loadResult}),s.length>1&&e.jsx("div",{className:"tool-call-file-list","aria-label":"改动文件",children:s.map(ie=>e.jsxs("button",{type:"button",onClick:()=>Sr(ie),"aria-label":`预览文件 ${Bn(ie)}`,title:`预览 ${ie}`,children:[e.jsx(Vs,{size:12,strokeWidth:1.8,"aria-hidden":"true"}),e.jsx("span",{children:Bn(ie)})]},ie))}),m?e.jsx(Qu,{activity:r,workspacePath:i,enableFilePreview:a}):y?e.jsx(Ku,{arguments:t.arguments}):I==="command"&&typeof t.arguments.command=="string"?e.jsxs(e.Fragment,{children:[typeof t.arguments.cwd=="string"&&t.arguments.cwd&&e.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",wordBreak:"break-all"},children:["工作目录 ",t.arguments.cwd]}),e.jsx(qr,{label:"命令",content:t.arguments.command,maxPreviewLines:6,maxPreviewHeight:160})]}):e.jsx(Gu,{raw:JSON.stringify(t.arguments,null,2)}),t.result&&!y&&!m&&e.jsx(qr,{label:t.isError?"错误信息":"返回结果",content:t.result,error:t.isError,maxPreviewHeight:240}),y&&k&&C&&e.jsx(qr,{label:k==="failed"?"错误信息":"执行摘要",content:C,error:k==="failed",maxPreviewHeight:180}),y&&!k&&E&&(!!d||!A)&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:5},children:"实时输出"}),e.jsxs("pre",{style:{fontSize:11,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-all",fontFamily:"var(--font-mono)",padding:"9px 11px",borderRadius:7,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderLeft:"3px solid var(--accent)",maxHeight:240,overflow:"auto",margin:0,lineHeight:1.6,boxSizing:"border-box",maxWidth:"100%"},children:[E,e.jsx("span",{style:{display:"inline-block",width:"0.5em",height:"1em",background:"var(--accent)",verticalAlign:"text-bottom",animation:"blink 1s step-end infinite"},children:""})]})]}),y&&!k&&!E&&!!d&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 0",fontSize:11,color:"var(--text-muted)",fontStyle:"italic"},children:[[0,1,2].map(ie=>e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--accent)",display:"inline-block",animation:"wave 1.1s ease-in-out infinite",animationDelay:`${ie*.16}s`}},ie)),"等待子 agent 响应..."]}),y&&t.arguments.subSessionId&&n&&e.jsxs("button",{onClick:()=>n(t.arguments.subSessionId),style:{alignSelf:"flex-start",padding:"4px 10px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--accent-dim)",color:"var(--accent)",fontSize:11,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,transition:"background 0.15s"},onMouseEnter:ie=>{ie.currentTarget.style.background="var(--accent)",ie.currentTarget.style.color="white"},onMouseLeave:ie=>{ie.currentTarget.style.background="var(--accent-dim)",ie.currentTarget.style.color="var(--accent)"},children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("path",{d:"M12 2a5 5 0 1 0 0 10A5 5 0 0 0 12 2z"}),e.jsx("path",{d:"M12 12c-5.33 0-8 2.67-8 4v2h16v-2c0-1.33-2.67-4-8-4z"})]}),"查看子会话"]})]})}function Tl({items:t,onSelectSession:n,workspacePath:r,enableFilePreview:s,onLoadResult:i}){var C;const[a,c]=l.useState(!1),d=(C=t[0])==null?void 0:C.toolCall,u=d?ro(d.name):null;if(!d||!u||t.length<2)return null;const h=t.every(({toolCall:E})=>Gr(E)),g=t.filter(({toolCall:E})=>E.isError).length,y=g>0?"var(--danger)":h?"var(--text-muted)":"var(--accent)",m=Il(d.name)??u.done,k=`${m},${t.length} 项,${a?"收起":"展开"}`;return e.jsxs("div",{className:"tool-call-group",children:[e.jsxs("button",{type:"button",className:"tool-call-group__summary","aria-expanded":a,"aria-label":k,onClick:()=>c(E=>!E),children:[e.jsx("span",{className:"tool-call-group__icon","aria-hidden":"true",children:e.jsx(ws,{name:d.name,color:y})}),e.jsx("span",{className:"tool-call-group__label",children:m}),e.jsxs("span",{className:"tool-call-group__count",children:[t.length," 项"]}),e.jsx("span",{className:"tool-call-group__spacer"}),g>0&&e.jsxs("span",{className:"tool-call-group__error",children:[g," 项失败"]}),!h&&e.jsx(Qr,{isDone:!1,color:y,size:11}),e.jsx(Vr,{className:"tool-call-group__chevron",size:13,strokeWidth:2.2,"aria-hidden":"true"})]}),a&&e.jsx("div",{className:"tool-call-group__items",children:t.map(({toolCall:E,beforeContent:A,progress:S,nativeSubagent:j})=>e.jsx(Xs,{toolCall:E,beforeContent:A,progress:S,nativeSubagent:j,onSelectSession:n,workspacePath:r,enableFilePreview:s,onLoadResult:i},E.id))})]})}function Xu(t,n){if(no(t.name)!=="file")return[];const r=t.name==="apply_patch"&&Array.isArray(t.arguments.changes)?t.arguments.changes.map(s=>s.path):[t.arguments.file_path??t.arguments.path??t.arguments.notebook_path];return[...new Set(r.filter(s=>typeof s=="string").map(s=>wl(s,n)).filter(s=>!!s))]}function Xs({toolCall:t,onSelectSession:n,beforeContent:r,progress:s,nativeSubagent:i,workspacePath:a,enableFilePreview:c=!1,onLoadResult:d}){const u=c?Xu(t,a):[],h=t.name==="write_file"?e.jsx(Uu,{toolCall:t,beforeContent:r,previewPath:u[0],onLoadResult:d}):t.name==="read_file"?e.jsx(qu,{toolCall:t,previewPath:u[0],onLoadResult:d}):t.name==="str_replace"?e.jsx(Vu,{toolCall:t,previewPath:u[0],onLoadResult:d}):e.jsx(Yu,{toolCall:t,onSelectSession:n,nativeSubagent:i,previewPaths:u,workspacePath:a,enableFilePreview:c,onLoadResult:d});return e.jsxs("div",{className:"tool-call-with-progress",children:[h,s&&e.jsx(Cl,{progress:s,compact:!0})]})}function Zu({question:t,options:n,fields:r,multiSelect:s,answered:i,answer:a,onAnswer:c}){const[d,u]=l.useState(new Set),[h,g]=l.useState(""),[y,m]=l.useState({}),k=l.useRef(!1),[C,E]=l.useState(!1),[A,S]=l.useState(""),j=async(I,N)=>{if(!(i||k.current)){k.current=!0,E(!0),S("");try{await c(I,N)}catch(G){S(G instanceof Error?G.message:"回答发送失败,请重试。")}finally{k.current=!1,E(!1)}}},v=!!(n!=null&&n.length),D=!!(r!=null&&r.length),V=I=>{i||u(N=>{const G=new Set(N);return s?G.has(I)?G.delete(I):G.add(I):(G.clear(),G.add(I)),G})},R=()=>{if(d.size===0)return;const I=Array.from(d).map(N=>n[N].label);j(I.join(", "),Array.from(d))},T=()=>{const I=Array.from(d).map(G=>n[G].label),N=Object.fromEntries((r??[]).map(G=>{var ie;return[G.name,((ie=y[G.name])==null?void 0:ie.trim())??""]}));!N.model&&I.length>0&&(N.model=I[0]),!(!Object.values(N).some(Boolean)&&I.length===0)&&j(JSON.stringify({fields:N,selectedOptions:I}),Array.from(d))},P=()=>{h.trim()&&j(h.trim())};return e.jsxs("div",{style:{marginBottom:12},children:[A&&!i&&e.jsx("div",{role:"alert",style:{color:"var(--danger)",marginBottom:8},children:A}),C&&e.jsx("div",{role:"status",children:"正在发送回答…"}),e.jsxs("div",{style:{borderRadius:12,border:"1px solid",borderColor:i?"var(--border-subtle)":"rgba(79,110,247,0.35)",background:i?"var(--bg-deep)":"linear-gradient(135deg, rgba(79,110,247,0.04) 0%, var(--bg-deep) 100%)",overflow:"hidden",transition:"border-color 0.2s ease"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:i?"1px solid var(--border-subtle)":"1px solid rgba(79,110,247,0.15)"},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:6,background:i?"var(--bg-surface)":"rgba(79,110,247,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:i?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:i?"var(--text-muted)":"var(--accent)",flex:1},children:i?"已回答":"向你提问"}),s&&!i&&e.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:10,background:"var(--accent-dim)",color:"var(--accent)",fontWeight:500},children:"可多选"})]}),e.jsx("div",{style:{padding:"12px 14px 8px",fontSize:13,color:"var(--text-primary)",lineHeight:1.6,fontWeight:500,whiteSpace:"pre-wrap"},children:t}),i&&e.jsxs("div",{style:{padding:"6px 14px 12px",fontSize:12,color:"var(--text-secondary)"},children:[e.jsx("span",{style:{fontWeight:500},children:"回答:"}),D?"配置已提交(敏感字段已隐藏)":a]}),v&&!i&&e.jsxs("div",{style:{padding:"4px 14px 6px",display:"flex",flexDirection:"column",gap:6},children:[n.map((I,N)=>{const G=d.has(N);return e.jsxs("button",{onClick:()=>V(N),style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 12px",borderRadius:8,border:"1px solid",borderColor:G?"var(--accent)":"var(--border-subtle)",background:G?"rgba(79,110,247,0.06)":"var(--bg-surface)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-body)",transition:"all 0.15s ease",width:"100%"},children:[e.jsx("div",{style:{width:16,height:16,borderRadius:s?4:8,border:`2px solid ${G?"var(--accent)":"var(--border-subtle)"}`,background:G?"var(--accent)":"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1,transition:"all 0.15s ease"},children:G&&e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:G?600:500,color:G?"var(--text-primary)":"var(--text-secondary)"},children:I.label}),I.description&&e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,lineHeight:1.4},children:I.description})]})]},N)}),!D&&e.jsx("button",{onClick:R,disabled:C||d.size===0,style:{marginTop:2,padding:"7px 16px",borderRadius:8,border:"none",background:d.size>0?"var(--accent)":"var(--bg-surface)",color:d.size>0?"white":"var(--text-muted)",cursor:d.size>0?"pointer":"default",fontSize:12,fontWeight:600,fontFamily:"var(--font-body)",alignSelf:"flex-end",transition:"all 0.15s ease"},children:"确认选择"})]}),D&&!i&&e.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexDirection:"column",gap:10},children:[r.map(I=>e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--text-secondary)"},children:I.label}),e.jsx("input",{type:I.type==="secret"?"password":"text",value:y[I.name]??"",onChange:N=>m(G=>({...G,[I.name]:N.target.value})),placeholder:I.description,autoComplete:I.type==="secret"?"off":void 0,style:{padding:"8px 12px",borderRadius:8,border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none"}}),I.description&&e.jsx("span",{style:{fontSize:10.5,color:"var(--text-muted)",lineHeight:1.4},children:I.description})]},I.name)),e.jsx("button",{onClick:T,disabled:C,style:{padding:"8px 16px",borderRadius:8,border:"none",background:"var(--accent)",color:"white",cursor:"pointer",fontSize:12,fontWeight:600,fontFamily:"var(--font-body)",alignSelf:"flex-end"},children:"确认配置"})]}),!i&&!D&&e.jsxs("div",{style:{padding:"4px 14px 12px",display:"flex",gap:8,borderTop:v?"1px solid var(--border-subtle)":"none",marginTop:v?2:0},children:[e.jsx("input",{type:"text",value:h,onChange:I=>g(I.target.value),onKeyDown:I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),P())},placeholder:v?"或输入自定义回答…":"输入你的回答…",style:{flex:1,padding:"8px 12px",borderRadius:8,border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none",transition:"border-color 0.15s ease"},onFocus:I=>{I.currentTarget.style.borderColor="var(--accent)"},onBlur:I=>{I.currentTarget.style.borderColor="var(--border-subtle)"}}),e.jsx("button",{onClick:P,disabled:C||!h.trim(),style:{padding:"8px 16px",borderRadius:8,border:"none",background:h.trim()?"var(--accent)":"var(--bg-surface)",color:h.trim()?"white":"var(--text-muted)",cursor:h.trim()?"pointer":"default",fontSize:12,fontWeight:600,fontFamily:"var(--font-body)",transition:"all 0.15s ease"},children:"发送"})]})]})]})}const Si={systemBase:{label:"系统基础提示",group:"system"},environment:{label:"运行环境",group:"system"},projectContext:{label:"项目上下文",group:"system"},skills:{label:"技能指令",group:"system"},memory:{label:"Memory",group:"system"},embeddedTools:{label:"系统内嵌工具定义",group:"system"},conversationHistory:{label:"历史用户消息",group:"messages"},currentUserMessage:{label:"当前用户消息",group:"messages"},assistantMessages:{label:"AI 历史回复",group:"messages"},compactionSummary:{label:"上下文压缩摘要",group:"messages"},toolCalls:{label:"工具调用",group:"tools"},toolResults:{label:"工具结果",group:"tools"},nativeToolDefinitions:{label:"原生工具定义",group:"tools"},images:{label:"图片",group:"images"},messageOverhead:{label:"协议与消息开销",group:"overhead"}},Ii={system:{label:"系统",color:"#8b5cf6"},messages:{label:"消息",color:"#4f6ef7"},tools:{label:"工具",color:"#f59e0b"},images:{label:"图片",color:"#ec4899"},overhead:{label:"协议开销",color:"#94a3b8"}},wa=["system","messages","tools","images","overhead"];function Ju(t,n){const r=(t==null?void 0:t.maxTokens)??Math.max(1,n*1e3),s=(t==null?void 0:t.totalTokens)??0,i=Object.fromEntries(wa.map(c=>[c,0]));for(const c of(t==null?void 0:t.segments)??[]){const d=Si[c.category];d&&(i[d.group]+=c.tokens)}const a=Math.min(s/r,1);return{hasUsage:!!t,totalTokens:s,maxTokens:r,ratio:a,percent:Math.round(a*100),groups:wa.map(c=>({key:c,label:Ii[c].label,color:Ii[c].color,tokens:i[c]})),details:((t==null?void 0:t.segments)??[]).filter(c=>c.tokens>0).map(c=>{var d,u;return{category:c.category,label:((d=Si[c.category])==null?void 0:d.label)??c.category,color:Ii[((u=Si[c.category])==null?void 0:u.group)??"overhead"].color,tokens:c.tokens}}),requestLabel:t?`${t.providerId} · ${t.modelId} · 第 ${t.requestIndex} 次请求`:void 0}}function Vi(t){return t>=1e3?`${(t/1e3).toFixed(t>=1e4?0:1)}K`:`${t}`}function ja(t,n){return n?`${t.percent}%`:t.hasUsage?`${Vi(t.totalTokens)} / ${Vi(t.maxTokens)} · ${t.percent}%`:"尚无模型请求"}function ep({usage:t,contextWindowK:n,compact:r=!1}){const[s,i]=l.useState(!1),[a,c]=l.useState(null),d=l.useRef(null),u=l.useMemo(()=>Ju(t,n),[t,n]),h=u.ratio>=.85?"var(--danger)":u.ratio>=.6?"#f59e0b":"var(--accent)",g=typeof window>"u"?1024:window.innerWidth;return e.jsxs("div",{className:"context-usage-ribbon",style:{position:"relative",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("button",{className:"context-usage-ribbon__button",ref:d,type:"button",onClick:()=>{var m;const y=((m=d.current)==null?void 0:m.getBoundingClientRect())??null;c(y),i(k=>!k)},title:"查看完整请求上下文占用估算",style:{width:"100%",display:"flex",alignItems:"center",gap:10,padding:"6px 10px",border:0,background:"transparent",cursor:"pointer",fontFamily:"var(--font-body)"},children:r?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"context-usage-ribbon__ring",width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",children:[e.jsx("circle",{cx:"14",cy:"14",r:"10",fill:"none",stroke:"currentColor",strokeWidth:"4",opacity:"0.14"}),e.jsx("circle",{cx:"14",cy:"14",r:"10",fill:"none",stroke:u.hasUsage?h:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:`${u.ratio*62.832} 62.832`,transform:"rotate(-90 14 14)"})]}),e.jsx("span",{className:"context-usage-ribbon__summary context-usage-ribbon__summary--compact",children:ja(u,!0)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"context-usage-ribbon__label",style:{fontSize:11,color:"var(--text-muted)",whiteSpace:"nowrap"},children:"上下文"}),e.jsx("div",{className:"context-usage-ribbon__meter",style:{flex:1,height:6,borderRadius:999,overflow:"hidden",background:"rgba(0,0,0,0.06)",display:"flex"},children:u.groups.map(y=>e.jsx("div",{style:{width:`${Math.max(0,Math.min(y.tokens/u.maxTokens*100,100))}%`,background:y.color,opacity:y.key==="overhead"?.65:1,minWidth:y.tokens>0?1:0}},y.key))}),e.jsx("span",{className:"context-usage-ribbon__summary",style:{fontSize:11,color:u.hasUsage?h:"var(--text-muted)",fontVariantNumeric:"tabular-nums",minWidth:110,textAlign:"right"},children:ja(u,!1)})]})}),s&&a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>i(!1),style:{position:"fixed",inset:0,zIndex:9998,background:"transparent"}}),e.jsxs("div",{style:{position:"fixed",left:r?Math.min(Math.max(8,a.left),Math.max(8,g-Math.min(340,g-16)-8)):Math.max(8,a.left),top:a.top-8,transform:"translateY(-100%)",width:Math.min(r?340:a.width,g-16),maxHeight:"min(520px, calc(100vh - 32px))",overflowY:"auto",zIndex:9999,padding:12,borderRadius:12,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",boxShadow:"var(--shadow-lg)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[e.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)"},children:"完整请求上下文估算"}),e.jsx("div",{style:{fontSize:11,color:u.hasUsage?h:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:u.hasUsage?`${u.percent}%`:"暂无"})]}),u.requestLabel&&e.jsx("div",{style:{marginBottom:10,fontSize:10,color:"var(--text-muted)",wordBreak:"break-all"},children:u.requestLabel}),u.hasUsage?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:u.details.map(y=>{const m=u.totalTokens>0?Math.round(y.tokens/u.totalTokens*100):0;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:y.color}}),e.jsx("span",{style:{flex:1,fontSize:12,color:"var(--text-secondary)"},children:y.label}),e.jsxs("span",{style:{fontSize:12,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[Vi(y.tokens)," · ",m,"%"]})]},y.category)})}):e.jsx("div",{style:{padding:"8px 0",fontSize:12,color:"var(--text-muted)"},children:"发送第一条消息后,将显示最新一次模型请求的完整上下文组成。"}),e.jsx("div",{style:{marginTop:10,fontSize:11,lineHeight:1.5,color:"var(--text-muted)"},children:"基于最新一次实际发送前请求的完整组成估算,包含系统提示、环境、项目上下文、技能、memory、历史消息、工具定义/调用/结果、图片和压缩摘要。不同模型的 tokenizer 与协议存在差异,因此不是账单精确值。"})]})]})]})}function tp({startedAt:t}){return e.jsxs("div",{className:"agent-activity-indicator",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"agent-activity-icon","aria-hidden":"true",children:e.jsx(Yi,{size:17,strokeWidth:1.8})}),e.jsxs("span",{children:["思考中",e.jsx(so,{startedAt:t})]})]})}function Nl({sections:t,streaming:n=!1,startedAt:r,renderContent:s}){const i=l.useMemo(()=>[...t].sort((h,g)=>h.sectionIndex-g.sectionIndex).map(h=>h.text.trim()).filter(Boolean).join(`
|
|
358
|
+
|
|
359
|
+
`),[t]),a=l.useMemo(()=>(i.split(`
|
|
360
|
+
`).find(g=>g.trim())??"").replace(/^#{1,6}\s+/,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1"),[i]),[c,d]=l.useState(n);if(l.useEffect(()=>{d(n)},[n]),!i)return null;const u=n?"思考中":"思考";return e.jsxs("div",{className:"reasoning-summary",children:[e.jsxs("button",{type:"button",className:"reasoning-summary__toggle","aria-expanded":c,"aria-label":`${u},${c?"收起":"展开"}`,onClick:()=>d(h=>!h),children:[e.jsx("span",{className:"reasoning-summary__brain","aria-hidden":"true",children:e.jsx(Yi,{size:17,strokeWidth:1.8})}),e.jsxs("span",{className:"reasoning-summary__label",children:[u,n&&r!==void 0&&e.jsx(so,{startedAt:r})]}),!c&&e.jsx("span",{className:"reasoning-summary__preview",children:a}),e.jsx("span",{className:"reasoning-summary__spacer"}),n&&e.jsx(Dt,{className:"reasoning-summary__spinner",size:13,strokeWidth:2,"aria-hidden":"true"}),e.jsx(Vr,{className:"reasoning-summary__chevron",size:13,strokeWidth:2,"aria-hidden":"true"})]}),c&&e.jsx("div",{className:"reasoning-summary__content",children:s(i)})]})}function zl(t){var n,r;return t.role==="assistant"&&!!((n=t.toolCalls)!=null&&n.length)&&!t.isCompactionSummary&&!t.widget&&!t.askUser&&!((r=t.images)!=null&&r.length)&&!t.presentation}function np(t){return zl(t)&&t.content.trim().length===0}function Ll(t){const n=[];for(const r of t){const s=n[n.length-1];if(s&&zl(s)&&np(r)){n[n.length-1]={...s,toolCalls:[...s.toolCalls,...r.toolCalls],timestamp:r.timestamp};continue}n.push(r)}return n}function _l(t){const n=[];for(const r of t){const s=Ou(r.toolCall.name),i=n[n.length-1];s&&(i==null?void 0:i.action)===s?i.items.push(r):n.push({action:s,items:[r]})}return n}function rp({trace:t,loadTrace:n,loadToolResult:r,renderContent:s,runtimeProgress:i,nativeSubagents:a,onSelectSession:c,workspacePath:d,enableFilePreview:u=!1,refreshSignal:h=0,autoLoad:g=!1}){const y=t.turnId,m=l.useRef(y),k=l.useRef(t.revision),C=l.useRef(h),E=l.useRef(null),[A,S]=l.useState(!1),[j,v]=l.useState(null),[D,V]=l.useState(null);l.useEffect(()=>{m.current=y,E.current=null,S(!1),v(null),V(null),C.current=h},[y]),l.useEffect(()=>{k.current=t.revision,E.current=null,S(!1),v(ie=>(ie==null?void 0:ie.map(Ae=>{var ze;return{...Ae,toolCalls:(ze=Ae.toolCalls)==null?void 0:ze.map(ce=>ce.resultRef?{...ce,resultRef:{...ce.resultRef,revision:t.revision}}:ce)}}))??null)},[t.revision]);const R=t.liveMessages??[],T=l.useMemo(()=>Vd(j??[],R),[R,j]),P=j!==null||R.length>0,I=l.useCallback(async(ie=!1)=>{if(!ie&&j)return j;if(!ie&&R.length>0)return R;if(E.current)return E.current;const Ae=y,ze=t.revision;S(!0),V(null);const ce=n(t);E.current=ce;try{const J=await ce;return m.current===Ae&&k.current===ze&&v(J),J}catch(J){throw m.current===Ae&&k.current===ze&&V(J instanceof Error?J.message:"执行过程加载失败"),J}finally{m.current===Ae&&k.current===ze&&(E.current=null,S(!1))}},[R,n,j,y,t]);l.useEffect(()=>{!g||P||I().catch(()=>{})},[g,I,P]),l.useEffect(()=>{!P&&!g||h===0||C.current!==h&&(C.current=h,I(!0).catch(()=>{}))},[g,I,P,h]);const N=l.useCallback(async ie=>{const Ae=await r(ie);m.current===y&&v(ze=>ze&&hl(ze,ie.itemId,Ae.content,Ae.isError))},[r,y]),G=A?"正在加载执行过程":D?"重新加载执行过程":"查看执行过程";return e.jsx("div",{className:"codex-execution-trace","data-turn-id":t.turnId,children:P?e.jsx(sp,{messages:T,renderContent:s,runtimeProgress:i,nativeSubagents:a,onSelectSession:c,workspacePath:d,enableFilePreview:u,onLoadResult:N}):g&&!D?e.jsxs("div",{className:"codex-execution-trace__status",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx("span",{className:"codex-execution-trace__icon","aria-hidden":"true",children:e.jsx(Dt,{size:14,strokeWidth:2})}),e.jsx("span",{className:"codex-execution-trace__label",children:"正在加载会话"})]}):e.jsxs("button",{type:"button",className:"codex-execution-trace__load","aria-busy":A||void 0,disabled:A,onClick:()=>void I().catch(()=>{}),children:[e.jsx("span",{className:"codex-execution-trace__icon","aria-hidden":"true",children:A?e.jsx(Dt,{size:14,strokeWidth:2}):D?e.jsx(el,{size:14,strokeWidth:2}):e.jsx(jd,{size:14,strokeWidth:1.8})}),e.jsx("span",{className:"codex-execution-trace__label",children:G}),D&&e.jsx("span",{className:"codex-execution-trace__error",children:"加载失败"})]})})}function sp({messages:t,renderContent:n,runtimeProgress:r,nativeSubagents:s,onSelectSession:i,workspacePath:a,enableFilePreview:c,onLoadResult:d}){const u=l.useMemo(()=>{const h=new Map;return Ll(t).map(g=>{const y=(g.toolCalls??[]).map(m=>{const k=typeof m.arguments.file_path=="string"?m.arguments.file_path:void 0,C=m.name==="write_file"&&k?h.get(k):void 0;return m.name==="read_file"&&k&&m.result!==void 0&&!m.isError&&h.set(k,m.result),{toolCall:m,beforeContent:C,progress:fl(r,m.id),nativeSubagent:s[m.id]}});return{message:g,toolGroups:_l(y)}})},[t,s,r]);return u.length===0?e.jsx("div",{className:"codex-execution-trace__empty",children:"这一轮没有可显示的执行过程"}):e.jsx("div",{className:"codex-execution-trace__timeline",children:u.map(({message:h,toolGroups:g})=>{var y,m,k;return e.jsxs("div",{className:"codex-execution-trace__item",children:[(m=(y=h.presentation)==null?void 0:y.reasoning)!=null&&m.length?e.jsx(Nl,{sections:h.presentation.reasoning,renderContent:n}):null,((k=h.presentation)==null?void 0:k.agentMessagePhase)==="commentary"&&h.content?e.jsx("div",{className:"codex-execution-trace__commentary",children:n(h.content)}):null,g.map(C=>C.action&&C.items.length>1?e.jsx(Tl,{items:C.items,onSelectSession:i,workspacePath:a,enableFilePreview:c,onLoadResult:d},`group-${C.items[0].toolCall.id}`):e.jsx(Xs,{toolCall:C.items[0].toolCall,beforeContent:C.items[0].beforeContent,progress:C.items[0].progress,nativeSubagent:C.items[0].nativeSubagent,onSelectSession:i,workspacePath:a,enableFilePreview:c,onLoadResult:d},C.items[0].toolCall.id))]},h.id)})})}function ip({appearanceOpen:t,settingsOpen:n,showSettings:r=!0,hideToBackgroundTitle:s="隐藏到后台",codexReleaseState:i="idle",onHideToBackground:a,onReleaseCodex:c,onOpenHub:d,onOpenDesktopLive:u,desktopLiveOpen:h=!1,onToggleAppearance:g,onOpenSettings:y}){const m=i==="releasing"?"正在停止 AgentRoam 使用此会话":i==="released"?"已停止在 AgentRoam 中使用;Codex Desktop 最长约 30 分钟后可用":"停止在 AgentRoam 中使用(Codex Desktop 最长约 30 分钟后可用)";return e.jsxs("div",{className:"chat-header-actions",children:[u&&e.jsx("button",{type:"button",onClick:u,title:"桌面直播与远程控制","aria-label":"桌面直播与远程控制","aria-expanded":h,className:`ui-icon-button chat-header-action ${h?"is-active":""}`,children:e.jsx(ld,{size:15,"aria-hidden":"true"})}),d&&e.jsx("button",{type:"button",onClick:d,title:"AI Hub · 多模型网页对比","aria-label":"打开 AI Hub",className:"ui-icon-button chat-header-action chat-header-action--ai-hub",children:e.jsx(ed,{size:15,"aria-hidden":"true"})}),c&&e.jsx("button",{type:"button",onClick:c,title:m,"aria-label":m,disabled:i!=="idle",className:`ui-icon-button chat-header-action chat-header-action--codex-release is-${i}`,children:i==="releasing"?e.jsx(Dt,{size:15,className:"spin","aria-hidden":"true"}):i==="released"?e.jsx(Ur,{size:15,"aria-hidden":"true"}):e.jsx(yd,{size:15,"aria-hidden":"true"})}),e.jsx("button",{type:"button",onClick:a,title:s,"aria-label":"隐藏后台",className:"ui-icon-button chat-header-action chat-header-action--background",children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"14",rx:"2"}),e.jsx("path",{d:"m9 11 3 3 3-3M12 7v7M8 21h8"})]})}),e.jsx("button",{type:"button",onClick:k=>g(k.currentTarget.getBoundingClientRect()),title:"皮肤与布局","aria-label":"皮肤与布局","aria-expanded":t,className:`ui-icon-button chat-header-action chat-header-action--appearance ${t?"is-active":""}`,children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),e.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})]})}),r&&e.jsx("button",{type:"button",onClick:y,title:"设置","aria-label":"设置","aria-expanded":n,className:`ui-icon-button chat-header-action chat-header-action--settings ${n?"is-active":""}`,children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})})]})}var qs,Pl;class op{constructor(){qo(this,qs);this.points=new Map,this.origin=null,this.originDistance=0,this.moved=!1}reset(){this.points.clear(),this.origin=null,this.originDistance=0,this.moved=!1}down(n,r){this.points.size||(this.origin=r,this.moved=!1),this.points.set(n,r),this.points.size>1&&(this.moved=!0),this.originDistance=Vo(this,qs,Pl).call(this)}move(n,r){const s=this.points.get(n);if(!s)return null;const i=[...this.points.values()];if(this.points.set(n,r),this.origin&&Math.hypot(r.x-this.origin.x,r.y-this.origin.y)>8&&(this.moved=!0),this.points.size===1)return this.moved?{scale:1,distanceRatio:1,from:s,to:r,pointers:1}:null;const a=[...this.points.values()],c=g=>({x:(g[0].x+g[1].x)/2,y:(g[0].y+g[1].y)/2}),d=g=>Math.hypot(g[0].x-g[1].x,g[0].y-g[1].y),u=d(i),h=this.originDistance>0?d(a)/this.originDistance:1;return{scale:u>0?d(a)/u:1,distanceRatio:h,from:c(i),to:c(a),pointers:this.points.size}}up(n,r,s=!1){if(!this.points.has(n))return!1;const i=!s&&!this.moved&&this.points.size===1&&!!this.origin&&Math.hypot(r.x-this.origin.x,r.y-this.origin.y)<=8;return this.points.delete(n),s&&(this.moved=!0),this.points.size||this.reset(),i}}qs=new WeakSet,Pl=function(){const n=[...this.points.values()];return n.length>=2?Math.hypot(n[0].x-n[1].x,n[0].y-n[1].y):0};const ap={"agent-controlled":"Agent 操作中","handoff-requested":"正在交接","user-controlled":"你正在操作","return-requested":"正在归还",resyncing:"Agent 正在同步页面"};function ka(t){return t==="desktop"?"桌面屏幕":t==="ego-browser"?"ego-browser":"内置 Browser"}function Sa(t,n,r){var s,i;return t||(((s=n.find(a=>a.agentSessionId===r))==null?void 0:s.id)??((i=n[0])==null?void 0:i.id)??null)}function Ia(t){return[t.altKey?"Alt":"",t.ctrlKey?"Control":"",t.metaKey?"Meta":"",t.shiftKey?"Shift":""].filter(Boolean)}const lp=2;function cp(t,n,r,s,i=.02){if(!t||!n||!n.width||!n.height)return!1;const a=t.x/n.width-i,c=t.y/n.height-i,d=(t.x+t.w)/n.width+i,u=(t.y+t.h)/n.height+i;return r>=a&&r<=d&&s>=c&&s<=u}function dp(t,n,r=lp){const s={deltaX:Math.round(t.x-n.x),deltaY:Math.round(t.y-n.y)};return Math.abs(s.deltaX)<r&&Math.abs(s.deltaY)<r?null:s}function up({open:t,agentSessionId:n,onClose:r}){const s=l.useContext(Mc),i=typeof window>"u"?void 0:window.browserLiveApi,a=l.useRef(null),[c,d]=l.useState(!1),u=async()=>{const b=a.current;if(b){if(c){document.fullscreenElement===b&&await document.exitFullscreen().catch(()=>{}),d(!1);return}d(!0),b.requestFullscreen&&await b.requestFullscreen().catch(()=>{})}};l.useEffect(()=>{if(!t){d(!1);return}const b=a.current,z=()=>d(document.fullscreenElement===b),F=re=>{re.key==="Escape"&&(document.fullscreenElement===b||b!=null&&b.classList.contains("is-fullscreen"))&&(re.preventDefault(),re.stopPropagation(),document.fullscreenElement===b&&document.exitFullscreen().catch(()=>{}),d(!1))};return document.addEventListener("fullscreenchange",z),document.addEventListener("keydown",F,!0),()=>{document.removeEventListener("fullscreenchange",z),document.removeEventListener("keydown",F,!0),b&&document.fullscreenElement===b&&document.exitFullscreen().catch(()=>{})}},[t]);const[h,g]=l.useState([]),[y,m]=l.useState(null),[k,C]=l.useState(null),[E,A]=l.useState("hd"),[S,j]=l.useState(!1),[v,D]=l.useState(null),[V,R]=l.useState(!1),[T,P]=l.useState(0),[I,N]=l.useState(null),[G,ie]=l.useState(!1),[Ae,ze]=l.useState(1),[ce,J]=l.useState(!1),[je,Ke]=l.useState({width:0,height:0}),Xe=l.useRef(null),ct=l.useRef(null),nt=l.useRef(!1),Ht=l.useRef(null),Ze=l.useRef(new op),_=l.useRef(Ae),ne=l.useRef(null);l.useLayoutEffect(()=>{_.current=Ae;const b=ne.current,z=Xe.current,F=z==null?void 0:z.querySelector(".browser-live-image-hit-area");if(!b||!z||!F)return;const re=F.getBoundingClientRect();z.scrollLeft+=re.left+b.x*re.width-b.clientX,z.scrollTop+=re.top+b.y*re.height-b.clientY,ne.current=null},[Ae]);const Ie=l.useRef(null),[be,Ce]=l.useState(!1),_e=l.useRef(!1),ke=l.useRef(null),Je=l.useRef(0),[jt,Tt]=l.useState(!1),Be=l.useRef(null),Me=l.useRef(0),Ge=l.useRef("none"),Qe=l.useRef(null),W=l.useRef(null),[O,K]=l.useState(null),[X,ae]=l.useState(!1),Re=l.useRef(null),ht=l.useRef(null),[vn,gt]=l.useState("off"),Ye=l.useRef(null),dt=l.useRef(null);l.useLayoutEffect(()=>{_e.current=be,be&&Tt(!1)},[be]);const $=l.useMemo(()=>h.find(b=>b.id===y)??null,[y,h]),Z=($==null?void 0:$.backend)==="desktop",xe=($==null?void 0:$.isController)&&$.state==="user-controlled";l.useEffect(()=>{if(!t||!i||!y){K(null);return}let b=!0;const z=()=>{const re=performance.now();i.request("browser:ping",{t:re}).then(()=>{b&&K(Math.round(performance.now()-re))}).catch(()=>{b&&K(null)})};z();const F=window.setInterval(z,3e3);return()=>{b=!1,window.clearInterval(F),K(null)}},[i,t,y]),l.useEffect(()=>{const b=navigator;if(!xe||!b.wakeLock)return;let z=!1,F=null;return b.wakeLock.request("screen").then(re=>{if(z){re.release();return}F=re,Re.current=re}).catch(()=>{}),()=>{z=!0,F==null||F.release().catch(()=>{}),Re.current=null}},[xe]);const kt=(v==null?void 0:v.viewport)??($==null?void 0:$.viewport),xt=kt&&je.width&&je.height?Math.min(je.width/kt.width,je.height/kt.height):null;l.useEffect(()=>{var b;ze(1),J(!1),ct.current=null,Ze.current.reset(),ne.current=null,ke.current=null,ht.current=null,(b=Xe.current)==null||b.scrollTo(0,0)},[t,y]),l.useEffect(()=>{const b=Xe.current;if(!t||!b)return;const z=new ResizeObserver(()=>{Ke({width:b.clientWidth,height:b.clientHeight})});return z.observe(b),()=>z.disconnect()},[t,Z]),l.useEffect(()=>{const b=Xe.current;if(!t||!b||!xe||ce)return;const z=F=>F.preventDefault();return b.addEventListener("wheel",z,{passive:!1}),()=>b.removeEventListener("wheel",z)},[t,xe,ce]);const Bt=l.useCallback(()=>{const b=Ie.current;b&&(be?(b.blur(),Ce(!1)):(b.focus({preventScroll:!0}),Ce(!0)))},[be]);l.useEffect(()=>{var b;(!xe||ce)&&be&&((b=Ie.current)==null||b.blur(),Ce(!1))},[xe,ce,be]);const at=l.useCallback(b=>{const z=(v==null?void 0:v.viewport)??($==null?void 0:$.viewport),F=Xe.current,re=F==null?void 0:F.querySelector(".browser-live-image-hit-area");if(!b||!z||!F||!re)return;const pe=re.getBoundingClientRect(),Pe=F.getBoundingClientRect(),ut=pe.top+b.y/z.height*pe.height,He=ut+b.h/z.height*pe.height,et=16;ut>=Pe.top+et&&He<=Pe.bottom-et||(F.scrollTop+=ut-(Pe.top+Math.max(et,Pe.height*.3)))},[v==null?void 0:v.viewport,$==null?void 0:$.viewport]);l.useEffect(()=>{if(!be||!ke.current)return;const b=window.setTimeout(()=>at(ke.current),420);return()=>window.clearTimeout(b)},[be,je.width,je.height,at]);const Xt=l.useCallback(b=>{var F;const z=b&&typeof b.input=="object"&&b.input!==null?b.input:b;if(typeof(z==null?void 0:z.editable)=="boolean"){if(!z.editable&&z.kind==="control"){const re=z.bounds;re&&["x","y","w","h"].every(pe=>typeof re[pe]=="number")&&(ht.current={rect:{x:re.x,y:re.y,w:re.w,h:re.h},at:Date.now()});return}if(z.editable){const re=z.bounds,pe=re&&["x","y","w","h"].every(Pe=>typeof re[Pe]=="number")?{x:re.x,y:re.y,w:re.w,h:re.h}:null;pe&&(ke.current=pe,Je.current=Date.now()),_e.current?at(pe??ke.current):Tt(!0)}else ke.current=null,_e.current&&((F=Ie.current)==null||F.blur(),Ce(!1))}},[at]),mt=l.useMemo(()=>[{urls:"stun:stun.l.google.com:19302"}],[]),wn=l.useCallback(async(b,z)=>{if(!(!i||!b||!z))try{let F=Ye.current;F||(F=new RTCPeerConnection({iceServers:mt}),F.onicecandidate=pe=>{pe.candidate&&i.request("browser:webrtc",{sessionId:b,data:{kind:"ice",candidate:pe.candidate.toJSON()}}).catch(()=>{})},F.ontrack=pe=>{const Pe=dt.current;Pe&&pe.streams[0]&&(Pe.srcObject=pe.streams[0],Pe.play().catch(()=>{}))},F.onconnectionstatechange=()=>{const pe=F==null?void 0:F.connectionState;pe==="connected"?gt("live"):(pe==="failed"||pe==="disconnected"||pe==="closed")&>("failed")},Ye.current=F),await F.setRemoteDescription(z);const re=await F.createAnswer();await F.setLocalDescription(re),gt("connecting"),await i.request("browser:webrtc",{sessionId:b,data:{kind:"answer",sdp:F.localDescription.toJSON()}})}catch{gt("failed")}},[i,mt]),un=l.useCallback((b,z)=>{if(z){if(z.kind==="quality-state"&&["smooth","hd","original"].includes(String(z.quality))){A(String(z.quality)),j(!1),typeof z.error=="string"&&N(z.error);return}if(z.kind==="offer"){wn(b,z.sdp);return}if(z.kind==="ice"){const F=z.candidate,re=Ye.current;re&&F&&re.addIceCandidate(F).catch(()=>{});return}if(z.kind==="state"){const F=String(z.state);F==="connected"?gt("live"):(F==="failed"||F==="disconnected"||F==="closed")&>("failed")}}},[wn]),[Nt,Zt]=l.useState(null);l.useEffect(()=>{if(!v){Zt(null);return}const b=typeof v.data=="string"?`data:${v.mime};base64,${v.data}`:URL.createObjectURL(new Blob([v.data],{type:v.mime}));let z=!1,F=!1;const re=new Image;return re.src=b,re.decode().then(()=>{z||(F=!0,Zt(b))}).catch(()=>{}),()=>{z=!0,!F&&b.startsWith("blob:")&&URL.revokeObjectURL(b)}},[v]),l.useEffect(()=>()=>{Nt!=null&&Nt.startsWith("blob:")&&URL.revokeObjectURL(Nt)},[Nt]);const st=l.useCallback(b=>{g(z=>{const F=z.findIndex(pe=>pe.id===b.id);if(F<0)return[b,...z];const re=[...z];return re[F]=b,re.sort((pe,Pe)=>Pe.updatedAt-pe.updatedAt)}),m(z=>Sa(z,[b],n)),ie(!1)},[n]),zt=l.useCallback(async()=>{if(!(!i||!t)){R(!0),N(null);try{const b=await i.request("browser:list");g(b.sessions),m(z=>{const F=z&&b.sessions.some(re=>re.id===z)?z:null;return Sa(F,b.sessions,n)}),y&&await i.request("browser:watch",{sessionId:y}).then(z=>st(z.session)).catch(()=>{}),P(z=>z+1)}catch(b){N(b instanceof Error?b.message:"无法读取浏览器会话")}finally{R(!1)}}},[n,i,st,t,y]);l.useEffect(()=>{if(!(!t||!i))return zt(),i.onEvent(b=>{if(b.type==="browser:frame"){const z=b;z.sessionId===y&&D(z);return}if(b.type==="browser:webrtc"){const z=b.data;b.sessionId===y&&un(y,z);return}if(b.session&&typeof b.session=="object"&&st(b.session),b.type==="browser:closed"){const z=b.session;z&&(g(F=>F.filter(re=>re.id!==z.id)),z.id===y&&(D(null),m(null)))}})},[i,un,st,t,zt,y]),l.useEffect(()=>{if(!(!t||!i||!y))return D(null),N(null),i.request("browser:watch",{sessionId:y}).then(b=>st(b.session)).catch(b=>N(b instanceof Error?b.message:"无法观看浏览器")),()=>{i.request("browser:unwatch").catch(()=>{})}},[i,st,t,y]),l.useEffect(()=>{var b,z;if(!t||!i||!xe||!Z||!y){(b=Ye.current)==null||b.close(),Ye.current=null,dt.current&&(dt.current.srcObject=null),gt("off");return}return(z=Ye.current)==null||z.close(),Ye.current=null,gt("connecting"),i.request("browser:webrtc",{sessionId:y,data:{kind:"start"}}).catch(()=>gt("failed")),()=>{var F;(F=Ye.current)==null||F.close(),Ye.current=null,dt.current&&(dt.current.srcObject=null),i.request("browser:webrtc",{sessionId:y,data:{kind:"stop"}}).catch(()=>{})}},[i,xe,Z,t,y,T]);const Ir=l.useCallback(async()=>{if(!(!i||!$)){ie(!0),N(null);try{const b=await i.request("browser:takeover",{sessionId:$.id});st(b.session)}catch(b){ie(!1),N(b instanceof Error?b.message:"无法接管浏览器")}}},[i,st,$]),jn=l.useCallback(async()=>{if(!(!i||!$)){ie(!0),N(null);try{const b=await i.request("browser:return",{sessionId:$.id});st(b.session)}catch(b){ie(!1),N(b instanceof Error?b.message:"无法归还浏览器")}}},[i,st,$]),ye=l.useCallback(b=>{!i||k||S||!($!=null&&$.isController)||$.state!=="user-controlled"||i.request("browser:input",{sessionId:$.id,input:b}).catch(z=>{N(z instanceof Error?z.message:"浏览器输入失败")})},[i,$,k,S]),Se=l.useCallback((b,z,F=[])=>{ye({kind:"key",action:"down",key:b,code:z,text:"",modifiers:F}),ye({kind:"key",action:"up",key:b,code:z,text:"",modifiers:F})},[ye]),sn=l.useCallback(b=>{Se(b,`Key${b.toUpperCase()}`,["Control"])},[Se]),kn=l.useCallback(b=>!i||k||S||!($!=null&&$.isController)||$.state!=="user-controlled"?Promise.resolve(null):i.request("browser:input",{sessionId:$.id,input:b}).then(z=>z&&typeof z=="object"?z:null).catch(()=>null),[i,$,k,S]),St=l.useCallback((b,z)=>{kn({kind:"pointer",action:"up",...b,button:"left",...z&&z>1?{click:z}:{}}).then(Xt)},[Xt,kn]),$t=l.useRef(!1),$n=l.useRef(""),pn=l.useCallback(b=>{const z=$n.current;if(b!==z){if(b.startsWith(z)){const F=b.slice(z.length);F&&ye({kind:"key",action:"down",text:F,key:"",code:"",modifiers:[]})}$n.current=b}},[ye]),rt=($==null?void 0:$.displays)??null;l.useEffect(()=>{if(!S)return;const b=window.setTimeout(()=>{j(!1),N("画质切换未完成,请刷新画面后重试")},14e3);return()=>window.clearTimeout(b)},[S]),l.useEffect(()=>{j(!1),A("hd")},[t,y]);const on=b=>{!i||!xe||k||S||!y||(j(!0),i.request("browser:webrtc",{sessionId:y,data:{kind:"quality",quality:b}}).catch(z=>{j(!1),N(z instanceof Error?z.message:"画质切换失败")}))};l.useEffect(()=>{if(!k)return;if(rt!=null&&rt.some(z=>z.id===k&&z.selected)){C(null);return}const b=window.setTimeout(()=>{C(null),N("切换屏幕未完成,请刷新画面后重试")},14e3);return()=>window.clearTimeout(b)},[rt,k]),l.useEffect(()=>{C(null)},[t,y]);const fn=l.useRef(0),hn=l.useCallback(b=>{!i||k||S||!y||!xe||!(rt!=null&&rt.some(z=>z.id===b&&!z.selected))||(C(b),i.request("browser:set-display",{sessionId:y,displayId:b}).catch(z=>{C(null),N(z instanceof Error?z.message:"切换屏幕失败")}))},[i,rt,y,xe,k,S]),lt=l.useCallback(b=>{const z=b.currentTarget.getBoundingClientRect(),F=(v==null?void 0:v.viewport)??($==null?void 0:$.viewport);if(!F)return null;const re=Math.min(z.width/F.width,z.height/F.height),pe=F.width*re,Pe=F.height*re,ut=(z.width-pe)/2,He=(z.height-Pe)/2,et=(b.clientX-z.left-ut)/pe,Ct=(b.clientY-z.top-He)/Pe;return et<0||et>1||Ct<0||Ct>1?null:{x:et,y:Ct}},[v==null?void 0:v.viewport,$==null?void 0:$.viewport]);if(!t||typeof document>"u")return null;const or=($==null?void 0:$.online)&&!$.controlledByAnotherViewer,ar=($==null?void 0:$.availability)==="unavailable"?Z?"桌面直播不可用":"浏览器直播不可用":($==null?void 0:$.availability)==="starting"?"正在连接画面":Z&&($==null?void 0:$.state)==="agent-controlled"?"未被远程控制":$?ap[$.state]:Z?"等待桌面直播":"等待浏览器",an=($==null?void 0:$.availability)==="unavailable"?Z?"桌面直播不可用":"浏览器直播不可用":($==null?void 0:$.availability)==="starting"?"正在连接画面":h.length?"等待第一帧":Z?"暂无桌面直播":"暂无浏览器直播",It=($==null?void 0:$.availability)==="unavailable"?$.capabilityError||(Z?"需要在桌面 App 中开启并授予屏幕录制权限":"当前浏览器不支持实时画面传输"):h.length?"画面开始后会自动显示":Z?"在桌面 App 设置中开启「桌面直播与远程控制」后,画面会出现在这里":"Agent 开始浏览网页后,会话会出现在这里";return Yt.createPortal(e.jsx("div",{className:"browser-live-backdrop","data-tab-swipe-ignore":!0,role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&r()},children:e.jsxs("section",{ref:a,className:`browser-live-panel ${c?"is-fullscreen":""} ${h.length>1?"has-session-tabs":""}`,role:"dialog","aria-modal":"true","aria-label":"浏览器直播",children:[e.jsxs("header",{className:"browser-live-header",children:[e.jsxs("div",{className:"browser-live-heading",children:[e.jsx(Yo,{size:17,"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:"浏览器直播"}),e.jsx("span",{children:$?ka($.backend):"实时观看与接管"})]}),s]}),e.jsxs("div",{className:"browser-live-header-actions",children:[e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>void u(),title:c?"退出全屏":"全屏","aria-label":c?"退出全屏":"全屏","aria-pressed":c,children:c?e.jsx(ad,{size:17}):e.jsx(id,{size:17})}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>void zt(),title:"刷新画面与会话","aria-label":"刷新直播画面与会话",children:e.jsx(rl,{size:15,className:V?"spin":void 0,"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:r,title:"关闭","aria-label":"关闭浏览器直播",children:e.jsx(Kr,{size:17,"aria-hidden":"true"})})]})]}),h.length>1&&e.jsx("div",{className:"browser-live-session-tabs",role:"tablist","aria-label":"浏览器会话",children:h.map(b=>e.jsxs("button",{type:"button",role:"tab","aria-selected":b.id===y,className:b.id===y?"is-active":"",onClick:()=>m(b.id),children:[e.jsx("span",{children:ka(b.backend)}),e.jsx("small",{children:b.title||"浏览器"})]},b.id))}),e.jsxs("div",{className:`browser-live-surface ${xe?"is-controlling":""} has-zoom ${xe&&!ce&&X?"has-quickkeys":""}`,children:[e.jsxs("div",{className:"browser-live-zoom",role:"group","aria-label":"桌面画面缩放",children:[Z&&rt&&rt.length>0&&e.jsx("select",{"aria-label":"选择直播屏幕",title:xe?"选择直播屏幕":"点击开始控制后可切换屏幕",value:(rt.find(b=>b.selected)??rt[0]).id,disabled:!v||!xe||!!k||S||rt.length<2,onChange:b=>hn(b.target.value),style:{minHeight:32,maxWidth:180,flexShrink:0,fontSize:16,color:"inherit",background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderRadius:6},children:rt.map((b,z)=>e.jsx("option",{value:b.id,children:`第 ${z+1} 屏${b.primary?"(主屏)":""}`},b.id))}),y==="cli-desktop:primary"&&e.jsxs("select",{"aria-label":"视频画质",title:xe?"视频画质":"点击开始控制后可调整画质",value:E,disabled:!xe||!!k||S,onChange:b=>on(b.target.value),style:{minHeight:32,flexShrink:0,fontSize:16,color:"inherit",background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",borderRadius:6},children:[e.jsx("option",{value:"smooth",children:"流畅"}),e.jsx("option",{value:"hd",children:"高清"}),e.jsx("option",{value:"original",children:"原画"})]}),(k||S)&&e.jsx("span",{role:"status",children:"切换中…"}),e.jsx("button",{type:"button","aria-label":"缩小桌面画面",title:"缩小",disabled:!v||Ae<=.5,onClick:()=>ze(b=>Math.max(.5,b-.25)),children:e.jsx(al,{size:16})}),e.jsxs("output",{"aria-label":"桌面缩放比例",children:[Math.round(Ae*100),"%"]}),e.jsx("button",{type:"button","aria-label":"放大桌面画面",title:"放大",disabled:!v||Ae>=5,onClick:()=>ze(b=>Math.min(5,b+.25)),children:e.jsx(ol,{size:16})}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>{var b;ze(1),J(!1),(b=Xe.current)==null||b.scrollTo(0,0)},children:"适应窗口"}),e.jsxs("button",{type:"button","aria-label":"移动桌面画面","aria-pressed":ce,title:"拖动或滚动画面,不发送远程输入",disabled:!v,onClick:()=>J(b=>!b),children:[e.jsx(Zc,{size:15}),"移动画面"]}),e.jsxs("button",{type:"button","aria-label":"唤起键盘","aria-pressed":be,title:"唤起/收起键盘(轻点输入框也会自动弹起)",className:jt&&!be?"is-hint":void 0,disabled:!v||!xe,onClick:()=>{Tt(!1),Bt()},children:[e.jsx(xi,{size:15}),"键盘"]}),e.jsxs("button",{type:"button","aria-label":"快捷键条","aria-pressed":X,title:"展开/收起快捷键(Esc/Tab/复制/粘贴/方向键)",disabled:!v||!xe,onClick:()=>ae(b=>!b),children:[e.jsx(xi,{size:15}),X?"收起":"快捷键"]}),e.jsxs("button",{type:"button","aria-label":"窗口控制",title:"全屏看不到左上角按钮时用:第 1 次点=退出全屏(ESC + Ctrl+Cmd+F),第 2 次点=关闭窗口(Cmd+W)",disabled:!v||!xe,onClick:()=>{const b=Date.now();if(b-fn.current<2500){Se("w","KeyW",["Meta"]),fn.current=0;return}fn.current=b,Se("Escape","Escape"),window.setTimeout(()=>{Se("f","KeyF",["Control","Meta"])},150)},children:[e.jsx(xi,{size:15}),"窗口"]})]}),xe&&!ce&&X&&e.jsxs("div",{className:"browser-live-quickkeys",role:"group","aria-label":"快捷键",children:[e.jsx("button",{type:"button",disabled:!v,onClick:()=>Se("Escape","Escape"),children:"Esc"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>Se("Tab","Tab"),children:"Tab"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>sn("c"),children:"复制"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>sn("v"),children:"粘贴"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>sn("a"),children:"全选"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>sn("z"),children:"撤销"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>sn("s"),children:"保存"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>sn("f"),children:"查找"}),e.jsx("button",{type:"button",disabled:!v,title:"退出当前前台应用(Cmd+Q)",onClick:()=>Se("q","KeyQ",["Meta"]),children:"⌘Q"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>Se("ArrowLeft","ArrowLeft"),children:"←"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>Se("ArrowUp","ArrowUp"),children:"↑"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>Se("ArrowDown","ArrowDown"),children:"↓"}),e.jsx("button",{type:"button",disabled:!v,onClick:()=>Se("ArrowRight","ArrowRight"),children:"→"})]}),e.jsx("div",{className:"browser-live-touch-hint",children:"滑动滚动 · 轻点点击 · 双击打开 · 长按拖动 · 按住1秒右键 · 双指缩放"}),e.jsx("div",{ref:Xe,className:"browser-live-viewport",children:v&&Nt?e.jsxs("div",{className:"browser-live-image-hit-area",style:xt&&kt?{width:kt.width*xt*Ae,height:kt.height*xt*Ae,cursor:ce?"grab":void 0}:void 0,tabIndex:xe&&!ce?0:-1,onPointerDown:b=>{if(b.pointerType==="touch"){b.preventDefault(),Ze.current.down(b.pointerId,{x:b.clientX,y:b.clientY}),Ht.current=xe&&!ce?lt(b):null,b.currentTarget.setPointerCapture(b.pointerId),Qe.current&&window.clearTimeout(Qe.current),Ge.current="none",Be.current=xe&&!ce?{x:b.clientX,y:b.clientY}:null,Me.current=Date.now(),Be.current&&(Qe.current=window.setTimeout(()=>{Ge.current="armed"},550));return}if(ce&&Xe.current){const F=Xe.current;ct.current={x:b.clientX,y:b.clientY,left:F.scrollLeft,top:F.scrollTop},b.currentTarget.setPointerCapture(b.pointerId);return}if(!xe)return;const z=lt(b);z&&(nt.current=!0,b.currentTarget.setPointerCapture(b.pointerId),ye({kind:"pointer",action:"down",...z,button:"left"}))},onPointerMove:b=>{if(b.pointerType==="touch"){b.preventDefault();const F=Ze.current.move(b.pointerId,{x:b.clientX,y:b.clientY}),re=Xe.current;if(!F||!re)return;const pe=F.pointers>=2&&Math.abs(F.distanceRatio-1)>.05,Pe=Math.max(.5,Math.min(5,_.current*F.scale));if(pe&&Pe!==_.current){const He=b.currentTarget.getBoundingClientRect();ne.current={x:(F.from.x-He.left)/He.width,y:(F.from.y-He.top)/He.height,clientX:F.to.x,clientY:F.to.y},_.current=Pe,Yt.flushSync(()=>ze(Pe));return}if(Qe.current&&(window.clearTimeout(Qe.current),Qe.current=null),Ge.current==="armed"&&Be.current){Ge.current="drag";const He=lt(b);He&&ye({kind:"pointer",action:"down",...He,button:"left"})}if(Ge.current==="drag"){const He=lt(b);He&&ye({kind:"pointer",action:"move",...He,button:"left"});return}const ut=_.current<=1.001;if(xe&&!ce&&(F.pointers>=2||ut)){const He=dp(F.from,F.to);if(He){const et=Ht.current??lt(b);et&&ye({kind:"pointer",action:"wheel",...et,...He})}return}re.scrollLeft+=F.from.x-F.to.x,re.scrollTop+=F.from.y-F.to.y;return}if(ce&&ct.current&&Xe.current){const F=ct.current;Xe.current.scrollTo(F.left+F.x-b.clientX,F.top+F.y-b.clientY);return}if(!xe||!nt.current)return;const z=lt(b);z&&ye({kind:"pointer",action:"move",...z,button:"left"})},onPointerUp:b=>{var F,re;if(b.pointerType==="touch"){b.preventDefault(),Qe.current&&(window.clearTimeout(Qe.current),Qe.current=null);const pe=lt(b);if(Ht.current=null,Ge.current==="armed"&&(Ge.current="none",(Me.current?Date.now()-Me.current:0)>=800&&pe&&xe&&!ce)){Ze.current.reset(),ye({kind:"pointer",action:"down",...pe,button:"right"}),ye({kind:"pointer",action:"up",...pe,button:"right"});return}if(Ge.current==="drag"){Ge.current="none",Ze.current.reset(),pe&&xe&&ye({kind:"pointer",action:"up",...pe,button:"left"});return}if(Ze.current.up(b.pointerId,{x:b.clientX,y:b.clientY})&&pe&&xe&&!ce){const ut=ke.current,He=ut!==null&&Date.now()-Je.current<6e4&&cp(ut,(v==null?void 0:v.viewport)??($==null?void 0:$.viewport),pe.x,pe.y,.03);He&&!_e.current?((F=Ie.current)==null||F.focus({preventScroll:!0}),Ce(!0),Tt(!1)):!He&&_e.current&&((re=Ie.current)==null||re.blur(),Ce(!1));const et=(v==null?void 0:v.viewport)??($==null?void 0:$.viewport),Ct=W.current;Ct!==null&&Date.now()-Ct.at<400&&et!==void 0&&Math.hypot((pe.x-Ct.x)*et.width,(pe.y-Ct.y)*et.height)<et.width*.03?(ye({kind:"pointer",action:"down",...pe,button:"left",click:2}),St(pe,2),W.current=null):(ye({kind:"pointer",action:"down",...pe,button:"left"}),St(pe),W.current={at:Date.now(),x:pe.x,y:pe.y})}return}if(ce){ct.current=null;return}if(!xe)return;const z=lt(b);nt.current=!1,z&&St(z)},onPointerCancel:b=>{Ze.current.up(b.pointerId,{x:b.clientX,y:b.clientY},!0),ct.current=null,nt.current=!1,Ht.current=null,Qe.current&&(window.clearTimeout(Qe.current),Qe.current=null),Ge.current="none"},onLostPointerCapture:b=>{Ze.current.up(b.pointerId,{x:b.clientX,y:b.clientY},!0)},onWheel:b=>{if(!xe||ce)return;const z=lt(b);z&&ye({kind:"pointer",action:"wheel",...z,deltaX:b.deltaX,deltaY:b.deltaY})},onKeyDown:b=>{!xe||ce||b.target===Ie.current&&b.key.length===1&&!b.ctrlKey&&!b.metaKey&&!b.altKey||(ye({kind:"key",action:"down",key:b.key,code:b.code,text:b.key.length===1?b.key:"",modifiers:Ia(b)}),["Backspace","Tab","Enter","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Escape"].includes(b.key)&&b.preventDefault())},onKeyUp:b=>{!xe||ce||b.target===Ie.current&&b.key.length===1&&!b.ctrlKey&&!b.metaKey&&!b.altKey||xe&&ye({kind:"key",action:"up",key:b.key,code:b.code,modifiers:Ia(b)})},children:[e.jsx("img",{src:Nt,alt:($==null?void 0:$.title)||"浏览器实时画面",draggable:!1,decoding:"async"}),e.jsx("video",{ref:dt,className:`browser-live-video ${vn==="live"?"is-live":""}`,"aria-label":Z?"桌面实时视频流":"浏览器实时视频流",autoPlay:!0,playsInline:!0,muted:!0}),e.jsx("input",{ref:Ie,className:"browser-live-mobile-input","aria-label":"浏览器键盘输入",defaultValue:"",inputMode:"text",autoCapitalize:"none",autoCorrect:"off",autoComplete:"off",spellCheck:!1,onCompositionStart:()=>{$t.current=!0},onCompositionEnd:b=>{$t.current=!1,ce||pn(b.target.value)},onBlur:b=>{$t.current=!1,$n.current="",b.target.value="",Ce(!1)},onChange:b=>{!ce&&!$t.current&&pn(b.target.value)}})]}):e.jsxs("div",{className:"browser-live-empty",children:[V||($==null?void 0:$.availability)==="starting"?e.jsx(Dt,{size:22,className:"spin","aria-hidden":"true"}):e.jsx(Yo,{size:24,"aria-hidden":"true"}),e.jsx("strong",{children:V?"正在连接浏览器":an}),e.jsx("span",{children:It})]})}),xe&&!ce&&e.jsxs("div",{className:"browser-live-control-cue",children:[e.jsx(cd,{size:13,"aria-hidden":"true"})," ",Z?"当前输入会发送到本机":"当前输入会发送到浏览器",Z&&vn==="live"?" · 实时视频流":Z&&vn==="connecting"?" · 正在连接实时流":"",O!=null?` · ${O}ms`:""]})]}),e.jsxs("footer",{className:"browser-live-footer",children:[e.jsxs("div",{className:"browser-live-location",children:[e.jsx("span",{className:`browser-live-status-dot is-${($==null?void 0:$.state)??"idle"}`,"aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:ar}),e.jsx("span",{title:$==null?void 0:$.url,children:($==null?void 0:$.capabilityError)||(Z?"本机屏幕":$==null?void 0:$.url)||I||"等待可观看的直播会话"})]}),($==null?void 0:$.url)&&!Z&&e.jsx(Fc,{size:13,"aria-hidden":"true"})]}),$&&(xe?e.jsxs("button",{type:"button",className:"browser-live-control-button is-return",onClick:()=>void jn(),disabled:G,children:[G&&e.jsx(Dt,{size:14,className:"spin","aria-hidden":"true"}),Z?"结束控制":"归还给 Agent"]}):e.jsxs("button",{type:"button",className:"browser-live-control-button",onClick:()=>void Ir(),disabled:!or||G||$.state!=="agent-controlled"||$.availability!=="ready",children:[G&&e.jsx(Dt,{size:14,className:"spin","aria-hidden":"true"}),$.controlledByAnotherViewer?"其他设备操作中":Z?"开始控制":"接管浏览器"]}))]}),I&&e.jsx("div",{className:"browser-live-error",role:"alert",children:I})]})}),document.body)}const pp=[{prompt:"带我熟悉这个项目",Icon:Wc},{prompt:"帮我排查一个问题",Icon:il},{prompt:"一起实现一个新想法",Icon:td}];function fp(t){return t>=5&&t<9?{title:"早啊。",prompt:"新的一天,想做点什么?"}:t>=9&&t<12?{title:"上午好。",prompt:"今天想一起做点什么?"}:t>=12&&t<14?{title:"中午好。",prompt:"想趁午休推进点什么?"}:t>=14&&t<18?{title:"下午好。",prompt:"这个下午,想做点什么?"}:t>=18&&t<23?{title:"晚上好。",prompt:"今晚想一起做点什么?"}:{title:"夜深了。",prompt:"注意休息,重要的事可以先留给我。"}}const hp={"customer-agent":"Customer Agent",codex:"Codex","claude-code":"Claude Code",opencode:"OpenCode"};function gp({agentType:t,ready:n,now:r,onSelectPrompt:s}){const i=hp[t],a=fp((r??new Date).getHours());return e.jsxs("section",{className:"empty-session-welcome","aria-labelledby":"empty-session-welcome-title",children:[e.jsxs("div",{className:"empty-session-welcome__core","aria-hidden":"true",children:[e.jsx("span",{className:"empty-session-welcome__glow"}),e.jsxs("svg",{viewBox:"0 0 120 120",role:"presentation",children:[e.jsx("circle",{className:"empty-session-welcome__orbit empty-session-welcome__orbit--outer",cx:"60",cy:"60",r:"44"}),e.jsx("circle",{className:"empty-session-welcome__orbit empty-session-welcome__orbit--inner",cx:"60",cy:"60",r:"33"}),e.jsx("rect",{className:"empty-session-welcome__diamond",x:"43",y:"43",width:"34",height:"34",rx:"2"}),e.jsx("circle",{className:"empty-session-welcome__pulse",cx:"60",cy:"60",r:"3"})]})]}),e.jsxs("div",{className:"empty-session-welcome__copy",children:[e.jsx("p",{className:"empty-session-welcome__status",children:n?`${i} · 已准备好`:`${i} · 等待配置`}),e.jsx("h2",{id:"empty-session-welcome-title",children:a.title}),e.jsx("p",{className:"empty-session-welcome__prompt",children:n?a.prompt:"配置好 API Key 后,我就能开始。"})]}),e.jsx("div",{className:"empty-session-welcome__starters","aria-label":"开始一个任务",children:pp.map(({prompt:c,Icon:d})=>e.jsxs("button",{type:"button","data-prompt":c,disabled:!n,onClick:()=>s(c),children:[e.jsx(d,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),e.jsx("span",{children:c})]},c))})]})}function xp({image:t,onClose:n}){return l.useEffect(()=>{if(!t)return;const r=document.body.style.overflow,s=i=>{i.key==="Escape"&&n()};return document.body.style.overflow="hidden",window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s),document.body.style.overflow=r}},[t,n]),t?Yt.createPortal(e.jsxs("div",{className:"message-image-lightbox",role:"dialog","aria-modal":"true","aria-label":"图片预览",onClick:r=>{r.target===r.currentTarget&&n()},children:[e.jsx("img",{className:"message-image-lightbox__image",src:t.src,alt:t.alt}),e.jsx("button",{type:"button",className:"message-image-lightbox__close",onClick:n,"aria-label":"关闭图片预览",title:"关闭",autoFocus:!0,children:e.jsx(Kr,{size:22,"aria-hidden":"true"})})]}),document.body):null}const mp={pending:"⏳",image_generating:"🎨",video_generating:"🎬",done:"✅",error:"❌"};function bp(t){const{title:n="视频工作台",shots:r=[],status:s="generating",composedVideoUrl:i,isAgentRunning:a}=t,[c,d]=l.useState(!1),[u,h]=l.useState(null);return e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",background:"var(--bg-surface)",overflow:"hidden",maxWidth:600},children:[e.jsxs("div",{onClick:()=>d(!c),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",background:"var(--bg-deep)",cursor:"pointer",userSelect:"none",borderBottom:c?"none":"1px solid var(--border-subtle)"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:["🎬 ",n]}),e.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[r.filter(g=>g.status==="done").length,"/",r.length," 完成",e.jsx("span",{style:{marginLeft:6,transform:c?"rotate(-90deg)":"none",display:"inline-block",transition:"transform 0.2s"},children:"▼"})]})]}),!c&&e.jsxs("div",{style:{padding:"12px 16px"},children:[e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:13,marginBottom:12},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"var(--bg-deep)"},children:[e.jsx("th",{style:hs,children:"#"}),e.jsx("th",{style:{...hs,textAlign:"left",minWidth:120},children:"画面描述"}),e.jsx("th",{style:hs,children:"时长"}),e.jsx("th",{style:hs,children:"状态"}),e.jsx("th",{style:hs,children:"预览"})]})}),e.jsx("tbody",{children:r.map(g=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("td",{style:gs,children:g.index}),e.jsx("td",{style:{...gs,textAlign:"left",maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.description,children:g.description}),e.jsxs("td",{style:gs,children:[g.duration,"s"]}),e.jsxs("td",{style:gs,children:[mp[g.status]??"⏳",g.error&&e.jsx("span",{style:{color:"var(--danger)",fontSize:11,marginLeft:4},title:g.error,children:"!"})]}),e.jsx("td",{style:gs,children:g.videoUrl?e.jsx("button",{onClick:()=>h(g.videoUrl),style:{background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid rgba(79,110,247,0.22)",borderRadius:6,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"▶ 播放"}):g.previewImageUrl?e.jsx("img",{src:g.previewImageUrl,alt:`shot-${g.index}`,style:{width:48,height:32,objectFit:"cover",borderRadius:4,border:"1px solid var(--border-subtle)"}}):e.jsx("span",{style:{color:"var(--text-muted)",fontSize:11},children:"—"})})]},g.index))})]}),u&&e.jsx("video",{src:u,controls:!0,autoPlay:!0,style:{width:"100%",borderRadius:8,marginBottom:12,border:"1px solid var(--border-subtle)"}}),i&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",marginBottom:6},children:"完整视频"}),e.jsx("video",{src:i,controls:!0,style:{width:"100%",borderRadius:8,border:"1px solid var(--border-subtle)"}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-muted)"},children:[s==="generating"&&e.jsx("span",{children:a===!1?"本轮已结束":"🔄 生成中..."}),s==="preview_ready"&&e.jsx("span",{children:"📷 预览图已就绪"}),s==="video_ready"&&e.jsx("span",{children:"🎬 视频片段已就绪"}),s==="composed"&&e.jsx("span",{children:"✅ 合成完成"})]})]})]})}const hs={padding:"6px 10px",textAlign:"center",fontWeight:600,fontSize:12,color:"var(--text-muted)",borderBottom:"1px solid var(--border-subtle)"},gs={padding:"6px 10px",textAlign:"center",fontSize:13,color:"var(--text-secondary)"},yp={storyboard_workbench:bp};function vp(t,n,r){return!t||n!==t?!1:r===null||r===t}function wp(t,n,r=Date.now()){return!t||t.sessionId!==n?t:{...t,until:r+9e4}}async function jp(t){const{text:n,projectId:r,createSession:s,activateSession:i,showUserMessage:a,onSessionCreated:c,isCancelled:d}=t,u=!t.sessionId;let h=t.sessionId??null;if(!h){const g=await s(n.slice(0,60)||"语音任务",r||void 0);if(d!=null&&d())return null;h=g.id}return i(h),a(n,h),u&&c&&await c(h),h}async function Ca(t){var i,a;const n=((i=t.sessionId)==null?void 0:i.trim())||null,r=!n,s=n??(await t.createSession(t.text.slice(0,60)||"New Session",t.projectId||void 0)).id.trim();if(!s)throw new Error("创建会话失败:服务端未返回会话 ID");return t.activateSession(s),t.showUserMessage(t.text,s),r&&await((a=t.onSessionCreated)==null?void 0:a.call(t,s)),s}const kp=/\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|[ \t]*\/[^)\n]+)\)/gi,Sp=/`([^`\n]+)`/g,Ip=/:codex-file-citation\{([^}\n]*)\}/g,Ra=/([A-Za-z][\w-]*)="([^"\n]*)"/g,Cp=/\uE200visualize\uE202([^\uE201\n]+)\uE201/g;function io(t){if(!t.startsWith("/")||t.includes("?")||t.includes("#")||t.includes("\0"))return null;const n=t.match(/^(\/.*):([1-9]\d*)$/);return n?{path:n[1],line:Number(n[2])}:{path:t}}function Rp(t){const n={};for(const i of t.matchAll(Ra)){const a=i[1];if(a!=="path"&&a!=="purpose"||n[a]!==void 0)return null;n[a]=i[2]}if(t.replace(Ra,"").trim())return null;const r=io(n.path??"");if(!r||r.line!==void 0)return null;const s=r.path.slice(r.path.lastIndexOf("/")+1)||r.path;return{path:r.path,label:s}}function Ap(t){try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return null;const{path:r,title:s,mode:i}=n;if(typeof r!="string"||s!==void 0&&typeof s!="string"||i!==void 0&&typeof i!="string")return null;const a=io(r);if(!a||a.line!==void 0)return null;const c=(s==null?void 0:s.trim())||a.path.slice(a.path.lastIndexOf("/")+1)||a.path;return{path:a.path,label:c}}catch{return null}}function Mp(t,n){const r=[];let s=0;const i=[...[...t.matchAll(kp)].map(a=>({kind:"markdown",match:a})),...[...t.matchAll(Ip)].map(a=>({kind:"citation",match:a})),...[...t.matchAll(Cp)].map(a=>({kind:"visualize",match:a})),...[...t.matchAll(Sp)].map(a=>({kind:"code",match:a}))].sort((a,c)=>(a.match.index??0)-(c.match.index??0));for(const a of i){const{match:c}=a,d=c.index??0;if(d<s)continue;if(d>s&&r.push({type:"text",value:t.slice(s,d)}),a.kind==="code"){r.push({type:"code",value:c[1]}),s=d+c[0].length;continue}if(a.kind==="citation"){const h=Rp(c[1]);r.push(h?{type:"artifact",label:h.label,path:h.path,raw:c[0]}:{type:"text",value:c[0]}),s=d+c[0].length;continue}if(a.kind==="visualize"){const h=Ap(c[1]);r.push(h?{type:"artifact",label:h.label,path:h.path,raw:c[0]}:{type:"text",value:c[0]}),s=d+c[0].length;continue}const u=c[2];if(/^https?:\/\//i.test(u))r.push({type:"link",label:c[1],href:u});else{const h=io(u.replace(/^[ \t]+/,""));h?r.push({type:"artifact",label:c[1],path:h.path,...h.line?{line:h.line}:{},raw:c[0]}):r.push({type:"text",value:c[0]})}s=d+c[0].length}return s<t.length&&r.push({type:"text",value:t.slice(s)}),r.length>0?r:[{type:"text",value:t}]}function Ep(t){return Mp(t)}function Wl(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function Tp(t){const n=Wl(t);return n===void 0?void 0:`${Math.round(n/1e3)} 秒`}function Np(t){return t.role==="user"&&!t.isQueued&&!t.isSteered}function zp(t){var n,r,s;return t.role==="assistant"&&!!(t.content.trim()||(n=t.toolCalls)!=null&&n.length||(s=(r=t.presentation)==null?void 0:r.reasoning)!=null&&s.length||t.askUser||t.widget)}function Lp(t,n,r){var a;const s=t[n];if((s==null?void 0:s.role)!=="assistant"||!s.content.trim()||(a=s.toolCalls)!=null&&a.length||s.isCompactionSummary)return!1;let i=!r;for(let c=n+1;c<t.length;c++){const d=t[c];if(!d.isCompactionSummary){if(Np(d)){i=!0;break}if(zp(d))return!1}}return i}function _p(t,n,r){const s=t[n];if(!s)return{showCopy:!1,showSpeak:!1,showCompletion:!1,compact:!1};if(s.role==="user")return{showCopy:!!s.content,showSpeak:!1,showCompletion:!1,compact:!1};const i=Lp(t,n,r);return{showCopy:i,showSpeak:i,showCompletion:i,compact:s.role==="assistant"&&!i&&!s.isCompactionSummary}}const Pp=new Set(["image/jpeg","image/png","image/gif","image/webp"]);async function Wp(t,n){const r=[],s=[],i=[];for(const c of t){const d=c.type.trim().toLowerCase();d.startsWith("image/")?Pp.has(d)?r.push(c):i.push(c):s.push(c)}const a=await Promise.all(r.map(async c=>{try{return{file:c,dataUrl:await n(c)}}catch{return{file:c,dataUrl:null}}}));return{images:a.flatMap(c=>c.dataUrl?[c.dataUrl]:[]),attachments:s,unsupportedImages:i,failedImages:a.flatMap(c=>c.dataUrl?[]:[c.file])}}function _s(t,n){return n?t[n]:void 0}function Dp(t,n){const r=Object.fromEntries(Object.entries(t).filter(([,s])=>s.token!==n.token&&s.sourceSessionId!==n.sourceSessionId));return r[n.sourceSessionId]=n,n.forkSessionId&&(r[n.forkSessionId]=n),r}function Bp(t,n){const r=t[n];return r?Object.fromEntries(Object.entries(t).filter(([,s])=>s.token!==r.token)):t}function $p(t,n,r=crypto.randomUUID()){return{token:r,sourceSessionId:t,payload:{...n,images:n.images?[...n.images]:void 0,agentIds:n.agentIds?[...n.agentIds]:void 0},sendAttempted:!1}}function Aa(t,n){return t.forkSessionId===n&&t.sendAttempted?t:{...t,forkSessionId:n,sendAttempted:!0}}function Op(t){return`occupied-recovery:${t.token}`}function Fp(t,n){return!!(t&&n&&(t.sourceSessionId===n||t.forkSessionId===n))}async function Hp(t){const n=await t.forkSession(t.sourceSessionId);return t.activateSession(n.id),await t.refreshAndSelect(n),n}const Dn=50,Ci=1,xs=1,Ma=160;function Ea(t){return t.trim().replace(/^\/goal\s+/i,"").replace(/^\$([\w-]+)/,"/$1").trim()}function Ri(t){const r=t.trim().replace(/^每(?:隔)?/,"").match(/^(\d+(?:\.\d+)?)\s*(s|sec|秒|m|min|分钟?|h|hr|小时)$/i);if(r){const a=parseFloat(r[1]),c=r[2].toLowerCase(),d=c==="s"||c==="sec"||c==="秒"?a*1e3:c==="m"||c==="min"||c==="分"||c==="分钟"?a*6e4:a*36e5;return d>=36e5&&d%36e5===0?`每 ${d/36e5} 小时`:d>=6e4&&d%6e4===0?`每 ${d/6e4} 分钟`:`每 ${d/1e3} 秒`}const[s,i]=t.trim().split(/\s+/);return s==="0"&&i&&i!=="*"&&!i.includes("/")&&!i.includes(",")?`每天 ${i.padStart(2,"0")}:00`:`cron: ${t}`}function Up(t){const n=t.split(/(`[^`\n]+`)/g);return n.length<=1?t:e.jsx(e.Fragment,{children:n.map((r,s)=>s%2===1?e.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:"0.84em",background:"rgba(17,24,39,0.06)",padding:"1px 5px",borderRadius:4,color:"var(--accent)",border:"1px solid var(--border-subtle)"},children:r.slice(1,-1)},s):e.jsx("span",{children:r},s))})}function Dl(t,n){return t.split(/(\*\*[^*]+\*\*|\*[^*]+\*)/g).map((s,i)=>{const a=`${n}-${i}`;return s.startsWith("**")&&s.endsWith("**")&&s.length>4?e.jsx("strong",{style:{fontWeight:600,color:"var(--text-primary)"},children:s.slice(2,-2)},a):s.startsWith("*")&&s.endsWith("*")&&s.length>2?e.jsx("em",{children:s.slice(1,-1)},a):e.jsx("span",{children:s},a)})}function Ta(t,n){return t.split(/(`[^`\n]+`)/g).map((s,i)=>i%2===1?e.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:"0.84em",background:"rgba(17,24,39,0.06)",padding:"1px 5px",borderRadius:4,color:"var(--accent)",border:"1px solid var(--border-subtle)"},children:s.slice(1,-1)},`${n}-${i}`):Dl(s,`${n}-${i}`))}function Ki(t){return Ep(t).map((n,r)=>{if(n.type==="code")return e.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:"0.84em",background:"rgba(17,24,39,0.06)",padding:"1px 5px",borderRadius:4,color:"var(--accent)",border:"1px solid var(--border-subtle)"},children:n.value},r);if(n.type==="link")return e.jsx("a",{className:"chat-message-link",href:n.href,target:"_blank",rel:"noopener noreferrer",children:Ta(n.label,`${r}-label`)},r);if(n.type==="artifact"){if(!rr())return e.jsx("span",{children:n.raw},r);const s=n.line?`${n.path}:${n.line}`:n.path,i=n.label.replace(/^`([^`\n]+)`$/,"$1");return e.jsxs("button",{type:"button",className:"chat-message-artifact-link",title:s,"aria-label":`打开交付物 ${i}`,onClick:()=>Sr(n.path),children:[e.jsx(Vs,{size:16,strokeWidth:1.8,"aria-hidden":"true"}),e.jsx("span",{children:Ta(n.label,`${r}-label`)})]},r)}return Dl(n.value,`${r}`)})}function qp(t){if(t.length<2)return null;const n=a=>a.replace(/^\|/,"").replace(/\|$/,"").split("|").map(c=>c.trim()),r=n(t[0]),s=t[1].replace(/^\|/,"").replace(/\|$/,"");if(!/^[\s\-:|]+$/.test(s))return null;const i=t.slice(2).map(n);return{headers:r,rows:i}}function Vp(t,n){const r=s=>({padding:"6px 14px",textAlign:"left",fontSize:13,fontWeight:s?600:400,color:s?"var(--text-primary)":"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",whiteSpace:"pre-wrap",wordBreak:"break-word"});return e.jsx("div",{style:{margin:"8px 0",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",overflow:"auto",background:"var(--bg-surface)"},children:e.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"var(--bg-deep)"},children:t.map((s,i)=>e.jsx("th",{style:r(!0),children:Ki(s)},i))})}),e.jsx("tbody",{children:n.map((s,i)=>e.jsx("tr",{style:{background:i%2===0?"transparent":"rgba(0,0,0,0.015)"},children:s.map((a,c)=>e.jsx("td",{style:r(!1),children:Ki(a)},c))},i))})]})})}function Kp(t,n,r){return t.toLowerCase()==="mermaid"?e.jsx(_d,{code:n,complete:r}):e.jsxs("div",{style:{margin:"8px 0",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",overflow:"hidden",background:"var(--bg-surface)"},children:[e.jsx("div",{style:{padding:"4px 10px",background:"var(--bg-deep)",borderBottom:"1px solid var(--border-subtle)",fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em"},children:t||"code"}),e.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:12,lineHeight:1.6,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"auto",maxHeight:420},children:n})]})}function ms(t){const n=t.split(`
|
|
361
|
+
`),r=[];let s=0,i=0;const a=d=>d.trimStart().startsWith("```"),c=d=>n[d].trimStart().startsWith("|")&&d+1<n.length&&/^\|[\s\-:|]+\|$/.test(n[d+1].trim());for(;s<n.length;){if(a(n[s])){const d=n[s].trim().slice(3).trim();s++;const u=[];for(;s<n.length&&!a(n[s]);)u.push(n[s]),s++;const h=s<n.length;s++,r.push(e.jsx("div",{children:Kp(d,u.join(`
|
|
362
|
+
`),h)},`code-${i++}`));continue}if(c(s)){const d=[];for(;s<n.length&&n[s].trimStart().startsWith("|");)d.push(n[s].trim()),s++;const u=qp(d);u?r.push(e.jsx("div",{children:Vp(u.headers,u.rows)},`tbl-${i++}`)):r.push(e.jsx("span",{children:d.map((h,g)=>e.jsxs("span",{children:[Up(h),g<d.length-1?`
|
|
363
|
+
`:null]},g))},`tbl-fb-${i++}`))}else{const d=[];for(;s<n.length&&!c(s)&&!a(n[s]);)d.push(n[s]),s++;d.length>0&&r.push(e.jsx("span",{children:d.map((u,h)=>e.jsxs("span",{children:[Ki(u),h<d.length-1?`
|
|
364
|
+
`:null]},h))},`txt-${i++}`))}}return e.jsx(e.Fragment,{children:r})}const Bl=[{value:"off",label:"关"},{value:"low",label:"低"},{value:"medium",label:"中"},{value:"high",label:"高"}],Na=Object.fromEntries(Bl.map(t=>[t.value,t.label])),Gp=750,Ai={low:"低",medium:"中",high:"高",xhigh:"超高",max:"最大"},za={codex:"Codex","claude-code":"Claude Code",opencode:"OpenCode"};function Qp(t,n){return n==="codex"?t==="openai":n==="claude-code"?t==="anthropic":!1}const $s=[{value:"request-approval",label:"请求批准",description:"编辑外部文件和使用互联网时始终询问"},{value:"auto-approval",label:"帮我批准",description:"仅对检测到的风险操作请求批准"},{value:"full-access",label:"完全访问权限",description:"可不受限制地访问互联网和你电脑上的任何文件"}];function La(t){return $s.some(n=>n.value===t)?t:"full-access"}function Yp({activeAgentType:t="customer-agent",selectedProjectId:n=null,selectedSessionId:r=null,onSessionCreated:s,onMessageSent:i,onSubSessionCreated:a,onSelectSession:c,onSubAgentEvent:d,onRunComplete:u,sessionTitle:h,sessionSummary:g,workspacePath:y=null,onOpenSettings:m,settingsOpen:k=!1,onHideToBackground:C,onOpenHub:E,onOpenDesktopLive:A,desktopLiveOpen:S=!1,onToggleAppearance:j,appearanceOpen:v=!1,hideToBackgroundTitle:D,voiceCommand:V=null}){var zo,Lo,_o,Po,Wo,Do,Bo,$o,Oo,Fo;const{messages:R,runningSessionId:T,appendText:P,addMessage:I,setRunningSession:N,setSessionId:G,updateToolResult:ie,updateSubAgentStatus:Ae,updateSubAgentProgress:ze,updateMessage:ce,setMessages:J,getMessagesForSession:je,contextUsageBySession:Ke,runtimeProgressBySession:Xe,nativeSubagentsBySession:ct,setContextUsage:nt,applyRuntimeProgress:Ht,setRuntimeProgress:Ze,clearRuntimeProgress:_,applyNativeSubagentActivity:ne,setNativeSubagentActivities:Ie,applyReasoningSummary:be,applyCodexExecutionEvent:Ce,clearMessages:_e,sessionId:ke,todos:Je,setTodos:jt,cronTasks:Tt,setCronTasks:Be}=Le(),[Me,Ge]=l.useState({active:null,queued:[],history:[]}),[Qe,W]=l.useState(0),O=l.useMemo(()=>Ll(Nu(R.filter(o=>!o.isQueued),Me.queued)),[Me.queued,R]),K=l.useMemo(()=>{var o,f;return(f=(o=O.findLast(x=>x.executionTrace))==null?void 0:o.executionTrace)==null?void 0:f.turnId},[O]),{isConfigured:X,profiles:ae,activeProfileId:Re,switchActiveProfile:ht,loadFromSystem:vn,contextWindow:gt,reasoningEffort:Ye,setField:dt,saveToSystem:$}=Ks(),Z=r||ke,[xe,kt]=l.useState({}),xt=l.useRef({}),Bt=l.useCallback((o,f)=>{const x=o?Dp(xt.current,o):f?Bp(xt.current,f):xt.current;xt.current=x,kt(x)},[]),at=_s(xe,Z),[Xt,mt]=l.useState(!1),[wn,un]=l.useState("idle"),[Nt,Zt]=l.useState(!1);l.useEffect(()=>{if(!rr()||!window.browserLiveApi)return;const o=()=>Zt(!0);return window.addEventListener(Ko,o),()=>window.removeEventListener(Ko,o)},[]);const[st,zt]=l.useState(null),[Ir,jn]=l.useState(null),ye=Lu(g,t),Se=(g==null?void 0:g.agentType)??t,[sn,kn]=l.useState([]),St=l.useRef(null),[$t,$n]=l.useState(()=>ea(Se)),[pn,rt]=l.useState(!1),on=l.useRef(null);l.useEffect(()=>{$n(ea(Se)),rt(!1)},[Se]),l.useEffect(()=>{var o;!ye||!((o=window.agentApi)!=null&&o.listAgentModels)||St.current!==Se&&(St.current=Se,kn([]),window.agentApi.listAgentModels(Se).then(f=>kn(f.models??[])).catch(()=>{kn([]),St.current=null}))},[ye,Se]),l.useEffect(()=>{if(!pn)return;const o=f=>{on.current&&!on.current.contains(f.target)&&rt(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[pn]);const fn=l.useCallback(o=>{$n(f=>{const x={...f,...o};return Wd(Se,x),x})},[Se]),hn=l.useMemo(()=>ye?sn.map(o=>({key:bi(o),label:o.displayName||o.id,model:{id:o.id,...o.providerID?{providerID:o.providerID}:{}},reasoningEfforts:o.reasoningEfforts})):[],[ye,sn]),lt=l.useMemo(()=>ye?(ae??[]).filter(o=>{var f;return(f=o.modelId)==null?void 0:f.trim()}).filter(o=>Se==="opencode"||Qp(o.provider,Se)).map(o=>({key:Se==="opencode"?bi({id:o.modelId,providerID:o.provider}):o.modelId,label:o.name||o.modelId,model:{id:o.modelId,...Se==="opencode"?{providerID:o.provider}:{}}})):[],[ye,ae,Se]),or=(zo=$t.model)!=null&&zo.id?bi($t.model):"",ar=l.useMemo(()=>{var f;const o=hn.find(x=>x.key===or);if((f=o==null?void 0:o.reasoningEfforts)!=null&&f.length)return o.reasoningEfforts;if(Se==="claude-code")return["low","medium","high","xhigh"]},[hn,or,Se]),an=l.useMemo(()=>ye?Se==="codex"?ar??[]:Se==="claude-code"?ar??["low","medium","high","xhigh"]:[]:[],[ye,Se,ar]),It=$t.reasoningEffort&&an.includes($t.reasoningEffort)?$t.reasoningEffort:void 0,b=hn.length>0||lt.length>0,z=(g==null?void 0:g.messageQueueVersion)===1,F=Iu(g==null?void 0:g.agentType),re=st===Z?"direct":Ir?"incompatible":(Lo=g==null?void 0:g.compatibility)==null?void 0:Lo.status,pe=re!==void 0&&re!=="direct",Pe=pe||(g==null?void 0:g.occupancy)==="owned-externally"&&g.agentType!=="codex",ut=Fp(at,Z),He=X||ye,et=He&&!Pe&&!ut&&wn!=="released",Ct=l.useRef(new Set),[lr,Jt]=l.useState("idle"),ln=l.useRef("idle"),Cr=l.useRef(null),[Rr,Sn]=l.useState(()=>Date.now()),On=!!(Z&&(T===Z||Ct.current.has(Z))),Ot=Wu(g,On),gn=On||_u(g),cn=Z?Xe[Z]??[]:[],dn=Z?ct[Z]??{}:{},In=Bd(cn),Cn=O[O.length-1],Zs=!!((Cn==null?void 0:Cn.role)==="assistant"&&lr==="thinking"&&((Po=(_o=Cn.presentation)==null?void 0:_o.reasoning)!=null&&Po.some(o=>o.text.trim()))),Js=lr==="tools"&&O.some(o=>{var f;return((f=o.toolCalls)==null?void 0:f.length)&&!ji(o.toolCalls)}),ei=gn&&!In&&!Zs&&!Js;l.useEffect(()=>{vn()},[]),l.useEffect(()=>{window.agentApi&&window.agentApi.cronList().then(o=>Be(o))},[]);const[Ut,bt]=l.useState(""),[Rn,cr]=l.useState(null),[Yr,qt]=l.useState(""),[An,Vt]=l.useState(null),[dr,Fn]=l.useState(null),Mn=l.useRef(null),[xn,Hn]=l.useState(!1),[Ar,Xr]=l.useState(!1),[ur,Un]=l.useState(!1),[mn,qn]=l.useState("full-access"),[en,Zr]=l.useState(!1),[js,Mr]=l.useState(null),[$e,Vn]=l.useState(!1),Rt=l.useRef(null),Lt=l.useRef(null),_t=l.useCallback((o,f)=>{const x=Fe.current||Ft.current;f===x&&Ge(ya(o));const w=je(f);J(wi(w,o),f)},[je,J]);l.useEffect(()=>{if(!Ar)return;const o=f=>{Rt.current&&!Rt.current.contains(f.target)&&Xr(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[Ar]),l.useEffect(()=>{if(!ur)return;const o=f=>{Lt.current&&!Lt.current.contains(f.target)&&Un(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[ur]),l.useEffect(()=>{Un(!1),qn(La(g==null?void 0:g.permissionMode))},[ye,r,g==null?void 0:g.permissionMode]);const[Er,we]=l.useState(null),[Kn,pr]=l.useState(null),[bn,Kt]=l.useState(0),[ks,Tr]=l.useState([]),[Nr,En]=l.useState([]),[Jr,zr]=l.useState(0),[ti,Tn]=l.useState(null),Gt=l.useRef(null),Ss=l.useRef(null),Nn=l.useRef(null),Lr=l.useRef(()=>{}),fr=l.useRef(new Cd),es=l.useRef(()=>{}),Qt=l.useRef(null),zn=l.useRef(null),tn=l.useRef(null);tn.current||(tn.current=new cu);const p=l.useRef(null),L=l.useRef("latest"),q=l.useRef(null),Q=l.useRef(!1),Y=l.useRef(null),ge=l.useRef(0),de=l.useRef(0),ue=l.useRef(null),Ue=l.useRef(!1),yt=l.useRef(!1),vt=l.useRef(null),me=l.useRef(!1),Oe=l.useRef(!1),pt=l.useRef(null),ft=l.useRef(null),nn=l.useRef(0),Ln=l.useRef(null),Pt=l.useRef(new Map),Gn=l.useRef(new Set),Qn=l.useRef(null),Ne=l.useRef(!1),wt=l.useRef(!1),ts=l.useRef(null),_n=l.useRef(null),[ao,lo]=l.useState(!1),[Is,Cs]=l.useState(null),[ni,ri]=l.useState(null),[ns,ql]=l.useState("latest"),[Vl,_r]=l.useState(null),[Kl,Pr]=l.useState(null),[Gl,Wr]=l.useState(!1),[Ql,co]=l.useState(!1),[si,Rs]=l.useState(!1),[Yl,uo]=l.useState(!1),[As,Ms]=l.useState(!1),[Xl,Es]=l.useState(!1),po=l.useRef(null),rs=l.useRef(null),ii=l.useRef(null),[Yn,fo]=l.useState(null),[Zl,ho]=l.useState([]),[Jl,go]=l.useState([]),[ss,oi]=l.useState([]),[is,hr]=l.useState(null),[gr,xr]=l.useState(null),We=l.useCallback(o=>Fe.current===o?g==null?void 0:g.agentType:o.startsWith("runtime:codex:")?"codex":void 0,[g==null?void 0:g.agentType]),At=l.useCallback((o,f)=>{if(!f)return;const x=`${o}:${f}`;Ln.current!==x&&(Ln.current=x,Pt.current.clear())},[]),ai=l.useCallback(async o=>{const f=window.agentApi,x=Fe.current;if(!f||!x)throw new Error("当前会话不可用");At(x,o.revision);const w=`${o.turnId}:${o.itemId}`;let B=Pt.current.get(w);B||(B=f.getSessionToolResult(x,o),Pt.current.set(w,B),B.catch(()=>{Pt.current.get(w)===B&&Pt.current.delete(w)}));const M=await B;return Fe.current!==x||Ln.current!==`${x}:${o.revision}`,M},[At]),xo=l.useCallback(async o=>{const f=Fe.current;if(!f)throw new Error("当前会话不可用");const x=await ai(o);Fe.current===f&&ie(o.itemId,x.content,x.isError,f)},[ai,ie]),ec=l.useCallback(async o=>{var M;const f=window.agentApi,x=Fe.current;if(!f||!x)throw new Error("当前会话不可用");const w=await eu(f,x,o,Dn),B=w.detail;if(Fe.current!==x)throw new DOMException("Session selection changed","AbortError");if(((M=B==null?void 0:B.history)==null?void 0:M.revision)!==w.revision)throw new Error("会话内容已更新,请重新展开执行过程");return w.recovered&&J(je(x).map(te=>te.executionTrace?{...te,executionTrace:{...te.executionTrace,revision:w.revision}}:te),x),At(x,w.revision),nu(B)},[je,J,At]);l.useEffect(()=>{Ln.current=null,Pt.current.clear()},[r]);const yn=l.useCallback((o,f)=>{const x=window.agentApi;!f||!x||tn.current.prefetch(o,f,()=>x.getSession(o,{before:f,limit:We(o)==="codex"?xs:Dn,...We(o)==="codex"?{view:"core"}:{}})).catch(w=>{console.warn("[chat] failed to prefetch older history",{sessionId:o,error:w})})},[We]),mr=l.useCallback(o=>{L.current=o,ql(o)},[]);l.useEffect(()=>{if(!ye||!Z){Qn.current=null;return}if(Qn.current!==Z){Qn.current=Z;const o=_s(xt.current,Z);bt((o==null?void 0:o.payload.content)??Au(Z)),En((o==null?void 0:o.payload.images)??[]);return}if(Ne.current&&Ut===""){Ne.current=!1;return}vi(Z,Ut)},[Ut,ye,Z]);const tc=()=>{const o=Gt.current;o&&(o.scrollTop<=240&&Lr.current(),L.current==="anchored"&&o.scrollHeight-o.scrollTop-o.clientHeight<=240&&es.current(),uo(o.scrollHeight-o.scrollTop-o.clientHeight>Ma),o.classList.add("is-scrolling"),Nn.current!==null&&window.clearTimeout(Nn.current),Nn.current=window.setTimeout(()=>{o.classList.remove("is-scrolling"),Nn.current=null},700))};l.useEffect(()=>()=>{Nn.current!==null&&window.clearTimeout(Nn.current)},[]);const nc=l.useCallback(()=>{const o=Gt.current;if(!o)return;const f=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;o.scrollTo({top:o.scrollHeight,behavior:f?"auto":"smooth"})},[]);l.useLayoutEffect(()=>{const o=ts.current,f=Gt.current;!o||!f||(f.scrollTop=o.scrollTop+(f.scrollHeight-o.scrollHeight),ts.current=null)},[R]),l.useLayoutEffect(()=>{const o=ue.current,f=Gt.current;if(!o||!f)return;const x=Array.from(f.querySelectorAll("[data-message-id]")).find(w=>w.dataset.messageId===o);x&&(Mi(f,x),ue.current=null,_r(o))},[R]),l.useLayoutEffect(()=>{const o=Gt.current;!Ue.current||!o||ns!=="latest"||(Ue.current=!1,o.scrollTop=o.scrollHeight)},[ns,R]),l.useLayoutEffect(()=>{if(_n.current!=="skip")return;const o=Gt.current;o&&uo(o.scrollHeight-o.scrollTop-o.clientHeight>Ma)},[R]);const[mo,li]=l.useState(!1),[os,as]=l.useState(null),Ts=l.useRef(null);l.useEffect(()=>{const o=window.agentApi;if(!(o!=null&&o.onTtsStart)||!o.onTtsPcm||!o.onTtsStreamEnd||!o.onTtsFlush)return;const f=new Jd(o),x=[o.onTtsStart(w=>f.start(w)),o.onTtsPcm(({generation:w,pcm:B})=>f.enqueue(w,B)),o.onTtsStreamEnd(({generation:w})=>f.finish(w)),o.onTtsFlush(({generation:w})=>f.flush(w)),o.onTtsEnd(()=>as(null))];return()=>{for(const w of x)w();f.dispose()}},[]);const rc=()=>{var x;if(mo){(x=Ts.current)==null||x.stop(),Ts.current=null,li(!1);return}zs(window.agentApi,fs);const o=Ut?`${Ut.trimEnd()} `:"",f=Qd({onInterim:w=>bt(o+w),onFinal:w=>{var B;bt(o+w),(B=rs.current)==null||B.focus()},onError:w=>we(w),onEnd:()=>{li(!1),Ts.current=null}});f&&(Ts.current=f,li(!0))},sc=async(o,f)=>{var x;if(os===o){await zs(window.agentApi,fs),as(null);return}if(await zs(window.agentApi,fs),!((x=window.agentApi)!=null&&x.ttsSpeak)){we("TTS 模型服务不可用");return}as(o);try{(await window.agentApi.ttsSpeak(f)).ok||(as(null),we("TTS 模型播报失败"))}catch(w){as(null),we(w instanceof Error?w.message:"TTS 模型播报失败")}},it=l.useRef(null),br=l.useRef(!1),Dr=l.useRef(new Set),ls=l.useRef(new Map),bo=l.useRef(new Set),cs=l.useRef(new Map),Xn=l.useRef(null),Fe=l.useRef(r??null),Ft=l.useRef(null),Br=l.useRef(0);l.useEffect(()=>{Fe.current=r??null},[r]),l.useEffect(()=>{Ft.current=ke},[ke]),l.useEffect(()=>()=>{for(const o of ls.current.values())window.clearTimeout(o);ls.current.clear()},[]);const Ns=l.useCallback(async o=>{var x;const f=o||Fe.current||Ft.current;if(!f||!((x=window.agentApi)!=null&&x.getSessionGoals)){Ge({active:null,queued:[],history:[]});return}try{const w=await window.agentApi.getSessionGoals(f);_t(w,f),w.active&&(it.current=f,N(f))}catch(w){we(w instanceof Error?w.message:"目标状态加载失败")}},[_t,N]);l.useEffect(()=>{Ns(Z)},[Z,Ns]);const Mt=l.useCallback(o=>{const f=Fe.current||Ft.current;o==="thinking"&&(ln.current!=="thinking"||Cr.current!==f)?(Cr.current=f,Sn(Date.now())):o!=="thinking"&&(Cr.current=null),ln.current=o,Jt(o)},[]),ic=l.useCallback(o=>{Cr.current=o,ln.current="thinking",Sn(Date.now()),Jt("thinking")},[]);l.useEffect(()=>{mt(!1),un("idle"),Tn(null)},[r]),l.useEffect(()=>{window.agentApi&&(window.agentApi.listAgentDefs().then(o=>ho(o)),window.agentApi.listSkills().then(o=>go(o.filter(f=>f.name))).catch(o=>console.error("[listSkills] mount error:",o)))},[]);const yo=is===null?[]:Zl.filter(o=>is===""||o.name.toLowerCase().includes(is.toLowerCase())),ci=gr===null?[]:[...[{name:"goal",description:"目标模式:持续推进当前目标,后续目标自动排队"},{name:"compact",description:"主动压缩当前会话上下文,并在下轮重新注入环境"},{name:"loop",description:"定时任务:/loop 5m 任务 | list | pause/resume/delete <id> | stop"}].filter(o=>gr===""||o.name.toLowerCase().includes(gr.toLowerCase())),...Jl.filter(o=>gr===""||o.name.toLowerCase().includes(gr.toLowerCase()))],oc=o=>{oi(f=>f.find(x=>x.id===o.id)?f:[...f,o]),bt(f=>f.replace(/@[\w\u4e00-\u9fff]*$/,"")),hr(null),setTimeout(()=>{var f;return(f=rs.current)==null?void 0:f.focus()},0)},ac=o=>{oi(f=>f.filter(x=>x.id!==o))},lc=o=>{bt(f=>f.replace(/\/[\w\u4e00-\u9fff\-_]*$/,`/${o.name} `)),xr(null),setTimeout(()=>{var f;return(f=rs.current)==null?void 0:f.focus()},0)},vo=o=>{var w,B;bt(o);const f=o.match(/@([\w\u4e00-\u9fff]*)$/);if(f){window.agentApi&&window.agentApi.listAgentDefs().then(M=>ho(M)),fo(((w=ii.current)==null?void 0:w.getBoundingClientRect())??null),hr(f[1]),xr(null);return}const x=o.match(/\/([-\w\u4e00-\u9fff]*)$/);if(x){window.agentApi&&window.agentApi.listSkills().then(M=>go(M.filter(te=>te.name))).catch(M=>console.error("[listSkills] slash error:",M)),fo(((B=ii.current)==null?void 0:B.getBoundingClientRect())??null),xr(x[1]),hr(null);return}hr(null),xr(null)},cc=o=>{vo(o),hr(null),xr(null),requestAnimationFrame(()=>{var f;return(f=rs.current)==null?void 0:f.focus()})},dc=o=>{o.key==="Escape"&&(is!==null||gr!==null)?(o.preventDefault(),hr(null),xr(null)):o.key==="Escape"&&On?(o.preventDefault(),Ao()):o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),No())},uc=async o=>{const f=Array.from(o.target.files??[]);if(o.target.value="",f.length===0)return;const x=f.filter(w=>w.type.toLowerCase().startsWith("image/")).length;x>0&&zr(w=>w+1);try{const w=await Wp(f,async M=>wo(await xa(M)));w.attachments.length>0&&Tr(M=>[...M,...w.attachments]),w.images.length>0&&(En(M=>[...M,...w.images]),ye||hc());const B=[...w.unsupportedImages,...w.failedImages];B.length>0&&we(`无法添加图片:${B.map(M=>M.name).join("、")}。仅支持 JPG、PNG、GIF 和 WebP。`)}finally{x>0&&zr(w=>Math.max(0,w-1))}},pc=o=>{Tr(f=>f.filter((x,w)=>w!==o))},fc=/claude-3|gpt-4-vision|gpt-4o|gpt-4-turbo|gemini|deepseek-vl/i,di=o=>fc.test(o),hc=()=>{const o=ae.find(x=>x.id===Re);if(o&&di(o.modelId))return;const f=ae.find(x=>di(x.modelId));f&&ht(f.id)},gc=o=>{En(f=>[...f,o])},xc=o=>{En(f=>f.filter((x,w)=>w!==o))},wo=o=>new Promise((f,x)=>{const w=new FileReader;w.onload=()=>f(w.result),w.onerror=x,w.readAsDataURL(o)});l.useEffect(()=>{const o=async f=>{if(!f.clipboardData)return;const x=Array.from(f.clipboardData.items).find(B=>B.type.startsWith("image/"));if(!x)return;f.preventDefault();const w=x.getAsFile();if(w){zr(B=>B+1);try{gc(await wo(await xa(w)))}catch{we("无法添加图片。仅支持 JPG、PNG、GIF 和 WebP。")}finally{zr(B=>Math.max(0,B-1))}}};return window.addEventListener("paste",o),()=>window.removeEventListener("paste",o)},[ae,Re]),l.useEffect(()=>{var f;const o=_n.current;_n.current=null,o!=="skip"&&((f=Ss.current)==null||f.scrollIntoView({behavior:o==="instant"?"auto":"smooth"}))},[R]),l.useEffect(()=>window.agentApi?window.agentApi.onEvent(f=>mc(f)):void 0,[ke]),l.useEffect(()=>{const o=++Br.current,f=r,x=()=>Br.current===o&&Fe.current===f;return(async()=>{var te,U,se;const B=window.agentApi;if(!B||vp(it.current,Ft.current,f))return;if(!f){if(!x())return;(te=tn.current)==null||te.invalidate(),_e(),we(null),pr(null),zt(null),jn(null),Qt.current=null,zn.current=null,q.current=null,ge.current+=1,Y.current=null,ri(null),mr("latest"),_r(null),Pr(null),yt.current=!1,Rs(!1),Wr(!1),Cs(null),Ms(!1),Es(!1),p.current=null,Ft.current=null,G(""),qn("full-access");return}we(null),pr(null),zt(null),jn(null),Cs(null),(U=tn.current)==null||U.invalidate(),de.current+=1,Qt.current=null,zn.current=null,q.current=null,mr("latest"),Wr(!1),_r(null),Pr(null),yt.current=!1,Rs(!1),((se=Y.current)==null?void 0:se.sessionId)!==f&&(ge.current+=1,Y.current=null,ri(null)),Ms(!0),Es(!0),p.current=f,Ft.current=f,G(f);const M=je(f);J(M,f);try{await yu(async()=>{if(!x())throw new DOMException("Session selection changed","AbortError");return await Or(B,f,We(f),{limit:We(f)==="codex"?Ci:Dn},(H,ee)=>{var ds,he,ot,er;if(!x())return;const le=H,fe=ra((H==null?void 0:H.events)??[]),ve=ta((H==null?void 0:H.events)??[]),De=sa((H==null?void 0:H.events)??[]),Ee=Fr(H);At(f,(ds=H==null?void 0:H.history)==null?void 0:ds.revision),g!=null&&g.compatibility&&zt(f),qn(La((le==null?void 0:le.permissionMode)??((he=le==null?void 0:le.metadata)==null?void 0:he.permissionMode)));const qe=((ot=H==null?void 0:H.history)==null?void 0:ot.nextCursor)??null;Qt.current=qe,zn.current=qe,q.current=null;const Te=je(f),tt=ua(Te,Ee,ee,H==null?void 0:H.history),rn=H!=null&&H.goalState?wi(tt,H.goalState):tt;_n.current="instant",J(rn,f),yn(f,qe),Ze(ve,f),Ie(De,f),jl(H)||Pu(H)?(it.current=f,N(f)):it.current===f&&(it.current=null,N(null)),fe&&nt(fe,f);const Jn=rn[rn.length-1];(Jn==null?void 0:Jn.role)==="assistant"&&((er=Jn.toolCalls)!=null&&er.length)?Mt(ji(Jn.toolCalls)?"thinking":"tools"):Mt((H==null?void 0:H.agentType)!=="customer-agent"&&(H==null?void 0:H.status)==="running"?"thinking":"idle"),Ms(!1),Es(!1)},x),!0})}catch(H){if(!x())return;console.error("[chat] failed to restore session",{sessionId:f,error:H});const ee=bu(H);pr(ee),g!=null&&g.compatibility&&jn(ee)}finally{x()&&(Ms(!1),Es(!1))}})(),()=>{Br.current===o&&(Br.current+=1)}},[_e,je,We,yn,r,bn,nt,mr,J,G,At,Mt]);const Zn=l.useCallback(async o=>{const f=window.agentApi;if(!(f!=null&&f.getSessionQueryIndex))return null;const x=++ge.current;try{const w=await f.getSessionQueryIndex(o);return ge.current!==x||Fe.current!==o||w.sessionId!==o?null:(Y.current=w,ri(w),w)}catch(w){return ge.current===x&&console.warn("[chat] failed to load query index",{sessionId:o,error:w}),null}},[]),jo=l.useCallback(o=>{if(ft.current!==o&&(pt.current!==null&&window.clearTimeout(pt.current),ft.current=o,pt.current=null,nn.current=0),pt.current!==null)return;const f=Math.max(0,Gp-(Date.now()-nn.current));pt.current=window.setTimeout(()=>{pt.current=null,nn.current=Date.now(),Fe.current===o&&W(x=>x+1)},f)},[]);l.useEffect(()=>{var M;const o=r;if(!o||As||!((M=window.agentApi)!=null&&M.getSessionQueryIndex))return;let f=!1;const x=()=>{!f&&Fe.current===o&&Zn(o)},w=window,B=w.requestIdleCallback?w.requestIdleCallback(x,{timeout:1e3}):window.setTimeout(x,0);return()=>{f=!0,w.cancelIdleCallback&&w.requestIdleCallback?w.cancelIdleCallback(B):window.clearTimeout(B)}},[As,Zn,r,bn]);const ko=l.useCallback(async o=>{if(!(!window.agentApi||document.visibilityState==="hidden")){if(L.current==="anchored"){Wr(!0);return}if(vt.current!==o&&(vt.current=o,me.current=!1,Oe.current=!1),me.current){Oe.current=!0;return}me.current=!0;try{do Oe.current=!1,await Or(window.agentApi,o,We(o),{limit:We(o)==="codex"?Ci:Dn},(f,x)=>{var ve,De,Ee,qe,Te,tt;const w=Fr(f),B=je(o),M=ua(B,w,x,f==null?void 0:f.history),te=f!=null&&f.goalState?wi(M,f.goalState):M,U=Gt.current,se=!U||U.scrollHeight-U.scrollTop-U.clientHeight<80;_n.current=se?null:"skip",J(te,o),At(o,(ve=f==null?void 0:f.history)==null?void 0:ve.revision),f!=null&&f.goalState&&Ge(ya(f.goalState));const H=zn.current,ee=((De=f==null?void 0:f.history)==null?void 0:De.nextCursor)??null;if(Qt.current===H){const rn=Qt.current!==ee;Qt.current=ee,rn&&((Ee=tn.current)==null||Ee.invalidate(),yn(o,ee))}zn.current=ee,(qe=f==null?void 0:f.history)!=null&&qe.revision&&f.history.revision!==((Te=Y.current)==null?void 0:Te.revision)&&Zn(o);const le=ra((f==null?void 0:f.events)??[]);Ze(ta((f==null?void 0:f.events)??[]),o),Ie(sa((f==null?void 0:f.events)??[]),o),le&&nt(le,o);const fe=te[te.length-1];(fe==null?void 0:fe.role)==="assistant"&&((tt=fe.toolCalls)!=null&&tt.length)?Mt(ji(fe.toolCalls)?"thinking":"tools"):Mt(eo(f)?"thinking":"idle")},()=>Fe.current===o&&p.current===o),We(o)==="codex"&&jo(o);while(Oe.current)}catch(f){console.error("[chat] failed to refresh native session history",{sessionId:o,error:f})}finally{vt.current===o&&(me.current=!1)}}},[je,We,Zn,yn,jo,nt,J,At,Mt]);l.useEffect(()=>{const o=r,f=Du(g,o)||(g==null?void 0:g.agentType)==="customer-agent"&&o!==T,x=(g==null?void 0:g.agentType)==="customer-agent"||(g==null?void 0:g.occupancy)==="owned-externally"||(g==null?void 0:g.status)==="running";if(!o||!f||!window.agentApi)return;let w=null,B=null,M=!1;const te=()=>{!M&&document.visibilityState!=="hidden"&&ko(o)},U=()=>{w==null||w(),w=null,B!==null&&window.clearInterval(B),B=null},se=()=>{M||B!==null||document.visibilityState==="hidden"||(te(),B=window.setInterval(te,2e3))},H=()=>{if(!(M||document.visibilityState==="hidden")){if(typeof window.agentApi.observeSession!="function"){x&&se();return}try{w=window.agentApi.observeSession(o,te,()=>{w=null,x&&se()})}catch{x&&se()}}},ee=()=>{U(),document.visibilityState!=="hidden"&&(te(),H())};return H(),document.addEventListener("visibilitychange",ee),()=>{M=!0,document.removeEventListener("visibilitychange",ee),U(),vt.current===o&&(vt.current=null,Oe.current=!1),ft.current===o&&(pt.current!==null&&window.clearTimeout(pt.current),ft.current=null,pt.current=null,nn.current=0)}},[ko,r,T,g==null?void 0:g.agentType,g==null?void 0:g.occupancy,g==null?void 0:g.status]);const ui=l.useCallback(async()=>{const o=p.current,f=Qt.current,x=window.agentApi;if(!x||!o||!f||wt.current)return;wt.current=!0,Cs(null);const w=window.setTimeout(()=>{p.current===o&&wt.current&&lo(!0)},500);try{const B=je(o);await Or(x,o,We(o),{before:f,limit:We(o)==="codex"?xs:Dn},(M,te)=>{var ee,le;const U=Fr(M),se=Gt.current;te!=="trace"&&se&&U.length>0&&(ts.current={scrollHeight:se.scrollHeight,scrollTop:se.scrollTop},_n.current="skip");const H=((ee=M==null?void 0:M.history)==null?void 0:ee.nextCursor)??null;Qt.current=H,At(o,(le=M==null?void 0:M.history)==null?void 0:le.revision),U.length>0&&J([...U,...B],o),te!=="trace"&&yn(o,H)},()=>p.current===o&&Fe.current===o,()=>tn.current.consume(o,f,()=>x.getSession(o,{before:f,limit:We(o)==="codex"?xs:Dn,...We(o)==="codex"?{view:"core"}:{}})))}catch(B){if(p.current!==o)return;console.error("[chat] failed to load older history",{sessionId:o,error:B}),Cs(B instanceof Error?B.message:"历史消息加载失败")}finally{window.clearTimeout(w),wt.current=!1,p.current===o&&lo(!1)}},[je,We,yn,J,At]);l.useEffect(()=>{Lr.current=()=>{ui()}},[ui]);const So=l.useCallback(async()=>{const o=p.current,f=q.current;if(!(!window.agentApi||!o||!f||L.current!=="anchored"||Q.current)){Q.current=!0,co(!0);try{const x=je(o),w=new Set(x.map(B=>B.id));await Or(window.agentApi,o,We(o),{after:f,limit:We(o)==="codex"?xs:Dn},B=>{var te,U;const M=Fr(B).filter(se=>!w.has(se.id));q.current=((te=B==null?void 0:B.history)==null?void 0:te.newerCursor)??null,At(o,(U=B==null?void 0:B.history)==null?void 0:U.revision),M.length>0&&(_n.current="skip",J([...x,...M],o))},()=>Fe.current===o&&p.current===o&&L.current==="anchored")}catch(x){console.error("[chat] failed to load newer anchored history",{sessionId:o,error:x})}finally{Q.current=!1,co(!1)}}},[je,We,J,At]);l.useEffect(()=>{es.current=()=>{So()}},[So]);const Io=l.useCallback(async()=>{const o=Fe.current;if(!window.agentApi||!o||yt.current)return!1;const f=++de.current;yt.current=!0,Rs(!0),Pr(null);try{let x=!1;return await Or(window.agentApi,o,We(o),{limit:We(o)==="codex"?Ci:Dn},(w,B)=>{var U,se,H,ee,le,fe,ve;x=!0;const M=Fr(w),te=((U=w==null?void 0:w.history)==null?void 0:U.nextCursor)??null;B!=="trace"&&((se=tn.current)==null||se.invalidate()),Qt.current=te,zn.current=te,q.current=null,At(o,(H=w==null?void 0:w.history)==null?void 0:H.revision),mr("latest"),Wr(!1),_r(((le=(ee=Y.current)==null?void 0:ee.entries.at(-1))==null?void 0:le.messageId)??null),Ue.current=!0,_n.current="skip",J(M,o),B!=="trace"&&yn(o,te),((fe=w==null?void 0:w.history)==null?void 0:fe.revision)!==((ve=Y.current)==null?void 0:ve.revision)&&Zn(o)},()=>de.current===f&&Fe.current===o),x}catch(x){return we(x instanceof Error?x.message:"返回最新消息失败"),!1}finally{yt.current=!1,Rs(!1)}},[We,Zn,yn,mr,J,At]),Co=l.useCallback(async(o,f=!0)=>{var te;const x=Fe.current,w=Gt.current;if(!window.agentApi||!x||!w)return;const B=++de.current;_r(o.messageId);const M=Array.from(w.querySelectorAll("[data-message-id]")).find(U=>U.dataset.messageId===o.messageId);if(M){Pr(null),Mi(w,M,"smooth");return}Pr(o.messageId),(te=tn.current)==null||te.invalidate();try{await Or(window.agentApi,x,We(x),{anchor:o.pageToken,limit:We(x)==="codex"?xs:Dn},(U,se)=>{var le,fe,ve,De,Ee,qe;if(((le=Y.current)==null?void 0:le.revision)!==((fe=U==null?void 0:U.history)==null?void 0:fe.revision))return;const H=Fr(U),ee=((ve=U==null?void 0:U.history)==null?void 0:ve.olderCursor)??((De=U==null?void 0:U.history)==null?void 0:De.nextCursor)??null;Qt.current=ee,q.current=((Ee=U==null?void 0:U.history)==null?void 0:Ee.newerCursor)??null,At(x,(qe=U==null?void 0:U.history)==null?void 0:qe.revision),mr("anchored"),Wr(!1),ue.current=o.messageId,_n.current="skip",J(H,x),se!=="trace"&&(window.requestAnimationFrame(()=>{if(de.current!==B||Fe.current!==x)return;const Te=Gt.current,tt=Array.from((Te==null?void 0:Te.querySelectorAll("[data-message-id]"))??[]).find(rn=>rn.dataset.messageId===o.messageId);!Te||!tt||(Mi(Te,tt),ue.current=null,_r(o.messageId))}),yn(x,ee))},()=>de.current===B&&Fe.current===x)}catch(U){if(U.code==="STALE_SESSION_ANCHOR"&&f){const H=await Zn(x),ee=H==null?void 0:H.entries.find(le=>le.ordinal===o.ordinal);ee&&await Co(ee,!1);return}console.error("[chat] failed to open indexed query",{sessionId:x,error:U}),we(U instanceof Error?U.message:"无法打开这条消息")}finally{de.current===B&&Pr(null)}},[We,Zn,yn,mr,J,At]),Ro=o=>{if(Dr.current.has(o)||ls.current.has(o))return;const f=window.setTimeout(()=>{ls.current.delete(o),(async()=>{var x;if(!Dr.current.has(o))try{const w=await((x=window.agentApi)==null?void 0:x.getSessionGoals(o)),B=Fe.current||Ft.current;if(w&&o===B&&_t(w,o),w!=null&&w.active){it.current=o,o===B&&(br.current=!1,we(null),N(o));return}if(br.current)return;const M=Le.getState().getMessagesForSession(o).find(te=>te.isQueued&&!te.queueItemId);if(!M){o===B&&(it.current=null,N(null));return}ce(M.id,te=>({...te,isQueued:!1}),o),$r(M,o)}catch(w){we(w instanceof Error?w.message:"排队消息自动发送失败")}})()},150);ls.current.set(o,f)},mc=o=>{var B,M,te;const f=Fe.current||Ft.current,x=o._sid||f||void 0;if(o._nativeRunId&&Number.isSafeInteger(o._nativeSequence)){const U=`${o._nativeRunId}:${o._nativeSequence}`;if(Gn.current.has(U))return;Gn.current.add(U),Gn.current.size>2e3&&(Gn.current=new Set([...Gn.current].slice(-1e3)))}const w=!x||x===f;if(w&&L.current==="anchored"){Wr(!0);return}switch(o.type){case"run_admitted":if(x){cs.current.delete(x);const U=_s(xt.current,x);U&&(Xn.current===U.token&&(Xn.current=null),Bt(void 0,x)),Mu(x)}break;case"context_usage":o.usage&&nt(o.usage,x);break;case"text_chunk":o.text&&(x&&o.turnId&&o.messagePhase==="commentary"&&We(x)==="codex"?Ce(o.turnId,{type:"text_chunk",text:o.text,turnId:o.turnId,itemId:o.itemId,messagePhase:"commentary"},x):P(o.text,x),w&&Mt("thinking"));break;case"reasoning_summary_delta":if(typeof o.itemId=="string"&&Number.isSafeInteger(o.sectionIndex)&&typeof o.delta=="string"){const U={type:"reasoning_summary_delta",itemId:o.itemId,sectionIndex:o.sectionIndex,delta:o.delta,...o.turnId?{turnId:o.turnId}:{}};x&&o.turnId&&We(x)==="codex"?Ce(o.turnId,U,x):be(U,x),w&&Mt("thinking")}break;case"runtime_progress":if(typeof o.progressId=="string"&&typeof o.label=="string"&&["thinking","tool","retry","status"].includes(o.phase??"")){const U={progressId:o.progressId,phase:o.phase,label:o.label,...o.detail===void 0?{}:{detail:o.detail},...o.toolCallId===void 0?{}:{toolCallId:o.toolCallId},...o.elapsedSeconds===void 0?{}:{elapsedSeconds:o.elapsedSeconds},...o.current===void 0?{}:{current:o.current},...o.total===void 0?{}:{total:o.total}};Ht(U,x),w&&Mt(U.phase==="tool"?"tools":"thinking")}break;case"native_subagent_update":(B=o.activity)!=null&&B.parentToolCallId&&(ne(o.activity,x),w&&o.activity.status==="running"&&Mt("tools"));break;case"tool_call":w&&Mt("tools"),o.toolCall&&o.toolCall.name!=="dispatch_agent"&&o.toolCall.name!=="ask_user"&&o.toolCall.name!=="show_widget"&&(x&&o.turnId&&We(x)==="codex"?Ce(o.turnId,{type:"tool_call",toolCall:o.toolCall,turnId:o.turnId},x):I({id:crypto.randomUUID(),role:"assistant",content:"",toolCalls:[{id:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments}],timestamp:Date.now()},x));break;case"tool_result":o.result&&(x&&o.turnId&&We(x)==="codex"?Ce(o.turnId,{type:"tool_result",result:o.result,turnId:o.turnId},x):ie(o.result.toolCallId,o.result.content,o.result.isError,x));break;case"todo_update":o.todos&&jt(o.todos);break;case"cron_update":o.tasks&&Be(o.tasks);break;case"agent_dispatch":if(I({id:crypto.randomUUID(),role:"assistant",content:"",toolCalls:[{id:crypto.randomUUID(),name:"dispatch_agent",arguments:{agentName:o.agentName,task:o.task??"",subSessionId:o.subSessionId}}],timestamp:Date.now()},x),o.subSessionId){Ct.current.add(o.subSessionId);const U=it.current||ke;U&&a&&a(U)}d==null||d({type:"started",agentName:o.agentName??"",task:o.task??"",subSessionId:o.subSessionId});break;case"agent_done":o.subSessionId&&(Ct.current.delete(o.subSessionId),Ae(o.subSessionId,o.status??"completed",o.status==="failed"?o.error:o.summary,x)),d==null||d({type:o.status==="failed"?"failed":"completed",agentName:o.agentName??"",task:o.task??"",subSessionId:o.subSessionId});break;case"agent_progress":o.subSessionId&&o.text&&ze(o.subSessionId,o.text,x);break;case"compacted":I({id:crypto.randomUUID(),role:"assistant",content:o.summary??"",isCompactionSummary:!0,timestamp:Date.now()},x);break;case"show_widget":{const U=o.data??o.widgetData,se={widgetId:o.widgetId,widgetType:o.widgetType,data:U??{}},ee=(x?Le.getState().getMessagesForSession(x):Le.getState().messages).find(le=>{var fe;return((fe=le.widget)==null?void 0:fe.widgetId)===se.widgetId});ee?ce(ee.id,le=>({...le,widget:se}),x):I({id:crypto.randomUUID(),role:"assistant",content:"",widget:se,timestamp:Date.now()},x);break}case"ask_user":if(o.questionId&&(x?Le.getState().getMessagesForSession(x):Le.getState().messages).some(se=>{var H;return((H=se.askUser)==null?void 0:H.questionId)===o.questionId}))break;I({id:crypto.randomUUID(),role:"assistant",content:"",askUser:{questionId:o.questionId??"",question:o.question??"",options:o.options,fields:o.fields,multiSelect:o.multiSelect},timestamp:Date.now()},x);break;case"approval_resolved":{if(!o.questionId)break;const se=(x?Le.getState().getMessagesForSession(x):Le.getState().messages).find(H=>{var ee;return((ee=H.askUser)==null?void 0:ee.questionId)===o.questionId});se&&ce(se.id,H=>({...H,askUser:H.askUser?{...H.askUser,answered:!0,answer:"已处理"}:H.askUser}),x);break}case"text_done":break;case"thinking":w&&Mt("thinking");break;case"done":if(x){const U=Wl(o.durationMs);if(U!==void 0){const se=[...je(x)].reverse().find(H=>{var ee;return H.role==="assistant"&&!!H.content.trim()&&!((ee=H.toolCalls)!=null&&ee.length)&&!H.isCompactionSummary});se&&ce(se.id,H=>({...H,presentation:{...H.presentation,completionDurationMs:U}}),x)}}if(_(x),w&&!Le.getState().messages.some(U=>U.isQueued)&&N(null),w&&(Mt("idle"),Et.getState().autoSpeak)){const se=[...Le.getState().messages].reverse().find(H=>H.role==="assistant"&&H.content&&!H.isCompactionSummary);se!=null&&se.content&&(M=window.agentApi)!=null&&M.ttsSpeak&&(fs(),window.agentApi.ttsSpeak(se.content.slice(0,600)).then(H=>{H.ok||we("TTS 模型播报失败")}).catch(H=>{we(H instanceof Error?H.message:"TTS 模型播报失败")}))}x&&(Dr.current.has(x)?window.setTimeout(()=>{Ns(x)},150):Ro(x));break;case"error":if(o._preserveActiveRun||_(x),x&&o.code==="SESSION_OCCUPIED"){const U=Le.getState().getMessagesForSession(x),se=cs.current.get(x),H=_s(xt.current,x),ee=se??(H==null?void 0:H.payload),le=ee?[...U].reverse().find(ve=>ve.role==="user"&&!ve.isQueued&&ve.content===ee.content):w?[...U].reverse().find(ve=>ve.role==="user"&&!ve.isQueued):void 0,fe=ee??(le?{content:le.content,images:le.images,agentName:le.agentName}:void 0);le&&J(U.filter(ve=>ve.id!==le.id),x),cs.current.delete(x),fe!=null&&fe.content&&(Bt(H??$p(x,fe)),vi(x,fe.content),w&&(bt(fe.content),En(fe.images??[]))),w&&we(null)}if(w){if(o._preserveActiveRun&&x&&(bo.current.add(x),it.current=x,N(x),Mt("thinking")),o.code==="SESSION_ALREADY_RUNNING"){const U=x?Le.getState().getMessagesForSession(x):Le.getState().messages,se=Tu(U);if(se){const H=U.find(ee=>ee.id===se);ce(se,ee=>({...ee,isQueued:!0}),x),z&&x&&H&&((te=window.agentApi)!=null&&te.enqueueSessionMessage)&&window.agentApi.enqueueSessionMessage(x,{sourceMessageId:H.id,content:H.content,images:H.images,agentName:H.agentName}).then(ee=>_t(ee,x)).catch(ee=>{we(ee instanceof Error?ee.message:"排队消息保存失败")})}x&&cs.current.delete(x),x&&Bt(void 0,x),we(null)}else if(o.code!=="SESSION_OCCUPIED"){we(o.message??"Unknown error");const se=[...x?Le.getState().getMessagesForSession(x):Le.getState().messages].reverse().find(H=>H.role==="user"&&!H.isQueued);ye&&(se!=null&&se.content)&&(bt(se.content),x&&vi(x,se.content))}}if(!o._preserveActiveRun){const U=x??f;(!U||it.current===U)&&(it.current=null),(!U||Le.getState().runningSessionId===U)&&N(null),w&&Mt("idle")}x&&!o._preserveActiveRun&&(Dr.current.has(x)?window.setTimeout(()=>{Ns(x)},150):Ro(x));break;case"turn_aborted":_(x),w&&(N(null),Mt("idle"));break}},bc=async o=>{var x;if(!Z||!((x=window.agentApi)!=null&&x.setSessionPermissionMode)||$e)return;const f=mn;qn(o),Un(!1),Vn(!0);try{await window.agentApi.setSessionPermissionMode(Z,o)}catch(w){qn(f),we(w instanceof Error?w.message:"权限模式更新失败")}finally{Vn(!1)}},yc=async()=>{var o;if(!(!Z||(g==null?void 0:g.agentType)!=="codex"||!((o=window.agentApi)!=null&&o.releaseCodexSession)||wn!=="idle")&&!(gn&&!window.confirm("停止当前执行并退出此会话?Codex Desktop 最长约 30 分钟后可用。"))){un("releasing");try{await window.agentApi.releaseCodexSession(Z),br.current=!0,Br.current+=1,it.current=null,N(null),Ct.current.clear(),Ge(f=>({...f,active:null,queued:[]})),Jt("idle"),we(null),un("released")}catch(f){un("idle"),we(f instanceof Error?f.message:"释放 Codex 会话失败")}}},vc=async()=>{var x;const o=at;if(!o||!Z||Xt||Xn.current===o.token)return;Xn.current=o.token;const f=(w,B)=>{const M=Op(w);je(B).some(U=>U.id===M)||I({id:M,role:"user",content:w.payload.content,timestamp:Date.now(),agentName:w.payload.agentName,images:w.payload.images},B)};if(o.forkSessionId){mt(!0);const w=Aa(o,o.forkSessionId);Bt(w),f(w,w.forkSessionId),$r(w.payload,w.forkSessionId,w.payload.agentIds).finally(()=>{Xn.current=null,mt(!1)});return}if(!((x=window.agentApi)!=null&&x.forkSession)){Xn.current=null;return}mt(!0);try{const w=await Hp({sourceSessionId:o.sourceSessionId,forkSession:M=>window.agentApi.forkSession(M),activateSession:M=>{Ft.current=M,G(M)},refreshAndSelect:async M=>{s?await s(M.id,M):c==null||c(M.id)}}),B=Aa(o,w.id);Bt(B),f(B,w.id),$r(B.payload,w.id,B.payload.agentIds).finally(()=>{Xn.current=null,mt(!1)}),we(null)}catch(w){Xn.current=null,we(w instanceof Error?w.message:"创建会话副本失败"),mt(!1)}},Ao=()=>{br.current=!0,Br.current+=1,window.agentApi&&window.agentApi.abort(Z||void 0),it.current=null,N(null),Ct.current.clear()},Mo=async o=>{const f=r||ke;if(!f||!window.agentApi)return;const x=Le.getState().messages.find(w=>w.id===o);if(!(!x||!x.isQueued))try{x.queueItemId?_t(await window.agentApi.steerSessionMessage(f,x.queueItemId),f):(await window.agentApi.steer(x.content,f,x.agentName),ce(o,w=>({...w,isQueued:!1,isSteered:!0}))),Rn===o&&(cr(null),qt(""))}catch(w){we(w instanceof Error?w.message:"引导失败")}},wc=o=>{const f=Le.getState().messages.find(x=>x.id===o&&x.isQueued);f&&(cr(o),qt(f.content))},pi=()=>{cr(null),qt("")},Eo=async o=>{const f=Yr.trim(),x=Le.getState().messages.find(w=>w.id===o&&w.isQueued);if(!(!x||!f))try{x.queueItemId&&Z?_t(await window.agentApi.updateSessionMessage(Z,x.queueItemId,f),Z):ce(o,w=>w.isQueued?{...w,content:f}:w,Z||void 0),pi()}catch(w){we(w instanceof Error?w.message:"排队消息保存失败")}},jc=async o=>{const f=Le.getState().messages.find(x=>x.id===o&&x.isQueued);if(f){if(!await yi(f.content)){we("复制排队消息失败");return}Vt(o),window.setTimeout(()=>Vt(x=>x===o?null:x),1200)}},kc=async o=>{const f=Le.getState().messages,x=f.find(w=>w.id===o&&w.isQueued);if(x)try{x.queueItemId&&Z?_t(await window.agentApi.cancelSessionMessage(Z,x.queueItemId),Z):J(f.filter(w=>w.id!==o),Z||void 0),Rn===o&&pi()}catch(w){we(w instanceof Error?w.message:"排队消息删除失败")}},fi=async(o,f)=>{const x=Le.getState().messages,w=zu(x,o,f);if(w!==x){J(w,Z||void 0);const B=w.filter(M=>M.isQueued&&M.queueItemId);if(Z&&B.length>0)try{_t(await window.agentApi.reorderSessionMessages(Z,B.map(M=>M.queueItemId)),Z)}catch(M){J(x,Z),we(M instanceof Error?M.message:"排队消息排序保存失败")}}},Sc=(o,f)=>{const x=Le.getState().messages.filter(M=>M.isQueued),w=x.findIndex(M=>M.id===o),B=x[w+f];B&&fi(o,B.id)},Ic=async o=>{const f=js;if(Mr(null),!Z||!f||f===o)return;const x=Me.queued.map(U=>U.id),w=x.indexOf(f),B=x.indexOf(o);if(w<0||B<0)return;const M=[...x];M.splice(B,0,M.splice(w,1)[0]);const te=Me;Ge({...Me,queued:M.map((U,se)=>({...Me.queued.find(H=>H.id===U),position:se}))});try{_t(await window.agentApi.reorderSessionGoals(Z,M),Z)}catch(U){Ge(te),we(U instanceof Error?U.message:"目标排序保存失败")}},To=async o=>{if(!Z)return;const f=Me.queued.find(x=>x.id===o);try{const x=await window.agentApi.cancelSessionGoal(Z,o);if(_t(x,Z),f!=null&&f.sourceMessageId){const w=Le.getState().getMessagesForSession(Z);J(w.filter(B=>B.id!==f.sourceMessageId),Z)}x.active||N(null)}catch(x){we(x instanceof Error?x.message:"目标删除失败")}};l.useEffect(()=>{Rn&&(R.some(o=>o.id===Rn&&o.isQueued)||(cr(null),qt("")))},[Rn,R]);async function $r(o,f,x){var w,B;f.startsWith("runtime:")&&cs.current.set(f,{content:o.content,images:o.images?[...o.images]:void 0,agentIds:x?[...x]:void 0,agentName:o.agentName}),br.current=!1,Dr.current.add(f),ic(f),it.current=f,N(f);try{if(window.agentApi){const M=ye&&Os(Se)?{...(w=$t.model)!=null&&w.id?{model:$t.model}:{},...It?{reasoningEffort:It}:{}}:void 0;await window.agentApi.run(o.content,f,x,o.agentName,o.images,M)}}catch(M){we(M instanceof Error?M.message:"Agent run failed")}finally{if(Dr.current.delete(f),bo.current.delete(f)){it.current=f,N(f);return}const te=(B=window.agentApi)!=null&&B.getSessionGoals?await window.agentApi.getSessionGoals(f).catch(()=>{}):void 0;if(te&&f===(Fe.current||Ft.current)&&_t(te,f),te!=null&&te.active){it.current=f,N(f),u&&u(n,f);return}const U=br.current?void 0:Le.getState().getMessagesForSession(f).find(se=>se.isQueued&&!se.queueItemId);U?(ce(U.id,se=>({...se,isQueued:!1}),f),u&&u(n,f),$r(U,f)):(it.current=null,N(null),u&&u(n,f))}}const No=async()=>{var se,H;if(!Ut.trim()||!et||Jr>0||L.current==="anchored"&&!await Io())return;zs(window.agentApi,fs),we(null);const o=Ut.trim();if(/^\/loop\b/i.test(o)){const ee=o.slice(5).trim();if(bt(""),I({id:crypto.randomUUID(),role:"user",content:o,timestamp:Date.now()}),/^stop$/i.test(ee)){window.agentApi&&(await window.agentApi.cronDeleteAll(),Be([]),I({id:crypto.randomUUID(),role:"assistant",content:"✅ 所有定时任务已删除。",timestamp:Date.now()}));return}if(/^(?:list|status|查看|列表)$/i.test(ee)||ee===""){if(window.agentApi){const Ee=await window.agentApi.cronList();Be(Ee);const qe=Ee.length===0?"当前没有定时任务。":Ee.map((Te,tt)=>`**${tt+1}.** \`${Te.id.slice(0,6)}\` · ${Ri(Te.cron)} · ${Te.enabled?"▶ 启用":"⏸ 已暂停"}
|
|
365
|
+
${Te.prompt}`).join(`
|
|
366
|
+
|
|
367
|
+
`);I({id:crypto.randomUUID(),role:"assistant",content:qe,timestamp:Date.now()})}return}const le=ee.match(/^(?:pause|暂停)\s+(\S+)$/i);if(le){if(window.agentApi){const Ee=Tt.find(Te=>Te.id.startsWith(le[1])),qe=await window.agentApi.cronPause((Ee==null?void 0:Ee.id)??le[1]);if(qe){const Te=await window.agentApi.cronList();Be(Te),I({id:crypto.randomUUID(),role:"assistant",content:`⏸ 定时任务 \`${qe.id.slice(0,6)}\` 已暂停。`,timestamp:Date.now()})}else I({id:crypto.randomUUID(),role:"assistant",content:`未找到 ID 以 \`${le[1]}\` 开头的定时任务。`,timestamp:Date.now()})}return}const fe=ee.match(/^(?:resume|恢复)\s+(\S+)$/i);if(fe){if(window.agentApi){const Ee=Tt.find(Te=>Te.id.startsWith(fe[1])),qe=await window.agentApi.cronResume((Ee==null?void 0:Ee.id)??fe[1]);if(qe){const Te=await window.agentApi.cronList();Be(Te),I({id:crypto.randomUUID(),role:"assistant",content:`▶ 定时任务 \`${qe.id.slice(0,6)}\` 已恢复。`,timestamp:Date.now()})}else I({id:crypto.randomUUID(),role:"assistant",content:`未找到 ID 以 \`${fe[1]}\` 开头的定时任务。`,timestamp:Date.now()})}return}const ve=ee.match(/^(?:delete|del|删除|stop)\s+(\S+)$/i);if(ve){if(window.agentApi){const Ee=Tt.find(Te=>Te.id.startsWith(ve[1]));if(await window.agentApi.cronDelete((Ee==null?void 0:Ee.id)??ve[1])){const Te=await window.agentApi.cronList();Be(Te),I({id:crypto.randomUUID(),role:"assistant",content:`🗑 定时任务 \`${ve[1]}\` 已删除。`,timestamp:Date.now()})}else I({id:crypto.randomUUID(),role:"assistant",content:`未找到 ID 以 \`${ve[1]}\` 开头的定时任务。`,timestamp:Date.now()})}return}const De=ee.match(/^(\S+)\s+(.+)$/s);if(De){const Ee=De[1],qe=De[2].trim();if(window.agentApi){let Te=r||ke;if(!Te){const tt=await window.agentApi.createSession(qe.slice(0,60)||"定时任务",n||void 0);Te=tt.id,G(tt.id),s&&await s(tt.id)}try{const tt=await window.agentApi.cronCreate(Ee,qe,{sessionId:Te}),rn=await window.agentApi.cronList();Be(rn),I({id:crypto.randomUUID(),role:"assistant",content:`⏰ 定时任务已创建(ID: \`${tt.id.slice(0,6)}\`),${Ri(Ee)}执行:${qe}`,timestamp:Date.now()})}catch(tt){I({id:crypto.randomUUID(),role:"assistant",content:`❌ 创建失败:${tt instanceof Error?tt.message:String(tt)}`,timestamp:Date.now()})}}return}I({id:crypto.randomUUID(),role:"assistant",content:"**定时任务用法:**\n- `/loop <间隔/cron> <任务>` — 创建,如 `/loop 5m 检查系统状态` 或 `/loop 0 9 * * * 早报`\n- `/loop list` — 查看所有定时任务\n- `/loop pause <id>` — 暂停\n- `/loop resume <id>` — 恢复\n- `/loop delete <id>` — 删除\n- `/loop stop` — 删除全部\n\n间隔支持:`30s`、`5m`、`2h`;也支持 5 字段 cron 表达式。",timestamp:Date.now()});return}const f=o.match(/(?:每(?:隔)?|定时每)\s*(\d+(?:\.\d+)?)\s*(分钟|秒|小时|min|sec|h)\s*(.+)/is);if(f){const ee=f[1]+f[2],le=f[3].trim();if(le&&window.agentApi){let fe=r||ke;if(!fe){const ve=await window.agentApi.createSession(le.slice(0,60)||"定时任务",n||void 0);fe=ve.id,G(ve.id),s&&await s(ve.id)}try{const ve=await window.agentApi.cronCreate(ee,le,{sessionId:fe}),De=await window.agentApi.cronList();Be(De),bt(""),I({id:crypto.randomUUID(),role:"user",content:o,timestamp:Date.now()}),I({id:crypto.randomUUID(),role:"assistant",content:`⏰ 定时任务已创建(ID: \`${ve.id.slice(0,6)}\`),${Ri(ee)}执行:${le}`,timestamp:Date.now()})}catch(ve){I({id:crypto.randomUUID(),role:"assistant",content:`❌ 创建失败:${ve instanceof Error?ve.message:String(ve)}`,timestamp:Date.now()})}return}}const x=Ut.trim(),w=x.match(/^\/goal(?:\s+([\s\S]+))?$/i),B=w?((se=w[1])==null?void 0:se.trim())??"":en?x:null;if(B!==null&&!B){we("请输入目标内容");return}const M=ss.length>0?ss.map(ee=>ee.name).join(", "):void 0,te=Nr.length>0?[...Nr]:void 0,U=ss.map(ee=>ee.id);if(oi([]),ye&&(r||ke)&&(Ne.current=!0),bt(""),Tr([]),En([]),B!==null){const ee=crypto.randomUUID();let le=null;br.current=!1;try{const fe=await Ca({text:B,projectId:n??null,sessionId:r||ke,createSession:async(De,Ee)=>{if(!window.agentApi)throw new Error("agentApi 未就绪");return await window.agentApi.createSession(De,Ee)},activateSession:De=>{Ft.current=De,G(De),it.current=De,N(De)},showUserMessage:(De,Ee)=>{le=Ee,I({id:ee,role:"user",content:De,timestamp:Date.now(),agentName:M,images:te,isGoal:!0,goalId:ee},Ee)},onSessionCreated:s}),ve=await window.agentApi.enqueueSessionGoal(fe,B,ee);_t(ve,fe),i&&i(fe,B)}catch(fe){if(le){const ve=Le.getState().getMessagesForSession(le);J(ve.filter(De=>De.id!==ee),le)}N(null),we(fe instanceof Error?fe.message:"目标创建失败")}return}if(Ot){const ee=crypto.randomUUID(),le={id:ee,role:"user",content:x,timestamp:Date.now(),agentName:M,images:te,isQueued:!0};if(z&&Z&&((H=window.agentApi)!=null&&H.enqueueSessionMessage))try{const fe=await window.agentApi.enqueueSessionMessage(Z,{sourceMessageId:ee,content:x,images:te,agentIds:U,agentName:M});_t(fe,Z)}catch(fe){bt(x),En(te??[]),we(fe instanceof Error?fe.message:"排队消息保存失败")}else I(le);return}jt([]);try{const ee=await Ca({text:x,projectId:n??null,sessionId:r||ke,createSession:async(le,fe)=>{if(!window.agentApi)throw new Error("agentApi 未就绪");return await window.agentApi.createSession(le,fe)},activateSession:le=>{Ft.current=le,G(le),it.current=le,N(le)},showUserMessage:(le,fe)=>I({id:crypto.randomUUID(),role:"user",content:le,timestamp:Date.now(),agentName:M,images:te},fe),onSessionCreated:s});i&&i(ee,x),await $r({content:x,agentName:M,images:te},ee,U.length>0?U:void 0)}catch(ee){we(ee instanceof Error?ee.message:"Agent run failed")}};return l.useEffect(()=>{if(!V||!window.agentApi)return;const{text:o,projectId:f,sessionId:x}=V;let w=!1;return(async()=>{try{jt([]);const B=await jp({text:o,projectId:f,sessionId:x,createSession:async(M,te)=>await window.agentApi.createSession(M,te),activateSession:M=>{Ft.current=M,G(M),it.current=M,N(M)},showUserMessage:(M,te)=>I({id:crypto.randomUUID(),role:"user",content:M,timestamp:Date.now()},te),onSessionCreated:s,isCancelled:()=>w});if(!B)return;i&&i(B,o),await $r({content:o},B)}catch(B){we(B instanceof Error?B.message:"语音指令执行失败")}})(),()=>{w=!0}},[V==null?void 0:V.nonce]),e.jsxs("div",{className:"chat-view chat-view--codex-history",style:{display:"flex",flexDirection:"column",height:"100%",maxWidth:"var(--chat-max-width)",margin:"0 auto"},children:[e.jsxs("div",{className:"chat-top-bar",style:{display:"flex",alignItems:"center",padding:"var(--chat-header-padding)",height:"var(--chat-header-height)",flexShrink:0,borderBottom:"1px solid var(--border-subtle)",WebkitAppRegion:"no-drag"},children:[e.jsx("span",{style:{flex:1,minWidth:0,fontSize:14,fontWeight:500,color:h?"var(--text-primary)":"var(--text-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",letterSpacing:"-0.01em"},children:h||"会话"}),m&&C&&j&&e.jsx(ip,{appearanceOpen:v,settingsOpen:k,showSettings:Se==="customer-agent",onOpenDesktopLive:A,desktopLiveOpen:S,hideToBackgroundTitle:D,codexReleaseState:wn,onHideToBackground:C,onReleaseCodex:(g==null?void 0:g.agentType)==="codex"&&g.occupancy!=="owned-externally"?()=>{yc()}:void 0,onOpenHub:E,onToggleAppearance:j,onOpenSettings:m})]}),e.jsx(up,{open:Nt,agentSessionId:Z,onClose:()=>Zt(!1)}),e.jsxs("div",{className:"chat-messages-frame",children:[e.jsxs("div",{ref:Gt,className:"chat-messages",onScroll:tc,onTouchStart:o=>fr.current.start(o.touches),onTouchMove:o=>{fr.current.move(o.touches,o.currentTarget.scrollTop)&&Lr.current()},onTouchEnd:()=>fr.current.reset(),onTouchCancel:()=>fr.current.reset(),style:{overflow:"auto",position:"relative",padding:"var(--chat-messages-padding)"},children:[R.length>0&&(ao||Is)&&e.jsx("div",{className:"chat-history-page-status",role:Is?"alert":"status",style:{position:"absolute",top:8,left:"50%",transform:"translateX(-50%)",zIndex:2,minHeight:32,display:"flex",alignItems:"center",justifyContent:"center",gap:7,color:Is?"var(--danger)":"var(--text-muted)",fontSize:12},children:ao?e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.22-8.56"})}),e.jsx("span",{children:"正在加载更早消息"})]}):e.jsxs("button",{type:"button",onClick:()=>void ui(),className:"chat-history-retry",style:{border:"1px solid color-mix(in srgb, var(--danger) 30%, transparent)",background:"color-mix(in srgb, var(--danger) 7%, transparent)",color:"var(--danger)",borderRadius:6,padding:"5px 10px",cursor:"pointer",fontSize:12},children:[Is,",点击重试"]})}),R.length===0&&As&&Xl&&e.jsxs("div",{className:"chat-history-initial-loading",role:"status",style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:9,color:"var(--text-muted)",fontSize:13},children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.22-8.56"})}),e.jsx("span",{children:"正在加载历史消息"})]}),R.length===0&&!gn&&!As&&!Er&&e.jsx(gp,{agentType:(g==null?void 0:g.agentType)??t,ready:et,onSelectPrompt:cc},Z??"initial-empty-session"),O.map((o,f)=>{var ve,De,Ee,qe,Te,tt,rn,Jn,ds;const x=o;if(x.isQueued)return null;if(x.executionTrace)return e.jsx(rp,{trace:x.executionTrace,loadTrace:ec,loadToolResult:ai,renderContent:ms,runtimeProgress:cn,nativeSubagents:dn,onSelectSession:c,workspacePath:y,enableFilePreview:rr(),refreshSignal:x.executionTrace.turnId===K?Qe:0,autoLoad:ns==="latest"&&x.executionTrace.turnId===K},o.id);const w=o.role==="user",B=w&&(x.isGoal===!0||[Me.active,...Me.queued,...Me.history].some(he=>!!(he&&Ea(he.objective)===Ea(o.content)))),M=_p(O,f,gn),te=Tp((ve=x.presentation)==null?void 0:ve.completionDurationMs);if(x.isCompactionSummary)return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,margin:"20px 0",color:"var(--text-muted)",fontSize:12},children:[e.jsx("div",{style:{flex:1,height:1,background:"var(--border-subtle)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 12px",borderRadius:20,border:"1px solid var(--border-subtle)",background:"var(--bg-deep)",color:"var(--text-muted)",fontSize:11,cursor:"default",userSelect:"none"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"17 1 21 5 17 9"}),e.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e.jsx("polyline",{points:"7 23 3 19 7 15"}),e.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]}),"上下文已压缩"]}),e.jsx("div",{style:{flex:1,height:1,background:"var(--border-subtle)"}})]},o.id);if(x.widget){const he=yp[x.widget.widgetType];return he?e.jsx("div",{style:{marginBottom:16,display:"flex",justifyContent:"flex-start"},children:e.jsx(he,{...x.widget.data,widgetId:x.widget.widgetId,isAgentRunning:gn&&!O.slice(f+1).some(ot=>ot.role==="user"&&!ot.isQueued&&!ot.isSteered)})},o.id):e.jsx("div",{style:{marginBottom:16,padding:12,borderRadius:8,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",fontFamily:"var(--font-mono, monospace)",fontSize:12,whiteSpace:"pre-wrap",maxHeight:300,overflow:"auto"},children:JSON.stringify(x.widget.data,null,2)},o.id)}if(x.askUser)return e.jsx(Zu,{questionId:x.askUser.questionId,question:x.askUser.question,options:x.askUser.options,fields:x.askUser.fields,multiSelect:x.askUser.multiSelect,answered:x.askUser.answered,answer:x.askUser.answer,onAnswer:async(he,ot)=>{var Ve;if(!await((Ve=window.agentApi)==null?void 0:Ve.answerQuestion(x.askUser.questionId,he,ot)))throw new Error("回答未发送成功,请重试;若问题已结束,请刷新会话。");ce(o.id,Wt=>({...Wt,askUser:{...Wt.askUser,answered:!0,answer:he}}),Z??void 0)}},o.id);const U=x.agentName?x.agentName.charAt(0).toUpperCase():"你",se=!w&&f===O.length-1,H=O[f+1],ee=H&&H.role!==o.role&&!H.isCompactionSummary,le=(o.toolCalls??[]).map((he,ot)=>{let er;if(he.name==="write_file"&&he.arguments.file_path){const Ve=he.arguments.file_path;e:for(let Wt=f;Wt>=0;Wt--){const Pn=O[Wt].toolCalls;if(!Pn)continue;const us=Wt===f?ot-1:Pn.length-1;for(let yr=us;yr>=0;yr--){const Wn=Pn[yr];if(Wn.name==="read_file"&&Wn.arguments.file_path===Ve&&Wn.result&&!Wn.isError){er=Wn.result;break e}}}}return{toolCall:he,beforeContent:er,progress:fl(cn,he.id),nativeSubagent:dn[he.id]}}),fe=_l(le);return e.jsx("div",{"data-message-id":o.id,className:`chat-message-group${M.compact?" chat-message-group--intermediate":""}`,style:{marginBottom:M.compact?0:ee?"var(--chat-turn-gap)":"var(--chat-message-gap)"},children:e.jsxs("div",{className:`chat-message-row chat-message-row--${w?"user":"assistant"}`,style:{display:"flex",flexDirection:w?"row-reverse":"row",alignItems:"flex-start",gap:"var(--chat-row-gap)",animation:"fadeInUp 0.3s var(--ease-out) both"},children:[w?e.jsx("div",{className:"chat-message-avatar",style:{width:"var(--chat-avatar-size)",height:"var(--chat-avatar-size)",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--accent)",color:"#fff",fontSize:12,fontWeight:700,letterSpacing:0,userSelect:"none"},children:U}):e.jsx("div",{className:"chat-message-avatar",style:{width:"var(--chat-avatar-size)",height:"var(--chat-avatar-size)",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),e.jsx("path",{d:"M12 11V7"}),e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"8",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"16",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M8 20h8"})]})}),e.jsxs("div",{className:`chat-message-content chat-message-content--${w?"user":"assistant"}`,style:{maxWidth:"var(--chat-content-max-width)",display:"flex",flexDirection:"column",gap:4,alignItems:w?"flex-end":"flex-start",minWidth:0},children:[e.jsxs("div",{className:`chat-message-bubble chat-message-bubble--${w?"user":"assistant"} ${o.role==="assistant"&&o.content?"message-card":""}`,style:{padding:o.content||w&&((De=x.images)!=null&&De.length)?w?"var(--chat-user-bubble-padding)":"var(--chat-assistant-bubble-padding)":0,borderRadius:w?"14px 4px 14px 14px":"4px 14px 14px 14px",background:o.content||w&&((Ee=x.images)!=null&&Ee.length)?w?"rgba(79, 110, 247, 0.08)":void 0:"transparent",border:o.content||w&&((qe=x.images)!=null&&qe.length)?w?"1px solid rgba(79, 110, 247, 0.18)":void 0:"none",fontSize:"var(--chat-bubble-font-size)",lineHeight:"var(--chat-bubble-line-height)",color:"var(--text-primary)",letterSpacing:"0.01em"},children:[o.role==="assistant"&&((Te=o.presentation)==null?void 0:Te.reasoning)&&e.jsx(Nl,{sections:o.presentation.reasoning,streaming:gn&&se&&lr==="thinking",startedAt:Rr,renderContent:ms}),w&&x.agentName?e.jsxs("div",{children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,color:"var(--accent)",background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.22)",borderRadius:10,padding:"1px 7px 1px 5px",letterSpacing:"0.04em",marginRight:7,verticalAlign:"middle"},children:[e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("circle",{cx:"12",cy:"8",r:"4"}),e.jsx("path",{d:"M20 21a8 8 0 1 0-16 0"})]}),x.agentName]}),e.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",verticalAlign:"middle"},children:o.content})]}):o.role==="assistant"&&o.content?e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:ms(o.content)}):o.content&&e.jsx("div",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:w?o.content:ms(o.content)}),w&&x.images&&x.images.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:o.content?8:0},children:x.images.map((he,ot)=>e.jsx("button",{type:"button",className:"chat-message-image-button","aria-label":"放大查看图片",onClick:()=>Tn({src:he,alt:`用户发送的图片 ${ot+1}`}),children:e.jsx("img",{className:"chat-message-attachment-image",src:he,alt:`用户发送的图片 ${ot+1}`})},ot))}),w&&!((tt=x.images)!=null&&tt.length)&&((rn=x.presentation)==null?void 0:rn.attachments)&&x.presentation.attachments.length>0&&e.jsx("div",{className:"chat-message-attachments",children:x.presentation.attachments.map((he,ot)=>he.dataUrl?e.jsx("button",{type:"button",className:"chat-message-image-button","aria-label":`放大查看图片:${he.name}`,onClick:()=>Tn({src:he.dataUrl,alt:he.name}),children:e.jsx("img",{className:"chat-message-attachment-image",src:he.dataUrl,alt:he.name,title:he.name})},`${he.name}-${ot}`):e.jsxs("div",{className:"chat-message-attachment-unavailable","aria-label":`${he.name},图片已失效`,children:[e.jsx("span",{className:"chat-message-attachment-name",children:he.name}),e.jsx("span",{children:"图片已失效"})]},`${he.name}-${ot}`))}),w&&((Jn=x.presentation)==null?void 0:Jn.rawContent)&&e.jsxs("details",{className:"chat-message-raw-content",children:[e.jsx("summary",{children:"查看原始内容"}),e.jsx("pre",{children:x.presentation.rawContent})]}),fe.map(he=>he.action&&he.items.length>1?e.jsx(Tl,{items:he.items,onSelectSession:c,workspacePath:y,enableFilePreview:rr(),onLoadResult:xo},`group-${he.items[0].toolCall.id}`):e.jsx(Xs,{toolCall:he.items[0].toolCall,beforeContent:he.items[0].beforeContent,progress:he.items[0].progress,nativeSubagent:he.items[0].nativeSubagent,onSelectSession:c,workspacePath:y,enableFilePreview:rr(),onLoadResult:xo},he.items[0].toolCall.id)),(()=>{const he=(o.toolCalls??[]).filter(Ve=>Ve.name==="write_file"&&Ve.result&&!Ve.isError);if(he.length===0)return null;const ot=new Map;for(const Ve of he){const Wt=Ve.arguments.file_path??"",Pn=Ve.arguments.content??"",us=Pn?Pn.split(`
|
|
368
|
+
`).length:0;let yr=0;e:for(let Wn=f;Wn>=0;Wn--){const Ho=O[Wn].toolCalls??[];for(let hi=Ho.length-1;hi>=0;hi--){const ps=Ho[hi];if(ps.name==="read_file"&&ps.arguments.file_path===Wt&&ps.result&&!ps.isError){yr=ps.result.split(`
|
|
369
|
+
`).length;break e}}}ot.set(Wt,{path:Wt,lines:us,added:Math.max(0,us-yr),removed:Math.max(0,yr-us)})}const er=[...ot.values()];return e.jsxs("div",{style:{marginTop:10,padding:"8px 12px",borderRadius:8,background:"var(--bg-deep)",border:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",gap:8,alignItems:"center"},children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",flexShrink:0},children:"变更汇总"}),er.map(Ve=>{const Wt=wl(Ve.path,y),Pn=e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--text-secondary)",maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:Ve.path,children:Ve.path.replace(/\\/g,"/").split("/").pop()}),Ve.added>0&&e.jsxs("span",{style:{color:"var(--success)",fontWeight:600},children:["+",Ve.added]}),Ve.removed>0&&e.jsxs("span",{style:{color:"var(--danger)",fontWeight:600},children:["−",Ve.removed]}),Ve.added===0&&Ve.removed===0&&e.jsxs("span",{style:{color:"var(--text-muted)"},children:[Ve.lines,"行"]})]});return rr()&&Wt?e.jsx("button",{type:"button",className:"chat-file-change-link",onClick:()=>Sr(Wt),title:`预览 ${Wt}`,"aria-label":`预览改动文件 ${Ve.path.replace(/\\/g,"/").split("/").pop()}`,children:Pn},Ve.path):e.jsx("span",{className:"chat-file-change-link chat-file-change-link--static",children:Pn},Ve.path)})]})})()]}),M.showCompletion&&e.jsxs("div",{className:"msg-completion-footer",children:[e.jsxs("span",{className:"msg-completion-status",children:[e.jsx(Ur,{size:13,strokeWidth:2,"aria-hidden":"true"}),e.jsx("span",{children:"已完成"}),te&&e.jsxs("span",{children:[" · 总耗时 ",te]})]}),e.jsxs("span",{className:"msg-completion-actions",children:[!rr()&&M.showSpeak&&typeof((ds=window.agentApi)==null?void 0:ds.ttsSpeak)=="function"&&e.jsx("button",{type:"button",onClick:()=>sc(o.id,o.content),title:os===o.id?"停止播报":"语音播报","aria-label":os===o.id?"停止播报":"语音播报",className:`ui-icon-button ui-icon-button--small msg-action-button ${os===o.id?"is-active":""}`,children:os===o.id?e.jsx(bd,{size:12,fill:"currentColor","aria-hidden":"true"}):e.jsx(wd,{size:13,strokeWidth:1.8,"aria-hidden":"true"})}),e.jsx("button",{type:"button",onClick:()=>{yi(o.content)},title:"复制内容","aria-label":"复制内容",className:"ui-icon-button ui-icon-button--small msg-action-button",children:e.jsx(gi,{size:13,strokeWidth:1.8,"aria-hidden":"true"})})]})]}),!M.showCompletion&&(M.showCopy||B)&&e.jsxs("div",{className:"msg-actions",style:{display:"flex",alignItems:"center",gap:4},children:[B&&e.jsx("span",{className:"ui-icon-button ui-icon-button--small msg-action-button msg-goal-marker",title:"目标消息","aria-label":"目标消息",role:"img",children:e.jsx(mi,{size:13,strokeWidth:1.9,"aria-hidden":"true"})}),M.showCopy&&e.jsx("button",{type:"button",onClick:()=>{yi(o.content)},title:"复制内容","aria-label":"复制内容",className:"ui-icon-button ui-icon-button--small msg-action-button",children:e.jsx(gi,{size:13,strokeWidth:1.8,"aria-hidden":"true"})})]}),w&&(x.isQueued||x.isSteered)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:4},children:[x.isQueued&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,color:"var(--text-muted)",padding:"2px 8px",borderRadius:20,background:"var(--bg-deep)",border:"1px solid var(--border-subtle)"},children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"排队中"]}),F&&e.jsxs("button",{onClick:()=>void Mo(o.id),title:"将此消息引导到当前对话",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:"var(--accent)",padding:"2px 10px",borderRadius:20,border:"1px solid rgba(79,110,247,0.3)",background:"var(--accent-dim)",cursor:"pointer",transition:"all 0.15s",fontFamily:"var(--font-body)"},onMouseEnter:he=>{he.currentTarget.style.background="rgba(79,110,247,0.18)",he.currentTarget.style.borderColor="var(--accent)"},onMouseLeave:he=>{he.currentTarget.style.background="var(--accent-dim)",he.currentTarget.style.borderColor="rgba(79,110,247,0.3)"},children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 12h18M3 6h18M3 18h18"}),e.jsx("path",{d:"M12 3v18",opacity:"0.3"})]}),"引导"]})]}),x.isSteered&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,color:"var(--success)",padding:"2px 8px",borderRadius:20,background:"rgba(34,197,94,0.08)",border:"1px solid rgba(34,197,94,0.2)"},children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),"已引导"]})]})]})]})},o.id)}),gn&&In&&e.jsx(Cl,{progress:In,startedAt:Rr}),ei&&e.jsx("div",{className:"chat-message-activity",style:{display:"flex",alignItems:"flex-start",padding:"4px 0 4px",animation:"fadeInUp 0.3s var(--ease-out)"},children:e.jsx(tp,{startedAt:Rr})}),(Kn||Er)&&e.jsxs("div",{style:{padding:12,margin:"8px 0",borderRadius:"var(--radius-sm)",background:"rgba(248,113,113,0.08)",border:"1px solid rgba(248,113,113,0.2)",color:"var(--danger)",fontSize:13,animation:"fadeIn 0.2s var(--ease-out)",fontFamily:"var(--font-mono)",display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{flex:1,minWidth:0},children:Kn||Er}),Kn&&e.jsxs("button",{type:"button",onClick:()=>Kt(o=>o+1),"aria-label":"重新加载会话",title:"重新加载会话",style:{flexShrink:0,minHeight:30,display:"inline-flex",alignItems:"center",gap:5,padding:"5px 9px",border:"1px solid rgba(248,113,113,0.35)",borderRadius:5,background:"var(--bg-workspace)",color:"var(--danger)",cursor:"pointer",fontSize:12},children:[e.jsx(Xi,{size:14,"aria-hidden":"true"}),"重新加载"]})]}),e.jsx("div",{ref:Ss})]}),e.jsx(xu,{entries:(ni==null?void 0:ni.entries)??[],activeMessageId:Vl,loadingMessageId:Kl,onActivate:o=>{Co(o)}}),ns==="anchored"&&e.jsx("button",{type:"button",className:"chat-history-return-latest","data-has-updates":Gl,"data-loading-newer":Ql,"aria-busy":si||void 0,"aria-label":"回到最新消息",title:"回到最新消息",disabled:si,onClick:()=>{Io()},children:si?e.jsx(Dt,{className:"chat-history-return-latest__spinner",size:16,"aria-hidden":"true"}):e.jsx(Go,{size:16,"aria-hidden":"true"})}),ns!=="anchored"&&Yl&&e.jsx("button",{type:"button",className:"chat-jump-to-bottom","aria-label":"回到底部",title:"回到底部",onClick:nc,children:e.jsx(Go,{size:16,"aria-hidden":"true"})})]}),e.jsxs("div",{className:"chat-input-area",style:{padding:"var(--chat-input-padding)",background:"var(--bg-workspace)"},children:[pe&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-surface)",color:re==="incompatible"?"var(--danger)":"var(--text-muted)",fontSize:12},children:e.jsx("span",{style:{flex:1},children:re==="incompatible"?Ir||((Wo=g==null?void 0:g.compatibility)==null?void 0:Wo.reason)||`Codex ${((Do=g==null?void 0:g.compatibility)==null?void 0:Do.producerVersion)??"未知版本"} 与当前 ${((Bo=g==null?void 0:g.compatibility)==null?void 0:Bo.readerVersion)??"运行时"} 不兼容`:`正在使用 Codex ${(($o=g==null?void 0:g.compatibility)==null?void 0:$o.readerVersion)??"当前版本"} 验证此会话`})}),ut&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:9,padding:"8px 10px",border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-surface)",color:"var(--text-muted)",fontSize:12},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"5",y:"11",width:"14",height:"10",rx:"2"}),e.jsx("path",{d:"M8 11V7a4 4 0 0 1 8 0v4"})]}),e.jsx("span",{style:{flex:1},children:at!=null&&at.forkSessionId?"副本已创建,但消息尚未发送成功。":"此会话仍由原客户端持有,可创建副本继续。"}),ut&&e.jsx("button",{type:"button",onClick:()=>void vc(),disabled:Xt,style:{flexShrink:0,border:"1px solid var(--border-default)",borderRadius:5,padding:"5px 9px",background:"var(--bg-workspace)",color:"var(--text-primary)",fontSize:12,fontWeight:600,cursor:Xt?"wait":"pointer",opacity:Xt?.65:1},children:Xt?at!=null&&at.forkSessionId?"正在发送…":"正在创建…":at!=null&&at.forkSessionId?"重新发送":"以副本继续"})]}),Je.length>0&&e.jsxs("div",{style:{marginBottom:10,padding:"8px 12px",borderRadius:10,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)",boxShadow:"var(--shadow-sm)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6,fontSize:10,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em"},children:[e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),"任务列表"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(()=>{const o=new Set(Je.filter(f=>f.status==="completed").map(f=>f.title.toLowerCase()));return Je.map(f=>{const x=f.status==="pending",w=f.status==="in-progress",B=f.status==="completed",M=x&&(f.dependsOn??[]).some(te=>!o.has(te.toLowerCase()));return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,opacity:B?.65:1,transition:"opacity 0.3s"},children:[e.jsxs("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:B?"rgba(52,211,153,0.15)":w?"var(--accent-dim)":M?"rgba(239,68,68,0.08)":"rgba(0,0,0,0.04)",border:B?"1.5px solid rgba(52,211,153,0.6)":w?"1.5px solid var(--accent)":M?"1.5px solid rgba(239,68,68,0.5)":"1.5px solid var(--border-default)"},children:[B&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"rgba(52,211,153,0.9)",strokeWidth:"3",strokeLinecap:"round",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}),w&&e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"var(--accent)",animation:"pulse 1.2s ease-in-out infinite"}}),M&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"rgba(239,68,68,0.8)",strokeWidth:"3",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})}),x&&!M&&e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",background:"var(--border-default)"}})]}),e.jsx("span",{style:{fontSize:12,color:B?"var(--text-muted)":M?"rgba(239,68,68,0.8)":"var(--text-primary)",textDecoration:B?"line-through":"none",flex:1},children:f.title}),M&&e.jsx("span",{title:`等待: ${(f.dependsOn??[]).join(", ")}`,style:{fontSize:10,color:"rgba(239,68,68,0.9)",background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",borderRadius:8,padding:"1px 6px",flexShrink:0},children:"等待前置"}),f.agentName&&e.jsxs("span",{style:{fontSize:10,color:"var(--accent)",background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.2)",borderRadius:8,padding:"1px 6px",flexShrink:0},children:["@",f.agentName]})]},f.id)})})()})]}),Tt.length>0&&e.jsxs("div",{style:{marginBottom:10,borderRadius:10,background:"var(--bg-surface)",border:"1px solid rgba(251,191,36,0.25)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid rgba(251,191,36,0.15)",background:"rgba(251,191,36,0.06)"},children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"#d97706",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#d97706",textTransform:"uppercase",letterSpacing:"0.07em",flex:1},children:"定时任务"}),e.jsx("button",{onClick:async()=>{window.agentApi&&(await window.agentApi.cronDeleteAll(),Be([]),I({id:crypto.randomUUID(),role:"assistant",content:"✅ 所有定时任务已删除。",timestamp:Date.now()}))},title:"删除全部",style:{background:"none",border:"1px solid rgba(251,191,36,0.35)",borderRadius:6,color:"#d97706",cursor:"pointer",padding:"1px 7px",fontSize:10},children:"全部删除"})]}),Tt.map(o=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 12px",borderBottom:"1px solid var(--border-subtle)",opacity:o.enabled?1:.7},children:[e.jsx("div",{style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:o.enabled?"#22c55e":"#9ca3af",boxShadow:o.enabled?"0 0 5px rgba(34,197,94,0.55)":"none",animation:o.enabled?"pulse 2s ease-in-out infinite":"none"}}),e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#d97706",background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.25)",borderRadius:6,padding:"1px 6px",flexShrink:0,fontFamily:"var(--font-mono)"},children:o.cron}),e.jsx("span",{style:{fontSize:12,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.label||o.prompt}),e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"var(--font-mono)",flexShrink:0},children:o.id.slice(0,6)}),e.jsxs("div",{style:{display:"flex",gap:4,flexShrink:0},children:[o.enabled?e.jsx("button",{title:"暂停",onClick:async()=>{if(window.agentApi){await window.agentApi.cronPause(o.id);const f=await window.agentApi.cronList();Be(f)}},style:{background:"none",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",padding:"2px 7px",fontSize:11},onMouseEnter:f=>{f.currentTarget.style.borderColor="#d97706",f.currentTarget.style.color="#d97706"},onMouseLeave:f=>{f.currentTarget.style.borderColor="var(--border-default)",f.currentTarget.style.color="var(--text-muted)"},children:"⏸"}):e.jsx("button",{title:"恢复",onClick:async()=>{if(window.agentApi){await window.agentApi.cronResume(o.id);const f=await window.agentApi.cronList();Be(f)}},style:{background:"none",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",padding:"2px 7px",fontSize:11},onMouseEnter:f=>{f.currentTarget.style.borderColor="#22c55e",f.currentTarget.style.color="#22c55e"},onMouseLeave:f=>{f.currentTarget.style.borderColor="var(--border-default)",f.currentTarget.style.color="var(--text-muted)"},children:"▶"}),e.jsx("button",{title:"删除",onClick:async()=>{if(window.agentApi){await window.agentApi.cronDelete(o.id);const f=await window.agentApi.cronList();Be(f)}},style:{background:"none",border:"1px solid var(--border-default)",borderRadius:6,color:"var(--text-muted)",cursor:"pointer",padding:"2px 7px",fontSize:11},onMouseEnter:f=>{f.currentTarget.style.borderColor="var(--danger)",f.currentTarget.style.color="var(--danger)"},onMouseLeave:f=>{f.currentTarget.style.borderColor="var(--border-default)",f.currentTarget.style.color="var(--text-muted)"},children:"🗑"})]})]},o.id))]}),ks.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:10},children:ks.map((o,f)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,padding:"3px 10px 3px 8px",borderRadius:20,background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.18)",fontSize:12,color:"var(--accent)",maxWidth:220},children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name}),e.jsx("button",{onClick:()=>pc(f),style:{background:"none",border:"none",color:"rgba(79,110,247,0.55)",cursor:"pointer",padding:0,marginLeft:2,fontSize:13,lineHeight:1,display:"flex"},children:"✕"})]},f))}),Nr.length>0&&(()=>{const o=ae.find(x=>x.id===Re),f=!ye&&(!o||!di(o.modelId));return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:10},children:[f&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:8,background:"rgba(234,179,8,0.1)",border:"1px solid rgba(234,179,8,0.4)",color:"rgba(202,138,4,1)",fontSize:12},children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),"当前模型(",(o==null?void 0:o.modelId)??"未配置",")不支持图片,发送前请切换到支持视觉的模型(如 claude-3、gpt-4o)"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:Nr.map((x,w)=>e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("button",{type:"button",className:"chat-message-image-button pending-image-preview-button","aria-label":`预览待发送图片 ${w+1}`,onClick:()=>Tn({src:x,alt:`待发送图片 ${w+1}`}),children:e.jsx("img",{src:x,alt:`待发送图片 ${w+1}`,style:{width:72,height:72,objectFit:"cover",borderRadius:8,border:"1.5px solid var(--border-default)",display:"block"}})}),e.jsx("button",{type:"button","aria-label":`删除待发送图片 ${w+1}`,onClick:()=>xc(w),style:{position:"absolute",top:-6,right:-6,width:18,height:18,borderRadius:"50%",background:"var(--danger, #e53e3e)",border:"none",color:"#fff",fontSize:11,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},children:"✕"})]},w))})]})})(),(Me.active||Me.queued.length>0)&&e.jsxs("div",{className:"goal-queue","aria-label":"目标队列",children:[e.jsxs("div",{className:"goal-queue__header",children:[e.jsx(mi,{size:14,strokeWidth:1.9,"aria-hidden":"true"}),e.jsx("span",{children:"目标"}),e.jsx("span",{className:"goal-queue__count",children:Me.queued.length+(Me.active?1:0)})]}),Me.active&&e.jsxs("div",{className:"goal-queue__row is-active",children:[e.jsx("span",{className:"goal-queue__state",children:"进行中"}),e.jsx("span",{className:"goal-queue__objective",title:Me.active.objective,children:Me.active.objective}),e.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{To(Me.active.id)},title:"停止当前目标","aria-label":"停止当前目标",children:e.jsx(bs,{size:14,strokeWidth:1.8,"aria-hidden":"true"})})]}),Me.queued.map((o,f)=>e.jsxs("div",{className:`goal-queue__row is-queued${js===o.id?" is-dragging":""}`,draggable:!0,onDragStart:()=>Mr(o.id),onDragEnd:()=>Mr(null),onDragOver:x=>x.preventDefault(),onDrop:()=>{Ic(o.id)},children:[e.jsx(Qo,{className:"goal-queue__grip",size:14,strokeWidth:1.8,"aria-hidden":"true"}),e.jsxs("span",{className:"goal-queue__state",children:["#",f+1]}),e.jsx("span",{className:"goal-queue__objective",title:o.objective,children:o.objective}),e.jsx("button",{type:"button",className:"goal-queue__action",onClick:()=>{To(o.id)},title:"移出目标队列","aria-label":"移出目标队列",children:e.jsx(bs,{size:14,strokeWidth:1.8,"aria-hidden":"true"})})]},o.id))]}),(()=>{const o=R.filter(f=>f.isQueued);return o.length===0?null:e.jsx("div",{className:"queued-message-list",children:o.map(f=>{const x=f,w=Rn===f.id,B=x.content.length>80?x.content.slice(0,80)+"…":x.content;return e.jsxs("div",{className:`queued-message-row${dr===f.id?" is-dragging":""}`,"data-queued-message-id":f.id,onDragOver:M=>{!dr||dr===f.id||(M.preventDefault(),M.dataTransfer.dropEffect="move")},onDrop:M=>{M.preventDefault(),dr&&fi(dr,f.id),Fn(null)},children:[e.jsx("button",{type:"button",className:"queued-message-grip",draggable:!w,"aria-label":"拖动调整排队顺序",title:"拖动调整顺序",onDragStart:M=>{Fn(f.id),M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",f.id)},onDragEnd:()=>Fn(null),onKeyDown:M=>{(M.key==="ArrowUp"||M.key==="ArrowDown")&&(M.preventDefault(),Sc(f.id,M.key==="ArrowUp"?-1:1))},onPointerDown:M=>{M.pointerType==="mouse"||w||(Mn.current={id:f.id,pointerId:M.pointerId},M.currentTarget.setPointerCapture(M.pointerId),Fn(f.id))},onPointerMove:M=>{var H;const te=Mn.current;if(!te||te.pointerId!==M.pointerId)return;M.preventDefault();const U=(H=document.elementFromPoint(M.clientX,M.clientY))==null?void 0:H.closest("[data-queued-message-id]"),se=U==null?void 0:U.dataset.queuedMessageId;se&&se!==te.id&&fi(te.id,se)},onPointerUp:M=>{var te;((te=Mn.current)==null?void 0:te.pointerId)===M.pointerId&&(Mn.current=null,Fn(null))},onPointerCancel:()=>{Mn.current=null,Fn(null)},children:e.jsx(Qo,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),e.jsxs("div",{className:"queued-message-content",children:[x.agentName&&e.jsxs("span",{className:"queued-message-agent",children:["@",x.agentName]}),w?e.jsx("input",{autoFocus:!0,className:"queued-message-edit-input",value:Yr,onChange:M=>qt(M.target.value),onKeyDown:M=>{M.key==="Enter"&&!M.nativeEvent.isComposing?(M.preventDefault(),Eo(f.id)):M.key==="Escape"&&(M.preventDefault(),pi())},"aria-label":"编辑排队消息内容"}):e.jsx("span",{className:"queued-message-text",title:x.content,children:B})]}),e.jsxs("div",{className:"queued-message-actions",children:[F&&e.jsx("button",{type:"button",className:"queued-message-action queued-message-action--accent",onClick:()=>void Mo(f.id),title:"引导到当前对话","aria-label":"引导排队消息到当前对话",children:e.jsx($c,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"queued-message-action",onClick:()=>void jc(f.id),title:An===f.id?"已复制":"复制","aria-label":"复制排队消息",children:An===f.id?e.jsx(Ur,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):e.jsx(gi,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"queued-message-action",onClick:()=>w?Eo(f.id):wc(f.id),disabled:w&&!Yr.trim(),title:w?"保存":"编辑","aria-label":w?"保存排队消息":"编辑排队消息",children:w?e.jsx(Ur,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):e.jsx(nl,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"queued-message-action queued-message-action--danger",onClick:()=>kc(f.id),title:"删除","aria-label":"删除排队消息",children:e.jsx(bs,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]})]},f.id)})})})(),e.jsx("div",{ref:ii,className:"composer-anchor",style:{position:"relative"},children:e.jsx("div",{className:"composer-shell",style:{display:"flex",flexDirection:"column",gap:0,background:"var(--bg-surface)",borderRadius:14,overflow:"visible"},children:e.jsxs("div",{className:"composer-input-row",style:{display:"flex",alignItems:"center",gap:8,padding:"var(--composer-row-padding)"},children:[e.jsx("input",{ref:po,type:"file",multiple:!0,style:{display:"none"},onChange:uc}),ss.length>0&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,flexShrink:0,flexWrap:"nowrap",overflow:"hidden",maxWidth:300},children:ss.map(o=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,padding:"2px 7px 2px 6px",borderRadius:20,background:"var(--accent-dim)",border:"1px solid rgba(79,110,247,0.25)",fontSize:12,color:"var(--accent)",flexShrink:0,whiteSpace:"nowrap"},children:[e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("circle",{cx:"12",cy:"8",r:"4"}),e.jsx("path",{d:"M20 21a8 8 0 1 0-16 0"})]}),"@",o.name,e.jsx("button",{onClick:()=>ac(o.id),style:{background:"none",border:"none",color:"rgba(79,110,247,0.55)",cursor:"pointer",padding:0,lineHeight:1,fontSize:12,display:"flex"},children:"✕"})]},o.id))}),e.jsx("textarea",{className:"composer-text-input web-native-composer-textarea",ref:rs,rows:3,value:Ut,onChange:o=>vo(o.target.value),onBlur:()=>setTimeout(()=>{hr(null),xr(null)},120),onKeyDown:dc,placeholder:wn==="released"?"已停止在 AgentRoam 中使用;Codex Desktop 最长约 30 分钟后可用":pe?re==="incompatible"?"Codex 版本不兼容":"正在验证会话兼容性":Pe?"原客户端使用中,当前只读":He?en?"输入要持续推进的目标":Ot?"输入下一条排队消息":"提出后续修改要求":"请先在设置中配置 API Key",disabled:!et}),e.jsxs("div",{className:"web-native-composer-toolbar",children:[e.jsxs("div",{className:"web-native-add-wrap",children:[e.jsx("button",{type:"button",className:"web-native-add-button","aria-label":"添加附件、图片或语音","aria-expanded":xn,onClick:()=>Hn(o=>!o),children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),xn&&e.jsxs("div",{className:"web-native-add-menu",children:[e.jsx("button",{type:"button",onClick:()=>{var o;Hn(!1),(o=po.current)==null||o.click()},children:"附件 / 图片"}),e.jsx("button",{type:"button",onClick:()=>{Hn(!1),rc()},children:"语音输入"})]})]}),e.jsx("button",{type:"button",className:`web-native-runtime-status goal-mode-toggle${en?" is-active":""}`,"aria-pressed":en,"aria-label":en?"关闭目标模式":"开启目标模式",title:en?"目标模式已开启":"目标模式",onClick:()=>Zr(o=>!o),children:e.jsx(mi,{size:18,strokeWidth:1.9,"aria-hidden":"true"})}),e.jsxs("div",{className:"web-native-permission-wrap",ref:Lt,children:[e.jsx("button",{type:"button",className:`web-native-runtime-status web-native-permission-button mode-${mn}`,"aria-label":`会话权限:${(Oo=$s.find(o=>o.value===mn))==null?void 0:Oo.label}`,"aria-haspopup":"menu","aria-expanded":ur,title:`会话权限:${(Fo=$s.find(o=>o.value===mn))==null?void 0:Fo.label}`,disabled:!Z||$e,onClick:()=>Un(o=>!o),children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("path",{d:"M12 8v4"}),e.jsx("path",{d:"M12 16h.01"})]})}),ur&&e.jsx("div",{className:"web-native-permission-menu",role:"menu","aria-label":"会话权限模式",children:$s.map(o=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":mn===o.value,className:mn===o.value?"is-active":"",onClick:()=>{bc(o.value)},children:[e.jsx("span",{className:"web-native-permission-check","aria-hidden":"true",children:mn===o.value?"✓":""}),e.jsxs("span",{className:"web-native-permission-copy",children:[e.jsx("strong",{children:o.label}),e.jsx("small",{children:o.description})]})]},o.value))})]}),e.jsx("div",{className:"web-native-context-control",children:e.jsx(ep,{usage:Z?Ke[Z]:void 0,contextWindowK:gt,compact:!0})}),e.jsx("label",{className:`web-native-model-control${ye?" web-native-model-control--native":""}`,title:"切换模型",children:ye&&Os(Se)?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"web-native-model-agent",title:`${za[Se]} 会话`,children:[e.jsx(Zi,{agentType:Se,size:14}),e.jsx("span",{className:"web-native-model-agent-name",children:za[Se]})]}),b&&e.jsxs("select",{"aria-label":"当前模型",title:"切换模型",value:or,onChange:o=>{fn({model:o.target.value?Dd(o.target.value):void 0})},children:[e.jsx("option",{value:"",children:"默认模型"}),hn.map(o=>e.jsx("option",{value:o.key,children:o.label},o.key)),lt.length>0&&e.jsx("optgroup",{label:"设置里的模型",children:lt.map(o=>e.jsx("option",{value:o.key,children:o.label},o.key))})]})]}):e.jsx("select",{"aria-label":"当前模型",value:Re,disabled:ae.length===0,onChange:o=>{ht(o.target.value)},children:ae.length===0?e.jsx("option",{value:"",children:"未配置模型"}):ae.map(o=>e.jsx("option",{value:o.id,children:o.name||o.modelId},o.id))})}),On?e.jsx("button",{type:"button",onClick:Ao,className:"web-native-stop-button","aria-label":"停止生成",title:"停止生成",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}):ye&&an.length>0?e.jsxs("div",{className:"web-native-effort-wrap",ref:on,children:[e.jsx("button",{type:"button",className:"web-native-effort-button","aria-expanded":pn,"aria-label":`推理强度:${It?Ai[It]:"默认"}`,title:`推理强度:${It?Ai[It]:"默认"}(点击切换)`,onClick:()=>rt(o=>!o),children:e.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M9.5 4.5A3.5 3.5 0 0 0 6 8v1a3 3 0 0 0-2 2.83V14a3 3 0 0 0 3 3h.25A3.75 3.75 0 0 0 11 20.75V3.25A3.75 3.75 0 0 0 9.5 4.5Z"}),e.jsx("path",{d:"M14.5 4.5A3.5 3.5 0 0 1 18 8v1a3 3 0 0 1 2 2.83V14a3 3 0 0 1-3 3h-.25A3.75 3.75 0 0 1 13 20.75V3.25a3.75 3.75 0 0 1 1.5 1.25Z"})]})}),pn&&e.jsxs("div",{className:"web-native-effort-menu",role:"menu","aria-label":"推理强度",children:[e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":!It,className:It?void 0:"is-active",onClick:()=>{fn({reasoningEffort:void 0}),rt(!1)},children:[e.jsx("span",{className:"web-native-effort-check","aria-hidden":"true",children:It?"":"✓"}),"默认"]}),an.map(o=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":It===o,className:It===o?"is-active":void 0,onClick:()=>{fn({reasoningEffort:o}),rt(!1)},children:[e.jsx("span",{className:"web-native-effort-check","aria-hidden":"true",children:It===o?"✓":""}),Ai[o]]},o))]})]}):ye?e.jsxs("span",{className:"web-native-agent-status",role:"status","aria-label":"Agent 空闲",title:"Agent 空闲",children:[e.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M9.5 4.5A3.5 3.5 0 0 0 6 8v1a3 3 0 0 0-2 2.83V14a3 3 0 0 0 3 3h.25A3.75 3.75 0 0 0 11 20.75V3.25A3.75 3.75 0 0 0 9.5 4.5Z"}),e.jsx("path",{d:"M14.5 4.5A3.5 3.5 0 0 1 18 8v1a3 3 0 0 1 2 2.83V14a3 3 0 0 1-3 3h-.25A3.75 3.75 0 0 1 13 20.75V3.25a3.75 3.75 0 0 1 1.5 1.25Z"})]}),e.jsx("span",{"aria-hidden":"true"})]}):e.jsxs("div",{className:"web-native-effort-wrap",ref:Rt,children:[e.jsx("button",{type:"button",className:"web-native-effort-button","aria-expanded":Ar,"aria-label":`推理强度:${Na[Ye]}`,title:`推理强度:${Na[Ye]}(点击切换)`,onClick:()=>Xr(o=>!o),children:e.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M9.5 4.5A3.5 3.5 0 0 0 6 8v1a3 3 0 0 0-2 2.83V14a3 3 0 0 0 3 3h.25A3.75 3.75 0 0 0 11 20.75V3.25A3.75 3.75 0 0 0 9.5 4.5Z"}),e.jsx("path",{d:"M14.5 4.5A3.5 3.5 0 0 1 18 8v1a3 3 0 0 1 2 2.83V14a3 3 0 0 1-3 3h-.25A3.75 3.75 0 0 1 13 20.75V3.25a3.75 3.75 0 0 1 1.5 1.25Z"})]})}),Ar&&e.jsx("div",{className:"web-native-effort-menu",role:"menu","aria-label":"推理强度",children:Bl.map(o=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":Ye===o.value,className:Ye===o.value?"is-active":void 0,onClick:()=>{dt("reasoningEffort",o.value),$(),Xr(!1)},children:[e.jsx("span",{className:"web-native-effort-check","aria-hidden":"true",children:Ye===o.value?"✓":""}),o.label]},o.value))})]}),e.jsx("button",{type:"button",onClick:No,disabled:!et||Jr>0||!Ut.trim(),className:"web-native-send-button","aria-label":Ot?"排队发送":"发送",title:Ot?"排队发送":"发送",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})})}),e.jsxs("div",{className:"chat-composer-hint",style:{textAlign:"center",marginTop:7,fontSize:11,color:"var(--text-muted)",letterSpacing:"0.03em",opacity:.6},children:["Enter 发送",en?"目标":Ot?"(排队)":""," · @智能体(可多选)· /技能 · Shift+Enter 换行",mo?" · 🎤 正在聆听…":""]})]}),e.jsx(xp,{image:ti,onClose:()=>Tn(null)}),Yn&&is!==null&&yo.length>0&&Yt.createPortal(e.jsxs("div",{style:{position:"fixed",bottom:window.innerHeight-Yn.top+8,left:Yn.left,width:Yn.width,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:10,boxShadow:"var(--shadow-md)",overflow:"hidden",zIndex:99999},children:[e.jsx("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em"},children:"智能体"}),yo.map(o=>e.jsxs("button",{onMouseDown:f=>{f.preventDefault(),oc(o)},style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer"},onMouseEnter:f=>{f.currentTarget.style.background="var(--accent-dim)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:["@",o.name]}),o.description&&e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:1},children:o.description})]},o.id))]}),document.body),Yn&&gr!==null&&ci.length>0&&Yt.createPortal(e.jsxs("div",{style:{position:"fixed",bottom:window.innerHeight-Yn.top+8,left:Yn.left,width:Yn.width,background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:10,boxShadow:"var(--shadow-md)",zIndex:99999,display:"flex",flexDirection:"column",maxHeight:320},children:[e.jsxs("div",{style:{padding:"6px 10px 4px",fontSize:10,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",flexShrink:0},children:["技能 (",ci.length,")"]}),e.jsx("div",{style:{overflowY:"auto",flex:1},children:ci.map(o=>e.jsxs("button",{onMouseDown:f=>{f.preventDefault(),lc(o)},style:{display:"block",width:"100%",textAlign:"left",padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer"},onMouseEnter:f=>{f.currentTarget.style.background="var(--accent-dim)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:["/",o.name]}),o.description&&e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.description})]},o.name))})]}),document.body)]})}function Mi(t,n,r="auto"){const s=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=t.scrollTop+i.top-s.top-Math.max(0,(t.clientHeight-i.height)/2);t.scrollTo({top:Math.max(0,a),behavior:r})}const Ps=4,Xp=4e6,Zp=8,Jp=.12;function ef(t,n,r=Jp){if(n<=0)return[];const s=Array.from({length:n},(u,h)=>{const g=Number(t[h]);return Number.isFinite(g)&&g>0?g:1}),i=s.reduce((u,h)=>u+h,0),c=s.map(u=>u/i).map(u=>Math.max(u,r)),d=c.reduce((u,h)=>u+h,0);return c.map(u=>u/d)}function tf(t,n,r,s=Zp){if(n<=1||t.width<=0||t.height<=0)return t.width<=0||t.height<=0?[]:[{x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)}];const i=Math.min(n,6),a=s*(i-1),c=t.width-a;if(c<=0)return[];const d=ef(r,i),u=[];let h=t.x;for(let g=0;g<i;g+=1){const m=g===i-1?t.x+t.width-h:Math.floor(c*d[g]);u.push({x:Math.round(h),y:Math.round(t.y),width:Math.round(m),height:Math.round(t.height)}),h+=m+s}return u}function nf({siteId:t,name:n,onSetup:r}){const s=window.agentApi,[i,a]=l.useState(null),[c,d]=l.useState({connected:!1,tabs:[]}),[u,h]=l.useState(""),[g,y]=l.useState(!1),[m,k]=l.useState(Date.now()),[C,E]=l.useState(!0),A=l.useRef(null),S=!c.paused&&c.compatible!==!1&&c.tabs.some(D=>D.siteId===t);l.useEffect(()=>{let D=!1,V=!1,R=!1;s.hubChromeStatus().then(I=>{!D&&!V&&d(I)}),typeof s.hubChromeConversation!="function"?h("请重启 AI Hub 桌面端以启用消息面板"):s.hubChromeConversation(t).then(I=>{!D&&!R&&a(I)});const T=s.onHubChromeEvent(I=>{I.type==="chrome-conversation"&&I.conversation.siteId===t&&(R=!0,a(N=>!N||I.conversation.revision>N.revision?I.conversation:N),h("")),I.type==="chrome-status"&&(V=!0,d(I.status),I.status.tabs.some(N=>N.siteId===t)||(a(null),h(""))),I.type==="chrome-page-error"&&I.siteId===t&&h(I.error)}),P=setInterval(()=>k(Date.now()),1e3);return()=>{D=!0,T(),clearInterval(P)}},[s,t]),l.useLayoutEffect(()=>{C&&A.current&&(A.current.scrollTop=A.current.scrollHeight)},[i==null?void 0:i.revision,C]);const j=S&&!!i&&m-i.receivedAt>6e3,v=c.paused?"Chrome 网页连接已暂停,点击下方按钮即可恢复。":c.connected&&c.compatible===!1?"请从「连接 Chrome」加载新版自动连接扩展。":S?i?i.generating?"正在回复…":i.composerAvailable?"已同步 · 从下方输入框发送消息":"未找到输入框,请在 Chrome 检查页面":"正在读取网页对话…":"在日常 Chrome 中打开并登录此站点,扩展会自动接入;若已暂停,请在扩展中恢复自动连接。";return e.jsxs("div",{"data-aihub-native-pane":t,style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",minWidth:0},children:[e.jsx("div",{role:"status",style:{padding:"10px 16px",fontSize:12,lineHeight:1.6,color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:v}),e.jsx("div",{ref:A,onScroll:()=>{const D=A.current;D&&E(D.scrollHeight-D.scrollTop-D.clientHeight<60)},style:{flex:1,minHeight:0,overflow:"auto",padding:"18px 16px",overflowWrap:"anywhere"},children:S?i!=null&&i.messages.length?i.messages.map(D=>e.jsxs("article",{"data-message-id":D.id,style:{marginBottom:24,padding:D.role==="user"?"12px 14px":"0 2px",borderRadius:12,background:D.role==="user"?"var(--bg-deep)":"transparent"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,fontSize:12,color:"var(--text-muted)"},children:[e.jsx("strong",{children:D.role==="user"?"你":n}),e.jsx("button",{className:"ui-icon-button ui-icon-button--auto","aria-label":`复制 ${D.role==="user"?"消息":n+" 回复"}`,style:{padding:"2px 5px",fontSize:11},onClick:()=>{navigator.clipboard.writeText(D.content).catch(()=>h("未能复制,请选择文字复制"))},children:"复制"})]}),e.jsx("div",{style:{fontSize:15,lineHeight:1.8,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:ms(D.content)})]},`${i.conversationId}:${D.id}`)):e.jsx("p",{style:{margin:"32px 0",color:"var(--text-muted)",fontSize:15,lineHeight:1.8},children:"连接后会显示当前网页对话。可以在下方输入消息,也可以在 Chrome 中继续聊天。"}):e.jsxs("div",{style:{display:"grid",gap:14,paddingTop:36,textAlign:"center",justifyItems:"center"},children:[e.jsx("strong",{style:{fontSize:18},children:c.paused?`${n} 已暂停`:`连接 ${n}`}),e.jsx("span",{style:{fontSize:14,color:"var(--text-secondary)",lineHeight:1.7},children:c.paused?"取消 Chrome 的调试提示也会暂停连接,无需重新登录。":"登录态保留在 Chrome,回复会以文字显示在这里。"}),c.paused&&e.jsx("button",{className:"ui-icon-button ui-icon-button--auto",disabled:g,style:{padding:"8px 12px",color:"var(--accent)"},onClick:async()=>{y(!0),h("");try{d(await s.hubChromeResume())}catch(D){h(D instanceof Error?D.message:"恢复连接失败,请检查 Chrome 扩展")}finally{y(!1)}},children:g?"正在恢复…":"恢复全部 Chrome 连接"}),e.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{padding:"8px 12px"},onClick:()=>{s.hubOpenChrome(t).catch(()=>h("无法打开 Chrome,请检查是否已安装"))},children:"登录 / 打开原网页"}),e.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{padding:"8px 12px"},onClick:r,children:"连接设置"})]})}),!C&&e.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{alignSelf:"center",padding:"7px 12px",margin:8},onClick:()=>E(!0),children:"回到最新回复 ↓"}),(u||j)&&e.jsx("div",{role:u?"alert":"status",title:u||"暂未收到网页更新,请检查 Chrome 标签页或扩展连接;不代表 AI 已停止回答",style:{padding:"6px 16px",fontSize:12,lineHeight:1.6,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:u?"var(--danger)":"var(--text-muted)"},children:u||"同步暂未更新"})]})}function rf({onClose:t}){const n=window.agentApi,[r,s]=l.useState(""),[i,a]=l.useState(!1),[c,d]=l.useState(""),[u,h]=l.useState(!1);l.useEffect(()=>{let y=!0;n.hubChromeStatus().then(k=>{y&&h(k.connected&&k.compatible!==!1)}).catch(()=>{y&&s("暂时无法检测插件连接,请稍后重试")});const m=n.onHubChromeEvent(k=>{k.type==="chrome-status"&&h(k.status.connected&&k.status.compatible!==!1)});return()=>{y=!1,m()}},[n]);const g=async()=>{a(!0),s("");try{const y=await n.hubChromeInstallExtension();d(y.path),s(y.browserOpened?"已打开 Chrome 扩展管理页,插件目录路径已复制。":"未能打开 Chrome。请先安装或打开 Google Chrome,再进入 chrome://extensions;插件目录路径已复制。")}catch{s("未能准备插件,请确认桌面端已启动,稍后重试。")}finally{a(!1)}};return e.jsxs("div",{"data-aihub-chrome-setup":"",style:{flexShrink:0,padding:"12px 18px",background:"var(--bg-elevated)",borderBottom:"1px solid var(--border-subtle)",fontSize:12},children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",marginBottom:8},children:[e.jsx("strong",{children:"连接日常 Google Chrome"}),e.jsx("span",{role:"status",children:u?"扩展已连接":"等待扩展连接"}),e.jsx("button",{className:"ui-icon-button ui-icon-button--auto",style:{marginLeft:"auto"},onClick:t,children:"收起"})]}),e.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.7},children:"插件已随桌面端附带,无需另行下载。首次加载需要在 Chrome 中确认;加载后自动连接,连接成功后此引导会自动收起。已安装时刷新 AI Hub 扩展即可更新。"}),e.jsxs("ol",{style:{margin:0,paddingLeft:20,lineHeight:1.9},children:[e.jsx("li",{children:"点击「安装浏览器插件」,在打开的 Chrome 扩展管理页开启「开发者模式」。"}),e.jsx("li",{children:"选择「加载已解压的扩展程序」,选中 ai-hub-chrome-extension 文件夹。macOS 文件选择窗口可按 ⌘⇧G,粘贴已复制的路径并打开。"}),e.jsx("li",{children:"在同一个 Chrome 中完成网站登录,即可回到 AI Hub 查看回复并同步发送。取消 Chrome 顶部的调试提示会暂停连接;在 AI Hub 点击「恢复全部 Chrome 连接」即可继续。"})]}),e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center",marginTop:8},children:[e.jsx("button",{type:"button",disabled:i,className:"ui-icon-button ui-icon-button--auto",onClick:()=>void g(),style:{padding:"5px 10px"},children:i?"正在打开…":"安装浏览器插件"}),e.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",onClick:()=>{n.hubChromeRevealExtension().catch(()=>s("未能打开扩展目录"))},style:{padding:"5px 10px"},children:"打开插件文件夹"}),r&&e.jsx("span",{role:"status",children:r})]}),c&&e.jsxs("p",{style:{margin:"8px 0 0",overflowWrap:"anywhere",userSelect:"text"},children:["插件目录:",c]})]})}const sf=["chatgpt","gemini","grok"];function Ws(t){return sf.includes(t)}const of=52,Ei=30,af=4;function lf(t,n){return t.includes(n)?t.length>1?t.filter(r=>r!==n):t:t.length<af?[...t,n]:t}function cf(t){return(t.trim()[0]||"?").toUpperCase()}function _a(t){try{const n=new URL(t);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}function df({onExit:t}){const n=typeof window<"u"?window.agentApi:void 0,r=typeof(n==null?void 0:n.hubGetConfig)=="function",[s,i]=l.useState([]),[a,c]=l.useState([]),[d,u]=l.useState([]),[h,g]=l.useState(null),[y,m]=l.useState({}),[k,C]=l.useState({}),[E,A]=l.useState({}),[S,j]=l.useState(""),[v,D]=l.useState([]),[V,R]=l.useState(""),[T,P]=l.useState(!1),I=l.useRef(null),N=l.useRef(null),[G,ie]=l.useState(!1),[Ae,ze]=l.useState([]),[ce,J]=l.useState(!1),[je,Ke]=l.useState(!1),[Xe,ct]=l.useState(""),[nt,Ht]=l.useState(""),[Ze,_]=l.useState(!1),[ne,Ie]=l.useState([]);l.useEffect(()=>{if(!(n!=null&&n.hubChromeStatus))return;let W=!1,O=!1;const K=ae=>{if(W)return;const Re=ae.connected&&ae.compatible!==!1;Ie(Re?ae.tabs.map(ht=>ht.siteId):[]),Re?_(!1):O||_(!0),O=!0};n.hubChromeStatus().then(K).catch(()=>{!W&&!O&&(O=!0,_(!0))});const X=n.onHubChromeEvent(ae=>{ae.type==="chrome-status"&&K(ae.status)});return()=>{W=!0,X()}},[n]);const be=l.useRef(null),Ce=l.useRef(null);l.useRef(0),l.useLayoutEffect(()=>{const W=N.current;W&&(W.style.height="32px",S&&(W.style.height=`${Math.max(32,Math.min(W.scrollHeight,120))}px`))},[S,a.length]);const _e=async W=>{if(!(G||T)){P(!0),R("");try{if(W.length+v.length>Ps)throw new Error(`最多添加 ${Ps} 张图片`);const O=await Promise.all(W.map(async K=>{if(!/^image\/(png|jpeg|webp)$/.test(K.type))throw new Error("请选择 PNG、JPEG 或 WebP 图片");if(K.size*4/3+32>Xp)throw new Error("单张图片不能超过约 3 MB");return new Promise((X,ae)=>{const Re=new FileReader;Re.onload=()=>X(String(Re.result)),Re.onerror=()=>ae(new Error("图片读取失败,请重试")),Re.readAsDataURL(K)})}));D(K=>[...K,...O].slice(0,Ps))}catch(O){R(O instanceof Error?O.message:"图片读取失败")}finally{P(!1)}}},ke=l.useMemo(()=>h?tf(h,a.length,d):[],[h,a.length,d]);l.useEffect(()=>{if(!r||ke.length===0)return;const W=a.map((O,K)=>{const X=ke[K];return{siteId:O,x:X.x,y:X.y+Ei,width:X.width,height:Math.max(X.height-Ei,0)}});n==null||n.hubSetBounds(W)},[r,n,ke,a]),l.useEffect(()=>{if(r)for(const W of a)n==null||n.hubOpenSite(W)},[r,n,a]),l.useEffect(()=>{if(!r)return;const W=be.current;if(!W)return;const O=()=>{const ae=W.getBoundingClientRect();g(Re=>Re&&Math.abs(Re.x-ae.x)<.5&&Math.abs(Re.y-ae.y)<.5&&Math.abs(Re.width-ae.width)<.5&&Math.abs(Re.height-ae.height)<.5?Re:{x:ae.x,y:ae.y,width:ae.width,height:ae.height})},K={current:0},X=new ResizeObserver(()=>{cancelAnimationFrame(K.current),K.current=requestAnimationFrame(O)});return X.observe(W),O(),()=>{X.disconnect(),cancelAnimationFrame(K.current)}},[r,je]),l.useEffect(()=>{if(!ce)return;const W=K=>{var X;(X=Ce.current)!=null&&X.contains(K.target)||J(!1)},O=()=>J(!1);return document.addEventListener("pointerdown",W),window.addEventListener("blur",O),()=>{document.removeEventListener("pointerdown",W),window.removeEventListener("blur",O)}},[ce]),l.useEffect(()=>{if(!r||!n)return;let W=!1;n.hubGetConfig().then(K=>{W||(i(K.sites),c(X=>X.length>0?X:K.sites.slice(0,1).map(ae=>ae.id)))});const O=n.onHubEvent(K=>{K.type==="load-failed"?(m(X=>({...X,[K.siteId]:K.errorCode??-1})),C(X=>({...X,[K.siteId]:!1}))):K.type==="loaded"?(m(X=>{if(!(K.siteId in X))return X;const ae={...X};return delete ae[K.siteId],ae}),C(X=>({...X,[K.siteId]:!1}))):K.type==="loading"?(C(X=>({...X,[K.siteId]:!0})),A(X=>{if(!(K.siteId in X))return X;const ae={...X};return delete ae[K.siteId],ae})):K.type==="google-auth-external"&&A(X=>({...X,[K.siteId]:!0}))});return()=>{W=!0,O(),n.hubHideAll()}},[r,n]),l.useEffect(()=>{const W=Math.max(a.length,0);u(O=>O.length===W?O:Array.from({length:W},()=>W>0?1/W:0))},[a.length]);const Je=l.useCallback(W=>{c(O=>lf(O,W))},[]),jt=l.useCallback(W=>{m(O=>{const K={...O};return delete K[W],K}),n==null||n.hubReload(W),n==null||n.hubOpenSite(W)},[n]),Tt=l.useCallback(W=>{a.length<=1||(n==null||n.hubCloseSite(W),c(O=>O.filter(K=>K!==W)))},[n,a.length]),Be=l.useCallback(async()=>{const W=S.trim();if(!(!W&&v.length===0||!n||G||T||a.length===0)){ie(!0);try{const O=await n.hubBroadcast(W,a,v),K=O.map(X=>({...X,at:Date.now()}));ze(K),O.length>0&&O.every(X=>X.ok)&&(j(""),D([]),R("")),setTimeout(()=>{ze(X=>X.filter(ae=>!ae.ok||Date.now()-ae.at<8e3))},8200)}catch(O){R(O instanceof Error?O.message:"发送失败,请重试")}finally{ie(!1)}}},[n,S,v,T,G,a]),Me=l.useCallback(async()=>{if(!n||!_a(nt))return;const W=nt.trim(),O=Xe.trim()||new URL(W).hostname,K={id:`custom-${Math.random().toString(36).slice(2,10)}`,name:O,url:W,adapter:"generic"},X=await n.hubSetConfig({version:1,sites:[...s,K]});i(X.sites),ct(""),Ht(""),Ke(!1)},[n,Xe,nt,s]),Ge=l.useCallback(async W=>{if(!n||s.length<=1)return;n.hubCloseSite(W);const O=await n.hubSetConfig({version:1,sites:s.filter(K=>K.id!==W)});i(O.sites),c(K=>{const X=K.filter(ae=>ae!==W);return X.length>0?X:O.sites.slice(0,1).map(ae=>ae.id)})},[n,s]),Qe=l.useCallback((W,O)=>{O.preventDefault();const K=ke.length,X=K>1?8:0,ae=((h==null?void 0:h.width)??0)-X*(K-1);if(ae<=0)return;const Re=O.clientX,ht=[...d],vn=ke[W].width,gt=ht[W]+ht[W+1],Ye=$=>{const Z=$.clientX-Re,xe=80,kt=gt*ae,xt=Math.min(Math.max(vn+Z,xe),kt-xe),Bt=[...ht];Bt[W]=xt/ae,Bt[W+1]=(kt-xt)/ae,u(Bt)},dt=()=>{window.removeEventListener("pointermove",Ye),window.removeEventListener("pointerup",dt)};window.addEventListener("pointermove",Ye),window.addEventListener("pointerup",dt)},[d,ke,h]);return r?e.jsxs("div",{style:{position:"absolute",inset:0,zIndex:30,display:"flex",flexDirection:"column",background:"var(--bg-workspace)"},children:[e.jsxs("div",{className:"aihub-topbar",style:{height:of,display:"flex",alignItems:"center",gap:10,padding:"0 14px",borderBottom:"1px solid var(--border-subtle)",WebkitAppRegion:"drag"},children:[e.jsx("button",{type:"button",onClick:t,title:"返回对话","aria-label":"返回对话",className:"ui-icon-button ui-icon-button--auto",style:{WebkitAppRegion:"no-drag",padding:"5px 10px",whiteSpace:"nowrap"},children:"← 返回"}),e.jsx("strong",{style:{fontSize:14,color:"var(--text-secondary)"},children:"AI Hub"}),e.jsx("button",{type:"button",className:"ui-icon-button ui-icon-button--auto",onClick:()=>_(W=>!W),style:{WebkitAppRegion:"no-drag",marginLeft:"auto",padding:"5px 10px"},children:"连接 Chrome"})]}),Ze&&e.jsx(rf,{onClose:()=>_(!1)}),e.jsxs("div",{ref:be,style:{flex:1,position:"relative",overflow:"hidden",minHeight:0},children:[ke.map((W,O)=>{const K=a[O],X=s.find(Re=>Re.id===K),ae=K in y;return e.jsxs("div",{"data-aihub-pane":K,style:{position:"absolute",left:W.x-((h==null?void 0:h.x)??0),top:W.y-((h==null?void 0:h.y)??0),width:W.width,height:W.height,display:"flex",flexDirection:"column",borderRight:O<ke.length-1?"1px solid var(--border-subtle)":void 0},children:[e.jsxs("div",{style:{height:Ei,display:"flex",alignItems:"center",gap:6,padding:"0 8px",borderBottom:"1px solid var(--border-subtle)",fontSize:12,color:"var(--text-secondary)"},children:[e.jsx("span",{"aria-hidden":"true",style:{width:8,height:8,borderRadius:"50%",background:Ws(K)?ne.includes(K)?"var(--success)":"var(--text-muted)":ae?"#f7768e":k[K]?"var(--accent-glow)":"#9ece6a",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:40,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(X==null?void 0:X.name)??K}),E[K]&&e.jsx("span",{title:"Google 登录已在系统浏览器打开,登录状态不会同步回 AI Hub。如需继续内嵌使用,请选择邮箱登录。","aria-label":"Google 登录受限",style:{flexShrink:0,fontSize:10,padding:"1px 6px",borderRadius:999,color:"#f7768e",border:"1px solid currentColor",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:180},children:"Google 登录已转至浏览器,内嵌请用邮箱"}),Ws(K)&&e.jsx("button",{type:"button","aria-label":`打开 ${(X==null?void 0:X.name)??K} Chrome 页面`,title:"在日常 Chrome 中登录或查看页面",className:"ui-icon-button ui-icon-button--auto",onClick:()=>{n.hubOpenChrome(K).catch(()=>_(!0))},style:{padding:"2px 6px",fontSize:11},children:"Chrome ↗"}),e.jsx("button",{type:"button",title:"刷新","aria-label":`刷新 ${(X==null?void 0:X.name)??K}`,onClick:()=>jt(K),className:"ui-icon-button",style:{padding:2},children:"⟳"}),a.length>1&&e.jsx("button",{type:"button",title:"关闭页面","aria-label":`关闭 ${(X==null?void 0:X.name)??K}`,onClick:()=>Tt(K),className:"ui-icon-button",style:{padding:2},children:"×"})]}),e.jsxs("div",{style:{flex:1,position:"relative",background:"var(--bg-surface)"},children:[Ws(K)&&e.jsx(nf,{siteId:K,name:(X==null?void 0:X.name)??K,onSetup:()=>_(!0)}),!Ws(K)&&ae&&e.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:e.jsxs("div",{style:{textAlign:"center",display:"grid",gap:10,color:"var(--text-muted)",fontSize:12},children:[e.jsxs("span",{children:["页面加载失败(",y[K],")"]}),e.jsx("button",{type:"button",onClick:()=>jt(K),className:"ui-icon-button ui-icon-button--auto",style:{justifySelf:"center",padding:"5px 12px"},children:"重试"})]})})]}),O<ke.length-1&&e.jsx("div",{"data-aihub-divider":O,onPointerDown:Re=>Qe(O,Re),title:"拖动调整宽度",style:{position:"absolute",top:0,bottom:0,right:-5,width:10,cursor:"col-resize",zIndex:5}})]},K)}),ke.length===0&&e.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:"var(--text-muted)",fontSize:13},children:"从输入框选择一个 AI 站点"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",padding:"8px 12px 10px",display:"flex",flexDirection:"column",gap:8,background:"var(--bg-surface)"},children:[e.jsxs("div",{ref:Ce,style:{position:"relative",display:"flex",flexDirection:"column",gap:8},children:[ce&&e.jsxs("div",{role:"listbox","aria-label":"选择要发送的 AI 站点","data-aihub-site-picker":"",style:{width:"min(320px, 100%)",maxHeight:280,overflowY:"auto",padding:4,border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-workspace)",boxShadow:"0 -8px 24px rgba(0, 0, 0, 0.12)"},children:[s.map(W=>{const O=a.includes(W.id),K=W.id.startsWith("custom-");return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsxs("button",{type:"button",role:"option","aria-selected":O,onClick:()=>Je(W.id),style:{minWidth:0,flex:1,display:"flex",alignItems:"center",gap:8,padding:"8px 9px",border:0,borderRadius:6,background:O?"var(--bg-glass)":"transparent",color:"var(--text-secondary)",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{"aria-hidden":"true",style:{width:20,height:20,display:"grid",placeItems:"center",borderRadius:"50%",border:`1px solid ${O?"var(--accent)":"var(--border-default)"}`,background:O?"var(--accent)":"transparent",color:O?"var(--bg-workspace)":"transparent",flexShrink:0},children:e.jsx(Ur,{size:13,strokeWidth:2.5})}),e.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"grid",placeItems:"center",borderRadius:6,background:"var(--accent-glow)",fontSize:12,fontWeight:600,flexShrink:0},children:cf(W.name)}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:13},children:W.name})]}),K&&e.jsx("button",{type:"button",title:`删除站点 ${W.name}`,"aria-label":`删除站点 ${W.name}`,onClick:()=>void Ge(W.id),className:"ui-icon-button",style:{width:30,height:30,padding:0,flexShrink:0},children:e.jsx(bs,{size:14,"aria-hidden":"true"})})]},W.id)}),e.jsx("div",{style:{height:1,margin:"4px 6px",background:"var(--border-subtle)"}}),je?e.jsxs("div",{style:{display:"grid",gap:6,padding:6},children:[e.jsx("input",{value:Xe,onChange:W=>ct(W.target.value),placeholder:"名称(可选)",style:{minWidth:0,padding:"7px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-secondary)",fontSize:12}}),e.jsx("input",{value:nt,onChange:W=>Ht(W.target.value),placeholder:"https://...",style:{minWidth:0,padding:"7px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-secondary)",fontSize:12}}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>void Me(),disabled:!_a(nt),className:"ui-icon-button ui-icon-button--auto",style:{padding:"5px 10px",fontSize:12},children:"添加"}),e.jsx("button",{type:"button",onClick:()=>Ke(!1),className:"ui-icon-button ui-icon-button--auto",style:{padding:"5px 10px",fontSize:12},children:"取消"})]})]}):e.jsxs("button",{type:"button",onClick:()=>Ke(!0),className:"ui-icon-button ui-icon-button--auto",style:{width:"100%",justifyContent:"flex-start",gap:7,padding:"7px 9px",fontSize:12},children:[e.jsx(Fi,{size:14,"aria-hidden":"true"}),"添加站点"]})]}),e.jsxs("div",{"data-aihub-composer":"",style:{display:"flex",alignItems:"center",gap:8,minHeight:48,padding:"6px 8px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-workspace)"},children:[e.jsxs("button",{type:"button",onClick:()=>J(W=>!W),"aria-haspopup":"listbox","aria-expanded":ce,"aria-label":"选择 AI 站点",title:"选择 AI 站点",className:"ui-icon-button ui-icon-button--auto",style:{height:34,gap:5,padding:"0 10px",fontSize:12,whiteSpace:"nowrap",flexShrink:0},children:[a.length," 个 AI",e.jsx(Dc,{size:14,"aria-hidden":"true",style:{transform:ce?"rotate(180deg)":void 0}})]}),e.jsx("input",{ref:I,type:"file",accept:"image/png,image/jpeg,image/webp",multiple:!0,hidden:!0,onChange:W=>{const O=Array.from(W.target.files??[]);W.target.value="",_e(O)}}),e.jsx("button",{type:"button","aria-label":"添加图片附件",title:"添加图片附件(也可粘贴截图)",disabled:G||T||v.length>=Ps,onClick:()=>{var W;return(W=I.current)==null?void 0:W.click()},className:"ui-icon-button",style:{width:34,height:34,padding:0,flexShrink:0},children:e.jsx(pd,{size:17,"aria-hidden":"true"})}),e.jsx("textarea",{ref:N,"aria-label":"发送给选中的 AI",disabled:G,value:S,onChange:W=>j(W.target.value),onPaste:W=>{const O=Array.from(W.clipboardData.files);O.length!==0&&(W.preventDefault(),_e(O))},onKeyDown:W=>{W.nativeEvent.isComposing||W.nativeEvent.keyCode===229||(W.key==="Enter"&&(!W.shiftKey||W.metaKey||W.ctrlKey)?(W.preventDefault(),Be()):W.key==="Escape"&&ce&&(W.preventDefault(),J(!1)))},rows:1,placeholder:`一次输入,发到 ${a.length} 个选中的 AI(Enter 发送,Shift+Enter 换行)`,style:{flex:1,minWidth:0,height:32,minHeight:32,maxHeight:120,boxSizing:"border-box",resize:"none",padding:"4px 2px",border:0,outline:"none",boxShadow:"none",background:"transparent",color:"var(--text-primary)",fontSize:13,lineHeight:1.5,textAlign:S?"left":"center"}}),e.jsx("button",{type:"button",onClick:()=>void Be(),disabled:!S.trim()&&v.length===0||G||T||a.length===0,title:"同步发送(Enter)","aria-label":"同步发送",className:"ui-icon-button",style:{width:36,height:36,padding:0,borderRadius:"50%",background:(S.trim()||v.length>0)&&!G?"var(--accent)":"var(--bg-glass)",color:(S.trim()||v.length>0)&&!G?"var(--bg-workspace)":"var(--text-muted)",flexShrink:0},children:e.jsx(gd,{size:16,"aria-hidden":"true"})})]})]}),v.length>0&&e.jsx("div",{"aria-label":"待发送图片",style:{display:"flex",gap:8,flexWrap:"wrap"},children:v.map((W,O)=>e.jsxs("div",{style:{position:"relative",width:56,height:56},children:[e.jsx("img",{src:W,alt:`附件 ${O+1}`,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:6}}),e.jsx("button",{type:"button","aria-label":`移除附件 ${O+1}`,disabled:G,onClick:()=>D(K=>K.filter((X,ae)=>ae!==O)),className:"ui-icon-button",style:{position:"absolute",top:0,right:0,padding:2,background:"var(--bg-workspace)"},children:e.jsx(Kr,{size:12})})]},`${O}-${W.length}`))}),V&&e.jsx("div",{role:"alert",style:{fontSize:12,color:"var(--text-secondary)",textAlign:"center"},children:V}),Ae.length>0&&e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center",minHeight:18},children:Ae.map(W=>{var O;return e.jsx("span",{role:"status",style:{fontSize:11,padding:"3px 10px",borderRadius:999,color:W.ok?"#9ece6a":"#f7768e",background:"var(--bg-glass)",whiteSpace:"normal",overflowWrap:"anywhere"},children:(((O=s.find(K=>K.id===W.siteId))==null?void 0:O.name)??W.siteId)+(W.ok?" ✓":` ✕ ${W.reason??"失败"}`)},W.siteId)})})]})]}):e.jsx("div",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center",background:"var(--bg-workspace)",zIndex:30},children:e.jsxs("div",{style:{textAlign:"center",color:"var(--text-muted)",fontSize:13,display:"grid",gap:12},children:[e.jsx("span",{children:"AI Hub 仅在桌面端可用"}),e.jsx("button",{type:"button",onClick:t,className:"ui-icon-button ui-icon-button--auto",style:{justifySelf:"center",padding:"6px 14px"},children:"返回"})]})})}const $l=new Set(["downloading","installing","reconnecting"]),uf=new Set(["checking",...$l]),pf=6e3,ff=24e3;function hf(){const[t,n]=l.useState(null),[r,s]=l.useState(()=>sessionStorage.getItem("agentroam.dismissed-update"));if(l.useEffect(()=>{var C;let g=!0;const y=window.agentApi,m=((C=y.onUpdateStatus)==null?void 0:C.call(y,E=>{g&&n(E)}))??(()=>{});y.getUpdateStatus().then(E=>{g&&n(E)}).catch(()=>{});const k=window.setTimeout(()=>{y.checkForUpdate().then(E=>{g&&n(E)}).catch(()=>{})},pf+Math.floor(Math.random()*(ff+1)));return()=>{g=!1,window.clearTimeout(k),m()}},[]),l.useEffect(()=>{if(!t||!uf.has(t.phase))return;const g=window.setInterval(()=>{window.agentApi.getUpdateStatus().then(n).catch(()=>{})},1500);return()=>window.clearInterval(g)},[t==null?void 0:t.phase]),!t||["idle","checking","up-to-date","unavailable"].includes(t.phase)||t.phase==="available"&&t.targetVersion===r)return null;const i=$l.has(t.phase),a=t.phase==="failed",c=t.phase==="complete",d=i?t.phase==="downloading"?`正在下载${t.progress!==void 0?` ${t.progress}%`:""}`:t.phase==="installing"?"正在安装":"正在重连":a?"更新失败,重试":c?t.message??"更新已就绪":`发现 AgentRoam ${t.targetVersion}`,u=async()=>{try{n(await window.agentApi.installUpdate())}catch(g){n({...t,phase:"failed",message:g instanceof Error?g.message:"更新失败"})}},h=()=>{t.targetVersion&&(sessionStorage.setItem("agentroam.dismissed-update",t.targetVersion),s(t.targetVersion))};return e.jsxs("aside",{className:`update-notice${a?" update-notice--failed":""}`,"aria-live":"polite",children:[e.jsxs("div",{className:"update-notice__content",children:[e.jsx("strong",{children:d}),!i&&!c&&e.jsx("span",{children:"点击后才会下载安装文件"}),a&&t.message&&e.jsx("span",{children:t.message})]}),!i&&!c&&e.jsxs("button",{className:"update-notice__action",type:"button",onClick:()=>void u(),title:a?"重试更新":"下载更新",children:[a?e.jsx(Xi,{size:16}):e.jsx(tl,{size:16}),e.jsx("span",{children:a?"重试":"更新"})]}),!i&&e.jsx("button",{className:"update-notice__close",type:"button",onClick:h,title:"关闭更新提醒","aria-label":"关闭更新提醒",children:e.jsx(Kr,{size:16})})]})}function gf(){const[t,n]=l.useState(null);l.useEffect(()=>{const a=window.agentApi;if(!(a!=null&&a.desktopLiveGetStatus)||!(a!=null&&a.onDesktopLiveStatus))return;let c=!0;a.desktopLiveGetStatus().then(u=>{c&&n(u)}).catch(()=>{});const d=a.onDesktopLiveStatus(u=>n(u));return()=>{c=!1,d()}},[]);const r=t==null?void 0:t.controlState;if(!((t==null?void 0:t.enabled)&&r!==null&&r!==void 0&&r!=="agent-controlled"))return null;const i=r==="return-requested"||r==="resyncing";return e.jsxs("div",{className:"desktop-live-control-banner",role:"status",style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 10px)",left:"50%",transform:"translateX(-50%)",zIndex:1300,display:"flex",alignItems:"center",gap:8,padding:"7px 14px",borderRadius:999,border:"1px solid rgba(251,191,36,0.45)",background:"rgba(69,49,10,0.92)",color:"#fcd34d",fontSize:13,fontWeight:600,backdropFilter:"blur(8px)",pointerEvents:"none"},children:[e.jsx("span",{"aria-hidden":"true",children:"●"}),i?"正在结束远程控制":"正在被远程控制"]})}function Ti({status:t,isRunning:n,needsInput:r}){return t==="failed"||t==="error"?"error":n?r?"needs-input":"running":"completed"}const Ni={"needs-input":"需要输入",running:"运行中",completed:"执行完成",error:"执行错误"};function oo(t,n){return t.map((r,s)=>({session:r,index:s})).sort((r,s)=>n(r.session,s.session)||r.index-s.index).map(({session:r})=>r)}function Us(t){return oo(t,(n,r)=>r.created.localeCompare(n.created))}function Pa(t,n){return oo(Us(t),(r,s)=>Number(n(s))-Number(n(r)))}function xf(t,n){return oo(t,(r,s)=>Number(n(s))-Number(n(r)))}const Wa={projectId:null,sessionId:null};function Gi(t){return typeof t=="string"&&t.trim()?t.trim():null}function Da(t){return{projectId:Gi(t),sessionId:null}}function zi(t,n){return{projectId:Gi(t),sessionId:Gi(n)}}function mf(t){return t.agentType==="customer-agent"?`确定永久删除会话“${t.title}”吗?此操作不可恢复。`:t.agentType==="codex"?`确定归档 Codex 会话“${t.title}”并从 AgentRoam 中移除吗?可在 Codex 的已归档会话中恢复。`:`确定从 AgentRoam 中移除会话“${t.title}”吗?原生客户端中的历史记录会保留。`}function bf(t,n){const r=new Set(n);return{...t,selectedSessionId:t.selectedSessionId&&r.has(t.selectedSessionId)?null:t.selectedSessionId,sessions:Object.fromEntries(Object.entries(t.sessions).map(([s,i])=>[s,{...i,data:i.data.filter(a=>!r.has(a.id))}]))}}function yf(t,n){const r=new Set(n);let s=!1;const i=Object.fromEntries(Object.entries(t).map(([a,c])=>{const d=c.filter(u=>!r.has(u.id));return d.length!==c.length&&(s=!0),[a,d.length===c.length?c:d]}));return s?i:t}function vf(t,n,r,s){const i=[s,...(n[s]??[]).map(d=>d.id)],a=new Set(i),c=Object.fromEntries(Object.entries(n).flatMap(([d,u])=>{if(a.has(d))return[];const h=u.filter(g=>!a.has(g.id));return[[d,h.length===u.length?u:h]]}));return{sessionsByProject:yf(t,i),childSessionsByParent:c,otherLocalSessions:r.filter(d=>!a.has(d.id)),removedIds:i}}const wf=[{value:"anthropic",label:"Anthropic"},{value:"openai",label:"OpenAI"},{value:"deepseek",label:"DeepSeek"}],Ba={anthropic:"claude-sonnet-4-6",openai:"gpt-4o",deepseek:"deepseek-chat"};function $a(){return{name:"",provider:"anthropic",modelId:"claude-sonnet-4-6",apiKey:"",baseUrl:""}}function jf(){const{maxIterations:t,contextWindow:n,isConfigured:r,profiles:s,activeProfileId:i,setField:a,loadFromSystem:c,saveToSystem:d,addProfile:u,updateProfile:h,deleteProfile:g,switchActiveProfile:y}=Ks(),[m,k]=l.useState(null),[C,E]=l.useState("success"),[A,S]=l.useState(String(Math.round((n??100)*1e3)));l.useEffect(()=>{S(String(Math.round((n??100)*1e3)))},[n]);const[j,v]=l.useState(null),[D,V]=l.useState(!1),[R,T]=l.useState($a());l.useEffect(()=>{c()},[]);const P=()=>{V(!0),v(null),T($a())},I=J=>{V(!1),v(J.id),T({name:J.name,provider:J.provider,modelId:J.modelId,apiKey:["managed","__agentroam_stored_secret__"].includes(J.apiKey)?"":J.apiKey,baseUrl:J.baseUrl})},N=()=>{v(null),V(!1)},G=async()=>{if(!R.name.trim()||!R.apiKey.trim()||!R.modelId.trim()){k("名称、API Key 和模型 ID 为必填项"),E("error");return}D?u(R):j&&h(j,R),v(null),V(!1),k(null),setTimeout(()=>d(),0)},ie=async J=>{g(J),setTimeout(()=>d(),0)},Ae=async J=>{await y(J),k("已切换模型"),E("success"),setTimeout(()=>k(null),1500)},ze=async()=>{k(null);const J=Number(A);if(!Number.isInteger(J)||J<1024||J>2e6){k("上下文窗口请输入 1024 到 2000000 之间的整数 tokens,例如 8192。"),E("error");return}a("contextWindow",J/1e3);try{await d(),k("设置保存成功"),E("success")}catch(je){k(je instanceof Error?je.message:"保存失败"),E("error")}},ce=D||j!==null;return e.jsxs("div",{style:{padding:"40px 48px",maxWidth:640,animation:"fadeInUp 0.4s var(--ease-out)"},children:[e.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,marginBottom:8,letterSpacing:"-0.02em"},children:"设置"}),e.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginBottom:36},children:"管理模型提供商和运行参数。工作目录在项目设置中配置。"}),e.jsxs("section",{style:{marginBottom:40},children:[e.jsxs("div",{className:"settings-head-row",style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[e.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",margin:0},children:"模型提供商"}),e.jsx("button",{onClick:P,style:Sf,children:"+ 添加"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.length===0&&!ce&&e.jsx("div",{style:{padding:"20px 16px",borderRadius:"var(--radius-sm)",border:"1px dashed var(--border-subtle)",textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"暂无配置,点击「+ 添加」创建第一个模型提供商"}),s.map(J=>{const je=J.id===i,Ke=J.id===j;return e.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:`1px solid ${je?"var(--accent)":"var(--border-default)"}`,background:je?"var(--accent-dim)":"var(--bg-surface)",overflow:"hidden",transition:"border-color 0.2s"},children:[e.jsxs("div",{className:"profile-row",style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px"},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",padding:"2px 7px",borderRadius:4,background:je?"var(--accent)":"var(--bg-deep)",color:je?"#fff":"var(--text-muted)",flexShrink:0},children:J.provider}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:J.name||J.modelId}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:1},children:[J.modelId," ",J.baseUrl?`· ${J.baseUrl}`:""]})]}),je&&e.jsx("span",{style:{fontSize:11,color:"var(--accent)",fontWeight:600,flexShrink:0},children:"● 使用中"}),e.jsxs("div",{className:"profile-row-actions",style:{display:"flex",gap:6,flexShrink:0},children:[!je&&e.jsx("button",{onClick:()=>Ae(J.id),style:Li,children:"切换"}),e.jsx("button",{onClick:()=>Ke?N():I(J),style:Li,children:Ke?"收起":"编辑"}),e.jsx("button",{onClick:()=>ie(J.id),style:{...Li,color:"var(--danger)",borderColor:"rgba(244,63,94,0.25)"},children:"删除"})]})]}),Ke&&e.jsx(Oa,{draft:R,setDraft:T,onSave:G,onCancel:N})]},J.id)}),D&&e.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:"1px solid var(--accent)",background:"var(--bg-surface)"},children:[e.jsx("div",{style:{padding:"10px 14px 0",fontSize:13,fontWeight:600,color:"var(--accent)"},children:"新建提供商"}),e.jsx(Oa,{draft:R,setDraft:T,onSave:G,onCancel:N})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},children:"常规"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx(wr,{label:"最大迭代次数",children:e.jsx("input",{type:"number",value:t,onChange:J=>a("maxIterations",parseInt(J.target.value)||10),min:1,max:50,style:jr})}),e.jsxs(wr,{label:"上下文窗口(tokens,输入与输出合计)",children:[e.jsx("input",{type:"number",value:A,onChange:J=>S(J.target.value),min:1024,max:2e6,step:1,style:jr}),e.jsx("div",{style:{fontSize:12,opacity:.65},children:"8K 模型填 8192;不能超过模型服务实际启动的上下文大小。"})]})]})]}),e.jsxs("div",{style:{marginTop:28,display:"flex",gap:14,alignItems:"center"},children:[e.jsx("button",{onClick:ze,style:Ol,children:"保存"}),e.jsx("span",{style:{padding:"7px 14px",borderRadius:"var(--radius-sm)",fontSize:12,fontWeight:500,background:r?"rgba(52,211,153,0.1)":"rgba(255,255,255,0.04)",color:r?"var(--success)":"var(--text-muted)",border:`1px solid ${r?"rgba(52,211,153,0.2)":"var(--border-subtle)"}`},children:r?"● 已连接":"○ 未配置"})]}),m&&e.jsx("div",{style:{marginTop:12,padding:"10px 12px",borderRadius:"var(--radius-sm)",border:C==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:C==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:C==="success"?"var(--success)":"var(--danger)",fontSize:13},children:m})]})}function Oa({draft:t,setDraft:n,onSave:r,onCancel:s}){const i=(a,c)=>n(d=>{const u={...d,[a]:c};return a==="provider"&&!d.modelId&&(u.modelId=Ba[c]??""),u});return e.jsxs("div",{style:{padding:"12px 14px 14px",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsx(wr,{label:"名称",children:e.jsx("input",{value:t.name,onChange:a=>i("name",a.target.value),placeholder:"我的 Claude",style:jr})}),e.jsx(wr,{label:"提供商",children:e.jsx("select",{value:t.provider,onChange:a=>{i("provider",a.target.value),i("modelId",Ba[a.target.value]??"")},style:jr,children:wf.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})})]}),e.jsx(wr,{label:"模型 ID",children:e.jsx("input",{value:t.modelId,onChange:a=>i("modelId",a.target.value),placeholder:"claude-sonnet-4-6",style:jr})}),e.jsx(wr,{label:"API 密钥",children:e.jsx("input",{type:"password",value:t.apiKey,onChange:a=>i("apiKey",a.target.value),placeholder:"sk-...",style:jr})}),e.jsx(wr,{label:"接口地址(可选)",children:e.jsx("input",{value:t.baseUrl,onChange:a=>i("baseUrl",a.target.value),placeholder:"https://api.anthropic.com",style:jr})}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:2},children:[e.jsx("button",{onClick:r,style:Ol,children:"保存"}),e.jsx("button",{onClick:s,style:kf,children:"取消"})]})]})}function wr({label:t,children:n}){return e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--text-secondary)",marginBottom:6,fontWeight:500,textTransform:"uppercase",letterSpacing:"0.06em"},children:t}),n]})}const jr={width:"100%",padding:"9px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",boxSizing:"border-box"},Ol={padding:"11px 28px",borderRadius:"var(--radius-sm)",border:"1px solid transparent",background:"var(--accent)",color:"var(--text-inverse)",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)",boxShadow:"0 2px 16px var(--accent-glow)",transition:"transform 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out)"},kf={padding:"11px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-secondary)",fontSize:14,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)",whiteSpace:"nowrap",transition:"all 0.15s var(--ease-out)"},Sf={padding:"6px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-secondary)",fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)"},Li={padding:"4px 10px",borderRadius:6,border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-muted)",fontSize:12,cursor:"pointer",fontFamily:"var(--font-body)"},If={fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},_i={display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",fontSize:13};function Cf({onboarding:t=!1}){const n=typeof window>"u"?void 0:window.agentApi,r=!!(n!=null&&n.desktopLiveGetStatus),[s,i]=l.useState(null),[a,c]=l.useState(!1),[d,u]=l.useState(null),[h,g]=l.useState(!0),[y,m]=l.useState(null);l.useEffect(()=>{var V;if(!(n!=null&&n.desktopLiveGetStatus)||!(n!=null&&n.onDesktopLiveStatus))return;let v=!0;n.desktopLiveSetup().then(R=>{v&&(i(R.status),g(R.supported))}).catch(()=>{}),(V=n.desktopLiveGetDisplays)==null||V.call(n).then(R=>{v&&R.displays.length>1&&m(R.displays)}).catch(()=>{});const D=n.onDesktopLiveStatus(R=>i(R));return()=>{v=!1,D()}},[n]);const k=async()=>{if(n!=null&&n.desktopLiveRecheck)try{i(await n.desktopLiveRecheck()),u(null)}catch(v){u(v instanceof Error?v.message:String(v))}};l.useEffect(()=>{if(!r||!h)return;let v=!0,D=!1;const V=async()=>{if(!D){D=!0;try{const T=await n.desktopLiveRecheck();v&&i(T)}catch{}finally{D=!1}}};window.addEventListener("focus",V);const R=s!=null&&s.enabled&&(s.permissionScreen!=="granted"||s.accessibilityTrusted!==!0)?window.setInterval(V,3e3):void 0;return()=>{v=!1,window.removeEventListener("focus",V),R&&window.clearInterval(R)}},[n,r,h,s==null?void 0:s.enabled,s==null?void 0:s.permissionScreen,s==null?void 0:s.accessibilityTrusted]);const C=async v=>{if(n){c(!0);try{i(await n.desktopLiveSetEnabled(!0)),await n.desktopLiveOpenPermission(v),u(null)}catch(D){u(D instanceof Error?D.message:String(D))}finally{c(!1)}}},E=async v=>{var D;if(n!=null&&n.desktopLiveSetDisplay)try{await n.desktopLiveSetDisplay(v);const V=await((D=n.desktopLiveGetDisplays)==null?void 0:D.call(n));V&&m(V.displays)}catch{}};if(!r)return null;const A=async()=>{if(n!=null&&n.desktopLiveSetEnabled){c(!0);try{i(await n.desktopLiveSetEnabled(!(s!=null&&s.enabled))),u(null)}catch(v){u(v instanceof Error?v.message:String(v))}finally{c(!1)}}},S=(s==null?void 0:s.permissionScreen)==="granted",j=(s==null?void 0:s.accessibilityTrusted)===!0;return e.jsxs("section",{className:"desktop-permission-settings",children:[e.jsx("h3",{style:If,children:t?"设置桌面端权限":"桌面直播与远程控制"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"0 0 14px",lineHeight:1.6},children:t?"欢迎使用 AgentRoam。请为桌面端开启以下系统权限,完成后手机即可查看电脑画面;允许辅助功能后还可操作鼠标和键盘。":"开启后,已配对手机可查看电脑画面,并在授予辅助功能权限后操作鼠标和键盘。"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("button",{type:"button",onClick:()=>void A(),disabled:a||!h,style:{padding:"7px 16px",borderRadius:"var(--radius-sm)",border:`1px solid ${s!=null&&s.enabled?"rgba(244,63,94,0.35)":"var(--accent)"}`,background:s!=null&&s.enabled?"rgba(244,63,94,0.1)":"var(--accent-dim)",color:s!=null&&s.enabled?"var(--danger)":"var(--accent)",fontSize:13,fontWeight:600,cursor:"pointer"},children:a?"处理中…":s!=null&&s.enabled?t?"暂停手机查看":"关闭桌面直播":t?"开启手机查看":"开启桌面直播"}),(s==null?void 0:s.enabled)&&e.jsx("span",{style:{fontSize:12,color:s.sessionOnline?"var(--success)":"var(--text-muted)"},children:s.sessionOnline?"● 已连接,可从手机查看":"○ 未连接"})]}),!h&&e.jsx("p",{role:"status",children:"当前远程桌面仅支持 macOS,其他桌面功能可正常使用。"}),h&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{className:"desktop-permission-row",style:_i,children:[e.jsx("span",{children:"屏幕录制(画面采集)"}),e.jsx("span",{style:{color:S?"var(--success)":"var(--danger)",fontWeight:600},children:S?"已授权":"未授权"}),!S&&e.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:a,onClick:()=>void C("screen"),children:"去授权"})]}),e.jsxs("div",{className:"desktop-permission-row",style:_i,children:[e.jsx("span",{children:"辅助功能(键鼠控制)"}),e.jsx("span",{style:{color:j?"var(--success)":"var(--danger)",fontWeight:600},children:(s==null?void 0:s.accessibilityTrusted)===null?"待检测":j?"已授权":"未授权"}),!j&&e.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:a,onClick:()=>void C("accessibility"),children:"去授权"})]}),y&&y.length>1&&e.jsxs("div",{style:_i,children:[e.jsx("span",{children:"直播画面来源"}),e.jsx("span",{style:{display:"flex",gap:6},children:y.map(v=>e.jsx("button",{type:"button",onClick:()=>void E(v.selected?null:v.id),style:{padding:"4px 10px",borderRadius:"var(--radius-sm)",border:`1px solid ${v.selected?"var(--accent)":"var(--border-subtle)"}`,background:v.selected?"var(--accent-dim)":"transparent",color:v.selected?"var(--accent)":"var(--text-secondary)",fontSize:12,fontWeight:600,cursor:"pointer"},children:v.label},v.id))})]})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginTop:14,fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:"点击对应权限的「去授权」,在系统设置中允许 AgentRoam,返回后自动检测。"}),e.jsxs("details",{className:"desktop-permission-more",children:[e.jsx("summary",{children:"更多操作"}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void k(),children:"重新检测"}),!S&&e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void(n==null?void 0:n.desktopLiveRestart()),children:"重启桌面端"})]})]})]}),d&&e.jsx("p",{role:"alert",style:{color:"var(--danger)"},children:d}),(s==null?void 0:s.error)&&e.jsx("div",{style:{marginTop:10,fontSize:12,color:"var(--danger)"},role:"alert",children:s.error})]})}function Rf({onClose:t}){const n=l.useRef(null);return l.useEffect(()=>{var r;(r=n.current)==null||r.showModal()},[]),Yt.createPortal(e.jsx("dialog",{ref:n,"aria-label":"桌面直播与远程控制",onCancel:t,onClick:r=>{r.target===r.currentTarget&&t()},style:{width:"min(680px, calc(100vw - 48px))",maxHeight:"calc(100vh - 48px)",padding:0,margin:"auto",inset:0,overflowY:"auto",color:"var(--text-primary)",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)"},children:e.jsxs("div",{style:{padding:24},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:e.jsx("button",{type:"button",onClick:t,"aria-label":"关闭桌面直播设置",className:"ui-icon-button ui-icon-button--close",children:"×"})}),e.jsx(Cf,{}),e.jsx("div",{className:"desktop-permission-footer",children:e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:t,children:"关闭"})})]})}),document.body)}const Pi={id:"",name:"",command:"",args:"",url:"",headersRaw:""};function Af(){const[t,n]=l.useState([]),[r,s]=l.useState("stdio"),[i,a]=l.useState(Pi),[c,d]=l.useState(!1),[u,h]=l.useState({id:!1,command:!1,url:!1}),[g,y]=l.useState({}),[m,k]=l.useState({}),[C,E]=l.useState(new Set),[A,S]=l.useState(null),[j,v]=l.useState(""),[D,V]=l.useState(!1),R=async _=>{var Ie;if(!((Ie=window.agentApi)!=null&&Ie.mcpProbe))return;E(be=>new Set([...be,_.id])),k(be=>{const Ce={...be};return delete Ce[_.id],Ce});const ne=new Promise((be,Ce)=>setTimeout(()=>Ce(new Error("连接超时(15s)")),15e3));try{const be=await Promise.race([window.agentApi.mcpProbe(_),ne]);y(Ce=>({...Ce,[_.id]:be}))}catch(be){const Ce=be instanceof Error?be.message:String(be);console.warn(`[MCP] probe failed for ${_.id}:`,Ce),y(_e=>{const ke={..._e};return delete ke[_.id],ke}),k(_e=>({..._e,[_.id]:Ce})),(_.transport==="sse"||/401|403|unauthorized|forbidden|需要认证|访问被拒绝/i.test(Ce))&&(v(""),S({server:_}))}finally{E(be=>{const Ce=new Set(be);return Ce.delete(_.id),Ce})}};l.useEffect(()=>{window.agentApi&&window.agentApi.mcpList().then(_=>{n(_),_.filter(ne=>ne.enabled!==!1).forEach(ne=>R(ne))}).catch(console.error)},[]);const[T,P]=l.useState(""),[I,N]=l.useState(""),[G,ie]=l.useState(!1),Ae=async()=>{N("");let _;try{_=JSON.parse(T.trim());const ne=_.mcpServers??_,Ie=Object.entries(ne);if(Ie.length===0){N("未找到任何服务器");return}ie(!0);const be=[];for(const[_e,ke]of Ie){const Je=ke,jt=Je.name||_e,Be=Je.disabled!==!0;let Me;if(Je.url||Je.type==="streamableHttp"||Je.type==="sse"){const Ge=Je.type==="sse"?"sse":"streamableHttp";Me={id:_e,name:jt,transport:Ge,url:Je.url,headers:Je.headers??{},env:Je.env??{},enabled:Be}}else Me={id:_e,name:jt,transport:"stdio",command:Je.command,args:Je.args??[],env:Je.env??{},enabled:Be};await window.agentApi.mcpSave(Me),be.push(Me)}const Ce=await window.agentApi.mcpList();n(Ce),P(""),be.filter(_e=>_e.enabled!==!1).forEach(_e=>R(_e))}catch(ne){N(ne instanceof Error?ne.message:"JSON 解析失败")}finally{ie(!1)}},ze=()=>i.id.trim()!==""&&i.command.trim()!=="",ce=()=>i.id.trim()!==""&&i.url.trim()!=="",J=_=>{const ne={};for(const Ie of _.split(`
|
|
370
|
+
`)){const be=Ie.indexOf(":");if(be<1)continue;const Ce=Ie.slice(0,be).trim(),_e=Ie.slice(be+1).trim();Ce&&(ne[Ce]=_e)}return ne},je=async()=>{if(h({id:!0,command:!0,url:!0}),!(r==="stdio"&&!ze())&&!((r==="sse"||r==="streamableHttp")&&!ce())){d(!0);try{const _=r==="sse"||r==="streamableHttp"?J(i.headersRaw):{},ne=r==="stdio"?{id:i.id,name:i.name||i.id,transport:"stdio",command:i.command,args:i.args.split(" ").filter(Boolean),enabled:!0}:{id:i.id,name:i.name||i.id,transport:r,url:i.url,headers:_,enabled:!0};await window.agentApi.mcpSave(ne);const Ie=await window.agentApi.mcpList();n(Ie),a(Pi),h({id:!1,command:!1,url:!1}),R(ne)}catch(_){console.error("Failed to save MCP server",_)}finally{d(!1)}}},Ke=async _=>{await window.agentApi.mcpDelete(_),n(t.filter(ne=>ne.id!==_))},Xe=async(_,ne)=>{await window.agentApi.mcpSetEnabled(_,ne),n(t.map(Ie=>Ie.id===_?{...Ie,enabled:ne}:Ie))},ct=async()=>{if(!(!A||!j.trim())){V(!0);try{const _=A.server.transport==="streamableHttp"?{...A.server,headers:{...A.server.headers??{},Authorization:`Bearer ${j.trim()}`}}:{...A.server,env:{...A.server.env??{},Authorization:`Bearer ${j.trim()}`}};await window.agentApi.mcpSave(_);const ne=await window.agentApi.mcpList();n(ne),S(null),v("");const Ie=ne.find(be=>be.id===_.id)??_;R(Ie)}finally{V(!1)}}},nt=_=>_==="stdio"?"本地":_==="streamableHttp"?"HTTP":"SSE",Ht=_=>_==="stdio"?"#68d391":_==="streamableHttp"?"#f6ad55":"#63b3ed",Ze=_=>_==="stdio"?"rgba(154,230,180,0.15)":_==="streamableHttp"?"rgba(246,173,85,0.15)":"rgba(99,179,237,0.15)";return e.jsxs("div",{style:{padding:"40px 48px",maxWidth:660,animation:"fadeInUp 0.4s var(--ease-out)"},children:[e.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,marginBottom:8,letterSpacing:"-0.02em"},children:"MCP 服务器"}),e.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginBottom:32},children:"通过模型上下文协议连接外部工具。"}),e.jsxs("div",{style:{padding:20,background:"var(--bg-glass)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-subtle)",marginBottom:28,backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[e.jsx("h3",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",margin:0},children:"添加服务器"}),e.jsx("div",{style:{display:"flex",background:"var(--bg-surface)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",overflow:"hidden"},children:["stdio","sse","streamableHttp"].map(_=>e.jsx("button",{onClick:()=>{s(_),h({id:!1,command:!1,url:!1}),a(ne=>({...Pi,id:ne.id,name:ne.name}))},style:{padding:"5px 14px",border:"none",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)",transition:"background 0.15s",background:r===_?"var(--accent)":"transparent",color:r===_?"var(--text-inverse)":"var(--text-muted)"},children:_==="stdio"?"本地 stdio":_==="sse"?"远程 SSE":"HTTP"},_))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[e.jsx("input",{value:i.id,onChange:_=>a(ne=>({...ne,id:_.target.value})),onBlur:()=>h(_=>({..._,id:!0})),placeholder:"服务器 ID *",style:{...tr,...u.id&&!i.id?Wi:{}}}),u.id&&!i.id&&e.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:"必填"})]}),e.jsx("input",{value:i.name,onChange:_=>a(ne=>({...ne,name:_.target.value})),placeholder:"显示名称",style:{...tr,flex:1}})]}),r==="stdio"?e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[e.jsx("input",{value:i.command,onChange:_=>a(ne=>({...ne,command:_.target.value})),onBlur:()=>h(_=>({..._,command:!0})),placeholder:"命令(如 npx)*",style:{...tr,...u.command&&!i.command?Wi:{}}}),u.command&&!i.command&&e.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:"必填"})]}),e.jsx("input",{value:i.args,onChange:_=>a(ne=>({...ne,args:_.target.value})),placeholder:"参数(如 -y @anthropic/mcp-server)",style:{...tr,flex:2}})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("input",{value:i.url,onChange:_=>a(ne=>({...ne,url:_.target.value})),onBlur:()=>h(_=>({..._,url:!0})),placeholder:r==="streamableHttp"?"HTTP URL(如 http://host/mcp)*":"SSE URL(如 https://mcp.example.com/sse)*",style:{...tr,...u.url&&!i.url?Wi:{}}}),u.url&&!i.url&&e.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:"必填"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("label",{style:{fontSize:12,color:"var(--text-muted)"},children:"请求头(每行 key: value)"}),e.jsx("textarea",{value:i.headersRaw,onChange:_=>a(ne=>({...ne,headersRaw:_.target.value})),placeholder:`access_token: abc123
|
|
371
|
+
Authorization: Bearer sk-...`,rows:3,style:{...tr,fontFamily:"var(--font-mono)",fontSize:12,resize:"vertical"}})]})]}),e.jsx("button",{onClick:je,disabled:c,style:{alignSelf:"flex-start",padding:"10px 22px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:c?"not-allowed":"pointer",fontFamily:"var(--font-body)"},children:c?"保存中…":"添加服务器"})]})]}),e.jsxs("div",{style:{marginBottom:28,padding:20,background:"var(--bg-glass)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[e.jsx("h3",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:"导入 JSON 配置"}),e.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",margin:"0 0 10px"},children:"兼容 Claude Desktop / Cursor 格式,粘贴后点导入。"}),e.jsx("textarea",{value:T,onChange:_=>{P(_.target.value),N("")},placeholder:`{
|
|
372
|
+
"my-server": {
|
|
373
|
+
"command": "npx",
|
|
374
|
+
"args": ["-y", "some-mcp"]
|
|
375
|
+
}
|
|
376
|
+
}`,rows:5,style:{...tr,width:"100%",boxSizing:"border-box",fontFamily:"var(--font-mono)",fontSize:12,resize:"vertical",marginBottom:8}}),I&&e.jsx("div",{style:{fontSize:12,color:"var(--danger)",marginBottom:8},children:I}),e.jsx("button",{onClick:Ae,disabled:!T.trim()||G,style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:T.trim()&&!G?"pointer":"not-allowed",fontFamily:"var(--font-body)",opacity:T.trim()&&!G?1:.5},children:G?"导入中…":"导入"})]}),t.filter(_=>_.transport===r).length===0?e.jsxs("div",{style:{color:"var(--text-muted)",fontSize:14,padding:"40px 0",textAlign:"center"},children:["暂无",r==="stdio"?"本地 stdio":r==="sse"?"远程 SSE":"HTTP"," 服务器,点击上方添加。"]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.filter(_=>_.transport===r).map(_=>e.jsxs("div",{style:{padding:"14px 16px",background:"var(--bg-glass)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",transition:"border-color 0.2s"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:_.name||_.id}),e.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:Ze(_.transport),color:Ht(_.transport),fontWeight:600},children:nt(_.transport)})]}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2,fontFamily:"var(--font-mono)"},children:[_.transport==="stdio"?`${_.command} ${(_.args??[]).join(" ")}`:_.url,_.transport!=="stdio"&&_.headers&&Object.keys(_.headers).length>0&&e.jsxs("span",{style:{marginLeft:6,fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-body)"},children:["· ",Object.keys(_.headers).length," 个请求头"]})]}),C.has(_.id)?e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:6,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",border:"2px solid var(--accent)",borderTopColor:"transparent",animation:"spin 0.8s linear infinite"}}),"探测工具中…"]}):m[_.id]?e.jsxs("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--danger)"},children:m[_.id]}),_.transport==="sse"||/401|403|unauthorized|forbidden|需要认证|访问被拒绝/i.test(m[_.id])?e.jsx("button",{onClick:()=>{v(""),S({server:_})},style:{fontSize:11,padding:"2px 8px",borderRadius:4,border:"1px solid rgba(251,191,36,0.4)",background:"rgba(251,191,36,0.1)",color:"#fbbf24",cursor:"pointer",fontFamily:"var(--font-body)"},children:"输入 Token"}):null,e.jsx("button",{onClick:()=>R(_),style:{fontSize:11,padding:"2px 8px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontFamily:"var(--font-body)"},children:"重试"})]}):g[_.id]&&g[_.id].length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:6},children:g[_.id].map(ne=>e.jsx("span",{title:ne.description,style:{fontSize:11,padding:"2px 8px",borderRadius:10,background:"rgba(168,85,247,0.12)",color:"#c084fc",border:"1px solid rgba(168,85,247,0.2)",fontFamily:"var(--font-mono)",cursor:"default"},children:ne.name},ne.name))}):g[_.id]!==void 0?e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:6},children:"无可用工具"}):null]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{fontSize:12,color:"var(--text-muted)",cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[e.jsx("input",{type:"checkbox",checked:_.enabled!==!1,onChange:ne=>Xe(_.id,ne.target.checked),style:{cursor:"pointer"}}),"启用"]}),e.jsx("button",{onClick:()=>Ke(_.id),style:{padding:"5px 12px",borderRadius:"var(--radius-sm)",border:"1px solid rgba(248,113,113,0.2)",background:"transparent",color:"var(--danger)",fontSize:12,cursor:"pointer",fontFamily:"var(--font-body)",fontWeight:500,transition:"background 0.15s"},onMouseEnter:ne=>{ne.currentTarget.style.background="rgba(248,113,113,0.1)"},onMouseLeave:ne=>{ne.currentTarget.style.background="transparent"},children:"移除"})]})]},_.id))}),A&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"},onClick:_=>{_.target===_.currentTarget&&S(null)},children:e.jsxs("div",{style:{width:420,background:"var(--bg-surface)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-default)",padding:28,boxShadow:"0 24px 48px rgba(0,0,0,0.4)"},children:[e.jsx("h3",{style:{margin:"0 0 6px",fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:"需要认证"}),e.jsxs("p",{style:{margin:"0 0 20px",fontSize:13,color:"var(--text-muted)"},children:["服务器 ",e.jsx("strong",{style:{color:"var(--text-primary)"},children:A.server.name||A.server.id})," 返回了 401/403,请输入访问令牌(Bearer Token)。"]}),e.jsx("input",{autoFocus:!0,type:"password",value:j,onChange:_=>v(_.target.value),onKeyDown:_=>{_.key==="Enter"&&ct(),_.key==="Escape"&&S(null)},placeholder:"sk-… 或 Bearer token",style:{...tr,width:"100%",boxSizing:"border-box",marginBottom:16}}),e.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>S(null),style:{padding:"8px 18px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-muted)",fontSize:13,cursor:"pointer",fontFamily:"var(--font-body)"},children:"取消"}),e.jsx("button",{onClick:ct,disabled:!j.trim()||D,style:{padding:"8px 18px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:j.trim()&&!D?"pointer":"not-allowed",fontFamily:"var(--font-body)",opacity:j.trim()&&!D?1:.5},children:D?"保存中…":"保存并重试"})]})]})}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]})}const tr={padding:"10px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"var(--font-body)"},Wi={border:"1px solid var(--danger)",boxShadow:"0 0 0 2px rgba(248,113,113,0.15)"};function Mf(){const[t,n]=l.useState([]),[r,s]=l.useState(""),[i,a]=l.useState(null),[c,d]=l.useState(!1),[u,h]=l.useState(""),[g,y]=l.useState(""),[m,k]=l.useState("user"),[C,E]=l.useState(""),[A,S]=l.useState(null),[j,v]=l.useState("success"),D=async()=>{if(window.agentApi){const P=await window.agentApi.listMemories();n(P)}};l.useEffect(()=>{D()},[]);const V=async()=>{if(!r.trim()){D();return}if(window.agentApi){const P=await window.agentApi.searchMemories(r);n(P.map(I=>I.entry))}},R=async()=>{if(!(!u.trim()||!window.agentApi))try{await window.agentApi.setMemory({name:u.trim(),description:g,type:m,content:C,created:(i==null?void 0:i.created)??new Date().toISOString(),updated:new Date().toISOString()}),d(!1),a(null),h(""),y(""),E(""),k("user"),S("保存成功"),v("success"),await D()}catch(P){S(P instanceof Error?P.message:"保存失败"),v("error")}},T=P=>{a(P),h(P.name),y(P.description),k(P.type),E(P.content),d(!0)};return e.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,letterSpacing:"-0.02em"},children:"记忆"}),e.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginTop:4},children:"跨会话的持久化知识库。"})]}),e.jsx("button",{onClick:()=>{d(!0),a(null),h(""),y(""),E(""),k("user")},style:{padding:"10px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"var(--text-inverse)",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)"},children:"+ 新建"})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:24},children:[e.jsx("input",{value:r,onChange:P=>s(P.target.value),onKeyDown:P=>P.key==="Enter"&&V(),placeholder:"搜索记忆...",style:{flex:1,padding:"10px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"}}),e.jsx("button",{onClick:V,style:Fa,children:"搜索"})]}),A&&e.jsx("div",{style:{padding:"10px 12px",borderRadius:"var(--radius-sm)",border:j==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:j==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:j==="success"?"var(--success)":"var(--danger)",fontSize:13,marginBottom:16},children:A}),c&&e.jsxs("div",{style:{padding:20,marginBottom:24,background:"var(--bg-glass)",borderRadius:"var(--radius-md)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[e.jsx("input",{value:u,onChange:P=>h(P.target.value),placeholder:"名称",style:{...Ds,marginBottom:10},disabled:!!i}),e.jsx("input",{value:g,onChange:P=>y(P.target.value),placeholder:"描述",style:{...Ds,marginBottom:10}}),e.jsxs("select",{value:m,onChange:P=>k(P.target.value),style:{...Ds,marginBottom:10},children:[e.jsx("option",{value:"user",children:"用户"}),e.jsx("option",{value:"feedback",children:"反馈"}),e.jsx("option",{value:"project",children:"项目"}),e.jsx("option",{value:"reference",children:"参考"})]}),e.jsx("textarea",{value:C,onChange:P=>E(P.target.value),placeholder:"内容",rows:5,style:{...Ds,marginBottom:12,resize:"vertical"}}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:R,style:{padding:"9px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--success)",color:"#000",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)"},children:"保存"}),e.jsx("button",{onClick:()=>d(!1),style:Fa,children:"取消"})]})]}),t.map(P=>e.jsxs("div",{style:{padding:"14px 16px",marginBottom:8,background:"var(--bg-glass)",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",transition:"border-color 0.2s"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontSize:14},children:P.name}),e.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:10,background:"rgba(255,255,255,0.04)",color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:500},children:P.type})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{onClick:()=>T(P),style:Ha,children:"编辑"}),e.jsx("button",{onClick:async()=>{if(window.agentApi)try{await window.agentApi.deleteMemory(P.name),S("删除成功"),v("success"),await D()}catch(I){S(I instanceof Error?I.message:"删除失败"),v("error")}},style:{...Ha,color:"var(--danger)"},children:"删除"})]})]}),P.description&&e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:4},children:P.description}),e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:4,lineHeight:1.5},children:[P.content.slice(0,180),P.content.length>180?"…":""]})]},P.name)),t.length===0&&!c&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:14,padding:"60px 0",textAlign:"center"},children:"暂无记忆,点击「新建」创建一条。"})]})}const Ds={width:"100%",padding:"11px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",boxSizing:"border-box"},Fa={padding:"10px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-secondary)",fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"var(--font-body)"},Ha={padding:"4px 10px",borderRadius:6,fontSize:11,border:"none",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-body)",fontWeight:500},Ef=()=>({name:"",description:"",triggers:[],prompt:"",filePath:"",enabled:!0});function Tf(){const[t,n]=l.useState([]),[r,s]=l.useState(null),[i,a]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState("success"),[g,y]=l.useState(""),m=(T,P="success")=>{d(T),h(P),setTimeout(()=>d(null),3e3)},k=async()=>{if(!window.agentApi)return;const T=await window.agentApi.listSkills();n(T)};l.useEffect(()=>{k()},[]);const C=T=>{s({...T}),y((T.triggers??[]).join(", ")),a(!1)},E=()=>{s(Ef()),y(""),a(!0)},A=()=>{s(null),a(!1)},S=async()=>{if(!r||!window.agentApi)return;if(!r.name.trim()){m("名称不能为空","error");return}const T=g.split(",").map(P=>P.trim()).filter(Boolean);try{await window.agentApi.saveSkill({name:r.name.trim(),description:r.description,triggers:T,prompt:r.prompt,filePath:r.filePath??""}),m(i?"技能已创建":"技能已保存"),s(null),await k()}catch(P){m(P instanceof Error?P.message:"保存失败","error")}},j=async T=>{if(window.agentApi)try{await window.agentApi.deleteSkill(T),m("已删除"),(r==null?void 0:r.name)===T&&s(null),await k()}catch(P){m(P instanceof Error?P.message:"删除失败","error")}},v=async T=>{if(!window.agentApi)return;const P=!T.enabled;await window.agentApi.setSkillEnabled(T.name,P),await k()},D=async()=>{if(window.agentApi)try{const T=await window.agentApi.importSkill();if(!T)return;m(`已导入技能「${T.name}」,本次会话立即生效`),await k()}catch(T){m(T instanceof Error?T.message:"导入失败","error")}},V={width:"100%",padding:"8px 10px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none",boxSizing:"border-box"},R={fontSize:11,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:4,display:"block"};return e.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:0},children:"技能管理"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"4px 0 0"},children:"配置触发词和提示词,让 Agent 自动激活专属技能"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:D,style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:13,fontWeight:600,cursor:"pointer"},children:"↓ 导入技能"}),e.jsx("button",{onClick:E,style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer"},children:"+ 新建技能"})]})]}),c&&e.jsx("div",{style:{marginBottom:16,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:u==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:u==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:u==="success"?"var(--success)":"var(--danger)",fontSize:13},children:c}),r&&e.jsxs("div",{style:{marginBottom:24,padding:"20px 24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border-glow)",background:"var(--bg-glass)"},children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:i?"新建技能":`编辑:${r.name}`}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{children:[e.jsx("label",{style:R,children:"名称"}),e.jsx("input",{style:V,value:r.name,disabled:!i,onChange:T=>s({...r,name:T.target.value}),placeholder:"技能唯一标识,如 code-review"})]}),e.jsxs("div",{children:[e.jsx("label",{style:R,children:"描述"}),e.jsx("input",{style:V,value:r.description,onChange:T=>s({...r,description:T.target.value}),placeholder:"简短说明这个技能的用途"})]}),e.jsxs("div",{children:[e.jsx("label",{style:R,children:"触发词(逗号分隔)"}),e.jsx("input",{style:V,value:g,onChange:T=>y(T.target.value),placeholder:"代码审查, review, 审查代码"})]}),e.jsxs("div",{children:[e.jsx("label",{style:R,children:"提示词"}),e.jsx("textarea",{style:{...V,minHeight:120,resize:"vertical"},value:r.prompt,onChange:T=>s({...r,prompt:T.target.value}),placeholder:"当触发词匹配时,注入到系统提示的内容..."})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:16},children:[e.jsx("button",{onClick:S,style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer"},children:"保存"}),e.jsx("button",{onClick:A,style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:13,cursor:"pointer"},children:"取消"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.length===0&&!r&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:13,padding:"20px 0",textAlign:"center"},children:"暂无技能,点击「新建技能」创建第一个"}),t.map(T=>{var P;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12,padding:"14px 16px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",background:"var(--bg-glass)",opacity:T.enabled===!1?.5:1},children:[e.jsx("button",{onClick:()=>v(T),title:T.enabled===!1?"已禁用,点击启用":"点击禁用",style:{flexShrink:0,marginTop:2,width:32,height:18,borderRadius:9,border:"none",background:T.enabled===!1?"var(--border-default)":"var(--accent)",cursor:"pointer",position:"relative",transition:"background 0.2s"},children:e.jsx("span",{style:{position:"absolute",top:2,left:T.enabled===!1?2:14,width:14,height:14,borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:2},children:[e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:T.name}),((P=T.triggers)==null?void 0:P.length)>0&&e.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["触发词:",T.triggers.slice(0,3).join(" · "),T.triggers.length>3?" ...":""]})]}),T.description&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:T.description}),T.prompt&&e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",opacity:.7},children:[T.prompt.slice(0,80),T.prompt.length>80?"...":""]})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsx("button",{onClick:()=>C(T),style:{padding:"5px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,cursor:"pointer"},children:"编辑"}),e.jsx("button",{onClick:()=>j(T.name),style:{padding:"5px 12px",borderRadius:"var(--radius-sm)",border:"1px solid rgba(244,63,94,0.3)",background:"transparent",color:"var(--danger)",fontSize:12,cursor:"pointer"},children:"删除"})]})]},T.name)})]})]})}const Bs=[{name:"read_file",label:"读取文件"},{name:"write_file",label:"写入文件"},{name:"bash",label:"执行命令"},{name:"web_fetch",label:"网页抓取"},{name:"web_search",label:"网络搜索"},{name:"grep",label:"文件搜索"}];function Fl(){return{profileId:"",enabledTools:[],enabledSkills:[],enabledMCPServers:[]}}function Nf(){return{name:"",description:"",systemPrompt:"",contextPlaceholders:[],capabilities:Fl(),maxIterations:0,isDefault:!1}}const Qi={padding:"5px 12px",borderRadius:7,border:"1px solid var(--border-default)",background:"var(--bg-deep)",color:"var(--text-secondary)",fontSize:12,fontWeight:500,cursor:"pointer"},ys={padding:"3px 9px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},sr={width:"100%",padding:"7px 10px",borderRadius:7,border:"1px solid var(--border-default)",background:"var(--bg-surface)",color:"var(--text-primary)",fontSize:13,outline:"none",boxSizing:"border-box"},nr={fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:5,display:"block"};function zf({ph:t,onChange:n,onDelete:r}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.5fr 1fr auto",gap:6,alignItems:"center"},children:[e.jsx("input",{style:sr,placeholder:"变量名 (e.g. project)",value:t.key,onChange:s=>n({...t,key:s.target.value})}),e.jsx("input",{style:sr,placeholder:"说明",value:t.description,onChange:s=>n({...t,description:s.target.value})}),e.jsx("input",{style:sr,placeholder:"默认值",value:t.defaultValue,onChange:s=>n({...t,defaultValue:s.target.value})}),e.jsx("button",{onClick:r,style:{...ys,color:"var(--danger)",borderColor:"rgba(244,63,94,0.25)",flexShrink:0},children:"✕"})]})}function Ua({initial:t,activeAgentId:n,onSave:r,onCancel:s}){const{profiles:i}=Ks(),[a,c]=l.useState([]),[d,u]=l.useState([]),[h,g]=l.useState({...Nf(),...t,capabilities:{...Fl(),...t.capabilities??{}}}),[y,m]=l.useState(null),[k,C]=l.useState(!1);l.useEffect(()=>{var I,N;window.agentApi&&(window.agentApi.listSkills().then(G=>{c(G.filter(ie=>ie.name))}),(N=(I=window.agentApi).listMCPServers)==null||N.call(I).then(G=>{u(G??[])}).catch(()=>{}))},[]);const E=I=>g(N=>({...N,capabilities:{...N.capabilities,...I}})),A=I=>{const N=h.capabilities.enabledTools;if(N.length===0){const G=Bs.map(ie=>ie.name).filter(ie=>ie!==I);E({enabledTools:G})}else if(N.includes(I)){const G=N.filter(ie=>ie!==I);E({enabledTools:G})}else{const G=[...N,I];G.length===Bs.length?E({enabledTools:[]}):E({enabledTools:G})}},S=I=>{const N=h.capabilities.enabledSkills;E({enabledSkills:N.includes(I)?N.filter(G=>G!==I):[...N,I]})},j=I=>{const N=h.capabilities.enabledMCPServers;E({enabledMCPServers:N.includes(I)?N.filter(G=>G!==I):[...N,I]})},v=()=>g(I=>({...I,contextPlaceholders:[...I.contextPlaceholders,{key:"",description:"",defaultValue:""}]})),D=(I,N)=>g(G=>{const ie=[...G.contextPlaceholders];return ie[I]=N,{...G,contextPlaceholders:ie}}),V=I=>g(N=>({...N,contextPlaceholders:N.contextPlaceholders.filter((G,ie)=>ie!==I)})),R=async()=>{if(!h.name.trim()){m("名称为必填项");return}C(!0);try{await r(h)}catch(I){m(I instanceof Error?I.message:"保存失败")}finally{C(!1)}},T=I=>h.capabilities.enabledTools.length===0||h.capabilities.enabledTools.includes(I),P={fontSize:11,fontWeight:700,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:10,marginTop:22,paddingBottom:5,borderBottom:"1px solid var(--border-subtle)"};return e.jsxs("div",{style:{padding:"24px 28px",background:"transparent",borderTop:"1px solid var(--border-subtle)"},children:[y&&e.jsx("div",{style:{marginBottom:12,padding:"8px 12px",borderRadius:7,background:"rgba(244,63,94,0.08)",border:"1px solid rgba(244,63,94,0.25)",color:"var(--danger)",fontSize:12},children:y}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsx("label",{style:nr,children:"名称 *"}),e.jsx("input",{style:sr,value:h.name,onChange:I=>g(N=>({...N,name:I.target.value})),placeholder:"智能体名称"})]}),e.jsxs("div",{children:[e.jsx("label",{style:nr,children:"描述"}),e.jsx("input",{style:sr,value:h.description,onChange:I=>g(N=>({...N,description:I.target.value})),placeholder:"一句话描述"})]})]}),e.jsxs("div",{style:{marginTop:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:5},children:[e.jsx("label",{style:{...nr,marginBottom:0},children:"角色设定 / 工作指令"}),e.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)",opacity:.6},children:["支持 ","{{变量名}}"," 占位符"]})]}),e.jsx("textarea",{value:h.systemPrompt,onChange:I=>g(N=>({...N,systemPrompt:I.target.value})),placeholder:`你是一名专业的代码审查助手,请用中文回复所有问题。
|
|
377
|
+
|
|
378
|
+
当前项目:{{project_name}}`,rows:6,style:{...sr,resize:"vertical",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.6}})]}),e.jsx("p",{style:P,children:"上下文占位符"}),h.contextPlaceholders.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:8},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.5fr 1fr auto",gap:6},children:["变量名","说明","默认值",""].map(I=>e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",letterSpacing:"0.05em"},children:I},I))}),h.contextPlaceholders.map((I,N)=>e.jsx(zf,{ph:I,onChange:G=>D(N,G),onDelete:()=>V(N)},N))]}),e.jsx("button",{onClick:v,style:{...ys,color:"var(--accent)",borderColor:"rgba(79,110,247,0.25)"},children:"+ 添加占位符"}),e.jsx("p",{style:P,children:"能力配置"}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("label",{style:nr,children:"模型"}),e.jsxs("select",{value:h.capabilities.profileId,onChange:I=>E({profileId:I.target.value}),style:{...sr,cursor:"pointer"},children:[e.jsx("option",{value:"",children:"使用全局活跃模型"}),i.map(I=>e.jsxs("option",{value:I.id,children:[I.name||I.modelId," (",I.provider,")"]},I.id))]})]}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("label",{style:nr,children:["内置工具 ",h.capabilities.enabledTools.length===0?"(全部启用)":`(${h.capabilities.enabledTools.length}/${Bs.length})`]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Bs.map(I=>{const N=T(I.name);return e.jsx("button",{onClick:()=>A(I.name),style:{padding:"4px 10px",borderRadius:20,border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",background:N?"var(--accent-dim)":"transparent",color:N?"var(--accent)":"var(--text-muted)",fontSize:12,cursor:"pointer",transition:"all 0.12s"},children:I.label},I.name)})}),e.jsx("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:5,opacity:.7},children:'点击切换;全选时恢复为"全部启用"'})]}),a.length>0&&e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("label",{style:nr,children:["技能 ",h.capabilities.enabledSkills.length===0?"(全部)":`(${h.capabilities.enabledSkills.length}/${a.length})`]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:a.map(I=>{const N=h.capabilities.enabledSkills.length===0||h.capabilities.enabledSkills.includes(I.name);return e.jsx("button",{onClick:()=>S(I.name),title:I.description,style:{padding:"4px 10px",borderRadius:20,border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",background:N?"var(--accent-dim)":"transparent",color:N?"var(--accent)":"var(--text-muted)",fontSize:12,cursor:"pointer",transition:"all 0.12s"},children:I.name},I.name)})})]}),d.length>0&&e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("label",{style:nr,children:["MCP 服务器 ",h.capabilities.enabledMCPServers.length===0?"(全部)":`(${h.capabilities.enabledMCPServers.length}/${d.length})`]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:d.map(I=>{const N=h.capabilities.enabledMCPServers.length===0||h.capabilities.enabledMCPServers.includes(I.id);return e.jsx("button",{onClick:()=>j(I.id),style:{padding:"4px 10px",borderRadius:20,border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",background:N?"var(--accent-dim)":"transparent",color:N?"var(--accent)":"var(--text-muted)",fontSize:12,cursor:"pointer",transition:"all 0.12s"},children:I.name},I.id)})})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:nr,children:"最大迭代次数(0 = 全局)"}),e.jsx("input",{type:"number",style:sr,value:h.maxIterations,min:0,max:100,onChange:I=>g(N=>({...N,maxIterations:Number(I.target.value)}))})]}),e.jsx("div",{style:{display:"flex",alignItems:"flex-end",paddingBottom:2},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary)"},children:[e.jsx("input",{type:"checkbox",checked:h.isDefault,onChange:I=>g(N=>({...N,isDefault:I.target.checked})),style:{width:14,height:14,accentColor:"var(--accent)",cursor:"pointer"}}),"新会话默认使用此智能体"]})})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:R,disabled:k,style:{...Qi,background:"var(--accent)",color:"#fff",border:"none",fontWeight:600,opacity:k?.6:1},children:k?"保存中…":"保存"}),e.jsx("button",{onClick:s,style:Qi,children:"取消"})]})]})}function Lf(){const[t,n]=l.useState([]),[r,s]=l.useState([]),[i,a]=l.useState(null),[c,d]=l.useState(!1),[u,h]=l.useState(null),[g,y]=l.useState("success"),m=(j,v="success")=>{h(j),y(v),setTimeout(()=>h(null),2e3)},k=async()=>{if(!window.agentApi)return;const j=await window.agentApi.listAgentDefs();n(j);const v=await window.agentApi.getSettings();s(v.activeAgentIds??[])};l.useEffect(()=>{k()},[]);const C=async j=>{await window.agentApi.createAgentDef(j),d(!1),m("智能体已创建"),await k()},E=async(j,v)=>{await window.agentApi.updateAgentDef(j,v),a(null),m("保存成功"),await k()},A=async j=>{await window.agentApi.deleteAgentDef(j),i===j&&a(null),m("已删除"),await k()},S=async j=>{const D=(await window.agentApi.setActiveAgentDef(j)).activeAgentIds??[];s(D),m(D.includes(j)?"已激活":"已取消激活")};return e.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[e.jsx("h2",{style:{fontFamily:"var(--font-display)",fontSize:28,color:"var(--text-primary)",fontWeight:400,marginBottom:8,letterSpacing:"-0.02em"},children:"智能体"}),e.jsx("p",{style:{color:"var(--text-muted)",fontSize:14,marginBottom:28},children:"配置具有自定义角色、工具和模型的智能体,在消息框中按需切换。"}),u&&e.jsx("div",{style:{marginBottom:16,padding:"8px 14px",borderRadius:8,border:g==="success"?"1px solid rgba(52,211,153,0.35)":"1px solid rgba(244,63,94,0.35)",background:g==="success"?"rgba(52,211,153,0.08)":"rgba(244,63,94,0.08)",color:g==="success"?"var(--success)":"var(--danger)",fontSize:13},children:u}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:14},children:e.jsx("button",{onClick:()=>{d(!0),a(null)},style:{...Qi,background:"var(--accent)",color:"#fff",border:"none",fontWeight:600},children:"+ 新建智能体"})}),c&&e.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",overflow:"hidden",marginBottom:16},children:[e.jsx("div",{style:{padding:"10px 16px",background:"var(--bg-surface)",display:"flex",alignItems:"center",gap:8},children:e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)"},children:"新建智能体"})}),e.jsx(Ua,{initial:{},activeAgentId:r[0]??"",onSave:C,onCancel:()=>d(!1)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.length===0&&!c&&e.jsx("div",{style:{padding:"28px 20px",borderRadius:"var(--radius-sm)",border:"1px dashed var(--border-subtle)",textAlign:"center",color:"var(--text-muted)",fontSize:13},children:"暂无智能体配置,点击「新建智能体」开始创建"}),t.map(j=>{const v=r.includes(j.id),D=j.id===i;return e.jsxs("div",{style:{borderRadius:"var(--radius-sm)",border:`1px solid ${v?"var(--accent)":"var(--border-default)"}`,background:v?"var(--accent-dim)":"var(--bg-surface)",overflow:"hidden",transition:"border-color 0.2s, background 0.2s"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 16px"},children:[e.jsx("div",{style:{width:34,height:34,borderRadius:8,flexShrink:0,background:v?"var(--accent)":"var(--bg-deep)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:v?"#fff":"var(--text-muted)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"8",r:"4"}),e.jsx("path",{d:"M20 21a8 8 0 1 0-16 0"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:j.name}),v&&e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"var(--accent)",background:"rgba(79,110,247,0.12)",padding:"1px 6px",borderRadius:4,letterSpacing:"0.05em"},children:"激活"}),j.isDefault&&e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",background:"var(--bg-deep)",padding:"1px 6px",borderRadius:4},children:"默认"})]}),j.description&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.description}),e.jsxs("div",{style:{display:"flex",gap:5,marginTop:5,flexWrap:"wrap"},children:[j.capabilities.profileId&&e.jsx("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"rgba(79,110,247,0.08)",color:"var(--accent)",border:"1px solid rgba(79,110,247,0.15)"},children:"自定义模型"}),j.capabilities.enabledTools.length>0&&e.jsxs("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:[j.capabilities.enabledTools.length," 工具"]}),j.capabilities.enabledSkills.length>0&&e.jsxs("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:[j.capabilities.enabledSkills.length," 技能"]}),j.contextPlaceholders.length>0&&e.jsxs("span",{style:{fontSize:10,padding:"1px 7px",borderRadius:10,background:"var(--bg-deep)",color:"var(--text-muted)",border:"1px solid var(--border-subtle)"},children:[j.contextPlaceholders.length," 变量"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsx("button",{onClick:()=>S(j.id),style:{...ys,color:v?"var(--accent)":"var(--text-muted)",borderColor:v?"var(--accent)":"var(--border-default)",background:v?"var(--accent-dim)":"transparent"},children:v?"取消激活":"激活"}),e.jsx("button",{onClick:()=>a(D?null:j.id),style:ys,children:D?"收起":"编辑"}),e.jsx("button",{onClick:()=>A(j.id),style:{...ys,color:"var(--danger)",borderColor:"rgba(244,63,94,0.25)"},children:"删除"})]})]}),D&&e.jsx(Ua,{initial:j,activeAgentId:r[0]??"",onSave:V=>E(j.id,V),onCancel:()=>a(null)})]},j.id)})]})]})}const _f=[{label:"TypeScript / JavaScript",language:"typescript",fileTypes:".ts,.tsx,.js,.jsx",command:"typescript-language-server",args:"--stdio"},{label:"Python (pylsp)",language:"python",fileTypes:".py",command:"pylsp",args:""},{label:"Python (pyright)",language:"python",fileTypes:".py",command:"pyright-langserver",args:"--stdio"},{label:"Rust (rust-analyzer)",language:"rust",fileTypes:".rs",command:"rust-analyzer",args:""},{label:"Go (gopls)",language:"go",fileTypes:".go",command:"gopls",args:""},{label:"C/C++ (clangd)",language:"cpp",fileTypes:".c,.cpp,.cc,.h,.hpp",command:"clangd",args:""},{label:"Java (jdtls via brew)",language:"java",fileTypes:".java",command:"jdtls",args:"--data /tmp/jdtls-workspace"}],Di={id:"",name:"",language:"",fileTypes:"",command:"",args:"",envRaw:""};function Pf(){const[t,n]=l.useState([]),[r,s]=l.useState(Di),[i,a]=l.useState(!1),[c,d]=l.useState(null),[u,h]=l.useState(null),g=async()=>{var j;if((j=window.agentApi)!=null&&j.lspList)try{const v=await window.agentApi.lspList();n(v)}catch(v){console.error("[LSP] load error",v)}};l.useEffect(()=>{g()},[]);const y=j=>{s(v=>({...v,name:j.label,language:j.language,fileTypes:j.fileTypes,command:j.command,args:j.args}))},m=j=>{d(j.id),s({id:j.id,name:j.name,language:j.language,fileTypes:j.fileTypes.join(","),command:j.command,args:j.args.join(" "),envRaw:j.env?Object.entries(j.env).map(([v,D])=>`${v}=${D}`).join(`
|
|
379
|
+
`):""}),h(null)},k=()=>{d(null),s(Di)},C=async()=>{var R;if(!((R=window.agentApi)!=null&&R.lspSave))return;const j=r.name.trim(),v=r.command.trim();if(!j||!v)return;let D;if(r.envRaw.trim()){D={};for(const T of r.envRaw.split(`
|
|
380
|
+
`)){const P=T.indexOf("=");P>0&&(D[T.slice(0,P).trim()]=T.slice(P+1).trim())}}const V={id:c??crypto.randomUUID(),name:j,language:r.language.trim(),fileTypes:r.fileTypes.split(",").map(T=>T.trim()).filter(Boolean),command:v,args:r.args.trim()?r.args.trim().split(/\s+/):[],env:D,enabled:!0};a(!0);try{await window.agentApi.lspSave(V),await g(),k()}finally{a(!1)}},E=async j=>{var v;(v=window.agentApi)!=null&&v.lspDelete&&confirm("删除此 LSP 服务器配置?")&&(await window.agentApi.lspDelete(j),await g())},A=async j=>{var v;(v=window.agentApi)!=null&&v.lspSetEnabled&&(await window.agentApi.lspSetEnabled(j.id,!j.enabled),await g())},S=c!==null;return S&&c===null||!c&&r.name,e.jsxs("div",{style:{padding:"40px 48px",maxWidth:720,animation:"fadeInUp 0.4s var(--ease-out)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:0},children:"LSP 服务器"}),e.jsxs("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"4px 0 0"},children:["配置 Language Server Protocol 服务器,让 Agent 可通过"," ",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:"lsp_diagnostics"}),"、",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:"lsp_hover"}),"、",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:12,color:"var(--text-secondary)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:"lsp_definition"})," ","等工具进行代码分析。"]})]}),!S&&e.jsx("button",{onClick:()=>{d(""),s(Di)},style:{padding:"8px 16px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer",flexShrink:0},children:"+ 添加服务器"})]}),t.length===0&&!S&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:14,padding:"40px 0",textAlign:"center"},children:"尚未配置任何 LSP 服务器"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:S?24:0},children:t.map(j=>e.jsxs("div",{style:{background:"var(--bg-glass)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",cursor:"pointer"},onClick:()=>h(u===j.id?null:j.id),children:[e.jsx("div",{onClick:v=>{v.stopPropagation(),A(j)},style:{width:32,height:18,borderRadius:9,background:j.enabled?"var(--success, #34d399)":"var(--border-default)",position:"relative",cursor:"pointer",flexShrink:0,transition:"background 0.2s"},children:e.jsx("div",{style:{position:"absolute",top:2,left:j.enabled?16:2,width:14,height:14,borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13,color:"var(--text-primary)"},children:j.name}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:[j.language,j.fileTypes.length>0?` · ${j.fileTypes.join(", ")}`:""]})]}),e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--font-mono, monospace)",flexShrink:0},children:[j.command,j.args.length?" "+j.args.join(" "):""]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),m(j)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:13,padding:"2px 8px",fontFamily:"var(--font-body)"},children:"编辑"}),e.jsx("button",{onClick:v=>{v.stopPropagation(),E(j.id)},style:{background:"none",border:"none",cursor:"pointer",color:"var(--danger, #f43f5e)",fontSize:13,padding:"2px 8px",fontFamily:"var(--font-body)"},children:"删除"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-muted)",strokeWidth:"2.5",strokeLinecap:"round",style:{flexShrink:0,transition:"transform 0.2s",transform:u===j.id?"rotate(180deg)":"none"},children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),u===j.id&&e.jsxs("div",{style:{padding:"12px 16px",fontSize:12,color:"var(--text-muted)",borderTop:"1px solid var(--border-subtle)",display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:"命令:"}),e.jsxs("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:4},children:[j.command," ",j.args.join(" ")]})]}),j.fileTypes.length>0&&e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:"文件类型:"}),j.fileTypes.join(", ")]}),j.env&&Object.keys(j.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:"环境变量:"}),Object.entries(j.env).map(([v,D])=>`${v}=${D}`).join(", ")]})]})]},j.id))}),S&&e.jsxs("div",{style:{padding:"20px 24px",borderRadius:"var(--radius-md)",border:"1px solid var(--border-glow)",background:"var(--bg-glass)"},children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:14,fontWeight:600,color:"var(--text-primary)"},children:c?"编辑 LSP 服务器":"添加 LSP 服务器"}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:vr,children:"快速预设"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:_f.map(j=>e.jsx("button",{onClick:()=>y(j),style:{background:"var(--bg-deep)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-sm)",padding:"4px 10px",fontSize:11,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"var(--font-body)"},children:j.label},j.label))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsxs("label",{style:vr,children:["名称 ",e.jsx("span",{style:{color:"var(--danger, #f43f5e)",textTransform:"none"},children:"*"})]}),e.jsx("input",{value:r.name,onChange:j=>s(v=>({...v,name:j.target.value})),placeholder:"TypeScript Language Server",style:Hr})]}),e.jsxs("div",{children:[e.jsx("label",{style:vr,children:"语言"}),e.jsx("input",{value:r.language,onChange:j=>s(v=>({...v,language:j.target.value})),placeholder:"typescript",style:Hr})]})]}),e.jsxs("div",{children:[e.jsxs("label",{style:vr,children:["文件类型",e.jsx("span",{style:{textTransform:"none",letterSpacing:0,fontWeight:400,marginLeft:6,color:"var(--text-muted)"},children:"逗号分隔,如 .ts,.tsx"})]}),e.jsx("input",{value:r.fileTypes,onChange:j=>s(v=>({...v,fileTypes:j.target.value})),placeholder:".ts,.tsx,.js,.jsx",style:Hr})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{children:[e.jsxs("label",{style:vr,children:["命令 ",e.jsx("span",{style:{color:"var(--danger, #f43f5e)",textTransform:"none"},children:"*"})]}),e.jsx("input",{value:r.command,onChange:j=>s(v=>({...v,command:j.target.value})),placeholder:"typescript-language-server",style:{...Hr,fontFamily:"var(--font-mono, monospace)"}})]}),e.jsxs("div",{children:[e.jsxs("label",{style:vr,children:["参数",e.jsx("span",{style:{textTransform:"none",letterSpacing:0,fontWeight:400,marginLeft:6,color:"var(--text-muted)"},children:"空格分隔"})]}),e.jsx("input",{value:r.args,onChange:j=>s(v=>({...v,args:j.target.value})),placeholder:"--stdio",style:{...Hr,fontFamily:"var(--font-mono, monospace)"}})]})]}),e.jsxs("div",{children:[e.jsxs("label",{style:vr,children:["环境变量",e.jsx("span",{style:{textTransform:"none",letterSpacing:0,fontWeight:400,marginLeft:6,color:"var(--text-muted)"},children:"每行 KEY=VALUE"})]}),e.jsx("textarea",{value:r.envRaw,onChange:j=>s(v=>({...v,envRaw:j.target.value})),placeholder:`NODE_ENV=production
|
|
381
|
+
TSPROTOCOL_LOG=verbose`,rows:3,style:{...Hr,fontFamily:"var(--font-mono, monospace)",resize:"vertical"}})]}),r.language==="java"&&e.jsxs("div",{style:{background:"rgba(234,179,8,0.08)",border:"1px solid rgba(234,179,8,0.3)",borderRadius:"var(--radius-sm)",padding:"10px 14px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.65},children:[e.jsx("strong",{style:{color:"rgba(202,138,4,1)"},children:"Java 提示:"})," ","使用 ",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"jdtls"})," 预设需先通过"," ",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"brew install jdtls"})," ","安装包装脚本。若手动安装,请将命令改为"," ",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"java"}),", 并在参数中填入完整的 JVM 参数和"," ",e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",background:"var(--bg-deep)",padding:"1px 5px",borderRadius:3},children:"-jar .../launcher.jar -data /path/to/workspace"}),"。"]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:20},children:[e.jsx("button",{onClick:()=>void C(),disabled:i||!r.name.trim()||!r.command.trim(),style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"none",background:"var(--accent)",color:"#fff",fontSize:13,fontWeight:600,cursor:"pointer",opacity:i||!r.name.trim()||!r.command.trim()?.45:1,fontFamily:"var(--font-body)"},children:i?"保存中…":"保存"}),e.jsx("button",{onClick:k,style:{padding:"8px 20px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:13,fontWeight:600,cursor:"pointer",fontFamily:"var(--font-body)"},children:"取消"})]})]})]})}const Hr={width:"100%",padding:"8px 10px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:13,fontFamily:"var(--font-body)",outline:"none",boxSizing:"border-box"},vr={fontSize:11,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:4,display:"block"};function Wf({trigger:t,heardText:n}){const[r,s]=l.useState(!1);return l.useEffect(()=>{if(t<=0)return;s(!0);const i=setTimeout(()=>s(!1),2400);return()=>clearTimeout(i)},[t]),r?Yt.createPortal(e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:3e4,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:22,background:"radial-gradient(circle at 50% 50%, var(--accent-glow), transparent 60%)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",animation:"fadeIn 0.3s var(--ease-out)",pointerEvents:"none",WebkitAppRegion:"no-drag"},children:[e.jsxs("div",{style:{position:"relative",width:120,height:120},children:[[0,.45,.9].map(i=>e.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"2px solid var(--accent)",animation:`wakeRing 1.6s ${i}s var(--ease-out) infinite`}},i)),e.jsx("div",{style:{position:"absolute",inset:30,borderRadius:"50%",background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",animation:"wakeCore 1.6s var(--ease-out) infinite"},children:e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-inverse)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})]}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",letterSpacing:"0.12em",animation:"wakeText 0.9s var(--ease-out) both",fontFamily:"var(--font-display)"},children:"已唤醒 · 随时待命"}),n&&e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",maxWidth:320,textAlign:"center",animation:"fadeIn 0.6s var(--ease-out) 0.3s both"},children:["“",n.slice(0,40),"”"]})]},t),document.body):null}const Df=[{agentType:"customer-agent",label:"Customer Agent"},{agentType:"codex",label:"Codex"},{agentType:"claude-code",label:"Claude Code"},{agentType:"opencode",label:"OpenCode"}];function Bf({value:t,health:n,onChange:r}){return e.jsx("div",{className:"agent-workspace-switcher",role:"tablist","aria-label":"切换 Agent",children:Df.map(s=>{const i=n.find(c=>c.agentType===s.agentType),a=(i==null?void 0:i.available)===!1;return e.jsxs("button",{type:"button",role:"tab","aria-selected":t===s.agentType,"aria-label":s.label,title:a?`${s.label} 不可用:${(i==null?void 0:i.error)??"未检测到运行时"}`:s.label,className:t===s.agentType?"is-active":"",onClick:()=>r(s.agentType),children:[e.jsx(Zi,{agentType:s.agentType,size:22}),e.jsx("i",{className:a?"is-unavailable":"","aria-hidden":"true"})]},s.agentType)})})}const Bi=264,qa=126;function $f(t){const n=typeof window>"u"?1024:window.innerWidth,r=typeof window>"u"?768:window.innerHeight,s=Math.max(8,Math.min(t.left+t.width-Bi,n-Bi-8)),i=t.top+t.height+7,a=i+qa<=r-8?i:Math.max(8,t.top-qa-7);return{left:s,top:a,width:Bi}}function Of({message:t,anchor:n,mobile:r,pending:s,onCancel:i,onConfirm:a}){const c=d=>d.stopPropagation();return e.jsx("div",{className:`sidebar-delete-confirmation-layer${r?" is-mobile":""}`,onClick:s?void 0:i,children:e.jsxs("div",{className:"sidebar-delete-confirmation",role:"alertdialog","aria-modal":"true","aria-labelledby":"sidebar-delete-confirmation-title","aria-describedby":"sidebar-delete-confirmation-message",style:r?void 0:$f(n),onClick:c,children:[e.jsx("strong",{id:"sidebar-delete-confirmation-title",children:"删除会话"}),e.jsx("p",{id:"sidebar-delete-confirmation-message",children:t}),e.jsxs("div",{className:"sidebar-delete-confirmation-actions",children:[e.jsx("button",{type:"button",onClick:i,disabled:s,children:"取消"}),e.jsx("button",{type:"button",className:"is-danger",onClick:a,disabled:s,children:s?"正在删除...":"删除"})]})]})})}function $i({session:t,deleteLabel:n="删除会话",onSelect:r,onPin:s,onDelete:i}){var a,c;return e.jsxs("div",{className:`sidebar-row sidebar-session-row${t.child?" sidebar-session-row--child":""}${t.active?" sidebar-row-active":""}`,children:[e.jsxs("button",{type:"button",className:"sidebar-session-button",onClick:r,"aria-pressed":t.active,"aria-expanded":t.hasChildren?!!t.expanded:void 0,title:t.title,children:[e.jsx("span",{className:`sidebar-status-dot is-${t.visualState}`,title:t.statusLabel,"aria-label":t.statusLabel}),e.jsx("span",{className:"sidebar-session-title",children:t.title}),((a=t.compatibility)==null?void 0:a.status)==="checking"&&e.jsx("span",{className:"sidebar-session-compatibility",title:`正在验证 Codex ${t.compatibility.producerVersion??"未知版本"} 会话兼容性`,"aria-label":"正在验证会话兼容性",children:e.jsx(Dt,{size:13,style:{animation:"spin 1s linear infinite"},"aria-hidden":"true"})}),((c=t.compatibility)==null?void 0:c.status)==="incompatible"&&e.jsx("span",{className:"sidebar-session-compatibility",title:t.compatibility.reason??"Codex 版本不兼容","aria-label":"Codex 版本不兼容",children:e.jsx(el,{size:13,"aria-hidden":"true"})}),t.occupiedExternally&&e.jsx("span",{className:"sidebar-session-lock",title:"原客户端正在使用,只读","aria-label":"原客户端正在使用,只读",children:e.jsx(rd,{size:13,"aria-hidden":"true"})}),t.hasChildren&&e.jsx(Vr,{size:13,className:`sidebar-session-disclosure${t.expanded?" is-expanded":""}`,"aria-hidden":"true"})]}),s&&!t.child&&e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),s()},title:t.pinned?"取消置顶":"置顶会话","aria-label":`${t.pinned?"取消置顶":"置顶会话"}:${t.title}`,"aria-pressed":!!t.pinned,className:`sidebar-session-pin sidebar-row-action ui-icon-button ui-icon-button--small${t.pinned?" sidebar-row-action--accent":""}`,children:e.jsx(fd,{size:14,"aria-hidden":"true"})}),t.canDelete&&i&&e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation();const u=d.currentTarget.getBoundingClientRect();i({top:u.top,left:u.left,width:u.width,height:u.height})},title:n,"aria-label":`${n}:${t.title}`,className:"sidebar-session-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",children:e.jsx(bs,{size:14,"aria-hidden":"true"})})]})}const Ff=[["style",new Set(["css","scss","sass","less","styl"])],["image",new Set(["png","jpg","jpeg","gif","webp","avif","bmp","ico","svg","tif","tiff"])],["video",new Set(["mp4","mov","m4v","webm","mkv","avi","wmv","flv","mpeg","mpg"])],["audio",new Set(["mp3","wav","m4a","aac","ogg","flac","opus"])],["markdown",new Set(["md","mdx","markdown"])],["json",new Set(["json","jsonc","geojson"])],["archive",new Set(["zip","tar","gz","tgz","bz2","xz","7z","rar"])],["spreadsheet",new Set(["csv","tsv","xls","xlsx","ods"])],["presentation",new Set(["ppt","pptx","key","odp"])],["database",new Set(["db","sqlite","sqlite3"])],["text",new Set(["txt","log","rtf","ini","cfg","conf","env","yaml","yml","toml","xml","pdf","doc","docx","odt"])],["code",new Set(["js","jsx","mjs","cjs","ts","tsx","vue","svelte","java","kt","kts","py","rb","go","rs","php","c","cc","cpp","h","hpp","cs","swift","scala","sh","bash","zsh","fish","sql","html"])]],Hf=new Map([["dockerfile","code"],["makefile","code"],["gemfile","code"],["rakefile","code"],["license","text"]]);function Uf(t){var i;const n=t.toLocaleLowerCase(),r=Hf.get(n);if(r)return r;if(n.startsWith(".env")||n===".gitignore"||n===".npmrc")return"text";const s=n.includes(".")&&n.split(".").pop()||"";return((i=Ff.find(([,a])=>a.has(s)))==null?void 0:i[0])??"file"}const qf={folder:{icon:Xc,label:"文件夹"},code:{icon:qc,label:"代码文件"},style:{icon:ud,label:"样式文件"},image:{icon:Vc,label:"图片文件"},video:{icon:Qc,label:"视频文件"},audio:{icon:Uc,label:"音频文件"},markdown:{icon:dd,label:"Markdown 文件"},text:{icon:Vs,label:"文本文件"},json:{icon:Kc,label:"JSON 文件"},archive:{icon:Hc,label:"压缩文件"},spreadsheet:{icon:Gc,label:"表格文件"},presentation:{icon:hd,label:"演示文件"},database:{icon:Oc,label:"数据库文件"},file:{icon:Yc,label:"文件"}};function Vf(t,n){return n==="directory"?"folder":Uf(t)}const Va=t=>t.replace(/\\/g,"/").replace(/\/+$/,"")||"/";function Kf(t,n){const r=Va(t),s=Va(n),a=[{label:r==="/"?"/":r.split("/").filter(Boolean).pop()||r,path:r}];if(s===r)return a;const c=s.slice(r==="/"?1:r.length+1);let d=r;for(const u of c.split("/").filter(Boolean))d=d==="/"?`/${u}`:`${d}/${u}`,a.push({label:u,path:d});return a}function Gf({open:t,onCancel:n,onConfirm:r}){const[s,i]=l.useState([]),[a,c]=l.useState(""),[d,u]=l.useState(""),[h,g]=l.useState([]),[y,m]=l.useState(!1),[k,C]=l.useState(""),[E,A]=l.useState(!1),S=l.useMemo(()=>Kf(a||"/",d||a||"/"),[a,d]),j=async R=>{if(window.agentApi){m(!0),C("");try{const T=await window.agentApi.listProjectDirectories(R);g(T),u(R)}catch(T){C(T instanceof Error?T.message:"无法读取目录")}finally{m(!1)}}};if(l.useEffect(()=>{if(!t||!window.agentApi)return;let R=!1;return m(!0),C(""),window.agentApi.listProjectRoots().then(async T=>{if(R)return;i(T);const P=T[0]??"";c(P),P?await j(P):C("未配置可用的宿主机目录")}).catch(T=>{R||C(T instanceof Error?T.message:"无法读取宿主机目录")}).finally(()=>{R||m(!1)}),()=>{R=!0}},[t]),l.useEffect(()=>{if(!t)return;const R=T=>{T.key==="Escape"&&n()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t,n]),!t)return null;const v=R=>{c(R),j(R)},D=()=>{S.length<=1||j(S[S.length-2].path)},V=async()=>{if(!(!d||E)){A(!0),C("");try{await r(d)}catch(R){C(R instanceof Error?R.message:"项目导入失败")}finally{A(!1)}}};return Yt.createPortal(e.jsx("div",{className:"host-project-picker-backdrop",role:"presentation",onMouseDown:R=>{R.target===R.currentTarget&&n()},children:e.jsxs("section",{className:"host-project-picker",role:"dialog","aria-modal":"true","aria-labelledby":"host-project-picker-title",children:[e.jsxs("header",{className:"host-project-picker-header",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"host-project-picker-title",children:"选择宿主机项目"}),e.jsx("p",{children:"文件将直接在运行 AgentRoam 的机器上读写"})]}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:n,"aria-label":"关闭目录选择器",title:"关闭",children:e.jsx(Kr,{size:16,"aria-hidden":"true"})})]}),s.length>1&&e.jsxs("label",{className:"host-project-picker-root",children:[e.jsx("span",{children:"根目录"}),e.jsx("select",{value:a,onChange:R=>v(R.target.value),children:s.map(R=>e.jsx("option",{value:R,children:R},R))})]}),e.jsxs("nav",{className:"host-project-picker-nav","aria-label":"当前目录",children:[e.jsx("button",{type:"button",className:"ui-icon-button",onClick:D,disabled:S.length<=1,"aria-label":"返回上级目录",title:"返回上级目录",children:e.jsx(Pc,{size:16,"aria-hidden":"true"})}),e.jsx("div",{className:"host-project-picker-breadcrumbs",children:S.map((R,T)=>e.jsxs("span",{children:[T>0&&e.jsx("i",{children:"/"}),e.jsx("button",{type:"button",onClick:()=>void j(R.path),children:R.label})]},R.path))}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>d&&void j(d),disabled:!d||y,"aria-label":"刷新目录",title:"刷新目录",children:e.jsx(Xi,{size:15,"aria-hidden":"true"})})]}),a==="/"&&e.jsx("div",{className:"host-project-picker-warning",children:"当前允许访问宿主机根目录,请谨慎选择项目。"}),e.jsx("div",{className:"host-project-picker-list","aria-busy":y,children:y?e.jsx("div",{className:"host-project-picker-state",children:"正在读取目录…"}):k?e.jsx("div",{className:"host-project-picker-state is-error",children:k}):h.length===0?e.jsx("div",{className:"host-project-picker-state",children:"此目录为空"}):h.map(R=>{const T=Vf(R.name,R.kind),{icon:P,label:I}=qf[T],N=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`host-project-picker-entry-icon is-${T}`,"aria-hidden":"true",children:e.jsx(P,{size:18,strokeWidth:1.8})}),e.jsx("span",{className:"host-project-picker-name",children:R.name})]});return R.kind==="file"?e.jsx("div",{className:"host-project-picker-row is-file",title:I,children:N},`${R.name}:${R.path}`):e.jsxs("button",{type:"button",className:"host-project-picker-row is-directory",onClick:()=>void j(R.path),title:I,children:[N,R.hasChildren&&e.jsx("span",{className:"host-project-picker-chevron","aria-hidden":"true",children:e.jsx(Vr,{size:16})})]},`${R.name}:${R.path}`)})}),e.jsxs("footer",{className:"host-project-picker-footer",children:[e.jsx("code",{title:d,children:d}),e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"host-project-picker-cancel",onClick:n,children:"取消"}),e.jsx("button",{type:"button",className:"host-project-picker-confirm",disabled:!d||y||E,onClick:()=>void V(),children:E?"正在导入…":"选择此文件夹"})]})]})]})}),document.body)}const Hl="agentroam.agent-workspaces.v2",Qf=2,Ul=["customer-agent","codex","claude-code","opencode"];function Ka(){return{version:2,activeAgent:"customer-agent",agents:{}}}function Ga(){return{workspaces:[],nextCursor:null,watermark:null,expandedWorkspaceIds:[],selectedWorkspaceId:null,selectedSessionId:null,sidebarScrollTop:0,sessions:{}}}function Yf(t=localStorage){try{const n=JSON.parse(t.getItem(Hl)??"null");if(!kr(n)||n.version!==Qf)return Ka();const r=th(n.activeAgent)?n.activeAgent:"customer-agent",s=kr(n.agents)?n.agents:{},i={};for(const a of Ul){const c=eh(s[a],a);c&&(i[a]=c)}return{version:2,activeAgent:r,agents:i}}catch{return Ka()}}function Qa(t,n=localStorage){try{n.setItem(Hl,JSON.stringify(t))}catch{}}function Xf(t,n,r){const s=new Set(n.data.map(c=>c.workspaceId)),i=r?n.nextCursor?[...n.data,...t.filter(c=>!s.has(c.workspaceId))]:n.data:[...t,...n.data],a=new Set;return i.filter(c=>a.has(c.workspaceId)?!1:(a.add(c.workspaceId),!0))}function Zf(t,n,r){const s=new Set(n.data.map(c=>c.id)),i=r?n.nextCursor?[...n.data,...t.filter(c=>!s.has(c.id))]:n.data:[...t,...n.data],a=new Set;return i.filter(c=>a.has(c.id)?!1:(a.add(c.id),!0))}function Jf(t,n){return!n||t.some(r=>r.id===n.id)?[...t]:[n,...t]}function eh(t,n){if(!kr(t))return null;const r=Array.isArray(t.workspaces)?t.workspaces.filter(i=>kr(i)&&i.agentType===n&&typeof i.workspaceId=="string"&&typeof i.name=="string"&&Array.isArray(i.roots)&&i.roots.every(a=>typeof a=="string")&&typeof i.order=="number"&&(i.canCreateSession===void 0||typeof i.canCreateSession=="boolean")):[],s={};if(kr(t.sessions))for(const[i,a]of Object.entries(t.sessions))!kr(a)||!Array.isArray(a.data)||(s[i]={data:a.data.filter(c=>kr(c)&&c.agentType===n&&typeof c.id=="string"),nextCursor:typeof a.nextCursor=="string"?a.nextCursor:null,loaded:a.loaded===!0});return{workspaces:r,nextCursor:typeof t.nextCursor=="string"?t.nextCursor:null,watermark:typeof t.watermark=="string"?t.watermark:null,expandedWorkspaceIds:Array.isArray(t.expandedWorkspaceIds)?t.expandedWorkspaceIds.filter(i=>typeof i=="string"):[],selectedWorkspaceId:typeof t.selectedWorkspaceId=="string"?t.selectedWorkspaceId:null,selectedSessionId:typeof t.selectedSessionId=="string"?t.selectedSessionId:null,sidebarScrollTop:typeof t.sidebarScrollTop=="number"&&t.sidebarScrollTop>=0?t.sidebarScrollTop:0,sessions:s}}function th(t){return typeof t=="string"&&Ul.includes(t)}function kr(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ya(t){var s;const n={},r={};for(const[i,a]of Object.entries(t)){const c=a.data;n[i]=Us(c.filter(d=>!d.parentSessionId));for(const d of c.filter(u=>u.parentSessionId))(r[s=d.parentSessionId]??(r[s]=[])).push(d)}for(const i of Object.values(r))i.sort((a,c)=>a.created.localeCompare(c.created));return{roots:n,children:r,projectIds:new Set(Object.entries(t).filter(([,i])=>i.loaded).map(([i])=>i))}}function Oi(t){return{id:t.workspaceId,name:t.name,description:t.roots[0]??"",created:t.updatedAt??"",updated:t.updatedAt??"",agentType:t.agentType,source:t.source,canCreateSession:t.canCreateSession}}function nh(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4h8v2"}),e.jsx("path",{d:"M19 6l-1 14H6L5 6"}),e.jsx("path",{d:"M10 11v5M14 11v5"})]})}function Xa(t,n){n&&t.detail>0&&t.currentTarget.blur()}function rh(){const t=document.activeElement;t instanceof HTMLElement&&(t.matches("input, textarea, select")||t.isContentEditable)&&t.blur()}function ah(){var Lr,fr,es,Qt,zn,tn;const[t]=l.useState(Yf),n=t.activeAgent,r=t.agents[n]??Ga(),[s]=l.useState(()=>Ya(r.sessions)),i=l.useRef(t),[a,c]=l.useState(n),d=l.useRef(a);d.current=a;const[u,h]=l.useState(r.workspaces.map(Oi)),[g,y]=l.useState(r.nextCursor),[m,k]=l.useState(r.watermark),[C,E]=l.useState(!1),[A,S]=l.useState(!1),[j,v]=l.useState(null),[D,V]=l.useState(!1),[R,T]=l.useState(s.roots),[P,I]=l.useState(""),[N,G]=l.useState(!1),[ie,Ae]=l.useState(10),[ze,ce]=l.useState(null),[J,je]=l.useState(!1),[Ke,Xe]=l.useState(null),ct=l.useRef(!1),[nt,Ht]=l.useState([]),[Ze,_]=l.useState(s.children),ne=l.useRef(R),Ie=l.useRef(Ze);ne.current=R,Ie.current=Ze;const[be,Ce]=l.useState(s.projectIds),[_e,ke]=l.useState(new Set),[Je,jt]=l.useState({}),[Tt,Be]=l.useState(new Set),[Me,Ge]=l.useState(Object.fromEntries(Object.entries(r.sessions).map(([p,L])=>[p,L.nextCursor]))),Qe=l.useRef(new Map),W=l.useRef(new Map),[O,K]=l.useState(r.selectedWorkspaceId),[X,ae]=l.useState(r.selectedSessionId),Re=l.useRef(O),ht=l.useRef(X);Re.current=O,ht.current=X;const[vn,gt]=l.useState(new Set),[Ye,dt]=l.useState(new Set(r.expandedWorkspaceIds)),[$,Z]=l.useState(new Set),[xe,kt]=l.useState(!1),[xt,Bt]=l.useState(!1),[at,Xt]=l.useState(!1),[mt,wn]=l.useState("settings"),un=Le(p=>p.setTodos),Nt=Et(p=>p.skin),Zt=Et(p=>p.layout),st=Et(p=>p.wakeEnabled),zt=Et(p=>p.wakeWord),Ir=Et(p=>p.setSkin),jn=Et(p=>p.setLayout),ye=Et(p=>p.setWakeEnabled),Se=Et(p=>p.setWakeWord),sn=Et(p=>p.autoSpeak),kn=Et(p=>p.setAutoSpeak),St=Et(p=>p.runningFirst),$t=Et(p=>p.setRunningFirst),$n=Et(p=>p.pinnedSessionIds),pn=Et(p=>p.togglePinnedSession),rt=Et(p=>p.removePinnedSessions),on=new Set($n),fn=Le(p=>p.runningSessionId),hn=Le(Id(p=>Object.entries(p.messagesBySession).filter(([,L])=>L.some(q=>q.askUser&&!q.askUser.answered)).map(([L])=>L))),lt=l.useCallback(p=>p.status==="running"||fn===p.id,[fn]),or=()=>{dt(new Set),gt(new Set(Object.keys(Ze)))},ar=()=>{const p=u.filter(L=>!$.has(L.id)).map(L=>L.id);dt(new Set(p)),gt(new Set);for(const L of p){if(dn.current.has(L))continue;const q=cn.current.has(L);Kt(L,{refresh:q,background:q})}},an=rr(),It=Ec(),b=an&&It,[z,F]=l.useState(!1),[re,pe]=l.useState(!1),[Pe,ut]=l.useState(null),[He,et]=l.useState(0),[Ct,lr]=l.useState(void 0),Jt=l.useRef(null),ln=l.useRef(!1),[Cr,Rr]=l.useState(null),Sn=l.useRef(null),On=l.useRef(!1),Ot=l.useRef(u);Ot.current=u;const gn=l.useRef($);gn.current=$;const cn=l.useRef(be);cn.current=be;const dn=l.useRef(_e);dn.current=_e;const In=l.useRef(null);l.useEffect(()=>{document.documentElement.setAttribute("data-skin",Nt)},[Nt]),l.useEffect(()=>{document.body.classList.toggle("layout-compact",Zt==="compact")},[Zt]),l.useEffect(()=>{var Q;const p=u.map((Y,ge)=>({agentType:a,workspaceId:Y.id,name:Y.name,roots:Y.description?[Y.description]:[],order:ge,updatedAt:Y.updated||void 0,source:Y.source??(Y.agentType==="claude-code"?"derived":"native"),canCreateSession:Y.canCreateSession})),L=Object.fromEntries(u.map(Y=>[Y.id,{data:[...R[Y.id]??[],...Object.values(Ze).flat().filter(ge=>(R[Y.id]??[]).some(de=>de.id===ge.parentSessionId))],nextCursor:Me[Y.id]??null,loaded:be.has(Y.id)}])),q={...i.current,version:2,activeAgent:a,agents:{...i.current.agents,[a]:{workspaces:p,nextCursor:g,watermark:m,expandedWorkspaceIds:[...Ye],selectedWorkspaceId:O,selectedSessionId:X,sidebarScrollTop:((Q=In.current)==null?void 0:Q.scrollTop)??0,sessions:L}}};i.current=q,Qa(q)},[a,Ze,Ye,be,u,O,X,Me,R,g,m]);const Cn=l.useCallback(()=>{if(!window.agentApi||!st||ln.current||Jt.current)return;const p=()=>{Gd()&&!Jt.current&&(Jt.current=Yd({wakeWord:zt,onWake:L=>{var q;lr(L),et(Q=>Q+1),(q=window.agentApi)==null||q.showWindow()},onError:L=>console.warn("[wake]",L)}))};typeof window.agentApi.wakeStart=="function"?(ln.current=!0,window.agentApi.wakeStart(zt).then(L=>{L.ok||(ln.current=!1,p())}).catch(()=>{ln.current=!1,p()})):p()},[st,zt]);l.useEffect(()=>{var p;if((p=window.agentApi)!=null&&p.onWake)return window.agentApi.onWake(L=>{ln.current=!1,lr(L),et(q=>q+1)})},[]),l.useEffect(()=>{var p;if((p=window.agentApi)!=null&&p.onWakeAiHub)return window.agentApi.onWakeAiHub(()=>{Xt(!0),jn("focus")})},[]),l.useEffect(()=>{var p;if((p=window.agentApi)!=null&&p.onWakeCommand)return window.agentApi.onWakeCommand(L=>{var ge;const q=((L==null?void 0:L.text)||"").trim();if(!q)return;const Q=Sn.current&&Date.now()<Sn.current.until?Sn.current:null;if(Q){Q.until=Date.now()+9e4,ae(Q.sessionId),(ge=window.agentApi)==null||ge.wakeConversation(!0),Rr({text:q,projectId:null,sessionId:Q.sessionId,nonce:Date.now()}),$e(`语音追问:${q.length>40?q.slice(0,40)+"…":q}`),Rt("success"),setTimeout(()=>$e(null),4e3);return}const Y=Ot.current.find(de=>de.name&&q.includes(de.name)&&!gn.current.has(de.id));Y&&(K(Y.id),dt(de=>{const ue=new Set(de);return ue.add(Y.id),ue})),ae(null),On.current=!0,kn(!0),Rr({text:q,projectId:(Y==null?void 0:Y.id)??null,nonce:Date.now()}),$e(`语音指令:${q.length>40?q.slice(0,40)+"…":q}${Y?`(项目:${Y.name})`:""}`),Rt("success"),setTimeout(()=>$e(null),4e3)})},[]);const Zs=l.useCallback(async()=>{window.agentApi&&(Cn(),await window.agentApi.hideWindow())},[Cn]),Js=l.useCallback(p=>{kt(!1),ut({right:p.right,bottom:p.bottom}),pe(L=>!L)},[]),ei=l.useCallback(()=>{pe(!1),kt(p=>!p)},[]);l.useEffect(()=>{if(!re)return;const p=()=>{const q=document.querySelector(".chat-header-action--appearance");if(!q)return;const Q=q.getBoundingClientRect();ut(Y=>(Y==null?void 0:Y.right)===Q.right&&Y.bottom===Q.bottom?Y:{right:Q.right,bottom:Q.bottom})},L=window.requestAnimationFrame(p);return window.addEventListener("resize",p),()=>{window.cancelAnimationFrame(L),window.removeEventListener("resize",p)}},[Zt,re]),l.useEffect(()=>{window.agentApi&&Cn()},[Cn]),l.useEffect(()=>{const p=()=>{var L;(L=Jt.current)==null||L.stop(),Jt.current=null};return window.addEventListener("focus",p),()=>window.removeEventListener("focus",p)},[]),l.useEffect(()=>{var p,L;st||((p=Jt.current)==null||p.stop(),Jt.current=null,ln.current=!1,(L=window.agentApi)==null||L.wakeStop())},[st]),l.useEffect(()=>{!st||!window.agentApi||ln.current&&window.agentApi.wakeStart(zt)},[zt]),l.useEffect(()=>()=>{var p;(p=Jt.current)==null||p.stop()},[]);const Ut=[...Object.values(R).flat(),...Object.values(Ze).flat()],bt=xf(Ut,p=>on.has(p.id)),Rn=Object.entries(R).flatMap(([p,L])=>L.filter(q=>on.has(q.id)).map(q=>({projectId:p,session:q,created:q.created}))),cr=St?Pa(Rn,({session:p})=>lt(p)):Us(Rn),Yr=Ut,qt=P.trim().toLowerCase(),An=qt?bt.filter(p=>p.title.toLowerCase().includes(qt)||(p.cwd||"").toLowerCase().includes(qt)):null,Vt=X?Yr.find(p=>p.id===X):void 0,dr=Vt==null?void 0:Vt.title,Fn=(Vt==null?void 0:Vt.cwd)||((Lr=u.find(p=>p.id===O))==null?void 0:Lr.description)||null,Mn=u.filter(p=>!$.has(p.id)).map(p=>p.id),xn=Mn.length>0&&Mn.every(p=>!Ye.has(p)),[Hn,Ar]=l.useState(300),[Xr,ur]=l.useState(!1),Un=l.useRef(!1),mn=l.useRef(0),qn=l.useRef(0),en=l.useCallback(p=>{if(!Un.current)return;const L=Math.min(480,Math.max(160,qn.current+p.clientX-mn.current));Ar(L)},[]),Zr=l.useCallback(()=>{Un.current=!1,ur(!1),document.removeEventListener("mousemove",en),document.removeEventListener("mouseup",Zr)},[en]),js=l.useCallback(p=>{Un.current=!0,ur(!0),mn.current=p.clientX,qn.current=Hn,document.addEventListener("mousemove",en),document.addEventListener("mouseup",Zr)},[Hn,en,Zr]),[Mr,$e]=l.useState(null),[Vn,Rt]=l.useState("success"),Lt=p=>{Re.current=p.projectId,ht.current=p.sessionId,K(p.projectId),ae(p.sessionId),p.sessionId||un([])},_t=p=>{var de;if(p===d.current)return;const L=d.current,q=i.current.agents[L];q&&(i.current={...i.current,agents:{...i.current.agents,[L]:{...q,sidebarScrollTop:((de=In.current)==null?void 0:de.scrollTop)??q.sidebarScrollTop}}});const Q=i.current.agents[p]??Ga(),Y=Ya(Q.sessions),ge=Q.workspaces.map(Oi);d.current=p,Ot.current=ge,c(p),h(ge),y(Q.nextCursor),k(Q.watermark),E(!1),S(!1),v(null),ne.current=Y.roots,Ie.current=Y.children,T(Y.roots),_(Y.children),Ce(Y.projectIds),cn.current=Y.projectIds,ke(new Set),dn.current=new Set,jt({}),Be(new Set),Ge(Object.fromEntries(Object.entries(Q.sessions).map(([ue,Ue])=>[ue,Ue.nextCursor]))),dt(new Set(Q.expandedWorkspaceIds)),Z(new Set),Lt({projectId:Q.selectedWorkspaceId,sessionId:Q.selectedSessionId}),window.requestAnimationFrame(()=>{In.current&&(In.current.scrollTop=Q.sidebarScrollTop)}),bn(p,{refresh:Q.workspaces.length>0,since:Q.watermark})},[Er,we]=l.useState([]),Kn=l.useCallback(p=>{we(L=>L.filter(q=>q.id!==p))},[]),pr=l.useCallback(p=>{const L=crypto.randomUUID();we(q=>[...q,{...p,id:L}]),setTimeout(()=>Kn(L),12e3)},[Kn]);async function bn(p=d.current,L={}){if(!window.agentApi)return;const q=(W.current.get(p)??0)+1;W.current.set(p,q),E(!0),v(null);try{const Q=await window.agentApi.listAgentWorkspaces(p,{cursor:L.cursor,limit:50,refresh:L.refresh,since:L.refresh?L.since??m:null});if(d.current!==p||W.current.get(p)!==q)return;const Y=Ot.current.map((me,Oe)=>({agentType:p,workspaceId:me.id,name:me.name,roots:me.description?[me.description]:[],order:Oe,updatedAt:me.updated,source:me.source??(p==="claude-code"?"derived":"native"),canCreateSession:me.canCreateSession})),de=Xf(Y,Q,!L.cursor).map(Oi);Ot.current=de,h(de),y(Q.nextCursor),k(Q.watermark),S(Q.stale===!0);const ue=new Set(de.map(me=>me.id)),Ue=Re.current;Ue&&!ue.has(Ue)&&Lt(Wa);const yt=new Set([...cn.current].filter(me=>ue.has(me)));Ue&&ue.has(Ue)&&yt.add(Ue),T(me=>Object.fromEntries(Object.entries(me).filter(([Oe])=>ue.has(Oe)))),Ce(me=>{const Oe=new Set([...me].filter(pt=>ue.has(pt)));return cn.current=Oe,Oe}),ke(me=>{const Oe=new Set([...me].filter(pt=>ue.has(pt)));return dn.current=Oe,Oe}),jt(me=>Object.fromEntries(Object.entries(me).filter(([Oe])=>ue.has(Oe))));const vt=new Set;if(await Promise.all(de.map(async me=>{me.description&&!await window.agentApi.checkProjectPath(me.description)&&vt.add(me.id)})),d.current!==p||W.current.get(p)!==q)return;if(Z(vt),L.refreshLoadedSessions!==!1)for(const me of yt)vt.has(me)||dn.current.has(me)||Kt(me,{refresh:!0,background:!0})}catch(Q){d.current===p&&(Ot.current.length>0&&S(!0),v(Q instanceof Error?Q.message:"目录加载失败"))}finally{d.current===p&&W.current.get(p)===q&&E(!1)}}async function Kt(p,L={}){var ge;if(!window.agentApi)return;const q=d.current,Q=`${q}:${p}`,Y=(Qe.current.get(Q)??0)+1;Qe.current.set(Q,Y),ke(de=>{const ue=new Set(de).add(p);return dn.current=ue,ue}),jt(de=>{if(!(p in de))return de;const ue={...de};return delete ue[p],ue});try{const de=await window.agentApi.listAgentWorkspaceSessions(q,p,{cursor:L.cursor,limit:20,refresh:L.refresh});if(d.current!==q||Qe.current.get(Q)!==Y)return;const ue=ne.current[p]??[],Ue=L.pendingSession?{...L.pendingSession,projectId:p}:void 0,yt=Ue?[Ue,...ue.filter(Ne=>Ne.id!==Ue.id)]:ue,vt=new Set(yt.map(Ne=>Ne.id)),me=[...yt,...[...vt].flatMap(Ne=>Ie.current[Ne]??[])],Oe=Zf(me,de,!L.cursor).map(Ne=>({...Ne,projectId:Ne.projectId??p})),pt=Us(Oe.filter(Ne=>!Ne.parentSessionId)),ft=Re.current,nn=ht.current,Ln=Jf(pt,Ue);ft===p&&nn&&!Oe.some(Ne=>Ne.id===nn)&&!Ln.some(Ne=>Ne.id===nn)&&Lt(Wa);const Pt={};for(const Ne of Oe.filter(wt=>wt.parentSessionId))(Pt[ge=Ne.parentSessionId]??(Pt[ge]=[])).push(Ne);for(const Ne of Object.values(Pt))Ne.sort((wt,ts)=>wt.created.localeCompare(ts.created));Ge(Ne=>({...Ne,[p]:de.nextCursor})),Be(Ne=>{const wt=new Set(Ne);return de.stale?wt.add(p):wt.delete(p),wt});const Gn={...ne.current,[p]:Ln},Qn={...Ie.current};for(const Ne of vt)delete Qn[Ne];for(const[Ne,wt]of Object.entries(Pt))Qn[Ne]=wt;ne.current=Gn,Ie.current=Qn,T(Gn),_(Qn),Ce(Ne=>{const wt=new Set(Ne).add(p);return cn.current=wt,wt})}catch(de){if(Qe.current.get(Q)!==Y)return;jt(ue=>({...ue,[p]:de instanceof Error?de.message:"会话加载失败"}))}finally{Qe.current.get(Q)===Y&&ke(de=>{const ue=new Set(de);return ue.delete(p),dn.current=ue,ue})}}const ks=async p=>{if(!window.agentApi)return;const L=await window.agentApi.listChildSessions(p);_(q=>({...q,[p]:L.sort((Q,Y)=>Q.created<Y.created?-1:1)}))},Tr=async(p,L)=>{if(!window.agentApi)return;const q=Ot.current.find(Q=>Q.id===p);if(!q||q.canCreateSession===!1){$e("请先选择目录"),Rt("info"),setTimeout(()=>$e(null),3e3);return}if(!ct.current){ct.current=!0,Xe({projectId:p,agentType:L});try{const Q=(q==null?void 0:q.source)==="imported"?void 0:p,Y=await window.agentApi.createSession("新会话",Q,L,q==null?void 0:q.description);if(d.current!==L)return;const ge=Y.projectId===p?Y:{...Y,projectId:p},de={...ne.current,[p]:[ge,...(ne.current[p]??[]).filter(ue=>ue.id!==Y.id)]};ne.current=de,T(de),Lt({projectId:p,sessionId:Y.id}),b&&F(!1),L==="customer-agent"&&Kt(p,{refresh:!0,background:!0,pendingSession:ge})}catch(Q){$e(Q instanceof Error?Q.message:"新建会话失败"),Rt("error"),setTimeout(()=>$e(null),3e3)}finally{ct.current=!1,Xe(null)}}},Nr=()=>{const p=Ot.current.find(L=>L.id===O);if(!O||(p==null?void 0:p.canCreateSession)===!1){$e("请先选择目录"),Rt("info"),setTimeout(()=>$e(null),3e3);return}Tr(O,a)};l.useEffect(()=>{var p;window.agentApi&&(bn(d.current,{refresh:(((p=i.current.agents[d.current])==null?void 0:p.workspaces.length)??0)>0}),Ks.getState().loadFromSystem(),window.agentApi.getRuntimeHealth().then(Ht).catch(()=>{}))},[]),l.useEffect(()=>{const p=window.setInterval(()=>{document.visibilityState!=="visible"||C||bn(a,{refresh:!0,since:m,refreshLoadedSessions:!1})},15e3);return()=>window.clearInterval(p)},[a,C,m]),l.useEffect(()=>{if(!O||!X||!window.agentApi)return;let p=!1;const L=async()=>{document.visibilityState==="visible"&&(p||await Kt(O,{refresh:!0,background:!0}))},q=window.setInterval(()=>void L(),1e4);return()=>{p=!0,window.clearInterval(q)}},[O,X,Vt==null?void 0:Vt.agentType]),l.useEffect(()=>{if(!O||!window.agentApi)return;const p=u.find(q=>q.id===O),L=p==null?void 0:p.description;L&&window.agentApi.setProjectWorkingDir(L)},[O,u]);const En=p=>{Lt(Da(p));const L=!Ye.has(p);if(dt(q=>{const Q=new Set(q);return L?Q.add(p):Q.delete(p),Q}),L&&!dn.current.has(p)){const q=cn.current.has(p);Kt(p,{refresh:q,background:q})}},Jr=async p=>{if(!window.agentApi)throw new Error("agentApi 未就绪,请重启应用");const L=p.replace(/\\/g,"/"),q=L.split("/").filter(Boolean),Q=q[q.length-1]||L||"导入的项目",Y=await window.agentApi.importAgentWorkspace(d.current,L,Q);await bn(d.current,{refresh:!0,refreshLoadedSessions:!1}),Lt(Da(Y.workspace.workspaceId)),await Kt(Y.workspace.workspaceId,{refresh:!0}),dt(ge=>{const de=new Set(ge);return de.add(Y.workspace.workspaceId),de}),$e(Y.existing?"该文件夹已在当前 Agent 的目录中":`已导入:${Y.workspace.name}`),Rt(Y.existing?"info":"success"),setTimeout(()=>$e(null),3e3)},zr=async()=>{try{if(!window.agentApi){$e("agentApi 未就绪,请重启应用"),Rt("error");return}if(an){V(!0);return}const p=await window.agentApi.openFileDialog();if(console.log("[import] selectedPath:",p),!p)return;await Jr(p)}catch(p){console.error("[import] error:",p),$e(p instanceof Error?p.message:String(p)),Rt("error"),setTimeout(()=>$e(null),5e3)}},ti=async p=>{if(window.agentApi)try{await window.agentApi.deleteProject(p),O===p&&(K(null),ae(null),un([])),$e("项目删除成功"),Rt("success"),setTimeout(()=>$e(null),2500),await bn()}catch(L){$e(L instanceof Error?L.message:"项目删除失败"),Rt("error"),setTimeout(()=>$e(null),4e3)}},Tn=(p,L)=>{ce({session:p,anchor:L})},Gt=async()=>{if(!window.agentApi||!ze||J)return;const{session:p}=ze;je(!0);try{await window.agentApi.deleteSession(p.id);const L=p.projectId??Re.current,q=p.agentType;if(L){const ge=`${q}:${L}`;Qe.current.set(ge,(Qe.current.get(ge)??0)+1)}const Q=vf(ne.current,Ie.current,[],p.id);ne.current=Q.sessionsByProject,Ie.current=Q.childSessionsByParent,T(Q.sessionsByProject),_(Q.childSessionsByParent),rt(Q.removedIds);const Y=i.current.agents[q];if(Y){const ge={...i.current,agents:{...i.current.agents,[q]:bf(Y,Q.removedIds)}};i.current=ge,Qa(ge)}ht.current&&Q.removedIds.includes(ht.current)&&Lt({projectId:Re.current,sessionId:null}),$e("会话删除成功"),Rt("success"),setTimeout(()=>$e(null),2500),ce(null),L&&Kt(L,{refresh:!0,background:!0})}catch(L){$e(L instanceof Error?L.message:"会话删除失败"),Rt("error"),setTimeout(()=>$e(null),4e3)}finally{je(!1)}},Ss=[{id:"settings",label:"设置"},{id:"mcp",label:"MCP"},{id:"memory",label:"记忆"},{id:"skill",label:"技能"},{id:"agent",label:"智能体"},{id:"lsp",label:"LSP"}],Nn=(p,L)=>{const q=X===p.id,Q=lt(p),Y=Ti({status:p.status,isRunning:Q,needsInput:Q&&hn.includes(p.id)}),ge=Ze[p.id]??[],de=!vn.has(p.id);return e.jsxs("div",{className:"sidebar-session-tree",children:[e.jsx($i,{session:{id:p.id,title:p.title,visualState:Y,statusLabel:Ni[Y],occupiedExternally:p.agentType!=="codex"&&p.occupancy==="owned-externally",canDelete:p.canDelete,active:q,hasChildren:ge.length>0,expanded:de,compatibility:p.compatibility,pinned:on.has(p.id)},onSelect:()=>{b&&F(!1),Lt(zi(L,p.id)),ge.length>0&>(ue=>{const Ue=new Set(ue);return Ue.has(p.id)?Ue.delete(p.id):Ue.add(p.id),Ue})},onPin:()=>pn(p.id),onDelete:ue=>Tn(p,ue)}),e.jsx("div",{className:"sidebar-child-sessions",style:{maxHeight:de?ge.length*40:0,opacity:de?1:0},children:ge.map(ue=>{const Ue=lt(ue),yt=Ti({status:ue.status,isRunning:Ue,needsInput:Ue&&hn.includes(ue.id)});return e.jsx($i,{session:{id:ue.id,title:ue.title,visualState:yt,statusLabel:Ni[yt],occupiedExternally:ue.agentType!=="codex"&&ue.occupancy==="owned-externally",canDelete:ue.canDelete,active:X===ue.id,child:!0,compatibility:ue.compatibility},deleteLabel:"删除子会话",onSelect:()=>{b&&F(!1),Lt(zi(L,ue.id))},onDelete:vt=>Tn(ue,vt)},ue.id)})})]},p.id)};return e.jsxs("div",{className:"app-shell",style:{display:"flex",height:an?"100dvh":"100vh",width:"100vw",background:"var(--bg-deepest)",position:"relative",overflow:"hidden"},children:[e.jsx(hf,{}),e.jsx(gf,{}),b&&z&&e.jsx("div",{className:"mobile-drawer-scrim",onClick:()=>F(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:1150}}),b&&!z&&e.jsx("button",{className:"mobile-drawer-toggle",onClick:()=>F(!0),"aria-label":"会话列表","aria-expanded":!1,style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 8px)",left:10,zIndex:1250,width:34,height:34,borderRadius:9,border:"1px solid var(--border-default)",background:"var(--bg-glass, rgba(18,20,28,.82))",color:"var(--text-secondary)",display:"grid",placeItems:"center",backdropFilter:"blur(8px)",WebkitAppRegion:"no-drag",cursor:"pointer"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M3 6h18M3 12h18M3 18h18"})})}),e.jsx("div",{className:"app-drag-region",style:{position:"fixed",top:0,left:0,right:0,height:52,zIndex:9999,WebkitAppRegion:"drag",pointerEvents:"none"}}),e.jsx("div",{className:"app-accent-glow",style:{position:"absolute",top:"-120px",left:"-80px",width:320,height:320,borderRadius:"50%",background:"radial-gradient(circle, var(--accent-glow) 0%, transparent 70%)",pointerEvents:"none",zIndex:0}}),Zt!=="focus"&&e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"app-sidebar",style:{width:Hn,display:"flex",flexDirection:"column",background:"var(--bg-surface)",borderRight:"1px solid var(--border-subtle)",padding:"56px 0 0",position:"relative",zIndex:10,overflow:"hidden",...b?{position:"fixed",top:0,bottom:0,left:0,width:"min(82vw, 320px)",zIndex:1200,transform:z?"translateX(0)":"translateX(-103%)",transition:"transform .24s ease",boxShadow:"12px 0 32px rgba(0,0,0,.5)",padding:"calc(env(safe-area-inset-top) + 12px) 0 0"}:{}},children:[e.jsx("div",{className:"app-sidebar-brand",style:{padding:"0 20px 10px"},children:e.jsxs("div",{className:"sidebar-brand-row",children:[e.jsx("div",{className:"sidebar-brand-mark","aria-hidden":"true",children:e.jsx(Zi,{agentType:"customer-agent",size:24})}),e.jsx("span",{className:"sidebar-brand-name",children:"AgentRoam"})]})}),e.jsx(Bf,{value:a,health:nt,onChange:_t}),e.jsxs("button",{type:"button",className:"sidebar-search-field",onClick:()=>{G(!0),Ae(10)},title:"搜索会话","aria-label":"搜索会话",children:[e.jsx(sl,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:"搜索会话"}),e.jsx("kbd",{children:"⌘ K"})]}),e.jsxs("div",{className:"sidebar-project-toolbar",children:[e.jsxs("div",{className:"sidebar-project-heading",children:[e.jsx("span",{className:"sidebar-project-title",children:"目录"}),e.jsx("span",{className:"sidebar-project-count","aria-label":`${u.length} 个目录`,children:u.length})]}),e.jsxs("div",{className:"sidebar-project-actions",children:[e.jsx("button",{type:"button",onClick:p=>{xn?ar():or(),Xa(p,xn)},title:xn?"展开全部会话":"折叠全部会话","aria-label":xn?"展开全部会话":"折叠全部会话","aria-pressed":xn,disabled:Mn.length===0,className:`ui-icon-button sidebar-collapse-all${xn?" is-active":""}`,children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:xn?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m7 6 5 5 5-5"}),e.jsx("path",{d:"m7 13 5 5 5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m17 11-5-5-5 5"}),e.jsx("path",{d:"m17 18-5-5-5 5"})]})})}),e.jsx("button",{type:"button",onClick:p=>{$t(!St),Xa(p,St)},title:St?"按新建时间排序":"进行中会话优先","aria-label":St?"按新建时间排序":"进行中会话优先","aria-pressed":St,className:`ui-icon-button sidebar-session-sort${St?" is-active":""}`,children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h10M3 12h7M3 18h4"}),e.jsx("path",{d:"m15 9 3-3 3 3M18 6v12"})]})}),e.jsx("button",{type:"button",onClick:()=>void zr(),title:"导入目录","aria-label":"导入目录",className:"ui-icon-button",children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]})]}),e.jsx("div",{ref:In,className:"app-sidebar-scroll",onPointerDownCapture:rh,onScroll:p=>{const L=p.currentTarget;L.scrollHeight-L.scrollTop-L.clientHeight<120&&g&&!C&&bn(a,{cursor:g})},style:{flex:1,overflow:"auto",padding:"0 10px"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,marginBottom:12},children:[cr.length>0&&e.jsxs("section",{className:"sidebar-pinned-section","aria-label":"置顶会话",children:[e.jsx("div",{className:"sidebar-pinned-heading",children:"置顶"}),cr.map(({projectId:p,session:L})=>Nn(L,p))]}),u.map(p=>{var pt;const L=O===p.id,q=Ye.has(p.id),Q=be.has(p.id),Y=_e.has(p.id),ge=Je[p.id],de=R[p.id]??[],ue=de.filter(ft=>!on.has(ft.id)),yt=St?Pa(ue,lt):ue,vt=yt.length>10,me=$.has(p.id),Oe=(Ke==null?void 0:Ke.agentType)===a&&Ke.projectId===p.id;return e.jsxs("div",{className:"sidebar-project-block","aria-busy":Y,children:[e.jsxs("div",{className:`sidebar-row sidebar-project-row ${L&&!me?"sidebar-row-active":""}`,style:{paddingRight:4,opacity:me?.45:1},children:[e.jsxs("button",{className:"sidebar-project-button",onClick:()=>{me||En(p.id)},disabled:me,"aria-expanded":q,"aria-pressed":L,title:me?`路径不存在:${p.description}`:p.name,style:{flex:1,display:"flex",alignItems:"center",gap:8,minWidth:0,padding:"8px 10px",border:"none",background:"transparent",color:me?"var(--text-muted)":L?"var(--accent)":"var(--text-secondary)",fontSize:13,fontWeight:L&&!me?600:400,cursor:me?"not-allowed":"pointer",textAlign:"left",transition:"color 0.15s"},children:[me?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:.6},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):p.canCreateSession===!1?e.jsx(Jc,{size:13,"aria-hidden":"true",style:{flexShrink:0,opacity:L?1:.5}}):e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:L?1:.5},children:q?e.jsx("path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6A2 2 0 0 1 18.46 20H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}):e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.name})]}),a==="customer-agent"&&!an&&e.jsx("button",{onClick:ft=>{ft.stopPropagation(),ti(p.id)},title:"删除目录","aria-label":`删除目录:${p.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:e.jsx(nh,{})}),p.canCreateSession!==!1&&e.jsx("button",{type:"button",onClick:ft=>{ft.stopPropagation(),Tr(p.id,a)},title:Oe?"正在创建会话":`新建 ${a==="customer-agent"?"Customer Agent":a==="claude-code"?"Claude Code":a==="codex"?"Codex":"OpenCode"} 会话`,"aria-label":Oe?"正在创建会话":`在 ${p.name} 中新建会话`,"aria-busy":Oe,disabled:Ke!==null||me||((pt=nt.find(ft=>ft.agentType===a))==null?void 0:pt.available)===!1,className:"sidebar-runtime-create sidebar-project-add-action ui-icon-button ui-icon-button--small",children:Oe?e.jsx(Dt,{size:13,style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true"}):e.jsx(Fi,{size:13,"aria-hidden":"true"})})]}),e.jsx("div",{style:{overflow:"hidden",maxHeight:q?vt?300:800:0,opacity:q?1:0,transition:"max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease"},children:e.jsxs("div",{className:"sidebar-project-sessions",onScroll:ft=>{const nn=ft.currentTarget,Ln=nn.scrollHeight-nn.scrollTop-nn.clientHeight<80,Pt=Me[p.id];Ln&&Pt&&!Y&&Kt(p.id,{cursor:Pt})},style:{display:"flex",flexDirection:"column",gap:1,marginTop:2,paddingLeft:10,paddingBottom:4,...vt?{maxHeight:280,overflowY:"auto"}:{}},children:[yt.map(ft=>Nn(ft,p.id)),Y&&!Q&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"正在加载会话..."}),ge&&e.jsxs("div",{title:ge,style:{display:"flex",alignItems:"center",gap:8,color:"var(--danger)",fontSize:11,padding:"4px 10px"},children:[e.jsx("span",{style:{flex:1},children:"会话加载失败"}),e.jsx("button",{type:"button",onClick:()=>void Kt(p.id,{refresh:Q,background:Q}),style:{border:0,background:"transparent",color:"inherit",fontSize:11,cursor:"pointer",padding:0},children:"重试"})]}),Tt.has(p.id)&&!ge&&e.jsx("div",{className:"sidebar-cache-state",children:"显示缓存,会话将在下次刷新时更新"}),de.length===0&&Q&&!Y&&!ge&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"暂无会话"})]})})]},p.id)}),u.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"24px 10px",textAlign:"center",opacity:.7},children:C?"正在加载目录...":"暂无目录"}),u.length>0&&C&&e.jsx("div",{className:"sidebar-cache-state",children:"正在同步目录..."}),A&&!j&&e.jsx("div",{className:"sidebar-cache-state",children:"当前显示缓存目录"}),j&&e.jsxs("div",{className:"sidebar-load-error",title:j,children:[e.jsx("span",{children:u.length>0?"目录刷新失败,当前显示缓存":"目录加载失败"}),e.jsx("button",{type:"button",onClick:()=>void bn(a,{refresh:u.length>0}),children:"重试"})]})]})}),e.jsx("div",{className:"sidebar-bottom-action",children:e.jsx("button",{type:"button",className:"sidebar-new-session-primary",disabled:Ke!==null||O!==null&&$.has(O)||((fr=nt.find(p=>p.agentType===a))==null?void 0:fr.available)===!1,"aria-busy":Ke!==null,"aria-disabled":Ke!==null||!O||((es=u.find(p=>p.id===O))==null?void 0:es.canCreateSession)===!1,title:Ke?"正在创建会话":O&&((Qt=u.find(p=>p.id===O))==null?void 0:Qt.canCreateSession)!==!1?"新建会话":"请先选择目录",onClick:Nr,children:Ke?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{size:16,style:{animation:"spin 0.8s linear infinite"},"aria-hidden":"true"}),e.jsx("span",{children:"正在创建..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fi,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]})})})]}),ze&&e.jsx(Of,{message:mf(ze.session),anchor:ze.anchor,mobile:b,pending:J,onCancel:()=>ce(null),onConfirm:()=>void Gt()}),!b&&e.jsx("div",{className:`app-sidebar-resizer${Xr?" is-dragging":""}`,onMouseDown:js,style:{left:Hn}}),N&&e.jsx("div",{onClick:()=>G(!1),style:{position:"fixed",inset:0,zIndex:1300,background:"rgba(17,24,39,0.34)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"12vh 16px 16px"},children:e.jsxs("div",{onClick:p=>p.stopPropagation(),style:{width:"min(560px, 100%)",maxHeight:"64vh",display:"flex",flexDirection:"column",borderRadius:12,border:"1px solid var(--border-default)",background:"var(--bg-surface)",boxShadow:"0 18px 48px rgba(17,24,39,0.28)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:10,borderBottom:"1px solid var(--border-subtle)"},children:e.jsx("input",{autoFocus:!0,value:P,onChange:p=>I(p.target.value),onKeyDown:p=>{p.key==="Escape"&&G(!1)},placeholder:"搜索所有会话(标题或目录)…","aria-label":"搜索所有会话",style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",boxSizing:"border-box"}})}),e.jsxs("div",{style:{overflowY:"auto",padding:8},children:[qt&&An&&An.length>0&&e.jsxs("div",{style:{padding:"4px 10px 3px",fontSize:9,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-muted)"},children:[An.length," 个结果"]}),qt&&An&&An.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"无匹配会话"}),!qt&&bt.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"暂无会话"}),(An??bt.slice(0,ie)).map(p=>{const L=X===p.id,q=lt(p),Q=Ti({status:p.status,isRunning:q,needsInput:q&&hn.includes(p.id)});return e.jsx($i,{session:{id:p.id,title:p.title,visualState:Q,statusLabel:Ni[Q],occupiedExternally:p.agentType!=="codex"&&p.occupancy==="owned-externally",canDelete:p.canDelete,active:L,child:!!p.parentSessionId,compatibility:p.compatibility,pinned:on.has(p.id)},onSelect:()=>{const Y=p.projectId&&u.some(ge=>ge.id===p.projectId)?p.projectId:null;Lt(zi(Y,p.id)),G(!1),b&&F(!1)},onPin:p.parentSessionId?void 0:()=>pn(p.id),onDelete:Y=>Tn(p,Y)},p.id)}),!qt&&bt.length>ie&&e.jsx("button",{type:"button",onClick:()=>Ae(p=>p+10),style:{width:"100%",padding:"8px 10px",border:0,borderTop:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-muted)",fontSize:12,cursor:"pointer",textAlign:"center"},children:"更多…"})]})]})})]}),Mr&&Yt.createPortal(e.jsxs("div",{className:`app-action-notice is-${Vn}`,role:Vn==="error"?"alert":"status","aria-live":Vn==="error"?"assertive":"polite",children:[e.jsx("span",{className:"app-action-notice-mark","aria-hidden":"true",children:Vn==="success"?"✓":Vn==="info"?"i":"!"}),e.jsx("span",{children:Mr})]}),document.body),e.jsxs("main",{className:"app-main",style:{flex:1,overflow:"hidden",background:"var(--bg-workspace)",position:"relative",zIndex:5},children:[Zt==="focus"&&e.jsx("button",{onClick:()=>jn("standard"),title:"返回标准布局",style:{position:"absolute",top:12,left:12,zIndex:100,padding:"5px 10px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",backdropFilter:"blur(8px)",WebkitAppRegion:"no-drag"},children:"← 侧边栏"}),e.jsx("div",{style:{height:"100%",paddingTop:0,display:at?"none":void 0},children:e.jsx(Yp,{activeAgentType:a,selectedProjectId:O,selectedSessionId:X,sessionTitle:dr,sessionSummary:Vt,workspacePath:Fn,voiceCommand:Cr,onOpenSettings:ei,settingsOpen:xe,desktopLiveOpen:xt,onOpenDesktopLive:!an&&((zn=window.agentApi)!=null&&zn.desktopLiveGetStatus)?()=>Bt(!0):void 0,onHideToBackground:()=>void Zs(),onOpenHub:(tn=window.agentApi)!=null&&tn.hubGetConfig?()=>Xt(!0):void 0,onToggleAppearance:Js,appearanceOpen:re,hideToBackgroundTitle:st?`隐藏到后台(说“${zt}”唤醒)`:"隐藏到后台",onSessionCreated:async(p,L)=>{var Q;const q=Re.current;Lt({projectId:q,sessionId:p}),On.current&&(On.current=!1,Sn.current={sessionId:p,until:Date.now()+9e4},(Q=window.agentApi)==null||Q.wakeConversation(!0)),q&&await Kt(q,{pendingSession:L})},onSubSessionCreated:async p=>{await ks(p)},onSelectSession:p=>{ae(p)},onSubAgentEvent:p=>{p.type==="started"?pr({type:"info",title:"子会话已启动",body:`${p.agentName}:${p.task.slice(0,60)}`,sessionId:p.subSessionId}):p.type==="completed"?pr({type:"success",title:"子会话已完成",body:`${p.agentName}:${p.task.slice(0,60)}`,sessionId:p.subSessionId}):pr({type:"error",title:"子会话出错",body:`${p.agentName}:${p.task.slice(0,60)}`,sessionId:p.subSessionId})},onMessageSent:(p,L)=>{T(q=>{const Q={};for(const[Y,ge]of Object.entries(q))Q[Y]=ge.map(de=>de.id===p?{...de,title:L.slice(0,60)||de.title}:de);return Q})},onRunComplete:async(p,L)=>{var ge;const q=Sn.current,Q=wp(q,L);Sn.current=Q,Q!==q&&((ge=window.agentApi)==null||ge.wakeConversation(!0));const Y=p||O;Y&&await Kt(Y,{refresh:!0,background:!0})}})}),at&&e.jsx(df,{onExit:()=>Xt(!1)})]}),xt&&e.jsx(Rf,{onClose:()=>Bt(!1)}),xe&&Yt.createPortal(e.jsx("div",{onClick:()=>kt(!1),style:{position:"fixed",inset:0,zIndex:10001,background:"rgba(17,24,39,0.18)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s var(--ease-out)",WebkitAppRegion:"no-drag"},children:e.jsxs("div",{onClick:p=>p.stopPropagation(),style:{width:"min(920px, calc(100vw - 48px))",height:"min(760px, calc(100vh - 48px))",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"var(--shadow-md)",overflow:"hidden",display:"flex",flexDirection:"column",animation:"fadeInUp 0.25s var(--ease-out)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)",padding:"8px 10px",background:"var(--bg-deepest)"},children:[e.jsx("div",{style:{display:"flex",gap:6},children:Ss.map(p=>e.jsx("button",{onClick:()=>wn(p.id),className:`settings-tab ${mt===p.id?"settings-tab-active":""}`,children:p.label},p.id))}),e.jsx("button",{onClick:()=>kt(!1),title:"关闭",className:"ui-icon-button ui-icon-button--close ui-icon-button--danger",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[mt==="settings"&&e.jsx(jf,{}),mt==="mcp"&&e.jsx(Af,{}),mt==="memory"&&e.jsx(Mf,{}),mt==="skill"&&e.jsx(Tf,{}),mt==="agent"&&e.jsx(Lf,{}),mt==="lsp"&&e.jsx(Pf,{})]})]})}),document.body),e.jsx("div",{className:"noise-overlay"}),re&&Pe&&Yt.createPortal(e.jsx("div",{onClick:()=>pe(!1),style:{position:"fixed",inset:0,zIndex:1e4,WebkitAppRegion:"no-drag"},children:e.jsxs("div",{onClick:p=>p.stopPropagation(),className:"appearance-panel",style:{position:"absolute",left:Math.max(12,Math.min(Pe.right-320,window.innerWidth-332)),top:Pe.bottom+8,width:320,maxHeight:`calc(100vh - ${Pe.bottom+20}px)`,overflowY:"auto",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"16px",display:"flex",flexDirection:"column",gap:16,animation:"fadeInUp 0.2s var(--ease-out)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"皮肤"}),e.jsx("div",{className:"appearance-choices",children:Tc.map(p=>e.jsxs("button",{onClick:()=>Ir(p.id),className:`appearance-choice ${Nt===p.id?"appearance-choice-active":""}`,children:[e.jsx("span",{className:"appearance-swatch",style:{background:`linear-gradient(135deg, ${p.preview[0]} 55%, ${p.preview[1]} 55%)`}}),e.jsx("span",{className:"appearance-choice-label",style:{fontWeight:Nt===p.id?600:400},children:p.label}),Nt===p.id&&e.jsx("svg",{className:"appearance-choice-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},p.id))})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"布局"}),e.jsx("div",{className:"appearance-segmented",children:Nc.map(p=>e.jsx("button",{onClick:()=>jn(p.id),title:p.description,className:`appearance-segment ${Zt===p.id?"appearance-segment-active":""}`,children:p.label},p.id))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,borderTop:"1px solid var(--border-subtle)",paddingTop:12},children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"语音"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--text-secondary)",cursor:"pointer"},children:["助手回复自动播报",e.jsx("input",{className:"appearance-switch",type:"checkbox",checked:sn,onChange:p=>kn(p.target.checked)})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--text-secondary)",cursor:"pointer"},children:["隐藏后语音唤醒",e.jsx("input",{className:"appearance-switch",type:"checkbox",checked:st,onChange:p=>ye(p.target.checked)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-secondary)"},children:[e.jsx("span",{style:{flexShrink:0},children:"唤醒词"}),e.jsx("input",{value:zt,onChange:p=>Se(p.target.value||"小智"),style:{flex:1,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-deep)",color:"var(--text-primary)",fontSize:12}})]})]})]})}),document.body),e.jsx(Gf,{open:D,onCancel:()=>V(!1),onConfirm:async p=>{await Jr(p),V(!1)}}),e.jsx(Wf,{trigger:He,heardText:Ct}),Er.length>0&&Yt.createPortal(e.jsx("div",{style:{position:"fixed",bottom:24,right:24,zIndex:2e4,display:"flex",flexDirection:"column",gap:10,alignItems:"flex-end",pointerEvents:"none"},children:Er.map(p=>e.jsxs("div",{style:{pointerEvents:"auto",width:320,background:"var(--bg-surface)",border:`1px solid ${p.type==="error"?"rgba(220,38,38,0.25)":p.type==="success"?"rgba(5,150,105,0.25)":"var(--border-default)"}`,borderLeft:`3px solid ${p.type==="error"?"var(--danger)":p.type==="success"?"var(--success)":"var(--accent)"}`,borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"12px 14px",animation:"fadeInUp 0.22s var(--ease-out)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:p.type==="error"?"var(--danger)":p.type==="success"?"var(--success)":"var(--accent)",display:"flex",alignItems:"center",gap:5},children:[p.type==="error"?"✕":p.type==="success"?"✓":"◎"," ",p.title]}),e.jsx("button",{onClick:()=>Kn(p.id),title:"关闭",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:14,lineHeight:1,padding:"2px 4px",borderRadius:4,transition:"color 0.15s"},onMouseEnter:L=>L.currentTarget.style.color="var(--text-primary)",onMouseLeave:L=>L.currentTarget.style.color="var(--text-muted)",children:"×"})]}),e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--text-secondary)",lineHeight:1.5,wordBreak:"break-all"},children:p.body}),p.sessionId&&e.jsx("button",{onClick:()=>{ae(p.sessionId),Kn(p.id)},style:{marginTop:8,padding:"4px 10px",fontSize:11,fontWeight:500,background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--border-glow)",borderRadius:6,cursor:"pointer",transition:"background 0.15s",WebkitAppRegion:"no-drag"},onMouseEnter:L=>L.currentTarget.style.background="var(--accent-glow)",onMouseLeave:L=>L.currentTarget.style.background="var(--accent-dim)",children:"进入会话 →"})]},p.id))}),document.body)]})}export{ah as default};
|