UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines • 1.11 kB
import{formatError}from"#internal/logging.js";import{isPlainRecord,isThenable}from"#shared/guards.js";import{isInstrumentationChannelKind,normalizeInstrumentationChannelKind}from"#shared/instrumentation-channel-kind.js";import{parseJsonObject}from"#shared/json.js";function resolveInstrumentationProjection(e){let{invoke:t,log:n,source:r}=e,i;try{i=t()}catch(e){n.warn(`ignoring instrumentation projection after projector failure`,{error:formatError(e),source:r});return}if(isThenable(i)){n.warn(`ignoring instrumentation projection because it returned a Promise`,{source:r}),Promise.resolve(i).catch(e=>{n.warn(`ignored instrumentation projection Promise rejected`,{error:formatError(e),source:r})});return}if(i!==void 0){if(!isPlainRecord(i)){n.warn(`ignoring instrumentation projection because it is not a record`,{source:r});return}try{return parseJsonObject(i)}catch(e){n.warn(`ignoring instrumentation projection because it is outside the JSON contract`,{error:formatError(e),source:r});return}}}export{isInstrumentationChannelKind,normalizeInstrumentationChannelKind,resolveInstrumentationProjection};