agent-tower 0.5.3-beta.6 → 0.5.3-beta.8
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/app.d.ts.map +1 -1
- package/dist/app.js +13 -0
- package/dist/app.js.map +1 -1
- package/dist/cli.js +26 -3
- package/dist/cli.js.map +1 -1
- package/dist/core/container.d.ts +2 -0
- package/dist/core/container.d.ts.map +1 -1
- package/dist/core/container.js +8 -0
- package/dist/core/container.js.map +1 -1
- package/dist/executors/__tests__/base.executor.test.js +83 -10
- package/dist/executors/__tests__/base.executor.test.js.map +1 -1
- package/dist/executors/__tests__/claude-code.executor.test.d.ts +2 -0
- package/dist/executors/__tests__/claude-code.executor.test.d.ts.map +1 -0
- package/dist/executors/__tests__/claude-code.executor.test.js +72 -0
- package/dist/executors/__tests__/claude-code.executor.test.js.map +1 -0
- package/dist/executors/__tests__/providers-availability.test.d.ts +2 -0
- package/dist/executors/__tests__/providers-availability.test.d.ts.map +1 -0
- package/dist/executors/__tests__/providers-availability.test.js +92 -0
- package/dist/executors/__tests__/providers-availability.test.js.map +1 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.d.ts +2 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.d.ts.map +1 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.js +177 -0
- package/dist/executors/__tests__/stdin-prompt.executors.test.js.map +1 -0
- package/dist/executors/base.executor.d.ts.map +1 -1
- package/dist/executors/base.executor.js +131 -33
- package/dist/executors/base.executor.js.map +1 -1
- package/dist/executors/claude-code.executor.d.ts.map +1 -1
- package/dist/executors/claude-code.executor.js +22 -52
- package/dist/executors/claude-code.executor.js.map +1 -1
- package/dist/executors/codex.executor.js +4 -4
- package/dist/executors/codex.executor.js.map +1 -1
- package/dist/executors/cursor-agent.executor.d.ts.map +1 -1
- package/dist/executors/cursor-agent.executor.js +4 -6
- package/dist/executors/cursor-agent.executor.js.map +1 -1
- package/dist/executors/gemini-cli.executor.d.ts.map +1 -1
- package/dist/executors/gemini-cli.executor.js +9 -8
- package/dist/executors/gemini-cli.executor.js.map +1 -1
- package/dist/executors/image-utils.d.ts.map +1 -1
- package/dist/executors/image-utils.js +4 -22
- package/dist/executors/image-utils.js.map +1 -1
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/__tests__/agent-cli-local-only.test.d.ts +2 -0
- package/dist/middleware/__tests__/agent-cli-local-only.test.d.ts.map +1 -0
- package/dist/middleware/__tests__/agent-cli-local-only.test.js +119 -0
- package/dist/middleware/__tests__/agent-cli-local-only.test.js.map +1 -0
- package/dist/middleware/agent-cli-local-only.d.ts +5 -0
- package/dist/middleware/agent-cli-local-only.d.ts.map +1 -0
- package/dist/middleware/agent-cli-local-only.js +80 -0
- package/dist/middleware/agent-cli-local-only.js.map +1 -0
- package/dist/pipeline/agent-pipeline.d.ts.map +1 -1
- package/dist/pipeline/agent-pipeline.js +27 -2
- package/dist/pipeline/agent-pipeline.js.map +1 -1
- package/dist/routes/__tests__/agent-cli-environment.test.d.ts +2 -0
- package/dist/routes/__tests__/agent-cli-environment.test.d.ts.map +1 -0
- package/dist/routes/__tests__/agent-cli-environment.test.js +139 -0
- package/dist/routes/__tests__/agent-cli-environment.test.js.map +1 -0
- package/dist/routes/agent-cli-environment.d.ts +3 -0
- package/dist/routes/agent-cli-environment.d.ts.map +1 -0
- package/dist/routes/agent-cli-environment.js +92 -0
- package/dist/routes/agent-cli-environment.js.map +1 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +3 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/services/__tests__/conversation.service.test.js +63 -0
- package/dist/services/__tests__/conversation.service.test.js.map +1 -1
- package/dist/services/__tests__/team-reconciler.service.test.js +2 -2
- package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
- package/dist/services/__tests__/team-run.service.test.js +17 -16
- package/dist/services/__tests__/team-run.service.test.js.map +1 -1
- package/dist/services/agent-cli/__tests__/detection.test.d.ts +2 -0
- package/dist/services/agent-cli/__tests__/detection.test.d.ts.map +1 -0
- package/dist/services/agent-cli/__tests__/detection.test.js +77 -0
- package/dist/services/agent-cli/__tests__/detection.test.js.map +1 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.d.ts +2 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.d.ts.map +1 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.js +228 -0
- package/dist/services/agent-cli/__tests__/environment-task-manager.test.js.map +1 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.d.ts +2 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.d.ts.map +1 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.js +127 -0
- package/dist/services/agent-cli/__tests__/manifest-downloader.test.js.map +1 -0
- package/dist/services/agent-cli/detection.d.ts +27 -0
- package/dist/services/agent-cli/detection.d.ts.map +1 -0
- package/dist/services/agent-cli/detection.js +144 -0
- package/dist/services/agent-cli/detection.js.map +1 -0
- package/dist/services/agent-cli/downloader.d.ts +24 -0
- package/dist/services/agent-cli/downloader.d.ts.map +1 -0
- package/dist/services/agent-cli/downloader.js +152 -0
- package/dist/services/agent-cli/downloader.js.map +1 -0
- package/dist/services/agent-cli/environment.service.d.ts +35 -0
- package/dist/services/agent-cli/environment.service.d.ts.map +1 -0
- package/dist/services/agent-cli/environment.service.js +127 -0
- package/dist/services/agent-cli/environment.service.js.map +1 -0
- package/dist/services/agent-cli/manifest-validator.d.ts +4 -0
- package/dist/services/agent-cli/manifest-validator.d.ts.map +1 -0
- package/dist/services/agent-cli/manifest-validator.js +56 -0
- package/dist/services/agent-cli/manifest-validator.js.map +1 -0
- package/dist/services/agent-cli/manifest.d.ts +6 -0
- package/dist/services/agent-cli/manifest.d.ts.map +1 -0
- package/dist/services/agent-cli/manifest.js +180 -0
- package/dist/services/agent-cli/manifest.js.map +1 -0
- package/dist/services/agent-cli/security.d.ts +28 -0
- package/dist/services/agent-cli/security.d.ts.map +1 -0
- package/dist/services/agent-cli/security.js +148 -0
- package/dist/services/agent-cli/security.js.map +1 -0
- package/dist/services/agent-cli/task-manager.d.ts +39 -0
- package/dist/services/agent-cli/task-manager.d.ts.map +1 -0
- package/dist/services/agent-cli/task-manager.js +228 -0
- package/dist/services/agent-cli/task-manager.js.map +1 -0
- package/dist/services/conversation.service.d.ts.map +1 -1
- package/dist/services/conversation.service.js +17 -1
- package/dist/services/conversation.service.js.map +1 -1
- package/dist/services/mcp-config.service.js +1 -1
- package/dist/services/mcp-config.service.js.map +1 -1
- package/dist/services/mcp-config.service.test.js +19 -3
- package/dist/services/mcp-config.service.test.js.map +1 -1
- package/dist/services/session-manager.d.ts +9 -8
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +129 -16
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/task.service.d.ts +2 -2
- package/dist/services/team-run.service.d.ts.map +1 -1
- package/dist/services/team-run.service.js +4 -7
- package/dist/services/team-run.service.js.map +1 -1
- package/dist/services/terminal-manager.d.ts.map +1 -1
- package/dist/services/terminal-manager.js +39 -7
- package/dist/services/terminal-manager.js.map +1 -1
- package/dist/services/workspace.service.d.ts +7 -7
- package/dist/utils/error-log.d.ts +20 -0
- package/dist/utils/error-log.d.ts.map +1 -0
- package/dist/utils/error-log.js +176 -0
- package/dist/utils/error-log.js.map +1 -0
- package/dist/utils/error-log.test.d.ts +2 -0
- package/dist/utils/error-log.test.d.ts.map +1 -0
- package/dist/utils/error-log.test.js +233 -0
- package/dist/utils/error-log.test.js.map +1 -0
- package/dist/utils/prisma-cli-env.d.ts +3 -0
- package/dist/utils/prisma-cli-env.d.ts.map +1 -0
- package/dist/utils/prisma-cli-env.js +15 -0
- package/dist/utils/prisma-cli-env.js.map +1 -0
- package/dist/utils/prisma-cli-env.test.d.ts +2 -0
- package/dist/utils/prisma-cli-env.test.d.ts.map +1 -0
- package/dist/utils/prisma-cli-env.test.js +34 -0
- package/dist/utils/prisma-cli-env.test.js.map +1 -0
- package/dist/utils/process-launch.d.ts +4 -0
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +106 -16
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +138 -3
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-BqUFGORQ.js → AgentDemoPage-gztcIidI.js} +1 -1
- package/dist/web/assets/AgentEnvironmentSettingsPage-CPNttAOj.js +1 -0
- package/dist/web/assets/AgentLogo-Bqjt1u2k.js +1 -0
- package/dist/web/assets/ConversationPage-DdfPLaBU.js +3 -0
- package/dist/web/assets/CreateTaskInput-DQSvlvL0.js +1 -0
- package/dist/web/assets/{DemoPage-DohwggTK.js → DemoPage-BHRQrxxs.js} +3 -3
- package/dist/web/assets/{GeneralSettingsPage-BqSO35vU.js → GeneralSettingsPage-c6tWGPk7.js} +1 -1
- package/dist/web/assets/{Icons-B5Qr68Dp.js → Icons-hnXjnfjL.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-DBVTXpq2.js → LoadingPreviewPage-D_TI4PEx.js} +1 -1
- package/dist/web/assets/McpSettingsPage-D6b7ZWOS.js +1 -0
- package/dist/web/assets/{MemberAvatar-DmWOKCwf.js → MemberAvatar-DKsedKpu.js} +1 -1
- package/dist/web/assets/NotificationSettingsPage-Cv91U2pg.js +1 -0
- package/dist/web/assets/{ProfileSettingsPage-BcUtq3sY.js → ProfileSettingsPage-K_eadHzF.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-Cw4kAimX.js +89 -0
- package/dist/web/assets/{ProjectKanbanPage-G5OQeJvU.css → ProjectKanbanPage-DcpNTP1B.css} +1 -1
- package/dist/web/assets/ProjectSettingsPage-Vw4sQoAf.js +2 -0
- package/dist/web/assets/{ProviderSettingsPage-CX8WeQ3x.js → ProviderSettingsPage-DeNiqchP.js} +13 -13
- package/dist/web/assets/{SettingsMasterDetail-BtiI8TDc.js → SettingsMasterDetail-BusgjyV7.js} +1 -1
- package/dist/web/assets/TeamSettingsPage-DIQuN3Y5.js +1 -0
- package/dist/web/assets/{arc-BP5t0cJz.js → arc-cT4PVtdQ.js} +1 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-DYwJxluW.js +36 -0
- package/dist/web/assets/{arrow-left-CH7x-bnE.js → arrow-left-DWeEJsaX.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-C0obS1hu.js → blockDiagram-GPEHLZMM-CaXsST1G.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-DLOq2msX.js → c4Diagram-AAUBKEIU-DKqAyb1m.js} +1 -1
- package/dist/web/assets/channel--M3xJN0e.js +1 -0
- package/dist/web/assets/check-CjNklwnC.js +1 -0
- package/dist/web/assets/{chevron-down-CBY3fFTT.js → chevron-down-o4IZE_P6.js} +1 -1
- package/dist/web/assets/chevron-right-DSyyoNau.js +1 -0
- package/dist/web/assets/{chevron-up-721LBv_e.js → chevron-up-BsLA8Xot.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-C07Su0AF.js → chunk-2J33WTMH-DoC7k16y.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-DAdn-ED3.js → chunk-4BX2VUAB-CMKi8GO_.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-BL4-BcAX.js → chunk-55IACEB6-Lyg5IKqI.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-BmmMDMNV.js → chunk-727SXJPM-ColYow00.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-CeLsYTvJ.js → chunk-AQP2D5EJ-CoT-4pKg.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-Bs7S01MB.js → chunk-FMBD7UC4-DVIaL62f.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-uqytV5JO.js → chunk-ND2GUHAM-BNuafnYz.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-DGM3LKCe.js → chunk-QZHKN3VN-mqqlxbRp.js} +1 -1
- package/dist/web/assets/{circle-alert-Dkp6R_Ml.js → circle-alert-FqsC_oWX.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BkKX675E.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BkKX675E.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-C_fs5i5h.js → code-block-OCS4YCEC-BHWPqjt4.js} +1 -1
- package/dist/web/assets/confirm-dialog-BRqwAzwk.js +1 -0
- package/dist/web/assets/copy-r1RvUhIY.js +1 -0
- package/dist/web/assets/cose-bilkent-S5V4N54A-Dx6hZ-zB.js +1 -0
- package/dist/web/assets/{dagre-BM42HDAG-D0-HOAOA.js → dagre-BM42HDAG-jCqcQJ4A.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-Cyt7AAOQ.js → diagram-2AECGRRQ-BFaFAwAW.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-BBv9SoKB.js → diagram-5GNKFQAL-D0VOgGBN.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DV5NTHkX.js → diagram-KO2AKTUF-OkBj16PX.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-eNPojcJF.js → diagram-LMA3HP47-Ca28pfZT.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-DYNkChUG.js → diagram-OG6HWLK6-BdQf7KOI.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-ZXZ2vyVY.js → erDiagram-TEJ5UH35-Bf80VYE6.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-E8oqHUJx.js → flowDiagram-I6XJVG4X-BZWZqm_C.js} +1 -1
- package/dist/web/assets/{folder-BxT7ExMF.js → folder-C-l50KQ-.js} +1 -1
- package/dist/web/assets/folder-picker-ROPpPW7C.js +1 -0
- package/dist/web/assets/ganttDiagram-6RSMTGT7-CWf25QDV.js +292 -0
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-3dNQBESX.js → gitGraphDiagram-PVQCEYII-9cyYoW83.js} +1 -1
- package/dist/web/assets/index-3VWij2vw.js +122 -0
- package/dist/web/assets/index-C4wUDrio.css +1 -0
- package/dist/web/assets/{index-DhYpUXuu.js → index-Cask0_DN.js} +4 -4
- package/dist/web/assets/{infoDiagram-5YYISTIA-DkDDpqvX.js → infoDiagram-5YYISTIA-DWSuhoXN.js} +1 -1
- package/dist/web/assets/{input-CupQF5Np.js → input-Dyl1onpD.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-BSm79ZFA.js → ishikawaDiagram-YF4QCWOH-BfxkZcbP.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-BCP6kLky.js → journeyDiagram-JHISSGLW-keJyzDNt.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-jzLQwKw3.js → kanban-definition-UN3LZRKU-wo8SY3VQ.js} +1 -1
- package/dist/web/assets/{layers-CCP9NEZU.js → layers-CT4P8Wt_.js} +1 -1
- package/dist/web/assets/{linear-DWq5jvYH.js → linear-DXmYF97H.js} +1 -1
- package/dist/web/assets/mermaid-NOHMQCX5-DjJdrIaK.js +123 -0
- package/dist/web/assets/{message-square-tSoG7yGO.js → message-square-B0uoScMB.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-C5FxGBPQ.js → mindmap-definition-RKZ34NQL-BR1VqGMr.js} +1 -1
- package/dist/web/assets/modal-CN741Elc.js +1 -0
- package/dist/web/assets/{pencil-BOmVWDhP.js → pencil-B05Eh9uE.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-CmWVRs82.js → pieDiagram-4H26LBE5-DmIVi6kN.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-B4s3NNDO.js → quadrantDiagram-W4KKPZXB-Bh1fx3P_.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-C2KmzOV2.js → requirementDiagram-4Y6WPE33-BheNLVEb.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CJbPnzq8.js → sankeyDiagram-5OEKKPKP-CWuQByUh.js} +1 -1
- package/dist/web/assets/select-B2NVUyiF.js +1 -0
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BFea2ow4.js → sequenceDiagram-3UESZ5HK-Blll85Hd.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-osdtBRSX.js → stateDiagram-AJRCARHV-C31npQBQ.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BXcVcTJl.js +1 -0
- package/dist/web/assets/switch-BiB7Kgpg.js +1 -0
- package/dist/web/assets/{textarea-Cj61Z7ha.js → textarea-Du_ydNYw.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BlXV0jf2.js → timeline-definition-PNZ67QCA-BXjt2YG8.js} +1 -1
- package/dist/web/assets/{trash-2-D2zJVeEr.js → trash-2-CWVsy23V.js} +1 -1
- package/dist/web/assets/upload-C-wK_vWU.js +1 -0
- package/dist/web/assets/{use-profiles-BSYIQUHp.js → use-profiles-DwPVupVL.js} +1 -1
- package/dist/web/assets/{use-providers-Ct5qGj1d.js → use-providers-C-PIoFvi.js} +1 -1
- package/dist/web/assets/useNormalizedLogs-CGOi3cNq.js +1 -0
- package/dist/web/assets/{vennDiagram-CIIHVFJN-CCuhn7zI.js → vennDiagram-CIIHVFJN-DKpjIApG.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-Xu-SY-Xt.js → wardley-L42UT6IY-DvryVGdS.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-BDVBG-Eu.js → wardleyDiagram-YWT4CUSO-CtUF9zNr.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-DC5IWyMr.js → xychartDiagram-2RQKCTM6-Qx4Q-1Xq.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +123 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +2 -2
- package/node_modules/@prisma/client/.prisma/client/index.js +2 -2
- package/package.json +1 -1
- package/dist/web/assets/AgentLogo-O_lfAIQi.js +0 -1
- package/dist/web/assets/ConversationPage-t8BHC8qL.js +0 -3
- package/dist/web/assets/CreateTaskInput-D5aroK_o.js +0 -2
- package/dist/web/assets/McpSettingsPage-B4hjk8Q6.js +0 -1
- package/dist/web/assets/NotificationSettingsPage-DiUyq7V-.js +0 -1
- package/dist/web/assets/ProjectKanbanPage-klp2fAN1.js +0 -89
- package/dist/web/assets/ProjectSettingsPage-D2gQsbTJ.js +0 -2
- package/dist/web/assets/TeamSettingsPage-CZgtzFUH.js +0 -1
- package/dist/web/assets/architectureDiagram-3BPJPVTR-B4nGdxyB.js +0 -36
- package/dist/web/assets/channel-ByQ8jatA.js +0 -1
- package/dist/web/assets/check-EXzHBr5H.js +0 -1
- package/dist/web/assets/chevron-right-DZo7j27r.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BTR6CDm1.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BTR6CDm1.js +0 -1
- package/dist/web/assets/confirm-dialog-IGqDL03n.js +0 -1
- package/dist/web/assets/cose-bilkent-S5V4N54A-2VABc7UM.js +0 -1
- package/dist/web/assets/folder-picker-57gIIPSi.js +0 -1
- package/dist/web/assets/ganttDiagram-6RSMTGT7-CEAjt7Nr.js +0 -292
- package/dist/web/assets/index-B2TV-FU2.js +0 -120
- package/dist/web/assets/index-D1vY2KQU.css +0 -1
- package/dist/web/assets/loader-circle-RvIxJahM.js +0 -1
- package/dist/web/assets/mermaid-NOHMQCX5-v8DEF9xx.js +0 -122
- package/dist/web/assets/modal-Dc2shjmi.js +0 -1
- package/dist/web/assets/rotate-ccw-BJfFrvl2.js +0 -1
- package/dist/web/assets/select-C_UWYFsQ.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-ChsboHHf.js +0 -1
- package/dist/web/assets/switch-C6O0UllM.js +0 -1
- package/dist/web/assets/terminal-BKrr_mRJ.js +0 -1
- package/dist/web/assets/upload-Q5mYpwnh.js +0 -1
- package/dist/web/assets/useNormalizedLogs-DqPhzW9t.js +0 -1
|
@@ -3,14 +3,28 @@ import path from 'node:path';
|
|
|
3
3
|
export function getNodeRuntimeCommand() {
|
|
4
4
|
return process.env.AGENT_TOWER_NODE_RUNTIME || process.execPath;
|
|
5
5
|
}
|
|
6
|
+
export const PTY_WRAPPER_ENV_KEYS = [
|
|
7
|
+
'AGENT_TOWER_NODE_RUNTIME',
|
|
8
|
+
'ELECTRON_RUN_AS_NODE',
|
|
9
|
+
];
|
|
10
|
+
export function buildPtyWrapperEnv(agentEnv, parentEnv = process.env) {
|
|
11
|
+
const wrapperEnv = { ...agentEnv };
|
|
12
|
+
for (const key of PTY_WRAPPER_ENV_KEYS) {
|
|
13
|
+
const value = parentEnv[key];
|
|
14
|
+
if (value !== undefined) {
|
|
15
|
+
wrapperEnv[key] = value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return wrapperEnv;
|
|
19
|
+
}
|
|
6
20
|
const PTY_WRAPPER_SCRIPT = String.raw `
|
|
7
21
|
const { spawn } = require('node:child_process');
|
|
8
|
-
const { createReadStream,
|
|
22
|
+
const { createReadStream, unlinkSync } = require('node:fs');
|
|
9
23
|
|
|
10
24
|
const [mode, programPath, ...rest] = process.argv.slice(1);
|
|
11
25
|
const isWin = process.platform === 'win32';
|
|
12
26
|
const isCmdBat = isWin && /\.(cmd|bat)$/i.test(programPath);
|
|
13
|
-
const internalEnvKeys =
|
|
27
|
+
const internalEnvKeys = ${JSON.stringify(PTY_WRAPPER_ENV_KEYS)};
|
|
14
28
|
|
|
15
29
|
let child;
|
|
16
30
|
let cleanupTarget = null;
|
|
@@ -29,7 +43,7 @@ function cleanup() {
|
|
|
29
43
|
if (!cleanupTarget) return;
|
|
30
44
|
const target = cleanupTarget;
|
|
31
45
|
cleanupTarget = null;
|
|
32
|
-
|
|
46
|
+
try { unlinkSync(target); } catch {}
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
// 终止 child 及其整个进程组。
|
|
@@ -98,6 +112,7 @@ function spawnCmd(args, stdioOpt) {
|
|
|
98
112
|
stdio: stdioOpt,
|
|
99
113
|
env: getChildEnv(),
|
|
100
114
|
windowsVerbatimArguments: true,
|
|
115
|
+
windowsHide: true,
|
|
101
116
|
});
|
|
102
117
|
}
|
|
103
118
|
|
|
@@ -106,30 +121,96 @@ function spawnCmd(args, stdioOpt) {
|
|
|
106
121
|
// 本 wrapper 经 killTree 显式转发。Windows 下 detached 会脱离 ConPTY,
|
|
107
122
|
// 保持默认行为。
|
|
108
123
|
function spawnChild(args, stdioOpt) {
|
|
109
|
-
return spawn(programPath, args, {
|
|
124
|
+
return spawn(programPath, args, {
|
|
125
|
+
stdio: stdioOpt,
|
|
126
|
+
detached: !isWin,
|
|
127
|
+
env: getChildEnv(),
|
|
128
|
+
windowsHide: true,
|
|
129
|
+
});
|
|
110
130
|
}
|
|
111
131
|
|
|
112
132
|
if (mode === 'pipe-file') {
|
|
113
133
|
const [stdinFile, ...args] = rest;
|
|
114
134
|
cleanupTarget = stdinFile;
|
|
135
|
+
let stdinStream = null;
|
|
136
|
+
let stdinStreamClosed = false;
|
|
137
|
+
let finishingWithChildResult = false;
|
|
138
|
+
|
|
139
|
+
function isBrokenPipeError(error) {
|
|
140
|
+
const code = error && error.code;
|
|
141
|
+
return code === 'EPIPE'
|
|
142
|
+
|| code === 'ECONNRESET'
|
|
143
|
+
|| code === 'ERR_STREAM_DESTROYED'
|
|
144
|
+
|| code === 'ERR_STREAM_WRITE_AFTER_END';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function closeInputPipe() {
|
|
148
|
+
if (stdinStream && !stdinStream.destroyed) {
|
|
149
|
+
stdinStream.destroy();
|
|
150
|
+
}
|
|
151
|
+
if (child && child.stdin && !child.stdin.destroyed) {
|
|
152
|
+
child.stdin.destroy();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function afterInputClosed(callback) {
|
|
157
|
+
if (!stdinStream || stdinStreamClosed) {
|
|
158
|
+
cleanup();
|
|
159
|
+
callback();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
stdinStream.once('close', () => {
|
|
164
|
+
cleanup();
|
|
165
|
+
callback();
|
|
166
|
+
});
|
|
167
|
+
closeInputPipe();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function finishWithChildResult(code, signal) {
|
|
171
|
+
if (finishingWithChildResult) return;
|
|
172
|
+
finishingWithChildResult = true;
|
|
173
|
+
afterInputClosed(() => exitWithChildResult(code, signal));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function exitWithPipeError(error) {
|
|
177
|
+
killTree('SIGTERM');
|
|
178
|
+
afterInputClosed(() => exitWithError(error));
|
|
179
|
+
}
|
|
180
|
+
|
|
115
181
|
child = isCmdBat
|
|
116
182
|
? spawnCmd(args, ['pipe', 'inherit', 'inherit'])
|
|
117
183
|
: spawnChild(args, ['pipe', 'inherit', 'inherit']);
|
|
118
184
|
|
|
119
|
-
child.on('error',
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const stream = createReadStream(stdinFile);
|
|
123
|
-
stream.on('error', (error) => {
|
|
124
|
-
killTree('SIGTERM');
|
|
125
|
-
exitWithError(error);
|
|
185
|
+
child.on('error', (error) => {
|
|
186
|
+
afterInputClosed(() => exitWithError(error));
|
|
126
187
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
188
|
+
child.on('exit', finishWithChildResult);
|
|
189
|
+
|
|
190
|
+
stdinStream = createReadStream(stdinFile);
|
|
191
|
+
stdinStream.on('close', () => {
|
|
192
|
+
stdinStreamClosed = true;
|
|
193
|
+
cleanup();
|
|
132
194
|
});
|
|
195
|
+
stdinStream.on('error', exitWithPipeError);
|
|
196
|
+
|
|
197
|
+
if (child.stdin) {
|
|
198
|
+
child.stdin.on('error', (error) => {
|
|
199
|
+
if (isBrokenPipeError(error)) {
|
|
200
|
+
afterInputClosed(() => {});
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
exitWithPipeError(error);
|
|
204
|
+
});
|
|
205
|
+
child.stdin.on('close', () => {
|
|
206
|
+
if (stdinStream && !stdinStream.readableEnded && !stdinStream.destroyed) {
|
|
207
|
+
stdinStream.destroy();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
stdinStream.pipe(child.stdin);
|
|
211
|
+
} else {
|
|
212
|
+
exitWithPipeError(new Error('Child stdin is not available'));
|
|
213
|
+
}
|
|
133
214
|
} else {
|
|
134
215
|
child = isCmdBat
|
|
135
216
|
? spawnCmd(rest, 'inherit')
|
|
@@ -164,6 +245,15 @@ export function buildPtyCommandWithStdin(programPath, args, stdinFile) {
|
|
|
164
245
|
args: ['-e', PTY_WRAPPER_SCRIPT, 'pipe-file', programPath, stdinFile, ...args],
|
|
165
246
|
};
|
|
166
247
|
}
|
|
248
|
+
export function escapeArgForWindowsCmd(arg) {
|
|
249
|
+
if (/[\s"&|<>^()!]/.test(arg) || arg === '') {
|
|
250
|
+
return '"' + arg.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
251
|
+
}
|
|
252
|
+
return arg;
|
|
253
|
+
}
|
|
254
|
+
export function buildWindowsCmdShimCommandLine(programPath, args) {
|
|
255
|
+
return [programPath, ...args].map(escapeArgForWindowsCmd).join(' ');
|
|
256
|
+
}
|
|
167
257
|
export function getDefaultTerminalShell(platform = process.platform, env = process.env) {
|
|
168
258
|
if (platform === 'win32') {
|
|
169
259
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-launch.js","sourceRoot":"","sources":["../../src/utils/process-launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WA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;IAEpC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,SAAS;YAChD,IAAI,EAAE,EAAE;SACT,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,KAAK,IAAI,UAAU;QAChC,IAAI,EAAE,EAAE;KACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,CAAC,MAAM,EAAE;IAC5D,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,MAAM;SACjB,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpC,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,iFAAiF;IACjF,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,IAAI,SAAS;YAAE,OAAO,SAAS,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { execFileSync, spawn } from 'node:child_process';
|
|
2
|
-
import { existsSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { execFileSync, spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { describe, expect, it } from 'vitest';
|
|
6
|
-
import { buildPtyCommand, buildPtyCommandWithStdin, getDefaultTerminalShell, getNodeRuntimeCommand, normalizeCommandLookupOutput, } from './process-launch.js';
|
|
6
|
+
import { buildWindowsCmdShimCommandLine, buildPtyWrapperEnv, buildPtyCommand, buildPtyCommandWithStdin, getDefaultTerminalShell, getNodeRuntimeCommand, normalizeCommandLookupOutput, } from './process-launch.js';
|
|
7
7
|
function isAlive(pid) {
|
|
8
8
|
try {
|
|
9
9
|
process.kill(pid, 0);
|
|
@@ -41,6 +41,84 @@ function spawnWrapperWithGrandchild(childScript) {
|
|
|
41
41
|
return { wrapper, grandPid };
|
|
42
42
|
}
|
|
43
43
|
describe('process-launch', () => {
|
|
44
|
+
it('should add bundled node runtime env only to the PTY wrapper env', () => {
|
|
45
|
+
const wrapperEnv = buildPtyWrapperEnv({
|
|
46
|
+
PATH: '/usr/bin',
|
|
47
|
+
AGENT_TOWER_URL: 'http://127.0.0.1:42232',
|
|
48
|
+
}, {
|
|
49
|
+
AGENT_TOWER_NODE_RUNTIME: 'C:\\Program Files\\Agent Tower\\resources\\runtime\\node\\node.exe',
|
|
50
|
+
});
|
|
51
|
+
expect(wrapperEnv).toMatchObject({
|
|
52
|
+
PATH: '/usr/bin',
|
|
53
|
+
AGENT_TOWER_URL: 'http://127.0.0.1:42232',
|
|
54
|
+
AGENT_TOWER_NODE_RUNTIME: 'C:\\Program Files\\Agent Tower\\resources\\runtime\\node\\node.exe',
|
|
55
|
+
});
|
|
56
|
+
expect(wrapperEnv).not.toHaveProperty('ELECTRON_RUN_AS_NODE');
|
|
57
|
+
});
|
|
58
|
+
it('should preserve Electron node-mode env only for packaged fallback runtimes', () => {
|
|
59
|
+
const wrapperEnv = buildPtyWrapperEnv({
|
|
60
|
+
PATH: '/usr/bin',
|
|
61
|
+
AGENT_TOWER_URL: 'http://127.0.0.1:42232',
|
|
62
|
+
}, {
|
|
63
|
+
AGENT_TOWER_NODE_RUNTIME: '/Applications/Agent Tower.app/Contents/MacOS/Agent Tower',
|
|
64
|
+
ELECTRON_RUN_AS_NODE: '1',
|
|
65
|
+
});
|
|
66
|
+
expect(wrapperEnv).toMatchObject({
|
|
67
|
+
PATH: '/usr/bin',
|
|
68
|
+
AGENT_TOWER_URL: 'http://127.0.0.1:42232',
|
|
69
|
+
AGENT_TOWER_NODE_RUNTIME: '/Applications/Agent Tower.app/Contents/MacOS/Agent Tower',
|
|
70
|
+
ELECTRON_RUN_AS_NODE: '1',
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
it('should leave npm CLI wrapper env unchanged when packaged env is absent', () => {
|
|
74
|
+
const agentEnv = {
|
|
75
|
+
PATH: '/usr/bin',
|
|
76
|
+
AGENT_TOWER_URL: 'http://127.0.0.1:42232',
|
|
77
|
+
};
|
|
78
|
+
expect(buildPtyWrapperEnv(agentEnv, {})).toEqual(agentEnv);
|
|
79
|
+
});
|
|
80
|
+
it('should strip packaged node-mode env before spawning the wrapped child', () => {
|
|
81
|
+
const originalNodeRuntime = process.env.AGENT_TOWER_NODE_RUNTIME;
|
|
82
|
+
delete process.env.AGENT_TOWER_NODE_RUNTIME;
|
|
83
|
+
try {
|
|
84
|
+
const invocation = buildPtyCommand(process.execPath, [
|
|
85
|
+
'-e',
|
|
86
|
+
[
|
|
87
|
+
'process.stdout.write(JSON.stringify({',
|
|
88
|
+
'nodeRuntime: process.env.AGENT_TOWER_NODE_RUNTIME ?? null,',
|
|
89
|
+
'electronRunAsNode: process.env.ELECTRON_RUN_AS_NODE ?? null,',
|
|
90
|
+
'marker: process.env.AGENT_TOWER_TEST_NORMAL_ENV ?? null',
|
|
91
|
+
'}))',
|
|
92
|
+
].join(''),
|
|
93
|
+
]);
|
|
94
|
+
const agentEnv = {
|
|
95
|
+
...process.env,
|
|
96
|
+
AGENT_TOWER_TEST_NORMAL_ENV: 'keep-me',
|
|
97
|
+
};
|
|
98
|
+
delete agentEnv.AGENT_TOWER_NODE_RUNTIME;
|
|
99
|
+
delete agentEnv.ELECTRON_RUN_AS_NODE;
|
|
100
|
+
const stdout = execFileSync(invocation.command, invocation.args, {
|
|
101
|
+
encoding: 'utf-8',
|
|
102
|
+
env: buildPtyWrapperEnv(agentEnv, {
|
|
103
|
+
AGENT_TOWER_NODE_RUNTIME: 'C:\\Program Files\\Agent Tower\\Agent Tower.exe',
|
|
104
|
+
ELECTRON_RUN_AS_NODE: '1',
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
expect(JSON.parse(stdout)).toEqual({
|
|
108
|
+
nodeRuntime: null,
|
|
109
|
+
electronRunAsNode: null,
|
|
110
|
+
marker: 'keep-me',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
if (originalNodeRuntime === undefined) {
|
|
115
|
+
delete process.env.AGENT_TOWER_NODE_RUNTIME;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
process.env.AGENT_TOWER_NODE_RUNTIME = originalNodeRuntime;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
44
122
|
it('should preserve arguments through the PTY wrapper', () => {
|
|
45
123
|
const invocation = buildPtyCommand(process.execPath, [
|
|
46
124
|
'-e',
|
|
@@ -71,6 +149,63 @@ describe('process-launch', () => {
|
|
|
71
149
|
expect(stdout).toBe('{"message":"hello"}');
|
|
72
150
|
expect(existsSync(tmpFile)).toBe(false);
|
|
73
151
|
});
|
|
152
|
+
it('should delete the stdin temp file when the child exits without reading stdin', () => {
|
|
153
|
+
const tmpFile = path.join(os.tmpdir(), `agent-tower-test-early-exit-${Date.now()}.txt`);
|
|
154
|
+
writeFileSync(tmpFile, 'x'.repeat(1024 * 1024), 'utf-8');
|
|
155
|
+
try {
|
|
156
|
+
const invocation = buildPtyCommandWithStdin(process.execPath, [
|
|
157
|
+
'-e',
|
|
158
|
+
'process.exit(0)',
|
|
159
|
+
], tmpFile);
|
|
160
|
+
execFileSync(invocation.command, invocation.args, {
|
|
161
|
+
encoding: 'utf-8',
|
|
162
|
+
});
|
|
163
|
+
expect(existsSync(tmpFile)).toBe(false);
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
rmSync(tmpFile, { force: true });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
it('should preserve the child exit code when stdin pipe breaks on early exit', () => {
|
|
170
|
+
const tmpFile = path.join(os.tmpdir(), `agent-tower-test-early-exit-code-${Date.now()}.txt`);
|
|
171
|
+
writeFileSync(tmpFile, 'x'.repeat(1024 * 1024), 'utf-8');
|
|
172
|
+
try {
|
|
173
|
+
const invocation = buildPtyCommandWithStdin(process.execPath, [
|
|
174
|
+
'-e',
|
|
175
|
+
'process.exit(42)',
|
|
176
|
+
], tmpFile);
|
|
177
|
+
const result = spawnSync(invocation.command, invocation.args, {
|
|
178
|
+
encoding: 'utf-8',
|
|
179
|
+
});
|
|
180
|
+
expect(result.error).toBeUndefined();
|
|
181
|
+
expect(result.status).toBe(42);
|
|
182
|
+
expect(existsSync(tmpFile)).toBe(false);
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
rmSync(tmpFile, { force: true });
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
it('should keep long stdin data out of Windows .cmd/.bat command lines', () => {
|
|
189
|
+
const marker = 'WINDOWS_LONG_PROMPT_MARKER';
|
|
190
|
+
const longPrompt = `${marker}${'x'.repeat(32_000)}`;
|
|
191
|
+
const stdinFile = path.join(os.tmpdir(), 'agent-tower-long-prompt-test.txt');
|
|
192
|
+
const invocation = buildPtyCommandWithStdin('C:\\Tools\\cursor-agent.cmd', ['--print', '--output-format=stream-json'], stdinFile);
|
|
193
|
+
expect(longPrompt).toContain(marker);
|
|
194
|
+
expect(JSON.stringify(invocation.args)).not.toContain(marker);
|
|
195
|
+
const modeIndex = invocation.args.indexOf('pipe-file');
|
|
196
|
+
expect(modeIndex).toBeGreaterThanOrEqual(0);
|
|
197
|
+
const childProgram = invocation.args[modeIndex + 1];
|
|
198
|
+
const childArgs = invocation.args.slice(modeIndex + 3);
|
|
199
|
+
const cmdLine = buildWindowsCmdShimCommandLine(childProgram, childArgs);
|
|
200
|
+
expect(cmdLine).toContain('cursor-agent.cmd');
|
|
201
|
+
expect(cmdLine).toContain('--print');
|
|
202
|
+
expect(cmdLine).not.toContain(marker);
|
|
203
|
+
expect(cmdLine).not.toContain(stdinFile);
|
|
204
|
+
});
|
|
205
|
+
it('should hide Windows consoles for wrapper-spawned child processes', () => {
|
|
206
|
+
const invocation = buildPtyCommand('C:\\Tools\\cursor-agent.cmd', ['--print']);
|
|
207
|
+
expect(invocation.args[1]).toContain('windowsHide: true');
|
|
208
|
+
});
|
|
74
209
|
it('should allow overriding the node-like runtime command', () => {
|
|
75
210
|
const original = process.env.AGENT_TOWER_NODE_RUNTIME;
|
|
76
211
|
process.env.AGENT_TOWER_NODE_RUNTIME = '/tmp/agent-tower-node-runtime';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-launch.test.js","sourceRoot":"","sources":["../../src/utils/process-launch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"process-launch.test.js","sourceRoot":"","sources":["../../src/utils/process-launch.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAA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AAC,CACF,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as H,u as X,M as Y,r as n,m as b,j as e,B as y,N as Z,O as ee}from"./index-B2TV-FU2.js";import{u as te,a as se,T as ne,P as re,S as ae}from"./useNormalizedLogs-DqPhzW9t.js";import{b as le}from"./mermaid-NOHMQCX5-v8DEF9xx.js";import{I as L,a as ie,b as oe,A as ce,G as de}from"./Icons-B5Qr68Dp.js";import{d as xe}from"./use-profiles-BSYIQUHp.js";import{C as me}from"./chevron-up-721LBv_e.js";import{C as ue}from"./chevron-down-CBY3fFTT.js";import"./check-EXzHBr5H.js";import"./chevron-right-DZo7j27r.js";const pe=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],he=H("hash",pe);const ge=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],fe=H("send",ge),be=!0;function Ee(){const{t:s}=X(),{preserveDesktopSearch:U}=Y(),[w,F]=n.useState([]),[i,S]=n.useState(""),[x,A]=n.useState("DEFAULT"),[o,k]=n.useState(""),[a,D]=n.useState(null),[l,c]=n.useState("idle"),[g,E]=n.useState(!1),[m,j]=n.useState(""),C=n.useRef(null),$=n.useRef(null),u=n.useRef(null),{data:p}=xe(i),M=p?Object.keys(p):["DEFAULT"],V=t=>{S(t),A("DEFAULT")},_=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),B=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:G,agentSessionId:I,attach:z,clearLogs:P}=te({sessionId:a||"",onExit:_,onError:B}),{todos:R}=se(G);n.useEffect(()=>{b.get("/demo/agents").then(t=>{F(t.agents);const r=t.agents.find(N=>N.available);r&&S(r.type)})},[]),n.useEffect(()=>{C.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${h} isAttached=${f}`),a&&h&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,h,f,z]);const O=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const N=Math.min(u.current.scrollHeight,210);u.current.style.height=`${N}px`}},K=async()=>{if(!i||!o.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),c("starting"),P();try{const r=await b.post("/demo/start",{agentType:i,prompt:o.trim(),variant:x});be&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${r.sessionId}`),D(r.sessionId),c("running")}catch(r){console.error("Start failed:",r),c("error")}},T=async()=>{if(!a||!m.trim())return;const t=m.trim();j("");try{await b.post(`/demo/${a}/message`,{message:t})}catch(r){console.error("Send failed:",r)}},q=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},J=()=>{D(null),c("idle"),k(""),j(""),P()},W=l==="running",d=a!==null,Q=w.find(t=>t.type===i);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:d?o.slice(0,50)+(o.length>50?"...":""):s("新会话")})]}),e.jsxs("div",{className:"flex items-center",children:[l==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),l==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Done"})]}),l==="idle"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-neutral-100 text-neutral-600 rounded-full text-xs font-medium border border-neutral-200",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),l==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),l==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),d&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${g?"":"truncate"}`,onClick:()=>E(!g),children:o}),e.jsx("button",{onClick:()=>E(!g),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:g?e.jsx(me,{size:14}):e.jsx(ue,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:Q?.name||i||s("未选择")})]}),x!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:x})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:s("连接")}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${h?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:s(h?f?"已连接":"连接中...":"未连接")})]}),d&&e.jsx(y,{variant:"outline",size:"sm",onClick:J,className:"ml-auto",children:s("新会话")}),e.jsxs(Z,{to:U("/settings/profiles"),className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${d?"":"ml-auto"}`,children:[e.jsx(ee,{size:14}),e.jsx("span",{children:s("Profiles 设置")})]})]})]}),e.jsx("div",{ref:$,className:"flex-1 overflow-y-auto px-8 py-6",children:d?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:s("等待 Agent 响应...")}):e.jsx(le,{ref:C,logs:v,scrollElementRef:$})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("选择 Agent")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:i===t.type?"default":"outline",disabled:!t.available,onClick:()=>V(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:M.map(t=>e.jsx("button",{onClick:()=>A(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${x===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),p&&p[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(p[x]).map(([t,r])=>`${t}: ${JSON.stringify(r)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("输入任务")}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:o,onChange:t=>k(t.target.value),rows:4,placeholder:s("描述你想让 Agent 完成的任务..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:K,disabled:l==="starting"||!i||!o.trim(),children:s(l==="starting"?"启动中...":"开始")})})]})]})]})}),d&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(ne,{todos:R})}),d&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:u,value:m,onChange:O,rows:3,placeholder:s("发送消息给 Agent..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(re,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Mention",children:e.jsx(ce,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(he,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(de,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[W&&e.jsxs("button",{onClick:q,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(ae,{size:12,fill:"currentColor"}),e.jsx("span",{children:s("停止")})]}),e.jsxs("button",{onClick:T,disabled:!m.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${m.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:s("发送")}),e.jsx(fe,{size:14})]})]})]})]})})]})}export{Ee as AgentDemoPage};
|
|
1
|
+
import{g as H,u as X,O as Y,r as n,m as b,j as e,B as y,P as Z,Q as ee,U as te}from"./index-3VWij2vw.js";import{u as se,a as ne,T as re,P as ae}from"./useNormalizedLogs-CGOi3cNq.js";import{b as le}from"./mermaid-NOHMQCX5-DjJdrIaK.js";import{I as L,a as ie,b as oe,A as ce,G as de}from"./Icons-hnXjnfjL.js";import{d as xe}from"./use-profiles-DwPVupVL.js";import{C as me}from"./chevron-up-BsLA8Xot.js";import{C as ue}from"./chevron-down-o4IZE_P6.js";import"./check-CjNklwnC.js";import"./chevron-right-DSyyoNau.js";const pe=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],he=H("hash",pe);const ge=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],fe=H("send",ge),be=!0;function Ee(){const{t:s}=X(),{preserveDesktopSearch:U}=Y(),[w,F]=n.useState([]),[i,S]=n.useState(""),[x,A]=n.useState("DEFAULT"),[o,k]=n.useState(""),[a,D]=n.useState(null),[l,c]=n.useState("idle"),[g,E]=n.useState(!1),[m,j]=n.useState(""),C=n.useRef(null),$=n.useRef(null),u=n.useRef(null),{data:p}=xe(i),V=p?Object.keys(p):["DEFAULT"],_=t=>{S(t),A("DEFAULT")},B=n.useCallback(t=>{c(t===0?"stopped":"error")},[]),G=n.useCallback(t=>{console.error("Agent error:",t),c("error")},[]),{isConnected:h,isAttached:f,logs:v,entries:M,agentSessionId:I,attach:z,clearLogs:P}=se({sessionId:a||"",onExit:B,onError:G}),{todos:R}=ne(M);n.useEffect(()=>{b.get("/demo/agents").then(t=>{F(t.agents);const r=t.agents.find(N=>N.available);r&&S(r.type)})},[]),n.useEffect(()=>{C.current?.scrollToBottom("smooth")},[v]),n.useEffect(()=>{console.log(`[AgentDemoPage:useEffect] t=${Date.now()} sessionId=${a} isConnected=${h} isAttached=${f}`),a&&h&&!f&&(console.log(`[AgentDemoPage:useEffect] t=${Date.now()} calling attach()`),z())},[a,h,f,z]);const O=t=>{if(j(t.target.value),u.current){u.current.style.height="auto";const N=Math.min(u.current.scrollHeight,210);u.current.style.height=`${N}px`}},K=async()=>{if(!i||!o.trim())return;const t=Date.now();console.log(`[AgentDemoPage:handleStart] t=${t} starting...`),c("starting"),P();try{const r=await b.post("/demo/start",{agentType:i,prompt:o.trim(),variant:x});be&&console.log(`[AgentDemoPage:handleStart] t=${Date.now()} apiTime=${Date.now()-t}ms sessionId=${r.sessionId}`),D(r.sessionId),c("running")}catch(r){console.error("Start failed:",r),c("error")}},T=async()=>{if(!a||!m.trim())return;const t=m.trim();j("");try{await b.post(`/demo/${a}/message`,{message:t})}catch(r){console.error("Send failed:",r)}},q=async()=>{if(a)try{await b.post(`/demo/${a}/stop`),c("stopped")}catch(t){console.error("Stop failed:",t)}},J=()=>{D(null),c("idle"),k(""),j(""),P()},Q=l==="running",d=a!==null,W=w.find(t=>t.type===i);return e.jsxs("div",{className:"flex flex-col h-full bg-white",children:[e.jsxs("div",{className:"px-8 py-5 border-b border-neutral-100 bg-white transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-blue-600",children:"Agent Demo"}),e.jsx("span",{className:"text-neutral-300 text-sm",children:"/"}),e.jsx("span",{className:"text-xl font-bold text-neutral-900 tracking-tight",children:d?o.slice(0,50)+(o.length>50?"...":""):s("新会话")})]}),e.jsxs("div",{className:"flex items-center",children:[l==="running"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-blue-50 text-blue-700 rounded-full text-xs font-medium border border-blue-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-pulse"}),e.jsx("span",{children:"Running"})]}),l==="stopped"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-emerald-50 text-emerald-700 rounded-full text-xs font-medium border border-emerald-100",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Done"})]}),l==="idle"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-neutral-100 text-neutral-600 rounded-full text-xs font-medium border border-neutral-200",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Idle"})]}),l==="starting"&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-amber-50 text-amber-700 rounded-full text-xs font-medium border border-amber-100",children:[e.jsx(L,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"Starting..."})]}),l==="error"&&e.jsx("div",{className:"flex items-center gap-1.5 px-2.5 py-0.5 bg-red-50 text-red-700 rounded-full text-xs font-medium border border-red-100",children:e.jsx("span",{children:"Error"})})]})]}),d&&e.jsxs("div",{className:"mt-1.5 flex items-start gap-2 group max-w-4xl",children:[e.jsx("div",{className:`text-sm text-neutral-600 leading-relaxed cursor-pointer transition-all ${g?"":"truncate"}`,onClick:()=>E(!g),children:o}),e.jsx("button",{onClick:()=>E(!g),className:"mt-0.5 text-neutral-400 opacity-0 group-hover:opacity-100 hover:text-neutral-600 transition-opacity",children:g?e.jsx(me,{size:14}):e.jsx(ue,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Agent"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-900 font-medium bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:W?.name||i||s("未选择")})]}),x!=="DEFAULT"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Variant"}),e.jsx("div",{className:"flex items-center gap-1.5 text-neutral-700 font-medium bg-blue-50 px-2 py-1 rounded border border-blue-100",children:x})]}),I&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:"Session"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-700 font-mono bg-neutral-50 px-2 py-1 rounded border border-neutral-100",children:[I.slice(0,8),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-neutral-400 font-medium",children:s("连接")}),e.jsx("div",{className:`flex items-center gap-1.5 font-medium px-2 py-1 rounded border ${h?"text-emerald-700 bg-emerald-50 border-emerald-100":"text-neutral-500 bg-neutral-50 border-neutral-100"}`,children:s(h?f?"已连接":"连接中...":"未连接")})]}),d&&e.jsx(y,{variant:"outline",size:"sm",onClick:J,className:"ml-auto",children:s("新会话")}),e.jsxs(Z,{to:U("/settings/profiles"),className:`flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors ${d?"":"ml-auto"}`,children:[e.jsx(ee,{size:14}),e.jsx("span",{children:s("Profiles 设置")})]})]})]}),e.jsx("div",{ref:$,className:"flex-1 overflow-y-auto px-8 py-6",children:d?e.jsx("div",{className:"min-h-[200px]",children:v.length===0?e.jsx("div",{className:"text-neutral-400 text-center py-8",children:s("等待 Agent 响应...")}):e.jsx(le,{ref:C,logs:v,scrollElementRef:$})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("选择 Agent")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:w.map(t=>e.jsxs(y,{variant:i===t.type?"default":"outline",disabled:!t.available,onClick:()=>_(t.type),children:[t.name,t.available&&t.version&&` (${t.version})`,!t.available&&s(" (不可用)")]},t.type))})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("配置变体 (Profile Variant)")}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:V.map(t=>e.jsx("button",{onClick:()=>A(t),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${x===t?"bg-neutral-900 text-white border-neutral-900":"bg-white text-neutral-600 border-neutral-200 hover:border-neutral-400"}`,children:t},t))}),p&&p[x]&&e.jsx("p",{className:"mt-2 text-xs text-neutral-500 font-mono",children:Object.entries(p[x]).map(([t,r])=>`${t}: ${JSON.stringify(r)}`).join(", ")})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3 text-neutral-900",children:s("输入任务")}),e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{value:o,onChange:t=>k(t.target.value),rows:4,placeholder:s("描述你想让 Agent 完成的任务..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm"}),e.jsx("div",{className:"flex items-center justify-end px-3 pb-3 pt-1",children:e.jsx(y,{onClick:K,disabled:l==="starting"||!i||!o.trim(),children:s(l==="starting"?"启动中...":"开始")})})]})]})]})}),d&&R.length>0&&e.jsx("div",{className:"px-8 py-2 bg-white border-t border-neutral-100",children:e.jsx(re,{todos:R})}),d&&e.jsx("div",{className:"px-8 py-6 border-t border-neutral-100 bg-white",children:e.jsxs("div",{className:"relative border border-neutral-200 rounded-xl shadow-sm bg-white focus-within:ring-1 focus-within:ring-neutral-300 focus-within:border-neutral-300 transition-all duration-200",children:[e.jsx("textarea",{ref:u,value:m,onChange:O,rows:3,placeholder:s("发送消息给 Agent..."),className:"w-full px-4 py-3 bg-transparent border-none focus:outline-none focus:ring-0 resize-none text-neutral-900 placeholder-neutral-400 leading-relaxed text-sm scrollbar-thin scrollbar-thumb-neutral-200 scrollbar-track-transparent",style:{minHeight:"80px",maxHeight:"210px"},onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229&&(t.preventDefault(),T())}}),e.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1 border-t border-transparent",children:[e.jsxs("div",{className:"flex items-center gap-1 text-neutral-400",children:[e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Attach File",children:e.jsx(ae,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Mention",children:e.jsx(ce,{size:18})}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Reference Issue",children:e.jsx(he,{size:18})}),e.jsx("div",{className:"w-px h-4 bg-neutral-200 mx-1"}),e.jsx("button",{className:"p-2 hover:bg-neutral-100 hover:text-neutral-600 rounded-lg transition-colors",title:"Search Web",children:e.jsx(de,{size:18})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Q&&e.jsxs("button",{onClick:q,className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(te,{size:12,fill:"currentColor"}),e.jsx("span",{children:s("停止")})]}),e.jsxs("button",{onClick:T,disabled:!m.trim(),className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold rounded-lg transition-all ${m.trim()?"bg-neutral-900 text-white hover:bg-black shadow-sm":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:[e.jsx("span",{children:s("发送")}),e.jsx(fe,{size:14})]})]})]})]})})]})}export{Ee as AgentDemoPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as e,j as n,S as s,d as i,A as r}from"./index-3VWij2vw.js";function g(){const{t}=e();return n.jsxs(s,{children:[n.jsx(i,{title:t("Agent 环境"),description:t("检测并安装本机 Agent CLI。安装前会展示官方来源、风险和校验摘要。")}),n.jsx(r,{})]})}export{g as AgentEnvironmentSettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,j as s,C as u,h as o}from"./index-3VWij2vw.js";import{g as f}from"./mermaid-NOHMQCX5-DjJdrIaK.js";function d({agentType:n,className:t,fallbackClassName:i}){const e=f(n),[c,r]=a.useState(!1);return a.useEffect(()=>{r(!1)},[e?.logoSrc]),!e||c?s.jsx(u,{"aria-hidden":"true",className:o("shrink-0 text-muted-foreground",t,i)}):s.jsx("img",{src:e.logoSrc,alt:"","aria-hidden":"true",className:o("shrink-0 object-contain",t),draggable:!1,onError:()=>r(!0)})}export{d as A};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{g as Ee,u as ie,r,j as e,U as Ae,h as y,i as je,k as Z,l as le,q as h,m as B,a2 as Te,O as Le,a3 as Pe,K as Me,M as be,Q as Re,a4 as qe,a5 as ae}from"./index-3VWij2vw.js";import{u as Oe,b as ze,A as Fe,S as w}from"./mermaid-NOHMQCX5-DjJdrIaK.js";import{u as Ke,a as Qe,T as Ue,P as Be}from"./useNormalizedLogs-CGOi3cNq.js";import{u as _e,a as $e,A as Ge,P as He,T as Ve,b as We,B as Je,c as Ye,S as Xe,d as we,C as Ze}from"./CreateTaskInput-DQSvlvL0.js";import{u as et}from"./use-providers-C-PIoFvi.js";import{M as pe}from"./message-square-B0uoScMB.js";import{A as tt}from"./arrow-left-DWeEJsaX.js";import{T as st}from"./trash-2-CWVsy23V.js";import"./chevron-right-DSyyoNau.js";import"./chevron-down-o4IZE_P6.js";import"./check-CjNklwnC.js";import"./AgentLogo-Bqjt1u2k.js";import"./MemberAvatar-DKsedKpu.js";import"./folder-C-l50KQ-.js";const nt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],rt=Ee("layout-list",nt);function at(t){return t===w.RUNNING||t===w.PENDING}function ot({sessionId:t,sessionStatus:n,agentType:o,providerId:f,providers:S,initialTokenUsage:j,onProviderChange:m,onSend:p,onStop:x,onExit:C,isSending:N=!1,isStopping:I=!1,canStop:O,className:T}){const{t:a}=ie(),[d,_]=r.useState(""),[z,$]=r.useState(f??""),[G,F]=r.useState(!1),[K,k]=r.useState(null),H=r.useRef(null),ee=r.useRef(null),ce=r.useRef(null),L=r.useRef(!1),{scrollRef:de,contentRef:ue,isAtBottom:V,scrollToBottom:P}=_e({initial:"instant",resize:"smooth"}),{isConnected:W,isLoadingSnapshot:i,logs:D,entries:me,attach:E}=Ke({sessionId:t,sessionStatus:n,onExit:C}),{todos:J}=Qe(me),Q=$e(D,j),{files:fe,addFiles:g,removeFile:te,clear:se,buildMarkdownLinks:Y,getDoneAttachments:ne,hasFiles:A,isUploading:M}=Oe(),R=at(n),X=O??R;r.useEffect(()=>{$(f??"")},[f]),r.useEffect(()=>{t&&W&&E()},[t,W,E]);const xe=r.useCallback(c=>{$(c),m?.(c)},[m]),re=r.useCallback(()=>{H.current&&(H.current.style.height="60px")},[]),he=r.useCallback(c=>{_(c.target.value);const v=c.target;v.style.height="auto",v.style.height=`${Math.max(60,Math.min(v.scrollHeight,300))}px`},[]),s=r.useCallback(async()=>{if(!d.trim()&&!A||L.current||N||M)return;L.current=!0;const c=Y(),v=ne().map(q=>q.id),U=[d.trim(),c].filter(Boolean).join(`
|
|
2
|
+
|
|
3
|
+
`);_(""),se(),re(),k(null);try{await p({message:U,providerId:z||void 0,attachmentIds:v}),await E(),requestAnimationFrame(()=>P("smooth"))}catch(q){k(q instanceof Error?q.message:a("Send failed. Please try again.")),_(U)}finally{L.current=!1}},[d,A,N,M,Y,ne,se,re,p,z,E,P,a]),l=r.useCallback(async()=>{!X||I||await x()},[X,I,x]),u=r.useCallback(c=>{const v=c.target.files;v&&v.length>0&&g(Array.from(v)),c.target.value=""},[g]),b=r.useCallback(c=>{const v=c.clipboardData.items,U=[];for(const q of v)if(q.kind==="file"){const ge=q.getAsFile();ge&&U.push(ge)}U.length>0&&(c.preventDefault(),g(U))},[g]),Se=r.useCallback(c=>{c.preventDefault(),F(!0)},[]),Ie=r.useCallback(c=>{c.preventDefault(),F(!1)},[]),De=r.useCallback(c=>{c.preventDefault(),F(!1);const v=c.dataTransfer.files;v.length>0&&g(Array.from(v))},[g]);return e.jsxs("div",{className:y("relative flex min-h-0 flex-1 flex-col bg-background",T),children:[e.jsxs("div",{className:"relative min-h-0 flex-1",children:[e.jsx("div",{ref:de,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pb-4 pt-6",children:e.jsx("div",{ref:ue,className:"mx-auto w-full min-w-0 max-w-4xl",children:i?e.jsxs("div",{className:"flex items-center justify-center gap-3 py-12 text-muted-foreground/70",children:[e.jsxs("svg",{className:"h-5 w-5 animate-spin",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:a("Loading logs...")})]}):D.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground/70",children:a(R?"Waiting for agent output...":"No logs recorded for this session.")}):e.jsx(ze,{logs:D})})}),!V&&e.jsxs("button",{type:"button",onClick:()=>P(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-background/90 px-3 py-1.5 text-xs text-muted-foreground shadow-md backdrop-blur-sm transition-all hover:bg-background hover:text-foreground","aria-label":a("Scroll to bottom"),children:[e.jsx(Ge,{size:14}),e.jsx("span",{children:a("Back to bottom")})]})]}),J.length>0&&e.jsx("div",{className:"shrink-0 border-t border-border/60 bg-background px-6 pb-1 pt-2",children:e.jsx("div",{className:"mx-auto max-w-4xl",children:e.jsx(Ue,{todos:J})})}),e.jsx("div",{className:"z-10 w-full shrink-0 border-t border-transparent bg-background p-6 pb-6 pt-2",onDragOver:Se,onDragLeave:Ie,onDrop:De,children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[K?e.jsx("div",{className:"mb-2 text-sm text-destructive",children:K}):null,e.jsxs("div",{ref:ce,className:y("relative rounded-xl border bg-background transition-colors duration-200 hover:border-ring/40 focus-within:border-ring/60",G?"border-info bg-info/5":"border-border"),children:[e.jsx(Fe,{files:fe,onRemove:te}),e.jsx("textarea",{ref:H,value:d,onChange:he,onPaste:b,onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!c.repeat&&!c.nativeEvent.isComposing&&c.nativeEvent.keyCode!==229&&(c.preventDefault(),s())},rows:1,placeholder:a(G?"Drop files here...":t&&!R?"Continue conversation...":"Message Agent..."),className:"w-full resize-none border-none bg-transparent px-4 pb-2 pt-4 text-sm leading-relaxed text-foreground placeholder-muted-foreground/70 focus:outline-none",style:{minHeight:"60px",maxHeight:"300px"}}),e.jsx("input",{ref:ee,type:"file",multiple:!0,className:"hidden",onChange:u}),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",{type:"button",onClick:()=>ee.current?.click(),disabled:M,className:"rounded-lg p-2 text-muted-foreground/70 transition-colors hover:bg-muted hover:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",title:a("Upload file"),children:e.jsx(Be,{size:18})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{providers:S,currentProviderId:z,agentType:o,onSelect:xe}),e.jsx(Ve,{usage:Q}),X&&R&&!d.trim()&&!A?e.jsx("button",{type:"button",onClick:l,disabled:I,className:"rounded-lg bg-destructive p-2 text-white transition-all duration-200 hover:bg-destructive/90 disabled:opacity-50",title:a("Stop"),children:e.jsx(Ae,{size:14})}):e.jsx("button",{type:"button",onClick:s,disabled:!d.trim()&&!A||M||N,className:y("rounded-lg p-2 transition-all duration-200",(d.trim()||A)&&!M&&!N?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-transparent text-muted-foreground/50"),title:a("Send"),children:e.jsx(We,{size:18})})]})]})]})]})})]})}function it(t=50){return je({queryKey:h.conversations.list({limit:t}),queryFn:()=>B.get("/conversations",{params:{limit:String(t)}})})}function lt(t){return je({queryKey:h.conversations.detail(t??""),queryFn:()=>B.get(`/conversations/${t}`),enabled:!!t})}function ct(){const t=Z();return le({mutationFn:n=>B.post("/conversations",n),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function dt(){const t=Z();return le({mutationFn:({id:n,...o})=>B.post(`/conversations/${n}/message`,o),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function ut(){const t=Z();return le({mutationFn:n=>B.post(`/conversations/${n}/stop`),onSuccess:n=>{t.setQueryData(h.conversations.detail(n.id),n),t.invalidateQueries({queryKey:h.conversations.all}),t.invalidateQueries({queryKey:h.sessions.detail(n.sessionId)})}})}function mt(){const t=Z();return le({mutationFn:n=>B.delete(`/conversations/${n}`),onSuccess:(n,o)=>{t.removeQueries({queryKey:h.conversations.detail(o)}),t.invalidateQueries({queryKey:h.conversations.all})}})}const ft=3e4,Ce="agent-tower:conversation-read-times";function xt(){try{const t=window.localStorage.getItem(Ce);if(!t)return{};const n=JSON.parse(t);return!n||typeof n!="object"||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).map(([o,f])=>[o,typeof f=="number"?f:Number(f)]).filter(o=>Number.isFinite(o[1])))}catch{return{}}}function ve(t){try{window.localStorage.setItem(Ce,JSON.stringify(t))}catch{}}function ye(t){const n=t.lastActiveAt??t.updatedAt??t.createdAt;if(!n)return 0;const o=new Date(n).getTime();return Number.isFinite(o)?o:0}function ht(t=ft){const[,n]=r.useState(0);r.useEffect(()=>{const o=setInterval(()=>n(f=>f+1),t);return()=>clearInterval(o)},[t])}function oe(t){return t===w.RUNNING||t===w.PENDING}function ke(t){if(!t)return"";const n=new Date(t);if(Number.isNaN(n.getTime()))return"";const o=Math.max(0,Math.floor((Date.now()-n.getTime())/1e3));return o<60?ae("{count}s ago",{count:o}):o<3600?ae("{count}m ago",{count:Math.floor(o/60)}):o<86400?ae("{count}h ago",{count:Math.floor(o/3600)}):ae("{count}d ago",{count:Math.floor(o/86400)})}function pt(t,n){switch(t){case w.RUNNING:return n("Running");case w.PENDING:return n("Starting");case w.COMPLETED:return n("Completed");case w.FAILED:return n("Failed");case w.CANCELLED:return n("Stopped");default:return t}}function Ne({className:t,pulseClassName:n}){return e.jsxs("span",{className:"relative inline-flex h-2 w-2",children:[e.jsx("span",{className:y("absolute inline-flex h-full w-full animate-ping rounded-full",n)}),e.jsx("span",{className:y("relative inline-flex h-2 w-2 rounded-full",t)})]})}function gt({status:t,unread:n}){return oe(t)?e.jsx(Ne,{className:"bg-success",pulseClassName:"bg-success/70"}):n?e.jsx(Ne,{className:"bg-warning",pulseClassName:"bg-warning/70"}):null}function bt({conversation:t,selected:n,onSelect:o,onDelete:f,disabled:S,unread:j}){const{t:m}=ie(),p=ke(t.lastActiveAt??t.createdAt),x=oe(t.status)||j;return e.jsxs("div",{className:y("group ml-4 mr-2 flex items-center rounded-md transition-colors",n?"bg-accent":"hover:bg-accent/50"),children:[e.jsxs("button",{type:"button",onClick:o,title:t.title,className:"flex min-w-0 flex-1 animate-task-enter items-center gap-2.5 rounded-md px-2 py-2 text-left text-sm",children:[e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(pe,{size:14,className:"text-muted-foreground"})}),e.jsx("span",{className:y("min-w-0 flex-1 truncate",n?"font-medium text-foreground":"text-foreground/90"),children:t.title}),x?e.jsx("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:e.jsx(gt,{status:t.status,unread:j})}):e.jsx("span",{className:"flex w-14 shrink-0 items-center justify-end text-[11px] tabular-nums text-muted-foreground/50",children:e.jsx("span",{className:"truncate group-hover:hidden",children:p})})]}),e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),f()},disabled:S,className:"mr-1 hidden shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-background hover:text-destructive disabled:opacity-50 group-hover:flex",title:m("Delete"),children:e.jsx(st,{size:14})})]})}function vt({isOpen:t,conversations:n,onClose:o,onSelectConversation:f}){const{t:S}=ie(),[j,m]=r.useState(""),[p,x]=r.useState(0),C=r.useRef(null);r.useEffect(()=>{t&&(m(""),x(0))},[t]);const N=r.useMemo(()=>{const a=j.trim().toLowerCase();return a?n.filter(d=>d.title.toLowerCase().includes(a)).slice(0,50):n.slice(0,12)},[n,j]);r.useEffect(()=>{x(0)},[j]),r.useEffect(()=>{C.current?.children[p]?.scrollIntoView({block:"nearest"})},[p]);const I=r.useCallback(a=>{f(a),o()},[o,f]),O=r.useCallback(a=>{if(a.key==="Escape"){a.preventDefault(),o();return}if(a.key==="ArrowDown"){a.preventDefault(),x(d=>Math.min(d+1,N.length-1));return}if(a.key==="ArrowUp"){a.preventDefault(),x(d=>Math.max(d-1,0));return}if(a.key==="Enter"&&!a.nativeEvent.isComposing){a.preventDefault();const d=N[p];d&&I(d)}},[p,I,o,N]);if(!t)return null;const T=j.trim().length>0;return e.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:o}),e.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-border bg-popover shadow-lg animate-in fade-in zoom-in-95 duration-100",children:[e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border/60 px-4",children:[e.jsx(we,{size:15,className:"shrink-0 text-muted-foreground/70"}),e.jsx("input",{value:j,onChange:a=>m(a.target.value),onKeyDown:O,placeholder:S("Search conversations..."),"aria-label":S("Search conversations..."),autoFocus:!0,className:"flex-1 border-none bg-transparent py-3 text-sm text-foreground placeholder-muted-foreground/60 focus:outline-none"})]}),N.length>0?e.jsxs(e.Fragment,{children:[T?null:e.jsx("div",{className:"px-4 pb-1 pt-2.5 text-[11px] font-medium text-muted-foreground/70",children:S("Recent conversations")}),e.jsx("div",{ref:C,className:"max-h-[46vh] overflow-y-auto pb-1.5 pt-0.5 scrollbar-app-thin",children:N.map((a,d)=>e.jsxs("button",{type:"button",onClick:()=>I(a),onMouseEnter:()=>x(d),className:y("flex w-full items-center gap-2.5 px-4 py-2 text-left transition-colors",d===p&&"bg-accent"),children:[e.jsx(pe,{size:14,className:"shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground/90",title:a.title,children:a.title}),e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground/60",children:ke(a.lastActiveAt??a.createdAt)})]},a.id))})]}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:S("No matching conversations")})]})]})}function Mt(){const{t}=ie();ht();const n=Te(),{usesIntegratedTitlebar:o,desktopPlatform:f,hasMacTrafficLights:S}=Le(),j=o&&f==="win32",{conversationId:m}=Pe(),p=Z(),[x,C]=r.useState(""),[N,I]=r.useState("idle"),[O,T]=r.useState(null),[a,d]=r.useState(!1),[_,z]=r.useState(!1),[$,G]=r.useState(xt),[F,K]=r.useState(()=>new Set),{data:k=[],isLoading:H}=it(),{data:ee,isLoading:ce}=lt(m),{data:L=[],isLoading:de}=et(),ue=ct(),V=dt(),P=ut(),W=mt(),i=ee??k.find(s=>s.id===m)??null,D=r.useMemo(()=>L.filter(({availability:s})=>s.type!=="NOT_FOUND"),[L]),me=D.map(({provider:s})=>({id:s.id,name:s.name,agentType:s.agentType,available:!0})),E=!!m,J=E||a,Q=r.useCallback(s=>{p.invalidateQueries({queryKey:h.conversations.all}),s&&p.invalidateQueries({queryKey:h.conversations.detail(s)})},[p]),fe=r.useCallback(()=>{Q(m)},[m,Q]),g=r.useCallback(s=>{if(K(u=>{if(!u.has(s.id))return u;const b=new Set(u);return b.delete(s.id),b}),s.status!==w.COMPLETED)return;const l=Math.max(Date.now(),ye(s));G(u=>{if(u[s.id]&&u[s.id]>=l)return u;const b={...u,[s.id]:l};return ve(b),b})},[]),te=r.useCallback(s=>{K(l=>{if(l.has(s))return l;const u=new Set(l);return u.add(s),u})},[]),se=r.useCallback(s=>{K(l=>{if(!l.has(s))return l;const u=new Set(l);return u.delete(s),u}),G(l=>{if(!(s in l))return l;const u={...l};return delete u[s],ve(u),u})},[]),Y=r.useMemo(()=>{const s=new Map;for(const l of k)s.set(l.sessionId,l);return i&&s.set(i.sessionId,i),s},[i,k]),ne=r.useCallback(s=>s.status!==w.COMPLETED?!1:F.has(s.id)?!0:ye(s)>($[s.id]??0),[$,F]);r.useEffect(()=>{!x&&D.length>0&&C(D[0].provider.id)},[D,x]),r.useEffect(()=>{i?.providerId&&C(i.providerId)},[i?.providerId]),r.useEffect(()=>{m&&d(!1)},[m]),r.useEffect(()=>{i&&g(i)},[i,g]),r.useEffect(()=>{const s=Me.connect(),l=u=>{const b=Y.get(u.sessionId);if(b){if(Q(b.id),u.status!==w.COMPLETED){g(b);return}if(b.id===m){g(b);return}te(b.id)}};return s.on(be.SESSION_COMPLETED,l),()=>{s.off(be.SESSION_COMPLETED,l)}},[m,Y,Q,g,te]);const A=()=>{T(null),d(!0),n("/conversations")},M=()=>{d(!1),n("/conversations")},R=r.useCallback(s=>{g(s),d(!1),n(`/conversations/${s.id}`)},[g,n]),X=async s=>{if(!(!s.providerId||!s.title.trim()||N!=="idle")){I("starting-session"),T(null);try{const l=await ue.mutateAsync({prompt:s.title.trim(),providerId:s.providerId,attachmentIds:s.attachmentIds});C(s.providerId),d(!1),n(`/conversations/${l.id}`)}catch(l){T(l instanceof Error?l.message:t("Failed to start. Please try again."))}finally{I("idle")}}},xe=async s=>{!i||!s.message.trim()||V.isPending||await V.mutateAsync({id:i.id,message:s.message,providerId:s.providerId||x||void 0,attachmentIds:s.attachmentIds})},re=async()=>{!i||!oe(i.status)||P.isPending||await P.mutateAsync(i.id)},he=async s=>{window.confirm(t("Delete this conversation?"))&&(await W.mutateAsync(s),se(s),m===s&&(d(!1),n("/conversations")))};return e.jsxs("div",{className:"flex h-dvh flex-col overflow-hidden bg-sidebar text-sm text-foreground",children:[e.jsxs("header",{className:y("flex h-12 shrink-0 items-center justify-between bg-sidebar px-4",o&&"app-region-drag",j&&"pr-[150px]"),children:[e.jsxs("div",{className:y("flex min-w-0 items-center gap-2",S&&"pl-[72px]"),children:[e.jsx(Je,{}),e.jsx(Ye,{}),e.jsx("span",{className:"mx-1.5 select-none text-muted-foreground/40",children:"/"}),e.jsx("span",{className:"truncate text-sm font-medium text-foreground/90",children:t("Conversation")})]}),e.jsx("button",{type:"button",onClick:()=>qe.getState().openSettings(),className:y("rounded-md p-1.5 text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground",o&&"app-region-no-drag"),title:t("Settings"),children:e.jsx(Re,{size:16})})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsxs("aside",{className:y("h-full w-full shrink-0 flex-col bg-sidebar md:flex md:w-[320px]",J?"hidden md:flex":"flex"),children:[e.jsxs("div",{className:"shrink-0 px-2 pb-1 pt-2",children:[e.jsxs("button",{type:"button",onClick:A,className:y("flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm transition-colors",a?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"),title:t("New Conversation"),children:[e.jsx(Xe,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("New Conversation")})]}),e.jsxs("button",{type:"button",onClick:()=>n("/"),className:"flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent/50",title:t("Tasks"),children:[e.jsx(rt,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("Tasks")})]}),e.jsxs("button",{type:"button",onClick:()=>z(!0),className:"flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-sm text-foreground/80 transition-colors hover:bg-accent/50",title:t("Search"),children:[e.jsx(we,{size:16,className:"text-muted-foreground"}),e.jsx("span",{children:t("Search")})]})]}),e.jsx("div",{className:"relative min-h-0 flex-1 overflow-y-auto scrollbar-app-thin pb-4 pt-3",children:H?e.jsx("div",{className:"px-4 py-4 text-sm text-muted-foreground",children:t("Loading...")}):k.length===0?e.jsxs("div",{className:"flex h-full select-none flex-col items-center justify-center px-6 text-center",children:[e.jsx(pe,{size:36,className:"mb-3 text-muted-foreground/40",strokeWidth:1.5}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:t("No conversations")}),e.jsx("button",{type:"button",onClick:A,className:"rounded-md bg-brand px-3.5 py-1.5 text-xs font-medium text-brand-foreground transition-colors hover:bg-brand/90",children:t("New Conversation")})]}):e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex w-full items-center gap-1.5 px-4 py-1.5 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"flex-1 text-left",children:t("History")}),e.jsx("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/50",children:k.length})]}),e.jsx("div",{className:"mt-0.5 flex min-h-[40px] flex-col rounded-md",children:k.map(s=>e.jsx(bt,{conversation:s,selected:s.id===m,disabled:W.isPending,unread:s.id!==m&&ne(s),onSelect:()=>R(s),onDelete:()=>he(s.id)},s.id))})]})}),e.jsx("div",{className:"flex items-center justify-between border-t border-border/60 px-4 py-3 text-xs text-muted-foreground/70",children:e.jsxs("span",{children:[t("Conversations")," · ",k.length]})})]}),e.jsxs("main",{className:y("min-w-0 flex-1 flex-col bg-background md:mb-2 md:mr-2 md:overflow-hidden md:rounded-xl md:border md:border-border/50",J?"flex":"hidden md:flex"),children:[e.jsx("header",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border/60 px-4 md:px-5",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[E||a?e.jsx("button",{type:"button",className:"rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground md:hidden",onClick:M,title:t("Back"),children:e.jsx(tt,{size:17})}):null,e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold",children:i?.title??t("New Conversation")}),i?e.jsxs("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[pt(i.status,t),i.directoryName?` · ${i.directoryName}`:""]}):null]})]})}),!i&&E?e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-4 text-sm text-muted-foreground",children:t(ce?"Loading...":"Conversation not found")}):i?e.jsx(ot,{sessionId:i.sessionId,sessionStatus:i.status,agentType:i.agentType,providerId:x||i.providerId,providers:L,initialTokenUsage:i.tokenUsage,onProviderChange:C,onSend:xe,onStop:re,onExit:fe,isSending:V.isPending,isStopping:P.isPending,canStop:oe(i.status)}):e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 pb-[10vh] md:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[e.jsx("h1",{className:"mb-8 max-w-full break-words text-center text-3xl leading-tight tracking-tight text-foreground",children:t("需要我帮你做点什么?")}),e.jsx(Ze,{variant:"conversation",projects:[],providers:me,isProvidersLoading:de,defaultProviderId:x,createStep:N,placeholder:"Ask a question...",submitLabel:"Start",pendingLabel:"Starting...",submitTitle:"Start",onSubmit:async({title:s,providerId:l,attachmentIds:u})=>{await X({title:s,providerId:l,attachmentIds:u})}}),O?e.jsx("div",{className:"mt-3 rounded-lg border border-destructive/15 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:O}):null]})})]})]}),e.jsx(vt,{isOpen:_,conversations:k,onClose:()=>z(!1),onSelectConversation:R})]})}export{Mt as ConversationPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as q,j as e,u as ce,r as n,aa as Re,O as Ye,x as Ge,y as Ve,$ as le,P as Ae,h as b,X as Xe,ab as Ze,ac as Je,ad as Qe}from"./index-3VWij2vw.js";import{W as L,u as et,A as tt}from"./mermaid-NOHMQCX5-DjJdrIaK.js";import{A as se}from"./AgentLogo-Bqjt1u2k.js";import{C as re}from"./chevron-down-o4IZE_P6.js";import{C as X}from"./check-CjNklwnC.js";import{M as ze}from"./MemberAvatar-DKsedKpu.js";import{u as st}from"./use-providers-C-PIoFvi.js";import{P as rt}from"./trash-2-CWVsy23V.js";import{P as nt}from"./useNormalizedLogs-CGOi3cNq.js";import{F as ot}from"./folder-C-l50KQ-.js";const at=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ot=q("arrow-down",at);const it=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],lt=q("arrow-up",it);const ct=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],dt=q("gauge",ct);const ut=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],mt=q("git-branch",ut);const ft=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pt=q("search",ft);const xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pt=q("shield",xt);const gt=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],Ft=q("square-pen",gt);const ht=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],bt=q("zap",ht);function be({content:a,children:c,className:d="",side:l="top"}){const j=l==="bottom"?"top-full mt-2":"bottom-full mb-2",v=l==="bottom"?"bottom-full border-b-neutral-900":"top-full border-t-neutral-900";return e.jsxs("div",{className:`group/tooltip relative inline-block ${d}`,children:[c,e.jsxs("div",{className:`invisible absolute ${j} left-1/2 -translate-x-1/2 max-w-[260px] px-3 py-2 bg-neutral-900 text-white text-xs leading-relaxed rounded-lg opacity-0 group-hover/tooltip:visible group-hover/tooltip:opacity-100 group-focus-within/tooltip:visible group-focus-within/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-normal z-[100] shadow-lg`,children:[a,e.jsx("div",{className:`absolute ${v} left-1/2 -translate-x-1/2 border-4 border-transparent`})]})]})}function ie(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toString()}function vt(a){return a>=.9?"text-red-500":a>=.7?"text-amber-500":"text-neutral-400"}function Bt({usage:a,tooltipSide:c="top"}){const{t:d}=ce();if(!a)return null;const l=a.modelContextWindow,j=l?a.totalTokens/l:0,v=l?Math.min(Math.round(j*100),100):null,u=l?vt(j):"text-neutral-400",y=l?e.jsx("span",{children:d("上下文: {used} / {max} tokens",{used:ie(a.totalTokens),max:ie(l)})}):e.jsx("span",{children:d("已使用: {used} tokens",{used:ie(a.totalTokens)})});return e.jsx(be,{content:y,side:c,children:e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[e.jsx(dt,{size:14,className:u}),e.jsxs("span",{className:`tabular-nums ${u}`,children:[ie(a.totalTokens),v!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",v,"%"]})]})]})})}const Nt={damping:.7,stiffness:.05,mass:1.25},jt=70,yt=1e3/60,kt=350;let de=!1;globalThis.document?.addEventListener("mousedown",()=>{de=!0});globalThis.document?.addEventListener("mouseup",()=>{de=!1});globalThis.document?.addEventListener("click",()=>{de=!1});const $t=(a={})=>{const[c,d]=n.useState(!1),[l,j]=n.useState(a.initial!==!1),[v,u]=n.useState(!1),y=n.useRef(null);y.current=a;const f=n.useCallback(()=>{if(!de)return!1;const o=window.getSelection();if(!o||!o.rangeCount)return!1;const m=o.getRangeAt(0);return m.commonAncestorContainer.contains(g.current)||g.current?.contains(m.commonAncestorContainer)},[]),N=n.useCallback(o=>{t.isAtBottom=o,j(o)},[]),x=n.useCallback(o=>{t.escapedFromLock=o,d(o)},[]),t=n.useMemo(()=>{let o;return{escapedFromLock:c,isAtBottom:l,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(m){g.current&&(g.current.scrollTop=m,t.ignoreScrollToTop=g.current.scrollTop)},get targetScrollTop(){return!g.current||!F.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!F.current)return 0;const{targetScrollTop:m}=this;if(!a.targetScrollTop)return m;if(o?.targetScrollTop===m)return o.calculatedScrollTop;const p=Math.max(Math.min(a.targetScrollTop(m,{scrollElement:g.current,contentElement:F.current}),m),0);return o={targetScrollTop:m,calculatedScrollTop:p},requestAnimationFrame(()=>{o=void 0}),p},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=jt}}},[]),P=n.useCallback((o={})=>{typeof o=="string"&&(o={animation:o}),o.preserveScrollPosition||N(!0);const m=Date.now()+(Number(o.wait)||0),p=he(y.current,o.animation),{ignoreEscapes:w=!1}=o;let R,A=t.calculatedTargetScrollTop;o.duration instanceof Promise?o.duration.finally(()=>{R=Date.now()}):R=m+(o.duration??0);const M=async()=>{const H=new Promise(requestAnimationFrame).then(()=>{if(!t.isAtBottom)return t.animation=void 0,!1;const{scrollTop:z}=t,Y=performance.now(),U=(Y-(t.lastTick??Y))/yt;if(t.animation||(t.animation={behavior:p,promise:H,ignoreEscapes:w}),t.animation.behavior===p&&(t.lastTick=Y),f()||m>Date.now())return M();if(z<Math.min(A,t.calculatedTargetScrollTop)){if(t.animation?.behavior===p){if(p==="instant")return t.scrollTop=t.calculatedTargetScrollTop,M();t.velocity=(p.damping*t.velocity+p.stiffness*t.scrollDifference)/p.mass,t.accumulated+=t.velocity*U,t.scrollTop+=t.accumulated,t.scrollTop!==z&&(t.accumulated=0)}return M()}return R>Date.now()?(A=t.calculatedTargetScrollTop,M()):(t.animation=void 0,t.scrollTop<t.calculatedTargetScrollTop?P({animation:he(y.current,y.current.resize),ignoreEscapes:w,duration:Math.max(0,R-Date.now())||void 0}):t.isAtBottom)});return H.then(z=>(requestAnimationFrame(()=>{t.animation||(t.lastTick=void 0,t.velocity=0)}),z))};return o.wait!==!0&&(t.animation=void 0),t.animation?.behavior===p?t.animation.promise:M()},[N,f,t]),i=n.useCallback(()=>{x(!0),N(!1)},[x,N]),O=n.useCallback(({target:o})=>{if(o!==g.current)return;const{scrollTop:m,ignoreScrollToTop:p}=t;let{lastScrollTop:w=m}=t;t.lastScrollTop=m,t.ignoreScrollToTop=void 0,p&&p>m&&(w=p),u(t.isNearBottom),setTimeout(()=>{if(t.resizeDifference||m===p)return;if(f()){x(!0),N(!1);return}const R=m>w,A=m<w;if(t.animation?.ignoreEscapes){t.scrollTop=w;return}A&&(x(!0),N(!1)),R&&x(!1),!t.escapedFromLock&&t.isNearBottom&&N(!0)},1)},[x,N,f,t]),K=n.useCallback(({target:o,deltaY:m})=>{let p=o;for(;!["scroll","auto"].includes(getComputedStyle(p).overflow);){if(!p.parentElement)return;p=p.parentElement}p===g.current&&m<0&&g.current.scrollHeight>g.current.clientHeight&&!t.animation?.ignoreEscapes&&(x(!0),N(!1))},[x,N,t]),g=Ie(o=>{g.current?.removeEventListener("scroll",O),g.current?.removeEventListener("wheel",K),o?.addEventListener("scroll",O,{passive:!0}),o?.addEventListener("wheel",K,{passive:!0})},[]),F=Ie(o=>{if(t.resizeObserver?.disconnect(),!o)return;let m;t.resizeObserver=new ResizeObserver(([p])=>{const{height:w}=p.contentRect,R=w-(m??w);if(t.resizeDifference=R,t.scrollTop>t.targetScrollTop&&(t.scrollTop=t.targetScrollTop),u(t.isNearBottom),R>=0){const A=he(y.current,m?y.current.resize:y.current.initial);P({animation:A,wait:!0,preserveScrollPosition:!0,duration:A==="instant"?void 0:kt})}else t.isNearBottom&&(x(!1),N(!0));m=w,requestAnimationFrame(()=>{setTimeout(()=>{t.resizeDifference===R&&(t.resizeDifference=0)},1)})}),t.resizeObserver?.observe(o)},[]);return{contentRef:F,scrollRef:g,scrollToBottom:P,stopScroll:i,isAtBottom:l||v,isNearBottom:v,escapedFromLock:c,state:t}};function Ie(a,c){const d=n.useCallback(l=>(d.current=l,a(l)),c);return d}const ge=new Map;function he(...a){const c={...Nt};let d=!1;for(const j of a){if(j==="instant"){d=!0;continue}typeof j=="object"&&(d=!1,c.damping=j.damping??c.damping,c.stiffness=j.stiffness??c.stiffness,c.mass=j.mass??c.mass)}const l=JSON.stringify(c);return ge.has(l)||ge.set(l,Object.freeze(c)),d?"instant":ge.get(l)}function Ut({providers:a,currentProviderId:c,agentType:d,onSelect:l}){const{t:j}=ce(),[v,u]=n.useState(!1),y=n.useRef(null),f=a.filter(x=>String(x.provider.agentType)===d),N=a.find(x=>x.provider.id===c);return n.useEffect(()=>{function x(t){y.current&&!y.current.contains(t.target)&&u(!1)}if(v)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[v]),f.length<=1?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[e.jsx(se,{agentType:N?.provider.agentType??d,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:N?.provider.name?Re(N.provider.name,12):d})]}):e.jsxs("div",{className:"relative",ref:y,children:[e.jsxs("button",{onClick:()=>u(!v),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${N?.provider.name??d} (click to change)`,children:[e.jsx(se,{agentType:N?.provider.agentType??d,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:N?.provider.name?Re(N.provider.name,12):d}),e.jsx(re,{size:12,className:`shrink-0 transition-transform ${v?"rotate-180":""}`})]}),v&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[e.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:j("切换渠道")}),f.map(x=>e.jsxs("button",{onClick:()=>{l(x.provider.id),u(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${x.provider.id===c?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(se,{agentType:x.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:x.provider.name}),x.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:j("(默认)")})]}),x.provider.id===c&&e.jsx(X,{size:14,className:"shrink-0"})]},x.provider.id))]})]})}function Wt(a,c){return n.useMemo(()=>{for(let d=a.length-1;d>=0;d--){const l=a[d];if(l.tokenUsage&&typeof l.tokenUsage.totalTokens=="number"&&l.tokenUsage.totalTokens>0)return{totalTokens:l.tokenUsage.totalTokens,modelContextWindow:l.tokenUsage.modelContextWindow}}return c??null},[a,c])}function Le(a,c,d,l){if(d.filter(u=>u===l).length<=1)return a;const v=d.slice(0,c+1).filter(u=>u===l).length;return`${a} #${v}`}function wt(a){return Object.values(a).filter(Boolean).length}function Tt({mode:a,setMode:c,selectedTemplateId:d,setSelectedTemplateId:l,selectedMemberPresetIds:j,setSelectedMemberPresetIds:v,disabled:u=!1,compact:y=!1}){const{t:f}=ce(),{preserveDesktopSearch:N}=Ye(),[x,t]=n.useState(!1),{data:P}=st(),{data:i,isError:O,isFetching:K,isLoading:g,refetch:F}=Ge(),{data:o,isError:m,isFetching:p,isLoading:w,refetch:R}=Ve(),A=n.useMemo(()=>new Map((P??[]).map(({provider:r,availability:h})=>[r.id,r.name+(h.type==="NOT_FOUND"?f(" (不可用)"):"")])),[P,f]),M=n.useMemo(()=>new Map((i??[]).map(r=>[r.id,r])),[i]),H=n.useMemo(()=>new Map((o??[]).map(r=>[r.id,r])),[o]),z=n.useMemo(()=>j.map(r=>M.get(r)).filter(r=>!!r),[M,j]);n.useEffect(()=>{i!==void 0&&v(r=>{const h=r.filter(T=>M.has(T));return h.length===r.length&&h.every((T,_)=>T===r[_])?r:h})},[i,M,v]),n.useEffect(()=>{o!==void 0&&l(r=>!r||H.has(r)?r:null)},[l,H,o]);const Y=r=>{u||l(h=>h===r?null:r)},U=r=>{u||v(h=>[...h,r])},ue=r=>{u||v(h=>h.filter((T,_)=>_!==r))},ne=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:f("团队模板")}),m?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:f("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{R()},disabled:u||p,className:"ml-2 underline hover:no-underline",children:f("重试")})]}):w?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(le,{size:12,className:"animate-spin"}),f("加载中...")]}):(o??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[f("当前没有团队模板"),e.jsx(Ae,{to:N("/settings/team"),className:"ml-1.5 text-info hover:underline",children:f("去创建")})]}):e.jsx("div",{className:b("space-y-1.5",y&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(o??[]).map(r=>{const h=r.id===d,T=r.members?.length??0,_=r.members?.map(B=>B.memberPresetId)??[],W=r.members?.slice(0,3).map((B,me)=>Le(B.memberPreset?.name??B.memberPresetId,me,_,B.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>Y(r.id),disabled:u,className:b("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",h?"bg-background border-foreground/20 shadow-sm":"bg-background border-border/60 hover:border-border hover:bg-accent"),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:b("text-xs truncate",h?"font-medium text-foreground":"text-foreground"),children:r.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[T,f("人")]})]}),W&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:W})]}),h&&e.jsx(X,{size:13,className:"shrink-0 text-foreground"})]})},r.id)})})]}),Z=z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:z.map((r,h)=>{const T=Le(r.name,h,j,r.id);return e.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded-md border border-border/60 bg-background text-[10px] text-foreground",children:[e.jsx(ze,{name:r.name,avatar:r.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:T}),e.jsx("button",{type:"button",onClick:()=>ue(h),disabled:u,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Xe,{size:9})})]},`${r.id}-${h}`)})}),G=O?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:f("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{F()},disabled:u||K,className:"ml-2 underline hover:no-underline",children:f("重试")})]}):g?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(le,{size:12,className:"animate-spin"}),f("加载中...")]}):(i??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[f("当前没有成员预设"),e.jsx(Ae,{to:N("/settings/team"),className:"ml-1.5 text-info hover:underline",children:f("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(i??[]).map(r=>{const h=j.filter(W=>W===r.id).length,T=A.get(r.providerId)??r.providerId,_=wt(r.capabilities);return e.jsxs("button",{type:"button",onClick:()=>U(r.id),disabled:u,className:b("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left border border-transparent transition-all",u&&"cursor-not-allowed opacity-60","bg-background hover:bg-accent hover:border-border/60"),children:[e.jsx(ze,{name:r.name,avatar:r.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:r.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[T," · ",_,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",h]}),e.jsx(rt,{size:12,className:"text-muted-foreground"})]})]},r.id)})}),J=z.length>0&&e.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-primary text-[10px] font-semibold text-primary-foreground px-1.5",children:z.length}),V=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:f("执行模式")}),e.jsxs("div",{className:"inline-flex items-center h-7 rounded-md border border-border/70 bg-background p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>!u&&c("AUTO"),disabled:u,className:b("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",a==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(bt,{size:11}),f("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!u&&c("CONFIRM"),disabled:u,className:b("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",a==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(pt,{size:11}),f("确认模式")]})]})]});return y?e.jsxs("div",{className:"space-y-3",children:[V,ne,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!u&&t(r=>!r),disabled:u,"aria-expanded":x,className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(re,{size:12,className:b("transition-transform",x?"":"-rotate-90")}),f("追加独立成员"),J]}),x&&e.jsxs("div",{className:"mt-2",children:[Z,G]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[V,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[ne,e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:f("追加成员")}),J]}),Z,G]})]})]})}function qt({className:a="h-7 w-7"}){return e.jsx("img",{src:Ze,alt:"Agent Tower",className:`block shrink-0 object-contain ${a}`})}function Kt({className:a=""}){return e.jsx("span",{className:`font-semibold text-foreground tracking-tight text-base ${a}`,children:"Agent Tower"})}const Ct={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Ht({variant:a="task",projects:c,providers:d,isProvidersLoading:l,onSubmit:j,defaultProjectId:v="",defaultProviderId:u="",onProjectChange:y,createStep:f,placeholder:N,submitLabel:x,pendingLabel:t,submitTitle:P}){const{t:i}=ce(),[O,K]=n.useState(""),[g,F]=n.useState(v),[o,m]=n.useState(u),[p,w]=n.useState("SOLO"),[R,A]=n.useState(L.WORKTREE),[M,H]=n.useState("AUTO"),[z,Y]=n.useState(null),[U,ue]=n.useState([]),[ne,Z]=n.useState(!1),[G,J]=n.useState(!1),[V,r]=n.useState(!1),[h,T]=n.useState(!1),_=n.useRef(null),W=n.useRef(null),B=n.useRef(null),me=n.useRef(null),ve=n.useRef(null),{files:Ne,addFiles:Q,removeFile:De,clear:je,buildMarkdownLinks:ye,getDoneAttachments:ke,isUploading:oe}=et(),C=a==="conversation",k=a==="task"||a==="conversation",_e=x??i(C?"开始":"创建");n.useEffect(()=>{F(v),y?.(v)},[v,y]),n.useEffect(()=>{m(u)},[u]),n.useEffect(()=>{if(!G)return;const s=S=>{_.current&&!_.current.contains(S.target)&&J(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[G]),n.useEffect(()=>{if(!V)return;const s=S=>{W.current&&!W.current.contains(S.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[V]),n.useEffect(()=>{if(!h)return;const s=S=>{B.current&&!B.current.contains(S.target)&&T(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[h]);const ae=n.useMemo(()=>c.find(s=>s.id===g),[c,g]),fe=n.useMemo(()=>d.find(s=>s.id===o),[d,o]),Oe=ae?.isGitRepo!==!1,D=!C&&!Oe,I=D?"SOLO":p,$=D?L.MAIN_DIRECTORY:R,Pe=$===L.MAIN_DIRECTORY?i("本地模式"):i("工作树模式"),we=i("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),Fe=i("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),Te=i("初始化 Git 后可使用工作树模式。"),E=f!=="idle",Ce=!!z||U.length>0,ee=!E&&!oe&&O.trim().length>0&&(C?!!o:!!g&&(I==="SOLO"?!!o:Ce));n.useEffect(()=>{D&&(w("SOLO"),A(L.MAIN_DIRECTORY),Z(!1),T(!1))},[D]);const xe=n.useCallback(async()=>{if(!ee)return;const s=k?ye():"",S=k?ke().map(te=>te.id):[];try{await j({title:O.trim(),description:"",projectId:C?"":g,providerId:o,mode:C?"SOLO":I,workspaceMode:!C&&I==="SOLO"?$:L.WORKTREE,teamRunMode:C?"AUTO":M,teamTemplateId:C||D?null:z,memberPresetIds:C||D?[]:U,attachmentLinks:s,attachmentIds:S}),K(""),k&&je()}catch{}},[ee,k,ye,ke,j,O,C,g,o,I,$,M,D,z,U,je]),Be=n.useCallback(s=>{s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229&&(s.preventDefault(),xe())},[xe]),$e=n.useCallback(s=>{const S=s.target.files;S&&S.length>0&&Q(Array.from(S)),s.target.value=""},[Q]),Ue=n.useCallback(s=>{F(s),y?.(s),J(!1)},[y]),We=n.useCallback(s=>{if(!k)return;const S=s.clipboardData.items,te=[];for(const Me of S)if(Me.kind==="file"){const Ee=Me.getAsFile();Ee&&te.push(Ee)}te.length>0&&(s.preventDefault(),Q(te))},[Q,k]),[Se,pe]=n.useState(!1),qe=n.useCallback(s=>{k&&(s.preventDefault(),pe(!0))},[k]),Ke=n.useCallback(s=>{k&&(s.preventDefault(),pe(!1))},[k]),He=n.useCallback(s=>{if(!k)return;s.preventDefault(),pe(!1);const S=s.dataTransfer.files;S.length>0&&Q(Array.from(S))},[Q,k]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:b("relative bg-background rounded-xl border transition-colors duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.05)]","hover:border-ring/40 focus-within:border-ring/60",Se?"border-info bg-info/5":"border-border",E&&"opacity-80"),onDragOver:k?qe:void 0,onDragLeave:k?Ke:void 0,onDrop:k?He:void 0,children:[k&&Ne.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(tt,{files:Ne,onRemove:De})}),e.jsx("textarea",{ref:me,value:O,onChange:s=>K(s.target.value),onKeyDown:Be,onPaste:k?We:void 0,placeholder:i(N||"Describe your task..."),disabled:E,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-[15px] text-foreground placeholder:text-muted-foreground/80 leading-relaxed",style:{minHeight:"76px",maxHeight:"220px",fieldSizing:"content"}}),k&&Se&&e.jsx("div",{className:"px-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-center py-3 border border-dashed border-info/40 rounded-lg text-xs font-medium text-info",children:i("Drop files here")})}),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:k?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>ve.current?.click(),disabled:E||oe,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("Attach files"),children:e.jsx(nt,{size:18})}),e.jsx("input",{ref:ve,type:"file",multiple:!0,onChange:$e,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[k&&oe&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{size:14,className:"animate-spin"}),i("Uploading...")]}),E&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(le,{size:14,className:"animate-spin"}),i(t??Ct[f])]}),!C&&!E&&!oe&&I==="TEAM"&&!Ce&&O.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:i("请选择团队模板或追加成员")}),ee&&e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[11px] text-muted-foreground/80 select-none",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-border bg-muted/60 text-[10px] font-medium text-muted-foreground leading-none",children:"⏎"}),_e]}),e.jsx("button",{type:"button",onClick:xe,disabled:!ee,className:b("flex items-center justify-center size-8 rounded-lg transition-all duration-200",ee?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:i(P||"Create & Start"),children:e.jsx(lt,{size:16,strokeWidth:2.5})})]})]})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!C&&e.jsxs("div",{className:"relative",ref:_,children:[e.jsxs("button",{type:"button",onClick:()=>{E||J(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",ae?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(ot,{size:14,className:"shrink-0",style:{color:ae?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:ae?.name??i("Project")}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",G&&"rotate-180")})]}),G&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:c.map(s=>e.jsxs("button",{type:"button",onClick:()=>Ue(s.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:s.color??"var(--muted-foreground)"}}),e.jsx("span",{className:b("truncate flex-1",s.id===g?"text-foreground font-medium":"text-muted-foreground"),children:s.name}),e.jsx(X,{size:14,className:b("ml-2 shrink-0 text-foreground",s.id===g?"opacity-100":"opacity-0")})]},s.id))})]}),(C||I==="SOLO")&&e.jsxs("div",{className:"relative",ref:W,children:[e.jsxs("button",{type:"button",onClick:()=>{E||r(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",fe?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(se,{agentType:fe?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:fe?.name??i(l?"Loading...":"Agent")}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",V&&"rotate-180")})]}),V&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:d.map(s=>e.jsxs("button",{type:"button",disabled:!s.available,onClick:()=>{m(s.id),r(!1)},className:b("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",!s.available&&"opacity-40 cursor-not-allowed"),children:[e.jsx(X,{size:14,className:b("mr-2 shrink-0 text-foreground",s.id===o?"opacity-100":"opacity-0")}),e.jsx(se,{agentType:s.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:b("min-w-0 truncate",s.id===o?"text-foreground font-medium":"text-muted-foreground"),children:[s.name,s.available?"":i(" (unavailable)")]})]},s.id))})]}),!C&&I==="SOLO"&&e.jsxs("div",{className:"relative",ref:B,children:[e.jsxs("button",{type:"button",onClick:()=>{E||T(s=>!s)},disabled:E,className:b("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed text-foreground/80"),children:[e.jsx(mt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:Pe}),e.jsx(re,{size:12,className:b("text-muted-foreground transition-transform",h&&"rotate-180")})]}),h&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-w-[calc(100vw-2rem)] bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[D?e.jsx(be,{side:"bottom",className:"block w-full",content:Te,children:e.jsx("div",{tabIndex:0,"aria-label":Te,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsxs("button",{type:"button",disabled:!0,className:"flex w-full cursor-not-allowed items-center px-3 py-2 text-left text-xs opacity-40 transition-colors",children:[e.jsx(X,{size:14,className:"mr-2 mt-0.5 shrink-0 text-foreground opacity-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-muted-foreground",children:i("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:we})]})]})})}):e.jsxs("button",{type:"button",onClick:()=>{A(L.WORKTREE),T(!1)},className:"flex w-full items-center px-3 py-2 text-left text-xs transition-colors hover:bg-accent",children:[e.jsx(X,{size:14,className:b("mr-2 mt-0.5 shrink-0 text-foreground",$===L.WORKTREE?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:b("block truncate",$===L.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:i("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:we})]})]}),e.jsxs("button",{type:"button",onClick:()=>{A(L.MAIN_DIRECTORY),T(!1)},className:"flex items-start w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(X,{size:14,className:b("mr-2 mt-0.5 shrink-0 text-foreground",$===L.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:b("block truncate",$===L.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:i("本地模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]})]})]}),!C&&e.jsx(be,{side:"bottom",className:"ml-auto",content:D?i("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun."):$===L.MAIN_DIRECTORY?i("TeamRun 需要工作树模式。开启团队模式时会自动切换为工作树模式。"):i("启用 TeamRun 后可选择团队模板或成员。"),children:e.jsxs("button",{type:"button",role:"switch","aria-checked":I==="TEAM",onClick:()=>{E||D||(p==="TEAM"?(w("SOLO"),Z(!1)):(w("TEAM"),T(!1),A(L.WORKTREE),Z(!0)))},disabled:E||D,className:b("flex items-center gap-2 h-7 pl-2 pr-2 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",I==="TEAM"?"text-foreground/80":"text-muted-foreground"),"aria-label":i("启用团队模式"),children:[e.jsx(Je,{size:14,className:I==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:i("团队模式")}),(D||$===L.MAIN_DIRECTORY)&&I!=="TEAM"?e.jsx(Qe,{size:12,className:"text-muted-foreground/70","aria-hidden":"true"}):null,e.jsx("span",{className:b("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",I==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:b("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",I==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})})]}),!C&&I==="TEAM"&&ne&&e.jsx("div",{className:"mt-2.5 rounded-xl border border-border/60 bg-muted/40 p-3 animate-[fadeInUp_0.25s_cubic-bezier(0.16,1,0.3,1)]",children:e.jsx(Tt,{mode:M,setMode:H,selectedTemplateId:z,setSelectedTemplateId:Y,selectedMemberPresetIds:U,setSelectedMemberPresetIds:ue,disabled:E,compact:!0})})]})}export{Ot as A,qt as B,Ht as C,mt as G,Ut as P,Ft as S,Bt as T,bt as Z,Wt as a,lt as b,Kt as c,Pt as d,be as e,Tt as f,pt as g,$t as u};
|