@lacneu/atrium 0.69.1 → 0.69.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 (85) hide show
  1. package/dist/assets/AccessTab-nOqXnNqd.js +1 -0
  2. package/dist/assets/{AdvancedFilter-B3seyYt-.js → AdvancedFilter-DalnKKbE.js} +1 -1
  3. package/dist/assets/AgentFilesTab-Dz1pqhpI.js +3 -0
  4. package/dist/assets/AnomaliesTab-Cpq-17Ix.js +1 -0
  5. package/dist/assets/{AuditTab-DhuJS60M.js → AuditTab-jQhjHz-F.js} +1 -1
  6. package/dist/assets/BridgeTab-B7X1qwdk.js +1 -0
  7. package/dist/assets/ChatDefaultsTab-DpQZBBbZ.js +1 -0
  8. package/dist/assets/{DataTableShell-CgSphYFu.js → DataTableShell-CqU0-4M7.js} +1 -1
  9. package/dist/assets/{DetailChips-D3CrYO3c.js → DetailChips-DrJgW8-P.js} +1 -1
  10. package/dist/assets/FeedbacksTab-BWqtFYsM.js +1 -0
  11. package/dist/assets/{FieldLabel-Dt5eJKiD.js → FieldLabel-JybJ9RRM.js} +1 -1
  12. package/dist/assets/FilesTab-Bkj8zpxC.js +1 -0
  13. package/dist/assets/{FilterBar-I6E15DsP.js → FilterBar-B4i5RQ5h.js} +1 -1
  14. package/dist/assets/GroupsTab-CIkUWA6C.js +1 -0
  15. package/dist/assets/InstancesTab-Dbbu5JKt.js +1 -0
  16. package/dist/assets/IntegrationsTab-CSgNim1Y.js +1 -0
  17. package/dist/assets/{KpiTab-Cqfp8moM.js → KpiTab-BYdiUCW7.js} +1 -1
  18. package/dist/assets/PreferencesTab-BynMX7kx.js +1 -0
  19. package/dist/assets/ProjectPage-CrSQfAic.js +1 -0
  20. package/dist/assets/PromptInjectionsTab-GhxMEHYm.js +4 -0
  21. package/dist/assets/RolesTab-BJtxahDw.js +1 -0
  22. package/dist/assets/ScheduledTab-EtubzHoE.js +1 -0
  23. package/dist/assets/ServiceAccountsTab-D36fZOx2.js +1 -0
  24. package/dist/assets/SubAgentReportsTab-I5YZ1Jjr.js +1 -0
  25. package/dist/assets/ThemeShowroom-BeidaWln.js +1 -0
  26. package/dist/assets/TimeRangePicker-I8KZZSiJ.js +1 -0
  27. package/dist/assets/{TimezoneCombobox-ko6S60ZX.js → TimezoneCombobox-DuZNYkVA.js} +1 -1
  28. package/dist/assets/TracesTab-B3nkM0Pt.js +1 -0
  29. package/dist/assets/UsersTab-CffKSu3G.js +1 -0
  30. package/dist/assets/VoiceTab-vGLsZHre.js +1 -0
  31. package/dist/assets/api-Dv9KEyyu.js +44 -0
  32. package/dist/assets/{button-B_rxV4Hv.js → button-D9yXQ2Th.js} +1 -1
  33. package/dist/assets/{card-1R1vH3Wp.js → card-CwT7Pj_Y.js} +1 -1
  34. package/dist/assets/check-RMjSSPfa.js +1 -0
  35. package/dist/assets/chevron-up-NPxwzzmO.js +1 -0
  36. package/dist/assets/chevrons-up-down-DT1RCPP_.js +1 -0
  37. package/dist/assets/{compatView-Dg7wsTPK.js → compatView-5r10IMkT.js} +1 -1
  38. package/dist/assets/dispatchErrorInfo-Cqf1On-M.js +1 -0
  39. package/dist/assets/{dist-60cgSkkV.js → dist-1Isc78ze.js} +1 -1
  40. package/dist/assets/{dist-mHgdDBUV.js → dist-BaKVbU2X.js} +1 -1
  41. package/dist/assets/{dist-Bzknt9lC.js → dist-C0PHqVM0.js} +1 -1
  42. package/dist/assets/{highlighted-body-OFNGDK62-CsJyfjdy.js → highlighted-body-OFNGDK62-CB56Z3oc.js} +1 -1
  43. package/dist/assets/index-BAyOACwC.js +238 -0
  44. package/dist/assets/index-o45yUihd.css +1 -0
  45. package/dist/assets/{list-CJldmRo5.js → list-Cxi8aGjl.js} +1 -1
  46. package/dist/assets/mermaid-GHXKKRXX-Uu9pqaP0.js +1 -0
  47. package/dist/assets/{pdf-D-Us2R6E.js → pdf-DmlUy5B4.js} +1 -1
  48. package/dist/assets/roleDescriptions-DgcNSNlq.js +1 -0
  49. package/dist/assets/{table-C2BiIaq6.js → table-DCOgab8-.js} +1 -1
  50. package/dist/assets/{tabs-CJVl3r7X.js → tabs-Dv-cJfvQ.js} +1 -1
  51. package/dist/assets/x-C58t2mLG.js +1 -0
  52. package/dist/index.html +10 -10
  53. package/package.json +1 -1
  54. package/dist/assets/AccessTab-BrxEpjsr.js +0 -1
  55. package/dist/assets/AgentFilesTab-Cs8Nzz_I.js +0 -3
  56. package/dist/assets/AnomaliesTab-D6D6CYSk.js +0 -1
  57. package/dist/assets/BridgeTab-DnIaX4fN.js +0 -1
  58. package/dist/assets/ChatDefaultsTab-BnteHH3v.js +0 -1
  59. package/dist/assets/FeedbacksTab-CSsK5q9T.js +0 -1
  60. package/dist/assets/FilesTab-DRf2WHHd.js +0 -1
  61. package/dist/assets/GroupsTab-DdMjDK06.js +0 -1
  62. package/dist/assets/InstancesTab-s9iO39kt.js +0 -1
  63. package/dist/assets/IntegrationsTab-0BQN2eLD.js +0 -1
  64. package/dist/assets/PreferencesTab-iuWpDWjc.js +0 -1
  65. package/dist/assets/ProjectPage-CLKrB8ZU.js +0 -1
  66. package/dist/assets/PromptInjectionsTab-CV-LnDsD.js +0 -4
  67. package/dist/assets/RolesTab-BlEtFwR8.js +0 -1
  68. package/dist/assets/ScheduledTab-C_ijI98X.js +0 -1
  69. package/dist/assets/ServiceAccountsTab-0RaoKfJe.js +0 -1
  70. package/dist/assets/SubAgentReportsTab-wWGDafZX.js +0 -1
  71. package/dist/assets/ThemeShowroom-BMPThlV5.js +0 -1
  72. package/dist/assets/TimeRangePicker-CVMLr89E.js +0 -1
  73. package/dist/assets/TracesTab-BFLB5V7D.js +0 -1
  74. package/dist/assets/UsersTab-CBVfw_2T.js +0 -1
  75. package/dist/assets/VoiceTab-D55jFmxr.js +0 -1
  76. package/dist/assets/api-CbVyaw6f.js +0 -44
  77. package/dist/assets/check-DI-pspfc.js +0 -1
  78. package/dist/assets/chevron-up-D9LbKOmX.js +0 -1
  79. package/dist/assets/chevrons-up-down-huJFCk51.js +0 -1
  80. package/dist/assets/dispatchErrorInfo-sCqe0cBT.js +0 -1
  81. package/dist/assets/index-Dr-TdniH.css +0 -1
  82. package/dist/assets/index-EISUCtE9.js +0 -238
  83. package/dist/assets/mermaid-GHXKKRXX-C9ORYnsN.js +0 -1
  84. package/dist/assets/roleDescriptions-B4jROh9m.js +0 -1
  85. package/dist/assets/x-DniS1cpm.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$f as r,AR as i,Jf as a,Qf as o,Xf as s,Yf as c,Zf as l,ap as u,ep as d,ip as f,np as p,op as m,qf as h,rp as g,sp as _,t as v,tp as y,zR as b}from"./api-Dv9KEyyu.js";import{_t as x,bt as S,ut as C,vt as w,xt as T,yt as E}from"./index-BAyOACwC.js";var D=t(e(),1);function O(e){return e===`user`?l():e===`all`?s():c({group:e.group})}function k(e){return e===`common`?a():e===`owner`?h():c({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=b(v.admin.listUsers,{}),[t,n]=(0,D.useState)(``),a=b(v.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:_()}),(0,A.jsxs)(x,{value:t,onValueChange:n,children:[(0,A.jsx)(S,{size:`sm`,"aria-label":m(),children:(0,A.jsx)(T,{placeholder:m()})}),(0,A.jsx)(w,{children:(e??[]).map(e=>(0,A.jsx)(E,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):a===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(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:f()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:a.user.label}),(0,A.jsx)(C,{variant:`secondary`,children:a.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),a.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:a.groups.map(e=>(0,A.jsx)(C,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:p()}),a.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:a.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(C,{variant:`default`,children:o()}):null,(0,A.jsx)(C,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(C,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:y()}),a.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:a.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(C,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:d()}),a.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:a.permissions.map(e=>(0,A.jsx)(C,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ch as r,Sh as i,_h as a,bh as o,vh as s,xh as c,yh as l}from"./api-CbVyaw6f.js";import{r as u}from"./dist-mHgdDBUV.js";import{t as d}from"./x-DniS1cpm.js";import{t as f}from"./button-B_rxV4Hv.js";import{_t as p,bt as m,jt as h,ln as g,vt as _,xt as v,yt as y}from"./index-EISUCtE9.js";import{r as b}from"./TimeRangePicker-CVMLr89E.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}),i(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:c()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(p,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(m,{size:`sm`,className:`w-40`,children:(0,S.jsx)(v,{placeholder:o()})}),(0,S.jsx)(_,{children:e.map(e=>(0,S.jsx)(y,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(p,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(m,{size:`sm`,className:`w-28`,children:(0,S.jsx)(v,{})}),(0,S.jsx)(_,{children:C.map(e=>(0,S.jsx)(y,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(h,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:l()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":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)(g,{}),a()]})]}):null]})}export{D as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ch as r,Sh as i,bh as a,vh as o,wh as s,xh as c,yh as l}from"./api-Dv9KEyyu.js";import{r as u}from"./dist-BaKVbU2X.js";import{t as d}from"./x-C58t2mLG.js";import{t as f}from"./button-D9yXQ2Th.js";import{_t as p,bt as m,jt as h,ln as g,vt as _,xt as v,yt as y}from"./index-BAyOACwC.js";import{r as b}from"./TimeRangePicker-I8KZZSiJ.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:s()},{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 s=(0,x.useRef)(t),w=!!(s.current&&s.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(s.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}),r(),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:i()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(p,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(m,{size:`sm`,className:`w-40`,children:(0,S.jsx)(v,{placeholder:c()})}),(0,S.jsx)(_,{children:e.map(e=>(0,S.jsx)(y,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(p,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(m,{size:`sm`,className:`w-28`,children:(0,S.jsx)(v,{})}),(0,S.jsx)(_,{children:C.map(e=>(0,S.jsx)(y,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(h,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:a()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":l(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(g,{}),o()]})]}):null]})}export{D as t};
