


























@@ -9,6 +9,7 @@ import path from "node:path";
99import { uniqueStrings } from "@openclaw/normalization-core/string-normalization";
1010import { sanitizeTerminalText } from "../../packages/terminal-core/src/safe-text.js";
1111import { resolveBundledInstallPlanForCatalogEntry } from "../cli/plugin-install-plan.js";
12+import { invalidatePluginRuntimeDiscoveryAfterConfigMutation } from "../cli/plugins-registry-refresh.js";
1213import { assertConfigWriteAllowedInCurrentMode } from "../config/nix-mode-write-guard.js";
1314import type { OpenClawConfig } from "../config/types.openclaw.js";
1415import { parseClawHubPluginSpec } from "../infra/clawhub-spec.js";
@@ -40,12 +41,14 @@ import {
4041installPluginFromNpmPackArchive,
4142type InstallPluginResult,
4243} from "../plugins/install.js";
44+import { clearLoadInstalledPluginIndexInstallRecordsCache } from "../plugins/installed-plugin-index-records.js";
4345import {
4446buildNpmResolutionInstallFields,
4547recordPluginInstall,
4648resolveNpmInstallRecordSpec,
4749} from "../plugins/installs.js";
4850import type { PluginPackageInstall } from "../plugins/manifest.js";
51+import { clearPluginMetadataLifecycleCaches } from "../plugins/plugin-metadata-lifecycle.js";
4952import type { RuntimeEnv } from "../runtime.js";
5053import { withTimeout } from "../utils/with-timeout.js";
5154import { VERSION } from "../version.js";
@@ -79,6 +82,22 @@ type OnboardingPluginInstallResult = {
7982status: OnboardingPluginInstallStatus;
8083};
818485+async function markOnboardingPluginInstalled(
86+result: OnboardingPluginInstallResult & { installed: true },
87+params: {
88+runtime: RuntimeEnv;
89+},
90+): Promise<OnboardingPluginInstallResult & { installed: true }> {
91+// Onboarding has not committed config yet, so invalidate only process-local
92+// discovery. The next lookup recovers the new package alongside persisted records.
93+clearLoadInstalledPluginIndexInstallRecordsCache();
94+clearPluginMetadataLifecycleCaches();
95+await invalidatePluginRuntimeDiscoveryAfterConfigMutation({
96+logger: { warn: (message) => params.runtime.log(message) },
97+});
98+return result;
99+}
100+82101function shouldFallbackClawHubToNpm(params: {
83102result: { ok: false; code?: string };
84103npmSpec?: string;
@@ -915,12 +934,15 @@ async function installPluginFromOverride(params: {
915934 ...(result.version ? { version: result.version } : {}),
916935 ...buildNpmResolutionInstallFields(result.npmResolution),
917936} as const);
918-return {
919-cfg: recordPluginInstall(enableResult.config, install),
920-installed: true,
921-pluginId: result.pluginId,
922-status: "installed",
923-};
937+return await markOnboardingPluginInstalled(
938+{
939+cfg: recordPluginInstall(enableResult.config, install),
940+installed: true,
941+pluginId: result.pluginId,
942+status: "installed",
943+},
944+{ runtime: params.runtime },
945+);
924946}
925947926948async function installPluginFromClawHubSpecWithProgress(params: {
@@ -1104,21 +1126,27 @@ export async function ensureOnboardingPluginInstalled(params: {
11041126};
11051127}
11061128if (pathsReferToSameDirectory(localPath, bundledLocalPath)) {
1107-return {
1108-cfg: enableResult.config,
1109-installed: true,
1110-pluginId: entry.pluginId,
1111-status: "installed",
1112-};
1129+return await markOnboardingPluginInstalled(
1130+{
1131+cfg: enableResult.config,
1132+installed: true,
1133+pluginId: entry.pluginId,
1134+status: "installed",
1135+},
1136+{ runtime },
1137+);
11131138}
11141139next = addPluginLoadPath(enableResult.config, localPath);
11151140next = await recordLocalPluginInstall({ cfg: next, entry, localPath, npmSpec, workspaceDir });
1116-return {
1117-cfg: next,
1118-installed: true,
1119-pluginId: entry.pluginId,
1120-status: "installed",
1121-};
1141+return await markOnboardingPluginInstalled(
1142+{
1143+cfg: next,
1144+installed: true,
1145+pluginId: entry.pluginId,
1146+status: "installed",
1147+},
1148+{ runtime },
1149+);
11221150}
1123115111241152let shouldTryNpm = choice === "npm";
@@ -1171,12 +1199,15 @@ export async function ensureOnboardingPluginInstalled(params: {
11711199spec: clawhubSpecs?.recordSpec ?? clawhubInstallSpec,
11721200installPath: result.targetDir,
11731201});
1174-return {
1175-cfg: next,
1176-installed: true,
1177-pluginId: result.pluginId,
1178-status: "installed",
1179-};
1202+return await markOnboardingPluginInstalled(
1203+{
1204+cfg: next,
1205+installed: true,
1206+pluginId: result.pluginId,
1207+status: "installed",
1208+},
1209+{ runtime },
1210+);
11801211}
1181121211821213await prompter.note(
@@ -1293,12 +1324,15 @@ export async function ensureOnboardingPluginInstalled(params: {
12931324 ...buildNpmResolutionInstallFields(result.npmResolution),
12941325} as const;
12951326next = recordPluginInstall(next, install);
1296-return {
1297-cfg: next,
1298-installed: true,
1299-pluginId: result.pluginId,
1300-status: "installed",
1301-};
1327+return await markOnboardingPluginInstalled(
1328+{
1329+cfg: next,
1330+installed: true,
1331+pluginId: result.pluginId,
1332+status: "installed",
1333+},
1334+{ runtime },
1335+);
13021336}
1303133713041338await prompter.note(
@@ -1338,21 +1372,27 @@ export async function ensureOnboardingPluginInstalled(params: {
13381372};
13391373}
13401374if (pathsReferToSameDirectory(localPath, bundledLocalPath)) {
1341-return {
1342-cfg: enableResult.config,
1343-installed: true,
1344-pluginId: entry.pluginId,
1345-status: "installed",
1346-};
1375+return await markOnboardingPluginInstalled(
1376+{
1377+cfg: enableResult.config,
1378+installed: true,
1379+pluginId: entry.pluginId,
1380+status: "installed",
1381+},
1382+{ runtime },
1383+);
13471384}
13481385next = addPluginLoadPath(enableResult.config, localPath);
13491386next = await recordLocalPluginInstall({ cfg: next, entry, localPath, npmSpec, workspaceDir });
1350-return {
1351-cfg: next,
1352-installed: true,
1353-pluginId: entry.pluginId,
1354-status: "installed",
1355-};
1387+return await markOnboardingPluginInstalled(
1388+{
1389+cfg: next,
1390+installed: true,
1391+pluginId: entry.pluginId,
1392+status: "installed",
1393+},
1394+{ runtime },
1395+);
13561396}
13571397}
13581398此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。