import { O as OkraClient } from '../client-CD1UgTAe.js'; import 'effect/Cause'; import 'effect/Types'; import '@okrapdf/component'; import 'effect'; import '../types-R6f5p55r.js'; import 'zod'; /** * CLI Types for okraPDF Review Operations * * These types mirror the review page UI interactions: * - Left panel: Document tree (verification status, entity counts) * - Middle panel: PDF viewer (entities, overlays) * - Right panel: Page content (markdown, versions) */ type VerificationPageStatus = 'complete' | 'partial' | 'flagged' | 'pending' | 'empty' | 'gap' | 'error'; interface VerificationTreePage { page: number; status: VerificationPageStatus; total: number; verified: number; pending: number; flagged: number; rejected: number; avgConfidence: number; hasOcr: boolean; ocrLineCount: number; hasCoverageGaps: boolean; uncoveredCount: number; resolution: string | null; classification: string | null; isStale: boolean; } interface VerificationTreeSummary { complete: number; partial: number; flagged: number; pending: number; empty: number; gap: number; resolved?: number; stale?: number; } interface VerificationTree { jobId: string; documentId: string; totalPages: number; summary: VerificationTreeSummary; pages: VerificationTreePage[]; } type EntityType = 'table' | 'figure' | 'footnote' | 'summary' | 'signature' | 'paragraph'; interface EntityBBox { x: number; y: number; width: number; height: number; } interface Entity { id: string; type: EntityType; title: string | null; page: number; schema?: string[]; isComplete?: boolean; bbox?: EntityBBox; confidence?: number; verificationStatus?: 'pending' | 'verified' | 'flagged' | 'rejected'; } interface EntitiesResponse { jobId: string; entities: Entity[]; counts: { tables: number; figures: number; footnotes: number; summaries: number; signatures?: number; }; extractionStatus?: 'not_started' | 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused'; totalPages?: number; } interface TextBlock { text: string; bbox?: EntityBBox; confidence?: number; } interface PageDimension { width: number | null; height: number | null; } interface PageContent { page: number; content: string; version?: number; blocks?: TextBlock[]; dimension?: PageDimension | null; } interface PageVersionInfo { version: number; editSource: 'ocr_extraction' | 'user_edit' | 'ai_correction'; createdAt: string | null; preview: string; } interface PageVersionsResponse { page: number; currentVersion: number; versions: PageVersionInfo[]; } interface Table { id: string; pageNumber: number; markdown: string; bbox: { xmin: number; ymin: number; xmax: number; ymax: number; }; confidence: number | null; verificationStatus: 'pending' | 'verified' | 'flagged' | 'rejected'; verifiedBy: string | null; verifiedAt: string | null; wasCorrected?: boolean; createdAt: string; } interface TablesResponse { tables: Table[]; source: 'job_id' | 'document_uuid'; } type MatchSource = 'content' | 'table_title' | 'table_schema' | 'table_row' | 'figure' | 'footnote' | 'summary' | 'signature' | 'paragraph'; interface SearchResult { page: number; snippet: string; matchCount: number; matchSource?: MatchSource; } interface SearchResponse { query: string; totalMatches: number; results: SearchResult[]; } interface HistoryEntry { id: string; entityType: string; entityId: string; state: string; previousState: string | null; transitionName: string | null; triggeredBy: string | null; triggeredByName: string | null; reason: string | null; resolution: string | null; classification: string | null; pageNum: number | null; createdAt: string; } interface HistoryResponse { history: HistoryEntry[]; } type OutputFormat = 'text' | 'json' | 'markdown'; interface TreeOptions { status?: VerificationPageStatus; entity?: EntityType; format?: OutputFormat; } interface PageGetOptions { format?: OutputFormat; version?: number; } interface PageResolveOptions { resolution: string; classification?: string; reason?: string; } interface TablesOptions { page?: number; status?: 'pending' | 'verified' | 'flagged' | 'rejected'; format?: OutputFormat; } interface HistoryOptions { limit?: number; format?: OutputFormat; } interface QueryConfig { selector: string; topK?: number; minConfidence?: number; pageRange?: [number, number]; sortBy?: 'confidence' | 'page' | 'type'; } /** * Query Engine - jQuery-like entity selector * * Inspired by okra-jquery from ~/dev/okrapdf/lib/okra-jquery * Supports selectors like: * - Type: .table, .figure, .footnote * - ID: #entity_123 * - Attributes: [confidence>0.9], [verified=true] * - Page: :page(5), :pages(1-10) * - Combinators: .table[confidence>0.9], .table, .figure */ interface SelectorParts { types: EntityType[]; id?: string; pageFilter?: { type: 'single' | 'range'; value: number | [number, number]; }; confidenceFilter?: { op: '>' | '<' | '>=' | '<='; value: number; }; verificationFilter?: 'pending' | 'verified' | 'flagged' | 'rejected'; textContains?: string; } /** * Parse a jQuery-like selector string into parts. * * Examples: * - ".table" -> { types: ['table'] } * - ".table, .figure" -> { types: ['table', 'figure'] } * - ".table:page(5)" -> { types: ['table'], pageFilter: { type: 'single', value: 5 } } * - "[confidence>0.9]" -> { confidenceFilter: { op: '>', value: 0.9 } } * - ".table[confidence>=0.8]:page(1-10)" -> complex filter */ declare function parseSelector(selector: string): SelectorParts; /** * Filter entities based on parsed selector parts. */ declare function filterEntities(entities: Entity[], parts: SelectorParts): Entity[]; interface QueryOptions { topK?: number; minConfidence?: number; pageRange?: [number, number]; sortBy?: 'confidence' | 'page' | 'type'; } interface QueryStats { total: number; byType: Record; byPage: Record; avgConfidence: number; minConfidence: number; maxConfidence: number; } interface QueryResult { entities: Entity[]; total: number; stats: QueryStats; } /** * Execute a query against entities. */ declare function executeQuery(entities: Entity[], selector: string, options?: QueryOptions): QueryResult; /** * Calculate aggregate statistics for entities. */ declare function calculateStats(entities: Entity[]): QueryStats; interface FindOptions extends QueryOptions { stats?: boolean; format?: 'text' | 'json' | 'entities' | 'ids'; } /** * Find entities matching a selector. */ declare function find(client: OkraClient, jobId: string, selector: string, options?: FindOptions): Promise; /** * Format find result for output. */ declare function formatFindOutput(result: QueryResult, format?: 'text' | 'json' | 'entities' | 'ids', showStats?: boolean): string; /** * Format stats only. */ declare function formatStats(stats: QueryStats): string; interface SearchOptions { format?: 'text' | 'json'; limit?: number; } /** * Search page content. */ declare function search(client: OkraClient, jobId: string, query: string): Promise; /** * Format search results for output. */ declare function formatSearchOutput(result: SearchResponse, format?: 'text' | 'json'): string; interface AuthVerificationResult { authenticated: true; user_id: string; key_id: string; key_name?: string | null; key_type?: string | null; scope?: string | null; scoped_orgs?: string[]; scoped_projects?: string[]; } declare function maskApiKey(apiKey: string): string; declare function verifyApiKey(apiKey: string, options?: { baseUrl?: string; }): Promise; /** * Login command - set API key in global config. */ declare function authLogin(providedApiKey?: string): Promise; /** * Set API key non-interactively. */ declare function authSetKey(apiKey: string): Promise; interface AuthStatusOptions { validate?: boolean; json?: boolean; output?: string; } /** * Status command - show current auth status. */ declare function authStatus(options?: AuthStatusOptions): Promise; /** * Print active API key to stdout (for piping). */ declare function authToken(): Promise; /** * WhoAmI command - currently aliases auth status. */ declare function authWhoAmI(): Promise; /** * Logout command - remove API key from global config. */ declare function authLogout(): Promise; interface OkraConfig { apiKey?: string; baseUrl?: string; activeProfile?: string; profiles?: Record; } interface OkraProfile { baseUrl?: string; apiKey?: string; createdAt?: string; updatedAt?: string; } /** * Get the global config directory path. * Supports XDG_CONFIG_HOME convention. */ declare function getGlobalConfigDir(): string; /** * Get the global config file path. */ declare function getGlobalConfigPath(): string; declare function readGlobalConfig(): OkraConfig | null; declare function writeGlobalConfig(config: OkraConfig): void; /** * Find and read project config from current directory. * Checks for .okrarc and .okra.json */ declare function readProjectConfig(): OkraConfig | null; /** * Get API key from all sources with proper priority. * * Priority order: * 1. Environment variable: OKRA_API_KEY * 2. Project config: .okrarc or .okra.json * 3. Active global profile: ~/.okra/config.json profiles[activeProfile] * 4. Global config: ~/.okra/config.json */ declare function getApiKey(): string | undefined; /** * Get base URL from all sources with proper priority. * * 1. `--host` flag (setHostOverride) * 2. `OKRA_HOST` env — the protocol-spec name * 3. `OKRA_BASE_URL` env — the CLI's original name, kept as an alias * 4. Project config: .okrarc or .okra.json * 5. Active global profile * 6. Global config * 7. okra cloud (see the module header for why this is not 127.0.0.1:6572) */ declare function getBaseUrl(): string | undefined; /** * Get source of API key for debugging. */ declare function getApiKeySource(): string; /** * CLI subpath exports for okraPDF. * * The default public CLI experience focuses on auth, upload, extract, chat, * and collection workflows. This module still exports the lower-level * inspection helpers for advanced and internal uses. */ /** * Programmatic CLI entry — `@okrapdf/cli`'s `okra` bin is a thin shim over * this. bin.ts only self-executes under direct execution, so wrappers call * runCli() instead of importing the bin. */ declare function runCli(argv?: string[]): Promise; export { type AuthStatusOptions, type AuthVerificationResult, type EntitiesResponse, type Entity, type EntityBBox, type EntityType, type FindOptions, type HistoryEntry, type HistoryOptions, type HistoryResponse, type MatchSource, type OkraConfig, type OutputFormat, type PageContent, type PageDimension, type PageGetOptions, type PageResolveOptions, type PageVersionInfo, type PageVersionsResponse, type QueryConfig, type QueryOptions, type QueryResult, type QueryStats, type SearchOptions, type SearchResponse, type SearchResult, type SelectorParts, type Table, type TablesOptions, type TablesResponse, type TextBlock, type TreeOptions, type VerificationPageStatus, type VerificationTree, type VerificationTreePage, type VerificationTreeSummary, authLogin, authLogout, authSetKey, authStatus, authToken, authWhoAmI, calculateStats, executeQuery, filterEntities, find, formatFindOutput, formatSearchOutput, formatStats, getApiKey, getApiKeySource, getBaseUrl, getGlobalConfigDir, getGlobalConfigPath, maskApiKey, parseSelector, readGlobalConfig, readProjectConfig, runCli, search, verifyApiKey, writeGlobalConfig };