/** * Local cost calculation for Factory Droid usage. * * Mirrors pi-ai's `calculateCost` arithmetic exactly (same as the Command Code * backend). Factory is billed via subscription credits (multipliers), not * per-token USD, so the pricing table is all zeros — but the arithmetic must * still be correct if a host injects real per-token costs via onPayload. */ import type { ModelLike, Usage } from "./types.ts" export function calculateFactoryDroidCost(model: ModelLike, usage: Usage): void { usage.cost.input = (model.cost.input / 1_000_000) * usage.input usage.cost.output = (model.cost.output / 1_000_000) * usage.output usage.cost.cacheRead = (model.cost.cacheRead / 1_000_000) * usage.cacheRead usage.cost.cacheWrite = (model.cost.cacheWrite * usage.cacheWrite) / 1_000_000 usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite }