clanker-agent/packages/web-ui/src/storage/stores/custom-providers-store.ts
Harivansh Rathi 0250f72976 move pi-mono into companion-cloud as apps/companion-os
- Copy all pi-mono source into apps/companion-os/
- Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases
- Update deploy-staging.yml to build pi from source (bun compile) before Docker build
- Add apps/companion-os/** to path triggers
- No more cross-repo dispatch needed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 09:22:50 -08:00

66 lines
1.9 KiB
TypeScript

import type { Model } from "@mariozechner/pi-ai";
import { Store } from "../store.js";
import type { StoreConfig } from "../types.js";
export type AutoDiscoveryProviderType =
| "ollama"
| "llama.cpp"
| "vllm"
| "lmstudio";
export type CustomProviderType =
| AutoDiscoveryProviderType // Auto-discovery - models fetched on-demand
| "openai-completions" // Manual models - stored in provider.models
| "openai-responses" // Manual models - stored in provider.models
| "anthropic-messages"; // Manual models - stored in provider.models
export interface CustomProvider {
id: string; // UUID
name: string; // Display name, also used as Model.provider
type: CustomProviderType;
baseUrl: string;
apiKey?: string; // Optional, applies to all models
// For manual types ONLY - models stored directly on provider
// Auto-discovery types: models fetched on-demand, never stored
models?: Model<any>[];
}
/**
* Store for custom LLM providers (auto-discovery servers + manual providers).
*/
export class CustomProvidersStore extends Store {
getConfig(): StoreConfig {
return {
name: "custom-providers",
};
}
async get(id: string): Promise<CustomProvider | null> {
return this.getBackend().get("custom-providers", id);
}
async set(provider: CustomProvider): Promise<void> {
await this.getBackend().set("custom-providers", provider.id, provider);
}
async delete(id: string): Promise<void> {
await this.getBackend().delete("custom-providers", id);
}
async getAll(): Promise<CustomProvider[]> {
const keys = await this.getBackend().keys("custom-providers");
const providers: CustomProvider[] = [];
for (const key of keys) {
const provider = await this.get(key);
if (provider) {
providers.push(provider);
}
}
return providers;
}
async has(id: string): Promise<boolean> {
return this.getBackend().has("custom-providers", id);
}
}