import type { OpenCodeClient, SessionInfo } from "@opencode/client"; import type { ContextSources } from "./context-sources.js"; import type { ReadActiveSessions } from "./performance.js"; import type { PriceCatalog, UsageMessage } from "./usage.js"; export type Session = Pick & Partial>; export interface Page { data: T[]; cursor: { next?: string | null; previous?: string | null; }; } /** Active model of the viewed session plus the location's current resolved price catalog. */ export interface ActiveModel { label: string; catalog: PriceCatalog; context?: number | undefined; } export interface UsageSource { session(id: string, signal: AbortSignal): Promise; children(id: string, cursor: string | undefined, signal: AbortSignal): Promise>; messages(id: string, cursor: string | undefined, signal: AbortSignal): Promise>; model(session: Session, signal: AbortSignal): Promise; composition?(session: Session, signal: AbortSignal): Promise; active?: ReadActiveSessions; } export declare function createSource(client: OpenCodeClient): UsageSource; export declare function pages(read: (cursor?: string) => Promise>, signal: AbortSignal): Promise; export interface Snapshot { rootID: string; viewedID: string; sessions: Map; messages: Map>; model: ActiveModel; } /** A changed set permits reuse of unchanged histories. Omitting it forces a full read. */ export declare function loadSnapshot(source: UsageSource, sessionID: string, signal: AbortSignal, previous?: Snapshot, changed?: ReadonlySet): Promise; /** History of the viewed session only, in API order (`order: "asc"`). */ export declare function viewedMessages(snapshot: Snapshot): readonly UsageMessage[]; export declare function uniqueMessages(snapshot: Snapshot): Iterable;