/** * Read a collected connector result in bounded pieces. * * A result file can be tens of megabytes (a ChatGPT export with thousands of * conversations), far past what an agent can take in one tool result. These * helpers describe a result by scope (item counts and byte sizes) and page * through one scope's items with an optional text filter, never returning * more than a fixed number of bytes. * * Pure functions over the parsed result; no file or terminal access. */ /** Top-level keys that describe a run rather than hold collected data. */ export declare const RESULT_METADATA_KEYS: Set; /** The last segment of a scope key, `github.repositories` -> `repositories`. */ export declare function scopeLeaf(scope: string): string; /** * The list of items a scope holds, or null when it holds one record. * * Connectors write a scope three ways: a bare array, a wrapper named after * the stream (`{ messages: [...] }`, `{ conversations: [...], total: 3 }`), * or a single record such as a profile. */ export declare function scopeList(scope: string, value: unknown): unknown[] | null; export interface ScopeOverview { scope: string; /** "list" pages by item; "record" is one object returned whole. */ kind: "list" | "record"; items: number; bytes: number; } /** Data-bearing keys of a result, in file order. */ export declare function dataScopeKeys(data: Record): string[]; export declare function describeScopes(data: Record): ScopeOverview[]; /** * Match a requested scope to a key in the result. Accepts the exact key * (`github.repositories`) or its last segment (`repositories`). */ export declare function resolveScopeKey(data: Record, requested: string): string | null; export declare const DEFAULT_SLICE_LIMIT = 20; export declare const MAX_SLICE_LIMIT = 500; /** Hard cap on the serialized items in one slice. */ export declare const DEFAULT_SLICE_MAX_BYTES = 100000; export interface SliceOptions { scope: string; offset?: number; limit?: number; query?: string; maxBytes?: number; } export interface DataSlice { scope: string; kind: "list" | "record"; /** Items in the scope, before the query filter. */ total: number; /** Items that match `query` (equals `total` without one). */ matched: number; query: string | null; offset: number; returned: number; /** Offset to pass for the next page, or null when this is the last. */ nextOffset: number | null; /** True when the byte cap cut the page short or shortened an item. */ truncated: boolean; note: string; items: unknown[]; } export declare class UnknownScopeError extends Error { readonly requested: string; readonly available: string[]; constructor(requested: string, available: string[]); } /** * One page of a scope's items. Items are filtered by `query` * (case-insensitive substring over each item's JSON), then paged by * `offset`/`limit`, then cut so the page stays under `maxBytes`. A single * item larger than the cap comes back as a truncated JSON preview. */ export declare function sliceScope(data: Record, options: SliceOptions): DataSlice; //# sourceMappingURL=data-slice.d.ts.map