UNPKG

eve

Version:

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

1 lines 732 B
import{isAbsolute,relative,sep}from"node:path";const RUNTIME_ROOT_TOKEN=`$runtime`;function serializeCompiledManifestForFingerprint(e){return JSON.stringify(normalizeValue(e.manifest,e.runtimeAppRoot))}function normalizeValue(e,t){return typeof e==`string`?normalizeRuntimePath(e,t):Array.isArray(e)?e.map(e=>normalizeValue(e,t)):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>[e,normalizeValue(n,t)]))}function normalizeRuntimePath(r,i){if(!isAbsolute(r))return r;let a=relative(i,r);return a===``?RUNTIME_ROOT_TOKEN:a===`..`||a.startsWith(`..${sep}`)||isAbsolute(a)?r:`${RUNTIME_ROOT_TOKEN}/${a.split(sep).join(`/`)}`}export{serializeCompiledManifestForFingerprint};