import { type CustomProviderApi, type CustomProviderInput, type CustomProviderIssue, type CustomProviderModelSpec } from './custom-provider-model.js'; export interface CustomProviderStores { /** PI's user catalog (`~/.pi/agent/models.json`). */ modelsPath: string; /** The gateway config the running gateway watches (`~/.aistatus/gateway.yaml`). */ gatewayPath: string; /** Gateway base URL every custom provider is routed through. */ gatewayUrl: string; /** Provider ids PI already owns, so a definition cannot shadow a built-in. */ reservedNames?: string[]; /** Called after a successful change so provider discovery and account status can refresh. */ onChanged?: () => void; } /** * The host files a custom provider lives in: PI's own catalog and the gateway config it routes to. * A change invalidates the provider discovery cache the same way a login does, so a provider defined * from any surface reaches the next spawn without waiting out the cache TTL. */ export declare function defaultCustomProviderStores(): CustomProviderStores; /** Secret-free view of a stored custom provider. */ export interface CustomProviderView { name: string; api: CustomProviderApi; models: CustomProviderModelSpec[]; /** Upstream from the gateway route, or null when the route is missing. */ upstreamUrl: string | null; hasApiKey: boolean; /** Whether a gateway route backs this definition. False means calls will 404 at the gateway. */ routed: boolean; headers?: Record; compat?: Record; } export type CustomProviderFailure = CustomProviderIssue | 'write-failed' | 'not-found'; export type CustomProviderResult = { ok: true; provider: CustomProviderView; } | { ok: false; errors: CustomProviderFailure[]; }; export type CustomProviderRemoval = { ok: true; } | { ok: false; errors: CustomProviderFailure[]; }; export declare function listCustomProviders(stores: CustomProviderStores): CustomProviderView[]; export declare function getCustomProvider(stores: CustomProviderStores, name: string): CustomProviderView | null; /** * Create or update a custom provider. The gateway route is written first — an unreferenced route is * inert — and the PI catalog second, because that write is what makes the provider visible to PI. * A failed catalog write therefore rolls the route back to its previous state. * * `apiKey` semantics: `undefined` keeps the stored upstream key (so an edit need not retype it), * `''` clears it and lets the gateway pass the caller's own key through. */ export declare function upsertCustomProvider(stores: CustomProviderStores, input: CustomProviderInput): CustomProviderResult; /** Remove a custom provider from both files. Built-in overrides are not custom and are refused. */ export declare function removeCustomProvider(stores: CustomProviderStores, name: string): CustomProviderRemoval;