UNPKG

eve

Version:

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

2 lines 1.28 kB
const CHANNEL_SENTINEL=`eve:channel`,CHANNEL_INSTRUMENTATION_KIND=Symbol.for(`eve.channel.instrumentationKind`),CHANNEL_INSTRUMENTATION_KINDS=Symbol.for(`eve.channel.instrumentationKinds`),channelInstrumentationKindGlobal=globalThis;channelInstrumentationKindGlobal[CHANNEL_INSTRUMENTATION_KINDS]??=new Map;const channelInstrumentationKinds=channelInstrumentationKindGlobal[CHANNEL_INSTRUMENTATION_KINDS];function isCompiledChannel(e){return typeof e==`object`&&!!e&&e.__kind===`eve:channel`}function getChannelInstrumentationKind(e){if(!isCompiledChannel(e))return;let t=Reflect.get(e,CHANNEL_INSTRUMENTATION_KIND);if(typeof t==`string`&&t.length>0)return t;let n=e.adapter.kind;if(typeof n==`string`&&n.startsWith(`channel:`))return n;let r=channelRouteSignature(e);return r===void 0?void 0:channelInstrumentationKinds.get(r)}function setChannelInstrumentationKind(e,t){Object.defineProperty(e,CHANNEL_INSTRUMENTATION_KIND,{configurable:!0,enumerable:!1,value:t});let n=channelRouteSignature(e);n!==void 0&&channelInstrumentationKinds.set(n,t)}function channelRouteSignature(e){if(e.routes.length!==0)return e.routes.map(e=>`${e.method.toUpperCase()} ${e.path}`).sort().join(` `)}export{CHANNEL_SENTINEL,getChannelInstrumentationKind,isCompiledChannel,setChannelInstrumentationKind};