


















@@ -5,10 +5,9 @@ import { moveSingleAccountChannelSectionToDefaultAccount } from "../../channels/
55import type { ChannelSetupPlugin } from "../../channels/plugins/setup-wizard-types.js";
66import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js";
77import type { ChannelId, ChannelSetupInput } from "../../channels/plugins/types.public.js";
8-import { commitPluginInstallRecordsWithConfig } from "../../cli/plugins-install-record-commit.js";
8+import { commitConfigWithPendingPluginInstalls } from "../../cli/plugins-install-record-commit.js";
99import { refreshPluginRegistryAfterConfigMutation } from "../../cli/plugins-registry-refresh.js";
10-import { replaceConfigFile, type OpenClawConfig } from "../../config/config.js";
11-import { withoutPluginInstallRecords } from "../../plugins/installed-plugin-index-records.js";
10+import type { OpenClawConfig } from "../../config/config.js";
1211import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js";
1312import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
1413import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js";
@@ -241,29 +240,16 @@ export async function channelsAddCommand(
241240}
242241}
243242244-const shouldMovePluginInstalls = Boolean(
245-nextConfig.plugins?.installs && Object.keys(nextConfig.plugins.installs).length > 0,
246-);
247-const writtenConfig = shouldMovePluginInstalls
248- ? withoutPluginInstallRecords(nextConfig)
249- : nextConfig;
250-if (shouldMovePluginInstalls) {
251-await commitPluginInstallRecordsWithConfig({
252-nextInstallRecords: nextConfig.plugins?.installs ?? {},
253-nextConfig: writtenConfig,
254- ...(baseHash !== undefined ? { baseHash } : {}),
255-});
256-} else {
257-await replaceConfigFile({
258-nextConfig: writtenConfig,
259- ...(baseHash !== undefined ? { baseHash } : {}),
260-});
261-}
262-if (shouldMovePluginInstalls) {
243+const committed = await commitConfigWithPendingPluginInstalls({
244+ nextConfig,
245+ ...(baseHash !== undefined ? { baseHash } : {}),
246+});
247+const writtenConfig = committed.config;
248+if (committed.movedInstallRecords) {
263249await refreshPluginRegistryAfterConfigMutation({
264250config: writtenConfig,
265251reason: "source-changed",
266-installRecords: nextConfig.plugins?.installs ?? {},
252+installRecords: committed.installRecords,
267253logger: { warn: (message) => runtime.log(message) },
268254});
269255}
@@ -395,29 +381,16 @@ export async function channelsAddCommand(
395381 runtime,
396382});
397383398-const shouldMovePluginInstalls = Boolean(
399-nextConfig.plugins?.installs && Object.keys(nextConfig.plugins.installs).length > 0,
400-);
401-const writtenConfig = shouldMovePluginInstalls
402- ? withoutPluginInstallRecords(nextConfig)
403- : nextConfig;
404-if (shouldMovePluginInstalls) {
405-await commitPluginInstallRecordsWithConfig({
406-nextInstallRecords: nextConfig.plugins?.installs ?? {},
407-nextConfig: writtenConfig,
408- ...(baseHash !== undefined ? { baseHash } : {}),
409-});
410-} else {
411-await replaceConfigFile({
412-nextConfig: writtenConfig,
413- ...(baseHash !== undefined ? { baseHash } : {}),
414-});
415-}
416-if (shouldMovePluginInstalls || pluginRegistrySourceChanged) {
384+const committed = await commitConfigWithPendingPluginInstalls({
385+ nextConfig,
386+ ...(baseHash !== undefined ? { baseHash } : {}),
387+});
388+const writtenConfig = committed.config;
389+if (committed.movedInstallRecords || pluginRegistrySourceChanged) {
417390await refreshPluginRegistryAfterConfigMutation({
418391config: writtenConfig,
419392reason: "source-changed",
420- ...(shouldMovePluginInstalls ? { installRecords: nextConfig.plugins?.installs ?? {} } : {}),
393+ ...(committed.movedInstallRecords ? { installRecords: committed.installRecords } : {}),
421394logger: { warn: (message) => runtime.log(message) },
422395});
423396}
@@ -440,7 +413,7 @@ export async function channelsAddCommand(
440413}),
441414},
442415],
443-cfg: nextConfig,
416+cfg: writtenConfig,
444417 runtime,
445418});
446419}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。