/**
* Z.AI layout-parsing REST client (GLM-OCR, ADR-0014 D2 — glm-ocr lane T1).
*
* One POST to `/paas/v4/layout_parsing` with the minimal wire
* surface `{model:"glm-ocr", file}` (no page-range flags, no extra
* options — the server owns page-count policy). The default base is the
* PLAIN path `https://api.z.ai/api` (PAYG is account-level); the
* `/coding/` variant's funded-key behavior is a plan-time check, not a
* runtime concern here.
*
* Boundary rules (ARCHITECTURE.md §2):
* - May import normalized errors. Imports no transport beyond the
* injected fetch, no capability contract, no command presentation.
* - Raw response bodies NEVER enter public errors; messages are
* stable sanitized labels.
*
* Decode contract (fail closed): `md_results` must be a nonempty
* string; `id`/`created`/`model` are tolerated and everything else is
* ignored at the boundary. The two bbox spaces (pixel coordinates
* embedded in `md_results` annotations vs normalized `layout_details.
* bbox_2d`) never cross this module — `layout_details` is discarded
* here, so no internal type ever conflates them.
*
* Error mapping: any envelope carrying `error.code === 1113` is the
* exhaustion seam — {@link isInsufficientBalance} detects it in every
* wrapper shape the wire can produce and `parseLayout` surfaces it as
* a terminal `QuotaError` the caller's fallback seam consumes. Every
* other failure maps through the existing zai error classes
* (`AuthError` 401/403, `ApiError` with status, `NetworkError`,
* `TimeoutError`); no bespoke classes.
*
* This transport performs ONE logical attempt; shared execution owns
* retry policy, and the glm-ocr arm runs adapter-internal (no shared
* retry on the fallback seam — ADR-0014 §1).
*/
import type { ProviderLayoutParsingFetch } from "../types.js";
/** Injectable transport dependencies (tests pass fakes for both). */
export interface LayoutParsingDeps {
readonly fetch?: ProviderLayoutParsingFetch;
readonly env?: NodeJS.ProcessEnv;
}
/**
* Whole-request form combining request + injected fetch, for callers
* that prefer one object (the adapter always passes `deps.fetch`
* explicitly; tests use either form). Equivalent to spreading `fetch`
* into `deps`.
*/
export type LayoutParsingCall = LayoutParsingRequest & LayoutParsingDeps;
/** Request shape for one layout-parsing call. */
export interface LayoutParsingRequest {
readonly apiKey: string;
/** `file` wire value: canonical URL string or base64 payload. */
readonly file: string;
/** Overrides the plain default base (tests pin exact URLs). */
readonly baseUrl?: string;
}
/** Injectable timer pair so timeout tests never arm real timers. */
export interface LayoutParsingTimers {
setTimeout: typeof setTimeout;
clearTimeout: typeof clearTimeout;
}
/**
* Whether a decoded payload carries the Z.AI exhaustion code `1113` in
* any wrapper shape the wire can produce. The code may be numeric or
* string, at the top level or under `data` — both were observed in
* live probes (2026-09-10/20, plan key). Message-only shapes are
* deliberately NOT matched: the code is authoritative.
*/
export declare function isInsufficientBalance(payload: unknown): boolean;
/**
* POST one layout-parsing request and return the normalized text
* (`md_results`). One logical attempt: no internal retry, no cache —
* the adapter caller owns both (ADR-0014 D4).
*/
export declare function parseLayout(request: LayoutParsingRequest, timers: LayoutParsingTimers, deps?: LayoutParsingDeps): Promise;
//# sourceMappingURL=layout-parsing.d.ts.map