openclaw/scripts/lib/managed-memory-entrypoint.mts
Vincent Koc b9cd492ac6
fix(tooling): enforce Linux process-tree memory limits (#160024)
Add opt-in aggregate Linux process-tree memory containment to the managed tooling runner. Own the invocation-specific scope through verified cleanup before releasing its resource claim; preserve uncapped caller behavior.

Validated real-kernel OOM, descendant cleanup, signals, cancellation and packaged launcher behavior; focused lifecycle/preload tests and exact-head CI/security gates passed. Related: #160010.
2026-09-28 11:58:07 +08:00

21 lines
788 B
TypeScript

import { extname } from "node:path";
import { fileURLToPath } from "node:url";
export const managedMemoryEntrypoint = {
currentModuleUrl: import.meta.url,
sourceWorkerName: "managed-memory-launcher",
sourceExtension: ".mts",
distWorkerPath: "tooling/managed-memory-launcher.js",
} as const;
/** Resolve the standalone launcher in source checkouts and packaged tooling. */
export function resolveManagedMemoryEntrypointUrl(): URL {
const current = new URL(import.meta.url);
const distIndex = current.pathname.lastIndexOf("/dist/");
return distIndex < 0
? new URL(`./managed-memory-launcher${extname(fileURLToPath(current))}`, current)
: new URL(
current.pathname.slice(0, distIndex + 6) + managedMemoryEntrypoint.distWorkerPath,
current,
);
}