import type { Symbol, Edge } from './types.js'; /** * Options for the streaming encoder. */ export interface StreamOptions { tokenBudget?: number; tokensUsed?: number; packRoot?: string; session?: boolean; /** * Opt into the labeled trailer counts form (SPEC ยง8.4.1): the graph * "##! summary" counts field is emitted as label:count per entry * (e.g. counts=targets:1,related:1,edges:1). Default/undefined emits the * positional form (counts=1,1,1), unchanged and byte-identical to today. */ labeledTrailerCounts?: boolean; } /** * A writable sink for streaming output. Accepts string chunks. * Compatible with Node.js streams, web WritableStreams, or simple callbacks. */ export interface StreamWriter { write(chunk: string): void; } /** * StreamEncoder writes GCF output incrementally as symbols and edges arrive. * Zero buffering: each symbol/edge is written immediately. A trailer summary * is emitted on close() with the final counts. * * @example * ```ts * const chunks: string[] = []; * const enc = new StreamEncoder({ write: (s) => chunks.push(s) }, 'context_for_task', { tokenBudget: 5000 }); * enc.writeSymbol({ qualifiedName: 'pkg.Auth', kind: 'function', score: 0.95, provenance: 'lsp', distance: 0 }); * enc.writeEdge({ source: 'pkg.Server', target: 'pkg.Auth', edgeType: 'calls' }); * enc.close(); * ``` */ export declare class StreamEncoder { private w; private symIndex; private nextID; private currentGroup; private groupCounts; private edgeCount; private edgesStarted; private labeledTrailerCounts; constructor(w: StreamWriter, tool: string, opts?: StreamOptions); private writeHeader; /** * Emit a symbol line immediately. Group headers are emitted automatically * when the distance changes. */ writeSymbol(s: Symbol): void; /** * Emit an edge line immediately. The edges section header is emitted * automatically on the first edge (with [?] deferred count). * Source and target must reference previously-written symbols. */ writeEdge(e: Edge): void; /** * Emit a bare reference for a previously-transmitted symbol (session mode). */ writeBareRef(qname: string, distance: number): void; /** * Emit the ##! summary trailer with final counts. Must be called after all * symbols and edges have been written. */ close(): void; /** Number of symbols written so far. */ get symbolCount(): number; /** Number of edges written so far. */ get edgeCount_(): number; } //# sourceMappingURL=stream.d.ts.map