@lacneu/atrium 0.54.0 → 0.54.1
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-DY-_W44L.js → AccessTab-Bra1w9mI.js} +1 -1
- package/dist/assets/{AdvancedFilter-DyxLXUxk.js → AdvancedFilter-CXI70fDB.js} +1 -1
- package/dist/assets/{AgentFilesTab-BZ-sJ98U.js → AgentFilesTab--eTTThOy.js} +1 -1
- package/dist/assets/{AnomaliesTab-CJteiNE_.js → AnomaliesTab-lkmO_g5K.js} +1 -1
- package/dist/assets/{AuditTab-34knmXJb.js → AuditTab-BJSOjXf5.js} +1 -1
- package/dist/assets/{BridgeTab-DZW3Ex7N.js → BridgeTab-DSY7hdDk.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-CPinuj9W.js → ChatDefaultsTab-vjRy3Av7.js} +1 -1
- package/dist/assets/{DataTableShell-D64nWDBv.js → DataTableShell-DTw-rOw3.js} +1 -1
- package/dist/assets/{DetailChips-BkCxA-j5.js → DetailChips-BviEGC5c.js} +1 -1
- package/dist/assets/{FeedbacksTab-RJRY0B5q.js → FeedbacksTab-6qgIgk4h.js} +1 -1
- package/dist/assets/{FieldLabel-9EnuRpXB.js → FieldLabel-B-ZBXJZE.js} +1 -1
- package/dist/assets/{FilesTab-DNBtXjVq.js → FilesTab-DDPMBYeS.js} +1 -1
- package/dist/assets/{FilterBar-CwLzwvAh.js → FilterBar-CTBZM__z.js} +1 -1
- package/dist/assets/{GroupsTab-CV--ambi.js → GroupsTab-DMuGAp-1.js} +1 -1
- package/dist/assets/{InstancesTab-BoGr0E6E.js → InstancesTab-HXTzTikJ.js} +1 -1
- package/dist/assets/{IntegrationsTab-DAHHn1ZI.js → IntegrationsTab-C1dCcfJI.js} +1 -1
- package/dist/assets/{KpiTab-CzEvdGve.js → KpiTab-Gr9INsJ6.js} +1 -1
- package/dist/assets/{PreferencesTab-CiLl-rr8.js → PreferencesTab-BBWh7JJ_.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-xyD6EfPx.js → PromptInjectionsTab-DPW4ZK_F.js} +1 -1
- package/dist/assets/{RolesTab-C6ONFLVw.js → RolesTab-C4CjCfXQ.js} +1 -1
- package/dist/assets/{ScheduledTab-Cu7N8tdX.js → ScheduledTab-iq39kp5Z.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-Whz-rzfb.js → ServiceAccountsTab-Bg5IYwHt.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-C-zd821N.js → SubAgentReportsTab-B8lPe9Yy.js} +1 -1
- package/dist/assets/{ThemeShowroom-H18edgy5.js → ThemeShowroom-CmvPT6pZ.js} +1 -1
- package/dist/assets/{TimeRangePicker-DVJCx8F-.js → TimeRangePicker-C3vWWVJs.js} +1 -1
- package/dist/assets/{TracesTab-Bh31C3II.js → TracesTab-BX1G_6or.js} +1 -1
- package/dist/assets/{UsersTab-CYrE-Dl0.js → UsersTab-B2gKsvUO.js} +1 -1
- package/dist/assets/{VoiceTab-BZ-l-_P4.js → VoiceTab-RHH5sbcg.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-CaUQ2KWd.js → highlighted-body-OFNGDK62-DoH8U-bo.js} +1 -1
- package/dist/assets/{index-Bk18lEVJ.js → index-BoGVkzmD.js} +7 -7
- package/dist/assets/mermaid-GHXKKRXX-Cox7MkSV.js +1 -0
- package/dist/assets/{pdf-D_MeH9g_.js → pdf-DgVAKiaL.js} +1 -1
- package/dist/assets/{tabs-eWt8KqrV.js → tabs-BQAkx85P.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/mermaid-GHXKKRXX-DnNEf9Hf.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$u as r,Bu as i,CM as a,Gu as o,Hu as s,Ju as c,Ku as l,MM as u,Qu as d,Uu as f,Vu as p,Wu as m,Xu as h,Yu as g,Zu as _,c as v,qu as y,zu as b}from"./dist-Bh78J5oj.js";import{C as x,S,b as C,ct as w,w as T,x as E}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$u as r,Bu as i,CM as a,Gu as o,Hu as s,Ju as c,Ku as l,MM as u,Qu as d,Uu as f,Vu as p,Wu as m,Xu as h,Yu as g,Zu as _,c as v,qu as y,zu as b}from"./dist-Bh78J5oj.js";import{C as x,S,b as C,ct as w,w as T,x as E}from"./index-BoGVkzmD.js";var D=e(t(),1);function O(e){return e===`user`?f():e===`all`?s():p({group:e.group})}function k(e){return e===`common`?i():e===`owner`?b():p({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=u(v.admin.listUsers,{}),[t,n]=(0,D.useState)(``),i=u(v.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}),(0,A.jsxs)(C,{value:t,onValueChange:n,children:[(0,A.jsx)(x,{size:`sm`,"aria-label":d(),children:(0,A.jsx)(T,{placeholder:d()})}),(0,A.jsx)(E,{children:(e??[]).map(e=>(0,A.jsx)(S,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):i===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:h()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:i.user.label}),(0,A.jsx)(w,{variant:`secondary`,children:i.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),i.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:i.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:c()}),i.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:i.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:m()}):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:y()}),i.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:i.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:l()}),i.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:i.permissions.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{cp as r,dp as i,fp as a,lp as o,op as s,sp as c,up as l}from"./dist-Bh78J5oj.js";import{i as u}from"./dist-Cj3AsyfP.js";import{t as d}from"./x-Dj2c0suA.js";import{t as f}from"./button-BWtKy7q6.js";import{C as p,It as m,S as h,b as g,lt as _,w as v,x as y}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{cp as r,dp as i,fp as a,lp as o,op as s,sp as c,up as l}from"./dist-Bh78J5oj.js";import{i as u}from"./dist-Cj3AsyfP.js";import{t as d}from"./x-Dj2c0suA.js";import{t as f}from"./button-BWtKy7q6.js";import{C as p,It as m,S as h,b as g,lt as _,w as v,x as y}from"./index-BoGVkzmD.js";import{r as b}from"./TimeRangePicker-C3vWWVJs.js";var x=e(t(),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}),i(),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:l()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(g,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-40`,children:(0,S.jsx)(v,{placeholder:o()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(h,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(g,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-28`,children:(0,S.jsx)(v,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(h,{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:r()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":c(),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)(m,{}),s()]})]}):null]})}export{D as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{Ac as r,Ar as i,CM as a,Cc as o,Cr as s,Dc as ee,Dr as c,Ec as l,Er as u,Fr as d,MM as f,Mc as p,Mr as m,Nc as h,Nr as g,Oc as _,Or as v,Pc as y,Pr as b,Sc as x,Sr as S,TM as C,Tc as w,Tr as T,WE as E,_c as D,_l as O,_r as k,ac as A,ar as j,bc as M,br as N,c as P,cc as F,cr as I,dc as L,fc as R,gc as z,gr as B,hc as te,hl as ne,hr as re,ir as ie,jM as V,jc as ae,jr as oe,kM as H,kc as se,kr as U,lc as ce,mc as le,nr as W,oc as G,or as ue,pc as de,rr as fe,sc as pe,sr as me,uc as he,vc as ge,vr as _e,wc as ve,wr as ye,xc as be,xr as xe,yc as Se,yr as Ce}from"./dist-Bh78J5oj.js";import{t as K}from"./button-BWtKy7q6.js";import{At as q,C as we,G as Te,H as Ee,J as De,K as Oe,S as ke,U as Ae,W as je,Y as Me,b as Ne,ct as Pe,dt as Fe,ft as Ie,ht as Le,mt as Re,q as ze,ut as Be,w as Ve,x as He,xt as Ue,y as We,z as J}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{Ac as r,Ar as i,CM as a,Cc as o,Cr as s,Dc as ee,Dr as c,Ec as l,Er as u,Fr as d,MM as f,Mc as p,Mr as m,Nc as h,Nr as g,Oc as _,Or as v,Pc as y,Pr as b,Sc as x,Sr as S,TM as C,Tc as w,Tr as T,WE as E,_c as D,_l as O,_r as k,ac as A,ar as j,bc as M,br as N,c as P,cc as F,cr as I,dc as L,fc as R,gc as z,gr as B,hc as te,hl as ne,hr as re,ir as ie,jM as V,jc as ae,jr as oe,kM as H,kc as se,kr as U,lc as ce,mc as le,nr as W,oc as G,or as ue,pc as de,rr as fe,sc as pe,sr as me,uc as he,vc as ge,vr as _e,wc as ve,wr as ye,xc as be,xr as xe,yc as Se,yr as Ce}from"./dist-Bh78J5oj.js";import{t as K}from"./button-BWtKy7q6.js";import{At as q,C as we,G as Te,H as Ee,J as De,K as Oe,S as ke,U as Ae,W as je,Y as Me,b as Ne,ct as Pe,dt as Fe,ft as Ie,ht as Le,mt as Re,q as ze,ut as Be,w as Ve,x as He,xt as Ue,y as We,z as J}from"./index-BoGVkzmD.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-Cr1GOQAx.js";/* empty css */var Y=e(t(),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=f(P.me.getMe,{host:Ue}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),s=f(P.admin.listInstances,e!==void 0&&t?{}:`skip`),[c,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!t||!s||s.length===0||(!c||!s.some(e=>e.name===c))&&u(s[0].name)},[t,s,c]);let d=f(P.agents.listAgentsForInstance,t&&c?{instanceName:c}:`skip`),g=f(P.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),v=(0,Y.useMemo)(()=>{if(e!==void 0){if(t)return c===null||d===void 0?s!==void 0&&s.length===0?[]:void 0:d.agents.map(e=>({instanceName:c,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(g!==void 0)return g.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,c,d,s,g]),[b,S]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!v||v.length===0||(!b||!v.some(e=>$(e)===b))&&S($(v[0]))},[v,b]);let T=v?.find(e=>$(e)===b)??null,E=H(P.agentFiles.listAgentFiles),[D,O]=(0,Y.useState)({status:`idle`}),k=T?.instanceName??null,A=T?.agentId??null,j=f(P.compat.forInstance,n&&k!==null?{instanceName:k}:`skip`),M=n&&k!==null?We(j,`agentFiles`):null,N=M===null?!1:M===`loading`?null:M.blocked,F=(0,Y.useCallback)(async()=>{if(!(k===null||A===null)){O({status:`loading`});try{O({status:`done`,files:(await E({instanceName:k,agentId:A})).files})}catch{O({status:`error`})}}},[E,k,A]);(0,Y.useEffect)(()=>{N===!1&&F()},[F,N]);let[I,L]=(0,Y.useState)(null),R=f(P.agentFileCuration.listCurations,t&&k!==null&&A!==null?{instanceName:k,agentId:A}:`skip`),z=f(P.agentFileCuration.curationSettings,t&&k!==null?{instanceName:k}:`skip`),B=H(P.agentFileCuration.requestCuration),[te,re]=(0,Y.useState)(null),[ie,V]=(0,Y.useState)(null),{toast:U}=J(),ce=(0,Y.useMemo)(()=>{let e=new Map;for(let t of R??[])e.has(t.name)||e.set(t.name,t);return e},[R]),le=(0,Y.useCallback)(async e=>{if(!(k===null||A===null)){re(e);try{let t=await B({instanceName:k,agentId:A,name:e,trigger:`manual`});t.ok?U({title:m(),variant:`success`}):U({title:oe({reason:t.reason??`unknown`}),variant:`error`})}catch{U({title:i(),variant:`error`})}finally{re(null)}}},[B,k,A,U]),W=C(),G=(0,Y.useMemo)(()=>new Intl.NumberFormat(W,{maximumFractionDigits:0}),[W]);return e===void 0||v===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:y()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(s?.length??0)>1?(0,Q.jsxs)(Ne,{value:c??``,onValueChange:e=>u(e),children:[(0,Q.jsx)(we,{size:`sm`,"aria-label":h(),children:(0,Q.jsx)(Ve,{})}),(0,Q.jsx)(He,{children:(s??[]).map(e=>(0,Q.jsx)(ke,{value:e.name,children:e.name},e.name))})]}):null,v.length>0?(0,Q.jsxs)(Ne,{value:b??``,onValueChange:e=>S(e),children:[(0,Q.jsx)(we,{size:`sm`,"aria-label":p(),children:(0,Q.jsx)(Ve,{})}),(0,Q.jsx)(He,{children:v.map(e=>(0,Q.jsx)(ke,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ae()})]}),T===null?null:M===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):M!==null&&M.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(q,{size:14,"aria-hidden":!0}),` `,qe(M.gatewayVersion,M.provider)]}):D.status===`loading`||D.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):D.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[se(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void F(),children:ne()})]}):D.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:D.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)(Pe,{variant:`outline`,children:_()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:ee({size:Z(e.size,W)})}),(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:l({pct:G.format(n)})}),r?(0,Q.jsx)(q,{size:14,className:`oc-afiles__warn`,"aria-label":w()}):(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:()=>L(e),children:t?o():x()}),t&&!e.missing?(0,Q.jsx)(nt,{curatable:Ke.includes(e.name),size:e.size??0,budget:z?.budgetChars??null,enabled:z?.enabled??!1,curation:ce.get(e.name)??null,inFlight:te===e.name,onCurate:()=>void le(e.name),onReview:e=>V(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:ve({used:Z(Ze(D.files),W),total:Z(Je,W),pct:G.format(Xe(Ze(D.files)))})})]}),I&&T?(0,Q.jsx)(rt,{instanceName:T.instanceName,agentId:T.agentId,name:I.name,isAdmin:t,onClose:()=>L(null),onSaved:()=>void F()}):null,ie?(0,Q.jsx)(it,{curationId:ie,onClose:()=>V(null),onApplied:()=>{V(null),F()}}):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:b()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Pe,{variant:`outline`,className:`oc-afiles__curate-status`,children:g()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:d()}):null}function rt({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:o}){let s=H(P.agentFiles.getAgentFile),ee=H(P.agentFiles.setAgentFile),c=J(),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(!1),w=(0,Y.useCallback)(async r=>{f(!1);try{let i=await s({instanceName:e,agentId:t,name:n});u({content:i.content,updatedAtMs:i.updatedAtMs}),r||m(i.content),b(!1)}catch{f(!0)}},[s,e,t,n]);(0,Y.useEffect)(()=>{w(!1)},[w]);async function T(){if(l!==null){v(!0),S(!1);try{await ee({instanceName:e,agentId:t,name:n,content:p,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(te({name:n})),o(),await w(!1)}catch(e){et(e)?b(!0):S(!0)}finally{v(!1)}}}let k=l!==null&&p!==l.content,j=(0,Y.useMemo)(()=>l===null?null:$e(l.content,p),[l,p]),N=p.length>X,I=C(),B=(0,Y.useMemo)(()=>new Intl.NumberFormat(I),[I]);return(0,Q.jsx)(Be,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(Fe,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Le,{children:be({name:n})}),(0,Q.jsxs)(Ie,{children:[M({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,Se()]})]})]}),d?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[de(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void w(!1),children:ne()})]}):l===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:p,readOnly:!r,spellCheck:!1,onChange:e=>m(e.target.value),"aria-label":be({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:ge()}),y?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[R(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void w(!0),children:L()})]}):null,x?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:le()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${N?` is-over`:``}`,children:D({count:B.format(p.length),max:B.format(X)})}),r?(0,Q.jsx)(K,{size:`sm`,disabled:!k||_||y,onClick:()=>g(!0),children:_?O():z()}):null]})]}),(0,Q.jsx)(Ee,{open:h,onOpenChange:g,children:(0,Q.jsxs)(Te,{children:[(0,Q.jsxs)(De,{children:[(0,Q.jsx)(Me,{children:he({name:n})}),(0,Q.jsx)(Oe,{children:ce({agent:t})})]}),j?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:F({added:j.added,removed:j.removed})}),j.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:pe()}),j.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,j.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:G()}),j.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(ze,{children:[(0,Q.jsx)(je,{children:E()}),(0,Q.jsx)(Ae,{onClick:()=>void T(),children:A()})]})]})})]})})}function it({curationId:e,onClose:t,onApplied:n}){let r=f(P.agentFileCuration.getProposal,{curationId:e}),o=H(P.agentFileCuration.approveCuration),ee=V(P.agentFileCuration.rejectCuration),{toast:l}=J(),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),y=C(),b=(0,Y.useMemo)(()=>r?$e(r.beforeContent,r.proposedContent):null,[r]);async function x(){p(`approve`);try{let t=await o({curationId:e});t.ok?(l({title:U(),variant:`success`}),n()):l({title:t.reason===`conflict`?c():u({reason:t.reason??`unknown`}),variant:`error`})}catch{l({title:i(),variant:`error`})}finally{p(null)}}async function w(n){p(`reject`);try{let r=g.trim();(await ee({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?l({title:n?fe():v(),variant:`success`}):l({title:s(),variant:`error`}),t()}catch{l({title:i(),variant:`error`})}finally{p(null)}}return(0,Q.jsx)(Be,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Fe,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Le,{children:r?T({name:r.name}):a()}),(0,Q.jsx)(Ie,{children:ye()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):r===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:[S({before:Z(r.beforeSize,y),after:Z(r.proposedSize,y)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(q,{size:13,"aria-hidden":!0}),` `,xe()]}):null]}),b?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:N({added:b.added,removed:b.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:W({feedback:r.feedback})}):null,b&&b.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:re()}),(0,Q.jsx)(`ul`,{children:b.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:B()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:Ce()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.proposedContent})]})]})]}),m?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:I()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:me(),value:g,onChange:e=>_(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`ghost`,onClick:()=>h(!1),disabled:d!==null,children:ue()}),(0,Q.jsx)(K,{variant:`outline`,onClick:()=>void w(!1),disabled:d!==null,children:d===`reject`?O():j()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void w(!0),disabled:d!==null,children:d===`reject`?O():ie()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`outline`,onClick:()=>h(!0),disabled:d!==null||r==null,children:_e()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void x(),disabled:d!==null||r==null,children:d===`approve`?O():k()})]})]})})}export{tt as AgentFilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$v as r,Av as i,Bv as ee,Fv as a,Gv as te,Hv as ne,Iv as o,Jv as s,Kv as re,Lv as ie,MM as c,Mv as l,Nv as u,Pv as d,Qv as f,Rv as p,Uv as m,Vv as h,Wv as ae,Xv as g,Yv as oe,Zv as se,_y as ce,ay as le,by as _,c as v,cy as ue,dy as de,ey as fe,fy as pe,gy as me,hy as he,iy as ge,jM as _e,jv as y,kv as b,ly as ve,my as ye,ny as x,oy as S,py as C,qv as w,ry as T,sy as E,ty as D,uy as O,vy as k,xy as A,yy as j,zv as M}from"./dist-Bh78J5oj.js";import{B as N,C as P,S as F,Xt as be,Yt as I,a as xe,b as L,ct as R,dt as z,et as Se,ht as B,mt as V,r as Ce,ut as H,w as U,x as W,xt as we,z as Te}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$v as r,Av as i,Bv as ee,Fv as a,Gv as te,Hv as ne,Iv as o,Jv as s,Kv as re,Lv as ie,MM as c,Mv as l,Nv as u,Pv as d,Qv as f,Rv as p,Uv as m,Vv as h,Wv as ae,Xv as g,Yv as oe,Zv as se,_y as ce,ay as le,by as _,c as v,cy as ue,dy as de,ey as fe,fy as pe,gy as me,hy as he,iy as ge,jM as _e,jv as y,kv as b,ly as ve,my as ye,ny as x,oy as S,py as C,qv as w,ry as T,sy as E,ty as D,uy as O,vy as k,xy as A,yy as j,zv as M}from"./dist-Bh78J5oj.js";import{B as N,C as P,S as F,Xt as be,Yt as I,a as xe,b as L,ct as R,dt as z,et as Se,ht as B,mt as V,r as Ce,ut as H,w as U,x as W,xt as we,z as Te}from"./index-BoGVkzmD.js";import{n as Ee}from"./TimeRangePicker-C3vWWVJs.js";import{t as De}from"./FilterBar-CTBZM__z.js";import{t as Oe}from"./DataTableShell-DTw-rOw3.js";import{t as G}from"./dispatchErrorInfo-CmzXtnuL.js";var K=e(t(),1),q=n(),J=`__all__`,ke=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Ae(e){return e===`open`?A():e===`acknowledged`?_():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=be({from:`/settings/anomalies`}),t=I({from:`/settings/anomalies`}),n=e.q??``,i=e.status===Y?J:e.status,a=e.severity??J,o=e.kind??J,[l,u]=(0,K.useState)(J),d=Ce(e.from,e.to),{from:_,to:y}=Ee(d),b=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})}),z=e=>void t({search:t=>({...t,kind:e===J?void 0:e})}),B=e=>void t({search:t=>({...t,...xe(e)})}),V=N(),H=Te(),G=_e(v.anomalies.resolveAnomaly),X=(c(v.me.getMe,{host:we})?.permissions??[]).includes(`admin.manage`),Z=c(v.anomalies.listAnomalies,{limit:Pe,filter:{q:n||void 0,from:_,to:y,anomalyStatus:i===J?void 0:i,severity:a===J?void 0:a,source:l===J?void 0:l,kind:o===J?void 0:o}}),Q=(0,K.useMemo)(()=>{let e=new Set;for(let t of Z??[])e.add(t.kind);return[...e].sort()},[Z]),ze=n!==``||i!==`open`||a!==J||l!==J||o!==J||d.kind!==`relative`||d.from!==Ne.from;function Be(){u(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()}),`.`,` `,ye()]}),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(ve(),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()}),` `,x(),` `,(0,q.jsx)(`span`,{className:`oc-filter__window`,children:D()})]}),(0,q.jsxs)(De,{q:n,onQChange:b,searchPlaceholder:fe(),timeRange:d,onTimeRangeChange:B,onReset:Be,canReset:ze,children:[(0,q.jsxs)(L,{value:i,onValueChange:A,children:[(0,q.jsx)(P,{size:`sm`,className:`w-36`,children:(0,q.jsx)(U,{})}),(0,q.jsxs)(W,{children:[(0,q.jsx)(F,{value:J,children:r()}),ke.map(e=>(0,q.jsx)(F,{value:e.value,children:Ae(e.value)},e.value))]})]}),(0,q.jsxs)(L,{value:a,onValueChange:j,children:[(0,q.jsx)(P,{size:`sm`,className:`w-36`,children:(0,q.jsx)(U,{placeholder:f()})}),(0,q.jsxs)(W,{children:[(0,q.jsx)(F,{value:J,children:se()}),je.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]}),(0,q.jsxs)(L,{value:l,onValueChange:u,children:[(0,q.jsx)(P,{size:`sm`,className:`w-32`,children:(0,q.jsx)(U,{placeholder:g()})}),(0,q.jsxs)(W,{children:[(0,q.jsx)(F,{value:J,children:oe()}),Me.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]}),(0,q.jsxs)(L,{value:o,onValueChange:z,children:[(0,q.jsx)(P,{size:`sm`,className:`w-36`,children:(0,q.jsx)(U,{placeholder:s()})}),(0,q.jsxs)(W,{children:[(0,q.jsx)(F,{value:J,children:w()}),Q.map(e=>(0,q.jsx)(F,{value:e,children:e},e))]})]})]}),(0,q.jsx)(Oe,{title:re(),rows:Z,emptyHint:i===`open`?te():ae(),rowActions:e=>X&&e.status===`open`?[{label:m(),onSelect:()=>void Ve(e)},{label:ne(),onSelect:()=>void He(e)}]:[],columns:[{header:h(),cell:e=>(0,q.jsx)(`span`,{className:`oc-traces__time`,children:Se(e.at)}),sort:e=>e.at},{header:s(),cell:e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:f(),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:g(),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:p(),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=I();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:[`↗ `,o()]}):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:[`↗ `,o()]}):null]})}function Ie({row:e}){let[t,n]=(0,K.useState)(!1),r=c(v.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:[a(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,q.jsx)(H,{open:t,onOpenChange:n,children:(0,q.jsxs)(z,{className:`oc-anomaly__attachments-dialog`,children:[(0,q.jsx)(V,{children:(0,q.jsx)(B,{children:d()})}),r===void 0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:u()}):r.length===0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:l()}):(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:y()}):e===`acknowledged`?(0,q.jsx)(R,{variant:`secondary`,children:i()}):(0,q.jsx)(R,{variant:`outline`,children:b()})}function Re(e){return e.length>8?e.slice(0,8):e}export{X as AnomaliesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$t as r,Cb as i,Eb as a,MM as o,Sb as s,Tb as c,_b as l,bb as u,c as d,en as f,fb as p,gb as m,hb as h,in as g,mb as _,nn as v,pb as y,rn as b,tn as x,vb as S,wb as C,xb as w,yb as T}from"./dist-Bh78J5oj.js";import{C as E,S as D,Xt as O,Yt as k,a as A,b as j,et as M,i as N,o as P,r as F,t as I,w as L,x as R}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$t as r,Cb as i,Eb as a,MM as o,Sb as s,Tb as c,_b as l,bb as u,c as d,en as f,fb as p,gb as m,hb as h,in as g,mb as _,nn as v,pb as y,rn as b,tn as x,vb as S,wb as C,xb as w,yb as T}from"./dist-Bh78J5oj.js";import{C as E,S as D,Xt as O,Yt as k,a as A,b as j,et as M,i as N,o as P,r as F,t as I,w as L,x as R}from"./index-BoGVkzmD.js";import{n as ee}from"./TimeRangePicker-C3vWWVJs.js";import{t as z}from"./FilterBar-CTBZM__z.js";import{t as B}from"./AdvancedFilter-CXI70fDB.js";import{t as V}from"./DataTableShell-DTw-rOw3.js";var H=e(t(),1),U=n(),W={kind:`relative`,from:I,to:`now`},G=`__all__`,K=[{value:`action`,label:g()},{value:`realLabel`,label:b()},{value:`targetLabel`,label:v()},{value:`impersonated`,label:x()},{value:`resource`,label:f()},{value:`resourceId`,label:r()}];function q(){let e=O({from:`/settings/audit`}),t=k({from:`/settings/audit`}),n=e.q??``,r=e.action??G,f=e.impersonated??G,g=e.resource??G,v=F(e.from,e.to),b=(0,H.useMemo)(()=>P(e.adv),[e.adv]),{from:x,to:I}=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,...A(e)})}),Q=e=>void t({search:t=>({...t,adv:N(e)}),replace:!0}),$=o(d.admin.listAudit,{filter:{q:n||void 0,from:x,to:I,action:r===G?void 0:r,resource:g===G?void 0:g,impersonated:f===G?void 0:f===`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||f!==G||g!==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:[a(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:c()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:C(),timeRange:v,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(j,{value:r,onValueChange:J,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:i()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:s()}),te.map(e=>(0,U.jsx)(D,{value:e,children:e},e))]})]}),(0,U.jsxs)(j,{value:f,onValueChange:Y,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:w()}),(0,U.jsx)(D,{value:`yes`,children:u()}),(0,U.jsx)(D,{value:`no`,children:T()})]})]}),(0,U.jsxs)(j,{value:g,onValueChange:X,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:S()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:l()}),ne.map(e=>(0,U.jsx)(D,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:b,onChange:Q}),(0,U.jsx)(V,{title:m(),rows:$,emptyHint:h(),columns:[{header:_(),cell:e=>M(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:p(),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{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$m as r,Ag as i,Ah as a,Bh as o,Bs as s,Cg as c,Ch as l,Ct as u,Dg as d,Dh as f,Eg as p,Eh as m,Fh as ee,Gh as te,Gs as h,Hh as ne,Hs as g,Ih as re,Is as _,Jh as ie,Js as v,Kh as ae,Ks as y,Lh as b,Ls as oe,MM as x,Mh as se,Ms as ce,Nh as le,Oh as ue,Ot as de,Ph as fe,Qm as pe,Rh as me,Rs as he,Sg as ge,Sh as _e,St as ve,Tg as ye,Th as be,Tt as xe,Uh as Se,Us as S,Vh as Ce,Vs as we,Wh as Te,Ws as Ee,Zm as C,_g as De,_h as Oe,ah as ke,bg as Ae,bh as je,c as w,ch as Me,dh as T,eh as Ne,fh as Pe,gg as Fe,gh as Ie,hh as Le,ih as Re,jM as ze,jh as Be,kM as Ve,kg as He,kh as Ue,l as E,lh as We,mh as Ge,nh as Ke,oh as qe,ph as Je,qh as Ye,qs as Xe,rh as Ze,sh as Qe,th as $e,uh as et,vh as tt,wg as nt,wh as rt,wt as it,xg as at,xh as ot,xt as st,yh as ct,zh as lt,zs as ut}from"./dist-Bh78J5oj.js";import{i as D,r as dt}from"./dist-Cj3AsyfP.js";import{t as ft}from"./chevrons-up-down-DWBiHBws.js";import{i as pt,n as O,o as mt,r as ht,s as gt}from"./FieldLabel-9EnuRpXB.js";import{i as _t,n as vt,r as yt,t as bt}from"./tabs-eWt8KqrV.js";import{t as k}from"./button-BWtKy7q6.js";import{At as A,C as j,Kt as M,Nt as N,Q as xt,S as P,X as St,Xt as Ct,Yt as F,Z as wt,b as I,ct as L,dt as Tt,et as Et,ft as Dt,ht as Ot,lt as R,m as kt,mt as At,p as jt,qt as Mt,tt as z,ut as Nt,w as B,x as V,xt as Pt,z as Ft,zt as It}from"./index-Bk18lEVJ.js";import{r as Lt}from"./locales-CPjguROj.js";import{a as Rt,i as H,n as zt,o as U,r as W,t as Bt}from"./table-EVqhs7Hw.js";import{t as Vt}from"./FilterBar-CwLzwvAh.js";import{a as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt}from"./compatView-Cr1GOQAx.js";import{t as G}from"./dispatchErrorInfo-CmzXtnuL.js";var Jt=E(`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`}]]),Yt=E(`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`}]]),K=e(t(),1);function Xt(e){return e.filter(e=>e.state===`error`)}function Zt(e){return e.reachable&&Xt(e.targets).length===0}function Qt(e){return Zt(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function $t(e){return e.state===`error`&&e.lastErrorCode!==null}function en(e){return!!e.lastDownstreamRejectCode}function q(e){return e.kind??`openclaw`}function tn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function nn(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,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return tn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,rn={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function an(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function on(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 Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function sn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function cn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Wt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function ln(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=sn(t.key,e),a=sn(t.key,r);return i&&a?0:i?1:a?-1:n*cn(t.key,e,r)})}function un(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function dn(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)=>Z(e.label,t.label))}function fn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Wt(e,t)??Z(e,t))}var Q=n();function pn({connections:e,displayByInstance:t}){let[n,r]=(0,K.useState)(rn),[i,a]=(0,K.useState)(null),o=(0,K.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,K.useMemo)(()=>un(o),[o]),c=(0,K.useMemo)(()=>dn(o),[o]),l=(0,K.useMemo)(()=>fn(o),[o]),u=(0,K.useMemo)(()=>ln(on(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,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Vt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Pe(),onReset:()=>r(rn),canReset:an(n),children:[(0,Q.jsxs)(I,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(B,{placeholder:et()})}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(P,{value:Y,children:T()}),s.map(e=>(0,Q.jsx)(P,{value:e,children:hn(e)},e))]})]}),(0,Q.jsxs)(I,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(B,{placeholder:We()})}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(P,{value:Y,children:T()}),c.map(e=>(0,Q.jsx)(P,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(I,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(B,{placeholder:Me()})}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(P,{value:Y,children:T()}),l.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}):(0,Q.jsxs)(Bt,{className:`oc-conn__table`,children:[(0,Q.jsx)(Rt,{children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)($,{label:qe(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:ke(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Re(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ze(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ke(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(H,{children:$e()}),(0,Q.jsx)($,{label:Ne(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(zt,{children:u.map(e=>(0,Q.jsx)(mn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(H,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(dt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(ft,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function mn({r:e}){let t=$t(e)?G(e.lastErrorCode):null,n=en(e)?G(e.lastDownstreamRejectCode):null;return(0,Q.jsxs)(K.Fragment,{children:[(0,Q.jsxs)(U,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(W,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(gn,{state:e.state})}),(0,Q.jsx)(W,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(W,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:Ge({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(W,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:z(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Q.jsx)(U,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(W,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${z(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Je({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${z(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function hn(e){return e===`connected`?r():e===`error`?pe():C()}function gn({state:e}){return e===`connected`?(0,Q.jsx)(L,{variant:`secondary`,children:r()}):e===`error`?(0,Q.jsx)(L,{variant:`destructive`,children:pe()}):(0,Q.jsx)(L,{variant:`outline`,children:C()})}function _n(){return x(w.bridgeHealth.getBridgeHealth,{})}function vn(){let e=_n(),t=x(w.compat.getBridgeCompat,{}),n=x(w.me.getMe,{host:Pt})?.role===`admin`,r=x(w.admin.listInstances,n?{}:`skip`),i=x(w.agents.usageForInstances,n?{}:`skip`),a=F(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=nn(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Ct({from:`/settings/bridge`}),l=F({from:`/settings/bridge`}),d=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,p=d!==null&&Ut(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(yn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:fe()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:le()}),(0,Q.jsxs)(Bt,{children:[(0,Q.jsx)(Rt,{children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{children:xe()}),(0,Q.jsx)(H,{children:it()}),(0,Q.jsx)(H,{children:u()}),(0,Q.jsx)(H,{children:ve()}),(0,Q.jsx)(H,{children:st()})]})}),(0,Q.jsx)(zt,{children:i.flatMap(e=>{let t=kt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(U,{children:[(0,Q.jsx)(W,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(W,{children:t.provider}),(0,Q.jsx)(W,{children:t.label}),(0,Q.jsx)(W,{children:(0,Q.jsxs)(L,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(W,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.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,Q.jsx)(yt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(_t,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(N,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(vt,{value:e.key,children:(0,Q.jsx)(bn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:d,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,p?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ce()}):null]})}function yn({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,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Ht(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:y(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,h({build:t.buildVersion??`?`})]}):null,` · `,Ee(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?S():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:be()});let o=Xt(e.targets),s=!e.reachable,c=Qt(e),u=e.unreachableInstances??[],d=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,f=Et(e.checkedAt),p=e.startedAt==null?null:Et(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Q.jsx)(M,{size:22}):s||c===`gateways_unreachable`?(0,Q.jsx)(Yt,{size:22}):(0,Q.jsx)(A,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?rt():c===`gateways_unreachable`?je({count:u.length}):s?l():_e({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Jt,{size:12,"aria-hidden":!0}),` `,ot({time:f})]}),p?(0,Q.jsx)(`span`,{children:tt({time:p})}):null,a]}),c===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ct({names:u.join(`, `)})}):null,s?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:G(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Oe()})]})}function bn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(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:qt(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,K.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(N,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),f?(0,Q.jsx)(L,{variant:f===`beyond`?`destructive`:`secondary`,children:Gt(f)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:v()}),(0,Q.jsx)(Sn,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(xn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[p?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Mt,{size:13,"aria-hidden":!0}),Ie({count:t.length})]}),p?(0,Q.jsx)(pn,{connections:t,displayByInstance:c}):null]})}function xn({protocol:e}){let[t,n]=(0,K.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[se(),i.length>0?(0,Q.jsx)(L,{variant:`destructive`,children:a({count:i.length})}):(0,Q.jsx)(L,{variant:`secondary`,children:Be()})]}),(0,Q.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,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Mt,{size:13,"aria-hidden":!0}),f({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function Sn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Xe()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:g()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:de({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:s({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:S()}),e?(0,Q.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Ht(e.version)}),(0,Q.jsx)(L,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Gt(e.state)})]},e.instanceName))})]})}function Cn({instance:e,onClose:t}){return(0,Q.jsx)(Nt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Tt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ot,{children:i({instance:e.displayName??e.name})}),(0,Q.jsx)(Dt,{children:He()})]}),(0,Q.jsx)(Tn,{instance:e,onClose:t})]})})}function wn({label:e,result:t}){return t?t.checked?(0,Q.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,Q.jsx)(M,{"aria-hidden":!0}):(0,Q.jsx)(A,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?me():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,b()]}):null}function Tn({instance:e,onClose:t}){let n=ze(w.admin.upsertInstanceConfig),r=Ve(w.bridge.validateMediaPaths),i=Ft(),a=Lt(e.config?.contentLocale,void 0),[s,l]=(0,K.useState)(()=>pt(e.config??{},a)),[u,f]=(0,K.useState)(!1),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),v=s.inboundMediaMode===`shared-fs`,y=s.mediaMode===`shared-fs`,b=v||y;async function oe(){h(!0),_(null);try{_(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(ne(),e)}finally{h(!1)}}async function x(){f(!0);try{let r=e.config??{};await n({instanceId:e._id,config:ht(s,r,a)}),t()}catch(e){i.error(ge(),e)}finally{f(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:d(),help:at()}),(0,Q.jsxs)(I,{value:s.mediaMode,onValueChange:e=>l({...s,mediaMode:e}),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(B,{})}),(0,Q.jsx)(V,{children:gt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:p(),help:Ae()}),(0,Q.jsxs)(I,{value:s.inboundMediaMode,onValueChange:e=>l({...s,inboundMediaMode:e}),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(B,{})}),(0,Q.jsx)(V,{children:mt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ye(),help:De()}),(0,Q.jsx)(R,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>l({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ie(),help:Ye()}),(0,Q.jsx)(R,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>l({...s,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ae(),help:te()}),(0,Q.jsx)(R,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>l({...s,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(jt,{checked:s.rehydration,onCheckedChange:e=>l({...s,rehydration:e===!0})}),(0,Q.jsx)(O,{label:nt(),help:Fe()})]}),b&&g!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(A,{"aria-hidden":!0}),ee({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wn,{label:o(),result:g.inbound}),(0,Q.jsx)(wn,{label:lt(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(A,{"aria-hidden":!0}),re()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void oe(),disabled:m,children:[m?(0,Q.jsx)(It,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?Se():Te()]}),(0,Q.jsx)(k,{size:`sm`,onClick:()=>void x(),disabled:u,children:c()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(St,{children:[(0,Q.jsx)(xt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?ut():he({count:e.length}),(0,Q.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(wt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:oe()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(L,{variant:`secondary`,children:e},e))})]})]})}export{vn as BridgeTab,Cn as InstanceConfigDialog};
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$m as r,Ag as i,Ah as a,Bh as o,Bs as s,Cg as c,Ch as l,Ct as u,Dg as d,Dh as f,Eg as p,Eh as m,Fh as ee,Gh as te,Gs as h,Hh as ne,Hs as g,Ih as re,Is as _,Jh as ie,Js as v,Kh as ae,Ks as y,Lh as b,Ls as oe,MM as x,Mh as se,Ms as ce,Nh as le,Oh as ue,Ot as de,Ph as fe,Qm as pe,Rh as me,Rs as he,Sg as ge,Sh as _e,St as ve,Tg as ye,Th as be,Tt as xe,Uh as Se,Us as S,Vh as Ce,Vs as we,Wh as Te,Ws as Ee,Zm as C,_g as De,_h as Oe,ah as ke,bg as Ae,bh as je,c as w,ch as Me,dh as T,eh as Ne,fh as Pe,gg as Fe,gh as Ie,hh as Le,ih as Re,jM as ze,jh as Be,kM as Ve,kg as He,kh as Ue,l as E,lh as We,mh as Ge,nh as Ke,oh as qe,ph as Je,qh as Ye,qs as Xe,rh as Ze,sh as Qe,th as $e,uh as et,vh as tt,wg as nt,wh as rt,wt as it,xg as at,xh as ot,xt as st,yh as ct,zh as lt,zs as ut}from"./dist-Bh78J5oj.js";import{i as D,r as dt}from"./dist-Cj3AsyfP.js";import{t as ft}from"./chevrons-up-down-DWBiHBws.js";import{i as pt,n as O,o as mt,r as ht,s as gt}from"./FieldLabel-B-ZBXJZE.js";import{i as _t,n as vt,r as yt,t as bt}from"./tabs-BQAkx85P.js";import{t as k}from"./button-BWtKy7q6.js";import{At as A,C as j,Kt as M,Nt as N,Q as xt,S as P,X as St,Xt as Ct,Yt as F,Z as wt,b as I,ct as L,dt as Tt,et as Et,ft as Dt,ht as Ot,lt as R,m as kt,mt as At,p as jt,qt as Mt,tt as z,ut as Nt,w as B,x as V,xt as Pt,z as Ft,zt as It}from"./index-BoGVkzmD.js";import{r as Lt}from"./locales-CPjguROj.js";import{a as Rt,i as H,n as zt,o as U,r as W,t as Bt}from"./table-EVqhs7Hw.js";import{t as Vt}from"./FilterBar-CTBZM__z.js";import{a as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt}from"./compatView-Cr1GOQAx.js";import{t as G}from"./dispatchErrorInfo-CmzXtnuL.js";var Jt=E(`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`}]]),Yt=E(`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`}]]),K=e(t(),1);function Xt(e){return e.filter(e=>e.state===`error`)}function Zt(e){return e.reachable&&Xt(e.targets).length===0}function Qt(e){return Zt(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function $t(e){return e.state===`error`&&e.lastErrorCode!==null}function en(e){return!!e.lastDownstreamRejectCode}function q(e){return e.kind??`openclaw`}function tn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function nn(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,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return tn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,rn={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function an(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function on(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 Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function sn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function cn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Wt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function ln(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=sn(t.key,e),a=sn(t.key,r);return i&&a?0:i?1:a?-1:n*cn(t.key,e,r)})}function un(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function dn(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)=>Z(e.label,t.label))}function fn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Wt(e,t)??Z(e,t))}var Q=n();function pn({connections:e,displayByInstance:t}){let[n,r]=(0,K.useState)(rn),[i,a]=(0,K.useState)(null),o=(0,K.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,K.useMemo)(()=>un(o),[o]),c=(0,K.useMemo)(()=>dn(o),[o]),l=(0,K.useMemo)(()=>fn(o),[o]),u=(0,K.useMemo)(()=>ln(on(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,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Vt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Pe(),onReset:()=>r(rn),canReset:an(n),children:[(0,Q.jsxs)(I,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(B,{placeholder:et()})}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(P,{value:Y,children:T()}),s.map(e=>(0,Q.jsx)(P,{value:e,children:hn(e)},e))]})]}),(0,Q.jsxs)(I,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(B,{placeholder:We()})}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(P,{value:Y,children:T()}),c.map(e=>(0,Q.jsx)(P,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(I,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(B,{placeholder:Me()})}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(P,{value:Y,children:T()}),l.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}):(0,Q.jsxs)(Bt,{className:`oc-conn__table`,children:[(0,Q.jsx)(Rt,{children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)($,{label:qe(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:ke(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Re(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ze(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ke(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(H,{children:$e()}),(0,Q.jsx)($,{label:Ne(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(zt,{children:u.map(e=>(0,Q.jsx)(mn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(H,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(dt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(ft,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function mn({r:e}){let t=$t(e)?G(e.lastErrorCode):null,n=en(e)?G(e.lastDownstreamRejectCode):null;return(0,Q.jsxs)(K.Fragment,{children:[(0,Q.jsxs)(U,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(W,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(gn,{state:e.state})}),(0,Q.jsx)(W,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(W,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:Ge({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(W,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:z(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Q.jsx)(U,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(W,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${z(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Je({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${z(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function hn(e){return e===`connected`?r():e===`error`?pe():C()}function gn({state:e}){return e===`connected`?(0,Q.jsx)(L,{variant:`secondary`,children:r()}):e===`error`?(0,Q.jsx)(L,{variant:`destructive`,children:pe()}):(0,Q.jsx)(L,{variant:`outline`,children:C()})}function _n(){return x(w.bridgeHealth.getBridgeHealth,{})}function vn(){let e=_n(),t=x(w.compat.getBridgeCompat,{}),n=x(w.me.getMe,{host:Pt})?.role===`admin`,r=x(w.admin.listInstances,n?{}:`skip`),i=x(w.agents.usageForInstances,n?{}:`skip`),a=F(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=nn(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Ct({from:`/settings/bridge`}),l=F({from:`/settings/bridge`}),d=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,p=d!==null&&Ut(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(yn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:fe()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:le()}),(0,Q.jsxs)(Bt,{children:[(0,Q.jsx)(Rt,{children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)(H,{children:xe()}),(0,Q.jsx)(H,{children:it()}),(0,Q.jsx)(H,{children:u()}),(0,Q.jsx)(H,{children:ve()}),(0,Q.jsx)(H,{children:st()})]})}),(0,Q.jsx)(zt,{children:i.flatMap(e=>{let t=kt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(U,{children:[(0,Q.jsx)(W,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(W,{children:t.provider}),(0,Q.jsx)(W,{children:t.label}),(0,Q.jsx)(W,{children:(0,Q.jsxs)(L,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(W,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.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,Q.jsx)(yt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(_t,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(N,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(vt,{value:e.key,children:(0,Q.jsx)(bn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:d,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,p?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ce()}):null]})}function yn({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,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Ht(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:y(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,h({build:t.buildVersion??`?`})]}):null,` · `,Ee(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?S():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:be()});let o=Xt(e.targets),s=!e.reachable,c=Qt(e),u=e.unreachableInstances??[],d=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,f=Et(e.checkedAt),p=e.startedAt==null?null:Et(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Q.jsx)(M,{size:22}):s||c===`gateways_unreachable`?(0,Q.jsx)(Yt,{size:22}):(0,Q.jsx)(A,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?rt():c===`gateways_unreachable`?je({count:u.length}):s?l():_e({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Jt,{size:12,"aria-hidden":!0}),` `,ot({time:f})]}),p?(0,Q.jsx)(`span`,{children:tt({time:p})}):null,a]}),c===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ct({names:u.join(`, `)})}):null,s?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:G(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Oe()})]})}function bn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(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:qt(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,K.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(N,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),f?(0,Q.jsx)(L,{variant:f===`beyond`?`destructive`:`secondary`,children:Gt(f)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:v()}),(0,Q.jsx)(Sn,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(xn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>m(e=>!e),children:[p?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Mt,{size:13,"aria-hidden":!0}),Ie({count:t.length})]}),p?(0,Q.jsx)(pn,{connections:t,displayByInstance:c}):null]})}function xn({protocol:e}){let[t,n]=(0,K.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[se(),i.length>0?(0,Q.jsx)(L,{variant:`destructive`,children:a({count:i.length})}):(0,Q.jsx)(L,{variant:`secondary`,children:Be()})]}),(0,Q.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,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Mt,{size:13,"aria-hidden":!0}),f({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function Sn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Xe()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:g()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:de({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:s({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:S()}),e?(0,Q.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Ht(e.version)}),(0,Q.jsx)(L,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Gt(e.state)})]},e.instanceName))})]})}function Cn({instance:e,onClose:t}){return(0,Q.jsx)(Nt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Tt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(At,{children:[(0,Q.jsx)(Ot,{children:i({instance:e.displayName??e.name})}),(0,Q.jsx)(Dt,{children:He()})]}),(0,Q.jsx)(Tn,{instance:e,onClose:t})]})})}function wn({label:e,result:t}){return t?t.checked?(0,Q.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,Q.jsx)(M,{"aria-hidden":!0}):(0,Q.jsx)(A,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?me():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,b()]}):null}function Tn({instance:e,onClose:t}){let n=ze(w.admin.upsertInstanceConfig),r=Ve(w.bridge.validateMediaPaths),i=Ft(),a=Lt(e.config?.contentLocale,void 0),[s,l]=(0,K.useState)(()=>pt(e.config??{},a)),[u,f]=(0,K.useState)(!1),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),v=s.inboundMediaMode===`shared-fs`,y=s.mediaMode===`shared-fs`,b=v||y;async function oe(){h(!0),_(null);try{_(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(ne(),e)}finally{h(!1)}}async function x(){f(!0);try{let r=e.config??{};await n({instanceId:e._id,config:ht(s,r,a)}),t()}catch(e){i.error(ge(),e)}finally{f(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:d(),help:at()}),(0,Q.jsxs)(I,{value:s.mediaMode,onValueChange:e=>l({...s,mediaMode:e}),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(B,{})}),(0,Q.jsx)(V,{children:gt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:p(),help:Ae()}),(0,Q.jsxs)(I,{value:s.inboundMediaMode,onValueChange:e=>l({...s,inboundMediaMode:e}),children:[(0,Q.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(B,{})}),(0,Q.jsx)(V,{children:mt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ye(),help:De()}),(0,Q.jsx)(R,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>l({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ie(),help:Ye()}),(0,Q.jsx)(R,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>l({...s,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ae(),help:te()}),(0,Q.jsx)(R,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>l({...s,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(jt,{checked:s.rehydration,onCheckedChange:e=>l({...s,rehydration:e===!0})}),(0,Q.jsx)(O,{label:nt(),help:Fe()})]}),b&&g!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(A,{"aria-hidden":!0}),ee({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wn,{label:o(),result:g.inbound}),(0,Q.jsx)(wn,{label:lt(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(A,{"aria-hidden":!0}),re()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void oe(),disabled:m,children:[m?(0,Q.jsx)(It,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?Se():Te()]}),(0,Q.jsx)(k,{size:`sm`,onClick:()=>void x(),disabled:u,children:c()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(St,{children:[(0,Q.jsx)(xt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?ut():he({count:e.length}),(0,Q.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(wt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:oe()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(L,{variant:`secondary`,children:e},e))})]})]})}export{vn as BridgeTab,Cn as InstanceConfigDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$s as r,CM as i,Ci as a,Di as o,Dt as s,Ei as c,MM as l,Nc as u,Og as d,Oi as f,Qs as p,Si as m,Ti as h,Xs as g,Ys as _,Zs as v,_l as y,bi as b,c as x,dl as S,ec as C,hl as w,jM as T,kM as E,ki as D,nc as O,rc as k,tc as A,ul as j,wi as M,xi as N}from"./dist-Bh78J5oj.js";import{t as P}from"./button-BWtKy7q6.js";import{At as F,C as I,S as L,b as R,d as z,f as B,lt as V,p as H,w as U,x as W,y as G}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$s as r,CM as i,Ci as a,Di as o,Dt as s,Ei as c,MM as l,Nc as u,Og as d,Oi as f,Qs as p,Si as m,Ti as h,Xs as g,Ys as _,Zs as v,_l as y,bi as b,c as x,dl as S,ec as C,hl as w,jM as T,kM as E,ki as D,nc as O,rc as k,tc as A,ul as j,wi as M,xi as N}from"./dist-Bh78J5oj.js";import{t as P}from"./button-BWtKy7q6.js";import{At as F,C as I,S as L,b as R,d as z,f as B,lt as V,p as H,w as U,x as W,y as G}from"./index-BoGVkzmD.js";import{i as K}from"./compatView-Cr1GOQAx.js";/* empty css */var q=e(t(),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=T(x.admin.upsertInstanceConfig),n=l(x.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,q.useState)(r),[o,s]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(r),s(`idle`)},[e._id,r]);let u=`__none__`,d=i!==r;async function f(){s(`saving`);try{let n={...e.config??{}};i===``||i===u?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),s(`done`)}catch{s(`error`)}}let p=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:c()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:h()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(R,{value:i===``?u:i,onValueChange:e=>a(e===u?``:e),children:[(0,X.jsx)(I,{className:`oc-cdefaults__select`,"aria-label":c(),children:(0,X.jsx)(U,{placeholder:M()})}),(0,X.jsxs)(W,{children:[(0,X.jsx)(L,{value:u,children:M()}),p.map(e=>(0,X.jsx)(L,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!d||o===`saving`,onClick:()=>void f(),children:o===`saving`?y():v()})]}),o===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:g()}):null,o===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:_()}):null]})}function Q({instance:e}){let t=T(x.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,s]=(0,q.useState)(n),[c,l]=(0,q.useState)(r===null?``:String(r)),[u,d]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{s(n),l(r===null?``:String(r)),d(`idle`)},[e._id,n,r]);let f=c.trim(),p=f===``?null:/^\d+$/.test(f)?Number.parseInt(f,10):NaN,h=!i||p===null||Number.isInteger(p)&&p>=4e3&&p<=6e4,b=i!==n||(p??null)!==r;async function S(){d(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||p===null||Number.isNaN(p)?delete n.curationBudgetChars:n.curationBudgetChars=p,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`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:i,onCheckedChange:e=>s(e===!0),"aria-label":o()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:o()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:c,onChange:e=>l(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!h,"aria-label":a(),disabled:!i}),(0,X.jsx)(P,{size:`sm`,disabled:!b||!h||u===`saving`,onClick:()=>void S(),children:u===`saving`?y():v()})]}),h?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}),u===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:g()}):null,u===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:_()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:N()})]})}function $({instance:e}){let t=T(x.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,q.useState)(n===null?``:String(n)),[a,o]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{i(n===null?``:String(n)),o(`idle`)},[e._id,n]);let s=r.trim(),c=s===``?null:/^\d+$/.test(s)?Number.parseInt(s,10):NaN,l=c===null||Number.isInteger(c)&&c>=1e3&&c<=2e5,u=(c??null)!==n;async function d(){o(`saving`);try{let n={...e.config??{}};c===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=c,await t({instanceId:e._id,config:n}),o(`done`)}catch{o(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:D()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!l}),(0,X.jsx)(P,{size:`sm`,disabled:!u||!l||a===`saving`,onClick:()=>void d(),children:a===`saving`?y():v()})]}),l?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:b()}),a===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:g()}):null,a===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:_()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:f()})]})}function ee(){let e=E(x.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),a=l(x.admin.listInstances,{}),[o,c]=(0,q.useState)(null);(0,q.useEffect)(()=>{!a||a.length===0||(!o||!a.some(e=>e.name===o))&&c(a[0].name)},[a,o]);let f=(a?.length??0)>1,m=a!==void 0&&a.length===0,h=l(x.compat.forInstance,o?{instanceName:o}:`skip`),g=o?G(h,`configDefaults`):`loading`,_=g===`loading`?null:g.blocked,v=(0,q.useMemo)(()=>f&&o?{instanceName:o}:{},[f,o]),y=(0,q.useRef)(0),b=(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&&(f&&!o||b())},[b,_,f,o]);let T=t.status===`done`?t.current:null,D=(0,q.useMemo)(()=>J.map(e=>({id:e,label:B(e)})),[]),M=(0,q.useMemo)(()=>[{id:`fast`,label:S()},{id:`standard`,label:j()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:k()}),f&&o?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:u()}),(0,X.jsxs)(R,{value:o,onValueChange:e=>c(e),children:[(0,X.jsx)(I,{size:`sm`,"aria-label":u(),children:(0,X.jsx)(U,{})}),(0,X.jsx)(W,{children:(a??[]).map(e=>(0,X.jsx)(L,{value:e.name,children:e.name},e.name))})]})]}):null,m?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:d()}):g===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):g.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(F,{size:14,"aria-hidden":!0}),` `,K(g.gatewayVersion,g.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[p(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:w()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:O()}),(0,X.jsx)(z,{options:D,value:T?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:A()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:C()}),(0,X.jsx)(z,{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:r()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:s()})]}),(()=>{let e=a?.find(e=>e.name===(o??a[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{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{Cf as r,Sf as i,bf as a,vf as o,wf as s,xf as c,yf as l}from"./dist-Bh78J5oj.js";import{i as u,r as d}from"./dist-Cj3AsyfP.js";import{t as f}from"./chevrons-up-down-DWBiHBws.js";import{t as p}from"./button-BWtKy7q6.js";import{Ht as m,It as h,it as g,jt as _,nt as v,ot as y,p as b,rt as x,st as S}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{Cf as r,Sf as i,bf as a,vf as o,wf as s,xf as c,yf as l}from"./dist-Bh78J5oj.js";import{i as u,r as d}from"./dist-Cj3AsyfP.js";import{t as f}from"./chevrons-up-down-DWBiHBws.js";import{t as p}from"./button-BWtKy7q6.js";import{Ht as m,It as h,it as g,jt as _,nt as v,ot as y,p as b,rt as x,st as S}from"./index-BoGVkzmD.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-EVqhs7Hw.js";var k=e(t(),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=s(),bulkActions:F,emptyHint:I=r(),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)(_,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(h,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):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)(b,{"aria-label":c(),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":o({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)(b,{"aria-label":a(),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)(v,{children:[(0,M.jsx)(S,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":l(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(y,{}):null,(0,M.jsx)(g,{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-BJq7W7j9.js";import{ct as t}from"./index-
|
|
1
|
+
import{r as e}from"./bundle-mjs-BJq7W7j9.js";import{ct as t}from"./index-BoGVkzmD.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{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$S as r,AC as i,BC as a,CC as o,DC as s,EC as c,FC as l,GC as u,GS as d,HC as f,IC as p,JS as m,KS as h,LC as g,MC as _,MM as v,NC as y,OC as ee,PC as te,QS as ne,RC as re,SC as ie,TC as b,UC as x,VC as S,Vr as C,WC as w,WS as T,XS as E,YS as D,ZS as O,_C as k,aC as A,bC as j,c as M,cC as N,dC as P,eC as F,fC as I,gC as L,hC as R,iC as z,jC as B,jM as V,kC as H,lC as U,mC as ae,nC as W,oC as G,pC as K,qS as q,rC as J,sC as oe,tC as se,uC as ce,vC as le,wC as ue,xC as de,yC as fe,zC as pe,zr as me}from"./dist-Bh78J5oj.js";import{t as he}from"./button-BWtKy7q6.js";import{B as ge,et as _e}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$S as r,AC as i,BC as a,CC as o,DC as s,EC as c,FC as l,GC as u,GS as d,HC as f,IC as p,JS as m,KS as h,LC as g,MC as _,MM as v,NC as y,OC as ee,PC as te,QS as ne,RC as re,SC as ie,TC as b,UC as x,VC as S,Vr as C,WC as w,WS as T,XS as E,YS as D,ZS as O,_C as k,aC as A,bC as j,c as M,cC as N,dC as P,eC as F,fC as I,gC as L,hC as R,iC as z,jC as B,jM as V,kC as H,lC as U,mC as ae,nC as W,oC as G,pC as K,qS as q,rC as J,sC as oe,tC as se,uC as ce,vC as le,wC as ue,xC as de,yC as fe,zC as pe,zr as me}from"./dist-Bh78J5oj.js";import{t as he}from"./button-BWtKy7q6.js";import{B as ge,et as _e}from"./index-BoGVkzmD.js";import{t as Y}from"./DataTableShell-DTw-rOw3.js";var X=e(t(),1),Z=n(),ve={altered_words:()=>u(),incorrect:()=>w(),incoherence:()=>x(),formatting:()=>f(),latency:()=>S(),api_error:()=>a(),other:()=>pe()},Q=e=>ve[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:g()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:p()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:re()})}function ye({data:e,closeReason:t}){let n=e.snapshot,r=V(M.feedback.respondToFeedback),[a,u]=(0,X.useState)(e.thread),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!1);async function h(){let t=d.trim();if(!(!t||p)){m(!0);try{await r({feedbackId:e._id,text:t}),u(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),f(``)}finally{m(!1)}}}let g=[];try{g=n.contextJson?JSON.parse(n.contextJson):[]}catch{g=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:n.displayedMatchesStored,sourceWasOpen:n.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,n.messageRole,n.isRegeneration?` · ${l()}`:``,n.openclawModel?` · ${n.openclawModel}`:``,n.openclawRuntime?` (${n.openclawRuntime})`:``]})]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:te()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,t?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:E()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:t})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:y()}),a.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:a.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`?_():e.authorRole===`agent`?e.authorLabel??C():B()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:i()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:H(),value:d,maxLength:2e3,rows:3,onChange:e=>f(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(he,{size:`sm`,onClick:()=>void h(),disabled:!d.trim()||p,children:p?ee():s()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:c()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.messageText||b()})]}),n.clientInfo?.sourceWasOpen&&n.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ue()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.displayedText||b()})]}):null,n.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:o()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.promptText})]}):null,g.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ie({count:n.contextCount??g.length,truncated:n.contextTruncated?de():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:g.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,n.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:j()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[n.outboxText??``,n.outboxStatus?`\n[status: ${n.outboxStatus}]`:``]})]}):null,n.clientInfo?.extensionsDetected&&n.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:fe()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:n.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:le()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[n.clientInfo?.language,n.clientInfo?.timezone,n.clientInfo?.theme?k({theme:n.clientInfo.theme}):null,n.runId?`run ${n.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,n.clientInfo?.plugins&&n.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[L(),` `,n.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,R()]})]}):null,n.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:n.clientInfo.userAgent}):null]})]})]})}function be(){let e=v(M.feedback.listForAdmin,{}),t=V(M.feedback.readSnapshot),n=V(M.feedback.deleteFeedback),i=ge(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)({});async function l(e){if(a===e._id){o(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});c(t=>({...t,[e._id]:n}))}o(e._id)}async function u(e){await i({title:h(),description:d(),confirmLabel:T(),destructive:!0})&&(await n({feedbackId:e._id}),a===e._id&&o(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[ae(),` `,(0,Z.jsx)(`strong`,{children:K()}),` `,I()]}),(0,Z.jsx)(Y,{title:P(),rows:e,emptyHint:ce(),isExpanded:e=>a===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(ye,{data:s[e._id],closeReason:e.userCloseReason}):null,columns:[{header:U(),cell:e=>_e(e.at),sort:e=>e.at},{header:N(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:oe(),cell:e=>e.messageRole===`user`?G():A(),sort:e=>e.messageRole},{header:z(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${J({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:W(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:se(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:F(),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:ne()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:me()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:O()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?D():m(),onSelect:()=>void l(e)},{label:q(),onSelect:()=>void u(e),variant:`destructive`}]})]})}export{be as FeedbacksTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./bundle-mjs-BJq7W7j9.js";import{l as t,zM as n}from"./dist-Bh78J5oj.js";import{_ as r,g as i,h as a,v as o}from"./index-
|
|
1
|
+
import{r as e}from"./bundle-mjs-BJq7W7j9.js";import{l as t,zM as n}from"./dist-Bh78J5oj.js";import{_ as r,g as i,h as a,v as o}from"./index-BoGVkzmD.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{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$j as r,Aj as i,Bj as a,CM as ee,Cj as te,Dj as ne,Ej as o,Fj as re,Gj as s,Gr as c,Hj as l,Ij as ie,Jj as u,Kj as d,Lj as ae,MM as oe,Mj as se,Nj as ce,Oj as le,Pj as ue,Qj as de,Rj as fe,Sj as pe,TM as me,Tj as he,Uj as f,Vj as p,WE as ge,Wj as m,Wr as _e,Xj as ve,Yj as ye,Zj as be,c as h,eM as g,jM as xe,jj as Se,kj as _,nM as v,qj as y,rM as b,tM as x,wj as S,zj as C}from"./dist-Bh78J5oj.js";import{t as w}from"./button-BWtKy7q6.js";import{C as T,Ft as E,G as D,H as O,Ht as k,J as A,K as j,S as M,U as Ce,Ut as N,W as we,Y as Te,b as P,ct as F,it as I,jt as Ee,nt as De,p as Oe,q as ke,rt as Ae,st as je,w as L,x as R,z as Me}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$j as r,Aj as i,Bj as a,CM as ee,Cj as te,Dj as ne,Ej as o,Fj as re,Gj as s,Gr as c,Hj as l,Ij as ie,Jj as u,Kj as d,Lj as ae,MM as oe,Mj as se,Nj as ce,Oj as le,Pj as ue,Qj as de,Rj as fe,Sj as pe,TM as me,Tj as he,Uj as f,Vj as p,WE as ge,Wj as m,Wr as _e,Xj as ve,Yj as ye,Zj as be,c as h,eM as g,jM as xe,jj as Se,kj as _,nM as v,qj as y,rM as b,tM as x,wj as S,zj as C}from"./dist-Bh78J5oj.js";import{t as w}from"./button-BWtKy7q6.js";import{C as T,Ft as E,G as D,H as O,Ht as k,J as A,K as j,S as M,U as Ce,Ut as N,W as we,Y as Te,b as P,ct as F,it as I,jt as Ee,nt as De,p as Oe,q as ke,rt as Ae,st as je,w as L,x as R,z as Me}from"./index-BoGVkzmD.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-EVqhs7Hw.js";var H=e(t(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return d();case`audio`:return s();case`video`:return m();case`pdf`:return f();case`document`:return l();case`archive`:return p();default:return a()}}function K(){let[e,t]=(0,H.useState)(W),[n,a]=(0,H.useState)(W),[s,l]=(0,H.useState)(W),[d,f]=(0,H.useState)(W),[p,m]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=xe(h.files.softDelete),Y=Me();function Ie(){t(W),a(W),l(W),f(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(_())}catch(e){Y.error(le(),e)}}let X=oe(h.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:s===W?void 0:s,category:d===W?void 0:d,includeAutoGenerated:p||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(me(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:ee()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||s!==W||d!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:b()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(P,{value:e,onValueChange:t,children:[(0,U.jsx)(T,{size:`sm`,"aria-label":v(),children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(M,{value:W,children:x()}),(0,U.jsx)(M,{value:`inbound`,children:g()}),(0,U.jsx)(M,{value:`outbound`,children:r()})]})]}),(0,U.jsxs)(P,{value:n,onValueChange:a,children:[(0,U.jsx)(T,{size:`sm`,"aria-label":de(),children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(M,{value:W,children:be()}),Q.chats.map(e=>(0,U.jsx)(M,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(P,{value:s,onValueChange:l,children:[(0,U.jsx)(T,{size:`sm`,"aria-label":ve(),children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(M,{value:W,children:ye()}),Q.instances.map(e=>(0,U.jsx)(M,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(P,{value:d,onValueChange:f,children:[(0,U.jsx)(T,{size:`sm`,"aria-label":u(),children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(M,{value:W,children:y()}),Q.categories.map(e=>(0,U.jsx)(M,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(Oe,{checked:p,onCheckedChange:e=>m(e===!0),"aria-label":c()}),(0,U.jsx)(`span`,{children:c()})]}),$?(0,U.jsxs)(w,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(E,{size:14,"aria-hidden":!0}),se()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?te():S()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:C()}),(0,U.jsx)(z,{children:fe()}),(0,U.jsx)(z,{children:ae()}),(0,U.jsx)(z,{children:ie()}),(0,U.jsx)(z,{children:re()}),(0,U.jsx)(z,{className:`text-right`,children:ue()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(F,{variant:`outline`,style:{marginLeft:6},children:_e()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(F,{variant:`secondary`,children:e.direction===`inbound`?g():r()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(De,{children:[(0,U.jsx)(je,{asChild:!0,children:(0,U.jsx)(w,{variant:`ghost`,size:`icon`,"aria-label":Se(),children:(0,U.jsx)(k,{size:16})})}),(0,U.jsxs)(Ae,{align:`end`,children:[e.url?(0,U.jsx)(I,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(N,{size:14}),ce()]})}):(0,U.jsxs)(I,{disabled:!0,children:[(0,U.jsx)(N,{size:14}),he()]}),(0,U.jsxs)(I,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(Ee,{size:14}),i()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:pe({cap:Be})}):null]}),(0,U.jsx)(O,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(D,{children:[(0,U.jsxs)(A,{children:[(0,U.jsx)(Te,{children:ne()}),(0,U.jsx)(j,{children:o()})]}),(0,U.jsxs)(ke,{children:[(0,U.jsx)(we,{children:ge()}),(0,U.jsx)(Ce,{onClick:()=>void Le(),children:i()})]})]})})]})}export{K as FilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{Ef as r,Tf as i}from"./dist-Bh78J5oj.js";import{t as a}from"./button-BWtKy7q6.js";import{Ft as o,Pt as s,lt as c}from"./index-
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{Ef as r,Tf as i}from"./dist-Bh78J5oj.js";import{t as a}from"./button-BWtKy7q6.js";import{Ft as o,Pt as s,lt as c}from"./index-BoGVkzmD.js";import{t as l}from"./TimeRangePicker-C3vWWVJs.js";var u=e(t(),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)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(c,{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)(o,{}),i()]})]})}export{p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$l as r,Al as i,Au as a,Bl as o,Cu as s,Du as c,Eu as l,Fl as u,Fu as d,Gl as f,Hl as p,Il as m,Iu as h,Jl as g,Kl as _,Ll as v,Lu as y,MM as b,Ml as x,Mu as S,Nl as C,Nu as ee,Ou as w,Pl as T,Pu as E,Ql as D,Rl as O,Ru as k,Su as A,Tu as te,Ul as ne,Vl as j,Wl as M,Xl as N,Yl as P,Zl as re,_u as F,au as ie,bu as I,c as L,cu as ae,du as oe,eu as se,fu as ce,gu as le,hu as ue,iu as de,jM as R,jl as fe,ju as pe,kl as me,ku as he,l as z,lu as B,mu as ge,nu as _e,ou as ve,pu as ye,ql as be,ru as xe,su as Se,tu as Ce,uu as we,vu as Te,wu as Ee,xu as De,yu as Oe,zl as ke}from"./dist-Bh78J5oj.js";import{t as Ae}from"./x-Dj2c0suA.js";import{i as V,n as H,r as je,t as Me}from"./tabs-eWt8KqrV.js";import{t as U}from"./button-BWtKy7q6.js";import{B as Ne,C as Pe,Jt as Fe,Mt as W,Nt as G,S as Ie,b as Le,ct as K,dt as Re,ft as ze,ht as Be,lt as q,mt as Ve,p as J,qt as He,u as Ue,ut as We,w as Ge,x as Ke,xt as qe,z as Y}from"./index-Bk18lEVJ.js";import{t as Je}from"./FilterBar-CwLzwvAh.js";import{t as Ye}from"./DataTableShell-D64nWDBv.js";import{t as X}from"./DetailChips-BkCxA-j5.js";var Xe=z(`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`}]]),Z=z(`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`}]]),Ze=z(`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`}]]),Q=e(t(),1);function Qe(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 $e(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 et(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 tt(e){switch(e){case`admin`:return ie();case`user`:return de();case`pending`:return xe();default:return e}}function nt(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 rt(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 $=n(),it={name:``,description:``};function at(){let e=b(L.groups.listGroups,{}),t=b(L.me.getMe,{host:qe})?.role===`admin`,n=R(L.groups.createGroup),r=R(L.groups.updateGroup),i=R(L.groups.deleteGroup),o=Ne(),u=Y(),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(it),[C,T]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(``),ne=(0,Q.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(){g(null),v(it),p(!0)}function M(e){g(e),v({name:e.name,description:e.description??``}),p(!0)}async function N(){try{m?await r({groupId:m._id,name:_.name,description:_.description}):await n({name:_.name,description:_.description||void 0}),v(it),g(null),p(!1)}catch(e){u.error(x(),e)}}async function P(e){if(await o({title:Oe({name:e.name}),description:Te(),confirmWord:e.name,confirmLabel:F(),cancelLabel:te(),destructive:!0}))try{await i({groupId:e._id})}catch(e){u.error(fe(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:y()}),(0,$.jsx)(Je,{q:D,onQChange:O,onReset:()=>O(``),canReset:D!==``,searchPlaceholder:a()}),(0,$.jsx)(Ye,{title:k(),rows:ne,addLabel:h(),onAdd:t?j:void 0,emptyHint:d(),columns:[{header:E(),cell:e=>e.name,sort:e=>e.name},{header:ee(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(Z,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:S(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(G,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:pe(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Xe,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:he(),onSelect:()=>T({groupId:e._id,name:e.name})},...t?[{label:w(),onSelect:()=>M(e)},{label:c(),variant:`destructive`,onSelect:()=>void P(e)}]:[]]}),(0,$.jsx)(Ue,{open:f,onOpenChange:p,title:m?s():Ee(),description:A(),canSubmit:!!_.name.trim(),onSubmit:N,submitLabel:l(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:De()}),(0,$.jsx)(q,{value:_.name,onChange:e=>v({..._,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:I()}),(0,$.jsx)(q,{value:_.description,onChange:e=>v({..._,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:C?.groupId??null,groupName:C?.name??``,open:C!==null,onOpenChange:e=>{e||T(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Fe,{size:14,"aria-hidden":!0}),ae()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":ve({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[Se(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let a=b(L.groups.getGroup,n&&e?{groupId:e}:`skip`),o=b(L.groups.listAssignableInstances,n?{}:`skip`),s=b(L.groups.listAssignableUsers,n?{}:`skip`),c=R(L.groups.addMember),l=R(L.groups.removeMember),d=R(L.groups.bulkSetMembers),p=R(L.groups.setGroupManager),h=Y(),[g,_]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(`members`),[ee,w]=(0,Q.useState)(1),[E,O]=(0,Q.useState)(new Set),k=(0,Q.useRef)(null),A=(0,Q.useMemo)(()=>new Set((a?.members??[]).map(e=>e.userId)),[a]),te=(0,Q.useMemo)(()=>new Set((a?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[a]),ne=a?.viewerIsAdmin===!0,j=(0,Q.useMemo)(()=>new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[a]);(0,Q.useEffect)(()=>{_(``),x(``),C(`members`),w(1),k.current=null},[n,e]),(0,Q.useEffect)(()=>{w(1)},[g]),(0,Q.useEffect)(()=>{n&&a&&e&&k.current!==e&&(k.current=e,O(new Set((a.members??[]).map(e=>e.userId))))},[n,a,e]);let M=(0,Q.useMemo)(()=>s?Qe(s,g,E):[],[s,g,E]);async function N(t,n){if(e)try{n?await l({groupId:e,userId:t}):await c({groupId:e,userId:t})}catch(e){h.error(i(),e)}}async function P(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){h.error(T(),e)}}let F=nt(M,e=>A.has(e.userId)),ie=M.filter(e=>A.has(e.userId)).length,I=rt(M,ee,ot);async function ae(){if(!e||M.length===0)return;let t=M.map(e=>e.userId);try{await d({groupId:e,userIds:t,member:F!==`all`})}catch(e){h.error(i(),e)}}return(0,$.jsx)(We,{open:n,onOpenChange:r,children:(0,$.jsxs)(Re,{className:`oc-access`,children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:le({name:t})}),(0,$.jsx)(ze,{children:ue()})]}),(0,$.jsxs)(Me,{value:S,onValueChange:C,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(V,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),ge(),a?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:A.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),ce(),a?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),f(),a?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:a.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:s===void 0||a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:D()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:g,onChange:e=>_(e.target.value),placeholder:ye(),className:`oc-access__search`}),M.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:we()}):(0,$.jsxs)($.Fragment,{children:[M.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void ae(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()}),(0,$.jsxs)(K,{variant:`outline`,className:`oc-access__count`,children:[ie,` / `,M.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=A.has(e.userId),n=et(e),r=te.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:t,onCheckedChange:()=>void N(e.userId,t),"aria-label":_e({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&ne?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?u():m(),title:r?u():m(),onClick:()=>void P(e.userId,r),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&r?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":v(),title:v(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:I.page,pageCount:I.pageCount,onPage:w})]})]})}),(0,$.jsx)(H,{value:`agents`,children:o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:re()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:y,onChange:e=>x(e.target.value),placeholder:oe(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:j,query:y},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:i,query:a}){let o=b(L.groups.listAssignableAgents,{instanceName:t}),s=R(L.groups.assignAgentToGroup),c=R(L.groups.removeAgentFromGroup),l=R(L.groups.bulkSetGroupAgents),u=Y(),[d,f]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{f(1)},[a]),!e)return null;let p=$e(o?.agents??[],a),m=o?.discovery&&!o.discovery.lastPollOk;if(a.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),v=nt(h,e=>i.has(`${t}/${e.agentId}`)),y=rt(p,d,ot);async function x(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await s({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(me(),e)}}async function S(){if(h.length===0)return;let n=h.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:v!==`all`})}catch(e){u.error(me(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__stale`,children:g()}):null]}),o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:r()}):p.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:m?P():N()}):(0,$.jsxs)($.Fragment,{children:[h.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:v===`all`?!0:v===`some`?`indeterminate`:!1,onCheckedChange:()=>void S(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()})]}):null,y.pageItems.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(J,{checked:r,disabled:(a||o)&&!r,onCheckedChange:()=>void x(e.agentId,r),"aria-label":Ce({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":_(),title:_(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:be()}):null]},e.agentId)}),(0,$.jsx)(st,{page:y.page,pageCount:y.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=b(L.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=R(L.charts.assignChartToGroup),r=R(L.charts.removeChartFromGroup),i=R(L.charts.setGroupDefaultChart),a=R(L.charts.addChartToGroupPool),s=R(L.charts.removeChartFromGroupPool),c=Y();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()});let{pool:l,addable:u,canManagePool:d}=t;if(l.length===0&&!d)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:M()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}async function m(t){try{await i({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}async function g(t){try{await s({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:e.selected,onCheckedChange:()=>void f(e.chartKey,e.selected),"aria-label":o({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":ke(),title:ke(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:O()}):null,d?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":j({name:e.name}),title:j({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?u.length>0?(0,$.jsxs)(Le,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)(Pe,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ge,{placeholder:p()})}),(0,$.jsx)(Ke,{children:u.map(e=>(0,$.jsx)(Ie,{value:e.chartKey,children:e.name},e.chartKey))})]}):l.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):null:null]})}export{at as GroupsTab};
|
|
1
|
+
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$l as r,Al as i,Au as a,Bl as o,Cu as s,Du as c,Eu as l,Fl as u,Fu as d,Gl as f,Hl as p,Il as m,Iu as h,Jl as g,Kl as _,Ll as v,Lu as y,MM as b,Ml as x,Mu as S,Nl as C,Nu as ee,Ou as w,Pl as T,Pu as E,Ql as D,Rl as O,Ru as k,Su as A,Tu as te,Ul as ne,Vl as j,Wl as M,Xl as N,Yl as P,Zl as re,_u as F,au as ie,bu as I,c as L,cu as ae,du as oe,eu as se,fu as ce,gu as le,hu as ue,iu as de,jM as R,jl as fe,ju as pe,kl as me,ku as he,l as z,lu as B,mu as ge,nu as _e,ou as ve,pu as ye,ql as be,ru as xe,su as Se,tu as Ce,uu as we,vu as Te,wu as Ee,xu as De,yu as Oe,zl as ke}from"./dist-Bh78J5oj.js";import{t as Ae}from"./x-Dj2c0suA.js";import{i as V,n as H,r as je,t as Me}from"./tabs-BQAkx85P.js";import{t as U}from"./button-BWtKy7q6.js";import{B as Ne,C as Pe,Jt as Fe,Mt as W,Nt as G,S as Ie,b as Le,ct as K,dt as Re,ft as ze,ht as Be,lt as q,mt as Ve,p as J,qt as He,u as Ue,ut as We,w as Ge,x as Ke,xt as qe,z as Y}from"./index-BoGVkzmD.js";import{t as Je}from"./FilterBar-CTBZM__z.js";import{t as Ye}from"./DataTableShell-DTw-rOw3.js";import{t as X}from"./DetailChips-BviEGC5c.js";var Xe=z(`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`}]]),Z=z(`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`}]]),Ze=z(`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`}]]),Q=e(t(),1);function Qe(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 $e(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 et(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 tt(e){switch(e){case`admin`:return ie();case`user`:return de();case`pending`:return xe();default:return e}}function nt(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 rt(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 $=n(),it={name:``,description:``};function at(){let e=b(L.groups.listGroups,{}),t=b(L.me.getMe,{host:qe})?.role===`admin`,n=R(L.groups.createGroup),r=R(L.groups.updateGroup),i=R(L.groups.deleteGroup),o=Ne(),u=Y(),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(it),[C,T]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(``),ne=(0,Q.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(){g(null),v(it),p(!0)}function M(e){g(e),v({name:e.name,description:e.description??``}),p(!0)}async function N(){try{m?await r({groupId:m._id,name:_.name,description:_.description}):await n({name:_.name,description:_.description||void 0}),v(it),g(null),p(!1)}catch(e){u.error(x(),e)}}async function P(e){if(await o({title:Oe({name:e.name}),description:Te(),confirmWord:e.name,confirmLabel:F(),cancelLabel:te(),destructive:!0}))try{await i({groupId:e._id})}catch(e){u.error(fe(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:y()}),(0,$.jsx)(Je,{q:D,onQChange:O,onReset:()=>O(``),canReset:D!==``,searchPlaceholder:a()}),(0,$.jsx)(Ye,{title:k(),rows:ne,addLabel:h(),onAdd:t?j:void 0,emptyHint:d(),columns:[{header:E(),cell:e=>e.name,sort:e=>e.name},{header:ee(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(Z,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:S(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(G,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:pe(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Xe,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:he(),onSelect:()=>T({groupId:e._id,name:e.name})},...t?[{label:w(),onSelect:()=>M(e)},{label:c(),variant:`destructive`,onSelect:()=>void P(e)}]:[]]}),(0,$.jsx)(Ue,{open:f,onOpenChange:p,title:m?s():Ee(),description:A(),canSubmit:!!_.name.trim(),onSubmit:N,submitLabel:l(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:De()}),(0,$.jsx)(q,{value:_.name,onChange:e=>v({..._,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:I()}),(0,$.jsx)(q,{value:_.description,onChange:e=>v({..._,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:C?.groupId??null,groupName:C?.name??``,open:C!==null,onOpenChange:e=>{e||T(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Fe,{size:14,"aria-hidden":!0}),ae()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":ve({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[Se(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let a=b(L.groups.getGroup,n&&e?{groupId:e}:`skip`),o=b(L.groups.listAssignableInstances,n?{}:`skip`),s=b(L.groups.listAssignableUsers,n?{}:`skip`),c=R(L.groups.addMember),l=R(L.groups.removeMember),d=R(L.groups.bulkSetMembers),p=R(L.groups.setGroupManager),h=Y(),[g,_]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(`members`),[ee,w]=(0,Q.useState)(1),[E,O]=(0,Q.useState)(new Set),k=(0,Q.useRef)(null),A=(0,Q.useMemo)(()=>new Set((a?.members??[]).map(e=>e.userId)),[a]),te=(0,Q.useMemo)(()=>new Set((a?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[a]),ne=a?.viewerIsAdmin===!0,j=(0,Q.useMemo)(()=>new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[a]);(0,Q.useEffect)(()=>{_(``),x(``),C(`members`),w(1),k.current=null},[n,e]),(0,Q.useEffect)(()=>{w(1)},[g]),(0,Q.useEffect)(()=>{n&&a&&e&&k.current!==e&&(k.current=e,O(new Set((a.members??[]).map(e=>e.userId))))},[n,a,e]);let M=(0,Q.useMemo)(()=>s?Qe(s,g,E):[],[s,g,E]);async function N(t,n){if(e)try{n?await l({groupId:e,userId:t}):await c({groupId:e,userId:t})}catch(e){h.error(i(),e)}}async function P(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){h.error(T(),e)}}let F=nt(M,e=>A.has(e.userId)),ie=M.filter(e=>A.has(e.userId)).length,I=rt(M,ee,ot);async function ae(){if(!e||M.length===0)return;let t=M.map(e=>e.userId);try{await d({groupId:e,userIds:t,member:F!==`all`})}catch(e){h.error(i(),e)}}return(0,$.jsx)(We,{open:n,onOpenChange:r,children:(0,$.jsxs)(Re,{className:`oc-access`,children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:le({name:t})}),(0,$.jsx)(ze,{children:ue()})]}),(0,$.jsxs)(Me,{value:S,onValueChange:C,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(V,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),ge(),a?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:A.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),ce(),a?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),f(),a?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:a.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:s===void 0||a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:D()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:g,onChange:e=>_(e.target.value),placeholder:ye(),className:`oc-access__search`}),M.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:we()}):(0,$.jsxs)($.Fragment,{children:[M.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void ae(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()}),(0,$.jsxs)(K,{variant:`outline`,className:`oc-access__count`,children:[ie,` / `,M.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=A.has(e.userId),n=et(e),r=te.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:t,onCheckedChange:()=>void N(e.userId,t),"aria-label":_e({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&ne?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?u():m(),title:r?u():m(),onClick:()=>void P(e.userId,r),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&r?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":v(),title:v(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:I.page,pageCount:I.pageCount,onPage:w})]})]})}),(0,$.jsx)(H,{value:`agents`,children:o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:re()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:y,onChange:e=>x(e.target.value),placeholder:oe(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:j,query:y},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:i,query:a}){let o=b(L.groups.listAssignableAgents,{instanceName:t}),s=R(L.groups.assignAgentToGroup),c=R(L.groups.removeAgentFromGroup),l=R(L.groups.bulkSetGroupAgents),u=Y(),[d,f]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{f(1)},[a]),!e)return null;let p=$e(o?.agents??[],a),m=o?.discovery&&!o.discovery.lastPollOk;if(a.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),v=nt(h,e=>i.has(`${t}/${e.agentId}`)),y=rt(p,d,ot);async function x(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await s({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(me(),e)}}async function S(){if(h.length===0)return;let n=h.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:v!==`all`})}catch(e){u.error(me(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__stale`,children:g()}):null]}),o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:r()}):p.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:m?P():N()}):(0,$.jsxs)($.Fragment,{children:[h.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:v===`all`?!0:v===`some`?`indeterminate`:!1,onCheckedChange:()=>void S(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()})]}):null,y.pageItems.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(J,{checked:r,disabled:(a||o)&&!r,onCheckedChange:()=>void x(e.agentId,r),"aria-label":Ce({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":_(),title:_(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:be()}):null]},e.agentId)}),(0,$.jsx)(st,{page:y.page,pageCount:y.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=b(L.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=R(L.charts.assignChartToGroup),r=R(L.charts.removeChartFromGroup),i=R(L.charts.setGroupDefaultChart),a=R(L.charts.addChartToGroupPool),s=R(L.charts.removeChartFromGroupPool),c=Y();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()});let{pool:l,addable:u,canManagePool:d}=t;if(l.length===0&&!d)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:M()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}async function m(t){try{await i({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}async function g(t){try{await s({groupId:e,chartKey:t})}catch(e){c.error(C(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:e.selected,onCheckedChange:()=>void f(e.chartKey,e.selected),"aria-label":o({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":ke(),title:ke(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:O()}):null,d?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":j({name:e.name}),title:j({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?u.length>0?(0,$.jsxs)(Le,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)(Pe,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ge,{placeholder:p()})}),(0,$.jsx)(Ke,{children:u.map(e=>(0,$.jsx)(Ie,{value:e.chartKey,children:e.name},e.chartKey))})]}):l.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):null:null]})}export{at as GroupsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$b as r,$x as i,Ab as a,At as o,Ax as s,Bb as c,Bx as l,Cx as u,Db as d,Dx as f,Ex as p,Fb as m,Fx as h,Gb as g,Gi as _,Gx as v,Hb as y,Hx as b,ID as x,Ib as S,Ix as ee,Jb as te,Jx as ne,Kb as C,Ki as w,Kx as T,LD as E,Lb as re,Lx as ie,MM as D,Mb as ae,Mt as oe,Mx as O,Nb as se,Nx as k,Ob as ce,Ox as le,Pb as ue,Px as de,Qb as fe,Qx as pe,Rb as me,Rx as he,Sx as ge,Tx as _e,Ub as ve,Ux as ye,Vb as be,Vx as xe,Wb as Se,Wi as Ce,Wx as we,Xx as Te,Yb as Ee,Yx as De,Zb as A,Zx as Oe,_x as ke,aS as Ae,ax as je,bx as Me,c as j,cS as Ne,cx as Pe,dS as Fe,dx as Ie,eS as Le,ex as Re,fS as ze,fx as Be,gS as Ve,gx as He,hS as Ue,hx as We,iS as Ge,ix as Ke,jM as M,jb as qe,jt as Je,jx as Ye,kM as N,kb as Xe,kx as Ze,lS as Qe,lx as $e,mS as et,mx as tt,nS as P,nx as F,oS as nt,ox as rt,pS as it,px as at,qb as ot,qi as st,qx as ct,rS as lt,rx as ut,sS as dt,sx as ft,tS as pt,tx as mt,uS as ht,ux as gt,vg as _t,vx as vt,wx as yt,xx as bt,yg as xt,yx as St,zb as Ct,zx as wt}from"./dist-Bh78J5oj.js";import{a as Tt,c as Et}from"./FieldLabel-9EnuRpXB.js";import{t as I}from"./button-BWtKy7q6.js";import{B as Dt,C as L,Q as Ot,S as R,X as kt,Z as At,b as z,ct as B,dt as V,ft as H,ht as U,lt as W,mt as G,p as jt,u as Mt,ut as Nt,w as K,x as q,z as J}from"./index-Bk18lEVJ.js";import{t as Pt}from"./DataTableShell-D64nWDBv.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-DZW3Ex7N.js";var Y=e(t(),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:Tt},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=D(j.admin.listInstances,{}),t=D(j.agents.listAllInstanceAgents,{}),n=M(j.admin.upsertInstance),r=M(j.admin.deleteInstance),a=J(),[s,c]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(Q),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(null);async function S(){try{await n({instanceId:y??void 0,name:u.name,gatewayUrl:u.gatewayUrl,bridgeUrl:u.bridgeUrl||void 0,displayName:u.displayName||void 0,kind:u.kind,transport:u.kind===`hermes`?u.transport:void 0,gatewayVersion:u.gatewayVersion||void 0,gatewayHttpUrl:u.gatewayHttpUrl||void 0,streamTransport:u.streamTransport}),d(Q),x(null),c(!1)}catch(e){a.error(et(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[it(),(0,Z.jsx)(`strong`,{children:ze()}),Fe()]}),(0,Z.jsx)(Pt,{title:ht(),rows:e,addLabel:Qe(),onAdd:()=>{x(null),d(Q),c(!0)},emptyHint:Ne(),columns:[{header:dt(),cell:e=>e.name,sort:e=>e.name},{header:nt(),cell:e=>(0,Z.jsx)(B,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Ae(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Ge(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:Ve(),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)(B,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?ce():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Le(),onSelect:()=>{x(e._id),d(Bt(e)),c(!0)}},{label:Ue(),onSelect:()=>p(e.name)},{label:wt(),onSelect:()=>_(e)},{label:lt(),onSelect:()=>h(e)},{label:P(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:P(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(Mt,{open:s,onOpenChange:c,title:y?i():pt(),description:Oe(),canSubmit:!!(u.name&&u.gatewayUrl),onSubmit:S,submitLabel:Te(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:De(),children:[(0,Z.jsx)(W,{value:u.name,disabled:y!==null,onChange:e=>d({...u,name:e.target.value})}),y?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:pe()}):null]}),(0,Z.jsx)($,{label:ne(),children:(0,Z.jsxs)(z,{value:u.kind,onValueChange:e=>d({...u,kind:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(R,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(R,{value:`hermes`,children:`Hermes`})]})]})}),u.kind===`hermes`?(0,Z.jsx)($,{label:oe(),children:(0,Z.jsxs)(z,{value:u.transport,onValueChange:e=>d({...u,transport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(R,{value:`ws`,children:Je()}),(0,Z.jsx)(R,{value:`rest`,children:o()})]})]})}):null,(0,Z.jsx)($,{label:ct(),children:(0,Z.jsx)(W,{value:u.gatewayUrl,onChange:e=>d({...u,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:T(),children:(0,Z.jsx)(W,{value:u.bridgeUrl,placeholder:v(),onChange:e=>d({...u,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:we(),children:(0,Z.jsx)(W,{value:u.displayName,onChange:e=>d({...u,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:xt(),children:[(0,Z.jsxs)(z,{value:u.streamTransport,onValueChange:e=>d({...u,streamTransport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsx)(q,{children:Et.map(e=>(0,Z.jsx)(R,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_t()})]}),(0,Z.jsx)($,{label:ye(),children:(0,Z.jsx)(W,{value:u.gatewayVersion,placeholder:b(),onChange:e=>d({...u,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:xe(),children:(0,Z.jsx)(W,{value:u.gatewayHttpUrl,placeholder:l(),onChange:e=>d({...u,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:f,open:f!==null,onOpenChange:e=>{e||p(null)}}),m?(0,Z.jsx)(Ft,{instance:m,onClose:()=>h(null)},m._id):null,g?(0,Z.jsx)(Ht,{instance:g,onClose:()=>_(null)},g._id):null]})}function Ht({instance:e,onClose:t}){let n=D(j.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)(Nt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(V,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(U,{children:he({instance:e.displayName??e.name})}),(0,Z.jsx)(H,{children:ie()})]}),(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=N(j.instanceSync.forceInstanceSync),n=J(),[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(ke());break;case`no_agents`:n.success(We());break;case`no_bridge_url`:n.error(tt());break;case`deploy_misconfigured`:n.error(at());break;case`unauthorized`:n.error(Ie());break;case`not_served`:n.error(gt());break;default:n.error(Be());break}}catch(e){n.error(He(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:$e()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?vt():St()})})]})}function Wt({instance:e}){let t=D(j.bridgeAuth.listBridgeAuthStatus,{}),n=N(j.bridgeAuth.mintBridgeSecret),r=M(j.bridgeAuth.revokeBridgeSecret),i=J(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(F(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(ut())}catch(e){i.error(F(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Pe(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ft()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{variant:f?`outline`:`secondary`,children:f?`${k()} · ${d.prefix}…${d.lastFour}`:O()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?je():rt()}),f?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:Ke()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:mt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?E():x()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:Re()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=N(j.instanceSecrets.setInstanceSecret),i=M(j.instanceSecrets.clearInstanceSecret),a=N(j.deviceIdentity.generateDeviceIdentity),o=J(),[c,l]=(0,Y.useState)(``),[d,m]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),b=n!==null,S=t===`deviceIdentity`,te=t===`token`?ee():t===`deviceIdentity`?h():de();async function ne(){if(!(!c.trim()||d)){m(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),_(null),y(!1),o.success(f())}catch(e){o.error(p(),e)}finally{m(!1)}}}async function C(){if(!d){m(!0);try{await i({instanceId:e,field:t}),_(null),y(!1),o.success(_e())}catch(e){o.error(p(),e)}finally{m(!1)}}}async function w(){if(!d){m(!0);try{_(await a({instanceId:e})),y(!1),o.success(ge())}catch(e){o.error(Me(),e)}finally{m(!1)}}}let T=g?`openclaw devices approve ${g.id}`:``;async function re(){if(T)try{await navigator.clipboard.writeText(T),y(!0)}catch{}}return(0,Z.jsxs)($,{label:te,children:[S?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{variant:b?`outline`:`secondary`,children:b?k():O()}),(0,Z.jsx)(W,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:b?s():Ye(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void ne(),disabled:d||c.trim().length===0,children:Ze()}),S?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void w(),disabled:d,children:yt()}):null,b?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void C(),disabled:d,children:le()}):null]})]}),g?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:ge()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:bt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void re(),children:v?E():x()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{_(null),y(!1)},children:Re()})]}):null]})}var Kt={conversational:ve,documentary:be,summarizer:st,curator:_},qt={conversational:y,documentary:c,summarizer:w,curator:Ce},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)(B,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(kt,{children:[(0,Z.jsx)(Ot,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:C()})}),(0,Z.jsxs)(At,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:g()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Se()}),(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)(jt,{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=D(j.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),o=M(j.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=M(j.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=M(j.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),l=M(j.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),u=M(j.agents.removeInstanceAgent),f=Dt(),p=J();async function h(t,n){if(e)try{await o({instanceName:e,agentId:t,enabled:n})}catch(e){p.error(A(),e)}}async function g(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){p.error(A(),e)}}async function _(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await c({instanceName:e,agentId:t,types:i})}catch(e){p.error(A(),e)}}async function v(t,n){if(e&&await f({title:re({name:n}),description:S(),confirmLabel:m(),destructive:!0}))try{await u({instanceName:e,agentId:t}),p.success(ue())}catch(e){p.error(A(),e)}}return(0,Z.jsx)(Nt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(V,{className:`oc-access`,children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(U,{children:r({name:e??``})}),(0,Z.jsx)(H,{children:fe()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:se()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?ae():i.discovery.lastPollOk?qe():a({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)(jt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void h(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)(B,{variant:`outline`,className:`oc-access__gone`,children:d()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,a),children:me()})]}):r?(0,Z.jsx)(B,{variant:`default`,children:ce()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void g(t.agentId),children:Ct()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void _(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await l({instanceName:e,agentId:t.agentId,description:n})}catch(e){p.error(A(),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)(W,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ee(),"aria-label":te(),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{c as e,i as t,r as n}from"./bundle-mjs-BJq7W7j9.js";import{$b as r,$x as i,Ab as a,At as o,Ax as s,Bb as c,Bx as l,Cx as u,Db as d,Dx as f,Ex as p,Fb as m,Fx as h,Gb as g,Gi as _,Gx as v,Hb as y,Hx as b,ID as x,Ib as S,Ix as ee,Jb as te,Jx as ne,Kb as C,Ki as w,Kx as T,LD as E,Lb as re,Lx as ie,MM as D,Mb as ae,Mt as oe,Mx as O,Nb as se,Nx as k,Ob as ce,Ox as le,Pb as ue,Px as de,Qb as fe,Qx as pe,Rb as me,Rx as he,Sx as ge,Tx as _e,Ub as ve,Ux as ye,Vb as be,Vx as xe,Wb as Se,Wi as Ce,Wx as we,Xx as Te,Yb as Ee,Yx as De,Zb as A,Zx as Oe,_x as ke,aS as Ae,ax as je,bx as Me,c as j,cS as Ne,cx as Pe,dS as Fe,dx as Ie,eS as Le,ex as Re,fS as ze,fx as Be,gS as Ve,gx as He,hS as Ue,hx as We,iS as Ge,ix as Ke,jM as M,jb as qe,jt as Je,jx as Ye,kM as N,kb as Xe,kx as Ze,lS as Qe,lx as $e,mS as et,mx as tt,nS as P,nx as F,oS as nt,ox as rt,pS as it,px as at,qb as ot,qi as st,qx as ct,rS as lt,rx as ut,sS as dt,sx as ft,tS as pt,tx as mt,uS as ht,ux as gt,vg as _t,vx as vt,wx as yt,xx as bt,yg as xt,yx as St,zb as Ct,zx as wt}from"./dist-Bh78J5oj.js";import{a as Tt,c as Et}from"./FieldLabel-B-ZBXJZE.js";import{t as I}from"./button-BWtKy7q6.js";import{B as Dt,C as L,Q as Ot,S as R,X as kt,Z as At,b as z,ct as B,dt as V,ft as H,ht as U,lt as W,mt as G,p as jt,u as Mt,ut as Nt,w as K,x as q,z as J}from"./index-BoGVkzmD.js";import{t as Pt}from"./DataTableShell-DTw-rOw3.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-DSY7hdDk.js";var Y=e(t(),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:Tt},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=D(j.admin.listInstances,{}),t=D(j.agents.listAllInstanceAgents,{}),n=M(j.admin.upsertInstance),r=M(j.admin.deleteInstance),a=J(),[s,c]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(Q),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(null);async function S(){try{await n({instanceId:y??void 0,name:u.name,gatewayUrl:u.gatewayUrl,bridgeUrl:u.bridgeUrl||void 0,displayName:u.displayName||void 0,kind:u.kind,transport:u.kind===`hermes`?u.transport:void 0,gatewayVersion:u.gatewayVersion||void 0,gatewayHttpUrl:u.gatewayHttpUrl||void 0,streamTransport:u.streamTransport}),d(Q),x(null),c(!1)}catch(e){a.error(et(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[it(),(0,Z.jsx)(`strong`,{children:ze()}),Fe()]}),(0,Z.jsx)(Pt,{title:ht(),rows:e,addLabel:Qe(),onAdd:()=>{x(null),d(Q),c(!0)},emptyHint:Ne(),columns:[{header:dt(),cell:e=>e.name,sort:e=>e.name},{header:nt(),cell:e=>(0,Z.jsx)(B,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Ae(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Ge(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:Ve(),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)(B,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?ce():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Le(),onSelect:()=>{x(e._id),d(Bt(e)),c(!0)}},{label:Ue(),onSelect:()=>p(e.name)},{label:wt(),onSelect:()=>_(e)},{label:lt(),onSelect:()=>h(e)},{label:P(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:P(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(Mt,{open:s,onOpenChange:c,title:y?i():pt(),description:Oe(),canSubmit:!!(u.name&&u.gatewayUrl),onSubmit:S,submitLabel:Te(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:De(),children:[(0,Z.jsx)(W,{value:u.name,disabled:y!==null,onChange:e=>d({...u,name:e.target.value})}),y?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:pe()}):null]}),(0,Z.jsx)($,{label:ne(),children:(0,Z.jsxs)(z,{value:u.kind,onValueChange:e=>d({...u,kind:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(R,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(R,{value:`hermes`,children:`Hermes`})]})]})}),u.kind===`hermes`?(0,Z.jsx)($,{label:oe(),children:(0,Z.jsxs)(z,{value:u.transport,onValueChange:e=>d({...u,transport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(R,{value:`ws`,children:Je()}),(0,Z.jsx)(R,{value:`rest`,children:o()})]})]})}):null,(0,Z.jsx)($,{label:ct(),children:(0,Z.jsx)(W,{value:u.gatewayUrl,onChange:e=>d({...u,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:T(),children:(0,Z.jsx)(W,{value:u.bridgeUrl,placeholder:v(),onChange:e=>d({...u,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:we(),children:(0,Z.jsx)(W,{value:u.displayName,onChange:e=>d({...u,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:xt(),children:[(0,Z.jsxs)(z,{value:u.streamTransport,onValueChange:e=>d({...u,streamTransport:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsx)(q,{children:Et.map(e=>(0,Z.jsx)(R,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_t()})]}),(0,Z.jsx)($,{label:ye(),children:(0,Z.jsx)(W,{value:u.gatewayVersion,placeholder:b(),onChange:e=>d({...u,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:xe(),children:(0,Z.jsx)(W,{value:u.gatewayHttpUrl,placeholder:l(),onChange:e=>d({...u,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:f,open:f!==null,onOpenChange:e=>{e||p(null)}}),m?(0,Z.jsx)(Ft,{instance:m,onClose:()=>h(null)},m._id):null,g?(0,Z.jsx)(Ht,{instance:g,onClose:()=>_(null)},g._id):null]})}function Ht({instance:e,onClose:t}){let n=D(j.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)(Nt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(V,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(U,{children:he({instance:e.displayName??e.name})}),(0,Z.jsx)(H,{children:ie()})]}),(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=N(j.instanceSync.forceInstanceSync),n=J(),[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(ke());break;case`no_agents`:n.success(We());break;case`no_bridge_url`:n.error(tt());break;case`deploy_misconfigured`:n.error(at());break;case`unauthorized`:n.error(Ie());break;case`not_served`:n.error(gt());break;default:n.error(Be());break}}catch(e){n.error(He(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:$e()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?vt():St()})})]})}function Wt({instance:e}){let t=D(j.bridgeAuth.listBridgeAuthStatus,{}),n=N(j.bridgeAuth.mintBridgeSecret),r=M(j.bridgeAuth.revokeBridgeSecret),i=J(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(F(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(ut())}catch(e){i.error(F(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Pe(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ft()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{variant:f?`outline`:`secondary`,children:f?`${k()} · ${d.prefix}…${d.lastFour}`:O()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?je():rt()}),f?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:Ke()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:mt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?E():x()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:Re()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=N(j.instanceSecrets.setInstanceSecret),i=M(j.instanceSecrets.clearInstanceSecret),a=N(j.deviceIdentity.generateDeviceIdentity),o=J(),[c,l]=(0,Y.useState)(``),[d,m]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),b=n!==null,S=t===`deviceIdentity`,te=t===`token`?ee():t===`deviceIdentity`?h():de();async function ne(){if(!(!c.trim()||d)){m(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),_(null),y(!1),o.success(f())}catch(e){o.error(p(),e)}finally{m(!1)}}}async function C(){if(!d){m(!0);try{await i({instanceId:e,field:t}),_(null),y(!1),o.success(_e())}catch(e){o.error(p(),e)}finally{m(!1)}}}async function w(){if(!d){m(!0);try{_(await a({instanceId:e})),y(!1),o.success(ge())}catch(e){o.error(Me(),e)}finally{m(!1)}}}let T=g?`openclaw devices approve ${g.id}`:``;async function re(){if(T)try{await navigator.clipboard.writeText(T),y(!0)}catch{}}return(0,Z.jsxs)($,{label:te,children:[S?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{variant:b?`outline`:`secondary`,children:b?k():O()}),(0,Z.jsx)(W,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:b?s():Ye(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void ne(),disabled:d||c.trim().length===0,children:Ze()}),S?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void w(),disabled:d,children:yt()}):null,b?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void C(),disabled:d,children:le()}):null]})]}),g?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:ge()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:bt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void re(),children:v?E():x()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{_(null),y(!1)},children:Re()})]}):null]})}var Kt={conversational:ve,documentary:be,summarizer:st,curator:_},qt={conversational:y,documentary:c,summarizer:w,curator:Ce},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)(B,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(kt,{children:[(0,Z.jsx)(Ot,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:C()})}),(0,Z.jsxs)(At,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:g()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Se()}),(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)(jt,{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=D(j.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),o=M(j.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=M(j.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=M(j.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),l=M(j.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(j.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(j.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),u=M(j.agents.removeInstanceAgent),f=Dt(),p=J();async function h(t,n){if(e)try{await o({instanceName:e,agentId:t,enabled:n})}catch(e){p.error(A(),e)}}async function g(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){p.error(A(),e)}}async function _(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await c({instanceName:e,agentId:t,types:i})}catch(e){p.error(A(),e)}}async function v(t,n){if(e&&await f({title:re({name:n}),description:S(),confirmLabel:m(),destructive:!0}))try{await u({instanceName:e,agentId:t}),p.success(ue())}catch(e){p.error(A(),e)}}return(0,Z.jsx)(Nt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(V,{className:`oc-access`,children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(U,{children:r({name:e??``})}),(0,Z.jsx)(H,{children:fe()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:se()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?ae():i.discovery.lastPollOk?qe():a({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)(jt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void h(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)(B,{variant:`outline`,className:`oc-access__gone`,children:d()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,a),children:me()})]}):r?(0,Z.jsx)(B,{variant:`default`,children:ce()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void g(t.agentId),children:Ct()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void _(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await l({instanceName:e,agentId:t.agentId,description:n})}catch(e){p.error(A(),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)(W,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ee(),"aria-label":te(),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};
|