mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-04 02:32:07 +01:00
fix(cloud): persist configuration and load release-image packages (#18335)
Land the approved Cloud configuration and release-image package stack.
Includes the separately reviewed adapter settings (#18335), external adapters (#18333), bundled plugins (#18336), startup configuration (#18339), and migration/package checks (#18341).
Includes the final image-owned loader and linked-dependency inventory corrections.
Verified stack head: 462716170d.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
36f4422389
commit
8f822bfcf7
57 files changed
+3670
-250
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export function resolveBundledPluginRuntimeLoader(
|
||||
moduleDirectory = path.dirname(fileURLToPath(import.meta.url)),
|
||||
): string {
|
||||
let directory = fs.realpathSync(moduleDirectory);
|
||||
let imageRoot: string | undefined;
|
||||
for (let depth = 0; depth < 5; depth++) {
|
||||
const metadataPath = path.join(directory, "package.json");
|
||||
const metadata = fs.lstatSync(metadataPath, { throwIfNoEntry: false });
|
||||
if (metadata?.isFile() && metadata.size <= 128 * 1024
|
||||
&& JSON.parse(fs.readFileSync(metadataPath, "utf8")).name === "@paperclipai/server") {
|
||||
imageRoot = path.dirname(directory);
|
||||
break;
|
||||
}
|
||||
const parent = path.dirname(directory);
|
||||
if (parent === directory) break;
|
||||
directory = parent;
|
||||
}
|
||||
if (!imageRoot) throw new Error("Managed plugin server package is missing from the current image");
|
||||
const declared = path.join(imageRoot, "cli/node_modules/tsx/dist/loader.mjs");
|
||||
let loader: string;
|
||||
try {
|
||||
loader = fs.realpathSync(declared);
|
||||
if (!fs.statSync(loader).isFile()) throw new Error("not a file");
|
||||
} catch {
|
||||
throw new Error("Managed plugin runtime loader is missing from the current image");
|
||||
}
|
||||
const roots = [path.join(imageRoot, "cli"), path.join(imageRoot, "node_modules")];
|
||||
if (!roots.some((root) => {
|
||||
const relative = path.relative(root, loader);
|
||||
return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
|
||||
})) throw new Error("Managed plugin runtime loader escapes the current image");
|
||||
return loader;
|
||||
}
|
||||
Reference in new issue
Block a user