UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 830 B
import{s as resolveBlockMessage}from"./hooks-Bu2gwS_g.mjs"; //!src/agents/harness/before-agent-run.ts async function runBeforeAgentRunGate(e,t,n){if(!e?.hasHooks(`before_agent_run`))return;let r;try{r=await e.runBeforeAgentRun(structuredClone(t),n)}catch{r={pluginId:`before_agent_run`,decision:{outcome:`block`,reason:`before_agent_run hook failed`}}}if(r?.decision.outcome!==`block`)return;const i=r.pluginId??`unknown`;return{blockedBy:i,message:resolveBlockMessage(r.decision,{blockedBy:i})}}function buildAgentRunBlockedUserMessage(e,t){const n=Date.now();return{role:`user`,content:[{type:`text`,text:t.message}],timestamp:n,idempotencyKey:`hook-block:before_agent_run:user:${e}`,__openclaw:{beforeAgentRunBlocked:{blockedBy:t.blockedBy,blockedAt:n}}}}export{runBeforeAgentRunGate as n,buildAgentRunBlockedUserMessage as t};