@lacneu/atrium 0.55.1 → 0.55.3

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 (65) hide show
  1. package/dist/assets/AccessTab-C31jlbg9.js +1 -0
  2. package/dist/assets/{AdvancedFilter-Da3KTeHW.js → AdvancedFilter-Cqqt3aQy.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-zUyuhhPC.js → AgentFilesTab-hoV2OJkH.js} +2 -2
  4. package/dist/assets/AnomaliesTab-HNlBWX4H.js +1 -0
  5. package/dist/assets/{AuditTab-DhZziBmc.js → AuditTab-BDkuGhWd.js} +1 -1
  6. package/dist/assets/{BridgeTab-CBfGV3MJ.js → BridgeTab-7Gp-lSm8.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-CPHvONN5.js → ChatDefaultsTab-CuRfo1OD.js} +1 -1
  8. package/dist/assets/{DataTableShell-CRhep8-q.js → DataTableShell-O-bA35dG.js} +1 -1
  9. package/dist/assets/{DetailChips-DU6aRrkw.js → DetailChips-F3RMiEWW.js} +1 -1
  10. package/dist/assets/FeedbacksTab-n6fND_d8.js +1 -0
  11. package/dist/assets/{FieldLabel-Cam2yQ_L.js → FieldLabel-C2HKtml6.js} +1 -1
  12. package/dist/assets/FilesTab-ClwXf69-.js +1 -0
  13. package/dist/assets/{FilterBar-D6zZSKoR.js → FilterBar-CQBSm0gy.js} +1 -1
  14. package/dist/assets/{GroupsTab-BbXkqBwR.js → GroupsTab-By9wK7Xb.js} +1 -1
  15. package/dist/assets/InstancesTab-F8EFka-Z.js +1 -0
  16. package/dist/assets/{IntegrationsTab-gnKR_uar.js → IntegrationsTab-DyjOkGyX.js} +1 -1
  17. package/dist/assets/{KpiTab-C1faYNw_.js → KpiTab-D8YvkmYo.js} +1 -1
  18. package/dist/assets/PreferencesTab-CVf28USb.js +1 -0
  19. package/dist/assets/{PromptInjectionsTab-rzjPaDqW.js → PromptInjectionsTab-BnOXHYex.js} +2 -2
  20. package/dist/assets/RolesTab-HPXx0Dh3.js +1 -0
  21. package/dist/assets/ScheduledTab-CMFb6jsp.js +1 -0
  22. package/dist/assets/ServiceAccountsTab-CkbSZ_vx.js +1 -0
  23. package/dist/assets/{SubAgentReportsTab-DlOkF8VH.js → SubAgentReportsTab-BhJ2Xi_p.js} +1 -1
  24. package/dist/assets/ThemeShowroom-BHaHjfmV.js +1 -0
  25. package/dist/assets/{TimeRangePicker-5EYfNRUQ.js → TimeRangePicker-CV_IaaKP.js} +1 -1
  26. package/dist/assets/TracesTab-ChOCnxTO.js +1 -0
  27. package/dist/assets/UsersTab-CKat_1Zz.js +1 -0
  28. package/dist/assets/VoiceTab-Kw-KPRnH.js +1 -0
  29. package/dist/assets/{button-CJcuK3wk.js → button-CdHluvSK.js} +1 -1
  30. package/dist/assets/{card-CVCuPx_Y.js → card-AXe34vGw.js} +1 -1
  31. package/dist/assets/chevrons-up-down-BlSBNq85.js +1 -0
  32. package/dist/assets/{compatView-B7k06dFl.js → compatView-CB9xzhbT.js} +1 -1
  33. package/dist/assets/{dispatchErrorInfo-CGkgIKQB.js → dispatchErrorInfo-CkqdtQzy.js} +1 -1
  34. package/dist/assets/dist-BKXYNjW7.js +44 -0
  35. package/dist/assets/{dist-B7glRJ6t.js → dist-CchsedUP.js} +1 -1
  36. package/dist/assets/{dist-Czk9m5q_.js → dist-D06QCQPB.js} +1 -1
  37. package/dist/assets/{dist-DDmOEYQC.js → dist-x2y4VoOj.js} +1 -1
  38. package/dist/assets/{highlighted-body-OFNGDK62-CIIdpJOV.js → highlighted-body-OFNGDK62-dkUlu-Yf.js} +1 -1
  39. package/dist/assets/{index-CVElkIyB.js → index-DZcxHX-q.js} +24 -24
  40. package/dist/assets/mermaid-GHXKKRXX-DWJbe-FR.js +1 -0
  41. package/dist/assets/{pdf-DYyorNYM.js → pdf-XVS5_Y6b.js} +1 -1
  42. package/dist/assets/roleDescriptions-ReA48WUh.js +1 -0
  43. package/dist/assets/{table-HcdAROEr.js → table-BlgvNhKf.js} +1 -1
  44. package/dist/assets/{tabs--02lZ4zx.js → tabs-CXQdq7rn.js} +1 -1
  45. package/dist/assets/x-B77pQElB.js +1 -0
  46. package/dist/index.html +7 -7
  47. package/package.json +1 -1
  48. package/dist/assets/AccessTab-gIcazyyd.js +0 -1
  49. package/dist/assets/AnomaliesTab-Xzr68-lj.js +0 -1
  50. package/dist/assets/FeedbacksTab-B5AD5fns.js +0 -1
  51. package/dist/assets/FilesTab-2LXlwGbm.js +0 -1
  52. package/dist/assets/InstancesTab-efmqJkiF.js +0 -1
  53. package/dist/assets/PreferencesTab-Bntqbb3v.js +0 -1
  54. package/dist/assets/RolesTab-Dur_DWik.js +0 -1
  55. package/dist/assets/ScheduledTab-vr9ejIr6.js +0 -1
  56. package/dist/assets/ServiceAccountsTab-CDRsanZ2.js +0 -1
  57. package/dist/assets/ThemeShowroom-CIz45LkB.js +0 -1
  58. package/dist/assets/TracesTab-Drz4v12P.js +0 -1
  59. package/dist/assets/UsersTab-BM5wnZH4.js +0 -1
  60. package/dist/assets/VoiceTab-dC1OIeva.js +0 -1
  61. package/dist/assets/chevrons-up-down-QpMWDm41.js +0 -1
  62. package/dist/assets/dist-Dw05q7xL.js +0 -44
  63. package/dist/assets/mermaid-GHXKKRXX-B05YFZFp.js +0 -1
  64. package/dist/assets/roleDescriptions-5T4_7YgE.js +0 -1
  65. package/dist/assets/x-DiDC_TeC.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{E as r,_d as i,ad as a,cd as o,dd as s,fd as c,gd as l,hd as u,id as d,lP as f,ld as p,md as m,od as h,pd as g,rd as _,sd as v,ud as y,vP as b}from"./dist-BKXYNjW7.js";import{C as x,S,T as C,dt as w,w as T,x as E}from"./index-DZcxHX-q.js";var D=t(e(),1);function O(e){return e===`user`?v():e===`all`?h():a({group:e.group})}function k(e){return e===`common`?d():e===`owner`?_():a({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=b(r.admin.listUsers,{}),[t,n]=(0,D.useState)(``),a=b(r.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:i()}),(0,A.jsxs)(E,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":l(),children:(0,A.jsx)(C,{placeholder:l()})}),(0,A.jsx)(S,{children:(e??[]).map(e=>(0,A.jsx)(x,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):a===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(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:a.user.label}),(0,A.jsx)(w,{variant:`secondary`,children:a.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),a.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:a.groups.map(e=>(0,A.jsx)(w,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:c()}),a.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:a.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(w,{variant:`default`,children:o()}):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:s()}),a.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:a.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(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()}),a.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:a.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-Dw05q7xL.js";import{i as u}from"./dist-Czk9m5q_.js";import{t as d}from"./x-DiDC_TeC.js";import{t as f}from"./button-CJcuK3wk.js";import{Bt as p,C as m,S as h,T as g,ft as _,w as v,x as y}from"./index-CVElkIyB.js";import{r as b}from"./TimeRangePicker-5EYfNRUQ.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)(y,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(g,{placeholder:i()})}),(0,S.jsx)(h,{children:e.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(y,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(g,{})}),(0,S.jsx)(h,{children:C.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(_,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder: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)(p,{}),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-BKXYNjW7.js";import{i as u}from"./dist-D06QCQPB.js";import{t as d}from"./x-B77pQElB.js";import{t as f}from"./button-CdHluvSK.js";import{Bt as p,C as m,S as h,T as g,ft as _,w as v,x as y}from"./index-DZcxHX-q.js";import{r as b}from"./TimeRangePicker-CV_IaaKP.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)(y,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(g,{placeholder:i()})}),(0,S.jsx)(h,{children:e.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(y,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(g,{})}),(0,S.jsx)(h,{children:C.map(e=>(0,S.jsx)(m,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(_,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder: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)(p,{}),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,Dc as l,E as u,Ec as d,Er as f,Fc as p,Fl as m,Fr as h,Gc as g,Gr as _,Hc as v,Hr as y,Ic as b,Ir as x,Jc as S,Jr as C,Kc as w,Kr as T,Lc as E,Lr as D,Mc as O,Nc as k,Nl as ee,Nr as A,Oc as j,Pc as M,Pr as N,Qc as te,Qr as P,Rc as F,Rr as I,Sr as L,Tc as ne,Tr as R,Uc as z,Ur as B,Vc as re,Vr as V,Wc as ie,Wr as ae,Xc as oe,Xr as se,Yc as ce,Yr as le,Zc as ue,Zr as de,_P as H,br as fe,cP as U,gP as pe,jc as me,kc as he,lD as ge,mP as W,qc as _e,qr as ve,uP as G,wc as ye,wr as be,xr as xe,zc as Se,zr as Ce}from"./dist-Dw05q7xL.js";import{t as K}from"./button-CJcuK3wk.js";import{C as we,G as Te,H as q,J as Ee,K as De,Pt as J,Q as Oe,S as ke,T as Ae,X as je,Y as Me,Z as Ne,_t as Pe,b as Fe,dt as Ie,ht as Le,mt as Re,pt as ze,q as Be,vt as Ve,w as He,wt as Ue,x as We}from"./index-CVElkIyB.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-B7k06dFl.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,Dc as l,E as u,Ec as d,Er as f,Fc as p,Fl as m,Fr as h,Gc as g,Gr as _,Hc as v,Hr as y,Ic as b,Ir as x,Jc as S,Jr as C,Kc as w,Kr as T,Lc as E,Lr as D,Mc as O,Nc as k,Nl as ee,Nr as A,Oc as j,Pc as M,Pr as N,Qc as te,Qr as P,Rc as F,Rr as I,Sr as L,Tc as ne,Tr as R,Uc as z,Ur as B,Vc as re,Vr as V,Wc as ie,Wr as ae,Xc as oe,Xr as se,Yc as ce,Yr as le,Zc as ue,Zr as de,_P as fe,br as pe,dP as H,hP as U,jc as me,kc as he,lP as W,qc as ge,qr as _e,uD as ve,vP as G,wc as ye,wr as be,xr as xe,zc as Se,zr as Ce}from"./dist-BKXYNjW7.js";import{t as K}from"./button-CdHluvSK.js";import{C as we,G as Te,H as q,J as Ee,K as De,Pt as J,Q as Oe,S as ke,T as Ae,X as je,Y as Me,Z as Ne,_t as Pe,b as Fe,dt as Ie,ht as Le,mt as Re,pt as ze,q as Be,vt as Ve,w as He,wt as Ue,x as We}from"./index-DZcxHX-q.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-CB9xzhbT.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
- `))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=H(u.me.getMe,{host:Ue}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=H(u.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=H(u.agents.listAgentsForInstance,t&&i?{instanceName:i}:`skip`),c=H(u.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]),[d,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!l||l.length===0||(!d||!l.some(e=>$(e)===d))&&f($(l[0]))},[l,d]);let p=l?.find(e=>$(e)===d)??null,m=W(u.agentFiles.listAgentFiles),[h,_]=(0,Y.useState)({status:`idle`}),y=p?.instanceName??null,b=p?.agentId??null,x=H(u.compat.forInstance,n&&y!==null?{instanceName:y}:`skip`),T=n&&y!==null?Fe(x,`agentFiles`):null,E=T===null?!1:T===`loading`?null:T.blocked,D=(0,Y.useCallback)(async()=>{if(!(y===null||b===null)){_({status:`loading`});try{_({status:`done`,files:(await m({instanceName:y,agentId:b})).files})}catch{_({status:`error`})}}},[m,y,b]);(0,Y.useEffect)(()=>{E===!1&&D()},[D,E]);let[O,k]=(0,Y.useState)(null),A=H(u.agentFileCuration.listCurations,t&&y!==null&&b!==null?{instanceName:y,agentId:b}:`skip`),j=H(u.agentFileCuration.curationSettings,t&&y!==null?{instanceName:y}:`skip`),M=W(u.agentFileCuration.requestCuration),[N,P]=(0,Y.useState)(null),[F,I]=(0,Y.useState)(null),{toast:L}=q(),ne=(0,Y.useMemo)(()=>{let e=new Map;for(let t of A??[])e.has(t.name)||e.set(t.name,t);return e},[A]),R=(0,Y.useCallback)(async e=>{if(!(y===null||b===null)){P(e);try{let t=await M({instanceName:y,agentId:b,name:e,trigger:`manual`});t.ok?L({title:se(),variant:`success`}):L({title:le({reason:t.reason??`unknown`}),variant:`error`})}catch{L({title:C(),variant:`error`})}finally{P(null)}}},[M,y,b,L]),B=G(),V=(0,Y.useMemo)(()=>new Intl.NumberFormat(B,{maximumFractionDigits:0}),[B]);return e===void 0||l===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:U()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:te()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(We,{value:i??``,onValueChange:e=>o(e),children:[(0,Q.jsx)(He,{size:`sm`,"aria-label":ue(),children:(0,Q.jsx)(Ae,{})}),(0,Q.jsx)(ke,{children:(r??[]).map(e=>(0,Q.jsx)(we,{value:e.name,children:e.name},e.name))})]}):null,l.length>0?(0,Q.jsxs)(We,{value:d??``,onValueChange:e=>f(e),children:[(0,Q.jsx)(He,{size:`sm`,"aria-label":oe(),children:(0,Q.jsx)(Ae,{})}),(0,Q.jsx)(ke,{children:l.map(e=>(0,Q.jsx)(we,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ce()})]}),p===null?null:T===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:U()}):T!==null&&T.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(J,{size:14,"aria-hidden":!0}),` `,qe(T.gatewayVersion,T.provider)]}):h.status===`loading`||h.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:U()}):h.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[_e(),` `,(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:S()}):(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)(Ie,{variant:`outline`,children:w()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:g({size:Z(e.size,B)})}),(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:ie({pct:V.format(n)})}),r?(0,Q.jsx)(J,{size:14,className:`oc-afiles__warn`,"aria-label":z()}):(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:ne.get(e.name)??null,inFlight:N===e.name,onCurate:()=>void R(e.name),onReview:e=>I(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:v({used:Z(Ze(h.files),B),total:Z(Je,B),pct:V.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,F?(0,Q.jsx)(it,{curationId:F,onClose:()=>I(null),onApplied:()=>{I(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:P()}):o||a?.status===`dispatched`||a?.status===`applying`?(0,Q.jsx)(Ie,{variant:`outline`,className:`oc-afiles__curate-status`,children:de()}):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=W(u.agentFiles.getAgentFile),f=W(u.agentFiles.setAgentFile),h=q(),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(!1),[T,D]=(0,Y.useState)(!1),[A,N]=(0,Y.useState)(!1),[te,P]=(0,Y.useState)(!1),I=(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),N(!1)}catch{y(!0)}},[c,e,t,n]);(0,Y.useEffect)(()=>{I(!1)},[I]);async function L(){if(g!==null){D(!0),P(!1);try{await f({instanceName:e,agentId:t,name:n,content:x,baseUpdatedAtMs:g.updatedAtMs??void 0}),h.success(k({name:n})),o(),await I(!1)}catch(e){et(e)?N(!0):P(!0)}finally{D(!1)}}}let R=g!==null&&x!==g.content,z=(0,Y.useMemo)(()=>g===null?null:$e(g.content,x),[g,x]),B=x.length>X,re=G(),V=(0,Y.useMemo)(()=>new Intl.NumberFormat(re),[re]);return(0,Q.jsx)(ze,{open:!0,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Ve,{children:Se({name:n})}),(0,Q.jsxs)(Le,{children:[F({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,E()]})]})]}),v?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[me(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void I(!1),children:ee()})]}):g===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:U()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:x,readOnly:!r,spellCheck:!1,onChange:e=>S(e.target.value),"aria-label":Se({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:b()}),A?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[i(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void I(!0),children:he()})]}):null,te?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:O()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${B?` is-over`:``}`,children:p({count:V.format(x.length),max:V.format(X)})}),r?(0,Q.jsx)(K,{size:`sm`,disabled:!R||T||A,onClick:()=>w(!0),children:T?m():M()}):null]})]}),(0,Q.jsx)(Te,{open:C,onOpenChange:w,children:(0,Q.jsxs)(Ee,{children:[(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(Oe,{children:j({name:n})}),(0,Q.jsx)(Me,{children:l({agent:t})})]}),z?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:d({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)(je,{children:[(0,Q.jsx)(Be,{children:ge()}),(0,Q.jsx)(De,{onClick:()=>void L(),children:s()})]})]})})]})})}function it({curationId:e,onClose:t,onApplied:n}){let r=H(u.agentFileCuration.getProposal,{curationId:e}),i=W(u.agentFileCuration.approveCuration),a=pe(u.agentFileCuration.rejectCuration),{toast:s}=q(),[l,d]=(0,Y.useState)(null),[p,g]=(0,Y.useState)(!1),[v,b]=(0,Y.useState)(``),S=G(),w=(0,Y.useMemo)(()=>r?$e(r.beforeContent,r.proposedContent):null,[r]);async function E(){d(`approve`);try{let t=await i({curationId:e});t.ok?(s({title:ve(),variant:`success`}),n()):s({title:t.reason===`conflict`?_():ae({reason:t.reason??`unknown`}),variant:`error`})}catch{s({title:C(),variant:`error`})}finally{d(null)}}async function O(n){d(`reject`);try{let r=v.trim();(await a({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?s({title:n?xe():T(),variant:`success`}):s({title:V(),variant:`error`}),t()}catch{s({title:C(),variant:`error`})}finally{d(null)}}return(0,Q.jsx)(ze,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Ve,{children:r?B({name:r.name}):U()}),(0,Q.jsx)(Le,{children:y()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:U()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:V()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[o({before:Z(r.beforeSize,S),after:Z(r.proposedSize,S)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(J,{size:13,"aria-hidden":!0}),` `,Ce()]}):null]}),w?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:I({added:w.added,removed:w.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:fe({feedback:r.feedback})}):null,w&&w.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:A()}),(0,Q.jsx)(`ul`,{children:w.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:N()}),(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:D()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.proposedContent})]})]})]}),p?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:f()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:R(),value:v,onChange:e=>b(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`ghost`,onClick:()=>g(!1),disabled:l!==null,children:be()}),(0,Q.jsx)(K,{variant:`outline`,onClick:()=>void O(!1),disabled:l!==null,children:l===`reject`?m():c()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void O(!0),disabled:l!==null,children:l===`reject`?m():L()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`outline`,onClick:()=>g(!0),disabled:l!==null||r==null,children:x()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void E(),disabled:l!==null||r==null,children:l===`approve`?m():h()})]})]})})}export{tt as AgentFilesTab};
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=G(u.me.getMe,{host:Ue}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=G(u.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=G(u.agents.listAgentsForInstance,t&&i?{instanceName:i}:`skip`),c=G(u.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]),[d,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{!l||l.length===0||(!d||!l.some(e=>$(e)===d))&&f($(l[0]))},[l,d]);let p=l?.find(e=>$(e)===d)??null,m=U(u.agentFiles.listAgentFiles),[h,_]=(0,Y.useState)({status:`idle`}),y=p?.instanceName??null,b=p?.agentId??null,x=G(u.compat.forInstance,n&&y!==null?{instanceName:y}:`skip`),T=n&&y!==null?Fe(x,`agentFiles`):null,E=T===null?!1:T===`loading`?null:T.blocked,D=(0,Y.useCallback)(async()=>{if(!(y===null||b===null)){_({status:`loading`});try{_({status:`done`,files:(await m({instanceName:y,agentId:b})).files})}catch{_({status:`error`})}}},[m,y,b]);(0,Y.useEffect)(()=>{E===!1&&D()},[D,E]);let[O,k]=(0,Y.useState)(null),A=G(u.agentFileCuration.listCurations,t&&y!==null&&b!==null?{instanceName:y,agentId:b}:`skip`),j=G(u.agentFileCuration.curationSettings,t&&y!==null?{instanceName:y}:`skip`),M=U(u.agentFileCuration.requestCuration),[N,P]=(0,Y.useState)(null),[F,I]=(0,Y.useState)(null),{toast:L}=q(),ne=(0,Y.useMemo)(()=>{let e=new Map;for(let t of A??[])e.has(t.name)||e.set(t.name,t);return e},[A]),R=(0,Y.useCallback)(async e=>{if(!(y===null||b===null)){P(e);try{let t=await M({instanceName:y,agentId:b,name:e,trigger:`manual`});t.ok?L({title:se(),variant:`success`}):L({title:le({reason:t.reason??`unknown`}),variant:`error`})}catch{L({title:C(),variant:`error`})}finally{P(null)}}},[M,y,b,L]),B=H(),V=(0,Y.useMemo)(()=>new Intl.NumberFormat(B,{maximumFractionDigits:0}),[B]);return e===void 0||l===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:W()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:te()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(We,{value:i??``,onValueChange:e=>o(e),children:[(0,Q.jsx)(He,{size:`sm`,"aria-label":ue(),children:(0,Q.jsx)(Ae,{})}),(0,Q.jsx)(ke,{children:(r??[]).map(e=>(0,Q.jsx)(we,{value:e.name,children:e.name},e.name))})]}):null,l.length>0?(0,Q.jsxs)(We,{value:d??``,onValueChange:e=>f(e),children:[(0,Q.jsx)(He,{size:`sm`,"aria-label":oe(),children:(0,Q.jsx)(Ae,{})}),(0,Q.jsx)(ke,{children:l.map(e=>(0,Q.jsx)(we,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ce()})]}),p===null?null:T===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:W()}):T!==null&&T.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(J,{size:14,"aria-hidden":!0}),` `,qe(T.gatewayVersion,T.provider)]}):h.status===`loading`||h.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:W()}):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:S()}):(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)(Ie,{variant:`outline`,children:w()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:g({size:Z(e.size,B)})}),(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:ie({pct:V.format(n)})}),r?(0,Q.jsx)(J,{size:14,className:`oc-afiles__warn`,"aria-label":z()}):(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:ne.get(e.name)??null,inFlight:N===e.name,onCurate:()=>void R(e.name),onReview:e=>I(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:v({used:Z(Ze(h.files),B),total:Z(Je,B),pct:V.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,F?(0,Q.jsx)(it,{curationId:F,onClose:()=>I(null),onApplied:()=>{I(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:P()}):o||a?.status===`dispatched`||a?.status===`applying`?(0,Q.jsx)(Ie,{variant:`outline`,className:`oc-afiles__curate-status`,children:de()}):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=U(u.agentFiles.getAgentFile),f=U(u.agentFiles.setAgentFile),h=q(),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(!1),[T,D]=(0,Y.useState)(!1),[A,N]=(0,Y.useState)(!1),[te,P]=(0,Y.useState)(!1),I=(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),N(!1)}catch{y(!0)}},[c,e,t,n]);(0,Y.useEffect)(()=>{I(!1)},[I]);async function L(){if(g!==null){D(!0),P(!1);try{await f({instanceName:e,agentId:t,name:n,content:x,baseUpdatedAtMs:g.updatedAtMs??void 0}),h.success(k({name:n})),o(),await I(!1)}catch(e){et(e)?N(!0):P(!0)}finally{D(!1)}}}let R=g!==null&&x!==g.content,z=(0,Y.useMemo)(()=>g===null?null:$e(g.content,x),[g,x]),B=x.length>X,re=H(),V=(0,Y.useMemo)(()=>new Intl.NumberFormat(re),[re]);return(0,Q.jsx)(ze,{open:!0,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Ve,{children:Se({name:n})}),(0,Q.jsxs)(Le,{children:[F({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,E()]})]})]}),v?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[me(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void I(!1),children:ee()})]}):g===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:W()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:x,readOnly:!r,spellCheck:!1,onChange:e=>S(e.target.value),"aria-label":Se({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:b()}),A?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[i(),` `,(0,Q.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void I(!0),children:he()})]}):null,te?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:O()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${B?` is-over`:``}`,children:p({count:V.format(x.length),max:V.format(X)})}),r?(0,Q.jsx)(K,{size:`sm`,disabled:!R||T||A,onClick:()=>w(!0),children:T?m():M()}):null]})]}),(0,Q.jsx)(Te,{open:C,onOpenChange:w,children:(0,Q.jsxs)(Ee,{children:[(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(Oe,{children:j({name:n})}),(0,Q.jsx)(Me,{children:l({agent:t})})]}),z?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:d({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)(je,{children:[(0,Q.jsx)(Be,{children:ve()}),(0,Q.jsx)(De,{onClick:()=>void L(),children:s()})]})]})})]})})}function it({curationId:e,onClose:t,onApplied:n}){let r=G(u.agentFileCuration.getProposal,{curationId:e}),i=U(u.agentFileCuration.approveCuration),a=fe(u.agentFileCuration.rejectCuration),{toast:s}=q(),[l,d]=(0,Y.useState)(null),[p,g]=(0,Y.useState)(!1),[v,b]=(0,Y.useState)(``),S=H(),w=(0,Y.useMemo)(()=>r?$e(r.beforeContent,r.proposedContent):null,[r]);async function E(){d(`approve`);try{let t=await i({curationId:e});t.ok?(s({title:_e(),variant:`success`}),n()):s({title:t.reason===`conflict`?_():ae({reason:t.reason??`unknown`}),variant:`error`})}catch{s({title:C(),variant:`error`})}finally{d(null)}}async function O(n){d(`reject`);try{let r=v.trim();(await a({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?s({title:n?xe():T(),variant:`success`}):s({title:V(),variant:`error`}),t()}catch{s({title:C(),variant:`error`})}finally{d(null)}}return(0,Q.jsx)(ze,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Pe,{children:[(0,Q.jsx)(Ve,{children:r?B({name:r.name}):W()}),(0,Q.jsx)(Le,{children:y()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:W()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:V()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[o({before:Z(r.beforeSize,S),after:Z(r.proposedSize,S)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(J,{size:13,"aria-hidden":!0}),` `,Ce()]}):null]}),w?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:I({added:w.added,removed:w.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:pe({feedback:r.feedback})}):null,w&&w.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:A()}),(0,Q.jsx)(`ul`,{children:w.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:N()}),(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:D()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.proposedContent})]})]})]}),p?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:f()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:R(),value:v,onChange:e=>b(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`ghost`,onClick:()=>g(!1),disabled:l!==null,children:be()}),(0,Q.jsx)(K,{variant:`outline`,onClick:()=>void O(!1),disabled:l!==null,children:l===`reject`?m():c()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void O(!0),disabled:l!==null,children:l===`reject`?m():L()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(K,{variant:`outline`,onClick:()=>g(!0),disabled:l!==null||r==null,children:x()}),(0,Q.jsx)(K,{variant:`default`,onClick:()=>void E(),disabled:l!==null||r==null,children:l===`approve`?m():h()})]})]})})}export{tt as AgentFilesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Ay as i,By as a,Cy as ee,Dy as o,E as s,Ey as te,Fy as ne,Iy as c,Jv as l,Ly as u,My as d,Ny as re,Oy as ie,Py as ae,Qv as f,Ry as p,Sy as oe,Ty as se,Xv as m,Yv as h,Zv as g,_P as _,_y as v,ay as ce,by as le,cy as ue,dy as y,ey as b,fy as de,gy as fe,hy as x,iy as pe,jy as me,ky as he,ly as ge,my as _e,ny as ve,oy as S,py as C,ry as w,sy as T,ty as E,uy as D,vP as O,vy as k,wy as A,xy as j,yy as M,zy as N}from"./dist-BKXYNjW7.js";import{C as P,H as F,S as I,T as L,U as ye,_t as R,dt as z,i as be,mt as B,nn as V,o as xe,pt as H,rn as Se,rt as Ce,vt as U,w as W,wt as we,x as G}from"./index-DZcxHX-q.js";import{n as Te}from"./TimeRangePicker-CV_IaaKP.js";import{t as Ee}from"./FilterBar-CQBSm0gy.js";import{t as De}from"./DataTableShell-O-bA35dG.js";import{t as K}from"./dispatchErrorInfo-CkqdtQzy.js";var q=t(e(),1),J=n(),Y=`__all__`,Oe=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function ke(e){return e===`open`?a():e===`acknowledged`?N():p()}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=Se({from:`/settings/anomalies`}),t=V({from:`/settings/anomalies`}),n=e.q??``,r=e.status===X?Y:e.status,a=e.severity??Y,l=e.kind??Y,[f,p]=(0,q.useState)(Y),m=be(e.from,e.to),{from:h,to:g}=Te(m),b=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),E=e=>void t({search:t=>({...t,status:e===Y?X:e})}),N=e=>void t({search:t=>({...t,severity:e===Y?void 0:e})}),R=e=>void t({search:t=>({...t,kind:e===Y?void 0:e})}),B=e=>void t({search:t=>({...t,...xe(e)})}),H=ye(),U=F(),K=_(s.anomalies.resolveAnomaly),Z=(O(s.me.getMe,{host:we})?.permissions??[]).includes(`admin.manage`),Q=O(s.anomalies.listAnomalies,{limit:Ne,filter:{q:n||void 0,from:h,to:g,anomalyStatus:r===Y?void 0:r,severity:a===Y?void 0:a,source:f===Y?void 0:f,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!==``||r!==`open`||a!==Y||f!==Y||l!==Y||m.kind!==`relative`||m.from!==Me.from;function Be(){p(Y),t({search:{status:`open`},replace:!0})}async function Ve(e){if(await H({title:u(),description:(0,J.jsxs)(J.Fragment,{children:[c(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,ne(),` `,(0,J.jsx)(`strong`,{children:ae()}),`.`,` `,re()]}),confirmLabel:d()}))try{await K({anomalyId:e._id,status:`resolved`}),U.success(me(),e.kind)}catch(e){U.error(i(),e)}}async function He(e){try{await K({anomalyId:e._id,status:`acknowledged`}),U.success(he(),e.kind)}catch(e){U.error(ie(),e)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-admin__hint`,children:[o(),` `,(0,J.jsx)(`strong`,{children:te()}),` `,se(),` `,(0,J.jsx)(`strong`,{children:A()}),` `,ee(),` `,(0,J.jsx)(`strong`,{children:oe()}),` `,j(),` `,(0,J.jsx)(`span`,{className:`oc-filter__window`,children:le()})]}),(0,J.jsxs)(Ee,{q:n,onQChange:b,searchPlaceholder:M(),timeRange:m,onTimeRangeChange:B,onReset:Be,canReset:ze,children:[(0,J.jsxs)(G,{value:r,onValueChange:E,children:[(0,J.jsx)(W,{size:`sm`,className:`w-36`,children:(0,J.jsx)(L,{})}),(0,J.jsxs)(I,{children:[(0,J.jsx)(P,{value:Y,children:k()}),Oe.map(e=>(0,J.jsx)(P,{value:e.value,children:ke(e.value)},e.value))]})]}),(0,J.jsxs)(G,{value:a,onValueChange:N,children:[(0,J.jsx)(W,{size:`sm`,className:`w-36`,children:(0,J.jsx)(L,{placeholder:v()})}),(0,J.jsxs)(I,{children:[(0,J.jsx)(P,{value:Y,children:fe()}),Ae.map(e=>(0,J.jsx)(P,{value:e,children:e},e))]})]}),(0,J.jsxs)(G,{value:f,onValueChange:p,children:[(0,J.jsx)(W,{size:`sm`,className:`w-32`,children:(0,J.jsx)(L,{placeholder:x()})}),(0,J.jsxs)(I,{children:[(0,J.jsx)(P,{value:Y,children:_e()}),je.map(e=>(0,J.jsx)(P,{value:e,children:e},e))]})]}),(0,J.jsxs)(G,{value:l,onValueChange:R,children:[(0,J.jsx)(W,{size:`sm`,className:`w-36`,children:(0,J.jsx)(L,{placeholder:C()})}),(0,J.jsxs)(I,{children:[(0,J.jsx)(P,{value:Y,children:de()}),$.map(e=>(0,J.jsx)(P,{value:e,children:e},e))]})]})]}),(0,J.jsx)(De,{title:y(),rows:Q,emptyHint:r===`open`?D():ge(),rowActions:e=>Z&&e.status===`open`?[{label:ue(),onSelect:()=>void Ve(e)},{label:T(),onSelect:()=>void He(e)}]:[],columns:[{header:S(),cell:e=>(0,J.jsx)(`span`,{className:`oc-traces__time`,children:Ce(e.at)}),sort:e=>e.at},{header:C(),cell:e=>(0,J.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:v(),cell:e=>(0,J.jsx)(Ie,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:ce(),cell:e=>(0,J.jsx)(Le,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:x(),cell:e=>(0,J.jsx)(z,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:pe(),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:w(),cell:e=>(0,J.jsx)(Pe,{row:e}),sort:e=>e.evidence??null},{header:ve(),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=V();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:[`↗ `,E()]}):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:[`↗ `,E()]}):null]})}function Fe({row:e}){let[t,n]=(0,q.useState)(!1),i=O(s.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:[b(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,J.jsx)(H,{open:t,onOpenChange:n,children:(0,J.jsxs)(B,{className:`oc-anomaly__attachments-dialog`,children:[(0,J.jsx)(R,{children:(0,J.jsx)(U,{children:r()})}),i===void 0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:f()}):i.length===0?(0,J.jsx)(`p`,{className:`oc-traces__muted`,children:g()}):(0,J.jsx)(`div`,{className:`oc-anomaly__attachments`,children:i.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:m()}):e===`acknowledged`?(0,J.jsx)(z,{variant:`secondary`,children:h()}):(0,J.jsx)(z,{variant:`outline`,children:l()})}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{Bb as r,E as i,Fb as a,Gb as o,Hb as s,Ib as c,Lb as l,Mb as u,Nb as d,Pb as f,Rb as p,Sn as m,Ub as h,Vb as g,Wb as _,_P as v,_n as y,bn as b,jb as x,vn as S,xn as C,yn as w,zb as T}from"./dist-Dw05q7xL.js";import{C as E,S as D,T as O,a as k,i as A,n as j,nn as M,o as N,rn as P,rt as F,s as I,w as L,x as R}from"./index-CVElkIyB.js";import{n as ee}from"./TimeRangePicker-5EYfNRUQ.js";import{t as z}from"./FilterBar-D6zZSKoR.js";import{t as B}from"./AdvancedFilter-Da3KTeHW.js";import{t as V}from"./DataTableShell-CRhep8-q.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:j,to:`now`},G=`__all__`,K=[{value:`action`,label:m()},{value:`realLabel`,label:C()},{value:`targetLabel`,label:b()},{value:`impersonated`,label:w()},{value:`resource`,label:S()},{value:`resourceId`,label:y()}];function q(){let e=P({from:`/settings/audit`}),t=M({from:`/settings/audit`}),n=e.q??``,m=e.action??G,y=e.impersonated??G,b=e.resource??G,S=A(e.from,e.to),C=(0,H.useMemo)(()=>I(e.adv),[e.adv]),{from:w,to:j}=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,...N(e)})}),Q=e=>void t({search:t=>({...t,adv:k(e)}),replace:!0}),$=v(i.admin.listAudit,{filter:{q:n||void 0,from:w,to:j,action:m===G?void 0:m,resource:b===G?void 0:b,impersonated:y===G?void 0:y===`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!==``||m!==G||y!==G||b!==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:[o(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:_()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:h(),timeRange:S,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(R,{value:m,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{placeholder:s()})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:g()}),te.map(e=>(0,U.jsx)(E,{value:e,children:e},e))]})]}),(0,U.jsxs)(R,{value:y,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:r()}),(0,U.jsx)(E,{value:`yes`,children:T()}),(0,U.jsx)(E,{value:`no`,children:p()})]})]}),(0,U.jsxs)(R,{value:b,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{placeholder:l()})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:c()}),ne.map(e=>(0,U.jsx)(E,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:C,onChange:Q}),(0,U.jsx)(V,{title:a(),rows:$,emptyHint:f(),columns:[{header:d(),cell:e=>F(e.at),sort:e=>e.at},{header:s(),cell:e=>e.action,sort:e=>e.action},{header:u(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:x(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:l(),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{Bb as r,E as i,Fb as a,Gb as o,Hb as s,Ib as c,Lb as l,Mb as u,Nb as d,Pb as f,Rb as p,Sn as m,Ub as h,Vb as g,Wb as _,_n as v,bn as y,jb as b,vP as x,vn as S,xn as C,yn as w,zb as T}from"./dist-BKXYNjW7.js";import{C as E,S as D,T as O,a as k,i as A,n as j,nn as M,o as N,rn as P,rt as F,s as I,w as L,x as R}from"./index-DZcxHX-q.js";import{n as ee}from"./TimeRangePicker-CV_IaaKP.js";import{t as z}from"./FilterBar-CQBSm0gy.js";import{t as B}from"./AdvancedFilter-Cqqt3aQy.js";import{t as V}from"./DataTableShell-O-bA35dG.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:j,to:`now`},G=`__all__`,K=[{value:`action`,label:m()},{value:`realLabel`,label:C()},{value:`targetLabel`,label:y()},{value:`impersonated`,label:w()},{value:`resource`,label:S()},{value:`resourceId`,label:v()}];function q(){let e=P({from:`/settings/audit`}),t=M({from:`/settings/audit`}),n=e.q??``,m=e.action??G,v=e.impersonated??G,y=e.resource??G,S=A(e.from,e.to),C=(0,H.useMemo)(()=>I(e.adv),[e.adv]),{from:w,to:j}=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,...N(e)})}),Q=e=>void t({search:t=>({...t,adv:k(e)}),replace:!0}),$=x(i.admin.listAudit,{filter:{q:n||void 0,from:w,to:j,action:m===G?void 0:m,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!==``||m!==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:[o(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:_()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:h(),timeRange:S,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(R,{value:m,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{placeholder:s()})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:g()}),te.map(e=>(0,U.jsx)(E,{value:e,children:e},e))]})]}),(0,U.jsxs)(R,{value:v,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:r()}),(0,U.jsx)(E,{value:`yes`,children:T()}),(0,U.jsx)(E,{value:`no`,children:p()})]})]}),(0,U.jsxs)(R,{value:y,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(O,{placeholder:l()})}),(0,U.jsxs)(D,{children:[(0,U.jsx)(E,{value:G,children:c()}),ne.map(e=>(0,U.jsx)(E,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:C,onChange:Q}),(0,U.jsx)(V,{title:a(),rows:$,emptyHint:f(),columns:[{header:d(),cell:e=>F(e.at),sort:e=>e.at},{header:s(),cell:e=>e.action,sort:e=>e.action},{header:u(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:b(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:l(),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,Ah as i,Bg as a,Bh as o,Bt as s,Ch as c,D as l,Dh as u,E as d,Eh as f,Fg as p,Fh as m,Gg as h,Gh as g,Hg as ee,Hh as _,Ht as v,Ig as te,Ih as y,Jg as b,Jh as x,Kg as ne,Kh as S,Kt as re,Lh as ie,Mh as ae,Nh as oe,Oh as se,Ph as ce,Qh as le,Rh as ue,Sh as de,Th as fe,Ug as pe,Uh as me,Ut as he,Vg as ge,Vh as _e,Vt as ve,Wg as ye,Wh as be,Xh as xe,Xs as Se,Yg as Ce,Yh as we,Zh as Te,_P as C,_h as w,ac as Ee,ag as De,bh as Oe,cc as ke,cg as Ae,dc as je,dg as Me,ec as Ne,eg as Pe,fc as Fe,fg as Ie,gP as Le,gh as T,ic as Re,ig as ze,jh as Be,kh as Ve,lc as He,lg as Ue,mP as We,nc as Ge,ng as Ke,oc as qe,og as Je,pg as Ye,qh as Xe,rc as Ze,rg as Qe,sc as E,sg as $e,tc as et,tg as tt,uc as nt,ug as rt,vh as D,wh as it,xh as at,yh as ot,zg as st,zh as ct,zt as lt}from"./dist-Dw05q7xL.js";import{i as O,r as ut}from"./dist-Czk9m5q_.js";import{t as dt}from"./chevrons-up-down-QpMWDm41.js";import{i as ft,n as k,o as pt,r as mt,s as ht}from"./FieldLabel-Cam2yQ_L.js";import{i as gt,n as _t,r as vt,t as yt}from"./tabs--02lZ4zx.js";import{t as A}from"./button-CJcuK3wk.js";import{$ as bt,$t as j,C as M,H as xt,Kt as St,Lt as Ct,Pt as N,S as P,T as F,_t as wt,dt as I,en as Tt,et as Et,ft as L,h as Dt,ht as Ot,it as R,m as kt,mt as At,nn as jt,pt as Mt,rn as Nt,rt as Pt,tt as Ft,vt as It,w as z,wt as Lt,x as B}from"./index-CVElkIyB.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-HcdAROEr.js";import{t as Ht}from"./FilterBar-D6zZSKoR.js";import{a as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt}from"./compatView-B7k06dFl.js";import{t as W}from"./dispatchErrorInfo-CGkgIKQB.js";var Yt=l(`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=l(`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),[a,o]=(0,G.useState)(null),s=(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]),l=(0,G.useMemo)(()=>dn(s),[s]),d=(0,G.useMemo)(()=>fn(s),[s]),p=(0,G.useMemo)(()=>pn(s),[s]),m=(0,G.useMemo)(()=>un(sn(s,n),a),[s,n,a]);function h(e){o(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:ce()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Ht,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Be(),onReset:()=>r(an),canReset:on(n),children:[(0,Z.jsxs)(B,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:Ve()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(M,{value:J,children:i()}),l.map(e=>(0,Z.jsx)(M,{value:e,children:gn(e)},e))]})]}),(0,Z.jsxs)(B,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(F,{placeholder:se()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(M,{value:J,children:i()}),d.map(e=>(0,Z.jsx)(M,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(B,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:u()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(M,{value:J,children:i()}),p.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))]})]})]}),m.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(0,Z.jsxs)(Vt,{className:`oc-conn__table`,children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:fe(),sortKey:`target`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:it(),sortKey:`state`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:c(),sortKey:`instance`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:de(),sortKey:`host`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:at(),sortKey:`version`,sort:a,onSort:h}),(0,Z.jsx)(V,{children:Oe()}),(0,Z.jsx)(Q,{label:ot(),sortKey:`lastOk`,sort:a,onSort:h})]})}),(0,Z.jsx)(Bt,{children:m.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)(ut,{size:13,"aria-hidden":!0}):(0,Z.jsx)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(dt,{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:[ae({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`?D():e===`error`?w():T()}function _n({state:e}){return e===`connected`?(0,Z.jsx)(I,{variant:`secondary`,children:D()}):e===`error`?(0,Z.jsx)(I,{variant:`destructive`,children:w()}):(0,Z.jsx)(I,{variant:`outline`,children:T()})}function vn(){return C(d.bridgeHealth.getBridgeHealth,{})}function yn(){let e=vn(),t=C(d.compat.getBridgeCompat,{}),n=C(d.me.getMe,{host:Lt})?.role===`admin`,i=C(d.admin.listInstances,n?{}:`skip`),a=C(d.agents.usageForInstances,n?{}:`skip`),o=jt(),c=()=>void o({to:`/settings/anomalies`,search:{status:`open`}}),l=rn(e?e.targets:[],t?t.targets:[],i??[]),{section:u}=Nt({from:`/settings/bridge`}),f=jt({from:`/settings/bridge`}),p=t?.compat??null,m=t===void 0?`loading`:t===null?`nodata`:`ready`,h=p!==null&&Wt(p,`hermes`)&&!l.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(bn,{health:e,compat:t,onSeeAnomalies:c}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:r()}),a&&a.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:le()}),(0,Z.jsxs)(Vt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:he()}),(0,Z.jsx)(V,{children:v()}),(0,Z.jsx)(V,{children:ve()}),(0,Z.jsx)(V,{children:s()}),(0,Z.jsx)(V,{children:lt()})]})}),(0,Z.jsx)(Bt,{children:a.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(I,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,l.length>0?(0,Z.jsxs)(yt,{value:l.some(e=>e.key===u)?u:l[0]?.key??`openclaw`,onValueChange:e=>void f({search:{section:e},replace:!0}),children:[(0,Z.jsx)(vt,{className:`w-full`,children:l.map(e=>(0,Z.jsxs)(gt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(Ct,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),l.map(e=>(0,Z.jsx)(_t,{value:e.key,children:(0,Z.jsx)(xn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:p,compatStatus:m,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,h?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}):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:nt(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,He({build:t.buildVersion??`?`})]}):null,` · `,ke(),` `,(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:g()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:be()});let s=Zt(e.targets),c=!e.reachable,l=$t(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=Pt(e.checkedAt),p=e.startedAt==null?null:Pt(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Z.jsx)(j,{size:22}):c||l===`gateways_unreachable`?(0,Z.jsx)(Xt,{size:22}):(0,Z.jsx)(N,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?me():l===`gateways_unreachable`?ct({count:u.length}):c?_():_e({count:s.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}),` `,o({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:ue({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:y()})]})}function xn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?qt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,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)(Ct,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),f?(0,Z.jsx)(I,{variant:f===`beyond`?`destructive`:`secondary`,children:Kt(f)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Fe()}),(0,Z.jsx)(Cn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Z.jsx)(Sn,{protocol:o}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>h(e=>!e),children:[p?(0,Z.jsx)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),m({count:t.length})]}),p?(0,Z.jsx)(mn,{connections:t,displayByInstance:c}):null]})}function Sn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[Te(),i.length>0?(0,Z.jsx)(I,{variant:`destructive`,children:we({count:i.length})}):(0,Z.jsx)(I,{variant:`secondary`,children:xe()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[x({version:e.vendoredVersion}),r?` · `+Xe({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)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),S({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:g()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:je()}):(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:Ee()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:re({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)(I,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(e.state)})]},e.instanceName))})]})}function wn({instance:e,onClose:t}){return(0,Z.jsx)(Mt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(It,{children:Ce({instance:e.displayName??e.name})}),(0,Z.jsx)(Ot,{children:b()})]}),(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)(j,{"aria-hidden":!0}):(0,Z.jsx)(N,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?Qe():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,Ke()]}):null}function Tn({instance:e,onClose:t}){let n=Le(d.admin.upsertInstanceConfig),r=We(d.bridge.validateMediaPaths),i=xt(),o=Rt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>ft(e.config??{},o)),[l,u]=(0,G.useState)(!1),[f,m]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=s.inboundMediaMode===`shared-fs`,y=s.mediaMode===`shared-fs`,b=v||y;async function x(){m(!0),_(null);try{_(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error($e(),e)}finally{m(!1)}}async function S(){u(!0);try{let r=e.config??{};await n({instanceId:e._id,config:mt(s,r,o)}),t()}catch(e){i.error(ge(),e)}finally{u(!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)(k,{label:ne(),help:a()}),(0,Z.jsxs)(B,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:ht.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:h(),help:st()}),(0,Z.jsxs)(B,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:pt.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:ye(),help:te()}),(0,Z.jsx)(L,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:Ye(),help:Ie()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),y&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:Me(),help:rt()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(kt,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Z.jsx)(k,{label:pe(),help:p()})]}),b&&g!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),Pe({reason:g.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:De(),result:g.inbound}),(0,Z.jsx)($,{label:ze(),result:g.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Je()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),tt()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Z.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void x(),disabled:f,children:[f?(0,Z.jsx)(St,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,f?Ae():Ue()]}),(0,Z.jsx)(A,{size:`sm`,onClick:()=>void S(),disabled:l,children:ee()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(bt,{children:[(0,Z.jsx)(Ft,{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)(O,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Et,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:et()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(I,{variant:`secondary`,children:e},e))})]})]})}export{yn as BridgeTab,wn as InstanceConfigDialog};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$h as r,Ah as i,Bg as a,Bh as o,Bt as s,Ch as c,D as l,Dh as u,E as d,Eh as f,Fg as p,Fh as m,Gg as h,Gh as g,Hg as ee,Hh as _,Ht as v,Ig as te,Ih as y,Jg as b,Jh as x,Kg as ne,Kh as S,Kt as re,Lh as ie,Mh as ae,Nh as oe,Oh as se,Ph as ce,Qh as le,Rh as ue,Sh as de,Th as fe,Ug as pe,Uh as me,Ut as he,Vg as ge,Vh as _e,Vt as ve,Wg as ye,Wh as be,Xh as xe,Xs as Se,Yg as Ce,Yh as we,Zh as Te,_P as Ee,_h as C,ac as De,ag as Oe,bh as ke,cc as Ae,cg as je,dc as Me,dg as Ne,ec as Pe,eg as Fe,fc as Ie,fg as Le,gh as w,hP as Re,ic as ze,ig as Be,jh as Ve,kh as He,lc as Ue,lg as We,nc as Ge,ng as Ke,oc as qe,og as Je,pg as Ye,qh as Xe,rc as Ze,rg as Qe,sc as T,sg as $e,tc as et,tg as tt,uc as nt,ug as rt,vP as E,vh as D,wh as it,xh as at,yh as ot,zg as st,zh as ct,zt as lt}from"./dist-BKXYNjW7.js";import{i as O,r as ut}from"./dist-D06QCQPB.js";import{t as dt}from"./chevrons-up-down-BlSBNq85.js";import{i as ft,n as k,o as pt,r as mt,s as ht}from"./FieldLabel-C2HKtml6.js";import{i as gt,n as _t,r as vt,t as yt}from"./tabs-CXQdq7rn.js";import{t as A}from"./button-CdHluvSK.js";import{$ as bt,$t as j,C as M,H as xt,Kt as St,Lt as Ct,Pt as N,S as P,T as F,_t as wt,dt as I,en as Tt,et as Et,ft as L,h as Dt,ht as Ot,it as R,m as kt,mt as At,nn as jt,pt as Mt,rn as Nt,rt as Pt,tt as Ft,vt as It,w as z,wt as Lt,x as B}from"./index-DZcxHX-q.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-BlgvNhKf.js";import{t as Ht}from"./FilterBar-CQBSm0gy.js";import{a as Ut,n as Wt,o as Gt,r as Kt,s as qt,t as Jt}from"./compatView-CB9xzhbT.js";import{t as W}from"./dispatchErrorInfo-CkqdtQzy.js";var Yt=l(`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=l(`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),[a,o]=(0,G.useState)(null),s=(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]),l=(0,G.useMemo)(()=>dn(s),[s]),d=(0,G.useMemo)(()=>fn(s),[s]),p=(0,G.useMemo)(()=>pn(s),[s]),m=(0,G.useMemo)(()=>un(sn(s,n),a),[s,n,a]);function h(e){o(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:ce()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Ht,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:Ve(),onReset:()=>r(an),canReset:on(n),children:[(0,Z.jsxs)(B,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:He()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(M,{value:J,children:i()}),l.map(e=>(0,Z.jsx)(M,{value:e,children:gn(e)},e))]})]}),(0,Z.jsxs)(B,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(F,{placeholder:se()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(M,{value:J,children:i()}),d.map(e=>(0,Z.jsx)(M,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(B,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(F,{placeholder:u()})}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(M,{value:J,children:i()}),p.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))]})]})]}),m.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(0,Z.jsxs)(Vt,{className:`oc-conn__table`,children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:fe(),sortKey:`target`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:it(),sortKey:`state`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:c(),sortKey:`instance`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:de(),sortKey:`host`,sort:a,onSort:h}),(0,Z.jsx)(Q,{label:at(),sortKey:`version`,sort:a,onSort:h}),(0,Z.jsx)(V,{children:ke()}),(0,Z.jsx)(Q,{label:ot(),sortKey:`lastOk`,sort:a,onSort:h})]})}),(0,Z.jsx)(Bt,{children:m.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)(ut,{size:13,"aria-hidden":!0}):(0,Z.jsx)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(dt,{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:[ae({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`?D():e===`error`?C():w()}function _n({state:e}){return e===`connected`?(0,Z.jsx)(I,{variant:`secondary`,children:D()}):e===`error`?(0,Z.jsx)(I,{variant:`destructive`,children:C()}):(0,Z.jsx)(I,{variant:`outline`,children:w()})}function vn(){return E(d.bridgeHealth.getBridgeHealth,{})}function yn(){let e=vn(),t=E(d.compat.getBridgeCompat,{}),n=E(d.me.getMe,{host:Lt})?.role===`admin`,i=E(d.admin.listInstances,n?{}:`skip`),a=E(d.agents.usageForInstances,n?{}:`skip`),o=jt(),c=()=>void o({to:`/settings/anomalies`,search:{status:`open`}}),l=rn(e?e.targets:[],t?t.targets:[],i??[]),{section:u}=Nt({from:`/settings/bridge`}),f=jt({from:`/settings/bridge`}),p=t?.compat??null,m=t===void 0?`loading`:t===null?`nodata`:`ready`,h=p!==null&&Wt(p,`hermes`)&&!l.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(bn,{health:e,compat:t,onSeeAnomalies:c}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:r()}),a&&a.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:le()}),(0,Z.jsxs)(Vt,{children:[(0,Z.jsx)(zt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:he()}),(0,Z.jsx)(V,{children:v()}),(0,Z.jsx)(V,{children:ve()}),(0,Z.jsx)(V,{children:s()}),(0,Z.jsx)(V,{children:lt()})]})}),(0,Z.jsx)(Bt,{children:a.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(I,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,l.length>0?(0,Z.jsxs)(yt,{value:l.some(e=>e.key===u)?u:l[0]?.key??`openclaw`,onValueChange:e=>void f({search:{section:e},replace:!0}),children:[(0,Z.jsx)(vt,{className:`w-full`,children:l.map(e=>(0,Z.jsxs)(gt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(Ct,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),l.map(e=>(0,Z.jsx)(_t,{value:e.key,children:(0,Z.jsx)(xn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:p,compatStatus:m,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,h?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}):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:nt(),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?T():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:g()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:be()});let s=Zt(e.targets),c=!e.reachable,l=$t(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=Pt(e.checkedAt),p=e.startedAt==null?null:Pt(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Z.jsx)(j,{size:22}):c||l===`gateways_unreachable`?(0,Z.jsx)(Xt,{size:22}):(0,Z.jsx)(N,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?me():l===`gateways_unreachable`?ct({count:u.length}):c?_():_e({count:s.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}),` `,o({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:ue({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:y()})]})}function xn({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?qt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=l.map(e=>e.state),f=d.includes(`beyond`)?`beyond`:d.length>0&&d.every(e=>e===`supported`)?`supported`:null,[p,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)(Ct,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),f?(0,Z.jsx)(I,{variant:f===`beyond`?`destructive`:`secondary`,children:Kt(f)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ie()}),(0,Z.jsx)(Cn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Z.jsx)(Sn,{protocol:o}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":p,onClick:()=>h(e=>!e),children:[p?(0,Z.jsx)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),m({count:t.length})]}),p?(0,Z.jsx)(mn,{connections:t,displayByInstance:c}):null]})}function Sn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[Te(),i.length>0?(0,Z.jsx)(I,{variant:`destructive`,children:we({count:i.length})}):(0,Z.jsx)(I,{variant:`secondary`,children:xe()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[x({version:e.vendoredVersion}),r?` · `+Xe({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)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Tt,{size:13,"aria-hidden":!0}),S({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:g()}):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:re({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:ze({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:T()}),e?(0,Z.jsx)(En,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Ut(e.version)}),(0,Z.jsx)(I,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Kt(e.state)})]},e.instanceName))})]})}function wn({instance:e,onClose:t}){return(0,Z.jsx)(Mt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(It,{children:Ce({instance:e.displayName??e.name})}),(0,Z.jsx)(Ot,{children:b()})]}),(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)(j,{"aria-hidden":!0}):(0,Z.jsx)(N,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?Qe():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,Ke()]}):null}function Tn({instance:e,onClose:t}){let n=Ee(d.admin.upsertInstanceConfig),r=Re(d.bridge.validateMediaPaths),i=xt(),o=Rt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>ft(e.config??{},o)),[l,u]=(0,G.useState)(!1),[f,m]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=s.inboundMediaMode===`shared-fs`,y=s.mediaMode===`shared-fs`,b=v||y;async function x(){m(!0),_(null);try{_(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error($e(),e)}finally{m(!1)}}async function S(){u(!0);try{let r=e.config??{};await n({instanceId:e._id,config:mt(s,r,o)}),t()}catch(e){i.error(ge(),e)}finally{u(!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)(k,{label:ne(),help:a()}),(0,Z.jsxs)(B,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:ht.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:h(),help:st()}),(0,Z.jsxs)(B,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Z.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(F,{})}),(0,Z.jsx)(P,{children:pt.map(e=>(0,Z.jsx)(M,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:ye(),help:te()}),(0,Z.jsx)(L,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:Ye(),help:Le()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),y&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:Ne(),help:rt()}),(0,Z.jsx)(L,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(kt,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Z.jsx)(k,{label:pe(),help:p()})]}),b&&g!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),Fe({reason:g.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:Oe(),result:g.inbound}),(0,Z.jsx)($,{label:Be(),result:g.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Je()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(N,{"aria-hidden":!0}),tt()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Z.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void x(),disabled:f,children:[f?(0,Z.jsx)(St,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,f?je():We()]}),(0,Z.jsx)(A,{size:`sm`,onClick:()=>void S(),disabled:l,children:ee()})]})]})})}function En({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(bt,{children:[(0,Z.jsx)(Ft,{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)(O,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(Et,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:et()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(I,{variant:`secondary`,children:e},e))})]})]})}export{yn as BridgeTab,wn as InstanceConfigDialog};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bi as r,E as i,Fl as a,Gi as o,Gt as s,Hi as c,Ki as l,Nl as u,Ol as d,Ri as f,Ui as p,Vi as m,Wi as h,Zc as g,_P as _,_c as v,bc as y,cP as b,gP as x,gc as S,hc as C,kl as w,mP as T,mc as E,pc as D,qg as O,qi as k,vc as A,xc as j,yc as M,zi as N}from"./dist-Dw05q7xL.js";import{t as P}from"./button-CJcuK3wk.js";import{C as F,Pt as I,S as L,T as R,b as z,f as B,ft as V,m as H,p as U,w as W,x as G}from"./index-CVElkIyB.js";import{i as K}from"./compatView-B7k06dFl.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=x(i.admin.upsertInstanceConfig),n=_(i.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[o,s]=(0,q.useState)(r),[l,u]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{s(r),u(`idle`)},[e._id,r]);let d=`__none__`,f=o!==r;async function m(){u(`saving`);try{let n={...e.config??{}};o===``||o===d?delete n.converterAgentId:n.converterAgentId=o,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`error`)}}let g=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:h()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:p()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(G,{value:o===``?d:o,onValueChange:e=>s(e===d?``:e),children:[(0,X.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":h(),children:(0,X.jsx)(R,{placeholder:c()})}),(0,X.jsxs)(L,{children:[(0,X.jsx)(F,{value:d,children:c()}),g.map(e=>(0,X.jsx)(F,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!f||l===`saving`,onClick:()=>void m(),children:l===`saving`?a():C()})]}),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=x(i.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,s=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[c,l]=(0,q.useState)(n),[u,d]=(0,q.useState)(s===null?``:String(s)),[f,p]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{l(n),d(s===null?``:String(s)),p(`idle`)},[e._id,n,s]);let h=u.trim(),g=h===``?null:/^\d+$/.test(h)?Number.parseInt(h,10):NaN,_=!c||g===null||Number.isInteger(g)&&g>=4e3&&g<=6e4,v=c!==n||(g??null)!==s;async function y(){p(`saving`);try{let n={...e.config??{}};n.curationEnabled=c,!c||g===null||Number.isNaN(g)?delete n.curationBudgetChars:n.curationBudgetChars=g,await t({instanceId:e._id,config:n}),p(`done`)}catch{p(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(H,{checked:c,onCheckedChange:e=>l(e===!0),"aria-label":o()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:o()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:u,onChange:e=>d(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":m(),disabled:!c}),(0,X.jsx)(P,{size:`sm`,disabled:!v||!_||f===`saving`,onClick:()=>void y(),children:f===`saving`?a():C()})]}),_?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:r()}),f===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,f===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:N()})]})}function $({instance:e}){let t=x(i.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,o]=(0,q.useState)(n===null?``:String(n)),[s,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{o(n===null?``:String(n)),c(`idle`)},[e._id,n]);let u=r.trim(),d=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,p=d===null||Number.isInteger(d)&&d>=1e3&&d<=2e5,m=(d??null)!==n;async function h(){c(`saving`);try{let n={...e.config??{}};d===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=d,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()}),(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=>o(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!p}),(0,X.jsx)(P,{size:`sm`,disabled:!m||!p||s===`saving`,onClick:()=>void h(),children:s===`saving`?a():C()})]}),p?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:f()}),s===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,s===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:D()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:l()})]})}function ee(){let e=T(i.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),r=_(i.admin.listInstances,{}),[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!r||r.length===0||(!a||!r.some(e=>e.name===a))&&o(r[0].name)},[r,a]);let c=(r?.length??0)>1,l=r!==void 0&&r.length===0,f=_(i.compat.forInstance,a?{instanceName:a}:`skip`),p=a?z(f,`configDefaults`):`loading`,m=p===`loading`?null:p.blocked,h=(0,q.useMemo)(()=>c&&a?{instanceName:a}:{},[c,a]),x=(0,q.useRef)(0),C=(0,q.useCallback)(async()=>{let t=++x.current;n({status:`loading`});try{let r=Y(await e(h));if(x.current!==t)return;n({status:`done`,current:r})}catch{if(x.current!==t)return;n({status:`error`})}},[e,h]);(0,q.useEffect)(()=>{m===!1&&(c&&!a||C())},[C,m,c,a]);let E=t.status===`done`?t.current:null,D=(0,q.useMemo)(()=>J.map(e=>({id:e,label:U(e)})),[]),k=(0,q.useMemo)(()=>[{id:`fast`,label:w()},{id:`standard`,label:d()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}),c&&a?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()}),(0,X.jsxs)(G,{value:a,onValueChange:e=>o(e),children:[(0,X.jsx)(W,{size:`sm`,"aria-label":g(),children:(0,X.jsx)(R,{})}),(0,X.jsx)(L,{children:(r??[]).map(e=>(0,X.jsx)(F,{value:e.name,children:e.name},e.name))})]})]}):null,l?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:O()}):p===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):p.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(I,{size:14,"aria-hidden":!0}),` `,K(p.gatewayVersion,p.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[S(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void C(),children:u()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:y()}),(0,X.jsx)(B,{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:A()}),(0,X.jsx)(B,{options:k,value:E===null||E.fastModeDefault===null?null:E.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:v()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:s()})]}),(()=>{let e=r?.find(e=>e.name===(a??r[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bi as r,E as i,Fl as a,Gi as o,Gt as s,Hi as c,Ki as l,Nl as u,Ol as d,Ri as f,Ui as p,Vi as m,Wi as h,Zc as g,_P as _,_c as v,bc as y,gc as b,hP as x,hc as S,kl as C,lP as w,mc as T,pc as E,qg as D,qi as O,vP as k,vc as A,xc as j,yc as M,zi as N}from"./dist-BKXYNjW7.js";import{t as P}from"./button-CdHluvSK.js";import{C as F,Pt as I,S as L,T as R,b as z,f as B,ft as V,m as H,p as U,w as W,x as G}from"./index-DZcxHX-q.js";import{i as K}from"./compatView-CB9xzhbT.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.admin.upsertInstanceConfig),n=k(i.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[o,s]=(0,q.useState)(r),[l,u]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{s(r),u(`idle`)},[e._id,r]);let d=`__none__`,f=o!==r;async function m(){u(`saving`);try{let n={...e.config??{}};o===``||o===d?delete n.converterAgentId:n.converterAgentId=o,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`error`)}}let g=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:h()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:p()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(G,{value:o===``?d:o,onValueChange:e=>s(e===d?``:e),children:[(0,X.jsx)(W,{className:`oc-cdefaults__select`,"aria-label":h(),children:(0,X.jsx)(R,{placeholder:c()})}),(0,X.jsxs)(L,{children:[(0,X.jsx)(F,{value:d,children:c()}),g.map(e=>(0,X.jsx)(F,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!f||l===`saving`,onClick:()=>void m(),children:l===`saving`?a():S()})]}),l===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:T()}):null,l===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null]})}function Q({instance:e}){let t=_(i.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,s=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[c,l]=(0,q.useState)(n),[u,d]=(0,q.useState)(s===null?``:String(s)),[f,p]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{l(n),d(s===null?``:String(s)),p(`idle`)},[e._id,n,s]);let h=u.trim(),g=h===``?null:/^\d+$/.test(h)?Number.parseInt(h,10):NaN,v=!c||g===null||Number.isInteger(g)&&g>=4e3&&g<=6e4,y=c!==n||(g??null)!==s;async function b(){p(`saving`);try{let n={...e.config??{}};n.curationEnabled=c,!c||g===null||Number.isNaN(g)?delete n.curationBudgetChars:n.curationBudgetChars=g,await t({instanceId:e._id,config:n}),p(`done`)}catch{p(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(H,{checked:c,onCheckedChange:e=>l(e===!0),"aria-label":o()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:o()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:u,onChange:e=>d(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!v,"aria-label":m(),disabled:!c}),(0,X.jsx)(P,{size:`sm`,disabled:!y||!v||f===`saving`,onClick:()=>void b(),children:f===`saving`?a():S()})]}),v?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:r()}),f===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:T()}):null,f===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:N()})]})}function $({instance:e}){let t=_(i.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,o]=(0,q.useState)(n===null?``:String(n)),[s,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{o(n===null?``:String(n)),c(`idle`)},[e._id,n]);let u=r.trim(),d=u===``?null:/^\d+$/.test(u)?Number.parseInt(u,10):NaN,p=d===null||Number.isInteger(d)&&d>=1e3&&d<=2e5,m=(d??null)!==n;async function h(){c(`saving`);try{let n={...e.config??{}};d===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=d,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`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=>o(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!p}),(0,X.jsx)(P,{size:`sm`,disabled:!m||!p||s===`saving`,onClick:()=>void h(),children:s===`saving`?a():S()})]}),p?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:f()}),s===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:T()}):null,s===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:E()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:l()})]})}function ee(){let e=x(i.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),r=k(i.admin.listInstances,{}),[a,o]=(0,q.useState)(null);(0,q.useEffect)(()=>{!r||r.length===0||(!a||!r.some(e=>e.name===a))&&o(r[0].name)},[r,a]);let c=(r?.length??0)>1,l=r!==void 0&&r.length===0,f=k(i.compat.forInstance,a?{instanceName:a}:`skip`),p=a?z(f,`configDefaults`):`loading`,m=p===`loading`?null:p.blocked,h=(0,q.useMemo)(()=>c&&a?{instanceName:a}:{},[c,a]),_=(0,q.useRef)(0),S=(0,q.useCallback)(async()=>{let t=++_.current;n({status:`loading`});try{let r=Y(await e(h));if(_.current!==t)return;n({status:`done`,current:r})}catch{if(_.current!==t)return;n({status:`error`})}},[e,h]);(0,q.useEffect)(()=>{m===!1&&(c&&!a||S())},[S,m,c,a]);let T=t.status===`done`?t.current:null,E=(0,q.useMemo)(()=>J.map(e=>({id:e,label:U(e)})),[]),O=(0,q.useMemo)(()=>[{id:`fast`,label:C()},{id:`standard`,label:d()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}),c&&a?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()}),(0,X.jsxs)(G,{value:a,onValueChange:e=>o(e),children:[(0,X.jsx)(W,{size:`sm`,"aria-label":g(),children:(0,X.jsx)(R,{})}),(0,X.jsx)(L,{children:(r??[]).map(e=>(0,X.jsx)(F,{value:e.name,children:e.name},e.name))})]})]}):null,l?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:D()}):p===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:w()}):p.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(I,{size:14,"aria-hidden":!0}),` `,K(p.gatewayVersion,p.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:w()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[b(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:u()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:y()}),(0,X.jsx)(B,{options:E,value:T?.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:A()}),(0,X.jsx)(B,{options:O,value:T===null||T.fastModeDefault===null?null:T.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:v()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:s()})]}),(()=>{let e=r?.find(e=>e.name===(a??r[0]?.name));return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{instance:e}),(0,X.jsx)(Q,{instance:e}),(0,X.jsx)(Z,{instance:e})]}):null})()]})}export{ee as ChatDefaultsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bf as r,Hf as i,If as a,Lf as o,Rf as s,Vf as c,zf as l}from"./dist-Dw05q7xL.js";import{i as u,r as d}from"./dist-Czk9m5q_.js";import{t as f}from"./chevrons-up-down-QpMWDm41.js";import{t as p}from"./button-CJcuK3wk.js";import{Bt as m,Ft as h,Yt as g,at as _,lt as v,m as y,ot as b,st as x,ut as S}from"./index-CVElkIyB.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-HcdAROEr.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)(h,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children: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)(y,{"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)(y,{"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)(_,{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)(g,{})})}),(0,M.jsx)(b,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(x,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
1
+ 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-BKXYNjW7.js";import{i as u,r as d}from"./dist-D06QCQPB.js";import{t as f}from"./chevrons-up-down-BlSBNq85.js";import{t as p}from"./button-CdHluvSK.js";import{Bt as m,Ft as h,Yt as g,at as _,lt as v,m as y,ot as b,st as x,ut as S}from"./index-DZcxHX-q.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-BlgvNhKf.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)(h,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children: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)(y,{"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)(y,{"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)(_,{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)(g,{})})}),(0,M.jsx)(b,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(x,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{dt as t}from"./index-CVElkIyB.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{dt as t}from"./index-DZcxHX-q.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};
@@ -0,0 +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,E as c,EC as l,FC as u,GC as d,HC as f,IC as p,JC as m,KC as ee,LC as te,MC as h,NC as g,OC as _,PC as v,QC as y,RC as ne,SC as b,TC as x,UC as re,VC as ie,WC as S,XC as C,YC as w,ZC as T,_C as E,_P as D,ai as O,aw as k,bC as A,cw as j,dC as M,dw as N,ew as P,fC as F,gC as I,hC as L,iw as R,jC as z,kC as B,lC as V,lw as H,mC as U,nw as W,ow as G,pC as ae,qC as K,ri as q,rw as J,sw as oe,tw as se,uC as ce,uw as le,vC as ue,vP as de,wC as fe,xC as pe,yC as me,zC as he}from"./dist-BKXYNjW7.js";import{t as ge}from"./button-CdHluvSK.js";import{U as _e,rt as Y}from"./index-DZcxHX-q.js";import{t as ve}from"./DataTableShell-O-bA35dG.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>N(),incorrect:()=>le(),incoherence:()=>H(),formatting:()=>j(),latency:()=>oe(),api_error:()=>G(),other:()=>k()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:J()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:W()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:R()})}function be({data:e,reference:t,closeReason:n}){let i=e.snapshot,o=D(c.feedback.respondToFeedback),[s,l]=(0,X.useState)(e.thread),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(!1);async function b(){let t=h.trim();if(!(!t||_)){v(!0);try{await o({feedbackId:e._id,text:t}),l(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),g(``)}finally{v(!1)}}}let x=[];try{x=i.contextJson?JSON.parse(i.contextJson):[]}catch{x=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:i.displayedMatchesStored,sourceWasOpen:i.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,i.messageRole,i.isRegeneration?` · ${se()}`:``,i.openclawModel?` · ${i.openclawModel}`:``,i.openclawRuntime?` (${i.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:B(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:P()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:L()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:r()}),s.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:s.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`?y():e.authorRole===`agent`?e.authorLabel??O():T()}),(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:w(),value:h,maxLength:2e3,rows:3,onChange:e=>g(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void b(),disabled:!h.trim()||_,children:_?m():K()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ee()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.messageText||d()})]}),i.clientInfo?.sourceWasOpen&&i.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:S()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.displayedText||d()})]}):null,i.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:i.promptText})]}):null,x.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f({count:i.contextCount??x.length,truncated:i.contextTruncated?ie():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:x.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,i.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:a()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[i.outboxText??``,i.outboxStatus?`\n[status: ${i.outboxStatus}]`:``]})]}):null,i.clientInfo?.extensionsDetected&&i.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:he()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:i.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:ne()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[i.clientInfo?.language,i.clientInfo?.timezone,i.clientInfo?.theme?te({theme:i.clientInfo.theme}):null,i.runId?`run ${i.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,i.clientInfo?.plugins&&i.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[p(),` `,i.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,u()]})]}):null,i.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:i.clientInfo.userAgent}):null]})]})]})}function xe(){let e=de(c.feedback.listForAdmin,{}),t=D(c.feedback.readSnapshot),n=D(c.feedback.deleteFeedback),r=_e(),[a,u]=(0,X.useState)(null),[d,f]=(0,X.useState)({});async function p(e){if(a===e._id){u(null);return}if(!d[e._id]){let n=await t({feedbackId:e._id});f(t=>({...t,[e._id]:n}))}u(e._id)}async function m(e){await r({title:M(),description:ce(),confirmLabel:V(),destructive:!0})&&(await n({feedbackId:e._id}),a===e._id&&u(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[v(),` `,(0,Z.jsx)(`strong`,{children:g()}),` `,h()]}),(0,Z.jsx)(ve,{title:z(),rows:e,emptyHint:i(),isExpanded:e=>a===e._id&&!!d[e._id],renderExpanded:e=>d[e._id]?(0,Z.jsx)(be,{data:d[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:_(),cell:e=>Y(e.at),sort:e=>e.at},{header:s(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:l(),cell:e=>e.messageRole===`user`?x():fe(),sort:e=>e.messageRole},{header:o(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${b({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:pe(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:A(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:me(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:ue()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:E()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:q()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:I()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?U():ae(),onSelect:()=>void p(e)},{label:F(),onSelect:()=>void m(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{D as t,wP as n}from"./dist-Dw05q7xL.js";import{_ as r,g as i,v as a,y as o}from"./index-CVElkIyB.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,TP as n}from"./dist-BKXYNjW7.js";import{_ as r,g as i,v as a,y as o}from"./index-DZcxHX-q.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:
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AN as ee,CN as r,DN as te,E as i,EN as ne,FN as a,IN as re,MN as o,NN as s,ON as ie,PN as ae,SN as c,TN as l,_N as oe,_P as se,aN as ce,bN as u,cN as d,ci as f,dN as p,dP as m,fN as h,gN as le,hN as ue,iN as de,jN as fe,kN as pe,lN as g,lP as me,li as _,mN as he,nN as ge,oN as _e,pN as ve,rN as ye,sN as be,tN as xe,uD as v,uN as y,vN as b,vP as x,wN as S,xN as C,yN as w}from"./dist-BKXYNjW7.js";import{t as T}from"./button-CdHluvSK.js";import{C as E,Ft as D,G as O,H as k,J as A,K as j,Q as M,S as N,T as P,X as Se,Xt as F,Y as Ce,Yt as we,Z as Te,at as Ee,dt as I,m as De,ot as Oe,q as ke,st as L,ut as Ae,w as R,x as z,zt as je}from"./index-DZcxHX-q.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-BlgvNhKf.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return l();case`audio`:return S();case`video`:return r();case`pdf`:return c();case`document`:return C();case`archive`:return u();default:return w()}}function q(){let[e,t]=(0,U.useState)(G),[n,r]=(0,U.useState)(G),[c,l]=(0,U.useState)(G),[u,S]=(0,U.useState)(G),[C,w]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=se(i.files.softDelete),Y=k();function Ie(){t(G),r(G),l(G),S(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(d())}catch(e){Y.error(be(),e)}}let X=x(i.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:c===G?void 0:c,category:u===G?void 0:u,includeAutoGenerated:C||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(m(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:me()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||c!==G||u!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:re()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(z,{value:e,onValueChange:t,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":a(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:ae()}),(0,W.jsx)(E,{value:`inbound`,children:s()}),(0,W.jsx)(E,{value:`outbound`,children:o()})]})]}),(0,W.jsxs)(z,{value:n,onValueChange:r,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":fe(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:ee()}),Q.chats.map(e=>(0,W.jsx)(E,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(z,{value:c,onValueChange:l,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":pe(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:ie()}),Q.instances.map(e=>(0,W.jsx)(E,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(z,{value:u,onValueChange:S,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":te(),children:(0,W.jsx)(P,{})}),(0,W.jsxs)(N,{children:[(0,W.jsx)(E,{value:G,children:ne()}),Q.categories.map(e=>(0,W.jsx)(E,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(De,{checked:C,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)(je,{size:14,"aria-hidden":!0}),p()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?ge():ye()}):(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:b()}),(0,W.jsx)(B,{children:oe()}),(0,W.jsx)(B,{children:le()}),(0,W.jsx)(B,{children:ue()}),(0,W.jsx)(B,{children:he()}),(0,W.jsx)(B,{className:`text-right`,children:ve()})]})}),(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:f()}):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`?s():o()})}),(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":y(),children:(0,W.jsx)(we,{size:16})})}),(0,W.jsxs)(Oe,{align:`end`,children:[e.url?(0,W.jsx)(L,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(F,{size:14}),h()]})}):(0,W.jsxs)(L,{disabled:!0,children:[(0,W.jsx)(F,{size:14}),de()]}),(0,W.jsxs)(L,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(D,{size:14}),g()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:xe({cap:Be})}):null]}),(0,W.jsx)(O,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(A,{children:[(0,W.jsxs)(Te,{children:[(0,W.jsx)(M,{children:_e()}),(0,W.jsx)(Ce,{children:ce()})]}),(0,W.jsxs)(Se,{children:[(0,W.jsx)(ke,{children:v()}),(0,W.jsx)(j,{onClick:()=>void Le(),children:g()})]})]})})]})}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-Dw05q7xL.js";import{t as a}from"./button-CJcuK3wk.js";import{Rt as o,ft as s,zt as c}from"./index-CVElkIyB.js";import{t as l}from"./TimeRangePicker-5EYfNRUQ.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)(o,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(c,{}),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-BKXYNjW7.js";import{t as a}from"./button-CdHluvSK.js";import{Rt as o,ft as s,zt as c}from"./index-DZcxHX-q.js";import{t as l}from"./TimeRangePicker-CV_IaaKP.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)(o,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(c,{}),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,Du as l,E as u,Eu as d,Fu as f,Gu as p,Hu as m,Iu as h,Jl as g,Ju as _,Ku as v,Lu as y,Mu as b,Nu as x,Ou as S,Pu as C,Ql as w,Qu as T,Ru as ee,Su as E,Tu as D,Uu as O,Vu as k,Wu as te,Xl as A,Xu as j,Yl as ne,Yu as re,Zl as M,Zu as N,_P as P,_u as F,au as I,bu as ie,cu as L,du as ae,ed as R,eu as oe,fu as se,gP as z,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-Dw05q7xL.js";import{t as Ae}from"./x-DiDC_TeC.js";import{i as V,n as H,r as je,t as Me}from"./tabs--02lZ4zx.js";import{t as U}from"./button-CJcuK3wk.js";import{C as Ne,H as W,It as G,Lt as K,S as Pe,T as Fe,U as Ie,_t as Le,d as Re,dt as q,en as ze,ft as J,ht as Be,m as Y,mt as Ve,pt as He,tn as Ue,vt as We,w as Ge,wt as Ke,x as qe}from"./index-CVElkIyB.js";import{t as Je}from"./FilterBar-D6zZSKoR.js";import{t as Ye}from"./DataTableShell-CRhep8-q.js";import{t as X}from"./DetailChips-DU6aRrkw.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 E();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=P(u.groups.listGroups,{}),t=P(u.me.getMe,{host:Ke})?.role===`admin`,n=z(u.groups.createGroup),r=z(u.groups.updateGroup),a=z(u.groups.deleteGroup),s=Ie(),c=W(),[l,d]=(0,Q.useState)(!1),[g,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(it),[C,w]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(``),M=(0,Q.useMemo)(()=>{if(!e)return e;let t=E.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,E]);function F(){b(null),S(it),d(!0)}function I(e){b(e),S({name:e.name,description:e.description??``}),d(!0)}async function ie(){try{g?await r({groupId:g._id,name:x.name,description:x.description}):await n({name:x.name,description:x.description||void 0}),S(it),b(null),d(!1)}catch(e){c.error(A(),e)}}async function L(e){if(await s({title:y({name:e.name}),description:h(),confirmWord:e.name,confirmLabel:f(),cancelLabel:O(),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:E,onQChange:D,onReset:()=>D(``),canReset:E!==``,searchPlaceholder:_()}),(0,$.jsx)(Ye,{title:he(),rows:M,addLabel:R(),onAdd:t?F:void 0,emptyHint:i(),columns:[{header:T(),cell:e=>e.name,sort:e=>e.name},{header:N(),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:j(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(K,{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)(G,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:be(),onSelect:()=>w({groupId:e._id,name:e.name})},...t?[{label:v(),onSelect:()=>I(e)},{label:p(),variant:`destructive`,onSelect:()=>void L(e)}]:[]]}),(0,$.jsx)(Re,{open:l,onOpenChange:d,title:g?k():m(),description:o(),canSubmit:!!x.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)(J,{value:x.name,onChange:e=>S({...x,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:ee()}),(0,$.jsx)(J,{value:x.description,onChange:e=>S({...x,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:C?.groupId??null,groupName:C?.name??``,open:C!==null,onOpenChange:e=>{e||w(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)(Ue,{size:14,"aria-hidden":!0}),d()]}),(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:[D(),(0,$.jsx)(ze,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:i}){let o=P(u.groups.getGroup,n&&e?{groupId:e}:`skip`),s=P(u.groups.listAssignableInstances,n?{}:`skip`),c=P(u.groups.listAssignableUsers,n?{}:`skip`),d=z(u.groups.addMember),f=z(u.groups.removeMember),p=z(u.groups.bulkSetMembers),m=z(u.groups.setGroupManager),h=W(),[_,v]=(0,Q.useState)(``),[y,T]=(0,Q.useState)(``),[ee,E]=(0,Q.useState)(`members`),[D,O]=(0,Q.useState)(1),[k,te]=(0,Q.useState)(new Set),A=(0,Q.useRef)(null),j=(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,M=(0,Q.useMemo)(()=>new Set((o?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[o]);(0,Q.useEffect)(()=>{v(``),T(``),E(`members`),O(1),A.current=null},[n,e]),(0,Q.useEffect)(()=>{O(1)},[_]),(0,Q.useEffect)(()=>{n&&o&&e&&A.current!==e&&(A.current=e,te(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let N=(0,Q.useMemo)(()=>c?Qe(c,_,k):[],[c,_,k]);async function F(t,n){if(e)try{n?await f({groupId:e,userId:t}):await d({groupId:e,userId:t})}catch(e){h.error(g(),e)}}async function I(t,n){if(e)try{await m({groupId:e,userId:t,manager:!n})}catch(e){h.error(w(),e)}}let L=nt(N,e=>j.has(e.userId)),ae=N.filter(e=>j.has(e.userId)).length,R=rt(N,D,ot);async function se(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await p({groupId:e,userIds:t,member:L!==`all`})}catch(e){h.error(g(),e)}}return(0,$.jsx)(He,{open:n,onOpenChange:i,children:(0,$.jsxs)(Ve,{className:`oc-access`,children:[(0,$.jsxs)(Le,{children:[(0,$.jsx)(We,{children:C({name:t})}),(0,$.jsx)(Be,{children:x()})]}),(0,$.jsxs)(Me,{value:ee,onValueChange:E,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}),b(),o?(0,$.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(K,{size:13,"aria-hidden":!0}),a(),o?(0,$.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:M.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)(q,{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)(J,{value:_,onChange:e=>v(e.target.value),placeholder:de(),className:`oc-access__search`}),N.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:S()}):(0,$.jsxs)($.Fragment,{children:[N.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:L===`all`?!0:L===`some`?`indeterminate`:!1,onCheckedChange:()=>void se(),"aria-label":l()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:l()}),(0,$.jsxs)(q,{variant:`outline`,className:`oc-access__count`,children:[ae,` / `,N.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:R.pageItems.map(e=>{let t=j.has(e.userId),n=et(e),i=ne.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:t,onCheckedChange:()=>void F(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)(q,{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 I(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:R.page,pageCount:R.pageCount,onPage:O})]})]})}),(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)(J,{value:y,onChange:e=>T(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:M,query:y},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=P(u.groups.listAssignableAgents,{instanceName:t}),o=z(u.groups.assignAgentToGroup),s=z(u.groups.removeAgentFromGroup),c=z(u.groups.bulkSetGroupAgents),d=W(),[f,p]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{p(1)},[i]),!e)return null;let m=$e(a?.agents??[],i),h=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&m.length===0)return null;let g=m.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),_=nt(g,e=>r.has(`${t}/${e.agentId}`)),v=rt(m,f,ot);async function y(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){d.error(ye(),e)}}async function b(){if(g.length===0)return;let n=g.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:_!==`all`})}catch(e){d.error(ye(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(K,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(q,{variant:`outline`,className:`oc-access__kind`,children:n}),h?(0,$.jsx)(q,{variant:`outline`,className:`oc-access__stale`,children:se()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:F()}):m.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:h?ve():me()}):(0,$.jsxs)($.Fragment,{children:[g.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:_===`all`?!0:_===`some`?`indeterminate`:!1,onCheckedChange:()=>void b(),"aria-label":l()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:l()})]}):null,v.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)(Y,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void y(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)(G,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(q,{variant:`outline`,className:`oc-access__gone`,children:ae()}):null]},e.agentId)}),(0,$.jsx)(st,{page:v.page,pageCount:v.pageCount,onPage:p})]})]})}function ut({groupId:e}){let t=P(u.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=z(u.charts.assignChartToGroup),r=z(u.charts.removeChartFromGroup),i=z(u.charts.setGroupDefaultChart),a=z(u.charts.addChartToGroupPool),o=z(u.charts.removeChartFromGroupPool),s=W();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()});let{pool:c,addable:l,canManagePool:d}=t;if(c.length===0&&!d)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:L()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(M(),e)}}async function p(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(M(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(M(),e)}}async function h(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(M(),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)(Y,{checked:e.selected,onCheckedChange:()=>void f(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)(G,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:ge()}):null,d?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":I({name:e.name}),title:I({name:e.name}),onClick:()=>void h(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?l.length>0?(0,$.jsxs)(qe,{value:``,onValueChange:e=>void m(e),children:[(0,$.jsx)(Ge,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Fe,{placeholder:_e()})}),(0,$.jsx)(Pe,{children:l.map(e=>(0,$.jsx)(Ne,{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,Du as l,E as u,Eu as d,Fu as f,Gu as p,Hu as m,Iu as h,Jl as g,Ju as _,Ku as v,Lu as y,Mu as b,Nu as x,Ou as S,Pu as C,Ql as w,Qu as T,Ru as ee,Su as E,Tu as D,Uu as O,Vu as k,Wu as te,Xl as A,Xu as j,Yl as ne,Yu as re,Zl as M,Zu as N,_P as P,_u as F,au as I,bu as ie,cu as L,du as ae,ed as R,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,vP as z,vu as B,wu as Ee,xu as De,yu as Oe,zu as ke}from"./dist-BKXYNjW7.js";import{t as Ae}from"./x-B77pQElB.js";import{i as V,n as H,r as je,t as Me}from"./tabs-CXQdq7rn.js";import{t as U}from"./button-CdHluvSK.js";import{C as Ne,H as W,It as G,Lt as K,S as Pe,T as Fe,U as Ie,_t as Le,d as Re,dt as q,en as ze,ft as J,ht as Be,m as Y,mt as Ve,pt as He,tn as Ue,vt as We,w as Ge,wt as Ke,x as qe}from"./index-DZcxHX-q.js";import{t as Je}from"./FilterBar-CQBSm0gy.js";import{t as Ye}from"./DataTableShell-O-bA35dG.js";import{t as X}from"./DetailChips-F3RMiEWW.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 E();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=z(u.groups.listGroups,{}),t=z(u.me.getMe,{host:Ke})?.role===`admin`,n=P(u.groups.createGroup),r=P(u.groups.updateGroup),a=P(u.groups.deleteGroup),s=Ie(),c=W(),[l,d]=(0,Q.useState)(!1),[g,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(it),[C,w]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(``),M=(0,Q.useMemo)(()=>{if(!e)return e;let t=E.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,E]);function F(){b(null),S(it),d(!0)}function I(e){b(e),S({name:e.name,description:e.description??``}),d(!0)}async function ie(){try{g?await r({groupId:g._id,name:x.name,description:x.description}):await n({name:x.name,description:x.description||void 0}),S(it),b(null),d(!1)}catch(e){c.error(A(),e)}}async function L(e){if(await s({title:y({name:e.name}),description:h(),confirmWord:e.name,confirmLabel:f(),cancelLabel:O(),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:E,onQChange:D,onReset:()=>D(``),canReset:E!==``,searchPlaceholder:_()}),(0,$.jsx)(Ye,{title:he(),rows:M,addLabel:R(),onAdd:t?F:void 0,emptyHint:i(),columns:[{header:T(),cell:e=>e.name,sort:e=>e.name},{header:N(),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:j(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(K,{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)(G,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:be(),onSelect:()=>w({groupId:e._id,name:e.name})},...t?[{label:v(),onSelect:()=>I(e)},{label:p(),variant:`destructive`,onSelect:()=>void L(e)}]:[]]}),(0,$.jsx)(Re,{open:l,onOpenChange:d,title:g?k():m(),description:o(),canSubmit:!!x.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)(J,{value:x.name,onChange:e=>S({...x,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:ee()}),(0,$.jsx)(J,{value:x.description,onChange:e=>S({...x,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:C?.groupId??null,groupName:C?.name??``,open:C!==null,onOpenChange:e=>{e||w(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)(Ue,{size:14,"aria-hidden":!0}),d()]}),(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:[D(),(0,$.jsx)(ze,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:i}){let o=z(u.groups.getGroup,n&&e?{groupId:e}:`skip`),s=z(u.groups.listAssignableInstances,n?{}:`skip`),c=z(u.groups.listAssignableUsers,n?{}:`skip`),d=P(u.groups.addMember),f=P(u.groups.removeMember),p=P(u.groups.bulkSetMembers),m=P(u.groups.setGroupManager),h=W(),[_,v]=(0,Q.useState)(``),[y,T]=(0,Q.useState)(``),[ee,E]=(0,Q.useState)(`members`),[D,O]=(0,Q.useState)(1),[k,te]=(0,Q.useState)(new Set),A=(0,Q.useRef)(null),j=(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,M=(0,Q.useMemo)(()=>new Set((o?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[o]);(0,Q.useEffect)(()=>{v(``),T(``),E(`members`),O(1),A.current=null},[n,e]),(0,Q.useEffect)(()=>{O(1)},[_]),(0,Q.useEffect)(()=>{n&&o&&e&&A.current!==e&&(A.current=e,te(new Set((o.members??[]).map(e=>e.userId))))},[n,o,e]);let N=(0,Q.useMemo)(()=>c?Qe(c,_,k):[],[c,_,k]);async function F(t,n){if(e)try{n?await f({groupId:e,userId:t}):await d({groupId:e,userId:t})}catch(e){h.error(g(),e)}}async function I(t,n){if(e)try{await m({groupId:e,userId:t,manager:!n})}catch(e){h.error(w(),e)}}let L=nt(N,e=>j.has(e.userId)),ae=N.filter(e=>j.has(e.userId)).length,R=rt(N,D,ot);async function se(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await p({groupId:e,userIds:t,member:L!==`all`})}catch(e){h.error(g(),e)}}return(0,$.jsx)(He,{open:n,onOpenChange:i,children:(0,$.jsxs)(Ve,{className:`oc-access`,children:[(0,$.jsxs)(Le,{children:[(0,$.jsx)(We,{children:C({name:t})}),(0,$.jsx)(Be,{children:x()})]}),(0,$.jsxs)(Me,{value:ee,onValueChange:E,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}),b(),o?(0,$.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:j.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(K,{size:13,"aria-hidden":!0}),a(),o?(0,$.jsx)(q,{variant:`secondary`,className:`oc-access__tabcount`,children:M.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)(q,{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)(J,{value:_,onChange:e=>v(e.target.value),placeholder:de(),className:`oc-access__search`}),N.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:S()}):(0,$.jsxs)($.Fragment,{children:[N.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:L===`all`?!0:L===`some`?`indeterminate`:!1,onCheckedChange:()=>void se(),"aria-label":l()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:l()}),(0,$.jsxs)(q,{variant:`outline`,className:`oc-access__count`,children:[ae,` / `,N.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:R.pageItems.map(e=>{let t=j.has(e.userId),n=et(e),i=ne.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:t,onCheckedChange:()=>void F(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)(q,{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 I(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:R.page,pageCount:R.pageCount,onPage:O})]})]})}),(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)(J,{value:y,onChange:e=>T(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:M,query:y},`${e}-${t._id}`))})]})}),(0,$.jsx)(H,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=z(u.groups.listAssignableAgents,{instanceName:t}),o=P(u.groups.assignAgentToGroup),s=P(u.groups.removeAgentFromGroup),c=P(u.groups.bulkSetGroupAgents),d=W(),[f,p]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{p(1)},[i]),!e)return null;let m=$e(a?.agents??[],i),h=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&m.length===0)return null;let g=m.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),_=nt(g,e=>r.has(`${t}/${e.agentId}`)),v=rt(m,f,ot);async function y(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){d.error(ye(),e)}}async function b(){if(g.length===0)return;let n=g.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:_!==`all`})}catch(e){d.error(ye(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(K,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(q,{variant:`outline`,className:`oc-access__kind`,children:n}),h?(0,$.jsx)(q,{variant:`outline`,className:`oc-access__stale`,children:se()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:F()}):m.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:h?ve():me()}):(0,$.jsxs)($.Fragment,{children:[g.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:_===`all`?!0:_===`some`?`indeterminate`:!1,onCheckedChange:()=>void b(),"aria-label":l()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:l()})]}):null,v.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)(Y,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void y(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)(G,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(q,{variant:`outline`,className:`oc-access__gone`,children:ae()}):null]},e.agentId)}),(0,$.jsx)(st,{page:v.page,pageCount:v.pageCount,onPage:p})]})]})}function ut({groupId:e}){let t=z(u.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=P(u.charts.assignChartToGroup),r=P(u.charts.removeChartFromGroup),i=P(u.charts.setGroupDefaultChart),a=P(u.charts.addChartToGroupPool),o=P(u.charts.removeChartFromGroupPool),s=W();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:B()});let{pool:c,addable:l,canManagePool:d}=t;if(c.length===0&&!d)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:L()});async function f(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(M(),e)}}async function p(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(M(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(M(),e)}}async function h(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(M(),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)(Y,{checked:e.selected,onCheckedChange:()=>void f(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)(G,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void p(e.chartKey),children:ge()}):null,d?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":I({name:e.name}),title:I({name:e.name}),onClick:()=>void h(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),d?l.length>0?(0,$.jsxs)(qe,{value:``,onValueChange:e=>void m(e),children:[(0,$.jsx)(Ge,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Fe,{placeholder:_e()})}),(0,$.jsx)(Pe,{children:l.map(e=>(0,$.jsx)(Ne,{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};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,$x as i,AS as a,Ax as o,Bx as s,CS as c,Cx as l,DS as u,Dx as d,E as f,ES as p,Ex as m,FS as h,Fx as g,Gx as _,Hx as v,Ix as y,Jb as b,Jt as x,Jx as S,Kb as C,Kx as ee,Lg as te,Lx as ne,MS as w,Mx as T,NS as E,Nx as re,OS as ie,Ox as ae,PS as oe,Px as se,Qb as ce,Qx as D,Rg as le,Rx as ue,SS as de,Sx as fe,TS as pe,Tx as me,Ux as he,Vx as O,Wx as ge,Xb as _e,Xt as ve,Xx as ye,Yb as be,Yt as xe,Yx as Se,Zb as Ce,Zx as k,_P as A,_S as we,_x as Te,aS as Ee,ax as De,bS as Oe,bx as ke,cS as Ae,ca as je,cx as Me,dS as Ne,da as Pe,dx as Fe,eS as Ie,ex as Le,fS as Re,fx as ze,gS as Be,gx as j,hP as M,hS as Ve,iS as He,ix as Ue,jS as We,jx as Ge,kS as Ke,kx as qe,lS as Je,la as Ye,lx as Xe,mS as Ze,mx as Qe,nO as $e,nS as et,nx as tt,oS as nt,ox as rt,pS as it,px as at,qb as ot,qx as st,rO as N,rS as ct,rx as lt,sS as ut,sx as dt,tS as ft,tx as pt,uS as mt,ua as ht,ux as gt,vP as P,vS as _t,vx as vt,wS as yt,wx as bt,xS as F,xx as I,yS as xt,yx as L,zx as St}from"./dist-BKXYNjW7.js";import{a as Ct,c as wt}from"./FieldLabel-C2HKtml6.js";import{t as R}from"./button-CdHluvSK.js";import{$ as Tt,C as z,H as B,S as V,T as H,U as Et,_t as U,d as Dt,dt as W,et as Ot,ft as G,ht as K,m as kt,mt as At,pt as jt,tt as Mt,vt as Nt,w as q,x as J}from"./index-DZcxHX-q.js";import{t as Pt}from"./DataTableShell-O-bA35dG.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-7Gp-lSm8.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Ct},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=P(f.admin.listInstances,{}),t=P(f.agents.listAllInstanceAgents,{}),n=A(f.admin.upsertInstance),r=A(f.admin.deleteInstance),i=B(),[o,s]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)(Q),[m,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null);async function ee(){try{await n({instanceId:S??void 0,name:l.name,gatewayUrl:l.gatewayUrl,bridgeUrl:l.bridgeUrl||void 0,displayName:l.displayName||void 0,kind:l.kind,transport:l.kind===`hermes`?l.transport:void 0,gatewayVersion:l.gatewayVersion||void 0,gatewayHttpUrl:l.gatewayHttpUrl||void 0,streamTransport:l.streamTransport}),d(Q),C(null),s(!1)}catch(e){i.error(E(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[w(),(0,Z.jsx)(`strong`,{children:We()}),a()]}),(0,Z.jsx)(Pt,{title:Ke(),rows:e,addLabel:ie(),onAdd:()=>{C(null),d(Q),s(!0)},emptyHint:u(),columns:[{header:p(),cell:e=>e.name,sort:e=>e.name},{header:pe(),cell:e=>(0,Z.jsx)(W,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:yt(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:c(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:h(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(W,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?ot():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:xt(),onSelect:()=>{C(e._id),d(Bt(e)),s(!0)}},{label:oe(),onSelect:()=>g(e.name)},{label:He(),onSelect:()=>b(e)},{label:de(),onSelect:()=>v(e)},{label:F(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:F(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(Dt,{open:o,onOpenChange:s,title:S?_t():Oe(),description:Be(),canSubmit:!!(l.name&&l.gatewayUrl),onSubmit:ee,submitLabel:Ve(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Ze(),children:[(0,Z.jsx)(G,{value:l.name,disabled:S!==null,onChange:e=>d({...l,name:e.target.value})}),S?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:we()}):null]}),(0,Z.jsx)($,{label:it(),children:(0,Z.jsxs)(J,{value:l.kind,onValueChange:e=>d({...l,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(z,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(z,{value:`hermes`,children:`Hermes`})]})]})}),l.kind===`hermes`?(0,Z.jsx)($,{label:ve(),children:(0,Z.jsxs)(J,{value:l.transport,onValueChange:e=>d({...l,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(H,{})}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(z,{value:`ws`,children:xe()}),(0,Z.jsx)(z,{value:`rest`,children:x()})]})]})}):null,(0,Z.jsx)($,{label:Re(),children:(0,Z.jsx)(G,{value:l.gatewayUrl,onChange:e=>d({...l,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:Ne(),children:(0,Z.jsx)(G,{value:l.bridgeUrl,placeholder:mt(),onChange:e=>d({...l,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:Je(),children:(0,Z.jsx)(G,{value:l.displayName,onChange:e=>d({...l,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:le(),children:[(0,Z.jsxs)(J,{value:l.streamTransport,onValueChange:e=>d({...l,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(H,{})}),(0,Z.jsx)(V,{children:wt.map(e=>(0,Z.jsx)(z,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:te()})]}),(0,Z.jsx)($,{label:Ae(),children:(0,Z.jsx)(G,{value:l.gatewayVersion,placeholder:ut(),onChange:e=>d({...l,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:nt(),children:(0,Z.jsx)(G,{value:l.gatewayHttpUrl,placeholder:Ee(),onChange:e=>d({...l,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:m,open:m!==null,onOpenChange:e=>{e||g(null)}}),_?(0,Z.jsx)(Ft,{instance:_,onClose:()=>v(null)},_._id):null,y?(0,Z.jsx)(Ht,{instance:y,onClose:()=>b(null)},y._id):null]})}function Ht({instance:e,onClose:t}){let n=P(f.instanceSecrets.listInstanceSecretStatus,{}),r=zt[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(jt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(At,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(Nt,{children:ct({instance:e.displayName??e.name})}),(0,Z.jsx)(K,{children:et()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=M(f.instanceSync.forceInstanceSync),n=B(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(y());break;case`no_agents`:n.success(se());break;case`no_bridge_url`:n.error(re());break;case`deploy_misconfigured`:n.error(T());break;case`unauthorized`:n.error(o());break;case`not_served`:n.error(qe());break;default:n.error(Ge());break}}catch(e){n.error(g(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?ne():ue()})})]})}function Wt({instance:e}){let t=P(f.bridgeAuth.listBridgeAuthStatus,{}),n=M(f.bridgeAuth.mintBridgeSecret),r=A(f.bridgeAuth.revokeBridgeSecret),i=B(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[u,p]=(0,Y.useState)(!1),h=(t??[]).find(t=>t.instanceId===e._id),g=h!==void 0;async function _(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),p(!1)}catch(e){i.error(I(),e)}finally{o(!1)}}}async function v(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(fe())}catch(e){i.error(I(),e)}finally{o(!1)}}}async function y(){if(s)try{await navigator.clipboard.writeText(s),p(!0)}catch{}}return(0,Z.jsxs)($,{label:d(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:m()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(W,{variant:g?`outline`:`secondary`,children:g?`${D()} · ${h.prefix}…${h.lastFour}`:k()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void _(),disabled:a,children:g?bt():me()}),g?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void v(),disabled:a,children:l()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:ke()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:u?N():$e()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),p(!1)},children:L()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=M(f.instanceSecrets.setInstanceSecret),a=A(f.instanceSecrets.clearInstanceSecret),o=M(f.deviceIdentity.generateDeviceIdentity),c=B(),[l,u]=(0,Y.useState)(``),[d,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(null),[g,y]=(0,Y.useState)(!1),b=n!==null,x=t===`deviceIdentity`,C=t===`token`?ft():t===`deviceIdentity`?Ie():i();async function te(){if(!(!l.trim()||d)){p(!0);try{await r({instanceId:e,field:t,plaintext:l}),u(``),h(null),y(!1),c.success(ee())}catch(e){c.error(_(),e)}finally{p(!1)}}}async function ne(){if(!d){p(!0);try{await a({instanceId:e,field:t}),h(null),y(!1),c.success(ge())}catch(e){c.error(_(),e)}finally{p(!1)}}}async function w(){if(!d){p(!0);try{h(await o({instanceId:e})),y(!1),c.success(O())}catch(e){c.error(St(),e)}finally{p(!1)}}}let T=m?`openclaw devices approve ${m.id}`:``;async function E(){if(T)try{await navigator.clipboard.writeText(T),y(!0)}catch{}}return(0,Z.jsxs)($,{label:C,children:[x?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(W,{variant:b?`outline`:`secondary`,children:b?D():k()}),(0,Z.jsx)(G,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:l,placeholder:b?Se():ye(),onChange:e=>u(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void te(),disabled:d||l.trim().length===0,children:S()}),x?(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void w(),disabled:d,children:he()}):null,b?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void ne(),disabled:d,children:st()}):null]})]}),m?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:O()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:s()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void E(),children:g?N():$e()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{h(null),y(!1)},children:L()})]}):null]})}var Kt={conversational:Me,documentary:rt,summarizer:Pe,curator:Ye},qt={conversational:dt,documentary:De,summarizer:ht,curator:je},Jt=e=>(Kt[e]??(()=>e))(),Yt=e=>(qt[e]??(()=>``))();function Xt({agentId:e,types:t,onToggle:n}){return(0,Z.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,Z.jsx)(`span`,{className:`oc-agentcard__types-label`,children:ze()}),t.map(e=>(0,Z.jsx)(W,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(Tt,{children:[(0,Z.jsx)(Mt,{asChild:!0,children:(0,Z.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Fe()})}),(0,Z.jsxs)(Ot,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:gt()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Xe()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(kt,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let i=P(f.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=A(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=A(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=A(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=Rt(r);e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=A(f.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(f.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(f.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=A(f.agents.removeInstanceAgent),u=Et(),d=B();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 g(t,n){if(e&&await u({title:tt({name:n}),description:pt(),confirmLabel:Le(),destructive:!0}))try{await l({instanceName:e,agentId:t}),d.success(r())}catch(e){d.error(j(),e)}}return(0,Z.jsx)(jt,{open:t,onOpenChange:n,children:(0,Z.jsxs)(At,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(Nt,{children:vt({name:e??``})}),(0,Z.jsx)(K,{children:Te()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:ce()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?Ce():i.discovery.lastPollOk?_e():be({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:b()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,r=i.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(kt,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void p(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:C()}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void g(t.agentId,a),children:lt()})]}):r?(0,Z.jsx)(W,{variant:`default`,children:ot()}):(0,Z.jsx)(R,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void m(t.agentId),children:Ue()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void h(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){d.error(j(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(G,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Qe(),"aria-label":at(),onChange:e=>r(e.target.value),onBlur:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())}})}function $({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}export{Vt as InstancesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ao as r,Cw as i,Do as a,E as o,Eo as s,Mo as c,Oo as l,Sw as u,To as d,_P as f,_w as p,bw as m,dw as h,fw as g,gP as _,gw as v,hw as y,jo as b,ko as x,mP as S,mw as C,pw as w,vw as T,wo as E,ww as D,xw as O,yw as k}from"./dist-Dw05q7xL.js";import{t as A}from"./button-CJcuK3wk.js";import{dt as j,ft as M,m as N}from"./index-CVElkIyB.js";var P=t(e(),1),F=n();function I(){let e=f(o.integrations.status.status,{}),t=_(o.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:D()});let s=n,l=(e,t,n)=>a({...s,[e]:{...s[e],[t]:n}}),d=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[i(),` `,(0,F.jsx)(`strong`,{children:u()}),` `,O()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:m()}):(0,F.jsx)(j,{variant:`outline`,children:k()}):(0,F.jsx)(j,{variant:`outline`,children:T()}),note:p(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:s.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>l(`langfuse`,`host`,e.target.value),onBlur:()=>d(`langfuse`,{host:s.langfuse.host??``})})}),(0,F.jsx)(z,{label:h(),checked:s.langfuse.enabled??!0,onChange:e=>{l(`langfuse`,`enabled`,e),d(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:m()}):(0,F.jsx)(j,{variant:`outline`,children:k()}):(0,F.jsx)(j,{variant:`outline`,children:T()}),note:v(),children:[(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(M,{value:s.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>l(`opik`,`baseUrl`,e.target.value),onBlur:()=>d(`opik`,{baseUrl:s.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:w(),children:(0,F.jsx)(M,{value:s.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||g(),onChange:e=>l(`opik`,`workspace`,e.target.value),onBlur:()=>d(`opik`,{workspace:s.opik.workspace??``})})}),(0,F.jsx)(z,{label:h(),checked:s.opik.enabled??!0,onChange:e=>{l(`opik`,`enabled`,e),d(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:m()}):(0,F.jsx)(j,{variant:`outline`,children:k()}):(0,F.jsx)(j,{variant:`outline`,children:c()}),note:b(),children:[(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:s.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>l(`otlp`,`endpoint`,e.target.value),onBlur:()=>d(`otlp`,{endpoint:s.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:h(),checked:s.otlp.enabled??!0,onChange:e=>{l(`otlp`,`enabled`,e),d(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=S(o.integrations.otlpSecret.setOtlpHeaders),n=_(o.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[c,u]=(0,P.useState)(null),[f,p]=(0,P.useState)(!1),m=async()=>{p(!0),u(null);try{await t({headersJson:r}),i(``)}catch(e){u(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,F.jsxs)(R,{label:x(),children:[(0,F.jsx)(M,{value:r,placeholder:e?l():a(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void m(),children:s()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:d()}):null]}),c?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:c}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:E()})]})}export{I as IntegrationsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ao as r,Cw as i,Do as a,E as o,Eo as s,Mo as c,Oo as l,Sw as u,To as d,Tw as f,_P as p,_w as m,bw as h,fw as g,gw as _,hP as v,hw as y,jo as b,ko as x,mw as S,pw as C,vP as w,vw as T,wo as E,ww as D,xw as O,yw as k}from"./dist-BKXYNjW7.js";import{t as A}from"./button-CdHluvSK.js";import{dt as j,ft as M,m as N}from"./index-DZcxHX-q.js";var P=t(e(),1),F=n();function I(){let e=w(o.integrations.status.status,{}),t=p(o.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:f()});let s=n,l=(e,t,n)=>a({...s,[e]:{...s[e],[t]:n}}),d=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[D(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,u()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:k()}),note:T(),children:[(0,F.jsx)(R,{label:_(),children:(0,F.jsx)(M,{value:s.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>l(`langfuse`,`host`,e.target.value),onBlur:()=>d(`langfuse`,{host:s.langfuse.host??``})})}),(0,F.jsx)(z,{label:g(),checked:s.langfuse.enabled??!0,onChange:e=>{l(`langfuse`,`enabled`,e),d(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:k()}),note:m(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:s.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>l(`opik`,`baseUrl`,e.target.value),onBlur:()=>d(`opik`,{baseUrl:s.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:S(),children:(0,F.jsx)(M,{value:s.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||C(),onChange:e=>l(`opik`,`workspace`,e.target.value),onBlur:()=>d(`opik`,{workspace:s.opik.workspace??``})})}),(0,F.jsx)(z,{label:g(),checked:s.opik.enabled??!0,onChange:e=>{l(`opik`,`enabled`,e),d(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:c()}),note:b(),children:[(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:s.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>l(`otlp`,`endpoint`,e.target.value),onBlur:()=>d(`otlp`,{endpoint:s.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:g(),checked:s.otlp.enabled??!0,onChange:e=>{l(`otlp`,`enabled`,e),d(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=v(o.integrations.otlpSecret.setOtlpHeaders),n=p(o.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[c,u]=(0,P.useState)(null),[f,m]=(0,P.useState)(!1),h=async()=>{m(!0),u(null);try{await t({headersJson:r}),i(``)}catch(e){u(e instanceof Error?e.message:String(e))}finally{m(!1)}};return(0,F.jsxs)(R,{label:x(),children:[(0,F.jsx)(M,{value:r,placeholder:e?l():a(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void h(),children:s()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:d()}):null]}),c?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:c}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:E()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,E as i,Gm as a,Jm as o,Km as s,MT as c,Qm as l,Um as u,Wm as d,Xm as f,Xw as p,Ym as m,Zm as h,Zw as g,_P as _,aT as v,eh as y,iT as b,nh as x,oT as S,qm as C,sT as w,th as T}from"./dist-Dw05q7xL.js";import{i as E,nn as D,o as ee,r as te,rn as ne,wt as re}from"./index-CVElkIyB.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-CVCuPx_Y.js";import{n as N,t as P}from"./TimeRangePicker-5EYfNRUQ.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=_(i.me.getMe,{host:re})?.permissions?.includes(`traces.read`)??!1,t=_(i.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,L).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:c()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:w()}),(0,I.jsx)(j,{children:v()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,I.jsx)(B,{series:n})})]})]})}function B({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{style:{color:`var(--primary)`},children:[p(),` p50 `,R(s.cP50),` `,S()]}),(0,I.jsxs)(`span`,{children:[g(),` p50 `,R(s.aP50),` `,S()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":w(),children:[(0,I.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:x(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:T(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:y(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:r(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],H=V.length,U=[`API`,`OpenClaw`,`Chat`,`Assistant`],W=1e3,G=36e5;function K(e,t){let n=Math.max(1,Math.ceil((t-e)/G)),r=Math.min(n*H,W);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/H))}}function q(){let e=ne({from:`/settings/kpi`}),t=D({from:`/settings/kpi`}),n=E(e.from,e.to,te,`now`),r=e=>void t({search:t=>({...t,...ee(e)})}),{from:a,to:s}=N(n),{rowLimit:c,buckets:l}=K(a,s),u=_(i.kpi.listKpis,{limit:c,filter:{from:a,to:s}}),d=(0,F.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>l&&e.set(t,n.slice(n.length-l));return e},[u,l]),p=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[f(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return u===void 0?(0,I.jsxs)(I.Fragment,{children:[p,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}):u.length===0?(0,I.jsxs)(I.Fragment,{children:[p,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:C()})]}):(0,I.jsxs)(I.Fragment,{children:[p,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,I.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,I.jsx)(Y,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function J({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(P,{value:e,onChange:t})})}function Y({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(ae,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:s({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:d({count:t.length})})]})]})]})}var X=240,Z=48,ie=1;function ae({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-ie,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":u({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{q as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,E as i,Gm as a,Jm as o,Km as s,NT as c,Qm as l,Qw as u,Um as d,Wm as f,Xm as p,Ym as m,Zm as h,Zw as g,aT as _,cT as v,eh as y,nh as b,oT as x,qm as S,sT as C,th as w,vP as T}from"./dist-BKXYNjW7.js";import{i as E,nn as D,o as ee,r as te,rn as ne,wt as re}from"./index-DZcxHX-q.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-AXe34vGw.js";import{n as N,t as P}from"./TimeRangePicker-CV_IaaKP.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=T(i.me.getMe,{host:re})?.permissions?.includes(`traces.read`)??!1,t=T(i.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,F.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,L).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:c()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:v()}),(0,I.jsx)(j,{children:x()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,I.jsx)(B,{series:n})})]})]})}function B({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{style:{color:`var(--primary)`},children:[g(),` p50 `,R(s.cP50),` `,C()]}),(0,I.jsxs)(`span`,{children:[u(),` p50 `,R(s.aP50),` `,C()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":v(),children:[(0,I.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:b(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:w(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:y(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:r(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],H=V.length,U=[`API`,`OpenClaw`,`Chat`,`Assistant`],W=1e3,G=36e5;function K(e,t){let n=Math.max(1,Math.ceil((t-e)/G)),r=Math.min(n*H,W);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/H))}}function q(){let e=ne({from:`/settings/kpi`}),t=D({from:`/settings/kpi`}),n=E(e.from,e.to,te,`now`),r=e=>void t({search:t=>({...t,...ee(e)})}),{from:a,to:s}=N(n),{rowLimit:c,buckets:l}=K(a,s),u=T(i.kpi.listKpis,{limit:c,filter:{from:a,to:s}}),d=(0,F.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>l&&e.set(t,n.slice(n.length-l));return e},[u,l]),f=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[p(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return u===void 0?(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}):u.length===0?(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:S()})]}):(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,I.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,I.jsx)(Y,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function J({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(P,{value:e,onChange:t})})}function Y({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(ae,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:s({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:f({count:t.length})})]})]})]})}var X=240,Z=48,ie=1;function ae({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-ie,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":d({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{q as KpiTab};