@helm-ai/cli 1.4.0 → 1.6.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.
Files changed (2) hide show
  1. package/dist/cli.js +189 -27
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -25,7 +25,7 @@ function renderSplash(ctx) {
25
25
  }
26
26
 
27
27
  // src/version.ts
28
- var version = "1.4.0";
28
+ var version = "1.6.0";
29
29
 
30
30
  // src/commands/auth.ts
31
31
  import prompts from "prompts";
@@ -905,6 +905,26 @@ var HelmClient = class _HelmClient {
905
905
  const data = await this.request("create_sequence_email", "POST", { sequence_id: sequenceId, ...input });
906
906
  return data.step;
907
907
  },
908
+ update: async (sequenceId, updates) => {
909
+ const data = await this.request("update_email_sequence", "POST", { sequence_id: sequenceId, ...updates });
910
+ return data.sequence;
911
+ },
912
+ delete: async (sequenceId) => {
913
+ const data = await this.request("delete_email_sequence", "POST", { sequence_id: sequenceId });
914
+ return data;
915
+ },
916
+ updateEmail: async (sequenceId, emailId, updates) => {
917
+ const data = await this.request("update_sequence_email", "POST", { id: emailId, sequence_id: sequenceId, ...updates });
918
+ return data.step;
919
+ },
920
+ removeEmail: async (sequenceId, emailId) => {
921
+ const data = await this.request("delete_sequence_email", "POST", { id: emailId, sequence_id: sequenceId });
922
+ return data;
923
+ },
924
+ reorderEmails: async (sequenceId, orderedEmailIds) => {
925
+ const data = await this.request("reorder_sequence_emails", "POST", { sequence_id: sequenceId, ordered_step_ids: orderedEmailIds });
926
+ return data;
927
+ },
908
928
  enrollments: async (sequenceId, filters = {}) => {
909
929
  const data = await this.request("list_sequence_enrollments", "GET", { sequence_id: sequenceId, ...filters });
910
930
  return data.enrollments ?? [];
@@ -1774,13 +1794,13 @@ function registerDealCommands(parent) {
1774
1794
  process.exitCode = 1;
1775
1795
  return;
1776
1796
  }
1777
- const { confirmed } = await prompts2({
1797
+ const { confirmed: confirmed2 } = await prompts2({
1778
1798
  type: "confirm",
1779
1799
  name: "confirmed",
1780
1800
  message: `Delete deal ${id}? This cannot be undone.`,
1781
1801
  initial: false
1782
1802
  });
1783
- if (!confirmed) {
1803
+ if (!confirmed2) {
1784
1804
  console.log("Aborted.");
1785
1805
  return;
1786
1806
  }
@@ -1868,13 +1888,13 @@ function registerPipelineCommands(parent) {
1868
1888
  process.exitCode = 1;
1869
1889
  return;
1870
1890
  }
1871
- const { confirmed } = await prompts3({
1891
+ const { confirmed: confirmed2 } = await prompts3({
1872
1892
  type: "confirm",
1873
1893
  name: "confirmed",
1874
1894
  message: `Delete pipeline ${id}? This cannot be undone.`,
1875
1895
  initial: false
1876
1896
  });
1877
- if (!confirmed) {
1897
+ if (!confirmed2) {
1878
1898
  console.log("Aborted.");
1879
1899
  return;
1880
1900
  }
@@ -1935,13 +1955,13 @@ function registerPipelineCommands(parent) {
1935
1955
  process.exitCode = 1;
1936
1956
  return;
1937
1957
  }
1938
- const { confirmed } = await prompts3({
1958
+ const { confirmed: confirmed2 } = await prompts3({
1939
1959
  type: "confirm",
1940
1960
  name: "confirmed",
1941
1961
  message: `Delete stage ${stageId}?`,
1942
1962
  initial: false
1943
1963
  });
1944
- if (!confirmed) {
1964
+ if (!confirmed2) {
1945
1965
  console.log("Aborted.");
1946
1966
  return;
1947
1967
  }
@@ -2453,13 +2473,13 @@ Refusing to void without confirmation in a non-interactive shell. Re-run with -y
2453
2473
  process.exitCode = 1;
2454
2474
  return;
2455
2475
  }
2456
- const { confirmed } = await prompts4({
2476
+ const { confirmed: confirmed2 } = await prompts4({
2457
2477
  type: "confirm",
2458
2478
  name: "confirmed",
2459
2479
  message: `${check.impact} Void these hours?`,
2460
2480
  initial: false
2461
2481
  });
2462
- if (!confirmed) {
2482
+ if (!confirmed2) {
2463
2483
  console.log("Aborted.");
2464
2484
  return;
2465
2485
  }
@@ -2689,11 +2709,13 @@ function registerInvoiceCommands(parent) {
2689
2709
  return;
2690
2710
  }
2691
2711
  });
2692
- cmd.command("create").description("Create an invoice").requiredOption("-t, --title <title>", "invoice title (required)").option("-d, --description <text>").option("-C, --company <id>").option("--deal <id>", "deal this invoice bills against").option("-i, --item <item>", LINE_ITEM_HELP, collectLineItem).option("--items <path>", LINE_ITEMS_FILE_HELP).option("--tax-rate <pct>", "tax rate %", parseFloat).option("--issue-date <date>", "ISO 8601").option("--due-date <date>", "ISO 8601").option("--notes <text>", "client-visible notes").option("--internal-notes <text>").option("-p, --profile <name>").addHelpText("after", `
2712
+ cmd.command("create").description("Create an invoice").requiredOption("-t, --title <title>", "invoice title (required)").option("-d, --description <text>").option("-C, --company <id>").option("--deal <id>", "deal this invoice bills against").option("-i, --item <item>", LINE_ITEM_HELP, collectLineItem).option("--items <path>", LINE_ITEMS_FILE_HELP).option("--tax-rate <pct>", "tax rate %", parseFloat).option("--issue-date <date>", "ISO 8601").option("--due-date <date>", "ISO 8601").option("--notes <text>", "client-visible notes").option("--internal-notes <text>").option("--already-billed", "record a bill the client already got another way (text, paper); saved as open, so it counts as owed. Nothing is sent").option("-p, --profile <name>").addHelpText("after", `
2693
2713
  Examples:
2694
2714
  helm-ai invoice create -t "October retainer" -C <company-id> \\
2695
2715
  --item "Development|10|150" --item "Hosting|49"
2696
- helm-ai invoice create -t "October retainer" -C <company-id> --items items.json`).action(async (opts) => {
2716
+ helm-ai invoice create -t "October retainer" -C <company-id> --items items.json
2717
+ helm-ai invoice create -t "October pool service" -C <company-id> \\
2718
+ --item "Weekly service|1|180" --due-date 2026-11-01 --already-billed`).action(async (opts) => {
2697
2719
  try {
2698
2720
  const client = HelmClient.fromProfile(resolveProfile(opts.profile));
2699
2721
  const invoice = await client.invoices.create({
@@ -2706,7 +2728,8 @@ Examples:
2706
2728
  issue_date: opts.issueDate,
2707
2729
  due_date: opts.dueDate,
2708
2730
  notes: opts.notes,
2709
- internal_notes: opts.internalNotes
2731
+ internal_notes: opts.internalNotes,
2732
+ ...opts.alreadyBilled ? { already_billed: true } : {}
2710
2733
  });
2711
2734
  console.log(JSON.stringify(invoice, null, 2));
2712
2735
  } catch (err) {
@@ -4589,8 +4612,8 @@ async function readJsonSource(path) {
4589
4612
  for await (const chunk of process.stdin) chunks.push(chunk);
4590
4613
  raw = Buffer.concat(chunks).toString("utf8");
4591
4614
  } else {
4592
- const { readFileSync: readFileSync6 } = await import("fs");
4593
- raw = readFileSync6(path, "utf8");
4615
+ const { readFileSync: readFileSync7 } = await import("fs");
4616
+ raw = readFileSync7(path, "utf8");
4594
4617
  }
4595
4618
  try {
4596
4619
  return JSON.parse(raw);
@@ -4685,8 +4708,8 @@ function registerWorkflowCommands(parent) {
4685
4708
  try {
4686
4709
  let triggerData;
4687
4710
  if (opts.dataFile) {
4688
- const { readFileSync: readFileSync6 } = await import("fs");
4689
- triggerData = JSON.parse(readFileSync6(opts.dataFile, "utf8"));
4711
+ const { readFileSync: readFileSync7 } = await import("fs");
4712
+ triggerData = JSON.parse(readFileSync7(opts.dataFile, "utf8"));
4690
4713
  } else if (opts.data) {
4691
4714
  triggerData = JSON.parse(opts.data);
4692
4715
  }
@@ -4752,10 +4775,47 @@ function registerWorkflowCommands(parent) {
4752
4775
  }
4753
4776
 
4754
4777
  // src/commands/sequence.ts
4778
+ import { readFileSync as readFileSync5 } from "fs";
4779
+ import prompts5 from "prompts";
4755
4780
  import { stringify as yamlStringify2 } from "yaml";
4756
4781
  var collect2 = (value, prev) => prev.concat([value]);
4782
+ var UNITS = ["minutes", "hours", "days"];
4783
+ function readBodies(opts) {
4784
+ if (opts.text !== void 0 && opts.textFile) throw new Error("Use --text or --text-file, not both.");
4785
+ if (opts.html !== void 0 && opts.htmlFile) throw new Error("Use --html or --html-file, not both.");
4786
+ if (opts.textFile === "-" && opts.htmlFile === "-") throw new Error("Only one of --text-file and --html-file can read stdin (-).");
4787
+ const read = (path) => readFileSync5(path === "-" ? 0 : path, "utf8");
4788
+ return {
4789
+ text: opts.textFile ? read(opts.textFile) : opts.text,
4790
+ html: opts.htmlFile ? read(opts.htmlFile) : opts.html
4791
+ };
4792
+ }
4793
+ function parseDelay(delay, unit) {
4794
+ const out = {};
4795
+ if (delay !== void 0) {
4796
+ const n = Number(delay);
4797
+ if (!Number.isInteger(n) || n < 0) throw new Error("--delay must be a whole number of 0 or more.");
4798
+ out.delay_value = n;
4799
+ }
4800
+ if (unit !== void 0) {
4801
+ if (!UNITS.includes(unit)) throw new Error("--unit must be minutes, hours or days.");
4802
+ out.delay_unit = unit;
4803
+ }
4804
+ return out;
4805
+ }
4806
+ async function confirmed(message, yes) {
4807
+ if (yes) return true;
4808
+ if (!process.stdin.isTTY) {
4809
+ console.error("Refusing without confirmation in a non-interactive shell. Re-run with -y/--yes.");
4810
+ process.exitCode = 1;
4811
+ return false;
4812
+ }
4813
+ const { ok } = await prompts5({ type: "confirm", name: "ok", message, initial: false });
4814
+ if (!ok) console.log("Aborted.");
4815
+ return !!ok;
4816
+ }
4757
4817
  function registerSequenceCommands(parent) {
4758
- const cmd = parent.command("sequence").alias("sequences").description("Operate email sequences (read, enroll, lifecycle)");
4818
+ const cmd = parent.command("sequence").alias("sequences").description("Operate email sequences (read, build, edit, enroll, lifecycle)");
4759
4819
  cmd.command("list").description("List email sequences").option("--status <status>", "draft|live|paused|archived").option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
4760
4820
  try {
4761
4821
  const client = HelmClient.fromProfile(resolveProfile(opts.profile));
@@ -4860,20 +4920,22 @@ Next: add emails with
4860
4920
  return;
4861
4921
  }
4862
4922
  });
4863
- cmd.command("add-email <id>").description("Add an email to a sequence (appends to the end)").requiredOption("--subject <subject>", "email subject line").option("--text <body>", "plain-text body (provide --text and/or --html)").option("--html <body>", "HTML body (provide --text and/or --html)").requiredOption("--delay <n>", "wait before this email, with --unit (0 = on enrollment)").option("--unit <unit>", "minutes|hours|days", "days").option("--position <n>", "1-based insert position (omit to append)").option("-p, --profile <name>").action(async (id, opts) => {
4923
+ cmd.command("add-email <id>").description("Add an email to a sequence (appends to the end)").requiredOption("--subject <subject>", "email subject line").option("--text <body>", "plain-text body (provide a text and/or HTML body)").option("--html <body>", "HTML body (provide a text and/or HTML body)").option("--text-file <path>", "read the plain-text body from a file (- for stdin)").option("--html-file <path>", "read the HTML body from a file (- for stdin)").requiredOption("--delay <n>", "wait before this email, with --unit (0 = on enrollment)").option("--unit <unit>", "minutes|hours|days", "days").option("--position <n>", "1-based insert position (omit to append)").option("-p, --profile <name>").action(async (id, opts) => {
4864
4924
  try {
4865
- if (!opts.text && !opts.html) {
4866
- console.error("Provide --text and/or --html for the email body.");
4925
+ const { text, html } = readBodies(opts);
4926
+ if (!text && !html) {
4927
+ console.error("Provide a body with --text/--text-file and/or --html/--html-file.");
4867
4928
  process.exitCode = 1;
4868
4929
  return;
4869
4930
  }
4931
+ const delay = parseDelay(opts.delay, opts.unit);
4870
4932
  const client = HelmClient.fromProfile(resolveProfile(opts.profile));
4871
4933
  const step = await client.sequences.addEmail(id, {
4872
4934
  subject: opts.subject,
4873
- text_body: opts.text,
4874
- html_body: opts.html,
4875
- delay_value: Number(opts.delay),
4876
- delay_unit: opts.unit,
4935
+ text_body: text,
4936
+ html_body: html,
4937
+ delay_value: delay.delay_value ?? 0,
4938
+ delay_unit: delay.delay_unit ?? "days",
4877
4939
  position: opts.position != null ? Number(opts.position) : void 0
4878
4940
  });
4879
4941
  console.log(`\u2713 Added email #${step.position}: "${step.subject}" (after ${step.delay_value ?? 0} ${step.delay_unit ?? opts.unit})`);
@@ -4883,6 +4945,106 @@ Next: add emails with
4883
4945
  return;
4884
4946
  }
4885
4947
  });
4948
+ cmd.command("emails <id>").description("List a sequence's emails in order, with the IDs the edit commands take").option("-o, --output <format>").option("-p, --profile <name>").action(async (id, opts) => {
4949
+ try {
4950
+ const client = HelmClient.fromProfile(resolveProfile(opts.profile));
4951
+ const { steps } = await client.sequences.get(id);
4952
+ const rows = [...steps ?? []].sort((a, b) => a.position - b.position);
4953
+ console.log(render(rows, [
4954
+ { header: "#", get: (r) => String(r.position) },
4955
+ { header: "Subject", get: (r) => r.subject },
4956
+ { header: "Wait", get: (r) => `${r.delay_value ?? 0} ${r.delay_unit ?? "days"}` },
4957
+ { header: "ID", get: (r) => r.id }
4958
+ ], opts.output ?? defaultFormat()));
4959
+ } catch (err) {
4960
+ console.error(formatErrorForCli(err));
4961
+ process.exitCode = 1;
4962
+ return;
4963
+ }
4964
+ });
4965
+ cmd.command("update-email <id> <emailId>").description("Edit an email in a sequence (only the options you pass change)").option("--subject <subject>", "new subject line").option("--text <body>", "new plain-text body").option("--html <body>", "new HTML body").option("--text-file <path>", "read the new plain-text body from a file (- for stdin)").option("--html-file <path>", "read the new HTML body from a file (- for stdin)").option("--delay <n>", "new wait before this email").option("--unit <unit>", "minutes|hours|days").option("-p, --profile <name>").action(async (id, emailId, opts) => {
4966
+ try {
4967
+ const { text, html } = readBodies(opts);
4968
+ const delay = parseDelay(opts.delay, opts.unit);
4969
+ const updates = {
4970
+ ...opts.subject !== void 0 ? { subject: opts.subject } : {},
4971
+ ...text !== void 0 ? { text_body: text } : {},
4972
+ ...html !== void 0 ? { html_body: html } : {},
4973
+ ...delay
4974
+ };
4975
+ if (Object.keys(updates).length === 0) {
4976
+ console.error("Nothing to change. Pass --subject, a body, --delay or --unit.");
4977
+ process.exitCode = 1;
4978
+ return;
4979
+ }
4980
+ const client = HelmClient.fromProfile(resolveProfile(opts.profile));
4981
+ const step = await client.sequences.updateEmail(id, emailId, updates);
4982
+ console.log(`\u2713 Updated email #${step.position}: "${step.subject}" (after ${step.delay_value ?? 0} ${step.delay_unit ?? "days"})`);
4983
+ } catch (err) {
4984
+ console.error(formatErrorForCli(err));
4985
+ process.exitCode = 1;
4986
+ return;
4987
+ }
4988
+ });
4989
+ cmd.command("remove-email <id> <emailId>").description("Remove an email from a sequence (the rest close up the gap)").option("-y, --yes", "skip confirmation").option("-p, --profile <name>").action(async (id, emailId, opts) => {
4990
+ try {
4991
+ if (!await confirmed(`Remove email ${emailId} from the sequence? This cannot be undone.`, opts.yes)) return;
4992
+ const client = HelmClient.fromProfile(resolveProfile(opts.profile));
4993
+ await client.sequences.removeEmail(id, emailId);
4994
+ console.log(`\u2713 Removed email ${emailId}`);
4995
+ } catch (err) {
4996
+ console.error(formatErrorForCli(err));
4997
+ process.exitCode = 1;
4998
+ return;
4999
+ }
5000
+ });
5001
+ cmd.command("reorder <id> <emailIds...>").description("Set the order of a sequence's emails (list every email ID, first to last)").option("-p, --profile <name>").action(async (id, emailIds, opts) => {
5002
+ try {
5003
+ const client = HelmClient.fromProfile(resolveProfile(opts.profile));
5004
+ await client.sequences.reorderEmails(id, emailIds);
5005
+ console.log(`\u2713 Reordered ${emailIds.length} emails`);
5006
+ } catch (err) {
5007
+ console.error(formatErrorForCli(err));
5008
+ process.exitCode = 1;
5009
+ return;
5010
+ }
5011
+ });
5012
+ cmd.command("update <id>").description("Change a sequence's settings (only the options you pass change)").option("-n, --name <name>", "new name").option("--description <text>", "new description").option("--sender <id>", "sender identity UUID").option("--exit-on-reply", "stop sending when a contact replies").option("--no-exit-on-reply", "keep sending after a contact replies").option("--exit-on-bounce", "stop sending after a bounce").option("--no-exit-on-bounce", "keep sending after a bounce").option("--transactional", "billing/account mail: still sends to marketing unsubscribes, no unsubscribe footer").option("--no-transactional", "marketing mail: honors unsubscribes, adds the unsubscribe footer").option("-p, --profile <name>").action(async (id, opts) => {
5013
+ try {
5014
+ const updates = Object.fromEntries(Object.entries({
5015
+ name: opts.name,
5016
+ description: opts.description,
5017
+ sender_identity_id: opts.sender,
5018
+ exit_on_reply: opts.exitOnReply,
5019
+ exit_on_bounce: opts.exitOnBounce,
5020
+ is_transactional: opts.transactional
5021
+ }).filter(([, v]) => v !== void 0));
5022
+ if (Object.keys(updates).length === 0) {
5023
+ console.error("Nothing to change. Pass at least one option (see --help).");
5024
+ process.exitCode = 1;
5025
+ return;
5026
+ }
5027
+ const client = HelmClient.fromProfile(resolveProfile(opts.profile));
5028
+ const seq = await client.sequences.update(id, updates);
5029
+ console.log(`\u2713 Updated sequence "${seq.name ?? id}"`);
5030
+ } catch (err) {
5031
+ console.error(formatErrorForCli(err));
5032
+ process.exitCode = 1;
5033
+ return;
5034
+ }
5035
+ });
5036
+ cmd.command("delete <id>").description("Permanently delete a sequence, its emails and its enrollments").option("-y, --yes", "skip confirmation").option("-p, --profile <name>").action(async (id, opts) => {
5037
+ try {
5038
+ if (!await confirmed(`Delete sequence ${id}, its emails and enrollments? This cannot be undone. (archive keeps them)`, opts.yes)) return;
5039
+ const client = HelmClient.fromProfile(resolveProfile(opts.profile));
5040
+ await client.sequences.delete(id);
5041
+ console.log(`\u2713 Deleted sequence ${id}`);
5042
+ } catch (err) {
5043
+ console.error(formatErrorForCli(err));
5044
+ process.exitCode = 1;
5045
+ return;
5046
+ }
5047
+ });
4886
5048
  const setStatus = (verb, status, desc) => {
4887
5049
  cmd.command(`${verb} <id>`).description(desc).option("-p, --profile <name>").action(async (id, opts) => {
4888
5050
  try {
@@ -4921,7 +5083,7 @@ Next: add emails with
4921
5083
  }
4922
5084
 
4923
5085
  // src/commands/email.ts
4924
- import { readFileSync as readFileSync5 } from "fs";
5086
+ import { readFileSync as readFileSync6 } from "fs";
4925
5087
  function registerEmailCommands(parent) {
4926
5088
  const cmd = parent.command("email").description("Draft and revise email from your own address");
4927
5089
  cmd.command("identities").alias("addresses").description("List the addresses you can send from").option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
@@ -4953,7 +5115,7 @@ function registerEmailCommands(parent) {
4953
5115
  const splitAddrs = (v) => (v ?? "").split(",").map((s) => s.trim()).filter(Boolean);
4954
5116
  let body = opts.body;
4955
5117
  if (opts.bodyFile) {
4956
- body = readFileSync5(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
5118
+ body = readFileSync6(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
4957
5119
  }
4958
5120
  if (!body && !opts.html) {
4959
5121
  throw new Error("--body, --body-file, or --html is required");
@@ -5014,7 +5176,7 @@ function registerEmailCommands(parent) {
5014
5176
  const splitAddrs = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
5015
5177
  let body = opts.body;
5016
5178
  if (opts.bodyFile) {
5017
- body = readFileSync5(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
5179
+ body = readFileSync6(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
5018
5180
  }
5019
5181
  const client = HelmClient.fromProfile(resolveProfile(opts.profile));
5020
5182
  const draft = await client.email.updateDraft({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helm-ai/cli",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Command line interface for Helm",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",