mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
fix: stabilize plugin metadata release checks
This commit is contained in:
@@ -70,6 +70,11 @@ vi.mock("./plugin-registry.js", async (importOriginal) => {
|
||||
return {
|
||||
...actual,
|
||||
loadPluginRegistrySnapshot: mocks.loadPluginRegistrySnapshot,
|
||||
loadPluginRegistrySnapshotWithMetadata: (params?: { index?: unknown }) => ({
|
||||
snapshot: params?.index ?? mocks.loadPluginRegistrySnapshot(),
|
||||
source: params?.index ? "provided" : "derived",
|
||||
diagnostics: [],
|
||||
}),
|
||||
loadPluginManifestRegistryForPluginRegistry: (
|
||||
...args: Parameters<typeof mocks.loadPluginManifestRegistry>
|
||||
) => {
|
||||
@@ -1078,7 +1083,7 @@ describe("resolvePluginCapabilityProviders", () => {
|
||||
expectResolvedCapabilityProviderIds(providers, ["google"]);
|
||||
expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: undefined,
|
||||
config: {},
|
||||
env: process.env,
|
||||
includeDisabled: true,
|
||||
index: expect.any(Object),
|
||||
|
||||
@@ -850,6 +850,7 @@ async function installPluginFromPackageDir(
|
||||
const { plugin } = validated;
|
||||
|
||||
preparedTarget = await resolvePreparedTargetForPluginId(plugin.pluginId);
|
||||
const hasBundleManifest = Boolean(runtime.detectBundleManifestFormat(params.packageDir));
|
||||
|
||||
return await installPluginDirectoryIntoExtensions({
|
||||
sourceDir: params.packageDir,
|
||||
@@ -865,7 +866,9 @@ async function installPluginFromPackageDir(
|
||||
dryRun,
|
||||
copyErrorPrefix: "failed to copy plugin",
|
||||
hasDeps:
|
||||
plugin.hasRuntimeDependencies && params.installPolicyRequest?.kind === "plugin-archive",
|
||||
plugin.hasRuntimeDependencies &&
|
||||
!hasBundleManifest &&
|
||||
params.installPolicyRequest?.kind === "plugin-archive",
|
||||
depsLogMessage: "Installing plugin dependencies…",
|
||||
nameEncoder: encodePluginInstallDirName,
|
||||
afterInstall: async (installedDir) => {
|
||||
|
||||
@@ -14,7 +14,7 @@ import type {
|
||||
PluginMetadataSnapshotOwnerMaps,
|
||||
} from "./plugin-metadata-snapshot.types.js";
|
||||
import { createPluginRegistryIdNormalizer } from "./plugin-registry-id-normalizer.js";
|
||||
import { loadPluginRegistrySnapshotWithMetadata } from "./plugin-registry-snapshot.js";
|
||||
import { loadPluginRegistrySnapshotWithMetadata } from "./plugin-registry.js";
|
||||
export type {
|
||||
LoadPluginMetadataSnapshotParams,
|
||||
PluginMetadataManifestView,
|
||||
@@ -102,13 +102,13 @@ function buildPluginMetadataOwnerMaps(
|
||||
const contracts = new Map<string, string[]>();
|
||||
|
||||
for (const plugin of plugins) {
|
||||
for (const channelId of plugin.channels) {
|
||||
for (const channelId of plugin.channels ?? []) {
|
||||
appendOwner(channels, channelId, plugin.id);
|
||||
}
|
||||
for (const channelId of Object.keys(plugin.channelConfigs ?? {})) {
|
||||
appendOwner(channelConfigs, channelId, plugin.id);
|
||||
}
|
||||
for (const providerId of plugin.providers) {
|
||||
for (const providerId of plugin.providers ?? []) {
|
||||
appendOwner(providers, providerId, plugin.id);
|
||||
}
|
||||
for (const providerId of Object.keys(plugin.modelCatalog?.providers ?? {})) {
|
||||
@@ -117,7 +117,7 @@ function buildPluginMetadataOwnerMaps(
|
||||
for (const providerId of Object.keys(plugin.modelCatalog?.aliases ?? {})) {
|
||||
appendOwner(modelCatalogProviders, providerId, plugin.id);
|
||||
}
|
||||
for (const cliBackendId of plugin.cliBackends) {
|
||||
for (const cliBackendId of plugin.cliBackends ?? []) {
|
||||
appendOwner(cliBackends, cliBackendId, plugin.id);
|
||||
}
|
||||
for (const cliBackendId of plugin.setup?.cliBackends ?? []) {
|
||||
|
||||
@@ -22,10 +22,10 @@ function collectObjectKeys(value: Record<string, unknown> | undefined): readonly
|
||||
function listPluginRegistryNormalizerAliases(plugin: PluginManifestRecord): readonly string[] {
|
||||
return [
|
||||
plugin.id,
|
||||
...plugin.providers,
|
||||
...plugin.channels,
|
||||
...(plugin.providers ?? []),
|
||||
...(plugin.channels ?? []),
|
||||
...(plugin.setup?.providers?.map((provider) => provider.id) ?? []),
|
||||
...plugin.cliBackends,
|
||||
...(plugin.cliBackends ?? []),
|
||||
...(plugin.setup?.cliBackends ?? []),
|
||||
...collectObjectKeys(plugin.modelCatalog?.providers),
|
||||
...collectObjectKeys(plugin.modelCatalog?.aliases),
|
||||
|
||||
@@ -234,16 +234,19 @@ function createOptionalDemoActiveRegistry() {
|
||||
|
||||
function installToolManifestSnapshot(params: {
|
||||
config: ReturnType<typeof createContext>["config"];
|
||||
env?: NodeJS.ProcessEnv;
|
||||
plugin: Record<string, unknown>;
|
||||
}) {
|
||||
installToolManifestSnapshots({
|
||||
config: params.config,
|
||||
env: params.env,
|
||||
plugins: [params.plugin],
|
||||
});
|
||||
}
|
||||
|
||||
function installToolManifestSnapshots(params: {
|
||||
config: ReturnType<typeof createContext>["config"];
|
||||
env?: NodeJS.ProcessEnv;
|
||||
plugins: Record<string, unknown>[];
|
||||
}) {
|
||||
const plugins = params.plugins;
|
||||
@@ -287,7 +290,7 @@ function installToolManifestSnapshots(params: {
|
||||
manifestPluginCount: plugins.length,
|
||||
},
|
||||
} as never,
|
||||
{ config: params.config, env: process.env, workspaceDir: "/tmp" },
|
||||
{ config: params.config, env: params.env ?? process.env, workspaceDir: "/tmp" },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -392,6 +395,7 @@ describe("resolvePluginTools optional tools", () => {
|
||||
const config = createContext().config;
|
||||
installToolManifestSnapshot({
|
||||
config,
|
||||
env: {},
|
||||
plugin: createXaiToolManifest(),
|
||||
});
|
||||
const factory = vi.fn(() => makeTool("x_search"));
|
||||
@@ -434,6 +438,7 @@ describe("resolvePluginTools optional tools", () => {
|
||||
const config = createContext().config;
|
||||
installToolManifestSnapshot({
|
||||
config,
|
||||
env: {},
|
||||
plugin: createXaiToolManifest(),
|
||||
});
|
||||
const factory = vi.fn(() => makeTool("x_search"));
|
||||
@@ -474,6 +479,7 @@ describe("resolvePluginTools optional tools", () => {
|
||||
const config = createContext().config;
|
||||
installToolManifestSnapshot({
|
||||
config,
|
||||
env: { XAI_API_KEY: "test-key" },
|
||||
plugin: createXaiToolManifest(),
|
||||
});
|
||||
const factory = vi.fn(() => makeTool("x_search"));
|
||||
@@ -541,6 +547,7 @@ describe("resolvePluginTools optional tools", () => {
|
||||
} as const;
|
||||
installToolManifestSnapshot({
|
||||
config,
|
||||
env: {},
|
||||
plugin: createXaiToolManifest(),
|
||||
});
|
||||
const factory = vi.fn(() => makeTool("x_search"));
|
||||
|
||||
Reference in New Issue
Block a user