export declare const LISA_USAGE_HEADING = "## Lisa Usage";
/**
 *
 */
export interface LisaUsageEntry {
    artifactRef: string;
    cachedInputTokens: number | null;
    cost: number | null;
    currency: string | null;
    entryId: string;
    flow: string;
    inputTokens: number | null;
    measuredSubsetTokens?: number | null;
    model: string;
    outputTokens: number | null;
    parentArtifactRef: string | null;
    pricingSource: string | null;
    pricingStatus: string;
    provider: string;
    reasoningTokens: number | null;
    runId: string;
    source: string;
    totalTokens: number | null;
}
/**
 *
 */
export interface LisaUsageRollup {
    childCost: number | null;
    childCurrency: string | null;
    childEntryIds: readonly string[];
    childRefs: readonly string[];
    childTokens: number | null;
    childTokensIncomplete?: boolean;
    currency: string | null;
    directCost: number | null;
    directEntryIds: readonly string[];
    directTokens: number | null;
    totalCost: number | null;
    totalTokens: number | null;
}
/**
 *
 */
export interface LisaUsageChildArtifact {
    artifactRef: string;
    entries: readonly LisaUsageEntry[];
}
/**
 *
 */
export interface ParsedLisaUsageSection {
    entries: readonly LisaUsageEntry[];
    range: {
        end: number;
        start: number;
    } | null;
    rollup: LisaUsageRollup | null;
}
/**
 * Merge new usage entries into an existing ledger while keeping stable order for
 * previously recorded entries and replacing matching `entry_id` rows in place.
 *
 * @param existingEntries Previously recorded direct usage entries.
 * @param nextEntries Newly observed direct usage entries to apply.
 * @returns The merged direct-entry set in deterministic document order.
 */
export declare function mergeLisaUsageEntries(existingEntries: readonly LisaUsageEntry[], nextEntries: readonly LisaUsageEntry[]): readonly LisaUsageEntry[];
/**
 * Build a default rollup token from direct entries while preserving any prior
 * child-work totals supplied by callers from later lifecycle stages.
 *
 * @param entries Direct usage entries that should appear in the section.
 * @param previousRollup Existing rollup token parsed from the artifact, if any.
 * @param childArtifacts Optional child ledgers to recompute descendant totals from current work.
 * @returns A deterministic rollup token payload for the managed section.
 */
export declare function createLisaUsageRollup(entries: readonly LisaUsageEntry[], previousRollup?: LisaUsageRollup | null, childArtifacts?: readonly LisaUsageChildArtifact[]): LisaUsageRollup;
/**
 * Render the machine-readable token for a single direct usage row.
 *
 * @param entry Direct usage entry to serialize.
 * @returns The legacy-readable primary token plus its measured-subset extension.
 */
export declare function renderLisaUsageEntryToken(entry: LisaUsageEntry): string;
/**
 * Render the machine-readable rollup token for a managed usage section.
 *
 * @param rollup Rollup values to serialize.
 * @returns The canonical `lisa:usage-rollup` token line.
 */
export declare function renderLisaUsageRollupToken(rollup: LisaUsageRollup): string;
/**
 * Render the canonical `## Lisa Usage` section body from direct entries and a
 * rollup token.
 *
 * Entry tokens are rendered on their own lines BELOW the visible table, never
 * trailing a table row. Hosts that normalize markdown re-serialize a table from
 * its parsed cell model and discard anything that is not a cell — measured
 * against Linear on 2026-08-04, an HTML comment trailing a table row is
 * destroyed on write while the same comment on its own line round-trips
 * byte-identically. Trailing the row therefore produced a silently unreadable
 * ledger whose surviving rollup token named entries no reader could resolve.
 * Parsing has always been position-agnostic, so sections written in the old
 * layout still enumerate and migrate to this layout on their next rewrite.
 *
 * @param input Section payload containing direct entries and rollup totals.
 * @param input.entries Direct entries to render in document order.
 * @param input.rollup Rollup token to end the section with.
 * @returns The managed section text, terminated with a trailing newline.
 */
export declare function renderLisaUsageSection(input: {
    entries: readonly LisaUsageEntry[];
    rollup: LisaUsageRollup;
}): string;
/**
 * Parse the managed usage section out of an artifact body or comment.
 *
 * @param document Artifact markdown to inspect.
 * @returns Parsed direct entries, rollup token, and the located section range.
 */
export declare function parseLisaUsageSection(document: string): ParsedLisaUsageSection;
/**
 * Describe one way a stored managed usage section fails to be a readable ledger.
 */
export interface LisaUsageSectionIntegrityIssue {
    code: "missing-entry-token" | "missing-rollup-token" | "missing-section" | "unrecorded-entry";
    entryIds: readonly string[];
    message: string;
}
/**
 *
 */
export interface LisaUsageSectionIntegrityResult {
    issues: readonly LisaUsageSectionIntegrityIssue[];
    ok: boolean;
}
/**
 * Verify that a STORED managed usage section is still a readable ledger.
 *
 * This exists because a write surface can accept a section, report success, and
 * silently destroy part of it. Callers must run this against the bytes read back
 * from the host, never against the payload they sent and never against the
 * mutation's return value — trusting the mutation result is precisely what let a
 * Linear description strip every entry token while reporting `success: true`.
 *
 * @param storedDocument Artifact body or comment body as read back from the host.
 * @param expected Optional expectations from the write that was just performed.
 * @param expected.entryIds Entry ids the caller believes it just persisted.
 * @returns Whether the stored ledger is enumerable, plus every issue found.
 */
export declare function verifyLisaUsageSectionIntegrity(storedDocument: string, expected?: {
    entryIds?: readonly string[];
}): LisaUsageSectionIntegrityResult;
/**
 * Append or replace the canonical `## Lisa Usage` section in a markdown
 * artifact while preserving prior entries that are not being refreshed.
 *
 * @param document Existing artifact markdown or comment body.
 * @param input New usage content to merge into the managed section.
 * @param input.childArtifacts Optional child ledgers to recompute descendant totals from current work.
 * @param input.entries Newly observed direct usage entries.
 * @param input.rollup Optional explicit rollup payload to serialize.
 * @returns The updated artifact markdown with exactly one managed usage block.
 */
export declare function upsertLisaUsageSection(document: string, input: {
    childArtifacts?: readonly LisaUsageChildArtifact[];
    entries: readonly LisaUsageEntry[];
    rollup?: LisaUsageRollup | null;
}): string;
//# sourceMappingURL=usage-accounting.d.ts.map