|
|
|
|
@@ -294,22 +294,25 @@ else {
|
|
|
|
|
const delta = rec.delta || { added: {}, replaced: {}, removed: {} };
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// ── Handle ADDED entries: remove them ─────────────────────────────────
|
|
|
|
|
if (delta.added[PATH_PLUGIN_ENTRY] !== undefined) {
|
|
|
|
|
const plugins = getJson("plugins") || {};
|
|
|
|
|
plugins.entries = plugins.entries || {};
|
|
|
|
|
delete plugins.entries.dirigent;
|
|
|
|
|
setJson("plugins", plugins);
|
|
|
|
|
// ── IMPORTANT: Order matters for OpenClaw config validation ────────────
|
|
|
|
|
// 1. First remove from allow (before deleting entry, otherwise validation fails)
|
|
|
|
|
if (delta.added[PATH_PLUGINS_ALLOW] !== undefined) {
|
|
|
|
|
const allowList = getJson(PATH_PLUGINS_ALLOW) || [];
|
|
|
|
|
const idx = allowList.indexOf("dirigent");
|
|
|
|
|
if (idx !== -1) {
|
|
|
|
|
allowList.splice(idx, 1);
|
|
|
|
|
setJson(PATH_PLUGINS_ALLOW, allowList);
|
|
|
|
|
console.log("[dirigent] removed 'dirigent' from plugins.allow");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. Then remove entry
|
|
|
|
|
if (delta.added[PATH_PLUGIN_ENTRY] !== undefined || delta.replaced[PATH_PLUGIN_ENTRY] !== undefined) {
|
|
|
|
|
unsetPath(PATH_PLUGIN_ENTRY);
|
|
|
|
|
console.log("[dirigent] removed plugins.entries.dirigent");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (delta.added[PATH_PROVIDER_ENTRY] !== undefined) {
|
|
|
|
|
const providers = getJson(PATH_PROVIDERS) || {};
|
|
|
|
|
delete providers[NO_REPLY_PROVIDER_ID];
|
|
|
|
|
setJson(PATH_PROVIDERS, providers);
|
|
|
|
|
console.log(`[dirigent] removed models.providers.${NO_REPLY_PROVIDER_ID}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. Then remove plugin path (after entry is gone)
|
|
|
|
|
if (delta.added[PATH_PLUGINS_LOAD] !== undefined) {
|
|
|
|
|
const plugins = getJson("plugins") || {};
|
|
|
|
|
const paths = plugins.load?.paths || [];
|
|
|
|
|
@@ -322,26 +325,15 @@ else {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Handle plugins.allow ──────────────────────────────────────────────
|
|
|
|
|
if (delta.added[PATH_PLUGINS_ALLOW] !== undefined) {
|
|
|
|
|
const allowList = getJson(PATH_PLUGINS_ALLOW) || [];
|
|
|
|
|
const idx = allowList.indexOf("dirigent");
|
|
|
|
|
if (idx !== -1) {
|
|
|
|
|
allowList.splice(idx, 1);
|
|
|
|
|
setJson(PATH_PLUGINS_ALLOW, allowList);
|
|
|
|
|
console.log("[dirigent] removed 'dirigent' from plugins.allow");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Handle REPLACED entries: restore old value ────────────────────────
|
|
|
|
|
if (delta.replaced[PATH_PLUGIN_ENTRY] !== undefined) {
|
|
|
|
|
const plugins = getJson("plugins") || {};
|
|
|
|
|
plugins.entries = plugins.entries || {};
|
|
|
|
|
plugins.entries.dirigent = delta.replaced[PATH_PLUGIN_ENTRY];
|
|
|
|
|
setJson("plugins", plugins);
|
|
|
|
|
console.log("[dirigent] restored previous plugins.entries.dirigent");
|
|
|
|
|
// 4. Finally remove provider
|
|
|
|
|
if (delta.added[PATH_PROVIDER_ENTRY] !== undefined) {
|
|
|
|
|
const providers = getJson(PATH_PROVIDERS) || {};
|
|
|
|
|
delete providers[NO_REPLY_PROVIDER_ID];
|
|
|
|
|
setJson(PATH_PROVIDERS, providers);
|
|
|
|
|
console.log(`[dirigent] removed models.providers.${NO_REPLY_PROVIDER_ID}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Handle REPLACED provider: restore old value ───────────────────────
|
|
|
|
|
if (delta.replaced[PATH_PROVIDER_ENTRY] !== undefined) {
|
|
|
|
|
const providers = getJson(PATH_PROVIDERS) || {};
|
|
|
|
|
providers[NO_REPLY_PROVIDER_ID] = delta.replaced[PATH_PROVIDER_ENTRY];
|
|
|
|
|
|