@tickernelz/wardmote-ui 2026.1117.3 → 2026.1117.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdapterManager-C59AKY0f.js → AdapterManager-Dn6r8M3v.js} +1 -1
- package/dist/assets/{AdvancedToolsRoute-Bg4KowJU.js → AdvancedToolsRoute-tleFHTcB.js} +1 -1
- package/dist/assets/{AgentActionButtons-BBhJXLbY.js → AgentActionButtons-Dd6alMqq.js} +1 -1
- package/dist/assets/{AgentChat--rcr73Ls.js → AgentChat-BHjA0PWW.js} +1 -1
- package/dist/assets/{AgentChats-56CMlXmb.js → AgentChats-IEiJJtdg.js} +1 -1
- package/dist/assets/{AgentDetail-NfA1gamX.js → AgentDetail-D7joo2rc.js} +1 -1
- package/dist/assets/{AgentTodoCard-CGUyYht3.js → AgentTodoCard-Brh8SSVE.js} +1 -1
- package/dist/assets/{Agents-BjPLaL-p.js → Agents-hJqeQN6A.js} +3 -3
- package/dist/assets/{AppDetail-CwyYWsvw.js → AppDetail-B8ZBWzk8.js} +1 -1
- package/dist/assets/{AppNotConnected-DzDZR0-8.js → AppNotConnected-NVgEwEYJ.js} +1 -1
- package/dist/assets/{ApprovalCard-DyxP9tMM.js → ApprovalCard-DTIm5U9W.js} +1 -1
- package/dist/assets/{ApprovalDetail-Cxhx_U0d.js → ApprovalDetail-eGGSB0_Q.js} +1 -1
- package/dist/assets/{ApprovalPayload-C7jnoOLa.js → ApprovalPayload-m4AnE9rE.js} +1 -1
- package/dist/assets/{Approvals-CF4K0bD1.js → Approvals-Zxq0yDz0.js} +1 -1
- package/dist/assets/{AppsReview-Chv6Jms5.js → AppsReview-BlGCgr9w.js} +1 -1
- package/dist/assets/{ArtifactCard-CAlD_gkp.js → ArtifactCard-pKhZhgLB.js} +1 -1
- package/dist/assets/{Artifacts-47GmGXVx.js → Artifacts-BvvQffcj.js} +1 -1
- package/dist/assets/{AssistantConnection-BCrEgmJR.js → AssistantConnection-XWq_Gvxh.js} +1 -1
- package/dist/assets/{AttentionInteractionResolver-DUg8FwhJ.js → AttentionInteractionResolver-BmiwiFlx.js} +1 -1
- package/dist/assets/{AuditHub-DNmGrEzV.js → AuditHub-DCksM6Df.js} +1 -1
- package/dist/assets/{BoardChat-BenJSqr6.js → BoardChat-Bp_P56xH.js} +1 -1
- package/dist/assets/{BootstrapSetupUxLab-DO03bmwI.js → BootstrapSetupUxLab-CcxoPa2W.js} +1 -1
- package/dist/assets/{Browse-gMVDtSCz.js → Browse-DQJ6Gj80.js} +1 -1
- package/dist/assets/{BudgetPolicyCard-CbkwslmQ.js → BudgetPolicyCard-D-aZ30F6.js} +1 -1
- package/dist/assets/{CaseDetail-k79_F25A.js → CaseDetail-CYIIqjOz.js} +1 -1
- package/dist/assets/{Cases-C5IE_YuB.js → Cases-Bd2Ckeh9.js} +1 -1
- package/dist/assets/{ChatEndpointDetail-DPiCCvto.js → ChatEndpointDetail-DdbIST5k.js} +1 -1
- package/dist/assets/{ChatEndpointSetup-CTntfzjg.js → ChatEndpointSetup-BZGnK0W7.js} +1 -1
- package/dist/assets/{Companies-Cr0mZy2B.js → Companies-CQ_mUV6-.js} +1 -1
- package/dist/assets/{CompanyAccess-BQZD0MZf.js → CompanyAccess-CZAfSbtD.js} +1 -1
- package/dist/assets/{CompanyActivity-BhNtXl8c.js → CompanyActivity-CBwdj3In.js} +1 -1
- package/dist/assets/{CompanyConnections-BwCkXXZK.js → CompanyConnections-D7x76vZy.js} +1 -1
- package/dist/assets/{CompanyEnvironments-CyrghjsN.js → CompanyEnvironments-fJh3Mt-u.js} +1 -1
- package/dist/assets/{CompanyExport-BlQuIvDU.js → CompanyExport-B9FgX5uJ.js} +1 -1
- package/dist/assets/{CompanyImport-5M7yWHR-.js → CompanyImport-D3UlNq4i.js} +1 -1
- package/dist/assets/{CompanySettings-C6FNik3j.js → CompanySettings-D4-cqzil.js} +1 -1
- package/dist/assets/{CompanySettingsPluginPage-DPHNF4sp.js → CompanySettingsPluginPage-DQeyVIjI.js} +1 -1
- package/dist/assets/{CompanySkills-DsgjKlp7.js → CompanySkills-Doub2oUz.js} +1 -1
- package/dist/assets/{ConfigureBuiltInAgentModal-reyr1Tds.js → ConfigureBuiltInAgentModal-CHCXXZ3A.js} +1 -1
- package/dist/assets/{CopyableGatewayUrl-B4EYBk9t.js → CopyableGatewayUrl-DtEeRG6_.js} +1 -1
- package/dist/assets/{Dashboard-B0JjQSAg.js → Dashboard-b22e7HsQ.js} +1 -1
- package/dist/assets/{DecisionDateChips-BaRZkOU2.js → DecisionDateChips-BPqVvaQ7.js} +1 -1
- package/dist/assets/{DecisionQueuePage-DtzH_oQI.js → DecisionQueuePage-BxiBix3d.js} +1 -1
- package/dist/assets/{DesignGuide-CXHLyL_C.js → DesignGuide-5uuu_1IQ.js} +1 -1
- package/dist/assets/{EmailEndpointSetup-hb_Hewoa.js → EmailEndpointSetup-FXzIFk9y.js} +1 -1
- package/dist/assets/{ExecutionWorkspaceDetail-BxA_kWKs.js → ExecutionWorkspaceDetail-2AFXb_-1.js} +1 -1
- package/dist/assets/{GatewayDetail-CUcpw4Hj.js → GatewayDetail-BRId71b2.js} +1 -1
- package/dist/assets/{GatewaysList-Ad1dZuwC.js → GatewaysList-BgwbsqYZ.js} +1 -1
- package/dist/assets/{GoalDetail-C-uH9eNu.js → GoalDetail-C8NwbVu0.js} +1 -1
- package/dist/assets/{GoalTree-BZUt4xZ3.js → GoalTree-BF1J-Wd-.js} +1 -1
- package/dist/assets/{Goals-UrfBAjOT.js → Goals-BWNWwYmd.js} +1 -1
- package/dist/assets/{ImageGalleryModal-D3SH_FYj.js → ImageGalleryModal-B_H2699L.js} +1 -1
- package/dist/assets/{Inbox-BzkFmAxU.js → Inbox-cm1ulHkR.js} +1 -1
- package/dist/assets/{InstanceAdvanced-DYZ50o97.js → InstanceAdvanced-DHBs71Ii.js} +1 -1
- package/dist/assets/{InviteLanding-Bqp1ulQV.js → InviteLanding-DTNcs2-Z.js} +1 -1
- package/dist/assets/{IssueChatLongThreadPerf-BJ_Hr2PT.js → IssueChatLongThreadPerf-Bw21NogO.js} +1 -1
- package/dist/assets/{IssueChatThread-qDc-9yA9.js → IssueChatThread-aO8MN-x0.js} +1 -1
- package/dist/assets/{IssueDetail-C0hCFL-i.js → IssueDetail-BTGIxWc1.js} +1 -1
- package/dist/assets/{IssueOutputSection-D7QbMiqq.js → IssueOutputSection-EDMuhye2.js} +1 -1
- package/dist/assets/{IssueRecoveryActionCard-DeJbfGm1.js → IssueRecoveryActionCard-DgG9K5yf.js} +1 -1
- package/dist/assets/{IssueReferencePill-BTH42QmE.js → IssueReferencePill-eeVd9x72.js} +1 -1
- package/dist/assets/{IssueThreadInteractionCard-D9QAYhuJ.js → IssueThreadInteractionCard-C8Bu2LL1.js} +1 -1
- package/dist/assets/{Issues-DtYFX9i_.js → Issues-B4mFVMjr.js} +1 -1
- package/dist/assets/{LiveNowTodoLine-IsmhMx5O.js → LiveNowTodoLine-BaBvpVxD.js} +1 -1
- package/dist/assets/{ManagedAiConnectionDetails-BrX9Q9t2.js → ManagedAiConnectionDetails-CFL872M2.js} +1 -1
- package/dist/assets/{McpConnect-BYYMfbhs.js → McpConnect-Dqx0rBQk.js} +1 -1
- package/dist/assets/{MembershipAction-Esk0pndF.js → MembershipAction-Cn7I3sEB.js} +1 -1
- package/dist/assets/{ModelsAndProviders-C7VZHvPR.js → ModelsAndProviders-Bzd4NZcX.js} +1 -1
- package/dist/assets/{NewAgent-BzZI-FBE.js → NewAgent-wSr42KiN.js} +1 -1
- package/dist/assets/{PipelineSettings-BgfMR73P.js → PipelineSettings-CoFzH1-c.js} +1 -1
- package/dist/assets/{Pipelines-DAuqtVqc.js → Pipelines-CBrVkNVf.js} +1 -1
- package/dist/assets/{PixelsOffice-CaQYQilp.js → PixelsOffice-D1vo-0wW.js} +1 -1
- package/dist/assets/{PluginPage-C-W3lTd9.js → PluginPage-BtaYd9AD.js} +1 -1
- package/dist/assets/{PluginSettings-D365WG22.js → PluginSettings-Hcx5yZJk.js} +1 -1
- package/dist/assets/{ProfileDetailRoute-YzeVN0Ko.js → ProfileDetailRoute-nVOQkxal.js} +1 -1
- package/dist/assets/{ProfileSettings-BLh9EdSK.js → ProfileSettings-D_ZrTEBL.js} +1 -1
- package/dist/assets/{ProfileWizardRoute-DvOWuvrG.js → ProfileWizardRoute-Bk8tx6UC.js} +1 -1
- package/dist/assets/{ProjectDetail-OirlXEA4.js → ProjectDetail-BCjyXt2s.js} +1 -1
- package/dist/assets/{ProjectWorkspaceDetail-C9_liq4q.js → ProjectWorkspaceDetail-BcyMO75Z.js} +1 -1
- package/dist/assets/{ProjectWorkspacesContent-DRAIVofy.js → ProjectWorkspacesContent-B0vZEtt2.js} +1 -1
- package/dist/assets/{Projects-B6UgAQ3Z.js → Projects-Ck08UWc-.js} +1 -1
- package/dist/assets/{PublicIssueSharePage-Cg0GqSVM.js → PublicIssueSharePage-D28zKQ4N.js} +1 -1
- package/dist/assets/{ReviewQueueCard-MNEVuxSA.js → ReviewQueueCard-CQJtenHf.js} +1 -1
- package/dist/assets/{RichWorkProductCard-D4Qq1gRh.js → RichWorkProductCard-DvhYE1cH.js} +1 -1
- package/dist/assets/{RoutineDetail-DPzql29w.js → RoutineDetail-CM_C8njY.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-C8OHcazq.js → RoutineRunVariablesDialog-BKrZPW5U.js} +1 -1
- package/dist/assets/{Routines-pnhQk9RN.js → Routines-BB5zkfap.js} +1 -1
- package/dist/assets/{ScrollToBottom-C_k4p-hC.js → ScrollToBottom-CT7fjpoT.js} +1 -1
- package/dist/assets/{Search-DjpKZIsB.js → Search-BgSHY-QB.js} +1 -1
- package/dist/assets/{Secrets-BOZydXaY.js → Secrets-zu14ajI8.js} +1 -1
- package/dist/assets/{SkillSourceTree-Cuv3EWpo.js → SkillSourceTree-Cm9N2xW8.js} +1 -1
- package/dist/assets/{SkillSources-CYYp9Mds.js → SkillSources-BG_dPDP8.js} +1 -1
- package/dist/assets/{SkillStudio-Dl28fokd.js → SkillStudio-D4GvrYEe.js} +1 -1
- package/dist/assets/{SourceTrustBadge-BYpC1Kw9.js → SourceTrustBadge-BUmQZ6VD.js} +1 -1
- package/dist/assets/{StatusCards-Bqkb18QJ.js → StatusCards-BQYp9_rr.js} +1 -1
- package/dist/assets/{SummarySlotCard-DlwG6iRT.js → SummarySlotCard-_MpN7TiK.js} +1 -1
- package/dist/assets/{TaskChatLab-vnFP7gcJ.js → TaskChatLab-BtodeACE.js} +1 -1
- package/dist/assets/{TaskChatMarker-KUR-n-7D.js → TaskChatMarker-LLCNK3e-.js} +1 -1
- package/dist/assets/{TaskChatProtocolCard-CuyApwWM.js → TaskChatProtocolCard-CdeGEtdY.js} +1 -1
- package/dist/assets/{TaskChatThreadView-B2LR9geW.js → TaskChatThreadView-BxvoJvZk.js} +1 -1
- package/dist/assets/{TaskTreeControls-CRzAjVlt.js → TaskTreeControls-Cqhs5wQ9.js} +1 -1
- package/dist/assets/{Terminal-YAhWrMv9.js → Terminal-D_PTBqFk.js} +1 -1
- package/dist/assets/{TerminalView-7diHxQOx.js → TerminalView-Du4ncjRe.js} +1 -1
- package/dist/assets/{TrustPresetSection-DCiCKRh0.js → TrustPresetSection-Dkv__1Qr.js} +1 -1
- package/dist/assets/{UserProfile-CEpSKMzS.js → UserProfile-6tR8KBkI.js} +1 -1
- package/dist/assets/{WhatNeedsMe-D0yh5L5H.js → WhatNeedsMe-CokwG-qz.js} +1 -1
- package/dist/assets/{Workspaces-uDkUYVN3.js → Workspaces-z0KIx4hI.js} +1 -1
- package/dist/assets/{connection-owner-rjoh3jce.js → connection-owner-Bhzm673Y.js} +1 -1
- package/dist/assets/{index-BcwxLap4.js → index-b1wwaMjV.js} +3 -3
- package/dist/assets/{issue-properties-D64PIhST.js → issue-properties-DxJFyYY9.js} +1 -1
- package/dist/assets/{issue-workspace-selection-BY0sBaN6.js → issue-workspace-selection-CyOTHbLN.js} +1 -1
- package/dist/assets/{pipeline-stage-presentation-DDdch-G7.js → pipeline-stage-presentation-COuyOfPG.js} +1 -1
- package/dist/assets/{shared-BjSrBoPt.js → shared-c4dzLU_x.js} +1 -1
- package/dist/assets/{transcript-adapter-C1RGcJFu.js → transcript-adapter-D3tQN7Tw.js} +1 -1
- package/dist/assets/{useSummaryDraftStream-DOcsGLEm.js → useSummaryDraftStream-DLjyfaIh.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var U=Object.defineProperty;var t=(m,u)=>U(m,"name",{value:u,configurable:!0});import{i as _}from"./rolldown-runtime-ZpX3ckPj.js";import{O as L,f as I,la as R,t as X,ua as $}from"./createLucideIcon-CgrPXnTY.js";import{X as Z,_ as f,t as n,v as G}from"./queryKeys-BzT8CD34.js";import{u as d}from"./companies-query-BEdFiAhG.js";import{n as H}from"./CompanyContext-fQCNWI_f.js";import{c as J,i as v,p as V,r as W,t as Y}from"./dropdown-menu-rUbU8QKw.js";import{t as ee}from"./archive-restore-tP0pyaei.js";import{t as se}from"./check-Bis3vECb.js";import{t as te}from"./circle-dot-EfQ00xK3.js";import{t as ae}from"./ellipsis-DyXbAp4P.js";import{t as i}from"./button-DI4w5WP7.js";import{t as ie}from"./plus-CwNlqadt.js";import{t as ne}from"./trash-QxFF084e.js";import{t as re}from"./users-CEZ1U5q9.js";import{t as le}from"./x-6E1yeU3Q.js";import{t as oe}from"./badge-jeXr866I.js";import{t as de}from"./input-BBNGmECW.js";import{n as ce}from"./BreadcrumbContext-DNbB7zWn.js";import{t as me}from"./card-BVZvs7aX.js";import{Ia as S,Za as ue,ya as xe}from"./index-
|
|
1
|
+
var U=Object.defineProperty;var t=(m,u)=>U(m,"name",{value:u,configurable:!0});import{i as _}from"./rolldown-runtime-ZpX3ckPj.js";import{O as L,f as I,la as R,t as X,ua as $}from"./createLucideIcon-CgrPXnTY.js";import{X as Z,_ as f,t as n,v as G}from"./queryKeys-BzT8CD34.js";import{u as d}from"./companies-query-BEdFiAhG.js";import{n as H}from"./CompanyContext-fQCNWI_f.js";import{c as J,i as v,p as V,r as W,t as Y}from"./dropdown-menu-rUbU8QKw.js";import{t as ee}from"./archive-restore-tP0pyaei.js";import{t as se}from"./check-Bis3vECb.js";import{t as te}from"./circle-dot-EfQ00xK3.js";import{t as ae}from"./ellipsis-DyXbAp4P.js";import{t as i}from"./button-DI4w5WP7.js";import{t as ie}from"./plus-CwNlqadt.js";import{t as ne}from"./trash-QxFF084e.js";import{t as re}from"./users-CEZ1U5q9.js";import{t as le}from"./x-6E1yeU3Q.js";import{t as oe}from"./badge-jeXr866I.js";import{t as de}from"./input-BBNGmECW.js";import{n as ce}from"./BreadcrumbContext-DNbB7zWn.js";import{t as me}from"./card-BVZvs7aX.js";import{Ia as S,Za as ue,ya as xe}from"./index-b1wwaMjV.js";var K={name:"calendar",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}]]};K.node;var he=X(K),c=_($(),1),e=_(R(),1);function Qe(){const{companies:m,selectedCompanyId:u,setSelectedCompanyId:N,loading:Q,error:C}=H(),{openOnboarding:F}=xe(),{setBreadcrumbs:b}=ce(),r=Z(),{data:O}=G({queryKey:n.companies.stats,queryFn:t(()=>d.stats(),"queryFn")}),[x,h]=(0,c.useState)(null),[p,g]=(0,c.useState)(""),[A,j]=(0,c.useState)(null),k=f({mutationFn:t(({id:s,newName:l})=>d.update(s,{name:l}),"mutationFn"),onSuccess:t(()=>{r.invalidateQueries({queryKey:n.companies.all}),h(null)},"onSuccess")}),o=f({mutationFn:t(s=>d.remove(s),"mutationFn"),onSuccess:t(()=>{r.invalidateQueries({queryKey:n.companies.all}),r.invalidateQueries({queryKey:n.companies.stats}),j(null)},"onSuccess")}),w=f({mutationFn:t(s=>d.update(s,{status:"active"}),"mutationFn"),onSuccess:t(()=>{r.invalidateQueries({queryKey:n.companies.all}),r.invalidateQueries({queryKey:n.companies.stats})},"onSuccess")});(0,c.useEffect)(()=>{b([{label:"Organizations"}])},[b]);function y(s,l){h(s),g(l)}t(y,"startEdit");function M(){!x||!p.trim()||k.mutate({id:x,newName:p.trim()})}t(M,"saveEdit");function D(){h(null),g("")}return t(D,"cancelEdit"),(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)("div",{className:"flex items-center justify-end",children:(0,e.jsxs)(i,{size:"sm",onClick:t(()=>F(),"onClick"),children:[(0,e.jsx)(ie,{className:"h-3.5 w-3.5 mr-1.5"}),"New Organization"]})}),(0,e.jsxs)("div",{className:"h-6",children:[Q&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading organizations..."}),C&&(0,e.jsx)("p",{className:"text-sm text-bad",children:C.message})]}),(0,e.jsx)("div",{className:"grid gap-4",children:m.map(s=>{const l=s.id===u,z=x===s.id,B=A===s.id,E=O?.[s.id],P=E?.agentCount??0,q=E?.issueCount??0,T=s.budgetMonthlyCents>0?Math.round(s.spentMonthlyCents/s.budgetMonthlyCents*100):0;return(0,e.jsxs)(me,{role:"button",tabIndex:0,onClick:t(()=>N(s.id),"onClick"),onKeyDown:t(a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),N(s.id))},"onKeyDown"),interactive:!0,className:`block group text-left p-5 ${l?"border-accent ring-1 ring-accent hover:border-accent":""}`,children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[z?(0,e.jsxs)("div",{className:"flex items-center gap-2",onClick:t(a=>a.stopPropagation(),"onClick"),children:[(0,e.jsx)(de,{value:p,onChange:t(a=>g(a.target.value),"onChange"),className:"h-7 text-sm",autoFocus:!0,onKeyDown:t(a=>{a.key==="Enter"&&M(),a.key==="Escape"&&D()},"onKeyDown")}),(0,e.jsx)(i,{variant:"ghost",size:"icon-xs",onClick:M,disabled:k.isPending,children:(0,e.jsx)(se,{className:"h-3.5 w-3.5 text-green-500"})}),(0,e.jsx)(i,{variant:"ghost",size:"icon-xs",onClick:D,children:(0,e.jsx)(le,{className:"h-3.5 w-3.5 text-ink-3"})})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"font-semibold text-base",children:s.name}),(0,e.jsx)(oe,{variant:"ghost",className:`text-(length:--text-micro) ${s.status==="active"?"bg-green-500/10 text-green-600 dark:text-green-400":s.status==="paused"?"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400":"bg-bg-3 text-ink-3"}`,children:s.status}),(0,e.jsx)(i,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100",onClick:t(a=>{a.stopPropagation(),y(s.id,s.name)},"onClick"),children:(0,e.jsx)(S,{className:"h-3 w-3"})})]}),s.description&&!z&&(0,e.jsx)("p",{className:"text-sm text-ink-3 mt-1 line-clamp-2",children:s.description})]}),(0,e.jsx)("div",{onClick:t(a=>a.stopPropagation(),"onClick"),children:(0,e.jsxs)(Y,{children:[(0,e.jsx)(V,{asChild:!0,children:(0,e.jsx)(i,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100",children:(0,e.jsx)(ae,{className:"h-4 w-4"})})}),(0,e.jsxs)(W,{align:"end",children:[(0,e.jsxs)(v,{onClick:t(()=>y(s.id,s.name),"onClick"),children:[(0,e.jsx)(S,{className:"h-3.5 w-3.5"}),"Rename"]}),s.status==="archived"&&(0,e.jsxs)(v,{disabled:w.isPending,onClick:t(()=>w.mutate(s.id),"onClick"),children:[(0,e.jsx)(ee,{className:"h-3.5 w-3.5"}),"Unarchive"]}),(0,e.jsx)(J,{}),(0,e.jsxs)(v,{variant:"destructive",onClick:t(()=>j(s.id),"onClick"),children:[(0,e.jsx)(ne,{className:"h-3.5 w-3.5"}),"Delete Organization"]})]})]})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3 sm:gap-5 mt-4 text-sm text-ink-3 flex-wrap",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(re,{className:"h-3.5 w-3.5"}),(0,e.jsxs)("span",{children:[P," ",P===1?"agent":"agents"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(te,{className:"h-3.5 w-3.5"}),(0,e.jsxs)("span",{children:[q," ",q===1?"task":"tasks"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 tabular-nums",children:[(0,e.jsx)(ue,{className:"h-3.5 w-3.5"}),(0,e.jsxs)("span",{children:[I(s.spentMonthlyCents),s.budgetMonthlyCents>0?(0,e.jsxs)(e.Fragment,{children:[" / ",I(s.budgetMonthlyCents)," ",(0,e.jsxs)("span",{className:"text-xs",children:["(",T,"%)"]})]}):(0,e.jsx)("span",{className:"text-xs ml-1",children:"Unlimited budget"})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 ml-auto",children:[(0,e.jsx)(he,{className:"h-3.5 w-3.5"}),(0,e.jsxs)("span",{children:["Created ",L(s.createdAt)]})]})]}),B&&(0,e.jsxs)("div",{className:"mt-4 flex items-center justify-between bg-bad/5 border border-bad/20 rounded-md px-4 py-3",onClick:t(a=>a.stopPropagation(),"onClick"),children:[(0,e.jsx)("p",{className:"text-sm text-bad font-medium",children:"Delete this organization and all its data? This cannot be undone."}),(0,e.jsxs)("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[(0,e.jsx)(i,{variant:"ghost",size:"sm",onClick:t(()=>j(null),"onClick"),disabled:o.isPending,children:"Cancel"}),(0,e.jsx)(i,{variant:"delete",size:"sm",onClick:t(()=>o.mutate(s.id),"onClick"),disabled:o.isPending,children:o.isPending?"Deleting…":"Delete"})]})]})]},s.id)})})]})}t(Qe,"Companies");export{Qe as Companies};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ve=Object.defineProperty;var t=(a,i)=>ve(a,"name",{value:i,configurable:!0});import{i as oe}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as Z,la as ge,ua as je,zt as be}from"./createLucideIcon-CgrPXnTY.js";import{y as ye}from"./star-eem0qj3E.js";import{X as ce,_ as A,n as de,t as h,v as L}from"./queryKeys-BzT8CD34.js";import{t as fe}from"./useInfiniteQuery-DTEIZ1gz.js";import{n as K}from"./CompanyContext-fQCNWI_f.js";import{r as Ne,t as z,zt as ke}from"./router-BKzUF9uf.js";import{a as we,n as Ie,t as Ce}from"./avatar-qO_h93F8.js";import{n as ee,t as Re}from"./tabs-CjHzZxtD.js";import{t as qe}from"./check-Bis3vECb.js";import{t as Se}from"./copy-C1cfcpxY.js";import{t as d}from"./button-DI4w5WP7.js";import{t as Ae}from"./shield-check-RPyaLAc-.js";import{t as Ue}from"./shield-DC6LuDUy.js";import{t as Me}from"./trash-QxFF084e.js";import{t as F}from"./badge-jeXr866I.js";import{i as me}from"./ToastContext-DyVJ6bCh.js";import{t as Ee}from"./agents-B8n-p0aX.js";import{a as se,i as te,n as ne,r as ae,s as ie,t as re}from"./dialog-CeH7rDcv.js";import{t as j}from"./access-DhB95qNC.js";import{o as Te}from"./slots-DZ1hj5sG.js";import{t as Pe}from"./useHiddenSettings-D0HL2tkE.js";import{n as ue}from"./BreadcrumbContext-DNbB7zWn.js";import{t as _e}from"./clipboard-CTLKYvRL.js";import{ri as Le}from"./index-BcwxLap4.js";var r=oe(je(),1),e=oe(ge(),1),ze=[{value:"viewer",label:"Viewer",description:"Can view organization work and follow along.",gets:"View-only organization membership."},{value:"operator",label:"Operator",description:"Can edit organization work and invite people.",gets:"Full editing and audit access. Cannot approve join requests or manage member permissions."},{value:"admin",label:"Admin",description:"Recommended for operators who need to invite people, create agents, and approve joins.",gets:"Can create agents, invite users, assign tasks, and approve join requests."},{value:"owner",label:"Owner",description:"Full organization access, including membership management.",gets:"Everything in Admin, plus managing members."}],le=5;function Fe(a){return!a||typeof a!="object"?!1:"id"in a&&"state"in a&&"createdAt"in a}t(Fe,"isInviteHistoryRow");function Je(){const{selectedCompanyId:a}=K(),{pushToast:i}=me(),m=ce(),[o,c]=(0,r.useState)("operator"),[v,U]=(0,r.useState)(null),[b,g]=(0,r.useState)(!1),k=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!b)return;const n=window.setTimeout(()=>{g(!1)},1600);return()=>window.clearTimeout(n)},[b]);function T(){k.current?.focus(),k.current?.select()}t(T,"selectLatestInviteUrl");async function M(n,f,S){try{return await _e(n),!0}catch{S?.()}return i({title:"Clipboard unavailable",body:f,tone:"warn"}),!1}t(M,"copyText");async function P(n){return M(n,"The invite URL is selected. Copy it manually from the field.",T)}t(P,"copyInviteUrl");const y=h.access.invites(a??"","all",le),l=fe({queryKey:y,queryFn:t(({pageParam:n})=>j.listInvites(a,{limit:le,offset:n}),"queryFn"),enabled:!!a,initialPageParam:0,getNextPageParam:t(n=>n.nextOffset??void 0,"getNextPageParam")}),w=(0,r.useMemo)(()=>l.data?.pages.flatMap(n=>Array.isArray(n?.invites)?n.invites.filter(Fe):[])??[],[l.data?.pages]),R=A({mutationFn:t(()=>j.createCompanyInvite(a,{allowedJoinTypes:"human",humanRole:o,agentMessage:null}),"mutationFn"),onSuccess:t(async n=>{U(n.inviteUrl),g(!1);const f=await M(n.inviteUrl,"Copy the invite URL manually from the field below.");await m.invalidateQueries({queryKey:y}),i({title:"Invite created",body:f?"Invite ready below and copied to clipboard.":"Invite ready below.",tone:"success"})},"onSuccess"),onError:t(n=>{i({title:"Failed to create invite",body:n instanceof Error?n.message:"Unknown error",tone:"error"})},"onError")}),q=A({mutationFn:t(n=>j.revokeInvite(n),"mutationFn"),onSuccess:t(async()=>{await m.invalidateQueries({queryKey:y}),i({title:"Invite revoked",tone:"success"})},"onSuccess"),onError:t(n=>{i({title:"Failed to revoke invite",body:n instanceof Error?n.message:"Unknown error",tone:"error"})},"onError")});if(!a)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization to manage invites."});if(l.isLoading)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading invites…"});if(l.error){const n=l.error instanceof de&&l.error.status===403?"You do not have permission to manage organization invites.":l.error instanceof Error?l.error.message:"Failed to load invites.";return(0,e.jsx)("div",{className:"text-sm text-bad",children:n})}return(0,e.jsxs)("div",{className:"max-w-6xl space-y-8",children:[(0,e.jsx)("p",{className:"max-w-3xl text-sm text-ink-3",children:"Invite people to request access to this organization. New invite links are copied to your clipboard when they are generated."}),(0,e.jsxs)("section",{className:"space-y-4 rounded-xl border border-line p-5",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"Invite a person"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Generate a human invite link and choose the default access it should request."})]}),(0,e.jsxs)("fieldset",{className:"space-y-3",children:[(0,e.jsx)("legend",{className:"text-sm font-medium",children:"Choose a role"}),(0,e.jsx)("div",{className:"rounded-xl border border-line",children:ze.map((n,f)=>{const S=o===n.value;return(0,e.jsxs)("label",{className:`flex cursor-pointer gap-3 px-4 py-4 ${f>0?"border-t border-line":""}`,children:[(0,e.jsx)("input",{type:"radio",name:"invite-role",value:n.value,checked:S,onChange:t(()=>c(n.value),"onChange"),className:"mt-1 h-4 w-4 border-line text-ink"}),(0,e.jsxs)("span",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:n.label}),n.value==="operator"?(0,e.jsx)(F,{variant:"outline",className:"border-line text-ink-3",children:"Default"}):null]}),(0,e.jsx)("span",{className:"block max-w-2xl text-sm text-ink-3",children:n.description}),(0,e.jsx)("span",{className:"block text-sm text-ink",children:n.gets})]})]},n.value)})})]}),(0,e.jsx)("div",{className:"rounded-lg border border-line px-4 py-3 text-sm text-ink-3",children:"Each invite link is single-use. Human invitees get the selected role immediately after sign-in; agent invites still create a join request for approval."}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsx)(d,{onClick:t(()=>R.mutate(),"onClick"),disabled:R.isPending,children:R.isPending?"Creating…":"Create invite"}),(0,e.jsx)("span",{className:"text-sm text-ink-3",children:"Invite history below keeps the audit trail."})]}),v?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-line px-4 py-4",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Latest invite link"}),b?(0,e.jsxs)("div",{className:"inline-flex items-center gap-1 text-xs font-medium text-ink",children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5"}),"Copied"]}):null]}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"This URL includes the current Wardmote domain returned by the server."})]}),(0,e.jsxs)("label",{className:"block space-y-1",children:[(0,e.jsx)("span",{className:"sr-only",children:"Latest invite URL"}),(0,e.jsx)("input",{ref:k,readOnly:!0,value:v,onFocus:t(n=>n.currentTarget.select(),"onFocus"),onClick:t(n=>n.currentTarget.select(),"onClick"),className:"w-full rounded-md border border-line bg-bg-3/60 px-3 py-2 text-sm text-ink outline-none transition-colors selection:bg-accent selection:text-accent-ink focus:border-focus","aria-label":"Latest invite URL"})]}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,e.jsxs)(d,{type:"button",size:"sm",variant:"secondary",onClick:t(async()=>{const n=await P(v);g(n)},"onClick"),children:[(0,e.jsx)(Se,{className:"h-4 w-4"}),"Copy link"]})})]}):null]}),(0,e.jsxs)("section",{className:"rounded-xl border border-line",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 px-5 py-4",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"Invite history"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Review invite status, audience, inviter, and any linked join request."})]}),(0,e.jsx)(z,{to:"/inbox/requests",className:"text-sm underline underline-offset-4",children:"Open join request queue"})]}),w.length===0?(0,e.jsx)("div",{className:"border-t border-line px-5 py-8 text-sm text-ink-3",children:"No invites have been created for this organization yet."}):(0,e.jsxs)("div",{className:"border-t border-line",children:[(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"min-w-full text-left text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line",children:[(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"State"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"For"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"Invited by"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"Created"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"Join request"}),(0,e.jsx)("th",{className:"px-5 py-3 text-right font-medium text-ink-3",children:"Action"})]})}),(0,e.jsx)("tbody",{children:w.map(n=>(0,e.jsxs)("tr",{className:"border-b border-line last:border-b-0",children:[(0,e.jsx)("td",{className:"px-5 py-3 align-top",children:(0,e.jsx)(F,{variant:"outline",className:"border-line text-ink-3",children:Oe(n.state)})}),(0,e.jsx)("td",{className:"px-5 py-3 align-top",children:Qe(n)}),(0,e.jsxs)("td",{className:"px-5 py-3 align-top",children:[(0,e.jsx)("div",{children:n.invitedByUser?.name||n.invitedByUser?.email||"Unknown inviter"}),n.invitedByUser?.email&&n.invitedByUser.name?(0,e.jsx)("div",{className:"text-xs text-ink-3",children:n.invitedByUser.email}):null]}),(0,e.jsx)("td",{className:"px-5 py-3 align-top text-ink-3",children:new Date(n.createdAt).toLocaleString()}),(0,e.jsx)("td",{className:"px-5 py-3 align-top",children:n.relatedJoinRequestId?(0,e.jsx)(z,{to:"/inbox/requests",className:"underline underline-offset-4",children:"Review request"}):(0,e.jsx)("span",{className:"text-ink-3",children:"—"})}),(0,e.jsx)("td",{className:"px-5 py-3 text-right align-top",children:n.state==="active"?(0,e.jsx)(d,{size:"sm",variant:"secondary",onClick:t(()=>q.mutate(n.id),"onClick"),disabled:q.isPending,children:"Revoke"}):(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Inactive"})})]},n.id))})]})}),l.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center border-t border-line px-5 py-4",children:(0,e.jsx)(d,{type:"button",variant:"secondary",onClick:t(()=>l.fetchNextPage(),"onClick"),disabled:l.isFetchingNextPage,children:l.isFetchingNextPage?"Loading more…":"View more"})}):null]})]})]})}t(Je,"InvitesSection");function Oe(a){return a.charAt(0).toUpperCase()+a.slice(1)}t(Oe,"formatInviteState");function Qe(a){return a.allowedJoinTypes==="agent"?"Agent":a.allowedJoinTypes==="both"?a.humanRole?`Human or agent · ${a.humanRole}`:"Human or agent":a.humanRole??"Human"}t(Qe,"formatInviteAudience");var Be="backlog,todo,in_progress,in_review,blocked,failed,timed_out";function ys(){const{selectedCompany:a,selectedCompanyId:i}=K(),{setBreadcrumbs:m}=ue(),{pushToast:o}=me(),c=ce(),[v,U]=ye(),{hidden:b}=Pe(),g=be(b,"company.invites"),k=v.get("tab")==="invites"?"invites":"members",T=g?"members":k,M=t(s=>{U(N=>{const C=new URLSearchParams(N);return s==="invites"?C.set("tab","invites"):C.delete("tab"),C},{replace:!0})},"handleTabChange"),[P,y]=(0,r.useState)(null),[l,w]=(0,r.useState)(null),[R,q]=(0,r.useState)("__unassigned"),[n,f]=(0,r.useState)(null),[S,$]=(0,r.useState)("active");(0,r.useEffect)(()=>{m([{label:a?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Members"}])},[a?.name,m]);const u=L({queryKey:h.access.companyMembers(i??""),queryFn:t(()=>j.listMembers(i),"queryFn"),enabled:!!i}),xe=L({queryKey:h.agents.list(i??""),queryFn:t(()=>Ee.list(i),"queryFn"),enabled:!!i}),pe=L({queryKey:h.access.joinRequests(i??"","pending_approval"),queryFn:t(()=>j.listJoinRequests(i,"pending_approval"),"queryFn"),enabled:!!i&&!!u.data?.access.canApproveJoinRequests}),_=t(async()=>{i&&(await c.invalidateQueries({queryKey:h.access.companyMembers(i)}),await c.invalidateQueries({queryKey:h.access.companyUserDirectory(i)}),await c.invalidateQueries({queryKey:h.access.joinRequests(i,"pending_approval")}))},"refreshAccessData"),J=A({mutationFn:t(async s=>j.updateMember(i,s.memberId,{membershipRole:s.membershipRole,status:s.status}),"mutationFn"),onSuccess:t(async()=>{y(null),await _(),o({title:"Member updated",tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to update member",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")}),V=A({mutationFn:t(s=>j.approveJoinRequest(i,s),"mutationFn"),onSuccess:t(async()=>{await _(),o({title:"Join request approved",tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to approve join request",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")}),W=A({mutationFn:t(s=>j.rejectJoinRequest(i,s),"mutationFn"),onSuccess:t(async()=>{await _(),o({title:"Join request rejected",tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to reject join request",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")}),p=(0,r.useMemo)(()=>u.data?.members.find(s=>s.id===P)??null,[P,u.data?.members]),x=(0,r.useMemo)(()=>u.data?.members.find(s=>s.id===l)??null,[l,u.data?.members]),O=L({queryKey:["access","member-assigned-issues",i??"",x?.principalId??""],queryFn:t(()=>ke.list(i,{assigneeUserId:x.principalId,status:Be}),"queryFn"),enabled:!!i&&!!x}),Q=A({mutationFn:t(async s=>{const N=s.target.startsWith("agent:")?{assigneeAgentId:s.target.slice(6),assigneeUserId:null}:s.target.startsWith("user:")?{assigneeAgentId:null,assigneeUserId:s.target.slice(5)}:null;return j.archiveMember(i,s.memberId,{reassignment:N})},"mutationFn"),onSuccess:t(async s=>{w(null),q("__unassigned"),await _(),i&&(await c.invalidateQueries({queryKey:h.issues.list(i)}),await c.invalidateQueries({queryKey:h.issues.listAssignedToMe(i)}),await c.invalidateQueries({queryKey:h.issues.listTouchedByMe(i)})),o({title:"Member removed",body:s.reassignedIssueCount>0?`${s.reassignedIssueCount} assigned task${s.reassignedIssueCount===1?"":"s"} cleaned up.`:void 0,tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to remove member",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")});if((0,r.useEffect)(()=>{p&&(f(p.membershipRole),$(Ke(p.status)?p.status:"suspended"))},[p]),(0,r.useEffect)(()=>{x&&q("__unassigned")},[x]),!i)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization to manage access."});if(u.isLoading)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading organization access…"});if(u.error){const s=u.error instanceof de&&u.error.status===403?"You do not have permission to manage organization members.":u.error instanceof Error?u.error.message:"Failed to load organization members.";return(0,e.jsx)("div",{className:"text-sm text-bad",children:s})}const B=u.data?.members??[],D=u.data?.access,H=pe.data?.filter(s=>s.requestType==="human")??[],he=V.isPending||W.isPending,Y=B.filter(s=>s.status==="active"&&s.principalType==="user"&&s.id!==l),G=(xe.data??[]).filter(He),I=O.data??[];return(0,e.jsxs)("div",{className:"max-w-6xl space-y-8",children:[(0,e.jsx)("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)(Ae,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Organization Members"})]})}),(0,e.jsxs)(Re,{value:T,onValueChange:M,className:"flex flex-col gap-4",children:[!g&&(0,e.jsx)(Le,{items:[{value:"members",label:"Members"},{value:"invites",label:"Invites"}],align:"start",value:T,onValueChange:M}),(0,e.jsxs)(ee,{value:"members",className:"space-y-8",children:[D&&!D.currentUserRole&&(0,e.jsx)("div",{className:"rounded-xl bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",children:"This account can manage access here through instance-admin privileges, but it does not currently hold an active organization membership."}),(0,e.jsxs)("section",{className:"space-y-4",children:[D?.canApproveJoinRequests&&H.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Pending human joins"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Review pending join requests before they become active organization members."})]}),(0,e.jsxs)(F,{variant:"outline",children:[H.length," pending"]})]}),(0,e.jsx)("div",{className:"space-y-3",children:H.map(s=>(0,e.jsx)($e,{title:s.requesterUser?.name||s.requestEmailSnapshot||s.requestingUserId||"Unknown human requester",subtitle:s.requesterUser?.email||s.requestEmailSnapshot||s.requestingUserId||"No email available",context:s.invite?`${s.invite.allowedJoinTypes} join invite${s.invite.humanRole?` • default role ${s.invite.humanRole}`:""}`:"Invite metadata unavailable",detail:`Submitted ${new Date(s.createdAt).toLocaleString()}`,approveLabel:"Approve human",rejectLabel:"Reject human",disabled:he,onApprove:t(()=>V.mutate(s.id),"onApprove"),onReject:t(()=>W.mutate(s.id),"onReject")},s.id))})]}):null,(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full min-w-(--sz-44rem) text-left text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line text-ink-3",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Name"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Email"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Role"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"}),(0,e.jsx)("th",{className:"px-3 py-2 text-right font-medium",children:"Action"})]})}),(0,e.jsx)("tbody",{children:B.length===0?(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:5,className:"px-3 py-8 text-ink-3",children:"No user memberships found for this organization yet."})}):B.map(s=>{const N=s.removal?.reason??null,C=s.removal?.canArchive??!0,X=E(s);return(0,e.jsxs)("tr",{className:"border-b border-line last:border-b-0",children:[(0,e.jsx)("td",{className:"px-3 py-3",children:(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,e.jsxs)(Ce,{size:"sm",children:[s.user?.image?(0,e.jsx)(we,{src:s.user.image,alt:X}):null,(0,e.jsx)(Ie,{children:De(s)})]}),(0,e.jsx)("span",{className:"truncate font-medium",children:X})]})}),(0,e.jsx)("td",{className:"px-3 py-3 text-ink-3",children:s.user?.email||s.principalId}),(0,e.jsx)("td",{className:"px-3 py-3",children:s.membershipRole?Z[s.membershipRole]:"Unset"}),(0,e.jsx)("td",{className:"px-3 py-3",children:(0,e.jsx)(F,{variant:s.status==="active"?"secondary":s.status==="suspended"?"destructive":"outline",children:s.status.replace("_"," ")})}),(0,e.jsx)("td",{className:"px-3 py-3 text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)(d,{size:"sm",variant:"secondary",onClick:t(()=>y(s.id),"onClick"),children:"Edit"}),(0,e.jsx)("span",{className:"inline-flex",title:C?void 0:N??void 0,children:(0,e.jsxs)(d,{size:"sm",variant:"secondary",onClick:t(()=>w(s.id),"onClick"),disabled:!C,title:C?void 0:N??void 0,children:[(0,e.jsx)(Me,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]})})]})})]},s.id)})})]})})]}),(0,e.jsx)(re,{open:!!p,onOpenChange:t(s=>!s&&y(null),"onOpenChange"),children:(0,e.jsxs)(ne,{className:"max-w-2xl",children:[(0,e.jsxs)(se,{children:[(0,e.jsx)(ie,{children:"Edit member"}),(0,e.jsxs)(ae,{children:["Update organization role and membership status for ",p?.user?.name||p?.user?.email||p?.principalId,"."]})]}),p&&(0,e.jsx)("div",{className:"space-y-5",children:(0,e.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,e.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,e.jsx)("span",{className:"font-medium",children:"Organization role"}),(0,e.jsxs)("select",{className:"w-full rounded-md border border-line bg-bg px-3 py-2",value:n??"",onChange:t(s=>f(s.target.value||null),"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Unset"}),Object.entries(Z).map(([s,N])=>(0,e.jsx)("option",{value:s,children:N},s))]})]}),(0,e.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,e.jsx)("span",{className:"font-medium",children:"Membership status"}),(0,e.jsxs)("select",{className:"w-full rounded-md border border-line bg-bg px-3 py-2",value:S,onChange:t(s=>$(s.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"active",children:"Active"}),(0,e.jsx)("option",{value:"pending",children:"Pending"}),(0,e.jsx)("option",{value:"suspended",children:"Suspended"})]})]})]})}),(0,e.jsxs)(te,{children:[(0,e.jsx)(d,{variant:"secondary",onClick:t(()=>y(null),"onClick"),children:"Cancel"}),(0,e.jsx)(d,{onClick:t(()=>{p&&J.mutate({memberId:p.id,membershipRole:n,status:S})},"onClick"),disabled:J.isPending,children:J.isPending?"Saving…":"Save member"})]})]})}),(0,e.jsx)(re,{open:!!x,onOpenChange:t(s=>!s&&w(null),"onOpenChange"),children:(0,e.jsxs)(ne,{className:"max-w-xl",children:[(0,e.jsxs)(se,{children:[(0,e.jsx)(ie,{children:"Remove member"}),(0,e.jsxs)(ae,{children:["Archive ",E(x)," and move active assignments before hiding this user from assignment fields."]})]}),x&&(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-line px-3 py-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:E(x)}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:x.user?.email||x.principalId}),(0,e.jsx)("div",{className:"mt-2 text-sm text-ink-3",children:O.isLoading?"Checking assigned tasks...":`${I.length} open assigned task${I.length===1?"":"s"}`})]}),I.length>0?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Task reassignment"}),(0,e.jsxs)("select",{className:"w-full rounded-md border border-line bg-bg px-3 py-2 text-sm",value:R,onChange:t(s=>q(s.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"__unassigned",children:"Leave unassigned"}),Y.length>0?(0,e.jsx)("optgroup",{label:"Humans",children:Y.map(s=>(0,e.jsx)("option",{value:`user:${s.principalId}`,children:E(s)},s.id))}):null,G.length>0?(0,e.jsx)("optgroup",{label:"Agents",children:G.map(s=>(0,e.jsxs)("option",{value:`agent:${s.id}`,children:[s.name," (",s.role,")"]},s.id))}):null]}),(0,e.jsxs)("div",{className:"max-h-36 overflow-auto rounded-lg border border-line",children:[I.slice(0,6).map(s=>(0,e.jsxs)("div",{className:"border-b border-line px-3 py-2 text-sm last:border-b-0",children:[(0,e.jsx)("div",{className:"font-medium",children:s.identifier??s.id.slice(0,8)}),(0,e.jsx)("div",{className:"truncate text-ink-3",children:s.title})]},s.id)),I.length>6?(0,e.jsxs)("div",{className:"px-3 py-2 text-sm text-ink-3",children:[I.length-6," more task",I.length-6===1?"":"s"]}):null]})]}):null]}),(0,e.jsxs)(te,{children:[(0,e.jsx)(d,{variant:"secondary",onClick:t(()=>w(null),"onClick"),children:"Cancel"}),(0,e.jsx)(d,{variant:"danger",onClick:t(()=>{x&&Q.mutate({memberId:x.id,target:R})},"onClick"),disabled:Q.isPending||O.isLoading,children:Q.isPending?"Removing...":"Remove member"})]})]})})]}),!g&&(0,e.jsx)(ee,{value:"invites",children:(0,e.jsx)(Je,{})})]})]})}t(ys,"CompanyAccess");function fs(){const{selectedCompanyId:a}=K(),{setBreadcrumbs:i}=ue(),{slots:m,isLoading:o,errorMessage:c}=Te({slotTypes:["companySettingsPage"],companyId:a,enabled:!!a});return(0,r.useEffect)(()=>{i([{label:"Settings",href:"/company/settings"},{label:"Access"}])},[i]),m.find(v=>v.routePath==="permissions")?(0,e.jsx)(Ne,{to:"/company/settings/permissions",replace:!0}):o?(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Checking for advanced permission extensions..."}):(0,e.jsxs)("div",{className:"max-w-2xl space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ue,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Advanced Permissions"})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Advanced access, scoped assignment, and explicit grant controls are provided by installed organization settings extensions."})]}),(0,e.jsxs)("div",{className:"space-y-4 rounded-xl border border-line px-5 py-5",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"Advanced permissions unavailable"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Core Wardmote keeps enforcing organization boundaries and any existing restrictive policy data, but editing advanced permissions requires an installed extension."}),c?(0,e.jsxs)("p",{className:"text-sm text-bad",children:["Plugin extensions unavailable: ",c]}):null]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsx)(d,{asChild:!0,children:(0,e.jsx)(z,{to:"/company/settings/members",children:"Open Members"})}),(0,e.jsx)(d,{asChild:!0,variant:"secondary",children:(0,e.jsx)(z,{to:"/company/settings/members?tab=invites",children:"Open Invites"})})]})]})]})}t(fs,"CompanyAccessLegacyRoute");function E(a){return a?a.user?.name?.trim()||a.user?.email||a.principalId:"this member"}t(E,"memberDisplayName");function De(a){const i=E(a).trim(),m=i.split(/\s+/).filter(Boolean);return m.length>1?`${m[0]?.[0]??""}${m.at(-1)?.[0]??""}`.toUpperCase():i.slice(0,2).toUpperCase()}t(De,"memberInitials");function He(a){return a.status!=="terminated"&&a.status!=="pending_approval"}t(He,"isAssignableAgent");function Ke(a){return a==="pending"||a==="active"||a==="suspended"}t(Ke,"isEditableMemberStatus");function $e({title:a,subtitle:i,context:m,detail:o,detailSecondary:c,approveLabel:v,rejectLabel:U,disabled:b,onApprove:g,onReject:k}){return(0,e.jsx)("div",{className:"py-3",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"font-medium",children:a}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:i})]}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:m}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:o}),c?(0,e.jsx)("div",{className:"text-sm text-ink-3",children:c}):null]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(d,{type:"button",variant:"secondary",onClick:k,disabled:b,children:U}),(0,e.jsx)(d,{type:"button",onClick:g,disabled:b,children:v})]})]})})}t($e,"PendingJoinRequestCard");export{ys as CompanyAccess,fs as CompanyAccessLegacyRoute};
|
|
1
|
+
var ve=Object.defineProperty;var t=(a,i)=>ve(a,"name",{value:i,configurable:!0});import{i as oe}from"./rolldown-runtime-ZpX3ckPj.js";import{Fi as Z,la as ge,ua as je,zt as be}from"./createLucideIcon-CgrPXnTY.js";import{y as ye}from"./star-eem0qj3E.js";import{X as ce,_ as A,n as de,t as h,v as L}from"./queryKeys-BzT8CD34.js";import{t as fe}from"./useInfiniteQuery-DTEIZ1gz.js";import{n as K}from"./CompanyContext-fQCNWI_f.js";import{r as Ne,t as z,zt as ke}from"./router-BKzUF9uf.js";import{a as we,n as Ie,t as Ce}from"./avatar-qO_h93F8.js";import{n as ee,t as Re}from"./tabs-CjHzZxtD.js";import{t as qe}from"./check-Bis3vECb.js";import{t as Se}from"./copy-C1cfcpxY.js";import{t as d}from"./button-DI4w5WP7.js";import{t as Ae}from"./shield-check-RPyaLAc-.js";import{t as Ue}from"./shield-DC6LuDUy.js";import{t as Me}from"./trash-QxFF084e.js";import{t as F}from"./badge-jeXr866I.js";import{i as me}from"./ToastContext-DyVJ6bCh.js";import{t as Ee}from"./agents-B8n-p0aX.js";import{a as se,i as te,n as ne,r as ae,s as ie,t as re}from"./dialog-CeH7rDcv.js";import{t as j}from"./access-DhB95qNC.js";import{o as Te}from"./slots-DZ1hj5sG.js";import{t as Pe}from"./useHiddenSettings-D0HL2tkE.js";import{n as ue}from"./BreadcrumbContext-DNbB7zWn.js";import{t as _e}from"./clipboard-CTLKYvRL.js";import{ri as Le}from"./index-b1wwaMjV.js";var r=oe(je(),1),e=oe(ge(),1),ze=[{value:"viewer",label:"Viewer",description:"Can view organization work and follow along.",gets:"View-only organization membership."},{value:"operator",label:"Operator",description:"Can edit organization work and invite people.",gets:"Full editing and audit access. Cannot approve join requests or manage member permissions."},{value:"admin",label:"Admin",description:"Recommended for operators who need to invite people, create agents, and approve joins.",gets:"Can create agents, invite users, assign tasks, and approve join requests."},{value:"owner",label:"Owner",description:"Full organization access, including membership management.",gets:"Everything in Admin, plus managing members."}],le=5;function Fe(a){return!a||typeof a!="object"?!1:"id"in a&&"state"in a&&"createdAt"in a}t(Fe,"isInviteHistoryRow");function Je(){const{selectedCompanyId:a}=K(),{pushToast:i}=me(),m=ce(),[o,c]=(0,r.useState)("operator"),[v,U]=(0,r.useState)(null),[b,g]=(0,r.useState)(!1),k=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!b)return;const n=window.setTimeout(()=>{g(!1)},1600);return()=>window.clearTimeout(n)},[b]);function T(){k.current?.focus(),k.current?.select()}t(T,"selectLatestInviteUrl");async function M(n,f,S){try{return await _e(n),!0}catch{S?.()}return i({title:"Clipboard unavailable",body:f,tone:"warn"}),!1}t(M,"copyText");async function P(n){return M(n,"The invite URL is selected. Copy it manually from the field.",T)}t(P,"copyInviteUrl");const y=h.access.invites(a??"","all",le),l=fe({queryKey:y,queryFn:t(({pageParam:n})=>j.listInvites(a,{limit:le,offset:n}),"queryFn"),enabled:!!a,initialPageParam:0,getNextPageParam:t(n=>n.nextOffset??void 0,"getNextPageParam")}),w=(0,r.useMemo)(()=>l.data?.pages.flatMap(n=>Array.isArray(n?.invites)?n.invites.filter(Fe):[])??[],[l.data?.pages]),R=A({mutationFn:t(()=>j.createCompanyInvite(a,{allowedJoinTypes:"human",humanRole:o,agentMessage:null}),"mutationFn"),onSuccess:t(async n=>{U(n.inviteUrl),g(!1);const f=await M(n.inviteUrl,"Copy the invite URL manually from the field below.");await m.invalidateQueries({queryKey:y}),i({title:"Invite created",body:f?"Invite ready below and copied to clipboard.":"Invite ready below.",tone:"success"})},"onSuccess"),onError:t(n=>{i({title:"Failed to create invite",body:n instanceof Error?n.message:"Unknown error",tone:"error"})},"onError")}),q=A({mutationFn:t(n=>j.revokeInvite(n),"mutationFn"),onSuccess:t(async()=>{await m.invalidateQueries({queryKey:y}),i({title:"Invite revoked",tone:"success"})},"onSuccess"),onError:t(n=>{i({title:"Failed to revoke invite",body:n instanceof Error?n.message:"Unknown error",tone:"error"})},"onError")});if(!a)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization to manage invites."});if(l.isLoading)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading invites…"});if(l.error){const n=l.error instanceof de&&l.error.status===403?"You do not have permission to manage organization invites.":l.error instanceof Error?l.error.message:"Failed to load invites.";return(0,e.jsx)("div",{className:"text-sm text-bad",children:n})}return(0,e.jsxs)("div",{className:"max-w-6xl space-y-8",children:[(0,e.jsx)("p",{className:"max-w-3xl text-sm text-ink-3",children:"Invite people to request access to this organization. New invite links are copied to your clipboard when they are generated."}),(0,e.jsxs)("section",{className:"space-y-4 rounded-xl border border-line p-5",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"Invite a person"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Generate a human invite link and choose the default access it should request."})]}),(0,e.jsxs)("fieldset",{className:"space-y-3",children:[(0,e.jsx)("legend",{className:"text-sm font-medium",children:"Choose a role"}),(0,e.jsx)("div",{className:"rounded-xl border border-line",children:ze.map((n,f)=>{const S=o===n.value;return(0,e.jsxs)("label",{className:`flex cursor-pointer gap-3 px-4 py-4 ${f>0?"border-t border-line":""}`,children:[(0,e.jsx)("input",{type:"radio",name:"invite-role",value:n.value,checked:S,onChange:t(()=>c(n.value),"onChange"),className:"mt-1 h-4 w-4 border-line text-ink"}),(0,e.jsxs)("span",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-sm font-medium",children:n.label}),n.value==="operator"?(0,e.jsx)(F,{variant:"outline",className:"border-line text-ink-3",children:"Default"}):null]}),(0,e.jsx)("span",{className:"block max-w-2xl text-sm text-ink-3",children:n.description}),(0,e.jsx)("span",{className:"block text-sm text-ink",children:n.gets})]})]},n.value)})})]}),(0,e.jsx)("div",{className:"rounded-lg border border-line px-4 py-3 text-sm text-ink-3",children:"Each invite link is single-use. Human invitees get the selected role immediately after sign-in; agent invites still create a join request for approval."}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsx)(d,{onClick:t(()=>R.mutate(),"onClick"),disabled:R.isPending,children:R.isPending?"Creating…":"Create invite"}),(0,e.jsx)("span",{className:"text-sm text-ink-3",children:"Invite history below keeps the audit trail."})]}),v?(0,e.jsxs)("div",{className:"space-y-3 rounded-lg border border-line px-4 py-4",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Latest invite link"}),b?(0,e.jsxs)("div",{className:"inline-flex items-center gap-1 text-xs font-medium text-ink",children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5"}),"Copied"]}):null]}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"This URL includes the current Wardmote domain returned by the server."})]}),(0,e.jsxs)("label",{className:"block space-y-1",children:[(0,e.jsx)("span",{className:"sr-only",children:"Latest invite URL"}),(0,e.jsx)("input",{ref:k,readOnly:!0,value:v,onFocus:t(n=>n.currentTarget.select(),"onFocus"),onClick:t(n=>n.currentTarget.select(),"onClick"),className:"w-full rounded-md border border-line bg-bg-3/60 px-3 py-2 text-sm text-ink outline-none transition-colors selection:bg-accent selection:text-accent-ink focus:border-focus","aria-label":"Latest invite URL"})]}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,e.jsxs)(d,{type:"button",size:"sm",variant:"secondary",onClick:t(async()=>{const n=await P(v);g(n)},"onClick"),children:[(0,e.jsx)(Se,{className:"h-4 w-4"}),"Copy link"]})})]}):null]}),(0,e.jsxs)("section",{className:"rounded-xl border border-line",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 px-5 py-4",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"Invite history"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Review invite status, audience, inviter, and any linked join request."})]}),(0,e.jsx)(z,{to:"/inbox/requests",className:"text-sm underline underline-offset-4",children:"Open join request queue"})]}),w.length===0?(0,e.jsx)("div",{className:"border-t border-line px-5 py-8 text-sm text-ink-3",children:"No invites have been created for this organization yet."}):(0,e.jsxs)("div",{className:"border-t border-line",children:[(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"min-w-full text-left text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line",children:[(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"State"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"For"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"Invited by"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"Created"}),(0,e.jsx)("th",{className:"px-5 py-3 font-medium text-ink-3",children:"Join request"}),(0,e.jsx)("th",{className:"px-5 py-3 text-right font-medium text-ink-3",children:"Action"})]})}),(0,e.jsx)("tbody",{children:w.map(n=>(0,e.jsxs)("tr",{className:"border-b border-line last:border-b-0",children:[(0,e.jsx)("td",{className:"px-5 py-3 align-top",children:(0,e.jsx)(F,{variant:"outline",className:"border-line text-ink-3",children:Oe(n.state)})}),(0,e.jsx)("td",{className:"px-5 py-3 align-top",children:Qe(n)}),(0,e.jsxs)("td",{className:"px-5 py-3 align-top",children:[(0,e.jsx)("div",{children:n.invitedByUser?.name||n.invitedByUser?.email||"Unknown inviter"}),n.invitedByUser?.email&&n.invitedByUser.name?(0,e.jsx)("div",{className:"text-xs text-ink-3",children:n.invitedByUser.email}):null]}),(0,e.jsx)("td",{className:"px-5 py-3 align-top text-ink-3",children:new Date(n.createdAt).toLocaleString()}),(0,e.jsx)("td",{className:"px-5 py-3 align-top",children:n.relatedJoinRequestId?(0,e.jsx)(z,{to:"/inbox/requests",className:"underline underline-offset-4",children:"Review request"}):(0,e.jsx)("span",{className:"text-ink-3",children:"—"})}),(0,e.jsx)("td",{className:"px-5 py-3 text-right align-top",children:n.state==="active"?(0,e.jsx)(d,{size:"sm",variant:"secondary",onClick:t(()=>q.mutate(n.id),"onClick"),disabled:q.isPending,children:"Revoke"}):(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Inactive"})})]},n.id))})]})}),l.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center border-t border-line px-5 py-4",children:(0,e.jsx)(d,{type:"button",variant:"secondary",onClick:t(()=>l.fetchNextPage(),"onClick"),disabled:l.isFetchingNextPage,children:l.isFetchingNextPage?"Loading more…":"View more"})}):null]})]})]})}t(Je,"InvitesSection");function Oe(a){return a.charAt(0).toUpperCase()+a.slice(1)}t(Oe,"formatInviteState");function Qe(a){return a.allowedJoinTypes==="agent"?"Agent":a.allowedJoinTypes==="both"?a.humanRole?`Human or agent · ${a.humanRole}`:"Human or agent":a.humanRole??"Human"}t(Qe,"formatInviteAudience");var Be="backlog,todo,in_progress,in_review,blocked,failed,timed_out";function ys(){const{selectedCompany:a,selectedCompanyId:i}=K(),{setBreadcrumbs:m}=ue(),{pushToast:o}=me(),c=ce(),[v,U]=ye(),{hidden:b}=Pe(),g=be(b,"company.invites"),k=v.get("tab")==="invites"?"invites":"members",T=g?"members":k,M=t(s=>{U(N=>{const C=new URLSearchParams(N);return s==="invites"?C.set("tab","invites"):C.delete("tab"),C},{replace:!0})},"handleTabChange"),[P,y]=(0,r.useState)(null),[l,w]=(0,r.useState)(null),[R,q]=(0,r.useState)("__unassigned"),[n,f]=(0,r.useState)(null),[S,$]=(0,r.useState)("active");(0,r.useEffect)(()=>{m([{label:a?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Members"}])},[a?.name,m]);const u=L({queryKey:h.access.companyMembers(i??""),queryFn:t(()=>j.listMembers(i),"queryFn"),enabled:!!i}),xe=L({queryKey:h.agents.list(i??""),queryFn:t(()=>Ee.list(i),"queryFn"),enabled:!!i}),pe=L({queryKey:h.access.joinRequests(i??"","pending_approval"),queryFn:t(()=>j.listJoinRequests(i,"pending_approval"),"queryFn"),enabled:!!i&&!!u.data?.access.canApproveJoinRequests}),_=t(async()=>{i&&(await c.invalidateQueries({queryKey:h.access.companyMembers(i)}),await c.invalidateQueries({queryKey:h.access.companyUserDirectory(i)}),await c.invalidateQueries({queryKey:h.access.joinRequests(i,"pending_approval")}))},"refreshAccessData"),J=A({mutationFn:t(async s=>j.updateMember(i,s.memberId,{membershipRole:s.membershipRole,status:s.status}),"mutationFn"),onSuccess:t(async()=>{y(null),await _(),o({title:"Member updated",tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to update member",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")}),V=A({mutationFn:t(s=>j.approveJoinRequest(i,s),"mutationFn"),onSuccess:t(async()=>{await _(),o({title:"Join request approved",tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to approve join request",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")}),W=A({mutationFn:t(s=>j.rejectJoinRequest(i,s),"mutationFn"),onSuccess:t(async()=>{await _(),o({title:"Join request rejected",tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to reject join request",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")}),p=(0,r.useMemo)(()=>u.data?.members.find(s=>s.id===P)??null,[P,u.data?.members]),x=(0,r.useMemo)(()=>u.data?.members.find(s=>s.id===l)??null,[l,u.data?.members]),O=L({queryKey:["access","member-assigned-issues",i??"",x?.principalId??""],queryFn:t(()=>ke.list(i,{assigneeUserId:x.principalId,status:Be}),"queryFn"),enabled:!!i&&!!x}),Q=A({mutationFn:t(async s=>{const N=s.target.startsWith("agent:")?{assigneeAgentId:s.target.slice(6),assigneeUserId:null}:s.target.startsWith("user:")?{assigneeAgentId:null,assigneeUserId:s.target.slice(5)}:null;return j.archiveMember(i,s.memberId,{reassignment:N})},"mutationFn"),onSuccess:t(async s=>{w(null),q("__unassigned"),await _(),i&&(await c.invalidateQueries({queryKey:h.issues.list(i)}),await c.invalidateQueries({queryKey:h.issues.listAssignedToMe(i)}),await c.invalidateQueries({queryKey:h.issues.listTouchedByMe(i)})),o({title:"Member removed",body:s.reassignedIssueCount>0?`${s.reassignedIssueCount} assigned task${s.reassignedIssueCount===1?"":"s"} cleaned up.`:void 0,tone:"success"})},"onSuccess"),onError:t(s=>{o({title:"Failed to remove member",body:s instanceof Error?s.message:"Unknown error",tone:"error"})},"onError")});if((0,r.useEffect)(()=>{p&&(f(p.membershipRole),$(Ke(p.status)?p.status:"suspended"))},[p]),(0,r.useEffect)(()=>{x&&q("__unassigned")},[x]),!i)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization to manage access."});if(u.isLoading)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading organization access…"});if(u.error){const s=u.error instanceof de&&u.error.status===403?"You do not have permission to manage organization members.":u.error instanceof Error?u.error.message:"Failed to load organization members.";return(0,e.jsx)("div",{className:"text-sm text-bad",children:s})}const B=u.data?.members??[],D=u.data?.access,H=pe.data?.filter(s=>s.requestType==="human")??[],he=V.isPending||W.isPending,Y=B.filter(s=>s.status==="active"&&s.principalType==="user"&&s.id!==l),G=(xe.data??[]).filter(He),I=O.data??[];return(0,e.jsxs)("div",{className:"max-w-6xl space-y-8",children:[(0,e.jsx)("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)(Ae,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Organization Members"})]})}),(0,e.jsxs)(Re,{value:T,onValueChange:M,className:"flex flex-col gap-4",children:[!g&&(0,e.jsx)(Le,{items:[{value:"members",label:"Members"},{value:"invites",label:"Invites"}],align:"start",value:T,onValueChange:M}),(0,e.jsxs)(ee,{value:"members",className:"space-y-8",children:[D&&!D.currentUserRole&&(0,e.jsx)("div",{className:"rounded-xl bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",children:"This account can manage access here through instance-admin privileges, but it does not currently hold an active organization membership."}),(0,e.jsxs)("section",{className:"space-y-4",children:[D?.canApproveJoinRequests&&H.length>0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:"Pending human joins"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Review pending join requests before they become active organization members."})]}),(0,e.jsxs)(F,{variant:"outline",children:[H.length," pending"]})]}),(0,e.jsx)("div",{className:"space-y-3",children:H.map(s=>(0,e.jsx)($e,{title:s.requesterUser?.name||s.requestEmailSnapshot||s.requestingUserId||"Unknown human requester",subtitle:s.requesterUser?.email||s.requestEmailSnapshot||s.requestingUserId||"No email available",context:s.invite?`${s.invite.allowedJoinTypes} join invite${s.invite.humanRole?` • default role ${s.invite.humanRole}`:""}`:"Invite metadata unavailable",detail:`Submitted ${new Date(s.createdAt).toLocaleString()}`,approveLabel:"Approve human",rejectLabel:"Reject human",disabled:he,onApprove:t(()=>V.mutate(s.id),"onApprove"),onReject:t(()=>W.mutate(s.id),"onReject")},s.id))})]}):null,(0,e.jsx)("div",{className:"overflow-x-auto",children:(0,e.jsxs)("table",{className:"w-full min-w-(--sz-44rem) text-left text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line text-ink-3",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Name"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Email"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Role"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"}),(0,e.jsx)("th",{className:"px-3 py-2 text-right font-medium",children:"Action"})]})}),(0,e.jsx)("tbody",{children:B.length===0?(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:5,className:"px-3 py-8 text-ink-3",children:"No user memberships found for this organization yet."})}):B.map(s=>{const N=s.removal?.reason??null,C=s.removal?.canArchive??!0,X=E(s);return(0,e.jsxs)("tr",{className:"border-b border-line last:border-b-0",children:[(0,e.jsx)("td",{className:"px-3 py-3",children:(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,e.jsxs)(Ce,{size:"sm",children:[s.user?.image?(0,e.jsx)(we,{src:s.user.image,alt:X}):null,(0,e.jsx)(Ie,{children:De(s)})]}),(0,e.jsx)("span",{className:"truncate font-medium",children:X})]})}),(0,e.jsx)("td",{className:"px-3 py-3 text-ink-3",children:s.user?.email||s.principalId}),(0,e.jsx)("td",{className:"px-3 py-3",children:s.membershipRole?Z[s.membershipRole]:"Unset"}),(0,e.jsx)("td",{className:"px-3 py-3",children:(0,e.jsx)(F,{variant:s.status==="active"?"secondary":s.status==="suspended"?"destructive":"outline",children:s.status.replace("_"," ")})}),(0,e.jsx)("td",{className:"px-3 py-3 text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)(d,{size:"sm",variant:"secondary",onClick:t(()=>y(s.id),"onClick"),children:"Edit"}),(0,e.jsx)("span",{className:"inline-flex",title:C?void 0:N??void 0,children:(0,e.jsxs)(d,{size:"sm",variant:"secondary",onClick:t(()=>w(s.id),"onClick"),disabled:!C,title:C?void 0:N??void 0,children:[(0,e.jsx)(Me,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]})})]})})]},s.id)})})]})})]}),(0,e.jsx)(re,{open:!!p,onOpenChange:t(s=>!s&&y(null),"onOpenChange"),children:(0,e.jsxs)(ne,{className:"max-w-2xl",children:[(0,e.jsxs)(se,{children:[(0,e.jsx)(ie,{children:"Edit member"}),(0,e.jsxs)(ae,{children:["Update organization role and membership status for ",p?.user?.name||p?.user?.email||p?.principalId,"."]})]}),p&&(0,e.jsx)("div",{className:"space-y-5",children:(0,e.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,e.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,e.jsx)("span",{className:"font-medium",children:"Organization role"}),(0,e.jsxs)("select",{className:"w-full rounded-md border border-line bg-bg px-3 py-2",value:n??"",onChange:t(s=>f(s.target.value||null),"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Unset"}),Object.entries(Z).map(([s,N])=>(0,e.jsx)("option",{value:s,children:N},s))]})]}),(0,e.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,e.jsx)("span",{className:"font-medium",children:"Membership status"}),(0,e.jsxs)("select",{className:"w-full rounded-md border border-line bg-bg px-3 py-2",value:S,onChange:t(s=>$(s.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"active",children:"Active"}),(0,e.jsx)("option",{value:"pending",children:"Pending"}),(0,e.jsx)("option",{value:"suspended",children:"Suspended"})]})]})]})}),(0,e.jsxs)(te,{children:[(0,e.jsx)(d,{variant:"secondary",onClick:t(()=>y(null),"onClick"),children:"Cancel"}),(0,e.jsx)(d,{onClick:t(()=>{p&&J.mutate({memberId:p.id,membershipRole:n,status:S})},"onClick"),disabled:J.isPending,children:J.isPending?"Saving…":"Save member"})]})]})}),(0,e.jsx)(re,{open:!!x,onOpenChange:t(s=>!s&&w(null),"onOpenChange"),children:(0,e.jsxs)(ne,{className:"max-w-xl",children:[(0,e.jsxs)(se,{children:[(0,e.jsx)(ie,{children:"Remove member"}),(0,e.jsxs)(ae,{children:["Archive ",E(x)," and move active assignments before hiding this user from assignment fields."]})]}),x&&(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-line px-3 py-3",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:E(x)}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:x.user?.email||x.principalId}),(0,e.jsx)("div",{className:"mt-2 text-sm text-ink-3",children:O.isLoading?"Checking assigned tasks...":`${I.length} open assigned task${I.length===1?"":"s"}`})]}),I.length>0?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Task reassignment"}),(0,e.jsxs)("select",{className:"w-full rounded-md border border-line bg-bg px-3 py-2 text-sm",value:R,onChange:t(s=>q(s.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"__unassigned",children:"Leave unassigned"}),Y.length>0?(0,e.jsx)("optgroup",{label:"Humans",children:Y.map(s=>(0,e.jsx)("option",{value:`user:${s.principalId}`,children:E(s)},s.id))}):null,G.length>0?(0,e.jsx)("optgroup",{label:"Agents",children:G.map(s=>(0,e.jsxs)("option",{value:`agent:${s.id}`,children:[s.name," (",s.role,")"]},s.id))}):null]}),(0,e.jsxs)("div",{className:"max-h-36 overflow-auto rounded-lg border border-line",children:[I.slice(0,6).map(s=>(0,e.jsxs)("div",{className:"border-b border-line px-3 py-2 text-sm last:border-b-0",children:[(0,e.jsx)("div",{className:"font-medium",children:s.identifier??s.id.slice(0,8)}),(0,e.jsx)("div",{className:"truncate text-ink-3",children:s.title})]},s.id)),I.length>6?(0,e.jsxs)("div",{className:"px-3 py-2 text-sm text-ink-3",children:[I.length-6," more task",I.length-6===1?"":"s"]}):null]})]}):null]}),(0,e.jsxs)(te,{children:[(0,e.jsx)(d,{variant:"secondary",onClick:t(()=>w(null),"onClick"),children:"Cancel"}),(0,e.jsx)(d,{variant:"danger",onClick:t(()=>{x&&Q.mutate({memberId:x.id,target:R})},"onClick"),disabled:Q.isPending||O.isLoading,children:Q.isPending?"Removing...":"Remove member"})]})]})})]}),!g&&(0,e.jsx)(ee,{value:"invites",children:(0,e.jsx)(Je,{})})]})]})}t(ys,"CompanyAccess");function fs(){const{selectedCompanyId:a}=K(),{setBreadcrumbs:i}=ue(),{slots:m,isLoading:o,errorMessage:c}=Te({slotTypes:["companySettingsPage"],companyId:a,enabled:!!a});return(0,r.useEffect)(()=>{i([{label:"Settings",href:"/company/settings"},{label:"Access"}])},[i]),m.find(v=>v.routePath==="permissions")?(0,e.jsx)(Ne,{to:"/company/settings/permissions",replace:!0}):o?(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Checking for advanced permission extensions..."}):(0,e.jsxs)("div",{className:"max-w-2xl space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ue,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Advanced Permissions"})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Advanced access, scoped assignment, and explicit grant controls are provided by installed organization settings extensions."})]}),(0,e.jsxs)("div",{className:"space-y-4 rounded-xl border border-line px-5 py-5",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold",children:"Advanced permissions unavailable"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Core Wardmote keeps enforcing organization boundaries and any existing restrictive policy data, but editing advanced permissions requires an installed extension."}),c?(0,e.jsxs)("p",{className:"text-sm text-bad",children:["Plugin extensions unavailable: ",c]}):null]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsx)(d,{asChild:!0,children:(0,e.jsx)(z,{to:"/company/settings/members",children:"Open Members"})}),(0,e.jsx)(d,{asChild:!0,variant:"secondary",children:(0,e.jsx)(z,{to:"/company/settings/members?tab=invites",children:"Open Invites"})})]})]})]})}t(fs,"CompanyAccessLegacyRoute");function E(a){return a?a.user?.name?.trim()||a.user?.email||a.principalId:"this member"}t(E,"memberDisplayName");function De(a){const i=E(a).trim(),m=i.split(/\s+/).filter(Boolean);return m.length>1?`${m[0]?.[0]??""}${m.at(-1)?.[0]??""}`.toUpperCase():i.slice(0,2).toUpperCase()}t(De,"memberInitials");function He(a){return a.status!=="terminated"&&a.status!=="pending_approval"}t(He,"isAssignableAgent");function Ke(a){return a==="pending"||a==="active"||a==="suspended"}t(Ke,"isEditableMemberStatus");function $e({title:a,subtitle:i,context:m,detail:o,detailSecondary:c,approveLabel:v,rejectLabel:U,disabled:b,onApprove:g,onReject:k}){return(0,e.jsx)("div",{className:"py-3",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"font-medium",children:a}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:i})]}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:m}),(0,e.jsx)("div",{className:"text-sm text-ink-3",children:o}),c?(0,e.jsx)("div",{className:"text-sm text-ink-3",children:c}):null]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(d,{type:"button",variant:"secondary",onClick:k,disabled:b,children:U}),(0,e.jsx)(d,{type:"button",onClick:g,disabled:b,children:v})]})]})})}t($e,"PendingJoinRequestCard");export{ys as CompanyAccess,fs as CompanyAccessLegacyRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o=Object.defineProperty;var t=(i,r)=>o(i,"name",{value:r,configurable:!0});import{i as m}from"./rolldown-runtime-ZpX3ckPj.js";import{la as e}from"./createLucideIcon-CgrPXnTY.js";import{AuditHub as n}from"./AuditHub-
|
|
1
|
+
var o=Object.defineProperty;var t=(i,r)=>o(i,"name",{value:r,configurable:!0});import{i as m}from"./rolldown-runtime-ZpX3ckPj.js";import{la as e}from"./createLucideIcon-CgrPXnTY.js";import{AuditHub as n}from"./AuditHub-DCksM6Df.js";var u=m(e(),1);function c(){return(0,u.jsx)(n,{section:"activity"})}t(c,"CompanyActivity");export{c as CompanyActivity};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var M=Object.defineProperty;var o=(n,a)=>M(n,"name",{value:a,configurable:!0});import{i as E}from"./rolldown-runtime-ZpX3ckPj.js";import{M as A,la as R,ua as L}from"./createLucideIcon-CgrPXnTY.js";import{X as O,_ as F,v as D}from"./queryKeys-BzT8CD34.js";import{n as z,ut as q}from"./ConnectionSetupFlow-g6asOGFg.js";import{n as K}from"./CompanyContext-fQCNWI_f.js";import{r as Q,t as T}from"./router-BKzUF9uf.js";import{t as B}from"./link-2-Cn4f4xsG.js";import{t as C}from"./button-DI4w5WP7.js";import{a as U,n as $,r as J,s as V,t as G}from"./dialog-CeH7rDcv.js";import{t as H}from"./input-BBNGmECW.js";import{t as P}from"./AppLogo-BLq8BpKi.js";import{n as W}from"./BreadcrumbContext-DNbB7zWn.js";import{o as _}from"./agent-config-primitives-BJlDiwaH.js";import{ii as X}from"./index-
|
|
1
|
+
var M=Object.defineProperty;var o=(n,a)=>M(n,"name",{value:a,configurable:!0});import{i as E}from"./rolldown-runtime-ZpX3ckPj.js";import{M as A,la as R,ua as L}from"./createLucideIcon-CgrPXnTY.js";import{X as O,_ as F,v as D}from"./queryKeys-BzT8CD34.js";import{n as z,ut as q}from"./ConnectionSetupFlow-g6asOGFg.js";import{n as K}from"./CompanyContext-fQCNWI_f.js";import{r as Q,t as T}from"./router-BKzUF9uf.js";import{t as B}from"./link-2-Cn4f4xsG.js";import{t as C}from"./button-DI4w5WP7.js";import{a as U,n as $,r as J,s as V,t as G}from"./dialog-CeH7rDcv.js";import{t as H}from"./input-BBNGmECW.js";import{t as P}from"./AppLogo-BLq8BpKi.js";import{n as W}from"./BreadcrumbContext-DNbB7zWn.js";import{o as _}from"./agent-config-primitives-BJlDiwaH.js";import{ii as X}from"./index-b1wwaMjV.js";import{t as Y}from"./DecisionModelSettings-HEZJ0E6n.js";import{t as k}from"./fast-responses-B5vx8axv.js";var c=E(L(),1),e=E(R(),1),w=o(n=>({enabled:n.enabled,connectionId:n.connectionId,grantId:n.grantId,model:n.model,allowSponsored:n.allowSponsored}),"editable");function Z({settings:n,choices:a,models:f=[],saving:r,testing:u,error:y,result:x,newlyConnectedId:m,onSave:b,onTest:N,onConnectionChange:h,onAdd:S}){const[l,p]=(0,c.useState)(()=>w(n)),d=(0,c.useId)(),I=JSON.stringify(w(n));(0,c.useEffect)(()=>{p(w(n)),h?.(n.connectionId)},[I]);const g=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(!m){g.current=null;return}if(g.current===m)return;const s=a.find(i=>i.id===m);s&&(g.current=m,p(i=>({...i,connectionId:s.id,grantId:s.grantId,model:s.provider==="openrouter"||s.routing?.kind==="openrouter"?A:s.routing?.models[0]?.id??null,enabled:i.connectionId?i.enabled:!0})),h?.(s.id))},[m,a,h]);const t=a.find(s=>s.grantId===l.grantId),j=l.enabled!==n.enabled||l.grantId!==n.grantId||l.model!==n.model||l.allowSponsored!==n.allowSponsored;return(0,e.jsxs)("section",{className:"max-w-2xl space-y-4","aria-label":"Fast response",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold",children:"Fast response"}),(0,e.jsx)(T,{to:"/activity/costs?tab=fast-responses",className:"text-sm underline underline-offset-4",children:"View usage"})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Send a short acknowledgement while your agent starts work. Usage is charged to the selected shared API connection."}),(0,e.jsx)(q,{selectedId:l.grantId??void 0,disabled:r||u,choices:a.map(s=>({id:s.grantId,name:s.name,description:s.status==="connected"?"Connected":"Needs attention",icon:(0,e.jsx)(P,{name:s.provider,brandKey:s.provider,size:24})})),onSelect:o(s=>{const i=a.find(v=>v.grantId===s);p(v=>({...v,connectionId:i.id,grantId:s,model:i.provider==="openrouter"||i.routing?.kind==="openrouter"?A:i.routing?.models[0]?.id??null,enabled:v.connectionId?v.enabled:!0})),h?.(i.id)},"onSelect")}),!a.length&&(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Add a shared API connection in Apps to get started."}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[S&&(0,e.jsx)(C,{variant:"secondary",size:"sm",onClick:S,children:"Add connection"}),(0,e.jsx)(T,{to:"/apps",className:"text-sm underline underline-offset-4",children:"Manage connections"})]}),l.connectionId&&(0,e.jsxs)("fieldset",{disabled:r||u,className:"space-y-4",children:[!t&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"The saved connection is unavailable. Disable fast responses or choose another connection."}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("label",{htmlFor:`${d}-input`,className:"text-sm font-medium",children:"Model"}),(0,e.jsx)(H,{id:`${d}-input`,list:d,value:l.model??"",placeholder:"Choose or enter a model ID",onChange:o(s=>p(i=>({...i,model:s.target.value||null})),"onChange")}),(0,e.jsx)("datalist",{id:d,children:f.map(s=>(0,e.jsx)("option",{value:s.id,children:s.label??s.id},s.id))})]}),(0,e.jsx)(_,{label:"Enable fast responses",checked:l.enabled,onChange:o(s=>p(i=>({...i,enabled:s})),"onChange")}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(_,{label:"Allow company-sponsored fast responses",checked:l.allowSponsored,onChange:o(s=>p(i=>({...i,allowSponsored:s})),"onChange")}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Covers accepted external messages from people without a linked Wardmote account."})]})]}),y&&(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:y}),!j&&x&&(x.status==="succeeded"?(0,e.jsxs)("div",{role:"status",className:"space-y-2 text-sm",children:[(0,e.jsx)("p",{children:x.text}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:[(x.durationMs/1e3).toFixed(2)," seconds ·"," ",x.usage.inputTokens??"—"," input /"," ",x.usage.outputTokens??"—"," output tokens · Usage recorded in Costs."]})]}):(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:x.reason==="timeout"?"The model did not respond within three seconds. Try a faster model.":"Could not generate a response. Check the connection and model, then try again."})),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(C,{variant:"secondary",size:"sm",onClick:N,disabled:j||!n.enabled||r||u,children:u?"Testing…":"Test response"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:j?"Save changes before testing.":"Runs a small sample with an API charge."})]}),j&&(0,e.jsx)(C,{disabled:r||u||l.enabled&&(!l.model||t?.status!=="connected"),onClick:o(()=>b(l),"onClick"),children:r?"Saving…":"Save fast response"})]})]})}o(Z,"FastResponseSettingsView");function ee({companyId:n}){const a=O(),f=["fast-response",n],r=D({queryKey:f,queryFn:o(()=>k.settings(n),"queryFn")}),[u,y]=(0,c.useState)(null),[x,m]=(0,c.useState)(!1),[b,N]=(0,c.useState)(null),[h,S]=(0,c.useState)(null),l=D({queryKey:["fast-response-models",n,h],queryFn:o(()=>k.models(n,h),"queryFn"),enabled:!!h}),p=JSON.stringify(r.data?.settings??{companyId:n}),d=F({mutationFn:o(t=>k.test(n),"mutationFn"),onSettled:o(()=>{a.invalidateQueries({queryKey:["fast-response-history",n]}),a.invalidateQueries({predicate:o(t=>String(t.queryKey[0]).includes("cost"),"predicate")})},"onSettled")}),I=d.reset;(0,c.useEffect)(()=>{I()},[p,I]);const g=F({mutationFn:o(t=>k.update(n,t),"mutationFn"),onSuccess:o(t=>{d.reset(),a.setQueryData(f,{...r.data,settings:t})},"onSuccess")});return r.isPending?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading fast response…"}):r.error?(0,e.jsxs)("div",{role:"alert",children:[(0,e.jsx)("p",{className:"text-sm text-bad",children:"Could not load fast response settings."}),(0,e.jsx)(C,{variant:"secondary",onClick:o(()=>{r.refetch()},"onClick"),children:"Try again"})]}):!r.data?.canManage||!r.data.settings?null:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Z,{newlyConnectedId:u,settings:r.data.settings,choices:r.data.choices,models:l.data,saving:g.isPending,testing:d.isPending,error:g.error?.message??d.error?.message??(l.error?"Could not load models. Enter a model ID or retry later.":null),result:d.variables===p?d.data:null,onConnectionChange:S,onSave:o(t=>g.mutate(t),"onSave"),onTest:o(()=>d.mutate(p),"onTest"),onAdd:o(()=>{N(null),m(!0)},"onAdd")},n),(0,e.jsx)(G,{open:x,onOpenChange:m,children:(0,e.jsxs)($,{className:"sm:max-w-2xl max-h-(--sz-85vh) overflow-y-auto",children:[(0,e.jsxs)(U,{children:[(0,e.jsx)(V,{children:"Add a fast response connection"}),(0,e.jsx)(J,{children:"Use a shared API connection for short acknowledgements."})]}),b?(0,e.jsx)(z,{host:"dialog",serviceSlug:b,forceNewConnection:!0,aiConnection:{provider:b,method:"api_key",mode:"shared"},requiredAiOwnership:"shared",onCancel:o(()=>m(!1),"onCancel"),onComplete:o(async t=>{const j=await r.refetch();"connectionId"in t&&t.connectionId&&j.data?.choices.some(s=>s.id===t.connectionId)&&y(t.connectionId),m(!1)},"onComplete")}):(0,e.jsx)(q,{choices:["openrouter","openai","anthropic","google","xai"].map(t=>({id:t,description:"Shared API connection",name:t==="openrouter"?"OpenRouter":t==="openai"?"OpenAI":t==="xai"?"xAI":t==="google"?"Google":"Anthropic",icon:(0,e.jsx)(P,{name:t,brandKey:t,size:24})})),onSelect:o(t=>N(t),"onSelect")})]})})]})}o(ee,"FastResponseSettingsSection");function je(){const{selectedCompany:n,selectedCompanyId:a}=K(),{setBreadcrumbs:f}=W(),{enabled:r,loaded:u}=X();return(0,c.useEffect)(()=>{f([{label:n?.name??"Company",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Connections"}])},[f,n?.name]),u?r?a?(0,e.jsxs)("div",{className:"max-w-6xl space-y-8",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(B,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Connections"})]}),(0,e.jsx)(Y,{companyId:a},a),(0,e.jsx)("div",{className:"max-w-2xl border-t border-line pt-8",children:(0,e.jsx)(ee,{companyId:a},`fast-${a}`)})]}):(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"No organization selected. Select an organization from the switcher above."}):(0,e.jsx)(Q,{to:"/company/settings",replace:!0}):null}o(je,"CompanyConnections");export{je as CompanyConnections};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var ct=Object.defineProperty;var s=(n,a)=>ct(n,"name",{value:a,configurable:!0});import{i as Je}from"./rolldown-runtime-ZpX3ckPj.js";import{la as dt,ua as ut}from"./createLucideIcon-CgrPXnTY.js";import{n as mt,v as ft}from"./star-eem0qj3E.js";import{X as Ge,_ as H,n as pt,t as A,v as U}from"./queryKeys-BzT8CD34.js";import{n as ht}from"./CompanyContext-fQCNWI_f.js";import{o as xt,t as ae}from"./router-BKzUF9uf.js";import{a as gt,c as vt,i as bt,n as yt,o as St,r as wt,s as jt,t as kt}from"./alert-dialog-DNbnZgRz.js";import{t as Ct}from"./arrow-left-CnGEiANj.js";import{t as Nt}from"./check-Bis3vECb.js";import{t as Et}from"./environment-variables-editor-D6Ylcd74.js";import{t as Pt}from"./link-2-Cn4f4xsG.js";import{t as P}from"./button-DI4w5WP7.js";import{t as Tt}from"./play-Czm7OCYh.js";import{t as Rt}from"./plus-CwNlqadt.js";import{t as It}from"./refresh-cw-CfzWP9se.js";import{t as _t}from"./rotate-ccw-DpzLJhXT.js";import{t as $e}from"./terminal-i6UlT3R6.js";import{t as Ye}from"./trash-QxFF084e.js";import{t as Dt}from"./x-6E1yeU3Q.js";import{i as Xe}from"./ToastContext-DyVJ6bCh.js";import{t as Le}from"./agents-B8n-p0aX.js";import{t as be}from"./instanceSettings-D1nNVWU0.js";import{n as Kt}from"./BreadcrumbContext-DNbB7zWn.js";import{t as Me}from"./secrets-D17QEm13.js";import{i as At,n as ye,r as Ft,t as $t}from"./JsonSchemaForm-Dkh3zdL9.js";import{a as q,o as Oe}from"./agent-config-primitives-BJlDiwaH.js";import{t as k}from"./environments-xuhuvnTt.js";import{r as Se,t as Lt}from"./managed-sandbox-environment-B8DewKvK.js";import{zt as Mt}from"./index-BcwxLap4.js";import{a as Ot,i as Ht,r as Bt}from"./terminal-font-B-qtwS34.js";var d=Je(ut(),1),t=Je(dt(),1),Z="/company/settings/instance/environments";function qt(n){return`${Z}/${encodeURIComponent(n)}/edit`}s(qt,"environmentEditPath");function zt(n){return n.staticReferences.isManagedLocal?"Cannot delete the managed local environment.":n.staticReferences.isInstanceDefault?"Cannot delete the current instance default environment. Set a new default environment before deleting this one.":n.pendingCleanupLeaseCount>0?"Cannot delete this environment while a sandbox cleanup is pending. Wait for the cleanup sweep to destroy the orphan sandbox, then retry.":n.reusableSandboxLeaseCount>0?"Cannot delete this environment while it has a reusable sandbox lease. Remove the associated execution workspace or issue so Wardmote can destroy the sandbox, then retry.":null}s(zt,"environmentDeleteBlockMessage");function Ce(n){return{name:n.name.trim(),description:n.description.trim()||null,driver:n.driver,envVars:n.envVars,config:n.driver==="ssh"?{host:n.sshHost.trim(),port:Number.parseInt(n.sshPort||"22",10)||22,username:n.sshUsername.trim(),remoteWorkspacePath:n.sshRemoteWorkspacePath.trim(),privateKey:n.sshPrivateKey.trim()||null,privateKeySecretRef:n.sshPrivateKey.trim().length>0||!n.sshPrivateKeySecretId?null:{type:"secret_ref",secretId:n.sshPrivateKeySecretId,version:"latest"},knownHosts:n.sshKnownHosts.trim()||null,strictHostKeyChecking:n.sshStrictHostKeyChecking}:n.driver==="sandbox"?{provider:n.sandboxProvider.trim(),...n.sandboxConfig}:{}}}s(Ce,"buildEnvironmentPayload");function G(){return{name:"",description:"",driver:"ssh",sshHost:"",sshPort:"22",sshUsername:"",sshRemoteWorkspacePath:"",sshPrivateKey:"",sshPrivateKeySecretId:"",sshKnownHosts:"",sshStrictHostKeyChecking:!0,sandboxProvider:"",sandboxConfig:{},envVars:{}}}s(G,"createEmptyEnvironmentForm");function Ze(n){return n?.driver==="local"}s(Ze,"isLocalEnvironment");function Wt(n,a){return n?Ze(a.find(u=>u.id===n)??null)?"":n:""}s(Wt,"normalizeNonLocalEnvironmentId");function Ut(n){const a=n.config??{};return{host:typeof a.host=="string"?a.host:"",port:typeof a.port=="number"?String(a.port):typeof a.port=="string"?a.port:"22",username:typeof a.username=="string"?a.username:"",remoteWorkspacePath:typeof a.remoteWorkspacePath=="string"?a.remoteWorkspacePath:"",privateKey:"",privateKeySecretId:a.privateKeySecretRef&&typeof a.privateKeySecretRef=="object"&&!Array.isArray(a.privateKeySecretRef)&&typeof a.privateKeySecretRef.secretId=="string"?String(a.privateKeySecretRef.secretId):"",knownHosts:typeof a.knownHosts=="string"?a.knownHosts:"",strictHostKeyChecking:typeof a.strictHostKeyChecking=="boolean"?a.strictHostKeyChecking:!0}}s(Ut,"readSshConfig");function Qt(n){const{provider:a,...u}=n.config??{};return{provider:typeof a=="string"&&a.trim().length>0?a:"fake",config:u}}s(Qt,"readSandboxConfig");function Vt(n){if(n.driver==="ssh"){const a=Ut(n);return{...G(),name:n.name,description:n.description??"",driver:"ssh",sshHost:a.host,sshPort:a.port,sshUsername:a.username,sshRemoteWorkspacePath:a.remoteWorkspacePath,sshPrivateKey:a.privateKey,sshPrivateKeySecretId:a.privateKeySecretId,sshKnownHosts:a.knownHosts,sshStrictHostKeyChecking:a.strictHostKeyChecking,envVars:n.envVars??{}}}if(n.driver==="sandbox"){const a=Qt(n);return{...G(),name:n.name,description:n.description??"",driver:"sandbox",sandboxProvider:a.provider,sandboxConfig:a.config,envVars:n.envVars??{}}}return{...G(),name:n.name,description:n.description??"",driver:"local",envVars:n.envVars??{}}}s(Vt,"createEnvironmentFormFromEnvironment");var He="Discard unsaved environment changes?";function Ne(n){return Array.isArray(n)?`[${n.map(a=>Ne(a)).join(",")}]`:n&&typeof n=="object"?`{${Object.entries(n).filter(([,a])=>a!==void 0).sort(([a],[u])=>a.localeCompare(u)).map(([a,u])=>`${JSON.stringify(a)}:${Ne(u)}`).join(",")}}`:JSON.stringify(n)??"undefined"}s(Ne,"stableJsonStringify");function we(n){return Ne(Ce(n))}s(we,"environmentFormKey");function Jt(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}s(Jt,"normalizeJsonSchema");function Gt(n){for(const a of["template","image","region","workspacePath"]){const u=n[a];if(typeof u=="string"&&u.trim().length>0)return u}return null}s(Gt,"summarizeSandboxConfig");var Yt=new Set(["starting","waiting_for_user","capturing"]);function je(n){return!!(n&&Yt.has(n.status))}s(je,"isActiveCustomImageSetupSession");function Be(n){return n.driver==="sandbox"&&typeof n.config.provider=="string"?n.config.provider:null}s(Be,"readEnvironmentSandboxProvider");function ke(n){if(!n)return null;const a=n instanceof Date?n:new Date(n);return Number.isNaN(a.getTime())?null:a.toLocaleString()}s(ke,"formatDateTime");function Xt(n){const a=n.trim();return a.length<=12?a:`${a.slice(0,12)}…`}s(Xt,"formatShortId");function qe(n){return typeof n=="string"?n:n==null?"none":JSON.stringify(n)}s(qe,"formatBootSourceDriftValue");function Zt(n){if(!n||n.classification!=="boot_source_drift")return null;const a=n.driftedPaths.filter(u=>"from"in u||"to"in u).map(u=>`${u.path} \`${qe(u.from)}\` -> \`${qe(u.to)}\``);return a.length===0?null:`Base image changed: ${a.join("; ")}`}s(Zt,"formatBootSourceDriftSummary");function et(n){return typeof n?.command=="string"&&n.command.trim().length>0?n.command:null}s(et,"readConnectionCommand");function en(n){return n.refreshError?"Setup connection details could not be refreshed. You can still finish or cancel this setup.":n.isLoading?null:n.payload?n.payload.type!=="ssh"?"Browser terminal is not available for this provider connection. Use the provider setup instructions, then finish or cancel here.":et(n.payload)?null:"Connection details are not available yet. You can still finish or cancel this setup.":"Connection details are not available yet. You can still finish or cancel this setup."}s(en,"setupConnectionFallbackMessage");var ze=100,We=28,tn=5e3,nn=Bt();function sn(n,a){return`${n}${n.includes("?")?"&":"?"}${new URLSearchParams(Object.fromEntries(Object.entries(a).map(([u,o])=>[u,String(o)]))).toString()}`}s(sn,"appendTerminalQuery");function rn(n){try{const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:null}catch{return null}}s(rn,"parseTerminalFrame");function an(n){switch(n){case"connecting":return"Connecting";case"connected":return"Connected";case"closed":return"Closed";case"error":return"Connection failed";default:return"Ready to connect"}}s(an,"customImageTerminalStatusCopy");function on(n){if(n!=="expired"&&n!=="ssh_closed"&&n!=="server_shutdown"&&n!=="setup_finished"&&n!=="setup_cancelled")return typeof n=="string"&&n.trim()?"Terminal closed.":null;switch(n){case"expired":return"Setup session expired.";case"ssh_closed":return"SSH session closed.";case"server_shutdown":return"Terminal server shut down.";case"setup_finished":return"Setup session finished.";case"setup_cancelled":return"Setup session cancelled.";default:return null}}s(on,"customImageTerminalCloseReasonCopy");function ln({autoConnect:n=!1,sessionId:a}){const[u,o]=(0,d.useState)("idle"),[N,g]=(0,d.useState)(null),T=(0,d.useRef)(null),p=(0,d.useRef)(null),m=(0,d.useRef)(null),l=(0,d.useRef)(null),h=(0,d.useRef)(null),D=(0,d.useRef)(null),S=(0,d.useRef)(null),z=(0,d.useRef)(null),_=(0,d.useRef)(null),F=(0,d.useCallback)((f="operator_closed")=>{const y=S.current;S.current=null,y&&y.readyState!==WebSocket.CLOSED&&y.readyState!==WebSocket.CLOSING&&y.close(1e3,f)},[]),R=(0,d.useCallback)(()=>{const f=p.current;return{cols:f?.cols||ze,rows:f?.rows||We}},[]),Q=(0,d.useCallback)((f=!1)=>{const y=S.current;if(!y||y.readyState!==WebSocket.OPEN)return;const I=R(),w=_.current;!f&&w?.cols===I.cols&&w.rows===I.rows||(_.current=I,y.send(JSON.stringify({type:"resize",cols:I.cols,rows:I.rows})))},[R]),K=(0,d.useCallback)(()=>{const f=m.current;if(!(!f||!p.current))try{f.fit(),Q()}catch{}},[Q]),$=(0,d.useCallback)(()=>{D.current!==null&&window.cancelAnimationFrame(D.current),D.current=window.requestAnimationFrame(()=>{D.current=null,K()})},[K]),E=(0,d.useCallback)(f=>{const y=S.current;!y||y.readyState!==WebSocket.OPEN||y.send(JSON.stringify({type:"input",data:f}))},[]),b=(0,d.useCallback)(()=>{const f=p.current;f&&(f.reset(),f.clear())},[]);(0,d.useEffect)(()=>{const f=T.current;if(!f||p.current)return;const y=new Ot({allowTransparency:!0,cols:ze,rows:We,convertEol:!1,cursorBlink:!0,cursorInactiveStyle:"bar",cursorStyle:"bar",cursorWidth:2,fontFamily:nn,fontSize:12,letterSpacing:0,lineHeight:1.35,scrollback:tn,theme:{background:"#0a0a0a",foreground:"#f5f5f5",cursor:"#22d3ee",cursorAccent:"#020617",selectionBackground:"#2563eb55"}}),I=new Ht;if(y.loadAddon(I),y.open(f),p.current=y,m.current=I,l.current=y.onData(E),typeof ResizeObserver<"u"){const i=new ResizeObserver(()=>$());i.observe(f),h.current=i}y.focus(),$();const w=[50,250].map(i=>window.setTimeout(K,i)),C="fonts"in document?document.fonts?.ready:null;return C&&C.then(()=>K()),()=>{D.current!==null&&(window.cancelAnimationFrame(D.current),D.current=null);for(const i of w)window.clearTimeout(i);h.current?.disconnect(),h.current=null,l.current?.dispose(),l.current=null,m.current=null,p.current=null,y.dispose()}},[K,$,E]),(0,d.useEffect)(()=>()=>F("component_unmounted"),[F]),(0,d.useEffect)(()=>{F("session_changed"),z.current=null,_.current=null,o("idle"),g(null),b()},[F,b,a]),(0,d.useEffect)(()=>{u==="connected"&&p.current?.focus()},[u]);const M=(0,d.useCallback)(async()=>{if(typeof WebSocket>"u"){o("error"),g("Browser terminal is unavailable in this browser.");return}F("reconnect"),o("connecting"),_.current=null,g(null),b(),p.current?.focus();try{K();const f=R(),y=await k.createCustomImageTerminalSessionToken(a,{}),I=sn(y.websocketPath,{cols:f.cols,rows:f.rows}),w=new WebSocket(Mt(I));S.current=w,w.onopen=()=>{S.current===w&&(p.current?.focus(),w.send(JSON.stringify({type:"auth",token:y.token})),Q(!0))},w.onmessage=C=>{if(S.current!==w)return;const i=typeof C.data=="string"?C.data:"",x=i?rn(i):null;if(x){if(x.type==="ready"){o("connected"),p.current?.focus();return}if(x.type==="output"&&typeof x.data=="string"){p.current?.write(x.data);return}if(x.type==="error"){o("error"),g(typeof x.message=="string"?x.message:"Terminal connection failed.");return}x.type==="closed"&&(o("closed"),g(on(x.reason)))}},w.onclose=()=>{S.current===w&&(S.current=null,o(C=>C==="connected"||C==="connecting"?"closed":C))},w.onerror=()=>{S.current===w&&(o("error"),g("Terminal websocket connection failed."))}}catch(f){o("error"),g(f instanceof Error?f.message:"Terminal session could not be opened.")}},[F,K,R,b,Q,a]);(0,d.useEffect)(()=>{if(!n||u!=="idle"||z.current===a)return;const f=window.setTimeout(()=>{z.current=a,M()},0);return()=>window.clearTimeout(f)},[n,M,u,a]);const V=(0,d.useCallback)(()=>{F("operator_closed"),o("closed")},[F]),ee=u==="connected";return(0,t.jsxs)("div",{className:"mt-3 rounded-md border border-line/70 bg-bg","data-testid":`custom-image-terminal-${a}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-line/60 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-xs",children:[(0,t.jsx)($e,{className:"h-3.5 w-3.5 text-ink-3"}),(0,t.jsx)("span",{className:"font-medium",children:"Browser terminal"}),(0,t.jsx)("span",{className:"text-ink-3",children:an(u)})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:ee?(0,t.jsx)(P,{size:"sm",variant:"ghost",onClick:V,children:"Disconnect"}):(0,t.jsxs)(P,{size:"sm",variant:"secondary",onClick:s(()=>{M()},"onClick"),disabled:u==="connecting",children:[(0,t.jsx)($e,{className:"mr-1.5 h-3.5 w-3.5"}),u==="closed"||u==="error"?"Reconnect":"Open terminal"]})})]}),(0,t.jsx)("div",{className:"bg-neutral-950 p-2 focus-within:ring-2 focus-within:ring-focus",children:(0,t.jsx)("div",{ref:T,"data-testid":`custom-image-terminal-screen-${a}`,"aria-label":"Custom image browser terminal",role:"application",tabIndex:0,onFocus:s(()=>p.current?.focus(),"onFocus"),onClick:s(()=>p.current?.focus(),"onClick"),className:"h-(--sz-18rem) w-full overflow-hidden bg-neutral-950 outline-none sm:h-(--sz-22rem) [&_.xterm-cursor-bar]:!border-l-2 [&_.xterm-cursor-bar]:!border-l-cyan-300 [&_.xterm-cursor-layer_.xterm-cursor]:!bg-cyan-300 [&_.xterm-helper-textarea]:!opacity-0 [&_.xterm-screen]:focus:outline-none [&_.xterm-viewport]:!overflow-y-auto [&_.xterm]:h-full"})}),N?(0,t.jsx)("div",{className:"border-t border-line/60 px-3 py-2 text-xs text-bad",children:N}):null]})}s(ln,"EnvironmentCustomImageBrowserTerminal");function cn(n){return!n||n.status!=="supported"||!n.supportsInteractiveSetup?{kind:"unsupported",label:"Unsupported provider",reason:"This provider does not advertise interactive template setup."}:n.supportsTemplateCapture?{kind:"supported",label:"Template setup",reason:null}:{kind:"capture_unavailable",label:"Setup capture unavailable",reason:"This provider advertises setup, but image capture is unavailable."}}s(cn,"capabilityState");function Ue(n){switch(n){case"starting":return"Setup starting";case"waiting_for_user":return"Setup running";case"capturing":return"Capturing template";case"promoted":return"Template captured";case"cancelled":return"Setup cancelled";case"timed_out":return"Setup expired";case"failed":return"Setup failed";default:return"Setup status"}}s(Ue,"sessionStatusCopy");var Qe=class extends Error{static{s(this,"RelinkConfirmationDeclined")}constructor(){super("relink confirmation declined"),this.name="RelinkConfirmationDeclined"}};function Ve(n){return n==null?"(none)":typeof n=="string"?n:JSON.stringify(n)}s(Ve,"formatRelinkDriftValue");function dn(n){if(n.classification==="boot_source_drift"){const a=n.driftedPaths.find(u=>u.from!==void 0||u.to!==void 0);return a?`The base image changed: ${a.path} ${Ve(a.from)} -> ${Ve(a.to)}.`:"The base image changed since this image was captured."}return"The server cannot verify the boot source; the snapshot will override the current base image."}s(dn,"relinkDriftWarning");function un({environment:n,companyId:a,providerCapability:u,providerDisplayName:o}){const{pushToast:N}=Xe(),g=Ge(),T=cn(u),p=A.environments.customImageTemplate(n.id),m=U({queryKey:p,queryFn:s(()=>k.customImageTemplate(n.id,a),"queryFn"),enabled:T.kind==="supported",retry:!1}),l=m.data?.activeSession?.id??null,h=U({queryKey:l?A.environments.customImageSetupSession(l):["environment-custom-image-setup-sessions","none",n.id],queryFn:s(()=>k.customImageSetupSession(l),"queryFn"),enabled:!!(l&&je(m.data?.activeSession)),retry:!1});function D(i){g.setQueryData(A.environments.customImageSetupSession(i.session.id),i)}s(D,"setSessionResult");function S(){g.invalidateQueries({queryKey:p})}s(S,"invalidateOverview");const z=H({mutationFn:s((i={})=>k.startCustomImageSetupSession(n.id,a,{templateId:i.templateId??null}),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:x?.activeTemplate??null,activeSession:i.session,latestSession:i.session})),D(i),N({title:"Setup session started",body:"Connect details are available while the session is active.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to start setup",body:i instanceof Error?i.message:"Setup session could not be started.",tone:"error"})},"onError")}),_=H({mutationFn:s(i=>k.finishCustomImageSetupSession(i,{}),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,{activeTemplate:i.template,activeSession:null,latestSession:i.session}),D({session:i.session,connectionPayload:null}),S(),N({title:"Template captured",body:"Future runs can use the promoted template.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to capture template",body:i instanceof Error?i.message:"Template capture failed.",tone:"error"})},"onError")}),F=H({mutationFn:s(i=>k.cancelCustomImageSetupSession(i,{reason:"operator cancelled"}),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:x?.activeTemplate??null,activeSession:null,latestSession:i})),D({session:i,connectionPayload:null}),S(),N({title:"Setup cancelled",body:"The active template was not changed.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to cancel setup",body:i instanceof Error?i.message:"Setup session could not be cancelled.",tone:"error"})},"onError")}),R=H({mutationFn:s(()=>k.rollbackCustomImageTemplate(n.id,a),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:i.activeTemplate,activeSession:null,latestSession:x?.latestSession??null})),S(),N({title:"Template rolled back",body:"Future runs will use the previous template.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to roll back template",body:i instanceof Error?i.message:"Rollback failed.",tone:"error"})},"onError")}),Q=H({mutationFn:s(async()=>{try{return await k.relinkCustomImageTemplate(n.id,a)}catch(i){if(i instanceof pt&&i.status===409){const x=i.body?.details,Y=x?dn(x):i.message;if(!window.confirm(`${Y}
|
|
1
|
+
var ct=Object.defineProperty;var s=(n,a)=>ct(n,"name",{value:a,configurable:!0});import{i as Je}from"./rolldown-runtime-ZpX3ckPj.js";import{la as dt,ua as ut}from"./createLucideIcon-CgrPXnTY.js";import{n as mt,v as ft}from"./star-eem0qj3E.js";import{X as Ge,_ as H,n as pt,t as A,v as U}from"./queryKeys-BzT8CD34.js";import{n as ht}from"./CompanyContext-fQCNWI_f.js";import{o as xt,t as ae}from"./router-BKzUF9uf.js";import{a as gt,c as vt,i as bt,n as yt,o as St,r as wt,s as jt,t as kt}from"./alert-dialog-DNbnZgRz.js";import{t as Ct}from"./arrow-left-CnGEiANj.js";import{t as Nt}from"./check-Bis3vECb.js";import{t as Et}from"./environment-variables-editor-D6Ylcd74.js";import{t as Pt}from"./link-2-Cn4f4xsG.js";import{t as P}from"./button-DI4w5WP7.js";import{t as Tt}from"./play-Czm7OCYh.js";import{t as Rt}from"./plus-CwNlqadt.js";import{t as It}from"./refresh-cw-CfzWP9se.js";import{t as _t}from"./rotate-ccw-DpzLJhXT.js";import{t as $e}from"./terminal-i6UlT3R6.js";import{t as Ye}from"./trash-QxFF084e.js";import{t as Dt}from"./x-6E1yeU3Q.js";import{i as Xe}from"./ToastContext-DyVJ6bCh.js";import{t as Le}from"./agents-B8n-p0aX.js";import{t as be}from"./instanceSettings-D1nNVWU0.js";import{n as Kt}from"./BreadcrumbContext-DNbB7zWn.js";import{t as Me}from"./secrets-D17QEm13.js";import{i as At,n as ye,r as Ft,t as $t}from"./JsonSchemaForm-Dkh3zdL9.js";import{a as q,o as Oe}from"./agent-config-primitives-BJlDiwaH.js";import{t as k}from"./environments-xuhuvnTt.js";import{r as Se,t as Lt}from"./managed-sandbox-environment-B8DewKvK.js";import{zt as Mt}from"./index-b1wwaMjV.js";import{a as Ot,i as Ht,r as Bt}from"./terminal-font-B-qtwS34.js";var d=Je(ut(),1),t=Je(dt(),1),Z="/company/settings/instance/environments";function qt(n){return`${Z}/${encodeURIComponent(n)}/edit`}s(qt,"environmentEditPath");function zt(n){return n.staticReferences.isManagedLocal?"Cannot delete the managed local environment.":n.staticReferences.isInstanceDefault?"Cannot delete the current instance default environment. Set a new default environment before deleting this one.":n.pendingCleanupLeaseCount>0?"Cannot delete this environment while a sandbox cleanup is pending. Wait for the cleanup sweep to destroy the orphan sandbox, then retry.":n.reusableSandboxLeaseCount>0?"Cannot delete this environment while it has a reusable sandbox lease. Remove the associated execution workspace or issue so Wardmote can destroy the sandbox, then retry.":null}s(zt,"environmentDeleteBlockMessage");function Ce(n){return{name:n.name.trim(),description:n.description.trim()||null,driver:n.driver,envVars:n.envVars,config:n.driver==="ssh"?{host:n.sshHost.trim(),port:Number.parseInt(n.sshPort||"22",10)||22,username:n.sshUsername.trim(),remoteWorkspacePath:n.sshRemoteWorkspacePath.trim(),privateKey:n.sshPrivateKey.trim()||null,privateKeySecretRef:n.sshPrivateKey.trim().length>0||!n.sshPrivateKeySecretId?null:{type:"secret_ref",secretId:n.sshPrivateKeySecretId,version:"latest"},knownHosts:n.sshKnownHosts.trim()||null,strictHostKeyChecking:n.sshStrictHostKeyChecking}:n.driver==="sandbox"?{provider:n.sandboxProvider.trim(),...n.sandboxConfig}:{}}}s(Ce,"buildEnvironmentPayload");function G(){return{name:"",description:"",driver:"ssh",sshHost:"",sshPort:"22",sshUsername:"",sshRemoteWorkspacePath:"",sshPrivateKey:"",sshPrivateKeySecretId:"",sshKnownHosts:"",sshStrictHostKeyChecking:!0,sandboxProvider:"",sandboxConfig:{},envVars:{}}}s(G,"createEmptyEnvironmentForm");function Ze(n){return n?.driver==="local"}s(Ze,"isLocalEnvironment");function Wt(n,a){return n?Ze(a.find(u=>u.id===n)??null)?"":n:""}s(Wt,"normalizeNonLocalEnvironmentId");function Ut(n){const a=n.config??{};return{host:typeof a.host=="string"?a.host:"",port:typeof a.port=="number"?String(a.port):typeof a.port=="string"?a.port:"22",username:typeof a.username=="string"?a.username:"",remoteWorkspacePath:typeof a.remoteWorkspacePath=="string"?a.remoteWorkspacePath:"",privateKey:"",privateKeySecretId:a.privateKeySecretRef&&typeof a.privateKeySecretRef=="object"&&!Array.isArray(a.privateKeySecretRef)&&typeof a.privateKeySecretRef.secretId=="string"?String(a.privateKeySecretRef.secretId):"",knownHosts:typeof a.knownHosts=="string"?a.knownHosts:"",strictHostKeyChecking:typeof a.strictHostKeyChecking=="boolean"?a.strictHostKeyChecking:!0}}s(Ut,"readSshConfig");function Qt(n){const{provider:a,...u}=n.config??{};return{provider:typeof a=="string"&&a.trim().length>0?a:"fake",config:u}}s(Qt,"readSandboxConfig");function Vt(n){if(n.driver==="ssh"){const a=Ut(n);return{...G(),name:n.name,description:n.description??"",driver:"ssh",sshHost:a.host,sshPort:a.port,sshUsername:a.username,sshRemoteWorkspacePath:a.remoteWorkspacePath,sshPrivateKey:a.privateKey,sshPrivateKeySecretId:a.privateKeySecretId,sshKnownHosts:a.knownHosts,sshStrictHostKeyChecking:a.strictHostKeyChecking,envVars:n.envVars??{}}}if(n.driver==="sandbox"){const a=Qt(n);return{...G(),name:n.name,description:n.description??"",driver:"sandbox",sandboxProvider:a.provider,sandboxConfig:a.config,envVars:n.envVars??{}}}return{...G(),name:n.name,description:n.description??"",driver:"local",envVars:n.envVars??{}}}s(Vt,"createEnvironmentFormFromEnvironment");var He="Discard unsaved environment changes?";function Ne(n){return Array.isArray(n)?`[${n.map(a=>Ne(a)).join(",")}]`:n&&typeof n=="object"?`{${Object.entries(n).filter(([,a])=>a!==void 0).sort(([a],[u])=>a.localeCompare(u)).map(([a,u])=>`${JSON.stringify(a)}:${Ne(u)}`).join(",")}}`:JSON.stringify(n)??"undefined"}s(Ne,"stableJsonStringify");function we(n){return Ne(Ce(n))}s(we,"environmentFormKey");function Jt(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}s(Jt,"normalizeJsonSchema");function Gt(n){for(const a of["template","image","region","workspacePath"]){const u=n[a];if(typeof u=="string"&&u.trim().length>0)return u}return null}s(Gt,"summarizeSandboxConfig");var Yt=new Set(["starting","waiting_for_user","capturing"]);function je(n){return!!(n&&Yt.has(n.status))}s(je,"isActiveCustomImageSetupSession");function Be(n){return n.driver==="sandbox"&&typeof n.config.provider=="string"?n.config.provider:null}s(Be,"readEnvironmentSandboxProvider");function ke(n){if(!n)return null;const a=n instanceof Date?n:new Date(n);return Number.isNaN(a.getTime())?null:a.toLocaleString()}s(ke,"formatDateTime");function Xt(n){const a=n.trim();return a.length<=12?a:`${a.slice(0,12)}…`}s(Xt,"formatShortId");function qe(n){return typeof n=="string"?n:n==null?"none":JSON.stringify(n)}s(qe,"formatBootSourceDriftValue");function Zt(n){if(!n||n.classification!=="boot_source_drift")return null;const a=n.driftedPaths.filter(u=>"from"in u||"to"in u).map(u=>`${u.path} \`${qe(u.from)}\` -> \`${qe(u.to)}\``);return a.length===0?null:`Base image changed: ${a.join("; ")}`}s(Zt,"formatBootSourceDriftSummary");function et(n){return typeof n?.command=="string"&&n.command.trim().length>0?n.command:null}s(et,"readConnectionCommand");function en(n){return n.refreshError?"Setup connection details could not be refreshed. You can still finish or cancel this setup.":n.isLoading?null:n.payload?n.payload.type!=="ssh"?"Browser terminal is not available for this provider connection. Use the provider setup instructions, then finish or cancel here.":et(n.payload)?null:"Connection details are not available yet. You can still finish or cancel this setup.":"Connection details are not available yet. You can still finish or cancel this setup."}s(en,"setupConnectionFallbackMessage");var ze=100,We=28,tn=5e3,nn=Bt();function sn(n,a){return`${n}${n.includes("?")?"&":"?"}${new URLSearchParams(Object.fromEntries(Object.entries(a).map(([u,o])=>[u,String(o)]))).toString()}`}s(sn,"appendTerminalQuery");function rn(n){try{const a=JSON.parse(n);return a&&typeof a=="object"&&!Array.isArray(a)?a:null}catch{return null}}s(rn,"parseTerminalFrame");function an(n){switch(n){case"connecting":return"Connecting";case"connected":return"Connected";case"closed":return"Closed";case"error":return"Connection failed";default:return"Ready to connect"}}s(an,"customImageTerminalStatusCopy");function on(n){if(n!=="expired"&&n!=="ssh_closed"&&n!=="server_shutdown"&&n!=="setup_finished"&&n!=="setup_cancelled")return typeof n=="string"&&n.trim()?"Terminal closed.":null;switch(n){case"expired":return"Setup session expired.";case"ssh_closed":return"SSH session closed.";case"server_shutdown":return"Terminal server shut down.";case"setup_finished":return"Setup session finished.";case"setup_cancelled":return"Setup session cancelled.";default:return null}}s(on,"customImageTerminalCloseReasonCopy");function ln({autoConnect:n=!1,sessionId:a}){const[u,o]=(0,d.useState)("idle"),[N,g]=(0,d.useState)(null),T=(0,d.useRef)(null),p=(0,d.useRef)(null),m=(0,d.useRef)(null),l=(0,d.useRef)(null),h=(0,d.useRef)(null),D=(0,d.useRef)(null),S=(0,d.useRef)(null),z=(0,d.useRef)(null),_=(0,d.useRef)(null),F=(0,d.useCallback)((f="operator_closed")=>{const y=S.current;S.current=null,y&&y.readyState!==WebSocket.CLOSED&&y.readyState!==WebSocket.CLOSING&&y.close(1e3,f)},[]),R=(0,d.useCallback)(()=>{const f=p.current;return{cols:f?.cols||ze,rows:f?.rows||We}},[]),Q=(0,d.useCallback)((f=!1)=>{const y=S.current;if(!y||y.readyState!==WebSocket.OPEN)return;const I=R(),w=_.current;!f&&w?.cols===I.cols&&w.rows===I.rows||(_.current=I,y.send(JSON.stringify({type:"resize",cols:I.cols,rows:I.rows})))},[R]),K=(0,d.useCallback)(()=>{const f=m.current;if(!(!f||!p.current))try{f.fit(),Q()}catch{}},[Q]),$=(0,d.useCallback)(()=>{D.current!==null&&window.cancelAnimationFrame(D.current),D.current=window.requestAnimationFrame(()=>{D.current=null,K()})},[K]),E=(0,d.useCallback)(f=>{const y=S.current;!y||y.readyState!==WebSocket.OPEN||y.send(JSON.stringify({type:"input",data:f}))},[]),b=(0,d.useCallback)(()=>{const f=p.current;f&&(f.reset(),f.clear())},[]);(0,d.useEffect)(()=>{const f=T.current;if(!f||p.current)return;const y=new Ot({allowTransparency:!0,cols:ze,rows:We,convertEol:!1,cursorBlink:!0,cursorInactiveStyle:"bar",cursorStyle:"bar",cursorWidth:2,fontFamily:nn,fontSize:12,letterSpacing:0,lineHeight:1.35,scrollback:tn,theme:{background:"#0a0a0a",foreground:"#f5f5f5",cursor:"#22d3ee",cursorAccent:"#020617",selectionBackground:"#2563eb55"}}),I=new Ht;if(y.loadAddon(I),y.open(f),p.current=y,m.current=I,l.current=y.onData(E),typeof ResizeObserver<"u"){const i=new ResizeObserver(()=>$());i.observe(f),h.current=i}y.focus(),$();const w=[50,250].map(i=>window.setTimeout(K,i)),C="fonts"in document?document.fonts?.ready:null;return C&&C.then(()=>K()),()=>{D.current!==null&&(window.cancelAnimationFrame(D.current),D.current=null);for(const i of w)window.clearTimeout(i);h.current?.disconnect(),h.current=null,l.current?.dispose(),l.current=null,m.current=null,p.current=null,y.dispose()}},[K,$,E]),(0,d.useEffect)(()=>()=>F("component_unmounted"),[F]),(0,d.useEffect)(()=>{F("session_changed"),z.current=null,_.current=null,o("idle"),g(null),b()},[F,b,a]),(0,d.useEffect)(()=>{u==="connected"&&p.current?.focus()},[u]);const M=(0,d.useCallback)(async()=>{if(typeof WebSocket>"u"){o("error"),g("Browser terminal is unavailable in this browser.");return}F("reconnect"),o("connecting"),_.current=null,g(null),b(),p.current?.focus();try{K();const f=R(),y=await k.createCustomImageTerminalSessionToken(a,{}),I=sn(y.websocketPath,{cols:f.cols,rows:f.rows}),w=new WebSocket(Mt(I));S.current=w,w.onopen=()=>{S.current===w&&(p.current?.focus(),w.send(JSON.stringify({type:"auth",token:y.token})),Q(!0))},w.onmessage=C=>{if(S.current!==w)return;const i=typeof C.data=="string"?C.data:"",x=i?rn(i):null;if(x){if(x.type==="ready"){o("connected"),p.current?.focus();return}if(x.type==="output"&&typeof x.data=="string"){p.current?.write(x.data);return}if(x.type==="error"){o("error"),g(typeof x.message=="string"?x.message:"Terminal connection failed.");return}x.type==="closed"&&(o("closed"),g(on(x.reason)))}},w.onclose=()=>{S.current===w&&(S.current=null,o(C=>C==="connected"||C==="connecting"?"closed":C))},w.onerror=()=>{S.current===w&&(o("error"),g("Terminal websocket connection failed."))}}catch(f){o("error"),g(f instanceof Error?f.message:"Terminal session could not be opened.")}},[F,K,R,b,Q,a]);(0,d.useEffect)(()=>{if(!n||u!=="idle"||z.current===a)return;const f=window.setTimeout(()=>{z.current=a,M()},0);return()=>window.clearTimeout(f)},[n,M,u,a]);const V=(0,d.useCallback)(()=>{F("operator_closed"),o("closed")},[F]),ee=u==="connected";return(0,t.jsxs)("div",{className:"mt-3 rounded-md border border-line/70 bg-bg","data-testid":`custom-image-terminal-${a}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-line/60 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-xs",children:[(0,t.jsx)($e,{className:"h-3.5 w-3.5 text-ink-3"}),(0,t.jsx)("span",{className:"font-medium",children:"Browser terminal"}),(0,t.jsx)("span",{className:"text-ink-3",children:an(u)})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:ee?(0,t.jsx)(P,{size:"sm",variant:"ghost",onClick:V,children:"Disconnect"}):(0,t.jsxs)(P,{size:"sm",variant:"secondary",onClick:s(()=>{M()},"onClick"),disabled:u==="connecting",children:[(0,t.jsx)($e,{className:"mr-1.5 h-3.5 w-3.5"}),u==="closed"||u==="error"?"Reconnect":"Open terminal"]})})]}),(0,t.jsx)("div",{className:"bg-neutral-950 p-2 focus-within:ring-2 focus-within:ring-focus",children:(0,t.jsx)("div",{ref:T,"data-testid":`custom-image-terminal-screen-${a}`,"aria-label":"Custom image browser terminal",role:"application",tabIndex:0,onFocus:s(()=>p.current?.focus(),"onFocus"),onClick:s(()=>p.current?.focus(),"onClick"),className:"h-(--sz-18rem) w-full overflow-hidden bg-neutral-950 outline-none sm:h-(--sz-22rem) [&_.xterm-cursor-bar]:!border-l-2 [&_.xterm-cursor-bar]:!border-l-cyan-300 [&_.xterm-cursor-layer_.xterm-cursor]:!bg-cyan-300 [&_.xterm-helper-textarea]:!opacity-0 [&_.xterm-screen]:focus:outline-none [&_.xterm-viewport]:!overflow-y-auto [&_.xterm]:h-full"})}),N?(0,t.jsx)("div",{className:"border-t border-line/60 px-3 py-2 text-xs text-bad",children:N}):null]})}s(ln,"EnvironmentCustomImageBrowserTerminal");function cn(n){return!n||n.status!=="supported"||!n.supportsInteractiveSetup?{kind:"unsupported",label:"Unsupported provider",reason:"This provider does not advertise interactive template setup."}:n.supportsTemplateCapture?{kind:"supported",label:"Template setup",reason:null}:{kind:"capture_unavailable",label:"Setup capture unavailable",reason:"This provider advertises setup, but image capture is unavailable."}}s(cn,"capabilityState");function Ue(n){switch(n){case"starting":return"Setup starting";case"waiting_for_user":return"Setup running";case"capturing":return"Capturing template";case"promoted":return"Template captured";case"cancelled":return"Setup cancelled";case"timed_out":return"Setup expired";case"failed":return"Setup failed";default:return"Setup status"}}s(Ue,"sessionStatusCopy");var Qe=class extends Error{static{s(this,"RelinkConfirmationDeclined")}constructor(){super("relink confirmation declined"),this.name="RelinkConfirmationDeclined"}};function Ve(n){return n==null?"(none)":typeof n=="string"?n:JSON.stringify(n)}s(Ve,"formatRelinkDriftValue");function dn(n){if(n.classification==="boot_source_drift"){const a=n.driftedPaths.find(u=>u.from!==void 0||u.to!==void 0);return a?`The base image changed: ${a.path} ${Ve(a.from)} -> ${Ve(a.to)}.`:"The base image changed since this image was captured."}return"The server cannot verify the boot source; the snapshot will override the current base image."}s(dn,"relinkDriftWarning");function un({environment:n,companyId:a,providerCapability:u,providerDisplayName:o}){const{pushToast:N}=Xe(),g=Ge(),T=cn(u),p=A.environments.customImageTemplate(n.id),m=U({queryKey:p,queryFn:s(()=>k.customImageTemplate(n.id,a),"queryFn"),enabled:T.kind==="supported",retry:!1}),l=m.data?.activeSession?.id??null,h=U({queryKey:l?A.environments.customImageSetupSession(l):["environment-custom-image-setup-sessions","none",n.id],queryFn:s(()=>k.customImageSetupSession(l),"queryFn"),enabled:!!(l&&je(m.data?.activeSession)),retry:!1});function D(i){g.setQueryData(A.environments.customImageSetupSession(i.session.id),i)}s(D,"setSessionResult");function S(){g.invalidateQueries({queryKey:p})}s(S,"invalidateOverview");const z=H({mutationFn:s((i={})=>k.startCustomImageSetupSession(n.id,a,{templateId:i.templateId??null}),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:x?.activeTemplate??null,activeSession:i.session,latestSession:i.session})),D(i),N({title:"Setup session started",body:"Connect details are available while the session is active.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to start setup",body:i instanceof Error?i.message:"Setup session could not be started.",tone:"error"})},"onError")}),_=H({mutationFn:s(i=>k.finishCustomImageSetupSession(i,{}),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,{activeTemplate:i.template,activeSession:null,latestSession:i.session}),D({session:i.session,connectionPayload:null}),S(),N({title:"Template captured",body:"Future runs can use the promoted template.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to capture template",body:i instanceof Error?i.message:"Template capture failed.",tone:"error"})},"onError")}),F=H({mutationFn:s(i=>k.cancelCustomImageSetupSession(i,{reason:"operator cancelled"}),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:x?.activeTemplate??null,activeSession:null,latestSession:i})),D({session:i,connectionPayload:null}),S(),N({title:"Setup cancelled",body:"The active template was not changed.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to cancel setup",body:i instanceof Error?i.message:"Setup session could not be cancelled.",tone:"error"})},"onError")}),R=H({mutationFn:s(()=>k.rollbackCustomImageTemplate(n.id,a),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:i.activeTemplate,activeSession:null,latestSession:x?.latestSession??null})),S(),N({title:"Template rolled back",body:"Future runs will use the previous template.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to roll back template",body:i instanceof Error?i.message:"Rollback failed.",tone:"error"})},"onError")}),Q=H({mutationFn:s(async()=>{try{return await k.relinkCustomImageTemplate(n.id,a)}catch(i){if(i instanceof pt&&i.status===409){const x=i.body?.details,Y=x?dn(x):i.message;if(!window.confirm(`${Y}
|
|
2
2
|
|
|
3
3
|
Relink this image anyway?`))throw new Qe;return await k.relinkCustomImageTemplate(n.id,a,{confirmBootSourceDrift:!0})}throw i}},"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:i.template,activeTemplateMatchesConfig:!0,activeSession:x?.activeSession??null,latestSession:x?.latestSession??null})),S(),N({title:"Template relinked",body:"Runs use the captured image again.",tone:"success"})},"onSuccess"),onError:s(i=>{i instanceof Qe||N({title:"Failed to relink template",body:i instanceof Error?i.message:"Relink failed.",tone:"error"})},"onError")}),K=H({mutationFn:s(()=>k.disableCustomImageTemplate(n.id,a),"mutationFn"),onSuccess:s(i=>{g.setQueryData(p,x=>({activeTemplate:null,activeSession:null,latestSession:x?.latestSession??null})),S(),N({title:"Template disabled",body:"Future runs will use the base provider configuration.",tone:"success"})},"onSuccess"),onError:s(i=>{N({title:"Failed to disable template",body:i instanceof Error?i.message:"Disable failed.",tone:"error"})},"onError")});if(T.kind!=="supported")return(0,t.jsxs)("div",{className:"mt-3 border-t border-line/60 pt-3 text-xs","data-testid":`custom-image-template-state-${n.id}`,children:[(0,t.jsx)("div",{className:"font-medium text-ink",children:T.label}),(0,t.jsx)("div",{className:"mt-1 text-ink-3",children:T.reason})]});if(m.isLoading)return(0,t.jsx)("div",{className:"mt-3 border-t border-line/60 pt-3 text-xs text-ink-3",children:"Loading template setup..."});if(m.isError)return(0,t.jsx)("div",{className:"mt-3 border-t border-line/60 pt-3 text-xs text-bad",children:m.error instanceof Error?m.error.message:"Template setup could not be loaded."});const $=m.data,E=$?.activeTemplate??null,b=h.data?.session??null??$?.activeSession??null,M=je(b)?$?.latestSession??null:b??$?.latestSession??null,V=b?.status==="waiting_for_user"?h.data?.connectionPayload??null:null,ee=et(V),f=b?.status==="waiting_for_user"?en({payload:V,refreshError:h.isError?h.error:null,isLoading:h.isLoading}):null,y=ke(V?.expiresAt??b?.expiresAt??null),I=ke(E?.capturedAt??E?.createdAt??null),w=ke(E?.lastUsedAt??null),C=z.isPending||_.isPending||F.isPending||Q.isPending||R.isPending||K.isPending;if(b&&je(b)){const i=b.status==="capturing";return(0,t.jsxs)("div",{className:"mt-3 border-t border-line/60 pt-3","data-testid":`custom-image-template-state-${n.id}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,t.jsx)("div",{className:"text-xs font-medium",children:Ue(b.status)}),(0,t.jsxs)("div",{className:"text-xs text-ink-3",children:[o,y?` · expires ${y}`:""]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(P,{size:"sm",variant:"secondary",onClick:s(()=>_.mutate(b.id),"onClick"),disabled:C||b.status!=="waiting_for_user",children:[(0,t.jsx)(Nt,{className:"mr-1.5 h-3.5 w-3.5"}),"Finished"]}),(0,t.jsxs)(P,{size:"sm",variant:"ghost",onClick:s(()=>F.mutate(b.id),"onClick"),disabled:C,children:[(0,t.jsx)(Dt,{className:"mr-1.5 h-3.5 w-3.5"}),"Cancel"]})]})]}),i?(0,t.jsx)("div",{className:"mt-2 text-xs text-ink-3",children:"Capture is in progress. If this state remains after a refresh or interrupted request, cancel it to return to the active template controls."}):null,b.status==="waiting_for_user"&&V?.type==="ssh"?(0,t.jsx)(ln,{autoConnect:!0,sessionId:b.id}):null,b.status==="waiting_for_user"&&ee?(0,t.jsxs)("details",{className:"mt-2 rounded-md border border-line/60 bg-bg-3/20 px-3 py-2 text-xs text-ink-3",children:[(0,t.jsx)("summary",{className:"cursor-pointer select-none font-medium text-ink",children:"SSH command fallback"}),(0,t.jsx)("code",{className:"mt-2 block overflow-x-auto whitespace-nowrap text-(length:--text-micro) leading-5",children:ee})]}):null,b.status==="waiting_for_user"&&f?(0,t.jsx)("div",{className:"mt-2 text-xs text-ink-3",children:f}):null,b.failureReason?(0,t.jsx)("div",{className:"mt-2 text-xs text-bad",children:b.failureReason}):null]})}if(E){const i=E.templateRef?.trim()||null,x=$?.activeTemplateMatchesConfig===!1,Y=Zt($?.activeTemplateDrift);return(0,t.jsx)("div",{className:"mt-3 border-t border-line/60 pt-3","data-testid":`custom-image-template-state-${n.id}`,children:(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,t.jsx)("div",{className:"text-xs font-medium",children:"Active template"}),(0,t.jsxs)("div",{className:"text-xs text-ink-3",children:[o," · ",E.templateKind," · ",(0,t.jsx)("span",{className:"break-all font-mono text-ink",title:i?`Provider ${E.templateKind} ref ${i} (Wardmote template ${E.id})`:E.id,children:i??`id ${Xt(E.id)}`}),I?` · captured ${I}`:"",w?` · last used ${w}`:""]}),x?(0,t.jsx)("div",{className:"text-xs text-bad","data-testid":`custom-image-template-out-of-sync-${n.id}`,children:Y?`Not in use — ${Y}. Runs fall back to the base configuration until you relink this image or capture a new one.`:"Not in use — the environment configuration changed since this image was captured. Runs fall back to the base configuration until you relink this image or capture a new one."}):null]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(P,{size:"sm",variant:"secondary",onClick:s(()=>z.mutate({templateId:E.id}),"onClick"),disabled:C,children:[(0,t.jsx)(It,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]}),(0,t.jsxs)(P,{size:"sm",variant:"secondary",onClick:s(()=>Q.mutate(),"onClick"),disabled:C,"data-testid":`custom-image-template-relink-${n.id}`,children:[(0,t.jsx)(Pt,{className:"mr-1.5 h-3.5 w-3.5"}),"Relink"]}),(0,t.jsxs)(P,{size:"sm",variant:"ghost",onClick:s(()=>R.mutate(),"onClick"),disabled:C,children:[(0,t.jsx)(_t,{className:"mr-1.5 h-3.5 w-3.5"}),"Rollback"]}),(0,t.jsxs)(P,{size:"sm",variant:"ghost",onClick:s(()=>K.mutate(),"onClick"),disabled:C,children:[(0,t.jsx)(Ye,{className:"mr-1.5 h-3.5 w-3.5"}),"Disable"]})]})]})})}return(0,t.jsx)("div",{className:"mt-3 border-t border-line/60 pt-3","data-testid":`custom-image-template-state-${n.id}`,children:(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-xs font-medium",children:"Not configured"}),(0,t.jsx)("div",{className:"text-xs text-ink-3",children:M?Ue(M.status):`Capture a custom ${o} image with your tools already logged in.`}),M?.failureReason?(0,t.jsx)("div",{className:"text-xs text-bad",children:M.failureReason}):null]}),(0,t.jsxs)(P,{size:"sm",variant:"secondary",onClick:s(()=>z.mutate({templateId:null}),"onClick"),disabled:C,children:[(0,t.jsx)(Tt,{className:"mr-1.5 h-3.5 w-3.5"}),"Configure image"]})]})})}s(un,"EnvironmentImageTemplatePanel");function qn({mode:n="list"}){const{environmentId:a}=ft(),u=xt(),{selectedCompanyId:o}=ht(),{setBreadcrumbs:N}=Kt(),{pushToast:g}=Xe(),T=Ge(),p=n==="create"||n==="edit",m=n==="edit"?a??null:null,[l,h]=(0,d.useState)(G),D=(0,d.useRef)(null),S=(0,d.useRef)(null),[z,_]=(0,d.useState)(null),[F,R]=(0,d.useState)(!1),[Q,K]=(0,d.useState)({}),[$,E]=(0,d.useState)(null),[b,M]=(0,d.useState)(!1),[V,ee]=(0,d.useState)(""),f=p&&(F||z!==null&&we(l)!==z);(0,d.useEffect)(()=>{const e=[{label:"Settings",href:"/company/settings"},p?{label:"Environments",href:Z}:{label:"Environments"}];n==="create"&&e.push({label:"Add environment"}),n==="edit"&&e.push({label:"Edit environment"}),N(e)},[p,n,N]);const{data:y}=U({queryKey:A.instance.settings,queryFn:s(()=>be.get(),"queryFn"),retry:!1}),{data:I}=U({queryKey:A.instance.experimentalSettings,queryFn:s(()=>be.getExperimental(),"queryFn"),retry:!1}),w=I?.enableEnvironments===!0,C=I?.enableManagedSandboxOnly===!0,{data:i}=U({queryKey:o?A.environments.list(o):["environments","none"],queryFn:s(()=>k.list(o),"queryFn"),enabled:!!o&&w}),x=i??[],Y=U({queryKey:m?["environment-delete-blast-radius",m]:["environment-delete-blast-radius","none"],queryFn:s(()=>k.deleteBlastRadius(m),"queryFn"),enabled:b&&!!m,retry:!1}),de=U({queryKey:o?A.agents.list(o):["agents","none"],queryFn:s(()=>Le.list(o),"queryFn"),enabled:b&&!!o}),ne=U({queryKey:m?["environment-secret-refs",m]:["environment-secret-refs","none"],queryFn:s(()=>k.secretRefs(m),"queryFn"),enabled:!!m&&w,retry:!1}),tt=(0,d.useMemo)(()=>{if(!m)return{status:"ready",hints:{}};if(ne.isError)return{status:"error",hints:{}};if(!ne.data)return{status:"loading",hints:{}};const e={};for(const r of ne.data.refs)e[r.secretId]={name:r.name,status:r.status,companyId:r.companyId,companyName:r.companyName};return{status:"ready",hints:e}},[m,ne.data,ne.isError]),{data:ue}=U({queryKey:o?["environment-capabilities",o]:["environment-capabilities","none"],queryFn:s(()=>k.capabilities(o),"queryFn"),enabled:!!o&&w}),{data:Ee}=U({queryKey:o?["company-secrets",o]:["company-secrets","none"],queryFn:s(()=>Me.list(o),"queryFn"),enabled:!!o}),nt=H({mutationFn:s(e=>{if(!o)throw new Error("Select an organization to create secrets");return Me.create(o,e)},"mutationFn"),onSuccess:s(async()=>{o&&await T.invalidateQueries({queryKey:A.secrets.list(o)})},"onSuccess")}),B=H({mutationFn:s(async e=>{const r=Ce(e);if(m)return await k.update(m,r,o);if(!o)throw new Error("Select a company to create environments");return await k.create(o,r)},"mutationFn"),onSuccess:s(async e=>{const r=m!==null;o&&await T.invalidateQueries({queryKey:A.environments.list(o)}),await T.invalidateQueries({queryKey:A.environments.customImageTemplate(e.id)}),S.current=null,h(G()),_(null),R(!1),B.reset(),J.reset(),u(Z,{replace:!0}),g({title:r?"Environment updated":"Environment created",body:`${e.name} is ready.`,tone:"success"});const c=e.customImageReconciliation;c?.action==="relinked"?g({title:"Custom image kept active",body:"The captured image was re-linked to the updated configuration automatically.",tone:"info"}):c?.action==="detached"&&g({title:"Custom image no longer applies",body:"This change alters what the captured image was built from. Runs use the base configuration until you capture a new image.",tone:"warn"})},"onSuccess"),onError:s(e=>{g({title:"Failed to save environment",body:e instanceof Error?e.message:"Environment save failed.",tone:"error"})},"onError")}),Pe=H({mutationFn:s(async e=>await be.update({defaultEnvironmentId:e}),"mutationFn"),onSuccess:s(async()=>{await T.invalidateQueries({queryKey:A.instance.settings}),g({title:"Default environment updated",body:"Agent inheritance now follows the updated instance default.",tone:"success"})},"onSuccess"),onError:s(e=>{g({title:"Failed to update default environment",body:e instanceof Error?e.message:"Default environment update failed.",tone:"error"})},"onError")}),se=H({mutationFn:s(async e=>{for(const r of e.reassignAgentIds)await Le.update(r,{defaultEnvironmentId:e.reassignTargetId},o??void 0);return e.destroyReusableLeases?await k.remove(e.environment.id,{destroyReusableSandboxLeases:!0}):await k.remove(e.environment.id)},"mutationFn"),onSuccess:s(async(e,r)=>{o&&(await T.invalidateQueries({queryKey:A.environments.list(o)}),r.reassignAgentIds.length>0&&await T.invalidateQueries({queryKey:A.agents.list(o)})),T.removeQueries({queryKey:["environment-delete-blast-radius",e.id]}),M(!1),S.current=null,h(G()),_(null),R(!1),u(Z,{replace:!0});const c=e.destroyedReusableSandboxLeaseCount??0;g({title:"Environment deleted",body:c>0?`${e.name} was deleted. Destroyed ${c===1?"1 reusable sandbox":`${c} reusable sandboxes`}.`:`${e.name} was deleted.`,tone:"success"})},"onSuccess"),onError:s(async(e,r)=>{o&&r.reassignAgentIds.length>0&&await T.invalidateQueries({queryKey:A.agents.list(o)}),await T.invalidateQueries({queryKey:["environment-delete-blast-radius",r.environment.id]}),g({title:"Failed to delete environment",body:e instanceof Error?e.message:"Environment delete failed.",tone:"error"})},"onError")}),st=H({mutationFn:s(async e=>await k.probe(e,o),"mutationFn"),onMutate:s(e=>{E(e)},"onMutate"),onSettled:s((e,r,c)=>{E(v=>v===c?null:v)},"onSettled"),onSuccess:s((e,r)=>{K(c=>({...c,[r]:e})),g({title:e.ok?"Environment probe passed":"Environment probe failed",body:e.summary,tone:e.ok?"success":"error"})},"onSuccess"),onError:s((e,r)=>{const c=(i??[]).find(v=>v.id===r);K(v=>({...v,[r]:{ok:!1,driver:c?.driver??"local",summary:e instanceof Error?e.message:"Environment probe failed.",details:null}})),g({title:"Environment probe failed",body:e instanceof Error?e.message:"Environment probe failed.",tone:"error"})},"onError")}),J=H({mutationFn:s(async e=>{if(!o)throw new Error("Select a company to test environments");const r=Ce(e);return await k.probeConfig(o,r)},"mutationFn"),onSuccess:s(e=>{g({title:e.ok?"Draft probe passed":"Draft probe failed",body:e.summary,tone:e.ok?"success":"error"})},"onSuccess"),onError:s(e=>{g({title:"Draft probe failed",body:e instanceof Error?e.message:"Environment probe failed.",tone:"error"})},"onError")});(0,d.useEffect)(()=>{S.current=null,h(G()),_(null),R(!1),K({}),E(null)},[o]);const Te=B.reset,Re=J.reset;(0,d.useEffect)(()=>{if(!p){S.current=null,_(null),R(!1);return}const e=n==="create"?`create:${o??"none"}`:`edit:${o??"none"}:${m??"missing"}`;if(S.current===e)return;if(Te(),Re(),n==="create"){const v=G();h(v),_(we(v)),R(!1),S.current=e;return}const r=m?(i??[]).find(v=>v.id===m)??null:null;if(!r)return;const c=Vt(r);h(c),_(we(c)),R(!1),S.current=e},[m,i,p,n,Re,Te,o]);function rt(){return!f||typeof window>"u"||window.confirm(He)}s(rt,"confirmDiscardEnvironmentChanges"),(0,d.useEffect)(()=>{if(!f)return;function e(c){c.preventDefault(),c.returnValue=""}s(e,"handleBeforeUnload");function r(c){if(c.defaultPrevented||c.button!==0||c.altKey||c.ctrlKey||c.metaKey||c.shiftKey)return;const v=c.target;if(!(v instanceof Element))return;const L=v.closest("a[href]");if(!(L instanceof HTMLAnchorElement)||L.target&&L.target!=="_self")return;const le=new URL(L.href,window.location.href),ce=new URL(window.location.href);le.origin===ce.origin&&(le.pathname===ce.pathname&&le.search===ce.search&&le.hash===ce.hash||window.confirm(He)||(c.preventDefault(),c.stopPropagation()))}return s(r,"handleDocumentClick"),window.addEventListener("beforeunload",e),document.addEventListener("click",r,!0),()=>{window.removeEventListener("beforeunload",e),document.removeEventListener("click",r,!0)}},[f]);function at(){B.isPending||rt()&&(S.current=null,h(G()),_(null),R(!1),B.reset(),J.reset(),u(Z))}s(at,"closeEnvironmentForm");function Ie(){const e=D.current?.flushPendingDraft();return e?{...l,envVars:e}:l}s(Ie,"flushEnvironmentForm");const W=Object.entries(ue?.sandboxProviders??{}).filter(([e,r])=>e!=="fake"&&r.supportsRunExecution).map(([e,r])=>({provider:e,displayName:r.displayName||e,description:r.description,configSchema:Jt(r.configSchema)})).sort((e,r)=>e.displayName.localeCompare(r.displayName)),it=W.length>0,me=l.sandboxProvider.trim().length>0&&l.sandboxProvider!=="fake"&&!W.some(e=>e.provider===l.sandboxProvider)?[...W,{provider:l.sandboxProvider,displayName:l.sandboxProvider,description:void 0,configSchema:null}]:W,fe=me.find(e=>e.provider===l.sandboxProvider)??null,ie=fe?.configSchema??null,_e=l.driver==="sandbox"&&ie?Ft(ie,l.sandboxConfig):{};(0,d.useEffect)(()=>{if(l.driver!=="sandbox"||l.sandboxProvider.trim().length>0&&l.sandboxProvider!=="fake")return;const e=W[0]?.provider;if(!e)return;const r=W[0]?.configSchema;h(c=>c.driver!=="sandbox"||c.sandboxProvider.trim().length>0&&c.sandboxProvider!=="fake"?c:{...c,sandboxProvider:e,sandboxConfig:r?ye(r):{}})},[W,l.driver,l.sandboxProvider]);const De=l.name.trim().length>0&&(l.driver!=="ssh"||l.sshHost.trim().length>0&&l.sshUsername.trim().length>0&&l.sshRemoteWorkspacePath.trim().length>0)&&(l.driver!=="sandbox"||l.sandboxProvider.trim().length>0&&l.sandboxProvider!=="fake"&&Object.keys(_e).length===0),O=m?x.find(e=>e.id===m)??null:null,pe=O?Be(O):null,Ke=pe?ue?.sandboxProviders?.[pe]:null,ot=Ke?.displayName??pe??"sandbox",Ae=x.filter(e=>!Ze(e)),he=Wt(y?.defaultEnvironmentId??null,x),xe=x.find(e=>e.id===he)??null,j=Y.data??null,re=j!==null&&j.deleteBlockedReasons.length>0&&j.deleteBlockedReasons.every(e=>e==="reusable_sandbox_lease"),oe=j&&!re?zt(j):null,ge=Y.isPending||de.isPending,ve=Y.isError||de.isError,X=m?(de.data??[]).filter(e=>e.status!=="terminated"&&e.defaultEnvironmentId===m):[],lt=Ae.filter(e=>e.id!==m),te=[];if(j&&!oe){j.staticReferences.agentDefaultCount>X.length&&te.push("Other references to this environment (agents in other organizations or terminated agents) fall back to the instance default.");const e=j.staticReferences.executionWorkspaceSelectionCount+j.staticReferences.issueSelectionCount+j.staticReferences.projectSelectionCount;e>0&&te.push(`${e} workspace, issue, or project environment ${e===1?"selection":"selections"} will be cleared.`),j.staticReferences.secretBindingCount>0&&te.push(`${j.staticReferences.secretBindingCount} secret ${j.staticReferences.secretBindingCount===1?"binding":"bindings"} will be removed.`),j.activeRuntimeUse.hasActiveRuntimeUse&&te.push("Active runs or sandbox leases currently resolve to this environment.")}const Fe=(()=>{const e=new Map;for(const r of j?.reusableSandboxLeaseHolders??[]){const c=r.executionWorkspaceId??`lease:${r.leaseId}`,v=r.issueIdentifier??r.issueTitle,L=e.get(c);L?(L.leaseCount+=1,v&&!L.issueLabels.includes(v)&&L.issueLabels.push(v)):e.set(c,{workspaceId:r.executionWorkspaceId,label:r.executionWorkspaceName??r.issueIdentifier??r.issueTitle??"Workspace no longer on record",issueLabels:v?[v]:[],leaseCount:1})}return Array.from(e.values())})();return o?w?(0,t.jsxs)("div",{className:"max-w-6xl space-y-6","data-testid":"instance-settings-environments-section",children:[p?null:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsxs)("label",{className:"flex flex-wrap items-center gap-3 text-sm font-medium",children:[(0,t.jsx)("span",{children:"Default"}),(0,t.jsx)("span",{children:(0,t.jsxs)("select",{"aria-label":"Default environment",className:"min-w-(--sz-12rem) max-w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm font-normal outline-none",value:he,onChange:s(e=>Pe.mutate(e.target.value||null),"onChange"),disabled:Pe.isPending,children:[C?he===""?(0,t.jsx)("option",{value:"",disabled:!0,children:"Select environment"}):null:(0,t.jsx)("option",{value:"",children:"Local"}),Ae.map(e=>(0,t.jsx)("option",{value:e.id,children:Lt(e)},e.id))]})})]}),(0,t.jsx)(P,{size:"icon-sm",variant:"ghost",asChild:!0,children:(0,t.jsx)(ae,{to:`${Z}/new`,"aria-label":"Add environment",title:"Add environment",children:(0,t.jsx)(Rt,{className:"h-4 w-4"})})})]}),(0,t.jsx)("div",{className:"space-y-1",children:x.map(e=>{const r=Q[e.id]??null,c=Be(e),v=(c?ue?.sandboxProviders?.[c]:null)?.displayName??c??"sandbox";return(0,t.jsxs)("div",{className:"py-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[(0,t.jsxs)("span",{children:[e.name,Se(e)?null:(0,t.jsxs)("span",{className:"text-ink-3",children:[" · ",e.driver]})]}),Se(e)?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-bg-3 px-2 py-0.5 text-xs font-normal text-ink-3",children:[(0,t.jsx)(mt,{className:"h-3 w-3","aria-hidden":!0}),"Managed by Wardmote"]}):null]}),e.description?(0,t.jsx)("div",{className:"text-xs text-ink-3",children:e.description}):null,e.driver==="ssh"?(0,t.jsxs)("div",{className:"text-xs text-ink-3",children:[typeof e.config.host=="string"?e.config.host:"SSH host"," ·"," ",typeof e.config.username=="string"?e.config.username:"user"]}):e.driver==="sandbox"?(0,t.jsx)("div",{className:"text-xs text-ink-3",children:(()=>{const L=Gt(e.config);return Se(e)?L??"Provisioned and maintained for you.":`${v} sandbox provider${L?` · ${L}`:""}`})()}):(0,t.jsx)("div",{className:"text-xs text-ink-3",children:"Runs on this Wardmote host."})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[e.driver!=="local"?(0,t.jsx)(P,{size:"sm",variant:"secondary",onClick:s(()=>st.mutate(e.id),"onClick"),disabled:$===e.id,children:$===e.id?"Testing...":e.driver==="ssh"?"Test connection":"Test provider"}):null,(0,t.jsx)(P,{size:"sm",variant:"ghost",asChild:!0,children:(0,t.jsx)(ae,{to:qt(e.id),children:"Edit"})})]})]}),r?(0,t.jsxs)("div",{className:r.ok?"mt-3 rounded bg-green-500/5 px-2.5 py-2 text-xs text-green-700":"mt-3 rounded bg-bad/5 px-2.5 py-2 text-xs text-bad",children:[(0,t.jsx)("div",{className:"font-medium",children:r.summary}),r.details?.error&&typeof r.details.error=="string"?(0,t.jsx)("div",{className:"mt-1 font-mono text-(length:--text-micro)",children:r.details.error}):null]}):null]},e.id)})})]}),p&&n==="edit"&&i===void 0?(0,t.jsx)("div",{className:"text-sm text-ink-3",children:"Loading environment..."}):null,p&&n==="edit"&&i!==void 0&&!O?(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsx)("div",{className:"font-medium",children:"Environment not found"}),(0,t.jsx)("div",{className:"text-ink-3",children:"The environment may have been removed or is not available in this organization."}),(0,t.jsx)(P,{size:"sm",variant:"secondary",asChild:!0,children:(0,t.jsx)(ae,{to:Z,children:"Back to environments"})})]}):null,p&&(n==="create"||O)?(0,t.jsx)(At.Provider,{value:tt,children:(0,t.jsxs)("div",{"data-testid":"environment-form-page",children:[(0,t.jsxs)("div",{className:"pb-4",children:[(0,t.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-2",children:[(0,t.jsx)(P,{size:"sm",variant:"ghost",asChild:!0,children:(0,t.jsxs)(ae,{to:Z,children:[(0,t.jsx)(Ct,{className:"mr-1.5 h-3.5 w-3.5"}),"Environments"]})}),O?(0,t.jsx)(P,{size:"icon-sm",variant:"ghost","aria-label":`Delete ${O.name}`,title:"Delete environment","data-testid":"environment-delete-button",onClick:s(()=>{ee(""),M(!0)},"onClick"),children:(0,t.jsx)(Ye,{className:"h-4 w-4"})}):null]}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:m?"Edit environment":"Add environment"}),(0,t.jsx)("p",{className:"mt-1 max-w-3xl text-sm text-ink-3",children:"Configure a reusable execution target for your agents. Saved changes affect future runs; Wardmote may start fresh sessions or sandbox leases after environment config changes."})]}),(0,t.jsx)("div",{className:"py-4",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(q,{label:"Name",hint:"Operator-facing name for this execution target.",children:(0,t.jsx)("input",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",value:l.name,onChange:s(e=>h(r=>({...r,name:e.target.value})),"onChange")})}),(0,t.jsx)(q,{label:"Description",hint:"Optional note about what this machine is for.",children:(0,t.jsx)("input",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",value:l.description,onChange:s(e=>h(r=>({...r,description:e.target.value})),"onChange")})}),(0,t.jsx)(q,{label:"Driver",hint:"Sandbox stores plugin-backed provider config on the shared environment seam. SSH stores a remote machine target.",children:(0,t.jsxs)("select",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",value:l.driver,onChange:s(e=>h(r=>({...r,sandboxProvider:e.target.value==="sandbox"?r.sandboxProvider.trim()||W[0]?.provider||"":r.sandboxProvider,sandboxConfig:e.target.value==="sandbox"?r.sandboxProvider.trim().length>0&&r.driver==="sandbox"?r.sandboxConfig:W[0]?.configSchema?ye(W[0].configSchema):{}:r.sandboxConfig,driver:e.target.value==="sandbox"?"sandbox":"ssh"})),"onChange"),children:[it||l.driver==="sandbox"?(0,t.jsx)("option",{value:"sandbox",children:"Sandbox"}):null,(0,t.jsx)("option",{value:"ssh",children:"SSH"}),l.driver==="local"?(0,t.jsx)("option",{value:"local",children:"Local"}):null]})}),l.driver==="ssh"?(0,t.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,t.jsx)(q,{label:"Host",hint:"DNS name or IP address for the remote machine.",children:(0,t.jsx)("input",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",value:l.sshHost,onChange:s(e=>h(r=>({...r,sshHost:e.target.value})),"onChange")})}),(0,t.jsx)(q,{label:"Port",hint:"Defaults to 22.",children:(0,t.jsx)("input",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"number",min:1,max:65535,value:l.sshPort,onChange:s(e=>h(r=>({...r,sshPort:e.target.value})),"onChange")})}),(0,t.jsx)(q,{label:"Username",hint:"SSH username.",children:(0,t.jsx)("input",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",value:l.sshUsername,onChange:s(e=>h(r=>({...r,sshUsername:e.target.value})),"onChange")})}),(0,t.jsx)(q,{label:"Remote workspace path",hint:"Absolute path that Wardmote will verify during SSH connection tests.",children:(0,t.jsx)("input",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",type:"text",placeholder:"/Users/wardmote/workspace",value:l.sshRemoteWorkspacePath,onChange:s(e=>h(r=>({...r,sshRemoteWorkspacePath:e.target.value})),"onChange")})}),(0,t.jsx)(q,{label:"Private key",hint:"Optional PEM private key. Leave blank to rely on the server's SSH agent or default keychain.",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("select",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",value:l.sshPrivateKeySecretId,onChange:s(e=>h(r=>({...r,sshPrivateKeySecretId:e.target.value,sshPrivateKey:e.target.value?"":r.sshPrivateKey})),"onChange"),children:[(0,t.jsx)("option",{value:"",children:"No saved secret"}),(Ee??[]).map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,t.jsx)("textarea",{className:"h-32 w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-xs font-mono outline-none",value:l.sshPrivateKey,disabled:!!l.sshPrivateKeySecretId,onChange:s(e=>h(r=>({...r,sshPrivateKey:e.target.value})),"onChange")})]})}),(0,t.jsx)(q,{label:"Known hosts",hint:"Optional known_hosts block used when strict host key checking is enabled.",children:(0,t.jsx)("textarea",{className:"h-32 w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-xs font-mono outline-none",value:l.sshKnownHosts,onChange:s(e=>h(r=>({...r,sshKnownHosts:e.target.value})),"onChange")})}),(0,t.jsx)("div",{className:"md:col-span-2",children:(0,t.jsx)(Oe,{label:"Strict host key checking",hint:"Keep this on unless you deliberately want probe-time host key acceptance disabled.",checked:l.sshStrictHostKeyChecking,onChange:s(e=>h(r=>({...r,sshStrictHostKeyChecking:e})),"onChange")})})]}):null,l.driver==="sandbox"?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(q,{label:"Provider",hint:"Installed run-capable sandbox provider plugins appear here.",children:(0,t.jsx)("select",{className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm outline-none",value:l.sandboxProvider,onChange:s(e=>{const r=e.target.value,c=me.find(v=>v.provider===r)??null;h(v=>({...v,sandboxProvider:r,sandboxConfig:v.sandboxProvider===r?v.sandboxConfig:c?.configSchema?ye(c.configSchema):{}}))},"onChange"),children:me.map(e=>(0,t.jsx)("option",{value:e.provider,children:e.displayName},e.provider))})}),fe?.description?(0,t.jsx)("div",{className:"text-xs text-ink-3",children:fe.description}):null,ie?(0,t.jsx)($t,{schema:ie,values:l.sandboxConfig,onChange:s(e=>h(r=>({...r,sandboxConfig:e})),"onChange"),errors:_e}):(0,t.jsx)("div",{className:"text-xs text-ink-3",children:"This provider does not declare additional configuration fields."}),(0,t.jsx)(Oe,{label:"Stream run logs",hint:"Stream the agent CLI's output live while runs execute (recommended). Turn off to deliver output only when the run finishes.",checked:l.sandboxConfig.streamRunLogs!==!1,onChange:s(e=>h(r=>({...r,sandboxConfig:{...r.sandboxConfig,streamRunLogs:e}})),"onChange")})]}):null,O&&O.driver==="sandbox"&&l.driver==="sandbox"&&o?(0,t.jsxs)("div",{className:"space-y-2 py-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:"Custom image"}),(0,t.jsx)("div",{className:"text-xs text-ink-3",children:"Start a setup sandbox, SSH in to customize the instance, then capture the running machine as a reusable image for future runs."}),(0,t.jsx)(un,{environment:O,companyId:o,providerCapability:Ke,providerDisplayName:ot})]}):null,(0,t.jsx)(q,{label:"Environment variables",hint:"Injected into runs that resolve through this environment. Use plain values or organization secrets.",children:(0,t.jsx)(Et,{ref:D,value:l.envVars,secrets:Ee??[],onCreateSecret:s(async(e,r)=>await nt.mutateAsync({name:e,value:r}),"onCreateSecret"),onChange:s(e=>h(r=>({...r,envVars:e??{}})),"onChange"),onDirtyChange:R})}),B.isError?(0,t.jsx)("div",{className:"text-xs text-bad",children:B.error instanceof Error?B.error.message:"Failed to save environment"}):null,J.data?(0,t.jsx)("div",{className:J.data.ok?"text-xs text-green-600":"text-xs text-bad",children:J.data.summary}):null]})}),(0,t.jsxs)("div",{className:"flex flex-wrap justify-end gap-2 py-4",children:[(0,t.jsx)(P,{variant:"secondary",onClick:at,disabled:B.isPending,children:"Cancel"}),l.driver!=="local"?(0,t.jsx)(P,{variant:"secondary",onClick:s(()=>J.mutate(Ie()),"onClick"),disabled:J.isPending||!De,children:J.isPending?"Testing...":"Test"}):null,(0,t.jsx)(P,{onClick:s(()=>B.mutate(Ie()),"onClick"),disabled:B.isPending||!De,children:B.isPending?m?"Saving...":"Creating...":m?"Save environment":"Create environment"})]}),O?(0,t.jsx)(kt,{open:b,onOpenChange:s(e=>{!e&&se.isPending||M(e)},"onOpenChange"),children:(0,t.jsxs)(bt,{"data-testid":"environment-delete-dialog",children:[(0,t.jsxs)(jt,{children:[(0,t.jsxs)(vt,{children:["Delete ",O.name,"?"]}),(0,t.jsx)(gt,{children:ge?"Checking what uses this environment...":ve?"Could not check what uses this environment. Close this dialog and retry.":oe??([re&&j?`${j.reusableSandboxLeaseCount===1?"1 reusable sandbox":`${j.reusableSandboxLeaseCount} reusable sandboxes`} will be destroyed; the workspaces holding them stay open and provision a fresh sandbox on their next run.`:null,X.length>0?`${X.length===1?"1 agent uses":`${X.length} agents use`} this environment as their default. Choose the environment those agents should be reassigned to.`:null].filter(Boolean).join(" ")||"This environment will be permanently deleted and future runs stop resolving to it.")})]}),Fe.length>0?(0,t.jsxs)("div",{className:"space-y-1.5","data-testid":"environment-delete-lease-holders",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-ink-3",children:"Sandbox leases held by"}),(0,t.jsx)("ul",{className:"space-y-1",children:Fe.map(e=>(0,t.jsxs)("li",{className:"text-sm",children:[e.workspaceId?(0,t.jsx)(ae,{className:"underline underline-offset-2 hover:text-ink",to:`/execution-workspaces/${e.workspaceId}`,children:e.label}):(0,t.jsx)("span",{children:e.label}),(0,t.jsxs)("span",{className:"text-xs text-ink-3",children:[" ","· ",e.leaseCount===1?"1 sandbox lease":`${e.leaseCount} sandbox leases`,e.issueLabels.length>0?` · ${e.issueLabels.join(", ")}`:""]})]},e.workspaceId??e.label))}),(0,t.jsx)("div",{className:"text-xs text-ink-3",children:re?"Deleting destroys these sandboxes; the workspaces stay open.":"Close these workspaces to let Wardmote destroy their sandboxes, then retry the delete."})]}):null,!ge&&!ve&&!oe?(0,t.jsxs)("div",{className:"space-y-3",children:[X.length>0?(0,t.jsxs)("label",{className:"block space-y-1.5 text-sm",children:[(0,t.jsxs)("span",{className:"font-medium",children:["Reassign ",X.length===1?"agent":"agents"," to"]}),(0,t.jsxs)("select",{"aria-label":"Reassign agents to environment","data-testid":"environment-delete-reassign-select",className:"w-full rounded-md border border-line bg-transparent px-2.5 py-1.5 text-sm font-normal outline-none",value:V,onChange:s(e=>ee(e.target.value),"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",xe?`${xe.name} · ${xe.driver}`:"Local"]}),lt.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," · ",e.driver]},e.id))]}),(0,t.jsxs)("span",{className:"block text-xs text-ink-3",children:["Affected: ",X.map(e=>e.name).join(", ")]})]}):null,te.length>0?(0,t.jsx)("ul",{className:"space-y-1 text-xs text-ink-3",children:te.map(e=>(0,t.jsx)("li",{children:e},e))}):null]}):null,(0,t.jsxs)(St,{children:[(0,t.jsx)(wt,{disabled:se.isPending,children:"Cancel"}),(0,t.jsx)(yt,{className:"bg-bad text-accent-ink hover:bg-bad/90","data-testid":"environment-delete-confirm",disabled:se.isPending||ge||ve||!!oe,onClick:s(e=>{e.preventDefault(),se.mutate({environment:O,reassignAgentIds:X.map(r=>r.id),reassignTargetId:V||null,destroyReusableLeases:re})},"onClick"),children:se.isPending?"Deleting...":re&&j?`Destroy ${j.reusableSandboxLeaseCount===1?"1 sandbox":`${j.reusableSandboxLeaseCount} sandboxes`} and delete`:"Delete environment"})]})]})}):null]})}):null]}):(0,t.jsx)("div",{className:"max-w-6xl space-y-4",children:(0,t.jsx)("div",{className:"text-sm text-ink-3",children:"Turn on Environments in Settings > Features to manage shared execution targets."})}):(0,t.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization context to manage environment secrets and bindings."})}s(qn,"CompanyEnvironments");export{qn as CompanyEnvironments};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Be=Object.defineProperty;var u=(e,r)=>Be(e,"name",{value:r,configurable:!0});import{i as we}from"./rolldown-runtime-ZpX3ckPj.js";import{Ir as De,en as _e,l as ne,la as We,ua as Ue}from"./createLucideIcon-CgrPXnTY.js";import{h as qe}from"./star-eem0qj3E.js";import{_ as pe,t as G,v as X}from"./queryKeys-BzT8CD34.js";import{o as Ke,u as te}from"./companies-query-BEdFiAhG.js";import{n as Ye}from"./CompanyContext-fQCNWI_f.js";import{o as Ze,p as Ge}from"./router-BKzUF9uf.js";import{t as fe}from"./MarkdownBody-D7qCQaU_.js";import{t as B}from"./package-G5arH6JJ.js";import{r as Xe,t as H}from"./button-DI4w5WP7.js";import{t as me}from"./rotate-ccw-DpzLJhXT.js";import{t as He}from"./search-CgZSuGC8.js";import{t as Qe}from"./x-6E1yeU3Q.js";import{a as Ve}from"./ToastContext-DyVJ6bCh.js";import{t as Je}from"./agents-B8n-p0aX.js";import{t as et}from"./projects-l3kQxnTp.js";import{n as tt}from"./BreadcrumbContext-DNbB7zWn.js";import{Qn as st,T as D,Xa as nt,_ as rt,dt as he,ft as ot,ga as it,lt as at,mt as lt,pt as ct,ut}from"./index-
|
|
1
|
+
var Be=Object.defineProperty;var u=(e,r)=>Be(e,"name",{value:r,configurable:!0});import{i as we}from"./rolldown-runtime-ZpX3ckPj.js";import{Ir as De,en as _e,l as ne,la as We,ua as Ue}from"./createLucideIcon-CgrPXnTY.js";import{h as qe}from"./star-eem0qj3E.js";import{_ as pe,t as G,v as X}from"./queryKeys-BzT8CD34.js";import{o as Ke,u as te}from"./companies-query-BEdFiAhG.js";import{n as Ye}from"./CompanyContext-fQCNWI_f.js";import{o as Ze,p as Ge}from"./router-BKzUF9uf.js";import{t as fe}from"./MarkdownBody-D7qCQaU_.js";import{t as B}from"./package-G5arH6JJ.js";import{r as Xe,t as H}from"./button-DI4w5WP7.js";import{t as me}from"./rotate-ccw-DpzLJhXT.js";import{t as He}from"./search-CgZSuGC8.js";import{t as Qe}from"./x-6E1yeU3Q.js";import{a as Ve}from"./ToastContext-DyVJ6bCh.js";import{t as Je}from"./agents-B8n-p0aX.js";import{t as et}from"./projects-l3kQxnTp.js";import{n as tt}from"./BreadcrumbContext-DNbB7zWn.js";import{Qn as st,T as D,Xa as nt,_ as rt,dt as he,ft as ot,ga as it,lt as at,mt as lt,pt as ct,ut}from"./index-b1wwaMjV.js";import{t as dt}from"./issue-output-BM-lLts2.js";import{a as pt,i as ft,n as mt,r as ht,t as je}from"./portable-files-CloN_vbk.js";var h=we(Ue(),1),xt=["agents","projects","skills","routines","tasks","attachments"],gt={agents:"Agents",projects:"Projects",skills:"Skills",routines:"Routines",tasks:"Tasks",attachments:"Attachments"};function bt(){return{agents:!0,projects:!0,skills:!0,routines:!0,tasks:!0,attachments:!0}}u(bt,"buildDefaultExportCategorySelection");function ye(e){return e.tasks||e.routines}u(ye,"isAttachmentsCategoryEnabled");function ke(e){const r=new Set;for(const i of e){if(!i.recurring)continue;const n=i.path.trim();if(!n)continue;r.add(n);const o=n.lastIndexOf("/");o>=0&&r.add(`${n.slice(0,o+1)}`)}return r}u(ke,"buildRecurringTaskPrefixes");function wt(e,r){for(const i of r)if(e===i||e.startsWith(i))return!0;return!1}u(wt,"isRecurringTaskFile");function jt(e){const r=new Set,i=new Set;for(const n of e)for(const o of n.attachments??[]){const l=o.sha256.trim().toLowerCase();l&&(n.recurring?r:i).add(l)}return{recurring:r,oneOff:i}}u(jt,"buildAttachmentShaOwnership");var yt=new Set(["agents","projects","skills","routines","tasks"]);function kt(e){const r=new Map;for(const i of e){const n=i.sha256.trim().toLowerCase();if(!n)continue;const o=r.get(n)??new Set,l=i.ownedBy&&i.ownedBy.length>0?i.ownedBy:["always"];for(const p of l)o.add(p);r.set(n,o)}return r}u(kt,"buildEmbeddedAssetShaOwnership");function vt(e,r){for(const i of e)if(!yt.has(i)||r[i])return!0;return!1}u(vt,"isEmbeddedAssetBlobIncluded");function ve(e,r){return e.startsWith("agents/")?"agents":e.startsWith("projects/")?"projects":e.startsWith("skills/")?"skills":e.startsWith("tasks/")?wt(e,r)?"routines":"tasks":e.startsWith("blobs/")?"attachments":null}u(ve,"categorizeExportFile");function St(e,r){const i=ke(r),n={agents:0,projects:0,skills:0,routines:0,tasks:0,attachments:0};for(const o of e){const l=ve(o,i);l&&(n[l]+=1)}return n}u(St,"countExportFilesByCategory");function Ct(e){const{filePaths:r,issues:i,categories:n}=e,o=ke(i),l=jt(i),p=kt(e.embeddedAssets??[]),f=n.attachments&&ye(n),x=new Set;for(const c of r){const b=ve(c,o);if(b===null){x.add(c);continue}if(b==="attachments"){const a=c.slice(6).trim().toLowerCase(),g=p.get(a);if(g&&vt(g,n)){x.add(c);continue}if(!f)continue;const j=l.recurring.has(a),y=l.oneOff.has(a);!j&&!y?g||x.add(c):(y&&n.tasks||j&&n.routines)&&x.add(c);continue}n[b]&&x.add(c)}return x}u(Ct,"buildExportCheckedFiles");function Se(e,r){if(!r.has(e))return r.add(e),e;let i=2;for(;;){const n=`${e}-${i}`;if(!r.has(n))return r.add(n),n;i+=1}}u(Se,"uniqueSlug");function Et(e){const r=new Set,i=new Map,n=[...e].sort((o,l)=>o.name.localeCompare(l.name));for(const o of n){const l=De(o.name)??"agent";i.set(o.id,Se(l,r))}return i}u(Et,"buildPortableAgentSlugMap");function Nt(e){const r=new Set,i=new Map,n=[...e].sort((o,l)=>o.name.localeCompare(l.name));for(const o of n){const l=_e(o.name,o.name);i.set(o.id,Se(l,r))}return i}u(Nt,"buildPortableProjectSlugMap");function At(e){const r=Et(e.agents),i=Nt(e.projects),n={agents:e.orderedAgents.map(o=>r.get(o.id)).filter(o=>!!o),projects:e.orderedProjects.map(o=>i.get(o.id)).filter(o=>!!o)};return n.agents.length>0||n.projects.length>0?n:void 0}u(At,"buildPortableSidebarOrder");var t=we(We(),1);function Ce(e){const r=new Set,i=new Set,n=new Set;for(const o of e){const l=o.match(/^agents\/([^/]+)\//);l&&r.add(l[1]);const p=o.match(/^projects\/([^/]+)\//);p&&i.add(p[1]);const f=o.match(/^tasks\/([^/]+)\//);f&&n.add(f[1])}return{agents:r,projects:i,tasks:n,routines:new Set(n)}}u(Ce,"checkedSlugs");function Pt(e,r){const i=Ce(r),n=e.split(`
|
|
2
2
|
`),o=[],l=new Set(["agents","projects","tasks","routines"]),p=new Set(["agents","projects"]);let f=null,x=null,c=!0,b=null,a=null,g=[],j=null,y=[];function T(){a!==null&&g.length>0&&(y.push(a),y.push(...g)),a=null,g=[]}u(T,"flushSidebarSection");function N(){T(),j!==null&&y.length>0&&(o.push(j),o.push(...y)),j=null,y=[]}u(N,"flushSection");for(const w of n){const W=w.match(/^([a-zA-Z_][\w-]*):\s*(.*)$/);if(W&&!w.startsWith(" ")){N(),x=null,c=!0;const E=W[0].split(":")[0];if(l.has(E)){f=E,j=w;continue}else if(E==="sidebar"){f=E,b=null,j=w;continue}else{f=null,o.push(w);continue}}if(f==="sidebar"){const E=w.match(/^ ([\w-]+):\s*$/);if(E&&!w.startsWith(" ")){T();const A=E[1];b=A&&p.has(A)?A:null,a=b?w:null;continue}const L=w.match(/^ - ["']?([^"'\n]+)["']?\s*$/);if(L&&b){const A=L[1],U=i[b];A&&U.has(A)&&g.push(w);continue}if(b){g.push(w);continue}}if(f&&l.has(f)){const E=w.match(/^ ([\w][\w-]*):\s*(.*)$/);if(E&&!w.startsWith(" ")){const L=E[1];x=L,c=i[f].has(L),c&&y.push(w);continue}if(x!==null){c&&y.push(w);continue}y.push(w);continue}o.push(w)}N();let C=o.join(`
|
|
3
3
|
`);const _=C.match(/^\s{2}logoPath:\s*["']?([^"'\n]+)["']?\s*$/m);return _&&!r.has(_[1])&&(C=C.replace(/^\s{2}logoPath:\s*["']?([^"'\n]+)["']?\s*\n?/m,"")),C}u(Pt,"filterWardmoteYaml");function Ee(e,r){if(!r)return e;const i=r.toLowerCase();return e.map(n=>{if(n.kind==="file")return n.name.toLowerCase().includes(i)||n.path.toLowerCase().includes(i)?n:null;const o=Ee(n.children,r);return o.length>0?{...n,children:o}:null}).filter(n=>n!==null)}u(Ee,"filterTree");function Rt(e,r){const i=new Set,n=r.toLowerCase();function o(l,p){if(l.kind==="file"){if(l.name.toLowerCase().includes(n)||l.path.toLowerCase().includes(n))for(const f of p)i.add(f)}else for(const f of l.children)o(f,[...p,l.path])}u(o,"walk");for(const l of e)o(l,[]);return i}u(Rt,"collectMatchedParentDirs");var xe=10;function Tt(e,r,i,n){let o=0,l=0;return{nodes:e.map(p=>{if(p.kind==="dir"&&p.name==="tasks"){o=p.children.length;const f=[],x=[],c=i.toLowerCase();for(const g of p.children){const j=ot([g],"file"),y=n!==null&&j.has(n),T=i&&(g.name.toLowerCase().includes(c)||g.path.toLowerCase().includes(c)||[...j].some(N=>N.toLowerCase().includes(c)));y||T?f.push(g):x.push(g)}const b=Math.max(0,r-f.length),a=[...f,...x.slice(0,b)];return l=a.length,{...p,children:a}}return p}),totalTaskChildren:o,visibleTaskChildren:l}}u(Tt,"paginateTaskNodes");function Ne(e,r,i){const n={};for(const o of Object.keys(e))r.has(o)&&(n[o]=i[o]??e[o]);return n}u(Ne,"filterExportForDownload");function Lt(e,r,i){const n=Ne(e.files,r,i),o=ft(n,e.rootPath),l=new ArrayBuffer(o.byteLength);new Uint8Array(l).set(o);const p=new Blob([l],{type:"application/zip"}),f=URL.createObjectURL(p),x=document.createElement("a");x.href=f,x.download=`${e.rootPath}.zip`,document.body.appendChild(x),x.click(),x.remove(),window.setTimeout(()=>URL.revokeObjectURL(f),1e3)}u(Lt,"downloadZip");function Ot({data:e,onSkillClick:r}){return(0,t.jsx)("div",{className:"rounded-md border border-line bg-bg-3/20 px-4 py-3 mb-4",children:(0,t.jsx)("dl",{className:"grid grid-cols-(--gtc-5) gap-x-4 gap-y-1.5 text-sm",children:Object.entries(e).map(([i,n])=>(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)("dt",{className:"text-ink-3 whitespace-nowrap py-0.5",children:at[i]??i}),(0,t.jsx)("dd",{className:"py-0.5",children:Array.isArray(n)?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(o=>(0,t.jsx)("button",{type:"button",className:ne("inline-flex items-center rounded-md border border-line bg-bg px-2 py-0.5 text-xs",i==="skills"&&r&&"cursor-pointer hover:bg-bg-3/50 hover:border-ink/30 transition-colors"),onClick:u(()=>i==="skills"&&r?.(o),"onClick"),children:o},o))}):(0,t.jsx)("span",{children:n})})]},i))})})}u(Ot,"FrontmatterCard");var Mt={ceo:"CEO",cto:"CTO",cmo:"CMO",cfo:"CFO",coo:"COO",vp:"VP",manager:"Manager",engineer:"Engineer",agent:"Agent"};function Ft(e,r,i,n){const o=Ce(r),l=e.agents.filter(a=>o.agents.has(a.slug)),p=e.projects.filter(a=>o.projects.has(a.slug)),f=e.issues.filter(a=>o.tasks.has(a.slug)),x=e.skills.filter(a=>[...r].some(g=>g.startsWith(`skills/${a.key}/`)||g.startsWith("skills/")&&g.includes(`/${a.slug}/`))),c=[];c.push(`# ${i}`),c.push(""),n&&(c.push(`> ${n}`),c.push("")),l.length>0&&(c.push(""),c.push("")),c.push("## What's Inside"),c.push(""),c.push("This is an [Agent Company](https://agentcompanies.io) package."),c.push("");const b=[];if(l.length>0&&b.push(["Agents",l.length]),p.length>0&&b.push(["Projects",p.length]),x.length>0&&b.push(["Skills",x.length]),f.length>0&&b.push(["Tasks",f.length]),b.length>0){c.push("| Content | Count |"),c.push("|---------|-------|");for(const[a,g]of b)c.push(`| ${a} | ${g} |`);c.push("")}if(l.length>0){c.push("### Agents"),c.push(""),c.push("| Agent | Role | Reports To |"),c.push("|-------|------|------------|");for(const a of l){const g=Mt[a.role]??a.role,j=a.reportsToSlug??"—";c.push(`| ${a.name} | ${g} | ${j} |`)}c.push("")}if(p.length>0){c.push("### Projects"),c.push("");for(const a of p){const g=a.description?` — ${a.description}`:"";c.push(`- **${a.name}**${g}`)}c.push("")}return c.push("## Getting Started"),c.push(""),c.push("```bash"),c.push("npx @tickernelz/wardmote company import this-github-url-or-folder"),c.push("```"),c.push(""),c.push("See [Wardmote](https://github.com/tickernelz/wardmote) for more information."),c.push(""),c.push("---"),c.push(`Exported from [Wardmote](https://github.com/tickernelz/wardmote) on ${new Date().toISOString().split("T")[0]}`),c.push(""),c.join(`
|
|
4
4
|
`)}u(Ft,"generateReadmeFromSelection");function It(e){const{src:r,selectedFile:i,allFiles:n,orgChartPreviewUrl:o}=e;if(/^(?:https?:|data:)/i.test(r))return null;if(r.replace(/^\.\//,"")==="images/org-chart.png"&&o)return o;const l=(i.includes("/")?i.slice(0,i.lastIndexOf("/")+1):"")+r,p=n[l]??n[r];return p?je(l in n?l:r,p):null}u(It,"resolveExportPreviewImageSrc");function zt({selectedFile:e,content:r,allFiles:i,orgChartPreviewUrl:n,onSkillClick:o}){if(!e||r===null)return(0,t.jsx)(D,{icon:B,message:"Select a file to preview its contents."});const l=mt(r),p=e.endsWith(".md")&&l!==null,f=p&&l?lt(l):null,x=ht(e,r)?je(e,r):null,c=p?b=>It({src:b,selectedFile:e,allFiles:i,orgChartPreviewUrl:n}):void 0;return(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"border-b border-line px-5 py-3",children:(0,t.jsx)("div",{className:"truncate font-mono text-sm",children:e})}),(0,t.jsx)("div",{className:"min-h-(--sz-560px) px-5 py-5",children:f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ot,{data:f.data,onSkillClick:o}),f.body.trim()&&(0,t.jsx)(fe,{resolveImageSrc:c,softBreaks:!1,linkIssueReferences:!1,children:f.body})]}):p?(0,t.jsx)(fe,{resolveImageSrc:c,softBreaks:!1,linkIssueReferences:!1,children:l??""}):x?(0,t.jsx)("div",{className:"flex min-h-(--sz-520px) items-center justify-center rounded-lg border border-line bg-bg-3/10 p-6",children:(0,t.jsx)("img",{src:x,alt:e,className:"max-h-(--sz-480px) max-w-full object-contain"})}):l!==null?(0,t.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words border-0 bg-transparent p-0 font-mono text-sm text-ink",children:(0,t.jsx)("code",{children:l})}):(0,t.jsx)("div",{className:"rounded-lg border border-line bg-bg-3/10 px-4 py-3 text-sm text-ink-3",children:"Binary asset preview is not available for this file type."})})]})}u(zt,"ExportPreviewPane");function ge(e){const r="/company/export/files/",i=Ge(e),n=i.indexOf(r);return n===-1?null:decodeURIComponent(i.slice(n+22))||null}u(ge,"filePathFromLocation");function be(e){const r=e.split("/").slice(0,-1),i=[];let n="";for(const o of r)n=n?`${n}/${o}`:o,i.push(n);return i}u(be,"expandAncestors");function $t(e){return(e instanceof DOMException||e instanceof Error)&&e.name==="AbortError"}u($t,"isAbortError");function se(e){return e instanceof Error?e.message:"Failed to load export data."}u(se,"previewErrorMessage");function is(){const{selectedCompanyId:e,selectedCompany:r}=Ye(),{setBreadcrumbs:i}=tt(),{pushToast:n}=Ve(),o=Ze(),l=qe(),p=(0,h.useRef)(ge(l.pathname)),{data:f}=X({queryKey:G.auth.session,queryFn:u(()=>Ke.getSession(),"queryFn")}),{data:x=[]}=X({queryKey:G.agents.list(e),queryFn:u(()=>Je.list(e),"queryFn"),enabled:!!e}),{data:c=[]}=X({queryKey:G.projects.list(e),queryFn:u(()=>et.list(e),"queryFn"),enabled:!!e}),{data:b}=X({queryKey:G.companies.exportFidelity(e),queryFn:u(()=>te.exportFidelity(e),"queryFn"),enabled:!!e}),[a,g]=(0,h.useState)(null),[j,y]=(0,h.useState)(null),[T,N]=(0,h.useState)(new Set),[C,_]=(0,h.useState)(()=>({...bt(),tasks:!1,routines:!1,attachments:!1})),[w,W]=(0,h.useState)(""),[E,L]=(0,h.useState)(xe),[A,U]=(0,h.useState)(!1),q=(0,h.useRef)(null),I=(0,h.useRef)(null),M=(0,h.useRef)(0),re=(0,h.useRef)(null),oe=f?.user?.id??f?.session?.userId??null,Q=(0,h.useMemo)(()=>x.filter(s=>s.status!=="terminated"),[x]),V=(0,h.useMemo)(()=>c,[c]),{orderedAgents:ie}=it({agents:Q,companyId:e,userId:oe}),{orderedProjects:ae}=st({projects:V,companyId:e,userId:oe}),le=(0,h.useMemo)(()=>At({agents:Q,orderedAgents:ie,projects:V,orderedProjects:ae}),[ie,ae,Q,V]),J=C.tasks||C.routines,ee=(0,h.useCallback)((s,d=!1)=>{y(s),s?o(`/company/export/files/${encodeURI(s)}`,{replace:d}):o("/company/export",{replace:d})},[o]);(0,h.useEffect)(()=>{if(!a)return;const s=ge(l.pathname);s&&s in a.files&&s!==j?(y(s),N(d=>{const m=new Set(d);for(const k of be(s))m.add(k);return m})):!s&&j&&y(null)},[l.pathname,a]),(0,h.useEffect)(()=>{i([{label:r?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Export"}])},[r?.name,i]);const P=pe({mutationFn:u(({includeIssues:s,includeSkills:d,signal:m})=>te.exportPreview(e,{include:{company:!0,agents:!0,projects:!0,issues:s,skills:d},sidebarOrder:le},{signal:m}),"mutationFn"),onSuccess:u((s,d)=>{if(d.requestId!==M.current)return;g(s);const m=he(s.files),k=new Set;for(const v of m)v.kind==="dir"&&v.name!=="tasks"&&k.add(v.path);const S=p.current;if(S&&S in s.files){y(S);const v=be(S);N(new Set([...k,...v]))}else{const v="README.md"in s.files?"README.md":Object.keys(s.files)[0];v&&ee(v,!0),N(k)}},"onSuccess"),onError:u((s,d)=>{d.requestId!==M.current||$t(s)||n({tone:"error",title:"Export failed",body:se(s)})},"onError")});function F(){if(!e)return;I.current?.abort();const s=new AbortController,d=M.current+1;M.current=d,I.current=s,U(!1),P.mutate({includeIssues:J,includeSkills:C.skills,requestId:d,signal:s.signal})}u(F,"startPreviewRequest");const K=pe({mutationFn:u(()=>te.exportBundle(e,{include:{company:!0,agents:!0,projects:!0,issues:J,skills:C.skills},selectedFiles:Array.from(R).sort(),sidebarOrder:le}),"mutationFn"),onSuccess:u(s=>{const d=new Set(Object.keys(s.files));Lt(s,d,s.files),n({tone:"success",title:"Export downloaded",body:`${d.size} file${d.size===1?"":"s"} exported as ${s.rootPath}.zip`})},"onSuccess"),onError:u(s=>{n({tone:"error",title:"Export failed",body:s instanceof Error?s.message:"Failed to build export package."})},"onError")});(0,h.useEffect)(()=>{e&&(re.current!==e&&(re.current=e,g(null),y(null)),F())},[e,J,C.skills]),(0,h.useEffect)(()=>()=>{M.current+=1,I.current?.abort()},[]);const O=(0,h.useMemo)(()=>a?he(a.files):[],[a]),R=(0,h.useMemo)(()=>a?Ct({filePaths:Object.keys(a.files),issues:a.manifest.issues,categories:C,embeddedAssets:a.manifest.embeddedAssets??[]}):new Set,[a,C]),Ae=(0,h.useMemo)(()=>a?St(Object.keys(a.files),a.manifest.issues):null,[a]),{displayTree:Pe,totalTaskChildren:ce,visibleTaskChildren:ue}=(0,h.useMemo)(()=>{let s=O;w&&(s=Ee(s,w));const d=Tt(s,E,w,j);return{displayTree:d.nodes,totalTaskChildren:d.totalTaskChildren,visibleTaskChildren:d.visibleTaskChildren}},[O,w,E,j]),Re=(0,h.useMemo)(()=>{const s={};function d(m){if(m.kind==="file"){const S=R.has(m.path);return S||(s[m.path]="muted"),S}let k=!1;for(const S of m.children)d(S)&&(k=!0);return k||(s[m.path]="muted"),k}u(d,"walk");for(const m of O)d(m);return s},[O,R]),Y=(0,h.useMemo)(()=>{if(!a)return{};const s={...a.files},d=a.wardmoteExtensionPath;if(d&&typeof a.files[d]=="string"&&(s[d]=Pt(a.files[d],R)),typeof a.files["README.md"]=="string"){const m=a.manifest.company?.name??r?.name??"Company",k=a.manifest.company?.description??null;s["README.md"]=Ft(a.manifest,R,m,k)}return s},[a,R,r?.name]),Te=(0,h.useMemo)(()=>a?pt(Ne(a.files,R,Y),a.rootPath):0,[a,R,Y]),de=(0,h.useMemo)(()=>ct(O),[O]),z=R.size,$=(0,h.useMemo)(()=>a?a.warnings.filter(s=>!/terminated agent/i.test(s)):[],[a]);function Le(s){N(d=>{const m=new Set(d);return m.has(s)?m.delete(s):m.add(s),m})}u(Le,"handleToggleDir");function Oe(s){_(d=>({...d,[s]:!d[s]}))}u(Oe,"handleToggleCategory");function Me(s){const d=w.length>0,m=s.length>0;if(m&&!d&&(q.current=new Set(T)),W(s),m){const k=Rt(O,s);N(S=>{const v=new Set(S);for(const Z of k)v.add(Z);return v})}else d&&q.current&&(N(q.current),q.current=null)}u(Me,"handleSearchChange");function Fe(s){if(!a)return;const d=a.manifest.skills.find(m=>m.key===s||m.slug===s)?.path??`skills/${s}/SKILL.md`;d in a.files&&(ee(d),N(m=>{const k=new Set(m);k.add("skills");const S=d.split("/").slice(0,-1);let v="";for(const Z of S)v=v?`${v}/${Z}`:Z,k.add(v);return k}))}u(Fe,"handleSkillClick");function Ie(){!a||R.size===0||K.isPending||K.mutate()}u(Ie,"handleDownload");function ze(){M.current+=1,I.current?.abort(),I.current=null,P.reset(),U(!0)}if(u(ze,"handleCancelPreview"),!e)return(0,t.jsx)(D,{icon:B,message:"Select an organization to export."});if(P.isPending&&!a)return(0,t.jsx)(rt,{variant:"detail"});if(A&&!a)return(0,t.jsx)(D,{icon:B,title:"Export preview cancelled",message:"The preview request was cancelled. Your export settings are unchanged.",action:"Retry preview",onAction:F,hideActionIcon:!0});if(P.isError&&!a)return(0,t.jsx)(D,{icon:B,title:"Export preview failed",message:se(P.error),description:"Retry the preview. You do not need to reload this page.",action:"Retry preview",onAction:F,hideActionIcon:!0});if(!a)return(0,t.jsx)(D,{icon:B,title:"Export preview unavailable",message:"No export preview is loaded.",action:"Load preview",onAction:F,hideActionIcon:!0});const $e=j?Y[j]??null:null;return(0,t.jsxs)("div",{className:"max-w-6xl",children:[(0,t.jsx)("div",{className:"sticky top-0 z-10 border-b border-line bg-bg px-5 py-3",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[(0,t.jsxs)("span",{className:"font-medium",children:[r?.name??"Organization"," export"]}),(0,t.jsxs)("span",{className:"text-ink-3",children:["Exporting ",z.toLocaleString()," of ",de.toLocaleString()," file",de===1?"":"s",z>0&&` (~${dt(Te)})`]}),$.length>0&&(0,t.jsxs)("span",{className:"text-amber-500",children:[$.length," warning",$.length===1?"":"s"]})]}),(0,t.jsxs)(H,{size:"sm",onClick:Ie,disabled:z===0||K.isPending||P.isPending||P.isError||A,children:[(0,t.jsx)(nt,{className:"mr-1.5 h-3.5 w-3.5"}),K.isPending?"Building export...":`Export ${z.toLocaleString()} file${z===1?"":"s"}`]})]})}),$.length>0&&(0,t.jsx)("div",{className:"mx-5 mt-3 rounded-md border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:$.map(s=>(0,t.jsx)("div",{className:"text-xs text-amber-500",children:s},s))}),b&&b.warnings.length>0&&(0,t.jsxs)("div",{className:"mx-5 mt-3 rounded-md border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:[(0,t.jsx)("h3",{className:"mb-1.5 text-xs font-medium",children:"Not included in this export"}),b.warnings.map(s=>(0,t.jsx)("div",{className:ne("text-xs",s.severity==="blocker"?"font-medium text-bad":"text-amber-500"),children:s.message},s.code))]}),(0,t.jsxs)("div",{className:"grid gap-4 xl:h-(--sz-calc-30) xl:grid-cols-(--gtc-25) xl:gap-0",children:[(0,t.jsxs)("aside",{className:"flex max-h-(--sz-24rem) flex-col overflow-hidden border-b border-line xl:max-h-none xl:border-b-0 xl:border-r",children:[(0,t.jsx)("div",{className:"border-b border-line px-4 py-3 shrink-0",children:(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Package files"})}),(0,t.jsxs)("div",{className:"border-b border-line px-4 py-3 shrink-0",children:[(0,t.jsx)("h3",{className:"mb-2 text-xs font-medium text-ink-3",children:"What to include"}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",role:"group","aria-label":"What to include",children:xt.map(s=>{const d=s==="attachments"&&!ye(C),m=C[s]&&!d,k=Ae?.[s]??0,S=a.manifest.includes.issues||s!=="tasks"&&s!=="routines"&&s!=="attachments";return(0,t.jsxs)("label",{className:ne("flex items-center gap-2 text-sm",d?"cursor-not-allowed opacity-50":"cursor-pointer"),title:d?"Attachments travel with tasks and routines; re-enable one of them to include attachments.":void 0,children:[(0,t.jsx)("input",{type:"checkbox",checked:m,disabled:d,onChange:u(()=>Oe(s),"onChange"),className:"accent-ink","data-export-category":s}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:gt[s]}),(0,t.jsx)("span",{className:"text-xs text-ink-3",children:S?k.toLocaleString():"—"})]},s)})}),(0,t.jsx)("p",{className:"mt-2 text-xs text-ink-3",children:"Task and routine history is opt-in because it can be large."})]}),(0,t.jsx)("div",{className:"border-b border-line px-3 py-2 shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-line px-2 py-1",children:[(0,t.jsx)(He,{className:"h-3.5 w-3.5 text-ink-3 shrink-0"}),(0,t.jsx)("input",{type:"text",value:w,onChange:u(s=>Me(s.target.value),"onChange"),placeholder:"Search files...",className:"w-full bg-transparent text-sm outline-none placeholder:text-ink-3","data-page-search-target":"true"})]})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,t.jsx)(ut,{nodes:Pe,selectedFile:j,expandedDirs:T,onToggleDir:Le,onSelectFile:ee,fileTones:Re,showCheckboxes:!1,wrapLabels:!1}),ce>ue&&!w&&(0,t.jsx)("div",{className:"px-4 py-2",children:(0,t.jsxs)("button",{type:"button",onClick:u(()=>L(s=>s+xe),"onClick"),className:"w-full rounded-md border border-line px-3 py-1.5 text-xs text-ink-3 hover:bg-bg-3/30 hover:text-ink transition-colors",children:["Show more tasks (",ue," of ",ce,")"]})})]})]}),(0,t.jsxs)("div",{className:"relative min-w-0 overflow-y-auto xl:pl-6",children:[(0,t.jsx)(zt,{selectedFile:j,content:$e,allFiles:Y,orgChartPreviewUrl:`/api/companies/${encodeURIComponent(e)}/org.svg`,onSkillClick:Fe}),P.isPending?(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex min-h-(--sz-520px) items-center justify-center bg-bg/90 px-6 text-center",role:"status","aria-live":"polite","aria-busy":"true","data-export-preview-state":"loading",children:(0,t.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3",children:[(0,t.jsx)(Xe,{className:"h-6 w-6 animate-spin text-ink-3"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Updating export preview…"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"Large task histories can take a minute. You can untick Tasks or cancel this update."})]}),(0,t.jsxs)(H,{type:"button",variant:"secondary",size:"sm",onClick:ze,children:[(0,t.jsx)(Qe,{}),"Cancel update"]})]})}):A?(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex min-h-(--sz-520px) items-center justify-center bg-bg/90 px-6 text-center","data-export-preview-state":"cancelled",children:(0,t.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Preview update cancelled"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:"The previous preview remains available. Retry when you are ready."})]}),(0,t.jsxs)(H,{type:"button",variant:"secondary",size:"sm",onClick:F,children:[(0,t.jsx)(me,{}),"Retry preview"]})]})}):P.isError?(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex min-h-(--sz-520px) items-center justify-center bg-bg/90 px-6 text-center",role:"alert","data-export-preview-state":"error",children:(0,t.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-bad",children:"Export preview failed"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:se(P.error)})]}),(0,t.jsxs)(H,{type:"button",variant:"secondary",size:"sm",onClick:F,children:[(0,t.jsx)(me,{}),"Retry preview"]})]})}):null]})]})]})}u(is,"CompanyExport");export{is as CompanyExport};
|