

















@@ -1,4 +1,3 @@
1-import { isDeepStrictEqual } from "node:util";
21import chokidar from "chokidar";
32import { bumpSkillsSnapshotVersion } from "../agents/skills/refresh-state.js";
43import type { ConfigWriteNotification } from "../config/io.js";
@@ -9,38 +8,30 @@ import {
98shouldAttemptLastKnownGoodRecovery,
109} from "../config/recovery-policy.js";
1110import { resolveConfigWriteFollowUp } from "../config/runtime-snapshot.js";
12-import type { GatewayReloadMode } from "../config/types.gateway.js";
1311import type { ConfigFileSnapshot, OpenClawConfig } from "../config/types.openclaw.js";
1412import type { PluginInstallRecord } from "../config/types.plugins.js";
1513import { validateConfigObjectWithPlugins } from "../config/validation.js";
1614import {
1715loadInstalledPluginIndexInstallRecords,
1816loadInstalledPluginIndexInstallRecordsSync,
1917} from "../plugins/installed-plugin-index-records.js";
20-import { isPlainObject } from "../utils.js";
18+import { diffConfigPaths } from "./config-diff.js";
2119import {
2220buildGatewayReloadPlan,
2321listPluginInstallTimestampMetadataPaths,
2422listPluginInstallWholeRecordPaths,
2523type GatewayReloadPlan,
2624} from "./config-reload-plan.js";
25+import { resolveGatewayReloadSettings } from "./config-reload-settings.js";
27262827export {
2928buildGatewayReloadPlan,
29+diffConfigPaths,
3030listPluginInstallTimestampMetadataPaths,
3131listPluginInstallWholeRecordPaths,
32+resolveGatewayReloadSettings,
3233};
3334export type { ChannelKind, GatewayReloadPlan } from "./config-reload-plan.js";
34-35-type GatewayReloadSettings = {
36-mode: GatewayReloadMode;
37-debounceMs: number;
38-};
39-40-const DEFAULT_RELOAD_SETTINGS: GatewayReloadSettings = {
41-mode: "hybrid",
42-debounceMs: 300,
43-};
4435const MISSING_CONFIG_RETRY_DELAY_MS = 150;
4536const MISSING_CONFIG_MAX_RETRIES = 2;
4637@@ -115,51 +106,6 @@ function resolvePluginLocalInvalidReloadSnapshot(params: {
115106};
116107}
117108118-export function diffConfigPaths(prev: unknown, next: unknown, prefix = ""): string[] {
119-if (prev === next) {
120-return [];
121-}
122-if (isPlainObject(prev) && isPlainObject(next)) {
123-const keys = new Set([...Object.keys(prev), ...Object.keys(next)]);
124-const paths: string[] = [];
125-for (const key of keys) {
126-const prevValue = prev[key];
127-const nextValue = next[key];
128-if (prevValue === undefined && nextValue === undefined) {
129-continue;
130-}
131-const childPrefix = prefix ? `${prefix}.${key}` : key;
132-const childPaths = diffConfigPaths(prevValue, nextValue, childPrefix);
133-if (childPaths.length > 0) {
134-paths.push(...childPaths);
135-}
136-}
137-return paths;
138-}
139-if (Array.isArray(prev) && Array.isArray(next)) {
140-// Arrays can contain object entries (for example memory.qmd.paths/scope.rules);
141-// compare structurally so identical values are not reported as changed.
142-if (isDeepStrictEqual(prev, next)) {
143-return [];
144-}
145-}
146-return [prefix || "<root>"];
147-}
148-149-export function resolveGatewayReloadSettings(cfg: OpenClawConfig): GatewayReloadSettings {
150-const rawMode = cfg.gateway?.reload?.mode;
151-const mode =
152-rawMode === "off" || rawMode === "restart" || rawMode === "hot" || rawMode === "hybrid"
153- ? rawMode
154- : DEFAULT_RELOAD_SETTINGS.mode;
155-const debounceRaw = cfg.gateway?.reload?.debounceMs;
156-const debounceMs =
157-typeof debounceRaw === "number" && Number.isFinite(debounceRaw)
158- ? Math.max(0, Math.floor(debounceRaw))
159- : DEFAULT_RELOAD_SETTINGS.debounceMs;
160-return { mode, debounceMs };
161-}
162-163109type GatewayConfigReloader = {
164110stop: () => Promise<void>;
165111};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。