@manfred-kunze-dev/backbone-cli 2.6.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +19 -0
  2. package/dist/commands/ai.d.ts +3 -0
  3. package/dist/commands/ai.js +72 -0
  4. package/dist/commands/analytics.d.ts +3 -0
  5. package/dist/commands/analytics.js +120 -0
  6. package/dist/commands/auth.d.ts +3 -0
  7. package/dist/commands/auth.js +115 -0
  8. package/dist/commands/billing.d.ts +3 -0
  9. package/dist/commands/billing.js +100 -0
  10. package/dist/commands/config.d.ts +3 -0
  11. package/dist/commands/config.js +70 -0
  12. package/dist/commands/convert.d.ts +3 -0
  13. package/dist/commands/convert.js +123 -0
  14. package/dist/commands/extractions.d.ts +3 -0
  15. package/dist/commands/extractions.js +143 -0
  16. package/dist/commands/projects.d.ts +3 -0
  17. package/dist/commands/projects.js +83 -0
  18. package/dist/commands/prompt-labels.d.ts +3 -0
  19. package/dist/commands/prompt-labels.js +72 -0
  20. package/dist/commands/prompt-versions.d.ts +3 -0
  21. package/dist/commands/prompt-versions.js +70 -0
  22. package/dist/commands/prompts.d.ts +3 -0
  23. package/dist/commands/prompts.js +170 -0
  24. package/dist/commands/providers.d.ts +3 -0
  25. package/dist/commands/providers.js +115 -0
  26. package/dist/commands/schema-labels.d.ts +3 -0
  27. package/dist/commands/schema-labels.js +72 -0
  28. package/dist/commands/schema-versions.d.ts +3 -0
  29. package/dist/commands/schema-versions.js +71 -0
  30. package/dist/commands/schemas.d.ts +3 -0
  31. package/dist/commands/schemas.js +168 -0
  32. package/dist/commands/transcribe.d.ts +3 -0
  33. package/dist/commands/transcribe.js +65 -0
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.js +38 -0
  36. package/dist/lib/client.d.ts +12 -0
  37. package/dist/lib/client.js +52 -0
  38. package/dist/lib/config.d.ts +20 -0
  39. package/dist/lib/config.js +68 -0
  40. package/dist/lib/context.d.ts +7 -0
  41. package/dist/lib/context.js +14 -0
  42. package/dist/lib/errors.d.ts +14 -0
  43. package/dist/lib/errors.js +53 -0
  44. package/dist/lib/multipart.d.ts +10 -0
  45. package/dist/lib/multipart.js +57 -0
  46. package/dist/lib/output.d.ts +29 -0
  47. package/dist/lib/output.js +107 -0
  48. package/dist/lib/pagination.d.ts +21 -0
  49. package/dist/lib/pagination.js +21 -0
  50. package/package.json +52 -0
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2025-present Manfred Kunze Dev
2
+
3
+ All rights reserved.
4
+
5
+ This software and associated documentation files (the "Software") are proprietary
6
+ and confidential. No part of the Software may be reproduced, distributed, or
7
+ transmitted in any form or by any means, including photocopying, recording, or
8
+ other electronic or mechanical methods, without the prior written permission of
9
+ the copyright holder.
10
+
11
+ The Software is provided "as is", without warranty of any kind, express or implied,
12
+ including but not limited to the warranties of merchantability, fitness for a
13
+ particular purpose, and noninfringement. In no event shall the authors or copyright
14
+ holders be liable for any claim, damages, or other liability, whether in an action
15
+ of contract, tort, or otherwise, arising from, out of, or in connection with the
16
+ Software or the use or other dealings in the Software.
17
+
18
+ Usage of this Software is permitted only in accordance with the terms and conditions
19
+ set forth by Manfred Kunze Dev.
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeAiCommand(): Command;
3
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1,72 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { isJsonOutput } from "../lib/config.js";
4
+ import { formatList, withSpinner } from "../lib/output.js";
5
+ import chalk from "chalk";
6
+ export function makeAiCommand() {
7
+ const cmd = new Command("ai").description("AI gateway operations");
8
+ cmd
9
+ .command("chat")
10
+ .description("Send a chat completion request")
11
+ .requiredOption("-m, --model <model>", "Model (provider/model format)")
12
+ .requiredOption("--message <text>", "User message")
13
+ .option("--system <text>", "System message")
14
+ .option("--temperature <n>", "Temperature (0-2)")
15
+ .option("--max-tokens <n>", "Max tokens")
16
+ .option("--top-p <n>", "Top-p sampling")
17
+ .action(async (opts, command) => {
18
+ await runAction(command, async () => {
19
+ const client = getClient(command);
20
+ const messages = [];
21
+ if (opts.system) {
22
+ messages.push({ role: "system", content: opts.system });
23
+ }
24
+ messages.push({ role: "user", content: opts.message });
25
+ const body = {
26
+ model: opts.model,
27
+ messages,
28
+ stream: false,
29
+ temperature: opts.temperature ? parseFloat(opts.temperature) : undefined,
30
+ max_tokens: opts.maxTokens ? parseInt(opts.maxTokens, 10) : undefined,
31
+ top_p: opts.topP ? parseFloat(opts.topP) : undefined,
32
+ };
33
+ const { data } = await withSpinner("Thinking...", () => client.POST("/v1/chat/completions", { body }));
34
+ // Response type is untyped in OpenAPI spec (OpenAI-compatible format)
35
+ const result = data;
36
+ const json = isJsonOutput(command);
37
+ if (json) {
38
+ console.log(JSON.stringify(result, null, 2));
39
+ }
40
+ else {
41
+ const choices = result?.choices;
42
+ const content = choices?.[0]?.message?.content;
43
+ if (content) {
44
+ console.log(content);
45
+ }
46
+ const usage = result?.usage;
47
+ if (usage) {
48
+ console.log(chalk.dim(`\n[${result?.model} | ${usage.prompt_tokens} in / ${usage.completion_tokens} out / ${usage.total_tokens} total tokens]`));
49
+ }
50
+ }
51
+ });
52
+ });
53
+ cmd
54
+ .command("models")
55
+ .description("List available AI models")
56
+ .action(async (_opts, command) => {
57
+ await runAction(command, async () => {
58
+ const client = getClient(command);
59
+ const { data } = await client.GET("/v1/models");
60
+ const json = isJsonOutput(command);
61
+ if (json) {
62
+ console.log(JSON.stringify(data, null, 2));
63
+ }
64
+ else {
65
+ const models = data?.data ?? [];
66
+ formatList(models, command, ["id", "owned_by"]);
67
+ }
68
+ });
69
+ });
70
+ return cmd;
71
+ }
72
+ //# sourceMappingURL=ai.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeAnalyticsCommand(): Command;
3
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1,120 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { requireProjectId } from "../lib/context.js";
4
+ import { formatDetail, formatList } from "../lib/output.js";
5
+ function addDateOptions(cmd) {
6
+ return cmd
7
+ .option("--start <date>", "Start date (YYYY-MM-DD)")
8
+ .option("--end <date>", "End date (YYYY-MM-DD)");
9
+ }
10
+ export function makeAnalyticsCommand() {
11
+ const cmd = new Command("analytics").description("Project analytics");
12
+ const summary = new Command("summary").description("Get summary analytics");
13
+ addDateOptions(summary);
14
+ summary.action(async (opts, command) => {
15
+ await runAction(command, async () => {
16
+ const projectId = requireProjectId(command);
17
+ const client = getClient(command);
18
+ const { data } = await client.GET("/v1/projects/{projectId}/analytics/summary", {
19
+ params: {
20
+ path: { projectId },
21
+ query: { startDate: opts.start, endDate: opts.end },
22
+ },
23
+ });
24
+ formatDetail(data, command);
25
+ });
26
+ });
27
+ cmd.addCommand(summary);
28
+ const timeSeries = new Command("time-series").description("Get time-series data");
29
+ addDateOptions(timeSeries);
30
+ timeSeries.option("--group-by <interval>", "Group by: day, week, month", "day");
31
+ timeSeries.action(async (opts, command) => {
32
+ await runAction(command, async () => {
33
+ const projectId = requireProjectId(command);
34
+ const client = getClient(command);
35
+ const { data } = await client.GET("/v1/projects/{projectId}/analytics/time-series", {
36
+ params: {
37
+ path: { projectId },
38
+ query: {
39
+ startDate: opts.start,
40
+ endDate: opts.end,
41
+ groupBy: opts.groupBy,
42
+ },
43
+ },
44
+ });
45
+ formatList(data, command, ["date", "count", "successCount", "failedCount", "totalTokens"]);
46
+ });
47
+ });
48
+ cmd.addCommand(timeSeries);
49
+ const schemas = new Command("schemas").description("Schema usage statistics");
50
+ addDateOptions(schemas);
51
+ schemas.option("--limit <n>", "Max results", "10");
52
+ schemas.action(async (opts, command) => {
53
+ await runAction(command, async () => {
54
+ const projectId = requireProjectId(command);
55
+ const client = getClient(command);
56
+ const { data } = await client.GET("/v1/projects/{projectId}/analytics/schemas", {
57
+ params: {
58
+ path: { projectId },
59
+ query: {
60
+ startDate: opts.start,
61
+ endDate: opts.end,
62
+ limit: parseInt(opts.limit, 10),
63
+ },
64
+ },
65
+ });
66
+ formatList(data, command, ["schemaId", "schemaName", "extractionCount", "successCount", "totalTokens", "averageDurationMs"]);
67
+ });
68
+ });
69
+ cmd.addCommand(schemas);
70
+ const providers = new Command("providers").description("Provider usage statistics");
71
+ addDateOptions(providers);
72
+ providers.action(async (opts, command) => {
73
+ await runAction(command, async () => {
74
+ const projectId = requireProjectId(command);
75
+ const client = getClient(command);
76
+ const { data } = await client.GET("/v1/projects/{projectId}/analytics/providers", {
77
+ params: {
78
+ path: { projectId },
79
+ query: { startDate: opts.start, endDate: opts.end },
80
+ },
81
+ });
82
+ formatList(data, command, ["provider", "model", "extractionCount", "successCount", "totalTokens", "averageDurationMs"]);
83
+ });
84
+ });
85
+ cmd.addCommand(providers);
86
+ const errors = new Command("errors").description("Error statistics");
87
+ addDateOptions(errors);
88
+ errors.option("--limit <n>", "Max results", "10");
89
+ errors.action(async (opts, command) => {
90
+ await runAction(command, async () => {
91
+ const projectId = requireProjectId(command);
92
+ const client = getClient(command);
93
+ const { data } = await client.GET("/v1/projects/{projectId}/analytics/errors", {
94
+ params: {
95
+ path: { projectId },
96
+ query: {
97
+ startDate: opts.start,
98
+ endDate: opts.end,
99
+ limit: parseInt(opts.limit, 10),
100
+ },
101
+ },
102
+ });
103
+ formatList(data, command, ["errorType", "message", "count", "lastOccurrence"]);
104
+ });
105
+ });
106
+ cmd.addCommand(errors);
107
+ cmd
108
+ .command("status")
109
+ .description("Extraction status distribution")
110
+ .action(async (_opts, command) => {
111
+ await runAction(command, async () => {
112
+ const projectId = requireProjectId(command);
113
+ const client = getClient(command);
114
+ const { data } = await client.GET("/v1/projects/{projectId}/analytics/status-distribution", { params: { path: { projectId } } });
115
+ formatDetail(data, command);
116
+ });
117
+ });
118
+ return cmd;
119
+ }
120
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeAuthCommand(): Command;
3
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1,115 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { store, resolveConfig } from "../lib/config.js";
4
+ import { getClient, runAction } from "../lib/client.js";
5
+ import { isJsonOutput } from "../lib/config.js";
6
+ import { createInterface } from "node:readline/promises";
7
+ export function makeAuthCommand() {
8
+ const cmd = new Command("auth").description("Manage authentication");
9
+ cmd
10
+ .command("login")
11
+ .description("Configure API credentials")
12
+ .option("--api-key <key>", "API key")
13
+ .option("--base-url <url>", "Base URL")
14
+ .action(async (opts) => {
15
+ let apiKey = opts.apiKey;
16
+ let baseUrl = opts.baseUrl;
17
+ if (!apiKey || !baseUrl) {
18
+ const rl = createInterface({
19
+ input: process.stdin,
20
+ output: process.stdout,
21
+ });
22
+ try {
23
+ if (!baseUrl) {
24
+ baseUrl = await rl.question(`Base URL [${store.get("baseUrl") ?? "https://backbone.manfred-kunze.dev/api"}]: `);
25
+ if (!baseUrl)
26
+ baseUrl = store.get("baseUrl") ?? "https://backbone.manfred-kunze.dev/api";
27
+ }
28
+ if (!apiKey) {
29
+ apiKey = await rl.question("API Key (sk_...): ");
30
+ }
31
+ }
32
+ finally {
33
+ rl.close();
34
+ }
35
+ }
36
+ if (!apiKey) {
37
+ console.error(chalk.red("API key is required."));
38
+ process.exit(1);
39
+ }
40
+ store.set("apiKey", apiKey);
41
+ store.set("baseUrl", baseUrl);
42
+ console.log(chalk.green("Credentials saved successfully."));
43
+ console.log(chalk.dim(`Config stored at: ${store.path}`));
44
+ });
45
+ cmd
46
+ .command("logout")
47
+ .description("Clear stored credentials")
48
+ .action(() => {
49
+ store.delete("apiKey");
50
+ store.delete("baseUrl");
51
+ store.delete("project");
52
+ console.log(chalk.green("Credentials cleared."));
53
+ });
54
+ cmd
55
+ .command("status")
56
+ .description("Show current authentication status")
57
+ .action(async (_opts, command) => {
58
+ await runAction(command, async () => {
59
+ const json = isJsonOutput(command);
60
+ let config;
61
+ try {
62
+ config = resolveConfig(command);
63
+ }
64
+ catch {
65
+ if (json) {
66
+ console.log(JSON.stringify({ authenticated: false }));
67
+ }
68
+ else {
69
+ console.log(chalk.yellow("Not authenticated."));
70
+ console.log(chalk.dim('Run "backbone auth login" to configure.'));
71
+ }
72
+ return;
73
+ }
74
+ const { apiKey, baseUrl } = config;
75
+ const keyPreview = apiKey.slice(0, 7) + "..." + apiKey.slice(-4);
76
+ // Try to validate by listing models (lightweight call)
77
+ try {
78
+ const client = getClient(command);
79
+ const { data } = await client.GET("/v1/models");
80
+ const modelCount = data?.data?.length ?? 0;
81
+ if (json) {
82
+ console.log(JSON.stringify({
83
+ authenticated: true,
84
+ baseUrl,
85
+ apiKeyPreview: keyPreview,
86
+ modelCount,
87
+ }));
88
+ }
89
+ else {
90
+ console.log(chalk.green("Authenticated"));
91
+ console.log(` Base URL: ${baseUrl}`);
92
+ console.log(` API Key: ${keyPreview}`);
93
+ console.log(` Models: ${modelCount} available`);
94
+ }
95
+ }
96
+ catch {
97
+ if (json) {
98
+ console.log(JSON.stringify({
99
+ authenticated: false,
100
+ baseUrl,
101
+ apiKeyPreview: keyPreview,
102
+ error: "Failed to validate credentials",
103
+ }));
104
+ }
105
+ else {
106
+ console.log(chalk.yellow("Credentials configured but validation failed."));
107
+ console.log(` Base URL: ${baseUrl}`);
108
+ console.log(` API Key: ${keyPreview}`);
109
+ }
110
+ }
111
+ });
112
+ });
113
+ return cmd;
114
+ }
115
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeBillingCommand(): Command;
3
+ //# sourceMappingURL=billing.d.ts.map
@@ -0,0 +1,100 @@
1
+ import { Command } from "commander";
2
+ import { getClient, runAction } from "../lib/client.js";
3
+ import { isJsonOutput } from "../lib/config.js";
4
+ import { formatDetail, formatList } from "../lib/output.js";
5
+ import chalk from "chalk";
6
+ export function makeBillingCommand() {
7
+ const cmd = new Command("billing").description("Billing and subscription management");
8
+ cmd
9
+ .command("tiers")
10
+ .description("List available subscription tiers")
11
+ .action(async (_opts, command) => {
12
+ await runAction(command, async () => {
13
+ const client = getClient(command);
14
+ const { data } = await client.GET("/v1/billing/tiers");
15
+ formatList(data, command, ["name", "displayName", "maxProjects", "maxSchemas", "monthlyExtractionCredits", "monthlyGatewayTokens"]);
16
+ });
17
+ });
18
+ cmd
19
+ .command("tier")
20
+ .description("Show current organization tier")
21
+ .action(async (_opts, command) => {
22
+ await runAction(command, async () => {
23
+ const client = getClient(command);
24
+ const { data } = await client.GET("/v1/billing/tier");
25
+ formatDetail(data, command);
26
+ });
27
+ });
28
+ cmd
29
+ .command("limits")
30
+ .description("Show current usage and limits")
31
+ .action(async (_opts, command) => {
32
+ await runAction(command, async () => {
33
+ const client = getClient(command);
34
+ const { data } = await client.GET("/v1/billing/limits");
35
+ if (isJsonOutput(command)) {
36
+ console.log(JSON.stringify(data, null, 2));
37
+ }
38
+ else {
39
+ console.log(chalk.cyan(`Tier: ${data?.tier ?? "unknown"}`));
40
+ console.log();
41
+ if (data?.resources?.length) {
42
+ console.log(chalk.bold("Resources:"));
43
+ for (const r of data.resources) {
44
+ const label = r.displayName ?? r.resourceType;
45
+ const bar = r.limit === -1
46
+ ? chalk.green("unlimited")
47
+ : `${r.used ?? 0} / ${r.limit ?? 0} (${r.remaining ?? 0} remaining)`;
48
+ console.log(` ${chalk.bold(String(label))}: ${bar}`);
49
+ }
50
+ console.log();
51
+ }
52
+ console.log(chalk.bold("Usage:"));
53
+ console.log(` Projects: ${data?.currentProjects ?? 0} / ${data?.maxProjects ?? 0}`);
54
+ console.log(` Schemas: ${data?.currentSchemas ?? 0} / ${data?.maxSchemas ?? 0}`);
55
+ console.log(` Prompts: ${data?.currentPrompts ?? 0} / ${data?.maxPrompts ?? 0}`);
56
+ console.log(` Team members: ${data?.currentTeamMembers ?? 0} / ${data?.maxTeamMembers ?? 0}`);
57
+ console.log();
58
+ console.log(chalk.bold("Features:"));
59
+ console.log(` BYOK: ${data?.byokEnabled ? chalk.green("yes") : chalk.dim("no")}`);
60
+ console.log(` Priority support: ${data?.prioritySupport ? chalk.green("yes") : chalk.dim("no")}`);
61
+ if (data?.periodStart || data?.periodEnd) {
62
+ console.log();
63
+ console.log(chalk.dim(`Period: ${data.periodStart?.slice(0, 10) ?? "?"} \u2192 ${data.periodEnd?.slice(0, 10) ?? "?"}`));
64
+ }
65
+ }
66
+ });
67
+ });
68
+ cmd
69
+ .command("check")
70
+ .description("Check if a resource can be created")
71
+ .argument("<resource>", "Resource type: project, schema, prompt, team-member")
72
+ .action(async (resource, _opts, command) => {
73
+ await runAction(command, async () => {
74
+ const client = getClient(command);
75
+ const endpoints = {
76
+ project: "/v1/billing/can-create-project",
77
+ schema: "/v1/billing/can-create-schema",
78
+ prompt: "/v1/billing/can-create-prompt",
79
+ "team-member": "/v1/billing/can-add-team-member",
80
+ };
81
+ const endpoint = endpoints[resource];
82
+ if (!endpoint) {
83
+ throw new Error(`Unknown resource: "${resource}". Use: project, schema, prompt, team-member`);
84
+ }
85
+ const { data } = await client.GET(endpoint);
86
+ const result = data?.result;
87
+ if (isJsonOutput(command)) {
88
+ console.log(JSON.stringify({ resource, canCreate: result }));
89
+ }
90
+ else if (result) {
91
+ console.log(chalk.green(`You can create a new ${resource}.`));
92
+ }
93
+ else {
94
+ console.log(chalk.yellow(`You cannot create a new ${resource}. Upgrade your tier or check limits.`));
95
+ }
96
+ });
97
+ });
98
+ return cmd;
99
+ }
100
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeConfigCommand(): Command;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,70 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { store, isJsonOutput } from "../lib/config.js";
4
+ const ALLOWED_KEYS = ["apiKey", "baseUrl", "project"];
5
+ function validateKey(key) {
6
+ if (!ALLOWED_KEYS.includes(key)) {
7
+ throw new Error(`Unknown config key: "${key}". Allowed keys: ${ALLOWED_KEYS.join(", ")}`);
8
+ }
9
+ return key;
10
+ }
11
+ export function makeConfigCommand() {
12
+ const cmd = new Command("config").description("Manage CLI configuration");
13
+ cmd
14
+ .command("set")
15
+ .description("Set a configuration value")
16
+ .argument("<key>", `Config key (${ALLOWED_KEYS.join(", ")})`)
17
+ .argument("<value>", "Config value")
18
+ .action((key, value, _opts, command) => {
19
+ const validKey = validateKey(key);
20
+ store.set(validKey, value);
21
+ if (isJsonOutput(command)) {
22
+ console.log(JSON.stringify({ key: validKey, value }));
23
+ }
24
+ else {
25
+ console.log(chalk.green(`Set ${validKey} = ${validKey === "apiKey" ? "****" : value}`));
26
+ }
27
+ });
28
+ cmd
29
+ .command("get")
30
+ .description("Get a configuration value")
31
+ .argument("<key>", `Config key (${ALLOWED_KEYS.join(", ")})`)
32
+ .action((key, _opts, command) => {
33
+ const validKey = validateKey(key);
34
+ const value = store.get(validKey);
35
+ if (isJsonOutput(command)) {
36
+ console.log(JSON.stringify({ key: validKey, value: value ?? null }));
37
+ }
38
+ else if (value) {
39
+ console.log(validKey === "apiKey" ? "****" : value);
40
+ }
41
+ else {
42
+ console.log(chalk.dim("(not set)"));
43
+ }
44
+ });
45
+ cmd
46
+ .command("list")
47
+ .description("Show all configuration values")
48
+ .action((_opts, command) => {
49
+ const values = {};
50
+ for (const key of ALLOWED_KEYS) {
51
+ values[key] = store.get(key);
52
+ }
53
+ if (isJsonOutput(command)) {
54
+ console.log(JSON.stringify(values, null, 2));
55
+ }
56
+ else {
57
+ for (const [key, value] of Object.entries(values)) {
58
+ const display = !value
59
+ ? chalk.dim("(not set)")
60
+ : key === "apiKey"
61
+ ? value.slice(0, 7) + "..." + value.slice(-4)
62
+ : value;
63
+ console.log(`${chalk.cyan(key)}: ${display}`);
64
+ }
65
+ console.log(chalk.dim(`\nConfig file: ${store.path}`));
66
+ }
67
+ });
68
+ return cmd;
69
+ }
70
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeConvertCommand(): Command;
3
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1,123 @@
1
+ import { Command } from "commander";
2
+ import { readFileSync } from "node:fs";
3
+ import { basename } from "node:path";
4
+ import { getClient, runAction } from "../lib/client.js";
5
+ import { formatDetail, withSpinner } from "../lib/output.js";
6
+ import { getMimeType } from "../lib/multipart.js";
7
+ function mapFormat(format) {
8
+ const map = {
9
+ markdown: "MD",
10
+ md: "MD",
11
+ text: "TEXT",
12
+ txt: "TEXT",
13
+ json: "JSON",
14
+ html: "HTML",
15
+ };
16
+ return map[format.toLowerCase()] ?? format.toUpperCase();
17
+ }
18
+ export function makeConvertCommand() {
19
+ const cmd = new Command("convert").description("Convert documents");
20
+ cmd
21
+ .command("file")
22
+ .description("Convert local files")
23
+ .argument("<paths...>", "File paths to convert")
24
+ .option("--format <formats...>", "Output formats (md, text, html, json)", ["md"])
25
+ .option("--pipeline <name>", "Pipeline (standard, vlm)")
26
+ .option("--async", "Run asynchronously")
27
+ .action(async (paths, opts, command) => {
28
+ await runAction(command, async () => {
29
+ const client = getClient(command);
30
+ // Build base64 sources from local files
31
+ const sources = paths.map((p) => {
32
+ const buffer = readFileSync(p);
33
+ const filename = basename(p);
34
+ return {
35
+ kind: "Base64Source",
36
+ content: buffer.toString("base64"),
37
+ filename,
38
+ mimeType: getMimeType(filename),
39
+ };
40
+ });
41
+ const toFormats = opts.format.map(mapFormat);
42
+ const body = {
43
+ sources,
44
+ options: {
45
+ toFormats,
46
+ pipeline: opts.pipeline,
47
+ },
48
+ };
49
+ if (opts.async) {
50
+ const { data } = await withSpinner("Submitting conversion...", () => client.POST("/v1/convert/source/async", { body }));
51
+ formatDetail(data, command);
52
+ }
53
+ else {
54
+ const { data } = await withSpinner("Converting...", () => client.POST("/v1/convert/source", { body }));
55
+ formatDetail(data, command);
56
+ }
57
+ });
58
+ });
59
+ cmd
60
+ .command("url")
61
+ .description("Convert documents from URLs")
62
+ .argument("<urls...>", "URLs to convert")
63
+ .option("--format <formats...>", "Output formats (md, text, html, json)", ["md"])
64
+ .option("--pipeline <name>", "Pipeline (standard, vlm)")
65
+ .option("--async", "Run asynchronously")
66
+ .action(async (urls, opts, command) => {
67
+ await runAction(command, async () => {
68
+ const client = getClient(command);
69
+ const sources = urls.map((url) => ({
70
+ kind: "HttpSource",
71
+ url,
72
+ }));
73
+ const toFormats = opts.format.map(mapFormat);
74
+ const body = {
75
+ sources,
76
+ options: {
77
+ toFormats,
78
+ pipeline: opts.pipeline,
79
+ },
80
+ };
81
+ if (opts.async) {
82
+ const { data } = await withSpinner("Submitting conversion...", () => client.POST("/v1/convert/source/async", { body }));
83
+ formatDetail(data, command);
84
+ }
85
+ else {
86
+ const { data } = await withSpinner("Converting...", () => client.POST("/v1/convert/source", { body }));
87
+ formatDetail(data, command);
88
+ }
89
+ });
90
+ });
91
+ cmd
92
+ .command("status")
93
+ .description("Check async conversion task status")
94
+ .argument("<taskId>", "Task ID")
95
+ .option("-w, --wait", "Wait for completion")
96
+ .action(async (taskId, opts, command) => {
97
+ await runAction(command, async () => {
98
+ const client = getClient(command);
99
+ const { data } = await client.GET("/v1/convert/tasks/{taskId}", {
100
+ params: {
101
+ path: { taskId },
102
+ query: { wait: opts.wait },
103
+ },
104
+ });
105
+ formatDetail(data, command);
106
+ });
107
+ });
108
+ cmd
109
+ .command("result")
110
+ .description("Get async conversion task result")
111
+ .argument("<taskId>", "Task ID")
112
+ .action(async (taskId, _opts, command) => {
113
+ await runAction(command, async () => {
114
+ const client = getClient(command);
115
+ const { data } = await client.GET("/v1/convert/tasks/{taskId}/result", {
116
+ params: { path: { taskId } },
117
+ });
118
+ formatDetail(data, command);
119
+ });
120
+ });
121
+ return cmd;
122
+ }
123
+ //# sourceMappingURL=convert.js.map
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function makeExtractionsCommand(): Command;
3
+ //# sourceMappingURL=extractions.d.ts.map