openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.33 kB
JavaScript
import{f as resolveExecApprovalsSocketPath}from"./exec-approvals-config-B_i2AhQm.mjs";import{n as runClientCredentialOperationAsync}from"./client-credential-async-Cjr3lnxO.mjs";import{randomBytes}from"node:crypto";
//!src/infra/exec-approvals-socket.ts
async function readExecApprovalsSocket(e=process.env,t){const n=await runClientCredentialOperationAsync(e,{kind:`socket.read`},t);if(n.kind!==`socket`)throw new Error(`Client credential owner returned an invalid socket result.`);return n.socket}async function ensureExecApprovalsSocket(e=process.env,t,n){const r=await runClientCredentialOperationAsync(e,{kind:`socket.ensure`,fallback:{socket_key:`current`,socket_path:resolveExecApprovalsSocketPath(e),socket_token:randomBytes(24).toString(`base64url`),updated_at_ms:Date.now()},requested:n},t);if(r.kind!==`socket`||!r.socket)throw new Error(`Client credential owner returned an invalid socket result.`);return r.socket}async function attachExecApprovalsSocket(e,t,n,r){const i=await ensureExecApprovalsSocket(t.initializationEnvironment??t.environment,{assertCurrent:()=>{t.admission.assertCurrent();n?.()}},r);return{...e,file:{...e.file,socket:{...e.file.socket,path:i.socket_path??void 0,token:i.socket_token??void 0}}}}export{ensureExecApprovalsSocket as n,readExecApprovalsSocket as r,attachExecApprovalsSocket as t};