/** * Per-commit cost receipt. * * When the agent runs `git commit` through the bash tool, a trailer like * * Elyra-Cost: $0.42 (glm-5.3, 4 turns, 1 model switch) * * is appended to the commit message via `--trailer`, so spend per change is * visible in `git log`. This module is pure: it summarizes a window of agent * messages, formats the trailer, and rewrites shell commands. Session wiring * lives in agent-session.ts. */ import type { AgentMessage } from "@elyracode/agent-core"; export declare const COST_TRAILER_KEY = "Elyra-Cost"; export interface CostWindowSummary { /** Total USD spent by assistant messages in the window (including errored attempts). */ costUsd: number; /** Assistant messages in the window whose stopReason is not "error". */ turns: number; /** Distinct model ids used in the window, in order of first appearance. */ models: string[]; /** * Number of times consecutive assistant messages in the window used a different * (provider, model) pair. A proxy for failovers and manual model changes; there is * no session-scoped failover counter, so this is labeled "model switch" not "failover". */ switches: number; } /** * Summarize assistant spend for messages with `timestamp >= sinceTs`. * Errored messages contribute cost and count toward model switches (a failover * leaves an errored message behind) but are not counted as turns. */ export declare function summarizeCostWindow(messages: readonly AgentMessage[], sinceTs: number): CostWindowSummary; /** Format the trailer line. Zero-valued detail parts are omitted. */ export declare function formatCostTrailer(summary: CostWindowSummary): string; /** * True when the command contains at least one `git commit` invocation that should * receive a cost trailer. Handles leading env assignments, `&&`/`;`/`|` chains, and * git global options (`git -c x=y commit`). False for `--fixup`/`--squash`/`--amend` * commits and when the command already carries an `Elyra-Cost:` trailer. */ export declare function isGitCommitCommand(command: string): boolean; /** * Append `--trailer ''` to every eligible `git commit` invocation in the * command. The argument is inserted before a `--` pathspec separator when present, * otherwise after the last word of the invocation, so `-m "..."` arguments and * following chained commands are left intact. */ export declare function injectCostTrailer(command: string, trailer: string): string; //# sourceMappingURL=commit-cost-trailer.d.ts.map