mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
fix: tolerate sparse plugin metadata snapshots
This commit is contained in:
@@ -112,6 +112,10 @@ export function createModelListAuthIndex(
|
||||
addProvider(provider);
|
||||
}
|
||||
}
|
||||
const primaryModelProvider = params.cfg.agents?.defaults?.model?.primary?.split("/", 1)[0];
|
||||
if (primaryModelProvider === "openai-codex" || primaryModelProvider === "codex") {
|
||||
addSyntheticProvider("codex");
|
||||
}
|
||||
|
||||
for (const provider of params.syntheticAuthProviderRefs ??
|
||||
listValidatedSyntheticAuthProviderRefs({
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
loadPluginManifestRegistryForInstalledIndex,
|
||||
resolveInstalledManifestRegistryIndexFingerprint,
|
||||
} from "./manifest-registry-installed.js";
|
||||
import type { PluginManifestRecord } from "./manifest-registry.js";
|
||||
import { loadPluginManifestRegistry, type PluginManifestRecord } from "./manifest-registry.js";
|
||||
import { resolvePluginControlPlaneFingerprint } from "./plugin-control-plane-context.js";
|
||||
import type {
|
||||
LoadPluginMetadataSnapshotParams,
|
||||
@@ -47,6 +47,22 @@ function indexesMatch(
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeInstalledPluginIndex(index: InstalledPluginIndex): InstalledPluginIndex {
|
||||
return {
|
||||
version: index.version ?? 1,
|
||||
hostContractVersion: index.hostContractVersion ?? "",
|
||||
compatRegistryVersion: index.compatRegistryVersion ?? "",
|
||||
migrationVersion: index.migrationVersion ?? 1,
|
||||
policyHash: index.policyHash ?? "",
|
||||
generatedAtMs: index.generatedAtMs ?? 0,
|
||||
installRecords: index.installRecords ?? {},
|
||||
plugins: index.plugins ?? [],
|
||||
diagnostics: index.diagnostics ?? [],
|
||||
...(index.warning ? { warning: index.warning } : {}),
|
||||
...(index.refreshReason ? { refreshReason: index.refreshReason } : {}),
|
||||
} as InstalledPluginIndex;
|
||||
}
|
||||
|
||||
export function isPluginMetadataSnapshotCompatible(params: {
|
||||
snapshot: Pick<
|
||||
PluginMetadataSnapshot,
|
||||
@@ -184,17 +200,30 @@ function loadPluginMetadataSnapshotImpl(
|
||||
env: params.env,
|
||||
...(params.preferPersisted !== undefined ? { preferPersisted: params.preferPersisted } : {}),
|
||||
...(params.index ? { index: params.index } : {}),
|
||||
});
|
||||
}) ?? {
|
||||
source: "derived" as const,
|
||||
snapshot: { plugins: [] },
|
||||
diagnostics: [],
|
||||
};
|
||||
const registrySnapshotMs = performance.now() - registryStartedAt;
|
||||
const index = registryResult.snapshot;
|
||||
const index = normalizeInstalledPluginIndex(registryResult.snapshot);
|
||||
const manifestStartedAt = performance.now();
|
||||
const manifestRegistry = loadPluginManifestRegistryForInstalledIndex({
|
||||
index,
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
includeDisabled: true,
|
||||
});
|
||||
const manifestRegistry =
|
||||
index.plugins.length === 0
|
||||
? loadPluginManifestRegistry({
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
diagnostics: index.diagnostics,
|
||||
installRecords: index.installRecords,
|
||||
})
|
||||
: loadPluginManifestRegistryForInstalledIndex({
|
||||
index,
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
includeDisabled: true,
|
||||
});
|
||||
const manifestRegistryMs = performance.now() - manifestStartedAt;
|
||||
const normalizePluginId = createPluginRegistryIdNormalizer(index, { manifestRegistry });
|
||||
const byPluginId = new Map(manifestRegistry.plugins.map((plugin) => [plugin.id, plugin]));
|
||||
|
||||
@@ -39,6 +39,9 @@ export function createPluginRegistryIdNormalizer(
|
||||
): (pluginId: string) => string {
|
||||
const aliases = new Map<string, string>();
|
||||
for (const plugin of index.plugins) {
|
||||
if (!plugin.pluginId) {
|
||||
continue;
|
||||
}
|
||||
const pluginId = normalizePluginRegistryAlias(plugin.pluginId);
|
||||
if (pluginId) {
|
||||
aliases.set(normalizePluginRegistryAliasKey(pluginId), plugin.pluginId);
|
||||
|
||||
@@ -163,7 +163,10 @@ function resolveManifestProviderAuthEvidence(
|
||||
});
|
||||
const evidenceByProvider: Record<string, ProviderAuthEvidence[]> = {};
|
||||
for (const plugin of snapshot.plugins) {
|
||||
if (!isInstalledPluginEnabled(snapshot.index, plugin.id, params?.config)) {
|
||||
if (
|
||||
snapshot.index.plugins.length > 0 &&
|
||||
!isInstalledPluginEnabled(snapshot.index, plugin.id, params?.config)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!shouldUsePluginProviderAuthEvidence(plugin, params)) {
|
||||
|
||||
Reference in New Issue
Block a user