@linxiraos/pi-catalog 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +999 -0
- package/README.md +43 -0
- package/dist/types/build.d.ts +14 -0
- package/dist/types/compat/anthropic.d.ts +18 -0
- package/dist/types/compat/apply.d.ts +7 -0
- package/dist/types/compat/bedrock.d.ts +3 -0
- package/dist/types/compat/devin.d.ts +9 -0
- package/dist/types/compat/openai.d.ts +26 -0
- package/dist/types/discovery/antigravity.d.ts +70 -0
- package/dist/types/discovery/codex.d.ts +36 -0
- package/dist/types/discovery/cursor-gen/agent_pb.d.ts +16769 -0
- package/dist/types/discovery/cursor.d.ts +23 -0
- package/dist/types/discovery/devin-gen/buf/validate/validate_pb.d.ts +1715 -0
- package/dist/types/discovery/devin-gen/exa/analytics_pb/analytics_pb.d.ts +693 -0
- package/dist/types/discovery/devin-gen/exa/api_server_pb/api_server_pb.d.ts +9158 -0
- package/dist/types/discovery/devin-gen/exa/auth_pb/auth_pb.d.ts +52 -0
- package/dist/types/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.d.ts +276 -0
- package/dist/types/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.d.ts +78 -0
- package/dist/types/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.d.ts +999 -0
- package/dist/types/discovery/devin-gen/exa/chat_pb/chat_pb.d.ts +1704 -0
- package/dist/types/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.d.ts +656 -0
- package/dist/types/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.d.ts +15014 -0
- package/dist/types/discovery/devin-gen/exa/context_module_pb/context_module_pb.d.ts +607 -0
- package/dist/types/discovery/devin-gen/exa/cortex_pb/cortex_pb.d.ts +11830 -0
- package/dist/types/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.d.ts +248 -0
- package/dist/types/discovery/devin-gen/exa/index_pb/index_pb.d.ts +1747 -0
- package/dist/types/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.d.ts +509 -0
- package/dist/types/discovery/devin-gen/exa/language_server_pb/language_server_pb.d.ts +9048 -0
- package/dist/types/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.d.ts +1760 -0
- package/dist/types/discovery/devin-gen/exa/prompt_pb/prompt_pb.d.ts +286 -0
- package/dist/types/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.d.ts +405 -0
- package/dist/types/discovery/devin-gen/exa/trust_pb/trust_pb.d.ts +582 -0
- package/dist/types/discovery/devin.d.ts +24 -0
- package/dist/types/discovery/gemini.d.ts +25 -0
- package/dist/types/discovery/gitlab-duo-workflow.d.ts +30 -0
- package/dist/types/discovery/index.d.ts +5 -0
- package/dist/types/discovery/openai-compatible.d.ts +74 -0
- package/dist/types/effort.d.ts +10 -0
- package/dist/types/fireworks-model-id.d.ts +23 -0
- package/dist/types/hosts.d.ts +164 -0
- package/dist/types/identity/bundled.d.ts +3 -0
- package/dist/types/identity/classify.d.ts +69 -0
- package/dist/types/identity/dialect.d.ts +3 -0
- package/dist/types/identity/family.d.ts +181 -0
- package/dist/types/identity/id.d.ts +12 -0
- package/dist/types/identity/index.d.ts +8 -0
- package/dist/types/identity/markers.d.ts +4 -0
- package/dist/types/identity/priority.d.ts +1 -0
- package/dist/types/identity/reference.d.ts +29 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/model-cache.d.ts +23 -0
- package/dist/types/model-manager.d.ts +77 -0
- package/dist/types/model-thinking.d.ts +66 -0
- package/dist/types/models.d.ts +12 -0
- package/dist/types/provider-models/bundled-references.d.ts +13 -0
- package/dist/types/provider-models/cache-provider-id.d.ts +9 -0
- package/dist/types/provider-models/descriptor-types.d.ts +76 -0
- package/dist/types/provider-models/descriptors.d.ts +504 -0
- package/dist/types/provider-models/google.d.ts +27 -0
- package/dist/types/provider-models/index.d.ts +7 -0
- package/dist/types/provider-models/ollama.d.ts +22 -0
- package/dist/types/provider-models/openai-compat.d.ts +599 -0
- package/dist/types/provider-models/special.d.ts +53 -0
- package/dist/types/types.d.ts +811 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/variant-collapse.d.ts +133 -0
- package/dist/types/wire/alibaba-token-plan.d.ts +22 -0
- package/dist/types/wire/codex.d.ts +42 -0
- package/dist/types/wire/coreweave.d.ts +12 -0
- package/dist/types/wire/gemini-headers.d.ts +37 -0
- package/dist/types/wire/github-copilot.d.ts +39 -0
- package/package.json +101 -0
- package/src/build.ts +94 -0
- package/src/compat/anthropic.ts +179 -0
- package/src/compat/apply.ts +15 -0
- package/src/compat/bedrock.ts +153 -0
- package/src/compat/devin.ts +12 -0
- package/src/compat/openai.ts +796 -0
- package/src/discovery/antigravity.ts +253 -0
- package/src/discovery/codex.ts +346 -0
- package/src/discovery/cursor-gen/agent_pb.ts +19513 -0
- package/src/discovery/cursor.ts +396 -0
- package/src/discovery/devin-gen/buf/validate/validate_pb.ts +1862 -0
- package/src/discovery/devin-gen/exa/analytics_pb/analytics_pb.ts +871 -0
- package/src/discovery/devin-gen/exa/api_server_pb/api_server_pb.ts +11083 -0
- package/src/discovery/devin-gen/exa/auth_pb/auth_pb.ts +71 -0
- package/src/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.ts +348 -0
- package/src/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.ts +103 -0
- package/src/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.ts +1198 -0
- package/src/discovery/devin-gen/exa/chat_pb/chat_pb.ts +2063 -0
- package/src/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.ts +810 -0
- package/src/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.ts +18354 -0
- package/src/discovery/devin-gen/exa/context_module_pb/context_module_pb.ts +732 -0
- package/src/discovery/devin-gen/exa/cortex_pb/cortex_pb.ts +14277 -0
- package/src/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.ts +312 -0
- package/src/discovery/devin-gen/exa/index_pb/index_pb.ts +2106 -0
- package/src/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.ts +623 -0
- package/src/discovery/devin-gen/exa/language_server_pb/language_server_pb.ts +10918 -0
- package/src/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.ts +2125 -0
- package/src/discovery/devin-gen/exa/prompt_pb/prompt_pb.ts +361 -0
- package/src/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.ts +450 -0
- package/src/discovery/devin-gen/exa/trust_pb/trust_pb.ts +712 -0
- package/src/discovery/devin.ts +151 -0
- package/src/discovery/gemini.ts +260 -0
- package/src/discovery/gitlab-duo-workflow.ts +859 -0
- package/src/discovery/index.ts +5 -0
- package/src/discovery/openai-compatible.ts +249 -0
- package/src/effort.ts +18 -0
- package/src/fireworks-model-id.ts +50 -0
- package/src/hosts.ts +155 -0
- package/src/identity/bundled.ts +28 -0
- package/src/identity/classify.ts +219 -0
- package/src/identity/dialect.ts +42 -0
- package/src/identity/family.ts +366 -0
- package/src/identity/id.ts +81 -0
- package/src/identity/index.ts +8 -0
- package/src/identity/markers.ts +49 -0
- package/src/identity/priority.ts +59 -0
- package/src/identity/reference.ts +167 -0
- package/src/index.ts +17 -0
- package/src/model-cache.ts +285 -0
- package/src/model-manager.ts +672 -0
- package/src/model-thinking.ts +821 -0
- package/src/models.json +106099 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +93 -0
- package/src/provider-models/bundled-references.ts +75 -0
- package/src/provider-models/cache-provider-id.ts +68 -0
- package/src/provider-models/descriptor-types.ts +85 -0
- package/src/provider-models/descriptors.ts +584 -0
- package/src/provider-models/google.ts +107 -0
- package/src/provider-models/index.ts +7 -0
- package/src/provider-models/ollama.ts +204 -0
- package/src/provider-models/openai-compat.ts +5991 -0
- package/src/provider-models/special.ts +213 -0
- package/src/types.ts +952 -0
- package/src/utils.ts +69 -0
- package/src/variant-collapse.ts +1225 -0
- package/src/wire/alibaba-token-plan.ts +54 -0
- package/src/wire/codex.ts +60 -0
- package/src/wire/coreweave.ts +51 -0
- package/src/wire/gemini-headers.ts +74 -0
- package/src/wire/github-copilot.ts +115 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Api, Model, ModelSpec, Provider } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Controls when dynamic endpoint models should be fetched.
|
|
4
|
+
*/
|
|
5
|
+
export type ModelRefreshStrategy = "online" | "offline" | "online-if-uncached";
|
|
6
|
+
/**
|
|
7
|
+
* Hook for loading and mapping stencil.so fallback data into canonical model objects.
|
|
8
|
+
*/
|
|
9
|
+
export interface ModelsDevFallback<TApi extends Api = Api, TPayload = unknown> {
|
|
10
|
+
/** Fetches raw fallback payload (for example from stencil.so). */
|
|
11
|
+
fetch(): Promise<TPayload>;
|
|
12
|
+
/** Maps payload into provider models. */
|
|
13
|
+
map(payload: TPayload, providerId: Provider): readonly ModelSpec<TApi>[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for provider model resolution.
|
|
17
|
+
*/
|
|
18
|
+
export interface ModelManagerOptions<TApi extends Api = Api, TModelsDevPayload = unknown> {
|
|
19
|
+
/** Provider id used for static lookup and cache namespacing. */
|
|
20
|
+
providerId: Provider;
|
|
21
|
+
/** Optional static list override. When omitted, bundled models.json is used. */
|
|
22
|
+
staticModels?: readonly ModelSpec<TApi>[];
|
|
23
|
+
/** Optional override for the cache database path. Default: <agent-dir>/models.db. */
|
|
24
|
+
cacheDbPath?: string;
|
|
25
|
+
/** Optional provider id override for cache namespacing. Defaults to providerId. */
|
|
26
|
+
cacheProviderId?: string;
|
|
27
|
+
/** Maximum cache age in milliseconds before considered stale. Default: 2h (`DEFAULT_CACHE_TTL_MS`). */
|
|
28
|
+
cacheTtlMs?: number;
|
|
29
|
+
/** When true, a successful dynamic fetch is the complete provider catalog and prunes static-only models. */
|
|
30
|
+
dynamicModelsAuthoritative?: boolean;
|
|
31
|
+
/** Cached model ids whose presence forces refresh when the static or migration-policy fingerprint changes. */
|
|
32
|
+
dropCachedModelIdsOnStaticMismatch?: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Trusted, provider-wide request headers (compile-time constants, never
|
|
35
|
+
* credentials) that the cache may restore by value for any model whose live
|
|
36
|
+
* headers matched them at write time. Lets header-bearing dynamic models
|
|
37
|
+
* without a bundled static entry survive offline reads instead of being
|
|
38
|
+
* dropped as unrestorable (e.g. GitHub Copilot's User-Agent + API version).
|
|
39
|
+
*/
|
|
40
|
+
restorableHeaderFallback?: Record<string, string>;
|
|
41
|
+
/** Optional dynamic endpoint fetcher. */
|
|
42
|
+
fetchDynamicModels?: () => Promise<readonly ModelSpec<TApi>[] | null>;
|
|
43
|
+
/** Optional stencil.so fallback hook. */
|
|
44
|
+
modelsDev?: ModelsDevFallback<TApi, TModelsDevPayload>;
|
|
45
|
+
/** Clock override for deterministic tests. */
|
|
46
|
+
now?: () => number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolution result.
|
|
50
|
+
*
|
|
51
|
+
* `stale` is false when the resolved catalog is authoritative for the selected provider:
|
|
52
|
+
* - a dynamic endpoint fetch succeeded in this call (an empty catalog is still
|
|
53
|
+
* authoritative for the cycle, so downstream pruning of removed models runs),
|
|
54
|
+
* - a still-fresh authoritative cache was reused in `online-if-uncached` mode, or
|
|
55
|
+
* - the provider has no dynamic fetcher configured.
|
|
56
|
+
*/
|
|
57
|
+
export interface ModelResolutionResult<TApi extends Api = Api> {
|
|
58
|
+
models: Model<TApi>[];
|
|
59
|
+
stale: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Stateful facade over provider model resolution.
|
|
63
|
+
*/
|
|
64
|
+
export interface ModelManager<TApi extends Api = Api> {
|
|
65
|
+
refresh(strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a reusable provider model manager.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createModelManager<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>): ModelManager<TApi>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves provider models with source precedence:
|
|
73
|
+
* static -> stencil.so -> cache -> dynamic.
|
|
74
|
+
*
|
|
75
|
+
* Later sources override earlier ones by model id.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveProviderModels<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>, strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thinking metadata: build-time derivation and runtime field-read helpers.
|
|
3
|
+
*
|
|
4
|
+
* Derivation (`resolveModelThinking`) runs exactly once per model — from
|
|
5
|
+
* `buildModel` for dynamic specs and from the catalog generator for bundled
|
|
6
|
+
* entries. Everything below the "runtime helpers" divider reads baked fields
|
|
7
|
+
* only: no id parsing, no host matching, no compat detection per request.
|
|
8
|
+
*/
|
|
9
|
+
import { Effort } from "./effort.js";
|
|
10
|
+
import type { Api, CompatOf, Model, ModelSpec, ThinkingConfig } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Runtime helpers read baked metadata only, so they accept both pre-build
|
|
13
|
+
* specs and built models.
|
|
14
|
+
*/
|
|
15
|
+
type ApiModel<TApi extends Api = Api> = ModelSpec<TApi> | Model<TApi>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the canonical thinking metadata for a spec. Called exactly once per
|
|
18
|
+
* model by `buildModel`, after compat resolution.
|
|
19
|
+
*
|
|
20
|
+
* - Non-reasoning models never carry thinking.
|
|
21
|
+
* - Models that reason natively but reject the wire effort param
|
|
22
|
+
* (`compat.supportsReasoningEffort: false` on openai-responses*) carry no
|
|
23
|
+
* thinking either: `reasoning: true, thinking: undefined` IS the encoding
|
|
24
|
+
* for "thinks, but exposes no control surface".
|
|
25
|
+
* - Explicit spec thinking (generator-baked or user-authored) owns the
|
|
26
|
+
* capability surface (`mode`, `efforts`, `defaultLevel`); the wire facts
|
|
27
|
+
* (`effortMap`, `supportsDisplay`) are backfilled from identity when not
|
|
28
|
+
* explicitly set, so configs never need to know provider wire tier tables.
|
|
29
|
+
* - Sparse specs go through full inference.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveModelThinking<TApi extends Api>(spec: ModelSpec<TApi>, compat: CompatOf<TApi>): ThinkingConfig | undefined;
|
|
32
|
+
/** Derive thinking from identity + resolved compat, ignoring any baked value. Generator-side entry. */
|
|
33
|
+
export declare function deriveThinking<TApi extends Api>(spec: ModelSpec<TApi>, compat: CompatOf<TApi>): ThinkingConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the supported thinking efforts declared on the model metadata.
|
|
36
|
+
* Empty for non-reasoning models and for reasoning models without a
|
|
37
|
+
* controllable effort surface (`thinking: undefined`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getSupportedEfforts<TApi extends Api>(model: ApiModel<TApi>): readonly Effort[];
|
|
40
|
+
/**
|
|
41
|
+
* Clamps a requested thinking level against explicit model metadata.
|
|
42
|
+
*
|
|
43
|
+
* Non-reasoning models always resolve to `undefined`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function clampThinkingLevelForModel<TApi extends Api>(model: ApiModel<TApi> | undefined, requested: Effort | undefined): Effort | undefined;
|
|
46
|
+
export declare function requireSupportedEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): Effort;
|
|
47
|
+
/** Maps a normalized thinking effort to Google's `thinkingLevel` enum values. */
|
|
48
|
+
export declare function mapEffortToGoogleThinkingLevel(effort: Effort): "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
|
|
49
|
+
/**
|
|
50
|
+
* Maps a normalized thinking effort to Anthropic adaptive effort values via
|
|
51
|
+
* the model's baked `thinking.effortMap` (identity for unmapped efforts).
|
|
52
|
+
*/
|
|
53
|
+
export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "low" | "medium" | "high" | "xhigh" | "max" | "adaptive";
|
|
54
|
+
/**
|
|
55
|
+
* Resolves the upstream wire model id for a request at the given effort
|
|
56
|
+
* (`undefined` = thinking off). Collapsed effort-tier variants route through
|
|
57
|
+
* `thinking.effortRouting`; everything else falls back to
|
|
58
|
+
* `requestModelId ?? id`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveWireModelId<TApi extends Api>(model: ApiModel<TApi>, effort: Effort | undefined): string;
|
|
61
|
+
/**
|
|
62
|
+
* Lowest supported effort in canonical order — the clamp target for
|
|
63
|
+
* thinking-off requests on `thinking.requiresEffort` models.
|
|
64
|
+
*/
|
|
65
|
+
export declare function minimumSupportedEffort<TApi extends Api>(model: ApiModel<TApi>): Effort | undefined;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import MODELS from "./models.json";
|
|
2
|
+
import type { Api, KnownProvider, Model, Usage } from "./types.js";
|
|
3
|
+
export type GeneratedProvider = keyof typeof MODELS;
|
|
4
|
+
export declare function getBundledModel<TApi extends Api = Api>(provider: GeneratedProvider, modelId: string): Model<TApi>;
|
|
5
|
+
export declare function getBundledProviders(): KnownProvider[];
|
|
6
|
+
export declare function getBundledModels(provider: GeneratedProvider): Model<Api>[];
|
|
7
|
+
export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
|
|
8
|
+
/**
|
|
9
|
+
* Check if two models are equal by comparing both their id and provider.
|
|
10
|
+
* Returns false if either model is null or undefined.
|
|
11
|
+
*/
|
|
12
|
+
export declare function modelsAreEqual<TApi extends Api>(a: Model<TApi> | null | undefined, b: Model<TApi> | null | undefined): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getBundledModels } from "../models.js";
|
|
2
|
+
import type { Api, Model, ModelSpec } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Project a built `Model` back to spec stage: `compat` becomes the verbatim
|
|
5
|
+
* sparse override record (`compatConfig`), never the resolved view. Discovery
|
|
6
|
+
* mappers spread these references into the specs they hand to the model
|
|
7
|
+
* manager, which rebuilds via `buildModel`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toModelSpec<TApi extends Api>(model: Model<TApi>): ModelSpec<TApi>;
|
|
10
|
+
export declare function createBundledReferenceMap<TApi extends Api>(provider: Parameters<typeof getBundledModels>[0]): Map<string, ModelSpec<TApi>>;
|
|
11
|
+
type ProviderReferenceSource<TApi extends Api> = Map<string, ModelSpec<TApi>> | (() => Map<string, ModelSpec<TApi>>);
|
|
12
|
+
export declare function createReferenceResolver<TApi extends Api>(providerReferenceSource: ProviderReferenceSource<TApi>): (modelId: string) => ModelSpec<TApi> | undefined;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ModelCacheProviderIdOptions {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function getDefaultModelDiscoveryBaseUrl(providerId: string): string | undefined;
|
|
6
|
+
/** Resolve an Ollama model-cache namespace scoped to the normalized discovery endpoint. */
|
|
7
|
+
export declare function resolveOllamaModelCacheProviderId(providerId: string, baseUrl?: string): string;
|
|
8
|
+
/** Resolve the cache namespace used by a provider's model-manager options without constructing those options. */
|
|
9
|
+
export declare function resolveModelCacheProviderId(providerId: string, options?: ModelCacheProviderIdOptions): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ModelManagerOptions } from "../model-manager.js";
|
|
2
|
+
import type { Api, FetchImpl } from "../types.js";
|
|
3
|
+
/** Config passed to a provider's runtime model-manager factory. */
|
|
4
|
+
export type ModelManagerConfig = {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
fetch?: FetchImpl;
|
|
8
|
+
/** The supplied fetch already applies provider-specific authentication. */
|
|
9
|
+
authenticated?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Catalog discovery configuration for providers that support endpoint-based model listing. */
|
|
12
|
+
export interface CatalogDiscoveryConfig {
|
|
13
|
+
/** Human-readable name for log messages. */
|
|
14
|
+
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Environment variables to check for API keys during catalog generation.
|
|
17
|
+
* Defaults to the entry-level `envVars` when omitted.
|
|
18
|
+
*/
|
|
19
|
+
envVars?: readonly string[];
|
|
20
|
+
/** OAuth provider for credential refresh during catalog generation. */
|
|
21
|
+
oauthProvider?: string;
|
|
22
|
+
/** When true, catalog discovery proceeds even without credentials. */
|
|
23
|
+
allowUnauthenticated?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Unified provider descriptor used by both runtime discovery and catalog generation. */
|
|
26
|
+
export interface ProviderDescriptor {
|
|
27
|
+
providerId: string;
|
|
28
|
+
createModelManagerOptions(config: ModelManagerConfig): ModelManagerOptions<Api>;
|
|
29
|
+
/** Preferred model ID when no explicit selection is made. */
|
|
30
|
+
defaultModel: string;
|
|
31
|
+
/** When true, the runtime creates a model manager even without a valid API key (e.g. ollama). */
|
|
32
|
+
allowUnauthenticated?: boolean;
|
|
33
|
+
/** When true, successful runtime discovery replaces bundled provider models instead of merging fallback-only IDs. */
|
|
34
|
+
dynamicModelsAuthoritative?: boolean;
|
|
35
|
+
/** Catalog discovery configuration. Only providers with this field participate in generate-models.ts. */
|
|
36
|
+
catalogDiscovery?: CatalogDiscoveryConfig;
|
|
37
|
+
}
|
|
38
|
+
/** A provider descriptor that has catalog discovery configured. */
|
|
39
|
+
export type CatalogProviderDescriptor = ProviderDescriptor & {
|
|
40
|
+
catalogDiscovery: CatalogDiscoveryConfig;
|
|
41
|
+
};
|
|
42
|
+
/** Type guard for descriptors with catalog discovery. */
|
|
43
|
+
export declare function isCatalogDescriptor(d: ProviderDescriptor): d is CatalogProviderDescriptor;
|
|
44
|
+
/** Whether catalog discovery may run without provider credentials. */
|
|
45
|
+
export declare function allowsUnauthenticatedCatalogDiscovery(descriptor: CatalogProviderDescriptor): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* One model provider's catalog-side description. The auth half of a provider
|
|
48
|
+
* (env keys, OAuth login/refresh flows) lives in `@linxiraos/pi-ai`'s registry;
|
|
49
|
+
* the catalog table below is the single source of truth for ids, default
|
|
50
|
+
* models, and discovery wiring.
|
|
51
|
+
*
|
|
52
|
+
* - Every entry is a member of `KnownProvider`.
|
|
53
|
+
* - `createModelManagerOptions` present (and not `specialModelManager`) ⇒
|
|
54
|
+
* appears in `PROVIDER_DESCRIPTORS` for runtime model discovery.
|
|
55
|
+
* - \`catalogDiscovery\` present ⇒ participates in \`generate-models.ts\`.
|
|
56
|
+
*/
|
|
57
|
+
export interface ProviderCatalogEntry {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
/** Preferred model ID when no explicit selection is made. */
|
|
60
|
+
readonly defaultModel: string;
|
|
61
|
+
/** Environment variables consulted (in order) for the provider's runtime API-key env fallback. */
|
|
62
|
+
readonly envVars?: readonly string[];
|
|
63
|
+
/** Runtime model-manager factory. Omitted for catalog-only providers. */
|
|
64
|
+
readonly createModelManagerOptions?: (config: ModelManagerConfig) => ModelManagerOptions<Api>;
|
|
65
|
+
/** When true, the runtime creates a model manager even without a valid API key. */
|
|
66
|
+
readonly allowUnauthenticated?: boolean;
|
|
67
|
+
/** When true, successful runtime discovery replaces bundled provider models. */
|
|
68
|
+
readonly dynamicModelsAuthoritative?: boolean;
|
|
69
|
+
/** Catalog discovery configuration for generate-models.ts. */
|
|
70
|
+
readonly catalogDiscovery?: CatalogDiscoveryConfig;
|
|
71
|
+
/**
|
|
72
|
+
* Built bespoke by the coding-agent runtime (OAuth-token-driven managers);
|
|
73
|
+
* excluded from `PROVIDER_DESCRIPTORS` even though models are discoverable.
|
|
74
|
+
*/
|
|
75
|
+
readonly specialModelManager?: boolean;
|
|
76
|
+
}
|