Skip to content

Commit d62cc59

Browse files
committed
fix: reuse startup metadata for auto enable
1 parent 9de2bc6 commit d62cc59

3 files changed

Lines changed: 67 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Docs: https://docs.openclaw.ai
3333

3434
- Gateway/device tokens: stop echoing rotated bearer tokens from shared/admin `device.token.rotate` responses while preserving the same-device token handoff needed by token-only clients before reconnect. (#66773) Thanks @MoerAI.
3535
- Control UI/Talk: keep Google Live browser sessions on the WebSocket transport instead of falling back to WebRTC, validate browser Google Live WebSocket endpoints, cap Gateway relay sessions per browser connection, and remove stale browser-native voice buttons that did not use the configured Talk/TTS provider. Thanks @BunsDev.
36+
- Gateway/startup: reuse config snapshot plugin manifests for startup auto-enable before plugin bootstrap plans plugin loading. Thanks @shakkernerd.
3637
- Agents/subagents: enforce `subagents.allowAgents` for explicit same-agent `sessions_spawn(agentId=...)` calls instead of auto-allowing requester self-targets. Fixes #72827. Thanks @oiGaDio.
3738
- ACP/sessions_spawn: let explicit `sessions_spawn(runtime="acp")` bootstrap turns run while `acp.dispatch.enabled=false` still blocks automatic ACP thread dispatch. Fixes #63591. Thanks @moeedahmed.
3839
- CLI/update: install npm global updates into a verified temporary prefix before swapping the package tree into place, preventing mixed old/new installs and stale packaged files from breaking `openclaw update` verification. Thanks @shakkernerd.

src/gateway/server-startup-config.recovery.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
11
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
22
import type { ConfigFileSnapshot, OpenClawConfig } from "../config/types.js";
3+
import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";
34
import { buildTestConfigSnapshot } from "./test-helpers.config-snapshots.js";
45

6+
const applyPluginAutoEnable = vi.hoisted(() =>
7+
vi.fn((params: { config: OpenClawConfig }) => ({
8+
config: params.config,
9+
changes: [] as string[],
10+
autoEnabledReasons: {} as Record<string, string[]>,
11+
})),
12+
);
13+
const pluginManifestRegistry = vi.hoisted(() => ({ plugins: [], diagnostics: [] }));
14+
const pluginMetadataSnapshot = vi.hoisted(
15+
(): PluginMetadataSnapshot => ({
16+
index: {
17+
version: 1,
18+
hostContractVersion: "test",
19+
compatRegistryVersion: "test",
20+
migrationVersion: 1,
21+
policyHash: "policy",
22+
generatedAtMs: 0,
23+
installRecords: {},
24+
plugins: [],
25+
diagnostics: [],
26+
},
27+
registryDiagnostics: [],
28+
manifestRegistry: pluginManifestRegistry,
29+
plugins: [],
30+
diagnostics: [],
31+
byPluginId: new Map(),
32+
normalizePluginId: (pluginId) => pluginId,
33+
owners: {
34+
channels: new Map(),
35+
channelConfigs: new Map(),
36+
providers: new Map(),
37+
modelCatalogProviders: new Map(),
38+
cliBackends: new Map(),
39+
setupProviders: new Map(),
40+
commandAliases: new Map(),
41+
contracts: new Map(),
42+
},
43+
metrics: {
44+
registrySnapshotMs: 0,
45+
manifestRegistryMs: 0,
46+
ownerMapsMs: 0,
47+
totalMs: 0,
48+
indexPluginCount: 0,
49+
manifestPluginCount: 0,
50+
},
51+
}),
52+
);
53+
554
vi.mock("../config/config.js", () => ({
655
applyConfigOverrides: vi.fn((config: OpenClawConfig) => config),
756
isNixMode: false,
@@ -33,6 +82,10 @@ vi.mock("../config/config.js", () => ({
3382
writeConfigFile: vi.fn(),
3483
}));
3584

85+
vi.mock("../config/plugin-auto-enable.js", () => ({
86+
applyPluginAutoEnable: (params: { config: OpenClawConfig }) => applyPluginAutoEnable(params),
87+
}));
88+
3689
vi.mock("./config-recovery-notice.js", () => ({
3790
enqueueConfigRecoveryNotice: vi.fn(),
3891
}));
@@ -118,6 +171,7 @@ describe("gateway startup config recovery", () => {
118171
resolved: sourceConfig,
119172
runtimeConfig,
120173
config: runtimeConfig,
174+
pluginMetadataSnapshot,
121175
} satisfies ConfigFileSnapshot;
122176
vi.mocked(configIo.readConfigFileSnapshot).mockResolvedValueOnce(snapshot);
123177
const log = { info: vi.fn(), warn: vi.fn() };
@@ -133,6 +187,11 @@ describe("gateway startup config recovery", () => {
133187
});
134188

135189
expect(configIo.readConfigFileSnapshot).toHaveBeenCalledTimes(1);
190+
expect(applyPluginAutoEnable).toHaveBeenCalledWith({
191+
config: sourceConfig,
192+
env: process.env,
193+
manifestRegistry: pluginManifestRegistry,
194+
});
136195
expect(configIo.replaceConfigFile).not.toHaveBeenCalled();
137196
expect(log.info).not.toHaveBeenCalled();
138197
});

src/gateway/server-startup-config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,13 @@ export async function loadGatewayStartupConfigSnapshot(params: {
271271
params.minimalTestGateway || degradedStartupConfig || degradedPluginConfig
272272
? { config: configSnapshot.config, changes: [] as string[] }
273273
: await measure("config.snapshot.auto-enable", () =>
274-
applyPluginAutoEnable({ config: configSnapshot.sourceConfig, env: process.env }),
274+
applyPluginAutoEnable({
275+
config: configSnapshot.sourceConfig,
276+
env: process.env,
277+
...(configSnapshot.pluginMetadataSnapshot?.manifestRegistry
278+
? { manifestRegistry: configSnapshot.pluginMetadataSnapshot.manifestRegistry }
279+
: {}),
280+
}),
275281
);
276282
if (autoEnable.changes.length === 0) {
277283
return {

0 commit comments

Comments
 (0)