erosolar-cli
Version:
Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning
25 lines • 862 B
JavaScript
const registry = new Map();
export function registerProvider(id, factory, options = {}) {
if (!id?.trim()) {
throw new Error('Provider id cannot be blank.');
}
if (registry.has(id) && !options.override) {
throw new Error(`Provider "${id}" is already registered.`);
}
registry.set(id, factory);
}
export function createProvider(config) {
const factory = registry.get(config.provider);
if (!factory) {
const known = Array.from(registry.keys()).sort().join(', ');
throw new Error(`Provider "${config.provider}" is not registered. Registered providers: ${known || 'none'}.`);
}
return factory(config);
}
export function listRegisteredProviders() {
return Array.from(registry.keys());
}
export function hasProvider(id) {
return registry.has(id);
}
//# sourceMappingURL=providerFactory.js.map