okrapdf 0.12.0 → 0.12.1
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 +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/{chunk-XM4MS5WV.js → chunk-2HJPTW6S.js} +197 -5
- package/dist/chunk-2HJPTW6S.js.map +1 -0
- package/dist/{chunk-YY44NPDZ.js → chunk-XOHPZW3V.js} +80 -9
- package/dist/{chunk-YY44NPDZ.js.map → chunk-XOHPZW3V.js.map} +1 -1
- package/dist/chunk-YVUL6ZLA.js +155 -0
- package/dist/chunk-YVUL6ZLA.js.map +1 -0
- package/dist/cli/bin.js +115 -10
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/index.d.ts +16 -4
- package/dist/cli/index.js +7 -1
- package/dist/{client-CdCU6Div.d.ts → client-p82YcAs3.d.ts} +9 -1
- package/dist/index.d.ts +20 -4
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +2 -2
- package/dist/{types-58dvD4Yj.d.ts → types-DDm2eEL0.d.ts} +114 -2
- package/dist/url.d.ts +1 -1
- package/package.json +3 -1
- package/dist/chunk-ADVWUO22.js +0 -84
- package/dist/chunk-ADVWUO22.js.map +0 -1
- package/dist/chunk-XM4MS5WV.js.map +0 -1
package/dist/cli/bin.js
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
authLogin,
|
|
4
4
|
authLogout,
|
|
5
|
+
authSetKey,
|
|
5
6
|
authStatus,
|
|
7
|
+
authToken,
|
|
8
|
+
authWhoAmI,
|
|
9
|
+
collectionExport,
|
|
6
10
|
collectionList,
|
|
7
11
|
collectionQueryRaw,
|
|
8
12
|
collectionSetVisibility,
|
|
9
13
|
find,
|
|
10
14
|
formatCollectionCsv,
|
|
15
|
+
formatCollectionExportFlat,
|
|
11
16
|
formatCollectionList,
|
|
12
17
|
formatCollectionTable,
|
|
13
18
|
formatFindOutput,
|
|
@@ -35,16 +40,19 @@ import {
|
|
|
35
40
|
tree,
|
|
36
41
|
upload,
|
|
37
42
|
writeOutput
|
|
38
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-XOHPZW3V.js";
|
|
39
44
|
import {
|
|
40
45
|
OkraClient
|
|
41
|
-
} from "../chunk-
|
|
46
|
+
} from "../chunk-2HJPTW6S.js";
|
|
42
47
|
import "../chunk-NIZM2ETT.js";
|
|
43
48
|
|
|
44
49
|
// src/cli/bin.ts
|
|
45
50
|
import { Command } from "commander";
|
|
51
|
+
import { writeFileSync } from "fs";
|
|
46
52
|
var program = new Command();
|
|
47
|
-
program.
|
|
53
|
+
program.showHelpAfterError();
|
|
54
|
+
program.showSuggestionAfterError();
|
|
55
|
+
program.name("okra").description("OkraPDF CLI \u2014 upload PDFs, query collections, extract data").version("0.12.1").option("-j, --json", "Output JSON (structured, machine-readable)").option("-q, --quiet", "Suppress progress and human-readable frills").option("-o, --output <file>", "Write output to file instead of stdout");
|
|
48
56
|
function globals() {
|
|
49
57
|
return program.opts();
|
|
50
58
|
}
|
|
@@ -57,14 +65,14 @@ function getClient() {
|
|
|
57
65
|
process.stderr.write(JSON.stringify({ error: "No API key found", code: 401 }) + "\n");
|
|
58
66
|
} else {
|
|
59
67
|
process.stderr.write(
|
|
60
|
-
'No API key found.\n\n Get one: https://okrapdf.
|
|
68
|
+
'No API key found.\n\n Get one: https://docs.okrapdf.com/api-keys\n Then: export OKRA_API_KEY="okra_xxx"\n Or: npx okra auth login\n\n Docs: https://docs.okrapdf.com\n Discord: https://discord.gg/BHNmbZVs\n'
|
|
61
69
|
);
|
|
62
70
|
}
|
|
63
71
|
process.exit(1);
|
|
64
72
|
}
|
|
65
73
|
return new OkraClient({ apiKey, baseUrl });
|
|
66
74
|
}
|
|
67
|
-
|
|
75
|
+
async function runUploadCommand(source, options) {
|
|
68
76
|
const g = globals();
|
|
69
77
|
try {
|
|
70
78
|
const client = getClient();
|
|
@@ -89,7 +97,35 @@ program.command("upload <source>").description("Upload a PDF (file path or URL),
|
|
|
89
97
|
lines.push(" /v1/documents/{id}/d_shimmer/pg_{N}.png page image");
|
|
90
98
|
lines.push(" /v1/documents/{id}/full.md full document");
|
|
91
99
|
lines.push("");
|
|
92
|
-
lines.push(" Docs: https://okrapdf.
|
|
100
|
+
lines.push(" Docs: https://docs.okrapdf.com Discord: https://discord.gg/BHNmbZVs");
|
|
101
|
+
}
|
|
102
|
+
writeOutput(lines.join("\n"), g.output);
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
handleError(error, g.json);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function registerUploadCommand(commandName, description) {
|
|
109
|
+
program.command(`${commandName} <source>`).description(description).option("--no-wait", "Fire-and-forget (don't wait for processing)").action(async (source, options) => {
|
|
110
|
+
await runUploadCommand(source, options);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
registerUploadCommand("upload", "Upload a PDF (file path or URL), wait for processing");
|
|
114
|
+
registerUploadCommand("extract", "Alias for upload (compatibility)");
|
|
115
|
+
program.command("status <docId>").description("Get document processing status").action(async (docId) => {
|
|
116
|
+
const g = globals();
|
|
117
|
+
try {
|
|
118
|
+
const client = getClient();
|
|
119
|
+
const status = await client.status(docId);
|
|
120
|
+
if (g.json) {
|
|
121
|
+
writeOutput(JSON.stringify(status), g.output);
|
|
122
|
+
} else {
|
|
123
|
+
const lines = [
|
|
124
|
+
`Document: ${docId}`,
|
|
125
|
+
`Phase: ${status.phase}`
|
|
126
|
+
];
|
|
127
|
+
if (typeof status.pagesCompleted === "number" || typeof status.pagesTotal === "number") {
|
|
128
|
+
lines.push(`Pages: ${status.pagesCompleted ?? "?"} / ${status.pagesTotal ?? "?"}`);
|
|
93
129
|
}
|
|
94
130
|
writeOutput(lines.join("\n"), g.output);
|
|
95
131
|
}
|
|
@@ -97,8 +133,22 @@ program.command("upload <source>").description("Upload a PDF (file path or URL),
|
|
|
97
133
|
handleError(error, g.json);
|
|
98
134
|
}
|
|
99
135
|
});
|
|
100
|
-
|
|
101
|
-
|
|
136
|
+
program.command("chat <question>").description("Ask a question about a processed document").requiredOption("--doc <id>", "Document ID").option("--model <name>", "Override model").action(async (question, options) => {
|
|
137
|
+
const g = globals();
|
|
138
|
+
try {
|
|
139
|
+
const client = getClient();
|
|
140
|
+
const result = await client.generate(options.doc, question, options.model ? { model: options.model } : void 0);
|
|
141
|
+
if (g.json) {
|
|
142
|
+
writeOutput(JSON.stringify({ docId: options.doc, question, ...result }), g.output);
|
|
143
|
+
} else {
|
|
144
|
+
writeOutput(result.answer, g.output);
|
|
145
|
+
}
|
|
146
|
+
} catch (error) {
|
|
147
|
+
handleError(error, g.json);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
var collectionCmd = program.command("collection").alias("collections").alias("col").description("Collection operations");
|
|
151
|
+
collectionCmd.command("list").alias("ls").description("List available collections").action(async () => {
|
|
102
152
|
const g = globals();
|
|
103
153
|
try {
|
|
104
154
|
const client = getClient();
|
|
@@ -167,10 +217,51 @@ collectionCmd.command("unpublish <nameOrId>").description("Make a collection pri
|
|
|
167
217
|
handleError(error, g.json);
|
|
168
218
|
}
|
|
169
219
|
});
|
|
220
|
+
collectionCmd.command("export <nameOrId>").description("Export pre-computed markdown for all documents in a collection").option("--flat", "Concatenated markdown with # headers + === separators").option("--zip", "One markdown file per document in a .zip archive").action(async (nameOrId, options) => {
|
|
221
|
+
const g = globals();
|
|
222
|
+
try {
|
|
223
|
+
const client = getClient();
|
|
224
|
+
if (options.flat && options.zip) {
|
|
225
|
+
throw new Error("Use either --flat or --zip, not both");
|
|
226
|
+
}
|
|
227
|
+
if (options.zip) {
|
|
228
|
+
const bytes = await collectionExport(client, nameOrId, { ...g, zip: true });
|
|
229
|
+
const safeBase = String(nameOrId).trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-_.]+|[-_.]+$/g, "") || "collection-export";
|
|
230
|
+
const outputPath = g.output || `${safeBase}.zip`;
|
|
231
|
+
writeFileSync(outputPath, bytes);
|
|
232
|
+
progress(`Wrote \u2192 ${outputPath}`, g.quiet);
|
|
233
|
+
if (g.json) {
|
|
234
|
+
writeOutput(JSON.stringify({
|
|
235
|
+
format: "zip",
|
|
236
|
+
file: outputPath,
|
|
237
|
+
bytes: bytes.byteLength
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const result = await collectionExport(client, nameOrId, { ...g, flat: options.flat });
|
|
243
|
+
if (options.flat) {
|
|
244
|
+
writeOutput(formatCollectionExportFlat(result), g.output);
|
|
245
|
+
} else if (g.json) {
|
|
246
|
+
writeOutput(JSON.stringify(result), g.output);
|
|
247
|
+
} else {
|
|
248
|
+
writeOutput(JSON.stringify(result, null, 2), g.output);
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
handleError(error, g.json);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
170
254
|
var authCmd = program.command("auth").description("Manage authentication");
|
|
171
|
-
authCmd.command("login").description("Save API key to global config").action(async () => {
|
|
255
|
+
authCmd.command("login").description("Save API key to global config").option("-k, --key <apiKey>", "Set API key non-interactively").action(async (options) => {
|
|
172
256
|
try {
|
|
173
|
-
await authLogin();
|
|
257
|
+
await authLogin(options.key);
|
|
258
|
+
} catch (error) {
|
|
259
|
+
handleError(error, globals().json);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
authCmd.command("set-key <apiKey>").description("Save API key to global config (non-interactive)").action(async (apiKey) => {
|
|
263
|
+
try {
|
|
264
|
+
await authSetKey(apiKey);
|
|
174
265
|
} catch (error) {
|
|
175
266
|
handleError(error, globals().json);
|
|
176
267
|
}
|
|
@@ -182,6 +273,20 @@ authCmd.command("status").description("Show authentication status").action(async
|
|
|
182
273
|
handleError(error, globals().json);
|
|
183
274
|
}
|
|
184
275
|
});
|
|
276
|
+
authCmd.command("whoami").description("Show current auth identity (alias for status)").action(async () => {
|
|
277
|
+
try {
|
|
278
|
+
await authWhoAmI();
|
|
279
|
+
} catch (error) {
|
|
280
|
+
handleError(error, globals().json);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
authCmd.command("token").description("Print active API key to stdout").action(async () => {
|
|
284
|
+
try {
|
|
285
|
+
await authToken();
|
|
286
|
+
} catch (error) {
|
|
287
|
+
handleError(error, globals().json);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
185
290
|
authCmd.command("logout").description("Remove API key from global config").action(async () => {
|
|
186
291
|
try {
|
|
187
292
|
await authLogout();
|
package/dist/cli/bin.js.map
CHANGED
|
@@ -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)\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 { 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 authStatus,\n authLogout,\n upload,\n collectionList,\n collectionSetVisibility,\n collectionQueryRaw,\n formatCollectionList,\n formatCollectionCsv,\n formatCollectionTable,\n formatQueryJsonl,\n} from './commands';\nimport { getApiKey, getBaseUrl } from './config';\nimport { handleError, writeOutput, progress } from './output';\nimport type { GlobalFlags } from './output';\n\nconst program = new Command();\n\nprogram\n .name('okra')\n .description('OkraPDF CLI — upload PDFs, query collections, extract data')\n .version('0.9.0')\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://okrapdf.dev/api-keys\\n' +\n ' Then: export OKRA_API_KEY=\"okra_xxx\"\\n' +\n ' Or: npx okra auth login\\n\\n' +\n ' Docs: https://okrapdf.dev/docs\\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// ============================================================================\nprogram\n .command('upload <source>')\n .description('Upload a PDF (file path or URL), wait for processing')\n .option('--no-wait', 'Fire-and-forget (don\\'t wait for processing)')\n .action(async (source, options) => {\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://okrapdf.dev/docs 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\n// ============================================================================\n// collection command\n// ============================================================================\nconst collectionCmd = program.command('collection').description('Collection operations');\n\ncollectionCmd\n .command('list')\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\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 .action(async () => {\n try {\n await authLogin();\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('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;AAsCxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,MAAM,EACX,YAAY,iEAA4D,EACxE,QAAQ,OAAO,EACf,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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;AACF,CAAC;AAKH,QACG,QAAQ,iBAAiB,EACzB,YAAY,2BAA2B,EACvC,OAAO,mBAAmB,iBAAiB,UAAU,EAAE,EACvD,OAAO,yBAAyB,6BAA6B,MAAM,EACnE,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,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 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;AA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B,iBAAiB,UAAU,EAAE,EACvD,OAAO,yBAAyB,6BAA6B,MAAM,EACnE,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,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":[]}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OkraClient } from '../client-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { O as OkraClient } from '../client-p82YcAs3.js';
|
|
2
|
+
import '../types-DDm2eEL0.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -471,11 +471,23 @@ declare function formatTocOutput(result: TocResult, format?: 'text' | 'json' | '
|
|
|
471
471
|
/**
|
|
472
472
|
* Login command - set API key in global config.
|
|
473
473
|
*/
|
|
474
|
-
declare function authLogin(): Promise<void>;
|
|
474
|
+
declare function authLogin(providedApiKey?: string): Promise<void>;
|
|
475
|
+
/**
|
|
476
|
+
* Set API key non-interactively.
|
|
477
|
+
*/
|
|
478
|
+
declare function authSetKey(apiKey: string): Promise<void>;
|
|
475
479
|
/**
|
|
476
480
|
* Status command - show current auth status.
|
|
477
481
|
*/
|
|
478
482
|
declare function authStatus(): Promise<void>;
|
|
483
|
+
/**
|
|
484
|
+
* Print active API key to stdout (for piping).
|
|
485
|
+
*/
|
|
486
|
+
declare function authToken(): Promise<void>;
|
|
487
|
+
/**
|
|
488
|
+
* WhoAmI command - currently aliases auth status.
|
|
489
|
+
*/
|
|
490
|
+
declare function authWhoAmI(): Promise<void>;
|
|
479
491
|
/**
|
|
480
492
|
* Logout command - remove API key from global config.
|
|
481
493
|
*/
|
|
@@ -533,4 +545,4 @@ declare function getBaseUrl(): string | undefined;
|
|
|
533
545
|
*/
|
|
534
546
|
declare function getApiKeySource(): string;
|
|
535
547
|
|
|
536
|
-
export { type EntitiesResponse, type Entity, type EntityBBox, type EntityType, type FindOptions, type HistoryEntry, type HistoryOptions, type HistoryResponse, type MatchSource, type OkraConfig, type OutputFormat, type PageContent, type PageDimension, type PageGetOptions, type PageResolveOptions, type PageVersionInfo, type PageVersionsResponse, type QueryConfig, type QueryOptions, type QueryResult, type QueryStats, type SearchOptions, type SearchResponse, type SearchResult, type SelectorParts, type Table, type TablesOptions, type TablesResponse, type TextBlock, type TocOptions, type TreeOptions, type TreeResult, type VerificationPageStatus, type VerificationTree, type VerificationTreePage, type VerificationTreeSummary, authLogin, authLogout, authStatus, calculateStats, executeQuery, filterEntities, find, formatFindOutput, formatHistoryOutput, formatPageOutput, formatSearchOutput, formatStats, formatTablesOutput, formatTocOutput, formatTreeOutput, formatVersionsOutput, getApiKey, getApiKeySource, getBaseUrl, getGlobalConfigDir, getGlobalConfigPath, history, pageEdit, pageGet, pageResolve, pageVersions, parseSelector, readGlobalConfig, readProjectConfig, search, tables, toc, tree, writeGlobalConfig };
|
|
548
|
+
export { type EntitiesResponse, type Entity, type EntityBBox, type EntityType, type FindOptions, type HistoryEntry, type HistoryOptions, type HistoryResponse, type MatchSource, type OkraConfig, type OutputFormat, type PageContent, type PageDimension, type PageGetOptions, type PageResolveOptions, type PageVersionInfo, type PageVersionsResponse, type QueryConfig, type QueryOptions, type QueryResult, type QueryStats, type SearchOptions, type SearchResponse, type SearchResult, type SelectorParts, type Table, type TablesOptions, type TablesResponse, type TextBlock, type TocOptions, type TreeOptions, type TreeResult, type VerificationPageStatus, type VerificationTree, type VerificationTreePage, type VerificationTreeSummary, authLogin, authLogout, authSetKey, authStatus, authToken, authWhoAmI, calculateStats, executeQuery, filterEntities, find, formatFindOutput, formatHistoryOutput, formatPageOutput, formatSearchOutput, formatStats, formatTablesOutput, formatTocOutput, formatTreeOutput, formatVersionsOutput, getApiKey, getApiKeySource, getBaseUrl, getGlobalConfigDir, getGlobalConfigPath, history, pageEdit, pageGet, pageResolve, pageVersions, parseSelector, readGlobalConfig, readProjectConfig, search, tables, toc, tree, writeGlobalConfig };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
authLogin,
|
|
3
3
|
authLogout,
|
|
4
|
+
authSetKey,
|
|
4
5
|
authStatus,
|
|
6
|
+
authToken,
|
|
7
|
+
authWhoAmI,
|
|
5
8
|
calculateStats,
|
|
6
9
|
executeQuery,
|
|
7
10
|
filterEntities,
|
|
@@ -33,12 +36,15 @@ import {
|
|
|
33
36
|
toc,
|
|
34
37
|
tree,
|
|
35
38
|
writeGlobalConfig
|
|
36
|
-
} from "../chunk-
|
|
39
|
+
} from "../chunk-XOHPZW3V.js";
|
|
37
40
|
import "../chunk-NIZM2ETT.js";
|
|
38
41
|
export {
|
|
39
42
|
authLogin,
|
|
40
43
|
authLogout,
|
|
44
|
+
authSetKey,
|
|
41
45
|
authStatus,
|
|
46
|
+
authToken,
|
|
47
|
+
authWhoAmI,
|
|
42
48
|
calculateStats,
|
|
43
49
|
executeQuery,
|
|
44
50
|
filterEntities,
|
|
@@ -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
|
|
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';
|
|
2
2
|
|
|
3
3
|
declare class OkraClient {
|
|
4
4
|
private readonly baseUrl;
|
|
@@ -13,12 +13,20 @@ declare class OkraClient {
|
|
|
13
13
|
list: (signal?: AbortSignal) => Promise<CollectionSummary[]>;
|
|
14
14
|
get: (collectionId: string, signal?: AbortSignal) => Promise<Collection>;
|
|
15
15
|
query: <T = undefined>(collectionId: string, prompt: string, options?: CollectionQueryOptions<T>) => CollectionQueryStream<T>;
|
|
16
|
+
exportMarkdown: (collectionId: string, options?: AbortSignal | CollectionExportOptions) => Promise<CollectionMarkdownExport | Uint8Array>;
|
|
16
17
|
};
|
|
17
18
|
constructor(options: OkraClientOptions);
|
|
18
19
|
private collectionList;
|
|
19
20
|
private collectionGet;
|
|
20
21
|
private collectionQuery;
|
|
22
|
+
private collectionExportPath;
|
|
23
|
+
private collectionExportMarkdown;
|
|
21
24
|
upload(input: UploadInput, options?: UploadOptions): Promise<OkraSession>;
|
|
25
|
+
updateConfig(documentId: string, update: DocumentConfigUpdate, signal?: AbortSignal): Promise<DocumentConfigResult>;
|
|
26
|
+
reparse(documentId: string, options?: ReparseOptions): Promise<ReparseResult>;
|
|
27
|
+
applyWorkflow(documentId: string, options: ApplyWorkflowOptions): Promise<ApplyWorkflowResult>;
|
|
28
|
+
getKeyWorkflow(signal?: AbortSignal): Promise<ApiKeyWorkflowConfigResponse>;
|
|
29
|
+
setKeyWorkflow(defaultCapabilities: ApiKeyWorkflowConfigResponse['default_capabilities'], signal?: AbortSignal): Promise<ApiKeyWorkflowConfigResponse>;
|
|
22
30
|
status(documentId: string, signal?: AbortSignal): Promise<DocumentStatus>;
|
|
23
31
|
wait(documentId: string, options?: WaitOptions): Promise<DocumentStatus>;
|
|
24
32
|
pages(documentId: string, options?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { O as OkraClient } from './client-
|
|
2
|
-
import {
|
|
3
|
-
export { d as Collection,
|
|
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';
|
|
4
4
|
export { doc } from './url.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
|
+
type WorkflowPresetName = 'default' | 'llamaparse_ocr' | 'parse_proxy_ocr' | 'docling_ocr';
|
|
8
|
+
declare const DEFAULT_WORKFLOW_CAPABILITIES: ProcessingCapabilities;
|
|
9
|
+
declare const WORKFLOW_PRESETS: Record<WorkflowPresetName, ProcessingCapabilities>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns immutable capabilities for a named workflow preset.
|
|
12
|
+
* Optional overrides are deep-merged on top for per-app tuning.
|
|
13
|
+
*/
|
|
14
|
+
declare function workflowPreset(name: WorkflowPresetName, overrides?: ProcessingCapabilities): ProcessingCapabilities;
|
|
15
|
+
|
|
7
16
|
type ExtractionPhase = 'ocr' | 'enhance' | 'metadata' | 'verify';
|
|
8
17
|
interface OkraProvider {
|
|
9
18
|
name: string;
|
|
@@ -17,7 +26,14 @@ interface CreateOkraOptions extends OkraClientOptions {
|
|
|
17
26
|
providers?: Record<string, OkraProvider>;
|
|
18
27
|
extraction?: Partial<Record<ExtractionPhase, string>>;
|
|
19
28
|
middleware?: OkraMiddleware[];
|
|
29
|
+
/** Legacy default BYOK keys (prefer `workflow.vendorKeys`). */
|
|
20
30
|
vendorKeys?: Record<string, string>;
|
|
31
|
+
/** General workflow defaults for all uploads from this client. */
|
|
32
|
+
workflow?: {
|
|
33
|
+
preset?: WorkflowPresetName;
|
|
34
|
+
capabilities?: ProcessingCapabilities;
|
|
35
|
+
vendorKeys?: Record<string, string>;
|
|
36
|
+
};
|
|
21
37
|
}
|
|
22
38
|
/**
|
|
23
39
|
* Factory function — AI SDK-style provider abstraction.
|
|
@@ -120,4 +136,4 @@ declare class StructuredOutputError extends OkraRuntimeError {
|
|
|
120
136
|
constructor(code: StructuredOutputErrorCode, message: string, status: number, details?: unknown);
|
|
121
137
|
}
|
|
122
138
|
|
|
123
|
-
export { type ChatStreamServerEvent, CompletionEvent, CompletionOptions, type CreateOkraOptions, DocumentStatus, EntitiesResponse, type ExtractionPhase, GenerateOptions, GenerateResult, LogEntry, LogsOptions, OkraClient, OkraClientOptions, type OkraMiddleware, type OkraProvider, OkraClient as OkraRuntime, OkraRuntimeError, OkraSession, Page, PublishResult, QueryResult, RuntimeErrorCode, SessionState, ShareLinkOptions, ShareLinkResult, StructuredOutputError, StructuredOutputErrorCode, StructuredSchema, WaitOptions, type WsSendFn, WsSession, type WsSessionOptions, type WsSubscribeFn, createOkra, withCache, withQualityScore, withSecret };
|
|
139
|
+
export { type ChatStreamServerEvent, CompletionEvent, CompletionOptions, type CreateOkraOptions, DEFAULT_WORKFLOW_CAPABILITIES, DocumentStatus, EntitiesResponse, type ExtractionPhase, GenerateOptions, GenerateResult, LogEntry, LogsOptions, OkraClient, OkraClientOptions, type OkraMiddleware, type OkraProvider, OkraClient as OkraRuntime, OkraRuntimeError, OkraSession, Page, ProcessingCapabilities, PublishResult, QueryResult, RuntimeErrorCode, SessionState, ShareLinkOptions, ShareLinkResult, StructuredOutputError, StructuredOutputErrorCode, StructuredSchema, WORKFLOW_PRESETS, WaitOptions, type WorkflowPresetName, type WsSendFn, WsSession, type WsSessionOptions, type WsSubscribeFn, createOkra, withCache, withQualityScore, withSecret, workflowPreset };
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,17 @@ import {
|
|
|
2
2
|
doc
|
|
3
3
|
} from "./chunk-QKII53VN.js";
|
|
4
4
|
import {
|
|
5
|
+
DEFAULT_WORKFLOW_CAPABILITIES,
|
|
6
|
+
WORKFLOW_PRESETS,
|
|
5
7
|
createOkra,
|
|
6
8
|
withCache,
|
|
7
9
|
withQualityScore,
|
|
8
|
-
withSecret
|
|
9
|
-
|
|
10
|
+
withSecret,
|
|
11
|
+
workflowPreset
|
|
12
|
+
} from "./chunk-YVUL6ZLA.js";
|
|
10
13
|
import {
|
|
11
14
|
OkraClient
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-2HJPTW6S.js";
|
|
13
16
|
import {
|
|
14
17
|
OkraRuntimeError,
|
|
15
18
|
StructuredOutputError
|
|
@@ -145,15 +148,18 @@ var WsSession = class {
|
|
|
145
148
|
}
|
|
146
149
|
};
|
|
147
150
|
export {
|
|
151
|
+
DEFAULT_WORKFLOW_CAPABILITIES,
|
|
148
152
|
OkraClient,
|
|
149
153
|
OkraClient as OkraRuntime,
|
|
150
154
|
OkraRuntimeError,
|
|
151
155
|
StructuredOutputError,
|
|
156
|
+
WORKFLOW_PRESETS,
|
|
152
157
|
WsSession,
|
|
153
158
|
createOkra,
|
|
154
159
|
doc,
|
|
155
160
|
withCache,
|
|
156
161
|
withQualityScore,
|
|
157
|
-
withSecret
|
|
162
|
+
withSecret,
|
|
163
|
+
workflowPreset
|
|
158
164
|
};
|
|
159
165
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ws-session.ts"],"sourcesContent":["/**\n * WsSession — OkraSession adapter that routes `stream()` over an existing\n * WebSocket connection instead of HTTP SSE.\n *\n * All non-streaming methods delegate to the inner HTTP-backed session.\n * Only `stream()` is overridden to send CHAT_COMPLETION over WS and yield\n * CompletionEvents from CHAT_STREAM_* responses.\n *\n * Usage:\n * const wsSession = new WsSession(httpSession, { send, subscribe });\n * const chat = useChat({ session: wsSession });\n */\n\nimport type {\n OkraSession,\n CompletionEvent,\n CompletionOptions,\n DocumentStatus,\n WaitOptions,\n Page,\n EntitiesResponse,\n QueryResult,\n PublishResult,\n ShareLinkOptions,\n ShareLinkResult,\n GenerateOptions,\n GenerateResult,\n SessionState,\n StructuredSchema,\n} from './types';\n\n// Chat stream event types — mirrors @okrapdf/schemas ChatStreamServerEvent\n// Inlined to avoid adding @okrapdf/schemas as a dependency of the published SDK.\n\nexport type ChatStreamServerEvent =\n | { type: 'CHAT_STREAM_START'; requestId: string }\n | { type: 'CHAT_STREAM_DELTA'; requestId: string; delta: string }\n | { type: 'CHAT_STREAM_DONE'; requestId: string; usage?: { inputTokens: number; outputTokens: number; costUsd: number }; model?: string }\n | { type: 'CHAT_STREAM_ERROR'; requestId: string; error: string };\n\n/** Function that sends a JSON string over the WebSocket. Returns false if WS is closed. */\nexport type WsSendFn = (message: string) => boolean;\n\n/** Subscribe to chat stream events. Returns unsubscribe function. */\nexport type WsSubscribeFn = (\n requestId: string,\n handler: (event: ChatStreamServerEvent) => void,\n) => () => void;\n\nexport interface WsSessionOptions {\n /** Send JSON string over the existing WebSocket connection */\n send: WsSendFn;\n /** Subscribe to CHAT_STREAM_* events for a given requestId */\n subscribe: WsSubscribeFn;\n}\n\nfunction uuid(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nexport class WsSession implements OkraSession {\n readonly id: string;\n readonly modelEndpoint: string;\n readonly model?: string;\n\n #inner: OkraSession;\n #opts: WsSessionOptions;\n\n constructor(inner: OkraSession, opts: WsSessionOptions) {\n this.#inner = inner;\n this.#opts = opts;\n this.id = inner.id;\n this.modelEndpoint = inner.modelEndpoint;\n this.model = inner.model;\n }\n\n // ── Overridden: stream via WebSocket ──────────────────────────────────────\n\n async *stream(\n query: string,\n options?: CompletionOptions,\n ): AsyncGenerator<CompletionEvent> {\n const requestId = uuid();\n\n // Build message history (single user message for now — matches HTTP path)\n const messages = [{ role: 'user', content: query }];\n\n const sent = this.#opts.send(JSON.stringify({\n type: 'CHAT_COMPLETION',\n requestId,\n messages,\n }));\n\n if (!sent) {\n yield { type: 'error', message: 'WebSocket not connected' };\n return;\n }\n\n // Create a promise-based event queue\n type QueueItem =\n | { done: false; event: ChatStreamServerEvent }\n | { done: true };\n\n const queue: QueueItem[] = [];\n let resolve: (() => void) | null = null;\n let finished = false;\n\n const unsubscribe = this.#opts.subscribe(requestId, (event) => {\n if (finished) return;\n queue.push({ done: false, event });\n resolve?.();\n });\n\n const cleanup = () => {\n finished = true;\n unsubscribe();\n };\n\n // Handle abort signal\n if (options?.signal) {\n options.signal.addEventListener('abort', () => {\n cleanup();\n queue.push({ done: true });\n resolve?.();\n }, { once: true });\n }\n\n try {\n let fullText = '';\n\n while (true) {\n if (queue.length === 0) {\n await new Promise<void>((r) => { resolve = r; });\n resolve = null;\n }\n\n const item = queue.shift();\n if (!item || item.done) break;\n\n const evt = item.event;\n\n switch (evt.type) {\n case 'CHAT_STREAM_START':\n // No CompletionEvent for start — just skip\n break;\n\n case 'CHAT_STREAM_DELTA':\n fullText += evt.delta;\n yield { type: 'text_delta', text: evt.delta };\n break;\n\n case 'CHAT_STREAM_DONE':\n yield { type: 'done', answer: fullText };\n cleanup();\n return;\n\n case 'CHAT_STREAM_ERROR':\n yield { type: 'error', message: evt.error };\n cleanup();\n return;\n }\n }\n } finally {\n cleanup();\n }\n }\n\n // ── Delegated to inner HTTP session ───────────────────────────────────────\n\n state(): SessionState { return this.#inner.state(); }\n setModel(model: string): Promise<void> { return this.#inner.setModel(model); }\n status(signal?: AbortSignal): Promise<DocumentStatus> { return this.#inner.status(signal); }\n wait(options?: WaitOptions): Promise<DocumentStatus> { return this.#inner.wait(options); }\n pages(options?: { range?: string; signal?: AbortSignal }): Promise<Page[]> { return this.#inner.pages(options); }\n page(pageNumber: number, signal?: AbortSignal): Promise<Page> { return this.#inner.page(pageNumber, signal); }\n entities(options?: { type?: string; limit?: number; offset?: number; signal?: AbortSignal }): Promise<EntitiesResponse> { return this.#inner.entities(options); }\n downloadUrl(): string { return this.#inner.downloadUrl(); }\n query(sql: string, signal?: AbortSignal): Promise<QueryResult> { return this.#inner.query(sql, signal); }\n logs(options?: import('./types').LogsOptions): Promise<import('./types').LogEntry[]> { return this.#inner.logs(options); }\n publish(signal?: AbortSignal): Promise<PublishResult> { return this.#inner.publish(signal); }\n shareLink(options?: ShareLinkOptions): Promise<ShareLinkResult> { return this.#inner.shareLink(options); }\n\n prompt(query: string, options?: GenerateOptions & { schema?: undefined }): Promise<GenerateResult>;\n prompt<T>(query: string, options: GenerateOptions & { schema: StructuredSchema<T> }): Promise<GenerateResult<T>>;\n prompt<T = undefined>(query: string, options?: GenerateOptions): Promise<GenerateResult<T>> {\n if (options?.schema !== undefined) {\n return this.#inner.prompt(query, options as GenerateOptions & { schema: StructuredSchema<unknown> }) as Promise<GenerateResult<T>>;\n }\n return this.#inner.prompt(query, options as GenerateOptions & { schema?: undefined }) as Promise<GenerateResult<T>>;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/ws-session.ts"],"sourcesContent":["/**\n * WsSession — OkraSession adapter that routes `stream()` over an existing\n * WebSocket connection instead of HTTP SSE.\n *\n * All non-streaming methods delegate to the inner HTTP-backed session.\n * Only `stream()` is overridden to send CHAT_COMPLETION over WS and yield\n * CompletionEvents from CHAT_STREAM_* responses.\n *\n * Usage:\n * const wsSession = new WsSession(httpSession, { send, subscribe });\n * const chat = useChat({ session: wsSession });\n */\n\nimport type {\n OkraSession,\n CompletionEvent,\n CompletionOptions,\n DocumentStatus,\n WaitOptions,\n Page,\n EntitiesResponse,\n QueryResult,\n PublishResult,\n ShareLinkOptions,\n ShareLinkResult,\n GenerateOptions,\n GenerateResult,\n SessionState,\n StructuredSchema,\n} from './types';\n\n// Chat stream event types — mirrors @okrapdf/schemas ChatStreamServerEvent\n// Inlined to avoid adding @okrapdf/schemas as a dependency of the published SDK.\n\nexport type ChatStreamServerEvent =\n | { type: 'CHAT_STREAM_START'; requestId: string }\n | { type: 'CHAT_STREAM_DELTA'; requestId: string; delta: string }\n | { type: 'CHAT_STREAM_DONE'; requestId: string; usage?: { inputTokens: number; outputTokens: number; costUsd: number }; model?: string }\n | { type: 'CHAT_STREAM_ERROR'; requestId: string; error: string };\n\n/** Function that sends a JSON string over the WebSocket. Returns false if WS is closed. */\nexport type WsSendFn = (message: string) => boolean;\n\n/** Subscribe to chat stream events. Returns unsubscribe function. */\nexport type WsSubscribeFn = (\n requestId: string,\n handler: (event: ChatStreamServerEvent) => void,\n) => () => void;\n\nexport interface WsSessionOptions {\n /** Send JSON string over the existing WebSocket connection */\n send: WsSendFn;\n /** Subscribe to CHAT_STREAM_* events for a given requestId */\n subscribe: WsSubscribeFn;\n}\n\nfunction uuid(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nexport class WsSession implements OkraSession {\n readonly id: string;\n readonly modelEndpoint: string;\n readonly model?: string;\n\n #inner: OkraSession;\n #opts: WsSessionOptions;\n\n constructor(inner: OkraSession, opts: WsSessionOptions) {\n this.#inner = inner;\n this.#opts = opts;\n this.id = inner.id;\n this.modelEndpoint = inner.modelEndpoint;\n this.model = inner.model;\n }\n\n // ── Overridden: stream via WebSocket ──────────────────────────────────────\n\n async *stream(\n query: string,\n options?: CompletionOptions,\n ): AsyncGenerator<CompletionEvent> {\n const requestId = uuid();\n\n // Build message history (single user message for now — matches HTTP path)\n const messages = [{ role: 'user', content: query }];\n\n const sent = this.#opts.send(JSON.stringify({\n type: 'CHAT_COMPLETION',\n requestId,\n messages,\n }));\n\n if (!sent) {\n yield { type: 'error', message: 'WebSocket not connected' };\n return;\n }\n\n // Create a promise-based event queue\n type QueueItem =\n | { done: false; event: ChatStreamServerEvent }\n | { done: true };\n\n const queue: QueueItem[] = [];\n let resolve: (() => void) | null = null;\n let finished = false;\n\n const unsubscribe = this.#opts.subscribe(requestId, (event) => {\n if (finished) return;\n queue.push({ done: false, event });\n resolve?.();\n });\n\n const cleanup = () => {\n finished = true;\n unsubscribe();\n };\n\n // Handle abort signal\n if (options?.signal) {\n options.signal.addEventListener('abort', () => {\n cleanup();\n queue.push({ done: true });\n resolve?.();\n }, { once: true });\n }\n\n try {\n let fullText = '';\n\n while (true) {\n if (queue.length === 0) {\n await new Promise<void>((r) => { resolve = r; });\n resolve = null;\n }\n\n const item = queue.shift();\n if (!item || item.done) break;\n\n const evt = item.event;\n\n switch (evt.type) {\n case 'CHAT_STREAM_START':\n // No CompletionEvent for start — just skip\n break;\n\n case 'CHAT_STREAM_DELTA':\n fullText += evt.delta;\n yield { type: 'text_delta', text: evt.delta };\n break;\n\n case 'CHAT_STREAM_DONE':\n yield { type: 'done', answer: fullText };\n cleanup();\n return;\n\n case 'CHAT_STREAM_ERROR':\n yield { type: 'error', message: evt.error };\n cleanup();\n return;\n }\n }\n } finally {\n cleanup();\n }\n }\n\n // ── Delegated to inner HTTP session ───────────────────────────────────────\n\n state(): SessionState { return this.#inner.state(); }\n setModel(model: string): Promise<void> { return this.#inner.setModel(model); }\n status(signal?: AbortSignal): Promise<DocumentStatus> { return this.#inner.status(signal); }\n wait(options?: WaitOptions): Promise<DocumentStatus> { return this.#inner.wait(options); }\n pages(options?: { range?: string; signal?: AbortSignal }): Promise<Page[]> { return this.#inner.pages(options); }\n page(pageNumber: number, signal?: AbortSignal): Promise<Page> { return this.#inner.page(pageNumber, signal); }\n entities(options?: { type?: string; limit?: number; offset?: number; signal?: AbortSignal }): Promise<EntitiesResponse> { return this.#inner.entities(options); }\n downloadUrl(): string { return this.#inner.downloadUrl(); }\n query(sql: string, signal?: AbortSignal): Promise<QueryResult> { return this.#inner.query(sql, signal); }\n logs(options?: import('./types').LogsOptions): Promise<import('./types').LogEntry[]> { return this.#inner.logs(options); }\n publish(signal?: AbortSignal): Promise<PublishResult> { return this.#inner.publish(signal); }\n shareLink(options?: ShareLinkOptions): Promise<ShareLinkResult> { return this.#inner.shareLink(options); }\n\n prompt(query: string, options?: GenerateOptions & { schema?: undefined }): Promise<GenerateResult>;\n prompt<T>(query: string, options: GenerateOptions & { schema: StructuredSchema<T> }): Promise<GenerateResult<T>>;\n prompt<T = undefined>(query: string, options?: GenerateOptions): Promise<GenerateResult<T>> {\n if (options?.schema !== undefined) {\n return this.#inner.prompt(query, options as GenerateOptions & { schema: StructuredSchema<unknown> }) as Promise<GenerateResult<T>>;\n }\n return this.#inner.prompt(query, options as GenerateOptions & { schema?: undefined }) as Promise<GenerateResult<T>>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,SAAS,OAAe;AACtB,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,OAAO,WAAW;AAAA,EAC3B;AACA,SAAO,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACjE;AAEO,IAAM,YAAN,MAAuC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EAET;AAAA,EACA;AAAA,EAEA,YAAY,OAAoB,MAAwB;AACtD,SAAK,SAAS;AACd,SAAK,QAAQ;AACb,SAAK,KAAK,MAAM;AAChB,SAAK,gBAAgB,MAAM;AAC3B,SAAK,QAAQ,MAAM;AAAA,EACrB;AAAA;AAAA,EAIA,OAAO,OACL,OACA,SACiC;AACjC,UAAM,YAAY,KAAK;AAGvB,UAAM,WAAW,CAAC,EAAE,MAAM,QAAQ,SAAS,MAAM,CAAC;AAElD,UAAM,OAAO,KAAK,MAAM,KAAK,KAAK,UAAU;AAAA,MAC1C,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF,CAAC,CAAC;AAEF,QAAI,CAAC,MAAM;AACT,YAAM,EAAE,MAAM,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AS,OAA8B;AAAE,WAAO,KAAK,OAAO,SAAS,KAAK;AAAA,EAAG;AAAA,EAC7E,OAAO,QAA+C;AAAE,WAAO,KAAK,OAAO,OAAO,MAAM;AAAA,EAAG;AAAA,EAC3F,KAAK,SAAgD;AAAE,WAAO,KAAK,OAAO,KAAK,OAAO;AAAA,EAAG;AAAA,EACzF,MAAM,SAAqE;AAAE,WAAO,KAAK,OAAO,MAAM,OAAO;AAAA,EAAG;AAAA,EAChH,KAAK,YAAoB,QAAqC;AAAE,WAAO,KAAK,OAAO,KAAK,YAAY,MAAM;AAAA,EAAG;AAAA,EAC7G,SAAS,SAA+G;AAAE,WAAO,KAAK,OAAO,SAAS,OAAO;AAAA,EAAG;AAAA,EAChK,cAAsB;AAAE,WAAO,KAAK,OAAO,YAAY;AAAA,EAAG;AAAA,EAC1D,MAAM,KAAa,QAA4C;AAAE,WAAO,KAAK,OAAO,MAAM,KAAK,MAAM;AAAA,EAAG;AAAA,EACxG,KAAK,SAAgF;AAAE,WAAO,KAAK,OAAO,KAAK,OAAO;AAAA,EAAG;AAAA,EACzH,QAAQ,QAA8C;AAAE,WAAO,KAAK,OAAO,QAAQ,MAAM;AAAA,EAAG;AAAA,EAC5F,UAAU,SAAsD;AAAE,WAAO,KAAK,OAAO,UAAU,OAAO;AAAA,EAAG;AAAA,EAIzG,OAAsB,OAAe,SAAuD;AAC1F,QAAI,SAAS,WAAW,QAAW;AACjC,aAAO,KAAK,OAAO,OAAO,OAAO,OAAkE;AAAA,IACrG;AACA,WAAO,KAAK,OAAO,OAAO,OAAO,OAAmD;AAAA,EACtF;AACF;","names":[]}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { O as OkraClient } from '../client-
|
|
3
|
-
import { O as OkraSession,
|
|
4
|
-
export {
|
|
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';
|
|
5
5
|
import 'zod';
|
|
6
6
|
|
|
7
7
|
interface OkraContextValue {
|