@rigelbuild/omp-catalog 18.0.3
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 +1204 -0
- package/LICENSE +22 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.txt +22909 -0
- package/dist/types/build.d.ts +19 -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 +28 -0
- package/dist/types/discovery/antigravity.d.ts +70 -0
- package/dist/types/discovery/codex.d.ts +36 -0
- package/dist/types/discovery/cursor-proto.d.ts +5368 -0
- package/dist/types/discovery/cursor.d.ts +23 -0
- package/dist/types/discovery/devin-proto.d.ts +1549 -0
- package/dist/types/discovery/devin.d.ts +24 -0
- package/dist/types/discovery/gemini-cli.d.ts +33 -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 +7 -0
- package/dist/types/discovery/openai-compatible.d.ts +89 -0
- package/dist/types/discovery/protobuf.d.ts +102 -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 +169 -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 +239 -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 +19 -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 +70 -0
- package/dist/types/model-tokenizer.d.ts +8 -0
- package/dist/types/models.d.ts +14 -0
- package/dist/types/openai-pricing.d.ts +17 -0
- package/dist/types/provider-models/bundled-references.d.ts +13 -0
- package/dist/types/provider-models/cache-provider-id.d.ts +11 -0
- package/dist/types/provider-models/descriptor-types.d.ts +76 -0
- package/dist/types/provider-models/descriptors.d.ts +505 -0
- package/dist/types/provider-models/google.d.ts +29 -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 +646 -0
- package/dist/types/provider-models/special.d.ts +53 -0
- package/dist/types/types.d.ts +876 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/variant-collapse.d.ts +137 -0
- package/dist/types/wire/alibaba-token-plan.d.ts +22 -0
- package/dist/types/wire/codex.d.ts +66 -0
- package/dist/types/wire/coreweave.d.ts +12 -0
- package/dist/types/wire/gemini-headers.d.ts +62 -0
- package/dist/types/wire/github-copilot.d.ts +47 -0
- package/dist/types/wire/image-fetchers.d.ts +76 -0
- package/package.json +102 -0
- package/src/build.ts +103 -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 +864 -0
- package/src/discovery/antigravity.ts +257 -0
- package/src/discovery/codex.ts +456 -0
- package/src/discovery/cursor-proto.ts +8329 -0
- package/src/discovery/cursor.ts +409 -0
- package/src/discovery/devin-proto.ts +2037 -0
- package/src/discovery/devin.ts +152 -0
- package/src/discovery/gemini-cli.ts +198 -0
- package/src/discovery/gemini.ts +260 -0
- package/src/discovery/gitlab-duo-workflow.ts +859 -0
- package/src/discovery/index.ts +7 -0
- package/src/discovery/openai-compatible.ts +266 -0
- package/src/discovery/protobuf.ts +1073 -0
- package/src/effort.ts +18 -0
- package/src/fireworks-model-id.ts +50 -0
- package/src/hosts.ts +178 -0
- package/src/identity/bundled.ts +28 -0
- package/src/identity/classify.ts +242 -0
- package/src/identity/dialect.ts +42 -0
- package/src/identity/family.ts +477 -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 +19 -0
- package/src/model-cache.ts +346 -0
- package/src/model-manager.ts +683 -0
- package/src/model-thinking.ts +925 -0
- package/src/model-tokenizer.ts +75 -0
- package/src/models.json +304657 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +108 -0
- package/src/openai-pricing.ts +29 -0
- package/src/provider-models/bundled-references.ts +87 -0
- package/src/provider-models/cache-provider-id.ts +97 -0
- package/src/provider-models/descriptor-types.ts +85 -0
- package/src/provider-models/descriptors.ts +585 -0
- package/src/provider-models/google.ts +117 -0
- package/src/provider-models/index.ts +7 -0
- package/src/provider-models/ollama.ts +204 -0
- package/src/provider-models/openai-compat.ts +6405 -0
- package/src/provider-models/special.ts +213 -0
- package/src/types.ts +1032 -0
- package/src/utils.ts +69 -0
- package/src/variant-collapse.ts +1555 -0
- package/src/wire/alibaba-token-plan.ts +54 -0
- package/src/wire/codex.ts +117 -0
- package/src/wire/coreweave.ts +51 -0
- package/src/wire/gemini-headers.ts +135 -0
- package/src/wire/github-copilot.ts +147 -0
- package/src/wire/image-fetchers.ts +159 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FetchImpl, ModelSpec } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for fetching dynamic Devin (Codeium Cascade) models from `GetCliModelConfigs`.
|
|
4
|
+
*/
|
|
5
|
+
export interface DevinModelDiscoveryOptions {
|
|
6
|
+
/** Codeium session token carried inside protobuf `Metadata.apiKey`. */
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
/** Optional Codeium API base URL override. */
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/** Optional request timeout in milliseconds (default 5000). */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
/** Optional caller abort signal, combined with the internal timeout. */
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
/** Optional fetch implementation for request-debug/proxy/test transports. */
|
|
15
|
+
fetch?: FetchImpl;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Fetches Devin models through the `GetCliModelConfigs` unary Connect RPC and
|
|
19
|
+
* normalizes them into canonical model entries.
|
|
20
|
+
*
|
|
21
|
+
* Returns `null` on request/decode failures.
|
|
22
|
+
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fetchDevinModels(options: DevinModelDiscoveryOptions): Promise<ModelSpec<"devin-agent">[] | null>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ModelSpec } from "../types.js";
|
|
2
|
+
import { type VariantCollapseTable } from "../variant-collapse.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options for the Gemini CLI quota-based discovery fallback.
|
|
5
|
+
*/
|
|
6
|
+
export interface FetchGeminiCliQuotaModelsOptions {
|
|
7
|
+
/** OAuth access token sent as `Authorization: Bearer <token>`. */
|
|
8
|
+
token: string;
|
|
9
|
+
/** Cloud Code Assist endpoint. Defaults to `https://cloudcode-pa.googleapis.com`. */
|
|
10
|
+
endpoint?: string;
|
|
11
|
+
/** Pre-resolved GCP project id; otherwise discovered via `loadCodeAssist`. */
|
|
12
|
+
projectId?: string;
|
|
13
|
+
/** Optional abort signal for request cancellation. */
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
/** Optional fetch implementation override for tests. */
|
|
16
|
+
fetcher?: typeof fetch;
|
|
17
|
+
/** Effort-tier collapse table applied to the discovered list. */
|
|
18
|
+
collapseTable?: VariantCollapseTable;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Discovers the Gemini models available to a `google-gemini-cli` credential via
|
|
22
|
+
* the account's own `retrieveUserQuota` endpoint on Cloud Code Assist.
|
|
23
|
+
*
|
|
24
|
+
* This is the fallback for accounts whose credential is not authorized for the
|
|
25
|
+
* Antigravity `fetchAvailableModels` endpoint (e.g. Gemini Code Assist Standard
|
|
26
|
+
* tiers, which return HTTP 403 there). Quota buckets carry only model ids, so
|
|
27
|
+
* metadata is filled from the bundled catalog where the id is known and
|
|
28
|
+
* synthesized with Gemini CLI defaults otherwise.
|
|
29
|
+
*
|
|
30
|
+
* Returns `null` on network/payload/auth failure (the caller keeps the bundled
|
|
31
|
+
* catalog). Returns `[]` when the quota response lists no usable Gemini models.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchGeminiCliQuotaModels(options: FetchGeminiCliQuotaModelsOptions): Promise<ModelSpec<"google-gemini-cli">[] | null>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FetchImpl, ModelSpec } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for Google Generative AI model discovery.
|
|
4
|
+
*/
|
|
5
|
+
export interface GeminiDiscoveryOptions {
|
|
6
|
+
/** API key for the Google Generative AI public endpoint. */
|
|
7
|
+
apiKey: string;
|
|
8
|
+
/** Optional endpoint override for testing or proxying. */
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
/** Optional requested page size for model listing. */
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
/** Maximum number of pages to request before stopping pagination. */
|
|
13
|
+
maxPages?: number;
|
|
14
|
+
/** Optional abort signal for HTTP requests. */
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
/** Optional fetch implementation override for tests. */
|
|
17
|
+
fetch?: FetchImpl;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetches and normalizes Google Generative AI models from the public models endpoint.
|
|
21
|
+
*
|
|
22
|
+
* Returns `null` on transport/protocol failures.
|
|
23
|
+
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fetchGeminiModels(options: GeminiDiscoveryOptions): Promise<ModelSpec<"google-generative-ai">[] | null>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FetchImpl, ModelSpec } from "../types.js";
|
|
2
|
+
type GitLabDuoWorkflowCandidateSource = "override" | "project" | "remote" | "group";
|
|
3
|
+
export interface GitLabDuoWorkflowModelRef {
|
|
4
|
+
name: string;
|
|
5
|
+
ref: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* GitLab Duo Workflow model/namespace discovery configuration.
|
|
9
|
+
*/
|
|
10
|
+
export interface GitLabDuoWorkflowDiscoveryConfig {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
fetch?: FetchImpl;
|
|
14
|
+
namespaceId?: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
projectPath?: string;
|
|
17
|
+
cwd?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GitLabDuoWorkflowNamespaceSelection {
|
|
20
|
+
rootNamespaceId: string;
|
|
21
|
+
namespacePath?: string;
|
|
22
|
+
projectPath?: string;
|
|
23
|
+
source: GitLabDuoWorkflowCandidateSource;
|
|
24
|
+
}
|
|
25
|
+
export declare function discoverGitLabDuoWorkflowNamespace(config: GitLabDuoWorkflowDiscoveryConfig): Promise<GitLabDuoWorkflowNamespaceSelection>;
|
|
26
|
+
export declare function discoverGitLabDuoWorkflowRuntimeNamespace(config: GitLabDuoWorkflowDiscoveryConfig): Promise<GitLabDuoWorkflowNamespaceSelection>;
|
|
27
|
+
export declare function fetchGitLabDuoWorkflowModels(config: GitLabDuoWorkflowDiscoveryConfig): Promise<readonly ModelSpec<"gitlab-duo-agent">[] | null>;
|
|
28
|
+
export declare function buildGitLabDuoWorkflowModelSpec(model: GitLabDuoWorkflowModelRef, baseUrl?: string, rootNamespaceId?: string): ModelSpec<"gitlab-duo-agent">;
|
|
29
|
+
export declare function buildGitLabDuoWorkflowFallbackModel(id?: string, name?: string, baseUrl?: string): ModelSpec<"gitlab-duo-agent">;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Api, FetchImpl, ModelSpec, Provider } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default hard deadline applied to an OpenAI-compatible `/models` probe when
|
|
4
|
+
* the caller supplies neither an `AbortSignal` nor an explicit `timeoutMs`.
|
|
5
|
+
*
|
|
6
|
+
* Built-in provider model managers (openrouter, xAI, DeepSeek, …) call
|
|
7
|
+
* {@link fetchOpenAICompatibleModels} with no timeout, so without this bound a
|
|
8
|
+
* stalled endpoint left the request pending forever and blocked startup's
|
|
9
|
+
* awaited `resolveModelDiscoveryFallback` discovery pass indefinitely
|
|
10
|
+
* (issue #8315). 10s matches the coding-agent's remote-discovery budget.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_OPENAI_COMPATIBLE_DISCOVERY_TIMEOUT_MS = 10000;
|
|
13
|
+
/**
|
|
14
|
+
* Minimal OpenAI-style model entry shape consumed by discovery.
|
|
15
|
+
*
|
|
16
|
+
* Providers may return additional fields; this type only captures
|
|
17
|
+
* fields that are useful for generic normalization.
|
|
18
|
+
*/
|
|
19
|
+
export interface OpenAICompatibleModelRecord {
|
|
20
|
+
id?: unknown;
|
|
21
|
+
name?: unknown;
|
|
22
|
+
object?: unknown;
|
|
23
|
+
owned_by?: unknown;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tolerant envelope for OpenAI-compatible `/models` responses.
|
|
28
|
+
*
|
|
29
|
+
* Common providers return `{ data: [...] }`, but variants such as
|
|
30
|
+
* `{ models: [...] }`, `{ result: [...] }`, or direct arrays are also
|
|
31
|
+
* accepted during extraction.
|
|
32
|
+
*/
|
|
33
|
+
export interface OpenAICompatibleModelsEnvelope {
|
|
34
|
+
data?: unknown;
|
|
35
|
+
models?: unknown;
|
|
36
|
+
result?: unknown;
|
|
37
|
+
items?: unknown;
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Context passed to custom OpenAI-compatible model mappers.
|
|
42
|
+
*/
|
|
43
|
+
export interface OpenAICompatibleModelMapperContext<TApi extends Api> {
|
|
44
|
+
api: TApi;
|
|
45
|
+
provider: Provider;
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for fetching and normalizing OpenAI-compatible `/models` catalogs.
|
|
50
|
+
*/
|
|
51
|
+
export interface FetchOpenAICompatibleModelsOptions<TApi extends Api> {
|
|
52
|
+
/** API type assigned to normalized models. */
|
|
53
|
+
api: TApi;
|
|
54
|
+
/** Provider id assigned to normalized models. */
|
|
55
|
+
provider: Provider;
|
|
56
|
+
/** Provider base URL used for both fetch and normalized model records. */
|
|
57
|
+
baseUrl: string;
|
|
58
|
+
/** Optional bearer token for Authorization header. */
|
|
59
|
+
apiKey?: string;
|
|
60
|
+
/** Additional request headers. */
|
|
61
|
+
headers?: Record<string, string>;
|
|
62
|
+
/** Optional AbortSignal for request cancellation; caller owns its lifecycle. */
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
/**
|
|
65
|
+
* Optional cancellable request timeout used when `signal` is omitted.
|
|
66
|
+
* Defaults to {@link DEFAULT_OPENAI_COMPATIBLE_DISCOVERY_TIMEOUT_MS} so a
|
|
67
|
+
* stalled endpoint can never hang discovery indefinitely.
|
|
68
|
+
*/
|
|
69
|
+
timeoutMs?: number;
|
|
70
|
+
/** Optional fetch implementation override for testing/custom runtimes. */
|
|
71
|
+
fetch?: FetchImpl;
|
|
72
|
+
/**
|
|
73
|
+
* Optional post-normalization filter.
|
|
74
|
+
* Return false to skip a model.
|
|
75
|
+
*/
|
|
76
|
+
filterModel?: (entry: OpenAICompatibleModelRecord, model: ModelSpec<TApi>) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Optional mapper override for provider-specific quirks.
|
|
79
|
+
* Return null to skip a model.
|
|
80
|
+
*/
|
|
81
|
+
mapModel?: (entry: OpenAICompatibleModelRecord, defaults: ModelSpec<TApi>, context: OpenAICompatibleModelMapperContext<TApi>) => ModelSpec<TApi> | null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Fetches and normalizes an OpenAI-compatible `/models` catalog.
|
|
85
|
+
*
|
|
86
|
+
* Returns `null` on transport/protocol failures.
|
|
87
|
+
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
88
|
+
*/
|
|
89
|
+
export declare function fetchOpenAICompatibleModels<TApi extends Api>(options: FetchOpenAICompatibleModelsOptions<TApi>): Promise<ModelSpec<TApi>[] | null>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-performance, zero-builder protobuf wire codecs for @oh-my-pi/pi-catalog.
|
|
3
|
+
*
|
|
4
|
+
* Schemas are declared as static IR descriptors with near-zero module load overhead
|
|
5
|
+
* and lazy compilation on first encode/decode/create invocation.
|
|
6
|
+
*/
|
|
7
|
+
/** JSON values carried by `google.protobuf.Value` fields. */
|
|
8
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
9
|
+
[key: string]: JsonValue;
|
|
10
|
+
};
|
|
11
|
+
/** An unrecognised wire field retained for forward-compatible round-trips. */
|
|
12
|
+
export interface ProtoUnknownField {
|
|
13
|
+
no: number;
|
|
14
|
+
wireType: number;
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
/** Shared internal metadata present on every decoded protocol message. */
|
|
18
|
+
export interface ProtoMessage {
|
|
19
|
+
$typeName?: string;
|
|
20
|
+
$unknown?: ProtoUnknownField[];
|
|
21
|
+
}
|
|
22
|
+
/** A bidirectional codec for one protobuf message type. */
|
|
23
|
+
export interface MessageCodec<T extends ProtoMessage = ProtoMessage> {
|
|
24
|
+
(value: T): Uint8Array;
|
|
25
|
+
(value: Uint8Array): T;
|
|
26
|
+
/** Creates a message with protobuf defaults for omitted fields. */
|
|
27
|
+
create(value?: Partial<T>): T;
|
|
28
|
+
/** Encodes one message into protobuf wire bytes. */
|
|
29
|
+
encode(value: T): Uint8Array;
|
|
30
|
+
/** Decodes one protobuf message from wire bytes. */
|
|
31
|
+
decode(value: Uint8Array): T;
|
|
32
|
+
/** Converts a message to its protobuf JSON representation. */
|
|
33
|
+
toJson(value: T): JsonValue;
|
|
34
|
+
}
|
|
35
|
+
/** Infers a message shape from a codec result. */
|
|
36
|
+
export type InferMessage<TCodec> = TCodec extends MessageCodec<infer TMessage> ? TMessage : never;
|
|
37
|
+
/** Erases a referenced message's concrete shape for static field descriptors. */
|
|
38
|
+
export interface MessageReference {
|
|
39
|
+
encode(value: unknown): Uint8Array;
|
|
40
|
+
decode(value: Uint8Array): ProtoMessage;
|
|
41
|
+
toJson(value: unknown): JsonValue;
|
|
42
|
+
}
|
|
43
|
+
export type ScalarKind = "bool" | "bytes" | "double" | "enum" | "float" | "int32" | "int64" | "string" | "uint32" | "uint64";
|
|
44
|
+
export type WireType = 0 | 1 | 2 | 5;
|
|
45
|
+
export interface ScalarFieldDesc {
|
|
46
|
+
readonly no: number;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly kind: ScalarKind;
|
|
49
|
+
readonly optional?: boolean;
|
|
50
|
+
readonly repeat?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface MessageFieldDesc {
|
|
53
|
+
readonly no: number;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly kind: "message";
|
|
56
|
+
readonly T: () => MessageReference;
|
|
57
|
+
readonly repeat?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface EnumFieldDesc {
|
|
60
|
+
readonly no: number;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly kind: "enum";
|
|
63
|
+
readonly optional?: boolean;
|
|
64
|
+
readonly repeat?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface MapFieldDesc {
|
|
67
|
+
readonly no: number;
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly kind: "map";
|
|
70
|
+
readonly K: "string";
|
|
71
|
+
readonly V: ScalarKind | (() => MessageReference);
|
|
72
|
+
}
|
|
73
|
+
export type VariantDesc = {
|
|
74
|
+
readonly no: number;
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly kind: ScalarKind;
|
|
77
|
+
} | {
|
|
78
|
+
readonly no: number;
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly kind: "message";
|
|
81
|
+
readonly T: () => MessageReference;
|
|
82
|
+
};
|
|
83
|
+
export interface OneofFieldDesc {
|
|
84
|
+
readonly kind: "oneof";
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly variants: readonly VariantDesc[];
|
|
87
|
+
}
|
|
88
|
+
export type FieldDesc = ScalarFieldDesc | MessageFieldDesc | EnumFieldDesc | MapFieldDesc | OneofFieldDesc;
|
|
89
|
+
/** Creates a high-performance, lazy protobuf message codec from an IR field descriptor list. */
|
|
90
|
+
export declare function pb<T extends ProtoMessage = ProtoMessage>(typeName: string, fields?: readonly FieldDesc[]): MessageCodec<T>;
|
|
91
|
+
/** Creates a message using its codec's protobuf defaults. */
|
|
92
|
+
export declare function create<TMessage extends ProtoMessage>(codec: MessageCodec<TMessage>, value?: Partial<TMessage>): TMessage;
|
|
93
|
+
/** Encodes a message using its codec. */
|
|
94
|
+
export declare function toBinary<TMessage extends ProtoMessage>(codec: MessageCodec<TMessage>, value: TMessage): Uint8Array;
|
|
95
|
+
/** Decodes wire bytes using a message codec. */
|
|
96
|
+
export declare function fromBinary<TMessage extends ProtoMessage>(codec: MessageCodec<TMessage>, value: Uint8Array): TMessage;
|
|
97
|
+
/** Converts a message to protobuf JSON using its codec. */
|
|
98
|
+
export declare function toJson<TMessage extends ProtoMessage>(codec: MessageCodec<TMessage>, value: TMessage): JsonValue;
|
|
99
|
+
/** Encodes a JSON value as `google.protobuf.Value`. */
|
|
100
|
+
export declare function encodeJsonValue(value: JsonValue): Uint8Array;
|
|
101
|
+
/** Decodes `google.protobuf.Value` wire bytes into a JSON value. */
|
|
102
|
+
export declare function decodeJsonValue(value: Uint8Array): JsonValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** User-facing thinking levels, ordered least to most intensive. */
|
|
2
|
+
export declare const enum Effort {
|
|
3
|
+
Minimal = "minimal",
|
|
4
|
+
Low = "low",
|
|
5
|
+
Medium = "medium",
|
|
6
|
+
High = "high",
|
|
7
|
+
XHigh = "xhigh",
|
|
8
|
+
Max = "max"
|
|
9
|
+
}
|
|
10
|
+
export declare const THINKING_EFFORTS: readonly Effort[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function toFireworksPublicModelId(modelId: string): string;
|
|
2
|
+
export declare function toFireworksWireModelId(modelId: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Fire Pass exposes its Kimi K2.6 Turbo subscription through a dedicated router
|
|
5
|
+
* endpoint at `accounts/fireworks/routers/<id>` rather than the `models/` namespace.
|
|
6
|
+
* We keep a friendly public id (e.g. `kimi-k2.6-turbo`) in the catalog and translate
|
|
7
|
+
* to the wire form (`accounts/fireworks/routers/kimi-k2p6-turbo`) at request time.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toFirepassPublicModelId(modelId: string): string;
|
|
10
|
+
export declare function toFirepassWireModelId(modelId: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Public-id suffix marking a Fireworks "Fast" serving-path variant. Fast is a
|
|
13
|
+
* higher-throughput route (100+ tok/s) exposed under a dedicated router id
|
|
14
|
+
* (`accounts/fireworks/routers/<id>-fast`), not a separate model — same weights,
|
|
15
|
+
* higher price, no Priority tier. We keep a friendly `<id>-fast` public id and
|
|
16
|
+
* translate it to the router wire form at request time (compat
|
|
17
|
+
* `wireModelIdMode: "firepass"`). See https://docs.fireworks.ai/serverless/serving-paths.
|
|
18
|
+
*/
|
|
19
|
+
export declare const FIREWORKS_FAST_SUFFIX = "-fast";
|
|
20
|
+
/** True for a Fireworks public model id that selects the Fast serving path. */
|
|
21
|
+
export declare function isFireworksFastModelId(modelId: string): boolean;
|
|
22
|
+
/** Strip the Fast suffix to recover the base (Standard-tier) model id. */
|
|
23
|
+
export declare function toFireworksBaseModelId(modelId: string): string;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Known model-endpoint host classification — the single vocabulary for the
|
|
3
|
+
* `provider === id || baseUrl.includes(marker)` idiom that gates wire-level
|
|
4
|
+
* behavior (compat detection, routing, header shaping, watchdog floors).
|
|
5
|
+
*
|
|
6
|
+
* Markers are case-insensitive substrings matched against the base URL, NOT
|
|
7
|
+
* parsed hostnames: proxies regularly embed the upstream host in a path
|
|
8
|
+
* segment, and the historical call sites all used substring semantics.
|
|
9
|
+
* Callers that need strict hostname matching — where a substring false
|
|
10
|
+
* positive is dangerous, e.g. the Anthropic official-endpoint OAuth gate —
|
|
11
|
+
* parse the URL and compare the hostname themselves.
|
|
12
|
+
*/
|
|
13
|
+
export declare const KNOWN_HOSTS: {
|
|
14
|
+
readonly openai: {
|
|
15
|
+
readonly providers: readonly ["openai"];
|
|
16
|
+
readonly urlMarkers: readonly ["api.openai.com"];
|
|
17
|
+
};
|
|
18
|
+
readonly azureOpenAI: {
|
|
19
|
+
readonly providers: readonly ["azure"];
|
|
20
|
+
readonly urlMarkers: readonly [".openai.azure.com", "azure.com/openai", "models.inference.ai.azure.com"];
|
|
21
|
+
};
|
|
22
|
+
readonly openrouter: {
|
|
23
|
+
readonly providers: readonly ["openrouter"];
|
|
24
|
+
readonly urlMarkers: readonly ["openrouter.ai"];
|
|
25
|
+
};
|
|
26
|
+
readonly vercelAIGateway: {
|
|
27
|
+
readonly providers: readonly ["vercel-ai-gateway"];
|
|
28
|
+
readonly urlMarkers: readonly ["ai-gateway.vercel.sh"];
|
|
29
|
+
};
|
|
30
|
+
readonly githubCopilot: {
|
|
31
|
+
readonly providers: readonly ["github-copilot"];
|
|
32
|
+
readonly urlMarkers: readonly ["githubcopilot.com", "copilot-api."];
|
|
33
|
+
};
|
|
34
|
+
readonly anthropic: {
|
|
35
|
+
readonly providers: readonly ["anthropic"];
|
|
36
|
+
readonly urlMarkers: readonly ["api.anthropic.com"];
|
|
37
|
+
};
|
|
38
|
+
/** DeepSeek's first-party API only — gates direct-API quirks (max_tokens field, thinking extraBody). */
|
|
39
|
+
readonly deepseekDirect: {
|
|
40
|
+
readonly providers: readonly ["deepseek"];
|
|
41
|
+
readonly urlMarkers: readonly ["api.deepseek.com"];
|
|
42
|
+
};
|
|
43
|
+
/** Any DeepSeek-operated host (first-party API, web-chat fronts). Wider than `deepseekDirect` on purpose. */
|
|
44
|
+
readonly deepseekFamily: {
|
|
45
|
+
readonly providers: readonly ["deepseek"];
|
|
46
|
+
readonly urlMarkers: readonly ["deepseek.com"];
|
|
47
|
+
};
|
|
48
|
+
readonly cerebras: {
|
|
49
|
+
readonly providers: readonly ["cerebras"];
|
|
50
|
+
readonly urlMarkers: readonly ["cerebras.ai"];
|
|
51
|
+
};
|
|
52
|
+
readonly zai: {
|
|
53
|
+
readonly providers: readonly ["zai"];
|
|
54
|
+
readonly urlMarkers: readonly ["api.z.ai"];
|
|
55
|
+
};
|
|
56
|
+
readonly zhipu: {
|
|
57
|
+
readonly providers: readonly ["zhipu-coding-plan"];
|
|
58
|
+
readonly urlMarkers: readonly ["open.bigmodel.cn"];
|
|
59
|
+
};
|
|
60
|
+
readonly kilo: {
|
|
61
|
+
readonly providers: readonly ["kilo"];
|
|
62
|
+
readonly urlMarkers: readonly ["api.kilo.ai"];
|
|
63
|
+
};
|
|
64
|
+
readonly alibabaDashscope: {
|
|
65
|
+
readonly providers: readonly ["alibaba-coding-plan", "alibaba-token-plan"];
|
|
66
|
+
readonly urlMarkers: readonly ["dashscope", "token-plan."];
|
|
67
|
+
};
|
|
68
|
+
readonly umans: {
|
|
69
|
+
readonly providers: readonly ["umans"];
|
|
70
|
+
readonly urlMarkers: readonly ["api.code.umans.ai"];
|
|
71
|
+
};
|
|
72
|
+
readonly xiaomi: {
|
|
73
|
+
readonly providers: readonly ["xiaomi"];
|
|
74
|
+
readonly providerPrefixes: readonly ["xiaomi-token-plan-"];
|
|
75
|
+
readonly urlMarkers: readonly ["xiaomimimo.com"];
|
|
76
|
+
};
|
|
77
|
+
readonly xai: {
|
|
78
|
+
readonly providers: readonly ["xai", "xai-oauth"];
|
|
79
|
+
readonly urlMarkers: readonly ["api.x.ai"];
|
|
80
|
+
};
|
|
81
|
+
readonly mistral: {
|
|
82
|
+
readonly providers: readonly ["mistral"];
|
|
83
|
+
readonly urlMarkers: readonly ["mistral.ai"];
|
|
84
|
+
};
|
|
85
|
+
readonly together: {
|
|
86
|
+
readonly providers: readonly ["together"];
|
|
87
|
+
readonly urlMarkers: readonly ["api.together.xyz"];
|
|
88
|
+
};
|
|
89
|
+
readonly baseten: {
|
|
90
|
+
readonly providers: readonly ["baseten"];
|
|
91
|
+
readonly urlMarkers: readonly ["baseten.co"];
|
|
92
|
+
};
|
|
93
|
+
/** URL-only on purpose: the `fireworks`/`firepass` providers route per-model and not every model is Fireworks-shaped. */
|
|
94
|
+
readonly fireworks: {
|
|
95
|
+
readonly urlMarkers: readonly ["fireworks.ai"];
|
|
96
|
+
};
|
|
97
|
+
readonly groq: {
|
|
98
|
+
readonly providers: readonly ["groq"];
|
|
99
|
+
readonly urlMarkers: readonly ["api.groq.com"];
|
|
100
|
+
};
|
|
101
|
+
readonly minimax: {
|
|
102
|
+
readonly providers: readonly ["minimax", "minimax-code", "minimax-code-cn"];
|
|
103
|
+
readonly urlMarkers: readonly ["api.minimax.io", "api.minimaxi.com"];
|
|
104
|
+
};
|
|
105
|
+
readonly qwenPortal: {
|
|
106
|
+
readonly providers: readonly ["qwen-portal"];
|
|
107
|
+
readonly urlMarkers: readonly ["portal.qwen.ai"];
|
|
108
|
+
};
|
|
109
|
+
/** NVIDIA NIM (`integrate.api.nvidia.com`). Qwen NIM endpoints take `chat_template_kwargs.enable_thinking`, never top-level `enable_thinking`. */
|
|
110
|
+
readonly nvidia: {
|
|
111
|
+
readonly providers: readonly ["nvidia"];
|
|
112
|
+
readonly urlMarkers: readonly ["integrate.api.nvidia.com"];
|
|
113
|
+
};
|
|
114
|
+
/** Venice AI (`api.venice.ai`). OpenAI-compatible; drives reasoning via top-level `reasoning_effort` (and `venice_parameters.disable_thinking`), and rejects DashScope's top-level `enable_thinking` with a 400 (`additionalProperties: false` request schema). */
|
|
115
|
+
readonly venice: {
|
|
116
|
+
readonly providers: readonly ["venice"];
|
|
117
|
+
readonly urlMarkers: readonly ["api.venice.ai"];
|
|
118
|
+
};
|
|
119
|
+
readonly moonshotNative: {
|
|
120
|
+
readonly providers: readonly ["moonshot", "kimi-code"];
|
|
121
|
+
readonly urlMarkers: readonly ["api.moonshot.ai", "api.kimi.com"];
|
|
122
|
+
};
|
|
123
|
+
/** Google AI Studio's OpenAI-compatible shim (`/v1beta/openai`) — a subset of chat-completions; rejects `store` with a 400. Native Gemini uses `google-generative-ai` api instead. */
|
|
124
|
+
readonly googleAistudio: {
|
|
125
|
+
readonly providers: readonly [];
|
|
126
|
+
readonly urlMarkers: readonly ["generativelanguage.googleapis.com"];
|
|
127
|
+
};
|
|
128
|
+
readonly opencode: {
|
|
129
|
+
readonly providers: readonly ["opencode-go", "opencode-zen"];
|
|
130
|
+
readonly urlMarkers: readonly ["opencode.ai"];
|
|
131
|
+
};
|
|
132
|
+
/** ZenMux's Anthropic-compatible proxy (`zenmux.ai/api/anthropic`) forwards to signature-enforcing Anthropic. */
|
|
133
|
+
readonly zenmux: {
|
|
134
|
+
readonly providers: readonly ["zenmux"];
|
|
135
|
+
readonly urlMarkers: readonly ["zenmux.ai"];
|
|
136
|
+
};
|
|
137
|
+
readonly chutes: {
|
|
138
|
+
readonly urlMarkers: readonly ["chutes.ai"];
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
export type KnownHost = keyof typeof KNOWN_HOSTS;
|
|
142
|
+
/** URL-only host check (for call sites that have no provider id, e.g. raw env config). */
|
|
143
|
+
export declare function hostMatchesUrl(baseUrl: string | undefined, host: KnownHost): boolean;
|
|
144
|
+
/** Provider-or-URL host check — the canonical `provider === id || baseUrl.includes(marker)` idiom. */
|
|
145
|
+
export declare function modelMatchesHost(model: {
|
|
146
|
+
provider: string;
|
|
147
|
+
baseUrl: string;
|
|
148
|
+
}, host: KnownHost): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Hostname for a Vertex AI GenerateContent / rawPredict / OpenAI-compat
|
|
151
|
+
* request for the given location.
|
|
152
|
+
*
|
|
153
|
+
* - `global` → global endpoint (`aiplatform.googleapis.com`)
|
|
154
|
+
* - `eu` / `us` multi-regions → REP endpoints (`aiplatform.{eu|us}.rep.googleapis.com`)
|
|
155
|
+
* - every other location → regional (`{location}-aiplatform.googleapis.com`)
|
|
156
|
+
*
|
|
157
|
+
* Multi-region codes do NOT follow the regional `{location}-aiplatform` pattern;
|
|
158
|
+
* interpolating them that way yields hosts like `eu-aiplatform.googleapis.com`
|
|
159
|
+
* that 404.
|
|
160
|
+
*/
|
|
161
|
+
export declare function resolveVertexEndpointHost(location: string): string;
|
|
162
|
+
/** Vertex AI express-mode OpenAI-compatible endpoint (`…/endpoints/openapi`). */
|
|
163
|
+
export declare function isVertexExpressOpenAIUrl(baseUrl: string): boolean;
|
|
164
|
+
/** Vertex AI Anthropic raw-predict endpoints (`:streamRawPredict` / `:rawPredict`). */
|
|
165
|
+
export declare function isVertexRawPredictUrl(baseUrl: string): boolean;
|
|
166
|
+
/** Azure OpenAI deployment-scoped path (`…/deployments/<name>/…`). */
|
|
167
|
+
export declare function isAzureDeploymentsUrl(baseUrl: string): boolean;
|
|
168
|
+
/** Alibaba DashScope consumer `compatible-mode` endpoint (rejects multimodal arrays for some text-only SKUs). */
|
|
169
|
+
export declare function isDashscopeCompatibleModeUrl(baseUrl: string): boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-id classification: parse a model id into its family (gemini / anthropic /
|
|
3
|
+
* openai), kind/variant, and version. This is the shared layer both catalog
|
|
4
|
+
* policy rules (`model-thinking.ts`) and downstream consumers build on —
|
|
5
|
+
* classification lives here, the rules that consume it stay with their domain.
|
|
6
|
+
*/
|
|
7
|
+
export type SemVer = {
|
|
8
|
+
major: number;
|
|
9
|
+
minor: number;
|
|
10
|
+
patch: number;
|
|
11
|
+
};
|
|
12
|
+
export type GeminiKind = "pro" | "flash";
|
|
13
|
+
export type AnthropicKind = "opus" | "sonnet" | "fable" | "mythos";
|
|
14
|
+
export type OpenAIVariant = "base" | "codex" | "codex-max" | "codex-mini" | "codex-spark" | "mini" | "max" | "nano";
|
|
15
|
+
export type GlmVariant = "base" | "air" | "turbo" | "flash" | "flashx" | "preview";
|
|
16
|
+
export interface GeminiModel {
|
|
17
|
+
family: "gemini";
|
|
18
|
+
kind: GeminiKind;
|
|
19
|
+
version: SemVer;
|
|
20
|
+
}
|
|
21
|
+
export interface AnthropicModel {
|
|
22
|
+
family: "anthropic";
|
|
23
|
+
kind: AnthropicKind;
|
|
24
|
+
version: SemVer;
|
|
25
|
+
}
|
|
26
|
+
export interface OpenAIModel {
|
|
27
|
+
family: "openai";
|
|
28
|
+
variant: OpenAIVariant;
|
|
29
|
+
version: SemVer;
|
|
30
|
+
}
|
|
31
|
+
export interface GlmModel {
|
|
32
|
+
family: "glm";
|
|
33
|
+
/** Suffix variant (`-air`, `-turbo`, `-flash`, `-flashx`, `-preview`); `base` when none. */
|
|
34
|
+
variant: GlmVariant;
|
|
35
|
+
/** Vision SKU — the `v` that attaches directly to the version (`glm-4v`, `glm-4.5v`). */
|
|
36
|
+
vision: boolean;
|
|
37
|
+
version: SemVer;
|
|
38
|
+
}
|
|
39
|
+
export interface UnknownModel {
|
|
40
|
+
family: "unknown";
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
export type ParsedModel = GeminiModel | AnthropicModel | OpenAIModel | UnknownModel;
|
|
44
|
+
export declare function bareModelId(modelId: string): string;
|
|
45
|
+
export declare function parseKnownModel(modelId: string): ParsedModel;
|
|
46
|
+
export declare const parseGeminiModel: (modelId: string) => GeminiModel | null;
|
|
47
|
+
export declare const parseAnthropicModel: (modelId: string) => AnthropicModel | null;
|
|
48
|
+
export declare const parseOpenAIModel: (modelId: string) => OpenAIModel | null;
|
|
49
|
+
/**
|
|
50
|
+
* Parse a GLM (Zhipu / Z.AI) model id into family + variant + vision + version.
|
|
51
|
+
* Shape: `glm-<version>[v][-<variant>]` — e.g. `glm-4.5`, `glm-4.5-air`,
|
|
52
|
+
* `glm-5-turbo`, `glm-4.5v`, `glm-5-preview`. The `v` (vision) attaches to the
|
|
53
|
+
* version; other variants are `-` suffixes. Standalone like `parseAnthropicModel`
|
|
54
|
+
* is used in family.ts — GLM needs no global thinking policy, so it stays out of
|
|
55
|
+
* `parseKnownModel`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const parseGlmModel: (modelId: string) => GlmModel | null;
|
|
58
|
+
export declare function isFableOrMythos(kind: AnthropicKind): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the parsed Anthropic model is part of the adaptive-thinking
|
|
61
|
+
* Claude generation at or above a specific capability threshold.
|
|
62
|
+
* - Opus has a configurable minimum version floor (e.g. "4.6", "4.7", "4.8").
|
|
63
|
+
* - Sonnet, Fable, and Mythos all require version 5 or higher.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isAnthropicAdaptiveGenAtLeast(parsed: AnthropicModel, opusMin: "4.6" | "4.7" | "4.8"): boolean;
|
|
66
|
+
export declare function parseSemVer(version: string): SemVer | null;
|
|
67
|
+
export declare function semverGte(left: SemVer | string, right: SemVer | string): boolean;
|
|
68
|
+
export declare function semverEqual(left: SemVer | string, right: SemVer | string): boolean;
|
|
69
|
+
export declare function compareSemVer(left: SemVer | string | null, right: SemVer | string | null): number;
|