@tickernelz/wardmote-ui 2026.1114.2 → 2026.1114.3

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.
Files changed (140) hide show
  1. package/dist/assets/{ActiveAgentsPanel-Budj8e9v.js → ActiveAgentsPanel-CF0fwsze.js} +1 -1
  2. package/dist/assets/{AdapterManager-DhiW44Eo.js → AdapterManager-DUXWwNxv.js} +1 -1
  3. package/dist/assets/{AdvancedToolsRoute-CICI1XRd.js → AdvancedToolsRoute-BamlkE3p.js} +1 -1
  4. package/dist/assets/{AgentActionButtons-DIhpv51Y.js → AgentActionButtons-CPIhsP04.js} +1 -1
  5. package/dist/assets/{AgentBubbleActionRow-DIr3TdR9.js → AgentBubbleActionRow-BUAUmJKa.js} +1 -1
  6. package/dist/assets/{AgentChat-CeuGtMXr.js → AgentChat-BAn_ghsu.js} +1 -1
  7. package/dist/assets/{AgentChats-CmDtTrMa.js → AgentChats-f73hodzr.js} +1 -1
  8. package/dist/assets/{AgentDefaults-DpYaMGkf.js → AgentDefaults-BL1XYvEo.js} +1 -1
  9. package/dist/assets/{AgentDetail-DFTeFc4-.js → AgentDetail-DthxFfuB.js} +1 -1
  10. package/dist/assets/{AgentTodoCard-DRXZ7hmU.js → AgentTodoCard-BvgkWD0T.js} +1 -1
  11. package/dist/assets/{Agents-CClUUMUq.js → Agents-D5qI6yZZ.js} +3 -3
  12. package/dist/assets/{AppDetail-DfHLFOtj.js → AppDetail-B6PtMl8J.js} +1 -1
  13. package/dist/assets/{AppNotConnected-CcmXbFtD.js → AppNotConnected-C_tGn786.js} +1 -1
  14. package/dist/assets/{ApprovalCard-uT_9D_uH.js → ApprovalCard-DrfZAdGQ.js} +1 -1
  15. package/dist/assets/{ApprovalDetail-CE41WFbd.js → ApprovalDetail-sfPpfdXc.js} +1 -1
  16. package/dist/assets/{ApprovalPayload-_zU9bukt.js → ApprovalPayload-C4F3ItGH.js} +1 -1
  17. package/dist/assets/{Approvals-BXrjqpKc.js → Approvals-DZoMl7_m.js} +1 -1
  18. package/dist/assets/{AppsConnect-DH7aSjtS.js → AppsConnect-D8Gu187f.js} +1 -1
  19. package/dist/assets/{AppsReview-C0Y3SxmZ.js → AppsReview-DokFETm0.js} +1 -1
  20. package/dist/assets/{ArtifactCard-DKUUBZ0K.js → ArtifactCard-BTf2-JIV.js} +1 -1
  21. package/dist/assets/{Artifacts-Bsv5m0aU.js → Artifacts-CK8FaygC.js} +1 -1
  22. package/dist/assets/{AssistantConnection-Dm2PaSeU.js → AssistantConnection-BlKC7jk0.js} +1 -1
  23. package/dist/assets/{AttentionInteractionResolver-CBjNuhYo.js → AttentionInteractionResolver-C2iz6oqT.js} +1 -1
  24. package/dist/assets/{AuditHub-DbUni0O_.js → AuditHub-DMhunMn8.js} +1 -1
  25. package/dist/assets/{BoardChat-CgzCuFIL.js → BoardChat-C4W8JLKB.js} +1 -1
  26. package/dist/assets/{BootstrapSetupUxLab-D-niQCV5.js → BootstrapSetupUxLab-D58OwniR.js} +1 -1
  27. package/dist/assets/{Browse-0bmB5mqw.js → Browse-BDjohBak.js} +1 -1
  28. package/dist/assets/{BudgetPolicyCard-CqFUHqOj.js → BudgetPolicyCard-DfAAgk9Z.js} +1 -1
  29. package/dist/assets/{CaseDetail-DakrB2jI.js → CaseDetail-CL0FC5sG.js} +1 -1
  30. package/dist/assets/{Cases-DXbr4HJt.js → Cases-C-7dXrEt.js} +1 -1
  31. package/dist/assets/{ChatEndpointDetail-BdDKo-Gq.js → ChatEndpointDetail-C-IYAYG8.js} +1 -1
  32. package/dist/assets/{ChatEndpointSetup-BX3iDH7N.js → ChatEndpointSetup-CM3QixMj.js} +1 -1
  33. package/dist/assets/{ChoiceControls-Bu-fd6qI.js → ChoiceControls-3Qpci4yE.js} +1 -1
  34. package/dist/assets/{Companies-FcUNLIkt.js → Companies-97toQ8Cw.js} +1 -1
  35. package/dist/assets/{CompanyAccess-BUcTNg7_.js → CompanyAccess-CKhS1BaS.js} +1 -1
  36. package/dist/assets/{CompanyActivity-ScpRBz1G.js → CompanyActivity-DzNrAyAb.js} +1 -1
  37. package/dist/assets/{CompanyConnections-DMEwbZv7.js → CompanyConnections-ORCH4i3U.js} +1 -1
  38. package/dist/assets/{CompanyEnvironments-EqXhVruZ.js → CompanyEnvironments-DphURbtb.js} +1 -1
  39. package/dist/assets/{CompanyExport-DQ9ffuua.js → CompanyExport-XeVCUcK3.js} +1 -1
  40. package/dist/assets/{CompanyImport-BhuZu4oc.js → CompanyImport-DPKpUaRa.js} +1 -1
  41. package/dist/assets/{CompanySettings-BSkg4ahA.js → CompanySettings-4JQpzuS1.js} +1 -1
  42. package/dist/assets/{CompanySettingsPluginPage-BzZkZqh-.js → CompanySettingsPluginPage-cVvXh0_G.js} +1 -1
  43. package/dist/assets/{CompanySkills-BbA4RKIw.js → CompanySkills-BA_9Ztwj.js} +1 -1
  44. package/dist/assets/{ComposerAddMenu-D9z2INup.js → ComposerAddMenu-DNp4ecG8.js} +1 -1
  45. package/dist/assets/{ConfigureBuiltInAgentModal-BUJPbmWc.js → ConfigureBuiltInAgentModal-CQCHDkl4.js} +1 -1
  46. package/dist/assets/{ConnectionSetupFlow-DKjP5RBZ.js → ConnectionSetupFlow-BaarToKu.js} +1 -1
  47. package/dist/assets/{CopyableGatewayUrl-BZyE_jT9.js → CopyableGatewayUrl-DxQsV7Hr.js} +1 -1
  48. package/dist/assets/{Dashboard--lTwxjV-.js → Dashboard--iaPJqJp.js} +1 -1
  49. package/dist/assets/{DashboardLive-BYyTgF5d.js → DashboardLive-4rGeotay.js} +1 -1
  50. package/dist/assets/{DecisionDateChips-vXwAFdua.js → DecisionDateChips-CJOLtNrJ.js} +1 -1
  51. package/dist/assets/{DecisionModelSettings-NrNERkaW.js → DecisionModelSettings-D-OxKIGP.js} +1 -1
  52. package/dist/assets/{DecisionQueuePage-BaaKuZBi.js → DecisionQueuePage-D-kNFav_.js} +1 -1
  53. package/dist/assets/{DesignGuide-DS6MuXWY.js → DesignGuide-D7486q4b.js} +1 -1
  54. package/dist/assets/{DocumentFrameHeader-DTSqcw4Q.js → DocumentFrameHeader-B61HhahB.js} +1 -1
  55. package/dist/assets/{EmailEndpointSetup-CJFYu2G0.js → EmailEndpointSetup-6OHb9B4q.js} +1 -1
  56. package/dist/assets/{ExecutionWorkspaceDetail-CuD5xWOB.js → ExecutionWorkspaceDetail-BGV-9D5Y.js} +1 -1
  57. package/dist/assets/{FolderControls-B7TWghGc.js → FolderControls-L2RzbfdQ.js} +1 -1
  58. package/dist/assets/{GatewayDetail-xNVOxSIs.js → GatewayDetail-CdXNQ9gD.js} +1 -1
  59. package/dist/assets/{GatewaysList-DsSKLm1h.js → GatewaysList-B0Jq1IRC.js} +1 -1
  60. package/dist/assets/{GoalDetail-oN5pyUUY.js → GoalDetail-D2VhPtvw.js} +1 -1
  61. package/dist/assets/{GoalTree-DaFizciF.js → GoalTree-kFpgH4dA.js} +1 -1
  62. package/dist/assets/{Goals-xgGKfQZi.js → Goals-B-_gq_Qu.js} +1 -1
  63. package/dist/assets/{ImageGalleryModal-CjHED0Lb.js → ImageGalleryModal-DzKBMOnu.js} +1 -1
  64. package/dist/assets/{Inbox-wHhHozfr.js → Inbox-zllmqRcB.js} +1 -1
  65. package/dist/assets/{InstanceAdvanced-Bdf2a4c_.js → InstanceAdvanced-B7tDfjwG.js} +1 -1
  66. package/dist/assets/{InviteLanding-McBYpNeW.js → InviteLanding-brwa_8NC.js} +1 -1
  67. package/dist/assets/{IssueChatLongThreadPerf-DD3RLbBo.js → IssueChatLongThreadPerf-D0HJe6IV.js} +1 -1
  68. package/dist/assets/{IssueChatThread-BN-_8hT8.js → IssueChatThread-CMXzuvrF.js} +1 -1
  69. package/dist/assets/{IssueDetail-CsaD311l.js → IssueDetail-DGdg-mB8.js} +1 -1
  70. package/dist/assets/{IssueDocumentAnnotations-BVdH4RTa.js → IssueDocumentAnnotations-BK-LgExc.js} +1 -1
  71. package/dist/assets/{IssueOutputSection-CDIMRaF0.js → IssueOutputSection-aSyiE1pg.js} +1 -1
  72. package/dist/assets/{IssueRecoveryActionCard-C9qJAHes.js → IssueRecoveryActionCard-vAuL_OEC.js} +1 -1
  73. package/dist/assets/{IssueThreadInteractionCard-BbigJB2U.js → IssueThreadInteractionCard-wFidFTIh.js} +1 -1
  74. package/dist/assets/{Issues-BWoc80Y9.js → Issues-CsmM33z_.js} +1 -1
  75. package/dist/assets/{LiveNowTodoLine-B9oTH2L0.js → LiveNowTodoLine-CP32NNp_.js} +1 -1
  76. package/dist/assets/{ManagedAiConnectionDetails-B0aWUPkf.js → ManagedAiConnectionDetails-Ba0awZ-O.js} +1 -1
  77. package/dist/assets/{McpConnect-Dzf7W2K6.js → McpConnect-CYLP1yLX.js} +1 -1
  78. package/dist/assets/{MembershipAction-oiLtxQm3.js → MembershipAction-CKs7Ua9x.js} +1 -1
  79. package/dist/assets/{ModelsAndProviders-BEb4Z38S.js → ModelsAndProviders-gaR7HDQm.js} +1 -1
  80. package/dist/assets/{NewAgent-C3MxIRJj.js → NewAgent-DBQzvxIr.js} +1 -1
  81. package/dist/assets/{OmpAllSettings-DBtL1qDL.js → OmpAllSettings-B_Knr51Z.js} +1 -1
  82. package/dist/assets/{PipelineSettings-BcAtsehE.js → PipelineSettings-Dl-94FB5.js} +1 -1
  83. package/dist/assets/{Pipelines-CkiYUQS-.js → Pipelines-CY9hGe0h.js} +1 -1
  84. package/dist/assets/{PixelsOffice-BSlctoug.js → PixelsOffice-BgyGZsiV.js} +1 -1
  85. package/dist/assets/{PluginPage-C6Qnf9ka.js → PluginPage-CMA4Ei50.js} +1 -1
  86. package/dist/assets/{PluginSettings-Do37r6Zu.js → PluginSettings-Cm4H1JRT.js} +1 -1
  87. package/dist/assets/{ProfileDetailRoute-DRFQNId6.js → ProfileDetailRoute-BEBctbC6.js} +1 -1
  88. package/dist/assets/{ProfileSettings-BMwLBQDB.js → ProfileSettings-Djo7BLIj.js} +1 -1
  89. package/dist/assets/{ProfileWizardRoute-XnnvzH9S.js → ProfileWizardRoute-DxLujEtD.js} +1 -1
  90. package/dist/assets/{ProjectDetail-BW6Lr4Iq.js → ProjectDetail-CmmdvUHn.js} +1 -1
  91. package/dist/assets/{ProjectWorkspaceDetail-DR4JCa1b.js → ProjectWorkspaceDetail-BsA0hJ-k.js} +1 -1
  92. package/dist/assets/{ProjectWorkspacesContent-CadPZn0k.js → ProjectWorkspacesContent-BNNI_WAk.js} +1 -1
  93. package/dist/assets/{Projects-DLBFbxcj.js → Projects-BTAauZr0.js} +1 -1
  94. package/dist/assets/{PublicIssueSharePage-C9yRZOdP.js → PublicIssueSharePage-DdPjfmD9.js} +1 -1
  95. package/dist/assets/{ReviewQueueCard-CIkiY-Lm.js → ReviewQueueCard-BC6VY8Bc.js} +1 -1
  96. package/dist/assets/{RichWorkProductCard-JGHGU_RI.js → RichWorkProductCard-ClpMt_Bh.js} +1 -1
  97. package/dist/assets/{RoutineDetail-izWzADvA.js → RoutineDetail-BT6_GKnC.js} +1 -1
  98. package/dist/assets/{RoutineRunVariablesDialog-DiT_o5Dm.js → RoutineRunVariablesDialog-D_Mls1sV.js} +1 -1
  99. package/dist/assets/{Routines-CHtabiYj.js → Routines-4LevOfvV.js} +1 -1
  100. package/dist/assets/{ScrollToBottom-pyHLjOjY.js → ScrollToBottom-jItsgDR8.js} +1 -1
  101. package/dist/assets/{Search-yNNB6kys.js → Search-bmcm0_m_.js} +1 -1
  102. package/dist/assets/{Secrets-BOyOk5BF.js → Secrets-DfR1fBAZ.js} +1 -1
  103. package/dist/assets/{SkillSourceTree-M58QwBFF.js → SkillSourceTree--FWKWyF3.js} +1 -1
  104. package/dist/assets/{SkillSources-Cw4PU-Bz.js → SkillSources-jUDjqy5i.js} +1 -1
  105. package/dist/assets/{SkillStudio-Cj_M3ZJa.js → SkillStudio-BsqtUnzF.js} +1 -1
  106. package/dist/assets/{SourceTrustBadge-BZBQe5No.js → SourceTrustBadge-CfBrvKL3.js} +1 -1
  107. package/dist/assets/{StatusCards-DaJdQUN5.js → StatusCards-Dt3zorUZ.js} +1 -1
  108. package/dist/assets/{SummarySlotCard-DlSmN6PL.js → SummarySlotCard-D1C0qH2L.js} +1 -1
  109. package/dist/assets/{TaskChatLab-CU5eA7nX.js → TaskChatLab-B0coUvdp.js} +1 -1
  110. package/dist/assets/{TaskChatMarker-wBVUFL3u.js → TaskChatMarker-C40twVjh.js} +1 -1
  111. package/dist/assets/{TaskChatProtocolCard-D-Dwy2EL.js → TaskChatProtocolCard--bi_tc6i.js} +1 -1
  112. package/dist/assets/{TaskChatThreadView-Crlf9I05.js → TaskChatThreadView-DkzFDrLW.js} +1 -1
  113. package/dist/assets/{TaskDetailRelationsPanel-CkktN1EC.js → TaskDetailRelationsPanel-DZGkinoJ.js} +1 -1
  114. package/dist/assets/{TaskTreeControls-B_ulMOi1.js → TaskTreeControls-DznugVpi.js} +1 -1
  115. package/dist/assets/Terminal-NjEb5-2b.js +1 -0
  116. package/dist/assets/TerminalView-DZxK2Ei5.js +58 -0
  117. package/dist/assets/{TrustPresetSection-DTc1Rj4q.js → TrustPresetSection-CjNwNBo3.js} +1 -1
  118. package/dist/assets/{UserProfile-C6q55R0Q.js → UserProfile-Dujv3qdz.js} +1 -1
  119. package/dist/assets/{WhatNeedsMe-1igJA4gL.js → WhatNeedsMe-C9P2EsqQ.js} +1 -1
  120. package/dist/assets/{Workspaces-rtQKliW0.js → Workspaces-BTgSx9nA.js} +1 -1
  121. package/dist/assets/{connection-owner-CZwxTEuM.js → connection-owner-DL4yKhSt.js} +1 -1
  122. package/dist/assets/dist-ypeTPGg_.js +1 -0
  123. package/dist/assets/dropdown-menu-DEO3mF_E.js +1 -0
  124. package/dist/assets/{environment-variables-editor-CCxeFKKk.js → environment-variables-editor-0qgSPgNN.js} +1 -1
  125. package/dist/assets/{index-DDoARkPG.js → index-3AxqhPET.js} +4 -4
  126. package/dist/assets/index-B5bd7Tk6.css +2 -0
  127. package/dist/assets/{issue-properties-lmRBaUTG.js → issue-properties-B1cYnBDU.js} +1 -1
  128. package/dist/assets/{issue-workspace-selection-4JI2Uh9p.js → issue-workspace-selection-S8UgGgK1.js} +1 -1
  129. package/dist/assets/{pipeline-stage-presentation-BSuBql6K.js → pipeline-stage-presentation-5UBw7nsb.js} +1 -1
  130. package/dist/assets/{shared-DDwmHbeD.js → shared-4LF6wQ38.js} +1 -1
  131. package/dist/assets/{tool-taxonomy-DR7Q8sVs.js → tool-taxonomy-B5zpbkHA.js} +1 -1
  132. package/dist/assets/{transcript-adapter-wiFIjKfq.js → transcript-adapter-C29ZJiU2.js} +1 -1
  133. package/dist/assets/{useSummaryDraftStream-CWOQt25o.js → useSummaryDraftStream-R2Y2bAUU.js} +1 -1
  134. package/dist/index.html +7 -6
  135. package/dist/sw.js +1 -1
  136. package/package.json +1 -1
  137. package/dist/assets/Terminal-Bo-WuezO.js +0 -1
  138. package/dist/assets/TerminalView-AkFY5bLC.js +0 -58
  139. package/dist/assets/dropdown-menu-CqRAF7Oj.js +0 -1
  140. package/dist/assets/index-KZ2bEg2H.css +0 -2
