UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 2.79 kB
import{t as expandHomePrefix}from"./home-dir-DEN5DisQ.mjs";import{f as resolveExecApprovalsSocketPath,u as resolveExecApprovalsDisplayPath}from"./exec-approvals-config-B_i2AhQm.mjs";import{t as resolveExecApprovalsFromFileInternal}from"./exec-approvals-resolver-BBnOjuxT.mjs";import{r as readExecApprovalsSocket}from"./exec-approvals-socket-6gKb6Zw9.mjs";import{a as loadExecApprovalsReadOnlyAsync,n as ensureExecApprovalsSnapshot,t as commitExecAuthorizations}from"./exec-approvals-store-CKqFK0Id.mjs";import"./exec-approvals-allowlist-WcJeUOTK.mjs";import"./exec-approvals-generated-migration-CRnGtmJK.mjs";import{i as createExecApprovalPolicySnapshot,n as assertCurrentUsageAuthorization,r as buildAllowlistEntryMatchKey}from"./exec-approvals-authorization.kernel-K-YiskZ8.mjs"; //!src/infra/exec-approvals-authorization.ts async function recordAllowlistMatchesUse(e,t){const n=structuredClone({agentId:e.agentId,matches:[...e.matches],command:e.command,resolvedPath:e.resolvedPath,authorization:e.authorization});return retainedAuthorization(n,await commitExecAuthorizations(n,e.assertCurrent,t))}async function commitExecAuthorizationLocked(e){const t=structuredClone(e);return retainedAuthorization(t,await commitExecAuthorizations(t))}function retainedAuthorization(e,{file:t,readCurrent:n}){const r=new Set(e.matches.filter(e=>e.pattern).map(buildAllowlistEntryMatchKey));const i={...e.authorization,policySnapshot:createExecApprovalPolicySnapshot({file:t,agentId:e.agentId})};return()=>assertCurrentUsageAuthorization({file:n(),agentId:e.agentId,command:e.command,matchKeys:r,authorization:i})} //!src/infra/exec-approvals.ts function redactExecApprovals(e){const{raw:t,...n}=e;const r=e.file.socket?.path?.trim();return{...n,file:{...e.file,socket:r?{path:r}:void 0}}}function shapeResolvedExecApprovals(e){const t=resolveExecApprovalsSocketPath();return resolveExecApprovalsFromFileInternal({file:e.file,agentId:e.agentId,overrides:e.overrides,path:e.filePath,socketPath:e.socket===`persisted`?expandHomePrefix(e.file.socket?.path??t):t,token:e.socket===`persisted`?e.file.socket?.token??``:``})}async function resolveExecApprovalsLocked(e,t){const n=resolveExecApprovalsDisplayPath();if(!t?.requireSocket){const r=shapeResolvedExecApprovals({file:await loadExecApprovalsReadOnlyAsync(),filePath:n,agentId:e,overrides:t,socket:`none`});if((r.agent.security===`full`||r.agent.security===`deny`)&&r.agent.ask===`off`&&!(await readExecApprovalsSocket())?.socket_token?.trim())return r}return shapeResolvedExecApprovals({file:(await ensureExecApprovalsSnapshot()).file,filePath:resolveExecApprovalsDisplayPath(),agentId:e,overrides:t,socket:`persisted`})}export{recordAllowlistMatchesUse as i,resolveExecApprovalsLocked as n,commitExecAuthorizationLocked as r,redactExecApprovals as t};