// engine/cost-tracking/operation-tracker.ts — Wrap tool calls with cost capture (SPEC-475)
import { writeCostEntry, calculateCost } from './ledger.js';
/**
 * Wrap a tool call with cost capture.
 * Token counts are 0 for now — real integration with LLM runtime is future work.
 * The entry is written fire-and-forget; errors are silently swallowed.
 */
export async function trackCost(projectPath, toolName, fn, options) {
    const start = Date.now();
    // Token counts are 0 until real LLM runtime integration lands
    const tokensInput = 0;
    const tokensOutput = 0;
    const model = options?.model ?? 'unknown';
    const result = await fn();
    writeCostEntry(projectPath, {
        ts: new Date().toISOString(),
        toolName,
        action: options?.action,
        model,
        tokensInput,
        tokensOutput,
        costUsd: calculateCost(model, tokensInput, tokensOutput),
        durationMs: Date.now() - start,
    });
    return result;
}
//# sourceMappingURL=operation-tracker.js.map