UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 834 B
//!src/gateway/server-methods/lazy-core-handlers.ts const preparations=/* @__PURE__ */ new WeakMap;async function prepareGatewayRequestHandler(e,t,n){let r=e;let i=preparations.get(r);while(i){t?.assertOpen();r=await i();i=preparations.get(r)}if(n?.prepareDispatchCurrent)await n.prepareDispatchCurrent();return r}function createLazyCoreHandlers(e){return Object.fromEntries(e.methods.map(t=>{const forwarding=async e=>{const t=e.context.requestEntryLifetime?.enter(e);try{const n=await prepareGatewayRequestHandler(forwarding,t);t?.assertOpen();t?.release();await n(e)}finally{t?.release()}};preparations.set(forwarding,async()=>{const n=(await e.loadHandlers())[t];if(!n)throw new Error(`lazy gateway handler not found: ${t}`);return n});return[t,forwarding]}))}export{prepareGatewayRequestHandler as n,createLazyCoreHandlers as t};