@helm-ai/cli 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.js +108 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ Every resource follows the same shape — `list`, `get <id>`, `create`, `update
|
|
|
86
86
|
| `company`, `contact`, `deal`, `pipeline` | Customers: companies, people, and the sales pipeline |
|
|
87
87
|
| `invoice`, `estimate`, `product` | Money: billing documents and the product catalog |
|
|
88
88
|
| `doc` | Rich-text documents, folders, and pages |
|
|
89
|
+
| `file` | Uploaded files and saved links: `list`, and `read` for the extracted text (`--text`) or a download (`--save`) |
|
|
89
90
|
| `calendar` | Events and meetings |
|
|
90
91
|
| `form`, `sequence`, `email` | Capture and follow-up |
|
|
91
92
|
| `workflow`, `template` | Automations and reusable project structures |
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command4 } from "commander";
|
|
5
5
|
import kleur8 from "kleur";
|
|
6
6
|
|
|
7
7
|
// src/lib/branding.ts
|
|
@@ -25,7 +25,7 @@ function renderSplash(ctx) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// src/version.ts
|
|
28
|
-
var version = "1.
|
|
28
|
+
var version = "1.2.0";
|
|
29
29
|
|
|
30
30
|
// src/commands/auth.ts
|
|
31
31
|
import prompts from "prompts";
|
|
@@ -641,6 +641,22 @@ var HelmClient = class _HelmClient {
|
|
|
641
641
|
return data;
|
|
642
642
|
}
|
|
643
643
|
};
|
|
644
|
+
/** Uploaded files and saved links (Helm Files). Documents are `documents`. */
|
|
645
|
+
files = {
|
|
646
|
+
list: async (filters = {}) => {
|
|
647
|
+
const data = await this.request("list_files", "GET", filters);
|
|
648
|
+
return {
|
|
649
|
+
files: data.files ?? [],
|
|
650
|
+
total: data.total ?? null,
|
|
651
|
+
has_more: data.has_more === true
|
|
652
|
+
};
|
|
653
|
+
},
|
|
654
|
+
/** Extracted text when there is any, plus a download link valid for 5 minutes. */
|
|
655
|
+
read: async (fileId) => {
|
|
656
|
+
const data = await this.request("read_file", "GET", { file_id: fileId });
|
|
657
|
+
return data;
|
|
658
|
+
}
|
|
659
|
+
};
|
|
644
660
|
documents = {
|
|
645
661
|
list: async (filters = {}) => {
|
|
646
662
|
const data = await this.request("get_documents", "GET", filters);
|
|
@@ -1795,14 +1811,14 @@ function registerPipelineCommands(parent) {
|
|
|
1795
1811
|
cmd.command("create").description("Create a pipeline (seeds default stages unless --stage given)").requiredOption("-n, --name <name>", "pipeline name (required)").option("-d, --description <text>").option("--color <name>", "accent color name").option("--default", "make this the default pipeline").option("--stage <key:label>", "seed stage (repeatable), e.g. --stage trial:Trial", collectStage, []).option("-p, --profile <name>").action(async (opts) => {
|
|
1796
1812
|
try {
|
|
1797
1813
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1798
|
-
const
|
|
1814
|
+
const pipeline2 = await client.pipelines.create({
|
|
1799
1815
|
name: opts.name,
|
|
1800
1816
|
description: opts.description,
|
|
1801
1817
|
color: opts.color,
|
|
1802
1818
|
is_default: opts.default,
|
|
1803
1819
|
stages: opts.stage.length ? opts.stage : void 0
|
|
1804
1820
|
});
|
|
1805
|
-
console.log(JSON.stringify(
|
|
1821
|
+
console.log(JSON.stringify(pipeline2, null, 2));
|
|
1806
1822
|
} catch (err) {
|
|
1807
1823
|
console.error(formatErrorForCli(err));
|
|
1808
1824
|
process.exitCode = 1;
|
|
@@ -1812,14 +1828,14 @@ function registerPipelineCommands(parent) {
|
|
|
1812
1828
|
cmd.command("update <id>").description("Update a pipeline").option("-n, --name <name>").option("-d, --description <text>").option("--color <name>").option("--default", "make this the default pipeline").option("--position <n>", "order position", (v) => parseInt(v, 10)).option("-p, --profile <name>").action(async (id, opts) => {
|
|
1813
1829
|
try {
|
|
1814
1830
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1815
|
-
const
|
|
1831
|
+
const pipeline2 = await client.pipelines.update(id, {
|
|
1816
1832
|
name: opts.name,
|
|
1817
1833
|
description: opts.description,
|
|
1818
1834
|
color: opts.color,
|
|
1819
1835
|
is_default: opts.default,
|
|
1820
1836
|
position: opts.position
|
|
1821
1837
|
});
|
|
1822
|
-
console.log(JSON.stringify(
|
|
1838
|
+
console.log(JSON.stringify(pipeline2, null, 2));
|
|
1823
1839
|
} catch (err) {
|
|
1824
1840
|
console.error(formatErrorForCli(err));
|
|
1825
1841
|
process.exitCode = 1;
|
|
@@ -3714,6 +3730,90 @@ function registerDocCommands(parent) {
|
|
|
3714
3730
|
});
|
|
3715
3731
|
}
|
|
3716
3732
|
|
|
3733
|
+
// src/commands/file.ts
|
|
3734
|
+
import { InvalidArgumentError as InvalidArgumentError4 } from "commander";
|
|
3735
|
+
import { createWriteStream } from "fs";
|
|
3736
|
+
import { Readable } from "stream";
|
|
3737
|
+
import { pipeline } from "stream/promises";
|
|
3738
|
+
var KINDS = ["image", "pdf", "spreadsheet", "video", "link", "other"];
|
|
3739
|
+
function parseKind(value) {
|
|
3740
|
+
if (!KINDS.includes(value)) {
|
|
3741
|
+
throw new InvalidArgumentError4(`must be one of: ${KINDS.join(", ")}`);
|
|
3742
|
+
}
|
|
3743
|
+
return value;
|
|
3744
|
+
}
|
|
3745
|
+
function parseCount(value) {
|
|
3746
|
+
const n = Number(value);
|
|
3747
|
+
if (!Number.isInteger(n) || n < 1) throw new InvalidArgumentError4("must be a whole number, 1 or more");
|
|
3748
|
+
return n;
|
|
3749
|
+
}
|
|
3750
|
+
function formatSize(bytes) {
|
|
3751
|
+
if (typeof bytes !== "number" || bytes < 0) return "";
|
|
3752
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
3753
|
+
let n = bytes;
|
|
3754
|
+
let i = 0;
|
|
3755
|
+
while (n >= 1024 && i < units.length - 1) {
|
|
3756
|
+
n /= 1024;
|
|
3757
|
+
i++;
|
|
3758
|
+
}
|
|
3759
|
+
return i === 0 ? `${n} B` : `${n.toFixed(1)} ${units[i]}`;
|
|
3760
|
+
}
|
|
3761
|
+
function registerFileCommands(parent) {
|
|
3762
|
+
const cmd = parent.command("file").alias("files").description("Uploaded files and saved links (Helm Files)");
|
|
3763
|
+
cmd.command("list").description("List files, newest first").option("-q, --query <text>", "match part of the file name").option("-k, --kind <kind>", KINDS.join("|"), parseKind).option("--folder <id>", 'a folder id, or "root" for files in no folder').option("--company <id>", "files attached to this company").option("--project <id>", "files attached to this project").option("-l, --limit <n>", "max rows (up to 100)", parseCount, 25).option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
3764
|
+
try {
|
|
3765
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3766
|
+
const { files, total, has_more } = await client.files.list({
|
|
3767
|
+
query: opts.query,
|
|
3768
|
+
kind: opts.kind,
|
|
3769
|
+
folder_id: opts.folder,
|
|
3770
|
+
company_id: opts.company,
|
|
3771
|
+
project_id: opts.project,
|
|
3772
|
+
limit: opts.limit
|
|
3773
|
+
});
|
|
3774
|
+
console.log(render(files, [
|
|
3775
|
+
{ header: "Name", get: (r) => r.name, truncate: 40 },
|
|
3776
|
+
{ header: "Kind", get: (r) => r.kind },
|
|
3777
|
+
{ header: "Size", get: (r) => r.kind === "link" ? "" : formatSize(r.size_bytes) },
|
|
3778
|
+
{ header: "Folder", get: (r) => r.folder ?? "" },
|
|
3779
|
+
{ header: "Added", get: (r) => r.created_at?.slice(0, 10) },
|
|
3780
|
+
{ header: "ID", get: (r) => r.file_id }
|
|
3781
|
+
], opts.output ?? defaultFormat()));
|
|
3782
|
+
if (has_more) console.error(`Showing ${files.length}${total !== null ? ` of ${total}` : ""}. Use --limit for more.`);
|
|
3783
|
+
} catch (err) {
|
|
3784
|
+
console.error(formatErrorForCli(err));
|
|
3785
|
+
process.exitCode = 1;
|
|
3786
|
+
}
|
|
3787
|
+
});
|
|
3788
|
+
cmd.command("read <id>").description("Show a file: its extracted text and a 5-minute download link (JSON by default)").option("--text", "print only the extracted text").option("--save <path>", "download the file to this path").option("-p, --profile <name>").action(async (id, opts) => {
|
|
3789
|
+
try {
|
|
3790
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
3791
|
+
const file = await client.files.read(id);
|
|
3792
|
+
if (opts.save) {
|
|
3793
|
+
if (!file.download_url) throw new Error(file.kind === "link" ? `That's a saved link: ${file.url}` : "No download link for that file.");
|
|
3794
|
+
const res = await fetch(file.download_url);
|
|
3795
|
+
if (!res.ok || !res.body) throw new Error(`Download failed (${res.status}).`);
|
|
3796
|
+
await pipeline(Readable.fromWeb(res.body), createWriteStream(opts.save));
|
|
3797
|
+
console.error(`Saved ${file.name} to ${opts.save}`);
|
|
3798
|
+
return;
|
|
3799
|
+
}
|
|
3800
|
+
if (opts.text) {
|
|
3801
|
+
if (typeof file.text !== "string") {
|
|
3802
|
+
const why = file.kind === "link" ? `it's a saved link: ${file.url}` : file.text_status === "pending" ? "its text is still being extracted" : "no text could be extracted from it";
|
|
3803
|
+
throw new Error(`No text for ${file.name}: ${why}.`);
|
|
3804
|
+
}
|
|
3805
|
+
console.log(file.text);
|
|
3806
|
+
if (file.text_truncated) console.error("(Only the first part of this file was extracted.)");
|
|
3807
|
+
return;
|
|
3808
|
+
}
|
|
3809
|
+
console.log(JSON.stringify(file, null, 2));
|
|
3810
|
+
} catch (err) {
|
|
3811
|
+
console.error(formatErrorForCli(err));
|
|
3812
|
+
process.exitCode = 1;
|
|
3813
|
+
}
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3717
3817
|
// src/commands/agent.ts
|
|
3718
3818
|
var DAY_MAP = {
|
|
3719
3819
|
sun: 0,
|
|
@@ -4919,7 +5019,7 @@ function registerEmailCommands(parent) {
|
|
|
4919
5019
|
}
|
|
4920
5020
|
|
|
4921
5021
|
// src/cli.ts
|
|
4922
|
-
var program = new
|
|
5022
|
+
var program = new Command4();
|
|
4923
5023
|
program.name("helm-ai").description("Helm CLI \u2014 run your business operations (projects, CRM, billing, automations, AI agents) from the terminal").version(version, "-v, --version").addHelpText("beforeAll", () => process.stdout.isTTY ? renderSplash({ version }) : "");
|
|
4924
5024
|
registerAuthCommands(program);
|
|
4925
5025
|
registerProfileCommands(program);
|
|
@@ -4940,6 +5040,7 @@ registerProductCommands(program);
|
|
|
4940
5040
|
registerFormCommands(program);
|
|
4941
5041
|
registerCalendarCommands(program);
|
|
4942
5042
|
registerDocCommands(program);
|
|
5043
|
+
registerFileCommands(program);
|
|
4943
5044
|
registerAgentCommands(program);
|
|
4944
5045
|
registerImportCommands(program);
|
|
4945
5046
|
registerTemplateCommands(program);
|