import type { Adapter } from "../../adapter.js"; export type RuntimeContextTelemetry = { state: "observed"; used_tokens: number; limit_tokens: number; measured_at: string; method: "codex_transcript_token_count" | "claude_transcript_usage_model_capability"; source_event: string; source_witness: string; attestation: "derived" | "inferred"; confidence: "exact" | "high" | "medium"; bytes_read: number; io_duration_ms: number; } | { state: "observed"; used_percent: number; measured_at: string; method: "cursor_composer_context_percent"; source_event: string; source_witness: string; attestation: "derived"; confidence: "high"; runtime_version?: string; bytes_read: number; io_duration_ms: number; } | { state: "partial"; reason: RuntimeContextMissingReason; used_tokens?: number; measured_at?: string; bytes_read: number; io_duration_ms: number; } | { state: "unsupported"; reason: RuntimeContextUnsupportedReason; bytes_read: 0; io_duration_ms: number; }; export type RuntimeContextMissingReason = "codex_transcript_ambiguous" | "codex_transcript_session_mismatch" | "codex_transcript_unreadable" | "codex_transcript_turn_not_found" | "codex_transcript_turn_not_terminal" | "codex_transcript_token_count_missing" | "codex_transcript_sample_stale" | "context_used_tokens_not_reported" | "context_limit_tokens_not_reported" | "context_limit_tokens_invalid" | "claude_context_limit_tokens_not_reported" | "claude_transcript_sample_stale" | "claude_transcript_session_mismatch" | "claude_transcript_turn_not_found" | "claude_transcript_unreadable" | "cursor_context_database_unavailable" | "cursor_context_database_unreadable" | "cursor_context_session_not_found" | "cursor_context_sample_ambiguous" | "cursor_context_sample_stale" | "cursor_context_sample_time_not_reported" | "cursor_context_usage_invalid"; export type RuntimeContextUnsupportedReason = "runtime_context_telemetry_unavailable" | "runtime_session_id_not_reported" | "runtime_turn_id_not_reported" | "runtime_adapter_not_supported"; export interface RuntimeContextRequest { adapter: Adapter; session_id?: string; turn_id?: string; /** Canonical producer turn boundary used when task_started has left the bounded tail. */ turn_started_at?: string; transcript_path?: string; observed_at?: string; /** * Status reads the newest session sample without turn attribution. Active * turn reads require a matching task_started boundary but not task_complete. */ mode: "turn" | "active_turn" | "status"; } export interface RuntimeTelemetryOptions { codexRoots?: string[]; cursorRoots?: string[]; maxCursorDatabases?: number; maxTailBytes?: number; maxSampleAgeMs?: number; /** Recorder-only cadence override used by deterministic tests. */ activeContextProbeIntervalMs?: number; } /** * Read privacy-safe context telemetry from a local runtime transcript. * * The returned union contains only numeric measurements, timestamps, bounded * I/O counters, and a privacy-safe witness. Transcript bodies and paths never * cross this interface. */ export declare function readRuntimeContextTelemetry(request: RuntimeContextRequest, options?: RuntimeTelemetryOptions): RuntimeContextTelemetry; /** * Locate a Codex rollout transcript for a session when the hook payload * carries no transcript_path. Codex omits the path on its hook events, which * leaves transcript-backed evidence unavailable unless Harnery resolves the * rollout itself. Discovery reuses the telemetry scanner's roots (native * ~/.codex plus WSL-mounted Windows homes) and its process cache, and returns * undefined on zero or ambiguous matches. * * Callers on repeated hook paths must retain the verified result in their * owner-only session state. The process cache bounds repeated reads inside one * process, but hook processes are intentionally short-lived. */ export declare function discoverCodexSessionTranscript(sessionId: string | undefined, transcriptPath?: string, options?: RuntimeTelemetryOptions): string | undefined; /** Status compatibility wrapper: exact pairs render; partial values do not. */ export declare function readRuntimeContextUsage(adapter: Adapter, sessionId: string, options?: RuntimeTelemetryOptions): { used: number; window: number; } | null; export declare function clearRuntimeTelemetryCachesForTest(): void; export type RuntimeTuningMissingReason = "codex_transcript_ambiguous" | "codex_transcript_session_mismatch" | "codex_transcript_unreadable" | "codex_transcript_turn_context_missing" | "claude_transcript_unreadable" | "claude_transcript_assistant_row_missing"; /** * Privacy-safe tuning identity read from a local runtime transcript. * * `observed` means the newest identity-bearing row was read: a Codex * `turn_context` row or a CC assistant row with a real model id. An observed * result with NO `effort` is itself evidence — CC omits the field exactly when * the model has no effort dial — so callers must distinguish it from * `partial`/`unsupported`, where nothing was established. */ export type RuntimeTuningTelemetry = { state: "observed"; model?: string; effort?: string; speed?: string; measured_at?: string; method: "codex_transcript_turn_context" | "claude_transcript_assistant_row"; source_event: string; bytes_read: number; io_duration_ms: number; } | { state: "partial"; reason: RuntimeTuningMissingReason; bytes_read: number; io_duration_ms: number; } | { state: "unsupported"; reason: RuntimeContextUnsupportedReason; bytes_read: 0; io_duration_ms: number; }; export interface RuntimeTuningRequest { adapter: Adapter; session_id?: string; transcript_path?: string; } /** * Read the newest observed tuning (effort, and speed where reported) for a * session from its local runtime transcript. * * Codex: the newest `turn_context` row carries the EFFECTIVE per-turn effort, * including `-c model_reasoning_effort` overrides (the config default is * deliberately not consulted — it is the default, not the effective value). * CC: the newest assistant row carries effort at the row's top level and * speed inside `message.usage`; model, effort, and speed are read from the * SAME row so a mid-session model swap cannot blend two rows' values. * * Same bounded tail-read and privacy posture as `readRuntimeContextTelemetry`: * only tokens, timestamps, and I/O counters cross this interface. */ export declare function readRuntimeTuning(request: RuntimeTuningRequest, options?: RuntimeTelemetryOptions): RuntimeTuningTelemetry; //# sourceMappingURL=runtime-telemetry.d.ts.map