@lacneu/atrium 0.88.1 → 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.
- package/dist/assets/AccessTab-D82x_380.js +1 -0
- package/dist/assets/{AdvancedFilter-D_IAxoTH.js → AdvancedFilter-DEwJUkfT.js} +1 -1
- package/dist/assets/AgentFilesTab-CEqQ02fZ.js +3 -0
- package/dist/assets/AnomaliesTab-Cl2630PU.js +1 -0
- package/dist/assets/AuditTab-DYryQjmJ.js +1 -0
- package/dist/assets/BridgeTab-rI4MFNcQ.js +1 -0
- package/dist/assets/ChatDefaultsTab-CgTm4WMx.js +1 -0
- package/dist/assets/{DataTableShell-CgfEZzcq.js → DataTableShell-REGK6Dqj.js} +1 -1
- package/dist/assets/{DetailChips-BWOhDvfm.js → DetailChips-Dhiulk-F.js} +1 -1
- package/dist/assets/FeedbacksTab-DpWIlp9R.js +1 -0
- package/dist/assets/{FieldLabel-ObN4xPwN.js → FieldLabel-CFBfL_GK.js} +1 -1
- package/dist/assets/FilesTab-VZuW17oP.js +1 -0
- package/dist/assets/{FilterBar-YVVbd65x.js → FilterBar-CJwP10CI.js} +1 -1
- package/dist/assets/GroupsTab-BjJmfc7f.js +1 -0
- package/dist/assets/InstancesTab-Ofqk-EZR.js +1 -0
- package/dist/assets/IntegrationsTab-Cey3WV3E.js +1 -0
- package/dist/assets/KpiTab-DIRKI4qa.js +1 -0
- package/dist/assets/PreferencesTab-BfHNBONO.js +1 -0
- package/dist/assets/ProjectPage-BsJB0GCv.js +1 -0
- package/dist/assets/PromptInjectionsTab-KdBPVl-W.js +4 -0
- package/dist/assets/RolesTab-DdooYgwg.js +1 -0
- package/dist/assets/ScheduledTab-AArpRKQU.js +1 -0
- package/dist/assets/ServiceAccountsTab-ByKfn9jX.js +1 -0
- package/dist/assets/SubAgentReportsTab-BMxqMtk1.js +1 -0
- package/dist/assets/ThemeShowroom-Ctv3Ktd3.js +1 -0
- package/dist/assets/{TimeRangePicker-Bo3B16zc.js → TimeRangePicker-es8qiYT0.js} +1 -1
- package/dist/assets/{TimezoneCombobox-DvhM5ae3.js → TimezoneCombobox-DSIM9YOb.js} +1 -1
- package/dist/assets/TracesTab-CXdVaFxl.js +1 -0
- package/dist/assets/TrashPage-DBE3OVMc.css +1 -0
- package/dist/assets/TrashPage-DwgS7gln.js +1 -0
- package/dist/assets/TrashTab-CAfRYG_t.js +1 -0
- package/dist/assets/UsersTab-B29t4KCa.js +1 -0
- package/dist/assets/VoiceTab-BaN-J1s2.js +1 -0
- package/dist/assets/api-DfVtzU1G.js +44 -0
- package/dist/assets/button-BWdRKrS3.js +1 -0
- package/dist/assets/{card-MbRTJSAv.js → card-CdvSrnID.js} +1 -1
- package/dist/assets/chevrons-up-down-RHDK4dlM.js +1 -0
- package/dist/assets/{compatView-Bc7ErYFT.js → compatView-ChkOVx0F.js} +1 -1
- package/dist/assets/dispatchErrorInfo-CpWqaJBx.js +1 -0
- package/dist/assets/dist-CGHNQwsf.js +1 -0
- package/dist/assets/dist-CdViHsIv.js +1 -0
- package/dist/assets/{dist-QaMCaCpK.js → dist-D8270q9m.js} +1 -1
- package/dist/assets/{dist-CgIoeCFu.js → dist-cnxPdTGN.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-BHc3abNI.js → highlighted-body-OFNGDK62-CrlMHfOs.js} +1 -1
- package/dist/assets/index-B0MXmi3m.js +327 -0
- package/dist/assets/index-Dwpglqo3.css +1 -0
- package/dist/assets/{list-CTSN7gc5.js → list-CR2YIdia.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-n8ziFmjV.js +1 -0
- package/dist/assets/{pdf-CMtKos9j.js → pdf-D1bMzEYl.js} +1 -1
- package/dist/assets/roleDescriptions-DBqNfMhe.js +1 -0
- package/dist/assets/{table-VhRaEfeZ.js → table-CVSQWo7b.js} +1 -1
- package/dist/assets/use_paginated_query-DSw-EOJL.js +1 -0
- package/dist/assets/x-CrZwGtLz.js +1 -0
- package/dist/index.html +9 -8
- package/package.json +3 -2
- package/dist/assets/AccessTab-ltWQiPGn.js +0 -1
- package/dist/assets/AgentFilesTab-DKg-5AOZ.js +0 -3
- package/dist/assets/AnomaliesTab-Dshz0Xdo.js +0 -1
- package/dist/assets/AuditTab-DZViPs0S.js +0 -1
- package/dist/assets/BridgeTab-CULepdP_.js +0 -1
- package/dist/assets/ChatDefaultsTab-BW8xCDPC.js +0 -1
- package/dist/assets/FeedbacksTab-CtKRbyAA.js +0 -1
- package/dist/assets/FilesTab-CmzQqlbZ.js +0 -1
- package/dist/assets/GroupsTab-C4hW_HZp.js +0 -1
- package/dist/assets/InstancesTab-BScBfWJZ.js +0 -1
- package/dist/assets/IntegrationsTab-BoN5nv7u.js +0 -1
- package/dist/assets/KpiTab-CZk6V7_p.js +0 -1
- package/dist/assets/PreferencesTab-C6_BZOL8.js +0 -1
- package/dist/assets/ProjectPage-D0_yFA88.js +0 -1
- package/dist/assets/PromptInjectionsTab-BToYYWRN.js +0 -4
- package/dist/assets/RolesTab-Dqf82Nw4.js +0 -1
- package/dist/assets/ScheduledTab-DgYEuqzx.js +0 -1
- package/dist/assets/ServiceAccountsTab-BuxSQV5z.js +0 -1
- package/dist/assets/SubAgentReportsTab-CbhBlx3_.js +0 -1
- package/dist/assets/ThemeShowroom-Bq3JZseY.js +0 -1
- package/dist/assets/TracesTab-BYz48MmX.js +0 -1
- package/dist/assets/UsersTab-CRl1CgUo.js +0 -1
- package/dist/assets/VoiceTab-D9o7TRAg.js +0 -1
- package/dist/assets/api-CKGeK7QS.js +0 -44
- package/dist/assets/button-HWWS6bgL.js +0 -1
- package/dist/assets/chevrons-up-down-AQ82L9UQ.js +0 -1
- package/dist/assets/dispatchErrorInfo-cGLdZODI.js +0 -1
- package/dist/assets/dist-BVlixrts.js +0 -1
- package/dist/assets/index-0DcZwf39.css +0 -1
- package/dist/assets/index-BZLPehFE.js +0 -327
- package/dist/assets/mermaid-GHXKKRXX-vvzO9QCP.js +0 -1
- package/dist/assets/roleDescriptions-B2IUxsB1.js +0 -1
- package/dist/assets/x-CZJSCjdP.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-
|
|
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-
|
|
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-
|
|
68
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
69
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
70
|
-
<link rel="modulepreload" crossorigin href="/assets/dist-
|
|
71
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
72
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
73
|
-
<link rel="
|
|
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.
|
|
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": "
|
|
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{EK as r,IK as i,ay as a,cy as o,dy as s,ey as c,fy as l,iy as u,ly as d,my as f,ny as p,oy as m,py as h,ry as g,sy as _,t as v,ty as y,uy as b}from"./api-CKGeK7QS.js";import{At as x,et as S,it as C,nt as w,rt as T,tt as E}from"./index-BZLPehFE.js";var D=t(e(),1);function O(e){return e===`user`?u():e===`all`?g():p({group:e.group})}function k(e){return e===`common`?y():e===`owner`?c():p({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=i(v.admin.listUsers,{}),[t,n]=(0,D.useState)(``),c=i(v.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:f()}),(0,A.jsxs)(S,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":h(),children:(0,A.jsx)(C,{placeholder:h()})}),(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:l()}):c===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:s()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:c.user.label}),(0,A.jsx)(x,{variant:`secondary`,children:c.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:b()}),c.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:c.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:d()}),c.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:c.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:a()}):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:o()}),c.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:c.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:_()}),c.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:c.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{A_ as r,Ad as i,Ag as a,Bg as o,Cd as s,Cg as c,Co as l,Dd as u,Dg as d,EK as f,Ed as p,Eg as m,FK as h,Fg as g,Gg as ee,Gu as _,Hg as v,IK as y,Ig as b,Ju as x,Kg as S,Ku as C,LL as w,Lg as T,M_ as E,Md as D,Mg as te,NK as O,Nd as k,Ng as A,OK as j,Od as M,Og as N,Pg as P,Rg as ne,Sd as F,Sg as I,Td as L,Tg as R,Ug as re,Vg as z,Wg as B,Xu as V,Yu as ie,Zu as H,_d as U,_g as W,bd as G,bg as ae,gd as oe,hd as K,jd as q,jg as se,kd as ce,kg as le,md as ue,pd as de,qu as fe,t as J,vd as pe,vg as me,wd as he,wg as ge,xd as _e,xg as ve,yd as ye,yg as be,zg as xe}from"./api-CKGeK7QS.js";import{t as Y}from"./button-HWWS6bgL.js";import{At as Se,Ct as Ce,Dt as we,Et as Te,Ot as Ee,St as De,Tt as Oe,V as ke,Z as Ae,at as je,et as Me,it as Ne,jt as Pe,kt as Fe,lt as Ie,nt as Le,ot as Re,rt as ze,st as Be,tt as Ve,un as He,ut as Ue,wt as We}from"./index-BZLPehFE.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-Bc7ErYFT.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=y(J.me.getMe,{host:Ae}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),a=y(J.admin.listInstances,e!==void 0&&t?{}:`skip`),[s,c]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!a||a.length===0||(!s||!a.some(e=>e.name===s))&&c(a[0].name)},[t,a,s]);let u=y(J.agents.listAgentsForInstance,t&&s?{instanceName:s}:`skip`),d=y(J.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),p=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return s===null||u===void 0?a!==void 0&&a.length===0?[]:void 0:u.agents.map(e=>({instanceName:s,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(d!==void 0)return d.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,s,u,a,d]),[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 _=p?.find(e=>$(e)===m)??null,x=O(J.agentFiles.listAgentFiles),[C,w]=(0,X.useState)({status:`idle`}),E=_?.instanceName??null,D=_?.agentId??null,te=y(J.compat.forInstance,n&&E!==null?{instanceName:E}:`skip`),k=n&&E!==null?ke(te,`agentFiles`):null,A=k===null?!1:k===`loading`?null:k.blocked,N=(0,X.useCallback)(async()=>{if(!(E===null||D===null)){w({status:`loading`});try{w({status:`done`,files:(await x({instanceName:E,agentId:D})).files})}catch(e){w({status:`error`,dashboardAbsent:tt(e)})}}},[x,E,D]);(0,X.useEffect)(()=>{A===!1&&N()},[N,A]);let[F,I]=(0,X.useState)(null),L=y(J.agentFileCuration.listCurations,t&&E!==null&&D!==null?{instanceName:E,agentId:D}:`skip`),R=y(J.agentFileCuration.curationSettings,t&&E!==null?{instanceName:E}:`skip`),V=O(J.agentFileCuration.requestCuration),[ie,H]=(0,X.useState)(null),[U,W]=(0,X.useState)(null),{toast:G}=Pe(),ae=(0,X.useMemo)(()=>{let e=new Map;for(let t of L??[])e.has(t.name)||e.set(t.name,t);return e},[L]),oe=(0,X.useCallback)(async e=>{if(!(E===null||D===null)){H(e);try{let t=await V({instanceName:E,agentId:D,name:e,trigger:`manual`});t.ok?G({title:i(),variant:`success`}):G({title:ce({reason:t.reason??`unknown`}),variant:`error`})}catch{G({title:M(),variant:`error`})}finally{H(null)}}},[V,E,D,G]),K=j(),q=(0,X.useMemo)(()=>new Intl.NumberFormat(K,{maximumFractionDigits:0}),[K]);return e===void 0||p===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(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&&(a?.length??0)>1?(0,Q.jsxs)(Me,{value:s??``,onValueChange:e=>c(e),children:[(0,Q.jsx)(ze,{size:`sm`,"aria-label":ee(),children:(0,Q.jsx)(Ne,{})}),(0,Q.jsx)(Ve,{children:(a??[]).map(e=>(0,Q.jsx)(Le,{value:e.name,children:e.name},e.name))})]}):null,p.length>0?(0,Q.jsxs)(Me,{value:m??``,onValueChange:e=>h(e),children:[(0,Q.jsx)(ze,{size:`sm`,"aria-label":B(),children:(0,Q.jsx)(Ne,{})}),(0,Q.jsx)(Ve,{children:p.map(e=>(0,Q.jsx)(Le,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:re()})]}),_===null?null:k===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):k!==null&&k.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(He,{size:14,"aria-hidden":!0}),` `,qe(k.gatewayVersion,k.provider)]}):C.status===`loading`||C.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):C.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[C.dashboardAbsent?l():z(),` `,!C.dashboardAbsent&&(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void N(),children:r()})]}):C.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(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)(Se,{variant:`outline`,children:o()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:xe({size:Z(e.size,K)})}),(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:ne({pct:q.format(n)})}),r?(0,Q.jsx)(He,{size:14,className:`oc-afiles__warn`,"aria-label":T()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>I(e),children:t?g():P()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:R?.budgetChars??null,enabled:R?.enabled??!1,curation:ae.get(e.name)??null,inFlight:ie===e.name,onCurate:()=>void oe(e.name),onReview:e=>W(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:b({used:Z(Qe(C.files),K),total:Z(Ye,K),pct:q.format(Ze(Qe(C.files)))})})]}),F&&_?(0,Q.jsx)(at,{instanceName:_.instanceName,agentId:_.agentId,name:F.name,isAdmin:t,onClose:()=>I(null),onSaved:()=>void N()}):null,U?(0,Q.jsx)(ot,{curationId:U,onClose:()=>W(null),onApplied:()=>{W(null),N()}}):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)(Y,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:D()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(Se,{variant:`outline`,className:`oc-afiles__curate-status`,children:q()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:k()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:i,onClose:o,onSaved:s}){let l=O(J.agentFiles.getAgentFile),u=O(J.agentFiles.setAgentFile),p=Pe(),[h,g]=(0,X.useState)(null),[ee,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[T,D]=(0,X.useState)(!1),[k,M]=(0,X.useState)(!1),P=(0,X.useCallback)(async r=>{_(!1);try{let i=await l({instanceName:e,agentId:t,name:n});g({content:i.content,updatedAtMs:i.updatedAtMs}),r||y(i.content),D(!1)}catch{_(!0)}},[l,e,t,n]);(0,X.useEffect)(()=>{P(!1)},[P]);async function ne(){if(h!==null){C(!0),M(!1);try{await u({instanceName:e,agentId:t,name:n,content:v,baseUpdatedAtMs:h.updatedAtMs??void 0}),p.success(d({name:n})),s(),await P(!1)}catch(e){nt(e)?D(!0):M(!0)}finally{C(!1)}}}let F=h!==null&&v!==h.content,L=(0,X.useMemo)(()=>h===null?null:et(h.content,v),[h,v]),re=v.length>Je,z=j(),B=(0,X.useMemo)(()=>new Intl.NumberFormat(z),[z]);return(0,Q.jsx)(je,{open:!0,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Ie,{children:[(0,Q.jsx)(Ue,{children:A({name:n})}),(0,Q.jsxs)(Be,{children:[te({agent:t,instance:e}),i?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,se()]})]})]}),ee?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[R(),` `,(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void P(!1),children:r()})]}):h===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:v,readOnly:!i,spellCheck:!1,onChange:e=>y(e.target.value),"aria-label":A({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:a()}),T?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ge(),` `,(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void P(!0),children:c()})]}):null,k?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:m()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${re?` is-over`:``}`,children:le({count:B.format(v.length),max:B.format(Je)})}),i?(0,Q.jsx)(Y,{size:`sm`,disabled:!F||S||T,onClick:()=>x(!0),children:S?E():N()}):null]})]}),(0,Q.jsx)(De,{open:b,onOpenChange:x,children:(0,Q.jsxs)(Oe,{children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(Fe,{children:I({name:n})}),(0,Q.jsx)(Te,{children:ve({agent:t})})]}),L?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:ae({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:be()}),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:me()}),L.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(we,{children:[(0,Q.jsx)(We,{children:w()}),(0,Q.jsx)(Ce,{onClick:()=>void ne(),children:W()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let r=y(J.agentFileCuration.getProposal,{curationId:e}),i=O(J.agentFileCuration.approveCuration),a=h(J.agentFileCuration.rejectCuration),{toast:o}=Pe(),[c,l]=(0,X.useState)(null),[d,m]=(0,X.useState)(!1),[g,ee]=(0,X.useState)(``),v=j(),b=(0,X.useMemo)(()=>r?et(r.beforeContent,r.proposedContent):null,[r]);async function S(){l(`approve`);try{let t=await i({curationId:e});t.ok?(o({title:u(),variant:`success`}),n()):o({title:t.reason===`conflict`?L():he({reason:t.reason??`unknown`}),variant:`error`})}catch{o({title:M(),variant:`error`})}finally{l(null)}}async function w(n){l(`reject`);try{let r=g.trim();(await a({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?o({title:n?C():p(),variant:`success`}):o({title:_e(),variant:`error`}),t()}catch{o({title:M(),variant:`error`})}finally{l(null)}}return(0,Q.jsx)(je,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(Re,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Ie,{children:[(0,Q.jsx)(Ue,{children:r?s({name:r.name}):f()}),(0,Q.jsx)(Be,{children:F()})]}),r===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:_e()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[G({before:Z(r.beforeSize,v),after:Z(r.proposedSize,v)}),r.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(He,{size:13,"aria-hidden":!0}),` `,ye()]}):null]}),b?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:pe({added:b.added,removed:b.removed})}):null,r.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:_({feedback:r.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:de()}),(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:ue()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:U()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:r.proposedContent})]})]})]}),d?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:H()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:V(),value:g,onChange:e=>ee(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(Y,{variant:`ghost`,onClick:()=>m(!1),disabled:c!==null,children:ie()}),(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>void w(!1),disabled:c!==null,children:c===`reject`?E():x()}),(0,Q.jsx)(Y,{variant:`default`,onClick:()=>void w(!0),disabled:c!==null,children:c===`reject`?E():fe()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>m(!0),disabled:c!==null||r==null,children:oe()}),(0,Q.jsx)(Y,{variant:`default`,onClick:()=>void S(),disabled:c!==null||r==null,children:c===`approve`?E():K()})]})]})})}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,Bk as a,Ck as o,Dk as ee,Ek as te,FK as ne,Fk as re,IK as s,Ik as ie,JO as c,KO as l,Lk as ae,Mk as oe,Nk as se,Ok as ce,Pk as le,QO as u,Rk as ue,Sk as de,Tk as fe,Vk as d,XO as f,YO as p,ZO as m,_k as pe,ak as h,bk as g,ck as _,dk as v,ek as me,fk as he,gk as ge,hk as _e,ik as ve,jk as ye,kk as be,lk as xe,mk as Se,nk as Ce,ok as y,pk as b,qO as x,rk as S,sk as C,t as w,tk as T,uk as E,vk as D,wk as O,xk as k,yk as A,zk as j}from"./api-CKGeK7QS.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-BZLPehFE.js";import{n as Ae}from"./TimeRangePicker-Bo3B16zc.js";import{t as je}from"./FilterBar-YVVbd65x.js";import{t as Me}from"./DataTableShell-CgfEZzcq.js";import{t as W}from"./dispatchErrorInfo-cGLdZODI.js";var G=t(e(),1),K=n(),q=`__all__`,Ne=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Pe(e){return e===`open`?d():e===`acknowledged`?a():j()}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??``,r=e.status===J?q:e.status,a=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}),x=e=>void t({search:t=>({...t,status:e===q?J:e})}),j=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=ne(w.anomalies.resolveAnomaly),Y=(s(w.me.getMe,{host:Te})?.permissions??[]).includes(`admin.manage`),X=s(w.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:f,to:p,anomalyStatus:r===q?void 0:r,severity:a===q?void 0:a,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!==``||r!==`open`||a!==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:ue(),description:(0,K.jsxs)(K.Fragment,{children:[ae(),` `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,ie(),` `,(0,K.jsx)(`strong`,{children:re()}),`.`,` `,le()]}),confirmLabel:se()}))try{await W({anomalyId:e._id,status:`resolved`}),U.success(oe(),e.kind)}catch(e){U.error(ye(),e)}}async function Ge(e){try{await W({anomalyId:e._id,status:`acknowledged`}),U.success(i(),e.kind)}catch(e){U.error(be(),e)}}return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`oc-admin__hint`,children:[ce(),` `,(0,K.jsx)(`strong`,{children:ee()}),` `,te(),` `,(0,K.jsx)(`strong`,{children:fe()}),` `,O(),` `,(0,K.jsx)(`strong`,{children:o()}),` `,de(),` `,(0,K.jsx)(`span`,{className:`oc-filter__window`,children:k()})]}),(0,K.jsxs)(je,{q:n,onQChange:m,searchPlaceholder:g(),timeRange:d,onTimeRangeChange:R,onReset:Ue,canReset:Q,children:[(0,K.jsxs)(F,{value:r,onValueChange:x,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:A()}),Ne.map(e=>(0,K.jsx)(z,{value:e.value,children:Pe(e.value)},e.value))]})]}),(0,K.jsxs)(F,{value:a,onValueChange:j,children:[(0,K.jsx)(V,{size:`sm`,className:`w-36`,children:(0,K.jsx)(L,{placeholder:D()})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:Se()}),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:b()})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:he()}),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:v()})}),(0,K.jsxs)(H,{children:[(0,K.jsx)(z,{value:q,children:E()}),Z.map(e=>(0,K.jsx)(z,{value:e,children:e},e))]})]})]}),(0,K.jsx)(Me,{title:xe(),rows:X,emptyHint:r===`open`?_():C(),rowActions:e=>Y&&e.status===`open`?[{label:y(),onSelect:()=>void We(e)},{label:h(),onSelect:()=>void Ge(e)}]:[],columns:[{header:ve(),cell:e=>(0,K.jsx)(`span`,{className:`oc-traces__time`,children:I(e.at)}),sort:e=>e.at},{header:v(),cell:e=>(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:pe(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,K.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:_e({when:I(e.firstAt)}),children:ge({count:String(e.occurrenceCount)})}):(0,K.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:D(),cell:e=>(0,K.jsx)(Be,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:S(),cell:e=>(0,K.jsx)(Ve,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:b(),cell:e=>(0,K.jsx)(M,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:Ce(),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)(ze,{row:e})]}),sort:e=>e.message},{header:T(),cell:e=>(0,K.jsx)($,{row:e}),sort:e=>e.evidence??null},{header:me(),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 $({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:[`↗ `,r()]}):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:[`↗ `,r()]})}):(0,K.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let i=W(n.dominantCode),a=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:i.label}),(0,K.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,K.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:i.hint}),a?(0,K.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:a,limit:100}}),children:[`↗ `,r()]}):null]})}function ze({row:e}){let[t,n]=(0,G.useState)(!1),r=s(w.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:[u(),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:m()})}),r===void 0?(0,K.jsx)(`p`,{className:`oc-traces__muted`,children:f()}):r.length===0?(0,K.jsx)(`p`,{className:`oc-traces__muted`,children:p()}):(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:c()}):e===`acknowledged`?(0,K.jsx)(M,{variant:`secondary`,children:x()}):(0,K.jsx)(M,{variant:`outline`,children:l()})}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{BA as r,FA as i,GA as a,Gl as o,HA as s,Hl as c,IA as l,IK as u,KA as d,Kl as f,LA as p,NA as m,PA as h,RA as g,UA as _,Ul as v,VA as y,WA as b,Wl as x,qA as S,ql as C,t as w,zA as T}from"./api-CKGeK7QS.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-BZLPehFE.js";import{n as ee}from"./TimeRangePicker-Bo3B16zc.js";import{t as z}from"./FilterBar-YVVbd65x.js";import{t as B}from"./AdvancedFilter-D_IAxoTH.js";import{t as V}from"./DataTableShell-CgfEZzcq.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:f()},{value:`targetLabel`,label:o()},{value:`impersonated`,label:x()},{value:`resource`,label:v()},{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,f=e.resource??G,v=j(e.from,e.to),x=(0,H.useMemo)(()=>L(e.adv),[e.adv]),{from:C,to:N}=ee(v),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}),$=u(w.admin.listAudit,{filter:{q:n||void 0,from:C,to:N,action:o===G?void 0:o,resource:f===G?void 0:f,impersonated:c===G?void 0:c===`yes`,advanced:x.length>0?x: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||f!==G||x.length>0||v.kind!==`relative`||v.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:d()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:a(),timeRange:v,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:b()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(P,{value:G,children:_()}),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:s()}),(0,U.jsx)(P,{value:`yes`,children:y()}),(0,U.jsx)(P,{value:`no`,children:r()})]})]}),(0,U.jsxs)(k,{value:f,onValueChange:X,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()}),ne.map(e=>(0,U.jsx)(P,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:x,onChange:Q}),(0,U.jsx)(V,{title:p(),rows:$,emptyHint:l(),columns:[{header:i(),cell:e=>A(e.at),sort:e=>e.at},{header:b(),cell:e=>e.action,sort:e=>e.action},{header:h(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:m(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:T(),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,AT as a,BE as o,BT as s,CT as c,D as l,DT as u,ET as d,FK as f,FT as p,GE as m,GT as h,HE as ee,HT as g,IE as te,IK as _,IT as v,JT as y,Jh as b,KE as ne,KT as re,LE as ie,LT as ae,ME as oe,MT as se,NE as ce,NK as le,NT as ue,OT as de,PT as fe,QT as pe,Qh as me,RE as he,RT as ge,ST as _e,TT as ve,UE as ye,UT as be,Uh as xe,VE as Se,VT as x,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,cE as Pe,dl as Fe,eE as Ie,eg as Le,fT as S,fl as Re,gT as ze,gl as Be,hT as Ve,iE as He,ig as Ue,jT as We,kT as Ge,lE as Ke,ll as qe,mT as C,nE as Je,ng as Ye,oE as Xe,og as Ze,pT as Qe,pl as $e,qT as et,rE as tt,ra as nt,rg as rt,sE as it,t as w,tE as at,tg as T,uE as ot,ul as st,vT as ct,wT as lt,wo as ut,xT as dt,yT as ft,zE as pt,zT as mt}from"./api-CKGeK7QS.js";import{r as E}from"./dist-QaMCaCpK.js";import{t as ht}from"./chevrons-up-down-AQ82L9UQ.js";import{i as gt,n as D,o as _t,r as vt,s as yt}from"./FieldLabel-ObN4xPwN.js";import{t as bt}from"./button-HWWS6bgL.js";import{At as O,Bn as xt,Ft as k,G as St,Gn as Ct,Ht as wt,K as Tt,Kn as Et,N as Dt,On as Ot,U as kt,Ut as At,Vn as A,W as jt,Wt as Mt,Z as Nt,at as Pt,et as j,ft as M,it as N,jt as Ft,lt as It,mn as P,mt as Lt,nt as F,ot as Rt,pt as I,rt as L,st as zt,tt as R,un as z,ut as Bt,zn as B}from"./index-BZLPehFE.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-VhRaEfeZ.js";import{t as Gt}from"./FilterBar-YVVbd65x.js";import{c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./compatView-Bc7ErYFT.js";import{t as W}from"./dispatchErrorInfo-cGLdZODI.js";var $t=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),en=l(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function tn(e){return e.filter(e=>e.state===`error`)}function nn(e){return e.reachable&&tn(e.targets).length===0}function rn(e){return nn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function an(e){return e.state===`error`&&e.lastErrorCode!==null}function on(e){return!!e.lastDownstreamRejectCode}function sn(e){return!!e.lastLocalRefusalCode}function cn(e){return an(e)||on(e)||sn(e)}function K(e){return e.kind??`openclaw`}function ln(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function un(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,K(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return ln(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K(e)===r)}))}function q(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J=`__all__`,dn={q:``,state:J,instance:J,version:J},Y={connected:0,error:1,idle:2};function fn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function pn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function X(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function mn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function hn(e,t,n){switch(e){case`state`:return(Y[t.state]??99)-(Y[n.state]??99);case`instance`:return X(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return X(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Zt(e,r)??X(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return X(t.targetLabel,n.targetLabel)}}function gn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=mn(t.key,e),a=mn(t.key,r);return i&&a?0:i?1:a?-1:n*hn(t.key,e,r)})}function _n(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(Y[e]??99)-(Y[t]??99))}function vn(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>X(e.label,t.label))}function yn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Zt(e,t)??X(e,t))}var Z=n();function bn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(dn),[i,o]=(0,G.useState)(null),s=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(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]),l=(0,G.useMemo)(()=>_n(s),[s]),f=(0,G.useMemo)(()=>vn(s),[s]),p=(0,G.useMemo)(()=>yn(s),[s]),m=(0,G.useMemo)(()=>gn(pn(s,n),i),[s,n,i]);function h(e){o(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):(0,Z.jsxs)(`div`,{className:`oc-conn`,children:[(0,Z.jsxs)(Gt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:u(),onReset:()=>r(dn),canReset:fn(n),children:[(0,Z.jsxs)(j,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(N,{placeholder:ve()})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(F,{value:J,children:d()}),l.map(e=>(0,Z.jsx)(F,{value:e,children:Sn(e)},e))]})]}),(0,Z.jsxs)(j,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-40`,children:(0,Z.jsx)(N,{placeholder:lt()})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(F,{value:J,children:d()}),f.map(e=>(0,Z.jsx)(F,{value:e.name,children:e.label},e.name))]})]}),(0,Z.jsxs)(j,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-36`,children:(0,Z.jsx)(N,{placeholder:c()})}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(F,{value:J,children:d()}),p.map(e=>(0,Z.jsx)(F,{value:e,children:e},e))]})]})]}),m.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:_e()}):(0,Z.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Z.jsx)(Ht,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(Q,{label:dt(),sortKey:`target`,sort:i,onSort:h}),(0,Z.jsx)(Q,{label:Ne(),sortKey:`state`,sort:i,onSort:h}),(0,Z.jsx)(Q,{label:ft(),sortKey:`instance`,sort:i,onSort:h}),(0,Z.jsx)(Q,{label:ct(),sortKey:`host`,sort:i,onSort:h}),(0,Z.jsx)(Q,{label:Ae(),sortKey:`version`,sort:i,onSort:h}),(0,Z.jsx)(V,{children:ze()}),(0,Z.jsx)(Q,{label:Ve(),sortKey:`lastOk`,sort:i,onSort:h})]})}),(0,Z.jsx)(Ut,{children:m.map(e=>(0,Z.jsx)(xn,{r:e},e._id))})]})]})}function Q({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Z.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Z.jsx)(xt,{size:13,"aria-hidden":!0}):(0,Z.jsx)(E,{size:13,"aria-hidden":!0}):(0,Z.jsx)(ht,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function xn({r:e}){let t=an(e)?W(e.lastErrorCode):null,n=on(e)?W(e.lastDownstreamRejectCode):null,r=sn(e)?W(e.lastLocalRefusalCode):null;return(0,Z.jsxs)(G.Fragment,{children:[(0,Z.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Z.jsx)(U,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(Cn,{state:e.state})}),(0,Z.jsx)(U,{children:e.instanceLabel?(0,Z.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Z.jsx)(U,{children:e.gatewayVersion?(0,Z.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Z.jsx)(U,{children:(0,Z.jsx)(`span`,{className:`oc-conn__stats`,children:Ge({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Z.jsx)(U,{children:e.lastOkAt?(0,Z.jsx)(`span`,{className:`oc-traces__mono`,children:I(e.lastOkAt)}):(0,Z.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),cn(e)?(0,Z.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Z.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Z.jsx)(`strong`,{children:t.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${I(e.lastErrorAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[nt({label:r.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${I(e.lastLocalRefusalAt)}`:``,(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Z.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[de({label:n.label}),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${I(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function Sn(e){return e===`connected`?C():e===`error`?Qe():S()}function Cn({state:e}){return e===`connected`?(0,Z.jsx)(O,{variant:`secondary`,children:C()}):e===`error`?(0,Z.jsx)(O,{variant:`destructive`,children:Qe()}):(0,Z.jsx)(O,{variant:`outline`,children:S()})}function wn(){return _(w.bridgeHealth.getBridgeHealth,{})}function Tn(){let e=wn(),t=_(w.compat.getBridgeCompat,{}),n=_(w.me.getMe,{host:Nt})?.role===`admin`,r=_(w.admin.listInstances,n?{}:`skip`),i=_(w.agents.usageForInstances,n?{}:`skip`),a=Ct(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=un(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=Et({from:`/settings/bridge`}),l=Ct({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Xt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Z.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Z.jsx)(En,{health:e,compat:t,onSeeAnomalies:o}),(0,Z.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:we()}),i&&i.length>0?(0,Z.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Z.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:Ee()}),(0,Z.jsxs)(Wt,{children:[(0,Z.jsx)(Ht,{children:(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{children:$e()}),(0,Z.jsx)(V,{children:Re()}),(0,Z.jsx)(V,{children:Fe()}),(0,Z.jsx)(V,{children:st()}),(0,Z.jsx)(V,{children:qe()})]})}),(0,Z.jsx)(Ut,{children:i.flatMap(e=>{let t=Dt(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Z.jsx)(U,{children:t.provider}),(0,Z.jsx)(U,{children:t.label}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(O,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Z.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Z.jsxs)(kt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Z.jsx)(St,{className:`w-full`,children:s.map(e=>(0,Z.jsxs)(Tt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Z.jsx)(P,{size:13,"aria-hidden":!0}),q(e.key)]},e.key))}),s.map(e=>(0,Z.jsx)(jt,{value:e.key,children:(0,Z.jsx)(Dn,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}):null]})}function En({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,i=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,a=t&&t!==null?(0,Z.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(t.bridgeVersion)}),i?(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsxs)(`code`,{className:`oc-traces__mono`,title:Ue(),children:[`(`,i,`)`]})]}):null,r?(0,Z.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,rt({build:t.buildVersion??`?`})]}):null,` · `,Ye(),` `,(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?T():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:x()});if(e===null)return(0,Z.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:s()});let o=tn(e.targets),c=!e.reachable,l=rn(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=M(e.checkedAt),m=e.startedAt==null?null:M(e.startedAt);return(0,Z.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Z.jsx)(B,{size:22}):c||l===`gateways_unreachable`?(0,Z.jsx)(en,{size:22}):(0,Z.jsx)(z,{size:22})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Z.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?mt():l===`gateways_unreachable`?p({count:u.length}):c?ge():ae({count:o.length})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)($t,{size:12,"aria-hidden":!0}),` `,v({time:f})]}),m?(0,Z.jsx)(`span`,{children:ue({time:m})}):null,a]}),l===`gateways_unreachable`?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:fe({names:u.join(`, `)})}):null,c?(0,Z.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Z.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:se()})]})}function Dn({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=Qt(l.map(e=>e.state)),[f,p]=(0,G.useState)(!1);return(0,Z.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Z.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Z.jsx)(P,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Z.jsx)(`span`,{className:`oc-bridge-provider__name`,children:q(e)}),d?(0,Z.jsx)(O,{variant:d===`beyond`||d===`defective`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Z.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Ze()}),(0,Z.jsx)(kn,{providerName:q(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Z.jsx)(On,{protocol:o}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,Z.jsx)(E,{size:13,"aria-hidden":!0}):(0,Z.jsx)(A,{size:13,"aria-hidden":!0}),We({count:t.length})]}),f?(0,Z.jsx)(bn,{connections:t,displayByInstance:c}):null]})}function On({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],a=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[y(),i.length>0?(0,Z.jsx)(O,{variant:`destructive`,children:re({count:i.length})}):a>0?(0,Z.jsx)(O,{variant:`destructive`,children:h()}):(0,Z.jsx)(O,{variant:`secondary`,children:et()})]}),(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[Ce({version:e.vendoredVersion}),r?` · `+be({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a>0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ut({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,i.length>0?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Z.jsx)(E,{size:13,"aria-hidden":!0}):(0,Z.jsx)(A,{size:13,"aria-hidden":!0}),g({count:r.gapList.length})]}),t?(0,Z.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function kn({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:a,providerName:o}){return t===`loading`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:x()}):t===`nodata`?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):(0,Z.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:Le()}),r===null?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:i()}):(0,Z.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__label`,children:Be({provider:o})}),e&&e.range!==null?(0,Z.jsx)(`span`,{children:me({min:e.range.min,max:e.range.maxValidated})}):(0,Z.jsx)(`span`,{children:T()}),e?(0,Z.jsx)(Mn,{versions:e.validatedVersions}):null]}),a.length===0?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,Z.jsx)(`div`,{className:`oc-compat__targets`,children:a.map(e=>(0,Z.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Z.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Z.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(e.version)}),(0,Z.jsx)(O,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function An({instance:e,onClose:t}){return(0,Z.jsx)(Pt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(Rt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(It,{children:[(0,Z.jsx)(Bt,{children:ne({instance:e.displayName??e.name})}),(0,Z.jsx)(zt,{children:m()})]}),(0,Z.jsx)(jn,{instance:e,onClose:t})]})})}function $({label:e,result:t}){return t?t.checked?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Z.jsx)(B,{"aria-hidden":!0}):(0,Z.jsx)(z,{"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[e,` — `,t.ok?Ie():t.detail]})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,r()]}):null}function jn({instance:e,onClose:t}){let n=f(w.admin.upsertInstanceConfig),r=le(w.bridge.validateMediaPaths),i=Ft(),a=Vt(e.config?.contentLocale,void 0),[s,c]=(0,G.useState)(()=>gt(e.config??{},a)),[l,u]=(0,G.useState)(!1),[d,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),g=s.inboundMediaMode===`shared-fs`,_=s.mediaMode===`shared-fs`,v=g||_;async function y(){p(!0),h(null);try{h(await r({instanceName:e.name,inboundMediaMode:s.inboundMediaMode,mediaMode:s.mediaMode}))}catch(e){i.error(He(),e)}finally{p(!1)}}async function b(){u(!0);try{let r=e.config??{};await n({instanceId:e._id,config:vt(s,r,a)}),t()}catch(e){i.error(he(),e)}finally{u(!1)}}return(0,Z.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Z.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(D,{label:ye(),help:ie()}),(0,Z.jsxs)(j,{value:s.mediaMode,onValueChange:e=>c({...s,mediaMode:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(N,{})}),(0,Z.jsx)(R,{children:yt.map(e=>(0,Z.jsx)(F,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(D,{label:ee(),help:te()}),(0,Z.jsxs)(j,{value:s.inboundMediaMode,onValueChange:e=>c({...s,inboundMediaMode:e}),children:[(0,Z.jsx)(L,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(N,{})}),(0,Z.jsx)(R,{children:_t.map(e=>(0,Z.jsx)(F,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(D,{label:Se(),help:ce()}),(0,Z.jsx)(k,{type:`number`,min:1,max:4096,className:`w-full`,value:s.mediaMaxMb,onChange:e=>c({...s,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),v&&(0,Z.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[g&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(D,{label:ot(),help:Ke()}),(0,Z.jsx)(k,{className:`w-full`,spellCheck:!1,value:s.inboundAgentMount,onChange:e=>c({...s,inboundAgentMount:e.target.value})})]}),_&&(0,Z.jsxs)(`label`,{className:`oc-field`,children:[(0,Z.jsx)(D,{label:Pe(),help:it()}),(0,Z.jsx)(k,{className:`w-full`,spellCheck:!1,value:s.outboundAgentMount,onChange:e=>c({...s,outboundAgentMount:e.target.value})})]})]}),(0,Z.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Z.jsx)(Lt,{checked:s.rehydration,onCheckedChange:e=>c({...s,rehydration:e===!0})}),(0,Z.jsx)(D,{label:o(),help:oe()})]}),v&&m!==null&&(0,Z.jsx)(`div`,{className:`oc-bridge-config__check`,children:m.reachable?!m.inbound&&!m.outbound?(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(z,{"aria-hidden":!0}),Oe({reason:m.reason??`?`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:Je(),result:m.inbound}),(0,Z.jsx)($,{label:at(),result:m.outbound}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:tt()})]}):(0,Z.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Z.jsx)(z,{"aria-hidden":!0}),pe()]})}),(0,Z.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[v&&(0,Z.jsxs)(bt,{variant:`outline`,size:`sm`,onClick:()=>void y(),disabled:d,children:[d?(0,Z.jsx)(Ot,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,d?je():Xe()]}),(0,Z.jsx)(bt,{size:`sm`,onClick:()=>void b(),disabled:l,children:pt()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Z.jsxs)(wt,{children:[(0,Z.jsx)(Mt,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?ke():Te({count:e.length}),(0,Z.jsx)(E,{size:13,"aria-hidden":!0})]})}),(0,Z.jsxs)(At,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Z.jsx)(`p`,{className:`oc-compat__versions-title`,children:De()}),(0,Z.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Z.jsx)(O,{variant:`secondary`,children:e},e))})]})]})}export{Tn as BridgeTab,An 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,EK as u,E_ as d,Ef as f,F as p,FK as m,G as h,Gg as g,H as _,HK as v,I as y,IK as b,J as x,K as ee,L as te,LK as S,M as C,M_ as w,Mf as ne,N as re,NK as T,Nf as ie,O as ae,Of as E,P as oe,PK as se,Q as ce,R as le,T_ as ue,Tf as de,U as D,V as fe,W as pe,WE as me,WK as O,X as he,Y as ge,Z as _e,cg as k,dg as ve,fg as A,hg as ye,hl as be,j as xe,jf as j,k as Se,kf as Ce,lg as M,mg as N,pg as we,q as Te,sg as P,t as F,ug as Ee,wf as De,z as Oe}from"./api-CKGeK7QS.js";import{t as I}from"./button-HWWS6bgL.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-BZLPehFE.js";import{a as Me}from"./compatView-Bc7ErYFT.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`,o=i?{}:t,s=S(e),c=(0,G.useMemo)(()=>()=>{let t=ze();return{query:e,args:o,id:t,nextPageKey:1,pageKeys:i?[]:[0],queries:i?{}:{0:{query:e,args:{...o,paginationOpts:{numItems:n.initialNumItems,cursor:null,id:t}}}},ongoingSplits:{},skip:i}},[JSON.stringify(O(o)),s,n.initialNumItems,i]),[l,u]=(0,G.useState)(c),d=l;(S(e)!==S(l.query)||JSON.stringify(O(o))!==JSON.stringify(O(l.args))||i!==l.skip)&&(d=c(),u(d));let f=se().logger,p=a(d.queries),m=n[Ie]??!1,[h,g,_]=(0,G.useMemo)(()=>{let e,t=[];for(let i of d.pageKeys){if(e=p[i],e===void 0)break;if(e instanceof Error){if(e.message.includes(`InvalidCursor`)||e instanceof v&&typeof e.data==`object`&&e.data?.isConvexSystemError===!0&&e.data?.paginationError===`InvalidCursor`)return f.warn(`usePaginatedQuery hit error, resetting pagination state: `+e.message),u(c),[[],void 0,void 0];if(r)throw e;return[t,void 0,e]}let a=d.ongoingSplits[i];if(a===void 0?e.splitCursor&&(e.pageStatus===`SplitRecommended`||e.pageStatus===`SplitRequired`||e.page.length>n.initialNumItems*2)&&u(Ne(i,e.splitCursor,e.continueCursor)):p[a[0]]!==void 0&&p[a[1]]!==void 0&&u(Pe(i)),e.pageStatus===`SplitRequired`)return[t,void 0,void 0];t.push(...m?e.page.map(e=>({...e,[Le]:i.toString()})):e.page)}return[t,e,void 0]},[p,d.pageKeys,d.ongoingSplits,n.initialNumItems,c,f,m,r]);return{user:{results:h,...(0,G.useMemo)(()=>{if(_!==void 0)return{status:`Error`,isLoading:!1,error:_,loadMore:()=>{}};if(g===void 0)return d.nextPageKey===1?{status:`LoadingFirstPage`,isLoading:!0,loadMore:()=>{}}:{status:`LoadingMore`,isLoading:!0,loadMore:e=>{}};if(g.isDone)return{status:`Exhausted`,isLoading:!1,loadMore:e=>{}};let e=g.continueCursor,t=!1;return{status:`CanLoadMore`,isLoading:!1,loadMore:n=>{t||(t=!0,u(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,d.nextPageKey])},internal:{state:d}}}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 he();case`hybrid`:return ge();case`tool`:return x();default:return Te()}}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`?_():We(e)?C():null:D(),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:h()}}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`?_():e.code===`stale_default`?fe():e.code===`write_unknown`||e.code===`not_confirmed`?le():e.code===`not_applied`?te():e.code===`default_too_large`?i():e.code===`allowlist_too_large`?xe():e.code===`plugin_too_old`?C():e.code===`source_not_allowed`?re():e.code===`plugin_config_lag`?oe():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?pe():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=T(F.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 v(){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":_e(),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:ee()}),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:[Se(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>m(t),children:ae()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:Oe()}),_?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(I,{size:`sm`,disabled:!g.dirty||!g.valid||c===`saving`,onClick:()=>void v(),children:c===`saving`?w():M()})}):(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:k()}):null,u===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:u})]})]})}function Je({instanceName:e}){let t=b(F.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:i,loadMore:a}=Fe(F.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:ce()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:D()}),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:y({shown:n.length})}),(0,$.jsx)(I,{variant:`outline`,size:`sm`,disabled:i===`LoadingMore`,onClick:()=>a(50),"data-knowledge-load-more":!0,children:p()})]}):null]})}function Ye({instance:e}){let t=m(F.admin.upsertInstanceConfig),n=b(F.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,a]=(0,G.useState)(r),[o,c]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{a(r),c(`idle`)},[e._id,r]);let l=`__none__`,u=i!==r;async function d(){c(`saving`);try{let n={...e.config??{}};i===``||i===l?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let f=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:Ce()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(z,{value:i===``?l:i,onValueChange:e=>a(e===l?``:e),children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":s(),children:(0,$.jsx)(B,{placeholder:E()})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(H,{value:l,children:E()}),f.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:!u||o===`saving`,onClick:()=>void d(),children:o===`saving`?w():M()})]}),o===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:k()}):null,o===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:P()}):null]})}function Xe({instance:e}){let t=m(F.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,a]=(0,G.useState)(n),[o,s]=(0,G.useState)(r===null?``:String(r)),[c,u]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{a(n),s(r===null?``:String(r)),u(`idle`)},[e._id,n,r]);let d=o.trim(),p=d===``?null:/^\d+$/.test(d)?Number.parseInt(d,10):NaN,h=!i||p===null||Number.isInteger(p)&&p>=4e3&&p<=6e4,g=i!==n||(p??null)!==r;async function _(){u(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||p===null||Number.isNaN(p)?delete n.curationBudgetChars:n.curationBudgetChars=p,await t({instanceId:e._id,config:n}),u(`done`)}catch{u(`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=>a(e===!0),"aria-label":j()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:j()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(R,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:o,onChange:e=>s(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!h,"aria-label":l(),disabled:!i}),(0,$.jsx)(I,{size:`sm`,disabled:!g||!h||c===`saving`,onClick:()=>void _(),children:c===`saving`?w():M()})]}),h?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:f()}),c===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:k()}):null,c===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:P()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:de()})]})}function Ze({instance:e}){let t=m(F.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,G.useState)(n===null?``:String(n)),[a,o]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{i(n===null?``:String(n)),o(`idle`)},[e._id,n]);let s=r.trim(),c=s===``?null:/^\d+$/.test(s)?Number.parseInt(s,10):NaN,l=c===null||Number.isInteger(c)&&c>=1e3&&c<=2e5,u=(c??null)!==n;async function d(){o(`saving`);try{let n={...e.config??{}};c===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=c,await t({instanceId:e._id,config:n}),o(`done`)}catch{o(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:ie()}),(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":!l}),(0,$.jsx)(I,{size:`sm`,disabled:!u||!l||a===`saving`,onClick:()=>void d(),children:a===`saving`?w():M()})]}),l?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:De()}),a===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:k()}):null,a===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:P()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ne()})]})}function Qe(){let e=T(F.agentFiles.getChatDefaults),[t,n]=(0,G.useState)({status:`loading`}),r=b(F.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=b(F.compat.forInstance,i?{instanceName:i}:`skip`),f=i?Ae(l,`configDefaults`):`loading`,p=f===`loading`?null:f.blocked,m=(0,G.useMemo)(()=>s&&i?{instanceName:i}:{},[s,i]),h=(0,G.useRef)(0),_=(0,G.useCallback)(async()=>{let t=++h.current;n({status:`loading`});try{let r=Ve(await e(m));if(h.current!==t)return;n({status:`done`,current:r})}catch{if(h.current!==t)return;n({status:`error`})}},[e,m]);(0,G.useEffect)(()=>{p===!1&&(s&&!i||_())},[_,p,s,i]);let v=t.status===`done`?t.current:null,y=(0,G.useMemo)(()=>Be.map(e=>({id:e,label:ke(e)})),[]),x=(0,G.useMemo)(()=>[{id:`fast`,label:d()},{id:`standard`,label:ue()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ye()}),s&&i?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()}),(0,$.jsxs)(z,{value:i,onValueChange:e=>a(e),children:[(0,$.jsx)(U,{size:`sm`,"aria-label":g(),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:me()}):f===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):f.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(je,{size:14,"aria-hidden":!0}),` `,Me(f.gatewayVersion,f.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:u()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[Ee(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void _(),children:o()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:N()}),(0,$.jsx)(L,{field:`thinkingLevel`,options:y,value:v?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:N()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:we()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:A()}),(0,$.jsx)(L,{field:`fastMode`,options:x,value:v===null||v.fastModeDefault===null?null:v.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:A()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ve()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:be()})]}),(()=>{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,AN as i,BN as a,CN as o,DN as s,EN as c,FK as l,FN as u,GN as d,HN as f,IK as p,IN as m,JN as h,KN as g,LN as _,Ld as v,MN as y,NN as b,ON as x,PN as ee,QN as te,RN as ne,SN as re,TN as ie,UN as ae,VN as S,WN as C,XN as w,YN as T,ZN as E,_N as D,aP as O,bN as k,cP as A,dN as j,dP as M,eP as N,fN as P,fP as F,gN as I,hN as L,iP as R,jN as z,kN as B,lP as V,mN as H,nP as U,oP as W,pN as G,pP as oe,qN as K,rP as q,sP as se,t as J,tP as ce,uP as le,vN as ue,wN as de,xN as fe,yN as pe,zN as me,zd as he}from"./api-CKGeK7QS.js";import{t as ge}from"./button-HWWS6bgL.js";import{ft as _e,q as Y}from"./index-BZLPehFE.js";import{t as ve}from"./DataTableShell-CgfEZzcq.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>oe(),incorrect:()=>F(),incoherence:()=>M(),formatting:()=>le(),latency:()=>V(),api_error:()=>A(),other:()=>se()},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:O()}):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:W()})}function be({data:e,reference:t,closeReason:n}){let i=e.snapshot,o=l(J.feedback.respondToFeedback),[s,c]=(0,X.useState)(e.thread),[u,p]=(0,X.useState)(``),[m,v]=(0,X.useState)(!1);async function y(){let t=u.trim();if(!(!t||m)){v(!0);try{await o({feedbackId:e._id,text:t}),c(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),p(``)}finally{v(!1)}}}let b=[];try{b=i.contextJson?JSON.parse(i.contextJson):[]}catch{b=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:i.displayedMatchesStored,sourceWasOpen:i.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,i.messageRole,i.isRegeneration?` · ${q()}`:``,i.openclawModel?` · ${i.openclawModel}`:``,i.openclawRuntime?` (${i.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:z(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:U()}),(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:D()}),(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:ce()}),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`?N():e.authorRole===`agent`?e.authorLabel??he():r()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:te()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:E(),value:u,maxLength:2e3,rows:3,onChange:e=>p(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 y(),disabled:!u.trim()||m,children:m?w():T()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:h()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.messageText||K()})]}),i.clientInfo?.sourceWasOpen&&i.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.displayedText||K()})]}):null,i.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:d()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.promptText})]}):null,b.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:C({count:i.contextCount??b.length,truncated:i.contextTruncated?ae():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:b.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,i.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[i.outboxText??``,i.outboxStatus?`\n[status: ${i.outboxStatus}]`:``]})]}):null,i.clientInfo?.extensionsDetected&&i.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:S()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:i.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:a()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[i.clientInfo?.language,i.clientInfo?.timezone,i.clientInfo?.theme?me({theme:i.clientInfo.theme}):null,i.runId?`run ${i.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,i.clientInfo?.plugins&&i.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[ne(),` `,i.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,_()]})]}):null,i.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:i.clientInfo.userAgent}):null]})]})]})}function xe(){let e=p(J.feedback.listForAdmin,{}),t=l(J.feedback.readSnapshot),n=l(J.feedback.deleteFeedback),r=Y(),[a,d]=(0,X.useState)(null),[f,h]=(0,X.useState)({});async function g(e){if(a===e._id){d(null);return}if(!f[e._id]){let n=await t({feedbackId:e._id});h(t=>({...t,[e._id]:n}))}d(e._id)}async function _(e){await r({title:G(),description:P(),confirmLabel:j(),destructive:!0})&&(await n({feedbackId:e._id}),a===e._id&&d(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[m(),` `,(0,Z.jsx)(`strong`,{children:u()}),` `,ee()]}),(0,Z.jsx)(ve,{title:b(),rows:e,emptyHint:y(),isExpanded:e=>a===e._id&&!!f[e._id],renderExpanded:e=>f[e._id]?(0,Z.jsx)(be,{data:f[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:i(),cell:e=>_e(e.at),sort:e=>e.at},{header:B(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:x(),cell:e=>e.messageRole===`user`?s():c(),sort:e=>e.messageRole},{header:ie(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${de({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:o(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:re(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:fe(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:k()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:pe()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:v()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:ue()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:a===e._id?I():L(),onSelect:()=>void g(e)},{label:H(),onSelect:()=>void _(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,BG as ee,CG as i,DG as te,EG as ne,EK as re,FG as a,FK as ie,GG as ae,HG as oe,Hd as se,IG as o,IK as s,KG as c,LG as l,LL as u,MG as d,NG as f,OG as ce,OK as le,PG as p,RG as ue,SG as de,TG as fe,UG as m,Ud as h,VG as pe,WG as g,_G as me,bG as _,fG as he,gG as ge,hG as _e,jG as v,kG as ve,mG as ye,pG as be,qG as y,t as b,vG as x,wG as S,xG as C,yG as w,zG as T}from"./api-CKGeK7QS.js";import{t as E}from"./button-HWWS6bgL.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-BZLPehFE.js";import{a as Me,i as B,n as Ne,o as V,r as H,t as Pe}from"./table-VhRaEfeZ.js";var U=t(e(),1),W=n(),G=`all`;function K(e){switch(e){case`image`:return o();case`audio`:return a();case`video`:return p();case`pdf`:return f();case`document`:return d();case`archive`:return v();default:return r()}}function q(){let[e,t]=(0,U.useState)(G),[n,r]=(0,U.useState)(G),[a,o]=(0,U.useState)(G),[d,f]=(0,U.useState)(G),[p,v]=(0,U.useState)(!1),[q,J]=(0,U.useState)(null),Fe=ie(b.files.softDelete),Y=Oe();function Ie(){t(G),r(G),o(G),f(G)}async function Le(){let e=q;if(J(null),e)try{await Fe({fileId:e.id}),Y.success(w())}catch(e){Y.error(x(),e)}}let X=s(b.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:p||void 0}),Re=(0,U.useMemo)(()=>new Intl.DateTimeFormat(le(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:re()});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:y()}),(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":c(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:ae()}),(0,W.jsx)(L,{value:`inbound`,children:g()}),(0,W.jsx)(L,{value:`outbound`,children:m()})]})]}),(0,W.jsxs)(F,{value:n,onValueChange:r,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":oe(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:pe()}),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":ee(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:T()}),Q.instances.map(e=>(0,W.jsx)(L,{value:e,children:e},e))]})]}):null,(0,W.jsxs)(F,{value:d,onValueChange:f,children:[(0,W.jsx)(R,{size:`sm`,"aria-label":ue(),children:(0,W.jsx)(I,{})}),(0,W.jsxs)(z,{children:[(0,W.jsx)(L,{value:G,children:l()}),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:p,onCheckedChange:e=>v(e===!0),"aria-label":h()}),(0,W.jsx)(`span`,{children:h()})]}),$?(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}),de()]}):null]}),Z.length===0?(0,W.jsx)(`p`,{className:`oc-admin__hint`,children:$?be():ye()}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Pe,{children:[(0,W.jsx)(Me,{children:(0,W.jsxs)(V,{children:[(0,W.jsx)(B,{children:ve()}),(0,W.jsx)(B,{children:ce()}),(0,W.jsx)(B,{children:te()}),(0,W.jsx)(B,{children:ne()}),(0,W.jsx)(B,{children:fe()}),(0,W.jsx)(B,{className:`text-right`,children:S()})]})}),(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:se()}):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`?g():m()})}),(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":C(),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}),i()]})}):(0,W.jsxs)(P,{disabled:!0,children:[(0,W.jsx)(M,{size:14}),_e()]}),(0,W.jsxs)(P,{variant:`destructive`,onSelect:()=>J({id:e._id,filename:e.filename}),children:[(0,W.jsx)(Ee,{size:14}),_()]})]})]})})]},e._id))})]}),ze?(0,W.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:he({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:ge()})]}),(0,W.jsxs)(k,{children:[(0,W.jsx)(je,{children:u()}),(0,W.jsx)(O,{onClick:()=>void Le(),children:_()})]})]})})]})}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,Av as a,Bv as o,Cv as s,D as c,Dv as l,Ev as u,FK as d,Fv as f,G_ as p,Gv as m,Hv as h,IK as g,Iv as _,J_ as v,Jv as y,K_ as b,Kv as x,Lv as ee,Mv as S,Nv as te,Ov as C,Pv as w,Q_ as T,Qv as E,Rv as ne,Sv as D,Tv as O,Uv as k,Vv as re,W_ as A,Wv as j,X_ as M,Xv as N,Y_ as ie,Yv as ae,Z_ as P,Zv as oe,_v as se,av as F,bv as I,cv as L,dv as ce,ev as le,fv as ue,gv as de,hv as R,iv as fe,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-CKGeK7QS.js";import{t as Ae}from"./x-CZJSCjdP.js";import{t as V}from"./button-HWWS6bgL.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-BZLPehFE.js";import{t as Ye}from"./FilterBar-YVVbd65x.js";import{t as Xe}from"./DataTableShell-CgfEZzcq.js";import{t as Z}from"./DetailChips-BWOhDvfm.js";var Ze=c(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),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 I();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=g(z.groups.listGroups,{}),t=g(z.me.getMe,{host:Fe})?.role===`admin`,n=d(z.groups.createGroup),r=d(z.groups.updateGroup),a=d(z.groups.deleteGroup),s=We(),c=q(),[l,u]=(0,Q.useState)(!1),[p,v]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(it),[D,O]=(0,Q.useState)(null),[A,M]=(0,Q.useState)(``),ie=(0,Q.useMemo)(()=>{if(!e)return e;let t=A.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,A]);function P(){v(null),T(it),u(!0)}function se(e){v(e),T({name:e.name,description:e.description??``}),u(!0)}async function F(){try{p?await r({groupId:p._id,name:C.name,description:C.description}):await n({name:C.name,description:C.description||void 0}),T(it),v(null),u(!1)}catch(e){c.error(be(),e)}}async function I(e){if(await s({title:w({name:e.name}),description:te(),confirmWord:e.name,confirmLabel:S(),cancelLabel:o(),destructive:!0}))try{await a({groupId:e._id})}catch(e){c.error(b(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:E()}),(0,$.jsx)(Ye,{q:A,onQChange:M,onReset:()=>M(``),canReset:A!==``,searchPlaceholder:m()}),(0,$.jsx)(Xe,{title:i(),rows:ie,addLabel:oe(),onAdd:t?P:void 0,emptyHint:N(),columns:[{header:ae(),cell:e=>e.name,sort:e=>e.name},{header:y(),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:x(),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:j(),onSelect:()=>O({groupId:e._id,name:e.name})},...t?[{label:k(),onSelect:()=>se(e)},{label:h(),variant:`destructive`,onSelect:()=>void I(e)}]:[]]}),(0,$.jsx)(Ie,{open:l,onOpenChange:u,title:p?ne():ke(),description:ee(),canSubmit:!!C.name.trim(),onSubmit:F,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:_()}),(0,$.jsx)(U,{value:C.name,onChange:e=>T({...C,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:f()}),(0,$.jsx)(U,{value:C.description,onChange:e=>T({...C,description:e.target.value})})]})]})}),(0,$.jsx)(ct,{groupId:D?.groupId??null,groupName:D?.name??``,open:D!==null,onOpenChange:e=>{e||O(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}),s()]}),(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:[D(),(0,$.jsx)(Pe,{size:14,"aria-hidden":!0})]})]})}function ct({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=g(z.groups.getGroup,n&&e?{groupId:e}:`skip`),o=g(z.groups.listAssignableInstances,n?{}:`skip`),s=g(z.groups.listAssignableUsers,n?{}:`skip`),c=d(z.groups.addMember),f=d(z.groups.removeMember),m=d(z.groups.bulkSetMembers),h=d(z.groups.setGroupManager),_=q(),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(``),[ee,S]=(0,Q.useState)(`members`),[te,w]=(0,Q.useState)(1),[E,ne]=(0,Q.useState)(new Set),D=(0,Q.useRef)(null),k=(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]),A=i?.viewerIsAdmin===!0,j=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[i]);(0,Q.useEffect)(()=>{y(``),x(``),S(`members`),w(1),D.current=null},[n,e]),(0,Q.useEffect)(()=>{w(1)},[v]),(0,Q.useEffect)(()=>{n&&i&&e&&D.current!==e&&(D.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let N=(0,Q.useMemo)(()=>s?Qe(s,v,E):[],[s,v,E]);async function ae(t,n){if(e)try{n?await f({groupId:e,userId:t}):await c({groupId:e,userId:t})}catch(e){_.error(p(),e)}}async function oe(t,n){if(e)try{await h({groupId:e,userId:t,manager:!n})}catch(e){_.error(ie(),e)}}let F=nt(N,e=>k.has(e.userId)),I=N.filter(e=>k.has(e.userId)).length,L=rt(N,te,ot);async function ce(){if(!e||N.length===0)return;let t=N.map(e=>e.userId);try{await m({groupId:e,userIds:t,member:F!==`all`})}catch(e){_.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:a()})]}),(0,$.jsxs)(Ne,{value:ee,onValueChange:S,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:k.size}):null]}),(0,$.jsxs)(W,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(J,{size:13,"aria-hidden":!0}),l(),i?(0,$.jsx)(H,{variant:`secondary`,className:`oc-access__tabcount`,children:j.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:s===void 0||i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:R()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ye()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{value:v,onChange:e=>y(e.target.value),placeholder:C(),className:`oc-access__search`}),N.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:O()}):(0,$.jsxs)($.Fragment,{children:[N.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(Y,{checked:F===`all`?!0:F===`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:[I,` / `,N.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:L.pageItems.map(e=>{let t=k.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&&A?(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?M():P(),title:r?M():P(),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":T(),title:T(),children:(0,$.jsx)(X,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(st,{page:L.page,pageCount:L.pageCount,onPage:w})]})]})}),(0,$.jsx)(G,{value:`agents`,children:o===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:R()}):o.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ue()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{value:b,onChange:e=>x(e.target.value),placeholder:u(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:o.map(t=>(0,$.jsx)(lt,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:j,query:b},`${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 a=g(z.groups.listAssignableAgents,{instanceName:t}),o=d(z.groups.assignAgentToGroup),s=d(z.groups.removeAgentFromGroup),c=d(z.groups.bulkSetGroupAgents),l=q(),[u,f]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{f(1)},[i]),!e)return null;let p=$e(a?.agents??[],i),m=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&p.length===0)return null;let h=p.filter(e=>e.presentInLastOk!==!1&&e.enabled!==!1),_=nt(h,e=>r.has(`${t}/${e.agentId}`)),v=rt(p,u,ot);async function y(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){l.error(A(),e)}}async function b(){if(h.length===0)return;let n=h.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:_!==`all`})}catch(e){l.error(A(),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]}),a===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:_===`all`?!0:_===`some`?`indeterminate`:!1,onCheckedChange:()=>void b(),"aria-label":B()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:B()})]}):null,v.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1,o=!e.enabled;return(0,$.jsxs)(`div`,{className:`oc-access__row${o?` is-disabled`:``}`,children:[(0,$.jsx)(Y,{checked:i,disabled:(a||o)&&!i,onCheckedChange:()=>void y(e.agentId,i),"aria-label":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:L()}):null]},e.agentId)}),(0,$.jsx)(st,{page:v.page,pageCount:v.pageCount,onPage:f})]})]})}function ut({groupId:e}){let t=g(z.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=d(z.charts.assignChartToGroup),i=d(z.charts.removeChartFromGroup),a=d(z.charts.setGroupDefaultChart),o=d(z.charts.addChartToGroupPool),s=d(z.charts.removeChartFromGroupPool),c=q();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:R()});let{pool:l,addable:u,canManagePool:f}=t;if(l.length===0&&!f)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:F()});async function p(t,r){try{r?await i({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){c.error(v(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){c.error(v(),e)}}async function h(t){try{await o({groupId:e,chartKey:t})}catch(e){c.error(v(),e)}}async function _(t){try{await s({groupId:e,chartKey:t})}catch(e){c.error(v(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:l.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 _(e.chartKey),children:(0,$.jsx)(Ae,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?u.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:u.map(e=>(0,$.jsx)(He,{value:e.chartKey,children:e.name},e.chartKey))})]}):l.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,AM as a,Aj as o,Bj as s,Bt as c,CM as l,Ca as u,Cj as d,DM as f,Da as p,Dj as m,EM as h,Ea as g,Ej as _,FE as v,FK as y,FM as b,Fj as x,Ft as S,Gj as C,Hj as w,Ht as T,IK as E,IM as ee,Ij as D,It as te,JA as O,Jf as k,Jj as A,Kj as j,LM as ne,Lj as re,Lt as ie,MM as ae,Mj as oe,Mz as M,NK as N,NM as se,Nj as ce,OM as le,Oa as ue,Oj as de,PE as fe,PM as pe,Pj as me,QA as he,Qj as ge,Rj as _e,Rt as ve,SM as ye,Sa as be,Sj as xe,TM as Se,Ta as Ce,Tj as we,Uj as Te,Ut as Ee,Vj as De,Vt as Oe,Wj as ke,Wt as Ae,XA as je,Xf as Me,Xj as Ne,YA as Pe,Yf as Fe,Yj as Ie,ZA as Le,Zf as Re,Zj as ze,_M as Be,_a 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,fj as tt,gM as nt,ga as rt,gj as it,hM as at,ha as ot,hj as st,iM as ct,ij as lt,jM as ut,jj as dt,jz as P,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 Et,qj as F,rM as Dt,rj as Ot,sM as kt,sj as At,t as I,tM as jt,tj as Mt,uM as Nt,uj as Pt,vM as Ft,va as It,vj as L,vl as Lt,wM as Rt,wa as zt,wj as Bt,xM as Vt,xa as Ht,xj as Ut,yM as Wt,ya as Gt,yj as Kt,yl as qt,zj as Jt,zt as Yt}from"./api-CKGeK7QS.js";import{a as Xt,c as Zt}from"./FieldLabel-ObN4xPwN.js";import{t as R}from"./button-HWWS6bgL.js";import{At as z,Ft as B,Ht as Qt,Ut as $t,Wt as en,_ as tn,at as V,et as H,it as U,jt as W,lt as G,mt as nn,nt as K,ot as rn,q as an,rt as q,st as on,tt as J,ut as sn}from"./index-BZLPehFE.js";import{t as cn}from"./DataTableShell-CgfEZzcq.js";import{InstanceConfigDialog as ln}from"./BridgeTab-CULepdP_.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:Xt},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=E(I.admin.listInstances,{}),t=E(I.agents.listAllInstanceAgents,{}),n=y(I.admin.upsertInstance),r=y(I.admin.deleteInstance),i=W(),[o,s]=(0,Y.useState)(!1),[d,m]=(0,Y.useState)(Q),[_,x]=(0,Y.useState)(null),[C,w]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(null),[k,A]=(0,Y.useState)(null);async function j(){try{await n({instanceId:k??void 0,name:d.name,gatewayUrl:d.gatewayUrl,bridgeUrl:d.bridgeUrl||void 0,displayName:d.displayName||void 0,kind:d.kind,transport:d.kind===`hermes`?d.transport:void 0,gatewayVersion:d.gatewayVersion||void 0,gatewayHttpUrl:d.gatewayHttpUrl||void 0,...d.kind===`openclaw`?{authMode:d.authMode,personScopes:d.personScopes,identitySource:d.identitySource,participantIdentity:d.participantIdentity,managePermissionModes:d.managePermissionModes,systemIdentity:d.systemIdentity||void 0}:{},streamTransport:d.streamTransport}),m(Q),A(null),s(!1)}catch(e){i.error(b(),e)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[pe(),(0,Z.jsx)(`strong`,{children:se()}),ae()]}),(0,Z.jsx)(cn,{title:ut(),rows:e,addLabel:a(),onAdd:()=>{A(null),m(Q),s(!0)},emptyHint:ft(),columns:[{header:le(),cell:e=>e.name,sort:e=>e.name},{header:f(),cell:e=>(0,Z.jsx)(z,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:h(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Se(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:ne(),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)(z,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?Pe():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:Vt(),onSelect:()=>{A(e._id),m(mn(e)),s(!0)}},{label:ee(),onSelect:()=>x(e.name)},{label:St(),onSelect:()=>O(e)},{label:Rt(),onSelect:()=>w(e)},{label:l(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:l(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,Z.jsx)(tn,{open:o,onOpenChange:s,title:k?We():ye(),description:Ft(),canSubmit:!!(d.name&&d.gatewayUrl),onSubmit:j,submitLabel:Be(),children:(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsxs)($,{label:nt(),children:[(0,Z.jsx)(B,{value:d.name,disabled:k!==null,onChange:e=>m({...d,name:e.target.value})}),k?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Wt()}):null]}),(0,Z.jsx)($,{label:at(),children:(0,Z.jsxs)(H,{value:d.kind,onValueChange:e=>m({...d,kind:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`openclaw`,children:`OpenClaw`}),(0,Z.jsx)(K,{value:`hermes`,children:`Hermes`})]})]})}),d.kind===`hermes`?(0,Z.jsx)($,{label:qe(),children:(0,Z.jsxs)(H,{value:d.transport,onValueChange:e=>m({...d,transport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`ws`,children:qt()}),(0,Z.jsx)(K,{value:`rest`,children:Lt()})]})]})}):null,(0,Z.jsx)($,{label:_t(),children:(0,Z.jsx)(B,{value:d.gatewayUrl,onChange:e=>m({...d,gatewayUrl:e.target.value})})}),(0,Z.jsx)($,{label:wt(),children:(0,Z.jsx)(B,{value:d.bridgeUrl,placeholder:et(),onChange:e=>m({...d,bridgeUrl:e.target.value})})}),(0,Z.jsx)($,{label:Xe(),children:(0,Z.jsx)(B,{value:d.displayName,onChange:e=>m({...d,displayName:e.target.value})})}),(0,Z.jsxs)($,{label:v(),children:[(0,Z.jsxs)(H,{value:d.streamTransport,onValueChange:e=>m({...d,streamTransport:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsx)(J,{children:Zt.map(e=>(0,Z.jsx)(K,{value:e,children:e},e))})]}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:fe()})]}),(0,Z.jsx)($,{label:Nt(),children:(0,Z.jsx)(B,{value:d.gatewayVersion,placeholder:ht(),onChange:e=>m({...d,gatewayVersion:e.target.value})})}),d.kind===`openclaw`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($,{label:Gt(),children:[(0,Z.jsxs)(H,{value:d.authMode,onValueChange:e=>m({...d,authMode:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`token`,children:It()}),(0,Z.jsx)(K,{value:`trusted-proxy`,children:Ve()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:d.authMode===`trusted-proxy`?ot():rt()})]}),d.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:pt(),children:[(0,Z.jsxs)(H,{value:d.personScopes,onValueChange:e=>m({...d,personScopes:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`capped`,children:ue()}),(0,Z.jsx)(K,{value:`full`,children:p()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:d.personScopes===`full`?Ce():g()})]}):null,d.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:zt(),children:[(0,Z.jsxs)(H,{value:d.identitySource,onValueChange:e=>m({...d,identitySource:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`canonical`,children:u()}),(0,Z.jsx)(K,{value:`email`,children:be()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:d.identitySource===`email`?Ge():Ht()})]}):null,d.authMode===`trusted-proxy`?(0,Z.jsxs)($,{label:Ae(),children:[(0,Z.jsxs)(H,{value:d.participantIdentity,onValueChange:e=>m({...d,participantIdentity:e}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`owner`,children:Ee()}),(0,Z.jsx)(K,{value:`self`,children:T()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:d.participantIdentity===`self`?S():Oe()})]}):null,d.kind===`openclaw`?(0,Z.jsxs)($,{label:c(),children:[(0,Z.jsxs)(H,{value:d.managePermissionModes?`on`:`off`,onValueChange:e=>m({...d,managePermissionModes:e===`on`}),children:[(0,Z.jsx)(q,{size:`sm`,className:`w-full`,children:(0,Z.jsx)(U,{})}),(0,Z.jsxs)(J,{children:[(0,Z.jsx)(K,{value:`off`,children:Yt()}),(0,Z.jsx)(K,{value:`on`,children:ve()})]})]}),(0,Z.jsx)(`p`,{className:`oc-field__hint`,children:d.managePermissionModes?te():ie()})]}):null,d.authMode===`trusted-proxy`?(0,Z.jsx)($,{label:vt(),children:(0,Z.jsx)(B,{value:d.systemIdentity,placeholder:Tt(),onChange:e=>m({...d,systemIdentity:e.target.value})})}):null]}):null,(0,Z.jsx)($,{label:Je(),children:(0,Z.jsx)(B,{value:d.gatewayHttpUrl,placeholder:kt(),onChange:e=>m({...d,gatewayHttpUrl:e.target.value})})})]})}),(0,Z.jsx)(Tn,{instanceName:_,open:_!==null,onOpenChange:e=>{e||x(null)}}),C?(0,Z.jsx)(ln,{instance:C,onClose:()=>w(null)},C._id):null,D?(0,Z.jsx)(gn,{instance:D,onClose:()=>O(null)},D._id):null]})}function gn({instance:e,onClose:t}){let n=E(I.instanceSecrets.listInstanceSecretStatus,{}),r=pn[e.kind??`openclaw`],i=(0,Y.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,Z.jsx)(V,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Z.jsxs)(rn,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(sn,{children:He({instance:e.displayName??e.name})}),(0,Z.jsx)(on,{children:ct()})]}),(0,Z.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,Z.jsx)(yn,{instanceId:e._id,field:t,updatedAt:i[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=N(I.instanceSync.forceInstanceSync),n=W(),[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(_e());break;case`no_agents`:n.success(D());break;case`no_bridge_url`:n.error(x());break;case`deploy_misconfigured`:n.error(me());break;case`unauthorized`:n.error(oe());break;case`not_served`:n.error(dt());break;default:n.error(ce());break}}catch(e){n.error(re(),e)}finally{i(!1)}}}return(0,Z.jsxs)(`div`,{className:`oc-form`,children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:o()}),(0,Z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?Jt():s()})})]})}function vn({instance:e}){let t=E(I.bridgeAuth.listBridgeAuthStatus,{}),n=N(I.bridgeAuth.mintBridgeSecret),r=y(I.bridgeAuth.revokeBridgeSecret),a=W(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,f]=(0,Y.useState)(!1),p=(t??[]).find(t=>t.instanceId===e._id),h=p!==void 0;async function g(){if(!o){s(!0);try{l((await n({instanceId:e._id})).plaintext),f(!1)}catch(e){a.error(d(),e)}finally{s(!1)}}}async function v(){if(!o){s(!0);try{await r({instanceId:e._id}),l(null),a.success(Bt())}catch(e){a.error(d(),e)}finally{s(!1)}}}async function b(){if(c)try{await navigator.clipboard.writeText(c),f(!0)}catch{}}return(0,Z.jsxs)($,{label:mt(),children:[(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:de()}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:h?`outline`:`secondary`,children:h?`${Qe()} · ${p.prefix}…${p.lastFour}`:i()}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void g(),disabled:o,children:h?_():m()}),h?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void v(),disabled:o,children:we()}):null]})]}),c?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`oc-sa__minted-warning`,children:xe()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:c}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:u?M():P()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{l(null),f(!1)},children:Ut()})]}):null]})}function yn({instanceId:e,field:t,updatedAt:n}){let r=N(I.instanceSecrets.setInstanceSecret),a=y(I.instanceSecrets.clearInstanceSecret),o=N(I.deviceIdentity.generateDeviceIdentity),s=W(),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),g=n!==null,_=t===`deviceIdentity`,v=t===`token`?Dt():t===`deviceIdentity`?bt():jt();async function b(){if(!(!c.trim()||u)){d(!0);try{await r({instanceId:e,field:t,plaintext:c}),l(``),p(null),h(!1),s.success(A())}catch(e){s.error(F(),e)}finally{d(!1)}}}async function x(){if(!u){d(!0);try{await a({instanceId:e,field:t}),p(null),h(!1),s.success(j())}catch(e){s.error(F(),e)}finally{d(!1)}}}async function S(){if(!u){d(!0);try{p(await o({instanceId:e})),h(!1),s.success(Te())}catch(e){s.error(De(),e)}finally{d(!1)}}}let T=f?`openclaw devices approve ${f.id}`:``;async function E(){if(T)try{await navigator.clipboard.writeText(T),h(!0)}catch{}}return(0,Z.jsxs)($,{label:v,children:[_?(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:ke()}):null,(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(z,{variant:g?`outline`:`secondary`,children:g?Qe():i()}),(0,Z.jsx)(B,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:c,placeholder:g?ze():ge(),onChange:e=>l(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{size:`sm`,onClick:()=>void b(),disabled:u||c.trim().length===0,children:Ne()}),_?(0,Z.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>void S(),disabled:u,children:C()}):null,g?(0,Z.jsx)(R,{size:`sm`,variant:`destructive`,onClick:()=>void x(),disabled:u,children:Ie()}):null]})]}),f?(0,Z.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:Te()}),(0,Z.jsx)(`p`,{className:`oc-admin__hint`,children:w()}),(0,Z.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,Z.jsx)(`code`,{className:`oc-sa__minted-plain`,children:T}),(0,Z.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>void E(),children:m?M():P()})]}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>{p(null),h(!1)},children:Ut()})]}):null]})}var bn={conversational:Pt,documentary:Ye,summarizer:Re,curator:Fe},xn={conversational:gt,documentary:At,summarizer:Me,curator:k},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:yt()}),t.map(e=>(0,Z.jsx)(z,{variant:`secondary`,className:`oc-agenttype__chip`,title:Cn(e),children:Sn(e)},e)),(0,Z.jsxs)(Qt,{children:[(0,Z.jsx)(en,{asChild:!0,children:(0,Z.jsx)(R,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:Et()})}),(0,Z.jsxs)($t,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:tt()}),(0,Z.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:Ze()}),(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)(nn,{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=E(I.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),a=y(I.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),o=y(I.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),s=y(I.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=fn(r);e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),c=y(I.agents.setAgentDescription).withOptimisticUpdate((e,{instanceName:t,agentId:n,description:r})=>{let i=e.getQuery(I.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=r.trim();e.setQuery(I.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,description:a.length===0?null:a}:e)})}),l=y(I.agents.removeInstanceAgent),u=an(),d=W();async function f(t,n){if(e)try{await a({instanceName:e,agentId:t,enabled:n})}catch(e){d.error(L(),e)}}async function p(t){if(e)try{await o({instanceName:e,agentId:t})}catch(e){d.error(L(),e)}}async function m(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await s({instanceName:e,agentId:t,types:i})}catch(e){d.error(L(),e)}}async function h(t,n){if(e&&await u({title:lt({name:n}),description:Ot(),confirmLabel:xt(),destructive:!0}))try{await l({instanceName:e,agentId:t}),d.success(Mt())}catch(e){d.error(L(),e)}}return(0,Z.jsx)(V,{open:t,onOpenChange:n,children:(0,Z.jsxs)(rn,{className:`oc-access`,children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(sn,{children:Ke({name:e??``})}),(0,Z.jsx)(on,{children:Kt()})]}),i===void 0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:$e()}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`oc-access__poll`,children:i.discovery===null?r():i.discovery.lastPollOk?he():Le({error:i.discovery.error??`?`})}),i.agents.length===0?(0,Z.jsx)(`p`,{className:`oc-access__hint`,children:je()}):(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)(nn,{checked:t.enabled,disabled:n,"aria-label":a,onCheckedChange:e=>void f(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)(z,{variant:`outline`,className:`oc-access__gone`,children:O()}),(0,Z.jsx)(R,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void h(t.agentId,a),children:Ue()})]}):r?(0,Z.jsx)(z,{variant:`default`,children:Pe()}):(0,Z.jsx)(R,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!t.enabled,onClick:()=>void p(t.agentId),children:Ct()})]}),t.enabled?(0,Z.jsx)(wn,{agentId:t.agentId,types:o,onToggle:e=>void m(t.agentId,e,o)}):null,t.enabled?(0,Z.jsx)(En,{value:t.description??``,onSave:async n=>{if(e)try{await c({instanceName:e,agentId:t.agentId,description:n})}catch(e){d.error(L(),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)(B,{className:`oc-agentcard__desc`,value:n,maxLength:280,placeholder:it(),"aria-label":st(),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{CP as r,DP as i,EP as a,FK as o,IK as s,NK as c,OP as l,SP as u,TP as d,_P as f,_m as p,bP as m,dm as h,fm as g,gP as _,gm as v,hP as y,hm as b,mm as x,pm as S,t as C,um as w,vP as T,vm as E,wP as D,xP as O,yP as k}from"./api-CKGeK7QS.js";import{t as A}from"./button-HWWS6bgL.js";import{At as j,Ft as M,mt as N}from"./index-BZLPehFE.js";var P=t(e(),1),F=n();function I(){let e=s(C.integrations.status.status,{}),t=o(C.admin.setIntegrationConfig),[n,c]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&c(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:l()});let h=n,g=(e,t,n)=>c({...h,[e]:{...h[e],[t]:n}}),b=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[i(),` `,(0,F.jsx)(`strong`,{children:a()}),` `,d()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:D()}):(0,F.jsx)(j,{variant:`outline`,children:r()}):(0,F.jsx)(j,{variant:`outline`,children:u()}),note:O(),children:[(0,F.jsx)(R,{label:k(),children:(0,F.jsx)(M,{value:h.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>g(`langfuse`,`host`,e.target.value),onBlur:()=>b(`langfuse`,{host:h.langfuse.host??``})})}),(0,F.jsx)(z,{label:y(),checked:h.langfuse.enabled??!0,onChange:e=>{g(`langfuse`,`enabled`,e),b(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:D()}):(0,F.jsx)(j,{variant:`outline`,children:r()}):(0,F.jsx)(j,{variant:`outline`,children:u()}),note:m(),children:[(0,F.jsx)(R,{label:T(),children:(0,F.jsx)(M,{value:h.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>g(`opik`,`baseUrl`,e.target.value),onBlur:()=>b(`opik`,{baseUrl:h.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:f(),children:(0,F.jsx)(M,{value:h.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||_(),onChange:e=>g(`opik`,`workspace`,e.target.value),onBlur:()=>b(`opik`,{workspace:h.opik.workspace??``})})}),(0,F.jsx)(z,{label:y(),checked:h.opik.enabled??!0,onChange:e=>{g(`opik`,`enabled`,e),b(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:D()}):(0,F.jsx)(j,{variant:`outline`,children:r()}):(0,F.jsx)(j,{variant:`outline`,children:E()}),note:p(),children:[(0,F.jsx)(R,{label:v(),children:(0,F.jsx)(M,{value:h.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>g(`otlp`,`endpoint`,e.target.value),onBlur:()=>b(`otlp`,{endpoint:h.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:y(),checked:h.otlp.enabled??!0,onChange:e=>{g(`otlp`,`enabled`,e),b(`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=c(C.integrations.otlpSecret.setOtlpHeaders),n=o(C.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[a,s]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),d=async()=>{u(!0),s(null);try{await t({headersJson:r}),i(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,F.jsxs)(R,{label:b(),children:[(0,F.jsx)(M,{value:r,placeholder:e?x():S(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:l||r.trim().length===0,onClick:()=>void d(),children:g()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:l,onClick:()=>void n({}),children:h()}):null]}),a?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:a}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:w()})]})}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,Gw as i,Hw as a,IK as o,Jw as s,Kw as c,LF as l,Qw as u,Rw as d,Uw as f,Vw as p,Ww as ee,Xw as m,Yw as h,Zw as g,dF as _,fF as v,lF as te,nF as y,qw as b,t as x,tF as S,uF as C,zw as w}from"./api-CKGeK7QS.js";import{Gn as T,Kn as E,Z as D,i as O,o as ne,r as re}from"./index-BZLPehFE.js";import{a as k,n as A,o as j,r as M,t as N}from"./card-MbRTJSAv.js";import{n as P,t as F}from"./TimeRangePicker-Bo3B16zc.js";var I=t(e(),1),L={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`},R=Object.keys(L).length,z=n(),B=15,V=e=>String(Math.round(e));function H(){let e=o(x.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=o(x.deliveryTiming.listDeliverySessions,e?{}:`skip`),n=(0,I.useMemo)(()=>t?t.filter(e=>!e.active&&e.rollup!==null&&e.rollup.cP50!==null&&e.rollup.aP50!==null).slice(0,B).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:l()}),(0,z.jsxs)(N,{children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{children:v()}),(0,z.jsx)(M,{children:C()})]}),(0,z.jsx)(A,{children:n.length<2?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:te()}):(0,z.jsx)(U,{series:n})})]})]})}function U({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,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{style:{color:`var(--primary)`},children:[S(),` p50 `,V(s.cP50),` `,_()]}),(0,z.jsxs)(`span`,{children:[y(),` p50 `,V(s.aP50),` `,_()]})]}),(0,z.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":v(),children:[(0,z.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,z.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var W=[{metric:`api.calls`,label:u(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:g(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:m(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:h(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:s(),unit:`/h`,group:`Chat`,isError:!1},{metric:L.ASSISTANT_STREAM_ERRORS,label:b(),unit:`/h`,group:`Assistant`,isError:!0},{metric:L.ASSISTANT_ANNOUNCE_ERRORS,label:c(),unit:`/h`,group:`Assistant`,isError:!0}],G=R,K=[`API`,`OpenClaw`,`Chat`,`Assistant`],q=1e3,J=36e5;function Y(e,t){let n=Math.max(1,Math.ceil((t-e)/J)),r=Math.min(n*G,q);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/G))}}function ie(){let e=E({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=O(e.from,e.to,re,`now`),r=e=>void t({search:t=>({...t,...ne(e)})}),{from:s,to:c}=P(n),{rowLimit:l,buckets:u}=Y(s,c),d=o(x.kpi.listKpis,{limit:l,filter:{from:s,to:c}}),p=(0,I.useMemo)(()=>{let e=new Map;for(let t of d??[]){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>u&&e.set(t,n.slice(n.length-u));return e},[d,u]),m=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`p`,{className:`oc-admin__hint`,children:[i(),` `,(0,z.jsx)(`span`,{className:`oc-filter__window`,children:ee()})]}),(0,z.jsx)(ae,{value:n,onChange:r})]});return d===void 0?(0,z.jsxs)(z.Fragment,{children:[m,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:f()})]}):d.length===0?(0,z.jsxs)(z.Fragment,{children:[m,(0,z.jsx)(H,{}),(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]}):(0,z.jsxs)(z.Fragment,{children:[m,(0,z.jsx)(H,{}),K.map(e=>{let t=W.filter(t=>t.group===e);return t.some(e=>(p.get(e.metric)??[]).length>0)?(0,z.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,z.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,z.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,z.jsx)(oe,{config:e,series:p.get(e.metric)??[]},e.metric))})]},e):null})]})}function ae({value:e,onChange:t}){return(0,z.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,z.jsx)(F,{value:e,onChange:t})})}function oe({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,i=n?n.value:0;return(0,z.jsxs)(N,{size:`sm`,className:`oc-kpi__card`,children:[(0,z.jsxs)(k,{children:[(0,z.jsx)(j,{className:`oc-kpi__card-title`,children:e.label}),(0,z.jsx)(M,{className:`oc-kpi__card-metric`,children:(0,z.jsx)(`code`,{children:e.metric})})]}),(0,z.jsxs)(A,{className:`oc-kpi__card-body`,children:[(0,z.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,z.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&i>0?` oc-kpi__value--error`:``),children:Q(i)}),(0,z.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,z.jsx)(ce,{series:t,isError:e.isError,unit:e.unit}),(0,z.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,z.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:p({value:$(n.bucket)})}):(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:r()}),(0,z.jsx)(`span`,{className:`oc-kpi__muted`,children:w({count:t.length})})]})]})]})}var X=240,Z=48,se=1;function ce({series:e,isError:t,unit:n}){if(e.length===0)return(0,z.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,z.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,z.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,z.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{ie 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,CV as a,DV as o,EK as s,EV as c,FK as l,GB as u,IK as d,JB as f,KB as p,Ns as m,OV as h,Os as ee,Ps as te,QB as ne,QG as re,SV as ie,TV as ae,WB as oe,XB as se,XG as ce,YB as le,YG as ue,ZB as g,ZG as de,_K as fe,_M as pe,_V as me,_s as he,aK as ge,aV as _,bV as v,bs as y,cK as b,cV as x,dK as S,dV as C,eK as w,eV as T,fK as E,fV as D,gK as O,gV as k,gs as A,hK as j,hV as M,hs as N,iK as P,iV as F,kV as I,lK as L,lV as _e,mK as ve,mV as ye,ms as be,nK as xe,nV as Se,oK as Ce,oV as we,pK as Te,pV as Ee,ps as De,qB as Oe,r as R,rK as ke,rV as z,sK as Ae,sV as je,t as B,tK as Me,tV as Ne,uK as Pe,uV as Fe,vK as Ie,vV as Le,vs as Re,wV as ze,xK as Be,xV as Ve,yV as He,ys as Ue}from"./api-CKGeK7QS.js";import{t as V}from"./button-HWWS6bgL.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-BZLPehFE.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-DvhM5ae3.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:R(`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:R(`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:()=>I()},{id:`composer`,label:()=>h()},{id:`sidebar`,label:()=>o()},{id:`notifications`,label:()=>Fe()},{id:`other`,label:()=>c()}],X={showSource:{category:`messages`,label:()=>ae(),help:()=>ze()},showReport:{category:`messages`,label:()=>a(),help:()=>ie()},copyAssistant:{category:`messages`,label:()=>Ve()},copyUser:{category:`messages`,label:()=>v()},showDelete:{category:`messages`,label:()=>He()},showTools:{category:`messages`,label:()=>Le(),help:()=>me()},voiceInput:{category:`composer`,label:()=>k(),help:()=>M()},showUsage:{category:`composer`,label:()=>ye(),help:()=>Ee()},autoReadAloud:{category:`composer`,label:()=>te(),help:()=>m()},showChatAge:{category:`sidebar`,label:()=>D(),help:()=>C()},notifSound:{category:`notifications`,label:()=>_e(),help:()=>x()},notifSystem:{category:`notifications`,label:()=>je(),help:()=>we()},replySound:{category:`notifications`,label:()=>_(),help:()=>F()}};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:()=>f()};function ut({prefKey:e,ui:t}){let n=l(B.admin.setUiPrefDefault),r=l(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ne()}),(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:p()}),(0,J.jsx)(K,{value:`off`,children:u()}),(0,J.jsx)(K,{value:`inherit`,children:oe()})]})]}),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":g()}),g()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=l(B.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ge(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[y(),e?(0,J.jsx)(H,{variant:`secondary`,children:Ke(e,We())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?he():r?Re():Ue()})]}),(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:De()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?be():e?N():A()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,i]=(0,q.useState)(!1),a=d(B.me.getMe,{host:W}),o=a?.ui,c=$(a?.role)&&n,u=l(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:[$(a?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(G,{checked:n,onCheckedChange:e=>i(e===!0),"aria-label":r()}),r()]}):null,c?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:se()}),(0,J.jsx)(`p`,{children:le()}),(0,J.jsx)(`p`,{children:Oe()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:z(),"aria-label":z(),className:`mb-2`}),f.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:Se()}):(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],s=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:Ne()}):s?(0,J.jsx)(H,{variant:`secondary`,children:ee()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&s?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void u({key:e,value:null}),children:T()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),u({key:e,value:t})},"aria-label":n})]}),c?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:a?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:s()})}var pt={sm:()=>Ce(),md:()=>ge(),lg:()=>P(),xl:()=>ke(),"2xl":()=>xe(),"3xl":()=>Me()};function mt(){let e=d(B.me.getMe,{host:W}),t=l(B.me.setLocale),n=l(B.me.setTimezone),r=l(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`})}),a=l(B.me.setMyName),o=Xe(),s=e?.locale??`default`,c=e?.name??``,[u,f]=(0,q.useState)(null),p=u??c,m=p.trim()!==c.trim();async function h(){try{await a({name:p}),f(null),o.success(ve())}catch(e){o.error(Te(),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:Ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:fe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:p,maxLength:120,placeholder:O(),onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,J.jsx)(V,{size:`sm`,disabled:!m,onClick:()=>void h(),children:pe()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(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:E()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:S()})]}),(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:Be()})]}),(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:w()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:i()})]}),(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:re()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:de()})]}),(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:b()})]}),(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:Ae()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ce()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ue()})]}),(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,BC as a,Ba as o,CC as s,D as c,DC as l,EK as u,FC as d,FK as f,GC as p,HC as m,IC as h,IK as g,JC as _,KC as v,LC as y,MC as ee,NC as b,OC as te,PC as ne,QC as x,RC as re,SC as ie,UC as ae,VC as oe,Va as se,WC as ce,XC as le,ZC as ue,_C as S,aw as de,bw as fe,cw as pe,cx as me,dC as C,dw as he,ew as w,fw as ge,gC as T,hC as _e,hw as E,iw as ve,kC as ye,mC as be,mw as D,nw as O,ow as xe,pC as Se,qC as k,rw as Ce,t as A,vC as j,xC as M,xw as we,yC as N,yw as Te,zC as Ee}from"./api-CKGeK7QS.js";import{r as De}from"./dist-QaMCaCpK.js";import{t as Oe}from"./list-CTSN7gc5.js";import{t as P}from"./button-HWWS6bgL.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 et,h as W,j as G,jn as tt,jt as nt,k as rt,m as it,p as at,q as ot,qn as st,v as K,w as ct,x as q,xn as lt,y as ut,yn as dt,zt as ft}from"./index-BZLPehFE.js";var pt=c(`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`}]]),mt=c(`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`}]]),ht=c(`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`}]]),J=c(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Y=t(e(),1),X=n();function gt({className:e}){return(0,X.jsx)(Ye,{asChild:!0,children:(0,X.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":N(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,X.jsx)(Ie,{})})})}function Z({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let o=f(A.projects.renameProject),s=f(A.projects.setProjectColor),c=f(A.projects.moveProject),u=f(A.projects.deleteProject),d=f(A.projects.createProject),p=ot(),m=Re(),[h,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(t),[ee,b]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(!1),x=g(A.projects.projectTreeCount,te?{projectId:e}:`skip`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Le,{onOpenChange:e=>e&&ne(!0),children:[(0,X.jsx)(gt,{className:i}),(0,X.jsxs)(Be,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(B,{onSelect:()=>a(),children:[(0,X.jsx)(He,{}),` `,O()]}),(0,X.jsxs)(B,{onSelect:()=>{y(t),_(!0)},children:[(0,X.jsx)(lt,{}),` `,j()]}),(0,X.jsxs)(B,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await m({title:k(),label:we(),placeholder:fe(),confirmLabel:Te()});t&&await d({name:t,parentId:e})})},children:[(0,X.jsx)(tt,{}),` `,k()]}),(0,X.jsxs)(B,{onSelect:()=>b(!0),children:[(0,X.jsx)(mt,{}),` `,ye()]}),(0,X.jsx)(ft,{children:_e()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":be(),children:`✕`}),it.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e,color:t.value})},t.value))]}),(0,X.jsx)(je,{}),(0,X.jsxs)(B,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=x?.folders??0,r=x?.chats??0;await p({title:de({name:t}),description:n>0?Ce({folders:n,chats:r}):r>0?ve({count:r}):ie(),confirmWord:M(),confirmLabel:xe(),destructive:!0})&&await u({projectId:e})})},children:[(0,X.jsx)($e,{}),` `,M()]})]})]}),(0,X.jsx)(Xe,{open:h,onOpenChange:_,title:he(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),_(!1)},submitLabel:j(),children:(0,X.jsx)(L,{value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),ee?(0,X.jsx)(at,{open:ee,onOpenChange:b,title:l(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function _t({chat:e,currentFolderId:t,className:n}){let a=f(A.chats.pinChat),o=f(A.chats.deleteChat),s=f(A.chats.renameChat),c=f(A.chats.setChatSidebar),l=f(A.chats.moveChatToProject),u=ot(),[d,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(e.title??``),[g,_]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Le,{children:[(0,X.jsx)(gt,{className:n}),(0,X.jsxs)(Be,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(B,{onSelect:()=>{h(e.title??``),p(!0)},children:[(0,X.jsx)(lt,{}),` `,j()]}),(0,X.jsxs)(B,{onSelect:()=>void a({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,X.jsx)(dt,{}):(0,X.jsx)(Ze,{}),e.pinned?S():T()]}),(0,X.jsxs)(B,{onSelect:()=>_(!0),children:[(0,X.jsx)(mt,{}),` `,i()]}),e.pinned&&e.inSidebar?null:(0,X.jsxs)(B,{onSelect:()=>void c({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,X.jsx)(Ne,{}):(0,X.jsx)(J,{}),e.inSidebar?r():w()]}),(0,X.jsx)(je,{}),(0,X.jsxs)(B,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await u({title:Se(),description:ie(),confirmLabel:M(),destructive:!0})&&await o({chatId:e._id})})},children:[(0,X.jsx)($e,{}),` `,M()]})]})]}),(0,X.jsx)(Xe,{open:d,onOpenChange:p,title:C(),canSubmit:m.trim().length>0,onSubmit:async()=>{await s({chatId:e._id,title:m.trim()}),p(!1)},submitLabel:j(),children:(0,X.jsx)(L,{value:m,onChange:e=>h(e.target.value),autoFocus:!0})}),g?(0,X.jsx)(at,{open:g,onOpenChange:_,title:te(),currentId:t,onPick:t=>void l({chatId:e._id,projectId:t})}):null]})}function vt(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function yt(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 bt(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 xt=`oc.projpage.view`;function St(){let e=localStorage.getItem(xt);return e===`cards`||e===`list`?e:`columns`}var Q=e=>`into:${e}`,Ct=e=>`col:${e??`null`}`,wt=e=>`crumb:${e}`;function Tt(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 Et(){let{projectId:e}=st({from:`/project/$projectId`}),t=R(),n=g(A.projects.projectPage,{projectId:e});return(0,X.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:u()}):n===null?(0,X.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,X.jsx)(`h2`,{children:d()}),(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:ne()}),(0,X.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:b()})]}):(0,X.jsx)(Dt,{page:n})})}function Dt({page:e}){let t=R(),n=ot(),r=Re(),i=nt(),a=f(A.projects.renameProject),c=f(A.projects.setProjectColor),u=f(A.projects.deleteProject),d=f(A.projects.createProject),p=f(A.projects.moveProject),v=f(A.projects.setProjectSidebar),b=f(A.chats.moveChatToProject),te=f(A.chats.reorderChat),ne=f(A.projects.reorderProject),oe=g(A.projects.projectTreeCount,{projectId:e.project._id}),[S,pe]=(0,Y.useState)(St),C=e=>{localStorage.setItem(xt,e),pe(e)},w=g(A.projects.folderColumns,S===`columns`?{projectId:e.project._id}:`skip`),T=g(A.projects.projectTreeList,S===`list`?{projectId:e.project._id}:`skip`),{c:D}=ze({from:`/project/$projectId`}),O=g(A.projects.listProjects,{}),Se=g(A.chatReads.myBusyChats,{}),N=(0,Y.useMemo)(()=>new Set(Se??[]),[Se]),De=g(A.chatReads.myChatReads,{}),Ne=(0,Y.useMemo)(()=>bt(e.chats,De??[]),[e.chats,De]),{startNewChat:He,picker:z}=Qe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[V,H]=(0,Y.useState)(``),[Ze,U]=(0,Y.useState)(!1),[W,G]=(0,Y.useState)(e.project.name),[st,dt]=(0,Y.useState)(!1),[J,gt]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=setTimeout(()=>gt(V.trim()),180);return()=>clearTimeout(e)},[V]);let Z=g(A.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),_t=Ae(rt(ct,{activationConstraint:{distance:4}}),rt(qe,{activationConstraint:{delay:250,tolerance:8}})),Q=(0,Y.useRef)(!1),Ct=()=>{Q.current=!0,setTimeout(()=>{Q.current=!1},0)},[wt,Et]=(0,Y.useState)(null),Dt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=w?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||E()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(O??[]).find(t=>t._id===e)?.name??``}}return null},At=e=>Et(Dt(String(e.active.id))),$=(0,Y.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=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(S===`columns`){for(let e of w?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(S===`list`){let e=T?.chats.find(e=>e._id===t);return e?{list:T.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(S===`columns`){for(let e of w?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(S===`list`){let e=T?.folders.find(e=>e._id===t);if(!e||!T)return null;let n=e.parentId??T.rootId;return{list:ke(T.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},It=async e=>{Et(null),Ct();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),a=String(t.id),o=a.startsWith(`chat:`);try{let e=Tt(r);if(e!==void 0){if(o)await b({chatId:a.slice(5),projectId:e});else{let t=a.slice(7);if(t===e)return;if(!Ge(O??[],t,e)){i.error(_());return}await p({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=a.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 b({chatId:e,projectId:n.folderId});let i=yt(n.list,e=>e._id,e=>e.sortKey,e,t);i&&await te({chatId:e,...i});return}if(!o&&r.startsWith(`folder:`)){let e=a.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(O??[],e,n.parentId)){i.error(_());return}await p({projectId:e,parentId:n.parentId})}let o=yt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await ne({projectId:e,...o});return}}catch{i.error(_())}},[,Lt]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>Lt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Rt=Date.now(),zt=et(e.project),Bt=vt(e.chats,V),Vt=e.breadcrumb.slice(0,-1),Ht=e=>()=>{Q.current||e()};return(0,X.jsxs)(Ke,{sensors:_t,collisionDetection:$,onDragStart:At,onDragEnd:It,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":zt},children:[(0,X.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":ee(),children:[Vt.map(e=>(0,X.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,X.jsx)(Ot,{folderId:e._id,children:(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Ht(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,X.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,X.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,X.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,X.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),e.project.sidebarHidden?(0,X.jsxs)(P,{variant:`ghost`,size:`sm`,className:`oc-projpage__hiddenbadge`,title:se(),onClick:()=>{v({projectId:e.project._id,hidden:!1})},children:[(0,X.jsx)(We,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:o()}),(0,X.jsx)(Ue,{"aria-hidden":!0})]}):null,(0,X.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":x(),children:[(0,X.jsx)(P,{variant:S===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":x(),title:x(),"aria-pressed":S===`cards`,onClick:()=>C(`cards`),children:(0,X.jsx)(ht,{})}),(0,X.jsx)(P,{variant:S===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ue(),title:ue(),"aria-pressed":S===`columns`,onClick:()=>C(`columns`),children:(0,X.jsx)(pt,{})}),(0,X.jsx)(P,{variant:S===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":le(),title:le(),"aria-pressed":S===`list`,onClick:()=>C(`list`),children:(0,X.jsx)(Oe,{})})]}),(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void He({projectId:e.project._id}),children:[(0,X.jsx)(Fe,{}),m()]}),(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:k(),label:we(),placeholder:fe(),confirmLabel:Te()});t&&await d({name:t,parentId:e.project._id})},children:[(0,X.jsx)(tt,{}),k()]}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(Ye,{asChild:!0,children:(0,X.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ge(),children:(0,X.jsx)(Ie,{})})}),(0,X.jsxs)(Be,{align:`end`,className:`w-48`,children:[(0,X.jsxs)(B,{onSelect:()=>{G(e.project.name),U(!0)},children:[(0,X.jsx)(lt,{}),` `,j()]}),(0,X.jsxs)(B,{onSelect:()=>dt(!0),children:[(0,X.jsx)(mt,{}),` `,ye()]}),(0,X.jsx)(ft,{children:_e()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void c({projectId:e.project._id,color:null}),"aria-label":be(),children:`✕`}),it.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void c({projectId:e.project._id,color:t.value})},t.value))]}),(0,X.jsx)(je,{}),(0,X.jsxs)(B,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=oe?.folders??0,a=oe?.chats??0;await n({title:de({name:e.project.name}),description:i>0?Ce({folders:i,chats:a}):a>0?ve({count:a}):ie(),confirmWord:M(),confirmLabel:xe(),destructive:!0})&&(await u({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,X.jsx)($e,{}),` `,M()]})]})]})]})]}),S===`columns`?(0,X.jsx)(Ft,{data:w,currentId:e.project._id,busyIds:N,suppressClick:Q,locateChatId:D??null}):S===`list`?(0,X.jsx)(Mt,{data:T,busyIds:N,suppressClick:Q,locateChatId:D??null}):(0,X.jsxs)(X.Fragment,{children:[e.children.length>0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ce()}),(0,X.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,X.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:ut,children:e.children.map(t=>(0,X.jsx)(kt,{child:t,parentId:e.project._id,now:Rt,suppressClick:Q},t._id))})})]}):null,(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ae()}),e.chats.length>0?(0,X.jsx)(L,{value:V,onChange:e=>H(e.target.value),placeholder:Ee(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?y():h()}):Bt.length===0&&(Z??[]).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:re({term:V.trim()})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,X.jsx)(K,{items:Bt.map(e=>`chat:${e._id}`),strategy:q,children:Bt.map(t=>(0,X.jsx)(jt,{chat:t,currentFolderId:e.project._id,now:Rt,busy:N.has(t._id),unread:Ne.has(t._id),locate:t._id===D,suppressClick:Q},t._id))})})]}),J.length>=2&&Z!==void 0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:s()}),Z.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:re({term:J})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:Z.map(e=>(0,X.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Ve(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,X.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,X.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||me()}),e.projectPath&&e.projectPath.length>1?(0,X.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,X.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,X.jsx)(Xe,{open:Ze,onOpenChange:U,title:he(),canSubmit:W.trim().length>0,onSubmit:async()=>{await a({projectId:e.project._id,name:W.trim()}),U(!1)},submitLabel:j(),children:(0,X.jsx)(L,{value:W,onChange:e=>G(e.target.value),autoFocus:!0})}),st?(0,X.jsx)(at,{open:st,onOpenChange:dt,title:l(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void p({projectId:e.project._id,parentId:t})}):null,z]}),(0,X.jsx)(Me,{children:wt?(0,X.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[wt.kind===`folder`?(0,X.jsx)(F,{size:13,"aria-hidden":!0}):(0,X.jsx)(Je,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:wt.label})]}):null})]})}function Ot({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=z({id:wt(e)});return(0,X.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function kt({child:e,parentId:t,now:n,suppressClick:r}){let i=R(),o=H({id:`folder:${e._id}`}),s=z({id:Q(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.setNodeRef(e)},className:`oc-projpage__card`+(s.isOver?` is-over`:``)+(o.isDragging?` is-dragging`:``),style:{"--proj-hue":et(e),transform:G.Transform.toString(o.transform),transition:o.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}})},...o.listeners,...o.attributes,role:`link`,tabIndex:0,children:[(0,X.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,X.jsx)(F,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,X.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,X.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?oe({count:e.folderCount})+` · `:``,a({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,X.jsx)(`span`,{className:`oc-projpage__cardage`,children:U(e.lastActivityAt,n)})]})}function At({chat:e}){let t=f(A.chats.setChatSidebar),n=e.inSidebar?r():w();return(0,X.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,X.jsx)(Ne,{}):(0,X.jsx)(J,{})})}function jt({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=R(),c=W(e.color),l=H({id:`chat:${e._id}`}),u=$(a);return(0,X.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(l.transform),transition:l.transition},children:[(0,X.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,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||E()}),e.pinned?(0,X.jsx)(Ze,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,X.jsx)(`span`,{className:`oc-projpage__chatage`,children:U(e.updatedAt,n)}),r?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,title:D(),"aria-label":D()}):null,i&&!r?(0,X.jsx)(`span`,{className:`oc-chatitem__unread`,title:pe(),"aria-label":pe()}):null]}),(0,X.jsx)(At,{chat:e}),(0,X.jsx)(_t,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function $(e){let t=(0,Y.useRef)(null);return(0,Y.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,Y.useState)(new Set),o=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:u()});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,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{items:u.map(e=>`chat:${e._id}`),strategy:q,children:u.map(e=>(0,X.jsx)(Pt,{chat:e,depth:l,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,X.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:q,children:d.map(t=>(0,X.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,X.jsx)(`div`,{className:`oc-projpage__tree`,children:(o.get(e.rootId)??[]).length===0&&ke(e.folders,null).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:y()}):c(null,0)})}function Nt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=R(),c=H({id:`folder:${e._id}`}),l=z({id:Q(e._id)});return(0,X.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,X.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":et(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?v():p(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,X.jsx)(V,{size:13}):(0,X.jsx)(De,{size:13})}),(0,X.jsx)(F,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(Z,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function Pt({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=R(),o=H({id:`chat:${e._id}`}),s=$(r),c=W(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||E()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)(_t,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,X.jsx)(At,{chat:e})]})}function Ft({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:u()}):(0,X.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,X.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:Ct(e.folderId)});return(0,X.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,X.jsx)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:q,children:e.folders.map(t=>(0,X.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,X.jsx)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:q,children:e.chats.map(t=>(0,X.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,X.jsx)(`p`,{className:`oc-projpage__colempty`,children:h()}):null]})}function Lt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=H({id:`folder:${e._id}`}),o=z({id:Q(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":et(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,X.jsx)(F,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(Z,{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=$(r),c=W(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||E()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)(_t,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,X.jsx)(At,{chat:e})]})}export{Et 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,AE as a,CE as o,Cl as s,DE as c,EE as l,FK as u,IK as d,La as f,OE as p,Qf as m,Qu as h,RE as g,SE as _,Sl as ee,TE as v,_E as y,bE as te,dd as ne,ed as b,ep as x,fE as S,fd as C,gE as w,hE as T,jE as re,kE as ie,ld as ae,mE as oe,nd as se,np as ce,pE as E,t as D,td as O,tp as k,ud as A,vE as j,wE as M,xE as N,xl as P,yE as F,zE as I}from"./api-CKGeK7QS.js";import{i as L,n as R,r as z,t as B}from"./FieldLabel-ObN4xPwN.js";import{t as V}from"./button-HWWS6bgL.js";import{Qt as H,Xt as U,Yt as W,Z as le,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-BZLPehFE.js";import{r as X,t as Z}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),me={media_delivery:{label:l,help:v},documentary_fetch:{label:M,help:o},inbound_files:{label:_,help:N},history_summary:{label:ce,help:k},file_curation:{label:C,help:se},quote_reply:{label:ne,help:A}},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:oe,references:E,files:S,previous_summary:x,new_messages:r,max_chars:m,file_name:O,budget_chars:b,feedback:i,content:h,excerpt:ae};function _e(){let e=d(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:F()})});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:re(),help:a()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:te()}),(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=u(D.admin.upsertInstanceConfig),n=de(),r=d(D.me.getMe,{host:le}),i=e.config??{},a=X(e.config?.contentLocale,r?.defaultLocale??void 0),[o,c]=(0,Q.useState)(()=>L(i,a));(0,Q.useEffect)(()=>{c(L(i,a))},[a,e._id]);let[l,f]=(0,Q.useState)(!1),p=o.promptInjections,m=(e,t)=>c({...o,promptInjections:{...p,[e]:{...p[e],...t}}});async function h(){f(!0);try{await t({instanceId:e._id,config:z(o,i,a)})}catch(e){n.error(g(),e)}finally{f(!1)}}async function _(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(g(),e)}}let v=e.config?.contentLocale??`default`,y=Z[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:v,onValueChange:e=>void _(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:P({locale:y})}),pe().map(e=>(0,$.jsx)(q,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ee()})]}),U.map(e=>(0,$.jsx)(ye,{injKey:e,def:W[e],i18n:me[e],row:p[e]??{enabled:!0,template:W[e].defaultTemplate[a]},contentLocale:a,onChange:t=>m(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(V,{size:`sm`,onClick:()=>void h(),disabled:l,children:I()})})]})}function ye({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[o,s]=(0,Q.useState)(!1),l=r.template.trim()!==t.defaultTemplate[i],u=t.togglable&&!r.enabled,d=Object.fromEntries(t.placeholders.map(e=>[e,he[e]??`{${e}}`])),m=ue(e,r,i),h=m?H(m,d):``;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()}),l&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:p()})]}),(0,$.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:u,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:c()}),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:()=>s(e=>!e),children:o?y():j()}),l&&(0,$.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:ie()})]})]}),o&&(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:w()}),t.pluralDefaultTemplate!==void 0&&!u?(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:f()}):null]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:T()})})]})}export{_e as PromptInjectionsTab};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AA as r,CA as i,DA as a,EA as o,FK as s,Gk as c,Hk as l,IK as u,Id as d,Jk as ee,Kk as te,MA as f,OA as p,SA as m,TA as h,Uk as g,Wk as _,Xk as v,Yk as y,_A as ne,aA as re,bA as b,cA as ie,dA as ae,fA as oe,gA as x,hA as S,iA as C,jA as w,kA as T,lA as E,mA as D,nA as O,oA as k,pA as A,qk as j,rA as M,sA as N,t as P,uA as F,vA as I,wA as L,xA as R,yA as z}from"./api-CKGeK7QS.js";import{t as B}from"./button-HWWS6bgL.js";import{At as V,Dn as H,Ft as U,_ as W,jt as G,mt as K,q}from"./index-BZLPehFE.js";import{t as J}from"./roleDescriptions-B2IUxsB1.js";var Y=t(e(),1),X=n(),Z=[{group:()=>f(),keys:[{key:`traces.read`,label:()=>a()},{key:`traces.read.content`,label:()=>o(),phi:!0},{key:`traces.write`,label:()=>h()}]},{group:()=>w(),keys:[{key:`kpi.read`,label:()=>a()},{key:`kpi.write`,label:()=>h()}]},{group:()=>r(),keys:[{key:`openclaw.query`,label:()=>L()},{key:`anomalies.read`,label:()=>i()},{key:`anomalies.report`,label:()=>m()}]},{group:()=>T(),keys:[{key:`chats.read`,label:()=>a()},{key:`selfheal`,label:()=>b()},{key:`media.repair`,label:()=>z()},{key:`feedback.respond`,label:()=>d()}]},{group:()=>p(),keys:[{key:`admin.manage`,label:()=>R()}]}],se=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function ce(){let e=u(P.apiKeys.listRoles,{}),t=s(P.apiKeys.createRole),n=s(P.apiKeys.ensureRolesSeeded),r=s(P.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(P.apiKeys.listRoles,{});r&&e.setQuery(P.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),i=q(),a=G(),[o,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)($),[m,h]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{a.error(ne(),e)})},[n,a]);let b=e??[];async function w(e,t){if(Q(e.permissions))return;if(e.builtin){await i({title:x({name:e.name}),description:S(),confirmLabel:D()});return}if(m.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];h(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){a.error(A(),e)}finally{h(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function T(){try{await t({key:f.key,name:f.name,description:f.description||void 0,permissions:[]}),p($),d(!1)}catch(e){a.error(oe(),e)}}let L=e===void 0,R=!L&&b.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[ae(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,F(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,E()]}),(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:ie()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{p($),d(!0)},children:N()})})]}),L?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:k()}):R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:re()}):(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:C()}),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?I({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:b.map(e=>{let t=Q(e.permissions),n=m.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,{}),` `,M()]}):(0,X.jsx)(V,{variant:`secondary`,children:O()})]}),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?v():n?y():r,onCheckedChange:()=>void w(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:o,onOpenChange:d,title:ee(),description:j(),canSubmit:!!(f.key&&f.name),onSubmit:T,submitLabel:te(),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:c()}),(0,X.jsx)(U,{value:f.key,placeholder:_(),onChange:e=>p({...f,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:g()}),(0,X.jsx)(U,{value:f.name,onChange:e=>p({...f,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:l()}),(0,X.jsx)(U,{value:f.description,onChange:e=>p({...f,description:e.target.value})})]})]})})]})}export{ce as RolesTab};
|