Files
openclaw/extensions/openshell/index.ts
Peter Steinberger 430d2caa56 fix(sandbox): retire plugin backends with registry lifecycle (#130662)
* fix(openshell): unregister sandbox backend on plugin stop

Bind the explicit backend disposer to the plugin service lifetime so disabling or reloading OpenShell retires its factory, manager, and workdir hooks together. Preserve the core registry's stale and repeated disposer semantics.

* fix(sandbox): retire plugin backends with registry lifecycle
2026-08-27 12:54:25 -07:00

43 lines
1.5 KiB
TypeScript

// Openshell plugin entrypoint registers its OpenClaw integration.
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
import { registerSandboxBackend } from "openclaw/plugin-sdk/sandbox";
import {
createOpenShellSandboxBackendFactory,
createOpenShellSandboxBackendManager,
} from "./src/backend.js";
import { createOpenShellPluginConfigSchema, resolveOpenShellPluginConfig } from "./src/config.js";
export default definePluginEntry({
id: "openshell",
name: "OpenShell Sandbox",
description: "OpenShell-backed sandbox runtime for agent exec and file tools.",
configSchema: createOpenShellPluginConfigSchema(),
register(api) {
if (api.registrationMode !== "full") {
return;
}
const pluginConfig = resolveOpenShellPluginConfig(api.pluginConfig);
const unregister = registerSandboxBackend("openshell", {
factory: createOpenShellSandboxBackendFactory({
pluginConfig,
}),
manager: createOpenShellSandboxBackendManager({
pluginConfig,
}),
resolveWorkdir: () => pluginConfig.remoteWorkspaceDir,
});
// Eager CLI registrations must retire even if Gateway services never start.
api.lifecycle.registerRuntimeLifecycle({
id: "openshell-sandbox-cleanup",
cleanup: ({ reason, sessionKey, runId }) => {
if (sessionKey !== undefined || runId !== undefined) {
return;
}
if (reason === "disable" || reason === "restart") {
unregister();
}
},
});
},
});