@lacneu/atrium 0.88.0 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/assets/AccessTab-D82x_380.js +1 -0
  2. package/dist/assets/{AdvancedFilter-DfWuJNZC.js → AdvancedFilter-DEwJUkfT.js} +1 -1
  3. package/dist/assets/AgentFilesTab-CEqQ02fZ.js +3 -0
  4. package/dist/assets/AnomaliesTab-Cl2630PU.js +1 -0
  5. package/dist/assets/AuditTab-DYryQjmJ.js +1 -0
  6. package/dist/assets/BridgeTab-rI4MFNcQ.js +1 -0
  7. package/dist/assets/ChatDefaultsTab-CgTm4WMx.js +1 -0
  8. package/dist/assets/{DataTableShell-D_1TXULe.js → DataTableShell-REGK6Dqj.js} +1 -1
  9. package/dist/assets/{DetailChips-S9d12ANU.js → DetailChips-Dhiulk-F.js} +1 -1
  10. package/dist/assets/FeedbacksTab-DpWIlp9R.js +1 -0
  11. package/dist/assets/{FieldLabel-DpY9Xev6.js → FieldLabel-CFBfL_GK.js} +1 -1
  12. package/dist/assets/FilesTab-VZuW17oP.js +1 -0
  13. package/dist/assets/{FilterBar-c4Vf46z3.js → FilterBar-CJwP10CI.js} +1 -1
  14. package/dist/assets/GroupsTab-BjJmfc7f.js +1 -0
  15. package/dist/assets/InstancesTab-Ofqk-EZR.js +1 -0
  16. package/dist/assets/IntegrationsTab-Cey3WV3E.js +1 -0
  17. package/dist/assets/KpiTab-DIRKI4qa.js +1 -0
  18. package/dist/assets/PreferencesTab-BfHNBONO.js +1 -0
  19. package/dist/assets/ProjectPage-BsJB0GCv.js +1 -0
  20. package/dist/assets/PromptInjectionsTab-KdBPVl-W.js +4 -0
  21. package/dist/assets/RolesTab-DdooYgwg.js +1 -0
  22. package/dist/assets/ScheduledTab-AArpRKQU.js +1 -0
  23. package/dist/assets/ServiceAccountsTab-ByKfn9jX.js +1 -0
  24. package/dist/assets/SubAgentReportsTab-BMxqMtk1.js +1 -0
  25. package/dist/assets/ThemeShowroom-Ctv3Ktd3.js +1 -0
  26. package/dist/assets/{TimeRangePicker-FT0sN61o.js → TimeRangePicker-es8qiYT0.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-0qEgkKvV.js → TimezoneCombobox-DSIM9YOb.js} +1 -1
  28. package/dist/assets/TracesTab-CXdVaFxl.js +1 -0
  29. package/dist/assets/TrashPage-DBE3OVMc.css +1 -0
  30. package/dist/assets/TrashPage-DwgS7gln.js +1 -0
  31. package/dist/assets/TrashTab-CAfRYG_t.js +1 -0
  32. package/dist/assets/UsersTab-B29t4KCa.js +1 -0
  33. package/dist/assets/VoiceTab-BaN-J1s2.js +1 -0
  34. package/dist/assets/api-DfVtzU1G.js +44 -0
  35. package/dist/assets/button-BWdRKrS3.js +1 -0
  36. package/dist/assets/{card-DOI4qcUP.js → card-CdvSrnID.js} +1 -1
  37. package/dist/assets/chevrons-up-down-RHDK4dlM.js +1 -0
  38. package/dist/assets/{compatView-WF4iD3or.js → compatView-ChkOVx0F.js} +1 -1
  39. package/dist/assets/dispatchErrorInfo-CpWqaJBx.js +1 -0
  40. package/dist/assets/dist-CGHNQwsf.js +1 -0
  41. package/dist/assets/dist-CdViHsIv.js +1 -0
  42. package/dist/assets/{dist-BtoqPlB7.js → dist-D8270q9m.js} +1 -1
  43. package/dist/assets/{dist-DRf4t_B7.js → dist-cnxPdTGN.js} +1 -1
  44. package/dist/assets/{highlighted-body-OFNGDK62-CjcMoipl.js → highlighted-body-OFNGDK62-CrlMHfOs.js} +1 -1
  45. package/dist/assets/index-B0MXmi3m.js +327 -0
  46. package/dist/assets/index-Dwpglqo3.css +1 -0
  47. package/dist/assets/{list-_AdtdHKa.js → list-CR2YIdia.js} +1 -1
  48. package/dist/assets/mermaid-GHXKKRXX-n8ziFmjV.js +1 -0
  49. package/dist/assets/{pdf-CY8X_ahA.js → pdf-D1bMzEYl.js} +1 -1
  50. package/dist/assets/roleDescriptions-DBqNfMhe.js +1 -0
  51. package/dist/assets/{table-DJJzEEXc.js → table-CVSQWo7b.js} +1 -1
  52. package/dist/assets/use_paginated_query-DSw-EOJL.js +1 -0
  53. package/dist/assets/x-CrZwGtLz.js +1 -0
  54. package/dist/index.html +9 -8
  55. package/package.json +3 -2
  56. package/dist/assets/AccessTab-QSLwtuuc.js +0 -1
  57. package/dist/assets/AgentFilesTab-uwWgtQgE.js +0 -3
  58. package/dist/assets/AnomaliesTab-BUTl2hWd.js +0 -1
  59. package/dist/assets/AuditTab-CicfFU_n.js +0 -1
  60. package/dist/assets/BridgeTab-C12c4qBe.js +0 -1
  61. package/dist/assets/ChatDefaultsTab-D1Nj28J1.js +0 -1
  62. package/dist/assets/FeedbacksTab-BrJ2q49l.js +0 -1
  63. package/dist/assets/FilesTab-B9W1PbQN.js +0 -1
  64. package/dist/assets/GroupsTab-DcoPyNf-.js +0 -1
  65. package/dist/assets/InstancesTab-BVeOSJ5v.js +0 -1
  66. package/dist/assets/IntegrationsTab-CGITUOLA.js +0 -1
  67. package/dist/assets/KpiTab-BK_BrK-j.js +0 -1
  68. package/dist/assets/PreferencesTab-jlp6OzO_.js +0 -1
  69. package/dist/assets/ProjectPage-Qg8uaPYR.js +0 -1
  70. package/dist/assets/PromptInjectionsTab-B3OWlGa0.js +0 -4
  71. package/dist/assets/RolesTab-BSvuojBC.js +0 -1
  72. package/dist/assets/ScheduledTab-DBkiXWYU.js +0 -1
  73. package/dist/assets/ServiceAccountsTab-DGOPe59N.js +0 -1
  74. package/dist/assets/SubAgentReportsTab-DYIXDbFr.js +0 -1
  75. package/dist/assets/ThemeShowroom-BqqT9eCK.js +0 -1
  76. package/dist/assets/TracesTab-pddQ9h_F.js +0 -1
  77. package/dist/assets/UsersTab-B-oeu5Px.js +0 -1
  78. package/dist/assets/VoiceTab-DKgyz5nJ.js +0 -1
  79. package/dist/assets/api-pyd1BsFz.js +0 -44
  80. package/dist/assets/button-CSHWa9fF.js +0 -1
  81. package/dist/assets/chevrons-up-down-CVE2gmuK.js +0 -1
  82. package/dist/assets/dispatchErrorInfo-Bbo9tRSI.js +0 -1
  83. package/dist/assets/dist-BEIK-Fy2.js +0 -1
  84. package/dist/assets/index-0DcZwf39.css +0 -1
  85. package/dist/assets/index-D_SQS2Hc.js +0 -327
  86. package/dist/assets/mermaid-GHXKKRXX-k47BfDk_.js +0 -1
  87. package/dist/assets/roleDescriptions-CWN610yU.js +0 -1
  88. package/dist/assets/x-BAZ6f_9l.js +0 -1
