feat(ai): lazy-load provider modules for faster startup fixes #2297

This commit is contained in:
Mario Zechner
2026-03-17 18:03:24 +01:00
parent dd53eb56ee
commit a7559f01e9
7 changed files with 488 additions and 78 deletions

View File

@@ -1161,6 +1161,9 @@ Create a new provider file (for example `amazon-bedrock.ts`) that exports:
#### 3. API Registry Integration (`src/providers/register-builtins.ts`)
- Register the API with `registerApiProvider()`
- Add a package subpath export in `package.json` for the provider module (`./dist/providers/<provider>.js`)
- Add lazy loader wrappers in `src/providers/register-builtins.ts`, do not statically import provider implementation modules there
- Add any root-level `export type` re-exports in `src/index.ts` that should remain available from `@mariozechner/pi-ai`
- Add credential detection in `env-api-keys.ts` for the new provider
- Ensure `streamSimple` handles auth lookup via `getEnvApiKey()` or provider-specific auth