Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
548 B
Raw Blame
import * as fs from "node:fs/promises";
import * as nodePath from "node:path";

const SOUL_BASE_PATH = "/etc/workflow/souls";

export async function loadSoul(storageRef: string): Promise<string> {
  if (storageRef.includes("..") || storageRef.includes("\0")) {
    throw new Error(`Invalid soul reference: ${storageRef}`);
  }
  const resolved = nodePath.resolve(SOUL_BASE_PATH, storageRef);
  if (!resolved.startsWith(SOUL_BASE_PATH + "/")) {
    throw new Error(`Soul path escapes base directory`);
  }
  return fs.readFile(resolved, "utf-8");
}