fix(plugins): keep packed entries consistent through package lifecycle (#121174)

* fix(plugins): own packed entry lifecycles by package

Persist package ownership per runtime child, route lifecycle actions through one closed resolver, reconcile removed child policy during updates, and retain rollback generations until durable config/index commit.

* fix(plugins): break uninstall policy import cycle

* test(plugins): model package ownership in lifecycle fixtures
This commit is contained in:
Peter Steinberger
2026-08-12 00:49:29 -07:00
committed by GitHub
parent 016c5aa772
commit 5a643e3543
60 changed files with 4069 additions and 1102 deletions
+33
View File
@@ -47,6 +47,38 @@ function writePlugin([dir, id, version, method, name]) {
writePluginManifest(path.join(dir, "openclaw.plugin.json"), id);
}
function writePluginPack([dir, id, version, entryList]) {
for (const [value, label] of [
[dir, "dir"],
[id, "id"],
[version, "version"],
]) {
requireArg(value, label);
}
const entries = entryList
? entryList
.split(",")
.map((entry) => entry.trim())
.filter(Boolean)
: ["one", "two"];
if (entries.length === 0) {
throw new Error("plugin-pack entries must not be empty");
}
writeJson(path.join(dir, "package.json"), {
name: `@openclaw/${id}`,
version,
openclaw: { extensions: entries.map((entry) => `./${entry}.js`) },
});
for (const entry of entries) {
const childId = `${id}/${entry}`;
write(
path.join(dir, `${entry}.js`),
`module.exports = { id: ${JSON.stringify(childId)}, name: ${JSON.stringify(childId)}, register(api) { api.registerGatewayMethod(${JSON.stringify(`${id}.${entry}`)}, async () => ({ version: ${JSON.stringify(version)} })); }, };\n`,
);
}
writePluginManifest(path.join(dir, "openclaw.plugin.json"), id);
}
function writePluginWithVendoredDependency([dir, id, version, method, name]) {
writePlugin([dir, id, version, method, name]);
const packageJsonPath = path.join(dir, "package.json");
@@ -162,6 +194,7 @@ function writePluginMarketplace(args) {
export const pluginCommands = {
"plugin-demo": writePluginDemo,
plugin: writePlugin,
"plugin-pack": writePluginPack,
"plugin-vendored-dep": writePluginWithVendoredDependency,
"plugin-cli": writePluginWithCli,
"plugin-cli-registry-dep": writePluginWithCliRegistryDependency,