Files
openclaw/extensions/mxc/src/plugin-root.ts
Paul Campbell 008f04a656 feat(mxc): add Windows MXC sandbox backend (#97086)
* feat(mxc): add Windows MXC sandbox backend

Add the official MXC sandbox plugin package with Windows ProcessContainer execution, plugin-owned MXC SDK dependency packaging, host-backed filesystem bridge support, and configured MXC policy file loading via mxcPolicyPaths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(mxc): preserve Windows binary override paths

* fix: remove stray sandbox barrel export

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9ea19539-b8ca-44fb-93bd-b8496e3deb2c

* fix(mxc): address sandbox review feedback

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(mxc): satisfy test type checks

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(mxc): clarify protected skill enforcement

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* test(mxc): align fail-closed expectations

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(mxc): satisfy extension lint

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(plugin-sdk): narrow fs-safe remove surface

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* fix(mxc): repair rebased CI failures

* fix(scripts): declare shrinkwrap override normalizer

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Gio Della-Libera <235387111+giodl73-repo@users.noreply.github.com>
Co-authored-by: Dallin Romney <dallinromney@gmail.com>
2026-07-12 23:07:25 -07:00

45 lines
1.4 KiB
TypeScript

import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
function isMxcPluginRoot(dir: string): boolean {
return (
fs.existsSync(path.join(dir, "openclaw.plugin.json")) &&
fs.existsSync(path.join(dir, "package.json"))
);
}
function resolveMxcPluginRoot(moduleUrl: string = import.meta.url): string {
let cursor = path.dirname(fileURLToPath(moduleUrl));
for (let i = 0; i < 6; i += 1) {
if (isMxcPluginRoot(cursor)) {
return cursor;
}
const parent = path.dirname(cursor);
if (parent === cursor) {
break;
}
cursor = parent;
}
throw new Error(`[mxc] cannot locate plugin root from ${moduleUrl}`);
}
export function resolveMxcLauncherPath(moduleUrl: string = import.meta.url): string {
const root = resolveMxcPluginRoot(moduleUrl);
const sourceLauncher = path.join(root, "src", "mxc-spawn-launcher.mjs");
const rootDistLauncher = path.join(root, "mxc-spawn-launcher.mjs");
const packageDistLauncher = path.join(root, "dist", "mxc-spawn-launcher.mjs");
if (fs.existsSync(sourceLauncher)) {
return sourceLauncher;
}
if (fs.existsSync(rootDistLauncher)) {
return rootDistLauncher;
}
if (fs.existsSync(packageDistLauncher)) {
return packageDistLauncher;
}
throw new Error(
`[mxc] launcher not found; searched ${sourceLauncher}, ${rootDistLauncher}, and ${packageDistLauncher}`,
);
}