@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.
- package/README.md +163 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +175 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/auth.d.ts +6 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +155 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/chat.d.ts +6 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +218 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/docs.d.ts +6 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +181 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/jobs.d.ts +6 -0
- package/dist/commands/jobs.d.ts.map +1 -0
- package/dist/commands/jobs.js +348 -0
- package/dist/commands/jobs.js.map +1 -0
- package/dist/commands/jobs.test.d.ts +5 -0
- package/dist/commands/jobs.test.d.ts.map +1 -0
- package/dist/commands/jobs.test.js +118 -0
- package/dist/commands/jobs.test.js.map +1 -0
- package/dist/commands/logs.d.ts +8 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +186 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/processors.d.ts +8 -0
- package/dist/commands/processors.d.ts.map +1 -0
- package/dist/commands/processors.js +91 -0
- package/dist/commands/processors.js.map +1 -0
- package/dist/commands/review.d.ts +3 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +370 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/shortcuts.d.ts +20 -0
- package/dist/commands/shortcuts.d.ts.map +1 -0
- package/dist/commands/shortcuts.js +405 -0
- package/dist/commands/shortcuts.js.map +1 -0
- package/dist/commands/tables.d.ts +6 -0
- package/dist/commands/tables.d.ts.map +1 -0
- package/dist/commands/tables.js +189 -0
- package/dist/commands/tables.js.map +1 -0
- package/dist/commands/templates.d.ts +8 -0
- package/dist/commands/templates.d.ts.map +1 -0
- package/dist/commands/templates.js +202 -0
- package/dist/commands/templates.js.map +1 -0
- package/dist/index.d.ts +14 -412
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -46
- package/dist/index.js.map +1 -1
- package/dist/lib/browser.d.ts +11 -0
- package/dist/lib/browser.d.ts.map +1 -0
- package/dist/lib/browser.js +33 -0
- package/dist/lib/browser.js.map +1 -0
- package/dist/lib/client.d.ts +57 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +176 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/config.d.ts +56 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +110 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/config.test.d.ts +5 -0
- package/dist/lib/config.test.d.ts.map +1 -0
- package/dist/lib/config.test.js +81 -0
- package/dist/lib/config.test.js.map +1 -0
- package/dist/lib/logs.d.ts +89 -0
- package/dist/lib/logs.d.ts.map +1 -0
- package/dist/lib/logs.js +196 -0
- package/dist/lib/logs.js.map +1 -0
- package/dist/lib/logs.test.d.ts +5 -0
- package/dist/lib/logs.test.d.ts.map +1 -0
- package/dist/lib/logs.test.js +183 -0
- package/dist/lib/logs.test.js.map +1 -0
- package/dist/lib/output.d.ts +73 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/output.js +204 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/output.test.d.ts +5 -0
- package/dist/lib/output.test.d.ts.map +1 -0
- package/dist/lib/output.test.js +174 -0
- package/dist/lib/output.test.js.map +1 -0
- package/dist/lib/processors.d.ts +73 -0
- package/dist/lib/processors.d.ts.map +1 -0
- package/dist/lib/processors.js +94 -0
- package/dist/lib/processors.js.map +1 -0
- package/dist/lib/processors.test.d.ts +5 -0
- package/dist/lib/processors.test.d.ts.map +1 -0
- package/dist/lib/processors.test.js +83 -0
- package/dist/lib/processors.test.js.map +1 -0
- package/dist/lib/progress.d.ts +44 -0
- package/dist/lib/progress.d.ts.map +1 -0
- package/dist/lib/progress.js +102 -0
- package/dist/lib/progress.js.map +1 -0
- package/dist/lib/templates.d.ts +56 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/templates.js +204 -0
- package/dist/lib/templates.js.map +1 -0
- package/dist/lib/templates.test.d.ts +5 -0
- package/dist/lib/templates.test.d.ts.map +1 -0
- package/dist/lib/templates.test.js +101 -0
- package/dist/lib/templates.test.js.map +1 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +56 -25
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +0 -152
- package/dist/bin.js.map +0 -1
- package/dist/chunk-A6YTW4WL.js +0 -499
- package/dist/chunk-A6YTW4WL.js.map +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template management commands
|
|
3
|
+
*
|
|
4
|
+
* Create, list, and use extraction templates.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { listTemplates, loadTemplate, saveTemplate, deleteTemplate, formatTemplateInfo, getTemplatesDir, } from '../lib/templates.js';
|
|
9
|
+
import { formatOutput, success, error, info } from '../lib/output.js';
|
|
10
|
+
import { getDefaultFormat } from '../lib/config.js';
|
|
11
|
+
export function createTemplatesCommand() {
|
|
12
|
+
const templates = new Command('templates')
|
|
13
|
+
.description('Manage extraction templates');
|
|
14
|
+
// templates list
|
|
15
|
+
templates
|
|
16
|
+
.command('list')
|
|
17
|
+
.alias('ls')
|
|
18
|
+
.description('List available templates')
|
|
19
|
+
.option('-o, --output <format>', 'Output format (table, json)', getDefaultFormat())
|
|
20
|
+
.option('-b, --builtin', 'Show only built-in templates')
|
|
21
|
+
.option('-c, --custom', 'Show only custom templates')
|
|
22
|
+
.action((options) => {
|
|
23
|
+
let tpls = listTemplates();
|
|
24
|
+
if (options.builtin) {
|
|
25
|
+
tpls = tpls.filter(t => t.builtin);
|
|
26
|
+
}
|
|
27
|
+
else if (options.custom) {
|
|
28
|
+
tpls = tpls.filter(t => !t.builtin);
|
|
29
|
+
}
|
|
30
|
+
if (options.output === 'json') {
|
|
31
|
+
console.log(formatOutput(tpls, 'json'));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (tpls.length === 0) {
|
|
35
|
+
console.log(chalk.dim('No templates found'));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
console.log(chalk.bold('\nAvailable Templates\n'));
|
|
39
|
+
for (const tpl of tpls) {
|
|
40
|
+
const badge = tpl.builtin ? chalk.gray(' (builtin)') : chalk.green(' (custom)');
|
|
41
|
+
const processor = tpl.processor ? chalk.dim(` [${tpl.processor}]`) : '';
|
|
42
|
+
console.log(` ${chalk.cyan(tpl.id.padEnd(20))} ${tpl.name}${badge}${processor}`);
|
|
43
|
+
console.log(` ${''.padEnd(20)} ${chalk.dim(tpl.description)}`);
|
|
44
|
+
console.log();
|
|
45
|
+
}
|
|
46
|
+
console.log(chalk.dim(`Templates directory: ${getTemplatesDir()}`));
|
|
47
|
+
console.log();
|
|
48
|
+
});
|
|
49
|
+
// templates show <id>
|
|
50
|
+
templates
|
|
51
|
+
.command('show <id>')
|
|
52
|
+
.description('Show template details')
|
|
53
|
+
.option('-o, --output <format>', 'Output format (text, json)', 'text')
|
|
54
|
+
.action((id, options) => {
|
|
55
|
+
const tpl = loadTemplate(id);
|
|
56
|
+
if (!tpl) {
|
|
57
|
+
error(`Template not found: ${id}`);
|
|
58
|
+
console.log(chalk.dim('Run `okra templates list` to see available templates'));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
if (options.output === 'json') {
|
|
62
|
+
console.log(formatOutput(tpl, 'json'));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
console.log();
|
|
66
|
+
console.log(formatTemplateInfo(tpl));
|
|
67
|
+
console.log();
|
|
68
|
+
});
|
|
69
|
+
// templates create
|
|
70
|
+
templates
|
|
71
|
+
.command('create <id>')
|
|
72
|
+
.description('Create a new custom template')
|
|
73
|
+
.option('-n, --name <name>', 'Template name')
|
|
74
|
+
.option('-d, --description <desc>', 'Template description')
|
|
75
|
+
.option('-p, --processor <processor>', 'Preferred processor')
|
|
76
|
+
.option('--from <template>', 'Base on existing template')
|
|
77
|
+
.action(async (id, options) => {
|
|
78
|
+
// Check if template already exists
|
|
79
|
+
const existing = loadTemplate(id);
|
|
80
|
+
if (existing && existing.builtin) {
|
|
81
|
+
error(`Cannot override built-in template: ${id}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
let template;
|
|
85
|
+
if (options.from) {
|
|
86
|
+
// Base on existing template
|
|
87
|
+
const base = loadTemplate(options.from);
|
|
88
|
+
if (!base) {
|
|
89
|
+
error(`Base template not found: ${options.from}`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
template = {
|
|
93
|
+
...base,
|
|
94
|
+
id,
|
|
95
|
+
name: options.name || `${base.name} (copy)`,
|
|
96
|
+
description: options.description || base.description,
|
|
97
|
+
builtin: false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Create new empty template
|
|
102
|
+
template = {
|
|
103
|
+
id,
|
|
104
|
+
name: options.name || id,
|
|
105
|
+
description: options.description || `Custom template: ${id}`,
|
|
106
|
+
documentType: 'custom',
|
|
107
|
+
processor: options.processor,
|
|
108
|
+
fields: [],
|
|
109
|
+
builtin: false,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (options.processor) {
|
|
113
|
+
template.processor = options.processor;
|
|
114
|
+
}
|
|
115
|
+
saveTemplate(template);
|
|
116
|
+
success(`Template created: ${id}`);
|
|
117
|
+
info(`Edit at: ${getTemplatesDir()}/${id}.json`);
|
|
118
|
+
});
|
|
119
|
+
// templates edit <id>
|
|
120
|
+
templates
|
|
121
|
+
.command('edit <id>')
|
|
122
|
+
.description('Open template in editor')
|
|
123
|
+
.action(async (id) => {
|
|
124
|
+
const tpl = loadTemplate(id);
|
|
125
|
+
if (tpl?.builtin) {
|
|
126
|
+
error('Cannot edit built-in template. Use `okra templates create --from` to create a copy.');
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
if (!tpl) {
|
|
130
|
+
error(`Template not found: ${id}`);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
const path = `${getTemplatesDir()}/${id}.json`;
|
|
134
|
+
const editor = process.env.EDITOR || 'vi';
|
|
135
|
+
console.log(chalk.dim(`Opening ${path} in ${editor}...`));
|
|
136
|
+
const { spawn } = await import('child_process');
|
|
137
|
+
const child = spawn(editor, [path], { stdio: 'inherit' });
|
|
138
|
+
child.on('exit', (code) => {
|
|
139
|
+
if (code === 0) {
|
|
140
|
+
success('Template saved');
|
|
141
|
+
}
|
|
142
|
+
process.exit(code || 0);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
// templates delete <id>
|
|
146
|
+
templates
|
|
147
|
+
.command('delete <id>')
|
|
148
|
+
.alias('rm')
|
|
149
|
+
.description('Delete a custom template')
|
|
150
|
+
.option('-f, --force', 'Skip confirmation')
|
|
151
|
+
.action(async (id, options) => {
|
|
152
|
+
const tpl = loadTemplate(id);
|
|
153
|
+
if (!tpl) {
|
|
154
|
+
error(`Template not found: ${id}`);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
if (tpl.builtin) {
|
|
158
|
+
error('Cannot delete built-in template');
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
if (!options.force) {
|
|
162
|
+
const { prompt } = await import('enquirer');
|
|
163
|
+
const response = await prompt({
|
|
164
|
+
type: 'confirm',
|
|
165
|
+
name: 'confirm',
|
|
166
|
+
message: `Delete template "${id}"?`,
|
|
167
|
+
initial: false,
|
|
168
|
+
});
|
|
169
|
+
if (!response.confirm) {
|
|
170
|
+
console.log('Cancelled');
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (deleteTemplate(id)) {
|
|
175
|
+
success(`Template deleted: ${id}`);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
error('Failed to delete template');
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
// templates path
|
|
182
|
+
templates
|
|
183
|
+
.command('path')
|
|
184
|
+
.description('Show templates directory path')
|
|
185
|
+
.action(() => {
|
|
186
|
+
console.log(getTemplatesDir());
|
|
187
|
+
});
|
|
188
|
+
// Default action - same as list
|
|
189
|
+
templates.action(() => {
|
|
190
|
+
const tpls = listTemplates();
|
|
191
|
+
console.log(chalk.bold('\nAvailable Templates\n'));
|
|
192
|
+
for (const tpl of tpls) {
|
|
193
|
+
const badge = tpl.builtin ? chalk.gray(' (builtin)') : chalk.green(' (custom)');
|
|
194
|
+
console.log(` ${chalk.cyan(tpl.id.padEnd(20))} ${tpl.name}${badge}`);
|
|
195
|
+
}
|
|
196
|
+
console.log();
|
|
197
|
+
console.log(chalk.dim('Use `okra templates show <id>` for details'));
|
|
198
|
+
console.log();
|
|
199
|
+
});
|
|
200
|
+
return templates;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/commands/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,eAAe,GAGhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,OAAO,EAA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yB,CAAC,CAAC,CAAC;QAEnD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAChF,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,418 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
3
2
|
/**
|
|
4
|
-
* CLI
|
|
3
|
+
* OkraPDF CLI - Entry Point
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
|
|
11
|
-
type VerificationPageStatus = 'complete' | 'partial' | 'flagged' | 'pending' | 'empty' | 'gap' | 'error';
|
|
12
|
-
interface VerificationTreePage {
|
|
13
|
-
page: number;
|
|
14
|
-
status: VerificationPageStatus;
|
|
15
|
-
total: number;
|
|
16
|
-
verified: number;
|
|
17
|
-
pending: number;
|
|
18
|
-
flagged: number;
|
|
19
|
-
rejected: number;
|
|
20
|
-
avgConfidence: number;
|
|
21
|
-
hasOcr: boolean;
|
|
22
|
-
ocrLineCount: number;
|
|
23
|
-
hasCoverageGaps: boolean;
|
|
24
|
-
uncoveredCount: number;
|
|
25
|
-
resolution: string | null;
|
|
26
|
-
classification: string | null;
|
|
27
|
-
isStale: boolean;
|
|
28
|
-
}
|
|
29
|
-
interface VerificationTreeSummary {
|
|
30
|
-
complete: number;
|
|
31
|
-
partial: number;
|
|
32
|
-
flagged: number;
|
|
33
|
-
pending: number;
|
|
34
|
-
empty: number;
|
|
35
|
-
gap: number;
|
|
36
|
-
resolved?: number;
|
|
37
|
-
stale?: number;
|
|
38
|
-
}
|
|
39
|
-
interface VerificationTree {
|
|
40
|
-
jobId: string;
|
|
41
|
-
documentId: string;
|
|
42
|
-
totalPages: number;
|
|
43
|
-
summary: VerificationTreeSummary;
|
|
44
|
-
pages: VerificationTreePage[];
|
|
45
|
-
}
|
|
46
|
-
type EntityType = 'table' | 'figure' | 'footnote' | 'summary' | 'signature' | 'paragraph';
|
|
47
|
-
interface EntityBBox {
|
|
48
|
-
x: number;
|
|
49
|
-
y: number;
|
|
50
|
-
width: number;
|
|
51
|
-
height: number;
|
|
52
|
-
}
|
|
53
|
-
interface Entity {
|
|
54
|
-
id: string;
|
|
55
|
-
type: EntityType;
|
|
56
|
-
title: string | null;
|
|
57
|
-
page: number;
|
|
58
|
-
schema?: string[];
|
|
59
|
-
isComplete?: boolean;
|
|
60
|
-
bbox?: EntityBBox;
|
|
61
|
-
confidence?: number;
|
|
62
|
-
verificationStatus?: 'pending' | 'verified' | 'flagged' | 'rejected';
|
|
63
|
-
}
|
|
64
|
-
interface EntitiesResponse {
|
|
65
|
-
jobId: string;
|
|
66
|
-
entities: Entity[];
|
|
67
|
-
counts: {
|
|
68
|
-
tables: number;
|
|
69
|
-
figures: number;
|
|
70
|
-
footnotes: number;
|
|
71
|
-
summaries: number;
|
|
72
|
-
signatures?: number;
|
|
73
|
-
};
|
|
74
|
-
extractionStatus?: 'not_started' | 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused';
|
|
75
|
-
totalPages?: number;
|
|
76
|
-
}
|
|
77
|
-
interface TextBlock {
|
|
78
|
-
text: string;
|
|
79
|
-
bbox?: EntityBBox;
|
|
80
|
-
confidence?: number;
|
|
81
|
-
}
|
|
82
|
-
interface PageDimension {
|
|
83
|
-
width: number | null;
|
|
84
|
-
height: number | null;
|
|
85
|
-
}
|
|
86
|
-
interface PageContent {
|
|
87
|
-
page: number;
|
|
88
|
-
content: string;
|
|
89
|
-
version?: number;
|
|
90
|
-
blocks?: TextBlock[];
|
|
91
|
-
dimension?: PageDimension | null;
|
|
92
|
-
}
|
|
93
|
-
interface PageVersionInfo {
|
|
94
|
-
version: number;
|
|
95
|
-
editSource: 'ocr_extraction' | 'user_edit' | 'ai_correction';
|
|
96
|
-
createdAt: string | null;
|
|
97
|
-
preview: string;
|
|
98
|
-
}
|
|
99
|
-
interface PageVersionsResponse {
|
|
100
|
-
page: number;
|
|
101
|
-
currentVersion: number;
|
|
102
|
-
versions: PageVersionInfo[];
|
|
103
|
-
}
|
|
104
|
-
interface Table {
|
|
105
|
-
id: string;
|
|
106
|
-
pageNumber: number;
|
|
107
|
-
markdown: string;
|
|
108
|
-
bbox: {
|
|
109
|
-
xmin: number;
|
|
110
|
-
ymin: number;
|
|
111
|
-
xmax: number;
|
|
112
|
-
ymax: number;
|
|
113
|
-
};
|
|
114
|
-
confidence: number | null;
|
|
115
|
-
verificationStatus: 'pending' | 'verified' | 'flagged' | 'rejected';
|
|
116
|
-
verifiedBy: string | null;
|
|
117
|
-
verifiedAt: string | null;
|
|
118
|
-
wasCorrected?: boolean;
|
|
119
|
-
createdAt: string;
|
|
120
|
-
}
|
|
121
|
-
interface TablesResponse {
|
|
122
|
-
tables: Table[];
|
|
123
|
-
source: 'job_id' | 'document_uuid';
|
|
124
|
-
}
|
|
125
|
-
type MatchSource = 'content' | 'table_title' | 'table_schema' | 'table_row' | 'figure' | 'footnote' | 'summary' | 'signature' | 'paragraph';
|
|
126
|
-
interface SearchResult {
|
|
127
|
-
page: number;
|
|
128
|
-
snippet: string;
|
|
129
|
-
matchCount: number;
|
|
130
|
-
matchSource?: MatchSource;
|
|
131
|
-
}
|
|
132
|
-
interface SearchResponse {
|
|
133
|
-
query: string;
|
|
134
|
-
totalMatches: number;
|
|
135
|
-
results: SearchResult[];
|
|
136
|
-
}
|
|
137
|
-
interface HistoryEntry {
|
|
138
|
-
id: string;
|
|
139
|
-
entityType: string;
|
|
140
|
-
entityId: string;
|
|
141
|
-
state: string;
|
|
142
|
-
previousState: string | null;
|
|
143
|
-
transitionName: string | null;
|
|
144
|
-
triggeredBy: string | null;
|
|
145
|
-
triggeredByName: string | null;
|
|
146
|
-
reason: string | null;
|
|
147
|
-
resolution: string | null;
|
|
148
|
-
classification: string | null;
|
|
149
|
-
pageNum: number | null;
|
|
150
|
-
createdAt: string;
|
|
151
|
-
}
|
|
152
|
-
interface HistoryResponse {
|
|
153
|
-
history: HistoryEntry[];
|
|
154
|
-
}
|
|
155
|
-
type OutputFormat = 'text' | 'json' | 'markdown';
|
|
156
|
-
interface QueryConfig {
|
|
157
|
-
selector: string;
|
|
158
|
-
topK?: number;
|
|
159
|
-
minConfidence?: number;
|
|
160
|
-
pageRange?: [number, number];
|
|
161
|
-
sortBy?: 'confidence' | 'page' | 'type';
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Query Engine - jQuery-like entity selector
|
|
166
|
-
*
|
|
167
|
-
* Inspired by okra-jquery from ~/dev/okrapdf/lib/okra-jquery
|
|
168
|
-
* Supports selectors like:
|
|
169
|
-
* - Type: .table, .figure, .footnote
|
|
170
|
-
* - ID: #entity_123
|
|
171
|
-
* - Attributes: [confidence>0.9], [verified=true]
|
|
172
|
-
* - Page: :page(5), :pages(1-10)
|
|
173
|
-
* - Combinators: .table[confidence>0.9], .table, .figure
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
interface SelectorParts {
|
|
177
|
-
types: EntityType[];
|
|
178
|
-
id?: string;
|
|
179
|
-
pageFilter?: {
|
|
180
|
-
type: 'single' | 'range';
|
|
181
|
-
value: number | [number, number];
|
|
182
|
-
};
|
|
183
|
-
confidenceFilter?: {
|
|
184
|
-
op: '>' | '<' | '>=' | '<=';
|
|
185
|
-
value: number;
|
|
186
|
-
};
|
|
187
|
-
verificationFilter?: 'pending' | 'verified' | 'flagged' | 'rejected';
|
|
188
|
-
textContains?: string;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Parse a jQuery-like selector string into parts.
|
|
192
|
-
*
|
|
193
|
-
* Examples:
|
|
194
|
-
* - ".table" -> { types: ['table'] }
|
|
195
|
-
* - ".table, .figure" -> { types: ['table', 'figure'] }
|
|
196
|
-
* - ".table:page(5)" -> { types: ['table'], pageFilter: { type: 'single', value: 5 } }
|
|
197
|
-
* - "[confidence>0.9]" -> { confidenceFilter: { op: '>', value: 0.9 } }
|
|
198
|
-
* - ".table[confidence>=0.8]:page(1-10)" -> complex filter
|
|
199
|
-
*/
|
|
200
|
-
declare function parseSelector(selector: string): SelectorParts;
|
|
201
|
-
/**
|
|
202
|
-
* Filter entities based on parsed selector parts.
|
|
203
|
-
*/
|
|
204
|
-
declare function filterEntities(entities: Entity[], parts: SelectorParts): Entity[];
|
|
205
|
-
interface QueryOptions {
|
|
206
|
-
topK?: number;
|
|
207
|
-
minConfidence?: number;
|
|
208
|
-
pageRange?: [number, number];
|
|
209
|
-
sortBy?: 'confidence' | 'page' | 'type';
|
|
210
|
-
}
|
|
211
|
-
interface QueryStats {
|
|
212
|
-
total: number;
|
|
213
|
-
byType: Record<string, number>;
|
|
214
|
-
byPage: Record<number, number>;
|
|
215
|
-
avgConfidence: number;
|
|
216
|
-
minConfidence: number;
|
|
217
|
-
maxConfidence: number;
|
|
218
|
-
}
|
|
219
|
-
interface QueryResult {
|
|
220
|
-
entities: Entity[];
|
|
221
|
-
total: number;
|
|
222
|
-
stats: QueryStats;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Execute a query against entities.
|
|
226
|
-
*/
|
|
227
|
-
declare function executeQuery(entities: Entity[], selector: string, options?: QueryOptions): QueryResult;
|
|
228
|
-
/**
|
|
229
|
-
* Calculate aggregate statistics for entities.
|
|
230
|
-
*/
|
|
231
|
-
declare function calculateStats(entities: Entity[]): QueryStats;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* okra tree - Document verification tree command
|
|
235
|
-
*
|
|
236
|
-
* Maps to: Left panel of review page
|
|
237
|
-
* Shows page-level verification status and entity counts.
|
|
5
|
+
* A command-line interface for OkraPDF that provides:
|
|
6
|
+
* - Document management (upload, list, download, delete)
|
|
7
|
+
* - OCR job management (create, status, results, export)
|
|
8
|
+
* - Table extraction and export
|
|
9
|
+
* - Interactive document chat
|
|
238
10
|
*
|
|
239
11
|
* Usage:
|
|
240
|
-
* okra
|
|
241
|
-
* okra tree <jobId> --status pending
|
|
242
|
-
* okra tree <jobId> --entity table
|
|
243
|
-
* okra tree <jobId> --format json
|
|
244
|
-
*/
|
|
245
|
-
|
|
246
|
-
interface TreeOptions {
|
|
247
|
-
status?: VerificationPageStatus$1;
|
|
248
|
-
entity?: EntityType$1;
|
|
249
|
-
format?: 'text' | 'json' | 'markdown';
|
|
250
|
-
}
|
|
251
|
-
interface TreeResult {
|
|
252
|
-
tree: VerificationTreeResponse;
|
|
253
|
-
filteredPages: number[];
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Get the verification tree for a job.
|
|
257
|
-
*/
|
|
258
|
-
declare function tree(client: OkraClient, jobId: string, options?: TreeOptions): Promise<TreeResult>;
|
|
259
|
-
/**
|
|
260
|
-
* Format tree result for output.
|
|
261
|
-
*/
|
|
262
|
-
declare function formatTreeOutput(result: TreeResult, format?: 'text' | 'json' | 'markdown'): string;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* okra find - Entity search with jQuery-like selectors
|
|
266
|
-
*
|
|
267
|
-
* Maps to: Middle panel of review page (entity overlays)
|
|
268
|
-
* Find entities using CSS-like selectors.
|
|
269
|
-
*
|
|
270
|
-
* Usage:
|
|
271
|
-
* okra find <jobId> ".table" # Find all tables
|
|
272
|
-
* okra find <jobId> ".figure:page(5)" # Figures on page 5
|
|
273
|
-
* okra find <jobId> "[confidence>0.9]" # High confidence entities
|
|
274
|
-
* okra find <jobId> ".table, .figure" # Tables OR figures
|
|
275
|
-
* okra find <jobId> "*" --stats # All entities with stats
|
|
276
|
-
* okra find <jobId> ".table" --top-k 10 # Top 10 tables
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
|
-
interface FindOptions extends QueryOptions {
|
|
280
|
-
stats?: boolean;
|
|
281
|
-
format?: 'text' | 'json' | 'entities' | 'ids';
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Find entities matching a selector.
|
|
285
|
-
*/
|
|
286
|
-
declare function find(client: OkraClient, jobId: string, selector: string, options?: FindOptions): Promise<QueryResult>;
|
|
287
|
-
/**
|
|
288
|
-
* Format find result for output.
|
|
289
|
-
*/
|
|
290
|
-
declare function formatFindOutput(result: QueryResult, format?: 'text' | 'json' | 'entities' | 'ids', showStats?: boolean): string;
|
|
291
|
-
/**
|
|
292
|
-
* Format stats only.
|
|
293
|
-
*/
|
|
294
|
-
declare function formatStats(stats: QueryStats): string;
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* okra page - Page content operations
|
|
12
|
+
* okra <command> [options]
|
|
298
13
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* okra page get <jobId> <pageNum> # Get page markdown
|
|
304
|
-
* okra page get <jobId> <pageNum> --version 2 # Get specific version
|
|
305
|
-
* okra page edit <jobId> <pageNum> <content> # Edit page content
|
|
306
|
-
* okra page resolve <jobId> <pageNum> reviewed # Mark as reviewed
|
|
307
|
-
* okra page versions <jobId> <pageNum> # List versions
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
interface PageGetOptions {
|
|
311
|
-
version?: number;
|
|
312
|
-
format?: 'text' | 'json' | 'markdown';
|
|
313
|
-
}
|
|
314
|
-
interface PageResolveOptions {
|
|
315
|
-
resolution: string;
|
|
316
|
-
classification?: string;
|
|
317
|
-
reason?: string;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Get page content.
|
|
321
|
-
*/
|
|
322
|
-
declare function pageGet(client: OkraClient, jobId: string, pageNum: number, options?: PageGetOptions): Promise<PageContentResponse>;
|
|
323
|
-
/**
|
|
324
|
-
* Edit page content.
|
|
325
|
-
*/
|
|
326
|
-
declare function pageEdit(client: OkraClient, jobId: string, pageNum: number, content: string): Promise<{
|
|
327
|
-
success: boolean;
|
|
328
|
-
version: number;
|
|
329
|
-
}>;
|
|
330
|
-
/**
|
|
331
|
-
* Resolve page verification status.
|
|
332
|
-
*/
|
|
333
|
-
declare function pageResolve(client: OkraClient, jobId: string, pageNum: number, options: PageResolveOptions): Promise<{
|
|
334
|
-
success: boolean;
|
|
335
|
-
}>;
|
|
336
|
-
/**
|
|
337
|
-
* List page versions.
|
|
338
|
-
*/
|
|
339
|
-
declare function pageVersions(client: OkraClient, jobId: string, pageNum: number): Promise<PageVersionsResponse$1>;
|
|
340
|
-
/**
|
|
341
|
-
* Format page content for output.
|
|
342
|
-
*/
|
|
343
|
-
declare function formatPageOutput(content: PageContentResponse, format?: 'text' | 'json' | 'markdown'): string;
|
|
344
|
-
/**
|
|
345
|
-
* Format versions list for output.
|
|
346
|
-
*/
|
|
347
|
-
declare function formatVersionsOutput(versions: PageVersionsResponse$1, format?: 'text' | 'json'): string;
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* okra search - Full-text search command
|
|
351
|
-
*
|
|
352
|
-
* Search page content across all pages.
|
|
353
|
-
*
|
|
354
|
-
* Usage:
|
|
355
|
-
* okra search <jobId> "revenue"
|
|
356
|
-
* okra search <jobId> "total" --format json
|
|
357
|
-
*/
|
|
358
|
-
|
|
359
|
-
interface SearchOptions {
|
|
360
|
-
format?: 'text' | 'json';
|
|
361
|
-
limit?: number;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Search page content.
|
|
365
|
-
*/
|
|
366
|
-
declare function search(client: OkraClient, jobId: string, query: string): Promise<SearchResponse$1>;
|
|
367
|
-
/**
|
|
368
|
-
* Format search results for output.
|
|
369
|
-
*/
|
|
370
|
-
declare function formatSearchOutput(result: SearchResponse$1, format?: 'text' | 'json'): string;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* okra tables - List and filter tables
|
|
374
|
-
*
|
|
375
|
-
* Usage:
|
|
376
|
-
* okra tables <jobId>
|
|
377
|
-
* okra tables <jobId> --page 5
|
|
378
|
-
* okra tables <jobId> --status pending
|
|
379
|
-
* okra tables <jobId> --format json
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
|
-
interface TablesOptions {
|
|
383
|
-
page?: number;
|
|
384
|
-
status?: 'pending' | 'verified' | 'flagged' | 'rejected';
|
|
385
|
-
format?: 'text' | 'json' | 'markdown';
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Get tables for a job.
|
|
389
|
-
*/
|
|
390
|
-
declare function tables(client: OkraClient, jobId: string, options?: TablesOptions): Promise<TablesResponse$1>;
|
|
391
|
-
/**
|
|
392
|
-
* Format tables for output.
|
|
393
|
-
*/
|
|
394
|
-
declare function formatTablesOutput(result: TablesResponse$1, format?: 'text' | 'json' | 'markdown'): string;
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* okra history - Verification audit trail
|
|
398
|
-
*
|
|
399
|
-
* Usage:
|
|
400
|
-
* okra history <jobId>
|
|
401
|
-
* okra history <jobId> --limit 20
|
|
402
|
-
* okra history <jobId> --format json
|
|
403
|
-
*/
|
|
404
|
-
|
|
405
|
-
interface HistoryOptions {
|
|
406
|
-
limit?: number;
|
|
407
|
-
format?: 'text' | 'json';
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Get verification history.
|
|
411
|
-
*/
|
|
412
|
-
declare function history(client: OkraClient, jobId: string, options?: HistoryOptions): Promise<HistoryResponse$1>;
|
|
413
|
-
/**
|
|
414
|
-
* Format history for output.
|
|
14
|
+
* Examples:
|
|
15
|
+
* okra auth login
|
|
16
|
+
* okra extract invoice.pdf
|
|
17
|
+
* okra chat <document-uuid>
|
|
415
18
|
*/
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
export { type EntitiesResponse, type Entity, type EntityBBox, type EntityType, type FindOptions, type HistoryEntry, type HistoryOptions, type HistoryResponse, type MatchSource, type OutputFormat, type PageContent, type PageDimension, type PageGetOptions, type PageResolveOptions, type PageVersionInfo, type PageVersionsResponse, type QueryConfig, type QueryOptions, type QueryResult, type QueryStats, type SearchOptions, type SearchResponse, type SearchResult, type SelectorParts, type Table, type TablesOptions, type TablesResponse, type TextBlock, type TreeOptions, type TreeResult, type VerificationPageStatus, type VerificationTree, type VerificationTreePage, type VerificationTreeSummary, calculateStats, executeQuery, filterEntities, find, formatFindOutput, formatHistoryOutput, formatPageOutput, formatSearchOutput, formatStats, formatTablesOutput, formatTreeOutput, formatVersionsOutput, history, pageEdit, pageGet, pageResolve, pageVersions, parseSelector, search, tables, tree };
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;GAgBG"}
|