Files
PaperClipAI/packages/paperclip-runner/scripts/lib/runner-runtime-dependency-roots.mjs
T
DottaandPaperclip 2cc7992369 Share the external Runner lifecycle and add strict Muse contracts (#16444)
Add the external Runner foundation with distinct Dot/Grok V6, canonical home-mode V7 and Muse V8 contracts.

Keep generated schemas and profiles synchronized. Bound default question-answer command IDs in a disjoint namespace while preserving existing IDs and durable replay. Preserve canonical migration history and add normally generated, replay-safe Muse schema milestones with literal preview-history fixtures.

Refs #16444.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-16 13:46:50 -05:00

24 lines
1.1 KiB
JavaScript

import { readFile, realpath } from "node:fs/promises";
import { resolve } from "node:path";
/** Seed every installed runtime root before traversing its dependency graph. */
export async function collectRunnerRuntimeDependencyRoots(runnerRoot) {
const manifest = JSON.parse(await readFile(resolve(runnerRoot, "package.json"), "utf8"));
const required = manifest.dependencies ?? {};
const optional = manifest.optionalDependencies ?? {};
const roots = [];
for (const dependencyName of Object.keys({ ...required, ...optional }).sort()) {
let packageRoot;
try {
packageRoot = await realpath(resolve(runnerRoot, "node_modules", dependencyName));
} catch (error) {
// Platform-filtered optional packages may be absent. Malformed installed
// roots and required dependencies must still fail the distribution check.
if (!Object.hasOwn(required, dependencyName) && Object.hasOwn(optional, dependencyName) && error?.code === "ENOENT") continue;
throw error;
}
roots.push({ dependencyName, packageRoot });
}
return roots;
}