@lacneu/atrium 0.51.0 → 0.52.0

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.
Files changed (37) hide show
  1. package/dist/assets/{AccessTab-BTTUfIwc.js → AccessTab-CTW_nnWZ.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-BQlL-4N9.js → AdvancedFilter-CKwZSjrh.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-By3Jzopm.js → AgentFilesTab-q9XSjz3-.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-Cs6vlfDv.js → AnomaliesTab-DRfDR0J5.js} +1 -1
  5. package/dist/assets/{AuditTab-BOu6pgTB.js → AuditTab-Dy6MHYXk.js} +1 -1
  6. package/dist/assets/{BridgeTab-DFpunFsv.js → BridgeTab-BYuXlyxy.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-DkHZTknY.js → ChatDefaultsTab-Dcfzk7xu.js} +1 -1
  8. package/dist/assets/{DataTableShell-KGrtOG5M.js → DataTableShell-DtJr2ebT.js} +1 -1
  9. package/dist/assets/{DetailChips-C2LFFpNg.js → DetailChips-CXG_QPSx.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-D34MEu6C.js → FeedbacksTab-WlCA0v5O.js} +1 -1
  11. package/dist/assets/{FieldLabel-CKVYl95W.js → FieldLabel-DOYQdxs6.js} +1 -1
  12. package/dist/assets/{FilesTab-ByKXXey8.js → FilesTab-DQ9pHjeQ.js} +1 -1
  13. package/dist/assets/{FilterBar-BVVVO1_O.js → FilterBar-Csl1r1c5.js} +1 -1
  14. package/dist/assets/{GroupsTab-CJUI6gQ9.js → GroupsTab-i_p1qxDl.js} +1 -1
  15. package/dist/assets/{InstancesTab-Cb_2msXj.js → InstancesTab-C2vgcYdE.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-B9Nkc7-l.js → IntegrationsTab-U_Dml2lf.js} +1 -1
  17. package/dist/assets/{KpiTab-B6SqslSj.js → KpiTab-D8BAnPiK.js} +1 -1
  18. package/dist/assets/{PreferencesTab-BdvOFp2E.js → PreferencesTab-BktDAi8P.js} +1 -1
  19. package/dist/assets/{PromptInjectionsTab-CgAFhOn5.js → PromptInjectionsTab-Bk59PWzu.js} +1 -1
  20. package/dist/assets/{RolesTab-CtV113pW.js → RolesTab-DVdsW49x.js} +1 -1
  21. package/dist/assets/{ServiceAccountsTab-Bu_j0kUL.js → ServiceAccountsTab-ZsiwQmeJ.js} +1 -1
  22. package/dist/assets/{SubAgentReportsTab-G_s4_aPf.js → SubAgentReportsTab-Ce0Y_sVn.js} +1 -1
  23. package/dist/assets/{ThemeShowroom-CbU-xJra.js → ThemeShowroom-BRl6NHy2.js} +1 -1
  24. package/dist/assets/{TimeRangePicker-NSOkx3C0.js → TimeRangePicker-BeZLlC4Y.js} +1 -1
  25. package/dist/assets/{TracesTab-Wo-rxO1v.js → TracesTab-CBN2vo1w.js} +1 -1
  26. package/dist/assets/{UsersTab-DO7Wa8iJ.js → UsersTab-C_K650wH.js} +1 -1
  27. package/dist/assets/{VoiceTab-ilUT53Ds.js → VoiceTab-b4ZPVB2F.js} +1 -1
  28. package/dist/assets/compatView-CONPJXEW.js +1 -0
  29. package/dist/assets/{highlighted-body-OFNGDK62-BOjjbbd6.js → highlighted-body-OFNGDK62-CJz5HJX2.js} +1 -1
  30. package/dist/assets/{index-DBQ43N4_.js → index-4Peu865E.js} +5 -5
  31. package/dist/assets/mermaid-GHXKKRXX-B47aXknL.js +1 -0
  32. package/dist/assets/{pdf-D7AA0FY6.js → pdf-C1wt9cpf.js} +1 -1
  33. package/dist/assets/{tabs-BJyz65LR.js → tabs-0f19le6d.js} +1 -1
  34. package/dist/index.html +1 -1
  35. package/package.json +1 -1
  36. package/dist/assets/compatView-S4X8HKXY.js +0 -1
  37. package/dist/assets/mermaid-GHXKKRXX-CXCdU_oF.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{E as r,OM as i,_d as a,ad as o,cd as s,dd as c,fd as l,gd as u,hd as d,id as f,ld as p,md as m,od as h,pd as g,rd as _,sd as v,ud as y,yM as b}from"./dist-HBBi9Y25.js";import{C as x,S,b as C,ct as w,w as T,x as E}from"./index-DBQ43N4_.js";var D=t(e(),1);function O(e){return e===`user`?v():e===`all`?h():o({group:e.group})}function k(e){return e===`common`?f():e===`owner`?_():o({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=i(r.admin.listUsers,{}),[t,n]=(0,D.useState)(``),o=i(r.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:a()}),(0,A.jsxs)(C,{value:t,onValueChange:n,children:[(0,A.jsx)(x,{size:`sm`,"aria-label":u(),children:(0,A.jsx)(T,{placeholder:u()})}),(0,A.jsx)(E,{children:(e??[]).map(e=>(0,A.jsx)(S,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):o===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(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:m()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:o.user.label}),(0,A.jsx)(w,{variant:`secondary`,children:o.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),o.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:o.groups.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:l()}),o.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:o.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(w,{variant:`default`,children:s()}):null,(0,A.jsx)(w,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(w,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:c()}),o.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:o.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(w,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:y()}),o.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:o.permissions.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{E as r,OM as i,_d as a,ad as o,cd as s,dd as c,fd as l,gd as u,hd as d,id as f,ld as p,md as m,od as h,pd as g,rd as _,sd as v,ud as y,yM as b}from"./dist-HBBi9Y25.js";import{C as x,S,b as C,ct as w,w as T,x as E}from"./index-4Peu865E.js";var D=t(e(),1);function O(e){return e===`user`?v():e===`all`?h():o({group:e.group})}function k(e){return e===`common`?f():e===`owner`?_():o({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=i(r.admin.listUsers,{}),[t,n]=(0,D.useState)(``),o=i(r.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:a()}),(0,A.jsxs)(C,{value:t,onValueChange:n,children:[(0,A.jsx)(x,{size:`sm`,"aria-label":u(),children:(0,A.jsx)(T,{placeholder:u()})}),(0,A.jsx)(E,{children:(e??[]).map(e=>(0,A.jsx)(S,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):o===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(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:m()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:o.user.label}),(0,A.jsx)(w,{variant:`secondary`,children:o.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),o.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:o.groups.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:l()}),o.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:o.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(w,{variant:`default`,children:s()}):null,(0,A.jsx)(w,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(w,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:c()}),o.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:o.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(w,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:y()}),o.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:o.permissions.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ap as r,Dp as i,Ep as a,Op as o,Tp as s,kp as c,wp as l}from"./dist-HBBi9Y25.js";import{i as u}from"./dist-DBet7oNc.js";import{t as d}from"./x-DBKGK4o_.js";import{t as f}from"./button-b04wLuGq.js";import{C as p,It as m,S as h,b as g,lt as _,w as v,x as y}from"./index-DBQ43N4_.js";import{r as b}from"./TimeRangePicker-NSOkx3C0.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:r()},{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 r=(0,x.useRef)(t),w=!!(r.current&&r.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(r.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}),c(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(g,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-40`,children:(0,S.jsx)(v,{placeholder:i()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(h,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(g,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-28`,children:(0,S.jsx)(v,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(h,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(_,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:a()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":s(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(m,{}),l()]})]}):null]})}export{D as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ap as r,Dp as i,Ep as a,Op as o,Tp as s,kp as c,wp as l}from"./dist-HBBi9Y25.js";import{i as u}from"./dist-DBet7oNc.js";import{t as d}from"./x-DBKGK4o_.js";import{t as f}from"./button-b04wLuGq.js";import{C as p,It as m,S as h,b as g,lt as _,w as v,x as y}from"./index-4Peu865E.js";import{r as b}from"./TimeRangePicker-BeZLlC4Y.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:r()},{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 r=(0,x.useRef)(t),w=!!(r.current&&r.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(r.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}),c(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(g,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-40`,children:(0,S.jsx)(v,{placeholder:i()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(h,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(g,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(p,{size:`sm`,className:`w-28`,children:(0,S.jsx)(v,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(h,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(_,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:a()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":s(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(m,{}),l()]})]}):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{$r as r,Ac as i,Bc as a,Br as o,Cc as s,Cr as c,DM as l,Dc as u,E as d,Ec as f,Er as p,Fc as m,Fl as h,Fr as g,Gc as _,Gr as v,Hc as y,Hr as b,Ic as x,Ir as S,Jc as C,Jr as w,Kc as T,Kr as E,Lc as D,Lr as O,Mc as k,Nc as A,Nl as ee,Nr as j,OM as M,Oc as N,Pc as te,Pr as P,Qc as F,Qr as I,Rc as L,Rr as R,Sr as z,TM as B,Tc as ne,Tr as V,Uc as H,Ur as U,Vc as re,Vr as ie,Wc as ae,Wr as oe,Xc as se,Xr as ce,Yc as le,Yr as ue,Zc as de,Zr as fe,br as pe,jc as me,kc as he,qc as ge,qr as _e,tD as ve,wc as ye,wr as be,xM as W,xr as xe,yM as G,zc as Se,zr as Ce}from"./dist-HBBi9Y25.js";import{t as K}from"./button-b04wLuGq.js";import{At as q,C as we,G as Te,H as Ee,J as De,K as Oe,S as ke,U as Ae,W as je,Y as Me,b as Ne,ct as Pe,dt as Fe,ft as Ie,ht as Le,mt as Re,q as ze,ut as Be,w as Ve,x as He,xt as Ue,y as We,z as J}from"./index-DBQ43N4_.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-S4X8HKXY.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(`
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$r as r,Ac as i,Bc as a,Br as o,Cc as s,Cr as c,DM as l,Dc as u,E as d,Ec as f,Er as p,Fc as m,Fl as h,Fr as g,Gc as _,Gr as v,Hc as y,Hr as b,Ic as x,Ir as S,Jc as C,Jr as w,Kc as T,Kr as E,Lc as D,Lr as O,Mc as k,Nc as A,Nl as ee,Nr as j,OM as M,Oc as N,Pc as te,Pr as P,Qc as F,Qr as I,Rc as L,Rr as R,Sr as z,TM as B,Tc as ne,Tr as V,Uc as H,Ur as U,Vc as re,Vr as ie,Wc as ae,Wr as oe,Xc as se,Xr as ce,Yc as le,Yr as ue,Zc as de,Zr as fe,br as pe,jc as me,kc as he,qc as ge,qr as _e,tD as ve,wc as ye,wr as be,xM as W,xr as xe,yM as G,zc as Se,zr as Ce}from"./dist-HBBi9Y25.js";import{t as K}from"./button-b04wLuGq.js";import{At as q,C as we,G as Te,H as Ee,J as De,K as Oe,S as ke,U as Ae,W as je,Y as Me,b as Ne,ct as Pe,dt as Fe,ft as Ie,ht as Le,mt as Re,q as ze,ut as Be,w as Ve,x as He,xt as Ue,y as We,z as J}from"./index-4Peu865E.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-CONPJXEW.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=M(d.me.getMe,{host:Ue}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=M(d.admin.listInstances,e!==void 0&&t?{}:`skip`),[i,o]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!t||!r||r.length===0||(!i||!r.some(e=>e.name===i))&&o(r[0].name)},[t,r,i]);let s=M(d.agents.listAgentsForInstance,t&&i?{instanceName:i}:`skip`),c=M(d.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),l=(0,Y.useMemo)(()=>{if(e!==void 0){if(t)return i===null||s===void 0?r!==void 0&&r.length===0?[]:void 0:s.agents.map(e=>({instanceName:i,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(c!==void 0)return c.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,i,s,r,c]),[u,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!l||l.length===0||(!u||!l.some(e=>$(e)===u))&&f($(l[0]))},[l,u]);let p=l?.find(e=>$(e)===u)??null,m=B(d.agentFiles.listAgentFiles),[h,g]=(0,Y.useState)({status:`idle`}),v=p?.instanceName??null,b=p?.agentId??null,x=M(d.compat.forInstance,n&&v!==null?{instanceName:v}:`skip`),S=n&&v!==null?We(x,`agentFiles`):null,E=S===null?!1:S===`loading`?null:S.blocked,D=(0,Y.useCallback)(async()=>{if(!(v===null||b===null)){g({status:`loading`});try{g({status:`done`,files:(await m({instanceName:v,agentId:b})).files})}catch{g({status:`error`})}}},[m,v,b]);(0,Y.useEffect)(()=>{E===!1&&D()},[D,E]);let[O,k]=(0,Y.useState)(null),A=M(d.agentFileCuration.listCurations,t&&v!==null&&b!==null?{instanceName:v,agentId:b}:`skip`),j=M(d.agentFileCuration.curationSettings,t&&v!==null?{instanceName:v}:`skip`),N=B(d.agentFileCuration.requestCuration),[te,P]=(0,Y.useState)(null),[I,L]=(0,Y.useState)(null),{toast:R}=J(),z=(0,Y.useMemo)(()=>{let e=new Map;for(let t of A??[])e.has(t.name)||e.set(t.name,t);return e},[A]),ne=(0,Y.useCallback)(async e=>{if(!(v===null||b===null)){P(e);try{let t=await N({instanceName:v,agentId:b,name:e,trigger:`manual`});t.ok?R({title:ce(),variant:`success`}):R({title:ue({reason:t.reason??`unknown`}),variant:`error`})}catch{R({title:w(),variant:`error`})}finally{P(null)}}},[N,v,b,R]),V=W(),U=(0,Y.useMemo)(()=>new Intl.NumberFormat(V,{maximumFractionDigits:0}),[V]);return e===void 0||l===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:F()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(Ne,{value:i??``,onValueChange:e=>o(e),children:[(0,Q.jsx)(we,{size:`sm`,"aria-label":de(),children:(0,Q.jsx)(Ve,{})}),(0,Q.jsx)(He,{children:(r??[]).map(e=>(0,Q.jsx)(ke,{value:e.name,children:e.name},e.name))})]}):null,l.length>0?(0,Q.jsxs)(Ne,{value:u??``,onValueChange:e=>f(e),children:[(0,Q.jsx)(we,{size:`sm`,"aria-label":se(),children:(0,Q.jsx)(Ve,{})}),(0,Q.jsx)(He,{children:l.map(e=>(0,Q.jsx)(ke,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:le()})]}),p===null?null:S===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):S!==null&&S.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(q,{size:14,"aria-hidden":!0}),` `,qe(S.gatewayVersion,S.provider)]}):h.status===`loading`||h.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):h.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ge(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void D(),children:ee()})]}):h.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:h.files.map(e=>{let n=Ye(e.size),r=n>=80;return(0,Q.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,Q.jsx)(Pe,{variant:`outline`,children:T()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:_({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:ae({pct:U.format(n)})}),r?(0,Q.jsx)(q,{size:14,className:`oc-afiles__warn`,"aria-label":H()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>k(e),children:t?re():a()}),t&&!e.missing?(0,Q.jsx)(nt,{curatable:Ke.includes(e.name),size:e.size??0,budget:j?.budgetChars??null,enabled:j?.enabled??!1,curation:z.get(e.name)??null,inFlight:te===e.name,onCurate:()=>void ne(e.name),onReview:e=>L(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:y({used:Z(Ze(h.files),V),total:Z(Je,V),pct:U.format(Xe(Ze(h.files)))})})]}),O&&p?(0,Q.jsx)(rt,{instanceName:p.instanceName,agentId:p.agentId,name:O.name,isAdmin:t,onClose:()=>k(null),onSaved:()=>void D()}):null,I?(0,Q.jsx)(it,{curationId:I,onClose:()=>L(null),onApplied:()=>{L(null),D()}}):null]})}function nt({curatable:e,size:t,budget:n,enabled:i,curation:a,inFlight:o,onCurate:s,onReview:c}){return a?.status===`proposed`?(0,Q.jsx)(K,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>c(a._id),children:I()}):o||a?.status===`dispatched`||a?.status===`applying`?(0,Q.jsx)(Pe,{variant:`outline`,className:`oc-afiles__curate-status`,children:fe()}):e&&i&&n!==null&&Ge(t,n)?(0,Q.jsx)(K,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:s,children:r()}):null}function rt({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:a,onSaved:o}){let c=B(d.agentFiles.getAgentFile),l=B(d.agentFiles.setAgentFile),p=J(),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(!1),[O,j]=(0,Y.useState)(!1),[M,P]=(0,Y.useState)(!1),F=(0,Y.useCallback)(async r=>{y(!1);try{let i=await c({instanceName:e,agentId:t,name:n});_({content:i.content,updatedAtMs:i.updatedAtMs}),r||S(i.content),j(!1)}catch{y(!0)}},[c,e,t,n]);(0,Y.useEffect)(()=>{F(!1)},[F]);async function I(){if(g!==null){E(!0),P(!1);try{await l({instanceName:e,agentId:t,name:n,content:b,baseUpdatedAtMs:g.updatedAtMs??void 0}),p.success(A({name:n})),o(),await F(!1)}catch(e){et(e)?j(!0):P(!0)}finally{E(!1)}}}let R=g!==null&&b!==g.content,z=(0,Y.useMemo)(()=>g===null?null:$e(g.content,b),[g,b]),V=b.length>X,H=W(),U=(0,Y.useMemo)(()=>new Intl.NumberFormat(H),[H]);return(0,Q.jsx)(Be,{open:!0,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(Fe,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Le,{children:Se({name:n})}),(0,Q.jsxs)(Ie,{children:[L({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,D()]})]})]}),v?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[me(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void F(!1),children:ee()})]}):g===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:b,readOnly:!r,spellCheck:!1,onChange:e=>S(e.target.value),"aria-label":Se({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:x()}),O?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[i(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void F(!0),children:he()})]}):null,M?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:k()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${V?` is-over`:``}`,children:m({count:U.format(b.length),max:U.format(X)})}),r?(0,Q.jsx)(K,{size:`sm`,disabled:!R||T||O,onClick:()=>w(!0),children:T?h():te()}):null]})]}),(0,Q.jsx)(Ee,{open:C,onOpenChange:w,children:(0,Q.jsxs)(Te,{children:[(0,Q.jsxs)(De,{children:[(0,Q.jsx)(Me,{children:N({name:n})}),(0,Q.jsx)(Oe,{children:u({agent:t})})]}),z?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:f({added:z.added,removed:z.removed})}),z.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:ne()}),z.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,z.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:ye()}),z.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(ze,{children:[(0,Q.jsx)(je,{children:ve()}),(0,Q.jsx)(Ae,{onClick:()=>void I(),children:s()})]})]})})]})})}function it({curationId:e,onClose:t,onApplied:n}){let r=M(d.agentFileCuration.getProposal,{curationId:e}),i=B(d.agentFileCuration.approveCuration),a=l(d.agentFileCuration.rejectCuration),{toast:s}=J(),[u,f]=(0,Y.useState)(null),[m,_]=(0,Y.useState)(!1),[y,x]=(0,Y.useState)(``),C=W(),T=(0,Y.useMemo)(()=>r?$e(r.beforeContent,r.proposedContent):null,[r]);async function D(){f(`approve`);try{let t=await i({curationId:e});t.ok?(s({title:_e(),variant:`success`}),n()):s({title:t.reason===`conflict`?v():oe({reason:t.reason??`unknown`}),variant:`error`})}catch{s({title:w(),variant:`error`})}finally{f(null)}}async function k(n){f(`reject`);try{let r=y.trim();(await a({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?s({title:n?xe():E(),variant:`success`}):s({title:ie(),variant:`error`}),t()}catch{s({title:w(),variant:`error`})}finally{f(null)}}return(0,Q.jsx)(Be,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Fe,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Le,{children:r?U({name:r.name}):G()}),(0,Q.jsx)(Ie,{children:b()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:G()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[o({before:Z(r.beforeSize,C),after:Z(r.proposedSize,C)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(q,{size:13,"aria-hidden":!0}),` `,Ce()]}):null]}),T?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:R({added:T.added,removed:T.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:pe({feedback:r.feedback})}):null,T&&T.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:j()}),(0,Q.jsx)(`ul`,{children:T.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:P()}),(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:O()}),(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:p()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:V(),value:y,onChange:e=>x(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`ghost`,onClick:()=>_(!1),disabled:u!==null,children:be()}),(0,Q.jsx)(K,{variant:`outline`,onClick:()=>void k(!1),disabled:u!==null,children:u===`reject`?h():c()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void k(!0),disabled:u!==null,children:u===`reject`?h():z()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`outline`,onClick:()=>_(!0),disabled:u!==null||r==null,children:S()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void D(),disabled:u!==null||r==null,children:u===`approve`?h():g()})]})]})})}export{tt as AgentFilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Ay as i,Cy as ee,DM as a,Dy as te,E as o,Ey as ne,Fy as s,Gv as c,Jv as l,Kv as u,My as d,Ny as f,OM as p,Oy as re,Py as m,Qv as h,Sy as ie,Ty as ae,Uv as g,Wv as _,Xv as v,Yv as y,Zv as oe,_y as se,ay as ce,by as le,cy as b,dy as x,ey as ue,fy as S,gy as de,hy as fe,iy as pe,jy as me,ky as he,ly as ge,my as _e,ny as ve,oy as C,py as w,qv as T,ry as E,sy as D,ty as O,uy as k,vy as A,wy as j,xy as M,yy as N}from"./dist-HBBi9Y25.js";import{B as P,C as F,S as I,Xt as ye,Yt as L,a as be,b as R,ct as z,dt as B,et as xe,ht as V,mt as H,r as Se,ut as U,w as W,x as G,xt as Ce,z as we}from"./index-DBQ43N4_.js";import{n as Te}from"./TimeRangePicker-NSOkx3C0.js";import{t as Ee}from"./FilterBar-BVVVO1_O.js";import{t as De}from"./DataTableShell-KGrtOG5M.js";import{t as K}from"./dispatchErrorInfo-Cs8_1qCQ.js";var q=t(e(),1),J=n(),Y=`__all__`,Oe=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function ke(e){return e===`open`?s():e===`acknowledged`?m():f()}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=ye({from:`/settings/anomalies`}),t=L({from:`/settings/anomalies`}),n=e.q??``,s=e.status===X?Y:e.status,c=e.severity??Y,l=e.kind??Y,[u,f]=(0,q.useState)(Y),m=Se(e.from,e.to),{from:g,to:_}=Te(m),v=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),y=e=>void t({search:t=>({...t,status:e===Y?X:e})}),T=e=>void t({search:t=>({...t,severity:e===Y?void 0:e})}),B=e=>void t({search:t=>({...t,kind:e===Y?void 0:e})}),V=e=>void t({search:t=>({...t,...be(e)})}),H=P(),U=we(),K=a(o.anomalies.resolveAnomaly),Z=(p(o.me.getMe,{host:Ce})?.permissions??[]).includes(`admin.manage`),Q=p(o.anomalies.listAnomalies,{limit:Ne,filter:{q:n||void 0,from:g,to:_,anomalyStatus:s===Y?void 0:s,severity:c===Y?void 0:c,source:u===Y?void 0:u,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!==``||s!==`open`||c!==Y||u!==Y||l!==Y||m.kind!==`relative`||m.from!==Me.from;function Be(){f(Y),t({search:{status:`open`},replace:!0})}async function Ve(e){if(await H({title:d(),description:(0,J.jsxs)(J.Fragment,{children:[me(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,i(),` `,(0,J.jsx)(`strong`,{children:he()}),`.`,` `,re()]}),confirmLabel:te()}))try{await K({anomalyId:e._id,status:`resolved`}),U.success(ne(),e.kind)}catch(e){U.error(ae(),e)}}async function He(e){try{await K({anomalyId:e._id,status:`acknowledged`}),U.success(j(),e.kind)}catch(e){U.error(ee(),e)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-admin__hint`,children:[ie(),` `,(0,J.jsx)(`strong`,{children:M()}),` `,le(),` `,(0,J.jsx)(`strong`,{children:N()}),` `,A(),` `,(0,J.jsx)(`strong`,{children:se()}),` `,de(),` `,(0,J.jsx)(`span`,{className:`oc-filter__window`,children:fe()})]}),(0,J.jsxs)(Ee,{q:n,onQChange:v,searchPlaceholder:_e(),timeRange:m,onTimeRangeChange:V,onReset:Be,canReset:ze,children:[(0,J.jsxs)(R,{value:s,onValueChange:y,children:[(0,J.jsx)(F,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:w()}),Oe.map(e=>(0,J.jsx)(I,{value:e.value,children:ke(e.value)},e.value))]})]}),(0,J.jsxs)(R,{value:c,onValueChange:T,children:[(0,J.jsx)(F,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{placeholder:S()})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:x()}),Ae.map(e=>(0,J.jsx)(I,{value:e,children:e},e))]})]}),(0,J.jsxs)(R,{value:u,onValueChange:f,children:[(0,J.jsx)(F,{size:`sm`,className:`w-32`,children:(0,J.jsx)(W,{placeholder:k()})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:ge()}),je.map(e=>(0,J.jsx)(I,{value:e,children:e},e))]})]}),(0,J.jsxs)(R,{value:l,onValueChange:B,children:[(0,J.jsx)(F,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{placeholder:b()})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:D()}),$.map(e=>(0,J.jsx)(I,{value:e,children:e},e))]})]})]}),(0,J.jsx)(De,{title:C(),rows:Q,emptyHint:s===`open`?ce():pe(),rowActions:e=>Z&&e.status===`open`?[{label:E(),onSelect:()=>void Ve(e)},{label:ve(),onSelect:()=>void He(e)}]:[],columns:[{header:O(),cell:e=>(0,J.jsx)(`span`,{className:`oc-traces__time`,children:xe(e.at)}),sort:e=>e.at},{header:b(),cell:e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:S(),cell:e=>(0,J.jsx)(Ie,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:ue(),cell:e=>(0,J.jsx)(Le,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:k(),cell:e=>(0,J.jsx)(z,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:r(),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:h(),cell:e=>(0,J.jsx)(Pe,{row:e}),sort:e=>e.evidence??null},{header:oe(),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=L();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:[`↗ `,v()]}):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:[`↗ `,v()]}):null]})}function Fe({row:e}){let[t,n]=(0,q.useState)(!1),r=p(o.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:[y(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,J.jsx)(U,{open:t,onOpenChange:n,children:(0,J.jsxs)(B,{className:`oc-anomaly__attachments-dialog`,children:[(0,J.jsx)(H,{children:(0,J.jsx)(V,{children:l()})}),r===void 0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:T()}):r.length===0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:u()}):(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)(z,{variant:`destructive`,children:c()}):e===`acknowledged`?(0,J.jsx)(z,{variant:`secondary`,children:_()}):(0,J.jsx)(z,{variant:`outline`,children:g()})}function Re(e){return e.length>8?e.slice(0,8):e}export{Z as AnomaliesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Ay as i,Cy as ee,DM as a,Dy as te,E as o,Ey as ne,Fy as s,Gv as c,Jv as l,Kv as u,My as d,Ny as f,OM as p,Oy as re,Py as m,Qv as h,Sy as ie,Ty as ae,Uv as g,Wv as _,Xv as v,Yv as y,Zv as oe,_y as se,ay as ce,by as le,cy as b,dy as x,ey as ue,fy as S,gy as de,hy as fe,iy as pe,jy as me,ky as he,ly as ge,my as _e,ny as ve,oy as C,py as w,qv as T,ry as E,sy as D,ty as O,uy as k,vy as A,wy as j,xy as M,yy as N}from"./dist-HBBi9Y25.js";import{B as P,C as F,S as I,Xt as ye,Yt as L,a as be,b as R,ct as z,dt as B,et as xe,ht as V,mt as H,r as Se,ut as U,w as W,x as G,xt as Ce,z as we}from"./index-4Peu865E.js";import{n as Te}from"./TimeRangePicker-BeZLlC4Y.js";import{t as Ee}from"./FilterBar-Csl1r1c5.js";import{t as De}from"./DataTableShell-DtJr2ebT.js";import{t as K}from"./dispatchErrorInfo-Cs8_1qCQ.js";var q=t(e(),1),J=n(),Y=`__all__`,Oe=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function ke(e){return e===`open`?s():e===`acknowledged`?m():f()}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=ye({from:`/settings/anomalies`}),t=L({from:`/settings/anomalies`}),n=e.q??``,s=e.status===X?Y:e.status,c=e.severity??Y,l=e.kind??Y,[u,f]=(0,q.useState)(Y),m=Se(e.from,e.to),{from:g,to:_}=Te(m),v=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),y=e=>void t({search:t=>({...t,status:e===Y?X:e})}),T=e=>void t({search:t=>({...t,severity:e===Y?void 0:e})}),B=e=>void t({search:t=>({...t,kind:e===Y?void 0:e})}),V=e=>void t({search:t=>({...t,...be(e)})}),H=P(),U=we(),K=a(o.anomalies.resolveAnomaly),Z=(p(o.me.getMe,{host:Ce})?.permissions??[]).includes(`admin.manage`),Q=p(o.anomalies.listAnomalies,{limit:Ne,filter:{q:n||void 0,from:g,to:_,anomalyStatus:s===Y?void 0:s,severity:c===Y?void 0:c,source:u===Y?void 0:u,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!==``||s!==`open`||c!==Y||u!==Y||l!==Y||m.kind!==`relative`||m.from!==Me.from;function Be(){f(Y),t({search:{status:`open`},replace:!0})}async function Ve(e){if(await H({title:d(),description:(0,J.jsxs)(J.Fragment,{children:[me(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,i(),` `,(0,J.jsx)(`strong`,{children:he()}),`.`,` `,re()]}),confirmLabel:te()}))try{await K({anomalyId:e._id,status:`resolved`}),U.success(ne(),e.kind)}catch(e){U.error(ae(),e)}}async function He(e){try{await K({anomalyId:e._id,status:`acknowledged`}),U.success(j(),e.kind)}catch(e){U.error(ee(),e)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-admin__hint`,children:[ie(),` `,(0,J.jsx)(`strong`,{children:M()}),` `,le(),` `,(0,J.jsx)(`strong`,{children:N()}),` `,A(),` `,(0,J.jsx)(`strong`,{children:se()}),` `,de(),` `,(0,J.jsx)(`span`,{className:`oc-filter__window`,children:fe()})]}),(0,J.jsxs)(Ee,{q:n,onQChange:v,searchPlaceholder:_e(),timeRange:m,onTimeRangeChange:V,onReset:Be,canReset:ze,children:[(0,J.jsxs)(R,{value:s,onValueChange:y,children:[(0,J.jsx)(F,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:w()}),Oe.map(e=>(0,J.jsx)(I,{value:e.value,children:ke(e.value)},e.value))]})]}),(0,J.jsxs)(R,{value:c,onValueChange:T,children:[(0,J.jsx)(F,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{placeholder:S()})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:x()}),Ae.map(e=>(0,J.jsx)(I,{value:e,children:e},e))]})]}),(0,J.jsxs)(R,{value:u,onValueChange:f,children:[(0,J.jsx)(F,{size:`sm`,className:`w-32`,children:(0,J.jsx)(W,{placeholder:k()})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:ge()}),je.map(e=>(0,J.jsx)(I,{value:e,children:e},e))]})]}),(0,J.jsxs)(R,{value:l,onValueChange:B,children:[(0,J.jsx)(F,{size:`sm`,className:`w-36`,children:(0,J.jsx)(W,{placeholder:b()})}),(0,J.jsxs)(G,{children:[(0,J.jsx)(I,{value:Y,children:D()}),$.map(e=>(0,J.jsx)(I,{value:e,children:e},e))]})]})]}),(0,J.jsx)(De,{title:C(),rows:Q,emptyHint:s===`open`?ce():pe(),rowActions:e=>Z&&e.status===`open`?[{label:E(),onSelect:()=>void Ve(e)},{label:ve(),onSelect:()=>void He(e)}]:[],columns:[{header:O(),cell:e=>(0,J.jsx)(`span`,{className:`oc-traces__time`,children:xe(e.at)}),sort:e=>e.at},{header:b(),cell:e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:S(),cell:e=>(0,J.jsx)(Ie,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:ue(),cell:e=>(0,J.jsx)(Le,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:k(),cell:e=>(0,J.jsx)(z,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:r(),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:h(),cell:e=>(0,J.jsx)(Pe,{row:e}),sort:e=>e.evidence??null},{header:oe(),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=L();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:[`↗ `,v()]}):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:[`↗ `,v()]}):null]})}function Fe({row:e}){let[t,n]=(0,q.useState)(!1),r=p(o.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:[y(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,J.jsx)(U,{open:t,onOpenChange:n,children:(0,J.jsxs)(B,{className:`oc-anomaly__attachments-dialog`,children:[(0,J.jsx)(H,{children:(0,J.jsx)(V,{children:l()})}),r===void 0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:T()}):r.length===0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:u()}):(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)(z,{variant:`destructive`,children:c()}):e===`acknowledged`?(0,J.jsx)(z,{variant:`secondary`,children:_()}):(0,J.jsx)(z,{variant:`outline`,children:g()})}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{Ab as r,Bb as i,Db as a,E as o,Eb as s,Fb as c,Ib as l,Lb as u,Mb as d,Nb as f,OM as p,Ob as m,Pb as h,Rb as g,Sn as _,_n as v,bn as y,jb as b,kb as x,vn as S,xn as C,yn as w,zb as T}from"./dist-HBBi9Y25.js";import{C as E,S as D,Xt as O,Yt as k,a as A,b as j,et as M,i as N,o as P,r as F,t as I,w as L,x as R}from"./index-DBQ43N4_.js";import{n as ee}from"./TimeRangePicker-NSOkx3C0.js";import{t as z}from"./FilterBar-BVVVO1_O.js";import{t as B}from"./AdvancedFilter-BQlL-4N9.js";import{t as V}from"./DataTableShell-KGrtOG5M.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:I,to:`now`},G=`__all__`,K=[{value:`action`,label:_()},{value:`realLabel`,label:C()},{value:`targetLabel`,label:y()},{value:`impersonated`,label:w()},{value:`resource`,label:S()},{value:`resourceId`,label:v()}];function q(){let e=O({from:`/settings/audit`}),t=k({from:`/settings/audit`}),n=e.q??``,_=e.action??G,v=e.impersonated??G,y=e.resource??G,S=F(e.from,e.to),C=(0,H.useMemo)(()=>P(e.adv),[e.adv]),{from:w,to:I}=ee(S),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...A(e)})}),Q=e=>void t({search:t=>({...t,adv:N(e)}),replace:!0}),$=p(o.admin.listAudit,{filter:{q:n||void 0,from:w,to:I,action:_===G?void 0:_,resource:y===G?void 0:y,impersonated:v===G?void 0:v===`yes`,advanced:C.length>0?C: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!==``||_!==G||v!==G||y!==G||C.length>0||S.kind!==`relative`||S.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:[i(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:T()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:g(),timeRange:S,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(j,{value:_,onValueChange:J,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:u()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:l()}),te.map(e=>(0,U.jsx)(D,{value:e,children:e},e))]})]}),(0,U.jsxs)(j,{value:v,onValueChange:Y,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:c()}),(0,U.jsx)(D,{value:`yes`,children:h()}),(0,U.jsx)(D,{value:`no`,children:f()})]})]}),(0,U.jsxs)(j,{value:y,onValueChange:X,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:d()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:b()}),ne.map(e=>(0,U.jsx)(D,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:C,onChange:Q}),(0,U.jsx)(V,{title:r(),rows:$,emptyHint:x(),columns:[{header:m(),cell:e=>M(e.at),sort:e=>e.at},{header:u(),cell:e=>e.action,sort:e=>e.action},{header:a(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:s(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:d(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ab as r,Bb as i,Db as a,E as o,Eb as s,Fb as c,Ib as l,Lb as u,Mb as d,Nb as f,OM as p,Ob as m,Pb as h,Rb as g,Sn as _,_n as v,bn as y,jb as b,kb as x,vn as S,xn as C,yn as w,zb as T}from"./dist-HBBi9Y25.js";import{C as E,S as D,Xt as O,Yt as k,a as A,b as j,et as M,i as N,o as P,r as F,t as I,w as L,x as R}from"./index-4Peu865E.js";import{n as ee}from"./TimeRangePicker-BeZLlC4Y.js";import{t as z}from"./FilterBar-Csl1r1c5.js";import{t as B}from"./AdvancedFilter-CKwZSjrh.js";import{t as V}from"./DataTableShell-DtJr2ebT.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:I,to:`now`},G=`__all__`,K=[{value:`action`,label:_()},{value:`realLabel`,label:C()},{value:`targetLabel`,label:y()},{value:`impersonated`,label:w()},{value:`resource`,label:S()},{value:`resourceId`,label:v()}];function q(){let e=O({from:`/settings/audit`}),t=k({from:`/settings/audit`}),n=e.q??``,_=e.action??G,v=e.impersonated??G,y=e.resource??G,S=F(e.from,e.to),C=(0,H.useMemo)(()=>P(e.adv),[e.adv]),{from:w,to:I}=ee(S),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...A(e)})}),Q=e=>void t({search:t=>({...t,adv:N(e)}),replace:!0}),$=p(o.admin.listAudit,{filter:{q:n||void 0,from:w,to:I,action:_===G?void 0:_,resource:y===G?void 0:y,impersonated:v===G?void 0:v===`yes`,advanced:C.length>0?C: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!==``||_!==G||v!==G||y!==G||C.length>0||S.kind!==`relative`||S.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:[i(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:T()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:g(),timeRange:S,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(j,{value:_,onValueChange:J,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:u()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:l()}),te.map(e=>(0,U.jsx)(D,{value:e,children:e},e))]})]}),(0,U.jsxs)(j,{value:v,onValueChange:Y,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:c()}),(0,U.jsx)(D,{value:`yes`,children:h()}),(0,U.jsx)(D,{value:`no`,children:f()})]})]}),(0,U.jsxs)(j,{value:y,onValueChange:X,children:[(0,U.jsx)(E,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:d()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(D,{value:G,children:b()}),ne.map(e=>(0,U.jsx)(D,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:C,onChange:Q}),(0,U.jsx)(V,{title:r(),rows:$,emptyHint:x(),columns:[{header:m(),cell:e=>M(e.at),sort:e=>e.at},{header:u(),cell:e=>e.action,sort:e=>e.action},{header:a(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:s(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:d(),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{$h as r,Ag as i,Ah as a,Bg as o,Bh as s,Bt as c,Ch as l,D as u,DM as d,Dh as f,E as p,Eh as m,Fg as h,Fh as g,Gh as _,Hh as v,Ht as y,Ig as ee,Ih as b,Jh as x,Kh as S,Kt as te,Lg as ne,Lh as re,Mh as ie,Nh as ae,OM as C,Oh as oe,Pg as se,Ph as ce,Qh as le,Rg as ue,Rh as de,Sh as fe,TM as pe,Th as w,Ug as me,Uh as he,Ut as ge,Vg as _e,Vh as ve,Vt as ye,Wg as be,Wh as xe,Xh as Se,Xs as Ce,Yh as we,Zh as Te,_h as Ee,ac as De,ag as Oe,bh as ke,cc as Ae,cg as je,dc as Me,dh as T,ec as Ne,eg as Pe,fc as Fe,fh as E,gh as Ie,hh as Le,ic as Re,ig as ze,jg as Be,jh as Ve,kh as He,lc as Ue,mh as We,nc as Ge,ng as Ke,oc as qe,og as Je,ph as Ye,qh as Xe,rc as Ze,rg as Qe,sc as $e,sg as et,tc as tt,tg as nt,uc as rt,vh as it,wh as at,xh as ot,yh as st,zg as ct,zh as lt,zt as ut}from"./dist-HBBi9Y25.js";import{i as D,r as dt}from"./dist-DBet7oNc.js";import{t as ft}from"./chevrons-up-down-Kyw8BbOf.js";import{i as pt,n as O,o as mt,r as ht,s as gt}from"./FieldLabel-CKVYl95W.js";import{i as _t,n as vt,r as yt,t as bt}from"./tabs-BJyz65LR.js";import{t as k}from"./button-b04wLuGq.js";import{At as A,C as j,Kt as xt,Nt as St,Q as Ct,S as M,X as wt,Xt as Tt,Yt as Et,Z as Dt,b as N,ct as P,dt as Ot,et as F,ft as kt,ht as At,lt as I,m as jt,mt as Mt,p as Nt,qt as L,tt as R,ut as Pt,w as z,x as B,xt as Ft,z as It,zt as Lt}from"./index-DBQ43N4_.js";import{r as Rt}from"./locales-CPjguROj.js";import{a as zt,i as V,n as Bt,o as H,r as U,t as Vt}from"./table-CtNwimV_.js";import{t as Ht}from"./FilterBar-BVVVO1_O.js";import{a as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt}from"./compatView-S4X8HKXY.js";import{t as W}from"./dispatchErrorInfo-Cs8_1qCQ.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 Zt(e){return e.filter(e=>e.state===`error`)}function Qt(e){return e.reachable&&Zt(e.targets).length===0}function $t(e){return Qt(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function en(e){return e.state===`error`&&e.lastErrorCode!==null}function tn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function nn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function rn(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return nn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,an={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function on(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function sn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function cn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function ln(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Gt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function un(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=cn(t.key,e),a=cn(t.key,r);return i&&a?0:i?1:a?-1:n*ln(t.key,e,r)})}function dn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function fn(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>X(e.label,t.label))}function pn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Gt(e,t)??X(e,t))}var Z=n();function mn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(an),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>dn(o),[o]),c=(0,G.useMemo)(()=>fn(o),[o]),u=(0,G.useMemo)(()=>pn(o),[o]),d=(0,G.useMemo)(()=>un(sn(o,n),i),[o,n,i]);function f(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:He()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Ht,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:m(),onReset:()=>r(an),canReset:on(n),children:[(0,Z.jsxs)(N,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(z,{placeholder:at()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(M,{value:J,children:w()}),s.map(e=>(0,Z.jsx)(M,{value:e,children:gn(e)},e))]})]}),(0,Z.jsxs)(N,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(z,{placeholder:l()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(M,{value:J,children:w()}),c.map(e=>(0,Z.jsx)(M,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(N,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(z,{placeholder:fe()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(M,{value:J,children:w()}),u.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))]})]})]}),d.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}):(0,Z.jsxs)(Vt,{className:`oc-conn__table`,children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:ke(),sortKey:`target`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:st(),sortKey:`state`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:it(),sortKey:`instance`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:Ee(),sortKey:`host`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:Ie(),sortKey:`version`,sort:i,onSort:f}),(0,Z.jsx)(V,{children:Le()}),(0,Z.jsx)(Q,{label:We(),sortKey:`lastOk`,sort:i,onSort:f})]})}),(0,Z.jsx)(Bt,{children:d.map(e=>(0,Z.jsx)(hn,{r:e},e._id))})]})]})}function Q({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Z.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Z.jsx)(dt,{size:13,"aria-hidden":!0}):(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ft,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function hn({r:e}){let t=en(e)?W(e.lastErrorCode):null,n=tn(e)?W(e.lastDownstreamRejectCode):null;return(0,Z.jsxs)(G.Fragment,{children:[(0,Z.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(_n,{state:e.state})}),(0,Z.jsx)(U,{children:e.instanceLabel?(0,Z.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Z.jsx)(U,{children:e.gatewayVersion?(0,Z.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-conn__stats`,children:oe({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Z.jsx)(U,{children:e.lastOkAt?(0,Z.jsx)(`span`,{className:`oc-traces__mono`,children:R(e.lastOkAt)}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Z.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Z.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Z.jsx)(`strong`,{children:t.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${R(e.lastErrorAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[f({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${R(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function gn(e){return e===`connected`?Ye():e===`error`?E():T()}function _n({state:e}){return e===`connected`?(0,Z.jsx)(P,{variant:`secondary`,children:Ye()}):e===`error`?(0,Z.jsx)(P,{variant:`destructive`,children:E()}):(0,Z.jsx)(P,{variant:`outline`,children:T()})}function vn(){return C(p.bridgeHealth.getBridgeHealth,{})}function yn(){let e=vn(),t=C(p.compat.getBridgeCompat,{}),n=C(p.me.getMe,{host:Ft})?.role===`admin`,r=C(p.admin.listInstances,n?{}:`skip`),i=C(p.agents.usageForInstances,n?{}:`skip`),a=Et(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=rn(e?e.targets:[],t?t.targets:[],r??[]),{section:l}=Tt({from:`/settings/bridge`}),u=Et({from:`/settings/bridge`}),d=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,m=d!==null&&Wt(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(bn,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:x()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:Xe()}),(0,Z.jsxs)(Vt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:ge()}),(0,Z.jsx)(V,{children:y()}),(0,Z.jsx)(V,{children:ye()}),(0,Z.jsx)(V,{children:c()}),(0,Z.jsx)(V,{children:ut()})]})}),(0,Z.jsx)(Bt,{children:i.flatMap(e=>{let t=jt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(P,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(bt,{value:s.some(e=>e.key===l)?l:s[0]?.key??`openclaw`,onValueChange:e=>void u({search:{section:e},replace:!0}),children:[(0,Z.jsx)(yt,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(_t,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(St,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(vt,{value:e.key,children:(0,Z.jsx)(xn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:d,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,m?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):null]})}function bn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Z.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:rt(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,Ue({build:t.buildVersion??`?`})]}):null,` · `,Ae(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?$e():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:lt()});let o=Zt(e.targets),c=!e.reachable,l=$t(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=F(e.checkedAt),p=e.startedAt==null?null:F(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Z.jsx)(xt,{size:22}):c||l===`gateways_unreachable`?(0,Z.jsx)(Xt,{size:22}):(0,Z.jsx)(A,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?de():l===`gateways_unreachable`?ce({count:u.length}):c?re():b({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Yt,{size:12,"aria-hidden":!0}),` `,g({time:f})]}),p?(0,Z.jsx)(`span`,{children:ie({time:p})}):null,a]}),l===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ae({names:u.join(`, `)})}):null,c?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Ve()})]})}function xn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:o,protocol:s}){let c=r?qt(r,e):null,l=new Map;for(let e of n)l.set(e.name,e.displayName??e.name);let u=[],d=new Set;for(let n of t){if(!n.instanceName||d.has(n.instanceName))continue;d.add(n.instanceName);let t=n.gatewayVersion??null;u.push({instanceName:n.instanceName,displayName:l.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let f=u.map(e=>e.state),p=f.includes(`beyond`)?`beyond`:f.length>0&&f.every(e=>e===`supported`)?`supported`:null,[m,h]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(St,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),p?(0,Z.jsx)(P,{variant:p===`beyond`?`destructive`:`secondary`,children:Kt(p)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Fe()}),(0,Z.jsx)(Cn,{providerName:q(e),support:c,compatStatus:i,compatReachable:o,manifest:r,instanceRows:u}),s?(0,Z.jsx)(Sn,{protocol:s}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":m,onClick:()=>h(e=>!e),children:[m?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(L,{size:13,"aria-hidden":!0}),a({count:t.length})]}),m?(0,Z.jsx)(mn,{connections:t,displayByInstance:l}):null]})}function Sn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[S(),i.length>0?(0,Z.jsx)(P,{variant:`destructive`,children:xe({count:i.length})}):(0,Z.jsx)(P,{variant:`secondary`,children:_()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[he({version:e.vendoredVersion}),r?` · `+v({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),i.length>0?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(L,{size:13,"aria-hidden":!0}),ve({count:r.gapList.length})]}),t?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function Cn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:te({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:Re({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:$e()}),e?(0,Z.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ne()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(e.version)}),(0,Z.jsx)(P,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(e.state)})]},e.instanceName))})]})}function wn({instance:e,onClose:t}){return(0,Z.jsx)(Pt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(Ot,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(Mt,{children:[(0,Z.jsx)(At,{children:be({instance:e.displayName??e.name})}),(0,Z.jsx)(kt,{children:me()})]}),(0,Z.jsx)(Tn,{instance:e,onClose:t})]})})}function $({label:e,result:t}){return t?t.checked?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Z.jsx)(xt,{"aria-hidden":!0}):(0,Z.jsx)(A,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?le():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,Te()]}):null}function Tn({instance:e,onClose:t}){let n=d(p.admin.upsertInstanceConfig),a=pe(p.bridge.validateMediaPaths),s=It(),c=Rt(e.config?.contentLocale,void 0),[l,u]=(0,G.useState)(()=>pt(e.config??{},c)),[f,m]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),b=l.inboundMediaMode===`shared-fs`,x=l.mediaMode===`shared-fs`,S=b||x;async function te(){_(!0),y(null);try{y(await a({instanceName:e.name,inboundMediaMode:l.inboundMediaMode,mediaMode:l.mediaMode}))}catch(e){s.error(Ke(),e)}finally{_(!1)}}async function re(){m(!0);try{let r=e.config??{};await n({instanceId:e._id,config:ht(l,r,c)}),t()}catch(e){s.error(ee(),e)}finally{m(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:_e(),help:h()}),(0,Z.jsxs)(N,{value:l.mediaMode,onValueChange:e=>u({...l,mediaMode:e}),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(z,{})}),(0,Z.jsx)(B,{children:gt.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:o(),help:se()}),(0,Z.jsxs)(N,{value:l.inboundMediaMode,onValueChange:e=>u({...l,inboundMediaMode:e}),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(z,{})}),(0,Z.jsx)(B,{children:mt.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ct(),help:Be()}),(0,Z.jsx)(I,{type:`number`,min:1,max:4096,className:`w-full`,value:l.mediaMaxMb,onChange:e=>u({...l,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),S&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[b&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:je(),help:et()}),(0,Z.jsx)(I,{className:`w-full`,spellCheck:!1,value:l.inboundAgentMount,onChange:e=>u({...l,inboundAgentMount:e.target.value})})]}),x&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:Je(),help:Oe()}),(0,Z.jsx)(I,{className:`w-full`,spellCheck:!1,value:l.outboundAgentMount,onChange:e=>u({...l,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(Nt,{checked:l.rehydration,onCheckedChange:e=>u({...l,rehydration:e===!0})}),(0,Z.jsx)(O,{label:ue(),help:i()})]}),S&&v!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:v.reachable?!v.inbound&&!v.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(A,{"aria-hidden":!0}),we({reason:v.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:Pe(),result:v.inbound}),(0,Z.jsx)($,{label:r(),result:v.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:nt()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(A,{"aria-hidden":!0}),Se()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[S&&(0,Z.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void te(),disabled:g,children:[g?(0,Z.jsx)(Lt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,g?Qe():ze()]}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>void re(),disabled:f,children:ne()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(Ct,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?Ze():Ge({count:e.length}),(0,Z.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Dt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:tt()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(P,{variant:`secondary`,children:e},e))})]})]})}export{yn as BridgeTab,wn as InstanceConfigDialog};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$h as r,Ag as i,Ah as a,Bg as o,Bh as s,Bt as c,Ch as l,D as u,DM as d,Dh as f,E as p,Eh as m,Fg as h,Fh as g,Gh as _,Hh as v,Ht as y,Ig as ee,Ih as b,Jh as x,Kh as S,Kt as te,Lg as ne,Lh as re,Mh as ie,Nh as ae,OM as C,Oh as oe,Pg as se,Ph as ce,Qh as le,Rg as ue,Rh as de,Sh as fe,TM as pe,Th as w,Ug as me,Uh as he,Ut as ge,Vg as _e,Vh as ve,Vt as ye,Wg as be,Wh as xe,Xh as Se,Xs as Ce,Yh as we,Zh as Te,_h as Ee,ac as De,ag as Oe,bh as ke,cc as Ae,cg as je,dc as Me,dh as T,ec as Ne,eg as Pe,fc as Fe,fh as E,gh as Ie,hh as Le,ic as Re,ig as ze,jg as Be,jh as Ve,kh as He,lc as Ue,mh as We,nc as Ge,ng as Ke,oc as qe,og as Je,ph as Ye,qh as Xe,rc as Ze,rg as Qe,sc as $e,sg as et,tc as tt,tg as nt,uc as rt,vh as it,wh as at,xh as ot,yh as st,zg as ct,zh as lt,zt as ut}from"./dist-HBBi9Y25.js";import{i as D,r as dt}from"./dist-DBet7oNc.js";import{t as ft}from"./chevrons-up-down-Kyw8BbOf.js";import{i as pt,n as O,o as mt,r as ht,s as gt}from"./FieldLabel-DOYQdxs6.js";import{i as _t,n as vt,r as yt,t as bt}from"./tabs-0f19le6d.js";import{t as k}from"./button-b04wLuGq.js";import{At as A,C as j,Kt as xt,Nt as St,Q as Ct,S as M,X as wt,Xt as Tt,Yt as Et,Z as Dt,b as N,ct as P,dt as Ot,et as F,ft as kt,ht as At,lt as I,m as jt,mt as Mt,p as Nt,qt as L,tt as R,ut as Pt,w as z,x as B,xt as Ft,z as It,zt as Lt}from"./index-4Peu865E.js";import{r as Rt}from"./locales-CPjguROj.js";import{a as zt,i as V,n as Bt,o as H,r as U,t as Vt}from"./table-CtNwimV_.js";import{t as Ht}from"./FilterBar-Csl1r1c5.js";import{a as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt}from"./compatView-CONPJXEW.js";import{t as W}from"./dispatchErrorInfo-Cs8_1qCQ.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 Zt(e){return e.filter(e=>e.state===`error`)}function Qt(e){return e.reachable&&Zt(e.targets).length===0}function $t(e){return Qt(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function en(e){return e.state===`error`&&e.lastErrorCode!==null}function tn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function nn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function rn(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return nn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,an={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function on(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function sn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function cn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function ln(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Gt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function un(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=cn(t.key,e),a=cn(t.key,r);return i&&a?0:i?1:a?-1:n*ln(t.key,e,r)})}function dn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function fn(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>X(e.label,t.label))}function pn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Gt(e,t)??X(e,t))}var Z=n();function mn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(an),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,G.useMemo)(()=>dn(o),[o]),c=(0,G.useMemo)(()=>fn(o),[o]),u=(0,G.useMemo)(()=>pn(o),[o]),d=(0,G.useMemo)(()=>un(sn(o,n),i),[o,n,i]);function f(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:He()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Ht,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:m(),onReset:()=>r(an),canReset:on(n),children:[(0,Z.jsxs)(N,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(z,{placeholder:at()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(M,{value:J,children:w()}),s.map(e=>(0,Z.jsx)(M,{value:e,children:gn(e)},e))]})]}),(0,Z.jsxs)(N,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(z,{placeholder:l()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(M,{value:J,children:w()}),c.map(e=>(0,Z.jsx)(M,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(N,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(z,{placeholder:fe()})}),(0,Z.jsxs)(B,{children:[(0,Z.jsx)(M,{value:J,children:w()}),u.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))]})]})]}),d.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ot()}):(0,Z.jsxs)(Vt,{className:`oc-conn__table`,children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:ke(),sortKey:`target`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:st(),sortKey:`state`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:it(),sortKey:`instance`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:Ee(),sortKey:`host`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:Ie(),sortKey:`version`,sort:i,onSort:f}),(0,Z.jsx)(V,{children:Le()}),(0,Z.jsx)(Q,{label:We(),sortKey:`lastOk`,sort:i,onSort:f})]})}),(0,Z.jsx)(Bt,{children:d.map(e=>(0,Z.jsx)(hn,{r:e},e._id))})]})]})}function Q({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Z.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Z.jsx)(dt,{size:13,"aria-hidden":!0}):(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ft,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function hn({r:e}){let t=en(e)?W(e.lastErrorCode):null,n=tn(e)?W(e.lastDownstreamRejectCode):null;return(0,Z.jsxs)(G.Fragment,{children:[(0,Z.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(_n,{state:e.state})}),(0,Z.jsx)(U,{children:e.instanceLabel?(0,Z.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Z.jsx)(U,{children:e.gatewayVersion?(0,Z.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-conn__stats`,children:oe({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Z.jsx)(U,{children:e.lastOkAt?(0,Z.jsx)(`span`,{className:`oc-traces__mono`,children:R(e.lastOkAt)}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,Z.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Z.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Z.jsx)(`strong`,{children:t.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${R(e.lastErrorAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[f({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${R(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function gn(e){return e===`connected`?Ye():e===`error`?E():T()}function _n({state:e}){return e===`connected`?(0,Z.jsx)(P,{variant:`secondary`,children:Ye()}):e===`error`?(0,Z.jsx)(P,{variant:`destructive`,children:E()}):(0,Z.jsx)(P,{variant:`outline`,children:T()})}function vn(){return C(p.bridgeHealth.getBridgeHealth,{})}function yn(){let e=vn(),t=C(p.compat.getBridgeCompat,{}),n=C(p.me.getMe,{host:Ft})?.role===`admin`,r=C(p.admin.listInstances,n?{}:`skip`),i=C(p.agents.usageForInstances,n?{}:`skip`),a=Et(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=rn(e?e.targets:[],t?t.targets:[],r??[]),{section:l}=Tt({from:`/settings/bridge`}),u=Et({from:`/settings/bridge`}),d=t?.compat??null,f=t===void 0?`loading`:t===null?`nodata`:`ready`,m=d!==null&&Wt(d,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(bn,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:x()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:Xe()}),(0,Z.jsxs)(Vt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:ge()}),(0,Z.jsx)(V,{children:y()}),(0,Z.jsx)(V,{children:ye()}),(0,Z.jsx)(V,{children:c()}),(0,Z.jsx)(V,{children:ut()})]})}),(0,Z.jsx)(Bt,{children:i.flatMap(e=>{let t=jt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(P,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(bt,{value:s.some(e=>e.key===l)?l:s[0]?.key??`openclaw`,onValueChange:e=>void u({search:{section:e},replace:!0}),children:[(0,Z.jsx)(yt,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(_t,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(St,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(vt,{value:e.key,children:(0,Z.jsx)(xn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:d,compatStatus:f,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,m?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):null]})}function bn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Z.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:rt(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,Ue({build:t.buildVersion??`?`})]}):null,` · `,Ae(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?$e():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:lt()});let o=Zt(e.targets),c=!e.reachable,l=$t(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=F(e.checkedAt),p=e.startedAt==null?null:F(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Z.jsx)(xt,{size:22}):c||l===`gateways_unreachable`?(0,Z.jsx)(Xt,{size:22}):(0,Z.jsx)(A,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?de():l===`gateways_unreachable`?ce({count:u.length}):c?re():b({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Yt,{size:12,"aria-hidden":!0}),` `,g({time:f})]}),p?(0,Z.jsx)(`span`,{children:ie({time:p})}):null,a]}),l===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:ae({names:u.join(`, `)})}):null,c?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:Ve()})]})}function xn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:o,protocol:s}){let c=r?qt(r,e):null,l=new Map;for(let e of n)l.set(e.name,e.displayName??e.name);let u=[],d=new Set;for(let n of t){if(!n.instanceName||d.has(n.instanceName))continue;d.add(n.instanceName);let t=n.gatewayVersion??null;u.push({instanceName:n.instanceName,displayName:l.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let f=u.map(e=>e.state),p=f.includes(`beyond`)?`beyond`:f.length>0&&f.every(e=>e===`supported`)?`supported`:null,[m,h]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(St,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),p?(0,Z.jsx)(P,{variant:p===`beyond`?`destructive`:`secondary`,children:Kt(p)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Fe()}),(0,Z.jsx)(Cn,{providerName:q(e),support:c,compatStatus:i,compatReachable:o,manifest:r,instanceRows:u}),s?(0,Z.jsx)(Sn,{protocol:s}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":m,onClick:()=>h(e=>!e),children:[m?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(L,{size:13,"aria-hidden":!0}),a({count:t.length})]}),m?(0,Z.jsx)(mn,{connections:t,displayByInstance:l}):null]})}function Sn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[S(),i.length>0?(0,Z.jsx)(P,{variant:`destructive`,children:xe({count:i.length})}):(0,Z.jsx)(P,{variant:`secondary`,children:_()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[he({version:e.vendoredVersion}),r?` · `+v({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),i.length>0?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Z.jsx)(D,{size:13,"aria-hidden":!0}):(0,Z.jsx)(L,{size:13,"aria-hidden":!0}),ve({count:r.gapList.length})]}),t?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function Cn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:qe()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:De()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:te({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:Re({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:$e()}),e?(0,Z.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ne()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(e.version)}),(0,Z.jsx)(P,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(e.state)})]},e.instanceName))})]})}function wn({instance:e,onClose:t}){return(0,Z.jsx)(Pt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(Ot,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(Mt,{children:[(0,Z.jsx)(At,{children:be({instance:e.displayName??e.name})}),(0,Z.jsx)(kt,{children:me()})]}),(0,Z.jsx)(Tn,{instance:e,onClose:t})]})})}function $({label:e,result:t}){return t?t.checked?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Z.jsx)(xt,{"aria-hidden":!0}):(0,Z.jsx)(A,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?le():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,Te()]}):null}function Tn({instance:e,onClose:t}){let n=d(p.admin.upsertInstanceConfig),a=pe(p.bridge.validateMediaPaths),s=It(),c=Rt(e.config?.contentLocale,void 0),[l,u]=(0,G.useState)(()=>pt(e.config??{},c)),[f,m]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),b=l.inboundMediaMode===`shared-fs`,x=l.mediaMode===`shared-fs`,S=b||x;async function te(){_(!0),y(null);try{y(await a({instanceName:e.name,inboundMediaMode:l.inboundMediaMode,mediaMode:l.mediaMode}))}catch(e){s.error(Ke(),e)}finally{_(!1)}}async function re(){m(!0);try{let r=e.config??{};await n({instanceId:e._id,config:ht(l,r,c)}),t()}catch(e){s.error(ee(),e)}finally{m(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:_e(),help:h()}),(0,Z.jsxs)(N,{value:l.mediaMode,onValueChange:e=>u({...l,mediaMode:e}),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(z,{})}),(0,Z.jsx)(B,{children:gt.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:o(),help:se()}),(0,Z.jsxs)(N,{value:l.inboundMediaMode,onValueChange:e=>u({...l,inboundMediaMode:e}),children:[(0,Z.jsx)(j,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(z,{})}),(0,Z.jsx)(B,{children:mt.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:ct(),help:Be()}),(0,Z.jsx)(I,{type:`number`,min:1,max:4096,className:`w-full`,value:l.mediaMaxMb,onChange:e=>u({...l,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),S&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[b&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:je(),help:et()}),(0,Z.jsx)(I,{className:`w-full`,spellCheck:!1,value:l.inboundAgentMount,onChange:e=>u({...l,inboundAgentMount:e.target.value})})]}),x&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(O,{label:Je(),help:Oe()}),(0,Z.jsx)(I,{className:`w-full`,spellCheck:!1,value:l.outboundAgentMount,onChange:e=>u({...l,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(Nt,{checked:l.rehydration,onCheckedChange:e=>u({...l,rehydration:e===!0})}),(0,Z.jsx)(O,{label:ue(),help:i()})]}),S&&v!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:v.reachable?!v.inbound&&!v.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(A,{"aria-hidden":!0}),we({reason:v.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:Pe(),result:v.inbound}),(0,Z.jsx)($,{label:r(),result:v.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:nt()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(A,{"aria-hidden":!0}),Se()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[S&&(0,Z.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void te(),disabled:g,children:[g?(0,Z.jsx)(Lt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,g?Qe():ze()]}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>void re(),disabled:f,children:ne()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(Ct,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?Ze():Ge({count:e.length}),(0,Z.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Dt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:tt()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(P,{variant:`secondary`,children:e},e))})]})]})}export{yn as BridgeTab,wn as InstanceConfigDialog};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bi as r,DM as i,E as a,Fl as o,Gi as s,Gt as c,Hg as l,Hi as u,Ki as d,Nl as f,OM as p,Ol as m,Ri as h,TM as g,Ui as _,Vi as v,Wi as y,Zc as b,_c as x,bc as S,gc as C,hc as w,kl as T,mc as E,pc as D,qi as O,vc as k,xc as A,yM as j,yc as M,zi as N}from"./dist-HBBi9Y25.js";import{t as P}from"./button-b04wLuGq.js";import{At as F,C as I,S as L,b as R,d as z,f as B,lt as V,p as H,w as U,x as W,y as G}from"./index-DBQ43N4_.js";import{i as K}from"./compatView-S4X8HKXY.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=i(a.admin.upsertInstanceConfig),n=p(a.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[s,c]=(0,q.useState)(r),[l,d]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{c(r),d(`idle`)},[e._id,r]);let f=`__none__`,m=s!==r;async function h(){d(`saving`);try{let n={...e.config??{}};s===``||s===f?delete n.converterAgentId:n.converterAgentId=s,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}let g=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:y()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:_()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(R,{value:s===``?f:s,onValueChange:e=>c(e===f?``:e),children:[(0,X.jsx)(I,{className:`oc-cdefaults__select`,"aria-label":y(),children:(0,X.jsx)(U,{placeholder:u()})}),(0,X.jsxs)(W,{children:[(0,X.jsx)(L,{value:f,children:u()}),g.map(e=>(0,X.jsx)(L,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!m||l===`saving`,onClick:()=>void h(),children:l===`saving`?o():w()})]}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null]})}function Q({instance:e}){let t=i(a.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,c=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[l,u]=(0,q.useState)(n),[d,f]=(0,q.useState)(c===null?``:String(c)),[p,m]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{u(n),f(c===null?``:String(c)),m(`idle`)},[e._id,n,c]);let h=d.trim(),g=h===``?null:/^\d+$/.test(h)?Number.parseInt(h,10):NaN,_=!l||g===null||Number.isInteger(g)&&g>=4e3&&g<=6e4,y=l!==n||(g??null)!==c;async function b(){m(`saving`);try{let n={...e.config??{}};n.curationEnabled=l,!l||g===null||Number.isNaN(g)?delete n.curationBudgetChars:n.curationBudgetChars=g,await t({instanceId:e._id,config:n}),m(`done`)}catch{m(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(H,{checked:l,onCheckedChange:e=>u(e===!0),"aria-label":s()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:s()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:d,onChange:e=>f(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":v(),disabled:!l}),(0,X.jsx)(P,{size:`sm`,disabled:!y||!_||p===`saving`,onClick:()=>void b(),children:p===`saving`?o():w()})]}),_?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:r()}),p===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,p===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:N()})]})}function $({instance:e}){let t=i(a.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,s]=(0,q.useState)(n===null?``:String(n)),[c,l]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{s(n===null?``:String(n)),l(`idle`)},[e._id,n]);let u=r.trim(),f=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,p=f===null||Number.isInteger(f)&&f>=1e3&&f<=2e5,m=(f??null)!==n;async function g(){l(`saving`);try{let n={...e.config??{}};f===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=f,await t({instanceId:e._id,config:n}),l(`done`)}catch{l(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:O()}),(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=>s(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!p}),(0,X.jsx)(P,{size:`sm`,disabled:!m||!p||c===`saving`,onClick:()=>void g(),children:c===`saving`?o():w()})]}),p?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:h()}),c===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,c===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:d()})]})}function ee(){let e=g(a.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),r=p(a.admin.listInstances,{}),[i,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!r||r.length===0||(!i||!r.some(e=>e.name===i))&&o(r[0].name)},[r,i]);let s=(r?.length??0)>1,u=r!==void 0&&r.length===0,d=p(a.compat.forInstance,i?{instanceName:i}:`skip`),h=i?G(d,`configDefaults`):`loading`,_=h===`loading`?null:h.blocked,v=(0,q.useMemo)(()=>s&&i?{instanceName:i}:{},[s,i]),y=(0,q.useRef)(0),w=(0,q.useCallback)(async()=>{let t=++y.current;n({status:`loading`});try{let r=Y(await e(v));if(y.current!==t)return;n({status:`done`,current:r})}catch{if(y.current!==t)return;n({status:`error`})}},[e,v]);(0,q.useEffect)(()=>{_===!1&&(s&&!i||w())},[w,_,s,i]);let E=t.status===`done`?t.current:null,D=(0,q.useMemo)(()=>J.map(e=>({id:e,label:B(e)})),[]),O=(0,q.useMemo)(()=>[{id:`fast`,label:T()},{id:`standard`,label:m()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:A()}),s&&i?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:b()}),(0,X.jsxs)(R,{value:i,onValueChange:e=>o(e),children:[(0,X.jsx)(I,{size:`sm`,"aria-label":b(),children:(0,X.jsx)(U,{})}),(0,X.jsx)(W,{children:(r??[]).map(e=>(0,X.jsx)(L,{value:e.name,children:e.name},e.name))})]})]}):null,u?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:l()}):h===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):h.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(F,{size:14,"aria-hidden":!0}),` `,K(h.gatewayVersion,h.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[C(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void w(),children:f()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:S()}),(0,X.jsx)(z,{options:D,value:E?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:M()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()}),(0,X.jsx)(z,{options:O,value:E===null||E.fastModeDefault===null?null:E.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:c()})]}),(()=>{let e=r?.find(e=>e.name===(i??r[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bi as r,DM as i,E as a,Fl as o,Gi as s,Gt as c,Hg as l,Hi as u,Ki as d,Nl as f,OM as p,Ol as m,Ri as h,TM as g,Ui as _,Vi as v,Wi as y,Zc as b,_c as x,bc as S,gc as C,hc as w,kl as T,mc as E,pc as D,qi as O,vc as k,xc as A,yM as j,yc as M,zi as N}from"./dist-HBBi9Y25.js";import{t as P}from"./button-b04wLuGq.js";import{At as F,C as I,S as L,b as R,d as z,f as B,lt as V,p as H,w as U,x as W,y as G}from"./index-4Peu865E.js";import{i as K}from"./compatView-CONPJXEW.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=i(a.admin.upsertInstanceConfig),n=p(a.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[s,c]=(0,q.useState)(r),[l,d]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{c(r),d(`idle`)},[e._id,r]);let f=`__none__`,m=s!==r;async function h(){d(`saving`);try{let n={...e.config??{}};s===``||s===f?delete n.converterAgentId:n.converterAgentId=s,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}let g=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:y()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:_()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(R,{value:s===``?f:s,onValueChange:e=>c(e===f?``:e),children:[(0,X.jsx)(I,{className:`oc-cdefaults__select`,"aria-label":y(),children:(0,X.jsx)(U,{placeholder:u()})}),(0,X.jsxs)(W,{children:[(0,X.jsx)(L,{value:f,children:u()}),g.map(e=>(0,X.jsx)(L,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!m||l===`saving`,onClick:()=>void h(),children:l===`saving`?o():w()})]}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null]})}function Q({instance:e}){let t=i(a.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,c=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[l,u]=(0,q.useState)(n),[d,f]=(0,q.useState)(c===null?``:String(c)),[p,m]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{u(n),f(c===null?``:String(c)),m(`idle`)},[e._id,n,c]);let h=d.trim(),g=h===``?null:/^\d+$/.test(h)?Number.parseInt(h,10):NaN,_=!l||g===null||Number.isInteger(g)&&g>=4e3&&g<=6e4,y=l!==n||(g??null)!==c;async function b(){m(`saving`);try{let n={...e.config??{}};n.curationEnabled=l,!l||g===null||Number.isNaN(g)?delete n.curationBudgetChars:n.curationBudgetChars=g,await t({instanceId:e._id,config:n}),m(`done`)}catch{m(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(H,{checked:l,onCheckedChange:e=>u(e===!0),"aria-label":s()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:s()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:d,onChange:e=>f(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":v(),disabled:!l}),(0,X.jsx)(P,{size:`sm`,disabled:!y||!_||p===`saving`,onClick:()=>void b(),children:p===`saving`?o():w()})]}),_?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:r()}),p===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,p===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:N()})]})}function $({instance:e}){let t=i(a.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,s]=(0,q.useState)(n===null?``:String(n)),[c,l]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{s(n===null?``:String(n)),l(`idle`)},[e._id,n]);let u=r.trim(),f=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,p=f===null||Number.isInteger(f)&&f>=1e3&&f<=2e5,m=(f??null)!==n;async function g(){l(`saving`);try{let n={...e.config??{}};f===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=f,await t({instanceId:e._id,config:n}),l(`done`)}catch{l(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:O()}),(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=>s(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!p}),(0,X.jsx)(P,{size:`sm`,disabled:!m||!p||c===`saving`,onClick:()=>void g(),children:c===`saving`?o():w()})]}),p?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:h()}),c===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,c===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:d()})]})}function ee(){let e=g(a.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),r=p(a.admin.listInstances,{}),[i,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!r||r.length===0||(!i||!r.some(e=>e.name===i))&&o(r[0].name)},[r,i]);let s=(r?.length??0)>1,u=r!==void 0&&r.length===0,d=p(a.compat.forInstance,i?{instanceName:i}:`skip`),h=i?G(d,`configDefaults`):`loading`,_=h===`loading`?null:h.blocked,v=(0,q.useMemo)(()=>s&&i?{instanceName:i}:{},[s,i]),y=(0,q.useRef)(0),w=(0,q.useCallback)(async()=>{let t=++y.current;n({status:`loading`});try{let r=Y(await e(v));if(y.current!==t)return;n({status:`done`,current:r})}catch{if(y.current!==t)return;n({status:`error`})}},[e,v]);(0,q.useEffect)(()=>{_===!1&&(s&&!i||w())},[w,_,s,i]);let E=t.status===`done`?t.current:null,D=(0,q.useMemo)(()=>J.map(e=>({id:e,label:B(e)})),[]),O=(0,q.useMemo)(()=>[{id:`fast`,label:T()},{id:`standard`,label:m()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:A()}),s&&i?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:b()}),(0,X.jsxs)(R,{value:i,onValueChange:e=>o(e),children:[(0,X.jsx)(I,{size:`sm`,"aria-label":b(),children:(0,X.jsx)(U,{})}),(0,X.jsx)(W,{children:(r??[]).map(e=>(0,X.jsx)(L,{value:e.name,children:e.name},e.name))})]})]}):null,u?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:l()}):h===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):h.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(F,{size:14,"aria-hidden":!0}),` `,K(h.gatewayVersion,h.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[C(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void w(),children:f()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:S()}),(0,X.jsx)(z,{options:D,value:E?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:M()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()}),(0,X.jsx)(z,{options:O,value:E===null||E.fastModeDefault===null?null:E.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:c()})]}),(()=>{let e=r?.find(e=>e.name===(i??r[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bf as r,Hf as i,If as a,Lf as o,Rf as s,Vf as c,zf as l}from"./dist-HBBi9Y25.js";import{i as u,r as d}from"./dist-DBet7oNc.js";import{t as f}from"./chevrons-up-down-Kyw8BbOf.js";import{t as p}from"./button-b04wLuGq.js";import{Ht as m,It as h,it as g,jt as _,nt as v,ot as y,p as b,rt as x,st as S}from"./index-DBQ43N4_.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-CtNwimV_.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=i(),bulkActions:F,emptyHint:I=c(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(_,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(h,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(b,{"aria-label":l(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":a({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(d,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(f,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],r=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(b,{"aria-label":s(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(v,{children:[(0,M.jsx)(S,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":o(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(y,{}):null,(0,M.jsx)(g,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bf as r,Hf as i,If as a,Lf as o,Rf as s,Vf as c,zf as l}from"./dist-HBBi9Y25.js";import{i as u,r as d}from"./dist-DBet7oNc.js";import{t as f}from"./chevrons-up-down-Kyw8BbOf.js";import{t as p}from"./button-b04wLuGq.js";import{Ht as m,It as h,it as g,jt as _,nt as v,ot as y,p as b,rt as x,st as S}from"./index-4Peu865E.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-CtNwimV_.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=i(),bulkActions:F,emptyHint:I=c(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(_,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(h,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(b,{"aria-label":l(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":a({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(d,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(f,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],r=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(b,{"aria-label":s(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(v,{children:[(0,M.jsx)(S,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":o(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(y,{}):null,(0,M.jsx)(g,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{ct as t}from"./index-DBQ43N4_.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
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{ct as t}from"./index-4Peu865E.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,AC as i,BC as a,CC as o,DC as s,DM as c,E as l,EC as u,FC as d,GC as f,HC as ee,IC as p,JC as m,KC as te,LC as ne,MC as h,NC as g,OC as _,OM as v,PC as re,QC as y,RC as ie,SC as b,TC as x,UC as S,VC as C,WC as w,XC as T,YC as E,ZC as D,_C as O,aC as k,ai as A,bC as j,cC as M,dC as N,ew as P,fC as F,gC as I,hC as L,iC as R,jC as z,kC as B,lC as V,mC as H,nC as U,nw as W,oC as ae,pC as G,qC as K,rC as q,ri as J,sC as oe,tC as se,tw as ce,uC as le,vC as ue,wC as de,xC as fe,yC as pe,zC as me}from"./dist-HBBi9Y25.js";import{t as he}from"./button-b04wLuGq.js";import{B as ge,et as _e}from"./index-DBQ43N4_.js";import{t as Y}from"./DataTableShell-KGrtOG5M.js";var X=t(e(),1),Z=n(),ve={altered_words:()=>W(),incorrect:()=>ce(),incoherence:()=>P(),formatting:()=>r(),latency:()=>y(),api_error:()=>D(),other:()=>T()},Q=e=>ve[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:m()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:K()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:E()})}function ye({data:e,closeReason:t}){let n=e.snapshot,r=c(l.feedback.respondToFeedback),[o,m]=(0,X.useState)(e.thread),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(!1);async function T(){let t=v.trim();if(!(!t||b)){x(!0);try{await r({feedbackId:e._id,text:t}),m(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),y(``)}finally{x(!1)}}}let E=[];try{E=n.contextJson?JSON.parse(n.contextJson):[]}catch{E=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:n.displayedMatchesStored,sourceWasOpen:n.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,n.messageRole,n.isRegeneration?` · ${te()}`:``,n.openclawModel?` · ${n.openclawModel}`:``,n.openclawRuntime?` (${n.openclawRuntime})`:``]})]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,t?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:oe()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:t})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),o.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:o.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`?S():e.authorRole===`agent`?e.authorLabel??A():ee()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:C()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:a(),value:v,maxLength:2e3,rows:3,onChange:e=>y(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(he,{size:`sm`,onClick:()=>void T(),disabled:!v.trim()||b,children:b?me():ie()})})]}),(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:n.messageText||p()})]}),n.clientInfo?.sourceWasOpen&&n.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:d()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.displayedText||p()})]}):null,n.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:re()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.promptText})]}):null,E.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g({count:n.contextCount??E.length,truncated:n.contextTruncated?h():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:E.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,n.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:z()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[n.outboxText??``,n.outboxStatus?`\n[status: ${n.outboxStatus}]`:``]})]}):null,n.clientInfo?.extensionsDetected&&n.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:i()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:n.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:B()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[n.clientInfo?.language,n.clientInfo?.timezone,n.clientInfo?.theme?_({theme:n.clientInfo.theme}):null,n.runId?`run ${n.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,n.clientInfo?.plugins&&n.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[s(),` `,n.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,u()]})]}):null,n.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:n.clientInfo.userAgent}):null]})]})]})}function be(){let e=v(l.feedback.listForAdmin,{}),t=c(l.feedback.readSnapshot),n=c(l.feedback.deleteFeedback),r=ge(),[i,a]=(0,X.useState)(null),[s,u]=(0,X.useState)({});async function d(e){if(i===e._id){a(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});u(t=>({...t,[e._id]:n}))}a(e._id)}async function f(e){await r({title:q(),description:U(),confirmLabel:se(),destructive:!0})&&(await n({feedbackId:e._id}),i===e._id&&a(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[x(),` `,(0,Z.jsx)(`strong`,{children:de()}),` `,o()]}),(0,Z.jsx)(Y,{title:b(),rows:e,emptyHint:fe(),isExpanded:e=>i===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(ye,{data:s[e._id],closeReason:e.userCloseReason}):null,columns:[{header:j(),cell:e=>_e(e.at),sort:e=>e.at},{header:pe(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:ue(),cell:e=>e.messageRole===`user`?O():I(),sort:e=>e.messageRole},{header:L(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${H({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:G(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:F(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:N(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:le()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:V()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:J()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:M()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:i===e._id?ae():k(),onSelect:()=>void d(e)},{label:R(),onSelect:()=>void f(e),variant:`destructive`}]})]})}export{be as FeedbacksTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,AC as i,BC as a,CC as o,DC as s,DM as c,E as l,EC as u,FC as d,GC as f,HC as ee,IC as p,JC as m,KC as te,LC as ne,MC as h,NC as g,OC as _,OM as v,PC as re,QC as y,RC as ie,SC as b,TC as x,UC as S,VC as C,WC as w,XC as T,YC as E,ZC as D,_C as O,aC as k,ai as A,bC as j,cC as M,dC as N,ew as P,fC as F,gC as I,hC as L,iC as R,jC as z,kC as B,lC as V,mC as H,nC as U,nw as W,oC as ae,pC as G,qC as K,rC as q,ri as J,sC as oe,tC as se,tw as ce,uC as le,vC as ue,wC as de,xC as fe,yC as pe,zC as me}from"./dist-HBBi9Y25.js";import{t as he}from"./button-b04wLuGq.js";import{B as ge,et as _e}from"./index-4Peu865E.js";import{t as Y}from"./DataTableShell-DtJr2ebT.js";var X=t(e(),1),Z=n(),ve={altered_words:()=>W(),incorrect:()=>ce(),incoherence:()=>P(),formatting:()=>r(),latency:()=>y(),api_error:()=>D(),other:()=>T()},Q=e=>ve[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:m()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:K()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:E()})}function ye({data:e,closeReason:t}){let n=e.snapshot,r=c(l.feedback.respondToFeedback),[o,m]=(0,X.useState)(e.thread),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(!1);async function T(){let t=v.trim();if(!(!t||b)){x(!0);try{await r({feedbackId:e._id,text:t}),m(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),y(``)}finally{x(!1)}}}let E=[];try{E=n.contextJson?JSON.parse(n.contextJson):[]}catch{E=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:n.displayedMatchesStored,sourceWasOpen:n.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,n.messageRole,n.isRegeneration?` · ${te()}`:``,n.openclawModel?` · ${n.openclawModel}`:``,n.openclawRuntime?` (${n.openclawRuntime})`:``]})]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,t?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:oe()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:t})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),o.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:o.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`?S():e.authorRole===`agent`?e.authorLabel??A():ee()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:C()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:a(),value:v,maxLength:2e3,rows:3,onChange:e=>y(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(he,{size:`sm`,onClick:()=>void T(),disabled:!v.trim()||b,children:b?me():ie()})})]}),(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:n.messageText||p()})]}),n.clientInfo?.sourceWasOpen&&n.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:d()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.displayedText||p()})]}):null,n.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:re()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.promptText})]}):null,E.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g({count:n.contextCount??E.length,truncated:n.contextTruncated?h():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:E.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,n.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:z()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[n.outboxText??``,n.outboxStatus?`\n[status: ${n.outboxStatus}]`:``]})]}):null,n.clientInfo?.extensionsDetected&&n.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:i()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:n.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:B()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[n.clientInfo?.language,n.clientInfo?.timezone,n.clientInfo?.theme?_({theme:n.clientInfo.theme}):null,n.runId?`run ${n.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,n.clientInfo?.plugins&&n.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[s(),` `,n.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,u()]})]}):null,n.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:n.clientInfo.userAgent}):null]})]})]})}function be(){let e=v(l.feedback.listForAdmin,{}),t=c(l.feedback.readSnapshot),n=c(l.feedback.deleteFeedback),r=ge(),[i,a]=(0,X.useState)(null),[s,u]=(0,X.useState)({});async function d(e){if(i===e._id){a(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});u(t=>({...t,[e._id]:n}))}a(e._id)}async function f(e){await r({title:q(),description:U(),confirmLabel:se(),destructive:!0})&&(await n({feedbackId:e._id}),i===e._id&&a(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[x(),` `,(0,Z.jsx)(`strong`,{children:de()}),` `,o()]}),(0,Z.jsx)(Y,{title:b(),rows:e,emptyHint:fe(),isExpanded:e=>i===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(ye,{data:s[e._id],closeReason:e.userCloseReason}):null,columns:[{header:j(),cell:e=>_e(e.at),sort:e=>e.at},{header:pe(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:ue(),cell:e=>e.messageRole===`user`?O():I(),sort:e=>e.messageRole},{header:L(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${H({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:G(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:F(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:N(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:le()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:V()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:J()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:M()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:i===e._id?ae():k(),onSelect:()=>void d(e)},{label:R(),onSelect:()=>void f(e),variant:`destructive`}]})]})}export{be as FeedbacksTab};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,FM as n}from"./dist-HBBi9Y25.js";import{_ as r,g as i,h as a,v as o}from"./index-DBQ43N4_.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]
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,FM as n}from"./dist-HBBi9Y25.js";import{_ as r,g as i,h as a,v as o}from"./index-4Peu865E.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{$j as ee,Aj as te,Bj as r,Cj as ne,DM as i,Dj as a,E as o,Ej as s,Fj as re,Gj as ie,Hj as c,Ij as l,Jj as u,Kj as d,Lj as f,Mj as ae,Nj as oe,OM as se,Oj as ce,Pj as le,Qj as ue,Rj as p,Sj as de,Tj as fe,Uj as pe,Vj as m,Wj as me,Xj as h,Yj as g,Zj as he,bj as ge,ci as _e,jj as ve,kj as ye,li as _,qj as be,tD as xe,vj as v,wj as y,xM as b,xj as x,yM as S,yj as C,zj as w}from"./dist-HBBi9Y25.js";import{t as T}from"./button-b04wLuGq.js";import{C as E,Ft as D,G as O,H as k,Ht as A,J as j,K as M,S as N,U as Se,Ut as P,W as Ce,Y as we,b as F,ct as I,it as L,jt as Te,nt as Ee,p as De,q as Oe,rt as ke,st as Ae,w as R,x as z,z as je}from"./index-DBQ43N4_.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-CtNwimV_.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return c();case`audio`:return m();case`video`:return r();case`pdf`:return w();case`document`:return p();case`archive`:return f();default:return l()}}function q(){let[e,t]=(0,U.useState)(G),[n,r]=(0,U.useState)(G),[c,l]=(0,U.useState)(G),[f,p]=(0,U.useState)(G),[m,w]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=i(o.files.softDelete),Y=je();function Ie(){t(G),r(G),l(G),p(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(fe())}catch(e){Y.error(y(),e)}}let X=se(o.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:c===G?void 0:c,category:f===G?void 0:f,includeAutoGenerated:m||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(b(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:S()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||c!==G||f!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ee()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(F,{value:e,onValueChange:t,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":ue(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:he()}),(0,W.jsx)(N,{value:`inbound`,children:h()}),(0,W.jsx)(N,{value:`outbound`,children:g()})]})]}),(0,W.jsxs)(F,{value:n,onValueChange:r,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":u(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:be()}),Q.chats.map(e=>(0,W.jsx)(N,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(F,{value:c,onValueChange:l,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":d(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:ie()}),Q.instances.map(e=>(0,W.jsx)(N,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(F,{value:f,onValueChange:p,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":me(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:pe()}),Q.categories.map(e=>(0,W.jsx)(N,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(De,{checked:m,onCheckedChange:e=>w(e===!0),"aria-label":_()}),(0,W.jsx)(`span`,{children:_()})]}),$?(0,W.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(D,{size:14,"aria-hidden":!0}),ce()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?C():ge()}):(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:re()}),(0,W.jsx)(B,{children:le()}),(0,W.jsx)(B,{children:oe()}),(0,W.jsx)(B,{children:ae()}),(0,W.jsx)(B,{children:ve()}),(0,W.jsx)(B,{className:`text-right`,children:te()})]})}),(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:_e()}):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`?h():g()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(Ee,{children:[(0,W.jsx)(Ae,{asChild:!0,children:(0,W.jsx)(T,{variant:`ghost`,size:`icon`,"aria-label":a(),children:(0,W.jsx)(A,{size:16})})}),(0,W.jsxs)(ke,{align:`end`,children:[e.url?(0,W.jsx)(L,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(P,{size:14}),ye()]})}):(0,W.jsxs)(L,{disabled:!0,children:[(0,W.jsx)(P,{size:14}),x()]}),(0,W.jsxs)(L,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Te,{size:14}),s()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:v({cap:Be})}):null]}),(0,W.jsx)(k,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(O,{children:[(0,W.jsxs)(j,{children:[(0,W.jsx)(we,{children:ne()}),(0,W.jsx)(M,{children:de()})]}),(0,W.jsxs)(Oe,{children:[(0,W.jsx)(Ce,{children:xe()}),(0,W.jsx)(Se,{onClick:()=>void Le(),children:s()})]})]})})]})}export{q as FilesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$j as ee,Aj as te,Bj as r,Cj as ne,DM as i,Dj as a,E as o,Ej as s,Fj as re,Gj as ie,Hj as c,Ij as l,Jj as u,Kj as d,Lj as f,Mj as ae,Nj as oe,OM as se,Oj as ce,Pj as le,Qj as ue,Rj as p,Sj as de,Tj as fe,Uj as pe,Vj as m,Wj as me,Xj as h,Yj as g,Zj as he,bj as ge,ci as _e,jj as ve,kj as ye,li as _,qj as be,tD as xe,vj as v,wj as y,xM as b,xj as x,yM as S,yj as C,zj as w}from"./dist-HBBi9Y25.js";import{t as T}from"./button-b04wLuGq.js";import{C as E,Ft as D,G as O,H as k,Ht as A,J as j,K as M,S as N,U as Se,Ut as P,W as Ce,Y as we,b as F,ct as I,it as L,jt as Te,nt as Ee,p as De,q as Oe,rt as ke,st as Ae,w as R,x as z,z as je}from"./index-4Peu865E.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-CtNwimV_.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return c();case`audio`:return m();case`video`:return r();case`pdf`:return w();case`document`:return p();case`archive`:return f();default:return l()}}function q(){let[e,t]=(0,U.useState)(G),[n,r]=(0,U.useState)(G),[c,l]=(0,U.useState)(G),[f,p]=(0,U.useState)(G),[m,w]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=i(o.files.softDelete),Y=je();function Ie(){t(G),r(G),l(G),p(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(fe())}catch(e){Y.error(y(),e)}}let X=se(o.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:c===G?void 0:c,category:f===G?void 0:f,includeAutoGenerated:m||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(b(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:S()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||c!==G||f!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ee()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(F,{value:e,onValueChange:t,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":ue(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:he()}),(0,W.jsx)(N,{value:`inbound`,children:h()}),(0,W.jsx)(N,{value:`outbound`,children:g()})]})]}),(0,W.jsxs)(F,{value:n,onValueChange:r,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":u(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:be()}),Q.chats.map(e=>(0,W.jsx)(N,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(F,{value:c,onValueChange:l,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":d(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:ie()}),Q.instances.map(e=>(0,W.jsx)(N,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(F,{value:f,onValueChange:p,children:[(0,W.jsx)(E,{size:`sm`,"aria-label":me(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(N,{value:G,children:pe()}),Q.categories.map(e=>(0,W.jsx)(N,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(De,{checked:m,onCheckedChange:e=>w(e===!0),"aria-label":_()}),(0,W.jsx)(`span`,{children:_()})]}),$?(0,W.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(D,{size:14,"aria-hidden":!0}),ce()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?C():ge()}):(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:re()}),(0,W.jsx)(B,{children:le()}),(0,W.jsx)(B,{children:oe()}),(0,W.jsx)(B,{children:ae()}),(0,W.jsx)(B,{children:ve()}),(0,W.jsx)(B,{className:`text-right`,children:te()})]})}),(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:_e()}):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`?h():g()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(Ee,{children:[(0,W.jsx)(Ae,{asChild:!0,children:(0,W.jsx)(T,{variant:`ghost`,size:`icon`,"aria-label":a(),children:(0,W.jsx)(A,{size:16})})}),(0,W.jsxs)(ke,{align:`end`,children:[e.url?(0,W.jsx)(L,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(P,{size:14}),ye()]})}):(0,W.jsxs)(L,{disabled:!0,children:[(0,W.jsx)(P,{size:14}),x()]}),(0,W.jsxs)(L,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Te,{size:14}),s()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:v({cap:Be})}):null]}),(0,W.jsx)(k,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(O,{children:[(0,W.jsxs)(j,{children:[(0,W.jsx)(we,{children:ne()}),(0,W.jsx)(M,{children:de()})]}),(0,W.jsxs)(Oe,{children:[(0,W.jsx)(Ce,{children:xe()}),(0,W.jsx)(Se,{onClick:()=>void Le(),children:s()})]})]})})]})}export{q as FilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Uf as r,Wf as i}from"./dist-HBBi9Y25.js";import{t as a}from"./button-b04wLuGq.js";import{Ft as o,Pt as s,lt as c}from"./index-DBQ43N4_.js";import{t as l}from"./TimeRangePicker-NSOkx3C0.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)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(c,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),r()]})]})}export{p as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Uf as r,Wf as i}from"./dist-HBBi9Y25.js";import{t as a}from"./button-b04wLuGq.js";import{Ft as o,Pt as s,lt as c}from"./index-4Peu865E.js";import{t as l}from"./TimeRangePicker-BeZLlC4Y.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)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(c,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),r()]})]})}export{p as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$l as r,$u as i,Au as a,Bu as o,Cu as s,D as c,DM as l,Du as u,E as d,Eu as f,Fu as p,Gu as m,Hu as h,Iu as g,Jl as _,Ju as v,Ku as y,Lu as b,Mu as x,Nu as S,OM as C,Ou as w,Pu as T,Ql as E,Qu as D,Ru as ee,Su as O,Tu as k,Uu as A,Vu as j,Wu as te,Xl as M,Xu as N,Yl as ne,Yu as re,Zl as P,Zu as F,_u as I,au as L,bu as ie,cu as R,du as ae,ed as z,eu as oe,fu as se,gu as ce,hu as le,iu as ue,ju as de,ku as fe,lu as pe,mu as me,nd as he,nu as ge,ou as _e,pu as ve,ql as ye,qu as be,ru as xe,su as Se,td as Ce,tu as we,uu as Te,vu as B,wu as Ee,xu as De,yu as Oe,zu as ke}from"./dist-HBBi9Y25.js";import{t as Ae}from"./x-DBKGK4o_.js";import{i as V,n as H,r as je,t as Me}from"./tabs-BJyz65LR.js";import{t as U}from"./button-b04wLuGq.js";import{B as Ne,C as Pe,Jt as Fe,Mt as W,Nt as G,S as Ie,b as Le,ct as K,dt as Re,ft as ze,ht as Be,lt as q,mt as Ve,p as J,qt as He,u as Ue,ut as We,w as Ge,x as Ke,xt as qe,z as Y}from"./index-DBQ43N4_.js";import{t as Je}from"./FilterBar-BVVVO1_O.js";import{t as Ye}from"./DataTableShell-KGrtOG5M.js";import{t as X}from"./DetailChips-C2LFFpNg.js";var Xe=c(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Z=c(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ze=c(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Q=t(e(),1);function Qe(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function $e(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function et(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function tt(e){switch(e){case`admin`:return s();case`user`:return O();case`pending`:return De();default:return e}}function nt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function rt(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var $=n(),it={name:``,description:``};function at(){let e=C(d.groups.listGroups,{}),t=C(d.me.getMe,{host:qe})?.role===`admin`,n=l(d.groups.createGroup),r=l(d.groups.updateGroup),a=l(d.groups.deleteGroup),s=Ne(),c=Y(),[u,f]=(0,Q.useState)(!1),[_,x]=(0,Q.useState)(null),[S,w]=(0,Q.useState)(it),[T,E]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(``),P=(0,Q.useMemo)(()=>{if(!e)return e;let t=O.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,O]);function I(){x(null),w(it),f(!0)}function L(e){x(e),w({name:e.name,description:e.description??``}),f(!0)}async function ie(){try{_?await r({groupId:_._id,name:S.name,description:S.description}):await n({name:S.name,description:S.description||void 0}),w(it),x(null),f(!1)}catch(e){c.error(M(),e)}}async function R(e){if(await s({title:b({name:e.name}),description:g(),confirmWord:e.name,confirmLabel:p(),cancelLabel:A(),destructive:!0}))try{await a({groupId:e._id})}catch(e){c.error(ne(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),(0,$.jsx)(Je,{q:O,onQChange:k,onReset:()=>k(``),canReset:O!==``,searchPlaceholder:v()}),(0,$.jsx)(Ye,{title:he(),rows:P,addLabel:z(),onAdd:t?I:void 0,emptyHint:i(),columns:[{header:D(),cell:e=>e.name,sort:e=>e.name},{header:F(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(Z,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:N(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(G,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:re(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Xe,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:be(),onSelect:()=>E({groupId:e._id,name:e.name})},...t?[{label:y(),onSelect:()=>L(e)},{label:m(),variant:`destructive`,onSelect:()=>void R(e)}]:[]]}),(0,$.jsx)(Ue,{open:u,onOpenChange:f,title:_?j():h(),description:o(),canSubmit:!!S.name.trim(),onSubmit:ie,submitLabel:te(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:ke()}),(0,$.jsx)(q,{value:S.name,onChange:e=>w({...S,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:ee()}),(0,$.jsx)(q,{value:S.description,onChange:e=>w({...S,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:T?.groupId??null,groupName:T?.name??``,open:T!==null,onOpenChange:e=>{e||E(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Fe,{size:14,"aria-hidden":!0}),f()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":Ee({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[k(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:i}){let o=C(d.groups.getGroup,n&&e?{groupId:e}:`skip`),s=C(d.groups.listAssignableInstances,n?{}:`skip`),c=C(d.groups.listAssignableUsers,n?{}:`skip`),f=l(d.groups.addMember),p=l(d.groups.removeMember),m=l(d.groups.bulkSetMembers),h=l(d.groups.setGroupManager),g=Y(),[v,y]=(0,Q.useState)(``),[b,D]=(0,Q.useState)(``),[ee,O]=(0,Q.useState)(`members`),[k,A]=(0,Q.useState)(1),[j,te]=(0,Q.useState)(new Set),M=(0,Q.useRef)(null),N=(0,Q.useMemo)(()=>new Set((o?.members??[]).map(e=>e.userId)),[o]),ne=(0,Q.useMemo)(()=>new Set((o?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[o]),re=o?.viewerIsAdmin===!0,P=(0,Q.useMemo)(()=>new Set((o?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[o]);(0,Q.useEffect)(()=>{y(``),D(``),O(`members`),A(1),M.current=null},[n,e]),(0,Q.useEffect)(()=>{A(1)},[v]),(0,Q.useEffect)(()=>{n&&o&&e&&M.current!==e&&(M.current=e,te(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let F=(0,Q.useMemo)(()=>c?Qe(c,v,j):[],[c,v,j]);async function I(t,n){if(e)try{n?await p({groupId:e,userId:t}):await f({groupId:e,userId:t})}catch(e){g.error(_(),e)}}async function L(t,n){if(e)try{await h({groupId:e,userId:t,manager:!n})}catch(e){g.error(E(),e)}}let R=nt(F,e=>N.has(e.userId)),ae=F.filter(e=>N.has(e.userId)).length,z=rt(F,k,ot);async function se(){if(!e||F.length===0)return;let t=F.map(e=>e.userId);try{await m({groupId:e,userIds:t,member:R!==`all`})}catch(e){g.error(_(),e)}}return(0,$.jsx)(We,{open:n,onOpenChange:i,children:(0,$.jsxs)(Re,{className:`oc-access`,children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:T({name:t})}),(0,$.jsx)(ze,{children:S()})]}),(0,$.jsxs)(Me,{value:ee,onValueChange:O,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(V,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),x(),o?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),a(),o?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:P.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),pe(),o?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:o.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:c===void 0||o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ce()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:v,onChange:e=>y(e.target.value),placeholder:de(),className:`oc-access__search`}),F.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}):(0,$.jsxs)($.Fragment,{children:[F.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:R===`all`?!0:R===`some`?`indeterminate`:!1,onCheckedChange:()=>void se(),"aria-label":u()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:u()}),(0,$.jsxs)(K,{variant:`outline`,className:`oc-access__count`,children:[ae,` / `,F.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:z.pageItems.map(e=>{let t=N.has(e.userId),n=et(e),i=ne.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:t,onCheckedChange:()=>void I(e.userId,t),"aria-label":ie({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&re?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${i?` oc-access__mgr--on`:``}`,"aria-pressed":i,"aria-label":i?r():oe(),title:i?r():oe(),onClick:()=>void L(e.userId,i),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&i?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":we(),title:we(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:z.page,pageCount:z.pageCount,onPage:A})]})]})}),(0,$.jsx)(H,{value:`agents`,children:s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:le()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:b,onChange:e=>D(e.target.value),placeholder:fe(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:P,query:b},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=C(d.groups.listAssignableAgents,{instanceName:t}),o=l(d.groups.assignAgentToGroup),s=l(d.groups.removeAgentFromGroup),c=l(d.groups.bulkSetGroupAgents),f=Y(),[p,m]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{m(1)},[i]),!e)return null;let h=$e(a?.agents??[],i),g=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&h.length===0)return null;let _=h.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),v=nt(_,e=>r.has(`${t}/${e.agentId}`)),y=rt(h,p,ot);async function b(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){f.error(ye(),e)}}async function x(){if(_.length===0)return;let n=_.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:v!==`all`})}catch(e){f.error(ye(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n}),g?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__stale`,children:se()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:I()}):h.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:g?ve():me()}):(0,$.jsxs)($.Fragment,{children:[_.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:v===`all`?!0:v===`some`?`indeterminate`:!1,onCheckedChange:()=>void x(),"aria-label":u()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:u()})]}):null,y.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(J,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void b(e.agentId,i),"aria-label":Oe({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":Te(),title:Te(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:ae()}):null]},e.agentId)}),(0,$.jsx)(st,{page:y.page,pageCount:y.pageCount,onPage:m})]})]})}function ut({groupId:e}){let t=C(d.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=l(d.charts.assignChartToGroup),r=l(d.charts.removeChartFromGroup),i=l(d.charts.setGroupDefaultChart),a=l(d.charts.addChartToGroupPool),o=l(d.charts.removeChartFromGroupPool),s=Y();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()});let{pool:c,addable:u,canManagePool:f}=t;if(c.length===0&&!f)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:R()});async function p(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}async function m(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":ue({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":xe(),title:xe(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:ge()}):null,f?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":L({name:e.name}),title:L({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?u.length>0?(0,$.jsxs)(Le,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)(Pe,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ge,{placeholder:_e()})}),(0,$.jsx)(Ke,{children:u.map(e=>(0,$.jsx)(Ie,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Se()}):null:null]})}export{at as GroupsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$l as r,$u as i,Au as a,Bu as o,Cu as s,D as c,DM as l,Du as u,E as d,Eu as f,Fu as p,Gu as m,Hu as h,Iu as g,Jl as _,Ju as v,Ku as y,Lu as b,Mu as x,Nu as S,OM as C,Ou as w,Pu as T,Ql as E,Qu as D,Ru as ee,Su as O,Tu as k,Uu as A,Vu as j,Wu as te,Xl as M,Xu as N,Yl as ne,Yu as re,Zl as P,Zu as F,_u as I,au as L,bu as ie,cu as R,du as ae,ed as z,eu as oe,fu as se,gu as ce,hu as le,iu as ue,ju as de,ku as fe,lu as pe,mu as me,nd as he,nu as ge,ou as _e,pu as ve,ql as ye,qu as be,ru as xe,su as Se,td as Ce,tu as we,uu as Te,vu as B,wu as Ee,xu as De,yu as Oe,zu as ke}from"./dist-HBBi9Y25.js";import{t as Ae}from"./x-DBKGK4o_.js";import{i as V,n as H,r as je,t as Me}from"./tabs-0f19le6d.js";import{t as U}from"./button-b04wLuGq.js";import{B as Ne,C as Pe,Jt as Fe,Mt as W,Nt as G,S as Ie,b as Le,ct as K,dt as Re,ft as ze,ht as Be,lt as q,mt as Ve,p as J,qt as He,u as Ue,ut as We,w as Ge,x as Ke,xt as qe,z as Y}from"./index-4Peu865E.js";import{t as Je}from"./FilterBar-Csl1r1c5.js";import{t as Ye}from"./DataTableShell-DtJr2ebT.js";import{t as X}from"./DetailChips-CXG_QPSx.js";var Xe=c(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Z=c(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ze=c(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Q=t(e(),1);function Qe(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function $e(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function et(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function tt(e){switch(e){case`admin`:return s();case`user`:return O();case`pending`:return De();default:return e}}function nt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function rt(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var $=n(),it={name:``,description:``};function at(){let e=C(d.groups.listGroups,{}),t=C(d.me.getMe,{host:qe})?.role===`admin`,n=l(d.groups.createGroup),r=l(d.groups.updateGroup),a=l(d.groups.deleteGroup),s=Ne(),c=Y(),[u,f]=(0,Q.useState)(!1),[_,x]=(0,Q.useState)(null),[S,w]=(0,Q.useState)(it),[T,E]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(``),P=(0,Q.useMemo)(()=>{if(!e)return e;let t=O.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,O]);function I(){x(null),w(it),f(!0)}function L(e){x(e),w({name:e.name,description:e.description??``}),f(!0)}async function ie(){try{_?await r({groupId:_._id,name:S.name,description:S.description}):await n({name:S.name,description:S.description||void 0}),w(it),x(null),f(!1)}catch(e){c.error(M(),e)}}async function R(e){if(await s({title:b({name:e.name}),description:g(),confirmWord:e.name,confirmLabel:p(),cancelLabel:A(),destructive:!0}))try{await a({groupId:e._id})}catch(e){c.error(ne(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),(0,$.jsx)(Je,{q:O,onQChange:k,onReset:()=>k(``),canReset:O!==``,searchPlaceholder:v()}),(0,$.jsx)(Ye,{title:he(),rows:P,addLabel:z(),onAdd:t?I:void 0,emptyHint:i(),columns:[{header:D(),cell:e=>e.name,sort:e=>e.name},{header:F(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Ze,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(Z,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:N(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(G,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:re(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(Xe,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(W,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:be(),onSelect:()=>E({groupId:e._id,name:e.name})},...t?[{label:y(),onSelect:()=>L(e)},{label:m(),variant:`destructive`,onSelect:()=>void R(e)}]:[]]}),(0,$.jsx)(Ue,{open:u,onOpenChange:f,title:_?j():h(),description:o(),canSubmit:!!S.name.trim(),onSubmit:ie,submitLabel:te(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:ke()}),(0,$.jsx)(q,{value:S.name,onChange:e=>w({...S,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:ee()}),(0,$.jsx)(q,{value:S.description,onChange:e=>w({...S,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:T?.groupId??null,groupName:T?.name??``,open:T!==null,onOpenChange:e=>{e||E(null)}})]})}var ot=8;function st({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Fe,{size:14,"aria-hidden":!0}),f()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":Ee({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[k(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:i}){let o=C(d.groups.getGroup,n&&e?{groupId:e}:`skip`),s=C(d.groups.listAssignableInstances,n?{}:`skip`),c=C(d.groups.listAssignableUsers,n?{}:`skip`),f=l(d.groups.addMember),p=l(d.groups.removeMember),m=l(d.groups.bulkSetMembers),h=l(d.groups.setGroupManager),g=Y(),[v,y]=(0,Q.useState)(``),[b,D]=(0,Q.useState)(``),[ee,O]=(0,Q.useState)(`members`),[k,A]=(0,Q.useState)(1),[j,te]=(0,Q.useState)(new Set),M=(0,Q.useRef)(null),N=(0,Q.useMemo)(()=>new Set((o?.members??[]).map(e=>e.userId)),[o]),ne=(0,Q.useMemo)(()=>new Set((o?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[o]),re=o?.viewerIsAdmin===!0,P=(0,Q.useMemo)(()=>new Set((o?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[o]);(0,Q.useEffect)(()=>{y(``),D(``),O(`members`),A(1),M.current=null},[n,e]),(0,Q.useEffect)(()=>{A(1)},[v]),(0,Q.useEffect)(()=>{n&&o&&e&&M.current!==e&&(M.current=e,te(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let F=(0,Q.useMemo)(()=>c?Qe(c,v,j):[],[c,v,j]);async function I(t,n){if(e)try{n?await p({groupId:e,userId:t}):await f({groupId:e,userId:t})}catch(e){g.error(_(),e)}}async function L(t,n){if(e)try{await h({groupId:e,userId:t,manager:!n})}catch(e){g.error(E(),e)}}let R=nt(F,e=>N.has(e.userId)),ae=F.filter(e=>N.has(e.userId)).length,z=rt(F,k,ot);async function se(){if(!e||F.length===0)return;let t=F.map(e=>e.userId);try{await m({groupId:e,userIds:t,member:R!==`all`})}catch(e){g.error(_(),e)}}return(0,$.jsx)(We,{open:n,onOpenChange:i,children:(0,$.jsxs)(Re,{className:`oc-access`,children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:T({name:t})}),(0,$.jsx)(ze,{children:S()})]}),(0,$.jsxs)(Me,{value:ee,onValueChange:O,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(V,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),x(),o?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),a(),o?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:P.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),pe(),o?(0,$.jsx)(K,{variant:`secondary`,className:`oc-access__tabcount`,children:o.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:c===void 0||o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ce()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:v,onChange:e=>y(e.target.value),placeholder:de(),className:`oc-access__search`}),F.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}):(0,$.jsxs)($.Fragment,{children:[F.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:R===`all`?!0:R===`some`?`indeterminate`:!1,onCheckedChange:()=>void se(),"aria-label":u()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:u()}),(0,$.jsxs)(K,{variant:`outline`,className:`oc-access__count`,children:[ae,` / `,F.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:z.pageItems.map(e=>{let t=N.has(e.userId),n=et(e),i=ne.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:t,onCheckedChange:()=>void I(e.userId,t),"aria-label":ie({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&re?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${i?` oc-access__mgr--on`:``}`,"aria-pressed":i,"aria-label":i?r():oe(),title:i?r():oe(),onClick:()=>void L(e.userId,i),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&i?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":we(),title:we(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:z.page,pageCount:z.pageCount,onPage:A})]})]})}),(0,$.jsx)(H,{value:`agents`,children:s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:le()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:b,onChange:e=>D(e.target.value),placeholder:fe(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:P,query:b},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=C(d.groups.listAssignableAgents,{instanceName:t}),o=l(d.groups.assignAgentToGroup),s=l(d.groups.removeAgentFromGroup),c=l(d.groups.bulkSetGroupAgents),f=Y(),[p,m]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{m(1)},[i]),!e)return null;let h=$e(a?.agents??[],i),g=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&h.length===0)return null;let _=h.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),v=nt(_,e=>r.has(`${t}/${e.agentId}`)),y=rt(h,p,ot);async function b(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){f.error(ye(),e)}}async function x(){if(_.length===0)return;let n=_.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:v!==`all`})}catch(e){f.error(ye(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(G,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(K,{variant:`outline`,className:`oc-access__kind`,children:n}),g?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__stale`,children:se()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:I()}):h.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:g?ve():me()}):(0,$.jsxs)($.Fragment,{children:[_.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(J,{checked:v===`all`?!0:v===`some`?`indeterminate`:!1,onCheckedChange:()=>void x(),"aria-label":u()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:u()})]}):null,y.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(J,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void b(e.agentId,i),"aria-label":Oe({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":Te(),title:Te(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(K,{variant:`outline`,className:`oc-access__gone`,children:ae()}):null]},e.agentId)}),(0,$.jsx)(st,{page:y.page,pageCount:y.pageCount,onPage:m})]})]})}function ut({groupId:e}){let t=C(d.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=l(d.charts.assignChartToGroup),r=l(d.charts.removeChartFromGroup),i=l(d.charts.setGroupDefaultChart),a=l(d.charts.addChartToGroupPool),o=l(d.charts.removeChartFromGroupPool),s=Y();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()});let{pool:c,addable:u,canManagePool:f}=t;if(c.length===0&&!f)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:R()});async function p(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}async function m(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}async function h(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}async function g(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(P(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(J,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":ue({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":xe(),title:xe(),children:(0,$.jsx)(W,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:ge()}):null,f?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":L({name:e.name}),title:L({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?u.length>0?(0,$.jsxs)(Le,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)(Pe,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ge,{placeholder:_e()})}),(0,$.jsx)(Ke,{children:u.map(e=>(0,$.jsx)(Ie,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Se()}):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{$b as r,$x as i,Ax as a,Bx as o,CS as s,Cx as c,DM as l,DS as u,Dx as d,E as f,ES as p,Ex as m,Fx as h,Gb as g,Gx as _,Hb as v,Hx as y,Ix as b,JD as x,Jb as S,Jt as C,Jx as w,Kb as T,Kx as ee,Lx as te,Mg as ne,Mx as re,Ng as ie,Nx as E,OM as D,Ox as O,Px as ae,Qb as oe,Qx as se,Rx as ce,SS as le,Sx as ue,TM as k,TS as de,Tx as fe,Ub as pe,Ux as me,Vb as he,Vx as ge,Wb as _e,Wx as A,Xb as ve,Xt as ye,Xx as be,Yb as xe,Yt as Se,Yx as Ce,Zb as we,Zx as Te,_S as Ee,_x as De,aS as Oe,ax as ke,bS as Ae,bx as je,cS as Me,ca as Ne,cx as j,dS as Pe,da as Fe,dx as M,eS as Ie,ex as Le,fS as Re,fx as ze,gS as Be,gx as Ve,hS as He,hx as Ue,iS as We,ix as Ge,jx as Ke,kx as qe,lS as Je,la as Ye,lx as Xe,mS as Ze,mx as Qe,nS as $e,nx as et,oS as tt,ox as nt,pS as N,px as rt,qD as it,qb as at,qx as ot,rS as st,rx as ct,sS as lt,sx as ut,tS as dt,tx as ft,uS as pt,ua as mt,ux as ht,vS as gt,vx as _t,wS as vt,wx as yt,xS as bt,xx as xt,yS as St,yx as Ct,zx as wt}from"./dist-HBBi9Y25.js";import{a as Tt,c as Et}from"./FieldLabel-CKVYl95W.js";import{t as P}from"./button-b04wLuGq.js";import{B as Dt,C as F,Q as Ot,S as I,X as kt,Z as At,b as L,ct as R,dt as z,ft as B,ht as V,lt as H,mt as U,p as W,u as jt,ut as G,w as K,x as q,z as J}from"./index-DBQ43N4_.js";import{t as Mt}from"./DataTableShell-KGrtOG5M.js";import{InstanceConfigDialog as Nt}from"./BridgeTab-DFpunFsv.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],Pt=new Set(X),Ft=`conversational`;function It(e){let t=new Set((e??[]).filter(e=>Pt.has(e)));return t.size===0?[Ft]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Tt},Lt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Rt(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 zt(){let e=D(f.admin.listInstances,{}),t=D(f.agents.listAllInstanceAgents,{}),n=l(f.admin.upsertInstance),r=l(f.admin.deleteInstance),a=J(),[o,c]=(0,Y.useState)(!1),[d,m]=(0,Y.useState)(Q),[h,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),[S,w]=(0,Y.useState)(null);async function T(){try{await n({instanceId:S??void 0,name:d.name,gatewayUrl:d.gatewayUrl,bridgeUrl:d.bridgeUrl||void 0,displayName:d.displayName||void 0,kind:d.kind,transport:d.kind===`hermes`?d.transport:void 0,gatewayVersion:d.gatewayVersion||void 0,gatewayHttpUrl:d.gatewayHttpUrl||void 0,streamTransport:d.streamTransport}),m(Q),w(null),c(!1)}catch(e){a.error(de(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[vt(),(0,Z.jsx)(`strong`,{children:s()}),le()]}),(0,Z.jsx)(Mt,{title:bt(),rows:e,addLabel:Ae(),onAdd:()=>{w(null),m(Q),c(!0)},emptyHint:St(),columns:[{header:gt(),cell:e=>e.name,sort:e=>e.name},{header:Ee(),cell:e=>(0,Z.jsx)(R,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Be(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:He(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:u(),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)(R,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?v():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Pe(),onSelect:()=>{w(e._id),m(Rt(e)),c(!0)}},{label:p(),onSelect:()=>g(e.name)},{label:be(),onSelect:()=>x(e)},{label:Ze(),onSelect:()=>y(e)},{label:N(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:N(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(jt,{open:o,onOpenChange:c,title:S?pt():Re(),description:Me(),canSubmit:!!(d.name&&d.gatewayUrl),onSubmit:T,submitLabel:lt(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:tt(),children:[(0,Z.jsx)(H,{value:d.name,disabled:S!==null,onChange:e=>m({...d,name:e.target.value})}),S?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Je()}):null]}),(0,Z.jsx)($,{label:Oe(),children:(0,Z.jsxs)(L,{value:d.kind,onValueChange:e=>m({...d,kind:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(I,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(I,{value:`hermes`,children:`Hermes`})]})]})}),d.kind===`hermes`?(0,Z.jsx)($,{label:ye(),children:(0,Z.jsxs)(L,{value:d.transport,onValueChange:e=>m({...d,transport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(I,{value:`ws`,children:Se()}),(0,Z.jsx)(I,{value:`rest`,children:C()})]})]})}):null,(0,Z.jsx)($,{label:We(),children:(0,Z.jsx)(H,{value:d.gatewayUrl,onChange:e=>m({...d,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:st(),children:(0,Z.jsx)(H,{value:d.bridgeUrl,placeholder:$e(),onChange:e=>m({...d,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:dt(),children:(0,Z.jsx)(H,{value:d.displayName,onChange:e=>m({...d,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:ie(),children:[(0,Z.jsxs)(L,{value:d.streamTransport,onValueChange:e=>m({...d,streamTransport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsx)(q,{children:Et.map(e=>(0,Z.jsx)(I,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ne()})]}),(0,Z.jsx)($,{label:Ie(),children:(0,Z.jsx)(H,{value:d.gatewayVersion,placeholder:i(),onChange:e=>m({...d,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:se(),children:(0,Z.jsx)(H,{value:d.gatewayHttpUrl,placeholder:Te(),onChange:e=>m({...d,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Yt,{instanceName:h,open:h!==null,onOpenChange:e=>{e||g(null)}}),_?(0,Z.jsx)(Nt,{instance:_,onClose:()=>y(null)},_._id):null,b?(0,Z.jsx)(Bt,{instance:b,onClose:()=>x(null)},b._id):null]})}function Bt({instance:e,onClose:t}){let n=D(f.instanceSecrets.listInstanceSecretStatus,{}),r=Lt[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)(G,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(z,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{children:Ce({instance:e.displayName??e.name})}),(0,Z.jsx)(B,{children:w()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Ut,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ht,{instance:e})}),(0,Z.jsx)(Vt,{instance:e})]})})}function Vt({instance:e}){let t=k(f.instanceSync.forceInstanceSync),n=J(),[r,i]=(0,Y.useState)(!1);async function o(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(O());break;case`no_agents`:n.success(m());break;case`no_bridge_url`:n.error(fe());break;case`deploy_misconfigured`:n.error(yt());break;case`unauthorized`:n.error(ue());break;case`not_served`:n.error(xt());break;default:n.error(c());break}}catch(e){n.error(d(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:je()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:r,children:r?qe():a()})})]})}function Ht({instance:e}){let t=D(f.bridgeAuth.listBridgeAuthStatus,{}),n=k(f.bridgeAuth.mintBridgeSecret),r=l(f.bridgeAuth.revokeBridgeSecret),i=J(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),p=(t??[]).find(t=>t.instanceId===e._id),m=p!==void 0;async function h(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(rt(),e)}finally{o(!1)}}}async function g(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Qe())}catch(e){i.error(rt(),e)}finally{o(!1)}}}async function _(){if(s)try{await navigator.clipboard.writeText(s),d(!0)}catch{}}return(0,Z.jsxs)($,{label:Ct(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_t()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(R,{variant:m?`outline`:`secondary`,children:m?`${A()} · ${p.prefix}…${p.lastFour}`:me()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void h(),disabled:a,children:m?Ve():De()}),m?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void g(),disabled:a,children:Ue()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:ze()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:u?x():it()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),d(!1)},children:M()})]}):null]})}function Ut({instanceId:e,field:t,updatedAt:n}){let r=k(f.instanceSecrets.setInstanceSecret),i=l(f.instanceSecrets.clearInstanceSecret),a=k(f.deviceIdentity.generateDeviceIdentity),s=J(),[c,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(null),[v,S]=(0,Y.useState)(!1),C=n!==null,w=t===`deviceIdentity`,T=t===`token`?ot():t===`deviceIdentity`?ee():_();async function ne(){if(!(!c.trim()||d)){p(!0);try{await r({instanceId:e,field:t,plaintext:c}),u(``),g(null),S(!1),s.success(ce())}catch(e){s.error(te(),e)}finally{p(!1)}}}async function ie(){if(!d){p(!0);try{await i({instanceId:e,field:t}),g(null),S(!1),s.success(b())}catch(e){s.error(te(),e)}finally{p(!1)}}}async function D(){if(!d){p(!0);try{g(await a({instanceId:e})),S(!1),s.success(E())}catch(e){s.error(Ke(),e)}finally{p(!1)}}}let O=m?`openclaw devices approve ${m.id}`:``;async function oe(){if(O)try{await navigator.clipboard.writeText(O),S(!0)}catch{}}return(0,Z.jsxs)($,{label:T,children:[w?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(R,{variant:C?`outline`:`secondary`,children:C?A():me()}),(0,Z.jsx)(H,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:C?ge():y(),onChange:e=>u(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void ne(),disabled:d||c.trim().length===0,children:o()}),w?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void D(),disabled:d,children:h()}):null,C?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void ie(),disabled:d,children:wt()}):null]})]}),m?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:E()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:re()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:O}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void oe(),children:v?x():it()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{g(null),S(!1)},children:M()})]}):null]})}var Wt={conversational:ct,documentary:ft,summarizer:Fe,curator:Ye},Gt={conversational:et,documentary:Le,summarizer:mt,curator:Ne},Kt=e=>(Wt[e]??(()=>e))(),qt=e=>(Gt[e]??(()=>``))();function Jt({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:ut()}),t.map(e=>(0,Z.jsx)(R,{variant:`secondary`,className:`oc-agenttype__chip`,title:qt(e),children:Kt(e)},e)),(0,Z.jsxs)(kt,{children:[(0,Z.jsx)(Ot,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:nt()})}),(0,Z.jsxs)(At,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:ke()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ge()}),(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)(W,{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:Kt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:qt(r)})]})]},r)})})]})]})]})}function Yt({instanceName:e,open:t,onOpenChange:n}){let i=D(f.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=l(f.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),o=l(f.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),s=l(f.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=It(r);e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=l(f.agents.removeInstanceAgent),u=Dt(),d=J();async function p(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){d.error(j(),e)}}async function m(t){if(e)try{await o({instanceName:e,agentId:t})}catch(e){d.error(j(),e)}}async function h(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await s({instanceName:e,agentId:t,types:i})}catch(e){d.error(j(),e)}}async function _(t,n){if(e&&await u({title:we({name:n}),description:ve(),confirmLabel:xe(),destructive:!0}))try{await c({instanceName:e,agentId:t}),d.success(S())}catch(e){d.error(j(),e)}}return(0,Z.jsx)(G,{open:t,onOpenChange:n,children:(0,Z.jsxs)(z,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{children:ht({name:e??``})}),(0,Z.jsx)(B,{children:Xe()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:at()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?T():i.discovery.lastPollOk?g():_e({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:pe()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(e=>{let t=e.presentInLastOk===!1,n=i.defaultAgentId===e.agentId,a=e.displayName??e.agentId,o=e.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(e.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(W,{checked:e.enabled,disabled:t,"aria-label":a,onCheckedChange:t=>void p(e.agentId,t===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[e.emoji?`${e.emoji} `:``,a]}),e.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__gone`,children:he()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void _(e.agentId,a),children:oe()})]}):n?(0,Z.jsx)(R,{variant:`default`,children:v()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!e.enabled,onClick:()=>void m(e.agentId),children:r()})]}),e.enabled?(0,Z.jsx)(Jt,{agentId:e.agentId,types:o,onToggle:t=>void h(e.agentId,t,o)}):null]},e.agentId)})})]})]})})}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{zt as InstancesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,$x as i,Ax as a,Bx as o,CS as s,Cx as c,DM as l,DS as u,Dx as d,E as f,ES as p,Ex as m,Fx as h,Gb as g,Gx as _,Hb as v,Hx as y,Ix as b,JD as x,Jb as S,Jt as C,Jx as w,Kb as T,Kx as ee,Lx as te,Mg as ne,Mx as re,Ng as ie,Nx as E,OM as D,Ox as O,Px as ae,Qb as oe,Qx as se,Rx as ce,SS as le,Sx as ue,TM as k,TS as de,Tx as fe,Ub as pe,Ux as me,Vb as he,Vx as ge,Wb as _e,Wx as A,Xb as ve,Xt as ye,Xx as be,Yb as xe,Yt as Se,Yx as Ce,Zb as we,Zx as Te,_S as Ee,_x as De,aS as Oe,ax as ke,bS as Ae,bx as je,cS as Me,ca as Ne,cx as j,dS as Pe,da as Fe,dx as M,eS as Ie,ex as Le,fS as Re,fx as ze,gS as Be,gx as Ve,hS as He,hx as Ue,iS as We,ix as Ge,jx as Ke,kx as qe,lS as Je,la as Ye,lx as Xe,mS as Ze,mx as Qe,nS as $e,nx as et,oS as tt,ox as nt,pS as N,px as rt,qD as it,qb as at,qx as ot,rS as st,rx as ct,sS as lt,sx as ut,tS as dt,tx as ft,uS as pt,ua as mt,ux as ht,vS as gt,vx as _t,wS as vt,wx as yt,xS as bt,xx as xt,yS as St,yx as Ct,zx as wt}from"./dist-HBBi9Y25.js";import{a as Tt,c as Et}from"./FieldLabel-DOYQdxs6.js";import{t as P}from"./button-b04wLuGq.js";import{B as Dt,C as F,Q as Ot,S as I,X as kt,Z as At,b as L,ct as R,dt as z,ft as B,ht as V,lt as H,mt as U,p as W,u as jt,ut as G,w as K,x as q,z as J}from"./index-4Peu865E.js";import{t as Mt}from"./DataTableShell-DtJr2ebT.js";import{InstanceConfigDialog as Nt}from"./BridgeTab-BYuXlyxy.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],Pt=new Set(X),Ft=`conversational`;function It(e){let t=new Set((e??[]).filter(e=>Pt.has(e)));return t.size===0?[Ft]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Tt},Lt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Rt(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 zt(){let e=D(f.admin.listInstances,{}),t=D(f.agents.listAllInstanceAgents,{}),n=l(f.admin.upsertInstance),r=l(f.admin.deleteInstance),a=J(),[o,c]=(0,Y.useState)(!1),[d,m]=(0,Y.useState)(Q),[h,g]=(0,Y.useState)(null),[_,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(null),[S,w]=(0,Y.useState)(null);async function T(){try{await n({instanceId:S??void 0,name:d.name,gatewayUrl:d.gatewayUrl,bridgeUrl:d.bridgeUrl||void 0,displayName:d.displayName||void 0,kind:d.kind,transport:d.kind===`hermes`?d.transport:void 0,gatewayVersion:d.gatewayVersion||void 0,gatewayHttpUrl:d.gatewayHttpUrl||void 0,streamTransport:d.streamTransport}),m(Q),w(null),c(!1)}catch(e){a.error(de(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[vt(),(0,Z.jsx)(`strong`,{children:s()}),le()]}),(0,Z.jsx)(Mt,{title:bt(),rows:e,addLabel:Ae(),onAdd:()=>{w(null),m(Q),c(!0)},emptyHint:St(),columns:[{header:gt(),cell:e=>e.name,sort:e=>e.name},{header:Ee(),cell:e=>(0,Z.jsx)(R,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Be(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:He(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:u(),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)(R,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?v():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Pe(),onSelect:()=>{w(e._id),m(Rt(e)),c(!0)}},{label:p(),onSelect:()=>g(e.name)},{label:be(),onSelect:()=>x(e)},{label:Ze(),onSelect:()=>y(e)},{label:N(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:N(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(jt,{open:o,onOpenChange:c,title:S?pt():Re(),description:Me(),canSubmit:!!(d.name&&d.gatewayUrl),onSubmit:T,submitLabel:lt(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:tt(),children:[(0,Z.jsx)(H,{value:d.name,disabled:S!==null,onChange:e=>m({...d,name:e.target.value})}),S?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Je()}):null]}),(0,Z.jsx)($,{label:Oe(),children:(0,Z.jsxs)(L,{value:d.kind,onValueChange:e=>m({...d,kind:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(I,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(I,{value:`hermes`,children:`Hermes`})]})]})}),d.kind===`hermes`?(0,Z.jsx)($,{label:ye(),children:(0,Z.jsxs)(L,{value:d.transport,onValueChange:e=>m({...d,transport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(K,{})}),(0,Z.jsxs)(q,{children:[(0,Z.jsx)(I,{value:`ws`,children:Se()}),(0,Z.jsx)(I,{value:`rest`,children:C()})]})]})}):null,(0,Z.jsx)($,{label:We(),children:(0,Z.jsx)(H,{value:d.gatewayUrl,onChange:e=>m({...d,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:st(),children:(0,Z.jsx)(H,{value:d.bridgeUrl,placeholder:$e(),onChange:e=>m({...d,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:dt(),children:(0,Z.jsx)(H,{value:d.displayName,onChange:e=>m({...d,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:ie(),children:[(0,Z.jsxs)(L,{value:d.streamTransport,onValueChange:e=>m({...d,streamTransport:e}),children:[(0,Z.jsx)(F,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(K,{})}),(0,Z.jsx)(q,{children:Et.map(e=>(0,Z.jsx)(I,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:ne()})]}),(0,Z.jsx)($,{label:Ie(),children:(0,Z.jsx)(H,{value:d.gatewayVersion,placeholder:i(),onChange:e=>m({...d,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:se(),children:(0,Z.jsx)(H,{value:d.gatewayHttpUrl,placeholder:Te(),onChange:e=>m({...d,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Yt,{instanceName:h,open:h!==null,onOpenChange:e=>{e||g(null)}}),_?(0,Z.jsx)(Nt,{instance:_,onClose:()=>y(null)},_._id):null,b?(0,Z.jsx)(Bt,{instance:b,onClose:()=>x(null)},b._id):null]})}function Bt({instance:e,onClose:t}){let n=D(f.instanceSecrets.listInstanceSecretStatus,{}),r=Lt[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)(G,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(z,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{children:Ce({instance:e.displayName??e.name})}),(0,Z.jsx)(B,{children:w()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Ut,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Ht,{instance:e})}),(0,Z.jsx)(Vt,{instance:e})]})})}function Vt({instance:e}){let t=k(f.instanceSync.forceInstanceSync),n=J(),[r,i]=(0,Y.useState)(!1);async function o(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(O());break;case`no_agents`:n.success(m());break;case`no_bridge_url`:n.error(fe());break;case`deploy_misconfigured`:n.error(yt());break;case`unauthorized`:n.error(ue());break;case`not_served`:n.error(xt());break;default:n.error(c());break}}catch(e){n.error(d(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:je()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:r,children:r?qe():a()})})]})}function Ht({instance:e}){let t=D(f.bridgeAuth.listBridgeAuthStatus,{}),n=k(f.bridgeAuth.mintBridgeSecret),r=l(f.bridgeAuth.revokeBridgeSecret),i=J(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),p=(t??[]).find(t=>t.instanceId===e._id),m=p!==void 0;async function h(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(rt(),e)}finally{o(!1)}}}async function g(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Qe())}catch(e){i.error(rt(),e)}finally{o(!1)}}}async function _(){if(s)try{await navigator.clipboard.writeText(s),d(!0)}catch{}}return(0,Z.jsxs)($,{label:Ct(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_t()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(R,{variant:m?`outline`:`secondary`,children:m?`${A()} · ${p.prefix}…${p.lastFour}`:me()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void h(),disabled:a,children:m?Ve():De()}),m?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void g(),disabled:a,children:Ue()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:ze()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:u?x():it()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),d(!1)},children:M()})]}):null]})}function Ut({instanceId:e,field:t,updatedAt:n}){let r=k(f.instanceSecrets.setInstanceSecret),i=l(f.instanceSecrets.clearInstanceSecret),a=k(f.deviceIdentity.generateDeviceIdentity),s=J(),[c,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(null),[v,S]=(0,Y.useState)(!1),C=n!==null,w=t===`deviceIdentity`,T=t===`token`?ot():t===`deviceIdentity`?ee():_();async function ne(){if(!(!c.trim()||d)){p(!0);try{await r({instanceId:e,field:t,plaintext:c}),u(``),g(null),S(!1),s.success(ce())}catch(e){s.error(te(),e)}finally{p(!1)}}}async function ie(){if(!d){p(!0);try{await i({instanceId:e,field:t}),g(null),S(!1),s.success(b())}catch(e){s.error(te(),e)}finally{p(!1)}}}async function D(){if(!d){p(!0);try{g(await a({instanceId:e})),S(!1),s.success(E())}catch(e){s.error(Ke(),e)}finally{p(!1)}}}let O=m?`openclaw devices approve ${m.id}`:``;async function oe(){if(O)try{await navigator.clipboard.writeText(O),S(!0)}catch{}}return(0,Z.jsxs)($,{label:T,children:[w?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(R,{variant:C?`outline`:`secondary`,children:C?A():me()}),(0,Z.jsx)(H,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:C?ge():y(),onChange:e=>u(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(P,{size:`sm`,onClick:()=>void ne(),disabled:d||c.trim().length===0,children:o()}),w?(0,Z.jsx)(P,{size:`sm`,variant:`outline`,onClick:()=>void D(),disabled:d,children:h()}):null,C?(0,Z.jsx)(P,{size:`sm`,variant:`destructive`,onClick:()=>void ie(),disabled:d,children:wt()}):null]})]}),m?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:E()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:re()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:O}),(0,Z.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void oe(),children:v?x():it()})]}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,onClick:()=>{g(null),S(!1)},children:M()})]}):null]})}var Wt={conversational:ct,documentary:ft,summarizer:Fe,curator:Ye},Gt={conversational:et,documentary:Le,summarizer:mt,curator:Ne},Kt=e=>(Wt[e]??(()=>e))(),qt=e=>(Gt[e]??(()=>``))();function Jt({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:ut()}),t.map(e=>(0,Z.jsx)(R,{variant:`secondary`,className:`oc-agenttype__chip`,title:qt(e),children:Kt(e)},e)),(0,Z.jsxs)(kt,{children:[(0,Z.jsx)(Ot,{asChild:!0,children:(0,Z.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:nt()})}),(0,Z.jsxs)(At,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:ke()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ge()}),(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)(W,{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:Kt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:qt(r)})]})]},r)})})]})]})]})}function Yt({instanceName:e,open:t,onOpenChange:n}){let i=D(f.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=l(f.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),o=l(f.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),s=l(f.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=It(r);e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=l(f.agents.removeInstanceAgent),u=Dt(),d=J();async function p(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){d.error(j(),e)}}async function m(t){if(e)try{await o({instanceName:e,agentId:t})}catch(e){d.error(j(),e)}}async function h(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await s({instanceName:e,agentId:t,types:i})}catch(e){d.error(j(),e)}}async function _(t,n){if(e&&await u({title:we({name:n}),description:ve(),confirmLabel:xe(),destructive:!0}))try{await c({instanceName:e,agentId:t}),d.success(S())}catch(e){d.error(j(),e)}}return(0,Z.jsx)(G,{open:t,onOpenChange:n,children:(0,Z.jsxs)(z,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{children:ht({name:e??``})}),(0,Z.jsx)(B,{children:Xe()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:at()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?T():i.discovery.lastPollOk?g():_e({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:pe()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(e=>{let t=e.presentInLastOk===!1,n=i.defaultAgentId===e.agentId,a=e.displayName??e.agentId,o=e.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(e.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(W,{checked:e.enabled,disabled:t,"aria-label":a,onCheckedChange:t=>void p(e.agentId,t===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[e.emoji?`${e.emoji} `:``,a]}),e.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{variant:`outline`,className:`oc-access__gone`,children:he()}),(0,Z.jsx)(P,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void _(e.agentId,a),children:oe()})]}):n?(0,Z.jsx)(R,{variant:`default`,children:v()}):(0,Z.jsx)(P,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!e.enabled,onClick:()=>void m(e.agentId),children:r()})]}),e.enabled?(0,Z.jsx)(Jt,{agentId:e.agentId,types:o,onToggle:t=>void h(e.agentId,t,o)}):null]},e.agentId)})})]})]})})}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{zt as InstancesTab};