
























@@ -6,7 +6,7 @@ import {
66type OpenClawConfig,
77applyConfigOverrides,
88isNixMode,
9-readConfigFileSnapshot,
9+readConfigFileSnapshotWithPluginMetadata,
1010recoverConfigFromLastKnownGood,
1111recoverConfigFromJsonRootSuffix,
1212replaceConfigFile,
@@ -18,6 +18,7 @@ import { formatConfigIssueLines } from "../config/issue-format.js";
1818import { asResolvedSourceConfig, materializeRuntimeConfig } from "../config/materialize.js";
1919import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
2020import { isTruthyEnvValue } from "../infra/env.js";
21+import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";
2122import {
2223GATEWAY_AUTH_SURFACE_PATHS,
2324evaluateGatewayAuthSurfaceStates,
@@ -61,6 +62,7 @@ type GatewayStartupConfigMeasure = <T>(name: string, run: () => T | Promise<T>)
6162export type GatewayStartupConfigSnapshotLoadResult = {
6263snapshot: ConfigFileSnapshot;
6364wroteConfig: boolean;
65+pluginMetadataSnapshot?: PluginMetadataSnapshot;
6466degradedProviderApi?: boolean;
6567degradedPluginConfig?: boolean;
6668};
@@ -192,9 +194,11 @@ export async function loadGatewayStartupConfigSnapshot(params: {
192194measure?: GatewayStartupConfigMeasure;
193195}): Promise<GatewayStartupConfigSnapshotLoadResult> {
194196const measure = params.measure ?? (async (_name, run) => await run());
195-let configSnapshot = await measure("config.snapshot.read", () =>
196-readConfigFileSnapshot({ measure }),
197+let snapshotRead = await measure("config.snapshot.read", () =>
198+readConfigFileSnapshotWithPluginMetadata({ measure }),
197199);
200+let configSnapshot = snapshotRead.snapshot;
201+let pluginMetadataSnapshot = snapshotRead.pluginMetadataSnapshot;
198202let wroteConfig = false;
199203let degradedStartupConfig = false;
200204let degradedPluginConfig = false;
@@ -242,9 +246,11 @@ export async function loadGatewayStartupConfigSnapshot(params: {
242246params.log.warn(
243247`gateway: invalid config was restored from last-known-good backup: ${configSnapshot.path}`,
244248);
245-configSnapshot = await measure("config.snapshot.recovery-read", () =>
246-readConfigFileSnapshot({ measure }),
249+snapshotRead = await measure("config.snapshot.recovery-read", () =>
250+readConfigFileSnapshotWithPluginMetadata({ measure }),
247251);
252+configSnapshot = snapshotRead.snapshot;
253+pluginMetadataSnapshot = snapshotRead.pluginMetadataSnapshot;
248254if (configSnapshot.valid) {
249255enqueueConfigRecoveryNotice({
250256cfg: configSnapshot.config,
@@ -259,9 +265,11 @@ export async function loadGatewayStartupConfigSnapshot(params: {
259265params.log.warn(
260266`gateway: invalid config was repaired by stripping a non-JSON prefix: ${configSnapshot.path}`,
261267);
262-configSnapshot = await measure("config.snapshot.prefix-recovery-read", () =>
263-readConfigFileSnapshot({ measure }),
268+snapshotRead = await measure("config.snapshot.prefix-recovery-read", () =>
269+readConfigFileSnapshotWithPluginMetadata({ measure }),
264270);
271+configSnapshot = snapshotRead.snapshot;
272+pluginMetadataSnapshot = snapshotRead.pluginMetadataSnapshot;
265273}
266274}
267275assertValidGatewayStartupConfigSnapshot(configSnapshot, { includeDoctorHint: true });
@@ -274,15 +282,16 @@ export async function loadGatewayStartupConfigSnapshot(params: {
274282applyPluginAutoEnable({
275283config: configSnapshot.sourceConfig,
276284env: process.env,
277- ...(configSnapshot.pluginMetadataSnapshot?.manifestRegistry
278- ? { manifestRegistry: configSnapshot.pluginMetadataSnapshot.manifestRegistry }
285+ ...(pluginMetadataSnapshot?.manifestRegistry
286+ ? { manifestRegistry: pluginMetadataSnapshot.manifestRegistry }
279287 : {}),
280288}),
281289);
282290if (autoEnable.changes.length === 0) {
283291return {
284292snapshot: configSnapshot,
285293 wroteConfig,
294+ ...(pluginMetadataSnapshot ? { pluginMetadataSnapshot } : {}),
286295 ...(degradedStartupConfig ? { degradedProviderApi: true } : {}),
287296 ...(degradedPluginConfig ? { degradedPluginConfig: true } : {}),
288297};
@@ -294,9 +303,11 @@ export async function loadGatewayStartupConfigSnapshot(params: {
294303afterWrite: { mode: "auto" },
295304});
296305wroteConfig = true;
297-configSnapshot = await measure("config.snapshot.auto-enable-read", () =>
298-readConfigFileSnapshot({ measure }),
306+snapshotRead = await measure("config.snapshot.auto-enable-read", () =>
307+readConfigFileSnapshotWithPluginMetadata({ measure }),
299308);
309+configSnapshot = snapshotRead.snapshot;
310+pluginMetadataSnapshot = snapshotRead.pluginMetadataSnapshot;
300311assertValidGatewayStartupConfigSnapshot(configSnapshot);
301312params.log.info(
302313`gateway: auto-enabled plugins:\n${autoEnable.changes.map((entry) => `- ${entry}`).join("\n")}`,
@@ -308,6 +319,7 @@ export async function loadGatewayStartupConfigSnapshot(params: {
308319return {
309320snapshot: configSnapshot,
310321 wroteConfig,
322+ ...(pluginMetadataSnapshot ? { pluginMetadataSnapshot } : {}),
311323 ...(degradedStartupConfig ? { degradedProviderApi: true } : {}),
312324 ...(degradedPluginConfig ? { degradedPluginConfig: true } : {}),
313325};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。