Files
openclaw/test/helpers/extensions/provider-registration.ts
Neerav Makwana 6fd9d2ff38 fix: support OpenAI Codex media understanding (#54829) (thanks @neeravmakwana)
* OpenAI: register Codex media understanding provider

* fix: route codex image prompts through system instructions

* fix: add changelog for codex image tool fix (#54829) (thanks @neeravmakwana)

* fix: remove any from provider registration tests (#54829) (thanks @neeravmakwana)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-03-26 10:10:11 +05:30

66 lines
1.8 KiB
TypeScript

import type {
ImageGenerationProviderPlugin,
MediaUnderstandingProviderPlugin,
ProviderPlugin,
SpeechProviderPlugin,
} from "../../../src/plugins/types.js";
import { createTestPluginApi } from "./plugin-api.js";
type RegisteredProviderCollections = {
providers: ProviderPlugin[];
speechProviders: SpeechProviderPlugin[];
mediaProviders: MediaUnderstandingProviderPlugin[];
imageProviders: ImageGenerationProviderPlugin[];
};
type ProviderPluginModule = {
register(api: ReturnType<typeof createTestPluginApi>): void;
};
export function registerProviderPlugin(params: {
plugin: ProviderPluginModule;
id: string;
name: string;
}): RegisteredProviderCollections {
const providers: ProviderPlugin[] = [];
const speechProviders: SpeechProviderPlugin[] = [];
const mediaProviders: MediaUnderstandingProviderPlugin[] = [];
const imageProviders: ImageGenerationProviderPlugin[] = [];
params.plugin.register(
createTestPluginApi({
id: params.id,
name: params.name,
source: "test",
config: {},
runtime: {} as never,
registerProvider: (provider) => {
providers.push(provider);
},
registerSpeechProvider: (provider) => {
speechProviders.push(provider);
},
registerMediaUnderstandingProvider: (provider) => {
mediaProviders.push(provider);
},
registerImageGenerationProvider: (provider) => {
imageProviders.push(provider);
},
}),
);
return { providers, speechProviders, mediaProviders, imageProviders };
}
export function requireRegisteredProvider<T extends { id: string }>(
entries: T[],
id: string,
label = "provider",
): T {
const entry = entries.find((candidate) => candidate.id === id);
if (!entry) {
throw new Error(`${label} ${id} was not registered`);
}
return entry;
}