agent-tower 0.7.4-beta.0 → 0.7.4
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/dist/mcp/tools/tasks.js +3 -3
- package/dist/mcp/tools/tasks.js.map +1 -1
- package/dist/mcp/types.js +2 -2
- package/dist/mcp/types.js.map +1 -1
- package/dist/prompts/task-handoff.d.ts.map +1 -1
- package/dist/prompts/task-handoff.js +2 -1
- package/dist/prompts/task-handoff.js.map +1 -1
- package/dist/routes/__tests__/sessions-runtime.test.js +2 -0
- package/dist/routes/__tests__/sessions-runtime.test.js.map +1 -1
- package/dist/routes/__tests__/tasks.test.js +41 -0
- package/dist/routes/__tests__/tasks.test.js.map +1 -1
- package/dist/routes/__tests__/workspace-history.test.d.ts +2 -0
- package/dist/routes/__tests__/workspace-history.test.d.ts.map +1 -0
- package/dist/routes/__tests__/workspace-history.test.js +174 -0
- package/dist/routes/__tests__/workspace-history.test.js.map +1 -0
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +10 -0
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/tasks.d.ts.map +1 -1
- package/dist/routes/tasks.js +8 -0
- package/dist/routes/tasks.js.map +1 -1
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +84 -0
- package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
- package/dist/runtime/cli-driver.js +11 -8
- package/dist/runtime/cli-driver.js.map +1 -1
- package/dist/services/__tests__/task.service.test.js +128 -13
- package/dist/services/__tests__/task.service.test.js.map +1 -1
- package/dist/services/__tests__/workspace.service.test.js +64 -5
- package/dist/services/__tests__/workspace.service.test.js.map +1 -1
- package/dist/services/message-delivery.service.d.ts +1 -0
- package/dist/services/message-delivery.service.d.ts.map +1 -1
- package/dist/services/session-manager.d.ts +4 -0
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +3 -1
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/session-resource-cleanup.d.ts +5 -0
- package/dist/services/session-resource-cleanup.d.ts.map +1 -1
- package/dist/services/session-resource-cleanup.js +7 -0
- package/dist/services/session-resource-cleanup.js.map +1 -1
- package/dist/services/task-cleanup.service.d.ts +2 -0
- package/dist/services/task-cleanup.service.d.ts.map +1 -1
- package/dist/services/task-cleanup.service.js +4 -0
- package/dist/services/task-cleanup.service.js.map +1 -1
- package/dist/services/task-display-state.d.ts +10 -0
- package/dist/services/task-display-state.d.ts.map +1 -0
- package/dist/services/task-display-state.js +45 -0
- package/dist/services/task-display-state.js.map +1 -0
- package/dist/services/task.service.d.ts +20 -1
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +134 -101
- package/dist/services/task.service.js.map +1 -1
- package/dist/services/workspace.service.d.ts +10 -7
- package/dist/services/workspace.service.d.ts.map +1 -1
- package/dist/services/workspace.service.js +160 -88
- package/dist/services/workspace.service.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-JXetlNBf.js → AgentDemoPage-D9bIiALx.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-CdYyUCwJ.js → AgentEnvironmentSettingsPage-BE0RC6fR.js} +1 -1
- package/dist/web/assets/{AttachmentPreview-DMS-PM-1.js → AttachmentPreview-TPd4gdfb.js} +2 -2
- package/dist/web/assets/{BranchSelect-BAq4L2ZS.js → BranchSelect-Kv3M1YhZ.js} +1 -1
- package/dist/web/assets/{BrandLogo--kWXXJtZ.js → BrandLogo-fR2lCwEo.js} +1 -1
- package/dist/web/assets/{ConversationPage-CvC4RyB5.js → ConversationPage-BZiMHI9T.js} +1 -1
- package/dist/web/assets/{CreateTaskInput-DjVxCAfc.js → CreateTaskInput-TcZpjBe-.js} +1 -1
- package/dist/web/assets/{DemoPage-cDVTGOp8.js → DemoPage-DwpThe16.js} +1 -1
- package/dist/web/assets/{DesignSystemPage-BI54IkKi.js → DesignSystemPage-DH9_cygJ.js} +1 -1
- package/dist/web/assets/{ExecutionPermissionSelector-f1UYIm1z.js → ExecutionPermissionSelector-C-akTOVg.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-C0yto6C_.js → GeneralSettingsPage-v2w1eofz.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-BiJSaHUi.js → LoadingPreviewPage-pgk3PWM9.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-BbHwZtyj.js → McpSettingsPage-w1DOlY5V.js} +1 -1
- package/dist/web/assets/{MemberAvatar-BLezO3vS.js → MemberAvatar-CJtylxwu.js} +1 -1
- package/dist/web/assets/MobileTaskDetail-D5Czlr2O.js +3 -0
- package/dist/web/assets/{NotificationSettingsPage-CiKoL2Kv.js → NotificationSettingsPage-CkLg4WvT.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-DCB48cPS.js → ProfileSettingsPage-B3yzbY1V.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-CuGSLvrU.js +14 -0
- package/dist/web/assets/{ProjectSettingsPage-COvIVq1h.js → ProjectSettingsPage-DoklOfna.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-CPuJcZDg.js → ProviderSettingsPage-Cm0hbX5n.js} +2 -2
- package/dist/web/assets/{SettingsMasterDetail-Cv7YaRJB.js → SettingsMasterDetail-CGCUalkW.js} +1 -1
- package/dist/web/assets/TaskDetail-BiZbuXcE.js +1 -0
- package/dist/web/assets/{TaskHandoffPanel-CxH3Mgyd.js → TaskHandoffPanel-CJahUKNo.js} +24 -24
- package/dist/web/assets/{TeamSettingsPage-D-XDefNd.js → TeamSettingsPage-CyppRTaY.js} +1 -1
- package/dist/web/assets/{TranslationSettingsPage-BPHI-SZW.js → TranslationSettingsPage-BoQXEZmn.js} +1 -1
- package/dist/web/assets/{arc-CC81aLuf.js → arc-5NPBSbiL.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-DL08XGaN.js → architectureDiagram-3BPJPVTR-CqPT-IsX.js} +1 -1
- package/dist/web/assets/{at-sign-DYPIlD6D.js → at-sign-Cf39WHCg.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-B4IW5WxI.js → blockDiagram-GPEHLZMM-BN-1z9KN.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-Cj4d_FqK.js → c4Diagram-AAUBKEIU-CkeLbmQp.js} +1 -1
- package/dist/web/assets/channel-CDkuQ_7m.js +1 -0
- package/dist/web/assets/check-yNWhPvMH.js +1 -0
- package/dist/web/assets/{chevron-down-DNhYsNAt.js → chevron-down-Ct7FZbKm.js} +1 -1
- package/dist/web/assets/{chevron-up-CjrLieBR.js → chevron-up-ARFlXMyO.js} +1 -1
- package/dist/web/assets/{chip-Cf92J-pQ.js → chip-BV_1-tIb.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-DeCj8QSD.js → chunk-2J33WTMH-CWR7tRuT.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-k-6rzQmQ.js → chunk-4BX2VUAB-CAulp4D5.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-qMTCQ5bX.js → chunk-55IACEB6-DqkKXsbD.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-CMnu18d1.js → chunk-727SXJPM-B19m45Sq.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-C0mFbUMn.js → chunk-AQP2D5EJ-CuODwkza.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-u6-_M137.js → chunk-FMBD7UC4-CbUAjtCT.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-DHrIE_8H.js → chunk-ND2GUHAM-C54VxArl.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-aTyC0wZq.js → chunk-QZHKN3VN-D54Uw5fD.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-eHY73FGu.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-eHY73FGu.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-CBIOQOMH.js → code-block-OCS4YCEC-CtAySD1h.js} +1 -1
- package/dist/web/assets/{confirm-dialog-DWeBZLJW.js → confirm-dialog-CCjHVFTv.js} +1 -1
- package/dist/web/assets/{content-JM9E1MeD.js → content-DZozZbBD.js} +2 -2
- package/dist/web/assets/{copy-D0gl9kF8.js → copy-C-jvx2et.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-xLyliSgU.js → cose-bilkent-S5V4N54A-BaB2EVcU.js} +1 -1
- package/dist/web/assets/{cssMode-DO5UnQ64.js → cssMode-wd7JR1S4.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-CbNpoO2d.js → dagre-BM42HDAG-C2j1Y8pO.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CG3hKxAX.js → diagram-2AECGRRQ-CF-EvpV9.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-mQu9M28s.js → diagram-5GNKFQAL-rBNso835.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-BSeEp_Uw.js → diagram-KO2AKTUF-6NW-oos1.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-D6yRdao-.js → diagram-LMA3HP47-DTfRxRLT.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-BUBUW9wD.js → diagram-OG6HWLK6-CS4Ae-hD.js} +1 -1
- package/dist/web/assets/{dialog-D1lkhqVL.js → dialog-DV4wfpNU.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-BQSZgRqq.js → erDiagram-TEJ5UH35-Dw9QQctN.js} +1 -1
- package/dist/web/assets/{file-BijjwxRR.js → file-Btui_I8Z.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-D-eqyr5Y.js → flowDiagram-I6XJVG4X-BGZ9q86S.js} +1 -1
- package/dist/web/assets/{folder-picker-Czxm0_S9.js → folder-picker-DiR-8Qdl.js} +1 -1
- package/dist/web/assets/{freemarker2-B4RvEa_U.js → freemarker2-yVWXzD3l.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-BWGkCt_x.js → ganttDiagram-6RSMTGT7-CkGun0no.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DGVc49pR.js → gitGraphDiagram-PVQCEYII-Bz3oiYvi.js} +1 -1
- package/dist/web/assets/{globe-Ce01-45x.js → globe-DAFqpAcW.js} +1 -1
- package/dist/web/assets/{handlebars-oyT7drqS.js → handlebars-BPf0z6eN.js} +1 -1
- package/dist/web/assets/{html-CxxWf2Qk.js → html-HCTCjfUg.js} +1 -1
- package/dist/web/assets/{htmlMode-RfAHh5Jj.js → htmlMode-BDkbsknt.js} +1 -1
- package/dist/web/assets/index-408ws6FY.css +1 -0
- package/dist/web/assets/{index-Dh-tgeaL.js → index-B8xoIIa6.js} +4 -4
- package/dist/web/assets/{index-T38iVLEb.js → index-BMcLxIvZ.js} +1 -1
- package/dist/web/assets/{index-DWrSDMX2.js → index-BPqjxXmH.js} +1 -1
- package/dist/web/assets/index-BszkzNS4.js +122 -0
- package/dist/web/assets/{index-DyJfPc4O.js → index-DgUtx9rV.js} +1 -1
- package/dist/web/assets/{index-Pt4TsHjm.js → index-DkSPjZm4.js} +1 -1
- package/dist/web/assets/{index-hpHE1jXY.js → index-DuM6iAxG.js} +1 -1
- package/dist/web/assets/{index-BMZFF1UJ.js → index-GuczxPxb.js} +1 -1
- package/dist/web/assets/{index-Disv1kQS.js → index-lZLy5rkr.js} +1 -1
- package/dist/web/assets/{infoDiagram-5YYISTIA-DLPs3dV_.js → infoDiagram-5YYISTIA-DYFufUYC.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-d_OrnwDY.js → ishikawaDiagram-YF4QCWOH-IOkrKRwu.js} +1 -1
- package/dist/web/assets/javascript-DKmxrNeR.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-EtU1st_0.js → journeyDiagram-JHISSGLW-Btl3yxne.js} +1 -1
- package/dist/web/assets/{jsonMode-Bqh5vIxx.js → jsonMode-DJPdvFcw.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-ZWzUnsFK.js → kanban-definition-UN3LZRKU-CDryhPbA.js} +1 -1
- package/dist/web/assets/{kbd-IjDGsZ2B.js → kbd-8RRRm9jd.js} +1 -1
- package/dist/web/assets/{key-round-CbnAuUxp.js → key-round-wojrCrDP.js} +1 -1
- package/dist/web/assets/{layers-Pdy9vZ6K.js → layers-BH_LL4b8.js} +1 -1
- package/dist/web/assets/{linear-D7n23wcA.js → linear-BLuwKHze.js} +1 -1
- package/dist/web/assets/{link-Bl1ZbjFh.js → link-jWQOSQOQ.js} +1 -1
- package/dist/web/assets/{liquid-Ds47iVLN.js → liquid-1y-xg637.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-Dcch3bsp.js → lspLanguageFeatures-cYkILdCn.js} +1 -1
- package/dist/web/assets/{mdx-CM7ky-2B.js → mdx-CRg4Q6aP.js} +1 -1
- package/dist/web/assets/{menu-DubntFHq.js → menu-CMqbaDni.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-nBsnjgeU.js → mermaid-NOHMQCX5-CYeAhOl-.js} +4 -4
- package/dist/web/assets/{message-square-BE-pW0m_.js → message-square-DykJ2lWP.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-ClHORNTt.js → mindmap-definition-RKZ34NQL-B5wtw1Rv.js} +1 -1
- package/dist/web/assets/{modal-CHLtZWvx.js → modal-BwOwTzij.js} +1 -1
- package/dist/web/assets/{monaco-BbAmalE2.js → monaco-CcHqpOKe.js} +3 -3
- package/dist/web/assets/{nav-row-DH7rNq1V.js → nav-row-BmtdNLxR.js} +1 -1
- package/dist/web/assets/{paperclip-YP3Bk1lI.js → paperclip-C4t49vX2.js} +1 -1
- package/dist/web/assets/{pencil-BFDuhbtW.js → pencil-BQ5_raiB.js} +1 -1
- package/dist/web/assets/{people-DEeNaaLt.js → people-Dr0v8HK0.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-BUOaKIyP.js → pieDiagram-4H26LBE5-BZ3VoaNI.js} +1 -1
- package/dist/web/assets/{popover-CUmBEXxL.js → popover-CTqvKqTR.js} +1 -1
- package/dist/web/assets/{python-BODTtU6m.js → python-Huq_acyd.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Caezg-U2.js → quadrantDiagram-W4KKPZXB-C6ArHmnG.js} +1 -1
- package/dist/web/assets/{razor-CHm8DY1p.js → razor-Clc87Ivb.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-BtdP3Ka6.js → requirementDiagram-4Y6WPE33-DiLzBRQP.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-Bv74oA-n.js → sankeyDiagram-5OEKKPKP-QlYYd7IZ.js} +1 -1
- package/dist/web/assets/{search-ClmOQd4H.js → search-CMIAPUEt.js} +1 -1
- package/dist/web/assets/{select-CYtYPr-c.js → select-Bg7NI8i0.js} +1 -1
- package/dist/web/assets/{select-BB7QG08o.js → select-DqB7YF38.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DuNPl-dg.js → sequenceDiagram-3UESZ5HK-COKEtqc0.js} +1 -1
- package/dist/web/assets/{server-bEB_DY55.js → server-D7knl8H9.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-B72HAgBJ.js → stateDiagram-AJRCARHV-1RZZZdOe.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CCLmVs34.js +1 -0
- package/dist/web/assets/{textarea-BqYPvoO-.js → textarea-BCY2J2ca.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-DTmHUgmQ.js → timeline-definition-PNZ67QCA-IJl1LY6J.js} +1 -1
- package/dist/web/assets/{toggles-a5fkwT_D.js → toggles-C4LmZwyo.js} +1 -1
- package/dist/web/assets/{tooltip-DuyJMci9.js → tooltip-Cirpotu3.js} +1 -1
- package/dist/web/assets/{track-DCjyrv3n.js → track-Cv7h6oaE.js} +1 -1
- package/dist/web/assets/{trash-2-CIyBqaVy.js → trash-2-BEOQ1ICJ.js} +1 -1
- package/dist/web/assets/{tsMode-C1UXAkMh.js → tsMode-CHIbCBQc.js} +1 -1
- package/dist/web/assets/{typescript-Biht2wHb.js → typescript-CScj0bbb.js} +1 -1
- package/dist/web/assets/{upload-D05XS5-G.js → upload-tLVD0xMT.js} +1 -1
- package/dist/web/assets/{use-profiles-CrWTyz1G.js → use-profiles-TkoP4Yw9.js} +1 -1
- package/dist/web/assets/{use-providers-Dv1Nk6s7.js → use-providers-Bz6YNiYj.js} +1 -1
- package/dist/web/assets/{use-translation-settings-CcUnipVO.js → use-translation-settings-CCpQNS30.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-D9W1cT4R.js → useNormalizedLogs-Bstb98cF.js} +1 -1
- package/dist/web/assets/{useTokenUsage-CZ5mDshD.js → useTokenUsage-D7SEwXb0.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-ByoNydXe.js → vennDiagram-CIIHVFJN-DzVayy4U.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-BqdMkOLl.js → wardley-L42UT6IY-CULSKh55.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-AO22HrEF.js → wardleyDiagram-YWT4CUSO-C5_h3lAA.js} +1 -1
- package/dist/web/assets/{xml-NLGqNFDv.js → xml-XuycSwh6.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-vzPgjgqW.js → xychartDiagram-2RQKCTM6-F65naXcR.js} +1 -1
- package/dist/web/assets/{yaml-AWlGS_Ig.js → yaml-BWm159lw.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/index.d.ts +1 -0
- package/node_modules/@agent-tower/shared/dist/index.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/index.js +1 -0
- package/node_modules/@agent-tower/shared/dist/index.js.map +1 -1
- package/node_modules/@agent-tower/shared/dist/task-hierarchy.d.ts +17 -0
- package/node_modules/@agent-tower/shared/dist/task-hierarchy.d.ts.map +1 -0
- package/node_modules/@agent-tower/shared/dist/task-hierarchy.js +12 -0
- package/node_modules/@agent-tower/shared/dist/task-hierarchy.js.map +1 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts +20 -4
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20261027000000_preserve_workspace_history/migration.sql +2 -0
- package/prisma/schema.prisma +2 -0
- package/dist/web/assets/MobileTaskDetail-M_Kke9rL.js +0 -3
- package/dist/web/assets/ProjectKanbanPage-soDqevjQ.js +0 -12
- package/dist/web/assets/TaskDetail-CqhPxvg3.js +0 -1
- package/dist/web/assets/channel-CUa8oyzC.js +0 -1
- package/dist/web/assets/check-DaZqOL8l.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BAx111NO.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BAx111NO.js +0 -1
- package/dist/web/assets/index-BN53vGxp.css +0 -1
- package/dist/web/assets/index-Cc3qXMhU.js +0 -122
- package/dist/web/assets/javascript-BNXtViSL.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Bu3l_CgB.js +0 -1
package/dist/web/assets/{ProviderSettingsPage-CPuJcZDg.js → ProviderSettingsPage-Cm0hbX5n.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as dt,m as ct,q as mt,p as ut,u as J,r as y,j as e,l as D,a9 as Fe,ae as Pe,b3 as X,b4 as E,b5 as fe,I as ne,b6 as xt,b7 as pt,_ as le,B as A,a3 as ft,S as Oe,aU as gt,h as ht,b8 as vt,E as bt,b9 as jt,ba as yt,t as U,au as Nt,k as pe,bb as wt,aC as ye}from"./index-Cc3qXMhU.js";import{c as Ct,b as Pt,r as Je,d as De,u as kt,e as Et,E as St,f as It,s as At,i as Re,h as Ue,a as $e,j as Ne,k as Tt,l as _t,m as Ot,p as Dt,n as Rt,o as Ut,q as Le,w as Lt,t as Kt}from"./ExecutionPermissionSelector-f1UYIm1z.js";import{a as Mt,b as Bt,u as zt,c as Ft,d as Jt,e as $t,f as qt,g as Wt,h as Gt}from"./use-providers-Dv1Nk6s7.js";import{C as Xt}from"./confirm-dialog-DWeBZLJW.js";import{M as ke}from"./modal-CHLtZWvx.js";import{S as Ke}from"./select-BB7QG08o.js";import{T as Me}from"./textarea-BqYPvoO-.js";import{S as Ee}from"./toggles-a5fkwT_D.js";import"./mermaid-NOHMQCX5-nBsnjgeU.js";import"./AttachmentPreview-DMS-PM-1.js";import{C as qe}from"./chevron-down-DNhYsNAt.js";import{S as Vt}from"./SettingsMasterDetail-Cv7YaRJB.js";import{K as Yt}from"./key-round-CbnAuUxp.js";import{T as We,P as we}from"./trash-2-CIyBqaVy.js";import{U as Ht}from"./upload-D05XS5-G.js";import{P as Zt}from"./pencil-BFDuhbtW.js";import"./check-DaZqOL8l.js";import"./dialog-D1lkhqVL.js";import"./index-DWrSDMX2.js";import"./select-CYtYPr-c.js";import"./menu-styles-DWynpVVz.js";import"./index-BMZFF1UJ.js";import"./index-Disv1kQS.js";import"./index-T38iVLEb.js";import"./index-Pt4TsHjm.js";import"./index-hpHE1jXY.js";import"./use-translation-settings-CcUnipVO.js";import"./copy-D0gl9kF8.js";import"./index-DyJfPc4O.js";import"./tooltip-DuyJMci9.js";import"./kbd-IjDGsZ2B.js";const Qt=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],es=dt("flask-conical",Qt);function ts(){return ct({queryKey:mt.system.cursorAgentModels,queryFn:()=>ut.get("/system/cursor-agent-models"),staleTime:1e3*60*10})}function ss({value:t,onChange:i}){const{t:a}=J(),{data:p,isLoading:f,isError:x}=ts(),s=p?.models??[],[S,r]=y.useState(!1),[j,C]=y.useState(""),b=y.useMemo(()=>{const g=j.trim().toLowerCase();return g?s.filter(u=>u.id.toLowerCase().includes(g)||u.label.toLowerCase().includes(g)):s},[s,j]);return e.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-w-0",children:[e.jsx("input",{type:"text",value:t,onChange:g=>{const u=g.target.value;i(u===""?void 0:u)},placeholder:a("留空为 auto;或直接输入模型 ID(与 cursor-agent --model 一致)"),className:"w-full px-3 py-1.5 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring/60 font-mono"}),e.jsxs("button",{type:"button",onClick:()=>r(g=>!g),disabled:f,className:"flex items-center gap-1 text-xs text-foreground/70 hover:text-foreground disabled:opacity-50 w-fit",children:[e.jsx(qe,{size:14,className:D("transition-transform",S&&"rotate-180")}),f?a("正在加载 cursor-agent 模型列表…"):S?a("收起列表"):a("从本机 cursor-agent 选择({count} 个)",{count:s.length})]}),S&&!f&&e.jsxs("div",{className:"rounded-lg border border-border bg-background shadow-raised overflow-hidden",children:[e.jsx("input",{type:"text",value:j,onChange:g=>C(g.target.value),placeholder:a("筛选模型…"),className:"w-full px-3 py-2 text-sm border-b border-border/60 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-ring/60"}),e.jsxs("div",{className:"max-h-[min(50vh,22rem)] overflow-y-auto py-1",children:[e.jsx("button",{type:"button",onClick:()=>{i(void 0),r(!1),C("")},className:D("w-full px-3 py-2 text-left text-sm hover:bg-accent",t?"text-foreground/80":"bg-muted/50 font-medium"),children:a("默认 (auto)")}),b.map(g=>e.jsxs("button",{type:"button",onClick:()=>{i(g.id),r(!1),C("")},className:D("w-full px-3 py-2 text-left text-sm hover:bg-accent border-t border-border/60",t===g.id?"bg-foreground/[0.06]":""),children:[e.jsx("div",{className:"font-mono text-xs text-foreground break-all",children:g.id}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 break-words",children:g.label})]},g.id)),b.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground text-center",children:a("无匹配项")})]})]}),(x||p?.error)&&e.jsxs("p",{className:"text-xs text-warning-ink",children:[a("无法从本机加载模型列表({error})。仍可手动输入;或在安装 cursor-agent 的机器上运行",{error:p?.error??a("请求失败")}),e.jsx("code",{className:"mx-0.5 bg-muted px-1 rounded text-[11px]",children:"cursor-agent --list-models"}),a("查看 ID。")]})]})}function ns(t){if(!t)return null;try{const i=new URL(t);return i.protocol!=="http:"&&i.protocol!=="https:"?null:`${i.origin}${i.pathname}`}catch{return null}}function rs(t,i){if(!t)return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"medium"}).format(a)}function is({result:t}){const{locale:i,t:a}=J(),p=ns(t.target?.endpoint),f=rs(t.testedAt,i);return e.jsx("div",{"data-provider-test-result":!0,className:D("rounded-lg border px-4 py-3 text-sm",t.ok?"border-success/30 bg-success/10 text-success-ink":"border-warning/30 bg-warning/10 text-foreground"),children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.ok?e.jsx(Fe,{size:16,className:"shrink-0"}):e.jsx(Pe,{size:16,className:"shrink-0 text-warning"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium",children:t.ok?t.stage==="connection"?a("连接测试通过"):a("本机可用性检查通过"):a("配置检查未通过")}),e.jsx("div",{className:"mt-0.5 break-words text-xs opacity-80",children:t.summary}),(p||f)&&e.jsxs("dl",{className:"mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs opacity-80",children:[p&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"font-medium",children:a("测试对象")}),e.jsx("dd",{className:"min-w-0",children:e.jsx("code",{className:"break-all",children:p})})]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"font-medium",children:a("测试时间")}),e.jsx("dd",{className:"min-w-0 break-words",children:e.jsx("time",{dateTime:t.testedAt,children:f})})]})]}),!t.ok&&e.jsx("div",{className:"mt-1 text-xs opacity-80",children:a("测试失败不会阻止保存。")})]})]})})}function as({options:t,value:i,onChange:a,label:p,efficiencyLabel:f,intelligenceLabel:x,followCliLabel:s,currentLabel:S,disabled:r=!1,error:j}){const C=t.findIndex(h=>h.value===i),b=i==="",g=y.useRef(C>=0?i:void 0),u=y.useRef(null),P=y.useRef(null),[M,F]=y.useState(!1);y.useEffect(()=>{C>=0&&(g.current=i)},[C,i]);const $=h=>{if(r||b||t.length===0)return;const k=t[Math.max(0,Math.min(t.length-1,h))];k&&k.value!==i&&a(k.value)},V=h=>{const k=P.current?.getBoundingClientRect();if(!k||k.width<=0)return;const q=Math.max(0,Math.min(1,(h-k.left)/k.width));$(Math.round(q*(t.length-1)))},L=C>=0?t[C]:void 0,K=C<0||t.length<2?0:C/(t.length-1)*100,R=y.useId(),Y=`${R}-label`,T=`${R}-current`,O=`${R}-error`;return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3",children:[e.jsx("label",{id:Y,className:"text-xs font-medium text-foreground",children:p}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e.jsx(Ee,{checked:b,disabled:r,onCheckedChange:h=>{a(h?"":g.current??t.find(k=>k.value==="medium")?.value??t[0]?.value??"")},"aria-label":s})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground","aria-hidden":"true",children:[e.jsx("span",{children:f}),e.jsx("span",{children:x})]}),e.jsxs("div",{id:R,ref:P,role:"slider",tabIndex:b||r?-1:0,"aria-labelledby":Y,"aria-disabled":b||r,"aria-valuemin":0,"aria-valuemax":Math.max(0,t.length-1),"aria-valuenow":C>=0?C:void 0,"aria-valuetext":L?`${L.label}, ${L.value}`:s,"aria-describedby":j?`${T} ${O}`:T,onKeyDown:h=>{if(b||r||C<0)return;let k=C;if(h.key==="ArrowLeft"||h.key==="ArrowDown")k-=1;else if(h.key==="ArrowRight"||h.key==="ArrowUp")k+=1;else if(h.key==="Home")k=0;else if(h.key==="End")k=t.length-1;else return;h.preventDefault(),$(k)},onPointerDown:h=>{b||r||(u.current=h.pointerId,F(!0),h.currentTarget.setPointerCapture?.(h.pointerId),V(h.clientX))},onPointerMove:h=>{u.current===h.pointerId&&V(h.clientX)},onPointerUp:h=>{u.current===h.pointerId&&(u.current=null,F(!1),h.currentTarget.releasePointerCapture?.(h.pointerId))},onPointerCancel:()=>{u.current=null,F(!1)},className:D("relative mx-2.5 flex h-11 touch-pan-y items-center outline-none select-none",b||r?"cursor-not-allowed opacity-55":"cursor-pointer","focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2"),children:[e.jsx("div",{className:"absolute inset-x-0 h-1 rounded-full bg-border"}),!b&&e.jsx("div",{className:"absolute left-0 h-1 rounded-full bg-primary transition-[width] duration-150 motion-reduce:transition-none",style:{width:`${K}%`}}),t.map((h,k)=>e.jsx("span",{"aria-hidden":"true",className:D("absolute size-3 -translate-x-1/2 rounded-full border-2 transition-colors motion-reduce:transition-none",!b&&k<=C?"border-primary bg-primary":"border-border bg-background"),style:{left:`${t.length<2?0:k/(t.length-1)*100}%`}},h.value)),!b&&L&&e.jsx("span",{"aria-hidden":"true",className:D("absolute size-5 -translate-x-1/2 rounded-full border-[5px] border-primary bg-background shadow-raised transition-[left,transform] duration-150 motion-reduce:transition-none",M&&"scale-110"),style:{left:`${K}%`}})]}),e.jsx("div",{id:T,className:"min-h-5 text-center text-xs text-muted-foreground",children:b?s:`${S}: ${L?.label??i} (${L?.value??i})`}),j&&e.jsx("p",{id:O,role:"alert",className:"text-xs text-destructive-ink",children:j})]})}const z={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},Ge={[E.CLAUDE_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},z],[E.GEMINI_CLI]:[{key:"yolo",label:"自动批准操作(YOLO)",type:"switch"},z],[E.CURSOR_AGENT]:[{key:"force",label:"强制执行",type:"switch"},z],[E.CODEX]:[{key:"dangerouslyBypassApprovalsAndSandbox",label:"跳过所有确认和沙盒",type:"switch"},{key:"fastMode",label:"Fast 模式",type:"switch"},{key:"disableResponsesWebsocket",label:"禁用 WebSocket",type:"switch"},{key:"profile",label:"Profile",type:"input",placeholder:"~/.codex/config.toml 中的 profile 名称"},z],[E.QWEN_CODE]:[z],[E.KIRO_CLI]:[{key:"trustAllTools",label:"信任所有工具",type:"switch"},z],[E.OPENCODE]:[{key:"autoApprove",label:"自动批准操作",type:"switch"},z],[E.PI_CODING_AGENT]:[{key:"autoApprove",label:"自动批准操作",type:"switch"},{key:"supportsImages",label:"模型支持图片输入",type:"switch"},z],[E.GROK_BUILD]:[{key:"alwaysApprove",label:"始终批准操作",type:"switch"},z],[E.MINION_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},z]};function Be(){return{}}function Xe(t,i){return{...i}}const os=JSON.stringify({env:{ANTHROPIC_API_KEY:"",ANTHROPIC_BASE_URL:""}},null,2),ls=`# Codex config.toml 配置片段 — 通过 -c 参数注入,不会修改 ~/.codex/config.toml
|
|
1
|
+
import{c as dt,m as ct,q as mt,p as ut,u as J,r as y,j as e,l as D,a9 as Fe,ae as Ce,b4 as X,b5 as E,b6 as fe,I as ne,b7 as xt,b8 as pt,_ as le,B as A,a3 as ft,S as Oe,aV as gt,h as ht,b9 as vt,E as bt,ba as jt,bb as yt,t as U,av as Nt,k as pe,bc as wt,aD as ye}from"./index-BszkzNS4.js";import{c as Pt,b as Ct,r as Je,d as De,u as kt,e as Et,E as St,f as It,s as At,i as Re,h as Ue,a as $e,j as Ne,k as Tt,l as _t,m as Ot,p as Dt,n as Rt,o as Ut,q as Le,w as Lt,t as Kt}from"./ExecutionPermissionSelector-C-akTOVg.js";import{a as Mt,b as Bt,u as zt,c as Ft,d as Jt,e as $t,f as qt,g as Wt,h as Gt}from"./use-providers-Bz6YNiYj.js";import{C as Xt}from"./confirm-dialog-CCjHVFTv.js";import{M as ke}from"./modal-BwOwTzij.js";import{S as Ke}from"./select-DqB7YF38.js";import{T as Me}from"./textarea-BCY2J2ca.js";import{S as Ee}from"./toggles-C4LmZwyo.js";import"./mermaid-NOHMQCX5-CYeAhOl-.js";import"./AttachmentPreview-TPd4gdfb.js";import{C as qe}from"./chevron-down-Ct7FZbKm.js";import{S as Vt}from"./SettingsMasterDetail-CGCUalkW.js";import{K as Yt}from"./key-round-wojrCrDP.js";import{T as We,P as we}from"./trash-2-BEOQ1ICJ.js";import{U as Ht}from"./upload-tLVD0xMT.js";import{P as Zt}from"./pencil-BQ5_raiB.js";import"./check-yNWhPvMH.js";import"./dialog-DV4wfpNU.js";import"./index-BPqjxXmH.js";import"./select-Bg7NI8i0.js";import"./menu-styles-DWynpVVz.js";import"./index-GuczxPxb.js";import"./index-lZLy5rkr.js";import"./index-BMcLxIvZ.js";import"./index-DkSPjZm4.js";import"./index-DuM6iAxG.js";import"./use-translation-settings-CCpQNS30.js";import"./copy-C-jvx2et.js";import"./index-DgUtx9rV.js";import"./tooltip-Cirpotu3.js";import"./kbd-8RRRm9jd.js";const Qt=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],es=dt("flask-conical",Qt);function ts(){return ct({queryKey:mt.system.cursorAgentModels,queryFn:()=>ut.get("/system/cursor-agent-models"),staleTime:1e3*60*10})}function ss({value:t,onChange:i}){const{t:a}=J(),{data:p,isLoading:f,isError:x}=ts(),s=p?.models??[],[S,r]=y.useState(!1),[j,P]=y.useState(""),b=y.useMemo(()=>{const g=j.trim().toLowerCase();return g?s.filter(u=>u.id.toLowerCase().includes(g)||u.label.toLowerCase().includes(g)):s},[s,j]);return e.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-w-0",children:[e.jsx("input",{type:"text",value:t,onChange:g=>{const u=g.target.value;i(u===""?void 0:u)},placeholder:a("留空为 auto;或直接输入模型 ID(与 cursor-agent --model 一致)"),className:"w-full px-3 py-1.5 text-sm border border-border rounded focus:outline-none focus:ring-1 focus:ring-ring/60 font-mono"}),e.jsxs("button",{type:"button",onClick:()=>r(g=>!g),disabled:f,className:"flex items-center gap-1 text-xs text-foreground/70 hover:text-foreground disabled:opacity-50 w-fit",children:[e.jsx(qe,{size:14,className:D("transition-transform",S&&"rotate-180")}),f?a("正在加载 cursor-agent 模型列表…"):S?a("收起列表"):a("从本机 cursor-agent 选择({count} 个)",{count:s.length})]}),S&&!f&&e.jsxs("div",{className:"rounded-lg border border-border bg-background shadow-raised overflow-hidden",children:[e.jsx("input",{type:"text",value:j,onChange:g=>P(g.target.value),placeholder:a("筛选模型…"),className:"w-full px-3 py-2 text-sm border-b border-border/60 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-ring/60"}),e.jsxs("div",{className:"max-h-[min(50vh,22rem)] overflow-y-auto py-1",children:[e.jsx("button",{type:"button",onClick:()=>{i(void 0),r(!1),P("")},className:D("w-full px-3 py-2 text-left text-sm hover:bg-accent",t?"text-foreground/80":"bg-muted/50 font-medium"),children:a("默认 (auto)")}),b.map(g=>e.jsxs("button",{type:"button",onClick:()=>{i(g.id),r(!1),P("")},className:D("w-full px-3 py-2 text-left text-sm hover:bg-accent border-t border-border/60",t===g.id?"bg-foreground/[0.06]":""),children:[e.jsx("div",{className:"font-mono text-xs text-foreground break-all",children:g.id}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 break-words",children:g.label})]},g.id)),b.length===0&&e.jsx("div",{className:"px-3 py-4 text-xs text-muted-foreground text-center",children:a("无匹配项")})]})]}),(x||p?.error)&&e.jsxs("p",{className:"text-xs text-warning-ink",children:[a("无法从本机加载模型列表({error})。仍可手动输入;或在安装 cursor-agent 的机器上运行",{error:p?.error??a("请求失败")}),e.jsx("code",{className:"mx-0.5 bg-muted px-1 rounded text-[11px]",children:"cursor-agent --list-models"}),a("查看 ID。")]})]})}function ns(t){if(!t)return null;try{const i=new URL(t);return i.protocol!=="http:"&&i.protocol!=="https:"?null:`${i.origin}${i.pathname}`}catch{return null}}function rs(t,i){if(!t)return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"medium"}).format(a)}function is({result:t}){const{locale:i,t:a}=J(),p=ns(t.target?.endpoint),f=rs(t.testedAt,i);return e.jsx("div",{"data-provider-test-result":!0,className:D("rounded-lg border px-4 py-3 text-sm",t.ok?"border-success/30 bg-success/10 text-success-ink":"border-warning/30 bg-warning/10 text-foreground"),children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.ok?e.jsx(Fe,{size:16,className:"shrink-0"}):e.jsx(Ce,{size:16,className:"shrink-0 text-warning"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium",children:t.ok?t.stage==="connection"?a("连接测试通过"):a("本机可用性检查通过"):a("配置检查未通过")}),e.jsx("div",{className:"mt-0.5 break-words text-xs opacity-80",children:t.summary}),(p||f)&&e.jsxs("dl",{className:"mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs opacity-80",children:[p&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"font-medium",children:a("测试对象")}),e.jsx("dd",{className:"min-w-0",children:e.jsx("code",{className:"break-all",children:p})})]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"font-medium",children:a("测试时间")}),e.jsx("dd",{className:"min-w-0 break-words",children:e.jsx("time",{dateTime:t.testedAt,children:f})})]})]}),!t.ok&&e.jsx("div",{className:"mt-1 text-xs opacity-80",children:a("测试失败不会阻止保存。")})]})]})})}function as({options:t,value:i,onChange:a,label:p,efficiencyLabel:f,intelligenceLabel:x,followCliLabel:s,currentLabel:S,disabled:r=!1,error:j}){const P=t.findIndex(h=>h.value===i),b=i==="",g=y.useRef(P>=0?i:void 0),u=y.useRef(null),C=y.useRef(null),[M,F]=y.useState(!1);y.useEffect(()=>{P>=0&&(g.current=i)},[P,i]);const $=h=>{if(r||b||t.length===0)return;const k=t[Math.max(0,Math.min(t.length-1,h))];k&&k.value!==i&&a(k.value)},V=h=>{const k=C.current?.getBoundingClientRect();if(!k||k.width<=0)return;const q=Math.max(0,Math.min(1,(h-k.left)/k.width));$(Math.round(q*(t.length-1)))},L=P>=0?t[P]:void 0,K=P<0||t.length<2?0:P/(t.length-1)*100,R=y.useId(),Y=`${R}-label`,T=`${R}-current`,O=`${R}-error`;return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-3",children:[e.jsx("label",{id:Y,className:"text-xs font-medium text-foreground",children:p}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:s}),e.jsx(Ee,{checked:b,disabled:r,onCheckedChange:h=>{a(h?"":g.current??t.find(k=>k.value==="medium")?.value??t[0]?.value??"")},"aria-label":s})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground","aria-hidden":"true",children:[e.jsx("span",{children:f}),e.jsx("span",{children:x})]}),e.jsxs("div",{id:R,ref:C,role:"slider",tabIndex:b||r?-1:0,"aria-labelledby":Y,"aria-disabled":b||r,"aria-valuemin":0,"aria-valuemax":Math.max(0,t.length-1),"aria-valuenow":P>=0?P:void 0,"aria-valuetext":L?`${L.label}, ${L.value}`:s,"aria-describedby":j?`${T} ${O}`:T,onKeyDown:h=>{if(b||r||P<0)return;let k=P;if(h.key==="ArrowLeft"||h.key==="ArrowDown")k-=1;else if(h.key==="ArrowRight"||h.key==="ArrowUp")k+=1;else if(h.key==="Home")k=0;else if(h.key==="End")k=t.length-1;else return;h.preventDefault(),$(k)},onPointerDown:h=>{b||r||(u.current=h.pointerId,F(!0),h.currentTarget.setPointerCapture?.(h.pointerId),V(h.clientX))},onPointerMove:h=>{u.current===h.pointerId&&V(h.clientX)},onPointerUp:h=>{u.current===h.pointerId&&(u.current=null,F(!1),h.currentTarget.releasePointerCapture?.(h.pointerId))},onPointerCancel:()=>{u.current=null,F(!1)},className:D("relative mx-2.5 flex h-11 touch-pan-y items-center outline-none select-none",b||r?"cursor-not-allowed opacity-55":"cursor-pointer","focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2"),children:[e.jsx("div",{className:"absolute inset-x-0 h-1 rounded-full bg-border"}),!b&&e.jsx("div",{className:"absolute left-0 h-1 rounded-full bg-primary transition-[width] duration-150 motion-reduce:transition-none",style:{width:`${K}%`}}),t.map((h,k)=>e.jsx("span",{"aria-hidden":"true",className:D("absolute size-3 -translate-x-1/2 rounded-full border-2 transition-colors motion-reduce:transition-none",!b&&k<=P?"border-primary bg-primary":"border-border bg-background"),style:{left:`${t.length<2?0:k/(t.length-1)*100}%`}},h.value)),!b&&L&&e.jsx("span",{"aria-hidden":"true",className:D("absolute size-5 -translate-x-1/2 rounded-full border-[5px] border-primary bg-background shadow-raised transition-[left,transform] duration-150 motion-reduce:transition-none",M&&"scale-110"),style:{left:`${K}%`}})]}),e.jsx("div",{id:T,className:"min-h-5 text-center text-xs text-muted-foreground",children:b?s:`${S}: ${L?.label??i} (${L?.value??i})`}),j&&e.jsx("p",{id:O,role:"alert",className:"text-xs text-destructive-ink",children:j})]})}const z={key:"appendPrompt",label:"追加 Prompt",type:"textarea",rows:3,placeholder:"追加到每次 prompt 末尾的文本"},Ge={[E.CLAUDE_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},z],[E.GEMINI_CLI]:[{key:"yolo",label:"自动批准操作(YOLO)",type:"switch"},z],[E.CURSOR_AGENT]:[{key:"force",label:"强制执行",type:"switch"},z],[E.CODEX]:[{key:"dangerouslyBypassApprovalsAndSandbox",label:"跳过所有确认和沙盒",type:"switch"},{key:"fastMode",label:"Fast 模式",type:"switch"},{key:"disableResponsesWebsocket",label:"禁用 WebSocket",type:"switch"},{key:"profile",label:"Profile",type:"input",placeholder:"~/.codex/config.toml 中的 profile 名称"},z],[E.QWEN_CODE]:[z],[E.KIRO_CLI]:[{key:"trustAllTools",label:"信任所有工具",type:"switch"},z],[E.OPENCODE]:[{key:"autoApprove",label:"自动批准操作",type:"switch"},z],[E.PI_CODING_AGENT]:[{key:"autoApprove",label:"自动批准操作",type:"switch"},{key:"supportsImages",label:"模型支持图片输入",type:"switch"},z],[E.GROK_BUILD]:[{key:"alwaysApprove",label:"始终批准操作",type:"switch"},z],[E.MINION_CODE]:[{key:"dangerouslySkipPermissions",label:"跳过权限确认",type:"switch"},z]};function Be(){return{}}function Xe(t,i){return{...i}}const os=JSON.stringify({env:{ANTHROPIC_API_KEY:"",ANTHROPIC_BASE_URL:""}},null,2),ls=`# Codex config.toml 配置片段 — 通过 -c 参数注入,不会修改 ~/.codex/config.toml
|
|
2
2
|
# 参考: https://developers.openai.com/codex/config-sample
|
|
3
3
|
|
|
4
4
|
# ─── 模型与推理 ─────────────────────────────────────────────
|
|
@@ -64,4 +64,4 @@ import{c as dt,m as ct,q as mt,p as ut,u as J,r as y,j as e,l as D,a9 as Fe,ae a
|
|
|
64
64
|
# name = "Ollama"
|
|
65
65
|
# base_url = "http://localhost:11434/v1"
|
|
66
66
|
# wire_api = "responses"
|
|
67
|
-
`;function cs(t,i){return t===E.CLAUDE_CODE?os:t===E.CODEX?i==="zh-CN"?ls:ds:""}function ms(t){return t===E.CLAUDE_CODE||t===E.CODEX}const Ce="::ACP";function ze(t,i){return i===X.ACP?`${t}${Ce}`:String(t)}function de(t,i){const a=yt(t);return i===X.ACP?`${a} (ACP)`:a}function us(t){return t.endsWith(Ce)?{agentType:t.slice(0,-Ce.length),runtimeType:X.ACP}:{agentType:t,runtimeType:X.CLI}}function xs(t,i){if(!t.trim())return t;try{const a=JSON.parse(t);if(!a.env||typeof a.env!="object"||Array.isArray(a.env))return t;const p=a.env;return i in p?(delete p[i],JSON.stringify(a,null,2)):t}catch{return t}}const Ve=Object.values(Ge).flat().reduce((t,i)=>(t[i.key]||(t[i.key]=i.label),t),{});Ve.permissionMode="权限策略";const Ye=Object.values(Ge).flat().reduce((t,i)=>(i.options&&(t[i.key]=Object.fromEntries(i.options.map(a=>[a.value,a.label]))),t),{});Ye.permissionMode={ASK:"每次询问",AUTO_APPROVE:"无限制",UNRESTRICTED:"无限制"};function ps(t,i){if(typeof i=="boolean")return i?ye("是"):ye("否");if(typeof i=="string"&&i){const a=Ye[t]?.[i];return a?ye(a):i}return String(i)}function G(t,i){return t instanceof Error?t.message:i}function fs(t){return t==="apiBaseUrl"?"API 地址":t==="apiKey"?"API Key":t==="reasoningEffort"?"思考强度":t==="model"?"模型":t==="executionPermission"?"执行权限":t==="fastMode"?"Fast 模式":t==="disableResponsesWebsocket"?"禁用 WebSocket":t}function gs(t){return{minimal:"最低",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最高",ultra:"Ultra"}[t]??t}function hs(t){return`agent-tower-provider-backup-${t.replace(/[:.]/g,"-")}.json`}function vs(t,i){const a=new Blob([JSON.stringify(i,null,2)],{type:"application/json"}),p=URL.createObjectURL(a),f=document.createElement("a");f.href=p,f.download=t,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p)}function bs(t){switch(t){case"CREATE":return{label:"新增",className:"bg-success/10 text-success-ink"};case"OVERWRITE":return{label:"覆盖",className:"bg-warning/10 text-warning-ink"};case"SKIP":return{label:"跳过",className:"bg-muted text-muted-foreground"}}}function js({issue:t,disabled:i=!1}){const{t:a}=J(),p=!i&&!t,f=a(i?"已禁用":p?"可用":"不可用");return e.jsx("span",{className:D("inline-block h-2 w-2 rounded-full shrink-0",p?"bg-success":"bg-border"),title:i?f:t?`${f}: ${a(t)}`:f,children:e.jsx("span",{className:"sr-only",children:f})})}function ys({issue:t,disabled:i=!1}){const{t:a}=J();return!i&&!t?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success-ink",children:[e.jsx(Fe,{size:11,"aria-hidden":"true"}),a("可用")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[e.jsx(wt,{size:11,"aria-hidden":"true"}),a(i?"已禁用":"不可用")]})}function Ns({title:t,status:i,defaultOpen:a=!1,children:p}){const[f,x]=y.useState(a);return e.jsxs("div",{className:"rounded-lg border border-border",children:[e.jsxs("button",{type:"button",onClick:()=>x(s=>!s),"aria-expanded":f,className:"w-full flex items-center justify-between rounded-lg px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t}),i]}),e.jsx(qe,{size:14,"aria-hidden":"true",className:D("text-muted-foreground transition-transform motion-reduce:transition-none",f&&"rotate-180")})]}),f&&e.jsx("div",{className:"px-4 pb-4 space-y-3",children:p})]})}function ws({isOpen:t,onClose:i,providerId:a,initialData:p,onSave:f}){const{locale:x,t:s}=J(),S=Mt(),[r,j]=y.useState(p??{name:"",agentType:E.CLAUDE_CODE,runtimeType:X.CLI,executionPermission:"ASK",config:Be(),settings:"",env:[],simplified:{apiKey:{configured:!1,envKey:"ANTHROPIC_API_KEY"}},diagnostics:[],isDefault:!1}),[C,b]=y.useState(()=>JSON.stringify(r.config,null,2)),[g,u]=y.useState(""),[P,M]=y.useState(()=>r.diagnostics?.find(n=>n.field==="settings")?.message??""),[F,$]=y.useState(!1),[V,L]=y.useState(!1),[K,R]=y.useState(null),[Y,T]=y.useState(()=>new Set),[O,h]=y.useState(()=>r.diagnostics?.filter(n=>n.code==="CONFLICT")??[]),[k,q]=y.useState({}),Q=y.useRef(Ct()),{data:ge}=Bt(r.agentType,r.simplified.model,{providerId:a,runtimeType:r.runtimeType,config:r.config,settings:r.settings}),N=ge?.[r.agentType]??fe[r.agentType],B=N.apiBaseUrl?Pt(r.simplified.apiBaseUrl):null,re=Je(r),ee=r.executionPermission??re.mode,ie=N.executionPermissionOptions?.[r.runtimeType],ce=ie?.find(n=>n.mode===ee),H=re.diagnostics[0]?.message??(ie?ce?.selectable?null:ce?.reasons[0]?.message??s("This Agent has no available execution permission mode."):s("Loading permission support…")),Z=N.disableResponsesWebsocket,d=Z?De(r.config,Z):null,m=N.fastMode,I=m?De(r.config,m):null,W=m?r.config[m.path]:void 0,He=W===!0?"fast":W===!1?"standard":"inherit",he=r.simplified.reasoningEffort??"",me=he&&!N.reasoningEffort?.options?.includes(he)?s("请选择当前 Agent 支持的思考强度档位"):null,ve=n=>{Q.current.invalidate(),n&&j(n),L(!0),R(null)},_=n=>{ve(n)},Se=()=>{V&&!window.confirm(s("存在未保存的修改,确定放弃吗?"))||i()},Ze=n=>r.env.find(o=>Ne(o.key,n)),ae=(n,o,l="")=>{if(o.action!=="keep"){const c=n===N.apiBaseUrl?.path?"apiBaseUrl":n===N.apiKey?.path?"apiKey":null;c&&q(v=>{const w={...v};return delete w[c],w})}_(c=>{const v=c.env.findIndex(lt=>Ne(lt.key,n)),w=[...c.env],se=v>=0?w[v]:null,oe={key:se?.key??n,value:l,write:o,configured:se?.configured??!1,sensitive:Ne(n,c.simplified.apiKey?.envKey)||!!se?.sensitive||/key|token|secret|password|auth/i.test(n)};v>=0?w[v]=oe:w.push(oe);const ot=c.agentType===E.CLAUDE_CODE&&o.action!=="keep"&&(n===N.apiBaseUrl?.path||n===N.apiKey?.path);return{...c,env:w,settings:ot?xs(c.settings,n):c.settings}})},ue=(n,o)=>{q(l=>{if(!(n in l))return l;const c={...l};return delete c[n],c}),T(l=>new Set(l).add(n)),n==="apiBaseUrl"&&N.apiBaseUrl?.kind==="env"&&ae(N.apiBaseUrl.path,o?{action:"replace",value:o}:{action:"clear"},o),_(l=>{const c=Ut(l,n,o,N);return c.config!==l.config&&b(JSON.stringify(c.config,null,2)),c})},Qe=n=>{Z&&_(o=>{const l=Le(o,Z,n);return b(JSON.stringify(l.config,null,2)),l})},et=n=>{m&&_(o=>{const l=Le(o,m,n==="inherit"?void 0:n==="fast");return b(JSON.stringify(l.config,null,2)),l})},tt=n=>{if(V&&!window.confirm(s("切换 Agent 类型会清空当前类型的配置,是否继续?")))return;const{agentType:o,runtimeType:l}=us(n),c=fe[o],v=Be(),w={...r,agentType:o,runtimeType:l,executionPermission:ee,executionPermissionReviewRequired:void 0,config:v,settings:"",env:[],simplified:{apiKey:c.apiKey?{configured:!1,envKey:c.apiKey.path}:void 0}};ve(()=>w),b(JSON.stringify(v,null,2)),u(""),M(""),$(!1),T(new Set),h([]),q({})},Ie=(n=!1)=>{let o=!g&&!H&&!I?.error&&!d?.error&&!me;const l=r.settings.trim();if(l&&(F||n))try{if(r.agentType===E.CODEX)Dt(l);else if(r.agentType===E.CLAUDE_CODE){const c=JSON.parse(l);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(s("JSON 顶层必须是对象"))}M("")}catch(c){M(s("{format} 语法错误: {message}",{format:r.agentType===E.CODEX?"TOML":"JSON",message:c instanceof Error?c.message:String(c)})),o=!1}return o},Ae=()=>{const n=Rt(r.env),o=Object.fromEntries([...Y].map(l=>[l,r.simplified[l]]));return{providerId:a,name:r.name,agentType:r.agentType,runtimeType:r.runtimeType,executionPermission:ee,env:n,config:r.config,settings:r.settings,simplified:Y.size>0?o:void 0,conflictResolutions:k,isDefault:r.isDefault}},st=()=>{if(B||!Ie(!1))return;const o={...Ae()};delete o.providerId,a&&delete o.runtimeType,f(o)},nt=()=>{if(B||O.length>0||!Ie(!0))return;const n=Q.current.begin();R(null),S.mutate(Ae(),{onSuccess:o=>{Q.current.isCurrent(n)&&R(o)},onError:o=>{Q.current.isCurrent(n)&&R({ok:!1,stage:"connection",errorKind:"unknown",summary:G(o,s("测试配置失败"))})}})};if(!t)return null;const rt=ms(r.agentType),xe=r.agentType===E.CODEX,be=xe&&kt(r.settings),te=r.simplified.apiKey?.envKey??N.apiKey?.path,je=te?Ze(te):void 0,Te=Et(je,!!r.simplified.apiKey?.configured,k.apiKey),it=Te==="advanced",_e=Te!=="unconfigured",at=!r.name.trim()||!!B||!!g||!!H||!!I?.error||!!d?.error||!!me||!!P&&F||O.length>0;return e.jsx(e.Fragment,{children:e.jsx(ke,{isOpen:t,onClose:Se,title:s(p?"编辑 Provider":"新建 Provider"),className:"max-w-3xl",action:e.jsxs("div",{className:"flex w-full flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(A,{variant:"outline",onClick:nt,disabled:S.isPending||!!B||!!g||!!H||!!I?.error||!!d?.error||!!me||!!P&&F||O.length>0,children:[S.isPending?e.jsx(ft,{className:"animate-spin motion-reduce:[animation-duration:2.4s]"}):e.jsx(es,{}),S.isPending?s("测试中..."):s("测试配置")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{variant:"outline",onClick:Se,children:s("取消")}),e.jsx(A,{onClick:st,disabled:at,children:s("保存 Provider")})]})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-name",className:"mb-1 block text-xs font-medium text-foreground",children:s("名称")}),e.jsx(ne,{id:"provider-name",value:r.name,onChange:n=>_(o=>({...o,name:n.target.value})),placeholder:s("例如: Claude Code (官方)")})]}),!p&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("Agent 类型")}),e.jsx(Ke,{value:ze(r.agentType,r.runtimeType),onChange:tt,options:xt.flatMap(n=>pt[n].map(o=>({value:ze(n,o),label:de(n,o),icon:e.jsx(le,{agentType:n,className:"size-4"})}))),placeholder:s("选择 Agent 类型")})]}),p&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("Agent 类型")}),e.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border bg-muted/30 px-3 text-sm text-muted-foreground",children:[e.jsx(le,{agentType:r.agentType,className:"size-4"}),e.jsx("span",{className:"min-w-0 truncate",children:de(r.agentType,r.runtimeType)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"isDefault",checked:r.isDefault,onChange:n=>_(o=>({...o,isDefault:n.target.checked})),className:"h-4 w-4 rounded border-border accent-primary"}),e.jsx("label",{htmlFor:"isDefault",className:"text-sm text-foreground",children:s("设为该类型的默认 Provider")})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/20 p-4",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s("基本配置")}),e.jsx(St,{value:ee,agentType:r.agentType,options:ie,error:H,onChange:n=>_(o=>{const l=Lt(o.agentType,o.config);return b(JSON.stringify(l,null,2)),{...o,executionPermission:n,executionPermissionReviewRequired:void 0,config:l}})}),N.apiBaseUrl&&!be&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-api-url",className:"mb-1 block text-xs font-medium text-foreground",children:s("API 地址")}),e.jsx(ne,{id:"provider-api-url",type:"url",value:r.simplified.apiBaseUrl??"",onChange:n=>ue("apiBaseUrl",n.target.value),placeholder:N.apiBaseUrl.placeholder,"aria-invalid":!!B,"aria-describedby":B?"provider-api-url-error":void 0}),B&&e.jsx("p",{id:"provider-api-url-error",role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("请输入以 http:// 或 https:// 开头的完整 API 地址")})]}),N.apiKey&&!be&&(r.agentType!==E.CODEX||!!r.simplified.apiKey)&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:"API Key"}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Yt,{size:12}),s(it?"由高级配置管理":_e?"已配置":"未配置")]})]}),je?.write.action==="replace"||!_e?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{id:"provider-api-key",type:"password",autoComplete:"new-password",value:je?.value??"",onChange:n=>ae(te,{action:"replace",value:n.target.value},n.target.value),placeholder:s("输入 API Key")}),r.simplified.apiKey?.configured&&e.jsx(A,{variant:"outline",size:"sm",onClick:()=>ae(te,{action:"keep"}),children:s("取消替换")})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{variant:"outline",size:"sm",onClick:()=>ae(te,{action:"replace",value:""}),children:s("替换")}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>{window.confirm(s("确定清除此 API Key?"))&&ae(te,{action:"clear"})},children:s("清除")})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-model",className:"mb-1 block text-xs font-medium text-foreground",children:s("模型")}),r.agentType===E.CURSOR_AGENT?e.jsx(ss,{value:r.simplified.model??"",onChange:n=>ue("model",n??"")}):e.jsx(ne,{id:"provider-model",value:r.simplified.model??"",onChange:n=>ue("model",n.target.value),placeholder:N.model.placeholder})]}),N.reasoningEffort&&e.jsx(as,{options:(N.reasoningEffort.options??[]).map(n=>({value:n,label:s(gs(n))})),value:he,onChange:n=>ue("reasoningEffort",n),label:s("思考强度"),efficiencyLabel:s("更高效"),intelligenceLabel:s("更智能"),followCliLabel:s("跟随 CLI"),currentLabel:s("当前"),error:me}),m&&I&&e.jsxs("section",{className:"border-t border-border pt-3","data-fast-mode-control":!0,children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_180px] sm:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s("Fast 模式")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s("支持的模型速度约提升至 1.5 倍,并增加用量消耗。ChatGPT 登录消耗更多额度;API Key 按 Priority 处理计费。")})]}),e.jsx(Ke,{value:He,disabled:!!I.error,onChange:et,options:[{value:"inherit",label:s("跟随 Codex")},{value:"standard",label:s("标准速度")},{value:"fast",label:"Fast"}]})]}),I.error&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("Fast 模式字段必须为 true 或 false,请在运行配置 JSON 中修正。")})]}),Z&&d&&e.jsxs("section",{className:"border-t border-border pt-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s("禁用 WebSocket")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s(be?"当前原生 Provider 已使用非 WebSocket 传输;此开关不会添加额外运行时覆盖。":"仅禁用 Codex Responses API 的 WebSocket 传输;新启动和后续继续的请求将使用 HTTP。")})]}),e.jsx(Ee,{checked:d.enabled,disabled:!!d.error,onCheckedChange:Qe,"aria-label":s("禁用 WebSocket")})]}),d.error&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("禁用 WebSocket 字段必须为 true 或 false,请在运行配置 JSON 中修正。")})]})]}),K&&e.jsx(is,{result:K}),O.length>0&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-warning/30 bg-warning/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx(Pe,{size:16,className:"text-warning"}),s("需要解决配置冲突")]}),O.map(n=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-warning/20 bg-background/70 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:s(fs(n.field))})," · ",s("简化字段与高级配置值不同")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["simple","advanced"].map(o=>e.jsx(A,{variant:"outline",size:"sm",onClick:()=>{const l=n.field,c=It(r,l,o,N);_(()=>c),b(JSON.stringify(c.config,null,2)),q(v=>({...v,[l]:o})),o==="advanced"&&(l==="apiBaseUrl"||l==="model"||l==="reasoningEffort")&&T(v=>{const w=new Set(v);return w.delete(l),w}),h(v=>v.filter(w=>w.field!==l))},children:s(o==="simple"?"采用简化值":"保留高级值")},o))})]},n.field))]}),e.jsxs(Ns,{title:s("高级配置"),defaultOpen:!!g||!!P||!!H||!!I?.error||O.length>0,children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("运行配置 (JSON)")}),e.jsx(Me,{value:C,onChange:n=>{const o=n.target.value;b(o);try{const l=JSON.parse(o);if(!l||typeof l!="object"||Array.isArray(l))throw new Error(s("JSON 顶层必须是对象"));const c=l;u(""),T(v=>{const w=new Set(v).add("model");return N.reasoningEffort?.kind==="config"&&w.add("reasoningEffort"),w}),_(v=>({...v,config:c,simplified:At(v.simplified,c,N)}))}catch(l){ve(),u(l instanceof Error?l.message:s("JSON 语法错误"))}},rows:7,className:"font-mono","aria-invalid":!!g}),g&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:g})]}),e.jsxs("div",{className:"border-t border-border pt-3",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:s("环境变量")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:[s("注入到 Agent 进程的环境变量。Codex 的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"env_key"})," ",s("指定的是变量名,实际值需在此处设置。")]}),e.jsxs("div",{className:"space-y-2",children:[r.env.map((n,o)=>n.write.action!=="clear"&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ne,{value:n.key,disabled:n.configured,onChange:l=>{const c=l.target.value;_(v=>{const w=[...v.env],se=w[o];if(!se)return v;const oe={...se,key:c};return w[o]={...oe,sensitive:Re(oe,v.simplified)},{...v,env:w}})},placeholder:s("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 py-1.5 font-mono"}),e.jsx(ne,{value:n.value,type:Re(n,r.simplified)?"password":"text",onChange:l=>{const c=[...r.env];c[o]={...c[o],value:l.target.value,write:{action:"replace",value:l.target.value}},_(v=>({...v,env:c,simplified:n.key===N.apiBaseUrl?.path?{...v.simplified,apiBaseUrl:l.target.value}:v.simplified})),n.key===N.apiBaseUrl?.path&&T(v=>new Set(v).add("apiBaseUrl"))},placeholder:n.configured&&n.write.action==="keep"?s("已配置,输入新值以替换"):s("值"),className:"flex-1 py-1.5 font-mono"}),e.jsx("button",{type:"button",onClick:()=>{const l=[...r.env];n.configured?l[o]={...n,value:"",write:{action:"clear"}}:l.splice(o,1),_(c=>({...c,env:l,simplified:n.key===N.apiBaseUrl?.path?{...c.simplified,apiBaseUrl:""}:c.simplified})),n.key===N.apiBaseUrl?.path&&T(c=>new Set(c).add("apiBaseUrl"))},"aria-label":s("删除"),className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsx(We,{size:14})})]},o)),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>_(n=>({...n,env:[...n.env,{key:"",value:"",write:{action:"replace",value:""},configured:!1,sensitive:!1}]})),children:[e.jsx(we,{size:12,className:"mr-1"}),s("添加变量")]})]})]}),rt&&e.jsxs("div",{className:"border-t border-border pt-3",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:s(xe?"Agent 原生配置 (config.toml)":"Agent 原生配置 (settings.json)")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:xe?e.jsxs(e.Fragment,{children:[s("直接填写 Codex")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"config.toml"})," ",s("格式的配置片段,由当前 Runtime 注入。不会修改你的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"~/.codex/config.toml"})," ",s("文件。")]}):e.jsxs(e.Fragment,{children:[s("对应 Claude Code 的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"~/.claude/settings.json"}),",",s("由当前 Runtime 注入。在")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"env"})," ",s("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),e.jsx(Me,{value:r.settings,onChange:n=>{const o=n.target.value;$(!0),M("");let l;if(xe)try{l=Ue(r.simplified,o,E.CODEX),T(c=>new Set(c).add("reasoningEffort"))}catch{}_(c=>{const v=l===void 0?c.simplified:Ue(c.simplified,o,E.CODEX,new Set(c.env.flatMap(w=>w.write.action==="clear"?[]:w.write.action==="replace"?w.value?[w.key]:[]:w.configured?[w.key]:[])));return{...c,settings:o,env:Kt(c.env,v),simplified:v}})},rows:10,className:"font-mono",placeholder:cs(r.agentType,x),"aria-invalid":!!P}),P&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:P})]})]})]})})})}function Cs({isOpen:t,onClose:i,onConfirm:a,acknowledged:p,onAcknowledgedChange:f,isLoading:x}){const{t:s}=J();return e.jsx(ke,{isOpen:t,onClose:i,title:s("导出 Provider 备份"),className:"max-w-xl",action:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",onClick:i,disabled:x,children:s("取消")}),e.jsx(A,{onClick:a,disabled:!p||x,children:s(x?"导出中...":"导出备份")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-warning/30 bg-warning/10 px-4 py-3 text-sm text-foreground",children:[e.jsx(Pe,{size:15,className:"mt-0.5 shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{children:s("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")})]}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:s("这个功能用于备份和迁移,不用于分享配置。")}),e.jsx("p",{children:s("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-border px-4 py-3 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:S=>f(S.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsx("span",{children:s("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function Ps({isOpen:t,onClose:i,preview:a,backup:p,onConfirm:f,isLoading:x}){const{t:s}=J();if(!a||!p)return null;const S=a.summary.create+a.summary.overwrite,r=[...a.items].sort((j,C)=>{const b={CREATE:0,OVERWRITE:1,SKIP:2};return b[j.action]-b[C.action]});return e.jsx(ke,{isOpen:t,onClose:i,title:s("导入 Provider 备份"),className:"max-w-3xl",action:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",onClick:i,disabled:x,children:s("取消")}),e.jsx(A,{onClick:f,disabled:S===0||x,children:x?s("导入中..."):s("确认导入 {count} 项",{count:S})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{children:s("导出时间:{value}",{value:new Date(p.exportedAt).toLocaleString()})}),e.jsx("div",{children:s("模式:完整备份(含敏感信息)")}),e.jsx("div",{children:s("文件内 Provider 数量:{count}",{count:p.providers.length})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-success/25 bg-success/10 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-success-ink",children:s("新增")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.create})]}),e.jsxs("div",{className:"rounded-lg border border-warning/25 bg-warning/10 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-warning-ink",children:s("覆盖")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.overwrite})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s("跳过")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.skip})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:r.map(j=>{const C=bs(j.action);return e.jsxs("div",{className:"rounded-lg border border-border px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"truncate text-sm font-medium text-foreground",children:j.incoming.name}),e.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${C.className}`,children:s(C.label)})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{agentType:j.incoming.agentType,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:de(j.incoming.agentType,j.incoming.runtimeType)})," · ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j.incoming.id})]})]})}),j.action==="OVERWRITE"&&j.existing&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("将覆盖当前已有的 Provider:{name}",{name:j.existing.name})}),j.action==="SKIP"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前同 ID Provider 配置一致,本次不会重复写入。")}),j.action==="CREATE"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前不存在同 ID Provider,将直接新增。")})]},j.incoming.id)})})]})})}function ks({item:t,onEdit:i,onDelete:a,onEnabledChange:p,isUpdating:f}){const{t:x}=J(),s=t.provider,S=$e(t),r=Tt(s),j=Xe(s.agentType,s.config),C=fe[s.agentType],b=Object.entries(j).filter(([u])=>u!=="cmd"&&u!==C.executionPermission.path),g=Object.keys(s.redactedEnv||{});return e.jsxs("div",{className:"min-w-0 space-y-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("h3",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:s.name}),e.jsx(ys,{issue:S,disabled:s.enabled===!1})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(le,{agentType:s.agentType,className:"size-3.5"}),e.jsx("span",{className:"truncate",children:de(s.agentType,s.runtimeType)})]}),s.isDefault&&e.jsx("span",{className:"rounded-full bg-primary/[0.06] px-2 py-0.5 text-xs font-medium text-primary",children:x("默认")}),s.builtIn&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:x("内置")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:shrink-0",children:[e.jsxs(A,{size:"sm",variant:"outline",onClick:i,children:[e.jsx(Zt,{size:13}),x("编辑")]}),e.jsxs(A,{size:"sm",variant:s.builtIn?"outline":"destructive",onClick:a,disabled:s.deletable===!1,children:[s.builtIn?e.jsx(Nt,{size:13}):e.jsx(We,{size:13}),s.builtIn?x("恢复默认"):x("删除")]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:"provider-enabled",className:"text-sm font-medium text-foreground",children:x("启用配置")}),e.jsx("p",{id:"provider-enabled-description",className:"mt-1 text-xs text-muted-foreground",children:x("禁用后不在 Agent 可选列表中显示,配置仍会保留,可随时重新启用。")})]}),e.jsx(Ee,{id:"provider-enabled",checked:s.enabled!==!1,disabled:f,onCheckedChange:p,"aria-describedby":"provider-enabled-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{children:x("Execution permission")}),e.jsx("p",{className:"text-sm",children:x(_t[Je(s).mode])}),r&&!s.diagnostics?.some(u=>u.field==="executionPermission")?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x(r)}):null,s.diagnostics?.filter(u=>u.field==="executionPermission").map((u,P)=>e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x(u.message)},`${u.code}-${P}`)),S&&!r?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x(S)}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:x("Changes apply when a new runtime starts. Running sessions keep their launch mode.")})]}),b.length>0&&e.jsxs("div",{children:[e.jsx(pe,{className:"mb-3",children:x("运行配置")}),e.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:b.map(([u,P])=>e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1 bg-background px-4 py-2.5 sm:flex-row sm:items-center sm:gap-4",children:[e.jsx("span",{className:"min-w-0 break-words text-[13px] text-muted-foreground sm:w-32 sm:shrink-0",children:x(Ve[u]??u)}),e.jsx("span",{className:"min-w-0 max-w-full break-all font-mono text-[13px] text-foreground",children:ps(u,P)})]},u))})]}),g.length>0&&e.jsxs("div",{children:[e.jsx(pe,{className:"mb-3",children:x("环境变量")}),e.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:g.map(u=>e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 bg-background px-4 py-2.5 sm:gap-4",children:[e.jsx("span",{className:"min-w-0 max-w-full break-all font-mono text-[13px] text-foreground",children:u}),e.jsx("span",{className:"text-[13px] text-muted-foreground","aria-label":"hidden",children:"•••••"})]},u))})]}),s.settings?.trim()&&e.jsxs("div",{children:[e.jsx(pe,{className:"mb-3",children:x("Agent 原生配置")}),e.jsx("div",{className:"rounded-lg border border-border bg-muted/40 p-4",children:e.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:s.settings})})]}),b.length===0&&g.length===0&&!s.settings?.trim()&&e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:x('该 Provider 未配置额外参数。点击"编辑"添加运行配置、环境变量或 Agent 原生配置。')})]})}function rn(){const{t}=J(),{data:i,isLoading:a}=zt(),p=Ft(),f=Jt(),x=$t(),s=qt(),S=Wt(),r=Gt(),j=y.useRef(null),[C,b]=y.useState(null),[g,u]=y.useState(null),[P,M]=y.useState(null),[F,$]=y.useState(!1),[V,L]=y.useState(!1),[K,R]=y.useState(null),[Y,T]=y.useState(!1),O=i??[],h=C??O[0]?.provider.id??null,k=d=>{p.mutate(d,{onSuccess:()=>u(null),onError:m=>U.error(G(m,t("创建 Provider 失败")))})},q=(d,m)=>{f.mutate({id:d,data:m},{onSuccess:()=>u(null),onError:I=>U.error(G(I,t("更新 Provider 失败")))})},Q=(d,m)=>{f.mutate({id:d,data:{enabled:m}},{onError:I=>U.error(G(I,t("更新 Provider 失败")))})},ge=d=>{if(!(d.deletable??!d.builtIn)){U.error(t("系统内置 Provider 不可删除"));return}M({id:d.id,name:d.name,builtIn:d.builtIn})},N=()=>{P&&x.mutate(P.id,{onSuccess:()=>{U.success(P.builtIn?t("已恢复默认 Provider 配置"):t("Provider 已删除")),h===P.id&&b(null),M(null),T(!1)},onError:d=>U.error(G(d,t("删除 Provider 失败")))})},B=()=>{$(!1),L(!1)},re=()=>R(null),ee=()=>{s.mutate(void 0,{onSuccess:d=>{vs(hs(d.exportedAt),d),U.success(t("Provider 备份已导出")),B()},onError:d=>U.error(G(d,t("导出 Provider 备份失败")))})},ie=()=>{j.current&&(j.current.value="",j.current.click())},ce=async d=>{const m=d.target.files?.[0];if(d.target.value="",!m)return;let I;try{I=JSON.parse(await m.text())}catch{U.error(t("备份文件不是有效的 JSON"));return}S.mutate(I,{onSuccess:W=>R({backup:I,preview:W}),onError:W=>U.error(G(W,t("导入预览失败")))})},H=()=>{K&&r.mutate(K.backup,{onSuccess:d=>{const m=d.summary.create+d.summary.overwrite;U.success(m===0?t("导入完成,当前配置无需变更"):t("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:d.summary.create,overwrite:d.summary.overwrite,skip:d.summary.skip})),re()},onError:d=>U.error(G(d,t("导入 Provider 备份失败")))})},Z=d=>{const m=d.provider,I=fe[m.agentType],W=Ot(m,I);u({id:m.id,data:{name:m.name,agentType:m.agentType,runtimeType:m.runtimeType===X.ACP?X.ACP:X.CLI,executionPermission:m.executionPermission,executionPermissionReviewRequired:m.executionPermissionReviewRequired,config:Xe(m.agentType,m.config),settings:m.settings??"",env:W,simplified:m.simplified??{},diagnostics:m.diagnostics,isDefault:m.isDefault}})};return a?e.jsx(Oe,{className:"max-w-5xl",children:e.jsx(gt,{})}):e.jsxs(Oe,{className:"max-w-5xl",children:[e.jsx("input",{ref:j,type:"file",accept:".json,application/json",className:"hidden",onChange:ce}),e.jsx(ht,{title:t("Agent 配置"),actions:e.jsxs(e.Fragment,{children:[e.jsxs(A,{variant:"outline",size:"sm",onClick:ie,disabled:S.isPending||r.isPending,children:[e.jsx(Ht,{size:13}),t("导入")]}),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>$(!0),disabled:s.isPending,children:[e.jsx(vt,{size:13}),t("导出")]}),e.jsxs(A,{size:"sm",onClick:()=>u({}),children:[e.jsx(we,{size:13,className:"mr-1"}),t("新建")]})]})}),O.length===0?e.jsx(bt,{icon:jt,message:t("暂无 Agent 配置"),action:e.jsxs(A,{size:"sm",onClick:()=>u({}),children:[e.jsx(we,{size:13,className:"mr-1"}),t("新建配置")]})}):e.jsx(Vt,{items:O,selectedId:h,onSelectItem:d=>{b(d),T(!0)},getItemId:d=>d.provider.id,mobileShowDetail:Y,onMobileBack:()=>T(!1),renderListItem:d=>{const m=d.provider,I=$e(d);return e.jsxs(e.Fragment,{children:[e.jsx(js,{issue:I,disabled:m.enabled===!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:D("truncate text-[13px] font-medium",m.enabled===!1&&"text-muted-foreground"),children:m.name}),e.jsxs("div",{className:D("flex min-w-0 items-center gap-1.5 text-[11px]","text-muted-foreground"),children:[e.jsx(le,{agentType:m.agentType,className:"size-3.5",fallbackClassName:"text-muted-foreground"}),e.jsx("span",{className:"min-w-0 truncate",children:de(m.agentType,m.runtimeType)}),m.enabled===!1&&e.jsx("span",{className:"shrink-0",children:t("已禁用")})]}),I?e.jsx("div",{className:D("mt-0.5 break-words text-xs leading-snug text-destructive-ink"),children:t(I)}):null]}),m.isDefault&&e.jsx("span",{className:D("shrink-0 rounded px-1.5 py-0.5 text-xs font-medium","bg-primary/[0.06] text-primary"),children:t("默认")})]})},renderDetail:d=>d?e.jsx("div",{className:"min-w-0 p-5",children:e.jsx(ks,{item:d,onEdit:()=>Z(d),onDelete:()=>ge(d.provider),onEnabledChange:m=>Q(d.provider.id,m),isUpdating:f.isPending})}):e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:t("选择一个 Provider 查看详情")})}),g&&e.jsx(ws,{isOpen:!0,onClose:()=>u(null),providerId:g.id,initialData:g.data,onSave:d=>{g.id?q(g.id,d):k(d)}}),e.jsx(Xt,{isOpen:P!==null,onClose:()=>{x.isPending||M(null)},onConfirm:N,title:P?.builtIn?t("恢复默认 Provider"):t("删除 Provider"),description:P?.builtIn?t('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:P?.name}):t('确定删除 "{name}"?此操作不可撤销。',{name:P?.name}),confirmText:P?.builtIn?t("恢复默认"):t("删除"),cancelText:t("取消"),variant:"danger",isLoading:x.isPending}),e.jsx(Cs,{isOpen:F,onClose:B,onConfirm:ee,acknowledged:V,onAcknowledgedChange:L,isLoading:s.isPending}),e.jsx(Ps,{isOpen:!!K,onClose:re,preview:K?.preview??null,backup:K?.backup??null,onConfirm:H,isLoading:r.isPending})]})}export{ws as ProviderFormModal,rn as ProviderSettingsPage};
|
|
67
|
+
`;function cs(t,i){return t===E.CLAUDE_CODE?os:t===E.CODEX?i==="zh-CN"?ls:ds:""}function ms(t){return t===E.CLAUDE_CODE||t===E.CODEX}const Pe="::ACP";function ze(t,i){return i===X.ACP?`${t}${Pe}`:String(t)}function de(t,i){const a=yt(t);return i===X.ACP?`${a} (ACP)`:a}function us(t){return t.endsWith(Pe)?{agentType:t.slice(0,-Pe.length),runtimeType:X.ACP}:{agentType:t,runtimeType:X.CLI}}function xs(t,i){if(!t.trim())return t;try{const a=JSON.parse(t);if(!a.env||typeof a.env!="object"||Array.isArray(a.env))return t;const p=a.env;return i in p?(delete p[i],JSON.stringify(a,null,2)):t}catch{return t}}const Ve=Object.values(Ge).flat().reduce((t,i)=>(t[i.key]||(t[i.key]=i.label),t),{});Ve.permissionMode="权限策略";const Ye=Object.values(Ge).flat().reduce((t,i)=>(i.options&&(t[i.key]=Object.fromEntries(i.options.map(a=>[a.value,a.label]))),t),{});Ye.permissionMode={ASK:"每次询问",AUTO_APPROVE:"无限制",UNRESTRICTED:"无限制"};function ps(t,i){if(typeof i=="boolean")return i?ye("是"):ye("否");if(typeof i=="string"&&i){const a=Ye[t]?.[i];return a?ye(a):i}return String(i)}function G(t,i){return t instanceof Error?t.message:i}function fs(t){return t==="apiBaseUrl"?"API 地址":t==="apiKey"?"API Key":t==="reasoningEffort"?"思考强度":t==="model"?"模型":t==="executionPermission"?"执行权限":t==="fastMode"?"Fast 模式":t==="disableResponsesWebsocket"?"禁用 WebSocket":t}function gs(t){return{minimal:"最低",low:"低",medium:"中",high:"高",xhigh:"超高",max:"最高",ultra:"Ultra"}[t]??t}function hs(t){return`agent-tower-provider-backup-${t.replace(/[:.]/g,"-")}.json`}function vs(t,i){const a=new Blob([JSON.stringify(i,null,2)],{type:"application/json"}),p=URL.createObjectURL(a),f=document.createElement("a");f.href=p,f.download=t,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p)}function bs(t){switch(t){case"CREATE":return{label:"新增",className:"bg-success/10 text-success-ink"};case"OVERWRITE":return{label:"覆盖",className:"bg-warning/10 text-warning-ink"};case"SKIP":return{label:"跳过",className:"bg-muted text-muted-foreground"}}}function js({issue:t,disabled:i=!1}){const{t:a}=J(),p=!i&&!t,f=a(i?"已禁用":p?"可用":"不可用");return e.jsx("span",{className:D("inline-block h-2 w-2 rounded-full shrink-0",p?"bg-success":"bg-border"),title:i?f:t?`${f}: ${a(t)}`:f,children:e.jsx("span",{className:"sr-only",children:f})})}function ys({issue:t,disabled:i=!1}){const{t:a}=J();return!i&&!t?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-xs font-medium text-success-ink",children:[e.jsx(Fe,{size:11,"aria-hidden":"true"}),a("可用")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:[e.jsx(wt,{size:11,"aria-hidden":"true"}),a(i?"已禁用":"不可用")]})}function Ns({title:t,status:i,defaultOpen:a=!1,children:p}){const[f,x]=y.useState(a);return e.jsxs("div",{className:"rounded-lg border border-border",children:[e.jsxs("button",{type:"button",onClick:()=>x(s=>!s),"aria-expanded":f,className:"w-full flex items-center justify-between rounded-lg px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t}),i]}),e.jsx(qe,{size:14,"aria-hidden":"true",className:D("text-muted-foreground transition-transform motion-reduce:transition-none",f&&"rotate-180")})]}),f&&e.jsx("div",{className:"px-4 pb-4 space-y-3",children:p})]})}function ws({isOpen:t,onClose:i,providerId:a,initialData:p,onSave:f}){const{locale:x,t:s}=J(),S=Mt(),[r,j]=y.useState(p??{name:"",agentType:E.CLAUDE_CODE,runtimeType:X.CLI,executionPermission:"ASK",config:Be(),settings:"",env:[],simplified:{apiKey:{configured:!1,envKey:"ANTHROPIC_API_KEY"}},diagnostics:[],isDefault:!1}),[P,b]=y.useState(()=>JSON.stringify(r.config,null,2)),[g,u]=y.useState(""),[C,M]=y.useState(()=>r.diagnostics?.find(n=>n.field==="settings")?.message??""),[F,$]=y.useState(!1),[V,L]=y.useState(!1),[K,R]=y.useState(null),[Y,T]=y.useState(()=>new Set),[O,h]=y.useState(()=>r.diagnostics?.filter(n=>n.code==="CONFLICT")??[]),[k,q]=y.useState({}),Q=y.useRef(Pt()),{data:ge}=Bt(r.agentType,r.simplified.model,{providerId:a,runtimeType:r.runtimeType,config:r.config,settings:r.settings}),N=ge?.[r.agentType]??fe[r.agentType],B=N.apiBaseUrl?Ct(r.simplified.apiBaseUrl):null,re=Je(r),ee=r.executionPermission??re.mode,ie=N.executionPermissionOptions?.[r.runtimeType],ce=ie?.find(n=>n.mode===ee),H=re.diagnostics[0]?.message??(ie?ce?.selectable?null:ce?.reasons[0]?.message??s("This Agent has no available execution permission mode."):s("Loading permission support…")),Z=N.disableResponsesWebsocket,d=Z?De(r.config,Z):null,m=N.fastMode,I=m?De(r.config,m):null,W=m?r.config[m.path]:void 0,He=W===!0?"fast":W===!1?"standard":"inherit",he=r.simplified.reasoningEffort??"",me=he&&!N.reasoningEffort?.options?.includes(he)?s("请选择当前 Agent 支持的思考强度档位"):null,ve=n=>{Q.current.invalidate(),n&&j(n),L(!0),R(null)},_=n=>{ve(n)},Se=()=>{V&&!window.confirm(s("存在未保存的修改,确定放弃吗?"))||i()},Ze=n=>r.env.find(o=>Ne(o.key,n)),ae=(n,o,l="")=>{if(o.action!=="keep"){const c=n===N.apiBaseUrl?.path?"apiBaseUrl":n===N.apiKey?.path?"apiKey":null;c&&q(v=>{const w={...v};return delete w[c],w})}_(c=>{const v=c.env.findIndex(lt=>Ne(lt.key,n)),w=[...c.env],se=v>=0?w[v]:null,oe={key:se?.key??n,value:l,write:o,configured:se?.configured??!1,sensitive:Ne(n,c.simplified.apiKey?.envKey)||!!se?.sensitive||/key|token|secret|password|auth/i.test(n)};v>=0?w[v]=oe:w.push(oe);const ot=c.agentType===E.CLAUDE_CODE&&o.action!=="keep"&&(n===N.apiBaseUrl?.path||n===N.apiKey?.path);return{...c,env:w,settings:ot?xs(c.settings,n):c.settings}})},ue=(n,o)=>{q(l=>{if(!(n in l))return l;const c={...l};return delete c[n],c}),T(l=>new Set(l).add(n)),n==="apiBaseUrl"&&N.apiBaseUrl?.kind==="env"&&ae(N.apiBaseUrl.path,o?{action:"replace",value:o}:{action:"clear"},o),_(l=>{const c=Ut(l,n,o,N);return c.config!==l.config&&b(JSON.stringify(c.config,null,2)),c})},Qe=n=>{Z&&_(o=>{const l=Le(o,Z,n);return b(JSON.stringify(l.config,null,2)),l})},et=n=>{m&&_(o=>{const l=Le(o,m,n==="inherit"?void 0:n==="fast");return b(JSON.stringify(l.config,null,2)),l})},tt=n=>{if(V&&!window.confirm(s("切换 Agent 类型会清空当前类型的配置,是否继续?")))return;const{agentType:o,runtimeType:l}=us(n),c=fe[o],v=Be(),w={...r,agentType:o,runtimeType:l,executionPermission:ee,executionPermissionReviewRequired:void 0,config:v,settings:"",env:[],simplified:{apiKey:c.apiKey?{configured:!1,envKey:c.apiKey.path}:void 0}};ve(()=>w),b(JSON.stringify(v,null,2)),u(""),M(""),$(!1),T(new Set),h([]),q({})},Ie=(n=!1)=>{let o=!g&&!H&&!I?.error&&!d?.error&&!me;const l=r.settings.trim();if(l&&(F||n))try{if(r.agentType===E.CODEX)Dt(l);else if(r.agentType===E.CLAUDE_CODE){const c=JSON.parse(l);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(s("JSON 顶层必须是对象"))}M("")}catch(c){M(s("{format} 语法错误: {message}",{format:r.agentType===E.CODEX?"TOML":"JSON",message:c instanceof Error?c.message:String(c)})),o=!1}return o},Ae=()=>{const n=Rt(r.env),o=Object.fromEntries([...Y].map(l=>[l,r.simplified[l]]));return{providerId:a,name:r.name,agentType:r.agentType,runtimeType:r.runtimeType,executionPermission:ee,env:n,config:r.config,settings:r.settings,simplified:Y.size>0?o:void 0,conflictResolutions:k,isDefault:r.isDefault}},st=()=>{if(B||!Ie(!1))return;const o={...Ae()};delete o.providerId,a&&delete o.runtimeType,f(o)},nt=()=>{if(B||O.length>0||!Ie(!0))return;const n=Q.current.begin();R(null),S.mutate(Ae(),{onSuccess:o=>{Q.current.isCurrent(n)&&R(o)},onError:o=>{Q.current.isCurrent(n)&&R({ok:!1,stage:"connection",errorKind:"unknown",summary:G(o,s("测试配置失败"))})}})};if(!t)return null;const rt=ms(r.agentType),xe=r.agentType===E.CODEX,be=xe&&kt(r.settings),te=r.simplified.apiKey?.envKey??N.apiKey?.path,je=te?Ze(te):void 0,Te=Et(je,!!r.simplified.apiKey?.configured,k.apiKey),it=Te==="advanced",_e=Te!=="unconfigured",at=!r.name.trim()||!!B||!!g||!!H||!!I?.error||!!d?.error||!!me||!!C&&F||O.length>0;return e.jsx(e.Fragment,{children:e.jsx(ke,{isOpen:t,onClose:Se,title:s(p?"编辑 Provider":"新建 Provider"),className:"max-w-3xl",action:e.jsxs("div",{className:"flex w-full flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs(A,{variant:"outline",onClick:nt,disabled:S.isPending||!!B||!!g||!!H||!!I?.error||!!d?.error||!!me||!!C&&F||O.length>0,children:[S.isPending?e.jsx(ft,{className:"animate-spin motion-reduce:[animation-duration:2.4s]"}):e.jsx(es,{}),S.isPending?s("测试中..."):s("测试配置")]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{variant:"outline",onClick:Se,children:s("取消")}),e.jsx(A,{onClick:st,disabled:at,children:s("保存 Provider")})]})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-name",className:"mb-1 block text-xs font-medium text-foreground",children:s("名称")}),e.jsx(ne,{id:"provider-name",value:r.name,onChange:n=>_(o=>({...o,name:n.target.value})),placeholder:s("例如: Claude Code (官方)")})]}),!p&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("Agent 类型")}),e.jsx(Ke,{value:ze(r.agentType,r.runtimeType),onChange:tt,options:xt.flatMap(n=>pt[n].map(o=>({value:ze(n,o),label:de(n,o),icon:e.jsx(le,{agentType:n,className:"size-4"})}))),placeholder:s("选择 Agent 类型")})]}),p&&e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("Agent 类型")}),e.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border bg-muted/30 px-3 text-sm text-muted-foreground",children:[e.jsx(le,{agentType:r.agentType,className:"size-4"}),e.jsx("span",{className:"min-w-0 truncate",children:de(r.agentType,r.runtimeType)})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"isDefault",checked:r.isDefault,onChange:n=>_(o=>({...o,isDefault:n.target.checked})),className:"h-4 w-4 rounded border-border accent-primary"}),e.jsx("label",{htmlFor:"isDefault",className:"text-sm text-foreground",children:s("设为该类型的默认 Provider")})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/20 p-4",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:s("基本配置")}),e.jsx(St,{value:ee,agentType:r.agentType,options:ie,error:H,onChange:n=>_(o=>{const l=Lt(o.agentType,o.config);return b(JSON.stringify(l,null,2)),{...o,executionPermission:n,executionPermissionReviewRequired:void 0,config:l}})}),N.apiBaseUrl&&!be&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-api-url",className:"mb-1 block text-xs font-medium text-foreground",children:s("API 地址")}),e.jsx(ne,{id:"provider-api-url",type:"url",value:r.simplified.apiBaseUrl??"",onChange:n=>ue("apiBaseUrl",n.target.value),placeholder:N.apiBaseUrl.placeholder,"aria-invalid":!!B,"aria-describedby":B?"provider-api-url-error":void 0}),B&&e.jsx("p",{id:"provider-api-url-error",role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("请输入以 http:// 或 https:// 开头的完整 API 地址")})]}),N.apiKey&&!be&&(r.agentType!==E.CODEX||!!r.simplified.apiKey)&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:"API Key"}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Yt,{size:12}),s(it?"由高级配置管理":_e?"已配置":"未配置")]})]}),je?.write.action==="replace"||!_e?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{id:"provider-api-key",type:"password",autoComplete:"new-password",value:je?.value??"",onChange:n=>ae(te,{action:"replace",value:n.target.value},n.target.value),placeholder:s("输入 API Key")}),r.simplified.apiKey?.configured&&e.jsx(A,{variant:"outline",size:"sm",onClick:()=>ae(te,{action:"keep"}),children:s("取消替换")})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{variant:"outline",size:"sm",onClick:()=>ae(te,{action:"replace",value:""}),children:s("替换")}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>{window.confirm(s("确定清除此 API Key?"))&&ae(te,{action:"clear"})},children:s("清除")})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"provider-model",className:"mb-1 block text-xs font-medium text-foreground",children:s("模型")}),r.agentType===E.CURSOR_AGENT?e.jsx(ss,{value:r.simplified.model??"",onChange:n=>ue("model",n??"")}):e.jsx(ne,{id:"provider-model",value:r.simplified.model??"",onChange:n=>ue("model",n.target.value),placeholder:N.model.placeholder})]}),N.reasoningEffort&&e.jsx(as,{options:(N.reasoningEffort.options??[]).map(n=>({value:n,label:s(gs(n))})),value:he,onChange:n=>ue("reasoningEffort",n),label:s("思考强度"),efficiencyLabel:s("更高效"),intelligenceLabel:s("更智能"),followCliLabel:s("跟随 CLI"),currentLabel:s("当前"),error:me}),m&&I&&e.jsxs("section",{className:"border-t border-border pt-3","data-fast-mode-control":!0,children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_180px] sm:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s("Fast 模式")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s("支持的模型速度约提升至 1.5 倍,并增加用量消耗。ChatGPT 登录消耗更多额度;API Key 按 Priority 处理计费。")})]}),e.jsx(Ke,{value:He,disabled:!!I.error,onChange:et,options:[{value:"inherit",label:s("跟随 Codex")},{value:"standard",label:s("标准速度")},{value:"fast",label:"Fast"}]})]}),I.error&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("Fast 模式字段必须为 true 或 false,请在运行配置 JSON 中修正。")})]}),Z&&d&&e.jsxs("section",{className:"border-t border-border pt-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s("禁用 WebSocket")}),e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s(be?"当前原生 Provider 已使用非 WebSocket 传输;此开关不会添加额外运行时覆盖。":"仅禁用 Codex Responses API 的 WebSocket 传输;新启动和后续继续的请求将使用 HTTP。")})]}),e.jsx(Ee,{checked:d.enabled,disabled:!!d.error,onCheckedChange:Qe,"aria-label":s("禁用 WebSocket")})]}),d.error&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:s("禁用 WebSocket 字段必须为 true 或 false,请在运行配置 JSON 中修正。")})]})]}),K&&e.jsx(is,{result:K}),O.length>0&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-warning/30 bg-warning/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx(Ce,{size:16,className:"text-warning"}),s("需要解决配置冲突")]}),O.map(n=>e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-warning/20 bg-background/70 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:s(fs(n.field))})," · ",s("简化字段与高级配置值不同")]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["simple","advanced"].map(o=>e.jsx(A,{variant:"outline",size:"sm",onClick:()=>{const l=n.field,c=It(r,l,o,N);_(()=>c),b(JSON.stringify(c.config,null,2)),q(v=>({...v,[l]:o})),o==="advanced"&&(l==="apiBaseUrl"||l==="model"||l==="reasoningEffort")&&T(v=>{const w=new Set(v);return w.delete(l),w}),h(v=>v.filter(w=>w.field!==l))},children:s(o==="simple"?"采用简化值":"保留高级值")},o))})]},n.field))]}),e.jsxs(Ns,{title:s("高级配置"),defaultOpen:!!g||!!C||!!H||!!I?.error||O.length>0,children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs font-medium text-foreground",children:s("运行配置 (JSON)")}),e.jsx(Me,{value:P,onChange:n=>{const o=n.target.value;b(o);try{const l=JSON.parse(o);if(!l||typeof l!="object"||Array.isArray(l))throw new Error(s("JSON 顶层必须是对象"));const c=l;u(""),T(v=>{const w=new Set(v).add("model");return N.reasoningEffort?.kind==="config"&&w.add("reasoningEffort"),w}),_(v=>({...v,config:c,simplified:At(v.simplified,c,N)}))}catch(l){ve(),u(l instanceof Error?l.message:s("JSON 语法错误"))}},rows:7,className:"font-mono","aria-invalid":!!g}),g&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:g})]}),e.jsxs("div",{className:"border-t border-border pt-3",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:s("环境变量")}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:[s("注入到 Agent 进程的环境变量。Codex 的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"env_key"})," ",s("指定的是变量名,实际值需在此处设置。")]}),e.jsxs("div",{className:"space-y-2",children:[r.env.map((n,o)=>n.write.action!=="clear"&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ne,{value:n.key,disabled:n.configured,onChange:l=>{const c=l.target.value;_(v=>{const w=[...v.env],se=w[o];if(!se)return v;const oe={...se,key:c};return w[o]={...oe,sensitive:Re(oe,v.simplified)},{...v,env:w}})},placeholder:s("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 py-1.5 font-mono"}),e.jsx(ne,{value:n.value,type:Re(n,r.simplified)?"password":"text",onChange:l=>{const c=[...r.env];c[o]={...c[o],value:l.target.value,write:{action:"replace",value:l.target.value}},_(v=>({...v,env:c,simplified:n.key===N.apiBaseUrl?.path?{...v.simplified,apiBaseUrl:l.target.value}:v.simplified})),n.key===N.apiBaseUrl?.path&&T(v=>new Set(v).add("apiBaseUrl"))},placeholder:n.configured&&n.write.action==="keep"?s("已配置,输入新值以替换"):s("值"),className:"flex-1 py-1.5 font-mono"}),e.jsx("button",{type:"button",onClick:()=>{const l=[...r.env];n.configured?l[o]={...n,value:"",write:{action:"clear"}}:l.splice(o,1),_(c=>({...c,env:l,simplified:n.key===N.apiBaseUrl?.path?{...c.simplified,apiBaseUrl:""}:c.simplified})),n.key===N.apiBaseUrl?.path&&T(c=>new Set(c).add("apiBaseUrl"))},"aria-label":s("删除"),className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsx(We,{size:14})})]},o)),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>_(n=>({...n,env:[...n.env,{key:"",value:"",write:{action:"replace",value:""},configured:!1,sensitive:!1}]})),children:[e.jsx(we,{size:12,className:"mr-1"}),s("添加变量")]})]})]}),rt&&e.jsxs("div",{className:"border-t border-border pt-3",children:[e.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:s(xe?"Agent 原生配置 (config.toml)":"Agent 原生配置 (settings.json)")}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:xe?e.jsxs(e.Fragment,{children:[s("直接填写 Codex")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"config.toml"})," ",s("格式的配置片段,由当前 Runtime 注入。不会修改你的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"~/.codex/config.toml"})," ",s("文件。")]}):e.jsxs(e.Fragment,{children:[s("对应 Claude Code 的")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"~/.claude/settings.json"}),",",s("由当前 Runtime 注入。在")," ",e.jsx("code",{className:"rounded bg-muted px-1",children:"env"})," ",s("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),e.jsx(Me,{value:r.settings,onChange:n=>{const o=n.target.value;$(!0),M("");let l;if(xe)try{l=Ue(r.simplified,o,E.CODEX),T(c=>new Set(c).add("reasoningEffort"))}catch{}_(c=>{const v=l===void 0?c.simplified:Ue(c.simplified,o,E.CODEX,new Set(c.env.flatMap(w=>w.write.action==="clear"?[]:w.write.action==="replace"?w.value?[w.key]:[]:w.configured?[w.key]:[])));return{...c,settings:o,env:Kt(c.env,v),simplified:v}})},rows:10,className:"font-mono",placeholder:cs(r.agentType,x),"aria-invalid":!!C}),C&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive-ink",children:C})]})]})]})})})}function Ps({isOpen:t,onClose:i,onConfirm:a,acknowledged:p,onAcknowledgedChange:f,isLoading:x}){const{t:s}=J();return e.jsx(ke,{isOpen:t,onClose:i,title:s("导出 Provider 备份"),className:"max-w-xl",action:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",onClick:i,disabled:x,children:s("取消")}),e.jsx(A,{onClick:a,disabled:!p||x,children:s(x?"导出中...":"导出备份")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5 rounded-lg border border-warning/30 bg-warning/10 px-4 py-3 text-sm text-foreground",children:[e.jsx(Ce,{size:15,className:"mt-0.5 shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{children:s("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")})]}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:s("这个功能用于备份和迁移,不用于分享配置。")}),e.jsx("p",{children:s("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-border px-4 py-3 text-sm text-foreground",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:S=>f(S.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsx("span",{children:s("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function Cs({isOpen:t,onClose:i,preview:a,backup:p,onConfirm:f,isLoading:x}){const{t:s}=J();if(!a||!p)return null;const S=a.summary.create+a.summary.overwrite,r=[...a.items].sort((j,P)=>{const b={CREATE:0,OVERWRITE:1,SKIP:2};return b[j.action]-b[P.action]});return e.jsx(ke,{isOpen:t,onClose:i,title:s("导入 Provider 备份"),className:"max-w-3xl",action:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",onClick:i,disabled:x,children:s("取消")}),e.jsx(A,{onClick:f,disabled:S===0||x,children:x?s("导入中..."):s("确认导入 {count} 项",{count:S})})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{children:s("导出时间:{value}",{value:new Date(p.exportedAt).toLocaleString()})}),e.jsx("div",{children:s("模式:完整备份(含敏感信息)")}),e.jsx("div",{children:s("文件内 Provider 数量:{count}",{count:p.providers.length})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-success/25 bg-success/10 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-success-ink",children:s("新增")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.create})]}),e.jsxs("div",{className:"rounded-lg border border-warning/25 bg-warning/10 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-warning-ink",children:s("覆盖")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.overwrite})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 px-4 py-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s("跳过")}),e.jsx("div",{className:"text-[15px] font-semibold text-foreground",children:a.summary.skip})]})]}),e.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:r.map(j=>{const P=bs(j.action);return e.jsxs("div",{className:"rounded-lg border border-border px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"truncate text-sm font-medium text-foreground",children:j.incoming.name}),e.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${P.className}`,children:s(P.label)})]}),e.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{agentType:j.incoming.agentType,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:de(j.incoming.agentType,j.incoming.runtimeType)})," · ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j.incoming.id})]})]})}),j.action==="OVERWRITE"&&j.existing&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("将覆盖当前已有的 Provider:{name}",{name:j.existing.name})}),j.action==="SKIP"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前同 ID Provider 配置一致,本次不会重复写入。")}),j.action==="CREATE"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:s("当前不存在同 ID Provider,将直接新增。")})]},j.incoming.id)})})]})})}function ks({item:t,onEdit:i,onDelete:a,onEnabledChange:p,isUpdating:f}){const{t:x}=J(),s=t.provider,S=$e(t),r=Tt(s),j=Xe(s.agentType,s.config),P=fe[s.agentType],b=Object.entries(j).filter(([u])=>u!=="cmd"&&u!==P.executionPermission.path),g=Object.keys(s.redactedEnv||{});return e.jsxs("div",{className:"min-w-0 space-y-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("h3",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:s.name}),e.jsx(ys,{issue:S,disabled:s.enabled===!1})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx(le,{agentType:s.agentType,className:"size-3.5"}),e.jsx("span",{className:"truncate",children:de(s.agentType,s.runtimeType)})]}),s.isDefault&&e.jsx("span",{className:"rounded-full bg-primary/[0.06] px-2 py-0.5 text-xs font-medium text-primary",children:x("默认")}),s.builtIn&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:x("内置")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:shrink-0",children:[e.jsxs(A,{size:"sm",variant:"outline",onClick:i,children:[e.jsx(Zt,{size:13}),x("编辑")]}),e.jsxs(A,{size:"sm",variant:s.builtIn?"outline":"destructive",onClick:a,disabled:s.deletable===!1,children:[s.builtIn?e.jsx(Nt,{size:13}):e.jsx(We,{size:13}),s.builtIn?x("恢复默认"):x("删除")]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:"provider-enabled",className:"text-sm font-medium text-foreground",children:x("启用配置")}),e.jsx("p",{id:"provider-enabled-description",className:"mt-1 text-xs text-muted-foreground",children:x("禁用后不在 Agent 可选列表中显示,配置仍会保留,可随时重新启用。")})]}),e.jsx(Ee,{id:"provider-enabled",checked:s.enabled!==!1,disabled:f,onCheckedChange:p,"aria-describedby":"provider-enabled-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(pe,{children:x("Execution permission")}),e.jsx("p",{className:"text-sm",children:x(_t[Je(s).mode])}),r&&!s.diagnostics?.some(u=>u.field==="executionPermission")?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x(r)}):null,s.diagnostics?.filter(u=>u.field==="executionPermission").map((u,C)=>e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x(u.message)},`${u.code}-${C}`)),S&&!r?e.jsx("p",{role:"alert",className:"text-xs text-destructive-ink",children:x(S)}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:x("Changes apply when a new runtime starts. Running sessions keep their launch mode.")})]}),b.length>0&&e.jsxs("div",{children:[e.jsx(pe,{className:"mb-3",children:x("运行配置")}),e.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:b.map(([u,C])=>e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1 bg-background px-4 py-2.5 sm:flex-row sm:items-center sm:gap-4",children:[e.jsx("span",{className:"min-w-0 break-words text-[13px] text-muted-foreground sm:w-32 sm:shrink-0",children:x(Ve[u]??u)}),e.jsx("span",{className:"min-w-0 max-w-full break-all font-mono text-[13px] text-foreground",children:ps(u,C)})]},u))})]}),g.length>0&&e.jsxs("div",{children:[e.jsx(pe,{className:"mb-3",children:x("环境变量")}),e.jsx("div",{className:"grid gap-px overflow-hidden rounded-lg border border-border bg-border/60",children:g.map(u=>e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 bg-background px-4 py-2.5 sm:gap-4",children:[e.jsx("span",{className:"min-w-0 max-w-full break-all font-mono text-[13px] text-foreground",children:u}),e.jsx("span",{className:"text-[13px] text-muted-foreground","aria-label":"hidden",children:"•••••"})]},u))})]}),s.settings?.trim()&&e.jsxs("div",{children:[e.jsx(pe,{className:"mb-3",children:x("Agent 原生配置")}),e.jsx("div",{className:"rounded-lg border border-border bg-muted/40 p-4",children:e.jsx("pre",{className:"max-h-[200px] overflow-y-auto whitespace-pre-wrap break-all font-mono text-xs text-muted-foreground",children:s.settings})})]}),b.length===0&&g.length===0&&!s.settings?.trim()&&e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:x('该 Provider 未配置额外参数。点击"编辑"添加运行配置、环境变量或 Agent 原生配置。')})]})}function rn(){const{t}=J(),{data:i,isLoading:a}=zt(),p=Ft(),f=Jt(),x=$t(),s=qt(),S=Wt(),r=Gt(),j=y.useRef(null),[P,b]=y.useState(null),[g,u]=y.useState(null),[C,M]=y.useState(null),[F,$]=y.useState(!1),[V,L]=y.useState(!1),[K,R]=y.useState(null),[Y,T]=y.useState(!1),O=i??[],h=P??O[0]?.provider.id??null,k=d=>{p.mutate(d,{onSuccess:()=>u(null),onError:m=>U.error(G(m,t("创建 Provider 失败")))})},q=(d,m)=>{f.mutate({id:d,data:m},{onSuccess:()=>u(null),onError:I=>U.error(G(I,t("更新 Provider 失败")))})},Q=(d,m)=>{f.mutate({id:d,data:{enabled:m}},{onError:I=>U.error(G(I,t("更新 Provider 失败")))})},ge=d=>{if(!(d.deletable??!d.builtIn)){U.error(t("系统内置 Provider 不可删除"));return}M({id:d.id,name:d.name,builtIn:d.builtIn})},N=()=>{C&&x.mutate(C.id,{onSuccess:()=>{U.success(C.builtIn?t("已恢复默认 Provider 配置"):t("Provider 已删除")),h===C.id&&b(null),M(null),T(!1)},onError:d=>U.error(G(d,t("删除 Provider 失败")))})},B=()=>{$(!1),L(!1)},re=()=>R(null),ee=()=>{s.mutate(void 0,{onSuccess:d=>{vs(hs(d.exportedAt),d),U.success(t("Provider 备份已导出")),B()},onError:d=>U.error(G(d,t("导出 Provider 备份失败")))})},ie=()=>{j.current&&(j.current.value="",j.current.click())},ce=async d=>{const m=d.target.files?.[0];if(d.target.value="",!m)return;let I;try{I=JSON.parse(await m.text())}catch{U.error(t("备份文件不是有效的 JSON"));return}S.mutate(I,{onSuccess:W=>R({backup:I,preview:W}),onError:W=>U.error(G(W,t("导入预览失败")))})},H=()=>{K&&r.mutate(K.backup,{onSuccess:d=>{const m=d.summary.create+d.summary.overwrite;U.success(m===0?t("导入完成,当前配置无需变更"):t("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:d.summary.create,overwrite:d.summary.overwrite,skip:d.summary.skip})),re()},onError:d=>U.error(G(d,t("导入 Provider 备份失败")))})},Z=d=>{const m=d.provider,I=fe[m.agentType],W=Ot(m,I);u({id:m.id,data:{name:m.name,agentType:m.agentType,runtimeType:m.runtimeType===X.ACP?X.ACP:X.CLI,executionPermission:m.executionPermission,executionPermissionReviewRequired:m.executionPermissionReviewRequired,config:Xe(m.agentType,m.config),settings:m.settings??"",env:W,simplified:m.simplified??{},diagnostics:m.diagnostics,isDefault:m.isDefault}})};return a?e.jsx(Oe,{className:"max-w-5xl",children:e.jsx(gt,{})}):e.jsxs(Oe,{className:"max-w-5xl",children:[e.jsx("input",{ref:j,type:"file",accept:".json,application/json",className:"hidden",onChange:ce}),e.jsx(ht,{title:t("Agent 配置"),actions:e.jsxs(e.Fragment,{children:[e.jsxs(A,{variant:"outline",size:"sm",onClick:ie,disabled:S.isPending||r.isPending,children:[e.jsx(Ht,{size:13}),t("导入")]}),e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>$(!0),disabled:s.isPending,children:[e.jsx(vt,{size:13}),t("导出")]}),e.jsxs(A,{size:"sm",onClick:()=>u({}),children:[e.jsx(we,{size:13,className:"mr-1"}),t("新建")]})]})}),O.length===0?e.jsx(bt,{icon:jt,message:t("暂无 Agent 配置"),action:e.jsxs(A,{size:"sm",onClick:()=>u({}),children:[e.jsx(we,{size:13,className:"mr-1"}),t("新建配置")]})}):e.jsx(Vt,{items:O,selectedId:h,onSelectItem:d=>{b(d),T(!0)},getItemId:d=>d.provider.id,mobileShowDetail:Y,onMobileBack:()=>T(!1),renderListItem:d=>{const m=d.provider,I=$e(d);return e.jsxs(e.Fragment,{children:[e.jsx(js,{issue:I,disabled:m.enabled===!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:D("truncate text-[13px] font-medium",m.enabled===!1&&"text-muted-foreground"),children:m.name}),e.jsxs("div",{className:D("flex min-w-0 items-center gap-1.5 text-[11px]","text-muted-foreground"),children:[e.jsx(le,{agentType:m.agentType,className:"size-3.5",fallbackClassName:"text-muted-foreground"}),e.jsx("span",{className:"min-w-0 truncate",children:de(m.agentType,m.runtimeType)}),m.enabled===!1&&e.jsx("span",{className:"shrink-0",children:t("已禁用")})]}),I?e.jsx("div",{className:D("mt-0.5 break-words text-xs leading-snug text-destructive-ink"),children:t(I)}):null]}),m.isDefault&&e.jsx("span",{className:D("shrink-0 rounded px-1.5 py-0.5 text-xs font-medium","bg-primary/[0.06] text-primary"),children:t("默认")})]})},renderDetail:d=>d?e.jsx("div",{className:"min-w-0 p-5",children:e.jsx(ks,{item:d,onEdit:()=>Z(d),onDelete:()=>ge(d.provider),onEnabledChange:m=>Q(d.provider.id,m),isUpdating:f.isPending})}):e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:t("选择一个 Provider 查看详情")})}),g&&e.jsx(ws,{isOpen:!0,onClose:()=>u(null),providerId:g.id,initialData:g.data,onSave:d=>{g.id?q(g.id,d):k(d)}}),e.jsx(Xt,{isOpen:C!==null,onClose:()=>{x.isPending||M(null)},onConfirm:N,title:C?.builtIn?t("恢复默认 Provider"):t("删除 Provider"),description:C?.builtIn?t('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:C?.name}):t('确定删除 "{name}"?此操作不可撤销。',{name:C?.name}),confirmText:C?.builtIn?t("恢复默认"):t("删除"),cancelText:t("取消"),variant:"danger",isLoading:x.isPending}),e.jsx(Ps,{isOpen:F,onClose:B,onConfirm:ee,acknowledged:V,onAcknowledgedChange:L,isLoading:s.isPending}),e.jsx(Cs,{isOpen:!!K,onClose:re,preview:K?.preview??null,backup:K?.backup??null,onConfirm:H,isLoading:r.isPending})]})}export{ws as ProviderFormModal,rn as ProviderSettingsPage};
|
package/dist/web/assets/{SettingsMasterDetail-Cv7YaRJB.js → SettingsMasterDetail-CGCUalkW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as v,j as r,l as s,s as h}from"./index-
|
|
1
|
+
import{u as v,j as r,l as s,s as h}from"./index-BszkzNS4.js";function w({items:o,selectedId:l,onSelectItem:a,getItemId:t,renderListItem:d,renderDetail:g,renderListFooter:u,mobileShowDetail:c,onMobileBack:x,listClassName:f,detailClassName:b}){const{t:m}=v(),p=o.find(e=>t(e)===l)??null;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)] gap-5 lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100vh-16rem)] lg:max-h-[640px]",children:[r.jsxs("div",{className:s("min-w-0 space-y-1 lg:overflow-y-auto lg:pr-1 scrollbar-app-thin",c&&"hidden lg:block",f),children:[o.map(e=>{const n=t(e),i=n===l;return r.jsx("button",{onClick:()=>a(n),"aria-current":i?"true":void 0,className:s("flex min-w-0 w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",i?"bg-background text-foreground shadow-raised ring-1 ring-border/80":"text-foreground hover:bg-accent"),children:d(e,i)},n)}),u?.()]}),r.jsxs("div",{className:s("min-w-0 rounded-xl border border-border bg-card lg:overflow-y-auto scrollbar-app-thin",!c&&"hidden lg:block",b),children:[r.jsxs("button",{onClick:x,className:"mb-4 flex items-center gap-1.5 px-5 pt-3 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 lg:hidden",children:[r.jsx(h,{size:14}),m("返回列表")]}),g(p)]})]})}export{w as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as Re,r as n,ai as _t,j as e,B as oe,aj as Kt,a5 as Js,a6 as qt,ak as Vt,al as Gt,am as Ht,an as Qt,ao as $t,ap as F,aq as Xt,ar as Yt,o as Jt,p as Zt,q as Ie,as as ms,at as en,af as Zs,ag as U,au as sn,av as tn,s as nn,aw as et,ax as rn,a3 as on,ay as an,az as W,a0 as ln,aA as cn}from"./index-BszkzNS4.js";import{u as dn,r as un,c as mn,g as _e,a as pn,b as fn,d as xn,e as gn,f as hn,h as bn,W as vn,E as jn,i as yn,C as kn,S as Cn,T as st,R as wn,j as Nn,k as In,l as Sn,m as Rn,n as Tn,o as An,p as En}from"./TaskHandoffPanel-CJahUKNo.js";import{r as Wn,a as tt,Q as Pn,s as Dn}from"./mermaid-NOHMQCX5-CYeAhOl-.js";import{t as Mn,g as nt,a as rt,D as On}from"./ProjectKanbanPage-CuGSLvrU.js";import{u as Ln,a as Bn,R as zn,P as Fn,T as Un}from"./useTokenUsage-D7SEwXb0.js";import{u as _n,a as Kn,L as ot,T as at}from"./useNormalizedLogs-Bstb98cF.js";import{g as qn}from"./ExecutionPermissionSelector-C-akTOVg.js";import{u as Vn,A as Gn}from"./AttachmentPreview-TPd4gdfb.js";import{T as Hn,u as Qn,a as $n,b as Xn,c as Yn,d as Jn,e as Zn,S as it}from"./CreateTaskInput-TcZpjBe-.js";import{u as er,a as sr,b as tr,c as nr,d as rr,e as or}from"./BranchSelect-Kv3M1YhZ.js";import{u as ar}from"./use-providers-Bz6YNiYj.js";import{i as ir}from"./provider-selection-DSu7SCI7.js";import{M as lr}from"./modal-BwOwTzij.js";import{C as cr}from"./confirm-dialog-CCjHVFTv.js";import{C as dr,P as ps}from"./content-DZozZbBD.js";import{P as fs,T as ur}from"./trash-2-BEOQ1ICJ.js";import{P as mr}from"./paperclip-C4t49vX2.js";import"./use-translation-settings-CCpQNS30.js";import"./MemberAvatar-CJtylxwu.js";import"./people-Dr0v8HK0.js";import"./chevron-down-Ct7FZbKm.js";import"./chevron-up-ARFlXMyO.js";import"./at-sign-Cf39WHCg.js";import"./check-yNWhPvMH.js";import"./tooltip-Cirpotu3.js";import"./kbd-8RRRm9jd.js";import"./index-BPqjxXmH.js";import"./index-lZLy5rkr.js";import"./index-DkSPjZm4.js";import"./BrandLogo-fR2lCwEo.js";import"./popover-CTqvKqTR.js";import"./search-CMIAPUEt.js";import"./index-DgUtx9rV.js";import"./index-DuM6iAxG.js";import"./index-GuczxPxb.js";import"./select-DqB7YF38.js";import"./select-Bg7NI8i0.js";import"./menu-styles-DWynpVVz.js";import"./index-BMcLxIvZ.js";import"./layers-BH_LL4b8.js";import"./message-square-DykJ2lWP.js";import"./textarea-BCY2J2ca.js";import"./menu-CMqbaDni.js";import"./server-D7knl8H9.js";import"./upload-tLVD0xMT.js";import"./globe-DAFqpAcW.js";import"./pencil-BQ5_raiB.js";import"./copy-C-jvx2et.js";import"./chip-BV_1-tIb.js";import"./folder-picker-DiR-8Qdl.js";import"./track-Cv7h6oaE.js";import"./dialog-DV4wfpNU.js";import"./file-Btui_I8Z.js";function pr({isOpen:t,onClose:x,taskId:R}){const{t:c}=Re(),[C,w]=n.useState("AUTO"),[N,g]=n.useState(null),[T,o]=n.useState([]),[h,P]=n.useState(null),Te=_t();n.useEffect(()=>{t&&(w("AUTO"),g(null),o([]),P(null))},[t]);const D=Te.isPending,Ke=!!N||T.length>0,ae=async()=>{if(!D){if(!N&&T.length===0){P(c("请选择至少一个团队模板或成员预设。"));return}P(null);try{await Te.mutateAsync({taskId:R,mode:C,...N?{teamTemplateId:N}:{},...T.length>0?{memberPresetIds:T}:{}}),x()}catch(G){P(G instanceof Error?G.message:c("创建 TeamRun 失败"))}}},qe=D||!Ke;return e.jsxs(lr,{isOpen:t,onClose:D?()=>{}:x,title:c("创建 TeamRun"),className:"max-w-5xl",action:e.jsxs(e.Fragment,{children:[e.jsx(oe,{type:"button",variant:"outline",onClick:x,disabled:D,children:c("取消")}),e.jsx(oe,{type:"button",onClick:ae,disabled:qe,children:c(D?"处理中...":"创建 TeamRun")})]}),children:[e.jsx(Hn,{mode:C,setMode:w,selectedTemplateId:N,setSelectedTemplateId:g,selectedMemberPresetIds:T,setSelectedMemberPresetIds:o,disabled:D}),h&&e.jsx("div",{role:"alert",className:"rounded-lg border border-destructive/25 bg-destructive/10 px-4 py-3 text-sm text-destructive-ink",children:h})]})}function fr({workspaceId:t,gitStatus:x,onResolve:R}){const{t:c}=Re(),C=er();if(x.operation==="idle"||x.conflictedFiles.length===0)return null;const w=x.operation==="rebase"?"Rebase":"Merge";return e.jsx(Kt,{tone:"warning",className:"mx-6 mt-3 items-center",title:e.jsxs("span",{className:"flex items-center gap-2",children:[w," ",c("冲突"),e.jsxs(qt,{tone:"warning",className:"tabular-nums",children:[x.conflictedFiles.length," ",c("个文件")]})]}),action:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Js,{variant:"ghost",onClick:()=>C.mutate(t),loading:C.isPending,children:c("中止操作")}),e.jsx(Js,{variant:"primary",onClick:R,children:c("解决冲突")})]})})}const xr=ln(),gr=t=>t.includes("://")||t.startsWith("/api/")?t:t.startsWith("/")?`${xr}/attachments/by-path?path=${encodeURIComponent(t)}`:t,re=520,xs=48,hr=4,br=420;function vr(){const{t}=Re();return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground select-none",children:[e.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-xl border border-border/60 flex items-center justify-center mb-6",children:e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground",children:[e.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),e.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsx("h3",{className:"text-foreground font-medium mb-2 text-[15px]",children:"Agent Tower"}),e.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:t("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}function Se(t){const x=cn[t].icon;return e.jsx(x,{className:"size-3"})}const lt=[{status:W.Review,className:"bg-warning/10 text-warning-ink",hoverClass:"hover:bg-warning/15",icon:Se(W.Review)},{status:W.Running,className:"bg-info/10 text-info-ink",hoverClass:"hover:bg-info/15",icon:Se(W.Running)},{status:W.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:Se(W.Pending)},{status:W.Done,className:"bg-success/10 text-success-ink",hoverClass:"hover:bg-success/15",icon:Se(W.Done)},{status:W.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:Se(W.Cancelled)}];function jr({status:t,ownStatus:x=t,summary:R,onChangeStatus:c}){const{t:C}=Re(),[w,N]=n.useState(!1),g=n.useRef(null);n.useEffect(()=>{if(!w)return;const o=h=>{g.current&&!g.current.contains(h.target)&&N(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[w]);const T=lt.find(o=>o.status===t);return e.jsxs("div",{className:"relative",ref:g,children:[e.jsxs("button",{title:R,onClick:()=>c&&N(o=>!o),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${T.className} ${c?"cursor-pointer hover:opacity-80":""}`,children:[T.icon,e.jsx("span",{children:C(t)}),c&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${w?"rotate-180":""}`,children:e.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),w&&e.jsxs("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-popover z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:[x!==t&&e.jsx("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:C("Own status: {status}",{status:C(x)})}),lt.filter(o=>o.status!==x).map(o=>e.jsxs("button",{onClick:()=>{c?.(o.status),N(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${o.hoverClass}`,children:[e.jsx("span",{className:o.className.split(" ").find(h=>h.startsWith("text-")),children:o.icon}),e.jsx("span",{className:"text-foreground/80",children:C(o.status)})]},o.status))]})]})}function yo({task:t,onSelectTask:x,onCreateSubtask:R,onDeleteTask:c,isDeleting:C,onTaskStatusChange:w,onTaskPriorityChange:N,autoStartState:g,onAutoStartRecovered:T}){const{t:o}=Re(),[h,P]=n.useState(""),[Te,D]=n.useState(!1),[Ke,ae]=n.useState(!1),[qe,G]=n.useState(!1),[ct,Ve]=n.useState(!1),[dt,gs]=n.useState(!1),Ae=n.useRef(null),[Ge,H]=n.useState(!1),[A,He]=n.useState(null),[ie,Q]=n.useState(void 0),[$,Ee]=n.useState(!1),Qe=n.useRef(null),$e=n.useRef(null),le=n.useRef(null),hs=n.useRef(null),{scrollRef:_,contentRef:bs,isAtBottom:vs,scrollToBottom:We,stopScroll:js}=Ln({resize:"smooth",initial:"instant"}),[M,ys]=n.useState(!1),[Xe,ce]=n.useState(re),[Pe,ks]=n.useState(!1),Cs=n.useRef(0),ws=n.useRef(re),Ns=n.useRef(null),Ye=n.useCallback((s,r,i)=>{Ae.current?.openFile(s,r,i)},[]),{data:a,isLoading:ut}=sr(t?.id??""),de=dn(t?.id),Is=de?.status==="completed"&&g?.status!=="failed"?null:g,Je=!!(Is||de&&de.status!=="completed"),{data:ue}=Vt(t?.id??""),{data:mt}=Gt(ue?.id??""),Ss=Ht(ue?.id??""),d=ue??null,me=!!d,X=t?.isGitRepo!==!1&&t?.worktreeReady!==!1,De=ue===null&&X,pt=!!(t?.id&&ue===null),{data:Y,isLoading:Rs}=Qt(t?.id??"",pt);n.useEffect(()=>{Ee(!1),He(null),Q(void 0)},[t?.id]);const K=n.useMemo(()=>un(a,d,ie),[ie,d,a]);n.useEffect(()=>{ie&&!a?.some(s=>s.id===ie)&&Q(void 0)},[ie,a]);const p=n.useMemo(()=>a?.find(s=>s.id===K),[K,a]),k=p?.status===$t.ACTIVE?p.id:void 0,pe=X&&mn(p,d);n.useEffect(()=>{if(!$||!a)return;a.some(r=>r.status==="ACTIVE"&&r.sessions&&r.sessions.length>0)&&Ee(!1)},[a,$]);const f=n.useMemo(()=>{if($||!a)return null;const s=l=>{const us=l.createdAt,Ne=l.endedAt??l.startedAt??us;if(!Ne)return 0;const ne=Date.parse(Ne);return Number.isNaN(ne)?0:ne},r=(l,us)=>{const Ne=l.filter(ne=>us.includes(ne.status));return Ne.length===0?null:Ne.sort((ne,Ut)=>s(Ut)-s(ne))[0]??null},i=a.filter(l=>l.status==="ACTIVE"&&Array.isArray(l.sessions)).flatMap(l=>l.sessions??[]),m=r(i,[F.RUNNING])??r(i,[F.PENDING])??r(i,[F.COMPLETED,F.FAILED,F.CANCELLED]);if(m)return m;const S=a.filter(l=>(l.status==="MERGED"||l.status==="ABANDONED"||l.status==="HIBERNATED")&&Array.isArray(l.sessions)).flatMap(l=>l.sessions??[]);return r(S,[F.COMPLETED,F.FAILED,F.CANCELLED])},[a,$]),J=f?.id??"",b=me?A??"":J,ft=n.useMemo(()=>{if(!A||!a)return null;for(const s of a){const r=s.sessions?.find(i=>i.id===A);if(r)return r}return null},[A,a]),Ze=n.useMemo(()=>{if(!A||!d?.invocations)return null;const s=d.invocations.filter(r=>r.sessionId===A);return s.length===0?null:s.sort((r,i)=>{const m=Date.parse(r.updatedAt??r.createdAt??""),S=Date.parse(i.updatedAt??i.createdAt??"");return(Number.isNaN(S)?0:S)-(Number.isNaN(m)?0:m)})[0]??null},[A,d?.invocations]),xt=n.useMemo(()=>!Ze?.memberId||!d?.members?null:d.members.find(s=>s.id===Ze.memberId)??null,[Ze?.memberId,d?.members]),v=A?ft:f??null,L=v?.id,Z=n.useMemo(()=>{if(v?.workspaceId)return v.workspaceId;if(!(!v||!a))return a.find(s=>s.sessions?.some(r=>r.id===v.id))?.id},[v,a]),Me=n.useCallback((s,r)=>{const m=(r&&a?.some(S=>S.id===r)?r:void 0)??Z??K??void 0;m&&Q(m),Ae.current?.openPreview(s,m)},[Z,K,a]),es=n.useCallback((s,r)=>{Me({kind:"web",url:s},r)},[Me]),ss=n.useCallback((s,r,i)=>{Me({kind:"visualization",sessionId:s,file:r},i)},[Me]),Ts=n.useCallback(s=>{es(s,Z)},[Z,es]),As=n.useCallback(s=>{L&&ss(L,s,Z)},[L,Z,ss]),{isActive:fe,isCancelling:xe}=Qn(L??"",v?.status),u=!!t?.projectArchivedAt,Es=!!t?.projectRepoDeletedAt,ts=o(Es?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:ee}=ar(),[Oe,Ws]=n.useState(null),Le=f?qn(ee,Oe??f.providerId):void 0;n.useEffect(()=>{Ws(f?.providerId??null)},[f?.providerId]);const gt=n.useMemo(()=>!f||!a?!1:!a.some(r=>r.status==="ACTIVE"&&r.sessions?.some(i=>i.id===f.id)),[f,a]),I=n.useMemo(()=>{if(!(!a||$)){if(p)return _e(p);for(const s of a)if(s.status==="ACTIVE"&&_e(s))return _e(s);return _e(a[0])}},[$,p,a]),q=$n({agentType:f?.agentType,workingDir:I,input:h,setInput:P,textareaRef:le,minHeight:60,maxHeight:300}),V=pn({agentType:f?.agentType,workingDir:I,input:h,setInput:P,textareaRef:le,minHeight:60,maxHeight:300}),ns=Xt(s=>s.setVisibleContext),ge=!!(pe&&k&&I&&!u),{data:E,isLoading:ht}=tr(k??"",{enabled:ge}),{data:bt}=fn(I,{enabled:ge});n.useEffect(()=>{if(!(M||!ge||!k||!I))return ns({workspaceId:k,workingDir:I,tab:"changes"}),()=>{ns(null)}},[M,k,ns,ge,I]);const vt=p?.sessions??[],he=xn(p),Ps=p?.commitMessage,be=n.useMemo(()=>gn(p,a,t?.mainBranch??""),[p,t?.mainBranch,a]),ve=hn((a??[]).map(s=>s.id),!me),{pendingConflictDetails:je}=ve,Ds=!!je,j=n.useMemo(()=>je||(E?.conflictOp&&E.conflictedFiles.length>0?Yt({conflictOp:E.conflictOp,conflictedFiles:E.conflictedFiles,resolutionContextToken:E.resolutionContextToken,sourceWorkspaceId:k,sourceWorktreePath:p?.worktreePath,sourceBranch:he,targetBranch:be}):je),[E,je,k,p?.worktreePath,he,be]),Ms=j?.targetWorkspaceId??k,jt=j?.targetWorktreePath??p?.worktreePath,yt=j?.sourceBranch??he,kt=j?.targetBranch??be,y=Jt(),Be=n.useCallback(async()=>t?.id?y.fetchQuery({queryKey:Ie.tasks.body(t.id),queryFn:()=>Zt.get(`/tasks/${t.id}/body`)}):null,[y,t?.id]),Os=n.useCallback(()=>t?.id?y.invalidateQueries({queryKey:Ie.workspaces.list(t.id)}):Promise.resolve(),[t?.id,y]);n.useEffect(()=>{if(!Ge)return;const s=r=>{$e.current&&!$e.current.contains(r.target)&&H(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[Ge]);const B=Xn(),Ls=nr(),Bs=rr(t?.id??""),zs=Yn(),rs=or(),ye=n.useMemo(()=>!a||a.some(r=>r.status==="ACTIVE")?null:a.find(r=>r.status==="HIBERNATED")??null,[a]),os=n.useRef(null);n.useEffect(()=>{ye&&os.current!==ye.id&&(rs.isPending||(os.current=ye.id,rs.mutate(ye.id,{onSettled:()=>{os.current=null}})))},[ye,rs]);const Ct=n.useCallback(async()=>{if(!t?.id)return;const s=f?.providerId??ee?.find(r=>ir(r)&&r.availability.type!=="NOT_FOUND")?.provider.id;if(s){Ve(!1),gs(!0);try{const i=(await Be())?.prompt??t.title;Ee(!0),await Mn(t.id,{providerId:s,prompt:i,retryTask:!0,workspaceKind:X?ms.WORKTREE:ms.MAIN_DIRECTORY},{createWorkspace:m=>Bs.mutateAsync({clientSubmissionId:m,workspaceKind:X?void 0:ms.MAIN_DIRECTORY}),startSession:m=>zs.mutateAsync(m)}),await y.invalidateQueries({queryKey:Ie.workspaces.list(t.id)})}catch(r){console.error("[retry] failed:",r),Ee(!1)}finally{gs(!1)}}},[t?.id,t?.title,X,f?.providerId,ee,Be,Bs,zs,y]),as=n.useCallback(async()=>{t?.id&&(await Be(),D(!0))},[Be,t?.id]),wt=n.useCallback(()=>{p?.id&&Ls.mutate({workspaceId:p.id})},[Ls,p?.id]),Nt=n.useCallback(s=>{!t?.id||!c||(c(t.id,s),G(!1))},[t?.id,c]),Fs=n.useCallback(s=>{He(s),requestAnimationFrame(()=>{We()})},[We]),It=n.useCallback(()=>{He(null)},[]),ke=n.useCallback(s=>{const r=s??j;r&&ve.openDialog(r)},[j,ve]),St=n.useCallback(s=>Ss.mutateAsync(s),[Ss]),se=n.useCallback(()=>{y.invalidateQueries({queryKey:en.all})},[y]),{isConnected:Us,isLoadingSnapshot:_s,isOutputActive:Ks,lastExitAt:qs,logs:Ce,entries:Rt,attach:ze}=_n({sessionId:b,sessionStatus:v?.status,sessionStartedAt:v?.startedAt??v?.createdAt,sessionEndedAt:v?.endedAt??(fe?null:v?.updatedAt),onExit:n.useCallback(()=>{y.invalidateQueries({queryKey:["workspaces"]})},[y])});n.useEffect(()=>{if(!t?.id)return;const s=Zs.connect(),r=Wn(t.id),i=l=>{l.taskId===t.id&&(y.invalidateQueries({queryKey:["tasks"]}),se())},m=l=>{l.taskId===t.id&&(y.invalidateQueries({queryKey:Ie.workspaces.list(t.id)}),se())},S=l=>{l.taskId===t.id&&(y.invalidateQueries({queryKey:Ie.workspaces.list(t.id)}),se())};return s.on(U.TASK_UPDATED,i),s.on(U.WORKSPACE_COMMIT_MESSAGE_UPDATED,m),s.on(U.WORKSPACE_HIBERNATED,S),()=>{s.off(U.TASK_UPDATED,i),s.off(U.WORKSPACE_COMMIT_MESSAGE_UPDATED,m),s.off(U.WORKSPACE_HIBERNATED,S),r()}},[t?.id,y,se]),n.useEffect(()=>{if(!b)return;const s=Zs.connect(),r=i=>{i.sessionId===b&&(y.invalidateQueries({queryKey:["workspaces"]}),se())};return s.on(U.SESSION_COMPLETED,r),()=>{s.off(U.SESSION_COMPLETED,r)}},[b,y,se]);const{todos:Fe}=Kn(Rt),{files:Tt,addFiles:te,removeFile:At,clear:Vs,getDoneAttachments:Gs,hasFiles:we,isUploading:Ue}=Vn(),Et=n.useMemo(()=>bn(v),[v?.tokenUsage]),Hs=Bn(Ce,Et);n.useEffect(()=>{b&&Us&&ze()},[b,Us,ze]);const Qs=n.useRef(t?.id);n.useEffect(()=>{if(Qs.current!==t?.id&&_.current){const s=_.current;requestAnimationFrame(()=>{s.scrollTop=s.scrollHeight})}Qs.current=t?.id},[t?.id,_]);const z=Jn(),is=n.useRef(!1),$s=n.useCallback(async()=>{if(!h.trim()&&!we||!b||is.current||z.isPending||xe||Ue||Le)return;is.current=!0;const s=Gs().map(i=>i.id),r=h.trim()||(s.length?" ":"");P(""),Vs(),le.current&&(le.current.style.height="60px"),B.mutate({id:b,message:r,attachmentIds:s,providerId:Oe??void 0},{onSuccess:()=>{ze()},onSettled:()=>{is.current=!1}})},[h,b,B,ze,we,Ue,Gs,Vs,Oe,Le,z.isPending,xe]),Wt=n.useCallback(()=>{!b||z.isPending||z.mutate(b)},[b,z]),Pt=n.useCallback(s=>{const r=s.target.files;r&&r.length>0&&te(Array.from(r)),s.target.value=""},[te]),Dt=n.useCallback(s=>{const r=s.clipboardData.items,i=[];for(const m of r)if(m.kind==="file"){const S=m.getAsFile();S&&i.push(S)}i.length>0&&(s.preventDefault(),te(i))},[te]),[Xs,ls]=n.useState(!1),Mt=n.useCallback(s=>{s.preventDefault(),ls(!0)},[]),Ot=n.useCallback(s=>{s.preventDefault(),ls(!1)},[]),Lt=n.useCallback(s=>{s.preventDefault(),ls(!1);const r=s.dataTransfer.files;r.length>0&&te(Array.from(r))},[te]),O=n.useCallback(s=>{const r=Ns.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),i=r?Math.max(re,r-xs-hr-br):re;return Math.max(re,Math.min(Math.round(s),i))},[]),cs=n.useCallback(s=>{const r=s.clientX-Cs.current;ce(O(ws.current-r))},[O]),ds=n.useCallback(()=>{ks(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);n.useEffect(()=>{if(Pe)return document.addEventListener("mousemove",cs),document.addEventListener("mouseup",ds),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",cs),document.removeEventListener("mouseup",ds),document.body.style.cursor="",document.body.style.userSelect=""}},[ds,cs,Pe]);const Bt=n.useCallback(s=>{s.preventDefault(),Cs.current=s.clientX,ws.current=Xe,ks(!0)},[Xe]);n.useEffect(()=>{!M||Pe||ce(s=>O(s))},[O,M,Pe]),n.useEffect(()=>{if(!M)return;const s=()=>{ce(r=>O(r))};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[O,M]);const zt=n.useCallback(()=>{ce(s=>O(s)),ys(!0),requestAnimationFrame(()=>{Ae.current?.setTab("review")})},[O]),Ft=n.useCallback(s=>{P(s.target.value);const r=s.target;r.style.height="auto";const i=r.scrollHeight;r.style.height=`${Math.max(60,Math.min(i,300))}px`},[]),Ys=ge&&k?e.jsx(vn,{projectId:t?.projectId??"",workspaceId:k,branchName:he,targetBranch:be,commitMessage:Ps,changes:bt,gitStatus:E,isGitStatusLoading:ht,canRunGitOperations:pe,onOpenChanges:zt,onRefreshCommitMessage:Os,onConflict:ke,className:"mb-1.5"}):null;return t?e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t.projectColor.replace("text-","bg-")}`}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.projectName}),t.projectArchivedAt&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground shrink-0",children:t.projectRepoDeletedAt?o("源码已删除"):o("已删除")}),e.jsx("span",{className:"text-muted-foreground text-xs",children:"/"}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate",children:t.branch})]}),e.jsx(jn,{taskId:t.id,title:t.title,readOnly:u})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[nt(t,o)&&e.jsx("span",{className:"max-w-56 truncate text-xs text-muted-foreground",title:rt(t,o),children:nt(t,o)}),e.jsx(jr,{status:t.status,ownStatus:t.ownStatus,summary:rt(t,o),onChangeStatus:!u&&w?s=>w(t.id,s):void 0}),e.jsx(Zn,{value:t.priority,onChange:!u&&N?s=>N(t.id,s):void 0}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:wt,disabled:!I||u,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:o("Open in IDE"),children:e.jsx(dr,{size:16})}),(c||R||De)&&!u&&e.jsxs("div",{className:"relative",ref:$e,children:[e.jsx("button",{onClick:()=>H(s=>!s),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:o("More actions"),children:e.jsx(yn,{size:16})}),Ge&&e.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-popover z-50 py-1",children:[R&&sn(t)&&e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50",onClick:()=>{H(!1),R(t.id)},children:[e.jsx(fs,{size:15}),e.jsx("span",{children:o("Create subtask")})]}),De&&e.jsxs("button",{onClick:()=>{ae(!0),H(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[e.jsx(fs,{size:15}),e.jsx("span",{children:o("创建 TeamRun")})]}),e.jsxs("button",{onClick:()=>{Ve(!0),H(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[e.jsx(tn,{size:15}),e.jsx("span",{children:o("重新开始")})]}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-1 border-t border-border/60"}),e.jsxs("button",{onClick:()=>{G(!0),H(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive-ink hover:bg-destructive/10 transition-colors",children:[e.jsx(ur,{size:15}),e.jsx("span",{children:o("删除任务")})]})]})]})]})]})]})]}),!me&&e.jsx(kn,{recovery:ve,onRecover:s=>{Q(s.sourceWorkspaceId),ke(s)}}),pe&&k&&E&&e.jsx(fr,{workspaceId:k,gitStatus:E,onResolve:()=>ke()}),e.jsxs("div",{ref:Ns,className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:me&&d?A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:o("Invocation details")}),e.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:A})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(Cn,{session:v,providers:ee,usage:Hs,providerIdFallback:xt?.providerId,agentTypeFallback:v?.agentType,tokenTooltipSide:"bottom"}),e.jsxs(oe,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:It,children:[e.jsx(nn,{size:13}),e.jsx("span",{children:o("Team room")})]})]})]}),e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:_,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:e.jsxs("div",{ref:bs,className:"w-full max-w-4xl mx-auto",children:[!d&&t&&e.jsx(st,{taskId:t.id}),_s?e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground",children:[e.jsxs("svg",{className:"animate-spin motion-reduce:[animation-duration:2.4s] h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:o("Loading logs...")})]}):Ce.length===0&&!b?e.jsx("div",{className:"text-muted-foreground text-center py-8",children:o(fe?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(ot,{children:e.jsx(tt,{logs:Ce,sessionId:L,downloadSessionId:L,isOutputActive:Ks,lastExitAt:qs,onUserToggleDetails:js,workingDir:I,scrollElementRef:_,onOpenWorkspaceFile:Ye,onOpenPreviewUrl:Ts,onOpenVisualization:As})})]})}),!vs&&e.jsxs("button",{onClick:()=>We(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-raised text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":o("Scroll to bottom"),children:[e.jsx(et,{size:14}),e.jsx("span",{children:o("回到底部")})]})]}),Fe.length>0&&e.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(at,{todos:Fe})})})]}):e.jsx(wn,{teamRun:d,messages:mt??d.messages??[],readOnly:u,readOnlyMessage:ts,onSendMessage:St,onViewInvocationSession:Fs,changeSummaryBar:Ys,centered:!0,workingDir:I,onOpenWorkspaceFile:Ye,onOpenPreviewUrl:es,onOpenVisualization:ss}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:_,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:e.jsxs("div",{ref:bs,className:"w-full min-w-0 max-w-4xl mx-auto",children:[!d&&t&&e.jsx(st,{taskId:t.id}),(Rs||Y?.body)&&e.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Rs?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:o("Loading...")}):Y?.body?e.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:e.jsx(Pn,{urlTransform:gr,components:Dn,children:Y.body})}):null}),!u&&e.jsx(Nn,{state:Is,setupProgress:de,sessionStarted:!!f?.startedAt,onRetry:J&&g?.status==="failed"?as:void 0},t.id),ut?(!Je||u)&&e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground",children:[e.jsxs("svg",{className:"animate-spin motion-reduce:[animation-duration:2.4s] h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:o("Loading...")})]}):J?_s?e.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground",children:[e.jsxs("svg",{className:"animate-spin motion-reduce:[animation-duration:2.4s] h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.jsx("span",{className:"text-sm",children:o("Loading logs...")})]}):Ce.length===0&&!b?e.jsx("div",{className:"text-muted-foreground text-center py-8",children:o(fe?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(ot,{children:e.jsx(tt,{logs:Ce,sessionId:L,downloadSessionId:L,isOutputActive:Ks,lastExitAt:qs,onUserToggleDetails:js,workingDir:I,scrollElementRef:_,onOpenWorkspaceFile:Ye,onOpenPreviewUrl:Ts,onOpenVisualization:As})}):!Je||g?.status==="failed"||de?.status==="failed"||u?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(!Je||u)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-xl border border-border/60 flex items-center justify-center mb-5",children:e.jsx(ps,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:o(u?"项目为只读历史":"尚未启动 Agent")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:u?ts:o("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")})]}),!u&&(!g||g.status==="failed")&&e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[e.jsxs(oe,{onClick:as,disabled:!!(g&&g.status!=="failed"),children:[e.jsx(ps,{size:16,className:"mr-1.5"}),g?.status==="failed"?o("重试启动 Agent"):o("启动 Agent")]}),De&&e.jsxs(oe,{variant:"outline",onClick:()=>ae(!0),children:[e.jsx(fs,{size:16,className:"mr-1.5"}),o("创建 TeamRun")]})]})]}):null]})}),!vs&&e.jsxs("button",{onClick:()=>We(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-raised text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":o("Scroll to bottom"),children:[e.jsx(et,{size:14}),e.jsx("span",{children:o("回到底部")})]})]}),Fe.length>0&&e.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx(at,{todos:Fe})})}),u?e.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:ts})})}):gt?e.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:e.jsx("div",{className:"max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:o("代码已合并,以上为历史沟通记录")}),e.jsxs(oe,{size:"sm",onClick:as,children:[e.jsx(ps,{size:14,className:"mr-1.5"}),o("启动新 Agent")]})]})})}):e.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Mt,onDragLeave:Ot,onDrop:Lt,children:[e.jsxs("div",{className:"max-w-4xl mx-auto",children:[Ys,b?e.jsx(zn,{sessionId:b}):null,e.jsxs("div",{ref:Qe,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${Xs?"border-foreground/40 bg-foreground/[0.02]":"border-border"}`,children:[e.jsx(Gn,{files:Tt,onRemove:At}),e.jsx("textarea",{ref:le,value:h,onChange:Ft,onPaste:Dt,onKeyDown:s=>{V.handleKeyDown(s)||q.handleKeyDown(s)||s.key==="Enter"&&!s.shiftKey&&!s.repeat&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229&&(s.preventDefault(),$s())},rows:1,placeholder:o(Xs?"Drop files here...":J&&!fe?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),e.jsx("input",{ref:hs,type:"file",multiple:!0,className:"hidden",onChange:Pt}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("button",{onClick:()=>hs.current?.click(),className:"p-2 text-muted-foreground hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:o("Upload file"),children:e.jsx(mr,{size:18})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[f&&ee&&e.jsx(Fn,{providers:ee,currentProviderId:Oe,agentType:f.agentType,runtimeType:f.runtimeType,onSelect:Ws}),e.jsx(Un,{usage:Hs}),fe&&!B.isPending&&!h.trim()&&!we?e.jsx("button",{onClick:Wt,disabled:z.isPending||xe,"aria-label":o("Stop"),title:o("Stop"),className:"p-2 rounded-lg transition-all duration-200 bg-destructive-ink text-white hover:bg-destructive-ink/90 disabled:opacity-50",children:e.jsx(rn,{size:14})}):e.jsx("button",{onClick:$s,"aria-label":o(B.isPending?"发送中...":"Send"),"aria-busy":B.isPending,disabled:!h.trim()&&!we||Ue||B.isPending||z.isPending||xe||!!Le,className:`p-2 rounded-lg transition-all duration-200 ${(h.trim()||we)&&!Ue&&!B.isPending&&!z.isPending&&!xe&&!Le?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground cursor-not-allowed"}`,children:B.isPending?e.jsx(on,{size:18,className:"animate-spin"}):e.jsx(an,{size:18})})]})]})]})]}),e.jsx(it,{open:q.query!==null,anchorRef:Qe,commands:q.filteredCommands,selectedIndex:q.selectedIndex,query:q.query??"",hasCatalog:q.allCommands.length>0,onSelect:q.applyCommand}),e.jsx(it,{open:V.query!==null,anchorRef:Qe,commands:V.filteredSkills,selectedIndex:V.selectedIndex,query:V.query??"",hasCatalog:V.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:V.applySkill})]})]})}),M&&e.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:Bt,role:"separator","aria-orientation":"vertical","aria-label":o("调整工作区宽度")}),e.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:M?xs+Xe:xs},children:e.jsx(In,{handoff:e.jsx(Tn,{taskId:t.id,readOnly:u},t.id),subtasks:e.jsx(Rn,{task:t,onSelectTask:x,onCreateSubtask:R},t.id),sessionId:J||void 0,workspaceId:K,workingDir:I,projectId:t.projectId,readOnly:u,repoDeleted:Es,teamRun:d,teamStatus:d?e.jsx(Sn,{teamRun:d,workspaces:a,selectedWorkspaceId:K,onSelectWorkspace:Q,onViewInvocationSession:Fs}):void 0,workspaces:a,selectedWorkspaceId:K,onSelectWorkspace:Q,variant:"rail",expanded:M,onExpandedChange:s=>{s&&ce(r=>O(r)),ys(s)},minContentWidth:re,tabRef:Ae,gitAvailable:X,gitProps:pe&&k?{branchName:he,targetBranch:be,commitMessage:Ps,canRunGitOperations:!0,onRefreshCommitMessage:Os,onConflict:ke,onResolveConflicts:()=>ke()}:void 0})})]}),!u&&e.jsx(An,{isOpen:Te,onClose:()=>D(!1),taskId:t.id,projectId:t.projectId,taskTitle:Y?.title??t.title,taskDescription:Y?.body??"",taskPrompt:Y?.prompt,projectIsGitRepo:t.isGitRepo,projectWorktreeReady:t.worktreeReady,projectGitReason:t.reason,onStarted:()=>T?.(t.id)}),De&&!u&&e.jsx(pr,{isOpen:Ke,onClose:()=>ae(!1),taskId:t.id}),Ds&&pe&&Ms&&j&&e.jsx(En,{open:Ds,onOpenChange:s=>{s||ve.closeDialog()},workspaceId:Ms,conflictOp:j.conflictOp,conflictedFiles:j.conflictedFiles,resolutionContextToken:j.resolutionContextToken,sourceBranch:yt,targetBranch:kt,operation:E?.operation,worktreePath:jt,mergeAborted:j.mergeAborted,mergeStrategy:j.mergeStrategy,sourceWorkspaceId:j.sourceWorkspaceId,targetWorkspaceId:j.targetWorkspaceId,sourceWorktreePath:j.sourceWorktreePath,targetWorktreePath:j.targetWorktreePath,sessions:vt,currentSessionId:me?void 0:J,teamRunId:d?.id}),e.jsx(cr,{isOpen:ct,onClose:()=>Ve(!1),onConfirm:Ct,title:o("重新开始任务"),description:e.jsx("p",{children:o("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:o("确认重试"),variant:"default",isLoading:dt}),e.jsx(On,{isOpen:qe,onClose:()=>G(!1),onConfirm:Nt,taskId:t.id,taskTitle:t.title,workspaces:a,isLoading:C})]}):e.jsx(vr,{})}export{yo as TaskDetail};
|