Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
/**
|
|
* Agent Provider Registry
|
|
*
|
|
* In-memory registry of agent provider configurations.
|
|
* Pre-populated with built-in presets, extensible via registerProvider()
|
|
* or loadProvidersFromFile() for custom/override configs.
|
|
*/
|
|
|
|
import { readFileSync } from 'node:fs';
|
|
import type { AgentProviderConfig } from './types.js';
|
|
import { PROVIDER_PRESETS } from './presets.js';
|
|
|
|
const providers = new Map<string, AgentProviderConfig>(
|
|
Object.entries(PROVIDER_PRESETS),
|
|
);
|
|
|
|
/**
|
|
* Get a provider configuration by name.
|
|
* Returns null if the provider is not registered.
|
|
*/
|
|
export function getProvider(name: string): AgentProviderConfig | null {
|
|
return providers.get(name) ?? null;
|
|
}
|
|
|
|
/**
|
|
* List all registered provider names.
|
|
*/
|
|
export function listProviders(): string[] {
|
|
return Array.from(providers.keys());
|
|
}
|
|
|
|
/**
|
|
* Register or override a provider configuration.
|
|
*/
|
|
export function registerProvider(config: AgentProviderConfig): void {
|
|
providers.set(config.name, config);
|
|
}
|
|
|
|
/**
|
|
* Load provider configurations from a JSON file and merge into the registry.
|
|
* File should contain a JSON object mapping provider names to AgentProviderConfig objects.
|
|
* Existing providers with matching names will be overridden.
|
|
*/
|
|
export function loadProvidersFromFile(path: string): void {
|
|
const raw = readFileSync(path, 'utf-8');
|
|
const parsed = JSON.parse(raw) as Record<string, AgentProviderConfig>;
|
|
for (const [name, config] of Object.entries(parsed)) {
|
|
providers.set(name, { ...config, name });
|
|
}
|
|
}
|