sidekick-shared 0.28.3 → 0.29.1
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 +86 -0
- package/README.md +188 -27
- package/dist/aggregation/EventAggregator.d.ts +19 -0
- package/dist/aggregation/EventAggregator.js +174 -35
- package/dist/aggregation/snapshot.d.ts +37 -8
- package/dist/aggregation/snapshot.js +31 -9
- package/dist/aggregation/types.d.ts +13 -0
- package/dist/authStatus.d.ts +54 -0
- package/dist/authStatus.js +91 -0
- package/dist/browser.d.ts +16 -6
- package/dist/browser.js +24 -2
- package/dist/codex.d.ts +23 -0
- package/dist/codex.js +44 -0
- package/dist/codexProfiles.d.ts +1 -0
- package/dist/codexProfiles.js +8 -11
- package/dist/context/sessionContext.js +4 -0
- package/dist/esm/aggregation/EventAggregator.js +174 -35
- package/dist/esm/aggregation/snapshot.js +31 -9
- package/dist/esm/authStatus.js +87 -0
- package/dist/esm/browser.js +5 -2
- package/dist/esm/codex.js +18 -0
- package/dist/esm/codexProfiles.js +8 -11
- package/dist/esm/context/sessionContext.js +4 -0
- package/dist/esm/formatters/toolSummary.js +4 -1
- package/dist/esm/formatting.js +10 -1
- package/dist/esm/index.js +11 -6
- package/dist/esm/modelCatalog.js +7 -5
- package/dist/esm/modelContext.js +4 -3
- package/dist/esm/modelInfo.js +425 -47
- package/dist/esm/node.js +9 -3
- package/dist/esm/observedContextWindows.js +2 -1
- package/dist/esm/ownKey.js +26 -0
- package/dist/esm/parsers/codexParser.js +351 -54
- package/dist/esm/parsers/codexRolloutOrigin.js +107 -0
- package/dist/esm/parsers/openCodeParser.js +85 -22
- package/dist/esm/parsers/subagentScanner.js +33 -12
- package/dist/esm/parsers/subagentTraceParser.js +97 -37
- package/dist/esm/pricing.js +18 -0
- package/dist/esm/pricingCatalog.js +17 -9
- package/dist/esm/promptHistory.js +66 -4
- package/dist/esm/providerFailure.js +124 -3
- package/dist/esm/providers/claudeCode.js +10 -2
- package/dist/esm/providers/codex.js +84 -62
- package/dist/esm/providers/codexDatabase.js +3 -19
- package/dist/esm/providers/codexRollouts.js +24 -1
- package/dist/esm/providers/openCode.js +9 -17
- package/dist/esm/report/htmlReportGenerator.js +42 -5
- package/dist/esm/report/transcriptParser.js +13 -11
- package/dist/esm/schemas/providerFailure.js +3 -1
- package/dist/esm/schemas/sessionEvent.js +35 -14
- package/dist/esm/schemas/transcript.js +4 -0
- package/dist/esm/sessionPromptHistory.js +2 -2
- package/dist/esm/statusline/payload.js +9 -0
- package/dist/esm/subagentSpawn.js +163 -0
- package/dist/esm/testing/credentialGuard.js +87 -5
- package/dist/esm/toolCallOrigins.js +310 -0
- package/dist/esm/transcript.js +46 -3
- package/dist/esm/turns/assistantTurn.js +3 -2
- package/dist/esm/usage/claudeUsageDedupe.js +68 -0
- package/dist/esm/usage/usageEvents.js +146 -17
- package/dist/esm/usage/usageReports.js +39 -6
- package/dist/esm/watchers/eventBridge.js +15 -0
- package/dist/esm/watchers/factory.js +5 -3
- package/dist/esm/watchers/jsonlTail.js +442 -58
- package/dist/esm/watchers/jsonlWatcher.js +51 -4
- package/dist/esm/watchers/providerReaderWatcher.js +13 -0
- package/dist/esm/zaiQuota.js +2 -1
- package/dist/formatters/toolSummary.js +4 -1
- package/dist/formatting.d.ts +26 -1
- package/dist/formatting.js +11 -1
- package/dist/index.d.ts +22 -11
- package/dist/index.js +44 -12
- package/dist/modelCatalog.js +7 -5
- package/dist/modelContext.js +4 -3
- package/dist/modelInfo.d.ts +185 -16
- package/dist/modelInfo.js +434 -49
- package/dist/node.d.ts +16 -5
- package/dist/node.js +33 -2
- package/dist/observedContextWindows.js +2 -1
- package/dist/ownKey.d.ts +16 -0
- package/dist/ownKey.js +30 -0
- package/dist/parsers/codexParser.d.ts +118 -0
- package/dist/parsers/codexParser.js +352 -54
- package/dist/parsers/codexRolloutOrigin.d.ts +49 -0
- package/dist/parsers/codexRolloutOrigin.js +111 -0
- package/dist/parsers/openCodeParser.d.ts +38 -0
- package/dist/parsers/openCodeParser.js +88 -22
- package/dist/parsers/subagentScanner.d.ts +19 -6
- package/dist/parsers/subagentScanner.js +33 -12
- package/dist/parsers/subagentTraceParser.d.ts +25 -5
- package/dist/parsers/subagentTraceParser.js +97 -37
- package/dist/pricing.d.ts +22 -0
- package/dist/pricing.js +50 -0
- package/dist/pricingCatalog.d.ts +10 -0
- package/dist/pricingCatalog.js +16 -8
- package/dist/promptHistory.d.ts +65 -4
- package/dist/promptHistory.js +68 -5
- package/dist/providerFailure.d.ts +44 -0
- package/dist/providerFailure.js +126 -4
- package/dist/providers/claudeCode.js +9 -1
- package/dist/providers/codex.d.ts +3 -22
- package/dist/providers/codex.js +85 -64
- package/dist/providers/codexDatabase.d.ts +3 -2
- package/dist/providers/codexDatabase.js +4 -22
- package/dist/providers/codexRollouts.d.ts +22 -0
- package/dist/providers/codexRollouts.js +24 -0
- package/dist/providers/openCode.js +8 -16
- package/dist/providers/types.d.ts +14 -0
- package/dist/report/htmlReportGenerator.js +42 -5
- package/dist/report/transcriptParser.d.ts +10 -1
- package/dist/report/transcriptParser.js +13 -11
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/providerFailure.d.ts +39 -0
- package/dist/schemas/providerFailure.js +2 -0
- package/dist/schemas/sessionEvent.d.ts +27 -10
- package/dist/schemas/sessionEvent.js +35 -14
- package/dist/schemas/transcript.d.ts +2 -0
- package/dist/schemas/transcript.js +4 -0
- package/dist/sessionPromptHistory.d.ts +7 -1
- package/dist/sessionPromptHistory.js +1 -1
- package/dist/statusline/payload.d.ts +10 -0
- package/dist/statusline/payload.js +14 -0
- package/dist/subagentSpawn.d.ts +80 -0
- package/dist/subagentSpawn.js +174 -0
- package/dist/testing/credentialGuard.d.ts +14 -0
- package/dist/testing/credentialGuard.js +87 -5
- package/dist/toolCallOrigins.d.ts +70 -0
- package/dist/toolCallOrigins.js +346 -0
- package/dist/transcript.d.ts +12 -0
- package/dist/transcript.js +46 -3
- package/dist/turns/assistantTurn.d.ts +1 -0
- package/dist/turns/assistantTurn.js +3 -2
- package/dist/types/opencode.d.ts +2 -0
- package/dist/usage/claudeUsageDedupe.d.ts +31 -0
- package/dist/usage/claudeUsageDedupe.js +68 -0
- package/dist/usage/usageEvents.d.ts +54 -6
- package/dist/usage/usageEvents.js +146 -17
- package/dist/usage/usageReports.d.ts +35 -4
- package/dist/usage/usageReports.js +39 -6
- package/dist/watchers/eventBridge.js +15 -0
- package/dist/watchers/factory.d.ts +6 -0
- package/dist/watchers/factory.js +5 -3
- package/dist/watchers/jsonlTail.d.ts +124 -4
- package/dist/watchers/jsonlTail.js +446 -59
- package/dist/watchers/jsonlWatcher.d.ts +18 -1
- package/dist/watchers/jsonlWatcher.js +50 -3
- package/dist/watchers/providerReaderWatcher.d.ts +7 -0
- package/dist/watchers/providerReaderWatcher.js +13 -0
- package/dist/watchers/types.d.ts +12 -0
- package/dist/zaiQuota.js +2 -1
- package/package.json +41 -1
package/dist/modelContext.js
CHANGED
|
@@ -42,6 +42,7 @@ exports._getModelContextIds = _getModelContextIds;
|
|
|
42
42
|
exports.resolveModelContextWindow = resolveModelContextWindow;
|
|
43
43
|
exports.getModelContextWindowSize = getModelContextWindowSize;
|
|
44
44
|
const modelAliases_1 = require("./modelAliases");
|
|
45
|
+
const ownKey_1 = require("./ownKey");
|
|
45
46
|
/** Known model context window sizes (in tokens); current models verified 2026-09-05. */
|
|
46
47
|
const MODEL_CONTEXT_SIZES = {
|
|
47
48
|
// Published API limits verified 2026-10-30; GLM's API documents 1M even
|
|
@@ -158,7 +159,7 @@ function normalizeOverrides(overrides) {
|
|
|
158
159
|
for (const [key, value] of Object.entries(overrides)) {
|
|
159
160
|
if (!Number.isFinite(value) || value <= 0)
|
|
160
161
|
continue;
|
|
161
|
-
out
|
|
162
|
+
(0, ownKey_1.setOwnValue)(out, key.trim().toLowerCase(), value);
|
|
162
163
|
}
|
|
163
164
|
return out;
|
|
164
165
|
}
|
|
@@ -222,7 +223,7 @@ function _getModelContextIds() {
|
|
|
222
223
|
// ── Lookup ──
|
|
223
224
|
/** Exact match against one table. */
|
|
224
225
|
function exactWindow(table, modelId) {
|
|
225
|
-
const hit = table
|
|
226
|
+
const hit = (0, ownKey_1.ownValue)(table, modelId);
|
|
226
227
|
return hit === undefined ? null : hit;
|
|
227
228
|
}
|
|
228
229
|
function exactWindowMatch(table, modelId) {
|
|
@@ -270,7 +271,7 @@ function resolveModelContextWindow(modelId) {
|
|
|
270
271
|
// Imported resolutions rank below local observed data: a window this realm
|
|
271
272
|
// saw first-hand is fresher than a snapshot transferred from another realm.
|
|
272
273
|
if (!observedExact) {
|
|
273
|
-
const imported = importedTable
|
|
274
|
+
const imported = (0, ownKey_1.ownValue)(importedTable, stripped) ?? (0, ownKey_1.ownValue)(importedTable, canonicalModelId);
|
|
274
275
|
if (imported) {
|
|
275
276
|
return { ...imported, modelId: rawModelId, canonicalModelId };
|
|
276
277
|
}
|
package/dist/modelInfo.d.ts
CHANGED
|
@@ -14,11 +14,18 @@
|
|
|
14
14
|
* baseline without requiring a redeploy when vendor prices change.
|
|
15
15
|
* - Longest-prefix matching handles variants like `claude-opus-4.5-20250514`
|
|
16
16
|
* against a key like `claude-opus-4.5`. Same pattern used in modelContext.ts.
|
|
17
|
+
* - A consumer layer (`registerModelPricing`) sits beside the catalog and
|
|
18
|
+
* imported layers and survives their resets.
|
|
19
|
+
* - Every table-derived value is computed lazily, so a tree-shaken bundle that
|
|
20
|
+
* only uses the parsing/display helpers does not retain the pricing table.
|
|
17
21
|
*
|
|
18
22
|
* @module modelInfo
|
|
19
23
|
*/
|
|
20
24
|
import type { ModelProviderId } from './providerIds';
|
|
25
|
+
import type { PricingProvenance } from './usageNormalization';
|
|
21
26
|
export { MODEL_PROVIDER_IDS } from './providerIds';
|
|
27
|
+
export { formatCost } from './formatting';
|
|
28
|
+
export type { FormatCostOptions } from './formatting';
|
|
22
29
|
/** Pricing information for a model. All costs are per million tokens in USD. */
|
|
23
30
|
export interface ModelPricing {
|
|
24
31
|
inputCostPerMillion: number;
|
|
@@ -26,7 +33,18 @@ export interface ModelPricing {
|
|
|
26
33
|
cacheWriteCostPerMillion: number;
|
|
27
34
|
cacheReadCostPerMillion: number;
|
|
28
35
|
}
|
|
29
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Which layer answered a pricing lookup.
|
|
38
|
+
*
|
|
39
|
+
* - `registered` — an entry supplied through `registerModelPricing` (consumer
|
|
40
|
+
* configuration such as negotiated prices). Always an exact match.
|
|
41
|
+
* - `imported` — an exact resolution imported from another realm via
|
|
42
|
+
* `importResolvedModelCatalog`.
|
|
43
|
+
* - `catalog` — the runtime LiteLLM catalog (`hydratePricingCatalog`).
|
|
44
|
+
* - `static` — the offline baseline shipped with this package.
|
|
45
|
+
* - `none` — unpriced.
|
|
46
|
+
*/
|
|
47
|
+
export type ModelPricingSource = 'registered' | 'imported' | 'catalog' | 'static' | 'none';
|
|
30
48
|
export type ModelPricingMatch = 'exact' | 'prefix' | 'none';
|
|
31
49
|
export interface ModelPricingProvenance {
|
|
32
50
|
source: ModelPricingSource;
|
|
@@ -37,10 +55,75 @@ export interface ModelPricingProvenance {
|
|
|
37
55
|
}
|
|
38
56
|
export interface ResolvedModelPricing {
|
|
39
57
|
modelId: string;
|
|
58
|
+
/**
|
|
59
|
+
* The looked-up id trimmed, lowercased, without `[1m]`, and resolved through
|
|
60
|
+
* registered aliases. Deployment prefixes and date suffixes are kept, so
|
|
61
|
+
* this is not the same value as `canonicalModelId(modelId)`.
|
|
62
|
+
*/
|
|
40
63
|
canonicalModelId: string;
|
|
41
64
|
pricing: ModelPricing | null;
|
|
42
65
|
provenance: ModelPricingProvenance;
|
|
43
66
|
}
|
|
67
|
+
export interface ResolveModelPricingOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Consult entries from `registerModelPricing`. Defaults to true; pass false
|
|
70
|
+
* to see what the package's own layers would answer.
|
|
71
|
+
*/
|
|
72
|
+
includeRegistered?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface RegisterModelPricingOptions {
|
|
75
|
+
/**
|
|
76
|
+
* `false` (default): the entry wins over every other layer — explicit
|
|
77
|
+
* configuration such as negotiated prices.
|
|
78
|
+
*
|
|
79
|
+
* `true`: the entry is a gap filler. It is used only when no other layer has
|
|
80
|
+
* an exact price for the looked-up id (its raw form or registered alias
|
|
81
|
+
* target), so it replaces a prefix-inherited or missing price but never an
|
|
82
|
+
* exact static, catalog, or imported one.
|
|
83
|
+
*/
|
|
84
|
+
onlyIfMissing?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Where the active pricing tables came from. */
|
|
87
|
+
export type PricingCatalogSource = 'static' | 'litellm' | 'stale-cache' | 'imported';
|
|
88
|
+
/** Describes the pricing basis currently applied to cost estimates. */
|
|
89
|
+
export interface PricingCatalogInfo {
|
|
90
|
+
/**
|
|
91
|
+
* `litellm` — catalog loaded from a fresh fetch or a cache within its TTL;
|
|
92
|
+
* `stale-cache` — catalog loaded from a cache older than its TTL (the
|
|
93
|
+
* refresh failed or was skipped offline); `imported` — no catalog, but
|
|
94
|
+
* resolutions imported from another realm are active; `static` — only the
|
|
95
|
+
* built-in baseline. Registered entries never change the source.
|
|
96
|
+
*/
|
|
97
|
+
source: PricingCatalogSource;
|
|
98
|
+
/** When the active catalog was fetched, if known. Only set for catalog sources. */
|
|
99
|
+
fetchedAt?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Stable, non-cryptographic fingerprint (`fnv1a64:<16 hex>`) of the active
|
|
102
|
+
* static, catalog, imported, and registered pricing tables. Equal digests
|
|
103
|
+
* mean equal prices; it changes whenever any price in any layer changes.
|
|
104
|
+
* Registered aliases are not part of it.
|
|
105
|
+
*/
|
|
106
|
+
digest: string;
|
|
107
|
+
/** Entries in the runtime catalog layer. */
|
|
108
|
+
catalogEntries: number;
|
|
109
|
+
/** Entries in the `registerModelPricing` layer. */
|
|
110
|
+
registeredEntries: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Internal: how the catalog overrides were obtained, recorded by
|
|
114
|
+
* `pricingCatalog.ts` alongside `_setPricingOverrides`.
|
|
115
|
+
*/
|
|
116
|
+
export interface PricingOverridesBasis {
|
|
117
|
+
source: 'litellm' | 'stale-cache';
|
|
118
|
+
fetchedAt?: string;
|
|
119
|
+
}
|
|
120
|
+
/** One contribution to a cost rollup, for `mergeCostComponents`. */
|
|
121
|
+
export interface CostComponent {
|
|
122
|
+
/** Provenance of this component's cost; undefined means nothing seen yet. */
|
|
123
|
+
source?: CostSource;
|
|
124
|
+
/** Tokens this component contributed. */
|
|
125
|
+
tokens: number;
|
|
126
|
+
}
|
|
44
127
|
/**
|
|
45
128
|
* Token usage for the legacy cost calculation contract.
|
|
46
129
|
* @deprecated Use NormalizedUsage and calculateNormalizedUsageCost. This shape
|
|
@@ -65,6 +148,12 @@ export interface ParsedModelId {
|
|
|
65
148
|
provider: ModelProvider;
|
|
66
149
|
family: string;
|
|
67
150
|
version: string;
|
|
151
|
+
/**
|
|
152
|
+
* GPT tier name (`astra`, `sol`, `terra`, `luna`) when the id carries one,
|
|
153
|
+
* e.g. `gpt-6.1-sol` → `sol`. `version` still includes it (`6.1-sol`).
|
|
154
|
+
* Absent for every other id.
|
|
155
|
+
*/
|
|
156
|
+
variant?: string;
|
|
68
157
|
}
|
|
69
158
|
/** Comprehensive model metadata. */
|
|
70
159
|
export interface ModelInfo {
|
|
@@ -104,8 +193,12 @@ export interface ModelDisplayInfo {
|
|
|
104
193
|
* after a successful LiteLLM hydration. Not part of the stable public API,
|
|
105
194
|
* but exported so the Node-only catalog module can wire itself in without
|
|
106
195
|
* creating a circular import.
|
|
196
|
+
*
|
|
197
|
+
* `basis` records how the map was obtained for `getPricingCatalogInfo()`;
|
|
198
|
+
* omitted, a non-empty map reports as `litellm` with no `fetchedAt`. Every
|
|
199
|
+
* call replaces the previous basis.
|
|
107
200
|
*/
|
|
108
|
-
export declare function _setPricingOverrides(overrides: Record<string, ModelPricing
|
|
201
|
+
export declare function _setPricingOverrides(overrides: Record<string, ModelPricing>, basis?: PricingOverridesBasis): void;
|
|
109
202
|
/** Internal: snapshot current overrides (test + diagnostics). */
|
|
110
203
|
export declare function _getPricingOverrides(): Record<string, ModelPricing>;
|
|
111
204
|
/** Internal: clear overrides (used by tests and when disabling hydration). */
|
|
@@ -118,8 +211,67 @@ export declare function _clearPricingOverrides(): void;
|
|
|
118
211
|
export declare function _setImportedResolvedPricing(values: Record<string, ResolvedModelPricing>): void;
|
|
119
212
|
/** Internal test hook. */
|
|
120
213
|
export declare function _clearImportedResolvedPricing(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Register consumer pricing for model ids, e.g. negotiated or private-deployment
|
|
216
|
+
* rates. This layer is separate from the runtime catalog and imported layers:
|
|
217
|
+
* `_setPricingOverrides`, `hydratePricingCatalog`, and
|
|
218
|
+
* `importResolvedModelCatalog` never reset it; only
|
|
219
|
+
* `clearRegisteredModelPricing` does.
|
|
220
|
+
*
|
|
221
|
+
* Keys are trimmed, lowercased, and stripped of `[1m]`, like the other tables.
|
|
222
|
+
* Matching is exact, never by prefix, against the looked-up id, its registered
|
|
223
|
+
* alias target, and its `canonicalModelId()` form — so a `claude-opus-5-5`
|
|
224
|
+
* entry also answers `claude-opus-5-5-20261001` and
|
|
225
|
+
* `us.anthropic.claude-opus-5-5-20261001-v1:0`.
|
|
226
|
+
*
|
|
227
|
+
* Successive calls merge; re-registering a key replaces its price and mode.
|
|
228
|
+
* Entries whose four rates are not all finite, nonnegative numbers are
|
|
229
|
+
* skipped. Results carry `provenance.source: 'registered'`.
|
|
230
|
+
*
|
|
231
|
+
* Registered entries are realm-local configuration and are kept out of
|
|
232
|
+
* cross-realm snapshots: they are not listed by the catalog id enumeration,
|
|
233
|
+
* and `resolveModelPricing(id, { includeRegistered: false })` is the
|
|
234
|
+
* resolution a snapshot should carry. An exported price would otherwise be
|
|
235
|
+
* pinned as an exact import in the other realm and outlive
|
|
236
|
+
* `clearRegisteredModelPricing` there. Register in each realm instead.
|
|
237
|
+
*/
|
|
238
|
+
export declare function registerModelPricing(entries: Record<string, ModelPricing>, options?: RegisterModelPricingOptions): void;
|
|
239
|
+
/** Remove every entry added by `registerModelPricing`. */
|
|
240
|
+
export declare function clearRegisteredModelPricing(): void;
|
|
241
|
+
/**
|
|
242
|
+
* Describe the pricing basis behind current cost estimates: which layer the
|
|
243
|
+
* prices come from, when the catalog was fetched, and a digest that changes
|
|
244
|
+
* whenever any active price changes. Pure and cheap after the first call (the
|
|
245
|
+
* digest is memoized until a table changes).
|
|
246
|
+
*/
|
|
247
|
+
export declare function getPricingCatalogInfo(): PricingCatalogInfo;
|
|
121
248
|
/** Internal: list every ID known to the pricing resolver. */
|
|
122
249
|
export declare function _getModelPricingIds(): string[];
|
|
250
|
+
/**
|
|
251
|
+
* Reduce a model id to the bare model name it denotes, for grouping and
|
|
252
|
+
* matching across hosts and snapshots.
|
|
253
|
+
*
|
|
254
|
+
* Trims and lowercases, then removes: `[1m]`; every leading `segment/`
|
|
255
|
+
* provider or region prefix (`azure/us/gpt-6.1-terra` → `gpt-6.1-terra`);
|
|
256
|
+
* Bedrock forms (`us.anthropic.claude-opus-5-5-20261001-v1:0` →
|
|
257
|
+
* `claude-opus-5-5`, also `eu.`/`apac.`/`global.` and bare `anthropic.`);
|
|
258
|
+
* Vertex `@YYYYMMDD`; trailing `-YYYYMMDD` and `-YYYY-MM-DD` dates; `-latest`.
|
|
259
|
+
* Meaningful suffixes (`-mini`, `-codex`, `-sol`, `-terra`, `-high`, …) stay.
|
|
260
|
+
*
|
|
261
|
+
* Pure and syntactic: registered aliases are not applied (see
|
|
262
|
+
* `resolveModelAlias`). Pricing lookups do not use this to reach other
|
|
263
|
+
* models' prices — dated snapshots and deployments can bill differently — only
|
|
264
|
+
* to match `registerModelPricing` entries.
|
|
265
|
+
*/
|
|
266
|
+
export declare function canonicalModelId(id: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* True for model names an agent CLI resolves to a different concrete model
|
|
269
|
+
* over time (`default`, `auto`, `latest`, `sonnet`, `opus`, `haiku`, `fable`,
|
|
270
|
+
* and Claude Code's `opusplan`), so a recorded value names a moving target
|
|
271
|
+
* rather than a model. Case-insensitive, trimmed, and `[1m]`-tolerant
|
|
272
|
+
* (`sonnet[1m]`). Dated or versioned ids are never moving aliases.
|
|
273
|
+
*/
|
|
274
|
+
export declare function isMovingModelAlias(id: string): boolean;
|
|
123
275
|
/**
|
|
124
276
|
* Parses a model ID into {provider, family, version}.
|
|
125
277
|
*
|
|
@@ -130,14 +282,23 @@ export declare function _getModelPricingIds(): string[];
|
|
|
130
282
|
* Returns null for anything else — callers should treat that as "unknown model".
|
|
131
283
|
*/
|
|
132
284
|
export declare function parseModelId(modelId: string): ParsedModelId | null;
|
|
133
|
-
/**
|
|
134
|
-
|
|
285
|
+
/**
|
|
286
|
+
* Resolve pricing and disclose which layer answered and whether the result was
|
|
287
|
+
* inherited by prefix.
|
|
288
|
+
*
|
|
289
|
+
* Order: registered entries (default mode); exact imported, catalog, and
|
|
290
|
+
* static matches; registered `onlyIfMissing` entries; catalog then static
|
|
291
|
+
* prefix matches; unpriced.
|
|
292
|
+
*/
|
|
293
|
+
export declare function resolveModelPricing(modelId: string, options?: ResolveModelPricingOptions): ResolvedModelPricing;
|
|
135
294
|
/**
|
|
136
295
|
* Gets pricing for a model ID.
|
|
137
296
|
*
|
|
138
|
-
* Lookup order:
|
|
139
|
-
* 1.
|
|
140
|
-
* 2.
|
|
297
|
+
* Lookup order (see `resolveModelPricing` for provenance):
|
|
298
|
+
* 1. Registered entries (`registerModelPricing`), exact matches only.
|
|
299
|
+
* 2. Imported resolutions, then the runtime override map (from LiteLLM
|
|
300
|
+
* catalog hydration), then the static PRICING_TABLE — exact before prefix,
|
|
301
|
+
* with gap-filling registered entries between the two.
|
|
141
302
|
* 3. `null` — unknown model. Callers MUST handle this.
|
|
142
303
|
*
|
|
143
304
|
* The ID is first looked up verbatim (minus the "[1m]" suffix) — override
|
|
@@ -188,6 +349,19 @@ export declare function calculateCostWithProvenance(input: CostProvenanceInput):
|
|
|
188
349
|
* containing any unpriced or estimated component does not look fully reported.
|
|
189
350
|
*/
|
|
190
351
|
export declare function mergeCostSources(a: CostSource, b: CostSource): CostSource;
|
|
352
|
+
/**
|
|
353
|
+
* Map the provenance `calculateNormalizedUsageCost` reports to the display
|
|
354
|
+
* cost source: provider-reported costs are `reported`, costs computed from
|
|
355
|
+
* explicit or catalog pricing are `estimated`, and unpriced stays `unpriced`.
|
|
356
|
+
*/
|
|
357
|
+
export declare function costSourceFromPricingProvenance(provenance: PricingProvenance): CostSource;
|
|
358
|
+
/**
|
|
359
|
+
* Merge the cost sources of a rollup's components, least certain winning (as
|
|
360
|
+
* `mergeCostSources`). Components without a `source` have not been seen yet
|
|
361
|
+
* and are ignored, and an `unpriced` component that contributed no tokens
|
|
362
|
+
* does not taint the total. Returns `undefined` when nothing counted.
|
|
363
|
+
*/
|
|
364
|
+
export declare function mergeCostComponents(components: Iterable<CostComponent>): CostSource | undefined;
|
|
191
365
|
/**
|
|
192
366
|
* Short display label for model IDs. Keeps historical Claude family labels
|
|
193
367
|
* compact while normalizing common OpenAI labels.
|
|
@@ -197,15 +371,10 @@ export declare function shortModelName(modelId: string): string;
|
|
|
197
371
|
* Returns stable display metadata and a rank suitable for provider model menus.
|
|
198
372
|
*/
|
|
199
373
|
export declare function getModelDisplayInfo(modelId: string): ModelDisplayInfo;
|
|
200
|
-
/**
|
|
374
|
+
/**
|
|
375
|
+
* Compare two model IDs using shared provider/family ranking rules. Within a
|
|
376
|
+
* family and numeric version, GPT tiers rank astra > sol > terra > luna.
|
|
377
|
+
*/
|
|
201
378
|
export declare function compareModelIds(a: string, b: string): number;
|
|
202
379
|
/** Return a sorted copy of model IDs using shared provider/family ranking rules. */
|
|
203
380
|
export declare function sortModelIds<T extends string>(modelIds: readonly T[]): T[];
|
|
204
|
-
/**
|
|
205
|
-
* Formats a USD cost as a currency string.
|
|
206
|
-
*
|
|
207
|
-
* - `null` / `undefined` → `"—"` (honest "pricing unavailable").
|
|
208
|
-
* - `< $0.01` → 4 decimals, so sub-cent costs are still visible.
|
|
209
|
-
* - otherwise → 2 decimals.
|
|
210
|
-
*/
|
|
211
|
-
export declare function formatCost(cost: number | null | undefined): string;
|