@lacneu/atrium 0.60.0 → 0.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccessTab-BBYqbyQz.js → AccessTab-BlTwl2Uk.js} +1 -1
- package/dist/assets/{AdvancedFilter-BTcB0NuZ.js → AdvancedFilter-C5pnO4fi.js} +1 -1
- package/dist/assets/{AgentFilesTab-BjPywJ7Q.js → AgentFilesTab-tYeG81Bo.js} +1 -1
- package/dist/assets/{AnomaliesTab-CYpcTOYy.js → AnomaliesTab-C94n-0pQ.js} +1 -1
- package/dist/assets/{AuditTab-NnWwJHq_.js → AuditTab-D_mhJO5w.js} +1 -1
- package/dist/assets/{BridgeTab-C_I81PZ8.js → BridgeTab-s6Ggg8Zu.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-STVjXTAX.js → ChatDefaultsTab-DYVQXktp.js} +1 -1
- package/dist/assets/{DataTableShell-DAEVsm3y.js → DataTableShell-COEwE2Hv.js} +1 -1
- package/dist/assets/{DetailChips-DerZpgh4.js → DetailChips-8ZpH5ZXE.js} +1 -1
- package/dist/assets/{FeedbacksTab-BdYRB-_C.js → FeedbacksTab-CqJ8NDLb.js} +1 -1
- package/dist/assets/{FieldLabel-BJRoUSf1.js → FieldLabel-hLNtge_D.js} +1 -1
- package/dist/assets/{FilesTab-h10yjTHp.js → FilesTab-lytzpFwp.js} +1 -1
- package/dist/assets/{FilterBar-Byr6OGo7.js → FilterBar-CY1WfFDB.js} +1 -1
- package/dist/assets/{GroupsTab-BJWQQexi.js → GroupsTab-BjjiPSDY.js} +1 -1
- package/dist/assets/{InstancesTab-ZJeQ4rRg.js → InstancesTab-bbthnf8h.js} +1 -1
- package/dist/assets/{IntegrationsTab-CSOlJvFa.js → IntegrationsTab-DQt4Kllc.js} +1 -1
- package/dist/assets/{KpiTab-Dz5IcL9k.js → KpiTab-qUWozfhc.js} +1 -1
- package/dist/assets/{PreferencesTab-Bd-GUi0T.js → PreferencesTab-B1JSLFVE.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-H8zrJADs.js → PromptInjectionsTab-Df6PKtxv.js} +1 -1
- package/dist/assets/{RolesTab-rgpFvkKx.js → RolesTab-DbSxOWRh.js} +1 -1
- package/dist/assets/{ScheduledTab-DbMIc4wG.js → ScheduledTab-km3Zx4dq.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-BeEdMciQ.js → ServiceAccountsTab-Bcd88LfG.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-BgM9O4QZ.js → SubAgentReportsTab-xgRtphLV.js} +1 -1
- package/dist/assets/{ThemeShowroom-BjDGGE3i.js → ThemeShowroom-DxcANzhZ.js} +1 -1
- package/dist/assets/{TimeRangePicker-RVc6k7g6.js → TimeRangePicker-BYCcnF0a.js} +1 -1
- package/dist/assets/{TracesTab-Cb65hpku.js → TracesTab-ColoY1Nx.js} +1 -1
- package/dist/assets/{UsersTab-BPRPmEOS.js → UsersTab-B0IdN_hl.js} +1 -1
- package/dist/assets/{VoiceTab-tgovFfm-.js → VoiceTab-qZ5tMxmC.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-Dj4OC_Nj.js → highlighted-body-OFNGDK62-xjw7PDBM.js} +1 -1
- package/dist/assets/{index-CW5WE31O.js → index-CNwjY680.js} +6 -6
- package/dist/assets/mermaid-GHXKKRXX-DxPFrHWq.js +1 -0
- package/dist/assets/{pdf-Bx7jp7ID.js → pdf-CLjbM27Z.js} +1 -1
- package/dist/assets/{tabs-Kb2_G-yp.js → tabs-fDXC7itk.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/mermaid-GHXKKRXX-DURCfVhS.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bd as r,E as i,GP as a,Gd as o,Hd as s,Jd as c,Kd as l,Qd as u,Rd as d,Ud as f,Vd as p,Wd as m,Xd as h,Yd as g,Zd as _,eF as v,qd as y,zd as b}from"./dist-De2K23IB.js";import{C as x,S,T as C,dt as w,w as T,x as E}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bd as r,E as i,GP as a,Gd as o,Hd as s,Jd as c,Kd as l,Qd as u,Rd as d,Ud as f,Vd as p,Wd as m,Xd as h,Yd as g,Zd as _,eF as v,qd as y,zd as b}from"./dist-De2K23IB.js";import{C as x,S,T as C,dt as w,w as T,x as E}from"./index-CNwjY680.js";var D=t(e(),1);function O(e){return e===`user`?s():e===`all`?p():r({group:e.group})}function k(e){return e===`common`?b():e===`owner`?d():r({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=v(i.admin.listUsers,{}),[t,n]=(0,D.useState)(``),r=v(i.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:u()}),(0,A.jsxs)(E,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":_(),children:(0,A.jsx)(C,{placeholder:_()})}),(0,A.jsx)(S,{children:(e??[]).map(e=>(0,A.jsx)(x,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:h()}):r===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:r.user.label}),(0,A.jsx)(w,{variant:`secondary`,children:r.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:c()}),r.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:r.groups.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:y()}),r.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:r.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(w,{variant:`default`,children:f()}):null,(0,A.jsx)(w,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(w,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:l()}),r.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:r.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(w,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:o()}),r.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:r.permissions.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{am as r,cm as i,dm as a,lm as o,om as s,sm as c,um as l}from"./dist-De2K23IB.js";import{i as u}from"./dist-CXJY_tYD.js";import{t as d}from"./x-DXaZHGzl.js";import{t as f}from"./button-Bd43O_sm.js";import{Bt as p,C as m,S as h,T as g,ft as _,w as v,x as y}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{am as r,cm as i,dm as a,lm as o,om as s,sm as c,um as l}from"./dist-De2K23IB.js";import{i as u}from"./dist-CXJY_tYD.js";import{t as d}from"./x-DXaZHGzl.js";import{t as f}from"./button-Bd43O_sm.js";import{Bt as p,C as m,S as h,T as g,ft as _,w as v,x as y}from"./index-CNwjY680.js";import{r as b}from"./TimeRangePicker-BYCcnF0a.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:a()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],w=1;function T(){return{id:w++,field:``,op:`eq`,value:``}}function E(e){return e.map(e=>({id:w++,field:e.field,op:e.op,value:String(e.value)}))}function D({fields:e,seed:t,onChange:n}){let a=(0,x.useRef)(t),w=!!(a.current&&a.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(a.current):[]);function j(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:b(e.value)})))}function M(e,t){let n=k.map(n=>n.id===e?{...n,...t}:n);A(n),j(n)}function N(){A(e=>[...e,T()])}function P(e){let t=k.filter(t=>t.id!==e);A(t),j(t)}let F=k.filter(e=>e.field!==``&&e.value!==``).length;return(0,S.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,S.jsx)(u,{className:`oc-advfilter__chevron`+(D?` is-open`:``),"aria-hidden":!0}),l(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(y,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(g,{placeholder:i()})}),(0,S.jsx)(h,{children:e.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(y,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(g,{})}),(0,S.jsx)(h,{children:C.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(_,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:c()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":s(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(p,{}),r()]})]}):null]})}export{D as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,Ai as i,Al as a,Ci as o,Cl as s,Di as c,Dl as l,E as u,Ei as d,El as f,GD as p,GP as m,Mi as h,Ml as g,Ni as _,Nl as v,Oi as y,Ol as b,Pi as x,Si as S,Sl as C,Ti as w,Tl as T,ZP as E,_i as D,_l as O,ai as k,al as ee,bi as A,bl as j,cl as M,dl as N,eF as P,fl as te,gi as F,gl as I,gu as L,hi as R,hl as ne,ii as z,il as B,ji as re,jl as ie,ki as V,kl as ae,ll as H,mi as oe,ml as se,mu as ce,ni as U,oi as W,ol as le,pl as ue,qP as G,ri as de,si as fe,sl as pe,ti as me,ul as he,vi as ge,vl as _e,wi as ve,wl as ye,xi as be,xl as xe,yi as Se,yl as Ce}from"./dist-De2K23IB.js";import{t as K}from"./button-Bd43O_sm.js";import{C as we,G as Te,H as q,J as Ee,K as De,Pt as J,Q as Oe,S as ke,T as Ae,X as je,Y as Me,Z as Ne,_t as Pe,b as Fe,dt as Ie,ht as Le,mt as Re,pt as ze,q as Be,vt as Ve,w as He,wt as Ue,x as We}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,Ai as i,Al as a,Ci as o,Cl as s,Di as c,Dl as l,E as u,Ei as d,El as f,GD as p,GP as m,Mi as h,Ml as g,Ni as _,Nl as v,Oi as y,Ol as b,Pi as x,Si as S,Sl as C,Ti as w,Tl as T,ZP as E,_i as D,_l as O,ai as k,al as ee,bi as A,bl as j,cl as M,dl as N,eF as P,fl as te,gi as F,gl as I,gu as L,hi as R,hl as ne,ii as z,il as B,ji as re,jl as ie,ki as V,kl as ae,ll as H,mi as oe,ml as se,mu as ce,ni as U,oi as W,ol as le,pl as ue,qP as G,ri as de,si as fe,sl as pe,ti as me,ul as he,vi as ge,vl as _e,wi as ve,wl as ye,xi as be,xl as xe,yi as Se,yl as Ce}from"./dist-De2K23IB.js";import{t as K}from"./button-Bd43O_sm.js";import{C as we,G as Te,H as q,J as Ee,K as De,Pt as J,Q as Oe,S as ke,T as Ae,X as je,Y as Me,Z as Ne,_t as Pe,b as Fe,dt as Ie,ht as Le,mt as Re,pt as ze,q as Be,vt as Ve,w as He,wt as Ue,x as We}from"./index-CNwjY680.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-B2BXfBvC.js";/* empty css */var Y=t(e(),1),X=2e4,Je=6e4;function Ye(e){return typeof e!=`number`||e<=0?0:Math.round(e/X*100)}function Xe(e){return e<=0?0:Math.round(e/Je*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Ze(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var Qe=3;function $e(e,t){let n=new Map;for(let t of e.split(`
|
|
2
2
|
`))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
|
|
3
3
|
`))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<Qe&&a.push(e)):t>0&&(i+=t,o.length<Qe&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function et(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function tt(){let e=P(u.me.getMe,{host:Ue}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=P(u.admin.listInstances,e!==void 0&&t?{}:`skip`),[o,c]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!t||!r||r.length===0||(!o||!r.some(e=>e.name===o))&&c(r[0].name)},[t,r,o]);let d=P(u.agents.listAgentsForInstance,t&&o?{instanceName:o}:`skip`),p=P(u.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),h=(0,Y.useMemo)(()=>{if(e!==void 0){if(t)return o===null||d===void 0?r!==void 0&&r.length===0?[]:void 0:d.agents.map(e=>({instanceName:o,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(p!==void 0)return p.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,o,d,r,p]),[_,y]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!h||h.length===0||(!_||!h.some(e=>$(e)===_))&&y($(h[0]))},[h,_]);let x=h?.find(e=>$(e)===_)??null,S=E(u.agentFiles.listAgentFiles),[w,D]=(0,Y.useState)({status:`idle`}),O=x?.instanceName??null,k=x?.agentId??null,ee=P(u.compat.forInstance,n&&O!==null?{instanceName:O}:`skip`),A=n&&O!==null?Fe(ee,`agentFiles`):null,j=A===null?!1:A===`loading`?null:A.blocked,M=(0,Y.useCallback)(async()=>{if(!(O===null||k===null)){D({status:`loading`});try{D({status:`done`,files:(await S({instanceName:O,agentId:k})).files})}catch{D({status:`error`})}}},[S,O,k]);(0,Y.useEffect)(()=>{j===!1&&M()},[M,j]);let[N,te]=(0,Y.useState)(null),F=P(u.agentFileCuration.listCurations,t&&O!==null&&k!==null?{instanceName:O,agentId:k}:`skip`),I=P(u.agentFileCuration.curationSettings,t&&O!==null?{instanceName:O}:`skip`),L=E(u.agentFileCuration.requestCuration),[R,ne]=(0,Y.useState)(null),[z,B]=(0,Y.useState)(null),{toast:H}=q(),oe=(0,Y.useMemo)(()=>{let e=new Map;for(let t of F??[])e.has(t.name)||e.set(t.name,t);return e},[F]),se=(0,Y.useCallback)(async e=>{if(!(O===null||k===null)){ne(e);try{let t=await L({instanceName:O,agentId:k,name:e,trigger:`manual`});t.ok?H({title:re(),variant:`success`}):H({title:i({reason:t.reason??`unknown`}),variant:`error`})}catch{H({title:V(),variant:`error`})}finally{ne(null)}}},[L,O,k,H]),U=G(),W=(0,Y.useMemo)(()=>new Intl.NumberFormat(U,{maximumFractionDigits:0}),[U]);return e===void 0||h===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(We,{value:o??``,onValueChange:e=>c(e),children:[(0,Q.jsx)(He,{size:`sm`,"aria-label":g(),children:(0,Q.jsx)(Ae,{})}),(0,Q.jsx)(ke,{children:(r??[]).map(e=>(0,Q.jsx)(we,{value:e.name,children:e.name},e.name))})]}):null,h.length>0?(0,Q.jsxs)(We,{value:_??``,onValueChange:e=>y(e),children:[(0,Q.jsx)(He,{size:`sm`,"aria-label":ie(),children:(0,Q.jsx)(Ae,{})}),(0,Q.jsx)(ke,{children:h.map(e=>(0,Q.jsx)(we,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]}),x===null?null:A===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):A!==null&&A.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(J,{size:14,"aria-hidden":!0}),` `,qe(A.gatewayVersion,A.provider)]}):w.status===`loading`||w.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):w.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[b(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void M(),children:ce()})]}):w.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:w.files.map(e=>{let n=Ye(e.size),r=n>=80;return(0,Q.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,Q.jsx)(Ie,{variant:`outline`,children:l()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:f({size:Z(e.size,U)})}),(0,Q.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,Q.jsx)(`span`,{className:`oc-afiles__pct`,children:T({pct:W.format(n)})}),r?(0,Q.jsx)(J,{size:14,className:`oc-afiles__warn`,"aria-label":ye()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>te(e),children:t?C():xe()}),t&&!e.missing?(0,Q.jsx)(nt,{curatable:Ke.includes(e.name),size:e.size??0,budget:I?.budgetChars??null,enabled:I?.enabled??!1,curation:oe.get(e.name)??null,inFlight:R===e.name,onCurate:()=>void se(e.name),onReview:e=>B(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:s({used:Z(Ze(w.files),U),total:Z(Je,U),pct:W.format(Xe(Ze(w.files)))})})]}),N&&x?(0,Q.jsx)(rt,{instanceName:x.instanceName,agentId:x.agentId,name:N.name,isAdmin:t,onClose:()=>te(null),onSaved:()=>void M()}):null,z?(0,Q.jsx)(it,{curationId:z,onClose:()=>B(null),onApplied:()=>{B(null),M()}}):null]})}function nt({curatable:e,size:t,budget:n,enabled:r,curation:i,inFlight:a,onCurate:o,onReview:s}){return i?.status===`proposed`?(0,Q.jsx)(K,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:_()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Ie,{variant:`outline`,className:`oc-afiles__curate-status`,children:h()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:x()}):null}function rt({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:a}){let o=E(u.agentFiles.getAgentFile),s=E(u.agentFiles.setAgentFile),c=q(),[l,d]=(0,Y.useState)(null),[f,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),D=(0,Y.useCallback)(async r=>{h(!1);try{let i=await o({instanceName:e,agentId:t,name:n});d({content:i.content,updatedAtMs:i.updatedAtMs}),r||_(i.content),C(!1)}catch{h(!0)}},[o,e,t,n]);(0,Y.useEffect)(()=>{D(!1)},[D]);async function k(){if(l!==null){x(!0),T(!1);try{await s({instanceName:e,agentId:t,name:n,content:g,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(se({name:n})),a(),await D(!1)}catch(e){et(e)?C(!0):T(!0)}finally{x(!1)}}}let A=l!==null&&g!==l.content,P=(0,Y.useMemo)(()=>l===null?null:$e(l.content,g),[l,g]),F=g.length>X,R=G(),z=(0,Y.useMemo)(()=>new Intl.NumberFormat(R),[R]);return(0,Q.jsx)(ze,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Ve,{children:j({name:n})}),(0,Q.jsxs)(Le,{children:[Ce({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,_e()]})]})]}),f?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[te(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void D(!1),children:ce()})]}):l===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:g,readOnly:!r,spellCheck:!1,onChange:e=>_(e.target.value),"aria-label":j({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:O()}),S?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[N(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void D(!0),children:he()})]}):null,w?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:ue()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${F?` is-over`:``}`,children:I({count:z.format(g.length),max:z.format(X)})}),r?(0,Q.jsx)(K,{size:`sm`,disabled:!A||b||S,onClick:()=>y(!0),children:b?L():ne()}):null]})]}),(0,Q.jsx)(Te,{open:v,onOpenChange:y,children:(0,Q.jsxs)(Ee,{children:[(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(Oe,{children:H({name:n})}),(0,Q.jsx)(Me,{children:M({agent:t})})]}),P?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:pe({added:P.added,removed:P.removed})}),P.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:le()}),P.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,P.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:ee()}),P.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(je,{children:[(0,Q.jsx)(Be,{children:p()}),(0,Q.jsx)(De,{onClick:()=>void k(),children:B()})]})]})})]})})}function it({curationId:e,onClose:t,onApplied:n}){let i=P(u.agentFileCuration.getProposal,{curationId:e}),a=E(u.agentFileCuration.approveCuration),s=r(u.agentFileCuration.rejectCuration),{toast:l}=q(),[f,p]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(``),b=G(),x=(0,Y.useMemo)(()=>i?$e(i.beforeContent,i.proposedContent):null,[i]);async function C(){p(`approve`);try{let t=await a({curationId:e});t.ok?(l({title:y(),variant:`success`}),n()):l({title:t.reason===`conflict`?d():w({reason:t.reason??`unknown`}),variant:`error`})}catch{l({title:V(),variant:`error`})}finally{p(null)}}async function T(n){p(`reject`);try{let r=_.trim();(await s({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?l({title:n?U():c(),variant:`success`}):l({title:S(),variant:`error`}),t()}catch{l({title:V(),variant:`error`})}finally{p(null)}}return(0,Q.jsx)(ze,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Ve,{children:i?ve({name:i.name}):m()}),(0,Q.jsx)(Le,{children:o()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):i===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[be({before:Z(i.beforeSize,b),after:Z(i.proposedSize,b)}),i.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(J,{size:13,"aria-hidden":!0}),` `,A()]}):null]}),x?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:Se({added:x.added,removed:x.removed})}):null,i.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:me({feedback:i.feedback})}):null,x&&x.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:oe()}),(0,Q.jsx)(`ul`,{children:x.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:R()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:ge()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.proposedContent})]})]})]}),h?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:fe()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:W(),value:_,onChange:e=>v(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`ghost`,onClick:()=>g(!1),disabled:f!==null,children:k()}),(0,Q.jsx)(K,{variant:`outline`,onClick:()=>void T(!1),disabled:f!==null,children:f===`reject`?L():z()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void T(!0),disabled:f!==null,children:f===`reject`?L():de()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`outline`,onClick:()=>g(!0),disabled:f!==null||i==null,children:D()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void C(),disabled:f!==null||i==null,children:f===`approve`?L():F()})]})]})})}export{tt as AgentFilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$y as i,Ay as a,By as ee,E as o,Fy as s,Gy as te,Hy as ne,Iy as c,Jy as l,Ky as re,Ly as ie,My as u,Ny as d,Py as f,Qy as p,Ry as m,Uy as h,Vy as g,Wy as ae,Xy as _,Yy as oe,Zy as se,_b as ce,ab as le,bb as v,cb as ue,db as de,eF as y,eb as fe,fb as pe,gb as me,hb as he,ib as ge,jy as b,ky as x,lb as _e,mb as ve,nb as ye,ob as S,pb as C,qy as w,rb as T,sb as E,tb as D,ub as O,vb as k,xb as A,yb as j,zy as M}from"./dist-De2K23IB.js";import{C as N,H as P,S as F,T as I,U as be,_t as L,dt as R,i as xe,mt as z,nn as B,o as Se,pt as V,rn as Ce,rt as we,vt as H,w as U,wt as Te,x as W}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$y as i,Ay as a,By as ee,E as o,Fy as s,Gy as te,Hy as ne,Iy as c,Jy as l,Ky as re,Ly as ie,My as u,Ny as d,Py as f,Qy as p,Ry as m,Uy as h,Vy as g,Wy as ae,Xy as _,Yy as oe,Zy as se,_b as ce,ab as le,bb as v,cb as ue,db as de,eF as y,eb as fe,fb as pe,gb as me,hb as he,ib as ge,jy as b,ky as x,lb as _e,mb as ve,nb as ye,ob as S,pb as C,qy as w,rb as T,sb as E,tb as D,ub as O,vb as k,xb as A,yb as j,zy as M}from"./dist-De2K23IB.js";import{C as N,H as P,S as F,T as I,U as be,_t as L,dt as R,i as xe,mt as z,nn as B,o as Se,pt as V,rn as Ce,rt as we,vt as H,w as U,wt as Te,x as W}from"./index-CNwjY680.js";import{n as Ee}from"./TimeRangePicker-BYCcnF0a.js";import{t as De}from"./FilterBar-CY1WfFDB.js";import{t as Oe}from"./DataTableShell-COEwE2Hv.js";import{t as G}from"./dispatchErrorInfo-DKMvYSfG.js";var K=t(e(),1),q=n(),J=`__all__`,ke=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Ae(e){return e===`open`?A():e===`acknowledged`?v():j()}var je=[`info`,`warn`,`critical`],Me=[`detector`,`agent`,`user`],Ne={kind:`relative`,from:`now-30d`,to:`now`},Pe=200,Y=`all`;function X(){let e=Ce({from:`/settings/anomalies`}),t=B({from:`/settings/anomalies`}),n=e.q??``,a=e.status===Y?J:e.status,s=e.severity??J,c=e.kind??J,[u,d]=(0,K.useState)(J),f=xe(e.from,e.to),{from:v,to:b}=Ee(f),x=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),A=e=>void t({search:t=>({...t,status:e===J?Y:e})}),j=e=>void t({search:t=>({...t,severity:e===J?void 0:e})}),L=e=>void t({search:t=>({...t,kind:e===J?void 0:e})}),z=e=>void t({search:t=>({...t,...Se(e)})}),V=be(),H=P(),G=r(o.anomalies.resolveAnomaly),X=(y(o.me.getMe,{host:Te})?.permissions??[]).includes(`admin.manage`),Z=y(o.anomalies.listAnomalies,{limit:Pe,filter:{q:n||void 0,from:v,to:b,anomalyStatus:a===J?void 0:a,severity:s===J?void 0:s,source:u===J?void 0:u,kind:c===J?void 0:c}}),Q=(0,K.useMemo)(()=>{let e=new Set;for(let t of Z??[])e.add(t.kind);return[...e].sort()},[Z]),ze=n!==``||a!==`open`||s!==J||u!==J||c!==J||f.kind!==`relative`||f.from!==Ne.from;function Be(){d(J),t({search:{status:`open`},replace:!0})}async function Ve(e){if(await V({title:k(),description:(0,q.jsxs)(q.Fragment,{children:[ce(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,me(),` `,(0,q.jsx)(`strong`,{children:he()}),`.`,` `,ve()]}),confirmLabel:C()}))try{await G({anomalyId:e._id,status:`resolved`}),H.success(pe(),e.kind)}catch(e){H.error(de(),e)}}async function He(e){try{await G({anomalyId:e._id,status:`acknowledged`}),H.success(O(),e.kind)}catch(e){H.error(_e(),e)}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`oc-admin__hint`,children:[ue(),` `,(0,q.jsx)(`strong`,{children:E()}),` `,S(),` `,(0,q.jsx)(`strong`,{children:le()}),` `,ge(),` `,(0,q.jsx)(`strong`,{children:T()}),` `,ye(),` `,(0,q.jsx)(`span`,{className:`oc-filter__window`,children:D()})]}),(0,q.jsxs)(De,{q:n,onQChange:x,searchPlaceholder:fe(),timeRange:f,onTimeRangeChange:z,onReset:Be,canReset:ze,children:[(0,q.jsxs)(W,{value:a,onValueChange:A,children:[(0,q.jsx)(U,{size:`sm`,className:`w-36`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{value:J,children:i()}),ke.map(e=>(0,q.jsx)(N,{value:e.value,children:Ae(e.value)},e.value))]})]}),(0,q.jsxs)(W,{value:s,onValueChange:j,children:[(0,q.jsx)(U,{size:`sm`,className:`w-36`,children:(0,q.jsx)(I,{placeholder:p()})}),(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{value:J,children:se()}),je.map(e=>(0,q.jsx)(N,{value:e,children:e},e))]})]}),(0,q.jsxs)(W,{value:u,onValueChange:d,children:[(0,q.jsx)(U,{size:`sm`,className:`w-32`,children:(0,q.jsx)(I,{placeholder:_()})}),(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{value:J,children:oe()}),Me.map(e=>(0,q.jsx)(N,{value:e,children:e},e))]})]}),(0,q.jsxs)(W,{value:c,onValueChange:L,children:[(0,q.jsx)(U,{size:`sm`,className:`w-36`,children:(0,q.jsx)(I,{placeholder:l()})}),(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{value:J,children:w()}),Q.map(e=>(0,q.jsx)(N,{value:e,children:e},e))]})]})]}),(0,q.jsx)(Oe,{title:re(),rows:Z,emptyHint:a===`open`?te():ae(),rowActions:e=>X&&e.status===`open`?[{label:h(),onSelect:()=>void Ve(e)},{label:ne(),onSelect:()=>void He(e)}]:[],columns:[{header:g(),cell:e=>(0,q.jsx)(`span`,{className:`oc-traces__time`,children:we(e.at)}),sort:e=>e.at},{header:l(),cell:e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:p(),cell:e=>(0,q.jsx)(Le,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:ee(),cell:e=>(0,q.jsx)($,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:_(),cell:e=>(0,q.jsx)(R,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:M(),cell:e=>(0,q.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,q.jsx)(Ie,{row:e})]}),sort:e=>e.message},{header:m(),cell:e=>(0,q.jsx)(Fe,{row:e}),sort:e=>e.evidence??null},{header:ie(),cell:e=>e.correlationId?(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:Re(e.correlationId)}):(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function Z(e){if(e.kind!==`openclaw.dispatch_failures`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function Q(e){if(e.kind!==`subagent.failure`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{failedCount:t.failedCount,totalCount:t.totalCount,errorCategories:t.errorCategories}}catch{return{}}}function Fe({row:e}){let t=B();if(e.kind===`subagent.failure`){let n=Q(e);return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,c()]}):null]})}let n=Z(e);if(!n.dominantCode)return(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`});let r=G(n.dominantCode),i=n.sampleCorrelationId;return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,q.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:i,limit:100}}),children:[`↗ `,c()]}):null]})}function Ie({row:e}){let[t,n]=(0,K.useState)(!1),r=y(o.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[s(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,q.jsx)(V,{open:t,onOpenChange:n,children:(0,q.jsxs)(z,{className:`oc-anomaly__attachments-dialog`,children:[(0,q.jsx)(L,{children:(0,q.jsx)(H,{children:f()})}),r===void 0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:d()}):r.length===0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:u()}):(0,q.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,q.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,q.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,q.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Le({severity:e}){return(0,q.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function $({status:e}){return e===`open`?(0,q.jsx)(R,{variant:`destructive`,children:b()}):e===`acknowledged`?(0,q.jsx)(R,{variant:`secondary`,children:a()}):(0,q.jsx)(R,{variant:`outline`,children:x()})}function Re(e){return e.length>8?e.slice(0,8):e}export{X as AnomaliesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$n as r,Cx as i,E as a,Ex as o,Qn as s,Sx as c,Tx as l,_x as u,bx as d,eF as f,er as p,fx as m,gx as h,hx as g,mx as _,nr as v,px as y,rr as b,tr as x,vx as S,wx as C,xx as w,yx as T}from"./dist-De2K23IB.js";import{C as E,S as D,T as O,a as k,i as A,n as j,nn as M,o as N,rn as P,rt as F,s as I,w as L,x as R}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$n as r,Cx as i,E as a,Ex as o,Qn as s,Sx as c,Tx as l,_x as u,bx as d,eF as f,er as p,fx as m,gx as h,hx as g,mx as _,nr as v,px as y,rr as b,tr as x,vx as S,wx as C,xx as w,yx as T}from"./dist-De2K23IB.js";import{C as E,S as D,T as O,a as k,i as A,n as j,nn as M,o as N,rn as P,rt as F,s as I,w as L,x as R}from"./index-CNwjY680.js";import{n as ee}from"./TimeRangePicker-BYCcnF0a.js";import{t as z}from"./FilterBar-CY1WfFDB.js";import{t as B}from"./AdvancedFilter-C5pnO4fi.js";import{t as V}from"./DataTableShell-COEwE2Hv.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:j,to:`now`},G=`__all__`,K=[{value:`action`,label:b()},{value:`realLabel`,label:v()},{value:`targetLabel`,label:x()},{value:`impersonated`,label:p()},{value:`resource`,label:r()},{value:`resourceId`,label:s()}];function q(){let e=P({from:`/settings/audit`}),t=M({from:`/settings/audit`}),n=e.q??``,r=e.action??G,s=e.impersonated??G,p=e.resource??G,v=A(e.from,e.to),b=(0,H.useMemo)(()=>I(e.adv),[e.adv]),{from:x,to:j}=ee(v),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...N(e)})}),Q=e=>void t({search:t=>({...t,adv:k(e)}),replace:!0}),$=f(a.admin.listAudit,{filter:{q:n||void 0,from:x,to:j,action:r===G?void 0:r,resource:p===G?void 0:p,impersonated:s===G?void 0:s===`yes`,advanced:b.length>0?b:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||s!==G||p!==G||b.length>0||v.kind!==`relative`||v.from!==W.from;function ie(){t({search:{},replace:!0})}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`oc-admin__hint`,children:[o(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:l()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:C(),timeRange:v,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(R,{value:r,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{placeholder:i()})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:c()}),te.map(e=>(0,U.jsx)(E,{value:e,children:e},e))]})]}),(0,U.jsxs)(R,{value:s,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:w()}),(0,U.jsx)(E,{value:`yes`,children:d()}),(0,U.jsx)(E,{value:`no`,children:T()})]})]}),(0,U.jsxs)(R,{value:p,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{placeholder:S()})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:u()}),ne.map(e=>(0,U.jsx)(E,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:b,onChange:Q}),(0,U.jsx)(V,{title:h(),rows:$,emptyHint:g(),columns:[{header:_(),cell:e=>F(e.at),sort:e=>e.at},{header:i(),cell:e=>e.action,sort:e=>e.action},{header:y(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:m(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:S(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$h as i,A_ as a,Ag as o,Bc as s,Bg as c,C_ as l,Cg as u,Cn as d,D as f,D_ as p,Dg as m,Dn as h,E as g,E_ as ee,Eg as _,Fc as v,Fg as te,Gc as y,Gg as ne,Hc as b,Hg as re,Ic as x,Ig as ie,Jg as ae,Kc as S,Kg as oe,Lc as C,Lg as se,Mg as ce,Ng as le,Og as ue,Pg as de,Qh as fe,Rc as pe,Rg as me,S_ as he,Sg as ge,Sn as _e,T_ as ve,Tg as ye,Uc as be,Ug as xe,Vc as Se,Vg as Ce,Wc as we,Wg as Te,ZP as Ee,Zh as w,__ as De,_g as Oe,ag as ke,b_ as Ae,bg as je,bn as Me,cg as Ne,dg as T,eF as E,eg as Pe,fg as Fe,g_ as Ie,gg as Le,hg as Re,ig as ze,jc as Be,jg as Ve,k_ as He,kg as Ue,lg as We,mg as Ge,ng as Ke,og as qe,pg as Je,qc as Ye,qg as Xe,rg as Ze,sg as Qe,tg as $e,ug as et,vg as tt,w_ as nt,wg as rt,wn as it,x_ as at,xg as ot,xn as st,yg as ct,zc as lt,zg as ut}from"./dist-De2K23IB.js";import{i as D,r as dt}from"./dist-CXJY_tYD.js";import{t as ft}from"./chevrons-up-down-DIXCqs3W.js";import{i as pt,n as O,o as mt,r as ht,s as gt}from"./FieldLabel-BJRoUSf1.js";import{i as _t,n as vt,r as yt,t as bt}from"./tabs-Kb2_G-yp.js";import{t as k}from"./button-Bd43O_sm.js";import{$ as xt,$t as A,C as j,H as St,Kt as Ct,Lt as M,Pt as N,S as P,T as F,_t as wt,dt as I,en as Tt,et as Et,ft as L,h as Dt,ht as Ot,it as R,m as kt,mt as At,nn as jt,pt as Mt,rn as Nt,rt as Pt,tt as Ft,vt as It,w as z,wt as Lt,x as B}from"./index-CW5WE31O.js";import{r as Rt}from"./locales-CPjguROj.js";import{a as zt,i as V,n as Bt,o as H,r as U,t as Vt}from"./table-BRilRxUj.js";import{t as Ht}from"./FilterBar-Byr6OGo7.js";import{a as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt}from"./compatView-B2BXfBvC.js";import{t as W}from"./dispatchErrorInfo-DKMvYSfG.js";var Yt=f(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Xt=f(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function Zt(e){return e.filter(e=>e.state===`error`)}function Qt(e){return e.reachable&&Zt(e.targets).length===0}function $t(e){return Qt(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function en(e){return e.state===`error`&&e.lastErrorCode!==null}function tn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function nn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function rn(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return nn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,an={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function on(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function sn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function cn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function ln(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Gt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function un(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=cn(t.key,e),a=cn(t.key,r);return i&&a?0:i?1:a?-1:n*ln(t.key,e,r)})}function dn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function fn(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>X(e.label,t.label))}function pn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Gt(e,t)??X(e,t))}var Z=n();function mn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(an),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>dn(o),[o]),c=(0,G.useMemo)(()=>fn(o),[o]),l=(0,G.useMemo)(()=>pn(o),[o]),u=(0,G.useMemo)(()=>un(sn(o,n),i),[o,n,i]);function d(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Ht,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Fe(),onReset:()=>r(an),canReset:on(n),children:[(0,Z.jsxs)(B,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:et()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(j,{value:J,children:T()}),s.map(e=>(0,Z.jsx)(j,{value:e,children:gn(e)},e))]})]}),(0,Z.jsxs)(B,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(F,{placeholder:We()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(j,{value:J,children:T()}),c.map(e=>(0,Z.jsx)(j,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(B,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:Ne()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(j,{value:J,children:T()}),l.map(e=>(0,Z.jsx)(j,{value:e,children:e},e))]})]})]}),u.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}):(0,Z.jsxs)(Vt,{className:`oc-conn__table`,children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:qe(),sortKey:`target`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:ke(),sortKey:`state`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:ze(),sortKey:`instance`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:Ze(),sortKey:`host`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:Ke(),sortKey:`version`,sort:i,onSort:d}),(0,Z.jsx)(V,{children:$e()}),(0,Z.jsx)(Q,{label:Pe(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Z.jsx)(Bt,{children:u.map(e=>(0,Z.jsx)(hn,{r:e},e._id))})]})]})}function Q({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Z.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Z.jsx)(dt,{size:13,"aria-hidden":!0}):(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ft,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function hn({r:e}){let t=en(e)?W(e.lastErrorCode):null,n=tn(e)?W(e.lastDownstreamRejectCode):null;return(0,Z.jsxs)(G.Fragment,{children:[(0,Z.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(_n,{state:e.state})}),(0,Z.jsx)(U,{children:e.instanceLabel?(0,Z.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Z.jsx)(U,{children:e.gatewayVersion?(0,Z.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-conn__stats`,children:Ge({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Z.jsx)(U,{children:e.lastOkAt?(0,Z.jsx)(`span`,{className:`oc-traces__mono`,children:R(e.lastOkAt)}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Z.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Z.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Z.jsx)(`strong`,{children:t.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${R(e.lastErrorAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Je({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${R(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function gn(e){return e===`connected`?i():e===`error`?fe():w()}function _n({state:e}){return e===`connected`?(0,Z.jsx)(I,{variant:`secondary`,children:i()}):e===`error`?(0,Z.jsx)(I,{variant:`destructive`,children:fe()}):(0,Z.jsx)(I,{variant:`outline`,children:w()})}function vn(){return E(g.bridgeHealth.getBridgeHealth,{})}function yn(){let e=vn(),t=E(g.compat.getBridgeCompat,{}),n=E(g.me.getMe,{host:Lt})?.role===`admin`,r=E(g.admin.listInstances,n?{}:`skip`),i=E(g.agents.usageForInstances,n?{}:`skip`),a=jt(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=rn(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Nt({from:`/settings/bridge`}),l=jt({from:`/settings/bridge`}),u=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,p=u!==null&&Wt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(bn,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:de()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:le()}),(0,Z.jsxs)(Vt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:it()}),(0,Z.jsx)(V,{children:d()}),(0,Z.jsx)(V,{children:_e()}),(0,Z.jsx)(V,{children:st()}),(0,Z.jsx)(V,{children:Me()})]})}),(0,Z.jsx)(Bt,{children:i.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(I,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(bt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Z.jsx)(yt,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(_t,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(M,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(vt,{value:e.key,children:(0,Z.jsx)(xn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,p?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Be()}):null]})}function bn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Z.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:y(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,we({build:t.buildVersion??`?`})]}):null,` · `,be(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?b():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:ye()});let o=Zt(e.targets),s=!e.reachable,c=$t(e),l=e.unreachableInstances??[],d=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,f=Pt(e.checkedAt),p=e.startedAt==null?null:Pt(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Z.jsx)(A,{size:22}):s||c===`gateways_unreachable`?(0,Z.jsx)(Xt,{size:22}):(0,Z.jsx)(N,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?rt():c===`gateways_unreachable`?je({count:l.length}):s?u():ge({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Yt,{size:12,"aria-hidden":!0}),` `,ot({time:f})]}),p?(0,Z.jsx)(`span`,{children:tt({time:p})}):null,a]}),c===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ct({names:l.join(`, `)})}):null,s?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Oe()})]})}function xn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?qt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,m]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(M,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),f?(0,Z.jsx)(I,{variant:f===`beyond`?`destructive`:`secondary`,children:Kt(f)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ye()}),(0,Z.jsx)(Cn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Z.jsx)(Sn,{protocol:o}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[p?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),Le({count:t.length})]}),p?(0,Z.jsx)(mn,{connections:t,displayByInstance:c}):null]})}function Sn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ce(),i.length>0?(0,Z.jsx)(I,{variant:`destructive`,children:o({count:i.length})}):(0,Z.jsx)(I,{variant:`secondary`,children:Ve()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Ue({version:e.vendoredVersion}),r?` · `+ue({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),i.length>0?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),m({count:r.gapList.length})]}),t?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function Cn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:h({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:lt({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:b()}),e?(0,Z.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(e.version)}),(0,Z.jsx)(I,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(e.state)})]},e.instanceName))})]})}function wn({instance:e,onClose:t}){return(0,Z.jsx)(Mt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(It,{children:a({instance:e.displayName??e.name})}),(0,Z.jsx)(Ot,{children:He()})]}),(0,Z.jsx)(Tn,{instance:e,onClose:t})]})})}function $({label:e,result:t}){return t?t.checked?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Z.jsx)(A,{"aria-hidden":!0}):(0,Z.jsx)(N,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?me():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,se()]}):null}function Tn({instance:e,onClose:t}){let n=r(g.admin.upsertInstanceConfig),i=Ee(g.bridge.validateMediaPaths),a=St(),o=Rt(e.config?.contentLocale,void 0),[s,u]=(0,G.useState)(()=>pt(e.config??{},o)),[d,f]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,v]=(0,G.useState)(null),y=s.inboundMediaMode===`shared-fs`,b=s.mediaMode===`shared-fs`,x=y||b;async function S(){h(!0),v(null);try{v(await i({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){a.error(re(),e)}finally{h(!1)}}async function C(){f(!0);try{let r=e.config??{};await n({instanceId:e._id,config:ht(s,r,o)}),t()}catch(e){a.error(he(),e)}finally{f(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:p(),help:at()}),(0,Z.jsxs)(B,{value:s.mediaMode,onValueChange:e=>u({...s,mediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:gt.map(e=>(0,Z.jsx)(j,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ee(),help:Ae()}),(0,Z.jsxs)(B,{value:s.inboundMediaMode,onValueChange:e=>u({...s,inboundMediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:mt.map(e=>(0,Z.jsx)(j,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ve(),help:De()}),(0,Z.jsx)(L,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>u({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),x&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[y&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ae(),help:Xe()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>u({...s,inboundAgentMount:e.target.value})})]}),b&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:oe(),help:ne()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>u({...s,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(kt,{checked:s.rehydration,onCheckedChange:e=>u({...s,rehydration:e===!0})}),(0,Z.jsx)(O,{label:nt(),help:Ie()})]}),x&&_!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:_.reachable?!_.inbound&&!_.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),te({reason:_.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:c(),result:_.inbound}),(0,Z.jsx)($,{label:ut(),result:_.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),ie()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[x&&(0,Z.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void S(),disabled:m,children:[m?(0,Z.jsx)(Ct,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?xe():Te()]}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>void C(),disabled:d,children:l()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(xt,{children:[(0,Z.jsx)(Ft,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?pe():C({count:e.length}),(0,Z.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Et,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:x()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(I,{variant:`secondary`,children:e},e))})]})]})}export{yn as BridgeTab,wn as InstanceConfigDialog};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$h as i,A_ as a,Ag as o,Bc as s,Bg as c,C_ as l,Cg as u,Cn as d,D as f,D_ as p,Dg as m,Dn as h,E as g,E_ as ee,Eg as _,Fc as v,Fg as te,Gc as y,Gg as ne,Hc as b,Hg as re,Ic as x,Ig as ie,Jg as ae,Kc as S,Kg as oe,Lc as C,Lg as se,Mg as ce,Ng as le,Og as ue,Pg as de,Qh as fe,Rc as pe,Rg as me,S_ as he,Sg as ge,Sn as _e,T_ as ve,Tg as ye,Uc as be,Ug as xe,Vc as Se,Vg as Ce,Wc as we,Wg as Te,ZP as Ee,Zh as w,__ as De,_g as Oe,ag as ke,b_ as Ae,bg as je,bn as Me,cg as Ne,dg as T,eF as E,eg as Pe,fg as Fe,g_ as Ie,gg as Le,hg as Re,ig as ze,jc as Be,jg as Ve,k_ as He,kg as Ue,lg as We,mg as Ge,ng as Ke,og as qe,pg as Je,qc as Ye,qg as Xe,rg as Ze,sg as Qe,tg as $e,ug as et,vg as tt,w_ as nt,wg as rt,wn as it,x_ as at,xg as ot,xn as st,yg as ct,zc as lt,zg as ut}from"./dist-De2K23IB.js";import{i as D,r as dt}from"./dist-CXJY_tYD.js";import{t as ft}from"./chevrons-up-down-DIXCqs3W.js";import{i as pt,n as O,o as mt,r as ht,s as gt}from"./FieldLabel-hLNtge_D.js";import{i as _t,n as vt,r as yt,t as bt}from"./tabs-fDXC7itk.js";import{t as k}from"./button-Bd43O_sm.js";import{$ as xt,$t as A,C as j,H as St,Kt as Ct,Lt as M,Pt as N,S as P,T as F,_t as wt,dt as I,en as Tt,et as Et,ft as L,h as Dt,ht as Ot,it as R,m as kt,mt as At,nn as jt,pt as Mt,rn as Nt,rt as Pt,tt as Ft,vt as It,w as z,wt as Lt,x as B}from"./index-CNwjY680.js";import{r as Rt}from"./locales-CPjguROj.js";import{a as zt,i as V,n as Bt,o as H,r as U,t as Vt}from"./table-BRilRxUj.js";import{t as Ht}from"./FilterBar-CY1WfFDB.js";import{a as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt}from"./compatView-B2BXfBvC.js";import{t as W}from"./dispatchErrorInfo-DKMvYSfG.js";var Yt=f(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Xt=f(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function Zt(e){return e.filter(e=>e.state===`error`)}function Qt(e){return e.reachable&&Zt(e.targets).length===0}function $t(e){return Qt(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function en(e){return e.state===`error`&&e.lastErrorCode!==null}function tn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function nn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function rn(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return nn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,an={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function on(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function sn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function cn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function ln(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Gt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function un(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=cn(t.key,e),a=cn(t.key,r);return i&&a?0:i?1:a?-1:n*ln(t.key,e,r)})}function dn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function fn(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>X(e.label,t.label))}function pn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Gt(e,t)??X(e,t))}var Z=n();function mn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(an),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>dn(o),[o]),c=(0,G.useMemo)(()=>fn(o),[o]),l=(0,G.useMemo)(()=>pn(o),[o]),u=(0,G.useMemo)(()=>un(sn(o,n),i),[o,n,i]);function d(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Ht,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Fe(),onReset:()=>r(an),canReset:on(n),children:[(0,Z.jsxs)(B,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:et()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(j,{value:J,children:T()}),s.map(e=>(0,Z.jsx)(j,{value:e,children:gn(e)},e))]})]}),(0,Z.jsxs)(B,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(F,{placeholder:We()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(j,{value:J,children:T()}),c.map(e=>(0,Z.jsx)(j,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(B,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:Ne()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(j,{value:J,children:T()}),l.map(e=>(0,Z.jsx)(j,{value:e,children:e},e))]})]})]}),u.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}):(0,Z.jsxs)(Vt,{className:`oc-conn__table`,children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:qe(),sortKey:`target`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:ke(),sortKey:`state`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:ze(),sortKey:`instance`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:Ze(),sortKey:`host`,sort:i,onSort:d}),(0,Z.jsx)(Q,{label:Ke(),sortKey:`version`,sort:i,onSort:d}),(0,Z.jsx)(V,{children:$e()}),(0,Z.jsx)(Q,{label:Pe(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Z.jsx)(Bt,{children:u.map(e=>(0,Z.jsx)(hn,{r:e},e._id))})]})]})}function Q({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Z.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Z.jsx)(dt,{size:13,"aria-hidden":!0}):(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ft,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function hn({r:e}){let t=en(e)?W(e.lastErrorCode):null,n=tn(e)?W(e.lastDownstreamRejectCode):null;return(0,Z.jsxs)(G.Fragment,{children:[(0,Z.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(_n,{state:e.state})}),(0,Z.jsx)(U,{children:e.instanceLabel?(0,Z.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Z.jsx)(U,{children:e.gatewayVersion?(0,Z.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-conn__stats`,children:Ge({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Z.jsx)(U,{children:e.lastOkAt?(0,Z.jsx)(`span`,{className:`oc-traces__mono`,children:R(e.lastOkAt)}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Z.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Z.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Z.jsx)(`strong`,{children:t.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${R(e.lastErrorAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Je({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${R(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function gn(e){return e===`connected`?i():e===`error`?fe():w()}function _n({state:e}){return e===`connected`?(0,Z.jsx)(I,{variant:`secondary`,children:i()}):e===`error`?(0,Z.jsx)(I,{variant:`destructive`,children:fe()}):(0,Z.jsx)(I,{variant:`outline`,children:w()})}function vn(){return E(g.bridgeHealth.getBridgeHealth,{})}function yn(){let e=vn(),t=E(g.compat.getBridgeCompat,{}),n=E(g.me.getMe,{host:Lt})?.role===`admin`,r=E(g.admin.listInstances,n?{}:`skip`),i=E(g.agents.usageForInstances,n?{}:`skip`),a=jt(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=rn(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Nt({from:`/settings/bridge`}),l=jt({from:`/settings/bridge`}),u=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,p=u!==null&&Wt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(bn,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:de()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:le()}),(0,Z.jsxs)(Vt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:it()}),(0,Z.jsx)(V,{children:d()}),(0,Z.jsx)(V,{children:_e()}),(0,Z.jsx)(V,{children:st()}),(0,Z.jsx)(V,{children:Me()})]})}),(0,Z.jsx)(Bt,{children:i.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(I,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(bt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Z.jsx)(yt,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(_t,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(M,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(vt,{value:e.key,children:(0,Z.jsx)(xn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,p?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Be()}):null]})}function bn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Z.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:y(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,we({build:t.buildVersion??`?`})]}):null,` · `,be(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?b():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:ye()});let o=Zt(e.targets),s=!e.reachable,c=$t(e),l=e.unreachableInstances??[],d=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,f=Pt(e.checkedAt),p=e.startedAt==null?null:Pt(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Z.jsx)(A,{size:22}):s||c===`gateways_unreachable`?(0,Z.jsx)(Xt,{size:22}):(0,Z.jsx)(N,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?rt():c===`gateways_unreachable`?je({count:l.length}):s?u():ge({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Yt,{size:12,"aria-hidden":!0}),` `,ot({time:f})]}),p?(0,Z.jsx)(`span`,{children:tt({time:p})}):null,a]}),c===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ct({names:l.join(`, `)})}):null,s?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Oe()})]})}function xn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?qt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,m]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(M,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),f?(0,Z.jsx)(I,{variant:f===`beyond`?`destructive`:`secondary`,children:Kt(f)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ye()}),(0,Z.jsx)(Cn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Z.jsx)(Sn,{protocol:o}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[p?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),Le({count:t.length})]}),p?(0,Z.jsx)(mn,{connections:t,displayByInstance:c}):null]})}function Sn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ce(),i.length>0?(0,Z.jsx)(I,{variant:`destructive`,children:o({count:i.length})}):(0,Z.jsx)(I,{variant:`secondary`,children:Ve()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Ue({version:e.vendoredVersion}),r?` · `+ue({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),i.length>0?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),m({count:r.gapList.length})]}),t?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function Cn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:h({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:lt({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:b()}),e?(0,Z.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(e.version)}),(0,Z.jsx)(I,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(e.state)})]},e.instanceName))})]})}function wn({instance:e,onClose:t}){return(0,Z.jsx)(Mt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(It,{children:a({instance:e.displayName??e.name})}),(0,Z.jsx)(Ot,{children:He()})]}),(0,Z.jsx)(Tn,{instance:e,onClose:t})]})})}function $({label:e,result:t}){return t?t.checked?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Z.jsx)(A,{"aria-hidden":!0}):(0,Z.jsx)(N,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?me():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,se()]}):null}function Tn({instance:e,onClose:t}){let n=r(g.admin.upsertInstanceConfig),i=Ee(g.bridge.validateMediaPaths),a=St(),o=Rt(e.config?.contentLocale,void 0),[s,u]=(0,G.useState)(()=>pt(e.config??{},o)),[d,f]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[_,v]=(0,G.useState)(null),y=s.inboundMediaMode===`shared-fs`,b=s.mediaMode===`shared-fs`,x=y||b;async function S(){h(!0),v(null);try{v(await i({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){a.error(re(),e)}finally{h(!1)}}async function C(){f(!0);try{let r=e.config??{};await n({instanceId:e._id,config:ht(s,r,o)}),t()}catch(e){a.error(he(),e)}finally{f(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:p(),help:at()}),(0,Z.jsxs)(B,{value:s.mediaMode,onValueChange:e=>u({...s,mediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:gt.map(e=>(0,Z.jsx)(j,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ee(),help:Ae()}),(0,Z.jsxs)(B,{value:s.inboundMediaMode,onValueChange:e=>u({...s,inboundMediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:mt.map(e=>(0,Z.jsx)(j,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ve(),help:De()}),(0,Z.jsx)(L,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>u({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),x&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[y&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ae(),help:Xe()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>u({...s,inboundAgentMount:e.target.value})})]}),b&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:oe(),help:ne()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>u({...s,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(kt,{checked:s.rehydration,onCheckedChange:e=>u({...s,rehydration:e===!0})}),(0,Z.jsx)(O,{label:nt(),help:Ie()})]}),x&&_!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:_.reachable?!_.inbound&&!_.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),te({reason:_.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:c(),result:_.inbound}),(0,Z.jsx)($,{label:ut(),result:_.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),ie()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[x&&(0,Z.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void S(),disabled:m,children:[m?(0,Z.jsx)(Ct,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?xe():Te()]}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>void C(),disabled:d,children:l()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(xt,{children:[(0,Z.jsx)(Ft,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?pe():C({count:e.length}),(0,Z.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Et,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:x()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(I,{variant:`secondary`,children:e},e))})]})]})}export{yn as BridgeTab,wn as InstanceConfigDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$c as i,Ca as a,Da as o,E as s,Ea as c,En as l,GP as u,Jc as d,Ml as f,O_ as p,Oa as m,Qc as h,Sa as g,Ta as _,Xc as v,Yc as y,ZP as b,Zc as x,ba as S,eF as C,el as w,gu as T,lu as E,mu as D,nl as O,tl as k,uu as A,wa as j,xa as M,ya as N}from"./dist-De2K23IB.js";import{t as P}from"./button-Bd43O_sm.js";import{C as F,Pt as I,S as L,T as R,b as z,f as B,ft as V,m as H,p as U,w as W,x as G}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$c as i,Ca as a,Da as o,E as s,Ea as c,En as l,GP as u,Jc as d,Ml as f,O_ as p,Oa as m,Qc as h,Sa as g,Ta as _,Xc as v,Yc as y,ZP as b,Zc as x,ba as S,eF as C,el as w,gu as T,lu as E,mu as D,nl as O,tl as k,uu as A,wa as j,xa as M,ya as N}from"./dist-De2K23IB.js";import{t as P}from"./button-Bd43O_sm.js";import{C as F,Pt as I,S as L,T as R,b as z,f as B,ft as V,m as H,p as U,w as W,x as G}from"./index-CNwjY680.js";import{i as K}from"./compatView-B2BXfBvC.js";/* empty css */var q=t(e(),1),J=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Y(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var X=n();function Z({instance:e}){let t=r(s.admin.upsertInstanceConfig),n=C(s.agents.listAgentsForInstance,{instanceName:e.name}),i=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[o,c]=(0,q.useState)(i),[l,u]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{c(i),u(`idle`)},[e._id,i]);let f=`__none__`,p=o!==i;async function m(){u(`saving`);try{let n={...e.config??{}};o===``||o===f?delete n.converterAgentId:n.converterAgentId=o,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`error`)}}let h=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:_()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(G,{value:o===``?f:o,onValueChange:e=>c(e===f?``:e),children:[(0,X.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":_(),children:(0,X.jsx)(R,{placeholder:a()})}),(0,X.jsxs)(L,{children:[(0,X.jsx)(F,{value:f,children:a()}),h.map(e=>(0,X.jsx)(F,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!p||l===`saving`,onClick:()=>void m(),children:l===`saving`?T():v()})]}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:y()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:d()}):null]})}function Q({instance:e}){let t=r(s.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,i=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[a,o]=(0,q.useState)(n),[l,u]=(0,q.useState)(i===null?``:String(i)),[f,p]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{o(n),u(i===null?``:String(i)),p(`idle`)},[e._id,n,i]);let m=l.trim(),h=m===``?null:/^\d+$/.test(m)?Number.parseInt(m,10):NaN,_=!a||h===null||Number.isInteger(h)&&h>=4e3&&h<=6e4,b=a!==n||(h??null)!==i;async function x(){p(`saving`);try{let n={...e.config??{}};n.curationEnabled=a,!a||h===null||Number.isNaN(h)?delete n.curationBudgetChars:n.curationBudgetChars=h,await t({instanceId:e._id,config:n}),p(`done`)}catch{p(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(H,{checked:a,onCheckedChange:e=>o(e===!0),"aria-label":c()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:c()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:l,onChange:e=>u(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":g(),disabled:!a}),(0,X.jsx)(P,{size:`sm`,disabled:!b||!_||f===`saving`,onClick:()=>void x(),children:f===`saving`?T():v()})]}),_?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:M()}),f===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:y()}):null,f===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:d()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:S()})]})}function $({instance:e}){let t=r(s.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[i,a]=(0,q.useState)(n===null?``:String(n)),[c,l]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(n===null?``:String(n)),l(`idle`)},[e._id,n]);let u=i.trim(),f=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,p=f===null||Number.isInteger(f)&&f>=1e3&&f<=2e5,h=(f??null)!==n;async function g(){l(`saving`);try{let n={...e.config??{}};f===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=f,await t({instanceId:e._id,config:n}),l(`done`)}catch{l(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:m()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:i,onChange:e=>a(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!p}),(0,X.jsx)(P,{size:`sm`,disabled:!h||!p||c===`saving`,onClick:()=>void g(),children:c===`saving`?T():v()})]}),p?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:N()}),c===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:y()}):null,c===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:d()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:o()})]})}function ee(){let e=b(s.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),r=C(s.admin.listInstances,{}),[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!r||r.length===0||(!a||!r.some(e=>e.name===a))&&o(r[0].name)},[r,a]);let c=(r?.length??0)>1,d=r!==void 0&&r.length===0,m=C(s.compat.forInstance,a?{instanceName:a}:`skip`),g=a?z(m,`configDefaults`):`loading`,_=g===`loading`?null:g.blocked,v=(0,q.useMemo)(()=>c&&a?{instanceName:a}:{},[c,a]),y=(0,q.useRef)(0),S=(0,q.useCallback)(async()=>{let t=++y.current;n({status:`loading`});try{let r=Y(await e(v));if(y.current!==t)return;n({status:`done`,current:r})}catch{if(y.current!==t)return;n({status:`error`})}},[e,v]);(0,q.useEffect)(()=>{_===!1&&(c&&!a||S())},[S,_,c,a]);let T=t.status===`done`?t.current:null,j=(0,q.useMemo)(()=>J.map(e=>({id:e,label:U(e)})),[]),M=(0,q.useMemo)(()=>[{id:`fast`,label:A()},{id:`standard`,label:E()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:O()}),c&&a?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,X.jsxs)(G,{value:a,onValueChange:e=>o(e),children:[(0,X.jsx)(W,{size:`sm`,"aria-label":f(),children:(0,X.jsx)(R,{})}),(0,X.jsx)(L,{children:(r??[]).map(e=>(0,X.jsx)(F,{value:e.name,children:e.name},e.name))})]})]}):null,d?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:p()}):g===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):g.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(I,{size:14,"aria-hidden":!0}),` `,K(g.gatewayVersion,g.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[x(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:D()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()}),(0,X.jsx)(B,{options:j,value:T?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:w()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:i()}),(0,X.jsx)(B,{options:M,value:T===null||T.fastModeDefault===null?null:T.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:h()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:l()})]}),(()=>{let e=r?.find(e=>e.name===(a??r[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Cp as r,Sp as i,_p as a,bp as o,vp as s,xp as c,yp as l}from"./dist-De2K23IB.js";import{i as u,r as d}from"./dist-CXJY_tYD.js";import{t as f}from"./chevrons-up-down-DIXCqs3W.js";import{t as p}from"./button-Bd43O_sm.js";import{Bt as m,Ft as h,Yt as g,at as _,lt as v,m as y,ot as b,st as x,ut as S}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Cp as r,Sp as i,_p as a,bp as o,vp as s,xp as c,yp as l}from"./dist-De2K23IB.js";import{i as u,r as d}from"./dist-CXJY_tYD.js";import{t as f}from"./chevrons-up-down-DIXCqs3W.js";import{t as p}from"./button-Bd43O_sm.js";import{Bt as m,Ft as h,Yt as g,at as _,lt as v,m as y,ot as b,st as x,ut as S}from"./index-CNwjY680.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-BRilRxUj.js";var k=t(e(),1);function A(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function j(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=A(i,a);return n===`asc`?c:-c})}var M=n();function N({title:e,rows:t,columns:n,rowActions:A,onAdd:N,addLabel:P=r(),bulkActions:F,emptyHint:I=i(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(h,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:c()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(y,{"aria-label":o(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":a({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(d,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(f,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],r=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(y,{"aria-label":l(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(S,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":s(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(g,{})})}),(0,M.jsx)(b,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(x,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{dt as t}from"./index-
|
|
1
|
+
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{dt as t}from"./index-CNwjY680.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,$P as i,Aw as a,Bi as o,Bw as s,Cw as c,Dw as l,E as u,Ew as d,Fw as f,GC as p,Gw as m,Hw as h,Iw as ee,JC as g,KC as _,Kw as v,Lw as y,Mw as te,Nw as ne,Ow as re,Pw as ie,QC as b,Ri as x,Rw as S,Sw as C,Tw as w,Uw as T,Vw as E,WC as D,Ww as O,XC as k,YC as A,ZC as j,_w as M,aw as N,bw as P,cw as F,dw as I,eF as L,ew as R,fw as z,gw as B,hw as V,iw as H,jw as U,kw as W,lw as ae,mw as G,nw as K,ow as q,pw as J,qC as oe,rw as se,sw as ce,tw as le,uw as ue,vw as de,ww as fe,xw as pe,yw as me,zw as he}from"./dist-De2K23IB.js";import{t as ge}from"./button-Bd43O_sm.js";import{U as _e,rt as Y}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,$P as i,Aw as a,Bi as o,Bw as s,Cw as c,Dw as l,E as u,Ew as d,Fw as f,GC as p,Gw as m,Hw as h,Iw as ee,JC as g,KC as _,Kw as v,Lw as y,Mw as te,Nw as ne,Ow as re,Pw as ie,QC as b,Ri as x,Rw as S,Sw as C,Tw as w,Uw as T,Vw as E,WC as D,Ww as O,XC as k,YC as A,ZC as j,_w as M,aw as N,bw as P,cw as F,dw as I,eF as L,ew as R,fw as z,gw as B,hw as V,iw as H,jw as U,kw as W,lw as ae,mw as G,nw as K,ow as q,pw as J,qC as oe,rw as se,sw as ce,tw as le,uw as ue,vw as de,ww as fe,xw as pe,yw as me,zw as he}from"./dist-De2K23IB.js";import{t as ge}from"./button-Bd43O_sm.js";import{U as _e,rt as Y}from"./index-CNwjY680.js";import{t as ve}from"./DataTableShell-COEwE2Hv.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>v(),incorrect:()=>m(),incoherence:()=>O(),formatting:()=>T(),latency:()=>h(),api_error:()=>E(),other:()=>s()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:S()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:y()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:he()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,s=i(u.feedback.respondToFeedback),[p,m]=(0,X.useState)(e.thread),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(!1);async function y(){let t=h.trim();if(!(!t||_)){v(!0);try{await s({feedbackId:e._id,text:t}),m(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),g(``)}finally{v(!1)}}}let b=[];try{b=r.contextJson?JSON.parse(r.contextJson):[]}catch{b=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:r.displayedMatchesStored,sourceWasOpen:r.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,r.messageRole,r.isRegeneration?` · ${ee()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:ue(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:k()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ie()}),p.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:p.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Z.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?ne():e.authorRole===`agent`?e.authorLabel??o():te()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:U()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:a(),value:h,maxLength:2e3,rows:3,onChange:e=>g(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void y(),disabled:!h.trim()||_,children:_?W():re()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:l()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||d()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||d()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:fe()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,b.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:c({count:r.contextCount??b.length,truncated:r.contextTruncated?C():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:b.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,r.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:pe()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[r.outboxText??``,r.outboxStatus?`\n[status: ${r.outboxStatus}]`:``]})]}):null,r.clientInfo?.extensionsDetected&&r.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:P()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:r.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:me()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?de({theme:r.clientInfo.theme}):null,r.runId?`run ${r.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,r.clientInfo?.plugins&&r.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[M(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,B()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=L(u.feedback.listForAdmin,{}),t=i(u.feedback.readSnapshot),n=i(u.feedback.deleteFeedback),a=_e(),[o,s]=(0,X.useState)(null),[c,l]=(0,X.useState)({});async function d(e){if(o===e._id){s(null);return}if(!c[e._id]){let n=await t({feedbackId:e._id});l(t=>({...t,[e._id]:n}))}s(e._id)}async function f(e){await a({title:_(),description:p(),confirmLabel:D(),destructive:!0})&&(await n({feedbackId:e._id}),o===e._id&&s(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[V(),` `,(0,Z.jsx)(`strong`,{children:G()}),` `,J()]}),(0,Z.jsx)(ve,{title:z(),rows:e,emptyHint:I(),isExpanded:e=>o===e._id&&!!c[e._id],renderExpanded:e=>c[e._id]?(0,Z.jsx)(be,{data:c[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:ae(),cell:e=>Y(e.at),sort:e=>e.at},{header:F(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:ce(),cell:e=>e.messageRole===`user`?q():N(),sort:e=>e.messageRole},{header:H(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${se({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:K(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:le(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:R(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:r()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:b()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:x()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:j()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:o===e._id?A():g(),onSelect:()=>void d(e)},{label:oe(),onSelect:()=>void f(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,sF as n}from"./dist-De2K23IB.js";import{_ as r,g as i,v as a,y as o}from"./index-
|
|
1
|
+
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,sF as n}from"./dist-De2K23IB.js";import{_ as r,g as i,v as a,y as o}from"./index-CNwjY680.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var s=t(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),c={media_delivery:{key:`media_delivery`,appliedIn:`bridge`,togglable:!0,placeholders:[`outboundDir`],defaultTemplate:{fr:`[LIVRAISON]
|
|
2
2
|
Pour qu'un fichier que tu génères soit téléchargeable par l'utilisateur dans ce webchat : écris-le sous {outboundDir}/ puis ajoute, dans ta réponse finale, une ligne dédiée EXACTEMENT au format MEDIA:<chemin absolu du fichier>. N'utilise PAS de lien markdown vers un chemin local — il ne serait pas cliquable.`,en:`[DELIVERY]
|
|
3
3
|
To make a file you generate downloadable by the user in this webchat: write it under {outboundDir}/ then add, in your final reply, a dedicated line EXACTLY in the format MEDIA:<absolute file path>. Do NOT use a markdown link to a local path — it would not be clickable.`}},documentary_fetch:{key:`documentary_fetch`,appliedIn:`convex`,togglable:!0,placeholders:[`references`],defaultTemplate:{fr:`Fournis les fichiers source téléchargeables correspondant EXACTEMENT à ces références de documents (un fichier par référence, nommé d'après la référence). Réponds uniquement avec les fichiers, sans commentaire :
|
|
4
4
|
{references}`,en:`Provide the downloadable source files matching EXACTLY these document references (one file per reference, named after the reference). Reply only with the files, no commentary:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as ee,$P as te,BN as ne,E as r,GD as re,GN as i,GP as ie,HN as ae,JN as oe,KN as a,LN as o,QN as s,RN as c,UN as l,Ui as u,VN as se,WN as ce,Wi as d,XN as le,YN as ue,ZN as de,_P as fe,aP as f,cP as pe,dP as me,eF as he,eP as ge,fP as _e,gP as ve,hP as p,iP as m,lP as ye,mP as h,nP as g,oP as _,pP as be,qN as xe,qP as v,rP as y,sP as b,tP as x,uP as S,vP as C,zN as w}from"./dist-De2K23IB.js";import{t as T}from"./button-Bd43O_sm.js";import{C as E,Ft as D,G as O,H as k,J as A,K as j,Q as M,S as N,T as P,X as Se,Xt as F,Y as Ce,Yt as we,Z as Te,at as Ee,dt as I,m as De,ot as Oe,q as ke,st as L,ut as Ae,w as R,x as z,zt as je}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as ee,$P as te,BN as ne,E as r,GD as re,GN as i,GP as ie,HN as ae,JN as oe,KN as a,LN as o,QN as s,RN as c,UN as l,Ui as u,VN as se,WN as ce,Wi as d,XN as le,YN as ue,ZN as de,_P as fe,aP as f,cP as pe,dP as me,eF as he,eP as ge,fP as _e,gP as ve,hP as p,iP as m,lP as ye,mP as h,nP as g,oP as _,pP as be,qN as xe,qP as v,rP as y,sP as b,tP as x,uP as S,vP as C,zN as w}from"./dist-De2K23IB.js";import{t as T}from"./button-Bd43O_sm.js";import{C as E,Ft as D,G as O,H as k,J as A,K as j,Q as M,S as N,T as P,X as Se,Xt as F,Y as Ce,Yt as we,Z as Te,at as Ee,dt as I,m as De,ot as Oe,q as ke,st as L,ut as Ae,w as R,x as z,zt as je}from"./index-CNwjY680.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-BRilRxUj.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return b();case`audio`:return _();case`video`:return f();case`pdf`:return m();case`document`:return y();case`archive`:return g();default:return x()}}function q(){let[e,t]=(0,U.useState)(G),[n,f]=(0,U.useState)(G),[m,g]=(0,U.useState)(G),[_,y]=(0,U.useState)(G),[b,x]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=te(r.files.softDelete),Y=k();function Ie(){t(G),f(G),g(G),y(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(ce())}catch(e){Y.error(l(),e)}}let X=he(r.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:m===G?void 0:m,category:_===G?void 0:_,includeAutoGenerated:b||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(v(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ie()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||m!==G||_!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:C()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(z,{value:e,onValueChange:t,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":fe(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:ve()}),(0,W.jsx)(E,{value:`inbound`,children:p()}),(0,W.jsx)(E,{value:`outbound`,children:h()})]})]}),(0,W.jsxs)(z,{value:n,onValueChange:f,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":be(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:_e()}),Q.chats.map(e=>(0,W.jsx)(E,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(z,{value:m,onValueChange:g,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":me(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:S()}),Q.instances.map(e=>(0,W.jsx)(E,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(z,{value:_,onValueChange:y,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":ye(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:pe()}),Q.categories.map(e=>(0,W.jsx)(E,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(De,{checked:b,onCheckedChange:e=>x(e===!0),"aria-label":d()}),(0,W.jsx)(`span`,{children:d()})]}),$?(0,W.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(je,{size:14,"aria-hidden":!0}),xe()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?c():w()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:ge()}),(0,W.jsx)(B,{children:ee()}),(0,W.jsx)(B,{children:s()}),(0,W.jsx)(B,{children:de()}),(0,W.jsx)(B,{children:le()}),(0,W.jsx)(B,{className:`text-right`,children:ue()})]})}),(0,W.jsx)(Ne,{children:Z.map(e=>(0,W.jsxs)(V,{children:[(0,W.jsxs)(H,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,W.jsx)(I,{variant:`outline`,style:{marginLeft:6},children:u()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(I,{variant:`secondary`,children:e.direction===`inbound`?p():h()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(Ee,{children:[(0,W.jsx)(Ae,{asChild:!0,children:(0,W.jsx)(T,{variant:`ghost`,size:`icon`,"aria-label":a(),children:(0,W.jsx)(we,{size:16})})}),(0,W.jsxs)(Oe,{align:`end`,children:[e.url?(0,W.jsx)(L,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(F,{size:14}),oe()]})}):(0,W.jsxs)(L,{disabled:!0,children:[(0,W.jsx)(F,{size:14}),ne()]}),(0,W.jsxs)(L,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(D,{size:14}),i()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:o({cap:Be})}):null]}),(0,W.jsx)(O,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(A,{children:[(0,W.jsxs)(Te,{children:[(0,W.jsx)(M,{children:ae()}),(0,W.jsx)(Ce,{children:se()})]}),(0,W.jsxs)(Se,{children:[(0,W.jsx)(ke,{children:re()}),(0,W.jsx)(j,{onClick:()=>void Le(),children:i()})]})]})})]})}export{q as FilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Tp as r,wp as i}from"./dist-De2K23IB.js";import{t as a}from"./button-Bd43O_sm.js";import{Rt as o,ft as s,zt as c}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Tp as r,wp as i}from"./dist-De2K23IB.js";import{t as a}from"./button-Bd43O_sm.js";import{Rt as o,ft as s,zt as c}from"./index-CNwjY680.js";import{t as l}from"./TimeRangePicker-BYCcnF0a.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=r(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(o,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(c,{}),i()]})]})}export{p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$u as i,Ad as a,Au as o,Bu as s,Cd as c,D as l,Dd as u,E as d,Ed as f,Fd as p,Fu as m,Gu as h,Hu as g,Id as _,Iu as v,Ju as y,Ku as b,Ld as x,Lu as S,Md as C,Mu as w,Nd as T,Nu as E,Od as ee,Ou as D,Pd as O,Pu as k,Qu as A,Ru as j,Sd as M,Td as N,Uu as P,Vu as F,Wu as te,Xu as ne,Yu as I,Zu as re,_d as ie,ad as L,bd as ae,cd as R,dd as oe,eF as z,ed as se,fd as ce,gd as le,hd as ue,id as de,jd as fe,ju as pe,kd as me,ku as he,ld as ge,md as _e,nd as ve,od as ye,pd as be,qu as xe,rd as Se,sd as Ce,td as we,ud as Te,vd as Ee,wd as De,xd as Oe,yd as ke,zu as Ae}from"./dist-De2K23IB.js";import{t as je}from"./x-DXaZHGzl.js";import{i as B,n as V,r as Me,t as Ne}from"./tabs-Kb2_G-yp.js";import{t as H}from"./button-Bd43O_sm.js";import{C as Pe,H as U,It as W,Lt as G,S as Fe,T as Ie,U as Le,_t as Re,d as ze,dt as K,en as Be,ft as q,ht as Ve,m as J,mt as He,pt as Ue,tn as We,vt as Ge,w as Ke,wt as qe,x as Je}from"./index-CW5WE31O.js";import{t as Ye}from"./FilterBar-Byr6OGo7.js";import{t as Xe}from"./DataTableShell-DAEVsm3y.js";import{t as Y}from"./DetailChips-DerZpgh4.js";var Ze=l(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),X=l(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Qe=l(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Z=t(e(),1);function $e(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function et(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function tt(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function nt(e){switch(e){case`admin`:return de();case`user`:return Se();case`pending`:return ve();default:return e}}function rt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function it(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var Q=n(),$={name:``,description:``};function at(){let e=z(d.groups.listGroups,{}),t=z(d.me.getMe,{host:qe})?.role===`admin`,n=r(d.groups.createGroup),i=r(d.groups.updateGroup),s=r(d.groups.deleteGroup),l=Le(),m=U(),[h,g]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,S]=(0,Z.useState)($),[w,E]=(0,Z.useState)(null),[D,k]=(0,Z.useState)(``),A=(0,Z.useMemo)(()=>{if(!e)return e;let t=D.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,D]);function j(){y(null),S($),g(!0)}function P(e){y(e),S({name:e.name,description:e.description??``}),g(!0)}async function F(){try{v?await i({groupId:v._id,name:b.name,description:b.description}):await n({name:b.name,description:b.description||void 0}),S($),y(null),g(!1)}catch(e){m.error(pe(),e)}}async function te(e){if(await l({title:Ee({name:e.name}),description:ie(),confirmWord:e.name,confirmLabel:le(),cancelLabel:De(),destructive:!0}))try{await s({groupId:e._id})}catch(e){m.error(o(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()}),(0,Q.jsx)(Ye,{q:D,onQChange:k,onReset:()=>k(``),canReset:D!==``,searchPlaceholder:me()}),(0,Q.jsx)(Xe,{title:x(),rows:A,addLabel:p(),onAdd:t?j:void 0,emptyHint:O(),columns:[{header:T(),cell:e=>e.name,sort:e=>e.name},{header:C(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Qe,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(X,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:fe(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(G,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:a(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:ee(),onSelect:()=>E({groupId:e._id,name:e.name})},...t?[{label:u(),onSelect:()=>P(e)},{label:f(),variant:`destructive`,onSelect:()=>void te(e)}]:[]]}),(0,Q.jsx)(ze,{open:h,onOpenChange:g,title:v?M():c(),description:Oe(),canSubmit:!!b.name.trim(),onSubmit:F,submitLabel:N(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:ae()}),(0,Q.jsx)(q,{value:b.name,onChange:e=>S({...b,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:ke()}),(0,Q.jsx)(q,{value:b.description,onChange:e=>S({...b,description:e.target.value})})]})]})}),(0,Q.jsx)(ct,{groupId:w?.groupId??null,groupName:w?.name??``,open:w!==null,onOpenChange:e=>{e||E(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(We,{size:14,"aria-hidden":!0}),Ce()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":L({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[ye(),(0,Q.jsx)(Be,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:a}){let o=z(d.groups.getGroup,n&&e?{groupId:e}:`skip`),s=z(d.groups.listAssignableInstances,n?{}:`skip`),c=z(d.groups.listAssignableUsers,n?{}:`skip`),l=r(d.groups.addMember),u=r(d.groups.removeMember),f=r(d.groups.bulkSetMembers),p=r(d.groups.setGroupManager),h=U(),[g,_]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(`members`),[C,w]=(0,Z.useState)(1),[T,ee]=(0,Z.useState)(new Set),D=(0,Z.useRef)(null),O=(0,Z.useMemo)(()=>new Set((o?.members??[]).map(e=>e.userId)),[o]),A=(0,Z.useMemo)(()=>new Set((o?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[o]),j=o?.viewerIsAdmin===!0,M=(0,Z.useMemo)(()=>new Set((o?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[o]);(0,Z.useEffect)(()=>{_(``),b(``),S(`members`),w(1),D.current=null},[n,e]),(0,Z.useEffect)(()=>{w(1)},[g]),(0,Z.useEffect)(()=>{n&&o&&e&&D.current!==e&&(D.current=e,ee(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let N=(0,Z.useMemo)(()=>c?$e(c,g,T):[],[c,g,T]);async function P(t,n){if(e)try{n?await u({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){h.error(he(),e)}}async function F(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){h.error(E(),e)}}let I=rt(N,e=>O.has(e.userId)),ie=N.filter(e=>O.has(e.userId)).length,L=it(N,C,ot);async function ae(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await f({groupId:e,userIds:t,member:I!==`all`})}catch(e){h.error(he(),e)}}return(0,Q.jsx)(Ue,{open:n,onOpenChange:a,children:(0,Q.jsxs)(He,{className:`oc-access`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Ge,{children:ue({name:t})}),(0,Q.jsx)(Ve,{children:_e()})]}),(0,Q.jsxs)(Ne,{value:x,onValueChange:S,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Me,{className:`w-full`,children:[(0,Q.jsxs)(B,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Qe,{size:13,"aria-hidden":!0}),be(),o?(0,Q.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:O.size}):null]}),(0,Q.jsxs)(B,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(G,{size:13,"aria-hidden":!0}),oe(),o?(0,Q.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,Q.jsxs)(B,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ze,{size:13,"aria-hidden":!0}),te(),o?(0,Q.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:o.chartCount}):null]})]}),(0,Q.jsx)(V,{value:`members`,children:c===void 0||o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:i()}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{value:g,onChange:e=>_(e.target.value),placeholder:ce(),className:`oc-access__search`}),N.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ge()}):(0,Q.jsxs)(Q.Fragment,{children:[N.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(J,{checked:I===`all`?!0:I===`some`?`indeterminate`:!1,onCheckedChange:()=>void ae(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,Q.jsxs)(K,{variant:`outline`,className:`oc-access__count`,children:[ie,` / `,N.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:L.pageItems.map(e=>{let t=O.has(e.userId),n=tt(e),r=A.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(J,{checked:t,onCheckedChange:()=>void P(e.userId,t),"aria-label":we({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__role`,children:nt(e.role)}),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&j?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?k():m(),title:r?k():m(),onClick:()=>void F(e.userId,r),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):t&&r?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":v(),title:v(),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)(st,{page:L.page,pageCount:L.pageCount,onPage:w})]})]})}),(0,Q.jsx)(V,{value:`agents`,children:s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:i()}):s.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{value:y,onChange:e=>b(e.target.value),placeholder:Te(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,Q.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,query:y},`${e}-${t._id}`))})]})}),(0,Q.jsx)(V,{value:`charts`,children:(0,Q.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:i,query:a}){let o=z(d.groups.listAssignableAgents,{instanceName:t}),s=r(d.groups.assignAgentToGroup),c=r(d.groups.removeAgentFromGroup),l=r(d.groups.bulkSetGroupAgents),u=U(),[f,p]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{p(1)},[a]),!e)return null;let m=et(o?.agents??[],a),g=o?.discovery&&!o.discovery.lastPollOk;if(a.trim()&&m.length===0)return null;let _=m.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),v=rt(_,e=>i.has(`${t}/${e.agentId}`)),x=it(m,f,ot);async function S(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await s({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(D(),e)}}async function C(){if(_.length===0)return;let n=_.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:v!==`all`})}catch(e){u.error(D(),e)}}return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(G,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n}),g?(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__stale`,children:xe()}):null]}),o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:A()}):m.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:g?y():I()}):(0,Q.jsxs)(Q.Fragment,{children:[_.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(J,{checked:v===`all`?!0:v===`some`?`indeterminate`:!1,onCheckedChange:()=>void C(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,x.pageItems.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,Q.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,Q.jsx)(J,{checked:r,disabled:(a||o)&&!r,onCheckedChange:()=>void S(e.agentId,r),"aria-label":se({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":h(),title:h(),children:(0,Q.jsx)(W,{size:14,fill:`currentColor`})}):null,a?(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:b()}):null]},e.agentId)}),(0,Q.jsx)(st,{page:x.page,pageCount:x.pageCount,onPage:p})]})]})}function ut({groupId:e}){let t=z(d.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=r(d.charts.assignChartToGroup),a=r(d.charts.removeChartFromGroup),o=r(d.charts.setGroupDefaultChart),c=r(d.charts.addChartToGroupPool),l=r(d.charts.removeChartFromGroupPool),u=U();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:i()});let{pool:f,addable:p,canManagePool:m}=t;if(f.length===0&&!m)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:P()});async function h(t,r){try{r?await a({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}async function _(t){try{await o({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}async function v(t){try{await c({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}async function y(t){try{await l({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:f.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(J,{checked:e.selected,onCheckedChange:()=>void h(e.chartKey,e.selected),"aria-label":Ae({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":j(),title:j(),children:(0,Q.jsx)(W,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void _(e.chartKey),children:S()}):null,m?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":s({name:e.name}),title:s({name:e.name}),onClick:()=>void y(e.chartKey),children:(0,Q.jsx)(je,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),m?p.length>0?(0,Q.jsxs)(Je,{value:``,onValueChange:e=>void v(e),children:[(0,Q.jsx)(Ke,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(Ie,{placeholder:F()})}),(0,Q.jsx)(Fe,{children:p.map(e=>(0,Q.jsx)(Pe,{value:e.chartKey,children:e.name},e.chartKey))})]}):f.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:g()}):null:null]})}export{at as GroupsTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$u as i,Ad as a,Au as o,Bu as s,Cd as c,D as l,Dd as u,E as d,Ed as f,Fd as p,Fu as m,Gu as h,Hu as g,Id as _,Iu as v,Ju as y,Ku as b,Ld as x,Lu as S,Md as C,Mu as w,Nd as T,Nu as E,Od as ee,Ou as D,Pd as O,Pu as k,Qu as A,Ru as j,Sd as M,Td as N,Uu as P,Vu as F,Wu as te,Xu as ne,Yu as I,Zu as re,_d as ie,ad as L,bd as ae,cd as R,dd as oe,eF as z,ed as se,fd as ce,gd as le,hd as ue,id as de,jd as fe,ju as pe,kd as me,ku as he,ld as ge,md as _e,nd as ve,od as ye,pd as be,qu as xe,rd as Se,sd as Ce,td as we,ud as Te,vd as Ee,wd as De,xd as Oe,yd as ke,zu as Ae}from"./dist-De2K23IB.js";import{t as je}from"./x-DXaZHGzl.js";import{i as B,n as V,r as Me,t as Ne}from"./tabs-fDXC7itk.js";import{t as H}from"./button-Bd43O_sm.js";import{C as Pe,H as U,It as W,Lt as G,S as Fe,T as Ie,U as Le,_t as Re,d as ze,dt as K,en as Be,ft as q,ht as Ve,m as J,mt as He,pt as Ue,tn as We,vt as Ge,w as Ke,wt as qe,x as Je}from"./index-CNwjY680.js";import{t as Ye}from"./FilterBar-CY1WfFDB.js";import{t as Xe}from"./DataTableShell-COEwE2Hv.js";import{t as Y}from"./DetailChips-8ZpH5ZXE.js";var Ze=l(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),X=l(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Qe=l(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Z=t(e(),1);function $e(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function et(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function tt(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function nt(e){switch(e){case`admin`:return de();case`user`:return Se();case`pending`:return ve();default:return e}}function rt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function it(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var Q=n(),$={name:``,description:``};function at(){let e=z(d.groups.listGroups,{}),t=z(d.me.getMe,{host:qe})?.role===`admin`,n=r(d.groups.createGroup),i=r(d.groups.updateGroup),s=r(d.groups.deleteGroup),l=Le(),m=U(),[h,g]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(null),[b,S]=(0,Z.useState)($),[w,E]=(0,Z.useState)(null),[D,k]=(0,Z.useState)(``),A=(0,Z.useMemo)(()=>{if(!e)return e;let t=D.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,D]);function j(){y(null),S($),g(!0)}function P(e){y(e),S({name:e.name,description:e.description??``}),g(!0)}async function F(){try{v?await i({groupId:v._id,name:b.name,description:b.description}):await n({name:b.name,description:b.description||void 0}),S($),y(null),g(!1)}catch(e){m.error(pe(),e)}}async function te(e){if(await l({title:Ee({name:e.name}),description:ie(),confirmWord:e.name,confirmLabel:le(),cancelLabel:De(),destructive:!0}))try{await s({groupId:e._id})}catch(e){m.error(o(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()}),(0,Q.jsx)(Ye,{q:D,onQChange:k,onReset:()=>k(``),canReset:D!==``,searchPlaceholder:me()}),(0,Q.jsx)(Xe,{title:x(),rows:A,addLabel:p(),onAdd:t?j:void 0,emptyHint:O(),columns:[{header:T(),cell:e=>e.name,sort:e=>e.name},{header:C(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Qe,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(X,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:fe(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(G,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:a(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:ee(),onSelect:()=>E({groupId:e._id,name:e.name})},...t?[{label:u(),onSelect:()=>P(e)},{label:f(),variant:`destructive`,onSelect:()=>void te(e)}]:[]]}),(0,Q.jsx)(ze,{open:h,onOpenChange:g,title:v?M():c(),description:Oe(),canSubmit:!!b.name.trim(),onSubmit:F,submitLabel:N(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:ae()}),(0,Q.jsx)(q,{value:b.name,onChange:e=>S({...b,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:ke()}),(0,Q.jsx)(q,{value:b.description,onChange:e=>S({...b,description:e.target.value})})]})]})}),(0,Q.jsx)(ct,{groupId:w?.groupId??null,groupName:w?.name??``,open:w!==null,onOpenChange:e=>{e||E(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(We,{size:14,"aria-hidden":!0}),Ce()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":L({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[ye(),(0,Q.jsx)(Be,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:a}){let o=z(d.groups.getGroup,n&&e?{groupId:e}:`skip`),s=z(d.groups.listAssignableInstances,n?{}:`skip`),c=z(d.groups.listAssignableUsers,n?{}:`skip`),l=r(d.groups.addMember),u=r(d.groups.removeMember),f=r(d.groups.bulkSetMembers),p=r(d.groups.setGroupManager),h=U(),[g,_]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(`members`),[C,w]=(0,Z.useState)(1),[T,ee]=(0,Z.useState)(new Set),D=(0,Z.useRef)(null),O=(0,Z.useMemo)(()=>new Set((o?.members??[]).map(e=>e.userId)),[o]),A=(0,Z.useMemo)(()=>new Set((o?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[o]),j=o?.viewerIsAdmin===!0,M=(0,Z.useMemo)(()=>new Set((o?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[o]);(0,Z.useEffect)(()=>{_(``),b(``),S(`members`),w(1),D.current=null},[n,e]),(0,Z.useEffect)(()=>{w(1)},[g]),(0,Z.useEffect)(()=>{n&&o&&e&&D.current!==e&&(D.current=e,ee(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let N=(0,Z.useMemo)(()=>c?$e(c,g,T):[],[c,g,T]);async function P(t,n){if(e)try{n?await u({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){h.error(he(),e)}}async function F(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){h.error(E(),e)}}let I=rt(N,e=>O.has(e.userId)),ie=N.filter(e=>O.has(e.userId)).length,L=it(N,C,ot);async function ae(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await f({groupId:e,userIds:t,member:I!==`all`})}catch(e){h.error(he(),e)}}return(0,Q.jsx)(Ue,{open:n,onOpenChange:a,children:(0,Q.jsxs)(He,{className:`oc-access`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Ge,{children:ue({name:t})}),(0,Q.jsx)(Ve,{children:_e()})]}),(0,Q.jsxs)(Ne,{value:x,onValueChange:S,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Me,{className:`w-full`,children:[(0,Q.jsxs)(B,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Qe,{size:13,"aria-hidden":!0}),be(),o?(0,Q.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:O.size}):null]}),(0,Q.jsxs)(B,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(G,{size:13,"aria-hidden":!0}),oe(),o?(0,Q.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,Q.jsxs)(B,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ze,{size:13,"aria-hidden":!0}),te(),o?(0,Q.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:o.chartCount}):null]})]}),(0,Q.jsx)(V,{value:`members`,children:c===void 0||o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:i()}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{value:g,onChange:e=>_(e.target.value),placeholder:ce(),className:`oc-access__search`}),N.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ge()}):(0,Q.jsxs)(Q.Fragment,{children:[N.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(J,{checked:I===`all`?!0:I===`some`?`indeterminate`:!1,onCheckedChange:()=>void ae(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,Q.jsxs)(K,{variant:`outline`,className:`oc-access__count`,children:[ie,` / `,N.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:L.pageItems.map(e=>{let t=O.has(e.userId),n=tt(e),r=A.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(J,{checked:t,onCheckedChange:()=>void P(e.userId,t),"aria-label":we({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__role`,children:nt(e.role)}),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&j?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?k():m(),title:r?k():m(),onClick:()=>void F(e.userId,r),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):t&&r?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":v(),title:v(),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)(st,{page:L.page,pageCount:L.pageCount,onPage:w})]})]})}),(0,Q.jsx)(V,{value:`agents`,children:s===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:i()}):s.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{value:y,onChange:e=>b(e.target.value),placeholder:Te(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,Q.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:M,query:y},`${e}-${t._id}`))})]})}),(0,Q.jsx)(V,{value:`charts`,children:(0,Q.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:i,query:a}){let o=z(d.groups.listAssignableAgents,{instanceName:t}),s=r(d.groups.assignAgentToGroup),c=r(d.groups.removeAgentFromGroup),l=r(d.groups.bulkSetGroupAgents),u=U(),[f,p]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{p(1)},[a]),!e)return null;let m=et(o?.agents??[],a),g=o?.discovery&&!o.discovery.lastPollOk;if(a.trim()&&m.length===0)return null;let _=m.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),v=rt(_,e=>i.has(`${t}/${e.agentId}`)),x=it(m,f,ot);async function S(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await s({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(D(),e)}}async function C(){if(_.length===0)return;let n=_.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:v!==`all`})}catch(e){u.error(D(),e)}}return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(G,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n}),g?(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__stale`,children:xe()}):null]}),o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:A()}):m.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:g?y():I()}):(0,Q.jsxs)(Q.Fragment,{children:[_.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(J,{checked:v===`all`?!0:v===`some`?`indeterminate`:!1,onCheckedChange:()=>void C(),"aria-label":R()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,x.pageItems.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,Q.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,Q.jsx)(J,{checked:r,disabled:(a||o)&&!r,onCheckedChange:()=>void S(e.agentId,r),"aria-label":se({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":h(),title:h(),children:(0,Q.jsx)(W,{size:14,fill:`currentColor`})}):null,a?(0,Q.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:b()}):null]},e.agentId)}),(0,Q.jsx)(st,{page:x.page,pageCount:x.pageCount,onPage:p})]})]})}function ut({groupId:e}){let t=z(d.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=r(d.charts.assignChartToGroup),a=r(d.charts.removeChartFromGroup),o=r(d.charts.setGroupDefaultChart),c=r(d.charts.addChartToGroupPool),l=r(d.charts.removeChartFromGroupPool),u=U();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:i()});let{pool:f,addable:p,canManagePool:m}=t;if(f.length===0&&!m)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:P()});async function h(t,r){try{r?await a({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}async function _(t){try{await o({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}async function v(t){try{await c({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}async function y(t){try{await l({groupId:e,chartKey:t})}catch(e){u.error(w(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:f.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(J,{checked:e.selected,onCheckedChange:()=>void h(e.chartKey,e.selected),"aria-label":Ae({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":j(),title:j(),children:(0,Q.jsx)(W,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void _(e.chartKey),children:S()}):null,m?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":s({name:e.name}),title:s({name:e.name}),onClick:()=>void y(e.chartKey),children:(0,Q.jsx)(je,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),m?p.length>0?(0,Q.jsxs)(Je,{value:``,onValueChange:e=>void v(e),children:[(0,Q.jsx)(Ke,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(Ie,{placeholder:F()})}),(0,Q.jsx)(Fe,{children:p.map(e=>(0,Q.jsx)(Pe,{value:e.chartKey,children:e.name},e.chartKey))})]}):f.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:g()}):null:null]})}export{at as GroupsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$S as i,$x as a,AS as o,An as s,Ax as c,BS as l,Bx as u,CS as d,DS as f,Dx as p,E as m,ES as h,FS as g,Fx as _,GS as v,Ga as y,Gx as b,HS as x,Hx as S,IS as C,Ix as w,JS as T,Jx as ee,KS as te,Ka as E,Kx as D,LO as O,LS as k,Lx as ne,MS as A,Mx as re,NS as j,Nx as ie,OS as ae,Ox as oe,PS as se,Px as ce,QS as le,Qx as ue,RO as de,RS as fe,Rx as pe,SS as me,TS as he,US as ge,Ua as _e,Ux as ve,VS as ye,Vx as be,WS as xe,Wa as Se,Wx as Ce,XS as we,YS as Te,Yx as Ee,ZP as M,ZS as De,Zx as N,_S as Oe,aC as ke,aS as Ae,bS as je,cC as Me,cS as Ne,dC as Pe,dS as Fe,eC as Ie,eF as P,eS as F,fC as Le,fS as Re,gC as ze,gS as Be,hC as Ve,hS as He,iC as Ue,iS as We,jS as Ge,jn as Ke,jx as qe,kS as Je,kn as Ye,kx as Xe,lC as Ze,lS as Qe,mC as $e,mS as et,nC as I,nS as L,oC as tt,oS as nt,pC as rt,pS as it,qS as at,qx as ot,rC as st,rS as ct,sC as lt,sS as ut,tC as dt,tS as ft,uC as pt,uS as mt,vS as ht,v_ as gt,wS as _t,xS as vt,yS as yt,y_ as bt,zS as xt,zx as St}from"./dist-De2K23IB.js";import{a as Ct,c as wt}from"./FieldLabel-BJRoUSf1.js";import{t as R}from"./button-Bd43O_sm.js";import{$ as Tt,C as z,H as B,S as V,T as H,U as Et,_t as U,d as Dt,dt as W,et as Ot,ft as G,ht as K,m as kt,mt as At,pt as jt,tt as Mt,vt as Nt,w as q,x as J}from"./index-CW5WE31O.js";import{t as Pt}from"./DataTableShell-DAEVsm3y.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-C_I81PZ8.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Ct},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=P(m.admin.listInstances,{}),t=P(m.agents.listAllInstanceAgents,{}),n=r(m.admin.upsertInstance),a=r(m.admin.deleteInstance),o=B(),[c,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(Q),[p,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null);async function w(){try{await n({instanceId:S??void 0,name:d.name,gatewayUrl:d.gatewayUrl,bridgeUrl:d.bridgeUrl||void 0,displayName:d.displayName||void 0,kind:d.kind,transport:d.kind===`hermes`?d.transport:void 0,gatewayVersion:d.gatewayVersion||void 0,gatewayHttpUrl:d.gatewayHttpUrl||void 0,streamTransport:d.streamTransport}),f(Q),C(null),u(!1)}catch(e){o.error($e(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[rt(),(0,Z.jsx)(`strong`,{children:Le()}),Pe()]}),(0,Z.jsx)(Pt,{title:pt(),rows:e,addLabel:Ze(),onAdd:()=>{C(null),f(Q),u(!0)},emptyHint:Me(),columns:[{header:lt(),cell:e=>e.name,sort:e=>e.name},{header:tt(),cell:e=>(0,Z.jsx)(W,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:ke(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Ue(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:ze(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(W,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?oe():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Ie(),onSelect:()=>{C(e._id),f(Bt(e)),u(!0)}},{label:Ve(),onSelect:()=>h(e.name)},{label:xt(),onSelect:()=>b(e)},{label:st(),onSelect:()=>_(e)},{label:I(),variant:`destructive`,onSelect:()=>void a({instanceId:e._id})}],bulkActions:[{label:I(),variant:`destructive`,onSelect:e=>e.forEach(e=>void a({instanceId:e}))}]}),(0,Z.jsx)(Dt,{open:c,onOpenChange:u,title:S?i():dt(),description:De(),canSubmit:!!(d.name&&d.gatewayUrl),onSubmit:w,submitLabel:we(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Te(),children:[(0,Z.jsx)(G,{value:d.name,disabled:S!==null,onChange:e=>f({...d,name:e.target.value})}),S?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:le()}):null]}),(0,Z.jsx)($,{label:T(),children:(0,Z.jsxs)(J,{value:d.kind,onValueChange:e=>f({...d,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(z,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(z,{value:`hermes`,children:`Hermes`})]})]})}),d.kind===`hermes`?(0,Z.jsx)($,{label:Ke(),children:(0,Z.jsxs)(J,{value:d.transport,onValueChange:e=>f({...d,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(z,{value:`ws`,children:s()}),(0,Z.jsx)(z,{value:`rest`,children:Ye()})]})]})}):null,(0,Z.jsx)($,{label:at(),children:(0,Z.jsx)(G,{value:d.gatewayUrl,onChange:e=>f({...d,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:te(),children:(0,Z.jsx)(G,{value:d.bridgeUrl,placeholder:v(),onChange:e=>f({...d,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:xe(),children:(0,Z.jsx)(G,{value:d.displayName,onChange:e=>f({...d,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:bt(),children:[(0,Z.jsxs)(J,{value:d.streamTransport,onValueChange:e=>f({...d,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(V,{children:wt.map(e=>(0,Z.jsx)(z,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:gt()})]}),(0,Z.jsx)($,{label:ge(),children:(0,Z.jsx)(G,{value:d.gatewayVersion,placeholder:x(),onChange:e=>f({...d,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:ye(),children:(0,Z.jsx)(G,{value:d.gatewayHttpUrl,placeholder:l(),onChange:e=>f({...d,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:p,open:p!==null,onOpenChange:e=>{e||h(null)}}),g?(0,Z.jsx)(Ft,{instance:g,onClose:()=>_(null)},g._id):null,y?(0,Z.jsx)(Ht,{instance:y,onClose:()=>b(null)},y._id):null]})}function Ht({instance:e,onClose:t}){let n=P(m.instanceSecrets.listInstanceSecretStatus,{}),r=zt[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(jt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(Nt,{children:fe({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:k()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=M(m.instanceSync.forceInstanceSync),n=B(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Oe());break;case`no_agents`:n.success(He());break;case`no_bridge_url`:n.error(et());break;case`deploy_misconfigured`:n.error(it());break;case`unauthorized`:n.error(Fe());break;case`not_served`:n.error(mt());break;default:n.error(Re());break}}catch(e){n.error(Be(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?ht():yt()})})]})}function Wt({instance:e}){let t=P(m.bridgeAuth.listBridgeAuthStatus,{}),n=M(m.bridgeAuth.mintBridgeSecret),i=r(m.bridgeAuth.revokeBridgeSecret),a=B(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function h(){if(!o){s(!0);try{l((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){a.error(L(),e)}finally{s(!1)}}}async function g(){if(!o){s(!0);try{await i({instanceId:e._id}),l(null),a.success(ct())}catch(e){a.error(L(),e)}finally{s(!1)}}}async function _(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,Z.jsxs)($,{label:Ne(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ut()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(W,{variant:p?`outline`:`secondary`,children:p?`${j()} · ${f.prefix}…${f.lastFour}`:A()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void h(),disabled:o,children:p?Ae():nt()}),p?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void g(),disabled:o,children:We()}):null]})]}),c?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:ft()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:u?de():O()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:F()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let i=M(m.instanceSecrets.setInstanceSecret),a=r(m.instanceSecrets.clearInstanceSecret),s=M(m.deviceIdentity.generateDeviceIdentity),c=B(),[l,u]=(0,Y.useState)(``),[p,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),S=n!==null,w=t===`deviceIdentity`,T=t===`token`?C():t===`deviceIdentity`?g():se();async function ee(){if(!(!l.trim()||p)){_(!0);try{await i({instanceId:e,field:t,plaintext:l}),u(``),y(null),x(!1),c.success(f())}catch(e){c.error(h(),e)}finally{_(!1)}}}async function te(){if(!p){_(!0);try{await a({instanceId:e,field:t}),y(null),x(!1),c.success(he())}catch(e){c.error(h(),e)}finally{_(!1)}}}async function E(){if(!p){_(!0);try{y(await s({instanceId:e})),x(!1),c.success(me())}catch(e){c.error(je(),e)}finally{_(!1)}}}let D=v?`openclaw devices approve ${v.id}`:``;async function k(){if(D)try{await navigator.clipboard.writeText(D),x(!0)}catch{}}return(0,Z.jsxs)($,{label:T,children:[w?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(W,{variant:S?`outline`:`secondary`,children:S?j():A()}),(0,Z.jsx)(G,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:l,placeholder:S?o():Ge(),onChange:e=>u(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void ee(),disabled:p||l.trim().length===0,children:Je()}),w?(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void E(),disabled:p,children:_t()}):null,S?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void te(),disabled:p,children:ae()}):null]})]}),v?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:me()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:vt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:D}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void k(),children:b?de():O()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{y(null),x(!1)},children:F()})]}):null]})}var Kt={conversational:ve,documentary:be,summarizer:E,curator:Se},qt={conversational:S,documentary:u,summarizer:y,curator:_e},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:ot()}),t.map(e=>(0,Z.jsx)(W,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(Tt,{children:[(0,Z.jsx)(Mt,{asChild:!0,children:(0,Z.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:D()})}),(0,Z.jsxs)(Ot,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:b()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ce()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(kt,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let i=P(m.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),o=r(m.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=r(m.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),l=r(m.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),u=r(m.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),d=r(m.agents.removeInstanceAgent),f=Et(),h=B();async function g(t,n){if(e)try{await o({instanceName:e,agentId:t,enabled:n})}catch(e){h.error(N(),e)}}async function v(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){h.error(N(),e)}}async function y(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await l({instanceName:e,agentId:t,types:i})}catch(e){h.error(N(),e)}}async function b(t,n){if(e&&await f({title:ne({name:n}),description:w(),confirmLabel:_(),destructive:!0}))try{await d({instanceName:e,agentId:t}),h.success(ce())}catch(e){h.error(N(),e)}}return(0,Z.jsx)(jt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(At,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(Nt,{children:a({name:e??``})}),(0,Z.jsx)(K,{children:ue()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:ie()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?re():i.discovery.lastPollOk?qe():c({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:Xe()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,r=i.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(kt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void g(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:p()}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void b(t.agentId,a),children:pe()})]}):r?(0,Z.jsx)(W,{variant:`default`,children:oe()}):(0,Z.jsx)(R,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void v(t.agentId),children:St()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void y(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await u({instanceName:e,agentId:t.agentId,description:n})}catch(e){h.error(N(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(G,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ee(),"aria-label":ee(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Vt as InstancesTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,$S as i,$x as a,AS as o,An as s,Ax as c,BS as l,Bx as u,CS as d,DS as f,Dx as p,E as m,ES as h,FS as g,Fx as _,GS as v,Ga as y,Gx as b,HS as x,Hx as S,IS as C,Ix as w,JS as T,Jx as ee,KS as te,Ka as E,Kx as D,LO as O,LS as k,Lx as ne,MS as A,Mx as re,NS as j,Nx as ie,OS as ae,Ox as oe,PS as se,Px as ce,QS as le,Qx as ue,RO as de,RS as fe,Rx as pe,SS as me,TS as he,US as ge,Ua as _e,Ux as ve,VS as ye,Vx as be,WS as xe,Wa as Se,Wx as Ce,XS as we,YS as Te,Yx as Ee,ZP as M,ZS as De,Zx as N,_S as Oe,aC as ke,aS as Ae,bS as je,cC as Me,cS as Ne,dC as Pe,dS as Fe,eC as Ie,eF as P,eS as F,fC as Le,fS as Re,gC as ze,gS as Be,hC as Ve,hS as He,iC as Ue,iS as We,jS as Ge,jn as Ke,jx as qe,kS as Je,kn as Ye,kx as Xe,lC as Ze,lS as Qe,mC as $e,mS as et,nC as I,nS as L,oC as tt,oS as nt,pC as rt,pS as it,qS as at,qx as ot,rC as st,rS as ct,sC as lt,sS as ut,tC as dt,tS as ft,uC as pt,uS as mt,vS as ht,v_ as gt,wS as _t,xS as vt,yS as yt,y_ as bt,zS as xt,zx as St}from"./dist-De2K23IB.js";import{a as Ct,c as wt}from"./FieldLabel-hLNtge_D.js";import{t as R}from"./button-Bd43O_sm.js";import{$ as Tt,C as z,H as B,S as V,T as H,U as Et,_t as U,d as Dt,dt as W,et as Ot,ft as G,ht as K,m as kt,mt as At,pt as jt,tt as Mt,vt as Nt,w as q,x as J}from"./index-CNwjY680.js";import{t as Pt}from"./DataTableShell-COEwE2Hv.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-s6Ggg8Zu.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Ct},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=P(m.admin.listInstances,{}),t=P(m.agents.listAllInstanceAgents,{}),n=r(m.admin.upsertInstance),a=r(m.admin.deleteInstance),o=B(),[c,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(Q),[p,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null);async function w(){try{await n({instanceId:S??void 0,name:d.name,gatewayUrl:d.gatewayUrl,bridgeUrl:d.bridgeUrl||void 0,displayName:d.displayName||void 0,kind:d.kind,transport:d.kind===`hermes`?d.transport:void 0,gatewayVersion:d.gatewayVersion||void 0,gatewayHttpUrl:d.gatewayHttpUrl||void 0,streamTransport:d.streamTransport}),f(Q),C(null),u(!1)}catch(e){o.error($e(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[rt(),(0,Z.jsx)(`strong`,{children:Le()}),Pe()]}),(0,Z.jsx)(Pt,{title:pt(),rows:e,addLabel:Ze(),onAdd:()=>{C(null),f(Q),u(!0)},emptyHint:Me(),columns:[{header:lt(),cell:e=>e.name,sort:e=>e.name},{header:tt(),cell:e=>(0,Z.jsx)(W,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:ke(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Ue(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:ze(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(W,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?oe():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Ie(),onSelect:()=>{C(e._id),f(Bt(e)),u(!0)}},{label:Ve(),onSelect:()=>h(e.name)},{label:xt(),onSelect:()=>b(e)},{label:st(),onSelect:()=>_(e)},{label:I(),variant:`destructive`,onSelect:()=>void a({instanceId:e._id})}],bulkActions:[{label:I(),variant:`destructive`,onSelect:e=>e.forEach(e=>void a({instanceId:e}))}]}),(0,Z.jsx)(Dt,{open:c,onOpenChange:u,title:S?i():dt(),description:De(),canSubmit:!!(d.name&&d.gatewayUrl),onSubmit:w,submitLabel:we(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Te(),children:[(0,Z.jsx)(G,{value:d.name,disabled:S!==null,onChange:e=>f({...d,name:e.target.value})}),S?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:le()}):null]}),(0,Z.jsx)($,{label:T(),children:(0,Z.jsxs)(J,{value:d.kind,onValueChange:e=>f({...d,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(z,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(z,{value:`hermes`,children:`Hermes`})]})]})}),d.kind===`hermes`?(0,Z.jsx)($,{label:Ke(),children:(0,Z.jsxs)(J,{value:d.transport,onValueChange:e=>f({...d,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(z,{value:`ws`,children:s()}),(0,Z.jsx)(z,{value:`rest`,children:Ye()})]})]})}):null,(0,Z.jsx)($,{label:at(),children:(0,Z.jsx)(G,{value:d.gatewayUrl,onChange:e=>f({...d,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:te(),children:(0,Z.jsx)(G,{value:d.bridgeUrl,placeholder:v(),onChange:e=>f({...d,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:xe(),children:(0,Z.jsx)(G,{value:d.displayName,onChange:e=>f({...d,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:bt(),children:[(0,Z.jsxs)(J,{value:d.streamTransport,onValueChange:e=>f({...d,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(V,{children:wt.map(e=>(0,Z.jsx)(z,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:gt()})]}),(0,Z.jsx)($,{label:ge(),children:(0,Z.jsx)(G,{value:d.gatewayVersion,placeholder:x(),onChange:e=>f({...d,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:ye(),children:(0,Z.jsx)(G,{value:d.gatewayHttpUrl,placeholder:l(),onChange:e=>f({...d,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:p,open:p!==null,onOpenChange:e=>{e||h(null)}}),g?(0,Z.jsx)(Ft,{instance:g,onClose:()=>_(null)},g._id):null,y?(0,Z.jsx)(Ht,{instance:y,onClose:()=>b(null)},y._id):null]})}function Ht({instance:e,onClose:t}){let n=P(m.instanceSecrets.listInstanceSecretStatus,{}),r=zt[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(jt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(Nt,{children:fe({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:k()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=M(m.instanceSync.forceInstanceSync),n=B(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(Oe());break;case`no_agents`:n.success(He());break;case`no_bridge_url`:n.error(et());break;case`deploy_misconfigured`:n.error(it());break;case`unauthorized`:n.error(Fe());break;case`not_served`:n.error(mt());break;default:n.error(Re());break}}catch(e){n.error(Be(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?ht():yt()})})]})}function Wt({instance:e}){let t=P(m.bridgeAuth.listBridgeAuthStatus,{}),n=M(m.bridgeAuth.mintBridgeSecret),i=r(m.bridgeAuth.revokeBridgeSecret),a=B(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function h(){if(!o){s(!0);try{l((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){a.error(L(),e)}finally{s(!1)}}}async function g(){if(!o){s(!0);try{await i({instanceId:e._id}),l(null),a.success(ct())}catch(e){a.error(L(),e)}finally{s(!1)}}}async function _(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,Z.jsxs)($,{label:Ne(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ut()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(W,{variant:p?`outline`:`secondary`,children:p?`${j()} · ${f.prefix}…${f.lastFour}`:A()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void h(),disabled:o,children:p?Ae():nt()}),p?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void g(),disabled:o,children:We()}):null]})]}),c?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:ft()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:u?de():O()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:F()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let i=M(m.instanceSecrets.setInstanceSecret),a=r(m.instanceSecrets.clearInstanceSecret),s=M(m.deviceIdentity.generateDeviceIdentity),c=B(),[l,u]=(0,Y.useState)(``),[p,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),S=n!==null,w=t===`deviceIdentity`,T=t===`token`?C():t===`deviceIdentity`?g():se();async function ee(){if(!(!l.trim()||p)){_(!0);try{await i({instanceId:e,field:t,plaintext:l}),u(``),y(null),x(!1),c.success(f())}catch(e){c.error(h(),e)}finally{_(!1)}}}async function te(){if(!p){_(!0);try{await a({instanceId:e,field:t}),y(null),x(!1),c.success(he())}catch(e){c.error(h(),e)}finally{_(!1)}}}async function E(){if(!p){_(!0);try{y(await s({instanceId:e})),x(!1),c.success(me())}catch(e){c.error(je(),e)}finally{_(!1)}}}let D=v?`openclaw devices approve ${v.id}`:``;async function k(){if(D)try{await navigator.clipboard.writeText(D),x(!0)}catch{}}return(0,Z.jsxs)($,{label:T,children:[w?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(W,{variant:S?`outline`:`secondary`,children:S?j():A()}),(0,Z.jsx)(G,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:l,placeholder:S?o():Ge(),onChange:e=>u(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void ee(),disabled:p||l.trim().length===0,children:Je()}),w?(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void E(),disabled:p,children:_t()}):null,S?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void te(),disabled:p,children:ae()}):null]})]}),v?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:me()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:vt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:D}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void k(),children:b?de():O()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{y(null),x(!1)},children:F()})]}):null]})}var Kt={conversational:ve,documentary:be,summarizer:E,curator:Se},qt={conversational:S,documentary:u,summarizer:y,curator:_e},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:ot()}),t.map(e=>(0,Z.jsx)(W,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(Tt,{children:[(0,Z.jsx)(Mt,{asChild:!0,children:(0,Z.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:D()})}),(0,Z.jsxs)(Ot,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:b()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ce()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(kt,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let i=P(m.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),o=r(m.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=r(m.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),l=r(m.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),u=r(m.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(m.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(m.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),d=r(m.agents.removeInstanceAgent),f=Et(),h=B();async function g(t,n){if(e)try{await o({instanceName:e,agentId:t,enabled:n})}catch(e){h.error(N(),e)}}async function v(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){h.error(N(),e)}}async function y(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await l({instanceName:e,agentId:t,types:i})}catch(e){h.error(N(),e)}}async function b(t,n){if(e&&await f({title:ne({name:n}),description:w(),confirmLabel:_(),destructive:!0}))try{await d({instanceName:e,agentId:t}),h.success(ce())}catch(e){h.error(N(),e)}}return(0,Z.jsx)(jt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(At,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(Nt,{children:a({name:e??``})}),(0,Z.jsx)(K,{children:ue()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:ie()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?re():i.discovery.lastPollOk?qe():c({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:Xe()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,r=i.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(kt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void g(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:p()}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void b(t.agentId,a),children:pe()})]}):r?(0,Z.jsx)(W,{variant:`default`,children:oe()}):(0,Z.jsx)(R,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void v(t.agentId),children:St()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void y(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await u({instanceName:e,agentId:t.agentId,description:n})}catch(e){h.error(N(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(G,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ee(),"aria-label":ee(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Vt as InstancesTab};
|