@axiom-lattice/gateway 4.3.1 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed/{embed-page-AgentDetailSideApp-ONXG4B3D.js → embed-page-AgentDetailSideApp-7PQ2JKG6.js} +1 -1
- package/dist/embed/{embed-page-AgentGovernanceWorkbench-LCIQ5UF3.js → embed-page-AgentGovernanceWorkbench-ZNW72EEJ.js} +1 -1
- package/dist/embed/{embed-page-chunk-U6SL5TG6.js → embed-page-chunk-I42T7B7V.js} +21 -16
- package/dist/embed/{embed-page-chunk-YPV4BAWI.js → embed-page-chunk-RLP3BC7G.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as C}from"./embed-page-chunk-
|
|
1
|
+
import{l as C}from"./embed-page-chunk-RLP3BC7G.js";import"./embed-page-chunk-LE6OFJ7R.js";import"./embed-page-chunk-Z4S4OYA4.js";import"./embed-page-chunk-ZKJ7Z7P3.js";import"./embed-page-chunk-KEL6XU6R.js";import"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-I42T7B7V.js";import"./embed-page-chunk-VRV57DFE.js";import"./embed-page-chunk-4ZSGPIBZ.js";import{b as B}from"./embed-page-chunk-ZXFZANZM.js";import{Ya as T}from"./embed-page-chunk-BRETUPSG.js";import{r as P}from"./embed-page-chunk-T25T2YE6.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{U as c,W as p,oa as D,va as b,xa as l}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as u}from"./embed-page-chunk-6Y3UYJ6Z.js";var e=u(U());var t=u(I()),G={component_key:"workspace_assistants",data:{},message:"Assistants"},N=r=>{let i=r;if(typeof r=="string")try{i=JSON.parse(r)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},H=({data:r})=>{let{assistantId:i,initialTab:F}=r??{},{get:m,put:f,del:A}=P(),y=T(),[g,w]=(0,e.useState)(null),[R,h]=(0,e.useState)([]),[E,v]=(0,e.useState)(!1),[L,S]=(0,e.useState)(null),d=(0,e.useCallback)(()=>{y(G)},[y]),a=(0,e.useCallback)(async()=>{v(!0),S(null);try{let s=(await m("/api/assistants")).data?.records??[];h(s),w(s.find(o=>o.id===i)??null)}catch{S("Failed to load agent")}finally{v(!1)}},[m,i]);(0,e.useEffect)(()=>{i&&a()},[a,i]);let _=(0,e.useCallback)(async(n,s)=>{let o=N(n.graphDefinition),k;try{k=await f(`/api/assistants/${n.id}`,{name:s.name!==void 0?s.name:n.name,description:s.description!==void 0?s.description:n.description,graphDefinition:{...o,...s}})}catch(z){throw l.error("Failed to save agent"),z}if(!k.success)throw l.error("Failed to save agent"),new Error("Failed to save agent");l.success("Saved"),await a()},[f,a]),j=(0,e.useCallback)(n=>{w(s=>s&&s.id===n.id?n:s),h(s=>s.map(o=>o.id===n.id?n:o))},[]),x=(0,e.useCallback)(async n=>{if(!(await A(`/api/assistants/${n}`)).success)throw new Error("Failed to delete agent");l.success("Agent deleted"),d()},[A,d]);return i?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(B,{children:(0,t.jsx)(C,{assistant:g,allAssistants:R,onBack:d,onDeleted:x,onSave:_,onAssistantUpdated:j,onAgentListInvalidated:()=>void a(),initialTab:F})},g.id)}):E?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(b,{})}):L?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"error",showIcon:!0,message:"Failed to load agent","data-testid":"detail-error",action:(0,t.jsxs)(D,{children:[(0,t.jsx)(p,{size:"small",onClick:()=>void a(),children:"Retry"}),(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Agent not found","data-testid":"detail-not-found",action:(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Missing agent id","data-testid":"detail-missing-id"})})};export{H as AgentDetailSideApp};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Re,b as Me,c as Tt,d as It,e as Dt,f as Rt,g as Pt,h as Ft,i as Et,j as Mt,k as Nt,l as Lt}from"./embed-page-chunk-
|
|
1
|
+
import{a as Re,b as Me,c as Tt,d as It,e as Dt,f as Rt,g as Pt,h as Ft,i as Et,j as Mt,k as Nt,l as Lt}from"./embed-page-chunk-RLP3BC7G.js";import"./embed-page-chunk-LE6OFJ7R.js";import{a as Ge}from"./embed-page-chunk-Z4S4OYA4.js";import"./embed-page-chunk-ZKJ7Z7P3.js";import"./embed-page-chunk-KEL6XU6R.js";import{b as _e,e as Ve,f as At,g as Ct,h as xt,i as wt,l as vt,m as kt}from"./embed-page-chunk-AC6X2XRH.js";import{a as mt,b as gt,c as ut,d as ft,e as yt}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-I42T7B7V.js";import"./embed-page-chunk-VRV57DFE.js";import"./embed-page-chunk-4ZSGPIBZ.js";import{b as St}from"./embed-page-chunk-ZXFZANZM.js";import{C as at,Da as dt,M as ot,Ma as ct,Oa as pt,P as rt,X as st,Ya as ht,gb as bt,hb as Ke,ja as it,o as De,pa as lt}from"./embed-page-chunk-BRETUPSG.js";import{m as Qe,r as fe}from"./embed-page-chunk-T25T2YE6.js";import{a as E}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Db as et,Fa as Je,Ia as Ie,Ja as Ye,La as Y,Ua as Xe,W as Z,_ as Se,aa as Te,ac as Ee,ea as Fe,ka as Oe,la as We,ma as qe,mc as tt,oa as Ze,ra as P,ta as V,wa as $e,xa as v,ya as ue,yc as nt}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ge}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as x}from"./embed-page-chunk-6Y3UYJ6Z.js";var u=x(ge());var X=x(ge());var J=x(ge());var Bt=x(ge());var se=x(E()),Ot=60,$t=72,ze=(0,Bt.memo)(({data:n})=>{let r=Re(n.type),p=Math.min(12+Math.sqrt(n.subAgentCount)*10,48);return(0,se.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,se.jsx)(Ve,{type:"target",position:_e.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,se.jsx)("div",{title:n.label,style:{width:p,height:p,borderRadius:"50%",background:Me(r.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,p*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:n.label.charAt(0).toUpperCase()}),(0,se.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:n.label}),(0,se.jsx)(Ve,{type:"source",position:_e.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});ze.displayName="AgentGraphNode";var Q=x(E()),sn=({assistants:n,onNodeClick:r})=>{let[p,d,g]=xt([]),[o,f,k]=wt([]),[c,S]=(0,J.useState)(null),H=(0,J.useMemo)(()=>({agent:ze}),[]),m=(0,J.useMemo)(()=>Dt(n),[n]);(0,J.useEffect)(()=>{let w=m.nodes.map(i=>({id:i.id})),F=m.edges.map(i=>({source:i.source,target:i.target})),N=new Map(m.nodes.map(i=>[i.id,i])),_=ft(w).force("link",ut(F).id(i=>i.id).distance(80)).force("charge",yt().strength(-220)).force("center",mt(0,0)).force("collide",gt(45)).stop();for(let i=0;i<300;i++)_.tick();let R=w.map(i=>({id:i.id,type:"agent",data:N.get(i.id),position:{x:i.x-Ot/2,y:i.y-$t/2}})),s=m.edges.map(i=>({id:`e${i.source}-${i.target}`,source:i.source,target:i.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));d(R),f(s)},[m,d,f]);let I=(0,J.useMemo)(()=>c===null?p:p.map(w=>{let F=w.id===c||o.some(N=>N.source===c&&N.target===w.id||N.target===c&&N.source===w.id);return{...w,style:{opacity:F?1:.2,transition:"opacity 0.2s ease"}}}),[p,o,c]),K=(0,J.useMemo)(()=>c===null?o.map(w=>({...w,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):o.map(w=>{let F=w.source===c||w.target===c;return{...w,style:{stroke:"#1677ff",strokeWidth:F?2.5:1,opacity:F?1:.04,transition:"opacity 0.2s ease"}}}),[o,c]);return(0,Q.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,Q.jsxs)(Ct,{nodes:I,edges:K,onNodesChange:g,onEdgesChange:k,onNodeMouseEnter:(w,F)=>S(F.id),onNodeMouseLeave:()=>S(null),onNodeClick:(w,F)=>r?.(String(F.id)),nodeTypes:H,fitView:!0,fitViewOptions:{padding:.25},children:[(0,Q.jsx)(vt,{color:"#eee",gap:20}),(0,Q.jsx)(kt,{})]})})},Kt=n=>(0,Q.jsx)(At,{children:(0,Q.jsx)(sn,{...n})});var M=x(E()),ln=n=>{if(!n)return"\u2014";let r=Date.now()-new Date(n).getTime(),p=Math.floor(r/6e4);if(p<1)return"just now";if(p<60)return`${p}m ago`;let d=Math.floor(p/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`},dn=n=>n===null?"#d9d9d9":n>=80?"#22c55e":n>=50?"#f59e0b":"#ef4444",cn=ct(({css:n})=>({row:n`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: space-between;
|
|
4
4
|
align-items: flex-end;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as hr,Da as
|
|
1
|
+
import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as hr,Da as Nr,Ea as Mr,Ja as Br,K as Oo,Ka as Bt,L as br,La as Dr,Ma as C,Na as Fr,O as vr,Oa as Se,P as xr,Q as st,Qa as no,R as Wo,Ra as tt,Sa as Ko,Ta as lt,Ua as ke,Va as ro,W as wr,Wa as zr,Xa as io,Y as kt,Z as Cr,_ as Sr,a as at,c as Gt,d as Yn,e as Xn,ea as to,eb as Dt,f as Zn,g as jo,h as et,i as Zt,ia as Rr,k as gr,ka as oo,la as Tr,nb as jr,o as Nt,pa as Pr,q as fr,qa as Ve,rb as $r,sa as Uo,t as yr,ta as Ir,tb as _r,u as eo,ua as Ar,vb as qo,w as Mt,za as Ho}from"./embed-page-chunk-BRETUPSG.js";import{f as Qn,j as Oe,l as Jn,n as er,p as tr,q as Ce,r as ue}from"./embed-page-chunk-T25T2YE6.js";import{a as i}from"./embed-page-chunk-MB65DZAX.js";import{$ as Vt,$b as ar,Ac as dr,Ca as Vn,Eb as Qt,Fa as Ct,Gc as pr,Ia as be,Ic as mr,Ja as Le,Kc as Xt,La as P,Lc as Jt,Ma as Gn,Nc as ur,Tb as ir,V as Et,Va as $o,W as z,Y as Fo,Z as xe,_ as Me,aa as je,bc as sr,fc as lr,ia as _e,la as qn,mb as St,mc as Yt,na as zo,oa as de,ob as or,pa as qe,qb as nr,rc as yt,sb as _o,ta as K,tb as rr,va as re,wa as Pe,xa as q,ya as me,yb as Lo,yc as cr}from"./embed-page-chunk-O4QK5LWZ.js";import{a as w}from"./embed-page-chunk-4BKXE5ON.js";import{e as n}from"./embed-page-chunk-6Y3UYJ6Z.js";var Or=n(i()),xa=C(({token:e,css:t})=>({button:t`
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
@@ -19,7 +19,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
19
19
|
background: ${e.colorBgTextHover};
|
|
20
20
|
border-color: ${e.colorBorderSecondary};
|
|
21
21
|
}
|
|
22
|
-
`})),Rt=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:s}=xa();return(0,Or.jsx)(z,{type:"text",size:"small",className:s.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var Vo=n(i()),Go=()=>{let{toolsVisible:e,toggleTools:t}=ke();return(0,Vo.jsx)(Rt,{ariaLabel:"Toggle file directory",icon:(0,Vo.jsx)(st,{size:16}),onClick:t,pressed:e})};var he=n(w());var Ue=n(w());var ao=n(w());function ot(e){let[t,o]=(0,ao.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,ao.useEffect)(()=>{let r=window.matchMedia(e),s=a=>{o(a.matches)};return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}var Te=n(i()),ht=({main:e,detail:t,tools:o,logo:r,menu:s,header:a,mainStyle:d})=>{let{styles:c}=ro(),{detailVisible:p,detailSize:u,detailSelectedCard:b,toolsVisible:x,toolSelectedCard:v,contentAppSelectedCard:g,menuCollapsed:m,setMenuCollapsed:f,closeDetail:W,closeTools:j}=ke(),A=ot("(max-width: 768px)"),X=ot("(max-width: 1100px)"),ee=p||(m??A),pe=p&&!A,Q=ee?"collapsed":"expanded",S=p||x,B=x&&(u||"large")==="large"?"middle":u||"large";return(0,Te.jsxs)("div",{className:`fina_chat ${c.layout}`,children:[s&&(0,Te.jsxs)("div",{className:`${c.menu} ${Q} ${pe?c.menuSnap:""}`,children:[r,s]}),(0,Te.jsxs)("div",{className:c.contentArea,children:[(a||A&&s)&&(0,Te.jsxs)("div",{className:c.header,children:[A&&s?(0,Te.jsx)("button",{className:c.mobileMenuToggle,onClick:()=>f(!ee),"aria-label":"Toggle menu",children:(0,Te.jsx)(Tr,{size:18})}):null,a]}),(0,Te.jsxs)("div",{className:c.columns,style:{gap:S?void 0:0},children:[(0,Te.jsx)("div",{className:`${c.mainContent} ${S?"open":""}`,children:(0,Te.jsx)("div",{className:`${c.chat} ${g?"full_content_width":""}`,style:d,children:e})}),(0,Te.jsxs)("div",{className:`${c.detailPanel} ${p?`open ${B}`:""}`,children:[p&&A&&(0,Te.jsx)("button",{className:c.mobilePanelClose,onClick:W,"aria-label":"Close detail panel",children:(0,Te.jsx)(Bt,{size:20})}),p&&b&&t?(0,Te.jsx)("div",{className:c.detailContent,children:t}):null]}),(0,Te.jsxs)("div",{className:`${c.toolPanel} ${x?"open":""}`,children:[x&&X&&(0,Te.jsx)("button",{className:c.mobilePanelClose,onClick:j,"aria-label":"Close tool panel",children:(0,Te.jsx)(Bt,{size:20})}),x&&o?(0,Te.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Ie=n(w());var
|
|
22
|
+
`})),Rt=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:s}=xa();return(0,Or.jsx)(z,{type:"text",size:"small",className:s.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var Vo=n(i()),Go=()=>{let{toolsVisible:e,toggleTools:t}=ke();return(0,Vo.jsx)(Rt,{ariaLabel:"Toggle file directory",icon:(0,Vo.jsx)(st,{size:16}),onClick:t,pressed:e})};var he=n(w());var Ue=n(w());var ao=n(w());function ot(e){let[t,o]=(0,ao.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,ao.useEffect)(()=>{let r=window.matchMedia(e),s=a=>{o(a.matches)};return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}var Te=n(i()),ht=({main:e,detail:t,tools:o,logo:r,menu:s,header:a,mainStyle:d})=>{let{styles:c}=ro(),{detailVisible:p,detailSize:u,detailSelectedCard:b,toolsVisible:x,toolSelectedCard:v,contentAppSelectedCard:g,menuCollapsed:m,setMenuCollapsed:f,closeDetail:W,closeTools:j}=ke(),A=ot("(max-width: 768px)"),X=ot("(max-width: 1100px)"),ee=p||(m??A),pe=p&&!A,Q=ee?"collapsed":"expanded",S=p||x,B=x&&(u||"large")==="large"?"middle":u||"large";return(0,Te.jsxs)("div",{className:`fina_chat ${c.layout}`,children:[s&&(0,Te.jsxs)("div",{className:`${c.menu} ${Q} ${pe?c.menuSnap:""}`,children:[r,s]}),(0,Te.jsxs)("div",{className:c.contentArea,children:[(a||A&&s)&&(0,Te.jsxs)("div",{className:c.header,children:[A&&s?(0,Te.jsx)("button",{className:c.mobileMenuToggle,onClick:()=>f(!ee),"aria-label":"Toggle menu",children:(0,Te.jsx)(Tr,{size:18})}):null,a]}),(0,Te.jsxs)("div",{className:c.columns,style:{gap:S?void 0:0},children:[(0,Te.jsx)("div",{className:`${c.mainContent} ${S?"open":""}`,children:(0,Te.jsx)("div",{className:`${c.chat} ${g?"full_content_width":""}`,style:d,children:e})}),(0,Te.jsxs)("div",{className:`${c.detailPanel} ${p?`open ${B}`:""}`,children:[p&&A&&(0,Te.jsx)("button",{className:c.mobilePanelClose,onClick:W,"aria-label":"Close detail panel",children:(0,Te.jsx)(Bt,{size:20})}),p&&b&&t?(0,Te.jsx)("div",{className:c.detailContent,children:t}):null]}),(0,Te.jsxs)("div",{className:`${c.toolPanel} ${x?"open":""}`,children:[x&&X&&(0,Te.jsx)("button",{className:c.mobilePanelClose,onClick:j,"aria-label":"Close tool panel",children:(0,Te.jsx)(Bt,{size:20})}),x&&o?(0,Te.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Ie=n(w());var N=n(i()),Wr={wrapper:{background:"transparent",borderRadius:"0 24px 24px 0"},content:{background:"rgba(255, 255, 255, 0.72)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)"},header:{background:"transparent",borderBottom:"1px solid rgba(0, 0, 0, 0.06)"},body:{padding:0}},wa=C(({token:e,css:t})=>({sidebar:t`
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
25
25
|
height: 100%;
|
|
@@ -63,7 +63,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
63
63
|
width: 22px;
|
|
64
64
|
height: 22px;
|
|
65
65
|
}
|
|
66
|
-
`})),Ca=e=>{let t=new Map;return e.forEach(o=>{let r=o.group||null;t.has(r)||t.set(r,[]),t.get(r).push(o)}),Array.from(t.entries()).map(([o,r])=>({group:o,items:r.sort((s,a)=>(s.order??0)-(a.order??0))})).sort((o,r)=>{if(o.group===null)return-1;if(r.group===null)return 1;let s=o.items[0]?.order??0,a=r.items[0]?.order??0;return s-a})},so=({items:e,onItemClick:t,logo:o,logoIcon:r,logoText:s="Menu",showBranding:a=!0,showToggle:d=!0,showNewAnalysis:c=!1,onNewAnalysis:p,defaultExpanded:u=!0,forceIconMode:b=!1,collapsed:x,onCollapsedChange:v,className:g,style:m,footer:f,getContextMenuItems:W})=>{let{styles:j}=wa(),{styles:A}=ro(),X=x!==void 0,[ee,pe]=(0,Ie.useState)(!u),Q=X?x:ee;(0,Ie.useEffect)(()=>{X||v?.(Q)},[]);let[S,B]=(0,Ie.useState)({}),[J,Z]=(0,Ie.useState)(()=>{let k=new Set;return e.forEach(ne=>{ne.type==="drawer"&&ne.inline&&ne.inlineDefaultExpanded&&k.add(ne.id)}),k}),E=Q||b,D=!!E,$=(0,Ie.useMemo)(()=>Ca(e),[e]),le=(0,Ie.useCallback)(k=>{t?.(k),k.type==="drawer"&&((k.inline??!1)&&!E?Z(F=>{let U=new Set(F);return U.has(k.id)?U.delete(k.id):U.add(k.id),U}):B(F=>({...F,[k.id]:!0})))},[t,E]),L=(0,Ie.useCallback)(k=>{B(ne=>({...ne,[k]:!1}))},[]),R=(0,Ie.useMemo)(()=>e.filter(k=>k.type==="drawer"&&S[k.id]).map(k=>k.id),[e,S]);(0,Ie.useEffect)(()=>{if(R.length===0)return;let k=ne=>{let F=ne.target;!F||typeof F.closest!="function"||R.forEach(U=>{F.closest(`.menu-drawer-${U}`)||L(U)})};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[R,L]);let I=(0,Ie.useCallback)(()=>{if(!b){let k=!Q;X?v?.(k):pe(k)}},[b,Q,X,v]);return(0,
|
|
66
|
+
`})),Ca=e=>{let t=new Map;return e.forEach(o=>{let r=o.group||null;t.has(r)||t.set(r,[]),t.get(r).push(o)}),Array.from(t.entries()).map(([o,r])=>({group:o,items:r.sort((s,a)=>(s.order??0)-(a.order??0))})).sort((o,r)=>{if(o.group===null)return-1;if(r.group===null)return 1;let s=o.items[0]?.order??0,a=r.items[0]?.order??0;return s-a})},so=({items:e,onItemClick:t,logo:o,logoIcon:r,logoText:s="Menu",showBranding:a=!0,showToggle:d=!0,showNewAnalysis:c=!1,onNewAnalysis:p,defaultExpanded:u=!0,forceIconMode:b=!1,collapsed:x,onCollapsedChange:v,className:g,style:m,footer:f,getContextMenuItems:W})=>{let{styles:j}=wa(),{styles:A}=ro(),X=x!==void 0,[ee,pe]=(0,Ie.useState)(!u),Q=X?x:ee;(0,Ie.useEffect)(()=>{X||v?.(Q)},[]);let[S,B]=(0,Ie.useState)({}),[J,Z]=(0,Ie.useState)(()=>{let k=new Set;return e.forEach(ne=>{ne.type==="drawer"&&ne.inline&&ne.inlineDefaultExpanded&&k.add(ne.id)}),k}),E=Q||b,D=!!E,$=(0,Ie.useMemo)(()=>Ca(e),[e]),le=(0,Ie.useCallback)(k=>{t?.(k),k.type==="drawer"&&((k.inline??!1)&&!E?Z(F=>{let U=new Set(F);return U.has(k.id)?U.delete(k.id):U.add(k.id),U}):B(F=>({...F,[k.id]:!0})))},[t,E]),L=(0,Ie.useCallback)(k=>{B(ne=>({...ne,[k]:!1}))},[]),R=(0,Ie.useMemo)(()=>e.filter(k=>k.type==="drawer"&&S[k.id]).map(k=>k.id),[e,S]);(0,Ie.useEffect)(()=>{if(R.length===0)return;let k=ne=>{let F=ne.target;!F||typeof F.closest!="function"||R.forEach(U=>{F.closest(`.menu-drawer-${U}`)||L(U)})};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[R,L]);let I=(0,Ie.useCallback)(()=>{if(!b){let k=!Q;X?v?.(k):pe(k)}},[b,Q,X,v]);return(0,N.jsxs)(N.Fragment,{children:[E?(0,N.jsxs)("div",{className:`${j.sidebar} ${A.iconMode} ${g||""}`,style:m,children:[a?(0,N.jsx)("div",{className:A.iconModeLogo,children:o||r||(0,N.jsx)(Oo,{size:28,color:"#1677ff"})}):null,(0,N.jsx)("div",{className:A.iconModeContainer,children:$.map(({group:k,items:ne},F)=>(0,N.jsxs)(Ie.default.Fragment,{children:[F>0&&(0,N.jsx)("div",{className:A.iconModeDivider}),(0,N.jsx)("div",{className:A.iconModeGroup,children:ne.map(U=>{let We=W?.(U),He=U.badge!==void 0&&U.badge!==!1&&U.badge!==0,Ze=(0,N.jsxs)("button",{className:A.iconModeButton,onClick:()=>le(U),title:U.name,"aria-label":U.name,style:{position:"relative"},children:[(0,N.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:U.icon}),He&&(0,N.jsx)("span",{style:{position:"absolute",top:2,right:2,minWidth:typeof U.badge=="number"?16:8,height:typeof U.badge=="number"?16:8,borderRadius:typeof U.badge=="number"?8:4,background:"#ef4444",color:"#fff",fontSize:10,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof U.badge=="number"?"0 3px":0},children:typeof U.badge=="number"?U.badge>99?"99+":U.badge:null})]},U.id);return We?(0,N.jsx)(qe,{menu:{items:We},trigger:["contextMenu"],children:Ze},U.id):Ze})})]},k||`group-${F}`))}),d&&(0,N.jsx)("button",{className:A.iconModeButton,onClick:I,title:"Expand sidebar","aria-label":"Expand sidebar",style:{marginTop:"auto"},children:(0,N.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:(0,N.jsx)(Mt,{size:22})})}),f&&(0,N.jsx)("div",{style:{marginTop:"auto",paddingTop:8},children:typeof f=="function"?f({isIconMode:E}):f})]}):(0,N.jsxs)("div",{className:`${j.sidebar} ${A.expandedMenu} ${g||""}`,style:m,children:[a?(0,N.jsxs)("div",{className:`${A.expandedMenuLogo} ${D?"collapsed":""}`,children:[(0,N.jsx)("div",{className:"logo-icon",children:o||r||(0,N.jsx)(Oo,{size:28,color:"#1677ff"})}),(0,N.jsx)("span",{className:"logo-text",children:s}),d&&!b&&(0,N.jsx)("button",{className:A.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",children:(0,N.jsx)(oo,{size:18})})]}):d&&!b?(0,N.jsx)("button",{className:A.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",style:{alignSelf:"flex-end",marginBottom:8},children:(0,N.jsx)(oo,{size:18})}):null,c&&(0,N.jsxs)("button",{className:`${A.newAnalysisBtn} ${D?"collapsed":""}`,onClick:p,children:[(0,N.jsx)(Ir,{size:18}),(0,N.jsx)("span",{className:"btn-text",children:"New Thread"})]}),(0,N.jsx)("div",{className:A.buttonContainerExpanded,children:$.map(({group:k,items:ne})=>(0,N.jsxs)("div",{className:A.menuGroup,children:[k&&(0,N.jsx)("div",{className:`${A.menuGroupTitle} ${D?"collapsed":""}`,children:k}),ne.map(F=>{let U=F.inline??!1,We=J.has(F.id),He=W?.(F),Ze=F.badge!==void 0&&F.badge!==!1&&F.badge!==0,ft=(0,N.jsxs)("button",{className:`${A.menuItemExpanded} ${D?"collapsed":""} ${We?A.menuItemExpandedActive:""}`,onClick:()=>le(F),title:D?F.name:void 0,"aria-label":F.name,"aria-expanded":We,children:[(0,N.jsx)("span",{className:"menu-icon",children:F.icon}),(0,N.jsx)("span",{className:"menu-label",children:F.name}),Ze&&(0,N.jsx)("span",{style:{marginLeft:"auto",minWidth:typeof F.badge=="number"?18:8,height:typeof F.badge=="number"?18:8,borderRadius:typeof F.badge=="number"?9:4,background:"#ef4444",color:"#fff",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof F.badge=="number"?"0 4px":0},children:typeof F.badge=="number"?F.badge>99?"99+":F.badge:null}),U&&!D&&(0,N.jsx)("span",{className:A.inlineDrawerIndicator,children:We?(0,N.jsx)(eo,{size:16}):(0,N.jsx)(Mt,{size:16})})]}),rt=He?(0,N.jsx)(qe,{menu:{items:He},trigger:["contextMenu"],children:ft},F.id):(0,N.jsx)(Ie.default.Fragment,{children:ft},F.id);return(0,N.jsxs)(Ie.default.Fragment,{children:[rt,U&&We&&!D&&(0,N.jsx)("div",{className:A.inlineDrawerContainer,children:F.content})]},F.id)})]},k||"ungrouped"))}),f&&(0,N.jsx)("div",{style:{marginTop:"auto",paddingTop:16,borderTop:"1px solid rgba(0, 0, 0, 0.06)"},children:typeof f=="function"?f({isIconMode:E}):f})]}),e.filter(k=>k.type==="drawer").map(k=>(0,N.jsx)(zo,{rootClassName:`menu-drawer-${k.id}`,title:(0,N.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,N.jsx)("span",{style:{fontSize:16,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:k.title||k.name}),(0,N.jsx)("button",{onClick:()=>L(k.id),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,border:"1px solid rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.5)",cursor:"pointer"},children:(0,N.jsx)(oo,{size:24})})]}),open:S[k.id]||!1,onClose:()=>L(k.id),placement:"left",width:k.width||600,styles:{...Wr,header:{padding:"16px 20px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},content:{...Wr.content,borderRadius:"0 24px 24px 0",overflow:"hidden"}},closable:!1,mask:!1,destroyOnClose:!0,children:k.content},k.id))]})};var Ur=n(w());var Hr=n(i()),{TextArea:jl}=K;var Kr=n(w());var qr=n(i());var Vr=n(i());var Tt=n(w());var Qo=class{apps=new Map;defaultId=void 0;register(t){if(!t.id)throw new Error("App must have an id");this.apps.set(t.id,t),this.defaultId===void 0&&(this.defaultId=t.id)}get(t){return this.apps.get(t)}list(){return Array.from(this.apps.values())}getDefaultId(){return this.defaultId}setDefault(t){if(!this.apps.has(t))throw new Error(`Cannot set default to unregistered app: ${t}`);this.defaultId=t}getCurrentId(){return this.currentId}setCurrent(t){if(!this.apps.has(t))throw new Error(`Cannot set current to unregistered app: ${t}`);this.currentId=t}resetCurrent(){this.currentId=void 0}currentId=void 0},ka=new Qo;var Ra=n(i()),Gl=(0,Tt.createContext)(null);var Qr=n(i()),Jl=C(({token:e})=>({container:{display:"flex",flexDirection:"column",gap:e.padding,padding:e.padding},header:{fontSize:e.fontSizeHeading5,fontWeight:600,color:e.colorText,paddingBottom:e.paddingSM,borderBottom:`1px solid ${e.colorBorderSecondary}`},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:e.padding},card:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.paddingXS,padding:e.paddingLG,borderRadius:e.borderRadiusLG,border:`1px solid ${e.colorBorder}`,cursor:"pointer",transition:"all 0.2s",background:e.colorBgContainer,"&:hover":{borderColor:e.colorPrimary,background:e.colorPrimaryBg}},activeCard:{borderColor:e.colorPrimary,background:e.colorPrimaryBg},icon:{fontSize:28,lineHeight:1},name:{fontSize:e.fontSize,fontWeight:500,color:e.colorText,textAlign:"center"},activeName:{color:e.colorPrimary}}));var gi=n(w());var Ea=n(w());var Yo=n(i());var Yr=n(i());var ct=n(w());var Ma=n(i());var yc=300*1e3,hc=(0,ct.createContext)(null);var Ba=n(i());var pn=n(w());var Jo=n(w());var Da=n(w());var Fa=n(i());var Jr=n(i()),Nc=C(({token:e,css:t})=>({container:t`
|
|
67
67
|
display: flex;
|
|
68
68
|
flex-direction: column;
|
|
69
69
|
height: 100%;
|
|
@@ -166,7 +166,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
166
166
|
gap: 2px;
|
|
167
167
|
`,emptyContainer:t`
|
|
168
168
|
padding: 24px 16px;
|
|
169
|
-
`}));var Ya=n(w());var dt=n(w());var za=n(i());var Xc=(0,dt.createContext)(null);var Ot=n(w());var Ae=n(w());var
|
|
169
|
+
`}));var Ya=n(w());var dt=n(w());var za=n(i());var Xc=(0,dt.createContext)(null);var Ot=n(w());var Ae=n(w());var M=n(i()),ja=C(({token:e,css:t})=>({container:t`
|
|
170
170
|
display: flex;
|
|
171
171
|
flex-direction: column;
|
|
172
172
|
height: 100%;
|
|
@@ -411,7 +411,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
411
411
|
transform: translateY(0);
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
`})),$a=({component_key:e,data:t})=>t?.component?(0,
|
|
414
|
+
`})),$a=({component_key:e,data:t})=>t?.component?(0,M.jsx)(M.Fragment,{children:t.component}):(0,M.jsxs)("div",{children:[(0,M.jsx)("p",{children:"Component view not found"}),(0,M.jsx)("pre",{children:JSON.stringify({component_key:e,data:t},null,2)})]}),co=e=>(0,M.jsx)($o,{style:{fontSize:12,opacity:.6}}),po=({region:e="side",compact:t=!0,showCloseButton:o=!0})=>{let{styles:r}=ja(),{sideAppSelectedCard:s,contentAppSelectedCard:a,closeSideApp:d,closeContentApp:c,openSideApp:p,openContentApp:u}=ke(),b=e==="side"?s:a,x=e==="side"?d:c,v=e==="side"?p:u,[g,m]=(0,Ae.useState)(JSON.stringify(b)),[f,W]=(0,Ae.useState)(null),[j,A]=(0,Ae.useState)([]),[X,ee]=(0,Ae.useState)(!1),[pe,Q]=(0,Ae.useState)(!1),[S,B]=(0,Ae.useState)(!1),J=(0,Ae.useRef)(null),Z=(0,Ae.useCallback)(()=>{J.current&&(clearTimeout(J.current),J.current=null),Q(!1),B(!1),ee(!0)},[]),E=(0,Ae.useCallback)(()=>{J.current=setTimeout(()=>{Q(!0)},150)},[]),se=(0,Ae.useCallback)(()=>{pe&&(ee(!1),Q(!1))},[pe]),D=(T,ce,k,ne)=>{let F=[...j,{label:ce,children:k,key:T,componentKey:ne}];A(F),m(T)},$=T=>{let ce=g,k=j.findIndex(F=>F.key===T),ne=j.filter(F=>F.key!==T);if(ne.length===0){x();return}ce===T&&(k>0?ce=j[k-1].key:ce=ne[0].key),A(ne),m(ce)},le=T=>{m(T)};(0,Ae.useEffect)(()=>{if(!b)return;let T=JSON.stringify(b);if(j.find(k=>k.key===T)){m(T),setTimeout(()=>{document.querySelector(`[data-tab-key="${T}"]`)?.scrollIntoView({behavior:"smooth",inline:"center"})},100);return}let ce=qo(b?.component_key)?.side_app_view||$a;D(T,b?.message||b?.data?.message||"Unnamed",(0,M.jsx)(ce,{component_key:b?.component_key||"",data:b?.data,context:b?.context}),b?.component_key),J.current&&clearTimeout(J.current),ee(!0),Q(!1),B(!0),J.current=setTimeout(()=>{Q(!0)},1500)},[b]);let L=j.find(T=>T.key===g),R=j.map(T=>({key:T.key,label:(0,M.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[co(T.componentKey),(0,M.jsx)("span",{style:{flex:1},children:T.label}),(0,M.jsx)(St,{style:{fontSize:10,opacity:.5},onClick:ce=>{ce.stopPropagation(),$(T.key)}})]}),onClick:()=>le(T.key)})),I=(0,Ae.useMemo)(()=>({openApp:v}),[v]);return(0,M.jsxs)("div",{className:r.container,children:[t&&j.length>0&&(0,M.jsx)("div",{className:r.compactWrapper,onMouseEnter:Z,onMouseLeave:E,children:X?(0,M.jsxs)("div",{className:`${r.floatingHeader} ${S?r.floatingHeaderPeek:""} ${pe?r.floatingHeaderLeaving:""}`,onAnimationEnd:se,children:[(0,M.jsx)("div",{className:r.floatingTabsStrip,children:j.map(T=>(0,M.jsx)(je,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===g?"active":""}`,onClick:()=>le(T.key),onMouseEnter:()=>W(T.key),onMouseLeave:()=>W(null),children:[co(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${f===T.key||T.key===g?"always-visible":""}`,onClick:ce=>{ce.stopPropagation(),$(T.key)},children:(0,M.jsx)(St,{style:{fontSize:10}})})]})},T.key))}),j.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(yt,{})})}),o&&(0,M.jsx)(je,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(St,{})})})]}):L&&(0,M.jsxs)("div",{className:r.compactPill,children:[co(L.componentKey),(0,M.jsx)("span",{className:r.compactPillLabel,children:L.label})]})}),!t&&(0,M.jsxs)("div",{className:r.header,children:[(0,M.jsx)("div",{className:r.tabsStrip,children:j.map(T=>(0,M.jsx)(je,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===g?"active":""}`,onClick:()=>le(T.key),onMouseEnter:()=>W(T.key),onMouseLeave:()=>W(null),children:[co(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${f===T.key||T.key===g?"always-visible":""}`,onClick:ce=>{ce.stopPropagation(),$(T.key)},children:(0,M.jsx)(St,{style:{fontSize:10}})})]})},T.key))}),(0,M.jsxs)("div",{className:r.actions,children:[j.length>0&&(0,M.jsx)("div",{className:r.tabCounter,children:j.length}),j.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(yt,{})})}),o&&(0,M.jsx)(je,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(St,{})})})]})]}),(0,M.jsx)("div",{className:r.content,style:t&&j.length>0?{paddingTop:10}:void 0,children:(0,M.jsx)(io.Provider,{value:I,children:L?(0,M.jsx)("div",{className:r.contentWrapper,children:L.children},L.key):(0,M.jsxs)("div",{className:r.emptyState,children:[(0,M.jsx)($o,{className:"icon"}),(0,M.jsx)("span",{children:"Select an app to start"})]})})})]})};var zt=n(w());var Zo=n(w());var en=n(i());var md=C(({token:e,css:t})=>({content:t`
|
|
415
415
|
display: flex;
|
|
416
416
|
flex-direction: column;
|
|
417
417
|
gap: 4px;
|
|
@@ -533,7 +533,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
533
533
|
color: ${e.colorTextTertiary};
|
|
534
534
|
opacity: 0;
|
|
535
535
|
transition: opacity 0.15s ease;
|
|
536
|
-
`}));var ei=n(i());var
|
|
536
|
+
`}));var ei=n(i());var Md=5*6e4,Bd=C(({token:e,css:t})=>({root:t`
|
|
537
537
|
flex: 1;
|
|
538
538
|
min-height: 0;
|
|
539
539
|
overflow-y: auto;
|
|
@@ -568,9 +568,14 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
568
568
|
color: ${e.colorTextTertiary};
|
|
569
569
|
`}));var jt=n(w());var ti=n(i());var ip=C(({token:e,css:t})=>({root:t`
|
|
570
570
|
flex-shrink: 0;
|
|
571
|
-
border-top: 1px solid ${e.colorBorderSecondary};
|
|
572
571
|
background: ${e.colorBgContainer};
|
|
573
572
|
padding: 8px 12px max(8px, env(safe-area-inset-bottom));
|
|
573
|
+
|
|
574
|
+
@media (max-width: 768px) {
|
|
575
|
+
/* Nearly full-bleed on phones: the Sender already brings its own inner
|
|
576
|
+
padding, so extra host padding just wastes scarce width. */
|
|
577
|
+
padding: 4px 6px max(6px, env(safe-area-inset-bottom));
|
|
578
|
+
}
|
|
574
579
|
`,reply:t`
|
|
575
580
|
display: flex;
|
|
576
581
|
align-items: center;
|
|
@@ -967,7 +972,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
967
972
|
width: 14px;
|
|
968
973
|
height: 14px;
|
|
969
974
|
}
|
|
970
|
-
`})),si=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},Ha=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},an=e=>Ha(e.name||e.path),Ka=e=>(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{style:{fontWeight:600},children:an(e)}),e.created_at?(0,h.jsxs)("div",{children:["Created: ",si(e.created_at)]}):null,e.modified_at?(0,h.jsxs)("div",{children:["Modified: ",si(e.modified_at)]}):null]}),qa={display:"flex",flexDirection:"column",gap:12},sn=({workspaceId:e,projectId:t,resourceFolders:o,folderEntries:r,folderLoading:s,directoryChildren:a,directoryLoading:d,directoryExpanded:c,uploadingFolder:p,onRefreshFolder:u,onUploadFolder:b,onToggleDirectory:x,onAssetClick:v})=>{let{styles:g}=Ua(),{message:m}=Fo.useApp(),{currentAssistant:f}=et(),{getFileDownloadUrl:W,downloadFolder:j,getDirectFileUrl:A,listPathByFolder:X}=Se(),{openSideApp:ee}=ke(),{currentTenant:pe}=Oe(),Q=pe?.id||"",[S,B]=(0,ie.useState)(null),[J,Z]=(0,ie.useState)(null),{check:E,pin:se,unpin:D,enableCustomMenu:$,get:le}=uo(),L=ln(),[R,I]=(0,ie.useState)(L);(0,ie.useEffect)(()=>{I(L)},[L]);let[T,ce]=(0,ie.useState)({}),[k,ne]=(0,ie.useState)(null),[F,U]=(0,ie.useState)(""),[We,He]=(0,ie.useState)(""),[Ze,ft]=(0,ie.useState)(!1),[rt,O]=(0,ie.useState)(""),[fe,it]=(0,ie.useState)("name"),[Ye,fa]=(0,ie.useState)("asc"),[Ht,Mo]=(0,ie.useState)(null),[ya,No]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>{k&&cn(le).then(y=>{I(Array.from(new Set([...L,...y])).sort())})},[k]),(0,ie.useEffect)(()=>{let y=rt.trim();if(!y){Mo(null),No(!1);return}let Y=!1;return No(!0),$r(X,o.map(H=>H.name),f?.id).then(H=>{Y||Mo(ii(H,y))}).catch(()=>{Y||Mo([])}).finally(()=>{Y||No(!1)}),()=>{Y=!0}},[rt,X,o,f?.id]);let Bo=(0,ie.useMemo)(()=>Ht?rn(ai(Ht),fe,Ye):null,[Ht,fe,Ye]),Kt=(0,ie.useCallback)((y,Y)=>{if(!Y||!$)return;ce(_=>_[y]?_:{..._,[y]:{isPinned:!1,pinnedId:null,loading:!0}});let H={contentType:"file",contentConfig:{resourcePath:y,tenantId:Q,workspaceId:e||"",projectId:t||"",assistantId:f?.id||"",fileName:y.split("/").pop()||y},isMatch:_=>_.resourcePath===y};E(H).then(_=>{ce(Ke=>({...Ke,[y]:{..._,loading:!1}}))}).catch(()=>{ce(_=>({..._,[y]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[$,E,f?.id]),ha=async()=>{if(!k||!F.trim()){m.warning("Please enter a menu name");return}ft(!0);try{let y=k.split("/").pop()||k;await se({contentType:"file",name:F.trim(),group:We.trim()||void 0,contentConfig:{resourcePath:k,tenantId:Q,workspaceId:e||"",projectId:t||"",assistantId:f?.id||"",fileName:y},isMatch:Y=>Y.resourcePath===k}),m.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),ne(null),U(""),He(""),ce(Y=>{let H={...Y};return delete H[k],H})}catch(y){m.error(y.message||"Failed to pin")}finally{ft(!1)}},qt=(0,ie.useCallback)(async(y,Y)=>{ce(H=>({...H,[y]:{...H[y],loading:!0}}));try{await D(Y),m.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),ce(H=>({...H,[y]:{isPinned:!1,pinnedId:null,loading:!1}}))}catch(H){m.error(H.message||"Failed to unpin"),ce(_=>({..._,[y]:{..._[y],loading:!1}}))}},[D,m]),Hn=(0,ie.useCallback)(async y=>{Z(y);try{let Y=await j(y,f?.id),H=URL.createObjectURL(Y),_=document.createElement("a");_.href=H;let Ke=y.replace(/\/$/,"").split("/").pop()||"folder";_.download=`${Ke}.zip`,_.click(),window.setTimeout(()=>URL.revokeObjectURL(H),0)}catch(Y){m.error(Y instanceof Error?Y.message:"Failed to download folder")}finally{Z(null)}},[j,f?.id,m]),Do=ie.default.useCallback((y,Y)=>{let H=an(y);if(y.is_dir){let _=c[y.path]||!1,Ke=a[y.path]||[],ba=d[y.path]||!1;return(0,h.jsxs)("div",{className:g.treeChildren,children:[(0,h.jsxs)("div",{className:g.treeRow,children:[Array.from({length:Y}).map((Xe,va)=>(0,h.jsx)("span",{className:g.treeIndent},`${y.path}-indent-${va}`)),(0,h.jsx)("button",{type:"button",className:g.treeToggle,"aria-label":`${_?"collapse":"expand"} ${H}`,onClick:()=>void x(y.path),children:(0,h.jsx)(Nt,{size:14,style:{transform:_?"rotate(90deg)":void 0}})}),(0,h.jsxs)("button",{type:"button",className:g.assetItem,"aria-label":`toggle ${H}`,onClick:()=>void x(y.path),title:H,children:[(0,h.jsx)("div",{className:g.assetIcon,children:(0,h.jsx)(st,{size:14})}),(0,h.jsx)("div",{className:g.assetInfo,children:(0,h.jsx)("div",{className:g.assetName,children:H})})]}),(0,h.jsx)(qe,{trigger:["click"],onOpenChange:Xe=>Kt(y.path,Xe),menu:{items:[...$?T[y.path]?.isPinned?[{key:"unpin",icon:(0,h.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let Xe=T[y.path];Xe?.pinnedId&&qt(y.path,Xe.pinnedId)}}]:[{key:"pin",icon:(0,h.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{ne(y.path),U(H),He("")}}]:[],{key:"preview",icon:(0,h.jsx)(Qt,{}),label:"Preview",onClick:()=>{let Xe=A(y.path);Xe&&ee({component_key:"attachments",data:{file_id:y.path,url:Xe},message:H})}},{key:"share",icon:(0,h.jsx)(Yt,{}),label:"Share",onClick:()=>B(y.path)},{key:"download-folder",icon:(0,h.jsx)(Lo,{}),label:"Download",disabled:J===y.path,onClick:()=>{Hn(y.path)}}]},children:(0,h.jsx)(z,{type:"text",size:"small",icon:(0,h.jsx)(yt,{})})})]}),_?ba?(0,h.jsx)("div",{className:g.loading,children:(0,h.jsx)(re,{size:"small"})}):Ke.length>0?Lt(Ke,fe,Ye).map(Xe=>Do(Xe,Y+1)):(0,h.jsx)("div",{className:g.emptyState,children:"No files in this folder"}):null]},y.path)}return(0,h.jsxs)("div",{className:g.treeRow,children:[Array.from({length:Y}).map((_,Ke)=>(0,h.jsx)("span",{className:g.treeIndent},`${y.path}-indent-${Ke}`)),(0,h.jsx)("span",{className:g.treeSpacer}),(0,h.jsx)(je,{title:Ka(y),placement:"rightTop",children:(0,h.jsxs)("button",{type:"button",className:g.assetItem,onClick:()=>v(y),"aria-label":`open ${H}`,children:[(0,h.jsx)("div",{className:g.assetIcon,children:jr(H)}),(0,h.jsx)("div",{className:g.assetInfo,children:(0,h.jsx)("div",{className:g.assetName,children:H})})]})}),(0,h.jsx)(qe,{trigger:["click"],onOpenChange:_=>Kt(y.path,_),menu:{items:[...$?T[y.path]?.isPinned?[{key:"unpin",icon:(0,h.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let _=T[y.path];_?.pinnedId&&qt(y.path,_.pinnedId)}}]:[{key:"pin",icon:(0,h.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{ne(y.path),U(""),He("")}}]:[],{key:"preview",icon:(0,h.jsx)(Qt,{}),label:"Preview",onClick:()=>v(y)},{key:"download",icon:(0,h.jsx)(Lo,{}),label:"Download",onClick:()=>{let _=W(y.path,f?.id);window.open(_,"_blank")}},{key:"share",icon:(0,h.jsx)(Yt,{}),label:"Share",onClick:()=>B(y.path)}]},children:(0,h.jsx)(z,{type:"text",size:"small",icon:(0,h.jsx)(yt,{})})})]},y.path)},[a,c,d,v,x,g,W,j,f?.id,$,T,Kt,qt,J,Hn,fe,Ye]),Kn=(y,Y)=>{if(!y.is_dir)return Do(y,Y);let H=an(y);return(0,h.jsxs)("div",{className:g.treeChildren,children:[(0,h.jsxs)("div",{className:g.treeRow,children:[Array.from({length:Y}).map((_,Ke)=>(0,h.jsx)("span",{className:g.treeIndent},`${y.path}-indent-${Ke}`)),(0,h.jsx)("span",{className:g.treeSpacer}),(0,h.jsxs)("button",{type:"button",className:g.assetItem,title:H,children:[(0,h.jsx)("div",{className:g.assetIcon,children:(0,h.jsx)(st,{size:14})}),(0,h.jsx)("div",{className:g.assetInfo,children:(0,h.jsx)("div",{className:g.assetName,children:H})})]}),(0,h.jsx)(qe,{trigger:["click"],onOpenChange:_=>Kt(y.path,_),menu:{items:[...$?T[y.path]?.isPinned?[{key:"unpin",icon:(0,h.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let _=T[y.path];_?.pinnedId&&qt(y.path,_.pinnedId)}}]:[{key:"pin",icon:(0,h.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{ne(y.path),U(H),He("")}}]:[],{key:"preview",icon:(0,h.jsx)(Qt,{}),label:"Preview",onClick:()=>{let _=A(y.path);_&&ee({component_key:"attachments",data:{file_id:y.path,url:_},message:H})}},{key:"share",icon:(0,h.jsx)(Yt,{}),label:"Share",onClick:()=>B(y.path)}]},children:(0,h.jsx)(z,{type:"text",size:"small",icon:(0,h.jsx)(yt,{})})})]}),y.children&&y.children.length>0?Lt(y.children,fe,Ye).map(_=>Kn(_,Y+1)):null]},y.path)};return t?(0,h.jsxs)("div",{className:g.container,children:[(0,h.jsxs)("h3",{className:g.header,children:[(0,h.jsx)(st,{size:16}),(0,h.jsx)("span",{children:"Files"})]}),(0,h.jsxs)("div",{className:g.toolbar,children:[(0,h.jsx)(K,{size:"small",placeholder:"Search files\u2026",allowClear:!0,value:rt,onChange:y=>O(y.target.value)}),(0,h.jsxs)("div",{className:g.toolbarRow,children:[(0,h.jsx)(Ne,{size:"small",style:{flex:1,minWidth:0},value:fe,onChange:y=>it(y),options:[{value:"name",label:"Name"},{value:"created",label:"Created"},{value:"modified",label:"Modified"}]}),(0,h.jsx)(z,{size:"small",icon:Ye==="asc"?(0,h.jsx)(Xt,{}):(0,h.jsx)(Jt,{}),onClick:()=>fa(y=>y==="asc"?"desc":"asc"),title:Ye==="asc"?"Ascending":"Descending"})]})]}),Ht!==null?(0,h.jsx)("div",{className:g.assetList,children:ya?(0,h.jsx)("div",{className:g.loading,children:(0,h.jsx)(re,{size:"small"})}):Bo&&Bo.length>0?Bo.map(y=>Kn(y,0)):(0,h.jsxs)("div",{className:g.emptyState,children:['No files match "',rt.trim(),'"']})}):o.map(y=>{let Y=r[y.name]||[],H=s[y.name]||!1,_=Y.length;return(0,h.jsxs)("div",{className:g.section,children:[(0,h.jsxs)("div",{className:g.sectionHeader,children:[(0,h.jsx)("span",{className:g.sectionTitle,onClick:()=>void u(y),title:"Click to refresh",children:y.displayName||y.name}),(0,h.jsx)("span",{className:g.badge,children:_})]}),H?(0,h.jsx)("div",{className:g.loading,children:(0,h.jsx)(re,{size:"small"})}):(0,h.jsxs)("div",{className:g.assetList,children:[Lt(Y,fe,Ye).map(Ke=>Do(Ke,0)),Y.length===0?(0,h.jsx)("div",{className:g.emptyState,children:"No files in this folder"}):null,y.allowUpload?(0,h.jsx)("button",{type:"button",className:g.uploadBtn,onClick:()=>void b(y.name),disabled:!e||!t||p===y.name,children:p===y.name?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(re,{size:"small"}),(0,h.jsx)("span",{children:"Uploading..."})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nr,{size:14}),(0,h.jsx)("span",{children:"Upload"})]})}):null]})]},y.name)}),S&&(0,h.jsx)(zr,{open:!!S,filePath:S,assistantId:f?.id,fileName:S.split("/").pop(),onClose:()=>B(null)}),(0,h.jsx)(me,{title:"Pin to Menu",open:!!k,onOk:ha,onCancel:()=>ne(null),confirmLoading:Ze,okText:"Pin",children:(0,h.jsxs)("div",{style:qa,children:[(0,h.jsx)(K,{placeholder:"Menu name (required)",value:F,onChange:y=>U(y.target.value)}),(0,h.jsx)(Vt,{placeholder:"Group (optional, select or type new)",value:We,options:R.map(y=>({value:y})),onChange:y=>He(y),filterOption:(y,Y)=>Y?.value?.toUpperCase().includes(y.toUpperCase())??!1})]})})]}):(0,h.jsx)("div",{className:g.emptyState,children:"Please select a project to browse files"})};var li=n(i());var nm=C(({token:e,css:t})=>({root:t`
|
|
975
|
+
`})),si=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},Ha=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},an=e=>Ha(e.name||e.path),Ka=e=>(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{style:{fontWeight:600},children:an(e)}),e.created_at?(0,h.jsxs)("div",{children:["Created: ",si(e.created_at)]}):null,e.modified_at?(0,h.jsxs)("div",{children:["Modified: ",si(e.modified_at)]}):null]}),qa={display:"flex",flexDirection:"column",gap:12},sn=({workspaceId:e,projectId:t,resourceFolders:o,folderEntries:r,folderLoading:s,directoryChildren:a,directoryLoading:d,directoryExpanded:c,uploadingFolder:p,onRefreshFolder:u,onUploadFolder:b,onToggleDirectory:x,onAssetClick:v})=>{let{styles:g}=Ua(),{message:m}=Fo.useApp(),{currentAssistant:f}=et(),{getFileDownloadUrl:W,downloadFolder:j,getDirectFileUrl:A,listPathByFolder:X}=Se(),{openSideApp:ee}=ke(),{currentTenant:pe}=Oe(),Q=pe?.id||"",[S,B]=(0,ie.useState)(null),[J,Z]=(0,ie.useState)(null),{check:E,pin:se,unpin:D,enableCustomMenu:$,get:le}=uo(),L=ln(),[R,I]=(0,ie.useState)(L);(0,ie.useEffect)(()=>{I(L)},[L]);let[T,ce]=(0,ie.useState)({}),[k,ne]=(0,ie.useState)(null),[F,U]=(0,ie.useState)(""),[We,He]=(0,ie.useState)(""),[Ze,ft]=(0,ie.useState)(!1),[rt,O]=(0,ie.useState)(""),[fe,it]=(0,ie.useState)("name"),[Ye,fa]=(0,ie.useState)("asc"),[Ht,No]=(0,ie.useState)(null),[ya,Mo]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>{k&&cn(le).then(y=>{I(Array.from(new Set([...L,...y])).sort())})},[k]),(0,ie.useEffect)(()=>{let y=rt.trim();if(!y){No(null),Mo(!1);return}let Y=!1;return Mo(!0),$r(X,o.map(H=>H.name),f?.id).then(H=>{Y||No(ii(H,y))}).catch(()=>{Y||No([])}).finally(()=>{Y||Mo(!1)}),()=>{Y=!0}},[rt,X,o,f?.id]);let Bo=(0,ie.useMemo)(()=>Ht?rn(ai(Ht),fe,Ye):null,[Ht,fe,Ye]),Kt=(0,ie.useCallback)((y,Y)=>{if(!Y||!$)return;ce(_=>_[y]?_:{..._,[y]:{isPinned:!1,pinnedId:null,loading:!0}});let H={contentType:"file",contentConfig:{resourcePath:y,tenantId:Q,workspaceId:e||"",projectId:t||"",assistantId:f?.id||"",fileName:y.split("/").pop()||y},isMatch:_=>_.resourcePath===y};E(H).then(_=>{ce(Ke=>({...Ke,[y]:{..._,loading:!1}}))}).catch(()=>{ce(_=>({..._,[y]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[$,E,f?.id]),ha=async()=>{if(!k||!F.trim()){m.warning("Please enter a menu name");return}ft(!0);try{let y=k.split("/").pop()||k;await se({contentType:"file",name:F.trim(),group:We.trim()||void 0,contentConfig:{resourcePath:k,tenantId:Q,workspaceId:e||"",projectId:t||"",assistantId:f?.id||"",fileName:y},isMatch:Y=>Y.resourcePath===k}),m.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),ne(null),U(""),He(""),ce(Y=>{let H={...Y};return delete H[k],H})}catch(y){m.error(y.message||"Failed to pin")}finally{ft(!1)}},qt=(0,ie.useCallback)(async(y,Y)=>{ce(H=>({...H,[y]:{...H[y],loading:!0}}));try{await D(Y),m.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),ce(H=>({...H,[y]:{isPinned:!1,pinnedId:null,loading:!1}}))}catch(H){m.error(H.message||"Failed to unpin"),ce(_=>({..._,[y]:{..._[y],loading:!1}}))}},[D,m]),Hn=(0,ie.useCallback)(async y=>{Z(y);try{let Y=await j(y,f?.id),H=URL.createObjectURL(Y),_=document.createElement("a");_.href=H;let Ke=y.replace(/\/$/,"").split("/").pop()||"folder";_.download=`${Ke}.zip`,_.click(),window.setTimeout(()=>URL.revokeObjectURL(H),0)}catch(Y){m.error(Y instanceof Error?Y.message:"Failed to download folder")}finally{Z(null)}},[j,f?.id,m]),Do=ie.default.useCallback((y,Y)=>{let H=an(y);if(y.is_dir){let _=c[y.path]||!1,Ke=a[y.path]||[],ba=d[y.path]||!1;return(0,h.jsxs)("div",{className:g.treeChildren,children:[(0,h.jsxs)("div",{className:g.treeRow,children:[Array.from({length:Y}).map((Xe,va)=>(0,h.jsx)("span",{className:g.treeIndent},`${y.path}-indent-${va}`)),(0,h.jsx)("button",{type:"button",className:g.treeToggle,"aria-label":`${_?"collapse":"expand"} ${H}`,onClick:()=>void x(y.path),children:(0,h.jsx)(Mt,{size:14,style:{transform:_?"rotate(90deg)":void 0}})}),(0,h.jsxs)("button",{type:"button",className:g.assetItem,"aria-label":`toggle ${H}`,onClick:()=>void x(y.path),title:H,children:[(0,h.jsx)("div",{className:g.assetIcon,children:(0,h.jsx)(st,{size:14})}),(0,h.jsx)("div",{className:g.assetInfo,children:(0,h.jsx)("div",{className:g.assetName,children:H})})]}),(0,h.jsx)(qe,{trigger:["click"],onOpenChange:Xe=>Kt(y.path,Xe),menu:{items:[...$?T[y.path]?.isPinned?[{key:"unpin",icon:(0,h.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let Xe=T[y.path];Xe?.pinnedId&&qt(y.path,Xe.pinnedId)}}]:[{key:"pin",icon:(0,h.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{ne(y.path),U(H),He("")}}]:[],{key:"preview",icon:(0,h.jsx)(Qt,{}),label:"Preview",onClick:()=>{let Xe=A(y.path);Xe&&ee({component_key:"attachments",data:{file_id:y.path,url:Xe},message:H})}},{key:"share",icon:(0,h.jsx)(Yt,{}),label:"Share",onClick:()=>B(y.path)},{key:"download-folder",icon:(0,h.jsx)(Lo,{}),label:"Download",disabled:J===y.path,onClick:()=>{Hn(y.path)}}]},children:(0,h.jsx)(z,{type:"text",size:"small",icon:(0,h.jsx)(yt,{})})})]}),_?ba?(0,h.jsx)("div",{className:g.loading,children:(0,h.jsx)(re,{size:"small"})}):Ke.length>0?Lt(Ke,fe,Ye).map(Xe=>Do(Xe,Y+1)):(0,h.jsx)("div",{className:g.emptyState,children:"No files in this folder"}):null]},y.path)}return(0,h.jsxs)("div",{className:g.treeRow,children:[Array.from({length:Y}).map((_,Ke)=>(0,h.jsx)("span",{className:g.treeIndent},`${y.path}-indent-${Ke}`)),(0,h.jsx)("span",{className:g.treeSpacer}),(0,h.jsx)(je,{title:Ka(y),placement:"rightTop",children:(0,h.jsxs)("button",{type:"button",className:g.assetItem,onClick:()=>v(y),"aria-label":`open ${H}`,children:[(0,h.jsx)("div",{className:g.assetIcon,children:jr(H)}),(0,h.jsx)("div",{className:g.assetInfo,children:(0,h.jsx)("div",{className:g.assetName,children:H})})]})}),(0,h.jsx)(qe,{trigger:["click"],onOpenChange:_=>Kt(y.path,_),menu:{items:[...$?T[y.path]?.isPinned?[{key:"unpin",icon:(0,h.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let _=T[y.path];_?.pinnedId&&qt(y.path,_.pinnedId)}}]:[{key:"pin",icon:(0,h.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{ne(y.path),U(""),He("")}}]:[],{key:"preview",icon:(0,h.jsx)(Qt,{}),label:"Preview",onClick:()=>v(y)},{key:"download",icon:(0,h.jsx)(Lo,{}),label:"Download",onClick:()=>{let _=W(y.path,f?.id);window.open(_,"_blank")}},{key:"share",icon:(0,h.jsx)(Yt,{}),label:"Share",onClick:()=>B(y.path)}]},children:(0,h.jsx)(z,{type:"text",size:"small",icon:(0,h.jsx)(yt,{})})})]},y.path)},[a,c,d,v,x,g,W,j,f?.id,$,T,Kt,qt,J,Hn,fe,Ye]),Kn=(y,Y)=>{if(!y.is_dir)return Do(y,Y);let H=an(y);return(0,h.jsxs)("div",{className:g.treeChildren,children:[(0,h.jsxs)("div",{className:g.treeRow,children:[Array.from({length:Y}).map((_,Ke)=>(0,h.jsx)("span",{className:g.treeIndent},`${y.path}-indent-${Ke}`)),(0,h.jsx)("span",{className:g.treeSpacer}),(0,h.jsxs)("button",{type:"button",className:g.assetItem,title:H,children:[(0,h.jsx)("div",{className:g.assetIcon,children:(0,h.jsx)(st,{size:14})}),(0,h.jsx)("div",{className:g.assetInfo,children:(0,h.jsx)("div",{className:g.assetName,children:H})})]}),(0,h.jsx)(qe,{trigger:["click"],onOpenChange:_=>Kt(y.path,_),menu:{items:[...$?T[y.path]?.isPinned?[{key:"unpin",icon:(0,h.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let _=T[y.path];_?.pinnedId&&qt(y.path,_.pinnedId)}}]:[{key:"pin",icon:(0,h.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{ne(y.path),U(H),He("")}}]:[],{key:"preview",icon:(0,h.jsx)(Qt,{}),label:"Preview",onClick:()=>{let _=A(y.path);_&&ee({component_key:"attachments",data:{file_id:y.path,url:_},message:H})}},{key:"share",icon:(0,h.jsx)(Yt,{}),label:"Share",onClick:()=>B(y.path)}]},children:(0,h.jsx)(z,{type:"text",size:"small",icon:(0,h.jsx)(yt,{})})})]}),y.children&&y.children.length>0?Lt(y.children,fe,Ye).map(_=>Kn(_,Y+1)):null]},y.path)};return t?(0,h.jsxs)("div",{className:g.container,children:[(0,h.jsxs)("h3",{className:g.header,children:[(0,h.jsx)(st,{size:16}),(0,h.jsx)("span",{children:"Files"})]}),(0,h.jsxs)("div",{className:g.toolbar,children:[(0,h.jsx)(K,{size:"small",placeholder:"Search files\u2026",allowClear:!0,value:rt,onChange:y=>O(y.target.value)}),(0,h.jsxs)("div",{className:g.toolbarRow,children:[(0,h.jsx)(Me,{size:"small",style:{flex:1,minWidth:0},value:fe,onChange:y=>it(y),options:[{value:"name",label:"Name"},{value:"created",label:"Created"},{value:"modified",label:"Modified"}]}),(0,h.jsx)(z,{size:"small",icon:Ye==="asc"?(0,h.jsx)(Xt,{}):(0,h.jsx)(Jt,{}),onClick:()=>fa(y=>y==="asc"?"desc":"asc"),title:Ye==="asc"?"Ascending":"Descending"})]})]}),Ht!==null?(0,h.jsx)("div",{className:g.assetList,children:ya?(0,h.jsx)("div",{className:g.loading,children:(0,h.jsx)(re,{size:"small"})}):Bo&&Bo.length>0?Bo.map(y=>Kn(y,0)):(0,h.jsxs)("div",{className:g.emptyState,children:['No files match "',rt.trim(),'"']})}):o.map(y=>{let Y=r[y.name]||[],H=s[y.name]||!1,_=Y.length;return(0,h.jsxs)("div",{className:g.section,children:[(0,h.jsxs)("div",{className:g.sectionHeader,children:[(0,h.jsx)("span",{className:g.sectionTitle,onClick:()=>void u(y),title:"Click to refresh",children:y.displayName||y.name}),(0,h.jsx)("span",{className:g.badge,children:_})]}),H?(0,h.jsx)("div",{className:g.loading,children:(0,h.jsx)(re,{size:"small"})}):(0,h.jsxs)("div",{className:g.assetList,children:[Lt(Y,fe,Ye).map(Ke=>Do(Ke,0)),Y.length===0?(0,h.jsx)("div",{className:g.emptyState,children:"No files in this folder"}):null,y.allowUpload?(0,h.jsx)("button",{type:"button",className:g.uploadBtn,onClick:()=>void b(y.name),disabled:!e||!t||p===y.name,children:p===y.name?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(re,{size:"small"}),(0,h.jsx)("span",{children:"Uploading..."})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Mr,{size:14}),(0,h.jsx)("span",{children:"Upload"})]})}):null]})]},y.name)}),S&&(0,h.jsx)(zr,{open:!!S,filePath:S,assistantId:f?.id,fileName:S.split("/").pop(),onClose:()=>B(null)}),(0,h.jsx)(me,{title:"Pin to Menu",open:!!k,onOk:ha,onCancel:()=>ne(null),confirmLoading:Ze,okText:"Pin",children:(0,h.jsxs)("div",{style:qa,children:[(0,h.jsx)(K,{placeholder:"Menu name (required)",value:F,onChange:y=>U(y.target.value)}),(0,h.jsx)(Vt,{placeholder:"Group (optional, select or type new)",value:We,options:R.map(y=>({value:y})),onChange:y=>He(y),filterOption:(y,Y)=>Y?.value?.toUpperCase().includes(y.toUpperCase())??!1})]})})]}):(0,h.jsx)("div",{className:g.emptyState,children:"Please select a project to browse files"})};var li=n(i());var nm=C(({token:e,css:t})=>({root:t`
|
|
971
976
|
display: flex;
|
|
972
977
|
flex-direction: column;
|
|
973
978
|
height: 100%;
|
|
@@ -1424,7 +1429,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
1424
1429
|
&.active {
|
|
1425
1430
|
color: ${e.colorPrimary};
|
|
1426
1431
|
}
|
|
1427
|
-
`}));var ls=n(i());var Wt=n(w());var go=18,Uu={agent:Wt.default.createElement(
|
|
1432
|
+
`}));var ls=n(i());var Wt=n(w());var go=18,Uu={agent:Wt.default.createElement(Nt,{size:go}),html:Wt.default.createElement(wr,{size:go}),custom:Wt.default.createElement(Ar,{size:go}),file:Wt.default.createElement(vr,{size:go})};var xs=n(w());var cs=n(w());var yi=n(i());var Ii=n(w());var fo=n(w());var pt=n(w());function hi(e){let{get:t}=ue(),[o,r]=(0,pt.useState)(null),[s,a]=(0,pt.useState)(!0),[d,c]=(0,pt.useState)(!1);(0,pt.useEffect)(()=>{let b=!0,x=e||"/api/middleware-types";return a(!0),c(!1),r(null),t(x).then(v=>{if(!b)return;if(!Array.isArray(v)||v.length===0){c(!0);return}let g=v.map(m=>({type:m.type,name:m.name,description:m.description,icon:m.icon,tools:Array.isArray(m.tools)?m.tools.map(f=>({id:f.name,name:f.name,description:f.description})):[],schema:m.configSchema,defaultConfig:m.defaultConfig||{},category:m.category,capabilityBundleEligible:m.capabilityBundleEligible===!0,connectionSchema:m.connectionSchema?{fields:m.connectionSchema.fields,hasTest:m.connectionSchema.hasTest,hasDiscover:m.connectionSchema.hasDiscover,resourceLabel:m.connectionSchema.resourceLabel}:void 0}));r(g)}).catch(()=>{b&&c(!0)}).finally(()=>{b&&a(!1)}),()=>{b=!1}},[e,t]);let p=new Set(["topology"]);return{middlewareTypes:(0,pt.useMemo)(()=>(o||er).filter(b=>!p.has(b.type)),[o]),isLoading:s,isFallback:d}}var bi=C(({token:e,css:t})=>({nav:t`
|
|
1428
1433
|
width: clamp(180px, 20vw, 240px);
|
|
1429
1434
|
flex-shrink: 0;
|
|
1430
1435
|
border-right: 1px solid ${e.colorBorderSecondary};
|
|
@@ -1607,7 +1612,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
1607
1612
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1608
1613
|
gap: 12px 16px;
|
|
1609
1614
|
padding: 8px 0;
|
|
1610
|
-
`})),yo=({title:e,selectedCount:t,totalCount:o,searchPlaceholder:r,searchText:s,onSearchChange:a,onSelectAll:d,onClearAll:c,children:p,styles:u})=>{let b=o>0&&t===o;return(0,l.jsxs)("div",{className:u.dataSection,children:[(0,l.jsxs)("div",{className:u.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:[e,(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t," / ",o," selected"]})]}),(0,l.jsx)(de,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:b?c:d,children:b?"Clear":"Select All"})})]}),(0,l.jsx)("div",{style:{marginBottom:10},children:(0,l.jsx)(K,{size:"small",allowClear:!0,prefix:(0,l.jsx)(pr,{style:{fontSize:12}}),placeholder:r,value:s,onChange:x=>a(x.target.value),style:{width:"100%"}})}),(0,l.jsx)("div",{className:u.dataList,children:p})]})},ds=({text:e,className:t})=>(0,l.jsx)(je,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),ps=({tools:e,selectedToolNames:t,allToolNames:o,onChange:r,styles:s})=>{let a=e.length>0&&t.length===o.length,d=c=>{if(t.includes(c)){let p=t.filter(u=>u!==c);r(p.length===0?void 0:p)}else{let p=[...t,c];r(p.length===o.length&&o.every(u=>p.includes(u))?void 0:p)}};return(0,l.jsxs)("div",{className:s.dataSection,children:[(0,l.jsxs)("div",{className:s.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Tools",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t.length," / ",o.length," selected"]})]}),(0,l.jsx)(de,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:()=>r(a?[]:void 0),children:a?"Clear":"Select All"})})]}),(0,l.jsx)("div",{className:s.toolsGrid,children:e.map(c=>{let p=t.includes(c.name);return(0,l.jsx)(Dt,{item:c,dense:!0,className:p?s.selectedCard:void 0,onClick:()=>d(c.name),renderIcon:()=>(0,l.jsx)("span",{style:{fontSize:14,fontWeight:600},children:c.name.charAt(0).toUpperCase()}),renderPrimary:()=>c.name,renderDetails:()=>(0,l.jsx)(ds,{text:c.description,className:s.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(_e,{checked:p,onClick:u=>u.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},ms=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let f=await b("/api/skills");f.success&&f.data&&Array.isArray(f.data.records)&&a(f.data.records)}catch(f){console.error("Failed to fetch skills:",f)}finally{c(!1)}})()},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>m.name.toLowerCase().includes(p.toLowerCase())||m.description.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Skill Library",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search skills\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.id)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No skills available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.id);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.id):[...v,m.id]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description})})},m.id)}})})},us=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let f=await b("/api/database-configs");f.success&&f.data&&Array.isArray(f.data.records)&&a(f.data.records)}catch(f){console.error("Failed to fetch database configs:",f)}finally{c(!1)}})()},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Databases",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search databases\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No databases available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.key);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.key):[...v,m.key]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},gs=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let f=await b("/api/metrics-configs");f.success&&f.data&&Array.isArray(f.data.records)&&a(f.data.records)}catch(f){console.error("Failed to fetch metrics configs:",f)}finally{c(!1)}})()},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Metrics Servers",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search servers\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No servers available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.key);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.key):[...v,m.key]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},fs=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{x.current||(x.current=!0,c(!0),b("/api/collections").then(m=>{m.success&&a(m.data.records)}).catch(()=>{}).finally(()=>c(!1)))},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>(m.label||m.name).toLowerCase().includes(p.toLowerCase())||m.name.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Collections",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search collections\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.name)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No collections available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.name);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.name):[...v,m.name]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.label||m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.name})})},m.name)}})})},ys=({value:e,onChange:t,token:o,styles:r})=>{let s=Array.isArray(e)?e:[],[a,d]=(0,ge.useState)({from:"",to:"",purpose:""}),c=()=>{!a.from.trim()||!a.to.trim()||!a.purpose.trim()||(t([...s,{...a}]),d({from:"",to:"",purpose:""}))};return(0,l.jsxs)("div",{className:r.dataSection,children:[(0,l.jsx)("div",{className:r.dataSectionHeader,children:(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Dependencies",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[s.length," edges"]})]})}),(0,l.jsx)("div",{className:r.dataList,children:s.length===0?(0,l.jsx)(xe,{description:"No dependencies defined yet",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):s.map((p,u)=>(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",marginBottom:4,borderRadius:o.borderRadius,backgroundColor:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`},children:[(0,l.jsx)(be,{color:"blue",style:{margin:0,fontSize:11},children:p.from}),(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},children:"\u2192"}),(0,l.jsx)(be,{color:"green",style:{margin:0,fontSize:11},children:p.to}),(0,l.jsx)(we,{style:{fontSize:12,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.purpose}),(0,l.jsx)(z,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(rr,{}),onClick:()=>t(s.filter((b,x)=>x!==u))})]},u))}),(0,l.jsxs)("div",{style:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:12,marginTop:12},children:[(0,l.jsx)(we,{strong:!0,style:{fontSize:13,display:"block",marginBottom:8},children:"Add Dependency"}),(0,l.jsxs)(de,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,l.jsx)(K,{size:"small",placeholder:"Source Agent ID",value:a.from,onChange:p=>d({...a,from:p.target.value})}),(0,l.jsx)(K,{size:"small",placeholder:"Target Agent ID",value:a.to,onChange:p=>d({...a,to:p.target.value})}),(0,l.jsx)(K,{size:"small",placeholder:"Purpose (e.g. classify invoice fields)",value:a.purpose,onChange:p=>d({...a,purpose:p.target.value}),onPressEnter:c}),(0,l.jsx)(z,{type:"dashed",size:"small",icon:(0,l.jsx)(cr,{}),onClick:c,disabled:!a.from.trim()||!a.to.trim()||!a.purpose.trim(),block:!0,children:"Add Edge"})]})]})]})},Ci=(e,t,o,r,s)=>{let a=t.title||e,d=t.description?(0,l.jsx)(je,{title:t.description,children:(0,l.jsx)(dr,{style:{color:s.colorTextSecondary,cursor:"pointer"}})}):null;if(t.widget==="switch"||!t.widget&&t.type==="boolean")return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:a}),d]}),(0,l.jsx)(Ct,{size:"small",checked:o,onChange:r})]},e),gridItem:null};if(t.widget==="segmented"){let u=t.enum?.map(b=>({value:b,label:{global:"Global",agent:"Agent",project:"Project"}[b]||b}))||[];return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:a}),d]}),(0,l.jsx)(qn,{size:"small",value:o,onChange:r,options:u})]},e),gridItem:null}}let c=(0,l.jsxs)("span",{children:[a,d&&(0,l.jsxs)(l.Fragment,{children:["\xA0",d]})]}),p;if(t.type==="number"||t.type==="integer")p=(0,l.jsx)(K,{size:"small",type:"number",value:o,onChange:u=>r(parseFloat(u.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}});else if(t.widget==="select"||t.enum&&!t.widget){let u=t.enumLabels,b=u?Object.entries(u).map(([x,v])=>({value:x,label:v})):t.enum?.map(x=>({value:x,label:x}))||[];p=(0,l.jsx)(Ne,{size:"small",value:o,onChange:r,options:b,style:{width:"100%"}})}else t.widget==="textarea"?p=(0,l.jsx)(K.TextArea,{size:"small",value:o,onChange:u=>r(u.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}}):p=(0,l.jsx)(K,{size:"small",value:o,onChange:u=>r(u.target.value),placeholder:t.default});return{row:null,gridItem:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,l.jsx)(we,{style:{fontSize:12,color:s.colorTextSecondary},children:c}),p]},e)}},Si=({type:e})=>{let{token:t}=Le.useToken();switch(e){case"browser":return(0,l.jsx)(sr,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(_o,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(ur,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(ar,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(or,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Zt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(mr,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(ir,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(_o,{style:{color:t.colorInfo}});default:return(0,l.jsx)(lr,{style:{color:t.colorWarning}})}},hs=({middleware:e,middlewareType:t,onToggle:o,onConfigChange:r,onAllowedToolsChange:s,enabledAriaLabel:a,sectionTitles:d,headerActions:c,token:p,styles:u,renderListSubSection:b})=>{let x=t?.schema?.properties??{},v=Object.keys(x),g=v.filter(S=>{let B=x[S];return B.widget==="skillSelect"||B.widget==="databaseSelect"||B.widget==="metricsSelect"||B.widget==="collectionSelect"||B.widget==="connectionSelect"||B.widget==="topologyEdgeBuilder"}),m=v.filter(S=>{let B=x[S];return g.includes(S)?!1:B.widget==="switch"||B.widget==="segmented"}),f=v.filter(S=>!(g.includes(S)||m.includes(S)||S==="vmIsolation")),W=g.filter(S=>{let B=x[S];return S==="skills"&&e.config.readAll===!0||S==="serverKeys"&&e.config.connectAll===!0||S==="collectionKeys"&&e.config.connectAll===!0||S==="connections"&&e.config.connectAll===!0?!1:!!B.widget}),j=()=>(0,l.jsxs)(l.Fragment,{children:[m.map(S=>{let B=x[S],{row:J}=Ci(S,B,e.config[S]??B.default,Z=>r({[S]:Z}),p);return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:J},S)}),f.length>0&&(0,l.jsx)("div",{className:u.configGrid,children:f.map(S=>{let B=x[S],{gridItem:J}=Ci(S,B,e.config[S]??B.default,Z=>r({[S]:Z}),p);return J})})]}),A=t?.tools,X=A?.map(S=>S.name)??[],ee=e.allowedTools??X,pe=A&&A.length>0,Q=m.length>0||f.length>0;return(0,l.jsxs)("div",{style:{maxWidth:960},children:[(0,l.jsxs)("div",{className:u.pageHeader,children:[(0,l.jsx)("div",{className:u.pageIcon,children:(0,l.jsx)(Si,{type:e.type})}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("h2",{className:u.pageName,children:e.name}),(0,l.jsx)("p",{className:u.pageDesc,children:e.description})]}),(0,l.jsxs)(de,{size:10,children:[c,(0,l.jsx)(be,{color:e.enabled?"success":"default",style:{margin:0,fontSize:11},children:e.enabled?"Enabled":"Disabled"}),(0,l.jsx)(Ct,{"aria-label":a,checked:e.enabled,onChange:S=>{if(o(),S){let B=t;B?.defaultConfig&&!e.config&&r(B.defaultConfig)}}})]})]}),Q&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:u.blockTitle,children:d?.config??"Config"}),(0,l.jsx)("div",{style:{marginTop:12},children:j()})]}),W.length>0&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:u.blockTitle,style:{marginBottom:4},children:d?.resources??"Resources Permission"}),W.map(S=>{let B=x[S],J=e.config[S]??B.default??[];return b(S,B,J,Z=>r({[S]:Z}),e.type)})]}),pe&&A&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:u.blockTitle,style:{marginBottom:4},children:d?.tools??"Tools Permission"}),(0,l.jsx)(ps,{tools:A,selectedToolNames:ee,allToolNames:X,onChange:s,styles:u})]})]})},bs=e=>{let{token:t}=Le.useToken(),{styles:o}=gn();return(0,l.jsx)(hs,{...e,token:t,styles:o,renderListSubSection:(s,a,d,c,p)=>{switch(a.widget){case"skillSelect":return(0,l.jsx)(ms,{value:d,onChange:c,token:t,styles:o},s);case"databaseSelect":return(0,l.jsx)(us,{value:d,onChange:c,token:t,styles:o},s);case"metricsSelect":return(0,l.jsx)(gs,{value:d,onChange:c,token:t,styles:o},s);case"collectionSelect":return(0,l.jsx)(fs,{value:d,onChange:c,token:t,styles:o},s);case"connectionSelect":return(0,l.jsxs)("div",{className:o.dataSection,children:[(0,l.jsx)("div",{className:o.dataSectionHeader,children:(0,l.jsx)(we,{strong:!0,style:{fontSize:13},children:a.title||"Connections"})}),(0,l.jsx)(wi,{connectionType:a.connectionType??(s==="connections"?p:""),value:d||[],onChange:c})]},s);case"topologyEdgeBuilder":return(0,l.jsx)(ys,{value:d,onChange:c,token:t,styles:o},s);default:return null}}})};var ki=n(i()),{Text:Sg}=P,kg=C(({css:e,token:t})=>({toolRow:e`
|
|
1615
|
+
`})),yo=({title:e,selectedCount:t,totalCount:o,searchPlaceholder:r,searchText:s,onSearchChange:a,onSelectAll:d,onClearAll:c,children:p,styles:u})=>{let b=o>0&&t===o;return(0,l.jsxs)("div",{className:u.dataSection,children:[(0,l.jsxs)("div",{className:u.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:[e,(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t," / ",o," selected"]})]}),(0,l.jsx)(de,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:b?c:d,children:b?"Clear":"Select All"})})]}),(0,l.jsx)("div",{style:{marginBottom:10},children:(0,l.jsx)(K,{size:"small",allowClear:!0,prefix:(0,l.jsx)(pr,{style:{fontSize:12}}),placeholder:r,value:s,onChange:x=>a(x.target.value),style:{width:"100%"}})}),(0,l.jsx)("div",{className:u.dataList,children:p})]})},ds=({text:e,className:t})=>(0,l.jsx)(je,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),ps=({tools:e,selectedToolNames:t,allToolNames:o,onChange:r,styles:s})=>{let a=e.length>0&&t.length===o.length,d=c=>{if(t.includes(c)){let p=t.filter(u=>u!==c);r(p.length===0?void 0:p)}else{let p=[...t,c];r(p.length===o.length&&o.every(u=>p.includes(u))?void 0:p)}};return(0,l.jsxs)("div",{className:s.dataSection,children:[(0,l.jsxs)("div",{className:s.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Tools",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t.length," / ",o.length," selected"]})]}),(0,l.jsx)(de,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:()=>r(a?[]:void 0),children:a?"Clear":"Select All"})})]}),(0,l.jsx)("div",{className:s.toolsGrid,children:e.map(c=>{let p=t.includes(c.name);return(0,l.jsx)(Dt,{item:c,dense:!0,className:p?s.selectedCard:void 0,onClick:()=>d(c.name),renderIcon:()=>(0,l.jsx)("span",{style:{fontSize:14,fontWeight:600},children:c.name.charAt(0).toUpperCase()}),renderPrimary:()=>c.name,renderDetails:()=>(0,l.jsx)(ds,{text:c.description,className:s.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(_e,{checked:p,onClick:u=>u.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},ms=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let f=await b("/api/skills");f.success&&f.data&&Array.isArray(f.data.records)&&a(f.data.records)}catch(f){console.error("Failed to fetch skills:",f)}finally{c(!1)}})()},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>m.name.toLowerCase().includes(p.toLowerCase())||m.description.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Skill Library",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search skills\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.id)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No skills available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.id);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.id):[...v,m.id]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description})})},m.id)}})})},us=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let f=await b("/api/database-configs");f.success&&f.data&&Array.isArray(f.data.records)&&a(f.data.records)}catch(f){console.error("Failed to fetch database configs:",f)}finally{c(!1)}})()},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Databases",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search databases\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No databases available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.key);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.key):[...v,m.key]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},gs=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let f=await b("/api/metrics-configs");f.success&&f.data&&Array.isArray(f.data.records)&&a(f.data.records)}catch(f){console.error("Failed to fetch metrics configs:",f)}finally{c(!1)}})()},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Metrics Servers",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search servers\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No servers available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.key);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.key):[...v,m.key]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},fs=({value:e,onChange:t,token:o,styles:r})=>{let[s,a]=(0,ge.useState)([]),[d,c]=(0,ge.useState)(!1),[p,u]=(0,ge.useState)(""),{get:b}=ue(),x=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>{x.current||(x.current=!0,c(!0),b("/api/collections").then(m=>{m.success&&a(m.data.records)}).catch(()=>{}).finally(()=>c(!1)))},[b]);let v=Array.isArray(e)?e:[],g=s.filter(m=>(m.label||m.name).toLowerCase().includes(p.toLowerCase())||m.name.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(yo,{title:"Collections",selectedCount:v.length,totalCount:s.length,searchPlaceholder:"Search collections\u2026",searchText:p,onSearchChange:u,onSelectAll:()=>t(s.map(m=>m.name)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(re,{size:"small"})}):g.length===0?(0,l.jsx)(xe,{description:"No collections available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Pe,{dataSource:g,split:!1,size:"small",renderItem:m=>{let f=v.includes(m.name);return(0,l.jsx)(Pe.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:f?o.colorSuccessBg:"transparent",border:`1px solid ${f?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(f?v.filter(W=>W!==m.name):[...v,m.name]),children:(0,l.jsx)(Pe.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:f}),title:(0,l.jsx)(we,{strong:f,style:{fontSize:13},children:m.label||m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.name})})},m.name)}})})},ys=({value:e,onChange:t,token:o,styles:r})=>{let s=Array.isArray(e)?e:[],[a,d]=(0,ge.useState)({from:"",to:"",purpose:""}),c=()=>{!a.from.trim()||!a.to.trim()||!a.purpose.trim()||(t([...s,{...a}]),d({from:"",to:"",purpose:""}))};return(0,l.jsxs)("div",{className:r.dataSection,children:[(0,l.jsx)("div",{className:r.dataSectionHeader,children:(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Dependencies",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[s.length," edges"]})]})}),(0,l.jsx)("div",{className:r.dataList,children:s.length===0?(0,l.jsx)(xe,{description:"No dependencies defined yet",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):s.map((p,u)=>(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",marginBottom:4,borderRadius:o.borderRadius,backgroundColor:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`},children:[(0,l.jsx)(be,{color:"blue",style:{margin:0,fontSize:11},children:p.from}),(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},children:"\u2192"}),(0,l.jsx)(be,{color:"green",style:{margin:0,fontSize:11},children:p.to}),(0,l.jsx)(we,{style:{fontSize:12,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.purpose}),(0,l.jsx)(z,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(rr,{}),onClick:()=>t(s.filter((b,x)=>x!==u))})]},u))}),(0,l.jsxs)("div",{style:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:12,marginTop:12},children:[(0,l.jsx)(we,{strong:!0,style:{fontSize:13,display:"block",marginBottom:8},children:"Add Dependency"}),(0,l.jsxs)(de,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,l.jsx)(K,{size:"small",placeholder:"Source Agent ID",value:a.from,onChange:p=>d({...a,from:p.target.value})}),(0,l.jsx)(K,{size:"small",placeholder:"Target Agent ID",value:a.to,onChange:p=>d({...a,to:p.target.value})}),(0,l.jsx)(K,{size:"small",placeholder:"Purpose (e.g. classify invoice fields)",value:a.purpose,onChange:p=>d({...a,purpose:p.target.value}),onPressEnter:c}),(0,l.jsx)(z,{type:"dashed",size:"small",icon:(0,l.jsx)(cr,{}),onClick:c,disabled:!a.from.trim()||!a.to.trim()||!a.purpose.trim(),block:!0,children:"Add Edge"})]})]})]})},Ci=(e,t,o,r,s)=>{let a=t.title||e,d=t.description?(0,l.jsx)(je,{title:t.description,children:(0,l.jsx)(dr,{style:{color:s.colorTextSecondary,cursor:"pointer"}})}):null;if(t.widget==="switch"||!t.widget&&t.type==="boolean")return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:a}),d]}),(0,l.jsx)(Ct,{size:"small",checked:o,onChange:r})]},e),gridItem:null};if(t.widget==="segmented"){let u=t.enum?.map(b=>({value:b,label:{global:"Global",agent:"Agent",project:"Project"}[b]||b}))||[];return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:a}),d]}),(0,l.jsx)(qn,{size:"small",value:o,onChange:r,options:u})]},e),gridItem:null}}let c=(0,l.jsxs)("span",{children:[a,d&&(0,l.jsxs)(l.Fragment,{children:["\xA0",d]})]}),p;if(t.type==="number"||t.type==="integer")p=(0,l.jsx)(K,{size:"small",type:"number",value:o,onChange:u=>r(parseFloat(u.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}});else if(t.widget==="select"||t.enum&&!t.widget){let u=t.enumLabels,b=u?Object.entries(u).map(([x,v])=>({value:x,label:v})):t.enum?.map(x=>({value:x,label:x}))||[];p=(0,l.jsx)(Me,{size:"small",value:o,onChange:r,options:b,style:{width:"100%"}})}else t.widget==="textarea"?p=(0,l.jsx)(K.TextArea,{size:"small",value:o,onChange:u=>r(u.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}}):p=(0,l.jsx)(K,{size:"small",value:o,onChange:u=>r(u.target.value),placeholder:t.default});return{row:null,gridItem:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,l.jsx)(we,{style:{fontSize:12,color:s.colorTextSecondary},children:c}),p]},e)}},Si=({type:e})=>{let{token:t}=Le.useToken();switch(e){case"browser":return(0,l.jsx)(sr,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(_o,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(ur,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(ar,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(or,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Zt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(mr,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(ir,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(_o,{style:{color:t.colorInfo}});default:return(0,l.jsx)(lr,{style:{color:t.colorWarning}})}},hs=({middleware:e,middlewareType:t,onToggle:o,onConfigChange:r,onAllowedToolsChange:s,enabledAriaLabel:a,sectionTitles:d,headerActions:c,token:p,styles:u,renderListSubSection:b})=>{let x=t?.schema?.properties??{},v=Object.keys(x),g=v.filter(S=>{let B=x[S];return B.widget==="skillSelect"||B.widget==="databaseSelect"||B.widget==="metricsSelect"||B.widget==="collectionSelect"||B.widget==="connectionSelect"||B.widget==="topologyEdgeBuilder"}),m=v.filter(S=>{let B=x[S];return g.includes(S)?!1:B.widget==="switch"||B.widget==="segmented"}),f=v.filter(S=>!(g.includes(S)||m.includes(S)||S==="vmIsolation")),W=g.filter(S=>{let B=x[S];return S==="skills"&&e.config.readAll===!0||S==="serverKeys"&&e.config.connectAll===!0||S==="collectionKeys"&&e.config.connectAll===!0||S==="connections"&&e.config.connectAll===!0?!1:!!B.widget}),j=()=>(0,l.jsxs)(l.Fragment,{children:[m.map(S=>{let B=x[S],{row:J}=Ci(S,B,e.config[S]??B.default,Z=>r({[S]:Z}),p);return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:J},S)}),f.length>0&&(0,l.jsx)("div",{className:u.configGrid,children:f.map(S=>{let B=x[S],{gridItem:J}=Ci(S,B,e.config[S]??B.default,Z=>r({[S]:Z}),p);return J})})]}),A=t?.tools,X=A?.map(S=>S.name)??[],ee=e.allowedTools??X,pe=A&&A.length>0,Q=m.length>0||f.length>0;return(0,l.jsxs)("div",{style:{maxWidth:960},children:[(0,l.jsxs)("div",{className:u.pageHeader,children:[(0,l.jsx)("div",{className:u.pageIcon,children:(0,l.jsx)(Si,{type:e.type})}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("h2",{className:u.pageName,children:e.name}),(0,l.jsx)("p",{className:u.pageDesc,children:e.description})]}),(0,l.jsxs)(de,{size:10,children:[c,(0,l.jsx)(be,{color:e.enabled?"success":"default",style:{margin:0,fontSize:11},children:e.enabled?"Enabled":"Disabled"}),(0,l.jsx)(Ct,{"aria-label":a,checked:e.enabled,onChange:S=>{if(o(),S){let B=t;B?.defaultConfig&&!e.config&&r(B.defaultConfig)}}})]})]}),Q&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:u.blockTitle,children:d?.config??"Config"}),(0,l.jsx)("div",{style:{marginTop:12},children:j()})]}),W.length>0&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:u.blockTitle,style:{marginBottom:4},children:d?.resources??"Resources Permission"}),W.map(S=>{let B=x[S],J=e.config[S]??B.default??[];return b(S,B,J,Z=>r({[S]:Z}),e.type)})]}),pe&&A&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:u.blockTitle,style:{marginBottom:4},children:d?.tools??"Tools Permission"}),(0,l.jsx)(ps,{tools:A,selectedToolNames:ee,allToolNames:X,onChange:s,styles:u})]})]})},bs=e=>{let{token:t}=Le.useToken(),{styles:o}=gn();return(0,l.jsx)(hs,{...e,token:t,styles:o,renderListSubSection:(s,a,d,c,p)=>{switch(a.widget){case"skillSelect":return(0,l.jsx)(ms,{value:d,onChange:c,token:t,styles:o},s);case"databaseSelect":return(0,l.jsx)(us,{value:d,onChange:c,token:t,styles:o},s);case"metricsSelect":return(0,l.jsx)(gs,{value:d,onChange:c,token:t,styles:o},s);case"collectionSelect":return(0,l.jsx)(fs,{value:d,onChange:c,token:t,styles:o},s);case"connectionSelect":return(0,l.jsxs)("div",{className:o.dataSection,children:[(0,l.jsx)("div",{className:o.dataSectionHeader,children:(0,l.jsx)(we,{strong:!0,style:{fontSize:13},children:a.title||"Connections"})}),(0,l.jsx)(wi,{connectionType:a.connectionType??(s==="connections"?p:""),value:d||[],onChange:c})]},s);case"topologyEdgeBuilder":return(0,l.jsx)(ys,{value:d,onChange:c,token:t,styles:o},s);default:return null}}})};var ki=n(i()),{Text:Sg}=P,kg=C(({css:e,token:t})=>({toolRow:e`
|
|
1611
1616
|
width: 100%;
|
|
1612
1617
|
background: ${t.colorFillQuaternary};
|
|
1613
1618
|
border-color: ${t.colorBorderSecondary};
|
|
@@ -1737,7 +1742,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
1737
1742
|
font-size: 13px;
|
|
1738
1743
|
font-weight: 600;
|
|
1739
1744
|
padding: 2px 8px;
|
|
1740
|
-
`}));var hn=n(i());var Ai=n(i());var Ei=n(w());var bn=n(i()),{Text:
|
|
1745
|
+
`}));var hn=n(i());var Ai=n(i());var Ei=n(w());var bn=n(i()),{Text:Nf}=P,{TextArea:Mf}=K,{useToken:Bf}=Le;var Ni=n(w());var xn=n(i()),{Text:Lf}=P,{TextArea:Of}=K,Wf=C(({token:e,css:t})=>({container:t`
|
|
1741
1746
|
height: 100%;
|
|
1742
1747
|
display: flex;
|
|
1743
1748
|
flex-direction: column;
|
|
@@ -1786,7 +1791,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
1786
1791
|
font-size: 13px;
|
|
1787
1792
|
color: ${e.colorTextSecondary};
|
|
1788
1793
|
margin-top: 8px;
|
|
1789
|
-
`}));var vo=n(w());var
|
|
1794
|
+
`}));var vo=n(w());var Mi=n(w());var wn=n(i()),{Text:Qf}=P,Yf=C(({css:e})=>({formField:e`
|
|
1790
1795
|
margin-bottom: 16px;
|
|
1791
1796
|
`,fieldLabel:e`
|
|
1792
1797
|
display: block;
|
|
@@ -1881,7 +1886,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
1881
1886
|
gap: ${e.marginSM}px;
|
|
1882
1887
|
margin-bottom: ${e.marginSM}px;
|
|
1883
1888
|
align-items: center;
|
|
1884
|
-
`}));var An=n(w());var zi=n(i());var ji=n(w());var $i=n(i()),{Text:ih,Title:ah}=P;var wo=n(w());var xo=n(w());var _i=n(w());var Li=n(i()),{Text:fh}=P;var Oi=n(i()),{Text:kh}=P;var En=n(w());var
|
|
1889
|
+
`}));var An=n(w());var zi=n(i());var ji=n(w());var $i=n(i()),{Text:ih,Title:ah}=P;var wo=n(w());var xo=n(w());var _i=n(w());var Li=n(i()),{Text:fh}=P;var Oi=n(i()),{Text:kh}=P;var En=n(w());var Nn=n(i()),{Text:Dh,Paragraph:Fh}=P;var Mn=n(i()),{Text:qh}=P;var Bn=n(w());var Wi=n(i()),{Text:Xh}=P;var Dn=n(w());var Co=n(w());var Ui=n(w());var Hi=n(i()),{Text:lb}=P;var Fn=n(i()),{Text:bb}=P;var ko=n(w());var So=n(w());var Pt=n(i()),Rs=(0,So.lazy)(()=>import("./embed-page-TasksSideApp-MQTUCJO4.js").then(e=>({default:e.TasksSideApp}))),zn=()=>{let{openSideApp:e,sideAppVisible:t,sideAppSelectedCard:o}=ke(),r=t&&o?.component_key==="tasks_side_app_pin";return(0,Pt.jsx)(Rt,{ariaLabel:"Open tasks",icon:(0,Pt.jsx)(to,{size:16}),onClick:()=>{r||e({component_key:"tasks_side_app_pin",message:"Tasks",data:{component:(0,Pt.jsx)(So.Suspense,{fallback:(0,Pt.jsx)(re,{style:{display:"block",margin:"auto"}}),children:(0,Pt.jsx)(Rs,{showProjectFilter:!1})})}})}})};var Ut=n(w());var jn=n(i()),{Text:Mb}=P;var Bb=C(({css:e,token:t})=>({body:e`
|
|
1885
1890
|
display: flex;
|
|
1886
1891
|
height: 460px;
|
|
1887
1892
|
`,leftPanel:e`
|
|
@@ -2182,7 +2187,7 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
2182
2187
|
text-align: center;
|
|
2183
2188
|
color: ${e.colorTextSecondary};
|
|
2184
2189
|
font-size: 12px;
|
|
2185
|
-
`})),_n=()=>{let{styles:e}=Ts(),{threads:t,threadId:o,selectThread:r,deleteThread:s,updateThread:a,isLoading:d}=tt(),[c,p]=(0,ve.useState)(null),[u,b]=(0,ve.useState)(!1),[x,v]=(0,ve.useState)(null),[g,m]=(0,ve.useState)(""),[f,W]=(0,ve.useState)(!1),[j,A]=(0,ve.useState)(""),[X,ee]=(0,ve.useState)("updated"),[pe,Q]=(0,ve.useState)("desc"),S=(0,ve.useRef)(!1),B=(0,ve.useRef)(!1),J=(0,ve.useCallback)((R,I)=>{R.stopPropagation(),p(I)},[]),Z=(0,ve.useCallback)(async()=>{if(c){b(!0);try{await s(c),q.success("Conversation deleted"),p(null)}catch{q.error("Failed to delete conversation")}finally{b(!1)}}},[c,s]),E=(0,ve.useCallback)((R,I)=>{R.stopPropagation(),v(I.id),m(I.label)},[]),se=(0,ve.useCallback)(async R=>{if(B.current)return;let I=g.trim();if(!I||I===R.label){v(null);return}B.current=!0,W(!0);try{await a({...R,label:I}),q.success("Conversation renamed")}catch{q.error("Failed to rename conversation")}finally{B.current=!1,W(!1),v(null)}},[g,a]),D=(0,ve.useCallback)(()=>{S.current=!0,v(null)},[]),$=(0,ve.useCallback)(R=>{R.key==="Enter"?(R.preventDefault(),R.currentTarget.blur()):R.key==="Escape"&&(R.preventDefault(),D())},[D]),le=(0,ve.useCallback)(R=>{if(S.current){S.current=!1;return}se(R)},[se]),L=ve.default.useMemo(()=>Gi(Vi(t,j),X,pe),[t,j,X,pe]);return(0,V.jsxs)("div",{className:e.container,children:[(0,V.jsxs)("div",{className:e.toolbar,children:[(0,V.jsx)(K,{size:"small",placeholder:"Search conversations\u2026",allowClear:!0,value:j,onChange:R=>A(R.target.value)}),(0,V.jsxs)("div",{className:e.toolbarRow,children:[(0,V.jsx)(Ne,{size:"small",style:{flex:1,minWidth:0},value:X,onChange:R=>ee(R),options:[{value:"name",label:"Name"},{value:"updated",label:"Updated"},{value:"created",label:"Created"}]}),(0,V.jsx)(z,{size:"small",icon:pe==="asc"?(0,V.jsx)(Xt,{}):(0,V.jsx)(Jt,{}),onClick:()=>Q(R=>R==="asc"?"desc":"asc"),title:pe==="asc"?"Ascending":"Descending"})]})]}),d?(0,V.jsx)("div",{className:e.loading,children:"Loading conversations..."}):L.length===0?(0,V.jsx)("div",{className:e.emptyState,children:j.trim()?`No conversations match "${j.trim()}"`:"No conversations yet"}):(0,V.jsx)("div",{className:e.threadList,children:L.map(R=>(0,V.jsxs)("div",{className:`${e.threadItem} ${R.id===o?"active":""}`,onClick:()=>r(R.id),title:R.label,children:[(0,V.jsx)("div",{className:e.threadIcon,children:(0,V.jsx)(Rr,{size:14})}),x===R.id?(0,V.jsx)("input",{className:e.renameInput,"aria-label":"Conversation name",value:g,autoFocus:!0,disabled:f,onClick:I=>I.stopPropagation(),onFocus:I=>I.target.select(),onChange:I=>m(I.target.value),onKeyDown:I=>$(I),onBlur:()=>le(R)}):(0,V.jsx)("div",{className:R.id===o?e.threadNameActive:e.threadName,children:R.label}),x===R.id?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Save name",disabled:f,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),se(R)},children:(0,V.jsx)(yr,{size:12})}),(0,V.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Cancel rename",disabled:f,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),D()},children:(0,V.jsx)(Bt,{size:12})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{className:e.actionBtn,onClick:I=>E(I,R),title:"Rename conversation",children:(0,V.jsx)(Pr,{size:12})}),(0,V.jsx)("button",{className:e.actionBtn,onClick:I=>J(I,R.id),title:"Delete conversation",children:(0,V.jsx)(Mr,{size:12})})]})]},R.id))}),(0,V.jsx)(me,{title:"Delete Conversation",open:c!==null,onCancel:()=>p(null),onOk:Z,okText:"Delete",okButtonProps:{danger:!0,loading:u},cancelText:"Cancel",children:(0,V.jsx)("p",{children:"Are you sure you want to delete this conversation? This action cannot be undone."})})]})};var Yi=n(i());var Ji=n(i());var Zi=n(w());var ea=n(i()),{Text:$v}=P;var Ns=n(w());var Ln=n(w());var ta=n(i()),{Text:Hv}=P;var Ms=n(w());var Es=n(w());var On=n(i());var Wn=n(i()),{Dragger:Zv}=Gn,{Text:ex,Title:tx}=P;var oa=n(i()),{Title:cx,Text:dx}=P;var ye=n(i()),na=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ye.jsx)(Mt,{size:20}),order:-10},{id:"workspace_projects",type:"route",name:"Projects",icon:(0,ye.jsx)(st,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:(0,ye.jsx)(Zt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ye.jsx)(br,{size:20}),order:20,group:"DataSource"},{id:"connections",builtin:"connections",type:"route",name:"Plugins",icon:(0,ye.jsx)(Uo,{size:20}),order:21},{id:"topology-runtimes",type:"route",name:"Runtime",icon:(0,ye.jsx)(kt,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ye.jsx)(Cr,{size:20}),order:27,group:"Process"},{id:"workflows",type:"route",name:"Automations",icon:(0,ye.jsx)(Ho,{size:20}),order:25,group:"Process"},{id:"shares",type:"route",name:"Shares",icon:(0,ye.jsx)(Ho,{size:20}),order:55,group:"Settings"},{id:"workspace_migration",type:"route",name:"Migration",icon:(0,ye.jsx)(gr,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ye.jsx)(xr,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ye.jsx)(Mt,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ye.jsx)(Dr,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ye.jsx)(kr,{size:20}),order:29,group:"Knowledge"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:(0,ye.jsx)(Uo,{size:20}),order:40,group:"Settings"},{id:"a2a-keys",type:"route",name:"API Keys",icon:(0,ye.jsx)(Sr,{size:20}),order:45,group:"Settings"},{id:"open-audit",type:"route",name:"Audit Log",icon:(0,ye.jsx)(kt,{size:20}),order:47,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ye.jsx)(Er,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ye.jsx)(Br,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ye.jsx)(to,{size:20}),order:100}];var Iw=(0,Ue.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-LCIQ5UF3.js").then(e=>({default:e.AgentGovernanceWorkbench}))),Aw=(0,Ue.lazy)(()=>import("./embed-page-TopologyRuntimeView-PU2D7VZ7.js").then(e=>({default:e.TopologyRuntimeView}))),Ew=(0,Ue.lazy)(()=>import("./embed-page-WorkflowAutomationView-ST76M33F.js").then(e=>({default:e.WorkflowAutomationView}))),Mw=(0,Ue.lazy)(()=>import("./embed-page-TasksSideApp-MQTUCJO4.js").then(e=>({default:e.TasksSideApp}))),Nw=(0,Ue.lazy)(()=>import("./embed-page-AgentDetailSideApp-ONXG4B3D.js").then(e=>({default:e.AgentDetailSideApp})));var Be=n(i());function Bs(e){let{contentType:t,assistantId:o,contentConfig:r,workspaceId:s,projectId:a}=e;return t==="agent"?{agentId:o,workspaceId:s||void 0,projectId:a||void 0}:{...r,workspaceId:s||void 0,projectId:a||void 0}}async function Ds(e,t,o){let{contentType:r,assistantId:s,contentConfig:a,isMatch:d}=t;if(!(r==="agent"?!!s:!!a)||!o)return{isPinned:!1,pinnedId:null};let p=await e("/api/menu-items?menuTarget=workspace");if(p.success&&p.data?.records){let u=d??(x=>r==="agent"&&x.agentId===s),b=p.data.records.find(x=>x.contentType===r&&u(x.contentConfig));if(b)return{isPinned:!0,pinnedId:b.id}}return{isPinned:!1,pinnedId:null}}async function Fs(e,t){let{contentType:o,name:r,group:s}=t,a=Bs(t),d={menuTarget:"workspace",contentType:o,contentConfig:a,group:s?.trim()||void 0,name:r.trim(),sortOrder:0},c=await e("/api/menu-items",d);if(!c.success)throw new Error(c.message||"Failed to pin");return{id:c.data.id}}async function zs(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function uo(){let e=he.default.useContext(Fr),{config:t}=Ce(),{post:o,get:r,del:s}=ue(),a=t.enableCustomMenu??!1,d=(0,he.useCallback)(async u=>Ds(r,u,a),[r,a]),c=(0,he.useCallback)(async u=>Fs(o,{...u,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,he.useCallback)(async u=>zs(s,u),[s]);return{check:d,pin:c,unpin:p,enableCustomMenu:a,get:r}}function ra(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function ln(){let{config:e}=Ce(),t=he.default.useMemo(()=>ra(na),[]),o=he.default.useMemo(()=>ra(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return he.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function cn(e){let t=await e("/api/menu-items?menuTarget=workspace");if(t.success&&t.data?.records){let o=new Set;for(let r of t.data.records)r.group?.trim()&&o.add(r.group.trim());return Array.from(o).sort()}return[]}var js={display:"flex",flexDirection:"column",gap:12},Pn=({assistantId:e,contentType:t="agent",contentConfig:o,isMatch:r,size:s="small",label:a,block:d})=>{let{check:c,pin:p,unpin:u,enableCustomMenu:b,get:x}=uo(),[v,g]=(0,he.useState)(!1),[m,f]=(0,he.useState)(""),[W,j]=(0,he.useState)(""),[A,X]=(0,he.useState)(!1),[ee,pe]=(0,he.useState)(!1),[Q,S]=(0,he.useState)(null),[B,J]=(0,he.useState)(!0),Z=ln(),[E,se]=(0,he.useState)(Z);(0,he.useEffect)(()=>{se(Z)},[Z]),(0,he.useEffect)(()=>{v&&cn(x).then(I=>{se(Array.from(new Set([...Z,...I])).sort())})},[v]);let D=t==="agent"?!!e:!!o,$=(0,he.useCallback)(async()=>{if(!D||!b){J(!1);return}J(!0);try{let I=await c({contentType:t,assistantId:e,contentConfig:o,isMatch:r});pe(I.isPinned),S(I.pinnedId)}catch{}finally{J(!1)}},[D,b,c,t,e,o,r]);if((0,he.useEffect)(()=>{$()},[$]),!D||!b)return null;let le=async()=>{if(!W.trim()){q.warning("Please enter a menu name");return}X(!0);try{await p({contentType:t,assistantId:e,contentConfig:o,isMatch:r,name:W.trim(),group:m.trim()||void 0}),q.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),g(!1),f(""),j(""),$()}catch(I){q.error(I.message||"Failed to pin to menu")}finally{X(!1)}},L=async()=>{if(Q){X(!0);try{await u(Q),q.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),pe(!1),S(null)}catch(I){q.error(I.message||"Failed to unpin from menu")}finally{X(!1)}}},R=()=>{ee?L():g(!0)};return(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(je,{title:ee?"Unpin from Menu":"Pin to Menu",children:a?(0,Be.jsx)(z,{type:"text",size:s,block:d,icon:ee?(0,Be.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Be.jsx)(Ve,{size:14}),onClick:R,loading:B||A&&ee,children:a}):(0,Be.jsx)(z,{type:"text",size:s,block:d,icon:ee?(0,Be.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Be.jsx)(Ve,{size:14}),onClick:R,loading:B||A&&ee})}),(0,Be.jsx)(me,{title:"Pin to Menu",open:v,onOk:le,onCancel:()=>g(!1),confirmLoading:A,okText:"Pin",children:(0,Be.jsxs)("div",{style:js,children:[(0,Be.jsx)(K,{placeholder:"Menu name (required)",value:W,onChange:I=>j(I.target.value)}),(0,Be.jsx)(Vt,{placeholder:"Group (optional, select or type new)",value:m,options:E.map(I=>({value:I})),onChange:I=>f(I),filterOption:(I,T)=>T?.value?.toUpperCase().includes(I.toUpperCase())??!1})]})})]})};var ae=n(w());var G=n(i()),Un=50,$s=C(({token:e,css:t})=>({container:t`
|
|
2190
|
+
`})),_n=()=>{let{styles:e}=Ts(),{threads:t,threadId:o,selectThread:r,deleteThread:s,updateThread:a,isLoading:d}=tt(),[c,p]=(0,ve.useState)(null),[u,b]=(0,ve.useState)(!1),[x,v]=(0,ve.useState)(null),[g,m]=(0,ve.useState)(""),[f,W]=(0,ve.useState)(!1),[j,A]=(0,ve.useState)(""),[X,ee]=(0,ve.useState)("updated"),[pe,Q]=(0,ve.useState)("desc"),S=(0,ve.useRef)(!1),B=(0,ve.useRef)(!1),J=(0,ve.useCallback)((R,I)=>{R.stopPropagation(),p(I)},[]),Z=(0,ve.useCallback)(async()=>{if(c){b(!0);try{await s(c),q.success("Conversation deleted"),p(null)}catch{q.error("Failed to delete conversation")}finally{b(!1)}}},[c,s]),E=(0,ve.useCallback)((R,I)=>{R.stopPropagation(),v(I.id),m(I.label)},[]),se=(0,ve.useCallback)(async R=>{if(B.current)return;let I=g.trim();if(!I||I===R.label){v(null);return}B.current=!0,W(!0);try{await a({...R,label:I}),q.success("Conversation renamed")}catch{q.error("Failed to rename conversation")}finally{B.current=!1,W(!1),v(null)}},[g,a]),D=(0,ve.useCallback)(()=>{S.current=!0,v(null)},[]),$=(0,ve.useCallback)(R=>{R.key==="Enter"?(R.preventDefault(),R.currentTarget.blur()):R.key==="Escape"&&(R.preventDefault(),D())},[D]),le=(0,ve.useCallback)(R=>{if(S.current){S.current=!1;return}se(R)},[se]),L=ve.default.useMemo(()=>Gi(Vi(t,j),X,pe),[t,j,X,pe]);return(0,V.jsxs)("div",{className:e.container,children:[(0,V.jsxs)("div",{className:e.toolbar,children:[(0,V.jsx)(K,{size:"small",placeholder:"Search conversations\u2026",allowClear:!0,value:j,onChange:R=>A(R.target.value)}),(0,V.jsxs)("div",{className:e.toolbarRow,children:[(0,V.jsx)(Me,{size:"small",style:{flex:1,minWidth:0},value:X,onChange:R=>ee(R),options:[{value:"name",label:"Name"},{value:"updated",label:"Updated"},{value:"created",label:"Created"}]}),(0,V.jsx)(z,{size:"small",icon:pe==="asc"?(0,V.jsx)(Xt,{}):(0,V.jsx)(Jt,{}),onClick:()=>Q(R=>R==="asc"?"desc":"asc"),title:pe==="asc"?"Ascending":"Descending"})]})]}),d?(0,V.jsx)("div",{className:e.loading,children:"Loading conversations..."}):L.length===0?(0,V.jsx)("div",{className:e.emptyState,children:j.trim()?`No conversations match "${j.trim()}"`:"No conversations yet"}):(0,V.jsx)("div",{className:e.threadList,children:L.map(R=>(0,V.jsxs)("div",{className:`${e.threadItem} ${R.id===o?"active":""}`,onClick:()=>r(R.id),title:R.label,children:[(0,V.jsx)("div",{className:e.threadIcon,children:(0,V.jsx)(Rr,{size:14})}),x===R.id?(0,V.jsx)("input",{className:e.renameInput,"aria-label":"Conversation name",value:g,autoFocus:!0,disabled:f,onClick:I=>I.stopPropagation(),onFocus:I=>I.target.select(),onChange:I=>m(I.target.value),onKeyDown:I=>$(I),onBlur:()=>le(R)}):(0,V.jsx)("div",{className:R.id===o?e.threadNameActive:e.threadName,children:R.label}),x===R.id?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Save name",disabled:f,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),se(R)},children:(0,V.jsx)(yr,{size:12})}),(0,V.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Cancel rename",disabled:f,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),D()},children:(0,V.jsx)(Bt,{size:12})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{className:e.actionBtn,onClick:I=>E(I,R),title:"Rename conversation",children:(0,V.jsx)(Pr,{size:12})}),(0,V.jsx)("button",{className:e.actionBtn,onClick:I=>J(I,R.id),title:"Delete conversation",children:(0,V.jsx)(Nr,{size:12})})]})]},R.id))}),(0,V.jsx)(me,{title:"Delete Conversation",open:c!==null,onCancel:()=>p(null),onOk:Z,okText:"Delete",okButtonProps:{danger:!0,loading:u},cancelText:"Cancel",children:(0,V.jsx)("p",{children:"Are you sure you want to delete this conversation? This action cannot be undone."})})]})};var Yi=n(i());var Ji=n(i());var Zi=n(w());var ea=n(i()),{Text:$v}=P;var Ms=n(w());var Ln=n(w());var ta=n(i()),{Text:Hv}=P;var Ns=n(w());var Es=n(w());var On=n(i());var Wn=n(i()),{Dragger:Zv}=Gn,{Text:ex,Title:tx}=P;var oa=n(i()),{Title:cx,Text:dx}=P;var ye=n(i()),na=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ye.jsx)(Nt,{size:20}),order:-10},{id:"workspace_projects",type:"route",name:"Projects",icon:(0,ye.jsx)(st,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:(0,ye.jsx)(Zt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ye.jsx)(br,{size:20}),order:20,group:"DataSource"},{id:"connections",builtin:"connections",type:"route",name:"Plugins",icon:(0,ye.jsx)(Uo,{size:20}),order:21},{id:"topology-runtimes",type:"route",name:"Runtime",icon:(0,ye.jsx)(kt,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ye.jsx)(Cr,{size:20}),order:27,group:"Process"},{id:"workflows",type:"route",name:"Automations",icon:(0,ye.jsx)(Ho,{size:20}),order:25,group:"Process"},{id:"shares",type:"route",name:"Shares",icon:(0,ye.jsx)(Ho,{size:20}),order:55,group:"Settings"},{id:"workspace_migration",type:"route",name:"Migration",icon:(0,ye.jsx)(gr,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ye.jsx)(xr,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ye.jsx)(Nt,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ye.jsx)(Dr,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ye.jsx)(kr,{size:20}),order:29,group:"Knowledge"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:(0,ye.jsx)(Uo,{size:20}),order:40,group:"Settings"},{id:"a2a-keys",type:"route",name:"API Keys",icon:(0,ye.jsx)(Sr,{size:20}),order:45,group:"Settings"},{id:"open-audit",type:"route",name:"Audit Log",icon:(0,ye.jsx)(kt,{size:20}),order:47,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ye.jsx)(Er,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ye.jsx)(Br,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ye.jsx)(to,{size:20}),order:100}];var Iw=(0,Ue.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-ZNW72EEJ.js").then(e=>({default:e.AgentGovernanceWorkbench}))),Aw=(0,Ue.lazy)(()=>import("./embed-page-TopologyRuntimeView-PU2D7VZ7.js").then(e=>({default:e.TopologyRuntimeView}))),Ew=(0,Ue.lazy)(()=>import("./embed-page-WorkflowAutomationView-ST76M33F.js").then(e=>({default:e.WorkflowAutomationView}))),Nw=(0,Ue.lazy)(()=>import("./embed-page-TasksSideApp-MQTUCJO4.js").then(e=>({default:e.TasksSideApp}))),Mw=(0,Ue.lazy)(()=>import("./embed-page-AgentDetailSideApp-7PQ2JKG6.js").then(e=>({default:e.AgentDetailSideApp})));var Be=n(i());function Bs(e){let{contentType:t,assistantId:o,contentConfig:r,workspaceId:s,projectId:a}=e;return t==="agent"?{agentId:o,workspaceId:s||void 0,projectId:a||void 0}:{...r,workspaceId:s||void 0,projectId:a||void 0}}async function Ds(e,t,o){let{contentType:r,assistantId:s,contentConfig:a,isMatch:d}=t;if(!(r==="agent"?!!s:!!a)||!o)return{isPinned:!1,pinnedId:null};let p=await e("/api/menu-items?menuTarget=workspace");if(p.success&&p.data?.records){let u=d??(x=>r==="agent"&&x.agentId===s),b=p.data.records.find(x=>x.contentType===r&&u(x.contentConfig));if(b)return{isPinned:!0,pinnedId:b.id}}return{isPinned:!1,pinnedId:null}}async function Fs(e,t){let{contentType:o,name:r,group:s}=t,a=Bs(t),d={menuTarget:"workspace",contentType:o,contentConfig:a,group:s?.trim()||void 0,name:r.trim(),sortOrder:0},c=await e("/api/menu-items",d);if(!c.success)throw new Error(c.message||"Failed to pin");return{id:c.data.id}}async function zs(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function uo(){let e=he.default.useContext(Fr),{config:t}=Ce(),{post:o,get:r,del:s}=ue(),a=t.enableCustomMenu??!1,d=(0,he.useCallback)(async u=>Ds(r,u,a),[r,a]),c=(0,he.useCallback)(async u=>Fs(o,{...u,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,he.useCallback)(async u=>zs(s,u),[s]);return{check:d,pin:c,unpin:p,enableCustomMenu:a,get:r}}function ra(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function ln(){let{config:e}=Ce(),t=he.default.useMemo(()=>ra(na),[]),o=he.default.useMemo(()=>ra(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return he.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function cn(e){let t=await e("/api/menu-items?menuTarget=workspace");if(t.success&&t.data?.records){let o=new Set;for(let r of t.data.records)r.group?.trim()&&o.add(r.group.trim());return Array.from(o).sort()}return[]}var js={display:"flex",flexDirection:"column",gap:12},Pn=({assistantId:e,contentType:t="agent",contentConfig:o,isMatch:r,size:s="small",label:a,block:d})=>{let{check:c,pin:p,unpin:u,enableCustomMenu:b,get:x}=uo(),[v,g]=(0,he.useState)(!1),[m,f]=(0,he.useState)(""),[W,j]=(0,he.useState)(""),[A,X]=(0,he.useState)(!1),[ee,pe]=(0,he.useState)(!1),[Q,S]=(0,he.useState)(null),[B,J]=(0,he.useState)(!0),Z=ln(),[E,se]=(0,he.useState)(Z);(0,he.useEffect)(()=>{se(Z)},[Z]),(0,he.useEffect)(()=>{v&&cn(x).then(I=>{se(Array.from(new Set([...Z,...I])).sort())})},[v]);let D=t==="agent"?!!e:!!o,$=(0,he.useCallback)(async()=>{if(!D||!b){J(!1);return}J(!0);try{let I=await c({contentType:t,assistantId:e,contentConfig:o,isMatch:r});pe(I.isPinned),S(I.pinnedId)}catch{}finally{J(!1)}},[D,b,c,t,e,o,r]);if((0,he.useEffect)(()=>{$()},[$]),!D||!b)return null;let le=async()=>{if(!W.trim()){q.warning("Please enter a menu name");return}X(!0);try{await p({contentType:t,assistantId:e,contentConfig:o,isMatch:r,name:W.trim(),group:m.trim()||void 0}),q.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),g(!1),f(""),j(""),$()}catch(I){q.error(I.message||"Failed to pin to menu")}finally{X(!1)}},L=async()=>{if(Q){X(!0);try{await u(Q),q.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),pe(!1),S(null)}catch(I){q.error(I.message||"Failed to unpin from menu")}finally{X(!1)}}},R=()=>{ee?L():g(!0)};return(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(je,{title:ee?"Unpin from Menu":"Pin to Menu",children:a?(0,Be.jsx)(z,{type:"text",size:s,block:d,icon:ee?(0,Be.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Be.jsx)(Ve,{size:14}),onClick:R,loading:B||A&&ee,children:a}):(0,Be.jsx)(z,{type:"text",size:s,block:d,icon:ee?(0,Be.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Be.jsx)(Ve,{size:14}),onClick:R,loading:B||A&&ee})}),(0,Be.jsx)(me,{title:"Pin to Menu",open:v,onOk:le,onCancel:()=>g(!1),confirmLoading:A,okText:"Pin",children:(0,Be.jsxs)("div",{style:js,children:[(0,Be.jsx)(K,{placeholder:"Menu name (required)",value:W,onChange:I=>j(I.target.value)}),(0,Be.jsx)(Vt,{placeholder:"Group (optional, select or type new)",value:m,options:E.map(I=>({value:I})),onChange:I=>f(I),filterOption:(I,T)=>T?.value?.toUpperCase().includes(I.toUpperCase())??!1})]})})]})};var ae=n(w());var G=n(i()),Un=50,$s=C(({token:e,css:t})=>({container:t`
|
|
2186
2191
|
position: relative;
|
|
2187
2192
|
`,projectTrigger:t`
|
|
2188
2193
|
display: flex;
|
|
@@ -2406,5 +2411,5 @@ import{a as Lr}from"./embed-page-chunk-ZXFZANZM.js";import{$ as kr,Aa as Er,B as
|
|
|
2406
2411
|
align-items: center;
|
|
2407
2412
|
justify-content: flex-end;
|
|
2408
2413
|
flex-shrink: 0;
|
|
2409
|
-
`})),Us=e=>{let{assistant_id:t,thread_id:o="",menu:r,header:s,headerRight:a,showProjectSelector:d,headerSelector:c,emptyPlaceholder:p,...u}=e,{config:b}=Ce(),{styles:x}=Ws(),v=d??b.enableWorkspace,g=(0,oe.jsxs)("div",{className:x.headerBar,children:[(0,oe.jsx)("div",{className:x.headerLeft,children:c??(v?(0,oe.jsx)(Ro,{}):null)}),(0,oe.jsx)("div",{className:x.headerRight,children:a!==void 0?a:(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)(Pn,{assistantId:t}),(0,oe.jsx)(zn,{}),(0,oe.jsx)(Go,{})]})})]});return(0,oe.jsxs)("div",{className:x.wrapper,children:[s,(0,oe.jsx)(ht,{menu:r?(0,oe.jsx)(gt,{name:"Sidebar",children:r}):void 0,header:g,main:(0,oe.jsx)(gt,{name:"Chat panel",children:o?(0,oe.jsx)(_r,{...u}):p??(0,oe.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,oe.jsx)(gt,{name:"Detail panel",children:(0,oe.jsx)(po,{})}),tools:(0,oe.jsx)(gt,{name:"Tools panel",children:(0,oe.jsx)(ia,{})})})]})},Po=e=>(0,oe.jsx)(gt,{name:"Thread",children:(0,oe.jsx)(Ko,{assistantId:e.assistant_id,threadId:e.thread_id||"",options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:(0,oe.jsx)(io.Provider,{value:null,children:(0,oe.jsx)(lt,{children:(0,oe.jsx)(Us,{...e})})})})});var nt=n(i()),Hs=({thread_id:e,name:t,description:o,headerSelector:r,...s})=>{let{currentAssistant:a}=et(),{thread:d}=tt(),c=e??d?.id??"";return c?(0,nt.jsx)(Po,{thread_id:c,name:t??a?.name,description:o??a?.description,headerSelector:r??(0,nt.jsx)(Ro,{showWorkspace:!1,disableDropdown:!1}),...s}):(0,nt.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,nt.jsx)(re,{tip:"Creating conversation..."})})},Ki=({defaultWorkspaceId:e,defaultProjectId:t,assistant_id:o,...r})=>(0,nt.jsx)(Lr,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,nt.jsx)(jo,{autoLoad:!0,initialAssistantId:o,children:(0,nt.jsx)(no,{children:(0,nt.jsx)(Hs,{assistant_id:o,...r})})})});var
|
|
2410
|
-
`),o))if(await t(v),d=v.type==="stream.completed",d)break;if(d)break}}if(p.done)break}if(!d)throw wt()}finally{if(!c)try{await r.cancel()}catch{}r.releaseLock()}}var Xs=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function Ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ze(e,t,o=[]){let r=Object.keys(e);return t.every(s=>s in e)&&r.every(s=>t.includes(s)||o.includes(s))}function te(e){return typeof e=="string"}function Io(e){if(!Ee(e)||!ze(e,["id","projectId","createdAt","updatedAt"],["label"])||!te(e.id)||!te(e.projectId)||e.label!==void 0&&!te(e.label)||!te(e.createdAt)||!te(e.updatedAt))return;let t=new Date(e.createdAt),o=new Date(e.updatedAt);if(!(Number.isNaN(t.getTime())||Number.isNaN(o.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:t,updatedAt:o}}function ca(e){if(!Ee(e)||e.success!==!1||!Ee(e.error))return!1;let t=e.error;return ze(e,["success","error"])&&ze(t,["code","message","retryable"])&&typeof t.code=="string"&&Xs.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function Js(e){if(!Ee(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return ze(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function Zs(e){return Array.isArray(e)&&e.length<=6&&e.every(t=>Ee(t)&&ze(t,["label","text"])&&te(t.label)&&t.label.length>=1&&t.label.length<=40&&te(t.text)&&t.text.length>=1&&t.text.length<=500)}function el(e){return Ee(e)&&ze(e,[],["title","welcomeMessage","primaryColor","quickPrompts"])&&(e.title===void 0||te(e.title))&&(e.welcomeMessage===void 0||te(e.welcomeMessage))&&(e.primaryColor===void 0||te(e.primaryColor))&&(e.quickPrompts===void 0||Zs(e.quickPrompts))}function tl(e){if(!Ee(e)||!ze(e,["webApp","projects","models"],["thread"])||!Ee(e.webApp))return;let t=e.webApp;if(!ze(t,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!te(t.id)||!te(t.name)||!te(t.defaultProjectId)||t.description!==void 0&&!te(t.description)||t.defaultModelKey!==void 0&&!te(t.defaultModelKey)||t.identityAssurance!=="unverified"||!Ee(t.assistant)||!ze(t.assistant,["id","name"],["description"])||!te(t.assistant.id)||!te(t.assistant.name)||t.assistant.description!==void 0&&!te(t.assistant.description)||!Js(t.features)||!el(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>Ee(r)&&ze(r,["id","name"])&&te(r.id)&&te(r.name))||!Array.isArray(e.models)||!e.models.every(r=>Ee(r)&&ze(r,["key","label"])&&te(r.key)&&te(r.label)))return;let o=e.thread===void 0?void 0:Io(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function ol(e){if(!Ee(e)||!ze(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(Io);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function nl(e){return Ee(e)&&te(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||te(e.content)||Array.isArray(e.content)&&e.content.every(t=>Gt(t)!==void 0))}function rl(e){return Ee(e)&&ze(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(nl)?e:void 0}function il(e){return Ee(e)&&ze(e,["ref","name","mimeType","size"])&&te(e.ref)&&te(e.name)&&te(e.mimeType)&&typeof e.size=="number"?e:void 0}function da(e,t){return o=>Ee(o)&&ze(o,e)&&t(o)?o:void 0}var Ao=class{constructor(t){this.options=t;this.baseUrl=`${t.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(t.webAppId)}/runtime`,this.fetchImplementation=t.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(t={},o){return this.request("bootstrap",tl,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",ol,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",Io,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,Io,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,da(["id"],s=>te(s.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,rl,{query:o,signal:r})}async streamMessage(t,o,r,s){return this.streamRequest(`threads/${encodeURIComponent(t)}/messages/stream`,o,r,s)}async resumeInterrupt(t,o,r,s,a){return this.streamRequest(`threads/${encodeURIComponent(t)}/interrupts/${encodeURIComponent(o)}/resume`,r,s,a)}async streamRequest(t,o,r,s){let a;try{a=await this.fetchRequest(t,{method:"POST",body:o,signal:s})}catch(d){throw pa(d)||d instanceof Fe?d:new Fe("STREAM_FAILED","Stream failed",!0)}if(a.ok||await this.throwResponseError(a),!a.body||!a.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(a.body)try{await a.body.cancel()}catch{}throw new Fe("STREAM_FAILED","Stream failed",!0,a.status)}await la(a.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,da(["aborted"],s=>typeof s.aborted=="boolean"),{method:"POST",query:o,signal:r})}async uploadAttachment(t,o,r={},s){let a=new FormData,d=typeof File<"u"&&o instanceof File?o.name:"attachment";return a.append("file",o,d),this.request(`threads/${encodeURIComponent(t)}/attachments`,il,{method:"POST",query:r,body:a,signal:s})}async request(t,o,r={}){let s;try{s=await this.fetchRequest(t,r)}catch(c){throw pa(c)||c instanceof Fe?c:new Fe("INTERNAL_ERROR","Request failed",!0)}let a;try{a=await s.json()}catch{throw this.internalError(s.status)}if(ca(a))throw new Fe(a.error.code,a.error.message,a.error.retryable,s.status);if(!s.ok||!Ee(a)||!ze(a,["success","data"])||a.success!==!0)throw this.internalError(s.status);let d=o(a.data);if(d===void 0)throw this.internalError(s.status);return d}async fetchRequest(t,o){let r=await this.options.identityProvider.getIdentity(o.signal),s=new URL(`${this.baseUrl}/${t}`);for(let[c,p]of Object.entries(o.query??{}))p!==void 0&&s.searchParams.set(c,p);let a=new Headers;r.bearerToken!==void 0?a.set("Authorization",`Bearer ${r.bearerToken}`):a.set("X-Axiom-External-User-Id",r.externalUserId??"");let d;return o.body instanceof FormData?d=o.body:o.body!==void 0&&(a.set("Content-Type","application/json"),d=JSON.stringify(o.body)),this.fetchImplementation(s,{method:o.method??"GET",headers:a,body:d,signal:o.signal,credentials:"omit"})}async throwResponseError(t){let o;try{o=await t.json()}catch{throw this.internalError(t.status)}throw ca(o)?new Fe(o.error.code,o.error.message,o.error.retryable,t.status):this.internalError(t.status)}internalError(t){return new Fe("INTERNAL_ERROR","Invalid server response",!1,t)}};function pa(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var Eo=n(w());var At=n(i());function ma(){let{createThread:e}=tt(),{menuCollapsed:t,setMenuCollapsed:o}=ke();(0,Eo.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,Eo.useCallback)(async()=>{try{await e("New Thread")}catch(u){console.error("Failed to create new thread:",u)}},[e]),s=t??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,At.jsx)(hr,{size:20}),order:0},...s?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,At.jsx)(_n,{})}]];return(0,At.jsx)(so,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!s,collapsed:s,onCollapsedChange:o,onNewAnalysis:r,onItemClick:u=>{u.type==="action"&&u.builtin==="new-analysis"?r():u.type==="action"&&u.id==="thread-history-toggle"&&o(!1)}},s?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function ua(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let t=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,o=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,s=new WeakMap;return XMLHttpRequest.prototype.open=function(d,c){s.set(this,String(c)),o.call(this,d,c,!0)},XMLHttpRequest.prototype.send=function(d){let c=s.get(this)??"";if(!c.startsWith(t)||!/\/sandbox\/uploadfile$/.test(c)){r.call(this,d);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,d);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,d)}).catch(()=>{r.call(this,d)})},()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=r}}var Re=n(i());function al(e,t){let r=ga(e.welcome)??ga(t.welcomeMessage),s=e.quickPrompts??t.quickPrompts??[];return{...r!==void 0?{welcome:r}:{},quickPrompts:s}}function ga(e){return typeof e=="string"&&e.length>0?e:void 0}function sl(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function ll(e){return e instanceof Fe?e:new Fe("INTERNAL_ERROR","Request failed",!0)}function cl(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function oS(e){sl(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${cl(e.identity)}`;return(0,Re.jsx)(dl,{...e},t)}function dl({gatewayUrl:e,webAppId:t,identity:o,onError:r,onChatReady:s,onChatMessage:a,fetch:d,className:c,welcome:p,quickPrompts:u}){let[b,x]=(0,Me.useState)({status:"loading"}),v=(0,Me.useRef)(o);v.current=o;let g=(0,Me.useRef)(r);g.current=r;let m=(0,Me.useRef)();return m.current||(m.current=new Ao({gatewayUrl:e,webAppId:t,identityProvider:{getIdentity:async()=>{let f=v.current;if(f.mode!=="verified")return{externalUserId:f.userId};try{return{bearerToken:await f.tokenProvider()}}catch{throw new Fe("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,Me.useEffect)(()=>ua({gatewayUrl:e,webAppId:t,identity:o}),[e,t,o]),(0,Me.useEffect)(()=>{let f=!1,W=m.current;return(async()=>{try{let j=await W.bootstrap({});if(f)return;x({status:"ready",bootstrap:j})}catch(j){if(f)return;let A=ll(j);x({status:"error",error:A}),g.current?.(A)}})(),()=>{f=!0}},[]),b.status==="loading"?(0,Re.jsx)("div",{className:c}):b.status==="error"?(0,Re.jsxs)("div",{className:c,role:"alert",children:[(0,Re.jsx)("strong",{children:"Unable to load the assistant"}),(0,Re.jsx)("div",{children:b.error.code}),(0,Re.jsx)("button",{type:"button",onClick:()=>x({status:"loading"}),children:"Retry"})]}):(0,Re.jsx)(ml,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:b.bootstrap,onChatReady:s,onChatMessage:a,welcome:p,quickPrompts:u})}function pl(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function ml({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:s,onChatMessage:a,className:d,welcome:c,quickPrompts:p}){let u=(0,Me.useMemo)(()=>pl(r.webApp.assistant),[r.webApp.assistant]),b=(0,Me.useMemo)(()=>al({welcome:c,quickPrompts:p},r.webApp.appearance),[c,p,r.webApp.appearance]),x=(0,Me.useMemo)(()=>o.mode==="unverified"?{mode:"unverified",userId:o.userId}:{mode:"verified",tokenProvider:o.tokenProvider},[o]),v=(0,Me.useCallback)(f=>new Qn({gatewayUrl:e,webAppId:t,identity:x,assistantId:f.assistantId,transport:f.transport,...f.timeout!==void 0?{timeout:f.timeout}:{},...f.headers!==void 0?{headers:f.headers}:{}}),[e,t,x]),g=(0,Me.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${t}/runtime`,apiKey:"",transport:"sse",assistantId:u.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[u.id,e,t]),m=(0,Me.useMemo)(()=>({assistants:[u],currentAssistant:u,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>u,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[u]);return(0,Re.jsx)(Jn,{config:{baseURL:g.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:v,children:(0,Re.jsx)(tr,{initialConfig:g,persistToLocalStorage:!1,children:(0,Re.jsx)(Zn.Provider,{value:m,children:(0,Re.jsx)(no,{children:(0,Re.jsx)(ul,{className:d,onChatReady:s,onChatMessage:a,welcome:b.welcome,quickPrompts:b.quickPrompts})})})})})}function ul({className:e,onChatReady:t,onChatMessage:o,welcome:r,quickPrompts:s=[]}){let{threadId:a}=tt(),{currentAssistant:d}=et();if(!d)return null;let c=a??"";return c?(0,Re.jsx)("div",{className:e,children:(0,Re.jsx)(Po,{thread_id:c,assistant_id:d.id,name:d.name,description:d.description,menu:(0,Re.jsx)(ma,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,emptyStateGreeting:r?(0,Re.jsx)("span",{children:r}):void 0,senderPromptsItems:s.length>0?s.map((p,u)=>({key:`quick-${u}`,label:p.label,description:p.text})):void 0,showSkillPrompts:!1,showQuickAnalysis:!1,onChatReady:t,onChatMessage:o})}):(0,Re.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,Re.jsx)(re,{tip:"Creating conversation..."})})}export{ot as a,hi as b,bi as c,ds as d,bs as e,Ro as f,Ki as g,oS as h};
|
|
2414
|
+
`})),Us=e=>{let{assistant_id:t,thread_id:o="",menu:r,header:s,headerRight:a,showProjectSelector:d,headerSelector:c,emptyPlaceholder:p,...u}=e,{config:b}=Ce(),{styles:x}=Ws(),v=d??b.enableWorkspace,g=(0,oe.jsxs)("div",{className:x.headerBar,children:[(0,oe.jsx)("div",{className:x.headerLeft,children:c??(v?(0,oe.jsx)(Ro,{}):null)}),(0,oe.jsx)("div",{className:x.headerRight,children:a!==void 0?a:(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)(Pn,{assistantId:t}),(0,oe.jsx)(zn,{}),(0,oe.jsx)(Go,{})]})})]});return(0,oe.jsxs)("div",{className:x.wrapper,children:[s,(0,oe.jsx)(ht,{menu:r?(0,oe.jsx)(gt,{name:"Sidebar",children:r}):void 0,header:g,main:(0,oe.jsx)(gt,{name:"Chat panel",children:o?(0,oe.jsx)(_r,{...u}):p??(0,oe.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,oe.jsx)(gt,{name:"Detail panel",children:(0,oe.jsx)(po,{})}),tools:(0,oe.jsx)(gt,{name:"Tools panel",children:(0,oe.jsx)(ia,{})})})]})},Po=e=>(0,oe.jsx)(gt,{name:"Thread",children:(0,oe.jsx)(Ko,{assistantId:e.assistant_id,threadId:e.thread_id||"",options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:(0,oe.jsx)(io.Provider,{value:null,children:(0,oe.jsx)(lt,{children:(0,oe.jsx)(Us,{...e})})})})});var nt=n(i()),Hs=({thread_id:e,name:t,description:o,headerSelector:r,...s})=>{let{currentAssistant:a}=et(),{thread:d}=tt(),c=e??d?.id??"";return c?(0,nt.jsx)(Po,{thread_id:c,name:t??a?.name,description:o??a?.description,headerSelector:r??(0,nt.jsx)(Ro,{showWorkspace:!1,disableDropdown:!1}),...s}):(0,nt.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,nt.jsx)(re,{tip:"Creating conversation..."})})},Ki=({defaultWorkspaceId:e,defaultProjectId:t,assistant_id:o,...r})=>(0,nt.jsx)(Lr,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,nt.jsx)(jo,{autoLoad:!0,initialAssistantId:o,children:(0,nt.jsx)(no,{children:(0,nt.jsx)(Hs,{assistant_id:o,...r})})})});var Ne=n(w());var Fe=class extends Error{code;retryable;status;constructor(t,o,r,s){super(o),this.name="AgentWebAppRuntimeClientError",this.code=t,this.retryable=r,this.status=s}};function wt(){return new Fe("STREAM_FAILED","Stream failed",!0)}var Ks=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function It(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Je(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e)}function qs(e){return It(e)&&Je(e,["code","message","retryable"])&&typeof e.code=="string"&&Ks.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function Vs(e){if(!It(e))return!1;let t=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return Je(e,t)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||It(e.data))}var Gs=new Set([at.HUMAN,at.AI,at.TOOL,at.INTERRUPT,at.MESSAGE_COMPLETED,at.MESSAGE_FAILED,at.THREAD_IDLE]);function Qs(e,t){let o;try{o=JSON.parse(e)}catch{throw wt()}if(!It(o)||typeof o.type!="string")throw wt();if(Gs.has(o.type)||o.type==="error"&&It(o.data)&&!It(o.error)){let r=Xn(o,t);return r.length===0?[]:r}switch(o.type){case"message.delta":if(Je(o,["type","text"])&&typeof o.text=="string")return[o];break;case"message.completed":if(Je(o,["type","messageId"])&&typeof o.messageId=="string")return[o];break;case"tool.started":if(Je(o,["type","id","name"])&&typeof o.id=="string"&&typeof o.name=="string")return[o];break;case"tool.completed":if(Je(o,["type","id"])&&typeof o.id=="string")return[o];break;case"interrupt.created":if(Je(o,["type","interrupt"])&&Vs(o.interrupt))return[o];break;case"genui.render":if(Je(o,["type","block"])&&Gt(o.block))return[o];break;case"error":if(Je(o,["type","error"])&&qs(o.error))return[o];break;case"stream.completed":if(Je(o,["type"]))return[o];break}throw wt()}function Ys(e){return e instanceof Error&&e.name==="AbortError"}async function la(e,t){let o=Yn({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),s=new TextDecoder,a="",d=!1,c=!1;try{for(;!d;){let p;try{p=await r.read()}catch(b){if(Ys(b))return;throw wt()}p.done&&(c=!0);try{a+=s.decode(p.value,{stream:!p.done})}catch{throw wt()}let u=a.split(/\r?\n\r?\n/);a=p.done?"":u.pop()??"";for(let b of u){let x=b.split(/\r?\n/).filter(v=>v==="data"||v.startsWith("data:")).map(v=>v==="data"?"":v.slice(5).replace(/^ /,""));if(x.length!==0){for(let v of Qs(x.join(`
|
|
2415
|
+
`),o))if(await t(v),d=v.type==="stream.completed",d)break;if(d)break}}if(p.done)break}if(!d)throw wt()}finally{if(!c)try{await r.cancel()}catch{}r.releaseLock()}}var Xs=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function Ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ze(e,t,o=[]){let r=Object.keys(e);return t.every(s=>s in e)&&r.every(s=>t.includes(s)||o.includes(s))}function te(e){return typeof e=="string"}function Io(e){if(!Ee(e)||!ze(e,["id","projectId","createdAt","updatedAt"],["label"])||!te(e.id)||!te(e.projectId)||e.label!==void 0&&!te(e.label)||!te(e.createdAt)||!te(e.updatedAt))return;let t=new Date(e.createdAt),o=new Date(e.updatedAt);if(!(Number.isNaN(t.getTime())||Number.isNaN(o.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:t,updatedAt:o}}function ca(e){if(!Ee(e)||e.success!==!1||!Ee(e.error))return!1;let t=e.error;return ze(e,["success","error"])&&ze(t,["code","message","retryable"])&&typeof t.code=="string"&&Xs.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function Js(e){if(!Ee(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return ze(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function Zs(e){return Array.isArray(e)&&e.length<=6&&e.every(t=>Ee(t)&&ze(t,["label","text"])&&te(t.label)&&t.label.length>=1&&t.label.length<=40&&te(t.text)&&t.text.length>=1&&t.text.length<=500)}function el(e){return Ee(e)&&ze(e,[],["title","welcomeMessage","primaryColor","quickPrompts"])&&(e.title===void 0||te(e.title))&&(e.welcomeMessage===void 0||te(e.welcomeMessage))&&(e.primaryColor===void 0||te(e.primaryColor))&&(e.quickPrompts===void 0||Zs(e.quickPrompts))}function tl(e){if(!Ee(e)||!ze(e,["webApp","projects","models"],["thread"])||!Ee(e.webApp))return;let t=e.webApp;if(!ze(t,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!te(t.id)||!te(t.name)||!te(t.defaultProjectId)||t.description!==void 0&&!te(t.description)||t.defaultModelKey!==void 0&&!te(t.defaultModelKey)||t.identityAssurance!=="unverified"||!Ee(t.assistant)||!ze(t.assistant,["id","name"],["description"])||!te(t.assistant.id)||!te(t.assistant.name)||t.assistant.description!==void 0&&!te(t.assistant.description)||!Js(t.features)||!el(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>Ee(r)&&ze(r,["id","name"])&&te(r.id)&&te(r.name))||!Array.isArray(e.models)||!e.models.every(r=>Ee(r)&&ze(r,["key","label"])&&te(r.key)&&te(r.label)))return;let o=e.thread===void 0?void 0:Io(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function ol(e){if(!Ee(e)||!ze(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(Io);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function nl(e){return Ee(e)&&te(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||te(e.content)||Array.isArray(e.content)&&e.content.every(t=>Gt(t)!==void 0))}function rl(e){return Ee(e)&&ze(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(nl)?e:void 0}function il(e){return Ee(e)&&ze(e,["ref","name","mimeType","size"])&&te(e.ref)&&te(e.name)&&te(e.mimeType)&&typeof e.size=="number"?e:void 0}function da(e,t){return o=>Ee(o)&&ze(o,e)&&t(o)?o:void 0}var Ao=class{constructor(t){this.options=t;this.baseUrl=`${t.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(t.webAppId)}/runtime`,this.fetchImplementation=t.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(t={},o){return this.request("bootstrap",tl,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",ol,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",Io,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,Io,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,da(["id"],s=>te(s.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,rl,{query:o,signal:r})}async streamMessage(t,o,r,s){return this.streamRequest(`threads/${encodeURIComponent(t)}/messages/stream`,o,r,s)}async resumeInterrupt(t,o,r,s,a){return this.streamRequest(`threads/${encodeURIComponent(t)}/interrupts/${encodeURIComponent(o)}/resume`,r,s,a)}async streamRequest(t,o,r,s){let a;try{a=await this.fetchRequest(t,{method:"POST",body:o,signal:s})}catch(d){throw pa(d)||d instanceof Fe?d:new Fe("STREAM_FAILED","Stream failed",!0)}if(a.ok||await this.throwResponseError(a),!a.body||!a.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(a.body)try{await a.body.cancel()}catch{}throw new Fe("STREAM_FAILED","Stream failed",!0,a.status)}await la(a.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,da(["aborted"],s=>typeof s.aborted=="boolean"),{method:"POST",query:o,signal:r})}async uploadAttachment(t,o,r={},s){let a=new FormData,d=typeof File<"u"&&o instanceof File?o.name:"attachment";return a.append("file",o,d),this.request(`threads/${encodeURIComponent(t)}/attachments`,il,{method:"POST",query:r,body:a,signal:s})}async request(t,o,r={}){let s;try{s=await this.fetchRequest(t,r)}catch(c){throw pa(c)||c instanceof Fe?c:new Fe("INTERNAL_ERROR","Request failed",!0)}let a;try{a=await s.json()}catch{throw this.internalError(s.status)}if(ca(a))throw new Fe(a.error.code,a.error.message,a.error.retryable,s.status);if(!s.ok||!Ee(a)||!ze(a,["success","data"])||a.success!==!0)throw this.internalError(s.status);let d=o(a.data);if(d===void 0)throw this.internalError(s.status);return d}async fetchRequest(t,o){let r=await this.options.identityProvider.getIdentity(o.signal),s=new URL(`${this.baseUrl}/${t}`);for(let[c,p]of Object.entries(o.query??{}))p!==void 0&&s.searchParams.set(c,p);let a=new Headers;r.bearerToken!==void 0?a.set("Authorization",`Bearer ${r.bearerToken}`):a.set("X-Axiom-External-User-Id",r.externalUserId??"");let d;return o.body instanceof FormData?d=o.body:o.body!==void 0&&(a.set("Content-Type","application/json"),d=JSON.stringify(o.body)),this.fetchImplementation(s,{method:o.method??"GET",headers:a,body:d,signal:o.signal,credentials:"omit"})}async throwResponseError(t){let o;try{o=await t.json()}catch{throw this.internalError(t.status)}throw ca(o)?new Fe(o.error.code,o.error.message,o.error.retryable,t.status):this.internalError(t.status)}internalError(t){return new Fe("INTERNAL_ERROR","Invalid server response",!1,t)}};function pa(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var Eo=n(w());var At=n(i());function ma(){let{createThread:e}=tt(),{menuCollapsed:t,setMenuCollapsed:o}=ke();(0,Eo.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,Eo.useCallback)(async()=>{try{await e("New Thread")}catch(u){console.error("Failed to create new thread:",u)}},[e]),s=t??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,At.jsx)(hr,{size:20}),order:0},...s?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,At.jsx)(_n,{})}]];return(0,At.jsx)(so,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!s,collapsed:s,onCollapsedChange:o,onNewAnalysis:r,onItemClick:u=>{u.type==="action"&&u.builtin==="new-analysis"?r():u.type==="action"&&u.id==="thread-history-toggle"&&o(!1)}},s?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function ua(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let t=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,o=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,s=new WeakMap;return XMLHttpRequest.prototype.open=function(d,c){s.set(this,String(c)),o.call(this,d,c,!0)},XMLHttpRequest.prototype.send=function(d){let c=s.get(this)??"";if(!c.startsWith(t)||!/\/sandbox\/uploadfile$/.test(c)){r.call(this,d);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,d);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,d)}).catch(()=>{r.call(this,d)})},()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=r}}var Re=n(i());function al(e,t){let r=ga(e.welcome)??ga(t.welcomeMessage),s=e.quickPrompts??t.quickPrompts??[];return{...r!==void 0?{welcome:r}:{},quickPrompts:s}}function ga(e){return typeof e=="string"&&e.length>0?e:void 0}function sl(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function ll(e){return e instanceof Fe?e:new Fe("INTERNAL_ERROR","Request failed",!0)}function cl(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function oS(e){sl(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${cl(e.identity)}`;return(0,Re.jsx)(dl,{...e},t)}function dl({gatewayUrl:e,webAppId:t,identity:o,onError:r,onChatReady:s,onChatMessage:a,fetch:d,className:c,welcome:p,quickPrompts:u}){let[b,x]=(0,Ne.useState)({status:"loading"}),v=(0,Ne.useRef)(o);v.current=o;let g=(0,Ne.useRef)(r);g.current=r;let m=(0,Ne.useRef)();return m.current||(m.current=new Ao({gatewayUrl:e,webAppId:t,identityProvider:{getIdentity:async()=>{let f=v.current;if(f.mode!=="verified")return{externalUserId:f.userId};try{return{bearerToken:await f.tokenProvider()}}catch{throw new Fe("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,Ne.useEffect)(()=>ua({gatewayUrl:e,webAppId:t,identity:o}),[e,t,o]),(0,Ne.useEffect)(()=>{let f=!1,W=m.current;return(async()=>{try{let j=await W.bootstrap({});if(f)return;x({status:"ready",bootstrap:j})}catch(j){if(f)return;let A=ll(j);x({status:"error",error:A}),g.current?.(A)}})(),()=>{f=!0}},[]),b.status==="loading"?(0,Re.jsx)("div",{className:c}):b.status==="error"?(0,Re.jsxs)("div",{className:c,role:"alert",children:[(0,Re.jsx)("strong",{children:"Unable to load the assistant"}),(0,Re.jsx)("div",{children:b.error.code}),(0,Re.jsx)("button",{type:"button",onClick:()=>x({status:"loading"}),children:"Retry"})]}):(0,Re.jsx)(ml,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:b.bootstrap,onChatReady:s,onChatMessage:a,welcome:p,quickPrompts:u})}function pl(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function ml({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:s,onChatMessage:a,className:d,welcome:c,quickPrompts:p}){let u=(0,Ne.useMemo)(()=>pl(r.webApp.assistant),[r.webApp.assistant]),b=(0,Ne.useMemo)(()=>al({welcome:c,quickPrompts:p},r.webApp.appearance),[c,p,r.webApp.appearance]),x=(0,Ne.useMemo)(()=>o.mode==="unverified"?{mode:"unverified",userId:o.userId}:{mode:"verified",tokenProvider:o.tokenProvider},[o]),v=(0,Ne.useCallback)(f=>new Qn({gatewayUrl:e,webAppId:t,identity:x,assistantId:f.assistantId,transport:f.transport,...f.timeout!==void 0?{timeout:f.timeout}:{},...f.headers!==void 0?{headers:f.headers}:{}}),[e,t,x]),g=(0,Ne.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${t}/runtime`,apiKey:"",transport:"sse",assistantId:u.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[u.id,e,t]),m=(0,Ne.useMemo)(()=>({assistants:[u],currentAssistant:u,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>u,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[u]);return(0,Re.jsx)(Jn,{config:{baseURL:g.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:v,children:(0,Re.jsx)(tr,{initialConfig:g,persistToLocalStorage:!1,children:(0,Re.jsx)(Zn.Provider,{value:m,children:(0,Re.jsx)(no,{children:(0,Re.jsx)(ul,{className:d,onChatReady:s,onChatMessage:a,welcome:b.welcome,quickPrompts:b.quickPrompts})})})})})}function ul({className:e,onChatReady:t,onChatMessage:o,welcome:r,quickPrompts:s=[]}){let{threadId:a}=tt(),{currentAssistant:d}=et();if(!d)return null;let c=a??"";return c?(0,Re.jsx)("div",{className:e,children:(0,Re.jsx)(Po,{thread_id:c,assistant_id:d.id,name:d.name,description:d.description,menu:(0,Re.jsx)(ma,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,emptyStateGreeting:r?(0,Re.jsx)("span",{children:r}):void 0,senderPromptsItems:s.length>0?s.map((p,u)=>({key:`quick-${u}`,label:p.label,description:p.text})):void 0,showSkillPrompts:!1,showQuickAnalysis:!1,onChatReady:t,onChatMessage:o})}):(0,Re.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,Re.jsx)(re,{tip:"Creating conversation..."})})}export{ot as a,hi as b,bi as c,ds as d,bs as e,Ro as f,Ki as g,oS as h};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as _i}from"./embed-page-chunk-LE6OFJ7R.js";import{a as cr,b as Pn}from"./embed-page-chunk-Z4S4OYA4.js";import{b as Bi,c as ji}from"./embed-page-chunk-ZKJ7Z7P3.js";import{c as bo,d as vo}from"./embed-page-chunk-KEL6XU6R.js";import{b as it,c as Pi,d as yo,e as xt,f as ho,g as Di,h as Cn,i as An,j as Li,l as Ni,m as Mi}from"./embed-page-chunk-AC6X2XRH.js";import{a as Ri,b as To,c as Fi,d as Wi,e as Ro,f as dr,g as zi,h as Gi}from"./embed-page-chunk-
|
|
1
|
+
import{e as _i}from"./embed-page-chunk-LE6OFJ7R.js";import{a as cr,b as Pn}from"./embed-page-chunk-Z4S4OYA4.js";import{b as Bi,c as ji}from"./embed-page-chunk-ZKJ7Z7P3.js";import{c as bo,d as vo}from"./embed-page-chunk-KEL6XU6R.js";import{b as it,c as Pi,d as yo,e as xt,f as ho,g as Di,h as Cn,i as An,j as Li,l as Ni,m as Mi}from"./embed-page-chunk-AC6X2XRH.js";import{a as Ri,b as To,c as Fi,d as Wi,e as Ro,f as dr,g as zi,h as Gi}from"./embed-page-chunk-I42T7B7V.js";import{a as Oi,b as ko,c as wo,d as xo}from"./embed-page-chunk-VRV57DFE.js";import{a as En}from"./embed-page-chunk-ZXFZANZM.js";import{Da as ki,H as li,Ia as po,J as di,Ja as wi,K as ci,Ka as xi,M as ui,Ma as Ti,N as pi,Oa as Pt,P as uo,X as gi,_a as In,cb as Sn,db as go,eb as fo,fb as Ii,gb as Si,jb as Ci,kb as Ai,l as ii,lb as Ei,ma as fi,mb as mo,n as ai,na as mi,o as $n,oa as yi,qa as hi,ra as bi,xa as vi,z as si}from"./embed-page-chunk-BRETUPSG.js";import{b as Zr,i as Vr,j as Qr,m as yt,q as ao,r as Qe}from"./embed-page-chunk-T25T2YE6.js";import{a as W}from"./embed-page-chunk-MB65DZAX.js";import{Cb as lo,Db as ti,Dc as ni,Fc as oi,Gc as sr,Ha as io,Hc as lr,Ia as Ke,Ja as Hr,La as We,Ma as Ur,Sc as ri,Tb as ar,U as Zt,W as ee,Wa as Yr,Y as Rn,Z as Wt,_ as mt,aa as Vt,ca as rr,da as ir,eb as Xr,fa as $r,fc as co,ia as un,la as qr,mb as Jr,na as Kr,oa as Et,ob as ei,ra as pe,ta as De,tb as so,va as wt,xa as rt,ya as Fe,yc as Qt}from"./embed-page-chunk-O4QK5LWZ.js";import{a as Re}from"./embed-page-chunk-4BKXE5ON.js";import{e as T}from"./embed-page-chunk-6Y3UYJ6Z.js";var zs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},team:{label:"team",color:"green"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function Dn(e){return zs[e]??{label:"capability",color:"blue"}}var Bs={enabled:"green",draft:"orange",disabled:"default"};function qi(e){return Bs[e]??"default"}var $i={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function qn(e){return $i[e]??$i.cyan}function $d(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Ln(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function pr(e){return((Ln(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function gr(e){let o=(Ln(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function fr(e){let o=(Ln(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function ur(e){let n=Ln(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function qd(e){return e.map(t=>{let n=Ln(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:Dn(o).label,tags:pr(t),version:gr(t),status:fr(t),subAgents:ur(t)}})}function Kd(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:Dn(String(Ln(r).type??"react")).label,subAgentCount:ur(r).length})),o=[];for(let r of e)for(let i of ur(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Ie=T(Re());var ne=T(Re());var h=T(W()),{TextArea:js}=De,{Text:Tt}=We,Ki=["data","execution","workflow","assistant"],Gs={data:"Data & Knowledge",execution:"Execution & Interaction",workflow:"Workflow & Orchestration",assistant:"Assistant & Evaluation",other:"Other"},Kn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>Kn(o));return(t==="tools"||t==="subAgents")&&n.every(o=>typeof o=="string")?[...n].sort():n}return e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>[n,Kn(o,n)])):e},Hi=e=>{if(typeof e!="string")return Kn(e??null);try{return Kn(JSON.parse(e))}catch{return e}},Ui=e=>JSON.stringify(Kn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),$s=Ti(({token:e,css:t})=>({modalBody:t`
|
|
2
2
|
padding: 0;
|
|
3
3
|
height: 92vh;
|
|
4
4
|
width: 100%;
|
package/dist/embed/embed-page.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as f}from"./embed-page-chunk-
|
|
1
|
+
import{h as f}from"./embed-page-chunk-I42T7B7V.js";import"./embed-page-chunk-VRV57DFE.js";import"./embed-page-chunk-4ZSGPIBZ.js";import"./embed-page-chunk-ZXFZANZM.js";import"./embed-page-chunk-BRETUPSG.js";import"./embed-page-chunk-T25T2YE6.js";import{a as b}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{a as g}from"./embed-page-chunk-O4QK5LWZ.js";import"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{b as U,e as s}from"./embed-page-chunk-6Y3UYJ6Z.js";var h=U(d=>{"use strict";var E=g();d.createRoot=E.createRoot,d.hydrateRoot=E.hydrateRoot;var ee});var T=s(h()),k=s(g());var y="axiom-web-app-embed";var x=["axiom:hello","axiom:identity","axiom:send","axiom:config"];function w(e,t){return{source:y,version:1,type:e,payload:t}}var N=6,z=40,B=500;function H(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Object.keys(t);return n.length!==2||!n.includes("label")||!n.includes("text")?!1:typeof t.label=="string"&&t.label.length>=1&&t.label.length<=z&&typeof t.text=="string"&&t.text.length>=1&&t.text.length<=B}function Q(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(t.length>=N)break;H(n)&&t.push({label:n.label,text:n.text})}return t}function _(e){if(typeof e!="object"||e===null)return null;let t=e,n={};if(typeof t.welcome=="string"&&t.welcome.length>0&&(n.welcome=t.welcome),Array.isArray(t.quicks)){let r=Q(t.quicks);(r.length>0||t.quicks.length===0)&&(n.quicks=r)}return n.welcome===void 0&&n.quicks===void 0?null:n}function R(e,t){if(typeof e!="object"||e===null)return null;let n=e;return n.source!==y||n.version!==1||typeof n.type!="string"||!t.includes(n.type)?null:{type:n.type,payload:n.payload}}var p=s(b()),P=/^[A-Za-z0-9._:@-]{1,128}$/,q="Open this chat from the host page embed to start chatting.",v="axiom-embed-root",C="axiom-embed-style",A=32768,G=`
|
|
2
2
|
html, body, #${v} { height: 100%; margin: 0; }
|
|
3
3
|
.axiom-embed-fill { height: 100% !important; min-height: 0 !important; }
|
|
4
4
|
.axiom-embed-card { display: flex; align-items: center; justify-content: center; height: 100%; margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: #64748b; padding: 24px; box-sizing: border-box; text-align: center; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/gateway",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"uuid": "^9.0.1",
|
|
49
49
|
"web-push": "^3.6.7",
|
|
50
50
|
"zod": "3.25.76",
|
|
51
|
-
"@axiom-lattice/cli-a2a": "0.2.
|
|
52
|
-
"@axiom-lattice/core": "4.2.
|
|
53
|
-
"@axiom-lattice/pg-stores": "3.1.
|
|
54
|
-
"@axiom-lattice/protocols": "4.3.
|
|
55
|
-
"@axiom-lattice/queue-redis": "1.1.
|
|
51
|
+
"@axiom-lattice/cli-a2a": "0.2.11",
|
|
52
|
+
"@axiom-lattice/core": "4.2.16",
|
|
53
|
+
"@axiom-lattice/pg-stores": "3.1.16",
|
|
54
|
+
"@axiom-lattice/protocols": "4.3.1",
|
|
55
|
+
"@axiom-lattice/queue-redis": "1.1.11"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/bcrypt": "^6.0.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"tsconfig-paths": "^4.2.0",
|
|
75
75
|
"tsup": "^8.5.0",
|
|
76
76
|
"typescript": "^5.8.2",
|
|
77
|
-
"@axiom-lattice/react-sdk": "4.2.
|
|
77
|
+
"@axiom-lattice/react-sdk": "4.2.2"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean --sourcemap && pnpm copy:embed-assets",
|