@@ -0,0 +1 @@
1
+ import{FA as e,IA as t,LA as n,RA as r,zA as i}from"./api-DfVtzU1G.js";var a={pending:i,user:r,admin:n,observer:t,agent:e};function o(e){if(e.builtin){let t=a[e.key];if(t)return t()}return e.description}export{o as t};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./bundle-mjs-C73ZY4La.js";import{r as n}from"./api-pyd1BsFz.js";e();var r=t();function i({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:n(`w-full caption-bottom text-sm`,e),...t})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:n(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:n(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
1
+ import{a as e,r as t}from"./bundle-mjs-C73ZY4La.js";import{r as n}from"./api-DfVtzU1G.js";e();var r=t();function i({className:e,...t}){return(0,r.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,r.jsx)(`table`,{"data-slot":`table`,className:n(`w-full caption-bottom text-sm`,e),...t})})}function a({className:e,...t}){return(0,r.jsx)(`thead`,{"data-slot":`table-header`,className:n(`[&_tr]:border-b`,e),...t})}function o({className:e,...t}){return(0,r.jsx)(`tbody`,{"data-slot":`table-body`,className:n(`[&_tr:last-child]:border-0`,e),...t})}function s({className:e,...t}){return(0,r.jsx)(`tr`,{"data-slot":`table-row`,className:n(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function c({className:e,...t}){return(0,r.jsx)(`th`,{"data-slot":`table-head`,className:n(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function l({className:e,...t}){return(0,r.jsx)(`td`,{"data-slot":`table-cell`,className:n(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}export{a,c as i,o as n,s as o,l as r,i as t};
@@ -0,0 +1 @@
1
+ import{a as e,l as t}from"./bundle-mjs-C73ZY4La.js";import{Eq as n,Oq as r,mq as i,vq as a,xq as o}from"./api-DfVtzU1G.js";var s=t(e(),1),c=(e,t,n)=>r=>{let i={...r.queries},a=r.nextPageKey,o=r.nextPageKey+1,s=r.nextPageKey+2;i[a]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,endCursor:t}}},i[o]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,cursor:t,endCursor:n}}};let c={...r.ongoingSplits};return c[e]=[a,o],{...r,nextPageKey:s,queries:i,ongoingSplits:c}},l=e=>t=>{let n=t.ongoingSplits[e];if(n===void 0)return t;let r={...t.queries};delete r[e];let i={...t.ongoingSplits};delete i[e];let a=t.pageKeys.slice(),o=t.pageKeys.findIndex(t=>t===e);return o>=0&&(a=[...t.pageKeys.slice(0,o),...n,...t.pageKeys.slice(o+1)]),{...t,queries:r,pageKeys:a,ongoingSplits:i}};function u(e,t,n){let{user:r}=p(e,t,n,!0);return r}var d=Symbol(`includePageKeys`),f=Symbol(`page`);function p(e,t,u,p=!0){if(typeof u?.initialNumItems!=`number`||u.initialNumItems<0)throw Error(`\`options.initialNumItems\` must be a positive number. Received \`${u?.initialNumItems}\`.`);let m=t===`skip`,g=m?{}:t,_=o(e),v=(0,s.useMemo)(()=>()=>{let t=h();return{query:e,args:g,id:t,nextPageKey:1,pageKeys:m?[]:[0],queries:m?{}:{0:{query:e,args:{...g,paginationOpts:{numItems:u.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:m}},[JSON.stringify(r(g)),_,u.initialNumItems,m]),[y,b]=(0,s.useState)(v),x=y;(o(e)!==o(y.query)||JSON.stringify(r(g))!==JSON.stringify(r(y.args))||m!==y.skip)&&(x=v(),b(x));let S=a().logger,C=i(x.queries),w=u[d]??!1,[T,E,D]=(0,s.useMemo)(()=>{let e,t=[];for(let r of x.pageKeys){if(e=C[r],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof n&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return S.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),b(v),[[],void 0,void 0];if(p)throw e;return[t,void 0,e]}let i=x.ongoingSplits[r];if(i===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>u.initialNumItems*2)&&b(c(r,e.splitCursor,e.continueCursor)):C[i[0]]!==void 0&&C[i[1]]!==void 0&&b(l(r)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...w?e.page.map(e=>({...e,[f]:r.toString()})):e.page)}return[t,e,void 0]},[C,x.pageKeys,x.ongoingSplits,u.initialNumItems,v,S,w,p]);return{user:{results:T,...(0,s.useMemo)(()=>{if(D!==void 0)return{status:`Error`,isLoading:!1,error:D,loadMore:()=>{}};if(E===void 0)return x.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(E.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=E.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,b(t=>{let r=[...t.pageKeys,t.nextPageKey],i={...t.queries};return i[t.nextPageKey]={query:t.query,args:{...t.args,paginationOpts:{numItems:n,cursor:e,id:t.id}}},{...t,nextPageKey:t.nextPageKey+1,pageKeys:r,queries:i}}))}}},[D,E,x.nextPageKey])},internal:{state:x}}}var m=0;function h(){return m++,m}export{u as t};
@@ -0,0 +1 @@
1
+ import{E as e}from"./api-DfVtzU1G.js";var t=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t};
package/dist/index.html CHANGED
@@ -62,15 +62,16 @@
62
62
  document.documentElement.dataset.motion = "static";
63
63
  })();
64
64
  </script>
65
- <script type="module" crossorigin src="/assets/index-D_SQS2Hc.js"></script>
65
+ <script type="module" crossorigin src="/assets/index-B0MXmi3m.js"></script>
66
66
  <link rel="modulepreload" crossorigin href="/assets/bundle-mjs-C73ZY4La.js">
67
- <link rel="modulepreload" crossorigin href="/assets/api-pyd1BsFz.js">
68
- <link rel="modulepreload" crossorigin href="/assets/dist-BEIK-Fy2.js">
69
- <link rel="modulepreload" crossorigin href="/assets/dist-BtoqPlB7.js">
70
- <link rel="modulepreload" crossorigin href="/assets/dist-DRf4t_B7.js">
71
- <link rel="modulepreload" crossorigin href="/assets/x-BAZ6f_9l.js">
72
- <link rel="modulepreload" crossorigin href="/assets/button-CSHWa9fF.js">
73
- <link rel="stylesheet" crossorigin href="/assets/index-0DcZwf39.css">
67
+ <link rel="modulepreload" crossorigin href="/assets/api-DfVtzU1G.js">
68
+ <link rel="modulepreload" crossorigin href="/assets/dist-CGHNQwsf.js">
69
+ <link rel="modulepreload" crossorigin href="/assets/dist-CdViHsIv.js">
70
+ <link rel="modulepreload" crossorigin href="/assets/dist-D8270q9m.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/dist-cnxPdTGN.js">
72
+ <link rel="modulepreload" crossorigin href="/assets/x-CrZwGtLz.js">
73
+ <link rel="modulepreload" crossorigin href="/assets/button-BWdRKrS3.js">
74
+ <link rel="stylesheet" crossorigin href="/assets/index-Dwpglqo3.css">
74
75
  </head>
75
76
  <body>
76
77
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacneu/atrium",
3
- "version": "0.88.0",
3
+ "version": "0.89.0",
4
4
  "description": "Atrium — public, self-hostable, Convex-backed web chat UI for AI agent gateways (OpenClaw today, Hermes next). Ships an origin-agnostic static bundle (Convex URL injected at runtime via /config.json).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,7 +25,8 @@
25
25
  "build": "vite build",
26
26
  "paraglide:compile": "paraglide-js compile --project ./project.inlang --outdir ./src/paraglide --emit-ts-declarations --strategy localStorage baseLocale",
27
27
  "typecheck:convex": "tsc --noEmit -p convex",
28
- "typecheck": "npm run paraglide:compile && tsc --noEmit && npm run typecheck:convex",
28
+ "typecheck:gc": "tsc --noEmit -p deploy/gc",
29
+ "typecheck": "npm run paraglide:compile && tsc --noEmit && npm run typecheck:convex && npm run typecheck:gc",
29
30
  "test": "npm run paraglide:compile && npm run i18n:check && vitest run",
30
31
  "i18n:check": "npm run i18n:check-parity && npm run i18n:check-literals",
31
32
  "i18n:check-parity": "node scripts/i18n-check-parity.mjs",
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{ay as r,cy as i,dy as a,ey as o,fy as s,iy as c,jK as l,ly as u,my as d,ny as f,oy as p,py as m,ry as h,sy as g,t as _,ty as v,uy as y,xK as b}from"./api-pyd1BsFz.js";import{At as x,et as S,it as C,nt as w,rt as T,tt as E}from"./index-D_SQS2Hc.js";var D=t(e(),1);function O(e){return e===`user`?c():e===`all`?h():f({group:e.group})}function k(e){return e===`common`?v():e===`owner`?o():f({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=l(_.admin.listUsers,{}),[t,n]=(0,D.useState)(``),o=l(_.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:d()}),(0,A.jsxs)(S,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":m(),children:(0,A.jsx)(C,{placeholder:m()})}),(0,A.jsx)(E,{children:(e??[]).map(e=>(0,A.jsx)(w,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:s()}):o===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:a()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:o.user.label}),(0,A.jsx)(x,{variant:`secondary`,children:o.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:y()}),o.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:o.groups.map(e=>(0,A.jsx)(x,{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:u()}),o.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:o.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(x,{variant:`default`,children:r()}):null,(0,A.jsx)(x,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(x,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:i()}),o.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:o.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(x,{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:g()}),o.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:p()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:o.permissions.map(e=>(0,A.jsx)(x,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
@@ -1,3 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AK as r,A_ as i,Ad as a,Ag as o,Bg as s,CK as c,Cd as l,Cg as u,Co as d,Dd as f,Dg as p,Ed as m,Eg as h,Fg as g,Gg as _,Gu as v,Hg as y,Ig as b,Ju as x,Kg as S,Ku as C,Lg as w,ML as T,M_ as E,Md as D,Mg as ee,Nd as O,Ng as k,OK as A,Od as j,Og as M,Pg as te,Rg as N,Sd as P,Sg as F,Td as I,Tg as ne,Ug as L,Vg as re,Wg as ie,Xu as R,Yu as ae,Zu as z,_d as B,_g as V,bd as H,bg as oe,gd as se,hd as U,jK as W,jd as ce,jg as le,kd as ue,kg as de,md as fe,pd as pe,qu as me,t as G,vd as he,vg as ge,wd as _e,wg as ve,xK as K,xd as ye,xg as be,yd as xe,yg as Se,zg as Ce}from"./api-pyd1BsFz.js";import{t as q}from"./button-CSHWa9fF.js";import{At as we,Ct as Te,Dt as Ee,Et as De,Ot as Oe,St as ke,Tt as Ae,V as je,Z as Me,at as Ne,et as Pe,it as Fe,jt as J,kt as Ie,lt as Le,nt as Re,ot as ze,rt as Be,st as Ve,tt as He,un as Y,ut as Ue,wt as We}from"./index-D_SQS2Hc.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-WF4iD3or.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=W(G.me.getMe,{host:Me}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=W(G.admin.listInstances,e!==void 0&&t?{}:`skip`),[o,l]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!r||r.length===0||(!o||!r.some(e=>e.name===o))&&l(r[0].name)},[t,r,o]);let u=W(G.agents.listAgentsForInstance,t&&o?{instanceName:o}:`skip`),f=W(G.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),p=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return o===null||u===void 0?r!==void 0&&r.length===0?[]:void 0:u.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,u,r,f]),[m,h]=(0,X.useState)(null);(0,X.useEffect)(()=>{!p||p.length===0||(!m||!p.some(e=>$(e)===m))&&h($(p[0]))},[p,m]);let v=p?.find(e=>$(e)===m)??null,x=A(G.agentFiles.listAgentFiles),[C,T]=(0,X.useState)({status:`idle`}),E=v?.instanceName??null,D=v?.agentId??null,ee=W(G.compat.forInstance,n&&E!==null?{instanceName:E}:`skip`),O=n&&E!==null?je(ee,`agentFiles`):null,k=O===null?!1:O===`loading`?null:O.blocked,M=(0,X.useCallback)(async()=>{if(!(E===null||D===null)){T({status:`loading`});try{T({status:`done`,files:(await x({instanceName:E,agentId:D})).files})}catch(e){T({status:`error`,dashboardAbsent:tt(e)})}}},[x,E,D]);(0,X.useEffect)(()=>{k===!1&&M()},[M,k]);let[P,F]=(0,X.useState)(null),I=W(G.agentFileCuration.listCurations,t&&E!==null&&D!==null?{instanceName:E,agentId:D}:`skip`),ne=W(G.agentFileCuration.curationSettings,t&&E!==null?{instanceName:E}:`skip`),R=A(G.agentFileCuration.requestCuration),[ae,z]=(0,X.useState)(null),[B,V]=(0,X.useState)(null),{toast:H}=J(),oe=(0,X.useMemo)(()=>{let e=new Map;for(let t of I??[])e.has(t.name)||e.set(t.name,t);return e},[I]),se=(0,X.useCallback)(async e=>{if(!(E===null||D===null)){z(e);try{let t=await R({instanceName:E,agentId:D,name:e,trigger:`manual`});t.ok?H({title:a(),variant:`success`}):H({title:ue({reason:t.reason??`unknown`}),variant:`error`})}catch{H({title:j(),variant:`error`})}finally{z(null)}}},[R,E,D,H]),U=c(),ce=(0,X.useMemo)(()=>new Intl.NumberFormat(U,{maximumFractionDigits:0}),[U]);return e===void 0||p===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:K()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:S()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(Pe,{value:o??``,onValueChange:e=>l(e),children:[(0,Q.jsx)(Be,{size:`sm`,"aria-label":_(),children:(0,Q.jsx)(Fe,{})}),(0,Q.jsx)(He,{children:(r??[]).map(e=>(0,Q.jsx)(Re,{value:e.name,children:e.name},e.name))})]}):null,p.length>0?(0,Q.jsxs)(Pe,{value:m??``,onValueChange:e=>h(e),children:[(0,Q.jsx)(Be,{size:`sm`,"aria-label":ie(),children:(0,Q.jsx)(Fe,{})}),(0,Q.jsx)(He,{children:p.map(e=>(0,Q.jsx)(Re,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:L()})]}),v===null?null:O===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:K()}):O!==null&&O.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Y,{size:14,"aria-hidden":!0}),` `,qe(O.gatewayVersion,O.provider)]}):C.status===`loading`||C.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:K()}):C.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[C.dashboardAbsent?d():re(),` `,!C.dashboardAbsent&&(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void M(),children:i()})]}):C.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:y()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:C.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)(we,{variant:`outline`,children:s()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:Ce({size:Z(e.size,U)})}),(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:N({pct:ce.format(n)})}),r?(0,Q.jsx)(Y,{size:14,className:`oc-afiles__warn`,"aria-label":w()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>F(e),children:t?g():te()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:ne?.budgetChars??null,enabled:ne?.enabled??!1,curation:oe.get(e.name)??null,inFlight:ae===e.name,onCurate:()=>void se(e.name),onReview:e=>V(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:b({used:Z(Qe(C.files),U),total:Z(Ye,U),pct:ce.format(Ze(Qe(C.files)))})})]}),P&&v?(0,Q.jsx)(at,{instanceName:v.instanceName,agentId:v.agentId,name:P.name,isAdmin:t,onClose:()=>F(null),onSaved:()=>void M()}):null,B?(0,Q.jsx)(ot,{curationId:B,onClose:()=>V(null),onApplied:()=>{V(null),M()}}):null]})}function it({curatable:e,size:t,budget:n,enabled:r,curation:i,inFlight:a,onCurate:o,onReview:s}){return i?.status===`proposed`?(0,Q.jsx)(q,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:D()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(we,{variant:`outline`,className:`oc-afiles__curate-status`,children:ce()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:O()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:a,onSaved:s}){let l=A(G.agentFiles.getAgentFile),d=A(G.agentFiles.setAgentFile),f=J(),[m,g]=(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),[D,O]=(0,X.useState)(!1),[j,te]=(0,X.useState)(!1),N=(0,X.useCallback)(async r=>{v(!1);try{let i=await l({instanceName:e,agentId:t,name:n});g({content:i.content,updatedAtMs:i.updatedAtMs}),r||b(i.content),O(!1)}catch{v(!0)}},[l,e,t,n]);(0,X.useEffect)(()=>{N(!1)},[N]);async function P(){if(m!==null){w(!0),te(!1);try{await d({instanceName:e,agentId:t,name:n,content:y,baseUpdatedAtMs:m.updatedAtMs??void 0}),f.success(p({name:n})),s(),await N(!1)}catch(e){nt(e)?O(!0):te(!0)}finally{w(!1)}}}let I=m!==null&&y!==m.content,L=(0,X.useMemo)(()=>m===null?null:et(m.content,y),[m,y]),re=y.length>Je,ie=c(),R=(0,X.useMemo)(()=>new Intl.NumberFormat(ie),[ie]);return(0,Q.jsx)(Ne,{open:!0,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(ze,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(Ue,{children:k({name:n})}),(0,Q.jsxs)(Ve,{children:[ee({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,le()]})]})]}),_?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ne(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void N(!1),children:i()})]}):m===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:K()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:y,readOnly:!r,spellCheck:!1,onChange:e=>b(e.target.value),"aria-label":k({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:o()}),D?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ve(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void N(!0),children:u()})]}):null,j?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:h()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${re?` is-over`:``}`,children:de({count:R.format(y.length),max:R.format(Je)})}),r?(0,Q.jsx)(q,{size:`sm`,disabled:!I||C||D,onClick:()=>S(!0),children:C?E():M()}):null]})]}),(0,Q.jsx)(ke,{open:x,onOpenChange:S,children:(0,Q.jsxs)(Ae,{children:[(0,Q.jsxs)(Oe,{children:[(0,Q.jsx)(Ie,{children:F({name:n})}),(0,Q.jsx)(De,{children:be({agent:t})})]}),L?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:oe({added:L.added,removed:L.removed})}),L.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:Se()}),L.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,L.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:ge()}),L.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(We,{children:T()}),(0,Q.jsx)(Te,{onClick:()=>void P(),children:V()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let i=W(G.agentFileCuration.getProposal,{curationId:e}),a=A(G.agentFileCuration.approveCuration),o=r(G.agentFileCuration.rejectCuration),{toast:s}=J(),[u,d]=(0,X.useState)(null),[p,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(``),y=c(),b=(0,X.useMemo)(()=>i?et(i.beforeContent,i.proposedContent):null,[i]);async function S(){d(`approve`);try{let t=await a({curationId:e});t.ok?(s({title:f(),variant:`success`}),n()):s({title:t.reason===`conflict`?I():_e({reason:t.reason??`unknown`}),variant:`error`})}catch{s({title:j(),variant:`error`})}finally{d(null)}}async function w(n){d(`reject`);try{let r=g.trim();(await o({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?s({title:n?C():m(),variant:`success`}):s({title:ye(),variant:`error`}),t()}catch{s({title:j(),variant:`error`})}finally{d(null)}}return(0,Q.jsx)(Ne,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(ze,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(Ue,{children:i?l({name:i.name}):K()}),(0,Q.jsx)(Ve,{children:P()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:K()}):i===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ye()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[H({before:Z(i.beforeSize,y),after:Z(i.proposedSize,y)}),i.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Y,{size:13,"aria-hidden":!0}),` `,xe()]}):null]}),b?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:he({added:b.added,removed:b.removed})}):null,i.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:v({feedback:i.feedback})}):null,b&&b.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:pe()}),(0,Q.jsx)(`ul`,{children:b.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:fe()}),(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:B()}),(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:z()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:R(),value:g,onChange:e=>_(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`ghost`,onClick:()=>h(!1),disabled:u!==null,children:ae()}),(0,Q.jsx)(q,{variant:`outline`,onClick:()=>void w(!1),disabled:u!==null,children:u===`reject`?E():x()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void w(!0),disabled:u!==null,children:u===`reject`?E():me()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>h(!0),disabled:u!==null||i==null,children:se()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void S(),disabled:u!==null||i==null,children:u===`approve`?E():U()})]})]})})}export{rt as AgentFilesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,AK as i,Ak as ee,Ck as te,Dk as ne,Ek as a,Fk as o,GO as s,HO as c,Ik as l,JO as u,KO as d,Mk as re,Nk as ie,Ok as ae,Pk as f,QO as oe,Sk as se,Tk as ce,UO as p,VO as m,WO as h,XO as le,YO as ue,ZO as de,_k as g,ak as _,bk as v,ck as y,dk as fe,ek as pe,fk as me,gk as he,hk as ge,ik as _e,jK as b,jk as ve,kk as ye,lk as be,mk as xe,nk as Se,ok as x,pk as S,qO as C,rk as w,sk as T,t as E,tk as D,uk as O,vk as k,wk as A,xk as j,yk as Ce}from"./api-pyd1BsFz.js";import{At as M,Gn as N,Kn as we,Z as Te,at as P,et as F,ft as I,i as Ee,it as L,jt as De,lt as R,nt as z,o as Oe,ot as B,q as ke,rt as V,tt as H,ut as U}from"./index-D_SQS2Hc.js";import{n as Ae}from"./TimeRangePicker-FT0sN61o.js";import{t as je}from"./FilterBar-c4Vf46z3.js";import{t as Me}from"./DataTableShell-D_1TXULe.js";import{t as W}from"./dispatchErrorInfo-Bbo9tRSI.js";var G=t(e(),1),K=n(),q=`__all__`,Ne=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Pe(e){return e===`open`?l():e===`acknowledged`?o():f()}var Fe=[`info`,`warn`,`critical`],Ie=[`detector`,`agent`,`user`],Le={kind:`relative`,from:`now-30d`,to:`now`},Re=200,J=`all`;function Y(){let e=we({from:`/settings/anomalies`}),t=N({from:`/settings/anomalies`}),n=e.q??``,o=e.status===J?q:e.status,s=e.severity??q,c=e.kind??q,[l,u]=(0,G.useState)(q),d=Ee(e.from,e.to),{from:f,to:p}=Ae(d),m=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),h=e=>void t({search:t=>({...t,status:e===q?J:e})}),C=e=>void t({search:t=>({...t,severity:e===q?void 0:e})}),P=e=>void t({search:t=>({...t,kind:e===q?void 0:e})}),R=e=>void t({search:t=>({...t,...Oe(e)})}),B=ke(),U=De(),W=i(E.anomalies.resolveAnomaly),Y=(b(E.me.getMe,{host:Te})?.permissions??[]).includes(`admin.manage`),X=b(E.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:f,to:p,anomalyStatus:o===q?void 0:o,severity:s===q?void 0:s,source:l===q?void 0:l,kind:c===q?void 0:c}}),Z=(0,G.useMemo)(()=>{let e=new Set;for(let t of X??[])e.add(t.kind);return[...e].sort()},[X]),Q=n!==``||o!==`open`||s!==q||l!==q||c!==q||d.kind!==`relative`||d.from!==Le.from;function Ue(){u(q),t({search:{status:`open`},replace:!0})}async function We(e){if(await B({title:ie(),description:(0,K.jsxs)(K.Fragment,{children:[re(),` `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,ve(),` `,(0,K.jsx)(`strong`,{children:ee()}),`.`,` `,ye()]}),confirmLabel:ae()}))try{await W({anomalyId:e._id,status:`resolved`}),U.success(ne(),e.kind)}catch(e){U.error(a(),e)}}async function Ge(e){try{await W({anomalyId:e._id,status:`acknowledged`}),U.success(ce(),e.kind)}catch(e){U.error(A(),e)}}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`oc-admin__hint`,children:[te(),` `,(0,K.jsx)(`strong`,{children:se()}),` `,j(),` `,(0,K.jsx)(`strong`,{children:v()}),` `,Ce(),` `,(0,K.jsx)(`strong`,{children:k()}),` `,g(),` `,(0,K.jsx)(`span`,{className:`oc-filter__window`,children:he()})]}),(0,K.jsxs)(je,{q:n,onQChange:m,searchPlaceholder:ge(),timeRange:d,onTimeRangeChange:R,onReset:Ue,canReset:Q,children:[(0,K.jsxs)(F,{value:o,onValueChange:h,children:[(0,K.jsx)(V,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:xe()}),Ne.map(e=>(0,K.jsx)(z,{value:e.value,children:Pe(e.value)},e.value))]})]}),(0,K.jsxs)(F,{value:s,onValueChange:C,children:[(0,K.jsx)(V,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{placeholder:S()})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:be()}),Fe.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]}),(0,K.jsxs)(F,{value:l,onValueChange:u,children:[(0,K.jsx)(V,{size:`sm`,className:`w-32`,children:(0,K.jsx)(L,{placeholder:y()})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:T()}),Ie.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]}),(0,K.jsxs)(F,{value:c,onValueChange:P,children:[(0,K.jsx)(V,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{placeholder:x()})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:_()}),Z.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]})]}),(0,K.jsx)(Me,{title:_e(),rows:X,emptyHint:o===`open`?w():Se(),rowActions:e=>Y&&e.status===`open`?[{label:D(),onSelect:()=>void We(e)},{label:pe(),onSelect:()=>void Ge(e)}]:[],columns:[{header:r(),cell:e=>(0,K.jsx)(`span`,{className:`oc-traces__time`,children:I(e.at)}),sort:e=>e.at},{header:x(),cell:e=>(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:me(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,K.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:O({when:I(e.firstAt)}),children:fe({count:String(e.occurrenceCount)})}):(0,K.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:S(),cell:e=>(0,K.jsx)(Be,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:oe(),cell:e=>(0,K.jsx)(Ve,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:y(),cell:e=>(0,K.jsx)(M,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:de(),cell:e=>(0,K.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,K.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,K.jsx)($,{row:e})]}),sort:e=>e.message},{header:le(),cell:e=>(0,K.jsx)(ze,{row:e}),sort:e=>e.evidence??null},{header:ue(),cell:e=>e.correlationId?(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:He(e.correlationId)}):(0,K.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}var X=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]);function Z(e){if(!X.has(e.kind)||!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 ze({row:e}){let t=N();if(e.kind===`subagent.failure`){let n=Q(e);return(0,K.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,K.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,u()]}):null]})}let n=Z(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,K.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,u()]})}):(0,K.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=W(n.dominantCode),i=n.sampleCorrelationId;return(0,K.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,K.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,K.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,K.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,u()]}):null]})}function $({row:e}){let[t,n]=(0,G.useState)(!1),r=b(E.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[C(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,K.jsx)(P,{open:t,onOpenChange:n,children:(0,K.jsxs)(B,{className:`oc-anomaly__attachments-dialog`,children:[(0,K.jsx)(R,{children:(0,K.jsx)(U,{children:d()})}),r===void 0?(0,K.jsx)(`p`,{className:`oc-traces__muted`,children:s()}):r.length===0?(0,K.jsx)(`p`,{className:`oc-traces__muted`,children:h()}):(0,K.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,K.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,K.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,K.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Be({severity:e}){return(0,K.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function Ve({status:e}){return e===`open`?(0,K.jsx)(M,{variant:`destructive`,children:p()}):e===`acknowledged`?(0,K.jsx)(M,{variant:`secondary`,children:c()}):(0,K.jsx)(M,{variant:`outline`,children:m()})}function He(e){return e.length>8?e.slice(0,8):e}export{Y as AnomaliesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AA as r,BA as i,FA as a,Gl as o,HA as s,Hl as c,IA as l,Kl as u,LA as d,MA as f,NA as p,OA as m,PA as h,RA as g,Ul as _,VA as v,Wl as y,jA as b,jK as x,kA as S,ql as C,t as w,zA as T}from"./api-pyd1BsFz.js";import{Gn as E,Kn as D,a as O,et as k,ft as A,i as j,it as M,n as N,nt as P,o as F,rt as I,s as L,tt as R}from"./index-D_SQS2Hc.js";import{n as ee}from"./TimeRangePicker-FT0sN61o.js";import{t as z}from"./FilterBar-c4Vf46z3.js";import{t as B}from"./AdvancedFilter-DfWuJNZC.js";import{t as V}from"./DataTableShell-D_1TXULe.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:C()},{value:`realLabel`,label:u()},{value:`targetLabel`,label:o()},{value:`impersonated`,label:y()},{value:`resource`,label:_()},{value:`resourceId`,label:c()}];function q(){let e=D({from:`/settings/audit`}),t=E({from:`/settings/audit`}),n=e.q??``,o=e.action??G,c=e.impersonated??G,u=e.resource??G,_=j(e.from,e.to),y=(0,H.useMemo)(()=>L(e.adv),[e.adv]),{from:C,to:N}=ee(_),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,...F(e)})}),Q=e=>void t({search:t=>({...t,adv:O(e)}),replace:!0}),$=x(w.admin.listAudit,{filter:{q:n||void 0,from:C,to:N,action:o===G?void 0:o,resource:u===G?void 0:u,impersonated:c===G?void 0:c===`yes`,advanced:y.length>0?y: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!==``||o!==G||c!==G||u!==G||y.length>0||_.kind!==`relative`||_.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:[s(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:v()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:i(),timeRange:_,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(k,{value:o,onValueChange:J,children:[(0,U.jsx)(I,{size:`sm`,className:`w-40`,children:(0,U.jsx)(M,{placeholder:T()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(P,{value:G,children:g()}),te.map(e=>(0,U.jsx)(P,{value:e,children:e},e))]})]}),(0,U.jsxs)(k,{value:c,onValueChange:Y,children:[(0,U.jsx)(I,{size:`sm`,className:`w-40`,children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(P,{value:G,children:d()}),(0,U.jsx)(P,{value:`yes`,children:l()}),(0,U.jsx)(P,{value:`no`,children:a()})]})]}),(0,U.jsxs)(k,{value:u,onValueChange:X,children:[(0,U.jsx)(I,{size:`sm`,className:`w-40`,children:(0,U.jsx)(M,{placeholder:h()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(P,{value:G,children:p()}),ne.map(e=>(0,U.jsx)(P,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:y,onChange:Q}),(0,U.jsx)(V,{title:f(),rows:$,emptyHint:b(),columns:[{header:r(),cell:e=>A(e.at),sort:e=>e.at},{header:T(),cell:e=>e.action,sort:e=>e.action},{header:S(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:m(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:h(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$T as r,$h as i,AK as a,AT as o,BE as s,BT as c,CT as l,D as u,DE as d,DT as f,ET as p,FE as m,FT as h,GT as g,HT as _,IE as ee,IT as v,JT as y,Jh as b,KT as te,LE as ne,LT as re,ME as ie,MT as ae,NE as oe,NT as se,OE as ce,OK as le,OT as ue,PE as de,PT as fe,QT as pe,Qh as me,RE as he,RT as ge,ST as _e,TT as ve,UT as ye,Uh as be,VE as xe,VT as Se,WT as Ce,XT as we,Xh as Te,YT as Ee,Yh as De,ZT as Oe,Zh as ke,_T as Ae,aE as je,ag as Me,bT as Ne,cT as x,dT as Pe,dl as Fe,eE as Ie,eg as Le,fT as Re,fl as ze,gT as Be,gl as Ve,hT as He,iE as Ue,ig as We,jE as Ge,jK as S,jT as Ke,kT as qe,lT as Je,ll as Ye,mT as Xe,nE as Ze,ng as Qe,og as $e,pT as et,pl as tt,qT as nt,rE as rt,ra as it,rg as at,sT as C,t as w,tE as ot,tg as T,uT as st,ul as ct,vT as lt,wT as ut,wo as dt,xT as E,yT as ft,zT as pt}from"./api-pyd1BsFz.js";import{r as D}from"./dist-BtoqPlB7.js";import{t as mt}from"./chevrons-up-down-CVE2gmuK.js";import{i as ht,n as O,o as gt,r as _t,s as vt}from"./FieldLabel-DpY9Xev6.js";import{t as k}from"./button-CSHWa9fF.js";import{At as A,Bn as yt,Ft as j,G as bt,Gn as M,Ht as xt,K as St,Kn as Ct,N as wt,On as Tt,U as Et,Ut as Dt,Vn as Ot,W as kt,Wt as At,Z as jt,at as Mt,et as N,ft as Nt,it as P,jt as Pt,lt as Ft,mn as F,mt as It,nt as I,ot as Lt,pt as L,rt as R,st as Rt,tt as z,un as B,ut as zt,zn as Bt}from"./index-D_SQS2Hc.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as V,n as Ut,o as H,r as U,t as Wt}from"./table-DJJzEEXc.js";import{t as Gt}from"./FilterBar-c4Vf46z3.js";import{c as Kt,i as qt,n as Jt,o as W,r as Yt,s as Xt,t as Zt}from"./compatView-WF4iD3or.js";import{t as G}from"./dispatchErrorInfo-Bbo9tRSI.js";var Qt=u(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),$t=u(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),K=t(e(),1);function en(e){return e.filter(e=>e.state===`error`)}function tn(e){return e.reachable&&en(e.targets).length===0}function nn(e){return tn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function rn(e){return e.state===`error`&&e.lastErrorCode!==null}function an(e){return!!e.lastDownstreamRejectCode}function on(e){return!!e.lastLocalRefusalCode}function sn(e){return rn(e)||an(e)||on(e)}function q(e){return e.kind??`openclaw`}function cn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function ln(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,un={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function dn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function fn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function mn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Xt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function hn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=pn(t.key,e),a=pn(t.key,r);return i&&a?0:i?1:a?-1:n*mn(t.key,e,r)})}function gn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function _n(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>Z(e.label,t.label))}function vn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Xt(e,t)??Z(e,t))}var Q=n();function yn({connections:e,displayByInstance:t}){let[n,r]=(0,K.useState)(un),[i,a]=(0,K.useState)(null),o=(0,K.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(e.localRefusalCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null,lastLocalRefusalCode:e.lastLocalRefusalCode??null,lastLocalRefusalAt:e.lastLocalRefusalAt??null})),[e,t]),s=(0,K.useMemo)(()=>gn(o),[o]),c=(0,K.useMemo)(()=>_n(o),[o]),l=(0,K.useMemo)(()=>vn(o),[o]),u=(0,K.useMemo)(()=>hn(fn(o,n),i),[o,n,i]);function d(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ve()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Gt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:_e(),onReset:()=>r(un),canReset:dn(n),children:[(0,Q.jsxs)(N,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(R,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(P,{placeholder:Ne()})}),(0,Q.jsxs)(z,{children:[(0,Q.jsx)(I,{value:Y,children:E()}),s.map(e=>(0,Q.jsx)(I,{value:e,children:xn(e)},e))]})]}),(0,Q.jsxs)(N,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(R,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(P,{placeholder:ft()})}),(0,Q.jsxs)(z,{children:[(0,Q.jsx)(I,{value:Y,children:E()}),c.map(e=>(0,Q.jsx)(I,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(N,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(R,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(P,{placeholder:lt()})}),(0,Q.jsxs)(z,{children:[(0,Q.jsx)(I,{value:Y,children:E()}),l.map(e=>(0,Q.jsx)(I,{value:e,children:e},e))]})]})]}),u.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ae()}):(0,Q.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)($,{label:Be(),sortKey:`target`,sort:i,onSort:d}),(0,Q.jsx)($,{label:He(),sortKey:`state`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Xe(),sortKey:`instance`,sort:i,onSort:d}),(0,Q.jsx)($,{label:et(),sortKey:`host`,sort:i,onSort:d}),(0,Q.jsx)($,{label:Re(),sortKey:`version`,sort:i,onSort:d}),(0,Q.jsx)(V,{children:Pe()}),(0,Q.jsx)($,{label:st(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,Q.jsx)(Ut,{children:u.map(e=>(0,Q.jsx)(bn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(yt,{size:13,"aria-hidden":!0}):(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(mt,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function bn({r:e}){let t=rn(e)?G(e.lastErrorCode):null,n=an(e)?G(e.lastDownstreamRejectCode):null,r=on(e)?G(e.lastLocalRefusalCode):null;return(0,Q.jsxs)(K.Fragment,{children:[(0,Q.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(U,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(Sn,{state:e.state})}),(0,Q.jsx)(U,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(U,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:ut({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(U,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:L(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),sn(e)?(0,Q.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${L(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[it({label:r.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${L(e.lastLocalRefusalAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[l({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${L(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function xn(e){return e===`connected`?Je():e===`error`?x():C()}function Sn({state:e}){return e===`connected`?(0,Q.jsx)(A,{variant:`secondary`,children:Je()}):e===`error`?(0,Q.jsx)(A,{variant:`destructive`,children:x()}):(0,Q.jsx)(A,{variant:`outline`,children:C()})}function Cn(){return S(w.bridgeHealth.getBridgeHealth,{})}function wn(){let e=Cn(),t=S(w.compat.getBridgeCompat,{}),n=S(w.me.getMe,{host:jt})?.role===`admin`,r=S(w.admin.listInstances,n?{}:`skip`),i=S(w.agents.usageForInstances,n?{}:`skip`),a=M(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=ln(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Ct({from:`/settings/bridge`}),l=M({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Yt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(Tn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:g()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:Ce()}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(V,{children:tt()}),(0,Q.jsx)(V,{children:ze()}),(0,Q.jsx)(V,{children:Fe()}),(0,Q.jsx)(V,{children:ct()}),(0,Q.jsx)(V,{children:Ye()})]})}),(0,Q.jsx)(Ut,{children:i.flatMap(e=>{let t=wt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(U,{children:t.provider}),(0,Q.jsx)(U,{children:t.label}),(0,Q.jsx)(U,{children:(0,Q.jsxs)(A,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(Et,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Q.jsx)(bt,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(St,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(F,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(kt,{value:e.key,children:(0,Q.jsx)(En,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):null]})}function Tn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:W(t.bridgeVersion)}),i?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:We(),children:[`(`,i,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,at({build:t.buildVersion??`?`})]}):null,` · `,Qe(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?T():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:h()});let s=en(e.targets),c=!e.reachable,l=nn(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,p=Nt(e.checkedAt),m=e.startedAt==null?null:Nt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Q.jsx)(Bt,{size:22}):c||l===`gateways_unreachable`?(0,Q.jsx)($t,{size:22}):(0,Q.jsx)(B,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?fe():l===`gateways_unreachable`?o({count:u.length}):c?se():ae({count:s.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(Qt,{size:12,"aria-hidden":!0}),` `,Ke({time:p})]}),m?(0,Q.jsx)(`span`,{children:ue({time:m})}):null,a]}),l===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:qe({names:u.join(`, `)})}):null,c?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:G(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:f()})]})}function En({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=Zt(l.map(e=>e.state)),[f,m]=(0,K.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(F,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),d?(0,Q.jsx)(A,{variant:d===`beyond`||d===`defective`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:$e()}),(0,Q.jsx)(On,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Dn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>m(e=>!e),children:[f?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Ot,{size:13,"aria-hidden":!0}),p({count:t.length})]}),f?(0,Q.jsx)(yn,{connections:t,displayByInstance:c}):null]})}function Dn({protocol:e}){let[t,n]=(0,K.useState)(!1),r=e.coverage,i=e.drift??[],a=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ye(),i.length>0?(0,Q.jsx)(A,{variant:`destructive`,children:Se({count:i.length})}):a>0?(0,Q.jsx)(A,{variant:`destructive`,children:c()}):(0,Q.jsx)(A,{variant:`secondary`,children:_()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[pt({version:e.vendoredVersion}),r?` · `+ge({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:dt({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,i.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Ot,{size:13,"aria-hidden":!0}),re({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function On({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:a,providerName:o}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:Ve({provider:o})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:me({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:T()}),e?(0,Q.jsx)(Mn,{versions:e.validatedVersions}):null]}),a.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:a.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:W(e.version)}),(0,Q.jsx)(A,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function kn({instance:e,onClose:t}){return(0,Q.jsx)(Mt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Lt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(Ft,{children:[(0,Q.jsx)(zt,{children:xe({instance:e.displayName??e.name})}),(0,Q.jsx)(Rt,{children:s()})]}),(0,Q.jsx)(jn,{instance:e,onClose:t})]})})}function An({label:e,result:t}){return t?t.checked?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Q.jsx)(Bt,{"aria-hidden":!0}):(0,Q.jsx)(B,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?Ee():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,y()]}):null}function jn({instance:e,onClose:t}){let n=a(w.admin.upsertInstanceConfig),i=le(w.bridge.validateMediaPaths),o=Pt(),s=Vt(e.config?.contentLocale,void 0),[c,l]=(0,K.useState)(()=>ht(e.config??{},s)),[u,f]=(0,K.useState)(!1),[p,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(null),v=c.inboundMediaMode===`shared-fs`,y=c.mediaMode===`shared-fs`,b=v||y;async function re(){h(!0),_(null);try{_(await i({instanceName:e.name,inboundMediaMode:c.inboundMediaMode,mediaMode:c.mediaMode}))}catch(e){o.error(r(),e)}finally{h(!1)}}async function ae(){f(!0);try{let r=e.config??{};await n({instanceId:e._id,config:_t(c,r,s)}),t()}catch(e){o.error(oe(),e)}finally{f(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:he(),help:ie()}),(0,Q.jsxs)(N,{value:c.mediaMode,onValueChange:e=>l({...c,mediaMode:e}),children:[(0,Q.jsx)(R,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(P,{})}),(0,Q.jsx)(z,{children:vt.map(e=>(0,Q.jsx)(I,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ne(),help:Ge()}),(0,Q.jsxs)(N,{value:c.inboundMediaMode,onValueChange:e=>l({...c,inboundMediaMode:e}),children:[(0,Q.jsx)(R,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(P,{})}),(0,Q.jsx)(z,{children:gt.map(e=>(0,Q.jsx)(I,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:ee(),help:ce()}),(0,Q.jsx)(j,{type:`number`,min:1,max:4096,className:`w-full`,value:c.mediaMaxMb,onChange:e=>l({...c,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:je(),help:Ue()}),(0,Q.jsx)(j,{className:`w-full`,spellCheck:!1,value:c.inboundAgentMount,onChange:e=>l({...c,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:rt(),help:Ze()}),(0,Q.jsx)(j,{className:`w-full`,spellCheck:!1,value:c.outboundAgentMount,onChange:e=>l({...c,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(It,{checked:c.rehydration,onCheckedChange:e=>l({...c,rehydration:e===!0})}),(0,Q.jsx)(O,{label:m(),help:d()})]}),b&&g!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(B,{"aria-hidden":!0}),te({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{label:Oe(),result:g.inbound}),(0,Q.jsx)(An,{label:we(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:pe()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(B,{"aria-hidden":!0}),nt()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void re(),disabled:p,children:[p?(0,Q.jsx)(Tt,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,p?Ie():ot()]}),(0,Q.jsx)(k,{size:`sm`,onClick:()=>void ae(),disabled:u,children:de()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(xt,{children:[(0,Q.jsx)(At,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?ke():Te({count:e.length}),(0,Q.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Dt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:De()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(A,{variant:`secondary`,children:e},e))})]})]})}export{wn as BridgeTab,kn as InstanceConfigDialog};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$ as r,A as i,AK as a,A_ as o,Af as s,B as c,Df as l,E_ as u,Ef as d,F as f,G as p,Gg as m,H as h,I as g,J as _,K as v,L as y,LK as ee,M as b,MK as x,M_ as S,Mf as te,N as ne,Nf as re,O as ie,OK as C,Of as w,P as ae,Q as oe,R as se,TK as ce,T_ as le,Tf as ue,U as T,V as de,W as fe,X as pe,Y as me,Z as he,cg as E,dg as ge,fg as D,hg as _e,hl as ve,j as ye,jK as O,jf as k,k as be,kK as xe,kf as Se,lg as A,mg as j,pg as Ce,q as we,sg as M,t as N,ug as Te,wf as Ee,xK as P,z as De,zE as Oe,zK as F}from"./api-pyd1BsFz.js";import{t as I}from"./button-CSHWa9fF.js";import{B as L,Ft as R,H as ke,V as Ae,et as z,it as B,mt as V,nt as H,rt as U,tt as W,un as je}from"./index-D_SQS2Hc.js";import{a as Me}from"./compatView-WF4iD3or.js";/* empty css */var G=t(e(),1),Ne=(e,t,n)=>r=>{let i={...r.queries},a=r.nextPageKey,o=r.nextPageKey+1,s=r.nextPageKey+2;i[a]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,endCursor:t}}},i[o]={query:r.query,args:{...r.args,paginationOpts:{...r.queries[e].args.paginationOpts,cursor:t,endCursor:n}}};let c={...r.ongoingSplits};return c[e]=[a,o],{...r,nextPageKey:s,queries:i,ongoingSplits:c}},Pe=e=>t=>{let n=t.ongoingSplits[e];if(n===void 0)return t;let r={...t.queries};delete r[e];let i={...t.ongoingSplits};delete i[e];let a=t.pageKeys.slice(),o=t.pageKeys.findIndex(t=>t===e);return o>=0&&(a=[...t.pageKeys.slice(0,o),...n,...t.pageKeys.slice(o+1)]),{...t,queries:r,pageKeys:a,ongoingSplits:i}};function Fe(e,t,n){let{user:r}=Re(e,t,n,!0);return r}var Ie=Symbol(`includePageKeys`),Le=Symbol(`page`);function Re(e,t,n,r=!0){if(typeof n?.initialNumItems!=`number`||n.initialNumItems<0)throw Error(`\`options.initialNumItems\` must be a positive number. Received \`${n?.initialNumItems}\`.`);let i=t===`skip`,a=i?{}:t,o=x(e),s=(0,G.useMemo)(()=>()=>{let t=ze();return{query:e,args:a,id:t,nextPageKey:1,pageKeys:i?[]:[0],queries:i?{}:{0:{query:e,args:{...a,paginationOpts:{numItems:n.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:i}},[JSON.stringify(F(a)),o,n.initialNumItems,i]),[c,l]=(0,G.useState)(s),u=c;(x(e)!==x(c.query)||JSON.stringify(F(a))!==JSON.stringify(F(c.args))||i!==c.skip)&&(u=s(),l(u));let d=xe().logger,f=ce(u.queries),p=n[Ie]??!1,[m,h,g]=(0,G.useMemo)(()=>{let e,t=[];for(let i of u.pageKeys){if(e=f[i],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof ee&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return d.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),l(s),[[],void 0,void 0];if(r)throw e;return[t,void 0,e]}let a=u.ongoingSplits[i];if(a===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>n.initialNumItems*2)&&l(Ne(i,e.splitCursor,e.continueCursor)):f[a[0]]!==void 0&&f[a[1]]!==void 0&&l(Pe(i)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...p?e.page.map(e=>({...e,[Le]:i.toString()})):e.page)}return[t,e,void 0]},[f,u.pageKeys,u.ongoingSplits,n.initialNumItems,s,d,p,r]);return{user:{results:m,...(0,G.useMemo)(()=>{if(g!==void 0)return{status:`Error`,isLoading:!1,error:g,loadMore:()=>{}};if(h===void 0)return u.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(h.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=h.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,l(t=>{let r=[...t.pageKeys,t.nextPageKey],i={...t.queries};return i[t.nextPageKey]={query:t.query,args:{...t.args,paginationOpts:{numItems:n,cursor:e,id:t.id}}},{...t,nextPageKey:t.nextPageKey+1,pageKeys:r,queries:i}}))}}},[g,h,u.nextPageKey])},internal:{state:u}}}var K=0;function ze(){return K++,K}var Be=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Ve(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 q=[`auto`,`hybrid`,`tool`,`off`];function He(e){switch(e){case`auto`:return pe();case`hybrid`:return me();case`tool`:return _();default:return we()}}function J(e){return{injection:e.injection??`auto`,defaultSources:e.defaultSources,...e.config?{config:e.config}:{}}}function Y(e){return typeof e==`string`&&q.includes(e)}function X(e){return{injection:Y(e.injection)?e.injection:`auto`,sources:e.defaultSources.filter(t=>e.sources.some(e=>e.id===t))}}function Z(e,t){let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))}function Ue(e,t,n){let r=n?e.defaultWriteRefused===`scope_refused`?h():We(e)?b():null:T(),i=X(e),a=t.injection!==i.injection||!Z(t.sources,i.sources),o=new Set(e.sources.map(e=>e.id)),s=t.sources.length>0&&t.sources.length<=16&&t.sources.every(e=>o.has(e));return{readOnlyReason:r,dirty:a,valid:s,invalidReason:s?null:p()}}function We(e){return(e.contract??1)<2&&e.ownAllowlist===!1}function Ge(e,t,n){let r=t.sources.includes(n)?t.sources.filter(e=>e!==n):[...t.sources,n];return{...t,sources:e.sources.map(e=>e.id).filter(e=>r.includes(e))}}function Q(e){return e.ok?null:e.code===`scope_refused`?h():e.code===`stale_default`?de():e.code===`write_unknown`||e.code===`not_confirmed`?se():e.code===`not_applied`?y():e.code===`default_too_large`?i():e.code===`allowlist_too_large`?ye():e.code===`plugin_too_old`?b():e.code===`source_not_allowed`?ne():e.code===`plugin_config_lag`?ae():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?fe():c({code:e.code})}function Ke(e,t){let n=J(e),r=J(t);if(n.injection!==r.injection||!Z(n.defaultSources,r.defaultSources))return!0;let i=n.config,a=r.config;return i===void 0||a===void 0?i!==a:i.injection!==a.injection||!((e,t)=>e===null||t===null?e===t:e.length===t.length&&e.every((e,n)=>e===t[n]))(i.sources,a.sources)}var $=n();function qe({instanceName:e,row:t,supported:n}){let r=C(N.knowledge.setAgentKnowledgeDefault),[i,a]=(0,G.useState)(t),[o,s]=(0,G.useState)(()=>X(t)),[c,l]=(0,G.useState)(`idle`),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!1),m=e=>{a(e),s(X(e)),d(null)},h=Ke(i,t);(0,G.useEffect)(()=>{f&&h&&(p(!1),m(t))},[f,h]);let g=Ue(i,o,n),_=g.readOnlyReason===null;async function y(){l(`saving`),d(null);try{let n=Q(await r({instanceName:e,agentId:t.agentId,injection:o.injection,sources:o.sources,expected:J(i)}));d(n),l(n===null?`done`:`idle`),n===null&&p(!0)}catch(e){d(Q({ok:!1,code:String(e?.message??`error`).slice(0,60)})),l(`idle`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,"data-knowledge-agent":t.agentId,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:t.agentId}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsxs)(z,{value:o.injection,onValueChange:e=>{Y(e)&&s({...o,injection:e})},disabled:!_,children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":he(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(W,{children:q.map(e=>(0,$.jsx)(H,{value:e,children:He(e)},e))})]})}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:v()}),t.sources.map(e=>(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:_?`pointer`:`default`},title:e.description||void 0,children:[(0,$.jsx)(V,{checked:o.sources.includes(e.id),onCheckedChange:()=>s(Ge(t,o,e.id)),disabled:!_,"aria-label":e.label,"data-knowledge-default-source":e.id}),(0,$.jsx)(`span`,{children:e.label})]},e.id)),h&&!f?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[be(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>m(t),children:ie()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:De()}),_?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(I,{size:`sm`,disabled:!g.dirty||!g.valid||c===`saving`,onClick:()=>void y(),children:c===`saving`?S():A()})}):(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:g.readOnlyReason}),_&&g.dirty&&g.invalidReason!==null?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:g.invalidReason}):null,c===`done`&&u===null?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,u===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:u})]})]})}function Je({instanceName:e}){let t=O(N.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:i,loadMore:a}=Fe(N.knowledge.agentKnowledgePage,{instanceName:e},{initialNumItems:50});return t===void 0||t.provider!==`openclaw`||n.length===0&&i!==`CanLoadMore`?null:(0,$.jsxs)(`section`,{className:`oc-cdefaults__row`,"aria-label":r(),children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:r()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:T()}),n.map(n=>(0,$.jsx)(qe,{instanceName:e,row:n,supported:t.supported},n.agentId)),i===`CanLoadMore`||i===`LoadingMore`?(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:g({shown:n.length})}),(0,$.jsx)(I,{variant:`outline`,size:`sm`,disabled:i===`LoadingMore`,onClick:()=>a(50),"data-knowledge-load-more":!0,children:f()})]}):null]})}function Ye({instance:e}){let t=a(N.admin.upsertInstanceConfig),n=O(N.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,o]=(0,G.useState)(r),[c,l]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{o(r),l(`idle`)},[e._id,r]);let u=`__none__`,d=i!==r;async function f(){l(`saving`);try{let n={...e.config??{}};i===``||i===u?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),l(`done`)}catch{l(`error`)}}let p=n?.agents??[];return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:s()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:Se()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(z,{value:i===``?u:i,onValueChange:e=>o(e===u?``:e),children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":s(),children:(0,$.jsx)(B,{placeholder:w()})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(H,{value:u,children:w()}),p.map(e=>(0,$.jsx)(H,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,$.jsx)(I,{size:`sm`,disabled:!d||c===`saving`,onClick:()=>void f(),children:c===`saving`?S():A()})]}),c===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,c===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:M()}):null]})}function Xe({instance:e}){let t=a(N.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(r===null?``:String(r)),[u,f]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{o(n),c(r===null?``:String(r)),f(`idle`)},[e._id,n,r]);let p=s.trim(),m=p===``?null:/^\d+$/.test(p)?Number.parseInt(p,10):NaN,h=!i||m===null||Number.isInteger(m)&&m>=4e3&&m<=6e4,g=i!==n||(m??null)!==r;async function _(){f(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||m===null||Number.isNaN(m)?delete n.curationBudgetChars:n.curationBudgetChars=m,await t({instanceId:e._id,config:n}),f(`done`)}catch{f(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,$.jsx)(V,{checked:i,onCheckedChange:e=>o(e===!0),"aria-label":k()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:k()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!h,"aria-label":l(),disabled:!i}),(0,$.jsx)(I,{size:`sm`,disabled:!g||!h||u===`saving`,onClick:()=>void _(),children:u===`saving`?S():A()})]}),h?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:d()}),u===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,u===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:M()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ue()})]})}function Ze({instance:e}){let t=a(N.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,G.useState)(n===null?``:String(n)),[o,s]=(0,G.useState)(`idle`);(0,G.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,u=l===null||Number.isInteger(l)&&l>=1e3&&l<=2e5,d=(l??null)!==n;async function f(){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,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:re()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!u}),(0,$.jsx)(I,{size:`sm`,disabled:!d||!u||o===`saving`,onClick:()=>void f(),children:o===`saving`?S():A()})]}),u?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:Ee()}),o===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:E()}):null,o===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:M()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:te()})]})}function Qe(){let e=C(N.agentFiles.getChatDefaults),[t,n]=(0,G.useState)({status:`loading`}),r=O(N.admin.listInstances,{}),[i,a]=(0,G.useState)(null);(0,G.useEffect)(()=>{!r||r.length===0||(!i||!r.some(e=>e.name===i))&&a(r[0].name)},[r,i]);let s=(r?.length??0)>1,c=r!==void 0&&r.length===0,l=O(N.compat.forInstance,i?{instanceName:i}:`skip`),d=i?Ae(l,`configDefaults`):`loading`,f=d===`loading`?null:d.blocked,p=(0,G.useMemo)(()=>s&&i?{instanceName:i}:{},[s,i]),h=(0,G.useRef)(0),g=(0,G.useCallback)(async()=>{let t=++h.current;n({status:`loading`});try{let r=Ve(await e(p));if(h.current!==t)return;n({status:`done`,current:r})}catch{if(h.current!==t)return;n({status:`error`})}},[e,p]);(0,G.useEffect)(()=>{f===!1&&(s&&!i||g())},[g,f,s,i]);let _=t.status===`done`?t.current:null,v=(0,G.useMemo)(()=>Be.map(e=>({id:e,label:ke(e)})),[]),y=(0,G.useMemo)(()=>[{id:`fast`,label:u()},{id:`standard`,label:le()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:_e()}),s&&i?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:m()}),(0,$.jsxs)(z,{value:i,onValueChange:e=>a(e),children:[(0,$.jsx)(U,{size:`sm`,"aria-label":m(),children:(0,$.jsx)(B,{})}),(0,$.jsx)(W,{children:(r??[]).map(e=>(0,$.jsx)(H,{value:e.name,children:e.name},e.name))})]})]}):null,c?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:Oe()}):d===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:P()}):d.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(je,{size:14,"aria-hidden":!0}),` `,Me(d.gatewayVersion,d.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:P()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[Te(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void g(),children:o()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()}),(0,$.jsx)(L,{field:`thinkingLevel`,options:v,value:_?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:j()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:Ce()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:D()}),(0,$.jsx)(L,{field:`fastMode`,options:y,value:_===null||_.fastModeDefault===null?null:_.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:D()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ge()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:ve()})]}),(()=>{let e=r?.find(e=>e.name===(i??r[0]?.name));return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ze,{instance:e}),(0,$.jsx)(Xe,{instance:e}),(0,$.jsx)(Ye,{instance:e}),(0,$.jsx)(Je,{instanceName:e.name})]}):null})()]})}export{Qe as ChatDefaultsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,AK as i,AN as a,BN as o,CN as s,DN as c,EN as l,FN as u,GN as d,HN as f,IN as p,JN as ee,KN as te,LN as ne,Ld as m,MN as h,NN as g,ON as _,PN as re,QN as ie,RN as ae,SN as v,TN as y,UN as b,VN as x,WN as S,XN as C,YN as w,ZN as T,_N as E,aP as D,bN as O,cN as k,cP as A,dN as j,eP as M,fN as N,gN as P,hN as F,iP as I,jK as L,jN as R,kN as z,lN as B,mN as V,nP as H,oN as U,oP as oe,pN as W,qN as G,rP as K,sN as q,sP as se,t as J,tP as ce,uN as le,vN as ue,wN as de,xN as fe,yN as pe,zN as me,zd as he}from"./api-pyd1BsFz.js";import{t as ge}from"./button-CSHWa9fF.js";import{ft as _e,q as Y}from"./index-D_SQS2Hc.js";import{t as ve}from"./DataTableShell-D_1TXULe.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>A(),incorrect:()=>se(),incoherence:()=>oe(),formatting:()=>D(),latency:()=>I(),api_error:()=>K(),other:()=>H()},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:M()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:r()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:ce()})}function be({data:e,reference:t,closeReason:n}){let r=e.snapshot,a=i(J.feedback.respondToFeedback),[s,c]=(0,X.useState)(e.thread),[m,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(!1);async function E(){let t=m.trim();if(!(!t||v)){y(!0);try{await a({feedbackId:e._id,text:t}),c(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),_(``)}finally{y(!1)}}}let D=[];try{D=r.contextJson?JSON.parse(r.contextJson):[]}catch{D=[]}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?` · ${ie()}`:``,r.openclawModel?` · ${r.openclawModel}`:``,r.openclawRuntime?` (${r.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:l(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:T()}),(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:N()}),(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:C()}),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`?w():e.authorRole===`agent`?e.authorLabel??he():ee()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:G()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:te(),value:m,maxLength:2e3,rows:3,onChange:e=>_(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 E(),disabled:!m.trim()||v,children:v?d():S()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:b()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.messageText||f()})]}),r.clientInfo?.sourceWasOpen&&r.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:x()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.displayedText||f()})]}):null,r.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:o()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:r.promptText})]}):null,D.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:me({count:r.contextCount??D.length,truncated:r.contextTruncated?ae():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:D.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:ne()}),(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:p()}),(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:u()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[r.clientInfo?.language,r.clientInfo?.timezone,r.clientInfo?.theme?re({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:[g(),` `,r.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,h()]})]}):null,r.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:r.clientInfo.userAgent}):null]})]})]})}function xe(){let e=L(J.feedback.listForAdmin,{}),t=i(J.feedback.readSnapshot),n=i(J.feedback.deleteFeedback),r=Y(),[o,l]=(0,X.useState)(null),[u,d]=(0,X.useState)({});async function f(e){if(o===e._id){l(null);return}if(!u[e._id]){let n=await t({feedbackId:e._id});d(t=>({...t,[e._id]:n}))}l(e._id)}async function p(e){await r({title:k(),description:q(),confirmLabel:U(),destructive:!0})&&(await n({feedbackId:e._id}),o===e._id&&l(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[R(),` `,(0,Z.jsx)(`strong`,{children:a()}),` `,z()]}),(0,Z.jsx)(ve,{title:_(),rows:e,emptyHint:c(),isExpanded:e=>o===e._id&&!!u[e._id],renderExpanded:e=>u[e._id]?(0,Z.jsx)(be,{data:u[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:y(),cell:e=>_e(e.at),sort:e=>e.at},{header:de(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:s(),cell:e=>e.messageRole===`user`?v():fe(),sort:e=>e.messageRole},{header:O(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${pe({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:ue(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:E(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:P(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:F()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:V()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:m()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:W()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:o===e._id?j():le(),onSelect:()=>void f(e)},{label:B(),onSelect:()=>void p(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AG as r,AK as ee,BG as te,CG as i,CK as ne,DG as a,EG as o,FG as re,HG as ie,Hd as ae,IG as oe,LG as s,MG as c,ML as l,NG as u,OG as d,PG as se,RG as f,SG as ce,TG as p,Ud as m,VG as le,_G as ue,bG as de,cG as fe,dG as pe,fG as me,gG as he,hG as h,jG as g,jK as ge,kG as _,lG as _e,mG as ve,pG as ye,sG as be,t as v,uG as y,vG as b,wG as x,xG as S,xK as C,yG as w,zG as T}from"./api-pyd1BsFz.js";import{t as E}from"./button-CSHWa9fF.js";import{At as D,Ct as O,Dt as k,Et as A,Fn as j,In as M,It as N,Lt as xe,Ot as Se,Rt as P,St as Ce,Tt as we,Vt as Te,dn as Ee,et as F,gn as De,it as I,jt as Oe,kt as ke,mt as Ae,nt as L,rt as R,tt as z,wt as je}from"./index-D_SQS2Hc.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-DJJzEEXc.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return g();case`audio`:return r();case`video`:return _();case`pdf`:return d();case`document`:return a();case`archive`:return o();default:return p()}}function q(){let[e,t]=(0,U.useState)(G),[n,r]=(0,U.useState)(G),[a,o]=(0,U.useState)(G),[d,p]=(0,U.useState)(G),[g,_]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=ee(v.files.softDelete),Y=Oe();function Ie(){t(G),r(G),o(G),p(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(ve())}catch(e){Y.error(ye(),e)}}let X=ge(v.files.listMine,{direction:e===G?void 0:e,chatId:n===G?void 0:n,instanceName:a===G?void 0:a,category:d===G?void 0:d,includeAutoGenerated:g||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(ne(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:C()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==G||n!==G||a!==G||d!==G;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}),(0,W.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,W.jsxs)(F,{value:e,onValueChange:t,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":le(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:te()}),(0,W.jsx)(L,{value:`inbound`,children:T()}),(0,W.jsx)(L,{value:`outbound`,children:f()})]})]}),(0,W.jsxs)(F,{value:n,onValueChange:r,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":s(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:oe()}),Q.chats.map(e=>(0,W.jsx)(L,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,W.jsxs)(F,{value:a,onValueChange:o,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":re(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:se()}),Q.instances.map(e=>(0,W.jsx)(L,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(F,{value:d,onValueChange:p,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":u(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:c()}),Q.categories.map(e=>(0,W.jsx)(L,{value:e,children:K(e)},e))]})]}),(0,W.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,W.jsx)(Ae,{checked:g,onCheckedChange:e=>_(e===!0),"aria-label":m()}),(0,W.jsx)(`span`,{children:m()})]}),$?(0,W.jsxs)(E,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,W.jsx)(De,{size:14,"aria-hidden":!0}),ue()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?fe():_e()}):(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:x()}),(0,W.jsx)(B,{children:i()}),(0,W.jsx)(B,{children:ce()}),(0,W.jsx)(B,{children:S()}),(0,W.jsx)(B,{children:de()}),(0,W.jsx)(B,{className:`text-right`,children:w()})]})}),(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)(D,{variant:`outline`,style:{marginLeft:6},children:ae()}):null]}),(0,W.jsx)(H,{title:e.mimeType,children:K(e.category)}),(0,W.jsx)(H,{children:(0,W.jsx)(D,{variant:`secondary`,children:e.direction===`inbound`?T():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)(N,{children:[(0,W.jsx)(Te,{asChild:!0,children:(0,W.jsx)(E,{variant:`ghost`,size:`icon`,"aria-label":he(),children:(0,W.jsx)(j,{size:16})})}),(0,W.jsxs)(xe,{align:`end`,children:[e.url?(0,W.jsx)(P,{asChild:!0,children:(0,W.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,W.jsx)(M,{size:14}),b()]})}):(0,W.jsxs)(P,{disabled:!0,children:[(0,W.jsx)(M,{size:14}),y()]}),(0,W.jsxs)(P,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Ee,{size:14}),h()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:be({cap:Be})}):null]}),(0,W.jsx)(Ce,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,W.jsxs)(we,{children:[(0,W.jsxs)(Se,{children:[(0,W.jsx)(ke,{children:me()}),(0,W.jsx)(A,{children:pe()})]}),(0,W.jsxs)(k,{children:[(0,W.jsx)(je,{children:l()}),(0,W.jsx)(O,{onClick:()=>void Le(),children:h()})]})]})})]})}export{q as FilesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$_ as r,$v as i,AK as a,Av as o,Bv as s,Cv as c,D as l,Dv as u,Ev as d,Fv as f,G_ as p,Gv as m,Hv as h,Iv as g,J_ as _,Jv as v,K_ as y,Kv as b,Lv as ee,Mv as x,Nv as te,Ov as S,Pv as C,Q_ as w,Qv as T,Rv as ne,Sv as E,Tv as D,Uv as O,Vv as re,W_ as k,Wv as A,X_ as j,Xv as M,Y_ as ie,Yv as ae,Z_ as N,Zv as oe,_v as se,av as P,bv as F,cv as I,dv as ce,ev as le,fv as ue,gv as de,hv as L,iv as fe,jK as R,jv as pe,kv as me,lv as he,mv as ge,nv as _e,ov as ve,pv as ye,q_ as be,qv as xe,rv as Se,sv as Ce,t as z,tv as we,uv as Te,vv as Ee,wv as B,xv as De,yv as Oe,zv as ke}from"./api-pyd1BsFz.js";import{t as Ae}from"./x-BAZ6f_9l.js";import{t as V}from"./button-CSHWa9fF.js";import{At as H,Ft as U,G as je,Hn as Me,K as W,U as Ne,Vn as Pe,W as G,Z as Fe,_ as Ie,at as Le,cn as Re,et as ze,fn as K,it as Be,jt as q,lt as Ve,mn as J,mt as Y,nt as He,ot as Ue,pn as X,q as We,rt as Ge,st as Ke,tt as qe,ut as Je}from"./index-D_SQS2Hc.js";import{t as Ye}from"./FilterBar-c4Vf46z3.js";import{t as Xe}from"./DataTableShell-D_1TXULe.js";import{t as Z}from"./DetailChips-S9d12ANU.js";var Ze=l(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),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 F();case`user`:return Oe();case`pending`:return Ee();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=R(z.groups.listGroups,{}),t=R(z.me.getMe,{host:Fe})?.role===`admin`,n=a(z.groups.createGroup),r=a(z.groups.updateGroup),o=a(z.groups.deleteGroup),c=We(),l=q(),[u,d]=(0,Q.useState)(!1),[p,_]=(0,Q.useState)(null),[S,w]=(0,Q.useState)(it),[E,D]=(0,Q.useState)(null),[k,j]=(0,Q.useState)(``),ie=(0,Q.useMemo)(()=>{if(!e)return e;let t=k.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,k]);function N(){_(null),w(it),d(!0)}function se(e){_(e),w({name:e.name,description:e.description??``}),d(!0)}async function P(){try{p?await r({groupId:p._id,name:S.name,description:S.description}):await n({name:S.name,description:S.description||void 0}),w(it),_(null),d(!1)}catch(e){l.error(be(),e)}}async function F(e){if(await c({title:C({name:e.name}),description:te(),confirmWord:e.name,confirmLabel:x(),cancelLabel:s(),destructive:!0}))try{await o({groupId:e._id})}catch(e){l.error(y(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:T()}),(0,$.jsx)(Ye,{q:k,onQChange:j,onReset:()=>j(``),canReset:k!==``,searchPlaceholder:m()}),(0,$.jsx)(Xe,{title:i(),rows:ie,addLabel:oe(),onAdd:t?N:void 0,emptyHint:M(),columns:[{header:ae(),cell:e=>e.name,sort:e=>e.name},{header:v(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(Re,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(X,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:xe(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(J,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:b(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(Ze,{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:A(),onSelect:()=>D({groupId:e._id,name:e.name})},...t?[{label:O(),onSelect:()=>se(e)},{label:h(),variant:`destructive`,onSelect:()=>void F(e)}]:[]]}),(0,$.jsx)(Ie,{open:u,onOpenChange:d,title:p?ne():ke(),description:ee(),canSubmit:!!S.name.trim(),onSubmit:P,submitLabel:re(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:g()}),(0,$.jsx)(U,{value:S.name,onChange:e=>w({...S,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:f()}),(0,$.jsx)(U,{value:S.description,onChange:e=>w({...S,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:E?.groupId??null,groupName:E?.name??``,open:E!==null,onOpenChange:e=>{e||D(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)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Me,{size:14,"aria-hidden":!0}),c()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":De({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[E(),(0,$.jsx)(Pe,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=R(z.groups.getGroup,n&&e?{groupId:e}:`skip`),s=R(z.groups.listAssignableInstances,n?{}:`skip`),c=R(z.groups.listAssignableUsers,n?{}:`skip`),l=a(z.groups.addMember),f=a(z.groups.removeMember),m=a(z.groups.bulkSetMembers),h=a(z.groups.setGroupManager),g=q(),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[ee,x]=(0,Q.useState)(`members`),[te,C]=(0,Q.useState)(1),[T,ne]=(0,Q.useState)(new Set),E=(0,Q.useRef)(null),O=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),re=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),k=i?.viewerIsAdmin===!0,A=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[i]);(0,Q.useEffect)(()=>{v(``),b(``),x(`members`),C(1),E.current=null},[n,e]),(0,Q.useEffect)(()=>{C(1)},[_]),(0,Q.useEffect)(()=>{n&&i&&e&&E.current!==e&&(E.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let M=(0,Q.useMemo)(()=>c?Qe(c,_,T):[],[c,_,T]);async function ae(t,n){if(e)try{n?await f({groupId:e,userId:t}):await l({groupId:e,userId:t})}catch(e){g.error(p(),e)}}async function oe(t,n){if(e)try{await h({groupId:e,userId:t,manager:!n})}catch(e){g.error(ie(),e)}}let P=nt(M,e=>O.has(e.userId)),F=M.filter(e=>O.has(e.userId)).length,I=rt(M,te,ot);async function ce(){if(!e||M.length===0)return;let t=M.map(e=>e.userId);try{await m({groupId:e,userIds:t,member:P!==`all`})}catch(e){g.error(p(),e)}}return(0,$.jsx)(Le,{open:n,onOpenChange:r,children:(0,$.jsxs)(Ue,{className:`oc-access`,children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Je,{children:pe({name:t})}),(0,$.jsx)(Ke,{children:o()})]}),(0,$.jsxs)(Ne,{value:ee,onValueChange:x,className:`oc-access__tabs`,children:[(0,$.jsxs)(je,{className:`w-full`,children:[(0,$.jsxs)(W,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Re,{size:13,"aria-hidden":!0}),me(),i?(0,$.jsx)(H,{variant:`secondary`,className:`oc-access__tabcount`,children:O.size}):null]}),(0,$.jsxs)(W,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),u(),i?(0,$.jsx)(H,{variant:`secondary`,className:`oc-access__tabcount`,children:A.size}):null]}),(0,$.jsxs)(W,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ze,{size:13,"aria-hidden":!0}),ve(),i?(0,$.jsx)(H,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(G,{value:`members`,children:c===void 0||i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:L()}):c.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ye()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{value:_,onChange:e=>v(e.target.value),placeholder:S(),className:`oc-access__search`}),M.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:D()}):(0,$.jsxs)($.Fragment,{children:[M.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:P===`all`?!0:P===`some`?`indeterminate`:!1,onCheckedChange:()=>void ce(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()}),(0,$.jsxs)(H,{variant:`outline`,className:`oc-access__count`,children:[F,` / `,M.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=O.has(e.userId),n=et(e),r=re.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:t,onCheckedChange:()=>void ae(e.userId,t),"aria-label":se({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)(H,{variant:`outline`,className:`oc-access__role`,children:tt(e.role)}),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&k?(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?j():N(),title:r?j():N(),onClick:()=>void oe(e.userId,r),children:(0,$.jsx)(X,{size:15,"aria-hidden":!0})}):t&&r?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":w(),title:w(),children:(0,$.jsx)(X,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:I.page,pageCount:I.pageCount,onPage:C})]})]})}),(0,$.jsx)(G,{value:`agents`,children:s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:L()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ue()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{value:y,onChange:e=>b(e.target.value),placeholder:d(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:A,query:y},`${e}-${t._id}`))})]})}),(0,$.jsx)(G,{value:`charts`,children:(0,$.jsx)(ut,{groupId:e})})]})]})})}function lt({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let o=R(z.groups.listAssignableAgents,{instanceName:t}),s=a(z.groups.assignAgentToGroup),c=a(z.groups.removeAgentFromGroup),l=a(z.groups.bulkSetGroupAgents),u=q(),[d,f]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{f(1)},[i]),!e)return null;let p=$e(o?.agents??[],i),m=o?.discovery&&!o.discovery.lastPollOk;if(i.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),g=nt(h,e=>r.has(`${t}/${e.agentId}`)),_=rt(p,d,ot);async function v(n,r){try{r?await c({groupId:e,instanceName:t,agentId:n}):await s({groupId:e,instanceName:t,agentId:n})}catch(e){u.error(k(),e)}}async function y(){if(h.length===0)return;let n=h.map(e=>e.agentId);try{await l({groupId:e,instanceName:t,agentIds:n,assigned:g!==`all`})}catch(e){u.error(k(),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)(H,{variant:`outline`,className:`oc-access__kind`,children:n}),m?(0,$.jsx)(H,{variant:`outline`,className:`oc-access__stale`,children:he()}):null]}),o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ge()}):p.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:m?Te():ce()}):(0,$.jsxs)($.Fragment,{children:[h.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:g===`all`?!0:g===`some`?`indeterminate`:!1,onCheckedChange:()=>void y(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()})]}):null,_.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(Y,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void v(e.agentId,i),"aria-label":de({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":Ce(),title:Ce(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):null,a?(0,$.jsx)(H,{variant:`outline`,className:`oc-access__gone`,children:I()}):null]},e.agentId)}),(0,$.jsx)(st,{page:_.page,pageCount:_.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=R(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=a(z.charts.assignChartToGroup),i=a(z.charts.removeChartFromGroup),o=a(z.charts.setGroupDefaultChart),s=a(z.charts.addChartToGroupPool),c=a(z.charts.removeChartFromGroupPool),l=q();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:L()});let{pool:u,addable:d,canManagePool:f}=t;if(u.length===0&&!f)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:P()});async function p(t,r){try{r?await i({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){l.error(_(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){l.error(_(),e)}}async function h(t){try{await s({groupId:e,chartKey:t})}catch(e){l.error(_(),e)}}async function g(t){try{await c({groupId:e,chartKey:t})}catch(e){l.error(_(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:u.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(Y,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":we({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":le(),title:le(),children:(0,$.jsx)(K,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:r()}):null,f?(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":_e({name:e.name}),title:_e({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?d.length>0?(0,$.jsxs)(ze,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)(Ge,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Be,{placeholder:Se()})}),(0,$.jsx)(qe,{children:d.map(e=>(0,$.jsx)(He,{value:e.chartKey,children:e.name},e.chartKey))})]}):u.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:fe()}):null:null]})}export{at as GroupsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$A as r,$j as i,AE as a,AK as o,AM as s,Aj as c,Bj as l,Bt as u,CM as d,Ca as f,Cj as p,DM as m,Da as h,Dj as g,Dz as _,EM as v,Ea as y,Ej as b,Ez as x,Fj as S,Ft as ee,GA as C,Gj as w,Hj as T,Ht as E,Ij as D,It as O,JA as k,Jf as te,Jj as ne,KA as re,Kj as ie,Lj as ae,Lt as oe,MM as se,Mj as ce,Nj as le,OK as A,OM as ue,Oa as de,Oj as fe,Pj as pe,QA as me,Qj as he,Rj as ge,Rt as _e,SM as ve,Sa as ye,Sj as be,TM as xe,Ta as Se,Tj as Ce,UA as we,Uj as Te,Ut as Ee,Vj as De,Vt as Oe,WA as j,Wj as ke,Wt as Ae,XA as je,Xf as Me,Xj as Ne,YA as Pe,Yf as Fe,Yj as M,ZA as Ie,Zf as Le,Zj as Re,_M as ze,_a as Be,_j as Ve,aM as He,aj as Ue,bM as We,ba as Ge,bj as Ke,bl as qe,cM as Je,cj as Ye,dM as Xe,dj as Ze,eM as Qe,ej as $e,fM as et,gM as tt,ga as nt,gj as rt,hM as it,ha as at,hj as ot,iM as st,ij as ct,jK as N,jM as lt,jj as ut,kE as dt,kM as ft,ka as pt,kj as mt,lM as ht,lj as gt,mM as _t,ma as vt,mj as yt,nM as bt,nj as xt,oM as St,oj as Ct,pM as wt,pa as Tt,pj as P,qA as Et,qj as Dt,rM as Ot,rj as kt,sM as At,sj as jt,t as F,tM as Mt,tj as Nt,uM as Pt,uj as Ft,vM as It,va as Lt,vj as Rt,vl as zt,wM as Bt,wa as Vt,wj as Ht,xM as Ut,xa as Wt,xj as Gt,yM as Kt,ya as qt,yj as Jt,yl as Yt,zj as Xt,zt as Zt}from"./api-pyd1BsFz.js";import{a as Qt,c as $t}from"./FieldLabel-DpY9Xev6.js";import{t as I}from"./button-CSHWa9fF.js";import{At as L,Ft as R,Ht as en,Ut as tn,Wt as nn,_ as rn,at as z,et as B,it as V,jt as H,lt as U,mt as W,nt as G,ot as K,q as an,rt as q,st as on,tt as J,ut as sn}from"./index-D_SQS2Hc.js";import{t as cn}from"./DataTableShell-D_1TXULe.js";import{InstanceConfigDialog as ln}from"./BridgeTab-C12c4qBe.js";var Y=t(e(),1),X=[`conversational`,`documentary`,`summarizer`,`curator`],un=new Set(X),dn=`conversational`;function fn(e){let t=new Set((e??[]).filter(e=>un.has(e)));return t.size===0?[dn]:X.filter(e=>t.has(e))}var Z=n(),Q={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,transport:`ws`,gatewayVersion:``,gatewayHttpUrl:``,authMode:`token`,personScopes:`capped`,identitySource:`canonical`,participantIdentity:`owner`,managePermissionModes:!1,systemIdentity:``,streamTransport:Qt},pn={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function mn(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??``,authMode:e.authMode??`token`,personScopes:e.personScopes??`capped`,identitySource:e.identitySource??`canonical`,participantIdentity:e.participantIdentity??`owner`,managePermissionModes:e.managePermissionModes===!0,systemIdentity:e.systemIdentity??``,streamTransport:e.streamTransport??`reactive`}}function hn(){let e=N(F.admin.listInstances,{}),t=N(F.agents.listAllInstanceAgents,{}),n=o(F.admin.upsertInstance),r=o(F.admin.deleteInstance),i=H(),[c,l]=(0,Y.useState)(!1),[p,g]=(0,Y.useState)(Q),[_,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(null),[T,D]=(0,Y.useState)(null);async function k(){try{await n({instanceId:T??void 0,name:p.name,gatewayUrl:p.gatewayUrl,bridgeUrl:p.bridgeUrl||void 0,displayName:p.displayName||void 0,kind:p.kind,transport:p.kind===`hermes`?p.transport:void 0,gatewayVersion:p.gatewayVersion||void 0,gatewayHttpUrl:p.gatewayHttpUrl||void 0,...p.kind===`openclaw`?{authMode:p.authMode,personScopes:p.personScopes,identitySource:p.identitySource,participantIdentity:p.participantIdentity,managePermissionModes:p.managePermissionModes,systemIdentity:p.systemIdentity||void 0}:{},streamTransport:p.streamTransport}),g(Q),D(null),l(!1)}catch(e){i.error(s(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[ft(),(0,Z.jsx)(`strong`,{children:ue()}),m()]}),(0,Z.jsx)(cn,{title:v(),rows:e,addLabel:xe(),onAdd:()=>{D(null),g(Q),l(!0)},emptyHint:Bt(),columns:[{header:d(),cell:e=>e.name,sort:e=>e.name},{header:ve(),cell:e=>(0,Z.jsx)(L,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Ut(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:We(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:se(),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)(L,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?j():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:tt(),onSelect:()=>{D(e._id),g(mn(e)),l(!0)}},{label:lt(),onSelect:()=>b(e.name)},{label:Mt(),onSelect:()=>w(e)},{label:Kt(),onSelect:()=>S(e)},{label:It(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:It(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(rn,{open:c,onOpenChange:l,title:T?it():ze(),description:wt(),canSubmit:!!(p.name&&p.gatewayUrl),onSubmit:k,submitLabel:et(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:Xe(),children:[(0,Z.jsx)(R,{value:p.name,disabled:T!==null,onChange:e=>g({...p,name:e.target.value})}),T?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_t()}):null]}),(0,Z.jsx)($,{label:Pt(),children:(0,Z.jsxs)(B,{value:p.kind,onValueChange:e=>g({...p,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(G,{value:`hermes`,children:`Hermes`})]})]})}),p.kind===`hermes`?(0,Z.jsx)($,{label:qe(),children:(0,Z.jsxs)(B,{value:p.transport,onValueChange:e=>g({...p,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`ws`,children:Yt()}),(0,Z.jsx)(G,{value:`rest`,children:zt()})]})]})}):null,(0,Z.jsx)($,{label:ht(),children:(0,Z.jsx)(R,{value:p.gatewayUrl,onChange:e=>g({...p,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:Je(),children:(0,Z.jsx)(R,{value:p.bridgeUrl,placeholder:At(),onChange:e=>g({...p,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:St(),children:(0,Z.jsx)(R,{value:p.displayName,onChange:e=>g({...p,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:a(),children:[(0,Z.jsxs)(B,{value:p.streamTransport,onValueChange:e=>g({...p,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(J,{children:$t.map(e=>(0,Z.jsx)(G,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:dt()})]}),(0,Z.jsx)($,{label:He(),children:(0,Z.jsx)(R,{value:p.gatewayVersion,placeholder:st(),onChange:e=>g({...p,gatewayVersion:e.target.value})})}),p.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:qt(),children:[(0,Z.jsxs)(B,{value:p.authMode,onValueChange:e=>g({...p,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`token`,children:Lt()}),(0,Z.jsx)(G,{value:`trusted-proxy`,children:Be()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:p.authMode===`trusted-proxy`?at():nt()})]}),p.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:pt(),children:[(0,Z.jsxs)(B,{value:p.personScopes,onValueChange:e=>g({...p,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`capped`,children:de()}),(0,Z.jsx)(G,{value:`full`,children:h()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:p.personScopes===`full`?Se():y()})]}):null,p.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Vt(),children:[(0,Z.jsxs)(B,{value:p.identitySource,onValueChange:e=>g({...p,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`canonical`,children:f()}),(0,Z.jsx)(G,{value:`email`,children:ye()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:p.identitySource===`email`?Ge():Wt()})]}):null,p.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ae(),children:[(0,Z.jsxs)(B,{value:p.participantIdentity,onValueChange:e=>g({...p,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`owner`,children:Ee()}),(0,Z.jsx)(G,{value:`self`,children:E()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:p.participantIdentity===`self`?ee():Oe()})]}):null,p.kind===`openclaw`?(0,Z.jsxs)($,{label:u(),children:[(0,Z.jsxs)(B,{value:p.managePermissionModes?`on`:`off`,onValueChange:e=>g({...p,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(V,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(G,{value:`off`,children:Zt()}),(0,Z.jsx)(G,{value:`on`,children:_e()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:p.managePermissionModes?O():oe()})]}):null,p.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:vt(),children:(0,Z.jsx)(R,{value:p.systemIdentity,placeholder:Tt(),onChange:e=>g({...p,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:Ot(),children:(0,Z.jsx)(R,{value:p.gatewayHttpUrl,placeholder:bt(),onChange:e=>g({...p,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Tn,{instanceName:_,open:_!==null,onOpenChange:e=>{e||b(null)}}),x?(0,Z.jsx)(ln,{instance:x,onClose:()=>S(null)},x._id):null,C?(0,Z.jsx)(gn,{instance:C,onClose:()=>w(null)},C._id):null]})}function gn({instance:e,onClose:t}){let n=N(F.instanceSecrets.listInstanceSecretStatus,{}),r=pn[e.kind??`openclaw`],a=(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)(z,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(K,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(sn,{children:Qe({instance:e.displayName??e.name})}),(0,Z.jsx)(on,{children:i()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(yn,{instanceId:e._id,field:t,updatedAt:a[t]??null},t))}),(0,Z.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,Z.jsx)(vn,{instance:e})}),(0,Z.jsx)(_n,{instance:e})]})})}function _n({instance:e}){let t=A(F.instanceSync.forceInstanceSync),n=H(),[r,i]=(0,Y.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(le());break;case`no_agents`:n.success(ut());break;case`no_bridge_url`:n.error(c());break;case`deploy_misconfigured`:n.error(mt());break;case`unauthorized`:n.error(g());break;case`not_served`:n.error(b());break;default:n.error(fe());break}}catch(e){n.error(ce(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?pe():S()})})]})}function vn({instance:e}){let t=N(F.bridgeAuth.listBridgeAuthStatus,{}),n=A(F.bridgeAuth.mintBridgeSecret),r=o(F.bridgeAuth.revokeBridgeSecret),i=H(),[a,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=(t??[]).find(t=>t.instanceId===e._id),m=f!==void 0;async function h(){if(!a){s(!0);try{l((await n({instanceId:e._id})).plaintext),d(!1)}catch(e){i.error(Rt(),e)}finally{s(!1)}}}async function g(){if(!a){s(!0);try{await r({instanceId:e._id}),l(null),i.success(Jt())}catch(e){i.error(Rt(),e)}finally{s(!1)}}}async function v(){if(c)try{await navigator.clipboard.writeText(c),d(!0)}catch{}}return(0,Z.jsxs)($,{label:Ht(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:p()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:m?`outline`:`secondary`,children:m?`${M()} · ${f.prefix}…${f.lastFour}`:ne()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void h(),disabled:a,children:m?Gt():be()}),m?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void g(),disabled:a,children:Ke()}):null]})]}),c?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Ve()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void v(),children:u?_():x()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),d(!1)},children:rt()})]}):null]})}function yn({instanceId:e,field:t,updatedAt:n}){let r=A(F.instanceSecrets.setInstanceSecret),i=o(F.instanceSecrets.clearInstanceSecret),a=A(F.deviceIdentity.generateDeviceIdentity),s=H(),[c,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(!1),v=n!==null,y=t===`deviceIdentity`,b=t===`token`?he():t===`deviceIdentity`?Re():Ne();async function S(){if(!(!c.trim()||d)){f(!0);try{await r({instanceId:e,field:t,plaintext:c}),u(``),m(null),g(!1),s.success(Te())}catch(e){s.error(T(),e)}finally{f(!1)}}}async function ee(){if(!d){f(!0);try{await i({instanceId:e,field:t}),m(null),g(!1),s.success(De())}catch(e){s.error(T(),e)}finally{f(!1)}}}async function C(){if(!d){f(!0);try{m(await a({instanceId:e})),g(!1),s.success(ge())}catch(e){s.error(D(),e)}finally{f(!1)}}}let E=p?`openclaw devices approve ${p.id}`:``;async function O(){if(E)try{await navigator.clipboard.writeText(E),g(!0)}catch{}}return(0,Z.jsxs)($,{label:b,children:[y?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Xt()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(L,{variant:v?`outline`:`secondary`,children:v?M():ne()}),(0,Z.jsx)(R,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:v?ie():Dt(),onChange:e=>u(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(I,{size:`sm`,onClick:()=>void S(),disabled:d||c.trim().length===0,children:w()}),y?(0,Z.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>void C(),disabled:d,children:l()}):null,v?(0,Z.jsx)(I,{size:`sm`,variant:`destructive`,onClick:()=>void ee(),disabled:d,children:ke()}):null]})]}),p?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:ge()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ae()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:E}),(0,Z.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void O(),children:h?_():x()})]}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{m(null),g(!1)},children:rt()})]}):null]})}var bn={conversational:Ue,documentary:kt,summarizer:Le,curator:Fe},xn={conversational:ct,documentary:xt,summarizer:Me,curator:te},Sn=e=>(bn[e]??(()=>e))(),Cn=e=>(xn[e]??(()=>``))();function wn({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:gt()}),t.map(e=>(0,Z.jsx)(L,{variant:`secondary`,className:`oc-agenttype__chip`,title:Cn(e),children:Sn(e)},e)),(0,Z.jsxs)(en,{children:[(0,Z.jsx)(nn,{asChild:!0,children:(0,Z.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Ye()})}),(0,Z.jsxs)(tn,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:jt()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ct()}),(0,Z.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:X.map(r=>{let i=`agtype-${e}-${r}`;return(0,Z.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,Z.jsx)(W,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,Z.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:Sn(r)}),(0,Z.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:Cn(r)})]})]},r)})})]})]})]})}function Tn({instanceName:e,open:t,onOpenChange:n}){let i=N(F.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=o(F.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),s=o(F.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),c=o(F.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=fn(r);e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),l=o(F.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(F.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(F.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),u=o(F.agents.removeInstanceAgent),d=an(),f=H();async function p(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){f.error(P(),e)}}async function m(t){if(e)try{await s({instanceName:e,agentId:t})}catch(e){f.error(P(),e)}}async function h(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await c({instanceName:e,agentId:t,types:i})}catch(e){f.error(P(),e)}}async function g(t,n){if(e&&await d({title:r({name:n}),description:me(),confirmLabel:Ie(),destructive:!0}))try{await u({instanceName:e,agentId:t}),f.success(je())}catch(e){f.error(P(),e)}}return(0,Z.jsx)(z,{open:t,onOpenChange:n,children:(0,Z.jsxs)(K,{className:`oc-access`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(sn,{children:ot({name:e??``})}),(0,Z.jsx)(on,{children:yt()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:Pe()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?k():i.discovery.lastPollOk?Et():re({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:C()}):(0,Z.jsx)(`div`,{className:`oc-access__list`,children:i.agents.map(t=>{let n=t.presentInLastOk===!1,r=i.defaultAgentId===t.agentId,a=t.displayName??t.agentId,o=t.types??[];return(0,Z.jsxs)(`div`,{className:`oc-agentcard`+(t.enabled?``:` oc-agentcard--off`),children:[(0,Z.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,Z.jsx)(W,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void p(t.agentId,e===!0)}),(0,Z.jsxs)(`span`,{className:`oc-agentcard__name`,title:a,children:[t.emoji?`${t.emoji} `:``,a]}),t.model?(0,Z.jsx)(`span`,{className:`oc-access__model`,children:t.model}):null,n?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{variant:`outline`,className:`oc-access__gone`,children:we()}),(0,Z.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void g(t.agentId,a),children:$e()})]}):r?(0,Z.jsx)(L,{variant:`default`,children:j()}):(0,Z.jsx)(I,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void m(t.agentId),children:Nt()})]}),t.enabled?(0,Z.jsx)(wn,{agentId:t.agentId,types:o,onToggle:e=>void h(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(En,{value:t.description??``,onSave:async n=>{if(e)try{await l({instanceName:e,agentId:t.agentId,description:n})}catch(e){f.error(P(),e)}}}):null]},t.agentId)})})]})]})})}function En({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)(R,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:Ze(),"aria-label":Ft(),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{hn as InstancesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AK as r,CP as i,OK as a,SP as o,_P as s,_m as c,bP as l,dP as u,dm as d,fP as f,fm as p,gP as m,gm as h,hP as g,hm as _,jK as v,mP as y,mm as b,pP as x,pm as S,t as C,uP as w,um as T,vP as E,vm as D,xP as O,yP as k}from"./api-pyd1BsFz.js";import{t as A}from"./button-CSHWa9fF.js";import{At as j,Ft as M,mt as N}from"./index-D_SQS2Hc.js";var P=t(e(),1),F=n();function I(){let e=v(C.integrations.status.status,{}),t=r(C.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:i()});let d=n,p=(e,t,n)=>a({...d,[e]:{...d[e],[t]:n}}),_=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[o(),` `,(0,F.jsx)(`strong`,{children:O()}),` `,l()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:k()}):(0,F.jsx)(j,{variant:`outline`,children:E()}):(0,F.jsx)(j,{variant:`outline`,children:s()}),note:m(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:d.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>p(`langfuse`,`host`,e.target.value),onBlur:()=>_(`langfuse`,{host:d.langfuse.host??``})})}),(0,F.jsx)(z,{label:w(),checked:d.langfuse.enabled??!0,onChange:e=>{p(`langfuse`,`enabled`,e),_(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:k()}):(0,F.jsx)(j,{variant:`outline`,children:E()}):(0,F.jsx)(j,{variant:`outline`,children:s()}),note:g(),children:[(0,F.jsx)(R,{label:x(),children:(0,F.jsx)(M,{value:d.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>p(`opik`,`baseUrl`,e.target.value),onBlur:()=>_(`opik`,{baseUrl:d.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:f(),children:(0,F.jsx)(M,{value:d.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||u(),onChange:e=>p(`opik`,`workspace`,e.target.value),onBlur:()=>_(`opik`,{workspace:d.opik.workspace??``})})}),(0,F.jsx)(z,{label:w(),checked:d.opik.enabled??!0,onChange:e=>{p(`opik`,`enabled`,e),_(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:k()}):(0,F.jsx)(j,{variant:`outline`,children:E()}):(0,F.jsx)(j,{variant:`outline`,children:D()}),note:c(),children:[(0,F.jsx)(R,{label:h(),children:(0,F.jsx)(M,{value:d.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>p(`otlp`,`endpoint`,e.target.value),onBlur:()=>_(`otlp`,{endpoint:d.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:w(),checked:d.otlp.enabled??!0,onChange:e=>{p(`otlp`,`enabled`,e),_(`otlp`,{enabled:e})}})]})]})}function L({title:e,status:t,note:n,children:r}){return(0,F.jsxs)(`section`,{className:`oc-int__section`,children:[(0,F.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,F.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,F.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`oc-int__field`,children:[(0,F.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function z({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,F.jsx)(N,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=a(C.integrations.otlpSecret.setOtlpHeaders),n=r(C.integrations.otlpSecret.clearOtlpHeaders),[i,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),f=async()=>{u(!0),c(null);try{await t({headersJson:i}),o(``)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:_(),children:[(0,F.jsx)(M,{value:i,placeholder:e?b():S(),onChange:e=>o(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:l||i.trim().length===0,onClick:()=>void f(),children:p()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:d()}):null]}),s?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:s}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:T()})]})}export{I as IntegrationsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Bw as r,Fw as i,Gw as a,Hw as o,Iw as s,Kw as c,Lw as l,MF as u,Nw as d,Pw as f,Rw as p,Uw as m,Vw as h,Ww as g,XP as _,ZP as ee,aF as te,iF as ne,jK as v,oF as y,qw as b,sF as x,t as S,zw as C}from"./api-pyd1BsFz.js";import{Gn as w,Kn as T,Z as E,i as D,o as re,r as ie}from"./index-D_SQS2Hc.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-DOI4qcUP.js";import{n as N,t as P}from"./TimeRangePicker-FT0sN61o.js";var F=t(e(),1),I={API_CALLS:`api.calls`,API_ERRORS:`api.errors`,API_LATENCY_AVG_MS:`api.latency.avg_ms`,OPENCLAW_INGEST:`openclaw.ingest`,CHAT_SEND:`chat.send`,ASSISTANT_STREAM_ERRORS:`assistant.stream.errors`,ASSISTANT_ANNOUNCE_ERRORS:`assistant.announce.errors`,CONVEX_PROBE_LATENCY_AVG_MS:`convex.probe.latency.avg_ms`},L=Object.keys(I).length,R=n(),z=15,B=e=>String(Math.round(e));function V(){let e=v(S.me.getMe,{host:E})?.permissions?.includes(`traces.read`)??!1,t=v(S.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,z).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:u()}),(0,R.jsxs)(M,{children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{children:x()}),(0,R.jsx)(j,{children:te()})]}),(0,R.jsx)(k,{children:n.length<2?(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:ne()}):(0,R.jsx)(H,{series:n})})]})]})}function H({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{style:{color:`var(--primary)`},children:[_(),` p50 `,B(s.cP50),` `,y()]}),(0,R.jsxs)(`span`,{children:[ee(),` p50 `,B(s.aP50),` `,y()]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":x(),children:[(0,R.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,R.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var U=[{metric:`api.calls`,label:b(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:c(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:a(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:g(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:m(),unit:`/h`,group:`Chat`,isError:!1},{metric:I.ASSISTANT_STREAM_ERRORS,label:o(),unit:`/h`,group:`Assistant`,isError:!0},{metric:I.ASSISTANT_ANNOUNCE_ERRORS,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],W=L,G=[`API`,`OpenClaw`,`Chat`,`Assistant`],K=1e3,q=36e5;function J(e,t){let n=Math.max(1,Math.ceil((t-e)/q)),r=Math.min(n*W,K);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/W))}}function ae(){let e=T({from:`/settings/kpi`}),t=w({from:`/settings/kpi`}),n=D(e.from,e.to,ie,`now`),i=e=>void t({search:t=>({...t,...re(e)})}),{from:a,to:o}=N(n),{rowLimit:s,buckets:c}=J(a,o),u=v(S.kpi.listKpis,{limit:s,filter:{from:a,to:o}}),d=(0,F.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>c&&e.set(t,n.slice(n.length-c));return e},[u,c]),f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`oc-admin__hint`,children:[r(),` `,(0,R.jsx)(`span`,{className:`oc-filter__window`,children:C()})]}),(0,R.jsx)(Y,{value:n,onChange:i})]});return u===void 0?(0,R.jsxs)(R.Fragment,{children:[f,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}):u.length===0?(0,R.jsxs)(R.Fragment,{children:[f,(0,R.jsx)(V,{}),(0,R.jsx)(`p`,{className:`oc-admin__hint`,children:l()})]}):(0,R.jsxs)(R.Fragment,{children:[f,(0,R.jsx)(V,{}),G.map(e=>{let t=U.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,R.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,R.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,R.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,R.jsx)(oe,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function Y({value:e,onChange:t}){return(0,R.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,R.jsx)(P,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,R.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,R.jsxs)(O,{children:[(0,R.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,R.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,R.jsx)(`code`,{children:e.metric})})]}),(0,R.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,R.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,R.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,R.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,R.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,R.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,R.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:s({value:$(n.bucket)})}):(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:i()}),(0,R.jsx)(`span`,{className:`oc-kpi__muted`,children:f({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,R.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-se,1);return(0,R.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":d({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,R.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,R.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{ae as KpiTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$B as r,$G as i,AK as a,BB as o,CV as s,GB as c,GG as l,HB as u,JB as d,JG as f,KB as p,KG as ee,Ns as m,Os as h,Ps as g,QB as _,QG as te,SV as ne,UB as re,VB as ie,WB as ae,WG as oe,XB as se,XG as ce,YB as le,YG as ue,ZB as de,ZG as fe,_V as pe,_s as me,aK as he,aV as v,bV as y,bs as b,cK as x,cV as S,dK as C,dV as w,eK as T,eV as E,fK as D,fM as O,fV as k,gK as A,gV as j,gs as M,hV as N,hs as P,iK as F,iV as I,jK as L,lK as R,lV as ge,mV as _e,ms as ve,nK as ye,nV as be,oK as xe,oV as Se,pK as Ce,pV as we,ps as Te,qB as Ee,qG as De,r as z,rK as Oe,rV as ke,sK as Ae,sV as je,t as B,tK as Me,tV as Ne,uK as Pe,uV as Fe,vV as Ie,vs as Le,wV as Re,xK as ze,xV as Be,yV as Ve,ys as He,zB as Ue}from"./api-pyd1BsFz.js";import{t as V}from"./button-CSHWa9fF.js";import{At as H,Ft as U,Mt as We,Nt as Ge,Pt as Ke,R as qe,Z as W,et as Je,it as Ye,jt as Xe,mt as G,nt as K,rt as Ze,t as Qe,tt as $e}from"./index-D_SQS2Hc.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-0qEgkKvV.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:z(`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:z(`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:()=>Re()},{id:`composer`,label:()=>s()},{id:`sidebar`,label:()=>ne()},{id:`notifications`,label:()=>v()},{id:`other`,label:()=>Be()}],X={showSource:{category:`messages`,label:()=>y(),help:()=>Ve()},showReport:{category:`messages`,label:()=>Ie(),help:()=>pe()},copyAssistant:{category:`messages`,label:()=>j()},copyUser:{category:`messages`,label:()=>N()},showDelete:{category:`messages`,label:()=>_e()},showTools:{category:`messages`,label:()=>we(),help:()=>k()},voiceInput:{category:`composer`,label:()=>w(),help:()=>Fe()},showUsage:{category:`composer`,label:()=>ge(),help:()=>S()},autoReadAloud:{category:`composer`,label:()=>g(),help:()=>m()},showChatAge:{category:`sidebar`,label:()=>je(),help:()=>Se()},notifSound:{category:`notifications`,label:()=>I(),help:()=>ke()},notifSystem:{category:`notifications`,label:()=>be(),help:()=>Ne()},replySound:{category:`notifications`,label:()=>E(),help:()=>r()}};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:()=>re()};function ut({prefKey:e,ui:t}){let n=a(B.admin.setUiPrefDefault),r=a(B.admin.setFeatureEnabled),i=ct(e),s=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:Ee()}),(0,J.jsxs)(Je,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Ze,{size:`sm`,className:`w-36`,children:(0,J.jsx)(Ye,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(K,{value:`on`,children:ie()}),(0,J.jsx)(K,{value:`off`,children:o()}),(0,J.jsx)(K,{value:`inherit`,children:Ue()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(G,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":p()}),p()]}):null]}),s?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:s}):null]})}function dt({current:e,enabled:t}){let n=a(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(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=Ge(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!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:[b(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ke(e,We())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?me():r?Le():He()})]}),(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:Te()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?ve():e?P():M()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=L(B.me.getMe,{host:W}),o=i?.ui,s=$(i?.role)&&n,l=a(B.me.setUiPref).withOptimisticUpdate(qe),f=(0,q.useMemo)(()=>o?Q(Object.keys(o.effective),e):[],[o,e]);return o?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(G,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":d()}),d()]}):null,s?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:c()}),(0,J.jsx)(`p`,{children:ae()}),(0,J.jsx)(`p`,{children:u()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:_(),"aria-label":_(),className:`mb-2`}),f.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:de()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:f.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=o.locked[e],a=o.effective[e],c=o.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)(H,{variant:`outline`,children:se()}):c?(0,J.jsx)(H,{variant:`secondary`,children:h()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&c?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void l({key:e,value:null}),children:le()}):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})]}),s?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:ze()})}var pt={sm:()=>Me(),md:()=>T(),lg:()=>i(),xl:()=>te(),"2xl":()=>fe(),"3xl":()=>ce()};function mt(){let e=L(B.me.getMe,{host:W}),t=a(B.me.setLocale),n=a(B.me.setTimezone),r=a(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:W});n&&e.setQuery(B.me.getMe,{host:W},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=a(B.me.setMyName),o=Xe(),s=e?.locale??`default`,c=e?.name??``,[u,d]=(0,q.useState)(null),p=u??c,m=p.trim()!==c.trim();async function h(){try{await i({name:p}),d(null),o.success(R())}catch(e){o.error(x(),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:Ce()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:p,maxLength:120,placeholder:C(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,J.jsx)(V,{size:`sm`,disabled:!m,onClick:()=>void h(),children:O()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Pe()})]}),(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:Ae()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:xe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:A()})]}),(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:ue()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:f()})]}),(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:De()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ee()})]}),(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:F()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Oe()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Qe.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void r({scale:t}),children:pt[t]()},t))}),(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:l()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:oe()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$C as r,AC as i,AK as a,BC as o,Ba as s,CC as c,D as l,DC as u,FC as d,GC as f,HC as p,IC as m,JC as h,KC as g,LC as _,MC as v,NC as y,OC as b,PC as ee,QC as te,RC as ne,SC as re,TC as x,UC as S,VC as ie,Va as ae,YC as oe,ZC as se,_C as ce,cC as C,cx as le,dC as ue,ew as de,fC as w,gC as T,gw as fe,hw as pe,jC as me,jK as E,kC as D,lC as he,lw as O,mC as ge,mw as _e,oC as ve,ow as ye,pC as k,qC as be,rw as A,sw as xe,t as j,tw as Se,uC as Ce,uw as M,vC as we,wC as Te,xK as N,zC as Ee}from"./api-pyd1BsFz.js";import{r as De}from"./dist-BtoqPlB7.js";import{t as Oe}from"./list-_AdtdHKa.js";import{t as P}from"./button-CSHWa9fF.js";import{$ as ke,A as Ae,An as F,Bt as je,C as Me,Cn as Ne,D as I,E as Pe,En as Fe,Fn as Ie,Ft as L,Gn as R,It as Le,J as Re,Kn as ze,Lt as Be,M as Ve,Mn as He,Nn as Ue,O as z,Pn as We,Q as Ge,Rt as B,S as Ke,T as qe,Tn as Je,Vn as V,Vt as Ye,_ as Xe,b as H,bn as Ze,d as Qe,dn as $e,f as U,g as W,h as G,j as K,jn as et,jt as tt,k as nt,m as rt,p as it,q as at,qn as ot,v as q,w as st,x as J,xn as ct,y as lt,yn as ut,zt as dt}from"./index-D_SQS2Hc.js";var ft=l(`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`}]]),pt=l(`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`}]]),mt=l(`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`}]]),Y=l(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function ht({className:e}){return(0,Z.jsx)(Ye,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":ge(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Ie,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:i,className:o,onOpen:s}){let c=a(j.projects.renameProject),l=a(j.projects.setProjectColor),u=a(j.projects.moveProject),d=a(j.projects.deleteProject),f=a(j.projects.createProject),m=at(),h=Re(),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(t),[b,ee]=(0,X.useState)(!1),[ne,x]=(0,X.useState)(!1),S=E(j.projects.projectTreeCount,ne?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Le,{onOpenChange:e=>e&&x(!0),children:[(0,Z.jsx)(ht,{className:o}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(B,{onSelect:()=>s(),children:[(0,Z.jsx)(He,{}),` `,se()]}),(0,Z.jsxs)(B,{onSelect:()=>{y(t),_(!0)},children:[(0,Z.jsx)(ct,{}),` `,k()]}),(0,Z.jsxs)(B,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await h({title:p(),label:fe(),placeholder:pe(),confirmLabel:_e()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(et,{}),` `,p()]}),(0,Z.jsxs)(B,{onSelect:()=>ee(!0),children:[(0,Z.jsx)(pt,{}),` `,Te()]}),(0,Z.jsx)(dt,{children:Ce()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":he(),children:`✕`}),rt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(je,{}),(0,Z.jsxs)(B,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=S?.folders??0,i=S?.chats??0;await m({title:de({name:t}),description:n>0?te({folders:n,chats:i}):i>0?r({count:i}):ce(),confirmWord:T(),confirmLabel:Se(),destructive:!0})&&await d({projectId:e})})},children:[(0,Z.jsx)($e,{}),` `,T()]})]})]}),(0,Z.jsx)(Xe,{open:g,onOpenChange:_,title:ye(),canSubmit:v.trim().length>0,onSubmit:async()=>{await c({projectId:e,name:v.trim()}),_(!1)},submitLabel:k(),children:(0,Z.jsx)(L,{value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),b?(0,Z.jsx)(it,{open:b,onOpenChange:ee,title:re(),movingFolderId:e,currentId:i,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function gt({chat:e,currentFolderId:t,className:n}){let r=a(j.chats.pinChat),i=a(j.chats.deleteChat),o=a(j.chats.renameChat),s=a(j.chats.setChatSidebar),l=a(j.chats.moveChatToProject),u=at(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(e.title??``),[g,_]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Le,{children:[(0,Z.jsx)(ht,{className:n}),(0,Z.jsxs)(Be,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(B,{onSelect:()=>{m(e.title??``),f(!0)},children:[(0,Z.jsx)(ct,{}),` `,k()]}),(0,Z.jsxs)(B,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(ut,{}):(0,Z.jsx)(Ze,{}),e.pinned?w():ue()]}),(0,Z.jsxs)(B,{onSelect:()=>_(!0),children:[(0,Z.jsx)(pt,{}),` `,x()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(B,{onSelect:()=>void s({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(Ne,{}):(0,Z.jsx)(Y,{}),e.inSidebar?h():oe()]}),(0,Z.jsx)(je,{}),(0,Z.jsxs)(B,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:C(),description:ce(),confirmLabel:T(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)($e,{}),` `,T()]})]})]}),(0,Z.jsx)(Xe,{open:d,onOpenChange:f,title:ve(),canSubmit:p.trim().length>0,onSubmit:async()=>{await o({chatId:e._id,title:p.trim()}),f(!1)},submitLabel:k(),children:(0,Z.jsx)(L,{value:p,onChange:e=>m(e.target.value),autoFocus:!0})}),g?(0,Z.jsx)(it,{open:g,onOpenChange:_,title:c(),currentId:t,onPick:t=>void l({chatId:e._id,projectId:t})}):null]})}function _t(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function vt(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 yt(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 bt=`oc.projpage.view`;function xt(){let e=localStorage.getItem(bt);return e===`cards`||e===`list`?e:`columns`}var $=e=>`into:${e}`,St=e=>`col:${e??`null`}`,Ct=e=>`crumb:${e}`;function wt(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 Tt(){let{projectId:e}=ot({from:`/project/$projectId`}),t=R(),n=E(j.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:N()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:i()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:D()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:b()})]}):(0,Z.jsx)(Et,{page:n})})}function Et({page:e}){let t=R(),n=at(),i=Re(),o=tt(),c=a(j.projects.renameProject),l=a(j.projects.setProjectColor),d=a(j.projects.deleteProject),m=a(j.projects.createProject),h=a(j.projects.moveProject),b=a(j.projects.setProjectSidebar),x=a(j.chats.moveChatToProject),ie=a(j.chats.reorderChat),oe=a(j.projects.reorderProject),se=E(j.projects.projectTreeCount,{projectId:e.project._id}),[C,ue]=(0,X.useState)(xt),w=e=>{localStorage.setItem(bt,e),ue(e)},D=E(j.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),O=E(j.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:ge}=ze({from:`/project/$projectId`}),ve=E(j.projects.listProjects,{}),A=E(j.chatReads.myBusyChats,{}),N=(0,X.useMemo)(()=>new Set(A??[]),[A]),De=E(j.chatReads.myChatReads,{}),Ne=(0,X.useMemo)(()=>yt(e.chats,De??[]),[e.chats,De]),{startNewChat:He,picker:z}=Qe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[V,H]=(0,X.useState)(``),[Ze,U]=(0,X.useState)(!1),[G,K]=(0,X.useState)(e.project.name),[ot,ut]=(0,X.useState)(!1),[Y,ht]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ht(V.trim()),180);return()=>clearTimeout(e)},[V]);let Q=E(j.search.searchConversations,Y.length>=2?{query:Y,projectId:e.project._id}:`skip`),gt=Ae(nt(st,{activationConstraint:{distance:4}}),nt(qe,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),St=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[Ct,Tt]=(0,X.useState)(null),Et=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=D?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||M()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(ve??[]).find(t=>t._id===e)?.name??``}}return null},kt=e=>Tt(Et(String(e.active.id))),jt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=I(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=I(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=I(n(`crumb:`));if(a.length>0)return a;let o=I(n(`col:`));return o.length>0?o:Pe(n(t?`folder:`:`chat:`))},[]),Nt=t=>{if(C===`columns`){for(let e of D?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(C===`list`){let e=O?.chats.find(e=>e._id===t);return e?{list:O.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},Pt=t=>{if(C===`columns`){for(let e of D?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(C===`list`){let e=O?.folders.find(e=>e._id===t);if(!e||!O)return null;let n=e.parentId??O.rootId;return{list:ke(O.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},It=async e=>{Tt(null),St();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=wt(r);if(e!==void 0){if(a)await x({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Ge(ve??[],t,e)){o.error(S());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=Nt(t);if(!n)return;n.list.some(t=>t._id===e)||await x({chatId:e,projectId:n.folderId});let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await ie({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=Pt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ge(ve??[],e,n.parentId)){o.error(S());return}await h({projectId:e,parentId:n.parentId})}let a=vt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await oe({projectId:e,...a});return}}catch{o.error(S())}},[,Lt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Lt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Rt=Date.now(),zt=W(e.project),Bt=_t(e.chats,V),Vt=e.breadcrumb.slice(0,-1),Ht=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ke,{sensors:gt,collisionDetection:jt,onDragStart:kt,onDragEnd:It,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":zt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":u(),children:[Vt.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Dt,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Ht(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,Z.jsxs)(P,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:ae(),onClick:()=>{b({projectId:e.project._id,hidden:!1})},children:[(0,Z.jsx)(We,{"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:s()}),(0,Z.jsx)(Ue,{"aria-hidden":!0})]}):null,(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":be(),children:[(0,Z.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":be(),title:be(),"aria-pressed":C===`cards`,onClick:()=>w(`cards`),children:(0,Z.jsx)(mt,{})}),(0,Z.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":g(),title:g(),"aria-pressed":C===`columns`,onClick:()=>w(`columns`),children:(0,Z.jsx)(ft,{})}),(0,Z.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:(0,Z.jsx)(Oe,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void He({projectId:e.project._id}),children:[(0,Z.jsx)(Fe,{}),_()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await i({title:p(),label:fe(),placeholder:pe(),confirmLabel:_e()});t&&await m({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(et,{}),p()]}),(0,Z.jsxs)(Le,{children:[(0,Z.jsx)(Ye,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":xe(),children:(0,Z.jsx)(Ie,{})})}),(0,Z.jsxs)(Be,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(B,{onSelect:()=>{K(e.project.name),U(!0)},children:[(0,Z.jsx)(ct,{}),` `,k()]}),(0,Z.jsxs)(B,{onSelect:()=>ut(!0),children:[(0,Z.jsx)(pt,{}),` `,Te()]}),(0,Z.jsx)(dt,{children:Ce()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":he(),children:`✕`}),rt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(je,{}),(0,Z.jsxs)(B,{variant:`destructive`,onSelect:()=>{let i=e.project.parentId;requestAnimationFrame(async()=>{let a=se?.folders??0,o=se?.chats??0;await n({title:de({name:e.project.name}),description:a>0?te({folders:a,chats:o}):o>0?r({count:o}):ce(),confirmWord:T(),confirmLabel:Se(),destructive:!0})&&(await d({projectId:e.project._id}),t(i===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:i}}))})},children:[(0,Z.jsx)($e,{}),` `,T()]})]})]})]})]}),C===`columns`?(0,Z.jsx)(Ft,{data:D,currentId:e.project._id,busyIds:N,suppressClick:$,locateChatId:ge??null}):C===`list`?(0,Z.jsx)(Mt,{data:O,busyIds:N,suppressClick:$,locateChatId:ge??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:Ee()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:lt,children:e.children.map(t=>(0,Z.jsx)(Ot,{child:t,parentId:e.project._id,now:Rt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ne()}),e.chats.length>0?(0,Z.jsx)(L,{value:V,onChange:e=>H(e.target.value),placeholder:ee(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?v():me()}):Bt.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:y({term:V.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Bt.map(e=>`chat:${e._id}`),strategy:J,children:Bt.map(t=>(0,Z.jsx)(At,{chat:t,currentFolderId:e.project._id,now:Rt,busy:N.has(t._id),unread:Ne.has(t._id),locate:t._id===ge,suppressClick:$},t._id))})})]}),Y.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:we()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:y({term:Y})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&Y&&Ve(e.messageId,Y),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||le()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(Xe,{open:Ze,onOpenChange:U,title:ye(),canSubmit:G.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:G.trim()}),U(!1)},submitLabel:k(),children:(0,Z.jsx)(L,{value:G,onChange:e=>K(e.target.value),autoFocus:!0})}),ot?(0,Z.jsx)(it,{open:ot,onOpenChange:ut,title:re(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void h({projectId:e.project._id,parentId:t})}):null,z]}),(0,Z.jsx)(Me,{children:Ct?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[Ct.kind===`folder`?(0,Z.jsx)(F,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:Ct.label})]}):null})]})}function Dt({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=z({id:Ct(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function Ot({child:e,parentId:t,now:n,suppressClick:r}){let i=R(),a=H({id:`folder:${e._id}`}),o=z({id:$(e._id)});return(0,Z.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":W(e),transform:K.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,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(F,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.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,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?m({count:e.folderCount})+` · `:``,d({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:U(e.lastActivityAt,n)})]})}function kt({chat:e}){let t=a(j.chats.setChatSidebar),n=e.inSidebar?h():oe();return(0,Z.jsx)(P,{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,Z.jsx)(Ne,{}):(0,Z.jsx)(Y,{})})}function At({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=R(),c=G(e.color),l=H({id:`chat:${e._id}`}),u=jt(a);return(0,Z.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:K.Transform.toString(l.transform),transition:l.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||s({to:`/chat/$chatId`,params:{chatId:e._id}})},...l.listeners,...l.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||M()}),e.pinned?(0,Z.jsx)(Ze,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:U(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:O(),"aria-label":O()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:A(),"aria-label":A()}):null]}),(0,Z.jsx)(kt,{chat:e}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function jt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Mt({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[i,a]=(0,X.useState)(new Set),o=(0,X.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,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:N()});if(e===null)return null;let s=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=(a,l)=>{let u=o.get(a??e.rootId)??[],d=ke(e.folders,a);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:J,children:u.map(e=>(0,Z.jsx)(Pt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:J,children:d.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:a??e.rootId,depth:l,folded:i.has(t._id),onToggle:()=>s(t._id),suppressClick:n,children:i.has(t._id)?null:c(t._id,l+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&ke(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:v()}):c(null,0)})}function Nt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:s}){let c=R(),l=H({id:`folder:${e._id}`}),u=z({id:$(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{l.setNodeRef(e),u.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(u.isOver?` is-over`:``)+(l.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":W(e),transform:K.Transform.toString(l.transform),transition:l.transition},...l.listeners,...l.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||c({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&c({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?ie():o(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)(V,{size:13}):(0,Z.jsx)(De,{size:13})}),(0,Z.jsx)(F,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void c({to:`/project/$projectId`,params:{projectId:e._id}})})]}),s]})}function Pt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=R(),o=H({id:`chat:${e._id}`}),s=jt(r),c=G(e.color);return(0,Z.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:K.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.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,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||M()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(kt,{chat:e})]})}function Ft({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:N()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(It,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function It({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=R(),s=z({id:St(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:J,children:e.folders.map(t=>(0,Z.jsx)(Lt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:J,children:e.chats.map(t=>(0,Z.jsx)(Rt,{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,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:me()}):null]})}function Lt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=H({id:`folder:${e._id}`}),o=z({id:$(e._id)});return(0,Z.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":W(e),transform:K.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,Z.jsx)(F,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Rt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=H({id:`chat:${e._id}`}),s=jt(r),c=G(e.color);return(0,Z.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:K.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||M()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)(gt,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(kt,{chat:e})]})}export{Tt as ProjectPage};
@@ -1,4 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$f as r,$u as i,AK as a,CE as o,Cl as s,EE as c,La as l,NE as u,PE as d,Qf as f,Qu as p,SE as m,Sl as h,TE as g,_E as _,bE as v,cE as y,dE as b,dd as ee,ed as te,ep as ne,fE as x,fd as S,gE as re,hE as C,jK as w,lE as T,ld as E,mE as ie,nd as ae,np as oe,pE as se,sE as ce,t as D,td as O,tp as k,uE as A,ud as j,vE as M,wE as N,xE as P,xl as F,yE as I}from"./api-pyd1BsFz.js";import{i as L,n as R,r as z,t as B}from"./FieldLabel-DpY9Xev6.js";import{t as V}from"./button-CSHWa9fF.js";import{Qt as H,Xt as le,Yt as U,Z as W,Zt as ue,et as G,it as K,jt as de,mt as fe,nt as q,rt as J,tt as Y}from"./index-D_SQS2Hc.js";import{r as X,t as pe}from"./locales-CPjguROj.js";import{t as Z}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:P,help:v},documentary_fetch:{label:I,help:M},inbound_files:{label:_,help:re},history_summary:{label:oe,help:k},file_curation:{label:S,help:ae},quote_reply:{label:ee,help:j}},he={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.`},ge={outboundDir:T,references:y,files:ce,previous_summary:ne,new_messages:r,max_chars:f,file_name:O,budget_chars:te,feedback:i,content:p,excerpt:E};function _e(){let e=w(D.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:ie()})});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)(R,{label:c(),help:g()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:C()}),(0,$.jsxs)(G,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(J,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(K,{})}),(0,$.jsx)(Y,{children:e.map(e=>(0,$.jsx)(q,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(ve,{instance:r},r._id)]})}function ve({instance:e}){let t=a(D.admin.upsertInstanceConfig),n=de(),r=w(D.me.getMe,{host:W}),i=e.config??{},o=X(e.config?.contentLocale,r?.defaultLocale??void 0),[c,l]=(0,Q.useState)(()=>L(i,o));(0,Q.useEffect)(()=>{l(L(i,o))},[o,e._id]);let[f,p]=(0,Q.useState)(!1),m=c.promptInjections,g=(e,t)=>l({...c,promptInjections:{...m,[e]:{...m[e],...t}}});async function _(){p(!0);try{await t({instanceId:e._id,config:z(c,i,o)})}catch(e){n.error(u(),e)}finally{p(!1)}}async function v(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(u(),e)}}let y=e.config?.contentLocale??`default`,b=pe[X(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)(G,{value:y,onValueChange:e=>void v(e),children:[(0,$.jsx)(J,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(K,{})}),(0,$.jsxs)(Y,{children:[(0,$.jsx)(q,{value:`default`,children:F({locale:b})}),Z().map(e=>(0,$.jsx)(q,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:h()})]}),le.map(e=>(0,$.jsx)(ye,{injKey:e,def:U[e],i18n:me[e],row:m[e]??{enabled:!0,template:U[e].defaultTemplate[o]},contentLocale:o,onChange:t=>g(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(V,{size:`sm`,onClick:()=>void _(),disabled:f,children:d()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[s,c]=(0,Q.useState)(!1),u=r.template.trim()!==t.defaultTemplate[i],d=t.togglable&&!r.enabled,f=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),p=ue(e,r,i),h=p?H(p,f):``;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)(fe,{checked:r.enabled,onCheckedChange:e=>a({enabled:e===!0})}),(0,$.jsx)(R,{label:n.label(),help:n.help()})]}):(0,$.jsx)(R,{label:n.label(),help:n.help()}),u&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:o()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:d,rows:8,spellCheck:!1,onChange:e=>a({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:m()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(B,{text:(ge[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>c(e=>!e),children:s?x():se()}),u&&(0,$.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:N()})]})]}),s&&(0,$.jsx)(`div`,{className:`oc-injcard__preview`,children:h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:h}),(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:b()}),t.pluralDefaultTemplate!==void 0&&!d?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:l()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:A()})})]})}export{_e as PromptInjectionsTab};
@@ -1 +0,0 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$k as r,AK as i,Bk as a,CA as o,DA as s,EA as c,Gk as ee,Hk as l,Id as u,Lk as te,Qk as d,Rk as f,SA as p,TA as m,Uk as h,Vk as ne,Wk as g,Zk as _,_A as v,aA as y,bA as b,cA as x,dA as re,eA as ie,fA as ae,gA as S,hA as C,iA as w,jK as T,lA as E,mA as D,nA as O,oA as k,pA as A,rA as j,sA as M,t as N,tA as P,uA as F,vA as I,wA as L,xA as R,yA as oe,zk as z}from"./api-pyd1BsFz.js";import{t as B}from"./button-CSHWa9fF.js";import{At as V,Dn as H,Ft as U,_ as W,jt as G,mt as K,q}from"./index-D_SQS2Hc.js";import{t as J}from"./roleDescriptions-CWN610yU.js";var Y=t(e(),1),X=n(),Z=[{group:()=>s(),keys:[{key:`traces.read`,label:()=>p()},{key:`traces.read.content`,label:()=>R(),phi:!0},{key:`traces.write`,label:()=>b()}]},{group:()=>c(),keys:[{key:`kpi.read`,label:()=>p()},{key:`kpi.write`,label:()=>b()}]},{group:()=>m(),keys:[{key:`openclaw.query`,label:()=>oe()},{key:`anomalies.read`,label:()=>I()},{key:`anomalies.report`,label:()=>v()}]},{group:()=>L(),keys:[{key:`chats.read`,label:()=>p()},{key:`selfheal`,label:()=>C()},{key:`media.repair`,label:()=>D()},{key:`feedback.respond`,label:()=>u()}]},{group:()=>o(),keys:[{key:`admin.manage`,label:()=>S()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=T(N.apiKeys.listRoles,{}),t=i(N.apiKeys.createRole),n=i(N.apiKeys.ensureRolesSeeded),o=i(N.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(N.apiKeys.listRoles,{});r&&e.setQuery(N.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),s=q(),c=G(),[u,p]=(0,Y.useState)(!1),[m,v]=(0,Y.useState)($),[b,S]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{c.error(ae(),e)})},[n,c]);let C=e??[];async function D(e,t){if(Q(e.permissions))return;if(e.builtin){await s({title:re({name:e.name}),description:F(),confirmLabel:E()});return}if(b.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];S(t=>new Set(t).add(e._id));try{await o({roleId:e._id,permissions:n})}catch(e){c.error(x(),e)}finally{S(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function I(){try{await t({key:m.key,name:m.name,description:m.description||void 0,permissions:[]}),v($),p(!1)}catch(e){c.error(M(),e)}}let L=e===void 0,R=!L&&C.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[k(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,y(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,w()]}),(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:j()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{v($),p(!0)},children:O()})})]}),L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:P()}):R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}):(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:r()}),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?A({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:C.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)(V,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(H,{}),` `,d()]}):(0,X.jsx)(V,{variant:`secondary`,children:_()})]}),J(e)?(0,X.jsx)(`p`,{className:`oc-matrix__roledesc`,children:J(e)}):null]}),se.map(r=>(0,X.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,X.jsx)(K,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?ee():n?g():r,onCheckedChange:()=>void D(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:u,onOpenChange:p,title:h(),description:l(),canSubmit:!!(m.key&&m.name),onSubmit:I,submitLabel:ne(),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:a()}),(0,X.jsx)(U,{value:m.key,placeholder:z(),onChange:e=>v({...m,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:f()}),(0,X.jsx)(U,{value:m.name,onChange:e=>v({...m,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(U,{value:m.description,onChange:e=>v({...m,description:e.target.value})})]})]})})]})}export{ce as RolesTab};