@@ -0,0 +1,3 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AR as r,Aa as i,Au as a,Ca as o,Cd as s,Cu as c,Da as l,Du as u,Ea as d,Eu as f,Fu as p,Gi as m,IA as h,IR as g,Iu as _,Ji as v,Ki as y,Lu as b,MR as ee,Ma as x,Mu as S,Nu as C,O as w,Oa as T,Ou as E,Pu as te,RR as D,Ru as O,Sa as k,Su as A,Ta as j,Td as M,Tu as N,Wi as P,Xi as F,Yi as I,_a as L,_u as R,ba as z,bu as B,du as ne,fa as V,fu as H,ga as U,gu as W,ha as re,hu as ie,ja as G,ju as ae,ka as oe,ku as se,ma as K,mu as ce,pa as le,pu as ue,qi as de,t as q,uu as fe,va as pe,vu as me,wa as he,wu as ge,xa as _e,xu as ve,ya as ye,yu as be,zR as J,zu as xe}from"./api-Dv9KEyyu.js";import{t as Y}from"./button-D9yXQ2Th.js";import{$ as Se,Dt as Ce,V as we,_t as Te,at as Ee,bt as De,dt as Oe,et as ke,ft as Ae,gt as je,ht as Me,it as Ne,nt as Pe,ot as Fe,pt as Ie,rn as Le,rt as Re,tt as ze,ut as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-BAyOACwC.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{i as qe}from"./compatView-5r10IMkT.js";/* empty css */var X=t(e(),1),Je=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/Je*100)}function Ze(e){return e<=0?0:Math.round(e/Ye*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 Qe(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var $e=3;function et(e,t){let n=new Map;for(let t of e.split(`
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<$e&&a.push(e)):t>0&&(i+=t,o.length<$e&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function tt(e){return(e instanceof Error?e.message:String(e)).includes(`DASHBOARD_NOT_DEPLOYED`)}function nt(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function rt(){let e=J(q.me.getMe,{host:He}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),i=J(q.admin.listInstances,e!==void 0&&t?{}:`skip`),[o,c]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!i||i.length===0||(!o||!i.some(e=>e.name===o))&&c(i[0].name)},[t,i,o]);let d=J(q.agents.listAgentsForInstance,t&&o?{instanceName:o}:`skip`),f=J(q.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),m=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return o===null||d===void 0?i!==void 0&&i.length===0?[]:void 0:d.agents.map(e=>({instanceName:o,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(f!==void 0)return f.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,o,d,i,f]),[h,v]=(0,X.useState)(null);(0,X.useEffect)(()=>{!m||m.length===0||(!h||!m.some(e=>$(e)===h))&&v($(m[0]))},[m,h]);let y=m?.find(e=>$(e)===h)??null,x=g(q.agentFiles.listAgentFiles),[D,k]=(0,X.useState)({status:`idle`}),A=y?.instanceName??null,j=y?.agentId??null,M=J(q.compat.forInstance,n&&A!==null?{instanceName:A}:`skip`),N=n&&A!==null?we(M,`agentFiles`):null,P=N===null?!1:N===`loading`?null:N.blocked,F=(0,X.useCallback)(async()=>{if(!(A===null||j===null)){k({status:`loading`});try{k({status:`done`,files:(await x({instanceName:A,agentId:j})).files})}catch(e){k({status:`error`,dashboardAbsent:tt(e)})}}},[x,A,j]);(0,X.useEffect)(()=>{P===!1&&F()},[F,P]);let[I,L]=(0,X.useState)(null),R=J(q.agentFileCuration.listCurations,t&&A!==null&&j!==null?{instanceName:A,agentId:j}:`skip`),z=J(q.agentFileCuration.curationSettings,t&&A!==null?{instanceName:A}:`skip`),B=g(q.agentFileCuration.requestCuration),[ne,V]=(0,X.useState)(null),[H,U]=(0,X.useState)(null),{toast:W}=Ce(),re=(0,X.useMemo)(()=>{let e=new Map;for(let t of R??[])e.has(t.name)||e.set(t.name,t);return e},[R]),ie=(0,X.useCallback)(async e=>{if(!(A===null||j===null)){V(e);try{let t=await B({instanceName:A,agentId:j,name:e,trigger:`manual`});t.ok?W({title:oe(),variant:`success`}):W({title:T({reason:t.reason??`unknown`}),variant:`error`})}catch{W({title:l(),variant:`error`})}finally{V(null)}}},[B,A,j,W]),G=ee(),K=(0,X.useMemo)(()=>new Intl.NumberFormat(G,{maximumFractionDigits:0}),[G]);return e===void 0||m===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(i?.length??0)>1?(0,Q.jsxs)(Te,{value:o??``,onValueChange:e=>c(e),children:[(0,Q.jsx)(De,{size:`sm`,"aria-label":O(),children:(0,Q.jsx)(Ue,{})}),(0,Q.jsx)(Ve,{children:(i??[]).map(e=>(0,Q.jsx)(We,{value:e.name,children:e.name},e.name))})]}):null,m.length>0?(0,Q.jsxs)(Te,{value:h??``,onValueChange:e=>v(e),children:[(0,Q.jsx)(De,{size:`sm`,"aria-label":b(),children:(0,Q.jsx)(Ue,{})}),(0,Q.jsx)(Ve,{children:m.map(e=>(0,Q.jsx)(We,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_()})]}),y===null?null:N===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):N!==null&&N.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Le,{size:14,"aria-hidden":!0}),` `,qe(N.gatewayVersion,N.provider)]}):D.status===`loading`||D.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):D.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[D.dashboardAbsent?w():te(),` `,!D.dashboardAbsent&&(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void F(),children:s()})]}):D.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:D.files.map(e=>{let n=Xe(e.size),r=n>=80;return(0,Q.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,Q.jsx)(Be,{variant:`outline`,children:C()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:S({size:Z(e.size,G)})}),(0,Q.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,Q.jsx)(`span`,{className:`oc-afiles__pct`,children:ae({pct:K.format(n)})}),r?(0,Q.jsx)(Le,{size:14,className:`oc-afiles__warn`,"aria-label":a()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>L(e),children:t?E():u()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:z?.budgetChars??null,enabled:z?.enabled??!1,curation:re.get(e.name)??null,inFlight:ne===e.name,onCurate:()=>void ie(e.name),onReview:e=>U(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:se({used:Z(Qe(D.files),G),total:Z(Ye,G),pct:K.format(Ze(Qe(D.files)))})})]}),I&&y?(0,Q.jsx)(at,{instanceName:y.instanceName,agentId:y.agentId,name:I.name,isAdmin:t,onClose:()=>L(null),onSaved:()=>void F()}):null,H?(0,Q.jsx)(ot,{curationId:H,onClose:()=>U(null),onApplied:()=>{U(null),F()}}):null]})}function it({curatable:e,size:t,budget:n,enabled:r,curation:a,inFlight:o,onCurate:s,onReview:c}){return a?.status===`proposed`?(0,Q.jsx)(Y,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>c(a._id),children:G()}):o||a?.status===`dispatched`||a?.status===`applying`?(0,Q.jsx)(Be,{variant:`outline`,className:`oc-afiles__curate-status`,children:i()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:s,children:x()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:i,onClose:a,onSaved:o}){let l=g(q.agentFiles.getAgentFile),u=g(q.agentFiles.setAgentFile),d=Ce(),[p,m]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!1),[te,D]=(0,X.useState)(!1),O=(0,X.useCallback)(async r=>{v(!1);try{let i=await l({instanceName:e,agentId:t,name:n});m({content:i.content,updatedAtMs:i.updatedAtMs}),r||b(i.content),E(!1)}catch{v(!0)}},[l,e,t,n]);(0,X.useEffect)(()=>{O(!1)},[O]);async function k(){if(p!==null){w(!0),D(!1);try{await u({instanceName:e,agentId:t,name:n,content:y,baseUpdatedAtMs:p.updatedAtMs??void 0}),d.success(B({name:n})),o(),await O(!1)}catch(e){nt(e)?E(!0):D(!0)}finally{w(!1)}}}let j=p!==null&&y!==p.content,P=(0,X.useMemo)(()=>p===null?null:et(p.content,y),[p,y]),F=y.length>Je,I=ee(),L=(0,X.useMemo)(()=>new Intl.NumberFormat(I),[I]);return(0,Q.jsx)(Oe,{open:!0,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(Ae,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(je,{children:f({name:n})}),(0,Q.jsxs)(Ie,{children:[N({agent:t,instance:e}),i?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,ge()]})]})]}),_?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[me(),` `,(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void O(!1),children:s()})]}):p===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:y,readOnly:!i,spellCheck:!1,onChange:e=>b(e.target.value),"aria-label":f({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:c()}),T?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[R(),` `,(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void O(!0),children:W()})]}):null,te?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:be()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${F?` is-over`:``}`,children:A({count:L.format(y.length),max:L.format(Je)})}),i?(0,Q.jsx)(Y,{size:`sm`,disabled:!j||C||T,onClick:()=>S(!0),children:C?M():ve()}):null]})]}),(0,Q.jsx)(Se,{open:x,onOpenChange:S,children:(0,Q.jsxs)(Pe,{children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(Fe,{children:ie({name:n})}),(0,Q.jsx)(Re,{children:ce({agent:t})})]}),P?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:ue({added:P.added,removed:P.removed})}),P.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:H()}),P.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,P.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:ne()}),P.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(ze,{children:h()}),(0,Q.jsx)(ke,{onClick:()=>void k(),children:fe()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let i=J(q.agentFileCuration.getProposal,{curationId:e}),a=g(q.agentFileCuration.approveCuration),s=D(q.agentFileCuration.rejectCuration),{toast:c}=Ce(),[u,f]=(0,X.useState)(null),[p,h]=(0,X.useState)(!1),[_,b]=(0,X.useState)(``),x=ee(),S=(0,X.useMemo)(()=>i?et(i.beforeContent,i.proposedContent):null,[i]);async function C(){f(`approve`);try{let t=await a({curationId:e});t.ok?(c({title:d(),variant:`success`}),n()):c({title:t.reason===`conflict`?he():o({reason:t.reason??`unknown`}),variant:`error`})}catch{c({title:l(),variant:`error`})}finally{f(null)}}async function w(n){f(`reject`);try{let r=_.trim();(await s({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?c({title:n?m():j(),variant:`success`}):c({title:z(),variant:`error`}),t()}catch{c({title:l(),variant:`error`})}finally{f(null)}}return(0,Q.jsx)(Oe,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Ae,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(je,{children:i?k({name:i.name}):r()}),(0,Q.jsx)(Ie,{children:_e()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):i===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:z()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[ye({before:Z(i.beforeSize,x),after:Z(i.proposedSize,x)}),i.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Le,{size:13,"aria-hidden":!0}),` `,pe()]}):null]}),S?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:L({added:S.added,removed:S.removed})}):null,i.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:P({feedback:i.feedback})}):null,S&&S.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:V()}),(0,Q.jsx)(`ul`,{children:S.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:le()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:U()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.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:I(),value:_,onChange:e=>b(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(Y,{variant:`ghost`,onClick:()=>h(!1),disabled:u!==null,children:v()}),(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>void w(!1),disabled:u!==null,children:u===`reject`?M():de()}),(0,Q.jsx)(Y,{variant:`default`,onClick:()=>void w(!0),disabled:u!==null,children:u===`reject`?M():y()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>h(!0),disabled:u!==null||i==null,children:re()}),(0,Q.jsx)(Y,{variant:`default`,onClick:()=>void C(),disabled:u!==null||i==null,children:u===`approve`?M():K()})]})]})})}export{rt as AgentFilesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$S as r,AS as i,BS as ee,CS as a,DS as te,ES as o,FS as s,GS as ne,HS as c,IS as re,JS as ie,KS as ae,LS as l,MS as u,NS as d,OS as f,PS as p,QS as m,RR as oe,RS as se,SS as h,TS as ce,US as le,VS as ue,WS as de,XS as fe,YS as pe,ZS as me,_S as g,aC as he,bS as _,cC as ge,dC as v,eC as _e,gS as y,iC as ve,jS as ye,kS as be,lC as b,nC as xe,oC as x,qS as S,rC as C,sC as w,t as T,tC as E,uC as D,vS as O,wS as k,xS as A,yS as j,zR as M,zS as Se}from"./api-Dv9KEyyu.js";import{Dt as Ce,Fn as we,Pn as N,Z as Te,_t as P,bt as F,ct as I,dt as L,ft as R,gt as z,ht as B,i as Ee,o as De,ut as V,vt as H,wt as Oe,xt as U,yt as W}from"./index-BAyOACwC.js";import{n as ke}from"./TimeRangePicker-I8KZZSiJ.js";import{t as Ae}from"./FilterBar-B4i5RQ5h.js";import{t as je}from"./DataTableShell-CqU0-4M7.js";import{t as G}from"./dispatchErrorInfo-Cqf1On-M.js";var K=t(e(),1),q=n(),J=`__all__`,Me=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Ne(e){return e===`open`?v():e===`acknowledged`?D():b()}var Pe=[`info`,`warn`,`critical`],Fe=[`detector`,`agent`,`user`],Ie={kind:`relative`,from:`now-30d`,to:`now`},Le=200,Y=`all`;function X(){let e=we({from:`/settings/anomalies`}),t=N({from:`/settings/anomalies`}),n=e.q??``,a=e.status===Y?J:e.status,h=e.severity??J,g=e.kind??J,[_,v]=(0,K.useState)(J),y=Ee(e.from,e.to),{from:b,to:D}=ke(y),O=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),A=e=>void t({search:t=>({...t,status:e===J?Y:e})}),j=e=>void t({search:t=>({...t,severity:e===J?void 0:e})}),L=e=>void t({search:t=>({...t,kind:e===J?void 0:e})}),R=e=>void t({search:t=>({...t,...De(e)})}),z=Te(),B=Ce(),G=oe(T.anomalies.resolveAnomaly),X=(M(T.me.getMe,{host:Oe})?.permissions??[]).includes(`admin.manage`),Z=M(T.anomalies.listAnomalies,{limit:Le,filter:{q:n||void 0,from:b,to:D,anomalyStatus:a===J?void 0:a,severity:h===J?void 0:h,source:_===J?void 0:_,kind:g===J?void 0:g}}),Q=(0,K.useMemo)(()=>{let e=new Set;for(let t of Z??[])e.add(t.kind);return[...e].sort()},[Z]),He=n!==``||a!==`open`||h!==J||_!==J||g!==J||y.kind!==`relative`||y.from!==Ie.from;function Ue(){v(J),t({search:{status:`open`},replace:!0})}async function We(e){if(await z({title:ge(),description:(0,q.jsxs)(q.Fragment,{children:[w(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,x(),` `,(0,q.jsx)(`strong`,{children:he()}),`.`,` `,ve()]}),confirmLabel:C()}))try{await G({anomalyId:e._id,status:`resolved`}),B.success(xe(),e.kind)}catch(e){B.error(E(),e)}}async function Ge(e){try{await G({anomalyId:e._id,status:`acknowledged`}),B.success(_e(),e.kind)}catch(e){B.error(r(),e)}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`oc-admin__hint`,children:[m(),` `,(0,q.jsx)(`strong`,{children:me()}),` `,fe(),` `,(0,q.jsx)(`strong`,{children:pe()}),` `,ie(),` `,(0,q.jsx)(`strong`,{children:S()}),` `,ae(),` `,(0,q.jsx)(`span`,{className:`oc-filter__window`,children:ne()})]}),(0,q.jsxs)(Ae,{q:n,onQChange:O,searchPlaceholder:de(),timeRange:y,onTimeRangeChange:R,onReset:Ue,canReset:He,children:[(0,q.jsxs)(P,{value:a,onValueChange:A,children:[(0,q.jsx)(F,{size:`sm`,className:`w-36`,children:(0,q.jsx)(U,{})}),(0,q.jsxs)(H,{children:[(0,q.jsx)(W,{value:J,children:le()}),Me.map(e=>(0,q.jsx)(W,{value:e.value,children:Ne(e.value)},e.value))]})]}),(0,q.jsxs)(P,{value:h,onValueChange:j,children:[(0,q.jsx)(F,{size:`sm`,className:`w-36`,children:(0,q.jsx)(U,{placeholder:c()})}),(0,q.jsxs)(H,{children:[(0,q.jsx)(W,{value:J,children:se()}),Pe.map(e=>(0,q.jsx)(W,{value:e,children:e},e))]})]}),(0,q.jsxs)(P,{value:_,onValueChange:v,children:[(0,q.jsx)(F,{size:`sm`,className:`w-32`,children:(0,q.jsx)(U,{placeholder:l()})}),(0,q.jsxs)(H,{children:[(0,q.jsx)(W,{value:J,children:re()}),Fe.map(e=>(0,q.jsx)(W,{value:e,children:e},e))]})]}),(0,q.jsxs)(P,{value:g,onValueChange:L,children:[(0,q.jsx)(F,{size:`sm`,className:`w-36`,children:(0,q.jsx)(U,{placeholder:s()})}),(0,q.jsxs)(H,{children:[(0,q.jsx)(W,{value:J,children:p()}),Q.map(e=>(0,q.jsx)(W,{value:e,children:e},e))]})]})]}),(0,q.jsx)(je,{title:d(),rows:Z,emptyHint:a===`open`?u():ye(),rowActions:e=>X&&e.status===`open`?[{label:i(),onSelect:()=>void We(e)},{label:be(),onSelect:()=>void Ge(e)}]:[],columns:[{header:f(),cell:e=>(0,q.jsx)(`span`,{className:`oc-traces__time`,children:I(e.at)}),sort:e=>e.at},{header:s(),cell:e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:ue(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,q.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:Se({when:I(e.firstAt)}),children:ee({count:String(e.occurrenceCount)})}):(0,q.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:c(),cell:e=>(0,q.jsx)(ze,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:te(),cell:e=>(0,q.jsx)(Be,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:l(),cell:e=>(0,q.jsx)(V,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:o(),cell:e=>(0,q.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,q.jsx)(Re,{row:e})]}),sort:e=>e.message},{header:ce(),cell:e=>(0,q.jsx)($,{row:e}),sort:e=>e.evidence??null},{header:k(),cell:e=>e.correlationId?(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:Ve(e.correlationId)}):(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function Z(e){if(e.kind!==`openclaw.dispatch_failures`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function Q(e){if(e.kind!==`subagent.failure`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{failedCount:t.failedCount,totalCount:t.totalCount,errorCategories:t.errorCategories}}catch{return{}}}function $({row:e}){let t=N();if(e.kind===`subagent.failure`){let n=Q(e);return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,a()]}):null]})}let n=Z(e);if(!n.dominantCode)return(0,q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`});let r=G(n.dominantCode),i=n.sampleCorrelationId;return(0,q.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,q.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,q.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,q.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:i,limit:100}}),children:[`↗ `,a()]}):null]})}function Re({row:e}){let[t,n]=(0,K.useState)(!1),r=M(T.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[h(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,q.jsx)(L,{open:t,onOpenChange:n,children:(0,q.jsxs)(R,{className:`oc-anomaly__attachments-dialog`,children:[(0,q.jsx)(B,{children:(0,q.jsx)(z,{children:A()})}),r===void 0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:_()}):r.length===0?(0,q.jsx)(`p`,{className:`oc-traces__muted`,children:j()}):(0,q.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,q.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,q.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,q.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,q.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function ze({severity:e}){return(0,q.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function Be({status:e}){return e===`open`?(0,q.jsx)(V,{variant:`destructive`,children:O()}):e===`acknowledged`?(0,q.jsx)(V,{variant:`secondary`,children:g()}):(0,q.jsx)(V,{variant:`outline`,children:y()})}function Ve(e){return e.length>8?e.slice(0,8):e}export{X as AnomaliesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Br as r,Gr as i,Hr as a,Ur as o,Vr as s,Wr as c,aw as l,cw as u,dw as d,fw as f,hw as p,iw as m,jR as h,lw as g,mw as _,nw as v,ow as y,pw as b,rw as x,sw as S,t as C,tw as w,uw as T}from"./api-CbVyaw6f.js";import{Fn as E,Pn as D,_t as O,a as k,bt as A,ct as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-EISUCtE9.js";import{n as ee}from"./TimeRangePicker-CVMLr89E.js";import{t as z}from"./FilterBar-I6E15DsP.js";import{t as B}from"./AdvancedFilter-B3seyYt-.js";import{t as V}from"./DataTableShell-CgSphYFu.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:i()},{value:`realLabel`,label:c()},{value:`targetLabel`,label:o()},{value:`impersonated`,label:a()},{value:`resource`,label:s()},{value:`resourceId`,label:r()}];function q(){let e=E({from:`/settings/audit`}),t=D({from:`/settings/audit`}),n=e.q??``,r=e.action??G,i=e.impersonated??G,a=e.resource??G,o=M(e.from,e.to),s=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:c,to:N}=ee(o),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:k(e)}),replace:!0}),$=h(C.admin.listAudit,{filter:{q:n||void 0,from:c,to:N,action:r===G?void 0:r,resource:a===G?void 0:a,impersonated:i===G?void 0:i===`yes`,advanced:s.length>0?s:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||i!==G||a!==G||s.length>0||o.kind!==`relative`||o.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:[p(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:_()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:b(),timeRange:o,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(O,{value:r,onValueChange:J,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:f()})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:d()}),te.map(e=>(0,U.jsx)(R,{value:e,children:e},e))]})]}),(0,U.jsxs)(O,{value:i,onValueChange:Y,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:T()}),(0,U.jsx)(R,{value:`yes`,children:g()}),(0,U.jsx)(R,{value:`no`,children:u()})]})]}),(0,U.jsxs)(O,{value:a,onValueChange:X,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:S()})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:y()}),ne.map(e=>(0,U.jsx)(R,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:s,onChange:Q}),(0,U.jsx)(V,{title:l(),rows:$,emptyHint:m(),columns:[{header:x(),cell:e=>j(e.at),sort:e=>e.at},{header:f(),cell:e=>e.action,sort:e=>e.action},{header:v(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:w(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:S(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Gr as r,Hr as i,Kr as a,Ur as o,Vr as s,Wr as c,aw as l,cw as u,dw as d,fw as f,gw as p,hw as m,iw as h,lw as g,mw as _,nw as v,ow as y,pw as b,rw as x,sw as S,t as C,uw as w,zR as T}from"./api-Dv9KEyyu.js";import{Fn as E,Pn as D,_t as O,a as k,bt as A,ct as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-BAyOACwC.js";import{n as ee}from"./TimeRangePicker-I8KZZSiJ.js";import{t as z}from"./FilterBar-B4i5RQ5h.js";import{t as B}from"./AdvancedFilter-DalnKKbE.js";import{t as V}from"./DataTableShell-CqU0-4M7.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:a()},{value:`realLabel`,label:r()},{value:`targetLabel`,label:c()},{value:`impersonated`,label:o()},{value:`resource`,label:i()},{value:`resourceId`,label:s()}];function q(){let e=E({from:`/settings/audit`}),t=D({from:`/settings/audit`}),n=e.q??``,r=e.action??G,i=e.impersonated??G,a=e.resource??G,o=M(e.from,e.to),s=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:c,to:N}=ee(o),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:k(e)}),replace:!0}),$=T(C.admin.listAudit,{filter:{q:n||void 0,from:c,to:N,action:r===G?void 0:r,resource:a===G?void 0:a,impersonated:i===G?void 0:i===`yes`,advanced:s.length>0?s:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||i!==G||a!==G||s.length>0||o.kind!==`relative`||o.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:[p(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:_(),timeRange:o,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(O,{value:r,onValueChange:J,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:b()})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:f()}),te.map(e=>(0,U.jsx)(R,{value:e,children:e},e))]})]}),(0,U.jsxs)(O,{value:i,onValueChange:Y,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:d()}),(0,U.jsx)(R,{value:`yes`,children:w()}),(0,U.jsx)(R,{value:`no`,children:g()})]})]}),(0,U.jsxs)(O,{value:a,onValueChange:X,children:[(0,U.jsx)(A,{size:`sm`,className:`w-40`,children:(0,U.jsx)(L,{placeholder:u()})}),(0,U.jsxs)(I,{children:[(0,U.jsx)(R,{value:G,children:S()}),ne.map(e=>(0,U.jsx)(R,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:s,onChange:Q}),(0,U.jsx)(V,{title:y(),rows:$,emptyHint:l(),columns:[{header:h(),cell:e=>j(e.at),sort:e=>e.at},{header:b(),cell:e=>e.action,sort:e=>e.action},{header:x(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:v(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:u(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$l as r,$v as i,Ay as a,Bv as o,Cy as s,D as c,Dy as l,Ey as u,Fy as d,Gl as f,Gv as p,Hl as m,Hv as h,IR as ee,Jl as g,Jv as _,Kl as v,Kv as y,Ll as b,Lv as x,My as te,Ny as ne,Oy as re,Py as ie,Ql as S,Qv as ae,RR as oe,Rv as se,Sy as ce,Ty as le,Ul as ue,Uv as de,Vl as fe,Vv as pe,Wl as me,Wv as he,Xl as ge,Xv as _e,Yl as ve,Yv as ye,Zl as be,Zv as C,_b as xe,_y as Se,ay as Ce,by as we,cb as Te,cy as Ee,db as De,dr as Oe,dy as ke,ey as Ae,fb as je,fr as Me,fy as w,gb as Ne,gr as Pe,gy as Fe,hy as Ie,ib as Le,iy as Re,jy as ze,k as Be,ky as Ve,lb as He,lr as Ue,ly as We,mb as Ge,my as Ke,ny as qe,oy as Je,pb as Ye,pr as Xe,py as Ze,ql as Qe,qv as $e,rb as et,ry as tt,sb as nt,sy as rt,t as T,ty as it,ub as at,ur as ot,uy as st,vy as ct,wy as lt,xy as ut,yy as dt,zR as E,zv as D}from"./api-Dv9KEyyu.js";import{r as O}from"./dist-BaKVbU2X.js";import{t as ft}from"./chevron-up-NPxwzzmO.js";import{t as pt}from"./chevrons-up-down-DT1RCPP_.js";import{i as mt,n as k,o as ht,r as gt,s as _t}from"./FieldLabel-JybJ9RRM.js";import{i as vt,n as yt,r as bt,t as xt}from"./tabs-Dv-cJfvQ.js";import{t as A}from"./button-D9yXQ2Th.js";import{An as j,Bt as St,Dt as Ct,Fn as wt,I as Tt,P as Et,Pn as Dt,Rt as Ot,_t as M,bn as kt,bt as N,ct as At,dt as jt,ft as Mt,gt as Nt,ht as Pt,jn as Ft,jt as P,lt as F,on as It,pt as Lt,rn as I,ut as L,vt as R,wt as Rt,xt as z,yt as B,zt}from"./index-BAyOACwC.js";import{r as Bt}from"./locales-CPjguROj.js";import{a as Vt,i as V,n as Ht,o as H,r as U,t as Ut}from"./table-DCOgab8-.js";import{t as Wt}from"./FilterBar-B4i5RQ5h.js";import{a as Gt,n as Kt,o as qt,r as Jt,s as Yt,t as Xt}from"./compatView-5r10IMkT.js";import{t as W}from"./dispatchErrorInfo-Cqf1On-M.js";var Zt=c(`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`}]]),Qt=c(`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 $t(e){return e.filter(e=>e.state===`error`)}function en(e){return e.reachable&&$t(e.targets).length===0}function tn(e){return en(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function nn(e){return e.state===`error`&&e.lastErrorCode!==null}function rn(e){return!!e.lastDownstreamRejectCode}function K(e){return e.kind??`openclaw`}function an(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function on(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 an(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__`,sn={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function cn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function ln(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 un(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function dn(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 qt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function fn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=un(t.key,e),a=un(t.key,r);return i&&a?0:i?1:a?-1:n*dn(t.key,e,r)})}function pn(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 mn(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 hn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>qt(e,t)??X(e,t))}var Z=n();function gn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(sn),[i,a]=(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]),c=(0,G.useMemo)(()=>pn(s),[s]),l=(0,G.useMemo)(()=>mn(s),[s]),u=(0,G.useMemo)(()=>hn(s),[s]),d=(0,G.useMemo)(()=>fn(ln(s,n),i),[s,n,i]);function f(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:it()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Wt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:ae(),onReset:()=>r(sn),canReset:cn(n),children:[(0,Z.jsxs)(M,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(N,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(z,{placeholder:_e()})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(B,{value:J,children:C()}),c.map(e=>(0,Z.jsx)(B,{value:e,children:vn(e)},e))]})]}),(0,Z.jsxs)(M,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(N,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(z,{placeholder:ye()})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(B,{value:J,children:C()}),l.map(e=>(0,Z.jsx)(B,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(M,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(N,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(z,{placeholder:_()})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(B,{value:J,children:C()}),u.map(e=>(0,Z.jsx)(B,{value:e,children:e},e))]})]})]}),d.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:$e()}):(0,Z.jsxs)(Ut,{className:`oc-conn__table`,children:[(0,Z.jsx)(Vt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:y(),sortKey:`target`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:p(),sortKey:`state`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:he(),sortKey:`instance`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:de(),sortKey:`host`,sort:i,onSort:f}),(0,Z.jsx)(Q,{label:h(),sortKey:`version`,sort:i,onSort:f}),(0,Z.jsx)(V,{children:pe()}),(0,Z.jsx)(Q,{label:o(),sortKey:`lastOk`,sort:i,onSort:f})]})}),(0,Z.jsx)(Ht,{children:d.map(e=>(0,Z.jsx)(_n,{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)(ft,{size:13,"aria-hidden":!0}):(0,Z.jsx)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(pt,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function _n({r:e}){let t=nn(e)?W(e.lastErrorCode):null,n=rn(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)(yn,{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:Ae({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:F(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?` · ${F(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:[i({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${F(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function vn(e){return e===`connected`?D():e===`error`?se():x()}function yn({state:e}){return e===`connected`?(0,Z.jsx)(L,{variant:`secondary`,children:D()}):e===`error`?(0,Z.jsx)(L,{variant:`destructive`,children:se()}):(0,Z.jsx)(L,{variant:`outline`,children:x()})}function bn(){return E(T.bridgeHealth.getBridgeHealth,{})}function xn(){let e=bn(),t=E(T.compat.getBridgeCompat,{}),n=E(T.me.getMe,{host:Rt})?.role===`admin`,r=E(T.admin.listInstances,n?{}:`skip`),i=E(T.agents.usageForInstances,n?{}:`skip`),a=Dt(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=on(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=wt({from:`/settings/bridge`}),l=Dt({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Kt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(Sn,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:ut()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:we()}),(0,Z.jsxs)(Ut,{children:[(0,Z.jsx)(Vt,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:Xe()}),(0,Z.jsx)(V,{children:Me()}),(0,Z.jsx)(V,{children:Oe()}),(0,Z.jsx)(V,{children:ot()}),(0,Z.jsx)(V,{children:Ue()})]})}),(0,Z.jsx)(Ht,{children:i.flatMap(e=>{let t=Tt(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)(L,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(xt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Z.jsx)(bt,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(vt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(It,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(yt,{value:e.key,children:(0,Z.jsx)(Cn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):null]})}function Sn({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:Gt(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:be(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,ge({build:t.buildVersion??`?`})]}):null,` · `,ve(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?g():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:w()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:ke()});let o=$t(e.targets),s=!e.reachable,c=tn(e),l=e.unreachableInstances??[],u=c===`ok`?`ok`:c===`gateways_unreachable`?`warn`:`error`,d=At(e.checkedAt),f=e.startedAt==null?null:At(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${u}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:c===`ok`?(0,Z.jsx)(j,{size:22}):s||c===`gateways_unreachable`?(0,Z.jsx)(Qt,{size:22}):(0,Z.jsx)(I,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:c===`ok`?st():c===`gateways_unreachable`?Je({count:l.length}):s?We():Ee({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Zt,{size:12,"aria-hidden":!0}),` `,rt({time:d})]}),f?(0,Z.jsx)(`span`,{children:Re({time:f})}):null,a]}),c===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:Ce({names:l.join(`, `)})}):null,s?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:tt()})]})}function Cn({providerKey:e,connections:t,instances:n,manifest:i,compatStatus:a,compatReachable:o,protocol:s}){let c=i?Yt(i,e):null,l=new Map;for(let e of n)l.set(e.name,e.displayName??e.name);let u=[],d=new Set;for(let n of t){if(!n.instanceName||d.has(n.instanceName))continue;d.add(n.instanceName);let t=n.gatewayVersion??null;u.push({instanceName:n.instanceName,displayName:l.get(n.instanceName)??n.instanceName,version:t,state:Xt(t,e,i)})}let f=u.map(e=>e.state),p=f.includes(`beyond`)?`beyond`:f.length>0&&f.every(e=>e===`supported`)?`supported`:null,[m,h]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(It,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),p?(0,Z.jsx)(L,{variant:p===`beyond`?`destructive`:`secondary`,children:Jt(p)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:r()}),(0,Z.jsx)(Tn,{providerName:q(e),support:c,compatStatus:a,compatReachable:o,manifest:i,instanceRows:u}),s?(0,Z.jsx)(wn,{protocol:s}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":m,onClick:()=>h(e=>!e),children:[m?(0,Z.jsx)(O,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Ft,{size:13,"aria-hidden":!0}),qe({count:t.length})]}),m?(0,Z.jsx)(gn,{connections:t,displayByInstance:l}):null]})}function wn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],a=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[dt(),i.length>0?(0,Z.jsx)(L,{variant:`destructive`,children:Se({count:i.length})}):a>0?(0,Z.jsx)(L,{variant:`destructive`,children:Fe()}):(0,Z.jsx)(L,{variant:`secondary`,children:ct()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Ie({version:e.vendoredVersion}),r?` · `+Ke({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a>0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Be({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):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)(Ft,{size:13,"aria-hidden":!0}),Ze({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 Tn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:w()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Qe()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:Pe({provider:a})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:f({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:g()}),e?(0,Z.jsx)(On,{versions:e.validatedVersions}):null]}),i.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):(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:Gt(e.version)}),(0,Z.jsx)(L,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:Jt(e.state)})]},e.instanceName))})]})}function En({instance:e,onClose:t}){return(0,Z.jsx)(jt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(Mt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(Pt,{children:[(0,Z.jsx)(Nt,{children:xe({instance:e.displayName??e.name})}),(0,Z.jsx)(Lt,{children:Ne()})]}),(0,Z.jsx)(Dn,{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)(I,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?le():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,lt()]}):null}function Dn({instance:e,onClose:t}){let n=oe(T.admin.upsertInstanceConfig),r=ee(T.bridge.validateMediaPaths),i=Ct(),o=Bt(e.config?.contentLocale,void 0),[c,f]=(0,G.useState)(()=>mt(e.config??{},o)),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(null),y=c.inboundMediaMode===`shared-fs`,b=c.mediaMode===`shared-fs`,x=y||b;async function S(){g(!0),v(null);try{v(await r({instanceName:e.name,inboundMediaMode:c.inboundMediaMode,mediaMode:c.mediaMode}))}catch(e){i.error(Ve(),e)}finally{g(!1)}}async function ae(){m(!0);try{let r=e.config??{};await n({instanceId:e._id,config:gt(c,r,o)}),t()}catch(e){i.error(He(),e)}finally{m(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:Ge(),help:Te()}),(0,Z.jsxs)(M,{value:c.mediaMode,onValueChange:e=>f({...c,mediaMode:e}),children:[(0,Z.jsx)(N,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(z,{})}),(0,Z.jsx)(R,{children:_t.map(e=>(0,Z.jsx)(B,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:Ye(),help:nt()}),(0,Z.jsxs)(M,{value:c.inboundMediaMode,onValueChange:e=>f({...c,inboundMediaMode:e}),children:[(0,Z.jsx)(N,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(z,{})}),(0,Z.jsx)(R,{children:ht.map(e=>(0,Z.jsx)(B,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:je(),help:Le()}),(0,Z.jsx)(P,{type:`number`,min:1,max:4096,className:`w-full`,value:c.mediaMaxMb,onChange:e=>f({...c,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),x&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[y&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:d(),help:ie()}),(0,Z.jsx)(P,{className:`w-full`,spellCheck:!1,value:c.inboundAgentMount,onChange:e=>f({...c,inboundAgentMount:e.target.value})})]}),b&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(k,{label:ne(),help:te()}),(0,Z.jsx)(P,{className:`w-full`,spellCheck:!1,value:c.outboundAgentMount,onChange:e=>f({...c,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(Et,{checked:c.rehydration,onCheckedChange:e=>f({...c,rehydration:e===!0})}),(0,Z.jsx)(k,{label:De(),help:et()})]}),x&&_!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:_.reachable?!_.inbound&&!_.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(I,{"aria-hidden":!0}),ce({reason:_.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:l(),result:_.inbound}),(0,Z.jsx)($,{label:u(),result:_.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:re()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(I,{"aria-hidden":!0}),s()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[x&&(0,Z.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>void S(),disabled:h,children:[h?(0,Z.jsx)(kt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,h?a():ze()]}),(0,Z.jsx)(A,{size:`sm`,onClick:()=>void ae(),disabled:p,children:at()})]})]})})}function On({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(Ot,{children:[(0,Z.jsx)(St,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?me():ue({count:e.length}),(0,Z.jsx)(O,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(zt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:m()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(L,{variant:`secondary`,children:e},e))})]})]})}export{xn as BridgeTab,En as InstanceConfigDialog};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AR as r,Ao as i,Cd as a,Co as o,Do as s,Eo as c,IR as l,Mo as u,Oo as d,RR as f,Ru as p,Td as m,To as h,au as g,cu as _,eu as v,hb as y,hr as b,iu as x,jo as S,ko as C,nu as w,ou as T,ru as E,su as D,t as O,tu as k,vd as A,wo as j,yd as M,zR as N}from"./api-Dv9KEyyu.js";import{t as P}from"./button-D9yXQ2Th.js";import{M as F,N as I,P as L,V as R,_t as z,bt as B,jt as V,rn as H,vt as U,xt as W,yt as G}from"./index-BAyOACwC.js";import{i as K}from"./compatView-5r10IMkT.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=f(O.admin.upsertInstanceConfig),n=N(O.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,q.useState)(r),[o,c]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{a(r),c(`idle`)},[e._id,r]);let l=`__none__`,u=i!==r;async function p(){c(`saving`);try{let n={...e.config??{}};i===``||i===l?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let h=n?.agents??[];return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:C()}),(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:d()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsxs)(z,{value:i===``?l:i,onValueChange:e=>a(e===l?``:e),children:[(0,X.jsx)(B,{className:`oc-cdefaults__select`,"aria-label":C(),children:(0,X.jsx)(W,{placeholder:s()})}),(0,X.jsxs)(U,{children:[(0,X.jsx)(G,{value:l,children:s()}),h.map(e=>(0,X.jsx)(G,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,X.jsx)(P,{size:`sm`,disabled:!u||o===`saving`,onClick:()=>void p(),children:o===`saving`?m():w()})]}),o===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:k()}):null,o===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:v()}):null]})}function Q({instance:e}){let t=f(O.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[a,o]=(0,q.useState)(n),[s,l]=(0,q.useState)(r===null?``:String(r)),[u,d]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{o(n),l(r===null?``:String(r)),d(`idle`)},[e._id,n,r]);let p=s.trim(),g=p===``?null:/^\d+$/.test(p)?Number.parseInt(p,10):NaN,_=!a||g===null||Number.isInteger(g)&&g>=4e3&&g<=6e4,y=a!==n||(g??null)!==r;async function b(){d(`saving`);try{let n={...e.config??{}};n.curationEnabled=a,!a||g===null||Number.isNaN(g)?delete n.curationBudgetChars:n.curationBudgetChars=g,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,X.jsx)(L,{checked:a,onCheckedChange:e=>o(e===!0),"aria-label":i()}),(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:i()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>l(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":c(),disabled:!a}),(0,X.jsx)(P,{size:`sm`,disabled:!y||!_||u===`saving`,onClick:()=>void b(),children:u===`saving`?m():w()})]}),_?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:h()}),u===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:k()}):null,u===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:v()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:j()})]})}function $({instance:e}){let t=f(O.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,q.useState)(n===null?``:String(n)),[a,s]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{i(n===null?``:String(n)),s(`idle`)},[e._id,n]);let c=r.trim(),l=c===``?null:/^\d+$/.test(c)?Number.parseInt(c,10):NaN,d=l===null||Number.isInteger(l)&&l>=1e3&&l<=2e5,p=(l??null)!==n;async function h(){s(`saving`);try{let n={...e.config??{}};l===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=l,await t({instanceId:e._id,config:n}),s(`done`)}catch{s(`error`)}}return(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:u()}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,X.jsx)(V,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!d}),(0,X.jsx)(P,{size:`sm`,disabled:!p||!d||a===`saving`,onClick:()=>void h(),children:a===`saving`?m():w()})]}),d?null:(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:o()}),a===`done`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:k()}):null,a===`error`?(0,X.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:v()}):null,(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:S()})]})}function ee(){let e=l(O.agentFiles.getChatDefaults),[t,n]=(0,q.useState)({status:`loading`}),i=N(O.admin.listInstances,{}),[o,s]=(0,q.useState)(null);(0,q.useEffect)(()=>{!i||i.length===0||(!o||!i.some(e=>e.name===o))&&s(i[0].name)},[i,o]);let c=(i?.length??0)>1,u=i!==void 0&&i.length===0,d=N(O.compat.forInstance,o?{instanceName:o}:`skip`),f=o?R(d,`configDefaults`):`loading`,m=f===`loading`?null:f.blocked,h=(0,q.useMemo)(()=>c&&o?{instanceName:o}:{},[c,o]),v=(0,q.useRef)(0),S=(0,q.useCallback)(async()=>{let t=++v.current;n({status:`loading`});try{let r=Y(await e(h));if(v.current!==t)return;n({status:`done`,current:r})}catch{if(v.current!==t)return;n({status:`error`})}},[e,h]);(0,q.useEffect)(()=>{m===!1&&(c&&!o||S())},[S,m,c,o]);let C=t.status===`done`?t.current:null,w=(0,q.useMemo)(()=>J.map(e=>({id:e,label:I(e)})),[]),k=(0,q.useMemo)(()=>[{id:`fast`,label:M()},{id:`standard`,label:A()}],[]);return(0,X.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:_()}),c&&o?(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:p()}),(0,X.jsxs)(z,{value:o,onValueChange:e=>s(e),children:[(0,X.jsx)(B,{size:`sm`,"aria-label":p(),children:(0,X.jsx)(W,{})}),(0,X.jsx)(U,{children:(i??[]).map(e=>(0,X.jsx)(G,{value:e.name,children:e.name},e.name))})]})]}):null,u?(0,X.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:y()}):f===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):f.blocked?(0,X.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,X.jsx)(H,{size:14,"aria-hidden":!0}),` `,K(f.gatewayVersion,f.provider)]}):t.status===`loading`?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):t.status===`error`?(0,X.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[E(),` `,(0,X.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:a()})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:D()}),(0,X.jsx)(F,{options:w,value:C?.thinkingDefault??null,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:T()})]}),(0,X.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,X.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()}),(0,X.jsx)(F,{options:k,value:C===null||C.fastModeDefault===null?null:C.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0}),(0,X.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]}),(0,X.jsx)(`p`,{className:`oc-cdefaults__note`,children:b()})]}),(()=>{let e=i?.find(e=>e.name===(o??i[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{Am as r,Fm as i,Mm as a,Nm as o,Pm as s,jm as c,km as l}from"./api-CbVyaw6f.js";import{r as u}from"./dist-mHgdDBUV.js";import{t as d}from"./chevron-up-D9LbKOmX.js";import{t as f}from"./chevrons-up-down-huJFCk51.js";import{t as p}from"./button-B_rxV4Hv.js";import{En as m,It as h,Lt as g,Mt as _,Nt as v,P as y,Pt as b,in as x,ln as S}from"./index-EISUCtE9.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-C2BiIaq6.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=s(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(x,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(S,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):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":a(),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":l({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)??[],i=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":c(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(v,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(h,{}):null,(0,M.jsx)(b,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),i&&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{Am as r,Fm as i,Im as a,Mm as o,Nm as s,Pm as c,jm as l}from"./api-Dv9KEyyu.js";import{r as u}from"./dist-BaKVbU2X.js";import{t as d}from"./chevron-up-NPxwzzmO.js";import{t as f}from"./chevrons-up-down-DT1RCPP_.js";import{t as p}from"./button-D9yXQ2Th.js";import{En as m,It as h,Lt as g,Mt as _,Nt as v,P as y,Pt as b,in as x,ln as S}from"./index-BAyOACwC.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-DCOgab8-.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=a(),bulkActions:F,emptyHint:I=i(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(p,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(x,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(p,{size:`sm`,onClick:N,children:[(0,M.jsx)(S,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:c()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(y,{"aria-label":s(),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":r({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":o(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`icon-sm`,"aria-label":l(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(m,{})})}),(0,M.jsx)(v,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(h,{}):null,(0,M.jsx)(b,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{ut as t}from"./index-EISUCtE9.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{ut as t}from"./index-BAyOACwC.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{$E as r,AD as i,BE as a,CD as o,DD as s,ED as c,FD as l,FE as u,GE as d,HE as f,ID as p,IE as m,Ia as h,JE as g,KE as _,LE as ee,MD as te,ND as ne,OD as re,PD as ie,PE as ae,QE as v,RE as y,RR as b,Ra as x,SD as S,TD as C,UE as w,VE as T,WE as E,XE as D,YE as O,ZE as k,_D as A,aD as j,bD as M,cD as N,dD as P,eD as F,fD as I,gD as L,hD as R,iD as z,jD as B,kD as V,lD as oe,mD as H,nD as U,oD as W,pD as G,qE as K,rD as q,sD as se,t as J,tD as ce,uD as le,vD as ue,wD as de,xD as fe,yD as pe,zE as me,zR as he}from"./api-Dv9KEyyu.js";import{t as ge}from"./button-D9yXQ2Th.js";import{Z as _e,ct as Y}from"./index-BAyOACwC.js";import{t as ve}from"./DataTableShell-CqU0-4M7.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>p(),incorrect:()=>l(),incoherence:()=>ie(),formatting:()=>ne(),latency:()=>te(),api_error:()=>B(),other:()=>i()},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:re()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:s()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:V()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,i=b(J.feedback.respondToFeedback),[s,l]=(0,X.useState)(e.thread),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!1);async function m(){let t=u.trim();if(!(!t||f)){p(!0);try{await i({feedbackId:e._id,text:t}),l(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),d(``)}finally{p(!1)}}}let h=[];try{h=r.contextJson?JSON.parse(r.contextJson):[]}catch{h=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:r.displayedMatchesStored,sourceWasOpen:r.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,r.messageRole,r.isRegeneration?` · ${c()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:F(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:C()}),(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:a()}),(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:de()}),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`?o():e.authorRole===`agent`?e.authorLabel??x():S()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:fe()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:M(),value:u,maxLength:2e3,rows:3,onChange:e=>d(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 m(),disabled:!u.trim()||f,children:f?pe():ue()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:A()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||L()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:R()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||L()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:H()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,h.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:G({count:r.contextCount??h.length,truncated:r.contextTruncated?I():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:h.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,r.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:P()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[r.outboxText??``,r.outboxStatus?`\n[status: ${r.outboxStatus}]`:``]})]}):null,r.clientInfo?.extensionsDetected&&r.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:le()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:r.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:oe()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?N({theme:r.clientInfo.theme}):null,r.runId?`run ${r.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,r.clientInfo?.plugins&&r.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[se(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,W()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=he(J.feedback.listForAdmin,{}),t=b(J.feedback.readSnapshot),n=b(J.feedback.deleteFeedback),i=_e(),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)({});async function l(e){if(a===e._id){o(null);return}if(!s[e._id]){let n=await t({feedbackId:e._id});c(t=>({...t,[e._id]:n}))}o(e._id)}async function p(e){await i({title:m(),description:u(),confirmLabel:ae(),destructive:!0})&&(await n({feedbackId:e._id}),a===e._id&&o(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[j(),` `,(0,Z.jsx)(`strong`,{children:z()}),` `,q()]}),(0,Z.jsx)(ve,{title:U(),rows:e,emptyHint:ce(),isExpanded:e=>a===e._id&&!!s[e._id],renderExpanded:e=>s[e._id]?(0,Z.jsx)(be,{data:s[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:r(),cell:e=>Y(e.at),sort:e=>e.at},{header:v(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:k(),cell:e=>e.messageRole===`user`?D():O(),sort:e=>e.messageRole},{header:g(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${K({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:_(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:d(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:E(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:w()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:f()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:h()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:T()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?me():y(),onSelect:()=>void l(e)},{label:ee(),onSelect:()=>void p(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,RR as n}from"./api-CbVyaw6f.js";import{B as r,L as i,R as a,z as o}from"./index-EISUCtE9.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,KR as n}from"./api-Dv9KEyyu.js";import{B as r,L as i,R as a,z as o}from"./index-BAyOACwC.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{AL as r,AR as ee,BL as i,CL as a,DL as o,EL as s,FL as c,GL as te,HL as ne,Ha as l,IA as u,IL as d,JL as f,KL as p,LL as m,ML as re,MR as ie,NL as ae,OL as oe,PL as h,RL as g,RR as se,SL as ce,TL as le,UL as ue,VL as de,Va as fe,WL as pe,XL as me,YL as he,ZL as ge,_L as _e,bL as ve,gL as ye,jL as be,kL as xe,qL as _,t as v,vL as y,wL as b,xL as x,yL as S,zL as C,zR as w}from"./api-Dv9KEyyu.js";import{t as T}from"./button-D9yXQ2Th.js";import{$ as E,Dn as D,Dt as O,En as k,Lt as A,Mt as j,Nt as M,P as Se,Pt as N,_t as P,at as Ce,bt as F,cn as we,et as Te,in as Ee,it as De,nt as Oe,ot as ke,rt as Ae,tt as je,ut as I,vt as L,xt as R,yt as z}from"./index-BAyOACwC.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-DCOgab8-.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return i();case`audio`:return C();case`video`:return g();case`pdf`:return m();case`document`:return d();case`archive`:return c();default:return h()}}function q(){let[e,t]=(0,U.useState)(G),[n,i]=(0,U.useState)(G),[c,d]=(0,U.useState)(G),[m,h]=(0,U.useState)(G),[g,C]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=se(v.files.softDelete),Y=O();function Ie(){t(G),i(G),d(G),h(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(a())}catch(e){Y.error(ce(),e)}}let X=w(v.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:c===G?void 0:c,category:m===G?void 0:m,includeAutoGenerated:g||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(ie(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ee()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||c!==G||m!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ge()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(P,{value:e,onValueChange:t,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":me(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:he()}),(0,W.jsx)(z,{value:`inbound`,children:f()}),(0,W.jsx)(z,{value:`outbound`,children:_()})]})]}),(0,W.jsxs)(P,{value:n,onValueChange:i,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":p(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:te()}),Q.chats.map(e=>(0,W.jsx)(z,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(P,{value:c,onValueChange:d,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":pe(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:ue()}),Q.instances.map(e=>(0,W.jsx)(z,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(P,{value:m,onValueChange:h,children:[(0,W.jsx)(F,{size:`sm`,"aria-label":ne(),children:(0,W.jsx)(R,{})}),(0,W.jsxs)(L,{children:[(0,W.jsx)(z,{value:G,children:de()}),Q.categories.map(e=>(0,W.jsx)(z,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(Se,{checked:g,onCheckedChange:e=>C(e===!0),"aria-label":l()}),(0,W.jsx)(`span`,{children:l()})]}),$?(0,W.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(we,{size:14,"aria-hidden":!0}),s()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?_e():y()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:ae()}),(0,W.jsx)(B,{children:re()}),(0,W.jsx)(B,{children:be()}),(0,W.jsx)(B,{children:r()}),(0,W.jsx)(B,{children:xe()}),(0,W.jsx)(B,{className:`text-right`,children:oe()})]})}),(0,W.jsx)(Ne,{children:Z.map(e=>(0,W.jsxs)(V,{children:[(0,W.jsxs)(H,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,W.jsx)(I,{variant:`outline`,style:{marginLeft:6},children:fe()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(I,{variant:`secondary`,children:e.direction===`inbound`?f():_()})}),(0,W.jsx)(H,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,W.jsx)(H,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,W.jsx)(H,{className:`text-right`,children:(0,W.jsxs)(j,{children:[(0,W.jsx)(A,{asChild:!0,children:(0,W.jsx)(T,{variant:`ghost`,size:`icon`,"aria-label":le(),children:(0,W.jsx)(k,{size:16})})}),(0,W.jsxs)(M,{align:`end`,children:[e.url?(0,W.jsx)(N,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(D,{size:14}),o()]})}):(0,W.jsxs)(N,{disabled:!0,children:[(0,W.jsx)(D,{size:14}),S()]}),(0,W.jsxs)(N,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Ee,{size:14}),b()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:ye({cap:Be})}):null]}),(0,W.jsx)(E,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(Oe,{children:[(0,W.jsxs)(Ce,{children:[(0,W.jsx)(ke,{children:x()}),(0,W.jsx)(Ae,{children:ve()})]}),(0,W.jsxs)(De,{children:[(0,W.jsx)(je,{children:u()}),(0,W.jsx)(Te,{onClick:()=>void Le(),children:b()})]})]})})]})}export{q as FilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Im as r,Lm as i}from"./api-CbVyaw6f.js";import{t as a}from"./button-B_rxV4Hv.js";import{cn as o,jt as s,sn as c}from"./index-EISUCtE9.js";import{t as l}from"./TimeRangePicker-CVMLr89E.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=i(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(c,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),r()]})]})}export{p as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Lm as r,Rm as i}from"./api-Dv9KEyyu.js";import{t as a}from"./button-D9yXQ2Th.js";import{cn as o,jt as s,sn as c}from"./index-BAyOACwC.js";import{t as l}from"./TimeRangePicker-I8KZZSiJ.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=i(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(c,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(s,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(o,{}),r()]})]})}export{p as t};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,Af as i,Bd as a,Bf as o,Cf as s,D as c,Df as l,Ef as u,Ff as d,Gd as f,Gf as p,Hd as m,Hf as h,If as g,Jd as _,Kd as v,Kf as y,Ld as b,Lf as x,Mf as ee,Nf as S,Of as C,Pf as te,Qd as w,RR as T,Rd as E,Rf as D,Sf as O,Tf as ne,Ud as k,Uf as re,Vd as A,Vf as j,Wd as M,Wf as ie,Xd as N,Yd as P,Zd as F,_f as I,af as ae,bf as oe,cf as se,df as L,ef as R,ff as ce,gf as le,hf as ue,if as de,jf as fe,kf as pe,lf as me,mf as he,nf as ge,of as _e,pf as ve,qd as ye,rf as be,sf as xe,t as z,tf as Se,uf as Ce,vf as we,wf as Te,xf as Ee,yf as De,zR as B,zd as Oe,zf as ke}from"./api-Dv9KEyyu.js";import{t as Ae}from"./x-C58t2mLG.js";import{i as V,n as H,r as je,t as Me}from"./tabs-Dv-cJfvQ.js";import{t as U}from"./button-D9yXQ2Th.js";import{Dt as W,Mn as Ne,P as G,Z as Pe,_ as Fe,_t as Ie,an as K,bt as Le,dt as Re,ft as ze,gt as Be,ht as Ve,jn as He,jt as q,on as J,pt as Ue,ut as Y,vt as We,wt as Ge,xt as Ke,yt as qe}from"./index-BAyOACwC.js";import{t as Je}from"./FilterBar-B4i5RQ5h.js";import{t as Ye}from"./DataTableShell-CqU0-4M7.js";import{t as X}from"./DetailChips-DrJgW8-P.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 ve();case`user`:return ce();case`pending`:return L();default:return e}}function nt(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function rt(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}var $=n(),it={name:``,description:``};function at(){let e=B(z.groups.listGroups,{}),t=B(z.me.getMe,{host:Ge})?.role===`admin`,n=T(z.groups.createGroup),r=T(z.groups.updateGroup),s=T(z.groups.deleteGroup),c=Pe(),f=W(),[m,_]=(0,Q.useState)(!1),[v,b]=(0,Q.useState)(null),[w,E]=(0,Q.useState)(it),[O,k]=(0,Q.useState)(null),[A,M]=(0,Q.useState)(``),N=(0,Q.useMemo)(()=>{if(!e)return e;let t=A.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,A]);function P(){b(null),E(it),_(!0)}function F(e){b(e),E({name:e.name,description:e.description??``}),_(!0)}async function I(){try{v?await r({groupId:v._id,name:w.name,description:w.description}):await n({name:w.name,description:w.description||void 0}),E(it),b(null),_(!1)}catch(e){f.error(a(),e)}}async function ae(e){if(await c({title:l({name:e.name}),description:u(),confirmWord:e.name,confirmLabel:ne(),cancelLabel:S(),destructive:!0}))try{await s({groupId:e._id})}catch(e){f.error(Oe(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:p()}),(0,$.jsx)(Je,{q:A,onQChange:M,onReset:()=>M(``),canReset:A!==``,searchPlaceholder:D()}),(0,$.jsx)(Ye,{title:y(),rows:N,addLabel:ie(),onAdd:t?P:void 0,emptyHint:re(),columns:[{header:h(),cell:e=>e.name,sort:e=>e.name},{header:j(),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:o(),cell:e=>(0,$.jsx)(X,{icon:(0,$.jsx)(J,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:ke(),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)(K,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:x(),onSelect:()=>k({groupId:e._id,name:e.name})},...t?[{label:g(),onSelect:()=>F(e)},{label:d(),variant:`destructive`,onSelect:()=>void ae(e)}]:[]]}),(0,$.jsx)(Fe,{open:m,onOpenChange:_,title:v?fe():ee(),description:i(),canSubmit:!!w.name.trim(),onSubmit:I,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:pe()}),(0,$.jsx)(q,{value:w.name,onChange:e=>E({...w,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:C()}),(0,$.jsx)(q,{value:w.description,onChange:e=>E({...w,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:O?.groupId??null,groupName:O?.name??``,open:O!==null,onOpenChange:e=>{e||k(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)(Ne,{size:14,"aria-hidden":!0}),le()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":he({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[ue(),(0,$.jsx)(He,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:i}){let a=B(z.groups.getGroup,n&&e?{groupId:e}:`skip`),o=B(z.groups.listAssignableInstances,n?{}:`skip`),c=B(z.groups.listAssignableUsers,n?{}:`skip`),l=T(z.groups.addMember),u=T(z.groups.removeMember),d=T(z.groups.bulkSetMembers),p=T(z.groups.setGroupManager),h=W(),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(`members`),[ee,S]=(0,Q.useState)(1),[C,te]=(0,Q.useState)(new Set),w=(0,Q.useRef)(null),D=(0,Q.useMemo)(()=>new Set((a?.members??[]).map(e=>e.userId)),[a]),ne=(0,Q.useMemo)(()=>new Set((a?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[a]),re=a?.viewerIsAdmin===!0,A=(0,Q.useMemo)(()=>new Set((a?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[a]);(0,Q.useEffect)(()=>{_(``),y(``),x(`members`),S(1),w.current=null},[n,e]),(0,Q.useEffect)(()=>{S(1)},[g]),(0,Q.useEffect)(()=>{n&&a&&e&&w.current!==e&&(w.current=e,te(new Set((a.members??[]).map(e=>e.userId))))},[n,a,e]);let j=(0,Q.useMemo)(()=>c?Qe(c,g,C):[],[c,g,C]);async function ie(t,n){if(e)try{n?await u({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){h.error(E(),e)}}async function N(t,n){if(e)try{await p({groupId:e,userId:t,manager:!n})}catch(e){h.error(m(),e)}}let P=nt(j,e=>D.has(e.userId)),F=j.filter(e=>D.has(e.userId)).length,L=rt(j,ee,ot);async function R(){if(!e||j.length===0)return;let t=j.map(e=>e.userId);try{await d({groupId:e,userIds:t,member:P!==`all`})}catch(e){h.error(E(),e)}}return(0,$.jsx)(Re,{open:n,onOpenChange:i,children:(0,$.jsxs)(ze,{className:`oc-access`,children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:Te({name:t})}),(0,$.jsx)(Ue,{children:s()})]}),(0,$.jsxs)(Me,{value:b,onValueChange:x,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}),O(),a?(0,$.jsx)(Y,{variant:`secondary`,className:`oc-access__tabcount`,children:D.size}):null]}),(0,$.jsxs)(V,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),oe(),a?(0,$.jsx)(Y,{variant:`secondary`,className:`oc-access__tabcount`,children:A.size}):null]}),(0,$.jsxs)(V,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Xe,{size:13,"aria-hidden":!0}),r(),a?(0,$.jsx)(Y,{variant:`secondary`,className:`oc-access__tabcount`,children:a.chartCount}):null]})]}),(0,$.jsx)(H,{value:`members`,children:c===void 0||a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:_e()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:g,onChange:e=>_(e.target.value),placeholder:Ee(),className:`oc-access__search`}),j.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:we()}):(0,$.jsxs)($.Fragment,{children:[j.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(G,{checked:P===`all`?!0:P===`some`?`indeterminate`:!1,onCheckedChange:()=>void R(),"aria-label":I()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:I()}),(0,$.jsxs)(Y,{variant:`outline`,className:`oc-access__count`,children:[F,` / `,j.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:L.pageItems.map(e=>{let t=D.has(e.userId),n=et(e),r=ne.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:t,onCheckedChange:()=>void ie(e.userId,t),"aria-label":Ce({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)(Y,{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${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?k():M(),title:r?k():M(),onClick:()=>void N(e.userId,r),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):t&&r?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":f(),title:f(),children:(0,$.jsx)(Z,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:L.page,pageCount:L.pageCount,onPage:S})]})]})}),(0,$.jsx)(H,{value:`agents`,children:o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ae()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{value:v,onChange:e=>y(e.target.value),placeholder:De(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:A,query:v},`${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=B(z.groups.listAssignableAgents,{instanceName:t}),o=T(z.groups.assignAgentToGroup),s=T(z.groups.removeAgentFromGroup),c=T(z.groups.bulkSetGroupAgents),l=W(),[u,d]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{d(1)},[i]),!e)return null;let f=$e(a?.agents??[],i),p=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&f.length===0)return null;let m=f.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),h=nt(m,e=>r.has(`${t}/${e.agentId}`)),g=rt(f,u,ot);async function _(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){l.error(b(),e)}}async function v(){if(m.length===0)return;let n=m.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:h!==`all`})}catch(e){l.error(b(),e)}}return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(Y,{variant:`outline`,className:`oc-access__kind`,children:n}),p?(0,$.jsx)(Y,{variant:`outline`,className:`oc-access__stale`,children:ge()}):null]}),a===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:xe()}):f.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:p?be():de()}):(0,$.jsxs)($.Fragment,{children:[m.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(G,{checked:h===`all`?!0:h===`some`?`indeterminate`:!1,onCheckedChange:()=>void v(),"aria-label":I()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:I()})]}):null,g.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)(G,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void _(e.agentId,i),"aria-label":me({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":R(),title:R(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(Y,{variant:`outline`,className:`oc-access__gone`,children:Se()}):null]},e.agentId)}),(0,$.jsx)(st,{page:g.page,pageCount:g.pageCount,onPage:d})]})]})}function ut({groupId:e}){let t=B(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=T(z.charts.assignChartToGroup),r=T(z.charts.removeChartFromGroup),i=T(z.charts.setGroupDefaultChart),a=T(z.charts.addChartToGroupPool),o=T(z.charts.removeChartFromGroupPool),s=W();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:se()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(A(),e)}}async function f(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(A(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(A(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(A(),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)(G,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":_({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":ye(),title:ye(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void f(e.chartKey),children:v()}):null,u?(0,$.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":P({name:e.name}),title:P({name:e.name}),onClick:()=>void m(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,$.jsxs)(Ie,{value:``,onValueChange:e=>void p(e),children:[(0,$.jsx)(Le,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Ke,{placeholder:N()})}),(0,$.jsx)(We,{children:l.map(e=>(0,$.jsx)(qe,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:F()}):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{$T as r,$w as i,AT as a,Aw as o,BT as s,CT as c,Cw as l,DT as u,Dw as d,ET as f,Ew as p,FT as m,Fw as h,GT as g,Gw as _,HT as v,Hw as y,IR as b,IT as x,Iw as S,JT as C,Jo as w,Jw as T,KT as E,Kw as ee,LT as te,Lj as ne,Lw as re,MT as ie,Mw as ae,NT as oe,Nw as se,OT as ce,Ow as le,PT as ue,Pw as de,QT as fe,Qw as pe,RR as D,RT as me,Rj as he,Rw as ge,ST as O,Sw as _e,TT as ve,Tw as ye,UT as be,Uw as xe,VT as Se,Vw as k,WT as Ce,Ww as A,XT as we,Xo as Te,Xw as Ee,YT as De,Yo as Oe,Yw as ke,ZT as Ae,Zw as je,_T as Me,_w as Ne,aE as Pe,aT as Fe,ab as Ie,bT as Le,br as Re,bw as ze,cT as Be,dT as Ve,eE as He,eT as Ue,fT as j,gT as M,hT as We,iE as Ge,iT as Ke,jT as qe,jw as Je,kT as Ye,kw as Xe,lT as Ze,mT as Qe,nE as $e,nT as et,oE as tt,oT as nt,ob as rt,pT as it,qT as at,qo as ot,qw as st,rE as ct,rT as lt,sT as ut,t as N,tE as dt,tT as ft,uT as pt,vT as mt,vr as ht,vw as P,wT as gt,ww as _t,xT as vt,xw as yt,yT as bt,yr as xt,yw as St,zR as F,zT as Ct,zw as wt}from"./api-Dv9KEyyu.js";import{a as Tt,c as Et}from"./FieldLabel-JybJ9RRM.js";import{t as I}from"./button-D9yXQ2Th.js";import{Bt as Dt,Dt as L,P as R,Rt as Ot,Z as kt,_ as At,_t as z,bt as B,dt as V,ft as H,gt as U,ht as jt,jt as W,pt as Mt,ut as G,vt as K,xt as q,yt as J,zt as Nt}from"./index-BAyOACwC.js";import{t as Pt}from"./DataTableShell-CqU0-4M7.js";import{InstanceConfigDialog as Ft}from"./BridgeTab-B7X1qwdk.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],It=new Set(X),Lt=`conversational`;function Rt(e){let t=new Set((e??[]).filter(e=>It.has(e)));return t.size===0?[Lt]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,streamTransport:Tt},zt={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Bt(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,transport:e.transport??`ws`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``,streamTransport:e.streamTransport??`reactive`}}function Vt(){let e=F(N.admin.listInstances,{}),t=F(N.agents.listAllInstanceAgents,{}),n=D(N.admin.upsertInstance),i=D(N.admin.deleteInstance),o=L(),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(Q),[f,p]=(0,Y.useState)(null),[h,_]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[S,w]=(0,Y.useState)(null);async function T(){try{await n({instanceId:S??void 0,name:u.name,gatewayUrl:u.gatewayUrl,bridgeUrl:u.bridgeUrl||void 0,displayName:u.displayName||void 0,kind:u.kind,transport:u.kind===`hermes`?u.transport:void 0,gatewayVersion:u.gatewayVersion||void 0,gatewayHttpUrl:u.gatewayHttpUrl||void 0,streamTransport:u.streamTransport}),d(Q),w(null),l(!1)}catch(e){o.error(Ge(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[ct(),(0,Z.jsx)(`strong`,{children:$e()}),dt()]}),(0,Z.jsx)(Pt,{title:He(),rows:e,addLabel:r(),onAdd:()=>{w(null),d(Q),l(!0)},emptyHint:fe(),columns:[{header:Ae(),cell:e=>e.name,sort:e=>e.name},{header:we(),cell:e=>(0,Z.jsx)(G,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:De(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:C(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:tt(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,Z.jsxs)(G,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?P():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Ce(),onSelect:()=>{w(e._id),d(Bt(e)),l(!0)}},{label:Pe(),onSelect:()=>p(e.name)},{label:Ye(),onSelect:()=>b(e)},{label:at(),onSelect:()=>_(e)},{label:E(),variant:`destructive`,onSelect:()=>void i({instanceId:e._id})}],bulkActions:[{label:E(),variant:`destructive`,onSelect:e=>e.forEach(e=>void i({instanceId:e}))}]}),(0,Z.jsx)(At,{open:c,onOpenChange:l,title:S?be():g(),description:Se(),canSubmit:!!(u.name&&u.gatewayUrl),onSubmit:T,submitLabel:s(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Ct(),children:[(0,Z.jsx)(W,{value:u.name,disabled:S!==null,onChange:e=>d({...u,name:e.target.value})}),S?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v()}):null]}),(0,Z.jsx)($,{label:me(),children:(0,Z.jsxs)(z,{value:u.kind,onValueChange:e=>d({...u,kind:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(q,{})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(J,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(J,{value:`hermes`,children:`Hermes`})]})]})}),u.kind===`hermes`?(0,Z.jsx)($,{label:Re(),children:(0,Z.jsxs)(z,{value:u.transport,onValueChange:e=>d({...u,transport:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-56`,children:(0,Z.jsx)(q,{})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(J,{value:`ws`,children:xt()}),(0,Z.jsx)(J,{value:`rest`,children:ht()})]})]})}):null,(0,Z.jsx)($,{label:te(),children:(0,Z.jsx)(W,{value:u.gatewayUrl,onChange:e=>d({...u,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:x(),children:(0,Z.jsx)(W,{value:u.bridgeUrl,placeholder:m(),onChange:e=>d({...u,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:ue(),children:(0,Z.jsx)(W,{value:u.displayName,onChange:e=>d({...u,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:rt(),children:[(0,Z.jsxs)(z,{value:u.streamTransport,onValueChange:e=>d({...u,streamTransport:e}),children:[(0,Z.jsx)(B,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(q,{})}),(0,Z.jsx)(K,{children:Et.map(e=>(0,Z.jsx)(J,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Ie()})]}),(0,Z.jsx)($,{label:oe(),children:(0,Z.jsx)(W,{value:u.gatewayVersion,placeholder:ie(),onChange:e=>d({...u,gatewayVersion:e.target.value})})}),(0,Z.jsx)($,{label:qe(),children:(0,Z.jsx)(W,{value:u.gatewayHttpUrl,placeholder:a(),onChange:e=>d({...u,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Zt,{instanceName:f,open:f!==null,onOpenChange:e=>{e||p(null)}}),h?(0,Z.jsx)(Ft,{instance:h,onClose:()=>_(null)},h._id):null,y?(0,Z.jsx)(Ht,{instance:y,onClose:()=>b(null)},y._id):null]})}function Ht({instance:e,onClose:t}){let n=F(N.instanceSecrets.listInstanceSecretStatus,{}),r=zt[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(V,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(H,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(jt,{children:[(0,Z.jsx)(U,{children:ce({instance:e.displayName??e.name})}),(0,Z.jsx)(Mt,{children:u()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(Gt,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(Wt,{instance:e})}),(0,Z.jsx)(Ut,{instance:e})]})})}function Ut({instance:e}){let t=b(N.instanceSync.forceInstanceSync),n=L(),[r,a]=(0,Y.useState)(!1);async function o(){if(!r){a(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(ut());break;case`no_agents`:n.success(Fe());break;case`no_bridge_url`:n.error(Ke());break;case`deploy_misconfigured`:n.error(lt());break;case`unauthorized`:n.error(ft());break;case`not_served`:n.error(Ue());break;default:n.error(et());break}}catch(e){n.error(nt(),e)}finally{a(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:i()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void o(),disabled:r,children:r?Be():Ze()})})]})}function Wt({instance:e}){let t=F(N.bridgeAuth.listBridgeAuthStatus,{}),n=b(N.bridgeAuth.mintBridgeSecret),r=D(N.bridgeAuth.revokeBridgeSecret),i=L(),[a,o]=(0,Y.useState)(!1),[s,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),p=f!==void 0;async function m(){if(!a){o(!0);try{l((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(ee(),e)}finally{o(!1)}}}async function h(){if(!a){o(!0);try{await r({instanceId:e._id}),l(null),i.success(st())}catch(e){i.error(ee(),e)}finally{o(!1)}}}async function g(){if(s)try{await navigator.clipboard.writeText(s),d(!0)}catch{}}return(0,Z.jsxs)($,{label:pe(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:je()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(G,{variant:p?`outline`:`secondary`,children:p?`${c()} · ${f.prefix}…${f.lastFour}`:O()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void m(),disabled:a,children:p?ke():Ee()}),p?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void h(),disabled:a,children:T()}):null]})]}),s?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:_()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void g(),children:u?he():ne()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:A()})]}):null]})}function Gt({instanceId:e,field:t,updatedAt:n}){let r=b(N.instanceSecrets.setInstanceSecret),i=D(N.instanceSecrets.clearInstanceSecret),a=b(N.deviceIdentity.generateDeviceIdentity),o=L(),[s,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),_=n!==null,v=t===`deviceIdentity`,y=t===`token`?f():t===`deviceIdentity`?ve():gt();async function x(){if(!(!s.trim()||u)){d(!0);try{await r({instanceId:e,field:t,plaintext:s}),l(``),m(null),g(!1),o.success(Me())}catch(e){o.error(M(),e)}finally{d(!1)}}}async function S(){if(!u){d(!0);try{await i({instanceId:e,field:t}),m(null),g(!1),o.success(We())}catch(e){o.error(M(),e)}finally{d(!1)}}}async function C(){if(!u){d(!0);try{m(await a({instanceId:e})),g(!1),o.success(j())}catch(e){o.error(pt(),e)}finally{d(!1)}}}let w=p?`openclaw devices approve ${p.id}`:``;async function T(){if(w)try{await navigator.clipboard.writeText(w),g(!0)}catch{}}return(0,Z.jsxs)($,{label:y,children:[v?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:it()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(G,{variant:_?`outline`:`secondary`,children:_?c():O()}),(0,Z.jsx)(W,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:_?Le():vt(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void x(),disabled:u||s.trim().length===0,children:bt()}),v?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void C(),disabled:u,children:Qe()}):null,_?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void S(),disabled:u,children:mt()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:j()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ve()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:w}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void T(),children:h?he():ne()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),g(!1)},children:A()})]}):null]})}var Kt={conversational:se,documentary:Je,summarizer:Te,curator:w},qt={conversational:ae,documentary:o,summarizer:Oe,curator:ot},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:re()}),t.map(e=>(0,Z.jsx)(G,{variant:`secondary`,className:`oc-agenttype__chip`,title:Yt(e),children:Jt(e)},e)),(0,Z.jsxs)(Ot,{children:[(0,Z.jsx)(Dt,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:S()})}),(0,Z.jsxs)(Nt,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:h()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:de()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(R,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Jt(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Yt(r)})]})]},r)})})]})]})]})}function Zt({instanceName:e,open:t,onOpenChange:n}){let r=F(N.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=D(N.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=D(N.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=D(N.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=Rt(r);e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=D(N.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(N.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(N.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),c=D(N.agents.removeInstanceAgent),u=kt(),f=L();async function m(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){f.error(k(),e)}}async function h(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){f.error(k(),e)}}async function g(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){f.error(k(),e)}}async function _(t,n){if(e&&await u({title:d({name:n}),description:p(),confirmLabel:ye(),destructive:!0}))try{await c({instanceName:e,agentId:t}),f.success(_t())}catch(e){f.error(k(),e)}}return(0,Z.jsx)(V,{open:t,onOpenChange:n,children:(0,Z.jsxs)(H,{className:`oc-access`,children:[(0,Z.jsxs)(jt,{children:[(0,Z.jsx)(U,{children:xe({name:e??``})}),(0,Z.jsx)(Mt,{children:y()})]}),r===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:l()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?_e():r.discovery.lastPollOk?yt():ze({error:r.discovery.error??`?`})}),r.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:St()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(t=>{let n=t.presentInLastOk===!1,i=r.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)(R,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void m(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)(G,{variant:`outline`,className:`oc-access__gone`,children:Ne()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void _(t.agentId,a),children:le()})]}):i?(0,Z.jsx)(G,{variant:`default`,children:P()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void h(t.agentId),children:Xe()})]}),t.enabled?(0,Z.jsx)(Xt,{agentId:t.agentId,types:o,onToggle:e=>void g(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(Qt,{value:t.description??``,onSave:async n=>{if(e)try{await s({instanceName:e,agentId:t.agentId,description:n})}catch(e){f.error(k(),e)}}}):null]},t.agentId)})})]})]})})}function Qt({value:e,onSave:t}){let[n,r]=(0,Y.useState)(e);(0,Y.useEffect)(()=>{r(e)},[e]);let i=()=>{n.trim()!==e.trim()&&t(n)};return(0,Z.jsx)(W,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:wt(),"aria-label":ge(),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};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BD as r,GD as i,HD as a,IR as o,JD as s,KD as c,RD as l,RR as u,UD as d,VD as f,WD as p,XD as m,YD as h,ZD as g,_c as _,dc as v,fc as y,gc as b,hc as x,lc as S,mc as C,pc as w,qD as T,t as E,uc as D,zD as O,zR as k}from"./api-Dv9KEyyu.js";import{t as A}from"./button-D9yXQ2Th.js";import{P as j,jt as M,ut as N}from"./index-BAyOACwC.js";var P=t(e(),1),F=n();function I(){let e=k(E.integrations.status.status,{}),t=u(E.admin.setIntegrationConfig),[n,o]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&o(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:g()});let v=n,y=(e,t,n)=>o({...v,[e]:{...v[e],[t]:n}}),S=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[m(),` `,(0,F.jsx)(`strong`,{children:h()}),` `,s()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(N,{variant:`secondary`,children:T()}):(0,F.jsx)(N,{variant:`outline`,children:c()}):(0,F.jsx)(N,{variant:`outline`,children:i()}),note:p(),children:[(0,F.jsx)(R,{label:a(),children:(0,F.jsx)(M,{value:v.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>y(`langfuse`,`host`,e.target.value),onBlur:()=>S(`langfuse`,{host:v.langfuse.host??``})})}),(0,F.jsx)(z,{label:l(),checked:v.langfuse.enabled??!0,onChange:e=>{y(`langfuse`,`enabled`,e),S(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(N,{variant:`secondary`,children:T()}):(0,F.jsx)(N,{variant:`outline`,children:c()}):(0,F.jsx)(N,{variant:`outline`,children:i()}),note:d(),children:[(0,F.jsx)(R,{label:f(),children:(0,F.jsx)(M,{value:v.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>y(`opik`,`baseUrl`,e.target.value),onBlur:()=>S(`opik`,{baseUrl:v.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:v.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||O(),onChange:e=>y(`opik`,`workspace`,e.target.value),onBlur:()=>S(`opik`,{workspace:v.opik.workspace??``})})}),(0,F.jsx)(z,{label:l(),checked:v.opik.enabled??!0,onChange:e=>{y(`opik`,`enabled`,e),S(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(N,{variant:`secondary`,children:T()}):(0,F.jsx)(N,{variant:`outline`,children:c()}):(0,F.jsx)(N,{variant:`outline`,children:_()}),note:b(),children:[(0,F.jsx)(R,{label:x(),children:(0,F.jsx)(M,{value:v.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>y(`otlp`,`endpoint`,e.target.value),onBlur:()=>S(`otlp`,{endpoint:v.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:l(),checked:v.otlp.enabled??!0,onChange:e=>{y(`otlp`,`enabled`,e),S(`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)(j,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=o(E.integrations.otlpSecret.setOtlpHeaders),n=u(E.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[a,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(!1),d=async()=>{l(!0),s(null);try{await t({headersJson:r}),i(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,F.jsxs)(R,{label:C(),children:[(0,F.jsx)(M,{value:r,placeholder:e?w():y(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:c||r.trim().length===0,onClick:()=>void d(),children:v()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:c,onClick:()=>void n({}),children:D()}):null]}),a?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:a}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:S()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AO as r,CO as i,MO as a,NO as o,SO as s,Sv as c,_v as l,bv as u,dv as d,fv as f,gv as p,hv as m,ik as h,jO as g,jR as _,lv as v,mv as y,pv as b,t as x,uv as S,vv as C,xv as w,yv as T}from"./api-CbVyaw6f.js";import{Fn as ee,Pn as te,i as ne,o as re,r as E,wt as D}from"./index-EISUCtE9.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-1R1vH3Wp.js";import{n as N,t as P}from"./TimeRangePicker-CVMLr89E.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=_(x.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=_(x.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:h()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:o()}),(0,I.jsx)(j,{children:g()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(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),c=t=>6+t*468/(e.length-1),l=e=>74-e*68/r,u=e=>e.map((e,t)=>`${t===0?`M`:`L`}${c(t).toFixed(1)},${l(e).toFixed(1)}`).join(` `),d=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:[s(),` p50 `,R(d.cP50),` `,a()]}),(0,I.jsxs)(`span`,{children:[i(),` p50 `,R(d.aP50),` `,a()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":o(),children:[(0,I.jsx)(`path`,{d:u(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:u(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:c(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:w(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:u(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:T(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:C(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:l(),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=ee({from:`/settings/kpi`}),t=te({from:`/settings/kpi`}),n=ne(e.from,e.to,E,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:i,to:a}=N(n),{rowLimit:o,buckets:s}=K(i,a),c=_(x.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),l=(0,F.useMemo)(()=>{let e=new Map;for(let t of c??[]){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>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),u=(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 c===void 0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:y()})]}):c.length===0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:b()})]}):(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(l.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:l.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:f({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:d()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:S({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":v({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{CO as r,Cv as i,MO as a,NO as o,PO as s,Sv as c,_v as l,ak as u,bv as d,dv as f,fv as p,gv as m,hv as h,jO as g,mv as _,pv as v,t as y,uv as b,vv as x,wO as S,xv as C,yv as w,zR as T}from"./api-Dv9KEyyu.js";import{Fn as ee,Pn as te,i as ne,o as re,r as E,wt as D}from"./index-BAyOACwC.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-CwT7Pj_Y.js";import{n as N,t as P}from"./TimeRangePicker-I8KZZSiJ.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=T(y.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=T(y.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:u()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:s()}),(0,I.jsx)(j,{children:a()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):(0,I.jsx)(B,{series:n})})]})]})}function B({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),i=Math.max(1,...t,...n),a=t=>6+t*468/(e.length-1),c=e=>74-e*68/i,l=e=>e.map((e,t)=>`${t===0?`M`:`L`}${a(t).toFixed(1)},${c(e).toFixed(1)}`).join(` `),u=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:[r(),` p50 `,R(u.cP50),` `,o()]}),(0,I.jsxs)(`span`,{children:[S(),` p50 `,R(u.aP50),` `,o()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":s(),children:[(0,I.jsx)(`path`,{d:l(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:l(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:i(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:c(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:C(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:d(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:w(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:x(),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=ee({from:`/settings/kpi`}),t=te({from:`/settings/kpi`}),n=ne(e.from,e.to,E,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:i,to:a}=N(n),{rowLimit:o,buckets:s}=K(i,a),c=T(y.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),u=(0,F.useMemo)(()=>{let e=new Map;for(let t of c??[]){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>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),d=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[l(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return c===void 0?(0,I.jsxs)(I.Fragment,{children:[d,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:h()})]}):c.length===0?(0,I.jsxs)(I.Fragment,{children:[d,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:_()})]}):(0,I.jsxs)(I.Fragment,{children:[d,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(u.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:u.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:v({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:p()}),(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":b({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};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$L as r,$M as i,AN as a,AR as o,BT as s,CN as c,Ct as l,DN as u,EN as d,FN as f,Lt as p,MN as m,Mt as ee,NN as te,ON as h,PN as ne,QM as re,RR as g,Rt as ie,SN as ae,SR as oe,St as se,TN as ce,TR as le,XM as ue,ZM as de,_N as fe,_R as pe,_t as me,aN as _,aR as he,bN as ge,bR as _e,bt as v,cN as y,cR as b,dN as x,dR as S,eN as C,eR as w,fN as T,fR as E,gN as D,gR as O,hN as k,hR as A,iN as j,iR as M,jN as N,kN as P,lN as F,lR as I,mN as ve,mR as ye,nN as be,nR as xe,oN as Se,oR as Ce,pN as we,pR as Te,r as L,rN as R,rR as Ee,sN as De,sR as Oe,t as z,tN as ke,tR as Ae,uN as je,uR as Me,vN as Ne,vR as Pe,vt as Fe,wN as Ie,wt as Le,xN as Re,xR as ze,xt as Be,yN as Ve,yR as He,yt as Ue,zR as B}from"./api-Dv9KEyyu.js";import{t as V}from"./button-D9yXQ2Th.js";import{At as We,Dt as Ge,Ot as Ke,P as H,_t as qe,bt as Je,jt as U,kt as Ye,q as Xe,t as Ze,ut as W,vt as Qe,wt as G,xt as $e,yt as K}from"./index-BAyOACwC.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-DuZNYkVA.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:L(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:L(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>f()},{id:`composer`,label:()=>ne()},{id:`sidebar`,label:()=>te()},{id:`notifications`,label:()=>D()},{id:`other`,label:()=>m()}],X={showSource:{category:`messages`,label:()=>N(),help:()=>a()},showReport:{category:`messages`,label:()=>P(),help:()=>h()},copyAssistant:{category:`messages`,label:()=>u()},copyUser:{category:`messages`,label:()=>d()},showDelete:{category:`messages`,label:()=>ce()},showTools:{category:`messages`,label:()=>Ie(),help:()=>c()},voiceInput:{category:`composer`,label:()=>ae(),help:()=>Re()},showUsage:{category:`composer`,label:()=>ge(),help:()=>Ve()},autoReadAloud:{category:`composer`,label:()=>ie(),help:()=>p()},showChatAge:{category:`sidebar`,label:()=>Ne(),help:()=>fe()},notifSound:{category:`notifications`,label:()=>k(),help:()=>ve()},notifSystem:{category:`notifications`,label:()=>we(),help:()=>T()},replySound:{category:`notifications`,label:()=>x(),help:()=>je()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>C()};function ut({prefKey:e,ui:t}){let n=g(z.admin.setUiPrefDefault),r=g(z.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:j()}),(0,J.jsxs)(qe,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Je,{size:`sm`,className:`w-36`,children:(0,J.jsx)($e,{})}),(0,J.jsxs)(Qe,{children:[(0,J.jsx)(K,{value:`on`,children:re()}),(0,J.jsx)(K,{value:`off`,children:de()}),(0,J.jsx)(K,{value:`inherit`,children:ue()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(H,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":R()}),R()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=g(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[Le(),e?(0,J.jsx)(W,{variant:`secondary`,children:We(e,Ke())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?Be():r?se():l()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:me()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?Fe():e?Ue():v()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),a=B(z.me.getMe,{host:G}),s=a?.ui,c=$(a?.role)&&n,l=g(z.me.setUiPref).withOptimisticUpdate(Xe),u=(0,q.useMemo)(()=>s?Q(Object.keys(s.effective),e):[],[s,e]);return s?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(a?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(H,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":_()}),_()]}):null,c?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:be()}),(0,J.jsx)(`p`,{children:ke()}),(0,J.jsx)(`p`,{children:i()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:F(),"aria-label":F(),className:`mb-2`}),u.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:y()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:u.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=s.locked[e],a=s.effective[e],o=s.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(W,{variant:`outline`,children:De()}):o?(0,J.jsx)(W,{variant:`secondary`,children:ee()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&o?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void l({key:e,value:null}),children:Se()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),l({key:e,value:t})},"aria-label":n})]}),c?(0,J.jsx)(ut,{prefKey:e,ui:s}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:a?.dictationShortcut??null,enabled:s.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:o()})}var pt={sm:()=>Me(),md:()=>I(),lg:()=>b(),xl:()=>Oe(),"2xl":()=>Ce(),"3xl":()=>he()};function mt(){let e=B(z.me.getMe,{host:G}),t=g(z.me.setLocale),n=g(z.me.setTimezone),i=g(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),a=g(z.me.setMyName),o=Ge(),c=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),f=u??l,p=f.trim()!==l.trim();async function m(){try{await a({name:f}),d(null),o.success(Pe())}catch(e){o.error(pe(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:oe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:f,maxLength:120,placeholder:_e(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:s()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:He()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:O()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:A()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:c===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:c==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:le()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ye()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:M()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ee()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:xe()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:Te()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:E()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Ze.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void i({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:S()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:w()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:r()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -0,0 +1 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$m as i,AR as a,A_ as o,B_ as s,Bg as c,C_ as l,D as u,E_ as d,G_ as f,Gg as p,Hg as ee,Jg as te,K_ as ne,L_ as m,Lg as h,M_ as re,O_ as ie,P_ as g,RR as _,R_ as ae,S_ as v,T_ as y,Ug as b,V_ as x,Vg as oe,Wg as S,Yg as se,__ as C,a_ as ce,b_ as w,c_ as le,d_ as ue,e_ as T,f_ as E,g_ as de,h_ as fe,i_ as pe,j_ as me,k_ as he,l_ as ge,m_ as _e,n_ as D,o_ as O,p_ as k,q_ as ve,qg as A,s_ as ye,t as j,t_ as be,u_ as xe,v_ as M,w_ as Se,y_ as N,zR as P,zg as Ce}from"./api-Dv9KEyyu.js";import{r as we}from"./dist-BaKVbU2X.js";import{t as Te}from"./list-Cxi8aGjl.js";import{t as F}from"./button-D9yXQ2Th.js";import{A as Ee,C as De,Cn as Oe,D as ke,Dt as Ae,E as je,En as Me,Et as Ne,F as Pe,Fn as Fe,Ft as Ie,In as Le,It as Re,Lt as ze,Mt as Be,Nt as Ve,O as I,Pn as L,Pt as R,Q as He,S as Ue,Sn as z,T as We,Tt as Ge,Z as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as Qe,h as H,hn as U,in as $e,j as W,jn as et,jt as G,k as tt,m as nt,p as rt,pn as it,v as K,vn as at,w as ot,wn as q,x as J,y as st}from"./index-BAyOACwC.js";var ct=u(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),lt=u(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),ut=u(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),dt=u(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Y=t(e(),1),X=n();function Z({className:e}){return(0,X.jsx)(ze,{asChild:!0,children:(0,X.jsx)(F,{variant:`ghost`,size:`icon-xs`,"aria-label":p(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,X.jsx)(Me,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:i,className:a,onOpen:s}){let l=_(j.projects.renameProject),u=_(j.projects.setProjectColor),d=_(j.projects.moveProject),p=_(j.projects.deleteProject),ee=_(j.projects.createProject),h=Ke(),g=He(),[ae,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)(t),[x,se]=(0,Y.useState)(!1),[C,ce]=(0,Y.useState)(!1),w=P(j.projects.projectTreeCount,C?{projectId:e}:`skip`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{onOpenChange:e=>e&&ce(!0),children:[(0,X.jsx)(Z,{className:a}),(0,X.jsxs)(Ve,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(R,{onSelect:()=>s(),children:[(0,X.jsx)(q,{}),` `,ie()]}),(0,X.jsxs)(R,{onSelect:()=>{b(t),v(!0)},children:[(0,X.jsx)(it,{}),` `,S()]}),(0,X.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await g({title:N(),label:ve(),placeholder:ne(),confirmLabel:f()});t&&await ee({name:t,parentId:e})})},children:[(0,X.jsx)(Oe,{}),` `,N()]}),(0,X.jsxs)(R,{onSelect:()=>se(!0),children:[(0,X.jsx)(lt,{}),` `,be()]}),(0,X.jsx)(Ie,{children:oe()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void u({projectId:e,color:null}),"aria-label":c(),children:`✕`}),nt.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void u({projectId:e,color:t.value})},t.value))]}),(0,X.jsx)(Re,{}),(0,X.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=w?.folders??0,r=w?.chats??0;await h({title:me({name:t}),description:n>0?he({folders:n,chats:r}):r>0?o({count:r}):te(),confirmWord:A(),confirmLabel:re(),destructive:!0})&&await p({projectId:e})})},children:[(0,X.jsx)($e,{}),` `,A()]})]})]}),(0,X.jsx)(qe,{open:ae,onOpenChange:v,title:m(),canSubmit:y.trim().length>0,onSubmit:async()=>{await l({projectId:e,name:y.trim()}),v(!1)},submitLabel:S(),children:(0,X.jsx)(G,{value:y,onChange:e=>b(e.target.value),autoFocus:!0})}),x?(0,X.jsx)(rt,{open:x,onOpenChange:se,title:r(),movingFolderId:e,currentId:i,onPick:t=>void d({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=_(j.chats.pinChat),i=_(j.chats.deleteChat),a=_(j.chats.renameChat),o=_(j.chats.setChatSidebar),s=_(j.chats.moveChatToProject),c=Ke(),[l,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(e.title??``),[ne,m]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{children:[(0,X.jsx)(Z,{className:n}),(0,X.jsxs)(Ve,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(R,{onSelect:()=>{p(e.title??``),u(!0)},children:[(0,X.jsx)(it,{}),` `,S()]}),(0,X.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,X.jsx)(Xe,{}):(0,X.jsx)(V,{}),e.pinned?b():ee()]}),(0,X.jsxs)(R,{onSelect:()=>m(!0),children:[(0,X.jsx)(lt,{}),` `,D()]}),e.pinned&&e.inSidebar?null:(0,X.jsxs)(R,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,X.jsx)(U,{}):(0,X.jsx)(dt,{}),e.inSidebar?y():d()]}),(0,X.jsx)(Re,{}),(0,X.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:Ce(),description:te(),confirmLabel:A(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,X.jsx)($e,{}),` `,A()]})]})]}),(0,X.jsx)(qe,{open:l,onOpenChange:u,title:h(),canSubmit:f.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:f.trim()}),u(!1)},submitLabel:S(),children:(0,X.jsx)(G,{value:f,onChange:e=>p(e.target.value),autoFocus:!0})}),ne?(0,X.jsx)(rt,{open:ne,onOpenChange:m,title:T(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function mt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function xt(){let{projectId:e}=Le({from:`/project/$projectId`}),t=L(),n=P(j.projects.projectPage,{projectId:e});return(0,X.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:a()}):n===null?(0,X.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,X.jsx)(`h2`,{children:ye()}),(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:O()}),(0,X.jsx)(F,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ce()})]}):(0,X.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=Ke(),a=He(),s=Ae(),u=_(j.projects.renameProject),d=_(j.projects.setProjectColor),p=_(j.projects.deleteProject),ee=_(j.projects.createProject),h=_(j.projects.moveProject),ie=_(j.chats.moveChatToProject),g=_(j.chats.reorderChat),y=_(j.projects.reorderProject),b=P(j.projects.projectTreeCount,{projectId:e.project._id}),[C,ce]=(0,Y.useState)(gt),T=e=>{localStorage.setItem(ht,e),ce(e)},E=P(j.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=P(j.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:O}=Fe({from:`/project/$projectId`}),k=P(j.projects.listProjects,{}),ye=P(j.chatReads.myBusyChats,{}),M=(0,Y.useMemo)(()=>new Set(ye??[]),[ye]),Ce=P(j.chatReads.myChatReads,{}),we=(0,Y.useMemo)(()=>mt(e.chats,Ce??[]),[e.chats,Ce]),{startNewChat:Le,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,Y.useState)(``),[Ze,V]=(0,Y.useState)(!1),[H,U]=(0,Y.useState)(e.project.name),[W,et]=(0,Y.useState)(!1),[q,dt]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=setTimeout(()=>dt(B.trim()),180);return()=>clearTimeout(e)},[B]);let Z=P(j.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),Q=Ee(tt(ot,{activationConstraint:{distance:4}}),tt(We,{activationConstraint:{delay:250,tolerance:8}})),$=(0,Y.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,Y.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=E?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||x()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(k??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,Y.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=ke(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=ke(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=ke(n(`crumb:`));if(a.length>0)return a;let o=ke(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(C===`columns`){for(let e of E?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(C===`list`){let e=D?.chats.find(e=>e._id===t);return e?{list:D.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},kt=t=>{if(C===`columns`){for(let e of E?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(C===`list`){let e=D?.folders.find(e=>e._id===t);if(!e||!D)return null;let n=e.parentId??D.rootId;return{list:Ne(D.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(a)await ie({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Ge(k??[],t,e)){s.error(w());return}await h({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await ie({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await g({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ge(k??[],e,n.parentId)){s.error(w());return}await h({projectId:e,parentId:n.parentId})}let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await y({projectId:e,...a});return}}catch{s.error(w())}},[,Mt]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=Qe(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,X.jsxs)(Ue,{sensors:Q,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,X.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":pe(),children:[It.map(e=>(0,X.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,X.jsx)(Ct,{folderId:e._id,children:(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,X.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,X.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,X.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,X.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,X.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":Se(),children:[(0,X.jsx)(F,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Se(),title:Se(),"aria-pressed":C===`cards`,onClick:()=>T(`cards`),children:(0,X.jsx)(ut,{})}),(0,X.jsx)(F,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":l(),title:l(),"aria-pressed":C===`columns`,onClick:()=>T(`columns`),children:(0,X.jsx)(ct,{})}),(0,X.jsx)(F,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":v(),title:v(),"aria-pressed":C===`list`,onClick:()=>T(`list`),children:(0,X.jsx)(Te,{})})]}),(0,X.jsxs)(F,{variant:`outline`,size:`sm`,onClick:()=>void Le({projectId:e.project._id}),children:[(0,X.jsx)(at,{}),_e()]}),(0,X.jsxs)(F,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await a({title:N(),label:ve(),placeholder:ne(),confirmLabel:f()});t&&await ee({name:t,parentId:e.project._id})},children:[(0,X.jsx)(Oe,{}),N()]}),(0,X.jsxs)(Be,{children:[(0,X.jsx)(ze,{asChild:!0,children:(0,X.jsx)(F,{variant:`ghost`,size:`icon-sm`,"aria-label":ae(),children:(0,X.jsx)(Me,{})})}),(0,X.jsxs)(Ve,{align:`end`,className:`w-48`,children:[(0,X.jsxs)(R,{onSelect:()=>{U(e.project.name),V(!0)},children:[(0,X.jsx)(it,{}),` `,S()]}),(0,X.jsxs)(R,{onSelect:()=>et(!0),children:[(0,X.jsx)(lt,{}),` `,be()]}),(0,X.jsx)(Ie,{children:oe()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void d({projectId:e.project._id,color:null}),"aria-label":c(),children:`✕`}),nt.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void d({projectId:e.project._id,color:t.value})},t.value))]}),(0,X.jsx)(Re,{}),(0,X.jsxs)(R,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=b?.folders??0,a=b?.chats??0;await n({title:me({name:e.project.name}),description:i>0?he({folders:i,chats:a}):a>0?o({count:a}):te(),confirmWord:A(),confirmLabel:re(),destructive:!0})&&(await p({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,X.jsx)($e,{}),` `,A()]})]})]})]})]}),C===`columns`?(0,X.jsx)(jt,{data:E,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:O??null}):C===`list`?(0,X.jsx)(Ot,{data:D,busyIds:M,suppressClick:$,locateChatId:O??null}):(0,X.jsxs)(X.Fragment,{children:[e.children.length>0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:de()}),(0,X.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,X.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:st,children:e.children.map(t=>(0,X.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:fe()}),e.chats.length>0?(0,X.jsx)(G,{value:B,onChange:e=>Xe(e.target.value),placeholder:ue(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?ge():le()}):Ft.length===0&&(Z??[]).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:xe({term:B.trim()})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,X.jsx)(K,{items:Ft.map(e=>`chat:${e._id}`),strategy:J,children:Ft.map(t=>(0,X.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:we.has(t._id),locate:t._id===O,suppressClick:$},t._id))})})]}),q.length>=2&&Z!==void 0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:se()}),Z.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:xe({term:q})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:Z.map(e=>(0,X.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&Pe(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,X.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,X.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||i()}),e.projectPath&&e.projectPath.length>1?(0,X.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,X.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,X.jsx)(qe,{open:Ze,onOpenChange:V,title:m(),canSubmit:H.trim().length>0,onSubmit:async()=>{await u({projectId:e.project._id,name:H.trim()}),V(!1)},submitLabel:S(),children:(0,X.jsx)(G,{value:H,onChange:e=>U(e.target.value),autoFocus:!0})}),W?(0,X.jsx)(rt,{open:W,onOpenChange:et,title:r(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void h({projectId:e.project._id,parentId:t})}):null,I]}),(0,X.jsx)(De,{children:vt?(0,X.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,X.jsx)(z,{size:13,"aria-hidden":!0}):(0,X.jsx)(Je,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,X.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":Qe(e),transform:W.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,X.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,X.jsx)(z,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,X.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,X.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?k({count:e.folderCount})+` · `:``,E({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,X.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=_(j.chats.setChatSidebar),n=e.inSidebar?y():d();return(0,X.jsx)(F,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,X.jsx)(U,{}):(0,X.jsx)(dt,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let c=L(),l=H(e.color),u=B({id:`chat:${e._id}`}),d=Dt(a);return(0,X.jsxs)(`li`,{ref:e=>{u.setNodeRef(e),d.current=e},className:`oc-projpage__chatrow`+(u.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:W.Transform.toString(u.transform),transition:u.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||c({to:`/chat/$chatId`,params:{chatId:e._id}})},...u.listeners,...u.attributes,children:[l?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:l}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||x()}),e.pinned?(0,X.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,X.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,title:s(),"aria-label":s()}):null,i&&!r?(0,X.jsx)(`span`,{className:`oc-chatitem__unread`,title:g(),"aria-label":g()}):null]}),(0,X.jsx)(Tt,{chat:e}),(0,X.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,o]=(0,Y.useState)(new Set),s=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:a()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),l=(a,o)=>{let u=s.get(a??e.rootId)??[],d=Ne(e.folders,a);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{items:u.map(e=>`chat:${e._id}`),strategy:J,children:u.map(e=>(0,X.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,X.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:J,children:d.map(t=>(0,X.jsx)(kt,{folder:t,parentId:a??e.rootId,depth:o,folded:i.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:i.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,X.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ne(e.folders,null).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:ge()}):l(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,X.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,X.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":Qe(e),transform:W.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?M():C(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,X.jsx)(et,{size:13}):(0,X.jsx)(we,{size:13})}),(0,X.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=H(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:W.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||x()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,X.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let o=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=o.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:a()}):(0,X.jsx)(`div`,{className:`oc-projpage__cols`,ref:o,children:e.columns.map((a,o)=>(0,X.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(e.folderId)});return(0,X.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,X.jsx)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:J,children:e.folders.map(t=>(0,X.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,X.jsx)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:J,children:e.chats.map(t=>(0,X.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__colempty`,children:le()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":Qe(e),transform:W.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,X.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=H(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:W.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||x()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,X.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
@@ -0,0 +1,4 @@
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$i as r,$o as i,$y as a,By as o,Cr as s,Gy as c,Hy as l,Jy as u,Ky as d,Ly as f,Qi as p,Qo as m,Qy as h,RR as g,Ry as _,Sr as v,Uy as ee,Vy as te,Wy as ne,Xy as y,Yy as b,Zi as re,Zo as x,Zy as S,ca as C,da as w,ea as T,eb as ie,es as ae,la as oe,lb as E,nb as se,qy as D,t as O,ta as k,tb as A,ts as j,ua as M,ub as N,xr as P,zR as F,zy as I}from"./api-Dv9KEyyu.js";import{d as L,f as R,i as z,l as B,n as V,r as ce,t as H,u as U}from"./FieldLabel-JybJ9RRM.js";import{t as W}from"./button-D9yXQ2Th.js";import{Dt as G,P as le,_t as K,bt as q,vt as J,wt as ue,xt as Y,yt as X}from"./index-BAyOACwC.js";import{r as Z,t as de}from"./locales-CPjguROj.js";import{t as fe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),pe={media_delivery:{label:S,help:y},documentary_fetch:{label:b,help:u},inbound_files:{label:D,help:d},history_summary:{label:j,help:ae},file_curation:{label:w,help:k},quote_reply:{label:M,help:oe}},me={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
2
+ - gdrive/0f9e8d7c6b5a4321dcba`,files:`- /home/node/.openclaw/media/inbound/rapport.pdf (124800 o, application/pdf)`,previous_summary:`Projet Alpha : budget 40 000 EUR ; choix du serveur en cours.`,new_messages:`Utilisateur : Compare OVH et Scaleway.
3
+ Assistant : Comparaison en cours.`,max_chars:`6000`,file_name:`MEMORY.md`,budget_chars:`20000`,feedback:`Trop de suppressions dans la section des liens, garde-les.`,content:`# Memory index
4
+ - [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},he={outboundDir:I,references:_,files:f,previous_summary:i,new_messages:m,max_chars:x,file_name:T,budget_chars:r,feedback:p,content:re,excerpt:C};function ge(){let e=F(O.admin.listInstances,{}),[t,n]=(0,Q.useState)(null);if(e===void 0)return(0,$.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,$.jsx)(`div`,{className:`oc-injtab`,children:(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ne()})});let r=e.find(e=>e._id===t)??e[0];return(0,$.jsxs)(`div`,{className:`oc-injtab`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,$.jsx)(V,{label:se(),help:A()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:c()}),(0,$.jsxs)(K,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(q,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(Y,{})}),(0,$.jsx)(J,{children:e.map(e=>(0,$.jsx)(X,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(_e,{instance:r},r._id)]})}function _e({instance:e}){let t=g(O.admin.upsertInstanceConfig),n=G(),r=F(O.me.getMe,{host:ue}),i=e.config??{},a=Z(e.config?.contentLocale,r?.defaultLocale??void 0),[o,c]=(0,Q.useState)(()=>z(i,a));(0,Q.useEffect)(()=>{c(z(i,a))},[a,e._id]);let[l,u]=(0,Q.useState)(!1),d=o.promptInjections,f=(e,t)=>c({...o,promptInjections:{...d,[e]:{...d[e],...t}}});async function p(){u(!0);try{await t({instanceId:e._id,config:ce(o,i,a)})}catch(e){n.error(E(),e)}finally{u(!1)}}async function m(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(E(),e)}}let h=e.config?.contentLocale??`default`,_=de[Z(void 0,r?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:s()}),(0,$.jsxs)(K,{value:h,onValueChange:e=>void m(e),children:[(0,$.jsx)(q,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(Y,{})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(X,{value:`default`,children:P({locale:_})}),fe().map(e=>(0,$.jsx)(X,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:v()})]}),U.map(e=>(0,$.jsx)(ve,{injKey:e,def:B[e],i18n:pe[e],row:d[e]??{enabled:!0,template:B[e].defaultTemplate[a]},contentLocale:a,onChange:t=>f(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(W,{size:`sm`,onClick:()=>void p(),disabled:l,children:N()})})]})}function ve({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:s}){let[c,u]=(0,Q.useState)(!1),d=r.template.trim()!==t.defaultTemplate[i],f=t.togglable&&!r.enabled,p=Object.fromEntries(t.placeholders.map(e=>[e,me[e]??`{${e}}`])),m=L(e,r,i),g=m?R(m,p):``;return(0,$.jsxs)(`section`,{className:`oc-injcard`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,$.jsxs)(`label`,{className:`oc-field--row`,children:[(0,$.jsx)(le,{checked:r.enabled,onCheckedChange:e=>s({enabled:e===!0})}),(0,$.jsx)(V,{label:n.label(),help:n.help()})]}):(0,$.jsx)(V,{label:n.label(),help:n.help()}),d&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:a()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:f,rows:8,spellCheck:!1,onChange:e=>s({template:e.target.value})}),(0,$.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,$.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:h()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(H,{text:(he[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>u(e=>!e),children:c?l():ee()}),d&&(0,$.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>s({template:t.defaultTemplate[i]}),children:ie()})]})]}),c&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:g}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:te()})]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:o()})})]})}export{ge as PromptInjectionsTab};
@@ -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 ee,DC as a,EC as te,FC as o,Fa as s,GC as c,HC as l,IC as u,JC as d,KC as f,LC as p,MC as m,NC as ne,OC as h,PC as re,QC as g,RC as ie,RR as _,UC as v,VC as y,WC as b,XC as x,YC as S,ZC as C,_C as w,bC as T,ew as E,fC as D,gC as O,hC as k,jC as A,kC as j,mC as M,pC as N,qC as P,t as F,tw as I,vC as L,yC as R,zC as ae,zR as z}from"./api-Dv9KEyyu.js";import{t as B}from"./button-D9yXQ2Th.js";import{Dt as V,P as H,Z as U,_ as W,jt as G,ut as K,yn as q}from"./index-BAyOACwC.js";import{t as J}from"./roleDescriptions-DgcNSNlq.js";var Y=t(e(),1),X=n(),Z=[{group:()=>I(),keys:[{key:`traces.read`,label:()=>x()},{key:`traces.read.content`,label:()=>S(),phi:!0},{key:`traces.write`,label:()=>d()}]},{group:()=>E(),keys:[{key:`kpi.read`,label:()=>x()},{key:`kpi.write`,label:()=>d()}]},{group:()=>r(),keys:[{key:`openclaw.query`,label:()=>P()},{key:`anomalies.read`,label:()=>f()},{key:`anomalies.report`,label:()=>c()}]},{group:()=>g(),keys:[{key:`chats.read`,label:()=>x()},{key:`selfheal`,label:()=>v()},{key:`feedback.respond`,label:()=>s()}]},{group:()=>C(),keys:[{key:`admin.manage`,label:()=>b()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=z(F.apiKeys.listRoles,{}),t=_(F.apiKeys.createRole),n=_(F.apiKeys.ensureRolesSeeded),r=_(F.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(F.apiKeys.listRoles,{});r&&e.setQuery(F.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),s=U(),c=V(),[d,f]=(0,Y.useState)(!1),[g,v]=(0,Y.useState)($),[b,x]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{c.error(y(),e)})},[n,c]);let S=e??[];async function C(e,t){if(Q(e.permissions))return;if(e.builtin){await s({title:ee({name:e.name}),description:ae(),confirmLabel:ie()});return}if(b.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];x(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){c.error(p(),e)}finally{x(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function E(){try{await t({key:g.key,name:g.name,description:g.description||void 0,permissions:[]}),v($),f(!1)}catch(e){c.error(u(),e)}}let P=e===void 0,I=!P&&S.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[o(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,re(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,ne()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:m()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{v($),f(!0)},children:A()})})]}),P?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):I?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:j()}):(0,X.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,X.jsxs)(`table`,{className:`oc-matrix`,children:[(0,X.jsxs)(`thead`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:h()}),Z.map(e=>(0,X.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,X.jsx)(`tr`,{children:Z.flatMap(e=>e.keys.map(e=>(0,X.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?l({key:e.key}):e.key,children:[e.label(),e.phi?(0,X.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,X.jsx)(`tbody`,{children:S.map(e=>{let t=Q(e.permissions),n=b.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(K,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,a()]}):(0,X.jsx)(K,{variant:`secondary`,children:te()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),oe.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(H,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?T():n?R():r,onCheckedChange:()=>void C(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:d,onOpenChange:f,title:L(),description:w(),canSubmit:!!(g.key&&g.name),onSubmit:E,submitLabel:O(),children:(0,X.jsxs)(`div`,{className:`oc-form`,children:[(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:k()}),(0,X.jsx)(G,{value:g.key,placeholder:M(),onChange:e=>v({...g,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:N()}),(0,X.jsx)(G,{value:g.name,onChange:e=>v({...g,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:D()}),(0,X.jsx)(G,{value:g.description,onChange:e=>v({...g,description:e.target.value})})]})]})})]})}export{se as RolesTab};