@tickernelz/wardmote-ui 2026.1118.1 → 2026.1118.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdapterManager-1binbhYj.js → AdapterManager-DvntZ2AW.js} +1 -1
- package/dist/assets/{AdvancedToolsRoute-DUyXR4Xj.js → AdvancedToolsRoute-CUW8D9Ux.js} +1 -1
- package/dist/assets/{AgentActionButtons-DSmnGirw.js → AgentActionButtons-CQLGCtfu.js} +1 -1
- package/dist/assets/{AgentChat-Dj952aW1.js → AgentChat-DCwwZA2b.js} +1 -1
- package/dist/assets/{AgentChats-Fv5j4CM9.js → AgentChats-DMMLdo-o.js} +1 -1
- package/dist/assets/{AgentDetail-CffT38lI.js → AgentDetail-BMVWOVp-.js} +1 -1
- package/dist/assets/{AgentTodoCard-De5ZJbUa.js → AgentTodoCard-C4BfJg4x.js} +1 -1
- package/dist/assets/{Agents-CDDoQ4Ds.js → Agents-C0IDC6KD.js} +3 -3
- package/dist/assets/{AppDetail-DnTOxWEY.js → AppDetail-DzEGsx94.js} +1 -1
- package/dist/assets/{AppNotConnected-CgnmB3mH.js → AppNotConnected-BVL32B49.js} +1 -1
- package/dist/assets/{ApprovalCard-D6X8gzHU.js → ApprovalCard-DCQ49PuW.js} +1 -1
- package/dist/assets/{ApprovalDetail-CWxiqPs6.js → ApprovalDetail-B0J70llD.js} +1 -1
- package/dist/assets/{ApprovalPayload-DFsO21LC.js → ApprovalPayload-8lqBw-XQ.js} +1 -1
- package/dist/assets/{Approvals-BW3osPe0.js → Approvals-BkiVjx0M.js} +1 -1
- package/dist/assets/{AppsReview-4g3PeYWn.js → AppsReview-CeXp22cE.js} +1 -1
- package/dist/assets/{ArtifactCard-BoIqK207.js → ArtifactCard-BV82tDLI.js} +1 -1
- package/dist/assets/{Artifacts-DDdlgUkk.js → Artifacts-CL5ZmZ3m.js} +1 -1
- package/dist/assets/{AssistantConnection-B7yxIifb.js → AssistantConnection-C5rmoEsm.js} +1 -1
- package/dist/assets/{AttentionInteractionResolver-BdcCqDXe.js → AttentionInteractionResolver-DxZpuIIF.js} +1 -1
- package/dist/assets/{AuditHub-CI0zjHie.js → AuditHub-DDPFGvHG.js} +1 -1
- package/dist/assets/{BoardChat--69z_C0h.js → BoardChat-DlaNGzcQ.js} +1 -1
- package/dist/assets/{BootstrapSetupUxLab-UIxdNUcO.js → BootstrapSetupUxLab-B2tOIzXd.js} +1 -1
- package/dist/assets/{Browse-VPYhJopu.js → Browse-xEc9mGl7.js} +1 -1
- package/dist/assets/{BudgetPolicyCard-45TwMzp3.js → BudgetPolicyCard-Ccr3EX5M.js} +1 -1
- package/dist/assets/{CaseDetail-CRN2rF4k.js → CaseDetail-CvMk_M-F.js} +1 -1
- package/dist/assets/{Cases-CFqnLAMq.js → Cases-H1Y4Oipe.js} +1 -1
- package/dist/assets/{ChatEndpointDetail-BTYAtutu.js → ChatEndpointDetail-CjDVQWl8.js} +1 -1
- package/dist/assets/{ChatEndpointSetup-CzrgHmvH.js → ChatEndpointSetup-BfohtKVM.js} +1 -1
- package/dist/assets/{Companies-C-U5WI6o.js → Companies-C4ObCu9j.js} +1 -1
- package/dist/assets/{CompanyAccess-DLgvUIoB.js → CompanyAccess-J5Vwnko2.js} +1 -1
- package/dist/assets/{CompanyActivity-8CeynedM.js → CompanyActivity-B7-kMNmz.js} +1 -1
- package/dist/assets/{CompanyConnections-BjMmsqei.js → CompanyConnections-D2N6UWXk.js} +1 -1
- package/dist/assets/{CompanyEnvironments-D6p-TNkv.js → CompanyEnvironments-ChSu4gxW.js} +1 -1
- package/dist/assets/{CompanyExport-Dw0QDMvs.js → CompanyExport-B_opHRSJ.js} +1 -1
- package/dist/assets/{CompanyImport-OSi3fM2l.js → CompanyImport-DZAMEBBy.js} +1 -1
- package/dist/assets/{CompanySettings-B-aPUQpY.js → CompanySettings-Rz8cwgKC.js} +1 -1
- package/dist/assets/{CompanySettingsPluginPage-Kp7iOUP1.js → CompanySettingsPluginPage-CM-ViPwj.js} +1 -1
- package/dist/assets/{CompanySkills-HZqJ5DZ8.js → CompanySkills-BnwPuZze.js} +1 -1
- package/dist/assets/{ConfigureBuiltInAgentModal-DL3wv3Mb.js → ConfigureBuiltInAgentModal-BAfoTveX.js} +1 -1
- package/dist/assets/{CopyableGatewayUrl-BLjhj10P.js → CopyableGatewayUrl-D90Bjxj0.js} +1 -1
- package/dist/assets/{Dashboard-DTmjsaEr.js → Dashboard-DepIxrje.js} +1 -1
- package/dist/assets/{DecisionDateChips-Br5r2jWZ.js → DecisionDateChips-89KkV4mo.js} +1 -1
- package/dist/assets/{DecisionQueuePage-zWDMjHf9.js → DecisionQueuePage-nU9qXzln.js} +1 -1
- package/dist/assets/{DesignGuide-BsH97scx.js → DesignGuide-40TixHZ-.js} +1 -1
- package/dist/assets/{EmailEndpointSetup-C7PhFwBy.js → EmailEndpointSetup-D7-8f1XV.js} +1 -1
- package/dist/assets/{ExecutionWorkspaceDetail-CTDvazWh.js → ExecutionWorkspaceDetail-CnUD3jLO.js} +1 -1
- package/dist/assets/{GatewayDetail-BtpnGGIB.js → GatewayDetail-Bg7GU-1a.js} +1 -1
- package/dist/assets/{GatewaysList-DrRfNyqk.js → GatewaysList-4vvZCBkY.js} +1 -1
- package/dist/assets/{GoalDetail-D5QqhxMg.js → GoalDetail-h7WsjaOO.js} +1 -1
- package/dist/assets/{GoalTree-CDexmAKW.js → GoalTree-yPtfejUx.js} +1 -1
- package/dist/assets/{Goals-CZinws4s.js → Goals-DOi3E4DX.js} +1 -1
- package/dist/assets/{ImageGalleryModal-VT9I4D2p.js → ImageGalleryModal-D_VQgcBt.js} +1 -1
- package/dist/assets/{Inbox-BiE243MO.js → Inbox-COKxRKhR.js} +1 -1
- package/dist/assets/{InstanceAdvanced-D_iqUmgn.js → InstanceAdvanced-DlMlwZbU.js} +1 -1
- package/dist/assets/{InviteLanding-LR84Xv76.js → InviteLanding-BGvJMHKw.js} +1 -1
- package/dist/assets/{IssueChatLongThreadPerf-BHdYa83T.js → IssueChatLongThreadPerf-C3U2FZKJ.js} +1 -1
- package/dist/assets/{IssueChatThread-Cno8fLc-.js → IssueChatThread-CDKaIB6v.js} +1 -1
- package/dist/assets/{IssueDetail-BWZWLO4k.js → IssueDetail-BCwHANTn.js} +1 -1
- package/dist/assets/{IssueOutputSection-BuwP0RQx.js → IssueOutputSection-BzXRmoV7.js} +1 -1
- package/dist/assets/{IssueRecoveryActionCard-O4GRNsPc.js → IssueRecoveryActionCard-BYtbaP-M.js} +1 -1
- package/dist/assets/{IssueReferencePill-EbOs3MtQ.js → IssueReferencePill-BT7NBEy_.js} +1 -1
- package/dist/assets/{IssueThreadInteractionCard-BUIzNywc.js → IssueThreadInteractionCard-Btd0rZ23.js} +1 -1
- package/dist/assets/{Issues-mVYaoqsX.js → Issues-XKf7zemQ.js} +1 -1
- package/dist/assets/{LiveNowTodoLine-DP95vmnd.js → LiveNowTodoLine-CoL6ZNuK.js} +1 -1
- package/dist/assets/{ManagedAiConnectionDetails-ZByBvcqo.js → ManagedAiConnectionDetails-CebBi-Tw.js} +1 -1
- package/dist/assets/{McpConnect-D42jtK1S.js → McpConnect-ByorZN7G.js} +1 -1
- package/dist/assets/{MembershipAction-Df2Qlkdz.js → MembershipAction-De0MBfgb.js} +1 -1
- package/dist/assets/{ModelsAndProviders-BzUob8BB.js → ModelsAndProviders-BqM4UJc7.js} +1 -1
- package/dist/assets/{NewAgent-BywRvCR0.js → NewAgent-pMTQYNxn.js} +1 -1
- package/dist/assets/{PipelineSettings-DFjxoW4i.js → PipelineSettings-C2k3BzLQ.js} +1 -1
- package/dist/assets/{Pipelines-CSW-En3n.js → Pipelines-Cr6Xs32p.js} +1 -1
- package/dist/assets/{PixelsOffice-B2b8M6LM.js → PixelsOffice-Dfd4XKSj.js} +1 -1
- package/dist/assets/{PluginPage-CfSIAMQa.js → PluginPage-fPlWyFSc.js} +1 -1
- package/dist/assets/{PluginSettings-TewUkGUA.js → PluginSettings-X_VHvvo5.js} +1 -1
- package/dist/assets/{ProfileDetailRoute-CCbLcj8f.js → ProfileDetailRoute-PAsWmN-1.js} +1 -1
- package/dist/assets/{ProfileSettings-D1D_hKPu.js → ProfileSettings-BACxlGZS.js} +1 -1
- package/dist/assets/{ProfileWizardRoute-BzFGrQkr.js → ProfileWizardRoute-Dbq0n7If.js} +1 -1
- package/dist/assets/{ProjectDetail-CEjUARCN.js → ProjectDetail-DOJZUIWu.js} +1 -1
- package/dist/assets/{ProjectWorkspaceDetail-7fFllUMH.js → ProjectWorkspaceDetail-ZNnaHnuA.js} +1 -1
- package/dist/assets/{ProjectWorkspacesContent-S4UUfVU1.js → ProjectWorkspacesContent-DrWfnTJY.js} +1 -1
- package/dist/assets/{Projects-NrtT8d2x.js → Projects-CCzxmEZ8.js} +1 -1
- package/dist/assets/{PublicIssueSharePage-CfQDHmOe.js → PublicIssueSharePage-BUSkP1Js.js} +1 -1
- package/dist/assets/{ReviewQueueCard-CksOubye.js → ReviewQueueCard-CrCN_30c.js} +1 -1
- package/dist/assets/{RichWorkProductCard-XPJ4R-il.js → RichWorkProductCard-DndJn4LV.js} +1 -1
- package/dist/assets/{RoutineDetail-AcrnXhjR.js → RoutineDetail-B5MzV_74.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-CtSVwZjy.js → RoutineRunVariablesDialog-kGyQVBid.js} +1 -1
- package/dist/assets/{Routines-B19G6Lkw.js → Routines-B2zX9h3J.js} +1 -1
- package/dist/assets/{ScrollToBottom-csHqjOIa.js → ScrollToBottom-Dd3SpeJi.js} +1 -1
- package/dist/assets/{Search-CnO6qC0m.js → Search-D4W3cZZf.js} +1 -1
- package/dist/assets/{Secrets-Xz6WSEnG.js → Secrets-C4nbuMIh.js} +1 -1
- package/dist/assets/{SkillSourceTree-BC2Ycl7g.js → SkillSourceTree-BvGzMa2u.js} +1 -1
- package/dist/assets/{SkillSources-BMogH_qp.js → SkillSources-DL2tNkcr.js} +1 -1
- package/dist/assets/{SkillStudio-HekOqqo_.js → SkillStudio-BnZ2cfDq.js} +1 -1
- package/dist/assets/{SourceTrustBadge-CXZGc8G4.js → SourceTrustBadge-CCPQEGrC.js} +1 -1
- package/dist/assets/{StatusCards-CL-RC2Mf.js → StatusCards-BkE-9R8F.js} +1 -1
- package/dist/assets/{SummarySlotCard-BJmo-gDJ.js → SummarySlotCard-D1EyiciB.js} +1 -1
- package/dist/assets/{TaskChatLab-CIZVb5Ed.js → TaskChatLab-D3PsNRr5.js} +1 -1
- package/dist/assets/{TaskChatMarker-CdRbWeYc.js → TaskChatMarker-DEF88_sr.js} +1 -1
- package/dist/assets/{TaskChatProtocolCard-C_A2mV-g.js → TaskChatProtocolCard-Ba_vhDxn.js} +1 -1
- package/dist/assets/{TaskChatThreadView-Bd3E40e0.js → TaskChatThreadView-BsPvbxiA.js} +1 -1
- package/dist/assets/{TaskTreeControls-DK6EZXLI.js → TaskTreeControls-BKOIbilg.js} +1 -1
- package/dist/assets/{Terminal-BcD_c9Om.js → Terminal-1uPX7VEe.js} +1 -1
- package/dist/assets/{TerminalView-XV2mBbcS.js → TerminalView-DDv6s-R_.js} +1 -1
- package/dist/assets/{TrustPresetSection-Ev8RdYhN.js → TrustPresetSection-BDb0N4Pe.js} +1 -1
- package/dist/assets/{UserProfile-C_BKVfMQ.js → UserProfile-DqPRuGWk.js} +1 -1
- package/dist/assets/{WhatNeedsMe-CYs2iX06.js → WhatNeedsMe-DtBxgH24.js} +1 -1
- package/dist/assets/{Workspaces-B8Wwbx8B.js → Workspaces-BQOyG5HK.js} +1 -1
- package/dist/assets/{connection-owner-Ca1nfKiA.js → connection-owner-CPrMcD3t.js} +1 -1
- package/dist/assets/{index-LM7k1NmC.js → index-QhteFtm-.js} +3 -3
- package/dist/assets/{issue-properties-CKLKB9AO.js → issue-properties--M7WE6Ot.js} +1 -1
- package/dist/assets/{issue-workspace-selection-CJYasFEQ.js → issue-workspace-selection-pUdSkrJA.js} +1 -1
- package/dist/assets/{pipeline-stage-presentation-BzvR-f05.js → pipeline-stage-presentation-Dv1xgEPW.js} +1 -1
- package/dist/assets/{shared-CMP5lH_Q.js → shared-B75ClBUg.js} +1 -1
- package/dist/assets/{system-notice-comment-BUfjKy0_.js → system-notice-comment-D0I6rz8Y.js} +1 -1
- package/dist/assets/{transcript-adapter-DiPtVkEm.js → transcript-adapter-ClaGWYVL.js} +1 -1
- package/dist/assets/{useSummaryDraftStream-uMW1O0Ga.js → useSummaryDraftStream-BDuMgNcA.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var es=Object.defineProperty;var t=(a,n)=>es(a,"name",{value:n,configurable:!0});import{i as Ue}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as Qe,h as ss,la as ts,ua as as}from"./createLucideIcon-CgrPXnTY.js";import{y as Oe}from"./star-eem0qj3E.js";import{X as We,_ as G,n as ns,t as R,v as F}from"./queryKeys-BzT8CD34.js";import{n as is}from"./CompanyContext-fQCNWI_f.js";import{o as rs,t as Le,zt as os}from"./router-CJbFZfVR.js";import{t as de}from"./label-B707hSFt.js";import{t as ls}from"./arrow-left-CnGEiANj.js";import{t as $e}from"./arrow-right-W0iJ_-Zs.js";import{t as ds}from"./check-Bis3vECb.js";import{t as cs}from"./copy-C1cfcpxY.js";import{t as ms}from"./external-link-BIcMNNSN.js";import{t as u}from"./button-DI4w5WP7.js";import{t as xs}from"./triangle-alert-CnHMpmva.js";import{t as be}from"./agents-B8n-p0aX.js";import{t as us}from"./projects-l3kQxnTp.js";import{a as hs,i as ps,n as gs,r as fs,s as bs,t as js}from"./dialog-CeH7rDcv.js";import{t as ys}from"./input-BBNGmECW.js";import{t as Be}from"./tools-MhVvhrz_.js";import{n as vs}from"./AgentMultiSelect-BlUaNdZZ.js";import{i as ks,o as Ns,t as He}from"./card-BVZvs7aX.js";import{In as Pe,Mn as ze,Pn as De,ti as ws,wn as Cs}from"./index-LM7k1NmC.js";import{t as q}from"./email-hX48MODm.js";import{n as Ss,t as As}from"./AgentMailCredentialField-DNclWIul.js";import{t as Is}from"./CopyText-BbOm2I6t.js";import{t as qs}from"./TrustPresetSection-Ev8RdYhN.js";var o=Ue(as(),1);function Es(a,n,d,l,m){const i=JSON.stringify([a,n,d,l]),[w,r]=(0,o.useState)();(0,o.useEffect)(()=>{if(!m)return;const _=new AbortController,h=setTimeout(()=>{q.checkAddress(a,n,{username:d,domain:l},_.signal).then(j=>{_.signal.aborted||r({key:i,result:j})}).catch(j=>{_.signal.aborted||r({key:i,error:j instanceof Error?j.message:"Could not check this address."})})},350);return()=>{clearTimeout(h),_.abort()}},[a,n,d,l,i,m]);const c=m&&w?.key===i?w:void 0;return{result:c?.result,error:c?.error,checking:m&&!c}}t(Es,"useEmailAddressCheck");var e=Ue(ts(),1);function Je(){return(0,e.jsxs)("div",{role:"note",className:"space-y-3 rounded-lg border border-line bg-bg-3/30 p-4",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)(xs,{className:"size-4 shrink-0 text-(--status-agent-paused)"}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Anyone can email an unrestricted inbox"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Incoming email can create tasks and trigger agent work. Set up an allowlist in AgentMail to limit who can contact this inbox."}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Wardmote does not verify sender restrictions. AgentMail controls new messages and replies separately; check both lists."})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-4 text-sm",children:[(0,e.jsx)("a",{href:"https://console.agentmail.to",target:"_blank",rel:"noreferrer",className:"underline underline-offset-4",children:"Open AgentMail ↗"}),(0,e.jsx)("a",{href:"https://docs.agentmail.to/knowledge-base/allowlists-blocklists",target:"_blank",rel:"noreferrer",className:"text-ink-3 underline underline-offset-4",children:"Set up allowlists ↗"})]})]})}t(Je,"EmailSafetyNotice");var ce="w-full rounded-md border border-line-strong bg-bg px-3 py-2 text-sm";function Ks(a){try{const n=JSON.parse(sessionStorage.getItem(a)??"{}");if(!n||typeof n!="object")return{};const d={};for(const l of["connectionId","agentId","inboxId","username","domain"])typeof n[l]=="string"&&(d[l]=n[l]);return(n.step===0||n.step===1)&&(d.step=n.step),typeof n.requestId=="string"&&Qe(n.requestId)&&(d.requestId=n.requestId),(n.addressMode==="new"||n.addressMode==="existing")&&(d.addressMode=n.addressMode),(n.mode==="websocket"||n.mode==="webhook")&&(d.mode=n.mode),(n.selectedCredentialId===null||typeof n.selectedCredentialId=="string")&&(d.selectedCredentialId=n.selectedCredentialId),typeof n.allowInboxKey=="boolean"&&(d.allowInboxKey=n.allowInboxKey),typeof n.domainSelected=="boolean"&&(d.domainSelected=n.domainSelected),Array.isArray(n.takenAddresses)&&(d.takenAddresses=n.takenAddresses.filter(l=>typeof l=="string"&&l.length<=320).slice(-20)),d}catch{return{}}}t(Ks,"readEmailSetupDraft");function rt(){const{selectedCompanyId:a}=is(),[n]=Oe();return a?(0,e.jsx)(_s,{companyId:a},`${a}:${n.get("resume")??n.get("setupId")??n.get("connectionId")??"new"}:${n.get("agentId")??"choose"}`):(0,e.jsx)("p",{role:"status",className:"p-6 text-sm text-ink-3",children:"Loading email setup…"})}t(rt,"EmailEndpointSetup");function _s({companyId:a}){const[n]=Oe(),d=rs(),l=We(),m=n.get("resume"),i=n.get("setupId"),w=`wardmote.agentmail-setup:${a}:${m??i??n.get("connectionId")??"new"}:${n.get("agentId")??"choose"}`,[r]=(0,o.useState)(()=>{const s=Ks(w);return m&&s.requestId&&s.requestId!==m?{}:s}),[c,_]=(0,o.useState)(r.connectionId??n.get("connectionId")??""),[h,j]=(0,o.useState)(r.step??(m?1:0)),[g,V]=(0,o.useState)(r.agentId??n.get("agentId")??""),[y,v]=(0,o.useState)(""),[p,me]=(0,o.useState)(r.selectedCredentialId!==void 0?r.selectedCredentialId:c||null),[je,B]=(0,o.useState)(""),[D,xe]=(0,o.useState)(r.allowInboxKey??!1),[E]=(0,o.useState)(()=>r.requestId??m??(i&&Qe(i)?i:crypto.randomUUID())),[C,ue]=(0,o.useState)(r.addressMode??"new"),[U,he]=(0,o.useState)(r.inboxId??""),[S,X]=(0,o.useState)(r.username??""),[K,ye]=(0,o.useState)(r.domain??"agentmail.to"),[Y,ve]=(0,o.useState)(r.domainSelected??(!!r.domain&&r.domain!=="agentmail.to")),[Z,ke]=(0,o.useState)(r.takenAddresses??[]),[Q,Ne]=(0,o.useState)(r.mode??"websocket"),[ee,se]=(0,o.useState)(!1),[O,we]=(0,o.useState)({}),Ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(a)try{h===2?sessionStorage.removeItem(w):sessionStorage.setItem(w,JSON.stringify({connectionId:c,step:h,agentId:g,requestId:E,addressMode:C,inboxId:U,username:S,domain:K,domainSelected:Y,takenAddresses:Z,mode:Q,allowInboxKey:D,selectedCredentialId:p}))}catch{}},[a,w,c,h,g,E,C,U,S,K,Y,Z,Q,D,p]);const H=F({queryKey:R.agents.list(a),queryFn:t(()=>be.list(a),"queryFn"),enabled:!!a}),te=F({queryKey:R.projects.list(a),queryFn:t(()=>us.list(a),"queryFn"),enabled:!!a&&ee}),ae=F({queryKey:["email-boundary-issues",a],queryFn:t(()=>os.list(a),"queryFn"),enabled:!!a&&ee}),k=H.data?.find(s=>s.id===g),ne=De(k?.permissions)==="low_trust_review",ie=Pe(ze(k?.permissions)),N=F({queryKey:["email-credential-inspect",a,c],queryFn:t(()=>q.inspectSaved(a,c),"queryFn"),enabled:!!a&&!!c,retry:!1}),A=F({queryKey:["email-inboxes",a],queryFn:t(()=>q.list(a),"queryFn"),enabled:!!a}),f=A.data?.find(s=>s.id===E&&s.status!=="archived"),x=f?.address,J=F({queryKey:["email-resume-account",a,f?.connectionId],queryFn:t(()=>Be.getConnection(f.connectionId),"queryFn"),enabled:!!m&&E===m&&!!f&&!c,retry:!1});(0,o.useEffect)(()=>{if(!m||!f||c||!J.isSuccess)return;const s=J.data?.config?.credentialConnectionId;typeof s=="string"?_(s):j(0),Ne(f.receiveMode)},[m,f,c,J.isSuccess,J.data]),(0,o.useEffect)(()=>{f&&V(f.assignedAgentId)},[f]);const T=N.data?.scope.scope_type==="inbox",Se=[...new Set(N.data?.domains.filter(s=>s.status==="VERIFIED"&&s.domain.toLowerCase()!=="agentmail.to").map(s=>s.domain.toLowerCase())??[])],Ae=Se[0]??"agentmail.to";(0,o.useEffect)(()=>{N.isSuccess&&!Y&&!x&&ye(Ae)},[N.isSuccess,Y,x,Ae]),(0,o.useEffect)(()=>{!T||!A.isSuccess||(x||D?(ue("existing"),he(N.data?.inboxes[0]?.inbox_id??"")):h===1&&(B(N.data?.inboxes[0]?.inbox_id??"this inbox"),me(null),j(0)))},[T,N.data,A.isSuccess,x,D,h]),(0,o.useEffect)(()=>{k&&!Ce.current&&(Ce.current=!0,S||X(k.name.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").slice(0,64)))},[k,S]);const $=G({mutationFn:t(async()=>{if(x)return!0;const s=p?await q.inspectSaved(a,p):await q.inspect(a,y.trim());if(s.scope.scope_type==="inbox"&&!D)return B(s.inboxes[0]?.inbox_id??"this inbox"),!1;const M=!!c&&p!==c,W=M?crypto.randomUUID():E;let z=p;return z||(z=(await q.connect(a,{apiKey:y.trim(),grantKind:"organization",allAgents:!1,agentIds:[g],idempotencyKey:W})).id),l.setQueryData(["email-credential-inspect",a,z],s),me(z),v(""),l.invalidateQueries({queryKey:["email-credentials",a]}),l.invalidateQueries({queryKey:R.tools.connections(a)}),M?(f&&(await q.control(f.id,"remove"),await l.invalidateQueries({queryKey:["email-inboxes",a]})),Te({connectionId:z,selectedCredentialId:z,agentId:g,step:1,requestId:W,addressMode:s.scope.scope_type==="inbox"?"existing":"new",inboxId:s.scope.scope_type==="inbox"?s.inboxes[0]?.inbox_id??"":"",username:S,domain:"agentmail.to",domainSelected:!1,takenAddresses:[],mode:Q,allowInboxKey:D}),!1):(_(z),B(""),ue(s.scope.scope_type==="inbox"?"existing":"new"),s.scope.scope_type==="inbox"&&he(s.inboxes[0]?.inbox_id??""),!0)},"mutationFn"),onSuccess:t(s=>{s&&j(1)},"onSuccess")});function Ge(s){me(s),v(""),B(""),xe(!1),ve(!1),ke([]),$.reset()}t(Ge,"selectCredential");const pe=F({queryKey:R.agents.detail(g),queryFn:t(()=>be.get(g),"queryFn"),enabled:!!g&&ee}),re=G({mutationFn:t(()=>be.updatePermissions(g,{...O,canCreateAgents:O.canCreateAgents??!1,canCreateSkills:O.canCreateSkills??!0,canAssignTasks:pe.data?.access?.canAssignTasks??!1},a),"mutationFn"),onSuccess:t(()=>{se(!1),l.invalidateQueries({queryKey:R.agents.list(a)})},"onSuccess")}),I=G({mutationFn:t(()=>q.setup(a,{assignedAgentId:g,credentialConnectionId:c,...x?{inboxId:x}:C==="existing"?{inboxId:U}:{username:S,domain:K},receiveMode:Q,idempotencyKey:E}),"mutationFn"),onError:t(async s=>{s instanceof ns&&s.body?.code==="agentmail_address_taken"&&ke(M=>[...new Set([...M,`${S}@${K}`.toLowerCase()])].slice(-20)),await l.invalidateQueries({queryKey:["email-inboxes",a]})},"onError"),onSuccess:t(()=>{l.invalidateQueries({queryKey:["email-inboxes",a]}),l.invalidateQueries({queryKey:R.chatEndpoints.list(a)}),l.invalidateQueries({queryKey:R.tools.connections(a)}),l.invalidateQueries({queryKey:R.tools.connectionInstalls(c)}),j(2)},"onSuccess")}),Ie=x??(C==="existing"?U:`${S}@${K}`),qe=new Set([...Z,...N.data?.inboxes.map(s=>s.inbox_id.toLowerCase())??[]]),oe=h===1&&C==="new"&&!x&&!T,Ee=oe&&qe.has(Ie.toLowerCase()),ge=/^[a-z0-9][a-z0-9._-]*$/.test(S)&&S.length<=64,P=Es(a,c,S,K,oe&&ge&&!!N.data&&!Ee),fe=Ee||P.result?.status==="taken",Ke=oe&&ge&&(fe||P.result?.status==="unknown")?["-agent","-team",`-${E.slice(0,6)}`].map(s=>`${S.slice(0,64-s.length)}${s}`).filter(s=>!qe.has(`${s}@${K}`)):[],Ve=C==="existing"&&A.data?.some(s=>s.id!==E&&s.address===Ie&&s.status!=="archived"),L=fe?"This email address is already in use. Choose a different address.":Ve?"This inbox is already assigned to an agent.":null,le=$.error??(fe?null:I.error)??J.error??N.error??H.error,b=$.isPending||I.isPending,_e=A.isSuccess&&(!m||E!==m||!!f)&&(!f||f.assignedAgentId===g),Fe=_e&&!!k&&!b&&!(ne&&!ie)&&(!!x||!!p||!!y.trim()),Me=_e&&!!k&&!b&&!!N.data&&!(ne&&!ie)&&!L&&!P.checking&&(!!x||(C==="existing"?!!U:ge)),Re=t(()=>{k&&(we(k.permissions),se(!0))},"openTrust"),Xe=t(()=>d(`/apps/chat/${I.data?.id??f?.id}/settings`),"leave"),Ye=t(()=>{try{sessionStorage.removeItem(w)}catch{}d("/apps")},"cancel");function Te(s){try{sessionStorage.setItem(`wardmote.agentmail-setup:${a}:${s.requestId}:${g}`,JSON.stringify(s))}catch{}d(`/apps/chat/connect?${new URLSearchParams({provider:"agentmail",purpose:"chat",setupId:s.requestId,agentId:g,connectionId:s.connectionId})}`)}t(Te,"openDraft");const Ze=t(()=>{const s=crypto.randomUUID();Te({connectionId:c,selectedCredentialId:c,agentId:g,step:1,requestId:s,addressMode:"new",username:"",inboxId:"",domain:x?.slice(x.lastIndexOf("@")+1)??K,domainSelected:!0,takenAddresses:Z,mode:Q,allowInboxKey:!1})},"chooseAnotherAddress");return(0,e.jsxs)("div",{className:"mx-auto max-w-xl space-y-6 p-6",children:[(0,e.jsx)("header",{className:"space-y-2",children:(0,e.jsx)("h1",{className:"text-xl font-bold",children:h===2?"Your agent’s email is ready":"Give an agent an email address"})}),h<2&&A.isError&&(0,e.jsxs)("div",{role:"alert",className:"space-y-2 text-sm",children:[(0,e.jsxs)("p",{className:"text-bad",children:["Could not load email setup progress. ",A.error.message]}),(0,e.jsx)(u,{type:"button",variant:"secondary",size:"sm",disabled:b||A.isFetching,onClick:t(()=>{A.refetch()},"onClick"),children:A.isFetching?"Loading…":"Retry loading inboxes"})]}),h<2&&m===E&&A.isSuccess&&!f&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"This email setup could not be found. Return to Connectors and start a new connection."}),h<2&&(0,e.jsx)(ws,{labels:["Agent","Email address"],step:h,availableStep:h,disabled:b,onSelect:t(s=>{I.reset(),j(s)},"onSelect")}),h===0&&(0,e.jsxs)("form",{className:"space-y-6",onSubmit:t(s=>{s.preventDefault(),Fe&&$.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(de,{htmlFor:"email-agent",children:"Agent"}),(0,e.jsx)(vs,{id:"email-agent",value:g,disabled:b||H.isPending||!A.isSuccess||!!f,placeholder:"Choose an agent",emptyMessage:"No agents found.",triggerClassName:"h-10",agents:(H.data??[]).filter(s=>!["terminated","pending_approval"].includes(s.status)),onChange:t(s=>{V(s),X((H.data?.find(M=>M.id===s)?.name??"").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").slice(0,64))},"onChange")})]}),!x&&(0,e.jsx)(As,{companyId:a,connectionId:p,onConnectionChange:Ge,value:y,onChange:t(s=>{v(s),$.reset()},"onChange"),disabled:b}),je&&(0,e.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,e.jsxs)("p",{className:"text-ink-3",children:["That key only connects ",je,". Choose a saved account key or enter one to create a new address."]}),(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b||!(p||y.trim()),onClick:t(()=>{xe(!0),B(""),$.reset()},"onClick"),children:"Use the existing inbox instead"})]}),ne&&!ie&&(0,e.jsxs)("div",{role:"alert",className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:"This agent needs a work boundary before it can receive email."}),(0,e.jsx)(u,{type:"button",variant:"secondary",size:"sm",onClick:Re,children:"Configure work boundary"})]}),le&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:le.message}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-line pt-5",children:[(0,e.jsx)(u,{type:"button",variant:"ghost",disabled:b,onClick:Ye,children:"Cancel"}),(0,e.jsxs)(u,{disabled:!Fe,children:[$.isPending?"Connecting…":"Continue",(0,e.jsx)($e,{className:"size-4"})]})]})]}),h===1&&(0,e.jsxs)("form",{className:"space-y-6",onSubmit:t(s=>{s.preventDefault(),Me&&I.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(de,{htmlFor:C==="new"?"email-name":"email-existing",children:[k?.name,"’s email address"]}),x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:x}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["This address was created in AgentMail. Finish connecting it to ",k?.name,T?".":", or choose a different address. The original inbox will stay in AgentMail."]}),!T&&(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:Ze,children:"Choose a different address"})]}):C==="new"?(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ys,{id:"email-name",className:"min-w-0",value:S,maxLength:64,autoComplete:"off",spellCheck:!1,disabled:b,"aria-invalid":!!L,"aria-describedby":L?"email-address-error":"email-address-status",onChange:t(s=>{X(s.target.value.toLowerCase()),I.reset()},"onChange")}),(0,e.jsx)("select",{id:"email-domain","aria-label":"Email domain",className:`${ce} max-w-1/2 shrink-0`,value:K,disabled:b||!N.data,onChange:t(s=>{ve(!0),ye(s.target.value),I.reset()},"onChange"),children:[...new Set([...Se,"agentmail.to",K])].map(s=>(0,e.jsxs)("option",{value:s,children:["@",s]},s))})]})}):(0,e.jsxs)("select",{id:"email-existing",className:ce,value:x??U,disabled:b||T||!!x,"aria-invalid":!!L,"aria-describedby":L?"email-address-error":void 0,onChange:t(s=>{he(s.target.value),I.reset()},"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Choose an inbox"}),N.data?.inboxes.map(s=>{const M=A.data?.some(W=>W.id!==E&&W.address===s.inbox_id&&W.status!=="archived");return(0,e.jsxs)("option",{value:s.inbox_id,disabled:M,children:[s.inbox_id,M?" — already assigned":""]},s.inbox_id)})]}),T&&!x&&(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:t(()=>{xe(!1),j(0)},"onClick"),children:"Choose a key for a new address"}),L&&(0,e.jsx)("p",{id:"email-address-error",role:"alert",className:"text-sm text-bad",children:L}),oe&&!L&&(0,e.jsx)("p",{id:"email-address-status",role:"status",className:"text-sm text-ink-3",children:P.checking?"Checking address…":P.error?`Could not check this address. ${P.error}`:P.result?.status==="unknown"?"AgentMail confirms availability when you create the address.":null}),Ke.length>0&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm","aria-label":"Suggested email addresses",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Try:"}),Ke.map(s=>(0,e.jsxs)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:t(()=>{X(s),I.reset()},"onClick"),children:[s,"@",K]},s))]}),!T&&!x&&(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:t(()=>{ue(C==="new"?"existing":"new"),I.reset()},"onClick"),children:C==="new"?"Use an existing inbox":"Create a new address"})]}),(0,e.jsx)(He,{className:"py-4",children:(0,e.jsxs)(Ns,{className:"px-4",children:[(0,e.jsx)("h2",{className:"text-sm font-medium",children:"How it Works"}),(0,e.jsxs)(ks,{children:["Incoming email creates tasks for ",k?.name,". Replies stay in the same task."]})]})}),(0,e.jsxs)("details",{className:"space-y-4",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm text-ink-3",children:"Advanced options"}),(0,e.jsxs)("div",{className:"space-y-4",children:[C==="new"&&(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("a",{className:"text-sm underline",href:"https://docs.agentmail.to/custom-domains",target:"_blank",rel:"noreferrer",children:"Set up a custom domain ↗"})}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(de,{htmlFor:"email-mode",children:"Receiving"}),(0,e.jsxs)("select",{id:"email-mode",value:Q,disabled:b,className:ce,onChange:t(s=>Ne(s.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"websocket",children:"Live connection"}),(0,e.jsx)("option",{value:"webhook",children:"Webhook"})]})]}),(0,e.jsx)(Je,{}),(0,e.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:ne&&ie?"Low-trust review configured":"Manage which tasks and tools this agent can access."}),(0,e.jsx)(u,{type:"button",variant:"secondary",size:"sm",onClick:Re,children:"Review trust settings"})]})]})]}),le&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:le.message}),N.isPending&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading email options…"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-line pt-5",children:[(0,e.jsxs)(u,{type:"button",variant:"ghost",disabled:b,onClick:t(()=>{I.reset(),j(0)},"onClick"),children:[(0,e.jsx)(ls,{className:"size-4"}),"Back"]}),(0,e.jsxs)(u,{disabled:!Me,children:[I.isPending?"Connecting…":x?"Finish connecting":C==="new"?"Create email address":"Connect email address",(0,e.jsx)($e,{className:"size-4"})]})]})]}),h===2&&(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[(0,e.jsx)(ds,{className:"size-4"}),I.data?.address]}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:[k?.name," can now receive email at this address."]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-line pt-5",children:[(0,e.jsx)(u,{variant:"ghost",onClick:Xe,children:"Email settings"}),(0,e.jsx)(u,{onClick:t(()=>d("/apps"),"onClick"),children:"Done"})]})]}),(0,e.jsx)(js,{open:ee,onOpenChange:se,children:(0,e.jsxs)(gs,{className:"max-h-screen overflow-y-auto sm:max-w-2xl",children:[(0,e.jsxs)(hs,{children:[(0,e.jsxs)(bs,{children:["Trust settings · ",k?.name]}),(0,e.jsx)(fs,{children:"Changes apply to all of this agent’s work. Use a dedicated email agent if its other tasks need broader access."})]}),(0,e.jsx)(qs,{permissions:O,onChange:we,companyId:a,projectCandidates:(te.data??[]).map(s=>({id:s.id,label:s.name})),issueCandidates:(ae.data??[]).map(s=>({id:s.id,label:`${s.identifier} · ${s.title}`})),allowSingleIssue:!1,candidatesLoading:te.isPending||ae.isPending}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Low trust limits Wardmote access; it does not sandbox the runtime. Review filesystem, tool, and secret access separately."}),(re.error||te.error||ae.error)&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:(re.error??te.error??ae.error)?.message}),(0,e.jsxs)(ps,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:t(()=>se(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(u,{disabled:re.isPending||pe.isPending||!!pe.error||De(O)==="low_trust_review"&&!Pe(ze(O)),onClick:t(()=>re.mutate(),"onClick"),children:"Save trust settings"})]})]})})]})}t(_s,"EmailEndpointSetupForm");function ot({companyId:a,connectionId:n,canConfigure:d}){const l=F({queryKey:["email-inboxes",a],queryFn:t(()=>q.list(a),"queryFn"),refetchInterval:1e4}),m=F({queryKey:R.tools.connections(a),queryFn:t(()=>Be.listConnections(a),"queryFn")}),i=new Set(m.data?.connections.filter(r=>r.config?.credentialConnectionId===n).map(r=>r.id)),w=l.data?.filter(r=>r.connectionId===n||i.has(r.connectionId))??[];return(0,e.jsxs)("section",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 rounded-xl border border-line p-6",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Give an agent an email address"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Each email conversation becomes a task."})]}),d&&(0,e.jsx)(u,{asChild:!0,size:"lg",children:(0,e.jsx)(Le,{to:`/apps/chat/connect?provider=agentmail&connectionId=${n}`,children:"Give an agent an email address"})})]}),w.map(r=>(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-line p-4",children:[(0,e.jsx)(Le,{className:"text-sm underline",to:`/apps/chat/${r.id}/settings`,children:r.address}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:r.lastError??(r.status==="active"?"Receiving email":r.status)})]},r.id)),!!w.length&&(0,e.jsx)(Je,{}),l.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:l.error.message})]})}t(ot,"EmailConnectionInboxes");function lt({endpointId:a,companyId:n,assignedAgentName:d}){const l=We(),m=F({queryKey:["email-inboxes",n],queryFn:t(()=>q.list(n),"queryFn"),refetchInterval:1e4}),i=m.data?.find(p=>p.id===a),[w,r]=(0,o.useState)(!1),[c,_]=(0,o.useState)(""),[h,j]=(0,o.useState)(!1);(0,o.useEffect)(()=>{i?.lastError&&j(!0)},[i?.lastError]);const[g,V]=(0,o.useState)(""),y=G({mutationFn:t(()=>q.reconnect(a,c,g||i.receiveMode),"mutationFn"),onSuccess:t(()=>{_("")},"onSuccess"),onSettled:t(()=>{l.invalidateQueries({queryKey:["email-inboxes",n]})},"onSettled")}),v=G({mutationFn:t(p=>q.control(a,p),"mutationFn"),onSuccess:t(p=>{r(p.status==="archived"),l.invalidateQueries({queryKey:["email-inboxes",n]})},"onSuccess")});return w?(0,e.jsx)("p",{children:"Inbox disconnected. Email history remains in its tasks."}):i?(0,e.jsxs)("div",{className:"max-w-2xl space-y-8 pb-8",children:[(0,e.jsxs)("header",{className:"space-y-2",children:[(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:[d,"’s email address"]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,e.jsx)("h1",{"aria-label":i.address??void 0,className:"min-w-0 break-all text-xl font-bold",children:i.address?(0,e.jsxs)(Is,{text:i.address,ariaLabel:"Copy email address",title:"Copy email address",containerClassName:"max-w-full",className:"flex min-w-0 items-center gap-2 rounded-md text-left",children:[(0,e.jsx)("span",{className:"min-w-0 break-all",children:i.address}),(0,e.jsx)(cs,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-3"})]}):"Email inbox"}),i.address&&(0,e.jsxs)("a",{href:`https://console.agentmail.to/dashboard/inboxes/${encodeURIComponent(i.address)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-ink-3 underline underline-offset-4 hover:text-ink",children:["View inbox ",(0,e.jsx)(ms,{"aria-hidden":"true",className:"size-3"})]})]}),i.status==="active"&&i.address&&(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["Send an email to this address to start a task with ",d,"."]})]}),(0,e.jsxs)(He,{className:"gap-2 p-4",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"How it Works"}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["Incoming email creates tasks for ",d,". Replies stay in the same task. Task comments stay internal; use Email reply to send an email."]})]}),(0,e.jsxs)("section",{"aria-labelledby":"email-receiving-heading",className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{id:"email-receiving-heading",className:"text-sm font-semibold",children:"Receiving email"}),(i.status!=="active"||i.lastError)&&(0,e.jsx)(Cs,{status:i.status==="active"?"attention":i.status,label:i.status==="active"?"Needs attention":i.status==="revoked"?"Access revoked":void 0})]}),["active","paused"].includes(i.status)&&(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:v.isPending,onClick:t(()=>v.mutate(i.status==="active"?"pause":"resume"),"onClick"),children:i.status==="active"?"Pause":"Resume"})]}),i.status==="paused"&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Receiving is paused. Resume to receive new email."}),(0,e.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("dt",{className:"text-xs text-ink-3",children:"Receiving mode"}),(0,e.jsx)("dd",{className:"text-sm",children:i.receiveMode==="websocket"?"Live connection":"Webhook"})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("dt",{className:"text-xs text-ink-3",children:"Last mail check"}),(0,e.jsx)("dd",{className:"font-mono text-xs",children:i.lastSyncAt?ss(i.lastSyncAt):"Not checked yet"})]})]}),i.lastError&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:i.lastError}),v.error&&v.variables!=="remove"&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:v.error.message})]}),(0,e.jsxs)("details",{open:h,onToggle:t(p=>j(p.currentTarget.open),"onToggle"),className:"border-t border-line pt-5",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Reconnect inbox"}),(0,e.jsxs)("div",{className:"space-y-4 pt-4",children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Replace the API key or change how this inbox receives email. The email address and task history stay the same."}),(0,e.jsx)(Ss,{label:"New API key",value:c,onChange:_,disabled:y.isPending}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(de,{htmlFor:"email-reconnect-mode",children:"Receiving mode"}),(0,e.jsxs)("select",{id:"email-reconnect-mode",className:ce,disabled:y.isPending,value:g||i.receiveMode,onChange:t(p=>V(p.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"websocket",children:"Live connection"}),(0,e.jsx)("option",{value:"webhook",children:"Webhook"})]})]}),y.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:y.error.message}),y.isSuccess&&(0,e.jsx)("p",{role:"status",className:"text-sm",children:"Inbox reconnected."}),(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(u,{variant:"secondary",disabled:!c||y.isPending,onClick:t(()=>y.mutate(),"onClick"),children:y.isPending?"Reconnecting…":"Reconnect inbox"})})]})]}),(0,e.jsxs)("section",{"aria-labelledby":"email-disconnect-heading",className:"space-y-3 border-t border-line pt-5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{id:"email-disconnect-heading",className:"text-sm font-semibold",children:"Disconnect inbox"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Stop receiving email in Wardmote. The inbox stays in AgentMail."})]}),(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:v.isPending,onClick:t(()=>v.mutate("remove"),"onClick"),children:"Disconnect inbox"})]}),v.error&&v.variables==="remove"&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:v.error.message})]})]}):(0,e.jsx)("p",{role:m.error?"alert":void 0,children:m.error?.message??"Loading email inbox…"})}t(lt,"EmailEndpointSettings");export{lt as n,rt as r,ot as t};
|
|
1
|
+
var es=Object.defineProperty;var t=(a,n)=>es(a,"name",{value:n,configurable:!0});import{i as Ue}from"./rolldown-runtime-ZpX3ckPj.js";import{Fr as Qe,h as ss,la as ts,ua as as}from"./createLucideIcon-CgrPXnTY.js";import{y as Oe}from"./star-eem0qj3E.js";import{X as We,_ as G,n as ns,t as R,v as F}from"./queryKeys-BzT8CD34.js";import{n as is}from"./CompanyContext-fQCNWI_f.js";import{o as rs,t as Le,zt as os}from"./router-CJbFZfVR.js";import{t as de}from"./label-B707hSFt.js";import{t as ls}from"./arrow-left-CnGEiANj.js";import{t as $e}from"./arrow-right-W0iJ_-Zs.js";import{t as ds}from"./check-Bis3vECb.js";import{t as cs}from"./copy-C1cfcpxY.js";import{t as ms}from"./external-link-BIcMNNSN.js";import{t as u}from"./button-DI4w5WP7.js";import{t as xs}from"./triangle-alert-CnHMpmva.js";import{t as be}from"./agents-B8n-p0aX.js";import{t as us}from"./projects-l3kQxnTp.js";import{a as hs,i as ps,n as gs,r as fs,s as bs,t as js}from"./dialog-CeH7rDcv.js";import{t as ys}from"./input-BBNGmECW.js";import{t as Be}from"./tools-MhVvhrz_.js";import{n as vs}from"./AgentMultiSelect-BlUaNdZZ.js";import{i as ks,o as Ns,t as He}from"./card-BVZvs7aX.js";import{In as Pe,Mn as ze,Pn as De,ti as ws,wn as Cs}from"./index-QhteFtm-.js";import{t as q}from"./email-hX48MODm.js";import{n as Ss,t as As}from"./AgentMailCredentialField-DNclWIul.js";import{t as Is}from"./CopyText-BbOm2I6t.js";import{t as qs}from"./TrustPresetSection-BDb0N4Pe.js";var o=Ue(as(),1);function Es(a,n,d,l,m){const i=JSON.stringify([a,n,d,l]),[w,r]=(0,o.useState)();(0,o.useEffect)(()=>{if(!m)return;const _=new AbortController,h=setTimeout(()=>{q.checkAddress(a,n,{username:d,domain:l},_.signal).then(j=>{_.signal.aborted||r({key:i,result:j})}).catch(j=>{_.signal.aborted||r({key:i,error:j instanceof Error?j.message:"Could not check this address."})})},350);return()=>{clearTimeout(h),_.abort()}},[a,n,d,l,i,m]);const c=m&&w?.key===i?w:void 0;return{result:c?.result,error:c?.error,checking:m&&!c}}t(Es,"useEmailAddressCheck");var e=Ue(ts(),1);function Je(){return(0,e.jsxs)("div",{role:"note",className:"space-y-3 rounded-lg border border-line bg-bg-3/30 p-4",children:[(0,e.jsxs)("div",{className:"flex items-start gap-2",children:[(0,e.jsx)(xs,{className:"size-4 shrink-0 text-(--status-agent-paused)"}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:"Anyone can email an unrestricted inbox"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Incoming email can create tasks and trigger agent work. Set up an allowlist in AgentMail to limit who can contact this inbox."}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Wardmote does not verify sender restrictions. AgentMail controls new messages and replies separately; check both lists."})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-4 text-sm",children:[(0,e.jsx)("a",{href:"https://console.agentmail.to",target:"_blank",rel:"noreferrer",className:"underline underline-offset-4",children:"Open AgentMail ↗"}),(0,e.jsx)("a",{href:"https://docs.agentmail.to/knowledge-base/allowlists-blocklists",target:"_blank",rel:"noreferrer",className:"text-ink-3 underline underline-offset-4",children:"Set up allowlists ↗"})]})]})}t(Je,"EmailSafetyNotice");var ce="w-full rounded-md border border-line-strong bg-bg px-3 py-2 text-sm";function Ks(a){try{const n=JSON.parse(sessionStorage.getItem(a)??"{}");if(!n||typeof n!="object")return{};const d={};for(const l of["connectionId","agentId","inboxId","username","domain"])typeof n[l]=="string"&&(d[l]=n[l]);return(n.step===0||n.step===1)&&(d.step=n.step),typeof n.requestId=="string"&&Qe(n.requestId)&&(d.requestId=n.requestId),(n.addressMode==="new"||n.addressMode==="existing")&&(d.addressMode=n.addressMode),(n.mode==="websocket"||n.mode==="webhook")&&(d.mode=n.mode),(n.selectedCredentialId===null||typeof n.selectedCredentialId=="string")&&(d.selectedCredentialId=n.selectedCredentialId),typeof n.allowInboxKey=="boolean"&&(d.allowInboxKey=n.allowInboxKey),typeof n.domainSelected=="boolean"&&(d.domainSelected=n.domainSelected),Array.isArray(n.takenAddresses)&&(d.takenAddresses=n.takenAddresses.filter(l=>typeof l=="string"&&l.length<=320).slice(-20)),d}catch{return{}}}t(Ks,"readEmailSetupDraft");function rt(){const{selectedCompanyId:a}=is(),[n]=Oe();return a?(0,e.jsx)(_s,{companyId:a},`${a}:${n.get("resume")??n.get("setupId")??n.get("connectionId")??"new"}:${n.get("agentId")??"choose"}`):(0,e.jsx)("p",{role:"status",className:"p-6 text-sm text-ink-3",children:"Loading email setup…"})}t(rt,"EmailEndpointSetup");function _s({companyId:a}){const[n]=Oe(),d=rs(),l=We(),m=n.get("resume"),i=n.get("setupId"),w=`wardmote.agentmail-setup:${a}:${m??i??n.get("connectionId")??"new"}:${n.get("agentId")??"choose"}`,[r]=(0,o.useState)(()=>{const s=Ks(w);return m&&s.requestId&&s.requestId!==m?{}:s}),[c,_]=(0,o.useState)(r.connectionId??n.get("connectionId")??""),[h,j]=(0,o.useState)(r.step??(m?1:0)),[g,V]=(0,o.useState)(r.agentId??n.get("agentId")??""),[y,v]=(0,o.useState)(""),[p,me]=(0,o.useState)(r.selectedCredentialId!==void 0?r.selectedCredentialId:c||null),[je,B]=(0,o.useState)(""),[D,xe]=(0,o.useState)(r.allowInboxKey??!1),[E]=(0,o.useState)(()=>r.requestId??m??(i&&Qe(i)?i:crypto.randomUUID())),[C,ue]=(0,o.useState)(r.addressMode??"new"),[U,he]=(0,o.useState)(r.inboxId??""),[S,X]=(0,o.useState)(r.username??""),[K,ye]=(0,o.useState)(r.domain??"agentmail.to"),[Y,ve]=(0,o.useState)(r.domainSelected??(!!r.domain&&r.domain!=="agentmail.to")),[Z,ke]=(0,o.useState)(r.takenAddresses??[]),[Q,Ne]=(0,o.useState)(r.mode??"websocket"),[ee,se]=(0,o.useState)(!1),[O,we]=(0,o.useState)({}),Ce=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(a)try{h===2?sessionStorage.removeItem(w):sessionStorage.setItem(w,JSON.stringify({connectionId:c,step:h,agentId:g,requestId:E,addressMode:C,inboxId:U,username:S,domain:K,domainSelected:Y,takenAddresses:Z,mode:Q,allowInboxKey:D,selectedCredentialId:p}))}catch{}},[a,w,c,h,g,E,C,U,S,K,Y,Z,Q,D,p]);const H=F({queryKey:R.agents.list(a),queryFn:t(()=>be.list(a),"queryFn"),enabled:!!a}),te=F({queryKey:R.projects.list(a),queryFn:t(()=>us.list(a),"queryFn"),enabled:!!a&&ee}),ae=F({queryKey:["email-boundary-issues",a],queryFn:t(()=>os.list(a),"queryFn"),enabled:!!a&&ee}),k=H.data?.find(s=>s.id===g),ne=De(k?.permissions)==="low_trust_review",ie=Pe(ze(k?.permissions)),N=F({queryKey:["email-credential-inspect",a,c],queryFn:t(()=>q.inspectSaved(a,c),"queryFn"),enabled:!!a&&!!c,retry:!1}),A=F({queryKey:["email-inboxes",a],queryFn:t(()=>q.list(a),"queryFn"),enabled:!!a}),f=A.data?.find(s=>s.id===E&&s.status!=="archived"),x=f?.address,J=F({queryKey:["email-resume-account",a,f?.connectionId],queryFn:t(()=>Be.getConnection(f.connectionId),"queryFn"),enabled:!!m&&E===m&&!!f&&!c,retry:!1});(0,o.useEffect)(()=>{if(!m||!f||c||!J.isSuccess)return;const s=J.data?.config?.credentialConnectionId;typeof s=="string"?_(s):j(0),Ne(f.receiveMode)},[m,f,c,J.isSuccess,J.data]),(0,o.useEffect)(()=>{f&&V(f.assignedAgentId)},[f]);const T=N.data?.scope.scope_type==="inbox",Se=[...new Set(N.data?.domains.filter(s=>s.status==="VERIFIED"&&s.domain.toLowerCase()!=="agentmail.to").map(s=>s.domain.toLowerCase())??[])],Ae=Se[0]??"agentmail.to";(0,o.useEffect)(()=>{N.isSuccess&&!Y&&!x&&ye(Ae)},[N.isSuccess,Y,x,Ae]),(0,o.useEffect)(()=>{!T||!A.isSuccess||(x||D?(ue("existing"),he(N.data?.inboxes[0]?.inbox_id??"")):h===1&&(B(N.data?.inboxes[0]?.inbox_id??"this inbox"),me(null),j(0)))},[T,N.data,A.isSuccess,x,D,h]),(0,o.useEffect)(()=>{k&&!Ce.current&&(Ce.current=!0,S||X(k.name.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").slice(0,64)))},[k,S]);const $=G({mutationFn:t(async()=>{if(x)return!0;const s=p?await q.inspectSaved(a,p):await q.inspect(a,y.trim());if(s.scope.scope_type==="inbox"&&!D)return B(s.inboxes[0]?.inbox_id??"this inbox"),!1;const M=!!c&&p!==c,W=M?crypto.randomUUID():E;let z=p;return z||(z=(await q.connect(a,{apiKey:y.trim(),grantKind:"organization",allAgents:!1,agentIds:[g],idempotencyKey:W})).id),l.setQueryData(["email-credential-inspect",a,z],s),me(z),v(""),l.invalidateQueries({queryKey:["email-credentials",a]}),l.invalidateQueries({queryKey:R.tools.connections(a)}),M?(f&&(await q.control(f.id,"remove"),await l.invalidateQueries({queryKey:["email-inboxes",a]})),Te({connectionId:z,selectedCredentialId:z,agentId:g,step:1,requestId:W,addressMode:s.scope.scope_type==="inbox"?"existing":"new",inboxId:s.scope.scope_type==="inbox"?s.inboxes[0]?.inbox_id??"":"",username:S,domain:"agentmail.to",domainSelected:!1,takenAddresses:[],mode:Q,allowInboxKey:D}),!1):(_(z),B(""),ue(s.scope.scope_type==="inbox"?"existing":"new"),s.scope.scope_type==="inbox"&&he(s.inboxes[0]?.inbox_id??""),!0)},"mutationFn"),onSuccess:t(s=>{s&&j(1)},"onSuccess")});function Ge(s){me(s),v(""),B(""),xe(!1),ve(!1),ke([]),$.reset()}t(Ge,"selectCredential");const pe=F({queryKey:R.agents.detail(g),queryFn:t(()=>be.get(g),"queryFn"),enabled:!!g&&ee}),re=G({mutationFn:t(()=>be.updatePermissions(g,{...O,canCreateAgents:O.canCreateAgents??!1,canCreateSkills:O.canCreateSkills??!0,canAssignTasks:pe.data?.access?.canAssignTasks??!1},a),"mutationFn"),onSuccess:t(()=>{se(!1),l.invalidateQueries({queryKey:R.agents.list(a)})},"onSuccess")}),I=G({mutationFn:t(()=>q.setup(a,{assignedAgentId:g,credentialConnectionId:c,...x?{inboxId:x}:C==="existing"?{inboxId:U}:{username:S,domain:K},receiveMode:Q,idempotencyKey:E}),"mutationFn"),onError:t(async s=>{s instanceof ns&&s.body?.code==="agentmail_address_taken"&&ke(M=>[...new Set([...M,`${S}@${K}`.toLowerCase()])].slice(-20)),await l.invalidateQueries({queryKey:["email-inboxes",a]})},"onError"),onSuccess:t(()=>{l.invalidateQueries({queryKey:["email-inboxes",a]}),l.invalidateQueries({queryKey:R.chatEndpoints.list(a)}),l.invalidateQueries({queryKey:R.tools.connections(a)}),l.invalidateQueries({queryKey:R.tools.connectionInstalls(c)}),j(2)},"onSuccess")}),Ie=x??(C==="existing"?U:`${S}@${K}`),qe=new Set([...Z,...N.data?.inboxes.map(s=>s.inbox_id.toLowerCase())??[]]),oe=h===1&&C==="new"&&!x&&!T,Ee=oe&&qe.has(Ie.toLowerCase()),ge=/^[a-z0-9][a-z0-9._-]*$/.test(S)&&S.length<=64,P=Es(a,c,S,K,oe&&ge&&!!N.data&&!Ee),fe=Ee||P.result?.status==="taken",Ke=oe&&ge&&(fe||P.result?.status==="unknown")?["-agent","-team",`-${E.slice(0,6)}`].map(s=>`${S.slice(0,64-s.length)}${s}`).filter(s=>!qe.has(`${s}@${K}`)):[],Ve=C==="existing"&&A.data?.some(s=>s.id!==E&&s.address===Ie&&s.status!=="archived"),L=fe?"This email address is already in use. Choose a different address.":Ve?"This inbox is already assigned to an agent.":null,le=$.error??(fe?null:I.error)??J.error??N.error??H.error,b=$.isPending||I.isPending,_e=A.isSuccess&&(!m||E!==m||!!f)&&(!f||f.assignedAgentId===g),Fe=_e&&!!k&&!b&&!(ne&&!ie)&&(!!x||!!p||!!y.trim()),Me=_e&&!!k&&!b&&!!N.data&&!(ne&&!ie)&&!L&&!P.checking&&(!!x||(C==="existing"?!!U:ge)),Re=t(()=>{k&&(we(k.permissions),se(!0))},"openTrust"),Xe=t(()=>d(`/apps/chat/${I.data?.id??f?.id}/settings`),"leave"),Ye=t(()=>{try{sessionStorage.removeItem(w)}catch{}d("/apps")},"cancel");function Te(s){try{sessionStorage.setItem(`wardmote.agentmail-setup:${a}:${s.requestId}:${g}`,JSON.stringify(s))}catch{}d(`/apps/chat/connect?${new URLSearchParams({provider:"agentmail",purpose:"chat",setupId:s.requestId,agentId:g,connectionId:s.connectionId})}`)}t(Te,"openDraft");const Ze=t(()=>{const s=crypto.randomUUID();Te({connectionId:c,selectedCredentialId:c,agentId:g,step:1,requestId:s,addressMode:"new",username:"",inboxId:"",domain:x?.slice(x.lastIndexOf("@")+1)??K,domainSelected:!0,takenAddresses:Z,mode:Q,allowInboxKey:!1})},"chooseAnotherAddress");return(0,e.jsxs)("div",{className:"mx-auto max-w-xl space-y-6 p-6",children:[(0,e.jsx)("header",{className:"space-y-2",children:(0,e.jsx)("h1",{className:"text-xl font-bold",children:h===2?"Your agent’s email is ready":"Give an agent an email address"})}),h<2&&A.isError&&(0,e.jsxs)("div",{role:"alert",className:"space-y-2 text-sm",children:[(0,e.jsxs)("p",{className:"text-bad",children:["Could not load email setup progress. ",A.error.message]}),(0,e.jsx)(u,{type:"button",variant:"secondary",size:"sm",disabled:b||A.isFetching,onClick:t(()=>{A.refetch()},"onClick"),children:A.isFetching?"Loading…":"Retry loading inboxes"})]}),h<2&&m===E&&A.isSuccess&&!f&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"This email setup could not be found. Return to Connectors and start a new connection."}),h<2&&(0,e.jsx)(ws,{labels:["Agent","Email address"],step:h,availableStep:h,disabled:b,onSelect:t(s=>{I.reset(),j(s)},"onSelect")}),h===0&&(0,e.jsxs)("form",{className:"space-y-6",onSubmit:t(s=>{s.preventDefault(),Fe&&$.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(de,{htmlFor:"email-agent",children:"Agent"}),(0,e.jsx)(vs,{id:"email-agent",value:g,disabled:b||H.isPending||!A.isSuccess||!!f,placeholder:"Choose an agent",emptyMessage:"No agents found.",triggerClassName:"h-10",agents:(H.data??[]).filter(s=>!["terminated","pending_approval"].includes(s.status)),onChange:t(s=>{V(s),X((H.data?.find(M=>M.id===s)?.name??"").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").slice(0,64))},"onChange")})]}),!x&&(0,e.jsx)(As,{companyId:a,connectionId:p,onConnectionChange:Ge,value:y,onChange:t(s=>{v(s),$.reset()},"onChange"),disabled:b}),je&&(0,e.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,e.jsxs)("p",{className:"text-ink-3",children:["That key only connects ",je,". Choose a saved account key or enter one to create a new address."]}),(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b||!(p||y.trim()),onClick:t(()=>{xe(!0),B(""),$.reset()},"onClick"),children:"Use the existing inbox instead"})]}),ne&&!ie&&(0,e.jsxs)("div",{role:"alert",className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:"This agent needs a work boundary before it can receive email."}),(0,e.jsx)(u,{type:"button",variant:"secondary",size:"sm",onClick:Re,children:"Configure work boundary"})]}),le&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:le.message}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-line pt-5",children:[(0,e.jsx)(u,{type:"button",variant:"ghost",disabled:b,onClick:Ye,children:"Cancel"}),(0,e.jsxs)(u,{disabled:!Fe,children:[$.isPending?"Connecting…":"Continue",(0,e.jsx)($e,{className:"size-4"})]})]})]}),h===1&&(0,e.jsxs)("form",{className:"space-y-6",onSubmit:t(s=>{s.preventDefault(),Me&&I.mutate()},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(de,{htmlFor:C==="new"?"email-name":"email-existing",children:[k?.name,"’s email address"]}),x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-sm font-medium",children:x}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["This address was created in AgentMail. Finish connecting it to ",k?.name,T?".":", or choose a different address. The original inbox will stay in AgentMail."]}),!T&&(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:Ze,children:"Choose a different address"})]}):C==="new"?(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ys,{id:"email-name",className:"min-w-0",value:S,maxLength:64,autoComplete:"off",spellCheck:!1,disabled:b,"aria-invalid":!!L,"aria-describedby":L?"email-address-error":"email-address-status",onChange:t(s=>{X(s.target.value.toLowerCase()),I.reset()},"onChange")}),(0,e.jsx)("select",{id:"email-domain","aria-label":"Email domain",className:`${ce} max-w-1/2 shrink-0`,value:K,disabled:b||!N.data,onChange:t(s=>{ve(!0),ye(s.target.value),I.reset()},"onChange"),children:[...new Set([...Se,"agentmail.to",K])].map(s=>(0,e.jsxs)("option",{value:s,children:["@",s]},s))})]})}):(0,e.jsxs)("select",{id:"email-existing",className:ce,value:x??U,disabled:b||T||!!x,"aria-invalid":!!L,"aria-describedby":L?"email-address-error":void 0,onChange:t(s=>{he(s.target.value),I.reset()},"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Choose an inbox"}),N.data?.inboxes.map(s=>{const M=A.data?.some(W=>W.id!==E&&W.address===s.inbox_id&&W.status!=="archived");return(0,e.jsxs)("option",{value:s.inbox_id,disabled:M,children:[s.inbox_id,M?" — already assigned":""]},s.inbox_id)})]}),T&&!x&&(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:t(()=>{xe(!1),j(0)},"onClick"),children:"Choose a key for a new address"}),L&&(0,e.jsx)("p",{id:"email-address-error",role:"alert",className:"text-sm text-bad",children:L}),oe&&!L&&(0,e.jsx)("p",{id:"email-address-status",role:"status",className:"text-sm text-ink-3",children:P.checking?"Checking address…":P.error?`Could not check this address. ${P.error}`:P.result?.status==="unknown"?"AgentMail confirms availability when you create the address.":null}),Ke.length>0&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm","aria-label":"Suggested email addresses",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Try:"}),Ke.map(s=>(0,e.jsxs)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:t(()=>{X(s),I.reset()},"onClick"),children:[s,"@",K]},s))]}),!T&&!x&&(0,e.jsx)(u,{type:"button",variant:"link",size:"sm",className:"h-auto p-0",disabled:b,onClick:t(()=>{ue(C==="new"?"existing":"new"),I.reset()},"onClick"),children:C==="new"?"Use an existing inbox":"Create a new address"})]}),(0,e.jsx)(He,{className:"py-4",children:(0,e.jsxs)(Ns,{className:"px-4",children:[(0,e.jsx)("h2",{className:"text-sm font-medium",children:"How it Works"}),(0,e.jsxs)(ks,{children:["Incoming email creates tasks for ",k?.name,". Replies stay in the same task."]})]})}),(0,e.jsxs)("details",{className:"space-y-4",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm text-ink-3",children:"Advanced options"}),(0,e.jsxs)("div",{className:"space-y-4",children:[C==="new"&&(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("a",{className:"text-sm underline",href:"https://docs.agentmail.to/custom-domains",target:"_blank",rel:"noreferrer",children:"Set up a custom domain ↗"})}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(de,{htmlFor:"email-mode",children:"Receiving"}),(0,e.jsxs)("select",{id:"email-mode",value:Q,disabled:b,className:ce,onChange:t(s=>Ne(s.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"websocket",children:"Live connection"}),(0,e.jsx)("option",{value:"webhook",children:"Webhook"})]})]}),(0,e.jsx)(Je,{}),(0,e.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:ne&&ie?"Low-trust review configured":"Manage which tasks and tools this agent can access."}),(0,e.jsx)(u,{type:"button",variant:"secondary",size:"sm",onClick:Re,children:"Review trust settings"})]})]})]}),le&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:le.message}),N.isPending&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading email options…"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-line pt-5",children:[(0,e.jsxs)(u,{type:"button",variant:"ghost",disabled:b,onClick:t(()=>{I.reset(),j(0)},"onClick"),children:[(0,e.jsx)(ls,{className:"size-4"}),"Back"]}),(0,e.jsxs)(u,{disabled:!Me,children:[I.isPending?"Connecting…":x?"Finish connecting":C==="new"?"Create email address":"Connect email address",(0,e.jsx)($e,{className:"size-4"})]})]})]}),h===2&&(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[(0,e.jsx)(ds,{className:"size-4"}),I.data?.address]}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:[k?.name," can now receive email at this address."]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-line pt-5",children:[(0,e.jsx)(u,{variant:"ghost",onClick:Xe,children:"Email settings"}),(0,e.jsx)(u,{onClick:t(()=>d("/apps"),"onClick"),children:"Done"})]})]}),(0,e.jsx)(js,{open:ee,onOpenChange:se,children:(0,e.jsxs)(gs,{className:"max-h-screen overflow-y-auto sm:max-w-2xl",children:[(0,e.jsxs)(hs,{children:[(0,e.jsxs)(bs,{children:["Trust settings · ",k?.name]}),(0,e.jsx)(fs,{children:"Changes apply to all of this agent’s work. Use a dedicated email agent if its other tasks need broader access."})]}),(0,e.jsx)(qs,{permissions:O,onChange:we,companyId:a,projectCandidates:(te.data??[]).map(s=>({id:s.id,label:s.name})),issueCandidates:(ae.data??[]).map(s=>({id:s.id,label:`${s.identifier} · ${s.title}`})),allowSingleIssue:!1,candidatesLoading:te.isPending||ae.isPending}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Low trust limits Wardmote access; it does not sandbox the runtime. Review filesystem, tool, and secret access separately."}),(re.error||te.error||ae.error)&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:(re.error??te.error??ae.error)?.message}),(0,e.jsxs)(ps,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:t(()=>se(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(u,{disabled:re.isPending||pe.isPending||!!pe.error||De(O)==="low_trust_review"&&!Pe(ze(O)),onClick:t(()=>re.mutate(),"onClick"),children:"Save trust settings"})]})]})})]})}t(_s,"EmailEndpointSetupForm");function ot({companyId:a,connectionId:n,canConfigure:d}){const l=F({queryKey:["email-inboxes",a],queryFn:t(()=>q.list(a),"queryFn"),refetchInterval:1e4}),m=F({queryKey:R.tools.connections(a),queryFn:t(()=>Be.listConnections(a),"queryFn")}),i=new Set(m.data?.connections.filter(r=>r.config?.credentialConnectionId===n).map(r=>r.id)),w=l.data?.filter(r=>r.connectionId===n||i.has(r.connectionId))??[];return(0,e.jsxs)("section",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 rounded-xl border border-line p-6",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Give an agent an email address"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Each email conversation becomes a task."})]}),d&&(0,e.jsx)(u,{asChild:!0,size:"lg",children:(0,e.jsx)(Le,{to:`/apps/chat/connect?provider=agentmail&connectionId=${n}`,children:"Give an agent an email address"})})]}),w.map(r=>(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-line p-4",children:[(0,e.jsx)(Le,{className:"text-sm underline",to:`/apps/chat/${r.id}/settings`,children:r.address}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:r.lastError??(r.status==="active"?"Receiving email":r.status)})]},r.id)),!!w.length&&(0,e.jsx)(Je,{}),l.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:l.error.message})]})}t(ot,"EmailConnectionInboxes");function lt({endpointId:a,companyId:n,assignedAgentName:d}){const l=We(),m=F({queryKey:["email-inboxes",n],queryFn:t(()=>q.list(n),"queryFn"),refetchInterval:1e4}),i=m.data?.find(p=>p.id===a),[w,r]=(0,o.useState)(!1),[c,_]=(0,o.useState)(""),[h,j]=(0,o.useState)(!1);(0,o.useEffect)(()=>{i?.lastError&&j(!0)},[i?.lastError]);const[g,V]=(0,o.useState)(""),y=G({mutationFn:t(()=>q.reconnect(a,c,g||i.receiveMode),"mutationFn"),onSuccess:t(()=>{_("")},"onSuccess"),onSettled:t(()=>{l.invalidateQueries({queryKey:["email-inboxes",n]})},"onSettled")}),v=G({mutationFn:t(p=>q.control(a,p),"mutationFn"),onSuccess:t(p=>{r(p.status==="archived"),l.invalidateQueries({queryKey:["email-inboxes",n]})},"onSuccess")});return w?(0,e.jsx)("p",{children:"Inbox disconnected. Email history remains in its tasks."}):i?(0,e.jsxs)("div",{className:"max-w-2xl space-y-8 pb-8",children:[(0,e.jsxs)("header",{className:"space-y-2",children:[(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:[d,"’s email address"]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,e.jsx)("h1",{"aria-label":i.address??void 0,className:"min-w-0 break-all text-xl font-bold",children:i.address?(0,e.jsxs)(Is,{text:i.address,ariaLabel:"Copy email address",title:"Copy email address",containerClassName:"max-w-full",className:"flex min-w-0 items-center gap-2 rounded-md text-left",children:[(0,e.jsx)("span",{className:"min-w-0 break-all",children:i.address}),(0,e.jsx)(cs,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-3"})]}):"Email inbox"}),i.address&&(0,e.jsxs)("a",{href:`https://console.agentmail.to/dashboard/inboxes/${encodeURIComponent(i.address)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-ink-3 underline underline-offset-4 hover:text-ink",children:["View inbox ",(0,e.jsx)(ms,{"aria-hidden":"true",className:"size-3"})]})]}),i.status==="active"&&i.address&&(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["Send an email to this address to start a task with ",d,"."]})]}),(0,e.jsxs)(He,{className:"gap-2 p-4",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"How it Works"}),(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["Incoming email creates tasks for ",d,". Replies stay in the same task. Task comments stay internal; use Email reply to send an email."]})]}),(0,e.jsxs)("section",{"aria-labelledby":"email-receiving-heading",className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h2",{id:"email-receiving-heading",className:"text-sm font-semibold",children:"Receiving email"}),(i.status!=="active"||i.lastError)&&(0,e.jsx)(Cs,{status:i.status==="active"?"attention":i.status,label:i.status==="active"?"Needs attention":i.status==="revoked"?"Access revoked":void 0})]}),["active","paused"].includes(i.status)&&(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:v.isPending,onClick:t(()=>v.mutate(i.status==="active"?"pause":"resume"),"onClick"),children:i.status==="active"?"Pause":"Resume"})]}),i.status==="paused"&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Receiving is paused. Resume to receive new email."}),(0,e.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("dt",{className:"text-xs text-ink-3",children:"Receiving mode"}),(0,e.jsx)("dd",{className:"text-sm",children:i.receiveMode==="websocket"?"Live connection":"Webhook"})]}),(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("dt",{className:"text-xs text-ink-3",children:"Last mail check"}),(0,e.jsx)("dd",{className:"font-mono text-xs",children:i.lastSyncAt?ss(i.lastSyncAt):"Not checked yet"})]})]}),i.lastError&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:i.lastError}),v.error&&v.variables!=="remove"&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:v.error.message})]}),(0,e.jsxs)("details",{open:h,onToggle:t(p=>j(p.currentTarget.open),"onToggle"),className:"border-t border-line pt-5",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Reconnect inbox"}),(0,e.jsxs)("div",{className:"space-y-4 pt-4",children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Replace the API key or change how this inbox receives email. The email address and task history stay the same."}),(0,e.jsx)(Ss,{label:"New API key",value:c,onChange:_,disabled:y.isPending}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(de,{htmlFor:"email-reconnect-mode",children:"Receiving mode"}),(0,e.jsxs)("select",{id:"email-reconnect-mode",className:ce,disabled:y.isPending,value:g||i.receiveMode,onChange:t(p=>V(p.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"websocket",children:"Live connection"}),(0,e.jsx)("option",{value:"webhook",children:"Webhook"})]})]}),y.error&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:y.error.message}),y.isSuccess&&(0,e.jsx)("p",{role:"status",className:"text-sm",children:"Inbox reconnected."}),(0,e.jsx)("div",{className:"flex justify-end",children:(0,e.jsx)(u,{variant:"secondary",disabled:!c||y.isPending,onClick:t(()=>y.mutate(),"onClick"),children:y.isPending?"Reconnecting…":"Reconnect inbox"})})]})]}),(0,e.jsxs)("section",{"aria-labelledby":"email-disconnect-heading",className:"space-y-3 border-t border-line pt-5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{id:"email-disconnect-heading",className:"text-sm font-semibold",children:"Disconnect inbox"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Stop receiving email in Wardmote. The inbox stays in AgentMail."})]}),(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:v.isPending,onClick:t(()=>v.mutate("remove"),"onClick"),children:"Disconnect inbox"})]}),v.error&&v.variables==="remove"&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:v.error.message})]})]}):(0,e.jsx)("p",{role:m.error?"alert":void 0,children:m.error?.message??"Loading email inbox…"})}t(lt,"EmailEndpointSettings");export{lt as n,rt as r,ot as t};
|
package/dist/assets/{ExecutionWorkspaceDetail-CTDvazWh.js → ExecutionWorkspaceDetail-CnUD3jLO.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ms=Object.defineProperty;var r=(s,n)=>ms(s,"name",{value:n,configurable:!0});import{i as $e}from"./rolldown-runtime-ZpX3ckPj.js";import{C as ps,S as xs,T as hs,Zi as fs,Zn as gs,h as L,l as S,la as js,ua as vs}from"./createLucideIcon-CgrPXnTY.js";import{h as bs,v as ks}from"./star-eem0qj3E.js";import{X as Re,_ as le,t as x,v as P}from"./queryKeys-BzT8CD34.js";import{a as ys,i as ws,r as Ns,t as Rs}from"./WorkspaceRuntimeControls-Clk2nzU6.js";import{n as Cs}from"./CompanyContext-fQCNWI_f.js";import{o as Is,r as Ss,t as Y,zt as ke}from"./router-CJbFZfVR.js";import{t as Ws}from"./tabs-CjHzZxtD.js";import{o as Ps,r as _s,t as Es}from"./popover-CWlBonqy.js";import{t as As}from"./check-Bis3vECb.js";import{t as Ts}from"./chevron-down-nRcQ7bok.js";import{t as Ce}from"./copy-C1cfcpxY.js";import{t as ye}from"./external-link-BIcMNNSN.js";import{r as ue,t as N}from"./button-DI4w5WP7.js";import{t as we}from"./play-Czm7OCYh.js";import{t as Fs}from"./repeat-DzPORJjX.js";import{t as De}from"./rotate-ccw-DpzLJhXT.js";import{t as Ls}from"./square-CDo6rOf8.js";import{t as Ve}from"./triangle-alert-CnHMpmva.js";import{a as qs}from"./ToastContext-DyVJ6bCh.js";import{t as Je}from"./agents-B8n-p0aX.js";import{n as Os,t as Us}from"./useSharedPolling-CFeiZe2t.js";import{t as Bs}from"./projects-l3kQxnTp.js";import{t as U}from"./input-BBNGmECW.js";import{n as Ks,o as Ds,t as Ms}from"./slots-B7lwlN1w.js";import{t as Me}from"./routines-DteAuK7S.js";import{n as zs}from"./BreadcrumbContext-DNbB7zWn.js";import{t as $}from"./textarea-CTx68BDs.js";import{t as Qs}from"./clipboard-CTLKYvRL.js";import{i as H,n as $s,o as G,r as B,s as X,t as K}from"./card-BVZvs7aX.js";import{W as Vs,_a as Js,fr as V,pr as Hs,r as Gs,ri as Xs}from"./index-LM7k1NmC.js";import{t as ae}from"./separator-6cvFqhvW.js";import{t as Zs}from"./useManagedSandboxOnly-KE5BJrr7.js";import{t as He}from"./CopyText-BbOm2I6t.js";import{n as Ys,t as en}from"./SummarySlotCard-BJmo-gDJ.js";import{t as sn}from"./MissingPluginTabPlaceholder-D3N0rd-p.js";import{t as nn}from"./RoutineRunVariablesDialog-CtSVwZjy.js";var h=$e(vs(),1),e=$e(js(),1),tn=["provisioning","starting","stopping","restarting"];function Ie(s){return tn.includes(s)}r(Ie,"isTransitional");function Ge(s){return s?s.replace(/^https?:\/\//,"").replace(/\/$/,""):null}r(Ge,"formatServiceUrl");function Xe(s){switch(s.state){case"provisioning":return{label:"Provisioning…",unhealthy:!1};case"starting":return{label:"Starting…",unhealthy:!1};case"stopping":return{label:"Stopping…",unhealthy:!1};case"restarting":return{label:"Restarting…",unhealthy:!1};case"failed":return{label:"Failed",unhealthy:!1};case"running":return s.healthStatus==="unhealthy"?{label:"Unhealthy",unhealthy:!0}:{label:"Running",unhealthy:!1};default:return{label:"Stopped",unhealthy:!1}}}r(Xe,"statusMeta");function Se({entry:s,className:n}){if(Ie(s.state))return(0,e.jsx)(ue,{className:S("size-3 shrink-0 animate-spin text-ink-3",n)});if(s.state==="failed")return(0,e.jsx)(Ve,{className:S("size-3 shrink-0 text-bad",n)});const a=s.state==="running"&&s.healthStatus==="unhealthy";return(0,e.jsx)("span",{className:S("size-2 shrink-0 rounded-full",s.state==="running"?a?"bg-amber-500 ring-2 ring-amber-500/30":"bg-emerald-500":"border border-ink-3/60 bg-transparent",n)})}r(Se,"StatusIndicator");function Ze({url:s,disabled:n}){const[a,o]=(0,h.useState)("idle"),d=(0,h.useRef)(null);(0,h.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);const c=a==="copied"?"URL copied":a==="failed"?"Copy failed":"Copy URL";return(0,e.jsxs)(N,{variant:"ghost",size:"icon-xs",disabled:n,"aria-label":c,title:c,onClick:r(async()=>{try{await Qs(s),o("copied")}catch{o("failed")}d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o("idle"),1500)},"onClick"),children:[a==="copied"?(0,e.jsx)(As,{className:"size-3"}):a==="failed"?(0,e.jsx)(Ve,{className:"size-3 text-bad"}):(0,e.jsx)(Ce,{className:"size-3"}),(0,e.jsx)("span",{className:"sr-only","aria-live":"polite",children:c})]})}r(Ze,"CopyUrlButton");function ce({entry:s,compact:n}){const a=Ge(s.url)??(s.port?`:${s.port}`:null),o=s.state==="running"&&!!s.url;return a?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)("a",{href:s.url??void 0,target:"_blank",rel:"noreferrer",title:s.url??void 0,className:S("min-w-0 truncate font-mono text-xs text-ink hover:underline",n?"max-w-44":"max-w-56"),children:a}):(0,e.jsx)("span",{title:s.url??void 0,className:S("min-w-0 truncate font-mono text-xs text-ink-3/70",n?"max-w-44":"max-w-56"),children:a}),(0,e.jsxs)("span",{className:S("flex items-center",o?null:"invisible"),"aria-hidden":o?void 0:!0,children:[(0,e.jsx)(Ze,{url:s.url??"",disabled:!o}),(0,e.jsx)(N,{asChild:o,variant:"ghost",size:"icon-xs",disabled:!o,title:"Open in new tab",children:o?(0,e.jsx)("a",{href:s.url??void 0,target:"_blank",rel:"noreferrer","aria-label":"Open in new tab",children:(0,e.jsx)(ye,{className:"size-3"})}):(0,e.jsx)(ye,{className:"size-3"})})]})]}):(0,e.jsx)("span",{className:"font-mono text-xs text-ink-3/70",children:"no url"})}r(ce,"UrlSegment");function We({entry:s,onAction:n}){const a=Ie(s.state),o=s.canStart??!0;return s.state==="stopped"?(0,e.jsxs)(N,{variant:"primary",size:"xs",className:"w-13 justify-center",disabled:!o,onClick:r(()=>n("start"),"onClick"),"aria-label":"Start",title:"Start",children:[(0,e.jsx)(we,{className:"size-3"}),"Start"]}):s.state==="failed"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(N,{variant:"primary",size:"icon-xs",disabled:!o,onClick:r(()=>n("start"),"onClick"),"aria-label":"Start",title:"Start",children:(0,e.jsx)(we,{className:"size-3"})}),(0,e.jsx)(N,{variant:"ghost",size:"icon-xs",disabled:!o,onClick:r(()=>n("restart"),"onClick"),"aria-label":"Restart",title:"Restart",className:"border",children:(0,e.jsx)(De,{className:"size-3"})})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(N,{variant:"ghost",size:"icon-xs",disabled:a,onClick:r(()=>n("stop"),"onClick"),"aria-label":"Stop",title:"Stop",className:"border",children:(0,e.jsx)(Ls,{className:"size-3"})}),(0,e.jsx)(N,{variant:"ghost",size:"icon-xs",disabled:a||!o,onClick:r(()=>n("restart"),"onClick"),"aria-label":"Restart",title:"Restart",className:"border",children:(0,e.jsx)(De,{className:"size-3"})})]})}r(We,"ActionSlots");function rn({entry:s,onViewLogs:n}){const a=s.exposureDetail??(s.state==="failed"?s.failureDetail:null);if(!a)return null;const o=s.exposureState==="failed"||s.exposureState==="cleanup_pending";return(0,e.jsxs)("div",{className:S("flex items-center gap-1 text-xs",o?"text-bad":"text-ink-3"),children:[(0,e.jsx)("span",{children:a}),n&&s.state==="failed"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,e.jsx)("button",{type:"button",onClick:n,className:"font-medium text-ink underline underline-offset-2 hover:text-ink/80",children:"View logs"})]}):null]})}r(rn,"ServiceDetail");function an({entry:s,onAction:n,onViewLogs:a,className:o}){const d=Xe(s);return(0,e.jsxs)("div",{className:S("flex w-full flex-col items-stretch gap-1 sm:w-auto sm:items-end",o),children:[(0,e.jsxs)("div",{className:"rounded-lg border border-line bg-bg",children:[(0,e.jsxs)("div",{className:"flex h-9 items-center pl-3 pr-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 sm:min-w-24",children:[(0,e.jsx)(Se,{entry:s}),(0,e.jsx)("span",{className:"whitespace-nowrap text-xs font-medium text-ink",children:d.label})]}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"hidden w-56 min-w-0 shrink-0 items-center gap-0.5 sm:flex",children:(0,e.jsx)(ce,{entry:s})}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-1 pl-3 sm:pl-0",children:(0,e.jsx)(We,{entry:s,onAction:r(c=>n(c,s.key),"onAction")})})]}),(0,e.jsx)("div",{className:"flex h-8 items-center justify-between gap-0.5 border-t border-line px-3 sm:hidden",children:(0,e.jsx)(ce,{entry:s,compact:!0})})]}),(0,e.jsx)(rn,{entry:s,onViewLogs:a})]})}r(an,"SingleServiceBar");function on({entry:s,onAction:n}){const a=Xe(s),o=Ge(s.url),d=s.state==="running"&&!!s.url,c=s.exposureState==="failed"||s.exposureState==="cleanup_pending",u=s.exposureDetail?s.exposureDetail:d?o:s.state==="starting"&&s.port?`starting on :${s.port}…`:s.state==="failed"&&s.failureDetail?s.failureDetail:`${a.label.toLowerCase().replace(/…$/,"")}${s.port?` · :${s.port}`:""}`;return(0,e.jsxs)("div",{className:"flex items-center gap-3 py-2.5",children:[(0,e.jsx)(Se,{entry:s,className:"mt-0.5"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium text-ink",children:s.name}),(0,e.jsx)("div",{className:"flex min-w-0 items-center gap-0.5",children:d&&s.url?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("a",{href:s.url,target:"_blank",rel:"noreferrer",title:s.url,className:"min-w-0 truncate font-mono text-xs text-ink-3 hover:text-ink hover:underline",children:o}),(0,e.jsx)(Ze,{url:s.url})]}):(0,e.jsx)("span",{className:S("min-w-0 text-xs",c?"whitespace-normal break-words text-bad":"truncate text-ink-3"),children:u})})]}),(0,e.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:(0,e.jsx)(We,{entry:s,onAction:r(v=>n(v,s.key),"onAction")})})]})}r(on,"ServicePopoverRow");function ln({services:s,onAction:n,onManageServices:a,defaultServicesOpen:o,className:d}){const[c,u]=(0,h.useState)(o??!1),v=s.filter(f=>f.state==="running").length,k=s.some(f=>Ie(f.state)),y=s.some(f=>f.state==="failed"),m=v>0,p=s.find(f=>f.state==="running"&&f.url)??null,_={key:"__all__",name:"All services",state:k?"starting":y?"failed":m?"running":"stopped",healthStatus:s.some(f=>f.state==="running"&&f.healthStatus==="unhealthy")?"unhealthy":"healthy"};return(0,e.jsx)("div",{className:S("flex w-full flex-col items-stretch gap-1 sm:w-auto sm:items-end",d),children:(0,e.jsxs)("div",{className:"rounded-lg border border-line bg-bg",children:[(0,e.jsxs)("div",{className:"flex h-9 items-center pl-3 pr-1.5",children:[(0,e.jsxs)(Es,{open:c,onOpenChange:u,children:[(0,e.jsx)(Ps,{asChild:!0,children:(0,e.jsxs)("button",{type:"button",className:"flex h-full items-center gap-2 rounded-l-lg pr-1 text-xs font-medium text-ink hover:bg-bg-3","aria-label":`${v} of ${s.length} services running — show services`,children:[(0,e.jsx)(Se,{entry:_}),(0,e.jsxs)("span",{className:"whitespace-nowrap",children:[v,"/",s.length," running"]}),(0,e.jsx)(Ts,{className:"size-3 text-ink-3"})]})}),(0,e.jsxs)(_s,{align:"end",className:"w-96 p-0",onOpenAutoFocus:r(f=>f.preventDefault(),"onOpenAutoFocus"),children:[(0,e.jsxs)("div",{className:"px-4 pb-1 pt-3 text-xs font-medium uppercase tracking-wide text-ink-3",children:["Services · ",s.length]}),(0,e.jsx)("div",{className:"divide-y divide-line px-4",children:s.map(f=>(0,e.jsx)(on,{entry:f,onAction:n},f.key))}),(0,e.jsxs)("div",{className:"flex items-center gap-1 border-t border-line px-4 py-2",children:[(0,e.jsx)(N,{variant:"ghost",size:"xs",onClick:r(()=>n("start",null),"onClick"),children:"Start all"}),(0,e.jsx)(N,{variant:"ghost",size:"xs",onClick:r(()=>n("stop",null),"onClick"),children:"Stop all"}),(0,e.jsx)(N,{variant:"ghost",size:"xs",onClick:r(()=>n("restart",null),"onClick"),children:"Restart all"}),a?(0,e.jsx)(N,{variant:"link",size:"xs",className:"ml-auto",onClick:a,children:"Manage in Services tab →"}):null]})]})]}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"hidden min-w-0 items-center gap-0.5 sm:flex",children:p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"mr-1 shrink-0 text-xs text-ink-3",children:p.name}),(0,e.jsx)(ce,{entry:p})]}):(0,e.jsx)("span",{className:"font-mono text-xs text-ink-3/70",children:"no url"})}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-1 pl-3 sm:pl-0",children:(0,e.jsx)(We,{entry:{state:_.state,canStart:!0},onAction:r(f=>n(f,null),"onAction")})})]}),p?(0,e.jsx)("div",{className:"flex h-8 items-center justify-between gap-0.5 border-t border-line px-3 sm:hidden",children:(0,e.jsx)(ce,{entry:p,compact:!0})}):null]})})}r(ln,"MultiServiceBar");function cn({services:s,onAction:n,onViewLogs:a,onManageServices:o,defaultServicesOpen:d,className:c}){return s.length===0?null:s.length===1?(0,e.jsx)(an,{entry:s[0],onAction:n,onViewLogs:a,className:c}):(0,e.jsx)(ln,{services:s,onAction:n,onManageServices:o,defaultServicesOpen:d,className:c})}r(cn,"WorkspaceServiceControlBar");var ze=new Set([fs]);function Ye(s){const n=new Set;for(const a of s.variables)ze.has(a.name)&&n.add(a.name);for(const a of gs([s.title,s.description]))ze.has(a)&&n.add(a);return[...n]}r(Ye,"getWorkspaceSpecificRoutineVariableNames");function dn(s){return Ye(s).length>0}r(dn,"routineHasWorkspaceSpecificVariables");function un(s){return[...s].sort((n,a)=>{const o=n.title.localeCompare(a.title,void 0,{sensitivity:"base"});return o!==0?o:n.id.localeCompare(a.id)})}r(un,"sortWorkspaceRoutinesByName");var mn=100,pn=[{value:"issues",label:"Tasks",order:10},{value:"services",label:"Services",order:20},{value:"configuration",label:"Configuration",order:30},{value:"runtime_logs",label:"Runtime logs",order:40},{value:"routines",label:"Routines",order:60}];function J(s){return typeof s=="string"&&s.startsWith("plugin:")}r(J,"isExecutionWorkspacePluginTab");function xn(s){return s.map((n,a)=>({item:n,index:a})).sort((n,a)=>n.item.order-a.item.order||n.index-a.index).map(({item:n})=>n)}r(xn,"orderExecutionWorkspaceTabItems");function hn(s,n){const a=s.split("/").filter(Boolean),o=a.indexOf("execution-workspaces");if(o===-1||a[o+1]!==n)return null;const d=a[o+2];return d==="services"?"services":d==="issues"?"issues":d==="routines"?"routines":d==="runtime-logs"?"runtime_logs":d==="configuration"?"configuration":null}r(hn,"resolveExecutionWorkspaceTab");function ie(s,n){return`/execution-workspaces/${s}/${n==="runtime_logs"?"runtime-logs":n}`}r(ie,"executionWorkspaceTabPath");function be({workspaceId:s}){return(0,h.useEffect)(()=>{try{localStorage.removeItem(`wardmote:execution-workspace-tab:${s}`)}catch{}},[s]),(0,e.jsx)(Ss,{to:ie(s,"issues"),replace:!0})}r(be,"LegacyWorkspaceTabRedirect");function fn(s){if(!s)return!1;try{const n=new URL(s);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}r(fn,"isSafeExternalUrl");function T(s){return s??""}r(T,"readText");function Ne(s){return!s||Object.keys(s).length===0?"":JSON.stringify(s,null,2)}r(Ne,"formatJson");function gn(s){return s?L(s):"Never"}r(gn,"formatOptionalDateTime");function oe(s){const n=s.trim();return n.length>0?n:null}r(oe,"normalizeText");function de(s){const n=s.trim();if(!n)return{ok:!0,value:null};try{const a=JSON.parse(n);return!a||typeof a!="object"||Array.isArray(a)?{ok:!1,error:"Workspace commands JSON must be a JSON object."}:{ok:!0,value:a}}catch(a){return{ok:!1,error:a instanceof Error?a.message:"Invalid JSON."}}}r(de,"parseWorkspaceRuntimeJson");function es(s){if(!s)return[];const n=[],a=r((o,d,c)=>{Array.isArray(d)&&d.forEach((u,v)=>{if(!u||typeof u!="object"||Array.isArray(u))return;const k=u;if(c&&k.kind!=="service")return;const y=k.port,m=!!(y&&typeof y=="object"&&!Array.isArray(y)&&Object.hasOwn(y,"value")),p=typeof y=="number"?y:m?y.value:null;n.push({collection:o,index:v,name:typeof k.name=="string"&&k.name.trim()?k.name:`Service ${v+1}`,port:typeof p=="number"?p:null,invalidPort:(typeof y=="number"||m)&&(typeof p!="number"||!Number.isInteger(p)||p<1||p>65535)})})},"addServices");return a("commands",s.commands,!0),a("services",s.services,!1),n}r(es,"readConfiguredRuntimeServicePorts");function jn(s){const n=structuredClone(s.runtimeConfig),a=n[s.service.collection];if(!Array.isArray(a))return n;const o=a[s.service.index];if(!o||typeof o!="object"||Array.isArray(o))return n;const d=o,c=d.port&&typeof d.port=="object"&&!Array.isArray(d.port)?d.port:null,u=s.port.trim();if(!u){if(c){const k={...c,type:"auto"};delete k.value,d.port=k}else delete d.port;return n}const v=Number(u);return!Number.isInteger(v)||v<1||v>65535||(d.port={...c,type:"fixed",value:v}),n}r(jn,"updateConfiguredRuntimeServicePort");function vn(s){const n=new Map;for(const a of s){if(a.invalidPort||!a.port)continue;const o=n.get(a.port)??[];o.push(a),n.set(a.port,o)}return Array.from(n.entries()).filter(([,a])=>a.length>1).map(([a,o])=>`Port ${a} is assigned to multiple services: ${o.map(d=>d.name).join(", ")}.`)}r(vn,"getConfiguredRuntimeServicePortWarnings");function Qe(s){return{name:s.name,cwd:T(s.cwd),repoUrl:T(s.repoUrl),baseRef:T(s.baseRef),branchName:T(s.branchName),providerRef:T(s.providerRef),provisionCommand:T(s.config?.provisionCommand),runtimeProvisionCommand:T(s.config?.runtimeProvisionCommand),teardownCommand:T(s.config?.teardownCommand),cleanupCommand:T(s.config?.cleanupCommand),inheritRuntime:!s.config?.workspaceRuntime,workspaceRuntime:Ne(s.config?.workspaceRuntime)}}r(Qe,"formStateFromWorkspace");function bn(s,n){const a={},o={},d=r(u=>{s[u]!==n[u]&&(a[u]=u==="name"?oe(n[u])??s.name:oe(n[u]))},"maybeAssign");d("name"),d("cwd"),d("repoUrl"),d("baseRef"),d("branchName"),d("providerRef");const c=r(u=>{s[u]!==n[u]&&(o[u]=oe(n[u]))},"maybeAssignConfigText");if(c("provisionCommand"),c("runtimeProvisionCommand"),c("teardownCommand"),c("cleanupCommand"),s.inheritRuntime!==n.inheritRuntime||s.workspaceRuntime!==n.workspaceRuntime){const u=de(n.workspaceRuntime);if(!u.ok)throw new Error(u.error);o.workspaceRuntime=n.inheritRuntime?null:u.value}return Object.keys(o).length>0&&(a.config=o),a}r(bn,"buildWorkspacePatch");function kn(s){const n=oe(s.repoUrl);if(n)try{new URL(n)}catch{return"Repo URL must be a valid URL."}if(!s.inheritRuntime){const a=de(s.workspaceRuntime);if(!a.ok)return a.error;const o=es(a.value).find(d=>d.invalidPort);if(o)return`${o.name} has an invalid fixed port.`}return null}r(kn,"validateForm");function I({label:s,hint:n,children:a}){return(0,e.jsxs)("label",{className:"block space-y-2",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:s}),n?(0,e.jsx)("span",{className:"text-xs text-ink-3 sm:text-right",children:n}):null]}),a]})}r(I,"Field");function yn(s){switch(s){case"worktree_prepare":return"Worktree setup";case"workspace_config_freshness":return"Config freshness";case"workspace_provision":return"Provision";case"workspace_seed":return"Database seed";case"workspace_runtime_provision":return"Runtime provision";case"workspace_teardown":return"Teardown";case"worktree_cleanup":return"Worktree cleanup";case"workspace_finalize":return"Finalize";default:return s}}r(yn,"workspaceOperationPhaseLabel");function wn(s){const n=(s.operations??[]).find(a=>a.phase==="workspace_seed"||a.phase==="workspace_runtime_provision")??null;if(n){const a=n.finishedAt??n.startedAt??null;if(n.status==="running")return{kind:"provisioning",at:a};if(n.status==="succeeded")return{kind:"provisioned",at:a};if(n.status==="failed")return{kind:"failed",at:a}}return s.runtimeProvisionCommand&&s.runtimeProvisionCommand.trim()?{kind:"deferred"}:{kind:"eager"}}r(wn,"resolveRuntimeProvisionStatus");function C({label:s,children:n}){return(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 py-1.5 sm:flex-row sm:items-start sm:gap-3",children:[(0,e.jsx)("div",{className:"shrink-0 text-xs text-ink-3 sm:w-32",children:s}),(0,e.jsx)("div",{className:"min-w-0 flex-1 text-sm",children:n})]})}r(C,"DetailRow");function Z({children:s,className:n}){return(0,e.jsx)("div",{className:S("inline-flex items-center rounded-full border border-line bg-bg px-2.5 py-1 text-xs text-ink-3",n),children:s})}r(Z,"StatusPill");function Nn({status:s,onViewLogs:n}){return s.kind==="eager"?(0,e.jsx)("span",{className:"text-sm text-ink-3",children:"Eager · provisioned during workspace setup"}):s.kind==="deferred"?(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(Z,{className:"border-amber-500/40 text-amber-600 dark:text-amber-400",children:"Deferred"}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Runs once before the first runtime-service start."})]}):s.kind==="provisioning"?(0,e.jsxs)(Z,{className:"border-line text-ink-3",children:[(0,e.jsx)(ue,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Provisioning…"]}):s.kind==="provisioned"?(0,e.jsxs)(Z,{className:"border-emerald-500/40 text-emerald-600 dark:text-emerald-400",children:["Provisioned",s.at?` · ${L(s.at)}`:""]}):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxs)(Z,{className:"border-bad/50 text-bad",children:["Provisioning failed",s.at?` · ${L(s.at)}`:""]}),(0,e.jsx)("button",{type:"button",onClick:n,className:"self-start text-xs text-ink-3 underline underline-offset-2 hover:text-ink",children:"View runtime logs"})]})}r(Nn,"RuntimeProvisionStatusValue");function W({value:s,copy:n}){return(0,e.jsxs)("div",{className:"inline-flex max-w-full items-start gap-2",children:[(0,e.jsx)("span",{className:"break-all font-mono text-xs",children:s}),n?(0,e.jsx)(He,{text:s,className:"shrink-0 text-ink-3 hover:text-ink",copiedLabel:"Copied",children:(0,e.jsx)(Ce,{className:"h-3.5 w-3.5"})}):null]})}r(W,"MonoValue");function Rn({project:s,workspace:n}){return(0,e.jsx)(Y,{to:hs(s,n.id),className:"hover:underline",children:n.name})}r(Rn,"WorkspaceLink");function Cn({companyId:s,workspace:n,issues:a,isLoading:o,error:d,project:c}){const u=Re(),{data:v}=P({queryKey:x.agents.list(s),queryFn:r(()=>Je.list(s),"queryFn"),enabled:!!s}),k=x.liveRuns(s),y=Os({companyId:s,resourceKey:"live-runs",queryKey:k,enabled:!!s,refetchInterval:!1,leaderOnly:!0}),{data:m,dataUpdatedAt:p}=P({queryKey:k,queryFn:r(()=>Js.liveRunsForCompany(s),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});Us(y,m,p);const _=(0,h.useMemo)(()=>Vs(m,a),[a,m]),f=le({mutationFn:r(({id:q,data:F})=>ke.update(q,F),"mutationFn"),onSuccess:r(()=>{u.invalidateQueries({queryKey:x.issues.listByExecutionWorkspace(s,n.id)}),u.invalidateQueries({queryKey:x.issues.list(s)}),c?.id&&u.invalidateQueries({queryKey:x.issues.listByProject(s,c.id)})},"onSuccess")}),b=(0,h.useMemo)(()=>c?[{id:c.id,name:c.name,workspaces:c.workspaces??[]}]:void 0,[c]),g=(0,h.useMemo)(()=>({projectId:n.projectId,...n.projectWorkspaceId?{projectWorkspaceId:n.projectWorkspaceId}:{},executionWorkspaceId:n.id,executionWorkspaceMode:"reuse_existing"}),[n.id,n.projectId,n.projectWorkspaceId]);return(0,e.jsx)(Gs,{issues:a,isLoading:o,error:d,agents:v,projects:b,liveIssueIds:_,projectId:c?.id,viewStateKey:"wardmote:execution-workspace-issues-view",baseCreateIssueDefaults:g,onUpdateIssue:r((q,F)=>f.mutate({id:q,data:F}),"onUpdateIssue")})}r(Cn,"ExecutionWorkspaceIssuesList");function In({routine:s,variableNames:n,runningRoutineId:a,onRunNow:o}){const d=s.status==="archived",c=a===s.id;return(0,e.jsxs)("div",{className:"flex flex-col gap-3 border-b border-line px-3 py-3 last:border-b-0 sm:flex-row sm:items-center",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Y,{to:`/routines/${s.id}`,className:"truncate text-sm font-medium hover:underline",children:s.title}),s.status!=="active"?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:s.status}):null]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-ink-3",children:[(0,e.jsx)("span",{children:s.assigneeAgentId?"Default agent set":"Choose agent when running"}),(0,e.jsxs)("span",{children:["Last run ",gn(s.lastRun?.triggeredAt??s.lastTriggeredAt)]}),(0,e.jsx)("span",{className:"flex flex-wrap gap-1",children:n.map(u=>(0,e.jsx)("span",{className:"rounded-sm bg-bg-3 px-1.5 py-0.5 font-mono text-(length:--text-micro) text-ink-3",children:u},u))})]})]}),(0,e.jsxs)(N,{variant:"secondary",size:"sm",className:"w-full sm:w-auto",disabled:d||c,onClick:r(()=>o(s),"onClick"),children:[c?(0,e.jsx)(ue,{className:"mr-2 h-4 w-4 animate-spin"}):(0,e.jsx)(we,{className:"mr-2 h-4 w-4"}),c?"Running...":"Run now"]})]})}r(In,"WorkspaceRoutineRow");function Sn({workspace:s,project:n}){const a=Re(),{pushToast:o}=qs(),[d,c]=(0,h.useState)(null),[u,v]=(0,h.useState)(null),{data:k,isLoading:y,error:m}=P({queryKey:x.routines.list(s.companyId,{projectId:s.projectId}),queryFn:r(()=>Me.list(s.companyId,{projectId:s.projectId}),"queryFn")}),{data:p}=P({queryKey:x.agents.list(s.companyId),queryFn:r(()=>Je.list(s.companyId),"queryFn")}),_=(0,h.useMemo)(()=>un((k??[]).filter(dn)),[k]),f=le({mutationFn:r(({id:b,data:g})=>Me.run(b,{...g?.variables&&Object.keys(g.variables).length>0?{variables:g.variables}:{},...g?.assigneeAgentId!==void 0?{assigneeAgentId:g.assigneeAgentId}:{},...g?.projectId!==void 0?{projectId:g.projectId}:{},...g?.executionWorkspaceId!==void 0?{executionWorkspaceId:g.executionWorkspaceId}:{},...g?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:g.executionWorkspacePreference}:{},...g?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:g.executionWorkspaceSettings}:{}}),"mutationFn"),onMutate:r(({id:b})=>{v(b)},"onMutate"),onSuccess:r(async(b,{id:g})=>{c(null),await Promise.all([a.invalidateQueries({queryKey:["routines",s.companyId]}),a.invalidateQueries({queryKey:x.routines.detail(g)}),a.invalidateQueries({queryKey:x.issues.listByExecutionWorkspace(s.companyId,s.id)}),a.invalidateQueries({queryKey:x.issues.list(s.companyId)})]),o({title:"Routine started",body:"Wardmote created a run using this execution workspace.",tone:"success"})},"onSuccess"),onSettled:r(()=>{v(null)},"onSettled"),onError:r(b=>{o({title:"Routine run failed",body:b instanceof Error?b.message:"Wardmote could not start the routine run.",tone:"error"})},"onError")});return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(K,{className:"rounded-none",children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(X,{children:"Workspace routines"}),(0,e.jsx)(H,{children:"Routines that use workspace-specific variables can be run against this execution workspace."})]}),(0,e.jsx)(B,{children:y?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading routines..."}):m?(0,e.jsx)("p",{className:"text-sm text-bad",children:m instanceof Error?m.message:"Failed to load routines."}):_.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 py-10 text-center",children:[(0,e.jsx)(Fs,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"No routines use workspace-specific variables yet."})]}):(0,e.jsx)("div",{className:"rounded-lg border border-line",children:_.map(b=>(0,e.jsx)(In,{routine:b,variableNames:Ye(b),runningRoutineId:u,onRunNow:c},b.id))})})]}),(0,e.jsx)(nn,{open:d!==null,onOpenChange:r(b=>{b||c(null)},"onOpenChange"),companyId:s.companyId,routineName:d?.title??null,agents:p??[],projects:n?[n]:[],defaultProjectId:s.projectId,defaultAssigneeAgentId:d?.assigneeAgentId??null,defaultExecutionWorkspace:s,variables:d?.variables??[],isPending:f.isPending,onSubmit:r(b=>{d&&f.mutate({id:d.id,data:b})},"onSubmit")})]})}r(Sn,"ExecutionWorkspaceRoutinesList");function pt(){const{visible:s,loaded:n}=Hs(),{workspaceId:a}=ks(),o=bs(),d=Is(),c=Re(),{setBreadcrumbs:u}=zs(),{selectedCompanyId:v,setSelectedCompanyId:k}=Cs(),{hideHostPaths:y}=Zs(),[m,p]=(0,h.useState)(null),[_,f]=(0,h.useState)(!1),[b,g]=(0,h.useState)(null),[q,F]=(0,h.useState)(null),[Pe,me]=(0,h.useState)(null),[ss,pe]=(0,h.useState)([]),ns=a?hn(o.pathname,a):null,ts=(0,h.useMemo)(()=>{const t=new URLSearchParams(o.search).get("tab");return J(t)?t:null},[o.search]),R=ns??ts,D=P({queryKey:x.executionWorkspaces.detail(a),queryFn:r(()=>V.get(a),"queryFn"),enabled:!!a}),i=D.data??null,j=P({queryKey:i?[...x.projects.detail(i.projectId),i.companyId]:["projects","detail","__pending__"],queryFn:r(()=>Bs.get(i.projectId,i.companyId),"queryFn"),enabled:!!i?.projectId}).data??null,E=P({queryKey:i?.sourceIssueId?x.issues.detail(i.sourceIssueId):["issues","detail","__none__"],queryFn:r(()=>ke.get(i.sourceIssueId),"queryFn"),enabled:!!i?.sourceIssueId}).data??null,xe=P({queryKey:i?.derivedFromExecutionWorkspaceId?x.executionWorkspaces.detail(i.derivedFromExecutionWorkspaceId):["execution-workspaces","detail","__none__"],queryFn:r(()=>V.get(i.derivedFromExecutionWorkspaceId),"queryFn"),enabled:!!i?.derivedFromExecutionWorkspaceId}).data??null,he=P({queryKey:i?x.issues.listByExecutionWorkspace(i.companyId,i.id):["issues","__execution-workspace__","__none__"],queryFn:r(()=>ke.list(i.companyId,{executionWorkspaceId:i.id}),"queryFn"),enabled:!!i?.companyId}),rs=he.data??[],ee=(0,h.useMemo)(()=>j?.workspaces.find(t=>t.id===i?.projectWorkspaceId)??null,[j,i?.projectWorkspaceId]),{slots:_e,isLoading:as,errorMessage:Ee}=Ds({slotTypes:["detailTab"],entityType:"execution_workspace",companyId:i?.companyId??null,enabled:!!i?.companyId}),fe=(0,h.useMemo)(()=>_e.map(t=>({value:`plugin:${t.pluginKey}:${t.id}`,label:t.displayName,order:t.order??mn,slot:t})),[_e]),is=(0,h.useMemo)(()=>xn([...pn.filter(t=>t.value!=="configuration"||s),...fe]),[fe,s]),O=ee?.runtimeConfig?.workspaceRuntime??null,ge=i?.config?.workspaceRuntime??O,Ae=i?.config?.workspaceRuntime?"execution_workspace":O?"project_workspace":"none",Te=(0,h.useMemo)(()=>{if(!m||m.inheritRuntime)return O;const t=de(m.workspaceRuntime);return t.ok?t.value:null},[m,O]),se=(0,h.useMemo)(()=>es(Te),[Te]),Fe=(0,h.useMemo)(()=>vn(se),[se]),M=(0,h.useMemo)(()=>i?Qe(i):null,[i]),je=!!(m&&M&&JSON.stringify(m)!==JSON.stringify(M)),ne=j?ps(j):i?.projectId??"";(0,h.useEffect)(()=>{!i?.companyId||i.companyId===v||k(i.companyId,{source:"route_sync"})},[i?.companyId,v,k]),(0,h.useEffect)(()=>{i&&(p(Qe(i)),g(null),F(null),pe([]))},[i]),(0,h.useEffect)(()=>{if(!i)return;const t=[{label:"Projects",href:"/projects"},...j?[{label:j.name,href:`/projects/${ne}`}]:[],...j?[{label:"Workspaces",href:`/projects/${ne}/workspaces`}]:[],{label:i.name}];u(t)},[u,i,j,ne]);const te=le({mutationFn:r(t=>V.update(i.id,t),"mutationFn"),onSuccess:r(t=>{c.setQueryData(x.executionWorkspaces.detail(t.id),t),c.invalidateQueries({queryKey:x.executionWorkspaces.closeReadiness(t.id)}),c.invalidateQueries({queryKey:x.executionWorkspaces.workspaceOperations(t.id)}),j&&(c.invalidateQueries({queryKey:x.projects.detail(j.id)}),c.invalidateQueries({queryKey:x.projects.detail(j.urlKey)})),E&&c.invalidateQueries({queryKey:x.issues.detail(E.id)}),g(null)},"onSuccess"),onError:r(t=>{g(t instanceof Error?t.message:"Failed to save execution workspace.")},"onError")}),A=P({queryKey:x.executionWorkspaces.workspaceOperations(a),queryFn:r(()=>V.listWorkspaceOperations(a),"queryFn"),enabled:!!a}),Le=i?.config?.runtimeProvisionCommand??j?.executionWorkspacePolicy?.workspaceStrategy?.runtimeProvisionCommand??null,os=(0,h.useMemo)(()=>wn({runtimeProvisionCommand:Le,operations:A.data}),[Le,A.data]),re=le({mutationFn:r(t=>V.controlRuntimeCommands(i.id,t.action,t),"mutationFn"),onSuccess:r((t,l)=>{c.setQueryData(x.executionWorkspaces.detail(t.workspace.id),t.workspace),c.invalidateQueries({queryKey:x.executionWorkspaces.overview(t.workspace.companyId)}),c.invalidateQueries({queryKey:x.executionWorkspaces.workspaceOperations(t.workspace.id)}),c.invalidateQueries({queryKey:x.projects.detail(t.workspace.projectId)}),F(null),me(l.action==="run"?"Workspace job completed.":l.action==="stop"?"Workspace service stopped.":l.action==="restart"?"Workspace service restarted.":"Workspace service started.")},"onSuccess"),onError:r(t=>{me(null),F(t instanceof Error?t.message:"Failed to control workspace commands.")},"onError"),onSettled:r((t,l,w)=>{pe(Q=>Q.filter(us=>us!==w))},"onSettled")});if(D.isLoading)return(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading workspace…"});if(D.error)return(0,e.jsx)("p",{className:"text-sm text-bad",children:D.error instanceof Error?D.error.message:"Failed to load workspace"});if(!i||!m||!M)return null;const qe=!!i.cwd,Oe=!!ge&&qe,ve=Ns({runtimeConfig:ge,runtimeServices:i.runtimeServices??[],canStartServices:Oe,canRunJobs:qe}),ls=re.isPending?re.variables??null:null,cs=ws({sections:ve,runtimeServices:i.runtimeServices??[],pendingRequests:ss}),Ue={companyId:i.companyId,projectId:i.projectId,entityId:i.id,entityType:"execution_workspace"},Be=fe.find(t=>t.value===R)??null;if(R==="configuration"&&!n)return null;if(a&&R==="configuration"&&!s)return(0,e.jsx)(be,{workspaceId:a});if(a&&R===null)return(0,e.jsx)(be,{workspaceId:a});const z=r(t=>{if(J(t)){d(`/execution-workspaces/${i.id}?tab=${encodeURIComponent(t)}`);return}d(ie(i.id,t))},"handleTabChange"),ds=r(()=>{const t=kn(m);if(t){g(t);return}let l;try{l=bn(M,m)}catch(w){g(w instanceof Error?w.message:"Failed to build workspace update.");return}Object.keys(l).length!==0&&te.mutate(l)},"saveChanges"),Ke=r(t=>{if(t.length!==0){pe(l=>[...l,...t]);for(const l of t)re.mutate(l)}},"runRuntimeControlRequests");return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-4 overflow-hidden sm:space-y-6",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-(--tracking-eyebrow) text-ink-3",children:"Execution workspace"}),(0,e.jsx)("h1",{className:"truncate text-xl font-semibold sm:text-2xl",children:i.name})]}),(0,e.jsx)(cn,{services:cs,onAction:r((t,l)=>{Ke(ys(ve,t,l))},"onAction"),onViewLogs:r(()=>z("runtime_logs"),"onViewLogs"),onManageServices:r(()=>z("services"),"onManageServices")})]}),q?(0,e.jsx)("p",{className:"text-sm text-bad",children:q}):null,!q&&Pe?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:Pe}):null,(0,e.jsx)(Ks,{slotTypes:["toolbarButton","contextMenuItem"],entityType:"execution_workspace",context:Ue,className:"flex flex-wrap gap-2",itemClassName:"inline-flex",missingBehavior:"placeholder"}),(0,e.jsx)(Ws,{value:R??"issues",onValueChange:r(t=>z(t),"onValueChange"),children:(0,e.jsx)(Xs,{items:is.map(t=>({value:t.value,label:t.label})),align:"start",value:R??"issues",onValueChange:r(t=>z(t),"onValueChange")})}),R==="services"?(0,e.jsx)(Rs,{sections:ve,isPending:re.isPending,pendingRequest:ls,serviceEmptyMessage:ge?"No services have been started for this execution workspace yet.":"No workspace command config is defined for this execution workspace yet.",jobEmptyMessage:"No one-shot jobs are configured for this execution workspace yet.",disabledHint:Oe?null:"Execution workspaces need a working directory before local commands can run, and services also need runtime config.",onAction:r(t=>Ke([t]),"onAction")}):R==="configuration"?(0,e.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,e.jsxs)(K,{className:"rounded-none",children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(X,{children:"Workspace settings"}),(0,e.jsx)(H,{children:"Edit the concrete path, repo, branch, provisioning, teardown, and runtime overrides attached to this execution workspace. Saved changes affect future runs; Wardmote may refresh or replace a reused workspace when config changes."}),(0,e.jsx)($s,{children:(0,e.jsx)(N,{variant:"danger",size:"sm",className:"w-full sm:w-auto",onClick:r(()=>f(!0),"onClick"),disabled:i.status==="archived",children:i.status==="cleanup_failed"?"Retry close":"Close workspace"})})]}),(0,e.jsxs)(B,{children:[(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"General"}),(0,e.jsx)(I,{label:"Workspace name",children:(0,e.jsx)(U,{value:m.name,onChange:r(t=>p(l=>l&&{...l,name:t.target.value}),"onChange"),placeholder:"Execution workspace name"})})]}),(0,e.jsx)(ae,{}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Source control"}),(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,e.jsx)(I,{label:"Branch name",hint:"Useful for isolated worktrees",children:(0,e.jsx)(U,{className:"font-mono",value:m.branchName,onChange:r(t=>p(l=>l&&{...l,branchName:t.target.value}),"onChange"),placeholder:"PAP-946-workspace"})}),(0,e.jsx)(I,{label:"Base ref",children:(0,e.jsx)(U,{className:"font-mono",value:m.baseRef,onChange:r(t=>p(l=>l&&{...l,baseRef:t.target.value}),"onChange"),placeholder:"origin/main"})})]}),(0,e.jsx)(I,{label:"Repo URL",children:(0,e.jsx)(U,{value:m.repoUrl,onChange:r(t=>p(l=>l&&{...l,repoUrl:t.target.value}),"onChange"),placeholder:"https://github.com/org/repo"})})]}),(0,e.jsx)(ae,{}),!y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Paths"}),(0,e.jsx)(I,{label:"Working directory",children:(0,e.jsx)(U,{className:"font-mono",value:m.cwd,onChange:r(t=>p(l=>l&&{...l,cwd:t.target.value}),"onChange"),placeholder:"/absolute/path/to/workspace"})}),(0,e.jsx)(I,{label:"Provider path / ref",children:(0,e.jsx)(U,{className:"font-mono",value:m.providerRef,onChange:r(t=>p(l=>l&&{...l,providerRef:t.target.value}),"onChange"),placeholder:"/path/to/worktree or provider ref"})})]}),(0,e.jsx)(ae,{})]}),!y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Lifecycle commands"}),(0,e.jsx)(I,{label:"Provision command",hint:"Runs when Wardmote prepares this execution workspace",children:(0,e.jsx)($,{className:"min-h-20 font-mono",value:m.provisionCommand,onChange:r(t=>p(l=>l&&{...l,provisionCommand:t.target.value}),"onChange"),placeholder:"bash ./scripts/provision-worktree.sh"})}),(0,e.jsx)(I,{label:"Runtime provision command",hint:"Runs once before the first runtime-service start. Leave empty to keep eager provisioning.",children:(0,e.jsx)($,{className:"min-h-20 font-mono",value:m.runtimeProvisionCommand,onChange:r(t=>p(l=>l&&{...l,runtimeProvisionCommand:t.target.value}),"onChange"),placeholder:"bash ./scripts/provision-worktree-runtime.sh"})}),(0,e.jsx)(I,{label:"Teardown command",hint:"Runs when the execution workspace is archived or cleaned up",children:(0,e.jsx)($,{className:"min-h-20 font-mono",value:m.teardownCommand,onChange:r(t=>p(l=>l&&{...l,teardownCommand:t.target.value}),"onChange"),placeholder:"bash ./scripts/teardown-worktree.sh"})}),(0,e.jsx)(I,{label:"Cleanup command",hint:"Workspace-specific cleanup before teardown",children:(0,e.jsx)($,{className:"min-h-16 font-mono",value:m.cleanupCommand,onChange:r(t=>p(l=>l&&{...l,cleanupCommand:t.target.value}),"onChange"),placeholder:"pkill -f vite || true"})})]}),(0,e.jsx)(ae,{})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Runtime config"}),(0,e.jsx)("div",{className:"rounded-md border border-dashed border-line/70 bg-bg px-4 py-3",children:(0,e.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Runtime config source"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:Ae==="execution_workspace"?"This execution workspace currently overrides the project workspace runtime config.":Ae==="project_workspace"?"This execution workspace is inheriting the project workspace runtime config.":"No runtime config is currently defined on this execution workspace or its project workspace."})]}),(0,e.jsx)(N,{variant:"secondary",className:"w-full sm:w-auto",size:"sm",disabled:!ee?.runtimeConfig?.workspaceRuntime,onClick:r(()=>p(t=>t&&{...t,inheritRuntime:!0,workspaceRuntime:""}),"onClick"),children:"Reset to inherit"})]})}),(0,e.jsxs)("details",{className:"rounded-md border border-dashed border-line/70 bg-bg px-4 py-3",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Advanced runtime JSON"}),(0,e.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Override the inherited workspace command model only when this execution workspace truly needs different service or job behavior."}),(0,e.jsx)("div",{className:"mt-3",children:(0,e.jsxs)(I,{label:"Workspace commands JSON",hint:"Legacy `services` arrays still work, but `commands` supports both services and jobs.",children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-sm text-ink-3",children:[(0,e.jsx)("input",{id:"inherit-runtime-config",type:"checkbox",className:"rounded border-line",checked:m.inheritRuntime,onChange:r(t=>{const l=t.target.checked;p(w=>w&&(!l&&!w.workspaceRuntime.trim()&&O?{...w,inheritRuntime:l,workspaceRuntime:Ne(O)}:{...w,inheritRuntime:l}))},"onChange")}),(0,e.jsx)("label",{htmlFor:"inherit-runtime-config",children:"Inherit project workspace runtime config"})]}),(0,e.jsx)($,{className:"min-h-64 font-mono sm:min-h-96",value:m.workspaceRuntime,onChange:r(t=>p(l=>l&&{...l,workspaceRuntime:t.target.value}),"onChange"),disabled:m.inheritRuntime,placeholder:`{
|
|
1
|
+
var ms=Object.defineProperty;var r=(s,n)=>ms(s,"name",{value:n,configurable:!0});import{i as $e}from"./rolldown-runtime-ZpX3ckPj.js";import{C as ps,S as xs,T as hs,Zi as fs,Zn as gs,h as L,l as S,la as js,ua as vs}from"./createLucideIcon-CgrPXnTY.js";import{h as bs,v as ks}from"./star-eem0qj3E.js";import{X as Re,_ as le,t as x,v as P}from"./queryKeys-BzT8CD34.js";import{a as ys,i as ws,r as Ns,t as Rs}from"./WorkspaceRuntimeControls-Clk2nzU6.js";import{n as Cs}from"./CompanyContext-fQCNWI_f.js";import{o as Is,r as Ss,t as Y,zt as ke}from"./router-CJbFZfVR.js";import{t as Ws}from"./tabs-CjHzZxtD.js";import{o as Ps,r as _s,t as Es}from"./popover-CWlBonqy.js";import{t as As}from"./check-Bis3vECb.js";import{t as Ts}from"./chevron-down-nRcQ7bok.js";import{t as Ce}from"./copy-C1cfcpxY.js";import{t as ye}from"./external-link-BIcMNNSN.js";import{r as ue,t as N}from"./button-DI4w5WP7.js";import{t as we}from"./play-Czm7OCYh.js";import{t as Fs}from"./repeat-DzPORJjX.js";import{t as De}from"./rotate-ccw-DpzLJhXT.js";import{t as Ls}from"./square-CDo6rOf8.js";import{t as Ve}from"./triangle-alert-CnHMpmva.js";import{a as qs}from"./ToastContext-DyVJ6bCh.js";import{t as Je}from"./agents-B8n-p0aX.js";import{n as Os,t as Us}from"./useSharedPolling-CFeiZe2t.js";import{t as Bs}from"./projects-l3kQxnTp.js";import{t as U}from"./input-BBNGmECW.js";import{n as Ks,o as Ds,t as Ms}from"./slots-B7lwlN1w.js";import{t as Me}from"./routines-DteAuK7S.js";import{n as zs}from"./BreadcrumbContext-DNbB7zWn.js";import{t as $}from"./textarea-CTx68BDs.js";import{t as Qs}from"./clipboard-CTLKYvRL.js";import{i as H,n as $s,o as G,r as B,s as X,t as K}from"./card-BVZvs7aX.js";import{W as Vs,_a as Js,fr as V,pr as Hs,r as Gs,ri as Xs}from"./index-QhteFtm-.js";import{t as ae}from"./separator-6cvFqhvW.js";import{t as Zs}from"./useManagedSandboxOnly-KE5BJrr7.js";import{t as He}from"./CopyText-BbOm2I6t.js";import{n as Ys,t as en}from"./SummarySlotCard-D1EyiciB.js";import{t as sn}from"./MissingPluginTabPlaceholder-D3N0rd-p.js";import{t as nn}from"./RoutineRunVariablesDialog-kGyQVBid.js";var h=$e(vs(),1),e=$e(js(),1),tn=["provisioning","starting","stopping","restarting"];function Ie(s){return tn.includes(s)}r(Ie,"isTransitional");function Ge(s){return s?s.replace(/^https?:\/\//,"").replace(/\/$/,""):null}r(Ge,"formatServiceUrl");function Xe(s){switch(s.state){case"provisioning":return{label:"Provisioning…",unhealthy:!1};case"starting":return{label:"Starting…",unhealthy:!1};case"stopping":return{label:"Stopping…",unhealthy:!1};case"restarting":return{label:"Restarting…",unhealthy:!1};case"failed":return{label:"Failed",unhealthy:!1};case"running":return s.healthStatus==="unhealthy"?{label:"Unhealthy",unhealthy:!0}:{label:"Running",unhealthy:!1};default:return{label:"Stopped",unhealthy:!1}}}r(Xe,"statusMeta");function Se({entry:s,className:n}){if(Ie(s.state))return(0,e.jsx)(ue,{className:S("size-3 shrink-0 animate-spin text-ink-3",n)});if(s.state==="failed")return(0,e.jsx)(Ve,{className:S("size-3 shrink-0 text-bad",n)});const a=s.state==="running"&&s.healthStatus==="unhealthy";return(0,e.jsx)("span",{className:S("size-2 shrink-0 rounded-full",s.state==="running"?a?"bg-amber-500 ring-2 ring-amber-500/30":"bg-emerald-500":"border border-ink-3/60 bg-transparent",n)})}r(Se,"StatusIndicator");function Ze({url:s,disabled:n}){const[a,o]=(0,h.useState)("idle"),d=(0,h.useRef)(null);(0,h.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);const c=a==="copied"?"URL copied":a==="failed"?"Copy failed":"Copy URL";return(0,e.jsxs)(N,{variant:"ghost",size:"icon-xs",disabled:n,"aria-label":c,title:c,onClick:r(async()=>{try{await Qs(s),o("copied")}catch{o("failed")}d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o("idle"),1500)},"onClick"),children:[a==="copied"?(0,e.jsx)(As,{className:"size-3"}):a==="failed"?(0,e.jsx)(Ve,{className:"size-3 text-bad"}):(0,e.jsx)(Ce,{className:"size-3"}),(0,e.jsx)("span",{className:"sr-only","aria-live":"polite",children:c})]})}r(Ze,"CopyUrlButton");function ce({entry:s,compact:n}){const a=Ge(s.url)??(s.port?`:${s.port}`:null),o=s.state==="running"&&!!s.url;return a?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)("a",{href:s.url??void 0,target:"_blank",rel:"noreferrer",title:s.url??void 0,className:S("min-w-0 truncate font-mono text-xs text-ink hover:underline",n?"max-w-44":"max-w-56"),children:a}):(0,e.jsx)("span",{title:s.url??void 0,className:S("min-w-0 truncate font-mono text-xs text-ink-3/70",n?"max-w-44":"max-w-56"),children:a}),(0,e.jsxs)("span",{className:S("flex items-center",o?null:"invisible"),"aria-hidden":o?void 0:!0,children:[(0,e.jsx)(Ze,{url:s.url??"",disabled:!o}),(0,e.jsx)(N,{asChild:o,variant:"ghost",size:"icon-xs",disabled:!o,title:"Open in new tab",children:o?(0,e.jsx)("a",{href:s.url??void 0,target:"_blank",rel:"noreferrer","aria-label":"Open in new tab",children:(0,e.jsx)(ye,{className:"size-3"})}):(0,e.jsx)(ye,{className:"size-3"})})]})]}):(0,e.jsx)("span",{className:"font-mono text-xs text-ink-3/70",children:"no url"})}r(ce,"UrlSegment");function We({entry:s,onAction:n}){const a=Ie(s.state),o=s.canStart??!0;return s.state==="stopped"?(0,e.jsxs)(N,{variant:"primary",size:"xs",className:"w-13 justify-center",disabled:!o,onClick:r(()=>n("start"),"onClick"),"aria-label":"Start",title:"Start",children:[(0,e.jsx)(we,{className:"size-3"}),"Start"]}):s.state==="failed"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(N,{variant:"primary",size:"icon-xs",disabled:!o,onClick:r(()=>n("start"),"onClick"),"aria-label":"Start",title:"Start",children:(0,e.jsx)(we,{className:"size-3"})}),(0,e.jsx)(N,{variant:"ghost",size:"icon-xs",disabled:!o,onClick:r(()=>n("restart"),"onClick"),"aria-label":"Restart",title:"Restart",className:"border",children:(0,e.jsx)(De,{className:"size-3"})})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(N,{variant:"ghost",size:"icon-xs",disabled:a,onClick:r(()=>n("stop"),"onClick"),"aria-label":"Stop",title:"Stop",className:"border",children:(0,e.jsx)(Ls,{className:"size-3"})}),(0,e.jsx)(N,{variant:"ghost",size:"icon-xs",disabled:a||!o,onClick:r(()=>n("restart"),"onClick"),"aria-label":"Restart",title:"Restart",className:"border",children:(0,e.jsx)(De,{className:"size-3"})})]})}r(We,"ActionSlots");function rn({entry:s,onViewLogs:n}){const a=s.exposureDetail??(s.state==="failed"?s.failureDetail:null);if(!a)return null;const o=s.exposureState==="failed"||s.exposureState==="cleanup_pending";return(0,e.jsxs)("div",{className:S("flex items-center gap-1 text-xs",o?"text-bad":"text-ink-3"),children:[(0,e.jsx)("span",{children:a}),n&&s.state==="failed"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":!0,children:"·"}),(0,e.jsx)("button",{type:"button",onClick:n,className:"font-medium text-ink underline underline-offset-2 hover:text-ink/80",children:"View logs"})]}):null]})}r(rn,"ServiceDetail");function an({entry:s,onAction:n,onViewLogs:a,className:o}){const d=Xe(s);return(0,e.jsxs)("div",{className:S("flex w-full flex-col items-stretch gap-1 sm:w-auto sm:items-end",o),children:[(0,e.jsxs)("div",{className:"rounded-lg border border-line bg-bg",children:[(0,e.jsxs)("div",{className:"flex h-9 items-center pl-3 pr-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 sm:min-w-24",children:[(0,e.jsx)(Se,{entry:s}),(0,e.jsx)("span",{className:"whitespace-nowrap text-xs font-medium text-ink",children:d.label})]}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"hidden w-56 min-w-0 shrink-0 items-center gap-0.5 sm:flex",children:(0,e.jsx)(ce,{entry:s})}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-1 pl-3 sm:pl-0",children:(0,e.jsx)(We,{entry:s,onAction:r(c=>n(c,s.key),"onAction")})})]}),(0,e.jsx)("div",{className:"flex h-8 items-center justify-between gap-0.5 border-t border-line px-3 sm:hidden",children:(0,e.jsx)(ce,{entry:s,compact:!0})})]}),(0,e.jsx)(rn,{entry:s,onViewLogs:a})]})}r(an,"SingleServiceBar");function on({entry:s,onAction:n}){const a=Xe(s),o=Ge(s.url),d=s.state==="running"&&!!s.url,c=s.exposureState==="failed"||s.exposureState==="cleanup_pending",u=s.exposureDetail?s.exposureDetail:d?o:s.state==="starting"&&s.port?`starting on :${s.port}…`:s.state==="failed"&&s.failureDetail?s.failureDetail:`${a.label.toLowerCase().replace(/…$/,"")}${s.port?` · :${s.port}`:""}`;return(0,e.jsxs)("div",{className:"flex items-center gap-3 py-2.5",children:[(0,e.jsx)(Se,{entry:s,className:"mt-0.5"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium text-ink",children:s.name}),(0,e.jsx)("div",{className:"flex min-w-0 items-center gap-0.5",children:d&&s.url?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("a",{href:s.url,target:"_blank",rel:"noreferrer",title:s.url,className:"min-w-0 truncate font-mono text-xs text-ink-3 hover:text-ink hover:underline",children:o}),(0,e.jsx)(Ze,{url:s.url})]}):(0,e.jsx)("span",{className:S("min-w-0 text-xs",c?"whitespace-normal break-words text-bad":"truncate text-ink-3"),children:u})})]}),(0,e.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:(0,e.jsx)(We,{entry:s,onAction:r(v=>n(v,s.key),"onAction")})})]})}r(on,"ServicePopoverRow");function ln({services:s,onAction:n,onManageServices:a,defaultServicesOpen:o,className:d}){const[c,u]=(0,h.useState)(o??!1),v=s.filter(f=>f.state==="running").length,k=s.some(f=>Ie(f.state)),y=s.some(f=>f.state==="failed"),m=v>0,p=s.find(f=>f.state==="running"&&f.url)??null,_={key:"__all__",name:"All services",state:k?"starting":y?"failed":m?"running":"stopped",healthStatus:s.some(f=>f.state==="running"&&f.healthStatus==="unhealthy")?"unhealthy":"healthy"};return(0,e.jsx)("div",{className:S("flex w-full flex-col items-stretch gap-1 sm:w-auto sm:items-end",d),children:(0,e.jsxs)("div",{className:"rounded-lg border border-line bg-bg",children:[(0,e.jsxs)("div",{className:"flex h-9 items-center pl-3 pr-1.5",children:[(0,e.jsxs)(Es,{open:c,onOpenChange:u,children:[(0,e.jsx)(Ps,{asChild:!0,children:(0,e.jsxs)("button",{type:"button",className:"flex h-full items-center gap-2 rounded-l-lg pr-1 text-xs font-medium text-ink hover:bg-bg-3","aria-label":`${v} of ${s.length} services running — show services`,children:[(0,e.jsx)(Se,{entry:_}),(0,e.jsxs)("span",{className:"whitespace-nowrap",children:[v,"/",s.length," running"]}),(0,e.jsx)(Ts,{className:"size-3 text-ink-3"})]})}),(0,e.jsxs)(_s,{align:"end",className:"w-96 p-0",onOpenAutoFocus:r(f=>f.preventDefault(),"onOpenAutoFocus"),children:[(0,e.jsxs)("div",{className:"px-4 pb-1 pt-3 text-xs font-medium uppercase tracking-wide text-ink-3",children:["Services · ",s.length]}),(0,e.jsx)("div",{className:"divide-y divide-line px-4",children:s.map(f=>(0,e.jsx)(on,{entry:f,onAction:n},f.key))}),(0,e.jsxs)("div",{className:"flex items-center gap-1 border-t border-line px-4 py-2",children:[(0,e.jsx)(N,{variant:"ghost",size:"xs",onClick:r(()=>n("start",null),"onClick"),children:"Start all"}),(0,e.jsx)(N,{variant:"ghost",size:"xs",onClick:r(()=>n("stop",null),"onClick"),children:"Stop all"}),(0,e.jsx)(N,{variant:"ghost",size:"xs",onClick:r(()=>n("restart",null),"onClick"),children:"Restart all"}),a?(0,e.jsx)(N,{variant:"link",size:"xs",className:"ml-auto",onClick:a,children:"Manage in Services tab →"}):null]})]})]}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"hidden min-w-0 items-center gap-0.5 sm:flex",children:p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"mr-1 shrink-0 text-xs text-ink-3",children:p.name}),(0,e.jsx)(ce,{entry:p})]}):(0,e.jsx)("span",{className:"font-mono text-xs text-ink-3/70",children:"no url"})}),(0,e.jsx)("div",{className:"mx-3 hidden h-5 w-px bg-line sm:block"}),(0,e.jsx)("div",{className:"ml-auto flex items-center gap-1 pl-3 sm:pl-0",children:(0,e.jsx)(We,{entry:{state:_.state,canStart:!0},onAction:r(f=>n(f,null),"onAction")})})]}),p?(0,e.jsx)("div",{className:"flex h-8 items-center justify-between gap-0.5 border-t border-line px-3 sm:hidden",children:(0,e.jsx)(ce,{entry:p,compact:!0})}):null]})})}r(ln,"MultiServiceBar");function cn({services:s,onAction:n,onViewLogs:a,onManageServices:o,defaultServicesOpen:d,className:c}){return s.length===0?null:s.length===1?(0,e.jsx)(an,{entry:s[0],onAction:n,onViewLogs:a,className:c}):(0,e.jsx)(ln,{services:s,onAction:n,onManageServices:o,defaultServicesOpen:d,className:c})}r(cn,"WorkspaceServiceControlBar");var ze=new Set([fs]);function Ye(s){const n=new Set;for(const a of s.variables)ze.has(a.name)&&n.add(a.name);for(const a of gs([s.title,s.description]))ze.has(a)&&n.add(a);return[...n]}r(Ye,"getWorkspaceSpecificRoutineVariableNames");function dn(s){return Ye(s).length>0}r(dn,"routineHasWorkspaceSpecificVariables");function un(s){return[...s].sort((n,a)=>{const o=n.title.localeCompare(a.title,void 0,{sensitivity:"base"});return o!==0?o:n.id.localeCompare(a.id)})}r(un,"sortWorkspaceRoutinesByName");var mn=100,pn=[{value:"issues",label:"Tasks",order:10},{value:"services",label:"Services",order:20},{value:"configuration",label:"Configuration",order:30},{value:"runtime_logs",label:"Runtime logs",order:40},{value:"routines",label:"Routines",order:60}];function J(s){return typeof s=="string"&&s.startsWith("plugin:")}r(J,"isExecutionWorkspacePluginTab");function xn(s){return s.map((n,a)=>({item:n,index:a})).sort((n,a)=>n.item.order-a.item.order||n.index-a.index).map(({item:n})=>n)}r(xn,"orderExecutionWorkspaceTabItems");function hn(s,n){const a=s.split("/").filter(Boolean),o=a.indexOf("execution-workspaces");if(o===-1||a[o+1]!==n)return null;const d=a[o+2];return d==="services"?"services":d==="issues"?"issues":d==="routines"?"routines":d==="runtime-logs"?"runtime_logs":d==="configuration"?"configuration":null}r(hn,"resolveExecutionWorkspaceTab");function ie(s,n){return`/execution-workspaces/${s}/${n==="runtime_logs"?"runtime-logs":n}`}r(ie,"executionWorkspaceTabPath");function be({workspaceId:s}){return(0,h.useEffect)(()=>{try{localStorage.removeItem(`wardmote:execution-workspace-tab:${s}`)}catch{}},[s]),(0,e.jsx)(Ss,{to:ie(s,"issues"),replace:!0})}r(be,"LegacyWorkspaceTabRedirect");function fn(s){if(!s)return!1;try{const n=new URL(s);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}r(fn,"isSafeExternalUrl");function T(s){return s??""}r(T,"readText");function Ne(s){return!s||Object.keys(s).length===0?"":JSON.stringify(s,null,2)}r(Ne,"formatJson");function gn(s){return s?L(s):"Never"}r(gn,"formatOptionalDateTime");function oe(s){const n=s.trim();return n.length>0?n:null}r(oe,"normalizeText");function de(s){const n=s.trim();if(!n)return{ok:!0,value:null};try{const a=JSON.parse(n);return!a||typeof a!="object"||Array.isArray(a)?{ok:!1,error:"Workspace commands JSON must be a JSON object."}:{ok:!0,value:a}}catch(a){return{ok:!1,error:a instanceof Error?a.message:"Invalid JSON."}}}r(de,"parseWorkspaceRuntimeJson");function es(s){if(!s)return[];const n=[],a=r((o,d,c)=>{Array.isArray(d)&&d.forEach((u,v)=>{if(!u||typeof u!="object"||Array.isArray(u))return;const k=u;if(c&&k.kind!=="service")return;const y=k.port,m=!!(y&&typeof y=="object"&&!Array.isArray(y)&&Object.hasOwn(y,"value")),p=typeof y=="number"?y:m?y.value:null;n.push({collection:o,index:v,name:typeof k.name=="string"&&k.name.trim()?k.name:`Service ${v+1}`,port:typeof p=="number"?p:null,invalidPort:(typeof y=="number"||m)&&(typeof p!="number"||!Number.isInteger(p)||p<1||p>65535)})})},"addServices");return a("commands",s.commands,!0),a("services",s.services,!1),n}r(es,"readConfiguredRuntimeServicePorts");function jn(s){const n=structuredClone(s.runtimeConfig),a=n[s.service.collection];if(!Array.isArray(a))return n;const o=a[s.service.index];if(!o||typeof o!="object"||Array.isArray(o))return n;const d=o,c=d.port&&typeof d.port=="object"&&!Array.isArray(d.port)?d.port:null,u=s.port.trim();if(!u){if(c){const k={...c,type:"auto"};delete k.value,d.port=k}else delete d.port;return n}const v=Number(u);return!Number.isInteger(v)||v<1||v>65535||(d.port={...c,type:"fixed",value:v}),n}r(jn,"updateConfiguredRuntimeServicePort");function vn(s){const n=new Map;for(const a of s){if(a.invalidPort||!a.port)continue;const o=n.get(a.port)??[];o.push(a),n.set(a.port,o)}return Array.from(n.entries()).filter(([,a])=>a.length>1).map(([a,o])=>`Port ${a} is assigned to multiple services: ${o.map(d=>d.name).join(", ")}.`)}r(vn,"getConfiguredRuntimeServicePortWarnings");function Qe(s){return{name:s.name,cwd:T(s.cwd),repoUrl:T(s.repoUrl),baseRef:T(s.baseRef),branchName:T(s.branchName),providerRef:T(s.providerRef),provisionCommand:T(s.config?.provisionCommand),runtimeProvisionCommand:T(s.config?.runtimeProvisionCommand),teardownCommand:T(s.config?.teardownCommand),cleanupCommand:T(s.config?.cleanupCommand),inheritRuntime:!s.config?.workspaceRuntime,workspaceRuntime:Ne(s.config?.workspaceRuntime)}}r(Qe,"formStateFromWorkspace");function bn(s,n){const a={},o={},d=r(u=>{s[u]!==n[u]&&(a[u]=u==="name"?oe(n[u])??s.name:oe(n[u]))},"maybeAssign");d("name"),d("cwd"),d("repoUrl"),d("baseRef"),d("branchName"),d("providerRef");const c=r(u=>{s[u]!==n[u]&&(o[u]=oe(n[u]))},"maybeAssignConfigText");if(c("provisionCommand"),c("runtimeProvisionCommand"),c("teardownCommand"),c("cleanupCommand"),s.inheritRuntime!==n.inheritRuntime||s.workspaceRuntime!==n.workspaceRuntime){const u=de(n.workspaceRuntime);if(!u.ok)throw new Error(u.error);o.workspaceRuntime=n.inheritRuntime?null:u.value}return Object.keys(o).length>0&&(a.config=o),a}r(bn,"buildWorkspacePatch");function kn(s){const n=oe(s.repoUrl);if(n)try{new URL(n)}catch{return"Repo URL must be a valid URL."}if(!s.inheritRuntime){const a=de(s.workspaceRuntime);if(!a.ok)return a.error;const o=es(a.value).find(d=>d.invalidPort);if(o)return`${o.name} has an invalid fixed port.`}return null}r(kn,"validateForm");function I({label:s,hint:n,children:a}){return(0,e.jsxs)("label",{className:"block space-y-2",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-0.5 sm:flex-row sm:items-baseline sm:justify-between sm:gap-3",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:s}),n?(0,e.jsx)("span",{className:"text-xs text-ink-3 sm:text-right",children:n}):null]}),a]})}r(I,"Field");function yn(s){switch(s){case"worktree_prepare":return"Worktree setup";case"workspace_config_freshness":return"Config freshness";case"workspace_provision":return"Provision";case"workspace_seed":return"Database seed";case"workspace_runtime_provision":return"Runtime provision";case"workspace_teardown":return"Teardown";case"worktree_cleanup":return"Worktree cleanup";case"workspace_finalize":return"Finalize";default:return s}}r(yn,"workspaceOperationPhaseLabel");function wn(s){const n=(s.operations??[]).find(a=>a.phase==="workspace_seed"||a.phase==="workspace_runtime_provision")??null;if(n){const a=n.finishedAt??n.startedAt??null;if(n.status==="running")return{kind:"provisioning",at:a};if(n.status==="succeeded")return{kind:"provisioned",at:a};if(n.status==="failed")return{kind:"failed",at:a}}return s.runtimeProvisionCommand&&s.runtimeProvisionCommand.trim()?{kind:"deferred"}:{kind:"eager"}}r(wn,"resolveRuntimeProvisionStatus");function C({label:s,children:n}){return(0,e.jsxs)("div",{className:"flex flex-col gap-1.5 py-1.5 sm:flex-row sm:items-start sm:gap-3",children:[(0,e.jsx)("div",{className:"shrink-0 text-xs text-ink-3 sm:w-32",children:s}),(0,e.jsx)("div",{className:"min-w-0 flex-1 text-sm",children:n})]})}r(C,"DetailRow");function Z({children:s,className:n}){return(0,e.jsx)("div",{className:S("inline-flex items-center rounded-full border border-line bg-bg px-2.5 py-1 text-xs text-ink-3",n),children:s})}r(Z,"StatusPill");function Nn({status:s,onViewLogs:n}){return s.kind==="eager"?(0,e.jsx)("span",{className:"text-sm text-ink-3",children:"Eager · provisioned during workspace setup"}):s.kind==="deferred"?(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(Z,{className:"border-amber-500/40 text-amber-600 dark:text-amber-400",children:"Deferred"}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Runs once before the first runtime-service start."})]}):s.kind==="provisioning"?(0,e.jsxs)(Z,{className:"border-line text-ink-3",children:[(0,e.jsx)(ue,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Provisioning…"]}):s.kind==="provisioned"?(0,e.jsxs)(Z,{className:"border-emerald-500/40 text-emerald-600 dark:text-emerald-400",children:["Provisioned",s.at?` · ${L(s.at)}`:""]}):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsxs)(Z,{className:"border-bad/50 text-bad",children:["Provisioning failed",s.at?` · ${L(s.at)}`:""]}),(0,e.jsx)("button",{type:"button",onClick:n,className:"self-start text-xs text-ink-3 underline underline-offset-2 hover:text-ink",children:"View runtime logs"})]})}r(Nn,"RuntimeProvisionStatusValue");function W({value:s,copy:n}){return(0,e.jsxs)("div",{className:"inline-flex max-w-full items-start gap-2",children:[(0,e.jsx)("span",{className:"break-all font-mono text-xs",children:s}),n?(0,e.jsx)(He,{text:s,className:"shrink-0 text-ink-3 hover:text-ink",copiedLabel:"Copied",children:(0,e.jsx)(Ce,{className:"h-3.5 w-3.5"})}):null]})}r(W,"MonoValue");function Rn({project:s,workspace:n}){return(0,e.jsx)(Y,{to:hs(s,n.id),className:"hover:underline",children:n.name})}r(Rn,"WorkspaceLink");function Cn({companyId:s,workspace:n,issues:a,isLoading:o,error:d,project:c}){const u=Re(),{data:v}=P({queryKey:x.agents.list(s),queryFn:r(()=>Je.list(s),"queryFn"),enabled:!!s}),k=x.liveRuns(s),y=Os({companyId:s,resourceKey:"live-runs",queryKey:k,enabled:!!s,refetchInterval:!1,leaderOnly:!0}),{data:m,dataUpdatedAt:p}=P({queryKey:k,queryFn:r(()=>Js.liveRunsForCompany(s),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});Us(y,m,p);const _=(0,h.useMemo)(()=>Vs(m,a),[a,m]),f=le({mutationFn:r(({id:q,data:F})=>ke.update(q,F),"mutationFn"),onSuccess:r(()=>{u.invalidateQueries({queryKey:x.issues.listByExecutionWorkspace(s,n.id)}),u.invalidateQueries({queryKey:x.issues.list(s)}),c?.id&&u.invalidateQueries({queryKey:x.issues.listByProject(s,c.id)})},"onSuccess")}),b=(0,h.useMemo)(()=>c?[{id:c.id,name:c.name,workspaces:c.workspaces??[]}]:void 0,[c]),g=(0,h.useMemo)(()=>({projectId:n.projectId,...n.projectWorkspaceId?{projectWorkspaceId:n.projectWorkspaceId}:{},executionWorkspaceId:n.id,executionWorkspaceMode:"reuse_existing"}),[n.id,n.projectId,n.projectWorkspaceId]);return(0,e.jsx)(Gs,{issues:a,isLoading:o,error:d,agents:v,projects:b,liveIssueIds:_,projectId:c?.id,viewStateKey:"wardmote:execution-workspace-issues-view",baseCreateIssueDefaults:g,onUpdateIssue:r((q,F)=>f.mutate({id:q,data:F}),"onUpdateIssue")})}r(Cn,"ExecutionWorkspaceIssuesList");function In({routine:s,variableNames:n,runningRoutineId:a,onRunNow:o}){const d=s.status==="archived",c=a===s.id;return(0,e.jsxs)("div",{className:"flex flex-col gap-3 border-b border-line px-3 py-3 last:border-b-0 sm:flex-row sm:items-center",children:[(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Y,{to:`/routines/${s.id}`,className:"truncate text-sm font-medium hover:underline",children:s.title}),s.status!=="active"?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:s.status}):null]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-ink-3",children:[(0,e.jsx)("span",{children:s.assigneeAgentId?"Default agent set":"Choose agent when running"}),(0,e.jsxs)("span",{children:["Last run ",gn(s.lastRun?.triggeredAt??s.lastTriggeredAt)]}),(0,e.jsx)("span",{className:"flex flex-wrap gap-1",children:n.map(u=>(0,e.jsx)("span",{className:"rounded-sm bg-bg-3 px-1.5 py-0.5 font-mono text-(length:--text-micro) text-ink-3",children:u},u))})]})]}),(0,e.jsxs)(N,{variant:"secondary",size:"sm",className:"w-full sm:w-auto",disabled:d||c,onClick:r(()=>o(s),"onClick"),children:[c?(0,e.jsx)(ue,{className:"mr-2 h-4 w-4 animate-spin"}):(0,e.jsx)(we,{className:"mr-2 h-4 w-4"}),c?"Running...":"Run now"]})]})}r(In,"WorkspaceRoutineRow");function Sn({workspace:s,project:n}){const a=Re(),{pushToast:o}=qs(),[d,c]=(0,h.useState)(null),[u,v]=(0,h.useState)(null),{data:k,isLoading:y,error:m}=P({queryKey:x.routines.list(s.companyId,{projectId:s.projectId}),queryFn:r(()=>Me.list(s.companyId,{projectId:s.projectId}),"queryFn")}),{data:p}=P({queryKey:x.agents.list(s.companyId),queryFn:r(()=>Je.list(s.companyId),"queryFn")}),_=(0,h.useMemo)(()=>un((k??[]).filter(dn)),[k]),f=le({mutationFn:r(({id:b,data:g})=>Me.run(b,{...g?.variables&&Object.keys(g.variables).length>0?{variables:g.variables}:{},...g?.assigneeAgentId!==void 0?{assigneeAgentId:g.assigneeAgentId}:{},...g?.projectId!==void 0?{projectId:g.projectId}:{},...g?.executionWorkspaceId!==void 0?{executionWorkspaceId:g.executionWorkspaceId}:{},...g?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:g.executionWorkspacePreference}:{},...g?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:g.executionWorkspaceSettings}:{}}),"mutationFn"),onMutate:r(({id:b})=>{v(b)},"onMutate"),onSuccess:r(async(b,{id:g})=>{c(null),await Promise.all([a.invalidateQueries({queryKey:["routines",s.companyId]}),a.invalidateQueries({queryKey:x.routines.detail(g)}),a.invalidateQueries({queryKey:x.issues.listByExecutionWorkspace(s.companyId,s.id)}),a.invalidateQueries({queryKey:x.issues.list(s.companyId)})]),o({title:"Routine started",body:"Wardmote created a run using this execution workspace.",tone:"success"})},"onSuccess"),onSettled:r(()=>{v(null)},"onSettled"),onError:r(b=>{o({title:"Routine run failed",body:b instanceof Error?b.message:"Wardmote could not start the routine run.",tone:"error"})},"onError")});return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(K,{className:"rounded-none",children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(X,{children:"Workspace routines"}),(0,e.jsx)(H,{children:"Routines that use workspace-specific variables can be run against this execution workspace."})]}),(0,e.jsx)(B,{children:y?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading routines..."}):m?(0,e.jsx)("p",{className:"text-sm text-bad",children:m instanceof Error?m.message:"Failed to load routines."}):_.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 py-10 text-center",children:[(0,e.jsx)(Fs,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"No routines use workspace-specific variables yet."})]}):(0,e.jsx)("div",{className:"rounded-lg border border-line",children:_.map(b=>(0,e.jsx)(In,{routine:b,variableNames:Ye(b),runningRoutineId:u,onRunNow:c},b.id))})})]}),(0,e.jsx)(nn,{open:d!==null,onOpenChange:r(b=>{b||c(null)},"onOpenChange"),companyId:s.companyId,routineName:d?.title??null,agents:p??[],projects:n?[n]:[],defaultProjectId:s.projectId,defaultAssigneeAgentId:d?.assigneeAgentId??null,defaultExecutionWorkspace:s,variables:d?.variables??[],isPending:f.isPending,onSubmit:r(b=>{d&&f.mutate({id:d.id,data:b})},"onSubmit")})]})}r(Sn,"ExecutionWorkspaceRoutinesList");function pt(){const{visible:s,loaded:n}=Hs(),{workspaceId:a}=ks(),o=bs(),d=Is(),c=Re(),{setBreadcrumbs:u}=zs(),{selectedCompanyId:v,setSelectedCompanyId:k}=Cs(),{hideHostPaths:y}=Zs(),[m,p]=(0,h.useState)(null),[_,f]=(0,h.useState)(!1),[b,g]=(0,h.useState)(null),[q,F]=(0,h.useState)(null),[Pe,me]=(0,h.useState)(null),[ss,pe]=(0,h.useState)([]),ns=a?hn(o.pathname,a):null,ts=(0,h.useMemo)(()=>{const t=new URLSearchParams(o.search).get("tab");return J(t)?t:null},[o.search]),R=ns??ts,D=P({queryKey:x.executionWorkspaces.detail(a),queryFn:r(()=>V.get(a),"queryFn"),enabled:!!a}),i=D.data??null,j=P({queryKey:i?[...x.projects.detail(i.projectId),i.companyId]:["projects","detail","__pending__"],queryFn:r(()=>Bs.get(i.projectId,i.companyId),"queryFn"),enabled:!!i?.projectId}).data??null,E=P({queryKey:i?.sourceIssueId?x.issues.detail(i.sourceIssueId):["issues","detail","__none__"],queryFn:r(()=>ke.get(i.sourceIssueId),"queryFn"),enabled:!!i?.sourceIssueId}).data??null,xe=P({queryKey:i?.derivedFromExecutionWorkspaceId?x.executionWorkspaces.detail(i.derivedFromExecutionWorkspaceId):["execution-workspaces","detail","__none__"],queryFn:r(()=>V.get(i.derivedFromExecutionWorkspaceId),"queryFn"),enabled:!!i?.derivedFromExecutionWorkspaceId}).data??null,he=P({queryKey:i?x.issues.listByExecutionWorkspace(i.companyId,i.id):["issues","__execution-workspace__","__none__"],queryFn:r(()=>ke.list(i.companyId,{executionWorkspaceId:i.id}),"queryFn"),enabled:!!i?.companyId}),rs=he.data??[],ee=(0,h.useMemo)(()=>j?.workspaces.find(t=>t.id===i?.projectWorkspaceId)??null,[j,i?.projectWorkspaceId]),{slots:_e,isLoading:as,errorMessage:Ee}=Ds({slotTypes:["detailTab"],entityType:"execution_workspace",companyId:i?.companyId??null,enabled:!!i?.companyId}),fe=(0,h.useMemo)(()=>_e.map(t=>({value:`plugin:${t.pluginKey}:${t.id}`,label:t.displayName,order:t.order??mn,slot:t})),[_e]),is=(0,h.useMemo)(()=>xn([...pn.filter(t=>t.value!=="configuration"||s),...fe]),[fe,s]),O=ee?.runtimeConfig?.workspaceRuntime??null,ge=i?.config?.workspaceRuntime??O,Ae=i?.config?.workspaceRuntime?"execution_workspace":O?"project_workspace":"none",Te=(0,h.useMemo)(()=>{if(!m||m.inheritRuntime)return O;const t=de(m.workspaceRuntime);return t.ok?t.value:null},[m,O]),se=(0,h.useMemo)(()=>es(Te),[Te]),Fe=(0,h.useMemo)(()=>vn(se),[se]),M=(0,h.useMemo)(()=>i?Qe(i):null,[i]),je=!!(m&&M&&JSON.stringify(m)!==JSON.stringify(M)),ne=j?ps(j):i?.projectId??"";(0,h.useEffect)(()=>{!i?.companyId||i.companyId===v||k(i.companyId,{source:"route_sync"})},[i?.companyId,v,k]),(0,h.useEffect)(()=>{i&&(p(Qe(i)),g(null),F(null),pe([]))},[i]),(0,h.useEffect)(()=>{if(!i)return;const t=[{label:"Projects",href:"/projects"},...j?[{label:j.name,href:`/projects/${ne}`}]:[],...j?[{label:"Workspaces",href:`/projects/${ne}/workspaces`}]:[],{label:i.name}];u(t)},[u,i,j,ne]);const te=le({mutationFn:r(t=>V.update(i.id,t),"mutationFn"),onSuccess:r(t=>{c.setQueryData(x.executionWorkspaces.detail(t.id),t),c.invalidateQueries({queryKey:x.executionWorkspaces.closeReadiness(t.id)}),c.invalidateQueries({queryKey:x.executionWorkspaces.workspaceOperations(t.id)}),j&&(c.invalidateQueries({queryKey:x.projects.detail(j.id)}),c.invalidateQueries({queryKey:x.projects.detail(j.urlKey)})),E&&c.invalidateQueries({queryKey:x.issues.detail(E.id)}),g(null)},"onSuccess"),onError:r(t=>{g(t instanceof Error?t.message:"Failed to save execution workspace.")},"onError")}),A=P({queryKey:x.executionWorkspaces.workspaceOperations(a),queryFn:r(()=>V.listWorkspaceOperations(a),"queryFn"),enabled:!!a}),Le=i?.config?.runtimeProvisionCommand??j?.executionWorkspacePolicy?.workspaceStrategy?.runtimeProvisionCommand??null,os=(0,h.useMemo)(()=>wn({runtimeProvisionCommand:Le,operations:A.data}),[Le,A.data]),re=le({mutationFn:r(t=>V.controlRuntimeCommands(i.id,t.action,t),"mutationFn"),onSuccess:r((t,l)=>{c.setQueryData(x.executionWorkspaces.detail(t.workspace.id),t.workspace),c.invalidateQueries({queryKey:x.executionWorkspaces.overview(t.workspace.companyId)}),c.invalidateQueries({queryKey:x.executionWorkspaces.workspaceOperations(t.workspace.id)}),c.invalidateQueries({queryKey:x.projects.detail(t.workspace.projectId)}),F(null),me(l.action==="run"?"Workspace job completed.":l.action==="stop"?"Workspace service stopped.":l.action==="restart"?"Workspace service restarted.":"Workspace service started.")},"onSuccess"),onError:r(t=>{me(null),F(t instanceof Error?t.message:"Failed to control workspace commands.")},"onError"),onSettled:r((t,l,w)=>{pe(Q=>Q.filter(us=>us!==w))},"onSettled")});if(D.isLoading)return(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading workspace…"});if(D.error)return(0,e.jsx)("p",{className:"text-sm text-bad",children:D.error instanceof Error?D.error.message:"Failed to load workspace"});if(!i||!m||!M)return null;const qe=!!i.cwd,Oe=!!ge&&qe,ve=Ns({runtimeConfig:ge,runtimeServices:i.runtimeServices??[],canStartServices:Oe,canRunJobs:qe}),ls=re.isPending?re.variables??null:null,cs=ws({sections:ve,runtimeServices:i.runtimeServices??[],pendingRequests:ss}),Ue={companyId:i.companyId,projectId:i.projectId,entityId:i.id,entityType:"execution_workspace"},Be=fe.find(t=>t.value===R)??null;if(R==="configuration"&&!n)return null;if(a&&R==="configuration"&&!s)return(0,e.jsx)(be,{workspaceId:a});if(a&&R===null)return(0,e.jsx)(be,{workspaceId:a});const z=r(t=>{if(J(t)){d(`/execution-workspaces/${i.id}?tab=${encodeURIComponent(t)}`);return}d(ie(i.id,t))},"handleTabChange"),ds=r(()=>{const t=kn(m);if(t){g(t);return}let l;try{l=bn(M,m)}catch(w){g(w instanceof Error?w.message:"Failed to build workspace update.");return}Object.keys(l).length!==0&&te.mutate(l)},"saveChanges"),Ke=r(t=>{if(t.length!==0){pe(l=>[...l,...t]);for(const l of t)re.mutate(l)}},"runRuntimeControlRequests");return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-4 overflow-hidden sm:space-y-6",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-2",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-(--tracking-eyebrow) text-ink-3",children:"Execution workspace"}),(0,e.jsx)("h1",{className:"truncate text-xl font-semibold sm:text-2xl",children:i.name})]}),(0,e.jsx)(cn,{services:cs,onAction:r((t,l)=>{Ke(ys(ve,t,l))},"onAction"),onViewLogs:r(()=>z("runtime_logs"),"onViewLogs"),onManageServices:r(()=>z("services"),"onManageServices")})]}),q?(0,e.jsx)("p",{className:"text-sm text-bad",children:q}):null,!q&&Pe?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:Pe}):null,(0,e.jsx)(Ks,{slotTypes:["toolbarButton","contextMenuItem"],entityType:"execution_workspace",context:Ue,className:"flex flex-wrap gap-2",itemClassName:"inline-flex",missingBehavior:"placeholder"}),(0,e.jsx)(Ws,{value:R??"issues",onValueChange:r(t=>z(t),"onValueChange"),children:(0,e.jsx)(Xs,{items:is.map(t=>({value:t.value,label:t.label})),align:"start",value:R??"issues",onValueChange:r(t=>z(t),"onValueChange")})}),R==="services"?(0,e.jsx)(Rs,{sections:ve,isPending:re.isPending,pendingRequest:ls,serviceEmptyMessage:ge?"No services have been started for this execution workspace yet.":"No workspace command config is defined for this execution workspace yet.",jobEmptyMessage:"No one-shot jobs are configured for this execution workspace yet.",disabledHint:Oe?null:"Execution workspaces need a working directory before local commands can run, and services also need runtime config.",onAction:r(t=>Ke([t]),"onAction")}):R==="configuration"?(0,e.jsxs)("div",{className:"space-y-4 sm:space-y-6",children:[(0,e.jsxs)(K,{className:"rounded-none",children:[(0,e.jsxs)(G,{children:[(0,e.jsx)(X,{children:"Workspace settings"}),(0,e.jsx)(H,{children:"Edit the concrete path, repo, branch, provisioning, teardown, and runtime overrides attached to this execution workspace. Saved changes affect future runs; Wardmote may refresh or replace a reused workspace when config changes."}),(0,e.jsx)($s,{children:(0,e.jsx)(N,{variant:"danger",size:"sm",className:"w-full sm:w-auto",onClick:r(()=>f(!0),"onClick"),disabled:i.status==="archived",children:i.status==="cleanup_failed"?"Retry close":"Close workspace"})})]}),(0,e.jsxs)(B,{children:[(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"General"}),(0,e.jsx)(I,{label:"Workspace name",children:(0,e.jsx)(U,{value:m.name,onChange:r(t=>p(l=>l&&{...l,name:t.target.value}),"onChange"),placeholder:"Execution workspace name"})})]}),(0,e.jsx)(ae,{}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Source control"}),(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,e.jsx)(I,{label:"Branch name",hint:"Useful for isolated worktrees",children:(0,e.jsx)(U,{className:"font-mono",value:m.branchName,onChange:r(t=>p(l=>l&&{...l,branchName:t.target.value}),"onChange"),placeholder:"PAP-946-workspace"})}),(0,e.jsx)(I,{label:"Base ref",children:(0,e.jsx)(U,{className:"font-mono",value:m.baseRef,onChange:r(t=>p(l=>l&&{...l,baseRef:t.target.value}),"onChange"),placeholder:"origin/main"})})]}),(0,e.jsx)(I,{label:"Repo URL",children:(0,e.jsx)(U,{value:m.repoUrl,onChange:r(t=>p(l=>l&&{...l,repoUrl:t.target.value}),"onChange"),placeholder:"https://github.com/org/repo"})})]}),(0,e.jsx)(ae,{}),!y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Paths"}),(0,e.jsx)(I,{label:"Working directory",children:(0,e.jsx)(U,{className:"font-mono",value:m.cwd,onChange:r(t=>p(l=>l&&{...l,cwd:t.target.value}),"onChange"),placeholder:"/absolute/path/to/workspace"})}),(0,e.jsx)(I,{label:"Provider path / ref",children:(0,e.jsx)(U,{className:"font-mono",value:m.providerRef,onChange:r(t=>p(l=>l&&{...l,providerRef:t.target.value}),"onChange"),placeholder:"/path/to/worktree or provider ref"})})]}),(0,e.jsx)(ae,{})]}),!y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Lifecycle commands"}),(0,e.jsx)(I,{label:"Provision command",hint:"Runs when Wardmote prepares this execution workspace",children:(0,e.jsx)($,{className:"min-h-20 font-mono",value:m.provisionCommand,onChange:r(t=>p(l=>l&&{...l,provisionCommand:t.target.value}),"onChange"),placeholder:"bash ./scripts/provision-worktree.sh"})}),(0,e.jsx)(I,{label:"Runtime provision command",hint:"Runs once before the first runtime-service start. Leave empty to keep eager provisioning.",children:(0,e.jsx)($,{className:"min-h-20 font-mono",value:m.runtimeProvisionCommand,onChange:r(t=>p(l=>l&&{...l,runtimeProvisionCommand:t.target.value}),"onChange"),placeholder:"bash ./scripts/provision-worktree-runtime.sh"})}),(0,e.jsx)(I,{label:"Teardown command",hint:"Runs when the execution workspace is archived or cleaned up",children:(0,e.jsx)($,{className:"min-h-20 font-mono",value:m.teardownCommand,onChange:r(t=>p(l=>l&&{...l,teardownCommand:t.target.value}),"onChange"),placeholder:"bash ./scripts/teardown-worktree.sh"})}),(0,e.jsx)(I,{label:"Cleanup command",hint:"Workspace-specific cleanup before teardown",children:(0,e.jsx)($,{className:"min-h-16 font-mono",value:m.cleanupCommand,onChange:r(t=>p(l=>l&&{...l,cleanupCommand:t.target.value}),"onChange"),placeholder:"pkill -f vite || true"})})]}),(0,e.jsx)(ae,{})]}),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium uppercase tracking-widest text-ink-3",children:"Runtime config"}),(0,e.jsx)("div",{className:"rounded-md border border-dashed border-line/70 bg-bg px-4 py-3",children:(0,e.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Runtime config source"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:Ae==="execution_workspace"?"This execution workspace currently overrides the project workspace runtime config.":Ae==="project_workspace"?"This execution workspace is inheriting the project workspace runtime config.":"No runtime config is currently defined on this execution workspace or its project workspace."})]}),(0,e.jsx)(N,{variant:"secondary",className:"w-full sm:w-auto",size:"sm",disabled:!ee?.runtimeConfig?.workspaceRuntime,onClick:r(()=>p(t=>t&&{...t,inheritRuntime:!0,workspaceRuntime:""}),"onClick"),children:"Reset to inherit"})]})}),(0,e.jsxs)("details",{className:"rounded-md border border-dashed border-line/70 bg-bg px-4 py-3",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-sm font-medium",children:"Advanced runtime JSON"}),(0,e.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Override the inherited workspace command model only when this execution workspace truly needs different service or job behavior."}),(0,e.jsx)("div",{className:"mt-3",children:(0,e.jsxs)(I,{label:"Workspace commands JSON",hint:"Legacy `services` arrays still work, but `commands` supports both services and jobs.",children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-sm text-ink-3",children:[(0,e.jsx)("input",{id:"inherit-runtime-config",type:"checkbox",className:"rounded border-line",checked:m.inheritRuntime,onChange:r(t=>{const l=t.target.checked;p(w=>w&&(!l&&!w.workspaceRuntime.trim()&&O?{...w,inheritRuntime:l,workspaceRuntime:Ne(O)}:{...w,inheritRuntime:l}))},"onChange")}),(0,e.jsx)("label",{htmlFor:"inherit-runtime-config",children:"Inherit project workspace runtime config"})]}),(0,e.jsx)($,{className:"min-h-64 font-mono sm:min-h-96",value:m.workspaceRuntime,onChange:r(t=>p(l=>l&&{...l,workspaceRuntime:t.target.value}),"onChange"),disabled:m.inheritRuntime,placeholder:`{
|
|
2
2
|
"commands": [
|
|
3
3
|
{
|
|
4
4
|
"id": "web",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ze=Object.defineProperty;var t=(s,a)=>ze(s,"name",{value:a,configurable:!0});import{i as fe}from"./rolldown-runtime-ZpX3ckPj.js";import{l as Q,la as Me,t as qe,ua as $e}from"./createLucideIcon-CgrPXnTY.js";import{v as Oe}from"./star-eem0qj3E.js";import{X as V,_ as B,t as R,v as G}from"./queryKeys-BzT8CD34.js";import{t as Fe}from"./useInfiniteQuery-DTEIZ1gz.js";import{n as Ge}from"./CompanyContext-fQCNWI_f.js";import{o as je,r as Re,t as J}from"./router-CJbFZfVR.js";import{n as Le,r as Ke,t as Qe}from"./collapsible-D_rwONtV.js";import{t as Be}from"./bot-kSfD9MPZ.js";import{t as Ue}from"./braces-CpXTT0w9.js";import{t as He}from"./check-Bis3vECb.js";import{t as ge}from"./chevron-down-nRcQ7bok.js";import{t as We}from"./chevron-left-DnUVccc_.js";import{t as be}from"./chevron-right-BP8JjEC_.js";import{t as Je}from"./chevron-up-C1TOE3pP.js";import{t as Ve}from"./SearchableSelect-BbuRtdzg.js";import{t as Ze}from"./circle-question-mark-CasEGiDp.js";import{t as Xe}from"./code-xml-CZhhm_-P.js";import{t as F}from"./copy-C1cfcpxY.js";import{t as Ye}from"./key-round-CGxQxRtN.js";import{t as es}from"./link-0uKX-OmT.js";import{t as x}from"./button-DI4w5WP7.js";import{t as ss}from"./plus-CwNlqadt.js";import{t as ts}from"./send-DfQbMfo9.js";import{i as as,n as ns,t as is}from"./tooltip-CW50mEoC.js";import{i as H}from"./ToastContext-DyVJ6bCh.js";import{t as ls}from"./agents-B8n-p0aX.js";import{t as rs}from"./projects-l3kQxnTp.js";import{a as ye,i as Ne,n as ve,r as ke,s as we,t as Ce}from"./dialog-CeH7rDcv.js";import{t as L}from"./input-BBNGmECW.js";import{t as K}from"./skeleton-BAAoD7cz.js";import{t as A}from"./tools-MhVvhrz_.js";import{n as os}from"./BreadcrumbContext-DNbB7zWn.js";import{t as cs}from"./toggle-switch-Dj5GORxn.js";import{t as Y}from"./clipboard-CTLKYvRL.js";import{Aa as ds,La as ms,wn as xs}from"./index-LM7k1NmC.js";import{a as $,r as Te}from"./shared-CMP5lH_Q.js";import{_ as us,a as hs,b as oe,c as ps,d as fs,f as Se,g as js,h as O,i as gs,l as bs,o as le,p as Ae,r as U,s as Pe,t as ys,u as ce,v as ie,x as Ns,y as vs}from"./CopyableGatewayUrl-BLjhj10P.js";var _e={name:"mouse-pointer-2",size:24,node:[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]};_e.node;var ks=qe(_e),o=fe($e(),1),e=fe(Me(),1),ws={cursor:ks,claude_desktop:Be,vscode:Xe,claude_code:ds,opencode:Ue};function Cs({gateway:s,open:a,onOpenChange:i,createdTokens:p,onTokenCreated:c}){const r=V(),{pushToast:y}=H(),u=(0,o.useMemo)(()=>js(s.clientSnippets??[]),[s.clientSnippets]),N=(0,o.useMemo)(()=>`${typeof window<"u"?window.location.origin:""}${s.endpointPath}`,[s.endpointPath]),f=(0,o.useMemo)(()=>p.filter(l=>{const C=s.tokens.find(M=>M.id===l.id),S=ie(C??l);return S==="active"||S==="expiring"}),[p,s.tokens]),k=(0,o.useMemo)(()=>[{id:"tokens",label:"Available this session",options:f.map(l=>({key:l.id,value:l.id,label:l.name,title:l.clientLabel,searchText:`${l.name} ${l.clientLabel} ${l.tokenPrefix}`,token:l}))}],[f]),[j,w]=(0,o.useState)(u[0]?.client??"raw_url"),[h,v]=(0,o.useState)(""),g=f.find(l=>l.id===h)??null;(0,o.useEffect)(()=>{a&&(w(u[0]?.client??"raw_url"),v(l=>f.some(C=>C.id===l)?l:f[0]?.id??""))},[f,a,u]);const d=B({mutationFn:t(()=>{const l=Pe(s);return A.createGatewayToken(s.companyId,s.id,{name:l,clientLabel:l,ownerNote:"",allowedActions:["tools/list","tools/call"],expiresAt:new Date(Date.now()+7776e6).toISOString()})},"mutationFn"),onSuccess:t(async l=>{c(l),v(l.id),y({title:"Token issued",body:"The copy buttons now include its full Authorization header.",tone:"success"}),await r.invalidateQueries({queryKey:U(s.companyId)})},"onSuccess"),onError:t(l=>y({title:"Token was not issued",body:l instanceof Error?l.message:String(l),tone:"error"}),"onError")});async function D(l,C){try{await Y(l),y({title:"Copied",body:C,tone:"success"})}catch(S){y({title:"Copy failed",body:S instanceof Error?S.message:"Clipboard access is unavailable.",tone:"error"})}}t(D,"copyText");const T=u.find(l=>l.client===j)??null,P=T?ce(T.config,{endpointPath:s.endpointPath,endpoint:N,token:g?O(g):"pcgw_•••"}):"",b=T&&g?ce(T.config,{endpointPath:s.endpointPath,endpoint:N,token:g.token}):null;function _(){d.isPending||d.mutate()}return t(_,"issueToken"),(0,e.jsx)(Ce,{open:a,onOpenChange:i,children:(0,e.jsxs)(ve,{className:"sm:max-w-2xl",children:[(0,e.jsxs)(ye,{children:[(0,e.jsxs)(we,{className:"flex items-center gap-2",children:["Client snippets",(0,e.jsxs)(is,{children:[(0,e.jsx)(as,{asChild:!0,children:(0,e.jsx)("button",{type:"button","aria-label":"About client snippets",className:"text-ink-3 hover:text-ink",children:(0,e.jsx)(Ze,{className:"h-4 w-4"})})}),(0,e.jsx)(ns,{className:"max-w-xs text-xs",children:"Give this MCP gateway configuration to your tool. It does not give it access to Wardmote or skills; it only gateways calls between the client and the tools exposed here."})]})]}),(0,e.jsx)(ke,{children:"Choose a client and copy a complete, authenticated configuration."})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line pb-3",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Authorization"}),f.length>0?(0,e.jsx)(Ve,{value:h,groups:k,onValueChange:v,placeholder:"Issue a token",searchPlaceholder:"Search tokens…",emptyMessage:"No copyable tokens.",contentWidth:"auto",triggerClassName:"h-8 w-auto max-w-xs rounded-full px-3",renderValue:t(l=>l?`${l.label} · ${O(l.token)}`:"Issue a token","renderValue"),renderOption:t(l=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:"truncate",children:l.label}),(0,e.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-ink-3",children:O(l.token)})]}),"renderOption"),createItem:{render:t(()=>(0,e.jsx)("span",{children:"+ Issue a new token"}),"render"),onSelect:_}}):(0,e.jsx)(x,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",disabled:d.isPending,onClick:_,children:d.isPending?"Issuing…":"Issue a token"}),g?(0,e.jsxs)(x,{type:"button",variant:"ghost",size:"sm",onClick:t(()=>{D(`Authorization: Bearer ${g.token}`,"Authorization header")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy header"]}):null]}),g?null:(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Issue a token before copying a snippet; the full ",(0,e.jsx)("code",{children:"Authorization: Bearer …"})," header is required. Existing token secrets cannot be retrieved again, so only tokens issued in this page session can fill a snippet."]}),(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-(--gtc-10)",children:[(0,e.jsxs)("nav",{className:"flex gap-1 overflow-x-auto sm:flex-col","aria-label":"Clients",children:[u.map(l=>{const C=ws[l.client];return(0,e.jsxs)("button",{type:"button",onClick:t(()=>w(l.client),"onClick"),className:Q("flex shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm transition-colors",j===l.client?"bg-bg-3 font-medium text-ink":"text-ink-3 hover:bg-bg-3/60"),children:[(0,e.jsx)(C,{className:"h-4 w-4 shrink-0"}),l.label]},l.client)}),(0,e.jsxs)("button",{type:"button",onClick:t(()=>w("raw_url"),"onClick"),className:Q("flex shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm transition-colors",j==="raw_url"?"bg-bg-3 font-medium text-ink":"text-ink-3 hover:bg-bg-3/60"),children:[(0,e.jsx)(es,{className:"h-4 w-4 shrink-0"}),"Raw URL"]})]}),(0,e.jsxs)("div",{className:"min-w-0 space-y-3",children:[j==="raw_url"?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Endpoint URL"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:"min-w-0 flex-1 truncate rounded-md bg-bg-3 px-3 py-2 font-mono text-xs text-ink-3",children:N}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",onClick:t(()=>{D(N,"Endpoint URL")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Authorization header"}),(0,e.jsx)("code",{className:"block truncate rounded-md bg-bg-3 px-3 py-2 font-mono text-xs text-ink-3",children:g?`Authorization: Bearer ${O(g)}`:"Authorization: Bearer pcgw_•••"})]})]}):T?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:T.label}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",disabled:!b,onClick:t(()=>b&&void D(b,`${T.label} config`),"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]}),(0,e.jsx)("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md bg-bg-3 p-3 font-mono text-xs text-ink-3",children:P}),T.notes.length>0?(0,e.jsx)("ul",{className:"space-y-1 text-xs text-ink-3",children:T.notes.map(l=>(0,e.jsx)("li",{children:l},l))}):null]}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"No client snippets available for this gateway."}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Treat the token like a password. Anyone holding it can call the tools this gateway allows. Revoke it if it leaks."})]})]}),(0,e.jsx)(Ne,{children:(0,e.jsxs)(x,{onClick:t(()=>i(!1),"onClick"),children:[(0,e.jsx)(He,{className:"mr-1.5 h-4 w-4"}),"Done"]})})]})})}t(Cs,"ConnectClientDialog");function Ts({companyId:s,gateway:a,profiles:i,open:p,onOpenChange:c}){const r=V(),{pushToast:y}=H(),[u,N]=(0,o.useState)(a.name),[f,k]=(0,o.useState)(a.description??""),[j,w]=(0,o.useState)(a.profileId);(0,o.useEffect)(()=>{p&&(N(a.name),k(a.description??""),w(a.profileId))},[a,p]);const h=i.filter(d=>d.status!=="archived"),v=B({mutationFn:t(()=>A.updateGateway(s,a.id,{name:u.trim(),description:f.trim()||null,profileId:j}),"mutationFn"),onSuccess:t(async d=>{y({title:"Gateway updated",body:d.name,tone:"success"}),await r.invalidateQueries({queryKey:U(s)}),c(!1)},"onSuccess"),onError:t(d=>{y({title:"Gateway was not updated",body:d instanceof Error?d.message:String(d),tone:"error"})},"onError")});function g(d){d.preventDefault(),!(!u.trim()||!j)&&v.mutate()}return t(g,"submit"),(0,e.jsx)(Ce,{open:p,onOpenChange:c,children:(0,e.jsxs)(ve,{className:"sm:max-w-lg",children:[(0,e.jsxs)(ye,{children:[(0,e.jsx)(we,{children:"Edit gateway"}),(0,e.jsx)(ke,{children:"Change the label or the access profile that controls which tools this endpoint exposes."})]}),(0,e.jsxs)("form",{className:"space-y-4",onSubmit:g,children:[(0,e.jsxs)("label",{className:"block space-y-1.5",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Name"}),(0,e.jsx)(L,{value:u,onChange:t(d=>N(d.target.value),"onChange"),required:!0,autoFocus:!0})]}),(0,e.jsxs)("label",{className:"block space-y-1.5",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Access profile"}),(0,e.jsx)("select",{className:"w-full rounded-md border border-line-strong bg-bg px-3 py-2 text-sm",value:j,onChange:t(d=>w(d.target.value),"onChange"),required:!0,children:h.map(d=>(0,e.jsxs)("option",{value:d.id,children:[d.name," — ",le(d)]},d.id))})]}),(0,e.jsxs)("label",{className:"block space-y-1.5",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Description (optional)"}),(0,e.jsx)("textarea",{className:"min-h-16 w-full rounded-md border border-line-strong bg-bg px-3 py-2 text-sm",value:f,onChange:t(d=>k(d.target.value),"onChange"),placeholder:"Who this endpoint is for."})]}),(0,e.jsxs)(Ne,{children:[(0,e.jsx)(x,{type:"button",variant:"ghost",onClick:t(()=>c(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(x,{type:"submit",disabled:v.isPending||!u.trim()||!j,children:v.isPending?"Saving…":"Save changes"})]})]})]})})}t(Ts,"EditGatewayDialog");function Ss({gateway:s,profile:a,apps:i,agentNames:p,projectNames:c,toggleDisabled:r,onToggle:y}){const{pushToast:u}=H(),N=`${typeof window<"u"?window.location.origin:""}${s.endpointPath}`,f=hs(s),k=bs(s),j=i.filter(g=>g.needsAttention),w=Ae(s),h=["{",' "mcpServers": {',` "wardmote-${s.displaySlug}": {`,` "url": "${N}",`,' "headers": { "Authorization": "Bearer pcgw_•••_TOKEN" }'," }"," }","}"].join(`
|
|
1
|
+
var ze=Object.defineProperty;var t=(s,a)=>ze(s,"name",{value:a,configurable:!0});import{i as fe}from"./rolldown-runtime-ZpX3ckPj.js";import{l as Q,la as Me,t as qe,ua as $e}from"./createLucideIcon-CgrPXnTY.js";import{v as Oe}from"./star-eem0qj3E.js";import{X as V,_ as B,t as R,v as G}from"./queryKeys-BzT8CD34.js";import{t as Fe}from"./useInfiniteQuery-DTEIZ1gz.js";import{n as Ge}from"./CompanyContext-fQCNWI_f.js";import{o as je,r as Re,t as J}from"./router-CJbFZfVR.js";import{n as Le,r as Ke,t as Qe}from"./collapsible-D_rwONtV.js";import{t as Be}from"./bot-kSfD9MPZ.js";import{t as Ue}from"./braces-CpXTT0w9.js";import{t as He}from"./check-Bis3vECb.js";import{t as ge}from"./chevron-down-nRcQ7bok.js";import{t as We}from"./chevron-left-DnUVccc_.js";import{t as be}from"./chevron-right-BP8JjEC_.js";import{t as Je}from"./chevron-up-C1TOE3pP.js";import{t as Ve}from"./SearchableSelect-BbuRtdzg.js";import{t as Ze}from"./circle-question-mark-CasEGiDp.js";import{t as Xe}from"./code-xml-CZhhm_-P.js";import{t as F}from"./copy-C1cfcpxY.js";import{t as Ye}from"./key-round-CGxQxRtN.js";import{t as es}from"./link-0uKX-OmT.js";import{t as x}from"./button-DI4w5WP7.js";import{t as ss}from"./plus-CwNlqadt.js";import{t as ts}from"./send-DfQbMfo9.js";import{i as as,n as ns,t as is}from"./tooltip-CW50mEoC.js";import{i as H}from"./ToastContext-DyVJ6bCh.js";import{t as ls}from"./agents-B8n-p0aX.js";import{t as rs}from"./projects-l3kQxnTp.js";import{a as ye,i as Ne,n as ve,r as ke,s as we,t as Ce}from"./dialog-CeH7rDcv.js";import{t as L}from"./input-BBNGmECW.js";import{t as K}from"./skeleton-BAAoD7cz.js";import{t as A}from"./tools-MhVvhrz_.js";import{n as os}from"./BreadcrumbContext-DNbB7zWn.js";import{t as cs}from"./toggle-switch-Dj5GORxn.js";import{t as Y}from"./clipboard-CTLKYvRL.js";import{Aa as ds,La as ms,wn as xs}from"./index-QhteFtm-.js";import{a as $,r as Te}from"./shared-B75ClBUg.js";import{_ as us,a as hs,b as oe,c as ps,d as fs,f as Se,g as js,h as O,i as gs,l as bs,o as le,p as Ae,r as U,s as Pe,t as ys,u as ce,v as ie,x as Ns,y as vs}from"./CopyableGatewayUrl-D90Bjxj0.js";var _e={name:"mouse-pointer-2",size:24,node:[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]};_e.node;var ks=qe(_e),o=fe($e(),1),e=fe(Me(),1),ws={cursor:ks,claude_desktop:Be,vscode:Xe,claude_code:ds,opencode:Ue};function Cs({gateway:s,open:a,onOpenChange:i,createdTokens:p,onTokenCreated:c}){const r=V(),{pushToast:y}=H(),u=(0,o.useMemo)(()=>js(s.clientSnippets??[]),[s.clientSnippets]),N=(0,o.useMemo)(()=>`${typeof window<"u"?window.location.origin:""}${s.endpointPath}`,[s.endpointPath]),f=(0,o.useMemo)(()=>p.filter(l=>{const C=s.tokens.find(M=>M.id===l.id),S=ie(C??l);return S==="active"||S==="expiring"}),[p,s.tokens]),k=(0,o.useMemo)(()=>[{id:"tokens",label:"Available this session",options:f.map(l=>({key:l.id,value:l.id,label:l.name,title:l.clientLabel,searchText:`${l.name} ${l.clientLabel} ${l.tokenPrefix}`,token:l}))}],[f]),[j,w]=(0,o.useState)(u[0]?.client??"raw_url"),[h,v]=(0,o.useState)(""),g=f.find(l=>l.id===h)??null;(0,o.useEffect)(()=>{a&&(w(u[0]?.client??"raw_url"),v(l=>f.some(C=>C.id===l)?l:f[0]?.id??""))},[f,a,u]);const d=B({mutationFn:t(()=>{const l=Pe(s);return A.createGatewayToken(s.companyId,s.id,{name:l,clientLabel:l,ownerNote:"",allowedActions:["tools/list","tools/call"],expiresAt:new Date(Date.now()+7776e6).toISOString()})},"mutationFn"),onSuccess:t(async l=>{c(l),v(l.id),y({title:"Token issued",body:"The copy buttons now include its full Authorization header.",tone:"success"}),await r.invalidateQueries({queryKey:U(s.companyId)})},"onSuccess"),onError:t(l=>y({title:"Token was not issued",body:l instanceof Error?l.message:String(l),tone:"error"}),"onError")});async function D(l,C){try{await Y(l),y({title:"Copied",body:C,tone:"success"})}catch(S){y({title:"Copy failed",body:S instanceof Error?S.message:"Clipboard access is unavailable.",tone:"error"})}}t(D,"copyText");const T=u.find(l=>l.client===j)??null,P=T?ce(T.config,{endpointPath:s.endpointPath,endpoint:N,token:g?O(g):"pcgw_•••"}):"",b=T&&g?ce(T.config,{endpointPath:s.endpointPath,endpoint:N,token:g.token}):null;function _(){d.isPending||d.mutate()}return t(_,"issueToken"),(0,e.jsx)(Ce,{open:a,onOpenChange:i,children:(0,e.jsxs)(ve,{className:"sm:max-w-2xl",children:[(0,e.jsxs)(ye,{children:[(0,e.jsxs)(we,{className:"flex items-center gap-2",children:["Client snippets",(0,e.jsxs)(is,{children:[(0,e.jsx)(as,{asChild:!0,children:(0,e.jsx)("button",{type:"button","aria-label":"About client snippets",className:"text-ink-3 hover:text-ink",children:(0,e.jsx)(Ze,{className:"h-4 w-4"})})}),(0,e.jsx)(ns,{className:"max-w-xs text-xs",children:"Give this MCP gateway configuration to your tool. It does not give it access to Wardmote or skills; it only gateways calls between the client and the tools exposed here."})]})]}),(0,e.jsx)(ke,{children:"Choose a client and copy a complete, authenticated configuration."})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line pb-3",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Authorization"}),f.length>0?(0,e.jsx)(Ve,{value:h,groups:k,onValueChange:v,placeholder:"Issue a token",searchPlaceholder:"Search tokens…",emptyMessage:"No copyable tokens.",contentWidth:"auto",triggerClassName:"h-8 w-auto max-w-xs rounded-full px-3",renderValue:t(l=>l?`${l.label} · ${O(l.token)}`:"Issue a token","renderValue"),renderOption:t(l=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:"truncate",children:l.label}),(0,e.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-ink-3",children:O(l.token)})]}),"renderOption"),createItem:{render:t(()=>(0,e.jsx)("span",{children:"+ Issue a new token"}),"render"),onSelect:_}}):(0,e.jsx)(x,{type:"button",variant:"secondary",size:"sm",className:"rounded-full",disabled:d.isPending,onClick:_,children:d.isPending?"Issuing…":"Issue a token"}),g?(0,e.jsxs)(x,{type:"button",variant:"ghost",size:"sm",onClick:t(()=>{D(`Authorization: Bearer ${g.token}`,"Authorization header")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy header"]}):null]}),g?null:(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Issue a token before copying a snippet; the full ",(0,e.jsx)("code",{children:"Authorization: Bearer …"})," header is required. Existing token secrets cannot be retrieved again, so only tokens issued in this page session can fill a snippet."]}),(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-(--gtc-10)",children:[(0,e.jsxs)("nav",{className:"flex gap-1 overflow-x-auto sm:flex-col","aria-label":"Clients",children:[u.map(l=>{const C=ws[l.client];return(0,e.jsxs)("button",{type:"button",onClick:t(()=>w(l.client),"onClick"),className:Q("flex shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm transition-colors",j===l.client?"bg-bg-3 font-medium text-ink":"text-ink-3 hover:bg-bg-3/60"),children:[(0,e.jsx)(C,{className:"h-4 w-4 shrink-0"}),l.label]},l.client)}),(0,e.jsxs)("button",{type:"button",onClick:t(()=>w("raw_url"),"onClick"),className:Q("flex shrink-0 items-center gap-2 rounded-md px-3 py-1.5 text-left text-sm transition-colors",j==="raw_url"?"bg-bg-3 font-medium text-ink":"text-ink-3 hover:bg-bg-3/60"),children:[(0,e.jsx)(es,{className:"h-4 w-4 shrink-0"}),"Raw URL"]})]}),(0,e.jsxs)("div",{className:"min-w-0 space-y-3",children:[j==="raw_url"?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Endpoint URL"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:"min-w-0 flex-1 truncate rounded-md bg-bg-3 px-3 py-2 font-mono text-xs text-ink-3",children:N}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",onClick:t(()=>{D(N,"Endpoint URL")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:"Authorization header"}),(0,e.jsx)("code",{className:"block truncate rounded-md bg-bg-3 px-3 py-2 font-mono text-xs text-ink-3",children:g?`Authorization: Bearer ${O(g)}`:"Authorization: Bearer pcgw_•••"})]})]}):T?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium text-ink",children:T.label}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",disabled:!b,onClick:t(()=>b&&void D(b,`${T.label} config`),"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]}),(0,e.jsx)("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-md bg-bg-3 p-3 font-mono text-xs text-ink-3",children:P}),T.notes.length>0?(0,e.jsx)("ul",{className:"space-y-1 text-xs text-ink-3",children:T.notes.map(l=>(0,e.jsx)("li",{children:l},l))}):null]}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"No client snippets available for this gateway."}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Treat the token like a password. Anyone holding it can call the tools this gateway allows. Revoke it if it leaks."})]})]}),(0,e.jsx)(Ne,{children:(0,e.jsxs)(x,{onClick:t(()=>i(!1),"onClick"),children:[(0,e.jsx)(He,{className:"mr-1.5 h-4 w-4"}),"Done"]})})]})})}t(Cs,"ConnectClientDialog");function Ts({companyId:s,gateway:a,profiles:i,open:p,onOpenChange:c}){const r=V(),{pushToast:y}=H(),[u,N]=(0,o.useState)(a.name),[f,k]=(0,o.useState)(a.description??""),[j,w]=(0,o.useState)(a.profileId);(0,o.useEffect)(()=>{p&&(N(a.name),k(a.description??""),w(a.profileId))},[a,p]);const h=i.filter(d=>d.status!=="archived"),v=B({mutationFn:t(()=>A.updateGateway(s,a.id,{name:u.trim(),description:f.trim()||null,profileId:j}),"mutationFn"),onSuccess:t(async d=>{y({title:"Gateway updated",body:d.name,tone:"success"}),await r.invalidateQueries({queryKey:U(s)}),c(!1)},"onSuccess"),onError:t(d=>{y({title:"Gateway was not updated",body:d instanceof Error?d.message:String(d),tone:"error"})},"onError")});function g(d){d.preventDefault(),!(!u.trim()||!j)&&v.mutate()}return t(g,"submit"),(0,e.jsx)(Ce,{open:p,onOpenChange:c,children:(0,e.jsxs)(ve,{className:"sm:max-w-lg",children:[(0,e.jsxs)(ye,{children:[(0,e.jsx)(we,{children:"Edit gateway"}),(0,e.jsx)(ke,{children:"Change the label or the access profile that controls which tools this endpoint exposes."})]}),(0,e.jsxs)("form",{className:"space-y-4",onSubmit:g,children:[(0,e.jsxs)("label",{className:"block space-y-1.5",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Name"}),(0,e.jsx)(L,{value:u,onChange:t(d=>N(d.target.value),"onChange"),required:!0,autoFocus:!0})]}),(0,e.jsxs)("label",{className:"block space-y-1.5",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Access profile"}),(0,e.jsx)("select",{className:"w-full rounded-md border border-line-strong bg-bg px-3 py-2 text-sm",value:j,onChange:t(d=>w(d.target.value),"onChange"),required:!0,children:h.map(d=>(0,e.jsxs)("option",{value:d.id,children:[d.name," — ",le(d)]},d.id))})]}),(0,e.jsxs)("label",{className:"block space-y-1.5",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Description (optional)"}),(0,e.jsx)("textarea",{className:"min-h-16 w-full rounded-md border border-line-strong bg-bg px-3 py-2 text-sm",value:f,onChange:t(d=>k(d.target.value),"onChange"),placeholder:"Who this endpoint is for."})]}),(0,e.jsxs)(Ne,{children:[(0,e.jsx)(x,{type:"button",variant:"ghost",onClick:t(()=>c(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(x,{type:"submit",disabled:v.isPending||!u.trim()||!j,children:v.isPending?"Saving…":"Save changes"})]})]})]})})}t(Ts,"EditGatewayDialog");function Ss({gateway:s,profile:a,apps:i,agentNames:p,projectNames:c,toggleDisabled:r,onToggle:y}){const{pushToast:u}=H(),N=`${typeof window<"u"?window.location.origin:""}${s.endpointPath}`,f=hs(s),k=bs(s),j=i.filter(g=>g.needsAttention),w=Ae(s),h=["{",' "mcpServers": {',` "wardmote-${s.displaySlug}": {`,` "url": "${N}",`,' "headers": { "Authorization": "Bearer pcgw_•••_TOKEN" }'," }"," }","}"].join(`
|
|
2
2
|
`);async function v(g,d){try{await Y(g),u({title:"Copied",body:d,tone:"success"})}catch{u({title:"Copy failed",body:"Clipboard access is unavailable.",tone:"error"})}}return t(v,"copy"),(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-line p-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-ink-3",children:w?"On":"Off"}),(0,e.jsx)("div",{className:"mt-2",children:(0,e.jsx)(cs,{checked:w,disabled:r,onCheckedChange:y,"aria-label":"Toggle gateway"})}),(0,e.jsx)("p",{className:"mt-2 text-xs text-ink-3",children:"Toggle the whole gateway off here."})]}),(0,e.jsxs)(se,{label:"Apps",children:[i.length," ",i.length===1?"app":"apps",a?` · ${le(a)}`:""]}),(0,e.jsxs)(se,{label:"Tokens",children:[f," active",k>0?` · ${k} expiring`:""]}),(0,e.jsx)(se,{label:"Health",children:j.length===0?"All green":`${j.length} needs attention`})]}),(0,e.jsxs)("section",{className:"rounded-lg border border-line p-4",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Who can use it"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Anyone holding an active token below, restricted by the rules in the bound profile."})]})}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,e.jsxs)(te,{children:["Scope · ",fs(s,c,p)]}),(0,e.jsxs)(te,{children:["Profile · ",a?.name??"Unavailable"]}),(0,e.jsxs)(te,{children:[f," active ",f===1?"token":"tokens"]})]})]}),(0,e.jsxs)("section",{className:"rounded-lg border border-line p-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Apps in this gateway"}),i.length===0?(0,e.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This gateway’s profile doesn’t include any apps yet."}):(0,e.jsx)("ul",{className:"mt-3 divide-y divide-line",children:i.map(g=>(0,e.jsx)(As,{app:g},g.application.id))})]}),(0,e.jsxs)("section",{className:"rounded-lg border border-line bg-bg-3/30 p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"How clients connect"}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",onClick:t(()=>{v(h,"Client config")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]}),(0,e.jsx)("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap break-words rounded bg-bg p-3 font-mono text-xs text-ink-3",children:h})]})]})}t(Ss,"OverviewPanel");function se({label:s,children:a}){return(0,e.jsxs)("div",{className:"rounded-lg border border-line p-4",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-ink-3",children:s}),(0,e.jsx)("div",{className:"mt-2 text-sm font-semibold text-ink",children:a})]})}t(se,"StatCard");function te({children:s}){return(0,e.jsx)("span",{className:"inline-flex items-center rounded-full border border-line px-3 py-1 text-xs font-medium text-ink",children:s})}t(te,"Chip");function As({app:s}){const a=s.connection?`/apps/${s.connection.id}/permissions`:`/apps/app/${s.application.id}/permissions`;return(0,e.jsxs)("li",{className:"flex items-center justify-between gap-3 py-2.5",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)(J,{to:a,className:"font-medium text-ink hover:underline",children:Se(s)}),(0,e.jsxs)("div",{className:"text-xs text-ink-3",children:[s.toolCount," ",s.toolCount===1?"tool":"tools",s.needsAttention&&s.attentionReason?` · ${s.attentionReason}`:""]})]}),(0,e.jsx)("span",{className:Q("shrink-0 rounded-full border px-2 py-0.5 text-xs font-medium",s.needsAttention?"border-ink bg-ink text-bg":"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:s.needsAttention?"Needs attention":"Healthy"})]})}t(As,"AppRow");function Ps({apps:s,profile:a}){return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["These apps go through this gateway. The bound profile",a?` (${a.name})`:""," decides which tools are allowed",a?` — ${le(a)}.`:"."," Change the profile under Advanced."]}),s.length===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed border-line p-6 text-center text-sm text-ink-3",children:"No apps are assigned to this gateway’s profile yet."}):(0,e.jsx)("div",{className:"overflow-x-auto rounded-lg border border-line",children:(0,e.jsxs)("table",{className:"w-full min-w-(--sz-32rem) text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line bg-bg-3/40 text-left text-(length:--text-micro) font-semibold uppercase tracking-wide text-ink-3",children:[(0,e.jsx)("th",{className:"px-4 py-2.5",children:"App"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Tools"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Status"}),(0,e.jsx)("th",{className:"px-4 py-2.5 text-right"})]})}),(0,e.jsx)("tbody",{children:s.map(i=>{const p=i.connection?`/apps/${i.connection.id}/permissions`:`/apps/app/${i.application.id}/permissions`;return(0,e.jsxs)("tr",{className:"border-b border-line last:border-0",children:[(0,e.jsxs)("td",{className:"px-4 py-3",children:[(0,e.jsx)(J,{to:p,className:"font-medium text-ink hover:underline",children:Se(i)}),i.needsAttention&&i.attentionReason?(0,e.jsx)("div",{className:"text-xs text-ink-3",children:i.attentionReason}):null]}),(0,e.jsxs)("td",{className:"px-4 py-3 text-ink-3",children:[i.toolCount," ",i.toolCount===1?"tool":"tools"]}),(0,e.jsx)("td",{className:"px-4 py-3",children:(0,e.jsx)("span",{className:Q("inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium",i.needsAttention?"border-ink bg-ink text-bg":"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"),children:i.needsAttention?"Needs attention":"Healthy"})}),(0,e.jsx)("td",{className:"px-4 py-3 text-right",children:(0,e.jsx)(J,{to:p,className:"text-xs font-medium text-accent hover:underline",children:"Open →"})})]},i.application.id)})})]})})]})}t(Ps,"AppsToolsPanel");var _s=["tools/list","tools/call"],ae=10;function de(){return new Date(Date.now()+7776e6).toISOString().slice(0,10)}t(de,"defaultExpiry");var Es={active:"border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",expiring:"border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300",expired:"border-line bg-bg-3 text-ink-3",revoked:"border-ink bg-ink text-bg"};function me({status:s}){return(0,e.jsx)("span",{className:Q("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-xs font-medium",Es[s]),children:gs[s]})}t(me,"StatusBadge");function Z({label:s,value:a}){return(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("dt",{className:"text-(length:--text-micro) font-semibold uppercase tracking-wide text-ink-3",children:s}),(0,e.jsx)("dd",{className:"mt-0.5 truncate text-ink",children:a})]})}t(Z,"TokenField");function xe({token:s}){const a=us(s.expiresAt);return a?a.getTime()<=Date.now()?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:"Expired"})," ",(0,e.jsx)($,{value:s.expiresAt})]}):(0,e.jsxs)(e.Fragment,{children:["Expires ",(0,e.jsx)($,{value:s.expiresAt})]}):(0,e.jsx)(e.Fragment,{children:"No expiry"})}t(xe,"ExpiryValue");function Ds({companyId:s,gateway:a,onTokenCreated:i}){const p=V(),{pushToast:c}=H(),[r,y]=(0,o.useState)(!1),[u,N]=(0,o.useState)(""),[f,k]=(0,o.useState)(""),[j,w]=(0,o.useState)(de()),[h,v]=(0,o.useState)(null),[g,d]=(0,o.useState)(!1),[D,T]=(0,o.useState)(!1),[P,b]=(0,o.useState)(1),[_,l]=(0,o.useState)(""),[C,S]=(0,o.useState)(null),M=t(()=>p.invalidateQueries({queryKey:U(s)}),"invalidate"),I=(0,o.useMemo)(()=>[...a.tokens].sort((n,E)=>new Date(E.createdAt).getTime()-new Date(n.createdAt).getTime()),[a.tokens]),m=Math.max(1,Math.ceil(I.length/ae)),q=I.slice((P-1)*ae,P*ae);(0,o.useEffect)(()=>{b(n=>Math.min(n,m))},[m]);const W=B({mutationFn:t(()=>A.createGatewayToken(s,a.id,{name:u.trim(),clientLabel:u.trim(),ownerNote:f.trim(),allowedActions:_s,expiresAt:j?`${j}T23:59:59.000Z`:null}),"mutationFn"),onSuccess:t(async n=>{v(n),d(!0),y(!1),N(""),k(""),w(de()),c({title:"Token issued",body:"Copy it now — you won’t see the full value again after leaving this page.",tone:"success"}),i?.(n),await M()},"onSuccess"),onError:t(n=>c({title:"Token was not issued",body:n instanceof Error?n.message:String(n),tone:"error"}),"onError")}),ee=B({mutationFn:t(n=>A.revokeGatewayToken(s,n),"mutationFn"),onSuccess:t(async n=>{S(null),l(""),c({title:"Token revoked",body:`${n.name} can no longer connect.`,tone:"success"}),await M()},"onSuccess"),onError:t(n=>c({title:"Token was not revoked",body:n instanceof Error?n.message:String(n),tone:"error"}),"onError")});async function Ee(n){try{await Y(n),c({title:"Copied",body:"Access token",tone:"success"})}catch(E){c({title:"Copy failed",body:E instanceof Error?E.message:"Clipboard access is unavailable.",tone:"error"})}}t(Ee,"copyToken");function De(){!r&&!u.trim()&&N(Pe(a)),y(n=>!n)}t(De,"startIssuing");function Ie(n){n.preventDefault(),u.trim()&&W.mutate()}t(Ie,"submit");function re(n){S({id:n.id,name:n.name}),l("")}return t(re,"startRevoke"),(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"max-w-2xl space-y-1",children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Issue a reusable token for an external client. Its name is also used as the client label."}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Wardmote creates a fresh one-hour runtime token when an agent run starts, then revokes it when the run ends. Codex can receive the same gateway through both an app connection and the managed-gateway path, so one run may leave two revoked rows. These are audit history, not repeated manual tokens."})]}),(0,e.jsxs)(x,{size:"sm",onClick:De,children:[(0,e.jsx)(ss,{className:"mr-1.5 h-3.5 w-3.5"}),"Issue token"]})]}),r?(0,e.jsxs)("form",{className:"space-y-3",onSubmit:Ie,children:[(0,e.jsxs)("div",{className:"grid gap-3 md:grid-cols-[1fr_auto]",children:[(0,e.jsxs)("label",{className:"space-y-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Token name"}),(0,e.jsx)(L,{value:u,onChange:t(n=>N(n.target.value),"onChange"),required:!0,autoFocus:!0}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Also used as the client label."})]}),(0,e.jsxs)("label",{className:"space-y-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Expires"}),(0,e.jsx)(L,{type:"date",value:j,onChange:t(n=>w(n.target.value),"onChange"),required:!0})]})]}),(0,e.jsxs)("label",{className:"block space-y-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:"Owner note (optional)"}),(0,e.jsx)(L,{value:f,onChange:t(n=>k(n.target.value),"onChange"),placeholder:"Who uses this token or why it exists"})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)(x,{type:"button",variant:"ghost",size:"sm",onClick:t(()=>y(!1),"onClick"),children:"Cancel"}),(0,e.jsx)(x,{type:"submit",size:"sm",disabled:W.isPending||!u.trim(),children:W.isPending?"Issuing…":"Issue token"})]})]}):null,h?(0,e.jsxs)("div",{className:"space-y-2 border-y border-line py-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-sm font-semibold text-ink",children:"New token — copy now"}),(0,e.jsx)("div",{className:"text-xs text-ink-3",children:"It is now available in Client snippets for a copy-ready configuration."})]}),(0,e.jsx)(x,{variant:"ghost",size:"sm",onClick:t(()=>v(null),"onClick"),"aria-label":"Dismiss new token",children:"Dismiss"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:"min-w-0 flex-1 truncate rounded bg-bg-3 px-3 py-2 font-mono text-xs text-ink",children:g?h.token:O(h)}),g?(0,e.jsxs)(x,{variant:"secondary",size:"sm",onClick:t(()=>{Ee(h.token)},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]}):(0,e.jsx)(x,{variant:"secondary",size:"sm",onClick:t(()=>d(!0),"onClick"),children:"Show"})]})]}):null,(0,e.jsxs)(Qe,{open:D,onOpenChange:T,children:[(0,e.jsx)(Ke,{asChild:!0,children:(0,e.jsxs)(x,{variant:"ghost",className:"h-auto w-full justify-between px-0 py-1 hover:bg-transparent",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold text-ink",children:[(0,e.jsx)(Ye,{className:"h-4 w-4 text-ink-3"}),"Token history",(0,e.jsx)("span",{className:"font-normal text-ink-3",children:I.length})]}),D?(0,e.jsx)(Je,{className:"h-4 w-4"}):(0,e.jsx)(ge,{className:"h-4 w-4"})]})}),(0,e.jsx)(Le,{className:"space-y-3 pt-3",children:I.length===0?(0,e.jsx)("p",{className:"py-4 text-sm text-ink-3",children:"No tokens have been issued for this gateway."}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"hidden overflow-x-auto rounded-lg border border-line sm:block",children:(0,e.jsxs)("table",{className:"w-full min-w-(--sz-44rem) text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line bg-bg-3/40 text-left text-(length:--text-micro) font-semibold uppercase tracking-wide text-ink-3",children:[(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Token"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Owner"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Created"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Last used"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Expiry"}),(0,e.jsx)("th",{className:"px-4 py-2.5",children:"Status"}),(0,e.jsx)("th",{className:"px-4 py-2.5 text-right"})]})}),(0,e.jsx)("tbody",{children:q.map(n=>{const E=ie(n);return(0,e.jsxs)("tr",{className:"border-b border-line last:border-0",children:[(0,e.jsxs)("td",{className:"px-4 py-3",children:[(0,e.jsx)("div",{className:"font-medium text-ink",children:n.name}),(0,e.jsx)("div",{className:"font-mono text-xs text-ink-3",children:O(n)})]}),(0,e.jsx)("td",{className:"px-4 py-3 text-ink-3",children:n.clientLabel||n.ownerNote||"—"}),(0,e.jsx)("td",{className:"px-4 py-3 text-ink-3",children:(0,e.jsx)($,{value:n.createdAt})}),(0,e.jsx)("td",{className:"px-4 py-3 text-ink-3",children:n.lastUsedAt?(0,e.jsx)($,{value:n.lastUsedAt}):"—"}),(0,e.jsx)("td",{className:"px-4 py-3 text-ink-3",children:(0,e.jsx)(xe,{token:n})}),(0,e.jsx)("td",{className:"px-4 py-3",children:(0,e.jsx)(me,{status:E})}),(0,e.jsx)("td",{className:"px-4 py-3 text-right",children:E!=="revoked"?(0,e.jsx)(x,{variant:"danger",size:"sm",className:"h-7 px-2 text-xs",onClick:t(()=>re(n),"onClick"),children:"Revoke"}):null})]},n.id)})})]})}),(0,e.jsx)("div",{className:"space-y-3 sm:hidden",children:q.map(n=>{const E=ie(n);return(0,e.jsxs)("div",{className:"border-b border-line py-3 last:border-0",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"font-medium text-ink",children:n.name}),(0,e.jsx)("div",{className:"font-mono text-xs text-ink-3",children:O(n)})]}),(0,e.jsx)(me,{status:E})]}),(0,e.jsxs)("dl",{className:"mt-3 grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[(0,e.jsx)(Z,{label:"Owner",value:n.clientLabel||n.ownerNote||"—"}),(0,e.jsx)(Z,{label:"Created",value:(0,e.jsx)($,{value:n.createdAt})}),(0,e.jsx)(Z,{label:"Last used",value:n.lastUsedAt?(0,e.jsx)($,{value:n.lastUsedAt}):"—"}),(0,e.jsx)(Z,{label:"Expiry",value:(0,e.jsx)(xe,{token:n})})]}),E!=="revoked"?(0,e.jsx)(x,{variant:"danger",size:"sm",className:"mt-3 w-full text-xs",onClick:t(()=>re(n),"onClick"),children:"Revoke"}):null]},n.id)})}),m>1?(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Page ",P," of ",m," · ",I.length," tokens"]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(x,{variant:"ghost",size:"sm",disabled:P===1,onClick:t(()=>b(n=>Math.max(1,n-1)),"onClick"),"aria-label":"Previous token page",children:(0,e.jsx)(We,{className:"h-4 w-4"})}),(0,e.jsx)(x,{variant:"ghost",size:"sm",disabled:P===m,onClick:t(()=>b(n=>Math.min(m,n+1)),"onClick"),"aria-label":"Next token page",children:(0,e.jsx)(be,{className:"h-4 w-4"})})]})]}):null]})})]}),C?(0,e.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true",children:(0,e.jsxs)("div",{className:"w-full max-w-md space-y-3 rounded-lg border border-line bg-bg-2 p-5 shadow-lg",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Revoke this token?"}),(0,e.jsxs)("p",{className:"mt-1 text-sm text-ink-3",children:["Any client using ",(0,e.jsx)("span",{className:"font-medium text-ink",children:C.name})," goes silent immediately. This can’t be undone. Type the token name to confirm."]})]}),(0,e.jsx)(L,{value:_,onChange:t(n=>l(n.target.value),"onChange"),placeholder:C.name,"aria-label":"Type the token name to confirm",autoFocus:!0}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)(x,{variant:"ghost",size:"sm",onClick:t(()=>{S(null),l("")},"onClick"),children:"Cancel"}),(0,e.jsx)(x,{variant:"danger",size:"sm",disabled:_.trim()!==C.name||ee.isPending,onClick:t(()=>ee.mutate(C.id),"onClick"),children:ee.isPending?"Revoking…":"Revoke token"})]})]})}):null]})}t(Ds,"TokensPanel");var Is=25,ue={allowed:{label:"Allowed",status:"allowed"},blocked:{label:"Blocked",status:"denied"},asked_first:{label:"Asked first",status:"require-approval"},waiting:{label:"Waiting",status:"deferred"},failed:{label:"Failed",status:"failed"},unknown:{label:"Recorded",status:"unchecked"}};function ne(s,a){const i=s?.[a];return typeof i=="string"&&i.trim().length>0?i:null}t(ne,"detailString");function he(s){if(!s?.summary)return null;try{return JSON.stringify(JSON.parse(s.summary),null,2)}catch{return s.summary}}t(he,"formatSummary");function pe(s,a){const i=s?.[a];if(!i||typeof i!="object"||Array.isArray(i))return null;const p=i.summary;return typeof p=="string"?{summary:p}:null}t(pe,"summaryFromDetails");function zs(s){const a=s.invocation?.startedAt?new Date(s.invocation.startedAt).getTime():NaN,i=s.invocation?.completedAt?new Date(s.invocation.completedAt).getTime():NaN;return!Number.isFinite(a)||!Number.isFinite(i)||i<a?null:`${i-a} ms`}t(zs,"durationLabel");function z({label:s,value:a,mono:i=!1}){return(0,e.jsxs)("div",{className:"flex gap-3 py-1",children:[(0,e.jsx)("dt",{className:"w-28 shrink-0 text-ink-3",children:s}),(0,e.jsx)("dd",{className:i?"min-w-0 break-all font-mono text-(length:--text-micro) text-ink":"min-w-0 text-ink",children:a})]})}t(z,"Fact");function Ms({event:s}){const[a,i]=(0,o.useState)(!1),p=ue[s.normalizedOutcome]??ue.unknown,c=s.agentDisplayName??"Client",r=s.appDisplayName??s.connectionDisplayName??s.applicationDisplayName??"App",y=s.toolDisplayName??s.invocation?.toolName??"Tool call",u=s.invocation?.toolName??ne(s.details,"tool")??ne(s.details,"toolName"),N=ne(s.details,"reasonCode"),f=he(s.invocation?.argumentsSummary??pe(s.details,"argumentsSummary")),k=he(s.invocation?.resultSummary??pe(s.details,"resultSummary")),j=zs(s);return(0,e.jsxs)("li",{className:"text-sm",children:[(0,e.jsxs)("button",{type:"button",onClick:t(()=>i(w=>!w),"onClick"),className:"flex w-full items-start gap-2.5 px-4 py-3 text-left hover:bg-bg-3/50","aria-expanded":a,children:[a?(0,e.jsx)(ge,{className:"mt-0.5 h-4 w-4 shrink-0 text-ink-3"}):(0,e.jsx)(be,{className:"mt-0.5 h-4 w-4 shrink-0 text-ink-3"}),(0,e.jsx)("span",{className:"min-w-0 flex-1",children:(0,e.jsxs)("span",{className:"block text-ink",children:[(0,e.jsx)("span",{className:"font-medium",children:c})," used ",(0,e.jsx)("span",{className:"font-medium",children:y})," in ",r]})}),(0,e.jsxs)("span",{className:"flex shrink-0 items-center gap-2 whitespace-nowrap",children:[(0,e.jsx)(xs,{status:p.status,label:p.label}),(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["· ",(0,e.jsx)($,{value:s.createdAt})]})]})]}),a?(0,e.jsxs)("div",{className:"border-t border-line bg-bg-3/30 px-4 py-3 pl-10 text-xs",children:[(0,e.jsxs)("dl",{children:[u?(0,e.jsx)(z,{label:"Tool",value:u,mono:!0}):null,s.invocation?.status?(0,e.jsx)(z,{label:"Call status",value:s.invocation.status}):null,s.invocation?.policyDecision?(0,e.jsx)(z,{label:"Decision",value:s.invocation.policyDecision}):null,N?(0,e.jsx)(z,{label:"Reason",value:N,mono:!0}):null,j?(0,e.jsx)(z,{label:"Duration",value:j}):null,s.invocation?.id?(0,e.jsx)(z,{label:"Invocation ID",value:s.invocation.id,mono:!0}):null,s.invocation?.errorCode?(0,e.jsx)(z,{label:"Error code",value:s.invocation.errorCode,mono:!0}):null,s.invocation?.errorMessage?(0,e.jsx)(z,{label:"Error",value:s.invocation.errorMessage}):null]}),f?(0,e.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,e.jsx)("div",{className:"text-ink-3",children:"Arguments (redacted)"}),(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-ink",children:f})]}):null,k?(0,e.jsxs)("div",{className:"mt-3 space-y-1",children:[(0,e.jsx)("div",{className:"text-ink-3",children:"Result (redacted)"}),(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-ink",children:k})]}):null]}):null]})}t(Ms,"ActivityRow");function qs({companyId:s,gateway:a}){const i=Fe({queryKey:R.tools.activity(s,{gateway:a.id,window:"30d"}),queryFn:t(({pageParam:c})=>A.listActivity(s,{gateway:a.id,window:"30d",limit:Is,cursor:c??void 0}),"queryFn"),initialPageParam:null,getNextPageParam:t(c=>c.nextCursor??void 0,"getNextPageParam")}),p=(0,o.useMemo)(()=>i.data?.pages.flatMap(c=>c.events)??[],[i.data]);return i.isLoading?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(K,{className:"h-12 w-full"}),(0,e.jsx)(K,{className:"h-12 w-full"}),(0,e.jsx)(K,{className:"h-12 w-full"})]}):i.isError?(0,e.jsx)(Te,{error:i.error,onRetry:t(()=>i.refetch(),"onRetry")}):(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Calls through this gateway from the last 30 days. Open a row to inspect its tool, redacted arguments, result, and decision."}),p.length===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed border-line p-6 text-center text-sm text-ink-3",children:"No calls have gone through this gateway yet."}):(0,e.jsx)("ul",{className:"divide-y divide-line rounded-lg border border-line",children:p.map(c=>(0,e.jsx)(Ms,{event:c},c.id))}),i.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center",children:(0,e.jsx)(x,{variant:"secondary",size:"sm",onClick:t(()=>i.fetchNextPage(),"onClick"),disabled:i.isFetchingNextPage,children:i.isFetchingNextPage?"Loading…":"Load more"})}):null]})}t(qs,"GatewayActivityPanel");function $s({companyId:s,gateway:a}){const i=V(),p=je(),{pushToast:c}=H(),[r,y]=(0,o.useState)(!1),[u,N]=(0,o.useState)(""),f=`${typeof window<"u"?window.location.origin:""}${a.endpointPath}`,k=JSON.stringify({gatewayPublicId:a.gatewayPublicId,displaySlug:a.displaySlug,status:a.status,profileId:a.profileId,defaultProfileMode:a.defaultProfileMode,contextScopeType:a.contextScopeType,contextScopeId:a.contextScopeId,endpointPath:a.endpointPath,authConfig:a.authConfig,headerPolicy:a.headerPolicy,metadataPolicy:a.metadataPolicy,onDemandToolsConfig:a.onDemandToolsConfig},null,2),j=B({mutationFn:t(()=>A.updateGateway(s,a.id,{status:"archived"}),"mutationFn"),onSuccess:t(async()=>{c({title:"Gateway archived",body:`${a.name} is no longer reachable.`,tone:"success"}),await i.invalidateQueries({queryKey:U(s)}),p("/apps/gateways")},"onSuccess"),onError:t(h=>c({title:"Couldn't archive the gateway",body:h instanceof Error?h.message:String(h),tone:"error"}),"onError")});async function w(h,v){try{await Y(h),c({title:"Copied",body:v,tone:"success"})}catch{c({title:"Copy failed",body:"Clipboard access is unavailable.",tone:"error"})}}return t(w,"copy"),(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Transport"}),(0,e.jsxs)("dl",{className:"grid gap-x-6 gap-y-2 text-sm sm:grid-cols-2",children:[(0,e.jsx)(X,{label:"Transport",value:"streamable_http"}),(0,e.jsx)(X,{label:"Authentication",value:"bearer"}),(0,e.jsx)(X,{label:"Protocol version",value:"2025-03-26"}),(0,e.jsx)(X,{label:"Public ID",value:a.gatewayPublicId,mono:!0})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("code",{className:"min-w-0 flex-1 truncate rounded-md bg-bg-3 px-3 py-2 font-mono text-xs text-ink-3",children:f}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",onClick:t(()=>{w(f,"Endpoint URL")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]})]}),(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-ink",children:"Raw configuration"}),(0,e.jsxs)(x,{variant:"secondary",size:"sm",onClick:t(()=>{w(k,"Gateway config JSON")},"onClick"),children:[(0,e.jsx)(F,{className:"mr-1 h-3.5 w-3.5"}),"Copy JSON"]})]}),(0,e.jsx)("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md bg-bg-3 p-3 font-mono text-xs text-ink-3",children:k})]}),(0,e.jsxs)("section",{className:"space-y-2 rounded-lg border border-bad/40 p-4",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold text-bad",children:"Danger zone"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Archiving takes the gateway offline for every client. Existing tokens stop working. Type the gateway name to confirm."}),r?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(L,{value:u,onChange:t(h=>N(h.target.value),"onChange"),placeholder:a.name,"aria-label":"Type the gateway name to confirm archive"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(x,{variant:"danger",size:"sm",disabled:u.trim()!==a.name||j.isPending,onClick:t(()=>j.mutate(),"onClick"),children:j.isPending?"Archiving…":"Archive gateway"}),(0,e.jsx)(x,{variant:"ghost",size:"sm",onClick:t(()=>{y(!1),N("")},"onClick"),children:"Cancel"})]})]}):(0,e.jsx)(x,{variant:"danger",size:"sm",onClick:t(()=>y(!0),"onClick"),children:"Archive gateway"})]})]})}t($s,"GatewayAdvancedPanel");function X({label:s,value:a,mono:i}){return(0,e.jsxs)("div",{children:[(0,e.jsx)("dt",{className:"text-xs font-medium text-ink-3",children:s}),(0,e.jsx)("dd",{className:i?"mt-0.5 font-mono text-ink":"mt-0.5 text-ink",children:a})]})}t(X,"Row");function kt(){const{gatewayId:s="",tab:a}=Oe(),i=je(),p=V(),{pushToast:c}=H(),{selectedCompanyId:r}=Ge(),{setBreadcrumbs:y}=os(),[u,N]=(0,o.useState)(!1),[f,k]=(0,o.useState)(!1),[j,w]=(0,o.useState)([]),h=Ns(a)?a:null,v=G({queryKey:U(r??"__none__"),queryFn:t(()=>A.listGateways(r),"queryFn"),enabled:!!r}),g=G({queryKey:R.tools.profiles(r??"__none__"),queryFn:t(()=>A.listProfiles(r),"queryFn"),enabled:!!r}),d=G({queryKey:R.tools.connections(r??"__none__"),queryFn:t(()=>A.listConnections(r),"queryFn"),enabled:!!r}),D=G({queryKey:R.tools.applications(r??"__none__"),queryFn:t(()=>A.listApplications(r),"queryFn"),enabled:!!r}),T=G({queryKey:R.agents.list(r??"__none__"),queryFn:t(()=>ls.list(r),"queryFn"),enabled:!!r}),P=G({queryKey:R.projects.list(r??"__none__",{includeArchived:!0}),queryFn:t(()=>rs.list(r,{includeArchived:!0}),"queryFn"),enabled:!!r}),b=(0,o.useMemo)(()=>(v.data?.gateways??[]).find(m=>m.id===s),[v.data,s]),_=(0,o.useMemo)(()=>(g.data?.profiles??[]).find(m=>m.id===b?.profileId),[g.data,b?.profileId]),l=(0,o.useMemo)(()=>ps(_,D.data?.applications??[],d.data?.connections??[]),[_,D.data,d.data]),C=(0,o.useMemo)(()=>new Map((T.data??[]).map(m=>[m.id,m.name])),[T.data]),S=(0,o.useMemo)(()=>new Map((P.data??[]).map(m=>[m.id,m.name])),[P.data]);function M(m){w(q=>[m,...q.filter(W=>W.id!==m.id)])}t(M,"rememberCreatedToken"),(0,o.useEffect)(()=>{if(b)return y([{label:"Connectors",href:"/apps"},{label:"Gateways",href:"/apps/gateways"},{label:b.name}]),()=>y([])},[y,b]);const I=B({mutationFn:t(()=>A.updateGateway(r,s,{status:b&&Ae(b)?"disabled":"active"}),"mutationFn"),onSuccess:t(async m=>{c({title:m.status==="active"?"Gateway on":"Gateway off",body:m.status==="active"?`${m.name} is exposing its tools again.`:`${m.name} is off — every client goes silent.`,tone:"success"}),await p.invalidateQueries({queryKey:U(r)})},"onSuccess"),onError:t(m=>c({title:"Couldn't update the gateway",body:m instanceof Error?m.message:String(m),tone:"error"}),"onError")});return r?h?v.isLoading?(0,e.jsxs)("div",{className:"max-w-4xl space-y-4",children:[(0,e.jsx)(K,{className:"h-10 w-64"}),(0,e.jsx)(K,{className:"h-9 w-full max-w-lg"}),(0,e.jsx)(K,{className:"h-64 w-full"})]}):v.isError?(0,e.jsx)(Te,{error:v.error,onRetry:t(()=>v.refetch(),"onRetry")}):b?(0,e.jsxs)("div",{className:"max-w-4xl space-y-5 pb-12",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-xs text-ink-3",children:(0,e.jsx)(J,{to:"/apps/gateways",className:"hover:underline",children:"Apps · Gateways"})}),(0,e.jsx)("h1",{className:"mt-1 text-2xl font-bold tracking-tight",children:b.name}),(0,e.jsx)(ys,{endpointPath:b.endpointPath,className:"mt-1 max-w-xl"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsxs)(x,{variant:"secondary",onClick:t(()=>k(!0),"onClick"),children:[(0,e.jsx)(ms,{className:"mr-1.5 h-4 w-4"}),"Edit"]}),(0,e.jsxs)(x,{onClick:t(()=>N(!0),"onClick"),children:[(0,e.jsx)(ts,{className:"mr-1.5 h-4 w-4"}),"Client snippets"]})]})]}),(0,e.jsx)("nav",{className:"flex items-center gap-6 overflow-x-auto border-b border-line text-sm","aria-label":"Gateway tabs",children:vs.map(m=>{const q=m.key===h;return(0,e.jsx)(J,{to:oe(s,m.key),className:Q("-mb-px shrink-0 border-b-2 pb-2.5 pt-1 font-medium transition-colors",q?"border-ink text-ink":"border-transparent text-ink-3 hover:text-ink"),"aria-current":q?"page":void 0,children:m.label},m.key)})}),h==="overview"&&(0,e.jsx)(Ss,{gateway:b,profile:_,apps:l,agentNames:C,projectNames:S,toggleDisabled:I.isPending,onToggle:t(()=>I.mutate(),"onToggle")}),h==="apps"&&(0,e.jsx)(Ps,{apps:l,profile:_}),h==="tokens"&&(0,e.jsx)(Ds,{companyId:r,gateway:b,onTokenCreated:M}),h==="activity"&&(0,e.jsx)(qs,{companyId:r,gateway:b}),h==="advanced"&&(0,e.jsx)($s,{companyId:r,gateway:b}),(0,e.jsx)(Cs,{gateway:b,open:u,onOpenChange:N,createdTokens:j,onTokenCreated:M}),(0,e.jsx)(Ts,{companyId:r,gateway:b,profiles:g.data?.profiles??[],open:f,onOpenChange:k})]}):(0,e.jsxs)("div",{className:"max-w-3xl p-6",children:[(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"We couldn’t find that gateway."}),(0,e.jsx)(x,{className:"mt-4",variant:"secondary",onClick:t(()=>i("/apps/gateways"),"onClick"),children:"Back to gateways"})]}):(0,e.jsx)(Re,{replace:!0,to:oe(s,"overview")}):(0,e.jsx)("div",{className:"p-6 text-sm text-ink-3",children:"Select an organization to manage gateways."})}t(kt,"GatewayDetail");export{kt as GatewayDetail};
|