@erdoai/cli 0.245.0 → 0.249.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/index.js +53 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -125,7 +125,7 @@ function describeFreshnessTarget(state) {
125
125
  }
126
126
 
127
127
  // src/index.ts
128
- import { readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
128
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
129
129
 
130
130
  // src/script-edits.ts
131
131
  function parseScriptEdits(text) {
@@ -144,7 +144,7 @@ function parseScriptEdits(text) {
144
144
  }
145
145
 
146
146
  // src/index.ts
147
- import { basename as basename2 } from "path";
147
+ import { basename as basename2, resolve } from "path";
148
148
 
149
149
  // src/csv.ts
150
150
  function parseCSV(text) {
@@ -463,7 +463,7 @@ function networkErrorFor(method, path, err) {
463
463
  const detail = code ? `${code} (${causeMsg})` : causeMsg;
464
464
  return new ErdoNetworkError(`${method} ${path} failed: ${detail}`, cause);
465
465
  }
466
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
466
+ var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
467
467
  async function rawRequest(baseURL, token, orgId, projectId, method, path, body, retryNetworkFailures = true) {
468
468
  const headers = { Authorization: `Bearer ${token}` };
469
469
  if (orgId) headers["X-Organization-ID"] = orgId;
@@ -935,6 +935,9 @@ var ErdoClient = class {
935
935
  getSentEmail(emailID) {
936
936
  return this.request("GET", `/v1/emails/${encodeURIComponent(emailID)}`);
937
937
  }
938
+ previewEmail(input) {
939
+ return this.request("POST", "/v1/email/preview", input);
940
+ }
938
941
  // Phone conversation records: inbound calls to a voice agent's own number and
939
942
  // the outbound calls Erdo placed. Website chat widget conversations are a
940
943
  // different resource — they live under /v1/voice/widget-conversations.
@@ -1510,6 +1513,7 @@ var ErdoClient = class {
1510
1513
  const q = new URLSearchParams();
1511
1514
  if (params?.status !== void 0) q.set("status", params.status);
1512
1515
  if (params?.type) q.set("type", params.type);
1516
+ if (params?.filter) q.set("filter", params.filter);
1513
1517
  if (params?.limit) q.set("limit", String(params.limit));
1514
1518
  if (params?.offset) q.set("offset", String(params.offset));
1515
1519
  const qs = q.toString();
@@ -2734,7 +2738,7 @@ function parsePastedCode(input, state) {
2734
2738
  return { error: "couldn't find an authorization code in that \u2014 paste the full localhost callback URL" };
2735
2739
  }
2736
2740
  function waitForCode(state) {
2737
- return new Promise((resolve, reject) => {
2741
+ return new Promise((resolve2, reject) => {
2738
2742
  let settled = false;
2739
2743
  let server;
2740
2744
  let rl;
@@ -2762,7 +2766,7 @@ function waitForCode(state) {
2762
2766
  );
2763
2767
  if (gotState !== state) return finish(() => reject(new Error("state mismatch \u2014 login aborted")));
2764
2768
  if (!code) return finish(() => reject(new Error("no authorization code returned")));
2765
- finish(() => resolve(code));
2769
+ finish(() => resolve2(code));
2766
2770
  });
2767
2771
  server.on("error", (err) => {
2768
2772
  if (err.code === "EADDRINUSE") {
@@ -2807,7 +2811,7 @@ If it doesn't open, visit:
2807
2811
  console.log(` \u2717 ${parsed.error}`);
2808
2812
  return;
2809
2813
  }
2810
- finish(() => resolve(parsed.code));
2814
+ finish(() => resolve2(parsed.code));
2811
2815
  return;
2812
2816
  }
2813
2817
  if (key?.name === "backspace") {
@@ -6731,15 +6735,16 @@ webhooksCmd.command("retry <id> <delivery-id>").description("Retry a failed webh
6731
6735
  }
6732
6736
  });
6733
6737
  var reviewsCmd = program.command("reviews").description(
6734
- "The Knowledge Review queue \u2014 knowledge patches the critic proposes, investigations, and deduplicated failure signals awaiting a human decision"
6738
+ "Changes Erdo applied or that need you, plus investigations and failure signals"
6735
6739
  );
6736
- reviewsCmd.command("list").description("List review items (decision items rank above failure signals)").option("--status <status>", "open (default) | snoozed | resolved | rejected | '' for all").option("--type <type>", "filter by type, e.g. knowledge_patch, eval_failure, failed_run").option("-n, --limit <n>", "max items", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(
6740
+ reviewsCmd.command("list").description("List Changes that need you or were applied by Erdo").option("--status <status>", "open (default) | snoozed | applied | undone | resolved | rejected").option("--type <type>", "filter by type, e.g. knowledge_patch, eval_failure, failed_run").option("--filter <view>", "needs_you (open items) | changed_by_erdo (applied or undone Knowledge changes)").option("-n, --limit <n>", "max items", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(
6737
6741
  async (opts) => {
6738
6742
  try {
6739
6743
  print(
6740
6744
  await new ErdoClient().listReviewItems({
6741
6745
  status: opts.status,
6742
6746
  type: opts.type,
6747
+ filter: opts.filter,
6743
6748
  limit: opts.limit,
6744
6749
  offset: opts.offset
6745
6750
  })
@@ -6749,7 +6754,7 @@ reviewsCmd.command("list").description("List review items (decision items rank a
6749
6754
  }
6750
6755
  }
6751
6756
  );
6752
- reviewsCmd.command("show <id>").description("Show one review item with its full payload (the proposed patch body for a knowledge_patch)").action(async (id) => {
6757
+ reviewsCmd.command("show <id>").description("Show one change with its full payload and Knowledge diff fields when applicable").action(async (id) => {
6753
6758
  try {
6754
6759
  print(await new ErdoClient().getReviewItem(id));
6755
6760
  } catch (e) {
@@ -6757,18 +6762,19 @@ reviewsCmd.command("show <id>").description("Show one review item with its full
6757
6762
  }
6758
6763
  });
6759
6764
  reviewsCmd.command("decide <id>").description(
6760
- "Decide a review item: --apply a knowledge patch (mutates Knowledge, then resolves), --resolve, --reject, or --snooze [minutes]"
6761
- ).option("--apply", "apply a knowledge_patch: create/update the proposed Knowledge object, then resolve").option("--resolve", "close as handled").option("--reject", "close as declined").option("--snooze [minutes]", "hide the item for [minutes] (default 7 days)").option("--note <note>", "resolution note recorded on the item").action(
6765
+ "Act on a change: --apply a held Knowledge patch against the current version, --undo an applied change, --resolve, --reject, or --snooze [minutes]"
6766
+ ).option("--apply", "apply a held knowledge_patch against the current Knowledge version").option("--undo", "restore the previous revision of an applied Knowledge change").option("--resolve", "close as handled").option("--reject", "close as declined").option("--snooze [minutes]", "hide the item for [minutes] (default 7 days)").option("--note <note>", "resolution note recorded on the item").action(
6762
6767
  async (id, opts) => {
6763
6768
  try {
6764
6769
  const chosen = [
6765
6770
  opts.apply ? "apply" : null,
6771
+ opts.undo ? "undo" : null,
6766
6772
  opts.resolve ? "resolve" : null,
6767
6773
  opts.reject ? "reject" : null,
6768
6774
  opts.snooze === void 0 ? null : "snooze"
6769
6775
  ].filter(Boolean);
6770
6776
  if (chosen.length !== 1) {
6771
- fail(new Error("provide exactly one of --apply, --resolve, --reject, or --snooze"));
6777
+ fail(new Error("provide exactly one of --apply, --undo, --resolve, --reject, or --snooze"));
6772
6778
  }
6773
6779
  const action = chosen[0];
6774
6780
  let minutes;
@@ -7178,7 +7184,40 @@ domainsCmd.command("transfer <domain> <targetOrg>").description("Move a domain t
7178
7184
  fail(e);
7179
7185
  }
7180
7186
  });
7181
- var emailCmd = program.command("email").description("The domain Erdo sends your outbound agent email from, and the mail that comes back");
7187
+ var emailCmd = program.command("email").description("Preview outbound emails, manage their sending domain, and read replies");
7188
+ emailCmd.command("preview").description("Render an email at phone and desktop widths without sending it").option("--subject <text>", "Email subject").option("--html <html|@path>", "Authored HTML, or @path to an HTML file").option("--template <slug>", "Saved email template slug").option("--data <json|@path>", "Template data as JSON or @path to a JSON file").option("--out <directory>", "Directory for email-375.png and email-640.png", ".").action(async (opts) => {
7189
+ try {
7190
+ if (opts.html !== void 0 && opts.template !== void 0) {
7191
+ throw new Error("pass either --html or --template, not both");
7192
+ }
7193
+ const input = { subject: opts.subject };
7194
+ if (opts.html !== void 0) input.html_content = readMaybeFile(opts.html);
7195
+ if (opts.template !== void 0) input.template_slug = opts.template;
7196
+ if (opts.data !== void 0) {
7197
+ try {
7198
+ input.data = JSON.parse(readMaybeFile(opts.data) ?? "");
7199
+ } catch (error) {
7200
+ throw new Error(`--data must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
7201
+ }
7202
+ }
7203
+ if (input.data !== void 0 && (typeof input.data !== "object" || input.data === null || Array.isArray(input.data))) {
7204
+ throw new Error("--data must be a JSON object");
7205
+ }
7206
+ const preview = await new ErdoClient().previewEmail(input);
7207
+ const widths = new Set(preview.images.map((image) => image.width));
7208
+ if (preview.images.length !== 2 || widths.size !== 2 || !widths.has(375) || !widths.has(640)) {
7209
+ throw new Error("preview must return one image at each of 375px and 640px");
7210
+ }
7211
+ const outDir = resolve(opts.out);
7212
+ mkdirSync3(outDir, { recursive: true });
7213
+ for (const image of preview.images) {
7214
+ writeFileSync3(resolve(outDir, `email-${image.width}.png`), Buffer.from(image.png_base64, "base64"));
7215
+ }
7216
+ console.log(preview.plain_text);
7217
+ } catch (error) {
7218
+ fail(error);
7219
+ }
7220
+ });
7182
7221
  var sendingDomainsCmd = emailCmd.command("domains").description("Sending domains \u2014 the verified domain outreach is sent from (one per org)");
7183
7222
  function printSendingDomain(d) {
7184
7223
  console.log(`${d.domain} ${d.status}${d.error_reason ? ` ${d.error_reason}` : ""}`);
@@ -8556,7 +8595,7 @@ providerLeadSourcesCmd.command("forms").description("List the lead forms a conne
8556
8595
  }
8557
8596
  });
8558
8597
  providerLeadSourcesCmd.command("set").description(
8559
- "Save a lead source from JSON or flags. A LinkedIn or Meta (meta_ads) source names a connection, ad account and forms; a google_sheets, webhook or import source names itself and carries a column mapping (use --file). --dry-run previews what it would write and saves nothing."
8598
+ "Save a lead source from JSON or flags. A LinkedIn or Meta (meta_ads) source names a connection, ad account and forms; a google_sheets, webhook or import source names itself and carries a column mapping (use --file). A meta_ads source may add a budget ({question, currency, options}) in --file so each lead's choice is recorded as their budget. --dry-run previews what it would write and saves nothing."
8560
8599
  ).option("-f, --file <path>", "one JSON declaration object; use - to read from stdin").option("--dataset <slug>", "lead dataset slug").option("--provider <provider>", "linkedin_ads, meta_ads, google_sheets, webhook or import", "linkedin_ads").option("--connection-id <id>", "native integration id from erdo integrations status linkedin_ads_sync (or meta_ads) or GET /v1/integrations").option("--account-id <id>", "numeric ad account id (a Meta id with or without act_)").option("--form <id>", "LinkedIn lead gen form or Meta Instant Form id (repeatable)", collect, []).option("--name <name>", "a google_sheets, webhook or import source's name").option("--sheet-url <url>", "a google_sheets source's tab, as its address in the browser (open to anyone with the link)").option("--dry-run", "preview what the source would write; save nothing").option("--rotate-secret", "issue a webhook source a new secret").option("--disabled", "save the declaration disabled").option("--create-only", "refuse the save if a source with this name already exists").action(async (opts) => {
8561
8600
  try {
8562
8601
  let input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.245.0",
3
+ "version": "0.249.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {