eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.03 kB
JavaScript
import{buildBaseToolContext}from"#context/build-base-tool-context.js";import{createAuthorizationContext}from"#runtime/authorization-context.js";import{handleAuthorizationError}from"#runtime/connections/scoped-authorization.js";function createToolExecuteWithAuth(e){return(t,n)=>{let r=createAuthorizationContext({scope:e.scope}),i={...buildBaseToolContext({options:n,toolName:e.scope}),getToken:r.getToken,requireAuth:r.requireAuth};return r.run(()=>e.execute(t,i))}}function buildApprovalResponseAuth(e){let t=createAuthorizationContext({scope:e.scope,boundResponder:e.responder});return{getToken:(n,r)=>t.getToken(n,namespaceApprovalAuthOptions(e.scope,r)),requireAuth:(n,r)=>t.requireAuth(n,namespaceApprovalAuthOptions(e.scope,r))}}function namespaceApprovalAuthOptions(e,t){return t?.authKey===void 0?t:{...t,authKey:`${e}:${t.authKey}`}}async function handleApprovalResponsePolicyError(e){return await handleAuthorizationError(e)}export{buildApprovalResponseAuth,createToolExecuteWithAuth,handleApprovalResponsePolicyError};