mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 11:31:18 +00:00
* 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>
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import type { OpenClawPluginApi, OpenClawPluginService } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { registerSandboxBackend } from "openclaw/plugin-sdk/sandbox";
|
|
import { resolveMxcBinaryPath } from "./binary-resolver.js";
|
|
import { resolveConfig } from "./config.js";
|
|
import { createMxcSandboxBackendFactory } from "./mxc-backend-factory.js";
|
|
import { mxcSandboxBackendManager } from "./mxc-backend.js";
|
|
import { assertMxcReadiness, warnMxcHostPrepIfNeeded } from "./readiness.js";
|
|
|
|
export function registerMxcPlugin(api: OpenClawPluginApi): void {
|
|
if (api.registrationMode !== "full") {
|
|
return;
|
|
}
|
|
|
|
const config = resolveConfig(api.pluginConfig);
|
|
|
|
if (process.platform !== "win32") {
|
|
console.warn(
|
|
`[mxc] Sandbox backend is Windows-only and not available on ${process.platform}. Plugin will be dormant.`,
|
|
);
|
|
return;
|
|
}
|
|
|
|
// IsoEnvBroker availability is the ProcessContainer readiness signal for this plugin.
|
|
// Binary and host readiness checks fail load with actionable remediation.
|
|
try {
|
|
resolveMxcBinaryPath(config.mxcBinaryPath);
|
|
} catch (err) {
|
|
const reason = err instanceof Error ? err.message : String(err);
|
|
throw new Error(
|
|
`[mxc] MXC sandbox backend cannot load: ${reason}. Install @microsoft/mxc-sdk or set mxcBinaryPath.`,
|
|
{ cause: err },
|
|
);
|
|
}
|
|
assertMxcReadiness();
|
|
|
|
// Advisory: warn (don't block) when the system drive lacks AppContainer
|
|
// directory-access ACEs, which only degrades in-sandbox directory listing.
|
|
warnMxcHostPrepIfNeeded();
|
|
|
|
// Register the backend
|
|
const unregister = registerSandboxBackend("mxc", {
|
|
factory: createMxcSandboxBackendFactory(config),
|
|
manager: mxcSandboxBackendManager,
|
|
});
|
|
|
|
// Cleanup service unregisters backend on shutdown.
|
|
const cleanupService: OpenClawPluginService = {
|
|
id: "mxc-sandbox-cleanup",
|
|
start() {
|
|
/* no-op */
|
|
},
|
|
stop() {
|
|
unregister();
|
|
},
|
|
};
|
|
api.registerService(cleanupService);
|
|
}
|