@linxiraos/pi-catalog 1.4.6 → 1.4.9
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 +6 -2
- package/README.md +3 -3
- package/dist/types/build.d.ts +12 -4
- package/dist/types/compat/auth-ids.d.ts +2 -2
- package/dist/types/compat/catalog-policy.d.ts +6 -4
- package/dist/types/compat/factory-droid.d.ts +7 -1
- package/dist/types/compat/provider-ids.d.ts +1 -1
- package/dist/types/compat/resolve.d.ts +1 -1
- package/dist/types/compat/revision.d.ts +2 -0
- package/dist/types/compat/server-side-fallback.d.ts +6 -4
- package/dist/types/compat/types.d.ts +6 -2
- package/dist/types/discovery/codex.d.ts +4 -5
- package/dist/types/discovery/cursor-proto.d.ts +8 -0
- package/dist/types/discovery/openai-compatible.d.ts +6 -0
- package/dist/types/model-cache.d.ts +8 -0
- package/dist/types/model-catalog-format.d.ts +37 -0
- package/dist/types/model-manager.d.ts +11 -1
- package/dist/types/model-thinking.d.ts +4 -0
- package/dist/types/models.d.ts +22 -3
- package/dist/types/pricing.d.ts +66 -6
- package/dist/types/provider-models/openai-compat.d.ts +18 -13
- package/dist/types/types.d.ts +14 -19
- package/dist/types/utils.d.ts +8 -0
- package/dist/types/wire/codex.d.ts +1 -1
- package/package.json +6 -10
- package/src/build.d.ts +12 -4
- package/src/build.ts +50 -3
- package/src/compat/auth-ids.ts +5 -0
- package/src/compat/axes.ts +27 -9
- package/src/compat/catalog-policy.d.ts +9 -0
- package/src/compat/catalog-policy.ts +14 -10
- package/src/compat/collapse.ts +1 -1
- package/src/compat/factory-droid.d.ts +7 -1
- package/src/compat/factory-droid.ts +9 -1
- package/src/compat/provider-ids.d.ts +1 -1
- package/src/compat/provider-ids.ts +2 -0
- package/src/compat/resolve.d.ts +1 -1
- package/src/compat/resolve.ts +4 -5
- package/src/compat/revision.d.ts +2 -0
- package/src/compat/revision.ts +10 -0
- package/src/compat/rules/README.md +14 -12
- package/src/compat/rules/auth/_order.kdl +1 -1
- package/src/compat/rules/auth/mistral.kdl +4 -0
- package/src/compat/rules/auth/modular.kdl +9 -0
- package/src/compat/rules/auth/scaleway.kdl +17 -0
- package/src/compat/rules/auth/typesafe.kdl +2 -1
- package/src/compat/rules/classes/anthropic.kdl +5 -0
- package/src/compat/rules/classes/deepseek.kdl +3 -2
- package/src/compat/rules/classes/gemini.kdl +1 -1
- package/src/compat/rules/classes/openai.kdl +2 -2
- package/src/compat/rules/classes/xai.kdl +1 -1
- package/src/compat/rules/providers/anthropic.kdl +8 -4
- package/src/compat/rules/providers/cursor.kdl +10 -0
- package/src/compat/rules/providers/deepseek.kdl +2 -2
- package/src/compat/rules/providers/factory-droid.kdl +243 -13
- package/src/compat/rules/providers/google-vertex.kdl +3 -0
- package/src/compat/rules/providers/kimi-code.kdl +6 -0
- package/src/compat/rules/providers/mistral.kdl +8 -0
- package/src/compat/rules/providers/modular.kdl +35 -0
- package/src/compat/rules/providers/openai-codex.kdl +1 -1
- package/src/compat/rules/providers/sambanova.kdl +2 -0
- package/src/compat/rules/providers/scaleway.kdl +179 -0
- package/src/compat/rules/runtime/behavior.kdl +22 -6
- package/src/compat/rules.json +1 -1
- package/src/compat/server-side-fallback.d.ts +9 -0
- package/src/compat/server-side-fallback.ts +7 -5
- package/src/compat/types.d.ts +6 -2
- package/src/compat/types.ts +6 -2
- package/src/discovery/codex.d.ts +4 -5
- package/src/discovery/codex.ts +7 -15
- package/src/discovery/cursor-proto.d.ts +8 -0
- package/src/discovery/cursor-proto.ts +12 -1
- package/src/discovery/factory-droid.ts +35 -11
- package/src/discovery/openai-compatible.d.ts +6 -0
- package/src/discovery/openai-compatible.ts +1 -1
- package/src/model-cache.d.ts +8 -0
- package/src/model-cache.ts +83 -61
- package/src/model-catalog-format.d.ts +37 -0
- package/src/model-catalog-format.ts +296 -0
- package/src/model-manager.d.ts +11 -1
- package/src/model-manager.ts +85 -143
- package/src/model-thinking.d.ts +4 -0
- package/src/model-thinking.ts +10 -0
- package/src/model-tokenizer.ts +13 -12
- package/src/models.d.ts +22 -3
- package/src/models.json +1 -1
- package/src/models.ts +48 -11
- package/src/pricing.d.ts +66 -6
- package/src/pricing.ts +59 -94
- package/src/provider-models/cache-provider-id.ts +23 -6
- package/src/provider-models/catalog-snapshot.json.zst +0 -0
- package/src/provider-models/catalog-snapshot.json.zst.d.ts +3 -0
- package/src/provider-models/descriptors.ts +2 -0
- package/src/provider-models/openai-compat.d.ts +18 -13
- package/src/provider-models/openai-compat.ts +203 -94
- package/src/provider-models/special.ts +5 -6
- package/src/types.d.ts +14 -19
- package/src/types.ts +11 -18
- package/src/utils.d.ts +8 -0
- package/src/utils.ts +18 -0
- package/src/wire/codex.d.ts +1 -1
- package/src/wire/codex.ts +1 -1
- package/src/wire/factory-droid.ts +4 -3
- package/src/models.json.d.ts +0 -9
package/src/model-tokenizer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { revisionAtLeast } from "./compat/revision";
|
|
2
2
|
import { classifyModel } from "./compat/taxonomy";
|
|
3
3
|
import type { ModelIdentity } from "./compat/types";
|
|
4
4
|
import { bareModelId } from "./identity/id";
|
|
@@ -8,15 +8,6 @@ import type { ModelTokenizer } from "./types";
|
|
|
8
8
|
const MAX_TOKENIZER_CACHE_ENTRIES = 2_048;
|
|
9
9
|
const modelTokenizerCache = new Map<string, ModelTokenizer | null>();
|
|
10
10
|
|
|
11
|
-
function revisionAtLeast(revision: string | undefined, floor: string): boolean {
|
|
12
|
-
if (revision === undefined) return false;
|
|
13
|
-
const parsedRevision = parseRevision(revision);
|
|
14
|
-
const parsedFloor = parseRevision(floor);
|
|
15
|
-
return (
|
|
16
|
-
parsedRevision !== undefined && parsedFloor !== undefined && compareRevision(parsedRevision, parsedFloor) >= 0
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
11
|
function claudeTokenizer(identity: ModelIdentity): ModelTokenizer | undefined {
|
|
21
12
|
if (identity.class !== "anthropic") return undefined;
|
|
22
13
|
if (identity.family === "opus") {
|
|
@@ -49,9 +40,19 @@ function glmTokenizer(identity: ModelIdentity): ModelTokenizer | undefined {
|
|
|
49
40
|
return identity.class === "glm" && revisionAtLeast(identity.revision, "5") ? "glm5" : undefined;
|
|
50
41
|
}
|
|
51
42
|
|
|
52
|
-
// GPT-5 and later bill text in o200k_base
|
|
43
|
+
// GPT-5 and later bill text in o200k_base, GPT-3.5 and GPT-4 (Turbo) in cl100k_base. GPT-4.1, GPT-4.5, gpt-4o and the
|
|
44
|
+
// o-series are o200k too, which is the default for a model without a tokenizer.
|
|
53
45
|
function openAITokenizer(identity: ModelIdentity): ModelTokenizer | undefined {
|
|
54
|
-
|
|
46
|
+
if (identity.class !== "openai") return undefined;
|
|
47
|
+
if (revisionAtLeast(identity.revision, "5")) return "o200k";
|
|
48
|
+
if (
|
|
49
|
+
identity.family === "gpt" &&
|
|
50
|
+
revisionAtLeast(identity.revision, "3.5") &&
|
|
51
|
+
!revisionAtLeast(identity.revision, "4.1")
|
|
52
|
+
) {
|
|
53
|
+
return "cl100k";
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
package/src/models.d.ts
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
|
-
import MODELS from "./models.json";
|
|
2
1
|
import type { Api, KnownProvider, Model, ModelCost, ModelPricingStatus, TimeBasedCost, TokenCost, Usage } from "./types";
|
|
3
|
-
|
|
2
|
+
/** Provider identifier accepted by the bundled model registry. */
|
|
3
|
+
export type GeneratedProvider = string;
|
|
4
4
|
/** Whether `provider` has bundled rows in models.json (e.g. a provider id authored in KDL). */
|
|
5
5
|
export declare function isGeneratedProvider(provider: string): provider is GeneratedProvider;
|
|
6
|
+
/** Look up a bundled model; nested catalog values are shared and must not be mutated. */
|
|
6
7
|
export declare function getBundledModel<TApi extends Api = Api>(provider: GeneratedProvider, modelId: string): Model<TApi>;
|
|
7
|
-
|
|
8
|
+
/** List providers with bundled rows; the array is shared and frozen. */
|
|
9
|
+
export declare function getBundledProviders(): readonly KnownProvider[];
|
|
10
|
+
/** List a provider's bundled models; nested catalog values are shared and must not be mutated. */
|
|
8
11
|
export declare function getBundledModels(provider: GeneratedProvider): Model<Api>[];
|
|
9
12
|
/** Resolve display semantics without mistaking an absent rate card for a free model. */
|
|
10
13
|
export declare function getModelPricingStatus(model: Pick<Model<Api>, "cost" | "pricingStatus">): ModelPricingStatus;
|
|
14
|
+
/** Factory Droid credit rate in force at a time, and the next dated change to it. */
|
|
15
|
+
export interface FactoryDroidCreditRate {
|
|
16
|
+
rate: number;
|
|
17
|
+
/** The earliest later `credit-rates` card that changes `rate`: the rate it sets and when (Unix ms). */
|
|
18
|
+
next?: {
|
|
19
|
+
rate: number;
|
|
20
|
+
at: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Factory Droid Standard Credits rate at `timestamp` (Unix ms, default now):
|
|
25
|
+
* the `input` of the `credit-rates` card due then (the latest at or before
|
|
26
|
+
* it, as for cost cards), else the base rate. Undefined for models without a
|
|
27
|
+
* credit rate.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getFactoryDroidCreditRate(model: Pick<Model, "factoryDroidCredits" | "factoryDroidCreditCards">, timestamp?: number): FactoryDroidCreditRate | undefined;
|
|
11
30
|
/**
|
|
12
31
|
* The base token card in force at `timestamp` (Unix ms, default now): the
|
|
13
32
|
* latest due `timeBased` effective rate, else the row's own legs. Price
|