@@ -1,3 +1,3 @@
1
- var je=Object.defineProperty;var i=(s,t)=>je(s,"name",{value:t,configurable:!0});import{i as ue}from"./rolldown-runtime-ZpX3ckPj.js";import{_ as ye,l as E,na as Ae,ta as Me}from"./createLucideIcon-DJi9suAC.js";import{h as Te,y as de}from"./star-BZgQbzhV.js";import{X as te,_ as se,t as y,v as H}from"./queryKeys-DYV5MhM_.js";import{t as Ce}from"./useInfiniteQuery-B28xptxn.js";import{t as Pe}from"./useQueries-BIJ7zVTy.js";import{t as _e}from"./Inbox-wHhHozfr.js";import{n as me}from"./CompanyContext-CSrVsSze.js";import{$t as Le,Ht as Ee,Jt as Re,Q as qe,Qt as G,Ut as ne,Xt as De,Yt as $e,Zt as Fe,en as ze,nn as Oe,o as Ue,rn as he,t as U,tn as Ke,zt as B}from"./router-2UfGeejU.js";import{a as Qe,c as Be,i as Ve,n as We,o as He,r as Ge,s as Xe,t as Ze}from"./alert-dialog-Blls2GnU.js";import{a as Ye,c as Je,i as et,p as tt,r as st,t as nt}from"./dropdown-menu-CqRAF7Oj.js";import{a as at}from"./MarkdownEditor-DXD-Cu3u.js";import{t as it}from"./activity-CB9AQzZO.js";import{t as rt}from"./arrow-up-right-BLYWl-we.js";import{t as lt}from"./check-Ctsrlfa-.js";import{t as ot}from"./chevron-down-BCvxsWfI.js";import{t as ct}from"./chevron-right-s7L6hXXq.js";import{i as ut,o as ae}from"./tool-taxonomy-DR7Q8sVs.js";import{t as dt}from"./circle-dot-zr8GONq2.js";import{n as X,t as D}from"./button-CMwV3L1P.js";import{t as mt}from"./plus-C6fnr28l.js";import{t as ht}from"./scroll-text-BpkOrME3.js";import{t as pt}from"./square-B2aH51tE.js";import{t as ft}from"./triangle-alert-CBVKiaXB.js";import{t as Y}from"./AgentAvatar-DgGEobSY.js";import{t as xt}from"./agents-DmlgUVso.js";import{t as pe}from"./heartbeats-DOyojsaN.js";import{n as gt,t as vt}from"./useSharedPolling-D4Xn8mY2.js";import{t as bt}from"./projects-mixWrT5q.js";import{n as wt}from"./BreadcrumbContext-BVZDZoC0.js";import{t as St}from"./textarea-BRPEfJ-g.js";import{y as It}from"./model-picker-fields-235ien8Z.js";import{i as kt}from"./schema-config-fields-DggSrP5S.js";import{M as Nt,P as fe,T as jt,ca as yt,fi as At,i as Mt,k as Tt,mr as Ct,r as Pt,y as _t}from"./index-DDoARkPG.js";import{t as Lt}from"./useSecondTick-Gige2l0t.js";import{r as Et,t as Rt}from"./model-fallback-X_YvC3rj.js";import{t as qt}from"./LiveNowTodoLine-B9oTH2L0.js";var f=ue(Ae(),1),Dt=6e4,$t=12e4,Ft=9e5,ie={active:0,thinking:1,starting:2,quiet:3,stalled:4},xe={starting:"loading",active:"working",thinking:"thinking",quiet:"sleepy",stalled:"confused"};function ge(s){if(!s)return null;const t=new Date(s).getTime();return Number.isFinite(t)?t:null}i(ge,"toMs");function Q(s){let t=null;for(const n of[s.lastEventAt,s.currentStatusUpdatedAt,s.outputSilence?.lastOutputAt,s.lastUsefulActionAt]){const a=ge(n);a!==null&&(t===null||a>t)&&(t=a)}return t}i(Q,"lastLiveActivityMs");function J(s){const t=Math.floor(s/6e4);if(t<1)return`${Math.max(0,Math.floor(s/1e3))}s`;if(t<60)return`${t}m`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m`:`${n}h`}i(J,"formatSilence");function zt(s){return!!s.currentToolName&&!/^finished\b/i.test(s.currentStatusMessage??"")}i(zt,"toolInFlight");function ve(s,t){const n=ge(s.startedAt);if(n===null||s.status==="queued"||s.status==="scheduled_retry")return{health:"starting",label:"Queued",silentMs:null};const a=Q(s);if(a===null&&t-n<Dt)return{health:"starting",label:"Starting",silentMs:null};const l=Math.max(0,t-(a??n)),o=s.outputSilence?.level,r=s.outputSilence?.criticalThresholdMs||Ft;return o==="critical"||o!=="snoozed"&&l>=r?{health:"stalled",label:`Stalled ${J(l)}`,silentMs:l}:o==="suspicious"||l>=$t?{health:"quiet",label:`Quiet ${J(l)}`,silentMs:l}:zt(s)?{health:"active",label:"Working",silentMs:l}:{health:"thinking",label:"Thinking",silentMs:l}}i(ve,"classifyLiveNowHealth");function be(s){return s.reduce((t,n)=>ie[n.health]>ie[t.health]?n:t)}i(be,"mostSevereSignal");function Ot(s){const t={working:0,quiet:0,stalled:0};for(const n of s)n==="quiet"?t.quiet+=1:n==="stalled"?t.stalled+=1:t.working+=1;return t}i(Ot,"countLiveNowHealth");function re(s){const t=s.currentToolName?.trim()||null,n=(s.currentStatusMessage?.trim()||null)??(t?ae(t).verbLabel:null);return n?{icon:t?ae(t).icon:ut(n)??it,text:n}:null}i(re,"describeLiveActivity");var e=ue(Me(),1);function we(s,t){return s instanceof Error&&s.message?s.message:t}i(we,"errorMessage");function Ut({companyId:s,entry:t,issue:n,loadFailed:a,ancestors:l,truncatedAncestors:o,issueLinkState:r,now:c,hiddenOnWide:d=!1}){const p=te(),v=(0,f.useId)(),[w,k]=(0,f.useState)(!1),[S,x]=(0,f.useState)(!1),[q,_]=(0,f.useState)(null),A=n?.identifier??t.issueId,b=n?.identifier??t.issueId.slice(0,8),$=n?.title??(a?"Task unavailable":"Loading task…"),M=n?$e(r,n):void 0,R=ne(A),g=t.runs[0],u=t.runs.map(h=>ve(h,c)),m=be(u),I=u[0],j=t.runs.reduce((h,O)=>(Q(O)??0)>(Q(h)??0)?O:h,g),T=re(j)??t.runs.map(re).find(Boolean)??null,C=Q(j),V=t.runs.find(h=>h.lastAssistantSnippet?.trim())?.lastAssistantSnippet?.trim()??null,F=t.runs.find(h=>h.nextAction?.trim())?.nextAction?.trim()??null,z=[...new Map(t.runs.slice(1).filter(h=>h.agentId!==g.agentId).map(h=>[h.agentId,h])).values()],W=t.earliestStartedAt?ye(Math.max(0,c-new Date(t.earliestStartedAt).getTime())):"Queued",N=`/agents/${g.agentId}/runs/${g.id}`,L=T?.icon??null,P=se({mutationFn:i(()=>pe.cancel(g.id),"mutationFn"),onSuccess:i(()=>{_(`Stopping ${g.agentName}'s run`),p.invalidateQueries({queryKey:y.liveRuns(s)}),p.invalidateQueries({queryKey:y.issues.liveRuns(t.issueId)}),p.invalidateQueries({queryKey:y.issues.activeRun(t.issueId)}),p.invalidateQueries({queryKey:y.issues.runs(t.issueId)})},"onSuccess")}),ke=t.runs.map(h=>h.id),Ne=i(()=>{_(null),k(h=>!h)},"openComposer");return(0,e.jsxs)("li",{"data-live-now-issue-id":t.issueId,"data-live-health":m.health,className:E("live-now-card relative flex w-(--live-now-card-peek) shrink-0 snap-start flex-col overflow-hidden rounded-xl border border-line bg-bg-2 text-ink sm:w-auto",d&&"sm:hidden"),children:[m.health==="active"||m.health==="starting"?(0,e.jsx)("span",{"aria-hidden":"true",className:"live-now-sweep"}):null,(0,e.jsxs)("div",{className:"flex items-start gap-3 px-3 pt-3",children:[(0,e.jsxs)("span",{className:"relative shrink-0",children:[(0,e.jsx)(Y,{agent:{id:g.agentId,name:g.agentName,appearance:g.agentAppearance,avatarUrl:g.avatarUrl},size:40,pose:xe[I.health]}),(0,e.jsx)("span",{"aria-hidden":"true",className:E("live-now-health-dot absolute right-0 bottom-0 size-2.5 rounded-full ring-2 ring-bg-2",(m.health==="active"||m.health==="thinking")&&"live-now-breathe")})]}),(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)("span",{title:g.agentName,className:"truncate text-sm font-semibold",children:g.agentName}),z.length>0?(0,e.jsx)("span",{className:"flex shrink-0 items-center","data-slot":"tasks-live-now-other-agents",children:z.map(h=>(0,e.jsx)("span",{title:h.agentName,className:"-ml-1 rounded-full bg-bg-2 ring-2 ring-bg-2 first:ml-0",children:(0,e.jsx)(Y,{agent:{id:h.agentId,name:h.agentName,appearance:h.agentAppearance},size:20,label:h.agentName})},h.agentId))}):null,(0,e.jsx)("time",{dateTime:t.earliestStartedAt??t.latestStartAt,title:"Time since the run started",className:"ml-auto shrink-0 font-mono text-xs tabular-nums text-ink-3",children:W})]}),(0,e.jsxs)("span",{"data-slot":"tasks-live-now-health",className:"live-now-health-pill mt-1 inline-flex max-w-full items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium text-ink",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"live-now-health-dot size-1.5 shrink-0 rounded-full"}),(0,e.jsx)("span",{className:"truncate",children:m.label})]}),g.modelFallback?(0,e.jsx)(Kt,{adapterType:g.adapterType,fallback:g.modelFallback}):null]})]}),(0,e.jsxs)("div",{className:"mt-3 px-3",children:[l.length>0||o?(0,e.jsxs)("nav",{"aria-label":"Parent tasks","data-slot":"tasks-live-now-path",className:"mb-0.5 flex min-w-0 items-center gap-1 overflow-hidden whitespace-nowrap text-xs text-ink-3",children:[o?(0,e.jsx)("span",{"aria-hidden":"true",children:"… ›"}):null,l.map((h,O)=>(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[O>0?(0,e.jsx)("span",{"aria-hidden":"true",children:"›"}):null,(0,e.jsx)(U,{to:ne(h.identifier??h.id),title:h.title,className:"truncate font-mono text-ink-3 no-underline hover:text-ink hover:underline",children:h.identifier??h.id.slice(0,8)})]},h.id)),(0,e.jsx)("span",{"aria-hidden":"true",children:"›"})]}):null,(0,e.jsxs)(U,{to:R,state:M,issuePrefetch:n,disableIssueQuicklook:!0,onClickCapture:M?()=>Re(A,M):void 0,className:"line-clamp-2 rounded-sm text-sm leading-5 font-medium text-ink no-underline outline-none hover:underline focus-visible:ring-2 focus-visible:ring-focus",children:[(0,e.jsx)("span",{className:"mr-1.5 font-mono text-xs font-normal text-ink-3",children:b}),$]})]}),(0,e.jsx)("blockquote",{"data-slot":"tasks-live-now-snippet",className:"live-now-quote mx-3 mt-2.5 line-clamp-2 min-h-10 border-l-2 pl-2.5 text-sm leading-5 text-ink-3",children:V??(F?`Next: ${F}`:m.health==="starting"?"Warming up…":"No message yet")}),(0,e.jsxs)("div",{"data-slot":"tasks-live-now-status",className:"mx-3 mt-2 flex h-5 min-w-0 items-center gap-1.5 text-xs text-ink-3",children:[L?(0,e.jsx)(L,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):null,(0,e.jsx)("span",{className:"min-w-0 truncate",children:T?.text??"Waiting for the first event"}),C!==null?(0,e.jsxs)("span",{className:"ml-auto shrink-0 tabular-nums",children:[J(Math.max(0,c-C))," ago"]}):null]}),(0,e.jsx)(qt,{issueId:t.issueId,runIds:ke}),w?(0,e.jsx)(Qt,{id:v,issueId:t.issueId,agentName:g.agentName,identifier:b,onSent:i(h=>{k(!1),_(h)},"onSent"),onCancel:i(()=>k(!1),"onCancel")}):null,q||P.error?(0,e.jsx)("p",{role:P.error?"alert":"status",className:E("mx-3 mt-2 text-xs",P.error?"text-bad":"text-ink-3"),children:P.error?we(P.error,"Couldn’t stop the run."):q}):null,(0,e.jsx)("div",{className:"mt-auto pt-2.5",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-0.5 border-t border-line px-1.5 py-1.5",children:[(0,e.jsxs)(U,{to:R,state:M,disableIssueQuicklook:!0,"aria-label":`Open ${b}`,className:X({variant:"ghost",size:"xs"}),children:[(0,e.jsx)(rt,{"aria-hidden":"true"}),"Open"]}),(0,e.jsxs)(U,{to:N,"aria-label":`Run transcript for ${g.agentName}`,className:X({variant:"ghost",size:"xs"}),children:[(0,e.jsx)(ht,{"aria-hidden":"true"}),"Run"]}),(0,e.jsxs)(D,{type:"button",variant:"ghost",size:"xs","aria-expanded":w,"aria-controls":w?v:void 0,"aria-label":`Steer ${g.agentName} on ${b}`,onClick:Ne,children:[(0,e.jsx)(qe,{"aria-hidden":"true"}),"Steer"]}),(0,e.jsx)(_t,{className:"ml-auto",issueId:t.issueId,run:g,companyId:s,taskLabel:b}),(0,e.jsxs)(D,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:P.isPending,"aria-label":`Stop ${g.agentName}'s run on ${b}`,onClick:i(()=>x(!0),"onClick"),children:[(0,e.jsx)(pt,{"aria-hidden":"true",className:"fill-current"}),P.isPending?"Stopping…":"Stop"]})]})}),(0,e.jsx)(Ze,{open:S,onOpenChange:x,children:(0,e.jsxs)(Ve,{children:[(0,e.jsxs)(Xe,{children:[(0,e.jsxs)(Be,{children:["Stop ",g.agentName,"'s run?"]}),(0,e.jsxs)(Qe,{children:[b," keeps its status and comments. The agent stops mid-turn, so any unsaved work in this run is lost."]})]}),(0,e.jsxs)(He,{children:[(0,e.jsx)(Ge,{children:"Keep running"}),(0,e.jsx)(We,{className:X({variant:"danger"}),onClick:i(()=>{_(null),P.mutate()},"onClick"),children:"Stop run"})]})]})})]})}i(Ut,"LiveNowCard");function Kt({adapterType:s,fallback:t}){const n=kt(s)?.fields.find(a=>a.key==="model")?.options??[];return(0,e.jsxs)("span",{"data-slot":"live-now-model-fallback",title:`${t.activeModel} (primary ${t.primaryModel})`,className:"ml-1.5 mt-1 inline-flex max-w-full items-start gap-1.5 rounded-md border border-amber-500/25 bg-amber-500/10 px-2 py-1 text-left text-xs font-medium leading-snug text-amber-800 dark:text-amber-200",children:[(0,e.jsx)(ft,{"aria-hidden":"true",className:"mt-0.5 size-3.5 shrink-0 text-amber-500 dark:text-amber-400"}),(0,e.jsxs)("span",{className:"min-w-0 whitespace-normal break-words",children:[It(Rt(t.activeModel,n)),(0,e.jsxs)("span",{className:"text-ink-3",children:[" · primary: ",Et(t.reason)]})]})]})}i(Kt,"LiveNowModelFallbackPill");function Qt({id:s,issueId:t,agentName:n,identifier:a,onSent:l,onCancel:o}){const r=te(),[c,d]=(0,f.useState)(""),p=`${s}-field`,v=se({mutationFn:i(x=>B.addComment(t,x,void 0,void 0,void 0,crypto.randomUUID(),"steer"),"mutationFn"),onSuccess:i(x=>{r.invalidateQueries({queryKey:y.issues.comments(t)}),l(at(x)??(x?.deliveredAs==="steered"?`Steered into ${n}'s turn`:`Sent to ${n}`))},"onSuccess")}),w=c.trim(),k=i(x=>{x?.preventDefault(),!(!w||v.isPending)&&v.mutate(w)},"submit"),S=i(x=>{x.key==="Escape"?(x.preventDefault(),o()):x.key==="Enter"&&!x.shiftKey&&!x.nativeEvent.isComposing&&k(x)},"onKeyDown");return(0,e.jsxs)("form",{id:s,"data-slot":"tasks-live-now-steer",className:"mx-3 mt-3 space-y-2",onSubmit:k,children:[(0,e.jsxs)("label",{htmlFor:p,className:"sr-only",children:["Steer ",n," on ",a]}),(0,e.jsx)(St,{id:p,rows:2,autoFocus:!0,value:c,placeholder:`Steer ${n}…`,className:"min-h-14 resize-none text-sm",disabled:v.isPending,onChange:i(x=>d(x.target.value),"onChange"),onKeyDown:S}),v.error?(0,e.jsx)("p",{role:"alert",className:"text-xs text-bad",children:we(v.error,"Couldn’t send the message.")}):null,(0,e.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,e.jsx)("span",{className:"mr-auto text-xs text-ink-3",children:"Enter to send · Esc to cancel"}),(0,e.jsx)(D,{type:"button",variant:"ghost",size:"xs",onClick:o,children:"Cancel"}),(0,e.jsx)(D,{type:"submit",size:"xs",disabled:!w||v.isPending,children:v.isPending?"Sending…":"Send"})]})]})}i(Qt,"LiveNowSteerForm");var Bt=3e4,le=6,Vt=5,oe=2;function Z(s){return s.startedAt??s.createdAt}i(Z,"runStartAt");function K(s){const t=new Date(s).getTime();return Number.isFinite(t)?t:0}i(K,"timestampMs");function Wt(s,t){const n=new Map;for(const l of s??[]){if(!l.issueId||!fe(l,t.get(l.issueId)))continue;const o=n.get(l.issueId);o?o.push(l):n.set(l.issueId,[l])}const a=[];for(const[l,o]of n){o.sort((c,d)=>K(Z(d))-K(Z(c)));const r=o.filter(c=>c.startedAt!==null);a.push({issueId:l,runs:o,latestStartAt:Z(o[0]),earliestStartedAt:r.length>0?r[r.length-1].startedAt:null})}return a.sort((l,o)=>K(o.latestStartAt)-K(l.latestStartAt))}i(Wt,"buildLiveNowEntries");function ce(s,t,n){const a=[],l=new Set;let o=s?.parentId??null,r=!1;for(;o&&!l.has(o);){l.add(o);const c=t.get(o);if(!c){r=!0;break}a.push({id:c.id,identifier:c.identifier??null,title:c.title}),o=c.parentId??null}return r?n?{ancestors:[...n].reverse().map(({id:c,identifier:d,title:p})=>({id:c,identifier:d,title:p})),complete:!0}:{ancestors:a.reverse(),complete:!1}:{ancestors:a.reverse(),complete:!0}}i(ce,"resolveLiveNowParentPath");function ee(s){return`wardmote:tasks-live-now:collapsed:${s}`}i(ee,"liveNowCollapsedStorageKey");function Ht(s){try{return window.localStorage.getItem(ee(s))==="true"}catch{return!1}}i(Ht,"readCollapsed");function Gt(s,t){try{t?window.localStorage.setItem(ee(s),"true"):window.localStorage.removeItem(ee(s))}catch{return}}i(Gt,"writeCollapsed");function Xt(s){const t=(0,f.useRef)(!1);return(0,f.useLayoutEffect)(()=>{const n=s.current;if(!n||typeof ResizeObserver>"u")return;const a=Mt(n),l=a??window,o=i(()=>n.getBoundingClientRect().bottom-(a?a.getBoundingClientRect().top:0),"bottomBelowViewportTop");let r=o();const c=i(()=>{r=o()},"syncBottom"),d=new ResizeObserver(()=>{const p=o(),v=p-r,w=t.current;if(t.current=!1,!w&&v!==0&&r<=0){a?a.scrollTop+=v:window.scrollBy(0,v),c();return}r=p});return l.addEventListener("scroll",c,{passive:!0}),d.observe(n),()=>{d.disconnect(),l.removeEventListener("scroll",c)}},[s]),(0,f.useCallback)(()=>{t.current=!0},[])}i(Xt,"useAboveViewportResizeCompensation");function Zt({companyId:s,liveRuns:t,issues:n,issueLinkState:a}){const l=(0,f.useRef)(null),o=Xt(l),[r,c]=(0,f.useState)(()=>Ht(s)),d=(0,f.useMemo)(()=>new Map(n.map(u=>[u.id,u])),[n]),p=(0,f.useMemo)(()=>{const u=new Set;for(const m of t??[]){if(!m.issueId||u.has(m.issueId)||!fe(m))continue;const I=d.get(m.issueId);(!I||!ce(I,d).complete)&&u.add(m.issueId)}return[...u]},[t,d]),v=Pe({queries:p.map(u=>({queryKey:y.issues.detail(u),queryFn:i(()=>B.get(u),"queryFn"),staleTime:Bt,retry:!1}))}),{detailById:w,failedIds:k}=(0,f.useMemo)(()=>{const u=new Map,m=new Set;return v.forEach((I,j)=>{const T=p[j];I.data?u.set(T,I.data):I.isError&&m.add(T)}),{detailById:u,failedIds:m}},[p,v]),S=(0,f.useMemo)(()=>{const u=new Map;for(const m of t??[]){if(!m.issueId)continue;const I=d.get(m.issueId)?.status??w.get(m.issueId)?.status;I&&u.set(m.issueId,I)}return Wt(t,u)},[w,t,d]),x=Date.now();Lt(S.length>0&&!r);const[q,_]=(0,f.useState)(!1),A=(0,f.useId)(),b=S.map(u=>{const m=d.get(u.issueId)??w.get(u.issueId)??null;return{entry:u,issue:m,signal:be(u.runs.map(I=>ve(I,x))),identifier:m?.identifier??u.issueId.slice(0,8)}}).sort((u,m)=>+(m.signal.health==="stalled")-+(u.signal.health==="stalled")),$=Ot(b.map(u=>u.signal.health)),M=q?0:Math.max(0,b.length-le),R=Yt(b.map(u=>`${u.identifier} ${u.signal.health}`).join(`
1
+ var je=Object.defineProperty;var i=(s,t)=>je(s,"name",{value:t,configurable:!0});import{i as ue}from"./rolldown-runtime-ZpX3ckPj.js";import{_ as ye,l as E,na as Ae,ta as Me}from"./createLucideIcon-DJi9suAC.js";import{h as Te,y as de}from"./star-BZgQbzhV.js";import{X as te,_ as se,t as y,v as H}from"./queryKeys-DYV5MhM_.js";import{t as Ce}from"./useInfiniteQuery-B28xptxn.js";import{t as Pe}from"./useQueries-BIJ7zVTy.js";import{t as _e}from"./Inbox-zllmqRcB.js";import{n as me}from"./CompanyContext-CSrVsSze.js";import{$t as Le,Ht as Ee,Jt as Re,Q as qe,Qt as G,Ut as ne,Xt as De,Yt as $e,Zt as Fe,en as ze,nn as Oe,o as Ue,rn as he,t as U,tn as Ke,zt as B}from"./router-2UfGeejU.js";import{a as Qe,c as Be,i as Ve,n as We,o as He,r as Ge,s as Xe,t as Ze}from"./alert-dialog-Blls2GnU.js";import{a as Ye,c as Je,i as et,p as tt,r as st,t as nt}from"./dropdown-menu-DEO3mF_E.js";import{a as at}from"./MarkdownEditor-DXD-Cu3u.js";import{t as it}from"./activity-CB9AQzZO.js";import{t as rt}from"./arrow-up-right-BLYWl-we.js";import{t as lt}from"./check-Ctsrlfa-.js";import{t as ot}from"./chevron-down-BCvxsWfI.js";import{t as ct}from"./chevron-right-s7L6hXXq.js";import{i as ut,o as ae}from"./tool-taxonomy-B5zpbkHA.js";import{t as dt}from"./circle-dot-zr8GONq2.js";import{n as X,t as D}from"./button-CMwV3L1P.js";import{t as mt}from"./plus-C6fnr28l.js";import{t as ht}from"./scroll-text-BpkOrME3.js";import{t as pt}from"./square-B2aH51tE.js";import{t as ft}from"./triangle-alert-CBVKiaXB.js";import{t as Y}from"./AgentAvatar-DgGEobSY.js";import{t as xt}from"./agents-DmlgUVso.js";import{t as pe}from"./heartbeats-DOyojsaN.js";import{n as gt,t as vt}from"./useSharedPolling-D4Xn8mY2.js";import{t as bt}from"./projects-mixWrT5q.js";import{n as wt}from"./BreadcrumbContext-BVZDZoC0.js";import{t as St}from"./textarea-BRPEfJ-g.js";import{y as It}from"./model-picker-fields-235ien8Z.js";import{i as kt}from"./schema-config-fields-DggSrP5S.js";import{M as Nt,P as fe,T as jt,ca as yt,fi as At,i as Mt,k as Tt,mr as Ct,r as Pt,y as _t}from"./index-3AxqhPET.js";import{t as Lt}from"./useSecondTick-Gige2l0t.js";import{r as Et,t as Rt}from"./model-fallback-X_YvC3rj.js";import{t as qt}from"./LiveNowTodoLine-CP32NNp_.js";var f=ue(Ae(),1),Dt=6e4,$t=12e4,Ft=9e5,ie={active:0,thinking:1,starting:2,quiet:3,stalled:4},xe={starting:"loading",active:"working",thinking:"thinking",quiet:"sleepy",stalled:"confused"};function ge(s){if(!s)return null;const t=new Date(s).getTime();return Number.isFinite(t)?t:null}i(ge,"toMs");function Q(s){let t=null;for(const n of[s.lastEventAt,s.currentStatusUpdatedAt,s.outputSilence?.lastOutputAt,s.lastUsefulActionAt]){const a=ge(n);a!==null&&(t===null||a>t)&&(t=a)}return t}i(Q,"lastLiveActivityMs");function J(s){const t=Math.floor(s/6e4);if(t<1)return`${Math.max(0,Math.floor(s/1e3))}s`;if(t<60)return`${t}m`;const n=Math.floor(t/60),a=t%60;return a>0?`${n}h ${a}m`:`${n}h`}i(J,"formatSilence");function zt(s){return!!s.currentToolName&&!/^finished\b/i.test(s.currentStatusMessage??"")}i(zt,"toolInFlight");function ve(s,t){const n=ge(s.startedAt);if(n===null||s.status==="queued"||s.status==="scheduled_retry")return{health:"starting",label:"Queued",silentMs:null};const a=Q(s);if(a===null&&t-n<Dt)return{health:"starting",label:"Starting",silentMs:null};const l=Math.max(0,t-(a??n)),o=s.outputSilence?.level,r=s.outputSilence?.criticalThresholdMs||Ft;return o==="critical"||o!=="snoozed"&&l>=r?{health:"stalled",label:`Stalled ${J(l)}`,silentMs:l}:o==="suspicious"||l>=$t?{health:"quiet",label:`Quiet ${J(l)}`,silentMs:l}:zt(s)?{health:"active",label:"Working",silentMs:l}:{health:"thinking",label:"Thinking",silentMs:l}}i(ve,"classifyLiveNowHealth");function be(s){return s.reduce((t,n)=>ie[n.health]>ie[t.health]?n:t)}i(be,"mostSevereSignal");function Ot(s){const t={working:0,quiet:0,stalled:0};for(const n of s)n==="quiet"?t.quiet+=1:n==="stalled"?t.stalled+=1:t.working+=1;return t}i(Ot,"countLiveNowHealth");function re(s){const t=s.currentToolName?.trim()||null,n=(s.currentStatusMessage?.trim()||null)??(t?ae(t).verbLabel:null);return n?{icon:t?ae(t).icon:ut(n)??it,text:n}:null}i(re,"describeLiveActivity");var e=ue(Me(),1);function we(s,t){return s instanceof Error&&s.message?s.message:t}i(we,"errorMessage");function Ut({companyId:s,entry:t,issue:n,loadFailed:a,ancestors:l,truncatedAncestors:o,issueLinkState:r,now:c,hiddenOnWide:d=!1}){const p=te(),v=(0,f.useId)(),[w,k]=(0,f.useState)(!1),[S,x]=(0,f.useState)(!1),[q,_]=(0,f.useState)(null),A=n?.identifier??t.issueId,b=n?.identifier??t.issueId.slice(0,8),$=n?.title??(a?"Task unavailable":"Loading task…"),M=n?$e(r,n):void 0,R=ne(A),g=t.runs[0],u=t.runs.map(h=>ve(h,c)),m=be(u),I=u[0],j=t.runs.reduce((h,O)=>(Q(O)??0)>(Q(h)??0)?O:h,g),T=re(j)??t.runs.map(re).find(Boolean)??null,C=Q(j),V=t.runs.find(h=>h.lastAssistantSnippet?.trim())?.lastAssistantSnippet?.trim()??null,F=t.runs.find(h=>h.nextAction?.trim())?.nextAction?.trim()??null,z=[...new Map(t.runs.slice(1).filter(h=>h.agentId!==g.agentId).map(h=>[h.agentId,h])).values()],W=t.earliestStartedAt?ye(Math.max(0,c-new Date(t.earliestStartedAt).getTime())):"Queued",N=`/agents/${g.agentId}/runs/${g.id}`,L=T?.icon??null,P=se({mutationFn:i(()=>pe.cancel(g.id),"mutationFn"),onSuccess:i(()=>{_(`Stopping ${g.agentName}'s run`),p.invalidateQueries({queryKey:y.liveRuns(s)}),p.invalidateQueries({queryKey:y.issues.liveRuns(t.issueId)}),p.invalidateQueries({queryKey:y.issues.activeRun(t.issueId)}),p.invalidateQueries({queryKey:y.issues.runs(t.issueId)})},"onSuccess")}),ke=t.runs.map(h=>h.id),Ne=i(()=>{_(null),k(h=>!h)},"openComposer");return(0,e.jsxs)("li",{"data-live-now-issue-id":t.issueId,"data-live-health":m.health,className:E("live-now-card relative flex w-(--live-now-card-peek) shrink-0 snap-start flex-col overflow-hidden rounded-xl border border-line bg-bg-2 text-ink sm:w-auto",d&&"sm:hidden"),children:[m.health==="active"||m.health==="starting"?(0,e.jsx)("span",{"aria-hidden":"true",className:"live-now-sweep"}):null,(0,e.jsxs)("div",{className:"flex items-start gap-3 px-3 pt-3",children:[(0,e.jsxs)("span",{className:"relative shrink-0",children:[(0,e.jsx)(Y,{agent:{id:g.agentId,name:g.agentName,appearance:g.agentAppearance,avatarUrl:g.avatarUrl},size:40,pose:xe[I.health]}),(0,e.jsx)("span",{"aria-hidden":"true",className:E("live-now-health-dot absolute right-0 bottom-0 size-2.5 rounded-full ring-2 ring-bg-2",(m.health==="active"||m.health==="thinking")&&"live-now-breathe")})]}),(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)("span",{title:g.agentName,className:"truncate text-sm font-semibold",children:g.agentName}),z.length>0?(0,e.jsx)("span",{className:"flex shrink-0 items-center","data-slot":"tasks-live-now-other-agents",children:z.map(h=>(0,e.jsx)("span",{title:h.agentName,className:"-ml-1 rounded-full bg-bg-2 ring-2 ring-bg-2 first:ml-0",children:(0,e.jsx)(Y,{agent:{id:h.agentId,name:h.agentName,appearance:h.agentAppearance},size:20,label:h.agentName})},h.agentId))}):null,(0,e.jsx)("time",{dateTime:t.earliestStartedAt??t.latestStartAt,title:"Time since the run started",className:"ml-auto shrink-0 font-mono text-xs tabular-nums text-ink-3",children:W})]}),(0,e.jsxs)("span",{"data-slot":"tasks-live-now-health",className:"live-now-health-pill mt-1 inline-flex max-w-full items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium text-ink",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"live-now-health-dot size-1.5 shrink-0 rounded-full"}),(0,e.jsx)("span",{className:"truncate",children:m.label})]}),g.modelFallback?(0,e.jsx)(Kt,{adapterType:g.adapterType,fallback:g.modelFallback}):null]})]}),(0,e.jsxs)("div",{className:"mt-3 px-3",children:[l.length>0||o?(0,e.jsxs)("nav",{"aria-label":"Parent tasks","data-slot":"tasks-live-now-path",className:"mb-0.5 flex min-w-0 items-center gap-1 overflow-hidden whitespace-nowrap text-xs text-ink-3",children:[o?(0,e.jsx)("span",{"aria-hidden":"true",children:"… ›"}):null,l.map((h,O)=>(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[O>0?(0,e.jsx)("span",{"aria-hidden":"true",children:"›"}):null,(0,e.jsx)(U,{to:ne(h.identifier??h.id),title:h.title,className:"truncate font-mono text-ink-3 no-underline hover:text-ink hover:underline",children:h.identifier??h.id.slice(0,8)})]},h.id)),(0,e.jsx)("span",{"aria-hidden":"true",children:"›"})]}):null,(0,e.jsxs)(U,{to:R,state:M,issuePrefetch:n,disableIssueQuicklook:!0,onClickCapture:M?()=>Re(A,M):void 0,className:"line-clamp-2 rounded-sm text-sm leading-5 font-medium text-ink no-underline outline-none hover:underline focus-visible:ring-2 focus-visible:ring-focus",children:[(0,e.jsx)("span",{className:"mr-1.5 font-mono text-xs font-normal text-ink-3",children:b}),$]})]}),(0,e.jsx)("blockquote",{"data-slot":"tasks-live-now-snippet",className:"live-now-quote mx-3 mt-2.5 line-clamp-2 min-h-10 border-l-2 pl-2.5 text-sm leading-5 text-ink-3",children:V??(F?`Next: ${F}`:m.health==="starting"?"Warming up…":"No message yet")}),(0,e.jsxs)("div",{"data-slot":"tasks-live-now-status",className:"mx-3 mt-2 flex h-5 min-w-0 items-center gap-1.5 text-xs text-ink-3",children:[L?(0,e.jsx)(L,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):null,(0,e.jsx)("span",{className:"min-w-0 truncate",children:T?.text??"Waiting for the first event"}),C!==null?(0,e.jsxs)("span",{className:"ml-auto shrink-0 tabular-nums",children:[J(Math.max(0,c-C))," ago"]}):null]}),(0,e.jsx)(qt,{issueId:t.issueId,runIds:ke}),w?(0,e.jsx)(Qt,{id:v,issueId:t.issueId,agentName:g.agentName,identifier:b,onSent:i(h=>{k(!1),_(h)},"onSent"),onCancel:i(()=>k(!1),"onCancel")}):null,q||P.error?(0,e.jsx)("p",{role:P.error?"alert":"status",className:E("mx-3 mt-2 text-xs",P.error?"text-bad":"text-ink-3"),children:P.error?we(P.error,"Couldn’t stop the run."):q}):null,(0,e.jsx)("div",{className:"mt-auto pt-2.5",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-0.5 border-t border-line px-1.5 py-1.5",children:[(0,e.jsxs)(U,{to:R,state:M,disableIssueQuicklook:!0,"aria-label":`Open ${b}`,className:X({variant:"ghost",size:"xs"}),children:[(0,e.jsx)(rt,{"aria-hidden":"true"}),"Open"]}),(0,e.jsxs)(U,{to:N,"aria-label":`Run transcript for ${g.agentName}`,className:X({variant:"ghost",size:"xs"}),children:[(0,e.jsx)(ht,{"aria-hidden":"true"}),"Run"]}),(0,e.jsxs)(D,{type:"button",variant:"ghost",size:"xs","aria-expanded":w,"aria-controls":w?v:void 0,"aria-label":`Steer ${g.agentName} on ${b}`,onClick:Ne,children:[(0,e.jsx)(qe,{"aria-hidden":"true"}),"Steer"]}),(0,e.jsx)(_t,{className:"ml-auto",issueId:t.issueId,run:g,companyId:s,taskLabel:b}),(0,e.jsxs)(D,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:P.isPending,"aria-label":`Stop ${g.agentName}'s run on ${b}`,onClick:i(()=>x(!0),"onClick"),children:[(0,e.jsx)(pt,{"aria-hidden":"true",className:"fill-current"}),P.isPending?"Stopping…":"Stop"]})]})}),(0,e.jsx)(Ze,{open:S,onOpenChange:x,children:(0,e.jsxs)(Ve,{children:[(0,e.jsxs)(Xe,{children:[(0,e.jsxs)(Be,{children:["Stop ",g.agentName,"'s run?"]}),(0,e.jsxs)(Qe,{children:[b," keeps its status and comments. The agent stops mid-turn, so any unsaved work in this run is lost."]})]}),(0,e.jsxs)(He,{children:[(0,e.jsx)(Ge,{children:"Keep running"}),(0,e.jsx)(We,{className:X({variant:"danger"}),onClick:i(()=>{_(null),P.mutate()},"onClick"),children:"Stop run"})]})]})})]})}i(Ut,"LiveNowCard");function Kt({adapterType:s,fallback:t}){const n=kt(s)?.fields.find(a=>a.key==="model")?.options??[];return(0,e.jsxs)("span",{"data-slot":"live-now-model-fallback",title:`${t.activeModel} (primary ${t.primaryModel})`,className:"ml-1.5 mt-1 inline-flex max-w-full items-start gap-1.5 rounded-md border border-amber-500/25 bg-amber-500/10 px-2 py-1 text-left text-xs font-medium leading-snug text-amber-800 dark:text-amber-200",children:[(0,e.jsx)(ft,{"aria-hidden":"true",className:"mt-0.5 size-3.5 shrink-0 text-amber-500 dark:text-amber-400"}),(0,e.jsxs)("span",{className:"min-w-0 whitespace-normal break-words",children:[It(Rt(t.activeModel,n)),(0,e.jsxs)("span",{className:"text-ink-3",children:[" · primary: ",Et(t.reason)]})]})]})}i(Kt,"LiveNowModelFallbackPill");function Qt({id:s,issueId:t,agentName:n,identifier:a,onSent:l,onCancel:o}){const r=te(),[c,d]=(0,f.useState)(""),p=`${s}-field`,v=se({mutationFn:i(x=>B.addComment(t,x,void 0,void 0,void 0,crypto.randomUUID(),"steer"),"mutationFn"),onSuccess:i(x=>{r.invalidateQueries({queryKey:y.issues.comments(t)}),l(at(x)??(x?.deliveredAs==="steered"?`Steered into ${n}'s turn`:`Sent to ${n}`))},"onSuccess")}),w=c.trim(),k=i(x=>{x?.preventDefault(),!(!w||v.isPending)&&v.mutate(w)},"submit"),S=i(x=>{x.key==="Escape"?(x.preventDefault(),o()):x.key==="Enter"&&!x.shiftKey&&!x.nativeEvent.isComposing&&k(x)},"onKeyDown");return(0,e.jsxs)("form",{id:s,"data-slot":"tasks-live-now-steer",className:"mx-3 mt-3 space-y-2",onSubmit:k,children:[(0,e.jsxs)("label",{htmlFor:p,className:"sr-only",children:["Steer ",n," on ",a]}),(0,e.jsx)(St,{id:p,rows:2,autoFocus:!0,value:c,placeholder:`Steer ${n}…`,className:"min-h-14 resize-none text-sm",disabled:v.isPending,onChange:i(x=>d(x.target.value),"onChange"),onKeyDown:S}),v.error?(0,e.jsx)("p",{role:"alert",className:"text-xs text-bad",children:we(v.error,"Couldn’t send the message.")}):null,(0,e.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,e.jsx)("span",{className:"mr-auto text-xs text-ink-3",children:"Enter to send · Esc to cancel"}),(0,e.jsx)(D,{type:"button",variant:"ghost",size:"xs",onClick:o,children:"Cancel"}),(0,e.jsx)(D,{type:"submit",size:"xs",disabled:!w||v.isPending,children:v.isPending?"Sending…":"Send"})]})]})}i(Qt,"LiveNowSteerForm");var Bt=3e4,le=6,Vt=5,oe=2;function Z(s){return s.startedAt??s.createdAt}i(Z,"runStartAt");function K(s){const t=new Date(s).getTime();return Number.isFinite(t)?t:0}i(K,"timestampMs");function Wt(s,t){const n=new Map;for(const l of s??[]){if(!l.issueId||!fe(l,t.get(l.issueId)))continue;const o=n.get(l.issueId);o?o.push(l):n.set(l.issueId,[l])}const a=[];for(const[l,o]of n){o.sort((c,d)=>K(Z(d))-K(Z(c)));const r=o.filter(c=>c.startedAt!==null);a.push({issueId:l,runs:o,latestStartAt:Z(o[0]),earliestStartedAt:r.length>0?r[r.length-1].startedAt:null})}return a.sort((l,o)=>K(o.latestStartAt)-K(l.latestStartAt))}i(Wt,"buildLiveNowEntries");function ce(s,t,n){const a=[],l=new Set;let o=s?.parentId??null,r=!1;for(;o&&!l.has(o);){l.add(o);const c=t.get(o);if(!c){r=!0;break}a.push({id:c.id,identifier:c.identifier??null,title:c.title}),o=c.parentId??null}return r?n?{ancestors:[...n].reverse().map(({id:c,identifier:d,title:p})=>({id:c,identifier:d,title:p})),complete:!0}:{ancestors:a.reverse(),complete:!1}:{ancestors:a.reverse(),complete:!0}}i(ce,"resolveLiveNowParentPath");function ee(s){return`wardmote:tasks-live-now:collapsed:${s}`}i(ee,"liveNowCollapsedStorageKey");function Ht(s){try{return window.localStorage.getItem(ee(s))==="true"}catch{return!1}}i(Ht,"readCollapsed");function Gt(s,t){try{t?window.localStorage.setItem(ee(s),"true"):window.localStorage.removeItem(ee(s))}catch{return}}i(Gt,"writeCollapsed");function Xt(s){const t=(0,f.useRef)(!1);return(0,f.useLayoutEffect)(()=>{const n=s.current;if(!n||typeof ResizeObserver>"u")return;const a=Mt(n),l=a??window,o=i(()=>n.getBoundingClientRect().bottom-(a?a.getBoundingClientRect().top:0),"bottomBelowViewportTop");let r=o();const c=i(()=>{r=o()},"syncBottom"),d=new ResizeObserver(()=>{const p=o(),v=p-r,w=t.current;if(t.current=!1,!w&&v!==0&&r<=0){a?a.scrollTop+=v:window.scrollBy(0,v),c();return}r=p});return l.addEventListener("scroll",c,{passive:!0}),d.observe(n),()=>{d.disconnect(),l.removeEventListener("scroll",c)}},[s]),(0,f.useCallback)(()=>{t.current=!0},[])}i(Xt,"useAboveViewportResizeCompensation");function Zt({companyId:s,liveRuns:t,issues:n,issueLinkState:a}){const l=(0,f.useRef)(null),o=Xt(l),[r,c]=(0,f.useState)(()=>Ht(s)),d=(0,f.useMemo)(()=>new Map(n.map(u=>[u.id,u])),[n]),p=(0,f.useMemo)(()=>{const u=new Set;for(const m of t??[]){if(!m.issueId||u.has(m.issueId)||!fe(m))continue;const I=d.get(m.issueId);(!I||!ce(I,d).complete)&&u.add(m.issueId)}return[...u]},[t,d]),v=Pe({queries:p.map(u=>({queryKey:y.issues.detail(u),queryFn:i(()=>B.get(u),"queryFn"),staleTime:Bt,retry:!1}))}),{detailById:w,failedIds:k}=(0,f.useMemo)(()=>{const u=new Map,m=new Set;return v.forEach((I,j)=>{const T=p[j];I.data?u.set(T,I.data):I.isError&&m.add(T)}),{detailById:u,failedIds:m}},[p,v]),S=(0,f.useMemo)(()=>{const u=new Map;for(const m of t??[]){if(!m.issueId)continue;const I=d.get(m.issueId)?.status??w.get(m.issueId)?.status;I&&u.set(m.issueId,I)}return Wt(t,u)},[w,t,d]),x=Date.now();Lt(S.length>0&&!r);const[q,_]=(0,f.useState)(!1),A=(0,f.useId)(),b=S.map(u=>{const m=d.get(u.issueId)??w.get(u.issueId)??null;return{entry:u,issue:m,signal:be(u.runs.map(I=>ve(I,x))),identifier:m?.identifier??u.issueId.slice(0,8)}}).sort((u,m)=>+(m.signal.health==="stalled")-+(u.signal.health==="stalled")),$=Ot(b.map(u=>u.signal.health)),M=q?0:Math.max(0,b.length-le),R=Yt(b.map(u=>`${u.identifier} ${u.signal.health}`).join(`
2
2
  `)),g=i(()=>{const u=!r;o(),c(u),Gt(s,u)},"toggle");return(0,e.jsx)("div",{ref:l,"data-slot":"tasks-live-now",children:b.length>0?(0,e.jsxs)("section",{"aria-label":"Live now",className:"pb-4",children:[(0,e.jsxs)("button",{type:"button",className:E("flex w-full min-w-0 flex-wrap items-center gap-x-2 gap-y-1 rounded-xl border py-1.5 pl-1.5 pr-3 text-left outline-none hover:bg-bg-3/40 focus-visible:ring-2 focus-visible:ring-focus",r?"border-line bg-bg-2":"border-transparent"),"aria-expanded":!r,"aria-controls":r?void 0:A,onClick:g,children:[(0,e.jsx)("span",{className:"inline-flex w-4 shrink-0 items-center justify-center",children:(0,e.jsx)(ct,{className:E("h-3.5 w-3.5 shrink-0 text-ink-3 transition-transform",!r&&"rotate-90")})}),(0,e.jsx)(Tt,{}),(0,e.jsx)("span",{className:"shrink-0 text-sm font-semibold uppercase tracking-wide",children:"Live now"}),(0,e.jsx)("span",{"data-slot":"tasks-live-now-count",className:"text-xs tabular-nums text-ink-3",children:b.length}),r?(0,e.jsx)(es,{cards:b}):null,(0,e.jsx)(Jt,{counts:$})]}),r?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("ul",{id:A,className:"scrollbar-none mt-2 flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1 sm:grid sm:grid-cols-2 sm:overflow-visible sm:pb-0 xl:grid-cols-3",children:b.map(({entry:u,issue:m},I)=>{const{ancestors:j,complete:T}=ce(m,d,w.get(u.issueId)?.ancestors??null),C=j.slice(-3);return(0,e.jsx)(Ut,{companyId:s,entry:u,issue:m,loadFailed:k.has(u.issueId),ancestors:C,truncatedAncestors:!T||j.length>C.length,issueLinkState:a,now:x,hiddenOnWide:I>=b.length-M},u.issueId)})}),b.length>le?(0,e.jsx)("button",{type:"button",className:"mt-2 hidden rounded-md px-2 py-1 text-xs text-ink-3 outline-none hover:bg-bg-3/40 hover:text-ink focus-visible:ring-2 focus-visible:ring-focus sm:inline-flex","aria-controls":A,onClick:i(()=>_(u=>!u),"onClick"),children:q?"Show fewer":`Show ${M} more`}):null]}),(0,e.jsx)("p",{role:"status","aria-live":"polite",className:"sr-only","data-slot":"tasks-live-now-announcer",children:R})]}):null})}i(Zt,"TasksLiveNowSection");function Yt(s){const t=(0,f.useRef)(null),[n,a]=(0,f.useState)("");return(0,f.useEffect)(()=>{const l=new Map;for(const c of s?s.split(`
3
3
  `):[]){const[d,p]=c.split(" ");l.set(d,p)}const o=t.current;if(t.current=l,!o)return;const r=[];for(const[c,d]of l){const p=o.get(c);!p||p===d||(d==="stalled"||d==="quiet"?r.push(`${c} is ${d}`):(p==="stalled"||p==="quiet")&&r.push(`${c} is working again`))}r.length>0&&a(r.join(". "))},[s]),n}i(Yt,"useHealthAnnouncement");function Jt({counts:s}){const t=[{health:"stalled",count:s.stalled,text:"stalled"},{health:"quiet",count:s.quiet,text:"quiet"},{health:"active",count:s.working,text:"working"}].filter(a=>a.count>0),n=t.map(a=>`${a.count} ${a.text}`).join(", ");return(0,e.jsxs)("span",{"data-slot":"tasks-live-now-summary",className:"ml-auto flex shrink-0 items-center gap-2 text-xs text-ink-3 sm:gap-3",children:[(0,e.jsx)("span",{className:"sr-only",children:n}),t.map(a=>(0,e.jsxs)("span",{"aria-hidden":"true","data-live-health":a.health,className:E("items-center gap-1.5 tabular-nums",a.health==="active"?"hidden sm:inline-flex":"inline-flex"),children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"live-now-health-dot size-1.5 rounded-full"}),a.count," ",a.text]},a.health))]})}i(Jt,"LiveNowHealthSummary");function es({cards:s}){const t=new Map;for(const r of s)for(const c of r.entry.runs)t.has(c.agentId)||t.set(c.agentId,{run:c,health:r.signal.health});const n=[...t.values()],a=n.slice(0,Vt),l=n.length-a.length,o=n.length-Math.min(n.length,oe);return(0,e.jsxs)("span",{"data-slot":"tasks-live-now-avatars",className:"flex shrink-0 items-center pl-1",children:[a.map(({run:r,health:c},d)=>(0,e.jsx)("span",{title:r.agentName,className:E("-ml-1.5 inline-flex rounded-full bg-bg-2 ring-2 ring-bg-2 first:ml-0",d>=oe&&"hidden sm:inline-flex"),children:(0,e.jsx)(Y,{agent:{id:r.agentId,name:r.agentName,appearance:r.agentAppearance},size:24,pose:xe[c]})},r.agentId)),o>0?(0,e.jsxs)("span",{"aria-hidden":"true",className:"ml-1 text-xs tabular-nums text-ink-3 sm:hidden",children:["+",o]}):null,l>0?(0,e.jsxs)("span",{"aria-hidden":"true",className:"ml-1 hidden text-xs tabular-nums text-ink-3 sm:inline",children:["+",l]}):null,(0,e.jsx)("span",{className:"sr-only",children:n.map(({run:r})=>r.agentName).join(", ")})]})}i(es,"LiveNowAvatarStrip");function ts({value:s,onChange:t,badgeCount:n}){const a=he(s);return(0,e.jsxs)(nt,{children:[(0,e.jsx)(tt,{asChild:!0,children:(0,e.jsxs)(D,{size:"sm",variant:"secondary",className:"h-8 gap-1.5","aria-label":`Change view — currently ${a.label}`,children:[(0,e.jsx)("span",{className:"max-w-(--sz-160px) truncate font-medium",children:a.label}),(0,e.jsx)(ot,{"aria-hidden":"true",className:"h-3.5 w-3.5 text-ink-3"})]})}),(0,e.jsx)(st,{align:"start",className:"w-(--sz-260px)",children:Fe.map((l,o)=>(0,e.jsxs)("div",{children:[o>0?(0,e.jsx)(Je,{}):null,(0,e.jsxs)(Ye,{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{children:l.label}),o===0&&n!=null&&n>0?(0,e.jsx)("span",{className:"rounded-full bg-accent px-1.5 text-(length:--text-nano) leading-tight text-accent-ink",children:n>99?"99+":n}):null]}),l.views.map(r=>{const c=r.key===s;return(0,e.jsxs)(et,{onSelect:i(()=>t(r.key),"onSelect"),className:"items-start gap-2","aria-current":c?"true":void 0,children:[(0,e.jsx)(lt,{"aria-hidden":"true",className:E("mt-0.5 size-3.5 shrink-0",c?"opacity-100":"opacity-0")}),(0,e.jsxs)("span",{className:"min-w-0",children:[(0,e.jsx)("span",{className:E("block truncate",c&&"font-medium"),children:r.label}),(0,e.jsx)("span",{className:"block text-(length:--text-nano) text-ink-3",children:r.hint})]})]},r.key)})]},l.label))})]})}i(ts,"TaskViewsMenu");var ss=1e3,Se=100,ns="task",as="collection";function is(s,t,n=Se){return s>=n?t+n:void 0}i(is,"getNextIssuesPageOffset");function rs(s){const t=new Set,n=[];for(const a of s)for(const l of a)t.has(l.id)||(t.add(l.id),n.push(l));return n}i(rs,"mergeIssuePagesStable");function ls(s,t){const n=new URL(s);return(n.searchParams.get("q")??"")===t?null:(t.length>0?n.searchParams.set("q",t):n.searchParams.delete("q"),`${n.pathname}${n.search}${n.hash}`)}i(ls,"buildIssuesSearchUrl");function os(s,t){const[n,a]=(0,f.useState)(null);return{syncedSearch:(0,f.useMemo)(()=>typeof window<"u"&&n?.locationSearch===window.location.search?n.search:s,[n,s,t]),handleSearchChange:(0,f.useCallback)(l=>{const o=ls(window.location.href,l);o&&window.history.replaceState(window.history.state,"",o),a({search:l,locationSearch:window.location.search})},[])}}i(os,"useIssuesSearchSync");function Hs(){const{enabled:s}=Ct();return s?(0,e.jsx)(cs,{}):(0,e.jsx)(Ie,{})}i(Hs,"Issues");function cs(){const s=Ue(),[t,n]=de(),{selectedCompanyId:a}=me(),{openNewIssue:l}=yt(),o=At(a),r=t.get(G),c=De.some(S=>(t.get(S)??"").length>0),[d]=(0,f.useState)(()=>Le()),p=Ke(r,c,d),v=he(p);(0,f.useEffect)(()=>{ze(r)!==p&&n(S=>{const x=new URLSearchParams(S);return x.set(G,p),x},{replace:!0})},[r,p,n]);const w=(0,f.useCallback)(S=>{Oe(S),s(`/issues?${G}=${S}`)},[s]),k=(0,e.jsx)(ts,{value:p,onChange:w,badgeCount:o.inbox});return v.surface==="inbox"?(0,e.jsx)(_e,{tab:v.inboxTab,surfaceLabel:"Tasks",toolbarContext:(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[k,(0,e.jsxs)(D,{size:"sm",variant:"secondary","aria-label":"New Task",onClick:i(()=>l(),"onClick"),children:[(0,e.jsx)(mt,{className:"h-4 w-4 sm:mr-1"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"New Task"})]})]})}):(0,e.jsx)(Ie,{toolbarContext:k,initialStatuses:v.statuses})}i(cs,"StreamlinedTasks");function Ie({toolbarContext:s,initialStatuses:t}={}){const n={rowPresentation:ns,toolbarPresentation:as},{selectedCompanyId:a}=me(),{setBreadcrumbs:l}=wt(),o=Te(),[r]=de(),c=te(),d=(0,f.useRef)(!1),{syncedSearch:p,handleSearchChange:v}=os(r.get("q")??"",o.search),w=r.get("participantAgentId")??void 0,k=r.getAll("workspace").filter(N=>N.length>0),S=k.length===1?k[0]:void 0,{data:x}=H({queryKey:y.agents.list(a),queryFn:i(()=>xt.list(a),"queryFn"),enabled:!!a}),{data:q}=H({queryKey:y.projects.list(a,{includeArchived:!0}),queryFn:i(()=>bt.list(a,{includeArchived:!0}),"queryFn"),enabled:!!a}),_=y.liveRuns(a),A=gt({companyId:a,resourceKey:"live-runs",queryKey:_,enabled:!!a,refetchInterval:!1,leaderOnly:!0}),{data:b,dataUpdatedAt:$}=H({queryKey:_,queryFn:i(()=>pe.liveRunsForCompany(a),"queryFn"),enabled:A.enabled,refetchInterval:A.refetchInterval});vt(A,b,$);const M=(0,f.useMemo)(()=>Ee("Tasks",`${o.pathname}${o.search}${o.hash}`,"issues"),[o.pathname,o.search,o.hash]);(0,f.useEffect)(()=>{l([{label:"Tasks"}])},[l]);const R=S?ss:Se,{data:g,isLoading:u,isFetchingNextPage:m,error:I,hasNextPage:j,fetchNextPage:T}=Ce({queryKey:[...y.issues.list(a),"participant-agent",w??"__all__","workspace",S??"__all__","compact","with-routine-executions","infinite",R],queryFn:i(({pageParam:N,signal:L})=>B.listCompact(a,{participantAgentId:w,workspaceId:S,includeRoutineExecutions:!0,limit:R,offset:N,sortField:"updated",sortDir:"desc"},{signal:L}),"queryFn"),initialPageParam:0,getNextPageParam:i((N,L,P)=>is(N.length,P,R),"getNextPageParam"),enabled:!!a,placeholderData:i(N=>N,"placeholderData")}),C=(0,f.useMemo)(()=>rs(g?.pages??[]),[g]),V=(0,f.useMemo)(()=>Nt(b,C),[C,b]),F=p.trim().length===0&&j===!0,z=(0,f.useCallback)(()=>{!j||m||d.current||(d.current=!0,T({cancelRefetch:!1}).finally(()=>{d.current=!1}))},[T,j,m]),W=se({mutationFn:i(({id:N,data:L})=>B.update(N,L),"mutationFn"),onSuccess:i(()=>{c.invalidateQueries({queryKey:y.issues.list(a)})},"onSuccess")});return a?(0,e.jsx)(Pt,{issues:C??[],isLoading:u,isLoadingMoreIssues:m,error:I,agents:x,projects:q,liveIssueIds:V,liveRuns:b,viewStateKey:"wardmote:issues-view",rowPresentation:n.rowPresentation,toolbarPresentation:n.toolbarPresentation,issueLinkState:M,initialAssignees:r.get("assignee")?[r.get("assignee")]:void 0,initialWorkspaces:k.length>0?k:void 0,initialStatuses:t,toolbarContext:s,listHeader:(0,e.jsx)(Zt,{companyId:a,liveRuns:b,issues:C,issueLinkState:M},a),initialSearch:p,onSearchChange:v,enableRoutineVisibilityFilter:!0,hasMoreIssues:F,onLoadMoreIssues:z,onUpdateIssue:i((N,L)=>W.mutate({id:N,data:L}),"onUpdateIssue"),searchFilters:w||S?{participantAgentId:w,workspaceId:S}:void 0}):(0,e.jsx)(jt,{icon:dt,message:"Select an organization to view tasks."})}i(Ie,"OrganizationIssues");export{Hs as Issues};
@@ -1 +1 @@
1
- var i=Object.defineProperty;var a=(e,o)=>i(e,"name",{value:o,configurable:!0});import{i as r}from"./rolldown-runtime-ZpX3ckPj.js";import{l as m,ta as l}from"./createLucideIcon-DJi9suAC.js";import{t as u}from"./list-todo-BmObdeVq.js";import{a as d,n as x}from"./AgentTodoCard-DRXZ7hmU.js";var s=r(l(),1);function _({issueId:e,runIds:o,className:n="mx-3 mt-1.5"}){const{data:t}=d(e);return!t||!o.includes(t.runId)?null:(0,s.jsxs)("div",{"data-slot":"tasks-live-now-todo",className:m("flex h-5 min-w-0 items-center gap-1.5 text-xs text-ink-3",n),role:"group","aria-label":"Agent todo",children:[(0,s.jsx)(u,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),(0,s.jsx)(x,{snapshot:t,className:"flex-1 text-xs text-ink"}),(0,s.jsx)("span",{className:"shrink-0 font-medium tabular-nums",children:`${t.counts.completed}/${t.counts.total}`})]})}a(_,"LiveNowTodoLine");export{_ as t};
1
+ var i=Object.defineProperty;var a=(e,o)=>i(e,"name",{value:o,configurable:!0});import{i as r}from"./rolldown-runtime-ZpX3ckPj.js";import{l as m,ta as l}from"./createLucideIcon-DJi9suAC.js";import{t as u}from"./list-todo-BmObdeVq.js";import{a as d,n as x}from"./AgentTodoCard-BvgkWD0T.js";var s=r(l(),1);function _({issueId:e,runIds:o,className:n="mx-3 mt-1.5"}){const{data:t}=d(e);return!t||!o.includes(t.runId)?null:(0,s.jsxs)("div",{"data-slot":"tasks-live-now-todo",className:m("flex h-5 min-w-0 items-center gap-1.5 text-xs text-ink-3",n),role:"group","aria-label":"Agent todo",children:[(0,s.jsx)(u,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),(0,s.jsx)(x,{snapshot:t,className:"flex-1 text-xs text-ink"}),(0,s.jsx)("span",{className:"shrink-0 font-medium tabular-nums",children:`${t.counts.completed}/${t.counts.total}`})]})}a(_,"LiveNowTodoLine");export{_ as t};
@@ -1 +1 @@
1
- var me=Object.defineProperty;var a=(s,t)=>me(s,"name",{value:t,configurable:!0});import{i as ie}from"./rolldown-runtime-ZpX3ckPj.js";import{h as J,i as he,l as M,na as xe,t as pe,ta as fe,v as re}from"./createLucideIcon-DJi9suAC.js";import{n as ge,t as je}from"./star-BZgQbzhV.js";import{X as ve,_ as O,v as K}from"./queryKeys-DYV5MhM_.js";import{a as be,b as q,c as ye,h as ke,i as Ne,o as Ce,r as Se,s as Ie,t as $e}from"./connection-identity-YKZfppDS.js";import{E as B,T as De,o as ze,t as Ue}from"./router-2UfGeejU.js";import{a as Ae,c as Re,i as _e,n as Me,o as Pe,r as Te,s as Ge,t as Le}from"./alert-dialog-Blls2GnU.js";import{t as Fe}from"./checkbox-BHQhs41k.js";import{o as He,r as Ee,t as Be}from"./popover-BhYHYj7q.js";import{t as Oe}from"./chevron-right-s7L6hXXq.js";import{r as E,t as g}from"./button-CMwV3L1P.js";import{t as Q}from"./refresh-cw-B_Oki9wZ.js";import{t as qe}from"./triangle-alert-CBVKiaXB.js";import{t as ee}from"./user-round-CGxsJ0K8.js";import{t as X}from"./Identity-Cv_2a9qJ.js";import{t as We}from"./heartbeats-DOyojsaN.js";import{a as Ve,i as Ke,n as Ye,r as we,s as Je,t as Qe}from"./dialog-CKUblzlR.js";import{t as Xe}from"./input-DobnTAyB.js";import{t as Z}from"./skeleton-Bv_lQagE.js";import{t as se}from"./tools-B-L_sU_9.js";import{t as Ze}from"./github-icon-Bbgf67tg.js";import{t as le}from"./InlineBanner-VQ5mstsR.js";import{t as oe}from"./radio-card-DVZaXlw0.js";import{_a as es}from"./index-DDoARkPG.js";import{t as ss}from"./QuotaBar-_ok6Pek4.js";function ts(s,t){return t==="subscription"?s==="openai"||s==="anthropic"||s==="xai":s==="openrouter"}a(ts,"supportsAiConnectionUsage");var ce={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};ce.node;var as=pe(ce),j=ie(xe(),1),e=ie(fe(),1);function H(s){return s.name?.trim()||s.email?.trim()||s.userId}a(H,"memberOptionLabel");function ns({members:s,selectedUserIds:t,onChange:l,onSave:n,loading:o=!1,disabled:r=!1,pending:u=!1,getDescription:m,triggerLabel:p,triggerVariant:f="secondary",triggerSize:d="default",triggerFullWidth:x=!0,triggerClassName:k,contentAlign:c="start",emptyMessage:C="No members yet.",showSelectionPreview:S=!0,filterPlaceholder:U="Filter people",onOpenChange:D}){const[A,P]=(0,j.useState)(!1),[b,R]=(0,j.useState)(""),[_,T]=(0,j.useState)(new Set(t)),h=!!n,N=h?_:t;(0,j.useEffect)(()=>{A&&h&&T(new Set(t))},[A,t,h]);const I=b.trim().toLowerCase(),z=(0,j.useMemo)(()=>s.filter(i=>{const v=m?.(i)??i.email??"";return`${H(i)} ${v}`.toLowerCase().includes(I)}).sort((i,v)=>{const F=N.has(i.userId);return F!==N.has(v.userId)?F?-1:1:H(i).localeCompare(H(v))}),[s,m,I,N]),G=t.size,y=s.filter(i=>t.has(i.userId));function L(i){h?T(i):l?.(i)}return a(L,"setSelection"),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(Be,{open:A,onOpenChange:a(i=>{P(i),D?.(i),i||R("")},"onOpenChange"),children:[(0,e.jsx)(He,{asChild:!0,children:(0,e.jsxs)(g,{type:"button",variant:f,size:d,className:M("justify-between",x&&"w-full",k),disabled:r||u,children:[(0,e.jsx)("span",{className:"flex min-w-0 items-center",children:(0,e.jsx)("span",{className:"truncate",children:p??(G===0?"Select people":`${G} ${G===1?"person":"people"} selected`)})}),(0,e.jsx)(Oe,{className:"h-4 w-4 shrink-0 text-ink-3"})]})}),(0,e.jsxs)(Ee,{className:"w-80 p-0",align:c,children:[(0,e.jsx)("div",{className:"border-b border-line p-3",children:(0,e.jsx)(Xe,{value:b,onChange:a(i=>R(i.target.value),"onChange"),placeholder:U,className:"h-8",autoFocus:!0})}),o?(0,e.jsxs)("div",{className:"space-y-2 p-3",children:[(0,e.jsx)(Z,{className:"h-6 w-full"}),(0,e.jsx)(Z,{className:"h-6 w-full"})]}):s.length===0?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-ink-3",children:C}):(0,e.jsxs)("div",{className:"max-h-60 overflow-y-auto py-1",children:[z.map(i=>{const v=H(i),F=m?.(i)??(i.email&&i.email!==v?i.email:null);return(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 px-3 py-2 hover:bg-bg-3/30",children:[(0,e.jsx)(Fe,{checked:N.has(i.userId),"aria-label":`Allow ${v}`,onCheckedChange:a(ue=>{const V=new Set(N);ue?V.add(i.userId):V.delete(i.userId),L(V)},"onCheckedChange")}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)(X,{name:v,avatarUrl:i.image??null,size:"sm"}),F?(0,e.jsx)("span",{className:"truncate text-xs text-ink-3",children:F}):null]})]},i.userId)}),z.length===0?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-ink-3",children:"No matches."}):null]}),(0,e.jsxs)("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[(0,e.jsx)("span",{className:"text-xs text-ink-3","aria-live":"polite",children:N.size===0?"No people selected":`${N.size} selected`}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[h?(0,e.jsx)(g,{type:"button",variant:"ghost",size:"sm",onClick:a(()=>P(!1),"onClick"),disabled:u,children:"Cancel"}):null,(0,e.jsx)(g,{type:"button",size:"sm",onClick:a(()=>{h&&n?.(_),P(!1)},"onClick"),disabled:u,children:h?u?"Saving…":"Save":"Done"})]})]})]})]}),S&&y.length>0?(0,e.jsxs)("div",{className:"space-y-0.5",children:[y.slice(0,3).map(i=>(0,e.jsx)("div",{className:"flex items-center gap-2 px-1.5 py-1 text-sm",children:(0,e.jsx)(X,{name:H(i),avatarUrl:i.image??null,size:"sm"})},i.userId)),y.length>3?(0,e.jsxs)("p",{className:"px-1.5 pt-0.5 text-xs text-ink-3",children:["and ",y.length-3," more"]}):null]}):null]})}a(ns,"MemberMultiSelect");var is={connected:B.green,attention:B.amber,inactive:B.gray,missing:B.gray};function de({status:s}){const t=be(s);return(0,e.jsx)("span",{className:M("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-xs font-medium",is[t]),children:Ne(s)})}a(de,"StatusText");function Hs({appName:s,credentialPolicy:t,ownerUserId:l,connectedUser:n,dedicatedAgent:o,grantsQuery:r,loading:u,error:m,onConnectAsMe:p,onConnectOrganization:f,onConnectAgent:d,onRefreshAccess:x,refreshAccessPending:k=!1,onReplaceAudience:c,connectPending:C,audiencePending:S,audienceError:U,audienceGrantId:D,onOpenAudience:A,onCloseAudience:P}){const b=r?.grants??[],R=r?.capabilities,_=r?.currentUserId??null,T=r?.members??[],h=(0,j.useMemo)(()=>Ie(b),[b]),N=(0,j.useMemo)(()=>ye(b,_),[b,_]),I=(0,j.useMemo)(()=>{const i=b.filter(v=>v.kind==="user");return i.find(v=>v.subjectUserId===l)??N??i.find(v=>v.status==="active")??i[0]??null},[b,N,l]),z=(0,j.useMemo)(()=>b.find(i=>i.kind==="agent"&&i.subjectAgentId===o?.id)??b.find(i=>i.kind==="agent")??null,[o?.id,b]),G=Ce(T,I?.subjectUserId??l??_),y=t==="per_user"||t==="per_user_with_fallback"&&!!N,L=D?b.find(i=>i.id===D)??null:null;if(u)return(0,e.jsxs)("section",{className:"space-y-5","aria-busy":"true",children:[(0,e.jsx)(Y,{}),(0,e.jsx)(Z,{className:"h-14 w-full"})]});if(m)return(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)(Y,{}),(0,e.jsx)(le,{tone:"warning",compact:!0,children:"We couldn't load who this connection acts as. Reload the page to try again."})]});if(t==="per_agent"){const i=z?.providerTenant?.github;return(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold text-ink",children:"GitHub identity"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This agent uses this GitHub account for everyone’s work, instead of the person giving instructions."}),(0,e.jsx)(w,{title:i?`@${i.login}`:"Dedicated GitHub account",status:z?.status??null,detail:o?(0,e.jsxs)(Ue,{to:he(o),className:"transition-colors hover:text-ink hover:underline",children:["Used only by ",o.name]}):"Dedicated to one agent",actions:!z&&o&&R?.canConfigure?(0,e.jsxs)(g,{size:"sm",disabled:C,onClick:a(()=>d(o.id),"onClick"),children:[C?(0,e.jsx)(E,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Connect dedicated account"]}):null}),i?(0,e.jsx)(te,{grant:z,onRefreshAccess:x,refreshPending:k}):null]})}return(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)(Y,{}),(0,e.jsx)(rs,{personal:y,restricted:!y&&!!h?.members?.length,connectedName:y?G??n?.label??null:null,connectedImage:y?n?.image??null:null,status:(y?I:h)?.status??null,canEditAudience:h?.capabilities?.canEditAudience??!1,onChooseAll:a(()=>{h&&c(h,[])},"onChooseAll"),onChooseSelected:a(()=>{h&&A(h.id)},"onChooseSelected")}),(y?I:h)?.providerTenant?.github?(0,e.jsx)(te,{grant:y?I:h,onRefreshAccess:x,refreshPending:k}):null,(0,e.jsx)("div",{children:y?I?null:(0,e.jsx)(w,{id:"personal-identity",title:"Personal account",status:null,detail:"Personal identity",actions:R?.canConnectAsCurrentUser?(0,e.jsxs)(g,{size:"sm",disabled:C,onClick:p,children:[C?(0,e.jsx)(E,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Connect as me"]}):null}):h?h.capabilities?.canEditAudience?(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(g,{size:"sm",variant:"secondary",onClick:a(()=>A(h.id),"onClick"),children:"Manage access"})}):null:(0,e.jsx)(w,{title:"Organization account",status:null,detail:"Organization identity",actions:R?.canCreateOrganizationGrant?(0,e.jsx)(g,{size:"sm",disabled:C,onClick:f,children:"Connect organization identity"}):null})}),L?(0,e.jsx)(ls,{appName:s,grant:L,members:T,pending:S,error:U,onCancel:P,onSave:a(i=>c(L,i),"onSave")}):null]})}a(Hs,"IdentitiesSection");function te({grant:s,onRefreshAccess:t,refreshPending:l}){const n=s.providerTenant?.github;if(!n)return null;const o=n.appSlug?`https://github.com/apps/${encodeURIComponent(n.appSlug)}/installations/new`:/^https:\/\/github\.com\/apps\/[a-z0-9-]+\/installations\/new$/.test(n.installationUrl??"")?n.installationUrl:null,r=n.repositorySelection==="all"?"All current and future repositories":n.repositorySelection==="mixed"?"Mixed access; scope varies by installation":null,u=n.repositorySelection==="none"?"No repositories selected":`${n.repositoryCount} selected ${n.repositoryCount===1?"repository":"repositories"}`;return(0,e.jsxs)("div",{className:"divide-y divide-line border-y border-line",children:[(0,e.jsxs)("div",{className:"py-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"GitHub account"}),(0,e.jsxs)("a",{className:"text-sm text-ink-3 hover:underline",href:`https://github.com/${encodeURIComponent(n.login)}`,target:"_blank",rel:"noreferrer",children:["@",n.login]})]}),(0,e.jsxs)("div",{className:"space-y-3 py-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Repositories"}),r?(0,e.jsxs)("div",{role:"note",className:M("mt-1 inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs",De.warning),children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),r]}):(0,e.jsx)("div",{className:"text-xs text-ink-3",children:u})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[t&&o?(0,e.jsx)(g,{size:"icon-sm",variant:"secondary","aria-label":"Refresh access",title:"Refresh access",disabled:l,onClick:t,children:l?(0,e.jsx)(E,{className:"animate-spin","aria-hidden":"true"}):(0,e.jsx)(Q,{"aria-hidden":"true"})}):null,o?(0,e.jsx)(g,{asChild:!0,size:"sm",variant:"secondary",children:(0,e.jsx)("a",{href:o,target:"_blank",rel:"noreferrer",children:"Add More Repos on GitHub"})}):t?(0,e.jsxs)(g,{size:"sm",variant:"secondary",disabled:l,onClick:t,children:[l?(0,e.jsx)(E,{className:"animate-spin","aria-hidden":"true"}):(0,e.jsx)(Q,{"aria-hidden":"true"}),"Load GitHub configuration"]}):null]})]}),n.repositories?n.repositories.length?(0,e.jsx)("ul",{"aria-label":"Accessible GitHub repositories",tabIndex:0,className:"max-h-(--sz-github-repository-list) space-y-2 overflow-y-auto text-sm",children:n.repositories.map(m=>(0,e.jsx)("li",{children:(0,e.jsxs)("a",{className:"flex items-center gap-2 text-ink-3 hover:underline",href:`https://github.com/${m.fullName.split("/").map(encodeURIComponent).join("/")}`,target:"_blank",rel:"noreferrer",children:[(0,e.jsx)(Ze,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{className:"break-all",children:m.fullName}),m.private===!0?(0,e.jsx)(ge,{className:"h-3 w-3 shrink-0",role:"img","aria-label":"Private repository"}):null]})},m.id))}):(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"No accessible repositories."}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Refresh access to load the current repository list."}),o?(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Missing an organization or repository? ",(0,e.jsx)("a",{href:o,target:"_blank",rel:"noreferrer",className:"text-ink hover:underline",children:"Configure access on GitHub"}),", then refresh this list."]}):null]})]})}a(te,"GitHubConnectionSummary");function Y(){return(0,e.jsx)("h2",{className:"text-sm font-semibold text-ink",children:"Which humans can use this credential?"})}a(Y,"IdentitiesHeading");function rs({personal:s,restricted:t,connectedName:l,connectedImage:n,status:o,canEditAudience:r,onChooseAll:u,onChooseSelected:m}){return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(oe,{ariaLabel:"Which humans can use this credential",value:s?"personal":t?"selected":"company",className:"sm:grid-cols-2",onValueChange:a(p=>{!r||s||(p==="company"&&u(),p==="selected"&&m())},"onValueChange"),options:s?[{value:"personal",title:"Just me",description:"Only you can use this connection.",icon:(0,e.jsx)(ee,{className:"h-4 w-4"})}]:[{value:"selected",title:"Humans I pick",description:"Only selected people in your company.",icon:(0,e.jsx)(ee,{className:"h-4 w-4"}),disabled:!r},{value:"company",title:"Any human in the company",description:"Anyone in your company can use this connection.",icon:(0,e.jsx)(as,{className:"h-4 w-4"}),disabled:!r}]}),l&&o!==null?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(X,{name:l,avatarUrl:n}),o==="active"?null:(0,e.jsx)(de,{status:o})]}):null]})}a(rs,"HumanAccessCards");function w({id:s,title:t,status:l,detail:n,actions:o}){return(0,e.jsxs)("div",{id:s,className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between sm:gap-8",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-ink",children:t}),l==="active"?null:(0,e.jsx)(de,{status:l})]}),n?(0,e.jsx)("div",{className:"mt-0.5 text-xs text-ink-3",children:n}):null]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:o})]})}a(w,"IdentityRow");function ls({appName:s,grant:t,members:l,pending:n,error:o,onCancel:r,onSave:u}){const m=(0,j.useMemo)(()=>$e(t),[t]),[p,f]=(0,j.useState)(m.size===0?"all":"selected"),[d,x]=(0,j.useState)(m);(0,j.useEffect)(()=>{x(m),f(m.size===0?"all":"selected")},[m]);const k=p==="all"||d.size>0;return(0,e.jsx)(Qe,{open:!0,onOpenChange:a(c=>{c||r()},"onOpenChange"),children:(0,e.jsxs)(Ye,{children:[(0,e.jsxs)(Ve,{children:[(0,e.jsx)(Je,{children:"Who can use this identity"}),(0,e.jsxs)(we,{children:[Se(t)," · ",s]})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(oe,{ariaLabel:"Who can use this identity",value:p,onValueChange:a(c=>f(c),"onValueChange"),options:[{value:"all",title:"All organization members",description:"Anyone in this organization can have work use this identity."},{value:"selected",title:"Selected members",description:"Only the people you choose."}]}),p==="selected"?(0,e.jsx)(ns,{members:l.map(c=>({userId:c.userId,name:c.name,email:c.email})),selectedUserIds:d,onChange:x,triggerLabel:d.size===0?"Choose people":`${d.size} ${d.size===1?"person":"people"} selected`}):null,(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"This controls whose work can use the identity. It does not change which agents have the connection."}),o?(0,e.jsx)(le,{tone:"warning",compact:!0,children:o}):null]}),(0,e.jsxs)(Ke,{children:[(0,e.jsx)(g,{variant:"ghost",onClick:r,disabled:n,children:"Cancel"}),(0,e.jsxs)(g,{disabled:n||!k,onClick:a(()=>u(p==="all"?[]:[...d]),"onClick"),children:[n?(0,e.jsx)(E,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save audience"]})]})]})})}a(ls,"AudienceDialog");function os({grant:s,providerName:t,pending:l,isOwnIdentity:n,credentialPolicy:o,description:r,children:u,onCancel:m,onConfirm:p}){const f=s.kind==="user",d=f?n?`Revoke your ${t} identity?`:`Revoke this ${t} identity?`:"Revoke the organization identity?";return(0,e.jsx)(Le,{open:!0,onOpenChange:a(x=>{x||m()},"onOpenChange"),children:(0,e.jsxs)(_e,{children:[(0,e.jsxs)(Ge,{children:[(0,e.jsx)(Re,{children:d}),(0,e.jsx)(Ae,{children:r??(f?n?"Agents will stop acting as you. Work that needs this identity can ask you to connect again.":"Agents will stop acting as this person. They can connect again themselves; no one else can do it for them.":o==="per_user"?"Installed agents lose this shared identity immediately.":"Eligible members and installed agents will lose this shared identity immediately.")})]}),u,(0,e.jsxs)(Pe,{children:[(0,e.jsx)(Te,{disabled:l,autoFocus:!0,children:"Cancel"}),(0,e.jsx)(Me,{disabled:l,onClick:a(x=>{x.preventDefault(),p()},"onClick"),children:"Revoke identity"})]})]})})}a(os,"RevokeGrantDialog");function cs({account:s,grant:t,currentUserId:l,readOnly:n,onMakeDefault:o,onReconnect:r,onRevoke:u,revocationDetails:m}){const[p,f]=(0,j.useState)(!1),[d,x]=(0,j.useState)(!1),[k,c]=(0,j.useState)(),C=s.ownership==="personal"&&s.ownerUserId===l,S=s.status==="connected",U=s.isDefault&&S;return(0,e.jsxs)("section",{className:"space-y-4","aria-label":"AI account settings",children:[C&&!s.routing&&(0,e.jsxs)("div",{className:M("flex flex-wrap items-center justify-between gap-3 rounded-lg border border-line p-3",U&&"border-(--status-task-done)/30 bg-(--status-task-done)/5"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(je,{"aria-hidden":!0,className:M("size-5 shrink-0",U?"fill-current text-(--status-task-icon-done)":"text-ink-3")}),(0,e.jsx)("h3",{role:s.isDefault?"status":void 0,className:M("text-sm font-semibold",s.isDefault&&!S&&"text-bad"),children:s.isDefault&&!S?"Default unavailable":"Personal default"})]}),!s.isDefault&&(n?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Not default"}):(0,e.jsx)(g,{variant:"secondary",size:"sm",disabled:!S,onClick:o,children:"Make default"}))]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"min-w-0 text-sm",children:(0,e.jsxs)("p",{className:"break-words text-xs text-ink-3",children:[s.method==="subscription"?"Subscription":"API key",s.accountLabel?` · ${s.accountLabel}`:""]})}),!n&&t.capabilities?.canRevoke&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(g,{variant:"secondary",size:"sm",onClick:r,children:[(0,e.jsx)(Q,{className:"size-4","aria-hidden":!0}),"Reconnect"]}),s.status!=="revoked"&&(0,e.jsxs)(g,{variant:"danger",size:"sm",onClick:a(()=>f(!0),"onClick"),children:[(0,e.jsx)(es,{className:"size-4","aria-hidden":!0}),"Revoke identity"]})]})]}),p&&(0,e.jsxs)(os,{grant:t,providerName:s.name,pending:d,credentialPolicy:s.ownership==="shared"?"shared":"per_user",isOwnIdentity:s.ownerUserId===l,description:"New runs using this account will be blocked. Existing runs may retain credentials already issued to them. No other account will be selected automatically.",onCancel:a(()=>f(!1),"onCancel"),onConfirm:a(async()=>{x(!0),c(void 0);try{await u(),f(!1)}catch(D){c(D instanceof Error?D.message:"Could not revoke this account. Retry.")}finally{x(!1)}},"onConfirm"),children:[k&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:k}),m]})]})}a(cs,"AiConnectionAccountControls");var W=a(s=>re(s,{maximumFractionDigits:20}),"usageNumber"),$=a((s,t)=>t==="USD"?re(s,{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:20}):`${W(s)}${t?` ${t}`:""}`,"amount");function ae(s){const t=s.label.replace(/\b(\d+(?:\.\d+)?) hour limit\b/i,"$1h").replace(/\bweekly limit\b/i,"Weekly");if(s.windowDurationSeconds==null)return t;const l=s.windowDurationSeconds/3600,n=l===168?"Weekly":`${W(l)}h`;return/\b(?:Primary|Secondary)$/.test(t)?`${t} · ${n}`:l===168&&/weekly/i.test(t)||t.split(/[\s·()]+/).includes(n)?t:`${t} · ${n}`}a(ae,"limitLabel");function ne(s){return s.used===0&&s.limit===0?`${$(s.limit,s.unit)} cap`:s.used!=null&&s.limit!=null?`${$(s.used,s.unit)} / ${$(s.limit,s.unit)} used`:s.usedPercent!=null?`${W(s.usedPercent)}% used`:s.used!=null?`${$(s.used,s.unit)} used`:s.remainingPercent!=null?`${W(s.remainingPercent)}% left`:"Not reported"}a(ne,"limitValue");function ds(s){const t=[];return s.allowed===!1?t.push("Blocked"):s.limitReached===!0&&t.push("Limit reached"),s.allowed===!0&&(s.limitReached===!0||s.usedPercent==null)&&t.push("Usage allowed"),(s.used==null||s.limit==null)&&(s.remaining!=null&&t.push(`${$(s.remaining,s.unit)} left`),s.limit!=null&&t.push(`${$(s.limit,s.unit)} cap`)),s.resetsAt?t.push(`Resets ${J(s.resetsAt,{includeYear:!1})}`):s.resetInterval&&t.push(`Resets ${s.resetInterval}`),t.join(" · ")}a(ds,"limitDetails");function us(s){const t=s.overage,l=[t.available===!0?"Available":t.enabled===!1?"Off":t.available===!1?t.enabled===!0?"On · Unavailable":"Unavailable":t.enabled===!0?"On · Availability unknown":"Not reported"];return t.unlimited===!0?l.push("Unlimited"):t.balance!=null&&(t.balance!==0||t.enabled!==!1)&&l.push($(t.balance,t.unit)),t.remaining!=null&&(t.remaining!==0||t.enabled!==!1)&&!s.limits.some(n=>n.scope==="overage"&&n.remaining===t.remaining&&n.unit===t.unit)&&l.push(`${$(t.remaining,t.unit)} left`),l.join(" · ")}a(us,"overageSummary");function ms(s){switch(s.errorCode){case"authentication_required":return"Sign in again to check usage.";case"permission_denied":return"Usage access denied.";case"rate_limited":return"Too many checks. Try again later.";case"provider_unavailable":return"Provider unavailable. Try again.";case"invalid_response":return"Couldn’t read usage. Try again.";case"connection_unavailable":return"Reconnect to check usage.";case"unsupported":return"Usage unavailable.";default:return s.message??"Usage unavailable."}}a(ms,"usageError");function hs({account:s,observation:t,cachedOnly:l=!1}){const n=O({mutationFn:a(()=>q.probeUsage(s.companyId,s.id,s.grantId),"mutationFn")}),o=ts(s.provider,s.method),r=l?t:n.isSuccess?n.data:void 0;return(0,e.jsxs)("section",{"aria-label":"Account usage limits",className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Usage"}),o&&!l&&(0,e.jsx)(g,{variant:"secondary",size:"sm",disabled:n.isPending||s.status!=="connected",onClick:a(()=>n.mutate(),"onClick"),children:n.isPending?"Checking…":r?.status==="ok"?"Refresh":"Check usage"})]}),l&&!r&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Usage not observed."}),!o&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Unavailable for this sign-in method."}),n.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:n.error.message}),r&&r.status!=="ok"&&(0,e.jsx)("p",{role:r.status==="unsupported"?"status":"alert",className:"text-sm text-ink-3",children:ms(r)}),r?.status==="ok"&&(0,e.jsxs)("div",{className:"space-y-3","aria-live":"polite",children:[r.limits.length===0&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Usage not reported."}),r.limits.map(u=>{const m=ds(u);return(0,e.jsxs)("div",{className:"space-y-1.5",children:[u.usedPercent!=null?(0,e.jsx)(ss,{label:ae(u),percentUsed:u.usedPercent,leftLabel:ne(u)}):(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-ink-3",children:ae(u)}),(0,e.jsx)("span",{className:"font-mono",children:ne(u)})]}),m&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:m})]},u.id)}),r.overage&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Overage"}),(0,e.jsx)("span",{className:"font-mono",children:us(r)})]}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Updated ",(0,e.jsx)("time",{className:"font-mono",dateTime:r.checkedAt,title:J(r.checkedAt),children:J(r.checkedAt,{includeYear:!1})}),r.planType?` · ${r.planType}`:""]})]})]})}a(hs,"AiConnectionUsagePanel");function Es({connection:s}){const t=s.config?.ai;return t?(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:[t.routing?t.routing.kind==="bedrock"?`Bedrock · ${t.routing.region}`:t.routing.kind==="openrouter"?"OpenRouter":t.routing.baseUrl:ke(t.provider,t.method)," ·"," ",s.credentialPolicy==="per_user"?"Personal":"Company shared"]}):null}a(Es,"ManagedAiConnectionRow");function Bs({connection:s}){const t=ve(),l=ze(),n=K({queryKey:["ai-connection-active-runs",s.id],queryFn:a(()=>q.activeRuns(s.companyId,s.id),"queryFn")}),o=K({queryKey:["ai-connections",s.companyId],queryFn:a(()=>q.list(s.companyId),"queryFn")}),r=K({queryKey:["ai-connection-grants",s.id],queryFn:a(()=>se.listConnectionGrants(s.id),"queryFn")}),u=a(()=>t.invalidateQueries(),"refresh"),m=O({mutationFn:a(c=>q.setDefault(s.companyId,c),"mutationFn"),onSuccess:u}),p=O({mutationFn:a(c=>se.revokeConnectionGrant(s.id,c),"mutationFn"),onSuccess:u}),f=O({mutationFn:a(c=>We.cancel(c),"mutationFn"),onSuccess:u}),d=o.data?.connections.find(c=>c.id===s.id),x=r.data?.grants.find(c=>c.id===d?.grantId),k=o.error??r.error??m.error??f.error;return k?(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:k.message}):!d||!x?(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:o.isPending||r.isPending?"Loading AI account…":"This account is not available to you."}):(0,e.jsxs)("div",{className:"space-y-4",children:[d.routing&&(0,e.jsxs)("details",{className:"rounded-lg border border-line p-4",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Provider settings"}),(0,e.jsxs)("dl",{className:"mt-4 grid grid-cols-2 gap-3 text-sm",children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Destination"}),(0,e.jsx)("dd",{className:"break-all",children:d.routing.baseUrl??(d.routing.kind==="bedrock"?d.routing.region:"OpenRouter")}),(0,e.jsx)("dt",{className:"text-ink-3",children:"API format"}),(0,e.jsx)("dd",{children:d.routing.kind==="openrouter"?"Selected by harness":d.routing.protocol}),(0,e.jsx)("dt",{className:"text-ink-3",children:"Authentication"}),(0,e.jsx)("dd",{children:d.routing.auth}),(0,e.jsx)("dt",{className:"text-ink-3",children:"Models"}),(0,e.jsx)("dd",{children:d.routing.models.map(c=>c.label??c.id).join(", ")||"Enter a model ID on the agent"})]})]}),(0,e.jsx)(cs,{account:d,grant:x,currentUserId:o.data.currentUserId,onMakeDefault:a(()=>m.mutate(x.id),"onMakeDefault"),onRevoke:a(()=>p.mutateAsync(x.id).then(()=>{}),"onRevoke"),revocationDetails:(0,e.jsxs)("div",{className:"space-y-2",children:[n.error&&(0,e.jsx)("p",{role:"alert",children:"Could not load active runs. Retry before revoking."}),n.data?.map(c=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 text-sm",children:[(0,e.jsxs)("span",{children:[c.agentName," · ",c.status]}),(0,e.jsx)(g,{variant:"secondary",size:"sm",disabled:f.isPending,onClick:a(()=>f.mutate(c.id),"onClick"),children:"Stop run"})]},c.id))]}),onReconnect:a(()=>l(`/apps/connect?source=${d.provider}&reconnect=${s.id}&method=ai-${d.method}`),"onReconnect")}),(0,e.jsx)(hs,{account:d},`${d.id}:${d.grantId}:${d.status}`)]})}a(Bs,"ManagedAiConnectionDetails");export{os as i,Es as n,Hs as r,Bs as t};
1
+ var me=Object.defineProperty;var a=(s,t)=>me(s,"name",{value:t,configurable:!0});import{i as ie}from"./rolldown-runtime-ZpX3ckPj.js";import{h as J,i as he,l as M,na as xe,t as pe,ta as fe,v as re}from"./createLucideIcon-DJi9suAC.js";import{n as ge,t as je}from"./star-BZgQbzhV.js";import{X as ve,_ as O,v as K}from"./queryKeys-DYV5MhM_.js";import{a as be,b as q,c as ye,h as ke,i as Ne,o as Ce,r as Se,s as Ie,t as $e}from"./connection-identity-YKZfppDS.js";import{E as B,T as De,o as ze,t as Ue}from"./router-2UfGeejU.js";import{a as Ae,c as Re,i as _e,n as Me,o as Pe,r as Te,s as Ge,t as Le}from"./alert-dialog-Blls2GnU.js";import{t as Fe}from"./checkbox-BHQhs41k.js";import{o as He,r as Ee,t as Be}from"./popover-BhYHYj7q.js";import{t as Oe}from"./chevron-right-s7L6hXXq.js";import{r as E,t as g}from"./button-CMwV3L1P.js";import{t as Q}from"./refresh-cw-B_Oki9wZ.js";import{t as qe}from"./triangle-alert-CBVKiaXB.js";import{t as ee}from"./user-round-CGxsJ0K8.js";import{t as X}from"./Identity-Cv_2a9qJ.js";import{t as We}from"./heartbeats-DOyojsaN.js";import{a as Ve,i as Ke,n as Ye,r as we,s as Je,t as Qe}from"./dialog-CKUblzlR.js";import{t as Xe}from"./input-DobnTAyB.js";import{t as Z}from"./skeleton-Bv_lQagE.js";import{t as se}from"./tools-B-L_sU_9.js";import{t as Ze}from"./github-icon-Bbgf67tg.js";import{t as le}from"./InlineBanner-VQ5mstsR.js";import{t as oe}from"./radio-card-DVZaXlw0.js";import{_a as es}from"./index-3AxqhPET.js";import{t as ss}from"./QuotaBar-_ok6Pek4.js";function ts(s,t){return t==="subscription"?s==="openai"||s==="anthropic"||s==="xai":s==="openrouter"}a(ts,"supportsAiConnectionUsage");var ce={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};ce.node;var as=pe(ce),j=ie(xe(),1),e=ie(fe(),1);function H(s){return s.name?.trim()||s.email?.trim()||s.userId}a(H,"memberOptionLabel");function ns({members:s,selectedUserIds:t,onChange:l,onSave:n,loading:o=!1,disabled:r=!1,pending:u=!1,getDescription:m,triggerLabel:p,triggerVariant:f="secondary",triggerSize:d="default",triggerFullWidth:x=!0,triggerClassName:k,contentAlign:c="start",emptyMessage:C="No members yet.",showSelectionPreview:S=!0,filterPlaceholder:U="Filter people",onOpenChange:D}){const[A,P]=(0,j.useState)(!1),[b,R]=(0,j.useState)(""),[_,T]=(0,j.useState)(new Set(t)),h=!!n,N=h?_:t;(0,j.useEffect)(()=>{A&&h&&T(new Set(t))},[A,t,h]);const I=b.trim().toLowerCase(),z=(0,j.useMemo)(()=>s.filter(i=>{const v=m?.(i)??i.email??"";return`${H(i)} ${v}`.toLowerCase().includes(I)}).sort((i,v)=>{const F=N.has(i.userId);return F!==N.has(v.userId)?F?-1:1:H(i).localeCompare(H(v))}),[s,m,I,N]),G=t.size,y=s.filter(i=>t.has(i.userId));function L(i){h?T(i):l?.(i)}return a(L,"setSelection"),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(Be,{open:A,onOpenChange:a(i=>{P(i),D?.(i),i||R("")},"onOpenChange"),children:[(0,e.jsx)(He,{asChild:!0,children:(0,e.jsxs)(g,{type:"button",variant:f,size:d,className:M("justify-between",x&&"w-full",k),disabled:r||u,children:[(0,e.jsx)("span",{className:"flex min-w-0 items-center",children:(0,e.jsx)("span",{className:"truncate",children:p??(G===0?"Select people":`${G} ${G===1?"person":"people"} selected`)})}),(0,e.jsx)(Oe,{className:"h-4 w-4 shrink-0 text-ink-3"})]})}),(0,e.jsxs)(Ee,{className:"w-80 p-0",align:c,children:[(0,e.jsx)("div",{className:"border-b border-line p-3",children:(0,e.jsx)(Xe,{value:b,onChange:a(i=>R(i.target.value),"onChange"),placeholder:U,className:"h-8",autoFocus:!0})}),o?(0,e.jsxs)("div",{className:"space-y-2 p-3",children:[(0,e.jsx)(Z,{className:"h-6 w-full"}),(0,e.jsx)(Z,{className:"h-6 w-full"})]}):s.length===0?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-ink-3",children:C}):(0,e.jsxs)("div",{className:"max-h-60 overflow-y-auto py-1",children:[z.map(i=>{const v=H(i),F=m?.(i)??(i.email&&i.email!==v?i.email:null);return(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2 px-3 py-2 hover:bg-bg-3/30",children:[(0,e.jsx)(Fe,{checked:N.has(i.userId),"aria-label":`Allow ${v}`,onCheckedChange:a(ue=>{const V=new Set(N);ue?V.add(i.userId):V.delete(i.userId),L(V)},"onCheckedChange")}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)(X,{name:v,avatarUrl:i.image??null,size:"sm"}),F?(0,e.jsx)("span",{className:"truncate text-xs text-ink-3",children:F}):null]})]},i.userId)}),z.length===0?(0,e.jsx)("div",{className:"px-3 py-4 text-sm text-ink-3",children:"No matches."}):null]}),(0,e.jsxs)("div",{className:"flex items-center justify-between border-t border-line px-3 py-2",children:[(0,e.jsx)("span",{className:"text-xs text-ink-3","aria-live":"polite",children:N.size===0?"No people selected":`${N.size} selected`}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[h?(0,e.jsx)(g,{type:"button",variant:"ghost",size:"sm",onClick:a(()=>P(!1),"onClick"),disabled:u,children:"Cancel"}):null,(0,e.jsx)(g,{type:"button",size:"sm",onClick:a(()=>{h&&n?.(_),P(!1)},"onClick"),disabled:u,children:h?u?"Saving…":"Save":"Done"})]})]})]})]}),S&&y.length>0?(0,e.jsxs)("div",{className:"space-y-0.5",children:[y.slice(0,3).map(i=>(0,e.jsx)("div",{className:"flex items-center gap-2 px-1.5 py-1 text-sm",children:(0,e.jsx)(X,{name:H(i),avatarUrl:i.image??null,size:"sm"})},i.userId)),y.length>3?(0,e.jsxs)("p",{className:"px-1.5 pt-0.5 text-xs text-ink-3",children:["and ",y.length-3," more"]}):null]}):null]})}a(ns,"MemberMultiSelect");var is={connected:B.green,attention:B.amber,inactive:B.gray,missing:B.gray};function de({status:s}){const t=be(s);return(0,e.jsx)("span",{className:M("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-xs font-medium",is[t]),children:Ne(s)})}a(de,"StatusText");function Hs({appName:s,credentialPolicy:t,ownerUserId:l,connectedUser:n,dedicatedAgent:o,grantsQuery:r,loading:u,error:m,onConnectAsMe:p,onConnectOrganization:f,onConnectAgent:d,onRefreshAccess:x,refreshAccessPending:k=!1,onReplaceAudience:c,connectPending:C,audiencePending:S,audienceError:U,audienceGrantId:D,onOpenAudience:A,onCloseAudience:P}){const b=r?.grants??[],R=r?.capabilities,_=r?.currentUserId??null,T=r?.members??[],h=(0,j.useMemo)(()=>Ie(b),[b]),N=(0,j.useMemo)(()=>ye(b,_),[b,_]),I=(0,j.useMemo)(()=>{const i=b.filter(v=>v.kind==="user");return i.find(v=>v.subjectUserId===l)??N??i.find(v=>v.status==="active")??i[0]??null},[b,N,l]),z=(0,j.useMemo)(()=>b.find(i=>i.kind==="agent"&&i.subjectAgentId===o?.id)??b.find(i=>i.kind==="agent")??null,[o?.id,b]),G=Ce(T,I?.subjectUserId??l??_),y=t==="per_user"||t==="per_user_with_fallback"&&!!N,L=D?b.find(i=>i.id===D)??null:null;if(u)return(0,e.jsxs)("section",{className:"space-y-5","aria-busy":"true",children:[(0,e.jsx)(Y,{}),(0,e.jsx)(Z,{className:"h-14 w-full"})]});if(m)return(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)(Y,{}),(0,e.jsx)(le,{tone:"warning",compact:!0,children:"We couldn't load who this connection acts as. Reload the page to try again."})]});if(t==="per_agent"){const i=z?.providerTenant?.github;return(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold text-ink",children:"GitHub identity"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This agent uses this GitHub account for everyone’s work, instead of the person giving instructions."}),(0,e.jsx)(w,{title:i?`@${i.login}`:"Dedicated GitHub account",status:z?.status??null,detail:o?(0,e.jsxs)(Ue,{to:he(o),className:"transition-colors hover:text-ink hover:underline",children:["Used only by ",o.name]}):"Dedicated to one agent",actions:!z&&o&&R?.canConfigure?(0,e.jsxs)(g,{size:"sm",disabled:C,onClick:a(()=>d(o.id),"onClick"),children:[C?(0,e.jsx)(E,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Connect dedicated account"]}):null}),i?(0,e.jsx)(te,{grant:z,onRefreshAccess:x,refreshPending:k}):null]})}return(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)(Y,{}),(0,e.jsx)(rs,{personal:y,restricted:!y&&!!h?.members?.length,connectedName:y?G??n?.label??null:null,connectedImage:y?n?.image??null:null,status:(y?I:h)?.status??null,canEditAudience:h?.capabilities?.canEditAudience??!1,onChooseAll:a(()=>{h&&c(h,[])},"onChooseAll"),onChooseSelected:a(()=>{h&&A(h.id)},"onChooseSelected")}),(y?I:h)?.providerTenant?.github?(0,e.jsx)(te,{grant:y?I:h,onRefreshAccess:x,refreshPending:k}):null,(0,e.jsx)("div",{children:y?I?null:(0,e.jsx)(w,{id:"personal-identity",title:"Personal account",status:null,detail:"Personal identity",actions:R?.canConnectAsCurrentUser?(0,e.jsxs)(g,{size:"sm",disabled:C,onClick:p,children:[C?(0,e.jsx)(E,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Connect as me"]}):null}):h?h.capabilities?.canEditAudience?(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(g,{size:"sm",variant:"secondary",onClick:a(()=>A(h.id),"onClick"),children:"Manage access"})}):null:(0,e.jsx)(w,{title:"Organization account",status:null,detail:"Organization identity",actions:R?.canCreateOrganizationGrant?(0,e.jsx)(g,{size:"sm",disabled:C,onClick:f,children:"Connect organization identity"}):null})}),L?(0,e.jsx)(ls,{appName:s,grant:L,members:T,pending:S,error:U,onCancel:P,onSave:a(i=>c(L,i),"onSave")}):null]})}a(Hs,"IdentitiesSection");function te({grant:s,onRefreshAccess:t,refreshPending:l}){const n=s.providerTenant?.github;if(!n)return null;const o=n.appSlug?`https://github.com/apps/${encodeURIComponent(n.appSlug)}/installations/new`:/^https:\/\/github\.com\/apps\/[a-z0-9-]+\/installations\/new$/.test(n.installationUrl??"")?n.installationUrl:null,r=n.repositorySelection==="all"?"All current and future repositories":n.repositorySelection==="mixed"?"Mixed access; scope varies by installation":null,u=n.repositorySelection==="none"?"No repositories selected":`${n.repositoryCount} selected ${n.repositoryCount===1?"repository":"repositories"}`;return(0,e.jsxs)("div",{className:"divide-y divide-line border-y border-line",children:[(0,e.jsxs)("div",{className:"py-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"GitHub account"}),(0,e.jsxs)("a",{className:"text-sm text-ink-3 hover:underline",href:`https://github.com/${encodeURIComponent(n.login)}`,target:"_blank",rel:"noreferrer",children:["@",n.login]})]}),(0,e.jsxs)("div",{className:"space-y-3 py-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Repositories"}),r?(0,e.jsxs)("div",{role:"note",className:M("mt-1 inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs",De.warning),children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),r]}):(0,e.jsx)("div",{className:"text-xs text-ink-3",children:u})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[t&&o?(0,e.jsx)(g,{size:"icon-sm",variant:"secondary","aria-label":"Refresh access",title:"Refresh access",disabled:l,onClick:t,children:l?(0,e.jsx)(E,{className:"animate-spin","aria-hidden":"true"}):(0,e.jsx)(Q,{"aria-hidden":"true"})}):null,o?(0,e.jsx)(g,{asChild:!0,size:"sm",variant:"secondary",children:(0,e.jsx)("a",{href:o,target:"_blank",rel:"noreferrer",children:"Add More Repos on GitHub"})}):t?(0,e.jsxs)(g,{size:"sm",variant:"secondary",disabled:l,onClick:t,children:[l?(0,e.jsx)(E,{className:"animate-spin","aria-hidden":"true"}):(0,e.jsx)(Q,{"aria-hidden":"true"}),"Load GitHub configuration"]}):null]})]}),n.repositories?n.repositories.length?(0,e.jsx)("ul",{"aria-label":"Accessible GitHub repositories",tabIndex:0,className:"max-h-(--sz-github-repository-list) space-y-2 overflow-y-auto text-sm",children:n.repositories.map(m=>(0,e.jsx)("li",{children:(0,e.jsxs)("a",{className:"flex items-center gap-2 text-ink-3 hover:underline",href:`https://github.com/${m.fullName.split("/").map(encodeURIComponent).join("/")}`,target:"_blank",rel:"noreferrer",children:[(0,e.jsx)(Ze,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{className:"break-all",children:m.fullName}),m.private===!0?(0,e.jsx)(ge,{className:"h-3 w-3 shrink-0",role:"img","aria-label":"Private repository"}):null]})},m.id))}):(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"No accessible repositories."}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Refresh access to load the current repository list."}),o?(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Missing an organization or repository? ",(0,e.jsx)("a",{href:o,target:"_blank",rel:"noreferrer",className:"text-ink hover:underline",children:"Configure access on GitHub"}),", then refresh this list."]}):null]})]})}a(te,"GitHubConnectionSummary");function Y(){return(0,e.jsx)("h2",{className:"text-sm font-semibold text-ink",children:"Which humans can use this credential?"})}a(Y,"IdentitiesHeading");function rs({personal:s,restricted:t,connectedName:l,connectedImage:n,status:o,canEditAudience:r,onChooseAll:u,onChooseSelected:m}){return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(oe,{ariaLabel:"Which humans can use this credential",value:s?"personal":t?"selected":"company",className:"sm:grid-cols-2",onValueChange:a(p=>{!r||s||(p==="company"&&u(),p==="selected"&&m())},"onValueChange"),options:s?[{value:"personal",title:"Just me",description:"Only you can use this connection.",icon:(0,e.jsx)(ee,{className:"h-4 w-4"})}]:[{value:"selected",title:"Humans I pick",description:"Only selected people in your company.",icon:(0,e.jsx)(ee,{className:"h-4 w-4"}),disabled:!r},{value:"company",title:"Any human in the company",description:"Anyone in your company can use this connection.",icon:(0,e.jsx)(as,{className:"h-4 w-4"}),disabled:!r}]}),l&&o!==null?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(X,{name:l,avatarUrl:n}),o==="active"?null:(0,e.jsx)(de,{status:o})]}):null]})}a(rs,"HumanAccessCards");function w({id:s,title:t,status:l,detail:n,actions:o}){return(0,e.jsxs)("div",{id:s,className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between sm:gap-8",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-semibold text-ink",children:t}),l==="active"?null:(0,e.jsx)(de,{status:l})]}),n?(0,e.jsx)("div",{className:"mt-0.5 text-xs text-ink-3",children:n}):null]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:o})]})}a(w,"IdentityRow");function ls({appName:s,grant:t,members:l,pending:n,error:o,onCancel:r,onSave:u}){const m=(0,j.useMemo)(()=>$e(t),[t]),[p,f]=(0,j.useState)(m.size===0?"all":"selected"),[d,x]=(0,j.useState)(m);(0,j.useEffect)(()=>{x(m),f(m.size===0?"all":"selected")},[m]);const k=p==="all"||d.size>0;return(0,e.jsx)(Qe,{open:!0,onOpenChange:a(c=>{c||r()},"onOpenChange"),children:(0,e.jsxs)(Ye,{children:[(0,e.jsxs)(Ve,{children:[(0,e.jsx)(Je,{children:"Who can use this identity"}),(0,e.jsxs)(we,{children:[Se(t)," · ",s]})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(oe,{ariaLabel:"Who can use this identity",value:p,onValueChange:a(c=>f(c),"onValueChange"),options:[{value:"all",title:"All organization members",description:"Anyone in this organization can have work use this identity."},{value:"selected",title:"Selected members",description:"Only the people you choose."}]}),p==="selected"?(0,e.jsx)(ns,{members:l.map(c=>({userId:c.userId,name:c.name,email:c.email})),selectedUserIds:d,onChange:x,triggerLabel:d.size===0?"Choose people":`${d.size} ${d.size===1?"person":"people"} selected`}):null,(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"This controls whose work can use the identity. It does not change which agents have the connection."}),o?(0,e.jsx)(le,{tone:"warning",compact:!0,children:o}):null]}),(0,e.jsxs)(Ke,{children:[(0,e.jsx)(g,{variant:"ghost",onClick:r,disabled:n,children:"Cancel"}),(0,e.jsxs)(g,{disabled:n||!k,onClick:a(()=>u(p==="all"?[]:[...d]),"onClick"),children:[n?(0,e.jsx)(E,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save audience"]})]})]})})}a(ls,"AudienceDialog");function os({grant:s,providerName:t,pending:l,isOwnIdentity:n,credentialPolicy:o,description:r,children:u,onCancel:m,onConfirm:p}){const f=s.kind==="user",d=f?n?`Revoke your ${t} identity?`:`Revoke this ${t} identity?`:"Revoke the organization identity?";return(0,e.jsx)(Le,{open:!0,onOpenChange:a(x=>{x||m()},"onOpenChange"),children:(0,e.jsxs)(_e,{children:[(0,e.jsxs)(Ge,{children:[(0,e.jsx)(Re,{children:d}),(0,e.jsx)(Ae,{children:r??(f?n?"Agents will stop acting as you. Work that needs this identity can ask you to connect again.":"Agents will stop acting as this person. They can connect again themselves; no one else can do it for them.":o==="per_user"?"Installed agents lose this shared identity immediately.":"Eligible members and installed agents will lose this shared identity immediately.")})]}),u,(0,e.jsxs)(Pe,{children:[(0,e.jsx)(Te,{disabled:l,autoFocus:!0,children:"Cancel"}),(0,e.jsx)(Me,{disabled:l,onClick:a(x=>{x.preventDefault(),p()},"onClick"),children:"Revoke identity"})]})]})})}a(os,"RevokeGrantDialog");function cs({account:s,grant:t,currentUserId:l,readOnly:n,onMakeDefault:o,onReconnect:r,onRevoke:u,revocationDetails:m}){const[p,f]=(0,j.useState)(!1),[d,x]=(0,j.useState)(!1),[k,c]=(0,j.useState)(),C=s.ownership==="personal"&&s.ownerUserId===l,S=s.status==="connected",U=s.isDefault&&S;return(0,e.jsxs)("section",{className:"space-y-4","aria-label":"AI account settings",children:[C&&!s.routing&&(0,e.jsxs)("div",{className:M("flex flex-wrap items-center justify-between gap-3 rounded-lg border border-line p-3",U&&"border-(--status-task-done)/30 bg-(--status-task-done)/5"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(je,{"aria-hidden":!0,className:M("size-5 shrink-0",U?"fill-current text-(--status-task-icon-done)":"text-ink-3")}),(0,e.jsx)("h3",{role:s.isDefault?"status":void 0,className:M("text-sm font-semibold",s.isDefault&&!S&&"text-bad"),children:s.isDefault&&!S?"Default unavailable":"Personal default"})]}),!s.isDefault&&(n?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Not default"}):(0,e.jsx)(g,{variant:"secondary",size:"sm",disabled:!S,onClick:o,children:"Make default"}))]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"min-w-0 text-sm",children:(0,e.jsxs)("p",{className:"break-words text-xs text-ink-3",children:[s.method==="subscription"?"Subscription":"API key",s.accountLabel?` · ${s.accountLabel}`:""]})}),!n&&t.capabilities?.canRevoke&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(g,{variant:"secondary",size:"sm",onClick:r,children:[(0,e.jsx)(Q,{className:"size-4","aria-hidden":!0}),"Reconnect"]}),s.status!=="revoked"&&(0,e.jsxs)(g,{variant:"danger",size:"sm",onClick:a(()=>f(!0),"onClick"),children:[(0,e.jsx)(es,{className:"size-4","aria-hidden":!0}),"Revoke identity"]})]})]}),p&&(0,e.jsxs)(os,{grant:t,providerName:s.name,pending:d,credentialPolicy:s.ownership==="shared"?"shared":"per_user",isOwnIdentity:s.ownerUserId===l,description:"New runs using this account will be blocked. Existing runs may retain credentials already issued to them. No other account will be selected automatically.",onCancel:a(()=>f(!1),"onCancel"),onConfirm:a(async()=>{x(!0),c(void 0);try{await u(),f(!1)}catch(D){c(D instanceof Error?D.message:"Could not revoke this account. Retry.")}finally{x(!1)}},"onConfirm"),children:[k&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:k}),m]})]})}a(cs,"AiConnectionAccountControls");var W=a(s=>re(s,{maximumFractionDigits:20}),"usageNumber"),$=a((s,t)=>t==="USD"?re(s,{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:20}):`${W(s)}${t?` ${t}`:""}`,"amount");function ae(s){const t=s.label.replace(/\b(\d+(?:\.\d+)?) hour limit\b/i,"$1h").replace(/\bweekly limit\b/i,"Weekly");if(s.windowDurationSeconds==null)return t;const l=s.windowDurationSeconds/3600,n=l===168?"Weekly":`${W(l)}h`;return/\b(?:Primary|Secondary)$/.test(t)?`${t} · ${n}`:l===168&&/weekly/i.test(t)||t.split(/[\s·()]+/).includes(n)?t:`${t} · ${n}`}a(ae,"limitLabel");function ne(s){return s.used===0&&s.limit===0?`${$(s.limit,s.unit)} cap`:s.used!=null&&s.limit!=null?`${$(s.used,s.unit)} / ${$(s.limit,s.unit)} used`:s.usedPercent!=null?`${W(s.usedPercent)}% used`:s.used!=null?`${$(s.used,s.unit)} used`:s.remainingPercent!=null?`${W(s.remainingPercent)}% left`:"Not reported"}a(ne,"limitValue");function ds(s){const t=[];return s.allowed===!1?t.push("Blocked"):s.limitReached===!0&&t.push("Limit reached"),s.allowed===!0&&(s.limitReached===!0||s.usedPercent==null)&&t.push("Usage allowed"),(s.used==null||s.limit==null)&&(s.remaining!=null&&t.push(`${$(s.remaining,s.unit)} left`),s.limit!=null&&t.push(`${$(s.limit,s.unit)} cap`)),s.resetsAt?t.push(`Resets ${J(s.resetsAt,{includeYear:!1})}`):s.resetInterval&&t.push(`Resets ${s.resetInterval}`),t.join(" · ")}a(ds,"limitDetails");function us(s){const t=s.overage,l=[t.available===!0?"Available":t.enabled===!1?"Off":t.available===!1?t.enabled===!0?"On · Unavailable":"Unavailable":t.enabled===!0?"On · Availability unknown":"Not reported"];return t.unlimited===!0?l.push("Unlimited"):t.balance!=null&&(t.balance!==0||t.enabled!==!1)&&l.push($(t.balance,t.unit)),t.remaining!=null&&(t.remaining!==0||t.enabled!==!1)&&!s.limits.some(n=>n.scope==="overage"&&n.remaining===t.remaining&&n.unit===t.unit)&&l.push(`${$(t.remaining,t.unit)} left`),l.join(" · ")}a(us,"overageSummary");function ms(s){switch(s.errorCode){case"authentication_required":return"Sign in again to check usage.";case"permission_denied":return"Usage access denied.";case"rate_limited":return"Too many checks. Try again later.";case"provider_unavailable":return"Provider unavailable. Try again.";case"invalid_response":return"Couldn’t read usage. Try again.";case"connection_unavailable":return"Reconnect to check usage.";case"unsupported":return"Usage unavailable.";default:return s.message??"Usage unavailable."}}a(ms,"usageError");function hs({account:s,observation:t,cachedOnly:l=!1}){const n=O({mutationFn:a(()=>q.probeUsage(s.companyId,s.id,s.grantId),"mutationFn")}),o=ts(s.provider,s.method),r=l?t:n.isSuccess?n.data:void 0;return(0,e.jsxs)("section",{"aria-label":"Account usage limits",className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Usage"}),o&&!l&&(0,e.jsx)(g,{variant:"secondary",size:"sm",disabled:n.isPending||s.status!=="connected",onClick:a(()=>n.mutate(),"onClick"),children:n.isPending?"Checking…":r?.status==="ok"?"Refresh":"Check usage"})]}),l&&!r&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Usage not observed."}),!o&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Unavailable for this sign-in method."}),n.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:n.error.message}),r&&r.status!=="ok"&&(0,e.jsx)("p",{role:r.status==="unsupported"?"status":"alert",className:"text-sm text-ink-3",children:ms(r)}),r?.status==="ok"&&(0,e.jsxs)("div",{className:"space-y-3","aria-live":"polite",children:[r.limits.length===0&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Usage not reported."}),r.limits.map(u=>{const m=ds(u);return(0,e.jsxs)("div",{className:"space-y-1.5",children:[u.usedPercent!=null?(0,e.jsx)(ss,{label:ae(u),percentUsed:u.usedPercent,leftLabel:ne(u)}):(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-ink-3",children:ae(u)}),(0,e.jsx)("span",{className:"font-mono",children:ne(u)})]}),m&&(0,e.jsx)("p",{className:"text-xs text-ink-3",children:m})]},u.id)}),r.overage&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Overage"}),(0,e.jsx)("span",{className:"font-mono",children:us(r)})]}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Updated ",(0,e.jsx)("time",{className:"font-mono",dateTime:r.checkedAt,title:J(r.checkedAt),children:J(r.checkedAt,{includeYear:!1})}),r.planType?` · ${r.planType}`:""]})]})]})}a(hs,"AiConnectionUsagePanel");function Es({connection:s}){const t=s.config?.ai;return t?(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:[t.routing?t.routing.kind==="bedrock"?`Bedrock · ${t.routing.region}`:t.routing.kind==="openrouter"?"OpenRouter":t.routing.baseUrl:ke(t.provider,t.method)," ·"," ",s.credentialPolicy==="per_user"?"Personal":"Company shared"]}):null}a(Es,"ManagedAiConnectionRow");function Bs({connection:s}){const t=ve(),l=ze(),n=K({queryKey:["ai-connection-active-runs",s.id],queryFn:a(()=>q.activeRuns(s.companyId,s.id),"queryFn")}),o=K({queryKey:["ai-connections",s.companyId],queryFn:a(()=>q.list(s.companyId),"queryFn")}),r=K({queryKey:["ai-connection-grants",s.id],queryFn:a(()=>se.listConnectionGrants(s.id),"queryFn")}),u=a(()=>t.invalidateQueries(),"refresh"),m=O({mutationFn:a(c=>q.setDefault(s.companyId,c),"mutationFn"),onSuccess:u}),p=O({mutationFn:a(c=>se.revokeConnectionGrant(s.id,c),"mutationFn"),onSuccess:u}),f=O({mutationFn:a(c=>We.cancel(c),"mutationFn"),onSuccess:u}),d=o.data?.connections.find(c=>c.id===s.id),x=r.data?.grants.find(c=>c.id===d?.grantId),k=o.error??r.error??m.error??f.error;return k?(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:k.message}):!d||!x?(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:o.isPending||r.isPending?"Loading AI account…":"This account is not available to you."}):(0,e.jsxs)("div",{className:"space-y-4",children:[d.routing&&(0,e.jsxs)("details",{className:"rounded-lg border border-line p-4",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Provider settings"}),(0,e.jsxs)("dl",{className:"mt-4 grid grid-cols-2 gap-3 text-sm",children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Destination"}),(0,e.jsx)("dd",{className:"break-all",children:d.routing.baseUrl??(d.routing.kind==="bedrock"?d.routing.region:"OpenRouter")}),(0,e.jsx)("dt",{className:"text-ink-3",children:"API format"}),(0,e.jsx)("dd",{children:d.routing.kind==="openrouter"?"Selected by harness":d.routing.protocol}),(0,e.jsx)("dt",{className:"text-ink-3",children:"Authentication"}),(0,e.jsx)("dd",{children:d.routing.auth}),(0,e.jsx)("dt",{className:"text-ink-3",children:"Models"}),(0,e.jsx)("dd",{children:d.routing.models.map(c=>c.label??c.id).join(", ")||"Enter a model ID on the agent"})]})]}),(0,e.jsx)(cs,{account:d,grant:x,currentUserId:o.data.currentUserId,onMakeDefault:a(()=>m.mutate(x.id),"onMakeDefault"),onRevoke:a(()=>p.mutateAsync(x.id).then(()=>{}),"onRevoke"),revocationDetails:(0,e.jsxs)("div",{className:"space-y-2",children:[n.error&&(0,e.jsx)("p",{role:"alert",children:"Could not load active runs. Retry before revoking."}),n.data?.map(c=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 text-sm",children:[(0,e.jsxs)("span",{children:[c.agentName," · ",c.status]}),(0,e.jsx)(g,{variant:"secondary",size:"sm",disabled:f.isPending,onClick:a(()=>f.mutate(c.id),"onClick"),children:"Stop run"})]},c.id))]}),onReconnect:a(()=>l(`/apps/connect?source=${d.provider}&reconnect=${s.id}&method=ai-${d.method}`),"onReconnect")}),(0,e.jsx)(hs,{account:d},`${d.id}:${d.grantId}:${d.status}`)]})}a(Bs,"ManagedAiConnectionDetails");export{os as i,Es as n,Hs as r,Bs as t};
@@ -1 +1 @@
1
- var T=Object.defineProperty;var i=(r,n)=>T(r,"name",{value:n,configurable:!0});import{i as D}from"./rolldown-runtime-ZpX3ckPj.js";import{na as Z,ta as G}from"./createLucideIcon-DJi9suAC.js";import{v as J}from"./star-BZgQbzhV.js";import{X,_ as S,r as j,v as E}from"./queryKeys-DYV5MhM_.js";import{at as H,t as W}from"./router-2UfGeejU.js";import{t as V}from"./checkbox-BHQhs41k.js";import{t as h}from"./button-CMwV3L1P.js";import{t as z}from"./MootMark-DZAfkwdv.js";import{n as ee,t as se}from"./Identity-Cv_2a9qJ.js";import{t as A}from"./input-DobnTAyB.js";import{t as v}from"./card-Bru3x_SJ.js";import{Jr as U}from"./index-DDoARkPG.js";import{n as te}from"./connection-owner-CZwxTEuM.js";var l=D(Z(),1),e=D(G(),1);function _({origin:r}){const[n,d]=(0,l.useState)(!1);let o;try{const a=new URL(r);a.origin==="https://claude.ai"?o="/brands/claude-color.svg":["https://chatgpt.com","https://chat.openai.com","https://openai.com"].includes(a.origin)&&(o="/brands/codex-color.svg")}catch{}return(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[o&&!n?(0,e.jsx)("img",{src:o,alt:"",className:"size-4 shrink-0 object-contain",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:i(()=>d(!0),"onError")}):(0,e.jsx)(H,{className:"size-4 shrink-0","aria-hidden":"true"}),(0,e.jsx)("bdi",{className:"min-w-0 break-all",children:r})]})}i(_,"ClientOrigin");function je({agentPairingOnly:r=!1}={}){const{id:n=""}=J();return(0,e.jsx)(F,{id:n,agentPairingOnly:r},n)}i(je,"McpConnectPage");function fe({initialCode:r}={}){const[n,d]=(0,l.useState)(r??new URLSearchParams(window.location.search).get("user_code")??""),[o,a]=(0,l.useState)(n);return o?(0,e.jsx)(F,{id:o,device:!0,onEditCode:i(()=>a(""),"onEditCode")},o):(0,e.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,e.jsxs)(v,{className:"space-y-4 p-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(z,{className:"size-8 shrink-0 text-ink"}),(0,e.jsx)("h1",{className:"min-w-0 text-xl font-semibold",children:"Connect your assistant to Wardmote"})]}),(0,e.jsxs)("form",{className:"space-y-4",onSubmit:i(m=>{m.preventDefault(),a(n.trim())},"onSubmit"),children:[(0,e.jsx)("label",{htmlFor:"device-code",className:"text-sm",children:"Enter the code shown by your assistant"}),(0,e.jsx)(A,{id:"device-code",autoComplete:"off",value:n,onChange:i(m=>d(m.target.value),"onChange"),required:!0,maxLength:12}),(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(h,{type:"submit",children:"Continue"})})]})]})})}i(fe,"McpDevicePage");function F({id:r,device:n=!1,agentPairingOnly:d=!1,onEditCode:o}){const a=d?"/dot-mcp/requests":"/mcp/requests",[m,N]=(0,l.useState)(""),[p,R]=(0,l.useState)(""),[u,b]=(0,l.useState)(null),[$,w]=(0,l.useState)(""),[O,L]=(0,l.useState)(!0),[k,M]=(0,l.useState)(null),f=E({queryKey:[n?"mcp-device":d?"dot-mcp-request":"mcp-request",r],queryFn:i(()=>j.get(n?`/mcp/device?user_code=${encodeURIComponent(r)}`:`${a}/${encodeURIComponent(r)}`),"queryFn"),retry:!1}),s=f.data;(0,l.useEffect)(()=>{if(b(null),w(""),!s?.agentConnection||n||!/^[A-Za-z0-9_-]{32}$/.test(p.trim()))return;let t=!0;return j.post(`${a}/${encodeURIComponent(r)}/dot-pairing/preview`,{pairingCode:p.trim()}).then(g=>{t&&b(g)}).catch(g=>{t&&w(g instanceof Error?g.message:"Unable to verify this pairing code.")}),()=>{t=!1}},[r,n,a,s?.agentConnection,p]);const P=s?.requestedCompanyId??(m||s?.companies[0]?.id||"");(0,l.useEffect)(()=>{!m&&!s?.requestedCompanyId&&s?.companies[0]&&N(s.companies[0].id)},[m,s]);const q=s?.clientName.trim(),B=q&&!/^(assistant|mcp client)$/i.test(q)?q:"your assistant",C=s?.clientOrigin||s?.redirectOrigin,c=s?.companies.find(t=>t.id===P),I=!!(!s?.agentConnection&&c?.canWrite&&O),Q=!!(s?.requestedWrite&&I),K=!!(s?.requestedConfigure&&I),x=S({mutationFn:i(t=>j.post(n?"/mcp/device/consent":`/mcp/requests/${encodeURIComponent(r)}/consent`,{decision:t,companyId:P||void 0,allowWrites:t==="approve"&&Q,allowConfiguration:t==="approve"&&K,...n?{userCode:r}:{}}),"mutationFn"),onSuccess:i(({redirectUrl:t,status:g})=>{n&&g?M(g):t&&window.location.assign(t)},"onSuccess")}),y=S({mutationFn:i(()=>j.post(`${a}/${encodeURIComponent(r)}/dot-pairing`,{pairingCode:p.trim()}),"mutationFn"),onSuccess:i(({redirectUrl:t})=>{R(""),window.location.assign(t)},"onSuccess")});if(k)return(0,e.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,e.jsxs)(v,{className:"block space-y-4 p-6",children:[(0,e.jsx)(z,{className:"size-8 text-ink"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:k==="approved"?"Access approved":"Connection declined"}),(0,e.jsx)("p",{className:"text-sm",children:k==="approved"?"Return to your assistant. It will finish connecting automatically.":"No access was granted. You can start a new connection from your assistant."}),(0,e.jsx)(h,{variant:"secondary",asChild:!0,children:(0,e.jsx)(W,{to:"/",children:"Back to Wardmote"})})]})});const Y=n?`/mcp-device?user_code=${encodeURIComponent(r)}`:`${d?"/dot-connect":"/mcp-connect"}/${r}`;return(0,e.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,e.jsxs)(v,{className:"block space-y-4 p-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(z,{className:"size-8 shrink-0 text-ink",title:"Wardmote"}),(0,e.jsxs)("h1",{className:"min-w-0 break-words text-xl font-semibold",children:["Connect ",(0,e.jsx)("bdi",{children:B})," to Wardmote"]})]}),C&&(0,e.jsx)(_,{origin:C},C),!n&&s?.redirectOrigin&&s.redirectOrigin!==C&&(0,e.jsx)(_,{origin:s.redirectOrigin},s.redirectOrigin),n&&(0,e.jsxs)("p",{className:"text-sm",children:["Confirm this matches the code shown by your assistant: ",(0,e.jsx)("strong",{className:"font-mono",children:r.toUpperCase()})]}),f.isPending&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading connection request…"}),f.error&&(0,e.jsxs)("p",{className:"text-sm text-bad",children:[f.error.message," Start a new connection from your assistant."]}),n&&f.error&&(0,e.jsx)(h,{variant:"secondary",onClick:o,children:"Enter a different code"}),s?.agentConnection&&!n&&(0,e.jsxs)("form",{className:"space-y-3",onSubmit:i(t=>{t.preventDefault(),y.mutate()},"onSubmit"),children:[(0,e.jsx)("p",{className:"text-sm",children:"Enter the one-use code from your Dot setup prompt to review this agent’s access. Access is granted when you click “Connect Dot with pairing code”."}),(0,e.jsx)("label",{htmlFor:"dot-pairing-code",className:"text-sm",children:"Pairing code"}),(0,e.jsx)(A,{id:"dot-pairing-code",type:"password",autoComplete:"off",value:p,onChange:i(t=>{b(null),w(""),R(t.target.value)},"onChange"),required:!0,maxLength:32}),u&&(0,e.jsxs)("dl",{className:"space-y-2 rounded-md border border-line p-3 text-sm",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Company"}),(0,e.jsxs)("dd",{children:[u.company.name," ",(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.company.id,")"]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Agent"}),(0,e.jsxs)("dd",{children:[u.agent.name," ",(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.agent.id,")"]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Permissions"}),(0,e.jsx)("dd",{children:u.permissions})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Access duration"}),(0,e.jsx)("dd",{children:u.accessDuration})]})]}),$&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:$}),y.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:y.error.message}),(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(h,{type:"submit",disabled:!u||!/^[A-Za-z0-9_-]{32}$/.test(p.trim())||y.isPending,children:y.isPending?"Connecting…":"Connect Dot with pairing code"})})]}),s&&(0,e.jsx)(e.Fragment,{children:s.requiresSignIn?(0,e.jsx)(h,{asChild:!0,children:(0,e.jsx)(W,{to:`/auth?next=${encodeURIComponent(Y)}`,children:"Sign in / Create account"})}):(0,e.jsxs)(e.Fragment,{children:[s.requestedCompanyId?(0,e.jsxs)("div",{className:"flex items-center gap-4 rounded-md border border-line p-4",children:[c&&(0,e.jsx)(U,{companyName:c.name,logoUrl:c.logoUrl,className:"size-14 shrink-0 rounded-lg text-xl"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Organization"}),c?(0,e.jsx)("p",{className:"break-words text-lg font-semibold",children:c.name}):(0,e.jsx)("p",{className:"text-sm text-bad",children:"The selected organization is no longer available to this account. Cancel and reconnect from your assistant to choose an organization you can access."})]})]}):(0,e.jsxs)("fieldset",{className:"space-y-2",disabled:x.isPending,children:[(0,e.jsx)("legend",{className:"mb-2 text-sm font-medium",children:"Organization"}),s.companies.map(t=>(0,e.jsxs)("label",{className:"flex items-center gap-3 rounded-md border border-line p-3 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:"company","aria-label":t.name,value:t.id,checked:P===t.id,onChange:i(()=>N(t.id),"onChange")}),(0,e.jsx)(U,{companyName:t.name,logoUrl:t.logoUrl,className:"size-12 shrink-0 rounded-lg"}),(0,e.jsx)("span",{className:"min-w-0 break-words font-medium",children:t.name})]},t.id)),!s.companies.length&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This account has no available organizations. Ask an organization owner to add you, then reconnect from your assistant."})]}),(0,e.jsx)("p",{className:"text-sm",children:s.agentConnection?"Connect Dot as a Wardmote agent. Pair it with an agent after connecting; assigned work uses that agent’s permissions.":"Read all of your Wardmote data"}),(s.requestedWrite||s.requestedConfigure)&&!s.agentConnection&&(0,e.jsxs)("label",{htmlFor:"mcp-allow-writes",className:"flex items-start gap-3 text-sm leading-6",children:[(0,e.jsx)("span",{className:"flex h-6 shrink-0 items-center",children:(0,e.jsx)(V,{id:"mcp-allow-writes",checked:I,disabled:!c?.canWrite||x.isPending,onCheckedChange:i(t=>L(t===!0),"onCheckedChange")})}),(0,e.jsx)("span",{children:"Write all of your Wardmote data"})]}),c&&!c.canWrite&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Your role in this organization is read-only."}),x.error&&(0,e.jsx)("p",{className:"text-sm text-bad",children:x.error.message}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)(h,{variant:"secondary",disabled:x.isPending,onClick:i(()=>x.mutate("deny"),"onClick"),children:"Cancel"}),(0,e.jsx)(h,{className:"h-auto min-h-10 min-w-0 shrink whitespace-normal",disabled:!c||s.agentConnection&&!c.canWrite||x.isPending,onClick:i(()=>x.mutate("approve"),"onClick"),children:x.isPending?"Connecting…":s.agentConnection?"Connect Dot agent":"Connect organization"})]})]})})]})})}i(F,"McpConnectRequest");function ye(){const r=X(),n=E({queryKey:["mcp-connections"],queryFn:i(()=>j.get("/mcp/connections"),"queryFn"),retry:!1}),d=n.data?.filter(a=>!a.revokedAt),o=S({mutationFn:i(a=>j.delete(`/mcp/connections/${a}`),"mutationFn"),onSuccess:i((a,m)=>(r.setQueryData(["mcp-connections"],N=>N?.filter(p=>p.id!==m)),r.invalidateQueries({queryKey:["mcp-connections"]})),"onSuccess")});return(0,e.jsxs)("div",{className:"mx-auto max-w-xl space-y-4 py-10",children:[(0,e.jsx)("h1",{className:"text-xl font-semibold",children:"Assistant connections"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Revoking a connection stops its future tool calls. Work already delegated continues under your organization’s normal controls."}),n.isPending&&(0,e.jsx)("p",{className:"text-sm",children:"Loading connections…"}),(n.error||o.error)&&(0,e.jsx)("p",{className:"text-sm text-bad",children:(n.error??o.error)?.message}),d?.length===0&&(0,e.jsx)("p",{className:"text-sm",children:"No assistant connections."}),d?.map(a=>(0,e.jsxs)(v,{className:"block space-y-2 p-4",children:[(0,e.jsx)("h2",{className:"font-medium",children:(0,e.jsx)(se,{name:te(a),avatarUrl:a.user?.image,initials:ee(a.user?.name??"You")})}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["Organization: ",a.companyName]}),(0,e.jsx)("p",{className:"text-sm",children:a.scopes.includes("wardmote:agent")?"Dot agent connection":a.scopes.includes("wardmote:write")?"Read and edit work":"Read only"}),a.scopes.includes("wardmote:configure")&&(0,e.jsx)("p",{className:"text-sm",children:"Configure agents, projects and skills"}),(0,e.jsx)(h,{variant:"secondary",disabled:o.isPending,onClick:i(()=>o.mutate(a.id),"onClick"),children:"Revoke connection"})]},a.id)),(0,e.jsx)(W,{className:"text-sm underline",to:"/",children:"Back to Wardmote"})]})}i(ye,"AssistantConnectionsPage");export{ye as AssistantConnectionsPage,je as McpConnectPage,fe as McpDevicePage};
1
+ var T=Object.defineProperty;var i=(r,n)=>T(r,"name",{value:n,configurable:!0});import{i as D}from"./rolldown-runtime-ZpX3ckPj.js";import{na as Z,ta as G}from"./createLucideIcon-DJi9suAC.js";import{v as J}from"./star-BZgQbzhV.js";import{X,_ as S,r as j,v as E}from"./queryKeys-DYV5MhM_.js";import{at as H,t as W}from"./router-2UfGeejU.js";import{t as V}from"./checkbox-BHQhs41k.js";import{t as h}from"./button-CMwV3L1P.js";import{t as z}from"./MootMark-DZAfkwdv.js";import{n as ee,t as se}from"./Identity-Cv_2a9qJ.js";import{t as A}from"./input-DobnTAyB.js";import{t as v}from"./card-Bru3x_SJ.js";import{Jr as U}from"./index-3AxqhPET.js";import{n as te}from"./connection-owner-DL4yKhSt.js";var l=D(Z(),1),e=D(G(),1);function _({origin:r}){const[n,d]=(0,l.useState)(!1);let o;try{const a=new URL(r);a.origin==="https://claude.ai"?o="/brands/claude-color.svg":["https://chatgpt.com","https://chat.openai.com","https://openai.com"].includes(a.origin)&&(o="/brands/codex-color.svg")}catch{}return(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[o&&!n?(0,e.jsx)("img",{src:o,alt:"",className:"size-4 shrink-0 object-contain",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:i(()=>d(!0),"onError")}):(0,e.jsx)(H,{className:"size-4 shrink-0","aria-hidden":"true"}),(0,e.jsx)("bdi",{className:"min-w-0 break-all",children:r})]})}i(_,"ClientOrigin");function je({agentPairingOnly:r=!1}={}){const{id:n=""}=J();return(0,e.jsx)(F,{id:n,agentPairingOnly:r},n)}i(je,"McpConnectPage");function fe({initialCode:r}={}){const[n,d]=(0,l.useState)(r??new URLSearchParams(window.location.search).get("user_code")??""),[o,a]=(0,l.useState)(n);return o?(0,e.jsx)(F,{id:o,device:!0,onEditCode:i(()=>a(""),"onEditCode")},o):(0,e.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,e.jsxs)(v,{className:"space-y-4 p-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(z,{className:"size-8 shrink-0 text-ink"}),(0,e.jsx)("h1",{className:"min-w-0 text-xl font-semibold",children:"Connect your assistant to Wardmote"})]}),(0,e.jsxs)("form",{className:"space-y-4",onSubmit:i(m=>{m.preventDefault(),a(n.trim())},"onSubmit"),children:[(0,e.jsx)("label",{htmlFor:"device-code",className:"text-sm",children:"Enter the code shown by your assistant"}),(0,e.jsx)(A,{id:"device-code",autoComplete:"off",value:n,onChange:i(m=>d(m.target.value),"onChange"),required:!0,maxLength:12}),(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(h,{type:"submit",children:"Continue"})})]})]})})}i(fe,"McpDevicePage");function F({id:r,device:n=!1,agentPairingOnly:d=!1,onEditCode:o}){const a=d?"/dot-mcp/requests":"/mcp/requests",[m,N]=(0,l.useState)(""),[p,R]=(0,l.useState)(""),[u,b]=(0,l.useState)(null),[$,w]=(0,l.useState)(""),[O,L]=(0,l.useState)(!0),[k,M]=(0,l.useState)(null),f=E({queryKey:[n?"mcp-device":d?"dot-mcp-request":"mcp-request",r],queryFn:i(()=>j.get(n?`/mcp/device?user_code=${encodeURIComponent(r)}`:`${a}/${encodeURIComponent(r)}`),"queryFn"),retry:!1}),s=f.data;(0,l.useEffect)(()=>{if(b(null),w(""),!s?.agentConnection||n||!/^[A-Za-z0-9_-]{32}$/.test(p.trim()))return;let t=!0;return j.post(`${a}/${encodeURIComponent(r)}/dot-pairing/preview`,{pairingCode:p.trim()}).then(g=>{t&&b(g)}).catch(g=>{t&&w(g instanceof Error?g.message:"Unable to verify this pairing code.")}),()=>{t=!1}},[r,n,a,s?.agentConnection,p]);const P=s?.requestedCompanyId??(m||s?.companies[0]?.id||"");(0,l.useEffect)(()=>{!m&&!s?.requestedCompanyId&&s?.companies[0]&&N(s.companies[0].id)},[m,s]);const q=s?.clientName.trim(),B=q&&!/^(assistant|mcp client)$/i.test(q)?q:"your assistant",C=s?.clientOrigin||s?.redirectOrigin,c=s?.companies.find(t=>t.id===P),I=!!(!s?.agentConnection&&c?.canWrite&&O),Q=!!(s?.requestedWrite&&I),K=!!(s?.requestedConfigure&&I),x=S({mutationFn:i(t=>j.post(n?"/mcp/device/consent":`/mcp/requests/${encodeURIComponent(r)}/consent`,{decision:t,companyId:P||void 0,allowWrites:t==="approve"&&Q,allowConfiguration:t==="approve"&&K,...n?{userCode:r}:{}}),"mutationFn"),onSuccess:i(({redirectUrl:t,status:g})=>{n&&g?M(g):t&&window.location.assign(t)},"onSuccess")}),y=S({mutationFn:i(()=>j.post(`${a}/${encodeURIComponent(r)}/dot-pairing`,{pairingCode:p.trim()}),"mutationFn"),onSuccess:i(({redirectUrl:t})=>{R(""),window.location.assign(t)},"onSuccess")});if(k)return(0,e.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,e.jsxs)(v,{className:"block space-y-4 p-6",children:[(0,e.jsx)(z,{className:"size-8 text-ink"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:k==="approved"?"Access approved":"Connection declined"}),(0,e.jsx)("p",{className:"text-sm",children:k==="approved"?"Return to your assistant. It will finish connecting automatically.":"No access was granted. You can start a new connection from your assistant."}),(0,e.jsx)(h,{variant:"secondary",asChild:!0,children:(0,e.jsx)(W,{to:"/",children:"Back to Wardmote"})})]})});const Y=n?`/mcp-device?user_code=${encodeURIComponent(r)}`:`${d?"/dot-connect":"/mcp-connect"}/${r}`;return(0,e.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,e.jsxs)(v,{className:"block space-y-4 p-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(z,{className:"size-8 shrink-0 text-ink",title:"Wardmote"}),(0,e.jsxs)("h1",{className:"min-w-0 break-words text-xl font-semibold",children:["Connect ",(0,e.jsx)("bdi",{children:B})," to Wardmote"]})]}),C&&(0,e.jsx)(_,{origin:C},C),!n&&s?.redirectOrigin&&s.redirectOrigin!==C&&(0,e.jsx)(_,{origin:s.redirectOrigin},s.redirectOrigin),n&&(0,e.jsxs)("p",{className:"text-sm",children:["Confirm this matches the code shown by your assistant: ",(0,e.jsx)("strong",{className:"font-mono",children:r.toUpperCase()})]}),f.isPending&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading connection request…"}),f.error&&(0,e.jsxs)("p",{className:"text-sm text-bad",children:[f.error.message," Start a new connection from your assistant."]}),n&&f.error&&(0,e.jsx)(h,{variant:"secondary",onClick:o,children:"Enter a different code"}),s?.agentConnection&&!n&&(0,e.jsxs)("form",{className:"space-y-3",onSubmit:i(t=>{t.preventDefault(),y.mutate()},"onSubmit"),children:[(0,e.jsx)("p",{className:"text-sm",children:"Enter the one-use code from your Dot setup prompt to review this agent’s access. Access is granted when you click “Connect Dot with pairing code”."}),(0,e.jsx)("label",{htmlFor:"dot-pairing-code",className:"text-sm",children:"Pairing code"}),(0,e.jsx)(A,{id:"dot-pairing-code",type:"password",autoComplete:"off",value:p,onChange:i(t=>{b(null),w(""),R(t.target.value)},"onChange"),required:!0,maxLength:32}),u&&(0,e.jsxs)("dl",{className:"space-y-2 rounded-md border border-line p-3 text-sm",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Company"}),(0,e.jsxs)("dd",{children:[u.company.name," ",(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.company.id,")"]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Agent"}),(0,e.jsxs)("dd",{children:[u.agent.name," ",(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.agent.id,")"]})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Permissions"}),(0,e.jsx)("dd",{children:u.permissions})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Access duration"}),(0,e.jsx)("dd",{children:u.accessDuration})]})]}),$&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:$}),y.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:y.error.message}),(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(h,{type:"submit",disabled:!u||!/^[A-Za-z0-9_-]{32}$/.test(p.trim())||y.isPending,children:y.isPending?"Connecting…":"Connect Dot with pairing code"})})]}),s&&(0,e.jsx)(e.Fragment,{children:s.requiresSignIn?(0,e.jsx)(h,{asChild:!0,children:(0,e.jsx)(W,{to:`/auth?next=${encodeURIComponent(Y)}`,children:"Sign in / Create account"})}):(0,e.jsxs)(e.Fragment,{children:[s.requestedCompanyId?(0,e.jsxs)("div",{className:"flex items-center gap-4 rounded-md border border-line p-4",children:[c&&(0,e.jsx)(U,{companyName:c.name,logoUrl:c.logoUrl,className:"size-14 shrink-0 rounded-lg text-xl"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Organization"}),c?(0,e.jsx)("p",{className:"break-words text-lg font-semibold",children:c.name}):(0,e.jsx)("p",{className:"text-sm text-bad",children:"The selected organization is no longer available to this account. Cancel and reconnect from your assistant to choose an organization you can access."})]})]}):(0,e.jsxs)("fieldset",{className:"space-y-2",disabled:x.isPending,children:[(0,e.jsx)("legend",{className:"mb-2 text-sm font-medium",children:"Organization"}),s.companies.map(t=>(0,e.jsxs)("label",{className:"flex items-center gap-3 rounded-md border border-line p-3 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:"company","aria-label":t.name,value:t.id,checked:P===t.id,onChange:i(()=>N(t.id),"onChange")}),(0,e.jsx)(U,{companyName:t.name,logoUrl:t.logoUrl,className:"size-12 shrink-0 rounded-lg"}),(0,e.jsx)("span",{className:"min-w-0 break-words font-medium",children:t.name})]},t.id)),!s.companies.length&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This account has no available organizations. Ask an organization owner to add you, then reconnect from your assistant."})]}),(0,e.jsx)("p",{className:"text-sm",children:s.agentConnection?"Connect Dot as a Wardmote agent. Pair it with an agent after connecting; assigned work uses that agent’s permissions.":"Read all of your Wardmote data"}),(s.requestedWrite||s.requestedConfigure)&&!s.agentConnection&&(0,e.jsxs)("label",{htmlFor:"mcp-allow-writes",className:"flex items-start gap-3 text-sm leading-6",children:[(0,e.jsx)("span",{className:"flex h-6 shrink-0 items-center",children:(0,e.jsx)(V,{id:"mcp-allow-writes",checked:I,disabled:!c?.canWrite||x.isPending,onCheckedChange:i(t=>L(t===!0),"onCheckedChange")})}),(0,e.jsx)("span",{children:"Write all of your Wardmote data"})]}),c&&!c.canWrite&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Your role in this organization is read-only."}),x.error&&(0,e.jsx)("p",{className:"text-sm text-bad",children:x.error.message}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)(h,{variant:"secondary",disabled:x.isPending,onClick:i(()=>x.mutate("deny"),"onClick"),children:"Cancel"}),(0,e.jsx)(h,{className:"h-auto min-h-10 min-w-0 shrink whitespace-normal",disabled:!c||s.agentConnection&&!c.canWrite||x.isPending,onClick:i(()=>x.mutate("approve"),"onClick"),children:x.isPending?"Connecting…":s.agentConnection?"Connect Dot agent":"Connect organization"})]})]})})]})})}i(F,"McpConnectRequest");function ye(){const r=X(),n=E({queryKey:["mcp-connections"],queryFn:i(()=>j.get("/mcp/connections"),"queryFn"),retry:!1}),d=n.data?.filter(a=>!a.revokedAt),o=S({mutationFn:i(a=>j.delete(`/mcp/connections/${a}`),"mutationFn"),onSuccess:i((a,m)=>(r.setQueryData(["mcp-connections"],N=>N?.filter(p=>p.id!==m)),r.invalidateQueries({queryKey:["mcp-connections"]})),"onSuccess")});return(0,e.jsxs)("div",{className:"mx-auto max-w-xl space-y-4 py-10",children:[(0,e.jsx)("h1",{className:"text-xl font-semibold",children:"Assistant connections"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Revoking a connection stops its future tool calls. Work already delegated continues under your organization’s normal controls."}),n.isPending&&(0,e.jsx)("p",{className:"text-sm",children:"Loading connections…"}),(n.error||o.error)&&(0,e.jsx)("p",{className:"text-sm text-bad",children:(n.error??o.error)?.message}),d?.length===0&&(0,e.jsx)("p",{className:"text-sm",children:"No assistant connections."}),d?.map(a=>(0,e.jsxs)(v,{className:"block space-y-2 p-4",children:[(0,e.jsx)("h2",{className:"font-medium",children:(0,e.jsx)(se,{name:te(a),avatarUrl:a.user?.image,initials:ee(a.user?.name??"You")})}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["Organization: ",a.companyName]}),(0,e.jsx)("p",{className:"text-sm",children:a.scopes.includes("wardmote:agent")?"Dot agent connection":a.scopes.includes("wardmote:write")?"Read and edit work":"Read only"}),a.scopes.includes("wardmote:configure")&&(0,e.jsx)("p",{className:"text-sm",children:"Configure agents, projects and skills"}),(0,e.jsx)(h,{variant:"secondary",disabled:o.isPending,onClick:i(()=>o.mutate(a.id),"onClick"),children:"Revoke connection"})]},a.id)),(0,e.jsx)(W,{className:"text-sm underline",to:"/",children:"Back to Wardmote"})]})}i(ye,"AssistantConnectionsPage");export{ye as AssistantConnectionsPage,je as McpConnectPage,fe as McpDevicePage};
@@ -1 +1 @@
1
- var y=Object.defineProperty;var r=(o,i)=>y(o,"name",{value:i,configurable:!0});import{i as L}from"./rolldown-runtime-ZpX3ckPj.js";import{l as n,ta as b}from"./createLucideIcon-DJi9suAC.js";import{r as j,t as v}from"./button-CMwV3L1P.js";import{t as _}from"./log-in-nSyhNjrD.js";import{ka as d}from"./index-DDoARkPG.js";var t=L(b(),1);function N({state:o,resourceName:i,pending:a=!1,pendingState:l=null,compact:c=!1,onJoin:m,onLeave:p}){const s=o==="left",f=a?l==="left"?"Leaving...":"Joining...":s?"Join":"Leave",u=`${s?"Join":"Leave"} ${i}`,x=a?j:s?_:d;function h(e){e.preventDefault(),e.stopPropagation(),!a&&(s?m():p())}return r(h,"handleClick"),(0,t.jsx)("span",{className:n("flex w-(--sz-66px) shrink-0 justify-end",!s&&!c?"opacity-100 sm:opacity-0 sm:transition-opacity sm:group-hover:opacity-100 sm:group-focus-within:opacity-100":"opacity-100"),children:(0,t.jsxs)(v,{type:"button",size:"xs",variant:"ghost","aria-label":u,"aria-busy":a?"true":void 0,disabled:a,onClick:h,className:"w-(--sz-66px)",children:[(0,t.jsx)(x,{className:n("h-3 w-3",a&&"motion-safe:animate-spin")}),(0,t.jsx)("span",{children:f})]})})}r(N,"MembershipAction");export{N as t};
1
+ var y=Object.defineProperty;var r=(o,i)=>y(o,"name",{value:i,configurable:!0});import{i as L}from"./rolldown-runtime-ZpX3ckPj.js";import{l as n,ta as b}from"./createLucideIcon-DJi9suAC.js";import{r as j,t as v}from"./button-CMwV3L1P.js";import{t as _}from"./log-in-nSyhNjrD.js";import{ka as d}from"./index-3AxqhPET.js";var t=L(b(),1);function N({state:o,resourceName:i,pending:a=!1,pendingState:l=null,compact:c=!1,onJoin:m,onLeave:p}){const s=o==="left",f=a?l==="left"?"Leaving...":"Joining...":s?"Join":"Leave",u=`${s?"Join":"Leave"} ${i}`,x=a?j:s?_:d;function h(e){e.preventDefault(),e.stopPropagation(),!a&&(s?m():p())}return r(h,"handleClick"),(0,t.jsx)("span",{className:n("flex w-(--sz-66px) shrink-0 justify-end",!s&&!c?"opacity-100 sm:opacity-0 sm:transition-opacity sm:group-hover:opacity-100 sm:group-focus-within:opacity-100":"opacity-100"),children:(0,t.jsxs)(v,{type:"button",size:"xs",variant:"ghost","aria-label":u,"aria-busy":a?"true":void 0,disabled:a,onClick:h,className:"w-(--sz-66px)",children:[(0,t.jsx)(x,{className:n("h-3 w-3",a&&"motion-safe:animate-spin")}),(0,t.jsx)("span",{children:f})]})})}r(N,"MembershipAction");export{N as t};
@@ -1 +1 @@
1
- var g=Object.defineProperty;var i=(l,t)=>g(l,"name",{value:t,configurable:!0});import{i as j}from"./rolldown-runtime-ZpX3ckPj.js";import{na as v,ta as y}from"./createLucideIcon-DJi9suAC.js";import{X as N,t as k}from"./queryKeys-DYV5MhM_.js";import{n as M}from"./CompanyContext-CSrVsSze.js";import{t as u}from"./button-CMwV3L1P.js";import{t as w}from"./plus-C6fnr28l.js";import{t as P}from"./refresh-cw-B_Oki9wZ.js";import{t as C}from"./agents-DmlgUVso.js";import{n as S}from"./BreadcrumbContext-BVZDZoC0.js";import{At as O,jt as A}from"./index-DDoARkPG.js";import{l as _,n as f}from"./omp-settings-model-uqWvMNr2.js";var n=j(v(),1),e=j(y(),1);function F(){const{setBreadcrumbs:l}=S(),{selectedCompanyId:t}=M(),m=N(),r=_(t),[c,x]=(0,n.useState)(!1),[p,b]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l([{label:"Settings",href:"/company/settings"},{label:"Models and providers"}])},[l]);const h=(0,n.useMemo)(()=>{const s=new Map;for(const a of r.data??[]){const d=a.provider??a.id.split("/")[0]??"";s.set(d,(s.get(d)??0)+1)}return[...s.entries()].sort(([a],[d])=>a.localeCompare(d))},[r.data]),o=(0,n.useCallback)(async()=>{if(t){x(!0);try{const s=await C.adapterModels(t,f,{refresh:!0});m.setQueryData(k.agents.adapterModels(t,f),s)}finally{x(!1)}}},[m,t]);return t?(0,e.jsxs)("div",{className:"max-w-4xl space-y-5 pb-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Models and providers"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Imported from OMP. Sign-ins stay in OMP's credential store and custom keys in its models.yml; Wardmote never shows them."})]}),(0,e.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,e.jsxs)(u,{type:"button",variant:"secondary",size:"sm",disabled:c,onClick:o,children:[(0,e.jsx)(P,{"aria-hidden":"true",className:c?"motion-safe:animate-spin":void 0}),"Check again"]}),(0,e.jsxs)(u,{type:"button",size:"sm",onClick:i(()=>b(s=>!s),"onClick"),"aria-expanded":p,children:[(0,e.jsx)(w,{"aria-hidden":"true"}),"Sign in to a provider"]})]})]}),p?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-line bg-bg-2 px-4 py-3 text-sm sm:px-5",children:[(0,e.jsxs)("p",{className:"text-ink-2",children:["Runs ",(0,e.jsx)("code",{className:"font-mono text-xs",children:"omp login"})," on the Wardmote server. OMP keeps the sign-in."]}),(0,e.jsx)(A,{autoFocus:!0,onSignedIn:i(()=>{o()},"onSignedIn")})]}):null,r.error?(0,e.jsxs)("div",{role:"alert",className:"rounded-md border border-warn px-3 py-2 text-sm text-ink-2",children:["OMP did not answer: ",r.error.message,". Check that omp is installed and on the server's PATH."]}):null,(0,e.jsxs)("section",{"aria-labelledby":"providers-title",className:"overflow-hidden rounded-lg border border-line bg-bg-2",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-3 border-b border-line px-4 py-2.5 sm:px-5",children:[(0,e.jsx)("h2",{id:"providers-title",className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Providers"}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:r.data?`${r.data.length} models`:""})]}),r.isLoading?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"Asking OMP..."}):h.length===0?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"OMP reports no signed-in provider yet. Use Sign in to a provider, or add a custom provider below."}):(0,e.jsx)("div",{className:"px-4 sm:px-5",children:(0,e.jsxs)("table",{"aria-label":"Providers",className:"stack-table w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-xs text-ink-3",children:[(0,e.jsx)("th",{className:"py-2 font-medium",children:"Provider"}),(0,e.jsx)("th",{className:"py-2 font-medium",children:"Models"}),(0,e.jsx)("th",{className:"py-2 text-right font-medium",children:"Status"})]})}),(0,e.jsx)("tbody",{children:h.map(([s,a])=>(0,e.jsxs)("tr",{className:"border-t border-line",children:[(0,e.jsx)("td",{"data-cell":"title",className:"font-medium",children:s}),(0,e.jsx)("td",{"data-cell":"meta","data-label":"Models",children:a}),(0,e.jsx)("td",{"data-cell":"end",className:"text-right",children:(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-ok",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"size-2 rounded-full bg-ok"}),"Signed in"]})})]},s))})]})})]}),(0,e.jsxs)("section",{"aria-labelledby":"custom-providers-title",className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{id:"custom-providers-title",className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Custom providers"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Your own gateway or local server (vLLM, LiteLLM, Ollama, any /v1 endpoint), saved to OMP's models.yml."})]}),(0,e.jsx)(O,{onChanged:i(()=>{o()},"onChanged")})]})]}):null}i(F,"ModelsAndProviders");export{F as ModelsAndProviders};
1
+ var g=Object.defineProperty;var i=(l,t)=>g(l,"name",{value:t,configurable:!0});import{i as j}from"./rolldown-runtime-ZpX3ckPj.js";import{na as v,ta as y}from"./createLucideIcon-DJi9suAC.js";import{X as N,t as k}from"./queryKeys-DYV5MhM_.js";import{n as M}from"./CompanyContext-CSrVsSze.js";import{t as u}from"./button-CMwV3L1P.js";import{t as w}from"./plus-C6fnr28l.js";import{t as P}from"./refresh-cw-B_Oki9wZ.js";import{t as C}from"./agents-DmlgUVso.js";import{n as S}from"./BreadcrumbContext-BVZDZoC0.js";import{At as O,jt as A}from"./index-3AxqhPET.js";import{l as _,n as f}from"./omp-settings-model-uqWvMNr2.js";var n=j(v(),1),e=j(y(),1);function F(){const{setBreadcrumbs:l}=S(),{selectedCompanyId:t}=M(),m=N(),r=_(t),[c,x]=(0,n.useState)(!1),[p,b]=(0,n.useState)(!1);(0,n.useEffect)(()=>{l([{label:"Settings",href:"/company/settings"},{label:"Models and providers"}])},[l]);const h=(0,n.useMemo)(()=>{const s=new Map;for(const a of r.data??[]){const d=a.provider??a.id.split("/")[0]??"";s.set(d,(s.get(d)??0)+1)}return[...s.entries()].sort(([a],[d])=>a.localeCompare(d))},[r.data]),o=(0,n.useCallback)(async()=>{if(t){x(!0);try{const s=await C.adapterModels(t,f,{refresh:!0});m.setQueryData(k.agents.adapterModels(t,f),s)}finally{x(!1)}}},[m,t]);return t?(0,e.jsxs)("div",{className:"max-w-4xl space-y-5 pb-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Models and providers"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Imported from OMP. Sign-ins stay in OMP's credential store and custom keys in its models.yml; Wardmote never shows them."})]}),(0,e.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,e.jsxs)(u,{type:"button",variant:"secondary",size:"sm",disabled:c,onClick:o,children:[(0,e.jsx)(P,{"aria-hidden":"true",className:c?"motion-safe:animate-spin":void 0}),"Check again"]}),(0,e.jsxs)(u,{type:"button",size:"sm",onClick:i(()=>b(s=>!s),"onClick"),"aria-expanded":p,children:[(0,e.jsx)(w,{"aria-hidden":"true"}),"Sign in to a provider"]})]})]}),p?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-line bg-bg-2 px-4 py-3 text-sm sm:px-5",children:[(0,e.jsxs)("p",{className:"text-ink-2",children:["Runs ",(0,e.jsx)("code",{className:"font-mono text-xs",children:"omp login"})," on the Wardmote server. OMP keeps the sign-in."]}),(0,e.jsx)(A,{autoFocus:!0,onSignedIn:i(()=>{o()},"onSignedIn")})]}):null,r.error?(0,e.jsxs)("div",{role:"alert",className:"rounded-md border border-warn px-3 py-2 text-sm text-ink-2",children:["OMP did not answer: ",r.error.message,". Check that omp is installed and on the server's PATH."]}):null,(0,e.jsxs)("section",{"aria-labelledby":"providers-title",className:"overflow-hidden rounded-lg border border-line bg-bg-2",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-3 border-b border-line px-4 py-2.5 sm:px-5",children:[(0,e.jsx)("h2",{id:"providers-title",className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Providers"}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:r.data?`${r.data.length} models`:""})]}),r.isLoading?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"Asking OMP..."}):h.length===0?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"OMP reports no signed-in provider yet. Use Sign in to a provider, or add a custom provider below."}):(0,e.jsx)("div",{className:"px-4 sm:px-5",children:(0,e.jsxs)("table",{"aria-label":"Providers",className:"stack-table w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"text-left text-xs text-ink-3",children:[(0,e.jsx)("th",{className:"py-2 font-medium",children:"Provider"}),(0,e.jsx)("th",{className:"py-2 font-medium",children:"Models"}),(0,e.jsx)("th",{className:"py-2 text-right font-medium",children:"Status"})]})}),(0,e.jsx)("tbody",{children:h.map(([s,a])=>(0,e.jsxs)("tr",{className:"border-t border-line",children:[(0,e.jsx)("td",{"data-cell":"title",className:"font-medium",children:s}),(0,e.jsx)("td",{"data-cell":"meta","data-label":"Models",children:a}),(0,e.jsx)("td",{"data-cell":"end",className:"text-right",children:(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-ok",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"size-2 rounded-full bg-ok"}),"Signed in"]})})]},s))})]})})]}),(0,e.jsxs)("section",{"aria-labelledby":"custom-providers-title",className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{id:"custom-providers-title",className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Custom providers"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Your own gateway or local server (vLLM, LiteLLM, Ollama, any /v1 endpoint), saved to OMP's models.yml."})]}),(0,e.jsx)(O,{onChanged:i(()=>{o()},"onChanged")})]})]}):null}i(F,"ModelsAndProviders");export{F as ModelsAndProviders};
@@ -1 +1 @@
1
- var vt=Object.defineProperty;var s=(n,a)=>vt(n,"name",{value:a,configurable:!0});import{i as Je}from"./rolldown-runtime-ZpX3ckPj.js";import{i as ze,l as ue,na as ht,ta as bt}from"./createLucideIcon-DJi9suAC.js";import{y as yt}from"./star-BZgQbzhV.js";import{X as jt,t as u,v as y}from"./queryKeys-DYV5MhM_.js";import{B as Ct,F as Nt,H as At,I as _t,J as St,K as kt,N as wt,P as Et,R as Dt,U as Le,V as Ot,W as Mt,X as Ye,Y as Pt,d as qt,et as Kt,f as It,h as Rt,m as Bt,p as Qe,tt as Ft,v as Ut,w as $t,y as zt,z as Lt}from"./ConnectionSetupFlow-DKjP5RBZ.js";import{n as Yt}from"./CompanyContext-CSrVsSze.js";import{o as Qt}from"./router-2UfGeejU.js";import{t as Tt}from"./arrow-left-Ce_LIut0.js";import{t as Te}from"./arrow-right-BL5kYtCZ.js";import{t as Ge}from"./check-Ctsrlfa-.js";import{r as Gt}from"./environment-variables-editor-CCxeFKKk.js";import{t as W}from"./button-CMwV3L1P.js";import{t as X}from"./agents-DmlgUVso.js";import{t as je}from"./instanceSettings-D8g_QlS-.js";import{t as Vt}from"./input-DobnTAyB.js";import{n as Ht}from"./BreadcrumbContext-BVZDZoC0.js";import{t as q}from"./secrets-CZifgF0J.js";import{c as Wt,d as Xt,l as Jt}from"./model-picker-fields-235ien8Z.js";import{c as Zt}from"./select-V0Hm_q4f.js";import{t as Ce}from"./adapter-display-registry-Bk0KWAHT.js";import{a as Ne,o as en}from"./agent-config-primitives-BsZUnbf2.js";import{t as Ve}from"./environments-BLQs1ScE.js";import{t as He}from"./managed-sandbox-environment-B8DewKvK.js";import{t as tn}from"./adapters-Dp0USyWg.js";import{t as nn}from"./AgentCharacter-BTEn5MBu.js";import{Ca as sn,It as an,ca as rn,jt as on}from"./index-DDoARkPG.js";var e=Je(bt(),1),i=Je(ht(),1);function ln({children:n,...a}){const o=(0,i.useContext)(Ye);a={...o,...a},a.transition=Kt(a.transition,o.transition),a.isStatic=Ft(()=>a.isStatic);const r=(0,i.useMemo)(()=>a,[JSON.stringify(a.transition),a.transformPagePoint,a.reducedMotion,a.skipAnimations,a.isValidProp]);return(0,e.jsx)(Ye.Provider,{value:r,children:n})}s(ln,"MotionConfig");var Ae={openrouter:"OPENROUTER_API_KEY",openai:"OPENAI_API_KEY",anthropic:"ANTHROPIC_API_KEY",google:"GEMINI_API_KEY",xai:"XAI_API_KEY",groq:"GROQ_API_KEY",opencode:"OPENCODE_API_KEY"};async function dn(n,a,o){const r=await q.create(n,{name:`${a} · agent setup`,key:`${a}.setup.${crypto.randomUUID()}`,value:o.trim(),description:"Adapter credential supplied during agent setup."});return{binding:{type:"secret_ref",secretId:r.id,version:"latest"},remove:s(()=>q.remove(r.id),"remove")}}s(dn,"storeOrganizationApiKey");async function cn(n,a,o){const r=`${a}.setup.${crypto.randomUUID()}`,C=await q.createUserSecretDefinition(n,{key:r,name:`${a} · agent setup`,description:"Model provider credential for a new agent setup."}),N=s(()=>q.removeUserSecretDefinition(n,C.id),"remove");try{await q.createMyUserSecret(n,{definitionId:C.id,definitionKey:r,value:o.trim()})}catch(k){throw await N(),k}return{binding:{type:"user_secret_ref",key:r,version:"latest"},remove:N}}s(cn,"storeProviderApiKey");function un({children:n,className:a}){return(0,e.jsx)("div",{className:ue("w-(--sz-560px) max-w-full rounded-xl border border-line bg-bg-2 px-8 py-10 sm:px-10 sm:py-11",a),children:n})}s(un,"OnboardingCard");function mn({title:n,lede:a,center:o}){return(0,e.jsxs)("div",{className:ue("space-y-2",o&&"text-center"),children:[(0,e.jsx)("h1",{className:"text-(length:--text-onboarding-title) font-semibold leading-(--leading-onboarding-title) tracking-tight text-ink",children:n}),a?(0,e.jsx)("p",{className:"text-base leading-relaxed text-ink-3",children:a}):null]})}s(mn,"OnboardingHeading");var We=Zt,Xe=s(n=>n.status==="fail"||n.checks.some(a=>a.code==="adapter_auth_missing"),"blocking");function pn(){const{selectedCompanyId:n}=Yt(),[a]=yt();return n?(0,e.jsx)(gn,{companyId:n,name:a.get("name")??"",adapterType:a.get("adapterType")??"",runnerProvider:a.get("runnerProvider")??(a.get("adapterType")==="wardmote_runner"?"codex":""),createdAgentId:a.get("createdAgentId")},`${n}:${a.get("name")}:${a.get("adapterType")}:${a.get("runnerProvider")}`):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Select an organization to create an agent."})}s(pn,"NewAgentSetup");function gn({companyId:n,name:a,adapterType:o,runnerProvider:r,createdAgentId:C}){const N=Qt(),k=jt(),{openNewIssue:Ze}=rn(),me=Rt(`${n}:new-agent`),z=o==="wardmote_runner",p=z&&r==="openai_dot",l=p?"openai_dot":z?r==="grok"?"grok_local":r==="claude"?"claude_local":r==="opencode"?"opencode_local":"codex_local":o,f=l==="claude_local"||l==="codex_local"||l==="grok_local"?l:null,w=l==="opencode_local",E=w,J=!p,[pe,et]=(0,i.useState)(!1),[D,K]=(0,i.useState)(C?"saved":f?"connect":"runtime"),[A,_e]=(0,i.useState)(""),[I,Se]=(0,i.useState)(""),[tt,nt]=(0,i.useState)(!1),[ge,st]=(0,i.useState)(""),[Z,ke]=(0,i.useState)("openrouter"),[fe,L]=(0,i.useState)(""),[at,ee]=(0,i.useState)(null),[we,Y]=(0,i.useState)(()=>l==="opencode_local"?{provider:"openrouter",method:"api_key",mode:"responsible_user"}:void 0),[x,R]=(0,i.useState)(null),v=we??x?.aiConnection,_=kt(n,v,l),[rt,ot]=(0,i.useState)(null),te=y({queryKey:u.agents.detail(C??"new"),queryFn:s(()=>X.get(C,n),"queryFn"),enabled:!!C,retry:!1}),c=rt??(te.data?.companyId===n?te.data:null),[Ee,De]=(0,i.useState)(!1),[S,ne]=(0,i.useState)("idle"),[xe,ve]=(0,i.useState)(null),[se,B]=(0,i.useState)(null),Q=(0,i.useRef)(0),he=(0,i.useRef)(!1);(0,i.useEffect)(()=>()=>{Q.current++},[]);const h=s(()=>{Q.current++,ve(null),ne("idle"),B(null)},"resetTest"),Oe=s(()=>{R(null),Y(void 0),h(),K("connect")},"editConnection"),be=y({queryKey:u.adapters.all,queryFn:tn.list}),ae=y({queryKey:u.agents.list(n),queryFn:s(()=>X.list(n),"queryFn")}),b=y({queryKey:u.environments.list(n),queryFn:s(()=>Ve.list(n),"queryFn")}),re=y({queryKey:u.instance.settings,queryFn:je.get}),O=y({queryKey:u.instance.experimentalSettings,queryFn:je.getExperimental}),oe=y({queryKey:u.instance.generalSettings,queryFn:je.getGeneral}),ie=y({queryKey:u.environments.capabilities(n),queryFn:s(()=>Ve.capabilities(n),"queryFn")}),T=y({queryKey:u.agents.adapterModels(n,l,null,v?.provider),queryFn:s(()=>X.adapterModels(n,l,{provider:v?.provider}),"queryFn"),enabled:!!l&&J&&!_,retry:!1}),Me=y({queryKey:u.secrets.list(n),queryFn:s(()=>q.list(n),"queryFn"),enabled:E}),it=y({queryKey:u.secrets.myUserSecrets(n),queryFn:s(()=>q.listMyUserSecrets(n),"queryFn"),enabled:E,retry:!1}),F=zt(oe.data?.executionMode,b.data??[]),G=O.data?.enableManagedSandboxOnly===!0;let j=null,le=null;try{j=F.forced?F.kubernetesEnvironment?.id??null:Et({agentDefaultEnvironmentId:ge||null,instanceDefaultEnvironmentId:re.data?.defaultEnvironmentId??null,localDefaultEnvironmentId:Nt(b.data??[]),managedSandboxOnly:G,managedSandboxEnvironmentId:_t(b.data??[]),visibleEnvironmentIds:(b.data??[]).map(t=>t.id)})}catch(t){le=t instanceof Error?t.message:"Could not resolve the environment."}const de=b.data?.find(t=>t.id===j),lt=typeof de?.config?.provider=="string"?de.config.provider:"",dt=de?.driver==="sandbox"&&ie.data?.sandboxProviders?.[lt]?.supportsLoginPty===!0,M=Ae[Z]??"API_KEY",ct=it.data?.find(t=>t.definition.key===M&&t.secret),Pe=Me.data?.find(t=>t.key===M&&t.status==="active"),U=at??(Pe?{type:"secret_ref",secretId:Pe.id,version:"latest"}:ct?{type:"user_secret_ref",key:M,version:"latest"}:null),qe=Bt(o,{nativeRunnerEnabled:O.data?.enableNativeRunner===!0,openAiDotEnabled:O.data?.enableOpenAiDot===!0,runnerProvider:r})&&be.data?.some(t=>t.type===o&&t.loaded&&!t.disabled&&!Ce(o).comingSoon),$=!!(qe&&!le&&!b.isPending&&!re.isPending&&!O.isPending&&!oe.isPending&&!ae.isPending&&!ie.isPending&&!b.error&&!re.error&&!O.error&&!oe.error&&!ae.error&&!ie.error&&(!(G||F.forced)||j)),P=S==="running"||Ee;function ut(t=x,g=U){const d={...wt,adapterType:o,model:A||(l==="codex_local"?Ct:""),thinkingEffort:I,envBindings:t?.env??{},...z?{adapterSchemaValues:{provider:r==="claude"||r==="grok"?"acpx":r,...p?{allowUnmeteredProvider:pe}:{},...r==="claude"||r==="grok"?{acpxAgent:r}:{}}}:{}},m=$t(o).buildAdapterConfig(d);return o==="omp_local"&&(delete m.thinkingEffort,I&&(m.thinking=I)),z&&Object.assign(m,{provider:r==="claude"||r==="grok"?"acpx":r,...r==="claude"||r==="grok"?{acpxAgent:r}:{},...A?{model:A}:{}}),!v&&!t?.aiConnection&&E&&g&&(m.env={...m.env??{},[M]:g}),m}s(ut,"buildConfig");function Ke(t=x){if(p&&!pe)throw new Error("Acknowledge external provider billing before creating your Dot agent.");if(w&&(!A.trim()||!A.includes("/")))throw new Error("Choose or enter a model in provider/model format.");return ut(t)}s(Ke,"preparedConfig");function Ie(t=x){return v||t?.aiConnection?{}:{...t?.credentials,...E&&fe.trim()?{[M]:fe.trim()}:{}}}s(Ie,"pendingCredentials");async function ye(t=x){if(!$)return!1;const g=++Q.current;ne("running"),ve(null),B(null);try{const d=await Ke(t),m=await At({companyId:n,adapterType:o,providerAdapter:l,adapterConfig:d,testCredentials:Ie(t),aiConnection:we??t?.aiConnection,environmentId:j});return g!==Q.current?!1:(ve(m),ne(Xe(m)?"fail":m.status),!Xe(m)&&(!f||m.checks.some(ce=>ce.code.endsWith("hello_probe_passed"))))}catch(d){return g===Q.current&&(B(d instanceof Error?d.message:"Could not test the agent."),ne("fail")),!1}}s(ye,"runTest");async function mt(){if(he.current||C||c||!$||!a.trim()||S==="running"||S==="fail"||f&&!x)return;he.current=!0,De(!0),B(null);const t=[];let g=!1;try{const d=Ke(),m=Ie();if(Object.keys(m).length&&!await ye())return;for(const[H,xt]of Object.entries(m)){const $e=await(f?cn:dn)(n,H,xt);t.push($e),d.env={...d.env??{},[H]:$e.binding}}const ce=ae.data??[],Ue=ce.find(H=>H.role==="ceo"&&H.status!=="terminated"),V=await X.hire(n,{name:a.trim(),appearance:me.appearance,role:ce.length?"general":"ceo",...Ue?{reportsTo:Ue.id}:{},adapterType:o,adapterConfig:d,defaultEnvironmentId:ge||(F.forced||G?j:null),runtimeConfig:{...an({heartbeatEnabled:!1}),...v?{aiConnection:v}:{}},budgetMonthlyCents:0,...x?.storedSessionId?{storedSessionId:x.storedSessionId}:{},...x?.applyStoredClaudeLogin?{applyStoredClaudeLogin:!0}:{}});g=!0,L(""),R(null),ot(V.agent),me.clear(),K("saved"),N(`/agents/new?${Qe({name:V.agent.name,adapterType:o,runnerProvider:r,createdAgentId:V.agent.id})}`,{replace:!0}),k.setQueryData(u.agents.detail(V.agent.id),V.agent),await Promise.all([k.invalidateQueries({queryKey:u.agents.list(n)}),k.invalidateQueries({queryKey:u.approvals.list(n)})])}catch(d){B(d instanceof Error?d.message:"Could not create the agent.")}finally{if(!g)try{await Promise.all(t.map(d=>d.remove()))}catch{B(d=>`${d?`${d} `:""}Could not remove an unused setup credential. Remove it from Secrets before retrying.`)}k.invalidateQueries({queryKey:u.secrets.myUserSecrets(n)}),k.invalidateQueries({queryKey:u.secrets.list(n)}),he.current=!1,De(!1)}}if(s(mt,"finish"),C&&!c)return(0,e.jsx)("p",{role:te.error?"alert":"status",className:"text-sm text-ink-3",children:te.error?"Could not load the created agent. Return to Agents to view it.":"Loading your agent…"});if(!a||!o)return(0,e.jsx)(It,{open:!0,initialAdapter:o,onClose:s(()=>N("/agents/all"),"onClose"),onContinue:s(t=>N(`/agents/new?${Qe(t)}`,{replace:!0}),"onContinue")});const pt=[...f?["connect"]:[],"runtime","saved"],gt={connect:"Connect",runtime:"Configure",saved:"Confirmation"},Re=c?.defaultEnvironmentId?b.data?.find(t=>t.id===c.defaultEnvironmentId):de,ft=c?.adapterConfig?.model||A||"Default",Be=Re?He(Re):"Local machine",Fe=be.error??b.error??re.error??O.error??oe.error??ae.error??ie.error;return(0,e.jsx)(ln,{reducedMotion:"user",children:(0,e.jsxs)("div",{className:"mx-auto flex max-w-5xl flex-col gap-8 py-6",children:[(0,e.jsxs)("header",{className:"flex items-center gap-4",children:[(0,e.jsx)(nn,{appearance:c?.appearance??me.appearance,size:256,className:"size-48",trackingScope:"page",state:c||S==="pass"?"success":S==="running"?"loading":"sleepy",muted:!c&&S!=="pass"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[(0,e.jsx)(Lt,{type:l}),(0,e.jsx)("span",{children:Ce(l).label}),z&&!p&&(0,e.jsxs)("span",{children:["·"," ",r==="codex"?"Native app server runner":"Wardmote Runner"]})]})]})]}),le&&!b.isPending&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:le}),Fe&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:Fe.message}),be.data&&!qe&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"This adapter is unavailable. Choose an enabled adapter."}),(G||F.forced)&&!b.isPending&&!j&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"No managed environment is available. Configure an environment before continuing."}),(0,e.jsxs)("div",{className:"flex flex-col gap-8 md:flex-row",children:[(0,e.jsx)("nav",{"aria-label":"Agent setup steps",className:"shrink-0 md:w-44",children:(0,e.jsx)("ol",{className:"flex flex-wrap gap-2 md:flex-col",children:pt.map((t,g)=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button","aria-current":t===D?"step":void 0,disabled:P||!!c||t==="saved",onClick:s(()=>t==="connect"&&D!=="connect"?Oe():K(t),"onClick"),className:ue("flex w-full items-center gap-3 rounded-md px-3 py-3 text-left text-sm",t===D?"bg-bg-3 font-medium":"text-ink-3"),children:[(0,e.jsx)("span",{className:ue("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",t===D?"border-ink bg-ink text-bg":"border-line"),children:g+1}),gt[t]]})},t))})}),(0,e.jsx)("div",{className:"min-w-0 flex-1",children:(0,e.jsx)(Pt,{mode:"wait",initial:!1,children:(0,e.jsx)(St.div,{...Dt,children:D==="connect"&&f?(0,e.jsxs)(un,{className:"mx-auto",children:[(0,e.jsx)("div",{className:"mb-8",children:(0,e.jsx)(mn,{title:"Connect a model",center:!0})}),$?(0,e.jsx)(qt,{companyId:n,adapterType:f,environmentId:j,canLogin:dt,advancedConnection:{value:v,content:(0,e.jsx)(Le,{companyId:n,agentName:a,adapterType:l,model:A,environmentId:j??void 0,value:v,preferAdvanced:!0,onChange:s(t=>{R(null),Y(t),h()},"onChange")})},onBack:s(()=>N("/agents/all"),"onBack"),onDraftChanged:s(()=>{R(null),Y(void 0),h()},"onDraftChanged"),testConnection:ye,testError:se??(xe?.checks.find(t=>t.level==="error")??xe?.checks.find(t=>t.code.includes("hello_probe")&&t.level==="warn"))?.message,onConnected:s(t=>{R(t),Y(void 0),h(),K("runtime")},"onConnected")},j??"local"):(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading connection settings…"})]}):D==="saved"&&c?(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-6 rounded-lg border border-line p-6",children:[(0,e.jsxs)("h2",{className:"flex items-center gap-3 text-lg font-semibold",children:[(0,e.jsx)(Ge,{className:"size-5"}),c.status==="pending_approval"?"Agent submitted for approval":p?"Your Dot agent has been created":"Your agent is ready"]}),(0,e.jsxs)("dl",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Adapter"}),(0,e.jsx)("dd",{children:Ce(p?"openai_dot":o).label}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Model"}),(0,e.jsx)("dd",{className:"break-all",children:String(ft)})]}),(0,e.jsx)("dt",{className:"text-ink-3",children:"Environment"}),(0,e.jsx)("dd",{children:Be})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:c.status==="pending_approval"?"An organization administrator must approve this agent before it can work.":p?"Pair your Dot and test event delivery in configuration before assigning work.":"Assign a task when you’re ready for this agent to work."})]}),(0,e.jsxs)("div",{className:"flex flex-wrap justify-between gap-3",children:[(0,e.jsxs)(W,{variant:"secondary",onClick:s(()=>N(p?"/agents/all":`${ze(c)}/runtime`),"onClick"),children:[(0,e.jsx)(sn,{className:"size-4"}),p?"Back to Agents":"Edit configuration"]}),(0,e.jsxs)(W,{disabled:c.status==="pending_approval",onClick:s(()=>p?N(`${ze(c)}/runtime`):Ze({assigneeAgentId:c.id,status:"todo"}),"onClick"),children:[p?"Pair Dot":`Assign ${c.name} a Task`,(0,e.jsx)(Te,{className:"size-4"})]})]})]}):(0,e.jsxs)("form",{className:"space-y-8",onSubmit:s(t=>{t.preventDefault(),mt()},"onSubmit"),children:[(0,e.jsx)("h2",{className:"text-xl font-semibold",children:"Configure your agent"}),(0,e.jsxs)("fieldset",{disabled:P,className:"space-y-8",children:[(0,e.jsxs)("section",{className:"space-y-5",children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Create this agent, then copy its pairing prompt to your Dot."}),O.data?.enablePublicMcp!==!0&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Turn on Assistant connections in Settings > Features before pairing."}),(0,e.jsx)(en,{label:"Allow externally billed provider",hint:"Dot does not report token usage or cost. Wardmote cannot enforce a provider spend ceiling; known company and agent budget limits still apply.",checked:pe,onChange:s(t=>{et(t),h()},"onChange")})]}),!f&&Mt(l)&&(0,e.jsx)(Le,{companyId:n,agentName:a,adapterType:l,model:A,environmentId:j??void 0,value:v,onChange:s(t=>{Y(t),h()},"onChange")}),(_?_.error:T.error)&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"Could not load models. Retry or enter a model ID manually."}),o==="omp_local"&&T.isSuccess&&T.data.length===0&&(0,e.jsxs)("section",{"aria-label":"Connect a model",className:"space-y-3 rounded-lg border border-line bg-bg-2 px-4 py-3",children:[(0,e.jsx)("p",{className:"text-sm text-ink-2",children:"OMP has no signed-in model yet. Sign in to a provider here, or add your own server in Settings, Models and providers."}),(0,e.jsx)(on,{onSignedIn:s(()=>{X.adapterModels(n,l,{refresh:!0}).then(t=>k.setQueryData(u.agents.adapterModels(n,l,null,v?.provider),t))},"onSignedIn")})]}),J&&(0,e.jsx)("div",{className:"grid items-start gap-5 sm:grid-cols-2",children:J&&(0,e.jsx)(Ut,{models:_?.models??T.data??[],onRefreshModels:_?.refreshModels,refreshingModels:_?.refreshing,value:A,onChange:s(t=>{_e(_?.resolveModel(t)??t),(o==="omp_local"?!Wt(I,t,(T.data??[]).map(d=>Jt(d,!1))):I)&&Se("");const g=t.split("/")[0];w&&Ae[g]&&g!==Z&&(ke(g),L(""),ee(null)),h()},"onChange"),open:tt,onOpenChange:nt,allowDefault:!w,required:w,creatable:!0,groupByProvider:w&&!_,preserveOrder:!!_||Xt(l),effort:o==="omp_local"?{value:I||null,onChange:s(t=>{Se(t??""),h()},"onChange")}:void 0})}),E&&!v&&(0,e.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[E&&(0,e.jsx)(Ne,{label:"API key provider",children:(0,e.jsx)("select",{"aria-label":"API key provider",className:We,value:Z,onChange:s(t=>{ke(t.target.value),_e(""),L(""),ee(null),h()},"onChange"),children:Object.keys(Ae).map(t=>(0,e.jsx)("option",{value:t,children:t==="openrouter"?"OpenRouter":t==="openai"?"OpenAI":t==="anthropic"?"Anthropic":{google:"Google",xai:"xAI",groq:"Groq",opencode:"OpenCode"}[t]??t},t))})}),(0,e.jsx)("div",{children:(0,e.jsx)(Ne,{label:M,children:(0,e.jsx)("div",{className:"flex items-center gap-3",children:(0,e.jsx)(Vt,{"aria-label":M,type:"password",autoComplete:"off",value:fe,onChange:s(t=>{L(t.target.value),ee(null),h()},"onChange"),placeholder:U?"Using saved key":"Optional if already configured"})})})}),(0,e.jsx)("div",{className:E?"sm:col-span-2":void 0,children:(0,e.jsx)(Ne,{label:"Or use an organization secret",children:(0,e.jsx)(Gt,{secretId:U&&typeof U=="object"&&U.type==="secret_ref"?U.secretId:"",secrets:Me.data??[],disabled:P,onSelect:s(t=>{ee({type:"secret_ref",secretId:t,version:"latest"}),L(""),h()},"onSelect")})})}),(0,e.jsxs)("p",{className:"text-xs text-ink-3 sm:col-span-2",children:["New keys are saved as organization secrets when you finish setup.",w&&` Use a ${Z}/model ID.`]})]})]}),(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Environment"}),(0,e.jsxs)("select",{"aria-label":"Environment",className:We,value:ge,disabled:F.forced,onChange:s(t=>{st(t.target.value),R(null),h(),f&&K("connect")},"onChange"),children:[(0,e.jsxs)("option",{value:"",children:["Default: ",Be]}),(b.data??[]).filter(t=>t.status==="active"&&(!G||t.driver!=="local")).map(t=>(0,e.jsx)("option",{value:t.id,children:He(t)},t.id))]})]})]}),(0,e.jsx)(Ot,{variant:p?"prerequisites":"connection",state:S,result:xe,error:se,disabled:!$||P||!!(f&&!x),onTest:s(()=>{ye()},"onTest")}),se&&S!=="fail"&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:se}),(0,e.jsxs)("div",{className:"flex justify-between border-t border-line py-5",children:[f?(0,e.jsxs)(W,{type:"button",variant:"ghost",disabled:P,onClick:Oe,children:[(0,e.jsx)(Tt,{className:"size-4"}),"Connection"]}):(0,e.jsx)("span",{}),f&&!x?(0,e.jsxs)(W,{type:"button",disabled:!$||P,onClick:s(()=>K("connect"),"onClick"),children:["Connect model",(0,e.jsx)(Te,{className:"size-4"})]}):(0,e.jsxs)(W,{type:"submit",disabled:!$||P||S==="fail"||!!(f&&!x),children:[Ee?"Creating…":"Finish setup",(0,e.jsx)(Ge,{className:"size-4"})]})]})]})},D)})})]})]})})}s(gn,"Setup");function Ln(){const{setBreadcrumbs:n}=Ht();return(0,i.useEffect)(()=>{n([{label:"Agents",href:"/agents"},{label:"New agent"}])},[n]),(0,e.jsx)(pn,{})}s(Ln,"NewAgent");export{Ln as NewAgent};
1
+ var vt=Object.defineProperty;var s=(n,a)=>vt(n,"name",{value:a,configurable:!0});import{i as Je}from"./rolldown-runtime-ZpX3ckPj.js";import{i as ze,l as ue,na as ht,ta as bt}from"./createLucideIcon-DJi9suAC.js";import{y as yt}from"./star-BZgQbzhV.js";import{X as jt,t as u,v as y}from"./queryKeys-DYV5MhM_.js";import{B as Ct,F as Nt,H as At,I as _t,J as St,K as kt,N as wt,P as Et,R as Dt,U as Le,V as Ot,W as Mt,X as Ye,Y as Pt,d as qt,et as Kt,f as It,h as Rt,m as Bt,p as Qe,tt as Ft,v as Ut,w as $t,y as zt,z as Lt}from"./ConnectionSetupFlow-BaarToKu.js";import{n as Yt}from"./CompanyContext-CSrVsSze.js";import{o as Qt}from"./router-2UfGeejU.js";import{t as Tt}from"./arrow-left-Ce_LIut0.js";import{t as Te}from"./arrow-right-BL5kYtCZ.js";import{t as Ge}from"./check-Ctsrlfa-.js";import{r as Gt}from"./environment-variables-editor-0qgSPgNN.js";import{t as W}from"./button-CMwV3L1P.js";import{t as X}from"./agents-DmlgUVso.js";import{t as je}from"./instanceSettings-D8g_QlS-.js";import{t as Vt}from"./input-DobnTAyB.js";import{n as Ht}from"./BreadcrumbContext-BVZDZoC0.js";import{t as q}from"./secrets-CZifgF0J.js";import{c as Wt,d as Xt,l as Jt}from"./model-picker-fields-235ien8Z.js";import{c as Zt}from"./select-V0Hm_q4f.js";import{t as Ce}from"./adapter-display-registry-Bk0KWAHT.js";import{a as Ne,o as en}from"./agent-config-primitives-BsZUnbf2.js";import{t as Ve}from"./environments-BLQs1ScE.js";import{t as He}from"./managed-sandbox-environment-B8DewKvK.js";import{t as tn}from"./adapters-Dp0USyWg.js";import{t as nn}from"./AgentCharacter-BTEn5MBu.js";import{Ca as sn,It as an,ca as rn,jt as on}from"./index-3AxqhPET.js";var e=Je(bt(),1),i=Je(ht(),1);function ln({children:n,...a}){const o=(0,i.useContext)(Ye);a={...o,...a},a.transition=Kt(a.transition,o.transition),a.isStatic=Ft(()=>a.isStatic);const r=(0,i.useMemo)(()=>a,[JSON.stringify(a.transition),a.transformPagePoint,a.reducedMotion,a.skipAnimations,a.isValidProp]);return(0,e.jsx)(Ye.Provider,{value:r,children:n})}s(ln,"MotionConfig");var Ae={openrouter:"OPENROUTER_API_KEY",openai:"OPENAI_API_KEY",anthropic:"ANTHROPIC_API_KEY",google:"GEMINI_API_KEY",xai:"XAI_API_KEY",groq:"GROQ_API_KEY",opencode:"OPENCODE_API_KEY"};async function dn(n,a,o){const r=await q.create(n,{name:`${a} · agent setup`,key:`${a}.setup.${crypto.randomUUID()}`,value:o.trim(),description:"Adapter credential supplied during agent setup."});return{binding:{type:"secret_ref",secretId:r.id,version:"latest"},remove:s(()=>q.remove(r.id),"remove")}}s(dn,"storeOrganizationApiKey");async function cn(n,a,o){const r=`${a}.setup.${crypto.randomUUID()}`,C=await q.createUserSecretDefinition(n,{key:r,name:`${a} · agent setup`,description:"Model provider credential for a new agent setup."}),N=s(()=>q.removeUserSecretDefinition(n,C.id),"remove");try{await q.createMyUserSecret(n,{definitionId:C.id,definitionKey:r,value:o.trim()})}catch(k){throw await N(),k}return{binding:{type:"user_secret_ref",key:r,version:"latest"},remove:N}}s(cn,"storeProviderApiKey");function un({children:n,className:a}){return(0,e.jsx)("div",{className:ue("w-(--sz-560px) max-w-full rounded-xl border border-line bg-bg-2 px-8 py-10 sm:px-10 sm:py-11",a),children:n})}s(un,"OnboardingCard");function mn({title:n,lede:a,center:o}){return(0,e.jsxs)("div",{className:ue("space-y-2",o&&"text-center"),children:[(0,e.jsx)("h1",{className:"text-(length:--text-onboarding-title) font-semibold leading-(--leading-onboarding-title) tracking-tight text-ink",children:n}),a?(0,e.jsx)("p",{className:"text-base leading-relaxed text-ink-3",children:a}):null]})}s(mn,"OnboardingHeading");var We=Zt,Xe=s(n=>n.status==="fail"||n.checks.some(a=>a.code==="adapter_auth_missing"),"blocking");function pn(){const{selectedCompanyId:n}=Yt(),[a]=yt();return n?(0,e.jsx)(gn,{companyId:n,name:a.get("name")??"",adapterType:a.get("adapterType")??"",runnerProvider:a.get("runnerProvider")??(a.get("adapterType")==="wardmote_runner"?"codex":""),createdAgentId:a.get("createdAgentId")},`${n}:${a.get("name")}:${a.get("adapterType")}:${a.get("runnerProvider")}`):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Select an organization to create an agent."})}s(pn,"NewAgentSetup");function gn({companyId:n,name:a,adapterType:o,runnerProvider:r,createdAgentId:C}){const N=Qt(),k=jt(),{openNewIssue:Ze}=rn(),me=Rt(`${n}:new-agent`),z=o==="wardmote_runner",p=z&&r==="openai_dot",l=p?"openai_dot":z?r==="grok"?"grok_local":r==="claude"?"claude_local":r==="opencode"?"opencode_local":"codex_local":o,f=l==="claude_local"||l==="codex_local"||l==="grok_local"?l:null,w=l==="opencode_local",E=w,J=!p,[pe,et]=(0,i.useState)(!1),[D,K]=(0,i.useState)(C?"saved":f?"connect":"runtime"),[A,_e]=(0,i.useState)(""),[I,Se]=(0,i.useState)(""),[tt,nt]=(0,i.useState)(!1),[ge,st]=(0,i.useState)(""),[Z,ke]=(0,i.useState)("openrouter"),[fe,L]=(0,i.useState)(""),[at,ee]=(0,i.useState)(null),[we,Y]=(0,i.useState)(()=>l==="opencode_local"?{provider:"openrouter",method:"api_key",mode:"responsible_user"}:void 0),[x,R]=(0,i.useState)(null),v=we??x?.aiConnection,_=kt(n,v,l),[rt,ot]=(0,i.useState)(null),te=y({queryKey:u.agents.detail(C??"new"),queryFn:s(()=>X.get(C,n),"queryFn"),enabled:!!C,retry:!1}),c=rt??(te.data?.companyId===n?te.data:null),[Ee,De]=(0,i.useState)(!1),[S,ne]=(0,i.useState)("idle"),[xe,ve]=(0,i.useState)(null),[se,B]=(0,i.useState)(null),Q=(0,i.useRef)(0),he=(0,i.useRef)(!1);(0,i.useEffect)(()=>()=>{Q.current++},[]);const h=s(()=>{Q.current++,ve(null),ne("idle"),B(null)},"resetTest"),Oe=s(()=>{R(null),Y(void 0),h(),K("connect")},"editConnection"),be=y({queryKey:u.adapters.all,queryFn:tn.list}),ae=y({queryKey:u.agents.list(n),queryFn:s(()=>X.list(n),"queryFn")}),b=y({queryKey:u.environments.list(n),queryFn:s(()=>Ve.list(n),"queryFn")}),re=y({queryKey:u.instance.settings,queryFn:je.get}),O=y({queryKey:u.instance.experimentalSettings,queryFn:je.getExperimental}),oe=y({queryKey:u.instance.generalSettings,queryFn:je.getGeneral}),ie=y({queryKey:u.environments.capabilities(n),queryFn:s(()=>Ve.capabilities(n),"queryFn")}),T=y({queryKey:u.agents.adapterModels(n,l,null,v?.provider),queryFn:s(()=>X.adapterModels(n,l,{provider:v?.provider}),"queryFn"),enabled:!!l&&J&&!_,retry:!1}),Me=y({queryKey:u.secrets.list(n),queryFn:s(()=>q.list(n),"queryFn"),enabled:E}),it=y({queryKey:u.secrets.myUserSecrets(n),queryFn:s(()=>q.listMyUserSecrets(n),"queryFn"),enabled:E,retry:!1}),F=zt(oe.data?.executionMode,b.data??[]),G=O.data?.enableManagedSandboxOnly===!0;let j=null,le=null;try{j=F.forced?F.kubernetesEnvironment?.id??null:Et({agentDefaultEnvironmentId:ge||null,instanceDefaultEnvironmentId:re.data?.defaultEnvironmentId??null,localDefaultEnvironmentId:Nt(b.data??[]),managedSandboxOnly:G,managedSandboxEnvironmentId:_t(b.data??[]),visibleEnvironmentIds:(b.data??[]).map(t=>t.id)})}catch(t){le=t instanceof Error?t.message:"Could not resolve the environment."}const de=b.data?.find(t=>t.id===j),lt=typeof de?.config?.provider=="string"?de.config.provider:"",dt=de?.driver==="sandbox"&&ie.data?.sandboxProviders?.[lt]?.supportsLoginPty===!0,M=Ae[Z]??"API_KEY",ct=it.data?.find(t=>t.definition.key===M&&t.secret),Pe=Me.data?.find(t=>t.key===M&&t.status==="active"),U=at??(Pe?{type:"secret_ref",secretId:Pe.id,version:"latest"}:ct?{type:"user_secret_ref",key:M,version:"latest"}:null),qe=Bt(o,{nativeRunnerEnabled:O.data?.enableNativeRunner===!0,openAiDotEnabled:O.data?.enableOpenAiDot===!0,runnerProvider:r})&&be.data?.some(t=>t.type===o&&t.loaded&&!t.disabled&&!Ce(o).comingSoon),$=!!(qe&&!le&&!b.isPending&&!re.isPending&&!O.isPending&&!oe.isPending&&!ae.isPending&&!ie.isPending&&!b.error&&!re.error&&!O.error&&!oe.error&&!ae.error&&!ie.error&&(!(G||F.forced)||j)),P=S==="running"||Ee;function ut(t=x,g=U){const d={...wt,adapterType:o,model:A||(l==="codex_local"?Ct:""),thinkingEffort:I,envBindings:t?.env??{},...z?{adapterSchemaValues:{provider:r==="claude"||r==="grok"?"acpx":r,...p?{allowUnmeteredProvider:pe}:{},...r==="claude"||r==="grok"?{acpxAgent:r}:{}}}:{}},m=$t(o).buildAdapterConfig(d);return o==="omp_local"&&(delete m.thinkingEffort,I&&(m.thinking=I)),z&&Object.assign(m,{provider:r==="claude"||r==="grok"?"acpx":r,...r==="claude"||r==="grok"?{acpxAgent:r}:{},...A?{model:A}:{}}),!v&&!t?.aiConnection&&E&&g&&(m.env={...m.env??{},[M]:g}),m}s(ut,"buildConfig");function Ke(t=x){if(p&&!pe)throw new Error("Acknowledge external provider billing before creating your Dot agent.");if(w&&(!A.trim()||!A.includes("/")))throw new Error("Choose or enter a model in provider/model format.");return ut(t)}s(Ke,"preparedConfig");function Ie(t=x){return v||t?.aiConnection?{}:{...t?.credentials,...E&&fe.trim()?{[M]:fe.trim()}:{}}}s(Ie,"pendingCredentials");async function ye(t=x){if(!$)return!1;const g=++Q.current;ne("running"),ve(null),B(null);try{const d=await Ke(t),m=await At({companyId:n,adapterType:o,providerAdapter:l,adapterConfig:d,testCredentials:Ie(t),aiConnection:we??t?.aiConnection,environmentId:j});return g!==Q.current?!1:(ve(m),ne(Xe(m)?"fail":m.status),!Xe(m)&&(!f||m.checks.some(ce=>ce.code.endsWith("hello_probe_passed"))))}catch(d){return g===Q.current&&(B(d instanceof Error?d.message:"Could not test the agent."),ne("fail")),!1}}s(ye,"runTest");async function mt(){if(he.current||C||c||!$||!a.trim()||S==="running"||S==="fail"||f&&!x)return;he.current=!0,De(!0),B(null);const t=[];let g=!1;try{const d=Ke(),m=Ie();if(Object.keys(m).length&&!await ye())return;for(const[H,xt]of Object.entries(m)){const $e=await(f?cn:dn)(n,H,xt);t.push($e),d.env={...d.env??{},[H]:$e.binding}}const ce=ae.data??[],Ue=ce.find(H=>H.role==="ceo"&&H.status!=="terminated"),V=await X.hire(n,{name:a.trim(),appearance:me.appearance,role:ce.length?"general":"ceo",...Ue?{reportsTo:Ue.id}:{},adapterType:o,adapterConfig:d,defaultEnvironmentId:ge||(F.forced||G?j:null),runtimeConfig:{...an({heartbeatEnabled:!1}),...v?{aiConnection:v}:{}},budgetMonthlyCents:0,...x?.storedSessionId?{storedSessionId:x.storedSessionId}:{},...x?.applyStoredClaudeLogin?{applyStoredClaudeLogin:!0}:{}});g=!0,L(""),R(null),ot(V.agent),me.clear(),K("saved"),N(`/agents/new?${Qe({name:V.agent.name,adapterType:o,runnerProvider:r,createdAgentId:V.agent.id})}`,{replace:!0}),k.setQueryData(u.agents.detail(V.agent.id),V.agent),await Promise.all([k.invalidateQueries({queryKey:u.agents.list(n)}),k.invalidateQueries({queryKey:u.approvals.list(n)})])}catch(d){B(d instanceof Error?d.message:"Could not create the agent.")}finally{if(!g)try{await Promise.all(t.map(d=>d.remove()))}catch{B(d=>`${d?`${d} `:""}Could not remove an unused setup credential. Remove it from Secrets before retrying.`)}k.invalidateQueries({queryKey:u.secrets.myUserSecrets(n)}),k.invalidateQueries({queryKey:u.secrets.list(n)}),he.current=!1,De(!1)}}if(s(mt,"finish"),C&&!c)return(0,e.jsx)("p",{role:te.error?"alert":"status",className:"text-sm text-ink-3",children:te.error?"Could not load the created agent. Return to Agents to view it.":"Loading your agent…"});if(!a||!o)return(0,e.jsx)(It,{open:!0,initialAdapter:o,onClose:s(()=>N("/agents/all"),"onClose"),onContinue:s(t=>N(`/agents/new?${Qe(t)}`,{replace:!0}),"onContinue")});const pt=[...f?["connect"]:[],"runtime","saved"],gt={connect:"Connect",runtime:"Configure",saved:"Confirmation"},Re=c?.defaultEnvironmentId?b.data?.find(t=>t.id===c.defaultEnvironmentId):de,ft=c?.adapterConfig?.model||A||"Default",Be=Re?He(Re):"Local machine",Fe=be.error??b.error??re.error??O.error??oe.error??ae.error??ie.error;return(0,e.jsx)(ln,{reducedMotion:"user",children:(0,e.jsxs)("div",{className:"mx-auto flex max-w-5xl flex-col gap-8 py-6",children:[(0,e.jsxs)("header",{className:"flex items-center gap-4",children:[(0,e.jsx)(nn,{appearance:c?.appearance??me.appearance,size:256,className:"size-48",trackingScope:"page",state:c||S==="pass"?"success":S==="running"?"loading":"sleepy",muted:!c&&S!=="pass"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:a}),(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[(0,e.jsx)(Lt,{type:l}),(0,e.jsx)("span",{children:Ce(l).label}),z&&!p&&(0,e.jsxs)("span",{children:["·"," ",r==="codex"?"Native app server runner":"Wardmote Runner"]})]})]})]}),le&&!b.isPending&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:le}),Fe&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:Fe.message}),be.data&&!qe&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"This adapter is unavailable. Choose an enabled adapter."}),(G||F.forced)&&!b.isPending&&!j&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"No managed environment is available. Configure an environment before continuing."}),(0,e.jsxs)("div",{className:"flex flex-col gap-8 md:flex-row",children:[(0,e.jsx)("nav",{"aria-label":"Agent setup steps",className:"shrink-0 md:w-44",children:(0,e.jsx)("ol",{className:"flex flex-wrap gap-2 md:flex-col",children:pt.map((t,g)=>(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button","aria-current":t===D?"step":void 0,disabled:P||!!c||t==="saved",onClick:s(()=>t==="connect"&&D!=="connect"?Oe():K(t),"onClick"),className:ue("flex w-full items-center gap-3 rounded-md px-3 py-3 text-left text-sm",t===D?"bg-bg-3 font-medium":"text-ink-3"),children:[(0,e.jsx)("span",{className:ue("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",t===D?"border-ink bg-ink text-bg":"border-line"),children:g+1}),gt[t]]})},t))})}),(0,e.jsx)("div",{className:"min-w-0 flex-1",children:(0,e.jsx)(Pt,{mode:"wait",initial:!1,children:(0,e.jsx)(St.div,{...Dt,children:D==="connect"&&f?(0,e.jsxs)(un,{className:"mx-auto",children:[(0,e.jsx)("div",{className:"mb-8",children:(0,e.jsx)(mn,{title:"Connect a model",center:!0})}),$?(0,e.jsx)(qt,{companyId:n,adapterType:f,environmentId:j,canLogin:dt,advancedConnection:{value:v,content:(0,e.jsx)(Le,{companyId:n,agentName:a,adapterType:l,model:A,environmentId:j??void 0,value:v,preferAdvanced:!0,onChange:s(t=>{R(null),Y(t),h()},"onChange")})},onBack:s(()=>N("/agents/all"),"onBack"),onDraftChanged:s(()=>{R(null),Y(void 0),h()},"onDraftChanged"),testConnection:ye,testError:se??(xe?.checks.find(t=>t.level==="error")??xe?.checks.find(t=>t.code.includes("hello_probe")&&t.level==="warn"))?.message,onConnected:s(t=>{R(t),Y(void 0),h(),K("runtime")},"onConnected")},j??"local"):(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading connection settings…"})]}):D==="saved"&&c?(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-6 rounded-lg border border-line p-6",children:[(0,e.jsxs)("h2",{className:"flex items-center gap-3 text-lg font-semibold",children:[(0,e.jsx)(Ge,{className:"size-5"}),c.status==="pending_approval"?"Agent submitted for approval":p?"Your Dot agent has been created":"Your agent is ready"]}),(0,e.jsxs)("dl",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Adapter"}),(0,e.jsx)("dd",{children:Ce(p?"openai_dot":o).label}),J&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("dt",{className:"text-ink-3",children:"Model"}),(0,e.jsx)("dd",{className:"break-all",children:String(ft)})]}),(0,e.jsx)("dt",{className:"text-ink-3",children:"Environment"}),(0,e.jsx)("dd",{children:Be})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:c.status==="pending_approval"?"An organization administrator must approve this agent before it can work.":p?"Pair your Dot and test event delivery in configuration before assigning work.":"Assign a task when you’re ready for this agent to work."})]}),(0,e.jsxs)("div",{className:"flex flex-wrap justify-between gap-3",children:[(0,e.jsxs)(W,{variant:"secondary",onClick:s(()=>N(p?"/agents/all":`${ze(c)}/runtime`),"onClick"),children:[(0,e.jsx)(sn,{className:"size-4"}),p?"Back to Agents":"Edit configuration"]}),(0,e.jsxs)(W,{disabled:c.status==="pending_approval",onClick:s(()=>p?N(`${ze(c)}/runtime`):Ze({assigneeAgentId:c.id,status:"todo"}),"onClick"),children:[p?"Pair Dot":`Assign ${c.name} a Task`,(0,e.jsx)(Te,{className:"size-4"})]})]})]}):(0,e.jsxs)("form",{className:"space-y-8",onSubmit:s(t=>{t.preventDefault(),mt()},"onSubmit"),children:[(0,e.jsx)("h2",{className:"text-xl font-semibold",children:"Configure your agent"}),(0,e.jsxs)("fieldset",{disabled:P,className:"space-y-8",children:[(0,e.jsxs)("section",{className:"space-y-5",children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Create this agent, then copy its pairing prompt to your Dot."}),O.data?.enablePublicMcp!==!0&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Turn on Assistant connections in Settings > Features before pairing."}),(0,e.jsx)(en,{label:"Allow externally billed provider",hint:"Dot does not report token usage or cost. Wardmote cannot enforce a provider spend ceiling; known company and agent budget limits still apply.",checked:pe,onChange:s(t=>{et(t),h()},"onChange")})]}),!f&&Mt(l)&&(0,e.jsx)(Le,{companyId:n,agentName:a,adapterType:l,model:A,environmentId:j??void 0,value:v,onChange:s(t=>{Y(t),h()},"onChange")}),(_?_.error:T.error)&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"Could not load models. Retry or enter a model ID manually."}),o==="omp_local"&&T.isSuccess&&T.data.length===0&&(0,e.jsxs)("section",{"aria-label":"Connect a model",className:"space-y-3 rounded-lg border border-line bg-bg-2 px-4 py-3",children:[(0,e.jsx)("p",{className:"text-sm text-ink-2",children:"OMP has no signed-in model yet. Sign in to a provider here, or add your own server in Settings, Models and providers."}),(0,e.jsx)(on,{onSignedIn:s(()=>{X.adapterModels(n,l,{refresh:!0}).then(t=>k.setQueryData(u.agents.adapterModels(n,l,null,v?.provider),t))},"onSignedIn")})]}),J&&(0,e.jsx)("div",{className:"grid items-start gap-5 sm:grid-cols-2",children:J&&(0,e.jsx)(Ut,{models:_?.models??T.data??[],onRefreshModels:_?.refreshModels,refreshingModels:_?.refreshing,value:A,onChange:s(t=>{_e(_?.resolveModel(t)??t),(o==="omp_local"?!Wt(I,t,(T.data??[]).map(d=>Jt(d,!1))):I)&&Se("");const g=t.split("/")[0];w&&Ae[g]&&g!==Z&&(ke(g),L(""),ee(null)),h()},"onChange"),open:tt,onOpenChange:nt,allowDefault:!w,required:w,creatable:!0,groupByProvider:w&&!_,preserveOrder:!!_||Xt(l),effort:o==="omp_local"?{value:I||null,onChange:s(t=>{Se(t??""),h()},"onChange")}:void 0})}),E&&!v&&(0,e.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[E&&(0,e.jsx)(Ne,{label:"API key provider",children:(0,e.jsx)("select",{"aria-label":"API key provider",className:We,value:Z,onChange:s(t=>{ke(t.target.value),_e(""),L(""),ee(null),h()},"onChange"),children:Object.keys(Ae).map(t=>(0,e.jsx)("option",{value:t,children:t==="openrouter"?"OpenRouter":t==="openai"?"OpenAI":t==="anthropic"?"Anthropic":{google:"Google",xai:"xAI",groq:"Groq",opencode:"OpenCode"}[t]??t},t))})}),(0,e.jsx)("div",{children:(0,e.jsx)(Ne,{label:M,children:(0,e.jsx)("div",{className:"flex items-center gap-3",children:(0,e.jsx)(Vt,{"aria-label":M,type:"password",autoComplete:"off",value:fe,onChange:s(t=>{L(t.target.value),ee(null),h()},"onChange"),placeholder:U?"Using saved key":"Optional if already configured"})})})}),(0,e.jsx)("div",{className:E?"sm:col-span-2":void 0,children:(0,e.jsx)(Ne,{label:"Or use an organization secret",children:(0,e.jsx)(Gt,{secretId:U&&typeof U=="object"&&U.type==="secret_ref"?U.secretId:"",secrets:Me.data??[],disabled:P,onSelect:s(t=>{ee({type:"secret_ref",secretId:t,version:"latest"}),L(""),h()},"onSelect")})})}),(0,e.jsxs)("p",{className:"text-xs text-ink-3 sm:col-span-2",children:["New keys are saved as organization secrets when you finish setup.",w&&` Use a ${Z}/model ID.`]})]})]}),(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Environment"}),(0,e.jsxs)("select",{"aria-label":"Environment",className:We,value:ge,disabled:F.forced,onChange:s(t=>{st(t.target.value),R(null),h(),f&&K("connect")},"onChange"),children:[(0,e.jsxs)("option",{value:"",children:["Default: ",Be]}),(b.data??[]).filter(t=>t.status==="active"&&(!G||t.driver!=="local")).map(t=>(0,e.jsx)("option",{value:t.id,children:He(t)},t.id))]})]})]}),(0,e.jsx)(Ot,{variant:p?"prerequisites":"connection",state:S,result:xe,error:se,disabled:!$||P||!!(f&&!x),onTest:s(()=>{ye()},"onTest")}),se&&S!=="fail"&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:se}),(0,e.jsxs)("div",{className:"flex justify-between border-t border-line py-5",children:[f?(0,e.jsxs)(W,{type:"button",variant:"ghost",disabled:P,onClick:Oe,children:[(0,e.jsx)(Tt,{className:"size-4"}),"Connection"]}):(0,e.jsx)("span",{}),f&&!x?(0,e.jsxs)(W,{type:"button",disabled:!$||P,onClick:s(()=>K("connect"),"onClick"),children:["Connect model",(0,e.jsx)(Te,{className:"size-4"})]}):(0,e.jsxs)(W,{type:"submit",disabled:!$||P||S==="fail"||!!(f&&!x),children:[Ee?"Creating…":"Finish setup",(0,e.jsx)(Ge,{className:"size-4"})]})]})]})},D)})})]})]})})}s(gn,"Setup");function Ln(){const{setBreadcrumbs:n}=Ht();return(0,i.useEffect)(()=>{n([{label:"Agents",href:"/agents"},{label:"New agent"}])},[n]),(0,e.jsx)(pn,{})}s(Ln,"NewAgent");export{Ln as NewAgent};