okrapdf 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/bin.js CHANGED
@@ -10,11 +10,16 @@ import {
10
10
  collectionList,
11
11
  collectionQueryRaw,
12
12
  collectionSetVisibility,
13
+ deleteDocument,
13
14
  find,
14
15
  formatCollectionCsv,
15
16
  formatCollectionExportFlat,
16
17
  formatCollectionList,
17
18
  formatCollectionTable,
19
+ formatDocumentList,
20
+ formatExtractCsv,
21
+ formatExtractJson,
22
+ formatExtractTable,
18
23
  formatFindOutput,
19
24
  formatHistoryOutput,
20
25
  formatPageOutput,
@@ -29,21 +34,23 @@ import {
29
34
  getBaseUrl,
30
35
  handleError,
31
36
  history,
37
+ listDocuments,
32
38
  pageEdit,
33
39
  pageGet,
34
40
  pageResolve,
35
41
  pageVersions,
36
42
  progress,
43
+ readDocument,
37
44
  search,
38
45
  tables,
39
46
  toc,
40
47
  tree,
41
48
  upload,
42
49
  writeOutput
43
- } from "../chunk-XOHPZW3V.js";
50
+ } from "../chunk-F3LECDPP.js";
44
51
  import {
45
52
  OkraClient
46
- } from "../chunk-2HJPTW6S.js";
53
+ } from "../chunk-2VKGPLAA.js";
47
54
  import "../chunk-NIZM2ETT.js";
48
55
 
49
56
  // src/cli/bin.ts
@@ -111,7 +118,80 @@ function registerUploadCommand(commandName, description) {
111
118
  });
112
119
  }
113
120
  registerUploadCommand("upload", "Upload a PDF (file path or URL), wait for processing");
114
- registerUploadCommand("extract", "Alias for upload (compatibility)");
121
+ program.command("extract <source>").description("Extract structured data from a document (doc ID, URL, or file path)").option("--no-wait", "Fire-and-forget (don't wait for processing)").option("--schema <file>", "JSON Schema file or inline JSON for structured extraction").option("--prompt <query>", 'Extraction prompt (default: "Extract all data according to the schema")').action(async (source, options) => {
122
+ const g = globals();
123
+ try {
124
+ const client = getClient();
125
+ const { readFileSync } = await import("fs");
126
+ const isExistingDoc = /^(?:ocr|doc)-[A-Za-z0-9_-]+$/.test(source);
127
+ let docId;
128
+ if (isExistingDoc) {
129
+ docId = source;
130
+ } else {
131
+ const result = await upload(client, source, {
132
+ ...g,
133
+ noWait: options.wait === false
134
+ });
135
+ docId = result.id;
136
+ if (!options.schema || options.wait === false) {
137
+ if (g.json) {
138
+ writeOutput(JSON.stringify(result), g.output);
139
+ } else {
140
+ const lines = [`Done \u2014 ${result.pages ?? "?"} pages`, ""];
141
+ lines.push(` ${docId}`);
142
+ if (result.urls) {
143
+ const short = docId.slice(0, 11) + "...";
144
+ lines.push("");
145
+ lines.push(` Markdown: ${result.urls.full_md.replace(docId, short)}`);
146
+ lines.push(` Page 1: ${result.urls.page_png.replace(docId, short).replace("{N}", "1")}`);
147
+ lines.push(` Completion: ${result.urls.completion.replace(docId, short)}`);
148
+ }
149
+ writeOutput(lines.join("\n"), g.output);
150
+ }
151
+ return;
152
+ }
153
+ }
154
+ if (!options.schema) {
155
+ if (isExistingDoc) {
156
+ writeOutput("Error: --schema is required when extracting from an existing document.", g.output);
157
+ process.exitCode = 1;
158
+ return;
159
+ }
160
+ return;
161
+ }
162
+ let schemaJson;
163
+ const schemaArg = options.schema;
164
+ if (schemaArg.startsWith("{")) {
165
+ schemaJson = JSON.parse(schemaArg);
166
+ } else {
167
+ schemaJson = JSON.parse(readFileSync(schemaArg, "utf8"));
168
+ }
169
+ const prompt = options.prompt || "Extract all data from this document according to the schema.";
170
+ progress(`Extracting from ${docId}\u2026`, g.quiet);
171
+ const extraction = await client.generate(docId, prompt, { schema: schemaJson });
172
+ if (g.json) {
173
+ writeOutput(JSON.stringify({
174
+ doc_id: docId,
175
+ data: extraction.data ?? extraction.answer
176
+ }), g.output);
177
+ } else if (g.output && g.output.endsWith(".csv")) {
178
+ const data = extraction.data ?? {};
179
+ const keys = Object.keys(data);
180
+ const header = ["doc_id", ...keys].join(",");
181
+ const values = keys.map((k) => {
182
+ const v = data[k];
183
+ if (v == null) return "";
184
+ if (typeof v === "string") return `"${String(v).replace(/"/g, '""')}"`;
185
+ return String(v);
186
+ });
187
+ writeOutput([header, [docId, ...values].join(",")].join("\n"), g.output);
188
+ } else {
189
+ writeOutput(JSON.stringify(extraction.data ?? extraction.answer, null, 2), g.output);
190
+ }
191
+ } catch (error) {
192
+ handleError(error, g.json);
193
+ }
194
+ });
115
195
  program.command("status <docId>").description("Get document processing status").action(async (docId) => {
116
196
  const g = globals();
117
197
  try {
@@ -147,6 +227,44 @@ program.command("chat <question>").description("Ask a question about a processed
147
227
  handleError(error, g.json);
148
228
  }
149
229
  });
230
+ program.command("list").alias("ls").description("List all documents").action(async () => {
231
+ const g = globals();
232
+ try {
233
+ const client = getClient();
234
+ const { documents } = await listDocuments(client, g);
235
+ writeOutput(formatDocumentList(documents, g.json), g.output);
236
+ } catch (error) {
237
+ handleError(error, g.json);
238
+ }
239
+ });
240
+ program.command("delete <docId>").alias("rm").description("Delete a document").action(async (docId) => {
241
+ const g = globals();
242
+ try {
243
+ const client = getClient();
244
+ const result = await deleteDocument(client, docId, g);
245
+ if (g.json) {
246
+ writeOutput(JSON.stringify(result), g.output);
247
+ } else {
248
+ writeOutput(`Deleted ${docId}`, g.output);
249
+ }
250
+ } catch (error) {
251
+ handleError(error, g.json);
252
+ }
253
+ });
254
+ program.command("read <docId>").description("Read document as markdown").option("-p, --pages <range>", "Page range (e.g., 1-5, 10-15)").action(async (docId, options) => {
255
+ const g = globals();
256
+ try {
257
+ const client = getClient();
258
+ const result = await readDocument(client, docId, { ...g, pages: options.pages });
259
+ if (g.json) {
260
+ writeOutput(JSON.stringify(result), g.output);
261
+ } else {
262
+ writeOutput(result.markdown, g.output);
263
+ }
264
+ } catch (error) {
265
+ handleError(error, g.json);
266
+ }
267
+ });
150
268
  var collectionCmd = program.command("collection").alias("collections").alias("col").description("Collection operations");
151
269
  collectionCmd.command("list").alias("ls").description("List available collections").action(async () => {
152
270
  const g = globals();
@@ -185,6 +303,43 @@ collectionCmd.command("query <nameOrId> <question>").description("Fan-out query
185
303
  handleError(error, g.json);
186
304
  }
187
305
  });
306
+ collectionCmd.command("extract <nameOrId>").description("Extract structured data from all documents in a collection").requiredOption("--schema <file>", "JSON Schema file or inline JSON for structured extraction").option("--prompt <query>", "Extraction prompt (default: auto-generated from schema)").action(async (nameOrId, options) => {
307
+ const g = globals();
308
+ try {
309
+ const client = getClient();
310
+ const { readFileSync } = await import("fs");
311
+ let schemaJson;
312
+ const schemaArg = options.schema;
313
+ if (schemaArg.startsWith("{")) {
314
+ schemaJson = JSON.parse(schemaArg);
315
+ } else {
316
+ schemaJson = JSON.parse(readFileSync(schemaArg, "utf8"));
317
+ }
318
+ const prompt = options.prompt || "Extract all data from this document according to the schema.";
319
+ const { results, summary } = await collectionQueryRaw(
320
+ client,
321
+ nameOrId,
322
+ prompt,
323
+ { ...g, schema: schemaJson }
324
+ );
325
+ if (g.json) {
326
+ writeOutput(formatExtractJson(results), g.output);
327
+ } else if (g.output && g.output.endsWith(".csv")) {
328
+ writeOutput(formatExtractCsv(results), g.output);
329
+ } else if (g.output) {
330
+ writeOutput(formatExtractJson(results), g.output);
331
+ } else {
332
+ writeOutput(formatExtractTable(results));
333
+ }
334
+ progress(
335
+ `
336
+ ${summary.completed} documents \u2014 $${summary.total_cost_usd.toFixed(4)} total`,
337
+ g.quiet
338
+ );
339
+ } catch (error) {
340
+ handleError(error, g.json);
341
+ }
342
+ });
188
343
  collectionCmd.command("publish <nameOrId>").description("Make a collection publicly queryable").action(async (nameOrId) => {
189
344
  const g = globals();
190
345
  try {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * okra CLI — Agent-friendly PDF extraction and collection queries.\n *\n * Global flags:\n * -j, --json Structured JSON output\n * -q, --quiet Suppress progress (just data to stdout)\n * -o, --output Write output to file (CSV/JSON/ZIP)\n *\n * Action commands (agent-grade):\n * okra upload <source> # Upload + wait\n * okra collection list # List collections\n * okra collection query <name> \"<question>\" # Fan-out → CSV\n *\n * Review commands (existing):\n * okra tree / find / page / search / tables / history / toc\n *\n * Exit codes: 0=success, 1=client error, 2=server error\n */\n\nimport { Command } from 'commander';\nimport { writeFileSync } from 'fs';\nimport { OkraClient } from '../client';\nimport {\n tree,\n formatTreeOutput,\n find,\n formatFindOutput,\n formatStats,\n pageGet,\n pageEdit,\n pageResolve,\n pageVersions,\n formatPageOutput,\n formatVersionsOutput,\n search,\n formatSearchOutput,\n tables,\n formatTablesOutput,\n history,\n formatHistoryOutput,\n toc,\n formatTocOutput,\n authLogin,\n authSetKey,\n authStatus,\n authWhoAmI,\n authToken,\n authLogout,\n upload,\n collectionList,\n collectionSetVisibility,\n collectionQueryRaw,\n collectionExport,\n formatCollectionList,\n formatCollectionCsv,\n formatCollectionTable,\n formatQueryJsonl,\n formatCollectionExportFlat,\n} from './commands';\nimport { getApiKey, getBaseUrl } from './config';\nimport { handleError, writeOutput, progress } from './output';\nimport type { GlobalFlags } from './output';\n\nconst program = new Command();\nprogram.showHelpAfterError();\nprogram.showSuggestionAfterError();\n\nprogram\n .name('okra')\n .description('OkraPDF CLI — upload PDFs, query collections, extract data')\n .version('0.12.1')\n .option('-j, --json', 'Output JSON (structured, machine-readable)')\n .option('-q, --quiet', 'Suppress progress and human-readable frills')\n .option('-o, --output <file>', 'Write output to file instead of stdout');\n\n/** Read global flags from program.opts(). */\nfunction globals(): GlobalFlags {\n return program.opts();\n}\n\n// Create client with proper config priority:\n// 1. Environment variable (OKRA_API_KEY)\n// 2. Project config (.okrarc, .okra.json)\n// 3. Global config (~/.okra/config.json)\nfunction getClient(): OkraClient {\n const apiKey = getApiKey();\n const baseUrl = getBaseUrl();\n\n if (!apiKey) {\n const g = globals();\n if (g.json) {\n process.stderr.write(JSON.stringify({ error: 'No API key found', code: 401 }) + '\\n');\n } else {\n process.stderr.write(\n 'No API key found.\\n\\n' +\n ' Get one: https://docs.okrapdf.com/api-keys\\n' +\n ' Then: export OKRA_API_KEY=\"okra_xxx\"\\n' +\n ' Or: npx okra auth login\\n\\n' +\n ' Docs: https://docs.okrapdf.com\\n' +\n ' Discord: https://discord.gg/BHNmbZVs\\n',\n );\n }\n process.exit(1);\n }\n\n return new OkraClient({ apiKey, baseUrl });\n}\n\n// ============================================================================\n// upload command\n// ============================================================================\nasync function runUploadCommand(source: string, options: { wait?: boolean }): Promise<void> {\n const g = globals();\n try {\n const client = getClient();\n const result = await upload(client, source, {\n ...g,\n noWait: options.wait === false,\n });\n\n if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n const lines = [`Done — ${result.pages ?? '?'} pages`, ''];\n lines.push(` ${result.id}`);\n if (result.urls) {\n const short = result.id.slice(0, 11) + '...';\n lines.push('');\n lines.push(` Markdown: ${result.urls.full_md.replace(result.id, short)}`);\n lines.push(` Page 1: ${result.urls.page_png.replace(result.id, short).replace('{N}', '1')}`);\n lines.push(` Completion: ${result.urls.completion.replace(result.id, short)}`);\n lines.push('');\n lines.push(' URL patterns:');\n lines.push(' /v1/documents/{id}/pg_{N}.md page markdown');\n lines.push(' /v1/documents/{id}/d_shimmer/pg_{N}.png page image');\n lines.push(' /v1/documents/{id}/full.md full document');\n lines.push('');\n lines.push(' Docs: https://docs.okrapdf.com Discord: https://discord.gg/BHNmbZVs');\n }\n writeOutput(lines.join('\\n'), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n}\n\nfunction registerUploadCommand(commandName: string, description: string): void {\n program\n .command(`${commandName} <source>`)\n .description(description)\n .option('--no-wait', 'Fire-and-forget (don\\'t wait for processing)')\n .action(async (source, options) => {\n await runUploadCommand(source, options);\n });\n}\n\nregisterUploadCommand('upload', 'Upload a PDF (file path or URL), wait for processing');\nregisterUploadCommand('extract', 'Alias for upload (compatibility)');\n\n// ============================================================================\n// status command\n// ============================================================================\nprogram\n .command('status <docId>')\n .description('Get document processing status')\n .action(async (docId) => {\n const g = globals();\n try {\n const client = getClient();\n const status = await client.status(docId);\n if (g.json) {\n writeOutput(JSON.stringify(status), g.output);\n } else {\n const lines = [\n `Document: ${docId}`,\n `Phase: ${status.phase}`,\n ];\n if (typeof status.pagesCompleted === 'number' || typeof status.pagesTotal === 'number') {\n lines.push(`Pages: ${status.pagesCompleted ?? '?'} / ${status.pagesTotal ?? '?'}`);\n }\n writeOutput(lines.join('\\n'), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// chat command\n// ============================================================================\nprogram\n .command('chat <question>')\n .description('Ask a question about a processed document')\n .requiredOption('--doc <id>', 'Document ID')\n .option('--model <name>', 'Override model')\n .action(async (question, options) => {\n const g = globals();\n try {\n const client = getClient();\n const result = await client.generate(options.doc, question, options.model ? { model: options.model } : undefined);\n\n if (g.json) {\n writeOutput(JSON.stringify({ docId: options.doc, question, ...result }), g.output);\n } else {\n writeOutput(result.answer, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// collection command\n// ============================================================================\nconst collectionCmd = program\n .command('collection')\n .alias('collections')\n .alias('col')\n .description('Collection operations');\n\ncollectionCmd\n .command('list')\n .alias('ls')\n .description('List available collections')\n .action(async () => {\n const g = globals();\n try {\n const client = getClient();\n const rows = await collectionList(client, g);\n writeOutput(formatCollectionList(rows, g.json), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('query <nameOrId> <question>')\n .description('Fan-out query across collection documents')\n .option('--schema <file>', 'JSON Schema file for structured extraction')\n .action(async (nameOrId, question, options) => {\n const g = globals();\n try {\n const client = getClient();\n const { results, summary } = await collectionQueryRaw(\n client,\n nameOrId,\n question,\n { ...g, schema: options.schema },\n );\n\n // Determine output format based on flags\n if (g.json) {\n // --json: JSONL events to stdout\n writeOutput(formatQueryJsonl(results), g.output);\n } else if (g.output && g.output.endsWith('.csv')) {\n // -o file.csv → CSV\n writeOutput(formatCollectionCsv(results), g.output);\n } else if (g.output) {\n // -o file.json or other → JSON\n writeOutput(JSON.stringify({ results, summary }), g.output);\n } else {\n // Default: compact table to stdout\n writeOutput(formatCollectionTable(results));\n }\n\n progress(\n `${summary.completed} completed, ${summary.failed} failed — $${summary.total_cost_usd.toFixed(4)}`,\n g.quiet,\n );\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('publish <nameOrId>')\n .description('Make a collection publicly queryable')\n .action(async (nameOrId) => {\n const g = globals();\n try {\n const client = getClient();\n await collectionSetVisibility(client, nameOrId, 'public');\n if (g.json) {\n writeOutput(JSON.stringify({ ok: true, visibility: 'public', collection: nameOrId }), g.output);\n } else {\n writeOutput(\n `Published \"${nameOrId}\"\\n` +\n `Share with: okra collection query ${nameOrId} \"your question\"`,\n g.output,\n );\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('unpublish <nameOrId>')\n .description('Make a collection private (owner-only)')\n .action(async (nameOrId) => {\n const g = globals();\n try {\n const client = getClient();\n await collectionSetVisibility(client, nameOrId, 'private');\n if (g.json) {\n writeOutput(JSON.stringify({ ok: true, visibility: 'private', collection: nameOrId }), g.output);\n } else {\n writeOutput(`Unpublished \"${nameOrId}\" — now private`, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('export <nameOrId>')\n .description('Export pre-computed markdown for all documents in a collection')\n .option('--flat', 'Concatenated markdown with # headers + === separators')\n .option('--zip', 'One markdown file per document in a .zip archive')\n .action(async (nameOrId, options) => {\n const g = globals();\n try {\n const client = getClient();\n\n if (options.flat && options.zip) {\n throw new Error('Use either --flat or --zip, not both');\n }\n\n if (options.zip) {\n const bytes = await collectionExport(client, nameOrId, { ...g, zip: true });\n const safeBase = String(nameOrId)\n .trim()\n .replace(/[^A-Za-z0-9._-]+/g, '-')\n .replace(/-{2,}/g, '-')\n .replace(/^[-_.]+|[-_.]+$/g, '') || 'collection-export';\n const outputPath = g.output || `${safeBase}.zip`;\n writeFileSync(outputPath, bytes);\n progress(`Wrote → ${outputPath}`, g.quiet);\n\n if (g.json) {\n writeOutput(JSON.stringify({\n format: 'zip',\n file: outputPath,\n bytes: bytes.byteLength,\n }));\n }\n return;\n }\n\n const result = await collectionExport(client, nameOrId, { ...g, flat: options.flat });\n\n if (options.flat) {\n writeOutput(formatCollectionExportFlat(result), g.output);\n } else if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n // Default: structured JSON\n writeOutput(JSON.stringify(result, null, 2), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// auth command - Authentication management\n// ============================================================================\nconst authCmd = program.command('auth').description('Manage authentication');\n\nauthCmd\n .command('login')\n .description('Save API key to global config')\n .option('-k, --key <apiKey>', 'Set API key non-interactively')\n .action(async (options) => {\n try {\n await authLogin(options.key);\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('set-key <apiKey>')\n .description('Save API key to global config (non-interactive)')\n .action(async (apiKey) => {\n try {\n await authSetKey(apiKey);\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('status')\n .description('Show authentication status')\n .action(async () => {\n try {\n await authStatus();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('whoami')\n .description('Show current auth identity (alias for status)')\n .action(async () => {\n try {\n await authWhoAmI();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('token')\n .description('Print active API key to stdout')\n .action(async () => {\n try {\n await authToken();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('logout')\n .description('Remove API key from global config')\n .action(async () => {\n try {\n await authLogout();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\n// ============================================================================\n// tree command - Document verification tree\n// ============================================================================\nprogram\n .command('tree <jobId>')\n .description('Show document verification tree')\n .option('-s, --status <status>', 'Filter by status (complete|partial|pending|flagged|empty|gap)')\n .option('-e, --entity <type>', 'Filter by entity type (table|figure|footnote)')\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'text')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await tree(client, jobId, {\n status: options.status,\n entity: options.entity,\n });\n writeOutput(formatTreeOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// find command - jQuery-like entity search\n// ============================================================================\nprogram\n .command('find <jobId> <selector>')\n .description('Find entities using jQuery-like selectors')\n .option('-k, --top-k <n>', 'Limit results', parseInt)\n .option('-c, --min-confidence <n>', 'Minimum confidence (0-1)', parseFloat)\n .option('-p, --pages <range>', 'Page range (e.g., 1-10)')\n .option('--sort <by>', 'Sort by (confidence|page|type)')\n .option('--stats', 'Show aggregate statistics')\n .option('-f, --format <format>', 'Output format (text|json|entities|ids)', 'text')\n .action(async (jobId, selector, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const pageRange = options.pages\n ? options.pages.split('-').map(Number) as [number, number]\n : undefined;\n\n const result = await find(client, jobId, selector, {\n topK: options.topK,\n minConfidence: options.minConfidence,\n pageRange,\n sortBy: options.sort,\n });\n\n if (options.stats && fmt === 'text') {\n writeOutput(formatStats(result.stats), g.output);\n } else {\n writeOutput(formatFindOutput(result, fmt, options.stats), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// page command - Page content operations\n// ============================================================================\nconst pageCmd = program.command('page').description('Page content operations');\n\npageCmd\n .command('get <jobId> <pageNum>')\n .description('Get page content')\n .option('-v, --version <n>', 'Specific version', parseInt)\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'markdown')\n .action(async (jobId, pageNum, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const content = await pageGet(client, jobId, parseInt(pageNum), {\n version: options.version,\n });\n writeOutput(formatPageOutput(content, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\npageCmd\n .command('edit <jobId> <pageNum>')\n .description('Edit page content (reads from stdin)')\n .action(async (jobId, pageNum) => {\n const g = globals();\n try {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n const content = Buffer.concat(chunks).toString('utf8');\n\n const client = getClient();\n const result = await pageEdit(client, jobId, parseInt(pageNum), content);\n if (g.json) {\n writeOutput(JSON.stringify({ version: result.version }), g.output);\n } else {\n writeOutput(`Saved as version ${result.version}`, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\npageCmd\n .command('resolve <jobId> <pageNum> <resolution>')\n .description('Resolve page verification status')\n .option('-c, --classification <class>', 'Classification')\n .option('-r, --reason <reason>', 'Reason')\n .action(async (jobId, pageNum, resolution, options) => {\n const g = globals();\n try {\n const client = getClient();\n const result = await pageResolve(client, jobId, parseInt(pageNum), {\n resolution,\n classification: options.classification,\n reason: options.reason,\n });\n if (g.json) {\n writeOutput(JSON.stringify({ success: result.success }), g.output);\n } else {\n writeOutput(result.success ? 'Resolved' : 'Failed', g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\npageCmd\n .command('versions <jobId> <pageNum>')\n .description('List page versions')\n .option('-f, --format <format>', 'Output format (text|json)', 'text')\n .action(async (jobId, pageNum, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const versions = await pageVersions(client, jobId, parseInt(pageNum));\n writeOutput(formatVersionsOutput(versions, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// search command - Full-text search\n// ============================================================================\nprogram\n .command('search <jobId> <query>')\n .description('Search page content')\n .option('-f, --format <format>', 'Output format (text|json)', 'text')\n .action(async (jobId, query, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await search(client, jobId, query);\n writeOutput(formatSearchOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// tables command - List tables\n// ============================================================================\nprogram\n .command('tables <jobId>')\n .description('List extracted tables')\n .option('-p, --page <n>', 'Filter by page', parseInt)\n .option('-s, --status <status>', 'Filter by status (pending|verified|flagged|rejected)')\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'text')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await tables(client, jobId, {\n page: options.page,\n status: options.status,\n });\n writeOutput(formatTablesOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// history command - Verification audit trail\n// ============================================================================\nprogram\n .command('history <jobId>')\n .description('Show verification history')\n .option('-l, --limit <n>', 'Limit entries', parseInt, 50)\n .option('-f, --format <format>', 'Output format (text|json)', 'text')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await history(client, jobId, { limit: options.limit });\n writeOutput(formatHistoryOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// toc command - Table of contents extraction\n// ============================================================================\nprogram\n .command('toc <jobId>')\n .description('Extract table of contents from PDF')\n .option('--max-depth <n>', 'Maximum TOC depth', parseInt)\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'text')\n .option('--watch', 'Watch live extraction events via WebSocket')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await toc(client, jobId, {\n maxDepth: options.maxDepth,\n watch: options.watch,\n });\n writeOutput(formatTocOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AA2C9B,IAAM,UAAU,IAAI,QAAQ;AAC5B,QAAQ,mBAAmB;AAC3B,QAAQ,yBAAyB;AAEjC,QACG,KAAK,MAAM,EACX,YAAY,iEAA4D,EACxE,QAAQ,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AAO,YAAY;AAChC,QAAM,IAAI,QAAQ;AAClB,MAAI;AACF,UAAM,SAAS,UAAU;AACzB,UAAM,MAAM,EAAE,OAAO,SAAS,QAAQ;AACtC,UAAM,SAAS,MAAM,QAAQ,QAAQ,OAAO,EAAE,OAAO,QAAQ,MAAM,CAAC;AACpE,gBAAY,oBAAoB,QAAQ,GAAG,GAAG,EAAE,MAAM;AAAA,EACxD,SAAS,OAAO;AACd,gBAAY,OAAO,EAAE,IAAI;AAAA,EAC3B;AACF,CAAC;AAKH,QACG,QAAQ,aAAa,EACrB,YAAY,oCAAoC,EAChD,OAAO,mBAAmB,qBAAqB,QAAQ,EACvD,OAAO,yBAAyB,sCAAsC,MAAM,EAC5E,OAAO,WAAW,4CAA4C,EAC9D,OAAO,OAAO,OAAO,YAAY;AAChC,QAAM,IAAI,QAAQ;AAClB,MAAI;AACF,UAAM,SAAS,UAAU;AACzB,UAAM,MAAM,EAAE,OAAO,SAAS,QAAQ;AACtC,UAAM,SAAS,MAAM,IAAI,QAAQ,OAAO;AAAA,MACtC,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,IACjB,CAAC;AACD,gBAAY,gBAAgB,QAAQ,GAAG,GAAG,EAAE,MAAM;AAAA,EACpD,SAAS,OAAO;AACd,gBAAY,OAAO,EAAE,IAAI;AAAA,EAC3B;AACF,CAAC;AAEH,QAAQ,MAAM;","names":[]}
1
+ {"version":3,"sources":["../../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * okra CLI — Agent-friendly PDF extraction and collection queries.\n *\n * Global flags:\n * -j, --json Structured JSON output\n * -q, --quiet Suppress progress (just data to stdout)\n * -o, --output Write output to file (CSV/JSON/ZIP)\n *\n * Action commands (agent-grade):\n * okra upload <source> # Upload + wait\n * okra extract <source> --schema schema.json # Upload + structured extract\n * okra extract <docId> --schema schema.json # Extract from existing doc\n * okra list # List documents\n * okra read <id> [--pages 1-5] # Full markdown\n * okra delete <id> # Delete document\n * okra chat \"<question>\" --doc <id> # Ask a question\n * okra collection list # List collections\n * okra collection query <name> \"<question>\" # Fan-out → CSV\n * okra collection extract <name> --schema s.json # Structured extract → CSV\n *\n * Review commands:\n * okra tree / find / page / search / tables / history / toc\n *\n * Exit codes: 0=success, 1=client error, 2=server error\n */\n\nimport { Command } from 'commander';\nimport { writeFileSync } from 'fs';\nimport { OkraClient } from '../client';\nimport {\n tree,\n formatTreeOutput,\n find,\n formatFindOutput,\n formatStats,\n pageGet,\n pageEdit,\n pageResolve,\n pageVersions,\n formatPageOutput,\n formatVersionsOutput,\n search,\n formatSearchOutput,\n tables,\n formatTablesOutput,\n history,\n formatHistoryOutput,\n toc,\n formatTocOutput,\n authLogin,\n authSetKey,\n authStatus,\n authWhoAmI,\n authToken,\n authLogout,\n upload,\n listDocuments,\n formatDocumentList,\n deleteDocument,\n readDocument,\n collectionList,\n collectionSetVisibility,\n collectionQueryRaw,\n collectionExport,\n formatCollectionList,\n formatCollectionCsv,\n formatCollectionTable,\n formatQueryJsonl,\n formatCollectionExportFlat,\n formatExtractCsv,\n formatExtractTable,\n formatExtractJson,\n} from './commands';\nimport { getApiKey, getBaseUrl } from './config';\nimport { handleError, writeOutput, progress } from './output';\nimport type { GlobalFlags } from './output';\n\nconst program = new Command();\nprogram.showHelpAfterError();\nprogram.showSuggestionAfterError();\n\nprogram\n .name('okra')\n .description('OkraPDF CLI — upload PDFs, query collections, extract data')\n .version('0.12.1')\n .option('-j, --json', 'Output JSON (structured, machine-readable)')\n .option('-q, --quiet', 'Suppress progress and human-readable frills')\n .option('-o, --output <file>', 'Write output to file instead of stdout');\n\n/** Read global flags from program.opts(). */\nfunction globals(): GlobalFlags {\n return program.opts();\n}\n\n// Create client with proper config priority:\n// 1. Environment variable (OKRA_API_KEY)\n// 2. Project config (.okrarc, .okra.json)\n// 3. Global config (~/.okra/config.json)\nfunction getClient(): OkraClient {\n const apiKey = getApiKey();\n const baseUrl = getBaseUrl();\n\n if (!apiKey) {\n const g = globals();\n if (g.json) {\n process.stderr.write(JSON.stringify({ error: 'No API key found', code: 401 }) + '\\n');\n } else {\n process.stderr.write(\n 'No API key found.\\n\\n' +\n ' Get one: https://docs.okrapdf.com/api-keys\\n' +\n ' Then: export OKRA_API_KEY=\"okra_xxx\"\\n' +\n ' Or: npx okra auth login\\n\\n' +\n ' Docs: https://docs.okrapdf.com\\n' +\n ' Discord: https://discord.gg/BHNmbZVs\\n',\n );\n }\n process.exit(1);\n }\n\n return new OkraClient({ apiKey, baseUrl });\n}\n\n// ============================================================================\n// upload command\n// ============================================================================\nasync function runUploadCommand(source: string, options: { wait?: boolean }): Promise<void> {\n const g = globals();\n try {\n const client = getClient();\n const result = await upload(client, source, {\n ...g,\n noWait: options.wait === false,\n });\n\n if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n const lines = [`Done — ${result.pages ?? '?'} pages`, ''];\n lines.push(` ${result.id}`);\n if (result.urls) {\n const short = result.id.slice(0, 11) + '...';\n lines.push('');\n lines.push(` Markdown: ${result.urls.full_md.replace(result.id, short)}`);\n lines.push(` Page 1: ${result.urls.page_png.replace(result.id, short).replace('{N}', '1')}`);\n lines.push(` Completion: ${result.urls.completion.replace(result.id, short)}`);\n lines.push('');\n lines.push(' URL patterns:');\n lines.push(' /v1/documents/{id}/pg_{N}.md page markdown');\n lines.push(' /v1/documents/{id}/d_shimmer/pg_{N}.png page image');\n lines.push(' /v1/documents/{id}/full.md full document');\n lines.push('');\n lines.push(' Docs: https://docs.okrapdf.com Discord: https://discord.gg/BHNmbZVs');\n }\n writeOutput(lines.join('\\n'), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n}\n\nfunction registerUploadCommand(commandName: string, description: string): void {\n program\n .command(`${commandName} <source>`)\n .description(description)\n .option('--no-wait', 'Fire-and-forget (don\\'t wait for processing)')\n .action(async (source, options) => {\n await runUploadCommand(source, options);\n });\n}\n\nregisterUploadCommand('upload', 'Upload a PDF (file path or URL), wait for processing');\n\n// ============================================================================\n// extract command — structured extraction from existing doc or upload + extract\n// ============================================================================\nprogram\n .command('extract <source>')\n .description('Extract structured data from a document (doc ID, URL, or file path)')\n .option('--no-wait', \"Fire-and-forget (don't wait for processing)\")\n .option('--schema <file>', 'JSON Schema file or inline JSON for structured extraction')\n .option('--prompt <query>', 'Extraction prompt (default: \"Extract all data according to the schema\")')\n .action(async (source, options) => {\n const g = globals();\n try {\n const client = getClient();\n const { readFileSync } = await import('fs');\n\n // Resolve doc ID: if source looks like an existing doc, skip upload\n const isExistingDoc = /^(?:ocr|doc)-[A-Za-z0-9_-]+$/.test(source);\n let docId: string;\n\n if (isExistingDoc) {\n docId = source;\n } else {\n // Upload first\n const result = await upload(client, source, {\n ...g,\n noWait: options.wait === false,\n });\n docId = result.id;\n\n // If no schema and no-wait, just show upload result\n if (!options.schema || options.wait === false) {\n if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n const lines = [`Done — ${result.pages ?? '?'} pages`, ''];\n lines.push(` ${docId}`);\n if (result.urls) {\n const short = docId.slice(0, 11) + '...';\n lines.push('');\n lines.push(` Markdown: ${result.urls.full_md.replace(docId, short)}`);\n lines.push(` Page 1: ${result.urls.page_png.replace(docId, short).replace('{N}', '1')}`);\n lines.push(` Completion: ${result.urls.completion.replace(docId, short)}`);\n }\n writeOutput(lines.join('\\n'), g.output);\n }\n return;\n }\n }\n\n // Schema is required for existing docs, optional for uploads\n if (!options.schema) {\n if (isExistingDoc) {\n writeOutput('Error: --schema is required when extracting from an existing document.', g.output);\n process.exitCode = 1;\n return;\n }\n return;\n }\n\n // Load schema — support file path or inline JSON\n let schemaJson: Record<string, unknown>;\n const schemaArg: string = options.schema;\n if (schemaArg.startsWith('{')) {\n schemaJson = JSON.parse(schemaArg);\n } else {\n schemaJson = JSON.parse(readFileSync(schemaArg, 'utf8'));\n }\n\n const prompt = options.prompt || 'Extract all data from this document according to the schema.';\n\n progress(`Extracting from ${docId}…`, g.quiet);\n const extraction = await client.generate(docId, prompt, { schema: schemaJson });\n\n if (g.json) {\n writeOutput(JSON.stringify({\n doc_id: docId,\n data: extraction.data ?? extraction.answer,\n }), g.output);\n } else if (g.output && g.output.endsWith('.csv')) {\n // CSV output for single doc — one header row + one data row\n const data = (extraction.data ?? {}) as Record<string, unknown>;\n const keys = Object.keys(data);\n const header = ['doc_id', ...keys].join(',');\n const values = keys.map((k) => {\n const v = data[k];\n if (v == null) return '';\n if (typeof v === 'string') return `\"${String(v).replace(/\"/g, '\"\"')}\"`;\n return String(v);\n });\n writeOutput([header, [docId, ...values].join(',')].join('\\n'), g.output);\n } else {\n writeOutput(JSON.stringify(extraction.data ?? extraction.answer, null, 2), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// status command\n// ============================================================================\nprogram\n .command('status <docId>')\n .description('Get document processing status')\n .action(async (docId) => {\n const g = globals();\n try {\n const client = getClient();\n const status = await client.status(docId);\n if (g.json) {\n writeOutput(JSON.stringify(status), g.output);\n } else {\n const lines = [\n `Document: ${docId}`,\n `Phase: ${status.phase}`,\n ];\n if (typeof status.pagesCompleted === 'number' || typeof status.pagesTotal === 'number') {\n lines.push(`Pages: ${status.pagesCompleted ?? '?'} / ${status.pagesTotal ?? '?'}`);\n }\n writeOutput(lines.join('\\n'), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// chat command\n// ============================================================================\nprogram\n .command('chat <question>')\n .description('Ask a question about a processed document')\n .requiredOption('--doc <id>', 'Document ID')\n .option('--model <name>', 'Override model')\n .action(async (question, options) => {\n const g = globals();\n try {\n const client = getClient();\n const result = await client.generate(options.doc, question, options.model ? { model: options.model } : undefined);\n\n if (g.json) {\n writeOutput(JSON.stringify({ docId: options.doc, question, ...result }), g.output);\n } else {\n writeOutput(result.answer, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// list command\n// ============================================================================\nprogram\n .command('list')\n .alias('ls')\n .description('List all documents')\n .action(async () => {\n const g = globals();\n try {\n const client = getClient();\n const { documents } = await listDocuments(client, g);\n writeOutput(formatDocumentList(documents, g.json), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// delete command\n// ============================================================================\nprogram\n .command('delete <docId>')\n .alias('rm')\n .description('Delete a document')\n .action(async (docId) => {\n const g = globals();\n try {\n const client = getClient();\n const result = await deleteDocument(client, docId, g);\n if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n writeOutput(`Deleted ${docId}`, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// read command\n// ============================================================================\nprogram\n .command('read <docId>')\n .description('Read document as markdown')\n .option('-p, --pages <range>', 'Page range (e.g., 1-5, 10-15)')\n .action(async (docId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const result = await readDocument(client, docId, { ...g, pages: options.pages });\n if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n writeOutput(result.markdown, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// collection command\n// ============================================================================\nconst collectionCmd = program\n .command('collection')\n .alias('collections')\n .alias('col')\n .description('Collection operations');\n\ncollectionCmd\n .command('list')\n .alias('ls')\n .description('List available collections')\n .action(async () => {\n const g = globals();\n try {\n const client = getClient();\n const rows = await collectionList(client, g);\n writeOutput(formatCollectionList(rows, g.json), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('query <nameOrId> <question>')\n .description('Fan-out query across collection documents')\n .option('--schema <file>', 'JSON Schema file for structured extraction')\n .action(async (nameOrId, question, options) => {\n const g = globals();\n try {\n const client = getClient();\n const { results, summary } = await collectionQueryRaw(\n client,\n nameOrId,\n question,\n { ...g, schema: options.schema },\n );\n\n // Determine output format based on flags\n if (g.json) {\n // --json: JSONL events to stdout\n writeOutput(formatQueryJsonl(results), g.output);\n } else if (g.output && g.output.endsWith('.csv')) {\n // -o file.csv → CSV\n writeOutput(formatCollectionCsv(results), g.output);\n } else if (g.output) {\n // -o file.json or other → JSON\n writeOutput(JSON.stringify({ results, summary }), g.output);\n } else {\n // Default: compact table to stdout\n writeOutput(formatCollectionTable(results));\n }\n\n progress(\n `${summary.completed} completed, ${summary.failed} failed — $${summary.total_cost_usd.toFixed(4)}`,\n g.quiet,\n );\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('extract <nameOrId>')\n .description('Extract structured data from all documents in a collection')\n .requiredOption('--schema <file>', 'JSON Schema file or inline JSON for structured extraction')\n .option('--prompt <query>', 'Extraction prompt (default: auto-generated from schema)')\n .action(async (nameOrId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const { readFileSync } = await import('fs');\n\n // Load schema — support file path or inline JSON\n let schemaJson: Record<string, unknown>;\n const schemaArg: string = options.schema;\n if (schemaArg.startsWith('{')) {\n schemaJson = JSON.parse(schemaArg);\n } else {\n schemaJson = JSON.parse(readFileSync(schemaArg, 'utf8'));\n }\n\n const prompt = options.prompt || 'Extract all data from this document according to the schema.';\n\n const { results, summary } = await collectionQueryRaw(\n client,\n nameOrId,\n prompt,\n { ...g, schema: schemaJson },\n );\n\n // Use structured formatters that flatten data keys into columns\n if (g.json) {\n writeOutput(formatExtractJson(results), g.output);\n } else if (g.output && g.output.endsWith('.csv')) {\n writeOutput(formatExtractCsv(results), g.output);\n } else if (g.output) {\n // Non-csv file output → JSON\n writeOutput(formatExtractJson(results), g.output);\n } else {\n // Default: table to stdout with flattened data columns\n writeOutput(formatExtractTable(results));\n }\n\n progress(\n `\\n${summary.completed} documents — $${summary.total_cost_usd.toFixed(4)} total`,\n g.quiet,\n );\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('publish <nameOrId>')\n .description('Make a collection publicly queryable')\n .action(async (nameOrId) => {\n const g = globals();\n try {\n const client = getClient();\n await collectionSetVisibility(client, nameOrId, 'public');\n if (g.json) {\n writeOutput(JSON.stringify({ ok: true, visibility: 'public', collection: nameOrId }), g.output);\n } else {\n writeOutput(\n `Published \"${nameOrId}\"\\n` +\n `Share with: okra collection query ${nameOrId} \"your question\"`,\n g.output,\n );\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('unpublish <nameOrId>')\n .description('Make a collection private (owner-only)')\n .action(async (nameOrId) => {\n const g = globals();\n try {\n const client = getClient();\n await collectionSetVisibility(client, nameOrId, 'private');\n if (g.json) {\n writeOutput(JSON.stringify({ ok: true, visibility: 'private', collection: nameOrId }), g.output);\n } else {\n writeOutput(`Unpublished \"${nameOrId}\" — now private`, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\ncollectionCmd\n .command('export <nameOrId>')\n .description('Export pre-computed markdown for all documents in a collection')\n .option('--flat', 'Concatenated markdown with # headers + === separators')\n .option('--zip', 'One markdown file per document in a .zip archive')\n .action(async (nameOrId, options) => {\n const g = globals();\n try {\n const client = getClient();\n\n if (options.flat && options.zip) {\n throw new Error('Use either --flat or --zip, not both');\n }\n\n if (options.zip) {\n const bytes = await collectionExport(client, nameOrId, { ...g, zip: true });\n const safeBase = String(nameOrId)\n .trim()\n .replace(/[^A-Za-z0-9._-]+/g, '-')\n .replace(/-{2,}/g, '-')\n .replace(/^[-_.]+|[-_.]+$/g, '') || 'collection-export';\n const outputPath = g.output || `${safeBase}.zip`;\n writeFileSync(outputPath, bytes);\n progress(`Wrote → ${outputPath}`, g.quiet);\n\n if (g.json) {\n writeOutput(JSON.stringify({\n format: 'zip',\n file: outputPath,\n bytes: bytes.byteLength,\n }));\n }\n return;\n }\n\n const result = await collectionExport(client, nameOrId, { ...g, flat: options.flat });\n\n if (options.flat) {\n writeOutput(formatCollectionExportFlat(result), g.output);\n } else if (g.json) {\n writeOutput(JSON.stringify(result), g.output);\n } else {\n // Default: structured JSON\n writeOutput(JSON.stringify(result, null, 2), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// auth command - Authentication management\n// ============================================================================\nconst authCmd = program.command('auth').description('Manage authentication');\n\nauthCmd\n .command('login')\n .description('Save API key to global config')\n .option('-k, --key <apiKey>', 'Set API key non-interactively')\n .action(async (options) => {\n try {\n await authLogin(options.key);\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('set-key <apiKey>')\n .description('Save API key to global config (non-interactive)')\n .action(async (apiKey) => {\n try {\n await authSetKey(apiKey);\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('status')\n .description('Show authentication status')\n .action(async () => {\n try {\n await authStatus();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('whoami')\n .description('Show current auth identity (alias for status)')\n .action(async () => {\n try {\n await authWhoAmI();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('token')\n .description('Print active API key to stdout')\n .action(async () => {\n try {\n await authToken();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\nauthCmd\n .command('logout')\n .description('Remove API key from global config')\n .action(async () => {\n try {\n await authLogout();\n } catch (error) {\n handleError(error, globals().json);\n }\n });\n\n// ============================================================================\n// tree command - Document verification tree\n// ============================================================================\nprogram\n .command('tree <jobId>')\n .description('Show document verification tree')\n .option('-s, --status <status>', 'Filter by status (complete|partial|pending|flagged|empty|gap)')\n .option('-e, --entity <type>', 'Filter by entity type (table|figure|footnote)')\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'text')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await tree(client, jobId, {\n status: options.status,\n entity: options.entity,\n });\n writeOutput(formatTreeOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// find command - jQuery-like entity search\n// ============================================================================\nprogram\n .command('find <jobId> <selector>')\n .description('Find entities using jQuery-like selectors')\n .option('-k, --top-k <n>', 'Limit results', parseInt)\n .option('-c, --min-confidence <n>', 'Minimum confidence (0-1)', parseFloat)\n .option('-p, --pages <range>', 'Page range (e.g., 1-10)')\n .option('--sort <by>', 'Sort by (confidence|page|type)')\n .option('--stats', 'Show aggregate statistics')\n .option('-f, --format <format>', 'Output format (text|json|entities|ids)', 'text')\n .action(async (jobId, selector, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const pageRange = options.pages\n ? options.pages.split('-').map(Number) as [number, number]\n : undefined;\n\n const result = await find(client, jobId, selector, {\n topK: options.topK,\n minConfidence: options.minConfidence,\n pageRange,\n sortBy: options.sort,\n });\n\n if (options.stats && fmt === 'text') {\n writeOutput(formatStats(result.stats), g.output);\n } else {\n writeOutput(formatFindOutput(result, fmt, options.stats), g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// page command - Page content operations\n// ============================================================================\nconst pageCmd = program.command('page').description('Page content operations');\n\npageCmd\n .command('get <jobId> <pageNum>')\n .description('Get page content')\n .option('-v, --version <n>', 'Specific version', parseInt)\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'markdown')\n .action(async (jobId, pageNum, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const content = await pageGet(client, jobId, parseInt(pageNum), {\n version: options.version,\n });\n writeOutput(formatPageOutput(content, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\npageCmd\n .command('edit <jobId> <pageNum>')\n .description('Edit page content (reads from stdin)')\n .action(async (jobId, pageNum) => {\n const g = globals();\n try {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n const content = Buffer.concat(chunks).toString('utf8');\n\n const client = getClient();\n const result = await pageEdit(client, jobId, parseInt(pageNum), content);\n if (g.json) {\n writeOutput(JSON.stringify({ version: result.version }), g.output);\n } else {\n writeOutput(`Saved as version ${result.version}`, g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\npageCmd\n .command('resolve <jobId> <pageNum> <resolution>')\n .description('Resolve page verification status')\n .option('-c, --classification <class>', 'Classification')\n .option('-r, --reason <reason>', 'Reason')\n .action(async (jobId, pageNum, resolution, options) => {\n const g = globals();\n try {\n const client = getClient();\n const result = await pageResolve(client, jobId, parseInt(pageNum), {\n resolution,\n classification: options.classification,\n reason: options.reason,\n });\n if (g.json) {\n writeOutput(JSON.stringify({ success: result.success }), g.output);\n } else {\n writeOutput(result.success ? 'Resolved' : 'Failed', g.output);\n }\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\npageCmd\n .command('versions <jobId> <pageNum>')\n .description('List page versions')\n .option('-f, --format <format>', 'Output format (text|json)', 'text')\n .action(async (jobId, pageNum, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const versions = await pageVersions(client, jobId, parseInt(pageNum));\n writeOutput(formatVersionsOutput(versions, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// search command - Full-text search\n// ============================================================================\nprogram\n .command('search <jobId> <query>')\n .description('Search page content')\n .option('-f, --format <format>', 'Output format (text|json)', 'text')\n .action(async (jobId, query, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await search(client, jobId, query);\n writeOutput(formatSearchOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// tables command - List tables\n// ============================================================================\nprogram\n .command('tables <jobId>')\n .description('List extracted tables')\n .option('-p, --page <n>', 'Filter by page', parseInt)\n .option('-s, --status <status>', 'Filter by status (pending|verified|flagged|rejected)')\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'text')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await tables(client, jobId, {\n page: options.page,\n status: options.status,\n });\n writeOutput(formatTablesOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// history command - Verification audit trail\n// ============================================================================\nprogram\n .command('history <jobId>')\n .description('Show verification history')\n .option('-l, --limit <n>', 'Limit entries', parseInt, 50)\n .option('-f, --format <format>', 'Output format (text|json)', 'text')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await history(client, jobId, { limit: options.limit });\n writeOutput(formatHistoryOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\n// ============================================================================\n// toc command - Table of contents extraction\n// ============================================================================\nprogram\n .command('toc <jobId>')\n .description('Extract table of contents from PDF')\n .option('--max-depth <n>', 'Maximum TOC depth', parseInt)\n .option('-f, --format <format>', 'Output format (text|json|markdown)', 'text')\n .option('--watch', 'Watch live extraction events via WebSocket')\n .action(async (jobId, options) => {\n const g = globals();\n try {\n const client = getClient();\n const fmt = g.json ? 'json' : options.format;\n const result = await toc(client, jobId, {\n maxDepth: options.maxDepth,\n watch: options.watch,\n });\n writeOutput(formatTocOutput(result, fmt), g.output);\n } catch (error) {\n handleError(error, g.json);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAkD9B,IAAM,UAAU,IAAI,QAAQ;AAC5B,QAAQ,mBAAmB;AAC3B,QAAQ,yBAAyB;AAEjC,QACG,KAAK,MAAM,EACX,YAAY,iEAA4D,EACxE,QAAQ,QAAQ,EAChB,OAAO,cAAc,4CAA4C,EACjE,OAAO,eAAe,6CAA6C,EACnE,OAAO,uBAAuB,wCAAwC;AAGzE,SAAS,UAAuB;AAC9B,SAAO,QAAQ,KAAK;AACtB;AAMA,SAAS,YAAwB;AAC/B,QAAM,SAAS,UAAU;AACzB,QAAM,UAAU,WAAW;AAE3B,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,QAAQ;AAClB,QAAI,EAAE,MAAM;AACV,cAAQ,OAAO,MAAM,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B,QAAQ,EACvD,OAAO,yBAAyB,sCAAsC,MAAM,EAC5E,OAAO,WAAW,4CAA4C,EAC9D,OAAO,OAAO,OAAO,YAAY;AAChC,QAAM,IAAI,QAAQ;AAClB,MAAI;AACF,UAAM,SAAS,UAAU;AACzB,UAAM,MAAM,EAAE,OAAO,SAAS,QAAQ;AACtC,UAAM,SAAS,MAAM,IAAI,QAAQ,OAAO;AAAA,MACtC,UAAU,QAAQ;AAAA,MAClB,OAAO,QAAQ;AAAA,IACjB,CAAC;AACD,gBAAY,gBAAgB,QAAQ,GAAG,GAAG,EAAE,MAAM;AAAA,EACpD,SAAS,OAAO;AACd,gBAAY,OAAO,EAAE,IAAI;AAAA,EAC3B;AACF,CAAC;AAEH,QAAQ,MAAM;","names":[]}
@@ -1,5 +1,5 @@
1
- import { O as OkraClient } from '../client-p82YcAs3.js';
2
- import '../types-DDm2eEL0.js';
1
+ import { O as OkraClient } from '../client-DMEw0oK3.js';
2
+ import '../types-D2JaySEg.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/cli/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  toc,
37
37
  tree,
38
38
  writeGlobalConfig
39
- } from "../chunk-XOHPZW3V.js";
39
+ } from "../chunk-F3LECDPP.js";
40
40
  import "../chunk-NIZM2ETT.js";
41
41
  export {
42
42
  authLogin,
@@ -1,4 +1,4 @@
1
- import { b as UploadInput, S as SessionCreateOptions, O as OkraSession, c as SessionAttachOptions, C as CollectionSummary, d as Collection, e as CollectionQueryOptions, f as CollectionQueryStream, g as CollectionExportOptions, h as CollectionMarkdownExport, i as OkraClientOptions, j as UploadOptions, k as DocumentConfigUpdate, l as DocumentConfigResult, R as ReparseOptions, m as ReparseResult, A as ApplyWorkflowOptions, n as ApplyWorkflowResult, o as ApiKeyWorkflowConfigResponse, p as DocumentStatus, W as WaitOptions, P as Page, E as EntitiesResponse, Q as QueryResult, L as LogsOptions, q as LogEntry, r as CompletionOptions, s as CompletionEvent, G as GenerateOptions, t as GenerateResult, u as StructuredSchema, v as PublishResult, w as ShareLinkOptions, x as ShareLinkResult } from './types-DDm2eEL0.js';
1
+ import { b as UploadInput, S as SessionCreateOptions, O as OkraSession, c as SessionAttachOptions, C as CollectionSummary, d as Collection, e as CollectionQueryOptions, f as CollectionQueryStream, g as CollectionExportOptions, h as CollectionMarkdownExport, i as OkraClientOptions, j as UploadOptions, k as DocumentConfigUpdate, l as DocumentConfigResult, R as ReparseOptions, m as ReparseResult, A as ApplyWorkflowOptions, n as ApplyWorkflowResult, o as ApiKeyWorkflowConfigResponse, p as DocumentStatus, W as WaitOptions, P as Page, E as EntitiesResponse, Q as QueryResult, L as LogsOptions, q as LogEntry, r as CompletionOptions, s as CompletionEvent, G as GenerateOptions, t as GenerateResult, u as StructuredSchema, v as DocumentListItem, w as DeleteDocumentResult, x as ReadDocumentOptions, y as ReadDocumentResult, z as PublishResult, B as ShareLinkOptions, F as ShareLinkResult } from './types-D2JaySEg.js';
2
2
 
3
3
  declare class OkraClient {
4
4
  private readonly baseUrl;
@@ -51,6 +51,9 @@ declare class OkraClient {
51
51
  schema: StructuredSchema<T>;
52
52
  }): Promise<GenerateResult<T>>;
53
53
  private generateStructured;
54
+ listDocuments(signal?: AbortSignal): Promise<DocumentListItem[]>;
55
+ deleteDocument(documentId: string, signal?: AbortSignal): Promise<DeleteDocumentResult>;
56
+ read(documentId: string, options?: ReadDocumentOptions): Promise<ReadDocumentResult>;
54
57
  modelEndpoint(documentId: string): string;
55
58
  publish(documentId: string, signal?: AbortSignal): Promise<PublishResult>;
56
59
  shareLink(documentId: string, options?: ShareLinkOptions): Promise<ShareLinkResult>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { O as OkraClient } from './client-p82YcAs3.js';
2
- import { y as ProcessingCapabilities, i as OkraClientOptions, O as OkraSession, r as CompletionOptions, s as CompletionEvent, z as SessionState, p as DocumentStatus, W as WaitOptions, P as Page, E as EntitiesResponse, Q as QueryResult, L as LogsOptions, q as LogEntry, v as PublishResult, w as ShareLinkOptions, x as ShareLinkResult, G as GenerateOptions, t as GenerateResult, u as StructuredSchema, B as RuntimeErrorCode, F as StructuredOutputErrorCode } from './types-DDm2eEL0.js';
3
- export { o as ApiKeyWorkflowConfigResponse, A as ApplyWorkflowOptions, n as ApplyWorkflowResult, d as Collection, H as CollectionDocument, I as CollectionExportEvent, J as CollectionExportFormat, g as CollectionExportOptions, h as CollectionMarkdownExport, K as CollectionQueryEvent, e as CollectionQueryOptions, M as CollectionQueryResult, f as CollectionQueryStream, C as CollectionSummary, D as DocUrlOptions, N as DocumentAnswer, l as DocumentConfigResult, k as DocumentConfigUpdate, T as DocumentMarkdownExport, V as Entity, X as JsonSchema, Y as MarkdownPage, Z as OkraCollections, _ as PageBlock, $ as PageEntity, R as ReparseOptions, m as ReparseResult, c as SessionAttachOptions, S as SessionCreateOptions, a0 as ShareLinkCapabilities, a1 as ShareLinkLinks, a2 as StructuredOutputMeta, b as UploadInput, j as UploadOptions, a3 as UploadRedactOptions, a4 as UploadRedactPiiOptions, U as UrlBuilderOptions, a5 as WorkflowPhase, a6 as WorkflowPhaseConfig, a7 as WorkflowTier } from './types-DDm2eEL0.js';
1
+ import { O as OkraClient } from './client-DMEw0oK3.js';
2
+ import { H as ProcessingCapabilities, i as OkraClientOptions, O as OkraSession, r as CompletionOptions, s as CompletionEvent, I as SessionState, p as DocumentStatus, W as WaitOptions, P as Page, E as EntitiesResponse, Q as QueryResult, L as LogsOptions, q as LogEntry, z as PublishResult, B as ShareLinkOptions, F as ShareLinkResult, G as GenerateOptions, t as GenerateResult, u as StructuredSchema, J as RuntimeErrorCode, K as StructuredOutputErrorCode } from './types-D2JaySEg.js';
3
+ export { o as ApiKeyWorkflowConfigResponse, A as ApplyWorkflowOptions, n as ApplyWorkflowResult, d as Collection, M as CollectionDocument, N as CollectionExportEvent, T as CollectionExportFormat, g as CollectionExportOptions, h as CollectionMarkdownExport, V as CollectionQueryEvent, e as CollectionQueryOptions, X as CollectionQueryResult, f as CollectionQueryStream, C as CollectionSummary, w as DeleteDocumentResult, D as DocUrlOptions, Y as DocumentAnswer, l as DocumentConfigResult, k as DocumentConfigUpdate, v as DocumentListItem, Z as DocumentListResponse, _ as DocumentMarkdownExport, $ as Entity, a0 as JsonSchema, a1 as MarkdownPage, a2 as OkraCollections, a3 as PageBlock, a4 as PageEntity, x as ReadDocumentOptions, y as ReadDocumentResult, R as ReparseOptions, m as ReparseResult, c as SessionAttachOptions, S as SessionCreateOptions, a5 as ShareLinkCapabilities, a6 as ShareLinkLinks, a7 as StructuredOutputMeta, b as UploadInput, j as UploadOptions, a8 as UploadRedactOptions, a9 as UploadRedactPiiOptions, U as UrlBuilderOptions, aa as WorkflowPhase, ab as WorkflowPhaseConfig, ac as WorkflowTier } from './types-D2JaySEg.js';
4
4
  export { doc } from './url.js';
5
5
  import 'zod';
6
6
 
package/dist/index.js CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  withQualityScore,
10
10
  withSecret,
11
11
  workflowPreset
12
- } from "./chunk-YVUL6ZLA.js";
12
+ } from "./chunk-KJMV6TN2.js";
13
13
  import {
14
14
  OkraClient
15
- } from "./chunk-2HJPTW6S.js";
15
+ } from "./chunk-2VKGPLAA.js";
16
16
  import {
17
17
  OkraRuntimeError,
18
18
  StructuredOutputError
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
- import { O as OkraClient } from '../client-p82YcAs3.js';
3
- import { O as OkraSession, p as DocumentStatus, P as Page, u as StructuredSchema, t as GenerateResult } from '../types-DDm2eEL0.js';
4
- export { s as CompletionEvent } from '../types-DDm2eEL0.js';
2
+ import { O as OkraClient } from '../client-DMEw0oK3.js';
3
+ import { O as OkraSession, p as DocumentStatus, P as Page, u as StructuredSchema, t as GenerateResult } from '../types-D2JaySEg.js';
4
+ export { s as CompletionEvent } from '../types-D2JaySEg.js';
5
5
  import 'zod';
6
6
 
7
7
  interface OkraContextValue {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createOkra
3
- } from "../chunk-YVUL6ZLA.js";
4
- import "../chunk-2HJPTW6S.js";
3
+ } from "../chunk-KJMV6TN2.js";
4
+ import "../chunk-2VKGPLAA.js";
5
5
  import "../chunk-NIZM2ETT.js";
6
6
 
7
7
  // src/react/provider.ts
@@ -527,6 +527,32 @@ interface UrlBuilderOptions {
527
527
  /** Delivery transform for image resizing/processing. */
528
528
  transform?: DeliveryTransform;
529
529
  }
530
+ /** A document summary returned by `client.listDocuments()`. */
531
+ interface DocumentListItem {
532
+ id: string;
533
+ file_name: string | null;
534
+ phase: string;
535
+ pages_total: number | null;
536
+ total_nodes: number | null;
537
+ visibility: 'public' | 'private';
538
+ created_at: string;
539
+ }
540
+ interface DocumentListResponse {
541
+ documents: DocumentListItem[];
542
+ }
543
+ interface ReadDocumentOptions {
544
+ /** Page range in "1-5" format. Omit for full document. */
545
+ pages?: string;
546
+ signal?: AbortSignal;
547
+ }
548
+ interface ReadDocumentResult {
549
+ documentId: string;
550
+ markdown: string;
551
+ }
552
+ interface DeleteDocumentResult {
553
+ deleted: boolean;
554
+ documentId: string;
555
+ }
530
556
  interface DocUrlOptions {
531
557
  /**
532
558
  * Original source filename used to build friendly artifact URLs, e.g.
@@ -552,4 +578,4 @@ interface DocUrlOptions {
552
578
  output?: string;
553
579
  }
554
580
 
555
- export type { PageEntity as $, ApplyWorkflowOptions as A, RuntimeErrorCode as B, CollectionSummary as C, DocUrlOptions as D, EntitiesResponse as E, StructuredOutputErrorCode as F, GenerateOptions as G, CollectionDocument as H, CollectionExportEvent as I, CollectionExportFormat as J, CollectionQueryEvent as K, LogsOptions as L, CollectionQueryResult as M, DocumentAnswer as N, OkraSession as O, Page as P, QueryResult as Q, ReparseOptions as R, SessionCreateOptions as S, DocumentMarkdownExport as T, UrlBuilderOptions as U, Entity as V, WaitOptions as W, JsonSchema as X, MarkdownPage as Y, OkraCollections as Z, PageBlock as _, DeliveryTransform as a, ShareLinkCapabilities as a0, ShareLinkLinks as a1, StructuredOutputMeta as a2, UploadRedactOptions as a3, UploadRedactPiiOptions as a4, WorkflowPhase as a5, WorkflowPhaseConfig as a6, WorkflowTier as a7, UploadInput as b, SessionAttachOptions as c, Collection as d, CollectionQueryOptions as e, CollectionQueryStream as f, CollectionExportOptions as g, CollectionMarkdownExport as h, OkraClientOptions as i, UploadOptions as j, DocumentConfigUpdate as k, DocumentConfigResult as l, ReparseResult as m, ApplyWorkflowResult as n, ApiKeyWorkflowConfigResponse as o, DocumentStatus as p, LogEntry as q, CompletionOptions as r, CompletionEvent as s, GenerateResult as t, StructuredSchema as u, PublishResult as v, ShareLinkOptions as w, ShareLinkResult as x, ProcessingCapabilities as y, SessionState as z };
581
+ export type { Entity as $, ApplyWorkflowOptions as A, ShareLinkOptions as B, CollectionSummary as C, DocUrlOptions as D, EntitiesResponse as E, ShareLinkResult as F, GenerateOptions as G, ProcessingCapabilities as H, SessionState as I, RuntimeErrorCode as J, StructuredOutputErrorCode as K, LogsOptions as L, CollectionDocument as M, CollectionExportEvent as N, OkraSession as O, Page as P, QueryResult as Q, ReparseOptions as R, SessionCreateOptions as S, CollectionExportFormat as T, UrlBuilderOptions as U, CollectionQueryEvent as V, WaitOptions as W, CollectionQueryResult as X, DocumentAnswer as Y, DocumentListResponse as Z, DocumentMarkdownExport as _, DeliveryTransform as a, JsonSchema as a0, MarkdownPage as a1, OkraCollections as a2, PageBlock as a3, PageEntity as a4, ShareLinkCapabilities as a5, ShareLinkLinks as a6, StructuredOutputMeta as a7, UploadRedactOptions as a8, UploadRedactPiiOptions as a9, WorkflowPhase as aa, WorkflowPhaseConfig as ab, WorkflowTier as ac, UploadInput as b, SessionAttachOptions as c, Collection as d, CollectionQueryOptions as e, CollectionQueryStream as f, CollectionExportOptions as g, CollectionMarkdownExport as h, OkraClientOptions as i, UploadOptions as j, DocumentConfigUpdate as k, DocumentConfigResult as l, ReparseResult as m, ApplyWorkflowResult as n, ApiKeyWorkflowConfigResponse as o, DocumentStatus as p, LogEntry as q, CompletionOptions as r, CompletionEvent as s, GenerateResult as t, StructuredSchema as u, DocumentListItem as v, DeleteDocumentResult as w, ReadDocumentOptions as x, ReadDocumentResult as y, PublishResult as z };
package/dist/url.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { D as DocUrlOptions, U as UrlBuilderOptions, a as DeliveryTransform } from './types-DDm2eEL0.js';
1
+ import { D as DocUrlOptions, U as UrlBuilderOptions, a as DeliveryTransform } from './types-D2JaySEg.js';
2
2
  import 'zod';
3
3
 
4
4
  interface PgPage {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okrapdf",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "OkraPDF — upload a PDF, get an API. Runtime client, React hooks, and CLI.",
5
5
  "type": "module",
6
6
  "exports": {