mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
refactor: trim channel contract test helpers
This commit is contained in:
@@ -85,10 +85,3 @@ export function listBundledChannelPlugins(): readonly ChannelPlugin[] {
|
||||
return plugin ? [plugin] : [];
|
||||
});
|
||||
}
|
||||
|
||||
export async function listBundledChannelPluginsAsync(): Promise<readonly ChannelPlugin[]> {
|
||||
const plugins = await Promise.all(
|
||||
listBundledChannelPluginIds().map((id) => getBundledChannelPluginAsync(id)),
|
||||
);
|
||||
return plugins.filter((plugin): plugin is ChannelPlugin => Boolean(plugin));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { resolveOpenProviderRuntimeGroupPolicy } from "../../../../config/runtime-group-policy.js";
|
||||
|
||||
type ResolvedGroupPolicy = ReturnType<typeof resolveOpenProviderRuntimeGroupPolicy>;
|
||||
|
||||
export type RuntimeGroupPolicyResolver = (
|
||||
params: Parameters<typeof resolveOpenProviderRuntimeGroupPolicy>[0],
|
||||
) => ReturnType<typeof resolveOpenProviderRuntimeGroupPolicy>;
|
||||
@@ -39,11 +37,3 @@ export function installChannelRuntimeGroupPolicyFallbackSuite(params: {
|
||||
expect(resolved.providerMissingFallbackApplied).toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
export function expectResolvedGroupPolicyCase(
|
||||
resolved: Pick<ResolvedGroupPolicy, "groupPolicy" | "providerMissingFallbackApplied">,
|
||||
expected: Pick<ResolvedGroupPolicy, "groupPolicy" | "providerMissingFallbackApplied">,
|
||||
) {
|
||||
expect(resolved.groupPolicy).toBe(expected.groupPolicy);
|
||||
expect(resolved.providerMissingFallbackApplied).toBe(expected.providerMissingFallbackApplied);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,10 @@
|
||||
import type { ChannelId } from "../../channel-id.types.js";
|
||||
import { normalizeChannelMeta } from "../../meta-normalization.js";
|
||||
import type { ChannelPlugin } from "../../types.js";
|
||||
import {
|
||||
getBundledChannelCatalogEntry,
|
||||
getBundledChannelPlugin,
|
||||
listBundledChannelPluginIds,
|
||||
listBundledChannelPlugins,
|
||||
} from "./bundled-channel-plugin-loader.js";
|
||||
|
||||
type PluginContractEntry = {
|
||||
id: string;
|
||||
plugin: Pick<ChannelPlugin, "id" | "meta" | "capabilities" | "config">;
|
||||
};
|
||||
import { listBundledChannelPluginIds } from "./bundled-channel-plugin-loader.js";
|
||||
|
||||
type PluginContractRef = {
|
||||
id: ChannelId;
|
||||
};
|
||||
|
||||
function toPluginContractEntry(plugin: ChannelPlugin): PluginContractEntry {
|
||||
const existingMeta = getBundledChannelCatalogEntry(plugin.id)?.channel;
|
||||
return {
|
||||
id: plugin.id,
|
||||
plugin: {
|
||||
...plugin,
|
||||
meta: normalizeChannelMeta({ id: plugin.id, meta: plugin.meta, existing: existingMeta }),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function getBundledChannelPluginIdsForShard(params: {
|
||||
shardIndex: number;
|
||||
shardCount: number;
|
||||
@@ -37,20 +14,6 @@ function getBundledChannelPluginIdsForShard(params: {
|
||||
);
|
||||
}
|
||||
|
||||
export function getPluginContractRegistry(): PluginContractEntry[] {
|
||||
return listBundledChannelPlugins().map(toPluginContractEntry);
|
||||
}
|
||||
|
||||
export function getPluginContractRegistryShard(params: {
|
||||
shardIndex: number;
|
||||
shardCount: number;
|
||||
}): PluginContractEntry[] {
|
||||
return getBundledChannelPluginIdsForShard(params).flatMap((id) => {
|
||||
const plugin = getBundledChannelPlugin(id);
|
||||
return plugin ? [toPluginContractEntry(plugin)] : [];
|
||||
});
|
||||
}
|
||||
|
||||
export function getPluginContractRegistryShardRefs(params: {
|
||||
shardIndex: number;
|
||||
shardCount: number;
|
||||
|
||||
Reference in New Issue
Block a user