diff --git a/src/models.ts b/src/models.ts index ac3137f..7865cf0 100644 --- a/src/models.ts +++ b/src/models.ts @@ -30,14 +30,18 @@ const THINKING_ORDER = ["off", "minimal", "low", "medium", "high", "xhigh", "max function parseCost(summary?: string): ProviderModelConfig["cost"] { const empty = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }; if (!summary) return empty; - const input = summary.match(/\$([0-9.]+)\s*\/\s*MTok In/i); - const output = summary.match(/\$([0-9.]+)\s*\/\s*MTok Out/i); + // Devin CLI emits e.g. "$10 / 1M Input · $0.25 / 1M Cached input · $50 / 1M Output"; + // older catalogs used "/MTok In" style labels. Match the unit token loosely. + const input = summary.match(/\$([0-9.]+)\s*\/\s*1?M(?:Tok)?\s+In(?:put)?/i); + const output = summary.match(/\$([0-9.]+)\s*\/\s*1?M(?:Tok)?\s+Out(?:put)?/i); + const cached = summary.match(/\$([0-9.]+)\s*\/\s*1?M(?:Tok)?\s+Cached\s+in(?:put)?/i); const inCost = input ? Number(input[1]) : 0; const outCost = output ? Number(output[1]) : 0; + const cacheRead = cached ? Number(cached[1]) : Number((inCost * 0.1).toFixed(4)); return { input: inCost, output: outCost, - cacheRead: Number((inCost * 0.1).toFixed(4)), + cacheRead, cacheWrite: Number((inCost * 1.25).toFixed(4)), }; }