import type { SessionEvent } from './types.js';
import { type ShellProgramOccurrence } from './shell-programs.js';
export declare const TOOL_INPUT_MAX_BYTES: number;
export declare const TOOL_SUCCESS_OUTPUT_MAX_BYTES = 1024;
export declare const TOOL_ERROR_OUTPUT_MAX_BYTES: number;
export declare const TOOL_SESSION_EVIDENCE_MAX_BYTES: number;
export declare const TOOL_PENDING_MAX_BYTES: number;
export declare const TOOL_PENDING_MAX_CALLS = 256;
export declare const TOOL_CHANGED_MAX_CALLS = 10000;
export declare const TOOL_INDEX_LIMIT_ORDINAL: number;
export declare const TOOL_TEXT_PROCESSING_MAX_BYTES: number;
export declare const TOOL_SHELL_PARSE_MAX_BYTES: number;
export declare const TOOL_INDEX_VERSION = 8;
export type ToolCallOutcome = 'ok' | 'error' | 'unknown';
export interface IndexedToolCall {
    ordinal: number;
    sourceCallId?: string;
    timestamp: string;
    /**
     * When the call's RESULT record arrived — the call's own end time, taken from
     * the tool_result transcript record at `finish()` (PHNX-3437). `timestamp` is
     * the start; `endTimestamp - timestamp` is the call's own blocking duration,
     * which the traces insight engine attributes as a failed call's wasted time.
     * Undefined for a call that never produced a result (still pending at scan end)
     * and for rows produced by an older extractor.
     */
    endTimestamp?: string;
    tool: string;
    programs: string[];
    programOccurrences: ShellProgramOccurrence[];
    input: string;
    outcome: ToolCallOutcome;
    exitCode?: number;
    statusCode?: number;
    errorCode?: string;
    output?: string;
    error?: string;
    parseError?: string;
}
export interface ToolCallCollectorSnapshot {
    v: 1;
    nextOrdinal: number;
    pending: IndexedToolCall[];
}
export declare function sanitizeToolEvidenceText(value: string, maxBytes: number, knownValues?: readonly string[]): string;
/** Extract literal shell commands from the Codex orchestration tool without evaluating transcript code. */
export declare function commandsFromCodexExec(source: string): string[];
export declare function structuredToolResult(value: unknown): {
    text: string;
    outcome: ToolCallOutcome;
    exitCode?: number;
    statusCode?: number;
    errorCode?: string;
};
export declare function toolCallEvidenceBytes(call: IndexedToolCall): number;
export declare class ToolCallCollector {
    private nextOrdinal;
    private readonly pendingById;
    private readonly pendingOrder;
    private readonly changed;
    private readonly changedSizes;
    private pendingBytes;
    private changedBytes;
    private changedTruncated;
    constructor(snapshot?: ToolCallCollectorSnapshot);
    start(args: {
        timestamp: string;
        tool: string;
        input?: Record<string, unknown>;
        command?: string;
        sourceCallId?: string;
    }): IndexedToolCall;
    finish(args: {
        timestamp: string;
        sourceCallId?: string;
        tool?: string;
        success?: boolean;
        outcome?: ToolCallOutcome;
        exitCode?: number;
        statusCode?: number;
        errorCode?: string;
        output?: string;
        error?: string;
    }): IndexedToolCall | undefined;
    drainChanged(): IndexedToolCall[];
    snapshot(): ToolCallCollectorSnapshot;
    recordIndexLimit(): void;
    private rememberPending;
    private takePending;
    private removePending;
    private markChanged;
}
/** The prior scan's resume point for an append-only event stream. */
export interface EventToolScanResumePoint {
    /** ToolCallCollector snapshot after folding `eventCount` events. */
    snapshot: ToolCallCollectorSnapshot;
    /** How many events had been folded when the snapshot was taken. */
    eventCount: number;
}
export interface EventToolScanResult {
    /** The CHANGED calls — an append-safe upsert set, not the whole history. */
    calls: IndexedToolCall[];
    /** Serialized-ready snapshot to persist for the next incremental scan. */
    snapshot: ToolCallCollectorSnapshot;
    /** Events folded so far — the next scan's resume offset into `events`. */
    eventCount: number;
}
/**
 * Derive tool calls from a full-file harness's normalized events, optionally
 * RESUMING from a prior scan of the same append-only stream.
 *
 * Without `prior` this is a full parse from event 0 (identical to the legacy
 * {@link toolCallsFromEvents}). With `prior`, the collector is seeded from the
 * prior snapshot and only events at or after `prior.eventCount` are folded — so
 * an active session that grew by a few turns re-derives (and re-redacts) only
 * those new tool calls instead of re-sanitizing its entire history on every
 * daemon warm tick (PHNX-3411). The ordinals continue deterministically from the
 * snapshot, so folding [0..k) then [k..n) yields the same index as folding
 * [0..n) once, and the CHANGED set is safe to persist with `mode: 'append'`.
 *
 * The caller is responsible for only supplying `prior` when the stream is still
 * an append of what was scanned before (same source, un-truncated,
 * `prior.eventCount <= events.length`); anything else must full-scan.
 */
export declare function scanEventToolCalls(events: SessionEvent[], prior?: EventToolScanResumePoint): EventToolScanResult;
/** Build indexed calls from the normalized parser contract used by full-file harnesses. */
export declare function toolCallsFromEvents(events: SessionEvent[]): IndexedToolCall[];
export declare function toolCallKey(sessionId: string, ordinal: number): string;
/** Fold one raw Claude record into the resumable call collector. */
export declare function collectClaudeToolCalls(collector: ToolCallCollector, parsed: any): void;
/** Fold one raw Codex rollout record into the resumable call collector. */
export declare function collectCodexToolCalls(collector: ToolCallCollector, parsed: any): void;
