/** * Web reader command — thin handler over the Reader Capability * (DESIGN.md §18, reader-migration-core-flows, reader-migration-tech-plan * Ticket 04). * * The handler applies parse-level validation only (URL scheme, --extract * mode), delegates to `capability.fetch(request)` through shared * execution, then projects the normalized `ReaderFetchResult` into the * public v1 envelope(s) (content read vs extract read). The Adapter * (providers/zai/reader.ts) owns URL rewrite, credentials, transport, * raw response parsing, cache identity, and retry/terminal * classification; the handler owns projection (`--max-chars` * whole-envelope budgeting at the dispatcher seam, `--extract` slicing), output-mode presentation, and the * schema-version-1 envelope migration. * * Provider selection, capability support, configuration, Adapter * construction, and adapter.reader agreement live in `src/index.ts`. * * Handler interface (P6-07A pattern): `deps: ReadHandlerDependencies` * is REQUIRED — production and direct tests cross the same compile- * checked Interface. An optional trailing `CommandContext` follows when * a caller wants to surface per-invocation context; the handler does * not currently read it. A `CommandContext` is NOT a valid substitute * for `deps`. * * Output-mode behavior (core-flows table): * * - data: the envelope object (content or extract). * - json / pretty: standard `{success, data, timestamp}` envelope. * - compact / markdown / refs / tty: * * content read → the `content` string directly (presentations). * * extract read → JSON fallback (the extract envelope object); * no presentation override because extracted items are data, * not prose. * * `--full-envelope` is silently accepted and ignored (D3): the v1 * envelope is always returned. */ import type { CommandContext, CommandResult } from "../command-invocation.js"; import type { ReaderCapability } from "../capabilities/reader.js"; import type { ExecutionDependencies } from "../lib/execution.js"; import { type ExtractMode } from "../lib/extract.js"; import { type LadderRule } from "../lib/output-budget.js"; export interface ReadOptions { format?: "markdown" | "text"; noImages?: boolean; withLinks?: boolean; timeout?: number; noCache?: boolean; noGfm?: boolean; keepImgDataUrl?: boolean; withImagesSummary?: boolean; /** * Silently accepted and ignored at v1 (core-flows D3). The envelope * is always returned. Retained on the options type so callers and * `handleRead` parse it without errors; it never reaches the Adapter * request, the cache identity, or the projection. */ fullEnvelope?: boolean; extract?: ExtractMode; } /** * Dependencies injected by `src/index.ts` after Provider selection, * capability support check, configuration check, Adapter construction, * and adapter.reader agreement. The handler never resolves a Provider * descriptor itself. Required — a caller that omits `deps` is malformed * and fails loudly (a `CommandContext` is NOT a valid substitute). */ export interface ReadHandlerDependencies { readonly capability: ReaderCapability; readonly execution: ExecutionDependencies; } /** * The read Output Budget ladder: content reads walk * trim-last-paragraphs → drop-bottom-sections; extract reads walk * trim-item-values only (exported separately — the two envelope shapes * share one command but never one ladder). */ export declare const READ_LADDER: readonly [LadderRule, LadderRule]; export declare const READ_EXTRACT_LADDER: readonly [LadderRule]; /** * Output Budget T4: rebuild the text presentations from a budgeted * content projection so -O compact/markdown/refs/tty reflect the * shrunken `content` (the same string every text mode emits). */ export declare function budgetedContentPresentations(content: string): { compact: string; markdown: string; refs: string; tty: string; }; /** * Read web page content through the injected Reader Capability. * * Ordering: * 1. Parse-level validation (URL scheme, --extract mode). Throws * `ValidationError` BEFORE the Adapter or shared execution is * reached. * 2. Build the Provider-neutral request and delegate to * `executeProviderOperation` with shared cache + retry policy. * 3. Project the normalized result: * - `--extract` slicing into the extract envelope (sets `mode`, * `items`, `originalItemCount`); whole-envelope `--max-chars` * budgeting happens at the handler seam (index.ts, READ_EXTRACT_LADDER). * - Otherwise, whole-envelope `--max-chars` budgeting at the * handler seam (index.ts, READ_LADDER); the legacy per-field * `truncateContent` projection is deleted (ADR-0007, issue #105) * and a smuggled `maxChars` fails loud. * 4. Set presentations so text-oriented modes (compact/markdown/ * refs/tty) emit `content` directly for content reads. Extract * reads omit presentations; text modes then fall back to JSON * (the extract envelope), matching the core-flows table. */ export declare function read(url: string, options: ReadOptions | undefined, deps: ReadHandlerDependencies, _context?: CommandContext): Promise; export declare const READ_HELP: string; //# sourceMappingURL=read.d.ts.map