@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
51 lines • 2.2 kB
TypeScript
/**
* One-shot model discovery for an OpenAI-compatible provider in models.json (senpi#2196).
*
* `GET <baseUrl>/models` is fetched once and every listed id is upserted into the provider's
* `models` array. When the provider opts in with `compat.supportsReasoningEffort: true`, the
* `reasoning_efforts` an entry advertises become that model's `thinkingLevelMap` (endpoint
* spelling kept, unadvertised levels vetoed) and its `default` becomes `defaultThinkingLevel`.
* Discovery owns `reasoning`, `thinkingLevelMap`, and `defaultThinkingLevel` of a model that advertises
* efforts; every other field is left exactly as the user wrote them.
*/
import { type ModelThinkingLevel, type ProviderHeaders } from "@earendil-works/pi-ai";
export interface ModelsDiscoveryAuth {
apiKey?: string;
/** A `null` value removes a header, as for provider requests. */
headers?: ProviderHeaders;
}
export interface DiscoveredEfforts {
/** Levels the endpoint advertised, in senpi order. */
levels: ModelThinkingLevel[];
defaultThinkingLevel?: ModelThinkingLevel;
unmapped: string[];
}
export interface ModelsDiscoveryReport {
providerId: string;
url: string;
modelsPath: string;
added: string[];
updated: string[];
unchanged: string[];
/** Configured ids the endpoint did not list; kept untouched. */
unlisted: string[];
efforts: Record<string, DiscoveredEfforts>;
/** The listing advertised efforts but the provider did not opt in, so they were not used. */
effortsIgnored: boolean;
written: boolean;
backupPath?: string;
/** The rewritten file lost comments the original had; the backup keeps them. */
commentsDropped: boolean;
}
export interface DiscoverProviderModelsOptions {
providerId: string;
modelsPath: string;
auth: ModelsDiscoveryAuth;
fetch?: typeof fetch;
signal?: AbortSignal;
}
export declare class ModelsDiscoveryError extends Error {
}
/** Fetch the provider's model listing once and upsert it into models.json. */
export declare function discoverProviderModels(options: DiscoverProviderModelsOptions): Promise<ModelsDiscoveryReport>;
//# sourceMappingURL=model-discovery.d.ts.map