/** * Bounded reads and rendering of one durable child's own session log. * * The inspector is a temporary live-region surface over Harness's own record, * not a second transcript database. It keeps a lightweight seq index plus ONE * bounded page of full event bodies, reads a further page only when the reader * asks for adjacent history, and renders each event with Harness's * `extractSessionEventText` — the same presentation helper `/sessions` uses. * Nothing here folds the log, and nothing resumes or publishes the child. * * The page size is a real tradeoff rather than a round number: Harness caps * `readEvent` context at 50 events per side, and a child turn is roughly six to ten * raw events, so 24 spans about two or three turns of conversation while * keeping the retained bodies small. * @module dshline/subagents/transcript */ import type { SessionEvent, SessionId, SessionSeq } from '@deepseek-ai/dsh-session'; import type { SessionEventRecord } from '@deepseek-ai/dsh-session-query'; import type { ChildSessionReads } from './seam.ts'; /** * Full event bodies retained by one page read. * * Deliberately below Harness's 50-event context cap so a tail read of * `before: TRANSCRIPT_PAGE - 1` plus its target never asks for more than the * engine will serve. */ export declare const TRANSCRIPT_PAGE = 24; /** * What the conversation inspector can truthfully show. * * `stale` is only a presentation hint that a child session event arrived after * the window was read; the reader reloads on an explicit gesture, because * Harness publishes no per-child transcript subscription and polling one would * be a timer-backed state machine this frontend must not own. */ export type SubagentTranscriptReading = { readonly kind: 'unavailable'; } | { readonly kind: 'loading'; } | { readonly kind: 'empty'; } | { readonly kind: 'failed'; readonly message: string; } | { readonly kind: 'ready'; readonly events: readonly SessionEvent[]; readonly hasOlder: boolean; readonly hasNewer: boolean; readonly stale: boolean; }; /** The reader's retained state: the seq index plus one loaded window. */ export interface TranscriptState { /** Which reading this state resolves to. */ readonly kind: 'unavailable' | 'loading' | 'empty' | 'failed' | 'ready'; /** Harness's lightweight seq index for the whole child log. */ readonly index: readonly SessionEventRecord[]; /** The loaded window's full bodies, ascending by seq. */ readonly events: readonly SessionEvent[]; /** First seq of the loaded window, when one is loaded. */ readonly startSeq?: SessionSeq; /** Last seq of the loaded window, when one is loaded. */ readonly endSeq?: SessionSeq; /** Whether an older page exists in the captured index. */ readonly hasOlder: boolean; /** Whether a newer page exists in the captured index. */ readonly hasNewer: boolean; /** Whether a child session event arrived since the index was refreshed. */ readonly stale: boolean; /** Harness's or the transport's failure message, when the read failed. */ readonly message?: string; } /** * The state before any read has answered. * @param available - whether the profile mounts a session-query read surface. * @returns a loading state, or the honest capability absence. */ export declare function initialTranscript(available: boolean): TranscriptState; /** * Project the reader's state onto the small reading the overlay draws. * @param state - the retained reader state. * @returns the terminal-facing reading. */ export declare function transcriptReading(state: TranscriptState): SubagentTranscriptReading; /** * Read the newest page of one child's durable log. * * Two reads, both on demand: `listEvents` supplies the seq index (and the tail * seq a bounded window needs), and `readEvent` supplies the full bodies for the * newest page. No Agent is loaded, no turn is started, and the child's own * session log stays the only authority. * @param query - the bounded child-session read surface. * @param childId - the durable child session to read. * @param signal - caller cancellation, observed before the state is published. * @returns the newest page's state, or an honest failure state. */ export declare function readTranscriptTail(query: ChildSessionReads, childId: SessionId, signal?: AbortSignal): Promise; /** * Read one older page, replacing the currently loaded window. * * The index from {@link readTranscriptTail} locates the record immediately * before the window, so paging walks the log backwards without re-reading it. * The read REPLACES the window rather than prepending to it: the module's * contract is one bounded page of full bodies, and an accumulating window would * let `[` grow presenter state to the whole child log. `r` returns to the newest * page. The new window `[previous - (TRANSCRIPT_PAGE - 1) .. previous]` is * disjoint from the old one, so no de-duplication is needed. * @param query - the bounded child-session read surface. * @param childId - the durable child session being inspected. * @param state - the currently loaded reader state, whose page is replaced. * @param signal - caller cancellation. * @returns the state with the older page loaded in place of the current one. * @throws when the read fails; the caller keeps the loaded window and reports * the failure as a notice rather than discarding history it already has. */ export declare function readTranscriptOlder(query: ChildSessionReads, childId: SessionId, state: TranscriptState, signal?: AbortSignal): Promise; /** * Read one newer page inside the captured index, replacing the loaded window. * * Anchor at the END of the next captured slice so the Harness request itself * ends at the captured destination. Requesting only preceding context also * keeps forward navigation aligned with the tail/older `after: 0` reads and * reverses the tail-derived partition without repartitioning a partial oldest * page. * @param query - the bounded child-session read surface. * @param childId - the durable child session being inspected. * @param state - the captured index and currently loaded page. * @param signal - caller cancellation. * @returns the next captured page, preserving the index and staleness hint. * @throws when the read fails; the caller retains the current page and facts. */ export declare function readTranscriptNewer(query: ChildSessionReads, childId: SessionId, state: TranscriptState, signal?: AbortSignal): Promise; /** * Render the loaded window as bounded terminal rows. * * An event with no semantic text — a structural boundary or an unknown * declaration-merged type — deliberately contributes only its metadata row, * exactly as `/sessions` does, rather than a stringified payload. * @param reading - the terminal-facing reading. * @param width - display columns inside the frame. * @returns one metadata row per event, plus wrapped body rows. */ export declare function transcriptRows(reading: SubagentTranscriptReading, width: number): string[]; //# sourceMappingURL=transcript.d.ts.map