Files
openclaw/scripts/lib/plugin-npm-runtime-assets.mjs
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

40 lines
1.6 KiB
JavaScript

// Builds and validates static assets needed by package-local plugin runtime output.
import { spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { discoverStaticExtensionAssets } from "./static-extension-assets.mjs";
function resolvePackageAssetBuildCommand(packageJson) {
const command = packageJson.openclaw?.assetScripts?.build;
return typeof command === "string" && command.trim() ? command.trim() : null;
}
/** Run a package-local static asset build command when the plugin declares one. */
export function runPackageAssetBuild(plan) {
const command = resolvePackageAssetBuildCommand(plan.packageJson);
if (!command) {
return null;
}
console.error(`[plugin-npm-runtime-build] build assets ${plan.pluginDir}: ${command}`);
const result = spawnSync(command, {
cwd: plan.packageDir,
env: process.env,
shell: true,
stdio: "inherit",
});
if (result.status !== 0) {
throw new Error(`${plan.pluginDir} asset build failed: ${command}`);
}
return command;
}
/** List static asset source paths referenced by a package but missing from disk. */
export function listMissingPackageStaticAssetSources(plan) {
const packagePrefix = `extensions/${plan.pluginDir}/`;
return discoverStaticExtensionAssets({ rootDir: plan.repoRoot, includeExternalPlugins: true })
.filter((asset) => asset.src.replaceAll("\\", "/").startsWith(packagePrefix))
.map((asset) => asset.src)
.filter((src) => !fs.existsSync(path.join(plan.repoRoot, src)))
.toSorted((left, right) => left.localeCompare(right));
}