eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 732 B
JavaScript
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(e,t){if(!isAbsolute(e))return e;let n=relative(t,e);return n===``?RUNTIME_ROOT_TOKEN:n===`..`||n.startsWith(`..${sep}`)||isAbsolute(n)?e:`${RUNTIME_ROOT_TOKEN}/${n.split(sep).join(`/`)}`}export{serializeCompiledManifestForFingerprint};