mirror of https://github.com/openclaw/openclaw.git
Plugins: extract provider runtime
This commit is contained in:
parent
96bd348130
commit
19087405d2
|
|
@ -0,0 +1,27 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry.js";
|
||||
import { resolveExtensionHostProviders } from "./provider-runtime.js";
|
||||
|
||||
describe("resolveExtensionHostProviders", () => {
|
||||
it("projects provider registrations into provider plugins with plugin ids", () => {
|
||||
const registry = createEmptyPluginRegistry();
|
||||
registry.providers.push({
|
||||
pluginId: "demo-plugin",
|
||||
source: "bundled",
|
||||
provider: {
|
||||
id: "demo-provider",
|
||||
label: "Demo Provider",
|
||||
auth: [],
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolveExtensionHostProviders({ registry })).toEqual([
|
||||
{
|
||||
id: "demo-provider",
|
||||
label: "Demo Provider",
|
||||
auth: [],
|
||||
pluginId: "demo-plugin",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import type { PluginRegistry } from "../plugins/registry.js";
|
||||
import type { ProviderPlugin } from "../plugins/types.js";
|
||||
|
||||
export function resolveExtensionHostProviders(params: {
|
||||
registry: Pick<PluginRegistry, "providers">;
|
||||
}): ProviderPlugin[] {
|
||||
return params.registry.providers.map((entry) => ({
|
||||
...entry.provider,
|
||||
pluginId: entry.pluginId,
|
||||
}));
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { resolveExtensionHostProviders } from "../extension-host/provider-runtime.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { loadOpenClawPlugins, type PluginLoadOptions } from "./loader.js";
|
||||
import { createPluginLoaderLogger } from "./logger.js";
|
||||
|
|
@ -18,8 +19,5 @@ export function resolvePluginProviders(params: {
|
|||
logger: createPluginLoaderLogger(log),
|
||||
});
|
||||
|
||||
return registry.providers.map((entry) => ({
|
||||
...entry.provider,
|
||||
pluginId: entry.pluginId,
|
||||
}));
|
||||
return resolveExtensionHostProviders({ registry });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue