@okrapdf/cli 0.1.0 → 0.1.2

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.
Files changed (115) hide show
  1. package/README.md +163 -0
  2. package/dist/cli.d.ts +19 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +175 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/auth.d.ts +6 -0
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/auth.js +155 -0
  9. package/dist/commands/auth.js.map +1 -0
  10. package/dist/commands/chat.d.ts +6 -0
  11. package/dist/commands/chat.d.ts.map +1 -0
  12. package/dist/commands/chat.js +218 -0
  13. package/dist/commands/chat.js.map +1 -0
  14. package/dist/commands/docs.d.ts +6 -0
  15. package/dist/commands/docs.d.ts.map +1 -0
  16. package/dist/commands/docs.js +181 -0
  17. package/dist/commands/docs.js.map +1 -0
  18. package/dist/commands/jobs.d.ts +6 -0
  19. package/dist/commands/jobs.d.ts.map +1 -0
  20. package/dist/commands/jobs.js +348 -0
  21. package/dist/commands/jobs.js.map +1 -0
  22. package/dist/commands/jobs.test.d.ts +5 -0
  23. package/dist/commands/jobs.test.d.ts.map +1 -0
  24. package/dist/commands/jobs.test.js +118 -0
  25. package/dist/commands/jobs.test.js.map +1 -0
  26. package/dist/commands/logs.d.ts +8 -0
  27. package/dist/commands/logs.d.ts.map +1 -0
  28. package/dist/commands/logs.js +186 -0
  29. package/dist/commands/logs.js.map +1 -0
  30. package/dist/commands/processors.d.ts +8 -0
  31. package/dist/commands/processors.d.ts.map +1 -0
  32. package/dist/commands/processors.js +91 -0
  33. package/dist/commands/processors.js.map +1 -0
  34. package/dist/commands/review.d.ts +3 -0
  35. package/dist/commands/review.d.ts.map +1 -0
  36. package/dist/commands/review.js +370 -0
  37. package/dist/commands/review.js.map +1 -0
  38. package/dist/commands/shortcuts.d.ts +20 -0
  39. package/dist/commands/shortcuts.d.ts.map +1 -0
  40. package/dist/commands/shortcuts.js +405 -0
  41. package/dist/commands/shortcuts.js.map +1 -0
  42. package/dist/commands/tables.d.ts +6 -0
  43. package/dist/commands/tables.d.ts.map +1 -0
  44. package/dist/commands/tables.js +189 -0
  45. package/dist/commands/tables.js.map +1 -0
  46. package/dist/commands/templates.d.ts +8 -0
  47. package/dist/commands/templates.d.ts.map +1 -0
  48. package/dist/commands/templates.js +202 -0
  49. package/dist/commands/templates.js.map +1 -0
  50. package/dist/index.d.ts +14 -412
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +23 -46
  53. package/dist/index.js.map +1 -1
  54. package/dist/lib/browser.d.ts +11 -0
  55. package/dist/lib/browser.d.ts.map +1 -0
  56. package/dist/lib/browser.js +33 -0
  57. package/dist/lib/browser.js.map +1 -0
  58. package/dist/lib/client.d.ts +57 -0
  59. package/dist/lib/client.d.ts.map +1 -0
  60. package/dist/lib/client.js +176 -0
  61. package/dist/lib/client.js.map +1 -0
  62. package/dist/lib/config.d.ts +56 -0
  63. package/dist/lib/config.d.ts.map +1 -0
  64. package/dist/lib/config.js +110 -0
  65. package/dist/lib/config.js.map +1 -0
  66. package/dist/lib/config.test.d.ts +5 -0
  67. package/dist/lib/config.test.d.ts.map +1 -0
  68. package/dist/lib/config.test.js +81 -0
  69. package/dist/lib/config.test.js.map +1 -0
  70. package/dist/lib/logs.d.ts +89 -0
  71. package/dist/lib/logs.d.ts.map +1 -0
  72. package/dist/lib/logs.js +196 -0
  73. package/dist/lib/logs.js.map +1 -0
  74. package/dist/lib/logs.test.d.ts +5 -0
  75. package/dist/lib/logs.test.d.ts.map +1 -0
  76. package/dist/lib/logs.test.js +183 -0
  77. package/dist/lib/logs.test.js.map +1 -0
  78. package/dist/lib/output.d.ts +73 -0
  79. package/dist/lib/output.d.ts.map +1 -0
  80. package/dist/lib/output.js +204 -0
  81. package/dist/lib/output.js.map +1 -0
  82. package/dist/lib/output.test.d.ts +5 -0
  83. package/dist/lib/output.test.d.ts.map +1 -0
  84. package/dist/lib/output.test.js +174 -0
  85. package/dist/lib/output.test.js.map +1 -0
  86. package/dist/lib/processors.d.ts +73 -0
  87. package/dist/lib/processors.d.ts.map +1 -0
  88. package/dist/lib/processors.js +94 -0
  89. package/dist/lib/processors.js.map +1 -0
  90. package/dist/lib/processors.test.d.ts +5 -0
  91. package/dist/lib/processors.test.d.ts.map +1 -0
  92. package/dist/lib/processors.test.js +83 -0
  93. package/dist/lib/processors.test.js.map +1 -0
  94. package/dist/lib/progress.d.ts +44 -0
  95. package/dist/lib/progress.d.ts.map +1 -0
  96. package/dist/lib/progress.js +102 -0
  97. package/dist/lib/progress.js.map +1 -0
  98. package/dist/lib/templates.d.ts +56 -0
  99. package/dist/lib/templates.d.ts.map +1 -0
  100. package/dist/lib/templates.js +204 -0
  101. package/dist/lib/templates.js.map +1 -0
  102. package/dist/lib/templates.test.d.ts +5 -0
  103. package/dist/lib/templates.test.d.ts.map +1 -0
  104. package/dist/lib/templates.test.js +101 -0
  105. package/dist/lib/templates.test.js.map +1 -0
  106. package/dist/types.d.ts +144 -0
  107. package/dist/types.d.ts.map +1 -0
  108. package/dist/types.js +5 -0
  109. package/dist/types.js.map +1 -0
  110. package/package.json +56 -25
  111. package/dist/bin.d.ts +0 -1
  112. package/dist/bin.js +0 -152
  113. package/dist/bin.js.map +0 -1
  114. package/dist/chunk-A6YTW4WL.js +0 -499
  115. package/dist/chunk-A6YTW4WL.js.map +0 -1
@@ -0,0 +1,144 @@
1
+ /**
2
+ * OkraPDF CLI Types
3
+ */
4
+ export type JobStatus = 'queued' | 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
5
+ export type VerificationStatus = 'pending' | 'verified' | 'flagged' | 'rejected' | 'skipped' | 'needs_review';
6
+ export type OutputFormat = 'table' | 'json' | 'jsonl' | 'csv' | 'markdown';
7
+ export interface Document {
8
+ uuid: string;
9
+ file_name: string;
10
+ file_size: number | null;
11
+ upload_date: string;
12
+ document_type: string;
13
+ thumbnail_url: string | null;
14
+ tables_count?: number;
15
+ }
16
+ export interface Job {
17
+ id?: string;
18
+ job_id?: string;
19
+ status: JobStatus;
20
+ file_name?: string | null;
21
+ filename?: string | null;
22
+ pdf_url?: string | null;
23
+ total_pages: number | null;
24
+ pages_completed: number | null;
25
+ document_uuid?: string | null;
26
+ inserted_at?: string;
27
+ created_at?: string;
28
+ updated_at: string;
29
+ error: string | null;
30
+ }
31
+ export interface NormalizedJob {
32
+ id: string;
33
+ status: JobStatus;
34
+ file_name: string | null;
35
+ total_pages: number | null;
36
+ pages_completed: number | null;
37
+ updated_at: string;
38
+ error: string | null;
39
+ }
40
+ export interface CreateJobResponse {
41
+ job_id: string;
42
+ status: JobStatus;
43
+ poll_url: string;
44
+ message?: string;
45
+ }
46
+ export interface JobResults {
47
+ job_id: string;
48
+ status: JobStatus;
49
+ pages: PageResult[];
50
+ tables: TableResult[];
51
+ metadata: Record<string, unknown>;
52
+ }
53
+ export interface PageResult {
54
+ page_number: number;
55
+ text: string;
56
+ entities: Entity[];
57
+ }
58
+ export interface Entity {
59
+ type: string;
60
+ value: string;
61
+ confidence: number;
62
+ bounding_box?: BoundingBox;
63
+ }
64
+ export interface TableResult {
65
+ id: string;
66
+ page_number: number;
67
+ content_markdown: string;
68
+ confidence: number | null;
69
+ bbox?: BoundingBox;
70
+ }
71
+ export interface BoundingBox {
72
+ xmin: number;
73
+ ymin: number;
74
+ xmax: number;
75
+ ymax: number;
76
+ }
77
+ export interface Table {
78
+ id: string;
79
+ document_uuid: string;
80
+ page_number: number;
81
+ content_markdown: string;
82
+ processor_type: string;
83
+ confidence: number | null;
84
+ bbox: BoundingBox;
85
+ verification_status?: VerificationStatus;
86
+ verified_at?: string | null;
87
+ verified_by?: string | null;
88
+ created_at: string;
89
+ updated_at?: string;
90
+ }
91
+ export interface ChatMessage {
92
+ role: 'user' | 'assistant' | 'system';
93
+ content: string;
94
+ timestamp?: string;
95
+ }
96
+ export interface ChatResponse {
97
+ message: ChatMessage;
98
+ job_id?: string;
99
+ output_files?: OutputFile[];
100
+ }
101
+ export interface OutputFile {
102
+ filename: string;
103
+ gcs_path: string;
104
+ mime_type: string;
105
+ }
106
+ export interface ApiResponse<T> {
107
+ success: boolean;
108
+ data?: T;
109
+ error?: ApiError;
110
+ }
111
+ export interface ApiError {
112
+ code: string;
113
+ message: string;
114
+ details?: Record<string, unknown>;
115
+ }
116
+ export interface PaginatedResponse<T> {
117
+ items: T[];
118
+ pagination: {
119
+ page: number;
120
+ limit: number;
121
+ total: number;
122
+ totalPages: number;
123
+ hasNextPage: boolean;
124
+ hasPrevPage: boolean;
125
+ };
126
+ }
127
+ export interface CliConfig {
128
+ api_key?: string;
129
+ base_url: string;
130
+ default_format: OutputFormat;
131
+ }
132
+ export interface SignedUrlResponse {
133
+ upload_url: string;
134
+ document_uuid: string;
135
+ gcs_path: string;
136
+ }
137
+ export interface UserInfo {
138
+ id: string;
139
+ email: string;
140
+ name?: string;
141
+ created_at: string;
142
+ }
143
+ export type ExportFormat = 'docx' | 'xlsx' | 'zip' | 'csv' | 'json';
144
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAGhG,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAC;AAG9G,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,CAAC;AAG3E,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACp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AW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * OkraPDF CLI Types
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json CHANGED
@@ -1,38 +1,69 @@
1
1
  {
2
2
  "name": "@okrapdf/cli",
3
- "version": "0.1.0",
4
- "description": "CLI for OkraPDF document review operations",
3
+ "version": "0.1.2",
4
+ "description": "OkraPDF command-line interface for PDF extraction and document chat",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "okra": "./dist/bin.js"
9
+ "okra": "./dist/index.js"
10
10
  },
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- }
11
+ "publishConfig": {
12
+ "access": "public"
16
13
  },
17
- "files": [
18
- "dist"
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "dev": "tsc --watch",
17
+ "start": "node dist/index.js",
18
+ "test": "vitest run",
19
+ "test:watch": "vitest",
20
+ "test:coverage": "vitest run --coverage",
21
+ "lint": "eslint src/**/*.ts",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "okrapdf",
26
+ "pdf",
27
+ "ocr",
28
+ "extraction",
29
+ "cli",
30
+ "document",
31
+ "table-extraction"
19
32
  ],
33
+ "author": "OkraPDF",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/steventsao/okrapdf.git",
38
+ "directory": "packages/cli"
39
+ },
40
+ "homepage": "https://okrapdf.com",
41
+ "bugs": {
42
+ "url": "https://github.com/steventsao/okrapdf/issues"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
20
47
  "dependencies": {
21
- "commander": "^12.0.0",
22
- "@okrapdf/sdk": "0.1.0"
48
+ "chalk": "^5.3.0",
49
+ "cli-table3": "^0.6.5",
50
+ "commander": "^12.1.0",
51
+ "conf": "^13.0.1",
52
+ "dotenv": "^17.2.3",
53
+ "enquirer": "^2.4.1",
54
+ "form-data": "^4.0.0",
55
+ "got": "^14.4.2",
56
+ "ora": "^8.0.1",
57
+ "ws": "^8.18.0"
23
58
  },
24
59
  "devDependencies": {
25
- "@types/node": "^20.0.0",
26
- "tsup": "^8.0.0",
27
- "typescript": "^5.0.0",
28
- "vitest": "^4.0.0"
29
- },
30
- "peerDependencies": {
31
- "@okrapdf/sdk": "0.1.0"
60
+ "@types/node": "^20.14.0",
61
+ "@types/ws": "^8.5.12",
62
+ "typescript": "^5.5.0",
63
+ "vitest": "^2.0.0"
32
64
  },
33
- "scripts": {
34
- "build": "tsup",
35
- "test": "vitest run",
36
- "test:watch": "vitest"
37
- }
38
- }
65
+ "files": [
66
+ "dist",
67
+ "README.md"
68
+ ]
69
+ }
package/dist/bin.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/bin.js DELETED
@@ -1,152 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- find,
4
- formatFindOutput,
5
- formatHistoryOutput,
6
- formatPageOutput,
7
- formatSearchOutput,
8
- formatStats,
9
- formatTablesOutput,
10
- formatTreeOutput,
11
- formatVersionsOutput,
12
- history,
13
- pageEdit,
14
- pageGet,
15
- pageResolve,
16
- pageVersions,
17
- search,
18
- tables,
19
- tree
20
- } from "./chunk-A6YTW4WL.js";
21
-
22
- // src/bin.ts
23
- import { Command } from "commander";
24
- import { OkraClient } from "@okrapdf/sdk";
25
- var program = new Command();
26
- function getClient() {
27
- return new OkraClient({
28
- apiKey: process.env.OKRA_API_KEY,
29
- baseUrl: process.env.OKRA_BASE_URL || "https://app.okrapdf.com"
30
- });
31
- }
32
- program.name("okra").description("CLI for OkraPDF document review operations").version("0.1.0");
33
- program.command("tree <jobId>").description("Show document verification tree").option("-s, --status <status>", "Filter by status (complete|partial|pending|flagged|empty|gap)").option("-e, --entity <type>", "Filter by entity type (table|figure|footnote)").option("-f, --format <format>", "Output format (text|json|markdown)", "text").action(async (jobId, options) => {
34
- try {
35
- const client = getClient();
36
- const result = await tree(client, jobId, {
37
- status: options.status,
38
- entity: options.entity
39
- });
40
- console.log(formatTreeOutput(result, options.format));
41
- } catch (error) {
42
- console.error("Error:", error.message);
43
- process.exit(1);
44
- }
45
- });
46
- program.command("find <jobId> <selector>").description("Find entities using jQuery-like selectors").option("-k, --top-k <n>", "Limit results", parseInt).option("-c, --min-confidence <n>", "Minimum confidence (0-1)", parseFloat).option("-p, --pages <range>", "Page range (e.g., 1-10)").option("--sort <by>", "Sort by (confidence|page|type)").option("--stats", "Show aggregate statistics").option("-f, --format <format>", "Output format (text|json|entities|ids)", "text").action(async (jobId, selector, options) => {
47
- try {
48
- const client = getClient();
49
- const pageRange = options.pages ? options.pages.split("-").map(Number) : void 0;
50
- const result = await find(client, jobId, selector, {
51
- topK: options.topK,
52
- minConfidence: options.minConfidence,
53
- pageRange,
54
- sortBy: options.sort
55
- });
56
- if (options.stats && options.format === "text") {
57
- console.log(formatStats(result.stats));
58
- } else {
59
- console.log(formatFindOutput(result, options.format, options.stats));
60
- }
61
- } catch (error) {
62
- console.error("Error:", error.message);
63
- process.exit(1);
64
- }
65
- });
66
- var pageCmd = program.command("page").description("Page content operations");
67
- pageCmd.command("get <jobId> <pageNum>").description("Get page content").option("-v, --version <n>", "Specific version", parseInt).option("-f, --format <format>", "Output format (text|json|markdown)", "markdown").action(async (jobId, pageNum, options) => {
68
- try {
69
- const client = getClient();
70
- const content = await pageGet(client, jobId, parseInt(pageNum), {
71
- version: options.version
72
- });
73
- console.log(formatPageOutput(content, options.format));
74
- } catch (error) {
75
- console.error("Error:", error.message);
76
- process.exit(1);
77
- }
78
- });
79
- pageCmd.command("edit <jobId> <pageNum>").description("Edit page content (reads from stdin)").action(async (jobId, pageNum) => {
80
- try {
81
- const chunks = [];
82
- for await (const chunk of process.stdin) {
83
- chunks.push(chunk);
84
- }
85
- const content = Buffer.concat(chunks).toString("utf8");
86
- const client = getClient();
87
- const result = await pageEdit(client, jobId, parseInt(pageNum), content);
88
- console.log(`Saved as version ${result.version}`);
89
- } catch (error) {
90
- console.error("Error:", error.message);
91
- process.exit(1);
92
- }
93
- });
94
- pageCmd.command("resolve <jobId> <pageNum> <resolution>").description("Resolve page verification status").option("-c, --classification <class>", "Classification").option("-r, --reason <reason>", "Reason").action(async (jobId, pageNum, resolution, options) => {
95
- try {
96
- const client = getClient();
97
- const result = await pageResolve(client, jobId, parseInt(pageNum), {
98
- resolution,
99
- classification: options.classification,
100
- reason: options.reason
101
- });
102
- console.log(result.success ? "Resolved" : "Failed");
103
- } catch (error) {
104
- console.error("Error:", error.message);
105
- process.exit(1);
106
- }
107
- });
108
- pageCmd.command("versions <jobId> <pageNum>").description("List page versions").option("-f, --format <format>", "Output format (text|json)", "text").action(async (jobId, pageNum, options) => {
109
- try {
110
- const client = getClient();
111
- const versions = await pageVersions(client, jobId, parseInt(pageNum));
112
- console.log(formatVersionsOutput(versions, options.format));
113
- } catch (error) {
114
- console.error("Error:", error.message);
115
- process.exit(1);
116
- }
117
- });
118
- program.command("search <jobId> <query>").description("Search page content").option("-f, --format <format>", "Output format (text|json)", "text").action(async (jobId, query, options) => {
119
- try {
120
- const client = getClient();
121
- const result = await search(client, jobId, query);
122
- console.log(formatSearchOutput(result, options.format));
123
- } catch (error) {
124
- console.error("Error:", error.message);
125
- process.exit(1);
126
- }
127
- });
128
- program.command("tables <jobId>").description("List extracted tables").option("-p, --page <n>", "Filter by page", parseInt).option("-s, --status <status>", "Filter by status (pending|verified|flagged|rejected)").option("-f, --format <format>", "Output format (text|json|markdown)", "text").action(async (jobId, options) => {
129
- try {
130
- const client = getClient();
131
- const result = await tables(client, jobId, {
132
- page: options.page,
133
- status: options.status
134
- });
135
- console.log(formatTablesOutput(result, options.format));
136
- } catch (error) {
137
- console.error("Error:", error.message);
138
- process.exit(1);
139
- }
140
- });
141
- program.command("history <jobId>").description("Show verification history").option("-l, --limit <n>", "Limit entries", parseInt, 50).option("-f, --format <format>", "Output format (text|json)", "text").action(async (jobId, options) => {
142
- try {
143
- const client = getClient();
144
- const result = await history(client, jobId, { limit: options.limit });
145
- console.log(formatHistoryOutput(result, options.format));
146
- } catch (error) {
147
- console.error("Error:", error.message);
148
- process.exit(1);
149
- }
150
- });
151
- program.parse();
152
- //# sourceMappingURL=bin.js.map
package/dist/bin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * okra CLI - Command line interface for OkraPDF review operations\n *\n * Usage:\n * okra tree <jobId> # Document verification tree\n * okra find <jobId> <selector> # jQuery-like entity search\n * okra page get <jobId> <pageNum> # Get page content\n * okra page edit <jobId> <pageNum> <content> # Edit page content\n * okra page resolve <jobId> <pageNum> <res> # Resolve page status\n * okra search <jobId> <query> # Full-text search\n * okra tables <jobId> # List tables\n * okra history <jobId> # Verification history\n */\n\nimport { Command } from 'commander';\nimport { OkraClient } from '@okrapdf/sdk';\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} from './commands';\n\nconst program = new Command();\n\n// Create client (uses OKRA_API_KEY env var by default)\nfunction getClient(): OkraClient {\n return new OkraClient({\n apiKey: process.env.OKRA_API_KEY,\n baseUrl: process.env.OKRA_BASE_URL || 'https://app.okrapdf.com',\n });\n}\n\nprogram\n .name('okra')\n .description('CLI for OkraPDF document review operations')\n .version('0.1.0');\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 try {\n const client = getClient();\n const result = await tree(client, jobId, {\n status: options.status,\n entity: options.entity,\n });\n console.log(formatTreeOutput(result, options.format));\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 try {\n const client = getClient();\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 && options.format === 'text') {\n console.log(formatStats(result.stats));\n } else {\n console.log(formatFindOutput(result, options.format, options.stats));\n }\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 try {\n const client = getClient();\n const content = await pageGet(client, jobId, parseInt(pageNum), {\n version: options.version,\n });\n console.log(formatPageOutput(content, options.format));\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\n }\n });\n\npageCmd\n .command('edit <jobId> <pageNum>')\n .description('Edit page content (reads from stdin)')\n .action(async (jobId, pageNum) => {\n try {\n // Read content from stdin\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 console.log(`Saved as version ${result.version}`);\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 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 console.log(result.success ? 'Resolved' : 'Failed');\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 try {\n const client = getClient();\n const versions = await pageVersions(client, jobId, parseInt(pageNum));\n console.log(formatVersionsOutput(versions, options.format));\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 try {\n const client = getClient();\n const result = await search(client, jobId, query);\n console.log(formatSearchOutput(result, options.format));\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 try {\n const client = getClient();\n const result = await tables(client, jobId, {\n page: options.page,\n status: options.status,\n });\n console.log(formatTablesOutput(result, options.format));\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\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 try {\n const client = getClient();\n const result = await history(client, jobId, { limit: options.limit });\n console.log(formatHistoryOutput(result, options.format));\n } catch (error: any) {\n console.error('Error:', error.message);\n process.exit(1);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAqB3B,IAAM,UAAU,IAAI,QAAQ;AAG5B,SAAS,YAAwB;AAC/B,SAAO,IAAI,WAAW;AAAA,IACpB,QAAQ,QAAQ,IAAI;AAAA,IACpB,SAAS,QAAQ,IAAI,iBAAiB;AAAA,EACxC,CAAC;AACH;AAEA,QACG,KAAK,MAAM,EACX,YAAY,4CAA4C,EACxD,QAAQ,OAAO;AAKlB,QACG,QAAQ,cAAc,EACtB,YAAY,iCAAiC,EAC7C,OAAO,yBAAyB,+DAA+D,EAC/F,OAAO,uBAAuB,+CAA+C,EAC7E,OAAO,yBAAyB,sCAAsC,MAAM,EAC5E,OAAO,OAAO,OAAO,YAAY;AAChC,MAAI;AACF,UAAM,SAAS,UAAU;AACzB,UAAM,SAAS,MAAM,KAAK,QAAQ,OAAO;AAAA,MACvC,QAAQ,QAAQ;AAAA,MAChB,QAAQ,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