mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:50:46 +00:00
refactor: expose plugin lookup table normalizer
This commit is contained in:
@@ -98,7 +98,7 @@ describe("loadPluginLookUpTable", () => {
|
||||
createManifestRecord({
|
||||
id: "openai",
|
||||
origin: "bundled",
|
||||
providers: ["openai"],
|
||||
providers: ["openai", "openai-codex"],
|
||||
cliBackends: ["codex-cli"],
|
||||
setup: {
|
||||
providers: [{ id: "openai" }],
|
||||
@@ -128,6 +128,7 @@ describe("loadPluginLookUpTable", () => {
|
||||
|
||||
expect(table.manifestRegistry).toBe(manifestRegistry);
|
||||
expect(table.byPluginId.get("telegram")?.id).toBe("telegram");
|
||||
expect(table.normalizePluginId("openai-codex")).toBe("openai");
|
||||
expect(table.owners.channels.get("telegram")).toEqual(["telegram"]);
|
||||
expect(table.owners.providers.get("openai")).toEqual(["openai"]);
|
||||
expect(table.owners.cliBackends.get("codex-cli")).toEqual(["openai"]);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry
|
||||
import type { PluginManifestRecord, PluginManifestRegistry } from "./manifest-registry.js";
|
||||
import type { PluginDiagnostic } from "./manifest-types.js";
|
||||
import {
|
||||
createPluginRegistryIdNormalizer,
|
||||
loadPluginRegistrySnapshotWithMetadata,
|
||||
type PluginRegistrySnapshot,
|
||||
type PluginRegistrySnapshotDiagnostic,
|
||||
@@ -35,6 +36,7 @@ export type PluginLookUpTable = {
|
||||
plugins: readonly PluginManifestRecord[];
|
||||
diagnostics: readonly PluginDiagnostic[];
|
||||
byPluginId: ReadonlyMap<string, PluginManifestRecord>;
|
||||
normalizePluginId: (pluginId: string) => string;
|
||||
owners: PluginLookUpTableOwnerMaps;
|
||||
startup: PluginLookUpTableStartupPlan;
|
||||
};
|
||||
@@ -122,6 +124,7 @@ export function loadPluginLookUpTable(params: LoadPluginLookUpTableParams): Plug
|
||||
index,
|
||||
manifestRegistry,
|
||||
});
|
||||
const normalizePluginId = createPluginRegistryIdNormalizer(index, { manifestRegistry });
|
||||
const byPluginId = new Map(manifestRegistry.plugins.map((plugin) => [plugin.id, plugin]));
|
||||
const owners = buildOwnerMaps(manifestRegistry.plugins);
|
||||
const startup = {
|
||||
@@ -147,6 +150,7 @@ export function loadPluginLookUpTable(params: LoadPluginLookUpTableParams): Plug
|
||||
plugins: manifestRegistry.plugins,
|
||||
diagnostics: [...index.diagnostics, ...manifestRegistry.diagnostics],
|
||||
byPluginId,
|
||||
normalizePluginId,
|
||||
owners,
|
||||
startup,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user