Add Provider
Scaffolds a new LLM provider adapter under packages/providers/<name>/.
Steps
- •Ask for the provider name (e.g., "openai", "ollama", "anthropic")
- •Create the directory structure:
code
packages/providers/<name>/
package.json # @spaceduck/provider-<name>, depends on @spaceduck/core
src/
<name>.ts # <Name>Provider implements Provider interface
index.ts # barrel export
__tests__/
<name>.test.ts # unit tests with mocked SDK
- •The provider must implement the
Providerinterface from@spaceduck/core:
typescript
import type { Provider, Message, ProviderOptions } from "@spaceduck/core";
export class <Name>Provider implements Provider {
readonly name = "<name>";
async *chat(messages: Message[], options?: ProviderOptions): AsyncIterable<string> {
// Implementation here
// Must respect options.signal (AbortSignal) for cancellation
}
}
- •Add the provider to
@spaceduck/gatewayby importing and wiring it in the registry - •Map provider-specific exceptions to
ProviderErrorCodevalues - •Write unit tests using
spyOnto mock the SDK client