@erdoai/cli 0.256.0 → 0.258.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/dist/index.js +95 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -437,6 +437,9 @@ function formatOrg(name, slug) {
|
|
|
437
437
|
if (name && slug) return `${name} (${slug})`;
|
|
438
438
|
return name || slug || "";
|
|
439
439
|
}
|
|
440
|
+
function communicationCoverageUnavailable(response) {
|
|
441
|
+
return Object.values(response.coverage ?? {}).some((coverage) => coverage.state === "unavailable");
|
|
442
|
+
}
|
|
440
443
|
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "declined", "error"]);
|
|
441
444
|
var POLL_STOP_STATUSES = /* @__PURE__ */ new Set([...TERMINAL_RUN_STATUSES, "awaiting_approval"]);
|
|
442
445
|
var ErdoApiError = class extends Error {
|
|
@@ -938,6 +941,29 @@ var ErdoClient = class {
|
|
|
938
941
|
previewEmail(input) {
|
|
939
942
|
return this.request("POST", "/v1/email/preview", input);
|
|
940
943
|
}
|
|
944
|
+
listCommunications(params = {}) {
|
|
945
|
+
const q = new URLSearchParams();
|
|
946
|
+
for (const key of ["channel", "direction", "since", "until", "include", "conversation", "sender", "recipient", "agent", "widget", "subject", "limit", "cursor"]) {
|
|
947
|
+
const value = params[key];
|
|
948
|
+
if (value !== void 0 && value !== "") q.set(key, String(value));
|
|
949
|
+
}
|
|
950
|
+
for (const counterpart of params.counterpart ?? []) q.append("counterpart", counterpart);
|
|
951
|
+
if (params.context !== void 0) q.set("context", JSON.stringify(params.context));
|
|
952
|
+
const qs = q.toString();
|
|
953
|
+
return this.request("GET", `/v1/communications${qs ? `?${qs}` : ""}`);
|
|
954
|
+
}
|
|
955
|
+
queryCommunications(params = {}) {
|
|
956
|
+
return this.request("POST", "/v1/communications/query", params);
|
|
957
|
+
}
|
|
958
|
+
getCommunication(handle, cursor) {
|
|
959
|
+
const q = new URLSearchParams();
|
|
960
|
+
if (cursor) q.set("cursor", cursor);
|
|
961
|
+
const qs = q.toString();
|
|
962
|
+
return this.request(
|
|
963
|
+
"GET",
|
|
964
|
+
`/v1/communications/${encodeURIComponent(handle)}${qs ? `?${qs}` : ""}`
|
|
965
|
+
);
|
|
966
|
+
}
|
|
941
967
|
// Phone conversation records: inbound calls to a voice agent's own number and
|
|
942
968
|
// the outbound calls Erdo placed. Website chat widget conversations are a
|
|
943
969
|
// different resource — they live under /v1/voice/widget-conversations.
|
|
@@ -7590,6 +7616,74 @@ sentEmailsCmd.command("get <emailID>").description("Read one sent email, includi
|
|
|
7590
7616
|
fail(e);
|
|
7591
7617
|
}
|
|
7592
7618
|
});
|
|
7619
|
+
var communicationsCmd = program.command("communications").description("Read organization communications across supported channels");
|
|
7620
|
+
communicationsCmd.command("list").description("List communications, newest first").option("--channel <channel>", "sms, whatsapp, email, voice_call, or widget; comma-separated values are supported").option("--direction <direction>", "inbound or outbound").option("--since <rfc3339>", "event time lower bound; calls/widgets overlap the window").option("--until <rfc3339>", "exclusive event time upper bound; calls/widgets overlap the window").option("--counterpart <uri>", "match tel:+E164 or mailto:address (repeatable)", (value, previous = []) => [...previous, value], []).option("--conversation <id>", "only this conversation").option("--sender <uri>", "only this tel:+E164 number or mailto:address").option("--recipient <uri>", "only this tel:+E164 number or mailto:address").option("--agent <slug>", "only this agent").option("--widget <handle>", "only this widget").option("--subject <text>", "match email subject text").option("--context <json>", "match a structured context object").option("--content", "include message content (bounded per response)").option("--limit <n>", "records per page (default 100, max 100)").option("--cursor <cursor>", "next_cursor from the preceding page").option("--json", "print the raw JSON result instead of a table").action(async (opts) => {
|
|
7621
|
+
try {
|
|
7622
|
+
let context;
|
|
7623
|
+
if (opts.context) {
|
|
7624
|
+
const parsed = JSON.parse(opts.context);
|
|
7625
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
7626
|
+
throw new Error("--context must be a JSON object");
|
|
7627
|
+
}
|
|
7628
|
+
context = parsed;
|
|
7629
|
+
}
|
|
7630
|
+
const filter = {
|
|
7631
|
+
channel: opts.channel,
|
|
7632
|
+
direction: opts.direction,
|
|
7633
|
+
since: opts.since,
|
|
7634
|
+
until: opts.until,
|
|
7635
|
+
counterpart: opts.counterpart,
|
|
7636
|
+
conversation: opts.conversation,
|
|
7637
|
+
sender: opts.sender,
|
|
7638
|
+
recipient: opts.recipient,
|
|
7639
|
+
agent: opts.agent,
|
|
7640
|
+
widget: opts.widget,
|
|
7641
|
+
subject: opts.subject,
|
|
7642
|
+
context,
|
|
7643
|
+
include: opts.content ? "messages" : void 0,
|
|
7644
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
7645
|
+
cursor: opts.cursor
|
|
7646
|
+
};
|
|
7647
|
+
const result = await new ErdoClient().listCommunications(filter);
|
|
7648
|
+
if (opts.json) {
|
|
7649
|
+
print(result);
|
|
7650
|
+
return;
|
|
7651
|
+
}
|
|
7652
|
+
const response = result;
|
|
7653
|
+
const records = response.items ?? [];
|
|
7654
|
+
if (records.length === 0) {
|
|
7655
|
+
console.log(communicationCoverageUnavailable(response) ? "Communication results are incomplete; see source coverage." : response.next_cursor ? "No communications in this page; continue with the next cursor." : "No communications match those filters.");
|
|
7656
|
+
} else {
|
|
7657
|
+
printAlignedTable(
|
|
7658
|
+
["handle", "channel", "kind", "direction", "from", "to", "occurred", "content"],
|
|
7659
|
+
records.map((record) => [
|
|
7660
|
+
record.id,
|
|
7661
|
+
record.channel,
|
|
7662
|
+
record.kind,
|
|
7663
|
+
record.direction ?? "",
|
|
7664
|
+
record.from ?? "",
|
|
7665
|
+
(record.to ?? []).join(", "),
|
|
7666
|
+
record.occurred_at,
|
|
7667
|
+
record.content_complete ? "complete" : "omitted or partial"
|
|
7668
|
+
])
|
|
7669
|
+
);
|
|
7670
|
+
}
|
|
7671
|
+
const coverage = Object.entries(response.coverage ?? {}).map(([channel, value]) => `${channel}=${value.state}`).join(", ");
|
|
7672
|
+
process.stderr.write(`as of ${response.as_of}; coverage: ${coverage || "none"}
|
|
7673
|
+
`);
|
|
7674
|
+
if (response.next_cursor) process.stderr.write(`more available \u2014 re-run with --cursor ${response.next_cursor}
|
|
7675
|
+
`);
|
|
7676
|
+
} catch (e) {
|
|
7677
|
+
fail(e);
|
|
7678
|
+
}
|
|
7679
|
+
});
|
|
7680
|
+
communicationsCmd.command("get <handle>").description("Read one communication by its opaque list handle").option("--cursor <cursor>", "content continuation returned by an earlier read").action(async (handle, opts) => {
|
|
7681
|
+
try {
|
|
7682
|
+
print(await new ErdoClient().getCommunication(handle, opts.cursor));
|
|
7683
|
+
} catch (e) {
|
|
7684
|
+
fail(e);
|
|
7685
|
+
}
|
|
7686
|
+
});
|
|
7593
7687
|
var voiceCmd = program.command("voice").description("A voice agent's phone calls, text conversations, website widget conversations, and its numbers");
|
|
7594
7688
|
function contactLabel(contact) {
|
|
7595
7689
|
if (!contact) return "-";
|
|
@@ -11574,7 +11668,7 @@ knowledgeCmd.command("delete <id>").description("Delete a Knowledge object you c
|
|
|
11574
11668
|
});
|
|
11575
11669
|
knowledgeCmd.command("attach <objectId> [file]").description(
|
|
11576
11670
|
"Attach an image or other small binary to a knowledge object as an org-hosted asset, and print its asset id \u2014 the value a page's assetId field takes. Pass a local path, or --url to have the service download it (the only path for video)."
|
|
11577
|
-
).option("--url <sourceUrl>", "download
|
|
11671
|
+
).option("--url <sourceUrl>", "download a public file URL or SharePoint, OneDrive, Dropbox or Google Drive file share link").addOption(new Option2("--caption <text>", "caption describing the attachment").conflicts("description")).option("--role <prefix>", "filename role prefix, e.g. customer-logo; already prefixed names are preserved").option(
|
|
11578
11672
|
"-d, --description <text>",
|
|
11579
11673
|
"caption for the asset; for an image this is the only text search can match, so describe what is in the picture"
|
|
11580
11674
|
).option("--media-type <mime>", "MIME type hint, e.g. image/jpeg; detected from the filename otherwise").action(
|