UNPKG

eve

Version:

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

1 lines 1.28 kB
import{formatError}from"#internal/logging.js";import{isPlainRecord,isThenable}from"#shared/guards.js";import{parseJsonObject}from"#shared/json.js";const FRAMEWORK_CHANNEL_KINDS=new Set([`http`,`schedule`,`subagent`]);function isInstrumentationChannelKind(e){return e.startsWith(`channel:`)||FRAMEWORK_CHANNEL_KINDS.has(e)}function normalizeInstrumentationChannelKind(e){return e!==void 0&&isInstrumentationChannelKind(e)?e:`unknown`}function resolveInstrumentationProjection(n){let{invoke:r,log:i,source:a}=n,o;try{o=r()}catch(t){i.warn(`ignoring instrumentation projection after projector failure`,{error:formatError(t),source:a});return}if(isThenable(o)){i.warn(`ignoring instrumentation projection because it returned a Promise`,{source:a}),Promise.resolve(o).catch(t=>{i.warn(`ignored instrumentation projection Promise rejected`,{error:formatError(t),source:a})});return}if(o!==void 0){if(!isPlainRecord(o)){i.warn(`ignoring instrumentation projection because it is not a record`,{source:a});return}try{return parseJsonObject(o)}catch(t){i.warn(`ignoring instrumentation projection because it is outside the JSON contract`,{error:formatError(t),source:a});return}}}export{isInstrumentationChannelKind,normalizeInstrumentationChannelKind,resolveInstrumentationProjection};