UNPKG

eve

Version:

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

1 lines 1.52 kB
const DEFINITION_KEY=Symbol.for(`eve.definition-source-key`),REGISTRY_SYMBOL=Symbol.for(`eve.definition-source-registry`),registryContainer=globalThis;registryContainer[REGISTRY_SYMBOL]??=new Map;const definitionSourceRegistry=registryContainer[REGISTRY_SYMBOL];function stampDefinitionKey(e,t){Object.defineProperty(e,DEFINITION_KEY,{configurable:!0,value:t})}function registerDefinitionSource(e,t){let n=definitionSourceRegistry.get(e);if(n!==void 0&&!sameDefinitionSourceEntry(n,t)){n.kind!==`ambiguous`&&console.warn([`eve could not assign a unique toolResultFrom identity for ${JSON.stringify(e)}.`,`Conflicting definitions: ${formatDefinitionSourceForWarning(n)} and ${formatDefinitionSourceForWarning(t)}.`,`Multiple authored definitions share that fallback identity, so toolResultFrom will not match through it.`,`Use the original definition object loaded by eve so source-derived identity can be used instead.`].join(` `)),definitionSourceRegistry.set(e,{kind:`ambiguous`});return}definitionSourceRegistry.set(e,t)}function readDefinitionSource(e){let t=readDefinitionKey(e);return t===void 0?void 0:definitionSourceRegistry.get(t)}function readDefinitionKey(e){if(DEFINITION_KEY in e)return e[DEFINITION_KEY]}function sameDefinitionSourceEntry(e,t){return e.kind===t.kind&&e.name===t.name}function formatDefinitionSourceForWarning(e){return e.logicalPath===void 0?`${e.kind} "${e.name}"`:`${e.kind} "${e.name}" from "${e.logicalPath}"`}export{readDefinitionSource,registerDefinitionSource,stampDefinitionKey};