import { ExtensionAPI } from '@earendil-works/pi-coding-agent'; import { Model, Api, Context, ProviderStreamOptions, AssistantMessage } from '@earendil-works/pi-ai'; type PiModel = Model; interface ModelRegistryView { getAvailable(): PiModel[]; isUsingOAuth(model: PiModel): boolean; getApiKeyAndHeaders(model: PiModel): Promise<{ ok: true; apiKey?: string; headers?: Record; env?: Record; } | { ok: false; error: string; }>; } type CompleteModel = (model: PiModel, context: Context, options?: ProviderStreamOptions) => Promise; type BboxOrder = 'xyxy' | 'yxyx'; interface PromptProfile { id: string; version: number; displayName: string; bboxOrder: BboxOrder; system: string; user: string; modelIds: readonly string[]; estimatedInputTokensPerPage: number; estimatedOutputTokensPerPage: number; } type AccessKind = 'subscription' | 'local' | 'metered' | 'unknown'; interface ModelCandidate { model: PiModel; fullId: string; access: AccessKind; prompt?: PromptProfile; estimatedUsdPerPage?: number; } interface OkraPiConfig { defaultModel?: string; aliases: Record; } interface PageSelection { pages: number[]; description: string; } interface ParsePlan { source: string; pageCount: number; selectedPages: PageSelection; selectedPageCount: number; model: string; provider: string; prompt: string; promptVersion: number; access: AccessKind; estimatedCostUsd?: number; costNote: string; } interface RenderedPage { page: number; png: Uint8Array; width: number; height: number; } interface LayoutBlock { label: string; bbox: [number, number, number, number]; text: string; page: number; } interface UsageSummary { input: number; output: number; cacheRead: number; cacheWrite: number; reasoning: number; totalTokens: number; referenceCostUsd: number; } interface PageParse { page: number; markdown: string; blocks: LayoutBlock[]; rawText: string; usage: UsageSummary; } type ParseProgressPhase = 'planning' | 'planned' | 'authenticating' | 'rendering' | 'requesting' | 'decoded' | 'writing' | 'complete' | 'failed'; interface ParseProgress { phase: ParseProgressPhase; message: string; completedPages: number; totalPages?: number; currentPage?: number; blockCount: number; warningCount: number; model?: string; prompt?: string; } interface ParseResult { markdown: string; blocks: LayoutBlock[]; pages: PageParse[]; usage: UsageSummary; meta: { parserId: 'layout-vlm'; provider: string; model: string; prompt: string; promptVersion: number; access: AccessKind; pageCount: number; durationMs: number; estimatedCostUsd?: number; costUsd?: number; referenceCostUsd?: number; warnings: string[]; }; } interface ParseOptions { model?: string; pages?: string; dpi?: number; maxCostUsd?: number; config?: OkraPiConfig; signal?: AbortSignal; onProgress?: (progress: ParseProgress) => void; } interface WrittenArtifacts { outputDir: string; markdownPath: string; blocksPath: string; manifestPath: string; rawDir: string; rawPaths: string[]; } interface PdfSearchHit { page: number; bbox: [number, number, number, number]; text: string; label?: string; source: 'parsed-blocks' | 'pdf-text'; } interface PdfScreenshotArtifact { page: number; width: number; height: number; path: string; bytes: number; } interface CommandRuntime { cwd: string; registry: ModelRegistryView; completeModel: CompleteModel; onProgress?: (progress: ParseProgress) => void; } declare function tokenizeCommand(input: string): string[]; declare function formatModelTable(registry: ModelRegistryView, config: OkraPiConfig): string; declare function runPdfParseCommand(args: string, runtime: CommandRuntime): Promise; /** @deprecated Use runPdfParseCommand. */ declare const runOkraCommand: typeof runPdfParseCommand; declare function configPath(): string; declare function readConfig(path?: string): Promise; declare function writeConfig(config: OkraPiConfig, path?: string): Promise; declare function fullModelId(model: Pick): string; declare function accessForModel(model: PiModel, registry: ModelRegistryView): AccessKind; declare function estimateModelPageCost(model: PiModel, prompt: PromptProfile): number | undefined; declare function discoverModels(registry: ModelRegistryView): ModelCandidate[]; declare function selectModel(registry: ModelRegistryView, options?: { requested?: string; config?: OkraPiConfig; }): ModelCandidate; declare function costLabel(candidate: ModelCandidate): string; /** * Layout prompt and decoder contract shared with okraPDF's parser-gemini * implementation. Kept in this standalone package so a public checkout can * install and build without monorepo workspace dependencies. * * Derived from ParseBench and @okrapdf/parser-gemini (MIT). */ type DecodedLayoutBlock = { bbox: [number, number, number, number]; label: string; text: string; page?: number; }; declare function parseLayoutBlocks(content: string): DecodedLayoutBlock[]; declare function swapGeminiBbox(blocks: DecodedLayoutBlock[]): DecodedLayoutBlock[]; declare function itemsToMarkdown(blocks: DecodedLayoutBlock[]): string; declare function canonicalLabel(raw: string): string; declare const SYSTEM_PROMPT_LAYOUT: string; declare const USER_PROMPT_LAYOUT: string; declare const SYSTEM_PROMPT_LAYOUT_GEMINI: string; declare const USER_PROMPT_LAYOUT_GEMINI: string; declare function parsePageSelection(value: string | undefined, pageCount: number): PageSelection; declare function planPdfParse(source: string, registry: ModelRegistryView, options?: ParseOptions): Promise<{ plan: ParsePlan; candidate: ModelCandidate; }>; declare class PdfParseDecodeError extends Error { readonly plan: ParsePlan; readonly result: ParseResult; artifacts?: WrittenArtifacts; constructor(message: string, plan: ParsePlan, result: ParseResult); } declare function parsePdf(source: string, registry: ModelRegistryView, completeModel: CompleteModel, options?: ParseOptions): Promise<{ plan: ParsePlan; result: ParseResult; }>; declare function defaultOutputDir(source: string): string; declare function writeParseArtifacts(source: string, result: ParseResult, outputDir?: string): Promise; declare function parsePdfToArtifacts(source: string, registry: ModelRegistryView, completeModel: CompleteModel, options?: ParseOptions, outputDir?: string): Promise<{ plan: ParsePlan; result: ParseResult; artifacts: WrittenArtifacts; }>; declare function pdfPageCount(source: string): Promise; declare function renderPdfPages(source: string, selection: PageSelection, dpi?: number): Promise; declare function searchPdfText(source: string, selection: PageSelection, query: string, options?: { caseSensitive?: boolean; maxResults?: number; }): Promise; declare const PROMPT_PROFILES: readonly PromptProfile[]; declare function promptForModel(model: Pick): PromptProfile | undefined; declare function promptRef(profile: PromptProfile): string; declare function renderPdfScreenshots(source: string, options?: { pages?: string; dpi?: number; outputDir?: string; }): Promise<{ outputDir: string; screenshots: PdfScreenshotArtifact[]; rendered: RenderedPage[]; }>; declare function searchPdf(source: string, query: string, options?: { pages?: string; artifactDir?: string; caseSensitive?: boolean; maxResults?: number; }): Promise<{ hits: PdfSearchHit[]; searched: 'parsed-blocks' | 'pdf-text'; artifactPath?: string; }>; declare function okraPiExtension(pi: ExtensionAPI): void; export { type AccessKind, type BboxOrder, type CommandRuntime, type CompleteModel, type DecodedLayoutBlock, type LayoutBlock, type ModelCandidate, type ModelRegistryView, type OkraPiConfig, PROMPT_PROFILES, type PageParse, type PageSelection, type ParseOptions, type ParsePlan, type ParseProgress, type ParseProgressPhase, type ParseResult, PdfParseDecodeError, type PdfScreenshotArtifact, type PdfSearchHit, type PiModel, type PromptProfile, type RenderedPage, SYSTEM_PROMPT_LAYOUT, SYSTEM_PROMPT_LAYOUT_GEMINI, USER_PROMPT_LAYOUT, USER_PROMPT_LAYOUT_GEMINI, type UsageSummary, type WrittenArtifacts, accessForModel, canonicalLabel, configPath, costLabel, okraPiExtension as default, defaultOutputDir, discoverModels, estimateModelPageCost, formatModelTable, fullModelId, itemsToMarkdown, parseLayoutBlocks, parsePageSelection, parsePdf, parsePdfToArtifacts, pdfPageCount, planPdfParse, promptForModel, promptRef, readConfig, renderPdfPages, renderPdfScreenshots, runOkraCommand, runPdfParseCommand, searchPdf, searchPdfText, selectModel, swapGeminiBbox, tokenizeCommand, writeConfig, writeParseArtifacts };