groundmail-cli 0.50.1 → 0.52.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 +14 -0
- package/dist/cli.js +374 -190
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,6 +64,20 @@ groundmail emails send --to you@gmail.com --subject "Hello" --text "Hi" --watch
|
|
|
64
64
|
|
|
65
65
|
Without `--from`, it sends from the sandbox sender (`noreply@mail.groundmail.dev`) to your own account email, so it works right after `groundmail login`. Deferrals show the server's reply and keep watching; a bounce prints the exact reply, the bounce type and what to do. `groundmail emails get <id> --watch` follows an email you already sent; `--json` prints one JSON object per stage; `--timeout <seconds>` (default 60). Exit codes: `0` delivered, `1` error, `3` bounced or failed, `4` still on its way, `5` test send.
|
|
66
66
|
|
|
67
|
+
## For agents
|
|
68
|
+
|
|
69
|
+
`--json` works on every command. Results are JSON on stdout; an error is one JSON object on stderr, `{"error":{"message","code","status","hint","request_id","exit_code"}}`, with a non-zero exit code.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
groundmail mailboxes pause bot@agents.example.com --reason "Looking into odd replies" # stop one mailbox sending; it still receives
|
|
73
|
+
groundmail mailboxes resume bot@agents.example.com
|
|
74
|
+
groundmail mailboxes update bot@agents.example.com --allow-recipients acme.com,bob@x.com # it may only send to these; none clears it
|
|
75
|
+
groundmail mailboxes usage bot@agents.example.com --days 30 --json # sends, receives, bounces, estimated cost
|
|
76
|
+
groundmail feedback "the send was refused, but the mailbox is active" # report it, with your last failed command attached
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`feedback` removes keys, tokens and message bodies from the command it attaches.
|
|
80
|
+
|
|
67
81
|
## Common commands
|
|
68
82
|
|
|
69
83
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -2103,11 +2103,12 @@ async function runListKeysCommandWithClient(args, env = process.env) {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
2105
2105
|
// package.json
|
|
2106
|
-
var version = "0.
|
|
2106
|
+
var version = "0.52.0";
|
|
2107
2107
|
|
|
2108
2108
|
// src/help.ts
|
|
2109
2109
|
var USAGE_LINES = [
|
|
2110
2110
|
' groundmail cli search "<what you want to do>" [--limit 5] [--json] find the right command by describing the task; works offline, no sign-in',
|
|
2111
|
+
' groundmail feedback "<what happened>" [--no-last] [--json] report a command that should have worked; sends your last failed command (secrets removed), its error and request id to Groundmail support',
|
|
2111
2112
|
" groundmail login [--scope <scopes>] [--workspace <name>] sign in through the browser (OAuth; no key to copy)",
|
|
2112
2113
|
" groundmail logout [--workspace <name>|--all] revokes the sign-in server-side",
|
|
2113
2114
|
" groundmail whoami",
|
|
@@ -2138,7 +2139,10 @@ var USAGE_LINES = [
|
|
|
2138
2139
|
" groundmail mailboxes create [--local-part signup-bot] [--domain agents.example.com] [--display-name \u2026] [--external-id \u2026] [--tenant <tenant>] [--retention-days 7] [--spam-threshold 5] [--metadata JSON] [--forward-from <mailbox>] [--json] a real address your agent reads and sends from; no --domain: a hosted address, which can only reply; --forward-from: a hosted mailbox this one replaces",
|
|
2139
2140
|
" groundmail mailboxes list [--tenant <tenant>] [--limit 25] [--cursor \u2026] [--json]",
|
|
2140
2141
|
" groundmail mailboxes get <mailbox> [--json]",
|
|
2141
|
-
" groundmail mailboxes update <mailbox> [--send-as support@example.com] [--allowed-senders you@example.com,example.com] [--blocked-senders spam.example] choose who can reach the mailbox
|
|
2142
|
+
" groundmail mailboxes update <mailbox> [--send-as support@example.com] [--allowed-senders you@example.com,example.com] [--blocked-senders spam.example] [--allow-recipients acme.com,bob@x.com|none] [--json] choose who can reach the mailbox, what it sends as and who it may send to; --allow-recipients: sends to anyone else are refused; none clears a setting",
|
|
2143
|
+
" groundmail mailboxes pause <mailbox> [--reason \u2026] [--json] stop one mailbox sending; it still receives mail",
|
|
2144
|
+
" groundmail mailboxes resume <mailbox> [--json] let a paused mailbox send again",
|
|
2145
|
+
" groundmail mailboxes usage <mailbox> [--days 30] [--json] sends, receives, bounces, complaints and estimated cost for one mailbox",
|
|
2142
2146
|
" groundmail mailboxes delete <mailbox> --yes the mailbox and all its mail; a hosted address is never given out again",
|
|
2143
2147
|
" groundmail mailboxes forward <mailbox> --to <new mailbox> --yes move a hosted address to a mailbox on your own domain, for 30 days; it can't send meanwhile",
|
|
2144
2148
|
" groundmail mailboxes threads <mailbox> [--label \u2026] [--participant \u2026] [--unread] [--archived] [--since <iso>] [--include-held] [--limit 25] [--cursor \u2026] [--json]",
|
|
@@ -2219,7 +2223,7 @@ var USAGE_LINES = [
|
|
|
2219
2223
|
" groundmail tenants domains add <tenant> example.com only this tenant can then send from it",
|
|
2220
2224
|
" groundmail tenants domains remove <tenant> example.com gives the domain back to the account",
|
|
2221
2225
|
" groundmail brand get your logo, colors and footer, which templates follow",
|
|
2222
|
-
' groundmail brand set [--logo-url <https url>|none] [--logo-align left|center] [--logo-width 120] [--color #2f6feb] [--company "Acme Inc"|none] [--address "\u2026"|none] [--website acme.com|none] [--settings-file brand.json] --color: buttons, links and the line across the top',
|
|
2226
|
+
' groundmail brand set [--logo-url <https url>|none] [--logo-align left|center] [--logo-width 120] [--logo-name on|off] [--color #2f6feb] [--company "Acme Inc"|none] [--address "\u2026"|none] [--website acme.com|none] [--settings-file brand.json] --color: buttons, links and the line across the top',
|
|
2223
2227
|
" groundmail senders list the names and addresses your email goes out as",
|
|
2224
2228
|
' groundmail senders create --name "Acme Billing" --address billing@mail.acme.com [--reply-to billing@acme.com] [--handle billing] [--default] address on a verified domain',
|
|
2225
2229
|
" groundmail senders get <id|handle>",
|
|
@@ -2260,6 +2264,9 @@ var FOOTER_LINES = [
|
|
|
2260
2264
|
"",
|
|
2261
2265
|
"--watch exit codes: 0 delivered, 1 error, 3 bounced or failed, 4 still on its way at --timeout, 5 test send (never delivered).",
|
|
2262
2266
|
"",
|
|
2267
|
+
"--json works on every command. Results are JSON on stdout. An error is one JSON object on stderr,",
|
|
2268
|
+
' {"error":{"message","code","status","hint","request_id","exit_code"}}, and the exit code is not 0.',
|
|
2269
|
+
"",
|
|
2263
2270
|
"Add --help to any command for just its usage. --version prints the CLI version."
|
|
2264
2271
|
];
|
|
2265
2272
|
var CLI_VERSION = version;
|
|
@@ -4520,13 +4527,17 @@ async function runSetCommand(args, env = process.env) {
|
|
|
4520
4527
|
const logoUrl = clearable(readFlag23(args, "--logo-url"));
|
|
4521
4528
|
const logoAlign = readFlag23(args, "--logo-align");
|
|
4522
4529
|
const logoWidth = readFlag23(args, "--logo-width");
|
|
4530
|
+
const logoName = readFlag23(args, "--logo-name");
|
|
4523
4531
|
const color = readFlag23(args, "--color");
|
|
4524
4532
|
const settingsFile = readFlag23(args, "--settings-file");
|
|
4525
4533
|
if (logoAlign !== void 0 && logoAlign !== "left" && logoAlign !== "center") {
|
|
4526
4534
|
return { exitCode: 1, error: "--logo-align must be left or center" };
|
|
4527
4535
|
}
|
|
4528
|
-
if (
|
|
4529
|
-
return { exitCode: 1, error: "--logo-
|
|
4536
|
+
if (logoName !== void 0 && logoName !== "on" && logoName !== "off") {
|
|
4537
|
+
return { exitCode: 1, error: "--logo-name must be on or off" };
|
|
4538
|
+
}
|
|
4539
|
+
if ((logoAlign !== void 0 || logoWidth !== void 0 || logoName !== void 0) && !logoUrl) {
|
|
4540
|
+
return { exitCode: 1, error: "--logo-align, --logo-width and --logo-name go with --logo-url" };
|
|
4530
4541
|
}
|
|
4531
4542
|
if (logoWidth !== void 0 && !/^\d+$/.test(logoWidth)) return { exitCode: 1, error: "--logo-width must be a whole number of px" };
|
|
4532
4543
|
if (color !== void 0 && !HEX.test(color)) return { exitCode: 1, error: "--color must be a hex colour such as #2f6feb" };
|
|
@@ -4540,7 +4551,12 @@ async function runSetCommand(args, env = process.env) {
|
|
|
4540
4551
|
}
|
|
4541
4552
|
const params = {};
|
|
4542
4553
|
if (logoUrl !== void 0) {
|
|
4543
|
-
params.logo = logoUrl === null ? null : {
|
|
4554
|
+
params.logo = logoUrl === null ? null : {
|
|
4555
|
+
url: logoUrl,
|
|
4556
|
+
align: logoAlign ?? "left",
|
|
4557
|
+
...logoWidth ? { width: Number(logoWidth) } : {},
|
|
4558
|
+
...logoName !== void 0 ? { show_name: logoName === "on" } : {}
|
|
4559
|
+
};
|
|
4544
4560
|
}
|
|
4545
4561
|
const company = clearable(readFlag23(args, "--company"));
|
|
4546
4562
|
const address = clearable(readFlag23(args, "--address"));
|
|
@@ -5298,6 +5314,9 @@ var VALUE_FLAGS7 = [
|
|
|
5298
5314
|
"--send-as",
|
|
5299
5315
|
"--allowed-senders",
|
|
5300
5316
|
"--blocked-senders",
|
|
5317
|
+
"--allow-recipients",
|
|
5318
|
+
"--reason",
|
|
5319
|
+
"--days",
|
|
5301
5320
|
"--api-key",
|
|
5302
5321
|
"--base-url",
|
|
5303
5322
|
"--workspace",
|
|
@@ -5337,6 +5356,10 @@ var USAGE3 = [
|
|
|
5337
5356
|
" groundmail mailboxes create [--local-part signup-bot] [--domain agents.example.com] [--display-name \u2026] [--external-id \u2026] [--tenant <tenant>] [--retention-days 7] [--spam-threshold 5] [--metadata JSON] [--forward-from <mailbox>] [--json]",
|
|
5338
5357
|
" groundmail mailboxes list [--tenant <tenant>] [--limit 25] [--cursor \u2026] [--json]",
|
|
5339
5358
|
" groundmail mailboxes get <mailbox> [--json]",
|
|
5359
|
+
" groundmail mailboxes update <mailbox> [--send-as support@example.com] [--allowed-senders \u2026] [--blocked-senders \u2026] [--allow-recipients acme.com,bob@x.com|none] [--json]",
|
|
5360
|
+
" groundmail mailboxes pause <mailbox> [--reason \u2026] [--json]",
|
|
5361
|
+
" groundmail mailboxes resume <mailbox> [--json]",
|
|
5362
|
+
" groundmail mailboxes usage <mailbox> [--days 30] [--json]",
|
|
5340
5363
|
" groundmail mailboxes delete <mailbox> --yes",
|
|
5341
5364
|
" groundmail mailboxes forward <mailbox> --to <new mailbox> --yes",
|
|
5342
5365
|
" groundmail mailboxes threads <mailbox> [--label \u2026] [--participant \u2026] [--unread] [--archived] [--since <iso>] [--include-held] [--limit 25] [--cursor \u2026] [--json]",
|
|
@@ -5361,12 +5384,27 @@ function formatMailbox(mailbox) {
|
|
|
5361
5384
|
if (mailbox.external_id) lines.push(`Your id: ${mailbox.external_id}`);
|
|
5362
5385
|
if (mailbox.tenant) lines.push(`Tenant: ${mailbox.tenant}`);
|
|
5363
5386
|
if (mailbox.paused_reason) lines.push(`Paused: ${mailbox.paused_reason}`);
|
|
5387
|
+
if (mailbox.allowed_recipients?.length) lines.push(`Sends only to: ${mailbox.allowed_recipients.join(", ")}`);
|
|
5364
5388
|
if (mailbox.forwarding) {
|
|
5365
5389
|
const { to, until, active } = mailbox.forwarding;
|
|
5366
5390
|
lines.push(active ? `Forwards to ${to} until ${until}` : `Stopped forwarding on ${until}: mail is dropped`);
|
|
5367
5391
|
}
|
|
5368
5392
|
return lines.join("\n");
|
|
5369
5393
|
}
|
|
5394
|
+
function percent(rate) {
|
|
5395
|
+
return `${(rate * 100).toFixed(1)}%`;
|
|
5396
|
+
}
|
|
5397
|
+
function formatUsage(usage) {
|
|
5398
|
+
const cost = usage.cost.estimated_usd === null ? "no per-email charge on your plan" : `about $${usage.cost.estimated_usd.toFixed(2)} for ${usage.cost.billable_emails} emails sent and received, at $${usage.cost.per_thousand_usd} per 1,000 (an estimate, before your plan's included emails)`;
|
|
5399
|
+
return [
|
|
5400
|
+
`${usage.address}, last ${usage.days} days`,
|
|
5401
|
+
`Sent: ${usage.sent}`,
|
|
5402
|
+
`Received: ${usage.received}`,
|
|
5403
|
+
`Bounced: ${usage.bounced} (${percent(usage.bounce_rate)})`,
|
|
5404
|
+
`Complaints: ${usage.complained} (${percent(usage.complaint_rate)})`,
|
|
5405
|
+
`Cost: ${cost}`
|
|
5406
|
+
].join("\n");
|
|
5407
|
+
}
|
|
5370
5408
|
function formatSent(result) {
|
|
5371
5409
|
return [`Sent: ${result.message_id}`, `Thread: ${result.thread_id}`, `Email: ${result.email_id}`, `Status: ${result.status}`].join("\n");
|
|
5372
5410
|
}
|
|
@@ -5490,7 +5528,7 @@ async function createInstant(args) {
|
|
|
5490
5528
|
}
|
|
5491
5529
|
}
|
|
5492
5530
|
async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
5493
|
-
if (!subcommand || !["create", "owner", "verify", "list", "get", "update", "delete", "forward", "threads", "read", "wait", "send", "reply"].includes(subcommand)) {
|
|
5531
|
+
if (!subcommand || !["create", "owner", "verify", "list", "get", "update", "pause", "resume", "usage", "delete", "forward", "threads", "read", "wait", "send", "reply"].includes(subcommand)) {
|
|
5494
5532
|
return { exitCode: 1, error: USAGE3 };
|
|
5495
5533
|
}
|
|
5496
5534
|
const parsed = parseArgs(argv, { values: VALUE_FLAGS7, booleans: BOOLEAN_FLAGS });
|
|
@@ -5548,17 +5586,41 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5548
5586
|
const sendAs = args.values["--send-as"];
|
|
5549
5587
|
const allowed = senderList(args.values["--allowed-senders"]);
|
|
5550
5588
|
const blocked = senderList(args.values["--blocked-senders"]);
|
|
5551
|
-
|
|
5552
|
-
|
|
5589
|
+
const recipients = senderList(args.values["--allow-recipients"]);
|
|
5590
|
+
if (sendAs === void 0 && !allowed && !blocked && !recipients) {
|
|
5591
|
+
return { exitCode: 1, error: "Nothing to change. Usage: groundmail mailboxes update <mailbox> [--send-as support@example.com] [--allowed-senders you@example.com,example.com] [--blocked-senders spam.example] [--allow-recipients acme.com,bob@x.com]. Use none to clear one." };
|
|
5553
5592
|
}
|
|
5554
5593
|
const updated = await client3.mailboxes.update(ref, {
|
|
5555
5594
|
...sendAs !== void 0 ? { send_as: sendAs === "none" ? null : sendAs } : {},
|
|
5556
5595
|
...allowed ? { allowed_senders: allowed } : {},
|
|
5557
|
-
...blocked ? { blocked_senders: blocked } : {}
|
|
5596
|
+
...blocked ? { blocked_senders: blocked } : {},
|
|
5597
|
+
...recipients ? { allowed_recipients: recipients } : {}
|
|
5558
5598
|
});
|
|
5559
5599
|
print({ mailbox: updated }, () => formatMailbox(updated));
|
|
5560
5600
|
return { exitCode: 0 };
|
|
5561
5601
|
}
|
|
5602
|
+
if (subcommand === "pause") {
|
|
5603
|
+
const paused = await client3.mailboxes.pause(ref, v["--reason"]);
|
|
5604
|
+
print({ mailbox: paused }, () => `${formatMailbox(paused)}
|
|
5605
|
+
Sending is stopped. It still receives mail. Resume with: groundmail mailboxes resume ${ref}`);
|
|
5606
|
+
return { exitCode: 0 };
|
|
5607
|
+
}
|
|
5608
|
+
if (subcommand === "resume") {
|
|
5609
|
+
const resumed = await client3.mailboxes.resume(ref);
|
|
5610
|
+
print({ mailbox: resumed }, () => `${formatMailbox(resumed)}
|
|
5611
|
+
Sending is on again.`);
|
|
5612
|
+
return { exitCode: 0 };
|
|
5613
|
+
}
|
|
5614
|
+
if (subcommand === "usage") {
|
|
5615
|
+
const days = numberFlag(args, "--days");
|
|
5616
|
+
if (typeof days === "object") return { exitCode: 1, error: days.error };
|
|
5617
|
+
if (days !== void 0 && (!Number.isInteger(days) || days < 1 || days > 90)) {
|
|
5618
|
+
return { exitCode: 1, error: "--days must be a whole number from 1 to 90" };
|
|
5619
|
+
}
|
|
5620
|
+
const usage = await client3.mailboxes.usage(ref, days !== void 0 ? { days } : {});
|
|
5621
|
+
print({ usage }, () => formatUsage(usage));
|
|
5622
|
+
return { exitCode: 0 };
|
|
5623
|
+
}
|
|
5562
5624
|
if (subcommand === "delete") {
|
|
5563
5625
|
if (!on("--yes")) {
|
|
5564
5626
|
return { exitCode: 1, error: "This deletes the mailbox and all its mail. Add --yes to confirm." };
|
|
@@ -5665,8 +5727,195 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5665
5727
|
}
|
|
5666
5728
|
}
|
|
5667
5729
|
|
|
5730
|
+
// src/session/failure.ts
|
|
5731
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
5732
|
+
import { join as join2 } from "path";
|
|
5733
|
+
var FEEDBACK_LINE = "If this should have worked, `groundmail feedback` reports it.";
|
|
5734
|
+
var SECRET_FLAGS = /* @__PURE__ */ new Set(["--api-key", "--auth-token", "--secret", "--code", "--token", "--password", "--account-sid"]);
|
|
5735
|
+
var CONTENT_FLAGS = /* @__PURE__ */ new Set(["--text", "--html", "--data", "--props", "--metadata"]);
|
|
5736
|
+
var REMOVED = "[removed]";
|
|
5737
|
+
function redactText(text) {
|
|
5738
|
+
return text.replace(/\bgm_[A-Za-z0-9_-]{8,}/g, "gm_[removed]").replace(/\b(Bearer)\s+[A-Za-z0-9._~+/=-]{8,}/gi, `$1 ${REMOVED}`);
|
|
5739
|
+
}
|
|
5740
|
+
function redactArgs(argv) {
|
|
5741
|
+
const out = [];
|
|
5742
|
+
for (let i = 0; i < argv.length; i++) {
|
|
5743
|
+
const arg = argv[i];
|
|
5744
|
+
const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
5745
|
+
const name = eq === -1 ? arg : arg.slice(0, eq);
|
|
5746
|
+
const hide = SECRET_FLAGS.has(name) ? () => REMOVED : CONTENT_FLAGS.has(name) ? (value2) => `[${value2.length} characters]` : null;
|
|
5747
|
+
if (!hide) {
|
|
5748
|
+
out.push(redactText(arg));
|
|
5749
|
+
continue;
|
|
5750
|
+
}
|
|
5751
|
+
if (eq !== -1) {
|
|
5752
|
+
out.push(`${name}=${hide(arg.slice(eq + 1))}`);
|
|
5753
|
+
continue;
|
|
5754
|
+
}
|
|
5755
|
+
out.push(name);
|
|
5756
|
+
const value = argv[i + 1];
|
|
5757
|
+
if (value !== void 0 && !value.startsWith("--")) {
|
|
5758
|
+
out.push(hide(value));
|
|
5759
|
+
i++;
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
return out;
|
|
5763
|
+
}
|
|
5764
|
+
function commandName(argv) {
|
|
5765
|
+
const words2 = [];
|
|
5766
|
+
for (const arg of argv) {
|
|
5767
|
+
if (arg.startsWith("-") || words2.length === 2) break;
|
|
5768
|
+
words2.push(arg);
|
|
5769
|
+
}
|
|
5770
|
+
if (words2[1] && /[@._]|\d/.test(words2[1])) words2.pop();
|
|
5771
|
+
return words2.join(" ");
|
|
5772
|
+
}
|
|
5773
|
+
function failurePath(env) {
|
|
5774
|
+
return join2(configDir(env), "last-error.json");
|
|
5775
|
+
}
|
|
5776
|
+
function saveLastFailure(failure3, env = process.env) {
|
|
5777
|
+
try {
|
|
5778
|
+
mkdirSync2(configDir(env), { recursive: true });
|
|
5779
|
+
const path = failurePath(env);
|
|
5780
|
+
writeFileSync2(path, `${JSON.stringify(failure3, null, 2)}
|
|
5781
|
+
`, { mode: 384 });
|
|
5782
|
+
chmodSync2(path, 384);
|
|
5783
|
+
} catch {
|
|
5784
|
+
}
|
|
5785
|
+
}
|
|
5786
|
+
function loadLastFailure(env = process.env) {
|
|
5787
|
+
try {
|
|
5788
|
+
const parsed = JSON.parse(readFileSync2(failurePath(env), "utf8"));
|
|
5789
|
+
return parsed && typeof parsed === "object" && typeof parsed.command === "string" ? parsed : null;
|
|
5790
|
+
} catch {
|
|
5791
|
+
return null;
|
|
5792
|
+
}
|
|
5793
|
+
}
|
|
5794
|
+
function buildFailure(input) {
|
|
5795
|
+
return {
|
|
5796
|
+
at: (input.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
5797
|
+
command: commandName(input.argv),
|
|
5798
|
+
args: redactArgs(input.argv),
|
|
5799
|
+
error: redactText(input.error).slice(0, 2e3),
|
|
5800
|
+
exit_code: input.exitCode,
|
|
5801
|
+
cli_version: input.version,
|
|
5802
|
+
...input.http ? { http: input.http } : {}
|
|
5803
|
+
};
|
|
5804
|
+
}
|
|
5805
|
+
function jsonError(failure3) {
|
|
5806
|
+
const usage = /^(Usage:|Unknown (flag|command)|Missing |Nothing to )/.test(failure3.error);
|
|
5807
|
+
return {
|
|
5808
|
+
error: {
|
|
5809
|
+
message: failure3.http?.message && failure3.error.includes(failure3.http.message) ? failure3.http.message : failure3.error,
|
|
5810
|
+
code: failure3.http?.code ?? (usage ? "usage_error" : "cli_error"),
|
|
5811
|
+
...failure3.http ? { status: failure3.http.status } : {},
|
|
5812
|
+
...failure3.http?.hint ? { hint: failure3.http.hint } : {},
|
|
5813
|
+
...failure3.http?.request_id ? { request_id: failure3.http.request_id } : {},
|
|
5814
|
+
exit_code: failure3.exit_code
|
|
5815
|
+
},
|
|
5816
|
+
feedback: FEEDBACK_LINE
|
|
5817
|
+
};
|
|
5818
|
+
}
|
|
5819
|
+
function recordHttpFailures(target = globalThis) {
|
|
5820
|
+
const original = target.fetch;
|
|
5821
|
+
let last = null;
|
|
5822
|
+
target.fetch = (async (input, init) => {
|
|
5823
|
+
const response = await original(input, init);
|
|
5824
|
+
if (!response.ok) {
|
|
5825
|
+
const url = typeof input === "string" || input instanceof URL ? String(input) : input.url;
|
|
5826
|
+
const body = await response.clone().json().catch(() => null);
|
|
5827
|
+
const nested = body && typeof body.error === "object" && body.error ? body.error : null;
|
|
5828
|
+
const pick = (key) => {
|
|
5829
|
+
const value = nested?.[key] ?? body?.[key];
|
|
5830
|
+
return typeof value === "string" && value ? value : void 0;
|
|
5831
|
+
};
|
|
5832
|
+
let path = url;
|
|
5833
|
+
try {
|
|
5834
|
+
path = new URL(url).pathname;
|
|
5835
|
+
} catch {
|
|
5836
|
+
}
|
|
5837
|
+
last = {
|
|
5838
|
+
method: (init?.method ?? "GET").toUpperCase(),
|
|
5839
|
+
path,
|
|
5840
|
+
status: response.status,
|
|
5841
|
+
code: pick("code"),
|
|
5842
|
+
message: typeof body?.error === "string" ? body.error : pick("message"),
|
|
5843
|
+
hint: pick("hint"),
|
|
5844
|
+
request_id: response.headers.get("x-request-id") ?? void 0
|
|
5845
|
+
};
|
|
5846
|
+
for (const key of Object.keys(last)) if (last[key] === void 0) delete last[key];
|
|
5847
|
+
}
|
|
5848
|
+
return response;
|
|
5849
|
+
});
|
|
5850
|
+
return () => last;
|
|
5851
|
+
}
|
|
5852
|
+
|
|
5853
|
+
// src/commands/feedback.ts
|
|
5854
|
+
var USAGE4 = 'Usage: groundmail feedback "<what happened>" [--no-last] [--json]';
|
|
5855
|
+
var LAST_FAILURE_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
5856
|
+
async function defaultClient(apiKey, baseUrl) {
|
|
5857
|
+
const { Groundmail } = await import("groundmail");
|
|
5858
|
+
return new Groundmail(apiKey, sdkOptions(baseUrl));
|
|
5859
|
+
}
|
|
5860
|
+
function feedbackContext(failure3) {
|
|
5861
|
+
const client3 = { client: CLI_PACKAGE.name, client_version: CLI_PACKAGE.version };
|
|
5862
|
+
if (!failure3) return client3;
|
|
5863
|
+
return {
|
|
5864
|
+
command: failure3.command,
|
|
5865
|
+
args: failure3.args,
|
|
5866
|
+
error: failure3.error,
|
|
5867
|
+
at: failure3.at,
|
|
5868
|
+
...failure3.http ? {
|
|
5869
|
+
method: failure3.http.method,
|
|
5870
|
+
path: failure3.http.path,
|
|
5871
|
+
status: failure3.http.status,
|
|
5872
|
+
...failure3.http.code ? { code: failure3.http.code } : {},
|
|
5873
|
+
...failure3.http.request_id ? { request_id: failure3.http.request_id } : {}
|
|
5874
|
+
} : {},
|
|
5875
|
+
...client3,
|
|
5876
|
+
client_version: failure3.cli_version
|
|
5877
|
+
};
|
|
5878
|
+
}
|
|
5879
|
+
async function runFeedbackCommand(argv, deps = {}) {
|
|
5880
|
+
const env = deps.env ?? process.env;
|
|
5881
|
+
const stdout = deps.stdout ?? ((line) => console.log(line));
|
|
5882
|
+
const parsed = parseArgs(argv, { values: ["--api-key", "--base-url", "--workspace", "--message"], booleans: ["--json", "--last"] });
|
|
5883
|
+
if (!parsed.ok) return { exitCode: 1, error: `${parsed.error}
|
|
5884
|
+
${USAGE4}` };
|
|
5885
|
+
const { args } = parsed;
|
|
5886
|
+
const message = (args.values["--message"] ?? args.positionals.join(" ")).trim();
|
|
5887
|
+
if (!message) return { exitCode: 1, error: `Say what happened.
|
|
5888
|
+
${USAGE4}` };
|
|
5889
|
+
const apiKey = args.values["--api-key"] || env.GROUNDMAIL_API_KEY;
|
|
5890
|
+
if (!apiKey) return { exitCode: 1, error: "Missing API key. Run groundmail login, set GROUNDMAIL_API_KEY or pass --api-key. Or write to support@groundmail.dev." };
|
|
5891
|
+
const now = deps.now ?? /* @__PURE__ */ new Date();
|
|
5892
|
+
const saved = args.booleans["--last"] === false ? null : loadLastFailure(env);
|
|
5893
|
+
const failure3 = saved && now.getTime() - new Date(saved.at).getTime() <= LAST_FAILURE_MAX_AGE_MS ? saved : null;
|
|
5894
|
+
try {
|
|
5895
|
+
const client3 = await (deps.client ?? defaultClient)(apiKey, args.values["--base-url"]);
|
|
5896
|
+
const result = await client3.feedback({ message, context: feedbackContext(failure3) });
|
|
5897
|
+
if (args.booleans["--json"] === true) {
|
|
5898
|
+
stdout(JSON.stringify({ ...result, included: failure3 ? { command: failure3.command, args: failure3.args, error: failure3.error, request_id: failure3.http?.request_id ?? null } : null }));
|
|
5899
|
+
} else {
|
|
5900
|
+
const lines = [`Sent to Groundmail support. Reference: ${result.reference}`];
|
|
5901
|
+
if (failure3) {
|
|
5902
|
+
const detail = [failure3.http ? `HTTP ${failure3.http.status}` : null, failure3.http?.request_id ?? null].filter(Boolean).join(", ");
|
|
5903
|
+
lines.push(`Included your last failed command: groundmail ${failure3.args.join(" ")}${detail ? ` (${detail})` : ""}`);
|
|
5904
|
+
} else {
|
|
5905
|
+
lines.push("No failed command from the last 24 hours was attached.");
|
|
5906
|
+
}
|
|
5907
|
+
stdout(lines.join("\n"));
|
|
5908
|
+
}
|
|
5909
|
+
return { exitCode: 0 };
|
|
5910
|
+
} catch (error) {
|
|
5911
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
5912
|
+
return { exitCode: 1, error: `${reason}
|
|
5913
|
+
The report was not sent. You can also write to support@groundmail.dev.` };
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
|
|
5668
5917
|
// src/commands/cli/search.ts
|
|
5669
|
-
var
|
|
5918
|
+
var USAGE5 = 'Usage: groundmail cli search "<what you want to do>" [--limit 5] [--json]';
|
|
5670
5919
|
var DEFAULT_LIMIT = 5;
|
|
5671
5920
|
var MAX_LIMIT = 20;
|
|
5672
5921
|
var USAGE_WIDTH = 80;
|
|
@@ -5721,7 +5970,11 @@ var SYNONYMS = {
|
|
|
5721
5970
|
};
|
|
5722
5971
|
var KEYWORDS = {
|
|
5723
5972
|
"mailboxes create": "inbox address agent own email",
|
|
5724
|
-
"mailboxes update": "block allow sender stop reach who write send-as agent someone",
|
|
5973
|
+
"mailboxes update": "block allow sender stop reach who write send-as agent someone recipient allowlist restrict limit only",
|
|
5974
|
+
"mailboxes pause": "stop agent sending halt freeze disable kill switch",
|
|
5975
|
+
"mailboxes resume": "unpause restart start sending again enable",
|
|
5976
|
+
"mailboxes usage": "cost spend bill stats how many sent received bounce volume",
|
|
5977
|
+
feedback: "report bug problem broken support help wrong failed error should have worked",
|
|
5725
5978
|
"mailboxes read": "inbox message check mail",
|
|
5726
5979
|
"mailboxes wait": "code verification sign-up magic link next",
|
|
5727
5980
|
"mailboxes reply": "answer respond thread message email",
|
|
@@ -5741,7 +5994,7 @@ var KEYWORDS = {
|
|
|
5741
5994
|
"keys create": "api token secret",
|
|
5742
5995
|
login: "sign-in authenticate account browser"
|
|
5743
5996
|
};
|
|
5744
|
-
var NO_ACCOUNT_NEEDED = /* @__PURE__ */ new Set(["login", "logout", "whoami", "cli search", "validate"]);
|
|
5997
|
+
var NO_ACCOUNT_NEEDED = /* @__PURE__ */ new Set(["login", "logout", "whoami", "cli search", "validate", "feedback"]);
|
|
5745
5998
|
function stem(word) {
|
|
5746
5999
|
if (word.length > 5 && word.endsWith("ing")) return word.slice(0, -3);
|
|
5747
6000
|
if (word.length > 4 && word.endsWith("ies")) return `${word.slice(0, -3)}y`;
|
|
@@ -5834,12 +6087,12 @@ function textOutput(found) {
|
|
|
5834
6087
|
return [...lines, "", "Add --help to any of these for its flags."].join("\n");
|
|
5835
6088
|
}
|
|
5836
6089
|
async function runCliCommand(subcommand, argv) {
|
|
5837
|
-
if (subcommand !== "search") return { exitCode: 1, error:
|
|
6090
|
+
if (subcommand !== "search") return { exitCode: 1, error: USAGE5 };
|
|
5838
6091
|
const parsed = parseArgs(argv, { values: ["--limit"], booleans: ["--json"] });
|
|
5839
6092
|
if (!parsed.ok) return { exitCode: 1, error: `${parsed.error}
|
|
5840
|
-
${
|
|
6093
|
+
${USAGE5}` };
|
|
5841
6094
|
const task = parsed.args.positionals.join(" ").trim();
|
|
5842
|
-
if (!task) return { exitCode: 1, error:
|
|
6095
|
+
if (!task) return { exitCode: 1, error: USAGE5 };
|
|
5843
6096
|
const rawLimit = parsed.args.values["--limit"];
|
|
5844
6097
|
const limit = rawLimit === void 0 ? DEFAULT_LIMIT : Number(rawLimit);
|
|
5845
6098
|
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
|
|
@@ -5856,15 +6109,15 @@ ${USAGE4}` };
|
|
|
5856
6109
|
|
|
5857
6110
|
// src/update-check.ts
|
|
5858
6111
|
import { spawn as spawn2 } from "child_process";
|
|
5859
|
-
import { mkdirSync as
|
|
5860
|
-
import { join as
|
|
6112
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
6113
|
+
import { join as join3 } from "path";
|
|
5861
6114
|
var UPDATE_COMMAND = "npm install -g groundmail-cli@latest";
|
|
5862
6115
|
var REFRESH_COMMAND = "__refresh-update-check";
|
|
5863
6116
|
var REGISTRY_URL = "https://registry.npmjs.org/groundmail-cli/latest";
|
|
5864
6117
|
var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
|
|
5865
6118
|
var REGISTRY_TIMEOUT_MS = 3e3;
|
|
5866
6119
|
function cachePath(env) {
|
|
5867
|
-
return
|
|
6120
|
+
return join3(configDir(env), "update-check.json");
|
|
5868
6121
|
}
|
|
5869
6122
|
function parts(version2) {
|
|
5870
6123
|
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version2.trim());
|
|
@@ -5888,7 +6141,7 @@ function updateCheckEnabled(env, stderrIsTty) {
|
|
|
5888
6141
|
}
|
|
5889
6142
|
function readUpdateCache(env) {
|
|
5890
6143
|
try {
|
|
5891
|
-
const value = JSON.parse(
|
|
6144
|
+
const value = JSON.parse(readFileSync3(cachePath(env), "utf8"));
|
|
5892
6145
|
if (typeof value.checkedAt !== "number") return null;
|
|
5893
6146
|
return { checkedAt: value.checkedAt, latest: typeof value.latest === "string" ? value.latest : null };
|
|
5894
6147
|
} catch {
|
|
@@ -5906,8 +6159,8 @@ async function refreshUpdateCache(env = process.env, fetchImpl = fetch, now = Da
|
|
|
5906
6159
|
} catch {
|
|
5907
6160
|
}
|
|
5908
6161
|
try {
|
|
5909
|
-
|
|
5910
|
-
|
|
6162
|
+
mkdirSync3(configDir(env), { recursive: true });
|
|
6163
|
+
writeFileSync3(cachePath(env), JSON.stringify({ checkedAt: now, latest }));
|
|
5911
6164
|
} catch {
|
|
5912
6165
|
}
|
|
5913
6166
|
}
|
|
@@ -5935,10 +6188,41 @@ ${updateNotice(latest)}
|
|
|
5935
6188
|
function printUsage() {
|
|
5936
6189
|
console.error(fullUsage());
|
|
5937
6190
|
}
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
6191
|
+
var argvAll = process.argv.slice(2);
|
|
6192
|
+
var jsonMode = argvAll.includes("--json");
|
|
6193
|
+
var lastHttpFailure = recordHttpFailures();
|
|
6194
|
+
var errorLines = [];
|
|
6195
|
+
var writeError = console.error.bind(console);
|
|
6196
|
+
console.error = (...parts2) => {
|
|
6197
|
+
const line = parts2.map((part) => typeof part === "string" ? part : String(part)).join(" ");
|
|
6198
|
+
errorLines.push(line);
|
|
6199
|
+
if (!jsonMode) writeError(line);
|
|
6200
|
+
};
|
|
6201
|
+
function fail(exitCode, message, options = {}) {
|
|
6202
|
+
const isFeedback = argvAll[0] === "feedback";
|
|
6203
|
+
const failure3 = buildFailure({ argv: argvAll, error: message, exitCode, version: CLI_VERSION, http: lastHttpFailure() });
|
|
6204
|
+
if (!isFeedback) saveLastFailure(failure3);
|
|
6205
|
+
if (jsonMode) {
|
|
6206
|
+
const body = jsonError(failure3);
|
|
6207
|
+
writeError(JSON.stringify(isFeedback ? { error: body.error } : body));
|
|
6208
|
+
} else {
|
|
6209
|
+
if (!options.printed) writeError(message);
|
|
6210
|
+
if (options.usageHint) writeError(outdatedHint());
|
|
6211
|
+
if (!isFeedback) writeError(`
|
|
6212
|
+
${FEEDBACK_LINE}`);
|
|
6213
|
+
}
|
|
6214
|
+
process.exit(exitCode || 1);
|
|
6215
|
+
}
|
|
6216
|
+
async function finish(result, options = {}) {
|
|
6217
|
+
if (!result.exitCode) {
|
|
6218
|
+
if (jsonMode) for (const line of errorLines) writeError(line);
|
|
6219
|
+
process.exit(0);
|
|
6220
|
+
}
|
|
6221
|
+
const printed = errorLines.join("\n");
|
|
6222
|
+
const message = options.quiet ? printed || result.error : result.error || printed;
|
|
6223
|
+
if (!message) process.exit(result.exitCode);
|
|
6224
|
+
if (!jsonMode && result.error && !options.quiet) writeError(result.error);
|
|
6225
|
+
return fail(result.exitCode, message, { printed: true, usageHint: Boolean(result.error?.startsWith("Usage:")) });
|
|
5942
6226
|
}
|
|
5943
6227
|
async function main() {
|
|
5944
6228
|
const [, , command, subcommand] = process.argv;
|
|
@@ -5962,6 +6246,7 @@ async function main() {
|
|
|
5962
6246
|
const session = await applySavedSession(process.argv.slice(4));
|
|
5963
6247
|
if (session.notice) console.error(session.notice);
|
|
5964
6248
|
const rest = session.argv;
|
|
6249
|
+
if (command === "feedback") await finish(await runFeedbackCommand([...subcommand ? [subcommand] : [], ...rest]));
|
|
5965
6250
|
if (command === "migrate") await finish(await runMigrateCommand(subcommand, rest));
|
|
5966
6251
|
if (command === "validate") await finish(await runValidateCommand([...subcommand ? [subcommand] : [], ...rest]));
|
|
5967
6252
|
if (command === "burrowguard") await finish(await runBurrowGuardCommand(subcommand, rest));
|
|
@@ -5972,252 +6257,159 @@ async function main() {
|
|
|
5972
6257
|
}
|
|
5973
6258
|
if (command === "domains") {
|
|
5974
6259
|
if (subcommand === "add" || subcommand === "create") {
|
|
5975
|
-
|
|
5976
|
-
if (result.error) console.error(result.error);
|
|
5977
|
-
process.exit(result.exitCode);
|
|
6260
|
+
await finish(await runAddCommand(rest));
|
|
5978
6261
|
}
|
|
5979
6262
|
if (subcommand === "apply") {
|
|
5980
|
-
|
|
5981
|
-
if (result.error) console.error(result.error);
|
|
5982
|
-
process.exit(result.exitCode);
|
|
6263
|
+
await finish(await runApplyCommand(rest));
|
|
5983
6264
|
}
|
|
5984
6265
|
if (subcommand === "get") {
|
|
5985
|
-
|
|
5986
|
-
if (result.error) console.error(result.error);
|
|
5987
|
-
process.exit(result.exitCode);
|
|
6266
|
+
await finish(await runGetCommand3(rest));
|
|
5988
6267
|
}
|
|
5989
6268
|
if (subcommand === "list") {
|
|
5990
|
-
|
|
5991
|
-
if (result.error) console.error(result.error);
|
|
5992
|
-
process.exit(result.exitCode);
|
|
6269
|
+
await finish(await runListCommand3(rest));
|
|
5993
6270
|
}
|
|
5994
6271
|
if (subcommand === "delete" || subcommand === "remove") {
|
|
5995
|
-
|
|
5996
|
-
if (result.error) console.error(result.error);
|
|
5997
|
-
process.exit(result.exitCode);
|
|
6272
|
+
await finish(await runDeleteCommand2(rest));
|
|
5998
6273
|
}
|
|
5999
6274
|
if (subcommand === "update") {
|
|
6000
|
-
|
|
6001
|
-
if (result.error) console.error(result.error);
|
|
6002
|
-
process.exit(result.exitCode);
|
|
6275
|
+
await finish(await runUpdateCommand2(rest));
|
|
6003
6276
|
}
|
|
6004
6277
|
if (subcommand === "verify") {
|
|
6005
|
-
|
|
6006
|
-
if (result.error) console.error(result.error);
|
|
6007
|
-
process.exit(result.exitCode);
|
|
6278
|
+
await finish(await runVerifyCommand(rest));
|
|
6008
6279
|
}
|
|
6009
6280
|
}
|
|
6010
6281
|
if (command === "received-emails") {
|
|
6011
6282
|
if (subcommand === "list") {
|
|
6012
|
-
|
|
6013
|
-
if (result.error) console.error(result.error);
|
|
6014
|
-
process.exit(result.exitCode);
|
|
6283
|
+
await finish(await runListCommand4(rest));
|
|
6015
6284
|
}
|
|
6016
6285
|
if (subcommand === "get") {
|
|
6017
|
-
|
|
6018
|
-
if (result.error) console.error(result.error);
|
|
6019
|
-
process.exit(result.exitCode);
|
|
6286
|
+
await finish(await runGetCommand4(rest));
|
|
6020
6287
|
}
|
|
6021
6288
|
}
|
|
6022
6289
|
if (command === "emails") {
|
|
6023
6290
|
if (subcommand === "send") {
|
|
6024
|
-
|
|
6025
|
-
process.exit(result.exitCode);
|
|
6291
|
+
await finish(await runSendCommandWithClient(rest), { quiet: true });
|
|
6026
6292
|
}
|
|
6027
6293
|
if (subcommand === "batch") {
|
|
6028
|
-
|
|
6029
|
-
if (result.error) console.error(result.error);
|
|
6030
|
-
process.exit(result.exitCode);
|
|
6294
|
+
await finish(await runBatchCommandWithClient(rest));
|
|
6031
6295
|
}
|
|
6032
6296
|
if (subcommand === "cancel") {
|
|
6033
|
-
|
|
6034
|
-
if (result.error) console.error(result.error);
|
|
6035
|
-
process.exit(result.exitCode);
|
|
6297
|
+
await finish(await runCancelCommandWithClient(rest));
|
|
6036
6298
|
}
|
|
6037
6299
|
if (subcommand === "resend") {
|
|
6038
|
-
|
|
6039
|
-
if (result.error) console.error(result.error);
|
|
6040
|
-
process.exit(result.exitCode);
|
|
6300
|
+
await finish(await runResendCommandWithClient(rest));
|
|
6041
6301
|
}
|
|
6042
6302
|
if (subcommand === "list") {
|
|
6043
|
-
|
|
6044
|
-
if (result.error) console.error(result.error);
|
|
6045
|
-
process.exit(result.exitCode);
|
|
6303
|
+
await finish(await runListCommandWithClient(rest));
|
|
6046
6304
|
}
|
|
6047
6305
|
if (subcommand === "insights") {
|
|
6048
|
-
|
|
6049
|
-
if (result.error) console.error(result.error);
|
|
6050
|
-
process.exit(result.exitCode);
|
|
6306
|
+
await finish(await runInsightsCommandWithClient(rest));
|
|
6051
6307
|
}
|
|
6052
6308
|
if (subcommand === "get") {
|
|
6053
|
-
|
|
6054
|
-
if (result.error) console.error(result.error);
|
|
6055
|
-
process.exit(result.exitCode);
|
|
6309
|
+
await finish(await runGetCommandWithClient(rest));
|
|
6056
6310
|
}
|
|
6057
6311
|
}
|
|
6058
6312
|
if (command === "events") {
|
|
6059
6313
|
if (subcommand === "send" || subcommand === "trigger") {
|
|
6060
|
-
|
|
6061
|
-
if (result.error) console.error(result.error);
|
|
6062
|
-
process.exit(result.exitCode);
|
|
6314
|
+
await finish(await runSendEventCommand(rest));
|
|
6063
6315
|
}
|
|
6064
6316
|
}
|
|
6065
6317
|
if (command === "automations") {
|
|
6066
6318
|
if (subcommand === "list") {
|
|
6067
|
-
|
|
6068
|
-
if (result.error) console.error(result.error);
|
|
6069
|
-
process.exit(result.exitCode);
|
|
6319
|
+
await finish(await runListCommand2(rest));
|
|
6070
6320
|
}
|
|
6071
6321
|
if (subcommand === "get") {
|
|
6072
|
-
|
|
6073
|
-
if (result.error) console.error(result.error);
|
|
6074
|
-
process.exit(result.exitCode);
|
|
6322
|
+
await finish(await runGetCommand2(rest));
|
|
6075
6323
|
}
|
|
6076
6324
|
if (subcommand === "create" || subcommand === "add") {
|
|
6077
|
-
|
|
6078
|
-
if (result.error) console.error(result.error);
|
|
6079
|
-
process.exit(result.exitCode);
|
|
6325
|
+
await finish(await runCreateCommand(rest));
|
|
6080
6326
|
}
|
|
6081
6327
|
if (subcommand === "update") {
|
|
6082
|
-
|
|
6083
|
-
if (result.error) console.error(result.error);
|
|
6084
|
-
process.exit(result.exitCode);
|
|
6328
|
+
await finish(await runUpdateCommand(rest));
|
|
6085
6329
|
}
|
|
6086
6330
|
if (subcommand === "activate") {
|
|
6087
|
-
|
|
6088
|
-
if (result.error) console.error(result.error);
|
|
6089
|
-
process.exit(result.exitCode);
|
|
6331
|
+
await finish(await runActivateCommand(rest));
|
|
6090
6332
|
}
|
|
6091
6333
|
if (subcommand === "pause") {
|
|
6092
|
-
|
|
6093
|
-
if (result.error) console.error(result.error);
|
|
6094
|
-
process.exit(result.exitCode);
|
|
6334
|
+
await finish(await runPauseCommand(rest));
|
|
6095
6335
|
}
|
|
6096
6336
|
if (subcommand === "delete" || subcommand === "remove") {
|
|
6097
|
-
|
|
6098
|
-
if (result.error) console.error(result.error);
|
|
6099
|
-
process.exit(result.exitCode);
|
|
6337
|
+
await finish(await runDeleteCommand(rest));
|
|
6100
6338
|
}
|
|
6101
6339
|
}
|
|
6102
6340
|
if (command === "webhooks") {
|
|
6103
6341
|
if (subcommand === "deliveries") {
|
|
6104
|
-
|
|
6105
|
-
if (result.error) console.error(result.error);
|
|
6106
|
-
process.exit(result.exitCode);
|
|
6342
|
+
await finish(await runDeliveriesCommand(rest));
|
|
6107
6343
|
}
|
|
6108
6344
|
if (subcommand === "list") {
|
|
6109
|
-
|
|
6110
|
-
if (result.error) console.error(result.error);
|
|
6111
|
-
process.exit(result.exitCode);
|
|
6345
|
+
await finish(await runListCommand5(rest));
|
|
6112
6346
|
}
|
|
6113
6347
|
if (subcommand === "get") {
|
|
6114
|
-
|
|
6115
|
-
if (result.error) console.error(result.error);
|
|
6116
|
-
process.exit(result.exitCode);
|
|
6348
|
+
await finish(await runGetCommand5(rest));
|
|
6117
6349
|
}
|
|
6118
6350
|
if (subcommand === "create") {
|
|
6119
|
-
|
|
6120
|
-
if (result.error) console.error(result.error);
|
|
6121
|
-
process.exit(result.exitCode);
|
|
6351
|
+
await finish(await runCreateCommand2(rest));
|
|
6122
6352
|
}
|
|
6123
6353
|
if (subcommand === "update") {
|
|
6124
|
-
|
|
6125
|
-
if (result.error) console.error(result.error);
|
|
6126
|
-
process.exit(result.exitCode);
|
|
6354
|
+
await finish(await runUpdateCommand3(rest));
|
|
6127
6355
|
}
|
|
6128
6356
|
if (subcommand === "delete") {
|
|
6129
|
-
|
|
6130
|
-
if (result.error) console.error(result.error);
|
|
6131
|
-
process.exit(result.exitCode);
|
|
6357
|
+
await finish(await runDeleteCommand3(rest));
|
|
6132
6358
|
}
|
|
6133
6359
|
}
|
|
6134
6360
|
if (command === "suppressions") {
|
|
6135
6361
|
if (subcommand === "list") {
|
|
6136
|
-
|
|
6137
|
-
if (result.error) console.error(result.error);
|
|
6138
|
-
process.exit(result.exitCode);
|
|
6362
|
+
await finish(await runListCommand6(rest));
|
|
6139
6363
|
}
|
|
6140
6364
|
if (subcommand === "add" || subcommand === "create") {
|
|
6141
|
-
|
|
6142
|
-
if (result.error) console.error(result.error);
|
|
6143
|
-
process.exit(result.exitCode);
|
|
6365
|
+
await finish(await runAddCommand2(rest));
|
|
6144
6366
|
}
|
|
6145
6367
|
if (subcommand === "remove" || subcommand === "delete") {
|
|
6146
|
-
|
|
6147
|
-
if (result.error) console.error(result.error);
|
|
6148
|
-
process.exit(result.exitCode);
|
|
6368
|
+
await finish(await runRemoveCommand(rest));
|
|
6149
6369
|
}
|
|
6150
6370
|
}
|
|
6151
6371
|
if (command === "routes") {
|
|
6152
|
-
|
|
6153
|
-
if (result.error) console.error(result.error);
|
|
6154
|
-
process.exit(result.exitCode);
|
|
6372
|
+
await finish(await runRoutesCommand(subcommand, rest));
|
|
6155
6373
|
}
|
|
6156
6374
|
if (command === "templates") {
|
|
6157
6375
|
if (subcommand === "list") {
|
|
6158
|
-
|
|
6159
|
-
if (result.error) console.error(result.error);
|
|
6160
|
-
process.exit(result.exitCode);
|
|
6376
|
+
await finish(await runListCommand7(rest));
|
|
6161
6377
|
}
|
|
6162
6378
|
if (subcommand === "starters") {
|
|
6163
|
-
|
|
6164
|
-
if (result.error) console.error(result.error);
|
|
6165
|
-
process.exit(result.exitCode);
|
|
6379
|
+
await finish(await runListStartersCommand(rest));
|
|
6166
6380
|
}
|
|
6167
6381
|
if (subcommand === "from-starter") {
|
|
6168
|
-
|
|
6169
|
-
if (result.error) console.error(result.error);
|
|
6170
|
-
process.exit(result.exitCode);
|
|
6382
|
+
await finish(await runFromStarterCommand(rest));
|
|
6171
6383
|
}
|
|
6172
6384
|
if (subcommand === "create" || subcommand === "add") {
|
|
6173
|
-
|
|
6174
|
-
if (result.error) console.error(result.error);
|
|
6175
|
-
process.exit(result.exitCode);
|
|
6385
|
+
await finish(await runCreateCommand3(rest));
|
|
6176
6386
|
}
|
|
6177
6387
|
if (subcommand === "get") {
|
|
6178
|
-
|
|
6179
|
-
if (result.error) console.error(result.error);
|
|
6180
|
-
process.exit(result.exitCode);
|
|
6388
|
+
await finish(await runGetCommand6(rest));
|
|
6181
6389
|
}
|
|
6182
6390
|
if (subcommand === "update") {
|
|
6183
|
-
|
|
6184
|
-
if (result.error) console.error(result.error);
|
|
6185
|
-
process.exit(result.exitCode);
|
|
6391
|
+
await finish(await runUpdateCommand4(rest));
|
|
6186
6392
|
}
|
|
6187
6393
|
if (subcommand === "publish") {
|
|
6188
|
-
|
|
6189
|
-
if (result.error) console.error(result.error);
|
|
6190
|
-
process.exit(result.exitCode);
|
|
6394
|
+
await finish(await runPublishCommand(rest));
|
|
6191
6395
|
}
|
|
6192
6396
|
if (subcommand === "push") {
|
|
6193
|
-
|
|
6194
|
-
if (result.error) console.error(result.error);
|
|
6195
|
-
process.exit(result.exitCode);
|
|
6397
|
+
await finish(await runPushCommand(rest));
|
|
6196
6398
|
}
|
|
6197
6399
|
if (subcommand === "versions") {
|
|
6198
|
-
|
|
6199
|
-
if (result.error) console.error(result.error);
|
|
6200
|
-
process.exit(result.exitCode);
|
|
6400
|
+
await finish(await runVersionsCommand(rest));
|
|
6201
6401
|
}
|
|
6202
6402
|
if (subcommand === "restore") {
|
|
6203
|
-
|
|
6204
|
-
if (result.error) console.error(result.error);
|
|
6205
|
-
process.exit(result.exitCode);
|
|
6403
|
+
await finish(await runRestoreCommand(rest));
|
|
6206
6404
|
}
|
|
6207
6405
|
if (subcommand === "test-send") {
|
|
6208
|
-
|
|
6209
|
-
if (result.error) console.error(result.error);
|
|
6210
|
-
process.exit(result.exitCode);
|
|
6406
|
+
await finish(await runTestSendCommand(rest));
|
|
6211
6407
|
}
|
|
6212
6408
|
if (subcommand === "duplicate") {
|
|
6213
|
-
|
|
6214
|
-
if (result.error) console.error(result.error);
|
|
6215
|
-
process.exit(result.exitCode);
|
|
6409
|
+
await finish(await runDuplicateCommand(rest));
|
|
6216
6410
|
}
|
|
6217
6411
|
if (subcommand === "delete" || subcommand === "remove") {
|
|
6218
|
-
|
|
6219
|
-
if (result.error) console.error(result.error);
|
|
6220
|
-
process.exit(result.exitCode);
|
|
6412
|
+
await finish(await runDeleteCommand4(rest));
|
|
6221
6413
|
}
|
|
6222
6414
|
}
|
|
6223
6415
|
if (command === "integrations") {
|
|
@@ -6225,19 +6417,13 @@ async function main() {
|
|
|
6225
6417
|
const action = rest[0];
|
|
6226
6418
|
const actionArgs = rest.slice(1);
|
|
6227
6419
|
if (action === "status" || action === "get") {
|
|
6228
|
-
|
|
6229
|
-
if (result.error) console.error(result.error);
|
|
6230
|
-
process.exit(result.exitCode);
|
|
6420
|
+
await finish(await runTwilioStatusCommand(actionArgs));
|
|
6231
6421
|
}
|
|
6232
6422
|
if (action === "connect" || action === "set") {
|
|
6233
|
-
|
|
6234
|
-
if (result.error) console.error(result.error);
|
|
6235
|
-
process.exit(result.exitCode);
|
|
6423
|
+
await finish(await runTwilioConnectCommand(actionArgs));
|
|
6236
6424
|
}
|
|
6237
6425
|
if (action === "disconnect" || action === "delete" || action === "remove") {
|
|
6238
|
-
|
|
6239
|
-
if (result.error) console.error(result.error);
|
|
6240
|
-
process.exit(result.exitCode);
|
|
6426
|
+
await finish(await runTwilioDisconnectCommand(actionArgs));
|
|
6241
6427
|
}
|
|
6242
6428
|
}
|
|
6243
6429
|
}
|
|
@@ -6269,27 +6455,25 @@ async function main() {
|
|
|
6269
6455
|
}
|
|
6270
6456
|
if (command === "keys") {
|
|
6271
6457
|
if (subcommand === "list") {
|
|
6272
|
-
|
|
6273
|
-
if (result.error) console.error(result.error);
|
|
6274
|
-
process.exit(result.exitCode);
|
|
6458
|
+
await finish(await runListKeysCommandWithClient(rest));
|
|
6275
6459
|
}
|
|
6276
6460
|
if (subcommand === "create") {
|
|
6277
|
-
|
|
6278
|
-
if (result.error) console.error(result.error);
|
|
6279
|
-
process.exit(result.exitCode);
|
|
6461
|
+
await finish(await runCreateKeyCommandWithClient(rest));
|
|
6280
6462
|
}
|
|
6281
6463
|
if (subcommand === "delete") {
|
|
6282
|
-
|
|
6283
|
-
if (result.error) console.error(result.error);
|
|
6284
|
-
process.exit(result.exitCode);
|
|
6464
|
+
await finish(await runDeleteKeyCommandWithClient(rest));
|
|
6285
6465
|
}
|
|
6286
6466
|
}
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6467
|
+
if (!command) {
|
|
6468
|
+
printUsage();
|
|
6469
|
+
process.exit(1);
|
|
6470
|
+
}
|
|
6471
|
+
if (!jsonMode) printUsage();
|
|
6472
|
+
const unknown = unknownCommandMessage(process.argv.slice(2));
|
|
6473
|
+
if (!jsonMode) writeError(`
|
|
6474
|
+
${unknown}`);
|
|
6475
|
+
fail(1, unknown, { printed: true });
|
|
6291
6476
|
}
|
|
6292
6477
|
main().catch((error) => {
|
|
6293
|
-
|
|
6294
|
-
process.exit(1);
|
|
6478
|
+
fail(1, error instanceof Error ? error.message : String(error));
|
|
6295
6479
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groundmail-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Groundmail CLI: send email and manage mailboxes from the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"groundmail": "0.
|
|
41
|
+
"groundmail": "0.54.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^9.0.0",
|