@erdoai/cli 0.80.0 → 0.81.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 +124 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -508,6 +508,32 @@ var ErdoClient = class {
508
508
  { session_id: sessionID, ...widget ? { widget } : {} }
509
509
  );
510
510
  }
511
+ // Text conversations on those same numbers. A conversation is one Erdo number
512
+ // and one person, for as long as they keep texting — so it is addressed by its
513
+ // session id rather than by a message id, and narrowed by the two numbers
514
+ // rather than by an agent slug and a direction.
515
+ listSMSConversations(params) {
516
+ const q = new URLSearchParams();
517
+ if (params?.phone_number) q.set("phone_number", params.phone_number);
518
+ if (params?.address) q.set("address", params.address);
519
+ if (params?.limit !== void 0) q.set("limit", String(params.limit));
520
+ if (params?.cursor) q.set("cursor", params.cursor);
521
+ const qs = q.toString();
522
+ return this.request(
523
+ "GET",
524
+ `/v1/voice/sms-conversations${qs ? `?${qs}` : ""}`
525
+ );
526
+ }
527
+ getSMSConversation(sessionID, params) {
528
+ const q = new URLSearchParams();
529
+ if (params?.limit !== void 0) q.set("limit", String(params.limit));
530
+ if (params?.cursor) q.set("cursor", params.cursor);
531
+ const qs = q.toString();
532
+ return this.request(
533
+ "GET",
534
+ `/v1/voice/sms-conversations/${encodeURIComponent(sessionID)}${qs ? `?${qs}` : ""}`
535
+ );
536
+ }
511
537
  // Run a read-only HogQL query against the org's page-analytics events. Rows are
512
538
  // positional per columns; enabled:false means page analytics is off for the org
513
539
  // (not zero traffic). A rejected query surfaces PostHog's message as the error.
@@ -4846,7 +4872,7 @@ sentEmailsCmd.command("get <emailID>").description("Read one sent email, includi
4846
4872
  fail(e);
4847
4873
  }
4848
4874
  });
4849
- var voiceCmd = program.command("voice").description("Read voice agent phone calls and website widget conversations");
4875
+ var voiceCmd = program.command("voice").description("Read a voice agent's phone calls, text conversations and website widget conversations");
4850
4876
  function contactLabel(contact) {
4851
4877
  if (!contact) return "-";
4852
4878
  const name = [contact.first_name, contact.last_name].filter(Boolean).join(" ");
@@ -4992,6 +5018,103 @@ widgetConversationsCmd.command("get <sessionID>").description(
4992
5018
  fail(e);
4993
5019
  }
4994
5020
  });
5021
+ var voiceSMSCmd = voiceCmd.command("sms").description("Text conversations on a voice agent's own number");
5022
+ voiceSMSCmd.command("list").description("List the organization's SMS conversations, most recently active first").option("--phone-number <number>", "only conversations on this Erdo number (any format)").option("--address <number>", "only the conversation with this person (any format)").option("--limit <n>", "page size (default 25, max 100)").option("--cursor <cursor>", "next_cursor from the preceding page (stable paging)").option("--json", "print the raw JSON result instead of a table").action(
5023
+ async (opts) => {
5024
+ try {
5025
+ const res = await new ErdoClient().listSMSConversations({
5026
+ phone_number: opts.phoneNumber,
5027
+ address: opts.address,
5028
+ limit: opts.limit ? Number(opts.limit) : void 0,
5029
+ cursor: opts.cursor
5030
+ });
5031
+ if (opts.json) {
5032
+ print(res);
5033
+ return;
5034
+ }
5035
+ const conversations = res.conversations ?? [];
5036
+ if (conversations.length === 0) {
5037
+ console.log("No SMS conversations match those filters.");
5038
+ return;
5039
+ }
5040
+ printAlignedTable(
5041
+ ["session id", "phone", "address", "msgs", "last inbound", "last outbound", "summary"],
5042
+ conversations.map((c) => [
5043
+ c.session_id,
5044
+ c.phone_number,
5045
+ // An opted-out conversation is marked on the person, since that is
5046
+ // what the flag governs: nothing may text THEM until they send START.
5047
+ c.suppressed ? `${c.address} (suppressed)` : c.address,
5048
+ c.message_count,
5049
+ c.last_inbound_at ?? "",
5050
+ c.last_outbound_at ?? "",
5051
+ c.summary
5052
+ ])
5053
+ );
5054
+ process.stderr.write(`showing ${conversations.length} conversation(s)
5055
+ `);
5056
+ if (res.next_cursor) {
5057
+ process.stderr.write(`more available \u2014 re-run with --cursor ${res.next_cursor}
5058
+ `);
5059
+ }
5060
+ } catch (e) {
5061
+ fail(e);
5062
+ }
5063
+ }
5064
+ );
5065
+ voiceSMSCmd.command("get <sessionID>").description("Read one SMS conversation: its metadata, then every text oldest first").option("--limit <n>", "texts per page (default 50, max 200)").option("--cursor <cursor>", "next_cursor from the preceding page of texts").option("--json", "print the raw JSON result instead of a table").action(
5066
+ async (sessionID, opts) => {
5067
+ try {
5068
+ const res = await new ErdoClient().getSMSConversation(sessionID, {
5069
+ limit: opts.limit ? Number(opts.limit) : void 0,
5070
+ cursor: opts.cursor
5071
+ });
5072
+ if (opts.json) {
5073
+ print(res);
5074
+ return;
5075
+ }
5076
+ const c = res.conversation;
5077
+ printAlignedTable(
5078
+ ["session id", "phone", "address", "msgs", "last inbound", "last outbound", "summary"],
5079
+ [
5080
+ [
5081
+ c.session_id,
5082
+ c.phone_number,
5083
+ c.suppressed ? `${c.address} (suppressed)` : c.address,
5084
+ c.message_count,
5085
+ c.last_inbound_at ?? "",
5086
+ c.last_outbound_at ?? "",
5087
+ c.summary
5088
+ ]
5089
+ ]
5090
+ );
5091
+ const messages = res.messages ?? [];
5092
+ if (messages.length === 0) {
5093
+ console.log("\nNo texts have been recorded in this conversation yet.");
5094
+ return;
5095
+ }
5096
+ console.log("");
5097
+ printAlignedTable(
5098
+ ["at", "direction", "status", "media", "body"],
5099
+ messages.map((m) => [
5100
+ m.created_at,
5101
+ m.direction,
5102
+ m.status,
5103
+ m.num_media > 0 ? m.num_media : "",
5104
+ m.body
5105
+ ])
5106
+ );
5107
+ process.stderr.write(`showing ${messages.length} text(s), oldest first
5108
+ `);
5109
+ if (res.next_cursor) {
5110
+ process.stderr.write(`more available \u2014 re-run with --cursor ${res.next_cursor}
5111
+ `);
5112
+ }
5113
+ } catch (e) {
5114
+ fail(e);
5115
+ }
5116
+ }
5117
+ );
4995
5118
  var datasetsCmd = program.command("datasets").description("Datasets");
4996
5119
  datasetsCmd.command("list").description("List datasets").option(
4997
5120
  "--class <class>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {