@lacneu/atrium 0.68.0 → 0.68.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccessTab-BFZrGfSt.js → AccessTab-CoRmmFpP.js} +1 -1
- package/dist/assets/{AdvancedFilter-D3IHsSgI.js → AdvancedFilter-DqWG63qF.js} +1 -1
- package/dist/assets/{AgentFilesTab-CHMpYoZN.js → AgentFilesTab-BnwVjBen.js} +1 -1
- package/dist/assets/{AnomaliesTab-Bna7O7DK.js → AnomaliesTab-D0_DaVUT.js} +1 -1
- package/dist/assets/{AuditTab-BQO2KxIW.js → AuditTab-CiMRA2UB.js} +1 -1
- package/dist/assets/{BridgeTab-DCHBE54n.js → BridgeTab-BhAxJtIU.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-B49bnKco.js → ChatDefaultsTab-BRGSYbx2.js} +1 -1
- package/dist/assets/{DataTableShell-BYhMdaSl.js → DataTableShell-D5Nb8D27.js} +1 -1
- package/dist/assets/{DetailChips-BT8QU7Op.js → DetailChips-BpplTXuL.js} +1 -1
- package/dist/assets/{FeedbacksTab-B3aYpOIP.js → FeedbacksTab-6b-IOyv1.js} +1 -1
- package/dist/assets/{FieldLabel-2xG6-0gZ.js → FieldLabel-D_--lTMz.js} +1 -1
- package/dist/assets/{FilesTab-_09UVEP4.js → FilesTab-D5X6EpvN.js} +1 -1
- package/dist/assets/{FilterBar-Bxpfu6Cp.js → FilterBar-3xmqkmtO.js} +1 -1
- package/dist/assets/{GroupsTab-lX4rp_r8.js → GroupsTab-VRfFxe4t.js} +1 -1
- package/dist/assets/{InstancesTab-Bg4DV0Mg.js → InstancesTab-6WQvX86-.js} +1 -1
- package/dist/assets/{IntegrationsTab-eVcH8e5g.js → IntegrationsTab-cja9iSZK.js} +1 -1
- package/dist/assets/{KpiTab-BxeRQXix.js → KpiTab-DyotMcdO.js} +1 -1
- package/dist/assets/{PreferencesTab-DZSU4xP1.js → PreferencesTab-xvCftb-6.js} +1 -1
- package/dist/assets/{ProjectPage-vg8X5OT3.js → ProjectPage-B4CPwcaH.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-88NlW26U.js → PromptInjectionsTab-DEzP8Oti.js} +1 -1
- package/dist/assets/{RolesTab-BZFTJhyf.js → RolesTab-CZfNwFFx.js} +1 -1
- package/dist/assets/{ScheduledTab-DGRbUQ47.js → ScheduledTab-D6x6Mo89.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-pE8F7p-2.js → ServiceAccountsTab-S3OIL2wM.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-BTQehyRQ.js → SubAgentReportsTab-r5dkHWGD.js} +1 -1
- package/dist/assets/{ThemeShowroom-HrqPxKuI.js → ThemeShowroom-ClnOnpAv.js} +1 -1
- package/dist/assets/{TimeRangePicker-DBPA3ISK.js → TimeRangePicker-B3yMy8oz.js} +1 -1
- package/dist/assets/{TimezoneCombobox-Cf0dO1lp.js → TimezoneCombobox-DjUiyEWp.js} +1 -1
- package/dist/assets/{TracesTab-DpeDrf2G.js → TracesTab-CyUsgwvb.js} +1 -1
- package/dist/assets/{UsersTab-txTMEiI9.js → UsersTab-DlotCuaa.js} +1 -1
- package/dist/assets/{VoiceTab-CnjBb1Ea.js → VoiceTab-BaqvZlgH.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-D8RSF8so.js → highlighted-body-OFNGDK62-B8wQuJm_.js} +1 -1
- package/dist/assets/{index-CsdodIca.js → index-DdOFgMFG.js} +76 -76
- package/dist/assets/mermaid-GHXKKRXX-CE8gBGLh.js +1 -0
- package/dist/assets/{pdf-D65rOI23.js → pdf-BNLKKdqq.js} +1 -1
- package/dist/assets/{tabs-lFf0wQh0.js → tabs-D8fO33rb.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/mermaid-GHXKKRXX-CHdRR4I9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AL as r,Bf as i,Ff as a,Gf as o,Hf as s,If as c,Kf as l,Lf as u,Mf as d,Nf as f,Pf as p,Rf as m,Uf as h,Vf as g,Wf as _,t as v,zL as y,zf as b}from"./api-EsnGI4EC.js";import{_t as x,bt as S,ut as C,vt as w,xt as T,yt as E}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AL as r,Bf as i,Ff as a,Gf as o,Hf as s,If as c,Kf as l,Lf as u,Mf as d,Nf as f,Pf as p,Rf as m,Uf as h,Vf as g,Wf as _,t as v,zL as y,zf as b}from"./api-EsnGI4EC.js";import{_t as x,bt as S,ut as C,vt as w,xt as T,yt as E}from"./index-DdOFgMFG.js";var D=t(e(),1);function O(e){return e===`user`?c():e===`all`?a():p({group:e.group})}function k(e){return e===`common`?f():e===`owner`?d():p({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=y(v.admin.listUsers,{}),[t,n]=(0,D.useState)(``),a=y(v.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:l()}),(0,A.jsxs)(x,{value:t,onValueChange:n,children:[(0,A.jsx)(S,{size:`sm`,"aria-label":o(),children:(0,A.jsx)(T,{placeholder:o()})}),(0,A.jsx)(w,{children:(e??[]).map(e=>(0,A.jsx)(E,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):a===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(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:a.user.label}),(0,A.jsx)(C,{variant:`secondary`,children:a.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:s()}),a.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:a.groups.map(e=>(0,A.jsx)(C,{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:g()}),a.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:a.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)(C,{variant:`default`,children:u()}):null,(0,A.jsx)(C,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(C,{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:i()}),a.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:a.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)(C,{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:b()}),a.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:a.permissions.map(e=>(0,A.jsx)(C,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,ah as i,eh as a,ih as o,nh as s,rh as c,th as l}from"./api-EsnGI4EC.js";import{r as u}from"./dist-BM94bqpE.js";import{t as d}from"./x-DOcdk27K.js";import{t as f}from"./button-CZ9WPf0m.js";import{_t as p,bt as m,jt as h,ln as g,vt as _,xt as v,yt as y}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,ah as i,eh as a,ih as o,nh as s,rh as c,th as l}from"./api-EsnGI4EC.js";import{r as u}from"./dist-BM94bqpE.js";import{t as d}from"./x-DOcdk27K.js";import{t as f}from"./button-CZ9WPf0m.js";import{_t as p,bt as m,jt as h,ln as g,vt as _,xt as v,yt as y}from"./index-DdOFgMFG.js";import{r as b}from"./TimeRangePicker-B3yMy8oz.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:i()},{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 i=(0,x.useRef)(t),w=!!(i.current&&i.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(i.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}),o(),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:c()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(p,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(m,{size:`sm`,className:`w-40`,children:(0,S.jsx)(v,{placeholder:s()})}),(0,S.jsx)(_,{children:e.map(e=>(0,S.jsx)(y,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(p,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(m,{size:`sm`,className:`w-28`,children:(0,S.jsx)(v,{})}),(0,S.jsx)(_,{children:C.map(e=>(0,S.jsx)(y,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(h,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:l()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":a(),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)(g,{}),r()]})]}):null]})}export{D as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$l as r,AL as i,Bi as a,Ca as o,Cu as s,Du as c,Ea as l,Eu as u,Hi as d,IL as f,ML as p,Ql as m,RL as h,Ri as g,Sa as _,Su as v,Ta as y,Tu as b,Ui as x,Vi as S,Wi as C,Yk as w,_a as T,_u as E,au as D,ba as O,bu as k,ca as A,cd as ee,cu as te,da as j,du as M,eu as N,fa as P,fu as F,ga as I,gu as ne,ha as L,hu as re,iu as ie,la as ae,lu as R,ma as z,mu as B,nu as oe,oa as V,ou as H,pa as se,pu as ce,ru as le,sa as ue,su as de,t as U,tu as fe,ua as pe,ud as W,uu as me,va as he,vu as ge,wa as _e,wu as ve,xa as G,xu as ye,ya as be,yu as xe,zL as K,zi as Se}from"./api-EsnGI4EC.js";import{t as q}from"./button-CZ9WPf0m.js";import{$ as Ce,Dt as J,V as we,_t as Te,at as Ee,bt as De,dt as Oe,et as ke,ft as Ae,gt as je,ht as Me,it as Ne,nt as Pe,ot as Fe,pt as Ie,rn as Le,rt as Re,tt as ze,ut as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$l as r,AL as i,Bi as a,Ca as o,Cu as s,Du as c,Ea as l,Eu as u,Hi as d,IL as f,ML as p,Ql as m,RL as h,Ri as g,Sa as _,Su as v,Ta as y,Tu as b,Ui as x,Vi as S,Wi as C,Yk as w,_a as T,_u as E,au as D,ba as O,bu as k,ca as A,cd as ee,cu as te,da as j,du as M,eu as N,fa as P,fu as F,ga as I,gu as ne,ha as L,hu as re,iu as ie,la as ae,lu as R,ma as z,mu as B,nu as oe,oa as V,ou as H,pa as se,pu as ce,ru as le,sa as ue,su as de,t as U,tu as fe,ua as pe,ud as W,uu as me,va as he,vu as ge,wa as _e,wu as ve,xa as G,xu as ye,ya as be,yu as xe,zL as K,zi as Se}from"./api-EsnGI4EC.js";import{t as q}from"./button-CZ9WPf0m.js";import{$ as Ce,Dt as J,V as we,_t as Te,at as Ee,bt as De,dt as Oe,et as ke,ft as Ae,gt as je,ht as Me,it as Ne,nt as Pe,ot as Fe,pt as Ie,rn as Le,rt as Re,tt as ze,ut as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-DdOFgMFG.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-BNLmViDl.js";/* empty css */var Y=t(e(),1),X=2e4,Je=6e4;function Ye(e){return typeof e!=`number`||e<=0?0:Math.round(e/X*100)}function Xe(e){return e<=0?0:Math.round(e/Je*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Ze(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var Qe=3;function $e(e,t){let n=new Map;for(let t of e.split(`
|
|
2
2
|
`))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
|
|
3
3
|
`))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<Qe&&a.push(e)):t>0&&(i+=t,o.length<Qe&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function et(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function tt(){let e=K(U.me.getMe,{host:He}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=K(U.admin.listInstances,e!==void 0&&t?{}:`skip`),[a,l]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!t||!r||r.length===0||(!a||!r.some(e=>e.name===a))&&l(r[0].name)},[t,r,a]);let d=K(U.agents.listAgentsForInstance,t&&a?{instanceName:a}:`skip`),m=K(U.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),h=(0,Y.useMemo)(()=>{if(e!==void 0){if(t)return a===null||d===void 0?r!==void 0&&r.length===0?[]:void 0:d.agents.map(e=>({instanceName:a,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(m!==void 0)return m.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,a,d,r,m]),[g,y]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!h||h.length===0||(!g||!h.some(e=>$(e)===g))&&y($(h[0]))},[h,g]);let x=h?.find(e=>$(e)===g)??null,S=f(U.agentFiles.listAgentFiles),[C,w]=(0,Y.useState)({status:`idle`}),T=x?.instanceName??null,D=x?.agentId??null,O=K(U.compat.forInstance,n&&T!==null?{instanceName:T}:`skip`),A=n&&T!==null?we(O,`agentFiles`):null,te=A===null?!1:A===`loading`?null:A.blocked,j=(0,Y.useCallback)(async()=>{if(!(T===null||D===null)){w({status:`loading`});try{w({status:`done`,files:(await S({instanceName:T,agentId:D})).files})}catch{w({status:`error`})}}},[S,T,D]);(0,Y.useEffect)(()=>{te===!1&&j()},[j,te]);let[M,N]=(0,Y.useState)(null),P=K(U.agentFileCuration.listCurations,t&&T!==null&&D!==null?{instanceName:T,agentId:D}:`skip`),F=K(U.agentFileCuration.curationSettings,t&&T!==null?{instanceName:T}:`skip`),I=f(U.agentFileCuration.requestCuration),[L,ie]=(0,Y.useState)(null),[ae,R]=(0,Y.useState)(null),{toast:z}=J(),B=(0,Y.useMemo)(()=>{let e=new Map;for(let t of P??[])e.has(t.name)||e.set(t.name,t);return e},[P]),oe=(0,Y.useCallback)(async e=>{if(!(T===null||D===null)){ie(e);try{let t=await I({instanceName:T,agentId:D,name:e,trigger:`manual`});t.ok?z({title:o(),variant:`success`}):z({title:_({reason:t.reason??`unknown`}),variant:`error`})}catch{z({title:G(),variant:`error`})}finally{ie(null)}}},[I,T,D,z]),V=p(),H=(0,Y.useMemo)(()=>new Intl.NumberFormat(V,{maximumFractionDigits:0}),[V]);return e===void 0||h===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:c()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(Te,{value:a??``,onValueChange:e=>l(e),children:[(0,Q.jsx)(De,{size:`sm`,"aria-label":u(),children:(0,Q.jsx)(Ue,{})}),(0,Q.jsx)(Ve,{children:(r??[]).map(e=>(0,Q.jsx)(We,{value:e.name,children:e.name},e.name))})]}):null,h.length>0?(0,Q.jsxs)(Te,{value:g??``,onValueChange:e=>y(e),children:[(0,Q.jsx)(De,{size:`sm`,"aria-label":b(),children:(0,Q.jsx)(Ue,{})}),(0,Q.jsx)(Ve,{children:h.map(e=>(0,Q.jsx)(We,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ve()})]}),x===null?null:A===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):A!==null&&A.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Le,{size:14,"aria-hidden":!0}),` `,qe(A.gatewayVersion,A.provider)]}):C.status===`loading`||C.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):C.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[v(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void j(),children:ee()})]}):C.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:C.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)(Be,{variant:`outline`,children:ye()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:k({size:Z(e.size,V)})}),(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:xe({pct:H.format(n)})}),r?(0,Q.jsx)(Le,{size:14,className:`oc-afiles__warn`,"aria-label":ge()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>N(e),children:t?ne():re()}),t&&!e.missing?(0,Q.jsx)(nt,{curatable:Ke.includes(e.name),size:e.size??0,budget:F?.budgetChars??null,enabled:F?.enabled??!1,curation:B.get(e.name)??null,inFlight:L===e.name,onCurate:()=>void oe(e.name),onReview:e=>R(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:E({used:Z(Ze(C.files),V),total:Z(Je,V),pct:H.format(Xe(Ze(C.files)))})})]}),M&&x?(0,Q.jsx)(rt,{instanceName:x.instanceName,agentId:x.agentId,name:M.name,isAdmin:t,onClose:()=>N(null),onSaved:()=>void j()}):null,ae?(0,Q.jsx)(it,{curationId:ae,onClose:()=>R(null),onApplied:()=>{R(null),j()}}):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)(q,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:y()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Be,{variant:`outline`,className:`oc-afiles__curate-status`,children:_e()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:l()}):null}function rt({instanceName:e,agentId:t,name:n,isAdmin:a,onClose:o,onSaved:s}){let c=f(U.agentFiles.getAgentFile),l=f(U.agentFiles.setAgentFile),u=J(),[d,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),A=(0,Y.useCallback)(async r=>{_(!1);try{let i=await c({instanceName:e,agentId:t,name:n});h({content:i.content,updatedAtMs:i.updatedAtMs}),r||y(i.content),E(!1)}catch{_(!0)}},[c,e,t,n]);(0,Y.useEffect)(()=>{A(!1)},[A]);async function j(){if(d!==null){C(!0),k(!1);try{await l({instanceName:e,agentId:t,name:n,content:v,baseUpdatedAtMs:d.updatedAtMs??void 0}),u.success(te({name:n})),s(),await A(!1)}catch(e){et(e)?E(!0):k(!0)}finally{C(!1)}}}let P=d!==null&&v!==d.content,I=(0,Y.useMemo)(()=>d===null?null:$e(d.content,v),[d,v]),ne=v.length>X,L=p(),re=(0,Y.useMemo)(()=>new Intl.NumberFormat(L),[L]);return(0,Q.jsx)(Oe,{open:!0,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(Ae,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(je,{children:B({name:n})}),(0,Q.jsxs)(Ie,{children:[ce({agent:t,instance:e}),a?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,F()]})]})]}),g?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[H(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void A(!1),children:ee()})]}):d===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:v,readOnly:!a,spellCheck:!1,onChange:e=>y(e.target.value),"aria-label":B({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:M()}),T?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[D(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void A(!0),children:ie()})]}):null,O?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:de()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${ne?` is-over`:``}`,children:me({count:re.format(v.length),max:re.format(X)})}),a?(0,Q.jsx)(q,{size:`sm`,disabled:!P||S||T,onClick:()=>x(!0),children:S?W():R()}):null]})]}),(0,Q.jsx)(Ce,{open:b,onOpenChange:x,children:(0,Q.jsxs)(Pe,{children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(Fe,{children:le({name:n})}),(0,Q.jsx)(Re,{children:oe({agent:t})})]}),I?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:fe({added:I.added,removed:I.removed})}),I.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:N()}),I.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,I.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:r()}),I.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(ze,{children:w()}),(0,Q.jsx)(ke,{onClick:()=>void j(),children:m()})]})]})})]})})}function it({curationId:e,onClose:t,onApplied:n}){let r=K(U.agentFileCuration.getProposal,{curationId:e}),o=f(U.agentFileCuration.approveCuration),s=h(U.agentFileCuration.rejectCuration),{toast:c}=J(),[l,u]=(0,Y.useState)(null),[m,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),b=p(),w=(0,Y.useMemo)(()=>r?$e(r.beforeContent,r.proposedContent):null,[r]);async function E(){u(`approve`);try{let t=await o({curationId:e});t.ok?(c({title:O(),variant:`success`}),n()):c({title:t.reason===`conflict`?he():T({reason:t.reason??`unknown`}),variant:`error`})}catch{c({title:G(),variant:`error`})}finally{u(null)}}async function D(n){u(`reject`);try{let r=v.trim();(await s({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?c({title:n?Se():be(),variant:`success`}):c({title:z(),variant:`error`}),t()}catch{c({title:G(),variant:`error`})}finally{u(null)}}return(0,Q.jsx)(Oe,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Ae,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(je,{children:r?I({name:r.name}):i()}),(0,Q.jsx)(Ie,{children:L()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:z()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[se({before:Z(r.beforeSize,b),after:Z(r.proposedSize,b)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Le,{size:13,"aria-hidden":!0}),` `,P()]}):null]}),w?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:j({added:w.added,removed:w.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:g({feedback:r.feedback})}):null,w&&w.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:V()}),(0,Q.jsx)(`ul`,{children:w.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:ue()}),(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:pe()}),(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:C()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:x(),value:v,onChange:e=>y(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`ghost`,onClick:()=>_(!1),disabled:l!==null,children:d()}),(0,Q.jsx)(q,{variant:`outline`,onClick:()=>void D(!1),disabled:l!==null,children:l===`reject`?W():S()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void D(!0),disabled:l!==null,children:l===`reject`?W():a()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>_(!0),disabled:l!==null||r==null,children:ae()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void E(),disabled:l!==null||r==null,children:l===`approve`?W():A()})]})]})})}export{tt as AgentFilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$x as r,Bx as i,CS as a,Fx as o,Gx as s,Hx as c,Ix as l,Jx as ee,Kx as u,Lx as d,Mx as f,Nx as p,Px as m,Qx as te,RL as h,Rx as g,SS as _,Ux as ne,Vx as re,Wx as ie,Xx as ae,Yx as oe,Zx as v,_S as se,aS as ce,bS as le,cS as y,dS as b,eS as ue,fS as de,gS as fe,hS as pe,iS as me,lS as he,mS as ge,nS as _e,oS as ve,pS as ye,qx as x,rS as S,sS as C,t as w,tS as T,uS as E,vS as D,wS as O,xS as k,yS as A,zL as j,zx as M}from"./api-EsnGI4EC.js";import{Dt as N,Fn as P,Pn as F,Z as be,_t as I,bt as L,ct as xe,dt as R,ft as z,gt as B,ht as V,i as Se,o as Ce,ut as H,vt as U,wt as we,xt as W,yt as G}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$x as r,Bx as i,CS as a,Fx as o,Gx as s,Hx as c,Ix as l,Jx as ee,Kx as u,Lx as d,Mx as f,Nx as p,Px as m,Qx as te,RL as h,Rx as g,SS as _,Ux as ne,Vx as re,Wx as ie,Xx as ae,Yx as oe,Zx as v,_S as se,aS as ce,bS as le,cS as y,dS as b,eS as ue,fS as de,gS as fe,hS as pe,iS as me,lS as he,mS as ge,nS as _e,oS as ve,pS as ye,qx as x,rS as S,sS as C,t as w,tS as T,uS as E,vS as D,wS as O,xS as k,yS as A,zL as j,zx as M}from"./api-EsnGI4EC.js";import{Dt as N,Fn as P,Pn as F,Z as be,_t as I,bt as L,ct as xe,dt as R,ft as z,gt as B,ht as V,i as Se,o as Ce,ut as H,vt as U,wt as we,xt as W,yt as G}from"./index-DdOFgMFG.js";import{n as Te}from"./TimeRangePicker-B3yMy8oz.js";import{t as Ee}from"./FilterBar-3xmqkmtO.js";import{t as De}from"./DataTableShell-D5Nb8D27.js";import{t as K}from"./dispatchErrorInfo-GCb0ITYo.js";var q=t(e(),1),J=n(),Y=`__all__`,Oe=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function ke(e){return e===`open`?O():e===`acknowledged`?a():_()}var Ae=[`info`,`warn`,`critical`],je=[`detector`,`agent`,`user`],Me={kind:`relative`,from:`now-30d`,to:`now`},Ne=200,X=`all`;function Z(){let e=P({from:`/settings/anomalies`}),t=F({from:`/settings/anomalies`}),n=e.q??``,a=e.status===X?Y:e.status,o=e.severity??Y,l=e.kind??Y,[d,f]=(0,q.useState)(Y),p=Se(e.from,e.to),{from:m,to:g}=Te(p),_=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),O=e=>void t({search:t=>({...t,status:e===Y?X:e})}),M=e=>void t({search:t=>({...t,severity:e===Y?void 0:e})}),R=e=>void t({search:t=>({...t,kind:e===Y?void 0:e})}),z=e=>void t({search:t=>({...t,...Ce(e)})}),B=be(),V=N(),K=h(w.anomalies.resolveAnomaly),Z=(j(w.me.getMe,{host:we})?.permissions??[]).includes(`admin.manage`),Q=j(w.anomalies.listAnomalies,{limit:Ne,filter:{q:n||void 0,from:m,to:g,anomalyStatus:a===Y?void 0:a,severity:o===Y?void 0:o,source:d===Y?void 0:d,kind:l===Y?void 0:l}}),$=(0,q.useMemo)(()=>{let e=new Set;for(let t of Q??[])e.add(t.kind);return[...e].sort()},[Q]),ze=n!==``||a!==`open`||o!==Y||d!==Y||l!==Y||p.kind!==`relative`||p.from!==Me.from;function Be(){f(Y),t({search:{status:`open`},replace:!0})}async function Ve(e){if(await B({title:k(),description:(0,J.jsxs)(J.Fragment,{children:[le(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,A(),` `,(0,J.jsx)(`strong`,{children:D()}),`.`,` `,se()]}),confirmLabel:fe()}))try{await K({anomalyId:e._id,status:`resolved`}),V.success(pe(),e.kind)}catch(e){V.error(ge(),e)}}async function He(e){try{await K({anomalyId:e._id,status:`acknowledged`}),V.success(ye(),e.kind)}catch(e){V.error(de(),e)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-admin__hint`,children:[b(),` `,(0,J.jsx)(`strong`,{children:E()}),` `,he(),` `,(0,J.jsx)(`strong`,{children:y()}),` `,C(),` `,(0,J.jsx)(`strong`,{children:ve()}),` `,ce(),` `,(0,J.jsx)(`span`,{className:`oc-filter__window`,children:me()})]}),(0,J.jsxs)(Ee,{q:n,onQChange:_,searchPlaceholder:S(),timeRange:p,onTimeRangeChange:z,onReset:Be,canReset:ze,children:[(0,J.jsxs)(I,{value:a,onValueChange:O,children:[(0,J.jsx)(L,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(G,{value:Y,children:_e()}),Oe.map(e=>(0,J.jsx)(G,{value:e.value,children:ke(e.value)},e.value))]})]}),(0,J.jsxs)(I,{value:o,onValueChange:M,children:[(0,J.jsx)(L,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{placeholder:T()})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(G,{value:Y,children:ue()}),Ae.map(e=>(0,J.jsx)(G,{value:e,children:e},e))]})]}),(0,J.jsxs)(I,{value:d,onValueChange:f,children:[(0,J.jsx)(L,{size:`sm`,className:`w-32`,children:(0,J.jsx)(W,{placeholder:r()})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(G,{value:Y,children:te()}),je.map(e=>(0,J.jsx)(G,{value:e,children:e},e))]})]}),(0,J.jsxs)(I,{value:l,onValueChange:R,children:[(0,J.jsx)(L,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{placeholder:v()})}),(0,J.jsxs)(U,{children:[(0,J.jsx)(G,{value:Y,children:ae()}),$.map(e=>(0,J.jsx)(G,{value:e,children:e},e))]})]})]}),(0,J.jsx)(De,{title:oe(),rows:Q,emptyHint:a===`open`?ee():x(),rowActions:e=>Z&&e.status===`open`?[{label:u(),onSelect:()=>void Ve(e)},{label:s(),onSelect:()=>void He(e)}]:[],columns:[{header:ie(),cell:e=>(0,J.jsx)(`span`,{className:`oc-traces__time`,children:xe(e.at)}),sort:e=>e.at},{header:v(),cell:e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:T(),cell:e=>(0,J.jsx)(Ie,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:ne(),cell:e=>(0,J.jsx)(Le,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:r(),cell:e=>(0,J.jsx)(H,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:c(),cell:e=>(0,J.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,J.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,J.jsx)(Fe,{row:e})]}),sort:e=>e.message},{header:re(),cell:e=>(0,J.jsx)(Pe,{row:e}),sort:e=>e.evidence??null},{header:i(),cell:e=>e.correlationId?(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:Re(e.correlationId)}):(0,J.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function Q(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 $(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 Pe({row:e}){let t=F();if(e.kind===`subagent.failure`){let n=$(e);return(0,J.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,J.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,M()]}):null]})}let n=Q(e);if(!n.dominantCode)return(0,J.jsx)(`span`,{className:`oc-traces__muted`,children:`—`});let r=K(n.dominantCode),i=n.sampleCorrelationId;return(0,J.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,J.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,J.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,J.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:i,limit:100}}),children:[`↗ `,M()]}):null]})}function Fe({row:e}){let[t,n]=(0,q.useState)(!1),r=j(w.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[g(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,J.jsx)(R,{open:t,onOpenChange:n,children:(0,J.jsxs)(z,{className:`oc-anomaly__attachments-dialog`,children:[(0,J.jsx)(V,{children:(0,J.jsx)(B,{children:d()})}),r===void 0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:l()}):r.length===0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:o()}):(0,J.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,J.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,J.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,J.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Ie({severity:e}){return(0,J.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function Le({status:e}){return e===`open`?(0,J.jsx)(H,{variant:`destructive`,children:m()}):e===`acknowledged`?(0,J.jsx)(H,{variant:`secondary`,children:p()}):(0,J.jsx)(H,{variant:`outline`,children:f()})}function Re(e){return e.length>8?e.slice(0,8):e}export{Z as AnomaliesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Br as r,CC as i,DC as a,EC as o,Fr as s,Ir as c,Lr as l,OC as u,Rr as d,SC as f,TC as p,_C as m,bC as h,gC as g,hC as _,kC as v,t as y,vC as b,wC as x,xC as S,yC as C,zL as w,zr as T}from"./api-EsnGI4EC.js";import{Fn as E,Pn as D,_t as O,a as k,bt as A,ct as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Br as r,CC as i,DC as a,EC as o,Fr as s,Ir as c,Lr as l,OC as u,Rr as d,SC as f,TC as p,_C as m,bC as h,gC as g,hC as _,kC as v,t as y,vC as b,wC as x,xC as S,yC as C,zL as w,zr as T}from"./api-EsnGI4EC.js";import{Fn as E,Pn as D,_t as O,a as k,bt as A,ct as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-DdOFgMFG.js";import{n as ee}from"./TimeRangePicker-B3yMy8oz.js";import{t as z}from"./FilterBar-3xmqkmtO.js";import{t as B}from"./AdvancedFilter-DqWG63qF.js";import{t as V}from"./DataTableShell-D5Nb8D27.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:r()},{value:`realLabel`,label:T()},{value:`targetLabel`,label:d()},{value:`impersonated`,label:l()},{value:`resource`,label:c()},{value:`resourceId`,label:s()}];function q(){let e=E({from:`/settings/audit`}),t=D({from:`/settings/audit`}),n=e.q??``,r=e.action??G,s=e.impersonated??G,c=e.resource??G,l=M(e.from,e.to),d=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:T,to:N}=ee(l),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,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:k(e)}),replace:!0}),$=w(y.admin.listAudit,{filter:{q:n||void 0,from:T,to:N,action:r===G?void 0:r,resource:c===G?void 0:c,impersonated:s===G?void 0:s===`yes`,advanced:d.length>0?d:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||s!==G||c!==G||d.length>0||l.kind!==`relative`||l.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:[v(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:u()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:a(),timeRange:l,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(O,{value:r,onValueChange:J,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:o()})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:p()}),te.map(e=>(0,U.jsx)(R,{value:e,children:e},e))]})]}),(0,U.jsxs)(O,{value:s,onValueChange:Y,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:x()}),(0,U.jsx)(R,{value:`yes`,children:i()}),(0,U.jsx)(R,{value:`no`,children:f()})]})]}),(0,U.jsxs)(O,{value:c,onValueChange:X,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:S()})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:h()}),ne.map(e=>(0,U.jsx)(R,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:d,onChange:Q}),(0,U.jsx)(V,{title:C(),rows:$,emptyHint:b(),columns:[{header:m(),cell:e=>j(e.at),sort:e=>e.at},{header:o(),cell:e=>e.action,sort:e=>e.action},{header:g(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:_(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:S(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Al as r,Av as i,Ay as a,Bl as o,Bv as s,Cv as c,Cy as l,D as u,Dv as d,Dy as f,Ev as p,Ey as m,Fl as h,Fv as g,Gv as ee,Hv as te,IL as ne,Il as _,Iv as v,Jv as re,Kv as ie,Ll as y,Lv as b,Ml as ae,Mv as oe,My as se,Nl as ce,Nv as le,Ny as ue,Ov as de,Oy as fe,Pl as pe,Pv as me,RL as he,Rl as ge,Rv as _e,Sv as ve,Tl as ye,Tv as be,Ty as xe,Uv as Se,Vl as Ce,Vv as we,Wv as Te,Xv as Ee,Yv as De,Zv as Oe,_v as ke,ar as Ae,av as je,bv as Me,by as Ne,cv as Pe,dv as Fe,ev as Ie,fv as Le,gv as Re,hv as ze,ir as Be,iv as Ve,jl as He,jv as Ue,kl as We,kv as x,ky as Ge,lv as Ke,mv as S,nv as qe,or as Je,ov as Ye,pv as Xe,qv as Ze,rr as Qe,rv as $e,sr as et,sv as tt,t as C,tv as nt,ur as rt,uv as it,vv as at,wv as ot,wy as st,xv as ct,yv as lt,yy as ut,zL as w,zl as dt,zv as ft}from"./api-EsnGI4EC.js";import{r as T}from"./dist-BM94bqpE.js";import{t as pt}from"./chevron-up-DZeG4Ghe.js";import{t as mt}from"./chevrons-up-down-BQ8-VyUH.js";import{i as ht,n as E,o as gt,r as _t,s as vt}from"./FieldLabel-2xG6-0gZ.js";import{i as yt,n as bt,r as xt,t as St}from"./tabs-lFf0wQh0.js";import{t as Ct}from"./button-CZ9WPf0m.js";import{An as D,Bt as wt,Dt as Tt,Fn as Et,I as Dt,P as Ot,Pn as kt,Rt as At,_t as O,bn as jt,bt as k,ct as Mt,dt as Nt,ft as Pt,gt as Ft,ht as It,jn as Lt,jt as A,lt as j,on as M,pt as Rt,rn as N,ut as P,vt as F,wt as zt,xt as I,yt as L,zt as Bt}from"./index-CsdodIca.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as R,n as Ut,o as z,r as B,t as V}from"./table-B--HXOj1.js";import{t as Wt}from"./FilterBar-Bxpfu6Cp.js";import{a as H,n as Gt,o as U,r as Kt,s as qt,t as Jt}from"./compatView-BNLmViDl.js";import{t as W}from"./dispatchErrorInfo-GCb0ITYo.js";var Yt=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Xt=u(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function K(e){return e.filter(e=>e.state===`error`)}function Zt(e){return e.reachable&&K(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 U(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)=>U(e,t)??Z(e,t))}var Q=n();function pn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(rn),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>un(o),[o]),c=(0,G.useMemo)(()=>dn(o),[o]),l=(0,G.useMemo)(()=>fn(o),[o]),u=(0,G.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:at()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Wt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:ze(),onReset:()=>r(rn),canReset:an(n),children:[(0,Q.jsxs)(O,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(I,{placeholder:Xe()})}),(0,Q.jsxs)(F,{children:[(0,Q.jsx)(L,{value:Y,children:S()}),s.map(e=>(0,Q.jsx)(L,{value:e,children:hn(e)},e))]})]}),(0,Q.jsxs)(O,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(I,{placeholder:Le()})}),(0,Q.jsxs)(F,{children:[(0,Q.jsx)(L,{value:Y,children:S()}),c.map(e=>(0,Q.jsx)(L,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(O,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(I,{placeholder:Fe()})}),(0,Q.jsxs)(F,{children:[(0,Q.jsx)(L,{value:Y,children:S()}),l.map(e=>(0,Q.jsx)(L,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:it()}):(0,Q.jsxs)(V,{className:`oc-conn__table`,children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)($,{label:Ke(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Pe(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:tt(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ye(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:je(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(R,{children:Ve()}),(0,Q.jsx)($,{label:$e(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(Ut,{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)(R,{"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)(pt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(T,{size:13,"aria-hidden":!0}):(0,Q.jsx)(mt,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function mn({r:e}){let t=$t(e)?W(e.lastErrorCode):null,n=en(e)?W(e.lastDownstreamRejectCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(z,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(B,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(B,{children:(0,Q.jsx)(gn,{state:e.state})}),(0,Q.jsx)(B,{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)(B,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(B,{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)(B,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:ke({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(B,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:j(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Q.jsx)(z,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(B,{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?` · ${j(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:[Re({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${j(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function hn(e){return e===`connected`?qe():e===`error`?nt():Ie()}function gn({state:e}){return e===`connected`?(0,Q.jsx)(P,{variant:`secondary`,children:qe()}):e===`error`?(0,Q.jsx)(P,{variant:`destructive`,children:nt()}):(0,Q.jsx)(P,{variant:`outline`,children:Ie()})}function _n(){return w(C.bridgeHealth.getBridgeHealth,{})}function vn(){let e=_n(),t=w(C.compat.getBridgeCompat,{}),n=w(C.me.getMe,{host:zt})?.role===`admin`,r=w(C.admin.listInstances,n?{}:`skip`),i=w(C.agents.usageForInstances,n?{}:`skip`),a=kt(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=nn(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Et({from:`/settings/bridge`}),l=kt({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Gt(u,`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:b()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:v()}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)(R,{children:et()}),(0,Q.jsx)(R,{children:Je()}),(0,Q.jsx)(R,{children:Ae()}),(0,Q.jsx)(R,{children:Be()}),(0,Q.jsx)(R,{children:Qe()})]})}),(0,Q.jsx)(Ut,{children:i.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(z,{children:[(0,Q.jsx)(B,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(B,{children:t.provider}),(0,Q.jsx)(B,{children:t.label}),(0,Q.jsx)(B,{children:(0,Q.jsxs)(P,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(B,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(St,{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)(xt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(yt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(M,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(bt,{value:e.key,children:(0,Q.jsx)(bn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ye()}):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:H(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:dt(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,ge({build:t.buildVersion??`?`})]}):null,` · `,y(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?_():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:x()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:de()});let o=K(e.targets),s=!e.reachable,l=Qt(e),u=e.unreachableInstances??[],f=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,m=Mt(e.checkedAt),h=e.startedAt==null?null:Mt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${f}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Q.jsx)(D,{size:22}):s||l===`gateways_unreachable`?(0,Q.jsx)(Xt,{size:22}):(0,Q.jsx)(N,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?d():l===`gateways_unreachable`?c({count:u.length}):s?p():be({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Yt,{size:12,"aria-hidden":!0}),` `,ot({time:m})]}),h?(0,Q.jsx)(`span`,{children:ct({time:h})}):null,a]}),l===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ve({names:u.join(`, `)})}):null,s?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Me()})]})}function bn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?qt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,m]=(0,G.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(M,{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)(P,{variant:f===`beyond`?`destructive`:`secondary`,children:Kt(f)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ce()}),(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)(T,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Lt,{size:13,"aria-hidden":!0}),lt({count:t.length})]}),p?(0,Q.jsx)(pn,{connections:t,displayByInstance:c}):null]})}function xn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,a=e.drift??[];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[g(),a.length>0?(0,Q.jsx)(P,{variant:`destructive`,children:le({count:a.length})}):(0,Q.jsx)(P,{variant:`secondary`,children:me()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[oe({version:e.vendoredVersion}),r?` · `+Ue({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:a.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)(T,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Lt,{size:13,"aria-hidden":!0}),i({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:x()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:h()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:pe()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:rt({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:ce({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:_()}),e?(0,Q.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:We()}):(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:H(e.version)}),(0,Q.jsx)(P,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(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)(Pt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(It,{children:[(0,Q.jsx)(Ft,{children:ue({instance:e.displayName??e.name})}),(0,Q.jsx)(Rt,{children:se()})]}),(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)(D,{"aria-hidden":!0}):(0,Q.jsx)(N,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?we():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,s()]}):null}function Tn({instance:e,onClose:t}){let n=he(C.admin.upsertInstanceConfig),r=ne(C.bridge.validateMediaPaths),i=Tt(),o=Vt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>ht(e.config??{},o)),[u,d]=(0,G.useState)(!1),[p,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=s.inboundMediaMode===`shared-fs`,y=s.mediaMode===`shared-fs`,b=v||y;async function ae(){h(!0),_(null);try{_(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(ee(),e)}finally{h(!1)}}async function oe(){d(!0);try{let r=e.config??{};await n({instanceId:e._id,config:_t(s,r,o)}),t()}catch(e){i.error(xe(),e)}finally{d(!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)(E,{label:a(),help:st()}),(0,Q.jsxs)(O,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(I,{})}),(0,Q.jsx)(F,{children:vt.map(e=>(0,Q.jsx)(L,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(E,{label:Ge(),help:l()}),(0,Q.jsxs)(O,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(I,{})}),(0,Q.jsx)(F,{children:gt.map(e=>(0,Q.jsx)(L,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(E,{label:fe(),help:Ne()}),(0,Q.jsx)(A,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...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)(E,{label:Oe(),help:Ee()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(E,{label:De(),help:re()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(Ot,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Q.jsx)(E,{label:f(),help:ut()})]}),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)(N,{"aria-hidden":!0}),_e({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wn,{label:Se(),result:g.inbound}),(0,Q.jsx)(wn,{label:te(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Te()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(N,{"aria-hidden":!0}),ft()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(Ct,{variant:`outline`,size:`sm`,onClick:()=>void ae(),disabled:p,children:[p?(0,Q.jsx)(jt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,p?ie():Ze()]}),(0,Q.jsx)(Ct,{size:`sm`,onClick:()=>void oe(),disabled:u,children:m()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(wt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?ae():He({count:e.length}),(0,Q.jsx)(T,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Bt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:r()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(P,{variant:`secondary`,children:e},e))})]})]})}export{vn as BridgeTab,Cn as InstanceConfigDialog};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Al as r,Av as i,Ay as a,Bl as o,Bv as s,Cv as c,Cy as l,D as u,Dv as d,Dy as f,Ev as p,Ey as m,Fl as h,Fv as g,Gv as ee,Hv as te,IL as ne,Il as _,Iv as v,Jv as re,Kv as ie,Ll as y,Lv as b,Ml as ae,Mv as oe,My as se,Nl as ce,Nv as le,Ny as ue,Ov as de,Oy as fe,Pl as pe,Pv as me,RL as he,Rl as ge,Rv as _e,Sv as ve,Tl as ye,Tv as be,Ty as xe,Uv as Se,Vl as Ce,Vv as we,Wv as Te,Xv as Ee,Yv as De,Zv as Oe,_v as ke,ar as Ae,av as je,bv as Me,by as Ne,cv as Pe,dv as Fe,ev as Ie,fv as Le,gv as Re,hv as ze,ir as Be,iv as Ve,jl as He,jv as Ue,kl as We,kv as x,ky as Ge,lv as Ke,mv as S,nv as qe,or as Je,ov as Ye,pv as Xe,qv as Ze,rr as Qe,rv as $e,sr as et,sv as tt,t as C,tv as nt,ur as rt,uv as it,vv as at,wv as ot,wy as st,xv as ct,yv as lt,yy as ut,zL as w,zl as dt,zv as ft}from"./api-EsnGI4EC.js";import{r as T}from"./dist-BM94bqpE.js";import{t as pt}from"./chevron-up-DZeG4Ghe.js";import{t as mt}from"./chevrons-up-down-BQ8-VyUH.js";import{i as ht,n as E,o as gt,r as _t,s as vt}from"./FieldLabel-D_--lTMz.js";import{i as yt,n as bt,r as xt,t as St}from"./tabs-D8fO33rb.js";import{t as Ct}from"./button-CZ9WPf0m.js";import{An as D,Bt as wt,Dt as Tt,Fn as Et,I as Dt,P as Ot,Pn as kt,Rt as At,_t as O,bn as jt,bt as k,ct as Mt,dt as Nt,ft as Pt,gt as Ft,ht as It,jn as Lt,jt as A,lt as j,on as M,pt as Rt,rn as N,ut as P,vt as F,wt as zt,xt as I,yt as L,zt as Bt}from"./index-DdOFgMFG.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as R,n as Ut,o as z,r as B,t as V}from"./table-B--HXOj1.js";import{t as Wt}from"./FilterBar-3xmqkmtO.js";import{a as H,n as Gt,o as U,r as Kt,s as qt,t as Jt}from"./compatView-BNLmViDl.js";import{t as W}from"./dispatchErrorInfo-GCb0ITYo.js";var Yt=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Xt=u(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function K(e){return e.filter(e=>e.state===`error`)}function Zt(e){return e.reachable&&K(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 U(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)=>U(e,t)??Z(e,t))}var Q=n();function pn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(rn),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>un(o),[o]),c=(0,G.useMemo)(()=>dn(o),[o]),l=(0,G.useMemo)(()=>fn(o),[o]),u=(0,G.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:at()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Wt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:ze(),onReset:()=>r(rn),canReset:an(n),children:[(0,Q.jsxs)(O,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(I,{placeholder:Xe()})}),(0,Q.jsxs)(F,{children:[(0,Q.jsx)(L,{value:Y,children:S()}),s.map(e=>(0,Q.jsx)(L,{value:e,children:hn(e)},e))]})]}),(0,Q.jsxs)(O,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(I,{placeholder:Le()})}),(0,Q.jsxs)(F,{children:[(0,Q.jsx)(L,{value:Y,children:S()}),c.map(e=>(0,Q.jsx)(L,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(O,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(I,{placeholder:Fe()})}),(0,Q.jsxs)(F,{children:[(0,Q.jsx)(L,{value:Y,children:S()}),l.map(e=>(0,Q.jsx)(L,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:it()}):(0,Q.jsxs)(V,{className:`oc-conn__table`,children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)($,{label:Ke(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Pe(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:tt(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Ye(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:je(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(R,{children:Ve()}),(0,Q.jsx)($,{label:$e(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(Ut,{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)(R,{"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)(pt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(T,{size:13,"aria-hidden":!0}):(0,Q.jsx)(mt,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function mn({r:e}){let t=$t(e)?W(e.lastErrorCode):null,n=en(e)?W(e.lastDownstreamRejectCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(z,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(B,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(B,{children:(0,Q.jsx)(gn,{state:e.state})}),(0,Q.jsx)(B,{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)(B,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(B,{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)(B,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:ke({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(B,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:j(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Q.jsx)(z,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(B,{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?` · ${j(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:[Re({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${j(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function hn(e){return e===`connected`?qe():e===`error`?nt():Ie()}function gn({state:e}){return e===`connected`?(0,Q.jsx)(P,{variant:`secondary`,children:qe()}):e===`error`?(0,Q.jsx)(P,{variant:`destructive`,children:nt()}):(0,Q.jsx)(P,{variant:`outline`,children:Ie()})}function _n(){return w(C.bridgeHealth.getBridgeHealth,{})}function vn(){let e=_n(),t=w(C.compat.getBridgeCompat,{}),n=w(C.me.getMe,{host:zt})?.role===`admin`,r=w(C.admin.listInstances,n?{}:`skip`),i=w(C.agents.usageForInstances,n?{}:`skip`),a=kt(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=nn(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Et({from:`/settings/bridge`}),l=kt({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Gt(u,`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:b()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:v()}),(0,Q.jsxs)(V,{children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)(R,{children:et()}),(0,Q.jsx)(R,{children:Je()}),(0,Q.jsx)(R,{children:Ae()}),(0,Q.jsx)(R,{children:Be()}),(0,Q.jsx)(R,{children:Qe()})]})}),(0,Q.jsx)(Ut,{children:i.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(z,{children:[(0,Q.jsx)(B,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(B,{children:t.provider}),(0,Q.jsx)(B,{children:t.label}),(0,Q.jsx)(B,{children:(0,Q.jsxs)(P,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(B,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(St,{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)(xt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(yt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(M,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(bt,{value:e.key,children:(0,Q.jsx)(bn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ye()}):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:H(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:dt(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,ge({build:t.buildVersion??`?`})]}):null,` · `,y(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?_():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:x()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:de()});let o=K(e.targets),s=!e.reachable,l=Qt(e),u=e.unreachableInstances??[],f=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,m=Mt(e.checkedAt),h=e.startedAt==null?null:Mt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${f}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Q.jsx)(D,{size:22}):s||l===`gateways_unreachable`?(0,Q.jsx)(Xt,{size:22}):(0,Q.jsx)(N,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?d():l===`gateways_unreachable`?c({count:u.length}):s?p():be({count:o.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Yt,{size:12,"aria-hidden":!0}),` `,ot({time:m})]}),h?(0,Q.jsx)(`span`,{children:ct({time:h})}):null,a]}),l===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ve({names:u.join(`, `)})}):null,s?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Me()})]})}function bn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?qt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,m]=(0,G.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(M,{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)(P,{variant:f===`beyond`?`destructive`:`secondary`,children:Kt(f)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ce()}),(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)(T,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Lt,{size:13,"aria-hidden":!0}),lt({count:t.length})]}),p?(0,Q.jsx)(pn,{connections:t,displayByInstance:c}):null]})}function xn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,a=e.drift??[];return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[g(),a.length>0?(0,Q.jsx)(P,{variant:`destructive`,children:le({count:a.length})}):(0,Q.jsx)(P,{variant:`secondary`,children:me()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[oe({version:e.vendoredVersion}),r?` · `+Ue({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:a.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)(T,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Lt,{size:13,"aria-hidden":!0}),i({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:x()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:h()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:pe()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:rt({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:ce({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:_()}),e?(0,Q.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:We()}):(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:H(e.version)}),(0,Q.jsx)(P,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(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)(Pt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(It,{children:[(0,Q.jsx)(Ft,{children:ue({instance:e.displayName??e.name})}),(0,Q.jsx)(Rt,{children:se()})]}),(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)(D,{"aria-hidden":!0}):(0,Q.jsx)(N,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?we():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,s()]}):null}function Tn({instance:e,onClose:t}){let n=he(C.admin.upsertInstanceConfig),r=ne(C.bridge.validateMediaPaths),i=Tt(),o=Vt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>ht(e.config??{},o)),[u,d]=(0,G.useState)(!1),[p,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=s.inboundMediaMode===`shared-fs`,y=s.mediaMode===`shared-fs`,b=v||y;async function ae(){h(!0),_(null);try{_(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(ee(),e)}finally{h(!1)}}async function oe(){d(!0);try{let r=e.config??{};await n({instanceId:e._id,config:_t(s,r,o)}),t()}catch(e){i.error(xe(),e)}finally{d(!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)(E,{label:a(),help:st()}),(0,Q.jsxs)(O,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(I,{})}),(0,Q.jsx)(F,{children:vt.map(e=>(0,Q.jsx)(L,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(E,{label:Ge(),help:l()}),(0,Q.jsxs)(O,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Q.jsx)(k,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(I,{})}),(0,Q.jsx)(F,{children:gt.map(e=>(0,Q.jsx)(L,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(E,{label:fe(),help:Ne()}),(0,Q.jsx)(A,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...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)(E,{label:Oe(),help:Ee()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(E,{label:De(),help:re()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(Ot,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Q.jsx)(E,{label:f(),help:ut()})]}),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)(N,{"aria-hidden":!0}),_e({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wn,{label:Se(),result:g.inbound}),(0,Q.jsx)(wn,{label:te(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Te()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(N,{"aria-hidden":!0}),ft()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(Ct,{variant:`outline`,size:`sm`,onClick:()=>void ae(),disabled:p,children:[p?(0,Q.jsx)(jt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,p?ie():Ze()]}),(0,Q.jsx)(Ct,{size:`sm`,onClick:()=>void oe(),disabled:u,children:m()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(At,{children:[(0,Q.jsx)(wt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?ae():He({count:e.length}),(0,Q.jsx)(T,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Bt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:r()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(P,{variant:`secondary`,children:e},e))})]})]})}export{vn as BridgeTab,Cn as InstanceConfigDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AL as r,Eu as i,Gl as a,Hl as o,IL as s,Jl as c,Kl as l,RL as u,Ul as d,Wl as f,Xl as p,Yl as m,_o as h,bo as g,cd as _,do as v,fo as y,go as b,ho as x,id as S,jy as C,lr as w,mo as T,po as E,ql as D,rd as O,t as k,ud as A,vo as j,yo as M,zL as N}from"./api-EsnGI4EC.js";import{t as P}from"./button-CZ9WPf0m.js";import{M as F,N as I,P as L,V as R,_t as z,bt as B,jt as V,rn as H,vt as U,xt as W,yt as G}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AL as r,Eu as i,Gl as a,Hl as o,IL as s,Jl as c,Kl as l,RL as u,Ul as d,Wl as f,Xl as p,Yl as m,_o as h,bo as g,cd as _,do as v,fo as y,go as b,ho as x,id as S,jy as C,lr as w,mo as T,po as E,ql as D,rd as O,t as k,ud as A,vo as j,yo as M,zL as N}from"./api-EsnGI4EC.js";import{t as P}from"./button-CZ9WPf0m.js";import{M as F,N as I,P as L,V as R,_t as z,bt as B,jt as V,rn as H,vt as U,xt as W,yt as G}from"./index-DdOFgMFG.js";import{i as K}from"./compatView-BNLmViDl.js";/* empty css */var q=t(e(),1),J=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Y(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var X=n();function Z({instance:e}){let t=u(k.admin.upsertInstanceConfig),n=N(k.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,q.useState)(r),[s,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(r),c(`idle`)},[e._id,r]);let l=`__none__`,p=i!==r;async function m(){c(`saving`);try{let n={...e.config??{}};i===``||i===l?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let g=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:h()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:b()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(z,{value:i===``?l:i,onValueChange:e=>a(e===l?``:e),children:[(0,X.jsx)(B,{className:`oc-cdefaults__select`,"aria-label":h(),children:(0,X.jsx)(W,{placeholder:x()})}),(0,X.jsxs)(U,{children:[(0,X.jsx)(G,{value:l,children:x()}),g.map(e=>(0,X.jsx)(G,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!p||s===`saving`,onClick:()=>void m(),children:s===`saving`?A():f()})]}),s===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:d()}):null,s===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:o()}):null]})}function Q({instance:e}){let t=u(k.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,a]=(0,q.useState)(n),[s,c]=(0,q.useState)(r===null?``:String(r)),[l,p]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(n),c(r===null?``:String(r)),p(`idle`)},[e._id,n,r]);let m=s.trim(),h=m===``?null:/^\d+$/.test(m)?Number.parseInt(m,10):NaN,g=!i||h===null||Number.isInteger(h)&&h>=4e3&&h<=6e4,_=i!==n||(h??null)!==r;async function v(){p(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||h===null||Number.isNaN(h)?delete n.curationBudgetChars:n.curationBudgetChars=h,await t({instanceId:e._id,config:n}),p(`done`)}catch{p(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(L,{checked:i,onCheckedChange:e=>a(e===!0),"aria-label":j()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!g,"aria-label":T(),disabled:!i}),(0,X.jsx)(P,{size:`sm`,disabled:!_||!g||l===`saving`,onClick:()=>void v(),children:l===`saving`?A():f()})]}),g?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:d()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:o()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:y()})]})}function $({instance:e}){let t=u(k.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,q.useState)(n===null?``:String(n)),[a,s]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{i(n===null?``:String(n)),s(`idle`)},[e._id,n]);let c=r.trim(),l=c===``?null:/^\d+$/.test(c)?Number.parseInt(c,10):NaN,p=l===null||Number.isInteger(l)&&l>=1e3&&l<=2e5,m=(l??null)!==n;async function h(){s(`saving`);try{let n={...e.config??{}};l===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=l,await t({instanceId:e._id,config:n}),s(`done`)}catch{s(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()}),(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":!p}),(0,X.jsx)(P,{size:`sm`,disabled:!m||!p||a===`saving`,onClick:()=>void h(),children:a===`saving`?A():f()})]}),p?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:v()}),a===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:d()}):null,a===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:o()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:M()})]})}function ee(){let e=s(k.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),o=N(k.admin.listInstances,{}),[u,d]=(0,q.useState)(null);(0,q.useEffect)(()=>{!o||o.length===0||(!u||!o.some(e=>e.name===u))&&d(o[0].name)},[o,u]);let f=(o?.length??0)>1,h=o!==void 0&&o.length===0,g=N(k.compat.forInstance,u?{instanceName:u}:`skip`),v=u?R(g,`configDefaults`):`loading`,y=v===`loading`?null:v.blocked,b=(0,q.useMemo)(()=>f&&u?{instanceName:u}:{},[f,u]),x=(0,q.useRef)(0),T=(0,q.useCallback)(async()=>{let t=++x.current;n({status:`loading`});try{let r=Y(await e(b));if(x.current!==t)return;n({status:`done`,current:r})}catch{if(x.current!==t)return;n({status:`error`})}},[e,b]);(0,q.useEffect)(()=>{y===!1&&(f&&!u||T())},[T,y,f,u]);let E=t.status===`done`?t.current:null,A=(0,q.useMemo)(()=>J.map(e=>({id:e,label:I(e)})),[]),j=(0,q.useMemo)(()=>[{id:`fast`,label:S()},{id:`standard`,label:O()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:p()}),f&&u?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:i()}),(0,X.jsxs)(z,{value:u,onValueChange:e=>d(e),children:[(0,X.jsx)(B,{size:`sm`,"aria-label":i(),children:(0,X.jsx)(W,{})}),(0,X.jsx)(U,{children:(o??[]).map(e=>(0,X.jsx)(G,{value:e.name,children:e.name},e.name))})]})]}):null,h?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:C()}):v===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):v.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(H,{size:14,"aria-hidden":!0}),` `,K(v.gatewayVersion,v.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[a(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void T(),children:_()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:m()}),(0,X.jsx)(F,{options:A,value:E?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:c()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:D()}),(0,X.jsx)(F,{options:j,value:E===null||E.fastModeDefault===null?null:E.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:l()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:w()})]}),(()=>{let e=o?.find(e=>e.name===(u??o[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{_m as r,dm as i,fm as a,gm as o,hm as s,mm as c,pm as l}from"./api-EsnGI4EC.js";import{r as u}from"./dist-BM94bqpE.js";import{t as d}from"./chevron-up-DZeG4Ghe.js";import{t as f}from"./chevrons-up-down-BQ8-VyUH.js";import{t as p}from"./button-CZ9WPf0m.js";import{En as m,It as h,Lt as g,Mt as _,Nt as v,P as y,Pt as b,in as x,ln as S}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{_m as r,dm as i,fm as a,gm as o,hm as s,mm as c,pm as l}from"./api-EsnGI4EC.js";import{r as u}from"./dist-BM94bqpE.js";import{t as d}from"./chevron-up-DZeG4Ghe.js";import{t as f}from"./chevrons-up-down-BQ8-VyUH.js";import{t as p}from"./button-CZ9WPf0m.js";import{En as m,It as h,Lt as g,Mt as _,Nt as v,P as y,Pt as b,in as x,ln as S}from"./index-DdOFgMFG.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-B--HXOj1.js";var k=t(e(),1);function A(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function j(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=A(i,a);return n===`asc`?c:-c})}var M=n();function N({title:e,rows:t,columns:n,rowActions:A,onAdd:N,addLabel:P=r(),bulkActions:F,emptyHint:I=o(),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)(x,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(S,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(y,{"aria-label":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":i({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(d,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(f,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],r=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(y,{"aria-label":l(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":a(),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)(v,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(h,{}):null,(0,M.jsx)(b,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{ut as t}from"./index-
|
|
1
|
+
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{ut as t}from"./index-DdOFgMFG.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,AE as i,Aa as a,BE as o,CE as s,DE as c,EE as l,FE as u,GE as d,HE as f,IE as ee,JE as p,JT as m,KE as h,LE as te,ME as g,Ma as _,NE as v,OE as ne,PE as re,QT as y,RE as ie,RL as b,SE as ae,TE as x,UE as S,VE as C,WE as w,XT as T,YE as E,YT as D,ZT as O,_E as k,aE as A,bE as j,cE as M,dE as N,eE as P,fE as F,gE as I,hE as L,iE as R,jE as z,kE as B,lE as V,mE as H,nE as U,oE as W,pE as oe,qE as G,qT as K,rE as q,sE as se,t as J,tE as ce,uE as le,vE as ue,wE as de,xE as fe,yE as pe,zE as me,zL as he}from"./api-EsnGI4EC.js";import{t as ge}from"./button-CZ9WPf0m.js";import{Z as _e,ct as Y}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,AE as i,Aa as a,BE as o,CE as s,DE as c,EE as l,FE as u,GE as d,HE as f,IE as ee,JE as p,JT as m,KE as h,LE as te,ME as g,Ma as _,NE as v,OE as ne,PE as re,QT as y,RE as ie,RL as b,SE as ae,TE as x,UE as S,VE as C,WE as w,XT as T,YE as E,YT as D,ZT as O,_E as k,aE as A,bE as j,cE as M,dE as N,eE as P,fE as F,gE as I,hE as L,iE as R,jE as z,kE as B,lE as V,mE as H,nE as U,oE as W,pE as oe,qE as G,qT as K,rE as q,sE as se,t as J,tE as ce,uE as le,vE as ue,wE as de,xE as fe,yE as pe,zE as me,zL as he}from"./api-EsnGI4EC.js";import{t as ge}from"./button-CZ9WPf0m.js";import{Z as _e,ct as Y}from"./index-DdOFgMFG.js";import{t as ve}from"./DataTableShell-D5Nb8D27.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>E(),incorrect:()=>p(),incoherence:()=>G(),formatting:()=>h(),latency:()=>d(),api_error:()=>w(),other:()=>S()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:C()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:o()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:f()})}function be({data:e,reference:t,closeReason:n}){let a=e.snapshot,o=b(J.feedback.respondToFeedback),[d,f]=(0,X.useState)(e.thread),[p,m]=(0,X.useState)(``),[h,y]=(0,X.useState)(!1);async function S(){let t=p.trim();if(!(!t||h)){y(!0);try{await o({feedbackId:e._id,text:t}),f(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),m(``)}finally{y(!1)}}}let C=[];try{C=a.contextJson?JSON.parse(a.contextJson):[]}catch{C=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:a.displayedMatchesStored,sourceWasOpen:a.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,a.messageRole,a.isRegeneration?` · ${me()}`:``,a.openclawModel?` · ${a.openclawModel}`:``,a.openclawRuntime?` (${a.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:oe(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ie()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:r()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:te()}),d.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:d.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`?ee():e.authorRole===`agent`?e.authorLabel??_():u()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:re()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:v(),value:p,maxLength:2e3,rows:3,onChange:e=>m(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void S(),disabled:!p.trim()||h,children:h?g():z()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:i()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:a.messageText||B()})]}),a.clientInfo?.sourceWasOpen&&a.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ne()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:a.displayedText||B()})]}):null,a.promptText?(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:a.promptText})]}):null,C.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:l({count:a.contextCount??C.length,truncated:a.contextTruncated?x():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:C.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,a.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:de()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[a.outboxText??``,a.outboxStatus?`\n[status: ${a.outboxStatus}]`:``]})]}):null,a.clientInfo?.extensionsDetected&&a.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:s()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:a.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:ae()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[a.clientInfo?.language,a.clientInfo?.timezone,a.clientInfo?.theme?fe({theme:a.clientInfo.theme}):null,a.runId?`run ${a.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,a.clientInfo?.plugins&&a.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[j(),` `,a.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,pe()]})]}):null,a.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:a.clientInfo.userAgent}):null]})]})]})}function xe(){let e=he(J.feedback.listForAdmin,{}),t=b(J.feedback.readSnapshot),n=b(J.feedback.deleteFeedback),r=_e(),[i,o]=(0,X.useState)(null),[s,c]=(0,X.useState)({});async function l(e){if(i===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 r({title:D(),description:m(),confirmLabel:K(),destructive:!0})&&(await n({feedbackId:e._id}),i===e._id&&o(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[ue(),` `,(0,Z.jsx)(`strong`,{children:k()}),` `,I()]}),(0,Z.jsx)(ve,{title:L(),rows:e,emptyHint:H(),isExpanded:e=>i===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(be,{data:s[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:F(),cell:e=>Y(e.at),sort:e=>e.at},{header:N(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:le(),cell:e=>e.messageRole===`user`?V():M(),sort:e=>e.messageRole},{header:se(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${W({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:A(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:R(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:q(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:U()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:ce()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:a()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:P()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:i===e._id?y():O(),onSelect:()=>void l(e)},{label:T(),onSelect:()=>void u(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,KL as n}from"./api-EsnGI4EC.js";import{B as r,L as i,R as a,z as o}from"./index-
|
|
1
|
+
import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,KL as n}from"./api-EsnGI4EC.js";import{B as r,L as i,R as a,z as o}from"./index-DdOFgMFG.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var s=t(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),c={media_delivery:{key:`media_delivery`,appliedIn:`bridge`,togglable:!0,placeholders:[`outboundDir`],defaultTemplate:{fr:`[LIVRAISON]
|
|
2
2
|
Pour qu'un fichier que tu génères soit téléchargeable par l'utilisateur dans ce webchat : écris-le sous {outboundDir}/ puis ajoute, dans ta réponse finale, une ligne dédiée EXACTEMENT au format MEDIA:<chemin absolu du fichier>. N'utilise PAS de lien markdown vers un chemin local — il ne serait pas cliquable.`,en:`[DELIVERY]
|
|
3
3
|
To make a file you generate downloadable by the user in this webchat: write it under {outboundDir}/ then add, in your final reply, a dedicated line EXACTLY in the format MEDIA:<absolute file path>. Do NOT use a markdown link to a local path — it would not be clickable.`}},documentary_fetch:{key:`documentary_fetch`,appliedIn:`convex`,togglable:!0,placeholders:[`references`],defaultTemplate:{fr:`Fournis les fichiers source téléchargeables correspondant EXACTEMENT à ces références de documents (un fichier par référence, nommé d'après la référence). Réponds uniquement avec les fichiers, sans commentaire :
|
|
4
4
|
{references}`,en:`Provide the downloadable source files matching EXACTLY these document references (one file per reference, named after the reference). Reply only with the files, no commentary:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AI as r,AL as ee,BI as i,CI as a,DI as o,EI as s,FI as c,Fa as te,GI as ne,HI as l,II as u,Ia as d,JI as f,KI as p,LI as m,MI as re,ML as ie,NI as ae,OI as oe,PI as h,RI as g,RL as se,SI as ce,TI as le,UI as ue,VI as de,WI as fe,XI as pe,YI as me,Yk as he,ZI as ge,_I as _e,bI as ve,gI as ye,jI as be,kI as xe,qI as _,t as v,vI as y,wI as b,xI as x,yI as S,zI as C,zL as w}from"./api-EsnGI4EC.js";import{t as T}from"./button-CZ9WPf0m.js";import{$ as E,Dn as D,Dt as O,En as k,Lt as A,Mt as j,Nt as M,P as Se,Pt as N,_t as P,at as Ce,bt as F,cn as we,et as Te,in as Ee,it as De,nt as Oe,ot as ke,rt as Ae,tt as je,ut as I,vt as L,xt as R,yt as z}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AI as r,AL as ee,BI as i,CI as a,DI as o,EI as s,FI as c,Fa as te,GI as ne,HI as l,II as u,Ia as d,JI as f,KI as p,LI as m,MI as re,ML as ie,NI as ae,OI as oe,PI as h,RI as g,RL as se,SI as ce,TI as le,UI as ue,VI as de,WI as fe,XI as pe,YI as me,Yk as he,ZI as ge,_I as _e,bI as ve,gI as ye,jI as be,kI as xe,qI as _,t as v,vI as y,wI as b,xI as x,yI as S,zI as C,zL as w}from"./api-EsnGI4EC.js";import{t as T}from"./button-CZ9WPf0m.js";import{$ as E,Dn as D,Dt as O,En as k,Lt as A,Mt as j,Nt as M,P as Se,Pt as N,_t as P,at as Ce,bt as F,cn as we,et as Te,in as Ee,it as De,nt as Oe,ot as ke,rt as Ae,tt as je,ut as I,vt as L,xt as R,yt as z}from"./index-DdOFgMFG.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-B--HXOj1.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return i();case`audio`:return C();case`video`:return g();case`pdf`:return m();case`document`:return u();case`archive`:return c();default:return h()}}function q(){let[e,t]=(0,U.useState)(G),[n,i]=(0,U.useState)(G),[c,u]=(0,U.useState)(G),[m,h]=(0,U.useState)(G),[g,C]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=se(v.files.softDelete),Y=O();function Ie(){t(G),i(G),u(G),h(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(a())}catch(e){Y.error(ce(),e)}}let X=w(v.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:c===G?void 0:c,category:m===G?void 0:m,includeAutoGenerated:g||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(ie(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ee()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||c!==G||m!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ge()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(P,{value:e,onValueChange:t,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":pe(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:me()}),(0,W.jsx)(z,{value:`inbound`,children:f()}),(0,W.jsx)(z,{value:`outbound`,children:_()})]})]}),(0,W.jsxs)(P,{value:n,onValueChange:i,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":p(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:ne()}),Q.chats.map(e=>(0,W.jsx)(z,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(P,{value:c,onValueChange:u,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":fe(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:ue()}),Q.instances.map(e=>(0,W.jsx)(z,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(P,{value:m,onValueChange:h,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":l(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:de()}),Q.categories.map(e=>(0,W.jsx)(z,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(Se,{checked:g,onCheckedChange:e=>C(e===!0),"aria-label":d()}),(0,W.jsx)(`span`,{children:d()})]}),$?(0,W.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(we,{size:14,"aria-hidden":!0}),s()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?_e():y()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:ae()}),(0,W.jsx)(B,{children:re()}),(0,W.jsx)(B,{children:be()}),(0,W.jsx)(B,{children:r()}),(0,W.jsx)(B,{children:xe()}),(0,W.jsx)(B,{className:`text-right`,children:oe()})]})}),(0,W.jsx)(Ne,{children:Z.map(e=>(0,W.jsxs)(V,{children:[(0,W.jsxs)(H,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,W.jsx)(I,{variant:`outline`,style:{marginLeft:6},children:te()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(I,{variant:`secondary`,children:e.direction===`inbound`?f():_()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(j,{children:[(0,W.jsx)(A,{asChild:!0,children:(0,W.jsx)(T,{variant:`ghost`,size:`icon`,"aria-label":le(),children:(0,W.jsx)(k,{size:16})})}),(0,W.jsxs)(M,{align:`end`,children:[e.url?(0,W.jsx)(N,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(D,{size:14}),o()]})}):(0,W.jsxs)(N,{disabled:!0,children:[(0,W.jsx)(D,{size:14}),S()]}),(0,W.jsxs)(N,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Ee,{size:14}),b()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:ye({cap:Be})}):null]}),(0,W.jsx)(E,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(Oe,{children:[(0,W.jsxs)(Ce,{children:[(0,W.jsx)(ke,{children:x()}),(0,W.jsx)(Ae,{children:ve()})]}),(0,W.jsxs)(De,{children:[(0,W.jsx)(je,{children:he()}),(0,W.jsx)(Te,{onClick:()=>void Le(),children:b()})]})]})})]})}export{q as FilesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{vm as r,ym as i}from"./api-EsnGI4EC.js";import{t as a}from"./button-CZ9WPf0m.js";import{cn as o,jt as s,sn as c}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{vm as r,ym as i}from"./api-EsnGI4EC.js";import{t as a}from"./button-CZ9WPf0m.js";import{cn as o,jt as s,sn as c}from"./index-DdOFgMFG.js";import{t as l}from"./TimeRangePicker-B3yMy8oz.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=i(),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)(c,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),r()]})]})}export{p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,Ad as i,Af as a,Bd as o,Cd as s,Cf as c,D as l,Dd as u,Df as d,Ed as f,Ef as p,Fd as m,Gd as h,Hd as g,Id as _,Jd as v,Kd as y,Ld as b,Md as x,Nd as S,Od as C,Of as w,Pd as T,Qd as E,RL as D,Rd as ee,Sd as O,Sf as k,Td as te,Tf as ne,Ud as A,Vd as j,Wd as re,Xd as M,Yd as ie,Zd as ae,_f as N,af as oe,bf as se,cf as ce,df as P,ef as le,ff as ue,gf as de,hf as fe,if as pe,jd as me,jf as he,kd as ge,kf as _e,lf as ve,mf as ye,nf as F,of as be,pf as xe,qd as I,rf as Se,sf as Ce,t as L,tf as we,uf as Te,vf as Ee,wd as De,wf as Oe,xf as ke,yf as Ae,zL as R,zd as z}from"./api-EsnGI4EC.js";import{t as je}from"./x-DOcdk27K.js";import{i as B,n as V,r as Me,t as Ne}from"./tabs-lFf0wQh0.js";import{t as H}from"./button-CZ9WPf0m.js";import{Dt as U,Mn as Pe,P as W,Z as Fe,_ as Ie,_t as Le,an as G,bt as Re,dt as ze,ft as Be,gt as Ve,ht as He,jn as Ue,jt as K,on as q,pt as We,ut as J,vt as Ge,wt as Ke,xt as qe,yt as Je}from"./index-CsdodIca.js";import{t as Ye}from"./FilterBar-Bxpfu6Cp.js";import{t as Xe}from"./DataTableShell-BYhMdaSl.js";import{t as Y}from"./DetailChips-BT8QU7Op.js";var Ze=l(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),X=l(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Qe=l(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Z=t(e(),1);function $e(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function et(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function tt(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function nt(e){switch(e){case`admin`:return E();case`user`:return ae();case`pending`:return M();default:return e}}function rt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function it(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var Q=n(),$={name:``,description:``};function at(){let e=R(L.groups.listGroups,{}),t=R(L.me.getMe,{host:Ke})?.role===`admin`,n=D(L.groups.createGroup),r=D(L.groups.updateGroup),i=D(L.groups.deleteGroup),o=Fe(),s=U(),[l,u]=(0,Z.useState)(!1),[f,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)($),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(``),x=(0,Z.useMemo)(()=>{if(!e)return e;let t=y.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,y]);function S(){m(null),g($),u(!0)}function C(e){m(e),g({name:e.name,description:e.description??``}),u(!0)}async function T(){try{f?await r({groupId:f._id,name:h.name,description:h.description}):await n({name:h.name,description:h.description||void 0}),g($),m(null),u(!1)}catch(e){s.error(te(),e)}}async function E(e){if(await o({title:ue({name:e.name}),description:P(),confirmWord:e.name,confirmLabel:Te(),cancelLabel:Ee(),destructive:!0}))try{await i({groupId:e._id})}catch(e){s.error(De(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}),(0,Q.jsx)(Ye,{q:y,onQChange:b,onReset:()=>b(``),canReset:y!==``,searchPlaceholder:c()}),(0,Q.jsx)(Xe,{title:he(),rows:x,addLabel:_e(),onAdd:t?S:void 0,emptyHint:w(),columns:[{header:d(),cell:e=>e.name,sort:e=>e.name},{header:p(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Qe,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(X,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:ne(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(q,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:Oe(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(G,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:k(),onSelect:()=>v({groupId:e._id,name:e.name})},...t?[{label:ke(),onSelect:()=>C(e)},{label:se(),variant:`destructive`,onSelect:()=>void E(e)}]:[]]}),(0,Q.jsx)(Ie,{open:l,onOpenChange:u,title:f?de():N(),description:fe(),canSubmit:!!h.name.trim(),onSubmit:T,submitLabel:Ae(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:ye()}),(0,Q.jsx)(K,{value:h.name,onChange:e=>g({...h,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:xe()}),(0,Q.jsx)(K,{value:h.description,onChange:e=>g({...h,description:e.target.value})})]})]})}),(0,Q.jsx)(ct,{groupId:_?.groupId??null,groupName:_?.name??``,open:_!==null,onOpenChange:e=>{e||v(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(Pe,{size:14,"aria-hidden":!0}),we()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":r({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[le(),(0,Q.jsx)(Ue,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let a=R(L.groups.getGroup,n&&e?{groupId:e}:`skip`),o=R(L.groups.listAssignableInstances,n?{}:`skip`),c=R(L.groups.listAssignableUsers,n?{}:`skip`),l=D(L.groups.addMember),d=D(L.groups.removeMember),f=D(L.groups.bulkSetMembers),p=D(L.groups.setGroupManager),m=U(),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(`members`),[S,w]=(0,Z.useState)(1),[T,E]=(0,Z.useState)(new Set),O=(0,Z.useRef)(null),k=(0,Z.useMemo)(()=>new Set((a?.members??[]).map(e=>e.userId)),[a]),te=(0,Z.useMemo)(()=>new Set((a?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[a]),ne=a?.viewerIsAdmin===!0,A=(0,Z.useMemo)(()=>new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[a]);(0,Z.useEffect)(()=>{_(``),y(``),x(`members`),w(1),O.current=null},[n,e]),(0,Z.useEffect)(()=>{w(1)},[g]),(0,Z.useEffect)(()=>{n&&a&&e&&O.current!==e&&(O.current=e,E(new Set((a.members??[]).map(e=>e.userId))))},[n,a,e]);let j=(0,Z.useMemo)(()=>c?$e(c,g,T):[],[c,g,T]);async function M(t,n){if(e)try{n?await d({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){m.error(s(),e)}}async function ae(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){m.error(u(),e)}}let N=rt(j,e=>k.has(e.userId)),se=j.filter(e=>k.has(e.userId)).length,P=it(j,S,ot);async function le(){if(!e||j.length===0)return;let t=j.map(e=>e.userId);try{await f({groupId:e,userIds:t,member:N!==`all`})}catch(e){m.error(s(),e)}}return(0,Q.jsx)(ze,{open:n,onOpenChange:r,children:(0,Q.jsxs)(Be,{className:`oc-access`,children:[(0,Q.jsxs)(He,{children:[(0,Q.jsx)(Ve,{children:ve({name:t})}),(0,Q.jsx)(We,{children:ce()})]}),(0,Q.jsxs)(Ne,{value:b,onValueChange:x,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Me,{className:`w-full`,children:[(0,Q.jsxs)(B,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Qe,{size:13,"aria-hidden":!0}),Ce(),a?(0,Q.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:k.size}):null]}),(0,Q.jsxs)(B,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(q,{size:13,"aria-hidden":!0}),oe(),a?(0,Q.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:A.size}):null]}),(0,Q.jsxs)(B,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ze,{size:13,"aria-hidden":!0}),ee(),a?(0,Q.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:a.chartCount}):null]})]}),(0,Q.jsx)(V,{value:`members`,children:c===void 0||a===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:I()}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:h()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{value:g,onChange:e=>_(e.target.value),placeholder:be(),className:`oc-access__search`}),j.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Se()}):(0,Q.jsxs)(Q.Fragment,{children:[j.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(W,{checked:N===`all`?!0:N===`some`?`indeterminate`:!1,onCheckedChange:()=>void le(),"aria-label":F()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:F()}),(0,Q.jsxs)(J,{variant:`outline`,className:`oc-access__count`,children:[se,` / `,j.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:P.pageItems.map(e=>{let t=k.has(e.userId),n=tt(e),r=te.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:t,onCheckedChange:()=>void M(e.userId,t),"aria-label":ie({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:nt(e.role)}),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&ne?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?C():ge(),title:r?C():ge(),onClick:()=>void ae(e.userId,r),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):t&&r?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":i(),title:i(),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)(st,{page:P.page,pageCount:P.pageCount,onPage:w})]})]})}),(0,Q.jsx)(V,{value:`agents`,children:o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:I()}):o.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{value:v,onChange:e=>y(e.target.value),placeholder:pe(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,Q.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:A,query:v},`${e}-${t._id}`))})]})}),(0,Q.jsx)(V,{value:`charts`,children:(0,Q.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=R(L.groups.listAssignableAgents,{instanceName:t}),s=D(L.groups.assignAgentToGroup),c=D(L.groups.removeAgentFromGroup),l=D(L.groups.bulkSetGroupAgents),u=U(),[d,f]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{f(1)},[i]),!e)return null;let p=et(a?.agents??[],i),m=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),_=rt(h,e=>r.has(`${t}/${e.agentId}`)),b=it(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(O(),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:_!==`all`})}catch(e){u.error(O(),e)}}return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(q,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__stale`,children:j()}):null]}),a===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:y()}):p.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:m?g():A()}):(0,Q.jsxs)(Q.Fragment,{children:[h.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(W,{checked:_===`all`?!0:_===`some`?`indeterminate`:!1,onCheckedChange:()=>void S(),"aria-label":F()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:F()})]}):null,b.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,s=!e.enabled;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(W,{checked:i,disabled:(a||s)&&!i,onCheckedChange:()=>void x(e.agentId,i),"aria-label":v({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":z(),title:z(),children:(0,Q.jsx)(G,{size:14,fill:`currentColor`})}):null,a?(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:o()}):null]},e.agentId)}),(0,Q.jsx)(st,{page:b.page,pageCount:b.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=R(L.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=D(L.charts.assignChartToGroup),r=D(L.charts.removeChartFromGroup),i=D(L.charts.setGroupDefaultChart),a=D(L.charts.addChartToGroupPool),o=D(L.charts.removeChartFromGroupPool),s=U();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:I()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:b()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}async function p(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":S({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":x(),title:x(),children:(0,Q.jsx)(G,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:me()}):null,u?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":T({name:e.name}),title:T({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,Q.jsx)(je,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,Q.jsxs)(Le,{value:``,onValueChange:e=>void h(e),children:[(0,Q.jsx)(Re,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(qe,{placeholder:m()})}),(0,Q.jsx)(Ge,{children:l.map(e=>(0,Q.jsx)(Je,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:_()}):null:null]})}export{at as GroupsTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,Ad as i,Af as a,Bd as o,Cd as s,Cf as c,D as l,Dd as u,Df as d,Ed as f,Ef as p,Fd as m,Gd as h,Hd as g,Id as _,Jd as v,Kd as y,Ld as b,Md as x,Nd as S,Od as C,Of as w,Pd as T,Qd as E,RL as D,Rd as ee,Sd as O,Sf as k,Td as te,Tf as ne,Ud as A,Vd as j,Wd as re,Xd as M,Yd as ie,Zd as ae,_f as N,af as oe,bf as se,cf as ce,df as P,ef as le,ff as ue,gf as de,hf as fe,if as pe,jd as me,jf as he,kd as ge,kf as _e,lf as ve,mf as ye,nf as F,of as be,pf as xe,qd as I,rf as Se,sf as Ce,t as L,tf as we,uf as Te,vf as Ee,wd as De,wf as Oe,xf as ke,yf as Ae,zL as R,zd as z}from"./api-EsnGI4EC.js";import{t as je}from"./x-DOcdk27K.js";import{i as B,n as V,r as Me,t as Ne}from"./tabs-D8fO33rb.js";import{t as H}from"./button-CZ9WPf0m.js";import{Dt as U,Mn as Pe,P as W,Z as Fe,_ as Ie,_t as Le,an as G,bt as Re,dt as ze,ft as Be,gt as Ve,ht as He,jn as Ue,jt as K,on as q,pt as We,ut as J,vt as Ge,wt as Ke,xt as qe,yt as Je}from"./index-DdOFgMFG.js";import{t as Ye}from"./FilterBar-3xmqkmtO.js";import{t as Xe}from"./DataTableShell-D5Nb8D27.js";import{t as Y}from"./DetailChips-BpplTXuL.js";var Ze=l(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),X=l(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Qe=l(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Z=t(e(),1);function $e(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function et(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function tt(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function nt(e){switch(e){case`admin`:return E();case`user`:return ae();case`pending`:return M();default:return e}}function rt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function it(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var Q=n(),$={name:``,description:``};function at(){let e=R(L.groups.listGroups,{}),t=R(L.me.getMe,{host:Ke})?.role===`admin`,n=D(L.groups.createGroup),r=D(L.groups.updateGroup),i=D(L.groups.deleteGroup),o=Fe(),s=U(),[l,u]=(0,Z.useState)(!1),[f,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)($),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(``),x=(0,Z.useMemo)(()=>{if(!e)return e;let t=y.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,y]);function S(){m(null),g($),u(!0)}function C(e){m(e),g({name:e.name,description:e.description??``}),u(!0)}async function T(){try{f?await r({groupId:f._id,name:h.name,description:h.description}):await n({name:h.name,description:h.description||void 0}),g($),m(null),u(!1)}catch(e){s.error(te(),e)}}async function E(e){if(await o({title:ue({name:e.name}),description:P(),confirmWord:e.name,confirmLabel:Te(),cancelLabel:Ee(),destructive:!0}))try{await i({groupId:e._id})}catch(e){s.error(De(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:a()}),(0,Q.jsx)(Ye,{q:y,onQChange:b,onReset:()=>b(``),canReset:y!==``,searchPlaceholder:c()}),(0,Q.jsx)(Xe,{title:he(),rows:x,addLabel:_e(),onAdd:t?S:void 0,emptyHint:w(),columns:[{header:d(),cell:e=>e.name,sort:e=>e.name},{header:p(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Qe,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,Q.jsx)(X,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:ne(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(q,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:Oe(),cell:e=>(0,Q.jsx)(Y,{icon:(0,Q.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,Q.jsx)(G,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:k(),onSelect:()=>v({groupId:e._id,name:e.name})},...t?[{label:ke(),onSelect:()=>C(e)},{label:se(),variant:`destructive`,onSelect:()=>void E(e)}]:[]]}),(0,Q.jsx)(Ie,{open:l,onOpenChange:u,title:f?de():N(),description:fe(),canSubmit:!!h.name.trim(),onSubmit:T,submitLabel:Ae(),children:(0,Q.jsxs)(`div`,{className:`oc-form`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:ye()}),(0,Q.jsx)(K,{value:h.name,onChange:e=>g({...h,name:e.target.value})})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(`span`,{className:`oc-field__label`,children:xe()}),(0,Q.jsx)(K,{value:h.description,onChange:e=>g({...h,description:e.target.value})})]})]})}),(0,Q.jsx)(ct,{groupId:_?.groupId??null,groupName:_?.name??``,open:_!==null,onOpenChange:e=>{e||v(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,Q.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,Q.jsx)(Pe,{size:14,"aria-hidden":!0}),we()]}),(0,Q.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":r({page:e,pages:t}),children:[e,` / `,t]}),(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[le(),(0,Q.jsx)(Ue,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let a=R(L.groups.getGroup,n&&e?{groupId:e}:`skip`),o=R(L.groups.listAssignableInstances,n?{}:`skip`),c=R(L.groups.listAssignableUsers,n?{}:`skip`),l=D(L.groups.addMember),d=D(L.groups.removeMember),f=D(L.groups.bulkSetMembers),p=D(L.groups.setGroupManager),m=U(),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(`members`),[S,w]=(0,Z.useState)(1),[T,E]=(0,Z.useState)(new Set),O=(0,Z.useRef)(null),k=(0,Z.useMemo)(()=>new Set((a?.members??[]).map(e=>e.userId)),[a]),te=(0,Z.useMemo)(()=>new Set((a?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[a]),ne=a?.viewerIsAdmin===!0,A=(0,Z.useMemo)(()=>new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[a]);(0,Z.useEffect)(()=>{_(``),y(``),x(`members`),w(1),O.current=null},[n,e]),(0,Z.useEffect)(()=>{w(1)},[g]),(0,Z.useEffect)(()=>{n&&a&&e&&O.current!==e&&(O.current=e,E(new Set((a.members??[]).map(e=>e.userId))))},[n,a,e]);let j=(0,Z.useMemo)(()=>c?$e(c,g,T):[],[c,g,T]);async function M(t,n){if(e)try{n?await d({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){m.error(s(),e)}}async function ae(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){m.error(u(),e)}}let N=rt(j,e=>k.has(e.userId)),se=j.filter(e=>k.has(e.userId)).length,P=it(j,S,ot);async function le(){if(!e||j.length===0)return;let t=j.map(e=>e.userId);try{await f({groupId:e,userIds:t,member:N!==`all`})}catch(e){m.error(s(),e)}}return(0,Q.jsx)(ze,{open:n,onOpenChange:r,children:(0,Q.jsxs)(Be,{className:`oc-access`,children:[(0,Q.jsxs)(He,{children:[(0,Q.jsx)(Ve,{children:ve({name:t})}),(0,Q.jsx)(We,{children:ce()})]}),(0,Q.jsxs)(Ne,{value:b,onValueChange:x,className:`oc-access__tabs`,children:[(0,Q.jsxs)(Me,{className:`w-full`,children:[(0,Q.jsxs)(B,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Qe,{size:13,"aria-hidden":!0}),Ce(),a?(0,Q.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:k.size}):null]}),(0,Q.jsxs)(B,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(q,{size:13,"aria-hidden":!0}),oe(),a?(0,Q.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:A.size}):null]}),(0,Q.jsxs)(B,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Ze,{size:13,"aria-hidden":!0}),ee(),a?(0,Q.jsx)(J,{variant:`secondary`,className:`oc-access__tabcount`,children:a.chartCount}):null]})]}),(0,Q.jsx)(V,{value:`members`,children:c===void 0||a===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:I()}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:h()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{value:g,onChange:e=>_(e.target.value),placeholder:be(),className:`oc-access__search`}),j.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:Se()}):(0,Q.jsxs)(Q.Fragment,{children:[j.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(W,{checked:N===`all`?!0:N===`some`?`indeterminate`:!1,onCheckedChange:()=>void le(),"aria-label":F()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:F()}),(0,Q.jsxs)(J,{variant:`outline`,className:`oc-access__count`,children:[se,` / `,j.length]})]}):null,(0,Q.jsx)(`div`,{className:`oc-access__list`,children:P.pageItems.map(e=>{let t=k.has(e.userId),n=tt(e),r=te.has(e.userId);return(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:t,onCheckedChange:()=>void M(e.userId,t),"aria-label":ie({user:n.primary})}),(0,Q.jsxs)(`span`,{className:`oc-access__who`,children:[(0,Q.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,Q.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__role`,children:nt(e.role)}),(0,Q.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&ne?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?C():ge(),title:r?C():ge(),onClick:()=>void ae(e.userId,r),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):t&&r?(0,Q.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":i(),title:i(),children:(0,Q.jsx)(X,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,Q.jsx)(st,{page:P.page,pageCount:P.pageCount,onPage:w})]})]})}),(0,Q.jsx)(V,{value:`agents`,children:o===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:I()}):o.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{value:v,onChange:e=>y(e.target.value),placeholder:pe(),className:`oc-access__search`}),(0,Q.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,Q.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:A,query:v},`${e}-${t._id}`))})]})}),(0,Q.jsx)(V,{value:`charts`,children:(0,Q.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=R(L.groups.listAssignableAgents,{instanceName:t}),s=D(L.groups.assignAgentToGroup),c=D(L.groups.removeAgentFromGroup),l=D(L.groups.bulkSetGroupAgents),u=U(),[d,f]=(0,Z.useState)(1);if((0,Z.useEffect)(()=>{f(1)},[i]),!e)return null;let p=et(a?.agents??[],i),m=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),_=rt(h,e=>r.has(`${t}/${e.agentId}`)),b=it(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(O(),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:_!==`all`})}catch(e){u.error(O(),e)}}return(0,Q.jsxs)(`div`,{className:`oc-access__group`,children:[(0,Q.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,Q.jsx)(q,{size:13,"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__stale`,children:j()}):null]}),a===void 0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:y()}):p.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:m?g():A()}):(0,Q.jsxs)(Q.Fragment,{children:[h.length>1?(0,Q.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,Q.jsx)(W,{checked:_===`all`?!0:_===`some`?`indeterminate`:!1,onCheckedChange:()=>void S(),"aria-label":F()}),(0,Q.jsx)(`span`,{className:`oc-access__label`,children:F()})]}):null,b.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,s=!e.enabled;return(0,Q.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,Q.jsx)(W,{checked:i,disabled:(a||s)&&!i,onCheckedChange:()=>void x(e.agentId,i),"aria-label":v({name:e.displayName??e.agentId})}),(0,Q.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,Q.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":z(),title:z(),children:(0,Q.jsx)(G,{size:14,fill:`currentColor`})}):null,a?(0,Q.jsx)(J,{variant:`outline`,className:`oc-access__gone`,children:o()}):null]},e.agentId)}),(0,Q.jsx)(st,{page:b.page,pageCount:b.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=R(L.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=D(L.charts.assignChartToGroup),r=D(L.charts.removeChartFromGroup),i=D(L.charts.setGroupDefaultChart),a=D(L.charts.addChartToGroupPool),o=D(L.charts.removeChartFromGroupPool),s=U();if(!e)return null;if(t===void 0)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:I()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:b()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}async function p(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(f(),e)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,Q.jsxs)(`div`,{className:`oc-access__row`,children:[(0,Q.jsx)(W,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":S({name:e.name})}),(0,Q.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,Q.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":x(),title:x(),children:(0,Q.jsx)(G,{size:14,fill:`currentColor`})}):(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:me()}):null,u?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":T({name:e.name}),title:T({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,Q.jsx)(je,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,Q.jsxs)(Le,{value:``,onValueChange:e=>void h(e),children:[(0,Q.jsx)(Re,{size:`sm`,className:`oc-access__search`,children:(0,Q.jsx)(qe,{placeholder:m()})}),(0,Q.jsx)(Ge,{children:l.map(e=>(0,Q.jsx)(Je,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,Q.jsx)(`p`,{className:`oc-access__hint`,children:_()}):null:null]})}export{at as GroupsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$w as r,AC as i,Aw as a,BC as o,Bw as s,Cw as c,Dw as l,Ew as u,FC as d,Fo as f,Fw as p,GC as m,Gw as h,HA as g,HC as _,Hw as v,IC as y,IL as b,Io as x,Iw as ee,JC as S,Jw as C,KC as w,Kw as T,LC as te,Lo as E,Lw as ne,MC as D,Mw as re,NC as O,Nw as ie,Ow as ae,PC as oe,Pw as se,QC as ce,Qw as le,RC as ue,RL as k,Ro as de,Rw as fe,Sw as pe,Sy as me,Tw as A,UC as he,Uw as ge,VA as j,VC as _e,Vw as ve,WC as ye,Ww as be,XC as xe,Xw as Se,YC as Ce,Yw as we,ZC as Te,Zw as Ee,_T as De,_w as Oe,aT as ke,aw as Ae,bw as je,cT as Me,cw as Ne,dT as Pe,dw as Fe,eT as Ie,ew as M,fT as Le,fr as Re,fw as ze,gT as Be,gw as Ve,hT as He,hw as Ue,iT as We,iw as Ge,jC as Ke,jw as qe,kw as Je,lT as Ye,lw as Xe,mT as Ze,mr as Qe,mw as $e,nT as et,nw as tt,oT as nt,ow as rt,pT as it,pr as at,pw as ot,qC as st,qw as ct,rT as lt,rw as N,sT as ut,sw as dt,t as P,tT as ft,tw as pt,uT as mt,uw as ht,vT as gt,vw as _t,ww as vt,xw as yt,xy as bt,yT as xt,yw as St,zC as Ct,zL as F,zw as wt}from"./api-EsnGI4EC.js";import{a as Tt,c as Et}from"./FieldLabel-2xG6-0gZ.js";import{t as I}from"./button-CZ9WPf0m.js";import{Bt as Dt,Dt as L,P as R,Rt as Ot,Z as kt,_ as At,_t as z,bt as B,dt as V,ft as H,gt as U,ht as jt,jt as W,pt as Mt,ut as G,vt as K,xt as q,yt as J,zt as Nt}from"./index-CsdodIca.js";import{t as Pt}from"./DataTableShell-BYhMdaSl.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-DCHBE54n.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport: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=F(P.admin.listInstances,{}),t=F(P.agents.listAllInstanceAgents,{}),n=k(P.admin.upsertInstance),i=k(P.admin.deleteInstance),a=L(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(Q),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[m,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null);async function b(){try{await n({instanceId:_??void 0,name:c.name,gatewayUrl:c.gatewayUrl,bridgeUrl:c.bridgeUrl||void 0,displayName:c.displayName||void 0,kind:c.kind,transport:c.kind===`hermes`?c.transport:void 0,gatewayVersion:c.gatewayVersion||void 0,gatewayHttpUrl:c.gatewayHttpUrl||void 0,streamTransport:c.streamTransport}),l(Q),y(null),s(!1)}catch(e){a.error(De(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Be(),(0,Z.jsx)(`strong`,{children:He()}),Ze()]}),(0,Z.jsx)(Pt,{title:it(),rows:e,addLabel:Le(),onAdd:()=>{y(null),l(Q),s(!0)},emptyHint:Pe(),columns:[{header:mt(),cell:e=>e.name,sort:e=>e.name},{header:Ye(),cell:e=>(0,Z.jsx)(G,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Me(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:ut(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:xt(),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)(G,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Ke():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:lt(),onSelect:()=>{y(e._id),l(Bt(e)),s(!0)}},{label:gt(),onSelect:()=>d(e.name)},{label:v(),onSelect:()=>g(e)},{label:nt(),onSelect:()=>p(e)},{label:ke(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:ke(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,Z.jsx)(At,{open:o,onOpenChange:s,title:_?et():We(),description:Ie(),canSubmit:!!(c.name&&c.gatewayUrl),onSubmit:b,submitLabel:r(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:le(),children:[(0,Z.jsx)(W,{value:c.name,disabled:_!==null,onChange:e=>l({...c,name:e.target.value})}),_?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ft()}):null]}),(0,Z.jsx)($,{label:Ee(),children:(0,Z.jsxs)(z,{value:c.kind,onValueChange:e=>l({...c,kind:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(q,{})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(J,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(J,{value:`hermes`,children:`Hermes`})]})]})}),c.kind===`hermes`?(0,Z.jsx)($,{label:Qe(),children:(0,Z.jsxs)(z,{value:c.transport,onValueChange:e=>l({...c,transport:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(q,{})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(J,{value:`ws`,children:at()}),(0,Z.jsx)(J,{value:`rest`,children:Re()})]})]})}):null,(0,Z.jsx)($,{label:Se(),children:(0,Z.jsx)(W,{value:c.gatewayUrl,onChange:e=>l({...c,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:we(),children:(0,Z.jsx)(W,{value:c.bridgeUrl,placeholder:C(),onChange:e=>l({...c,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:ct(),children:(0,Z.jsx)(W,{value:c.displayName,onChange:e=>l({...c,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:me(),children:[(0,Z.jsxs)(z,{value:c.streamTransport,onValueChange:e=>l({...c,streamTransport:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(q,{})}),(0,Z.jsx)(K,{children:Et.map(e=>(0,Z.jsx)(J,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:bt()})]}),(0,Z.jsx)($,{label:T(),children:(0,Z.jsx)(W,{value:c.gatewayVersion,placeholder:h(),onChange:e=>l({...c,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:be(),children:(0,Z.jsx)(W,{value:c.gatewayHttpUrl,placeholder:ge(),onChange:e=>l({...c,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:u,open:u!==null,onOpenChange:e=>{e||d(null)}}),f?(0,Z.jsx)(Ft,{instance:f,onClose:()=>p(null)},f._id):null,m?(0,Z.jsx)(Ht,{instance:m,onClose:()=>g(null)},m._id):null]})}function Ht({instance:e,onClose:t}){let n=F(P.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)(V,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(H,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(jt,{children:[(0,Z.jsx)(U,{children:ve({instance:e.displayName??e.name})}),(0,Z.jsx)(Mt,{children:s()})]}),(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=b(P.instanceSync.forceInstanceSync),n=L(),[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(je());break;case`no_agents`:n.success(_t());break;case`no_bridge_url`:n.error(Oe());break;case`deploy_misconfigured`:n.error(Ve());break;case`unauthorized`:n.error($e());break;case`not_served`:n.error(ot());break;default:n.error(Ue());break}}catch(e){n.error(St(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}),(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?yt():pe()})})]})}function Wt({instance:e}){let t=F(P.bridgeAuth.listBridgeAuthStatus,{}),n=b(P.bridgeAuth.mintBridgeSecret),r=k(P.bridgeAuth.revokeBridgeSecret),i=L(),[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 m(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(Ae(),e)}finally{o(!1)}}}async function h(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(rt())}catch(e){i.error(Ae(),e)}finally{o(!1)}}}async function _(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Fe(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ht()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(G,{variant:f?`outline`:`secondary`,children:f?`${ee()} · ${d.prefix}…${d.lastFour}`:p()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void m(),disabled:a,children:f?Ne():Xe()}),f?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:dt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Ge()}),(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 _(),children:l?g():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:N()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=b(P.instanceSecrets.setInstanceSecret),i=k(P.instanceSecrets.clearInstanceSecret),o=b(P.deviceIdentity.generateDeviceIdentity),s=L(),[d,f]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(!1),S=n!==null,C=t===`deviceIdentity`,w=t===`token`?wt():t===`deviceIdentity`?fe():ne();async function T(){if(!(!d.trim()||m)){h(!0);try{await r({instanceId:e,field:t,plaintext:d}),f(``),v(null),x(!1),s.success(a())}catch(e){s.error(Je(),e)}finally{h(!1)}}}async function te(){if(!m){h(!0);try{await i({instanceId:e,field:t}),v(null),x(!1),s.success(ae())}catch(e){s.error(Je(),e)}finally{h(!1)}}}async function E(){if(!m){h(!0);try{v(await o({instanceId:e})),x(!1),s.success(A())}catch(e){s.error(c(),e)}finally{h(!1)}}}let D=_?`openclaw devices approve ${_.id}`:``;async function O(){if(D)try{await navigator.clipboard.writeText(D),x(!0)}catch{}}return(0,Z.jsxs)($,{label:w,children:[C?(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)(G,{variant:S?`outline`:`secondary`,children:S?ee():p()}),(0,Z.jsx)(W,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:d,placeholder:S?ie():se(),onChange:e=>f(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void T(),disabled:m||d.trim().length===0,children:re()}),C?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void E(),disabled:m,children:l()}):null,S?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void te(),disabled:m,children:qe()}):null]})]}),_?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:A()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:vt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:D}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void O(),children:y?g():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{v(null),x(!1)},children:N()})]}):null]})}var Kt={conversational:w,documentary:ye,summarizer:de,curator:x},qt={conversational:m,documentary:he,summarizer:E,curator:f},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:xe()}),t.map(e=>(0,Z.jsx)(G,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(Ot,{children:[(0,Z.jsx)(Dt,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Ce()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:S()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:st()}),(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)(R,{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 r=F(P.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=k(P.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=k(P.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=k(P.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),l=k(P.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),u=k(P.agents.removeInstanceAgent),f=kt(),p=L();async function m(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){p.error(M(),e)}}async function h(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){p.error(M(),e)}}async function g(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(M(),e)}}async function v(t,n){if(e&&await f({title:o({name:n}),description:Ct(),confirmLabel:ue(),destructive:!0}))try{await u({instanceName:e,agentId:t}),p.success(te())}catch(e){p.error(M(),e)}}return(0,Z.jsx)(V,{open:t,onOpenChange:n,children:(0,Z.jsxs)(H,{className:`oc-access`,children:[(0,Z.jsxs)(jt,{children:[(0,Z.jsx)(U,{children:tt({name:e??``})}),(0,Z.jsx)(Mt,{children:pt()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:y()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?d():r.discovery.lastPollOk?oe():O({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:D()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,a=r.defaultAgentId===t.agentId,o=t.displayName??t.agentId,s=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)(R,{checked:t.enabled,disabled:n,"aria-label":o,onCheckedChange:e=>void m(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:o,children:[t.emoji?`${t.emoji} `:``,o]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{variant:`outline`,className:`oc-access__gone`,children:i()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,o),children:_e()})]}):a?(0,Z.jsx)(G,{variant:`default`,children:Ke()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void h(t.agentId),children:_()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:s,onToggle:e=>void g(t.agentId,e,s)}):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(M(),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:ce(),"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{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$w as r,AC as i,Aw as a,BC as o,Bw as s,Cw as c,Dw as l,Ew as u,FC as d,Fo as f,Fw as p,GC as m,Gw as h,HA as g,HC as _,Hw as v,IC as y,IL as b,Io as x,Iw as ee,JC as S,Jw as C,KC as w,Kw as T,LC as te,Lo as E,Lw as ne,MC as D,Mw as re,NC as O,Nw as ie,Ow as ae,PC as oe,Pw as se,QC as ce,Qw as le,RC as ue,RL as k,Ro as de,Rw as fe,Sw as pe,Sy as me,Tw as A,UC as he,Uw as ge,VA as j,VC as _e,Vw as ve,WC as ye,Ww as be,XC as xe,Xw as Se,YC as Ce,Yw as we,ZC as Te,Zw as Ee,_T as De,_w as Oe,aT as ke,aw as Ae,bw as je,cT as Me,cw as Ne,dT as Pe,dw as Fe,eT as Ie,ew as M,fT as Le,fr as Re,fw as ze,gT as Be,gw as Ve,hT as He,hw as Ue,iT as We,iw as Ge,jC as Ke,jw as qe,kw as Je,lT as Ye,lw as Xe,mT as Ze,mr as Qe,mw as $e,nT as et,nw as tt,oT as nt,ow as rt,pT as it,pr as at,pw as ot,qC as st,qw as ct,rT as lt,rw as N,sT as ut,sw as dt,t as P,tT as ft,tw as pt,uT as mt,uw as ht,vT as gt,vw as _t,ww as vt,xw as yt,xy as bt,yT as xt,yw as St,zC as Ct,zL as F,zw as wt}from"./api-EsnGI4EC.js";import{a as Tt,c as Et}from"./FieldLabel-D_--lTMz.js";import{t as I}from"./button-CZ9WPf0m.js";import{Bt as Dt,Dt as L,P as R,Rt as Ot,Z as kt,_ as At,_t as z,bt as B,dt as V,ft as H,gt as U,ht as jt,jt as W,pt as Mt,ut as G,vt as K,xt as q,yt as J,zt as Nt}from"./index-DdOFgMFG.js";import{t as Pt}from"./DataTableShell-D5Nb8D27.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-BhAxJtIU.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport: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=F(P.admin.listInstances,{}),t=F(P.agents.listAllInstanceAgents,{}),n=k(P.admin.upsertInstance),i=k(P.admin.deleteInstance),a=L(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(Q),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),[m,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null);async function b(){try{await n({instanceId:_??void 0,name:c.name,gatewayUrl:c.gatewayUrl,bridgeUrl:c.bridgeUrl||void 0,displayName:c.displayName||void 0,kind:c.kind,transport:c.kind===`hermes`?c.transport:void 0,gatewayVersion:c.gatewayVersion||void 0,gatewayHttpUrl:c.gatewayHttpUrl||void 0,streamTransport:c.streamTransport}),l(Q),y(null),s(!1)}catch(e){a.error(De(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Be(),(0,Z.jsx)(`strong`,{children:He()}),Ze()]}),(0,Z.jsx)(Pt,{title:it(),rows:e,addLabel:Le(),onAdd:()=>{y(null),l(Q),s(!0)},emptyHint:Pe(),columns:[{header:mt(),cell:e=>e.name,sort:e=>e.name},{header:Ye(),cell:e=>(0,Z.jsx)(G,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Me(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:ut(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:xt(),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)(G,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Ke():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:lt(),onSelect:()=>{y(e._id),l(Bt(e)),s(!0)}},{label:gt(),onSelect:()=>d(e.name)},{label:v(),onSelect:()=>g(e)},{label:nt(),onSelect:()=>p(e)},{label:ke(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:ke(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,Z.jsx)(At,{open:o,onOpenChange:s,title:_?et():We(),description:Ie(),canSubmit:!!(c.name&&c.gatewayUrl),onSubmit:b,submitLabel:r(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:le(),children:[(0,Z.jsx)(W,{value:c.name,disabled:_!==null,onChange:e=>l({...c,name:e.target.value})}),_?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ft()}):null]}),(0,Z.jsx)($,{label:Ee(),children:(0,Z.jsxs)(z,{value:c.kind,onValueChange:e=>l({...c,kind:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(q,{})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(J,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(J,{value:`hermes`,children:`Hermes`})]})]})}),c.kind===`hermes`?(0,Z.jsx)($,{label:Qe(),children:(0,Z.jsxs)(z,{value:c.transport,onValueChange:e=>l({...c,transport:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(q,{})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(J,{value:`ws`,children:at()}),(0,Z.jsx)(J,{value:`rest`,children:Re()})]})]})}):null,(0,Z.jsx)($,{label:Se(),children:(0,Z.jsx)(W,{value:c.gatewayUrl,onChange:e=>l({...c,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:we(),children:(0,Z.jsx)(W,{value:c.bridgeUrl,placeholder:C(),onChange:e=>l({...c,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:ct(),children:(0,Z.jsx)(W,{value:c.displayName,onChange:e=>l({...c,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:me(),children:[(0,Z.jsxs)(z,{value:c.streamTransport,onValueChange:e=>l({...c,streamTransport:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(q,{})}),(0,Z.jsx)(K,{children:Et.map(e=>(0,Z.jsx)(J,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:bt()})]}),(0,Z.jsx)($,{label:T(),children:(0,Z.jsx)(W,{value:c.gatewayVersion,placeholder:h(),onChange:e=>l({...c,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:be(),children:(0,Z.jsx)(W,{value:c.gatewayHttpUrl,placeholder:ge(),onChange:e=>l({...c,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:u,open:u!==null,onOpenChange:e=>{e||d(null)}}),f?(0,Z.jsx)(Ft,{instance:f,onClose:()=>p(null)},f._id):null,m?(0,Z.jsx)(Ht,{instance:m,onClose:()=>g(null)},m._id):null]})}function Ht({instance:e,onClose:t}){let n=F(P.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)(V,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(H,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(jt,{children:[(0,Z.jsx)(U,{children:ve({instance:e.displayName??e.name})}),(0,Z.jsx)(Mt,{children:s()})]}),(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=b(P.instanceSync.forceInstanceSync),n=L(),[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(je());break;case`no_agents`:n.success(_t());break;case`no_bridge_url`:n.error(Oe());break;case`deploy_misconfigured`:n.error(Ve());break;case`unauthorized`:n.error($e());break;case`not_served`:n.error(ot());break;default:n.error(Ue());break}}catch(e){n.error(St(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ze()}),(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?yt():pe()})})]})}function Wt({instance:e}){let t=F(P.bridgeAuth.listBridgeAuthStatus,{}),n=b(P.bridgeAuth.mintBridgeSecret),r=k(P.bridgeAuth.revokeBridgeSecret),i=L(),[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 m(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(Ae(),e)}finally{o(!1)}}}async function h(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(rt())}catch(e){i.error(Ae(),e)}finally{o(!1)}}}async function _(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,Z.jsxs)($,{label:Fe(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ht()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(G,{variant:f?`outline`:`secondary`,children:f?`${ee()} · ${d.prefix}…${d.lastFour}`:p()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void m(),disabled:a,children:f?Ne():Xe()}),f?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:dt()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Ge()}),(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 _(),children:l?g():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:N()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=b(P.instanceSecrets.setInstanceSecret),i=k(P.instanceSecrets.clearInstanceSecret),o=b(P.deviceIdentity.generateDeviceIdentity),s=L(),[d,f]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(!1),S=n!==null,C=t===`deviceIdentity`,w=t===`token`?wt():t===`deviceIdentity`?fe():ne();async function T(){if(!(!d.trim()||m)){h(!0);try{await r({instanceId:e,field:t,plaintext:d}),f(``),v(null),x(!1),s.success(a())}catch(e){s.error(Je(),e)}finally{h(!1)}}}async function te(){if(!m){h(!0);try{await i({instanceId:e,field:t}),v(null),x(!1),s.success(ae())}catch(e){s.error(Je(),e)}finally{h(!1)}}}async function E(){if(!m){h(!0);try{v(await o({instanceId:e})),x(!1),s.success(A())}catch(e){s.error(c(),e)}finally{h(!1)}}}let D=_?`openclaw devices approve ${_.id}`:``;async function O(){if(D)try{await navigator.clipboard.writeText(D),x(!0)}catch{}}return(0,Z.jsxs)($,{label:w,children:[C?(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)(G,{variant:S?`outline`:`secondary`,children:S?ee():p()}),(0,Z.jsx)(W,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:d,placeholder:S?ie():se(),onChange:e=>f(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void T(),disabled:m||d.trim().length===0,children:re()}),C?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void E(),disabled:m,children:l()}):null,S?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void te(),disabled:m,children:qe()}):null]})]}),_?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:A()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:vt()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:D}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void O(),children:y?g():j()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{v(null),x(!1)},children:N()})]}):null]})}var Kt={conversational:w,documentary:ye,summarizer:de,curator:x},qt={conversational:m,documentary:he,summarizer:E,curator:f},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:xe()}),t.map(e=>(0,Z.jsx)(G,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(Ot,{children:[(0,Z.jsx)(Dt,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Ce()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:S()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:st()}),(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)(R,{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 r=F(P.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=k(P.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=k(P.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=k(P.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),l=k(P.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(P.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(P.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),u=k(P.agents.removeInstanceAgent),f=kt(),p=L();async function m(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){p.error(M(),e)}}async function h(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){p.error(M(),e)}}async function g(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(M(),e)}}async function v(t,n){if(e&&await f({title:o({name:n}),description:Ct(),confirmLabel:ue(),destructive:!0}))try{await u({instanceName:e,agentId:t}),p.success(te())}catch(e){p.error(M(),e)}}return(0,Z.jsx)(V,{open:t,onOpenChange:n,children:(0,Z.jsxs)(H,{className:`oc-access`,children:[(0,Z.jsxs)(jt,{children:[(0,Z.jsx)(U,{children:tt({name:e??``})}),(0,Z.jsx)(Mt,{children:pt()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:y()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?d():r.discovery.lastPollOk?oe():O({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:D()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,a=r.defaultAgentId===t.agentId,o=t.displayName??t.agentId,s=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)(R,{checked:t.enabled,disabled:n,"aria-label":o,onCheckedChange:e=>void m(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:o,children:[t.emoji?`${t.emoji} `:``,o]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{variant:`outline`,className:`oc-access__gone`,children:i()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void v(t.agentId,o),children:_e()})]}):a?(0,Z.jsx)(G,{variant:`default`,children:Ke()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void h(t.agentId),children:_()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:s,onToggle:e=>void g(t.agentId,e,s)}):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(M(),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:ce(),"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};
|