openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 13.4 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Nt as t,Qt as n,Xt as r,jt as i}from"./control-ui-connection-Bfj9beF_.js";import{a,dj as o,ej as s,fD as c,mj as l,o as u,pD as d,pj as f,tj as ee}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as p,C as m,Ct as h,F as g,I as te,Rt as ne,S as _,St as v,U as y,d as b,f as x,g as S,gt as re,j as C,l as w,s as T,u as E,w as D,x as O,yt as ie}from"./solid-runtime-C416s-HC.js";import{l as ae,n as oe,p as se,r as k,s as ce,u as le,y as A}from"./settings-ui-Ck6BJLhD.js";import{n as j,t as M}from"./en-approvals-CzdV2FkS.js";import{i as N,n as ue}from"./format-CCjyseBm.js";import{n as de,t as P}from"./gateway-page-BGbclR08.js";import{r as fe,t as F}from"./approval-result-validators-COrRxoh2.js";import{a as pe,o as I}from"./route-chrome-7YRVJwhf.js";function L(e){let t=()=>{if(e.error)throw Error(e.error);return null};return C(_,{fallback:(t,n)=>(()=>{var i=R(),a=i.firstChild,o=a.nextSibling;return b(i,()=>r(t()),a),b(i,(()=>{var t=x(()=>!!e.onRetry);return()=>t()?C(k,{get disabled(){return e.retryDisabled},onRetry:()=>{e.onRetry?.(),n()}}):null})(),o),i})(),get children(){return t()}})}var R;function z(){return(z=e((()=>{E(),y(),A(),n(),R=O(`<div class="callout danger"role=alert><!><!>`)})))()}function me(e,t){if(e.revokedAtMs!==null)return l(`standingGrants.stateRevoked`);if(e.expiresAtMs!==null&&e.expiresAtMs<=t)return l(`standingGrants.stateExpired`);if(e.expiresAtMs!==null){let n=Math.max(1,Math.ceil((e.expiresAtMs-t)/864e5));return l(`standingGrants.stateExpiresIn`,{count:String(n)})}return l(`standingGrants.stateUntilRevoked`)}function he(e){let t=e.presentation;return(t.kind===`exec`?t.commandText:t.title)||l(`approvalHistory.unknown`)}function ge(e){let t=[e.source?.agentId,e.source?.sessionKey].filter(e=>!!e);return t.length>0?t.join(` · `):l(`approvalHistory.unknown`)}function _e(e){return e.resolver?e.resolver.id?`${e.resolver.kind} · ${e.resolver.id}`:e.resolver.kind:l(`approvalHistory.unknown`)}function B(e){var t=U(),n=t.firstChild,r=n.firstChild;return b(r,()=>e.label),w(()=>e.columns,e=>{S(n,`colspan`,e)}),t}function V(e){var t=W();return b(t,()=>e.value),w(()=>({e:!!e.mono,t:l(e.labelKey)}),({e,t:n},r)=>{e!==r?.e&&t.classList.toggle(`mono`,e),n!==r?.t&&S(t,`data-label`,n)}),t}function H(){let e=ee(),n=!1,[i,a]=p(0,{ownedWrite:!0}),o=()=>a(e=>e+1),s={items:[],grants:[],grantsLoaded:!1,grantsError:null,revokingGrantId:null,nextCursor:null,loadKind:null,error:null,connected:!1,approvalsAccess:!0,client:null,gatewaySource:null,presentationScopeKey:null,requestGeneration:0,grantsGeneration:0,hasLoaded:!1,historyRefreshPending:!1},d=()=>(i(),s),[f,_]=p(null),[y,T]=p(null),E=g(()=>d().requestGeneration),O=Promise.withResolvers(),k=g(()=>{let e=E(),t=f();return t?.generation===e?t.completion:void 0}),A=g(()=>{let e=E(),t=y();return t?.generation===e?t.completion:void 0}),j=g(()=>d().items.length===0?f():null),M=()=>(d().items.length===0?k():h(k),null),N=()=>(d().grantsLoaded?h(A):A(),null),P=()=>v(k)&&d().loadKind===`more`,F=g(()=>{let e=E(),[t,n]=te(!1);return{generation:e,saving:t,setSaving:n}}),I=ie(function*(e,t,r){!n&&e.generation===s.requestGeneration&&e.setSaving(!0),yield Promise.race([t,r])}),R=()=>F().saving(),z;de({getGateway:()=>e.gateway,onSnapshot:({snapshot:n,initial:r,sourceChanged:i})=>{if(r||i){z?.(),H(!0);let n=e.gateway;s.gatewaySource=n,z=n.subscribeEvents(r=>{s.gatewaySource===n&&e.gateway===n&&s.approvalsAccess&&t(n.snapshot).canReviewApprovals&&u(r.event,r.payload)&&(s.historyRefreshPending=!0,s.loadKind===null&&W(!0))})}U(n)}}),re(()=>()=>{n=!0,z?.(),H(!1),s.gatewaySource=null});function H(e){O.resolve(),O=Promise.withResolvers(),s.requestGeneration+=1,s.loadKind=null,s.historyRefreshPending=!1,s.revokingGrantId=null,e&&(s.grants=[],s.grantsLoaded=!1,s.grantsError=null,s.hasLoaded=!1,s.items=[],s.nextCursor=null,s.error=null)}function U(e){let n=s.gatewaySource?c(s.gatewaySource).key:null,r=e.client!==s.client||n!==s.presentationScopeKey;s.presentationScopeKey=n;let i=e.phase===`connected`!==s.connected,a=e.phase===`connected`?t(e).canReviewApprovals:s.approvalsAccess,l=a!==s.approvalsAccess;s.connected=e.phase===`connected`,s.approvalsAccess=a,r||l?(s.client=e.client,H(!0)):i&&(H(!1),e.phase===`connected`&&(s.hasLoaded=!1)),e.phase===`connected`&&e.client&&s.approvalsAccess&&!s.hasLoaded&&s.loadKind!==`reset`&&W(!0),o()}async function W(e){let n=s.client,i=s.gatewaySource;if(!n||!i||!s.connected||!s.approvalsAccess||!t(i.snapshot).canReviewApprovals||s.loadKind!==null)return;let a=s.requestGeneration,c=e?void 0:s.nextCursor??void 0;if(!e&&!c)return;e&&(s.historyRefreshPending=!1),s.loadKind=e?`reset`:`more`,s.error=null,o();let u=()=>Z(n,i,a);e&&X(n,u);let d=f(n);return _({generation:a,completion:Promise.race([d,O.promise])}),d;async function f(t){try{let n=await t.request(`approval.history`,{...c?{cursor:c}:{},limit:De});if(!fe(n))throw Error(l(`approvalHistory.invalidResponse`));if(!u())return;s.items=e?n.items:[...s.items,...n.items],s.nextCursor=n.nextCursor??null,s.hasLoaded=!0}catch(e){u()&&(s.error=r(e),s.hasLoaded=!0)}finally{u()&&(s.loadKind=null,o(),s.historyRefreshPending&&W(!0))}}}async function X(e,t){let n=++s.grantsGeneration,i=()=>t()&&s.grantsGeneration===n,a=c();return T({generation:s.requestGeneration,completion:Promise.race([a,O.promise])}),a;async function c(){try{let t=await e.request(`exec.approval.grants.list`,{});if(!i())return;s.grants=t.grants,s.grantsLoaded=!0,s.grantsError=null,o()}catch(e){i()&&(s.grantsError=r(e),o())}}}function Z(r,i,a){return!n&&s.connected&&s.approvalsAccess&&s.gatewaySource===i&&e.gateway===i&&i.snapshot.phase===`connected`&&t(i.snapshot).canReviewApprovals&&s.client===r&&s.requestGeneration===a}async function Me(e){let t=s.client,n=s.gatewaySource,i=s.requestGeneration;if(!t||!n||s.revokingGrantId!==null||!Z(t,n,i))return;let a=()=>Z(t,n,i),c=F(),l=O.promise;s.revokingGrantId=e;let u=d(t);await I(c,u,l);async function d(t){try{if(await t.request(`exec.approval.grants.revoke`,{grantId:e}),!a())return;s.grantsGeneration+=1;let n=Date.now();s.grants=s.grants.map(t=>t.grantId===e?{...t,revokedAtMs:n}:t),s.grantsError=null,o()}catch(e){a()&&(s.grantsError=r(e),o())}finally{a()&&(s.revokingGrantId=null,o())}}}function Ne(e){let t=()=>l(R()&&d().revokingGrantId===e.grant.grantId?`standingGrants.revoking`:`standingGrants.revoke`);var n=ve(),r=n.firstChild,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling;return b(n,C(V,{labelKey:`standingGrants.columns.automation`,get value(){return e.grant.cronJobName??e.grant.cronJobId}}),r),b(n,C(V,{labelKey:`standingGrants.columns.command`,get value(){return e.grant.command},mono:!0}),i),b(n,C(V,{labelKey:`standingGrants.columns.uses`,get value(){return e.grant.useCount}}),a),b(a,()=>me(e.grant,Date.now())),b(o,(()=>{var n=x(()=>e.grant.revokedAtMs===null&&(e.grant.expiresAtMs===null||e.grant.expiresAtMs>Date.now()));return()=>n()?(()=>{var n=G();return n._$$click=()=>void Me(e.grant.grantId),b(n,t),w(()=>({e:`${t()}: ${e.grant.cronJobName??e.grant.cronJobId} — ${e.grant.command}`,t:R()||!d().connected}),({e,t},r)=>{e!==r?.e&&S(n,`aria-label`,e),t!==r?.t&&S(n,`disabled`,t)}),n})():null})()),w(()=>l(`standingGrants.columns.state`),e=>{S(a,`data-label`,e)}),n}function Pe(e){var t=K(),n=t.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling,s=o.nextSibling,c=s.nextSibling;return b(t,C(V,{labelKey:`approvalHistory.columns.resolved`,get value(){return ue(e.item.resolvedAtMs,{dateStyle:`medium`,timeStyle:`short`})}}),n),b(t,C(V,{labelKey:`approvalHistory.columns.kind`,get value(){return l(Oe[e.item.presentation.kind])}}),r),b(t,C(V,{labelKey:`approvalHistory.columns.request`,get value(){return he(e.item)},mono:!0}),i),b(t,C(V,{labelKey:`approvalHistory.columns.decision`,get value(){return[x(()=>l(ke[e.item.status])),` ·`,` `,x(()=>l(`decision`in e.item&&e.item.decision?Ae[e.item.decision]:`approvalHistory.notApplicable`))]}}),a),b(t,C(V,{labelKey:`approvalHistory.columns.reason`,get value(){return l(je[e.item.reason])}}),o),b(t,C(V,{labelKey:`approvalHistory.columns.source`,get value(){return ge(e.item)},mono:!0}),s),b(t,C(V,{labelKey:`approvalHistory.columns.resolver`,get value(){return _e(e.item)},mono:!0}),c),t}var Q=q(),$=Q.firstChild,Fe=$.nextSibling;return Q._$owner=ne(),b(Q,C(le,{get title(){return l(`tabs.approvals`)},get subtitle(){return[x(()=>l(`approvalHistory.description`)),` `,C(oe,{url:Y})]}}),$),b(Q,C(pe,{get children(){return C(ae,{wide:!0,get children(){return[x(()=>x(()=>!d().connected)()?(()=>{var e=J();return b(e,()=>l(`approvalHistory.offline`)),e})():null),x(()=>x(()=>!(!d().connected||d().approvalsAccess))()?(()=>{var e=ye(),t=e.firstChild;return b(e,()=>l(`common.disabled`),t),e})():null),x(()=>x(()=>!!d().approvalsAccess)()?C(L,{get error(){return d().error},onRetry:()=>void W(!0),get retryDisabled(){return!d().connected}}):null),x(()=>x(()=>!!d().approvalsAccess)()?[C(se,{get title(){var e=Ce();return b(e,()=>l(`standingGrants.title`)),e},get description(){return l(`standingGrants.description`)},get notice(){return C(L,{get error(){return d().grantsError}})},get children(){var e=be(),t=e.firstChild.firstChild,n=t.firstChild.firstChild,r=n.nextSibling,i=r.nextSibling,a=i.nextSibling,o=a.nextSibling.firstChild,s=t.nextSibling;return b(n,()=>l(`standingGrants.columns.automation`)),b(r,()=>l(`standingGrants.columns.command`)),b(i,()=>l(`standingGrants.columns.uses`)),b(a,()=>l(`standingGrants.columns.state`)),b(o,()=>l(`standingGrants.revoke`)),b(s,C(D,{get on(){return E()},get fallback(){return C(B,{columns:5,get label(){return l(`approvalHistory.unknown`)}})},get children(){return[x(()=>N()),x(()=>x(()=>d().grants.length===0)()?C(B,{columns:5,get label(){return l(d().grantsLoaded?`standingGrants.empty`:`approvalHistory.unknown`)}}):C(m,{get each(){return d().grants},keyed:e=>e.grantId,children:e=>C(Ne,{get grant(){return e()}})}))]}})),e}}),C(se,{get title(){var e=we();return b(e,()=>l(`standingGrants.historyTitle`)),e},get children(){return C(D,{get on(){return j()},get fallback(){return C(ce,{get label(){return l(`approvalHistory.loading`)}})},get children(){return[x(()=>M()),(()=>{var e=xe(),t=e.firstChild,n=t.firstChild,r=n.firstChild,i=n.nextSibling;return b(r,C(m,{each:[`resolved`,`kind`,`request`,`decision`,`reason`,`source`,`resolver`],children:e=>(()=>{var t=Te();return b(t,()=>l(`approvalHistory.columns.${e}`)),t})()})),b(i,(()=>{var e=x(()=>d().items.length===0);return()=>e()?C(B,{columns:7,get label(){return l(d().error||!d().hasLoaded?`approvalHistory.unknown`:`approvalHistory.empty`)}}):C(m,{get each(){return d().items},keyed:e=>e.id,children:e=>C(Pe,{get item(){return e()}})})})()),w(()=>v(k)?`true`:`false`,e=>{S(t,`aria-busy`,e)}),e})(),(()=>{var e=Se(),t=e.firstChild,n=t.nextSibling;return b(t,()=>l(`approvalHistory.retention`)),b(n,(()=>{var e=x(()=>!!d().nextCursor);return()=>e()?(()=>{var e=Ee();return e._$$click=()=>void W(!1),b(e,()=>l(P()?`approvalHistory.loadingMore`:`approvalHistory.loadMore`)),w(()=>!d().connected||P(),t=>{S(e,`disabled`,t)}),e})():null})()),e})()]}})}})]:null)]}})}}),Fe),Q}var U,W,ve,G,K,q,J,ye,be,xe,Se,Ce,we,Te,Ee,De,Y,Oe,ke,Ae,je;function X(){return(X=e((()=>{E(),y(),F(),a(),d(),i(),A(),I(),M(),n(),s(),N(),P(),o(),z(),U=O(`<tr><td class=data-table-empty-cell><div class=data-table-empty-state role=status aria-live=polite>`),W=O(`<td>`),ve=O(`<tr><!><!><td aria-live=polite></td><td>`),G=O(`<button class="btn btn--sm">`),K=O(`<tr><!><!><!><!><!><!><!>`),q=O(`<openclaw-approvals-page><!><!>`,1),J=O(`<div class="callout warn"role=status>`),ye=O(`<div class="callout warn"role=status> · <code>operator.approvals`),be=O(`<div class=data-table-container><table class="data-table standing-grants-table settings-table--stacked"role=table aria-labelledby=standing-grants-title><thead><tr><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col><span class=sr-only></span></th></tr></thead><tbody>`),xe=O(`<div class=data-table-container><table class="data-table approval-history-table settings-table--stacked"role=table aria-labelledby=approval-history-title><thead><tr></tr></thead><tbody>`),Se=O(`<div class=data-table-pagination><div class=data-table-pagination__info></div><div class=data-table-pagination__controls>`),Ce=O(`<span id=standing-grants-title>`),we=O(`<span id=approval-history-title>`),Te=O(`<th scope=col>`),Ee=O(`<button>`),f(j),De=50,Y=`https://docs.openclaw.ai/tools/exec-approvals`,Oe={exec:`approvalHistory.kinds.exec`,plugin:`approvalHistory.kinds.plugin`,"system-agent":`approvalHistory.kinds.systemAgent`},ke={allowed:`approvalHistory.statuses.allowed`,denied:`approvalHistory.statuses.denied`,expired:`approvalHistory.statuses.expired`,cancelled:`approvalHistory.statuses.cancelled`},Ae={"allow-once":`approvalHistory.decisions.allowOnce`,"allow-always":`approvalHistory.decisions.allowAlways`,deny:`approvalHistory.decisions.deny`},je={user:`approvalHistory.reasons.user`,timeout:`approvalHistory.reasons.timeout`,"malformed-verdict":`approvalHistory.reasons.malformedVerdict`,"no-route":`approvalHistory.reasons.noRoute`,"run-aborted":`approvalHistory.reasons.runAborted`,"gateway-restart":`approvalHistory.reasons.gatewayRestart`,"storage-corrupt":`approvalHistory.reasons.storageCorrupt`},T([`click`])})))()}X();export{H as ApprovalsPage};