dorkos 0.127.0 → 0.128.0
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/THIRD-PARTY-NOTICES.md +61 -0
- package/dist/bin/cli.js +1890 -1099
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-BnnwvwU1.js → AboutPage-CmQERFxo.js} +1 -1
- package/dist/client/assets/{ActivityErrorState-DW-plne9.js → ActivityErrorState-Dw231W2w.js} +1 -1
- package/dist/client/assets/{ActivityPage-BMrtNC9t.js → ActivityPage-DVfeyA9u.js} +1 -1
- package/dist/client/assets/{ActivityRow-BnBDxJqK.js → ActivityRow-DIBH4v9c.js} +1 -1
- package/dist/client/assets/{AdapterIcon-J2UUIfEX.js → AdapterIcon-NqCDzgCI.js} +1 -1
- package/dist/client/assets/{AdapterSetupWizard-MDV6zwYC.js → AdapterSetupWizard-Dle_b9qc.js} +1 -1
- package/dist/client/assets/{AgentOptionRow-Dj2MlE6E.js → AgentOptionRow-BRJfZo2y.js} +1 -1
- package/dist/client/assets/{AgentPicker-D6MsFN_H.js → AgentPicker-B7upjYRk.js} +1 -1
- package/dist/client/assets/{AgentRequestCard-BTyuNOhU.js → AgentRequestCard-DXJnLk6q.js} +1 -1
- package/dist/client/assets/{AppearancePage-DJfJUAkw.js → AppearancePage-DXbhUt2e.js} +1 -1
- package/dist/client/assets/{ApplyToOverridesDialog-Akw0_458.js → ApplyToOverridesDialog-C_QQhNIf.js} +1 -1
- package/dist/client/assets/{AttentionSignalRow-Cx9-sStN.js → AttentionSignalRow-5E7TkG98.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-CRlmlore.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-G7vrCqeA.js} +1 -1
- package/dist/client/assets/{BindingDialog-ZAX-h6D4.js → BindingDialog-q--8SDJF.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-fEMJgpNx.js → BlintzCanvas-DruVZcDU.js} +3 -3
- package/dist/client/assets/{CanvasCsvContent-CUoIFG7g.js → CanvasCsvContent-CtLpZnTs.js} +1 -1
- package/dist/client/assets/{CanvasFileContent-Cg2jcXse.js → CanvasFileContent-BThy5fjD.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-BL-UiHAj.js → CanvasModel3dContent-BbgR73jh.js} +2 -2
- package/dist/client/assets/ChannelComposer-qhk0KtW7.js +44 -0
- package/dist/client/assets/{ChatAppsOff-CSSu_yVC.js → ChatAppsOff-CCZUzDIH.js} +1 -1
- package/dist/client/assets/{CodeMirrorDiff-dfcDpguR.js → CodeMirrorDiff-BCpYdhgZ.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-C1YQ35ki.js → CodeMirrorEditor-BeCubxHV.js} +1 -1
- package/dist/client/assets/{CommitmentList-B6RG_hWB.js → CommitmentList-BZtfTnwg.js} +1 -1
- package/dist/client/assets/{CommitmentsPage-CDFvo1lt.js → CommitmentsPage-DmurDgxV.js} +1 -1
- package/dist/client/assets/{ComputerResourceView-vJ8UfRNm.js → ComputerResourceView-Bik6GLKp.js} +1 -1
- package/dist/client/assets/{ComputerViewer-BTqPuZyh.js → ComputerViewer-CksBDqdu.js} +1 -1
- package/dist/client/assets/{ConnectionAccessLists-DPnmOuiA.js → ConnectionAccessLists-DRwO1v0V.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-CSHnGkha.js → ConnectionsPage-Cgg36gDY.js} +1 -1
- package/dist/client/assets/{ConventionPage-C6WsAvm4.js → ConventionPage-CNhpF6Z1.js} +1 -1
- package/dist/client/assets/{ExtensionPageRoute-CGjw2Cwy.js → ExtensionPageRoute-C2zue_Pw.js} +1 -1
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-CKlmwuIc.js → FloatingTanStackRouterDevtools-CqogiFob-3v1TfY1P.js} +1 -1
- package/dist/client/assets/{ForwardConsentHost-D8rVtTRp.js → ForwardConsentHost-Mbo0D-zk.js} +1 -1
- package/dist/client/assets/HandlePage-B4qbFi40.js +1 -0
- package/dist/client/assets/{HeartbeatPage-DQImR4dY.js → HeartbeatPage-BnNbQLCW.js} +1 -1
- package/dist/client/assets/{KeyEntry-BerpQFQT.js → KeyEntry-C43vkwpA.js} +1 -1
- package/dist/client/assets/{LexicalField-CkcKNJGL.js → LexicalField-iAHcvRmI.js} +1 -1
- package/dist/client/assets/{ManagesPage-CV4xieFk.js → ManagesPage-BUIJvLmv.js} +1 -1
- package/dist/client/assets/{Marketplace-Cp0e4Nv8.js → Marketplace-DbdLWz0-.js} +1 -1
- package/dist/client/assets/{MarketplaceSourcesView-ZBNnVSuv.js → MarketplaceSourcesView-BZODwhxu.js} +1 -1
- package/dist/client/assets/{McpAppFrame-BtKAUDBg.js → McpAppFrame-D15nxVaI.js} +1 -1
- package/dist/client/assets/{McpSigninBody-DjGrp_sO.js → McpSigninBody-DmBxqgxN.js} +1 -1
- package/dist/client/assets/{Model3dViewer-BSX1QGsE.js → Model3dViewer-RGXeJd6a.js} +1 -1
- package/dist/client/assets/NamePage-fhxyWDDY.js +1 -0
- package/dist/client/assets/{NewDirectMessageMenu-DTQ7vFsa.js → NewDirectMessageMenu-DBAdvv5p.js} +1 -1
- package/dist/client/assets/{NotificationsPage-q7BDVKOz.js → NotificationsPage-NRfyiinS.js} +1 -1
- package/dist/client/assets/{OpenMeshSwitch-aAMKDAyc.js → OpenMeshSwitch-CgQ6uefo.js} +1 -1
- package/dist/client/assets/{OperatorIdentityForm-CCAvadEZ.js → OperatorIdentityForm-Bls5Vo_u.js} +1 -1
- package/dist/client/assets/{PermissionHistory-_8m4ohGq.js → PermissionHistory-DPEPq8D9.js} +1 -1
- package/dist/client/assets/{PermissionsPage-DHl8sCfQ.js → PermissionsPage--k-xutbJ.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-DOql0nWB.js → PersonalityPopover-DMMptmPS.js} +1 -1
- package/dist/client/assets/PhotoPage-CNHcXbz4.js +1 -0
- package/dist/client/assets/{PreviewRefusedNotice-BfvSYL-w.js → PreviewRefusedNotice-Ds4IO32o.js} +1 -1
- package/dist/client/assets/{ProfileFields-CX2mdPAV.js → ProfileFields-DbPJ7fvN.js} +1 -1
- package/dist/client/assets/{ProfilePanelContainer-Cj_57NEG.js → ProfilePanelContainer-CzwhrIlw.js} +1 -1
- package/dist/client/assets/{ProfileRolePicker-D7F0PDw9.js → ProfileRolePicker-CZEXvlJm.js} +1 -1
- package/dist/client/assets/{PromptSuggestionChips-BopMvYe7.js → PromptSuggestionChips-BXxC799Q.js} +1 -1
- package/dist/client/assets/{ReportsToPopover-CG_hjT_U.js → ReportsToPopover-YOwGLJy5.js} +1 -1
- package/dist/client/assets/{RoomSurface-Mt3dk4_6.js → RoomSurface-DgH3a_Fv.js} +1 -1
- package/dist/client/assets/{RoomsPage-ByHhS_HA.js → RoomsPage-CoXjZMWL.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-DS8_Au0B.js → RunsOnPopover-CEkkjrGg.js} +1 -1
- package/dist/client/assets/{RuntimeConnectFlow-hhvWVRMu.js → RuntimeConnectFlow-DXWGgvCW.js} +1 -1
- package/dist/client/assets/{RuntimeSetupDialog-NKy3mLEH.js → RuntimeSetupDialog-D6L1QhMF.js} +1 -1
- package/dist/client/assets/{SeenDevices-65oxnxk6.js → SeenDevices-Bh2yh-PW.js} +1 -1
- package/dist/client/assets/{SessionsPage-WbWf0huR.js → SessionsPage-CFvkbT9X.js} +1 -1
- package/dist/client/assets/{SettingsDialog-e33ltTb6.js → SettingsDialog-BOOqWKcj.js} +1 -1
- package/dist/client/assets/{SkillsPage-Cj3XrV8s.js → SkillsPage-ntCEhUIM.js} +1 -1
- package/dist/client/assets/{TaskDialogWrapper-DJAGQuab.js → TaskDialogWrapper-vBWAWwTY.js} +1 -1
- package/dist/client/assets/{TasksEmptyState-DNI1C274.js → TasksEmptyState-C_3UkAbA.js} +1 -1
- package/dist/client/assets/{TasksPage-Dc1j_X1K.js → TasksPage-D0Zi6Mve.js} +1 -1
- package/dist/client/assets/{TeamComputerEntry-DWenh1bP.js → TeamComputerEntry-CY9eLVad.js} +1 -1
- package/dist/client/assets/{ToolsPage-CXKq_axq.js → ToolsPage-0_vx5P-F.js} +1 -1
- package/dist/client/assets/{TopologyGraph-DgTGLoaA.js → TopologyGraph-DUZLZZrB.js} +1 -1
- package/dist/client/assets/{TourHost-C4KKDX9k.js → TourHost-B69XAKpE.js} +1 -1
- package/dist/client/assets/{UnlinkDialog-GfsbP91q.js → UnlinkDialog-ptZy3IN4.js} +1 -1
- package/dist/client/assets/UnreadDivider-Ckey1IWn.js +1 -0
- package/dist/client/assets/{WidgetErrorCard-BZkAK-Ke.js → WidgetErrorCard-BlqaIsPK.js} +7 -7
- package/dist/client/assets/{WithheldExtensionsNotice-Dt51QZLT.js → WithheldExtensionsNotice-7Vu1Jctn.js} +1 -1
- package/dist/client/assets/WorkView-BekLkR4O.js +51 -0
- package/dist/client/assets/{_shell-BScdINMH.js → _shell-Du0F-5fK.js} +1 -1
- package/dist/client/assets/{_shell._home-CUusDXBM.js → _shell._home-BRIXhYLg.js} +1 -1
- package/dist/client/assets/{_shell._home.activity-DPjJ1_vZ.js → _shell._home.activity-5rihXoYF.js} +1 -1
- package/dist/client/assets/{_shell._home.index-CTBWy5Au.js → _shell._home.index-BsLNqt4f.js} +1 -1
- package/dist/client/assets/{_shell._home.tasks-DWFh5Qbq.js → _shell._home.tasks-Cxs5tLWA.js} +1 -1
- package/dist/client/assets/{_shell._home.workspaces-DWjB1sCd.js → _shell._home.workspaces-CEHDdfbP.js} +1 -1
- package/dist/client/assets/{_shell.channels-C6v3yOzH.js → _shell.channels-Bx6q9xVH.js} +1 -1
- package/dist/client/assets/{_shell.connections-jXaP35mN.js → _shell.connections-Bm0WmgXH.js} +1 -1
- package/dist/client/assets/{_shell.feedback-requests-CyV-aboj.js → _shell.feedback-requests-DFznTGbN.js} +1 -1
- package/dist/client/assets/_shell.marketplace-CsQ60Mlc.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-DNyShS1x.js +1 -0
- package/dist/client/assets/_shell.session-BN42bV3w.js +1 -0
- package/dist/client/assets/{_shell.team-BPevCu33.js → _shell.team-DmA09abY.js} +3 -3
- package/dist/client/assets/{_shell.threads-gzYSpt7x.js → _shell.threads-HH4EvufJ.js} +1 -1
- package/dist/client/assets/_shell.x._extensionId-3ZlJV1iu.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-3ZlJV1iu.js +1 -0
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-iUnN9Com.js → abnfDiagram-WEYOIA3C-DxgtVd9I.js} +1 -1
- package/dist/client/assets/{access-copy-CP0B1ZT9.js → access-copy-Dqct36mi.js} +1 -1
- package/dist/client/assets/{arc-BVSQ4HBO.js → arc-C-67Ef0p.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-_zlUU8PS.js → architectureDiagram-ZHVYKT53-B7TjdT-_.js} +1 -1
- package/dist/client/assets/{banner-DTCBttcQ.js → banner-C9qTs6-C.js} +1 -1
- package/dist/client/assets/{blockDiagram-RJAE7QA3-COqNq2ny.js → blockDiagram-RJAE7QA3-DNqxJ3Ww.js} +1 -1
- package/dist/client/assets/{c4Diagram-XDPPPE54-Caa3QxQ_.js → c4Diagram-XDPPPE54-D3jNLV0j.js} +1 -1
- package/dist/client/assets/{card-D9DO5nt4.js → card-DUmTNXJJ.js} +1 -1
- package/dist/client/assets/channel-B7zgJbnU.js +1 -0
- package/dist/client/assets/{chunk-2E7WHVMD-BqirxZIN.js → chunk-2E7WHVMD-C6OKx0ty.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-CYGt3XQf.js → chunk-2Q5K7J3B-Dr_6hHrZ.js} +1 -1
- package/dist/client/assets/{chunk-4EMNKR2T-Bx234GPP.js → chunk-4EMNKR2T-CSrZVDEt.js} +1 -1
- package/dist/client/assets/{chunk-55XCU76K-CAA7du3_.js → chunk-55XCU76K-CIazeRXO.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-Dxl-FvVz.js → chunk-5VM5RSS4-C8IJ3zTR.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-CjcTenhr.js → chunk-JWPE2WC7-D9DGXb79.js} +1 -1
- package/dist/client/assets/{chunk-VQ5W62QI-COdK9J2i.js → chunk-VQ5W62QI-B0LNYdif.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-DeXzMeSy.js → chunk-XXDRQBXY-C7IAIbvZ.js} +1 -1
- package/dist/client/assets/{chunk-ZCHMQSOR-C7r0u2k6.js → chunk-ZCHMQSOR-C79hvjlu.js} +2 -2
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-BSI2Eza3.js → classDiagram-v2-4MYWR3UA-0Di1C2ZB.js} +1 -1
- package/dist/client/assets/{command-C7Cl56dV.js → command-BVQb6I3_.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-CLzQXbOG.js → cose-bilkent-JH36ORCC-rZumaV4b.js} +1 -1
- package/dist/client/assets/{cpu-CLfYM0zq.js → cpu-DeRuDMl4.js} +1 -1
- package/dist/client/assets/{cynefin-EF2NZ3EQ-e_0nKhb5.js → cynefin-EF2NZ3EQ-CI9l9xhM.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-Cflfw_GE.js → cynefinDiagram-WF24UDRP-C8CdorJJ.js} +1 -1
- package/dist/client/assets/{dagre-NK4GIZVX-D66Simjb.js → dagre-NK4GIZVX-AHpsTq1O.js} +1 -1
- package/dist/client/assets/{diagram-CBK3MWTC-CJEeUCUY.js → diagram-CBK3MWTC-BpPLL30n.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-BPSiDLoN.js → diagram-I5XIIV2D-D6loMn3G.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-DJptgW_s.js → diagram-ODIL2UCW-BaGNd5eN.js} +1 -1
- package/dist/client/assets/{diagram-PFBEJUXE-BECklqVg.js → diagram-PFBEJUXE-BnDdKu_g.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-B-veBl7Z.js → diagram-RJA3I4VV-UXagB0_c.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-U8kleemE.js → diagram-TYUNFSNR-C-whBP-S.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-DlwBfJCe.js → ebnfDiagram-V4P3TTPT-BbG481iS.js} +1 -1
- package/dist/client/assets/{elk-QONTBCTQ-DnFzEb3y.js → elk-QONTBCTQ-FtssIxOc.js} +1 -1
- package/dist/client/assets/{empty-state-2mQX7azC.js → empty-state-CACt-76q.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-CYTM37Ws.js → erDiagram-KYQIGQAA-PpFgUf4C.js} +1 -1
- package/dist/client/assets/{execution-config-COqY7hHn.js → execution-config-CGL73sRn.js} +1 -1
- package/dist/client/assets/{file-CKSjJRX5.js → file-D80JE_L0.js} +1 -1
- package/dist/client/assets/{file-exclamation-point-ad7FedZ9.js → file-exclamation-point-CcJ_e4_m.js} +1 -1
- package/dist/client/assets/{file-text-DXPPkxAL.js → file-text-Ds9edaTZ.js} +1 -1
- package/dist/client/assets/{find-latest-widget-fence-BsDq4SYp.js → find-latest-widget-fence-BtqFMP_f.js} +1 -1
- package/dist/client/assets/{flowDiagram-IUGLLWBU-DD259OPj.js → flowDiagram-IUGLLWBU-BIva66g9.js} +1 -1
- package/dist/client/assets/{form-C9cPRNOV.js → form-D93N5lrK.js} +1 -1
- package/dist/client/assets/{format-cron-DIw9_M6c.js → format-cron-BpGrgPLu.js} +1 -1
- package/dist/client/assets/{ganttDiagram-R7GPNTJY-BmoAVY6N.js → ganttDiagram-R7GPNTJY-CZqips_4.js} +1 -1
- package/dist/client/assets/{git-branch-DlUQMA-U.js → git-branch-B8JNwQ6q.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-Db8GGxGr.js → gitGraphDiagram-PDYL7XHY-DoIc3lda.js} +1 -1
- package/dist/client/assets/{graph-BqwkokGk.js → graph-yizM0vwL.js} +1 -1
- package/dist/client/assets/{heart-CRoafWCm.js → heart-BavUIV45.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-D-QIuqsv.js → highlighted-body-KPVGNVTW-CGr3AgaU.js} +1 -1
- package/dist/client/assets/{image-lightbox-BZBT_ptW.js → image-lightbox-vgPEvSCc.js} +1 -1
- package/dist/client/assets/{image-off-Bc6AP3w0.js → image-off-C1uTDs9-.js} +1 -1
- package/dist/client/assets/{index-sCJ7YWzB.js → index-1QfQImuJ.js} +3 -3
- package/dist/client/assets/{index-CTFwtIJP.js → index-56EOd-zy.js} +1 -1
- package/dist/client/assets/{index-AxYQRAoO.js → index-7XeZCCDI.js} +1 -1
- package/dist/client/assets/{index-bSzhhjtG.js → index-B36osK_S.js} +1 -1
- package/dist/client/assets/{index-BHNwprrd.js → index-B446r3dL.js} +1 -1
- package/dist/client/assets/{index-Cpy9wOYc.js → index-BGo1YiUE.js} +1 -1
- package/dist/client/assets/{index-DV5hFlfw.js → index-BJEt9R_G.js} +1 -1
- package/dist/client/assets/{index-y1yAU07O.js → index-BKWJiERs.js} +1 -1
- package/dist/client/assets/{index-DfWZORsm.js → index-BO3yPJt-.js} +1 -1
- package/dist/client/assets/{index-Cs9yQ5zH.js → index-BOEPL6hN.js} +1 -1
- package/dist/client/assets/{index-CFV7Ggyj.js → index-BOhSPP-6.js} +1 -1
- package/dist/client/assets/{index-okP_lDUw.js → index-BkJlIXqM.js} +1 -1
- package/dist/client/assets/{index-zSj20f3H.js → index-Br6xDNvu.js} +1 -1
- package/dist/client/assets/{index-CNsZn6QE.js → index-C4t0UTU-.js} +1 -1
- package/dist/client/assets/{index-BeCzlnZ3.js → index-C8ZpJXTQ.js} +1 -1
- package/dist/client/assets/{index-Cx2slDvh.js → index-CJXMgnYp.js} +1 -1
- package/dist/client/assets/{index-CoFRHepD.js → index-CXBYgGja.js} +1 -1
- package/dist/client/assets/{index-a8LKmWxN.js → index-Cdod8zEY.js} +1 -1
- package/dist/client/assets/{index-CWfreKgt.js → index-CeDn1Ak1.js} +1 -1
- package/dist/client/assets/{index-Bw1l5I4w.js → index-CiGYtR9O.js} +1 -1
- package/dist/client/assets/{index-Hf3kLtiJ.js → index-CoKNU2F9.js} +1 -1
- package/dist/client/assets/{index-mrbr3BaJ.js → index-CoNMlH37.js} +1 -1
- package/dist/client/assets/{index-jIAsl-Y5.js → index-CrTmY12y.js} +2 -2
- package/dist/client/assets/{index-CMWttCLt.js → index-DE6uOpn4.js} +1 -1
- package/dist/client/assets/{index-CptdhVbC.js → index-DEiSJbvu.js} +1 -1
- package/dist/client/assets/{index-Dtb34mrg.js → index-DW4KUPHp.js} +1 -1
- package/dist/client/assets/{index-x0XGESNQ.js → index-DYEmUa5t.js} +1 -1
- package/dist/client/assets/index-Dag1qeZI.js +1 -0
- package/dist/client/assets/{index-CWx_JEio.js → index-Dcd4NqFB.js} +1 -1
- package/dist/client/assets/{index-Clr1ssap.js → index-Dm0Tav7v.js} +1 -1
- package/dist/client/assets/{index-CZ4wx2F3.js → index-DqkFtcGQ.js} +1 -1
- package/dist/client/assets/{index-eF6QtmU6.js → index-FI_y_dND.js} +1 -1
- package/dist/client/assets/{index-DMlo5rLX.js → index-FhWMRBQP.js} +1 -1
- package/dist/client/assets/{index-DDGc0Nfu.js → index-LwL5BpE4.js} +1 -1
- package/dist/client/assets/{index-B48IJBNm.js → index-OQuvRZTD.js} +250 -250
- package/dist/client/assets/{index-zIfhHvVv.js → index-QSXJR98z.js} +1 -1
- package/dist/client/assets/{index-78G8l1M7.js → index-SOKlO1zZ.js} +1 -1
- package/dist/client/assets/{index-Be3_cvW0.js → index-X282DRZf.js} +1 -1
- package/dist/client/assets/{index-BwOvHDL2.js → index-YSHcMqHa.js} +1 -1
- package/dist/client/assets/{index-DwyVu2Mh.js → index-ZR5f82z2.js} +1 -1
- package/dist/client/assets/index-eVrGefuq.js +1 -0
- package/dist/client/assets/{index-ByyXrDny.js → index-n_pnc-CO.js} +1 -1
- package/dist/client/assets/{index-B_i3pTpf.js → index-tgbcsB6H.js} +1 -1
- package/dist/client/assets/{index.esm-uC5dql6Q.js → index.esm-CAeUe7uQ.js} +1 -1
- package/dist/client/assets/{infoDiagram-MVDRKAX5-y6U3OQ5m.js → infoDiagram-MVDRKAX5-DweUdYSy.js} +1 -1
- package/dist/client/assets/{inline-code-BCFlKPIb.js → inline-code-SYHTKcle.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-D32SA0vX.js → ishikawaDiagram-HPEHV2GE-DKNQIv7P.js} +1 -1
- package/dist/client/assets/{journeyDiagram-BOSHW7O7-D1X0dI8X.js → journeyDiagram-BOSHW7O7-DPD7F4VO.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-gU9KcKa4.js → kanban-definition-FNSA4HC5-B_uPSwxC.js} +1 -1
- package/dist/client/assets/{layers-A4MxcGWV.js → layers-F4mvrI2l.js} +1 -1
- package/dist/client/assets/{lightbulb-Dh2dYHMS.js → lightbulb-a6nNsrzy.js} +1 -1
- package/dist/client/assets/{link-2-qEUih2FP.js → link-2-yI2Tlm7Q.js} +1 -1
- package/dist/client/assets/{list-runtime-types-B1J9AtqH.js → list-runtime-types-CsGil5te.js} +1 -1
- package/dist/client/assets/{markdown-content-BA0KEJH_.js → markdown-content-Cjhsscbn.js} +1 -1
- package/dist/client/assets/{mention-pill-0aHe3D1A.js → mention-pill-BsOeTJ2f.js} +1 -1
- package/dist/client/assets/{mermaid.core-Birdr1kF.js → mermaid.core-9PwG-9fN.js} +4 -4
- package/dist/client/assets/{message-square-off-DvVenheW.js → message-square-off-aV4NMCjd.js} +1 -1
- package/dist/client/assets/{mindmap-definition-6OY57UG3-CLlh3nSF.js → mindmap-definition-6OY57UG3-BRbWmQkj.js} +1 -1
- package/dist/client/assets/{more-details-Bo2AAXHj.js → more-details-CRLU2HN4.js} +1 -1
- package/dist/client/assets/{owner-notice-DReCUEf1.js → owner-notice-CTJbhUak.js} +1 -1
- package/dist/client/assets/{package-CxZe6vve.js → package-sPggO7Dr.js} +1 -1
- package/dist/client/assets/{page-container-Bx1sr900.js → page-container-CnfDuiDC.js} +1 -1
- package/dist/client/assets/{pane-resize-handle-ojhYGmDs.js → pane-resize-handle-63OC5vfI.js} +1 -1
- package/dist/client/assets/{paperclip-D3-8ygf1.js → paperclip-WhPo3_WD.js} +1 -1
- package/dist/client/assets/{path-input-D_o1_pAa.js → path-input-C2KIXdON.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-BeMd_oXJ.js → pegDiagram-ECIUJNBX-Ct9Li_PA.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-CXUXnp_A.js → pieDiagram-GNMPY74T-BAB5RA5v.js} +1 -1
- package/dist/client/assets/{plug-Du5LK0oZ.js → plug-_q5iqunq.js} +1 -1
- package/dist/client/assets/{primer-trigger-BxofQe1n.js → primer-trigger-B2tjuHBx.js} +1 -1
- package/dist/client/assets/{profile-errors-C0BgTjzk.js → profile-errors-COcBx7w5.js} +1 -1
- package/dist/client/assets/{progress-AKcr8opu.js → progress-77FCPL2y.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-D57K4MC3-FTkKRlZm.js → quadrantDiagram-D57K4MC3-BqPJVmMS.js} +1 -1
- package/dist/client/assets/{query-error-state-CRmZMMkL.js → query-error-state-5236P3z0.js} +1 -1
- package/dist/client/assets/{radio-DQHR6Su5.js → radio-C8xmfoqO.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-D5TdGrPg.js → railroadDiagram-Y72NRBL7-B8U11nT6.js} +1 -1
- package/dist/client/assets/{registry-BxY1lah6.js → registry-BzXBOE9h.js} +13 -13
- package/dist/client/assets/registry-sfhDu9q2.js +1 -0
- package/dist/client/assets/{relay-trace-schemas---fuhTF2.js → relay-trace-schemas-B80E4EUn.js} +1 -1
- package/dist/client/assets/{repeat-zL9y24zY.js → repeat-CHmB_vD7.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-Dxiv9lE0.js → requirementDiagram-EQYSW5RA-CzJ1gzTh.js} +1 -1
- package/dist/client/assets/{room-files-source-B0WR4gIC.js → room-files-source-B0gc97Ri.js} +1 -1
- package/dist/client/assets/{rotate-ccw-clock-BUhy2_cF.js → rotate-ccw-clock-CCU6SVnv.js} +1 -1
- package/dist/client/assets/{rotate-cw-CCrNd4eJ.js → rotate-cw-B8WQa8O-.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-SY24JHO5-C3jjstXq.js → sankeyDiagram-SY24JHO5-D4vQwyve.js} +1 -1
- package/dist/client/assets/{scroll-area-D6gNpFjK.js → scroll-area-FwZwM74Q.js} +1 -1
- package/dist/client/assets/{search-x-CUZ1LRYe.js → search-x-Q18Wm-C5.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-CIDmjz0x.js → sequenceDiagram-BLEHNHQU-BVnIsPQe.js} +1 -1
- package/dist/client/assets/{shield-x-Ch7sY2XD.js → shield-x-ijIbRppV.js} +1 -1
- package/dist/client/assets/{signed-in-BQ44fFH5.js → signed-in-DEOMBWVX.js} +1 -1
- package/dist/client/assets/{sizeCapture-INFHLROL-Dkp-75Wy.js → sizeCapture-INFHLROL-DGb1rAJL.js} +1 -1
- package/dist/client/assets/{soul-file-CTFcpRMh.js → soul-file-CXgYs25S.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-L_51UnwV.js → stateDiagram-v2-A6IESKWZ-DeX3IKTm.js} +1 -1
- package/dist/client/assets/{swimlanes-B3ENRKFQ-D-etAQQd.js → swimlanes-B3ENRKFQ-DN5ljYhG.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-D8kHFWtL.js +8 -0
- package/dist/client/assets/{table-D6BUawIb.js → table-D9ww_3Ij.js} +1 -1
- package/dist/client/assets/{timeline-definition-JXYKGLGB-DNxnC3VG.js → timeline-definition-JXYKGLGB-DpRthC3r.js} +1 -1
- package/dist/client/assets/{trust-posture-5IWBJmA5.js → trust-posture-Dn2ciEE0.js} +1 -1
- package/dist/client/assets/{unplug-BVIT6OSL.js → unplug-BZ8zSvfB.js} +1 -1
- package/dist/client/assets/{unverified-catalog-notice-BA7_V-80.js → unverified-catalog-notice-CGy05tAO.js} +1 -1
- package/dist/client/assets/{use-bindings-DdWRXvtd.js → use-bindings-BLAWQRpe.js} +1 -1
- package/dist/client/assets/{use-composer-prefs-DC5w4eWw.js → use-composer-prefs-ICOpilWK.js} +1 -1
- package/dist/client/assets/{use-connector-management-DDlpD6tk.js → use-connector-management-DEMGZy9N.js} +1 -1
- package/dist/client/assets/{use-deep-link-scroll-Cvv0VcXx.js → use-deep-link-scroll-DxGYrks3.js} +1 -1
- package/dist/client/assets/{use-delete-binding-D585ISkL.js → use-delete-binding-Bnv3J5Fu.js} +1 -1
- package/dist/client/assets/{use-dev-links-BwS5hgur.js → use-dev-links-BOcktLiE.js} +1 -1
- package/dist/client/assets/{use-direct-message-panel--unflmj8.js → use-direct-message-panel-D38tSozW.js} +1 -1
- package/dist/client/assets/{use-external-adapter-catalog-DUyh1bH1.js → use-external-adapter-catalog-9qiNBqpc.js} +1 -1
- package/dist/client/assets/{use-full-activity-feed-DsNOIkL8.js → use-full-activity-feed-CtQquOBW.js} +1 -1
- package/dist/client/assets/use-is-below-desktop-CAGEAsCC.js +1 -0
- package/dist/client/assets/{use-local-browser-DGIut7R4.js → use-local-browser-B1huJhdg.js} +1 -1
- package/dist/client/assets/{use-mesh-topology-DNXD7seM.js → use-mesh-topology-BTYAy6zc.js} +1 -1
- package/dist/client/assets/{use-mounted-ref-7xoMthh4.js → use-mounted-ref-CaPc6Prv.js} +1 -1
- package/dist/client/assets/{use-notification-prefs-CzibxpTZ.js → use-notification-prefs-u76DPoP0.js} +1 -1
- package/dist/client/assets/use-pending-read-D0y6i7G9.js +1 -0
- package/dist/client/assets/{use-personality-commit-isaMS7W5.js → use-personality-commit-C3h8upDo.js} +1 -1
- package/dist/client/assets/{use-promo-activation-DesLEeyi.js → use-promo-activation-5HG08FlB.js} +1 -1
- package/dist/client/assets/{use-promo-dismissals-DQi8tey8.js → use-promo-dismissals-CO7-qhEl.js} +1 -1
- package/dist/client/assets/{use-pulse-freshness-DPplpvcq.js → use-pulse-freshness-D07Mv-Sa.js} +1 -1
- package/dist/client/assets/{use-room-follow-claim-C4UikQzz.js → use-room-follow-claim-DRQBuAIe.js} +1 -1
- package/dist/client/assets/{use-room-sessions-C6wsszcG.js → use-room-sessions-Bzk7rM40.js} +1 -1
- package/dist/client/assets/{use-roving-tab-list-DEh387tR.js → use-roving-tab-list-CcznVldj.js} +1 -1
- package/dist/client/assets/use-session-canvas-CpgE7tFb.js +27 -0
- package/dist/client/assets/{use-status-budget-CltxSIUD.js → use-status-budget-Xn2sIeM1.js} +2 -2
- package/dist/client/assets/{use-transform-CNLqlc2h.js → use-transform-ByJGn3hq.js} +1 -1
- package/dist/client/assets/{use-unclaimed-chats-DJyl7A1E.js → use-unclaimed-chats-C-z5fstJ.js} +1 -1
- package/dist/client/assets/use-update-config-L5NCTj3t.js +1 -0
- package/dist/client/assets/{useMutationState-BX-ggHVY.js → useMutationState-BF1EFtIZ.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-2l6yZUUH.js → usecaseDiagram-WPOLBNNX-efVKbRIX.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-DIOfjNDq.js → vennDiagram-Q3Y3IDCW-Bravmwce.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA-B5Hx1we8.js → wardleyDiagram-IVAIDKWA-fR77zByv.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-sy90CqIK.js → xychartDiagram-4URNHDU4-BphORSLh.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/drizzle/20261030041403_dor3376_project_only_schedules.sql +1 -0
- package/dist/drizzle/meta/20261030041403_snapshot.json +14101 -0
- package/dist/drizzle/meta/_journal.json +7 -0
- package/dist/server/index.js +26499 -23006
- package/dist/server/index.js.map +2 -2
- package/package.json +6 -5
- package/dist/client/assets/ChannelComposer-BHxXoQwT.js +0 -44
- package/dist/client/assets/HandlePage-BciCIffv.js +0 -1
- package/dist/client/assets/NamePage-tBV32PJI.js +0 -1
- package/dist/client/assets/PhotoPage-DtX2GEvQ.js +0 -1
- package/dist/client/assets/UnreadDivider-C52_nmrB.js +0 -1
- package/dist/client/assets/WorkView-YozVoXhb.js +0 -51
- package/dist/client/assets/_shell.marketplace-Cp2Udmlv.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-Dg0YgG-u.js +0 -1
- package/dist/client/assets/_shell.session-DyKnijqi.js +0 -1
- package/dist/client/assets/_shell.x._extensionId-BA0u_ZTU.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-BA0u_ZTU.js +0 -1
- package/dist/client/assets/channel-CenDG0-I.js +0 -1
- package/dist/client/assets/index-DSt16Y0s.js +0 -1
- package/dist/client/assets/index-sZ8Dddnp.js +0 -1
- package/dist/client/assets/registry-CWK5lzYs.js +0 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-zjIBWGY4.js +0 -8
- package/dist/client/assets/use-is-below-desktop-C-4kc5lS.js +0 -1
- package/dist/client/assets/use-pending-read-BTR5-HXf.js +0 -1
- package/dist/client/assets/use-session-canvas-B2CM1KZu.js +0 -27
- package/dist/client/assets/use-update-config-B2rsDnxk.js +0 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var Aa=Object.defineProperty;var _a=(e,t,n)=>t in e?Aa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ye=(e,t,n)=>_a(e,typeof t!="symbol"?t+"":t,n);import{r as l,O as it,e3 as Le,j as r,ap as Q,bw as me,ih as Un,a1 as be,qK as Ar,q as rt,kr as Ma,cq as Oa,qL as _r,qM as Ia,qN as Da,g8 as Pa,B as ue,dD as Oe,fA as $a,G as H,J as Qt,X as ot,b7 as ft,qO as kt,qP as Mr,aW as ie,qQ as Fa,qR as Tn,ie as La,aL as qn,dG as Ua,an as qa,j6 as za,ag as lt,a7 as zn,qS as Ba,j7 as Wa,qT as Ha,ba as Ga,x as Ue,U as vt,ik as Be,il as We,ah as Bn,qU as Vt,ee as St,kk as Ka,cs as Qe,s as ct,gS as Qa,gO as vs,is as Or,gW as Va,C as Bt,qV as Ya,l as Xa,n6 as Ir,aU as Ja,qW as Za,qX as Fe,o4 as Ce,od as ei,o5 as Yt,aO as ti,i0 as ni,cB as si,bU as ri,ju as oi,qY as tt,a0 as Wn,eR as Ss,dI as Dr,f as Pr,qZ as js,ed as ws,a6 as at,pF as ai,q_ as ii,pM as gt,q$ as Wt,a2 as ut,jS as Hn,a4 as xt,hh as jt,ec as Gn,ck as wt,d0 as li,d1 as ci,d3 as ui,d4 as di,d5 as mi,eC as fi,e as Ns,lo as pi,dN as hi,lp as gi,pH as Kn,e7 as xi,r0 as yi,r1 as bi,lC as Qn,r2 as $r,r3 as Fr,r4 as ki,r5 as vi,a3 as Vn,cS as Nt,eb as Xt,e9 as Yn,ea as Si,r6 as ji,j_ as Lr,r7 as wi,pJ as Ni,ia as Ci,hI as Ur,iy as qr,hU as yt,j$ as zr,eO as Ti,r8 as Ri,r9 as Ei,o as Br,y as Jt,aT as Wr,ra as Hr,rb as Ai,nF as an,rc as Ht,jH as _i,lt as Mi,bc as Gr,rd as Xn,re as Oi,rf as Ii,rg as Di,rh as Kr,ri as Pi,rj as $i,rk as Qr,rl as Vr,fg as Fi,rm as Li,fC as Ui,fe as qi,m7 as zi,bH as Bi,bI as Wi,bJ as Hi,bK as Gi,bL as Ki,bM as Qi,bN as Vi,bP as Yi,rn as Xi,o_ as Yr,ro as Ji,rp as Zi,mz as el,jB as tl,jC as nl,jD as sl,jE as ln,n0 as rl,jF as Cs,kj as ol,bZ as al,kl as il,b$ as ll,rq as Ts,cE as cl,f_ as Xr,cJ as Jr,cy as ul,cI as dl,iw as ml,cR as Zr,rr as eo,cu as to,cO as fl,rs as Jn,cP as pl,rt as hl,ar as gl,cA as xl,ru as yl,mg as re,rv as bl,rw as kl,cN as vl,_ as Sl,aS as Ge,nk as Rs,rx as jl,iY as He,ry as cn,dV as pt,rz as Es,rA as As,rB as _s,ct as un,rC as et,eS as ht,rD as wl,cU as no,rE as so,rF as Nl,rG as Cl,rH as Tl,cV as ro,rI as Rl,rJ as El,rK as Xe,rL as oo,rM as Al,bY as _l,rN as Ml,rO as Ol,fB as ao,rP as Ms,rQ as Il,c4 as Rn,jl as io,el as Dl,cY as Pl,rR as $l,gv as Fl,gu as Ll,jn as Ul,cl as ql,cX as zl,ci as Bl,ai as Zt,rS as Wl,rT as Hl,gp as lo,gm as Zn,kM as Gl,rU as Kl,rV as Ql,rW as Vl,i$ as Yl,rX as co,oy as Xl,jG as Jl,rY as mt,rZ as Zl,cT as ec,hl as tc,r_ as nc,fx as sc,r$ as rc,e1 as oc,jT as ac,Y as ic}from"./index-OQuvRZTD.js";import{P as lc}from"./PromptSuggestionChips-BXxC799Q.js";import{u as cc,a as uc,L as dc,f as mc,b as fc,c as pc,B as hc,d as gc}from"./primer-trigger-B2tjuHBx.js";import{C as xc}from"./card-DUmTNXJJ.js";import{a as yc,u as bc,i as kc}from"./use-notification-prefs-u76DPoP0.js";import{e as vc,h as Sc,o as uo,f as jc,P as wc,g as Nc,d as Cc,p as Tc,j as Rc,b as Ec,G as Ac,W as mo,y as _c,x as Mc,z as Oc,u as Ic,t as Dc,w as Pc,n as $c,k as Fc,s as Lc,M as Uc,i as qc,S as zc,U as Bc,A as Wc,v as Hc,R as Gc,q as Kc}from"./use-status-budget-Xn2sIeM1.js";import{B as Qc}from"./banner-C9qTs6-C.js";import{t as At,S as es,f as Gt,n as fo,O as po,o as Vc,p as Yc,V as ho,q as Xc,r as Jc,s as Zc,v as eu,w as Os,x as Is,T as tu,y as nu,L as Ds,z as go,A as su,B as xo,D as ru,G as yo,H as En,N as Ps,d as ou,I as bo,J as au,u as iu,C as bt,K as ko,c as Je,k as lu,h as cu,F as uu}from"./registry-BzXBOE9h.js";import{u as du,b as mu}from"./WidgetErrorCard-BlqaIsPK.js";import{u as fu,D as pu,U as hu}from"./UnreadDivider-Ckey1IWn.js";import{a as gu,c as xu}from"./composer-insert-BpyATrmR.js";import{u as yu}from"./use-composer-prefs-ICOpilWK.js";import{A as An,M as bu}from"./McpAppFrame-D15nxVaI.js";import{P as ku,C as vu,b as Su}from"./find-latest-widget-fence-BtqFMP_f.js";import{F as vo}from"./file-D80JE_L0.js";import{F as ju,j as wu}from"./use-session-canvas-CpgE7tFb.js";import{F as Nu}from"./file-text-Ds9edaTZ.js";import{b as So,e as Cu,R as Tu,K as Ru,a as Eu,g as Au}from"./RuntimeConnectFlow-DXWGgvCW.js";import{S as _u}from"./shield-x-ijIbRppV.js";import{u as Mu,M as Ou}from"./McpSigninBody-DmBxqgxN.js";import{I as Iu}from"./image-off-C1uTDs9-.js";import{f as Du}from"./format-duration-BCr6uzby.js";import{l as Pu}from"./use-connector-management-DEMGZy9N.js";import{A as $u}from"./AgentRequestCard-DXJnLk6q.js";function Fu(e){const t=Math.floor(e/1e3);if(t<3600){const o=Math.floor(t/60),a=t%60;return`${o}m ${String(a).padStart(2,"0")}s`}const n=Math.floor(t/3600),s=Math.floor(t%3600/60);return`${n}h ${String(s).padStart(2,"0")}m`}function jo(e){const[t,n]=l.useState(()=>Date.now()),s=l.useRef(null);if(l.useEffect(()=>{if(e===null){s.current&&(clearInterval(s.current),s.current=null);return}return n(Date.now()),s.current=setInterval(()=>n(Date.now()),1e3),()=>{s.current&&(clearInterval(s.current),s.current=null)}},[e]),e===null)return{formatted:"0m 00s",ms:0};const o=Math.max(0,t-e);return{formatted:Fu(o),ms:o}}function Lu(e={}){const{timeoutMs:t=3e4,onIdle:n,onReturn:s}=e,o=l.useRef(!1),a=l.useRef(null),i=l.useCallback(()=>{o.current||(o.current=!0,n==null||n())},[n]),c=l.useCallback(()=>{o.current&&(o.current=!1,s==null||s())},[s]),u=l.useCallback(()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(i,t),c()},[t,i,c]);return l.useEffect(()=>{a.current=setTimeout(i,t);const d=["mousemove","keydown","scroll","touchstart"];d.forEach(h=>document.addEventListener(h,u,{passive:!0}));const m=()=>{document.hidden?i():u()};return document.addEventListener("visibilitychange",m),()=>{a.current&&clearTimeout(a.current),d.forEach(h=>document.removeEventListener(h,u)),document.removeEventListener("visibilitychange",m)}},[t,i,u]),{isIdle:o.current}}function Uu({activeInteraction:e,onApprove:t,onAlwaysAllow:n,onDeny:s,onToggleOption:o,onNavigateOption:a,onNavigateQuestion:i,onSubmit:c,optionCount:u=0,focusedIndex:d=0}){const m=l.useRef(!1);l.useEffect(()=>{m.current=!1},[e==null?void 0:e.toolCallId]),l.useEffect(()=>{if(!e)return;function h(p){const f=p.target,g=(f.tagName==="TEXTAREA"||f.tagName==="INPUT")&&!f.disabled;if(!m.current&&!(p.metaKey||p.ctrlKey||p.altKey)){if(e.type==="approval"){if(p.key==="Enter"&&g&&f.closest("[data-approval-field]")!==null)return;p.key==="Enter"&&p.shiftKey?(p.preventDefault(),m.current=!0,n==null||n()):p.key==="Enter"?(p.preventDefault(),m.current=!0,t==null||t()):p.key==="Escape"&&(p.preventDefault(),m.current=!0,s==null||s());return}if(e.type==="question"){if(g){if(p.key==="Enter"&&!p.shiftKey){p.preventDefault(),c==null||c();return}if(p.key==="ArrowUp"){p.preventDefault(),a==null||a("up");return}if(p.key==="ArrowDown"){p.preventDefault(),a==null||a("down");return}return}const x=parseInt(p.key,10);if(x>=1&&x<=9){p.preventDefault(),x-1<u&&(o==null||o(x-1));return}switch(p.key){case"ArrowUp":p.preventDefault(),a==null||a("up");break;case"ArrowDown":p.preventDefault(),a==null||a("down");break;case" ":p.preventDefault(),o==null||o(d);break;case"ArrowLeft":case"[":p.preventDefault(),i==null||i("prev");break;case"ArrowRight":case"]":p.preventDefault(),i==null||i("next");break;case"Enter":p.preventDefault(),c==null||c();break}}}}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,t,n,s,o,a,i,c,u,d])}function wo(){const[e,t]=l.useState(()=>!document.hidden);return l.useEffect(()=>{const n=()=>t(!document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),e}/**
|
|
2
|
+
* @license lucide-react v1.48.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const No={name:"brain",size:24,node:[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]};No.node;const qu=it(No);/**
|
|
7
|
+
* @license lucide-react v1.48.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Co={name:"corner-up-left",size:24,node:[["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}],["path",{d:"M9 14 4 9l5-5",key:"102s5s"}]]};Co.node;const zu=it(Co);/**
|
|
12
|
+
* @license lucide-react v1.48.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const To={name:"file-image",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]};To.node;const Bu=it(To);/**
|
|
17
|
+
* @license lucide-react v1.48.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Ro={name:"file-spreadsheet",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]};Ro.node;const Wu=it(Ro);/**
|
|
22
|
+
* @license lucide-react v1.48.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Eo={name:"git-branch-plus",size:24,node:[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]};Eo.node;const Hu=it(Eo);/**
|
|
27
|
+
* @license lucide-react v1.48.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Ao={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};Ao.node;const Gu=it(Ao);function Ku({color:e,isTextStreaming:t,fadeEdges:n=!0,edge:s="bottom"}){const o=Le()===!0,a=t?1.8:2.5,i=n?"linear-gradient(to right, transparent, black 15%, black 85%, transparent)":void 0,c=s==="top"?"pointer-events-none absolute right-0 top-0 left-0":"pointer-events-none absolute right-0 bottom-0 left-0",u="[--scan-highlight:hsl(var(--background))] dark:[--scan-highlight:hsl(var(--foreground))]",d=s==="top"?"top":"bottom";return r.jsxs(Q.div,{"aria-hidden":!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:`${c} ${u}`,style:{height:n?10:0,overflow:n?"hidden":"visible",maskImage:i,WebkitMaskImage:i},children:[r.jsx("div",{className:"absolute right-0 left-0",style:{[d]:0,height:6,backgroundColor:e,opacity:.6,filter:"blur(3px)"}}),!o&&r.jsx(Q.div,{initial:{x:"-100%"},animate:{x:"433%"},transition:{x:{duration:a,repeat:1/0,ease:"linear"}},className:"absolute",style:{[d]:0,width:"30%",height:2,background:`linear-gradient(to right, transparent, ${e}, var(--scan-highlight), transparent)`,willChange:"transform"}}),r.jsx(me,{children:t&&!o&&r.jsx(Q.div,{initial:{opacity:0,x:"-100%"},animate:{opacity:.9,x:"1525%"},exit:{opacity:0},transition:{x:{duration:1.1,repeat:1/0,ease:"linear"},opacity:{duration:.2}},className:"absolute",style:{[d]:0,width:"8%",height:1,background:"linear-gradient(to right, transparent, var(--scan-highlight) 40%, var(--scan-highlight) 60%, transparent)",willChange:"transform"}})})]})}const dn={"word-boundary":3,substring:2,subsequence:1},Qu=new Set(["/",":","-","_","."," "]);function Vu(e,t){if(t===0)return!0;const n=e[t-1];if(Qu.has(n))return!0;const s=e[t];return n===n.toLowerCase()&&s!==s.toLowerCase()&&s===s.toUpperCase()}function _t(e,t){return Array.from({length:t},(n,s)=>e+s)}function Mt(e,t,n){const s=1/(1+t),o=n/e.length;return(s*.6+o*.4)*.999}function Yu(e,t){let n=0,s=0,o=0;const a=[];for(let i=0;i<t.length&&n<e.length;i++)t[i]===e[n]?(n++,s++,s>o&&(o=s),a.push(i)):s=0;return n===e.length?{indices:a,maxRun:o}:null}function Xu(e,t){const n=t.indices[t.indices.length-1]-t.indices[0]+1,s=t.maxRun/t.indices.length,o=t.indices.length/n,a=t.indices.length/e.length;return(s*.4+o*.3+a*.3)*.999}function Ut(e,t){if(!e)return{match:!0,tier:null,score:0,indices:[]};const n=e.toLowerCase(),s=t.toLowerCase();if(s===n)return{match:!0,tier:"exact",score:5+Mt(t,0,n.length),indices:_t(0,n.length)};if(s.startsWith(n))return{match:!0,tier:"prefix",score:4+Mt(t,0,n.length),indices:_t(0,n.length)};for(let i=1;i<=s.length-n.length;i++)if(Vu(t,i)&&s.startsWith(n,i))return{match:!0,tier:"word-boundary",score:dn["word-boundary"]+Mt(t,i,n.length),indices:_t(i,n.length)};const o=s.indexOf(n);if(o>=0)return{match:!0,tier:"substring",score:dn.substring+Mt(t,o,n.length),indices:_t(o,n.length)};const a=Yu(n,s);return a?{match:!0,tier:"subsequence",score:dn.subsequence+Xu(t,a),indices:a.indices}:{match:!1,tier:null,score:0,indices:[]}}class Ju{constructor(t){Ye(this,"config");Ye(this,"recentCompletions",[]);Ye(this,"queue",[]);Ye(this,"isIdle",!1);Ye(this,"debounceTimer",null);this.config=t}onTaskCompleted(t,n){if(!this.config.enabled)return;const s=Date.now();this.recentCompletions.push(s),this.recentCompletions=this.recentCompletions.filter(c=>s-c<this.config.debounceWindowMs);const o=n.length,a=n.filter(c=>c.status==="completed").length;if(o>=this.config.minTasksForMajor&&a===o){this.cancelDebounce();const c={level:"major",taskId:t,timestamp:s};this.emitOrQueue(c);return}if(this.recentCompletions.length>=this.config.debounceThreshold){this.cancelDebounce(),this.debounceTimer=setTimeout(()=>{const c={level:"mini",taskId:t,timestamp:Date.now()};this.emitOrQueue(c),this.recentCompletions=[]},this.config.debounceWindowMs);return}if(Math.random()<this.config.miniProbability){const c={level:"mini",taskId:t,timestamp:s};this.emitOrQueue(c)}}setIdle(t){this.isIdle=t}onUserReturn(){if(this.queue.length>0){const n=this.queue.some(s=>s.level==="major")?this.queue.find(s=>s.level==="major"):this.queue[this.queue.length-1];this.config.onCelebrate(n),this.queue=[]}}destroy(){this.cancelDebounce(),this.queue=[],this.recentCompletions=[]}emitOrQueue(t){this.isIdle?this.queue.push(t):this.config.onCelebrate(t)}cancelDebounce(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}const Zu={background:"radial-gradient(circle, rgba(255,215,0,0.15) 0%, transparent 70%)"};function ed(e,t=40){if(e.length<=t)return e;const n=e.split("/").pop()??e,s=n.length+2,o=Math.max(6,t-s);return`${e.slice(0,o)}…/${n}`}function en(e){var n;const{sessions:t}=Un();if(e)return(n=t.find(s=>s.id===e))==null?void 0:n.runtime}const td=typeof window<"u"&&window.location.pathname===Oa;let mn=null,$s=!td;function nd(e){return $s?mn===e?!0:(mn=null,!1):($s=!0,mn=e,!0)}function sd(e){var s;const t=be(),n=((s=Ar(e))==null?void 0:s.draft)===!0;l.useEffect(()=>{if(!e||n)return;let o=!1;const a=()=>{o||document.visibilityState!=="visible"||(o=!0,document.removeEventListener("visibilitychange",a),nd(e)||rt.getState().recordOpened("session",e),t.markSessionOpened(e).catch(i=>{Ma(t,i)}))};if(a(),!o)return document.addEventListener("visibilitychange",a),()=>document.removeEventListener("visibilitychange",a)},[e,n,t])}function _o(){const e=_r(),t=Ar(e.session);return{cwd:(t==null?void 0:t.cwd)??e.dir??null}}function Mo({agentId:e,agentName:t,onResumed:n}){const s=Ia(),{data:o,dataUpdatedAt:a,refetch:i}=Da(),[c]=l.useState(()=>Date.now());l.useEffect(()=>{i()},[e,i]);const u=t??"This agent";return o!=null&&a>=c&&!o.pauses.some(m=>m.agentId===e)?null:r.jsxs("div",{"data-testid":"agent-paused-notice",role:"status",className:"border-border bg-muted/50 my-2 flex items-center gap-3 rounded-lg border px-4 py-3",children:[r.jsx(Pa,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("p",{className:"text-sm font-medium",children:[u," is paused"]}),r.jsx("p",{className:"text-muted-foreground text-xs",children:"Resume it, then send your message again."})]}),r.jsx(ue,{size:"sm",variant:"outline",disabled:s.isPending,onClick:()=>s.mutate(e,{onSuccess:()=>{Oe(`${u} resumed`),n==null||n()}}),children:"Resume"})]})}function rd(e){if(!e)return[];const t=e.properties??{};return Object.entries(t).map(([n,s])=>({key:n,label:s.description??n,type:s.type??"string",options:s.enum,defaultValue:s.default}))}function od({sessionId:e,interactionId:t,serverName:n,message:s,mode:o="form",url:a,requestedSchema:i,status:c,action:u}){const d=be(),[m,h]=l.useState(!1),[p,f]=l.useState(null),[g,x]=l.useState(null),[y,b]=l.useState({}),[v,j]=l.useState(!1),S=l.useMemo(()=>rd(i),[i]),T=c!=="pending",R=l.useCallback(async(N,k)=>{if(!(m||T)){h(!0),f(null),x(null);try{await d.submitElicitation(e,t,N,k)}catch(C){if(C.code!=="INTERACTION_ALREADY_RESOLVED"){f("Couldn’t send your answer. Try again."),x(C instanceof Error?C.message:null),h(!1);return}}h(!1)}},[d,e,t,m,T]),E=l.useCallback(()=>{const N={};for(const k of S)N[k.key]=y[k.key]??k.defaultValue??"";R("accept",N)},[S,y,R]),O=l.useCallback(()=>{R("accept")},[R]),A=l.useCallback(()=>{R("decline")},[R]),I=l.useCallback((N,k)=>{b(C=>({...C,[N]:k}))},[]),F=l.useCallback(()=>{if(a){if(!$a(a)){f(`Couldn’t open ${a}. Nothing has been authorized.`),x(null);return}f(null),x(null),j(!0)}},[a]);return T?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 py-1 text-xs",children:[r.jsx("span",{className:"font-mono",children:n}),r.jsx("span",{children:"·"}),r.jsx("span",{children:u==="accept"?"Authorized":u==="decline"?"Declined":"Cancelled"})]}):r.jsxs(Q.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.15},className:H("border-border bg-card my-2 rounded-xl border p-4","shadow-soft"),children:[r.jsxs("div",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-xs",children:[r.jsx("span",{className:"bg-muted text-3xs inline-flex items-center rounded-md px-2 py-0.5 font-mono",children:n}),r.jsx("span",{children:"needs something from you"})]}),r.jsx("p",{className:"mb-3 text-sm",children:s}),p&&r.jsxs("div",{className:"mb-2",children:[r.jsx("p",{className:"text-destructive text-xs break-words",children:p}),g&&r.jsx("p",{className:"text-muted-foreground/70 mt-1 text-xs break-words",children:g})]}),o==="url"&&a&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ue,{size:"sm",variant:"outline",onClick:F,disabled:m,children:"Open authorization page"}),v&&r.jsx(ue,{size:"sm",onClick:O,disabled:m,children:m?"Sending…":"Done"}),r.jsx(ue,{size:"sm",variant:"ghost",onClick:A,disabled:m,children:"Decline"})]}),o==="form"&&r.jsxs(r.Fragment,{children:[S.length>0?r.jsx("div",{className:"mb-3 space-y-2",children:S.map(N=>r.jsxs("div",{children:[r.jsx("label",{htmlFor:`elicitation-${t}-${N.key}`,className:"text-muted-foreground mb-1 block text-xs font-medium",children:N.label}),N.options?r.jsxs("select",{id:`elicitation-${t}-${N.key}`,className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",value:y[N.key]??String(N.defaultValue??""),onChange:k=>I(N.key,k.target.value),disabled:m,children:[r.jsx("option",{value:"",children:"Select…"}),N.options.map(k=>r.jsx("option",{value:k,children:k},k))]}):r.jsx("input",{id:`elicitation-${t}-${N.key}`,type:N.type==="number"?"number":"text",className:"border-input bg-background w-full rounded-md border px-3 py-1.5 text-sm",placeholder:String(N.defaultValue??""),value:y[N.key]??"",onChange:k=>I(N.key,k.target.value),disabled:m})]},N.key))}):r.jsx("p",{className:"text-muted-foreground mb-3 text-xs",children:"No additional input required."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ue,{size:"sm",onClick:E,disabled:m,children:m?"Sending…":"Accept"}),r.jsx(ue,{size:"sm",variant:"ghost",onClick:A,disabled:m,children:"Decline"})]})]})]})}const ad=8,id={duration:.3,ease:[.16,1,.3,1]},ld={duration:0};function cd(e){const t=Math.round(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}:${String(s).padStart(2,"0")}`:`${s}s`}function ud(e){return new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function dd(e){return`${e} action${e===1?"":"s"}`}function md({outcome:e,items:t,resolvedAt:n,startedAt:s,reasonGiven:o,className:a}){var x;const i=Le(),[c,u]=l.useState(!1),d=t.length,m=d>1,h=m?dd(d):(x=t[0])==null?void 0:x.label,p=n!==void 0&&s!==void 0?Math.max(0,n-s):null,f=e==="allowed"?Qt:e==="denied"?ot:ft,g=e==="allowed"?"text-status-success":e==="denied"?"text-status-error":"text-muted-foreground";return r.jsxs(Q.div,{"data-testid":"approval-receipt","data-outcome":e,"data-count":d,initial:i?!1:{opacity:0,y:ad},animate:{opacity:1,y:0},transition:i?ld:id,className:H("text-muted-foreground my-1 text-xs",a),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(f,{className:H("size-(--size-icon-xs) shrink-0",g),"aria-hidden":"true"}),r.jsx("span",{className:"min-w-0 truncate",children:e==="expired"?r.jsxs(r.Fragment,{children:["Expired · ",m?`${h} `:"","denied",p!==null&&` after ${cd(p)}`]}):r.jsxs(r.Fragment,{children:["You ",e==="allowed"?"allowed":"denied"," ",m?h:r.jsx("span",{className:"font-mono",children:h}),e==="denied"&&o===!0&&r.jsx(r.Fragment,{children:" · agent was told why"})]})}),n!==void 0&&r.jsx("time",{dateTime:new Date(n).toISOString(),className:"ml-auto shrink-0 tabular-nums opacity-70",children:ud(n)}),m&&r.jsx("button",{type:"button",onClick:()=>u(y=>!y),"aria-expanded":c,className:H("hover:text-foreground focus-visible:ring-ring shrink-0 rounded underline","underline-offset-2 focus-visible:ring-2 focus-visible:outline-none"),children:c?"Hide":"Show"})]}),m&&c&&r.jsx("ul",{"data-testid":"approval-receipt-items",className:"mt-1 ml-6 space-y-0.5",children:t.map(y=>r.jsx("li",{className:"truncate font-mono",children:y.label},y.toolCallId))})]})}function fd({outcome:e,reasonGiven:t,members:n,lead:s,children:o}){return r.jsxs("div",{className:"flex flex-col",children:[r.jsx(md,{outcome:e,items:n.map(a=>({toolCallId:a.toolCallId,label:a.approvalDisplayName||kt(a.toolName,a.input??"")})),resolvedAt:s.approvalResolvedAt,startedAt:s.approvalStartedAt,reasonGiven:t}),e!=="allowed"&&s.result&&r.jsx(Mr,{"data-testid":"approval-receipt-result",content:s.result,className:"text-muted-foreground mt-0.5 ml-6"}),e==="allowed"&&o]})}function ts(e){return e.endsWith("connectors.request_connection")||e.endsWith("connectors_request_connection")}function Oo(e){if(e)try{return JSON.parse(e)}catch{return}}function qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pd(e){const t=Oo(e);if(!qt(t))return;const{serviceSlug:n,reason:s}=t;if(!(typeof n!="string"||typeof s!="string"))return{serviceSlug:n,reason:s}}function Io(e){const t=Oo(e);if(qt(t)&&typeof t.requestId=="string")return t.requestId;if(qt(t)&&Array.isArray(t.content)){const n=t.content.map(s=>qt(s)&&typeof s.text=="string"?s.text:"").join("");return Io(n)}}function hd(e,t){const n=Io(t.result);if(n)return e.find(o=>o.requestId===n);const s=pd(t.input);if(s)return e.filter(o=>o.serviceSlug===s.serviceSlug).sort((o,a)=>a.createdAt.localeCompare(o.createdAt))[0]}function gd({sessionId:e,input:t,result:n,fallback:s}){const o=Pu(e),a=o.data?hd(o.data,{input:t,result:n}):void 0;return a?r.jsx("div",{className:"my-3","data-testid":"chat-agent-request",children:r.jsx($u,{request:a})}):r.jsx(r.Fragment,{children:s})}const fn={name:{exact:0,prefix:1,"word-boundary":2,substring:6,subsequence:8},alias:{exact:3,prefix:4,"word-boundary":5,substring:7,subsequence:9},description:{exact:10,prefix:11,"word-boundary":12,substring:13,subsequence:14}},xd={match:!1,bucket:Number.POSITIVE_INFINITY,score:0};function Fs(e){return e.startsWith("/")?e.slice(1):e}function Ls(e,t){return e.bucket<t.bucket||e.bucket===t.bucket&&e.score>t.score}function yd(e,t){let n=xd;const s=Ut(e,Fs(t.fullCommand));s.match&&s.tier&&(n={match:!0,bucket:fn.name[s.tier],score:s.score});for(const o of t.aliases??[]){const a=Ut(e,Fs(o));if(!a.match||!a.tier)continue;const i={bucket:fn.alias[a.tier],score:a.score};Ls(i,n)&&(n={match:!0,...i,matchedAlias:o})}if(t.description){const o=Ut(e,t.description);if(o.match&&o.tier){const a={bucket:fn.description[o.tier],score:o.score};Ls(a,n)&&(n={match:!0,...a})}}return n}const Do="dorkos:mcp-app-consent:";function Po(e){return`${Do}${e}`}function bd(e){try{return localStorage.getItem(Po(e))==="granted"}catch{return!1}}function kd(e){try{localStorage.setItem(Po(e),"granted")}catch{}vd()}const _n=new Set;function vd(){for(const e of _n)e()}function Sd(e){_n.add(e);const t=n=>{var s;(s=n.key)!=null&&s.startsWith(Do)&&e()};return window.addEventListener("storage",t),()=>{_n.delete(e),window.removeEventListener("storage",t)}}function jd(e){const t=l.useSyncExternalStore(Sd,()=>bd(e),()=>!1),n=l.useCallback(()=>kd(e),[e]);return{consented:t,grant:n}}const wd="h-80";function Nd({sessionId:e,serverName:t,uri:n,title:s}){const{consented:o,grant:a}=jd(t),i=ie(d=>d.openPip),c=()=>{const d=ie.getState(),m={type:"mcp_app",serverName:t,uri:n,title:s};d.openCanvasDocument(m),Tn(d,"user",m)},u=()=>{i({kind:"mcp_app",sessionId:e,serverName:t,uri:n,title:s??`App · ${t}`})};return o?r.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"bg-muted/40 flex items-center justify-between border-b px-3 py-1.5",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[r.jsx(An,{className:"text-muted-foreground size-3.5 shrink-0"}),r.jsx("span",{className:"truncate",children:s??`App · ${t}`})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{type:"button",onClick:u,"aria-label":"Pop out into a floating window",title:"Pop out",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(ku,{className:"size-3.5"})}),r.jsx("button",{type:"button",onClick:c,title:"Open in canvas",className:"text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1 transition-colors",children:r.jsx(Fa,{className:"size-3.5"})})]})]}),r.jsx(bu,{sessionId:e,serverName:t,uri:n,title:s,onRequestFullscreen:c,onRequestPip:u,className:wd})]}):r.jsxs("div",{className:"bg-muted/40 flex flex-col gap-3 rounded-lg border p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx(An,{className:"text-muted-foreground size-4 shrink-0"}),r.jsxs("span",{children:["Interactive app from ",t]})]}),r.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[r.jsxs("p",{children:["It runs code from ",t," in a sealed-off frame."]}),r.jsx("p",{children:"It can’t see your chat, files or credentials."})]}),r.jsx("div",{children:r.jsx("button",{type:"button",onClick:a,className:"bg-foreground text-background hover:bg-foreground/90 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors",children:"Show app"})})]})}function Cd(e){return e.replace(/[-_]+/g," ").trim()}function Td({action:e}){const t=du(),n=Cd(e.actionId),s=`Widget interaction${e.title?`, ${e.title}`:""}: ${n}`;return r.jsxs(Q.span,{"data-testid":"ui-action-chip",title:e.payload?JSON.stringify(e.payload):void 0,className:H("ml-auto inline-flex w-fit items-center gap-2 rounded-full border py-1 pr-3 pl-1.5","bg-muted/40 shadow-soft text-xs"),initial:t?{opacity:0,y:4,scale:.9}:!1,animate:t?{opacity:1,y:0,scale:1}:!1,transition:t?mu:void 0,children:[r.jsx("span",{className:"sr-only",children:s}),r.jsx("span",{"aria-hidden":!0,className:"bg-primary/10 text-primary flex size-5 shrink-0 items-center justify-center rounded-full",children:r.jsx(Gu,{className:"size-3"})}),r.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground truncate",children:[e.title&&r.jsx("span",{className:"text-foreground font-medium",children:e.title}),e.title&&r.jsx("span",{className:"px-1 opacity-50",children:"·"}),r.jsx("span",{className:"text-foreground font-medium",children:n})]})]})}const Rd=/<ui_action>([\s\S]*?)<\/ui_action>/;function Us(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:null}catch{return null}}function Ed(e){const t=e.match(Rd);if(!t)return null;const n=t[1].split(`
|
|
32
|
+
`);let s=null,o=null,a=null,i=null;for(let c=0;c<n.length;c++){const u=n[c],d=u.match(/^\s*Widget:\s*(.*)$/);if(d){const f=d[1].trim();s=f&&f!=="(untitled)"?f:null;continue}const m=u.match(/^\s*Action:\s*(.*)$/);if(m){o=m[1].trim();continue}const h=u.match(/^\s*Widget ID:\s*(.*)$/);if(h){a=h[1].trim()||null;continue}const p=u.match(/^\s*Payload:\s*(.*)$/);if(p){const f=p[1].trim();if(f&&f!=="(none)")i=Us(f);else if(!f){let g="";for(let x=c+1;x<n.length;x++){g+=(g?`
|
|
33
|
+
`:"")+n[x];const y=Us(g.trim());if(y){i=y;break}}}break}}return o?{title:s,actionId:o,widgetId:a,payload:i}:null}function Ad({onAllow:e,onNotNow:t}){return r.jsxs(xc,{"data-slot":"notification-permission-primer",gap:"none",className:"flex-row flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2",children:[r.jsx(La,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0}),r.jsx("p",{className:"text-muted-foreground min-w-0 flex-1 text-xs",children:"Get notified when this needs you, even in another tab."}),r.jsxs("div",{className:"flex w-full shrink-0 flex-wrap items-center justify-end gap-1.5 sm:w-auto",children:[r.jsx(ue,{variant:"ghost",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:t,children:"Not now"}),r.jsx(ue,{variant:"outline",size:"sm",responsive:!1,className:"h-7 px-2 text-xs",onClick:e,children:"Turn on notifications"})]})]})}function _d(e){const t=cc(),{permission:n,request:s}=yc(),{prefs:o,setPrefs:a}=bc(),{data:i}=qn(),c=i!==void 0,[u,d]=l.useState(!1),m=Ua()||n==="unsupported";l.useEffect(()=>{if(m||!e)return;const g=setTimeout(uc,dc);return()=>clearTimeout(g)},[m,e]);const h=l.useCallback(()=>{d(!0),s().then(()=>{a({browserPermissionPrimerDismissed:!0})})},[s,a]),p=l.useCallback(()=>{d(!0),a({browserPermissionPrimerDismissed:!0})},[a]);return{eligible:!m&&c&&t&&!u&&n==="default"&&!o.browserPermissionPrimerDismissed,allow:h,notNow:p}}const Md="dorkos:chat:last-seen:";function Od(){try{const e=[];for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n!=null&&n.startsWith(Md)&&e.push(n)}for(const t of e)window.localStorage.removeItem(t)}catch{}}function Id(e){let t=0;for(const n of e)n._streaming!==!0&&t++;return t}function Dd(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:n,threadId:s,lastReadSeq:o}=e;return typeof t=="string"&&typeof n=="string"&&typeof s=="string"&&typeof o=="number"&&Number.isInteger(o)}function Pd(e,t,n=0){const s=be(),[o,a]=l.useState(()=>({sessionId:e,lastReadSeq:null,hydrated:!1}));o.sessionId!==e&&a({sessionId:e,lastReadSeq:null,hydrated:!1});const i=l.useRef(0),c=l.useRef(null),u=l.useRef(!1),d=l.useRef(!1),m=l.useRef(e),h=l.useRef(null),p=n+Id(t);l.useEffect(()=>{Od();let v=!1;return m.current=e,i.current=0,c.current=null,u.current=!1,d.current=!1,(async()=>{let j=null;try{j=await s.getReadCursor("session",e)}catch{}v||(j&&(i.current=j.lastReadSeq,h.current=j.userId),a({sessionId:e,lastReadSeq:(j==null?void 0:j.lastReadSeq)??null,hydrated:!0}))})(),()=>{v=!0}},[s,e]);const f=l.useCallback(async()=>{if(!u.current){u.current=!0;try{for(;;){const v=c.current;if(v===null)break;if(c.current=null,v.sessionId!==m.current)continue;if(d.current)break;const j=i.current;i.current=Math.max(j,v.seq);try{const S=await s.setReadCursor("session",v.sessionId,v.seq);h.current=S.userId??h.current}catch{i.current=j,v.sessionId===m.current&&(d.current=!0);break}}}finally{u.current=!1}}},[s]),g=l.useCallback(()=>{!o.hydrated||d.current||p<=i.current||(c.current={sessionId:e,seq:p},f())},[o.hydrated,e,p,f]);qa("read_cursor",v=>{if(!Dd(v)||v.threadKind!=="session"||v.threadId!==e)return;const j=h.current;j!==null&&v.userId!==j||v.lastReadSeq<=i.current||(i.current=v.lastReadSeq,a({sessionId:e,lastReadSeq:v.lastReadSeq,hydrated:!0}))});const x=l.useMemo(()=>t.filter(v=>v._streaming!==!0).map((v,j)=>({id:v.id,seq:n+j+1})),[t,n]),y=o.lastReadSeq,b=za(x,y===null?null:Math.min(y,p));return{lastSeenMessageId:b.lastSeenId,unreadFromStart:b.fromStart,markSeen:g,isHydrated:o.hydrated}}const $d="You",Fd="human",Ld="system",Ud="System",qd="agent",zd="Agent",Bd="chat-sender:",qs="room-author:",Wd="Room member",Hd="prompt-source:",Gd="runtime:";function Kd(e){return e.messageType==="local_command_output"||e.messageType==="compaction"}function Qd(e,t){var i,c,u,d,m,h;if(Kd(e)||e._chatStop)return{kind:"system",id:Ld,displayName:Ud};const n=e.role==="user"?(c=(i=e.chatMessages)==null?void 0:i[0])==null?void 0:c.from:void 0;if(n){const p=n.agentId??n.chatId,f=((u=t.senderAgent)==null?void 0:u.call(t,n))??lt({id:p});return{kind:"agent",id:`${Bd}${p}`,displayName:n.agentName,emoji:f.emoji,color:f.color}}const s=e.role==="user"?e.roomMessage:void 0;if(s&&!((d=s.author)!=null&&d.you))return Yd(s,t);const o=e.role==="user"?e.promptSource:void 0;if(o){const p=Vd(o);return{kind:o.kind==="channel"?"human":"system",id:`${Hd}${o.kind}:${o.label??""}`,displayName:p}}if(e.role==="user")return{kind:"human",id:Fd,displayName:((m=t.humanName)==null?void 0:m.trim())||$d,isSelf:!0};if(t.agent){const{id:p,displayName:f,emoji:g,color:x,imageUrl:y}=t.agent;return{kind:"agent",id:p,displayName:f,emoji:g,color:x,imageUrl:y}}const a=(h=t.runtime)==null?void 0:h.trim();return a?{kind:"agent",id:`${Gd}${a}`,displayName:zn(a),runtime:a}:{kind:"agent",id:qd,displayName:zd}}function Vd(e){switch(e.kind){case"heartbeat":return"Heartbeat";case"schedule":return e.label?`Schedule: ${e.label}`:"Schedule";case"agent":return e.label??"Another agent";case"channel":return e.label??"Connection";case"external":return e.label??"Outside DorkOS"}}function Yd(e,t){var o;const{author:n}=e;if(!n)return{kind:"human",id:`${qs}entry:${e.entryId}`,displayName:Wd};const s=`${qs}${n.id}`;if(n.kind==="agent"){const a=n.agentId??n.id,i=((o=t.senderAgent)==null?void 0:o.call(t,{agentId:a,chatId:a}))??lt({id:a,...n.emoji?{icon:n.emoji}:{},...n.color?{color:n.color}:{}});return{kind:"agent",id:s,displayName:n.displayName,...i}}return{kind:n.kind,id:s,displayName:n.displayName}}function $o(e){return`msg-${e}`}function Xd(){return{last:null}}function Jd(e,t){const{resolveAuthor:n,now:s,cache:o}=t,a=t.lastSeenMessageId??null,i=t.unreadFromStart??!1,c=o==null?void 0:o.last,u=c&&c.resolveAuthor===n&&c.now===s&&c.lastSeenMessageId===a&&c.unreadFromStart===i?c:null;let d=0;if(u){const y=Math.min(e.length,u.messages.length);for(;d<y&&e[d]===u.messages[d];)d++}const m=u?u.authors.slice(0,d):[],h=u?u.items.slice(0,d):[];for(let y=m.length;y<e.length;y++){const b=e[y],v=n(b,y);m.push(v),h.push({id:b.id,authorId:v.id,timestamp:b.timestamp})}const p={now:s,lastSeenId:a,unreadFromStart:i},{rows:f,kept:g}=u?Ba(h,p,u.timeline,d):{rows:Wa(h,p),kept:0},x=u?u.rows.slice(0,g):[];for(let y=g;y<f.length;y++){const b=f[y];x.push(b.kind!=="item"?b:{kind:"message",key:$o(e[b.index].id),messageIndex:b.index,message:e[b.index],grouping:b.grouping,author:m[b.index]})}return o&&(o.last={messages:e,authors:m,items:h,resolveAuthor:n,now:s,lastSeenMessageId:a,unreadFromStart:i,timeline:f,rows:x}),x}function Zd(e){const t=[],n=new Set;for(const s of e){const o=s.lastIndexOf("/"),a=o>=0?s.slice(0,o+1):"",i=o>=0?s.slice(o+1):s;t.push({path:s,filename:i,directory:a,isDirectory:!1});const c=s.split("/");for(let u=1;u<c.length;u++){const d=c.slice(0,u).join("/")+"/";n.has(d)||(n.add(d),t.push({path:d,filename:c[u-1]+"/",directory:u>1?c.slice(0,u-1).join("/")+"/":"",isDirectory:!0}))}}return t}function em(e,t){const n=[...e].reverse().find(s=>s.role==="user");if(n!=null&&n.content)return n.content;if((t==null?void 0:t.kind)==="first-message"&&t.kickoffMessage)return t.kickoffMessage}const Fo=Symbol("no-error-part");function tm(e){for(let t=e.length-1;t>=0;t--){const n=e[t].parts;for(let s=n.length-1;s>=0;s--){const o=n[s];if(o.type==="error")return o.category}}return Fo}function nm(e){const{messages:t,status:n,lastErrorCategory:s,queuedCount:o,draft:a}=e;if(a.trim().length>0||n==="streaming"||o>0)return null;let i=-1;for(let d=t.length-1;d>=0;d--)if(t[d].role==="user"){i=d;break}const c=i===-1?"":t[i].content.trim();if(!c)return null;const u=tm(t.slice(i+1));return u!==Fo?u==="auth_error"?c:null:n==="error"&&s==="auth_error"?c:null}const sm="dorkos:signin-resume",rm=1e4;function om(){const e=l.useRef(new Map),t=l.useRef(null);return l.useEffect(()=>{const n=Ha(sm);t.current=n;const s=e.current,o=n.onMessage(a=>{s.set(a.sessionId,Date.now())});return()=>{o(),n.close(),t.current=null}},[]),l.useMemo(()=>({claimedElsewhere:n=>{const s=e.current.get(n);return s!==void 0&&Date.now()-s<rm},claim:n=>{var s;return(s=t.current)==null?void 0:s.postMessage({sessionId:n})}}),[])}function Lo(e){switch(e){case"pending":case"running":return r.jsx(Ue,{size:"xs",className:At({status:e})});case"complete":return r.jsx(Qt,{className:H("size-(--size-icon-xs)",At({status:e}))});case"error":return r.jsx(ot,{className:H("size-(--size-icon-xs)",At({status:e}))});case"neutral":return r.jsx(Ga,{className:H("size-(--size-icon-xs)",At({status:e}))})}}function zs({type:e,toolName:t,toolInput:n,...s}){const o=e==="approval"?"Waiting for approval":"Answering questions",a=t?kt(t,n??""):null,i=a?`${o} · ${a}`:`${o}…`;return r.jsx("div",{className:"bg-muted/50 rounded-msg-tool text-muted-foreground shadow-msg-tool border px-3 py-1 text-sm transition-colors duration-150",...s,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ue,{className:"shrink-0"}),r.jsx("span",{className:"truncate text-xs",children:i})]})})}function Ct({expanded:e,onToggle:t,header:n,children:s,variant:o="default",dimmed:a=!1,disabled:i=!1,hideChevron:c=!1,extraContent:u,ariaLabel:d,className:m,...h}){const p=c?void 0:e;return r.jsxs("div",{className:H("bg-muted/40 mt-px rounded-md border-l-2 text-sm transition-[opacity,background-color,border-color,box-shadow] duration-200 first:mt-1","hover:bg-muted/60 hover:border-l-muted-foreground/60 hover:shadow-soft",o==="default"&&"border-l-muted-foreground/30",o==="thinking"&&"border-l-muted-foreground/20",o==="memory"&&"border-l-muted-foreground/20",a&&!e&&"opacity-50 hover:opacity-100",m),...h,children:[r.jsxs("button",{onClick:()=>!i&&t(),disabled:i,className:H("focus-ring flex w-full items-center gap-2 rounded-md px-3 py-1",i&&"cursor-default"),"aria-expanded":p,"aria-label":d,children:[n,!c&&!i&&r.jsx(Q.div,{animate:{rotate:e?180:0},transition:{type:"spring",stiffness:400,damping:30},className:"ml-auto",children:r.jsx(vt,{className:"text-muted-foreground size-(--size-icon-xs)"})})]}),u,r.jsx(me,{initial:!1,children:e&&r.jsx(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"overflow-hidden",children:r.jsx("div",{className:"border-border/50 border-t px-3 pt-1 pb-3",children:s})})})]})}const am=[0,.2,.4];function Uo({className:e}){return r.jsx("div",{className:H("flex gap-1",e),"data-testid":"typing-dots","aria-hidden":"true",children:am.map(t=>r.jsx("span",{className:"bg-muted-foreground h-2 w-2 rounded-full",style:{animation:"typing-dot 1.4s ease-in-out infinite",animationDelay:`${t}s`}},t))})}function im({record:e}){const t=Le(),{color:n,emoji:s}=lt({id:e.agentId,icon:e.icon,color:e.color}),o=e.displayName.trim()||"Your agent";return r.jsxs("div",{className:"flex flex-col items-center gap-5 text-center","data-testid":"first-light",children:[r.jsx(Q.div,{animate:t?void 0:{scale:[1,1.05,1],opacity:[.9,1,.9]},transition:t?void 0:{duration:3,repeat:1/0,ease:"easeInOut"},children:r.jsx(Bn,{color:n,emoji:s,size:"lg"})}),r.jsxs("div",{className:"flex flex-col items-center gap-3",children:[r.jsxs("p",{className:"text-muted-foreground text-base","aria-live":"polite",children:[o," is waking up…"]}),r.jsx(Uo,{})]})]})}function lm({birthRecord:e,firstLightRecord:t}){return(e==null?void 0:e.greetingFailed)===!0?r.jsxs("div",{className:"text-center","data-testid":"greeting-failed-empty",children:[r.jsxs("p",{className:"text-muted-foreground text-base",children:[e.displayName," couldn’t say hello just now"]}),r.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Send a message to get started."})]}):t?r.jsx(im,{record:t}):r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-muted-foreground text-base",children:"Start a chat"}),r.jsx("p",{className:"text-muted-foreground/60 mt-2 text-sm",children:"Type a message below to begin."})]})}function cm(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function um({sessionId:e}){const t=Vt(e),n=Le();if(!t||t.kind==="first-message")return null;const s=cm(t.bornAt),o=St(t.runtime).label;return r.jsxs(Q.div,{initial:n?!1:{opacity:0,y:-4},animate:{opacity:1,y:0},transition:{duration:.3},"data-testid":"birth-certificate",className:"text-muted-foreground flex items-center justify-center gap-1.5 px-4 pt-3 pb-1 text-xs",children:[r.jsx(Ka,{className:"text-primary size-3.5 shrink-0 fill-current","aria-hidden":"true"}),r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx("span",{className:"text-foreground font-medium",children:t.displayName}),s&&r.jsxs(r.Fragment,{children:[r.jsx(pn,{}),r.jsxs("span",{children:["born ",s]})]}),r.jsx(pn,{}),r.jsxs("span",{className:"min-w-0 truncate",children:["lives in ",r.jsx("code",{className:"text-2xs",children:t.path})]}),r.jsx(pn,{}),r.jsxs("span",{className:"shrink-0",children:["runs on ",o]})]})]})}function pn(){return r.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground/50 shrink-0",children:"·"})}const dm="another chat";function mm(e,t){const n=t==null?void 0:t.find(s=>s.id===e);return n?Qa(n)?vs("autonomy"):n.label:Or(e)?vs("autonomy"):Va(e)}function fm({startedBy:e,modes:t}){var a;const n=Qe();if(!e)return null;const s=((a=e.reason)==null?void 0:a.trim())||null,o=e.kind==="chat"?e.permission:null;return r.jsxs(r.Fragment,{children:[r.jsx(pm,{startedBy:e,reason:s,navigate:n}),o&&r.jsxs("p",{"data-testid":"started-level-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pb-1 text-center text-xs",children:["Started at ",mm(o.mode,t),","," ",o.sameAsStarter?"same as":"lower than"," the chat that started it."]})]})}function pm({startedBy:e,reason:t,navigate:n}){return r.jsxs("p",{"data-testid":"started-by-line",className:"text-muted-foreground mx-auto max-w-prose px-4 pt-3 pb-1 text-center text-xs",children:[e.kind==="extension"?r.jsxs(r.Fragment,{children:["Started by the"," ",r.jsx("span",{className:"text-foreground font-medium",children:e.extensionName})," extension"]}):r.jsxs(r.Fragment,{children:["Started from"," ",r.jsx("button",{type:"button",onClick:()=>void n(ct({session:e.sessionId})),className:"text-foreground focus-visible:ring-ring rounded-sm font-medium underline-offset-2 hover:underline focus-visible:ring-2 focus-visible:outline-none",children:e.title??dm})]}),t&&r.jsxs(r.Fragment,{children:[": ",t]})]})}function hm({content:e}){const[t,n]=l.useState(!1);return r.jsxs("div",{"data-testid":"started-prompt",className:"px-4 py-1",children:[r.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring mx-auto flex items-center gap-1 rounded-sm text-xs focus-visible:ring-2 focus-visible:outline-none",children:["What it was asked",r.jsx(Bt,{"aria-hidden":"true",className:H("size-3 transition-transform duration-200",t&&"rotate-90")})]}),t&&r.jsx("div",{className:"bg-muted/40 text-foreground mx-auto mt-2 max-w-prose rounded-md px-3 py-2 text-sm break-words whitespace-pre-wrap",children:e})]})}function Mn(e){if(e)try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}catch{return}}function fe(e,t){const n=e==null?void 0:e[t];return typeof n=="string"&&n.length>0?n:void 0}function gm(e){const t=Mn(e);if(t){if(Array.isArray(t.content))for(const n of t.content){const s=typeof(n==null?void 0:n.text)=="string"?Mn(n.text):void 0;if(s)return s}return t}}function qo(e){const t=Ya(e.toolName);if(t!=="chat_send"&&t!=="session_start"&&t!=="chat_stop")return null;const n=Mn(e.input),s=gm(e.result),o=xm(e,s),a=o===void 0&&(s==null?void 0:s.status)==="approval_required",i=fe(n,"delivery");return{tool:t,...fe(n,t==="chat_stop"?"chat":"to")!==void 0?{to:fe(n,t==="chat_stop"?"chat":"to")}:{},...fe(n,t==="session_start"?"prompt":"message")!==void 0?{message:fe(n,t==="session_start"?"prompt":"message")}:{},...fe(n,"summary")!==void 0?{summary:fe(n,"summary")}:{},...i==="queue"||i==="steer"||i==="interrupt"?{delivery:i}:{},...fe(n,"reason")!==void 0?{reason:fe(n,"reason")}:{},...fe(s,"messageId")!==void 0?{messageId:fe(s,"messageId")}:{},...(fe(s,"chatId")??fe(s,"sessionId"))!==void 0?{chatId:fe(s,"chatId")??fe(s,"sessionId")}:{},...o!==void 0?{error:o}:{},...a?{waiting:a}:{},...t==="chat_stop"&&o===void 0&&(s==null?void 0:s.stopped)===!1?{notRunning:!0}:{},...fe(s,"note")!==void 0?{note:fe(s,"note")}:{}}}const Ot="It could not be sent.";function xm(e,t){var n;if((t==null?void 0:t.status)==="denied")return fe(t,"message")??Ot;if((t==null?void 0:t.ok)===!1||typeof(t==null?void 0:t.error)=="string")return fe(t,"error")??fe(t,"message")??Ot;if(e.status==="error")return t?fe(t,"error")??fe(t,"message")??Ot:((n=e.result)==null?void 0:n.trim())||Ot}function ym(e,t=60){const n=e.trim().split(new RegExp("(?<=[.!?])\\s"))[0]??"";if(n.length<=t)return n;const s=n.slice(0,t),o=s.lastIndexOf(" ");return`${(o>t/2?s.slice(0,o):s).replace(/[\s,;:.]+$/,"")}…`}function bm(e,t){if(e){for(let n=t.length-1;n>=0;n--)if(t[n].to.chatId===e)return t[n].to}}function km(e,t){if(e.messageId)return t.find(n=>n.id===e.messageId);if(e.tool==="session_start"&&e.chatId)return t.find(n=>n.kind==="start"&&n.to.chatId===e.chatId)}function vm(e,t){if(e&&e.trim())return e.trim();const s=((t??"").split(`
|
|
34
|
+
`).find(o=>o.trim()!=="")??"").replace(/^#+\s*/,"").trim();return s.length>72?`${s.slice(0,71)}…`:s}function Sm(e,t){if(t.error)return{label:"Failed",tone:"error"};if(t.waiting)return{label:"Waiting for approval",tone:"muted"};if(!e)return{label:t.pending?"Sending":"Sent",tone:"muted"};switch(e.status){case"queued":return{label:e.position?`Queued · #${e.position}`:"Queued",tone:"muted"};case"steered":return{label:"Steered in",tone:"done"};case"working":return{label:e.delivery==="interrupt"?"Interrupted, working":"Working",tone:"active"};case"delivered":return{label:e.delivery==="interrupt"?"Interrupted, then delivered":"Delivered",tone:"done"};case"replied":return{label:"Replied",tone:"done"};case"failed":return{label:"Failed",tone:"error"};default:return{label:"Sent",tone:"muted"}}}function jm(e){const t=[];return e.kind==="report"&&t.push("Report"),e.kind==="start"&&t.push("Started this chat"),e.delivery==="steer"&&t.push("Steered in"),e.delivery==="interrupt"&&t.push("Interrupted"),t}function zo(e,t){var n,s;for(const o of e){if((n=o.chatMessages)!=null&&n.some(i=>i.id===t))return o.id;const a=[...o.toolCalls??[],...(o.parts??[]).filter(i=>i.type==="tool_call")];for(const i of a)if(((s=qo(i))==null?void 0:s.messageId)===t)return o.id}}const Bs=new WeakMap;function wm(e,t){if(t.length===0)return e;const n=[];let s=0;const o=a=>{let i=Bs.get(a);return i||(i={id:`chat-stop-${a.id}`,role:"user",content:"",parts:[],timestamp:a.at,_chatStop:a},Bs.set(a,i)),i};for(const a of e){const i=a.timestamp==="",c=i?Number.NaN:Date.parse(a.timestamp),u=d=>i||!Number.isNaN(c)&&Date.parse(d.at)<c;for(;s<t.length&&u(t[s]);)n.push(o(t[s])),s+=1;n.push(a)}for(;s<t.length;)n.push(o(t[s])),s+=1;return n}function Nm({stamp:e}){const t=jm(e);return t.length===0?null:r.jsx(r.Fragment,{children:t.map(n=>r.jsx("span",{"data-testid":"chat-message-tag",className:"bg-muted text-muted-foreground text-2xs rounded px-1.5 py-px leading-4 font-medium",children:n},n))})}function Bo({stamp:e}){const t=Qe(),n=e.from.chatTitle??"another chat";return r.jsxs("span",{"data-testid":"chat-from-mark",className:"inline-flex min-w-0 flex-wrap items-center gap-1.5 text-xs",children:[r.jsxs("span",{className:"text-muted-foreground inline-flex min-w-0 items-center gap-1",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"from"}),r.jsx("button",{type:"button",onClick:()=>void t(ct({session:e.from.chatId,message:e.id})),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]}),r.jsx(Nm,{stamp:e})]})}function Cm({sessionId:e,messageId:t}){const n=Qe();return r.jsxs("button",{type:"button","data-testid":"chat-reply-to",onClick:()=>void n(ct({session:e,message:t})),className:"focus-ring text-muted-foreground hover:text-foreground focus-visible:text-foreground mb-1 inline-flex items-center gap-1 text-xs underline-offset-4 hover:underline",children:[r.jsx(zu,{"aria-hidden":!0,className:"size-3"}),"Reply to your message"]})}function Tm({stamps:e,sessionId:t}){return r.jsx("div",{className:"space-y-2","data-testid":"received-chat-messages",children:e.map((n,s)=>r.jsxs("div",{"data-testid":"received-chat-message","data-kind":n.kind,className:"border-status-info-border bg-status-info-bg rounded-r-md border-l-2 py-1.5 pr-2 pl-3",children:[n.replyToId&&t&&r.jsx(Cm,{sessionId:t,messageId:n.replyToId}),s>0&&r.jsxs("div",{className:"text-muted-foreground mb-1 flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx("span",{className:"text-foreground/80 font-medium",children:n.from.agentName}),r.jsx(Bo,{stamp:n})]}),r.jsx("div",{className:"msg-prose",children:r.jsx(es,{content:n.text,isStreaming:!1,...t?{sessionId:t}:{}})})]},n.id))})}function Rm({stamp:e}){const t=Qe(),n=e.roomLabel??"a room";return r.jsxs("span",{"data-testid":"room-post-mark",className:"text-muted-foreground inline-flex min-w-0 items-center gap-1 text-xs",children:[r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{children:"in"}),r.jsx("button",{type:"button","aria-label":`Open ${n}`,onClick:()=>void t({...Xa.channels(),search:{id:e.roomId}}),className:"focus-ring text-foreground/80 hover:text-foreground max-w-48 truncate underline-offset-4 hover:underline",children:n})]})}const Em={muted:"text-muted-foreground",active:"text-foreground",done:"text-muted-foreground",error:"text-destructive"};function Am(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _m(e,t,n){if(e.error)return e.error;if(e.waiting)return"Waiting for a person to approve it.";if(e.tool==="chat_stop")return e.note??(e.notRunning?"Nothing was running there.":"Asked it to stop.");if(!t)return e.note??"Sent.";const s=Am(n);switch(t.status){case"queued":return t.position?`Waiting for ${n} to finish its turn. Number ${t.position} in line.`:`Waiting for ${n} to finish its turn.`;case"steered":return`Joined ${n}’s running turn.`;case"working":return t.delivery==="interrupt"?`Stopped ${n}’s turn. ${s} is on this now.`:`${s} is working on it.`;case"delivered":return`${s} read it and finished its turn.`;case"replied":return`${s} replied.`;case"failed":return t.failureReason??"It was not delivered.";default:return"Sent."}}function Mm(e,t){return e.error?{label:"Failed",tone:"error"}:e.waiting?{label:"Waiting for approval",tone:"muted"}:t?{label:"Stopping",tone:"muted"}:e.notRunning?{label:"Not running",tone:"muted"}:{label:"Stopped",tone:"done"}}function Om({part:e,sent:t,at:n,sessionId:s}){const[o,a]=l.useState(!1),i=l.useId(),c=Qe(),u=qo(e);if(!u)return null;const d=e.status==="pending"||e.status==="running",m=km(u,t),h=(m==null?void 0:m.to.chatId)??u.chatId??(u.tool==="chat_stop"?u.to:void 0),p=(m==null?void 0:m.to)??bm(h,t),f=(p==null?void 0:p.agentName)??"the agent",g=p==null?void 0:p.chatTitle,x=lt({id:(p==null?void 0:p.agentId)??u.to??h??"chat"}),y=u.tool==="chat_stop"?Mm(u,d):Sm(m,{...u,pending:d}),b=vm((m==null?void 0:m.summary)??u.summary,(m==null?void 0:m.text)??u.message),v=n?Gt(n):m?Gt(m.sentAt):"",j=u.error??((m==null?void 0:m.status)==="failed"?m.failureReason:void 0),S=j?ym(j):u.tool==="chat_stop"?u.reason:b!==g?b:"",T=u.tool==="session_start"?Hu:u.tool==="chat_stop"?Ir:Ja,R=u.tool==="session_start"?"Started spin-off chat":u.tool==="chat_stop"?u.error||u.notRunning?"Tried to stop":"Stopped":"To",E=u.tool==="session_start"?g??(b||"a new chat"):u.tool==="chat_stop"?g??"a chat":(p==null?void 0:p.agentName)??g??"a chat",O=()=>{h&&c(ct({session:h,...m?{message:m.id}:{}}))};return r.jsxs("div",{"data-testid":"sent-chat-card","data-tool":u.tool,"data-state":y.label,className:"border-border/70 bg-background my-1.5 rounded-lg border text-sm",children:[r.jsxs("button",{type:"button",onClick:()=>a(A=>!A),"aria-expanded":o,...o?{"aria-controls":i}:{},className:"focus-ring hover:bg-muted/40 flex w-full min-w-0 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors duration-150",children:[r.jsx(Bn,{size:"xs",emoji:x.emoji,color:x.color}),r.jsx(T,{"aria-hidden":!0,className:"text-muted-foreground hidden size-3.5 shrink-0 sm:block"}),r.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.jsxs("span",{className:"text-muted-foreground",children:[R," "]}),r.jsx("span",{className:"font-medium",children:E}),u.tool==="chat_send"&&g&&(p==null?void 0:p.agentName)&&r.jsxs("span",{className:"text-muted-foreground",children:[" · ",g]}),S&&(u.tool!=="session_start"||j)&&r.jsxs("span",{"data-testid":"sent-chat-aside",className:H("text-muted-foreground",!j&&"hidden sm:inline"),children:[" ","· ",S]})]}),r.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[r.jsx("span",{className:H("text-xs",Em[y.tone]),"data-testid":"sent-chat-state",children:y.label}),v&&r.jsx("time",{className:"text-muted-foreground hidden text-xs tabular-nums sm:inline",children:v}),r.jsx(vt,{"aria-hidden":!0,className:H("text-muted-foreground size-3.5 transition-transform duration-200",o&&"rotate-180")})]})]}),o&&r.jsxs("div",{id:i,className:"border-border/60 space-y-2 border-t px-3 py-2",children:[((m==null?void 0:m.text)??u.message??u.reason)&&r.jsx("div",{className:"msg-prose",children:r.jsx(es,{content:(m==null?void 0:m.text)??u.message??u.reason??"",isStreaming:!1,...s?{sessionId:s}:{}})}),r.jsxs("p",{className:"text-muted-foreground text-xs",children:[_m(u,m,f),u.note&&u.tool!=="chat_stop"&&m?` ${u.note}`:""]}),h&&!u.error&&!u.waiting&&r.jsx("button",{type:"button",onClick:O,className:"focus-ring text-foreground text-xs font-medium underline-offset-4 hover:underline",children:"Open chat →"})]})]})}function Im({notice:e}){const t=Qe();return r.jsxs("div",{"data-testid":"chat-stop-line",className:"text-muted-foreground flex flex-wrap items-center gap-1.5 text-xs",children:[r.jsx(Ir,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),r.jsxs("span",{children:["Stopped by ",r.jsx("span",{className:"text-foreground/80 font-medium",children:e.by.agentName})," · ",r.jsx("button",{type:"button",onClick:()=>void t(ct({session:e.by.chatId})),className:"focus-ring hover:text-foreground underline-offset-4 hover:underline",children:e.by.chatTitle??"another chat"}),e.reason?`: ${e.reason}`:""]})]})}function ns(e){const t=[],n=[];for(const s of e)s.type==="text"?t.push(s.text):s.type==="tool_call"&&n.push({toolCallId:s.toolCallId,toolName:s.toolName,input:s.input||"",result:s.result,progressOutput:s.progressOutput,status:s.status,interactiveType:s.interactiveType,questions:s.questions,answers:s.answers,timeoutMs:s.timeoutMs,hooks:s.hooks,startedAt:s.startedAt,completedAt:s.completedAt,approvalStartedAt:s.approvalStartedAt,approvalRemainingMs:s.approvalRemainingMs,approvalParked:s.approvalParked,approvalTitle:s.approvalTitle,approvalDisplayName:s.approvalDisplayName,approvalDescription:s.approvalDescription,approvalBlockedPath:s.approvalBlockedPath,approvalDecisionReason:s.approvalDecisionReason,approvalHasSuggestions:s.approvalHasSuggestions,approvalAlwaysAllowScope:s.approvalAlwaysAllowScope});return{content:t.join(`
|
|
35
|
+
`),toolCalls:n}}const Ws=new WeakMap;function Dm(e){let t=Ws.get(e);return t||(t=e.map(nt),Ws.set(e,t)),t}function nt(e){const t=e.parts?[...e.parts]:[];if(t.length===0&&(e.content&&t.push({type:"text",text:e.content}),e.toolCalls))for(const s of e.toolCalls)t.push({type:"tool_call",toolCallId:s.toolCallId,toolName:s.toolName,input:s.input,result:s.result,status:s.status,...s.questions||s.questionOutcome?{interactiveType:"question",questions:s.questions,answers:s.answers,questionOutcome:s.questionOutcome}:{},...s.approvalOutcome?{interactiveType:"approval",approvalOutcome:s.approvalOutcome,approvalResolvedAt:s.approvalResolvedAt,approvalStartedAt:s.approvalStartedAt,approvalReasonGiven:s.approvalReasonGiven}:{}});const n=ns(t);return{id:e.id,role:e.role,content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:void 0,parts:t,timestamp:e.timestamp||"",messageType:e.messageType,compactMetadata:e.compactMetadata,commandName:e.commandName,commandArgs:e.commandArgs,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{},...e.roomMessage?{roomMessage:e.roomMessage}:{},...e.promptSource?{promptSource:e.promptSource}:{}}}function Pm(e,t,n){const s=new Set(e.map(d=>d.id)),o=e.filter(d=>d._streaming),a=o.find(d=>d.role==="user"),i=o.find(d=>d.role==="assistant"),c=[];let u=-1;for(let d=0;d<t.length;d++){const m=t[d];if(!s.has(m.id)){if(a&&m.role==="user"&&m.content===a.content){u=d,n(h=>h.map(p=>p.id===a.id?{...nt(m),_streaming:!1}:p));continue}if(i&&u>=0&&d===u+1&&m.role==="assistant"){const h=nt(m),p=new Set(h.parts.filter(x=>x.type==="background_task").map(x=>x.taskId)),f=i.parts.filter(x=>x.type==="background_task"&&!p.has(x.taskId)),g=f.length>0?[...h.parts,...f]:h.parts;n(x=>x.map(y=>y.id===i.id?{...h,parts:g,_streaming:!1}:y));continue}c.push(m)}}c.length>0&&n(d=>[...d,...c.map(nt)])}const $m=20;function Fm(e,t){var b;const n=be(),s=Za(e),o=Fe(v=>v.seeks[e]),[a,i]=l.useState(null),c=l.useRef(null),u=a===e,d=l.useRef({key:"",count:0}),m=s.windowStartId!==null&&((b=t[0])==null?void 0:b.id)===s.windowStartId,h=l.useMemo(()=>m?s.earlier.map(nt):[],[m,s.earlier]),p=l.useMemo(()=>h.length>0?[...h,...t]:t,[h,t]),f=m&&s.remaining>0,g=m?s.remaining:0,x=l.useCallback(()=>{var S;if(c.current===e||!f)return;const{generation:v}=s,j=((S=s.earlier[0])==null?void 0:S.id)??s.windowStartId;j&&(c.current=e,i(e),n.getMessages(e,void 0,{before:j}).then(T=>{Fe.getState().prependPage(e,v,T.messages,T.earlierMessages??0)}).catch(T=>{console.warn("[chat] could not read earlier messages",T),Fe.getState().endSeek(e)}).finally(()=>{c.current===e&&(c.current=null,i(null))}))},[f,e,n,s]),y=o!==void 0&&(p.some(v=>v.id===o)||zo([...s.earlier,...Ce.getState().getSession(e).messages],o)!==void 0);return l.useEffect(()=>{if(o===void 0){d.current={key:"",count:0};return}const v=`${e}:${o}`;if(d.current.key!==v&&(d.current={key:v,count:0}),!(s.generation===0||u)){if(y||!f||d.current.count>=$m){Fe.getState().endSeek(e);return}d.current.count+=1,x()}},[o,y,f,u,x,e,s.generation]),{messages:p,earlierCount:h.length,messagesBefore:g,canLoadEarlier:f,isLoadingEarlier:u,isSeeking:o!==void 0,loadEarlier:x}}function Lm({celebration:e,onComplete:t}){const n=l.useRef(null),s=(e==null?void 0:e.level)==="major",o=l.useCallback(()=>{t()},[t]);return l.useEffect(()=>{if(!s)return;let a=!1;ei({kind:"burst"}).then(c=>{if(a){c();return}n.current=c});const i=setTimeout(()=>{o()},Yt.CELEBRATION_DISPLAY_MS);return()=>{var c;a=!0,(c=n.current)==null||c.call(n),n.current=null,clearTimeout(i)}},[s,o]),r.jsx(me,{children:s&&r.jsx(Q.div,{"aria-hidden":"true",className:"pointer-events-none fixed inset-0 z-50",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.1},transition:{duration:.6,ease:"easeOut"},style:Zu})})}function Um(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function qm({text:e,isStreaming:t,elapsedMs:n}){const[s,o]=l.useState(t),a=l.useRef(t),i=l.useRef(null);l.useEffect(()=>{a.current&&!t&&o(!1),a.current=t},[t]),l.useEffect(()=>{t&&s&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t,s]);const c=n?`Thought for ${Um(n)}`:"Thinking…";return r.jsx(Ct,{expanded:s,onToggle:()=>o(!s),variant:"thinking",dimmed:!t,disabled:t,ariaLabel:c,"data-testid":"thinking-block","data-streaming":t?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(qu,{className:H("text-muted-foreground size-(--size-icon-xs)",t&&"animate-breath")}),r.jsx("span",{className:H("text-3xs text-muted-foreground font-mono",t&&"animate-breath"),children:c})]}),children:r.jsx("div",{ref:i,className:"max-h-32 overflow-y-auto",children:r.jsx("pre",{className:"text-muted-foreground text-xs break-words whitespace-pre-wrap",children:e})})})}function zm({mode:e,memories:t,isStreaming:n}){const[s,o]=l.useState(n),a=l.useRef(n);if(l.useEffect(()=>{a.current&&!n&&o(!1),a.current=n},[n]),t.length===0)return null;const i=t.length,c=n?i<=1?"Consulting memory…":`Consulting ${i} memories…`:i===1?"Recalled 1 memory":`Recalled ${i} memories`,u=e==="synthesize"?ti:ni,d=e==="synthesize"?"sparkles":"bookopen";return r.jsx(Ct,{expanded:s,onToggle:()=>o(!s),variant:"memory",dimmed:!n,disabled:n,ariaLabel:c,"data-testid":"memory-recall-block","data-streaming":n?"true":void 0,header:r.jsxs(r.Fragment,{children:[r.jsx(u,{"aria-hidden":"true","data-testid":"memory-recall-header-icon","data-icon":d,className:H("text-muted-foreground size-(--size-icon-xs)",n&&"animate-breath")}),r.jsx("span",{className:H("text-3xs text-muted-foreground font-mono",n&&"animate-breath"),children:c})]}),children:r.jsx(Bm,{memories:t})})}function Bm({memories:e}){return r.jsx("ul",{className:"flex flex-col gap-1 px-3 py-2",children:e.map(t=>r.jsx(Wm,{memory:t},t.path))})}function Wm({memory:e}){const t=e.path.startsWith("<synthesis:"),n=e.scope==="team"?si:ri,s=e.scope==="team"?"team":"personal",{copy:o}=oi({toastOnSettle:!0}),a=()=>{const i=t&&e.content?e.content:e.path;o(i)};if(t&&e.content){const i=e.path.replace(/^<synthesis:/,"synthesis:").replace(/>$/,"");return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:a,"aria-label":`Copy synthesized ${s} memory content`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full flex-col items-start gap-1 rounded-md px-2 py-1 text-left transition-colors duration-150",children:[r.jsx("span",{className:"text-sm",children:e.content}),r.jsxs("span",{className:"text-3xs text-muted-foreground flex items-center gap-1 font-mono",children:[r.jsx(n,{"aria-hidden":"true",className:"size-(--size-icon-xs)"}),i]})]})})}return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:a,"aria-label":`Copy ${s} memory path ${e.path}`,"data-scope":e.scope,className:"focus-ring hover:bg-muted/50 flex min-h-[44px] w-full items-center gap-2 rounded-md px-2 py-1 text-left transition-colors duration-150",children:[r.jsx("span",{className:"flex-1 truncate font-mono text-sm",children:ed(e.path,40)}),r.jsx(n,{"aria-hidden":"true",className:"text-muted-foreground size-(--size-icon-xs)"})]})})}function zt(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Wo(e){return e===void 0?"Summarized (asked by the agent)":`Summarized at ${e}% (asked by the agent)`}function Hm(e){if((e==null?void 0:e.requestedBy)==="agent")return Wo(e.contextPercent);const t=["Context compacted"];return(e==null?void 0:e.preTokens)!==void 0&&t.push(`${zt(e.preTokens)} tokens`),e!=null&&e.trigger&&t.push(e.trigger),t.join(" · ")}function Gm(e,t){return e===void 0?"Compacted context":t===void 0?`Compacted context · ${zt(e)} tokens summarized`:`Compacted context · ${zt(e)} → ${zt(t)} tokens`}function Km({trigger:e,preTokens:t,postTokens:n,failed:s,error:o,requestedBy:a,contextPercent:i}){return s?r.jsx(tt,{"data-testid":"compact-boundary-row","data-failed":"true",icon:r.jsx(Wn,{"aria-hidden":"true",className:"text-status-warning-dot size-3 shrink-0"}),label:r.jsx("span",{className:"text-status-warning-fg",children:a==="agent"?"Couldn’t compact (asked by the agent)":"Couldn’t compact"}),children:o?r.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:o}):null}):a==="agent"?r.jsx(tt,{"data-testid":"compact-boundary-row","data-requested-by":"agent",icon:r.jsx(Ss,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:Wo(i)})}):r.jsx(tt,{"data-testid":"compact-boundary-row",icon:r.jsx(Ss,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:Gm(t,n)}),trailing:e?r.jsx("span",{"data-testid":"compact-boundary-trigger",className:"text-3xs text-muted-foreground/70 ml-auto font-mono uppercase",children:e}):void 0})}function Qm({part:e}){const[t,n]=l.useState(!1);return t?r.jsxs("div",{"data-testid":"message-image-missing",className:H("my-3 flex items-center gap-2 rounded-md border px-3 py-2","text-muted-foreground border-border/60 bg-muted/30 text-sm"),children:[r.jsx(Iu,{"aria-hidden":"true",className:"size-4 shrink-0"}),r.jsx("span",{children:e.alt?`${e.alt}, not available`:"This image is not available."})]}):r.jsx("figure",{className:"my-3","data-testid":"message-image",children:r.jsx(Dr,{image:{src:e.url,alt:e.alt??"Image produced by the agent"},className:"block",children:r.jsx("img",{src:e.url,alt:e.alt??"Image produced by the agent",loading:"lazy",decoding:"async",onError:()=>n(!0),className:"border-border/60 bg-muted/20 max-h-[32rem] max-w-full rounded-md border object-contain"})})})}function Vm({content:e}){return r.jsx(tt,{"data-testid":"staged-context-note",icon:r.jsx(Pr,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:"Added context for the next reply"}),children:r.jsx("p",{className:"text-muted-foreground/80 mt-1 text-xs whitespace-pre-wrap",children:e})})}function Ym(e){if(e<1e3)return"<1s";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),s=t%60;return`${n}m ${s}s`}function Xm(e){return e==="untracked"?"neutral":e==="stopped"?"complete":e}function Jm(e){const t=[];return e.toolUses&&t.push(`${e.toolUses} tool ${e.toolUses===1?"call":"calls"}`),e.durationMs&&t.push(Ym(e.durationMs)),t.length>0?t.join(" · "):null}function Zm({part:e}){const[t,n]=l.useState(!1),s=l.useRef(null),o=Jm(e),a=e.subagentText,i=e.status==="untracked",c=!!(o||e.summary||e.lastToolName||a||i);return l.useEffect(()=>{const u=s.current;u&&(u.scrollTop=u.scrollHeight)},[a]),r.jsx(Ct,{expanded:t,onToggle:()=>c&&n(!t),hideChevron:!c,ariaLabel:`Background task: ${e.description}`,"data-testid":"subagent-block","data-task-id":e.taskId,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[Lo(Xm(e.status)),r.jsx("span",{className:"text-3xs truncate font-mono",children:e.description}),o&&r.jsx("span",{className:"text-3xs text-muted-foreground ml-1 shrink-0",children:o})]}),children:r.jsxs("div",{className:"space-y-1.5",children:[a&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-3xs text-muted-foreground/70 tracking-wide uppercase",children:"Helper output"}),r.jsx("pre",{ref:s,className:"text-foreground/90 bg-muted/50 max-h-64 overflow-y-auto rounded-md p-2 text-xs break-words whitespace-pre-wrap","data-testid":"subagent-text",children:a})]}),e.lastToolName&&e.status==="running"&&r.jsxs("p",{className:"text-3xs text-muted-foreground",children:["Last tool: ",r.jsx("span",{className:"font-mono",children:e.lastToolName})]}),e.summary&&r.jsx("pre",{className:"overflow-x-auto text-xs whitespace-pre-wrap",children:e.summary}),i&&r.jsx("p",{className:"text-3xs text-muted-foreground","data-testid":"subagent-untracked",children:"No longer tracked. It may still be running."})]})})}function ef(e){try{const t=JSON.parse(e);if(!t||typeof t!="object")return e;const n=t;if(n.error&&typeof n.error=="object"){const s=n.error;if(typeof s.message=="string")return s.message}return typeof n.message=="string"?n.message:e}catch{return e}}function tf(e){const t=ef(e),n=t.match(/The ['"`]([^'"`]+)['"`] model requires a newer version of Codex\b/i);if(n)return{message:`The Codex version DorkOS is using is too old for ${n[1]}. Update DorkOS (or your custom Codex installation), then try again. You can also choose another model.`,category:"runtime_update_required",details:e};const s=t.match(/The ['"`]([^'"`]+)['"`] model is not supported when using Codex with a ChatGPT account\b/i);return s?{message:`${s[1]} isn’t available with a ChatGPT account. Choose another model from the model menu.`,category:"model_unavailable",details:e}:null}function Ke(e){return e.notAllowed!==!0&&e.usage.state!=="limited"}function nf(e,t){if(e.id===at||!e.eligible)return e.reason;const n=ai(e.usage,"seven_day");if(!n||n.usedPct===null)return"usage unknown";const s=Math.min(100,Math.max(0,Math.round(100-n.usedPct))),o=ii(n.resetsAt,t);return o?`${s}% left · resets ${o}`:`${s}% left`}function tn(e,t){return e.runtime!==void 0&&e.runtime!==t}function sf(e,t){const n=[],s=[];for(const o of e)(tn(o,t)?s:n).push(o);return{same:n,other:s}}function Kt(e,t){return`${e.runtime??t}:${e.id}`}function rf(e,t,n){if(tn(e,t)){const s=e.runtime;return!e.label&&e.id===gt?`${Wt({runtime:s,accountLabel:null,identityGate:!1})} (this computer's sign-in)`:Wt({runtime:s,accountLabel:e.label,identityGate:!0})}return e.label?e.label:e.id===gt&&e.usage.label?e.usage.label:e.usage.path?n(e.usage.path):e.id}function of(e,t){const n=e.accounts.find(o=>o.id===e.recommendedId);if(n&&Ke(n))return Kt(n,t);const s=e.accounts.find(Ke);return s?Kt(s,t):null}function af(e){return e.length===0?null:e.length===1?`${e[0]} is kept out, so it isn’t listed.`:`${`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`} are kept out, so they aren’t listed.`}function lf(e,t){if(e&&t)return{subtitle:"Picks up in the same folder and branch, from the last checkpoint.",carries:"Carries over: files, branch, checkpoint, task",doesnt:"Doesn’t: the chat itself"};const n="Starts a new chat in the same folder, with a summary of this one.";return{subtitle:e?n:`${n} Sorted by most usage left.`,carries:"Carries over: the folder and a summary of this chat",doesnt:"Doesn’t: the chat itself"}}function cf(e){return e.carryOver===!1}function uf(e,t,n){return e?!0:(t==null?void 0:t.accounts.some(s=>tn(s,n)))??!1}function df(e){return{id:at,runtime:e,label:ws,color:js,eligible:!0,reason:"paid from your DorkOS account",usage:{runtime:"claude-code",accountId:at,path:"",label:ws,color:js,subscriptionType:null,plan:null,credits:null,spend:null,windows:[],state:"unknown",limit:null,updatedAt:null}}}function Ho(e,t){const n=be();return ut({queryKey:Hn.continueOptions(e),queryFn:()=>n.getContinueOptions(e),enabled:t,staleTime:0,retry:!1})}function mf(e){const t=be();return xt({mutationFn:n=>t.continueSession(e,n),retry:!1})}function ff(e){const t=be();return xt({mutationFn:()=>t.cancelAutoContinue(e),retry:!1})}const Hs="claude-code",pf="No other account can take this work right now.";function hf(e){return e instanceof Error&&e.message?e.message:"Couldn’t continue on that account. Try again."}function gf({row:e,value:t,name:n,status:s,selected:o}){const a=Ke(e);return r.jsxs("label",{"data-slot":"continue-account-row","data-eligible":e.eligible,className:H("flex min-h-11 min-w-0 items-center gap-1.5 rounded-lg border px-2.5 py-2 text-sm transition-colors duration-150","has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-[3px]",o?"border-foreground ring-foreground ring-1 ring-inset":"border-border",a?"hover:bg-muted/50 cursor-pointer":"cursor-not-allowed",!e.eligible&&"opacity-60"),children:[r.jsx(gi,{value:t,disabled:!a,className:"sr-only"}),r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:r.jsx(Kn,{color:e.color,name:n})}),r.jsx("span",{className:"max-w-[55%] shrink-0 truncate font-medium",children:n}),e.badge==="recommended"&&r.jsx("span",{className:H(xi.success,"border-status-success-border text-2xs shrink-0 rounded-full border px-1.5"),children:"recommended"}),r.jsx("span",{className:"text-muted-foreground ml-auto min-w-0 pl-1 text-right text-xs",children:s})]})}function Go({open:e,onOpenChange:t,sessionId:n,account:s,cancelAutoFirst:o=!1,now:a,onCloseAutoFocus:i}){var te;const c=jt(),u=a??new Date(c),d=l.useId(),m=s.runtime??Hs,{accounts:h,nameFor:p}=Gn(),[,f]=wt(),g=ff(n),x=l.useRef(!1),{mutate:y,reset:b}=g;l.useEffect(()=>{if(!e){x.current=!1,b();return}!o||x.current||(x.current=!0,y())},[e,o,y,b]);const v=e&&(!o||g.isSuccess),j=Ho(n,v),S=mf(n),[T,R]=l.useState(null),E=()=>{S.isPending||(R(null),S.reset(),t(!1))},O=$=>$?t(!0):E(),A=v?j.data:void 0,I=A==null?void 0:A.ranking,F=A&&!cf(A.plan)?[...A.ranking.accounts,...A.credits?[df(m)]:[]]:[],N=F.some(Ke),k=T??(I?of(I,m):null),C=F.find($=>Kt($,m)===k)??null,w=C!==null&&Ke(C),P=$=>rf($,m,p),{same:M,other:D}=sf(F,m),W=lf((A==null?void 0:A.advised)===!0,s.trackerItems.some($=>$.via==="this-chat")),G=s.accountId??((te=s.limit)==null?void 0:te.accountId)??null,V=(A==null?void 0:A.advised)===!0&&m===Hs&&G!==null?af(h.filter($=>$.id&&$.id!==G&&!M.some(J=>J.id===$.id)).map($=>p($.path))):null,B=()=>{!C||!Ke(C)||S.mutate(tn(C,m)?{account:C.id,runtime:C.runtime}:{account:C.id},{onSuccess:$=>{E(),$.sessionId&&f($.sessionId)}})},L=$=>{const J=Kt($,m);return r.jsx(gf,{row:$,value:J,name:P($),status:nf($,u),selected:J===k},J)},X=g.isError?g.error:j.isError&&v?j.error:S.isError?S.error:null,_=e&&!X&&(!v||j.isPending),q=!_&&A!==void 0;return r.jsx(li,{open:e,onOpenChange:O,children:r.jsxs(ci,{className:"max-h-[85vh] !min-h-0",desktopProps:{className:"sm:max-w-[380px]"},onCloseAutoFocus:i,"aria-labelledby":d,children:[r.jsxs(ui,{className:"shrink-0 text-left",children:[r.jsx(di,{id:d,className:"text-left",children:"Continue on another account"}),r.jsx(mi,{className:"text-left",children:W.subtitle})]}),r.jsxs(fi,{className:"flex flex-col gap-3",children:[_&&r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx(Ns,{className:"h-11 rounded-lg"}),r.jsx(Ns,{className:"h-11 rounded-lg"})]}),q&&(N?r.jsxs(pi,{"aria-labelledby":d,value:k??"",onValueChange:R,className:"min-w-0 grid-cols-1 gap-1.5",children:[M.map(L),D.length>0&&r.jsx("div",{className:"text-muted-foreground mt-2 text-xs font-semibold tracking-wide uppercase",children:"Other runtimes"}),D.map(L)]}):r.jsx("p",{className:"text-muted-foreground text-sm",children:pf})),q&&V&&r.jsx("p",{className:"text-muted-foreground text-xs",children:V}),q&&r.jsxs("ul",{className:"text-muted-foreground list-disc pl-4 text-xs",children:[r.jsx("li",{children:W.carries}),r.jsx("li",{children:W.doesnt})]}),X!==null&&r.jsx("p",{role:"alert",className:"text-destructive text-sm",children:hf(X)})]}),r.jsxs(hi,{className:"shrink-0",children:[r.jsx(ue,{variant:"outline",onClick:E,disabled:S.isPending,children:"Cancel"}),r.jsxs(ue,{onClick:B,disabled:!q||!N||!w||S.isPending,"aria-busy":S.isPending||void 0,children:[S.isPending&&r.jsx(Ue,{}),C&&q&&N?`Continue on ${P(C)}`:"Continue"]})]})]})})}const xf=1440*60*1e3,yf="Paused until you continue or the account resets",bf="Paused until the task moves or the account resets",kf=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited"]);function vf(e){return kf.has(e)?"critical":"neutral"}function Ko(e){return e.carryOver===!1}function st(e,t){return e!==null&&Date.parse(e)<=t.getTime()}function ss(e){return`${e} should have reset by now.`}function Sf(e,t,n,s){if(st(n,s))return ss(e);const o=yi(t,n,s);return o==="out"?`${e} is out of usage.`:o.startsWith("back in ")?`${e} is out of usage · ${o}.`:`${e} is out of usage ${o.slice(4)}.`}function Qo(e){return e.plan.mode==="waiting"&&e.plan.resumeAt?e.plan.resumeAt:e.resetsAt}function Gs(e,t,n){if(t===null)return`Waiting for ${e}`;if(st(t,n))return ss(e);const s=Date.parse(t)-n.getTime();return s<xf?`Waiting for ${e} · back in ${bi(s)}`:`Waiting for ${e} · back ${Qn(t,n)}`}function jf(e,t){return Math.max(0,Math.ceil((Date.parse(e)-t.getTime())/1e3))}const wf=new Set(["continue-on","move-now","keep-going","resume","open-moved"]);function Nf(e,t){return(()=>{switch(e){case"limited":return[t.canPick&&"continue-on","wait"];case"handing-off":return["move-now",t.canPick&&"choose","wait"];case"model-limited":return[t.hasFallback&&"keep-going",t.canPick&&"continue-on","wait"];case"wait-only":case"all-accounts-out":return["wait"];case"reset-ready":return["resume"];case"moved":return["open-moved",!t.continuedHere&&"continue-here"];default:return[]}})().filter(s=>s!==!1)}const Cf=new Set(["limited","handing-off","wait-only","all-accounts-out","model-limited","waiting-reset"]),hn={canSubmit:!0,placeholder:null};function Tf(e,t,n){if(!e)return hn;const s=$r(e);if(s==="moved")return{canSubmit:t,placeholder:null};if(!Cf.has(s))return hn;const o=i=>i!==null&&!st(i,n);return o(Qo(e))||e.plan.mode==="auto"&&o(e.plan.fireAt)?{canSubmit:!1,placeholder:s==="handing-off"?bf:yf}:hn}const Rf=300*1e3;function Vo(e,t){const n=Date.parse(e)-Date.parse(t);return Number.isFinite(n)&&n>=0&&n<=Rf}function Ef(e,t){let n=null;for(const s of e)Vo(s.since,t)&&(n===null||Date.parse(s.since)<Date.parse(n.since))&&(n=s);return n}function On(e,t){var n;return e?((n=t.find(s=>s.value===e))==null?void 0:n.displayName)??e:null}function Af(e,t){return{from:On(e.modelFrom,t)??(e.scope==="model"?Fr(e.window,t):null),to:On(e.modelTo,t)}}function Yo(){const{accounts:e,nameFor:t,colorFor:n}=Gn(),s=ki("claude-code",{accountId:gt,path:null});return o=>{const a=vi({accountId:o,path:null,accounts:e,usage:o===gt?s:null,nameFor:t,colorFor:n});return{name:a.name??o,color:a.color}}}const Ks="claude-code",_f=new Set(["limited","handing-off","model-limited"]),Mf=new Set(["limited","model-limited","all-accounts-out"]);function Of(e){return(e==null?void 0:e.runsOn)==="own-sign-in"&&e.chosenBy==="user"}function If(e){return e instanceof Error&&e.message?e.message:"Couldn’t do that. Try again."}function Df(e,t){var G,V,B;const n=be(),s=Vn(),[,o]=wt(),a=Nt(e,{fetchUsage:!1}),i=t??a,c=i.limit,u=c?$r(c):null,d=i.runtime??Ks,m=i.visible,h=Yo(),p=d===Ks&&(c!=null&&c.accountId)?h(c.accountId).name:i.name,f=Wt({runtime:d,accountLabel:p,identityGate:m}),g=Xt({sessionId:e||void 0,runtime:d}).data??[],x=c?Ko(c.plan):!0,y=u!==null&&_f.has(u)&&!x,{isLoaded:b}=Gn(),{data:v}=Yn(),j=b&&v!==void 0,S=u==="model-limited",T=Ho(e,y&&j&&(S?m:!m)),R=y&&(S?m&&(((G=T.data)==null?void 0:G.ranking.accounts.some(Ke))??!1):uf(m,(V=T.data)==null?void 0:V.ranking,d)),{continuedHere:E,continueHere:O}=fo(e,(c==null?void 0:c.since)??null),{data:A}=Si(),I=u!==null&&Mf.has(u)&&!x&&(c==null?void 0:c.accountId)!==at&&ji(A,d)&&!Of((B=A==null?void 0:A.defaults)==null?void 0:B[d]),F=(c==null?void 0:c.since)??null,N=`${F}:${u}`,[k,C]=l.useState(null),w=L=>C(L===null?null:{key:N,message:L}),P=L=>w(If(L)),M=xt({mutationFn:L=>n.waitForReset(e,L),retry:!1,onError:P}),D=xt({mutationFn:L=>n.continueSession(e,L),retry:!1,onError:P,onSuccess:L=>{L.sessionId&&L.sessionId!==e&&o(L.sessionId)}}),W=l.useRef(F);return l.useEffect(()=>{W.current!==null&&F===null&&s.invalidateQueries({queryKey:Hn.limitHistory(e)}),W.current=F},[F,e,s]),{account:i,limit:c,state:u,runtime:d,subject:f,identityGate:m,canPick:R,creditsOffered:I,nameOf:h,models:g,continuedHere:E,continueHere:O,wait:L=>{w(null),M.mutate(L===void 0?{}:{autoResume:L})},continueOn:L=>{w(null),D.mutate(L)},openSession:L=>o(L),pending:M.isPending||D.isPending,failure:(k==null?void 0:k.key)===N?k.message:null}}function gn({visible:e,spoken:t,spokenKey:n}){const[s,o]=l.useState({key:n,text:t});return s.key!==n&&o({key:n,text:t}),r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:e}),r.jsx("span",{className:"sr-only",children:s.key===n?s.text:t})]})}function xn({account:e,showDot:t}){return r.jsxs(r.Fragment,{children:[t&&e.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-1 inline-flex align-middle",children:r.jsx(Kn,{color:e.color,name:e.name,tooltip:!1})}),e.name]})}function Pf(e,t){switch(e){case"continue-on":return"Continue on another account…";case"move-now":return"Move now";case"choose":return"Choose account…";case"keep-going":return`Keep going on ${t}, same account`;case"resume":return"Continue";case"open-moved":return"Open it →";case"continue-here":return"Continue here anyway";case"wait":return"Wait for reset"}}function $f({sessionId:e,onSend:t,account:n,now:s}){const o=Df(e,n),a=Lr(),{limit:i,state:c,subject:u,identityGate:d}=o,m=jt(c==="handing-off"?1e3:6e4),h=s??new Date(m),p=i?i.since:null,[f,g]=l.useState(null),x=o.canPick&&p!==null&&f===p,y=N=>g(N?p:null),b=l.useId();if(!i||!c)return null;const v=o.creditsOffered&&a!==null,j=i.plan,S=On(i.modelFallback,o.models),T=Nf(c,{canPick:o.canPick,hasFallback:S!==null,continuedHere:o.continuedHere}),R=`${c}:${i.since}:${u}`;let E,O=null,A=!1;switch(c){case"all-accounts-out":{E="All accounts are out.";const N=i.allOut;if(N!=null&&N.resetsAt){const k=o.nameOf(N.accountId);O=st(N.resetsAt,h)?ss(k.name):r.jsxs(r.Fragment,{children:["Soonest back: ",r.jsx(xn,{account:k,showDot:d}),","," ",Qn(N.resetsAt,h)]})}break}case"model-limited":E=`${Fr(i.window,o.models)} is out on ${u} for this week.`;break;case"waiting-reset":{const N=Qo(i);E=r.jsx(gn,{visible:Gs(u,N,h),spoken:Gs(u,N,h),spokenKey:`${R}:${st(N,h)}`});break}case"reset-ready":E=j.mode==="waiting"&&j.unconfirmed?`${u} should have reset by now.`:`${u} has reset.`;break;case"moved":{if(j.mode!=="continued")return null;const N=o.nameOf(j.accountId);E=r.jsxs(r.Fragment,{children:["This task continued on ",r.jsx(xn,{account:N,showDot:d}),"."]});break}default:{const N=Sf(u,i.window,i.resetsAt,h);if(E=r.jsx(gn,{visible:N,spoken:N,spokenKey:`${R}:${st(i.resetsAt,h)}`}),c==="handing-off"&&j.mode==="auto"){const k=o.nameOf(j.target),C=jf(j.fireAt,h);A=C===0,O=r.jsx(gn,{visible:r.jsxs(r.Fragment,{children:["Moving this task to ",r.jsx(xn,{account:k,showDot:d}),A?"…":` in ${C}s…`]}),spoken:A?`Moving this task to ${k.name}.`:`Moving this task to ${k.name} in ${C} seconds.`,spokenKey:`${R}:${j.fireAt}:${k.name}:${A}`})}}}const I=N=>{switch(N){case"continue-on":case"choose":y(!0);return;case"move-now":j.mode==="auto"&&o.continueOn({account:j.target});return;case"keep-going":i.modelFallback&&o.continueOn({model:i.modelFallback});return;case"resume":t(wi);return;case"open-moved":j.mode==="continued"&&o.openSession(j.sessionId);return;case"continue-here":o.continueHere();return;case"wait":o.wait();return}},F=c==="waiting-reset"&&j.mode==="waiting"&&!Ko(j);return r.jsxs(r.Fragment,{children:[r.jsxs(Qc,{variant:vf(c),role:"status",icon:null,"data-slot":"account-limit-banner","data-state":c,className:"mx-4 mb-2 rounded-lg border px-3 py-2",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"font-semibold",children:E}),O&&r.jsxs(r.Fragment,{children:[" ",O]})]}),F&&r.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[r.jsx("input",{id:b,type:"checkbox",className:"size-3.5",checked:j.autoResume,disabled:o.pending,onChange:N=>o.wait(N.target.checked)}),r.jsx("label",{htmlFor:b,children:"Continue automatically when it resets"})]}),v&&a&&r.jsx("div",{className:"mt-1.5",children:a({runtime:o.runtime,origin:`limit:${e}`,intent:"keep-going",confirmAfterLink:{prompt:"Linked. Continue on DorkOS credits?",action:"Continue"},onChoose:()=>o.continueOn({account:at})})}),T.length>0&&r.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:T.map(N=>r.jsx(ue,{size:"sm",variant:wf.has(N)&&!v?"default":N==="continue-here"?"ghost":"outline",className:"h-auto min-h-11 max-w-full py-1 whitespace-normal md:min-h-8",disabled:o.pending||N==="move-now"&&A,onClick:()=>I(N),children:Pf(N,S)},N))}),o.failure&&r.jsx("p",{role:"alert",className:"text-destructive mt-1.5",children:o.failure})]}),o.canPick&&r.jsx(Go,{open:x,onOpenChange:y,sessionId:e,account:{runtime:o.runtime,accountId:o.account.accountId,limit:i,trackerItems:o.account.trackerItems},cancelAutoFirst:c==="handing-off",now:s})]})}function Ff(e){const t=be();return ut({queryKey:Hn.limitHistory(e),queryFn:()=>t.getLimitHistory(e),enabled:e!=="",retry:!1})}const Lf={moved:Ci,"resumed-reset":ft,"resumed-model":ft,"resumed-early":ft};function Uf({entry:e,now:t}){const n=jt(),s=t??new Date(n),o=Yo(),a=Ni(e.runtime),i=Xt({runtime:e.runtime}).data??[],[,c]=wt(),u=e.runtime==="claude-code"&&e.accountId?o(e.accountId).name:null,d=Wt({runtime:e.runtime,accountLabel:u,identityGate:a}),m=`at ${Qn(e.resolvedAt,s)}`,h=Lf[e.resolution];let p;switch(e.resolution){case"moved":{const f=e.toAccountId?o(e.toAccountId):null,g=f?r.jsxs(r.Fragment,{children:[a&&f.color&&r.jsx("span",{"aria-hidden":!0,className:"mr-0.5 inline-flex align-middle",children:r.jsx(Kn,{color:f.color,name:f.name,tooltip:!1})}),f.name]}):null;p=r.jsxs(r.Fragment,{children:[d," ran out · moved",g&&r.jsxs(r.Fragment,{children:[" to ",e.toSessionId?r.jsx("button",{type:"button",className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 outline-none focus-visible:ring-2",onClick:()=>c(e.toSessionId),children:g}):g]})," ",m]});break}case"resumed-reset":p=`Resumed after reset ${m}`;break;case"resumed-model":{const{from:f,to:g}=Af(e,i);p=g?`${f??d} ran out · continued on ${g} ${m}`:`${d} ran out · continued here ${m}`;break}case"resumed-early":p=`${d} ran out · continued here ${m}`;break}return r.jsxs("p",{"data-slot":"account-limit-marker","data-resolution":e.resolution,className:"text-muted-foreground text-2xs my-2 flex items-center gap-1.5",children:[r.jsx(h,{"aria-hidden":!0,className:"size-3 shrink-0"}),r.jsx("span",{className:"min-w-0",children:p})]})}function qf({sessionId:e,at:t,fallback:n,now:s}){const{limit:o}=Nt(e,{fetchUsage:!1}),a=Ff(e),[i,c]=l.useState(null),u=o!==null&&(t===""||Vo(o.since,t));if(u&&((i==null?void 0:i.data)!==a.dataUpdatedAt||i.error!==a.errorUpdatedAt)&&c({data:a.dataUpdatedAt,error:a.errorUpdatedAt}),u||a.isPending)return null;const d=a.data&&t?Ef(a.data.entries,t):null;return d?r.jsx(Uf,{entry:d,now:s}):o===null&&i!==null&&a.dataUpdatedAt===i.data&&a.errorUpdatedAt===i.error?null:r.jsx(r.Fragment,{children:n})}function zf(e){const{limit:t}=Nt(e,{fetchUsage:!1}),{continuedHere:n}=fo(e,(t==null?void 0:t.since)??null),s=jt();return Tf(t,n,new Date(s))}function Bf(e){return Nt(e,{fetchUsage:!1}).limit!==null}const Xo="runtimes";function Wf({label:e}){const{open:t}=Ur();return r.jsx("button",{type:"button",onClick:()=>t(Xo),className:"text-muted-foreground hover:text-foreground mt-2 block text-xs underline decoration-dotted underline-offset-2 transition-colors",children:e})}function Hf({runtime:e,sessionId:t,onRetry:n,onSigninComplete:s}){const[o,a]=l.useState(!1),i=Eu(e,{sessionId:t,onCompleted:()=>a((s==null?void 0:s())??!1)}),c=Au(e);return i.isSuccess?r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin-success",children:[r.jsxs("p",{className:"text-status-success-fg flex items-center gap-2 text-sm",role:"status",children:[r.jsx(Qt,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),o?"Signed in. Sending your message again…":"Signed in."]}),!o&&n&&r.jsxs(ue,{size:"sm",onClick:n,className:"mt-2 gap-1.5",children:[r.jsx(yt,{className:"size-3"}),"Retry"]})]}):r.jsxs("div",{className:"mt-3","data-testid":"auth-error-signin",children:[r.jsx("p",{className:"text-muted-foreground mb-2 flex items-center gap-2 text-sm",role:"status",children:i.isPending&&r.jsxs(r.Fragment,{children:[r.jsx(Ue,{size:"xs",className:"shrink-0"}),c.signInPending]})}),i.isError&&r.jsx("p",{className:"text-destructive mb-2 text-sm",role:"alert",children:i.errorMessage}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(ue,{size:"sm",onClick:i.login,disabled:i.isPending,className:"gap-1.5","data-testid":"auth-error-signin-button",children:[r.jsx(qr,{className:"size-3"}),i.isError?"Try again":c.signInLabel]}),n&&r.jsxs(ue,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[r.jsx(yt,{className:"size-3"}),"Retry"]})]}),r.jsx(Wf,{label:"Use an API key instead"})]})}function Qs({onRetry:e}){return r.jsx("div",{className:"mt-3","data-testid":"auth-error-remote-guidance",children:r.jsx(Tu,{...e?{onRetry:e}:{}})})}function Jo({onRetry:e}){const{open:t}=Ur();return r.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r.jsxs(ue,{size:"sm",onClick:()=>t(Xo),className:"gap-1.5",children:[r.jsx(qr,{className:"size-3"}),"Fix sign-in"]}),e&&r.jsxs(ue,{variant:"outline",size:"sm",onClick:e,className:"gap-1.5",children:[r.jsx(yt,{className:"size-3"}),"Retry"]})]})}function Gf({runtime:e,sessionId:t,onRetry:n,renderOffer:s,lead:o,children:a}){const i=!So(),c=zr(),u=ie(p=>p.setRetryAccount),d=St(e).label,m=s({runtime:e,origin:`auth-error:${t}`,note:`This makes new ${d} work on this computer run on your DorkOS credits.`,chosen:n?`New ${d} work on this computer now runs on your DorkOS credits. Sending your message again…`:`New ${d} work on this computer now runs on your DorkOS credits.`,...n?{confirmAfterLink:{prompt:"Linked. Send again on DorkOS credits?",action:"Send again"}}:{},onChoose:async()=>{await c.mutateAsync({runtime:e,useCredits:!0}),n&&(u({id:at,sessionId:t}),n())}}),h=p=>r.jsxs("section",{"aria-label":"Other ways",children:[r.jsx("p",{className:"text-muted-foreground text-2xs font-medium tracking-wide uppercase",children:"Other ways"}),p]});return o?r.jsxs("div",{className:"mt-3 space-y-3","data-testid":"auth-error-credits-first",children:[m,h(a),r.jsx(Ru,{ollama:Ti(e)==="provider-picker",remote:i})]}):r.jsxs("div",{"data-testid":"auth-error-credits-other-way",children:[a,r.jsx("div",{className:"mt-3",children:h(m)})]})}function Kf({sessionId:e,onRetry:t,onSigninComplete:n}){var h;const{sessions:s,isLoading:o}=Un(),a=So(),i=(h=s.find(p=>p.id===e))==null?void 0:h.runtime,c=Cu(i),u=Lr(),d=i!==void 0&&u!==null&&(c==="lead"||c==="other-way");if(!a&&!d)return r.jsx(Qs,{onRetry:t});if(o)return null;const m=a?!i||!Ri(i)?r.jsx(Jo,{onRetry:t}):r.jsx(Hf,{runtime:i,sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(Qs,{onRetry:t});return d&&i&&u?r.jsx(Gf,{runtime:i,sessionId:e,onRetry:t,renderOffer:u,lead:c==="lead",children:m}):m}function Qf({sessionId:e,onRetry:t,onSigninComplete:n}){return e?r.jsx(Kf,{sessionId:e,onRetry:t,onSigninComplete:n}):r.jsx(Jo,{onRetry:t})}const Vf="credits_unavailable",Yf="folder-sign-in";function Xf({onRetry:e,sessionId:t,runtimeLabel:n,reason:s}){const o=ie(g=>g.setRetryAccount),a=Ei(),i=zr(),c=Br(),u=en(t),d=Jt(u??null);if(!e)return null;const m=Jf(d),h=n?`your ${n}`:"your own",p=()=>{if(d!==void 0){if(m==="pick-for-send"){t&&o({id:gt,sessionId:t}),e();return}i.mutate({runtime:d.type,useCredits:!1},{onSuccess:()=>m==="new-conversation"?c(void 0,{runtime:d.type}):e()})}},f=()=>{t&&a.mutate(t,{onSuccess:({launch:g})=>{g!=null&&g.ok&&o({id:g.accountId,sessionId:t}),e()}})};return r.jsxs("div",{className:"mt-2 flex flex-col gap-2","data-testid":"credits-error-actions",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(ue,{size:"sm",variant:"outline",onClick:e,className:"gap-1.5",children:[r.jsx(yt,{className:"size-3"}),"Retry"]}),t&&r.jsx(ue,{size:"sm",variant:"outline",onClick:p,disabled:d===void 0||i.isPending,children:m==="new-conversation"?`Start a new chat on ${h} sign-in`:`Use ${h} sign-in`}),t&&s===Yf&&r.jsx(ue,{size:"sm",variant:"outline",onClick:f,disabled:a.isPending,children:"Don’t use credits in this project"})]}),t&&m==="whole-runtime"&&r.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"credits-own-sign-in-reach",children:["This moves all ",n??"its"," chats to ",h," sign-in, not just this one."]}),a.error&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:a.error.message}),i.isError&&r.jsx("p",{className:"text-muted-foreground text-xs",role:"status",children:"Couldn’t switch to your own sign-in. Try again in a moment."})]})}function Jf(e){var t;return e===void 0||e.supportsAccounts?"pick-for-send":((t=e.credits)==null?void 0:t.scope)==="conversation"?"new-conversation":"whole-runtime"}function Zf({category:e,onChooseModel:t}){return t?r.jsxs(ue,{size:"sm",onClick:t,className:"mt-3 gap-1.5",children:[r.jsx(Wr,{className:"size-3"}),e==="runtime_update_required"?"Choose another model":"Choose model"]}):null}const ep="your agent",tp="agent",Vs={max_turns:{heading:"Turn limit reached",subtext:"The agent ran for its maximum number of turns.",retryable:!1},execution_error:{heading:"Agent stopped unexpectedly",subtext:"Something went wrong before it finished.",retryable:!0},budget_exceeded:{heading:"Cost limit reached",subtext:"This chat hit its spending limit.",retryable:!1},output_format_error:{heading:"Output format error",subtext:"The agent couldn’t produce the required output format.",retryable:!1},auth_error:{heading:"Sign in again",subtext:"Your login stopped working. Sign in again to continue.",retryable:!0},model_unavailable:{heading:"Model unavailable",subtext:"Choose another model from the model menu.",retryable:!1},runtime_update_required:{heading:"Codex update required",subtext:"Update DorkOS or your Codex install, then try again. Or choose another model.",retryable:!1}},np=new Set(["max_turns","budget_exceeded","output_format_error","auth_error"]);function sp(e){return`Sign in to ${e??ep} again`}function rp(e){return`Your ${e??tp} login stopped working. Sign in again to continue.`}const op="rate_limit";function nn(e){const{code:t,at:n,sessionId:s,reason:o}=e;return t===Hr&&o?r.jsx(Mo,{agentId:o}):t===op&&s?r.jsx(qf,{sessionId:s,at:n??"",fallback:r.jsx(Ys,{...e})}):r.jsx(Ys,{...e})}function Ys({message:e,category:t,details:n,onRetry:s,heading:o,subtext:a,runtimeLabel:i,sessionId:c,onSigninComplete:u,onChooseModel:d,code:m,reason:h}){const[p,f]=l.useState(!1),g=m===Vf,x=l.useMemo(()=>tf(e),[e]),y=(x==null?void 0:x.category)??t,b=(x==null?void 0:x.message)??e,v=x?n!=null&&n.includes(x.details??"")?n:[n,x.details].filter(Boolean).join(`
|
|
36
|
+
`):n,j=y==="auth_error",S=y?Vs[y]??Vs.execution_error:null,T=j?sp(i):y==="runtime_update_required"&&i?`${i} update required`:S==null?void 0:S.heading,R=j?rp(i):S==null?void 0:S.subtext,E=g?"Couldn’t reach DorkOS credits":x?T??"Error":o??T??"Error",O=b.trim(),A=y!==void 0&&np.has(y),I=g?O:(x&&(a==null?void 0:a.trim())===e.trim()?void 0:a)??(A?R:O||R)??O,F=I.trim(),N=l.useMemo(()=>Ai(O),[O]),k=!O||O===F||O===E,C=!k&&(!A||N)?O:null,w=k||C!==null||v!=null&&v.includes(O)?v:[v,O].filter(Boolean).join(`
|
|
37
|
+
`),P=(S==null?void 0:S.retryable)??!!s;return r.jsx("div",{"data-testid":"error-message-block",className:H("my-2 rounded-lg border px-4 py-3","border-destructive/30 bg-destructive/5 text-foreground"),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Wn,{className:"text-destructive mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium",children:E}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(an,{text:I})}),C&&r.jsx("p",{className:"text-muted-foreground mt-1 text-sm wrap-anywhere whitespace-pre-wrap",children:r.jsx(an,{text:C})}),w&&r.jsxs("button",{type:"button",onClick:()=>f(!p),className:"text-muted-foreground hover:text-foreground mt-2 flex items-center gap-1 text-xs","aria-expanded":p,children:[r.jsx(Q.div,{animate:{rotate:p?0:-90},transition:{type:"spring",stiffness:400,damping:30},children:r.jsx(vt,{className:"size-3"})}),"Details"]}),r.jsx(me,{initial:!1,children:p&&w&&r.jsx(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"overflow-hidden",children:r.jsx("pre",{className:"bg-muted/50 mt-1 max-h-40 overflow-auto rounded p-2 text-xs whitespace-pre-wrap",children:r.jsx(an,{text:w})})})}),g&&r.jsx(Xf,{onRetry:s,sessionId:c,runtimeLabel:i,reason:h}),j&&r.jsx(Qf,{sessionId:c,onRetry:s,onSigninComplete:u}),(y==="model_unavailable"||y==="runtime_update_required")&&r.jsx(Zf,{category:y,onChooseModel:d})]}),!j&&!g&&P&&s&&r.jsxs(ue,{variant:"outline",size:"sm",onClick:s,className:"shrink-0 gap-1.5",children:[r.jsx(yt,{className:"size-3"}),"Retry"]})]})})}const ap=8;function ip({toolName:e,reasonType:t,reason:n,message:s,agentId:o}){const a=n||s,i=t==="classifier",c=t==="asyncAgent",u=o!==void 0?`Helper ${o.slice(0,ap)}`:c?"A background helper":null,m=u!==null?`${u} was blocked from using ${e}${i?" by auto mode":""}: ${a}`:i?`Blocked by auto mode: ${a}`:`Blocked: ${a}`;return r.jsxs("div",{"data-testid":"permission-denied-chip","data-reason-type":t,"data-agent-id":o,className:H("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-amber-500/30 bg-amber-500/5"),children:[r.jsx(_u,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-500"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:m}),c?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Background helpers can’t ask for approval, so this was blocked."}),r.jsx("p",{className:"text-muted-foreground mt-0.5 text-xs",children:"Do it yourself, or ask the agent to run it in the foreground."})]}):null,r.jsx("p",{className:"text-muted-foreground mt-0.5 font-mono text-xs",children:e})]})]})}const lp=50;function cp(e){return e.type==="tool_call"&&e.interactiveType==="approval"&&e.approvalOutcome!==void 0}function up(e,t){return e.approvalOutcome!==t.approvalOutcome||(e.approvalReasonGiven??!1)!==(t.approvalReasonGiven??!1)||e.approvalResolvedAt===void 0||t.approvalResolvedAt===void 0?!1:Math.abs(e.approvalResolvedAt-t.approvalResolvedAt)<=lp}function dp(e){const t=new Map;let n=null;for(let s=0;s<e.length;s++){const o=e[s];if(!cp(o)){n=null;continue}if(n&&up(n.part,o)){n.group.indices.push(s),t.set(s,n.group);continue}const a={leadIndex:s,indices:[s],outcome:o.approvalOutcome,reasonGiven:o.approvalReasonGiven??!1};t.set(s,a),n={group:a,part:o}}return t}function rs(e){return e.type==="thinking"||e.type==="memory_recall"||e.type==="background_task"?!0:e.type==="tool_call"&&!e.interactiveType&&!e.ui&&!ts(e.toolName)&&!Ht(e.toolName)}function mp(e){let t=0;for(const n of e)(n.type==="background_task"||n.type==="tool_call"&&rs(n))&&t++;return t}function Zo(e){return e.some(rs)}function fp(e){return e.questionOutcome!==void 0?e.questionOutcome==="answered":e.status!=="pending"}function pp(e){return e.status==="pending"?void 0:e.questionOutcome}function hp({message:e}){return r.jsx(tt,{"data-testid":"unreadable-entry-note",icon:r.jsx(_i,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsx("span",{className:"text-muted-foreground",children:e})})}function gp({title:e}){return r.jsxs("div",{"data-testid":"capability-approval-timed-out",className:H("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[r.jsx(ft,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm",children:"The agent stopped waiting for your answer."}),r.jsxs("p",{className:"text-muted-foreground mt-0.5 text-xs",children:["“",e,"” is still in Approvals. Answer it, then ask the agent to retry."]})]})]})}function In({testId:e,icon:t,children:n}){return r.jsxs("div",{"data-testid":e,className:H("my-2 flex items-start gap-2 rounded-md border px-3 py-2","text-foreground border-border bg-muted/40"),children:[t,r.jsx("div",{className:"min-w-0 flex-1",children:n})]})}function xp({part:e}){return e.outcome==="failed"?r.jsx(In,{testId:"mcp-signin-failed",icon:r.jsx(Wn,{"aria-hidden":"true",className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Sign-in to “",e.serverName,"” didn’t finish. Ask your agent to retry."]})}):r.jsx(In,{testId:"mcp-signin-receipt",icon:r.jsx(Gr,{"aria-hidden":"true",className:"text-status-success mt-0.5 size-4 shrink-0"}),children:r.jsxs("p",{className:"text-sm",children:["Connected to ",e.serverName,e.toolCount===void 0?"":` · ${e.toolCount} tool${e.toolCount===1?"":"s"}`,"."]})})}function yp({part:e}){const t=Mu(e.agentId,e.serverName),{adopt:n}=t,s=e.outcome!==void 0;return l.useEffect(()=>{s||n({flowId:e.flowId,authorizeUrl:e.authorizeUrl,disclosure:e.disclosure})},[s,n,e.flowId,e.authorizeUrl,e.disclosure]),e.outcome!==void 0?r.jsx(xp,{part:e}):r.jsxs(In,{testId:"mcp-signin-card",icon:r.jsx(Mi,{"aria-hidden":"true",className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),children:[r.jsxs("p",{className:"text-sm",children:["Sign in to ",e.serverName]}),r.jsx(Ou,{flow:t,serverName:e.serverName,failedActions:r.jsx(ue,{variant:"secondary",size:"sm",onClick:()=>t.start(),className:"focus-visible:ring-2",children:"Try again"})})]})}function bp({fromName:e,toName:t}){return r.jsx(tt,{"data-testid":"model-substituted-row",icon:r.jsx(Wr,{"aria-hidden":"true",className:"text-muted-foreground size-3 shrink-0"}),label:r.jsxs("span",{className:"text-muted-foreground",children:["DorkOS credits don’t cover ",e,", so this ran on ",t,". Switch in the model menu."]})})}const kp=60;function vp(e,t=kp){if(e.length<=t)return e;const n=t-1,s=Math.ceil(n/2);return`${e.slice(0,s)}…${e.slice(e.length-(n-s))}`}function Xs({command:e}){return r.jsx("code",{title:e,className:"min-w-0 truncate font-mono text-xs",children:vp(e)||"A background command"})}function Js({state:e,label:t,onStop:n}){return e==="failed"?r.jsx("span",{className:"text-status-warning-fg text-xs",role:"status",children:"Couldn’t stop it, and it may keep running after DorkOS quits."}):r.jsx(ue,{type:"button",variant:"outline",size:"xs",className:"h-11 w-full shrink-0 sm:h-6 sm:w-auto",disabled:e==="stopping",onClick:n,children:t})}function Sp({sessionId:e,part:t}){const n=be(),[s,o]=l.useState({}),a=l.useCallback(async d=>{o(h=>({...h,[d]:"stopping"}));let m="failed";try{const{receipt:h}=await n.stopTask(e,d);Xn(h)&&(m="stopped")}catch{}o(h=>({...h,[d]:m}))},[e,n]),i=(d,m)=>{const h=s[d];return m??(h==="stopping"||h==="failed"?void 0:h)},c=t.tasks.filter(d=>!i(d.taskId,d.ended)),u=Oi(t);if(c.length===0)return r.jsx("div",{id:u,"data-testid":"work-left-running-row",className:"text-muted-foreground py-1 text-xs",children:"Stopped. Everything has ended."});if(c.length===1){const d=c[0];return r.jsxs("div",{id:u,"data-testid":"work-left-running-row",className:"text-status-warning-fg py-1 text-xs",children:[r.jsx("p",{children:"Stopped. 1 command is still running:"}),r.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2",children:[r.jsx(Xs,{command:d.command}),r.jsx(Js,{state:s[d.taskId],label:"Stop command",onStop:()=>void a(d.taskId)})]})]})}return r.jsxs("div",{id:u,"data-testid":"work-left-running-row",className:"text-status-warning-fg py-1 text-xs",children:[r.jsxs("p",{children:["Stopped. ",c.length," commands are still running."]}),r.jsx("ul",{className:"mt-1 flex flex-col gap-1.5",children:c.map(d=>r.jsxs("li",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2",children:[r.jsx(Xs,{command:d.command}),r.jsx(Js,{state:s[d.taskId],label:"Stop",onStop:()=>void a(d.taskId)})]},d.taskId))})]})}const jp={running:r.jsx(Ue,{size:"xs",className:"text-muted-foreground"}),success:r.jsx(Qt,{className:"text-muted-foreground size-(--size-icon-xs)"}),error:r.jsx(ot,{className:"text-destructive size-(--size-icon-xs)"}),cancelled:r.jsx(ot,{className:"text-muted-foreground size-(--size-icon-xs)"})};function wp({hook:e}){const t=!!(e.stdout||e.stderr),[n,s]=l.useState(e.status==="error"),o=e.stderr||e.stdout;return r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>t&&s(a=>!a),className:H("flex w-full items-center gap-1.5 py-0.5",!t&&"cursor-default"),"aria-expanded":t?n:void 0,disabled:!t,children:[jp[e.status],r.jsx("span",{className:H("text-3xs font-mono",e.status==="error"?"text-destructive":"text-muted-foreground"),children:e.hookName}),e.status==="error"&&r.jsx("span",{className:"text-3xs text-destructive",children:"Error"}),e.exitCode!==void 0&&r.jsxs("span",{className:"text-3xs text-muted-foreground ml-auto",children:["exit ",e.exitCode]})]}),r.jsx(me,{initial:!1,children:n&&t&&o&&r.jsx(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"overflow-hidden",children:r.jsx("pre",{className:"text-muted-foreground max-h-32 overflow-y-auto py-1 text-xs whitespace-pre-wrap",children:o})})})]})}function Np({toolCall:e,defaultExpanded:t=!1}){const[n,s]=l.useState(t),o=!!e.progressOutput;l.useEffect(()=>{o&&!n&&s(!0)},[o]);const a=e.hooks&&e.hooks.length>0?r.jsx("div",{className:"border-border/50 space-y-0.5 border-t px-3 py-1",children:e.hooks.map(u=>r.jsx(wp,{hook:u},u.hookId))}):void 0,i=e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0,c=Ii(e.toolName);return r.jsxs(Ct,{expanded:n,onToggle:()=>s(!n),dimmed:e.status==="complete",extraContent:a,"data-testid":"tool-call-card","data-tool-name":e.toolName,"data-status":e.status,header:r.jsxs(r.Fragment,{children:[Lo(e.status),c&&r.jsx("span",{className:"bg-muted text-muted-foreground text-3xs rounded px-1 py-0.5 font-medium",children:c}),r.jsx("span",{className:"text-3xs flex-1 text-left font-mono",children:kt(e.toolName,e.input)}),i!==void 0&&r.jsx("span",{className:"text-muted-foreground text-3xs tabular-nums",children:Du(i)})]}),children:[e.status==="running"&&!e.input?r.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 py-1 text-xs",children:[r.jsx(Ue,{size:"xs"}),r.jsx("span",{children:"Preparing…"})]}):e.input!==void 0&&e.input!==""?r.jsx(Di,{toolName:e.toolName,input:e.input,isStreaming:e.status==="running"}):null,e.progressOutput&&!e.result&&r.jsx(Mr,{content:e.progressOutput,className:"mt-2 border-t pt-2"}),e.result&&r.jsx("div",{className:"mt-2 border-t pt-2",children:r.jsx(po,{content:e.result,toolName:e.toolName,input:e.input})})]})}function Cp(e){if(e.startsWith("mcp__"))return e.split("__")[1]||void 0}function ea(e,t,n){const s=l.useRef(e),[o,a]=l.useState(!(t&&s.current==="complete"));return l.useEffect(()=>{if(t&&e==="complete"&&s.current!=="complete"&&!n){const i=setTimeout(()=>a(!1),Yt.TOOL_CALL_AUTO_HIDE_MS);return()=>clearTimeout(i)}},[e,t,n]),!t||n?!0:o}function Tp({part:e,autoHide:t,expandToolCalls:n}){var a;const s=((a=e.hooks)==null?void 0:a.some(i=>i.status==="error"))??!1,o=ea(e.status,t,s);return r.jsx(me,{children:o&&r.jsx(Q.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(Np,{toolCall:{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input||"",result:e.result,progressOutput:e.progressOutput,status:e.status,hooks:e.hooks,startedAt:e.startedAt,completedAt:e.completedAt},defaultExpanded:n})},e.toolCallId)})}function yn({part:e,sessionId:t,autoHide:n,expandToolCalls:s}){const o=e.ui?Cp(e.toolName):void 0,a=r.jsx(Tp,{part:e,autoHide:n,expandToolCalls:s});return!e.ui||e.status!=="complete"||!o?a:r.jsxs("div",{className:"flex flex-col gap-2",children:[a,r.jsx(Nd,{sessionId:t,serverName:o,uri:e.ui.resourceUri})]})}function Rp({part:e,autoHide:t,index:n}){const s=e.isStreaming?"running":"complete",o=ea(s,t,!1);return r.jsx(me,{children:o&&r.jsx(Q.div,{exit:{height:0,opacity:0},transition:{duration:.3,ease:[.4,0,.2,1]},className:"overflow-hidden",children:r.jsx(qm,{text:e.text,isStreaming:e.isStreaming??!1,elapsedMs:e.elapsedMs})},`thinking-${n}`)})}const Ep=4,Zs=2;function Ap({children:e}){const[t,n]=l.useState(!1);if(e.length<=Ep||t)return r.jsx(r.Fragment,{children:e});const s=e.length-Zs;return r.jsxs(r.Fragment,{children:[e.slice(0,Zs),r.jsx(Ct,{expanded:!1,onToggle:()=>n(!0),ariaLabel:`Show ${s} more steps`,className:"border-l-muted-foreground/15",header:r.jsxs("span",{className:"text-3xs text-muted-foreground font-mono",children:["and ",s," more steps…"]}),children:r.jsx(r.Fragment,{})})]})}const _p=["z-30","-ml-2 z-20 opacity-70","-ml-2 z-10 opacity-45"];function Mp({chips:e,expanded:t,controls:n,onExpand:s}){const o=Le()??!1,a=e.slice(-3).reverse();return r.jsxs("button",{type:"button","data-testid":"chip-pile","aria-expanded":t,"aria-controls":n,"aria-label":`Show everything this turn touched (${e.length} more)`,onClick:s,className:H("flex shrink-0 items-center gap-1.5 rounded-full py-0.5 pr-1.5 pl-0.5","hover:bg-accent focus-visible:ring-ring outline-none focus-visible:ring-2"),children:[r.jsx(Q.span,{animate:o?{rotate:0,scale:1}:Yc,transition:Vc,className:"flex origin-bottom items-center",children:a.map((i,c)=>r.jsx("span",{"aria-hidden":"true",className:H("bg-card border-border text-3xs flex size-5 items-center justify-center rounded-full border leading-none",_p[c]),children:ho[i.verb]},i.key))},e.length),r.jsx("span",{"data-testid":"chip-pile-count",className:"bg-primary text-primary-foreground text-3xs rounded-full px-1.5 tabular-nums",children:e.length})]})}const Op=new Set;function Ip(){const[e,t]=l.useState(Op),n=l.useCallback((o,a)=>a===!0&&!e.has(o),[e]),s=l.useCallback(o=>{t(a=>a.has(o)?a:new Set(a).add(o))},[]);return{shouldPulse:n,acknowledge:s}}function Dp(e){const t=[...e].sort((n,s)=>n.lastSeq-s.lastSeq);return{visible:t.slice(-Ds),absorbed:t.slice(0,Math.max(0,t.length-Ds))}}function Pp(e){return e.map(t=>{const n=[`${t.chips.length} ${go[t.verb].toLowerCase()}`];return t.additions!==void 0&&n.push(`${t.additions} added`),t.deletions!==void 0&&n.push(`${t.deletions} removed`),n.join(", ")}).join("; ")}function $p({verb:e,count:t,additions:n,deletions:s}){return r.jsxs("span",{"data-testid":`chip-summary-${e}`,className:"inline-flex items-center gap-1",children:[r.jsx("span",{"aria-hidden":"true",children:ho[e]}),r.jsx("span",{className:"sr-only",children:go[e]}),r.jsx("span",{className:"tabular-nums",children:t}),(n!==void 0||s!==void 0)&&r.jsxs("span",{className:"tabular-nums",children:[n!==void 0&&r.jsxs("span",{className:"text-status-success-fg",children:["+",n]}),n!==void 0&&s!==void 0&&" ",s!==void 0&&r.jsxs("span",{className:"text-destructive",children:["−",s]})]})]})}function Fp({parts:e,sessionId:t,turnActive:n=!1}){const s=Le()??!1,o=l.useMemo(()=>Xc(e),[e]),a=Ip(),i=l.useId(),c=Jc(l.useMemo(()=>Zc(t,e),[t,e])),u=l.useCallback(f=>{if(f.pattern===!0)return;const g=ie.getState();if(f.kind==="url"){const x={type:"url",url:f.fullTarget};g.openCanvasDocument(x),Tn(g,"user",x);return}if(f.kind==="file"){const x={type:"file",sourcePath:f.fullTarget};g.openCanvasDocument(x),Tn(g,"user",x)}},[]),d=l.useMemo(()=>eu(o),[o]),m=n||o.some(f=>f.live),{visible:h,absorbed:p}=l.useMemo(()=>Dp(o),[o]);return o.length===0?null:r.jsxs("div",{"data-testid":"touch-chip-strip",className:"mt-2 flex flex-col gap-2",children:[r.jsx(me,{initial:!1,mode:"wait",children:m?r.jsxs(Q.div,{"data-testid":"chip-live-row",role:"group","aria-label":"Latest activity",exit:s?{opacity:0}:{opacity:0,height:0},transition:s?Os:Is,className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[p.length>0&&r.jsx(Mp,{chips:p,expanded:c.expanded,controls:i,onExpand:c.toggleExpanded}),r.jsx(me,{initial:!1,children:h.map(f=>r.jsx(tu,{chip:f,onOpen:u,animated:!0,pulseUpgrade:a.shouldPulse(f.key,f.upgraded),onUpgradeSeen:a.acknowledge},f.key))})]},"live"):r.jsxs(Q.div,{"data-testid":"chip-summary-line",role:"group","aria-label":Pp(d),initial:{opacity:0},animate:{opacity:1},transition:s?Os:Is,className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs",children:[d.map((f,g)=>r.jsxs(l.Fragment,{children:[g>0&&r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx($p,{verb:f.verb,count:f.chips.length,additions:f.additions,deletions:f.deletions})]},f.verb)),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("button",{type:"button","aria-expanded":c.expanded,"aria-controls":i,onClick:c.toggleExpanded,className:H("hover:text-foreground rounded-sm underline underline-offset-2","focus-visible:ring-ring outline-none focus-visible:ring-2"),children:c.expanded?"hide":"show all"})]},"settled")}),c.expanded&&r.jsx(nu,{id:i,chips:o,onOpen:u,verbFilter:c.verbFilter,onVerbFilterChange:c.setVerbFilter,order:c.order,onOrderChange:c.setOrder})]})}function er(e){return e.type==="thinking"?!0:e.type==="tool_call"&&!e.interactiveType&&!ts(e.toolName)&&!Ht(e.toolName)}function os({message:e,show:t="all"}){const{sessionId:n,isStreaming:s,isLatestWidgetMessage:o,isFinalMessage:a,activeToolCallId:i,onToolRef:c,focusedOptionIndex:u,onToolDecided:d,onRetry:m,onSigninComplete:h,onChooseModel:p,inputZoneToolCallId:f,textEffect:g,runtimeLabel:x,allowsDenyReason:y}=su(),b=ie(k=>k.expandToolCalls),v=ie(k=>k.autoHideToolCalls)&&t!=="work",j=e.parts,S=l.useMemo(()=>{const k=j??[];return t==="all"?k:k.filter(C=>rs(C)===(t==="work"))},[j,t]),{sent:T}=xo(n),R=l.useCallback(k=>{c==null||c(k)},[c]),E=l.useCallback(k=>{c==null||c(k)},[c]),O=dp(S.map(k=>k.type==="tool_call"&&Ht(k.toolName)?{...k,interactiveType:void 0}:k));let A=-1;for(let k=S.length-1;k>=0;k--)if(S[k].type==="text"){A=k;break}function I(k,C){if(k.type==="text")return r.jsx("div",{className:"msg-prose",children:r.jsx(es,{content:k.text,isStreaming:s&&C===A,textEffect:g,sessionId:n,isLatestWidgetMessage:o})},`text-${C}`);if(k.type==="background_task")return r.jsx(Zm,{part:k},k.taskId);if(k.type==="error"&&k.code===Kr)return r.jsx(hp,{message:k.message},`unreadable-${C}`);if(k.type==="error")return r.jsx(nn,{message:k.message,category:k.category,details:k.details,code:k.code,reason:k.reason,at:e.timestamp,onRetry:a&&k.category!==void 0?m:void 0,onSigninComplete:h,onChooseModel:p,runtimeLabel:x,sessionId:n},`error-${C}`);if(k.type==="thinking")return r.jsx(Rp,{part:k,autoHide:v,index:C},`thinking-${C}`);if(k.type==="elicitation")return r.jsx(od,{sessionId:n,interactionId:k.interactionId,serverName:k.serverName,message:k.message,mode:k.mode,url:k.url,requestedSchema:k.requestedSchema,status:k.status,action:k.action},`elicitation-${k.interactionId}`);if(k.type==="memory_recall")return r.jsx(zm,{mode:k.mode,memories:k.memories,isStreaming:k.isStreaming??!1},`memory-recall-${C}`);if(k.type==="permission_denied")return r.jsx(ip,{toolName:k.toolName,reasonType:k.reasonType,reason:k.reason,message:k.message,agentId:k.agentId},`permission-denied-${k.toolCallId}-${C}`);if(k.type==="model_substituted")return r.jsx(bp,{fromName:k.fromName,toName:k.toName},`model-substituted-${C}`);if(k.type==="work_left_running")return r.jsx(Sp,{sessionId:n,part:k},`work-left-${C}`);if(k.type==="compact_boundary")return r.jsx(Km,{trigger:k.trigger,preTokens:k.preTokens,postTokens:k.postTokens,failed:k.failed,error:k.error,requestedBy:k.requestedBy,contextPercent:k.contextPercent},`compact-boundary-${C}`);if(k.type==="capability_approval")return k.outcome==="timeout"?r.jsx(gp,{title:Pi(k.approval)},`capability-approval-${k.approval.approvalId}`):r.jsx($i,{approval:k.approval},`capability-approval-${k.approval.approvalId}`);if(k.type==="mcp_signin")return r.jsx(yp,{part:k},`mcp-signin-${k.agentId}-${k.flowId}`);if(k.type==="image")return r.jsx(Qm,{part:k},`image-${k.attachmentId}-${C}`);if(k.type!=="tool_call")return null;const w=k;if(w.interactiveType==="approval"&&w.status==="pending"){if(w.toolCallId===f)return r.jsx(zs,{type:"approval",toolName:w.toolName,toolInput:w.input},w.toolCallId);const M=w.toolCallId===i;return r.jsx(Qr,{ref:M?R:void 0,sessionId:n,toolCallId:w.toolCallId,toolName:w.toolName,input:w.input||"",timeoutMs:w.timeoutMs,approvalStartedAt:w.approvalStartedAt,approvalRemainingMs:w.approvalRemainingMs,approvalParked:w.approvalParked,approvalTitle:w.approvalTitle,approvalDisplayName:w.approvalDisplayName,approvalDescription:w.approvalDescription,approvalBlockedPath:w.approvalBlockedPath,approvalDecisionReason:w.approvalDecisionReason,approvalHasSuggestions:w.approvalHasSuggestions,approvalAlwaysAllowScope:w.approvalAlwaysAllowScope,isActive:M,onDecided:d?()=>d(w.toolCallId):void 0,allowsDenyReason:y},w.toolCallId)}const P=O.get(C);if(P){if(P.leadIndex!==C)return null;const M=P.indices.map(D=>S[D]).filter(D=>D.type==="tool_call");return r.jsx(fd,{outcome:P.outcome,reasonGiven:P.reasonGiven,members:M,lead:w,children:M.map(D=>r.jsx(yn,{part:D,sessionId:n,autoHide:v,expandToolCalls:b},D.toolCallId))},`approval-receipt-${w.toolCallId}`)}if(w.interactiveType==="question"){if(w.toolCallId===f)return r.jsx(zs,{type:"question",toolName:w.toolName,toolInput:w.input},w.toolCallId);const M=w.toolCallId===i;return r.jsx(Vr,{ref:M?E:void 0,sessionId:n,toolCallId:w.toolCallId,questions:w.questions??[],answers:w.answers??(fp(w)?{}:void 0),outcome:pp(w),result:w.result,isActive:M,focusedOptionIndex:M?u:-1,onDecided:d?D=>d(w.toolCallId,D):void 0},w.toolCallId)}return Ht(w.toolName)?r.jsx(Om,{part:w,sent:T,...e.timestamp?{at:e.timestamp}:{},...n?{sessionId:n}:{}},w.toolCallId):ts(w.toolName)?r.jsx(gd,{sessionId:n,input:w.input,result:w.result,fallback:r.jsx(yn,{part:w,sessionId:n,autoHide:v,expandToolCalls:b})},w.toolCallId):r.jsx(yn,{part:w,sessionId:n,autoHide:v,expandToolCalls:b},w.toolCallId)}const F=[];let N=[];for(let k=0;k<S.length;k++){const C=S[k];er(C)?N.push(k):(N.length>0&&(F.push(N.length===1?{type:"single",index:N[0]}:{type:"run",indices:[...N]}),N=[]),F.push({type:"single",index:k}))}return N.length>0&&F.push(N.length===1?{type:"single",index:N[0]}:{type:"run",indices:[...N]}),r.jsxs(r.Fragment,{children:[F.map(k=>{if(k.type==="single"){const w=S[k.index];return er(w)?r.jsx("div",{className:"my-3",children:I(w,k.index)},`spacer-${k.index}`):I(w,k.index)}const C=k.indices.map(w=>I(S[w],w));return r.jsx("div",{className:"my-3",children:t==="work"?C:r.jsx(Ap,{children:C})},`run-${k.indices[0]}`)}),t==="all"&&r.jsx(Fp,{parts:S,sessionId:n,turnActive:e._streaming===!0})]})}const Lp=/^Please read the following uploaded file\(s\):\n((?:- .+\n)+)\n?/,Up=/^[a-f0-9]{8}-/,qp=new Set(["png","jpg","jpeg","gif","webp","svg"]);function zp(e){const t=e.match(Lp);if(!t)return{files:[],textContent:e};const s=t[1].split(`
|
|
38
|
+
`).filter(a=>a.startsWith("- ")).map(a=>{var m;const i=a.slice(2).trim(),u=(i.split("/").pop()??i).replace(Up,""),d=((m=u.split(".").pop())==null?void 0:m.toLowerCase())??"";return{path:i,displayName:u,isImage:qp.has(d)}}),o=e.slice(t[0].length).trim();return{files:s,textContent:o}}function Bp(e){var n;switch(((n=e.split(".").pop())==null?void 0:n.toLowerCase())??""){case"txt":case"md":case"log":return Nu;case"ts":case"tsx":case"js":case"jsx":case"json":case"py":case"rs":case"go":return ju;case"csv":case"xls":case"xlsx":return Wu;case"png":case"jpg":case"jpeg":case"gif":case"webp":case"svg":return Bu;default:return vo}}function Wp({files:e}){const t=ie(n=>n.selectedCwd);return e.length===0?null:r.jsx("div",{className:"flex flex-wrap gap-1.5 pb-1.5",children:e.map(n=>{const s=n.path.split("/").pop()??n.path;if(n.isImage){const a=`/api/uploads/${encodeURIComponent(s)}?cwd=${encodeURIComponent(t??"")}`;return r.jsx(Q.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},children:r.jsx(Dr,{image:{src:a,alt:n.displayName,downloadName:n.displayName},className:"block rounded-lg",children:r.jsx("img",{src:a,alt:n.displayName,loading:"lazy",className:"border-border/50 max-h-[120px] max-w-[200px] rounded-lg border object-contain"})})},n.path)}const o=Bp(n.displayName);return r.jsxs(Q.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.15},className:"bg-muted flex items-center gap-1 rounded-md px-2 py-1 text-xs",children:[r.jsx(o,{className:"text-muted-foreground size-3 shrink-0"}),r.jsx("span",{className:"max-w-40 truncate",children:n.displayName})]},n.path)})})}function Hp({message:e}){var u;const t=(u=ru())==null?void 0:u.sessionId,[n,s]=l.useState(!1),[o,a]=l.useState(!1),i=l.useMemo(()=>zp(e.content),[e.content]),c=l.useMemo(()=>Ed(e.content),[e.content]);if(c)return r.jsx(Td,{action:c});if(e.chatMessages&&e.chatMessages.length>0)return r.jsx(Tm,{stamps:e.chatMessages,...t?{sessionId:t}:{}});if(e.promptSource&&e.promptSource.kind!=="channel")return r.jsxs("div",{"data-testid":"prompt-source-note",children:[r.jsxs("button",{type:"button","aria-expanded":o,onClick:()=>a(!o),className:"text-muted-foreground flex items-center gap-1 text-xs",children:[r.jsx(Bt,{className:H("size-3 transition-transform duration-200",o&&"rotate-90")}),r.jsx("span",{children:o?"Hide message":"Show message"})]}),r.jsx("div",{className:H(o?"text-muted-foreground mt-2 text-xs break-words whitespace-pre-wrap":"sr-only"),children:e.content})]});if(e.messageType==="command")return r.jsx("div",{className:"text-msg-command-fg font-mono text-sm break-words",children:e.content});if(e.messageType==="local_command_output")return r.jsx(po,{content:e.content,toolName:""});if(e.messageType==="compaction"){const d=Hm(e.compactMetadata),m=e.content.trim(),h=r.jsx("div",{className:"bg-border/40 h-px flex-1"});return m.length===0?r.jsxs("div",{"data-testid":"compaction-row",className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[h,r.jsx("span",{children:d}),h]}):r.jsxs("div",{className:"w-full","data-testid":"compaction-row",children:[r.jsxs("button",{onClick:()=>s(!n),className:"text-msg-compaction-fg flex w-full items-center gap-2 text-xs",children:[h,r.jsx(Bt,{className:H("size-3 transition-transform duration-200",n&&"rotate-90")}),r.jsx("span",{children:d}),h]}),n&&r.jsx("div",{className:"text-msg-compaction-fg mt-2 text-xs whitespace-pre-wrap",children:e.content})]})}return r.jsxs("div",{children:[i.files.length>0&&r.jsx(Wp,{files:i.files}),i.textContent&&r.jsx("div",{className:"break-words whitespace-pre-wrap",children:i.textContent})]})}function Gp({tasks:e,isCollapsed:t,onToggleCollapse:n}){const s=e.length,o=e.filter(c=>c.status==="completed").length,a=o===s&&s>0,i=s>0?o/s*100:0;return r.jsxs("button",{onClick:n,className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-2 text-xs",children:[t?r.jsx(Bt,{className:"size-(--size-icon-xs) shrink-0"}):r.jsx(vt,{className:"size-(--size-icon-xs) shrink-0"}),r.jsx("div",{className:"bg-muted h-0.5 flex-1 overflow-hidden rounded-full",children:r.jsx("div",{"data-slot":"progress-fill",className:`h-full rounded-full transition-[width,background-color] duration-300 ease-out ${a?"bg-green-500":"bg-blue-500"}`,style:{width:`${i}%`}})}),r.jsxs("span",{className:"shrink-0 tabular-nums",children:[o,"/",s," ",s===1?"task":"tasks"]})]})}function Kp({activeForm:e,isCollapsed:t}){return r.jsx(me,{children:e&&!t&&r.jsxs(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"mb-1 flex items-center gap-2 text-xs text-blue-400",children:[r.jsx(Ue,{size:"xs",className:"shrink-0"}),r.jsx("span",{className:"truncate",children:e})]})})}const Qp={in_progress:"",pending:"waiting ",completed:"done "};function tr({tasks:e,onScrollToTask:t}){return r.jsx(r.Fragment,{children:e.map((n,s)=>r.jsxs("span",{children:[r.jsx("button",{onClick:o=>{o.stopPropagation(),t(n.id)},className:"hover:text-foreground underline decoration-dotted",children:n.subject}),s<e.length-1&&", "]},n.id))})}function Vp({task:e,taskMap:t,statusSince:n,onScrollToTask:s}){var d,m;const o=jo(n),a=Qp[e.status]??"",i=((d=e.blockedBy)==null?void 0:d.map(h=>t.get(h)).filter(h=>h!=null))??[],c=((m=e.blocks)==null?void 0:m.map(h=>t.get(h)).filter(h=>h!=null))??[],u=[];return n!==null&&u.push(r.jsxs("span",{children:[a,o.formatted]},"time")),e.owner&&u.push(r.jsx("span",{children:e.owner},"owner")),i.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["← ",r.jsx(tr,{tasks:i,onScrollToTask:s})]},"blocked-by")),c.length>0&&u.push(r.jsxs("span",{className:"inline-flex items-center gap-1",children:["→ ",r.jsx(tr,{tasks:c,onScrollToTask:s})]},"blocks")),r.jsxs(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"mt-0.5 ml-6 space-y-1",children:[e.description&&r.jsx("p",{className:"text-muted-foreground text-xs whitespace-pre-wrap",children:e.description}),u.length>0&&r.jsx("div",{className:"text-muted-foreground text-2xs flex flex-wrap items-center gap-1",children:u.map((h,p)=>r.jsxs("span",{className:"flex items-center gap-1",children:[p>0&&r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),h]},p))})]})}const nr={in_progress:r.jsx(Ue,{size:"xs",className:"text-status-info shrink-0"}),pending:r.jsx(Fi,{className:"text-muted-foreground size-(--size-icon-xs) shrink-0"}),completed:r.jsx(Gr,{className:"text-status-success size-(--size-icon-xs) shrink-0"})};function Yp({task:e,isBlocked:t,isExpanded:n,onToggleExpand:s,onHover:o,isHighlightedAsDep:a,isHighlightedAsDependent:i,taskMap:c,statusSince:u,isCelebrating:d,onCelebrationComplete:m,onScrollToTask:h}){const p=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s())};return r.jsxs(Q.li,{"data-task-id":e.id,children:[r.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":n,"data-task-id":e.id,onClick:s,onKeyDown:p,onMouseEnter:()=>o(e.id),onMouseLeave:()=>o(null),className:H("hover:bg-muted/40 focus-visible:bg-muted/40 relative flex items-center gap-2 rounded py-0.5 text-xs transition-colors",e.status==="completed"&&"text-muted-foreground/50 line-through",e.status==="in_progress"&&"text-foreground font-medium",e.status==="pending"&&!t&&"text-muted-foreground",e.status==="pending"&&t&&"text-muted-foreground/50",a&&"border-l-2 border-blue-400 pl-1.5",i&&"border-l-2 border-amber-400 pl-1.5",!a&&!i&&"border-l-2 border-transparent pl-1.5"),children:[d&&r.jsx(Q.div,{"aria-hidden":"true",className:"absolute inset-0 rounded",initial:{backgroundPosition:"-200% 0"},animate:{backgroundPosition:"200% 0"},transition:{duration:.4,ease:"easeOut"},style:{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,215,0,0.2) 50%, transparent 100%)",backgroundSize:"200% 100%"}}),d?r.jsx(Q.span,{initial:{scale:1},animate:{scale:[1,1.4,1]},transition:{type:"spring",stiffness:400,damping:10},onAnimationComplete:()=>m==null?void 0:m(),children:nr[e.status]}):nr[e.status],r.jsx("span",{className:"truncate",children:e.subject})]}),r.jsx(me,{children:n&&r.jsx(Vp,{task:e,taskMap:c,statusSince:u,onScrollToTask:h})})]})}function Xp(e,t){var n;return(n=e.blockedBy)!=null&&n.length?e.blockedBy.some(s=>{const o=t.get(s);return o&&o.status!=="completed"}):!1}const Jp=10,Zp="max-h-[30svh] sm:max-h-[40svh]";function eh({tasks:e,taskMap:t,activeForm:n,isCollapsed:s,onToggleCollapse:o,celebratingTaskId:a,onCelebrationComplete:i,statusTimestamps:c}){const[u,d]=l.useState(null),[m,h]=l.useState(null),p=l.useCallback(y=>{d(b=>b===y?null:y)},[]),f=l.useCallback(y=>{const b=document.querySelector(`[data-task-id="${y}"]`);b&&(b.scrollIntoView({behavior:"smooth",block:"nearest"}),b.classList.add("bg-blue-500/10"),setTimeout(()=>b.classList.remove("bg-blue-500/10"),1e3))},[]);if(e.length===0)return null;const g=e.slice(0,Jp),x=m?t.get(m):null;return r.jsxs("div",{className:"border-t px-4 py-2",children:[r.jsx(Kp,{activeForm:n,isCollapsed:s}),r.jsx(Gp,{tasks:e,isCollapsed:s,onToggleCollapse:o}),r.jsx(me,{children:!s&&r.jsx(Q.ul,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:H("mt-1 space-y-0.5 overflow-y-auto",Zp),children:g.map(y=>{var R,E;const b=y.id===a&&y.status==="completed",v=Xp(y,t),j=c.get(y.id),S=((R=x==null?void 0:x.blockedBy)==null?void 0:R.includes(y.id))??!1,T=((E=x==null?void 0:x.blocks)==null?void 0:E.includes(y.id))??!1;return r.jsx(Yp,{task:y,isBlocked:v,isExpanded:u===y.id,onToggleExpand:()=>p(y.id),onHover:h,isHighlightedAsDep:S,isHighlightedAsDependent:T,taskMap:t,statusSince:(j==null?void 0:j.since)??null,isCelebrating:b,onCelebrationComplete:i,onScrollToTask:f},y.id)})})})]})}function th({color:e}){const t=[{bx:"-8px",by:"-10px",delay:"0s"},{bx:"8px",by:"-8px",delay:"0.03s"},{bx:"-6px",by:"6px",delay:"0.06s"},{bx:"10px",by:"4px",delay:"0.09s"},{bx:"0px",by:"-12px",delay:"0.04s"},{bx:"-10px",by:"0px",delay:"0.07s"},{bx:"6px",by:"10px",delay:"0.05s"},{bx:"-4px",by:"-6px",delay:"0.08s"}];return r.jsx("div",{className:"pointer-events-none absolute inset-0",children:t.map((n,s)=>r.jsx("span",{className:"absolute top-1/2 left-1/2 size-[3px] rounded-full",style:{backgroundColor:e,"--bx":n.bx,"--by":n.by,animation:`burst-particle 0.5s ease-out ${n.delay} forwards`}},s))})}const nh=350;function sh({status:e,color:t}){return r.jsxs("svg",{className:"check-appear h-6 w-[22px]",viewBox:"0 0 22 24","data-status":e,children:[r.jsx("circle",{cx:"11",cy:"12",r:"7",fill:"none",stroke:t,strokeWidth:"1.5",opacity:"0.3"}),e==="error"&&r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"9",x2:"14",y2:"15",stroke:t,strokeWidth:"2",strokeLinecap:"round"}),r.jsx("line",{x1:"14",y1:"9",x2:"8",y2:"15",stroke:t,strokeWidth:"2",strokeLinecap:"round"})]}),e==="untracked"&&r.jsx("line",{x1:"8",y1:"12",x2:"14",y2:"12",stroke:t,strokeWidth:"2",strokeLinecap:"round",opacity:"0.5"}),e!=="error"&&e!=="untracked"&&r.jsx("polyline",{points:"7,12 10,15 15,9",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function rh({agent:e,index:t}){const n=l.useMemo(()=>({animationDelay:`${t*.09}s`}),[t]),[s,o]=l.useState(e.status==="running"?"running":"done"),a=l.useRef(e.status),i=l.useRef(null);return l.useEffect(()=>{const c=a.current;if(a.current=e.status,c==="running"&&e.status!=="running"){o("celebrating"),i.current=setTimeout(()=>o("done"),nh);return}c!=="running"&&e.status==="running"&&(i.current&&clearTimeout(i.current),i.current=null,o("running"))},[e.status]),l.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),s==="done"?r.jsx("div",{className:"relative inline-flex",children:r.jsx(sh,{status:e.status,color:e.color})}):r.jsxs("div",{className:"group relative inline-flex",children:[r.jsx("svg",{className:"h-6 w-[22px] shrink-0",style:{"--c":e.color},viewBox:"0 0 22 24","aria-label":e.description,children:r.jsxs("g",{className:"r-all",style:n,children:[r.jsx("circle",{cx:"11",cy:"4.5",r:"2.8",fill:"var(--c)"}),r.jsx("circle",{cx:"12.3",cy:"3.7",r:"0.6",fill:"hsl(0 0% 100% / 0.7)"}),r.jsx("ellipse",{cx:"11",cy:"10.5",rx:"2.5",ry:"3.5",fill:"var(--c)"}),r.jsxs("g",{className:"r-rua",style:n,children:[r.jsx("line",{x1:"12",y1:"9",x2:"14",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-rfa",style:n,children:r.jsx("line",{x1:"14",y1:"11",x2:"14.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-lua",style:n,children:[r.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"11",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-lfa",style:n,children:r.jsx("line",{x1:"8",y1:"11",x2:"7.5",y2:"13",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-rt",style:n,children:[r.jsx("line",{x1:"11",y1:"14",x2:"13",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-rs",style:n,children:r.jsx("line",{x1:"13",y1:"17",x2:"13.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]}),r.jsxs("g",{className:"r-lt",style:n,children:[r.jsx("line",{x1:"11",y1:"14",x2:"9",y2:"17",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"}),r.jsx("g",{className:"r-ls",style:n,children:r.jsx("line",{x1:"9",y1:"17",x2:"8.5",y2:"21",stroke:"var(--c)",strokeWidth:"1.8",strokeLinecap:"round"})})]})]})}),s==="celebrating"&&r.jsx(th,{color:e.color}),s==="running"&&r.jsxs("div",{"data-testid":"agent-runner-tooltip",className:H("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 hidden","-translate-x-1/2 translate-y-1 opacity-0 transition-[opacity,translate] duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-2xs shadow-lg md:block"),children:[r.jsxs("div",{className:"mb-0.5 flex items-center gap-1.5 font-semibold",children:[r.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.description]}),r.jsxs("div",{className:"text-muted-foreground text-3xs font-mono",children:[e.toolUses??0," tool calls · ",Math.round((e.durationMs??0)/1e3),"s"]}),e.lastToolName&&r.jsxs("div",{className:"text-muted-foreground/60 text-3xs mt-0.5 font-mono",children:["Last: ",e.lastToolName]}),r.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}function oh({bashTasks:e}){const t=Le(),n=e.filter(o=>o.taskType==="bash"),s=n.length;return s===0?null:r.jsxs("div",{role:"status","aria-live":"polite","aria-label":`${s} bash task${s!==1?"s":""} running`,className:"flex items-center gap-1.5",children:[r.jsx(me,{mode:"popLayout",children:n.map(o=>r.jsxs(Q.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.25},className:"relative flex size-3 items-center justify-center",children:[o.status==="running"&&!t&&r.jsx("span",{className:"task-dot-tasks absolute inset-0 rounded-full opacity-40",style:{backgroundColor:o.color,animation:"task-dot-tasks 2s ease-in-out infinite"}}),r.jsx("span",{className:"relative size-1.5 rounded-full",style:{backgroundColor:o.color}})]},o.taskId))}),r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[s," task",s!==1?"s":""]})]})}const ah=3e3;function ih({taskType:e,onConfirm:t}){const[n,s]=l.useState(!1),o=l.useRef(null);l.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),l.useEffect(()=>{if(n)return o.current=setTimeout(()=>{s(!1)},ah),()=>{o.current&&clearTimeout(o.current)}},[n]);const a=l.useCallback(()=>{if(e==="bash"){t();return}n?(o.current&&clearTimeout(o.current),s(!1),t()):s(!0)},[e,n,t]),i=l.useCallback(c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a())},[a]);return r.jsx("button",{onClick:a,onKeyDown:i,className:H("flex shrink-0 items-center justify-center rounded transition-colors duration-150","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-1",n?"bg-destructive/5 text-destructive hover:bg-destructive/10 text-3xs px-1.5 py-0.5 font-medium":"text-muted-foreground/40 hover:text-destructive size-4"),"aria-label":n?"Press again to stop task":"Stop task",tabIndex:0,children:n?"Stop?":r.jsx(ot,{className:"size-3"})})}function sr({task:e,onStop:t}){const n=e.taskType==="agent"?e.description??"Background agent":e.command??"Background task",s=e.durationMs?Math.round(e.durationMs/1e3):0,o=e.status==="running";return r.jsxs("div",{className:H("flex items-center gap-2 rounded-md px-2 py-1 text-xs",o?"bg-muted":"bg-muted/50 opacity-60"),children:[r.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),r.jsx("span",{className:"text-muted-foreground/60 text-3xs shrink-0 tracking-wider uppercase",children:e.taskType}),r.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate",children:n}),e.taskType==="agent"&&e.toolUses!==void 0&&e.toolUses>0&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs shrink-0 font-mono",children:[e.toolUses," tools"]}),e.taskType==="agent"&&e.lastToolName&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs hidden max-w-24 shrink-0 truncate font-mono md:inline",children:["Last: ",e.lastToolName]}),s>0&&r.jsxs("span",{className:"text-muted-foreground/60 text-3xs shrink-0 font-mono",children:[s,"s"]}),o&&r.jsx(ih,{taskType:e.taskType,onConfirm:t})]})}function lh({tasks:e,ambientTasks:t=[],onStopTask:n}){return r.jsx(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"border-border overflow-hidden border-t px-2 py-1.5",children:r.jsxs("div",{className:"flex flex-col gap-1",children:[e.map(s=>r.jsx(sr,{task:s,onStop:()=>n(s.taskId)},s.taskId)),t.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-muted-foreground/60 text-3xs mt-1 px-2",children:[t.length," housekeeping task",t.length!==1?"s":""," the agent runs for itself"]}),t.map(s=>r.jsx(sr,{task:s,onStop:()=>n(s.taskId)},s.taskId))]})]})})}const Dn=4;function ch(e){return e==="stopped"?"complete":e}const uh="relative after:absolute after:-inset-x-1 after:-inset-y-2.5 md:after:hidden",ta=[.16,1,.3,1],dh={width:{duration:.4,ease:ta},opacity:{duration:.25}};function mh({tasks:e,onStopTask:t}){const[n,s]=l.useState(!1),o=Le(),{shown:a,ambient:i}=Li(e),c=a.filter(y=>y.taskType==="agent"),u=a.filter(y=>y.taskType==="bash"),d=a.length,m=c.slice(0,Dn),h=c.length-Dn,p=c.reduce((y,b)=>y+(b.toolUses??0),0),f=Math.max(0,...a.map(y=>Math.round((y.durationMs??0)/1e3))),g=o?{duration:0}:{duration:.35,ease:ta},x=d>0;return r.jsx(me,{children:(d>0||i.length>0)&&r.jsxs(Q.div,{...x?{role:"status","aria-live":"polite","aria-label":`${d} background task${d!==1?"s":""} running`}:{role:"group","aria-label":"Background tasks"},initial:{opacity:0,y:6,maxHeight:0},animate:{opacity:1,y:0,maxHeight:n?400:44},exit:{opacity:0,maxHeight:0},transition:g,className:"border-border bg-card overflow-hidden rounded-lg border",children:[r.jsxs("div",{className:"flex min-h-9 items-center gap-2 px-2 py-1.5",children:[c.length>0&&r.jsx(fh,{visibleAgents:m,overflowAgentCount:h,allAgentTasks:c}),c.length>0&&u.length>0&&r.jsx("div",{className:"bg-border h-4 w-px shrink-0"}),u.length>0&&r.jsx(oh,{bashTasks:u}),d>0&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"text-muted-foreground text-xs whitespace-nowrap",children:[r.jsx("strong",{className:"text-foreground font-semibold",children:d})," task",d!==1?"s":""," running"]}),r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto font-mono whitespace-nowrap",children:[p>0&&r.jsxs(r.Fragment,{children:[p," tools · "]}),f,"s"]})]}),r.jsxs("button",{type:"button",onClick:()=>s(y=>!y),className:H("text-muted-foreground hover:text-foreground flex shrink-0 items-center gap-1 transition-colors duration-150",d>0?"ml-1":"ml-auto",uh),"aria-label":n?"Collapse task details":"Expand task details","aria-expanded":n,children:[d>0&&r.jsx("span",{className:"text-3xs tabular-nums",children:d}),r.jsx(vt,{className:H("size-3.5 transition-transform duration-200",n&&"rotate-180")})]})]}),r.jsx(me,{children:n&&r.jsx(lh,{tasks:a,ambientTasks:i,onStopTask:t})})]},"background-task-bar")})}function fh({visibleAgents:e,overflowAgentCount:t,allAgentTasks:n}){return r.jsxs("div",{className:"flex items-center gap-0",children:[r.jsx(me,{mode:"popLayout",children:e.map((s,o)=>r.jsx(Q.div,{initial:{width:0,opacity:0},animate:{width:22,opacity:1},exit:{width:0,opacity:0},transition:dh,className:"shrink-0",children:r.jsx(rh,{agent:{taskId:s.taskId,description:s.description??"",status:ch(s.status),color:s.color,toolUses:s.toolUses,lastToolName:s.lastToolName,durationMs:s.durationMs,summary:s.summary},index:o})},s.taskId))}),t>0&&r.jsx(ph,{count:t,overflowTasks:n.slice(Dn)})]})}function ph({count:e,overflowTasks:t}){return r.jsxs("div",{className:"group relative",children:[r.jsxs("div",{className:"text-muted-foreground bg-muted text-3xs flex size-6 shrink-0 items-center justify-center rounded-full font-semibold","aria-label":`${e} more helper${e===1?"":"s"} running`,children:["+",e]}),r.jsxs("div",{"data-testid":"overflow-badge-tooltip",className:H("pointer-events-none absolute bottom-[calc(100%+8px)] left-1/2 hidden","-translate-x-1/2 translate-y-1 opacity-0 transition-[opacity,translate] duration-150","group-hover:translate-y-0 group-hover:opacity-100","border-border bg-popover z-10 rounded-lg border px-3 py-2 whitespace-nowrap","text-foreground text-2xs shadow-lg md:block"),children:[t.map(n=>r.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[r.jsx("div",{className:"size-1.5 shrink-0 rounded-full",style:{backgroundColor:n.color}}),r.jsx("span",{className:"text-3xs",children:n.description})]},n.taskId)),r.jsx("div",{className:"border-t-border absolute top-full left-1/2 -translate-x-1/2 border-5 border-transparent"})]})]})}const as="Another chat";function hh(e){const t=e==null?void 0:e[0];if(!t||t.legacy)return null;const{agentName:n,agentId:s,chatId:o,chatTitle:a}=t.from;return{agentName:n,chatId:o,...s?{agentId:s}:{},...a?{chatTitle:a}:{}}}function gh(e){var u;const t=e.filter(d=>d.fromChat);if(t.length===0)return`Queued (${e.length})`;const n=new Map;for(const d of t){const m=((u=d.sender)==null?void 0:u.agentName)??as;n.set(m,(n.get(m)??0)+1)}const[s,o]=[...n].sort((d,m)=>m[1]-d[1])[0],a=n.size-1,i=`${o} from ${s}${a>0?` and ${a} other${a===1?"":"s"}`:""}`,c=e.length-t.length;return c===0?i:`${e.length} queued · ${c} yours, ${i}`}function xh({sender:e}){const t=Qe();if(e===null)return r.jsxs("span",{className:"text-muted-foreground flex min-w-0 items-center gap-1 text-xs",children:[r.jsx(Ui,{className:"size-3 shrink-0","aria-hidden":"true"}),r.jsx("span",{className:"min-w-0 truncate",children:as})]});const{color:n,emoji:s}=lt({id:e.agentId??e.agentName});return r.jsxs("span",{className:"text-muted-foreground flex min-w-0 flex-wrap items-center gap-x-1 text-xs",children:[r.jsxs("span",{className:"flex max-w-full shrink-0 items-center gap-1",children:[r.jsx(Bn,{color:n,emoji:s,size:"xs",className:"shrink-0"}),r.jsx("span",{className:"text-foreground truncate font-semibold",children:e.agentName})]}),r.jsxs("span",{className:"max-w-full min-w-0 truncate",children:["from"," ",e.chatTitle?r.jsx("a",{href:qi({session:e.chatId}),onClick:o=>{o.preventDefault(),o.stopPropagation(),t(ct({session:e.chatId}))},className:"focus-ring rounded-sm underline-offset-4 hover:underline",children:e.chatTitle}):"another chat · can’t open"]})]})}const bn="after:absolute after:-inset-1 md:after:hidden";function yh({queue:e,editingId:t,onEdit:n,onRemove:s,onSend:o,onMoveUp:a,statusNote:i,onSwitchNow:c}){return e.length===0?null:r.jsxs(Q.div,{variants:We,initial:"initial",animate:"animate",exit:"exit",transition:Be,className:"mb-1.5 overflow-hidden",children:[r.jsxs("div",{className:"text-muted-foreground mb-1 flex items-baseline gap-1 text-xs",children:[r.jsx("span",{className:"font-medium",children:gh(e)}),r.jsxs("span",{className:"truncate",children:["· ",i]})]}),r.jsx("div",{className:"space-y-0.5",children:r.jsx(me,{mode:"popLayout",children:e.map((u,d)=>{var m;return r.jsx(Q.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{type:"spring",stiffness:320,damping:28}},exit:{opacity:0,scale:.95,transition:{duration:.15}},layout:!0,children:r.jsxs("div",{className:H("group flex w-full items-center gap-2 rounded-md border-l-2 border-l-transparent pr-2 transition-colors md:gap-1",t===u.id?"border-l-primary bg-muted":"hover:bg-muted/50"),children:[u.fromChat?r.jsxs("div",{role:"group","aria-label":`From ${((m=u.sender)==null?void 0:m.agentName)??as}: ${u.content}`,className:"flex min-w-0 flex-1 items-center gap-2 py-1.5 pl-3",children:[r.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[d+1,"."]}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx(xh,{sender:u.sender??null}),r.jsx("span",{className:"text-muted-foreground line-clamp-1 text-sm",children:u.content}),u.notice!==null&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.notice}),u.waiting!==void 0&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.waiting.line})]})]}):r.jsxs("button",{type:"button",onClick:()=>n(u.id),"aria-current":t===u.id?!0:void 0,className:"focus-ring flex min-w-0 flex-1 items-center gap-2 rounded-md py-1.5 pl-3 text-left",children:[r.jsxs("span",{className:"text-muted-foreground shrink-0 text-xs font-medium",children:[d+1,"."]}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"text-muted-foreground line-clamp-1 text-sm",children:u.content}),u.notice!==null&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.notice}),u.waiting!==void 0&&r.jsx("span",{className:"text-muted-foreground/70 line-clamp-1 text-xs",children:u.waiting.line})]}),!u.mine&&r.jsxs("span",{className:"text-muted-foreground/60 flex shrink-0 items-center",title:"Queued from another window",children:[r.jsx(An,{className:"size-3","aria-hidden":"true"}),r.jsx("span",{className:"sr-only",children:"Queued from another window"})]})]}),u.waiting!==void 0&&c!==void 0&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:c,title:u.waiting.switchHint,"aria-describedby":`switch-now-${u.id}`,className:"focus-ring text-muted-foreground hover:text-foreground shrink-0 rounded-sm px-1.5 py-1 text-xs font-medium transition-colors",children:"Switch now"}),r.jsx("span",{id:`switch-now-${u.id}`,className:"sr-only",children:u.waiting.switchHint})]}),d>0&&r.jsx("button",{type:"button",onClick:()=>a(u.id),className:H("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100",bn),"aria-label":`Move queued message ${d+1} earlier`,children:r.jsx(zi,{className:"size-3"})}),d>0&&r.jsx("button",{type:"button",onClick:()=>o(u.id),"aria-label":`Send queued message ${d+1} next`,className:H("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm transition-colors",bn),children:r.jsx(vu,{className:"size-3"})}),r.jsx("button",{type:"button",onClick:()=>s(u.id),className:H("focus-ring text-muted-foreground hover:text-foreground relative flex size-6 shrink-0 items-center justify-center rounded-sm opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100",bn),"aria-label":`Remove queued message ${d+1}`,children:r.jsx(ot,{className:"size-3"})})]})},u.id)})})})]})}function bh({open:e,onOpenChange:t,queuedCount:n,fromChatCount:s=0,onConfirm:o}){const a=n===1?"message":"messages",i=s===1?"message":"messages";return r.jsx(Bi,{open:e,onOpenChange:t,children:r.jsxs(Wi,{children:[r.jsxs(Hi,{children:[r.jsx(Gi,{children:n>0?`Stop, and put ${n} queued ${a} back?`:`Stop, and cancel ${s} ${i} from other chats?`}),r.jsxs(Ki,{children:[n>0?`The agent stops. Your ${a} ${n===1?"goes":"go"} back to the composer.`:"The agent stops. Those messages are not delivered.",n>0&&s>0?r.jsx("span",{className:"block",children:`${s} from other chats ${s===1?"is":"are"} cancelled.`}):null]})]}),r.jsxs(Qi,{children:[r.jsx(Vi,{children:"Keep going"}),r.jsx(Yi,{onClick:o,children:"Stop"})]})]})})}const kh={initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4}},vh={duration:.3,ease:"easeInOut"};function Sh({text:e,animationKey:t}){return r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-start overflow-hidden py-0.5",children:r.jsx(me,{mode:"wait",children:r.jsx(Q.span,{variants:kh,initial:"initial",animate:"animate",exit:"exit",transition:vh,className:"text-muted-foreground truncate text-sm",children:e},t)})})}function jh(e){const t=be();return ut({queryKey:["workspace-for-session",e??null],queryFn:()=>t.resolveWorkspace(e),enabled:!!e}).data??null}async function na(e,t,n){try{return await e.runCommandIntent(t,"compact",n),!0}catch(s){const o=s.code==="SESSION_LOCKED";return Oe.error(o?"Your agent is busy. Try again in a moment.":"Couldn’t compact the chat."),!1}}function sa(e){const t=/^\/(\S+)([\s\S]*)$/.exec(e.trim());return t?{token:t[1],rest:t[2].trim()}:null}function wh(e){const t=sa(e);return t?Yr(t.token)?!0:yo(e.trim())!==null:!1}function Nh(e,t,n={}){const{mutateAsync:s}=Xi(e),o=be(),{startFreshSession:a,compact:i}=n,[c,u]=l.useState(0),d=l.useCallback(h=>{u(f=>f+1);const p=()=>u(f=>Math.max(0,f-1));h.then(p,p)},[]);return{tryRun:l.useCallback(h=>{const p=sa(h),f=p?Yr(p.token):null;if(p&&(f==null?void 0:f.fulfillment)==="runtime"&&i){if(!i.supported)return Oe.error(`Compact isn’t available on ${i.runtimeLabel||"this agent"}`),{handled:!0,ran:!1};if(!t)return Oe.error("No open chat to compact"),{handled:!0,ran:!1};const b=na(o,t,p.rest||void 0);return d(b),{handled:!0,ran:!0,confirmed:b}}const g=yo(h);if(!g)return{handled:!1};let x;return{handled:!0,ran:g.command.run(g.args,{sessionId:t,renameSession:b=>{t&&(x=s({sessionId:t,title:b}).then(()=>(Oe.success(`Renamed chat to “${b}”`),!0),()=>!1),d(x))},notify:(b,v)=>v==="error"?Oe.error(b):Oe.success(b),startFreshSession:b=>a==null?void 0:a(b),focusUsageSurface:()=>En.getState().reveal()}),...x?{confirmed:x}:{}}},[s,o,t,a,i,d]),commandPending:c>0}}function ra(e,t){return{supported:(e==null?void 0:e.compact.supported)!==!1,runtimeLabel:t}}function rr(e){const t=e.trim().toLowerCase();return t.startsWith("/")?t:`/${t}`}function Ch(e){return Zi.map(t=>{var s,o;const n=t.fulfillment==="runtime"&&((o=(s=e==null?void 0:e.commandIntents)==null?void 0:s[t.id])==null?void 0:o.supported)===!1;return{command:t.id,fullCommand:t.canonical,description:t.description,argumentHint:t.argumentHint,aliases:[...t.aliases],...n?{disabled:!0,disabledReason:`Not available on ${e.runtimeLabel}`}:{}}})}function Th(e,t){const n=Ji(),s=Ch(t),o=Ps.filter(c=>!(c.command!==void 0&&n.has(`/${c.command}`))),a=new Set(Ps.map(c=>c.command)),i=e.filter(c=>{if(c.command!==void 0&&a.has(c.command))return!1;const u=[c.fullCommand,...c.aliases??[]].map(rr);return c.command!==void 0&&u.push(rr(c.command)),!u.some(d=>n.has(d))});return[...s,...o,...i]}const Rh=3e4;function Eh({percent:e,compactSupported:t,isStreaming:n}){return!(e===null||e<el||!t||n)}function Ah({sessionId:e,percent:t,compactSupported:n,isStreaming:s}){const o=be(),[a,i]=l.useState(!1),c=l.useRef(!1),u=l.useRef(null),d=l.useCallback(()=>{c.current=!1,i(!1),u.current!==null&&(clearTimeout(u.current),u.current=null)},[]);l.useEffect(()=>{s&&c.current&&d()},[s,d]),l.useEffect(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);const m=l.useCallback(()=>{c.current||!e||(c.current=!0,i(!0),u.current=setTimeout(()=>{u.current=null,c.current=!1,i(!1)},Rh),na(o,e).then(h=>{h||d()}))},[e,o,d]);return{visible:Eh({percent:t,compactSupported:n,isStreaming:s}),percent:t??0,pending:a,onCompact:m}}function _h({children:e,onSwitchAgent:t,onViewProfile:n,onNewSession:s}){return r.jsxs(tl,{children:[r.jsx(nl,{className:"min-w-0",children:e}),r.jsxs(sl,{className:"w-48",children:[r.jsxs(ln,{onClick:t,children:[r.jsx(rl,{className:"mr-2 size-4"}),"Switch agent"]}),r.jsx(Cs,{}),r.jsxs(ln,{onClick:n,children:[r.jsx(ol,{className:"mr-2 size-4"}),"View profile"]}),r.jsx(Cs,{}),r.jsxs(ln,{onClick:s,children:[r.jsx(Pr,{className:"mr-2 size-4"}),"New chat"]})]})]})}function Mh({agentName:e,agentColor:t,agentEmoji:n,agentPath:s,nameHidden:o}){const a=al(s),{open:i}=il(),c=l.useCallback(()=>{s&&ll.getState().openProfileDocked(s)},[s]),u=l.useCallback(()=>{if(a===void 0)return c();i(a)},[a,i,c]),d=l.useCallback(()=>{ie.getState().openGlobalPaletteWithSearch("@")},[]),m=Br(),h=l.useCallback(()=>{m(s??void 0)},[m,s]);return!e||!t||!n?null:r.jsx("span",{className:"inline-flex min-w-0 items-center",children:s?r.jsx(_h,{onSwitchAgent:d,onViewProfile:u,onNewSession:h,children:r.jsx(Ts,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,onClick:u,className:"max-w-full"})}):r.jsx(Ts,{size:"xs",name:e,color:t,emoji:n,nameHidden:o,className:"max-w-full"})})}function Oh({sessionId:e,account:t}){const[n,s]=l.useState(!1),[o,a]=l.useState(!1),i=l.useRef(null);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:i,className:"contents",children:r.jsx(cl,{sessionId:e,account:t,open:n,onOpenChange:s,onContinue:()=>{s(!1),a(!0)}})}),r.jsx(Go,{open:o,onOpenChange:a,sessionId:e,account:t,onCloseAutoFocus:c=>{var d;const u=(d=i.current)==null?void 0:d.querySelector("button");u&&(c.preventDefault(),u.focus())}})]})}function Ih({ctx:e,items:t}){return r.jsx("span",{className:"inline-flex min-w-0 items-center gap-2",children:t.map((n,s)=>{const o=n.component;return r.jsxs(l.Fragment,{children:[s>0&&r.jsx("span",{className:"text-muted-foreground/30 shrink-0","aria-hidden":"true",children:"·"}),r.jsx("span",{role:"group","aria-label":n.label,"data-testid":`extension-status-item-${n.id}`,className:"inline-flex min-w-0 items-center",children:r.jsx(Xr,{fallback:null,onError:a=>oa(n,a),children:r.jsx(o,{...e})})})]},n.id)})})}function oa(e,t){console.warn(`[extensions] ${e.extensionId}'s status-bar item "${e.id}" failed to draw and is hidden.`,t)}function Dh({ctx:e,items:t}){return r.jsx(r.Fragment,{children:t.map(n=>{const s=n.component;return r.jsxs("div",{role:"group","aria-label":n.label,"data-testid":`session-row-extension-${n.id}`,className:"flex items-center gap-2 px-1 py-1 text-sm",children:[r.jsx("span",{className:"shrink-0",children:n.label}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("span",{className:"text-muted-foreground inline-flex min-w-0 items-center text-xs",children:r.jsx(Xr,{fallback:null,onError:o=>oa(n,o),children:r.jsx(s,{...e})})})]},n.id)})})}function Ph(e){const{costUsd:t,costBasis:n,...s}=e;return s}function $h(e){var m;const{sessionId:t,agent:n,status:s,runtimeChip:o,onUpdateSession:a}=e,i={},c=e.density!=="full";n.name&&n.color&&n.emoji&&(i.agent=r.jsx(Mh,{agentName:n.name,agentColor:n.color,agentEmoji:n.emoji,agentPath:n.path,nameHidden:e.density==="avatar"})),s.cwd&&(i.cwd=r.jsx(vc,{cwd:s.cwd})),e.gitStatus&&(i.git=r.jsx(Ac,{data:e.gitStatus,workspace:e.workspace,compact:c})),o.runtime!==null&&(i.runtime=r.jsx(Sc,{runtime:o.runtime,model:o.model,onChangeRuntime:o.onChangeRuntime,canSelect:o.canSelect,account:o.account,compact:!0,iconOnly:uo(e.density)}));const u=Jr(e.account);u!==null&&(i.account=r.jsx(Oh,{sessionId:t,account:e.account})),e.extensions.items.length>0&&(i.extensions=r.jsx(Ih,{ctx:e.extensions.ctx,items:e.extensions.items})),i.model=r.jsx(jc,{model:s.model,onChangeModel:h=>a({model:h}),effort:s.effort,onChangeEffort:h=>a({effort:h??void 0}),fastMode:s.fastMode,onChangeFastMode:h=>a({fastMode:h}),disabled:!t,sessionId:t||void 0,runtime:o.runtime,onCredits:e.account.onCredits,compact:c}),(m=e.plan)!=null&&m.active||(i.permission=r.jsx(wc,{mode:s.permissionMode,onChangeMode:e.onChangeMode,disabled:!t,pending:!s.permissionModeKnown,runtime:o.runtime,modelSupportsAutoMode:e.modelSupportsAutoMode,compact:c,makeDefault:e.makeDefault,onOpenChange:e.onPermissionPickerOpenChange})),e.plan&&(i.plan=r.jsx(Nc,{descriptor:e.plan.descriptor,active:e.plan.active,onToggle:e.plan.onToggle,disabled:!t})),e.contextPercent!==null&&(i.context=r.jsx(Cc,{percent:e.contextPercent,contextUsage:e.contextUsage,compact:e.compact,reading:e.contextReading}));const d=e.usage&&e.usageSource==="account"&&!e.supportsCostTracking?Ph(e.usage):e.usage;return d&&ul(d)&&(e.supportsCostTracking||e.usageSource==="account")&&!Tc({account:u})&&(i.usage=r.jsx(dl,{usage:d,observedAt:e.usageObservedAt,now:e.now})),e.liveSubagentCount>0&&(i.subagents=r.jsx(Rc,{count:e.liveSubagentCount,running:e.runningSubagents,waiting:e.waitingOnSubagents})),i.connection=r.jsx(Ec,{connectionState:e.connectionState,compact:c}),i}function Fh({compaction:e}){return r.jsxs("div",{"data-testid":"dm-safety-line",className:"text-muted-foreground flex items-center gap-2 pt-2 text-xs empty:hidden empty:p-0",children:[r.jsx(mo,{compact:!1}),e.visible&&r.jsxs("span",{className:"flex items-center gap-1.5","data-testid":"dm-compact-warning",children:[r.jsxs("span",{className:"text-status-warning-fg",children:["Context ",e.percent,"% full"]}),r.jsx("button",{type:"button",onClick:e.onCompact,disabled:e.pending,className:"focus-ring text-foreground/80 hover:text-foreground rounded-sm underline-offset-4 hover:underline disabled:opacity-50",children:e.pending?"Compacting…":"Compact chat"})]})]})}const Lh=[],Uh="(max-width: 639px)";function qh({sessionId:e,sessionStatus:t,isStreaming:n,syncConnectionState:s,agentName:o,agentColor:a,agentEmoji:i,agentPath:c,lineHidden:u=!1}){var ze,Y;const{ref:d,budget:m}=_c(),h=ml(),p=Zr(e),f=eo(e,t,n,p.runtime),g=Nt(e||null),{pins:x}=Mc(),y=to(e),b=Oc(e,g,y.usage),v=b.usage,j=jt(),S=new Date(j),T=fl(v,b.observedAt,S),R=y.contextUsage,E=((ze=Jn(e))==null?void 0:ze.contextUsage)??null,O=En(U=>U.open),A=En(U=>U.setOpen),{data:I}=pl(f.cwd),F=jh(f.cwd),{project:N}=hl(f.cwd),k=gl(Uh),C=l.useMemo(()=>({sessionId:e,cwd:f.cwd,project:N,trackerItems:g.trackerItems,compact:k}),[e,f.cwd,N,g.trackerItems,k]),w=Ic(C),{data:P}=Yn(),M=xl(y.activeSubagents).running,D=y.runningSubagentCount??M.length,{data:W}=Xt({sessionId:e||void 0,runtime:p.runtime??void 0}),G=((Y=W==null?void 0:W.find(U=>U.value===f.model))==null?void 0:Y.supportsAutoMode)??!1,V=Jt(p.runtime),B=(V==null?void 0:V.permissionModes.values)??Lh,L=V==null?void 0:V.permissionModes.default,X=yl(e),_=re(U=>U.recordAutoConfirmed),[q,te]=l.useState(!1),$=Dc({sessionId:e,runtime:p.runtime,declaredModes:B,runtimeDefaultMode:L}),[J,oe]=l.useState(!1),ne=l.useCallback(U=>f.updateSession({permissionMode:U}),[f]),de=l.useCallback(U=>{if(U==="auto"&&!X){te(!0);return}ne(U).then(ce=>{ce&&$.offerFor(U)})},[X,ne,$,te]),K=l.useCallback(()=>{_(e),ne("auto"),te(!1)},[_,e,ne,te]),Z=bl(B),je=Z!==void 0&&f.permissionMode===Z.id,ke=kl(e),ee=re(U=>U.recordModeBeforePlan),we=l.useCallback(U=>{if(!Z)return;if(U){ee(e,f.permissionMode),ne(Z.id);return}const ce=ke,Re=ce!==void 0&&B.some(se=>se.id===ce)&&(ce!=="auto"||G)?ce:L;Re&&ne(Re)},[Z,ee,e,f,ne,ke,B,G,L]),ve=p.runtime?St(p.runtime).label:"",qe=ra(V==null?void 0:V.commandIntents,ve),he=y.contextPercent,ge=Ah({sessionId:e,percent:he,compactSupported:qe.supported,isStreaming:n}),[Te,le]=l.useState(!1);Pc(()=>!u&&le(U=>!U));const _e={cwd:f.cwd,git:vl(I)?$c(I.branch,I.clean,I.detached):null,contextPercent:he,connectionState:s,permissionMode:f.permissionMode,permissionDescriptor:(V==null?void 0:V.permissionModes.values.find(U=>U.id===f.permissionMode))??null,permissionPickerOpen:J,onWifi:h,plan:Z?{active:je}:null,runtime:p.runtime===null||P===void 0?null:{type:p.runtime,isDefault:p.runtime===P.defaultRuntime,canSelect:p.canSelect},account:Jr(g),usage:v,usageStale:T,subagentsInFlight:D,extensionItems:w.promotion},pe=ge.visible&&m.density==="full",Se=ge.visible&&!pe,xe=$h({sessionId:e,agent:{name:o,color:a,emoji:i,path:c},status:f,onUpdateSession:f.updateSession,onChangeMode:de,makeDefault:J?$.line:null,onPermissionPickerOpenChange:oe,modelSupportsAutoMode:G,plan:Z?{descriptor:Z,active:je,onToggle:we}:null,gitStatus:I,workspace:F,runtimeChip:p,account:g,contextPercent:he,contextUsage:R,contextReading:E,compact:pe?{pending:ge.pending,onCompact:ge.onCompact}:null,usage:v,usageSource:b.source,usageObservedAt:b.observedAt,now:S,supportsCostTracking:(V==null?void 0:V.supportsCostTracking)??!0,runningSubagents:M,liveSubagentCount:D,waitingOnSubagents:y.lifecycle==="idle",connectionState:s,density:m.density,extensions:{ctx:C,items:w.visible}}),{items:Me,overflow:$e}=Fc(Lc({ctx:_e,pins:x,nodes:xe,density:m.density}),m);return r.jsxs("div",{ref:d,className:u?"relative":"relative pt-2",children:[!u&&!J&&$.line&&r.jsx(Uc,{...$.line,placement:"overlay"}),u&&r.jsx(Fh,{compaction:ge}),!u&&r.jsx(qc,{items:Me,nameFirst:uo(m.density),trailing:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(mo,{compact:m.density!=="full"}),r.jsx(zc,{open:Te,onOpenChange:le,diagnostics:y,controls:{plan:Z?{active:je,onToggle:we}:null},promotionContext:_e,overflowCount:$e,addOns:w.visible.length>0?r.jsx(Dh,{ctx:C,items:w.visible}):void 0,urgentAction:Se?{label:`Compact chat · ${ge.percent}% full`,onAction:ge.onCompact,pending:ge.pending}:null})]})}),r.jsx(Bc,{usage:v??null,accountUsage:b.accountUsage,observedAt:b.observedAt,open:O,onOpenChange:A}),r.jsx(Wc,{open:q,onOpenChange:te,onConfirm:K})]})}const zh=Object.freeze({completed:"Completed",aborted_tools:"Tool stopped",aborted_streaming:"Reply stopped",max_turns:"Turn limit reached",blocking_limit:"Blocking limit",rapid_refill_breaker:"Rate limit",prompt_too_long:"Prompt too long",image_error:"Image error",model_error:"Model error",stop_hook_prevented:"Stopped by hook",hook_stopped:"Hook stopped",tool_deferred:"Tool deferred"});function Bh(e){return e!==void 0&&e!=="completed"}function Wh(e){const t=zh[e];return t!==void 0?t:Hh(e)}function Hh(e){if(e.length===0)return"Ended";const t=e.replace(/[_-]+/g," ").trim().split(/\s+/);if(t.length===0)return"Ended";const[n,...s]=t;return[n.charAt(0).toUpperCase()+n.slice(1).toLowerCase(),...s.map(a=>a.toLowerCase())].join(" ")}function Gh({terminalReason:e}){const t=Bh(e),n=t?Wh(e):"";return r.jsx(me,{children:t&&r.jsx(Q.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,ease:"easeOut"},className:"flex px-4 py-1","data-testid":"terminal-reason-chip",children:r.jsx(Sl,{variant:"secondary","aria-label":`Chat ended: ${n}`,children:n})},e)})}const Kh="The turn ended before completing.";function Qh({sessionId:e,onRetry:t,onSigninComplete:n,onChooseModel:s}){var p;const o=en(e),a=((p=Jn(e))==null?void 0:p.lastError)??null,i=(a==null?void 0:a.category)==="auth_error"||(a==null?void 0:a.category)==="model_unavailable"||(a==null?void 0:a.category)==="runtime_update_required",c=!i&&o?`${St(o).label} stopped unexpectedly`:void 0,u=(a==null?void 0:a.message)??Kh,d=i?void 0:u,m=o?zn(o):void 0,h=a?[a.code,a.details].filter(Boolean).join(`
|
|
39
|
+
`):void 0;return r.jsx(Q.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:.3,duration:.2,ease:"easeOut"},className:"mx-4 mb-2","data-testid":"turn-failed-notice",children:r.jsx(nn,{category:(a==null?void 0:a.category)??"execution_error",heading:c,message:u,subtext:d,details:h||void 0,onRetry:t,onSigninComplete:n,onChooseModel:s,runtimeLabel:m,sessionId:e,...a!=null&&a.code?{code:a.code}:{},...a!=null&&a.reason?{reason:a.reason}:{}})})}const Vh=["Type @ to mention a file","Type / to browse commands","End a line with \\ to keep typing","Drop or paste files to attach"];function Yh(e,t,n){const s=l.useCallback(g=>{var v;if(!e||!t.current)return;const x=re.getState(),y=(v=n.current)==null?void 0:v.get(e);if(y!==void 0&&x.getSession(e).mountGeneration!==y)return;const b=typeof g=="function"?g(x.getSession(e).messages):g;x.updateSession(e,{messages:b})},[e,t,n]),o=l.useCallback(g=>{e&&re.getState().updateSession(e,{input:g})},[e]),a=l.useCallback(g=>{e&&re.getState().updateSession(e,{status:g})},[e]),i=l.useCallback(g=>{e&&re.getState().updateSession(e,{error:g})},[e]),c=l.useCallback(g=>{e&&re.getState().updateSession(e,{sessionStatus:g})},[e]),u=l.useCallback(g=>{e&&re.getState().updateSession(e,{estimatedTokens:g})},[e]),d=l.useCallback(g=>{e&&re.getState().updateSession(e,{streamStartTime:g})},[e]),m=l.useCallback(g=>{e&&re.getState().updateSession(e,{isTextStreaming:g})},[e]),h=l.useCallback(g=>{e&&re.getState().updateSession(e,{systemStatus:g})},[e]),p=l.useCallback(g=>{e&&re.getState().updateSession(e,{operationProgress:g})},[e]),f=l.useCallback(g=>{e&&re.getState().updateSession(e,{promptSuggestions:g})},[e]);return{setMessages:s,setInput:o,setStatus:a,setError:i,setSessionStatus:c,setEstimatedTokens:u,setStreamStartTime:d,setIsTextStreaming:m,setSystemStatus:h,setOperationProgress:p,setPromptSuggestions:f}}function Xh({sessionId:e,sid:t,transport:n,sessionCwd:s,enableMessagePolling:o,isStreaming:a,streamHydrated:i,setMessages:c}){const u=wo(),d=s.cwd,m=l.useRef(d);l.useEffect(()=>{m.current=d},[d]);const h=l.useRef(i);l.useEffect(()=>{h.current=i},[i]);const p=ut({queryKey:["messages",e,d],queryFn:()=>n.getMessages(e,d??void 0,{newest:!0}),staleTime:Ge.MESSAGE_STALE_TIME_MS,refetchOnWindowFocus:!1,enabled:e!==null&&!i,refetchInterval:()=>a||!o?!1:u?Ge.ACTIVE_TAB_REFETCH_MS:Ge.BACKGROUND_TAB_REFETCH_MS});return l.useEffect(()=>{const f=re.getState();t&&f.updateSession(t,{historySeeded:!1}),f.getSession(e??"").status!=="streaming"&&c([])},[e,d,t,c]),l.useEffect(()=>{if(!p.data)return;const f=p.data.messages,g=re.getState().getSession(t).historySeeded;if(!g&&f.length>0){if(a)return;if(t&&re.getState().updateSession(t,{historySeeded:!0}),e&&!h.current){const x=p.data.earlierMessages??0;Fe.getState().noteSnapshot(e,f[0].id,x)}c(f.map(nt));return}g&&!a&&Pm(re.getState().getSession(t).messages,f,c)},[p.data,a,e,t,c]),{historyQuery:p}}function aa(e,t){if(e===t)return;const{opened:n,counts:s,mergeUsage:o}=rt.getState(),a=Rs("session",e),i=Date.parse(n[a]??"");Number.isNaN(i)||o([{key:Rs("session",t),lastUsedAt:i,useCount:s[a]??1}])}function Pn(e,t,n){e&&n.then(s=>{if(!s)return;const o=re.getState();o.getSession(e).input.trim()===t.trim()&&o.updateSession(e,{input:""})},()=>{})}const It=new Map;function Jh(e,t){const s=(It.get(e)??Promise.resolve()).then(t),o=s.then(()=>{},()=>{});return It.set(e,o),o.then(()=>{It.get(e)===o&&It.delete(e)}),s}const Ze=new Set;function or(e){var o;const t=e,n=typeof(t==null?void 0:t.code)=="string"?t.code:void 0,s=(o=t==null?void 0:t.body)==null?void 0:o.agentId;return{...n?{code:n}:{},...typeof s=="string"?{agentId:s}:{}}}function Zh({sessionId:e,input:t,status:n,transport:s,queryClient:o,selectedCwd:a,onSessionIdChangeReplace:i,transformContent:c,launchRuntime:u,agentPath:d,agentLookupPending:m,agentLookupFailed:h,launchAccount:p,takeSeedContext:f,setInput:g,setError:x,tryNativeCommand:y}){const b=l.useRef(a);l.useEffect(()=>{b.current=a},[a]);const v=l.useRef(u);l.useEffect(()=>{v.current=u},[u]);const j=l.useRef(p);l.useEffect(()=>{j.current=p},[p]);const{data:S}=Yn(),T=l.useRef(S==null?void 0:S.defaultRuntime);l.useEffect(()=>{T.current=S==null?void 0:S.defaultRuntime},[S==null?void 0:S.defaultRuntime]);const R=jl(e,u),E=l.useRef(R.mode);l.useEffect(()=>{E.current=R.mode},[R.mode]);const O=l.useRef(c);l.useEffect(()=>{O.current=c});const A=l.useRef(f);l.useEffect(()=>{A.current=f});const I=l.useRef(i);l.useEffect(()=>{I.current=i});const F=l.useCallback(async(B,L,X={})=>{var Z,je,ke;if(!X.kickoff){const ee=y(B);if(ee.handled){L&&ee.ran&&(ee.confirmed?Pn(e,B,ee.confirmed):g(""));return}}const _=e,q=X.cwd??b.current;x(null);const te=o.getQueryData(He.list(q))??[],$=cn(_),J=($==null?void 0:$.draft)??!te.some(ee=>ee.id===_),oe=($==null?void 0:$.draft)===!1?!1:J||Ze.has(_);if(oe&&(m||h))return;oe&&Ze.add(_),X.kickoff||(rt.getState().recordOpened("session",_),q&&rt.getState().recordOpened("agent",q)),pt.attachSession(_,q);let ne;try{ne=!X.kickoff&&O.current?await O.current(B):B}catch(ee){if(X.kickoff)throw ee;x({heading:"Couldn’t send message",message:ee.message||"The attachment didn’t upload. Try again.",retryable:!1});return}const de=Ce.getState();if(J){const ee=new Date().toISOString();Es(o,q,{id:_,title:`Chat ${_.slice(0,8)}`,createdAt:ee,updatedAt:ee,permissionMode:((Z=o.getQueryData(He.detail(_,q)))==null?void 0:Z.permissionMode)??E.current??"default",runtime:v.current??T.current??"claude-code"})}const K=crypto.randomUUID();X.kickoff||de.setOptimisticUserMessage(_,{id:K,content:B}),de.setTriggerPending(_,!0),L&&g("");try{const ee=As(ie.getState(),q??null),{uiState:we,commit:ve}=_s(_,ee),he={clientMessageId:K,context:we?{uiState:we}:void 0};oe&&(he.create=!0),oe&&v.current&&(he.runtime=v.current),oe&&d&&(he.agentPath=d),oe&&j.current&&(he.account=j.current);const ge=ie.getState().retryAccount;(ge==null?void 0:ge.sessionId)===_&&(he.account=ge.id,ie.getState().setRetryAccount(null));const Te=(je=A.current)==null?void 0:je.call(A);Te&&(he.seedContext=Te);const{sessionId:le}=await s.postMessage(_,ne,q??void 0,he);if(Ze.delete(_),$){const pe={...$,draft:!1};un(_,pe),un(le,pe)}if(ve(le),le!==_){Ce.getState().migrateSessionContinuity(_,le),ie.getState().carryCanvasWritesAcross(_,le),pt.attachSession(le,q),aa(_,le),et.getState().migrate(_,le);const pe=o.getQueryData(He.list(q))??[],Se=pe.find(xe=>xe.id===_);Se&&!pe.some(xe=>xe.id===le)&&Es(o,q,{...Se,id:le}),o.setQueryData(He.list(q),xe=>xe==null?void 0:xe.filter(Me=>Me.id!==_))}(ke=I.current)==null||ke.call(I,le);const _e=le;setTimeout(()=>{var xe;const pe=ht.getState().rekeys[_e]??_e,Se=Ce.getState().getSession(pe);Se.triggerPending&&((xe=Se.status)==null?void 0:xe.lifecycle)!=="streaming"&&Ce.getState().setTriggerPending(pe,!1)},Yt.TRIGGER_PENDING_TIMEOUT_MS)}catch(ee){if(Ce.getState().setOptimisticUserMessage(_,null),Ce.getState().setTriggerPending(_,!1),X.kickoff)throw ee;x({heading:"Couldn’t send message",message:ee.message||"Couldn’t reach DorkOS. Try again.",retryable:!0,...or(ee)})}},[e,s,o,g,x,y,d,m,h]),N=l.useCallback(async(B,L)=>{!B.trim()||n==="streaming"||await F(B.trim(),(L==null?void 0:L.clearInput)===!0,{...L!=null&&L.cwd?{cwd:L.cwd}:{}})},[n,F]),k=l.useCallback(()=>N(t,{clearInput:!0}),[t,N]),C=l.useCallback(async(B,L,X)=>{if(!e)return!1;const _=e,q=b.current;x(null);const te=(o.getQueryData(He.list(q))??[]).some(J=>J.id===_),$=cn(_);return(($==null?void 0:$.draft)??!te)&&Ze.add(_),Jh(_,async()=>{var oe;let J;try{J=O.current?await O.current(B):B}catch(ne){return x({heading:X,message:ne.message||"The attachment didn’t upload. Try again.",retryable:!1}),!1}try{const ne=As(ie.getState(),q??null),{uiState:de,commit:K}=_s(_,ne),Z={...de?{uiState:de}:{},...L==="queue"?{queued:!0}:{}},je=Object.keys(Z).length>0?Z:void 0,ke=((oe=cn(_))==null?void 0:oe.draft)===!1?!1:Ze.has(_);if(ke&&(m||h))return!1;const{sessionId:ee}=await s.postMessage(_,J,q??void 0,{context:je,disposition:L,...ke?{create:!0,...v.current&&{runtime:v.current},...j.current&&{account:j.current},...d&&{agentPath:d}}:{}});return ke&&Ze.delete(_),$&&un(ee,{...$,draft:!1}),K(ee),!0}catch(ne){return x({heading:X,message:ne.message||"Couldn’t reach DorkOS. Try again.",retryable:!1,...or(ne)}),!1}})},[e,s,o,x,d,m,h]),w=l.useCallback(B=>C(B,"queue","Couldn’t queue message"),[C]),P=l.useCallback(B=>C(B,"steer","Couldn’t steer the agent"),[C]),M=l.useCallback(B=>C(B,"stage","Couldn’t add context"),[C]),D=l.useCallback(async()=>{if(!e)return{receipt:{outcome:"not-running",reason:"no-open-turn",runtime:"unknown"},cancelled:[]};try{const{receipt:B,cancelledQueued:L}=await s.interruptSession(e);return{receipt:B,cancelled:L??[]}}catch{return{receipt:{outcome:"failed",reason:"delivery-failed",runtime:"unknown"},cancelled:[]}}},[e,s]),W=l.useCallback(async B=>{x(null),await F(B,!1)},[F,x]),G=l.useCallback(async(B,L)=>{await F(B,!1,{kickoff:!0,...L?{cwd:L}:{}})},[F]),V=l.useCallback((B,L)=>{},[]);return{handleSubmit:k,submitContent:N,enqueueContent:w,steerContent:P,addContextContent:M,stop:D,retryMessage:W,submitKickoff:G,markToolCallResponded:V}}const Dt=new Set,ar=new Set,Pt=new Set;function eg(e){var t;return e.role==="user"||e.content.trim().length>0||(((t=e.toolCalls)==null?void 0:t.length)??0)>0?!0:e.parts.some(n=>n.type==="tool_call")}function tg({sessionId:e,cwd:t,status:n,messages:s,hydrated:o,canStart:a=!0,submitKickoff:i,submitContent:c}){const u=Vt(e),d=s.length,m=s.some(eg);l.useEffect(()=>{if(!e)return;if(!u){t&&d===0&&n==="idle"&&et.getState().claimByPath(t,e);return}if(u.fired||Dt.has(e)||!a||d>0||n!=="idle")return;Dt.add(e),et.getState().markFired(e);const h=u.kind==="first-message";(h?c:i)(u.kickoffMessage,u.path||void 0).catch(f=>{console.warn("[chat] first-turn trigger failed for newborn session",e,f),ar.has(e)?h||et.getState().markGreetingFailed(e):(ar.add(e),Dt.delete(e),et.getState().resetFired(e))})},[e,t,u,n,d,a,i,c]),l.useEffect(()=>{if(!(!e||!u)&&u.kind!=="first-message"&&!(!u.fired&&!Dt.has(e))&&!u.greetingFailed){if(m){Pt.delete(e);return}if(n==="streaming"){Pt.add(e);return}o&&Pt.has(e)&&(Pt.delete(e),et.getState().markGreetingFailed(e))}},[e,u,n,m,o])}function ng(e,t){return l.useEffect(()=>{wl(),pt.connectList(),e&&pt.attachSession(e,t)},[e,t]),l.useEffect(()=>()=>pt.releaseSession(),[]),no(e??"")}function sg(e,t){const n=so(e),s=l.useRef(t);l.useEffect(()=>{s.current=t}),l.useEffect(()=>{var o;!n||!e||(aa(e,n),(o=s.current)==null||o.call(s,n))},[n,e])}const rg=500;function og(e,t,n){const s=l.useRef(new Map),[o,a]=l.useState(null),i=t.length>0?t[0].seq:-1;l.useEffect(()=>{const h=s.current;if(!e||!n){e&&h.delete(e),a(null);return}let p=h.get(e);(!p||p.turnSeq!==i)&&(p={turnSeq:i,anchor:Date.now()},h.set(e,p)),a(p.anchor)},[e,n,i]);const c=l.useMemo(()=>{let h=0;for(const p of t)p.type==="text_delta"&&(h+=p.text.length);return h/4},[t]),[u,d]=l.useState(!1),m=l.useRef({sid:null,tokens:0});return l.useEffect(()=>{const h=m.current,p=e===h.sid&&c>h.tokens;if(m.current={sid:e,tokens:c},p&&!u&&d(!0),!p&&!u)return;const f=setTimeout(()=>d(!1),rg);return()=>clearTimeout(f)},[e,c,u]),{streamStartTime:o,estimatedTokens:c,isTextStreaming:u}}function ag(e,t,n,s){const o=l.useRef(new Map),a=l.useRef(s);l.useEffect(()=>{a.current=s}),l.useEffect(()=>{var d;if(!e)return;const i=o.current,c=n??0;let u=i.get(e);(!u||u.floor!==c)&&(u={floor:c,seen:c},i.set(e,u));for(const m of t)m.seq<=u.seen||(m.type==="todo_update"&&((d=a.current)==null||d.call(a,{action:m.action,task:m.task,tasks:m.tasks,previousId:m.previousId})),u.seen=m.seq)},[e,t,n])}function ig(e){let t=null,n=null;for(const s of e){if(s.type==="operation_progress"){t=s.state==="started"?{operation:s.operation,determinate:s.determinate,...s.percent!==void 0?{percent:s.percent}:{},...s.message!==void 0?{message:s.message}:{}}:null;continue}if(s.type==="system_status"){(!s.status||s.status===Nl)&&(n={message:s.message});continue}n=null}return{operationProgress:t,systemStatus:n}}function lg(e,t){return e===null||t===null?e===t:e.operation===t.operation&&e.determinate===t.determinate&&e.percent===t.percent&&e.message===t.message}function cg(e,t){return((e==null?void 0:e.message)??null)===((t==null?void 0:t.message)??null)}function ug(e,t,n,s){const o=l.useRef(new Map),a=l.useRef(new Map),i=l.useRef(n),c=l.useRef(s);l.useEffect(()=>{i.current=n,c.current=s}),l.useEffect(()=>{if(!e)return;const{operationProgress:u,systemStatus:d}=ig(t),m=o.current.get(e)??null;lg(m,u)||(i.current(u),o.current.set(e,u));const h=a.current.get(e)??null;cg(h,d)||(c.current(d),a.current.set(e,d))},[e,t])}function dg(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="capability_approval"&&s.approval.approvalId===t)return s}}function mg(e,t){const n=dg(e,t.approval.approvalId);n?n.approval=t.approval:e.push({type:"capability_approval",approval:t.approval})}function fg(e,t){const n=e.findIndex(o=>o.type==="capability_approval"&&o.approval.approvalId===t.approvalId);if(n===-1)return;if(t.outcome!=="timeout"){e.splice(n,1);return}const s=e[n];s.outcome="timeout"}function pg(e,t,n){return e.findIndex(s=>s.type==="mcp_signin"&&s.agentId===t&&s.serverName===n&&s.outcome===void 0)}function hg(e,t){const n={type:"mcp_signin",serverName:t.serverName,agentId:t.agentId,flowId:t.flowId,authorizeUrl:t.authorizeUrl,disclosure:t.disclosure},s=pg(e,t.agentId,t.serverName);s===-1?e.push(n):e[s]=n}function gg(e,t){const n=e.findIndex(o=>o.type==="mcp_signin"&&o.flowId===t.flowId);if(n===-1)return;const s=e[n];s.outcome=t.outcome,t.toolCount!==void 0&&(s.toolCount=t.toolCount)}function xg(e){return e.type==="interaction_resolved"||e.type==="capability_approval_resolved"||e.type==="mcp_signin_resolved"}function yg(e){const t=new Set;for(const n of e)n.type==="interaction_resolved"&&t.add(n.id);return t}function bg(e){return e.type==="work_left_running"?{type:"work_left_running",tasks:e.tasks.map(t=>({taskId:t.taskId,command:t.command}))}:{type:"model_substituted",from:e.from,fromName:e.fromName,to:e.to,toName:e.toName,reason:e.reason}}function ir(e){return e.tasks.map(t=>t.taskId).join("\0")}function kn(e){return e.type==="work_left_running"}function kg(e,t){const n=new Map;for(const i of t)i.type==="work_left_ended"&&n.set(i.taskId,i.status);const s=new Set;for(const i of e)if(!i._streaming)for(const c of i.parts)kn(c)&&s.add(ir(c));if(n.size===0&&s.size===0)return e;let o=!1;const a=[];for(const i of e){if(!i.parts.some(kn)){a.push(i);continue}const c=i.parts.flatMap(u=>kn(u)?i._streaming&&s.has(ir(u))?[]:u.tasks.some(d=>!d.ended&&n.has(d.taskId))?[{...u,tasks:u.tasks.map(d=>{const m=d.ended??n.get(d.taskId);return m?{...d,ended:m}:d})}]:[u]:[u]);if(c.length===i.parts.length&&c.every((u,d)=>u===i.parts[d])){a.push(i);continue}o=!0,c.length>0&&a.push({...i,parts:c})}return o?a:e}const lr="__in_progress_turn__",vg="__optimistic_user__";function Sg(e){return{id:vg,role:"user",content:e,parts:[{type:"text",text:e}],timestamp:"",_streaming:!0}}function jg(e){return{id:`steer-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,...e.chatMessages&&e.chatMessages.length>0?{chatMessages:e.chatMessages}:{}}}function wg(e){return{id:`staged-${e.messageId}`,role:"user",content:e.content,parts:[{type:"text",text:e.content}],timestamp:"",_streaming:!0,_stagedContext:!0}}function Pe(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.toolCallId===t)return s}}function sn(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="elicitation"&&s.interactionId===t)return s}}function Ng(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="background_task"&&s.taskId===t)return s}}function Cg(e,t){ia(e);const n=e[e.length-1];n&&n.type==="text"?n.text+=t.text:e.push({type:"text",text:t.text})}function Tg(e,t){const n=e[e.length-1];n&&n.type==="thinking"&&n.isStreaming?n.text+=t.text:e.push({type:"thinking",text:t.text,isStreaming:!0})}function ia(e){for(const t of e)t.type==="thinking"&&t.isStreaming&&(t.isStreaming=!1)}function Rg(e,t,n){const s=Pe(e,t.toolCallId);if(s){t.input!==void 0&&(s.input=(s.input??"")+t.input);return}const o=n.get(t.toolCallId);n.delete(t.toolCallId),e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",status:t.status,...o&&o.length>0?{hooks:o}:{}})}function Eg(e,t){const n=Pe(e,t.toolCallId);n?(n.result=t.result,n.status=t.status,t.ui!==void 0&&(n.ui=t.ui),t.result!==void 0&&(n.progressOutput=void 0)):e.push({type:"tool_call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input??"",result:t.result,status:t.status,...t.ui!==void 0?{ui:t.ui}:{}})}function Ag(e,t){const n=Pe(e,t.toolCallId);n&&(n.progressOutput=(n.progressOutput??"")+t.content)}function la(e,t){const n={interactiveType:"approval",input:t.input,status:"pending",timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs,approvalTitle:t.title,approvalDisplayName:t.displayName,approvalDescription:t.description,approvalBlockedPath:t.blockedPath,approvalDecisionReason:t.decisionReason,approvalHasSuggestions:t.hasSuggestions,approvalAlwaysAllowScope:t.alwaysAllowScope},s=Pe(e,t.id);s?Object.assign(s,n):e.push({type:"tool_call",toolCallId:t.id,toolName:t.toolName,...n})}function ca(e,t){const n=Pe(e,t.id),s={timeoutMs:t.timeoutMs,approvalStartedAt:t.startedAt,approvalRemainingMs:t.remainingMs};n?(n.interactiveType="question",n.questions=t.questions,n.status="pending",Object.assign(n,s)):e.push({type:"tool_call",toolCallId:t.id,toolName:"AskUserQuestion",input:"",status:"pending",interactiveType:"question",questions:t.questions,...s})}function ua(e,t){const n={serverName:t.serverName,message:t.message,mode:t.mode,url:t.url,elicitationId:t.elicitationId,requestedSchema:t.requestedSchema,status:"pending",startedAt:t.startedAt,remainingMs:t.remainingMs,timeoutMs:t.timeoutMs},s=sn(e,t.id);s?Object.assign(s,n):e.push({type:"elicitation",interactionId:t.id,...n})}function _g(e){return e==="denied"||e==="expired"||e==="cancelled"?"error":e==="answered"?"complete":"running"}function Mg(e,t){const n=Pe(e,t.id);if(n){n.status==="pending"&&(n.status=_g(t.resolution),n.approvalRemainingMs=void 0);const o=Cl(t);o&&(n.interactiveType="approval",n.approvalOutcome=o,n.approvalResolvedAt=t.at,t.reasonGiven===!0&&(n.approvalReasonGiven=!0),n.approvalStartedAt=t.startedAt??n.approvalStartedAt);const a=Tl(t);a&&(n.questionOutcome=a)}const s=sn(e,t.id);s&&s.status==="pending"&&(s.status="submitted",s.remainingMs=void 0)}function Og(e,t){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.type==="tool_call"&&s.hooks){const o=s.hooks.find(a=>a.hookId===t);if(o)return o}}}function Ig(e,t){for(const n of e.values()){const s=n.find(o=>o.hookId===t);if(s)return s}}function Dg(e,t,n){const s=Og(e,t.hookId)??Ig(n,t.hookId);if(s){s.status=t.status,t.hookName!==void 0&&(s.hookName=t.hookName),t.stdout!==void 0&&(s.stdout=t.stdout),t.stderr!==void 0&&(s.stderr=t.stderr),t.exitCode!==void 0&&(s.exitCode=t.exitCode);return}if(!t.toolCallId)return;const o={hookId:t.hookId,hookName:t.hookName??"",hookEvent:t.hookEvent??"",status:t.status,stdout:t.stdout??"",stderr:t.stderr??"",...t.exitCode!==void 0?{exitCode:t.exitCode}:{}},a=Pe(e,t.toolCallId);a?a.hooks=[...a.hooks??[],o]:n.set(t.toolCallId,[...n.get(t.toolCallId)??[],o])}function Pg(e,t){const n=e[0];if(n&&n.type==="memory_recall"){const a=new Set(n.memories.map(c=>c.path)),i=t.memories.filter(c=>!a.has(c.path));i.length>0&&(n.memories=[...n.memories,...i]);return}const s=new Set,o=t.memories.filter(a=>s.has(a.path)?!1:(s.add(a.path),!0));e.unshift({type:"memory_recall",mode:t.mode,memories:o,isStreaming:!0})}function $g(e,t){e.push({type:"image",attachmentId:t.attachmentId,url:t.url,mediaType:t.mediaType,size:t.size,...t.alt!==void 0?{alt:t.alt}:{}})}function Fg(e,t){e.push({type:"compact_boundary",...t.trigger!==void 0?{trigger:t.trigger}:{},...t.preTokens!==void 0?{preTokens:t.preTokens}:{},...t.postTokens!==void 0?{postTokens:t.postTokens}:{},...t.durationMs!==void 0?{durationMs:t.durationMs}:{},...t.requestedBy!==void 0?{requestedBy:t.requestedBy}:{},...t.contextPercent!==void 0?{contextPercent:t.contextPercent}:{}})}function Lg(e,t){e.push({type:"permission_denied",toolCallId:t.toolCallId,toolName:t.toolName,message:t.message,...t.reasonType!==void 0?{reasonType:t.reasonType}:{},...t.reason!==void 0?{reason:t.reason}:{},...t.agentId!==void 0?{agentId:t.agentId}:{}})}function Ug(e,t){t.operation!=="compaction"||t.state!=="failed"||e.push({type:"compact_boundary",failed:!0,...t.error!==void 0?{error:t.error}:{},...t.requestedBy!==void 0?{requestedBy:t.requestedBy}:{}})}function qg(e,t){ia(e);const n=t.code!==void 0?t.details!==void 0?`[${t.code}] ${t.details}`:`[${t.code}]`:t.details;e.push({type:"error",message:t.message,...t.category!==void 0?{category:t.category}:{},...n!==void 0?{details:n}:{},...t.code!==void 0?{code:t.code}:{},...t.reason!==void 0?{reason:t.reason}:{}})}function zg(e,t){const n=Ng(e,t.taskId);n?(n.status=t.status,t.description!==void 0&&(n.description=t.description),t.toolUses!==void 0&&(n.toolUses=t.toolUses),t.lastToolName!==void 0&&(n.lastToolName=t.lastToolName),t.summary!==void 0&&(n.summary=t.summary),t.ambient!==void 0&&(n.ambient=t.ambient)):e.push({type:"background_task",taskId:t.taskId,taskType:"agent",status:t.status,startedAt:0,description:t.description,toolUses:t.toolUses,lastToolName:t.lastToolName,summary:t.summary,ambient:t.ambient})}const Bg={approval:"approval_required",question:"question_prompt",elicitation:"elicitation_prompt"};function Wg(e){const{type:t,...n}=e;return{...n,seq:0,type:Bg[t]}}function Hg(e,t){const n=Pe(e,t);return(n==null?void 0:n.interactiveType)!==void 0?!0:sn(e,t)!==void 0}function Gg(e,t){switch(t.type){case"approval_required":la(e,t);break;case"question_prompt":ca(e,t);break;case"elicitation_prompt":ua(e,t);break}}function Kg(e,t,n){const s=Pe(e,t.id);if(s){!n&&s.result===void 0&&(s.status="pending"),s.approvalStartedAt=t.startedAt,s.approvalRemainingMs=t.remainingMs,t.timeoutMs!==void 0&&(s.timeoutMs=t.timeoutMs),s.approvalParked=t.parked===!0?!0:void 0;return}const o=sn(e,t.id);o&&(o.startedAt=t.startedAt,o.remainingMs=t.remainingMs,t.timeoutMs!==void 0&&(o.timeoutMs=t.timeoutMs))}function Qg(e,t,n){for(const s of t){if(Hg(e,s.id)){Kg(e,s,n.has(s.id));continue}Gg(e,Wg(s)),Vg(e,s)}}function Vg(e,t){if(t.parked!==!0)return;const n=Pe(e,t.id);n&&(n.approvalParked=!0)}function $n(e){const t=[],n=new Map;for(const s of e)switch(s.type){case"text_delta":Cg(t,s);break;case"thinking_delta":Tg(t,s);break;case"tool_call":Rg(t,s,n);break;case"tool_result":Eg(t,s);break;case"tool_progress":Ag(t,s);break;case"approval_required":la(t,s);break;case"question_prompt":ca(t,s);break;case"elicitation_prompt":ua(t,s);break;case"capability_approval_required":mg(t,s);break;case"capability_approval_resolved":fg(t,s);break;case"mcp_signin_required":hg(t,s);break;case"mcp_signin_resolved":gg(t,s);break;case"interaction_resolved":Mg(t,s);break;case"subagent_update":zg(t,s);break;case"hook_update":Dg(t,s,n);break;case"memory_recall":Pg(t,s);break;case"image_attachment":$g(t,s);break;case"compact_boundary":Fg(t,s);break;case"permission_denied":Lg(t,s);break;case"model_substituted":case"work_left_running":t.push(bg(s));break;case"operation_progress":Ug(t,s);break;case"error":qg(t,s);break}return t}function cr(e,t){if(e.length===0)return null;const n=ns(e);return{id:t,role:"assistant",content:n.content,toolCalls:n.toolCalls.length>0?n.toolCalls:[],parts:e,timestamp:"",_streaming:!0}}function Yg(e,t){const n=[];let s=[],o=0;for(const[c,u]of e.entries()){if(u.type!=="turn_input"&&u.type!=="context_staged"){s.push(u);continue}const d=$n([...s,...e.slice(c+1).filter(xg)]),m=cr(d,`${lr}-${o}`);m&&n.push(m),o+=1,n.push(u.type==="turn_input"?jg(u):wg(u)),s=[]}const a=$n(s);Qg(a,t,yg(e));const i=cr(a,lr);return i&&n.push(i),n}function Xg(e){const t=new Set;for(const n of e)for(const s of n.parts)s.type==="tool_call"&&t.add(s.toolCallId);return t}function Jg(e){return e.type==="tool_call"&&e.result===void 0&&e.answers===void 0&&e.approvalOutcome===void 0&&(e.questionOutcome===void 0||e.questionOutcome==="unresolved")}function Zg(e,t){const n=e.parts.filter(o=>o.type!=="tool_call"||!t.has(o.toolCallId)||!Jg(o));if(n.length===e.parts.length)return e;if(n.length===0)return null;const s=ns(n);return{...e,parts:n,content:s.content,toolCalls:s.toolCalls.length>0?s.toolCalls:void 0}}function ex(e){let t=e.length;for(;t>0&&e[t-1].role==="assistant";)t-=1;return t}function tx(e,t,n=[],s=null){const o=Yg(t,n),a=Xg(o),i=Dm(e),c=a.size===0?i.length:ex(i),u=[];for(const[d,m]of i.entries()){const h=d<c?m:Zg(m,a);h&&u.push(h)}return s&&u.push(Sg(s.content)),u.push(...o),kg(u,t)}function ur(e){const t=new Map;for(const n of e)n.type!=="tool_call"||n.approvalOutcome===void 0||t.set(n.toolCallId,{outcome:n.approvalOutcome,resolvedAt:n.approvalResolvedAt,startedAt:n.approvalStartedAt,displayName:n.approvalDisplayName,reasonGiven:n.approvalReasonGiven});return t}function nx(e,t){return e.interactiveType==="approval"&&e.approvalOutcome===t.outcome&&e.approvalResolvedAt===t.resolvedAt&&e.approvalStartedAt===t.startedAt&&e.approvalReasonGiven===t.reasonGiven}function sx(e,t){return t.size===0?e:e.map(n=>{if(!n.parts)return n;let s=!1;const o=n.parts.map(a=>{if(a.type!=="tool_call")return a;const i=t.get(a.toolCallId);return!i||nx(a,i)?a:(s=!0,{...a,interactiveType:"approval",approvalOutcome:i.outcome,approvalResolvedAt:i.resolvedAt,approvalStartedAt:i.startedAt,approvalReasonGiven:i.reasonGiven,...i.displayName!==void 0?{approvalDisplayName:i.displayName}:{}})});return s?{...n,parts:o}:n})}function rx(e,t){var o;if(!t.tail)return t.messages;const n=(o=t.messages[0])==null?void 0:o.id,s=n===void 0?-1:e.findIndex(a=>a.id===n);return s===-1?null:[...e.slice(0,s),...t.messages]}async function ox(e,t,n,s){const o=ax(s());if(o!==void 0){const a=await e.getMessages(t,n,{since:o}),i=rx(s(),a);if(i)return i}return(await e.getMessages(t,n)).messages}function ax(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return e[t].id}function ix({sessionId:e,transport:t,sessionCwd:n,streamState:s,queryClient:o,onStreamingDone:a}){var v;const i=n.cwd,c=l.useRef(e),u=l.useRef(i),d=l.useRef(a);l.useEffect(()=>{c.current=e,u.current=i,d.current=a});const m=l.useRef(new Map),h=l.useRef(new Map),p=l.useRef(new Map),f=l.useRef(new Map),g=l.useRef(new Map),x=((v=s.status)==null?void 0:v.lifecycle)??null,y=s.hydrationGeneration,b=s.userTurnCount;l.useEffect(()=>{var I,F,N;if(!e)return;const j=g.current.get(e);g.current.set(e,b),j!==void 0&&b!==j&&f.current.set(e,!1);const S=h.current.get(e);if(h.current.set(e,y),S!==y){m.current.set(e,x),x==="streaming"&&p.current.set(e,((I=Ce.getState().getSession(e).optimisticUserMessage)==null?void 0:I.id)??null);return}const T=m.current.get(e)??null;if(m.current.set(e,x),x==="streaming"&&T!=="streaming"&&p.current.set(e,((F=Ce.getState().getSession(e).optimisticUserMessage)==null?void 0:F.id)??null),!(T==="streaming"&&x!=="streaming"&&x!==null))return;const E=e,O=p.current.get(E)??null,A=ur($n(Ce.getState().getSession(E).inProgressTurn));ox(t,E,u.current??void 0,()=>Ce.getState().getSession(E).messages).then(k=>{var W;const C=Ce.getState(),w=C.getSession(E),P=((W=w.status)==null?void 0:W.lifecycle)==="streaming",M=new Map([...ur(w.messages.flatMap(G=>G.parts??[])),...A]);C.setHistoryMessages(E,sx(k,M),{preserveInProgressTurn:P});const D=w.optimisticUserMessage;(D===null||D.id===O)&&C.setOptimisticUserMessage(E,null)}).catch(k=>{console.warn("[turn-end-reconcile] history reload failed",{sessionId:E,error:k instanceof Error?k.message:String(k)})}),o.invalidateQueries({queryKey:["tasks",E]}),f.current.get(E)!==!0&&(f.current.set(E,!0),(N=d.current)==null||N.call(d))},[e,x,y,b,t,o])}function lx(e){return e.streamReadyCursor!==null||e.messages.length>0||e.inProgressTurn.length>0||e.optimisticUserMessage!==null}function da(e,t){const n=lx(e),s=n?e.messages:t,o=dr.get(s);if(o&&o.hydrated===n&&o.inProgressTurn===e.inProgressTurn&&o.pendingInteractions===e.pendingInteractions&&o.optimisticUserMessage===e.optimisticUserMessage&&o.legacyMessages===t)return o.result;const a=n?tx(e.messages,e.inProgressTurn,e.pendingInteractions,e.optimisticUserMessage):t,i=mc(a);return dr.set(s,{hydrated:n,inProgressTurn:e.inProgressTurn,pendingInteractions:e.pendingInteractions,optimisticUserMessage:e.optimisticUserMessage,legacyMessages:t,result:i}),i}const dr=new WeakMap;function cx(e,t={}){const n=be(),s=Vn(),o=ie(K=>K.selectedCwd),a=ie(K=>K.enableMessagePolling),i=ie(K=>K.pendingAccount),c=_o(),u=e??"",{messages:d,input:m,status:h,error:p,sessionStatus:f,systemStatus:g,operationProgress:x,promptSuggestions:y}=ro(u),b=ng(e,c.cwd);sg(e,t.onSessionIdChangeReplace);const v=Rl(u),j=l.useMemo(()=>da(b,d),[b,d]),S=El(b,h),{streamStartTime:T,estimatedTokens:R,isTextStreaming:E}=og(e,b.inProgressTurn,S==="streaming");ag(e,b.inProgressTurn,b.streamReadyCursor,t.onTaskEvent);const O=l.useRef(!0);l.useEffect(()=>(O.current=!0,()=>{O.current=!1}),[]);const A=l.useRef(new Map);l.useLayoutEffect(()=>{u&&(A.current.has(u)||A.current.set(u,re.getState().getSession(u).mountGeneration))},[u]);const{setMessages:I,setInput:F,setError:N,setSystemStatus:k,setOperationProgress:C}=Yh(u,O,A);ug(e,b.inProgressTurn,C,k),u&&re.getState().initSession(u),l.useEffect(()=>{e&&(re.getState().initSession(e),re.getState().touchSession(e),A.current.set(e,re.getState().getSession(e).mountGeneration))},[e]),l.useEffect(()=>{if(e)return ht.getState().clearUnseen(e),ht.subscribe(K=>{K.unseen[e]!==void 0&&ht.getState().clearUnseen(e)})},[e]);const{historyQuery:w}=Xh({sessionId:e,sid:u,transport:n,sessionCwd:c,enableMessagePolling:a,isStreaming:S==="streaming",streamHydrated:b.streamReadyCursor!==null,setMessages:I}),P=Nh(o,e,{startFreshSession:t.startFreshSession,compact:t.compactIntent}),{handleSubmit:M,submitContent:D,enqueueContent:W,steerContent:G,addContextContent:V,stop:B,retryMessage:L,submitKickoff:X,markToolCallResponded:_}=Zh({sessionId:e,input:m,status:S,transport:n,queryClient:s,selectedCwd:o,onSessionIdChangeReplace:t.onSessionIdChangeReplace,transformContent:t.transformContent,launchRuntime:t.launchRuntime,agentPath:t.agentPath,agentLookupPending:t.agentLookupPending,agentLookupFailed:t.agentLookupFailed,launchAccount:(i==null?void 0:i.sessionId)===u?i.id:null,takeSeedContext:t.takeSeedContext,setInput:F,setError:N,tryNativeCommand:P.tryRun}),q=b.streamReadyCursor!==null,te=l.useCallback((K,Z)=>D(K,Z?{cwd:Z}:void 0),[D]);tg({sessionId:e,cwd:o,status:S,messages:j,hydrated:q,canStart:!t.agentLookupPending&&!t.agentLookupFailed,submitKickoff:X,submitContent:te}),ix({sessionId:e,transport:n,sessionCwd:c,streamState:b,queryClient:s,onStreamingDone:t.onStreamingDone});const $=w.isLoading&&j.length===0,J=l.useMemo(()=>j.flatMap(K=>K.toolCalls||[]).filter(K=>K.interactiveType&&K.status==="pending"),[j]),oe=J[0]||null,ne=oe!==null,de=(oe==null?void 0:oe.interactiveType)||null;return{messages:j,input:m,setInput:F,handleSubmit:M,submitContent:D,enqueueContent:W,steerContent:G,addContextContent:V,status:S,error:p,stop:B,retryMessage:L,isLoadingHistory:$,hydrated:q,sessionStatus:f,streamStartTime:T,estimatedTokens:R,isTextStreaming:E,isWaitingForUser:ne,waitingType:de,activeInteraction:oe,pendingInteractions:J,markToolCallResponded:_,systemStatus:g,operationProgress:x,promptSuggestions:y,syncConnectionState:v,tryNativeCommand:P.tryRun,commandPending:P.commandPending}}function ux(e){switch(e.outcome){case"acked":return{message:"You stopped this reply.",isFailure:!1};case"closed":return{message:"Stopped. Your agent didn’t answer, so DorkOS ended it.",isFailure:!1};case"not-running":return{message:null,isFailure:!1};case"unconfirmed":return{message:`Stop requested. ${mx(e.runtime)} didn’t confirm, so it may still be working.`,isFailure:!1};case"failed":return{message:"Couldn’t stop it. Try again.",isFailure:!0}}}function dx(e,t){return!Xn(e)||e.outcome==="not-running"&&t}function mx(e){switch(e){case"claude-code":return"Claude Code";case"codex":return"Codex";case"opencode":return"OpenCode";case"doe":return"DorkOS";default:return"Your agent"}}function fx(){const e=ie(d=>d.showTaskCelebrations),[t,n]=l.useState(null),[s,o]=l.useState(null),a=l.useRef(null),i=l.useRef(!1);l.useEffect(()=>{const d=window.matchMedia("(prefers-reduced-motion: reduce)");i.current=d.matches;const m=h=>{i.current=h.matches};return d.addEventListener("change",m),()=>d.removeEventListener("change",m)},[]),Lu({timeoutMs:Xe.IDLE_TIMEOUT_MS,onIdle:l.useCallback(()=>{var d;(d=a.current)==null||d.setIdle(!0)},[]),onReturn:l.useCallback(()=>{var d,m;(d=a.current)==null||d.setIdle(!1),(m=a.current)==null||m.onUserReturn()},[])}),l.useEffect(()=>{const d=new Ju({enabled:e,miniProbability:Xe.MINI_PROBABILITY,debounceWindowMs:Xe.DEBOUNCE_WINDOW_MS,debounceThreshold:Xe.DEBOUNCE_THRESHOLD,minTasksForMajor:Xe.MIN_TASKS_FOR_MAJOR,idleTimeoutMs:Xe.IDLE_TIMEOUT_MS,onCelebrate:m=>{i.current&&m.level==="major"?n({...m,level:"mini"}):n(m),m.level==="mini"&&o(m.taskId)}});return a.current=d,()=>d.destroy()},[e]);const c=l.useCallback((d,m)=>{var h;d.action==="update"&&d.task.status==="completed"&&d.task.id&&((h=a.current)==null||h.onTaskCompleted(d.task.id,m))},[]),u=l.useCallback(()=>{n(null),o(null)},[]);return{handleTaskEvent:c,activeCelebration:t,celebratingTaskId:s,clearCelebration:u}}function vn(){return{tasks:new Map,statusTimestamps:new Map,legacyCreateCount:0}}function px(e){const t={};for(const[n,s]of Object.entries(e))s!==void 0&&s!==""&&(t[n]=s);return t}function Sn(e,t,n){switch(t.action){case"snapshot":{e.tasks.clear(),e.statusTimestamps.clear();const s=t.tasks??[t.task];for(const o of s)e.tasks.set(o.id,o),e.statusTimestamps.set(o.id,{status:o.status,since:n});return}case"create":{const s=t.task.id||`legacy:${e.legacyCreateCount++}`,o=s===t.task.id?t.task:{...t.task,id:s};e.tasks.set(s,o),e.statusTimestamps.set(s,{status:o.status,since:n});return}case"id_assigned":{const s=t.previousId;if(!s)return;const o=e.tasks.get(s);if(!o)return;const a=t.task.id;e.tasks.delete(s),e.tasks.set(a,{...o,id:a});const i=e.statusTimestamps.get(s);e.statusTimestamps.delete(s),e.statusTimestamps.set(a,i??{status:o.status,since:n});return}case"remove":{e.tasks.delete(t.task.id),e.statusTimestamps.delete(t.task.id);return}case"update":{if(!t.task.id)return;const s=e.tasks.get(t.task.id);if(!s)return;e.tasks.set(t.task.id,{...s,...px(t.task)}),t.task.status&&t.task.status!==s.status&&e.statusTimestamps.set(t.task.id,{status:t.task.status,since:n});return}}}function mr(e,t){var n;return(n=e.blockedBy)!=null&&n.length?e.blockedBy.some(s=>{const o=t.get(s);return o&&o.status!=="completed"}):!1}function hx(e,t){return[...e].sort((n,s)=>{const o=n.status==="in_progress"?0:n.status==="pending"&&!mr(n,t)?1:n.status==="pending"?2:3,a=s.status==="in_progress"?0:s.status==="pending"&&!mr(s,t)?1:s.status==="pending"?2:3;return o-a})}const gx=10;let fr=0;function $t(e){return e==="streaming"||e==="blocked"}function xx(e,t=!1){const n=be(),o=_o().cwd,a=ie(A=>A.enableMessagePolling),i=wo(),[c,u]=l.useState(vn()),d=oo(e??""),[m,h]=l.useState(()=>!$t(d)),p=l.useRef([]),f=l.useRef(0),{data:g}=ut({queryKey:["tasks",e,o],queryFn:async()=>{const A=++fr;return{...await n.getTasks(e,o??void 0),fetchOrder:A}},staleTime:3e4,refetchOnWindowFocus:!1,enabled:e!==null,refetchInterval:()=>!a||t?!1:i?Ge.ACTIVE_TAB_REFETCH_MS:Ge.BACKGROUND_TAB_REFETCH_MS}),x=l.useRef(null);l.useEffect(()=>{const A=`${e??""}::${o??""}`,I=x.current!==A;if(x.current=A,I&&(p.current=[],f.current=0,u(vn())),!g||g.fetchOrder<=f.current)return;f.current=g.fetchOrder;const F=vn();g.tasks.length>0&&Sn(F,{action:"snapshot",task:g.tasks[0],tasks:g.tasks},Date.now()),p.current=p.current.filter(({order:N})=>N>g.fetchOrder);for(const{event:N,receivedAt:k}of p.current)Sn(F,N,k);u(F)},[g,e,o]);const y=l.useCallback(A=>{const I=Date.now();A.action==="snapshot"&&(p.current=[]),p.current.push({order:++fr,event:A,receivedAt:I}),u(F=>{const N={tasks:new Map(F.tasks),statusTimestamps:new Map(F.statusTimestamps),legacyCreateCount:F.legacyCreateCount};return Sn(N,A,I),N})},[]),b=l.useRef(!1),v=l.useCallback(()=>{h(A=>(b.current=!A,!A))},[]),j=l.useRef($t(d));l.useEffect(()=>{const A=$t(d);A!==j.current&&(j.current=A,A?b.current||h(!1):h(!0))},[d]);const S=l.useRef(null);l.useEffect(()=>{const A=`${e??""}::${o??""}`;if(S.current===A)return;S.current=A;const I=$t(d);j.current=I,b.current=!1,h(!I)},[e,o,d]);const T=Array.from(c.tasks.values()),R=hx(T,c.tasks),E=T.find(A=>A.status==="in_progress"),O=(E==null?void 0:E.activeForm)??null;return{tasks:R.slice(0,gx),taskMap:c.tasks,activeForm:O,isCollapsed:m,toggleCollapse:v,handleTaskEvent:y,statusTimestamps:c.statusTimestamps}}function yx(e){const t=l.useRef(null),[n,s]=l.useState(0),[o,a]=l.useState(!1),[i,c]=l.useState(0),u=l.useCallback(b=>{t.current=b,c(b&&"getOptionCount"in b?b.getOptionCount():0)},[]);l.useEffect(()=>{s(0),c(0),a(!1)},[e==null?void 0:e.toolCallId]);const d=l.useMemo(()=>e!=null&&e.interactiveType?{type:e.interactiveType,toolCallId:e.toolCallId}:null,[e]),m=l.useCallback(()=>{const b=t.current;b&&"approve"in b&&b.approve()},[]),h=l.useCallback(()=>{const b=t.current;b&&"alwaysAllow"in b&&b.alwaysAllow()},[]),p=l.useCallback(()=>{const b=t.current;b&&"deny"in b&&b.deny()},[]),f=l.useCallback(b=>{const v=t.current;v&&"toggleOption"in v&&(v.toggleOption(b),s(b),a(!0))},[]),g=l.useCallback(b=>{if(!o){a(!0);return}s(v=>{const j=t.current,S=j&&"getOptionCount"in j?j.getOptionCount():0;return S===0?v:b==="up"?v<=0?S-1:v-1:v>=S-1?0:v+1})},[o]),x=l.useCallback(b=>{const v=t.current;v&&"navigateQuestion"in v&&(v.navigateQuestion(b),s(0),a(!0),c(v.getOptionCount()))},[]),y=l.useCallback(()=>{const b=t.current;b&&"submit"in b&&b.submit()},[]);return Uu({activeInteraction:d,onApprove:m,onAlwaysAllow:h,onDeny:p,onToggleOption:f,onNavigateOption:g,onNavigateQuestion:x,onSubmit:y,optionCount:i,focusedIndex:n}),{handleToolRef:u,focusedOptionIndex:o?n:-1}}function Ft(e,t,n){var a;const s=e.length;if(s===0)return 0;let o=(t%s+s)%s;for(let i=0;i<s;i++){if(!((a=e[o])!=null&&a.disabled))return o;o=(o+n+s)%s}return t}function bx({commands:e,input:t,cursorPos:n}){const[s,o]=l.useState(!1),[a,i]=l.useState(""),[c,u]=l.useState(-1),d=l.useMemo(()=>a?e.map(T=>({cmd:T,rank:yd(a,T)})).filter(T=>T.rank.match).sort((T,R)=>T.rank.bucket-R.rank.bucket||R.rank.score-T.rank.score).map(({cmd:T,rank:R})=>({...T,matchedAlias:R.matchedAlias})):e,[e,a]),[m,h]=l.useState(null),p=m!==null&&m.query===a&&m.open===s?m.index:Ft(d,0,1),f=d[p],g=d.length===0||f!==void 0&&!f.disabled?p:Ft(d,0,1),x=l.useCallback((T,R)=>{const O=T.slice(0,R).match(/(^|\s)\/([\w:-]*)$/);return O?(o(!0),i(O[2]),u((O.index??0)+O[1].length),!0):(o(!1),!1)},[]),y=l.useCallback(T=>{const R=t.slice(0,c),E=t.slice(c+1+a.length);return o(!1),R+T.fullCommand+(E.startsWith(" ")?"":" ")+E},[t,a,c]),b=l.useCallback(()=>{h({query:a,open:s,index:Ft(d,g+1,1)})},[d,g,a,s]),v=l.useCallback(()=>{h({query:a,open:s,index:Ft(d,g-1,-1)})},[d,g,a,s]),j=l.useCallback(()=>{const T=d[g];return T&&!T.disabled?y(T):(T||o(!1),null)},[d,g,y]),S=l.useCallback(()=>{o(!1),i("")},[]);return{showCommands:s,setShowCommands:o,commandQuery:a,selectedIndex:g,filteredCommands:d,slashTriggerPos:c,detectCommandTrigger:x,handleCommandSelect:y,handleArrowUp:v,handleArrowDown:b,handleKeyboardSelect:j,resetCommand:S}}function kx({fileEntries:e,input:t,cursorPos:n}){const[s,o]=l.useState(!1),[a,i]=l.useState(""),[c,u]=l.useState(0),[d,m]=l.useState(-1),h=l.useMemo(()=>s?a?e.map(v=>({...v,...Ut(a,v.path)})).filter(v=>v.match).sort((v,j)=>j.score-v.score).slice(0,50):e.slice(0,50).map(v=>({...v,indices:[]})):[],[e,a,s]);l.useEffect(()=>{u(0)},[a,s]),l.useEffect(()=>{h.length>0&&c>=h.length&&u(h.length-1)},[h.length,c]);const p=l.useCallback((v,j)=>{const T=v.slice(0,j).match(/(^|\s)@([\w./:-]*)$/);return T?(o(!0),i(T[2]),m((T.index??0)+T[1].length),!0):(o(!1),!1)},[]),f=l.useCallback(v=>{const j=t.slice(0,d),S=t.slice(d+1+a.length);if(v.isDirectory){const R=j+"@"+v.path+S,E=j.length+1+v.path.length;return i(v.path),u(0),{newValue:R,newCursorPos:E,keepOpen:!0}}const T=j+"@"+v.path+" "+S;return o(!1),{newValue:T,keepOpen:!1}},[t,d,a]),g=l.useCallback(()=>{u(v=>h.length===0?0:(v+1)%h.length)},[h.length]),x=l.useCallback(()=>{u(v=>h.length===0?0:(v-1+h.length)%h.length)},[h.length]),y=l.useCallback(()=>h.length>0&&c<h.length?f(h[c]):(o(!1),null),[h,c,f]),b=l.useCallback(()=>{o(!1),i("")},[]);return{showFiles:s,setShowFiles:o,fileQuery:a,fileSelectedIndex:c,filteredFiles:h,fileTriggerPos:d,detectFileTrigger:p,handleFileSelect:f,handleArrowUp:x,handleArrowDown:g,handleKeyboardSelect:y,resetFiles:b}}function vx({input:e,setInput:t,commands:n,fileEntries:s}){const[o,a]=l.useState(0),i=bx({commands:n,input:e,cursorPos:o}),c=kx({fileEntries:s,input:e,cursorPos:o}),u=l.useCallback((R,E)=>{if(c.detectFileTrigger(R,E)){i.setShowCommands(!1);return}if(i.detectCommandTrigger(R,E)){c.setShowFiles(!1);return}c.setShowFiles(!1),i.setShowCommands(!1)},[c,i]),d=l.useRef({value:e,cursor:0});l.useEffect(()=>{d.current.value=e},[e]);const m=l.useCallback(R=>{t(R),d.current={value:R,cursor:d.current.cursor||R.length},u(R,d.current.cursor)},[t,u]),h=l.useCallback(R=>{a(R),d.current={value:d.current.value,cursor:R},u(d.current.value,R)},[u]),p=l.useCallback(R=>{const E=i.handleCommandSelect(R);t(E)},[i,t]),f=l.useCallback(R=>{const E=c.handleFileSelect(R);t(E.newValue),E.newCursorPos!==void 0&&a(E.newCursorPos)},[c,t]),g=l.useCallback(()=>{c.showFiles?c.handleArrowDown():i.handleArrowDown()},[c,i]),x=l.useCallback(()=>{c.showFiles?c.handleArrowUp():i.handleArrowUp()},[c,i]),y=l.useCallback(()=>{if(c.showFiles){const R=c.handleKeyboardSelect();R&&(t(R.newValue),R.newCursorPos!==void 0&&a(R.newCursorPos))}else if(i.showCommands){const R=i.handleKeyboardSelect();R&&t(R)}},[c,i,t]),b=l.useCallback(()=>{i.setShowCommands(!1),c.setShowFiles(!1)},[i,c]),v=i.showCommands||c.showFiles,j=c.showFiles&&c.filteredFiles.length>0||i.showCommands&&i.filteredCommands.length>0,S=c.showFiles?"file-palette-listbox":i.showCommands?"command-palette-listbox":void 0,T=c.showFiles&&c.filteredFiles.length>0?`file-item-${c.fileSelectedIndex}`:i.showCommands&&i.filteredCommands.length>0?`command-item-${i.selectedIndex}`:void 0;return{commands:{show:i.showCommands,filtered:i.filteredCommands,selectedIndex:i.selectedIndex},files:{show:c.showFiles,filtered:c.filteredFiles,selectedIndex:c.fileSelectedIndex},isPaletteOpen:v,paletteHasResults:j,activeDescendantId:T,paletteListboxId:S,handleInputChange:m,handleCursorChange:h,handleArrowUp:x,handleArrowDown:g,handleKeyboardSelect:y,handleCommandSelect:p,handleFileSelect:f,dismissPalettes:b}}function Sx(e,t,n){const s=ie(i=>i.setIsStreaming),o=ie(i=>i.setIsWaitingForUser),a=ie(i=>i.setIsTextStreaming);l.useEffect(()=>(s(e==="streaming"),()=>s(!1)),[e,s]),l.useEffect(()=>(o(t),()=>o(!1)),[t,o]),l.useEffect(()=>(a(n),()=>a(!1)),[n,a])}function jx(){const e=be(),t=ie(p=>p.selectedCwd),[n,s]=l.useState([]),o=l.useCallback(p=>{const f=p.map(g=>({id:crypto.randomUUID(),file:g,status:"pending",progress:0}));s(g=>[...g,...f])},[]),a=l.useCallback(p=>{s(f=>f.filter(g=>g.id!==p))},[]),i=l.useCallback(()=>{s([])},[]),c=l.useCallback(p=>{s(f=>f.map(g=>g.id===p&&g.status==="error"?{...g,status:"pending",progress:0,error:void 0}:g))},[]),u=l.useRef(null),d=xt({meta:{suppressErrorToast:!0},mutationFn:async p=>{if(!t)throw new Error("No working directory selected");s(y=>y.map(b=>p.some(v=>v.id===b.id)?{...b,status:"uploading"}:b));const f=y=>{s(b=>b.map(v=>v.status==="uploading"?{...v,progress:y.percentage}:v))},g=new AbortController;u.current=g;const x=p.map(y=>y.file);return e.uploadFiles(x,t,f,g.signal)},onSettled:()=>{u.current=null},onSuccess:(p,f)=>{s(g=>g.map(x=>{const y=f.findIndex(b=>b.id===x.id);return y===-1?x:{...x,status:"uploaded",progress:100,result:p[y]}}))},onError:p=>{s(f=>f.map(g=>g.status==="uploading"?{...g,status:"error",error:p.message}:g))}}),m=l.useCallback(()=>{var p;(p=u.current)==null||p.abort()},[]),h=l.useCallback(async()=>{const p=n.filter(y=>y.status==="error");if(p.length>0)throw new Error(p.length===1?`${p[0].file.name} did not upload. Retry it or remove it, then send again.`:`${p.length} attachments did not upload. Retry them or remove them, then send again.`);const f=n.filter(y=>y.status==="uploaded"&&y.result).map(y=>y.result.savedPath),g=n.filter(y=>y.status==="pending");if(g.length===0)return f;const x=await d.mutateAsync(g);return[...f,...x.map(y=>y.savedPath)]},[n,d]);return{pendingFiles:n,addFiles:o,removeFile:a,retryFile:c,clearFiles:i,cancelUpload:m,uploadAndGetPaths:h,hasPendingFiles:n.length>0,hasFailedUpload:n.some(p=>p.status==="error"),isUploading:d.isPending}}const jn=new Set,wn=new Set;function wx(e,t){return`${e}\0${t}`}function Nx({sessionId:e,prompt:t,autoSend:n,input:s,setInput:o,messageCount:a,hydrated:i,status:c,submitBlocked:u=!1,submit:d,onSeeded:m,onConsumed:h}){const p=t!=null&&t.trim()?t:void 0,f=e&&p?wx(e,p):null;l.useEffect(()=>{if(!(!f||!p)&&!jn.has(f)&&i){if(jn.add(f),s.length>0||a>0){wn.add(f),h==null||h();return}o(p),m==null||m(),n||h==null||h()}},[f,p,n,s,i,a,o,m,h]),l.useEffect(()=>{!f||!p||!n||wn.has(f)||jn.has(f)&&s===p&&(!i||a>0||c==="streaming"||u||(wn.add(f),h==null||h(),d()))},[f,p,n,s,i,a,c,u,d,h])}const pr=Al-256,hr=`
|
|
40
|
+
…(context truncated)`,gr={"/":"the home team room","/activity":"the activity feed","/team":"the team page","/session":"a chat session","/tasks":"the scheduled-work page","/channels":"a channel","/workspaces":"the workspaces page","/connections":"the connections page","/marketplace":"the marketplace","/feedback-requests":"the feedback requests page","/threads":"the threads page"};function Cx(e){const t=`/${e.split("/").filter(Boolean)[0]??""}`;return gr[e]??gr[t]??`the ${e} page`}function Tx(e){const t=['The person opened this conversation by pressing "Ask DorkBot" in the DorkOS sidebar, so they are asking for help with DorkOS itself. Greet them with what you can see below and offer the next step; do not repeat this back to them.'];e.originPath!==null&&t.push(`They were on ${Cx(e.originPath)} (${e.originPath}).`),t.push(e.agentNames.length===1?"They have 1 agent registered.":`They have ${e.agentNames.length} agents registered.`),e.agentNames.length>0&&t.push(`Their agents: ${e.agentNames.join(", ")}.`),e.version!==null&&t.push(e.updateReady?`They are running DorkOS v${e.version}, and a newer version is ready to install.`:`They are running DorkOS v${e.version}.`),e.erroredSessionIds.length>0&&t.push(`These conversations ended in an error and may be what they want help with: ${e.erroredSessionIds.join(", ")}.`);const n=t.join(`
|
|
41
|
+
`);return n.length<=pr?n:n.slice(0,pr-hr.length)+hr}const Rx="dorkbot-help",Lt=new Set;function Ex({sessionId:e,seed:t,messageCount:n,hydrated:s,onConsumed:o}){const a=t===Rx&&e!==null,{data:i}=_l({enabled:a}),{data:c}=qn(),u=ht(Ml(p=>Object.entries(p.statuses).filter(([,f])=>f.lifecycle==="error").map(([f])=>f))),d=l.useRef({agentNames:[],version:null,updateReady:!1,erroredSessionIds:[]}),m=l.useRef({armed:a,sessionId:e,messageCount:n}),h=l.useRef(o);return l.useEffect(()=>{const p=(c==null?void 0:c.latestVersion)??null,f=(c==null?void 0:c.version)??null;d.current={agentNames:((i==null?void 0:i.agents)??[]).map(g=>g.displayName??g.name),version:f,updateReady:p!==null&&f!==null&&kc(p,f),erroredSessionIds:u}},[i,c,u]),l.useEffect(()=>{m.current={armed:a,sessionId:e,messageCount:n},h.current=o},[a,e,n,o]),l.useEffect(()=>{!a||e===null||!s||n===0||Lt.has(e)||(Lt.add(e),o==null||o())},[a,e,s,n,o]),l.useCallback(()=>{var f;const p=m.current;if(!(!p.armed||p.sessionId===null)&&!(p.messageCount>0)&&!Lt.has(p.sessionId))return Lt.add(p.sessionId),(f=h.current)==null||f.call(h),Tx({...d.current,originPath:Ol()})},[])}function Ax(e,t,n,s=!1){if(e!=="error"||t||s)return!1;let o=-1;for(let i=n.length-1;i>=0;i--)if(n[i].role==="user"){o=i;break}return!n.slice(o+1).some(i=>i.parts.some(c=>c.type==="error"&&c.code!==Kr))}const _x=4e3;function Mx(e){const t=e.approvalDisplayName||kt(e.toolName,e.input??"");return e.approvalOutcome==="allowed"?`Allowed ${t}. Recorded in the chat.`:e.approvalOutcome==="denied"?`Didn’t allow ${t}. Recorded in the chat.`:`${t} wasn’t answered in time, so it didn’t run. Recorded in the chat.`}function Ox(e,t){const n=l.useRef(null),s=l.useRef(null),[o,a]=l.useState({text:"",nonce:0});return l.useEffect(()=>{s.current!==t&&(s.current=t,n.current=null);const i=e.filter(d=>d.type==="tool_call"&&d.approvalOutcome!==void 0);if(n.current===null){n.current=new Set(i.map(d=>d.toolCallId));return}const c=i.filter(d=>!n.current.has(d.toolCallId));if(c.length===0)return;for(const d of c)n.current.add(d.toolCallId);const u=c.length===1?Mx(c[0]):`Answered ${c.length} permission requests. Recorded in the chat.`;a(d=>({text:u,nonce:d.nonce+1}))},[e,t]),l.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(c=>({text:"",nonce:c.nonce})),_x);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}`}const xr=["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"],yr=5e3,Ix=1e3,Dx=1500,Px=new Set;function $x(e){const t=l.useRef(new Map),n=ao({byTask:new Map,assigned:0}),[s,o]=l.useState(Px),[,a]=l.useState(0),i=l.useMemo(()=>{const u=new Map;for(const d of e)for(const m of d.parts)m.type==="background_task"&&u.set(m.taskId,m);return u},[e]);l.useEffect(()=>{if(!Array.from(i.values()).some(m=>m.taskType==="bash"&&m.status==="running"&&Date.now()-m.startedAt<yr))return;const d=setInterval(()=>{a(m=>m+1)},Ix);return()=>clearInterval(d)},[i]);const c=l.useRef(new Set);return l.useLayoutEffect(()=>{for(const[u,d]of i)t.current.get(u)==="running"&&d.status!=="running"&&!Ms(d)&&o(h=>h.has(u)?h:new Set(h).add(u)),t.current.set(u,d.status)},[i]),l.useEffect(()=>{for(const u of s)c.current.has(u)||(c.current.add(u),setTimeout(()=>{c.current.delete(u),o(d=>{if(!d.has(u))return d;const m=new Set(d);return m.delete(u),m})},Dx))},[s]),l.useMemo(()=>{const u=Date.now(),d=[],m=n.read();let h=m.assigned;for(const[p,f]of i){const g=f.status==="running",x=s.has(p);if(!g&&!x||f.taskType==="bash"&&g&&u-f.startedAt<yr)continue;let y=m.byTask.get(p);y===void 0&&(y=xr[h%xr.length],h+=1,m.byTask.set(p,y),n.write({byTask:m.byTask,assigned:h})),d.push({taskId:f.taskId,taskType:f.taskType,status:f.status,color:y,startedAt:f.startedAt,description:f.description,toolUses:f.toolUses,lastToolName:f.lastToolName,durationMs:f.durationMs,summary:f.summary,command:f.command,ambient:Ms(f)})}return d},[i,s,n])}const Fx=new Set(["streaming","blocked"]);function Lx(e,t){return e.length===0||e[0].waitingOn!==void 0||t&&Fx.has(t)?e:e.slice(1)}function Nn(e,t,n){return`${e} ${e===1?t:n}`}const br={"delivery-owed":"a helper’s report","waiting-on-person":"your answer","timer-pending":"a reminder the agent set"},Ux={"timer-pending":"Switching now cancels the reminder."};function qx(e){const{agents:t,shells:n,other:s}=e.holding,o=[t>0?Nn(t,"helper","helpers"):void 0,n>0?Nn(n,"command","commands"):void 0,s>0?Nn(s,"background job","background jobs"):void 0].filter(d=>d!==void 0),a=o.length===0?void 0:o.length===1?o[0]:`${o.slice(0,-1).join(", ")} and ${o.at(-1)}`,i=e.pins,c=i.includes("cwd")&&e.targetFolderName?`moves to ${e.targetFolderName}`:i.includes("agentIdentity")?"switches agents":i.includes("systemPromptAppend")?"loads new instructions":"applies new settings";return{line:`${a!==void 0?`Held for ${a}.`:e.because!==void 0&&br[e.because]!==void 0?`Held for ${br[e.because]}.`:"Held until the agent is free."} Sending it ${c}.`,switchHint:a!==void 0?`Switching now stops ${a}.`:(e.because!==void 0?Ux[e.because]:void 0)??"Switching now stops what the agent is doing."}}const zx={"session-idle":null,unsupported:"Queued. This agent can’t take a message mid-task.","not-steerable":"Couldn’t cut in. It’s waiting in line.","not-stageable":null,"turn-owned-elsewhere":"Couldn’t cut in: something else is running it. It’s waiting in line.","pending-interaction":"Queued. The agent needs your answer first."};function Bx(e){return e!=null&&e.degradedBecause?zx[e.degradedBecause]:null}function kr(e){return(e==null?void 0:e.code)==="QUEUED_MESSAGE_NOT_FOUND"}function Wx({sessionId:e,waiting:t,onEnqueue:n}){const s=be(),o=Il(e??""),[a,i]=l.useState(null),c=l.useMemo(()=>t.map(S=>({id:S.id,content:S.content,mine:s.clientId===void 0||S.enqueuedBy===s.clientId,fromChat:S.fromChats!==void 0||S.enqueuedBy.startsWith("chat:"),...S.fromChats!==void 0||S.enqueuedBy.startsWith("chat:")?{sender:hh(S.fromChats)}:{},notice:Bx(o[S.id]),...S.waitingOn?{waiting:qx(S.waitingOn)}:{}})),[t,o,s.clientId]),u=l.useMemo(()=>{if(a===null)return null;const S=c.findIndex(T=>T.id===a);return S===-1?null:S},[a,c]),d=l.useCallback(()=>{var S;if(e)return(S=Ce.getState().getSession(e).queuedMessages[0])==null?void 0:S.id},[e]),m=l.useCallback((S,T)=>{S().catch(R=>{kr(R)||Oe.error(T)})},[]),h=l.useCallback(async S=>{const T=S.trim();return!T||!e?!1:n(T)},[e,n]),p=l.useCallback((S,T)=>{e&&m(()=>s.updateQueuedMessage(e,S,{content:T}),"Couldn’t save that change")},[e,s,m]),f=l.useCallback(S=>{i(T=>T===S?null:T),e&&m(()=>s.removeQueuedMessage(e,S),"Couldn’t take that message off the queue")},[e,s,m]),g=l.useCallback((S,T)=>{if(!e)return;const R=E=>s.updateQueuedMessage(e,S,{move:{before:E}});m(async()=>{try{await R(T)}catch(E){if(!kr(E))throw E;const O=d();if(O===void 0||O===S)return;await R(O)}},"Couldn’t move that message")},[e,s,m,d]),x=l.useCallback(S=>c.findIndex(R=>R.id===S)<=0?!1:(i(R=>R===S?null:R),g(S,c[0].id),!0),[c,g]),y=l.useCallback(S=>{const T=c.findIndex(R=>R.id===S);T<=0||g(S,c[T-1].id)},[c,g]),b=l.useCallback(S=>{const T=c.find(R=>R.id===S);return!T||T.fromChat?null:(i(S),T.content)},[c]),v=l.useCallback(()=>{i(null)},[]),j=l.useCallback(S=>{a!==null&&(p(a,S),i(null))},[a,p]);return{queue:c,editingId:a,editingIndex:u,addToQueue:h,removeFromQueue:f,sendNow:x,moveUp:y,startEditing:b,cancelEditing:v,saveEditing:j,updateQueued:p}}function ma(e,t){return e===null?null:`${e} ${t??""}`}function vr(e,t,n){for(let s=t;s>=0&&s<e.length;s+=n)if(!e[s].fromChat)return s;return-1}function Hx({input:e,setInput:t,sessionId:n,selectedCwd:s,waiting:o,onEnqueue:a,onSteer:i,onStage:c,tryNativeCommand:u,chatInputRef:d}){const m=l.useRef(""),h=l.useRef(null),p=ma(n,s);l.useEffect(()=>{m.current="",h.current=null},[p]);const f=Wx({sessionId:n,waiting:o,onEnqueue:a}),g=f.cancelEditing;l.useEffect(()=>{g()},[p,g]);const x=l.useCallback(()=>{const P=f.editingId;if(P===null)return;const M=e.trim();M&&(f.updateQueued(P,M),wh(M)&&Oe.warning("Saved as a command. It runs instead of sending."))},[e,f]),y=Rn(f.editingId),b=Rn(f.updateQueued);l.useEffect(()=>{const P=n;return()=>{const M=y.read();if(M===null||!P)return;const D=re.getState(),W=D.getSession(P).input.trim();W&&b.read()(M,W),D.updateSession(P,{input:m.current})}},[p]);const v=l.useCallback(P=>{const M=e.trim();if(!M)return;const D=u(M);if(D.handled){if(!D.ran)return;D.confirmed?Pn(n,M,D.confirmed):t("");return}if(h.current===M)return;h.current=M,rt.getState().recordOpened("session",n),s&&rt.getState().recordOpened("agent",s);const W=P(M);W.finally(()=>{h.current===M&&(h.current=null)}),Pn(n,M,W)},[e,s,n,t,u]),j=l.useCallback(()=>v(P=>f.addToQueue(P)),[v,f]),S=l.useCallback(()=>{i&&v(i)},[v,i]),T=l.useCallback(()=>{c&&v(c)},[v,c]),R=l.useCallback(P=>{var W,G;if(f.editingId===P){(W=d.current)==null||W.focus();return}const M=f.editingId!==null;M&&x();const D=f.startEditing(P);D!==null&&(M||(m.current=e),t(D),(G=d.current)==null||G.focus())},[e,f,x,t,d]),E=l.useCallback(()=>{if(f.editingId===null)return;const P=e.trim();if(!P)return;const M=u(P);if(M.handled){M.ran&&(f.cancelEditing(),t(m.current));return}f.saveEditing(P),t(m.current)},[e,f,t,u]),O=l.useCallback(()=>{f.cancelEditing(),t(m.current)},[f,t]),A=l.useCallback(P=>{f.editingId===P&&t(m.current),f.removeFromQueue(P)},[f,t]),I=l.useCallback(P=>{const M=f.editingId===P;M&&x(),f.sendNow(P)&&M&&t(m.current)},[f,x,t]),F=l.useCallback(P=>{f.moveUp(P)},[f]),N=l.useCallback(P=>{var W;const M=(W=f.queue[P])==null?void 0:W.id;if(M!==void 0&&M===f.editingId)return;x();const D=M===void 0?null:f.startEditing(M);if(D===null){f.cancelEditing(),t(m.current);return}t(D)},[f,x,t]),k=l.useCallback(()=>{x(),f.cancelEditing(),t(m.current)},[x,f,t]),C=l.useCallback(()=>{const{editingIndex:P,queue:M}=f,D=vr(M,(P??M.length)-1,-1);if(P===null){if(D===-1)return;m.current=e,N(D)}else D!==-1?N(D):k()},[N,e,k,f]),w=l.useCallback(()=>{const{editingIndex:P,queue:M}=f;if(P===null)return;const D=vr(M,P+1,1);D!==-1?N(D):k()},[N,k,f]);return{queue:f.queue,editingId:f.editingId,editingIndex:f.editingIndex,handleQueue:j,handleSteer:S,handleStage:T,handleQueueEdit:R,handleQueueSaveEdit:E,handleQueueCancelEdit:O,handleQueueRemove:A,handleQueueSend:I,handleQueueMoveUp:F,handleQueueNavigateUp:C,handleQueueNavigateDown:w,leaveQueueForStop:k}}const Gx=5e3,Sr=3;function fa(){try{const e=Number(localStorage.getItem(io.PLACEHOLDER_HINT_CYCLES));return Number.isFinite(e)&&e>0?e:0}catch{return 0}}function Kx(){const e=fa()+1;try{localStorage.setItem(io.PLACEHOLDER_HINT_CYCLES,String(e))}catch{}return e}function Qx(e){const t=[...e];for(let n=t.length-1;n>0;n--){const s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}return t}function Vx({defaultText:e,hints:t,enabled:n,intervalMs:s=Gx}){const[o]=l.useState(()=>t.length>0?Qx(t):[]),[a,i]=l.useState(()=>fa()>=Sr),[c,u]=l.useState({key:0,hintIndex:-1}),d=l.useRef(0),m=l.useRef(0),h=l.useRef(!1);return l.useEffect(()=>{if(a||!n||t.length===0){h.current&&(h.current=!1,d.current+=1,u({key:d.current,hintIndex:-1}));return}const f=setInterval(()=>{if(d.current+=1,h.current=!h.current,!h.current){u({key:d.current,hintIndex:-1});return}const g=m.current%t.length;m.current+=1,m.current%t.length===0&&Kx()>=Sr&&i(!0),u({key:d.current,hintIndex:g})},s);return()=>clearInterval(f)},[n,t.length,s,a]),{text:c.hintIndex>=0?o[c.hintIndex]??e:e,key:c.key}}const Cn=/[.!?…:](?=\s|$)|\n/g;function jr(e,t,n){const s=e.startsWith(t)?t.length:0,o=e.slice(0,s),a=e.slice(s);if(a.trim()==="")return{chunk:"",announced:o};if(n)return{chunk:a.trim(),announced:e};Cn.lastIndex=0;let i=-1;for(let c=Cn.exec(a);c!==null;c=Cn.exec(a))i=c.index+c[0].length;return i===-1?{chunk:"",announced:o}:{chunk:a.slice(0,i).trim(),announced:e.slice(0,s+i)}}const Yx=1500,Xx=4e3,Jx=400;function Zx({messageId:e,text:t,isStreaming:n}){const s=l.useRef(new Map),[o,a]=l.useState({text:"",nonce:0});return l.useEffect(()=>{if(e===void 0)return;if(s.current.get(e)===void 0){if(!n)return;s.current.clear(),s.current.set(e,{announced:t.length<=Jx?"":t})}const c=s.current.get(e),{chunk:u,announced:d}=jr(t,c.announced,!1);c.announced=d,u!==""&&a(h=>({text:u,nonce:h.nonce+1}));const m=setTimeout(()=>{const h=jr(t,c.announced,!0);c.announced=h.announced,h.chunk!==""&&a(p=>({text:h.chunk,nonce:p.nonce+1}))},Yx);return()=>clearTimeout(m)},[e,t,n]),l.useEffect(()=>{if(o.text==="")return;const i=setTimeout(()=>a(c=>({text:"",nonce:c.nonce})),Xx);return()=>clearTimeout(i)},[o]),o.text===""?"":o.nonce%2===0?o.text:`${o.text}`}function ey({text:e,indices:t,startOffset:n=0}){const s=new Set(t.map(o=>o-n));return r.jsx(r.Fragment,{children:e.split("").map((o,a)=>s.has(a)?r.jsx("span",{className:"text-foreground font-semibold",children:o},a):r.jsx("span",{children:o},a))})}function ty({filteredFiles:e,selectedIndex:t,onSelect:n}){return l.useEffect(()=>{const s=document.getElementById(`file-item-${t}`);s&&s.scrollIntoView({block:"nearest"})},[t]),r.jsx(Q.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:s=>s.preventDefault(),children:r.jsx("div",{id:"file-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No files found."}):e.map((s,o)=>{const a=o===t,i=s.isDirectory?Dl:vo;return r.jsxs("div",{id:`file-item-${o}`,role:"option","aria-selected":a,"data-selected":a,tabIndex:a?0:-1,onClick:()=>n(s),onKeyDown:c=>{c.key==="Enter"&&n(s)},className:"data-[selected=true]:bg-accent hover:bg-muted flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsx(i,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:r.jsx(ey,{text:s.filename,indices:s.indices,startOffset:s.directory.length})}),s.directory&&r.jsx("p",{className:"text-muted-foreground/70 truncate text-xs leading-normal",children:s.directory})]})]},s.path)})})})}function ny(e){const t=be();return ut({queryKey:["files",{cwd:e??null}],queryFn:()=>t.listFiles(e),enabled:!!e,staleTime:Ge.FILES_STALE_TIME_MS,gcTime:Ge.FILES_GC_TIME_MS})}const pa={reactions:!1,threads:!1,runWith:!0,attachments:!0,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!0,asks:!0},ha='[data-testid="model-config-trigger"]',sy=3e3;function ry(e){var t;(t=e==null?void 0:e.querySelector(ha))==null||t.click()}function oy(e,t=sy){const n=Date.now()+t,s=()=>{var a;const o=(a=e())==null?void 0:a.querySelector(ha);if(o)return o.click();Date.now()<n&&setTimeout(s,50)};s()}function ay(e,t){const{openSessionView:n}=Pl();return l.useCallback(()=>{if(!t)return ry(e.current);n(),oy(()=>e.current)},[t,n,e])}const wr=new WeakMap;function iy(e,t,n,s,o=!0){const a=new Set(t),i=new Set(n.flatMap(m=>m.roomMessage?[m.roomMessage.entryId]:[]));let c;const u=o?null:dy(n),d=[];for(const m of e){if(m.kind!=="post"||m.threadRootEntryId||m.sessionId!==null&&a.has(m.sessionId)&&(c??(c=cy(n)),c.has(m.body.text)||!o&&(u===null||Date.parse(m.createdAt)<u))||i.has(m.id))continue;let h=wr.get(m);if(!h){const p=m.body.text;h={id:`direct-note-${m.id}`,role:s.has(m.authorId)?"assistant":"user",content:p,parts:[{type:"text",text:p}],timestamp:m.createdAt,_directNote:{roomId:m.roomId,entryId:m.id,seq:m.seq}},wr.set(m,h)}d.push(h)}return d}const ly=/(?:^|[_.])(?:post_to_room|relay_notify_user)$/;function cy(e){const t=new Set;for(const n of e){if(n.role!=="assistant")continue;const s=[];for(const o of n.parts??[])if(o.type==="text")t.add(o.text),t.add(o.text.trim()),s.push(o.text.trim());else if(o.type==="tool_call"&&o.input&&ly.test(o.toolName))for(const a of uy(o.input))t.add(a);s.length>1&&t.add(s.filter(Boolean).join(`
|
|
42
|
+
|
|
43
|
+
`).trim())}return t}function uy(e){try{const t=JSON.parse(e);return t===null||typeof t!="object"?[]:Object.values(t).filter(n=>typeof n=="string")}catch{return[]}}function dy(e){let t=null;for(const n of e){const s=Date.parse(n.timestamp);!Number.isNaN(s)&&(t===null||s<t)&&(t=s)}return t}function my(e,t){if(t.length===0)return e;const n=[];let s=0;for(const o of e){const a=o.timestamp==="",i=Date.parse(o.timestamp);for(;s<t.length&&(a||!Number.isNaN(i)&&Date.parse(t[s].timestamp)<i);)n.push(t[s]),s+=1;n.push(o)}for(;s<t.length;)n.push(t[s++]);return n}function fy(e,t,n=!0){if(!t||t.entries.length===0)return{messages:e,lastSeenBeforeUnread:null,unreadFromStart:!1};const s=iy(t.entries,t.sessionIds,e,t.agentAuthorIds,n),o=my(e,s),{readSeq:a}=t,i=a===null?-1:o.findIndex(c=>c._directNote!==void 0&&c.role==="assistant"&&c._directNote.seq>a);return{messages:o,lastSeenBeforeUnread:i>0?o[i-1].id:null,unreadFromStart:i===0}}function py(e){var m,h,p;const t=$l(e),n=((m=t.data)==null?void 0:m.roomId)??null,s=Fl(n),o=Ll(n),a=s.data,i=o.data;fu(n,i!==void 0),Ul(a,i??Nr);const c=((h=a==null?void 0:a.members.find(f=>f.author.id===a.viewerAuthorId))==null?void 0:h.lastReadSeq)??null,u=gy(n,c),d=((p=t.data)==null?void 0:p.sessionIds)??hy;return l.useMemo(()=>{const f=s.isError||o.isError,g=n===null||f||i!==void 0&&u!==null;return{roomId:n,entries:i??Nr,sessionIds:d,agentAuthorIds:new Set(((a==null?void 0:a.members)??[]).filter(x=>x.author.kind==="agent").map(x=>x.author.id)),readSeq:u,ready:e===null||t.isError||t.isFetched&&g}},[e,t.isError,t.isFetched,n,a,i,d,u,s.isError,o.isError])}const hy=[],Nr=[];function gy(e,t){const[n,s]=l.useState({key:null,value:null});return n.key===e&&n.value!==null?n.value:e===null||t===null?null:(s({key:e,value:t}),t)}function Cr(e){return e>=1e3?`~${(e/1e3).toFixed(1)}k tokens`:`~${Math.round(e)} tokens`}function xy(e){const{formatted:t}=jo(e.status==="streaming"?e.streamStartTime:null),n=Or(e.permissionMode),s=l.useRef(e.status),o=l.useRef(t),a=l.useRef(e.estimatedTokens),[i,c]=l.useState(!1);l.useEffect(()=>{e.status==="streaming"&&(o.current=t,a.current=e.estimatedTokens,s.current!=="streaming"&&c(!1))},[e.status,t,e.estimatedTokens]),l.useEffect(()=>{s.current==="streaming"&&e.status==="idle"&&a.current>0&&c(!0),s.current=e.status},[e.status]),l.useEffect(()=>{if(!i)return;const d=setTimeout(()=>c(!1),Yt.TURN_COMPLETE_DISMISS_MS);return()=>clearTimeout(d)},[i]);const u=ou({capabilities:pa,asks:e.asks??bo,stalled:!1,presence:au,turn:{status:e.status,isWaitingForUser:e.isWaitingForUser,waitingType:e.waitingType,operationProgress:e.operationProgress==null?null:{message:e.operationProgress.message??null,determinate:e.operationProgress.determinate,percent:e.operationProgress.percent??null},systemStatus:e.systemStatus??null,elapsed:t,activity:e.activity,tokens:Cr(e.estimatedTokens),isBypass:n,showComplete:i,lastElapsed:o.current,lastTokens:Cr(a.current)}});return e.quietNumbers?by(u):u}const yy={kind:"empty"};function by(e){return e.kind==="turn-streaming"?{...e,elapsed:"",tokens:""}:e.kind==="turn-complete"?yy:e}function ky(e,t){var y,b,v,j;const n=ql(e),s=n.mode==="dm"&&n.chat!==null,o=n.mode==="pending",a=zl(s?n.chat.agentPath:null),{data:i}=qn(),c=Bl(),u=((b=(y=i==null?void 0:i.profile)==null?void 0:y.displayName)==null?void 0:b.trim())||null,d=t?Zt(t):null,{id:m,name:h}=a,p=((v=a.visual)==null?void 0:v.emoji)??null,f=((j=a.visual)==null?void 0:j.color)??null,g=l.useMemo(()=>o?{agent:null,humanName:null,settled:!1}:s?{agent:m!==null&&h!==null&&p!==null&&f!==null?{id:m,displayName:h,emoji:p,color:f}:null,humanName:u,settled:!0}:null,[o,s,m,h,p,f,u]);if(g===null)return{directMessage:null,humanName:u,transcriptNames:{directMessage:null,humanName:u},placeholder:d?`Message ${d}…`:"Send a message…",quietTurnNumbers:!1};const x=h??d;return{directMessage:g,humanName:u,transcriptNames:{directMessage:g,humanName:u},placeholder:x?`Message ${x}`:"Send a message",quietTurnNumbers:!c}}function vy(e){const{sessionId:t,placeholder:n,files:s}=e,o=l.useRef(e);l.useEffect(()=>{o.current=e});const a=l.useCallback(x=>o.current.files.addFiles(x),[]),i=l.useCallback(x=>o.current.files.removeFile(x),[]),c=l.useCallback(x=>o.current.files.retryFile(x),[]),u=l.useCallback(()=>o.current.files.cancelUpload(),[]),{pendingFiles:d,hasFailedUpload:m,isUploading:h}=s,p=l.useMemo(()=>({staged:d,add:a,remove:i,retry:c,cancel:u,hasFailed:m,isUploading:h,holdsSendWhileUploading:!0}),[d,m,h,a,i,c,u]),f=l.useCallback(async x=>{await o.current.submit(x.text)},[]),g=l.useCallback(async x=>{if(!await o.current.enqueue(x.text))throw new Error("Couldn’t queue that message. Try again.")},[]);return l.useMemo(()=>({kind:"session",id:t,placeholder:n,canSend:t!=="",...t===""?{canSendReason:"Pick a chat, or start a new one."}:{},send:f,queue:g,attachments:p}),[t,n,p,f,g])}function Sy({error:e,composerAgent:t,onRetry:n}){return e.code===Hr&&e.agentId?r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(Mo,{agentId:e.agentId,...(t==null?void 0:t.id)===e.agentId?{agentName:Zt(t,"This agent")}:{}})}):r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(nn,{message:e.message,heading:e.heading,subtext:e.message,onRetry:e.retryable?n:void 0})})}const jy={duration:.16,delay:.08,ease:[.16,1,.3,1]},wy={duration:0};function Ny({sessionId:e,activeInteraction:t,pendingApprovals:n,focusedOptionIndex:s,onToolRef:o,onToolDecided:a,queueDepth:i=0,allowsDenyReason:c=!0}){const u=g=>a(t.toolCallId,g),d=Le(),{answerAll:m,isAnswering:h,error:p}=Wl(),f=l.useMemo(()=>n.map(g=>({sessionId:e,cwd:"",interaction:{type:"approval",id:g.toolCallId,startedAt:g.approvalStartedAt??0,remainingMs:g.timeoutMs??0,toolName:g.toolName,input:g.input??"",hasSuggestions:g.approvalHasSuggestions??!1}})),[n,e]);return r.jsxs(r.Fragment,{children:[n.length>=2&&r.jsx(Hl,{className:"mb-1.5",headline:`${n.length} tools are waiting on you`,items:n.map(g=>({id:g.toolCallId,line:kt(g.toolName,g.input??"")})),onAllowAll:()=>void m(f,"allow"),onDenyAll:()=>void m(f,"deny"),isAnswering:h,error:p}),r.jsx(me,{mode:"wait",initial:!1,children:r.jsx(Q.div,{initial:d?!1:{opacity:0,y:6},animate:{opacity:1,y:0},transition:d?wy:jy,children:t.interactiveType==="approval"?r.jsx(Qr,{ref:o,sessionId:e,toolCallId:t.toolCallId,toolName:t.toolName,input:t.input||"",isActive:!0,onDecided:u,timeoutMs:t.timeoutMs,approvalStartedAt:t.approvalStartedAt,approvalRemainingMs:t.approvalRemainingMs,approvalParked:t.approvalParked,approvalTitle:t.approvalTitle,approvalDisplayName:t.approvalDisplayName,approvalDescription:t.approvalDescription,approvalBlockedPath:t.approvalBlockedPath,approvalDecisionReason:t.approvalDecisionReason,approvalHasSuggestions:t.approvalHasSuggestions,approvalAlwaysAllowScope:t.approvalAlwaysAllowScope,allowsDenyReason:c}):t.interactiveType==="question"&&t.questions?r.jsx(Vr,{ref:o,sessionId:e,toolCallId:t.toolCallId,questions:t.questions,answers:t.answers,isActive:!0,focusedOptionIndex:s,onDecided:u}):null},t.toolCallId)}),i>0&&r.jsx("p",{className:"text-muted-foreground px-1 pt-2 text-xs",children:i===1?"1 message sends once you answer.":`${i} messages send once you answer.`})]})}function Cy({filteredCommands:e,selectedIndex:t,onSelect:n}){const s=l.useMemo(()=>{const o=[],a=new Map;let i=0;for(const c of e){const u=c.namespace??"built-in";a.has(u)||a.set(u,[]),a.get(u).push({cmd:c,index:i++})}for(const[c,u]of a)o.push({namespace:c,items:u});return o},[e]);return l.useEffect(()=>{const o=document.getElementById(`command-item-${t}`);o&&o.scrollIntoView({block:"nearest"})},[t]),r.jsx(Q.div,{initial:{opacity:0,scale:.98,y:4},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,y:4},transition:{duration:.15,ease:[0,0,.2,1]},className:"bg-popover max-h-80 overflow-hidden rounded-lg border shadow-lg",onMouseDown:o=>o.preventDefault(),children:r.jsx("div",{id:"command-palette-listbox",role:"listbox",className:"max-h-72 overflow-y-auto p-1.5",children:e.length===0?r.jsx("div",{className:"text-muted-foreground px-2 py-4 text-center text-sm",children:"No commands found."}):s.map(({namespace:o,items:a},i)=>r.jsxs("div",{children:[i>0&&r.jsx("div",{className:"bg-border mx-2 my-1.5 h-px"}),r.jsx("div",{className:"text-muted-foreground/70 text-2xs px-2 pt-1.5 pb-1 font-medium tracking-wide uppercase",children:o}),a.map(({cmd:c,index:u})=>{const d=u===t,m=c.disabled===!0;return r.jsxs("div",{id:`command-item-${u}`,role:"option","aria-selected":d,"aria-disabled":m,"data-selected":d,"data-disabled":m,tabIndex:d?0:-1,onClick:()=>{m||n(c)},onKeyDown:h=>{h.key==="Enter"&&!m&&n(c)},className:m?"cursor-not-allowed rounded-md px-2 py-1.5 opacity-45":"data-[selected=true]:bg-accent hover:bg-muted cursor-pointer rounded-md px-2 py-1.5 transition-colors duration-100",children:[r.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[r.jsx("span",{className:"text-foreground text-control shrink-0 font-mono font-medium",children:c.fullCommand}),c.argumentHint&&r.jsx("span",{className:"text-muted-foreground/50 shrink-0 font-mono text-xs",children:c.argumentHint}),m&&c.disabledReason?r.jsx("span",{className:"text-muted-foreground/70 text-2xs ml-auto shrink-0",children:c.disabledReason}):c.matchedAlias&&r.jsxs("span",{className:"text-muted-foreground/60 text-2xs ml-auto shrink-0 font-mono italic",children:["matched /",c.matchedAlias.replace(/^\//,"")]})]}),c.description&&r.jsx("p",{className:"text-muted-foreground mt-0.5 truncate text-xs leading-normal",children:c.description})]},c.fullCommand)})]},o))})})}function Ty(e,t,n,s){return e!==null?`Edit queued message ${e+1} of ${n}. Press Enter to save`:t&&n>0?`Compose another (${n} queued)`:t?"Compose next. It sends when ready":s}function Ry({asDirectMessage:e=!1,chatInputRef:t,input:n,autocomplete:s,steerContent:o,addContextContent:a,tryNativeCommand:i,commandPending:c,agentLookupPending:u=!1,agentLookupError:d=!1,status:m,stop:h,setInput:p,sessionId:f,sessionStatus:g,waiting:x,interaction:y,sync:b}){var Ie,Re;const{active:v,pendingApprovals:j,focusedOptionIndex:S,onToolRef:T,onToolDecided:R}=y,E=m==="streaming",O=ie(se=>se.isTextStreaming),[A]=lo(),I=be(),{data:F}=Zn(A),N=Gl(F??null,A??""),k=F?Zt(F):void 0,{target:C}=iu(),w=(C==null?void 0:C.placeholder)??"Send a message…",P=Kl(f),M=zf(f),D=en(f),W=Jt(D),G=Ql(f),V=((W==null?void 0:W.supportsSteer)??!1)&&(G??!0),B=(W==null?void 0:W.supportsContextStaging)??!1,L=((Ie=W==null?void 0:W.permissionModes)==null?void 0:Ie.denyReason)??!0,X=l.useCallback(async se=>{if((C==null?void 0:C.queue)===void 0)return!1;try{return await C.queue({text:se}),!0}catch{return!1}},[C]),_=Hx({input:n,setInput:p,sessionId:f,selectedCwd:A,waiting:x,onEnqueue:X,onSteer:o,onStage:a,tryNativeCommand:i,chatInputRef:t}),[q,te]=l.useState(null),$=l.useRef(null),J=l.useCallback(se=>{const ae=$.current;if($.current=null,se.length===0)return;const Ee=se.map(De=>ae&&De.id===ae.id?ae.content:De.content).join(`
|
|
44
|
+
|
|
45
|
+
`),Ne=re.getState().getSession(f).input.trim();p(Ne?`${Ne}
|
|
46
|
+
|
|
47
|
+
${Ee}`:Ee)},[f,p]),[oe,ne]=l.useState(null),de=oe===f&&E,K=l.useRef(null),Z=l.useCallback(()=>{K.current=null,ne(null)},[]);l.useEffect(()=>{E||Z()},[E,f,Z]);const je=l.useRef(E);l.useEffect(()=>{je.current=E},[E]);const ke=_.leaveQueueForStop,ee=l.useRef(_.editingId);l.useEffect(()=>{ee.current=_.editingId},[_.editingId]);const we=l.useCallback(()=>{const se=ee.current;if(se!==null){const ae=re.getState().getSession(f).input.trim();ae&&($.current={id:se,content:ae}),ke()}K.current=f,ne(f),h().then(ae=>{J(ae.cancelled),dx(ae.receipt,je.current)&&Z();const Ee=ux(ae.receipt);Ee.message!==null&&!Xn(ae.receipt)&&(Ee.isFailure?Oe.error(Ee.message):Oe.warning(Ee.message))}).catch(()=>{Z()})},[f,h,J,Z,ke]),ve=l.useCallback(()=>{if(K.current===f||de)return;if(x.length===0){we();return}const se=x.filter(ae=>ae.enqueuedBy.startsWith("chat:")).length;te({sessionId:f,queuedCount:x.length-se,fromChatCount:se})},[f,de,x.length,we]),qe=l.useCallback(()=>{K.current===f||de||(te(null),we())},[f,de,we]);l.useEffect(()=>{(q==null?void 0:q.sessionId)===f&&x.length===0&&te(null)},[q,f,x.length]);const{messages:he}=ro(f),ge=no(f),Te=l.useMemo(()=>da(ge,he),[ge,he]),le=$x(Te),_e=l.useCallback(async se=>{if(f)try{await I.stopTask(f,se)}catch(ae){console.error("[chat] Failed to stop task:",ae)}},[f,I]),pe=l.useCallback(()=>{f&&I.switchSessionProcess(f).catch(()=>{Oe.error("Couldn’t switch. Try again.")})},[f,I]),Se=l.useRef(n);l.useEffect(()=>{Se.current=n});const xe=l.useCallback(se=>{var De;const ae=Se.current,Ee=ae.length>0&&!/\s$/.test(ae)?" ":"",Ne=`${ae}${Ee}${se}`;p(Ne),(De=t.current)==null||De.focusAt(Ne.length)},[p,t]);l.useEffect(()=>gu(xe),[xe]);const Me=!E&&_.editingIndex===null,$e=Vx({defaultText:w,hints:Vh,enabled:!e&&Me&&n===""}),ze=yu(),Y=l.useCallback(()=>{s.dismissPalettes(),!(C===null||!C.canSend)&&C.send({text:n})},[s,C,n]),U=l.useCallback(()=>{s.dismissPalettes(),_.handleQueue()},[s,_]),ce=l.useCallback(()=>{s.dismissPalettes(),_.handleSteer()},[s,_]),ye=l.useCallback(()=>{s.dismissPalettes(),_.handleStage()},[s,_]);return r.jsx(bt.Composer,{className:"chat-input-container",onPathDropped:se=>xe(xu(se)),inputRef:t,value:n,onChange:s.handleInputChange,onSubmit:Y,head:r.jsx(me,{children:E&&r.jsx(Ku,{color:N.color,isTextStreaming:O,edge:"top"})}),asks:v?r.jsx(Ny,{sessionId:f,activeInteraction:v,pendingApprovals:j,focusedOptionIndex:S,onToolRef:T,onToolDecided:R,queueDepth:_.queue.length,allowsDenyReason:L}):null,overlays:r.jsx(r.Fragment,{children:r.jsxs(me,{children:[s.commands.show&&r.jsx(Cy,{filteredCommands:s.commands.filtered,selectedIndex:s.commands.selectedIndex,onSelect:s.handleCommandSelect}),s.files.show&&r.jsx(ty,{filteredFiles:s.files.filtered,selectedIndex:s.files.selectedIndex,onSelect:s.handleFileSelect})]})}),queue:r.jsx(me,{children:_.queue.length>0&&r.jsx(yh,{queue:_.queue,editingId:_.editingId,onEdit:_.handleQueueEdit,onRemove:_.handleQueueRemove,onSend:_.handleQueueSend,onMoveUp:_.handleQueueMoveUp,onSwitchNow:pe,statusNote:P?"Waiting for your answer above":((Re=_.queue[0])==null?void 0:Re.waiting)!==void 0?"Sending when the agent is free":"Sending one at a time as the agent finishes"})}),aboveInput:r.jsx(mh,{tasks:le,onStopTask:_e}),footer:r.jsx(bt.Footer,{asChild:!0,children:r.jsx(qh,{sessionId:f,sessionStatus:g,isStreaming:E,syncConnectionState:b.connectionState,agentName:k,agentColor:N.color,agentEmoji:N.emoji,agentPath:A??void 0,lineHidden:e})}),input:{isStreaming:E,commandPending:c,...u||d?{canSubmit:!1,canSubmitReason:d?"Check this folder again before you start.":"Checking this folder…"}:{},...M.canSubmit?{}:{canSubmit:!1},onStop:ve,stopPending:de,onEscape:s.dismissPalettes,onClear:()=>{p(""),s.dismissPalettes()},isPaletteOpen:s.isPaletteOpen,paletteHasResults:s.paletteHasResults,onArrowUp:s.handleArrowUp,onArrowDown:s.handleArrowDown,onCommandSelect:s.handleKeyboardSelect,activeDescendantId:s.activeDescendantId,paletteListboxId:s.paletteListboxId,onCursorChange:s.handleCursorChange,richText:ze,editingQueueItem:_.editingIndex!==null,..._.editingIndex===null?{}:{editingPosition:_.editingIndex+1},queueDepth:_.queue.length,onQueue:U,...V?{onSteer:ce}:{},...B?{onStage:ye}:{},onSaveEdit:_.handleQueueSaveEdit,onCancelEdit:_.handleQueueCancelEdit,onQueueNavigateUp:_.handleQueueNavigateUp,onQueueNavigateDown:_.handleQueueNavigateDown,queueHasItems:_.queue.length>0,contextKey:ma(f,A)??void 0,placeholder:M.placeholder??Ty(_.editingIndex,E,_.queue.length,w),placeholderOverlay:!e&&Me&&M.canSubmit?r.jsx(Sh,{text:$e.text,animationKey:$e.key}):null},children:r.jsx(bh,{open:(q==null?void 0:q.sessionId)===f,onOpenChange:se=>{se||te(null)},queuedCount:(q==null?void 0:q.queuedCount)??0,fromChatCount:(q==null?void 0:q.fromChatCount)??0,onConfirm:qe})})}const Ey=e=>{const t=e;return t.role==="user"?r.jsx(Hp,{message:t}):r.jsx(os,{message:t})};function Ay(e){return r.jsx(os,{message:e,show:"reply"})}function ga(e){return e.role==="user"&&!e._stagedContext&&!e._chatStop&&!e._directNote&&e.messageType!=="compaction"&&e.messageType!=="local_command_output"}function _y(e){const t=[];let n=null,s=null,o=null;for(const a of e){if(ga(a)){n=a.content.trim()||null,s=a.timestamp||null,o=null;continue}a.role!=="assistant"||!Zo(a.parts??[])||(o===null&&(o={key:a.id,prompt:n,startedAt:s,replies:[],live:!1},t.push(o)),o.replies.push(a),a._streaming&&(o.live=!0))}return t}function My(e){const t=new Map;let n=null;for(const s of e)ga(s)?n=s.timestamp||null:s.role==="assistant"&&n&&t.set(s.id,n);return t}function Oy(e,t){if(!e||!t)return null;const n=Date.parse(t)-Date.parse(e);if(!Number.isFinite(n)||n<1e3)return null;const s=Math.floor(n/1e3);if(s<60)return`${s}s`;const o=s%60;return o===0?`${s/60}m`:`${Math.floor(s/60)}m ${o}s`}function Iy(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(!n._streaming)return null;if(n.role==="assistant")return n.id}return null}const Fn=Yl()(e=>({request:null,ask:t=>e({request:{...t}}),consume:()=>e({request:null})}));function xa(e,t){const n=ie.getState();n.setActiveRightPanelTab(Vl),n.setRightPanelOpen(!0),Fn.getState().ask({sessionId:e,turn:t})}const ya="text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs",ba="focus-ring hover:text-foreground inline-flex items-center gap-1 rounded-sm font-medium transition-colors";function Dy({sessionId:e,messageId:t,steps:n,duration:s,describedBy:o}){const a=["Worked"];return n>0&&a.push(`${n} ${n===1?"step":"steps"}`),s&&a.push(s),r.jsxs("div",{className:ya,"data-testid":"dm-worked-line",children:[r.jsx("span",{children:a.join(" · ")}),r.jsxs("button",{type:"button",className:ba,"aria-describedby":o,onClick:()=>xa(e,t),children:[r.jsx(Jl,{className:"size-3.5","aria-hidden":!0}),"Show work"]})]})}function Py({sessionId:e}){const t=co(e);return r.jsxs("div",{className:ya,"data-testid":"dm-working-line",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"bg-primary size-1.5 shrink-0 rounded-full motion-safe:animate-pulse"}),Xl("streaming",t)]}),r.jsx("button",{type:"button",className:ba,onClick:()=>xa(e,"live"),children:"Watch"})]})}function $y(e,t){for(const n of Object.keys({...e,...t}))if(!(n==="grouping"||n==="author"||n==="feedPosition")&&!Object.is(e[n],t[n]))return!1;return e.grouping.position===t.grouping.position&&Tr(e.author,t.author)&&Tr(e.feedPosition,t.feedPosition)}function Tr(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(s=>Object.is(e[s],t[s]))}const Fy=l.memo(Ly,$y);function Ly({message:e,grouping:t,author:n,sessionId:s,isNew:o=!1,isStreaming:a=!1,isLatestWidgetMessage:i=!0,isFinalMessage:c=!0,activeToolCallId:u=null,onToolRef:d,focusedOptionIndex:m=-1,onToolDecided:h,onRetry:p,onSigninComplete:f,onChooseModel:g,inputZoneToolCallId:x=null,textEffect:y,runtimeLabel:b,allowsDenyReason:v,directRoomId:j,fallbackAt:S,foldWork:T=!1,turnStartedAt:R,liveReply:E=!1,feedPosition:O}){var q,te;const A=l.useId(),I=`${A}-author`,F=`${A}-content`,N=l.useRef(null),k=t.position==="first"||t.position==="only",C=e.role==="user",w=C&&!!e.promptSource&&e.promptSource.kind!=="channel",P=C&&e.messageType!=="local_command_output"&&!w,M=C?(q=e.chatMessages)==null?void 0:q[0]:void 0,D=C&&M===void 0?e.roomMessage:void 0,W=P&&M===void 0&&e.promptSource===void 0&&(D===void 0||((te=D.author)==null?void 0:te.you)===!0)&&e.messageType!=="command"&&e.messageType!=="compaction"&&e.content.trim().length>0,G=e.timestamp||S||"",V=G?Gt(G):"",B=V.length>0,L=B?G:void 0,X=l.useCallback(()=>{var $;return($=N.current)==null?void 0:$.focus()},[]),_=T&&e.role==="assistant";return r.jsx(ko,{value:{sessionId:s,isStreaming:a,isLatestWidgetMessage:i,isFinalMessage:c,activeToolCallId:u,onToolRef:d,focusedOptionIndex:m,onToolDecided:h,onRetry:p,onSigninComplete:f,onChooseModel:g,inputZoneToolCallId:x,textEffect:y,runtimeLabel:b,allowsDenyReason:v},children:r.jsxs(Je.Root,{ref:N,role:P?"user":"assistant",position:t.position,isNew:o,"data-testid":"message-item","data-role":e.role,...k?{"aria-labelledby":I}:{"aria-label":B?`${n.displayName}, ${V}`:n.displayName},"aria-describedby":F,...cu(O),children:[r.jsx(Je.Gutter,{author:n,at:L}),r.jsxs(Je.Body,{children:[r.jsx(Je.Author,{id:I,author:n,at:L,...M?{mark:r.jsx(Bo,{stamp:M}),className:"flex-wrap gap-y-0.5"}:D&&D.roomId!==j?{mark:r.jsx(Rm,{stamp:D}),className:"flex-wrap gap-y-0.5"}:e.promptSource?{className:"flex-wrap gap-y-0.5"}:{}}),(D==null?void 0:D.via)&&r.jsx(lu,{via:D.via}),r.jsx(Je.Content,{id:F,children:_?Ay(e):Ey(e,{rowId:e.id})}),_&&E&&r.jsx(Py,{sessionId:s}),_&&!E&&Zo(e.parts??[])&&r.jsx(Dy,{sessionId:s,messageId:e.id,steps:mp(e.parts??[]),duration:Oy(R,e.timestamp),describedBy:F}),W&&r.jsx(Je.Actions,{runWith:{prompt:e.content,sessionId:s},onExit:X})]})]})})}function Uy({loading:e,onLoad:t}){return r.jsx("div",{className:"flex justify-center px-4 py-3",children:r.jsxs(ue,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:e,"data-testid":"session-load-earlier",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&r.jsx(Ue,{size:"xs"}),e?"Loading earlier messages…":"Earlier messages"]})})}const Rr="Conversation",qy={kind:"notice",id:"session-load-earlier",at:"",body:null},zy=[];function By(e){for(let t=e.length-1;t>=0;t--)if(e[t].content.includes(Su))return t;return-1}function Wy({messages:e,sessionId:t,isLoadingHistory:n=!1,hydrated:s=!1,isTextStreaming:o=!1,activeToolCallId:a=null,onToolRef:i,focusedOptionIndex:c=-1,onToolDecided:u,onRetry:d,onSigninComplete:m,onChooseModel:h,inputZoneToolCallId:p=null,textEffect:f,runtimeLabel:g,allowsDenyReason:x,landOnRow:y,foldFirstPrompt:b=!1,directLog:v,directMessage:j=null,humanName:S=null}){const T=mt(i),R=mt(u),E=mt(d),O=mt(m),A=mt(h),I=Fm(t,e),F=I.messages,{stops:N}=xo(t),k=!I.canLoadEarlier,C=l.useMemo(()=>fy(F,v,k),[F,v,k]),w=l.useMemo(()=>wm(C.messages,N),[C.messages,N]),P=l.useMemo(()=>{let Y=0;return w.map(U=>U._chatStop||U._directNote?-1:Y++)},[w]),M=ao(null);M.read()===null&&F.length>0&&M.write(I.messagesBefore+F.length);const D=l.useMemo(()=>By(w),[w]),W=l.useMemo(()=>b&&!I.canLoadEarlier?w.findIndex(Y=>Y.role==="user"&&Y.messageType===void 0&&!Y._stagedContext&&!Y._chatStop&&!Y._directNote):-1,[b,I.canLoadEarlier,w]),G=Vt(t),V=ie(Y=>Y.selectedCwd),B=en(t),{data:L}=Zn(V),X=(j==null?void 0:j.agent)??null,_=(j==null?void 0:j.settled)===!0,[q]=l.useState(()=>new Map),te=l.useCallback(Y=>{if(!_||Y.timestamp||!Y._streaming)return;const U=q.get(Y.id);if(U)return U;const ce=new Date().toISOString();return q.set(Y.id,ce),ce},[_,q]);l.useEffect(()=>{const Y=new Set(w.map(U=>U.id));for(const U of q.keys())Y.has(U)||q.delete(U)},[w,q]);const $=(j==null?void 0:j.humanName)??S,J=(j==null?void 0:j.settled)===!0,oe=l.useMemo(()=>J?My(w):null,[J,w]),ne=l.useMemo(()=>J?Iy(w):null,[J,w]),de=l.useMemo(()=>({agent:X??(L?{id:L.id,displayName:Zt(L),...lt(L)}:null),runtime:B,...$?{humanName:$}:{}}),[L,B,X,$]),K=F[F.length-1],Z=(K==null?void 0:K.role)==="assistant"?K:void 0,je=Zx({messageId:Z==null?void 0:Z.id,text:(Z==null?void 0:Z.content)??"",isStreaming:Z!==void 0&&o}),ke=Ox((K==null?void 0:K.parts)??zy,t),{lastSeenMessageId:ee,unreadFromStart:we,markSeen:ve,isHydrated:qe}=Pd(t,F,I.messagesBefore),[he,ge]=l.useState(()=>Date.now()),Te=l.useRef(null);l.useLayoutEffect(()=>{const Y=Date.now(),U=new Date(Y).toDateString();if(Te.current===null){Te.current=U;return}Te.current!==U&&(Te.current=U,ge(Y))},[w]);const le=l.useCallback(Y=>Qd(Y,de),[de]),[_e]=l.useState(Xd),pe=l.useMemo(()=>Jd(w,{resolveAuthor:le,now:he,lastSeenMessageId:C.lastSeenBeforeUnread??ee,unreadFromStart:C.unreadFromStart||we,cache:_e}),[w,le,he,ee,we,C,_e]),[Se]=l.useState(()=>new WeakMap),xe=l.useMemo(()=>{const Y=pe.map(U=>{const ce=Se.get(U);if(ce)return ce;const ye=U.kind==="day-divider"?{kind:"day-divider",id:U.key,label:U.label}:U.kind==="unread-divider"?{kind:"unread-divider",id:U.key}:{kind:"message",id:U.key,payload:U.message,grouping:U.grouping,author:U.author,at:U.message.timestamp};return Se.set(U,ye),ye});return I.canLoadEarlier?[qy,...Y]:Y},[pe,Se,I.canLoadEarlier]),Me=I.canLoadEarlier?1:0,$e=l.useCallback((Y,U)=>{var De,Tt;if(Me===1&&U.index===0)return r.jsx(Uy,{loading:I.isLoadingEarlier,onLoad:I.loadEarlier});const ce=pe[U.index-Me];if(ce.kind==="day-divider")return r.jsx(pu,{label:ce.label});if(ce.kind==="unread-divider")return r.jsx(hu,{});const{message:ye,messageIndex:Ie}=ce;if(ye._stagedContext)return r.jsx(Vm,{content:ye.content});if(ye._chatStop)return r.jsx("div",{className:"px-4 py-1",children:r.jsx(Im,{notice:ye._chatStop})});if(Ie===W)return r.jsx(hm,{content:((Tt=(De=ye.chatMessages)==null?void 0:De[0])==null?void 0:Tt.text)??ye.content});const Re=P[Ie]??Ie,se=Re>=0&&Re===F.length-1,ae=se&&ye.role==="assistant",Ee=D===-1||Ie>=D,Ne=M.read();return r.jsx(Fy,{message:ye,grouping:ce.grouping,author:ce.author,sessionId:t,directRoomId:v==null?void 0:v.roomId,fallbackAt:te(ye),foldWork:J,turnStartedAt:oe==null?void 0:oe.get(ye.id),liveReply:ne===ye.id,isNew:Ne!==null&&I.messagesBefore+Re>=Ne,isStreaming:ae&&o,isLatestWidgetMessage:Ee,isFinalMessage:se,activeToolCallId:a,onToolRef:T,focusedOptionIndex:c,onToolDecided:R,onRetry:E,onSigninComplete:O,onChooseModel:A,inputZoneToolCallId:p,textEffect:f,runtimeLabel:g,allowsDenyReason:x,feedPosition:{index:Re+1,total:F.length}})},[pe,Me,I.isLoadingEarlier,I.loadEarlier,I.messagesBefore,F.length,P,D,W,t,v==null?void 0:v.roomId,te,J,oe,ne,M,o,a,T,c,R,E,O,A,p,f,g,x]),ze=G&&G.kind!=="first-message"&&G.fired&&!G.greetingFailed&&s?G:null;return r.jsx(bt.Timeline,{conversationId:t,label:Rr,rows:xe,renderRow:$e,landOn:"unread",landingReady:qe&&!I.isSeeking&&((v==null?void 0:v.ready)??!0),...y===void 0?{}:{landOnRow:y},onReachedBottom:ve,transcriptAnnouncement:je,approvalAnnouncement:ke,className:"pt-12 [--conversation-thumb-top:3rem]",loading:n?r.jsx(uu,{label:Rr,busy:!0,className:"flex h-full items-center justify-center","data-testid":"transcript-feed-loading",children:r.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[r.jsx(Uo,{}),"Loading chat…"]})}):void 0,empty:r.jsx("div",{className:"flex h-full items-center justify-center",children:r.jsx(lm,{birthRecord:G,firstLightRecord:ze})}),"data-testid":"message-list",feedTestId:"transcript-feed"})}function Hy({sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s=!1,launchSeed:o,onLaunchConsumed:a,landOnRow:i}){var xs,ys,bs;const[,c]=wt(),u=Vn(),d=l.useRef(null),m=l.useRef(null),h=py(e),p=xx(e),f=co(e??""),g=fx(),{play:x}=fc(),[y]=lo(),{data:b,isPending:v,isError:j,refetch:S}=Zn(y),{sessions:T}=Un(),R=e!==null&&!T.some(z=>z.id===e),E=Zl(e),O=jx(),A=l.useCallback(async z=>{let Ae=z;if(O.hasPendingFiles){const Ve=await O.uploadAndGetPaths(),ks=y?Ve.map(Et=>Et.startsWith(y)?Et.slice(y.length).replace(/^\//,""):Et):Ve;ks.length>0&&(Ae=`Please read the following uploaded file(s):
|
|
48
|
+
${ks.map(Ea=>`- ${Ea}`).join(`
|
|
49
|
+
`)}
|
|
50
|
+
|
|
51
|
+
${Ae}`),O.clearFiles()}return Ae},[O,y]),I=l.useCallback(z=>{p.handleTaskEvent(z);const Ae=p.tasks.map(Ve=>Ve.id===z.task.id?{...Ve,...z.task}:Ve);g.handleTaskEvent(z,Ae)},[p,g]);l.useCallback(z=>{c(z),u.invalidateQueries({queryKey:He.bySession(z)})},[c,u]);const F=l.useCallback(z=>{c(z,{replace:!0}),u.invalidateQueries({queryKey:He.bySession(z)})},[c,u]),N=l.useCallback(z=>{c(crypto.randomUUID(),{continuedFrom:z??void 0,draft:!0})},[c]),k=Zr(e??""),C=Jt(k.runtime),w=k.runtime?St(k.runtime).label:"",P=((xs=C==null?void 0:C.permissionModes)==null?void 0:xs.denyReason)??!0,M=l.useMemo(()=>ra(C==null?void 0:C.commandIntents,w),[C,w]),D=l.useRef(null),W=l.useCallback(()=>{var z;return(z=D.current)==null?void 0:z.call(D)},[]),{messages:G,input:V,setInput:B,handleSubmit:L,submitContent:X,enqueueContent:_,steerContent:q,addContextContent:te,status:$,error:J,stop:oe,isLoadingHistory:ne,hydrated:de,sessionStatus:K,streamStartTime:Z,estimatedTokens:je,isTextStreaming:ke,isWaitingForUser:ee,waitingType:we,activeInteraction:ve,pendingInteractions:qe,markToolCallResponded:he,systemStatus:ge,operationProgress:Te,promptSuggestions:le,syncConnectionState:_e,retryMessage:pe,tryNativeCommand:Se,commandPending:xe}=cx(e,{transformContent:A,onTaskEvent:I,onSessionIdChangeReplace:F,startFreshSession:N,compactIntent:M,launchRuntime:t,...b&&y?{agentPath:y}:{},agentLookupPending:y!==null&&v,agentLookupFailed:y!==null&&j,takeSeedContext:W,onStreamingDone:l.useCallback(()=>{x("turn-end"),u.invalidateQueries({queryKey:["commands"]})},[x,u])}),Me=l.useCallback(z=>X(z,{clearInput:!0}),[X]),{permissionMode:$e,permissionModeKnown:ze}=eo(e,K,$==="streaming"),Y=Hc(e,k.runtime,ze?$e:void 0),U=ec(z=>z.setOpen);l.useEffect(()=>{U(!1)},[e,U]);const{handleToolRef:ce,focusedOptionIndex:ye}=yx(ve);Sx($,ee,ke),l.useEffect(()=>{var z;(z=d.current)==null||z.focusUnlessTouch()},[e]);const Ie=l.useCallback(()=>{var z;(z=d.current)==null||z.focusUnlessTouch()},[]);Nx({sessionId:e,prompt:n,autoSend:s,input:V,setInput:B,messageCount:G.length,hydrated:de,status:$,submitBlocked:R&&y!==null&&(v||j),submit:L,onSeeded:Ie,onConsumed:a});const Re=Ex({sessionId:e,seed:o,messageCount:G.length,hydrated:de,onConsumed:a});l.useEffect(()=>{D.current=Re},[Re]);const se=k.runtime?zn(k.runtime):void 0,{data:ae}=pc(y,e??void 0,k.runtime??void 0),Ee=l.useMemo(()=>Th((ae==null?void 0:ae.commands)??[],{commandIntents:C==null?void 0:C.commandIntents,runtimeLabel:w}),[ae,C,w]),{data:Ne}=ny(y),De=l.useMemo(()=>Ne!=null&&Ne.files?Zd(Ne.files):[],[Ne]),Tt=vx({input:V,setInput:B,commands:Ee,fileEntries:De}),is=l.useCallback(()=>{const z=[...G].reverse().find(Ae=>Ae.role==="user");z!=null&&z.content&&X(z.content)},[G,X]),ls=Vt(e??""),ka=l.useCallback(()=>{const z=em(G,ls);z&&pe(z)},[G,ls,pe]),cs=$==="idle"&&le.length>0&&V.length===0,va=tc("chat.suggestion-chips"),Sa=Bf(e??""),ja=Ax($,J,G,Sa),wa=l.useMemo(()=>G.some(z=>z.role==="user"),[G]),us=l.useCallback(z=>{var Ae;B(z),(Ae=d.current)==null||Ae.focus()},[B]),Rt=nc(e??""),rn=oo(e??""),Na=l.useMemo(()=>Lx(Rt,rn),[Rt,rn]),ds=(bs=(ys=Jn(e??""))==null?void 0:ys.lastError)==null?void 0:bs.category,on=om(),ms=l.useCallback(()=>{const z=e??"";if(on.claimedElsewhere(z))return!1;const Ae=nm({messages:G,status:$,lastErrorCategory:ds,queuedCount:Rt.length,draft:re.getState().getSession(z).input});return Ae===null?!1:(on.claim(z),X(Ae),!0)},[G,$,ds,Rt.length,e,X,on]),dt=ky(e,b),fs=ay(m,dt.directMessage!==null),Ca=vy({sessionId:e??"",placeholder:dt.placeholder,submit:Me,enqueue:_,files:O}),{eligible:ps,allow:hs,notNow:gs}=_d($==="streaming"),Ta=l.useMemo(()=>[{id:"prompt-suggestions",show:cs,render:()=>r.jsx(lc,{suggestions:le,onChipClick:us})},{id:"permission-primer",show:ps,render:()=>r.jsx(Ad,{onAllow:hs,onNotNow:gs})},{id:"read-only-mode",show:Y.eligible,render:()=>r.jsx(Gc,{runtimeLabel:Y.runtimeLabel,onShown:Y.markShown,onDismiss:Y.dismiss})}],[cs,le,us,ps,hs,gs,Y]),Ra=xy({asks:bo,status:$,streamStartTime:Z,estimatedTokens:je,permissionMode:$e,isWaitingForUser:ee??!1,waitingType:we??"approval",operationProgress:Te,systemStatus:ge,activity:f,quietNumbers:dt.quietTurnNumbers});return r.jsx(bt.Root,{surface:"session",capabilities:pa,target:Ca,children:r.jsxs("div",{ref:m,"data-testid":"chat-panel","data-turn-status":$,"data-turn-lifecycle":rn??void 0,className:"flex h-full w-full flex-col",children:[r.jsx(um,{sessionId:e}),r.jsx(fm,{startedBy:E,modes:C==null?void 0:C.permissionModes.values}),r.jsx(Wy,{messages:G,sessionId:e,isLoadingHistory:ne,hydrated:de,isTextStreaming:ke,activeToolCallId:(ve==null?void 0:ve.toolCallId)??null,onToolRef:ce,focusedOptionIndex:ye,onToolDecided:he,onRetry:is,onSigninComplete:ms,onChooseModel:fs,inputZoneToolCallId:(ve==null?void 0:ve.toolCallId)??null,runtimeLabel:se,allowsDenyReason:P,...i===void 0?{}:{landOnRow:i},foldFirstPrompt:E!==null,directLog:h,...dt.transcriptNames}),r.jsx(Gh,{terminalReason:K==null?void 0:K.terminalReason}),r.jsx(bt.LiveLane,{state:Ra,scope:"session"}),r.jsx(hc,{candidates:Ta,ready:de,name:"session-bottom-slot",className:"px-4 pb-2"}),$==="idle"&&va.map(z=>r.jsx(z.component,{},z.id)),r.jsx(Lm,{celebration:g.activeCelebration,onComplete:g.clearCelebration}),r.jsx(eh,{tasks:p.tasks,taskMap:p.taskMap,activeForm:p.activeForm,isCollapsed:p.isCollapsed,onToggleCollapse:p.toggleCollapse,celebratingTaskId:g.celebratingTaskId,onCelebrationComplete:g.clearCelebration,statusTimestamps:p.statusTimestamps}),ja&&r.jsx(Qh,{sessionId:e,onRetry:wa?is:void 0,onSigninComplete:ms,onChooseModel:fs}),J&&r.jsx(Sy,{error:J,composerAgent:b,onRetry:ka}),R&&j&&r.jsx("div",{className:"mx-4 mb-2",children:r.jsx(nn,{heading:"Couldn’t check this folder",message:"DorkOS couldn’t tell if an agent owns this folder. Try again.",onRetry:()=>void S()})}),e&&r.jsx($f,{sessionId:e,onSend:z=>void X(z)}),r.jsx(Ry,{asDirectMessage:dt.directMessage!==null,chatInputRef:d,input:V,autocomplete:Tt,steerContent:q,addContextContent:te,tryNativeCommand:Se,commandPending:xe,agentLookupPending:R&&y!==null&&v,agentLookupError:R&&y!==null&&j,status:$,stop:oe,setInput:B,sessionId:e??"",sessionStatus:K,waiting:Na,interaction:{active:ve,pendingApprovals:qe.filter(z=>z.interactiveType==="approval"),focusedOptionIndex:ye,onToolRef:ce,onToolDecided:he},sync:{connectionState:_e}})]})})}function Gy(e,t){const n=e===null||t===void 0?null:`${e}:${t}`,s=l.useRef(null);l.useEffect(()=>{if(!(e===null||t===void 0))return s.current=`${e}:${t}`,Fe.getState().seek(e,t),()=>{const i=Fe.getState();i.seeks[e]===t&&i.endSeek(e)}},[e,t]);const o=l.useRef(null),a=l.useCallback(()=>{var d;if(n===null||o.current===n||t===void 0||e===null)return;const i=Fe.getState().seeks[e]===t;if(s.current!==n||i)return;o.current=n;const c=((d=Fe.getState().sessions[e])==null?void 0:d.earlier)??[],u=Ce.getState().getSession(e).messages;return $o(zo([...c,...u],t)??t)},[n,t,e]);return n===null?void 0:a}function Nb(){const[e]=wt();sd(e);const{runtime:t,prompt:n,send:s,seed:o,message:a}=_r(),i=sc(),c=Gy(e,a),{data:u}=rc(e,{enabled:!1,select:h=>h.title}),d=so(e);wu(e,{canonical:d===null}),gc();const m=l.useCallback(()=>{i==null||i({search:h=>({...h,prompt:void 0,send:void 0,seed:void 0}),replace:!0})},[i]);return r.jsxs(r.Fragment,{children:[r.jsx(oc,{children:u!=null&&u.trim()?u:"Chat"}),r.jsx(Hy,{sessionId:e,launchRuntime:t,launchPrompt:n,launchSend:s==="1",launchSeed:o,onLaunchConsumed:m,...c===void 0?{}:{landOnRow:c}})]})}const Ky=48,Qy="[&_[data-testid=tool-call-card]]:opacity-100 [&_[data-testid=tool-call-card]_.font-mono]:text-muted-foreground",Ln="Now · working";function Cb({sessionId:e,messages:t,agentName:n,showSessions:s,onOpenSession:o,working:a=!1,notice:i=null}){const c=l.useMemo(()=>_y(t),[t]),u=l.useRef(null),d=Fn(b=>b.request),m=Fn(b=>b.consume),h=c.some(b=>b.live),p=Rn(c),f=l.useRef(!0),g=l.useCallback(()=>{const b=u.current;b&&(f.current=b.scrollHeight-b.scrollTop-b.clientHeight<=Ky)},[]),x=l.useRef(e);l.useLayoutEffect(()=>{x.current!==e&&(x.current=e,f.current=!0);const b=u.current;b&&f.current&&(b.scrollTop=b.scrollHeight)});const y=`${c.length}|${h}`;return l.useEffect(()=>{var T,R,E;const b=u.current;if(!b||!d)return;if(d.sessionId!==e){m();return}const v=p.read(),j=d.turn==="live"?((T=v.find(O=>O.live))==null?void 0:T.key)??"live":(R=v.find(O=>O.replies.some(A=>A.id===d.turn)))==null?void 0:R.key,S=Array.from(b.querySelectorAll("[data-work-turn]")).find(O=>O.dataset.workTurn===j);!S&&v.length===0&&d.turn!=="live"||(S?((E=S.scrollIntoView)==null||E.call(S,{block:"start"}),S.focus({preventScroll:!0})):b.focus({preventScroll:!0}),f.current=d.turn==="live"||!S,f.current&&(b.scrollTop=b.scrollHeight),m())},[d,e,y,p,m]),r.jsxs("div",{ref:u,onScroll:g,tabIndex:-1,"data-testid":"work-panel",className:"flex h-full min-w-0 flex-col gap-3 overflow-y-auto p-3 outline-none",children:[r.jsx(Vy,{sessionId:e,agentName:n,showSessions:s,onOpenSession:o}),i!==null?r.jsx(Er,{children:i}):r.jsxs(r.Fragment,{children:[c.length===0&&!a&&r.jsx(Er,{children:"No steps yet."}),c.map(b=>r.jsx(Xy,{turn:b,sessionId:e},b.key)),a&&!h&&e!==null&&r.jsx(Zy,{})]})]})}function Vy({sessionId:e,agentName:t,showSessions:n,onOpenSession:s}){return!n||e===null?r.jsxs("div",{className:"bg-muted/50 text-muted-foreground rounded-md px-3 py-2 text-xs",children:["Every step ",t??"the agent"," took, turn by turn."]}):r.jsx(Yy,{sessionId:e,onOpenSession:s})}function Yy({sessionId:e,onOpenSession:t}){const{model:n,contextPercent:s,runtime:o}=to(e),{data:a}=Xt({sessionId:e,runtime:o??void 0}),i=["Session"];return n&&i.push(Kc(n,a??[])),typeof s=="number"&&i.push(`${Math.round(s)}% context`),r.jsxs("div",{"data-testid":"work-session-line",className:"bg-muted/50 text-muted-foreground flex items-center gap-2 rounded-md px-3 py-2 text-xs",children:[r.jsx(ac,{className:"size-3.5 shrink-0","aria-hidden":!0}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:i.join(" · ")}),r.jsxs("button",{type:"button",onClick:t,className:"focus-ring hover:text-foreground inline-flex shrink-0 items-center gap-0.5 rounded-sm font-medium transition-colors",children:["Open session",r.jsx(ic,{className:"size-3.5","aria-hidden":!0})]})]})}function Xy({turn:e,sessionId:t}){const n=e.startedAt?Gt(e.startedAt):"",s=e.live?Ln:[n,e.prompt?`“${e.prompt}”`:""].filter(Boolean).join(" · ")||"A turn";return r.jsxs("section",{"data-work-turn":e.key,"data-live":e.live||void 0,"aria-label":s,tabIndex:-1,className:"focus-ring rounded-lg border px-3 py-2",children:[r.jsx("h3",{className:"text-foreground line-clamp-2 text-xs font-medium",children:s}),r.jsx("div",{"data-slot":"work-steps",className:Qy,children:e.replies.map(o=>r.jsx(Jy,{reply:o,sessionId:t},o.id))})]})}const Jy=l.memo(function({reply:t,sessionId:n}){const s=t._streaming===!0,o=l.useMemo(()=>({sessionId:n,isStreaming:s,isLatestWidgetMessage:!0,isFinalMessage:!1,activeToolCallId:null,onToolRef:void 0,focusedOptionIndex:-1,onToolDecided:void 0,inputZoneToolCallId:null}),[n,s]);return r.jsx(ko,{value:o,children:r.jsx(os,{message:t,show:"work"})})});function Zy(){return r.jsxs("section",{"data-work-turn":"live","data-live":!0,"aria-label":Ln,tabIndex:-1,className:"focus-ring rounded-lg border px-3 py-2",children:[r.jsx("h3",{className:"text-foreground text-xs font-medium",children:Ln}),r.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Waiting for the first step"})]})}function Er({children:e}){return r.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:e})}export{Nb as S,Cb as W,pa as a,Ry as b,Fy as c,Wy as d,Dm as m,da as s,vy as u};
|