@microvac/ui 0.1.0-rc.14 → 0.1.0-rc.15
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/assets/{ActiveAgentsPanel-C9AP9hJu.js → ActiveAgentsPanel-BEx06tMt.js} +1 -1
- package/dist/assets/{AdapterManager-CmxTUKJH.js → AdapterManager-3kEEQWFJ.js} +1 -1
- package/dist/assets/{AdvancedToolsRoute-CXsQnTei.js → AdvancedToolsRoute-CgS6B-oh.js} +1 -1
- package/dist/assets/{AgentActionButtons-DWq2OuVK.js → AgentActionButtons-Cz3jCEd7.js} +1 -1
- package/dist/assets/{AgentAdvancedTab-dhBDxF-H.js → AgentAdvancedTab-BG6ZIAuN.js} +1 -1
- package/dist/assets/{AgentBulkSettingsSheet-DYT4ovDg.js → AgentBulkSettingsSheet-BrrbvspS.js} +1 -1
- package/dist/assets/{AgentChat-r0TPOfPK.js → AgentChat-Dw9iXD6H.js} +1 -1
- package/dist/assets/{AgentDetailPage-Bc_okBuS.js → AgentDetailPage-CuVIHv_q.js} +3 -3
- package/dist/assets/{AgentIdentityChip-CB2NBXkZ.js → AgentIdentityChip-BrVCcuHQ.js} +1 -1
- package/dist/assets/{AgentRosterFilters-b7qMLv8-.js → AgentRosterFilters-GQ2bdXfW.js} +2 -2
- package/dist/assets/{Agents-BsvXy3pZ.js → Agents-clrVQnvc.js} +2 -2
- package/dist/assets/{Agents.production-BeOZmzaF.js → Agents.production-DTopo7XB.js} +2 -2
- package/dist/assets/{AnimatedDialogContent-CWshmxP2.js → AnimatedDialogContent-CDLfw-dJ.js} +1 -1
- package/dist/assets/{AppDetail-DbqENTF_.js → AppDetail-BcWBg5yW.js} +1 -1
- package/dist/assets/{AppNotConnected-BhnCqL0F.js → AppNotConnected-NgfyHZ4L.js} +1 -1
- package/dist/assets/{ApprovalDetail-B2KiYLTj.js → ApprovalDetail-Dm_1V4tC.js} +1 -1
- package/dist/assets/{Approvals-j-wRmqKj.js → Approvals-i5AB3JPj.js} +1 -1
- package/dist/assets/{AppsConnect-CcPVEZ0C.js → AppsConnect-D660Tpuo.js} +1 -1
- package/dist/assets/{AppsReview-B8eWvKkS.js → AppsReview-DdTqOisY.js} +1 -1
- package/dist/assets/{ArtifactEmptyGraphic-5mdkS5jj.js → ArtifactEmptyGraphic-DzxCruYA.js} +1 -1
- package/dist/assets/{Artifacts-Bz7Oo6VX.js → Artifacts-CkXBz6nh.js} +1 -1
- package/dist/assets/{AssigneePickerInner-DdpF7hck.js → AssigneePickerInner-BNjyABBe.js} +1 -1
- package/dist/assets/{AssistantConnection-BpaaJDc_.js → AssistantConnection-CNF6mDmO.js} +1 -1
- package/dist/assets/{AttentionInlineVerbs-DlPQVCO-.js → AttentionInlineVerbs-BiyZ1ekZ.js} +1 -1
- package/dist/assets/{AttentionQueueRow-BC6ezctS.js → AttentionQueueRow-Bh0dKHpF.js} +1 -1
- package/dist/assets/{AuditHub-BVP7LKL9.js → AuditHub-BK848cb4.js} +1 -1
- package/dist/assets/{AuditRuns-DqizHgX1.js → AuditRuns-CUdlbP7S.js} +1 -1
- package/dist/assets/{Auth-DOF0snjp.js → Auth-DDqxm5gD.js} +1 -1
- package/dist/assets/{BoardChat-BYAbDtfd.js → BoardChat-fvKqk0R7.js} +1 -1
- package/dist/assets/{BoardClaim-7y41Pr8e.js → BoardClaim-BEC5BZfz.js} +1 -1
- package/dist/assets/{BootstrapSetupUxLab-BftH1vOv.js → BootstrapSetupUxLab-CXzErrin.js} +1 -1
- package/dist/assets/{Browse-Ck01W1Yl.js → Browse-DoovSMuF.js} +1 -1
- package/dist/assets/{BudgetPolicyCard-CKhrzfgy.js → BudgetPolicyCard-BYMlczCq.js} +1 -1
- package/dist/assets/{CaseDetail-qlXKJ66D.js → CaseDetail-UMAcSH_x.js} +1 -1
- package/dist/assets/{CaseStatus-B3RiZVDH.js → CaseStatus-BI0aMl9l.js} +1 -1
- package/dist/assets/{Cases-CFV3V-5X.js → Cases-CMTkGghU.js} +1 -1
- package/dist/assets/{ChatEndpointDetail-7Hi5TJNt.js → ChatEndpointDetail-CocNEInH.js} +1 -1
- package/dist/assets/{ChatEndpointSetup-CtwgH6sg.js → ChatEndpointSetup-Cyi2tI9K.js} +1 -1
- package/dist/assets/{ChatIdentityConfirm-CXjksBwX.js → ChatIdentityConfirm-Ba3JuTX1.js} +1 -1
- package/dist/assets/{CliAuth-KVjrGMfZ.js → CliAuth-D2jnueGH.js} +1 -1
- package/dist/assets/{Companies-oeJem3De.js → Companies-K75I9dJs.js} +1 -1
- package/dist/assets/{CompanyAccess-vWT6G-n_.js → CompanyAccess-Cw6nLUhE.js} +1 -1
- package/dist/assets/{CompanyActivity-zOzzeN1B.js → CompanyActivity-BsgmVpWS.js} +1 -1
- package/dist/assets/CompanyActivity.production-w-KGxvo6.js +1 -0
- package/dist/assets/{CompanyConnections-llSEaVa2.js → CompanyConnections-yRPYSdm7.js} +1 -1
- package/dist/assets/{CompanyEnvironments-DNyyGC_S.js → CompanyEnvironments-BA7kWdOJ.js} +1 -1
- package/dist/assets/{CompanyExport-CFa-F8Es.js → CompanyExport-DfsK4b9c.js} +1 -1
- package/dist/assets/{CompanyImport-DG6qwQ8F.js → CompanyImport-DJHAsmSF.js} +1 -1
- package/dist/assets/{CompanySettings-Dv5Z3ZQi.js → CompanySettings-DwzHGXec.js} +1 -1
- package/dist/assets/{CompanySettingsPluginPage-CZk1d_0d.js → CompanySettingsPluginPage-Bpa81PF3.js} +1 -1
- package/dist/assets/{CompanySkills-CdzWhJfQ.js → CompanySkills-eTqgbqQN.js} +1 -1
- package/dist/assets/{CompanySkills.production-IoCRW5FQ.js → CompanySkills.production-CQSWfH0r.js} +1 -1
- package/dist/assets/{ConfigureBuiltInAgentModal-BwW7XQ1O.js → ConfigureBuiltInAgentModal-DgeD7t_i.js} +1 -1
- package/dist/assets/{CopyableGatewayUrl-PTn061ft.js → CopyableGatewayUrl-B6K3rOal.js} +1 -1
- package/dist/assets/{CordisPluginSettings-C_BeeGEc.js → CordisPluginSettings-DD3AnD2G.js} +1 -1
- package/dist/assets/{Costs-DhuNxwSj.js → Costs-orBM8T-a.js} +1 -1
- package/dist/assets/{CrossIssueCollaborationUxLab-ZaAXq46r.js → CrossIssueCollaborationUxLab-Bv9y9-NE.js} +1 -1
- package/dist/assets/{Dashboard-BaDnqiKo.js → Dashboard-CrSBNKX1.js} +1 -1
- package/dist/assets/{DashboardLive-D-Ed7osd.js → DashboardLive-Cg8C9RiS.js} +1 -1
- package/dist/assets/{DecisionDateChips-D3pl_mLn.js → DecisionDateChips-BLZKZH71.js} +1 -1
- package/dist/assets/{DecisionHistoryPanel-D5MzyrOh.js → DecisionHistoryPanel-yK-CP7Qg.js} +1 -1
- package/dist/assets/{DecisionQueuePage-D3UZ9oRk.js → DecisionQueuePage-BKXbERai.js} +1 -1
- package/dist/assets/{DesignGuide-COTo7ICj.js → DesignGuide-2FswNsXz.js} +1 -1
- package/dist/assets/{DesignSandboxTaskThread-CMeCSQid.js → DesignSandboxTaskThread-CGU--FXR.js} +1 -1
- package/dist/assets/{EmailConnectionAccess-kCL7obSr.js → EmailConnectionAccess-CZ5QRKyg.js} +1 -1
- package/dist/assets/{EmailEndpointSetup-BGrksR_u.js → EmailEndpointSetup-BI2vsd8Y.js} +1 -1
- package/dist/assets/{EnforcementBanner-_Eb_nK3M.js → EnforcementBanner-B-iX466h.js} +1 -1
- package/dist/assets/{EntityRow-gpsOgEtu.js → EntityRow-BsICt6pd.js} +1 -1
- package/dist/assets/{ExecutionWorkspaceDetail-DwGkH6d3.js → ExecutionWorkspaceDetail-CMqR9puh.js} +1 -1
- package/dist/assets/{ExternalAgentInviteDialog-CGid6pM9.js → ExternalAgentInviteDialog-De30ZrLP.js} +1 -1
- package/dist/assets/{FilterBar-1D-VhrvG.js → FilterBar-rCmsTtG4.js} +1 -1
- package/dist/assets/{FolderControls-CQ6kef3c.js → FolderControls-CmnB7Ap-.js} +1 -1
- package/dist/assets/{GatewayDetail-CCqekM1J.js → GatewayDetail-Duw9pJ10.js} +1 -1
- package/dist/assets/{GatewaysList-nFsRcszh.js → GatewaysList-BBhVGhRq.js} +1 -1
- package/dist/assets/{GitHubConnectionRecovery-B9sFWJup.js → GitHubConnectionRecovery-6VshLoNV.js} +1 -1
- package/dist/assets/{GoalDetail-BQ8y55P-.js → GoalDetail-CahntjlI.js} +1 -1
- package/dist/assets/{GoalTree-laRjXp0P.js → GoalTree-CU4GBFCh.js} +1 -1
- package/dist/assets/{Goals-Cm14EaeP.js → Goals-CzM2NDFR.js} +1 -1
- package/dist/assets/{InstanceAccess-DxQ-Akt_.js → InstanceAccess-CZzkE65W.js} +1 -1
- package/dist/assets/{InstanceExperimentalSettings-BxwqbXNw.js → InstanceExperimentalSettings-DWumKtOK.js} +1 -1
- package/dist/assets/{InviteLanding-Cf0L_u6s.js → InviteLanding-BIy2z50u.js} +1 -1
- package/dist/assets/{IssueChatLongThreadPerf-BfsF6FdF.js → IssueChatLongThreadPerf-D4DJvdOG.js} +1 -1
- package/dist/assets/{JoinRequestQueue-BXCdTFG_.js → JoinRequestQueue-C5rauGYm.js} +1 -1
- package/dist/assets/{Layout.production-CqzU0qMi.js → Layout.production-BSDWnupa.js} +1 -1
- package/dist/assets/{McpConnect-COWnZ9Eb.js → McpConnect-BN8ST0RS.js} +1 -1
- package/dist/assets/{MembershipAction-C9i9Sdmi.js → MembershipAction-DTjhGn-L.js} +1 -1
- package/dist/assets/{MetricCard-Bwnt3_p3.js → MetricCard-CeL9Pdn5.js} +1 -1
- package/dist/assets/{MissingPluginTabPlaceholder-B0Zxv1Kx.js → MissingPluginTabPlaceholder-CbQiSVnZ.js} +1 -1
- package/dist/assets/{NewAgent-BIlJ5Dyt.js → NewAgent-BszrNpQk.js} +1 -1
- package/dist/assets/{NewAgentDialog-CJdMxxYL.js → NewAgentDialog-U9qAcTzc.js} +1 -1
- package/dist/assets/{NewGoalDialog-B8izfKLm.js → NewGoalDialog-DqKbk4-i.js} +1 -1
- package/dist/assets/{NewProjectDialog-DXqjTYFK.js → NewProjectDialog-DrlUAF-N.js} +1 -1
- package/dist/assets/{OnboardingPrimitives-DHYBqn_0.js → OnboardingPrimitives-BkgPF4Mu.js} +1 -1
- package/dist/assets/{OnboardingWizard-DqSfZ13V.js → OnboardingWizard-CMBMcuXv.js} +1 -1
- package/dist/assets/{OrgChart.production-DrSFUf7i.js → OrgChart.production-BLczTjRj.js} +1 -1
- package/dist/assets/{PaperclipCloudOAuthHandoff-jPUvjJ8q.js → PaperclipCloudOAuthHandoff-BTtF8UPD.js} +1 -1
- package/dist/assets/{PluginManager-h3LFPaUq.js → PluginManager-CCcqlfgK.js} +1 -1
- package/dist/assets/{PluginPage-E5Im4454.js → PluginPage-B1empV69.js} +1 -1
- package/dist/assets/{PluginSettings-BBO0jAgo.js → PluginSettings-DtopaRqR.js} +1 -1
- package/dist/assets/{ProfileDetailRoute-CQBD7fms.js → ProfileDetailRoute-BqvVpBZi.js} +1 -1
- package/dist/assets/{ProfileSettings-BwnVEHLp.js → ProfileSettings-5__tVfGi.js} +1 -1
- package/dist/assets/{ProfileWizardRoute-By_SC6Gn.js → ProfileWizardRoute-vt-MRLuD.js} +1 -1
- package/dist/assets/{ProjectDetail-CbiwFBAE.js → ProjectDetail-DJ4zjube.js} +1 -1
- package/dist/assets/{ProjectRepositoryInput-DZF9bX4E.js → ProjectRepositoryInput-BJcnj3At.js} +1 -1
- package/dist/assets/{ProjectWorkspaceDetail-DPsl_4bD.js → ProjectWorkspaceDetail-DEAO3q6v.js} +1 -1
- package/dist/assets/{ProjectWorkspacesContent-COH4dOWK.js → ProjectWorkspacesContent-CZvO7p0i.js} +1 -1
- package/dist/assets/{Projects-Ch9Qu7sn.js → Projects-Dm7-zXUH.js} +1 -1
- package/dist/assets/{QuotaBar-DIFOT9Uh.js → QuotaBar-Drp3CaxX.js} +1 -1
- package/dist/assets/{RepositoryEditor-DHB1bqId.js → RepositoryEditor-BT_VAkJu.js} +1 -1
- package/dist/assets/{Responsibilities-C5O0JXXG.js → Responsibilities-DbUEtGZu.js} +1 -1
- package/dist/assets/{ResponsibilityDetail-D6NpZpkm.js → ResponsibilityDetail--S8_GOkb.js} +1 -1
- package/dist/assets/{ResponsibleUserDenialUxLab-CFrIWYwe.js → ResponsibleUserDenialUxLab-1PB3JNG0.js} +1 -1
- package/dist/assets/{ReviewQueueCard-BPC4Lm67.js → ReviewQueueCard-B8w9aXKU.js} +1 -1
- package/dist/assets/{RoutineAuditActivity-sKyzMajz.js → RoutineAuditActivity-BCo7pYe5.js} +1 -1
- package/dist/assets/{RoutineDetail-CG8HF5fp.js → RoutineDetail-C9Dwn5G9.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-CKh3CmLD.js → RoutineRunVariablesDialog-Baomcbe3.js} +1 -1
- package/dist/assets/{Routines-tF2qfUKo.js → Routines-Dkv4gJno.js} +1 -1
- package/dist/assets/{Routines.production-BTyj1Ljr.js → Routines.production-Cs2Y-lpt.js} +1 -1
- package/dist/assets/{RoutinesToolbar-CvUFVCGN.js → RoutinesToolbar-BNKfCrTo.js} +1 -1
- package/dist/assets/{Search-Z9D0NuS1.js → Search-CVx4cl2o.js} +1 -1
- package/dist/assets/{Secrets-DgmbLOJK.js → Secrets-C2qv2HKZ.js} +1 -1
- package/dist/assets/{SkillBinaryFile-F3_9qcaM.js → SkillBinaryFile-DDkhLlfC.js} +1 -1
- package/dist/assets/{SkillCardIcon-CXHUCMej.js → SkillCardIcon-Cp_hws0N.js} +1 -1
- package/dist/assets/{SkillFolderTree-CB3lrTIE.js → SkillFolderTree-Cv0CmfYx.js} +1 -1
- package/dist/assets/{SkillSourceTree-BbuciCo6.js → SkillSourceTree-DmjlUswf.js} +1 -1
- package/dist/assets/{SkillSources-Dlo6Cew3.js → SkillSources-nmlYypUU.js} +1 -1
- package/dist/assets/{SkillStudio-ZO-Nf7eI.js → SkillStudio-BK3y_3zr.js} +1 -1
- package/dist/assets/{SkillsNavigationTabs-B9Iqnlqt.js → SkillsNavigationTabs-DRwMP1eu.js} +1 -1
- package/dist/assets/{SpekoPhoneCallback-C4VnMiZh.js → SpekoPhoneCallback-Cqi7AIyH.js} +1 -1
- package/dist/assets/{SpekoProviderSetup-I4evPZb3.js → SpekoProviderSetup-CJI4oXk5.js} +1 -1
- package/dist/assets/{StatusCards-D0MVzbsw.js → StatusCards-DKyyY81S.js} +1 -1
- package/dist/assets/{SummarySlotCard-DUXgZPxG.js → SummarySlotCard-f3RomdZS.js} +1 -1
- package/dist/assets/{TailscaleConnector-CMhT73gj.js → TailscaleConnector-yQWLR1Ra.js} +1 -1
- package/dist/assets/{TaskChatLab-D9-KAE-7.js → TaskChatLab-Dsr7eyj4.js} +1 -1
- package/dist/assets/{TaskSummaryList-CUxieFNe.js → TaskSummaryList-eFDfK_QH.js} +1 -1
- package/dist/assets/{Timeline-BNMoRbtK.js → Timeline-BWA9dyk6.js} +1 -1
- package/dist/assets/{ToolsAdminGate-CEr0zy2T.js → ToolsAdminGate-DpBg30hQ.js} +1 -1
- package/dist/assets/{TrustPresetSection-B9YXZtkh.js → TrustPresetSection-DtWjK9Kp.js} +1 -1
- package/dist/assets/{UserProfile-D-tnW96X.js → UserProfile-C66UI5xx.js} +1 -1
- package/dist/assets/{WebhookUrlWarning-Ba_DixKh.js → WebhookUrlWarning-CDygVnDH.js} +1 -1
- package/dist/assets/{WhatNeedsMe-B-Jzj8_M.js → WhatNeedsMe-BQ82RHus.js} +1 -1
- package/dist/assets/{Workspaces-BqhDI_Bl.js → Workspaces-DrjJes30.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-Bn9P-nUW.js → abnfDiagram-YUKMZFIV-Crkksu2D.js} +1 -1
- package/dist/assets/{architecture-WOLXFQ4H-V1ldsZlt.js → architecture-WOLXFQ4H-bHU8FW0c.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-BkYxt-Gc.js → architectureDiagram-47P4ROYG-Bj5Styf9.js} +1 -1
- package/dist/assets/{arrow-down-left-o81ENfeW.js → arrow-down-left-Ck9VQyqQ.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-BO7pPYbp.js → blockDiagram-E7TT5TSB-OeHpNCQ-.js} +1 -1
- package/dist/assets/{budgets-0Dw6TH1A.js → budgets-CAWPqcn4.js} +1 -1
- package/dist/assets/{building-complex-DciZTnys.js → building-complex-Dxiyk_pH.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-D4EpmmzV.js → c4Diagram-CRA5TL53-QbK5p76P.js} +1 -1
- package/dist/assets/channel-BSmZkKA8.js +1 -0
- package/dist/assets/{chat-channels-DWyry-9M.js → chat-channels-CzTZV2fr.js} +1 -1
- package/dist/assets/{chunk-2BW5OAIV-DFXIyCJy.js → chunk-2BW5OAIV-Ckr4HfBO.js} +1 -1
- package/dist/assets/{chunk-3YJQHVM4-Dj5wEKIw.js → chunk-3YJQHVM4-C_uoPpLR.js} +1 -1
- package/dist/assets/{chunk-4EA7E6EY-5XiUVgzK.js → chunk-4EA7E6EY-BeMEfIRS.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-D0opKcsy.js → chunk-7TKQ45FW-DiwqWHvN.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-DnjsTe04.js → chunk-AW2ZBBNX-Cf57K3PO.js} +1 -1
- package/dist/assets/{chunk-DBDB3WZW-DNqSQPZ0.js → chunk-DBDB3WZW-B2qouVQO.js} +1 -1
- package/dist/assets/{chunk-E2ZNV5FY-cjSf_BTz.js → chunk-E2ZNV5FY-DG8wQ_NS.js} +1 -1
- package/dist/assets/{chunk-EU5HNXII-CZYBiaSw.js → chunk-EU5HNXII-cxRrXRGV.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-DSc0-wJA.js → chunk-FVRAUYC3-Dizswk0V.js} +1 -1
- package/dist/assets/{chunk-HJ2JQQFS-MXK0gYSP.js → chunk-HJ2JQQFS-DL4lnpSv.js} +1 -1
- package/dist/assets/{chunk-HTAEGDNF-BjDZm_5k.js → chunk-HTAEGDNF-Zxjdb6kj.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-Bfj0tDmO.js → chunk-KQW6MTUR-BsVaJdnu.js} +1 -1
- package/dist/assets/{chunk-NTY3LDVX-Bpz5TkVb.js → chunk-NTY3LDVX-DyT9N5sM.js} +1 -1
- package/dist/assets/{chunk-VPRB5NB3-CfeHjtbb.js → chunk-VPRB5NB3-BNz5CtBn.js} +1 -1
- package/dist/assets/{chunk-XC4XBNZT-FBCWmi6K.js → chunk-XC4XBNZT-CCgIhjYS.js} +1 -1
- package/dist/assets/{circle-slash-DqKFFqfb.js → circle-slash-uNv_ha0X.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-DbC_J0kK.js → classDiagram-v2-K4WV4PDN-Cdh3CEl4.js} +1 -1
- package/dist/assets/{coins-BztUbqyl.js → coins-BDAh8hDQ.js} +1 -1
- package/dist/assets/{collections-BxrcELwt.js → collections-B58p51lw.js} +1 -1
- package/dist/assets/{connection-owner-D-ikSHyR.js → connection-owner-D8fNrFqC.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-COwSJ4qP.js → cynefin-EF2NZ3EQ-BkwhfqJ0.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-diaEJq9Y.js → cynefinDiagram-3GCD6N5R-DuGb_wq2.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-BPAMRuIj.js → dagre-W4DXFKR2-Bxq_Mhia.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-BvRnO1Id.js → diagram-2UJZ2QOL-B-P_hrXV.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-CDgBeD0m.js → diagram-OVF4WLC6-Ds0BqQWH.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-DAw9lREG.js → diagram-PFPMY2P6-Dpqb2-Cb.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-ZQqQn22t.js → diagram-UMYRVEAY-BJSoxjiu.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-CoJtGgWs.js → diagram-YEKJPTXX-BxaG_9tT.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-qW_Zn_bO.js → diagram-ZIFT7M5P-6acvVOtc.js} +1 -1
- package/dist/assets/{dist-B2E6oBK1.js → dist-0EWXio4m.js} +1 -1
- package/dist/assets/{dist-IcdxEhjC.js → dist-BGvZP_Cl.js} +1 -1
- package/dist/assets/{dist-DXjkgaZX.js → dist-BZ7AbEhN.js} +1 -1
- package/dist/assets/{dist-_EtfntKJ.js → dist-BlosHr86.js} +1 -1
- package/dist/assets/{dist-DylHAy-6.js → dist-Bmr4uhSk.js} +1 -1
- package/dist/assets/{dist-DML0cJH3.js → dist-C6yMfMNS.js} +1 -1
- package/dist/assets/{dist-Dl94YqeS.js → dist-CMZQedYl.js} +1 -1
- package/dist/assets/{dist-DKyBHaH2.js → dist-C_N_-eaT.js} +1 -1
- package/dist/assets/{dist-CvRpZH53.js → dist-CaUbG4Hl.js} +1 -1
- package/dist/assets/{dist-ptDa9fKh.js → dist-Cn7-nxjU.js} +1 -1
- package/dist/assets/{dist-CG-phytt.js → dist-Cnj95_pX.js} +1 -1
- package/dist/assets/{dist-DbXGl-wj.js → dist-D9DR7k9k.js} +1 -1
- package/dist/assets/{dist-CjRqeLFz.js → dist-DIwsVdS2.js} +1 -1
- package/dist/assets/{dist-BCJybC91.js → dist-DVE0lLId.js} +1 -1
- package/dist/assets/{dist-CPgRB-NQ.js → dist-DkAPL4CQ.js} +1 -1
- package/dist/assets/{dist-CeSzCyeG.js → dist-Dl6N3kpQ.js} +1 -1
- package/dist/assets/{dist-DZruZxAk.js → dist-DmBvXBzK.js} +1 -1
- package/dist/assets/{dist-CdmdXwCZ.js → dist-DpgXK0aZ.js} +1 -1
- package/dist/assets/{dist-CYRzGbSY.js → dist-gMRyU9GJ.js} +1 -1
- package/dist/assets/{dist-CG6fC1Db.js → dist-jQQX2kOU.js} +1 -1
- package/dist/assets/{dist-DZIxMHOT.js → dist-lUaUoFTq.js} +1 -1
- package/dist/assets/{dist-CuwPDbnL.js → dist-qw1ZF2vD.js} +1 -1
- package/dist/assets/{dist-B6Qde8KJ.js → dist-rH4qrNAn.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-DA4UvKXV.js → ebnfDiagram-VR2GEFS7-Ytj3Z5qC.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-CM74d3mJ.js → elk-IJKZMXRS-CJurNqqK.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-d869V0qL.js → erDiagram-O2IAPWRE-hyXckW2d.js} +1 -1
- package/dist/assets/{eventmodeling-K75KTNOO-C-oz_eyI.js → eventmodeling-K75KTNOO-D3xQujrh.js} +1 -1
- package/dist/assets/flowDiagram-OXPTDLAJ-D4ojBTuY.js +1 -0
- package/dist/assets/{folder-plus-CxWXoYCi.js → folder-plus-BJZSMzuj.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-BBul4Kpm.js → ganttDiagram-R7TSEDQI-C8U_ITl4.js} +1 -1
- package/dist/assets/{gitGraph-VSP46ZUC-BriEZgAq.js → gitGraph-VSP46ZUC-CDeq3yKT.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-I12rg8s1.js → gitGraphDiagram-XJZIOB7I-CST3EWE9.js} +1 -1
- package/dist/assets/{goals-CvMWzjH4.js → goals-BNJZ4nzg.js} +1 -1
- package/dist/assets/{index-Bt31d8ga.js → index-BJtnP7H1.js} +8 -8
- package/dist/assets/{info-OHQRW6UA-CxrcGiem.js → info-OHQRW6UA-CPvTWk7J.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-4Sm0LiOu.js → infoDiagram-5W2HQ5XZ-BPUiNdxI.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-CKXvKV-s.js → ishikawaDiagram-K3B6WC7H-D5Z3rmaA.js} +1 -1
- package/dist/assets/{issue-detail-4PCbYpdv.js → issue-detail-CZfjXs0M.js} +3 -3
- package/dist/assets/{journeyDiagram-COXZFDF6-BHsrZLvQ.js → journeyDiagram-COXZFDF6-CEkwEYdR.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-8HhnIs_l.js → kanban-definition-P3RFRI5V-8h_R6Qjq.js} +1 -1
- package/dist/assets/{line-rrKrpB-b.js → line-Ljt_vfsb.js} +1 -1
- package/dist/assets/{link-BecLzmfo.js → link-DvgFK0mz.js} +1 -1
- package/dist/assets/{list-filter-BC3D4IoX.js → list-filter-BR4_dvwm.js} +1 -1
- package/dist/assets/{log-in-BJCGwGGT.js → log-in-Dvx9-FMC.js} +1 -1
- package/dist/assets/{mcpSkills-DRs3pGKn.js → mcpSkills-76szK_k1.js} +1 -1
- package/dist/assets/{mermaid-parser.core-DmG0b4S0.js → mermaid-parser.core-BjFu937m.js} +3 -3
- package/dist/assets/{mermaid.core-D1vILTuF.js → mermaid.core-B0t95EIS.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-DIMpL0de.js → mindmap-definition-LZFPQGKD-TVnHYUR4.js} +1 -1
- package/dist/assets/{packet-JDAUHWVQ-BnbYht3G.js → packet-JDAUHWVQ-aNGiRWLy.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-BUjtJVjT.js → pegDiagram-BGZESJAR-DDadxqWQ.js} +1 -1
- package/dist/assets/{pie-XZMESJXO-CM4VXUb-.js → pie-XZMESJXO-CydFP1hd.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-B3v8ryvG.js → pieDiagram-CAPJLFHJ-KhdUDwDS.js} +1 -1
- package/dist/assets/{power-0mw59G-l.js → power-sYV-WuqQ.js} +1 -1
- package/dist/assets/{profile-summary-B5rPf8v-.js → profile-summary-D4LPX-Dv.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-Cv-dS2Rn.js → quadrantDiagram-GDMTTRAM-B1X8K2Fs.js} +1 -1
- package/dist/assets/{radar-ABXABTNO-v6yZj4Fk.js → radar-ABXABTNO-BqodkLpx.js} +1 -1
- package/dist/assets/{railroad-I3PHUGI6-D-U8Cs0m.js → railroad-I3PHUGI6-HmRKXDJj.js} +1 -1
- package/dist/assets/{railroad-abnf-LNEFI6M7-Dw3fkrVy.js → railroad-abnf-LNEFI6M7-CkBttaHp.js} +1 -1
- package/dist/assets/{railroad-ebnf-DWYD2UWJ-_ln-e3Tx.js → railroad-ebnf-DWYD2UWJ-C6DBawFA.js} +1 -1
- package/dist/assets/{railroad-peg-JR7BVNR7-Bf8u1-RZ.js → railroad-peg-JR7BVNR7-Z9df3u5o.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-Drr5UhQI.js → railroadDiagram-SM67HX2B-2vDUUppL.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-D5ef6_ac.js → requirementDiagram-X7JNWC4A-DAuP39Hc.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-DncJWIz_.js → sankeyDiagram-UM26HJRW-ByS54QZK.js} +1 -1
- package/dist/assets/{saved-permissions-CizWg8-P.js → saved-permissions-CPiYtxkZ.js} +1 -1
- package/dist/assets/{scroll-text-Ck6HB7eM.js → scroll-text-CVSt6aO2.js} +1 -1
- package/dist/assets/{sdk-CWyUlmcn.js → sdk-vrG4HtB4.js} +1 -1
- package/dist/assets/{search-DkTqg7ab.js → search-CG-QtPVH.js} +1 -1
- package/dist/assets/{send-CYVi50sh.js → send-CH-0xdLm.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-Cs0nGCCg.js → sequenceDiagram-ZO4K6R2Y-DvWxKTLK.js} +1 -1
- package/dist/assets/{shared-CIwISWMj.js → shared-D37zfckm.js} +1 -1
- package/dist/assets/{smoke-lab-matrix-A7ubFpfk.js → smoke-lab-matrix-C5gR81E3.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-Dpp3m5Wq.js → stateDiagram-v2-TBUQTH76-DtiiZIXq.js} +1 -1
- package/dist/assets/{swimlanes-N4OXWK64-NXVbx1w8.js → swimlanes-N4OXWK64-BWSEtCbX.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Bl_9DvHU.js +8 -0
- package/dist/assets/{timeline-definition-YOQAKGHF-DqI-Mv2e.js → timeline-definition-YOQAKGHF-U4QcniMh.js} +1 -1
- package/dist/assets/{treeView-D4JQ5SDB-CZBlE7ya.js → treeView-D4JQ5SDB-B2tdrtsj.js} +1 -1
- package/dist/assets/{treemap-SAJKECNS-BlueznID.js → treemap-SAJKECNS-DodN8j4n.js} +1 -1
- package/dist/assets/{useAgentlessOnboardingAutoOpen-CnFwEQ-H.js → useAgentlessOnboardingAutoOpen-DSWW7Juw.js} +1 -1
- package/dist/assets/{useAuthorizationWindow-DnFQsiFj.js → useAuthorizationWindow-tg3aKEU7.js} +1 -1
- package/dist/assets/{useDateRange-9EbqkWXy.js → useDateRange-CnZQr2KO.js} +1 -1
- package/dist/assets/{useFastResponsesEnabled-D8dunm4j.js → useFastResponsesEnabled-B8tHSJ1y.js} +1 -1
- package/dist/assets/{usePageView-BiX5i8ck.js → usePageView-CtFMs34g.js} +1 -1
- package/dist/assets/{useProfilesData-0VYQ4lAT.js → useProfilesData-CWHdMSuL.js} +1 -1
- package/dist/assets/{useReviewCount-WBWxwKI3.js → useReviewCount-W_bCZ2Hz.js} +1 -1
- package/dist/assets/{useRoutineFormOptions-DnX5DBn1.js → useRoutineFormOptions-CCLMmVSF.js} +1 -1
- package/dist/assets/{useSummaryDraftStream-DPQRvaXT.js → useSummaryDraftStream-NVNYNt72.js} +1 -1
- package/dist/assets/{useTailscaleConnections-BDff6dWx.js → useTailscaleConnections-Dy52nCY3.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-BSDn8OaJ.js → usecaseDiagram-VIAY4XPW-kEHhqgOj.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-BBSA9KNN.js → vennDiagram-BLWOH2XV-NPJU0aCU.js} +1 -1
- package/dist/assets/{wardley-7MLQ67FV-CsT-rTZ9.js → wardley-7MLQ67FV-bUGKvIPT.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-BLClsIjw.js → wardleyDiagram-YMQ3BMBF-qtUDHfhb.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-2x4wB0gq.js → xychartDiagram-TAQBALBS-C-z57aZj.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/CompanyActivity.production-DbaFBsM0.js +0 -1
- package/dist/assets/channel-BQh2vFIU.js +0 -1
- package/dist/assets/flowDiagram-OXPTDLAJ-Be1xLbJu.js +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Ct3LnXZt.js +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentAdvancedTab-
|
|
2
|
-
var qr=Object.defineProperty;var n=(t,s)=>qr(t,"name",{value:s,configurable:!0});import{a as Xn}from"./rolldown-runtime-DhZMWcEn.js";import{$ as Ft,Ci as Mr,H as Dr,Ni as Kr,Pi as Br,Q as un,S as zr,Si as mn,U as Or,Y as Ur,Z as xn,_ as Hr,at as Qr,d as Wr,et as pn,f as Vr,fi as Gr,ft as Yr,g as er,h as Jr,it as Zr,l as Xr,m as ea,ot as ta,p as sa,pt as Ms,q as na,rt as ra,s as aa,u as ia,ui as oa}from"./issue-detail-4PCbYpdv.js";import{t as la}from"./BudgetPolicyCard-CKhrzfgy.js";import{C as da,b as fn}from"./collections-BxrcELwt.js";import{n as ca,t as ua}from"./AuditRuns-DqizHgX1.js";import{t as ma}from"./coins-BztUbqyl.js";import{$A as xa,$S as Xe,$w as tr,$y as pa,Ab as sr,Ac as fa,Ap as hn,BC as ha,B_ as Ys,CC as Xt,CE as gn,Cb as ls,Cp as ga,Cx as ya,Db as ds,Dy as va,EC as ba,EO as nr,ET as Js,Eb as cs,Ep as Zt,Ex as ja,FE as ft,Fd as Na,Fu as Ds,GS as v,Gb as ce,Gd as yn,Gl as wa,Gn as ka,Gw as rr,HE as Ks,H_ as Nt,Hw as Sa,IC as Ca,IT as vn,In as Ra,Iy as Zs,Jl as Aa,Jp as ot,Kd as bn,Kl as Ia,Ko as Ea,Kv as us,LS as Xs,Ln as Ta,ME as Be,MT as es,Mc as ar,NE as M,Np as _a,Ob as ms,Op as La,Ou as Fa,PC as $a,Pp as Pa,QC as en,QT as xs,RE as qa,Rp as Ma,Ru as Da,Sb as ps,Sp as ir,TT as fs,Tb as hs,Ti as Ka,To as Bs,Tx as Ba,UE as et,UT as or,Ud as za,V_ as tn,WC as lr,WE as Oa,Wd as Ua,Wm as zs,Ww as Ha,XC as dr,XE as Ue,Xc as Qa,Xl as Wa,Xo as Va,Yb as Lt,Yc as Ga,Yo as Ya,ZE as Ja,ZT as Za,Z_ as Xa,_E as ei,_S as ti,_T as si,__ as qt,_w as Et,aD as ni,aE as gs,ab as yt,as as Rt,ay as vt,bC as Os,bE as te,bT as cr,cS as ri,cT as Us,ci as ai,cs as Ve,cv as sn,dE as jn,dk as ii,dl as oi,ds as li,eT as di,eb as ci,ev as ui,fb as mi,fi as xi,fs as pi,fy as fi,gC as Nn,hC as wn,hE as ur,hS as hi,hb as gi,hl as yi,hw as vi,iC as mr,iD as Tt,iS as xr,iT as bi,ib as pr,jT as dt,jc as ts,kT as st,kb as ys,kc as ji,kp as Ni,lC as wi,lS as gt,lb as ki,ls as Si,ly as Ci,mS as Ri,mb as Oe,my as Ai,nD as kn,nE as Ii,nj as Ei,oD as Ti,oE as _i,on as Li,pE as nn,pS as Fi,pT as Hs,pb as vs,pm as Mt,ps as $i,qC as rn,qD as Sn,qT as Pi,qb as qi,qo as Mi,qp as fr,rS as tt,rb as W,rm as Di,sD as Ki,sE as Bi,sm as zi,sy as Oi,tE as Ui,tT as hr,tb as Hi,uC as Qi,ub as Dt,us as Cn,ux as Qs,uy as Wi,vT as Vi,vb as ss,wb as bs,x as js,xE as U,x_ as gr,xb as ns,xw as Gi,yE as Yi,y_ as Ji,yb as rs,yl as Zi,zC as Pt,zE as w,z_ as an}from"./index-Bt31d8ga.js";import{t as ks}from"./budgets-0Dw6TH1A.js";import{t as Xi}from"./ConfigureBuiltInAgentModal-BwW7XQ1O.js";import{n as as,t as Ws}from"./AgentIdentityChip-CB2NBXkZ.js";import{t as eo}from"./company-skill-summary-DnWVmP1S.js";import{t as to}from"./SkillCardIcon-CXHUCMej.js";import{t as so}from"./TaskSummaryList-CUxieFNe.js";import{t as no}from"./MembershipAction-C9i9Sdmi.js";import{t as ro}from"./AgentActionButtons-DWq2OuVK.js";import{t as ao}from"./TrustPresetSection-B9YXZtkh.js";import{t as io}from"./EnforcementBanner-_Eb_nK3M.js";import{i as oo,o as lo,r as co,t as uo}from"./shared-CIwISWMj.js";import{i as mo,n as xo,o as Rn,r as po,s as fo,t as ho}from"./useDateRange-9EbqkWXy.js";import{t as Ss}from"./MetricCard-Bwnt3_p3.js";var go=["source_run_missing","recovery_action_missing","recovery_action_run_mismatch","source_run_not_terminal","source_issue_mismatch","native_reference_invalid","restore_reference_invalid","historical_reference_invalid","lease_reference_invalid","source_lease_not_bound","lease_issue_mismatch","lease_environment_missing","lease_allocation_missing","lease_provider_invalid","lease_policy_not_retained","lease_cwd_invalid","allocation_reference_mismatch","cwd_reference_mismatch","workspace_reference_mismatch","recovery_lease_not_selected","recovery_environment_mismatch","recovery_lease_not_claimed","recovery_owner_mismatch","recovery_stop_intent_missing","local_descriptor_invalid","execution_target_invalid","recovery_stop_intent_invalid","reopened_allocation_mismatch","reopened_cwd_mismatch"],yo={schema:{const:"paperclip.provider-failure.v1"},provider:{type:"string",minLength:1,maxLength:80,pattern:"^[a-zA-Z0-9_.:/-]+$"},phase:{enum:["startup","turn"]},category:{enum:["rate_limit","quota_exhausted","authentication","permission","model_unavailable","invalid_request","overloaded","timeout","unknown"]},message:{type:"string",minLength:1,maxLength:4e3},providerCode:{type:"string",minLength:1,maxLength:160,pattern:"^[a-zA-Z0-9_.:/-]+$"},httpStatus:{type:"integer",minimum:400,maximum:599},requestId:{type:"string",minLength:1,maxLength:160,pattern:"^[a-zA-Z0-9_.:/-]+$"},retryAt:{type:"string",format:"date-time"},retryability:{enum:["transient","requires_action","unknown"]}};function An(t){try{if(!t||typeof t!="object"||Array.isArray(t))return null;const s=t,r={};for(const[i,o]of Object.entries(yo)){const a=s[i];if(!(a===void 0&&!["schema","provider","phase","category","message","retryability"].includes(i))){if("const"in o){if(a!==o.const)return null}else if("enum"in o){if(typeof a!="string"||!o.enum.includes(a))return null}else if(o.type==="integer"){if(typeof a!="number"||!Number.isInteger(a)||a<o.minimum||a>o.maximum)return null}else if(typeof a!="string"||"maxLength"in o&&([...a].length<o.minLength||[...a].length>o.maxLength)||"pattern"in o&&!new RegExp(o.pattern).test(a)||"format"in o&&!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(a)||"format"in o&&!Number.isFinite(Date.parse(a)))return null;r[i]=a}}return r}catch{return null}}n(An,"readProviderFailure");var yr={name:"git-compare",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]};yr.node;var vo=xs(yr),vr={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]};vr.node;var bo=xs(vr),br={name:"slash",size:24,node:[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]};br.node;var jo=xs(br),jr={name:"timer",size:24,node:[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]};jr.node;var No=xs(jr),u=Xn(Ei(),1),e=Xn(xa(),1);function wo({context:t}){const s=t?.paperclipRunSettings,r=typeof s?.model=="string"?s.model:null,i=typeof s?.effort=="string"?s.effort:null;return!r&&!i?null:(0,e.jsxs)("div",{className:"rounded-lg border p-4 text-sm space-y-1","data-testid":"run-settings-run-details",children:[(0,e.jsx)("p",{className:"font-medium",children:"Run settings"}),(0,e.jsx)("p",{className:w(Xe),children:[r?`Model ${r}`:"Agent default model",i?`effort ${i}`:null].filter(Boolean).join(" · ")})]})}n(wo,"RunSettingsRunDetails");function ko(t,s,r,i){const o=t.find(l=>l.id===s)??null,a=U({queryKey:v.runDetail(s??""),queryFn:n(()=>tt.get(s),"queryFn"),enabled:!!(s&&!o)}),d=a.data?.id===s&&a.data.companyId===r&&a.data.agentId===i?a.data:null;return{run:o??d,loading:a.isPending,error:a.error,retry:a.refetch}}n(ko,"useSelectedHeartbeatRun");function So({context:t}){const s=t?.aiRouterSelection;if(!s)return null;const r=t?.aiConnection,i=s.runtimeConfig,o=i.modelReasoningEffort??i.reasoningEffort??i.effort??i.variant;return(0,e.jsxs)("div",{className:"rounded-lg border p-4 text-sm space-y-1",children:[(0,e.jsxs)("p",{className:w("font-medium",Xe),children:["Task-pinned pool account · ",r?.accountName??r?.connectionId??"Selected account"]}),(0,e.jsx)("p",{children:[s.binding.provider,i.provider,i.acpxAgent,i.model,o].filter(Boolean).map(String).join(" · ")}),s.notes.length>0&&(0,e.jsx)("p",{className:"text-muted-foreground",children:s.notes.join(" ")})]})}n(So,"AiConnectionPoolRunDetails");function Co({agentId:t,companyId:s,path:r,currentRevisionId:i,disabled:o,onRestored:a}){const[d,l]=(0,u.useState)(!1),[c,x]=(0,u.useState)(null),m=da({queryKey:["instruction-history",t,r,i],queryFn:n(({pageParam:h})=>W.instructionHistory(t,r,s,h),"queryFn"),initialPageParam:void 0,getNextPageParam:n(h=>h.nextCursor??void 0,"getNextPageParam"),enabled:d}),y=U({queryKey:["instruction-diff",t,r,c,i],queryFn:n(()=>W.instructionDiff(t,r,c,i,s),"queryFn"),enabled:d&&!!c}),S=te({mutationFn:n(()=>W.restoreInstructions(t,{path:r,revisionId:c,baseRevisionId:i},s),"mutationFn"),onSuccess:n(h=>{x(null),a(h)},"onSuccess")}),j=Dt(m),p=Dt(y);return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(M,{type:"button",size:"sm",variant:"outline","aria-expanded":d,onClick:n(()=>l(!d),"onClick"),children:"History"}),d&&(0,e.jsxs)("div",{className:"space-y-3",children:[j.kind==="error"&&(0,e.jsx)(yt,{size:"panel",error:j.error,action:"load revision history",onRetry:j.retry,retrying:j.isFetching}),p.kind==="error"&&(0,e.jsx)(yt,{size:"panel",error:p.error,action:"load the revision diff",onRetry:p.retry,retrying:p.isFetching}),S.isError&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:ur(S.error).body}),(j.kind==="loading"||j.kind==="reconnecting")&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading revisions…"}),m.data?.pages.flatMap(h=>h.revisions).map(h=>(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(M,{type:"button",size:"sm",variant:c===h.id?"secondary":"ghost",onClick:n(()=>x(h.id),"onClick"),children:(0,e.jsx)("span",{className:"font-mono",children:h.id.slice(0,8)})}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[h.source," ·"," ",new Date(h.createdAt).toLocaleString(),h.id===i?" · Current":""]})]},h.id)),m.hasNextPage&&(0,e.jsx)(M,{type:"button",variant:"ghost",disabled:m.isFetchingNextPage,onClick:n(()=>{m.fetchNextPage()},"onClick"),children:"Older revisions"}),y.data&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Selected revision"}),(0,e.jsx)("pre",{className:w("whitespace-pre-wrap break-words rounded-md border border-border p-3 font-mono text-sm","ph-mask ph-sensitive"),children:y.data.from.content}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Changes from selected revision to current"}),(0,e.jsxs)("pre",{className:w("whitespace-pre-wrap break-words rounded-md border border-border p-3 font-mono text-sm","ph-mask ph-sensitive"),children:[y.data.removed&&`Removed:
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentAdvancedTab-BG6ZIAuN.js","assets/rolldown-runtime-DhZMWcEn.js","assets/chat-channels-CzTZV2fr.js","assets/index-BJtnP7H1.js","assets/index-z7lcCz2I.css","assets/dist-CMZQedYl.js","assets/dist-Bmr4uhSk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var qr=Object.defineProperty;var n=(t,s)=>qr(t,"name",{value:s,configurable:!0});import{a as Xn}from"./rolldown-runtime-DhZMWcEn.js";import{$ as Ft,Ci as Mr,H as Dr,Ni as Kr,Pi as Br,Q as un,S as zr,Si as mn,U as Or,Y as Ur,Z as xn,_ as Hr,at as Qr,d as Wr,et as pn,f as Vr,fi as Gr,ft as Yr,g as er,h as Jr,it as Zr,l as Xr,m as ea,ot as ta,p as sa,pt as Ms,q as na,rt as ra,s as aa,u as ia,ui as oa}from"./issue-detail-CZfjXs0M.js";import{t as la}from"./BudgetPolicyCard-BYMlczCq.js";import{C as da,b as fn}from"./collections-B58p51lw.js";import{n as ca,t as ua}from"./AuditRuns-CUdlbP7S.js";import{t as ma}from"./coins-BDAh8hDQ.js";import{$A as xa,$S as Xe,$w as tr,$y as pa,Ab as sr,Ac as fa,Ap as hn,BC as ha,B_ as Ys,CC as Xt,CE as gn,Cb as ls,Cp as ga,Cx as ya,Db as ds,Dy as va,EC as ba,EO as nr,ET as Js,Eb as cs,Ep as Zt,Ex as ja,FE as ft,Fd as Na,Fu as Ds,GS as v,Gb as ce,Gd as yn,Gl as wa,Gn as ka,Gw as rr,HE as Ks,H_ as Nt,Hw as Sa,IC as Ca,IT as vn,In as Ra,Iy as Zs,Jl as Aa,Jp as ot,Kd as bn,Kl as Ia,Ko as Ea,Kv as us,LS as Xs,Ln as Ta,ME as Be,MT as es,Mc as ar,NE as M,Np as _a,Ob as ms,Op as La,Ou as Fa,PC as $a,Pp as Pa,QC as en,QT as xs,RE as qa,Rp as Ma,Ru as Da,Sb as ps,Sp as ir,TT as fs,Tb as hs,Ti as Ka,To as Bs,Tx as Ba,UE as et,UT as or,Ud as za,V_ as tn,WC as lr,WE as Oa,Wd as Ua,Wm as zs,Ww as Ha,XC as dr,XE as Ue,Xc as Qa,Xl as Wa,Xo as Va,Yb as Lt,Yc as Ga,Yo as Ya,ZE as Ja,ZT as Za,Z_ as Xa,_E as ei,_S as ti,_T as si,__ as qt,_w as Et,aD as ni,aE as gs,ab as yt,as as Rt,ay as vt,bC as Os,bE as te,bT as cr,cS as ri,cT as Us,ci as ai,cs as Ve,cv as sn,dE as jn,dk as ii,dl as oi,ds as li,eT as di,eb as ci,ev as ui,fb as mi,fi as xi,fs as pi,fy as fi,gC as Nn,hC as wn,hE as ur,hS as hi,hb as gi,hl as yi,hw as vi,iC as mr,iD as Tt,iS as xr,iT as bi,ib as pr,jT as dt,jc as ts,kT as st,kb as ys,kc as ji,kp as Ni,lC as wi,lS as gt,lb as ki,ls as Si,ly as Ci,mS as Ri,mb as Oe,my as Ai,nD as kn,nE as Ii,nj as Ei,oD as Ti,oE as _i,on as Li,pE as nn,pS as Fi,pT as Hs,pb as vs,pm as Mt,ps as $i,qC as rn,qD as Sn,qT as Pi,qb as qi,qo as Mi,qp as fr,rS as tt,rb as W,rm as Di,sD as Ki,sE as Bi,sm as zi,sy as Oi,tE as Ui,tT as hr,tb as Hi,uC as Qi,ub as Dt,us as Cn,ux as Qs,uy as Wi,vT as Vi,vb as ss,wb as bs,x as js,xE as U,x_ as gr,xb as ns,xw as Gi,yE as Yi,y_ as Ji,yb as rs,yl as Zi,zC as Pt,zE as w,z_ as an}from"./index-BJtnP7H1.js";import{t as ks}from"./budgets-CAWPqcn4.js";import{t as Xi}from"./ConfigureBuiltInAgentModal-DgeD7t_i.js";import{n as as,t as Ws}from"./AgentIdentityChip-BrVCcuHQ.js";import{t as eo}from"./company-skill-summary-DnWVmP1S.js";import{t as to}from"./SkillCardIcon-Cp_hws0N.js";import{t as so}from"./TaskSummaryList-eFDfK_QH.js";import{t as no}from"./MembershipAction-DTjhGn-L.js";import{t as ro}from"./AgentActionButtons-Cz3jCEd7.js";import{t as ao}from"./TrustPresetSection-DtWjK9Kp.js";import{t as io}from"./EnforcementBanner-B-iX466h.js";import{i as oo,o as lo,r as co,t as uo}from"./shared-D37zfckm.js";import{i as mo,n as xo,o as Rn,r as po,s as fo,t as ho}from"./useDateRange-CnZQr2KO.js";import{t as Ss}from"./MetricCard-CeL9Pdn5.js";var go=["source_run_missing","recovery_action_missing","recovery_action_run_mismatch","source_run_not_terminal","source_issue_mismatch","native_reference_invalid","restore_reference_invalid","historical_reference_invalid","lease_reference_invalid","source_lease_not_bound","lease_issue_mismatch","lease_environment_missing","lease_allocation_missing","lease_provider_invalid","lease_policy_not_retained","lease_cwd_invalid","allocation_reference_mismatch","cwd_reference_mismatch","workspace_reference_mismatch","recovery_lease_not_selected","recovery_environment_mismatch","recovery_lease_not_claimed","recovery_owner_mismatch","recovery_stop_intent_missing","local_descriptor_invalid","execution_target_invalid","recovery_stop_intent_invalid","reopened_allocation_mismatch","reopened_cwd_mismatch"],yo={schema:{const:"paperclip.provider-failure.v1"},provider:{type:"string",minLength:1,maxLength:80,pattern:"^[a-zA-Z0-9_.:/-]+$"},phase:{enum:["startup","turn"]},category:{enum:["rate_limit","quota_exhausted","authentication","permission","model_unavailable","invalid_request","overloaded","timeout","unknown"]},message:{type:"string",minLength:1,maxLength:4e3},providerCode:{type:"string",minLength:1,maxLength:160,pattern:"^[a-zA-Z0-9_.:/-]+$"},httpStatus:{type:"integer",minimum:400,maximum:599},requestId:{type:"string",minLength:1,maxLength:160,pattern:"^[a-zA-Z0-9_.:/-]+$"},retryAt:{type:"string",format:"date-time"},retryability:{enum:["transient","requires_action","unknown"]}};function An(t){try{if(!t||typeof t!="object"||Array.isArray(t))return null;const s=t,r={};for(const[i,o]of Object.entries(yo)){const a=s[i];if(!(a===void 0&&!["schema","provider","phase","category","message","retryability"].includes(i))){if("const"in o){if(a!==o.const)return null}else if("enum"in o){if(typeof a!="string"||!o.enum.includes(a))return null}else if(o.type==="integer"){if(typeof a!="number"||!Number.isInteger(a)||a<o.minimum||a>o.maximum)return null}else if(typeof a!="string"||"maxLength"in o&&([...a].length<o.minLength||[...a].length>o.maxLength)||"pattern"in o&&!new RegExp(o.pattern).test(a)||"format"in o&&!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(a)||"format"in o&&!Number.isFinite(Date.parse(a)))return null;r[i]=a}}return r}catch{return null}}n(An,"readProviderFailure");var yr={name:"git-compare",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]};yr.node;var vo=xs(yr),vr={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]};vr.node;var bo=xs(vr),br={name:"slash",size:24,node:[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]};br.node;var jo=xs(br),jr={name:"timer",size:24,node:[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]};jr.node;var No=xs(jr),u=Xn(Ei(),1),e=Xn(xa(),1);function wo({context:t}){const s=t?.paperclipRunSettings,r=typeof s?.model=="string"?s.model:null,i=typeof s?.effort=="string"?s.effort:null;return!r&&!i?null:(0,e.jsxs)("div",{className:"rounded-lg border p-4 text-sm space-y-1","data-testid":"run-settings-run-details",children:[(0,e.jsx)("p",{className:"font-medium",children:"Run settings"}),(0,e.jsx)("p",{className:w(Xe),children:[r?`Model ${r}`:"Agent default model",i?`effort ${i}`:null].filter(Boolean).join(" · ")})]})}n(wo,"RunSettingsRunDetails");function ko(t,s,r,i){const o=t.find(l=>l.id===s)??null,a=U({queryKey:v.runDetail(s??""),queryFn:n(()=>tt.get(s),"queryFn"),enabled:!!(s&&!o)}),d=a.data?.id===s&&a.data.companyId===r&&a.data.agentId===i?a.data:null;return{run:o??d,loading:a.isPending,error:a.error,retry:a.refetch}}n(ko,"useSelectedHeartbeatRun");function So({context:t}){const s=t?.aiRouterSelection;if(!s)return null;const r=t?.aiConnection,i=s.runtimeConfig,o=i.modelReasoningEffort??i.reasoningEffort??i.effort??i.variant;return(0,e.jsxs)("div",{className:"rounded-lg border p-4 text-sm space-y-1",children:[(0,e.jsxs)("p",{className:w("font-medium",Xe),children:["Task-pinned pool account · ",r?.accountName??r?.connectionId??"Selected account"]}),(0,e.jsx)("p",{children:[s.binding.provider,i.provider,i.acpxAgent,i.model,o].filter(Boolean).map(String).join(" · ")}),s.notes.length>0&&(0,e.jsx)("p",{className:"text-muted-foreground",children:s.notes.join(" ")})]})}n(So,"AiConnectionPoolRunDetails");function Co({agentId:t,companyId:s,path:r,currentRevisionId:i,disabled:o,onRestored:a}){const[d,l]=(0,u.useState)(!1),[c,x]=(0,u.useState)(null),m=da({queryKey:["instruction-history",t,r,i],queryFn:n(({pageParam:h})=>W.instructionHistory(t,r,s,h),"queryFn"),initialPageParam:void 0,getNextPageParam:n(h=>h.nextCursor??void 0,"getNextPageParam"),enabled:d}),y=U({queryKey:["instruction-diff",t,r,c,i],queryFn:n(()=>W.instructionDiff(t,r,c,i,s),"queryFn"),enabled:d&&!!c}),S=te({mutationFn:n(()=>W.restoreInstructions(t,{path:r,revisionId:c,baseRevisionId:i},s),"mutationFn"),onSuccess:n(h=>{x(null),a(h)},"onSuccess")}),j=Dt(m),p=Dt(y);return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(M,{type:"button",size:"sm",variant:"outline","aria-expanded":d,onClick:n(()=>l(!d),"onClick"),children:"History"}),d&&(0,e.jsxs)("div",{className:"space-y-3",children:[j.kind==="error"&&(0,e.jsx)(yt,{size:"panel",error:j.error,action:"load revision history",onRetry:j.retry,retrying:j.isFetching}),p.kind==="error"&&(0,e.jsx)(yt,{size:"panel",error:p.error,action:"load the revision diff",onRetry:p.retry,retrying:p.isFetching}),S.isError&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:ur(S.error).body}),(j.kind==="loading"||j.kind==="reconnecting")&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading revisions…"}),m.data?.pages.flatMap(h=>h.revisions).map(h=>(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(M,{type:"button",size:"sm",variant:c===h.id?"secondary":"ghost",onClick:n(()=>x(h.id),"onClick"),children:(0,e.jsx)("span",{className:"font-mono",children:h.id.slice(0,8)})}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[h.source," ·"," ",new Date(h.createdAt).toLocaleString(),h.id===i?" · Current":""]})]},h.id)),m.hasNextPage&&(0,e.jsx)(M,{type:"button",variant:"ghost",disabled:m.isFetchingNextPage,onClick:n(()=>{m.fetchNextPage()},"onClick"),children:"Older revisions"}),y.data&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Selected revision"}),(0,e.jsx)("pre",{className:w("whitespace-pre-wrap break-words rounded-md border border-border p-3 font-mono text-sm","ph-mask ph-sensitive"),children:y.data.from.content}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Changes from selected revision to current"}),(0,e.jsxs)("pre",{className:w("whitespace-pre-wrap break-words rounded-md border border-border p-3 font-mono text-sm","ph-mask ph-sensitive"),children:[y.data.removed&&`Removed:
|
|
3
3
|
${y.data.removed}
|
|
4
4
|
`,y.data.added&&`Added:
|
|
5
5
|
${y.data.added}`,!y.data.removed&&!y.data.added&&"No content changes."]}),(0,e.jsx)(M,{type:"button",disabled:o||S.isPending||c===i,onClick:n(()=>S.mutate(),"onClick"),children:"Restore as new revision"}),o&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Save or cancel your edits before restoring."})]})]})]})}n(Co,"InstructionHistory");function Ro(t){return t.grokWork?t.isPending?"Stopping Microvac work…":"Stop Microvac work":t.isFailed?t.isPending?"Stopping…":"Stop":t.isPending?"Cancelling…":"Cancel"}n(Ro,"runCancellationLabel");var Ot=new Map,In=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i,Cs=n(t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},"record");async function Ao(t,s){jn(`/heartbeat-runs/${t}`),jn("/cli-auth/me");const[r,i]=await Promise.all([tt.get(t),vt.getCurrentBoardAccess()]);if(r.id!==t||r.companyId!==s)throw new Error("Stop was not accepted because the run changed.");const o=i.userId;if(!o)throw new Error("Stop was not accepted because your session changed.");const a=Ri(`paperclip:native-run-stop:${s}:${t}`,o),d=n(j=>{const p=Cs(j);return p.runId===t&&p.companyId===s&&p.actorUserId===o},"matchesScope"),l=Cs(r.resultJson?.startupCancellation),c=l.cancellationRequestId;if(c!==void 0){const j=Cs(l.requestedBy);if(j.type!=="board"||j.userId!==o)throw new Error("This Stop request belongs to another operator.");if(typeof c!="string"||!In.test(c))throw new Error("Stop was not accepted because the run changed.")}const x=hi(a,d,"session")??Ot.get(a),m=typeof c=="string"?c:x&&d(x.payload)&&In.test(x.idempotencyKey)?x.idempotencyKey:ri(),y={idempotencyKey:m,payload:{runId:t,companyId:s,actorUserId:o},createdAt:x?.createdAt??Date.now()};Ot.set(a,y),ti(a,y,"session");const S=await tt.cancel(t,{cancellationRequestId:m});return Fi(a,m,"session"),Ot.get(a)?.idempotencyKey===m&&Ot.delete(a),S}n(Ao,"stopFailedNativeRun");function Io(t,s){return t===s?!0:t.length!==s.length?!1:t.every((r,i)=>r===s[i])}n(Io,"arraysEqual");function Vs(t,s){const r=new Set(t),i=new Set(s);if(r.size!==i.size)return!1;for(const o of r)if(!i.has(o))return!1;return!0}n(Vs,"sameSkillSelection");function Eo(t,s){const r=!t.hasHydratedSnapshot||Io(t.draft,t.lastSaved);return{draft:r?s:t.draft,lastSaved:s,hasHydratedSnapshot:!0,shouldSkipAutosave:r}}n(Eo,"applyAgentSkillSnapshot");function En(t){return!(Vs(t.draft,t.lastSaved)||t.failedDraft&&Vs(t.draft,t.failedDraft))}n(En,"shouldScheduleSkillAutosave");function To(t,s){return s.has(t.key)?!1:t.origin==="user_installed"||t.origin==="external_unknown"?!0:t.managed===!1&&t.state==="external"}n(To,"isReadOnlyUnmanagedSkillEntry");function Tn({variant:t,data:s,checked:r=!1,disabled:i=!1,disabledReason:o,onCheckedChange:a,badge:d,accessory:l}){const c=t==="readonly",x=s.sourceMeta?.icon,m=(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,e.jsx)(to,{card:s.icon,size:32}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),d?(0,e.jsx)("span",{className:"shrink-0",children:d}):null,s.chip?(0,e.jsx)("span",{className:"hidden shrink-0 items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-(length:--text-nano) capitalize text-muted-foreground sm:inline-flex",children:s.chip}):null]}),s.summary?(0,e.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:s.summary}):null,s.sourceMeta&&x?(0,e.jsxs)("p",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-(length:--text-nano) text-muted-foreground/80",children:[(0,e.jsx)(x,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{className:"truncate",children:s.sourceMeta.label})]}):null,c&&s.originLabel?(0,e.jsxs)("p",{className:"mt-0.5 truncate text-(length:--text-nano) text-muted-foreground/80",children:[s.originLabel,s.locationLabel?` · ${s.locationLabel}`:""]}):null]})]}),y=w("flex min-h-11 flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-3 py-2.5 last:border-b-0 sm:flex-nowrap sm:gap-y-3",c?"bg-muted/20":"transition-colors hover:bg-accent/50"),S=s.linkTo?(0,e.jsx)(ce,{to:s.linkTo,className:"flex min-w-0 flex-1 items-center gap-3 no-underline outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:m}):m,j=c?(0,e.jsx)(vi,{className:"h-4 w-4 shrink-0 text-muted-foreground/60","aria-label":"Read-only"}):(()=>{const p=(0,e.jsx)(Zt,{checked:r,disabled:i,onCheckedChange:n(h=>a?.(h),"onCheckedChange"),"aria-label":`${r?"Disable":"Enable"} ${s.name}`});return i&&o?(0,e.jsxs)(ss,{children:[(0,e.jsx)(ns,{asChild:!0,children:(0,e.jsx)("span",{className:"shrink-0",children:p})}),(0,e.jsx)(rs,{side:"left",children:o})]}):(0,e.jsx)("span",{className:"shrink-0",children:p})})();return(0,e.jsxs)("div",{className:y,children:[S,l&&!c?(0,e.jsx)("div",{className:"order-last w-full shrink-0 sm:order-none sm:w-auto",children:l}):null,j]})}n(Tn,"AgentSkillRow");function _o(t){return[t.name,t.slug??"",t.author??"",t.tagline??"",t.description??"",(t.categories??[]).join(" ")].join(" ").toLowerCase()}n(_o,"buildAgentSkillHaystack");function Lo(t,s){const r=s.trim();return r?_o(t).includes(r.toLowerCase()):!0}n(Lo,"agentSkillMatchesSearch");function Rs(t,s){const r=s.trim();return r?t.filter(i=>Lo(i,r)):t}n(Rs,"filterAgentSkills");function Ut(t){return t.replace(/\.git$/i,"")}n(Ut,"cleanRepoName");function Ht(t){const s=t?.trim();if(!s)return null;const r=n(a=>{const[d,l]=a.split("/").filter(Boolean);return!d||!l?null:`${d}/${Ut(l)}`},"parsePath");try{const a=new URL(s.startsWith("http")?s:`https://${s}`);if(a.hostname.toLowerCase().includes("github"))return r(a.pathname)}catch{}const i=s.match(/^git@[^:]+:([^/]+)\/([^/#?]+)(?:[/?#]|$)/i);if(i?.[1]&&i[2])return`${i[1]}/${Ut(i[2])}`;const o=s.match(/github\.com[:/]([^/]+)\/([^/#?]+)(?:[/?#]|$)/i);if(o?.[1]&&o[2])return`${o[1]}/${Ut(o[2])}`;if(!on(s)){const a=s.match(/^([^/\s]+)\/([^/\s]+)(?:[/?#]|$)/);if(a?.[1]&&a[2])return`${a[1]}/${Ut(a[2])}`}return null}n(Ht,"githubRepoLabel");function _n(t){const s=t?.trim();if(!s)return null;try{return new URL(s.startsWith("http")?s:`https://${s}`).hostname}catch{return null}}n(_n,"hostLabel");function on(t){return t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../")||/^[A-Za-z]:[\\/]/.test(t)||t.includes("\\")||t.includes("/")&&!t.includes(" / ")}n(on,"isFilesystemLikeLabel");function Fo(t){const s=t?.trim();return!s||on(s)?"Local folder":s}n(Fo,"displayLocalSourceLabel");function Ln(t){const s=t?.trim();return!s||on(s)?"Catalog":s}n(Ln,"displayCatalogSourceLabel");function $o(t){if(t.sourceBadge==="github"||t.sourceType==="github"){const s=Ht(t.sourceLabel)??Ht(t.sourceLocator);return{icon:Bs,label:s?`GitHub · ${s}`:"GitHub"}}if(t.sourceBadge==="skills_sh"||t.sourceType==="skills_sh"){const s=Ht(t.sourceLabel)??Ht(t.sourceLocator);return{icon:Bs,label:s?`skills.sh · ${s}`:"skills.sh"}}return t.sourceBadge==="url"||t.sourceType==="url"?{icon:Gi,label:_n(t.sourceLabel)??_n(t.sourceLocator)??"URL"}:t.sourceBadge==="paperclip"?{icon:en,label:t.sourceLabel?.trim()||"Microvac managed"}:t.sourceBadge==="catalog"||t.sourceType==="catalog"?{icon:vn,label:Ln(t.sourceLabel)}:t.sourceBadge==="local"||t.sourceType==="local_path"?{icon:Ha,label:Fo(t.sourceLabel)}:{icon:vn,label:Ln(t.sourceLabel)}}n($o,"buildAgentSkillSourceMeta");var Po="default",As="Default — current (recommended)";function qo(t){if(!t)return null;const s=typeof t=="string"?t:t.toISOString();if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const r=new Date(s);return Number.isNaN(r.getTime())?null:`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}n(qo,"formatReleaseDate");function Nr(t){return t.releaseName??t.label??t.releaseId??"Release"}n(Nr,"releaseName");function Mo(t){const s=Nr(t),r=qo(t.releasedAt);return r?`${s} · released ${r}`:s}n(Mo,"releaseOptionLabel");function Do(t){return(t.releaseName??t.label??t.releaseId??"Release").split(" — ")[0].trim()}n(Do,"releaseShortLabel");function Ko({releases:t,value:s,disabled:r=!1,onChange:i}){const o=s?t.find(d=>d.id===s)??null:null,a=o?Nr(o):As;return(0,e.jsxs)(La,{value:s??"default",disabled:r,onValueChange:n(d=>i(d==="default"?null:d),"onValueChange"),children:[(0,e.jsx)(_a,{size:"sm",className:"w-full max-w-(--sz-16rem) sm:w-(--sz-16rem)","aria-label":"Skill release",children:(0,e.jsx)(Pa,{placeholder:As,children:a})}),(0,e.jsxs)(Ni,{align:"end",className:"max-w-(--sz-20rem)",children:[(0,e.jsx)(hn,{value:Po,children:As}),t.map(d=>(0,e.jsx)(hn,{value:d.id,children:(0,e.jsxs)("span",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"truncate",children:Mo(d)}),(0,e.jsx)(Nt,{variant:"secondary",className:"shrink-0 text-(length:--text-nano)",children:"Beta"})]})},d.id))]})]})}n(Ko,"AgentSkillReleasePicker");var Bo="Enabled skills are materialized into the stable Paperclip-managed prompt bundle on the agent's next run.",Is="paperclipai/paperclip/paperclip";function Fn(t,s,r=!0){return t.map(i=>r&&s[i]?{key:i,versionId:s[i]}:i)}n(Fn,"toDesiredSkillPayload");function zo(t){return typeof t=="string"?t:t.key}n(zo,"desiredSkillKey");function $n(t){const s={};for(const r of t??[])r.versionId&&(s[r.key]=r.versionId);return s}n($n,"pinsFromEntries");function Oo({agent:t,companyId:s}){const r=Be(),[i,o]=(0,u.useState)([]),[a,d]=(0,u.useState)([]),[l,c]=(0,u.useState)({}),x=(0,u.useRef)({}),[m,y]=(0,u.useState)(""),[S,j]=(0,u.useState)(!1),p=(0,u.useRef)([]),h=(0,u.useRef)(!1),f=(0,u.useRef)(!0),$=(0,u.useRef)(null),{data:C,isLoading:R}=U({queryKey:v.agents.skills(t.id),queryFn:n(()=>W.skills(t.id,s),"queryFn"),enabled:!!s}),{data:T}=U({queryKey:v.companySkills.list(s??""),queryFn:n(()=>zs.list(s),"queryFn"),enabled:!!s}),{data:D}=U({queryKey:v.instance.experimentalSettings,queryFn:n(()=>us.getExperimental(),"queryFn")}),F=D?.enableBetaSkills===!0,se=(0,u.useMemo)(()=>(T??[]).find(N=>N.key===Is)??null,[T,C]),{data:ee}=U({queryKey:v.companySkills.versions(s??"",se?.id??""),queryFn:n(()=>zs.versions(s,se.id),"queryFn"),enabled:!!(s&&F&&se?.id)}),ae=(0,u.useMemo)(()=>(ee??[]).filter(N=>N.releaseId!=null),[ee]),O=te({mutationFn:n(N=>W.syncSkills(t.id,N,"replace",s),"mutationFn"),onSuccess:n(async N=>{r.setQueryData(v.agents.skills(t.id),N),p.current=N.desiredSkills,d(N.desiredSkills);const V=$n(N.desiredSkillEntries);x.current=V,c(V),await Promise.all([r.invalidateQueries({queryKey:v.agents.detail(t.id)}),r.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})])},"onSuccess"),onError:n((N,V)=>{$.current=V.map(zo)},"onError")});(0,u.useEffect)(()=>{o([]),d([]),p.current=[],c({}),x.current={},h.current=!1,f.current=!0,$.current=null},[t.id]),(0,u.useEffect)(()=>{if(!C||O.isPending)return;const N=$n(C.desiredSkillEntries);x.current=N,c(N)},[C,O.isPending]),(0,u.useEffect)(()=>{if(!C)return;const N=Eo({draft:i,lastSaved:p.current,hasHydratedSnapshot:h.current},C.desiredSkills);f.current=N.shouldSkipAutosave,h.current=N.hasHydratedSnapshot,o(N.draft),p.current=N.lastSaved,d(N.lastSaved)},[i,C]),(0,u.useEffect)(()=>{if(!C)return;if(f.current){f.current=!1;return}if(O.isPending||!En({draft:i,lastSaved:p.current,failedDraft:$.current}))return;const N=window.setTimeout(()=>{En({draft:i,lastSaved:p.current,failedDraft:$.current})&&O.mutate(Fn(i,x.current,F))},250);return()=>window.clearTimeout(N)},[F,i,C,O.isPending,O.isError,O.mutate]);const me=(0,u.useMemo)(()=>new Map((T??[]).map(N=>[N.key,N])),[T]),le=(0,u.useMemo)(()=>new Set((T??[]).map(N=>N.key)),[T]);(0,u.useMemo)(()=>new Map((C?.entries??[]).map(N=>[N.key,N])),[C]);const ne=C?.mode==="unsupported",X=(0,u.useMemo)(()=>(T??[]).filter(N=>!(C?.entries??[]).some(V=>V.key===N.key&&V.readOnly)).map(N=>({key:N.key,name:N.name,icon:{key:N.key,name:N.name,slug:N.slug,iconUrl:N.iconUrl,color:N.color},summary:eo(N,{fallbackKey:!0}),chip:N.categories[0]??null,sourceMeta:$o(N),linkTo:`/skills/${N.id}`,slug:N.slug,author:N.authorName??N.sourceLabel,tagline:N.tagline,description:N.description,categories:N.categories})),[T,C]),b=(0,u.useMemo)(()=>(C?.entries??[]).filter(N=>N.readOnly&&N.desired||To(N,le)).map(N=>({key:N.key,name:N.runtimeName??N.key,icon:{key:N.key,name:N.runtimeName??N.key,slug:null,iconUrl:null,color:null},summary:N.detail??null,chip:null,linkTo:null,originLabel:N.originLabel??null,locationLabel:N.locationLabel??null})),[le,C]),L=(0,u.useMemo)(()=>X.filter(N=>i.includes(N.key)),[X,i]),K=(0,u.useMemo)(()=>X.filter(N=>!i.includes(N.key)),[X,i]),z=(0,u.useMemo)(()=>i.filter(N=>!me.has(N)),[me,i]),q=(0,u.useMemo)(()=>Rs(L,m),[L,m]),pe=(0,u.useMemo)(()=>Rs(K,m),[K,m]),we=(0,u.useMemo)(()=>Rs(b,m),[b,m]),Me=(0,u.useMemo)(()=>{switch(C?.mode){case"persistent":return"Kept in workspace";case"ephemeral":return"Applied on next run";case"unsupported":return"Tracked only";default:return null}},[C?.mode]),I=(0,u.useMemo)(()=>ne?t.adapterType==="acpx_local"&&typeof t.adapterConfig.agent=="string"&&t.adapterConfig.agent==="custom"?"Microvac cannot manage skills for custom ACP commands yet.":t.adapterType==="openclaw_gateway"?"Microvac cannot manage OpenClaw skills here. Visit your OpenClaw instance to manage this agent's skills.":"Microvac cannot manage skills for this adapter yet. Manage them in the adapter directly.":null,[t.adapterConfig.agent,t.adapterType,ne]),De=!Vs(i,a),_e=n((N,V)=>{o(A=>V?Array.from(new Set([...A,N])):A.filter(Z=>Z!==N))},"toggleSkill"),Ce=n((N,V)=>{const A={...x.current};V?A[N]=V:delete A[N],x.current=A,c(A),O.mutate(Fn(i,A))},"handleReleaseChange"),xe=F&&ae.length>0,_=n((N,V)=>{const A=t.adapterType==="paperclip_runner"&&V==="available"&&N.key===Is,Z=ne||A,be=A?"Microvac Runner uses native semantic coordination and cannot attach the legacy Microvac operational skill.":I,Ne=xe&&V==="enabled"&&N.key===Is,Re=l[N.key]??null,ve=Re?ae.find(Se=>Se.id===Re)??null:null;return(0,e.jsx)(Tn,{variant:V,data:N,checked:V==="enabled",disabled:Z,disabledReason:be,onCheckedChange:n(Se=>_e(N.key,Se),"onCheckedChange"),badge:Ne&&ve?(0,e.jsxs)(Nt,{variant:"secondary",className:"text-(length:--text-nano)",children:["Beta · ",Do(ve)]}):void 0,accessory:Ne?(0,e.jsx)(Ko,{releases:ae,value:Re,disabled:Z||O.isPending,onChange:n(Se=>Ce(N.key,Se),"onChange")}):void 0},N.key)},"renderRow"),ue=X.length===0;return(0,e.jsxs)("div",{className:"max-w-4xl space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-foreground",children:[L.length," of ",X.length," enabled"]}),Me?(0,e.jsxs)(ss,{children:[(0,e.jsx)(ns,{asChild:!0,children:(0,e.jsx)("span",{className:"inline-flex cursor-default items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-xs text-muted-foreground",children:Me})}),(0,e.jsx)(rs,{side:"bottom",className:"max-w-xs",children:ne?I:Bo})]}):null,(0,e.jsx)(Uo,{pending:O.isPending,unsaved:De,error:O.isError&&De}),(0,e.jsxs)("div",{"data-canonical-toolbar":"agent-skills",role:"toolbar","aria-label":"Agent skills controls",className:"ml-auto flex w-full flex-col items-stretch gap-2 sm:w-auto sm:flex-row sm:items-center",children:[(0,e.jsxs)("div",{className:"relative w-full sm:w-auto",children:[(0,e.jsx)(Ca,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,e.jsx)(qt,{value:m,onChange:n(N=>y(N.target.value),"onChange"),placeholder:"Search skills",className:"h-8 w-full pl-8 sm:w-56","aria-label":"Search skills"})]}),(0,e.jsx)(M,{asChild:!0,variant:"outline",size:"sm",className:"shrink-0",children:(0,e.jsxs)(ce,{to:"/skills",className:"no-underline",children:[(0,e.jsx)(Os,{className:"h-3.5 w-3.5"}),"Browse skills store"]})})]})]}),O.isError?(0,e.jsx)("p",{className:"text-xs text-destructive",children:ur(O.error).body}):null]}),I?(0,e.jsx)("div",{className:"rounded-lg border border-border bg-muted/30 px-4 py-3 text-sm text-muted-foreground",children:I}):null,z.length>0?(0,e.jsx)("div",{className:"overflow-hidden rounded-lg border border-amber-300/60 dark:border-amber-500/30",children:z.map(N=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-amber-300/40 bg-amber-50/60 px-3 py-2 text-xs text-amber-800 last:border-b-0 dark:border-amber-500/20 dark:bg-amber-950/20 dark:text-amber-200",children:[(0,e.jsxs)("span",{className:"min-w-0 truncate",children:[(0,e.jsx)("span",{className:"font-medium",children:N})," is enabled but missing from the organization library."]}),(0,e.jsxs)("button",{type:"button",onClick:n(()=>_e(N,!1),"onClick"),className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-amber-400/50 px-2 py-0.5 font-medium transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-900/30",children:[(0,e.jsx)(mr,{className:"h-3 w-3"}),"Remove"]})]},N))}):null,R?(0,e.jsx)(vs,{variant:"list"}):ue&&b.length===0?(0,e.jsx)(Ho,{}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(Pn,{title:"Enabled on this agent",count:q.length,children:q.length>0?q.map(N=>_(N,"enabled")):(0,e.jsx)(Es,{children:m?"No enabled skills match your search.":"No skills enabled on this agent yet."})}),(0,e.jsx)(Pn,{title:"Available from the library",count:pe.length,children:pe.length>0?pe.map(N=>_(N,"available")):(0,e.jsx)(Es,{children:m?"No available skills match your search.":ue?"Import skills into the organization library to enable them here.":"Every library skill is enabled on this agent."})}),b.length>0?(0,e.jsx)(an,{open:S,onOpenChange:j,children:(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border",children:[(0,e.jsxs)(tn,{className:"flex w-full items-center gap-2 bg-muted/50 px-3 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,e.jsx)(dt,{className:w("h-3.5 w-3.5 text-muted-foreground transition-transform",S?"":"-rotate-90")}),(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Automatic and detected skills (read-only)"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground/70",children:we.length})]}),(0,e.jsx)(Ys,{children:we.length>0?we.map(N=>(0,e.jsx)(Tn,{variant:"readonly",data:N},N.key)):(0,e.jsx)(Es,{children:"No detected skills match your search."})})]})}):null,(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Adapter: ",za[t.adapterType]??t.adapterType]})]})]})}n(Oo,"AgentSkillsTab");function Uo({pending:t,unsaved:s,error:r}){return t?(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(Et,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):r?(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-destructive",children:[(0,e.jsx)(Js,{className:"h-3.5 w-3.5"}),"Couldn’t save"]}):s?(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(Et,{className:"h-3.5 w-3.5 animate-spin"}),"Saving soon…"]}):(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-(--status-task-done)",children:[(0,e.jsx)(fs,{className:"h-3.5 w-3.5"}),"Saved"]})}n(Uo,"SaveStatusChip");function Pn({title:t,count:s,children:r}){return(0,e.jsxs)("section",{className:"overflow-hidden rounded-lg border border-border",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 bg-muted/50 px-3 py-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:t}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground/70",children:s})]}),(0,e.jsx)("div",{children:r})]})}n(Pn,"SkillSection");function Es({children:t}){return(0,e.jsx)("div",{className:"px-3 py-4 text-xs text-muted-foreground",children:t})}n(Es,"SectionEmpty");function Ho(){return(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-border px-6 py-10 text-center",children:[(0,e.jsx)(Os,{className:"h-8 w-8 text-muted-foreground/60"}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No skills in the organization library"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Install skills to the organization, then enable them on this agent."})]}),(0,e.jsx)(M,{asChild:!0,variant:"outline",size:"sm",children:(0,e.jsxs)(ce,{to:"/skills",className:"no-underline",children:[(0,e.jsx)(Os,{className:"h-3.5 w-3.5"}),"Browse skills store"]})})]})}n(Ho,"EmptyLibraryCard");var qn={preparing:["Preparing agent","Required resources are being prepared. Work stays queued."],verifying:["Verifying agent","The saved execution configuration is being checked. Work stays queued."],pausing:["Pausing agent","Waiting for execution and required resources to stop."],resuming:["Resuming agent","Required resources are being started. Work stays queued."],terminating:["Terminating agent","Stopping execution before resource cleanup."],cleaning_up:["Cleaning up agent","Required resources are being removed. Termination is not complete."]},Qo={preparing:"Agent preparation failed",verifying:"Agent verification failed",pausing:"Agent pause failed",resuming:"Agent resume failed",terminating:"Agent termination failed",cleaning_up:"Agent cleanup failed"};function wr(t){return t&&t in qn?qn[t]:void 0}n(wr,"pendingPhase");function Wo(t){return wr(t)?2e3:3e4}n(Wo,"agentLifecycleRefetchInterval");function Vo(t){return U({queryKey:[...v.agents.detail(t?.id??""),"lifecycle",t?.companyId],queryFn:n(()=>W.get(t.id,t.companyId),"queryFn"),enabled:!!t,select:n(s=>({status:s.status,pauseReason:s.pauseReason,pausedAt:s.pausedAt,lifecycleState:s.lifecycleState,lifecycleVersion:s.lifecycleVersion,lifecycleError:s.lifecycleError}),"select"),refetchInterval:n(s=>Wo(s.state.data?.lifecycleState??t?.lifecycleState),"refetchInterval")})}n(Vo,"useAgentLifecycleStatus");function Go({agent:t,onRetry:s,retryPending:r,refreshError:i=!1}){const o=wr(t.lifecycleState);return!o&&!i?null:(0,e.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 text-sm",children:[i&&(0,e.jsx)("p",{className:"text-destructive",children:"Could not refresh agent lifecycle status."}),o&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(Nt,{variant:t.lifecycleError?"destructive":"secondary",children:[!t.lifecycleError&&(0,e.jsx)(Et,{"aria-hidden":"true",className:"mr-1 size-3 animate-spin motion-reduce:animate-none"}),t.lifecycleError?Qo[t.lifecycleState]:o[0]]}),!t.lifecycleError&&(0,e.jsx)("span",{className:"text-muted-foreground",children:o[1]})]}),o&&t.lifecycleError&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-destructive",children:[(0,e.jsx)("span",{children:t.lifecycleError}),(0,e.jsx)(M,{variant:"outline",size:"sm",disabled:r,onClick:s,children:r?"Retrying…":"Retry now"})]}),o&&t.lifecycleError&&(0,e.jsx)("p",{className:"text-muted-foreground",children:t.lifecycleState==="verifying"||t.lifecycleState==="resuming"?"Retry now checks the saved configuration again immediately.":"Microvac retries automatically; Retry now checks again immediately."})]})}n(Go,"AgentLifecycleStatus");var Yo={ready:{color:"green",glyph:"●",label:"Ready",title:"Materialized and matches the shipped default"},needs_setup:{color:"amber",glyph:"⚠",label:"Needs setup",title:"Present but not usable yet"},missing:{color:"amber",glyph:"⚠",label:"Missing",title:"Expected resource absent; reconcile will recreate it"},error:{color:"red",glyph:"✕",label:"Error",title:"Failed to load or reconcile"},update_available:{color:"blue",glyph:"↑",label:"Update available",title:"Unedited — a newer shipped default can be applied"},drifted:{color:"gray",glyph:"✎",label:"Drifted",title:"You've edited this; your changes are kept, not overwritten"},schedule_off:{color:"gray",glyph:"◌",label:"Schedule off",title:"No background work runs until you enable it — costs zero tokens"},schedule_on:{color:"green",glyph:"●",label:"Weekly",title:"Runs on the weekly schedule"},pending_approval:{color:"amber",glyph:"⚠",label:"Pending approval",title:"Waiting on board hire approval before it can run"},proposal_pending:{color:"blue",glyph:"↑",label:"Proposal pending",title:"A proposed update is waiting for your review"}};function At({variant:t,label:s,compact:r=!1,className:i}){const o=Yo[t];return(0,e.jsxs)(Nt,{variant:"outline",className:w(Qs[o.color],"font-medium",r&&"px-1.5 py-0 text-(length:--text-nano)",i),title:o.title,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:o.glyph}),s??o.label]})}n(At,"ResourceStatusChip");function Ts(t,s){return t?.find(r=>r.resourceKind===s)}n(Ts,"findResource");function Jo(t){return t.stockStatus==="missing"?"missing":"ready"}n(Jo,"readinessVariant");function Qt(t){return t.stockStatus==="missing"?null:t.stockStatus==="stock_update_available"?"update_available":t.stockStatus==="operator_modified"?"drifted":null}n(Qt,"driftVariant");function Zo(t,s){return t.stockStatus==="stock_update_available"?{title:`Update ${s} to the newest default?`,body:"You haven't edited this, so Microvac will replace it with the newer shipped version. Nothing you customized is affected, and your adapter credentials and settings are not touched.",confirmLabel:"Update",triggerLabel:"Update"}:t.stockStatus==="operator_modified"?{title:`Reset ${s} to the shipped default?`,body:"This replaces your edited version with Microvac's current default. Your edits can't be recovered. Adapter credentials and settings are not touched.",confirmLabel:`Reset ${s}`,triggerLabel:"Reset"}:t.stockStatus==="missing"?{title:`Recreate ${s}?`,body:"This resource is missing. Microvac will recreate it from the shipped default. Adapter credentials and settings are not touched.",confirmLabel:"Recreate",triggerLabel:"Recreate"}:null}n(Zo,"resourceActionCopy");function Mn({resource:t,label:s,onConfirm:r,pending:i}){const o=Zo(t,s);return o?(0,e.jsxs)(ps,{children:[(0,e.jsx)(sr,{asChild:!0,children:(0,e.jsx)(M,{variant:"outline",size:"sm",disabled:i,children:i?"Working…":o.triggerLabel})}),(0,e.jsxs)(hs,{children:[(0,e.jsxs)(ms,{children:[(0,e.jsx)(ys,{children:o.title}),(0,e.jsx)(cs,{children:o.body})]}),(0,e.jsxs)(ds,{children:[(0,e.jsx)(bs,{children:"Cancel"}),(0,e.jsx)(ls,{onClick:r,children:o.confirmLabel})]})]})]}):null}n(Mn,"ResourceActionButton");function _s({title:t,body:s,triggerLabel:r,confirmLabel:i,pending:o,onConfirm:a}){return(0,e.jsxs)(ps,{children:[(0,e.jsx)(sr,{asChild:!0,children:(0,e.jsx)(M,{variant:"outline",size:"sm",disabled:o,children:o?"Working…":r})}),(0,e.jsxs)(hs,{children:[(0,e.jsxs)(ms,{children:[(0,e.jsx)(ys,{children:t}),(0,e.jsx)(cs,{children:s})]}),(0,e.jsxs)(ds,{children:[(0,e.jsx)(bs,{children:"Cancel"}),(0,e.jsx)(ls,{onClick:a,children:i})]})]})]})}n(_s,"ConfirmActionButton");function Wt({label:t,secondary:s,chips:r,detail:i,detailTone:o="muted",actions:a}){return(0,e.jsxs)("div",{className:"flex flex-col gap-1 py-3 sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:t}),s&&(0,e.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:s}),r]}),i&&(0,e.jsx)("p",{className:w("text-(length:--text-micro) leading-snug",o==="error"?"text-red-600 dark:text-red-400":"text-muted-foreground"),children:i})]}),a&&(0,e.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:a})]})}n(Wt,"BundleRow");function Xo(t){switch(t.stockStatus){case"operator_modified":return"You've edited this. Your changes are kept until you reset.";case"stock_update_available":return"Microvac shipped a newer default.";case"missing":return"Not materialized yet — recreate it from the shipped default.";default:return}}n(Xo,"driftDetail");function el({state:t,agentRef:s,onConfigure:r,onResetResource:i,onRunRoutine:o,onEnableSchedule:a,onDisableSchedule:d,resettingResource:l=null,routineActionPending:c=null,className:x}){const{status:m,definition:y,resources:S}=t,j=y.bundle;if(!j)return null;const p=m==="ready"||m==="paused";let h="ready",f;m==="pending_approval"?(h="pending_approval",f="Waiting on board hire approval before this coach can run."):p||(h="needs_setup",f="Pick an adapter this coach can run on.");const $=Ts(S,"skill"),C=Ts(S,"instructions"),R=Ts(S,"routine"),T=R?.scheduleEnabled===!0,D=j.routine.routineKey,F=j.routine.scheduleLabel??"Weekly schedule",se=R?.pendingUpdateIssueIdentifier??R?.pendingUpdateIssueId??null,ee=se&&R?.pendingUpdateInteractionId?`/issues/${se}#interaction-${R.pendingUpdateInteractionId}`:null,ae=n((O,me,le,ne,X)=>{const b=Qt(X);return(0,e.jsx)(Wt,{label:me,secondary:le,chips:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(At,{variant:Jo(X)}),b&&(0,e.jsx)(At,{variant:b})]}),detail:Xo(X),actions:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(M,{asChild:!0,variant:"link",size:"sm",children:(0,e.jsx)(ce,{to:ne,children:"View"})}),(0,e.jsx)(Mn,{resource:X,label:me,onConfirm:n(()=>i(O),"onConfirm"),pending:l===O})]})},O)},"renderResourceRow");return(0,e.jsxs)("section",{className:w("space-y-2",x),"aria-label":"Bundle status",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Bundle status"}),(0,e.jsxs)("div",{className:"divide-y rounded-lg border px-4",children:[(0,e.jsx)(Wt,{label:"Adapter",chips:(0,e.jsx)(At,{variant:h}),detail:f,actions:(0,e.jsx)(M,{variant:"outline",size:"sm",onClick:r,children:"Configure"})}),$&&ae("skill","Skill",j.skill.displayName||$.resourceKey,`/agents/${s}/skills`,$),C&&ae("instructions","Instructions",j.instructions.entryFile,`/agents/${s}/instructions`,C),(0,e.jsx)(Wt,{label:"Routine",secondary:j.routine.title,chips:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(At,{variant:T?"schedule_on":"schedule_off",label:T?F:void 0}),R&&Qt(R)&&(0,e.jsx)(At,{variant:Qt(R)})]}),detail:T?"The weekly schedule is enabled and can create background work.":"Nothing runs until you enable the weekly schedule — it costs zero tokens by default.",actions:R?(0,e.jsxs)(e.Fragment,{children:[o&&(0,e.jsx)(_s,{title:"Run Reflection Coach once?",body:"Microvac will create one routine task now. This does not enable the weekly schedule or turn on background work.",triggerLabel:"Run once",confirmLabel:"Run once",pending:c==="run",onConfirm:n(()=>o(D),"onConfirm")}),T?d&&(0,e.jsx)(_s,{title:"Disable the weekly schedule?",body:"Microvac will stop future scheduled Reflection Coach runs. Manual Run once remains available.",triggerLabel:"Disable schedule",confirmLabel:"Disable schedule",pending:c==="disable",onConfirm:n(()=>d(D),"onConfirm")}):a&&(0,e.jsx)(_s,{title:"Enable the weekly schedule?",body:"Microvac will allow Reflection Coach to create routine tasks on the weekly schedule. It can spend tokens when those tasks run.",triggerLabel:"Enable weekly",confirmLabel:"Enable weekly",pending:c==="enable",onConfirm:n(()=>a(D),"onConfirm")}),Qt(R)&&(0,e.jsx)(Mn,{resource:R,label:"routine",onConfirm:n(()=>i("routine"),"onConfirm"),pending:l==="routine"})]}):void 0}),ee&&(0,e.jsx)(Wt,{label:"Proposal",chips:(0,e.jsx)(At,{variant:"proposal_pending"}),detail:"A proposed Reflection Coach update is waiting for review.",actions:(0,e.jsx)(M,{asChild:!0,variant:"link",size:"sm",children:(0,e.jsx)(ce,{to:ee,children:"Review proposal"})})})]})]})}n(el,"BuiltInBundlePanel");function tl({projects:t,projectIds:s,canManage:r,agentName:i,onSave:o}){const[a,d]=(0,u.useState)([]),[l,c]=(0,u.useState)(!1),[x,m]=(0,u.useState)(""),[y,S]=(0,u.useState)(!1),[j,p]=(0,u.useState)(!1),[h,f]=(0,u.useState)(null),$=a.filter(F=>!s.includes(F)),C=[...new Set([...s,...$])],R=n(F=>t.find(se=>se.id===F)?.name??"Unavailable project","name"),T=t.filter(F=>F.name.toLowerCase().includes(x.toLowerCase()));async function D(){if(!(!r||y||!$.length)){S(!0),f(null),p(!1);try{await o($),d([]),p(!0)}catch(F){f(F instanceof Error?F.message:"Couldn’t save project access.")}finally{S(!1)}}}return n(D,"save"),(0,e.jsxs)("section",{"aria-label":"Allowed projects",className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Allowed projects"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Projects whose tasks and repositories this agent may access."})]}),r&&(0,e.jsxs)(ya,{open:l,onOpenChange:c,children:[(0,e.jsx)(ja,{asChild:!0,children:(0,e.jsxs)(M,{variant:"outline",size:"sm",disabled:y,children:[(0,e.jsx)(rn,{className:"size-4","aria-hidden":!0}),"Add project"]})}),(0,e.jsxs)(Ba,{align:"end",className:"w-72 space-y-3",children:[(0,e.jsx)(qt,{"aria-label":"Search projects",placeholder:"Search projects…",value:x,onChange:n(F=>m(F.target.value),"onChange")}),(0,e.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:T.map(F=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 hover:bg-accent",children:[(0,e.jsx)(ir,{"aria-label":F.name,checked:s.includes(F.id)||$.includes(F.id),disabled:s.includes(F.id),className:"mt-0.5",onCheckedChange:n(se=>{d(ee=>se?[...new Set([...ee,F.id])]:ee.filter(ae=>ae!==F.id)),p(!1)},"onCheckedChange")}),(0,e.jsxs)("span",{className:"min-w-0 text-sm",children:[F.name,s.includes(F.id)&&(0,e.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Already allowed"})]})]},F.id))}),!T.length&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No projects found."}),(0,e.jsx)(M,{variant:"secondary",size:"sm",className:"w-full",onClick:n(()=>c(!1),"onClick"),children:"Done"})]})]})]}),C.length?(0,e.jsx)("ul",{"aria-label":"Allowed projects",className:"divide-y divide-border rounded-lg border",children:C.map(F=>(0,e.jsxs)("li",{className:"flex items-center gap-3 p-4",children:[(0,e.jsx)(rr,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,e.jsx)("span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:R(F)}),s.includes(F)?(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[(0,e.jsx)(es,{className:"size-3.5","aria-hidden":!0}),"Allowed"]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"To add"}),(0,e.jsx)(M,{variant:"ghost",size:"icon-sm",disabled:y,"aria-label":`Undo adding ${R(F)}`,onClick:n(()=>d(se=>se.filter(ee=>ee!==F)),"onClick"),children:(0,e.jsx)(mr,{className:"size-4","aria-hidden":!0})})]})]},F))}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No projects allowed yet."}),!r&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"A person with agent-management permission can add projects here."}),$.length>0&&(0,e.jsxs)("div",{className:"space-y-2 rounded-md bg-muted p-4 text-sm",children:[(0,e.jsxs)("p",{className:"font-medium",children:["Add access to ",$.map(R).join(", ")]}),(0,e.jsxs)("p",{className:"text-muted-foreground",children:[i," will be able to access work and repositories in ",$.length===1?"this project":"these projects",". Existing project access and low-trust restrictions stay in place."]})]}),h&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:["Couldn’t save project access. Your selection is kept. ",h]}),j&&(0,e.jsxs)("p",{role:"status",className:"inline-flex items-center gap-2 text-sm",children:[(0,e.jsx)(es,{className:"size-4","aria-hidden":!0}),"Project access saved. Return to your task to retry."]}),r&&(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t pt-4",children:[(0,e.jsx)(M,{variant:"ghost",disabled:y||!$.length,onClick:n(()=>{d([]),f(null),p(!1)},"onClick"),children:"Cancel"}),(0,e.jsxs)(M,{disabled:y||!$.length,onClick:n(()=>{D()},"onClick"),children:[y&&(0,e.jsx)(Et,{className:"size-4 animate-spin","aria-hidden":!0}),y?"Saving access…":h?"Try saving again":"Save project access"]})]})]})}n(tl,"AllowedProjectsEditor");function sl({agent:t}){const s=Be(),[r]=_i(),i=r.get("fromTask"),o=U({queryKey:v.agents.projectAccess(t.id),queryFn:n(()=>W.projectAccess(t.id),"queryFn")}),a=U({...gr(t.companyId)});return o.error||a.error?(0,e.jsxs)("div",{role:"alert",className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:"Couldn’t load project access."}),(0,e.jsx)(M,{variant:"outline",size:"sm",onClick:n(()=>{o.refetch(),a.refetch()},"onClick"),children:"Try again"})]}):!o.data||!a.data?(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading project access…"}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(tl,{agentName:t.name,projects:a.data,projectIds:o.data.projectIds,canManage:o.data.canManage,onSave:n(async d=>{const l=await W.addProjectAccess(t.id,d);s.setQueryData(v.agents.projectAccess(t.id),l),await Promise.all([s.invalidateQueries({queryKey:v.agents.detail(t.id)}),...t.urlKey?[s.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})]:[],s.invalidateQueries({queryKey:v.agents.list(t.companyId)}),s.invalidateQueries({queryKey:["issues"]})])},"onSave")},t.id),i&&nr(i)&&(0,e.jsx)(M,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsx)(ce,{to:`/issues/${i}`,children:"Return to task"})})]})}n(sl,"AgentProjectAccessSettings");function Dn(t){if(!t)return null;const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString()}n(Dn,"isoOrLocaleString");function Kn(t,s){return`/issues/${s??t}`}n(Kn,"issueLink");function $t({label:t,children:s}){return(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-10) gap-x-3 gap-y-0 py-1 text-xs sm:grid-cols-(--gtc-11)",children:[(0,e.jsx)("dt",{className:"truncate text-(length:--text-micro) font-medium uppercase tracking-(--tracking-label) text-emerald-900/70 dark:text-emerald-200/70",children:t}),(0,e.jsx)("dd",{className:"min-w-0 break-words text-emerald-950 dark:text-emerald-100",children:s})]})}n($t,"MetaRow");function nl({fold:t,finalizedAt:s,className:r}){const i=t.sourceIssueIdentifier??t.sourceIssueId.slice(0,8),o=Hr(t.sameRunEvidenceId),a=Dn(t.sameRunEvidenceAt),d=Jr(t.silenceAgeMs),l=Dn(t.silenceStartedAt),c=ea(t.cleanup.outcome),x=s?Tt(s):null,m=t.evaluationIssueIdentifier??t.evaluationIssueId?.slice(0,8);return(0,e.jsxs)("section",{role:"status","aria-label":"Source-resolved watchdog fold","data-source-resolved-fold":!0,className:w("relative w-full overflow-hidden rounded-lg border text-sm shadow-(--shadow-extract-8)","border-emerald-300/70 bg-emerald-50/80 text-emerald-950","dark:border-emerald-500/40 dark:bg-emerald-500/10 dark:text-emerald-100",r),children:[(0,e.jsxs)("header",{className:"flex items-start gap-3 px-3 py-2.5 sm:px-4",children:[(0,e.jsx)("span",{className:w("mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md","bg-emerald-100 text-emerald-800 dark:bg-emerald-500/20 dark:text-emerald-200"),"aria-hidden":!0,children:(0,e.jsx)(ba,{className:"h-4 w-4 text-emerald-700 dark:text-emerald-300"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-(length:--text-micro) font-semibold uppercase tracking-(--tracking-eyebrow)",children:[(0,e.jsx)("span",{className:"text-emerald-900 dark:text-emerald-200",children:"SOURCE-RESOLVED FOLD"}),(0,e.jsx)("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),(0,e.jsx)("span",{className:"font-medium normal-case tracking-normal text-muted-foreground",children:"system audit"}),x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),(0,e.jsx)("span",{className:"font-medium normal-case tracking-normal text-muted-foreground",children:x})]}):null]}),(0,e.jsx)("p",{className:"mt-1 text-sm leading-6",children:"This run was folded as a source-resolved false positive."})]})]}),(0,e.jsxs)("dl",{className:w("divide-y border-t bg-background/40 px-3 py-2 sm:px-4 dark:bg-background/20","border-emerald-300/60 dark:border-emerald-500/30","[&>*]:border-emerald-300/40 dark:[&>*]:border-emerald-500/20"),children:[(0,e.jsx)($t,{label:"Source task",children:(0,e.jsxs)("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[(0,e.jsx)(ce,{to:Kn(t.sourceIssueId,t.sourceIssueIdentifier),className:"rounded-sm font-medium underline-offset-2 hover:underline",children:i}),(0,e.jsx)("span",{className:"rounded-md border border-emerald-300/60 bg-background/60 px-1.5 py-0.5 text-(length:--text-micro) font-medium text-emerald-900 dark:border-emerald-500/30 dark:text-emerald-200",children:t.sourceIssueStatus})]})}),(0,e.jsx)($t,{label:"Same-run evidence",children:(0,e.jsxs)("span",{className:"inline-flex flex-wrap items-baseline gap-1.5",children:[(0,e.jsx)("span",{className:"rounded bg-background/70 px-1.5 py-0.5 font-mono text-(length:--text-micro) text-emerald-900 dark:bg-background/40 dark:text-emerald-100",children:t.sameRunEvidenceKind}),(0,e.jsx)("code",{className:"rounded bg-background/70 px-1.5 py-0.5 font-mono text-(length:--text-micro) text-emerald-900 dark:bg-background/40 dark:text-emerald-100",title:t.sameRunEvidenceId,children:o}),a?(0,e.jsxs)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:["at ",a]}):null]})}),(0,e.jsx)($t,{label:"Silence age before fold",children:d?(0,e.jsxs)("span",{children:[d,l?(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" (silence started ",l,")"]}):null]}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"unknown"})}),(0,e.jsx)($t,{label:"Process cleanup",children:(0,e.jsxs)("span",{className:"inline-flex flex-wrap items-baseline gap-1.5",title:t.cleanup.outcome,children:[(0,e.jsx)("span",{children:c}),t.cleanup.error?(0,e.jsxs)("span",{className:"text-muted-foreground",children:["— ",t.cleanup.error]}):null]})}),t.evaluationIssueId?(0,e.jsx)($t,{label:"Evaluation task",children:(0,e.jsx)(ce,{to:Kn(t.evaluationIssueId,t.evaluationIssueIdentifier),className:"rounded-sm font-medium underline-offset-2 hover:underline",children:m})}):null]})]})}n(nl,"SourceResolvedFoldCallout");function rl({run:t,agentRouteId:s}){const r=na(t);return r?(0,e.jsxs)("div",{className:"rounded-md border border-border/70 bg-accent/20 px-3 py-2 text-xs leading-5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:w("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",r.tone),children:r.badgeLabel}),r.retryOfRunId&&(0,e.jsx)(ce,{to:`/agents/${s}/runs/${r.retryOfRunId}`,className:"font-mono text-foreground hover:underline",children:r.retryOfRunId.slice(0,8)})]}),r.detail&&(0,e.jsx)("p",{className:"mt-2 text-muted-foreground",children:r.detail}),r.secondary&&(0,e.jsx)("p",{className:"text-muted-foreground",children:r.secondary})]}):null}n(rl,"RunRetryDetails");function al(t){return(t.config?.sourceTemplateKey??t.transportConfig?.sourceTemplateKey)==="github"}n(al,"isGitHubConnection");function il(t,s){return al(t)&&t.enabled&&t.status==="active"&&ar(ts(t.installs),s)}n(il,"isEligibleGitHubIdentityConnection");function ol({agentName:t,dedicatedIdentity:s,personalIdentity:r,loading:i,loadError:o,onRetry:a}){const d=s?.grant.providerTenant?.github?.login,l=r?.grant.providerTenant?.github?.login;return(0,e.jsx)("section",{className:"rounded-lg border border-border bg-card",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3 px-3 py-3",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,e.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-2 text-foreground",children:(0,e.jsx)(Bs,{className:"h-4 w-4"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:"GitHub identity"}),i?(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Checking GitHub identity…"}):o?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"mt-0.5 text-sm font-medium text-foreground",children:"Could not load GitHub identity"}),(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Microvac could not verify this agent's current connection. Your existing setup was not changed."})]}):s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"mt-0.5 text-sm font-medium text-foreground",children:d?`@${d}`:"Dedicated GitHub account"}),(0,e.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Used only by ",t,". This dedicated connection takes precedence over the responsible person's GitHub."]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"mt-0.5 text-sm font-medium text-foreground",children:"Use responsible person's GitHub"}),(0,e.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"At run start, Microvac uses the personal GitHub connection of the person responsible for the task."}),r?(0,e.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Your account is connected",l?` as @${l}`:"","."]}):null]})]})]}),i?null:(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:o?(0,e.jsx)(M,{variant:"outline",size:"sm",onClick:a,children:"Retry"}):s?(0,e.jsx)(M,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsx)(ce,{to:`/apps/${s.connection.id}/permissions`,children:"Manage GitHub identity"})}):(0,e.jsxs)(e.Fragment,{children:[r?(0,e.jsx)(M,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsx)(ce,{to:`/apps/${r.connection.id}/permissions`,children:"Manage my GitHub"})}):(0,e.jsx)(M,{size:"sm",asChild:!0,children:(0,e.jsx)(ce,{to:"/apps/connect?source=github",children:"Connect my GitHub"})}),(0,e.jsx)(M,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsx)(ce,{to:"/apps/connect?source=github",children:"Use a dedicated account"})})]})})]})})}n(ol,"GitHubIdentitySection");function Vt(t){return typeof t=="string"?t.trim()?[t.trim()]:[]:Array.isArray(t)?t.filter(s=>typeof s=="string"&&s.trim().length>0):[]}n(Vt,"selectorStringList");function ll(t,s){const r=t.selectors??{},i=[...Vt(r.agentId),...Vt(r.agentIds)];if(i.length>0)return i.includes(s);const o=[...Vt(r.actorType),...Vt(r.actorTypes)];return!(o.length>0&&!o.includes("agent"))}n(ll,"policyGovernsAgent");function dl(t,s,r){const i={...t};let o=!1;for(const[a,d]of Object.entries(s))d!==(r[a]??!1)&&(i[a]=d,o=!0);return{draft:i,hasPendingChanges:o}}n(dl,"mergeInstallDraft");function cl({agentId:t,agentName:s,connections:r,draft:i,permittedConnectionIds:o,pendingConnectionId:a,saving:d,unsaved:l,error:c,onChange:x}){return(0,e.jsxs)("section",{className:"rounded-lg border border-border bg-card",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b border-border px-3 py-2.5",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:"Installed apps"}),(0,e.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Installed apps load tools into ",s,"'s context on every run. Permitted-only apps do not add context cost."]})]}),(0,e.jsx)(ml,{pending:d,unsaved:l,error:c})]}),(0,e.jsxs)("div",{className:"space-y-3 p-3",children:[(0,e.jsx)(Mt,{tone:"info",compact:!0,children:"Has access means the app is permitted. Installed means its tools are added to this agent's runtime context."}),r.length===0?(0,e.jsx)("p",{className:"rounded-md border border-border bg-muted/30 px-3 py-4 text-sm text-muted-foreground",children:"No permitted apps yet. Bind an access profile to make apps available here."}):(0,e.jsx)("div",{className:"divide-y divide-border rounded-md border border-border",children:r.map(m=>{const y=ts(m.installs),S=y.onAll,j=S||(i[m.id]??y.agentIds.has(t)),p=o.has(m.id),h=a===m.id;return(0,e.jsxs)("div",{className:"space-y-2 px-3 py-3",children:[(0,e.jsxs)("label",{className:"flex items-start gap-3",children:[(0,e.jsx)(ir,{checked:j,disabled:S||h,"aria-label":`Install ${m.name} on ${s}`,onCheckedChange:n(f=>x(m.id,!!f),"onCheckedChange")}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:w("truncate text-sm font-medium text-foreground",Xe),children:m.name}),(0,e.jsx)(ul,{installed:j,installedForAll:S,permitted:p}),h?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Saving..."}):null]}),(0,e.jsx)("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:S?"Installed from the app page for every agent. Remove the all-agents install there.":j?"Loaded into this agent's runtime context.":ji})]})]}),p&&!j?(0,e.jsx)(Mt,{tone:"warning",compact:!0,className:"ml-7",actions:(0,e.jsx)(ce,{to:`/apps/${m.id}/permissions`,className:"text-xs font-medium text-primary hover:underline",children:"Open permissions"}),children:"Permitted but not installed — tools will not appear in runs."}):null]},m.id)})})]})]})}n(cl,"InstalledAppsSection");function ul({installed:t,installedForAll:s,permitted:r}){const i=t?s?"Installed for all":"Installed":r?"Permitted only":"Not permitted";return(0,e.jsxs)("span",{className:w("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium",t?Qs.green:Qs.gray),children:[t?(0,e.jsx)(oa,{className:"h-3 w-3"}):null,i]})}n(ul,"InstallBadge");function ml({pending:t,unsaved:s,error:r}){return t?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Saving..."}):r?(0,e.jsx)("span",{className:"text-xs text-destructive",children:"Could not save"}):s?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}):(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Saved"})}n(ml,"InstallSaveStatusChip");var xl={allow:"allow",block:"block",deny:"deny",require_approval:"require approval",redact:"redact",rate_limit:"rate limit"},Ls=30;function pl({agent:t,companyId:s}){const r=Be(),[i,o]=(0,u.useState)({}),a=(0,u.useRef)({}),d=(0,u.useRef)(!0),l=(0,u.useRef)(null),c=U({queryKey:v.tools.effectiveProfilesForAgent(s,t.id),queryFn:n(()=>ot.getEffectiveProfilesForAgent(s,t.id),"queryFn")}),x=U({queryKey:v.tools.connections(s),queryFn:n(()=>ot.listConnections(s),"queryFn")}),m=U({queryKey:v.tools.policies(s),queryFn:n(()=>ot.listPolicies(s),"queryFn")}),y=x.data?.connections??[],S=(0,u.useMemo)(()=>y.filter(b=>il(b,t.id)),[t.id,y]),j=gn({queries:S.map(b=>({queryKey:v.tools.connectionGrants(b.id),queryFn:n(()=>ot.listConnectionGrants(b.id),"queryFn"),staleTime:3e4}))}),p=S.flatMap((b,L)=>(j[L]?.data?.grants??[]).map(K=>({connection:b,grant:K,currentUserId:j[L]?.data?.currentUserId}))),h=p.find(({grant:b})=>b.kind==="agent"&&b.subjectAgentId===t.id&&b.status==="active")??null,f=p.find(({grant:b,currentUserId:L})=>b.kind==="user"&&b.subjectUserId===L&&b.status==="active")??null,$=(0,u.useMemo)(()=>y.map(b=>{const L=(b.installs??[]).map(K=>`${K.targetType}:${K.targetId}`).sort().join(",");return`${b.id}=${L}`}).join("|"),[y]),C=te({mutationFn:n(({connection:b,installed:L})=>{const K=ts(b.installs);return K.onAll||(L?K.agentIds.add(t.id):K.agentIds.delete(t.id)),ot.putConnectionInstalls(b.id,fa(b.companyId??s,K))},"mutationFn"),onSuccess:n(async(b,L)=>{l.current=null,a.current={...a.current,[L.connection.id]:L.installed},await Promise.all([r.invalidateQueries({queryKey:v.tools.connections(s)}),r.invalidateQueries({queryKey:v.tools.effectiveProfilesForAgent(s,t.id)}),r.invalidateQueries({queryKey:v.tools.testAgentAccessesForConnection(L.connection.id)})])},"onSuccess"),onError:n((b,L)=>{l.current={connectionId:L.connection.id,installed:L.installed}},"onError")});(0,u.useEffect)(()=>{o({}),a.current={},d.current=!0,l.current=null},[t.id,s]),(0,u.useEffect)(()=>{const b=Object.fromEntries(y.map(L=>[L.id,ar(ts(L.installs),t.id)]));l.current=null,o(L=>{const K=dl(b,L,a.current);return a.current=b,d.current=!K.hasPendingChanges,K.draft})},[t.id,$]),(0,u.useEffect)(()=>{if(d.current){d.current=!1;return}if(C.isPending)return;const b=y.find(K=>{const z=a.current[K.id]??!1,q=i[K.id]??!1,pe=l.current;return z!==q&&!(pe?.connectionId===K.id&&pe.installed===q)});if(!b)return;const L=window.setTimeout(()=>{const K=i[b.id]??!1,z=a.current[b.id]??!1,q=l.current;z!==K&&!(q?.connectionId===b.id&&q.installed===K)&&C.mutate({connection:b,installed:K})},250);return()=>window.clearTimeout(L)},[y,i,C.isPending,C.mutate]);const R=gn({queries:y.map(b=>({queryKey:v.tools.catalog(b.id),queryFn:n(()=>ot.listCatalog(b.id),"queryFn"),staleTime:6e4}))}),T=(0,u.useMemo)(()=>{const b=new Map;for(const L of y)b.set(L.id,L.name);return b},[y]),D=(0,u.useMemo)(()=>[...c.data?.allowedTools??[]].sort((b,L)=>b.toolName.localeCompare(L.toolName)),[c.data?.allowedTools]),F=(0,u.useMemo)(()=>new Set([...(c.data?.entries??[]).filter(b=>b.effect==="include"&&b.connectionId).map(b=>b.connectionId),...D.map(b=>b.connectionId)]),[D,c.data?.entries]),se=(0,u.useMemo)(()=>y.filter(b=>F.has(b.id)||(i[b.id]??!1)).sort((b,L)=>b.name.localeCompare(L.name)),[y,i,F]),ee=se.some(b=>(i[b.id]??!1)!==(a.current[b.id]??!1)),ae=R.map(b=>b.dataUpdatedAt).join(","),O=(0,u.useMemo)(()=>{const b=new Set((c.data?.allowedTools??[]).map(z=>z.id)),L=new Set,K=[];for(const z of R)for(const q of z.data?.catalog??[])q.status==="active"&&(b.has(q.id)||L.has(q.id)||(L.add(q.id),K.push(q)));return K.sort((z,q)=>z.toolName.localeCompare(q.toolName))},[c.data?.allowedTools,ae]),me=(0,u.useMemo)(()=>(m.data?.policies??[]).map((b,L)=>({policy:b,order:L+1})).filter(({policy:b})=>b.enabled&&ll(b,t.id)),[m.data?.policies,t.id]),le=c.data?.profiles??[],ne=R.some(b=>b.isLoading);if(c.isLoading)return(0,e.jsx)(oo,{label:"Resolving effective access…"});if(c.error)return(0,e.jsx)(co,{error:c.error,onRetry:n(()=>c.refetch(),"onRetry")});const X="/apps/advanced/profiles";return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(io,{tone:"info",title:"Effective access",body:(0,e.jsxs)(e.Fragment,{children:["This is exactly the tool set Microvac will accept for"," ",(0,e.jsx)("span",{className:"font-medium",children:t.name}),". Profile and policy edits are reflected within ~5 seconds. The agent's prompt can narrow this list but"," ",(0,e.jsx)("span",{className:"font-medium",children:"cannot expand it"})," — everything else is blocked by default."]})}),(0,e.jsx)(ol,{agentName:t.name,dedicatedIdentity:h,personalIdentity:f,loading:x.isLoading||j.some(b=>b.isLoading),loadError:x.isError||j.some(b=>b.isError),onRetry:n(()=>{x.isError&&x.refetch();for(const b of j)b.isError&&b.refetch()},"onRetry")}),(0,e.jsx)(cl,{agentId:t.id,agentName:t.name,connections:se,draft:i,permittedConnectionIds:F,pendingConnectionId:C.isPending?C.variables?.connection.id??null:null,saving:C.isPending,unsaved:ee,error:C.isError&&ee,onChange:n((b,L)=>{l.current=null,o(K=>({...K,[b]:L}))},"onChange")}),(0,e.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,e.jsx)("div",{className:"min-w-0 lg:col-span-2",children:(0,e.jsxs)("div",{className:"rounded-lg border border-border",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2.5",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:"Allowed tools"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums",children:[D.length," ",D.length===1?"tool":"tools"]})]}),D.length===0?(0,e.jsx)("p",{className:"px-3 py-6 text-sm text-muted-foreground",children:"No tools are allowed for this agent. Bind a tool profile to grant access."}):(0,e.jsx)("div",{className:"max-w-full overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-border text-left text-xs text-muted-foreground",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Tool"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Capability"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Risk"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Source"})]})}),(0,e.jsx)("tbody",{className:"divide-y divide-border",children:D.map(b=>(0,e.jsxs)("tr",{className:"align-top",children:[(0,e.jsxs)("td",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:"font-mono text-xs text-foreground",children:b.toolName}),b.title?(0,e.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:b.title}):null]}),(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsx)(uo,{isReadOnly:b.isReadOnly,isWrite:b.isWrite,isDestructive:b.isDestructive})}),(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsx)(lo,{risk:b.riskLevel})}),(0,e.jsx)("td",{className:w("px-3 py-2 text-xs text-muted-foreground",Xe),children:T.get(b.connectionId)??"—"})]},b.id))})]})})]})}),(0,e.jsx)("aside",{className:"space-y-4",children:(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-background/60 p-3",children:[(0,e.jsxs)("h3",{className:"flex items-center gap-1.5 text-sm font-semibold text-foreground",children:[(0,e.jsx)(Vi,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Why these tools?"]}),(0,e.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Access profiles"}),(0,e.jsx)(ce,{to:`${X}?check=1`,className:"text-(length:--text-micro) font-medium text-primary hover:underline",children:"Check access"})]}),le.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No active profile applies to this agent, so it has no allowed tools."}):le.map(b=>(0,e.jsxs)("div",{className:"rounded-md border border-border/70 px-2.5 py-2",children:[(0,e.jsx)(ce,{to:`${X}/${b.id}`,className:"text-xs font-medium text-primary hover:underline",children:b.name}),b.summary.isCompanyDefault?(0,e.jsx)("div",{className:"mt-1",children:(0,e.jsx)("span",{className:"rounded border border-border px-1.5 py-0.5 text-(length:--text-nano) uppercase text-muted-foreground",children:"Organization default"})}):null]},b.id))]}),(0,e.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Active policies"}),m.isLoading?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading policies…"}):me.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No enabled policy currently mutates this agent's allow list."}):me.map(({policy:b,order:L})=>(0,e.jsxs)("div",{className:"rounded-md border border-border/70 px-2.5 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"truncate text-xs font-medium text-foreground",title:`Policy #${L}: ${b.name}`,children:["#",L," ",b.name]}),(0,e.jsx)("span",{className:"shrink-0 rounded border border-border px-1.5 py-0.5 text-(length:--text-nano) uppercase text-muted-foreground",children:xl[b.policyType]??b.policyType})]}),b.description?(0,e.jsx)("div",{className:"mt-0.5 truncate text-(length:--text-micro) text-muted-foreground",children:b.description}):null]},b.id))]}),(0,e.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,e.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Unavailable tools"}),ne?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Checking tools…"}):O.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Every known tool this agent could name is allowed."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:"Tools the agent could name but Microvac would block:"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-1",children:O.slice(0,Ls).map(b=>(0,e.jsx)("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/40 px-1.5 py-0.5 font-mono text-(length:--text-micro) text-muted-foreground",title:T.get(b.connectionId)??void 0,children:b.toolName},b.id))}),O.length>Ls?(0,e.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:["+",O.length-Ls," more"]}):null]})]})]})})]})]})}n(pl,"AgentToolsTab");var fl={speko:"Speko",slack:"Slack",github:"GitHub Code Review Bot",discord:"Discord","microsoft-teams":"Microsoft Teams",telegram:"Telegram","imessage-photon":"iMessage Photon",agentmail:"AgentMail"};function hl({companyId:t,agentId:s}){const{enabled:r}=Qa(),i=U({queryKey:v.chatEndpoints.list(t),queryFn:n(()=>Ka.list(t),"queryFn"),enabled:!!t}),o=(i.data??[]).filter(a=>a.assignedAgentId===s&&a.status!=="archived"&&Ga(a.provider,r));return(0,e.jsxs)("section",{className:"max-w-3xl space-y-5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Channels"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Chat and email identities connected to this agent."})]}),(0,e.jsx)(M,{asChild:!0,size:"sm",children:(0,e.jsxs)(ce,{to:`/apps?chatAgentId=${encodeURIComponent(s)}`,children:[(0,e.jsx)(Gr,{}),"Connect a channel"]})})]}),i.isLoading?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading channels…"}):o.length===0?(0,e.jsxs)("div",{className:"rounded-lg border border-dashed border-border p-5",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"No channels connected"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Connect an agent identity from Connectors."}),(0,e.jsx)(M,{asChild:!0,className:"mt-3",variant:"outline",size:"sm",children:(0,e.jsx)(ce,{to:"/apps",children:"Open Connectors"})})]}):(0,e.jsx)("div",{className:"divide-y divide-border border-y border-border",children:o.map(a=>(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 py-4",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"text-sm font-semibold",children:fl[a.provider]}),(0,e.jsx)("p",{className:w("truncate text-xs text-muted-foreground",Xe),children:a.botLabel??a.providerAccountLabel??"Provider identity"})]}),(0,e.jsx)(Nt,{variant:"outline",children:a.status.replace(/[_-]/g," ")}),(0,e.jsx)(M,{asChild:!0,size:"sm",variant:"outline",children:(0,e.jsxs)(ce,{to:`/apps/chat/${a.id}/settings`,children:["Open connection ",(0,e.jsx)(hr,{})]})})]},a.id))})]})}n(hl,"AgentChannelsPanel");function gl(t){const s=t.systemRecovery;if(!s||typeof s!="object"||!("failure"in s))return"No recorded system recovery failure.";const r=s.failure;if(!r||typeof r!="object"||!("code"in r)||typeof r.code!="string")return"No recorded system recovery failure.";const i="sourceVerification"in r?r.sourceVerification:null;if(!i||typeof i!="object"||!("reason"in i)||typeof i.reason!="string"||!go.includes(i.reason))return r.code;const o="observedLeasePolicy"in i?i.observedLeasePolicy:null,a=typeof o=="string"&&(o==="unrecognized"||ii.includes(o));return[r.code,i.reason,...a?[`lease policy ${o}`]:[]].join(" · ")}n(gl,"recordedFailure");function yl({issueId:t,runId:s,companyId:r}){const i=te({mutationFn:n(()=>gt.recoveryActions(t,{runId:s}),"mutationFn")}),o=te({mutationFn:n(c=>gt.recoveryActions(t,{runId:s,actionId:c}),"mutationFn")}),a=i.isPending||o.isPending,d=i.error??o.error,l=o.data?.sourceInspection;return(0,e.jsxs)("div",{className:"space-y-2","data-testid":"run-workspace-source-inspection",children:[(0,e.jsx)(M,{variant:"outline",size:"sm",disabled:a,onClick:n(()=>{o.reset(),i.mutate()},"onClick"),children:a?"Inspecting recovery…":"Inspect recovery"}),d?(0,e.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:d instanceof Error?d.message:"Recovery inspection failed. Try inspecting again."}):null,i.data?.actions.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No recorded recovery action for this run."}):null,i.data?.actions.map(c=>(0,e.jsxs)("div",{className:"space-y-2 text-xs",children:[(0,e.jsxs)("p",{children:["Recorded failure: ",(0,e.jsx)("code",{className:"font-mono",children:gl(c.evidence)})]}),(0,e.jsxs)("p",{className:"font-mono text-muted-foreground",children:[c.id," · ",c.status]}),(0,e.jsx)(M,{variant:"ghost",size:"sm",disabled:a,onClick:n(()=>o.mutate(c.id),"onClick"),children:"Inspect current source"}),c.evidence.runId===s?(0,e.jsx)(Zr,{action:c,issueId:t,companyId:r,showStatus:!1}):null]},c.id)),l?(0,e.jsxs)("div",{className:"space-y-2 text-xs",role:"status",children:[(0,e.jsx)("p",{className:"font-medium",children:"Current recorded-source identity"}),(0,e.jsxs)("p",{className:"font-mono text-muted-foreground",children:["Action ",l.actionId]}),(0,e.jsx)("p",{className:"text-muted-foreground",children:"This read-only observation checks recorded identity. It does not confirm provider termination, local files, or successful preservation."}),l.status==="verified"?(0,e.jsx)("p",{children:"Recorded-source identity verified."}):l.status==="not_inspected"?(0,e.jsx)("p",{children:"Source not inspected: this record exceeds the inspection limit."}):(0,e.jsxs)("p",{children:["Blocked: ",(0,e.jsx)("code",{className:"font-mono",children:l.sourceVerification?.reason??l.failureCode}),l.sourceVerification?.observedLeasePolicy?(0,e.jsxs)(e.Fragment,{children:[" · lease policy ",(0,e.jsx)("code",{className:"font-mono",children:l.sourceVerification.observedLeasePolicy})]}):null]}),(0,e.jsxs)("p",{className:"font-mono text-muted-foreground",children:["Observed ",Oa(l.observedAt)]})]}):null]})}n(yl,"RunWorkspaceSourceInspection");function vl(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}n(vl,"asRecord$2");function bl(t){if(typeof t!="string")return null;const s=t.trim();return s.length>0?s:null}n(bl,"asNonEmptyString$1");function kr(t){const s=vl(t.contextSnapshot);return s?bl(s.issueId):null}n(kr,"readRunIssueId");function jl({run:t}){const s=kr(t),r=t.execution?.cause??t.errorCode;return s&&(Mr(r)||r==="native_workspace_sync_out_unrecoverable")?(0,e.jsx)(yl,{issueId:s,runId:t.id,companyId:t.companyId},t.id):(0,e.jsx)(Nl,{run:t})}n(jl,"RunWorkspaceRecoverySurface");function Nl({run:t}){const s=Lt(),r=Be(),{pushToast:i}=sn(),o=t.status==="failed"&&t.errorCode==="workspace_validation_failed",a=kr(t),{data:d}=U({queryKey:v.issues.detail(a??"__none__"),queryFn:n(()=>gt.get(a),"queryFn"),enabled:!!(o&&a)}),{data:l}=U({queryKey:v.access.currentBoardAccess,queryFn:n(()=>vt.getCurrentBoardAccess(),"queryFn"),enabled:!!(o&&a)}),c=d?.activeRecoveryAction??null,x=Qr(t.companyId,l),m=ta(c)??d?.executionWorkspaceId??null,y=(0,u.useCallback)(()=>{a&&r.invalidateQueries({queryKey:v.issues.detail(a)}),r.invalidateQueries({queryKey:v.runIssues(t.id)}),r.invalidateQueries({queryKey:v.runDetail(t.id)})},[a,r,t.id]),S=te({mutationFn:n(T=>{const{workspaceId:D,...F}=T;return Ji.reconcile(D,F)},"mutationFn"),onSuccess:n((T,D)=>{y(),i(D.mode==="quarantine_restore"?{title:"Workspace repaired",body:"Dirty changes were quarantined onto a rescue branch and the recorded branch restored; the task will resume.",tone:"success"}:{title:"Workspace branch reconciled",body:"The recorded branch now matches the live branch; the task will resume.",tone:"success"})},"onSuccess"),onError:n(T=>{i({title:"Reconcile failed",body:T instanceof Error?T.message:"Unable to reconcile the workspace branch.",tone:"error"})},"onError")}),j=te({mutationFn:n(async T=>{if(!d)throw new Error("Task is not loaded yet.");const D=d.identifier??"the stalled task",F=[`Re-issued from ${D} on an isolated git worktree after a workspace branch divergence.`,"",`- Base ref (live branch): \`${T.baseRef}\``,...T.expectedBranch?[`- Recorded branch: \`${T.expectedBranch}\``]:[],"","---","",d.description??""];return gt.create(d.companyId,{title:`Re-issue (isolated): ${d.title??D}`,description:F.join(`
|
|
@@ -35,5 +35,5 @@ ${t.summary}`:t.kind==="run_terminal"?`${t.runState} · ${t.turnState} · ${t.di
|
|
|
35
35
|
${t.stopReason}`:""}`:t.text}n(Rd,"rawEntryContent");function Ad({entries:t,density:s}){const r=s==="compact",i=(0,u.useRef)(null),o=t.length>ed,[a,d]=(0,u.useState)(()=>({start:0,end:Math.min(t.length,o?td:t.length)}));(0,u.useEffect)(()=>{if(!o){d({start:0,end:t.length});return}const m=i.current;if(!m)return;const y=Cd(m),S=n(()=>{const p=y===window?null:y,h=p?p.getBoundingClientRect().top:0,f=p?p.clientHeight:window.innerHeight,$=m.getBoundingClientRect().top,C=Math.max(0,h-$),R=Math.max(C+f,0),T=Math.max(0,Math.floor(C/Yt)-Hn),D=Math.min(t.length,Math.ceil(R/Yt)+Hn);d(F=>F.start===T&&F.end===D?F:{start:T,end:D})},"updateRange");S();const j=window.requestAnimationFrame(S);return y.addEventListener("scroll",S,{passive:!0}),window.addEventListener("resize",S),()=>{window.cancelAnimationFrame(j),y.removeEventListener("scroll",S),window.removeEventListener("resize",S)}},[t.length,o]);const l=o?t.slice(a.start,a.end):t,c=o?a.start*Yt:0,x=o?Math.max(0,t.length-a.end)*Yt:0;return(0,e.jsxs)("div",{ref:i,className:w("font-mono",r?"space-y-1 text-(length:--text-micro)":"space-y-1.5 text-xs"),children:[c>0&&(0,e.jsx)("div",{"aria-hidden":"true",style:{height:c}}),l.map((m,y)=>(0,e.jsxs)("div",{className:w("grid gap-x-3","grid-cols-(--gtc-16)"),children:[(0,e.jsx)("span",{className:"text-(length:--text-nano) uppercase tracking-(--tracking-caps) text-muted-foreground",children:m.kind}),(0,e.jsx)("pre",{className:w("min-w-0 whitespace-pre-wrap break-words text-foreground/80",Xe),children:Rd(m)})]},`${m.kind}-${m.ts}-${a.start+y}`)),x>0&&(0,e.jsx)("div",{"aria-hidden":"true",style:{height:x}})]})}n(Ad,"RawTranscriptView");function Id({entries:t,toolDecisions:s,mode:r="nice",density:i="comfortable",limit:o,streaming:a=!1,collapseStdout:d=!1,emptyMessage:l="No transcript yet.",className:c,thinkingClassName:x,externalReferences:m}){const y=(0,u.useMemo)(()=>id(s),[s]),S=(0,u.useMemo)(()=>r==="raw"?[]:ud(t,a),[t,r,a]),j=o?S.slice(-o):S,p=(0,u.useMemo)(()=>pd(j),[j]),h=o?t.slice(-o):t;return t.length===0?(0,e.jsx)("div",{className:w("rounded-2xl border border-dashed border-border/70 bg-background/40 p-4 text-sm text-muted-foreground",c,Xe),children:l}):r==="raw"?(0,e.jsx)("div",{className:w(c,Xe),children:(0,e.jsx)(Ad,{entries:h,density:i})}):(0,e.jsx)("div",{className:w("space-y-3",c,Xe),children:p.map(({block:f,key:$},C)=>(0,e.jsxs)("div",{className:w(C===p.length-1&&a&&"tc-stream-block-enter"),children:[f.type==="message"&&(0,e.jsx)(fd,{block:f,density:i,externalReferences:m}),f.type==="thinking"&&(0,e.jsx)(hd,{block:f,density:i,className:x,externalReferences:m}),f.type==="tool"&&(0,e.jsx)(gd,{block:f,density:i,decision:pt(y,f)}),f.type==="command_group"&&(0,e.jsx)(yd,{block:f,density:i,toolDecisionMaps:y}),f.type==="tool_group"&&(0,e.jsx)(vd,{block:f,density:i,toolDecisionMaps:y}),f.type==="diff_group"&&(0,e.jsx)(Nd,{block:f,density:i}),f.type==="stderr_group"&&(0,e.jsx)(wd,{block:f,density:i}),f.type==="system_group"&&(0,e.jsx)(kd,{block:f,density:i}),f.type==="stdout"&&(0,e.jsx)(Sd,{block:f,density:i,collapseByDefault:d}),f.type==="activity"&&(0,e.jsx)(bd,{block:f,density:i}),f.type==="event"&&(0,e.jsx)(jd,{block:f,density:i,externalReferences:m}),f.type==="provider_activity"&&(0,e.jsx)(xd,{block:f,density:i})]},$))})}n(Id,"RunTranscriptView");var Ed=5e3,Td=2e3,_d=1500,Ld=256e3,Tr="***REDACTED***",Fd=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,$d=/(^command$|^cmd$|command[-_]?line|resolved[-_]?command|PAPERCLIP_RESOLVED_COMMAND)/i,Pd=/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/;function Ze(t,s){return ci(t,{enabled:s})}n(Ze,"redactPathText");function It(t,s){return Hi(t,{enabled:s})}n(It,"redactPathValue");function _r(t,s){return Ze(pa(t,Tr),s)}n(_r,"redactCommandText");function qd(t,s){return Fd.test(t)?!0:typeof s!="string"?!1:Pd.test(s)}n(qd,"shouldRedactSecretValue");function Md(t,s,r){if(typeof s=="object"&&s!==null&&!Array.isArray(s)&&s.type==="secret_ref")return"***SECRET_REF***";if(qd(t,s))return Tr;if(s==null)return"";if(typeof s=="string"&&$d.test(t))return _r(s,r);if(typeof s=="string")return Ze(s,r);try{return JSON.stringify(It(s,r))}catch{return Ze(String(s),r)}}n(Md,"redactEnvValue");function Dd(t,s){const r=jt(t);if(!r)return"<unable-to-parse>";const i=Object.keys(r);return i.length===0?"<empty>":i.sort().map(o=>`${o}=${Md(o,r[o],s)}`).join(`
|
|
36
36
|
`)}n(Dd,"formatEnvForDisplay");function Lr(t){return t===window}n(Lr,"isWindowContainer");function Kd(t){const s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"||s==="overlay"}n(Kd,"isElementScrollContainer");function Bd(t){let s=t?.parentElement??null;for(;s;){if(Kd(s))return s;s=s.parentElement}return window}n(Bd,"findScrollContainer");function Jt(t){if(Lr(t)){const r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),i=window.scrollY+window.innerHeight;return{scrollHeight:r,distanceFromBottom:Math.max(0,r-i)}}const s=t.scrollTop+t.clientHeight;return{scrollHeight:t.scrollHeight,distanceFromBottom:Math.max(0,t.scrollHeight-s)}}n(Jt,"readScrollMetrics");function Vn(t,s="auto"){if(Lr(t)){const r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);window.scrollTo({top:r,behavior:s});return}t.scrollTo({top:t.scrollHeight,behavior:s})}n(Vn,"scrollToContainerBottom");function jt(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}n(jt,"asRecord");function fe(t){if(typeof t!="string")return null;const s=t.trim();return s.length>0?s:null}n(fe,"asNonEmptyString");function zd(t,s){const r=fe(t.message);if(!r)return null;const i=fe(t.phase);return{ts:fe(t.updatedAt)??s,stream:"system",chunk:i?`[${i}] ${r}`:r}}n(zd,"buildHeartbeatProgressLogLine");function Od(t){return`${t.ts}\0${t.stream}\0${t.chunk}`}n(Od,"heartbeatProgressLogLineKey");function Ud(t){return t==="running"}n(Ud,"shouldPollRunShellLog");function Hd({payload:t,censorUsernameInLogs:s}){const r=[typeof t.command=="string"?t.command:null,...Array.isArray(t.commandArgs)?t.commandArgs.filter(a=>typeof a=="string"):[]].filter(a=>!!a).join(" "),i=r?_r(r,s):"",o=i.length>0||Array.isArray(t.commandNotes)&&t.commandNotes.length>0||t.prompt!==void 0||t.context!==void 0||t.env!==void 0;return(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-background/60 p-3 space-y-2",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Invocation"}),typeof t.adapterType=="string"&&(0,e.jsxs)("div",{className:"text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Adapter: "}),t.adapterType]}),typeof t.cwd=="string"&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Working dir: "}),(0,e.jsx)("span",{className:"font-mono",children:t.cwd})]}),o&&(0,e.jsxs)(an,{children:[(0,e.jsxs)(tn,{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors group",children:[(0,e.jsx)(st,{className:"h-3 w-3 transition-transform group-data-[state=open]:rotate-90"}),"Details"]}),(0,e.jsxs)(Ys,{className:"pt-2 space-y-2",children:[i&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Command: "}),(0,e.jsx)("span",{className:w("font-mono","ph-mask ph-sensitive"),children:i})]}),Array.isArray(t.commandNotes)&&t.commandNotes.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Command notes"}),(0,e.jsx)("ul",{className:"list-disc pl-5 space-y-1",children:t.commandNotes.filter(a=>typeof a=="string"&&a.trim().length>0).map((a,d)=>(0,e.jsx)("li",{className:w("text-xs break-all font-mono","ph-mask ph-sensitive"),children:a},`${d}-${a}`))})]}),t.prompt!==void 0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Prompt"}),(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap","ph-mask ph-sensitive"),children:typeof t.prompt=="string"?Ze(t.prompt,s):JSON.stringify(It(t.prompt,s),null,2)})]}),t.context!==void 0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Context"}),(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap","ph-mask ph-sensitive"),children:JSON.stringify(It(t.context,s),null,2)})]}),t.env!==void 0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Environment"}),(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap font-mono","ph-mask ph-sensitive"),children:Dd(t.env,s)})]})]})]})]})}n(Hd,"RunInvocationCard");function Qd(t){const s=[];for(const r of t.split(`
|
|
37
37
|
`)){const i=r.trim();if(i)try{const o=JSON.parse(i),a=o.stream==="stderr"||o.stream==="system"?o.stream:"stdout",d=typeof o.chunk=="string"?o.chunk:"",l=typeof o.ts=="string"?o.ts:new Date().toISOString();if(!d)continue;s.push({ts:l,stream:a,chunk:d})}catch{}}return s}n(Qd,"parseStoredLogContent");function Wd(t){switch(t){case"worktree_prepare":return"Worktree setup";case"workspace_config_freshness":return"Config freshness";case"workspace_provision":return"Provision";case"workspace_teardown":return"Teardown";case"worktree_cleanup":return"Worktree cleanup";default:return t}}n(Wd,"workspaceOperationPhaseLabel");function Vd(t){switch(t){case"succeeded":return"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-300";case"failed":return"border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300";case"running":return"border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300";case"skipped":return"border-yellow-500/20 bg-yellow-500/10 text-yellow-700 dark:text-yellow-300";default:return"border-border bg-muted/40 text-muted-foreground"}}n(Vd,"workspaceOperationStatusTone");function Gd({status:t}){return(0,e.jsx)(Nt,{variant:"outline",className:w("text-(length:--text-micro) capitalize",Vd(t)),children:t.replace("_"," ")})}n(Gd,"WorkspaceOperationStatusBadge");function Yd({operation:t,censorUsernameInLogs:s}){const[r,i]=(0,u.useState)(!1),o=U({queryKey:["workspace-operation-log",t.id],queryFn:n(()=>tt.workspaceOperationLog(t.id),"queryFn"),enabled:r&&!!t.logRef,refetchInterval:r&&t.status==="running"?2e3:!1}),a=Dt(o),{data:d}=o,l=a.kind==="loading"||a.kind==="reconnecting",c=(0,u.useMemo)(()=>d?.content?Qd(d.content):[],[d?.content]);return(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("button",{type:"button",className:"text-(length:--text-micro) text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:n(()=>i(x=>!x),"onClick"),children:r?"Hide full log":"Show full log"}),r&&(0,e.jsxs)("div",{className:"rounded-md border border-border bg-background/70 p-2",children:[l&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Loading log..."}),a.kind==="error"&&(0,e.jsx)(yt,{size:"inline",error:a.error,onRetry:a.retry,retrying:a.isFetching}),!l&&a.kind!=="error"&&c.length===0&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"No persisted log lines."}),c.length>0&&(0,e.jsx)("div",{className:"max-h-64 overflow-y-auto rounded bg-neutral-100 p-2 font-mono text-xs dark:bg-neutral-950",children:c.map((x,m)=>(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("span",{className:"shrink-0 text-neutral-500",children:new Date(x.ts).toLocaleTimeString("en-US",{hour12:!1})}),(0,e.jsxs)("span",{className:w("shrink-0 w-14",x.stream==="stderr"?"text-red-600 dark:text-red-300":x.stream==="system"?"text-blue-600 dark:text-blue-300":"text-muted-foreground"),children:["[",x.stream,"]"]}),(0,e.jsx)("span",{className:"whitespace-pre-wrap break-all",children:Ze(x.chunk,s)})]},`${x.ts}-${m}`))})]})]})}n(Yd,"WorkspaceOperationLogViewer");function Jd({operations:t,censorUsernameInLogs:s}){return t.length===0?null:(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-background/60 p-3 space-y-3",children:[(0,e.jsxs)("div",{className:"text-xs font-medium text-muted-foreground",children:["Workspace (",t.length,")"]}),(0,e.jsx)("div",{className:"space-y-3",children:t.map(r=>{const i=jt(r.metadata);return(0,e.jsxs)("div",{className:"rounded-md border border-border/70 bg-background/70 p-3 space-y-2",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:Wd(r.phase)}),(0,e.jsx)(Gd,{status:r.status}),(0,e.jsxs)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:[Tt(r.startedAt),r.finishedAt&&` to ${Tt(r.finishedAt)}`]})]}),r.command&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Command: "}),(0,e.jsx)("span",{className:"font-mono",children:r.command})]}),r.cwd&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Working dir: "}),(0,e.jsx)("span",{className:"font-mono",children:r.cwd})]}),(fe(i?.branchName)||fe(i?.baseRef)||fe(i?.worktreePath)||fe(i?.repoRoot)||fe(i?.cleanupAction))&&(0,e.jsxs)("div",{className:"grid gap-1 text-xs sm:grid-cols-2",children:[fe(i?.branchName)&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Branch: "}),(0,e.jsx)("span",{className:"font-mono",children:i?.branchName})]}),fe(i?.baseRef)&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Base ref: "}),(0,e.jsx)("span",{className:"font-mono",children:i?.baseRef})]}),fe(i?.worktreePath)&&(0,e.jsxs)("div",{className:"break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Worktree: "}),(0,e.jsx)("span",{className:"font-mono",children:i?.worktreePath})]}),fe(i?.repoRoot)&&(0,e.jsxs)("div",{className:"break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Repo root: "}),(0,e.jsx)("span",{className:"font-mono",children:i?.repoRoot})]}),fe(i?.cleanupAction)&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Cleanup: "}),(0,e.jsx)("span",{className:"font-mono",children:i?.cleanupAction})]})]}),typeof i?.created=="boolean"&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:i.created?"Created by this run":"Reused existing workspace"}),r.stderrExcerpt&&r.stderrExcerpt.trim()&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-1 text-xs text-red-700 dark:text-red-300",children:"stderr excerpt"}),(0,e.jsx)("pre",{className:w("rounded-md bg-red-50 p-2 text-xs whitespace-pre-wrap break-all text-red-800 dark:bg-neutral-950 dark:text-red-100","ph-mask ph-sensitive"),children:Ze(r.stderrExcerpt,s)})]}),r.stdoutExcerpt&&r.stdoutExcerpt.trim()&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-1 text-xs text-muted-foreground",children:"stdout excerpt"}),(0,e.jsx)("pre",{className:w("rounded-md bg-neutral-100 p-2 text-xs whitespace-pre-wrap break-all dark:bg-neutral-950","ph-mask ph-sensitive"),children:Ze(r.stdoutExcerpt,s)})]}),r.logRef&&(0,e.jsx)(Yd,{operation:r,censorUsernameInLogs:s})]},r.id)})})]})}n(Jd,"WorkspaceOperationsSection");function Zd({run:t,adapterType:s}){const{visible:r}=Yi(),i=mi(),[o,a]=(0,u.useState)([]),[d,l]=(0,u.useState)(!1),[c,x]=(0,u.useState)(null),m=(0,u.useRef)(!1),[y,S]=(0,u.useState)(!1),j=(0,u.useRef)(null),[p,h]=(0,u.useState)([]),[f,$]=(0,u.useState)(!0),[C,R]=(0,u.useState)(0),T=(0,u.useRef)(0),D=(0,u.useCallback)(E=>{T.current=typeof E=="function"?E(T.current):E,R(T.current)},[]),F=(0,u.useRef)({seenChunkKeys:new Set,trimmedSeqFloorByRun:new Map}),[se,ee]=(0,u.useState)(!1),[ae,O]=(0,u.useState)(!1),[me,le]=(0,u.useState)("nice"),ne=(0,u.useRef)(null),X=(0,u.useRef)(""),b=(0,u.useRef)(new Set),L=(0,u.useRef)(null),K=(0,u.useRef)(!1),z=(0,u.useRef)({scrollHeight:0,distanceFromBottom:Number.POSITIVE_INFINITY}),q=t.status==="running"||t.status==="queued",pe=Ud(t.status),{data:we=[]}=U({queryKey:v.runWorkspaceOperations(t.id),queryFn:n(()=>tt.workspaceOperations(t.id),"queryFn"),refetchInterval:q?2e3:!1});function Me(E){return E instanceof nn&&E.status===404}n(Me,"isRunLogUnavailable");function I(E){h(P=>Ur(t.id,P,E.map(J=>({...J,dedupeKey:`log:${t.id}:${J.ts}:${J.stream}:${J.chunk}`})),F.current,q?Ed:Number.POSITIVE_INFINITY).chunks)}n(I,"appendLogLines");function De(E,P=!1){if(!E&&!P)return;const J=`${X.current}${E}`.split(`
|
|
38
|
-
`);X.current=J.pop()??"",P&&X.current&&(J.push(X.current),X.current="");const de=[];for(const re of J){const ye=re.trim();if(ye)try{const G=JSON.parse(ye),Ee=G.stream==="stderr"||G.stream==="system"?G.stream:"stdout",Te=typeof G.chunk=="string"?G.chunk:"",He=typeof G.ts=="string"?G.ts:new Date().toISOString();if(!Te)continue;const Ae=xn(G.seq);_.current.confirm(Ae),de.push({ts:He,stream:Ee,chunk:Te,seq:Ae})}catch{}}de.length>0&&I(de)}n(De,"appendLogContent");const _e=(0,u.useRef)(null),Ce=(0,u.useRef)(null),xe=(0,u.useRef)(new Ft),_=(0,u.useRef)(new Ft),ue=(0,u.useRef)(0),N=(0,u.useRef)(0),V=(0,u.useRef)(0),A=(0,u.useRef)(t.logRef??null),Z=(0,u.useRef)(new Set),be=(0,u.useRef)(q),Ne=n(E=>{if(typeof E!="string"||!E||E===A.current)return"same";if(Z.current.has(E))return"stale";const P=A.current;return A.current=E,P?(Z.current.add(P),Z.current.size>8&&Z.current.delete(Z.current.values().next().value),X.current="",F.current={seenChunkKeys:new Set,trimmedSeqFloorByRun:new Map},_.current=new Ft,h([]),D(0),"changed"):"same"},"bindLog");(0,u.useEffect)(()=>{ue.current=0,N.current=0,V.current=0,xe.current=new Ft,_.current=new Ft,be.current=q,A.current=t.logRef??null,Z.current.clear(),m.current=!1,l(!1),S(!1),x(null),a([]),$(!0)},[t.id,t.companyId]),(0,u.useEffect)(()=>{q&&(be.current=!0)},[q]);function Re(E,P=!1){P&&(V.current=Math.max(V.current,E.at(-1)?.seq??0)),a(J=>{const de=Or(J,E);if(!q&&!be.current)return de;const re=Math.max(200,V.current),ye=de.filter(Ee=>Ee.seq<=re),G=de.filter(Ee=>Ee.seq>re);return[...ye,...G.slice(-Td)]})}n(Re,"appendEvents");const ve=ka(q?[t.id]:[],{companyId:t.companyId,enabled:r},E=>{if(E.companyId!==t.companyId)return;const P=jt(E.payload);if(!P||P.runId!==t.id)return;if(E.type==="heartbeat.run.log"){const re=Ne(P.logRef);if(re==="stale")return;const ye=xn(P.seq);P.truncated===!0&&_.current.requireHistory(ye);const G=_.current.observe(ye);if((re==="changed"||P.truncated===!0||G)&&Ce.current?.(),P.truncated===!0)return;const Ee=typeof P.chunk=="string"?P.chunk:"";if(!Ee)return;const Te=P.stream==="stderr"||P.stream==="system"?P.stream:"stdout";I([{ts:fe(P.ts)??E.createdAt,stream:Te,chunk:Ee,seq:ye}]);return}if(E.type==="heartbeat.run.progress"){const re=zd(P,E.createdAt);if(!re)return;const ye=Od(re);if(b.current.has(ye))return;b.current.add(ye),I([re]);return}if(E.type==="heartbeat.run.status"){_e.current?.(!0),Ce.current?.(!0);return}const J=Dr(E);if(!J)return;const de=J.message===null&&J.payload===null;de&&xe.current.requireHistory(J.seq),xe.current.observe(J.seq)&&_e.current?.(),!de&&Re([J])});(0,u.useEffect)(()=>{if(S(!1),!r)return;let E=!1,P;const J=new AbortController;let de=!1,re=!1,ye=null;const G=n(async(Ee=!1,Te=!1)=>{if(E)return;if(de){Te&&(re=!0);return}if(m.current&&!Ee&&!Te)return;de=!0,re=!1,S(!0),x(null),window.clearTimeout(P),P=void 0;let He=!1;try{const Ae=Te?Math.max(N.current,ue.current):ue.current,Ge=ue.current===0,Ie=await un(Ye=>tt.events(t.id,Ae,1e3,{signal:Ye}),J.signal);if(E)return;Re(Ie,!Te||Ge),$(!1);const Qe=Math.max(Ae,Ie.at(-1)?.seq??Ae);N.current=Math.max(N.current,Qe),xe.current.confirm(Qe),Te&&Ie.length===1e3&&Qe>Ae&&(re=!0),(!Te||Ge)&&(ue.current=Qe,m.current=Ie.length===1e3&&Qe>Ae,l(m.current)),He=xe.current.needsCatchup,ye=null}catch(Ae){He=!0,ye={requested:Ee,catchup:Te},i.reportError(Ae),!E&&!ei(Ae)&&x("Could not load events. Try again.")}E||(de=!1,S(!1),re?G(!1,!0):(He||q&&!ve.healthy&&!m.current)&&(P=window.setTimeout(()=>{G(Ee,Te||xe.current.needsCatchup)},2e3)))},"read");return _e.current=()=>{G(!1,be.current)},j.current=()=>{G(ye?.requested??!0,ye?.catchup??!1)},G(!1,be.current&&(ve.healthy||ue.current>0)),()=>{E=!0,_e.current=null,j.current=null,J.abort(),P!==void 0&&window.clearTimeout(P)}},[r,t.id,t.companyId,t.status,ve.healthy,ve.epoch]);const Se=(0,u.useCallback)(()=>{if(L.current)return L.current;const E=Bd(ne.current);return L.current=E,E},[]),Pe=(0,u.useCallback)(()=>{const E=Se(),P=Jt(E);z.current=P;const J=P.distanceFromBottom<=32;K.current=J,O(de=>de===J?de:J)},[Se]);(0,u.useEffect)(()=>{if(L.current=null,z.current={scrollHeight:0,distanceFromBottom:Number.POSITIVE_INFINITY},!q){K.current=!1,O(!1);return}Pe()},[q,t.id,Pe]),(0,u.useEffect)(()=>{if(!q)return;const E=Se();return Pe(),E===window?window.addEventListener("scroll",Pe,{passive:!0}):E.addEventListener("scroll",Pe,{passive:!0}),window.addEventListener("resize",Pe),()=>{E===window?window.removeEventListener("scroll",Pe):E.removeEventListener("scroll",Pe),window.removeEventListener("resize",Pe)}},[q,t.id,Se,Pe]),(0,u.useEffect)(()=>{if(!q||!K.current)return;const E=Se(),P=z.current,J=Jt(E),de=Math.max(0,J.scrollHeight-P.scrollHeight),re=P.distanceFromBottom+de;if(J.distanceFromBottom-re>32){K.current=!1,O(!1),z.current=J;return}Vn(E,"auto");const ye=Jt(E);z.current=ye,K.current||(K.current=!0),O(G=>G||!0)},[o.length,p.length,q,Se]),(0,u.useEffect)(()=>{X.current="",F.current={seenChunkKeys:new Set,trimmedSeqFloorByRun:new Map},b.current=new Set,h([]),D(0),ee(!1)},[t.id,t.logRef,D]);const ge=(0,u.useRef)(!1),ke=!!t.logRef||pe,je=zr({key:["run-log",t.companyId,t.id,t.logRef??null,q?null:t.logBytes,pe],enabled:r&&ke,refetchInterval:_.current.needsCatchup||pe&&!ve.healthy?2e3:!1,fetcher:n(async E=>{const P=T.current;try{return{offset:P,result:await un(J=>tt.log(t.id,P,Ld,{signal:J}),E)}}catch(J){if(pe&&Me(J))return{offset:P,result:null};throw J}},"fetcher"),onSuccess:n(({offset:E,result:P})=>{if(!P)return;const J=Ne(P.logRef);if(J==="stale")return;if(J==="changed"&&E!==0){queueMicrotask(()=>je.refetch());return}De(P.content,P.nextOffset===void 0);const de=P.nextOffset??E+new TextEncoder().encode(P.content).byteLength;D(de),ee(!be.current&&P.nextOffset!==void 0&&!!P.content),(ge.current||be.current&&P.nextOffset!==void 0&&P.content&&de>E)&&(ge.current=!1,queueMicrotask(()=>je.refetch()))},"onSuccess")}),Y=ke&&["loading","reconnecting"].includes(je.view.kind),ct=je.view.kind==="error"?je.error:null,Le=je.isFetching;(0,u.useEffect)(()=>(Ce.current=()=>{je.isFetching?ge.current=!0:je.refetch()},()=>{Ce.current=null}),[je.refetch,je.isFetching]);const qe=(0,u.useRef)({runId:t.id,epoch:ve.epoch});(0,u.useEffect)(()=>{const E=qe.current;qe.current={runId:t.id,epoch:ve.epoch},r&&ke&&E.runId===t.id&&E.epoch!==ve.epoch&&Ce.current?.()},[t.id,ve.epoch,r,ke]),(0,u.useEffect)(()=>i.onRecover(()=>_e.current?.(!0)),[i]);const he=U({queryKey:v.instance.generalSettings,queryFn:n(()=>us.getGeneral(),"queryFn")}).data?.censorUsernameInLogs===!0,ie=(0,u.useMemo)(()=>{const E=o.find(P=>P.eventType==="adapter.invoke");return It(jt(E?.payload??null),he)},[he,o]),[nt,ut]=(0,u.useState)(0),rt=Aa(s);(0,u.useEffect)(()=>Wa(()=>ut(E=>E+1)),[]);const Ke=(0,u.useMemo)(()=>Ia(p,rt,{censorUsernameInLogs:he}),[rt,he,p,nt]),wt=U({queryKey:v.tools.runDecisions(t.companyId,t.id),queryFn:n(()=>ot.getRunDecisionLookup(t.companyId,t.id),"queryFn"),enabled:!!(t.companyId&&t.id),refetchInterval:q?3e3:!1,staleTime:q?1e3:3e4});if((0,u.useEffect)(()=>{le("nice")},[t.id]),f&&Y&&!c&&!ct)return(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading run logs..."});if(o.length===0&&p.length===0&&!ct&&!c)return(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:f||Y?"Loading run logs...":"No log events."});const Q={info:"text-foreground",warn:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400"},at={stdout:"text-foreground",stderr:"text-red-600 dark:text-red-300",system:"text-blue-600 dark:text-blue-300"};return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(Jd,{operations:we,censorUsernameInLogs:he}),ie&&(0,e.jsx)(Hd,{payload:ie,censorUsernameInLogs:he}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground",children:["Transcript (",Ke.length,")"]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"inline-flex rounded-lg border border-border/70 bg-background/70 p-0.5",children:["nice","raw"].map(E=>(0,e.jsx)("button",{type:"button",className:w("rounded-md px-2.5 py-1 text-(length:--text-micro) font-medium capitalize transition-colors",me===E?"bg-accent text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:n(()=>le(E),"onClick"),children:E},E))}),q&&!ae&&(0,e.jsx)(M,{variant:"ghost",size:"xs",onClick:n(()=>{const E=Se();K.current=!0,O(!0),Vn(E,"auto"),z.current=Jt(E)},"onClick"),children:"Jump to live"}),q&&(0,e.jsxs)("span",{className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),"Live"]})]})]}),(0,e.jsxs)("div",{className:"max-h-(--sz-38rem) overflow-y-auto rounded-2xl border border-border/70 bg-background/40 p-3 sm:p-4",children:[(0,e.jsx)(Id,{entries:Ke,toolDecisions:wt.data?.decisions??[],mode:me,streaming:q,limit:q?_d:void 0,emptyMessage:t.logRef?"Waiting for transcript...":"No persisted transcript for this run."}),se&&(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3",children:[(0,e.jsx)(M,{type:"button",variant:"outline",size:"xs",onClick:je.view.retry,disabled:Le,children:Le?"Loading...":"Load more log"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Showing the first ",Math.round(C/1024).toLocaleString("en-US")," KB",typeof t.logBytes=="number"&&t.logBytes>0?` of ${Math.round(t.logBytes/1024).toLocaleString("en-US")} KB`:""]})]}),ct!=null&&(0,e.jsx)(yt,{className:"mt-3",error:ct,action:"load the run log",onRetry:je.view.retry,retrying:Le}),(0,e.jsx)("div",{ref:ne})]}),(t.status==="failed"||t.status==="timed_out")&&(0,e.jsxs)("div",{className:w("rounded-lg border border-red-300 dark:border-red-500/30 bg-red-50 dark:bg-red-950/20 p-3 space-y-2","ph-mask ph-sensitive"),children:[(0,e.jsx)("div",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:"Failure details"}),t.error&&(0,e.jsxs)("div",{className:"text-xs text-red-600 dark:text-red-200",children:[(0,e.jsx)("span",{className:"text-red-700 dark:text-red-300",children:"Error: "}),(0,e.jsx)(Ms,{children:Ze(t.error,he)})]}),t.stderrExcerpt&&t.stderrExcerpt.trim()&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 mb-1",children:"stderr excerpt"}),(0,e.jsx)("pre",{className:w("bg-red-50 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap text-red-800 dark:text-red-100","ph-mask ph-sensitive"),children:Ze(t.stderrExcerpt,he)})]}),t.resultJson&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 mb-1",children:"adapter result JSON"}),(0,e.jsx)("pre",{className:w("bg-red-50 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap text-red-800 dark:text-red-100","ph-mask ph-sensitive"),children:JSON.stringify(It(t.resultJson,he),null,2)})]}),t.stdoutExcerpt&&t.stdoutExcerpt.trim()&&!t.resultJson&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 mb-1",children:"stdout excerpt"}),(0,e.jsx)("pre",{className:w("bg-red-50 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap text-red-800 dark:text-red-100","ph-mask ph-sensitive"),children:Ze(t.stdoutExcerpt,he)})]})]}),(o.length>0||c)&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:["Events (",o.length,")"]}),c&&(0,e.jsx)("p",{className:"text-sm text-destructive",children:c}),(d||c)&&(0,e.jsx)(M,{variant:"outline",size:"sm",disabled:y,onClick:n(()=>j.current?.(),"onClick"),children:y?"Loading...":c?"Retry events":"Load more events"}),(0,e.jsx)("div",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-lg p-3 font-mono text-xs space-y-0.5","ph-mask ph-sensitive"),children:o.map(E=>{const P=E.color??(E.level?Q[E.level]:null)??(E.stream?at[E.stream]:null)??"text-foreground";return(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("span",{className:"text-neutral-400 dark:text-neutral-600 shrink-0 select-none w-16",children:new Date(E.createdAt).toLocaleTimeString("en-US",{hour12:!1})}),(0,e.jsx)("span",{className:w("shrink-0 w-14",E.stream?at[E.stream]??"text-neutral-500":"text-neutral-500"),children:E.stream?`[${E.stream}]`:""}),(0,e.jsx)("span",{className:w("break-all",P),children:E.message?(0,e.jsx)(Ms,{children:Ze(E.message,he)}):E.payload?JSON.stringify(It(E.payload,he)):""})]},`${E.runId}:${E.seq}`)})})]})]})}n(Zd,"LogViewer");var Xd=(0,u.lazy)(()=>Bi(()=>import("./AgentAdvancedTab-dhBDxF-H.js").then(t=>({default:t.AgentAdvancedTab})),__vite__mapDeps([0,1,2,3,4,5,6]))),ec={succeeded:{icon:fs,color:"text-green-600 dark:text-green-400"},failed:{icon:si,color:"text-red-600 dark:text-red-400"},running:{icon:Et,color:"text-blue-600 dark:text-blue-400"},queued:{icon:Hs,color:"text-yellow-600 dark:text-yellow-400"},scheduled_retry:{icon:Hs,color:"text-sky-600 dark:text-sky-400"},timed_out:{icon:No,color:"text-orange-600 dark:text-orange-400"},cancelled:{icon:jo,color:"text-neutral-500 dark:text-neutral-400"}};function tc(t){return t.orgChainHealth?.fullChain.map(s=>`${s.name}${s.status!=="active"&&s.status!=="idle"?` (${s.status})`:""}`).join(" -> ")??t.name}n(tc,"formatOrgChainHealthPath");function sc(t){return t.toLowerCase().endsWith(".md")}n(sc,"isMarkdown");function nc(t){const s=t.detail?.markdown??t.summary?.markdown;return typeof s=="boolean"?s:sc(t.selectedPath)}n(nc,"shouldUseMarkdownInstructionsEditor");var rc={timer:"Timer",assignment:"Assignment",on_demand:"On-demand",automation:"Automation"};function ac(t,s=r=>typeof window>"u"||window.confirm(r)){return!t||s("Discard unsaved agent configuration changes?")}n(ac,"confirmAgentConfigNavigation");function ic(t,s){if(typeof t!="number"||typeof s!="number")return null;const r=t-s;return r===0?null:r}n(ic,"agentConfigHistoryRestoreDelta");function oc(t,s,r){const i=ic(s.index,r);return i===null?(t.pushState(s.state,"",s.url),!1):(t.go(i),!0)}n(oc,"restoreAgentConfigHistoryEntry");function Ps(t,...s){if(!t)return 0;for(const r of s){const i=t[r];if(typeof i=="number"&&Number.isFinite(i))return i}return 0}n(Ps,"usageNumber");function lc(t,s){if(t.size!==s.size)return!1;for(const r of t)if(!s.has(r))return!1;return!0}n(lc,"setsEqual");function cn(t){const s=t.usageJson??null,r=t.resultJson??null,i=Ja(r),o=Ps(s,"inputTokens","input_tokens"),a=Ps(s,"outputTokens","output_tokens"),d=Ps(s,"cachedInputTokens","cached_input_tokens","cache_read_input_tokens"),l=Ti(s,r),c=fe(s?.provider)??null,x=fe(s?.model)??null;return{usageUnavailable:i,input:i?null:o,output:i?null:a,cached:i?null:d,cost:i?null:l,totalTokens:i?null:Ki(s),provider:c,model:x}}n(cn,"runMetrics");function dc(t){return t==="queued"?5e3:t==="running"?15e3:!1}n(dc,"runDetailRefetchIntervalMs");var cc=new Set(["overview","instructions","budgets"]),Gn=200;function Yn(t,s){switch(t){case"runtime":return`How ${s} runs: harness, model and environment.`;case"secrets":return"Secrets this agent can reach. Values are never shown here.";case"permissions":return`What ${s} may do without asking, and where.`;case"activity":return`Everything ${s} did and everything done to ${s}.`;case"runs":return`Every execution of ${s}, newest first.`;case"costs":return`What ${s} spent, by model.`;default:return null}}n(Yn,"agentViewDescription");function uc(){const{companyPrefix:t,agentId:s,tab:r,runId:i}=gs(),{companies:o,selectedCompanyId:a,setSelectedCompanyId:d}=Xs(),{closePanel:l}=ai(),{setBreadcrumbs:c}=pr(),x=Be(),m=Lt(),y=Ii(),[S,j]=(0,u.useState)(null),[p,h]=(0,u.useState)(()=>new Set),f=i?"run-detail":$i(r??null);!i&&li(r??null);const $=f==="overview",C=$||f==="run-detail",[R,T]=(0,u.useState)(!1),[D,F]=(0,u.useState)(!1),[se,ee]=(0,u.useState)(0),ae=(0,u.useCallback)(()=>ee(k=>k+1),[]),[O,me]=(0,u.useState)(null),le=(0,u.useRef)(!1),ne=(0,u.useRef)(null),X=(0,u.useRef)(null),{isMobile:b}=Zs(),L=s??"",K=(0,u.useMemo)(()=>{if(!t)return null;const k=t.toUpperCase();return o.find(B=>B.issuePrefix.toUpperCase()===k)?.id??null},[o,t])??a??void 0,z=L.length>0&&(nr(L)||!!K),q=(0,u.useCallback)(k=>{ne.current=k},[]),pe=(0,u.useCallback)(k=>{X.current=k},[]),we=(0,u.useCallback)(()=>f==="advanced"&&D?!1:ac(R),[f,R,D]),Me=U({queryKey:[...v.agents.detail(L),K??null],queryFn:n(()=>W.get(L,K),"queryFn"),enabled:z}),{data:I,isLoading:De,error:_e}=Me,Ce=Dt(Me),xe=Vo(I),_=I?.companyId??a,ue=I?ft(I):L;(0,u.useCallback)(k=>{we()&&m(`/agents/${ue||L}/${k}`)},[ue,m,we,L]);const N=I?.id??L,V=I?.id??null,{data:A}=U({queryKey:v.access.currentBoardAccess,queryFn:n(()=>vt.getCurrentBoardAccess(),"queryFn")}),Z=A?.source==="local_implicit"||A?.isInstanceAdmin===!0,be=Va(_),Ne=Ya(_),Re=V?Mi(be.data,"agent",V):"joined",{data:ve}=U({queryKey:v.instance.experimentalSettings,queryFn:n(()=>us.getExperimental(),"queryFn"),enabled:!!_}),Se=ve?.enableBuiltInAgents===!0,{data:Pe}=U({queryKey:v.builtInAgents.list(_),queryFn:n(()=>Rt.list(_),"queryFn"),enabled:!!_&&Se}),ge=Se?Pe?.find(k=>k.agentId===V)??null:null,ke=ge?ge.definition.featureKeys.map(k=>k.charAt(0).toUpperCase()+k.slice(1)).join(", "):"",je=(0,u.useCallback)(()=>{x.invalidateQueries({queryKey:v.builtInAgents.list(_)}),V&&x.invalidateQueries({queryKey:v.agents.detail(V)}),x.invalidateQueries({queryKey:v.agents.detail(L)})},[x,_,V,L]),Y=te({mutationFn:n(()=>Rt.reset(_,ge.definition.key),"mutationFn"),onSuccess:je}),[ct,Le]=(0,u.useState)(!1),qe=te({mutationFn:n(k=>Rt.reset(_,ge.definition.key,[k]),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to update bundle resource")},"onError")}),he=te({mutationFn:n(k=>Rt.runRoutine(_,ge.definition.key,k),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to run built-in routine")},"onError")}),ie=te({mutationFn:n(k=>Rt.enableRoutineSchedule(_,ge.definition.key,k),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to enable routine schedule")},"onError")}),nt=te({mutationFn:n(k=>Rt.disableRoutineSchedule(_,ge.definition.key,k),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to disable routine schedule")},"onError")}),ut=he.isPending?"run":ie.isPending?"enable":nt.isPending?"disable":null,{data:rt}=U({queryKey:v.agents.runtimeState(V??L),queryFn:n(()=>W.runtimeState(V,_??void 0),"queryFn"),enabled:!!V&&$}),{data:Ke}=U({queryKey:v.heartbeats(_,I?.id??void 0),queryFn:n(()=>tt.list(_,I?.id??void 0),"queryFn"),enabled:!!_&&!!I?.id&&C}),{data:wt}=U({queryKey:[...v.issues.list(_),"participant-agent",V??"__none__"],queryFn:n(()=>gt.list(_,{participantAgentId:V}),"queryFn"),enabled:!!_&&!!V&&$}),{data:Q}=U({queryKey:v.agents.list(_),queryFn:n(()=>W.list(_),"queryFn"),enabled:!!_}),{data:at}=U({queryKey:v.agents.skills(V??"__none__"),queryFn:n(()=>W.skills(V,_??void 0),"queryFn"),enabled:!!(_&&V&&$)}),{data:E}=U({queryKey:v.companySkills.list(_??"__none__"),queryFn:n(()=>zs.list(_),"queryFn"),enabled:!!(_&&$)}),P=(0,u.useMemo)(()=>[...wt??[]].sort((k,B)=>new Date(B.updatedAt).getTime()-new Date(k.updatedAt).getTime()),[wt]),J=(Q??[]).find(k=>k.id===I?.reportsTo),[de,re]=(0,u.useState)(!1),ye=te({mutationFn:n(({target:k,patch:B})=>W.update(k.id,B,_??void 0),"mutationFn"),onSuccess:n((k,{target:B})=>{_&&x.invalidateQueries({queryKey:v.agents.list(_)}),x.invalidateQueries({queryKey:v.agents.configRevisions(B.id)}),Ns(x,m,B,k,r??"overview")||(x.invalidateQueries({queryKey:v.agents.detail(B.id)}),x.invalidateQueries({queryKey:v.agents.detail(ft(B))}))},"onSuccess")}),G=n(async k=>{if(I){if(R||D){j(`Save or discard your unsaved changes before you change the ${k.name===void 0?"title":"name"}.`);return}j(null);try{await ye.mutateAsync({target:I,patch:k})}catch(B){j(B instanceof Error?B.message:"Could not save that change")}}},"saveHeaderField"),Ee=(Q??[]).filter(k=>k.reportsTo===I?.id&&k.status!=="terminated"),Te=(0,u.useMemo)(()=>{const k=new Map((E??[]).map(B=>[B.key,B.name]));return(at?.desiredSkills??[]).map(B=>k.get(B)??B)},[E,at?.desiredSkills]),He=(0,u.useMemo)(()=>(Ke??[]).find(k=>k.status==="running"||k.status==="queued")??null,[Ke]);(0,u.useEffect)(()=>{if(!I||f==="advanced"&&(D||R))return;if(i){L!==ue&&m(`/agents/${ue}/runs/${i}`,{replace:!0});return}const k=f==="run-detail"?"overview":f;if(L!==ue||r!==Si(k)){m(`${Ve(ue,k)}${y.search}`,{replace:!0});return}},[I,L,ue,i,r,f,D,R,m,y.search]),(0,u.useEffect)(()=>{!I?.companyId||I.companyId===a||d(I.companyId,{source:"route_sync"})},[I?.companyId,a,d]);const Ae=te({mutationFn:n(async k=>N?k==="approve"?W.approve(N,_??void 0):W.retryLifecycle(N,_??void 0):Promise.reject(new Error("No agent reference")),"mutationFn"),onSuccess:n((k,B)=>{if(j(null),B==="retryLifecycle"){x.invalidateQueries({queryKey:[...v.agents.detail(N),"lifecycle"]});return}x.invalidateQueries({queryKey:v.agents.detail(L)}),x.invalidateQueries({queryKey:v.agents.detail(N)}),x.invalidateQueries({queryKey:v.agents.runtimeState(N)}),x.invalidateQueries({queryKey:v.agents.taskSessions(N)}),_&&(x.invalidateQueries({queryKey:v.agents.list(_)}),I?.id&&x.invalidateQueries({queryKey:v.heartbeats(_,I.id)}))},"onSuccess"),onError:n(k=>{j(k instanceof Error?k.message:"Action failed")},"onError")});te({mutationFn:n(k=>W.update(N,{icon:k},_??void 0),"mutationFn"),onSuccess:n(()=>{x.invalidateQueries({queryKey:v.agents.detail(L)}),x.invalidateQueries({queryKey:v.agents.detail(N)}),_&&x.invalidateQueries({queryKey:v.agents.list(_)})},"onSuccess")});const Ge=te({mutationFn:n(k=>W.updatePermissions(N,k,_??void 0),"mutationFn"),onSuccess:n(()=>{j(null),x.invalidateQueries({queryKey:v.agents.detail(L)}),x.invalidateQueries({queryKey:v.agents.detail(N)}),_&&x.invalidateQueries({queryKey:v.agents.list(_)})},"onSuccess"),onError:n(k=>{j(k instanceof Error?k.message:"Failed to update permissions")},"onError")});if((0,u.useEffect)(()=>{const k=[{label:"Agents",href:"/agents"}],B=I?.name??L??"Agent";f==="overview"&&!i?k.push({label:B}):(k.push({label:B,href:Ve(ue)}),i?(k.push({label:"Runs",href:Ve(ue,"runs")}),k.push({label:`Run ${i.slice(0,8)}`})):k.push({label:Cn(f==="run-detail"?"overview":f)})),c(k)},[c,I,L,ue,f,i]),(0,u.useEffect)(()=>(l(),()=>l()),[l]),(0,u.useEffect)(()=>{!V||Re!=="joined"||h(k=>{if(!k.has(V))return k;const B=new Set(k);return B.delete(V),B})},[V,Re]),Ui((0,u.useCallback)(k=>{R&&(k.preventDefault(),k.returnValue="")},[R])),(0,u.useEffect)(()=>{if(!R)return;function k(B){if(B.defaultPrevented||B.button!==0||B.altKey||B.ctrlKey||B.metaKey||B.shiftKey)return;const Fe=B.target;if(!(Fe instanceof Element))return;const it=Fe.closest("a[href]");if(!(it instanceof HTMLAnchorElement)||it.target&&it.target!=="_self")return;const ht=new URL(it.href,window.location.href),g=new URL(window.location.href);ht.origin===g.origin&&(ht.pathname===g.pathname&&ht.search===g.search&&ht.hash===g.hash||le.current||(B.preventDefault(),B.stopPropagation(),!(f==="advanced"&&D)&&me(it)))}return n(k,"handleDocumentClick"),document.addEventListener("click",k,!0),()=>document.removeEventListener("click",k,!0)},[f,R,D]),(0,u.useEffect)(()=>{if(!R)return;const k={index:window.history.state?.idx,state:window.history.state,url:window.location.href};let B=!1;function Fe(it){if(B){B=!1;return}we()||(it.stopImmediatePropagation(),B=oc(window.history,k,it.state?.idx))}return n(Fe,"handlePopState"),window.addEventListener("popstate",Fe,!0),()=>window.removeEventListener("popstate",Fe,!0)},[R,we]),De||Ce.kind==="reconnecting")return(0,e.jsx)(vs,{variant:"detail"});if(Ce.kind==="error")return(0,e.jsx)(yt,{size:"page",error:_e,action:"load this agent",onRetry:Ce.retry,retrying:Ce.isFetching});if(!I)return null;if(!i&&!r)return(0,e.jsx)(qi,{to:Ve(ue),replace:!0});const Ie=xe.data&&(xe.data.lifecycleVersion??0)>=(I.lifecycleVersion??0)?{...I,...xe.data}:I,Qe=Ie.status==="pending_approval",Ye=I.orgChainHealth?.status==="invalid_org_chain",xt=Ye?null:I.orgChainHealth?.escalationWarning??null,kt=f==="runtime"||f==="instructions"||f==="secrets",St=Re==="left"&&!p.has(I.id),We=Ne.isPending&&Ne.variables?.resourceType==="agent"&&Ne.variables.resourceId===I.id;Ea(be.data,"agent",I.id),We&&Ne.variables?.starred;const Ct=We&&Ne.variables?.starred===void 0;return(0,e.jsxs)("div",{className:w("agent-settings-content mx-auto max-w-5xl space-y-8",`agent-settings-${f}`,kt&&"agent-settings-with-save-bar"),children:[St?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 border border-yellow-300/35 bg-yellow-300/10 px-3 py-2 text-sm text-yellow-900 dark:text-yellow-100",children:[(0,e.jsx)("p",{className:"min-w-0 flex-1",children:"You left this agent. It no longer appears in your sidebar."}),(0,e.jsx)(no,{compact:!0,state:"left",pending:Ct,pendingState:Ct?Ne.variables?.state:null,resourceName:I.name,onJoin:n(()=>Ne.mutate({resourceType:"agent",resourceId:I.id,resourceName:I.name,state:"joined"}),"onJoin"),onLeave:n(()=>Ne.mutate({resourceType:"agent",resourceId:I.id,resourceName:I.name,state:"left"}),"onLeave")}),(0,e.jsx)("button",{type:"button",className:"h-6 w-6 shrink-0 text-yellow-900/70 hover:text-yellow-900 dark:text-yellow-100/70 dark:hover:text-yellow-100","aria-label":"Dismiss agent membership notice",onClick:n(()=>h(k=>new Set(k).add(I.id)),"onClick"),children:"×"})]}):null,xt?(0,e.jsxs)("div",{className:"flex items-start gap-3 border border-amber-300/35 bg-amber-300/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-100",children:[(0,e.jsx)(wn,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium",children:"Escalation path is paused"}),(0,e.jsx)("p",{className:"text-amber-900/90 dark:text-amber-100/90",children:xt})]})]}):null,Ye?(0,e.jsxs)("div",{className:"flex items-start gap-3 border border-amber-300/35 bg-amber-300/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-100",children:[(0,e.jsx)(wn,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium",children:"Invalid reporting chain"}),(0,e.jsxs)("p",{className:"text-amber-900/90 dark:text-amber-100/90",children:[I.name," cannot accept tasks or start runs until its reporting chain is repaired."]}),(0,e.jsx)("p",{className:"break-words font-mono text-xs text-amber-900/80 dark:text-amber-100/80",children:tc(I)}),I.orgChainHealth?.repairGuidance?(0,e.jsx)("p",{className:"text-amber-900/85 dark:text-amber-100/85",children:I.orgChainHealth.repairGuidance}):(0,e.jsx)("p",{className:"text-amber-900/85 dark:text-amber-100/85",children:"Assign this agent to an active manager/root, or explicitly pause or terminate the affected agent/subtree."})]})]}):null,(0,e.jsxs)("header",{className:"agent-character-header flex items-center gap-2",children:[(0,e.jsx)("div",{role:"img","aria-label":`${I.name} avatar`,className:"shrink-0",children:(0,e.jsx)(oi,{agent:I,state:Sn(Ie.status)==="rest"?"idle":Sn(Ie.status),size:128,className:"agent-header-character",trackingScope:"page",followCursor:!0})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(pn,{as:"h1",value:I.name,fitContent:!0,placeholder:"Agent name",className:"min-w-0 truncate text-2xl font-semibold leading-8 text-foreground",onSave:n(k=>G({name:k}),"onSave")}),(0,e.jsx)(gi,{agent:I})]}),(0,e.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-5 text-muted-foreground",children:[(0,e.jsxs)(ce,{to:Ve(ue,"runtime"),"aria-label":`Open ${bn(yn(I)).label} harness settings`,className:"flex shrink-0 items-center gap-1 rounded-sm no-underline transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[I.adapterType==="claude_local"||I.adapterType==="codex_local"?(0,e.jsx)("img",{src:`/brands/${I.adapterType==="claude_local"?"claude":"codex"}-color.svg`,className:"-ml-0.5 size-4",alt:""}):null,(0,e.jsx)("span",{children:bn(yn(I)).label})]}),(0,e.jsx)("span",{"aria-hidden":"true",children:"•"}),(0,e.jsx)(pn,{fitContent:!0,value:I.title??"",nullable:!0,placeholder:Ua[I.role]??I.role,className:"agent-header-custom-title min-w-0 truncate text-sm leading-5 text-muted-foreground",onSave:n(k=>G({title:k||null}),"onSave")})]}),(0,e.jsx)(Go,{agent:Ie,refreshError:xe.isError,onRetry:n(()=>Ae.mutate("retryLifecycle"),"onRetry"),retryPending:Ae.isPending})]}),(0,e.jsx)(ro,{agent:Ie,companyId:_,assignLabel:"New task",size:"default",assignIcon:en,showChat:!0,showStatus:!1,workActionsInMenu:!0,menuItems:[{label:"Agent history",icon:ha,onSelect:n(()=>re(!0),"onSelect")}],actionsDisabled:Ae.isPending||f==="advanced"&&D,workActionsDisabled:Ye,workActionsDisabledReason:"Repair this agent's reporting chain before assigning tasks or starting runs",hasPendingNavigationChanges:R,onBeforeNavigate:we,onActionError:j,onTerminateSuccess:n(()=>m("/agents/all",{replace:!0}),"onTerminateSuccess"),hideTerminate:!!ge,pauseConfirm:ge?{title:`Pause the ${ge.definition.displayName}?`,description:(0,e.jsxs)(e.Fragment,{children:[ke," depends on this agent. While paused,"," ",ke.toLowerCase()," generation is skipped and the"," ",ke," page shows a warning."]})}:void 0,children:He&&(0,e.jsxs)(ce,{to:`/agents/${ue}/runs/${He.id}`,className:"sm:hidden flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",children:[(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,e.jsx)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:"Live"})]})})]}),(0,e.jsx)(Zl,{agent:I,companyId:_??void 0,open:de,onOpenChange:re}),(0,e.jsx)(ps,{open:O!==null,onOpenChange:n(k=>k?void 0:me(null),"onOpenChange"),children:(0,e.jsxs)(hs,{children:[(0,e.jsxs)(ms,{children:[(0,e.jsx)(ys,{children:"Discard unsaved changes?"}),(0,e.jsxs)(cs,{children:["You have unsaved changes to ",I.name,"’s ",f==="runtime"?"harness settings":f==="secrets"?"secrets and variables":f==="advanced"?"configuration":"instructions",". If you continue, they’ll be lost."]})]}),(0,e.jsxs)(ds,{className:"sm:justify-between",children:[(0,e.jsx)(bs,{children:"Keep editing"}),(0,e.jsx)(ls,{className:"bg-destructive text-white hover:bg-destructive/90",onClick:n(()=>{const k=O;if(me(null),X.current?.(),!!k){le.current=!0;try{k.click()}finally{le.current=!1}}},"onClick"),children:"Discard changes"})]})]})}),ge&&(0,e.jsxs)(Mt,{tone:"info",title:"Built-in agent",actions:(0,e.jsx)(M,{variant:"outline",size:"sm",onClick:n(()=>Y.mutate(),"onClick"),disabled:Y.isPending,children:Y.isPending?"Resetting…":"Reset to defaults"}),children:["Ships with Microvac and powers ",(0,e.jsx)("strong",{children:ke}),". Configure it like any agent — model, instructions, budget. It can be paused but not deleted; pausing it pauses ",ke,"."]}),ge?.definition.bundle&&(0,e.jsx)(el,{state:ge,agentRef:ue,onConfigure:n(()=>Le(!0),"onConfigure"),onResetResource:n(k=>qe.mutate(k),"onResetResource"),onRunRoutine:n(k=>he.mutate(k),"onRunRoutine"),onEnableSchedule:n(k=>ie.mutate(k),"onEnableSchedule"),onDisableSchedule:n(k=>nt.mutate(k),"onDisableSchedule"),resettingResource:qe.isPending?qe.variables??null:null,routineActionPending:ut}),ge&&_&&(0,e.jsx)(Xi,{companyId:_,state:ge,open:ct,onOpenChange:Le,onConfigured:n(()=>{Le(!1),je()},"onConfigured")}),S&&(0,e.jsx)("p",{className:"text-sm text-destructive",children:S}),Qe&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-400/40 dark:bg-amber-950/30 dark:text-amber-200",children:[(0,e.jsx)("span",{children:"This agent is pending board approval and cannot be invoked yet."}),(0,e.jsxs)(M,{variant:"outline",size:"sm",onClick:n(()=>Ae.mutate("approve"),"onClick"),disabled:Ae.isPending,children:[(0,e.jsx)(fs,{className:"h-3.5 w-3.5 sm:mr-1"}),(0,e.jsx)("span",{children:"Approve agent"})]})]}),f!=="run-detail"&&f!=="channels"&&!cc.has(f)?(0,e.jsxs)("div",{className:"mb-4 space-y-1",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:Cn(f)}),Yn(f,I.name)?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:Yn(f,I.name)}):null]}):null,pi(f)&&_?(0,e.jsx)(Bl,{agent:I,companyId:_,section:f}):null,f==="overview"&&(0,e.jsx)(mc,{agent:I,runs:Ke??[],assignedIssues:P,runtimeState:rt,reportsToAgent:J,directReportCount:Ee.length,directReports:Ee,skillNames:Te,agentRouteId:ue}),f==="instructions"&&(0,e.jsxs)("div",{children:[(0,e.jsx)(pc,{agent:I,companyId:_??void 0,showSaveNotice:!1,onSaved:ae,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F}),_&&(0,e.jsx)(ga,{companyId:_,agentId:I.id})]}),f==="runtime"&&(0,e.jsx)("div",{children:(0,e.jsx)(qs,{agent:I,companyId:_??void 0,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F,onSaved:ae,updatePermissions:Ge,canConfigureProviderTrace:Z,content:"runtime",hidePromptTemplate:!0,hideInstructionsFile:!0})}),f==="secrets"&&(0,e.jsx)("div",{children:(0,e.jsx)(qs,{agent:I,companyId:_??void 0,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F,onSaved:ae,updatePermissions:Ge,content:"secrets"})}),f==="skills"&&(0,e.jsx)(Oo,{agent:I,companyId:_??void 0}),f==="tools"&&_&&(0,e.jsx)(pl,{agent:I,companyId:_}),f==="channels"&&_&&(0,e.jsx)(hl,{agentId:I.id,companyId:_}),f==="permissions"&&(0,e.jsx)("div",{children:(0,e.jsx)(qs,{agent:I,companyId:_??void 0,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F,onSaved:ae,updatePermissions:Ge,content:"permissions"})}),f==="api-keys"&&(0,e.jsx)("div",{className:"max-w-3xl",children:(0,e.jsx)(vc,{agentId:I.id,companyId:_??void 0})}),f==="revisions"&&(0,e.jsx)(xc,{agent:I,companyId:_??void 0}),f==="advanced"&&(0,e.jsx)(u.Suspense,{fallback:(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading configuration…"}),children:(0,e.jsx)(Xd,{agent:I,onDirtyChange:T,onSavingChange:F,onSaved:n(k=>{const B=ft(k),Fe=[...v.agents.detail(L),K??null];x.cancelQueries({queryKey:Fe,exact:!0}),x.setQueryData(Fe,{...I,...k}),x.setQueryData([...v.agents.detail(B),K??null],{...I,...k}),B!==L&&m(`/agents/${B}/advanced`,{replace:!0})},"onSaved")},I.id)}),f==="run-detail"&&(0,e.jsx)(hc,{runs:Ke??[],companyId:_,agentId:I.id,agentRouteId:ue,selectedRunId:i??null,adapterType:I.adapterType,adapterConfig:I.adapterConfig}),kt&&(0,e.jsx)(Ql,{dirty:R,saving:D,savedVersion:se,onDiscard:n(()=>X.current?.(),"onDiscard"),onSave:n(()=>{Promise.resolve(ne.current?.()).catch(()=>{})},"onSave")},`${I.id}-${f}`)]})}n(uc,"AgentDetail");function mc({agent:t,runs:s,assignedIssues:r,directReports:i=[],skillNames:o}){const a=ft(t),{openNewIssue:d}=va(),l=["Research a topic and summarize the key findings","Create a step-by-step plan for a project","Review a document and suggest improvements"],c=!!Cr(t.createdByUserId),x=U({queryKey:v.access.companyUserDirectory(t.companyId),queryFn:n(()=>vt.listUserDirectory(t.companyId),"queryFn"),enabled:c}),m=Xl(t.createdByUserId,x.data?.users),y=c&&ki(x)==="error",S=U({queryKey:[...v.activity(t.companyId),"agent-overview",t.id],queryFn:n(()=>xr.list(t.companyId,{agentId:t.id,limit:Gn}),"queryFn")}),j=Date.now(),p=j-6048e5,h=j-1728e5,f=Fs(S.data??[],p,Gn),$=Fs(s,p,200),C=Fs(s,h,200,F=>F.status==="failed"),R=t.budgetMonthlyCents??0,T=t.spentMonthlyCents??0,D=R>0?Math.round(T/R*100):null;return(0,e.jsxs)("div",{className:"flex flex-col gap-(--agent-detail-band-gap)",children:[(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-(--agent-detail-module-gap) sm:grid-cols-2 lg:grid-cols-4",children:[(0,e.jsx)(Gt,{icon:Za,value:S.isLoading?"–":$s(f),label:"Activity",description:"Events this week",to:Ve(a,"activity")}),(0,e.jsx)(Gt,{icon:cr,value:$s($),label:"Runs",description:`${$s(C)} failed in the last 2 days`,to:Ve(a,"runs")}),(0,e.jsx)(Gt,{icon:lr,value:Ks(T),label:"Costs",description:"Month to date",to:Ve(a,"costs")}),(0,e.jsx)(Gt,{icon:Sa,value:D===null?"–":`${D}%`,label:"Budget used",description:D===null?"No monthly budget set":`of ${Ks(R)} this month`,to:Ve(a,"budgets")}),(0,e.jsx)(Kt,{title:"Profile",className:"min-h-(--agent-detail-tile-min-h) sm:col-span-2","aria-label":"Profile",meta:(0,e.jsx)("span",{className:y?"text-destructive":void 0,children:y?"Could not load creator":m?`Created by ${m} · ${et(t.createdAt)}`:`Created ${et(t.createdAt)}`}),children:(0,e.jsxs)("div",{className:"flex flex-col pb-3",children:[(0,e.jsx)(Gl,{agent:t},t.id),i.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-(--agent-detail-module-inset) py-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Direct reports:"}),(0,e.jsx)(Ul,{reports:i})]})]})}),(0,e.jsx)(Kt,{title:"Skills",meta:(0,e.jsxs)("span",{children:[o.length," enabled"]}),className:"min-h-(--agent-detail-tile-min-h) sm:col-span-2","aria-label":"Skills",children:(0,e.jsxs)("div",{className:"flex flex-wrap gap-1.5 px-(--agent-detail-module-inset) pt-1 pb-(--agent-detail-module-inset)",children:[o.map(F=>(0,e.jsx)(is,{className:"h-7 px-2",children:F},F)),(0,e.jsxs)(ce,{to:Ve(a,"skills"),className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-dashed border-border px-2 py-1 text-sm text-muted-foreground no-underline transition-colors hover:bg-accent hover:text-foreground",children:["Explore skills ",(0,e.jsx)(or,{className:"size-3.5","aria-hidden":!0})]})]})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3","aria-label":"Recent tasks",children:[(0,e.jsx)(Tl,{title:"Recent tasks",action:(0,e.jsx)(ce,{to:`/issues?participantAgentId=${t.id}`,className:"text-xs text-muted-foreground no-underline transition-colors hover:text-foreground",children:"See all tasks"})}),r.length===0?(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Start with a suggested task"}),(0,e.jsx)("ul",{className:"overflow-hidden rounded-lg border border-border bg-(--agent-detail-tile) divide-y divide-dashed divide-border","aria-label":"Suggested tasks",children:l.map(F=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-4 text-left text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:n(()=>d({title:F,assigneeAgentId:t.id}),"onClick"),children:[(0,e.jsx)(en,{className:"size-4 shrink-0","aria-hidden":!0}),(0,e.jsx)("span",{className:"min-w-0 flex-1",children:F}),(0,e.jsx)(st,{className:"size-4 shrink-0","aria-hidden":!0})]})},F))})]}):(0,e.jsx)("div",{className:"overflow-hidden rounded-lg border border-border bg-(--agent-detail-tile)",children:(0,e.jsx)(so,{issues:r.slice(0,5)})})]})]})}n(mc,"AgentOverview");function xc({agent:t,companyId:s}){const r=Be(),i=Lt(),{data:o}=U({queryKey:v.agents.configRevisions(t.id),queryFn:n(()=>W.listConfigRevisions(t.id,s),"queryFn")}),a=te({mutationFn:n(d=>W.rollbackConfigRevision(t.id,d,s),"mutationFn"),onSuccess:n(d=>{r.invalidateQueries({queryKey:v.agents.detail(t.id)}),r.invalidateQueries({queryKey:v.agents.configRevisions(t.id)}),Ns(r,i,t,d,"revisions")||r.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})},"onSuccess")});return(0,e.jsxs)("div",{className:"max-w-3xl space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Configuration Revisions"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[o?.length??0," total"]})]}),(o??[]).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No configuration revisions yet."}):(0,e.jsx)("div",{className:"space-y-2",children:(o??[]).map(d=>(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-mono",children:d.id.slice(0,8)}),(0,e.jsx)("span",{className:"mx-1",children:"·"}),(0,e.jsx)("span",{children:et(d.createdAt)}),(0,e.jsx)("span",{className:"mx-1",children:"·"}),(0,e.jsx)("span",{children:d.source})]}),(0,e.jsx)(M,{size:"sm",variant:"outline",onClick:n(()=>a.mutate(d.id),"onClick"),disabled:a.isPending,children:"Restore"})]}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Changed: ",d.changedKeys.length>0?d.changedKeys.join(", "):"no tracked changes"]})]},d.id))})]})}n(xc,"AgentRevisionsTab");function qs({agent:t,companyId:s,onDirtyChange:r,onSaveActionChange:i,onCancelActionChange:o,onSavingChange:a,onSaved:d,updatePermissions:l,hidePromptTemplate:c,hideInstructionsFile:x,content:m="runtime",canConfigureProviderTrace:y=!1}){const S=Be(),j=Lt(),{tab:p}=gs(),{pushToast:h}=sn(),[f,$]=(0,u.useState)(!1),C=(0,u.useRef)(t),R=t.adapterType==="paperclip_runner"?String(t.adapterConfig.provider??"codex"):void 0,{data:T}=U({queryKey:s?v.agents.adapterModels(s,t.adapterType,null,R):["agents","none","adapter-models",t.adapterType],queryFn:n(()=>W.adapterModels(s,t.adapterType,{provider:R}),"queryFn"),enabled:!!s&&m==="runtime"&&!["openai_dot","grok_bot","muse"].includes(R??"")}),D=zi(t.permissions)==="low_trust_review",{data:F,isLoading:se}=U({...gr(s??""),enabled:!!(s&&D)&&m==="permissions"}),{data:ee,isLoading:ae}=U({queryKey:s?[...v.issues.list(s),"low-trust-boundary-candidates"]:["issues","__low-trust-disabled"],queryFn:n(()=>gt.list(s,{limit:100,sortField:"updated",sortDir:"desc"}),"queryFn"),enabled:!!(s&&D)&&m==="permissions"}),O=te({mutationFn:n(({target:z,patch:q})=>W.update(z.id,q,z.companyId),"mutationFn"),onMutate:n(()=>{$(!0)},"onMutate"),onSuccess:n((z,{target:q})=>{C.current.id===q.id&&d?.(),S.invalidateQueries({queryKey:v.agents.detail(q.id)}),S.invalidateQueries({queryKey:v.agents.configRevisions(q.id)}),S.invalidateQueries({queryKey:v.agents.list(q.companyId)}),(C.current.id!==q.id||!Ns(S,j,q,z,p??m))&&S.invalidateQueries({queryKey:v.agents.detail(q.urlKey)}),h({title:"Agent saved",tone:z.configurationWarnings?.length?"warn":"success",body:z.configurationWarnings?.map(pe=>pe.message).join(`
|
|
38
|
+
`);X.current=J.pop()??"",P&&X.current&&(J.push(X.current),X.current="");const de=[];for(const re of J){const ye=re.trim();if(ye)try{const G=JSON.parse(ye),Ee=G.stream==="stderr"||G.stream==="system"?G.stream:"stdout",Te=typeof G.chunk=="string"?G.chunk:"",He=typeof G.ts=="string"?G.ts:new Date().toISOString();if(!Te)continue;const Ae=xn(G.seq);_.current.confirm(Ae),de.push({ts:He,stream:Ee,chunk:Te,seq:Ae})}catch{}}de.length>0&&I(de)}n(De,"appendLogContent");const _e=(0,u.useRef)(null),Ce=(0,u.useRef)(null),xe=(0,u.useRef)(new Ft),_=(0,u.useRef)(new Ft),ue=(0,u.useRef)(0),N=(0,u.useRef)(0),V=(0,u.useRef)(0),A=(0,u.useRef)(t.logRef??null),Z=(0,u.useRef)(new Set),be=(0,u.useRef)(q),Ne=n(E=>{if(typeof E!="string"||!E||E===A.current)return"same";if(Z.current.has(E))return"stale";const P=A.current;return A.current=E,P?(Z.current.add(P),Z.current.size>8&&Z.current.delete(Z.current.values().next().value),X.current="",F.current={seenChunkKeys:new Set,trimmedSeqFloorByRun:new Map},_.current=new Ft,h([]),D(0),"changed"):"same"},"bindLog");(0,u.useEffect)(()=>{ue.current=0,N.current=0,V.current=0,xe.current=new Ft,_.current=new Ft,be.current=q,A.current=t.logRef??null,Z.current.clear(),m.current=!1,l(!1),S(!1),x(null),a([]),$(!0)},[t.id,t.companyId]),(0,u.useEffect)(()=>{q&&(be.current=!0)},[q]);function Re(E,P=!1){P&&(V.current=Math.max(V.current,E.at(-1)?.seq??0)),a(J=>{const de=Or(J,E);if(!q&&!be.current)return de;const re=Math.max(200,V.current),ye=de.filter(Ee=>Ee.seq<=re),G=de.filter(Ee=>Ee.seq>re);return[...ye,...G.slice(-Td)]})}n(Re,"appendEvents");const ve=ka(q?[t.id]:[],{companyId:t.companyId,enabled:r},E=>{if(E.companyId!==t.companyId)return;const P=jt(E.payload);if(!P||P.runId!==t.id)return;if(E.type==="heartbeat.run.log"){const re=Ne(P.logRef);if(re==="stale")return;const ye=xn(P.seq);P.truncated===!0&&_.current.requireHistory(ye);const G=_.current.observe(ye);if((re==="changed"||P.truncated===!0||G)&&Ce.current?.(),P.truncated===!0)return;const Ee=typeof P.chunk=="string"?P.chunk:"";if(!Ee)return;const Te=P.stream==="stderr"||P.stream==="system"?P.stream:"stdout";I([{ts:fe(P.ts)??E.createdAt,stream:Te,chunk:Ee,seq:ye}]);return}if(E.type==="heartbeat.run.progress"){const re=zd(P,E.createdAt);if(!re)return;const ye=Od(re);if(b.current.has(ye))return;b.current.add(ye),I([re]);return}if(E.type==="heartbeat.run.status"){_e.current?.(!0),Ce.current?.(!0);return}const J=Dr(E);if(!J)return;const de=J.message===null&&J.payload===null;de&&xe.current.requireHistory(J.seq),xe.current.observe(J.seq)&&_e.current?.(),!de&&Re([J])});(0,u.useEffect)(()=>{if(S(!1),!r)return;let E=!1,P;const J=new AbortController;let de=!1,re=!1,ye=null;const G=n(async(Ee=!1,Te=!1)=>{if(E)return;if(de){Te&&(re=!0);return}if(m.current&&!Ee&&!Te)return;de=!0,re=!1,S(!0),x(null),window.clearTimeout(P),P=void 0;let He=!1;try{const Ae=Te?Math.max(N.current,ue.current):ue.current,Ge=ue.current===0,Ie=await un(Ye=>tt.events(t.id,Ae,1e3,{signal:Ye}),J.signal);if(E)return;Re(Ie,!Te||Ge),$(!1);const Qe=Math.max(Ae,Ie.at(-1)?.seq??Ae);N.current=Math.max(N.current,Qe),xe.current.confirm(Qe),Te&&Ie.length===1e3&&Qe>Ae&&(re=!0),(!Te||Ge)&&(ue.current=Qe,m.current=Ie.length===1e3&&Qe>Ae,l(m.current)),He=xe.current.needsCatchup,ye=null}catch(Ae){He=!0,ye={requested:Ee,catchup:Te},i.reportError(Ae),!E&&!ei(Ae)&&x("Could not load events. Try again.")}E||(de=!1,S(!1),re?G(!1,!0):(He||q&&!ve.healthy&&!m.current)&&(P=window.setTimeout(()=>{G(Ee,Te||xe.current.needsCatchup)},2e3)))},"read");return _e.current=()=>{G(!1,be.current)},j.current=()=>{G(ye?.requested??!0,ye?.catchup??!1)},G(!1,be.current&&(ve.healthy||ue.current>0)),()=>{E=!0,_e.current=null,j.current=null,J.abort(),P!==void 0&&window.clearTimeout(P)}},[r,t.id,t.companyId,t.status,ve.healthy,ve.epoch]);const Se=(0,u.useCallback)(()=>{if(L.current)return L.current;const E=Bd(ne.current);return L.current=E,E},[]),Pe=(0,u.useCallback)(()=>{const E=Se(),P=Jt(E);z.current=P;const J=P.distanceFromBottom<=32;K.current=J,O(de=>de===J?de:J)},[Se]);(0,u.useEffect)(()=>{if(L.current=null,z.current={scrollHeight:0,distanceFromBottom:Number.POSITIVE_INFINITY},!q){K.current=!1,O(!1);return}Pe()},[q,t.id,Pe]),(0,u.useEffect)(()=>{if(!q)return;const E=Se();return Pe(),E===window?window.addEventListener("scroll",Pe,{passive:!0}):E.addEventListener("scroll",Pe,{passive:!0}),window.addEventListener("resize",Pe),()=>{E===window?window.removeEventListener("scroll",Pe):E.removeEventListener("scroll",Pe),window.removeEventListener("resize",Pe)}},[q,t.id,Se,Pe]),(0,u.useEffect)(()=>{if(!q||!K.current)return;const E=Se(),P=z.current,J=Jt(E),de=Math.max(0,J.scrollHeight-P.scrollHeight),re=P.distanceFromBottom+de;if(J.distanceFromBottom-re>32){K.current=!1,O(!1),z.current=J;return}Vn(E,"auto");const ye=Jt(E);z.current=ye,K.current||(K.current=!0),O(G=>G||!0)},[o.length,p.length,q,Se]),(0,u.useEffect)(()=>{X.current="",F.current={seenChunkKeys:new Set,trimmedSeqFloorByRun:new Map},b.current=new Set,h([]),D(0),ee(!1)},[t.id,t.logRef,D]);const ge=(0,u.useRef)(!1),ke=!!t.logRef||pe,je=zr({key:["run-log",t.companyId,t.id,t.logRef??null,q?null:t.logBytes,pe],enabled:r&&ke,refetchInterval:_.current.needsCatchup||pe&&!ve.healthy?2e3:!1,fetcher:n(async E=>{const P=T.current;try{return{offset:P,result:await un(J=>tt.log(t.id,P,Ld,{signal:J}),E)}}catch(J){if(pe&&Me(J))return{offset:P,result:null};throw J}},"fetcher"),onSuccess:n(({offset:E,result:P})=>{if(!P)return;const J=Ne(P.logRef);if(J==="stale")return;if(J==="changed"&&E!==0){queueMicrotask(()=>je.refetch());return}De(P.content,P.nextOffset===void 0);const de=P.nextOffset??E+new TextEncoder().encode(P.content).byteLength;D(de),ee(!be.current&&P.nextOffset!==void 0&&!!P.content),(ge.current||be.current&&P.nextOffset!==void 0&&P.content&&de>E)&&(ge.current=!1,queueMicrotask(()=>je.refetch()))},"onSuccess")}),Y=ke&&["loading","reconnecting"].includes(je.view.kind),ct=je.view.kind==="error"?je.error:null,Le=je.isFetching;(0,u.useEffect)(()=>(Ce.current=()=>{je.isFetching?ge.current=!0:je.refetch()},()=>{Ce.current=null}),[je.refetch,je.isFetching]);const qe=(0,u.useRef)({runId:t.id,epoch:ve.epoch});(0,u.useEffect)(()=>{const E=qe.current;qe.current={runId:t.id,epoch:ve.epoch},r&&ke&&E.runId===t.id&&E.epoch!==ve.epoch&&Ce.current?.()},[t.id,ve.epoch,r,ke]),(0,u.useEffect)(()=>i.onRecover(()=>_e.current?.(!0)),[i]);const he=U({queryKey:v.instance.generalSettings,queryFn:n(()=>us.getGeneral(),"queryFn")}).data?.censorUsernameInLogs===!0,ie=(0,u.useMemo)(()=>{const E=o.find(P=>P.eventType==="adapter.invoke");return It(jt(E?.payload??null),he)},[he,o]),[nt,ut]=(0,u.useState)(0),rt=Aa(s);(0,u.useEffect)(()=>Wa(()=>ut(E=>E+1)),[]);const Ke=(0,u.useMemo)(()=>Ia(p,rt,{censorUsernameInLogs:he}),[rt,he,p,nt]),wt=U({queryKey:v.tools.runDecisions(t.companyId,t.id),queryFn:n(()=>ot.getRunDecisionLookup(t.companyId,t.id),"queryFn"),enabled:!!(t.companyId&&t.id),refetchInterval:q?3e3:!1,staleTime:q?1e3:3e4});if((0,u.useEffect)(()=>{le("nice")},[t.id]),f&&Y&&!c&&!ct)return(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading run logs..."});if(o.length===0&&p.length===0&&!ct&&!c)return(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:f||Y?"Loading run logs...":"No log events."});const Q={info:"text-foreground",warn:"text-yellow-600 dark:text-yellow-400",error:"text-red-600 dark:text-red-400"},at={stdout:"text-foreground",stderr:"text-red-600 dark:text-red-300",system:"text-blue-600 dark:text-blue-300"};return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(Jd,{operations:we,censorUsernameInLogs:he}),ie&&(0,e.jsx)(Hd,{payload:ie,censorUsernameInLogs:he}),(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground",children:["Transcript (",Ke.length,")"]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"inline-flex rounded-lg border border-border/70 bg-background/70 p-0.5",children:["nice","raw"].map(E=>(0,e.jsx)("button",{type:"button",className:w("rounded-md px-2.5 py-1 text-(length:--text-micro) font-medium capitalize transition-colors",me===E?"bg-accent text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:n(()=>le(E),"onClick"),children:E},E))}),q&&!ae&&(0,e.jsx)(M,{variant:"ghost",size:"xs",onClick:n(()=>{const E=Se();K.current=!0,O(!0),Vn(E,"auto"),z.current=Jt(E)},"onClick"),children:"Jump to live"}),q&&(0,e.jsxs)("span",{className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400",children:[(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),"Live"]})]})]}),(0,e.jsxs)("div",{className:"max-h-(--sz-38rem) overflow-y-auto rounded-2xl border border-border/70 bg-background/40 p-3 sm:p-4",children:[(0,e.jsx)(Id,{entries:Ke,toolDecisions:wt.data?.decisions??[],mode:me,streaming:q,limit:q?_d:void 0,emptyMessage:t.logRef?"Waiting for transcript...":"No persisted transcript for this run."}),se&&(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3",children:[(0,e.jsx)(M,{type:"button",variant:"outline",size:"xs",onClick:je.view.retry,disabled:Le,children:Le?"Loading...":"Load more log"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Showing the first ",Math.round(C/1024).toLocaleString("en-US")," KB",typeof t.logBytes=="number"&&t.logBytes>0?` of ${Math.round(t.logBytes/1024).toLocaleString("en-US")} KB`:""]})]}),ct!=null&&(0,e.jsx)(yt,{className:"mt-3",error:ct,action:"load the run log",onRetry:je.view.retry,retrying:Le}),(0,e.jsx)("div",{ref:ne})]}),(t.status==="failed"||t.status==="timed_out")&&(0,e.jsxs)("div",{className:w("rounded-lg border border-red-300 dark:border-red-500/30 bg-red-50 dark:bg-red-950/20 p-3 space-y-2","ph-mask ph-sensitive"),children:[(0,e.jsx)("div",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:"Failure details"}),t.error&&(0,e.jsxs)("div",{className:"text-xs text-red-600 dark:text-red-200",children:[(0,e.jsx)("span",{className:"text-red-700 dark:text-red-300",children:"Error: "}),(0,e.jsx)(Ms,{children:Ze(t.error,he)})]}),t.stderrExcerpt&&t.stderrExcerpt.trim()&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 mb-1",children:"stderr excerpt"}),(0,e.jsx)("pre",{className:w("bg-red-50 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap text-red-800 dark:text-red-100","ph-mask ph-sensitive"),children:Ze(t.stderrExcerpt,he)})]}),t.resultJson&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 mb-1",children:"adapter result JSON"}),(0,e.jsx)("pre",{className:w("bg-red-50 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap text-red-800 dark:text-red-100","ph-mask ph-sensitive"),children:JSON.stringify(It(t.resultJson,he),null,2)})]}),t.stdoutExcerpt&&t.stdoutExcerpt.trim()&&!t.resultJson&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 mb-1",children:"stdout excerpt"}),(0,e.jsx)("pre",{className:w("bg-red-50 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap text-red-800 dark:text-red-100","ph-mask ph-sensitive"),children:Ze(t.stdoutExcerpt,he)})]})]}),(o.length>0||c)&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:["Events (",o.length,")"]}),c&&(0,e.jsx)("p",{className:"text-sm text-destructive",children:c}),(d||c)&&(0,e.jsx)(M,{variant:"outline",size:"sm",disabled:y,onClick:n(()=>j.current?.(),"onClick"),children:y?"Loading...":c?"Retry events":"Load more events"}),(0,e.jsx)("div",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-lg p-3 font-mono text-xs space-y-0.5","ph-mask ph-sensitive"),children:o.map(E=>{const P=E.color??(E.level?Q[E.level]:null)??(E.stream?at[E.stream]:null)??"text-foreground";return(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("span",{className:"text-neutral-400 dark:text-neutral-600 shrink-0 select-none w-16",children:new Date(E.createdAt).toLocaleTimeString("en-US",{hour12:!1})}),(0,e.jsx)("span",{className:w("shrink-0 w-14",E.stream?at[E.stream]??"text-neutral-500":"text-neutral-500"),children:E.stream?`[${E.stream}]`:""}),(0,e.jsx)("span",{className:w("break-all",P),children:E.message?(0,e.jsx)(Ms,{children:Ze(E.message,he)}):E.payload?JSON.stringify(It(E.payload,he)):""})]},`${E.runId}:${E.seq}`)})})]})]})}n(Zd,"LogViewer");var Xd=(0,u.lazy)(()=>Bi(()=>import("./AgentAdvancedTab-BG6ZIAuN.js").then(t=>({default:t.AgentAdvancedTab})),__vite__mapDeps([0,1,2,3,4,5,6]))),ec={succeeded:{icon:fs,color:"text-green-600 dark:text-green-400"},failed:{icon:si,color:"text-red-600 dark:text-red-400"},running:{icon:Et,color:"text-blue-600 dark:text-blue-400"},queued:{icon:Hs,color:"text-yellow-600 dark:text-yellow-400"},scheduled_retry:{icon:Hs,color:"text-sky-600 dark:text-sky-400"},timed_out:{icon:No,color:"text-orange-600 dark:text-orange-400"},cancelled:{icon:jo,color:"text-neutral-500 dark:text-neutral-400"}};function tc(t){return t.orgChainHealth?.fullChain.map(s=>`${s.name}${s.status!=="active"&&s.status!=="idle"?` (${s.status})`:""}`).join(" -> ")??t.name}n(tc,"formatOrgChainHealthPath");function sc(t){return t.toLowerCase().endsWith(".md")}n(sc,"isMarkdown");function nc(t){const s=t.detail?.markdown??t.summary?.markdown;return typeof s=="boolean"?s:sc(t.selectedPath)}n(nc,"shouldUseMarkdownInstructionsEditor");var rc={timer:"Timer",assignment:"Assignment",on_demand:"On-demand",automation:"Automation"};function ac(t,s=r=>typeof window>"u"||window.confirm(r)){return!t||s("Discard unsaved agent configuration changes?")}n(ac,"confirmAgentConfigNavigation");function ic(t,s){if(typeof t!="number"||typeof s!="number")return null;const r=t-s;return r===0?null:r}n(ic,"agentConfigHistoryRestoreDelta");function oc(t,s,r){const i=ic(s.index,r);return i===null?(t.pushState(s.state,"",s.url),!1):(t.go(i),!0)}n(oc,"restoreAgentConfigHistoryEntry");function Ps(t,...s){if(!t)return 0;for(const r of s){const i=t[r];if(typeof i=="number"&&Number.isFinite(i))return i}return 0}n(Ps,"usageNumber");function lc(t,s){if(t.size!==s.size)return!1;for(const r of t)if(!s.has(r))return!1;return!0}n(lc,"setsEqual");function cn(t){const s=t.usageJson??null,r=t.resultJson??null,i=Ja(r),o=Ps(s,"inputTokens","input_tokens"),a=Ps(s,"outputTokens","output_tokens"),d=Ps(s,"cachedInputTokens","cached_input_tokens","cache_read_input_tokens"),l=Ti(s,r),c=fe(s?.provider)??null,x=fe(s?.model)??null;return{usageUnavailable:i,input:i?null:o,output:i?null:a,cached:i?null:d,cost:i?null:l,totalTokens:i?null:Ki(s),provider:c,model:x}}n(cn,"runMetrics");function dc(t){return t==="queued"?5e3:t==="running"?15e3:!1}n(dc,"runDetailRefetchIntervalMs");var cc=new Set(["overview","instructions","budgets"]),Gn=200;function Yn(t,s){switch(t){case"runtime":return`How ${s} runs: harness, model and environment.`;case"secrets":return"Secrets this agent can reach. Values are never shown here.";case"permissions":return`What ${s} may do without asking, and where.`;case"activity":return`Everything ${s} did and everything done to ${s}.`;case"runs":return`Every execution of ${s}, newest first.`;case"costs":return`What ${s} spent, by model.`;default:return null}}n(Yn,"agentViewDescription");function uc(){const{companyPrefix:t,agentId:s,tab:r,runId:i}=gs(),{companies:o,selectedCompanyId:a,setSelectedCompanyId:d}=Xs(),{closePanel:l}=ai(),{setBreadcrumbs:c}=pr(),x=Be(),m=Lt(),y=Ii(),[S,j]=(0,u.useState)(null),[p,h]=(0,u.useState)(()=>new Set),f=i?"run-detail":$i(r??null);!i&&li(r??null);const $=f==="overview",C=$||f==="run-detail",[R,T]=(0,u.useState)(!1),[D,F]=(0,u.useState)(!1),[se,ee]=(0,u.useState)(0),ae=(0,u.useCallback)(()=>ee(k=>k+1),[]),[O,me]=(0,u.useState)(null),le=(0,u.useRef)(!1),ne=(0,u.useRef)(null),X=(0,u.useRef)(null),{isMobile:b}=Zs(),L=s??"",K=(0,u.useMemo)(()=>{if(!t)return null;const k=t.toUpperCase();return o.find(B=>B.issuePrefix.toUpperCase()===k)?.id??null},[o,t])??a??void 0,z=L.length>0&&(nr(L)||!!K),q=(0,u.useCallback)(k=>{ne.current=k},[]),pe=(0,u.useCallback)(k=>{X.current=k},[]),we=(0,u.useCallback)(()=>f==="advanced"&&D?!1:ac(R),[f,R,D]),Me=U({queryKey:[...v.agents.detail(L),K??null],queryFn:n(()=>W.get(L,K),"queryFn"),enabled:z}),{data:I,isLoading:De,error:_e}=Me,Ce=Dt(Me),xe=Vo(I),_=I?.companyId??a,ue=I?ft(I):L;(0,u.useCallback)(k=>{we()&&m(`/agents/${ue||L}/${k}`)},[ue,m,we,L]);const N=I?.id??L,V=I?.id??null,{data:A}=U({queryKey:v.access.currentBoardAccess,queryFn:n(()=>vt.getCurrentBoardAccess(),"queryFn")}),Z=A?.source==="local_implicit"||A?.isInstanceAdmin===!0,be=Va(_),Ne=Ya(_),Re=V?Mi(be.data,"agent",V):"joined",{data:ve}=U({queryKey:v.instance.experimentalSettings,queryFn:n(()=>us.getExperimental(),"queryFn"),enabled:!!_}),Se=ve?.enableBuiltInAgents===!0,{data:Pe}=U({queryKey:v.builtInAgents.list(_),queryFn:n(()=>Rt.list(_),"queryFn"),enabled:!!_&&Se}),ge=Se?Pe?.find(k=>k.agentId===V)??null:null,ke=ge?ge.definition.featureKeys.map(k=>k.charAt(0).toUpperCase()+k.slice(1)).join(", "):"",je=(0,u.useCallback)(()=>{x.invalidateQueries({queryKey:v.builtInAgents.list(_)}),V&&x.invalidateQueries({queryKey:v.agents.detail(V)}),x.invalidateQueries({queryKey:v.agents.detail(L)})},[x,_,V,L]),Y=te({mutationFn:n(()=>Rt.reset(_,ge.definition.key),"mutationFn"),onSuccess:je}),[ct,Le]=(0,u.useState)(!1),qe=te({mutationFn:n(k=>Rt.reset(_,ge.definition.key,[k]),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to update bundle resource")},"onError")}),he=te({mutationFn:n(k=>Rt.runRoutine(_,ge.definition.key,k),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to run built-in routine")},"onError")}),ie=te({mutationFn:n(k=>Rt.enableRoutineSchedule(_,ge.definition.key,k),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to enable routine schedule")},"onError")}),nt=te({mutationFn:n(k=>Rt.disableRoutineSchedule(_,ge.definition.key,k),"mutationFn"),onSuccess:je,onError:n(k=>{j(k instanceof Error?k.message:"Failed to disable routine schedule")},"onError")}),ut=he.isPending?"run":ie.isPending?"enable":nt.isPending?"disable":null,{data:rt}=U({queryKey:v.agents.runtimeState(V??L),queryFn:n(()=>W.runtimeState(V,_??void 0),"queryFn"),enabled:!!V&&$}),{data:Ke}=U({queryKey:v.heartbeats(_,I?.id??void 0),queryFn:n(()=>tt.list(_,I?.id??void 0),"queryFn"),enabled:!!_&&!!I?.id&&C}),{data:wt}=U({queryKey:[...v.issues.list(_),"participant-agent",V??"__none__"],queryFn:n(()=>gt.list(_,{participantAgentId:V}),"queryFn"),enabled:!!_&&!!V&&$}),{data:Q}=U({queryKey:v.agents.list(_),queryFn:n(()=>W.list(_),"queryFn"),enabled:!!_}),{data:at}=U({queryKey:v.agents.skills(V??"__none__"),queryFn:n(()=>W.skills(V,_??void 0),"queryFn"),enabled:!!(_&&V&&$)}),{data:E}=U({queryKey:v.companySkills.list(_??"__none__"),queryFn:n(()=>zs.list(_),"queryFn"),enabled:!!(_&&$)}),P=(0,u.useMemo)(()=>[...wt??[]].sort((k,B)=>new Date(B.updatedAt).getTime()-new Date(k.updatedAt).getTime()),[wt]),J=(Q??[]).find(k=>k.id===I?.reportsTo),[de,re]=(0,u.useState)(!1),ye=te({mutationFn:n(({target:k,patch:B})=>W.update(k.id,B,_??void 0),"mutationFn"),onSuccess:n((k,{target:B})=>{_&&x.invalidateQueries({queryKey:v.agents.list(_)}),x.invalidateQueries({queryKey:v.agents.configRevisions(B.id)}),Ns(x,m,B,k,r??"overview")||(x.invalidateQueries({queryKey:v.agents.detail(B.id)}),x.invalidateQueries({queryKey:v.agents.detail(ft(B))}))},"onSuccess")}),G=n(async k=>{if(I){if(R||D){j(`Save or discard your unsaved changes before you change the ${k.name===void 0?"title":"name"}.`);return}j(null);try{await ye.mutateAsync({target:I,patch:k})}catch(B){j(B instanceof Error?B.message:"Could not save that change")}}},"saveHeaderField"),Ee=(Q??[]).filter(k=>k.reportsTo===I?.id&&k.status!=="terminated"),Te=(0,u.useMemo)(()=>{const k=new Map((E??[]).map(B=>[B.key,B.name]));return(at?.desiredSkills??[]).map(B=>k.get(B)??B)},[E,at?.desiredSkills]),He=(0,u.useMemo)(()=>(Ke??[]).find(k=>k.status==="running"||k.status==="queued")??null,[Ke]);(0,u.useEffect)(()=>{if(!I||f==="advanced"&&(D||R))return;if(i){L!==ue&&m(`/agents/${ue}/runs/${i}`,{replace:!0});return}const k=f==="run-detail"?"overview":f;if(L!==ue||r!==Si(k)){m(`${Ve(ue,k)}${y.search}`,{replace:!0});return}},[I,L,ue,i,r,f,D,R,m,y.search]),(0,u.useEffect)(()=>{!I?.companyId||I.companyId===a||d(I.companyId,{source:"route_sync"})},[I?.companyId,a,d]);const Ae=te({mutationFn:n(async k=>N?k==="approve"?W.approve(N,_??void 0):W.retryLifecycle(N,_??void 0):Promise.reject(new Error("No agent reference")),"mutationFn"),onSuccess:n((k,B)=>{if(j(null),B==="retryLifecycle"){x.invalidateQueries({queryKey:[...v.agents.detail(N),"lifecycle"]});return}x.invalidateQueries({queryKey:v.agents.detail(L)}),x.invalidateQueries({queryKey:v.agents.detail(N)}),x.invalidateQueries({queryKey:v.agents.runtimeState(N)}),x.invalidateQueries({queryKey:v.agents.taskSessions(N)}),_&&(x.invalidateQueries({queryKey:v.agents.list(_)}),I?.id&&x.invalidateQueries({queryKey:v.heartbeats(_,I.id)}))},"onSuccess"),onError:n(k=>{j(k instanceof Error?k.message:"Action failed")},"onError")});te({mutationFn:n(k=>W.update(N,{icon:k},_??void 0),"mutationFn"),onSuccess:n(()=>{x.invalidateQueries({queryKey:v.agents.detail(L)}),x.invalidateQueries({queryKey:v.agents.detail(N)}),_&&x.invalidateQueries({queryKey:v.agents.list(_)})},"onSuccess")});const Ge=te({mutationFn:n(k=>W.updatePermissions(N,k,_??void 0),"mutationFn"),onSuccess:n(()=>{j(null),x.invalidateQueries({queryKey:v.agents.detail(L)}),x.invalidateQueries({queryKey:v.agents.detail(N)}),_&&x.invalidateQueries({queryKey:v.agents.list(_)})},"onSuccess"),onError:n(k=>{j(k instanceof Error?k.message:"Failed to update permissions")},"onError")});if((0,u.useEffect)(()=>{const k=[{label:"Agents",href:"/agents"}],B=I?.name??L??"Agent";f==="overview"&&!i?k.push({label:B}):(k.push({label:B,href:Ve(ue)}),i?(k.push({label:"Runs",href:Ve(ue,"runs")}),k.push({label:`Run ${i.slice(0,8)}`})):k.push({label:Cn(f==="run-detail"?"overview":f)})),c(k)},[c,I,L,ue,f,i]),(0,u.useEffect)(()=>(l(),()=>l()),[l]),(0,u.useEffect)(()=>{!V||Re!=="joined"||h(k=>{if(!k.has(V))return k;const B=new Set(k);return B.delete(V),B})},[V,Re]),Ui((0,u.useCallback)(k=>{R&&(k.preventDefault(),k.returnValue="")},[R])),(0,u.useEffect)(()=>{if(!R)return;function k(B){if(B.defaultPrevented||B.button!==0||B.altKey||B.ctrlKey||B.metaKey||B.shiftKey)return;const Fe=B.target;if(!(Fe instanceof Element))return;const it=Fe.closest("a[href]");if(!(it instanceof HTMLAnchorElement)||it.target&&it.target!=="_self")return;const ht=new URL(it.href,window.location.href),g=new URL(window.location.href);ht.origin===g.origin&&(ht.pathname===g.pathname&&ht.search===g.search&&ht.hash===g.hash||le.current||(B.preventDefault(),B.stopPropagation(),!(f==="advanced"&&D)&&me(it)))}return n(k,"handleDocumentClick"),document.addEventListener("click",k,!0),()=>document.removeEventListener("click",k,!0)},[f,R,D]),(0,u.useEffect)(()=>{if(!R)return;const k={index:window.history.state?.idx,state:window.history.state,url:window.location.href};let B=!1;function Fe(it){if(B){B=!1;return}we()||(it.stopImmediatePropagation(),B=oc(window.history,k,it.state?.idx))}return n(Fe,"handlePopState"),window.addEventListener("popstate",Fe,!0),()=>window.removeEventListener("popstate",Fe,!0)},[R,we]),De||Ce.kind==="reconnecting")return(0,e.jsx)(vs,{variant:"detail"});if(Ce.kind==="error")return(0,e.jsx)(yt,{size:"page",error:_e,action:"load this agent",onRetry:Ce.retry,retrying:Ce.isFetching});if(!I)return null;if(!i&&!r)return(0,e.jsx)(qi,{to:Ve(ue),replace:!0});const Ie=xe.data&&(xe.data.lifecycleVersion??0)>=(I.lifecycleVersion??0)?{...I,...xe.data}:I,Qe=Ie.status==="pending_approval",Ye=I.orgChainHealth?.status==="invalid_org_chain",xt=Ye?null:I.orgChainHealth?.escalationWarning??null,kt=f==="runtime"||f==="instructions"||f==="secrets",St=Re==="left"&&!p.has(I.id),We=Ne.isPending&&Ne.variables?.resourceType==="agent"&&Ne.variables.resourceId===I.id;Ea(be.data,"agent",I.id),We&&Ne.variables?.starred;const Ct=We&&Ne.variables?.starred===void 0;return(0,e.jsxs)("div",{className:w("agent-settings-content mx-auto max-w-5xl space-y-8",`agent-settings-${f}`,kt&&"agent-settings-with-save-bar"),children:[St?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 border border-yellow-300/35 bg-yellow-300/10 px-3 py-2 text-sm text-yellow-900 dark:text-yellow-100",children:[(0,e.jsx)("p",{className:"min-w-0 flex-1",children:"You left this agent. It no longer appears in your sidebar."}),(0,e.jsx)(no,{compact:!0,state:"left",pending:Ct,pendingState:Ct?Ne.variables?.state:null,resourceName:I.name,onJoin:n(()=>Ne.mutate({resourceType:"agent",resourceId:I.id,resourceName:I.name,state:"joined"}),"onJoin"),onLeave:n(()=>Ne.mutate({resourceType:"agent",resourceId:I.id,resourceName:I.name,state:"left"}),"onLeave")}),(0,e.jsx)("button",{type:"button",className:"h-6 w-6 shrink-0 text-yellow-900/70 hover:text-yellow-900 dark:text-yellow-100/70 dark:hover:text-yellow-100","aria-label":"Dismiss agent membership notice",onClick:n(()=>h(k=>new Set(k).add(I.id)),"onClick"),children:"×"})]}):null,xt?(0,e.jsxs)("div",{className:"flex items-start gap-3 border border-amber-300/35 bg-amber-300/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-100",children:[(0,e.jsx)(wn,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium",children:"Escalation path is paused"}),(0,e.jsx)("p",{className:"text-amber-900/90 dark:text-amber-100/90",children:xt})]})]}):null,Ye?(0,e.jsxs)("div",{className:"flex items-start gap-3 border border-amber-300/35 bg-amber-300/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-100",children:[(0,e.jsx)(wn,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium",children:"Invalid reporting chain"}),(0,e.jsxs)("p",{className:"text-amber-900/90 dark:text-amber-100/90",children:[I.name," cannot accept tasks or start runs until its reporting chain is repaired."]}),(0,e.jsx)("p",{className:"break-words font-mono text-xs text-amber-900/80 dark:text-amber-100/80",children:tc(I)}),I.orgChainHealth?.repairGuidance?(0,e.jsx)("p",{className:"text-amber-900/85 dark:text-amber-100/85",children:I.orgChainHealth.repairGuidance}):(0,e.jsx)("p",{className:"text-amber-900/85 dark:text-amber-100/85",children:"Assign this agent to an active manager/root, or explicitly pause or terminate the affected agent/subtree."})]})]}):null,(0,e.jsxs)("header",{className:"agent-character-header flex items-center gap-2",children:[(0,e.jsx)("div",{role:"img","aria-label":`${I.name} avatar`,className:"shrink-0",children:(0,e.jsx)(oi,{agent:I,state:Sn(Ie.status)==="rest"?"idle":Sn(Ie.status),size:128,className:"agent-header-character",trackingScope:"page",followCursor:!0})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(pn,{as:"h1",value:I.name,fitContent:!0,placeholder:"Agent name",className:"min-w-0 truncate text-2xl font-semibold leading-8 text-foreground",onSave:n(k=>G({name:k}),"onSave")}),(0,e.jsx)(gi,{agent:I})]}),(0,e.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-5 text-muted-foreground",children:[(0,e.jsxs)(ce,{to:Ve(ue,"runtime"),"aria-label":`Open ${bn(yn(I)).label} harness settings`,className:"flex shrink-0 items-center gap-1 rounded-sm no-underline transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[I.adapterType==="claude_local"||I.adapterType==="codex_local"?(0,e.jsx)("img",{src:`/brands/${I.adapterType==="claude_local"?"claude":"codex"}-color.svg`,className:"-ml-0.5 size-4",alt:""}):null,(0,e.jsx)("span",{children:bn(yn(I)).label})]}),(0,e.jsx)("span",{"aria-hidden":"true",children:"•"}),(0,e.jsx)(pn,{fitContent:!0,value:I.title??"",nullable:!0,placeholder:Ua[I.role]??I.role,className:"agent-header-custom-title min-w-0 truncate text-sm leading-5 text-muted-foreground",onSave:n(k=>G({title:k||null}),"onSave")})]}),(0,e.jsx)(Go,{agent:Ie,refreshError:xe.isError,onRetry:n(()=>Ae.mutate("retryLifecycle"),"onRetry"),retryPending:Ae.isPending})]}),(0,e.jsx)(ro,{agent:Ie,companyId:_,assignLabel:"New task",size:"default",assignIcon:en,showChat:!0,showStatus:!1,workActionsInMenu:!0,menuItems:[{label:"Agent history",icon:ha,onSelect:n(()=>re(!0),"onSelect")}],actionsDisabled:Ae.isPending||f==="advanced"&&D,workActionsDisabled:Ye,workActionsDisabledReason:"Repair this agent's reporting chain before assigning tasks or starting runs",hasPendingNavigationChanges:R,onBeforeNavigate:we,onActionError:j,onTerminateSuccess:n(()=>m("/agents/all",{replace:!0}),"onTerminateSuccess"),hideTerminate:!!ge,pauseConfirm:ge?{title:`Pause the ${ge.definition.displayName}?`,description:(0,e.jsxs)(e.Fragment,{children:[ke," depends on this agent. While paused,"," ",ke.toLowerCase()," generation is skipped and the"," ",ke," page shows a warning."]})}:void 0,children:He&&(0,e.jsxs)(ce,{to:`/agents/${ue}/runs/${He.id}`,className:"sm:hidden flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",children:[(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,e.jsx)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:"Live"})]})})]}),(0,e.jsx)(Zl,{agent:I,companyId:_??void 0,open:de,onOpenChange:re}),(0,e.jsx)(ps,{open:O!==null,onOpenChange:n(k=>k?void 0:me(null),"onOpenChange"),children:(0,e.jsxs)(hs,{children:[(0,e.jsxs)(ms,{children:[(0,e.jsx)(ys,{children:"Discard unsaved changes?"}),(0,e.jsxs)(cs,{children:["You have unsaved changes to ",I.name,"’s ",f==="runtime"?"harness settings":f==="secrets"?"secrets and variables":f==="advanced"?"configuration":"instructions",". If you continue, they’ll be lost."]})]}),(0,e.jsxs)(ds,{className:"sm:justify-between",children:[(0,e.jsx)(bs,{children:"Keep editing"}),(0,e.jsx)(ls,{className:"bg-destructive text-white hover:bg-destructive/90",onClick:n(()=>{const k=O;if(me(null),X.current?.(),!!k){le.current=!0;try{k.click()}finally{le.current=!1}}},"onClick"),children:"Discard changes"})]})]})}),ge&&(0,e.jsxs)(Mt,{tone:"info",title:"Built-in agent",actions:(0,e.jsx)(M,{variant:"outline",size:"sm",onClick:n(()=>Y.mutate(),"onClick"),disabled:Y.isPending,children:Y.isPending?"Resetting…":"Reset to defaults"}),children:["Ships with Microvac and powers ",(0,e.jsx)("strong",{children:ke}),". Configure it like any agent — model, instructions, budget. It can be paused but not deleted; pausing it pauses ",ke,"."]}),ge?.definition.bundle&&(0,e.jsx)(el,{state:ge,agentRef:ue,onConfigure:n(()=>Le(!0),"onConfigure"),onResetResource:n(k=>qe.mutate(k),"onResetResource"),onRunRoutine:n(k=>he.mutate(k),"onRunRoutine"),onEnableSchedule:n(k=>ie.mutate(k),"onEnableSchedule"),onDisableSchedule:n(k=>nt.mutate(k),"onDisableSchedule"),resettingResource:qe.isPending?qe.variables??null:null,routineActionPending:ut}),ge&&_&&(0,e.jsx)(Xi,{companyId:_,state:ge,open:ct,onOpenChange:Le,onConfigured:n(()=>{Le(!1),je()},"onConfigured")}),S&&(0,e.jsx)("p",{className:"text-sm text-destructive",children:S}),Qe&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-400/40 dark:bg-amber-950/30 dark:text-amber-200",children:[(0,e.jsx)("span",{children:"This agent is pending board approval and cannot be invoked yet."}),(0,e.jsxs)(M,{variant:"outline",size:"sm",onClick:n(()=>Ae.mutate("approve"),"onClick"),disabled:Ae.isPending,children:[(0,e.jsx)(fs,{className:"h-3.5 w-3.5 sm:mr-1"}),(0,e.jsx)("span",{children:"Approve agent"})]})]}),f!=="run-detail"&&f!=="channels"&&!cc.has(f)?(0,e.jsxs)("div",{className:"mb-4 space-y-1",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:Cn(f)}),Yn(f,I.name)?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:Yn(f,I.name)}):null]}):null,pi(f)&&_?(0,e.jsx)(Bl,{agent:I,companyId:_,section:f}):null,f==="overview"&&(0,e.jsx)(mc,{agent:I,runs:Ke??[],assignedIssues:P,runtimeState:rt,reportsToAgent:J,directReportCount:Ee.length,directReports:Ee,skillNames:Te,agentRouteId:ue}),f==="instructions"&&(0,e.jsxs)("div",{children:[(0,e.jsx)(pc,{agent:I,companyId:_??void 0,showSaveNotice:!1,onSaved:ae,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F}),_&&(0,e.jsx)(ga,{companyId:_,agentId:I.id})]}),f==="runtime"&&(0,e.jsx)("div",{children:(0,e.jsx)(qs,{agent:I,companyId:_??void 0,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F,onSaved:ae,updatePermissions:Ge,canConfigureProviderTrace:Z,content:"runtime",hidePromptTemplate:!0,hideInstructionsFile:!0})}),f==="secrets"&&(0,e.jsx)("div",{children:(0,e.jsx)(qs,{agent:I,companyId:_??void 0,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F,onSaved:ae,updatePermissions:Ge,content:"secrets"})}),f==="skills"&&(0,e.jsx)(Oo,{agent:I,companyId:_??void 0}),f==="tools"&&_&&(0,e.jsx)(pl,{agent:I,companyId:_}),f==="channels"&&_&&(0,e.jsx)(hl,{agentId:I.id,companyId:_}),f==="permissions"&&(0,e.jsx)("div",{children:(0,e.jsx)(qs,{agent:I,companyId:_??void 0,onDirtyChange:T,onSaveActionChange:q,onCancelActionChange:pe,onSavingChange:F,onSaved:ae,updatePermissions:Ge,content:"permissions"})}),f==="api-keys"&&(0,e.jsx)("div",{className:"max-w-3xl",children:(0,e.jsx)(vc,{agentId:I.id,companyId:_??void 0})}),f==="revisions"&&(0,e.jsx)(xc,{agent:I,companyId:_??void 0}),f==="advanced"&&(0,e.jsx)(u.Suspense,{fallback:(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading configuration…"}),children:(0,e.jsx)(Xd,{agent:I,onDirtyChange:T,onSavingChange:F,onSaved:n(k=>{const B=ft(k),Fe=[...v.agents.detail(L),K??null];x.cancelQueries({queryKey:Fe,exact:!0}),x.setQueryData(Fe,{...I,...k}),x.setQueryData([...v.agents.detail(B),K??null],{...I,...k}),B!==L&&m(`/agents/${B}/advanced`,{replace:!0})},"onSaved")},I.id)}),f==="run-detail"&&(0,e.jsx)(hc,{runs:Ke??[],companyId:_,agentId:I.id,agentRouteId:ue,selectedRunId:i??null,adapterType:I.adapterType,adapterConfig:I.adapterConfig}),kt&&(0,e.jsx)(Ql,{dirty:R,saving:D,savedVersion:se,onDiscard:n(()=>X.current?.(),"onDiscard"),onSave:n(()=>{Promise.resolve(ne.current?.()).catch(()=>{})},"onSave")},`${I.id}-${f}`)]})}n(uc,"AgentDetail");function mc({agent:t,runs:s,assignedIssues:r,directReports:i=[],skillNames:o}){const a=ft(t),{openNewIssue:d}=va(),l=["Research a topic and summarize the key findings","Create a step-by-step plan for a project","Review a document and suggest improvements"],c=!!Cr(t.createdByUserId),x=U({queryKey:v.access.companyUserDirectory(t.companyId),queryFn:n(()=>vt.listUserDirectory(t.companyId),"queryFn"),enabled:c}),m=Xl(t.createdByUserId,x.data?.users),y=c&&ki(x)==="error",S=U({queryKey:[...v.activity(t.companyId),"agent-overview",t.id],queryFn:n(()=>xr.list(t.companyId,{agentId:t.id,limit:Gn}),"queryFn")}),j=Date.now(),p=j-6048e5,h=j-1728e5,f=Fs(S.data??[],p,Gn),$=Fs(s,p,200),C=Fs(s,h,200,F=>F.status==="failed"),R=t.budgetMonthlyCents??0,T=t.spentMonthlyCents??0,D=R>0?Math.round(T/R*100):null;return(0,e.jsxs)("div",{className:"flex flex-col gap-(--agent-detail-band-gap)",children:[(0,e.jsxs)("div",{className:"grid grid-cols-1 gap-(--agent-detail-module-gap) sm:grid-cols-2 lg:grid-cols-4",children:[(0,e.jsx)(Gt,{icon:Za,value:S.isLoading?"–":$s(f),label:"Activity",description:"Events this week",to:Ve(a,"activity")}),(0,e.jsx)(Gt,{icon:cr,value:$s($),label:"Runs",description:`${$s(C)} failed in the last 2 days`,to:Ve(a,"runs")}),(0,e.jsx)(Gt,{icon:lr,value:Ks(T),label:"Costs",description:"Month to date",to:Ve(a,"costs")}),(0,e.jsx)(Gt,{icon:Sa,value:D===null?"–":`${D}%`,label:"Budget used",description:D===null?"No monthly budget set":`of ${Ks(R)} this month`,to:Ve(a,"budgets")}),(0,e.jsx)(Kt,{title:"Profile",className:"min-h-(--agent-detail-tile-min-h) sm:col-span-2","aria-label":"Profile",meta:(0,e.jsx)("span",{className:y?"text-destructive":void 0,children:y?"Could not load creator":m?`Created by ${m} · ${et(t.createdAt)}`:`Created ${et(t.createdAt)}`}),children:(0,e.jsxs)("div",{className:"flex flex-col pb-3",children:[(0,e.jsx)(Gl,{agent:t},t.id),i.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 px-(--agent-detail-module-inset) py-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Direct reports:"}),(0,e.jsx)(Ul,{reports:i})]})]})}),(0,e.jsx)(Kt,{title:"Skills",meta:(0,e.jsxs)("span",{children:[o.length," enabled"]}),className:"min-h-(--agent-detail-tile-min-h) sm:col-span-2","aria-label":"Skills",children:(0,e.jsxs)("div",{className:"flex flex-wrap gap-1.5 px-(--agent-detail-module-inset) pt-1 pb-(--agent-detail-module-inset)",children:[o.map(F=>(0,e.jsx)(is,{className:"h-7 px-2",children:F},F)),(0,e.jsxs)(ce,{to:Ve(a,"skills"),className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-dashed border-border px-2 py-1 text-sm text-muted-foreground no-underline transition-colors hover:bg-accent hover:text-foreground",children:["Explore skills ",(0,e.jsx)(or,{className:"size-3.5","aria-hidden":!0})]})]})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3","aria-label":"Recent tasks",children:[(0,e.jsx)(Tl,{title:"Recent tasks",action:(0,e.jsx)(ce,{to:`/issues?participantAgentId=${t.id}`,className:"text-xs text-muted-foreground no-underline transition-colors hover:text-foreground",children:"See all tasks"})}),r.length===0?(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Start with a suggested task"}),(0,e.jsx)("ul",{className:"overflow-hidden rounded-lg border border-border bg-(--agent-detail-tile) divide-y divide-dashed divide-border","aria-label":"Suggested tasks",children:l.map(F=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",className:"flex w-full items-center gap-3 px-4 py-4 text-left text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:n(()=>d({title:F,assigneeAgentId:t.id}),"onClick"),children:[(0,e.jsx)(en,{className:"size-4 shrink-0","aria-hidden":!0}),(0,e.jsx)("span",{className:"min-w-0 flex-1",children:F}),(0,e.jsx)(st,{className:"size-4 shrink-0","aria-hidden":!0})]})},F))})]}):(0,e.jsx)("div",{className:"overflow-hidden rounded-lg border border-border bg-(--agent-detail-tile)",children:(0,e.jsx)(so,{issues:r.slice(0,5)})})]})]})}n(mc,"AgentOverview");function xc({agent:t,companyId:s}){const r=Be(),i=Lt(),{data:o}=U({queryKey:v.agents.configRevisions(t.id),queryFn:n(()=>W.listConfigRevisions(t.id,s),"queryFn")}),a=te({mutationFn:n(d=>W.rollbackConfigRevision(t.id,d,s),"mutationFn"),onSuccess:n(d=>{r.invalidateQueries({queryKey:v.agents.detail(t.id)}),r.invalidateQueries({queryKey:v.agents.configRevisions(t.id)}),Ns(r,i,t,d,"revisions")||r.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})},"onSuccess")});return(0,e.jsxs)("div",{className:"max-w-3xl space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Configuration Revisions"}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[o?.length??0," total"]})]}),(o??[]).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No configuration revisions yet."}):(0,e.jsx)("div",{className:"space-y-2",children:(o??[]).map(d=>(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-mono",children:d.id.slice(0,8)}),(0,e.jsx)("span",{className:"mx-1",children:"·"}),(0,e.jsx)("span",{children:et(d.createdAt)}),(0,e.jsx)("span",{className:"mx-1",children:"·"}),(0,e.jsx)("span",{children:d.source})]}),(0,e.jsx)(M,{size:"sm",variant:"outline",onClick:n(()=>a.mutate(d.id),"onClick"),disabled:a.isPending,children:"Restore"})]}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Changed: ",d.changedKeys.length>0?d.changedKeys.join(", "):"no tracked changes"]})]},d.id))})]})}n(xc,"AgentRevisionsTab");function qs({agent:t,companyId:s,onDirtyChange:r,onSaveActionChange:i,onCancelActionChange:o,onSavingChange:a,onSaved:d,updatePermissions:l,hidePromptTemplate:c,hideInstructionsFile:x,content:m="runtime",canConfigureProviderTrace:y=!1}){const S=Be(),j=Lt(),{tab:p}=gs(),{pushToast:h}=sn(),[f,$]=(0,u.useState)(!1),C=(0,u.useRef)(t),R=t.adapterType==="paperclip_runner"?String(t.adapterConfig.provider??"codex"):void 0,{data:T}=U({queryKey:s?v.agents.adapterModels(s,t.adapterType,null,R):["agents","none","adapter-models",t.adapterType],queryFn:n(()=>W.adapterModels(s,t.adapterType,{provider:R}),"queryFn"),enabled:!!s&&m==="runtime"&&!["openai_dot","grok_bot","muse"].includes(R??"")}),D=zi(t.permissions)==="low_trust_review",{data:F,isLoading:se}=U({...gr(s??""),enabled:!!(s&&D)&&m==="permissions"}),{data:ee,isLoading:ae}=U({queryKey:s?[...v.issues.list(s),"low-trust-boundary-candidates"]:["issues","__low-trust-disabled"],queryFn:n(()=>gt.list(s,{limit:100,sortField:"updated",sortDir:"desc"}),"queryFn"),enabled:!!(s&&D)&&m==="permissions"}),O=te({mutationFn:n(({target:z,patch:q})=>W.update(z.id,q,z.companyId),"mutationFn"),onMutate:n(()=>{$(!0)},"onMutate"),onSuccess:n((z,{target:q})=>{C.current.id===q.id&&d?.(),S.invalidateQueries({queryKey:v.agents.detail(q.id)}),S.invalidateQueries({queryKey:v.agents.configRevisions(q.id)}),S.invalidateQueries({queryKey:v.agents.list(q.companyId)}),(C.current.id!==q.id||!Ns(S,j,q,z,p??m))&&S.invalidateQueries({queryKey:v.agents.detail(q.urlKey)}),h({title:"Agent saved",tone:z.configurationWarnings?.length?"warn":"success",body:z.configurationWarnings?.map(pe=>pe.message).join(`
|
|
39
39
|
`)})},"onSuccess"),onError:n(z=>{$(!1);const q=z instanceof nn||z instanceof Error?z.message:"Could not save agent";h({title:"Save failed",body:q,tone:"error"})},"onError")});(0,u.useEffect)(()=>{f&&t!==C.current&&$(!1),C.current=t},[t,f]);const me=m!=="permissions"&&(O.isPending||f);(0,u.useEffect)(()=>{a(me)},[a,me]),(0,u.useEffect)(()=>{m==="permissions"&&(r(!1),i(null),o(null))},[m,o,r,i]);const le=!!t.permissions?.canCreateAgents,ne=t.permissions?.canCreateSkills!==!1,X=!!t.access?.canAssignTasks,b=t.access?.taskAssignSource??"none",L=t.role==="ceo"||le,K=b==="ceo_role"?"Enabled automatically for CEO agents.":b==="agent_creator"?"Enabled automatically while this agent can create new agents.":b==="explicit_grant"?"Enabled via explicit organization permission grant.":b==="simple_default"?"Enabled by simple organization-wide task assignment defaults.":"Disabled unless explicitly granted.";return(0,e.jsxs)("div",{className:w("agent-settings-form",m==="permissions"?"flex flex-col gap-(--agent-detail-module-gap)":"space-y-6"),children:[m!=="permissions"?(0,e.jsx)(yi,{mode:"edit",agent:t,onSave:n(z=>O.mutateAsync({target:t,patch:z}),"onSave"),isSaving:me,adapterModels:T,onDirtyChange:r,onSaveActionChange:i,onCancelActionChange:o,hideInlineSave:!0,hidePromptTemplate:c,hideInstructionsFile:x,content:m==="runtime"?"configuration":"secrets",sectionLayout:"panels",environmentVariablesPlacement:m==="secrets"?"secrets":"configuration",compactTestFeedback:!0,sectionOrder:["adapter","configuration","environment","environment-variables"],hiddenSections:["identity","run-policy"],sectionTitles:{adapter:"",configuration:"",environment:""},canConfigureProviderTrace:y}):null,m==="permissions"?(0,e.jsx)(ao,{layout:"cards",aside:s?(0,e.jsx)($l,{agentId:t.id,companyId:s}):null,projectAccessEditor:(0,e.jsx)(sl,{agent:t}),permissions:t.permissions,disabled:l.isPending,companyId:s,projectCandidates:(F??[]).map(z=>({id:z.id,label:z.name})),issueCandidates:(ee??[]).map(z=>({id:z.id,label:`${z.identifier??z.id.slice(0,8)} · ${z.title}`})),candidatesLoading:se||ae,onChange:n(z=>l.mutate({canCreateAgents:le,canCreateSkills:ne,canAssignTasks:X,...Di(z,z.trustPreset==="low_trust_review"?"low_trust_review":"standard")}),"onChange")}):null,m==="permissions"?(0,e.jsx)(Kt,{title:"Capabilities","aria-label":"Capabilities",children:(0,e.jsxs)("div",{className:"flex flex-col pb-3",children:[(0,e.jsxs)("div",{className:"flex min-h-11 items-center justify-between gap-4 px-(--agent-detail-module-inset) py-2 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{children:"Can create new agents"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Lets this agent create or hire agents. This also grants task assignment authority."})]}),(0,e.jsx)(Zt,{checked:le,onCheckedChange:n(()=>l.mutate({canCreateAgents:!le,canCreateSkills:ne,canAssignTasks:le?X:!0}),"onCheckedChange"),disabled:l.isPending})]}),(0,e.jsxs)("div",{className:"flex min-h-11 items-center justify-between gap-4 px-(--agent-detail-module-inset) py-2 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{children:"Can create/import skills"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Lets this agent install, import, create, and scan organization skills without creating agents."})]}),(0,e.jsx)(Zt,{checked:ne,onCheckedChange:n(()=>l.mutate({canCreateAgents:le,canCreateSkills:!ne,canAssignTasks:X}),"onCheckedChange"),disabled:l.isPending})]}),(0,e.jsxs)("div",{className:"flex min-h-11 items-center justify-between gap-4 px-(--agent-detail-module-inset) py-2 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{children:"Can assign tasks"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:K})]}),(0,e.jsx)(Zt,{checked:X,onCheckedChange:n(()=>l.mutate({canCreateAgents:le,canCreateSkills:ne,canAssignTasks:!X}),"onCheckedChange"),disabled:l.isPending||L})]})]})}):null]})}n(qs,"ConfigurationTab");function pc({agent:t,companyId:s,onDirtyChange:r,onSaveActionChange:i,onCancelActionChange:o,onSavingChange:a,showSaveNotice:d=!0,onSaved:l}){const c=Be(),{selectedCompanyId:x}=Xs(),{isMobile:m}=Zs(),[y,S]=(0,u.useState)("AGENTS.md"),[j,p]=(0,u.useState)("raw"),[h,f]=(0,u.useState)(!1),[$,C]=(0,u.useState)(null),R=(0,u.useRef)(void 0),T=(0,u.useRef)(void 0),[D,F]=(0,u.useState)(null),[se,ee]=(0,u.useState)(null),ae=(0,u.useRef)(t.id);ae.current=t.id;const[O,me]=(0,u.useState)(null),[le,ne]=(0,u.useState)(null),[X,b]=(0,u.useState)(!1),[L,K]=(0,u.useState)(null),z=(0,u.useRef)(null),[q,pe]=(0,u.useState)(!1),we=(0,u.useRef)(!1),[Me,I]=(0,u.useState)(!1),[De,_e]=(0,u.useState)(null),Ce=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(Ce.current),[]),(0,u.useEffect)(()=>{clearTimeout(Ce.current),_e(null)},[t.id,y]);const[xe,_]=(0,u.useState)([]),[ue,N]=(0,u.useState)(new Set),[V,A]=(0,u.useState)(260),[Z,be]=(0,u.useState)(null),Ne=(0,u.useRef)(null),[Re,ve]=(0,u.useState)(!1),Se=(0,u.useRef)(null),Pe=(0,u.useRef)(null),ge=(0,u.useRef)(!1);(0,u.useCallback)(()=>{ge.current=!0},[]);const ke=(0,u.useCallback)(g=>{ge.current=!1,R.current=void 0,T.current=void 0,F(null),S(g)},[]);(0,u.useEffect)(()=>{ge.current=!1,ke("AGENTS.md"),p("raw"),f(!1),C(null),ee(null),me(null),ne(null),b(!1),K(null),_([]),N(new Set),ve(!1),Se.current=null,Pe.current=null},[t.id]);const je=Zi()(t.adapterType).supportsInstructionsBundle,{data:Y,isLoading:ct}=U({queryKey:v.agents.instructionsBundle(t.id),queryFn:n(()=>W.instructionsBundle(t.id,s),"queryFn"),enabled:!!(s&&je),refetchInterval:$===null?5e3:!1}),Le=Y?.mode??"managed",qe=Le==="managed"?Y?.managedRootPath??Y?.rootPath??"":Y?.rootPath??"",he=O?.mode??Le,ie=O?.entryFile??Y?.entryFile??"AGENTS.md",nt=O?.rootPath??qe,ut=(0,u.useMemo)(()=>Y?.files.map(g=>g.path)??[],[Y]),rt=!!(Y&&he===Le&&ie===Y.entryFile&&nt===qe),Ke=(0,u.useMemo)(()=>rt?[...new Set([ie,...ut,...xe])]:[ie,...xe],[rt,ie,ut,xe]),wt=(0,u.useMemo)(()=>Ta(Object.fromEntries(Ke.map(g=>[g,""]))),[Ke]),Q=y||ie,at=le??Q,E=at.replace(/\.md$/i,""),P=le===null?Q:Wl(le.replace(/\.md$/i,"")),J=P!==Q&&Ke.some(g=>g.toLowerCase()===P?.toLowerCase()),de=!P||J;(0,u.useEffect)(()=>{X&&z.current?.focus()},[X]);const re=rt&&ut.includes(Q),ye=Y?.files.find(g=>g.path===Q)??null,{data:G,isLoading:Ee,error:Te}=U({queryKey:v.agents.instructionsFile(t.id,Q),queryFn:n(()=>W.instructionsFile(t.id,Q,s),"queryFn"),enabled:!!(s&&je&&re),refetchInterval:$===null?5e3:!1}),He=U({queryKey:v.agents.instructionCandidates(t.id),queryFn:n(()=>W.instructionCandidates(t.id,s),"queryFn"),enabled:!!(s&&je&&he==="managed")}),Ae=He.data?.filter(g=>g.contract!=="agent_files")??[],Ge=te({mutationFn:n(async g=>{if(g.content===null)throw new Error("These instruction edits have not been retrieved yet.");return{candidate:g,file:await W.instructionsFile(t.id,g.entryFile,s).catch(H=>{if(H instanceof nn&&H.status===404&&g.baseRevisionId===null)return null;throw H}),agentId:t.id}},"mutationFn"),onSuccess:n(({candidate:g,file:H,agentId:oe})=>{ae.current===oe&&(ke(g.entryFile),H&&c.setQueryData(v.agents.instructionsFile(t.id,g.entryFile),H),R.current=H?.revision?.id??null,F(g.runId),C(g.content),p("edit"))},"onSuccess")}),Ie=te({mutationFn:n(async g=>({file:await W.resolveInstructionCandidate(t.id,g.runId,{content:g.content,baseRevisionId:g.baseRevisionId},s),agentId:t.id}),"mutationFn"),onSuccess:n(({file:g,agentId:H})=>{ae.current===H&&(C(null),F(null),R.current=void 0,T.current=void 0,c.setQueryData(v.agents.instructionsFile(t.id,g.path),g),c.invalidateQueries({queryKey:v.agents.instructionsBundle(t.id)}),c.invalidateQueries({queryKey:v.agents.instructionCandidates(t.id)}))},"onSuccess")}),Qe=te({mutationFn:n(async()=>({file:await W.instructionsFile(t.id,Q,s),agentId:t.id,runId:D}),"mutationFn"),onSuccess:n(({file:g,agentId:H,runId:oe})=>{ae.current!==H||D!==oe||(R.current=g.revision?.id??null,c.setQueryData(v.agents.instructionsFile(t.id,g.path),g),Ie.reset())},"onSuccess")}),Ye=te({mutationFn:n(g=>W.updateInstructionsBundle(t.id,g,s),"mutationFn"),onMutate:n(()=>{ge.current=!1},"onMutate"),onSuccess:n(()=>{ve(!0),c.invalidateQueries({queryKey:v.agents.instructionsBundle(t.id)}),c.invalidateQueries({queryKey:v.agents.detail(t.id)}),c.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})},"onSuccess"),onError:n(()=>ve(!1),"onError")}),xt=te({mutationFn:n(g=>W.saveInstructionsFile(t.id,g,s),"mutationFn"),onMutate:n(()=>{ge.current=!1},"onMutate"),onSuccess:n((g,H)=>{C(null),R.current=void 0,T.current=void 0,c.setQueryData(v.agents.instructionsFile(t.id,H.path),g),c.setQueryData(v.agents.instructionsBundle(t.id),oe=>oe&&{...oe,files:[...oe.files.filter($e=>$e.path!==g.path),{path:g.path,size:g.size,language:g.language,markdown:g.markdown,isEntryFile:g.isEntryFile,editable:g.editable,deprecated:g.deprecated,virtual:g.virtual,binary:g.binary,contentHash:g.contentHash,createdAt:g.createdAt,updatedAt:g.updatedAt}]}),_(oe=>oe.filter($e=>$e!==H.path)),c.invalidateQueries({queryKey:v.agents.instructionsBundle(t.id)}),c.invalidateQueries({queryKey:v.agents.instructionsFile(t.id,H.path)}),c.invalidateQueries({queryKey:v.agents.detail(t.id)}),c.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})},"onSuccess"),onError:n(()=>ve(!1),"onError")}),kt=te({mutationFn:n(g=>W.deleteInstructionsFile(t.id,g,s,Y?.files.find(H=>H.path===g)?.contentHash),"mutationFn"),onMutate:n(()=>{ge.current=!1,ve(!0)},"onMutate"),onSuccess:n((g,H)=>{c.invalidateQueries({queryKey:v.agents.instructionsBundle(t.id)}),c.removeQueries({queryKey:v.agents.instructionsFile(t.id,H)}),c.invalidateQueries({queryKey:v.agents.detail(t.id)}),c.invalidateQueries({queryKey:v.agents.detail(t.urlKey)})},"onSuccess"),onError:n(()=>ve(!1),"onError")});te({mutationFn:n(async({file:g,namespace:H})=>{if(!x)throw new Error("Select an organization to upload images");return Na.uploadImage(x,g,H)},"mutationFn")}),(0,u.useEffect)(()=>{if(!Y)return;if(!rt){y!==ie&&ke(ie);return}const g=Y.files.map(H=>H.path);if(!xe.includes(y)){if(g.length===0){y!==Y.entryFile&&ke(Y.entryFile);return}!g.includes(y)&&y!==ie&&!xe.includes(y)&&ke(g.includes(Y.entryFile)?Y.entryFile:g[0])}},[Y,rt,ie,xe,y]),(0,u.useEffect)(()=>{const g=new Set;for(const H of Ke){const oe=H.split("/");let $e="";for(let ze=0;ze<oe.length-1;ze++)$e=$e?`${$e}/${oe[ze]}`:oe[ze],g.add($e)}N(H=>lc(H,g)?H:g)},[Ke]),(0,u.useEffect)(()=>{if(m){be(null);return}const g=Ne.current;if(!g||(n(()=>be(g.getBoundingClientRect().width),"updateWidth")(),typeof ResizeObserver>"u"))return;const oe=new ResizeObserver($e=>{const ze=$e[0];ze&&be(ze.contentRect.width)});return oe.observe(g),()=>oe.disconnect()},[ct,m,Ke.length]),(0,u.useEffect)(()=>{const g=re&&G?`${G.path}:${G.content}`:`draft:${he}:${nt}:${Q}`;if(Re){ve(!1),me(null),C(null),Se.current=g;return}Se.current!==g&&(R.current===void 0&&C(null),Se.current=g)},[Re,he,nt,G,re,Q]),(0,u.useEffect)(()=>{Y&&me(g=>g||{mode:Le,rootPath:qe,entryFile:Y.entryFile})},[Y,Le,qe]),(0,u.useEffect)(()=>{!Y||he!=="external"||(Pe.current={rootPath:nt,entryFile:ie,selectedFile:Q})},[Y,ie,he,nt,Q]);const St=re?G?.content??"":"",We=$??St;nc({selectedFileExists:re,selectedPath:Q,detail:G,summary:ye});const Ct=!!(O&&(O.mode!==Le||O.rootPath!==qe||O.entryFile!==(Y?.entryFile??"AGENTS.md"))),k=le!==null&&le!==Q||$!==null&&$!==St||xe.includes(Q),B=Ct||k||D!==null,Fe=q||Ye.isPending||xt.isPending||Ie.isPending||Ge.isPending||Qe.isPending||kt.isPending||Re;(0,u.useEffect)(()=>{a(Fe)},[a,Fe]),(0,u.useEffect)(()=>{r(B)},[r,B]),(0,u.useEffect)(()=>()=>{i(null),o(null),r(!1),a(!1)},[o,r,i,a]),(0,u.useEffect)(()=>{i(B?()=>{if(we.current)return;n(async()=>{if(de){K(J?"A file with this name already exists.":"Use letters, numbers, hyphens or underscores."),b(!0);return}K(null);const H=!!Y?.legacyPromptTemplateActive||!!Y?.legacyBootstrapPromptTemplateActive;if(Ct&&O&&await Ye.mutateAsync({mode:O.mode,rootPath:O.mode==="external"?O.rootPath:null,entryFile:O.entryFile}),D)await Ie.mutateAsync({runId:D,content:We,baseRevisionId:R.current??null});else if(k&&P&&P!==Q){we.current=!0,pe(!0);const oe=await W.instructionsBundle(t.id,s),$e=T.current??G?.contentHash;if(re&&!$e)throw new Error("Reload this file before renaming; your draft is retained.");const ze=re||Q===ie?await W.renameInstructionsFile(t.id,{path:Q,renameTo:P,content:We,baseHash:re?$e:null},s):await W.saveInstructionsFile(t.id,{path:P,content:We,baseHash:null},s);c.setQueryData(v.agents.instructionsFile(t.id,P),ze),c.setQueryData(v.agents.instructionsBundle(t.id),{...oe,entryFile:Q===ie?P:oe.entryFile,files:[...oe.files.filter(ws=>ws.path!==Q),ze]}),me(null),_([]),C(null),ne(null),ke(P),c.invalidateQueries({queryKey:v.agents.instructionsBundle(t.id)}),c.invalidateQueries({queryKey:v.agents.detail(t.id)})}else k&&await xt.mutateAsync({path:Q,content:We,...Y?.persistence==="agent_files"?{baseHash:T.current!==void 0?T.current:G?.contentHash??null}:{},...Q===ie&&he==="managed"?{baseRevisionId:R.current!==void 0?R.current:G?.revision?.id??null}:{},clearLegacyPromptTemplate:H});l?.()},"save")().catch(H=>K(H instanceof Error?H.message:"Could not save the file. Your unsaved edits are retained.")).finally(()=>{we.current=!1,pe(!1)})}:null)},[Y,Ct,O,D,Ie,We,k,B,i,l,G?.revision?.id,ie,he,xt,Q,P,de,J,re,St,G?.contentHash,t.id,s,c,Ye]),(0,u.useEffect)(()=>{o(B?()=>{R.current=void 0,T.current=void 0,F(null),Ie.reset(),C(null),_([]),ne(null),b(!1),K(null),xe.includes(Q)&&ke(ie),Y&&me({mode:Le,rootPath:qe,entryFile:Y.entryFile})}:null)},[Y,B,o,Le,qe,Ie,xe,Q,ie,ke]);const it=(0,u.useCallback)(g=>{g.preventDefault();const H=g.clientX,oe=V,$e=n(ws=>{const $r=ws.clientX-H,Pr=Math.max(180,Math.min(500,oe+$r));A(Pr)},"onMouseMove"),ze=n(()=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",ze),document.body.style.cursor="",document.body.style.userSelect=""},"onMouseUp");document.addEventListener("mousemove",$e),document.addEventListener("mouseup",ze),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[V]),ht=!m&&Z!==null&&Z>=V+520;return je?ct&&!Y?(0,e.jsx)(fc,{}):(0,e.jsxs)("div",{className:"space-y-6",children:[(Y?.warnings??[]).length>0&&(0,e.jsx)("div",{className:"space-y-2",children:(Y?.warnings??[]).map(g=>(0,e.jsx)("div",{className:"rounded-md border border-sky-500/25 bg-sky-500/10 px-3 py-2 text-xs text-sky-900 dark:text-sky-100",children:g},g))}),d&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Saved instructions affect the next run. Active runs keep the instructions they started with, and instruction changes may start a fresh adapter session."}),(0,e.jsx)(Ll,{agentId:t.id,agentUrlKey:t.urlKey,companyId:s,mode:Le,rootPath:qe,entryFile:Y?.entryFile??"AGENTS.md",blocked:B,onSwitched:n(()=>me(null),"onSwitched")}),(0,e.jsxs)("div",{ref:Ne,className:"grid min-w-0 agent-instruction-panels",style:ht?{gridTemplateColumns:`${V}px var(--agent-identity-resizer-width) minmax(0, 1fr)`}:void 0,children:[(0,e.jsxs)("div",{"data-agent-tile":"",className:w("min-w-0 w-full space-y-3 self-start rounded-lg bg-(--agent-detail-tile) p-(--agent-identity-panel-gap)",m&&h&&"block",m&&!h&&"hidden"),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("h4",{className:"text-sm font-semibold text-foreground",children:"Files"}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(M,{type:"button",size:"icon-xs",variant:"ghost","aria-label":"Add agent file",disabled:Fe,onClick:n(()=>{if(B&&!window.confirm("Discard unsaved agent configuration changes?"))return;let g="Untitled.md",H=2;for(;ut.some(oe=>oe.toLowerCase()===g.toLowerCase());)g=`Untitled-${H++}.md`;_([g]),ke(g),R.current=null,T.current=null,C(""),ne(null),K(null),b(!0),p("edit"),f(!1)},"onClick"),children:(0,e.jsx)(rn,{className:"size-4"})}),m&&(0,e.jsx)(M,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7",onClick:n(()=>f(!1),"onClick"),children:"✕"})]})]}),(0,e.jsx)(Ra,{nodes:wt.map(n(function g(H){return{...H,name:H.path===Q?at.split("/").pop():H.name,children:H.children.map(g)}},"labelDraft")),selectedFile:Q,expandedDirs:ue,checkedFiles:new Set,onToggleDir:n(g=>N(H=>{const oe=new Set(H);return oe.has(g)?oe.delete(g):oe.add(g),oe}),"onToggleDir"),onSelectFile:n(g=>{g!==Q&&(B&&!window.confirm("Discard unsaved agent configuration changes?")||(C(null),_([]),ne(null),b(!1),K(null),ke(g),p("raw"),ut.includes(g)||C(""),m&&f(!1)))},"onSelectFile"),onToggleCheck:n(()=>{},"onToggleCheck"),showCheckboxes:!1,wrapLabels:!1,fileRowClassName:n(g=>w("agent-instruction-file-row font-mono",xe.includes(g.path)&&"agent-instruction-file-pending italic text-muted-foreground/60"),"fileRowClassName"),renderFileExtra:n(g=>{const H=Y?.files.find(oe=>oe.path===g.path);return H?H.deprecated?(0,e.jsxs)(ss,{children:[(0,e.jsx)(ns,{asChild:!0,children:(0,e.jsx)("span",{className:"ml-3 shrink-0 rounded border border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200 px-1.5 py-0.5 text-(length:--text-nano) uppercase tracking-wide cursor-help",children:"virtual file"})}),(0,e.jsx)(rs,{side:"right",sideOffset:4,children:"Legacy inline prompt — this deprecated virtual file preserves the old promptTemplate content"})]}):(0,e.jsx)("span",{className:w("ml-3 shrink-0 rounded text-muted-foreground px-1.5 py-0.5 font-sans text-(length:--text-nano) uppercase tracking-wide",H.isEntryFile&&"bg-(--agent-detail-tile-chip)"),children:H.isEntryFile?"ROOT":`${H.size}b`}):null},"renderFileExtra")})]}),ht&&(0,e.jsx)("div",{className:"w-1 cursor-col-resize rounded transition-colors hover:bg-border active:bg-primary/50",onMouseDown:it}),(0,e.jsxs)("div",{"data-agent-tile":"",className:w("min-w-0 w-full overflow-hidden rounded-lg bg-(--agent-detail-tile)",m&&h&&"hidden"),children:[(0,e.jsxs)("div",{className:"agent-identity-preview-header flex items-center justify-between gap-3 px-(--agent-identity-panel-gap) pt-(--agent-identity-panel-gap) pb-5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[m&&(0,e.jsx)(M,{type:"button",size:"icon",variant:"outline",className:"h-7 w-7 shrink-0",onClick:n(()=>f(!0),"onClick"),children:(0,e.jsx)(rr,{className:"h-3.5 w-3.5"})}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"agent-identity-file-heading flex min-w-0 items-center gap-2",children:[X?(0,e.jsxs)("div",{className:"agent-identity-preview-title flex min-w-0 items-baseline font-mono text-(length:--agent-identity-preview-title-size)",children:[(0,e.jsx)("input",{ref:z,"aria-label":"Markdown file name",autoFocus:!0,value:le===null&&xe.includes(Q)?"":E,placeholder:Q.replace(/\.md$/i,""),"aria-invalid":de||void 0,disabled:Fe,className:"agent-identity-file-name-input min-w-0 bg-transparent text-foreground outline-none placeholder:italic placeholder:text-muted-foreground/50",onChange:n(g=>{ne(`${g.target.value}.md`),K(null)},"onChange"),onBlur:n(()=>{de||b(!1)},"onBlur"),onKeyDown:n(g=>{g.key==="Enter"&&(g.preventDefault(),de||b(!1)),g.key==="Escape"&&(ne(null),b(!1),K(null))},"onKeyDown")}),(0,e.jsx)("span",{className:"text-muted-foreground/50",children:".md"})]}):(0,e.jsx)("button",{type:"button",disabled:Fe||!!D||ye?.deprecated||G?.binary||!Q.endsWith(".md"),"aria-label":`Rename ${at}`,onClick:n(()=>b(!0),"onClick"),className:w("agent-identity-preview-title min-w-0 truncate rounded font-mono text-(length:--agent-identity-preview-title-size) text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",xe.includes(Q)?"italic text-muted-foreground/60":"text-foreground"),children:at}),(0,e.jsx)(is,{children:he==="external"?"Managed externally":"Managed by you"})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:re?ye?.deprecated?"Deprecated virtual file":Hl(G??ye):"New file in this bundle"})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)("span",{role:"status","aria-hidden":!Me,className:w("agent-file-copy-notice flex items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground",!Me&&"opacity-0",De==="error"&&"text-destructive"),children:[De==="copied"&&(0,e.jsx)(fs,{className:"size-3.5","aria-hidden":!0}),De==="copied"?"File copied":De==="error"?"Copy failed":null]}),(0,e.jsx)(M,{type:"button",variant:"ghost",size:"icon-xs",className:w("size-8",j==="edit"&&"bg-(--agent-detail-tile-chip) text-foreground"),"aria-pressed":j==="edit","aria-label":j==="edit"?`Stop editing ${Q}`:`Edit ${Q}`,title:j==="edit"?"Stop editing":"Edit",disabled:!!G?.binary,onClick:n(()=>p(j==="edit"?"raw":"edit"),"onClick"),children:(0,e.jsx)(dr,{className:"size-4"})}),!Ee&&(0,e.jsx)(M,{type:"button",variant:"ghost",size:"icon-xs",className:"size-8","aria-label":"Copy instructions file as markdown",title:"Copy as markdown",onClick:n(async()=>{clearTimeout(Ce.current),I(!0);try{await fr(We),_e("copied")}catch{_e("error")}Ce.current=setTimeout(()=>I(!1),5e3)},"onClick"),children:(0,e.jsx)(Us,{className:"size-4"})}),Q===ie&&(0,e.jsxs)(ss,{children:[(0,e.jsx)(ns,{asChild:!0,children:(0,e.jsx)("span",{tabIndex:0,"aria-label":"This file is required",className:"inline-flex",children:(0,e.jsx)(M,{type:"button",variant:"ghost",size:"icon-xs",className:"size-8","aria-label":`Delete ${Q}`,disabled:!0,children:(0,e.jsx)(Nn,{className:"size-4"})})})}),(0,e.jsx)(rs,{children:"This file is required"})]}),re&&!ye?.deprecated&&Q!==ie&&(0,e.jsx)(M,{type:"button",size:"icon-xs",variant:"ghost",className:"size-8","aria-label":`Delete ${Q}`,title:"Delete file",onClick:n(()=>{confirm(`Delete ${Q}?`)&&kt.mutate(Q,{onSuccess:n(()=>{ke(ie),C(null)},"onSuccess")})},"onClick"),disabled:kt.isPending,children:(0,e.jsx)(Nn,{className:"size-4"})})]})]}),(0,e.jsx)("div",{"aria-hidden":!0,className:"h-px"}),(0,e.jsxs)("div",{className:"space-y-3 px-(--agent-identity-panel-gap) pt-4 empty:hidden",children:[he==="managed"&&Ae.length>0&&(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Preserved instruction edits"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Older instruction-only sessions have edits to review."}),Ae.map(g=>(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:g.runId.slice(0,8)}),(0,e.jsxs)("span",{className:"text-sm text-muted-foreground",children:[g.entryFile," · ",et(g.createdAt)]}),(0,e.jsx)(M,{type:"button",variant:"outline",size:"sm",disabled:g.content===null||g.entryFile===ie&&(B||Fe),"aria-expanded":g.entryFile!==ie?se===g.runId:void 0,onClick:n(()=>{g.entryFile!==ie?ee(H=>H===g.runId?null:g.runId):Ge.mutate(g)},"onClick"),children:"Review preserved edits"}),g.errorMessage&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:g.errorMessage}),g.entryFile!==ie&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"The instruction entry changed. These edits remain preserved for the original file."}),g.entryFile!==ie&&g.content!==null&&se===g.runId&&(0,e.jsxs)("div",{role:"region","aria-label":`Preserved edits for ${g.entryFile}`,className:"w-full space-y-3",children:[(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Read only: ",g.entryFile,". To keep any of these edits in ",ie,", copy them and edit the current entry explicitly."]}),(0,e.jsxs)(Ds,{text:g.content,ariaLabel:`Copy preserved edits for ${g.entryFile}`,className:"inline-flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:[(0,e.jsx)(Us,{className:"h-3.5 w-3.5"}),"Copy preserved edits"]}),(0,e.jsx)("pre",{className:w("overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-3 font-mono text-sm","ph-mask ph-sensitive"),children:g.content})]})]},g.runId))]}),D&&(0,e.jsxs)("div",{role:"status",className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Reviewing preserved edits. Save to apply your resolved draft and close this preserved edit."}),(0,e.jsxs)("details",{children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Compare current instructions"}),(0,e.jsx)("pre",{className:w("whitespace-pre-wrap break-words rounded-md border border-border p-3 font-mono text-sm","ph-mask ph-sensitive"),children:St})]}),R.current!==(G?.revision?.id??null)&&(0,e.jsx)("p",{className:"text-sm text-destructive",children:"The current instructions changed after this draft was loaded. Refresh the current revision, compare the instructions, and save your resolved draft again."}),(Ie.error||R.current!==(G?.revision?.id??null))&&(0,e.jsx)(M,{type:"button",variant:"outline",size:"sm",disabled:Fe,onClick:n(()=>Qe.mutate(),"onClick"),children:"Refresh current revision"})]}),(He.error||Ge.error||Ie.error||Qe.error)&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[(He.error??Ge.error??Ie.error??Qe.error)?.message," Your preserved edits remain available."]}),(L||X&&de)&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:L??(J?"A file with this name already exists.":"Use letters, numbers, hyphens or underscores.")}),(xt.error||Te||Ye.error)&&(0,e.jsxs)("p",{role:"alert",className:"text-sm text-destructive",children:[(xt.error??Te??Ye.error)?.message," Your unsaved edits are retained."]}),G?.receipt?.materialization==="pending"&&(0,e.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Revision saved. The instruction file still needs to be rebuilt from the saved revision."}),G?.revision&&he==="managed"&&Y?.persistence!=="agent_files"&&(0,e.jsx)(Co,{agentId:t.id,companyId:s,path:Q,currentRevisionId:G.revision.id,disabled:B||Fe,onRestored:n(g=>{C(null),R.current=void 0,T.current=void 0,c.setQueryData(v.agents.instructionsFile(t.id,Q),g),c.invalidateQueries({queryKey:v.agents.instructionsBundle(t.id)})},"onRestored")},Q)]}),G?.binary?(0,e.jsxs)("div",{className:"space-y-3 px-(--agent-identity-panel-gap) py-5",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"This file is preserved with the agent directory. Download it to view its contents."}),(0,e.jsxs)("a",{className:"text-sm text-primary underline",href:W.downloadInstructionsFile(t.id,Q,s),download:!0,children:["Download ",Q]})]}):re&&Ee&&!G?(0,e.jsx)("div",{className:"px-(--agent-identity-panel-gap) py-5",children:(0,e.jsx)(Fr,{})}):j==="edit"?(0,e.jsx)("textarea",{"aria-label":"Instruction file editor",autoFocus:!X,value:We,spellCheck:!1,onChange:n(g=>{R.current===void 0&&(R.current=G?.revision?.id??null),T.current===void 0&&(T.current=G?.contentHash??null),C(g.target.value)},"onChange"),className:"block min-h-(--sz-420px) w-full field-sizing-content resize-none bg-transparent p-(--agent-identity-panel-gap) font-mono text-xs leading-5 whitespace-pre-wrap text-foreground outline-none",placeholder:"File contents"}):(0,e.jsx)("div",{role:"button",tabIndex:0,"aria-label":`Edit ${Q} contents`,className:"cursor-text outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:n(()=>p("edit"),"onClick"),onKeyDown:n(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),p("edit"))},"onKeyDown"),children:We.trim()?(0,e.jsx)("pre",{"data-testid":"instructions-raw-source",className:w("block min-h-(--sz-420px) w-full overflow-x-auto p-(--agent-identity-panel-gap) font-mono text-xs leading-5 whitespace-pre-wrap break-words text-muted-foreground",Xe),children:We}):(0,e.jsx)("p",{className:"min-h-(--sz-420px) p-(--agent-identity-panel-gap) text-sm text-muted-foreground",children:"This instruction file is empty."})})]})]})]}):(0,e.jsx)("div",{className:"max-w-3xl",children:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Instructions bundles are only available for local adapters."})})}n(pc,"PromptsTab");function fc(){return(0,e.jsxs)("div",{className:"max-w-5xl space-y-4",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Oe,{className:"h-4 w-40"}),(0,e.jsx)(Oe,{className:"h-4 w-(--sz-30rem) max-w-full"})]}),(0,e.jsx)(Oe,{className:"h-4 w-16"})]}),(0,e.jsx)("div",{className:"grid gap-3 md:grid-cols-3",children:Array.from({length:3}).map((t,s)=>(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Oe,{className:"h-3 w-20"}),(0,e.jsx)(Oe,{className:"h-10 w-full"})]},s))})]}),(0,e.jsxs)("div",{className:"grid gap-4 lg:grid-cols-(--gtc-19)",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(Oe,{className:"h-4 w-12"}),(0,e.jsx)(Oe,{className:"h-8 w-16"})]}),(0,e.jsx)(Oe,{className:"h-10 w-full"}),(0,e.jsx)("div",{className:"space-y-2",children:Array.from({length:5}).map((t,s)=>(0,e.jsx)(Oe,{className:"h-9 w-full rounded-none"},s))})]}),(0,e.jsxs)("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Oe,{className:"h-4 w-48"}),(0,e.jsx)(Oe,{className:"h-3 w-28"})]}),(0,e.jsx)(Fr,{})]})]})]})}n(fc,"PromptsTabSkeleton");function Fr(){return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(Oe,{className:"h-10 w-full"}),(0,e.jsx)(Oe,{className:"h-(--sz-420px) w-full"})]})}n(Fr,"PromptEditorSkeleton");function Jn({run:t,isSelected:s,agentId:r}){const i=ec[t.status]??{icon:Hs,color:"text-neutral-400"},o=i.icon,a=cn(t),d=t.resultJson?String(t.resultJson.summary??t.resultJson.result??""):t.error??"",l=er(t.resultJson);return(0,e.jsxs)(ce,{to:s?`/agents/${r}/runs`:`/agents/${r}/runs/${t.id}`,className:w("flex flex-col gap-1 w-full px-3 py-2.5 text-left border-b border-border last:border-b-0 transition-colors no-underline text-inherit",s?"bg-accent/40":"hover:bg-accent/20"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(o,{className:w("h-3.5 w-3.5 shrink-0",i.color,t.status==="running"&&"animate-spin")}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:t.id.slice(0,8)}),(0,e.jsx)(Nt,{variant:"ghost",className:w("px-1.5 text-(length:--text-nano)",t.invocationSource==="timer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300":t.invocationSource==="assignment"?"bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300":t.invocationSource==="on_demand"?"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300":"bg-muted text-muted-foreground"),children:rc[t.invocationSource]??t.invocationSource}),l?(0,e.jsx)(sa,{showIcon:!1,className:"shrink-0 text-(length:--text-nano) py-0"}):null,(0,e.jsx)("span",{className:"ml-auto text-(length:--text-micro) text-muted-foreground shrink-0",children:Tt(t.createdAt)})]}),d&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate pl-5.5",children:d.slice(0,60)}),(a.usageUnavailable||(a.totalTokens??0)>0||(a.cost??0)>0)&&(0,e.jsxs)("div",{className:"flex items-center gap-2 pl-5.5 text-(length:--text-micro) text-muted-foreground tabular-nums",children:[a.usageUnavailable&&(0,e.jsx)("span",{children:"Usage and cost unavailable"}),a.totalTokens!==null&&a.totalTokens>0&&(0,e.jsxs)("span",{children:[Ue(a.totalTokens)," tok"]}),a.cost!==null&&a.cost>0&&(0,e.jsxs)("span",{children:["$",a.cost.toFixed(3)]})]})]})}n(Jn,"RunListItem");function hc({runs:t,companyId:s,agentId:r,agentRouteId:i,selectedRunId:o,adapterType:a,adapterConfig:d}){const{isMobile:l}=Zs(),c=[...t].sort((S,j)=>new Date(j.createdAt).getTime()-new Date(S.createdAt).getTime()),x=l?o:o??c[0]?.id??null,m=ko(c,x,s,r),y=m.run;return o&&!y?m.loading?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading run…"}):(0,e.jsxs)("div",{role:"alert",children:[(0,e.jsx)("p",{className:"text-sm text-destructive",children:m.error instanceof Error?m.error.message:"This run is unavailable for this agent."}),m.error&&(0,e.jsx)(M,{variant:"outline",onClick:n(()=>{m.retry()},"onClick"),children:"Try again"})]}):t.length===0&&!y?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No runs yet."}):l?y?(0,e.jsxs)("div",{className:"space-y-3 min-w-0 overflow-x-hidden",children:[(0,e.jsxs)(ce,{to:`/agents/${i}/runs`,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors no-underline",children:[(0,e.jsx)(Pi,{className:"h-3.5 w-3.5"}),"Back to runs"]}),(0,e.jsx)(Zn,{run:y,agentRouteId:i,adapterType:a,adapterConfig:d},y.id)]}):(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-x-hidden",children:c.map(S=>(0,e.jsx)(Jn,{run:S,isSelected:!1,agentId:i},S.id))}):(0,e.jsxs)("div",{className:"flex gap-0",children:[(0,e.jsx)("div",{className:w("shrink-0 border border-border rounded-lg",y?"w-72":"w-full"),children:(0,e.jsx)("div",{className:"sticky top-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 2rem)"},children:c.map(S=>(0,e.jsx)(Jn,{run:S,isSelected:S.id===x,agentId:i},S.id))})}),y&&(0,e.jsx)("div",{className:"flex-1 min-w-0 pl-4",children:(0,e.jsx)(Zn,{run:y,agentRouteId:i,adapterType:a,adapterConfig:d},y.id)})]})}n(hc,"RunsTab");function gc({resultJson:t}){const s=jt(t?.instructionSave),r=fe(s?.storageWarning),i=fe(s?.errorMessage),o=s?.contract==="agent_files"&&s.state==="unavailable"&&i&&(!r||s?.errorCode!=="AGENT_FILES_LIMIT_EXCEEDED");return(0,e.jsxs)(e.Fragment,{children:[r&&(0,e.jsx)(Mt,{tone:"warning",title:"Agent storage warning",compact:!0,children:r}),o&&(0,e.jsx)(Mt,{tone:"warning",title:"Agent file sync failed for this run",compact:!0,children:i})]})}n(gc,"AgentFileRunNotice");function yc({run:t}){const s=cn(t);if(!s.usageUnavailable&&![s.input,s.output,s.cached,s.cost].some(i=>(i??0)>0))return null;const r=[["Input",s.input===null?"Unavailable":Ue(s.input)],["Output",s.output===null?"Unavailable":Ue(s.output)],["Cached",s.cached===null?"Unavailable":Ue(s.cached)],["Cost",s.cost===null?"Unavailable":s.cost>0?`$${s.cost.toFixed(4)}`:"-"]];return(0,e.jsx)("div",{className:"border-t sm:border-t-0 sm:border-l border-border p-4 grid grid-cols-2 gap-x-4 sm:gap-x-8 gap-y-3 content-center tabular-nums",children:r.map(([i,o])=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:i}),(0,e.jsx)("div",{className:"text-sm font-medium font-mono",children:o})]},i))})}n(yc,"RunAccountingMetrics");function Zn({run:t,agentRouteId:s,adapterType:r,adapterConfig:i}){const o=Be(),a=Lt(),{data:d}=U({queryKey:v.runDetail(t.id),queryFn:n(()=>tt.get(t.id),"queryFn"),enabled:!!t.id,refetchInterval:n(A=>dc((A.state.data??t).status),"refetchInterval")}),l=d??t,{data:c}=U({queryKey:v.access.currentBoardAccess,queryFn:n(()=>vt.getCurrentBoardAccess(),"queryFn")}),x=c?.source==="local_implicit"||c?.isInstanceAdmin===!0,{data:m}=U({queryKey:v.instance.experimentalSettings,queryFn:n(()=>us.getExperimental(),"queryFn")}),y=m?.enablePaperclipDeveloperMode===!0,S=x&&ni(r,i),{data:j}=U({queryKey:v.providerTraceMetadata(l.companyId,[l.id]),queryFn:n(()=>tt.providerTraceMetadata(l.companyId,[l.id]),"queryFn"),enabled:x,refetchInterval:l.status==="running"||l.status==="queued"?3e3:!1}),p=j?.[0]??null,h=cn(l),{data:f}=U({queryKey:v.access.companyUserDirectory(l.companyId),queryFn:n(()=>vt.listUserDirectory(l.companyId),"queryFn"),enabled:!!(l.companyId&&l.responsibleUserId)}),$=(0,u.useMemo)(()=>{if(!l.responsibleUserId)return null;const A=f?.users.find(Z=>Z.principalId===l.responsibleUserId);return A?.user?.name??A?.user?.email??null},[l.responsibleUserId,f]),C=Kr(l.errorCode)?l.errorCode:null,[R,T]=(0,u.useState)(!1),[D,F]=(0,u.useState)(!1),[se,ee]=(0,u.useState)(null);(0,u.useEffect)(()=>{ee(null)},[l.id]);const ae=l.driverKind==="grok_bot_mcp",O=te({mutationFn:n(()=>ae?Da.stop(l.companyId,l.agentId,l.id):l.status!=="failed"?tt.cancel(l.id):Ao(t.id,t.companyId),"mutationFn"),onSettled:n(()=>{o.invalidateQueries({queryKey:v.runDetail(l.id)}),o.invalidateQueries({queryKey:v.heartbeats(l.companyId,l.agentId)})},"onSettled")}),me=l.errorCode==="process_lost"&&l.status==="failed",le=(0,u.useMemo)(()=>{const A={resumeFromRunId:l.id},Z=jt(l.contextSnapshot);if(!Z)return A;const be=fe(Z.issueId),Ne=fe(Z.taskId),Re=fe(Z.taskKey),ve=fe(Z.wakeCommentId)??fe(Z.commentId);return be&&(A.issueId=be),Ne&&(A.taskId=Ne),Re&&(A.taskKey=Re),ve&&(A.commentId=ve),A},[l.contextSnapshot,l.id]),ne=te({mutationFn:n(async()=>{const A=await W.wakeup(l.agentId,{source:"on_demand",triggerDetail:"manual",reason:"resume_process_lost_run",payload:le},l.companyId);if(!("id"in A))throw new Error(A.message??"Resume request was skipped.");return A},"mutationFn"),onSuccess:n(A=>{o.invalidateQueries({queryKey:v.heartbeats(l.companyId,l.agentId)}),a(`/agents/${s}/runs/${A.id}`)},"onSuccess")}),X=(l.status==="failed"||l.status==="timed_out")&&l.execution?.phase!=="recovery_needed"&&!l.execution?.successorRunId,b=(0,u.useMemo)(()=>{const A={},Z=jt(l.contextSnapshot);if(!Z)return A;const be=fe(Z.issueId),Ne=fe(Z.taskId),Re=fe(Z.taskKey);return be&&(A.issueId=be),Ne&&(A.taskId=Ne),Re&&(A.taskKey=Re),A},[l.contextSnapshot]),L=te({mutationFn:n(async()=>W.retryFailedRun(l.agentId,l.id,l.companyId),"mutationFn"),onSuccess:n(A=>{o.invalidateQueries({queryKey:v.heartbeats(l.companyId,l.agentId)}),A.runId?a(`/agents/${s}/runs/${A.runId}`):A.issueId&&a(`/issues/${A.issueId}`)},"onSuccess")}),K=te({mutationFn:n(async()=>{const A=await W.wakeup(l.agentId,{source:"on_demand",triggerDetail:"manual",reason:"rerun_with_provider_trace",payload:b,debug:{providerTrace:"raw"}},l.companyId);if(!("id"in A))throw new Error(A.message??"Trace re-run was skipped.");return A},"mutationFn"),onSuccess:n(A=>{F(!1),o.invalidateQueries({queryKey:v.heartbeats(l.companyId,l.agentId)}),a(`/agents/${s}/runs/${A.id}`)},"onSuccess")}),{data:z}=U({queryKey:v.runIssues(l.id),queryFn:n(()=>xr.issuesForRun(l.id),"queryFn")}),q=(0,u.useMemo)(()=>Array.from(new Set((z??[]).map(A=>A.issueId))),[z]),pe=te({mutationFn:n(async()=>q.length===0?0:(await Promise.all(q.map(A=>W.resetSession(l.agentId,A,l.companyId))),q.length),"mutationFn"),onSuccess:n(()=>{o.invalidateQueries({queryKey:v.agents.runtimeState(l.agentId)}),o.invalidateQueries({queryKey:v.agents.taskSessions(l.agentId)}),o.invalidateQueries({queryKey:v.runIssues(l.id)})},"onSuccess")}),we=te({mutationFn:n(()=>W.loginWithClaude(l.agentId,l.companyId),"mutationFn"),onSuccess:n(A=>{ee(A)},"onSuccess")}),Me=l.status==="running"&&!!l.startedAt&&!l.finishedAt,[I,De]=(0,u.useState)(()=>l.startedAt?Math.max(0,Math.round((Date.now()-new Date(l.startedAt).getTime())/1e3)):0);(0,u.useEffect)(()=>{if(!Me||!l.startedAt)return;const A=new Date(l.startedAt).getTime();De(Math.max(0,Math.round((Date.now()-A)/1e3)));const Z=setInterval(()=>{De(Math.max(0,Math.round((Date.now()-A)/1e3)))},1e3);return()=>clearInterval(Z)},[Me,l.startedAt]);const _e={hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},Ce=l.startedAt?new Date(l.startedAt).toLocaleTimeString("en-US",_e):null,xe=l.finishedAt?new Date(l.finishedAt).toLocaleTimeString("en-US",_e):null,_=(l.startedAt&&l.finishedAt?Math.round((new Date(l.finishedAt).getTime()-new Date(l.startedAt).getTime())/1e3):null)??(Me?I:null),ue=!!(l.sessionIdBefore||l.sessionIdAfter),N=l.sessionIdBefore&&l.sessionIdAfter&&l.sessionIdBefore!==l.sessionIdAfter;l.sessionIdAfter||l.sessionIdBefore;const V=l.exitCode!==null&&l.exitCode!==0;return(0,e.jsxs)("div",{className:"space-y-4 min-w-0",children:[(0,e.jsx)(jl,{run:l}),(0,e.jsx)(wo,{context:l.contextSnapshot}),(0,e.jsx)(So,{context:l.contextSnapshot}),ae&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Runs in Grok Bot. Usage not reported. Stopping this session revokes Microvac authority; remote execution may continue. Open the Grok Bot desktop app to inspect it. This view contains Paperclip-reported activity."}),(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row",children:[(0,e.jsxs)("div",{className:"flex-1 p-4 space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsx)(fn,{status:l.status}),(0,e.jsx)(Xr,{trace:p,requested:ia(l.contextSnapshot),showOff:!0}),(l.status==="running"||l.status==="queued"||l.status==="failed"&&l.driverKind!=="grok_bot_mcp"&&l.execution?.canStop===!0)&&(0,e.jsx)(M,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive text-xs h-6 px-2",onClick:n(()=>O.mutate(),"onClick"),disabled:O.isPending,children:Ro({grokWork:ae,isFailed:l.status==="failed",isPending:O.isPending})}),me&&(0,e.jsxs)(M,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n(()=>ne.mutate(),"onClick"),disabled:ne.isPending,children:[(0,e.jsx)(Pt,{className:"h-3.5 w-3.5 mr-1"}),ne.isPending?"Resuming…":"Resume"]}),X&&!me&&(0,e.jsxs)(M,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n(()=>L.mutate(),"onClick"),disabled:L.isPending,children:[(0,e.jsx)(Pt,{className:"h-3.5 w-3.5 mr-1"}),L.isPending?"Retrying…":"Retry"]}),(0,e.jsxs)(M,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n(()=>F(!0),"onClick"),children:[(0,e.jsx)(tr,{className:"h-3.5 w-3.5 mr-1"}),"Inspect run"]}),(0,e.jsx)(Al,{runId:l.id,enabled:y&&x}),S&&!["queued","running"].includes(l.status)?(0,e.jsxs)(M,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:n(()=>K.mutate(),"onClick"),disabled:K.isPending,children:[(0,e.jsx)(Pt,{className:"h-3.5 w-3.5 mr-1"}),K.isPending?"Starting…":"Re-run with provider trace"]}):null]}),(()=>{const A=h.provider??fe(i?.provider),Z=h.model??fe(i?.model);return!r&&!A&&!Z?null:(0,e.jsxs)("div",{className:"text-(length:--text-micro) text-muted-foreground font-mono flex items-center gap-1.5 flex-wrap",children:[r&&(0,e.jsx)("span",{className:"bg-muted rounded px-1.5 py-0.5 text-(length:--text-nano) font-medium uppercase tracking-wide",children:r.replace(/_/g," ")}),A&&Z&&(0,e.jsxs)("span",{children:[A,"/",Z]}),!A&&Z&&(0,e.jsx)("span",{children:Z})]})})(),l.responsibleUserId&&(0,e.jsxs)("div",{"data-testid":"run-detail-on-behalf-of",className:"text-xs text-muted-foreground",children:["On behalf of"," ",(0,e.jsx)("span",{className:w("text-foreground","ph-mask ph-sensitive"),children:$??Br(null)})]}),!!l.identityHistory?.length&&(0,e.jsxs)("details",{className:"text-xs text-muted-foreground","data-testid":"run-identity-history",children:[(0,e.jsx)("summary",{className:"cursor-pointer",children:"GitHub identity history"}),(0,e.jsx)("ol",{className:w("mt-2 space-y-2","ph-mask ph-sensitive"),children:l.identityHistory.map(A=>{const Z=f?.users.find(be=>be.principalId===A.responsibleUserId);return(0,e.jsxs)("li",{children:[(0,e.jsx)("span",{className:"text-foreground",children:Z?.user?.name??Z?.user?.email??A.responsibleUserId??"No responsible person"})," · ",A.cause," · ",A.status,A.github?(0,e.jsxs)("span",{className:"block",children:[A.github.login?`@${A.github.login} · `:"",A.github.source?`${A.github.source} · `:"",A.github.status,A.github.reason?`: ${A.github.reason}`:""]}):(0,e.jsx)("span",{className:"block",children:"No GitHub operation recorded"})]},A.id)})})]}),O.error&&(0,e.jsx)("div",{className:"text-xs text-destructive",role:"alert",children:O.error instanceof Error?O.error.message:"Failed to stop run"}),ne.isError&&(0,e.jsx)("div",{className:"text-xs text-destructive",children:ne.error instanceof Error?ne.error.message:"Failed to resume run"}),L.isError&&(0,e.jsx)("div",{className:"text-xs text-destructive",children:L.error instanceof Error?L.error.message:"Failed to retry run"}),Ce&&(0,e.jsxs)("div",{className:"space-y-0.5",children:[(0,e.jsxs)("div",{className:"text-sm font-mono",children:[Ce,xe&&(0,e.jsx)("span",{className:"text-muted-foreground",children:" → "}),xe]}),(0,e.jsxs)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:[Tt(l.startedAt),l.finishedAt&&(0,e.jsxs)(e.Fragment,{children:[" → ",Tt(l.finishedAt)]})]}),_!==null&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Duration: ",_>=60?`${Math.floor(_/60)}m ${_%60}s`:`${_}s`]})]}),(0,e.jsx)(gc,{resultJson:l.resultJson}),l.errorCode!=="sandbox_disk_full"&&An(l.resultJson?.providerFailure)?(0,e.jsx)(ra,{failure:An(l.resultJson?.providerFailure)}):mn(l)&&(0,e.jsxs)("div",{className:"text-xs",children:[(0,e.jsx)("span",{className:"text-destructive",children:(0,e.jsx)(Ms,{children:mn(l)})}),l.errorCode&&(0,e.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",l.errorCode,")"]})]}),l.errorCode==="claude_auth_required"&&r==="claude_local"&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(M,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:n(()=>we.mutate(),"onClick"),disabled:we.isPending,children:we.isPending?"Running claude login...":"Login to Claude Code"}),we.isError&&(0,e.jsx)("p",{className:"text-xs text-destructive",children:we.error instanceof Error?we.error.message:"Failed to run Claude login"}),se?.loginUrl&&(0,e.jsxs)("p",{className:"text-xs",children:["Login URL:",(0,e.jsx)("a",{href:se.loginUrl,className:"text-blue-600 underline underline-offset-2 ml-1 break-all dark:text-blue-400",target:"_blank",rel:"noreferrer",children:se.loginUrl})]}),se&&(0,e.jsxs)(e.Fragment,{children:[!!se.stdout&&(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-foreground overflow-x-auto whitespace-pre-wrap","ph-mask ph-sensitive"),children:se.stdout}),!!se.stderr&&(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-red-700 dark:text-red-300 overflow-x-auto whitespace-pre-wrap","ph-mask ph-sensitive"),children:se.stderr})]})]}),C&&(0,e.jsx)(Vr,{code:C,userName:$}),V&&(0,e.jsxs)("div",{className:"text-xs text-red-600 dark:text-red-400",children:["Exit code ",l.exitCode,l.signal&&(0,e.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(signal: ",l.signal,")"]})]}),(0,e.jsx)(rl,{run:l,agentRouteId:s})]}),(0,e.jsx)(yc,{run:l})]}),ue&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("button",{className:"flex items-center gap-1.5 w-full px-4 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:n(()=>T(A=>!A),"onClick"),children:[(0,e.jsx)(st,{className:w("h-3 w-3 transition-transform",R&&"rotate-90")}),"Session",N&&(0,e.jsx)("span",{className:"text-yellow-400 ml-1",children:"(changed)"})]}),R&&(0,e.jsxs)("div",{className:"px-4 pb-3 space-y-1 text-xs",children:[l.sessionIdBefore&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground w-12",children:N?"Before":"ID"}),(0,e.jsx)(Ds,{text:l.sessionIdBefore,className:"font-mono"})]}),N&&l.sessionIdAfter&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground w-12",children:"After"}),(0,e.jsx)(Ds,{text:l.sessionIdAfter,className:"font-mono"})]}),q.length>0&&(0,e.jsxs)("div",{className:"pt-1",children:[(0,e.jsx)("button",{type:"button",className:"text-(length:--text-micro) text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-60",disabled:pe.isPending,onClick:n(()=>{const A=q.length;window.confirm(`Clear session for ${A} issue${A===1?"":"s"} touched by this run?`)&&pe.mutate()},"onClick"),children:pe.isPending?"clearing session...":"clear session for these tasks"}),pe.isError&&(0,e.jsx)("p",{className:"text-(length:--text-micro) text-destructive mt-1",children:pe.error instanceof Error?pe.error.message:"Failed to clear sessions"})]})]})]})]}),z&&z.length>0&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground",children:["Tasks Touched (",z.length,")"]}),(0,e.jsx)("div",{className:"border border-border rounded-lg divide-y divide-border",children:z.map(A=>(0,e.jsxs)(ce,{to:`/issues/${A.identifier??A.issueId}`,className:"flex items-center justify-between w-full px-3 py-2 text-xs hover:bg-accent/20 transition-colors text-left no-underline text-inherit",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)(fn,{status:A.status}),(0,e.jsx)("span",{className:"truncate",children:A.title})]}),(0,e.jsx)("span",{className:"font-mono text-muted-foreground shrink-0 ml-2",children:A.identifier??A.issueId.slice(0,8)})]},A.issueId))})]}),l.stderrExcerpt&&(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-red-600 dark:text-red-400",children:"stderr"}),(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-red-700 dark:text-red-300 overflow-x-auto whitespace-pre-wrap","ph-mask ph-sensitive"),children:l.stderrExcerpt})]}),l.stdoutExcerpt&&!l.logRef&&(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"stdout"}),(0,e.jsx)("pre",{className:w("bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-foreground overflow-x-auto whitespace-pre-wrap","ph-mask ph-sensitive"),children:l.stdoutExcerpt})]}),(()=>{const A=er(l.resultJson);return!A||l.status==="failed"||l.status==="timed_out"?null:(0,e.jsx)(nl,{fold:A,finalizedAt:l.finishedAt})})(),(0,e.jsx)(Zd,{run:l,adapterType:r}),(0,e.jsx)(aa,{}),(0,e.jsx)(Wr,{runId:l.id,run:l,open:D,onOpenChange:F,onRerunWithTrace:S&&!["queued","running"].includes(l.status)?()=>K.mutate():void 0})]})}n(Zn,"RunDetail");function vc({agentId:t,companyId:s}){const r=Be(),{pushToast:i}=sn(),[o,a]=(0,u.useState)(""),[d,l]=(0,u.useState)(null),[c,x]=(0,u.useState)(!1),[m,y]=(0,u.useState)(!1),{data:S,isLoading:j}=U({queryKey:v.agents.keys(t),queryFn:n(()=>W.listKeys(t,s),"queryFn")}),p=te({mutationFn:n(()=>W.createKey(t,o.trim()||"Default",s),"mutationFn"),onSuccess:n(R=>{l(R.token),x(!0),a(""),r.invalidateQueries({queryKey:v.agents.keys(t)})},"onSuccess")}),h=te({mutationFn:n(R=>W.revokeKey(t,R,s),"mutationFn"),onSuccess:n(()=>{r.invalidateQueries({queryKey:v.agents.keys(t)})},"onSuccess")});function f(){d&&fr(d).then(()=>{y(!0),setTimeout(()=>y(!1),2e3)}).catch(()=>{i({title:"Copy failed",body:"Clipboard access is unavailable.",tone:"error"})})}n(f,"copyToken");const $=(S??[]).filter(R=>!R.revokedAt),C=(S??[]).filter(R=>R.revokedAt);return(0,e.jsxs)("div",{className:"space-y-6",children:[d&&(0,e.jsxs)("div",{className:"border border-yellow-300 dark:border-yellow-600/40 bg-yellow-50 dark:bg-yellow-500/5 rounded-lg p-4 space-y-2",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-yellow-700 dark:text-yellow-400",children:"API key created — copy it now, it will not be shown again."}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:w("flex-1 bg-neutral-100 dark:bg-neutral-950 rounded px-3 py-1.5 text-xs font-mono text-green-700 dark:text-green-300 truncate","ph-no-capture"),children:c?d:d.replace(/./g,"•")}),(0,e.jsx)(M,{variant:"ghost",size:"icon-sm",onClick:n(()=>x(R=>!R),"onClick"),title:c?"Hide":"Show",children:c?(0,e.jsx)(di,{className:"h-3.5 w-3.5"}):(0,e.jsx)(tr,{className:"h-3.5 w-3.5"})}),(0,e.jsx)(M,{variant:"ghost",size:"icon-sm",onClick:f,title:"Copy",children:(0,e.jsx)(Us,{className:"h-3.5 w-3.5"})}),m&&(0,e.jsx)("span",{className:"text-xs text-green-400",children:"Copied!"})]}),(0,e.jsx)(M,{variant:"ghost",size:"sm",className:"text-muted-foreground text-xs",onClick:n(()=>l(null),"onClick"),children:"Dismiss"})]}),(0,e.jsxs)("div",{className:"border border-border rounded-lg p-4 space-y-3",children:[(0,e.jsxs)("h3",{className:"text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,e.jsx)(bo,{className:"h-3.5 w-3.5"}),"Create API Key"]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"API keys allow this agent to authenticate calls to the Microvac server."}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(qt,{placeholder:"Key name (e.g. production)",value:o,onChange:n(R=>a(R.target.value),"onChange"),className:"h-8 text-sm",onKeyDown:n(R=>{R.key==="Enter"&&p.mutate()},"onKeyDown")}),(0,e.jsxs)(M,{size:"sm",onClick:n(()=>p.mutate(),"onClick"),disabled:p.isPending,children:[(0,e.jsx)(rn,{className:"h-3.5 w-3.5 mr-1"}),"Create"]})]})]}),j&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading keys..."}),!j&&$.length===0&&!d&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No active API keys."}),$.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Active Keys"}),(0,e.jsx)("div",{className:"border border-border rounded-lg divide-y divide-border",children:$.map(R=>(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:R.name}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground ml-3",children:["Created ",et(R.createdAt)]})]}),(0,e.jsx)(M,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive text-xs",onClick:n(()=>h.mutate(R.id),"onClick"),disabled:h.isPending,children:"Revoke"})]},R.id))})]}),C.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Revoked Keys"}),(0,e.jsx)("div",{className:"border border-border rounded-lg divide-y divide-border opacity-50",children:C.map(R=>(0,e.jsx)("div",{className:"flex items-center justify-between px-4 py-2.5",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-sm line-through",children:R.name}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground ml-3",children:["Revoked ",R.revokedAt?et(R.revokedAt):""]})]})},R.id))})]})]})}n(vc,"KeysTab");function Uc(){const{tab:t}=gs();return t?.startsWith("plugin:")?(0,e.jsx)(bc,{}):(0,e.jsx)(uc,{})}n(Uc,"AgentDetailPage");function bc(){const{agentId:t="",companyPrefix:s,tab:r}=gs(),{companies:i,selectedCompanyId:o}=Xs(),a=i.find(f=>f.issuePrefix.toUpperCase()===s?.toUpperCase())?.id??o,{data:d,isLoading:l,error:c}=U({queryKey:[...v.agents.detail(t),a??null],queryFn:n(()=>W.get(t,a??void 0),"queryFn"),enabled:!!(t&&a)}),{slots:x,isLoading:m,errorMessage:y}=ui({slotTypes:["detailTab"],entityType:"agent",companyId:d?.companyId,enabled:!!d}),S=(0,u.useMemo)(()=>x.filter(f=>`plugin:${f.pluginKey}:${f.id}`===r),[x,r]),{slots:[j],isLoading:p}=xi(S,d?.id,d?.companyId),{setBreadcrumbs:h}=pr();return(0,u.useEffect)(()=>{h([{label:"Agents",href:"/agents"},{label:d?.name??t,href:`/agents/${encodeURIComponent(t)}/overview`},{label:j?.displayName??"Plugin view"}])},[h,d?.name,t,j?.displayName]),c?(0,e.jsx)("p",{role:"alert",children:"Agent unavailable"}):!d||l||m||p?(0,e.jsx)("p",{role:"status",children:"Loading agent view…"}):(0,e.jsxs)("div",{className:"mx-auto max-w-5xl space-y-4",children:[(0,e.jsx)(ce,{to:`/agents/${encodeURIComponent(t)}/overview`,className:"text-sm text-muted-foreground",children:d.name}),j?(0,e.jsx)(Xa,{slot:j,context:{companyId:d.companyId,companyPrefix:s??null,entityId:d.id,entityType:"agent"},missingBehavior:"placeholder"}):(0,e.jsx)("p",{role:"status",children:y?"Agent view unavailable":"This plugin view is unavailable"})]})}n(bc,"AgentPluginDetail");export{Uc as AgentDetailPage};
|