dorkos 0.126.2 → 0.126.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +254 -114
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-BQ66xWcJ.js → AboutPage-CAt15a-r.js} +1 -1
- package/dist/client/assets/{ActivityErrorState-CPbfgXjw.js → ActivityErrorState-s4xAcJQR.js} +1 -1
- package/dist/client/assets/{ActivityPage-CesljfZn.js → ActivityPage-BpSggjZV.js} +1 -1
- package/dist/client/assets/{ActivityRow-DzhwE0ht.js → ActivityRow-5PJBHIt2.js} +1 -1
- package/dist/client/assets/{AdapterIcon-BXJkyF5g.js → AdapterIcon-d8mZODCX.js} +1 -1
- package/dist/client/assets/AdapterSetupWizard-R-KxNMiM.js +2 -0
- package/dist/client/assets/{AgentOptionRow-0VdNzXCF.js → AgentOptionRow-hemBruhh.js} +1 -1
- package/dist/client/assets/{AgentPicker-Ldh64iOA.js → AgentPicker-DOba9a77.js} +1 -1
- package/dist/client/assets/{AgentRequestCard-CmAlDGTr.js → AgentRequestCard-RFQOrk-W.js} +1 -1
- package/dist/client/assets/{AppearancePage-DmsZPHst.js → AppearancePage-1m4bJ-Rg.js} +1 -1
- package/dist/client/assets/{ApplyToOverridesDialog-Ct1W283T.js → ApplyToOverridesDialog-BxeMLhGv.js} +1 -1
- package/dist/client/assets/{AttentionSignalRow-B7gezgzA.js → AttentionSignalRow-BoTonsR5.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-Nqvr65_g.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-Bz6XyZ6v.js} +3 -3
- package/dist/client/assets/BindingDialog-CILm91iU.js +1 -0
- package/dist/client/assets/{BlintzCanvas-BCtfZPrs.js → BlintzCanvas-BFJXKo1L.js} +3 -3
- package/dist/client/assets/{CanvasCsvContent-DYksqzaf.js → CanvasCsvContent-DzkaHpEo.js} +3 -3
- package/dist/client/assets/{CanvasFileContent-CqEqSxuJ.js → CanvasFileContent-DZf9SjJn.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-vR6ze4IR.js → CanvasModel3dContent-Cd8hf6Ba.js} +2 -2
- package/dist/client/assets/{ChannelComposer-BVACOdph.js → ChannelComposer-YXkkFcyY.js} +10 -10
- package/dist/client/assets/{ChatAppsOff-VsPP2Hye.js → ChatAppsOff-X5Y8OHAz.js} +2 -2
- package/dist/client/assets/{CodeMirrorDiff-CmKjH03N.js → CodeMirrorDiff-BsQKbrls.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-BtNgazuc.js → CodeMirrorEditor-DnkumDd3.js} +1 -1
- package/dist/client/assets/{CommitmentList-D9I-CmNy.js → CommitmentList-BjI2jvMX.js} +1 -1
- package/dist/client/assets/{CommitmentsPage-BORMYDZb.js → CommitmentsPage-7g68FcGR.js} +1 -1
- package/dist/client/assets/{ComputerResourceView-BZ9BxgOi.js → ComputerResourceView-Dcd0e_Oj.js} +1 -1
- package/dist/client/assets/{ComputerViewer-CbuU9tXK.js → ComputerViewer-Dq3aQyZD.js} +1 -1
- package/dist/client/assets/{ConnectionAccessLists-uE-Fzp6Y.js → ConnectionAccessLists-CXPn8ICQ.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-D7QTHeQQ.js → ConnectionsPage-DEc4JsR5.js} +2 -2
- package/dist/client/assets/{ConventionPage-PS2WWCyB.js → ConventionPage-B7cm4O1D.js} +1 -1
- package/dist/client/assets/{ExtensionPageRoute-Cn7bYxGB.js → ExtensionPageRoute-ba2uGsYs.js} +2 -2
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-DKGNSXVz.js → FloatingTanStackRouterDevtools-CqogiFob-Dxk_rLHR.js} +1 -1
- package/dist/client/assets/{ForwardConsentHost-CLIHtWwq.js → ForwardConsentHost-CNuTTR3q.js} +1 -1
- package/dist/client/assets/HandlePage-WIwOCyJg.js +1 -0
- package/dist/client/assets/{HeartbeatPage-7MTowke-.js → HeartbeatPage-CEb8SaAx.js} +1 -1
- package/dist/client/assets/{KeyEntry-Cf7D0Oo6.js → KeyEntry-CHJpgP6H.js} +1 -1
- package/dist/client/assets/{LexicalField-DqvzeMr3.js → LexicalField-B0tWaDy5.js} +1 -1
- package/dist/client/assets/{ManagesPage-DxR4zWMf.js → ManagesPage-rcz--gCT.js} +1 -1
- package/dist/client/assets/{Marketplace-V_92jKOn.js → Marketplace-wjAUiULQ.js} +4 -4
- package/dist/client/assets/{MarketplaceSourcesView-CjCVMP_d.js → MarketplaceSourcesView-BMGnEy8T.js} +1 -1
- package/dist/client/assets/{McpAppFrame-4JDJsrmg.js → McpAppFrame-CmwiQHxf.js} +2 -2
- package/dist/client/assets/{McpSigninBody-DG1XX7XT.js → McpSigninBody-D99PCc0n.js} +1 -1
- package/dist/client/assets/{Model3dViewer-DedBFHsl.js → Model3dViewer-qUwwZnb2.js} +1 -1
- package/dist/client/assets/NamePage-B7VSrPmK.js +1 -0
- package/dist/client/assets/{NewDirectMessageMenu-C8t7x-sB.js → NewDirectMessageMenu-DyMfEU7i.js} +1 -1
- package/dist/client/assets/{NotificationsPage-DwGFE3F6.js → NotificationsPage-BsOaV6Ei.js} +1 -1
- package/dist/client/assets/{OpenMeshSwitch-DPmTA9eg.js → OpenMeshSwitch-CjCPWZn0.js} +2 -2
- package/dist/client/assets/{OperatorIdentityForm-Cu0h8Xqy.js → OperatorIdentityForm-Cd6B2hxb.js} +1 -1
- package/dist/client/assets/{PermissionHistory-zD6ksrl2.js → PermissionHistory-xp6vPQ20.js} +1 -1
- package/dist/client/assets/{PermissionsPage-Durcnmie.js → PermissionsPage-DaAJew99.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-DuRjJuLj.js → PersonalityPopover-BZaif5Fn.js} +1 -1
- package/dist/client/assets/PhotoPage-43WNaavk.js +1 -0
- package/dist/client/assets/{PreviewRefusedNotice-hlYrFDQM.js → PreviewRefusedNotice-CCpHgrea.js} +1 -1
- package/dist/client/assets/{ProfileFields-x-x8vgNo.js → ProfileFields-DyVqmcPr.js} +1 -1
- package/dist/client/assets/{ProfilePanelContainer-8WxopRj2.js → ProfilePanelContainer-CMRG6AmB.js} +1 -1
- package/dist/client/assets/{ProfileRolePicker-BfciiNpr.js → ProfileRolePicker-Q_hY6ybO.js} +1 -1
- package/dist/client/assets/{PromptSuggestionChips-D34Zeaq_.js → PromptSuggestionChips-B5afjbD0.js} +1 -1
- package/dist/client/assets/{ReportsToPopover-BhqA5qXi.js → ReportsToPopover-CVF7Rtzh.js} +1 -1
- package/dist/client/assets/{RoomSurface-BlMNuQsT.js → RoomSurface-Bz1DfoQD.js} +1 -1
- package/dist/client/assets/{RoomsPage-C52AOHIE.js → RoomsPage-4u74yonc.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-DLhEKwXF.js → RunsOnPopover-CnUm4LP2.js} +1 -1
- package/dist/client/assets/{RuntimeConnectFlow-D3H5Fpkc.js → RuntimeConnectFlow-B0TIITVq.js} +1 -1
- package/dist/client/assets/{RuntimeSetupDialog-DPU4QIY9.js → RuntimeSetupDialog-CEUC7GrY.js} +1 -1
- package/dist/client/assets/{SeenDevices-CDSHTsL7.js → SeenDevices-CxhuIRp3.js} +2 -2
- package/dist/client/assets/{SessionsPage-Crh3D3Jj.js → SessionsPage-l6_Qc7hz.js} +1 -1
- package/dist/client/assets/{SettingsDialog-D0Oh-ku1.js → SettingsDialog-GEK8nhI8.js} +4 -4
- package/dist/client/assets/{SkillsPage-BPexZwnJ.js → SkillsPage-PlVj6VdA.js} +1 -1
- package/dist/client/assets/{TaskDialogWrapper-D6RB8E59.js → TaskDialogWrapper-TspfYk9J.js} +1 -1
- package/dist/client/assets/{TasksEmptyState-Di3SbhJM.js → TasksEmptyState-DsHh0blU.js} +2 -2
- package/dist/client/assets/{TasksPage-CDLsY1Ww.js → TasksPage-Va0dvkif.js} +1 -1
- package/dist/client/assets/{TeamComputerEntry-B_q-oVSs.js → TeamComputerEntry-C6juiObF.js} +1 -1
- package/dist/client/assets/{ToolsPage-gvIVTnwf.js → ToolsPage-C0ESG42C.js} +2 -2
- package/dist/client/assets/{TopologyGraph-Bp8aL_qw.js → TopologyGraph-M24Edx-I.js} +3 -3
- package/dist/client/assets/TourHost-CcN4uCDR.js +1 -0
- package/dist/client/assets/{UnlinkDialog-Ddd1Yxfk.js → UnlinkDialog-DlD1cmRZ.js} +1 -1
- package/dist/client/assets/{UnreadDivider-LL4_YtF0.js → UnreadDivider-DPD9MQ8-.js} +1 -1
- package/dist/client/assets/{WidgetErrorCard-BA3P7hNv.js → WidgetErrorCard-Bte2obmw.js} +3 -3
- package/dist/client/assets/{WithheldExtensionsNotice-quqWNbus.js → WithheldExtensionsNotice-CZibLuKA.js} +1 -1
- package/dist/client/assets/{WorkView-C_h8sclU.js → WorkView-PsLjURld.js} +15 -15
- package/dist/client/assets/{_shell-D9q8zLfr.js → _shell-Ce_cSF7V.js} +2 -2
- package/dist/client/assets/{_shell._home-CrTxBB3h.js → _shell._home-DcZcTXu8.js} +1 -1
- package/dist/client/assets/{_shell._home.activity-2M0BJkbQ.js → _shell._home.activity-BXw8iSC4.js} +1 -1
- package/dist/client/assets/_shell._home.index-BleaCq_y.js +3 -0
- package/dist/client/assets/{_shell._home.tasks-Dfrqv2nl.js → _shell._home.tasks-gdbnkq3-.js} +1 -1
- package/dist/client/assets/{_shell._home.workspaces-DPLQXDdH.js → _shell._home.workspaces-BCwJX783.js} +1 -1
- package/dist/client/assets/{_shell.channels-CJqfUTZ1.js → _shell.channels-D-lMqbSA.js} +1 -1
- package/dist/client/assets/_shell.connections-BFmTpceq.js +1 -0
- package/dist/client/assets/{_shell.feedback-requests-BeWCqScf.js → _shell.feedback-requests-NKpm6Uhu.js} +1 -1
- package/dist/client/assets/_shell.marketplace-DB7NSxDU.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-WU9ILkRM.js +1 -0
- package/dist/client/assets/_shell.session-CchZWYRA.js +1 -0
- package/dist/client/assets/{_shell.team-EPvcS7RS.js → _shell.team-DcCRbdAb.js} +4 -4
- package/dist/client/assets/{_shell.threads-NJDzq9dv.js → _shell.threads-BLy6Cgqk.js} +1 -1
- package/dist/client/assets/_shell.x._extensionId-CVW0g7Rb.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-CVW0g7Rb.js +1 -0
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-DUHshdrR.js → abnfDiagram-WEYOIA3C-DpkXbw1_.js} +1 -1
- package/dist/client/assets/{access-copy-DHfPjN3G.js → access-copy-Y2_F9uAx.js} +1 -1
- package/dist/client/assets/{arc-sP6zNsGB.js → arc-B3bZAGvi.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-C8PTjsPx.js → architectureDiagram-ZHVYKT53-BKR1sFvp.js} +1 -1
- package/dist/client/assets/{banner-CVrzHqOT.js → banner-CqhUGJmy.js} +2 -2
- package/dist/client/assets/{blockDiagram-RJAE7QA3-Cydde2fz.js → blockDiagram-RJAE7QA3-C2I50BMQ.js} +1 -1
- package/dist/client/assets/{c4Diagram-XDPPPE54-DbM6KAK7.js → c4Diagram-XDPPPE54-dhHi_wUH.js} +1 -1
- package/dist/client/assets/{card-DA_Z-FYX.js → card-CM7-_8nD.js} +1 -1
- package/dist/client/assets/channel-NlrM9BR7.js +1 -0
- package/dist/client/assets/{chunk-2E7WHVMD-CEbspaNh.js → chunk-2E7WHVMD-B0B27SHJ.js} +1 -1
- package/dist/client/assets/{chunk-2Q5K7J3B-DDP1SiE0.js → chunk-2Q5K7J3B-dsUDjsr2.js} +1 -1
- package/dist/client/assets/{chunk-4EMNKR2T-BFjozJqd.js → chunk-4EMNKR2T-C3IdUlS9.js} +1 -1
- package/dist/client/assets/{chunk-55XCU76K-0JSp6acZ.js → chunk-55XCU76K-D6qgX8rY.js} +1 -1
- package/dist/client/assets/{chunk-5VM5RSS4-DswTXnmp.js → chunk-5VM5RSS4-CWhRZZS1.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-D0PYncYV.js → chunk-JWPE2WC7-Bd3RyNB2.js} +1 -1
- package/dist/client/assets/{chunk-VQ5W62QI-r5T-ZVBs.js → chunk-VQ5W62QI-HqUjzAO7.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-D8kkjktE.js → chunk-XXDRQBXY-CfeGRauy.js} +1 -1
- package/dist/client/assets/{chunk-ZCHMQSOR-D6XtRzln.js → chunk-ZCHMQSOR-D30UE34C.js} +2 -2
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-DUPDMGfm.js → classDiagram-v2-4MYWR3UA-ClIZEeNx.js} +1 -1
- package/dist/client/assets/{command-BvXBgZfv.js → command-DuhX52Bi.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-tiQpE-Q8.js → cose-bilkent-JH36ORCC-C_MZbmxw.js} +1 -1
- package/dist/client/assets/{cpu-mx7zDf7k.js → cpu-BMUMZCWW.js} +1 -1
- package/dist/client/assets/{cynefin-EF2NZ3EQ-BjAUxFfb.js → cynefin-EF2NZ3EQ-DjzC1gsw.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-PmlyltXR.js → cynefinDiagram-WF24UDRP-Dnu1pf_9.js} +1 -1
- package/dist/client/assets/{dagre-NK4GIZVX-DDePjPkn.js → dagre-NK4GIZVX-Bruwoqfg.js} +1 -1
- package/dist/client/assets/{diagram-CBK3MWTC-D7N3T4Fx.js → diagram-CBK3MWTC-Co7nk3xQ.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-BfZHSbR2.js → diagram-I5XIIV2D-CDJY0Snc.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-sXAa9bzN.js → diagram-ODIL2UCW-CF0utpvI.js} +1 -1
- package/dist/client/assets/{diagram-PFBEJUXE-Dfd_61WO.js → diagram-PFBEJUXE-BrLRX5Ip.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-BCzdEfnM.js → diagram-RJA3I4VV-BOo6-thr.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-BMqtz6sZ.js → diagram-TYUNFSNR-B-206XZy.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-CyWj1615.js → ebnfDiagram-V4P3TTPT-C6SZjvSQ.js} +1 -1
- package/dist/client/assets/{elk-QONTBCTQ-BkQMBXse.js → elk-QONTBCTQ-B_QHOQ8G.js} +1 -1
- package/dist/client/assets/{empty-state-Dv5iV4jb.js → empty-state-BzWMBBQZ.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-DiPsX7uU.js → erDiagram-KYQIGQAA-BTKJgVOK.js} +1 -1
- package/dist/client/assets/{execution-config-Bej0Ot8e.js → execution-config-D_PgYyCI.js} +1 -1
- package/dist/client/assets/{file-DXbyb23e.js → file-DiYwTQdD.js} +1 -1
- package/dist/client/assets/{file-exclamation-point-C8XqHyzY.js → file-exclamation-point-CnQYdJiV.js} +1 -1
- package/dist/client/assets/{file-text-CRTgqqkn.js → file-text-DLPhIP0f.js} +1 -1
- package/dist/client/assets/{find-latest-widget-fence-D1i7qNny.js → find-latest-widget-fence-BYtG5PzD.js} +3 -3
- package/dist/client/assets/{flowDiagram-IUGLLWBU-BSM44aJP.js → flowDiagram-IUGLLWBU-o2In4cGl.js} +1 -1
- package/dist/client/assets/{form-DYSiVEri.js → form-DUFlQ-yL.js} +1 -1
- package/dist/client/assets/{format-cron-DYYwmo-o.js → format-cron-D5dtMPdH.js} +1 -1
- package/dist/client/assets/{ganttDiagram-R7GPNTJY-BWCjYexX.js → ganttDiagram-R7GPNTJY-WwrWLB2J.js} +1 -1
- package/dist/client/assets/{git-branch-1zYKSuur.js → git-branch-uZFa3Tmr.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PDYL7XHY-ULC7Zunc.js → gitGraphDiagram-PDYL7XHY-C1yG6xrf.js} +1 -1
- package/dist/client/assets/{graph-BsZzo5TN.js → graph-C10tj8MW.js} +1 -1
- package/dist/client/assets/{heart-C4CSHUW7.js → heart--8btr31M.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-CFECg7iB.js → highlighted-body-KPVGNVTW-DGp-Vg6c.js} +1 -1
- package/dist/client/assets/{image-lightbox-M9t3Wulc.js → image-lightbox-BfwZy_vF.js} +1 -1
- package/dist/client/assets/{image-off-c01kxBAm.js → image-off-Bmtj2Xtq.js} +1 -1
- package/dist/client/assets/{index-BScgHCO_.js → index-8hXtJ0Xw.js} +1 -1
- package/dist/client/assets/{index-DG13Cp5o.js → index-B5i5B8F0.js} +1 -1
- package/dist/client/assets/{index-DzHj8lCz.js → index-BBaFVr5z.js} +9 -9
- package/dist/client/assets/{index-DIDUjTkq.js → index-BCZa5De0.js} +1 -1
- package/dist/client/assets/{index-BTGRc0hC.js → index-BE8yM241.js} +1 -1
- package/dist/client/assets/{index-XEE1k4cl.js → index-BHXG7bNX.js} +1 -1
- package/dist/client/assets/{index-BqwCOIbF.js → index-BJ_fl1Gy.js} +1 -1
- package/dist/client/assets/{index-DhoaVQXu.js → index-BbIFaQ9_.js} +1 -1
- package/dist/client/assets/{index-Dt7RONID.js → index-BlHuuCes.js} +1 -1
- package/dist/client/assets/{index-C3swXqWW.js → index-BtrV6g02.js} +1 -1
- package/dist/client/assets/{index-C1XazYWZ.js → index-C-tNYOVV.js} +1 -1
- package/dist/client/assets/{index-BYY8HEOz.js → index-C3LZBxuM.js} +1 -1
- package/dist/client/assets/{index-B-7P1Q9s.js → index-CO9QUYdl.js} +1 -1
- package/dist/client/assets/{index-BIVIHPoe.js → index-CP47qL8N.js} +1 -1
- package/dist/client/assets/{index-BRH6C3LJ.js → index-CYM65t4i.js} +1 -1
- package/dist/client/assets/{index-DhkfALZp.js → index-CaZ9yNIm.js} +1 -1
- package/dist/client/assets/index-CaxFHvSK.js +1 -0
- package/dist/client/assets/index-CdHuEKYh.js +1 -0
- package/dist/client/assets/{index-YXyEu3Ia.js → index-CoL3MmPh.js} +1 -1
- package/dist/client/assets/{index-Du4HX97h.js → index-CtN6_QCQ.js} +2 -2
- package/dist/client/assets/{index-JG_0k1NX.js → index-CvIKejlx.js} +1 -1
- package/dist/client/assets/{index-FwAvbbet.js → index-CypEgDik.js} +1 -1
- package/dist/client/assets/index-Cz9N1NHd.js +1 -0
- package/dist/client/assets/{index-CnltS8ym.js → index-D-ZRSiaH.js} +1 -1
- package/dist/client/assets/{index-DQTTC52E.js → index-D8ZcqMea.js} +1 -1
- package/dist/client/assets/{index-CAjKQnAd.js → index-D97clHqL.js} +1 -1
- package/dist/client/assets/index-DAaYbj1s.js +1 -0
- package/dist/client/assets/{index-B3xeyV6n.js → index-DI9IsN-O.js} +1 -1
- package/dist/client/assets/{index-DhYnXLRT.js → index-DLPkp7I9.js} +1 -1
- package/dist/client/assets/{index-CAAsqmfP.js → index-DMTfnznD.js} +1 -1
- package/dist/client/assets/{index-BSxkprTm.js → index-DZQUx5pX.js} +3 -3
- package/dist/client/assets/{index-B_he44rF.js → index-DamNtsio.js} +1 -1
- package/dist/client/assets/{index-Ce3HZQem.js → index-DenTxAiI.js} +1 -1
- package/dist/client/assets/{index-jLIoULQt.js → index-DmG7yphM.js} +1 -1
- package/dist/client/assets/{index-BnXWm8Db.js → index-Dqouol3i.js} +1 -1
- package/dist/client/assets/{index-DsasLE1l.js → index-Dsj1fDYU.js} +1 -1
- package/dist/client/assets/{index-Br35Gqfz.js → index-E5KPj_ZX.js} +1 -1
- package/dist/client/assets/{index-DrENuQdJ.js → index-LGTvsZzp.js} +1 -1
- package/dist/client/assets/{index-uLbyd6YP.js → index-Nr39AP-T.js} +1 -1
- package/dist/client/assets/{index-DrQqkQq_.js → index-YrSNUw95.js} +1 -1
- package/dist/client/assets/index-fge85Gub.js +1053 -0
- package/dist/client/assets/{index-D847rJXW.js → index-mweR5xOP.js} +1 -1
- package/dist/client/assets/{index-LpaxG4VS.js → index-ocZzSFoR.js} +1 -1
- package/dist/client/assets/{index.esm-CZ68Qd2t.js → index.esm-BEGwgVfU.js} +1 -1
- package/dist/client/assets/{infoDiagram-MVDRKAX5-BCjhXqIT.js → infoDiagram-MVDRKAX5-oeBcoEBA.js} +1 -1
- package/dist/client/assets/{inline-code-BKPMIXZR.js → inline-code-7dwi7wWG.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-C9rsv2nh.js → ishikawaDiagram-HPEHV2GE-CLIGz304.js} +1 -1
- package/dist/client/assets/{journeyDiagram-BOSHW7O7-BRYr1XL1.js → journeyDiagram-BOSHW7O7-Cg0HlPT5.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-2ey8FXEn.js → kanban-definition-FNSA4HC5-DXaqYXhm.js} +1 -1
- package/dist/client/assets/{layers-DE3wjQuk.js → layers-BhECZJWp.js} +1 -1
- package/dist/client/assets/{lightbulb-BXJIRUdm.js → lightbulb-DjMxuZnu.js} +1 -1
- package/dist/client/assets/{link-2-DzWm9OxA.js → link-2-BY2WyWzK.js} +1 -1
- package/dist/client/assets/{list-runtime-types-BhkZkTrB.js → list-runtime-types-hMouIGtG.js} +1 -1
- package/dist/client/assets/{markdown-content-Bk9lCksw.js → markdown-content-DV3AiG76.js} +1 -1
- package/dist/client/assets/{mention-pill-os_7QQu2.js → mention-pill-Db0XBC6Z.js} +1 -1
- package/dist/client/assets/{mermaid.core-BcRUBvZd.js → mermaid.core-_ZqWvaFB.js} +4 -4
- package/dist/client/assets/{message-square-off-DuOiETNI.js → message-square-off-w0__0O5g.js} +1 -1
- package/dist/client/assets/{mindmap-definition-6OY57UG3-DBhXkS2i.js → mindmap-definition-6OY57UG3-BRVkHL68.js} +1 -1
- package/dist/client/assets/{more-details-Bt9nlPmS.js → more-details-BUolHzrY.js} +1 -1
- package/dist/client/assets/{owner-notice-4ZSBxa2K.js → owner-notice-Cn5EUxgh.js} +1 -1
- package/dist/client/assets/{package-BmOMrNwc.js → package-BafFSryH.js} +1 -1
- package/dist/client/assets/{page-container-LomhzyuS.js → page-container-BCdJ_DsH.js} +1 -1
- package/dist/client/assets/{pane-resize-handle-BOtzx5Q4.js → pane-resize-handle-Bar-FdkY.js} +1 -1
- package/dist/client/assets/{paperclip-C1tkiT74.js → paperclip-DY4e-IlK.js} +1 -1
- package/dist/client/assets/{path-input-JHTlL97W.js → path-input-SZl4NGTs.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-B01fb3t0.js → pegDiagram-ECIUJNBX-D9J7XmXK.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-BJ7JYrTk.js → pieDiagram-GNMPY74T-myMGqtsR.js} +1 -1
- package/dist/client/assets/{plug-CsqfQsYq.js → plug-BdWCGVJg.js} +1 -1
- package/dist/client/assets/primer-trigger-r8N0YY5e.js +3 -0
- package/dist/client/assets/{profile-errors-CpvSy5wY.js → profile-errors-DymWFWiP.js} +1 -1
- package/dist/client/assets/{progress-qB87L0zJ.js → progress-es667_cM.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-D57K4MC3-mJYGGmOV.js → quadrantDiagram-D57K4MC3-D5_2lcqK.js} +1 -1
- package/dist/client/assets/{query-error-state-MyJ1ivia.js → query-error-state-BNPduDBN.js} +1 -1
- package/dist/client/assets/{radio-DJV7l0fv.js → radio-DpWUX1KL.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-BlXWwQe2.js → railroadDiagram-Y72NRBL7-D15ELhSC.js} +1 -1
- package/dist/client/assets/{registry-tJrGs7kB.js → registry-5Qudcjd5.js} +4 -4
- package/dist/client/assets/registry-DvKu39S1.js +1 -0
- package/dist/client/assets/relay-trace-schemas-DURazPP9.js +6 -0
- package/dist/client/assets/{repeat-CBnopqBr.js → repeat-HOHWZc6L.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-Dqr1Y74x.js → requirementDiagram-EQYSW5RA-CHcEVlsR.js} +1 -1
- package/dist/client/assets/{room-files-source-BFo0FEUP.js → room-files-source-BO3E2ed0.js} +1 -1
- package/dist/client/assets/{rotate-ccw-clock-D9XRHj5E.js → rotate-ccw-clock-Dniulnw5.js} +1 -1
- package/dist/client/assets/{rotate-cw-DNa7ENG3.js → rotate-cw-um9OzAM7.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-SY24JHO5-DGYZs_kW.js → sankeyDiagram-SY24JHO5-_R5087R3.js} +1 -1
- package/dist/client/assets/{scroll-area-Bf6IGziJ.js → scroll-area-MdXbnM77.js} +1 -1
- package/dist/client/assets/search-x-CHNgYj0F.js +6 -0
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-BW3u4L9y.js → sequenceDiagram-BLEHNHQU-BzHmSHMF.js} +1 -1
- package/dist/client/assets/{shield-x-WGxwrtNV.js → shield-x-CDXAW9YF.js} +1 -1
- package/dist/client/assets/{signed-in-eV4_EXuv.js → signed-in-JAMHtSjx.js} +1 -1
- package/dist/client/assets/{sizeCapture-INFHLROL-C1TpueOu.js → sizeCapture-INFHLROL-CqA3cZcy.js} +1 -1
- package/dist/client/assets/{soul-file-e1iYX9IV.js → soul-file-BcaDvIdL.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DvrHUauN.js → stateDiagram-v2-A6IESKWZ-RAA8YyBW.js} +1 -1
- package/dist/client/assets/{swimlanes-B3ENRKFQ-BUbTcoId.js → swimlanes-B3ENRKFQ-BQvgJIcj.js} +1 -1
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-iDgTYazX.js +8 -0
- package/dist/client/assets/{table-DsxLk3Gx.js → table-BcJvj9rx.js} +1 -1
- package/dist/client/assets/{timeline-definition-JXYKGLGB-CzbVpGxn.js → timeline-definition-JXYKGLGB-DXi0saeN.js} +1 -1
- package/dist/client/assets/{trust-posture-Blofy7eE.js → trust-posture-vH4plBRD.js} +1 -1
- package/dist/client/assets/{unplug-B6dUhqA7.js → unplug-CK2bPGpg.js} +1 -1
- package/dist/client/assets/untrusted-text-BDygHCRk.js +1 -0
- package/dist/client/assets/{unverified-catalog-notice-6pwZtIjx.js → unverified-catalog-notice-WMkPDdUp.js} +1 -1
- package/dist/client/assets/{use-bindings-BgXZ0D7k.js → use-bindings-h_mG9d64.js} +1 -1
- package/dist/client/assets/{use-composer-prefs--zO2mm_M.js → use-composer-prefs-DhCnTsrF.js} +1 -1
- package/dist/client/assets/{use-connector-management-9Q7wHb06.js → use-connector-management-CXVz2xe3.js} +1 -1
- package/dist/client/assets/{use-deep-link-scroll-CXqwdwGr.js → use-deep-link-scroll-DYOZ5k0G.js} +1 -1
- package/dist/client/assets/{use-delete-binding-BBQNMtUY.js → use-delete-binding-CHAeTC_Q.js} +1 -1
- package/dist/client/assets/{use-dev-links-C643CCcq.js → use-dev-links-CM2NIeqy.js} +1 -1
- package/dist/client/assets/{use-direct-message-panel-BD_daG2E.js → use-direct-message-panel-DXTH05Ym.js} +1 -1
- package/dist/client/assets/use-external-adapter-catalog-DKlBkkvF.js +1 -0
- package/dist/client/assets/use-full-activity-feed-QZAZ5vBJ.js +1 -0
- package/dist/client/assets/use-is-below-desktop-DS51QTwj.js +1 -0
- package/dist/client/assets/{use-local-browser-P93oA-F5.js → use-local-browser-43FpcgCM.js} +1 -1
- package/dist/client/assets/{use-mesh-topology-B0k0gLoW.js → use-mesh-topology-Bw7MmKA9.js} +1 -1
- package/dist/client/assets/{use-mounted-ref-DE7EQsBF.js → use-mounted-ref-Cuui7-gf.js} +1 -1
- package/dist/client/assets/{use-notification-prefs-B8JtshQ0.js → use-notification-prefs-CJnF55Rv.js} +1 -1
- package/dist/client/assets/use-pending-read-DB25CO5E.js +1 -0
- package/dist/client/assets/{use-personality-commit-Dh5Sejj_.js → use-personality-commit-p6Of1UxX.js} +1 -1
- package/dist/client/assets/{use-promo-activation-C9FWA7ru.js → use-promo-activation-CxG-kZJQ.js} +3 -3
- package/dist/client/assets/{use-promo-dismissals-BIfafj9f.js → use-promo-dismissals-DeNbRWOh.js} +1 -1
- package/dist/client/assets/{use-pulse-freshness-CxzVMmVK.js → use-pulse-freshness-CdRkKThf.js} +1 -1
- package/dist/client/assets/{use-room-follow-claim-B1QPFaUb.js → use-room-follow-claim-_B7HonZx.js} +1 -1
- package/dist/client/assets/{use-room-sessions-CdjzO67_.js → use-room-sessions-CrFskgCJ.js} +1 -1
- package/dist/client/assets/{use-roving-tab-list-Nu-MIapD.js → use-roving-tab-list-DSjW4_wm.js} +1 -1
- package/dist/client/assets/use-session-canvas-KguPfnsc.js +27 -0
- package/dist/client/assets/{use-status-budget-DgeTxC3h.js → use-status-budget-CTereFSr.js} +3 -3
- package/dist/client/assets/{use-transform-CiJqtMBf.js → use-transform-YUDqOhoc.js} +1 -1
- package/dist/client/assets/{use-unclaimed-chats-Blkq6U4D.js → use-unclaimed-chats-B9ChucvA.js} +1 -1
- package/dist/client/assets/use-update-config-BH0agtZh.js +1 -0
- package/dist/client/assets/{useMutationState-lbcdmnfE.js → useMutationState-TJGtJT5R.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-BM36oESm.js → usecaseDiagram-WPOLBNNX-Cjs1EpVL.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-Zrybcs91.js → vennDiagram-Q3Y3IDCW-BtgH-ZyN.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA-CO4pzGG0.js → wardleyDiagram-IVAIDKWA-BCWHQ18G.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-pi_wF1CM.js → xychartDiagram-4URNHDU4-CUBPWq_V.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/index.js +7695 -5486
- package/dist/server/index.js.map +2 -2
- package/package.json +5 -5
- package/dist/client/assets/AdapterSetupWizard-CwKYl1vG.js +0 -2
- package/dist/client/assets/BindingDialog-CpBZoSZU.js +0 -1
- package/dist/client/assets/HandlePage-BjlcYr_l.js +0 -1
- package/dist/client/assets/NamePage-A8X09lY7.js +0 -1
- package/dist/client/assets/PhotoPage-DP5WoeFd.js +0 -1
- package/dist/client/assets/TourHost-Cg8EHvod.js +0 -1
- package/dist/client/assets/_shell._home.index-BTJhhEWN.js +0 -3
- package/dist/client/assets/_shell.connections-Cpe1hru3.js +0 -1
- package/dist/client/assets/_shell.marketplace-CzLqm8iR.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-DtraxnMx.js +0 -1
- package/dist/client/assets/_shell.session-72JEfodU.js +0 -1
- package/dist/client/assets/_shell.x._extensionId-CcJi8pKR.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-CcJi8pKR.js +0 -1
- package/dist/client/assets/channel-DMgpNBDz.js +0 -1
- package/dist/client/assets/index-B6Scr7KJ.js +0 -1053
- package/dist/client/assets/index-DyN65ufd.js +0 -1
- package/dist/client/assets/index-UJq1qaku.js +0 -1
- package/dist/client/assets/index-e6oawwKv.js +0 -1
- package/dist/client/assets/index-j30EyYIU.js +0 -1
- package/dist/client/assets/primer-trigger-DLdK7lVr.js +0 -3
- package/dist/client/assets/registry-BrjQCdmG.js +0 -1
- package/dist/client/assets/relay-trace-schemas-TH0-GYCB.js +0 -6
- package/dist/client/assets/search-x-DFBBEouE.js +0 -6
- package/dist/client/assets/swimlanesDiagram-AYQRV4AK-wkooBe_N.js +0 -8
- package/dist/client/assets/untrusted-text-pHjcUwfI.js +0 -1
- package/dist/client/assets/use-adapter-catalog-J43bUHJu.js +0 -1
- package/dist/client/assets/use-external-adapter-catalog-BjbC1V6t.js +0 -1
- package/dist/client/assets/use-full-activity-feed-DUH8r8jx.js +0 -1
- package/dist/client/assets/use-is-below-desktop-DAZnwJGB.js +0 -1
- package/dist/client/assets/use-pending-read-DeGO1wGC.js +0 -1
- package/dist/client/assets/use-relay-config-DQE3dmJ2.js +0 -1
- package/dist/client/assets/use-session-canvas-BfKGOpNy.js +0 -27
- package/dist/client/assets/use-update-config-BFFW_6Mc.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a1 as ie,a4 as de,a3 as Oe,iZ as _e,i_ as ne,i$ as me,j0 as Le,j1 as Fe,j2 as De,aP as ze,r as s,j as t,G as ee,B as we,x as He,e as Q,gy as Ie,hh as qe,gx as ke,j3 as $e,j4 as We,n as Be,gB as U,a7 as Ke,fy as Ge,j5 as Ue,j6 as Xe,j7 as Ye,cu as Qe,j8 as Ve,j9 as Ze,ja as Je,jb as et,cq as tt,jc as nt,gw as Y,jd as st,l as rt,s as he,je as ot,jf as at,e7 as it,X as dt,e4 as lt,ar as ut,jg as ct,jh as pe,ji as ft,ad as mt,jj as ht,gv as pt,gu as gt,jk as xt,aF as ge,by as yt}from"./index-B6Scr7KJ.js";import{P as Rt,u as vt}from"./pane-resize-handle-BOtzx5Q4.js";import{D as bt,U as jt,u as wt}from"./UnreadDivider-LL4_YtF0.js";import{u as It}from"./use-room-follow-claim-B1QPFaUb.js";import{a as le,e as ue,g as kt,f as Ae,h as At,i as Ne,c as G,d as V,j as Nt,k as re,b as oe,l as ae,A as Se,m as Ce,t as ce,r as St,n as J,R as fe,u as Me,C as Te,o as Ct}from"./ChannelComposer-BVACOdph.js";import{u as Mt,f as Tt,a as Pt,F as Et,C as X,d as Ot,M as _t}from"./registry-tJrGs7kB.js";import{u as Lt}from"./use-connector-management-9Q7wHb06.js";import{A as Ft}from"./AgentRequestCard-CmAlDGTr.js";import{u as Dt}from"./use-room-sessions-CdjzO67_.js";function zt(){const e=ie();return de({mutationFn:({roomId:o,authorId:r})=>e.haltRoomAgent(o,r),meta:{errorLabel:"Couldn’t stop this agent"}})}function Ht(){const e=ie();return de({mutationFn:({roomId:o,authorId:r})=>e.promoteHold(o,r),meta:{errorLabel:"Couldn’t ask to be answered first"}})}function qt(e){const o=ie(),r=Oe(),u=_e(e),R=ne(p=>{var f;return e===null?null:((f=p.paging[e])==null?void 0:f.cursor)??null}),i=de({mutationFn:async p=>{var j;const f=(j=ne.getState().paging[p])==null?void 0:j.cursor;if(f==null)return;const v=await o.listRoomEntries(p,{before:f,limit:me}),I=ze.entries(p),k=r.getQueryData(I),A=Le(k,v);r.setQueryData(I,A),ne.getState().notePage(p,Fe(v)??f,De(v,me)||A.length===((k==null?void 0:k.length)??0))},meta:{errorLabel:"Couldn't load older messages"}}),{mutateAsync:d,isPending:w}=i,y=s.useRef(!1),x=s.useCallback(async()=>{if(!(e===null||y.current)){y.current=!0;try{await d(e).catch(()=>{})}finally{y.current=!1}}},[e,d]);return{canLoadOlder:u,isLoadingOlder:w,cursor:R,loadOlder:x}}function $t({id:e,summary:o,open:r,onOpen:u}){const{capabilities:R}=Mt(),{count:i,lastAt:d,unread:w}=o,y=Tt(d),[x,p]=s.useState({count:i,bumped:!1});x.count!==i&&p({count:i,bumped:!0});const f=x.count===i&&x.bumped;return R.threads?t.jsxs("button",{type:"button",id:e,"data-slot":"thread-reply-row","data-testid":"room-thread-replies","data-unread":w>0?"":void 0,"aria-expanded":r,onClick:u,className:ee("focus-ring ml-[calc(var(--msg-padding-x)_+_var(--msg-gutter-width)_+_var(--msg-gap))]","mb-1 w-fit rounded text-left text-xs transition-colors","px-2 py-2 md:px-1 md:py-0.5",w>0?"text-primary hover:text-primary/80 font-medium":"text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{"aria-hidden":!0,className:"mr-1",children:"↳"}),t.jsx("span",{className:ee(f&&"motion-safe:animate-count-flip"),"data-testid":"room-thread-reply-count",children:i},i),i===1?" reply":" replies",y.length>0&&t.jsxs(t.Fragment,{children:[" · last ",t.jsx("time",{dateTime:d,title:Pt(d),children:y})]}),w>0&&` · ${w} new`]}):null}function Wt({loading:e,onLoad:o}){return t.jsx("div",{className:"flex justify-center px-4 py-3",children:t.jsxs(we,{type:"button",variant:"ghost",size:"sm",onClick:o,disabled:e,"data-testid":"room-load-older",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&t.jsx(He,{size:"xs"}),e?"Loading older messages…":"Older messages"]})})}const Bt="room-load-older",Kt=4;function Pe({roomName:e}){return t.jsx(Et,{label:e===void 0?"Messages":`Messages in ${e}`,busy:!0,className:"flex flex-col gap-4 p-4","data-testid":"room-timeline-loading",children:Array.from({length:Kt},(o,r)=>t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Q,{className:"size-7 shrink-0 rounded-full"}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[t.jsx(Q,{className:"h-3 w-24"}),t.jsx(Q,{className:"h-3 w-full max-w-md"})]})]},`room-skeleton-${r}`))})}function Gt({roomId:e,roomName:o,viewerAuthorId:r,entries:u,members:R,formerAuthors:i,lastReadSeq:d,reactionFrequents:w,streamStalled:y,isLoading:x,error:p,onAddAgents:f,openThreadId:v,onOpenThread:I,resumeRow:k,landOnRow:A,onTopRow:j,canLoadOlder:S=!1,isLoadingOlder:l=!1,onLoadOlder:c,ref:C}){const N=s.useMemo(()=>le(R,i),[R,i]),P=Ie(R,r),E=ue(),T=s.useMemo(()=>new Map([...N].map(([n,m])=>[n,m.displayName])),[N]),M=qe(),L=ke(e,null),{topLevel:H,repliesByRoot:F,orphaned:D}=s.useMemo(()=>kt(u),[u]),q=s.useMemo(()=>new Map(u.map(n=>[n.id,n])),[u]),z=s.useMemo(()=>{const n=$e(H,d),m=We(H.map(a=>({id:a.id,authorId:a.body.moment?`moment:${a.id}`:a.authorId,timestamp:a.createdAt})),{now:M,lastSeenId:n.lastSeenId,unreadFromStart:n.fromStart}),b=[];S&&!x&&b.push({kind:"load-older",id:Bt});for(const a of m){if(a.kind==="day-divider"){b.push({kind:"day-divider",id:a.key,label:a.label});continue}if(a.kind==="unread-divider"){b.push({kind:"unread-divider",id:a.key});continue}const h=H[a.index];b.push({kind:"message",id:h.id,entry:h,grouping:a.grouping,position:a.index+1,answers:Ae(h,H[a.index-1],q.get.bind(q))});const g=F.get(h.id);g&&b.push({kind:"thread-reply",id:At(h.id),rootId:h.id,replies:g,totalReplies:h.threadReplyCount})}return b},[H,F,q,d,M,S,x]),$=s.useMemo(()=>z.map(n=>n.kind==="load-older"?{kind:"notice",id:n.id,at:"",body:null}:n.kind==="day-divider"?{kind:"day-divider",id:n.id,label:n.label}:n.kind==="unread-divider"?{kind:"unread-divider",id:n.id}:n.kind==="thread-reply"?{kind:"thread-reply",id:n.id,rootId:n.rootId,replyCount:Ne(n.replies.length,n.totalReplies),lastAt:n.replies[n.replies.length-1].createdAt}:{kind:"message",id:n.id,payload:n.entry,grouping:n.grouping,author:G(V(n.entry,N),N,E.faces),at:n.entry.createdAt}),[z,N,E.faces]),K=s.useCallback((n,m)=>{const b=z[m.index];if(b.kind==="load-older")return c===void 0?null:t.jsx(Wt,{loading:l,onLoad:c});if(b.kind==="day-divider")return t.jsx(bt,{label:b.label});if(b.kind==="unread-divider")return t.jsx(jt,{});if(b.kind==="thread-reply"){if(m.onOpenThread===void 0)return null;const h=m.onOpenThread;return t.jsx($t,{id:re(b.rootId),summary:Nt(b.replies,d,b.totalReplies),open:v===b.rootId,onOpen:()=>h(b.rootId)})}const a=V(b.entry,N);return t.jsx(oe,{roomId:e,entry:b.entry,author:G(a,N,E.faces),authorRef:N.get(a),authors:N,viewerAuthorId:r,authorNames:T,reactionFrequents:w,streamStalled:y,isMember:P,grouping:b.grouping,orphanedReply:D.has(b.entry.id),answers:b.answers,feedPosition:{index:b.position,total:-1},rowId:ae(b.entry.id)})},[z,e,N,E.faces,r,T,w,y,P,D,d,v,l,c]),O=s.useCallback(n=>{if(n.kind==="message")return ae(n.id);if(n.kind==="thread-reply")return re(n.rootId)},[]);if(p)return t.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[t.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load these messages"}),t.jsx("p",{className:"max-w-sm",children:"Nothing was lost. Reload to try again."})]});const W=R.some(n=>n.author.kind==="agent"),B=t.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[t.jsx(Be,{className:"text-muted-foreground/50 size-8","aria-hidden":!0}),t.jsx("p",{className:"text-foreground font-medium",children:"Nothing said here yet"}),t.jsx("p",{className:"max-w-sm",children:W?"Say something to get it going.":"Nothing answers until you add an agent."}),t.jsx(we,{type:"button",size:"sm",variant:W?"ghost":"default",onClick:f,className:"mt-1",children:W?"Add more agents":"Add agents"})]});return t.jsx(Se,{known:E,children:t.jsx(X.Timeline,{ref:C,conversationId:e,label:`Messages in ${o}`,rows:$,renderRow:K,onOpenThread:I,domIdOf:O,...k===void 0?{}:{resumeRow:k},...A===void 0?{}:{landOnRow:A},...j===void 0?{}:{onTopRow:j},pending:L,viewerAuthorId:r,loading:x?t.jsx(Pe,{roomName:o}):void 0,empty:B,feedTestId:"room-timeline"})})}function Ut(e){const{roomId:o,entrySeq:r,entries:u,historyLoaded:R}=e,i=r===void 0?null:`${o}:${r}`,d=s.useMemo(()=>{if(r===void 0)return null;const k=u.find(l=>l.seq===r);if(k===void 0)return null;const A=Ce(u,k.id);if(A===null)return null;const j=ce(k)??null,S=j!==null&&A.rowId!==k.id;return{roomRowId:A.rowId,threadRootId:S?j:null,entryId:k.id}},[u,r]),w=s.useRef(null),y=(d==null?void 0:d.threadRootId)??null;s.useEffect(()=>{i===null||y===null||w.current!==i&&(w.current=i,U.getState().openThread(o,y))},[i,o,y]);const x=s.useRef(null);s.useEffect(()=>{i===null||!R||d===null&&x.current!==i&&(x.current=i,Ke.info("That message isn’t in the loaded history",{description:"Only recent messages are open. Nothing was lost."}))},[i,R,d]);const p=s.useRef(null),f=s.useCallback(()=>{if(!(i===null||p.current===i))return p.current=i,d==null?void 0:d.roomRowId},[i,d]),v=s.useRef(null),I=s.useCallback(()=>{if(!(i===null||v.current===i))return v.current=i,(d==null?void 0:d.threadRootId)===null||d==null?void 0:d.entryId},[i,d]);return{roomRow:r===void 0?void 0:f,threadRow:r===void 0?void 0:I}}function Xt(e,o){const[r,u]=s.useState({roomId:null,seq:null});return r.roomId===e?r.seq:e===null?(u({roomId:null,seq:null}),null):o===null?null:(u({roomId:e,seq:o}),o)}const Yt=600;function Qt(e){return document.getElementById(re(e))??document.getElementById(ae(e))}function Vt(){const e=s.useRef(null);return s.useEffect(()=>()=>{var r;return(r=e.current)==null?void 0:r.call(e)},[]),{arm:s.useCallback(r=>{var w;(w=e.current)==null||w.call(e);let u=0;const R=Date.now()+Yt;let i=!1;const d=()=>{if(i)return;const y=document.activeElement;if(y===null||y===document.body||!y.isConnected){const p=Qt(r);if(p!==null){p.focus();return}}Date.now()>=R||(u=requestAnimationFrame(d))};u=requestAnimationFrame(d),e.current=()=>{i=!0,cancelAnimationFrame(u)}},[])}}function Zt({roomId:e,route:o,urlThreadId:r,openThreadId:u,entries:R,historyLoaded:i}){const d=Ge(),w=s.useRef(null);s.useEffect(()=>{if(e!==null){if(w.current!==e&&(w.current=e,r!==void 0)){U.getState().openThread(e,r);return}if(i&&u!==void 0){const y=R.find(p=>p.id===u),x=y===void 0?void 0:St(y);if(x!==void 0&&x!==u){const p=U.getState().open[e];U.getState().openThread(e,x,(p==null?void 0:p.focusComposer)??!1);return}}u!==r&&(d==null||d({to:o,search:y=>({...y,thread:u}),replace:!0}))}},[e,o,u,r,R,i,d])}function Jt(e){return e.kind!=="channel"||e.bridge!=null||e.archived?!1:!e.members.some(o=>o.author.kind==="agent")}function en({room:e,hasEntries:o,onAddAgents:r}){return!o||!Jt(e)?null:t.jsxs("p",{className:"text-muted-foreground shrink-0 px-4 pb-1 text-xs","data-testid":"no-agent-hint",children:["No agent is in this channel to answer."," ",t.jsx("button",{type:"button",onClick:r,className:"text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Add one"})," ","to get answers here."]})}function tn({roomId:e}){const{approvals:o}=Ue(),r=Xe(o).filter(u=>u.roomId===e);return r.length===0?null:t.jsx("section",{"data-slot":"room-approvals","aria-label":"Requests waiting on you",className:"shrink-0 px-3 pb-2 md:px-4",children:t.jsx(Ye,{approvals:r})})}function nn({roomId:e}){const{data:o}=Lt("pending"),r=(o??[]).filter(u=>u.roomId===e);return r.length===0?null:t.jsx("section",{"data-slot":"room-agent-requests","aria-label":"Apps agents are asking for",className:"shrink-0 space-y-2 px-3 pb-2 md:px-4",children:r.map(u=>t.jsx(Ft,{request:u},u.requestId))})}const sn="An agent",xe=64,se=3,rn=new Set;function Ee({room:e,entries:o,scope:r,laneScope:u,stalled:R,unavailable:i=!1,onRetry:d,onScrollToRow:w}){const y=Qe(),x=Ve(e.id,r),p=Ze(e.id,r),f=Je(e.id,r),[v,I]=s.useState(!1),k=Dt(e.id,{enabled:v}),A=et(),{mutate:j}=zt(),[S,l]=s.useState(rn),c=s.useCallback(a=>{l(h=>new Set(h).add(a)),j({roomId:e.id,authorId:a},{onSettled:()=>l(h=>{const g=new Set(h);return g.delete(a),g})})},[j,e.id]),C=Ht(),[N,P]=s.useState(()=>new Map),E=tt(),T=ue(),M=s.useMemo(()=>le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),L=s.useCallback(a=>{var h;return((h=M.get(a))==null?void 0:h.displayName)??sn},[M]),{interactions:H}=nt(),F=s.useMemo(()=>H.filter(a=>a.roomId===e.id),[H,e.id]),D=s.useMemo(()=>{var h;const a={};for(const g of F){if(g.roomAuthorId===void 0)continue;const _=(h=M.get(g.roomAuthorId))==null?void 0:h.displayName;_!==void 0&&(a[g.sessionId]=_)}return a},[F,M]),q=s.useMemo(()=>x.map(a=>({authorId:a.authorId,name:L(a.authorId),state:a.state,since:a.since,activity:a.activity??null})),[x,L]),z=s.useMemo(()=>p.map(a=>{var g;const h=(g=E.data)==null?void 0:g.find(_=>_.id===a.behindRoomId);return{authorId:a.authorId,name:L(a.authorId),since:a.since,behind:{roomId:a.behindRoomId,title:h===void 0?null:Y(h)},othersWaiting:a.othersWaiting,severalInTheWay:a.severalInTheWay}}),[p,L,E.data]),$=s.useMemo(()=>{const a=new Set;for(const h of p)N.get(h.authorId)===h.entryId&&a.add(h.authorId);return a},[p,N]),K=s.useMemo(()=>f===null?null:{authorId:f.authorId,name:L(f.authorId)},[f,L]),O=s.useMemo(()=>Ot({capabilities:fe,asks:F,agentNames:D,stalled:R,presence:q,held:z,silentFinish:K,turn:null}),[F,D,q,z,K,R]),W=s.useMemo(()=>{var h;const a=new Map;for(const g of((h=k.data)==null?void 0:h.bindings)??[])a.set(g.authorId,g.sessionId);return a},[k.data]),B=s.useCallback(a=>{const h=o.find(_=>_.id===a);if(h===void 0)return null;const g=h.body.text.replace(/\s+/gu," ").trim();return g.length===0?null:g.length>xe?`${g.slice(0,xe).trimEnd()}…`:g},[o]),n=s.useCallback(a=>{var h;return u==="thread"?J(a):((h=Ce(o,a))==null?void 0:h.domId)??null},[o,u]),m=s.useMemo(()=>{const a=x.map(g=>{const _=B(g.entryId),Z=n(g.entryId);return{authorId:g.authorId,author:G(g.authorId,M,T.faces),state:g.state,since:g.since,doing:st(g.activity),replyingTo:_===null||Z===null?null:{entryId:g.entryId,excerpt:_,rowId:Z},sessionId:W.get(g.authorId)??null}}),h=z.map(g=>({authorId:g.authorId,author:G(g.authorId,M,T.faces),state:"held",since:g.since,doing:null,replyingTo:null,sessionId:null,behind:g.behind,othersWaiting:g.othersWaiting}));return[...a,...h]},[x,z,M,T.faces,B,n,W]),b=s.useMemo(()=>{if(x.length===0)return null;const a=x.slice(0,se);return t.jsxs("span",{"aria-hidden":"true",className:"flex shrink-0 -space-x-1",children:[a.map(h=>t.jsx(_t,{author:G(h.authorId,M,T.faces),className:"ring-background size-4 ring-2"},h.authorId)),x.length>se&&t.jsx("span",{className:"bg-muted text-muted-foreground ring-background text-3xs flex size-4 items-center justify-center rounded-full ring-2",children:`+${x.length-se}`})]})},[x,M,T.faces]);return t.jsx(X.LiveLane,{state:O,scope:u,onRetry:d,unavailable:i,faces:b,onPeekOpenChange:I,askCard:O.kind==="ask"?t.jsx(ot,{ask:O.ask,...D[O.ask.sessionId]?{agentName:D[O.ask.sessionId]}:{},onOpenSession:a=>{y(he({session:a}))},className:"border-l-0"}):void 0,peek:t.jsx(X.LivePeek,{rows:m,onScrollToRow:w,onOpenSession:a=>{y(he({session:a}))},onOpenRoom:a=>{y({...rt.channels(),search:{id:a}})},onAnswerFirst:a=>{const h=p.find(g=>g.authorId===a);h!==void 0&&P(g=>new Map(g).set(a,h.entryId)),C.mutate({roomId:e.id,authorId:a})},promoted:$,onStopAll:()=>A.mutate({roomId:e.id}),stopping:A.isPending,onStopAgent:c,stoppingAgents:S})})}const ye=3e3;function on(e,o,r,u=Date.now){const R=s.useRef(null),i=s.useRef(new Map),d=s.useRef(new Map),w=R.current,y=i.current,x=d.current,p=u();for(const f of e){if(x.has(f.id))continue;if(w===null){x.set(f.id,"at-rest");continue}const v=y.get(f.authorId);x.set(f.id,v!==void 0&&p-v<ye?"handed-off":"dropped")}return s.useEffect(()=>{if(!r)return;R.current=new Set(e.map(v=>v.id));const f=u();for(const v of o)i.current.set(v,f);for(const[v,I]of i.current)f-I>ye&&i.current.delete(v);for(const v of d.current.keys())R.current.has(v)||d.current.delete(v)}),x}function an({kind:e}){return e==="thread-error"?t.jsxs("div",{"data-slot":"thread-notice","data-testid":"room-thread-error",className:"text-muted-foreground flex flex-col items-center gap-2 px-[var(--msg-padding-x)] py-6 text-center text-sm",children:[t.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load this thread"}),t.jsx("p",{className:"max-w-sm text-xs",children:"Nothing was lost. Reload to try again."})]}):e==="thread-waiting"?t.jsxs("div",{"data-slot":"thread-notice",className:"flex flex-col gap-2 px-[var(--msg-padding-x)]",children:[t.jsx(Q,{className:"h-3 w-24"}),t.jsx(Q,{className:"h-3 w-full max-w-sm"})]}):t.jsx("p",{"data-slot":"thread-notice","data-testid":"room-thread-orphan",className:"text-muted-foreground border-b px-[var(--msg-padding-x)] pb-3 text-xs italic",children:"This thread’s first message is gone. Its replies remain."})}function dn({room:e,rootEntryId:o,focusComposer:r,entries:u,reactionFrequents:R,streamStalled:i,streamUnavailable:d,onRetryStream:w,historyLoaded:y,historyFailed:x=!1,landOnRow:p,pushed:f,onClose:v}){const I=s.useMemo(()=>le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),k=Me({room:e,threadRootId:o}),A=Ie(e.members,e.viewerAuthorId),j=ue(),S=s.useMemo(()=>new Map([...I].map(([n,m])=>[n,m.displayName])),[I]),{root:l,replies:c}=s.useMemo(()=>{let n;const m=[];for(const b of u)b.id===o?n=b:ce(b)===o&&m.push(b);return{root:n,replies:m}},[u,o]),C=l==null?void 0:l.threadReplyCount,N=C!==void 0&&C>c.length,P=!f,E=l===void 0||N?-1:(P?1:0)+c.length,T=Ne(c.length,C),M=s.useMemo(()=>new Set(c.map(n=>n.id)),[c]),L=s.useMemo(()=>({replyIds:M,inside:!0}),[M]),H=at(e.id,L),F=ke(e.id,o),D=on(c,H,y),q=s.useRef(null),z=s.useCallback(n=>{var m;(m=q.current)==null||m.scrollToRow(n)},[]),$=s.useRef(null);s.useEffect(()=>{var n;r||(n=$.current)==null||n.focus()},[o,r]);const K=n=>{n.key!=="Escape"||n.defaultPrevented||(n.stopPropagation(),v())},O=s.useMemo(()=>{const n=[];if(l===void 0){const m=x?"thread-error":y?"thread-orphan":"thread-waiting";n.push({kind:"notice",id:m,at:"",body:null})}else P&&n.push({kind:"message",id:l.id,payload:l,grouping:{position:"only"},author:G(V(l,I),I,j.faces),at:l.createdAt});for(const m of c)n.push({kind:"message",id:m.id,payload:m,grouping:{position:"only"},author:G(V(m,I),I,j.faces),at:m.createdAt});return n},[l,P,c,I,j.faces,x,y]),W=s.useCallback(n=>{if(n.kind==="notice")return t.jsx(an,{kind:n.id});if(n.kind!=="message")return null;const m=n.payload,b=l!==void 0&&m.id===l.id,a=c.findIndex(_=>_.id===m.id),h=t.jsx(oe,{roomId:e.id,entry:m,rowId:J(m.id),author:n.author,authorRef:I.get(m.authorId),authors:I,viewerAuthorId:e.viewerAuthorId,authorNames:S,reactionFrequents:R,streamStalled:i,isMember:A,grouping:{position:"only"},answers:Ae(m,a<=0?l:c[a-1],_=>(l==null?void 0:l.id)===_?l:c.find(Z=>Z.id===_)),feedPosition:{index:b?1:(l===void 0||!P?0:1)+a+1,total:E}});if(b)return t.jsxs(t.Fragment,{children:[h,t.jsx(Re,{count:T})]});const g=D.get(m.id)??"at-rest";return t.jsx("div",{className:ee(g==="dropped"&&"motion-safe:animate-thread-reply-in",g==="handed-off"&&"motion-safe:animate-reply-settle"),children:h})},[l,P,c,T,D,e.id,e.viewerAuthorId,I,S,R,i,A,E]),B=s.useCallback(n=>n.kind==="message"?J(n.id):void 0,[]);return t.jsx(Se,{known:j,children:t.jsx(X.Root,{surface:"room",capabilities:fe,target:k.target,anchor:"rail",children:t.jsxs("section",{ref:$,"aria-label":"Thread","data-testid":"room-thread-panel",tabIndex:-1,onKeyDown:K,className:ee("bg-card flex min-h-0 flex-col outline-none",f?"h-full w-full":"w-full border-l"),children:[f?t.jsxs("header",{className:"flex items-center gap-2 border-b px-1 py-1",children:[t.jsxs("button",{type:"button",onClick:v,"aria-label":`Back to ${Y(e)}`,"data-testid":"room-thread-back",className:"focus-ring text-muted-foreground hover:text-foreground flex h-11 min-w-0 items-center gap-1 rounded px-2 text-sm",children:[t.jsx(it,{"aria-hidden":!0,className:"size-4 shrink-0"}),t.jsx("span",{className:"truncate",children:Y(e)})]}),t.jsx("p",{className:"ml-auto shrink-0 pr-3 text-sm font-medium",children:"Thread"})]}):t.jsxs("header",{className:"flex items-center gap-2 border-b px-3 py-2",children:[t.jsx("button",{type:"button",onClick:v,"aria-label":"Close thread",className:"focus-ring text-muted-foreground hover:text-foreground relative -ml-1 rounded p-1",children:t.jsx(dt,{"aria-hidden":!0,className:"size-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Thread"}),t.jsx("p",{className:"text-muted-foreground truncate text-xs",children:Y(e)})]})]}),f&&l!==void 0&&t.jsxs("div",{"data-testid":"room-thread-pinned-root",className:"max-h-[40%] shrink-0 overflow-y-auto border-b pt-2",children:[t.jsx(oe,{roomId:e.id,entry:l,rowId:J(l.id),author:G(V(l,I),I,j.faces),authorRef:I.get(l.authorId),authors:I,viewerAuthorId:e.viewerAuthorId,authorNames:S,reactionFrequents:R,streamStalled:i,isMember:A,grouping:{position:"only"}}),t.jsx(Re,{count:T})]}),t.jsx(X.Timeline,{ref:q,conversationId:`thread-${o}`,label:`Thread in ${Y(e)}`,busy:!y&&!x,rows:O,renderRow:W,domIdOf:B,...p===void 0?{}:{landOnRow:p},pending:F,viewerAuthorId:e.viewerAuthorId,className:"py-3",feedTestId:"room-thread-feed"}),t.jsx(Ee,{room:e,entries:u,scope:L,laneScope:"thread",stalled:f&&i===!0,unavailable:d,onRetry:f?w:void 0,onScrollToRow:z}),t.jsx(Te,{room:e,threadRootId:o,attachments:k.attachments,focusOnMount:r},o)]})})})}function Re({count:e}){return e===0?null:t.jsxs("div",{"aria-hidden":!0,"data-testid":"room-thread-divider",className:"flex items-center gap-2 px-[var(--msg-padding-x)] pt-1 pb-2",children:[t.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:e===1?"1 reply":`${e} replies`}),t.jsx("span",{className:"bg-border h-px flex-1"})]})}const ln=96,un=500;function cn(e){return e.offset.x>ln||e.velocity.x>un}function fn({children:e,onClose:o}){const r=lt()===!0,u=r?{x:0}:{x:"100%"};return t.jsx(ut.div,{"data-testid":"room-thread-sheet",className:"bg-card absolute inset-0 z-10 flex flex-col shadow-xl",initial:u,animate:{x:0},exit:u,transition:r?{duration:0}:{duration:.22,ease:[.32,.72,0,1]},drag:"x",dragDirectionLock:!0,dragConstraints:{left:0,right:0},dragElastic:{left:0,right:.9},dragMomentum:!1,onDragEnd:(R,i)=>{cn(i)&&o()},children:e})}const te="room-thread-split",mn=320,hn=360,pn=40,gn=50,xn=25;function ve(e,o){return o<=0?xn:Math.min(Math.round(e/o*1e3)/10,gn)}function yn(e){const o=ve(mn,e),r=Math.round((100-ve(hn,e))*10)/10;return{minPct:o,maxPct:r,defaultPct:Math.min(Math.max(pn,o),r)}}function Rn(e,o,r){if(e===null||o===null||o<=0)return r.defaultPct;const u=e/o*100;return Math.round(Math.min(Math.max(u,r.minPct),r.maxPct)*10)/10}function vn(e){try{const o=localStorage.getItem(e),r=o===null?NaN:Number(o);return Number.isFinite(r)&&r>0?r:null}catch{return null}}function bn(e,o){try{localStorage.setItem(e,String(Math.round(o)))}catch{}}const jn="react-resizable-panels:room-thread-split";function wn(){try{localStorage.removeItem(jn)}catch{}}function In(){const[e,o]=s.useState(null),[r,u]=s.useState(null);return{ref:s.useCallback(i=>{if(i===null)return;o(i);const d=()=>u(i.offsetWidth);d();const w=new ResizeObserver(d);return w.observe(i),()=>{w.disconnect(),o(null),u(null)}},[]),element:e,width:r,sizing:yn(r??0)}}const kn=`${te}-room`,be=`${te}-thread`,je=`${te}-handle`,An=4;function Nn({room:e,thread:o,storageKey:r=ft.ROOM_THREAD_WIDTH}){const{ref:u,element:R,width:i,sizing:d}=In(),[w,y]=s.useState(()=>vn(r)),[x,p]=s.useState(null),f=s.useRef(null),v=Rn(w,i,d),I=i===null||(d.maxPct-d.minPct)/100*i<An,k=o!==!1;s.useEffect(wn,[]);const A=s.useRef(!1);s.useLayoutEffect(()=>{var c;A.current&&((c=f.current)==null||c.resize(v))},[v,k]);const j=s.useRef(null),S=()=>{var P;const c=(P=f.current)==null?void 0:P.getSize(),C=j.current;if(j.current=null,c===void 0||i===null||i<=0||C===c)return;const N=Math.round(c/100*i);y(N),bn(r,N)},l=x??v;return s.useLayoutEffect(()=>{const c=R==null?void 0:R.querySelector(`[data-panel-resize-handle-id="${je}"]`);c&&(c.setAttribute("aria-controls",be),c.setAttribute("aria-valuenow",String(Math.round(l))),c.setAttribute("aria-valuemin",String(Math.round(d.minPct))),c.setAttribute("aria-valuemax",String(Math.round(d.maxPct))))}),t.jsx("div",{ref:u,className:"h-full overflow-hidden",children:t.jsxs(ct,{direction:"horizontal",id:te,onLayout:c=>{A.current=c.length>1,p(A.current?c[1]:null)},children:[t.jsx(pe,{id:kn,order:1,className:"flex",children:e}),k&&t.jsxs(t.Fragment,{children:[t.jsx(Rt,{id:je,"aria-label":"Resize thread","data-testid":"room-thread-resize-handle",disabled:I,onDragging:c=>{var C;c&&(j.current=((C=f.current)==null?void 0:C.getSize())??null)},onKeyDownCapture:c=>{var C,N;I||(j.current=((C=f.current)==null?void 0:C.getSize())??null,!(c.key!=="Home"&&c.key!=="End")&&(c.preventDefault(),(N=f.current)==null||N.resize(c.key==="Home"?d.minPct:d.maxPct)))},onResizeEnd:S}),t.jsx(pe,{ref:f,id:be,order:2,defaultSize:v,minSize:d.minPct,maxSize:d.maxPct,className:"flex",children:o})]})]})})}function Fn({roomId:e,threadId:o,entrySeq:r,threadRoute:u,aboveTimeline:R,aboveComposer:i,offerJumpBackIn:d,onComposerFocusChange:w}){const y=mt(),x=vt(),p=ht(e),f=p==null?void 0:p.rootEntryId,v=Vt(),I=s.useCallback(()=>{var m;const n=(m=U.getState().open[e])==null?void 0:m.rootEntryId;U.getState().closeThread(e),n!==void 0&&v.arm(n)},[e,v]),k=s.useCallback(n=>{U.getState().openThread(e,n)},[e]),A=pt(e),j=gt(e),S=wt(e,j.isSuccess);It(e);const l=A.data,c=s.useMemo(()=>j.data??[],[j.data]),C=Me({room:l});Zt({roomId:e,route:u,urlThreadId:o,openThreadId:f,entries:c,historyLoaded:j.isSuccess});const N=s.useMemo(()=>{var n;return((n=l==null?void 0:l.members.find(m=>m.author.id===l.viewerAuthorId))==null?void 0:n.lastReadSeq)??null},[l]),P=Xt(e,N);xt(l,c);const E=s.useRef(null),T=s.useRef(void 0),M=s.useCallback(n=>{T.current=n},[]),L=s.useCallback(()=>T.current,[]);s.useLayoutEffect(()=>{T.current=void 0},[e]);const H=s.useCallback(n=>{var m;(m=E.current)==null||m.scrollToRow(n)},[]),F=qt(e),{loadOlder:D,cursor:q}=F,z=s.useCallback(()=>{const n=Ct(c,q);D().then(()=>{n!==null&&requestAnimationFrame(()=>{var m;return(m=E.current)==null?void 0:m.scrollToRow(n.domId)})})},[c,q,D]),$=Ut({roomId:e,entrySeq:r,entries:c,historyLoaded:j.isSuccess}),K=s.useMemo(()=>f===void 0?void 0:{replyIds:new Set(c.filter(m=>ce(m)===f).map(m=>m.id)),inside:!1},[c,f]);if(A.isLoading)return t.jsx("div",{className:"flex h-full flex-col","aria-busy":!0,children:t.jsx(Pe,{})});if(A.isError||!l)return t.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[t.jsx("p",{className:"text-foreground font-medium",children:"That channel or DM isn’t here"}),t.jsx("p",{className:"max-w-sm",children:"It may be archived, or the link is old."})]});const O=p!==void 0&&t.jsx(dn,{room:l,rootEntryId:p.rootEntryId,focusComposer:p.focusComposer,entries:c,reactionFrequents:l.reactionFrequents,streamStalled:S.stalled,streamUnavailable:S.unavailable,onRetryStream:S.retry,historyLoaded:j.isSuccess,historyFailed:j.isError,...$.threadRow===void 0?{}:{landOnRow:$.threadRow},pushed:y,onClose:I},p.rootEntryId),W=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[R,t.jsx(Gt,{ref:E,roomId:l.id,roomName:Y(l),viewerAuthorId:l.viewerAuthorId,entries:c,members:l.members,formerAuthors:l.formerAuthors,lastReadSeq:P,reactionFrequents:l.reactionFrequents,streamStalled:S.stalled,isLoading:j.isLoading,error:j.error,onAddAgents:()=>ge("add",l.id),openThreadId:f,onOpenThread:k,resumeRow:L,...$.roomRow===void 0?{}:{landOnRow:$.roomRow},onTopRow:M,canLoadOlder:F.canLoadOlder,isLoadingOlder:F.isLoadingOlder,onLoadOlder:z}),i,t.jsx(tn,{roomId:l.id}),t.jsx(nn,{roomId:l.id}),t.jsx(Ee,{room:l,entries:c,scope:K,laneScope:"room",stalled:S.stalled,unavailable:S.unavailable,onRetry:S.retry,onScrollToRow:H}),t.jsx(en,{room:l,hasEntries:c.length>0,onAddAgents:()=>ge("add",l.id)}),t.jsx(Te,{room:l,attachments:C.attachments,offerJumpBackIn:d,onFocusChange:w},l.id)]}),B={surface:"room",capabilities:fe,target:C.target,anchor:"rail"};return y?t.jsx(X.Root,{...B,children:t.jsx("div",{style:{paddingBottom:x},"data-testid":"room-surface",className:"flex h-full flex-col overflow-hidden",children:t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",inert:O!==!1,"data-testid":"room-under-thread",children:W}),t.jsx(yt,{initial:!1,children:O!==!1&&t.jsx(fn,{onClose:I,children:O},`thread-${f}`)})]})})}):t.jsx(X.Root,{...B,children:t.jsx(Nn,{room:W,thread:O})})}export{Fn as R,$t as T,Pe as a};
|
|
1
|
+
import{a1 as ie,a4 as de,a3 as Oe,j0 as _e,j1 as ne,j2 as me,j3 as Le,j4 as De,j5 as Fe,aN as ze,r as s,j as t,G as ee,B as we,x as He,e as Q,gy as Ie,hh as qe,gx as ke,j6 as $e,j7 as We,n as Be,gB as U,dD as Ke,fx as Ge,j8 as Ue,j9 as Xe,ja as Ye,cs as Qe,jb as Ve,jc as Ze,jd as Je,je as et,co as tt,jf as nt,gw as Y,jg as st,l as rt,s as he,jh as ot,ji as at,e6 as it,X as dt,e3 as lt,ap as ut,jj as ct,jk as pe,jl as ft,ab as mt,jm as ht,gv as pt,gu as gt,jn as xt,aD as ge,bw as Rt}from"./index-fge85Gub.js";import{P as yt,u as vt}from"./pane-resize-handle-Bar-FdkY.js";import{D as bt,U as jt,u as wt}from"./UnreadDivider-DPD9MQ8-.js";import{u as It}from"./use-room-follow-claim-_B7HonZx.js";import{a as le,e as ue,g as kt,f as Ae,h as At,i as Ne,c as G,d as V,j as Nt,k as re,b as oe,l as ae,A as Se,m as Ce,t as ce,r as St,n as J,R as fe,u as Me,C as Te,o as Ct}from"./ChannelComposer-YXkkFcyY.js";import{u as Mt,f as Tt,a as Et,F as Pt,C as X,d as Ot,M as _t}from"./registry-5Qudcjd5.js";import{u as Lt}from"./use-connector-management-CXVz2xe3.js";import{A as Dt}from"./AgentRequestCard-RFQOrk-W.js";import{u as Ft}from"./use-room-sessions-CrFskgCJ.js";function zt(){const e=ie();return de({mutationFn:({roomId:o,authorId:r})=>e.haltRoomAgent(o,r),meta:{errorLabel:"Couldn’t stop this agent"}})}function Ht(){const e=ie();return de({mutationFn:({roomId:o,authorId:r})=>e.promoteHold(o,r),meta:{errorLabel:"Couldn’t ask to be answered first"}})}function qt(e){const o=ie(),r=Oe(),u=_e(e),y=ne(p=>{var f;return e===null?null:((f=p.paging[e])==null?void 0:f.cursor)??null}),i=de({mutationFn:async p=>{var j;const f=(j=ne.getState().paging[p])==null?void 0:j.cursor;if(f==null)return;const v=await o.listRoomEntries(p,{before:f,limit:me}),I=ze.entries(p),k=r.getQueryData(I),A=Le(k,v);r.setQueryData(I,A),ne.getState().notePage(p,De(v)??f,Fe(v,me)||A.length===((k==null?void 0:k.length)??0))},meta:{errorLabel:"Couldn't load older messages"}}),{mutateAsync:d,isPending:w}=i,R=s.useRef(!1),x=s.useCallback(async()=>{if(!(e===null||R.current)){R.current=!0;try{await d(e).catch(()=>{})}finally{R.current=!1}}},[e,d]);return{canLoadOlder:u,isLoadingOlder:w,cursor:y,loadOlder:x}}function $t({id:e,summary:o,open:r,onOpen:u}){const{capabilities:y}=Mt(),{count:i,lastAt:d,unread:w}=o,R=Tt(d),[x,p]=s.useState({count:i,bumped:!1});x.count!==i&&p({count:i,bumped:!0});const f=x.count===i&&x.bumped;return y.threads?t.jsxs("button",{type:"button",id:e,"data-slot":"thread-reply-row","data-testid":"room-thread-replies","data-unread":w>0?"":void 0,"aria-expanded":r,onClick:u,className:ee("focus-ring ml-[calc(var(--msg-padding-x)_+_var(--msg-gutter-width)_+_var(--msg-gap))]","mb-1 w-fit rounded text-left text-xs transition-colors","px-2 py-2 md:px-1 md:py-0.5",w>0?"text-primary hover:text-primary/80 font-medium":"text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{"aria-hidden":!0,className:"mr-1",children:"↳"}),t.jsx("span",{className:ee(f&&"motion-safe:animate-count-flip"),"data-testid":"room-thread-reply-count",children:i},i),i===1?" reply":" replies",R.length>0&&t.jsxs(t.Fragment,{children:[" · last ",t.jsx("time",{dateTime:d,title:Et(d),children:R})]}),w>0&&` · ${w} new`]}):null}function Wt({loading:e,onLoad:o}){return t.jsx("div",{className:"flex justify-center px-4 py-3",children:t.jsxs(we,{type:"button",variant:"ghost",size:"sm",onClick:o,disabled:e,"data-testid":"room-load-older",className:"text-muted-foreground hover:text-foreground h-7 gap-2 text-xs",children:[e&&t.jsx(He,{size:"xs"}),e?"Loading older messages…":"Older messages"]})})}const Bt="room-load-older",Kt=4;function Ee({roomName:e}){return t.jsx(Pt,{label:e===void 0?"Messages":`Messages in ${e}`,busy:!0,className:"flex flex-col gap-4 p-4","data-testid":"room-timeline-loading",children:Array.from({length:Kt},(o,r)=>t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Q,{className:"size-7 shrink-0 rounded-full"}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[t.jsx(Q,{className:"h-3 w-24"}),t.jsx(Q,{className:"h-3 w-full max-w-md"})]})]},`room-skeleton-${r}`))})}function Gt({roomId:e,roomName:o,viewerAuthorId:r,entries:u,members:y,formerAuthors:i,lastReadSeq:d,reactionFrequents:w,streamStalled:R,isLoading:x,error:p,onAddAgents:f,openThreadId:v,onOpenThread:I,resumeRow:k,landOnRow:A,onTopRow:j,canLoadOlder:S=!1,isLoadingOlder:l=!1,onLoadOlder:c,ref:C}){const N=s.useMemo(()=>le(y,i),[y,i]),E=Ie(y,r),P=ue(),T=s.useMemo(()=>new Map([...N].map(([n,m])=>[n,m.displayName])),[N]),M=qe(),L=ke(e,null),{topLevel:H,repliesByRoot:D,orphaned:F}=s.useMemo(()=>kt(u),[u]),q=s.useMemo(()=>new Map(u.map(n=>[n.id,n])),[u]),z=s.useMemo(()=>{const n=$e(H,d),m=We(H.map(a=>({id:a.id,authorId:a.body.moment?`moment:${a.id}`:a.authorId,timestamp:a.createdAt})),{now:M,lastSeenId:n.lastSeenId,unreadFromStart:n.fromStart}),b=[];S&&!x&&b.push({kind:"load-older",id:Bt});for(const a of m){if(a.kind==="day-divider"){b.push({kind:"day-divider",id:a.key,label:a.label});continue}if(a.kind==="unread-divider"){b.push({kind:"unread-divider",id:a.key});continue}const h=H[a.index];b.push({kind:"message",id:h.id,entry:h,grouping:a.grouping,position:a.index+1,answers:Ae(h,H[a.index-1],q.get.bind(q))});const g=D.get(h.id);g&&b.push({kind:"thread-reply",id:At(h.id),rootId:h.id,replies:g,totalReplies:h.threadReplyCount})}return b},[H,D,q,d,M,S,x]),$=s.useMemo(()=>z.map(n=>n.kind==="load-older"?{kind:"notice",id:n.id,at:"",body:null}:n.kind==="day-divider"?{kind:"day-divider",id:n.id,label:n.label}:n.kind==="unread-divider"?{kind:"unread-divider",id:n.id}:n.kind==="thread-reply"?{kind:"thread-reply",id:n.id,rootId:n.rootId,replyCount:Ne(n.replies.length,n.totalReplies),lastAt:n.replies[n.replies.length-1].createdAt}:{kind:"message",id:n.id,payload:n.entry,grouping:n.grouping,author:G(V(n.entry,N),N,P.faces),at:n.entry.createdAt}),[z,N,P.faces]),K=s.useCallback((n,m)=>{const b=z[m.index];if(b.kind==="load-older")return c===void 0?null:t.jsx(Wt,{loading:l,onLoad:c});if(b.kind==="day-divider")return t.jsx(bt,{label:b.label});if(b.kind==="unread-divider")return t.jsx(jt,{});if(b.kind==="thread-reply"){if(m.onOpenThread===void 0)return null;const h=m.onOpenThread;return t.jsx($t,{id:re(b.rootId),summary:Nt(b.replies,d,b.totalReplies),open:v===b.rootId,onOpen:()=>h(b.rootId)})}const a=V(b.entry,N);return t.jsx(oe,{roomId:e,entry:b.entry,author:G(a,N,P.faces),authorRef:N.get(a),authors:N,viewerAuthorId:r,authorNames:T,reactionFrequents:w,streamStalled:R,isMember:E,grouping:b.grouping,orphanedReply:F.has(b.entry.id),answers:b.answers,feedPosition:{index:b.position,total:-1},rowId:ae(b.entry.id)})},[z,e,N,P.faces,r,T,w,R,E,F,d,v,l,c]),O=s.useCallback(n=>{if(n.kind==="message")return ae(n.id);if(n.kind==="thread-reply")return re(n.rootId)},[]);if(p)return t.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[t.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load these messages"}),t.jsx("p",{className:"max-w-sm",children:"Nothing was lost. Reload to try again."})]});const W=y.some(n=>n.author.kind==="agent"),B=t.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2 p-10 text-center text-sm",children:[t.jsx(Be,{className:"text-muted-foreground/50 size-8","aria-hidden":!0}),t.jsx("p",{className:"text-foreground font-medium",children:"Nothing said here yet"}),t.jsx("p",{className:"max-w-sm",children:W?"Say something to get it going.":"Nothing answers until you add an agent."}),t.jsx(we,{type:"button",size:"sm",variant:W?"ghost":"default",onClick:f,className:"mt-1",children:W?"Add more agents":"Add agents"})]});return t.jsx(Se,{known:P,children:t.jsx(X.Timeline,{ref:C,conversationId:e,label:`Messages in ${o}`,rows:$,renderRow:K,onOpenThread:I,domIdOf:O,...k===void 0?{}:{resumeRow:k},...A===void 0?{}:{landOnRow:A},...j===void 0?{}:{onTopRow:j},pending:L,viewerAuthorId:r,loading:x?t.jsx(Ee,{roomName:o}):void 0,empty:B,feedTestId:"room-timeline"})})}function Ut(e){const{roomId:o,entrySeq:r,entries:u,historyLoaded:y}=e,i=r===void 0?null:`${o}:${r}`,d=s.useMemo(()=>{if(r===void 0)return null;const k=u.find(l=>l.seq===r);if(k===void 0)return null;const A=Ce(u,k.id);if(A===null)return null;const j=ce(k)??null,S=j!==null&&A.rowId!==k.id;return{roomRowId:A.rowId,threadRootId:S?j:null,entryId:k.id}},[u,r]),w=s.useRef(null),R=(d==null?void 0:d.threadRootId)??null;s.useEffect(()=>{i===null||R===null||w.current!==i&&(w.current=i,U.getState().openThread(o,R))},[i,o,R]);const x=s.useRef(null);s.useEffect(()=>{i===null||!y||d===null&&x.current!==i&&(x.current=i,Ke.info("That message isn’t in the loaded history",{description:"Only recent messages are open. Nothing was lost."}))},[i,y,d]);const p=s.useRef(null),f=s.useCallback(()=>{if(!(i===null||p.current===i))return p.current=i,d==null?void 0:d.roomRowId},[i,d]),v=s.useRef(null),I=s.useCallback(()=>{if(!(i===null||v.current===i))return v.current=i,(d==null?void 0:d.threadRootId)===null||d==null?void 0:d.entryId},[i,d]);return{roomRow:r===void 0?void 0:f,threadRow:r===void 0?void 0:I}}function Xt(e,o){const[r,u]=s.useState({roomId:null,seq:null});return r.roomId===e?r.seq:e===null?(u({roomId:null,seq:null}),null):o===null?null:(u({roomId:e,seq:o}),o)}const Yt=600;function Qt(e){return document.getElementById(re(e))??document.getElementById(ae(e))}function Vt(){const e=s.useRef(null);return s.useEffect(()=>()=>{var r;return(r=e.current)==null?void 0:r.call(e)},[]),{arm:s.useCallback(r=>{var w;(w=e.current)==null||w.call(e);let u=0;const y=Date.now()+Yt;let i=!1;const d=()=>{if(i)return;const R=document.activeElement;if(R===null||R===document.body||!R.isConnected){const p=Qt(r);if(p!==null){p.focus();return}}Date.now()>=y||(u=requestAnimationFrame(d))};u=requestAnimationFrame(d),e.current=()=>{i=!0,cancelAnimationFrame(u)}},[])}}function Zt({roomId:e,route:o,urlThreadId:r,openThreadId:u,entries:y,historyLoaded:i}){const d=Ge(),w=s.useRef(null);s.useEffect(()=>{if(e!==null){if(w.current!==e&&(w.current=e,r!==void 0)){U.getState().openThread(e,r);return}if(i&&u!==void 0){const R=y.find(p=>p.id===u),x=R===void 0?void 0:St(R);if(x!==void 0&&x!==u){const p=U.getState().open[e];U.getState().openThread(e,x,(p==null?void 0:p.focusComposer)??!1);return}}u!==r&&(d==null||d({to:o,search:R=>({...R,thread:u}),replace:!0}))}},[e,o,u,r,y,i,d])}function Jt(e){return e.kind!=="channel"||e.bridge!=null||e.archived?!1:!e.members.some(o=>o.author.kind==="agent")}function en({room:e,hasEntries:o,onAddAgents:r}){return!o||!Jt(e)?null:t.jsxs("p",{className:"text-muted-foreground shrink-0 px-4 pb-1 text-xs","data-testid":"no-agent-hint",children:["No agent is in this channel to answer."," ",t.jsx("button",{type:"button",onClick:r,className:"text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Add one"})," ","to get answers here."]})}function tn({roomId:e}){const{approvals:o}=Ue(),r=Xe(o).filter(u=>u.roomId===e);return r.length===0?null:t.jsx("section",{"data-slot":"room-approvals","aria-label":"Requests waiting on you",className:"shrink-0 px-3 pb-2 md:px-4",children:t.jsx(Ye,{approvals:r})})}function nn({roomId:e}){const{data:o}=Lt("pending"),r=(o??[]).filter(u=>u.roomId===e);return r.length===0?null:t.jsx("section",{"data-slot":"room-agent-requests","aria-label":"Apps agents are asking for",className:"shrink-0 space-y-2 px-3 pb-2 md:px-4",children:r.map(u=>t.jsx(Dt,{request:u},u.requestId))})}const sn="An agent",xe=64,se=3,rn=new Set;function Pe({room:e,entries:o,scope:r,laneScope:u,stalled:y,unavailable:i=!1,onRetry:d,onScrollToRow:w}){const R=Qe(),x=Ve(e.id,r),p=Ze(e.id,r),f=Je(e.id,r),[v,I]=s.useState(!1),k=Ft(e.id,{enabled:v}),A=et(),{mutate:j}=zt(),[S,l]=s.useState(rn),c=s.useCallback(a=>{l(h=>new Set(h).add(a)),j({roomId:e.id,authorId:a},{onSettled:()=>l(h=>{const g=new Set(h);return g.delete(a),g})})},[j,e.id]),C=Ht(),[N,E]=s.useState(()=>new Map),P=tt(),T=ue(),M=s.useMemo(()=>le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),L=s.useCallback(a=>{var h;return((h=M.get(a))==null?void 0:h.displayName)??sn},[M]),{interactions:H}=nt(),D=s.useMemo(()=>H.filter(a=>a.roomId===e.id),[H,e.id]),F=s.useMemo(()=>{var h;const a={};for(const g of D){if(g.roomAuthorId===void 0)continue;const _=(h=M.get(g.roomAuthorId))==null?void 0:h.displayName;_!==void 0&&(a[g.sessionId]=_)}return a},[D,M]),q=s.useMemo(()=>x.map(a=>({authorId:a.authorId,name:L(a.authorId),state:a.state,since:a.since,activity:a.activity??null})),[x,L]),z=s.useMemo(()=>p.map(a=>{var g;const h=(g=P.data)==null?void 0:g.find(_=>_.id===a.behindRoomId);return{authorId:a.authorId,name:L(a.authorId),since:a.since,behind:{roomId:a.behindRoomId,title:h===void 0?null:Y(h)},othersWaiting:a.othersWaiting,severalInTheWay:a.severalInTheWay}}),[p,L,P.data]),$=s.useMemo(()=>{const a=new Set;for(const h of p)N.get(h.authorId)===h.entryId&&a.add(h.authorId);return a},[p,N]),K=s.useMemo(()=>f===null?null:{authorId:f.authorId,name:L(f.authorId)},[f,L]),O=s.useMemo(()=>Ot({capabilities:fe,asks:D,agentNames:F,stalled:y,presence:q,held:z,silentFinish:K,turn:null}),[D,F,q,z,K,y]),W=s.useMemo(()=>{var h;const a=new Map;for(const g of((h=k.data)==null?void 0:h.bindings)??[])a.set(g.authorId,g.sessionId);return a},[k.data]),B=s.useCallback(a=>{const h=o.find(_=>_.id===a);if(h===void 0)return null;const g=h.body.text.replace(/\s+/gu," ").trim();return g.length===0?null:g.length>xe?`${g.slice(0,xe).trimEnd()}…`:g},[o]),n=s.useCallback(a=>{var h;return u==="thread"?J(a):((h=Ce(o,a))==null?void 0:h.domId)??null},[o,u]),m=s.useMemo(()=>{const a=x.map(g=>{const _=B(g.entryId),Z=n(g.entryId);return{authorId:g.authorId,author:G(g.authorId,M,T.faces),state:g.state,since:g.since,doing:st(g.activity),replyingTo:_===null||Z===null?null:{entryId:g.entryId,excerpt:_,rowId:Z},sessionId:W.get(g.authorId)??null}}),h=z.map(g=>({authorId:g.authorId,author:G(g.authorId,M,T.faces),state:"held",since:g.since,doing:null,replyingTo:null,sessionId:null,behind:g.behind,othersWaiting:g.othersWaiting}));return[...a,...h]},[x,z,M,T.faces,B,n,W]),b=s.useMemo(()=>{if(x.length===0)return null;const a=x.slice(0,se);return t.jsxs("span",{"aria-hidden":"true",className:"flex shrink-0 -space-x-1",children:[a.map(h=>t.jsx(_t,{author:G(h.authorId,M,T.faces),className:"ring-background size-4 ring-2"},h.authorId)),x.length>se&&t.jsx("span",{className:"bg-muted text-muted-foreground ring-background text-3xs flex size-4 items-center justify-center rounded-full ring-2",children:`+${x.length-se}`})]})},[x,M,T.faces]);return t.jsx(X.LiveLane,{state:O,scope:u,onRetry:d,unavailable:i,faces:b,onPeekOpenChange:I,askCard:O.kind==="ask"?t.jsx(ot,{ask:O.ask,...F[O.ask.sessionId]?{agentName:F[O.ask.sessionId]}:{},onOpenSession:a=>{R(he({session:a}))},className:"border-l-0"}):void 0,peek:t.jsx(X.LivePeek,{rows:m,onScrollToRow:w,onOpenSession:a=>{R(he({session:a}))},onOpenRoom:a=>{R({...rt.channels(),search:{id:a}})},onAnswerFirst:a=>{const h=p.find(g=>g.authorId===a);h!==void 0&&E(g=>new Map(g).set(a,h.entryId)),C.mutate({roomId:e.id,authorId:a})},promoted:$,onStopAll:()=>A.mutate({roomId:e.id}),stopping:A.isPending,onStopAgent:c,stoppingAgents:S})})}const Re=3e3;function on(e,o,r,u=Date.now){const y=s.useRef(null),i=s.useRef(new Map),d=s.useRef(new Map),w=y.current,R=i.current,x=d.current,p=u();for(const f of e){if(x.has(f.id))continue;if(w===null){x.set(f.id,"at-rest");continue}const v=R.get(f.authorId);x.set(f.id,v!==void 0&&p-v<Re?"handed-off":"dropped")}return s.useEffect(()=>{if(!r)return;y.current=new Set(e.map(v=>v.id));const f=u();for(const v of o)i.current.set(v,f);for(const[v,I]of i.current)f-I>Re&&i.current.delete(v);for(const v of d.current.keys())y.current.has(v)||d.current.delete(v)}),x}function an({kind:e}){return e==="thread-error"?t.jsxs("div",{"data-slot":"thread-notice","data-testid":"room-thread-error",className:"text-muted-foreground flex flex-col items-center gap-2 px-[var(--msg-padding-x)] py-6 text-center text-sm",children:[t.jsx("p",{className:"text-foreground font-medium",children:"Couldn’t load this thread"}),t.jsx("p",{className:"max-w-sm text-xs",children:"Nothing was lost. Reload to try again."})]}):e==="thread-waiting"?t.jsxs("div",{"data-slot":"thread-notice",className:"flex flex-col gap-2 px-[var(--msg-padding-x)]",children:[t.jsx(Q,{className:"h-3 w-24"}),t.jsx(Q,{className:"h-3 w-full max-w-sm"})]}):t.jsx("p",{"data-slot":"thread-notice","data-testid":"room-thread-orphan",className:"text-muted-foreground border-b px-[var(--msg-padding-x)] pb-3 text-xs italic",children:"This thread’s first message is gone. Its replies remain."})}function dn({room:e,rootEntryId:o,focusComposer:r,entries:u,reactionFrequents:y,streamStalled:i,streamUnavailable:d,onRetryStream:w,historyLoaded:R,historyFailed:x=!1,landOnRow:p,pushed:f,onClose:v}){const I=s.useMemo(()=>le(e.members,e.formerAuthors),[e.members,e.formerAuthors]),k=Me({room:e,threadRootId:o}),A=Ie(e.members,e.viewerAuthorId),j=ue(),S=s.useMemo(()=>new Map([...I].map(([n,m])=>[n,m.displayName])),[I]),{root:l,replies:c}=s.useMemo(()=>{let n;const m=[];for(const b of u)b.id===o?n=b:ce(b)===o&&m.push(b);return{root:n,replies:m}},[u,o]),C=l==null?void 0:l.threadReplyCount,N=C!==void 0&&C>c.length,E=!f,P=l===void 0||N?-1:(E?1:0)+c.length,T=Ne(c.length,C),M=s.useMemo(()=>new Set(c.map(n=>n.id)),[c]),L=s.useMemo(()=>({replyIds:M,inside:!0}),[M]),H=at(e.id,L),D=ke(e.id,o),F=on(c,H,R),q=s.useRef(null),z=s.useCallback(n=>{var m;(m=q.current)==null||m.scrollToRow(n)},[]),$=s.useRef(null);s.useEffect(()=>{var n;r||(n=$.current)==null||n.focus()},[o,r]);const K=n=>{n.key!=="Escape"||n.defaultPrevented||(n.stopPropagation(),v())},O=s.useMemo(()=>{const n=[];if(l===void 0){const m=x?"thread-error":R?"thread-orphan":"thread-waiting";n.push({kind:"notice",id:m,at:"",body:null})}else E&&n.push({kind:"message",id:l.id,payload:l,grouping:{position:"only"},author:G(V(l,I),I,j.faces),at:l.createdAt});for(const m of c)n.push({kind:"message",id:m.id,payload:m,grouping:{position:"only"},author:G(V(m,I),I,j.faces),at:m.createdAt});return n},[l,E,c,I,j.faces,x,R]),W=s.useCallback(n=>{if(n.kind==="notice")return t.jsx(an,{kind:n.id});if(n.kind!=="message")return null;const m=n.payload,b=l!==void 0&&m.id===l.id,a=c.findIndex(_=>_.id===m.id),h=t.jsx(oe,{roomId:e.id,entry:m,rowId:J(m.id),author:n.author,authorRef:I.get(m.authorId),authors:I,viewerAuthorId:e.viewerAuthorId,authorNames:S,reactionFrequents:y,streamStalled:i,isMember:A,grouping:{position:"only"},answers:Ae(m,a<=0?l:c[a-1],_=>(l==null?void 0:l.id)===_?l:c.find(Z=>Z.id===_)),feedPosition:{index:b?1:(l===void 0||!E?0:1)+a+1,total:P}});if(b)return t.jsxs(t.Fragment,{children:[h,t.jsx(ye,{count:T})]});const g=F.get(m.id)??"at-rest";return t.jsx("div",{className:ee(g==="dropped"&&"motion-safe:animate-thread-reply-in",g==="handed-off"&&"motion-safe:animate-reply-settle"),children:h})},[l,E,c,T,F,e.id,e.viewerAuthorId,I,S,y,i,A,P]),B=s.useCallback(n=>n.kind==="message"?J(n.id):void 0,[]);return t.jsx(Se,{known:j,children:t.jsx(X.Root,{surface:"room",capabilities:fe,target:k.target,anchor:"rail",children:t.jsxs("section",{ref:$,"aria-label":"Thread","data-testid":"room-thread-panel",tabIndex:-1,onKeyDown:K,className:ee("bg-card flex min-h-0 flex-col outline-none",f?"h-full w-full":"w-full border-l"),children:[f?t.jsxs("header",{className:"flex items-center gap-2 border-b px-1 py-1",children:[t.jsxs("button",{type:"button",onClick:v,"aria-label":`Back to ${Y(e)}`,"data-testid":"room-thread-back",className:"focus-ring text-muted-foreground hover:text-foreground flex h-11 min-w-0 items-center gap-1 rounded px-2 text-sm",children:[t.jsx(it,{"aria-hidden":!0,className:"size-4 shrink-0"}),t.jsx("span",{className:"truncate",children:Y(e)})]}),t.jsx("p",{className:"ml-auto shrink-0 pr-3 text-sm font-medium",children:"Thread"})]}):t.jsxs("header",{className:"flex items-center gap-2 border-b px-3 py-2",children:[t.jsx("button",{type:"button",onClick:v,"aria-label":"Close thread",className:"focus-ring text-muted-foreground hover:text-foreground relative -ml-1 rounded p-1",children:t.jsx(dt,{"aria-hidden":!0,className:"size-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Thread"}),t.jsx("p",{className:"text-muted-foreground truncate text-xs",children:Y(e)})]})]}),f&&l!==void 0&&t.jsxs("div",{"data-testid":"room-thread-pinned-root",className:"max-h-[40%] shrink-0 overflow-y-auto border-b pt-2",children:[t.jsx(oe,{roomId:e.id,entry:l,rowId:J(l.id),author:G(V(l,I),I,j.faces),authorRef:I.get(l.authorId),authors:I,viewerAuthorId:e.viewerAuthorId,authorNames:S,reactionFrequents:y,streamStalled:i,isMember:A,grouping:{position:"only"}}),t.jsx(ye,{count:T})]}),t.jsx(X.Timeline,{ref:q,conversationId:`thread-${o}`,label:`Thread in ${Y(e)}`,busy:!R&&!x,rows:O,renderRow:W,domIdOf:B,...p===void 0?{}:{landOnRow:p},pending:D,viewerAuthorId:e.viewerAuthorId,className:"py-3",feedTestId:"room-thread-feed"}),t.jsx(Pe,{room:e,entries:u,scope:L,laneScope:"thread",stalled:f&&i===!0,unavailable:d,onRetry:f?w:void 0,onScrollToRow:z}),t.jsx(Te,{room:e,threadRootId:o,attachments:k.attachments,focusOnMount:r},o)]})})})}function ye({count:e}){return e===0?null:t.jsxs("div",{"aria-hidden":!0,"data-testid":"room-thread-divider",className:"flex items-center gap-2 px-[var(--msg-padding-x)] pt-1 pb-2",children:[t.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:e===1?"1 reply":`${e} replies`}),t.jsx("span",{className:"bg-border h-px flex-1"})]})}const ln=96,un=500;function cn(e){return e.offset.x>ln||e.velocity.x>un}function fn({children:e,onClose:o}){const r=lt()===!0,u=r?{x:0}:{x:"100%"};return t.jsx(ut.div,{"data-testid":"room-thread-sheet",className:"bg-card absolute inset-0 z-10 flex flex-col shadow-xl",initial:u,animate:{x:0},exit:u,transition:r?{duration:0}:{duration:.22,ease:[.32,.72,0,1]},drag:"x",dragDirectionLock:!0,dragConstraints:{left:0,right:0},dragElastic:{left:0,right:.9},dragMomentum:!1,onDragEnd:(y,i)=>{cn(i)&&o()},children:e})}const te="room-thread-split",mn=320,hn=360,pn=40,gn=50,xn=25;function ve(e,o){return o<=0?xn:Math.min(Math.round(e/o*1e3)/10,gn)}function Rn(e){const o=ve(mn,e),r=Math.round((100-ve(hn,e))*10)/10;return{minPct:o,maxPct:r,defaultPct:Math.min(Math.max(pn,o),r)}}function yn(e,o,r){if(e===null||o===null||o<=0)return r.defaultPct;const u=e/o*100;return Math.round(Math.min(Math.max(u,r.minPct),r.maxPct)*10)/10}function vn(e){try{const o=localStorage.getItem(e),r=o===null?NaN:Number(o);return Number.isFinite(r)&&r>0?r:null}catch{return null}}function bn(e,o){try{localStorage.setItem(e,String(Math.round(o)))}catch{}}const jn="react-resizable-panels:room-thread-split";function wn(){try{localStorage.removeItem(jn)}catch{}}function In(){const[e,o]=s.useState(null),[r,u]=s.useState(null);return{ref:s.useCallback(i=>{if(i===null)return;o(i);const d=()=>u(i.offsetWidth);d();const w=new ResizeObserver(d);return w.observe(i),()=>{w.disconnect(),o(null),u(null)}},[]),element:e,width:r,sizing:Rn(r??0)}}const kn=`${te}-room`,be=`${te}-thread`,je=`${te}-handle`,An=4;function Nn({room:e,thread:o,storageKey:r=ft.ROOM_THREAD_WIDTH}){const{ref:u,element:y,width:i,sizing:d}=In(),[w,R]=s.useState(()=>vn(r)),[x,p]=s.useState(null),f=s.useRef(null),v=yn(w,i,d),I=i===null||(d.maxPct-d.minPct)/100*i<An,k=o!==!1;s.useEffect(wn,[]);const A=s.useRef(!1);s.useLayoutEffect(()=>{var c;A.current&&((c=f.current)==null||c.resize(v))},[v,k]);const j=s.useRef(null),S=()=>{var E;const c=(E=f.current)==null?void 0:E.getSize(),C=j.current;if(j.current=null,c===void 0||i===null||i<=0||C===c)return;const N=Math.round(c/100*i);R(N),bn(r,N)},l=x??v;return s.useLayoutEffect(()=>{const c=y==null?void 0:y.querySelector(`[data-panel-resize-handle-id="${je}"]`);c&&(c.setAttribute("aria-controls",be),c.setAttribute("aria-valuenow",String(Math.round(l))),c.setAttribute("aria-valuemin",String(Math.round(d.minPct))),c.setAttribute("aria-valuemax",String(Math.round(d.maxPct))))}),t.jsx("div",{ref:u,className:"h-full overflow-hidden",children:t.jsxs(ct,{direction:"horizontal",id:te,onLayout:c=>{A.current=c.length>1,p(A.current?c[1]:null)},children:[t.jsx(pe,{id:kn,order:1,className:"flex",children:e}),k&&t.jsxs(t.Fragment,{children:[t.jsx(yt,{id:je,"aria-label":"Resize thread","data-testid":"room-thread-resize-handle",disabled:I,onDragging:c=>{var C;c&&(j.current=((C=f.current)==null?void 0:C.getSize())??null)},onKeyDownCapture:c=>{var C,N;I||(j.current=((C=f.current)==null?void 0:C.getSize())??null,!(c.key!=="Home"&&c.key!=="End")&&(c.preventDefault(),(N=f.current)==null||N.resize(c.key==="Home"?d.minPct:d.maxPct)))},onResizeEnd:S}),t.jsx(pe,{ref:f,id:be,order:2,defaultSize:v,minSize:d.minPct,maxSize:d.maxPct,className:"flex",children:o})]})]})})}function Dn({roomId:e,threadId:o,entrySeq:r,threadRoute:u,aboveTimeline:y,aboveComposer:i,offerJumpBackIn:d,onComposerFocusChange:w}){const R=mt(),x=vt(),p=ht(e),f=p==null?void 0:p.rootEntryId,v=Vt(),I=s.useCallback(()=>{var m;const n=(m=U.getState().open[e])==null?void 0:m.rootEntryId;U.getState().closeThread(e),n!==void 0&&v.arm(n)},[e,v]),k=s.useCallback(n=>{U.getState().openThread(e,n)},[e]),A=pt(e),j=gt(e),S=wt(e,j.isSuccess);It(e);const l=A.data,c=s.useMemo(()=>j.data??[],[j.data]),C=Me({room:l});Zt({roomId:e,route:u,urlThreadId:o,openThreadId:f,entries:c,historyLoaded:j.isSuccess});const N=s.useMemo(()=>{var n;return((n=l==null?void 0:l.members.find(m=>m.author.id===l.viewerAuthorId))==null?void 0:n.lastReadSeq)??null},[l]),E=Xt(e,N);xt(l,c);const P=s.useRef(null),T=s.useRef(void 0),M=s.useCallback(n=>{T.current=n},[]),L=s.useCallback(()=>T.current,[]);s.useLayoutEffect(()=>{T.current=void 0},[e]);const H=s.useCallback(n=>{var m;(m=P.current)==null||m.scrollToRow(n)},[]),D=qt(e),{loadOlder:F,cursor:q}=D,z=s.useCallback(()=>{const n=Ct(c,q);F().then(()=>{n!==null&&requestAnimationFrame(()=>{var m;return(m=P.current)==null?void 0:m.scrollToRow(n.domId)})})},[c,q,F]),$=Ut({roomId:e,entrySeq:r,entries:c,historyLoaded:j.isSuccess}),K=s.useMemo(()=>f===void 0?void 0:{replyIds:new Set(c.filter(m=>ce(m)===f).map(m=>m.id)),inside:!1},[c,f]);if(A.isLoading)return t.jsx("div",{className:"flex h-full flex-col","aria-busy":!0,children:t.jsx(Ee,{})});if(A.isError||!l)return t.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-2 p-10 text-center text-sm",children:[t.jsx("p",{className:"text-foreground font-medium",children:"That channel or DM isn’t here"}),t.jsx("p",{className:"max-w-sm",children:"It may be archived, or the link is old."})]});const O=p!==void 0&&t.jsx(dn,{room:l,rootEntryId:p.rootEntryId,focusComposer:p.focusComposer,entries:c,reactionFrequents:l.reactionFrequents,streamStalled:S.stalled,streamUnavailable:S.unavailable,onRetryStream:S.retry,historyLoaded:j.isSuccess,historyFailed:j.isError,...$.threadRow===void 0?{}:{landOnRow:$.threadRow},pushed:R,onClose:I},p.rootEntryId),W=t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[y,t.jsx(Gt,{ref:P,roomId:l.id,roomName:Y(l),viewerAuthorId:l.viewerAuthorId,entries:c,members:l.members,formerAuthors:l.formerAuthors,lastReadSeq:E,reactionFrequents:l.reactionFrequents,streamStalled:S.stalled,isLoading:j.isLoading,error:j.error,onAddAgents:()=>ge("add",l.id),openThreadId:f,onOpenThread:k,resumeRow:L,...$.roomRow===void 0?{}:{landOnRow:$.roomRow},onTopRow:M,canLoadOlder:D.canLoadOlder,isLoadingOlder:D.isLoadingOlder,onLoadOlder:z}),i,t.jsx(tn,{roomId:l.id}),t.jsx(nn,{roomId:l.id}),t.jsx(Pe,{room:l,entries:c,scope:K,laneScope:"room",stalled:S.stalled,unavailable:S.unavailable,onRetry:S.retry,onScrollToRow:H}),t.jsx(en,{room:l,hasEntries:c.length>0,onAddAgents:()=>ge("add",l.id)}),t.jsx(Te,{room:l,attachments:C.attachments,offerJumpBackIn:d,onFocusChange:w},l.id)]}),B={surface:"room",capabilities:fe,target:C.target,anchor:"rail"};return R?t.jsx(X.Root,{...B,children:t.jsx("div",{style:{paddingBottom:x},"data-testid":"room-surface",className:"flex h-full flex-col overflow-hidden",children:t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:[t.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",inert:O!==!1,"data-testid":"room-under-thread",children:W}),t.jsx(Rt,{initial:!1,children:O!==!1&&t.jsx(fn,{onClose:I,children:O},`thread-${f}`)})]})})}):t.jsx(X.Root,{...B,children:t.jsx(Nn,{room:W,thread:O})})}export{Dn as R,$t as T,Ee as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as d,i as l,j as e,e as m,k as u,C as c,l as x,n as h,H as f}from"./index-
|
|
1
|
+
import{h as d,i as l,j as e,e as m,k as u,C as c,l as x,n as h,H as f}from"./index-fge85Gub.js";function g({kind:s}){const r="text-muted-foreground size-3.5 shrink-0";return s==="dm"?e.jsx(h,{"aria-hidden":!0,className:r}):e.jsx(f,{"aria-hidden":!0,className:r})}function p(s){return s===1?"1 member":`${s} members`}function N({member:s}){var i;const r=d(),n=l(s.id);if(n.isPending)return e.jsx(m,{className:"h-16 w-full"});if(n.isError)return e.jsx("p",{className:"text-muted-foreground text-sm",children:"Couldn’t read this member’s rooms."});const a=((i=n.data)==null?void 0:i.rooms)??[];return a.length===0?e.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.isSelf?"You aren’t":`${s.displayName} isn’t`," in any rooms yet."]}):e.jsx("div",{className:"flex flex-col",children:a.map(t=>{const o=e.jsxs(e.Fragment,{children:[e.jsx(g,{kind:t.kind}),e.jsx("span",{className:"min-w-0 truncate text-sm",children:u({kind:t.kind,slug:t.slug,title:t.name})}),e.jsx("span",{className:"text-muted-foreground ml-auto shrink-0 text-xs",children:p(t.memberCount)})]});return r?e.jsxs("button",{type:"button","data-slot":"profile-room-row",onClick:()=>void r({...x.channels(),search:{id:t.id}}),className:"focus-ring hover:bg-muted/50 flex h-9 items-center gap-2 rounded-md px-2 text-left transition-colors",children:[o,e.jsx(c,{"aria-hidden":!0,className:"text-muted-foreground/70 size-3.5 shrink-0"})]},t.id):e.jsx("div",{"data-slot":"profile-room-row",className:"flex h-9 items-center gap-2 rounded-md px-2",children:o},t.id)})})}export{N as RoomsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as D,j as e,a0 as ye,by as Ee,ar as we,G as N,e8 as de,bz as ue,bA as fe,bB as me,bD as xe,e9 as Ae,a1 as Te,a3 as ke,a4 as De,ad as pe,aN as Le,ea as he,eb as Oe,ec as Ie,ed as Pe,a8 as j,ee as _e,ef as H,eg as Ue,am as be,B as $e,U as Re,b as He,e as Me,eh as Be,ei as ze,ej as Ke,ek as qe,el as Qe,em as Ve}from"./index-B6Scr7KJ.js";import{C as ce}from"./runtime-connect-Dn0T5YWv.js";import{a as Fe,d as Ge,k as We,e as k}from"./execution-config-Bej0Ot8e.js";import{U as Xe}from"./unverified-catalog-notice-6pwZtIjx.js";import{s as Ye}from"./settings-for-runtime-BoOa-ZFG.js";const Je={duration:.12,ease:"easeOut"},Ze={type:"spring",stiffness:320,damping:28};function ge({isSetHere:a,serverDefault:l,onUseServerDefault:d,warning:r,className:s,"data-testid":i}){const[u,f]=D.useState(!1),o=a?"Set here":`Server default · ${l??"none"}`,n=a&&!!d,x=e.jsxs("span",{className:N("text-3xs inline-flex h-5 items-center gap-1 rounded-full px-2 leading-none whitespace-nowrap",r?de.warning:de.neutral,n&&"hover:bg-accent hover:text-accent-foreground transition-colors",s),"data-testid":i,children:[r&&e.jsx(ye,{className:"size-2.5 shrink-0","aria-hidden":!0}),e.jsx(Ee,{mode:"wait",initial:!1,children:e.jsx(we.span,{initial:{opacity:0,y:2},animate:{opacity:1,y:0,transition:Ze},exit:{opacity:0},transition:Je,children:o},o)})]});return n?e.jsxs(ue,{open:u,onOpenChange:f,children:[e.jsx(fe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Set here${r?`: ${r}`:""}`,children:x})}),e.jsxs(me,{className:"w-64 p-2",align:"start",children:[e.jsx(xe,{children:"Where this value comes from"}),r&&e.jsx("p",{className:N("px-2 pt-1 text-xs",Ae.warning),children:r}),e.jsxs("button",{type:"button",onClick:()=>{d(),f(!1)},className:"hover:bg-accent mt-1 w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors","data-testid":i?`${i}-reset`:void 0,children:["Use server default",l?e.jsxs("span",{className:"text-muted-foreground block text-xs",children:["Currently ",l]}):e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Not set. Uses the built-in default."})]})]})]}):r?e.jsx("span",{title:r,"aria-label":`${o}: ${r}`,children:x}):x}const et=["agents"];function tt(a){const l=Te(),d=ke();return De({...a!=null&&a.errorLabel?{meta:{errorLabel:a.errorLabel}}:{},mutationFn:r=>l.updateMeshAgent(r.id,r.updates),onSuccess:()=>{d.invalidateQueries({queryKey:["mesh","agents"]})},onSettled:()=>{d.invalidateQueries({queryKey:et})}})}const ve="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function $({label:a,valueLabel:l,options:d,selected:r,isSetHere:s,serverDefault:i,warning:u,onSelect:f,onInherit:o,testId:n,showHeader:x=!0,className:C,describedBy:m,inheritText:L}){const w=pe(),[S,h]=D.useState(!1);return e.jsxs("div",{className:N("space-y-1",C),children:[x&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ve,children:a}),!w&&e.jsx(ge,{isSetHere:s,serverDefault:i,warning:u,onUseServerDefault:o,"data-testid":`${n}-chip`})]}),e.jsxs(ue,{open:S,onOpenChange:h,children:[e.jsx(fe,{asChild:!0,children:e.jsxs("button",{type:"button",className:"border-input hover:bg-accent flex h-8 w-full items-center gap-1 rounded-md border px-2 text-sm transition-colors",...m?{"aria-describedby":m}:{},"data-testid":n,children:[e.jsx("span",{className:N("truncate",u?"text-status-warning-fg":s?"md:text-foreground text-status-warning-fg":"md:text-foreground text-status-success-fg"),children:l}),e.jsx(Re,{className:"text-muted-foreground ml-auto size-3.5 shrink-0"})]})}),e.jsxs(me,{className:"w-64 p-1",align:"start",children:[e.jsx(xe,{children:a}),e.jsx("div",{className:"max-h-72 overflow-y-auto",children:d.map(c=>e.jsxs("button",{type:"button","data-testid":`${n}-option-${c.value}`,onClick:()=>{f(c.value),h(!1)},className:N("hover:bg-accent w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors",c.value===r&&"bg-accent"),children:[c.label,c.hint&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:c.hint})]},c.value))}),e.jsx("button",{type:"button",onClick:()=>{o(),h(!1)},className:"hover:bg-accent border-border text-muted-foreground mt-1 w-full border-t px-2 py-2 text-left text-xs transition-colors","data-testid":`${n}-inherit`,children:L??(i?`Use server default: ${i}`:"Use server default")})]})]})]})}function st({agent:a,onUpdate:l,className:d}){var ee,te,se,ae,ne,le,oe,re,ie;const r=pe(),{data:s}=Le(),{data:i,isPending:u}=he(),f=((ee=s==null?void 0:s.executionDefaults)==null?void 0:ee.runtime)??"claude-code",o=a.runtime??f,n=(te=s==null?void 0:s.executionDefaults)==null?void 0:te.perRuntime.find(t=>t.runtime===o),{data:x}=Oe(),C=Fe(a,{defaultRuntime:f,runtimeDeclaresCredits:t=>{var b;return((b=i==null?void 0:i.capabilities[t])==null?void 0:b.credits)!==void 0},credits:(se=s==null?void 0:s.claudeCode)==null?void 0:se.credits,runtimeDefaultsToCredits:t=>{var b,T;return((T=(b=x==null?void 0:x.defaults)==null?void 0:b[t])==null?void 0:T.runsOn)==="credits"}}),{data:m,isError:L}=Ie({runtime:o,...C?{account:j}:{}}),w=a.model!=null,S=a.effort!=null,h=(n==null?void 0:n.model)??null,c=C&&(m??[]).some(t=>t.paidFromCredits),y=c?(m??[]).find(t=>t.isDefault):void 0,A=a.model??h??(y==null?void 0:y.value)??null,M=o==="doe"&&c&&!w&&!h,p=A?(m??[]).find(t=>t.value===A):void 0,O=(n==null?void 0:n.supportsEffort)??((ae=Ye(i,o))==null?void 0:ae.supportsEffort),B=O===void 0&&u,z=O!==!1,K=p?p.supportsEffort??!1:void 0,q=(ne=s==null?void 0:s.claudeCode)==null?void 0:ne.accounts,{nameFor:Q,creditsEntry:je,resolvedAccount:V}=Pe(),F=je??(a.account===j&&((le=s==null?void 0:s.claudeCode)!=null&&le.credits)?{path:s.claudeCode.credits.path}:null),g=q&&[...q.flatMap(t=>t.id===null?[]:[{id:t.id,label:Q(t.path),path:t.path}]),...F?[{id:j,label:_e,path:F.path}]:[]],v=a.account??null,G=v!==null,W=o==="claude-code"&&v===j&&((oe=s==null?void 0:s.claudeCode)==null?void 0:oe.credits)!==void 0&&!s.claudeCode.credits.allowedAgents.includes(a.id),I=s!=null&&s.claudeCode&&V?Q(V):null,P=tt({errorLabel:"Couldn’t change this agent’s account"}),_=D.useCallback(t=>{P.mutate({id:a.id,updates:{account:t}})},[a.id,P]),Ne=Ge({agent:{runtime:a.runtime,model:a.model,effort:a.effort,account:a.account},defaultRuntime:f,serverDefaultModel:h,knownModels:We(m),knownAccounts:g,accountsUnavailable:(re=s==null?void 0:s.claudeCode)==null?void 0:re.accountsUnavailable,modelSupportsEffort:K,runtimeSupportsEffort:O,runtimeLabel:t=>H(t).label}),E=t=>{var b;return((b=Ne.breakages.find(T=>t.includes(T.kind)))==null?void 0:b.message)??null},U=!B&&z&&K!==!1,X=a.effort??(n==null?void 0:n.effort)??null,Y=H(o).label,Ce=o==="claude-code"&&g!==void 0&&(g.length>1||G),Se=E(["account-unregistered"]),J=(m??[]).some(t=>t.unverified),Z=D.useId();return e.jsxs("div",{className:N("grid grid-cols-2 gap-3",d),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{label:"Model",valueLabel:M?ce:(p==null?void 0:p.displayName)??A??(c?"Default":"Automatic"),options:[...(m??[]).map(t=>({value:t.value,label:t.displayName,hint:t.description}))],selected:A,isSetHere:w,serverDefault:(n==null?void 0:n.model)??null,warning:E(["model-unavailable"]),onSelect:t=>l({model:t}),onInherit:()=>l({model:null}),testId:"agent-model-row",describedBy:J?Z:void 0,inheritText:M?ce:c&&!h?y?`Use the suggested model: ${y.displayName}`:"Use the default model":void 0}),J&&e.jsx(Xe,{id:Z}),c&&(m??[]).some(t=>t.creditsListOutOfDate)&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-out-of-date",children:"The models your DorkOS credits cover may be out of date."}),C&&L&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-unavailable",children:"Couldn’t load the models DorkOS credits cover. Try again in a moment."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ve,children:"Effort"}),(!r||!U)&&(S||U)&&e.jsx(ge,{isSetHere:S,serverDefault:n!=null&&n.effort?k(n.effort):null,warning:E(["effort-unsupported-runtime","effort-unsupported-model"]),onUseServerDefault:()=>l({effort:null}),"data-testid":"agent-effort-row-chip"})]}),B?e.jsx(R,{testId:"agent-effort-pending",text:`Checking what ${Y} supports`,warning:null}):z?U?e.jsx($,{label:"Effort",valueLabel:k(X),options:Ue.filter(t=>!(p!=null&&p.supportedEffortLevels)||p.supportedEffortLevels.includes(t)).map(t=>({value:t,label:k(t)})),selected:X,isSetHere:S,serverDefault:n!=null&&n.effort?k(n.effort):null,warning:null,showHeader:!1,onSelect:t=>l({effort:t}),onInherit:()=>l({effort:null}),testId:"agent-effort-row"}):e.jsx(R,{testId:"agent-effort-unsupported-model",text:"This model doesn’t take an effort setting",warning:E(["effort-unsupported-model"])}):e.jsx(R,{testId:"agent-effort-unsupported-runtime",text:`Not supported by ${Y}`,warning:E(["effort-unsupported-runtime"])})]}),Ce&&e.jsx($,{label:"Account",valueLabel:W?I??"Default":v!==null?((ie=g==null?void 0:g.find(t=>t.id===v))==null?void 0:ie.label)??v:I??"Default",options:(g??[]).map(t=>({value:t.id,label:t.label,hint:t.id===j?"Paid from your DorkOS account":be(t.path)})),selected:v,isSetHere:G,serverDefault:I,warning:Se,onSelect:t=>_(t),onInherit:()=>_(null),testId:"agent-account-row",className:"col-span-full"}),W&&e.jsxs("div",{className:"text-muted-foreground col-span-full flex flex-wrap items-center gap-2 text-xs","data-testid":"agent-credits-not-allowed",children:[e.jsx("span",{children:"This agent’s settings name DorkOS credits. It uses your default until you allow it."}),e.jsx($e,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",disabled:P.isPending,onClick:()=>_(j),children:"Allow"})]})]})}function R({text:a,warning:l,testId:d}){return e.jsxs("div",{className:"flex h-8 flex-col justify-center","data-testid":d,children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:a}),l&&e.jsx("p",{className:"text-status-warning-fg text-xs",children:l})]})}const at="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function dt({member:a}){const{agent:l,projectPath:d,isPending:r,update:s}=He(a),{data:i}=he();if(r)return e.jsx(Me,{className:"h-24 w-full"});if(!l)return e.jsx("p",{className:"text-muted-foreground p-1 text-sm",children:"Couldn’t read this agent’s settings."});const u=i?Object.keys(i.capabilities):[l.runtime],f=u.includes(l.runtime)?u:[l.runtime,...u];return e.jsxs("div",{className:"space-y-3 p-1","data-slot":"profile-runs-on",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:at,children:"Runs on"}),e.jsxs(Be,{value:l.runtime??"claude-code",onValueChange:o=>s({runtime:o}),children:[e.jsx(ze,{className:"h-8 text-sm",responsive:!1,children:e.jsx(Ke,{})}),e.jsx(qe,{children:f.map(o=>e.jsx(Qe,{value:o,responsive:!1,children:H(o).label},o))})]})]}),e.jsx(st,{agent:l,onUpdate:s,className:"grid-cols-1"}),d&&e.jsxs("div",{className:"text-muted-foreground flex min-w-0 items-center gap-1.5",children:[e.jsx(Ve,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:be(d)})]})]})}export{dt as RunsOnPopover};
|
|
1
|
+
import{r as L,j as e,a0 as ye,bw as Ee,ap as we,G as N,e7 as de,bx as ue,by as fe,bz as me,bB as xe,e8 as ke,a1 as Te,a3 as Ae,a4 as Le,ab as pe,aL as Oe,e9 as he,ea as De,eb as Ie,ec as Pe,a6 as j,ed as _e,ee as H,ef as Ue,ak as be,B as $e,U as Re,b as He,e as Me,eg as Be,eh as ze,ei as Ke,ej as qe,ek as Qe,el as Ve}from"./index-fge85Gub.js";import{C as ce}from"./runtime-connect-Dn0T5YWv.js";import{a as Fe,d as Ge,k as We,e as A}from"./execution-config-D_PgYyCI.js";import{U as Xe}from"./unverified-catalog-notice-WMkPDdUp.js";import{s as Ye}from"./settings-for-runtime-BoOa-ZFG.js";const Je={duration:.12,ease:"easeOut"},Ze={type:"spring",stiffness:320,damping:28};function ge({isSetHere:a,serverDefault:l,onUseServerDefault:d,warning:r,className:s,"data-testid":i}){const[u,f]=L.useState(!1),o=a?"Set here":`Server default · ${l??"none"}`,n=a&&!!d,x=e.jsxs("span",{className:N("text-3xs inline-flex h-5 items-center gap-1 rounded-full px-2 leading-none whitespace-nowrap",r?de.warning:de.neutral,n&&"hover:bg-accent hover:text-accent-foreground transition-colors",s),"data-testid":i,children:[r&&e.jsx(ye,{className:"size-2.5 shrink-0","aria-hidden":!0}),e.jsx(Ee,{mode:"wait",initial:!1,children:e.jsx(we.span,{initial:{opacity:0,y:2},animate:{opacity:1,y:0,transition:Ze},exit:{opacity:0},transition:Je,children:o},o)})]});return n?e.jsxs(ue,{open:u,onOpenChange:f,children:[e.jsx(fe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Set here${r?`: ${r}`:""}`,children:x})}),e.jsxs(me,{className:"w-64 p-2",align:"start",children:[e.jsx(xe,{children:"Where this value comes from"}),r&&e.jsx("p",{className:N("px-2 pt-1 text-xs",ke.warning),children:r}),e.jsxs("button",{type:"button",onClick:()=>{d(),f(!1)},className:"hover:bg-accent mt-1 w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors","data-testid":i?`${i}-reset`:void 0,children:["Use server default",l?e.jsxs("span",{className:"text-muted-foreground block text-xs",children:["Currently ",l]}):e.jsx("span",{className:"text-muted-foreground block text-xs",children:"Not set. Uses the built-in default."})]})]})]}):r?e.jsx("span",{title:r,"aria-label":`${o}: ${r}`,children:x}):x}const et=["agents"];function tt(a){const l=Te(),d=Ae();return Le({...a!=null&&a.errorLabel?{meta:{errorLabel:a.errorLabel}}:{},mutationFn:r=>l.updateMeshAgent(r.id,r.updates),onSuccess:()=>{d.invalidateQueries({queryKey:["mesh","agents"]})},onSettled:()=>{d.invalidateQueries({queryKey:et})}})}const ve="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function $({label:a,valueLabel:l,options:d,selected:r,isSetHere:s,serverDefault:i,warning:u,onSelect:f,onInherit:o,testId:n,showHeader:x=!0,className:C,describedBy:m,inheritText:O}){const w=pe(),[S,h]=L.useState(!1);return e.jsxs("div",{className:N("space-y-1",C),children:[x&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ve,children:a}),!w&&e.jsx(ge,{isSetHere:s,serverDefault:i,warning:u,onUseServerDefault:o,"data-testid":`${n}-chip`})]}),e.jsxs(ue,{open:S,onOpenChange:h,children:[e.jsx(fe,{asChild:!0,children:e.jsxs("button",{type:"button",className:"border-input hover:bg-accent flex h-8 w-full items-center gap-1 rounded-md border px-2 text-sm transition-colors",...m?{"aria-describedby":m}:{},"data-testid":n,children:[e.jsx("span",{className:N("truncate",u?"text-status-warning-fg":s?"md:text-foreground text-status-warning-fg":"md:text-foreground text-status-success-fg"),children:l}),e.jsx(Re,{className:"text-muted-foreground ml-auto size-3.5 shrink-0"})]})}),e.jsxs(me,{className:"w-64 p-1",align:"start",children:[e.jsx(xe,{children:a}),e.jsx("div",{className:"max-h-72 overflow-y-auto",children:d.map(c=>e.jsxs("button",{type:"button","data-testid":`${n}-option-${c.value}`,onClick:()=>{f(c.value),h(!1)},className:N("hover:bg-accent w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors",c.value===r&&"bg-accent"),children:[c.label,c.hint&&e.jsx("span",{className:"text-muted-foreground block text-xs",children:c.hint})]},c.value))}),e.jsx("button",{type:"button",onClick:()=>{o(),h(!1)},className:"hover:bg-accent border-border text-muted-foreground mt-1 w-full border-t px-2 py-2 text-left text-xs transition-colors","data-testid":`${n}-inherit`,children:O??(i?`Use server default: ${i}`:"Use server default")})]})]})]})}function st({agent:a,onUpdate:l,className:d}){var ee,te,se,ae,ne,le,oe,re,ie;const r=pe(),{data:s}=Oe(),{data:i,isPending:u}=he(),f=((ee=s==null?void 0:s.executionDefaults)==null?void 0:ee.runtime)??"claude-code",o=a.runtime??f,n=(te=s==null?void 0:s.executionDefaults)==null?void 0:te.perRuntime.find(t=>t.runtime===o),{data:x}=De(),C=Fe(a,{defaultRuntime:f,runtimeDeclaresCredits:t=>{var b;return((b=i==null?void 0:i.capabilities[t])==null?void 0:b.credits)!==void 0},credits:(se=s==null?void 0:s.claudeCode)==null?void 0:se.credits,runtimeDefaultsToCredits:t=>{var b,T;return((T=(b=x==null?void 0:x.defaults)==null?void 0:b[t])==null?void 0:T.runsOn)==="credits"}}),{data:m,isError:O}=Ie({runtime:o,...C?{account:j}:{}}),w=a.model!=null,S=a.effort!=null,h=(n==null?void 0:n.model)??null,c=C&&(m??[]).some(t=>t.paidFromCredits),y=c?(m??[]).find(t=>t.isDefault):void 0,k=a.model??h??(y==null?void 0:y.value)??null,M=o==="doe"&&c&&!w&&!h,p=k?(m??[]).find(t=>t.value===k):void 0,D=(n==null?void 0:n.supportsEffort)??((ae=Ye(i,o))==null?void 0:ae.supportsEffort),B=D===void 0&&u,z=D!==!1,K=p?p.supportsEffort??!1:void 0,q=(ne=s==null?void 0:s.claudeCode)==null?void 0:ne.accounts,{nameFor:Q,creditsEntry:je,resolvedAccount:V}=Pe(),F=je??(a.account===j&&((le=s==null?void 0:s.claudeCode)!=null&&le.credits)?{path:s.claudeCode.credits.path}:null),g=q&&[...q.flatMap(t=>t.id===null?[]:[{id:t.id,label:Q(t.path),path:t.path}]),...F?[{id:j,label:_e,path:F.path}]:[]],v=a.account??null,G=v!==null,W=o==="claude-code"&&v===j&&((oe=s==null?void 0:s.claudeCode)==null?void 0:oe.credits)!==void 0&&!s.claudeCode.credits.allowedAgents.includes(a.id),I=s!=null&&s.claudeCode&&V?Q(V):null,P=tt({errorLabel:"Couldn’t change this agent’s account"}),_=L.useCallback(t=>{P.mutate({id:a.id,updates:{account:t}})},[a.id,P]),Ne=Ge({agent:{runtime:a.runtime,model:a.model,effort:a.effort,account:a.account},defaultRuntime:f,serverDefaultModel:h,knownModels:We(m),knownAccounts:g,accountsUnavailable:(re=s==null?void 0:s.claudeCode)==null?void 0:re.accountsUnavailable,modelSupportsEffort:K,runtimeSupportsEffort:D,runtimeLabel:t=>H(t).label}),E=t=>{var b;return((b=Ne.breakages.find(T=>t.includes(T.kind)))==null?void 0:b.message)??null},U=!B&&z&&K!==!1,X=a.effort??(n==null?void 0:n.effort)??null,Y=H(o).label,Ce=o==="claude-code"&&g!==void 0&&(g.length>1||G),Se=E(["account-unregistered"]),J=(m??[]).some(t=>t.unverified),Z=L.useId();return e.jsxs("div",{className:N("grid grid-cols-2 gap-3",d),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx($,{label:"Model",valueLabel:M?ce:(p==null?void 0:p.displayName)??k??(c?"Default":"Automatic"),options:[...(m??[]).map(t=>({value:t.value,label:t.displayName,hint:t.description}))],selected:k,isSetHere:w,serverDefault:(n==null?void 0:n.model)??null,warning:E(["model-unavailable"]),onSelect:t=>l({model:t}),onInherit:()=>l({model:null}),testId:"agent-model-row",describedBy:J?Z:void 0,inheritText:M?ce:c&&!h?y?`Use the suggested model: ${y.displayName}`:"Use the default model":void 0}),J&&e.jsx(Xe,{id:Z}),c&&(m??[]).some(t=>t.creditsListOutOfDate)&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-out-of-date",children:"The models your DorkOS credits cover may be out of date."}),C&&O&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"agent-credits-models-unavailable",children:"Couldn’t load the models DorkOS credits cover. Try again in a moment."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:ve,children:"Effort"}),(!r||!U)&&(S||U)&&e.jsx(ge,{isSetHere:S,serverDefault:n!=null&&n.effort?A(n.effort):null,warning:E(["effort-unsupported-runtime","effort-unsupported-model"]),onUseServerDefault:()=>l({effort:null}),"data-testid":"agent-effort-row-chip"})]}),B?e.jsx(R,{testId:"agent-effort-pending",text:`Checking what ${Y} supports`,warning:null}):z?U?e.jsx($,{label:"Effort",valueLabel:A(X),options:Ue.filter(t=>!(p!=null&&p.supportedEffortLevels)||p.supportedEffortLevels.includes(t)).map(t=>({value:t,label:A(t)})),selected:X,isSetHere:S,serverDefault:n!=null&&n.effort?A(n.effort):null,warning:null,showHeader:!1,onSelect:t=>l({effort:t}),onInherit:()=>l({effort:null}),testId:"agent-effort-row"}):e.jsx(R,{testId:"agent-effort-unsupported-model",text:"This model doesn’t take an effort setting",warning:E(["effort-unsupported-model"])}):e.jsx(R,{testId:"agent-effort-unsupported-runtime",text:`Not supported by ${Y}`,warning:E(["effort-unsupported-runtime"])})]}),Ce&&e.jsx($,{label:"Account",valueLabel:W?I??"Default":v!==null?((ie=g==null?void 0:g.find(t=>t.id===v))==null?void 0:ie.label)??v:I??"Default",options:(g??[]).map(t=>({value:t.id,label:t.label,hint:t.id===j?"Paid from your DorkOS account":be(t.path)})),selected:v,isSetHere:G,serverDefault:I,warning:Se,onSelect:t=>_(t),onInherit:()=>_(null),testId:"agent-account-row",className:"col-span-full"}),W&&e.jsxs("div",{className:"text-muted-foreground col-span-full flex flex-wrap items-center gap-2 text-xs","data-testid":"agent-credits-not-allowed",children:[e.jsx("span",{children:"This agent’s settings name DorkOS credits. It uses your default until you allow it."}),e.jsx($e,{size:"sm",variant:"outline",className:"h-6 px-2 text-xs",disabled:P.isPending,onClick:()=>_(j),children:"Allow"})]})]})}function R({text:a,warning:l,testId:d}){return e.jsxs("div",{className:"flex h-8 flex-col justify-center","data-testid":d,children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:a}),l&&e.jsx("p",{className:"text-status-warning-fg text-xs",children:l})]})}const at="text-muted-foreground text-3xs font-medium tracking-wider uppercase";function dt({member:a}){const{agent:l,projectPath:d,isPending:r,update:s}=He(a),{data:i}=he();if(r)return e.jsx(Me,{className:"h-24 w-full"});if(!l)return e.jsx("p",{className:"text-muted-foreground p-1 text-sm",children:"Couldn’t read this agent’s settings."});const u=i?Object.keys(i.capabilities):[l.runtime],f=u.includes(l.runtime)?u:[l.runtime,...u];return e.jsxs("div",{className:"space-y-3 p-1","data-slot":"profile-runs-on",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:at,children:"Runs on"}),e.jsxs(Be,{value:l.runtime??"claude-code",onValueChange:o=>s({runtime:o}),children:[e.jsx(ze,{className:"h-8 text-sm",responsive:!1,children:e.jsx(Ke,{})}),e.jsx(qe,{children:f.map(o=>e.jsx(Qe,{value:o,responsive:!1,children:H(o).label},o))})]})]}),e.jsx(st,{agent:l,onUpdate:s,className:"grid-cols-1"}),d&&e.jsxs("div",{className:"text-muted-foreground flex min-w-0 items-center gap-1.5",children:[e.jsx(Ve,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:be(d)})]})]})}export{dt as RunsOnPopover};
|
package/dist/client/assets/{RuntimeConnectFlow-D3H5Fpkc.js → RuntimeConnectFlow-B0TIITVq.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aN as Ee,a1 as b,a3 as D,r as x,a4 as R,jN as F,jO as T,jP as Be,a2 as z,j as e,jQ as Ge,ig as we,er as We,es as Y,Q as Re,T as Ie,V as Le,B as C,hU as Ye,G as V,eQ as Ve,eb as He,jR as Je,jS as Xe,e4 as Ae,ar as te,x as de,by as Ze,J as ue,ef as me,eo as S,ep as ne,aI as es,jT as ss,I as _,jU as ts,jV as Ke,jW as ns,_ as De,fB as rs,eh as as,ei as is,ej as os,ek as ls,el as be,e7 as cs,C as ds,jX as us,jY as ms,jZ as xs,U as hs}from"./index-B6Scr7KJ.js";import{I as fs}from"./inline-code-BKPMIXZR.js";import{u as gs}from"./useMutationState-lbcdmnfE.js";import{O as ps,a as W}from"./runtime-connect-Dn0T5YWv.js";function ys(){var s;return((s=Ee().data)==null?void 0:s.isLocalCaller)!==!1}function St(){const s=Ee().data;return((s==null?void 0:s.onTrustedConnection)??(s==null?void 0:s.isLocalCaller))!==!1}function Ct(s){var u,d;const t=b(),n=D(),[i,a]=x.useState(null),r=R({mutationFn:()=>(a(null),t.provisionRuntime(s,m=>a(m))),onSuccess:m=>{m.ok&&(n.invalidateQueries({queryKey:[...F]}),n.invalidateQueries({queryKey:[...T]}))}}),l=r.isError||((u=r.data)==null?void 0:u.ok)===!1,o=r.isError?r.error.message:((d=r.data)==null?void 0:d.error)??null,c=(o==null?void 0:o.trim().toLowerCase())==="not found"?"One-click install isn’t available here.":o;return{provision:()=>r.mutate(),isPending:r.isPending,isError:l,errorMessage:l?c??"Couldn’t install. Try again.":null,progress:i,result:r.data}}function Te(s){return["runtime-key-status",s]}function js(s,t=!0){const n=b();return z({queryKey:Te(s),queryFn:()=>n.getRuntimeKeyStatus(s),enabled:t,staleTime:3e4})}function vs(s){const t=b(),n=R({mutationFn:a=>t.checkRuntimeCredential(s,a.trim().length>0?a:null),meta:{suppressErrorToast:!0}}),i=n.data??(n.isError?{ok:!1,reason:"unexpected",message:n.error.message||"Couldn’t check the key."}:null);return{check:a=>n.mutate(a),isPending:n.isPending,result:i,checkedSavedKey:i!==null&&(n.variables??"").trim().length===0,reset:n.reset}}function ks(s){var o,c,u;const t=b(),n=D(),[i,a]=x.useState(null),r=R({mutationFn:async d=>{a("checking");const m=await t.checkRuntimeCredential(s,d);return m.ok?(a("saving"),await t.storeRuntimeCredential(s,d),{saved:!0,message:null}):{saved:!1,message:m.message}},onSettled:()=>a(null),meta:{suppressErrorToast:!0},onSuccess:d=>{d.saved&&(n.invalidateQueries({queryKey:[...F]}),n.invalidateQueries({queryKey:[...T]}),n.invalidateQueries({queryKey:[...Te(s)]}))}}),l=((o=r.data)==null?void 0:o.saved)===!1;return{store:d=>{d.trim().length!==0&&r.mutate(d)},isPending:r.isPending,phase:i,isSuccess:((c=r.data)==null?void 0:c.saved)===!0,isError:r.isError||l,errorMessage:l?((u=r.data)==null?void 0:u.message)??null:r.isError?r.error.message??"Couldn’t save the API key.":null,reset:r.reset}}const Se=new WeakMap;function Ns(s){const t=Se.get(s);if(t)return t;const n=new Set;return Se.set(s,n),n}function bs(s,t){var M,I,w,P;const n=b(),i=D(),{sessionId:a,accountRoot:r,onCompleted:l}=t??{},o=x.useMemo(()=>["runtime-login",s,a??"",r??""],[s,a,r]),c=R({mutationKey:o,mutationFn:()=>n.delegateRuntimeLogin(s,a===void 0&&r===void 0?void 0:{sessionId:a,accountRoot:r}),onSuccess:N=>{N.ok&&(i.invalidateQueries({queryKey:Be.all}),i.invalidateQueries({queryKey:[...F]}),i.invalidateQueries({queryKey:[...T]}))}}),u=gs({filters:{mutationKey:o,exact:!0},select:N=>({id:N.mutationId,state:N.state})}),d=u.some(N=>N.state.status==="pending"),m=u[u.length-1],h=d||m==null?void 0:m.state,p=d||m==null?void 0:m.id,g=!d&&((h==null?void 0:h.status)==="error"||((M=h==null?void 0:h.data)==null?void 0:M.ok)===!1),y=(h==null?void 0:h.status)==="error"?((I=h.error)==null?void 0:I.message)??null:((w=h==null?void 0:h.data)==null?void 0:w.error)??null,v=((P=h==null?void 0:h.data)==null?void 0:P.ok)===!0,O=x.useRef(l);return O.current=l,x.useEffect(()=>{var L;if(!v||p===void 0)return;const N=Ns(i);N.has(p)||(N.add(p),(L=O.current)==null||L.call(O))},[v,p,i]),{login:()=>{d||c.mutate()},isPending:d,isSuccess:v,isError:g,errorMessage:g?y??"Couldn’t sign in. Try again.":null}}const Ce={"claude-code":{signInLabel:"Sign in",otherWayLabel:"Sign in with Claude",signInHint:"Use your Claude subscription or Anthropic account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"Anthropic API key",keyPlaceholder:"sk-ant-…",getKeyUrl:"https://console.anthropic.com/settings/keys"},codex:{signInLabel:"Sign in with ChatGPT",otherWayLabel:"Sign in with ChatGPT",signInHint:"Use your ChatGPT account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"OpenAI API key",keyPlaceholder:"sk-…",getKeyUrl:"https://platform.openai.com/api-keys"}};function Ss(s){return Ce[s]??Ce["claude-code"]}function Cs({command:s,infoUrl:t,copyLabel:n}){return!s&&!t?null:e.jsxs("div",{className:"space-y-2",children:[s&&e.jsxs("div",{className:"bg-muted flex items-center justify-between gap-2 rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(Ge,{className:"text-muted-foreground size-3.5 shrink-0"}),e.jsx("code",{className:"truncate text-xs",children:s})]}),e.jsx(we,{value:s,label:n??"Copy install command",className:"shrink-0"})]}),t&&e.jsxs(We,{href:t,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Learn more ",e.jsx(Y,{className:"size-3"})]})]})}function Ot({command:s,runtimeLabel:t}){const[n,i]=x.useState(!1);return e.jsxs(Re,{open:n,onOpenChange:i,className:"mt-2",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["DorkOS installs ",t," for you."," ",e.jsx(Ie,{className:"hover:text-foreground underline decoration-dotted underline-offset-2 transition-colors",children:n?"Hide command":"What runs?"})]}),e.jsxs(Le,{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx(fs,{children:s}),e.jsx(we,{value:s,label:`Copy command: ${s}`,className:"shrink-0"})]})]})}function Oe({onRetry:s}){return e.jsxs("div",{"data-testid":"remote-signin-notice",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Signing in needs the computer DorkOS runs on."}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:s?"Sign in to DorkOS there, then press Retry.":"Sign in to DorkOS there."}),e.jsx("p",{className:"text-muted-foreground/80 mt-2 text-xs",children:"Already on that computer? Open DorkOS at localhost instead."}),s&&e.jsxs(C,{variant:"outline",size:"sm",onClick:s,className:"mt-3 gap-1.5",children:[e.jsx(Ye,{className:"size-3"}),"Retry"]})]})}function Os({ollama:s=!1,remote:t=!1,className:n}){return e.jsxs("p",{className:V("text-muted-foreground text-xs",n),"data-testid":"keep-it-local-note",children:[t?"Prefer everything on the computer DorkOS runs on? Use your own sign-in there":"Prefer to keep everything on this computer? Use your own sign-in",s?", or Ollama":"","."]})}function Ps(s){const t=Ve(),{data:n}=He();return s?Je(Xe(t.data,s),n,s):"none"}const xe="OpenCode is connected",he="This chat uses OpenCode. Change models from the model menu.",Es={title:xe,body:`Frontier models are unlocked. ${he}`},ws={title:xe,body:he},Pe={title:xe,body:`Your local models are ready. ${he}`};function Me(s){return{title:`${s} is connected`,body:`This chat uses ${s}. Change models from the model menu.`}}function Rs(s){return{title:`${s} is ready`,body:`New work on ${s} runs on your DorkOS credits. Change it any time in Settings › Runtimes.`}}function A({message:s}){const t=Ae();return e.jsxs(te.div,{role:"status",className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:t?!1:{opacity:0},animate:{opacity:1},"data-testid":"connect-progress",children:[e.jsx(de,{size:"xs",className:V("text-muted-foreground shrink-0",t&&"animate-none")}),e.jsx(Ze,{mode:"wait",children:e.jsx(te.span,{className:"truncate text-xs",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:s},s)})]})}function U({message:s="Connected"}){return e.jsxs("div",{role:"status",className:"text-status-success-fg flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs","data-testid":"connect-connected",children:[e.jsx(ue,{className:"size-3.5"}),s]})}function Q({message:s,onRetry:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s}),e.jsx(C,{size:"sm",onClick:t,children:"Try again"})]})}function Is({type:s,onConnected:t,asOtherWay:n=!1}){const i=Ss(s),a=bs(s),[r,l]=x.useState(!1),o=x.useRef(!1);return x.useEffect(()=>{!a.isSuccess||o.current||(o.current=!0,t==null||t(Me(me(s).label)))},[a.isSuccess,t,s]),e.jsxs("div",{className:"space-y-4","data-testid":`login-connect-${s}`,children:[e.jsx("div",{className:"space-y-2",children:a.isPending?e.jsx(A,{message:i.signInPending}):a.isSuccess?e.jsx(U,{message:"Signed in"}):a.isError?e.jsx(Q,{message:a.errorMessage??"Couldn’t sign in.",onRetry:a.login}):e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm",variant:n?"outline":"default",className:"w-full",onClick:a.login,children:n?i.otherWayLabel:i.signInLabel}),e.jsx("p",{className:"text-muted-foreground text-xs",children:i.signInHint})]})}),r?e.jsxs("div",{className:"space-y-3","data-testid":`login-connect-key-${s}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"bg-border h-px flex-1"}),e.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),e.jsx("span",{className:"bg-border h-px flex-1"})]}),e.jsx(Ls,{type:s,copy:i,onConnected:t}),e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-muted-foreground hover:text-foreground text-xs underline decoration-dotted underline-offset-2 transition-colors",children:"Back to sign in"})]}):n?e.jsx(C,{size:"sm",variant:"outline",className:"w-full",onClick:()=>l(!0),"data-testid":`login-connect-use-key-${s}`,children:"Paste a key"}):e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-muted-foreground hover:text-foreground text-xs underline decoration-dotted underline-offset-2 transition-colors","data-testid":`login-connect-use-key-${s}`,children:"Use an API key instead"})]})}function Ls({type:s,copy:t,onConnected:n}){var g,y;const[i,a]=x.useState(""),r=ks(s),l=js(s),o=vs(s),c=x.useRef(!1),u=x.useRef(null);if(x.useEffect(()=>{!r.isSuccess||c.current||(c.current=!0,n==null||n(Me(me(s).label)))},[r.isSuccess,n,s]),x.useEffect(()=>{var v;r.isError&&((v=u.current)==null||v.focus())},[r.isError]),r.isSuccess)return e.jsx(U,{});const d=(g=l.data)!=null&&g.key.saved?l.data.key:null,m=i.trim().length>0,h=r.isPending||o.isPending,p=()=>{o.reset(),r.reset()};return e.jsxs("form",{className:"space-y-2",onSubmit:v=>{v.preventDefault(),o.reset(),r.store(i)},children:[e.jsx(S,{htmlFor:`api-key-${s}`,className:"text-xs",children:t.keyLabel}),e.jsx(ne,{id:`api-key-${s}`,ref:u,value:i,disabled:h,onChange:v=>{a(v.target.value),p()},placeholder:d?`Saved key ends in ${d.last4}. Paste to replace.`:t.keyPlaceholder,autoComplete:"off",spellCheck:!1}),r.isError&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:r.errorMessage}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.getKeyUrl?e.jsxs("a",{href:t.getKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an API key ",e.jsx(Y,{className:"size-3"})]}):e.jsx("span",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",size:"sm",variant:"ghost",disabled:!m&&d===null||h,"data-testid":`api-key-test-${s}`,onClick:()=>{r.reset(),o.reset(),o.check(i)},children:"Test key"}),e.jsx(C,{type:"submit",size:"sm",variant:"outline",disabled:!m||h,children:"Save key"})]})]}),h?e.jsx(A,{message:r.phase==="saving"?"Saving…":"Checking your key…"}):((y=o.result)==null?void 0:y.ok)===!0?e.jsx(U,{message:o.checkedSavedKey?"Your saved key works":"Key works"}):o.result?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:o.result.message}):null]})}function As(s){const t=b(),n=z({queryKey:["doe-inference"],queryFn:()=>t.getDoeInference()});return n.isPending?e.jsx(de,{"aria-label":"Loading model settings"}):n.isError?e.jsx("p",{role:"alert",children:"Couldn’t load model settings. Try again."}):e.jsx(Ks,{saved:n.data,...s},JSON.stringify(n.data))}function Ks({saved:s,onConnected:t,onSave:n}){var K,J,G,X,j,$,fe,ge,pe,ye,je,ve;const i=b(),a=D(),r=x.useId(),l=((K=s.inference)==null?void 0:K.source)??"api-key",[o,c]=x.useState(n&&l==="dorkos-credits"?"api-key":l),[u,d]=x.useState(((J=s.inference)==null?void 0:J.protocol)??"openai-chat-completions"),[m,h]=x.useState(((G=s.inference)==null?void 0:G.endpoint)??""),[p,g]=x.useState(((X=s.inference)==null?void 0:X.provider)??""),[y,v]=x.useState(((j=s.inference)==null?void 0:j.model)??""),[O,M]=x.useState(String((($=s.inference)==null?void 0:$.contextWindow)??8192)),[I,w]=x.useState(String(((fe=s.inference)==null?void 0:fe.maxOutputTokens)??1024)),[P,N]=x.useState(""),[L,E]=x.useState(null),k=z({queryKey:["doe-credits-models",u],queryFn:()=>i.getDoeCreditsModels(u),enabled:o==="dorkos-credits"}),q=o==="dorkos-credits"?(ge=k.data)==null?void 0:ge.models.find(f=>f.id===y):void 0,ee=s.hasKey&&((pe=s.inference)==null?void 0:pe.endpoint)===m&&s.inference.source==="api-key",H=R({mutationFn:async f=>{if(n)return n(f,P.trim()||null);o==="api-key"&&P.trim()?await i.storeDoeCredential(f,P.trim()):await i.setDoeInference(f),(await i.getCloudCredits()).linked&&await i.setCloudCreditsDefault("doe",o==="dorkos-credits")},onSuccess:()=>{N("");for(const f of[["doe-inference"],F,T,es.all,ss.status()])a.invalidateQueries({queryKey:f});t==null||t({title:"DorkOS model settings saved",body:"New chats use this source and model."})},onError:f=>E(n&&f instanceof Error&&f.message?f.message:"Couldn’t save model settings. Try again.")});function re(f){var ke,Ne;if(f.preventDefault(),E(null),P.trim().startsWith("sk-ant-oat")){E("Anthropic subscription tokens cannot run DorkOS agents. Use an API key.");return}if(o==="api-key"&&!P.trim()&&!ee){E("Enter an API key.");return}if(o==="dorkos-credits"&&(!q||!((ke=k.data)!=null&&ke.endpoint))){E("Link DorkOS credits and choose an available model.");return}const ae=ts.safeParse({source:o,protocol:u,provider:o==="dorkos-credits"?"dorkos":p,endpoint:o==="dorkos-credits"?(Ne=k.data)==null?void 0:Ne.endpoint:m,model:y,contextWindow:(q==null?void 0:q.contextWindow)??Number(O),maxOutputTokens:(q==null?void 0:q.maxOutputTokens)??Number(I)});if(!ae.success){E("Check the model, endpoint, and token limits.");return}H.mutate(ae.data)}const B="bg-background border-input focus-visible:ring-ring h-11 w-full rounded-md md:h-9 border px-3 text-sm focus-visible:ring-2";return e.jsxs("form",{onSubmit:re,className:"space-y-3","aria-label":"DorkOS model settings",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-source`,children:"Runs on"}),e.jsxs("select",{id:`${r}-source`,className:B,value:o,onChange:f=>{c(f.target.value),v("")},children:[e.jsx("option",{value:"api-key",children:"My API key"}),e.jsx("option",{value:"local",children:"Local model"}),!n&&e.jsx("option",{value:"dorkos-credits",children:"DorkOS credits"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-protocol`,children:"Model protocol"}),e.jsxs("select",{id:`${r}-protocol`,className:B,value:u,onChange:f=>{d(f.target.value),o==="dorkos-credits"&&v("")},children:[e.jsx("option",{value:"openai-chat-completions",children:"OpenAI Chat Completions"}),e.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),e.jsx("option",{value:"anthropic-messages",children:"Anthropic Messages"})]})]}),o==="dorkos-credits"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-model`,children:"Model"}),e.jsxs("select",{id:`${r}-model`,className:B,value:y,onChange:f=>v(f.target.value),disabled:k.isPending||!((ye=k.data)!=null&&ye.endpoint),children:[e.jsx("option",{value:"",children:"Choose a model"}),(je=k.data)==null?void 0:je.models.map(f=>e.jsx("option",{value:f.id,children:f.displayName},f.id))]}),!((ve=k.data)!=null&&ve.endpoint)&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Link DorkOS credits in Settings to choose a model."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-service`,children:"Service name"}),e.jsx(_,{id:`${r}-service`,value:p,onChange:f=>g(f.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-endpoint`,children:"Model endpoint"}),e.jsx(_,{id:`${r}-endpoint`,type:"url",value:m,onChange:f=>h(f.target.value),required:!0}),o==="local"&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Use a loopback address. No API key is needed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-model`,children:"Model ID"}),e.jsx(_,{id:`${r}-model`,value:y,onChange:f=>v(f.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-context`,children:"Context tokens"}),e.jsx(_,{id:`${r}-context`,type:"number",min:1,value:O,onChange:f=>M(f.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-output`,children:"Output tokens"}),e.jsx(_,{id:`${r}-output`,type:"number",min:1,value:I,onChange:f=>w(f.target.value),required:!0})]})]}),o==="api-key"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-key`,children:"API key"}),e.jsx(ne,{id:`${r}-key`,value:P,onChange:f=>N(f.target.value),autoComplete:"off"}),ee&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"API key saved. Leave blank to keep it."})]})]}),L&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:L}),e.jsx(C,{type:"submit",disabled:H.isPending,children:H.isPending?"Saving…":n?"Save":"Save model settings"})]})}const Ds={openai:"OpenAI",anthropic:"Anthropic"};function Ts(s){return Ds[s]??s}function Ms(s){switch(s){case"ollama":return"On your computer (Ollama)";case"openrouter":return"Cloud via OpenRouter";default:return`Your own API key (${Ts(s)})`}}const qe="ollama",Fe=["runtime-connect","ollama"];function qs(s){const t=b();return z({queryKey:Fe,queryFn:()=>t.detectOllama(),enabled:s,staleTime:3e4})}function Fs(){const s=b(),t=D(),n=R({mutationFn:i=>s.updateConfig({runtimes:{opencode:{provider:qe}}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]})}});return{connect:i=>n.mutate(i),isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,errorMessage:n.isError?n.error.message??"Couldn’t connect to Ollama.":null}}const $e=["runtime-connect","opencode","direct"];function $s(){const s=b();return z({queryKey:$e,queryFn:()=>s.getOpenCodeDirectSetup(),staleTime:3e4})}function _s(){var i;const s=b(),t=R({mutationFn:({providerId:a,key:r,baseURL:l})=>s.checkProviderCredential(a,r.trim().length>0?r:null,(l==null?void 0:l.trim())||null),meta:{suppressErrorToast:!0}}),n=t.data??(t.isError?{ok:!1,reason:"unexpected",message:t.error.message||"Couldn’t check the key."}:null);return{check:a=>t.mutate(a),isPending:t.isPending,result:n,checkedSavedKey:n!==null&&(((i=t.variables)==null?void 0:i.key)??"").trim().length===0,reset:t.reset}}function Us(){var l,o,c;const s=b(),t=D(),[n,i]=x.useState(null),a=R({mutationFn:async({providerId:u,key:d,baseURL:m})=>{const h=(m==null?void 0:m.trim())||null;i("checking");const p=await s.checkProviderCredential(u,d.trim().length>0?d:null,h);return p.ok?(i("saving"),await s.storeProviderCredential(u,d,h),{saved:!0,message:null}):{saved:!1,message:p.message}},onSettled:()=>i(null),meta:{suppressErrorToast:!0},onSuccess:u=>{u.saved&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}),t.invalidateQueries({queryKey:[...$e]}))}}),r=((l=a.data)==null?void 0:l.saved)===!1;return{connect:u=>{u.providerId.trim().length!==0&&a.mutate(u)},isPending:a.isPending,phase:n,isSuccess:((o=a.data)==null?void 0:o.saved)===!0,isError:a.isError||r,errorMessage:r?((c=a.data)==null?void 0:c.message)??null:a.isError?a.error.message??"Couldn’t save your key.":null,reset:a.reset}}function zs(s){const t=b();return z({queryKey:["runtime-connect","ollama","catalog"],queryFn:()=>t.getOllamaModelCatalog(),enabled:s,staleTime:6e4})}function Qs(){var o,c;const s=b(),t=D(),[n,i]=x.useState(null),a=R({mutationFn:async u=>{i(null);const d=await s.pullOllamaModel(u,m=>i(m));return d.ok&&await s.updateConfig({runtimes:{opencode:{provider:qe}}}),d},onSuccess:u=>{u.ok&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}))}}),r=a.isError||((o=a.data)==null?void 0:o.ok)===!1,l=a.isError?a.error.message:((c=a.data)==null?void 0:c.error)??null;return{pull:u=>a.mutate(u),isPending:a.isPending,isError:r,errorMessage:r?l??"Couldn’t download the model.":null,progress:n,result:a.data}}function Bs(){var o,c;const s=b(),t=D(),[n,i]=x.useState(null),a=R({mutationFn:()=>(i(null),s.provisionOllama(u=>i(u))),onSuccess:u=>{u.ok&&(t.invalidateQueries({queryKey:Fe}),t.invalidateQueries({queryKey:[...T]}))}}),r=a.isError||((o=a.data)==null?void 0:o.ok)===!1,l=a.isError?a.error.message:((c=a.data)==null?void 0:c.error)??null;return{provision:()=>a.mutate(),isPending:a.isPending,isError:r,errorMessage:r?l??"Couldn’t install Ollama.":null,progress:n,result:a.data}}const Gs="https://ollama.com/download",Ws="curl -fsSL https://ollama.com/install.sh | sh";function Ys({installMethod:s}){const t=Bs(),n=s==="brew"||s==="winget";return e.jsxs("div",{className:"space-y-3","data-testid":"ollama-absent",children:[e.jsx(Vs,{}),n?e.jsx(Hs,{provision:t}):e.jsx(Js,{}),e.jsx(Xs,{})]})}function Vs(){const s=Ke();return e.jsxs("div",{className:"space-y-1.5","data-testid":"ollama-explainer",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Run AI models on ",s]}),e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Ollama is a free app that runs AI models on ",s,"."]}),e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Nothing you type leaves ",s,"."]})]})}function Hs({provision:s}){var t,n,i;return s.isPending?e.jsx(A,{message:((t=s.progress)==null?void 0:t.message)??"Installing Ollama…"}):(n=s.result)!=null&&n.ok?(i=s.result.status)!=null&&i.running?e.jsx(A,{message:"Ollama is ready…"}):e.jsx("p",{className:"text-xs","data-testid":"ollama-installed-not-running",children:"Ollama isn’t running. Open the Ollama app to start it."}):s.isError?e.jsx(Q,{message:s.errorMessage??"Couldn’t install Ollama.",onRetry:s.provision}):e.jsx(C,{size:"sm",onClick:s.provision,"data-testid":"ollama-install-oneclick",children:"Install Ollama"})}function Js(){return e.jsxs("div",{className:"space-y-2","data-testid":"ollama-manual-install",children:[e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:"Installing Ollama needs administrator access. Run this in a terminal:"}),e.jsx(Cs,{command:Ws,copyLabel:"Copy the Ollama install command"})]})}function Xs(){return e.jsxs("a",{href:Gs,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Or download Ollama from ollama.com ",e.jsx(Y,{className:"size-3"})]})}const Zs="https://ollama.com/library",et={"runs-well":{label:"Runs well on your machine",tone:"text-status-success-fg"},"may-be-slow":{label:"May be slow on your machine",tone:"text-status-warning-fg"},"too-large":{label:"Too large for your machine",tone:"text-destructive"}},st={frontier:"Frontier","solid-coder":"Solid coder","quick-helper":"Quick helper"};function tt({active:s,onConnected:t,onConnectDirectly:n}){var I,w,P,N,L,E;const i=qs(s),a=Fs(),r=Qs(),l=((I=i.data)==null?void 0:I.running)??!1,o=zs(l),[c,u]=x.useState(null),[d,m]=x.useState(null);x.useEffect(()=>{a.isSuccess&&(t==null||t(Pe))},[a.isSuccess,t]),x.useEffect(()=>{var k;(k=r.result)!=null&&k.ok&&(t==null||t(Pe))},[(w=r.result)==null?void 0:w.ok,t]);const h=k=>{u(k),a.connect(k)},p=k=>{m(k),r.pull(k)};if(i.isPending)return e.jsx(A,{message:"Looking for Ollama on your machine…"});if(!l)return e.jsx(Ys,{installMethod:(P=i.data)==null?void 0:P.installMethod});if(a.isSuccess)return t?null:e.jsx(U,{message:"Connected to Ollama"});if((N=r.result)!=null&&N.ok)return t?null:e.jsxs("div",{className:"text-status-success-fg flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs","data-testid":"guided-pull-connected",children:[e.jsx(ue,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:"Connected:"}),e.jsx(ns,{runtime:"opencode",model:r.result.model,className:"text-xs"})]});const g=i.data,y=(g==null?void 0:g.installed)??[],v=((L=g==null?void 0:g.installed)==null?void 0:L.length)??(g==null?void 0:g.models.length)??0,O=((E=o.data)==null?void 0:E.models.some(k=>k.model.id===d))??!1,M=d!==null&&!O?d:null;return e.jsxs("div",{className:"space-y-4","data-testid":"ollama-running",children:[e.jsx(nt,{count:v}),y.length>0&&e.jsx(rt,{installed:y,connect:a,connectingId:c,onUse:h}),e.jsx(at,{catalogQuery:o,pull:r,pullingId:d,onGet:p}),e.jsx(it,{pull:r,activePull:M,onSubmit:p}),e.jsx(ot,{}),n&&e.jsxs("button",{type:"button",onClick:n,"data-testid":"local-connect-directly",className:"focus-ring text-muted-foreground hover:text-foreground block rounded-md text-left text-xs transition-colors",children:["Using LM Studio or another server? ",e.jsx("span",{className:"underline",children:"Connect it directly"})]})]})}function nt({count:s}){return e.jsxs("p",{className:"flex items-center gap-1.5 text-xs","data-testid":"ollama-status-line",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-emerald-500","aria-hidden":!0}),e.jsxs("span",{children:["Ollama is running · ",s," ",s===1?"model":"models"," installed"]})]})}function _e({verdict:s,explanation:t}){const n=et[s];return e.jsxs("div",{"data-testid":"ollama-verdict","data-verdict":s,children:[e.jsx("p",{className:V("text-xs font-medium",n.tone),children:n.label}),e.jsx("p",{className:"text-muted-foreground/80 text-2xs leading-snug",children:t})]})}function Ue({tier:s}){return e.jsx(De,{size:"xs",variant:"outline",className:"font-normal",children:st[s]})}function rt({installed:s,connect:t,connectingId:n,onUse:i}){return e.jsxs("div",{className:"space-y-2","data-testid":"ollama-installed",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Installed"}),e.jsx("ul",{className:"space-y-1.5",children:s.map(a=>{const r=n===a.id&&t.isPending,l=n===a.id&&t.isError,o=()=>i(a.id);let c=e.jsx(C,{size:"sm",onClick:o,children:"Use"});return r?c=e.jsx(A,{message:"Connecting…"}):l&&(c=e.jsx(Q,{message:t.errorMessage??"Couldn’t connect to Ollama.",onRetry:o})),e.jsxs("li",{className:"border-border flex items-center justify-between gap-3 rounded-lg border p-3","data-testid":"ollama-installed-item",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:a.id}),a.assessment.model.tier&&e.jsx(Ue,{tier:a.assessment.model.tier})]}),e.jsx(_e,{verdict:a.assessment.verdict,explanation:a.assessment.explanation})]}),c]},a.id)})})]})}function at({catalogQuery:s,pull:t,pullingId:n,onGet:i}){var r;if(s.isPending)return e.jsx(A,{message:"Checking which models fit your machine…"});const a=((r=s.data)==null?void 0:r.models)??[];return s.isError||a.length===0?null:e.jsxs("div",{className:"space-y-2","data-testid":"ollama-shelf",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add a model"}),e.jsx("ul",{className:"space-y-1.5",children:a.map(({model:l,verdict:o,explanation:c})=>{const u=n===l.id,d=()=>i(l.id);return u&&(t.isPending||t.isError)?e.jsxs("li",{className:"border-border rounded-lg border p-3","data-testid":"shelf-item",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:l.label}),t.isPending?e.jsx(ze,{progress:t.progress}):e.jsx(Q,{message:t.errorMessage??"Couldn’t download the model.",onRetry:d})]},l.id):e.jsxs("li",{className:"border-border flex items-center justify-between gap-3 rounded-lg border p-3","data-testid":"shelf-item",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:l.label}),l.tier&&e.jsx(Ue,{tier:l.tier}),e.jsx("span",{className:"text-muted-foreground text-xs",children:l.sizeLabel})]}),e.jsx(_e,{verdict:o,explanation:c})]}),e.jsx(C,{size:"sm",variant:"outline",disabled:o==="too-large"||t.isPending,onClick:d,children:"Get"})]},l.id)})})]})}function it({pull:s,activePull:t,onSubmit:n}){const[i,a]=x.useState(""),r=i.trim(),l=ps.test(r);if(t&&s.isPending)return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Downloading ",t,"…"]}),e.jsx(ze,{progress:s.progress})]});const o=c=>{c.preventDefault(),l&&n(r)};return e.jsxs("form",{onSubmit:o,className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"ollama-pull-tag",className:"text-xs font-normal",children:"Download any model by name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{id:"ollama-pull-tag","data-testid":"ollama-pull-by-name",value:i,onChange:c=>a(c.target.value),placeholder:"qwen2.5-coder:32b","aria-invalid":r.length>0&&!l}),e.jsx(C,{type:"submit",size:"sm",disabled:!l||s.isPending,children:"Download"})]}),r.length>0&&!l&&e.jsxs("p",{className:"text-muted-foreground text-2xs",children:["Use a tag like ",e.jsx("code",{className:"text-2xs",children:"qwen2.5-coder:32b"}),"."]}),t&&s.isError&&e.jsx(Q,{message:s.errorMessage??"Couldn’t download the model.",onRetry:()=>n(t)})]})}function ot(){return e.jsxs("a",{href:Zs,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Browse the library ",e.jsx(Y,{className:"size-3"})]})}function ze({progress:s}){const t=Ae(),n=s==null?void 0:s.percent,i=(s==null?void 0:s.status)??"Starting download…";return e.jsxs("div",{className:"space-y-2","data-testid":"guided-pull-progress",children:[e.jsx("div",{className:"bg-muted h-2 w-full overflow-hidden rounded-full",children:n===void 0?e.jsx(te.div,{className:"bg-primary/70 h-full w-1/3 rounded-full",animate:t?{}:{x:["-100%","300%"]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"}}):e.jsx(te.div,{className:"bg-primary h-full rounded-full",initial:!1,animate:{width:`${Math.min(100,Math.max(0,n))}%`},transition:t?{duration:0}:{duration:.3,ease:"easeOut"},"data-testid":"guided-pull-bar"})}),e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[e.jsx(de,{size:"xs",className:V("shrink-0",t&&"animate-none")}),e.jsxs("span",{className:"truncate",children:[i,n!==void 0?` · ${Math.round(n)}%`:""]})]})]})}function lt(){var r,l,o;const s=b(),t=D(),n=R({mutationFn:c=>s.storeOpenRouterKey(c),onSuccess:c=>{c.ok&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}))}}),i=n.isError||((r=n.data)==null?void 0:r.ok)===!1,a=n.isError?n.error.message:((l=n.data)==null?void 0:l.error)??null;return{store:c=>{c.trim().length!==0&&n.mutate(c)},isPending:n.isPending,isSuccess:((o=n.data)==null?void 0:o.ok)===!0,isError:i,errorMessage:i?a??"Couldn’t save the OpenRouter key.":null}}function ct(){var h,p;const s=b(),t=D(),[n,i]=x.useState(null),[a,r]=x.useState(null),l=R({mutationFn:()=>s.startOpenRouterOAuth(),onMutate:()=>r(null),onSuccess:({authorizeUrl:g,state:y})=>{if(!rs(g)){r("Couldn’t open the OpenRouter sign-in page.");return}i(y)},onError:g=>r(g.message??"Couldn’t start OpenRouter sign-in.")}),o=z({queryKey:["runtime-connect","openrouter","oauth",n],queryFn:()=>s.getOpenRouterOAuthStatus(n),enabled:n!==null,refetchInterval:g=>{var y;return((y=g.state.data)==null?void 0:y.status)==="pending"?1500:!1},refetchOnWindowFocus:g=>{var y;return((y=g.state.data)==null?void 0:y.status)==="error"}}),c=(h=o.data)==null?void 0:h.status;x.useEffect(()=>{c==="connected"&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}))},[c,t]);const u=l.isPending||n!==null&&c==="pending",d=!!a||c==="error",m=d?a??((p=o.data)==null?void 0:p.error)??"Couldn’t sign in to OpenRouter. Try again.":null;return{begin:()=>l.mutate(),isPending:u,isSuccess:c==="connected",isError:d,errorMessage:m}}const dt="https://openrouter.ai/keys";function ut({onConnected:s}){const[t,n]=x.useState(""),i=lt(),a=ct(),r=i.isSuccess||a.isSuccess;return x.useEffect(()=>{r&&(s==null||s(Es))},[r,s]),r?e.jsx(U,{message:"Connected to OpenRouter"}):e.jsxs("div",{className:"space-y-4","data-testid":"openrouter-gateway",children:[e.jsx("div",{className:"space-y-2",children:a.isPending?e.jsx(A,{message:"Sign in to OpenRouter in the new tab…"}):a.isError?e.jsx(Q,{message:a.errorMessage??"Couldn’t sign in to OpenRouter.",onRetry:a.begin}):e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm",className:"w-full",onClick:a.begin,children:"Connect OpenRouter"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Makes a limited key for you."})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"bg-border h-px flex-1"}),e.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),e.jsx("span",{className:"bg-border h-px flex-1"})]}),i.isPending?e.jsx(A,{message:"Checking your OpenRouter key…"}):e.jsxs("form",{className:"space-y-2",onSubmit:l=>{l.preventDefault(),i.store(t)},children:[e.jsx(S,{htmlFor:"openrouter-key",className:"text-xs",children:"OpenRouter key"}),e.jsx(ne,{id:"openrouter-key",value:t,onChange:l=>n(l.target.value),placeholder:"sk-or-…",autoComplete:"off",spellCheck:!1}),i.isError&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:i.errorMessage}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("a",{href:dt,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an OpenRouter key ",e.jsx(Y,{className:"size-3"})]}),e.jsx(C,{type:"submit",size:"sm",variant:"outline",disabled:t.trim().length===0,children:"Save key"})]})]})]})}const se="other";function Z(s){return W.find(t=>t.id===s)}function mt(s){var t;return((t=Z(s))==null?void 0:t.id)??"openai"}function ce(s){var t;return((t=W.find(n=>n.id===s))==null?void 0:t.defaultBaseURL)??W[0].defaultBaseURL}function Qe(s){return W.some(t=>t.id===s.providerId)}function ie(s){return Qe(s)?s.providerId==="anthropic"?"anthropic":s.baseURL===null||s.baseURL===ce(s.providerId)?s.providerId:se:"openai"}function xt({onConnected:s}){const t=$s();return t.isError&&!t.data?e.jsx(Q,{message:"Couldn’t load your saved settings.",onRetry:()=>void t.refetch()}):t.data?e.jsx(ht,{setup:t.data,onConnected:s},`${t.data.providerId??""}|${t.data.baseURL??""}`):e.jsx(A,{message:"Loading what you saved…"})}function ht({setup:s,onConnected:t}){var X;const n=Qe(s)?s:null,[i,a]=x.useState(()=>ie(s)),[r,l]=x.useState(""),[o,c]=x.useState(()=>{var j;return(n==null?void 0:n.baseURL)??((j=Z(ie(s)))==null?void 0:j.defaultBaseURL)??""}),[u,d]=x.useState(()=>{var $;const j=ie(s);return j!==se&&n!==null&&n.baseURL!==null&&n.baseURL!==(($=Z(j))==null?void 0:$.defaultBaseURL)}),m=Us(),h=_s(),p=Z(i),g=mt(i),y=n!=null&&n.key.saved&&n.providerId===g?n.key.last4:null,v=o.trim(),O=i===se,M=!O||v.length>0,I=ce(g),w=v||I,P=w===I?"":w,N=n===null?null:n.baseURL??ce(n.providerId),L=g!==((n==null?void 0:n.providerId)??null)||w!==N,E=r.trim().length>0,q=(E||y!==null&&!L)&&M,ee=E&&M,H=!E&&y!==null&&L,re=w.startsWith("http://"),B={providerId:g,key:r,baseURL:P},K=m.isPending||h.isPending,J=x.useRef(null),G=()=>{h.reset(),m.reset()};return x.useEffect(()=>{m.isSuccess&&(t==null||t(ws))},[m.isSuccess,t]),x.useEffect(()=>{var j;m.isError&&((j=J.current)==null||j.focus())},[m.isError]),m.isSuccess?e.jsx(U,{}):e.jsxs("form",{className:"space-y-3","data-testid":"direct-provider",onSubmit:j=>{j.preventDefault(),h.reset(),m.connect(B)},children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"direct-provider-source",className:"text-xs",children:"Power source"}),e.jsxs(as,{value:i,disabled:K,onValueChange:j=>{var $;a(j),c((($=Z(j))==null?void 0:$.defaultBaseURL)??""),G()},children:[e.jsx(is,{id:"direct-provider-source","data-testid":"direct-provider-source",children:e.jsx(os,{})}),e.jsxs(ls,{children:[W.map(j=>e.jsx(be,{value:j.id,children:j.label},j.id)),e.jsx(be,{value:se,children:"Other (OpenAI-compatible)"})]})]})]}),(O||u)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(S,{htmlFor:"direct-provider-base-url",className:"text-xs",children:["Base URL ",!O&&e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(_,{id:"direct-provider-base-url",value:o,disabled:K,onChange:j=>{c(j.target.value),G()},placeholder:"https://api.example.com/v1",autoComplete:"off",spellCheck:!1})]}),!O&&!u&&e.jsx("button",{type:"button",onClick:()=>d(!0),disabled:K,"data-testid":"direct-provider-advanced",className:"text-muted-foreground hover:text-foreground text-xs underline decoration-dotted underline-offset-2 transition-colors",children:"Advanced"}),re&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"direct-provider-insecure",children:"This address isn’t encrypted. Your key travels in the open."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"direct-provider-key",className:"text-xs",children:"API key"}),e.jsx(ne,{id:"direct-provider-key",ref:J,value:r,disabled:K,onChange:j=>{l(j.target.value),G()},placeholder:y===null?(p==null?void 0:p.keyPlaceholder)??W[0].keyPlaceholder:`Saved key ends in ${y}. Paste to replace.`,autoComplete:"off",spellCheck:!1})]}),m.isError&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:m.errorMessage}),H&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"direct-provider-repaste",children:"Paste your key again to change the address."}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p===void 0?e.jsx("span",{}):e.jsxs("a",{href:p.getKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an API key ",e.jsx(Y,{className:"size-3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",size:"sm",variant:"outline",disabled:!q||K,"data-testid":"direct-provider-test",onClick:()=>{m.reset(),h.reset(),h.check(B)},children:"Test key"}),e.jsx(C,{type:"submit",size:"sm",disabled:!ee||K,children:"Save & connect"})]})]}),K?e.jsx(A,{message:m.phase==="saving"?"Saving…":"Checking your key…"}):((X=h.result)==null?void 0:X.ok)===!0?e.jsx(U,{message:h.checkedSavedKey?"Your saved key works":"Key works"}):h.result?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:h.result.message}):null]})}function ft({currentProvider:s,onConnected:t}){const[n,i]=x.useState("choose"),a=gt();if(n==="choose")return e.jsx(pt,{sources:a,onChoose:i,currentProvider:s});const r=()=>i("choose");return n==="cloud"?e.jsx(oe,{source:a.cloud,onBack:r,children:e.jsx(ut,{onConnected:t})}):n==="local"?e.jsx(oe,{source:a.local,onBack:r,children:e.jsx(tt,{active:!0,onConnected:t,onConnectDirectly:()=>i("direct")})}):e.jsx(oe,{source:a.direct,onBack:r,children:e.jsx(xt,{onConnected:t})})}function gt(){return{cloud:{step:"cloud",title:"Best models, zero setup",description:"Claude, GPT, Gemini and 300+ more, in the cloud.",sub:"One OpenRouter account covers them all. Pay for what you use.",tradeOff:"Your prompts and code are sent to the model’s provider.",recommended:!0},local:{step:"local",title:"Private and free, on your computer",description:`Models run on ${Ke()}. Nothing you type ever leaves it.`,sub:"Runs Quick helpers and Solid coders. Frontier models stay cloud-only.",tradeOff:"Smaller models: good for edits and quick help."},direct:{step:"direct",title:"Use your own API key",stepTitle:"Your own API key",description:"Anthropic, OpenAI, or any OpenAI-compatible server, like LM Studio.",sub:"",quiet:!0}}}function pt({sources:s,onChoose:t,currentProvider:n}){return e.jsxs("div",{className:"space-y-2","data-testid":"opencode-power-sources",children:[n&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"opencode-current-source",children:["Currently: ",Ms(n)]}),Object.values(s).map(i=>e.jsx(yt,{source:i,onChoose:t},i.step))]})}function yt({source:s,onChoose:t}){return e.jsxs("button",{type:"button",onClick:()=>t(s.step),"data-testid":`power-source-${s.step}`,className:V("card-interactive focus-ring group flex w-full items-start gap-3 rounded-lg border p-3 text-left",s.recommended?"border-primary/40 bg-card shadow-soft":"border-border bg-card shadow-soft",s.quiet&&"shadow-none"),children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.title}),s.recommended&&e.jsx(De,{size:"xs",variant:"secondary",children:"Recommended"})]}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s.description})]}),e.jsx(ds,{className:"text-muted-foreground/60 mt-0.5 size-4 shrink-0"})]})}function oe({source:s,onBack:t,children:n}){const i=!!(s.sub||s.tradeOff);return e.jsxs("div",{className:"space-y-3","data-testid":"opencode-connect-step",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:t,className:"focus-ring text-muted-foreground hover:text-foreground -ml-1 inline-flex items-center gap-1 rounded-md px-1 py-0.5 text-xs transition-colors","data-testid":"connect-step-back",children:[e.jsx(cs,{className:"size-3.5"}),"Back"]}),e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsx("span",{className:"text-sm font-medium",children:s.stepTitle??s.title})]}),i&&e.jsxs("div",{className:"space-y-1","data-testid":"connect-step-details",children:[s.sub&&e.jsx("p",{className:"text-muted-foreground/80 text-xs",children:s.sub}),s.tradeOff&&e.jsxs("p",{className:"text-muted-foreground/70 text-2xs leading-snug",children:[e.jsx("span",{className:"font-medium",children:"Trade-off:"})," ",s.tradeOff]})]}),n]})}function jt({type:s,connect:t,currentProvider:n,onConnected:i}){const a=ys(),r=Ps(s),l=us(),o=ms(),c=xs([s]);if(s==="doe")return a?e.jsx(As,{onConnected:i}):e.jsx(Oe,{});const u=r==="lead"&&l!==null,d=a?t.kind==="provider-picker"?e.jsx(ft,{currentProvider:n,onConnected:i}):t.kind==="login"?e.jsx(Is,{type:s,onConnected:i,asOtherWay:u}):null:e.jsx(Oe,{});if(d===null)return null;const m=me(s).label,h=t.kind==="provider-picker";if(r==="on-credits")return e.jsxs("div",{className:"space-y-3","data-testid":`credits-ready-${s}`,children:[e.jsxs("div",{role:"status",children:[e.jsxs("p",{className:"text-status-success-fg flex items-center gap-1.5 text-sm font-medium",children:[e.jsx(ue,{className:"size-3.5","aria-hidden":!0}),"You’re ready"]}),e.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:["New work on ",m," runs on your DorkOS credits.",c.map(g=>` ${g}`).join("")]})]}),e.jsx(le,{collapsed:!0,children:d})]});const p=g=>l==null?void 0:l({runtime:s,origin:`runtime-connect:${s}`,fullWidth:g,onChoose:async()=>{await o.mutateAsync({runtime:s,useCredits:!0}),i==null||i(Rs(m))}});return u?e.jsxs("div",{className:"space-y-4","data-testid":`default-first-${s}`,children:[p(!0),e.jsx(le,{children:d}),e.jsx(Os,{ollama:h,remote:!a})]}):r==="other-way"&&l!==null?e.jsxs("div",{className:"space-y-4","data-testid":`credits-other-way-${s}`,children:[d,e.jsx(le,{children:p(!1)})]}):d}function le({collapsed:s=!1,children:t}){const[n,i]=x.useState(!s);return s?e.jsxs(Re,{open:n,onOpenChange:i,children:[e.jsxs(Ie,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:[e.jsx(hs,{className:V("size-3.5 transition-transform",n&&"rotate-180")}),"Other ways"]}),e.jsx(Le,{className:"mt-3",children:t})]}):e.jsxs("section",{className:"space-y-2","aria-label":"Other ways",children:[e.jsx("p",{className:"text-muted-foreground text-2xs font-medium tracking-wide uppercase",children:"Other ways"}),t]})}const Pt=s=>e.jsx(jt,{...s});export{Ot as C,Cs as D,Os as K,Oe as R,bs as a,ys as b,St as c,Ms as d,Ps as e,As as f,Ss as g,Pt as r,Ct as u};
|
|
1
|
+
import{aL as Ee,a1 as b,a3 as D,r as x,a4 as R,jQ as F,jR as T,jS as Be,a2 as z,j as e,jT as Ge,ij as we,eq as We,er as Y,Q as Re,T as Ie,V as Le,B as C,hU as Ye,G as V,eP as Ve,ea as He,jU as Je,jV as Xe,e3 as Ae,ap as te,x as de,bw as Ze,J as ue,ee as me,en as S,eo as ne,aG as es,jW as ss,I as _,jX as ts,jY as Ke,jZ as ns,_ as De,fA as rs,eg as as,eh as is,ei as os,ej as ls,ek as be,e6 as cs,C as ds,j_ as us,j$ as ms,k0 as xs,U as hs}from"./index-fge85Gub.js";import{I as fs}from"./inline-code-7dwi7wWG.js";import{u as gs}from"./useMutationState-TJGtJT5R.js";import{O as ps,a as W}from"./runtime-connect-Dn0T5YWv.js";function ys(){var s;return((s=Ee().data)==null?void 0:s.isLocalCaller)!==!1}function St(){const s=Ee().data;return((s==null?void 0:s.onTrustedConnection)??(s==null?void 0:s.isLocalCaller))!==!1}function Ct(s){var u,d;const t=b(),n=D(),[i,a]=x.useState(null),r=R({mutationFn:()=>(a(null),t.provisionRuntime(s,m=>a(m))),onSuccess:m=>{m.ok&&(n.invalidateQueries({queryKey:[...F]}),n.invalidateQueries({queryKey:[...T]}))}}),l=r.isError||((u=r.data)==null?void 0:u.ok)===!1,o=r.isError?r.error.message:((d=r.data)==null?void 0:d.error)??null,c=(o==null?void 0:o.trim().toLowerCase())==="not found"?"One-click install isn’t available here.":o;return{provision:()=>r.mutate(),isPending:r.isPending,isError:l,errorMessage:l?c??"Couldn’t install. Try again.":null,progress:i,result:r.data}}function Te(s){return["runtime-key-status",s]}function js(s,t=!0){const n=b();return z({queryKey:Te(s),queryFn:()=>n.getRuntimeKeyStatus(s),enabled:t,staleTime:3e4})}function vs(s){const t=b(),n=R({mutationFn:a=>t.checkRuntimeCredential(s,a.trim().length>0?a:null),meta:{suppressErrorToast:!0}}),i=n.data??(n.isError?{ok:!1,reason:"unexpected",message:n.error.message||"Couldn’t check the key."}:null);return{check:a=>n.mutate(a),isPending:n.isPending,result:i,checkedSavedKey:i!==null&&(n.variables??"").trim().length===0,reset:n.reset}}function ks(s){var o,c,u;const t=b(),n=D(),[i,a]=x.useState(null),r=R({mutationFn:async d=>{a("checking");const m=await t.checkRuntimeCredential(s,d);return m.ok?(a("saving"),await t.storeRuntimeCredential(s,d),{saved:!0,message:null}):{saved:!1,message:m.message}},onSettled:()=>a(null),meta:{suppressErrorToast:!0},onSuccess:d=>{d.saved&&(n.invalidateQueries({queryKey:[...F]}),n.invalidateQueries({queryKey:[...T]}),n.invalidateQueries({queryKey:[...Te(s)]}))}}),l=((o=r.data)==null?void 0:o.saved)===!1;return{store:d=>{d.trim().length!==0&&r.mutate(d)},isPending:r.isPending,phase:i,isSuccess:((c=r.data)==null?void 0:c.saved)===!0,isError:r.isError||l,errorMessage:l?((u=r.data)==null?void 0:u.message)??null:r.isError?r.error.message??"Couldn’t save the API key.":null,reset:r.reset}}const Se=new WeakMap;function Ns(s){const t=Se.get(s);if(t)return t;const n=new Set;return Se.set(s,n),n}function bs(s,t){var M,I,w,P;const n=b(),i=D(),{sessionId:a,accountRoot:r,onCompleted:l}=t??{},o=x.useMemo(()=>["runtime-login",s,a??"",r??""],[s,a,r]),c=R({mutationKey:o,mutationFn:()=>n.delegateRuntimeLogin(s,a===void 0&&r===void 0?void 0:{sessionId:a,accountRoot:r}),onSuccess:N=>{N.ok&&(i.invalidateQueries({queryKey:Be.all}),i.invalidateQueries({queryKey:[...F]}),i.invalidateQueries({queryKey:[...T]}))}}),u=gs({filters:{mutationKey:o,exact:!0},select:N=>({id:N.mutationId,state:N.state})}),d=u.some(N=>N.state.status==="pending"),m=u[u.length-1],h=d||m==null?void 0:m.state,p=d||m==null?void 0:m.id,g=!d&&((h==null?void 0:h.status)==="error"||((M=h==null?void 0:h.data)==null?void 0:M.ok)===!1),y=(h==null?void 0:h.status)==="error"?((I=h.error)==null?void 0:I.message)??null:((w=h==null?void 0:h.data)==null?void 0:w.error)??null,v=((P=h==null?void 0:h.data)==null?void 0:P.ok)===!0,O=x.useRef(l);return O.current=l,x.useEffect(()=>{var L;if(!v||p===void 0)return;const N=Ns(i);N.has(p)||(N.add(p),(L=O.current)==null||L.call(O))},[v,p,i]),{login:()=>{d||c.mutate()},isPending:d,isSuccess:v,isError:g,errorMessage:g?y??"Couldn’t sign in. Try again.":null}}const Ce={"claude-code":{signInLabel:"Sign in",otherWayLabel:"Sign in with Claude",signInHint:"Use your Claude subscription or Anthropic account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"Anthropic API key",keyPlaceholder:"sk-ant-…",getKeyUrl:"https://console.anthropic.com/settings/keys"},codex:{signInLabel:"Sign in with ChatGPT",otherWayLabel:"Sign in with ChatGPT",signInHint:"Use your ChatGPT account.",signInPending:"Waiting for sign-in to complete…",keyLabel:"OpenAI API key",keyPlaceholder:"sk-…",getKeyUrl:"https://platform.openai.com/api-keys"}};function Ss(s){return Ce[s]??Ce["claude-code"]}function Cs({command:s,infoUrl:t,copyLabel:n}){return!s&&!t?null:e.jsxs("div",{className:"space-y-2",children:[s&&e.jsxs("div",{className:"bg-muted flex items-center justify-between gap-2 rounded-lg px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[e.jsx(Ge,{className:"text-muted-foreground size-3.5 shrink-0"}),e.jsx("code",{className:"truncate text-xs",children:s})]}),e.jsx(we,{value:s,label:n??"Copy install command",className:"shrink-0"})]}),t&&e.jsxs(We,{href:t,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Learn more ",e.jsx(Y,{className:"size-3"})]})]})}function Ot({command:s,runtimeLabel:t}){const[n,i]=x.useState(!1);return e.jsxs(Re,{open:n,onOpenChange:i,className:"mt-2",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["DorkOS installs ",t," for you."," ",e.jsx(Ie,{className:"hover:text-foreground underline decoration-dotted underline-offset-2 transition-colors",children:n?"Hide command":"What runs?"})]}),e.jsxs(Le,{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx(fs,{children:s}),e.jsx(we,{value:s,label:`Copy command: ${s}`,className:"shrink-0"})]})]})}function Oe({onRetry:s}){return e.jsxs("div",{"data-testid":"remote-signin-notice",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Signing in needs the computer DorkOS runs on."}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:s?"Sign in to DorkOS there, then press Retry.":"Sign in to DorkOS there."}),e.jsx("p",{className:"text-muted-foreground/80 mt-2 text-xs",children:"Already on that computer? Open DorkOS at localhost instead."}),s&&e.jsxs(C,{variant:"outline",size:"sm",onClick:s,className:"mt-3 gap-1.5",children:[e.jsx(Ye,{className:"size-3"}),"Retry"]})]})}function Os({ollama:s=!1,remote:t=!1,className:n}){return e.jsxs("p",{className:V("text-muted-foreground text-xs",n),"data-testid":"keep-it-local-note",children:[t?"Prefer everything on the computer DorkOS runs on? Use your own sign-in there":"Prefer to keep everything on this computer? Use your own sign-in",s?", or Ollama":"","."]})}function Ps(s){const t=Ve(),{data:n}=He();return s?Je(Xe(t.data,s),n,s):"none"}const xe="OpenCode is connected",he="This chat uses OpenCode. Change models from the model menu.",Es={title:xe,body:`Frontier models are unlocked. ${he}`},ws={title:xe,body:he},Pe={title:xe,body:`Your local models are ready. ${he}`};function Me(s){return{title:`${s} is connected`,body:`This chat uses ${s}. Change models from the model menu.`}}function Rs(s){return{title:`${s} is ready`,body:`New work on ${s} runs on your DorkOS credits. Change it any time in Settings › Runtimes.`}}function A({message:s}){const t=Ae();return e.jsxs(te.div,{role:"status",className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:t?!1:{opacity:0},animate:{opacity:1},"data-testid":"connect-progress",children:[e.jsx(de,{size:"xs",className:V("text-muted-foreground shrink-0",t&&"animate-none")}),e.jsx(Ze,{mode:"wait",children:e.jsx(te.span,{className:"truncate text-xs",initial:t?!1:{opacity:0},animate:{opacity:1},exit:t?void 0:{opacity:0},transition:{duration:.2},children:s},s)})]})}function U({message:s="Connected"}){return e.jsxs("div",{role:"status",className:"text-status-success-fg flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs","data-testid":"connect-connected",children:[e.jsx(ue,{className:"size-3.5"}),s]})}function Q({message:s,onRetry:t}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:s}),e.jsx(C,{size:"sm",onClick:t,children:"Try again"})]})}function Is({type:s,onConnected:t,asOtherWay:n=!1}){const i=Ss(s),a=bs(s),[r,l]=x.useState(!1),o=x.useRef(!1);return x.useEffect(()=>{!a.isSuccess||o.current||(o.current=!0,t==null||t(Me(me(s).label)))},[a.isSuccess,t,s]),e.jsxs("div",{className:"space-y-4","data-testid":`login-connect-${s}`,children:[e.jsx("div",{className:"space-y-2",children:a.isPending?e.jsx(A,{message:i.signInPending}):a.isSuccess?e.jsx(U,{message:"Signed in"}):a.isError?e.jsx(Q,{message:a.errorMessage??"Couldn’t sign in.",onRetry:a.login}):e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm",variant:n?"outline":"default",className:"w-full",onClick:a.login,children:n?i.otherWayLabel:i.signInLabel}),e.jsx("p",{className:"text-muted-foreground text-xs",children:i.signInHint})]})}),r?e.jsxs("div",{className:"space-y-3","data-testid":`login-connect-key-${s}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"bg-border h-px flex-1"}),e.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),e.jsx("span",{className:"bg-border h-px flex-1"})]}),e.jsx(Ls,{type:s,copy:i,onConnected:t}),e.jsx("button",{type:"button",onClick:()=>l(!1),className:"text-muted-foreground hover:text-foreground text-xs underline decoration-dotted underline-offset-2 transition-colors",children:"Back to sign in"})]}):n?e.jsx(C,{size:"sm",variant:"outline",className:"w-full",onClick:()=>l(!0),"data-testid":`login-connect-use-key-${s}`,children:"Paste a key"}):e.jsx("button",{type:"button",onClick:()=>l(!0),className:"text-muted-foreground hover:text-foreground text-xs underline decoration-dotted underline-offset-2 transition-colors","data-testid":`login-connect-use-key-${s}`,children:"Use an API key instead"})]})}function Ls({type:s,copy:t,onConnected:n}){var g,y;const[i,a]=x.useState(""),r=ks(s),l=js(s),o=vs(s),c=x.useRef(!1),u=x.useRef(null);if(x.useEffect(()=>{!r.isSuccess||c.current||(c.current=!0,n==null||n(Me(me(s).label)))},[r.isSuccess,n,s]),x.useEffect(()=>{var v;r.isError&&((v=u.current)==null||v.focus())},[r.isError]),r.isSuccess)return e.jsx(U,{});const d=(g=l.data)!=null&&g.key.saved?l.data.key:null,m=i.trim().length>0,h=r.isPending||o.isPending,p=()=>{o.reset(),r.reset()};return e.jsxs("form",{className:"space-y-2",onSubmit:v=>{v.preventDefault(),o.reset(),r.store(i)},children:[e.jsx(S,{htmlFor:`api-key-${s}`,className:"text-xs",children:t.keyLabel}),e.jsx(ne,{id:`api-key-${s}`,ref:u,value:i,disabled:h,onChange:v=>{a(v.target.value),p()},placeholder:d?`Saved key ends in ${d.last4}. Paste to replace.`:t.keyPlaceholder,autoComplete:"off",spellCheck:!1}),r.isError&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:r.errorMessage}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.getKeyUrl?e.jsxs("a",{href:t.getKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an API key ",e.jsx(Y,{className:"size-3"})]}):e.jsx("span",{}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",size:"sm",variant:"ghost",disabled:!m&&d===null||h,"data-testid":`api-key-test-${s}`,onClick:()=>{r.reset(),o.reset(),o.check(i)},children:"Test key"}),e.jsx(C,{type:"submit",size:"sm",variant:"outline",disabled:!m||h,children:"Save key"})]})]}),h?e.jsx(A,{message:r.phase==="saving"?"Saving…":"Checking your key…"}):((y=o.result)==null?void 0:y.ok)===!0?e.jsx(U,{message:o.checkedSavedKey?"Your saved key works":"Key works"}):o.result?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:o.result.message}):null]})}function As(s){const t=b(),n=z({queryKey:["doe-inference"],queryFn:()=>t.getDoeInference()});return n.isPending?e.jsx(de,{"aria-label":"Loading model settings"}):n.isError?e.jsx("p",{role:"alert",children:"Couldn’t load model settings. Try again."}):e.jsx(Ks,{saved:n.data,...s},JSON.stringify(n.data))}function Ks({saved:s,onConnected:t,onSave:n}){var K,J,G,X,j,$,fe,ge,pe,ye,je,ve;const i=b(),a=D(),r=x.useId(),l=((K=s.inference)==null?void 0:K.source)??"api-key",[o,c]=x.useState(n&&l==="dorkos-credits"?"api-key":l),[u,d]=x.useState(((J=s.inference)==null?void 0:J.protocol)??"openai-chat-completions"),[m,h]=x.useState(((G=s.inference)==null?void 0:G.endpoint)??""),[p,g]=x.useState(((X=s.inference)==null?void 0:X.provider)??""),[y,v]=x.useState(((j=s.inference)==null?void 0:j.model)??""),[O,M]=x.useState(String((($=s.inference)==null?void 0:$.contextWindow)??8192)),[I,w]=x.useState(String(((fe=s.inference)==null?void 0:fe.maxOutputTokens)??1024)),[P,N]=x.useState(""),[L,E]=x.useState(null),k=z({queryKey:["doe-credits-models",u],queryFn:()=>i.getDoeCreditsModels(u),enabled:o==="dorkos-credits"}),q=o==="dorkos-credits"?(ge=k.data)==null?void 0:ge.models.find(f=>f.id===y):void 0,ee=s.hasKey&&((pe=s.inference)==null?void 0:pe.endpoint)===m&&s.inference.source==="api-key",H=R({mutationFn:async f=>{if(n)return n(f,P.trim()||null);o==="api-key"&&P.trim()?await i.storeDoeCredential(f,P.trim()):await i.setDoeInference(f),(await i.getCloudCredits()).linked&&await i.setCloudCreditsDefault("doe",o==="dorkos-credits")},onSuccess:()=>{N("");for(const f of[["doe-inference"],F,T,es.all,ss.status()])a.invalidateQueries({queryKey:f});t==null||t({title:"DorkOS model settings saved",body:"New chats use this source and model."})},onError:f=>E(n&&f instanceof Error&&f.message?f.message:"Couldn’t save model settings. Try again.")});function re(f){var ke,Ne;if(f.preventDefault(),E(null),P.trim().startsWith("sk-ant-oat")){E("Anthropic subscription tokens cannot run DorkOS agents. Use an API key.");return}if(o==="api-key"&&!P.trim()&&!ee){E("Enter an API key.");return}if(o==="dorkos-credits"&&(!q||!((ke=k.data)!=null&&ke.endpoint))){E("Link DorkOS credits and choose an available model.");return}const ae=ts.safeParse({source:o,protocol:u,provider:o==="dorkos-credits"?"dorkos":p,endpoint:o==="dorkos-credits"?(Ne=k.data)==null?void 0:Ne.endpoint:m,model:y,contextWindow:(q==null?void 0:q.contextWindow)??Number(O),maxOutputTokens:(q==null?void 0:q.maxOutputTokens)??Number(I)});if(!ae.success){E("Check the model, endpoint, and token limits.");return}H.mutate(ae.data)}const B="bg-background border-input focus-visible:ring-ring h-11 w-full rounded-md md:h-9 border px-3 text-sm focus-visible:ring-2";return e.jsxs("form",{onSubmit:re,className:"space-y-3","aria-label":"DorkOS model settings",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-source`,children:"Runs on"}),e.jsxs("select",{id:`${r}-source`,className:B,value:o,onChange:f=>{c(f.target.value),v("")},children:[e.jsx("option",{value:"api-key",children:"My API key"}),e.jsx("option",{value:"local",children:"Local model"}),!n&&e.jsx("option",{value:"dorkos-credits",children:"DorkOS credits"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-protocol`,children:"Model protocol"}),e.jsxs("select",{id:`${r}-protocol`,className:B,value:u,onChange:f=>{d(f.target.value),o==="dorkos-credits"&&v("")},children:[e.jsx("option",{value:"openai-chat-completions",children:"OpenAI Chat Completions"}),e.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),e.jsx("option",{value:"anthropic-messages",children:"Anthropic Messages"})]})]}),o==="dorkos-credits"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-model`,children:"Model"}),e.jsxs("select",{id:`${r}-model`,className:B,value:y,onChange:f=>v(f.target.value),disabled:k.isPending||!((ye=k.data)!=null&&ye.endpoint),children:[e.jsx("option",{value:"",children:"Choose a model"}),(je=k.data)==null?void 0:je.models.map(f=>e.jsx("option",{value:f.id,children:f.displayName},f.id))]}),!((ve=k.data)!=null&&ve.endpoint)&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Link DorkOS credits in Settings to choose a model."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-service`,children:"Service name"}),e.jsx(_,{id:`${r}-service`,value:p,onChange:f=>g(f.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-endpoint`,children:"Model endpoint"}),e.jsx(_,{id:`${r}-endpoint`,type:"url",value:m,onChange:f=>h(f.target.value),required:!0}),o==="local"&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"Use a loopback address. No API key is needed."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-model`,children:"Model ID"}),e.jsx(_,{id:`${r}-model`,value:y,onChange:f=>v(f.target.value),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-context`,children:"Context tokens"}),e.jsx(_,{id:`${r}-context`,type:"number",min:1,value:O,onChange:f=>M(f.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-output`,children:"Output tokens"}),e.jsx(_,{id:`${r}-output`,type:"number",min:1,value:I,onChange:f=>w(f.target.value),required:!0})]})]}),o==="api-key"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:`${r}-key`,children:"API key"}),e.jsx(ne,{id:`${r}-key`,value:P,onChange:f=>N(f.target.value),autoComplete:"off"}),ee&&e.jsx("p",{className:"text-muted-foreground text-xs",children:"API key saved. Leave blank to keep it."})]})]}),L&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:L}),e.jsx(C,{type:"submit",disabled:H.isPending,children:H.isPending?"Saving…":n?"Save":"Save model settings"})]})}const Ds={openai:"OpenAI",anthropic:"Anthropic"};function Ts(s){return Ds[s]??s}function Ms(s){switch(s){case"ollama":return"On your computer (Ollama)";case"openrouter":return"Cloud via OpenRouter";default:return`Your own API key (${Ts(s)})`}}const qe="ollama",Fe=["runtime-connect","ollama"];function qs(s){const t=b();return z({queryKey:Fe,queryFn:()=>t.detectOllama(),enabled:s,staleTime:3e4})}function Fs(){const s=b(),t=D(),n=R({mutationFn:i=>s.updateConfig({runtimes:{opencode:{provider:qe}}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]})}});return{connect:i=>n.mutate(i),isPending:n.isPending,isSuccess:n.isSuccess,isError:n.isError,errorMessage:n.isError?n.error.message??"Couldn’t connect to Ollama.":null}}const $e=["runtime-connect","opencode","direct"];function $s(){const s=b();return z({queryKey:$e,queryFn:()=>s.getOpenCodeDirectSetup(),staleTime:3e4})}function _s(){var i;const s=b(),t=R({mutationFn:({providerId:a,key:r,baseURL:l})=>s.checkProviderCredential(a,r.trim().length>0?r:null,(l==null?void 0:l.trim())||null),meta:{suppressErrorToast:!0}}),n=t.data??(t.isError?{ok:!1,reason:"unexpected",message:t.error.message||"Couldn’t check the key."}:null);return{check:a=>t.mutate(a),isPending:t.isPending,result:n,checkedSavedKey:n!==null&&(((i=t.variables)==null?void 0:i.key)??"").trim().length===0,reset:t.reset}}function Us(){var l,o,c;const s=b(),t=D(),[n,i]=x.useState(null),a=R({mutationFn:async({providerId:u,key:d,baseURL:m})=>{const h=(m==null?void 0:m.trim())||null;i("checking");const p=await s.checkProviderCredential(u,d.trim().length>0?d:null,h);return p.ok?(i("saving"),await s.storeProviderCredential(u,d,h),{saved:!0,message:null}):{saved:!1,message:p.message}},onSettled:()=>i(null),meta:{suppressErrorToast:!0},onSuccess:u=>{u.saved&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}),t.invalidateQueries({queryKey:[...$e]}))}}),r=((l=a.data)==null?void 0:l.saved)===!1;return{connect:u=>{u.providerId.trim().length!==0&&a.mutate(u)},isPending:a.isPending,phase:n,isSuccess:((o=a.data)==null?void 0:o.saved)===!0,isError:a.isError||r,errorMessage:r?((c=a.data)==null?void 0:c.message)??null:a.isError?a.error.message??"Couldn’t save your key.":null,reset:a.reset}}function zs(s){const t=b();return z({queryKey:["runtime-connect","ollama","catalog"],queryFn:()=>t.getOllamaModelCatalog(),enabled:s,staleTime:6e4})}function Qs(){var o,c;const s=b(),t=D(),[n,i]=x.useState(null),a=R({mutationFn:async u=>{i(null);const d=await s.pullOllamaModel(u,m=>i(m));return d.ok&&await s.updateConfig({runtimes:{opencode:{provider:qe}}}),d},onSuccess:u=>{u.ok&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}))}}),r=a.isError||((o=a.data)==null?void 0:o.ok)===!1,l=a.isError?a.error.message:((c=a.data)==null?void 0:c.error)??null;return{pull:u=>a.mutate(u),isPending:a.isPending,isError:r,errorMessage:r?l??"Couldn’t download the model.":null,progress:n,result:a.data}}function Bs(){var o,c;const s=b(),t=D(),[n,i]=x.useState(null),a=R({mutationFn:()=>(i(null),s.provisionOllama(u=>i(u))),onSuccess:u=>{u.ok&&(t.invalidateQueries({queryKey:Fe}),t.invalidateQueries({queryKey:[...T]}))}}),r=a.isError||((o=a.data)==null?void 0:o.ok)===!1,l=a.isError?a.error.message:((c=a.data)==null?void 0:c.error)??null;return{provision:()=>a.mutate(),isPending:a.isPending,isError:r,errorMessage:r?l??"Couldn’t install Ollama.":null,progress:n,result:a.data}}const Gs="https://ollama.com/download",Ws="curl -fsSL https://ollama.com/install.sh | sh";function Ys({installMethod:s}){const t=Bs(),n=s==="brew"||s==="winget";return e.jsxs("div",{className:"space-y-3","data-testid":"ollama-absent",children:[e.jsx(Vs,{}),n?e.jsx(Hs,{provision:t}):e.jsx(Js,{}),e.jsx(Xs,{})]})}function Vs(){const s=Ke();return e.jsxs("div",{className:"space-y-1.5","data-testid":"ollama-explainer",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Run AI models on ",s]}),e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Ollama is a free app that runs AI models on ",s,"."]}),e.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:["Nothing you type leaves ",s,"."]})]})}function Hs({provision:s}){var t,n,i;return s.isPending?e.jsx(A,{message:((t=s.progress)==null?void 0:t.message)??"Installing Ollama…"}):(n=s.result)!=null&&n.ok?(i=s.result.status)!=null&&i.running?e.jsx(A,{message:"Ollama is ready…"}):e.jsx("p",{className:"text-xs","data-testid":"ollama-installed-not-running",children:"Ollama isn’t running. Open the Ollama app to start it."}):s.isError?e.jsx(Q,{message:s.errorMessage??"Couldn’t install Ollama.",onRetry:s.provision}):e.jsx(C,{size:"sm",onClick:s.provision,"data-testid":"ollama-install-oneclick",children:"Install Ollama"})}function Js(){return e.jsxs("div",{className:"space-y-2","data-testid":"ollama-manual-install",children:[e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:"Installing Ollama needs administrator access. Run this in a terminal:"}),e.jsx(Cs,{command:Ws,copyLabel:"Copy the Ollama install command"})]})}function Xs(){return e.jsxs("a",{href:Gs,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Or download Ollama from ollama.com ",e.jsx(Y,{className:"size-3"})]})}const Zs="https://ollama.com/library",et={"runs-well":{label:"Runs well on your machine",tone:"text-status-success-fg"},"may-be-slow":{label:"May be slow on your machine",tone:"text-status-warning-fg"},"too-large":{label:"Too large for your machine",tone:"text-destructive"}},st={frontier:"Frontier","solid-coder":"Solid coder","quick-helper":"Quick helper"};function tt({active:s,onConnected:t,onConnectDirectly:n}){var I,w,P,N,L,E;const i=qs(s),a=Fs(),r=Qs(),l=((I=i.data)==null?void 0:I.running)??!1,o=zs(l),[c,u]=x.useState(null),[d,m]=x.useState(null);x.useEffect(()=>{a.isSuccess&&(t==null||t(Pe))},[a.isSuccess,t]),x.useEffect(()=>{var k;(k=r.result)!=null&&k.ok&&(t==null||t(Pe))},[(w=r.result)==null?void 0:w.ok,t]);const h=k=>{u(k),a.connect(k)},p=k=>{m(k),r.pull(k)};if(i.isPending)return e.jsx(A,{message:"Looking for Ollama on your machine…"});if(!l)return e.jsx(Ys,{installMethod:(P=i.data)==null?void 0:P.installMethod});if(a.isSuccess)return t?null:e.jsx(U,{message:"Connected to Ollama"});if((N=r.result)!=null&&N.ok)return t?null:e.jsxs("div",{className:"text-status-success-fg flex items-center gap-2 rounded-lg px-3 py-2.5 text-xs","data-testid":"guided-pull-connected",children:[e.jsx(ue,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:"Connected:"}),e.jsx(ns,{runtime:"opencode",model:r.result.model,className:"text-xs"})]});const g=i.data,y=(g==null?void 0:g.installed)??[],v=((L=g==null?void 0:g.installed)==null?void 0:L.length)??(g==null?void 0:g.models.length)??0,O=((E=o.data)==null?void 0:E.models.some(k=>k.model.id===d))??!1,M=d!==null&&!O?d:null;return e.jsxs("div",{className:"space-y-4","data-testid":"ollama-running",children:[e.jsx(nt,{count:v}),y.length>0&&e.jsx(rt,{installed:y,connect:a,connectingId:c,onUse:h}),e.jsx(at,{catalogQuery:o,pull:r,pullingId:d,onGet:p}),e.jsx(it,{pull:r,activePull:M,onSubmit:p}),e.jsx(ot,{}),n&&e.jsxs("button",{type:"button",onClick:n,"data-testid":"local-connect-directly",className:"focus-ring text-muted-foreground hover:text-foreground block rounded-md text-left text-xs transition-colors",children:["Using LM Studio or another server? ",e.jsx("span",{className:"underline",children:"Connect it directly"})]})]})}function nt({count:s}){return e.jsxs("p",{className:"flex items-center gap-1.5 text-xs","data-testid":"ollama-status-line",children:[e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-emerald-500","aria-hidden":!0}),e.jsxs("span",{children:["Ollama is running · ",s," ",s===1?"model":"models"," installed"]})]})}function _e({verdict:s,explanation:t}){const n=et[s];return e.jsxs("div",{"data-testid":"ollama-verdict","data-verdict":s,children:[e.jsx("p",{className:V("text-xs font-medium",n.tone),children:n.label}),e.jsx("p",{className:"text-muted-foreground/80 text-2xs leading-snug",children:t})]})}function Ue({tier:s}){return e.jsx(De,{size:"xs",variant:"outline",className:"font-normal",children:st[s]})}function rt({installed:s,connect:t,connectingId:n,onUse:i}){return e.jsxs("div",{className:"space-y-2","data-testid":"ollama-installed",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Installed"}),e.jsx("ul",{className:"space-y-1.5",children:s.map(a=>{const r=n===a.id&&t.isPending,l=n===a.id&&t.isError,o=()=>i(a.id);let c=e.jsx(C,{size:"sm",onClick:o,children:"Use"});return r?c=e.jsx(A,{message:"Connecting…"}):l&&(c=e.jsx(Q,{message:t.errorMessage??"Couldn’t connect to Ollama.",onRetry:o})),e.jsxs("li",{className:"border-border flex items-center justify-between gap-3 rounded-lg border p-3","data-testid":"ollama-installed-item",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:a.id}),a.assessment.model.tier&&e.jsx(Ue,{tier:a.assessment.model.tier})]}),e.jsx(_e,{verdict:a.assessment.verdict,explanation:a.assessment.explanation})]}),c]},a.id)})})]})}function at({catalogQuery:s,pull:t,pullingId:n,onGet:i}){var r;if(s.isPending)return e.jsx(A,{message:"Checking which models fit your machine…"});const a=((r=s.data)==null?void 0:r.models)??[];return s.isError||a.length===0?null:e.jsxs("div",{className:"space-y-2","data-testid":"ollama-shelf",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add a model"}),e.jsx("ul",{className:"space-y-1.5",children:a.map(({model:l,verdict:o,explanation:c})=>{const u=n===l.id,d=()=>i(l.id);return u&&(t.isPending||t.isError)?e.jsxs("li",{className:"border-border rounded-lg border p-3","data-testid":"shelf-item",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:l.label}),t.isPending?e.jsx(ze,{progress:t.progress}):e.jsx(Q,{message:t.errorMessage??"Couldn’t download the model.",onRetry:d})]},l.id):e.jsxs("li",{className:"border-border flex items-center justify-between gap-3 rounded-lg border p-3","data-testid":"shelf-item",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:l.label}),l.tier&&e.jsx(Ue,{tier:l.tier}),e.jsx("span",{className:"text-muted-foreground text-xs",children:l.sizeLabel})]}),e.jsx(_e,{verdict:o,explanation:c})]}),e.jsx(C,{size:"sm",variant:"outline",disabled:o==="too-large"||t.isPending,onClick:d,children:"Get"})]},l.id)})})]})}function it({pull:s,activePull:t,onSubmit:n}){const[i,a]=x.useState(""),r=i.trim(),l=ps.test(r);if(t&&s.isPending)return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Downloading ",t,"…"]}),e.jsx(ze,{progress:s.progress})]});const o=c=>{c.preventDefault(),l&&n(r)};return e.jsxs("form",{onSubmit:o,className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"ollama-pull-tag",className:"text-xs font-normal",children:"Download any model by name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{id:"ollama-pull-tag","data-testid":"ollama-pull-by-name",value:i,onChange:c=>a(c.target.value),placeholder:"qwen2.5-coder:32b","aria-invalid":r.length>0&&!l}),e.jsx(C,{type:"submit",size:"sm",disabled:!l||s.isPending,children:"Download"})]}),r.length>0&&!l&&e.jsxs("p",{className:"text-muted-foreground text-2xs",children:["Use a tag like ",e.jsx("code",{className:"text-2xs",children:"qwen2.5-coder:32b"}),"."]}),t&&s.isError&&e.jsx(Q,{message:s.errorMessage??"Couldn’t download the model.",onRetry:()=>n(t)})]})}function ot(){return e.jsxs("a",{href:Zs,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Browse the library ",e.jsx(Y,{className:"size-3"})]})}function ze({progress:s}){const t=Ae(),n=s==null?void 0:s.percent,i=(s==null?void 0:s.status)??"Starting download…";return e.jsxs("div",{className:"space-y-2","data-testid":"guided-pull-progress",children:[e.jsx("div",{className:"bg-muted h-2 w-full overflow-hidden rounded-full",children:n===void 0?e.jsx(te.div,{className:"bg-primary/70 h-full w-1/3 rounded-full",animate:t?{}:{x:["-100%","300%"]},transition:{duration:1.2,repeat:1/0,ease:"easeInOut"}}):e.jsx(te.div,{className:"bg-primary h-full rounded-full",initial:!1,animate:{width:`${Math.min(100,Math.max(0,n))}%`},transition:t?{duration:0}:{duration:.3,ease:"easeOut"},"data-testid":"guided-pull-bar"})}),e.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-xs",children:[e.jsx(de,{size:"xs",className:V("shrink-0",t&&"animate-none")}),e.jsxs("span",{className:"truncate",children:[i,n!==void 0?` · ${Math.round(n)}%`:""]})]})]})}function lt(){var r,l,o;const s=b(),t=D(),n=R({mutationFn:c=>s.storeOpenRouterKey(c),onSuccess:c=>{c.ok&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}))}}),i=n.isError||((r=n.data)==null?void 0:r.ok)===!1,a=n.isError?n.error.message:((l=n.data)==null?void 0:l.error)??null;return{store:c=>{c.trim().length!==0&&n.mutate(c)},isPending:n.isPending,isSuccess:((o=n.data)==null?void 0:o.ok)===!0,isError:i,errorMessage:i?a??"Couldn’t save the OpenRouter key.":null}}function ct(){var h,p;const s=b(),t=D(),[n,i]=x.useState(null),[a,r]=x.useState(null),l=R({mutationFn:()=>s.startOpenRouterOAuth(),onMutate:()=>r(null),onSuccess:({authorizeUrl:g,state:y})=>{if(!rs(g)){r("Couldn’t open the OpenRouter sign-in page.");return}i(y)},onError:g=>r(g.message??"Couldn’t start OpenRouter sign-in.")}),o=z({queryKey:["runtime-connect","openrouter","oauth",n],queryFn:()=>s.getOpenRouterOAuthStatus(n),enabled:n!==null,refetchInterval:g=>{var y;return((y=g.state.data)==null?void 0:y.status)==="pending"?1500:!1},refetchOnWindowFocus:g=>{var y;return((y=g.state.data)==null?void 0:y.status)==="error"}}),c=(h=o.data)==null?void 0:h.status;x.useEffect(()=>{c==="connected"&&(t.invalidateQueries({queryKey:[...F]}),t.invalidateQueries({queryKey:[...T]}))},[c,t]);const u=l.isPending||n!==null&&c==="pending",d=!!a||c==="error",m=d?a??((p=o.data)==null?void 0:p.error)??"Couldn’t sign in to OpenRouter. Try again.":null;return{begin:()=>l.mutate(),isPending:u,isSuccess:c==="connected",isError:d,errorMessage:m}}const dt="https://openrouter.ai/keys";function ut({onConnected:s}){const[t,n]=x.useState(""),i=lt(),a=ct(),r=i.isSuccess||a.isSuccess;return x.useEffect(()=>{r&&(s==null||s(Es))},[r,s]),r?e.jsx(U,{message:"Connected to OpenRouter"}):e.jsxs("div",{className:"space-y-4","data-testid":"openrouter-gateway",children:[e.jsx("div",{className:"space-y-2",children:a.isPending?e.jsx(A,{message:"Sign in to OpenRouter in the new tab…"}):a.isError?e.jsx(Q,{message:a.errorMessage??"Couldn’t sign in to OpenRouter.",onRetry:a.begin}):e.jsxs(e.Fragment,{children:[e.jsx(C,{size:"sm",className:"w-full",onClick:a.begin,children:"Connect OpenRouter"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Makes a limited key for you."})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"bg-border h-px flex-1"}),e.jsx("span",{className:"text-muted-foreground text-2xs tracking-wide uppercase",children:"or"}),e.jsx("span",{className:"bg-border h-px flex-1"})]}),i.isPending?e.jsx(A,{message:"Checking your OpenRouter key…"}):e.jsxs("form",{className:"space-y-2",onSubmit:l=>{l.preventDefault(),i.store(t)},children:[e.jsx(S,{htmlFor:"openrouter-key",className:"text-xs",children:"OpenRouter key"}),e.jsx(ne,{id:"openrouter-key",value:t,onChange:l=>n(l.target.value),placeholder:"sk-or-…",autoComplete:"off",spellCheck:!1}),i.isError&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:i.errorMessage}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("a",{href:dt,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an OpenRouter key ",e.jsx(Y,{className:"size-3"})]}),e.jsx(C,{type:"submit",size:"sm",variant:"outline",disabled:t.trim().length===0,children:"Save key"})]})]})]})}const se="other";function Z(s){return W.find(t=>t.id===s)}function mt(s){var t;return((t=Z(s))==null?void 0:t.id)??"openai"}function ce(s){var t;return((t=W.find(n=>n.id===s))==null?void 0:t.defaultBaseURL)??W[0].defaultBaseURL}function Qe(s){return W.some(t=>t.id===s.providerId)}function ie(s){return Qe(s)?s.providerId==="anthropic"?"anthropic":s.baseURL===null||s.baseURL===ce(s.providerId)?s.providerId:se:"openai"}function xt({onConnected:s}){const t=$s();return t.isError&&!t.data?e.jsx(Q,{message:"Couldn’t load your saved settings.",onRetry:()=>void t.refetch()}):t.data?e.jsx(ht,{setup:t.data,onConnected:s},`${t.data.providerId??""}|${t.data.baseURL??""}`):e.jsx(A,{message:"Loading what you saved…"})}function ht({setup:s,onConnected:t}){var X;const n=Qe(s)?s:null,[i,a]=x.useState(()=>ie(s)),[r,l]=x.useState(""),[o,c]=x.useState(()=>{var j;return(n==null?void 0:n.baseURL)??((j=Z(ie(s)))==null?void 0:j.defaultBaseURL)??""}),[u,d]=x.useState(()=>{var $;const j=ie(s);return j!==se&&n!==null&&n.baseURL!==null&&n.baseURL!==(($=Z(j))==null?void 0:$.defaultBaseURL)}),m=Us(),h=_s(),p=Z(i),g=mt(i),y=n!=null&&n.key.saved&&n.providerId===g?n.key.last4:null,v=o.trim(),O=i===se,M=!O||v.length>0,I=ce(g),w=v||I,P=w===I?"":w,N=n===null?null:n.baseURL??ce(n.providerId),L=g!==((n==null?void 0:n.providerId)??null)||w!==N,E=r.trim().length>0,q=(E||y!==null&&!L)&&M,ee=E&&M,H=!E&&y!==null&&L,re=w.startsWith("http://"),B={providerId:g,key:r,baseURL:P},K=m.isPending||h.isPending,J=x.useRef(null),G=()=>{h.reset(),m.reset()};return x.useEffect(()=>{m.isSuccess&&(t==null||t(ws))},[m.isSuccess,t]),x.useEffect(()=>{var j;m.isError&&((j=J.current)==null||j.focus())},[m.isError]),m.isSuccess?e.jsx(U,{}):e.jsxs("form",{className:"space-y-3","data-testid":"direct-provider",onSubmit:j=>{j.preventDefault(),h.reset(),m.connect(B)},children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"direct-provider-source",className:"text-xs",children:"Power source"}),e.jsxs(as,{value:i,disabled:K,onValueChange:j=>{var $;a(j),c((($=Z(j))==null?void 0:$.defaultBaseURL)??""),G()},children:[e.jsx(is,{id:"direct-provider-source","data-testid":"direct-provider-source",children:e.jsx(os,{})}),e.jsxs(ls,{children:[W.map(j=>e.jsx(be,{value:j.id,children:j.label},j.id)),e.jsx(be,{value:se,children:"Other (OpenAI-compatible)"})]})]})]}),(O||u)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(S,{htmlFor:"direct-provider-base-url",className:"text-xs",children:["Base URL ",!O&&e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(_,{id:"direct-provider-base-url",value:o,disabled:K,onChange:j=>{c(j.target.value),G()},placeholder:"https://api.example.com/v1",autoComplete:"off",spellCheck:!1})]}),!O&&!u&&e.jsx("button",{type:"button",onClick:()=>d(!0),disabled:K,"data-testid":"direct-provider-advanced",className:"text-muted-foreground hover:text-foreground text-xs underline decoration-dotted underline-offset-2 transition-colors",children:"Advanced"}),re&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"direct-provider-insecure",children:"This address isn’t encrypted. Your key travels in the open."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"direct-provider-key",className:"text-xs",children:"API key"}),e.jsx(ne,{id:"direct-provider-key",ref:J,value:r,disabled:K,onChange:j=>{l(j.target.value),G()},placeholder:y===null?(p==null?void 0:p.keyPlaceholder)??W[0].keyPlaceholder:`Saved key ends in ${y}. Paste to replace.`,autoComplete:"off",spellCheck:!1})]}),m.isError&&e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:m.errorMessage}),H&&e.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"direct-provider-repaste",children:"Paste your key again to change the address."}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p===void 0?e.jsx("span",{}):e.jsxs("a",{href:p.getKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:["Get an API key ",e.jsx(Y,{className:"size-3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",size:"sm",variant:"outline",disabled:!q||K,"data-testid":"direct-provider-test",onClick:()=>{m.reset(),h.reset(),h.check(B)},children:"Test key"}),e.jsx(C,{type:"submit",size:"sm",disabled:!ee||K,children:"Save & connect"})]})]}),K?e.jsx(A,{message:m.phase==="saving"?"Saving…":"Checking your key…"}):((X=h.result)==null?void 0:X.ok)===!0?e.jsx(U,{message:h.checkedSavedKey?"Your saved key works":"Key works"}):h.result?e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:h.result.message}):null]})}function ft({currentProvider:s,onConnected:t}){const[n,i]=x.useState("choose"),a=gt();if(n==="choose")return e.jsx(pt,{sources:a,onChoose:i,currentProvider:s});const r=()=>i("choose");return n==="cloud"?e.jsx(oe,{source:a.cloud,onBack:r,children:e.jsx(ut,{onConnected:t})}):n==="local"?e.jsx(oe,{source:a.local,onBack:r,children:e.jsx(tt,{active:!0,onConnected:t,onConnectDirectly:()=>i("direct")})}):e.jsx(oe,{source:a.direct,onBack:r,children:e.jsx(xt,{onConnected:t})})}function gt(){return{cloud:{step:"cloud",title:"Best models, zero setup",description:"Claude, GPT, Gemini and 300+ more, in the cloud.",sub:"One OpenRouter account covers them all. Pay for what you use.",tradeOff:"Your prompts and code are sent to the model’s provider.",recommended:!0},local:{step:"local",title:"Private and free, on your computer",description:`Models run on ${Ke()}. Nothing you type ever leaves it.`,sub:"Runs Quick helpers and Solid coders. Frontier models stay cloud-only.",tradeOff:"Smaller models: good for edits and quick help."},direct:{step:"direct",title:"Use your own API key",stepTitle:"Your own API key",description:"Anthropic, OpenAI, or any OpenAI-compatible server, like LM Studio.",sub:"",quiet:!0}}}function pt({sources:s,onChoose:t,currentProvider:n}){return e.jsxs("div",{className:"space-y-2","data-testid":"opencode-power-sources",children:[n&&e.jsxs("p",{className:"text-muted-foreground text-xs","data-testid":"opencode-current-source",children:["Currently: ",Ms(n)]}),Object.values(s).map(i=>e.jsx(yt,{source:i,onChoose:t},i.step))]})}function yt({source:s,onChoose:t}){return e.jsxs("button",{type:"button",onClick:()=>t(s.step),"data-testid":`power-source-${s.step}`,className:V("card-interactive focus-ring group flex w-full items-start gap-3 rounded-lg border p-3 text-left",s.recommended?"border-primary/40 bg-card shadow-soft":"border-border bg-card shadow-soft",s.quiet&&"shadow-none"),children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.title}),s.recommended&&e.jsx(De,{size:"xs",variant:"secondary",children:"Recommended"})]}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s.description})]}),e.jsx(ds,{className:"text-muted-foreground/60 mt-0.5 size-4 shrink-0"})]})}function oe({source:s,onBack:t,children:n}){const i=!!(s.sub||s.tradeOff);return e.jsxs("div",{className:"space-y-3","data-testid":"opencode-connect-step",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:t,className:"focus-ring text-muted-foreground hover:text-foreground -ml-1 inline-flex items-center gap-1 rounded-md px-1 py-0.5 text-xs transition-colors","data-testid":"connect-step-back",children:[e.jsx(cs,{className:"size-3.5"}),"Back"]}),e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsx("span",{className:"text-sm font-medium",children:s.stepTitle??s.title})]}),i&&e.jsxs("div",{className:"space-y-1","data-testid":"connect-step-details",children:[s.sub&&e.jsx("p",{className:"text-muted-foreground/80 text-xs",children:s.sub}),s.tradeOff&&e.jsxs("p",{className:"text-muted-foreground/70 text-2xs leading-snug",children:[e.jsx("span",{className:"font-medium",children:"Trade-off:"})," ",s.tradeOff]})]}),n]})}function jt({type:s,connect:t,currentProvider:n,onConnected:i}){const a=ys(),r=Ps(s),l=us(),o=ms(),c=xs([s]);if(s==="doe")return a?e.jsx(As,{onConnected:i}):e.jsx(Oe,{});const u=r==="lead"&&l!==null,d=a?t.kind==="provider-picker"?e.jsx(ft,{currentProvider:n,onConnected:i}):t.kind==="login"?e.jsx(Is,{type:s,onConnected:i,asOtherWay:u}):null:e.jsx(Oe,{});if(d===null)return null;const m=me(s).label,h=t.kind==="provider-picker";if(r==="on-credits")return e.jsxs("div",{className:"space-y-3","data-testid":`credits-ready-${s}`,children:[e.jsxs("div",{role:"status",children:[e.jsxs("p",{className:"text-status-success-fg flex items-center gap-1.5 text-sm font-medium",children:[e.jsx(ue,{className:"size-3.5","aria-hidden":!0}),"You’re ready"]}),e.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:["New work on ",m," runs on your DorkOS credits.",c.map(g=>` ${g}`).join("")]})]}),e.jsx(le,{collapsed:!0,children:d})]});const p=g=>l==null?void 0:l({runtime:s,origin:`runtime-connect:${s}`,fullWidth:g,onChoose:async()=>{await o.mutateAsync({runtime:s,useCredits:!0}),i==null||i(Rs(m))}});return u?e.jsxs("div",{className:"space-y-4","data-testid":`default-first-${s}`,children:[p(!0),e.jsx(le,{children:d}),e.jsx(Os,{ollama:h,remote:!a})]}):r==="other-way"&&l!==null?e.jsxs("div",{className:"space-y-4","data-testid":`credits-other-way-${s}`,children:[d,e.jsx(le,{children:p(!1)})]}):d}function le({collapsed:s=!1,children:t}){const[n,i]=x.useState(!s);return s?e.jsxs(Re,{open:n,onOpenChange:i,children:[e.jsxs(Ie,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:[e.jsx(hs,{className:V("size-3.5 transition-transform",n&&"rotate-180")}),"Other ways"]}),e.jsx(Le,{className:"mt-3",children:t})]}):e.jsxs("section",{className:"space-y-2","aria-label":"Other ways",children:[e.jsx("p",{className:"text-muted-foreground text-2xs font-medium tracking-wide uppercase",children:"Other ways"}),t]})}const Pt=s=>e.jsx(jt,{...s});export{Ot as C,Cs as D,Os as K,Oe as R,bs as a,ys as b,St as c,Ms as d,Ps as e,As as f,Ss as g,Pt as r,Ct as u};
|
package/dist/client/assets/{RuntimeSetupDialog-DPU4QIY9.js → RuntimeSetupDialog-CEUC7GrY.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,bq as Y,eH as U,eI as G,j as e,eJ as J,eK as Q,bp as W,bn as C,bm as M,eL as V,bo as X,eM as Z,eN as q,eO as ee,bv as te,eP as ne,aJ as se,a9 as re,eQ as ae,ea as oe,eR as z,d2 as ie,d3 as ce,d5 as le,d6 as de,d7 as ue,eD as fe,ef as k,J as D,B as S,e4 as A,eS as me,G as E,Q as xe,T as pe,U as ve,V as he,bX as ge,ar as I,x as Ce,by as be}from"./index-B6Scr7KJ.js";import{I as je}from"./inline-code-BKPMIXZR.js";import{l as Re}from"./list-runtime-types-BhkZkTrB.js";import{D as O,u as Ne,C as Pe}from"./RuntimeConnectFlow-D3H5Fpkc.js";var Se=Object.defineProperty,b=(t,n)=>Se(t,"name",{value:n,configurable:!0}),T,_="HoverCard",[F,Ze]=Y(_,[U]),L=U(),[we,H]=F(_),He=b(t=>{const{__scopeHoverCard:n,children:r,open:o,defaultOpen:s,onOpenChange:c,openDelay:a=700,closeDelay:f=300}=t,x=L(n),i=l.useRef(0),p=l.useRef(0),v=l.useRef(!1),g=l.useRef(!1),[u,m]=G({prop:o,defaultProp:s??!1,onChange:c,caller:_}),d=l.useCallback(()=>{clearTimeout(p.current),i.current=window.setTimeout(()=>m(!0),a)},[a,m]),j=l.useCallback(()=>{clearTimeout(i.current),!v.current&&!g.current&&(p.current=window.setTimeout(()=>m(!1),f))},[f,m]),h=l.useCallback(()=>m(!1),[m]);return l.useEffect(()=>()=>{clearTimeout(i.current),clearTimeout(p.current)},[]),e.jsx(we,{scope:n,open:u,onOpenChange:m,onOpen:d,onClose:j,onDismiss:h,hasSelectionRef:v,isPointerDownOnContentRef:g,children:e.jsx(J,{...x,children:r})})},"HoverCard"),Te="HoverCardTrigger",ye=l.forwardRef(b(function(n,r){const{__scopeHoverCard:o,...s}=n,c=H(Te,o),a=L(o);return e.jsx(Q,{asChild:!0,...a,children:e.jsx(W.a,{"data-state":c.open?"open":"closed",...s,ref:r,onPointerEnter:C(n.onPointerEnter,w(c.onOpen)),onPointerLeave:C(n.onPointerLeave,w(c.onClose)),onFocus:C(n.onFocus,c.onOpen),onBlur:C(n.onBlur,c.onClose),onTouchStart:C(n.onTouchStart,f=>f.preventDefault())})})},"HoverCardTrigger")),B="HoverCardPortal",[ke,De]=F(B,{forceMount:void 0}),Ee=b(t=>{const{__scopeHoverCard:n,forceMount:r,children:o,container:s}=t,c=H(B,n);return e.jsx(ke,{scope:n,forceMount:r,children:e.jsx(M,{present:r||c.open,children:e.jsx(V,{asChild:!0,container:s,children:o})})})},"HoverCardPortal"),y="HoverCardContent",Oe=l.forwardRef(b(function(n,r){const o=De(y,n.__scopeHoverCard),{forceMount:s=o.forceMount,...c}=n,a=H(y,n.__scopeHoverCard);return e.jsx(M,{present:s||a.open,children:e.jsx(_e,{"data-state":a.open?"open":"closed",...c,onPointerEnter:C(n.onPointerEnter,w(a.onOpen)),onPointerLeave:C(n.onPointerLeave,w(a.onClose)),ref:r})})},"HoverCardContent")),_e=l.forwardRef(b(function(n,r){const{__scopeHoverCard:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:a,onInteractOutside:f,...x}=n,i=H(y,o),p=L(o),v=l.useRef(null),g=X(r,v),[u,m]=l.useState(!1);return l.useEffect(()=>{if(u){const d=document.body;return T=d.style.userSelect||d.style.webkitUserSelect,d.style.userSelect="none",d.style.webkitUserSelect="none",()=>{d.style.userSelect=T,d.style.webkitUserSelect=T}}},[u]),l.useEffect(()=>{if(v.current){const d=b(()=>{m(!1),i.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var h;((h=document.getSelection())==null?void 0:h.toString())!==""&&(i.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",d),()=>{document.removeEventListener("pointerup",d),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!1}}},[i.isPointerDownOnContentRef,i.hasSelectionRef]),l.useEffect(()=>{v.current&&K(v.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(Z,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:f,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:C(a,d=>{d.preventDefault()}),onDismiss:i.onDismiss,children:e.jsx(q,{...p,...x,onPointerDown:C(x.onPointerDown,d=>{d.currentTarget.contains(d.target)&&m(!0),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!0}),ref:g,style:{...x.style,userSelect:u?"text":void 0,WebkitUserSelect:u?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function w(t){return n=>n.pointerType==="touch"?void 0:t()}b(w,"excludeTouch");function K(t){const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:b(o=>o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;r.nextNode();)n.push(r.currentNode);return n}b(K,"getTabbableNodes");var Le=He,$e=ye,Ie=Ee,Ue=Oe;function qe({...t}){return e.jsx(Le,{"data-slot":"hover-card",...t})}function et({...t}){return e.jsx($e,{"data-slot":"hover-card-trigger",...t})}function tt({className:t,align:n="center",sideOffset:r=4,...o}){const s=ee();return e.jsx(Ie,{"data-slot":"hover-card-portal",container:s,children:e.jsx(Ue,{"data-slot":"hover-card-content",align:n,sideOffset:r,className:te("bg-dui-popover text-dui-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-dui-border z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden motion-reduce:animate-none!",t),...o})})}function Me(t,n,r){return r?ne(t)==="provider-picker"?n?{idPrefix:"change",triggerLabel:"Change",cancelLabel:"Keep current source",connect:{kind:"provider-picker",label:"Change power source"},currentProvider:n}:null:se.includes(t)?{idPrefix:"reconnect",triggerLabel:"Fix sign-in",cancelLabel:"Keep current sign-in",connect:{kind:"login",label:`Reconnect ${re(t)}`}}:null:null}function ze(t,n,r){return t?[t]:n||Re(r)}function Ae({runtime:t,types:n,requirements:r,registeredTypes:o=[],onRecheck:s,isRechecking:c=!1,renderConnect:a}){const f=A(),x=ze(t,n,o);return e.jsxs("div",{className:"space-y-4","data-testid":"runtime-setup-panel",children:[x.map(i=>e.jsx(Fe,{type:i,requirements:r,registered:o.includes(i),renderConnect:a},i)),s&&e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Refresh after connecting."}),e.jsxs(S,{variant:"outline",size:"sm",className:"gap-2",onClick:s,disabled:c,children:[e.jsx(me,{className:E("size-3.5",c&&!f&&"animate-spin")}),"Check again"]})]})]})}function Fe({type:t,requirements:n,registered:r,renderConnect:o}){var N,P,$;const s=k(t),c=s.icon,a=n==null?void 0:n.runtimes[t],f=z(n,t,r),x=f.state==="ready",[i,p]=l.useState(!1),[v,g]=l.useState(!1);!x&&v&&g(!1);const u=x?Me(t,a==null?void 0:a.provider,!!o):null,m=a==null?void 0:a.dependencies.find(R=>R.status!=="satisfied"&&R.installHint),d=(m==null?void 0:m.installHint)??((N=s.setup)==null?void 0:N.installCommand),j=(m==null?void 0:m.infoUrl)??((P=s.setup)==null?void 0:P.infoUrl),h=!!a||!!s.setup;return e.jsxs("section",{className:"border-border rounded-xl border p-4","data-testid":`runtime-section-${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{className:"size-4"}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]}),x&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-status-success-fg inline-flex items-center gap-1 text-xs","data-testid":`runtime-ready-${t}`,children:[e.jsx(D,{className:"size-3.5"})," Ready"]}),u&&!v&&e.jsx("button",{type:"button",onClick:()=>g(!0),className:"text-muted-foreground hover:text-foreground text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-${u.idPrefix}-${t}`,children:u.triggerLabel})]})]}),u&&v&&e.jsxs("div",{className:"mt-3 space-y-2","data-testid":`runtime-${u.idPrefix}-panel-${t}`,children:[o==null?void 0:o({type:t,connect:u.connect,...u.currentProvider?{currentProvider:u.currentProvider}:{},onConnected:()=>g(!1)}),e.jsx("button",{type:"button",onClick:()=>g(!1),className:"text-muted-foreground hover:text-foreground text-xs transition-colors","data-testid":`runtime-${u.idPrefix}-cancel-${t}`,children:u.cancelLabel})]}),f.state==="unknown"&&e.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:($=a==null?void 0:a.dependencies.find(R=>R.status==="unknown"))==null?void 0:$.description}),!x&&f.connect&&e.jsx("div",{className:"mt-3",children:e.jsx(Be,{type:t,connect:f.connect,renderConnect:o,installCommand:d,installInfoUrl:j,onShowDetails:()=>p(!0)})}),h&&e.jsxs(xe,{open:i,onOpenChange:p,className:"mt-3",children:[e.jsxs(pe,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:[e.jsx(ve,{className:E("size-3.5 transition-transform",i&&"rotate-180")}),"Setup details"]}),e.jsx(he,{className:"mt-3 space-y-3",children:a?a.dependencies.map(R=>e.jsx(Ge,{dep:R},R.name)):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not registered with this server. Install it, then enable"," ",e.jsxs(je,{children:["runtimes.",t]})," in your DorkOS config."]}),s.setup&&e.jsx(O,{command:s.setup.installCommand,infoUrl:s.setup.infoUrl,copyLabel:`Copy install command for ${s.label}`})]})})]})]})}function Be({type:t,connect:n,renderConnect:r,installCommand:o,installInfoUrl:s,onShowDetails:c}){return n.kind==="install"?e.jsx(Ke,{type:t,label:n.label,installCommand:o,installInfoUrl:s}):r&&(n.kind==="login"||n.kind==="provider-picker")?e.jsx(e.Fragment,{children:r({type:t,connect:n})}):e.jsx(S,{size:"sm",onClick:c,children:n.label})}function Ke({type:t,label:n,installCommand:r,installInfoUrl:o}){const s=k(t),{provision:c,isPending:a,isError:f,errorMessage:x,progress:i,result:p}=Ne(t);return a||p!=null&&p.ok?e.jsx(Ye,{message:(i==null?void 0:i.message)??`Installing ${s.label}…`}):f?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:x}),r&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can install it yourself instead:"}),e.jsx(O,{command:r,infoUrl:o,copyLabel:`Copy install command for ${s.label}`})]}),e.jsx(S,{size:"sm",onClick:c,children:"Try again"})]}):e.jsxs("div",{children:[e.jsx(S,{size:"sm",onClick:c,children:n}),r&&e.jsx(Pe,{command:r,runtimeLabel:s.label})]})}function Ye({message:t}){const n=A();return e.jsxs(I.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:n?!1:{opacity:0},animate:{opacity:1},"data-testid":"provision-progress",children:[e.jsx(Ce,{size:"xs",className:E("text-muted-foreground shrink-0",n&&"animate-none")}),e.jsx(be,{mode:"wait",children:e.jsx(I.span,{className:"truncate text-xs",initial:n?!1:{opacity:0},animate:{opacity:1},exit:n?void 0:{opacity:0},transition:{duration:.2},children:t},t)})]})}function Ge({dep:t}){const n=t.status==="satisfied";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-x-2",children:[n?e.jsx(D,{className:"text-status-success size-3.5 shrink-0"}):e.jsx(ge,{className:"text-status-warning-dot size-3.5 shrink-0"}),e.jsx("span",{className:"text-sm",children:t.name}),e.jsx("p",{className:"text-muted-foreground col-start-2 mt-1 text-xs",children:n&&t.version?`v${t.version}`:t.description})]}),!n&&(t.installHint||t.infoUrl)&&e.jsx(O,{command:t.installHint,infoUrl:t.infoUrl,copyLabel:`Copy install command for ${t.name}`})]})}function nt({runtime:t,open:n,onOpenChange:r,renderConnect:o,onRuntimeReady:s,showConnectSuccess:c=!1}){const a=ae(),{data:f}=oe(),x=t?k(t):null,i=z(a.data,t??"",f?t!==void 0&&t in f.capabilities:!0),p=a.data!==void 0,v=x!==null&&p&&i.state==="ready",g=l.useRef(null);l.useEffect(()=>{if(!n){g.current=null;return}if(t===void 0||!p)return;const h=g.current;g.current={runtime:t,ready:v},h!==null&&h.runtime===t&&!h.ready&&v&&(s==null||s(t))},[n,p,v,t,s]);const[u,m]=l.useState(null),d=l.useRef(n);l.useEffect(()=>{d.current&&!n&&m(null),d.current=n},[n]);const j=o&&(c?h=>o({...h,onConnected:N=>{var P;(P=h.onConnected)==null||P.call(h,N),m(N)}}):o);return e.jsx(ie,{open:n,onOpenChange:r,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(le,{children:[e.jsx(de,{children:x?x.label:"Your runtimes"}),e.jsx(ue,{children:u?"Connected.":x?v?"Ready to use.":"Connect it to start a chat.":"Connect one to start a chat."})]}),e.jsx(fe,{children:u?e.jsx(Je,{success:u,onDone:()=>r(!1)}):e.jsx(Ae,{runtime:t,requirements:a.data,registeredTypes:f?Object.keys(f.capabilities):void 0,onRecheck:()=>void a.refetch(),isRechecking:a.isFetching,renderConnect:j})})]})})}function Je({success:t,onDone:n}){return e.jsxs("div",{className:"space-y-4","data-testid":"runtime-connected-panel",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(D,{className:"text-status-success mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.title}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:t.body})]})]}),e.jsx(S,{size:"sm",className:"w-full",onClick:n,"data-testid":"runtime-connected-done",children:"Done"})]})}export{qe as H,nt as R,et as a,tt as b,Ae as c};
|
|
1
|
+
import{r as l,bo as G,eG as U,eH as Y,j as e,eI as Q,eJ as V,bn as W,bl as C,bk as M,eK as J,bm as X,eL as Z,eM as q,eN as ee,bt as te,eO as ne,aH as se,a7 as re,eP as ae,e9 as oe,eQ as z,d0 as ie,d1 as ce,d3 as le,d4 as de,d5 as ue,eC as fe,ee as y,J as D,B as S,e3 as A,eR as me,G as E,Q as xe,T as pe,U as ve,V as he,bV as ge,ap as I,x as Ce,bw as be}from"./index-fge85Gub.js";import{I as je}from"./inline-code-7dwi7wWG.js";import{l as Re}from"./list-runtime-types-hMouIGtG.js";import{D as O,u as Ne,C as Pe}from"./RuntimeConnectFlow-B0TIITVq.js";var Se=Object.defineProperty,b=(t,n)=>Se(t,"name",{value:n,configurable:!0}),T,_="HoverCard",[F,Ze]=G(_,[U]),L=U(),[we,H]=F(_),He=b(t=>{const{__scopeHoverCard:n,children:r,open:o,defaultOpen:s,onOpenChange:c,openDelay:a=700,closeDelay:f=300}=t,x=L(n),i=l.useRef(0),p=l.useRef(0),v=l.useRef(!1),g=l.useRef(!1),[u,m]=Y({prop:o,defaultProp:s??!1,onChange:c,caller:_}),d=l.useCallback(()=>{clearTimeout(p.current),i.current=window.setTimeout(()=>m(!0),a)},[a,m]),j=l.useCallback(()=>{clearTimeout(i.current),!v.current&&!g.current&&(p.current=window.setTimeout(()=>m(!1),f))},[f,m]),h=l.useCallback(()=>m(!1),[m]);return l.useEffect(()=>()=>{clearTimeout(i.current),clearTimeout(p.current)},[]),e.jsx(we,{scope:n,open:u,onOpenChange:m,onOpen:d,onClose:j,onDismiss:h,hasSelectionRef:v,isPointerDownOnContentRef:g,children:e.jsx(Q,{...x,children:r})})},"HoverCard"),Te="HoverCardTrigger",ke=l.forwardRef(b(function(n,r){const{__scopeHoverCard:o,...s}=n,c=H(Te,o),a=L(o);return e.jsx(V,{asChild:!0,...a,children:e.jsx(W.a,{"data-state":c.open?"open":"closed",...s,ref:r,onPointerEnter:C(n.onPointerEnter,w(c.onOpen)),onPointerLeave:C(n.onPointerLeave,w(c.onClose)),onFocus:C(n.onFocus,c.onOpen),onBlur:C(n.onBlur,c.onClose),onTouchStart:C(n.onTouchStart,f=>f.preventDefault())})})},"HoverCardTrigger")),B="HoverCardPortal",[ye,De]=F(B,{forceMount:void 0}),Ee=b(t=>{const{__scopeHoverCard:n,forceMount:r,children:o,container:s}=t,c=H(B,n);return e.jsx(ye,{scope:n,forceMount:r,children:e.jsx(M,{present:r||c.open,children:e.jsx(J,{asChild:!0,container:s,children:o})})})},"HoverCardPortal"),k="HoverCardContent",Oe=l.forwardRef(b(function(n,r){const o=De(k,n.__scopeHoverCard),{forceMount:s=o.forceMount,...c}=n,a=H(k,n.__scopeHoverCard);return e.jsx(M,{present:s||a.open,children:e.jsx(_e,{"data-state":a.open?"open":"closed",...c,onPointerEnter:C(n.onPointerEnter,w(a.onOpen)),onPointerLeave:C(n.onPointerLeave,w(a.onClose)),ref:r})})},"HoverCardContent")),_e=l.forwardRef(b(function(n,r){const{__scopeHoverCard:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:a,onInteractOutside:f,...x}=n,i=H(k,o),p=L(o),v=l.useRef(null),g=X(r,v),[u,m]=l.useState(!1);return l.useEffect(()=>{if(u){const d=document.body;return T=d.style.userSelect||d.style.webkitUserSelect,d.style.userSelect="none",d.style.webkitUserSelect="none",()=>{d.style.userSelect=T,d.style.webkitUserSelect=T}}},[u]),l.useEffect(()=>{if(v.current){const d=b(()=>{m(!1),i.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var h;((h=document.getSelection())==null?void 0:h.toString())!==""&&(i.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",d),()=>{document.removeEventListener("pointerup",d),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!1}}},[i.isPointerDownOnContentRef,i.hasSelectionRef]),l.useEffect(()=>{v.current&&K(v.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(Z,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:f,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:C(a,d=>{d.preventDefault()}),onDismiss:i.onDismiss,children:e.jsx(q,{...p,...x,onPointerDown:C(x.onPointerDown,d=>{d.currentTarget.contains(d.target)&&m(!0),i.hasSelectionRef.current=!1,i.isPointerDownOnContentRef.current=!0}),ref:g,style:{...x.style,userSelect:u?"text":void 0,WebkitUserSelect:u?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function w(t){return n=>n.pointerType==="touch"?void 0:t()}b(w,"excludeTouch");function K(t){const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:b(o=>o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;r.nextNode();)n.push(r.currentNode);return n}b(K,"getTabbableNodes");var Le=He,$e=ke,Ie=Ee,Ue=Oe;function qe({...t}){return e.jsx(Le,{"data-slot":"hover-card",...t})}function et({...t}){return e.jsx($e,{"data-slot":"hover-card-trigger",...t})}function tt({className:t,align:n="center",sideOffset:r=4,...o}){const s=ee();return e.jsx(Ie,{"data-slot":"hover-card-portal",container:s,children:e.jsx(Ue,{"data-slot":"hover-card-content",align:n,sideOffset:r,className:te("bg-dui-popover text-dui-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-dui-border z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden motion-reduce:animate-none!",t),...o})})}function Me(t,n,r){return r?ne(t)==="provider-picker"?n?{idPrefix:"change",triggerLabel:"Change",cancelLabel:"Keep current source",connect:{kind:"provider-picker",label:"Change power source"},currentProvider:n}:null:se.includes(t)?{idPrefix:"reconnect",triggerLabel:"Fix sign-in",cancelLabel:"Keep current sign-in",connect:{kind:"login",label:`Reconnect ${re(t)}`}}:null:null}function ze(t,n,r){return t?[t]:n||Re(r)}function Ae({runtime:t,types:n,requirements:r,registeredTypes:o=[],onRecheck:s,isRechecking:c=!1,renderConnect:a}){const f=A(),x=ze(t,n,o);return e.jsxs("div",{className:"space-y-4","data-testid":"runtime-setup-panel",children:[x.map(i=>e.jsx(Fe,{type:i,requirements:r,registered:o.includes(i),renderConnect:a},i)),s&&e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"Refresh after connecting."}),e.jsxs(S,{variant:"outline",size:"sm",className:"gap-2",onClick:s,disabled:c,children:[e.jsx(me,{className:E("size-3.5",c&&!f&&"animate-spin")}),"Check again"]})]})]})}function Fe({type:t,requirements:n,registered:r,renderConnect:o}){var N,P,$;const s=y(t),c=s.icon,a=n==null?void 0:n.runtimes[t],f=z(n,t,r),x=f.state==="ready",[i,p]=l.useState(!1),[v,g]=l.useState(!1);!x&&v&&g(!1);const u=x?Me(t,a==null?void 0:a.provider,!!o):null,m=a==null?void 0:a.dependencies.find(R=>R.status!=="satisfied"&&R.installHint),d=(m==null?void 0:m.installHint)??((N=s.setup)==null?void 0:N.installCommand),j=(m==null?void 0:m.infoUrl)??((P=s.setup)==null?void 0:P.infoUrl),h=!!a||!!s.setup;return e.jsxs("section",{className:"border-border rounded-xl border p-4","data-testid":`runtime-section-${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{className:"size-4"}),e.jsx("span",{className:"text-sm font-medium",children:s.label})]}),x&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-status-success-fg inline-flex items-center gap-1 text-xs","data-testid":`runtime-ready-${t}`,children:[e.jsx(D,{className:"size-3.5"})," Ready"]}),u&&!v&&e.jsx("button",{type:"button",onClick:()=>g(!0),className:"text-muted-foreground hover:text-foreground text-xs underline-offset-2 transition-colors hover:underline","data-testid":`runtime-${u.idPrefix}-${t}`,children:u.triggerLabel})]})]}),u&&v&&e.jsxs("div",{className:"mt-3 space-y-2","data-testid":`runtime-${u.idPrefix}-panel-${t}`,children:[o==null?void 0:o({type:t,connect:u.connect,...u.currentProvider?{currentProvider:u.currentProvider}:{},onConnected:()=>g(!1)}),e.jsx("button",{type:"button",onClick:()=>g(!1),className:"text-muted-foreground hover:text-foreground text-xs transition-colors","data-testid":`runtime-${u.idPrefix}-cancel-${t}`,children:u.cancelLabel})]}),f.state==="unknown"&&e.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:($=a==null?void 0:a.dependencies.find(R=>R.status==="unknown"))==null?void 0:$.description}),!x&&f.connect&&e.jsx("div",{className:"mt-3",children:e.jsx(Be,{type:t,connect:f.connect,renderConnect:o,installCommand:d,installInfoUrl:j,onShowDetails:()=>p(!0)})}),h&&e.jsxs(xe,{open:i,onOpenChange:p,className:"mt-3",children:[e.jsxs(pe,{className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1 text-xs transition-colors",children:[e.jsx(ve,{className:E("size-3.5 transition-transform",i&&"rotate-180")}),"Setup details"]}),e.jsx(he,{className:"mt-3 space-y-3",children:a?a.dependencies.map(R=>e.jsx(Ye,{dep:R},R.name)):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Not registered with this server. Install it, then enable"," ",e.jsxs(je,{children:["runtimes.",t]})," in your DorkOS config."]}),s.setup&&e.jsx(O,{command:s.setup.installCommand,infoUrl:s.setup.infoUrl,copyLabel:`Copy install command for ${s.label}`})]})})]})]})}function Be({type:t,connect:n,renderConnect:r,installCommand:o,installInfoUrl:s,onShowDetails:c}){return n.kind==="install"?e.jsx(Ke,{type:t,label:n.label,installCommand:o,installInfoUrl:s}):r&&(n.kind==="login"||n.kind==="provider-picker")?e.jsx(e.Fragment,{children:r({type:t,connect:n})}):e.jsx(S,{size:"sm",onClick:c,children:n.label})}function Ke({type:t,label:n,installCommand:r,installInfoUrl:o}){const s=y(t),{provision:c,isPending:a,isError:f,errorMessage:x,progress:i,result:p}=Ne(t);return a||p!=null&&p.ok?e.jsx(Ge,{message:(i==null?void 0:i.message)??`Installing ${s.label}…`}):f?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-destructive text-xs",role:"alert",children:x}),r&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:"You can install it yourself instead:"}),e.jsx(O,{command:r,infoUrl:o,copyLabel:`Copy install command for ${s.label}`})]}),e.jsx(S,{size:"sm",onClick:c,children:"Try again"})]}):e.jsxs("div",{children:[e.jsx(S,{size:"sm",onClick:c,children:n}),r&&e.jsx(Pe,{command:r,runtimeLabel:s.label})]})}function Ge({message:t}){const n=A();return e.jsxs(I.div,{className:"bg-muted flex items-center gap-2 rounded-lg px-3 py-2.5",initial:n?!1:{opacity:0},animate:{opacity:1},"data-testid":"provision-progress",children:[e.jsx(Ce,{size:"xs",className:E("text-muted-foreground shrink-0",n&&"animate-none")}),e.jsx(be,{mode:"wait",children:e.jsx(I.span,{className:"truncate text-xs",initial:n?!1:{opacity:0},animate:{opacity:1},exit:n?void 0:{opacity:0},transition:{duration:.2},children:t},t)})]})}function Ye({dep:t}){const n=t.status==="satisfied";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr] items-center gap-x-2",children:[n?e.jsx(D,{className:"text-status-success size-3.5 shrink-0"}):e.jsx(ge,{className:"text-status-warning-dot size-3.5 shrink-0"}),e.jsx("span",{className:"text-sm",children:t.name}),e.jsx("p",{className:"text-muted-foreground col-start-2 mt-1 text-xs",children:n&&t.version?`v${t.version}`:t.description})]}),!n&&(t.installHint||t.infoUrl)&&e.jsx(O,{command:t.installHint,infoUrl:t.infoUrl,copyLabel:`Copy install command for ${t.name}`})]})}function nt({runtime:t,open:n,onOpenChange:r,renderConnect:o,onRuntimeReady:s,showConnectSuccess:c=!1}){const a=ae(),{data:f}=oe(),x=t?y(t):null,i=z(a.data,t??"",f?t!==void 0&&t in f.capabilities:!0),p=a.data!==void 0,v=x!==null&&p&&i.state==="ready",g=l.useRef(null);l.useEffect(()=>{if(!n){g.current=null;return}if(t===void 0||!p)return;const h=g.current;g.current={runtime:t,ready:v},h!==null&&h.runtime===t&&!h.ready&&v&&(s==null||s(t))},[n,p,v,t,s]);const[u,m]=l.useState(null),d=l.useRef(n);l.useEffect(()=>{d.current&&!n&&m(null),d.current=n},[n]);const j=o&&(c?h=>o({...h,onConnected:N=>{var P;(P=h.onConnected)==null||P.call(h,N),m(N)}}):o);return e.jsx(ie,{open:n,onOpenChange:r,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(le,{children:[e.jsx(de,{children:x?x.label:"Your runtimes"}),e.jsx(ue,{children:u?"Connected.":x?v?"Ready to use.":"Connect it to start a chat.":"Connect one to start a chat."})]}),e.jsx(fe,{children:u?e.jsx(Qe,{success:u,onDone:()=>r(!1)}):e.jsx(Ae,{runtime:t,requirements:a.data,registeredTypes:f?Object.keys(f.capabilities):void 0,onRecheck:()=>void a.refetch(),isRechecking:a.isFetching,renderConnect:j})})]})})}function Qe({success:t,onDone:n}){return e.jsxs("div",{className:"space-y-4","data-testid":"runtime-connected-panel",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(D,{className:"text-status-success mt-0.5 size-4 shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.title}),e.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:t.body})]})]}),e.jsx(S,{size:"sm",className:"w-full",onClick:n,"data-testid":"runtime-connected-done",children:"Done"})]})}export{qe as H,nt as R,et as a,tt as b,Ae as c};
|