mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:30:43 +00:00
refactor: share trusted catalog fallback listing
This commit is contained in:
@@ -53,11 +53,14 @@ export function getTrustedChannelPluginCatalogEntry(
|
||||
});
|
||||
}
|
||||
|
||||
export function listTrustedChannelPluginCatalogEntries(params: {
|
||||
cfg: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): ChannelPluginCatalogEntry[] {
|
||||
function listChannelPluginCatalogEntriesWithTrustedFallback(
|
||||
params: {
|
||||
cfg: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
},
|
||||
onMissingFallback: (entry: ChannelPluginCatalogEntry) => ChannelPluginCatalogEntry[],
|
||||
): ChannelPluginCatalogEntry[] {
|
||||
const unfiltered = listChannelPluginCatalogEntries({
|
||||
workspaceDir: params.workspaceDir,
|
||||
});
|
||||
@@ -72,29 +75,22 @@ export function listTrustedChannelPluginCatalogEntries(params: {
|
||||
return [entry];
|
||||
}
|
||||
const fallback = fallbackById.get(entry.id);
|
||||
return fallback ? [fallback] : [];
|
||||
return fallback ? [fallback] : onMissingFallback(entry);
|
||||
});
|
||||
}
|
||||
|
||||
export function listTrustedChannelPluginCatalogEntries(params: {
|
||||
cfg: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): ChannelPluginCatalogEntry[] {
|
||||
return listChannelPluginCatalogEntriesWithTrustedFallback(params, () => []);
|
||||
}
|
||||
|
||||
export function listSetupDiscoveryChannelPluginCatalogEntries(params: {
|
||||
cfg: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): ChannelPluginCatalogEntry[] {
|
||||
const unfiltered = listChannelPluginCatalogEntries({
|
||||
workspaceDir: params.workspaceDir,
|
||||
});
|
||||
const fallbackById = new Map(
|
||||
listChannelPluginCatalogEntries({
|
||||
workspaceDir: params.workspaceDir,
|
||||
excludeWorkspace: true,
|
||||
}).map((entry) => [entry.id, entry]),
|
||||
);
|
||||
return unfiltered.flatMap((entry) => {
|
||||
if (isTrustedWorkspaceChannelCatalogEntry(entry, params.cfg, params.env)) {
|
||||
return [entry];
|
||||
}
|
||||
const fallback = fallbackById.get(entry.id);
|
||||
return fallback ? [fallback] : [entry];
|
||||
});
|
||||
return listChannelPluginCatalogEntriesWithTrustedFallback(params, (entry) => [entry]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user