local-operator-ui 0.31.10 → 0.31.11
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/README.md +110 -126
- package/out/main/index.js +37 -0
- package/out/renderer/assets/{_basePickBy-9ROOwmxL.js → _basePickBy-DfG4wjig.js} +1 -1
- package/out/renderer/assets/{_baseUniq-eE-r5ZZ4.js → _baseUniq-BGWDx1XP.js} +1 -1
- package/out/renderer/assets/{agent-details-page-Vs9AZBwz.js → agent-details-page-DhkOKq6G.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-CGJbElaY.js → agent-hub-page-BRjvfsAy.js} +2 -2
- package/out/renderer/assets/{agents-page-tftebSEL.js → agents-page-DgY_6v2S.js} +2 -2
- package/out/renderer/assets/{arc-DN4pJSIq.js → arc-BbZdEs1w.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-uYP9fQLK.js → architectureDiagram-IEHRJDOE-4lLfeFcj.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-CmsXiKwe.js → blockDiagram-JOT3LUYC-CzCeK4l6.js} +1 -1
- package/out/renderer/assets/{browser-page-Bu7bkVij.js → browser-page-BVkXt8Il.js} +1 -1
- package/out/renderer/assets/{browser-webauthn-prompt-CCZq7UZY.js → browser-webauthn-prompt-Bynwfiuq.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DSjqK2s4.js → c4Diagram-VJAJSXHY-DV6jCVYX.js} +1 -1
- package/out/renderer/assets/channel-DZvj1zQv.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-C1_SAsaq.js → chunk-4BMEZGHF-oN7e33U6.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-Cq0zFbJT.js → chunk-A2AXSNBT-BY7xgPLa.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BcKdPjvg.js → chunk-AEK57VVT-CdvId8Is.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DRByxdTc.js → chunk-D6G4REZN-BnHX7WDi.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-Duscm0Bg.js → chunk-RZ5BOZE2-D-FjPJs7.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-BWEXg8AD.js → chunk-XZIHB7SX-DE_XcGmS.js} +1 -1
- package/out/renderer/assets/{classDiagram-GIVACNV2-CU02kTw_.js → classDiagram-GIVACNV2-CxG-TQSG.js} +1 -1
- package/out/renderer/assets/{classDiagram-v2-COTLJTTW-CU02kTw_.js → classDiagram-v2-COTLJTTW-CxG-TQSG.js} +1 -1
- package/out/renderer/assets/clone-CzEyof2a.js +1 -0
- package/out/renderer/assets/{dagre-OKDRZEBW-Cn7pFiK5.js → dagre-OKDRZEBW-DSno4uDg.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-LyA2eojc.js → diagram-SSKATNLV-Cta_mlzh.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-LPidUHcc.js → diagram-VNBRO52H-DXZvuw9Y.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CTjCMg7T.js → erDiagram-Q7BY3M3F-DX_NZcvT.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-BmWZ8kNr.js → flowDiagram-4HSFHLVR-CkKn14vu.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CfDRHTNJ.js → ganttDiagram-APWFNJXF-pfUZL8XQ.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CEYh6RxP.js → gitGraphDiagram-7IBYFJ6S-DyxkVnKD.js} +1 -1
- package/out/renderer/assets/{graph-_dzRI-I_.js → graph-CS6U_APD.js} +1 -1
- package/out/renderer/assets/{index-BKqWQaFB.js → index-0hsmy_dv.js} +1 -1
- package/out/renderer/assets/{index-tykR0DI9.js → index-BoBj0LUC.js} +391 -386
- package/out/renderer/assets/{index-DPFT_2au.js → index-W19BqfEn.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-BRBj70Iz.js → infoDiagram-PH2N3AL5-DstV9F9y.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-kHoqijou.js → journeyDiagram-U35MCT3I-DMxIQQHc.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-DEpxCCmE.js → kanban-definition-NDS4AKOZ-DwCNWIKf.js} +1 -1
- package/out/renderer/assets/{layout-C8CaQmGy.js → layout-rRE-L5H5.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-TbzorhDj.js → legacy-agents-page-D3XdLDk2.js} +1 -1
- package/out/renderer/assets/{mermaid.core-xrJy-S5f.js → mermaid.core-CHO9EN5d.js} +5 -5
- package/out/renderer/assets/{mesh-page-Do2sLCUJ.js → mesh-page-Bo6Mw1uW.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BUYs8m2Y.js → mindmap-definition-ALO5MXBD-C0TbE2NA.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-9zY-gRI7.js → org-surface-gate-CyrcQL7E.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-DLyxJ6_z.js → pieDiagram-IB7DONF6-psQNoVHK.js} +1 -1
- package/out/renderer/assets/{projects-page-pUwqeYdO.js → projects-page-DLrWcA92.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DH7de3iA.js → quadrantDiagram-7GDLP6J5-DAX1qBwZ.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-07d8mdrE.js → radar-MK3ICKWK-BRutmqUf.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-8U1osKLe.js → radient-auth-buttons-fe1Bn89n.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B32qFUIl.js → requirementDiagram-KVF5MWMF-PTinIVCd.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-sbqxByYH.js → sankeyDiagram-QLVOVGJD-DuPXhi_4.js} +1 -1
- package/out/renderer/assets/{schedules-page-XTDmccje.js → schedules-page-Bxn30SeI.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-B73M11ec.js → sequenceDiagram-X6HHIX6F-CSbiipy3.js} +1 -1
- package/out/renderer/assets/{settings-page-CK0UZY_b.js → settings-page-DeQ29q0v.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-B4WvgL0d.js → stateDiagram-DGXRK772-B0olW3ZC.js} +1 -1
- package/out/renderer/assets/{stateDiagram-v2-YXO3MK2T-DNtZ1inO.js → stateDiagram-v2-YXO3MK2T-DesKgCmL.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-C4QiFAyx.js → timeline-definition-BDJGKUSR-DrFO8Scg.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-uGo2AQXO.js → use-download-agent-mutation-DB-9HDGk.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-CjIPH1YX.js → use-memberships-query-DJonF1zy.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-wcBKtlf2.js → xychartDiagram-VJFVF3MP-ResXi4IE.js} +1 -1
- package/out/renderer/index.html +1 -1
- package/package.json +2 -2
- package/out/renderer/assets/channel-bHKgHeS_.js +0 -1
- package/out/renderer/assets/clone-ARdM9vXs.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as i,j as e,c as
|
|
1
|
+
import{r as i,j as e,c as I}from"./index-C-P4UaBn.js";import{i as pe,aJ as ie,aQ as Ee,aR as he,aV as Le,r as Ie,h as Fe,aE as Me,g as $e,aK as De,aW as Ue,aL as Ye,aX as ge,aY as Ve,ax as qe,aw as be,c as Qe,an as Be,aZ as He}from"./index-BoBj0LUC.js";import{o as je,u as We,a as Ge,C as Ze,b as Je}from"./org-surface-gate-CyrcQL7E.js";import{P as Ke}from"./page-header-BXIWLsA1.js";import{c as Xe,f as q,B as N,a as m,A as H,g as W,h as G,k as se,l as te,m as ne,n as re,o as Q,I as ea}from"./error-boundary-Be38BRVp.js";import{R as aa,u as sa}from"./radient-auth-buttons-fe1Bn89n.js";import{e as ta,f as na,p as ra,P as ia,b as la,h as oa}from"./use-memberships-query-DJonF1zy.js";import{O as ca,A as da,f as ua,H as ma,a as ha,b as ga,c as xa,d as ve,C as fa,u as pa,i as ba}from"./use-download-agent-mutation-DB-9HDGk.js";import"./console-mirror-DjoNpI7u.js";import"./en-US-BkS8Ixxl.js";import"./book-open-CNgko0U5.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ja=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],va=Xe("circle-ellipsis",ja),Na=({agent:a,isLiked:t,isFavourited:n,onLikeToggle:r,onFavouriteToggle:o,onDownload:c,isLikeActionLoading:h=!1,isFavouriteActionLoading:y=!1,isDownloading:x=!1,actionError:d=null,onRetryAction:p,showActions:b=!0,viewerStateKnown:f=!0,orgName:j=null})=>{const k=pe(),{isAuthenticated:u}=ie(),_=a.description??"",[P,R]=i.useState(!1),l=i.useRef(null),v=i.useCallback(g=>{if(l.current?.disconnect(),l.current=null,!g)return;const S=()=>R(g.scrollHeight-g.clientHeight>1);S();const D=new ResizeObserver(S);D.observe(g),l.current=D},[]),M=u?f?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",$=u?f?n?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",z=f?t?"Unlike agent":"Like agent":"Like state unavailable",O=f?n?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",E=a.visibility==="org";return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface transition-colors duration-fast ease-out-quart hover:border-control",children:[e.jsxs("button",{type:"button",onClick:()=>k(`/agent-hub/${a.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${a.name}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:a.name}),E&&e.jsx(ca,{orgName:j}),e.jsx(q,{content:P?_:"",children:e.jsx("span",{ref:v,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:_})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(da,{tags:a.tags,categories:a.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[a.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",ua(new Date(a.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":E?"org":u?f?"known":"unknown":"signed-out",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsx(q,{content:M,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u&&f?()=>r(a.id):void 0,disabled:h||!u||!f,"aria-label":z,className:F(t&&"text-danger"),children:[e.jsx(ma,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.like_count??0})]})})}),e.jsx(q,{content:$,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u?()=>o(a.id):void 0,disabled:y||!u||!f,"aria-label":O,className:F(n&&"text-warning"),children:[e.jsx(Ee,{fill:n?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.favourite_count??0})]})})})]}),e.jsx(q,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(he,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:x?e.jsx(m,{className:"h-3 w-6"}):(a.download_count??0).toLocaleString()})]})})]}),b&&c&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>c(a),disabled:x,"aria-label":`Download ${a.name}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(he,{"data-testid":"agent-download"}),"Get"]})})]}),d&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:d}),p&&e.jsx(N,{variant:"ghost",size:"sm",onClick:p,children:"Try again"})]})]})},ya=({agent:a,status:t,viewerStateKnown:n=!0,orgName:r=null})=>{const{isAuthenticated:o}=ie(),[c,h]=i.useState(null),y=t?.liked??!1,x=t?.favourited??!1,d=ha(),p=ga(),b=xa(),f=()=>{!o||d.isPending||(h(null),d.mutate({agentId:a.id,isCurrentlyLiked:y},{onError:()=>h("like")}))},j=()=>{!o||p.isPending||(h(null),p.mutate({agentId:a.id,isCurrentlyFavourited:x},{onError:()=>h("favourite")}))},k=()=>{b.isPending||(h(null),b.mutate({agentId:a.id,agentName:a.name},{onError:()=>h("download")}))},u=c?c==="like"?{action:"like",error:d.error,retry:f}:c==="favourite"?{action:"favourite",error:p.error,retry:j}:{action:"download",error:b.error,retry:k}:null;return e.jsx(Na,{agent:a,isLiked:o&&y,isFavourited:o&&x,onLikeToggle:f,onFavouriteToggle:j,onDownload:k,isLikeActionLoading:d.isPending,isFavouriteActionLoading:p.isPending,isDownloading:b.isPending,viewerStateKnown:n,orgName:r,actionError:u?ta(u.action,u.error,a.name):null,onRetryAction:u?.retry})},xe=({selected:a,onClick:t,children:n,...r})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":a,className:F("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",a?Ie:"text-ink hover:bg-row-hover"),...r,children:n}),fe=Object.keys(fa),wa=a=>[...a].sort((t,n)=>{const r=fe.indexOf(t),o=fe.indexOf(n);return r!==-1&&o!==-1?r-o:r!==-1?-1:o!==-1?1:t.localeCompare(n)}),ka=({selectedCategory:a,onSelectCategory:t,categories:n})=>{const r=wa(a&&!n.includes(a)?[...n,a]:n);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:"Categories"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(xe,{selected:a===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Le,{size:16,"aria-hidden":"true"})}),"All categories"]}),r.map(o=>{const c=ve(o),h=o==="other"?e.jsx(va,{size:16}):c.icon;return e.jsxs(xe,{selected:a===o,onClick:()=>t(o),"data-testid":`category-${o}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:h}),c.label]},o)})]})]})},Ne={all:["org-teams"],list:a=>[...Ne.all,"list",a]},Ca=({tenantId:a,enabled:t=!0})=>{const n=Fe({queryKey:Ne.list(a??""),queryFn:async()=>(await na(a)).result??{teams:[]},enabled:t&&!!a,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retry:Me});return{...n,teams:n.data?.teams??[]}},Sa=(a,t)=>{const n=a?.name?.trim()||t?.trim()||"Team",r=a?.renamed_from?.trim()||null;return a?.invalid_name===!0&&r?{level:"warning",message:`Pulled "${n}". The published name "${r}" is not usable locally, so the team was stored as "${n}".`}:r?{level:"success",message:`Pulled "${n}" (you already have a team called "${r}").`}:{level:"success",message:`Pulled team "${n}".`}},Ta=()=>{const a=$e();return De({mutationFn:async({teamId:t,tenantId:n})=>{if(!ge.baseUrl)throw new Error("Local Operator API URL is not configured.");return Ve.pullOrgTeamFromRadient(ge.baseUrl,t,n)},onSuccess:(t,n)=>{const r=Sa(t.result,n.name);r.level==="warning"?Ue(r.message):Ye(r.message),a.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Aa=["refresh-hub","retry","sign-in"],_a=({tenantId:a,orgName:t})=>{const{teams:n,isLoading:r,isFetching:o,isError:c,error:h,refetch:y}=Ca({tenantId:a}),x=je(h),d=Ta(),[p,b]=i.useState(null),[f,j]=i.useState(null),[k,u]=i.useState(!1),_=i.useMemo(()=>{if(!qe(d.error))return null;const l=n.find(v=>v.id===p);return ra({code:d.error.code,message:d.error.message,details:d.error.details},{name:l?.name??"this team",hubAgentId:null,surface:"pull"})},[d.error,p,n]),P=(l,v)=>{switch(l){case"refresh-hub":y();break;case"retry":R(v);break;case"sign-in":u(!0);break}},R=l=>{d.isPending||(b(null),j(l.id),d.mutate({teamId:l.id,tenantId:a,name:l.name},{onSettled:()=>j(null),onError:()=>b(l.id)}))};return e.jsxs("section",{className:"mb-6 rounded-lg border border-hairline bg-surface","aria-labelledby":"org-teams-heading","data-testid":"org-teams",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2 px-4 pt-3 pb-2",children:[e.jsx("h2",{id:"org-teams-heading",className:"font-medium text-heading text-ink",children:"Teams"}),!r&&!c&&e.jsxs("p",{className:"text-meta text-ink-dim","data-testid":"org-teams-count",children:[n.length," ",n.length===1?"team":"teams"," shared with"," ",t??"this organization"]})]}),r&&e.jsxs("div",{className:"flex flex-col gap-2 px-4 pb-4","data-testid":"org-teams-loading",children:[e.jsx("span",{className:"sr-only",children:"Loading teams…"}),e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col gap-2",children:[e.jsx(m,{className:"h-4.5 w-40"}),e.jsx(m,{className:"h-3.5 w-64"})]})]}),!r&&c&&e.jsxs(H,{variant:x?"warning":"danger",className:"mx-4 mb-4","data-testid":"org-teams-error",children:[e.jsx(W,{children:x==="plan"?"That organization needs an active Team plan":x==="no_access"?"You do not have access to that organization":"Teams could not be loaded"}),e.jsx(G,{children:x==="plan"?`Reading an organization's teams is part of the Team plan. An owner of ${t??"this organization"} can activate it in the Radient console, and then its teams will be listed here.`:x==="no_access"?`You are not a member of ${t??"that organization"}, so its teams are not listed here. An owner can invite you again.`:be("The teams shared with this organization could not be read.",h)}),x!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void y(),disabled:o,"aria-busy":o,children:o?"Trying…":"Try again"})})]}),!r&&!c&&n.length===0&&e.jsx("p",{className:"px-4 pb-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:"No teams have been shared with this organization yet."}),!r&&!c&&n.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline border-t border-hairline",children:n.map(l=>e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:l.name}),e.jsxs("span",{className:"truncate text-meta text-ink-muted",children:[l.project||"No project",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),Pa(l),l.version?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"v",l.version]}):null]}),p===l.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:_?.body??d.error?.message??`"${l.name}" could not be pulled.`}),_?.actions.filter(v=>Aa.includes(v)).map(v=>e.jsx(N,{variant:"primary",size:"sm",onClick:()=>P(v,l),children:ia[v]},v)),k&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(aa,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{u(!1),b(null),y()}})})]})]}),e.jsx(N,{variant:"secondary",size:"sm",onClick:()=>R(l),disabled:d.isPending,"aria-label":`Pull team ${l.name}`,children:f===l.id?"Pulling…":"Pull"})]},l.id))})]})},Pa=a=>a.members.length===0?"No members":a.members.map(t=>t.count>1?`${t.role} ×${t.count}`:t.role).join(", "),Ra=(a,t)=>{const[n,r]=i.useState(a);return i.useEffect(()=>{const o=setTimeout(()=>r(a),t);return()=>clearTimeout(o)},[a,t]),n},B=[{value:"download_count:desc",label:"Most downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"Most liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"Most favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"Newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"Recently updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"Name (A to Z)",sort:"name",order:"asc"}],za=[{value:"name",label:"Name"},{value:"description",label:"Description"}],Oa=300,I="public",Ea=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(m,{className:"h-5.5 w-2/3"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(m,{className:"h-5.5 w-24"}),e.jsx(m,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(m,{className:"h-5.5 w-24"})})]}),e.jsx(m,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"ml-auto h-7 w-16"})]})]}),Ba=()=>{const a=pe(),{isAuthenticated:t}=ie(),[n,r]=i.useState(1),[o]=i.useState(12),[c,h]=i.useState(null),[y,x]=i.useState(""),[d,p]=i.useState("name"),[b,f]=i.useState(B[0].value),[j,k]=i.useState(I),[u,_]=i.useState([]),P=Ra(y,Oa),R=B.find(s=>s.value===b)??B[0],l=Qe(),v=sa(),M=Be(l.data,"radient_org"),$=t?Ge(M,v):null,{memberships:z}=la({enabled:Je(M)}),O=i.useMemo(()=>We(z),[z]),E=j===I||O.some(s=>s.tenant_id===j);i.useEffect(()=>{E||k(I)},[E]);const g=j===I?null:O.find(s=>s.tenant_id===j)??null,S=g?.tenant_id,D=g?.role==="owner"||g?.role==="admin",ye=i.useMemo(()=>new Map(z.map(s=>[s.tenant_id,s.tenant_name])),[z]),{data:U,agents:we,isLoading:ke,isFetching:C,error:T,refetch:le,pagination:A}=oa({page:n,perPage:o,categories:c?[c]:void 0,name:d==="name"&&P||void 0,description:d==="description"&&P||void 0,sort:R.sort,order:R.order,tenantId:S}),L=g?je(T):null,Y=we??[],oe=C&&U!==void 0,{statuses:ce,isKnown:Ce,isError:Se,isFetching:Z,refetch:Te}=pa({agentIds:S?[]:Y.map(s=>s.id)}),J=i.useRef(null),K=i.useRef(null),[de,Ae]=i.useState(0);i.useEffect(()=>{de!==0&&(J.current??K.current)?.focus()},[de]);const ue=i.useRef(null),X=i.useRef(!1),ee=i.useMemo(()=>[...new Set((U?.records??[]).flatMap(s=>s.categories??[]))],[U]);i.useEffect(()=>{_(s=>ee.every(ae=>s.includes(ae))?s:[...new Set([...s,...ee])])},[ee]);const V=c!==null||P!=="",_e=()=>{h(null),x(""),r(1),Ae(s=>s+1)},w=(ke||C)&&U===void 0,me=!w&&!V&&(T!==null||Y.length===0);i.useEffect(()=>{!X.current||w||(X.current=!1,T?ue.current?.focus():(J.current??K.current)?.focus())},[w,T]);const Pe=s=>{r(s)},Re=s=>{h(s),r(1)},ze=s=>{x(s),r(1)},Oe=s=>{p(s),r(1)};return e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(Ke,{title:"Agent hub",subtitle:"Discover and download community agents on Radient",icon:He}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-tour-tag":"agent-hub-sidebar-container",children:!me&&e.jsx(ka,{selectedCategory:c,onSelectCategory:Re,categories:u})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[$&&e.jsxs(H,{variant:"warning",className:"mb-3 max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(W,{children:"Organizations are unavailable"}),e.jsx(G,{children:$})]}),O.length>0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:"agent-hub-scope-label",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs(se,{value:j,onValueChange:s=>{k(s),r(1)},children:[e.jsx(te,{className:"w-56","aria-labelledby":"agent-hub-scope-label","data-testid":"agent-hub-scope",children:e.jsx(ne,{})}),e.jsxs(re,{children:[e.jsx(Q,{value:I,children:"Public hub"}),O.map(s=>e.jsx(Q,{value:s.tenant_id,children:s.tenant_name||"Organization"},s.tenant_id))]})]})]}),!me&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:F("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(ea,{ref:J,type:"search",value:y,onChange:s=>ze(s.target.value),placeholder:"Search agents","aria-label":"Search agents",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(se,{value:d,onValueChange:Oe,children:[e.jsx(te,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":"Search in","data-testid":"agent-hub-search-scope",children:e.jsx(ne,{})}),e.jsx(re,{children:za.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs(se,{value:b,onValueChange:f,children:[e.jsx(te,{className:"w-48","aria-label":"Sort agents","data-testid":"agent-hub-sort",children:e.jsx(ne,{})}),e.jsx(re,{children:B.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("p",{"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[w?"Loading agents…":A?`${A.totalRecords} ${A.totalRecords===1?"agent":"agents"}`:"",oe?e.jsx(e.Fragment,{children:" Updating…"}):null]}),t&&Se&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so no card shows a viewer state."}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>void Te(),disabled:Z,"aria-busy":Z,children:Z?"Trying…":"Try again"})]}),w&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(s,ae)=>e.jsx(Ea,{},ae))}),w&&A===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(m,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:F(!w&&T&&!L?"block":"sr-only"),children:!w&&T&&!L&&e.jsxs(H,{variant:"danger",className:"max-w-2xl","aria-busy":C,"data-testid":"agent-hub-error",children:[e.jsx(W,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(G,{children:t?be("The agent list could not be loaded.",T):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(N,{ref:ue,variant:"outline",size:"sm",onClick:()=>{X.current=!0,le()},disabled:C,"aria-busy":C,children:C?"Trying…":"Try again"})})]})}),!w&&L&&g&&e.jsxs(H,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(W,{children:L==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(G,{children:L==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${g.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${g.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),L==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void le(),disabled:C,"aria-busy":C,children:C?"Trying…":"Try again"})})]}),!w&&!T&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":oe,children:Y.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:"col-span-full w-full max-w-2xl justify-self-center flex flex-col items-center gap-2 rounded-lg border border-hairline bg-surface px-6 py-10 text-center",children:[e.jsx("p",{className:"text-heading text-ink",children:S?"This organization has no shared agents yet.":c?`No agents in ${ve(c).label}.`:V?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:S?`Agents published into ${g?.tenant_name||"this organization"} appear here for its members.`:c?"Nothing in this category yet. Clear the filter to see the whole hub.":V?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:V?e.jsx(N,{variant:"secondary",onClick:_e,children:c?"Clear filter":"Clear search"}):S&&!D?null:e.jsx(N,{ref:K,variant:"secondary",onClick:()=>a("/agents"),children:"Publish an agent"})})]}):Y.map(s=>e.jsx(ya,{agent:s,status:t?ce[s.id]:void 0,viewerStateKnown:t&&ba(Ce,ce,s.id),orgName:s.visibility==="org"?ye.get(s.tenant_id)??null:null},s.id))}),!w&&A&&A.totalPages>1&&e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx(Ze,{count:A.totalPages,page:A.page,onChange:Pe})}),g&&e.jsx(_a,{tenantId:g.tenant_id,orgName:g.tenant_name||null})]})]})]})};export{Ba as AgentHubPage};
|
|
6
|
+
*/const ja=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],va=Xe("circle-ellipsis",ja),Na=({agent:a,isLiked:t,isFavourited:n,onLikeToggle:r,onFavouriteToggle:o,onDownload:c,isLikeActionLoading:h=!1,isFavouriteActionLoading:y=!1,isDownloading:x=!1,actionError:d=null,onRetryAction:p,showActions:b=!0,viewerStateKnown:f=!0,orgName:j=null})=>{const k=pe(),{isAuthenticated:u}=ie(),_=a.description??"",[P,R]=i.useState(!1),l=i.useRef(null),v=i.useCallback(g=>{if(l.current?.disconnect(),l.current=null,!g)return;const C=()=>R(g.scrollHeight-g.clientHeight>1);C();const D=new ResizeObserver(C);D.observe(g),l.current=D},[]),M=u?f?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",$=u?f?n?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",z=f?t?"Unlike agent":"Like agent":"Like state unavailable",O=f?n?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",E=a.visibility==="org";return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface transition-colors duration-fast ease-out-quart hover:border-control",children:[e.jsxs("button",{type:"button",onClick:()=>k(`/agent-hub/${a.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${a.name}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:a.name}),E&&e.jsx(ca,{orgName:j}),e.jsx(q,{content:P?_:"",children:e.jsx("span",{ref:v,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:_})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(da,{tags:a.tags,categories:a.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[a.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",ua(new Date(a.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":E?"org":u?f?"known":"unknown":"signed-out",children:[!E&&e.jsxs(e.Fragment,{children:[e.jsx(q,{content:M,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u&&f?()=>r(a.id):void 0,disabled:h||!u||!f,"aria-label":z,className:I(t&&"text-danger"),children:[e.jsx(ma,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.like_count??0})]})})}),e.jsx(q,{content:$,children:e.jsx("span",{children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:u?()=>o(a.id):void 0,disabled:y||!u||!f,"aria-label":O,className:I(n&&"text-warning"),children:[e.jsx(Ee,{fill:n?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:a.favourite_count??0})]})})})]}),e.jsx(q,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(he,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:x?e.jsx(m,{className:"h-3 w-6"}):(a.download_count??0).toLocaleString()})]})})]}),b&&c&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>c(a),disabled:x,"aria-label":`Download ${a.name}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(he,{"data-testid":"agent-download"}),"Get"]})})]}),d&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:d}),p&&e.jsx(N,{variant:"ghost",size:"sm",onClick:p,children:"Try again"})]})]})},ya=({agent:a,status:t,viewerStateKnown:n=!0,orgName:r=null})=>{const{isAuthenticated:o}=ie(),[c,h]=i.useState(null),y=t?.liked??!1,x=t?.favourited??!1,d=ha(),p=ga(),b=xa(),f=()=>{!o||d.isPending||(h(null),d.mutate({agentId:a.id,isCurrentlyLiked:y},{onError:()=>h("like")}))},j=()=>{!o||p.isPending||(h(null),p.mutate({agentId:a.id,isCurrentlyFavourited:x},{onError:()=>h("favourite")}))},k=()=>{b.isPending||(h(null),b.mutate({agentId:a.id,agentName:a.name},{onError:()=>h("download")}))},u=c?c==="like"?{action:"like",error:d.error,retry:f}:c==="favourite"?{action:"favourite",error:p.error,retry:j}:{action:"download",error:b.error,retry:k}:null;return e.jsx(Na,{agent:a,isLiked:o&&y,isFavourited:o&&x,onLikeToggle:f,onFavouriteToggle:j,onDownload:k,isLikeActionLoading:d.isPending,isFavouriteActionLoading:p.isPending,isDownloading:b.isPending,viewerStateKnown:n,orgName:r,actionError:u?ta(u.action,u.error,a.name):null,onRetryAction:u?.retry})},xe=({selected:a,onClick:t,children:n,...r})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":a,className:I("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",a?Ie:"text-ink hover:bg-row-hover"),...r,children:n}),fe=Object.keys(fa),wa=a=>[...a].sort((t,n)=>{const r=fe.indexOf(t),o=fe.indexOf(n);return r!==-1&&o!==-1?r-o:r!==-1?-1:o!==-1?1:t.localeCompare(n)}),ka=({selectedCategory:a,onSelectCategory:t,categories:n})=>{const r=wa(a&&!n.includes(a)?[...n,a]:n);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:"Categories"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(xe,{selected:a===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Le,{size:16,"aria-hidden":"true"})}),"All categories"]}),r.map(o=>{const c=ve(o),h=o==="other"?e.jsx(va,{size:16}):c.icon;return e.jsxs(xe,{selected:a===o,onClick:()=>t(o),"data-testid":`category-${o}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:h}),c.label]},o)})]})]})},Ne={all:["org-teams"],list:a=>[...Ne.all,"list",a]},Ca=({tenantId:a,enabled:t=!0})=>{const n=Fe({queryKey:Ne.list(a??""),queryFn:async()=>(await na(a)).result??{teams:[]},enabled:t&&!!a,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retry:Me});return{...n,teams:n.data?.teams??[]}},Sa=(a,t)=>{const n=a?.name?.trim()||t?.trim()||"Team",r=a?.renamed_from?.trim()||null;return a?.invalid_name===!0&&r?{level:"warning",message:`Pulled "${n}". The published name "${r}" is not usable locally, so the team was stored as "${n}".`}:r?{level:"success",message:`Pulled "${n}" (you already have a team called "${r}").`}:{level:"success",message:`Pulled team "${n}".`}},Ta=()=>{const a=$e();return De({mutationFn:async({teamId:t,tenantId:n})=>{if(!ge.baseUrl)throw new Error("Local Operator API URL is not configured.");return Ve.pullOrgTeamFromRadient(ge.baseUrl,t,n)},onSuccess:(t,n)=>{const r=Sa(t.result,n.name);r.level==="warning"?Ue(r.message):Ye(r.message),a.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Aa=["refresh-hub","retry","sign-in"],_a=({tenantId:a,orgName:t})=>{const{teams:n,isLoading:r,isFetching:o,isError:c,error:h,refetch:y}=Ca({tenantId:a}),x=je(h),d=Ta(),[p,b]=i.useState(null),[f,j]=i.useState(null),[k,u]=i.useState(!1),_=i.useMemo(()=>{if(!qe(d.error))return null;const l=n.find(v=>v.id===p);return ra({code:d.error.code,message:d.error.message,details:d.error.details},{name:l?.name??"this team",hubAgentId:null,surface:"pull"})},[d.error,p,n]),P=(l,v)=>{switch(l){case"refresh-hub":y();break;case"retry":R(v);break;case"sign-in":u(!0);break}},R=l=>{d.isPending||(b(null),j(l.id),d.mutate({teamId:l.id,tenantId:a,name:l.name},{onSettled:()=>j(null),onError:()=>b(l.id)}))};return e.jsxs("section",{className:"mb-6 rounded-lg border border-hairline bg-surface","aria-labelledby":"org-teams-heading","data-testid":"org-teams",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2 px-4 pt-3 pb-2",children:[e.jsx("h2",{id:"org-teams-heading",className:"font-medium text-heading text-ink",children:"Teams"}),!r&&!c&&e.jsxs("p",{className:"text-meta text-ink-dim","data-testid":"org-teams-count",children:[n.length," ",n.length===1?"team":"teams"," shared with"," ",t??"this organization"]})]}),r&&e.jsxs("div",{className:"flex flex-col gap-2 px-4 pb-4","data-testid":"org-teams-loading",children:[e.jsx("span",{className:"sr-only",children:"Loading teams…"}),e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col gap-2",children:[e.jsx(m,{className:"h-4.5 w-40"}),e.jsx(m,{className:"h-3.5 w-64"})]})]}),!r&&c&&e.jsxs(H,{variant:x?"warning":"danger",className:"mx-4 mb-4","data-testid":"org-teams-error",children:[e.jsx(W,{children:x==="plan"?"That organization needs an active Team plan":x==="no_access"?"You do not have access to that organization":"Teams could not be loaded"}),e.jsx(G,{children:x==="plan"?`Reading an organization's teams is part of the Team plan. An owner of ${t??"this organization"} can activate it in the Radient console, and then its teams will be listed here.`:x==="no_access"?`You are not a member of ${t??"that organization"}, so its teams are not listed here. An owner can invite you again.`:be("The teams shared with this organization could not be read.",h)}),x!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void y(),disabled:o,"aria-busy":o,children:o?"Trying…":"Try again"})})]}),!r&&!c&&n.length===0&&e.jsx("p",{className:"px-4 pb-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:"No teams have been shared with this organization yet."}),!r&&!c&&n.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline border-t border-hairline",children:n.map(l=>e.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:l.name}),e.jsxs("span",{className:"truncate text-meta text-ink-muted",children:[l.project||"No project",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),Pa(l),l.version?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"v",l.version]}):null]}),p===l.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:_?.body??d.error?.message??`"${l.name}" could not be pulled.`}),_?.actions.filter(v=>Aa.includes(v)).map(v=>e.jsx(N,{variant:"primary",size:"sm",onClick:()=>P(v,l),children:ia[v]},v)),k&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(aa,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{u(!1),b(null),y()}})})]})]}),e.jsx(N,{variant:"secondary",size:"sm",onClick:()=>R(l),disabled:d.isPending,"aria-label":`Pull team ${l.name}`,children:f===l.id?"Pulling…":"Pull"})]},l.id))})]})},Pa=a=>a.members.length===0?"No members":a.members.map(t=>t.count>1?`${t.role} ×${t.count}`:t.role).join(", "),Ra=(a,t)=>{const[n,r]=i.useState(a);return i.useEffect(()=>{const o=setTimeout(()=>r(a),t);return()=>clearTimeout(o)},[a,t]),n},B=[{value:"download_count:desc",label:"Most downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"Most liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"Most favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"Newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"Recently updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"Name (A to Z)",sort:"name",order:"asc"}],za=[{value:"name",label:"Name"},{value:"description",label:"Description"}],Oa=300,F="public",Ea=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border border-hairline bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(m,{className:"h-5.5 w-2/3"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-full"}),e.jsx(m,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(m,{className:"h-5.5 w-24"}),e.jsx(m,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(m,{className:"h-5.5 w-24"})})]}),e.jsx(m,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"size-4"}),e.jsx(m,{className:"h-4 w-6"}),e.jsx(m,{className:"ml-auto h-7 w-16"})]})]}),Ba=()=>{const a=pe(),{isAuthenticated:t}=ie(),[n,r]=i.useState(1),[o]=i.useState(12),[c,h]=i.useState(null),[y,x]=i.useState(""),[d,p]=i.useState("name"),[b,f]=i.useState(B[0].value),[j,k]=i.useState(F),[u,_]=i.useState([]),P=Ra(y,Oa),R=B.find(s=>s.value===b)??B[0],l=Qe(),v=sa(),M=Be(l.data,"radient_org"),$=t?Ge(M,v):null,{memberships:z}=la({enabled:Je(M)}),O=i.useMemo(()=>We(z),[z]),E=j===F||O.some(s=>s.tenant_id===j);i.useEffect(()=>{E||k(F)},[E]);const g=j===F?null:O.find(s=>s.tenant_id===j)??null,C=g?.tenant_id,D=g?.role==="owner"||g?.role==="admin",ye=i.useMemo(()=>new Map(z.map(s=>[s.tenant_id,s.tenant_name])),[z]),{data:U,agents:we,isLoading:ke,isFetching:S,error:T,refetch:le,pagination:A}=oa({page:n,perPage:o,categories:c?[c]:void 0,name:d==="name"&&P||void 0,description:d==="description"&&P||void 0,sort:R.sort,order:R.order,tenantId:C}),L=g?je(T):null,Y=we??[],oe=S&&U!==void 0,{statuses:ce,isKnown:Ce,isError:Se,isFetching:Z,refetch:Te}=pa({agentIds:C?[]:Y.map(s=>s.id)}),J=i.useRef(null),K=i.useRef(null),[de,Ae]=i.useState(0);i.useEffect(()=>{de!==0&&(J.current??K.current)?.focus()},[de]);const ue=i.useRef(null),X=i.useRef(!1),ee=i.useMemo(()=>[...new Set((U?.records??[]).flatMap(s=>s.categories??[]))],[U]);i.useEffect(()=>{_(s=>ee.every(ae=>s.includes(ae))?s:[...new Set([...s,...ee])])},[ee]);const V=c!==null||P!=="",_e=()=>{h(null),x(""),r(1),Ae(s=>s+1)},w=(ke||S)&&U===void 0,me=!w&&!V&&(T!==null||Y.length===0);i.useEffect(()=>{!X.current||w||(X.current=!1,T?ue.current?.focus():(J.current??K.current)?.focus())},[w,T]);const Pe=s=>{r(s)},Re=s=>{h(s),r(1)},ze=s=>{x(s),r(1)},Oe=s=>{p(s),r(1)};return e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(Ke,{title:"Agent hub",subtitle:"Discover and download community agents on Radient",icon:He}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-tour-tag":"agent-hub-sidebar-container",children:!me&&e.jsx(ka,{selectedCategory:c,onSelectCategory:Re,categories:u})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[$&&e.jsxs(H,{variant:"warning",className:"mb-3 max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(W,{children:"Organizations are unavailable"}),e.jsx(G,{children:$})]}),O.length>0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{id:"agent-hub-scope-label",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs(se,{value:j,onValueChange:s=>{k(s),r(1)},children:[e.jsx(te,{className:"w-56","aria-labelledby":"agent-hub-scope-label","data-testid":"agent-hub-scope",children:e.jsx(ne,{})}),e.jsxs(re,{children:[e.jsx(Q,{value:F,children:"Public hub"}),O.map(s=>e.jsx(Q,{value:s.tenant_id,children:s.tenant_name||"Organization"},s.tenant_id))]})]})]}),!me&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:I("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(ea,{ref:J,type:"search",value:y,onChange:s=>ze(s.target.value),placeholder:"Search agents","aria-label":"Search agents",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(se,{value:d,onValueChange:Oe,children:[e.jsx(te,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":"Search in","data-testid":"agent-hub-search-scope",children:e.jsx(ne,{})}),e.jsx(re,{children:za.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs(se,{value:b,onValueChange:f,children:[e.jsx(te,{className:"w-48","aria-label":"Sort agents","data-testid":"agent-hub-sort",children:e.jsx(ne,{})}),e.jsx(re,{children:B.map(s=>e.jsx(Q,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("p",{"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[w?"Loading agents…":A?`${A.totalRecords} ${A.totalRecords===1?"agent":"agents"}`:"",oe?e.jsx(e.Fragment,{children:" Updating…"}):null]}),t&&Se&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so no card shows a viewer state."}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>void Te(),disabled:Z,"aria-busy":Z,children:Z?"Trying…":"Try again"})]}),w&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(s,ae)=>e.jsx(Ea,{},ae))}),w&&A===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(m,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:I(!w&&T&&!L?"block":"sr-only"),children:!w&&T&&!L&&e.jsxs(H,{variant:"danger",className:"max-w-2xl","aria-busy":S,"data-testid":"agent-hub-error",children:[e.jsx(W,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(G,{children:t?be("The agent list could not be loaded.",T):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(N,{ref:ue,variant:"outline",size:"sm",onClick:()=>{X.current=!0,le()},disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})})]})}),!w&&L&&g&&e.jsxs(H,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(W,{children:L==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(G,{children:L==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${g.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${g.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),L==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(N,{variant:"primary",size:"sm",onClick:()=>void le(),disabled:S,"aria-busy":S,children:S?"Trying…":"Try again"})})]}),!w&&!T&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":oe,children:Y.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:I("col-span-full w-full flex flex-col items-center gap-2 rounded-lg border border-hairline bg-surface px-6 py-10 text-center",!C&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:C?"This organization has no shared agents yet.":c?`No agents in ${ve(c).label}.`:V?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:C?`Agents published into ${g?.tenant_name||"this organization"} appear here for its members.`:c?"Nothing in this category yet. Clear the filter to see the whole hub.":V?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:V?e.jsx(N,{variant:"secondary",onClick:_e,children:c?"Clear filter":"Clear search"}):C&&!D?null:e.jsx(N,{ref:K,variant:"secondary",onClick:()=>a("/agents"),children:"Publish an agent"})})]}):Y.map(s=>e.jsx(ya,{agent:s,status:t?ce[s.id]:void 0,viewerStateKnown:t&&ba(Ce,ce,s.id),orgName:s.visibility==="org"?ye.get(s.tenant_id)??null:null},s.id))}),!w&&A&&A.totalPages>1&&e.jsx("div",{className:"mt-6 flex justify-center",children:e.jsx(Ze,{count:A.totalPages,page:A.page,onChange:Pe})}),g&&e.jsx(_a,{tenantId:g.tenant_id,orgName:g.tenant_name||null})]})]})]})};export{Ba as AgentHubPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-
|
|
2
|
-
import{u as O,a as Q,b as J,c as V,d as W,e as G,f as H,g as X,h as Y,B as Z,U as ee,P as te,r as ae,_ as se,i as $,j as z,k as L}from"./index-tykR0DI9.js";import{j as e,r as n,c as w}from"./index-C-P4UaBn.js";import{B as h}from"./error-boundary-Be38BRVp.js";import"./console-mirror-DjoNpI7u.js";const ne=n.lazy(()=>se(()=>import("./legacy-agents-page-TbzorhDj.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),m="w-full rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink";function T({profile:t,creating:E,onSaved:b}){const[j,r]=n.useState(!1),[v,c]=n.useState(E),[p,x]=n.useState(t?.name??""),[g,y]=n.useState(t?.kind??"role"),[P,d]=n.useState(t?.description??""),[N,u]=n.useState(t?.instructions??""),[_,D]=n.useState(t?.tools?.join(", ")??""),[I,k]=n.useState(t?.effort??"inherit"),[U,R]=n.useState(t?.delegate??!1),[f,a]=n.useState(!1),[o,l]=n.useState(null),i=n.useRef(null),C=$(),S=E||j,K=async s=>{if(s.preventDefault(),f)return;const M={kind:g,description:P,instructions:N,tools:_.split(",").map(q=>q.trim()).filter(Boolean),effort:I,delegate:U},A=JSON.stringify({name:p,fields:M,fresh:S});if(i.current&&i.current.body!==A){l("The previous save has not been confirmed. Retry it unchanged or reload the profile to reconcile before editing again.");return}i.current??={id:crypto.randomUUID(),body:A},a(!0),l(null);try{const q=await L({op:S?"profiles.create":"profiles.update",requestId:i.current.id,name:p,fields:M});i.current=null,c(!1),b(q.name)}catch(q){l(q instanceof Error?q.message:"Profile could not be saved.")}finally{a(!1)}},F=async()=>{if(!(!t||f)){a(!0),l(null);try{const s=await L({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()});c(!1),r(!1),i.current=null,x(s.name),y(s.kind),d(s.description??""),u(s.instructions??""),D(s.tools?.join(", ")??""),k(s.effort??"inherit"),R(s.delegate??!1),b(s.name)}catch(s){l(s instanceof Error?s.message:"Profile could not be installed.")}finally{a(!1)}}};return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:S?j?"Extend agent":"Create agent":t?.name}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Reusable instructions shared by agent commands, subagents and teams. Chats remain separate."})]}),t&&!S&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-meta text-ink-muted",children:[t.source==="builtin"?"Built-in":t.source==="installed"?"Installed":"Custom",t.divergent_fields?.length?" · Modified":""," ·"," ",t.kind]}),t.source==="builtin"?e.jsx(h,{variant:"outline",onClick:F,disabled:f,children:"Install"}):e.jsx(h,{variant:"outline",onClick:()=>c(!0),children:"Edit"}),e.jsx(h,{variant:"outline",onClick:()=>{r(!0),c(!0),x(""),i.current=null},children:"Extend"}),e.jsx(h,{onClick:()=>{z.getState().stageDraft({kind:"agent",name:t.name}),C("/chat")},children:"New chat"})]}),o&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:o}),!v&&t?.source==="builtin"&&e.jsx("p",{id:"builtin-readonly",className:"text-body-sm text-ink-muted",children:"Built-in agents are read-only. Install this one to edit it, or Extend it to start a separate agent from its instructions."}),e.jsxs("form",{onSubmit:K,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:!v||f,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:m,value:p,disabled:!S,required:!0,"aria-describedby":t?.source==="builtin"?"builtin-readonly":void 0,onChange:s=>x(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Kind"}),e.jsxs("select",{className:m,value:g,disabled:!S,onChange:s=>y(s.target.value),children:[e.jsx("option",{value:"role",children:"Role"}),e.jsx("option",{value:"specialist",children:"Specialist"})]})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"When to use this agent"}),e.jsx("input",{className:m,value:P,maxLength:8e3,onChange:s=>d(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Instructions"}),e.jsx("textarea",{className:w(m,"min-h-52"),value:N,required:!0,maxLength:8e3,onChange:s=>u(s.target.value)})]}),g==="role"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Allowed tools"}),e.jsx("input",{className:m,value:_,onChange:s=>D(s.target.value),placeholder:"All tools when empty; otherwise comma-separated names"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Effort tier"}),e.jsx("input",{className:m,value:I,onChange:s=>k(s.target.value),"aria-describedby":"effort-help"}),e.jsx("span",{id:"effort-help",className:"text-meta text-ink-muted",children:"Use inherit, or a tier configured in backend settings. Unsupported tiers are rejected before saving."})]}),e.jsxs("label",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>R(s.target.checked)}),"May delegate to subagents"]})]})]}),v&&e.jsx(h,{type:"submit",disabled:f,children:f?"Saving…":S?"Create agent":"Save changes"})]}),!v&&t?.packaged_instructions&&t.divergent_fields?.length?e.jsxs("details",{className:"text-body-sm",children:[e.jsx("summary",{children:"Compare packaged instructions"}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-body-sm text-ink-muted",children:t.packaged_instructions})]}):null]})}function B({team:t,onSaved:E}){const[b,j]=n.useState(t?.name??""),[r,v]=n.useState(t?.description??""),[c,p]=n.useState(t?.manager??"manager"),[x,g]=n.useState((t?.members??[]).map(a=>({...a,key:crypto.randomUUID()}))),[y,P]=n.useState(t?.instructions??""),[d,N]=n.useState(t?.project??""),[u,_]=n.useState(!1),[D,I]=n.useState(null),k=n.useRef(null),U=$(),R=async a=>{if(a.preventDefault(),u)return;const o={name:b,description:r,manager:c,members:x.map(({key:i,...C})=>C),instructions:y,project:d},l=JSON.stringify(o);if(k.current&&k.current.body!==l){I("The previous save has not been confirmed. Reload the team before changing that request.");return}k.current??={id:crypto.randomUUID(),body:l},_(!0),I(null);try{const i=t?await L({op:"teams.update",name:t.name,requestId:k.current.id,fields:o}):await L({op:"teams.create",requestId:k.current.id,fields:o});k.current=null,E(i.name)}catch(i){I(i instanceof Error?i.message:"Team could not be saved.")}finally{_(!1)}},f=(a,o)=>g(l=>l.map((i,C)=>C===a?{...i,...o}:i));return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:t?t.name:"Create team"}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"The manager leads the chat. Members retain their own instructions and start only when delegated work."})]}),t&&e.jsx(h,{onClick:()=>{z.getState().stageDraft({kind:"team",name:t.name}),U("/chat")},children:"New team chat"}),D&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:D}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:u,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:m,required:!0,maxLength:64,value:b,onChange:a=>j(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Description"}),e.jsx("input",{className:m,value:r,onChange:a=>v(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Manager agent"}),e.jsx("input",{className:m,required:!0,value:c,onChange:a=>p(a.target.value)})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-heading",children:"Members"}),x.map((a,o)=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:w(m,"w-48 flex-1"),"aria-label":`Member ${o+1} name`,required:!0,value:a.role,onChange:l=>f(o,{role:l.target.value})}),e.jsxs("select",{className:w(m,"w-32"),"aria-label":`Member ${o+1} kind`,value:a.kind,onChange:l=>f(o,{kind:l.target.value}),children:[e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"team",children:"Nested team"})]}),e.jsx("input",{className:w(m,"w-20"),"aria-label":`Member ${o+1} count`,type:"number",min:1,max:16,value:a.count,onChange:l=>f(o,{count:Number(l.target.value)})}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>g(l=>l.filter((i,C)=>C!==o)),children:"Remove"})]},a.key)),e.jsx(h,{type:"button",variant:"outline",onClick:()=>g(a=>[...a,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]),children:"Add member"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Collaboration instructions"}),e.jsx("textarea",{className:w(m,"min-h-36"),maxLength:8e3,value:y,onChange:a=>P(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Project brief"}),e.jsx("textarea",{className:w(m,"min-h-36"),maxLength:8e3,value:d,onChange:a=>N(a.target.value)})]})]}),e.jsx(h,{type:"submit",disabled:u,children:u?"Saving…":t?"Save team":"Create team"})]})]})}function oe(){const t=O(),{agentId:E}=Q(),[b,j]=J(),r=b.get("kind")==="team"||b.get("create")==="team",v=b.has("create"),c=b.get("name"),p=V(),x=W(p.data,r?"team_catalogue":"profile_catalogue"),g=G(x&&!r),y=H(x&&r),P=X(),d=Y({queryKey:["desktop",r?"team":"profile",c],enabled:x&&!!c&&!v,queryFn:()=>L({op:r?"teams.get":"profiles.get",name:c??""}),retry:!1}),N=async u=>{await P.invalidateQueries({queryKey:["desktop"]}),j({kind:r?"team":"agent",name:u})};return E?e.jsx(n.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(ne,{})}):e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{ref:t,className:"flex w-64 shrink-0 flex-col gap-4 border-r border-hairline bg-surface p-4",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:r?"ghost":"outline",onClick:()=>j({kind:"agent"}),children:[e.jsx(Z,{className:"size-4"}),"Agents"]}),e.jsxs(h,{variant:r?"outline":"ghost",onClick:()=>j({kind:"team"}),children:[e.jsx(ee,{className:"size-4"}),"Teams"]})]}),e.jsxs(h,{variant:"outline",disabled:!x,onClick:()=>j({create:r?"team":"agent"}),children:[e.jsx(te,{className:"size-4"}),r?"Create team":"Create agent"]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(r?y.data:g.data)?.map(u=>e.jsx("button",{type:"button",className:w("flex h-8 w-full items-center rounded-md px-2 text-left text-body-sm hover:bg-row-hover",u.name===c&&ae),onClick:()=>j({kind:r?"team":"agent",name:u.name}),children:e.jsx("span",{className:"truncate",children:u.name})},u.name))})]}),e.jsx("main",{className:"min-w-0 flex-1 overflow-auto p-6",children:x?g.error||y.error||d.error?e.jsxs("div",{role:"alert",children:[e.jsx("p",{className:"text-danger",children:g.error?.message||y.error?.message||d.error?.message}),e.jsx(h,{variant:"outline",onClick:()=>{g.refetch(),y.refetch(),d.refetch()},children:"Retry"})]}):v?r?e.jsx(B,{onSaved:N},"create-team"):e.jsx(T,{creating:!0,onSaved:N},"create-agent"):c&&d.isLoading?e.jsx("p",{"aria-live":"polite",children:"Loading details…"}):c&&d.data?r?e.jsx(B,{team:d.data,onSaved:N},c):e.jsx(T,{profile:d.data,creating:!1,onSaved:N},`${c}:${d.data.source}`):e.jsxs("div",{children:[e.jsx("h2",{className:"text-title",children:r?"Reusable teams":"Reusable agents"}),e.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Select a definition to view or edit it. A new chat does not change its definition."})]}):e.jsxs("div",{"aria-live":"polite",className:"space-y-3 text-body-sm",children:[e.jsx("p",{children:p.isLoading?"Connecting to the backend…":p.error?p.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."}),e.jsx(h,{variant:"outline",onClick:()=>void p.refetch(),children:"Retry connection"})]})})]})}export{oe as AgentsPage};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-D3XdLDk2.js","./index-C-P4UaBn.js","./index-BjeBA__i.css","./index-BoBj0LUC.js","./error-boundary-Be38BRVp.js","./console-mirror-DjoNpI7u.js","./console-mirror-DOrYoP_4.css","./index-CSPo12AE.css","./page-header-BXIWLsA1.js","./settings-section-BeU3N8-t.js","./org-surface-gate-CyrcQL7E.js","./use-memberships-query-DJonF1zy.js","./radient-auth-buttons-fe1Bn89n.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as O,a as Q,b as J,c as V,d as W,e as G,f as H,g as X,h as Y,B as Z,U as ee,P as te,r as ae,_ as se,i as $,j as z,k as L}from"./index-BoBj0LUC.js";import{j as e,r as n,c as w}from"./index-C-P4UaBn.js";import{B as h}from"./error-boundary-Be38BRVp.js";import"./console-mirror-DjoNpI7u.js";const ne=n.lazy(()=>se(()=>import("./legacy-agents-page-D3XdLDk2.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),m="w-full rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink";function T({profile:t,creating:E,onSaved:b}){const[j,r]=n.useState(!1),[v,c]=n.useState(E),[p,x]=n.useState(t?.name??""),[g,y]=n.useState(t?.kind??"role"),[P,d]=n.useState(t?.description??""),[N,u]=n.useState(t?.instructions??""),[_,D]=n.useState(t?.tools?.join(", ")??""),[I,k]=n.useState(t?.effort??"inherit"),[U,R]=n.useState(t?.delegate??!1),[f,a]=n.useState(!1),[o,l]=n.useState(null),i=n.useRef(null),C=$(),S=E||j,K=async s=>{if(s.preventDefault(),f)return;const M={kind:g,description:P,instructions:N,tools:_.split(",").map(q=>q.trim()).filter(Boolean),effort:I,delegate:U},A=JSON.stringify({name:p,fields:M,fresh:S});if(i.current&&i.current.body!==A){l("The previous save has not been confirmed. Retry it unchanged or reload the profile to reconcile before editing again.");return}i.current??={id:crypto.randomUUID(),body:A},a(!0),l(null);try{const q=await L({op:S?"profiles.create":"profiles.update",requestId:i.current.id,name:p,fields:M});i.current=null,c(!1),b(q.name)}catch(q){l(q instanceof Error?q.message:"Profile could not be saved.")}finally{a(!1)}},F=async()=>{if(!(!t||f)){a(!0),l(null);try{const s=await L({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()});c(!1),r(!1),i.current=null,x(s.name),y(s.kind),d(s.description??""),u(s.instructions??""),D(s.tools?.join(", ")??""),k(s.effort??"inherit"),R(s.delegate??!1),b(s.name)}catch(s){l(s instanceof Error?s.message:"Profile could not be installed.")}finally{a(!1)}}};return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:S?j?"Extend agent":"Create agent":t?.name}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Reusable instructions shared by agent commands, subagents and teams. Chats remain separate."})]}),t&&!S&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-meta text-ink-muted",children:[t.source==="builtin"?"Built-in":t.source==="installed"?"Installed":"Custom",t.divergent_fields?.length?" · Modified":""," ·"," ",t.kind]}),t.source==="builtin"?e.jsx(h,{variant:"outline",onClick:F,disabled:f,children:"Install"}):e.jsx(h,{variant:"outline",onClick:()=>c(!0),children:"Edit"}),e.jsx(h,{variant:"outline",onClick:()=>{r(!0),c(!0),x(""),i.current=null},children:"Extend"}),e.jsx(h,{onClick:()=>{z.getState().stageDraft({kind:"agent",name:t.name}),C("/chat")},children:"New chat"})]}),o&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:o}),!v&&t?.source==="builtin"&&e.jsx("p",{id:"builtin-readonly",className:"text-body-sm text-ink-muted",children:"Built-in agents are read-only. Install this one to edit it, or Extend it to start a separate agent from its instructions."}),e.jsxs("form",{onSubmit:K,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:!v||f,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:m,value:p,disabled:!S,required:!0,"aria-describedby":t?.source==="builtin"?"builtin-readonly":void 0,onChange:s=>x(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Kind"}),e.jsxs("select",{className:m,value:g,disabled:!S,onChange:s=>y(s.target.value),children:[e.jsx("option",{value:"role",children:"Role"}),e.jsx("option",{value:"specialist",children:"Specialist"})]})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"When to use this agent"}),e.jsx("input",{className:m,value:P,maxLength:8e3,onChange:s=>d(s.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Instructions"}),e.jsx("textarea",{className:w(m,"min-h-52"),value:N,required:!0,maxLength:8e3,onChange:s=>u(s.target.value)})]}),g==="role"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Allowed tools"}),e.jsx("input",{className:m,value:_,onChange:s=>D(s.target.value),placeholder:"All tools when empty; otherwise comma-separated names"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Effort tier"}),e.jsx("input",{className:m,value:I,onChange:s=>k(s.target.value),"aria-describedby":"effort-help"}),e.jsx("span",{id:"effort-help",className:"text-meta text-ink-muted",children:"Use inherit, or a tier configured in backend settings. Unsupported tiers are rejected before saving."})]}),e.jsxs("label",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>R(s.target.checked)}),"May delegate to subagents"]})]})]}),v&&e.jsx(h,{type:"submit",disabled:f,children:f?"Saving…":S?"Create agent":"Save changes"})]}),!v&&t?.packaged_instructions&&t.divergent_fields?.length?e.jsxs("details",{className:"text-body-sm",children:[e.jsx("summary",{children:"Compare packaged instructions"}),e.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-body-sm text-ink-muted",children:t.packaged_instructions})]}):null]})}function B({team:t,onSaved:E}){const[b,j]=n.useState(t?.name??""),[r,v]=n.useState(t?.description??""),[c,p]=n.useState(t?.manager??"manager"),[x,g]=n.useState((t?.members??[]).map(a=>({...a,key:crypto.randomUUID()}))),[y,P]=n.useState(t?.instructions??""),[d,N]=n.useState(t?.project??""),[u,_]=n.useState(!1),[D,I]=n.useState(null),k=n.useRef(null),U=$(),R=async a=>{if(a.preventDefault(),u)return;const o={name:b,description:r,manager:c,members:x.map(({key:i,...C})=>C),instructions:y,project:d},l=JSON.stringify(o);if(k.current&&k.current.body!==l){I("The previous save has not been confirmed. Reload the team before changing that request.");return}k.current??={id:crypto.randomUUID(),body:l},_(!0),I(null);try{const i=t?await L({op:"teams.update",name:t.name,requestId:k.current.id,fields:o}):await L({op:"teams.create",requestId:k.current.id,fields:o});k.current=null,E(i.name)}catch(i){I(i instanceof Error?i.message:"Team could not be saved.")}finally{_(!1)}},f=(a,o)=>g(l=>l.map((i,C)=>C===a?{...i,...o}:i));return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{children:[e.jsx("h1",{className:"text-title",children:t?t.name:"Create team"}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"The manager leads the chat. Members retain their own instructions and start only when delegated work."})]}),t&&e.jsx(h,{onClick:()=>{z.getState().stageDraft({kind:"team",name:t.name}),U("/chat")},children:"New team chat"}),D&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:D}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("fieldset",{disabled:u,className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{className:m,required:!0,maxLength:64,value:b,onChange:a=>j(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Description"}),e.jsx("input",{className:m,value:r,onChange:a=>v(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Manager agent"}),e.jsx("input",{className:m,required:!0,value:c,onChange:a=>p(a.target.value)})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-heading",children:"Members"}),x.map((a,o)=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:w(m,"w-48 flex-1"),"aria-label":`Member ${o+1} name`,required:!0,value:a.role,onChange:l=>f(o,{role:l.target.value})}),e.jsxs("select",{className:w(m,"w-32"),"aria-label":`Member ${o+1} kind`,value:a.kind,onChange:l=>f(o,{kind:l.target.value}),children:[e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"team",children:"Nested team"})]}),e.jsx("input",{className:w(m,"w-20"),"aria-label":`Member ${o+1} count`,type:"number",min:1,max:16,value:a.count,onChange:l=>f(o,{count:Number(l.target.value)})}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>g(l=>l.filter((i,C)=>C!==o)),children:"Remove"})]},a.key)),e.jsx(h,{type:"button",variant:"outline",onClick:()=>g(a=>[...a,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]),children:"Add member"})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Collaboration instructions"}),e.jsx("textarea",{className:w(m,"min-h-36"),maxLength:8e3,value:y,onChange:a=>P(a.target.value)})]}),e.jsxs("label",{className:"block space-y-1 text-body-sm",children:[e.jsx("span",{children:"Project brief"}),e.jsx("textarea",{className:w(m,"min-h-36"),maxLength:8e3,value:d,onChange:a=>N(a.target.value)})]})]}),e.jsx(h,{type:"submit",disabled:u,children:u?"Saving…":t?"Save team":"Create team"})]})]})}function oe(){const t=O(),{agentId:E}=Q(),[b,j]=J(),r=b.get("kind")==="team"||b.get("create")==="team",v=b.has("create"),c=b.get("name"),p=V(),x=W(p.data,r?"team_catalogue":"profile_catalogue"),g=G(x&&!r),y=H(x&&r),P=X(),d=Y({queryKey:["desktop",r?"team":"profile",c],enabled:x&&!!c&&!v,queryFn:()=>L({op:r?"teams.get":"profiles.get",name:c??""}),retry:!1}),N=async u=>{await P.invalidateQueries({queryKey:["desktop"]}),j({kind:r?"team":"agent",name:u})};return E?e.jsx(n.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(ne,{})}):e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{ref:t,className:"flex w-64 shrink-0 flex-col gap-4 border-r border-hairline bg-surface p-4",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(h,{variant:r?"ghost":"outline",onClick:()=>j({kind:"agent"}),children:[e.jsx(Z,{className:"size-4"}),"Agents"]}),e.jsxs(h,{variant:r?"outline":"ghost",onClick:()=>j({kind:"team"}),children:[e.jsx(ee,{className:"size-4"}),"Teams"]})]}),e.jsxs(h,{variant:"outline",disabled:!x,onClick:()=>j({create:r?"team":"agent"}),children:[e.jsx(te,{className:"size-4"}),r?"Create team":"Create agent"]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(r?y.data:g.data)?.map(u=>e.jsx("button",{type:"button",className:w("flex h-8 w-full items-center rounded-md px-2 text-left text-body-sm hover:bg-row-hover",u.name===c&&ae),onClick:()=>j({kind:r?"team":"agent",name:u.name}),children:e.jsx("span",{className:"truncate",children:u.name})},u.name))})]}),e.jsx("main",{className:"min-w-0 flex-1 overflow-auto p-6",children:x?g.error||y.error||d.error?e.jsxs("div",{role:"alert",children:[e.jsx("p",{className:"text-danger",children:g.error?.message||y.error?.message||d.error?.message}),e.jsx(h,{variant:"outline",onClick:()=>{g.refetch(),y.refetch(),d.refetch()},children:"Retry"})]}):v?r?e.jsx(B,{onSaved:N},"create-team"):e.jsx(T,{creating:!0,onSaved:N},"create-agent"):c&&d.isLoading?e.jsx("p",{"aria-live":"polite",children:"Loading details…"}):c&&d.data?r?e.jsx(B,{team:d.data,onSaved:N},c):e.jsx(T,{profile:d.data,creating:!1,onSaved:N},`${c}:${d.data.source}`):e.jsxs("div",{children:[e.jsx("h2",{className:"text-title",children:r?"Reusable teams":"Reusable agents"}),e.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Select a definition to view or edit it. A new chat does not change its definition."})]}):e.jsxs("div",{"aria-live":"polite",className:"space-y-3 text-body-sm",children:[e.jsx("p",{children:p.isLoading?"Connecting to the backend…":p.error?p.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."}),e.jsx(h,{variant:"outline",onClick:()=>void p.refetch(),children:"Retry connection"})]})})]})}export{oe as AgentsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w as ln,p as un,m as H,s as q,n as j,o as an,q as y,t as tn,v as L,x as _,y as rn,z as o,A as sn,C as on,D as fn}from"./index-
|
|
1
|
+
import{w as ln,p as un,m as H,s as q,n as j,o as an,q as y,t as tn,v as L,x as _,y as rn,z as o,A as sn,C as on,D as fn}from"./index-BoBj0LUC.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function dn(l,h,C,D,v,A,B,u){var E=C-l,s=D-h,n=B-v,m=u-A,a=m*E-n*s;if(!(a*a<y))return a=(n*(h-A)-m*(l-v))/a,[l+a*E,h+a*s]}function W(l,h,C,D,v,A,B){var u=l-C,E=h-D,s=(B?A:-A)/L(u*u+E*E),n=s*E,m=-s*u,a=l+n,i=h+m,f=C+n,c=D+m,F=(a+f)/2,t=(i+c)/2,p=f-a,g=c-i,R=p*p+g*g,T=v-A,P=a*c-f*i,I=(g<0?-1:1)*L(on(0,T*T*R-P*P)),O=(P*g-p*I)/R,S=(-P*p-g*I)/R,w=(P*g+p*I)/R,d=(-P*p+g*I)/R,x=O-F,e=S-t,r=w-F,G=d-t;return x*x+e*e>r*r+G*G&&(O=w,S=d),{cx:O,cy:S,x01:-n,y01:-m,x11:O*(v/T-1),y11:S*(v/T-1)}}function hn(){var l=cn,h=yn,C=j(0),D=null,v=gn,A=mn,B=pn,u=null,E=ln(s);function s(){var n,m,a=+l.apply(this,arguments),i=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,F=rn(c-f),t=c>f;if(u||(u=n=E()),i<a&&(m=i,i=a,a=m),!(i>y))u.moveTo(0,0);else if(F>tn-y)u.moveTo(i*H(f),i*q(f)),u.arc(0,0,i,f,c,!t),a>y&&(u.moveTo(a*H(c),a*q(c)),u.arc(0,0,a,c,f,t));else{var p=f,g=c,R=f,T=c,P=F,I=F,O=B.apply(this,arguments)/2,S=O>y&&(D?+D.apply(this,arguments):L(a*a+i*i)),w=_(rn(i-a)/2,+C.apply(this,arguments)),d=w,x=w,e,r;if(S>y){var G=sn(S/a*q(O)),M=sn(S/i*q(O));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(I-=M*2)>y?(M*=t?1:-1,p+=M,g-=M):(I=0,p=g=(f+c)/2)}var J=i*H(p),K=i*q(p),N=a*H(T),Q=a*q(T);if(w>y){var U=i*H(g),V=i*q(g),X=a*H(R),Y=a*q(R),z;if(F<un)if(z=dn(J,K,X,Y,U,V,N,Q)){var Z=J-z[0],$=K-z[1],k=U-z[0],b=V-z[1],nn=1/q(fn((Z*k+$*b)/(L(Z*Z+$*$)*L(k*k+b*b)))/2),en=L(z[0]*z[0]+z[1]*z[1]);d=_(w,(a-en)/(nn-1)),x=_(w,(i-en)/(nn+1))}else d=x=0}I>y?x>y?(e=W(X,Y,J,K,i,x,t),r=W(U,V,N,Q,i,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,i,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(J,K),u.arc(0,0,i,p,g,!t)):u.moveTo(J,K),!(a>y)||!(P>y)?u.lineTo(N,Q):d>y?(e=W(N,Q,U,V,a,-d,t),r=W(J,K,X,Y,a,-d,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),d<w?u.arc(e.cx,e.cy,d,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,d,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,d,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,R,t)}if(u.closePath(),n)return u=null,n+""||null}return s.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-un/2;return[H(m)*n,q(m)*n]},s.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),s):l},s.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),s):h},s.cornerRadius=function(n){return arguments.length?(C=typeof n=="function"?n:j(+n),s):C},s.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),s):D},s.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),s):v},s.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),s):A},s.padAngle=function(n){return arguments.length?(B=typeof n=="function"?n:j(+n),s):B},s.context=function(n){return arguments.length?(u=n??null,s):u},s}export{hn as d};
|