agentModelPricing.ts ×7

Frontier kind: Code frontier

unlabeled · c_0b2b41bcf66f

182 tests · 32000 LOC · 170 files · introduces 0 tests · 38 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges38 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2849 ranges32000 lines · 170 files · Browse complete extent
All tests (intent)
182 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 38 introduced LOC across 7 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/common/agentModelPricing.ts 38 introduced LOC · 7 ranges

Open complete file

100 */
101 export function createAgentModelPricingMeta(pricing: IAgentModelPricingMeta): Record<string, unknown> | undefined {
102 > const entries = Object.entries(pricing).filter(([, value]) => value !== undefined); agentModelPricing.ts
103 > return entries.length > 0 ? Object.fromEntries(entries) : undefined;
104 > }
105
106 /**
110 */
111 export function normalizeCAPIBilling(raw: unknown): ICAPIModelBilling | undefined {
112 > if (!raw || typeof raw !== 'object') { agentModelPricing.ts
113 return undefined;
114 }
115 const billing = raw as Record<string, unknown>;
116 > const multiplier = typeof billing.multiplier === 'number' ? billing.multiplier : undefined; agentModelPricing.ts
117 > const priceCategory = typeof billing.priceCategory === 'string' ? billing.priceCategory
118 : typeof (billing as Record<string, unknown>).price_category === 'string' ? (billing as Record<string, unknown>).price_category as string
119 : undefined;
120 > const discountPercent = typeof billing.discountPercent === 'number' ? billing.discountPercent agentModelPricing.ts
121 : typeof (billing as Record<string, unknown>).discount_percent === 'number' ? (billing as Record<string, unknown>).discount_percent as number
122 : undefined;
124 > // Resolve token prices: prefer camelCase `tokenPrices`, fall back to snake_case `token_prices`.
125 > const rawTokenPrices = (billing.tokenPrices ?? billing.token_prices) as Record<string, unknown> | undefined;
126 > let tokenPrices: ICAPIModelBilling['tokenPrices'] = undefined;
127 > if (rawTokenPrices && typeof rawTokenPrices === 'object') {
128 // The CAPI snake_case format nests prices under `default` / `long_context` tiers;
129 // the camelCase format flattens them at the top level of `tokenPrices`.
227 */
228 export function createPricingMetaFromBilling(billing: ICAPIModelBilling | undefined, priceCategory?: string, category?: string): Record<string, unknown> | undefined {
229 > const tokenPrices = billing?.tokenPrices; agentModelPricing.ts
230 > const longContext = tokenPrices?.longContext;
231 >
232 > // Only emit long-context costs when there is an actual surcharge (at least
233 > // one price differs from default). When emitting, fall back to the default-
234 > // tier value for any field the long-context tier does not specify so the
235 > // hover table renders complete rows without gaps.
236 > const showLongContext = longContext !== undefined && (
237 (longContext.inputPrice !== undefined && longContext.inputPrice !== tokenPrices?.inputPrice) ||
238 (longContext.outputPrice !== undefined && longContext.outputPrice !== tokenPrices?.outputPrice) ||
239 (longContext.cachePrice !== undefined && longContext.cachePrice !== tokenPrices?.cachePrice) ||
240 (longContext.cacheWritePrice !== undefined && longContext.cacheWritePrice !== tokenPrices?.cacheWritePrice)
242 >
243 > return createAgentModelPricingMeta({
244 > multiplierNumeric: typeof billing?.multiplier === 'number' ? billing.multiplier : undefined,
245 > inputCost: tokenPrices?.inputPrice,
246 > cacheCost: tokenPrices?.cachePrice,
247 > cacheWriteCost: tokenPrices?.cacheWritePrice,
248 > outputCost: tokenPrices?.outputPrice,
249 > longContextInputCost: showLongContext ? (longContext.inputPrice ?? tokenPrices?.inputPrice) : undefined,
250 > longContextCacheCost: showLongContext ? (longContext.cachePrice ?? tokenPrices?.cachePrice) : undefined,
251 > longContextCacheWriteCost: showLongContext ? (longContext.cacheWritePrice ?? tokenPrices?.cacheWritePrice) : undefined,
252 > longContextOutputCost: showLongContext ? (longContext.outputPrice ?? tokenPrices?.outputPrice) : undefined,
253 > priceCategory: priceCategory ?? (typeof billing?.priceCategory === 'string' ? billing.priceCategory : undefined),
254 > category,
255 > discountPercent: typeof billing?.discountPercent === 'number' ? billing.discountPercent : undefined,
256 > promo: billing?.promo,
257 > });
258 > }
259
260 /**