(model: Record<string, unknown>)
| 298 | } |
| 299 | |
| 300 | function normalizeCost(model: Record<string, unknown>) { |
| 301 | const cost = model.cost; |
| 302 | if (cost === undefined || cost === null || typeof cost !== "object" || Array.isArray(cost)) { |
| 303 | return model; |
| 304 | } |
| 305 | |
| 306 | const tiers = (cost as { tiers?: unknown }).tiers; |
| 307 | if (!Array.isArray(tiers) || tiers.length !== 1) { |
| 308 | return model; |
| 309 | } |
| 310 | |
| 311 | const contextOver200k = tiers.find((tier) => { |
| 312 | if (tier === null || typeof tier !== "object" || Array.isArray(tier)) return false; |
| 313 | const tierConfig = (tier as { tier?: unknown }).tier; |
| 314 | if (tierConfig === null || typeof tierConfig !== "object" || Array.isArray(tierConfig)) return false; |
| 315 | const type = (tierConfig as { type?: unknown }).type; |
| 316 | const size = (tierConfig as { size?: unknown }).size; |
| 317 | return ( |
| 318 | (type === undefined || type === "context") && |
| 319 | typeof size === "number" && |
| 320 | size >= 200_000 |
| 321 | ); |
| 322 | }); |
| 323 | |
| 324 | if (contextOver200k === undefined) { |
| 325 | return model; |
| 326 | } |
| 327 | |
| 328 | const { tier: _tier, ...legacyCost } = contextOver200k as Record<string, unknown>; |
| 329 | return { |
| 330 | ...model, |
| 331 | cost: { |
| 332 | ...(cost as Record<string, unknown>), |
| 333 | context_over_200k: legacyCost, |
| 334 | }, |
| 335 | }; |
| 336 | } |
| 337 | |
| 338 | function applyOmit(target: Record<string, unknown>, paths: string[]) { |
| 339 | omitLoop: for (const omit of paths) { |
no outgoing calls
no test coverage detected