groundmail-cli 0.51.0 → 0.52.1
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 +361 -186
- 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.1";
|
|
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]",
|
|
@@ -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;
|
|
@@ -5307,6 +5314,9 @@ var VALUE_FLAGS7 = [
|
|
|
5307
5314
|
"--send-as",
|
|
5308
5315
|
"--allowed-senders",
|
|
5309
5316
|
"--blocked-senders",
|
|
5317
|
+
"--allow-recipients",
|
|
5318
|
+
"--reason",
|
|
5319
|
+
"--days",
|
|
5310
5320
|
"--api-key",
|
|
5311
5321
|
"--base-url",
|
|
5312
5322
|
"--workspace",
|
|
@@ -5346,6 +5356,10 @@ var USAGE3 = [
|
|
|
5346
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]",
|
|
5347
5357
|
" groundmail mailboxes list [--tenant <tenant>] [--limit 25] [--cursor \u2026] [--json]",
|
|
5348
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]",
|
|
5349
5363
|
" groundmail mailboxes delete <mailbox> --yes",
|
|
5350
5364
|
" groundmail mailboxes forward <mailbox> --to <new mailbox> --yes",
|
|
5351
5365
|
" groundmail mailboxes threads <mailbox> [--label \u2026] [--participant \u2026] [--unread] [--archived] [--since <iso>] [--include-held] [--limit 25] [--cursor \u2026] [--json]",
|
|
@@ -5370,12 +5384,27 @@ function formatMailbox(mailbox) {
|
|
|
5370
5384
|
if (mailbox.external_id) lines.push(`Your id: ${mailbox.external_id}`);
|
|
5371
5385
|
if (mailbox.tenant) lines.push(`Tenant: ${mailbox.tenant}`);
|
|
5372
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(", ")}`);
|
|
5373
5388
|
if (mailbox.forwarding) {
|
|
5374
5389
|
const { to, until, active } = mailbox.forwarding;
|
|
5375
5390
|
lines.push(active ? `Forwards to ${to} until ${until}` : `Stopped forwarding on ${until}: mail is dropped`);
|
|
5376
5391
|
}
|
|
5377
5392
|
return lines.join("\n");
|
|
5378
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
|
+
}
|
|
5379
5408
|
function formatSent(result) {
|
|
5380
5409
|
return [`Sent: ${result.message_id}`, `Thread: ${result.thread_id}`, `Email: ${result.email_id}`, `Status: ${result.status}`].join("\n");
|
|
5381
5410
|
}
|
|
@@ -5499,7 +5528,7 @@ async function createInstant(args) {
|
|
|
5499
5528
|
}
|
|
5500
5529
|
}
|
|
5501
5530
|
async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
5502
|
-
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)) {
|
|
5503
5532
|
return { exitCode: 1, error: USAGE3 };
|
|
5504
5533
|
}
|
|
5505
5534
|
const parsed = parseArgs(argv, { values: VALUE_FLAGS7, booleans: BOOLEAN_FLAGS });
|
|
@@ -5557,17 +5586,41 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5557
5586
|
const sendAs = args.values["--send-as"];
|
|
5558
5587
|
const allowed = senderList(args.values["--allowed-senders"]);
|
|
5559
5588
|
const blocked = senderList(args.values["--blocked-senders"]);
|
|
5560
|
-
|
|
5561
|
-
|
|
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." };
|
|
5562
5592
|
}
|
|
5563
5593
|
const updated = await client3.mailboxes.update(ref, {
|
|
5564
5594
|
...sendAs !== void 0 ? { send_as: sendAs === "none" ? null : sendAs } : {},
|
|
5565
5595
|
...allowed ? { allowed_senders: allowed } : {},
|
|
5566
|
-
...blocked ? { blocked_senders: blocked } : {}
|
|
5596
|
+
...blocked ? { blocked_senders: blocked } : {},
|
|
5597
|
+
...recipients ? { allowed_recipients: recipients } : {}
|
|
5567
5598
|
});
|
|
5568
5599
|
print({ mailbox: updated }, () => formatMailbox(updated));
|
|
5569
5600
|
return { exitCode: 0 };
|
|
5570
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
|
+
}
|
|
5571
5624
|
if (subcommand === "delete") {
|
|
5572
5625
|
if (!on("--yes")) {
|
|
5573
5626
|
return { exitCode: 1, error: "This deletes the mailbox and all its mail. Add --yes to confirm." };
|
|
@@ -5674,8 +5727,195 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
|
|
|
5674
5727
|
}
|
|
5675
5728
|
}
|
|
5676
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
|
+
|
|
5677
5917
|
// src/commands/cli/search.ts
|
|
5678
|
-
var
|
|
5918
|
+
var USAGE5 = 'Usage: groundmail cli search "<what you want to do>" [--limit 5] [--json]';
|
|
5679
5919
|
var DEFAULT_LIMIT = 5;
|
|
5680
5920
|
var MAX_LIMIT = 20;
|
|
5681
5921
|
var USAGE_WIDTH = 80;
|
|
@@ -5730,7 +5970,11 @@ var SYNONYMS = {
|
|
|
5730
5970
|
};
|
|
5731
5971
|
var KEYWORDS = {
|
|
5732
5972
|
"mailboxes create": "inbox address agent own email",
|
|
5733
|
-
"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",
|
|
5734
5978
|
"mailboxes read": "inbox message check mail",
|
|
5735
5979
|
"mailboxes wait": "code verification sign-up magic link next",
|
|
5736
5980
|
"mailboxes reply": "answer respond thread message email",
|
|
@@ -5750,7 +5994,7 @@ var KEYWORDS = {
|
|
|
5750
5994
|
"keys create": "api token secret",
|
|
5751
5995
|
login: "sign-in authenticate account browser"
|
|
5752
5996
|
};
|
|
5753
|
-
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"]);
|
|
5754
5998
|
function stem(word) {
|
|
5755
5999
|
if (word.length > 5 && word.endsWith("ing")) return word.slice(0, -3);
|
|
5756
6000
|
if (word.length > 4 && word.endsWith("ies")) return `${word.slice(0, -3)}y`;
|
|
@@ -5843,12 +6087,12 @@ function textOutput(found) {
|
|
|
5843
6087
|
return [...lines, "", "Add --help to any of these for its flags."].join("\n");
|
|
5844
6088
|
}
|
|
5845
6089
|
async function runCliCommand(subcommand, argv) {
|
|
5846
|
-
if (subcommand !== "search") return { exitCode: 1, error:
|
|
6090
|
+
if (subcommand !== "search") return { exitCode: 1, error: USAGE5 };
|
|
5847
6091
|
const parsed = parseArgs(argv, { values: ["--limit"], booleans: ["--json"] });
|
|
5848
6092
|
if (!parsed.ok) return { exitCode: 1, error: `${parsed.error}
|
|
5849
|
-
${
|
|
6093
|
+
${USAGE5}` };
|
|
5850
6094
|
const task = parsed.args.positionals.join(" ").trim();
|
|
5851
|
-
if (!task) return { exitCode: 1, error:
|
|
6095
|
+
if (!task) return { exitCode: 1, error: USAGE5 };
|
|
5852
6096
|
const rawLimit = parsed.args.values["--limit"];
|
|
5853
6097
|
const limit = rawLimit === void 0 ? DEFAULT_LIMIT : Number(rawLimit);
|
|
5854
6098
|
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
|
|
@@ -5865,15 +6109,15 @@ ${USAGE4}` };
|
|
|
5865
6109
|
|
|
5866
6110
|
// src/update-check.ts
|
|
5867
6111
|
import { spawn as spawn2 } from "child_process";
|
|
5868
|
-
import { mkdirSync as
|
|
5869
|
-
import { join as
|
|
6112
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
6113
|
+
import { join as join3 } from "path";
|
|
5870
6114
|
var UPDATE_COMMAND = "npm install -g groundmail-cli@latest";
|
|
5871
6115
|
var REFRESH_COMMAND = "__refresh-update-check";
|
|
5872
6116
|
var REGISTRY_URL = "https://registry.npmjs.org/groundmail-cli/latest";
|
|
5873
6117
|
var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
|
|
5874
6118
|
var REGISTRY_TIMEOUT_MS = 3e3;
|
|
5875
6119
|
function cachePath(env) {
|
|
5876
|
-
return
|
|
6120
|
+
return join3(configDir(env), "update-check.json");
|
|
5877
6121
|
}
|
|
5878
6122
|
function parts(version2) {
|
|
5879
6123
|
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version2.trim());
|
|
@@ -5897,7 +6141,7 @@ function updateCheckEnabled(env, stderrIsTty) {
|
|
|
5897
6141
|
}
|
|
5898
6142
|
function readUpdateCache(env) {
|
|
5899
6143
|
try {
|
|
5900
|
-
const value = JSON.parse(
|
|
6144
|
+
const value = JSON.parse(readFileSync3(cachePath(env), "utf8"));
|
|
5901
6145
|
if (typeof value.checkedAt !== "number") return null;
|
|
5902
6146
|
return { checkedAt: value.checkedAt, latest: typeof value.latest === "string" ? value.latest : null };
|
|
5903
6147
|
} catch {
|
|
@@ -5915,8 +6159,8 @@ async function refreshUpdateCache(env = process.env, fetchImpl = fetch, now = Da
|
|
|
5915
6159
|
} catch {
|
|
5916
6160
|
}
|
|
5917
6161
|
try {
|
|
5918
|
-
|
|
5919
|
-
|
|
6162
|
+
mkdirSync3(configDir(env), { recursive: true });
|
|
6163
|
+
writeFileSync3(cachePath(env), JSON.stringify({ checkedAt: now, latest }));
|
|
5920
6164
|
} catch {
|
|
5921
6165
|
}
|
|
5922
6166
|
}
|
|
@@ -5944,10 +6188,41 @@ ${updateNotice(latest)}
|
|
|
5944
6188
|
function printUsage() {
|
|
5945
6189
|
console.error(fullUsage());
|
|
5946
6190
|
}
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
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:")) });
|
|
5951
6226
|
}
|
|
5952
6227
|
async function main() {
|
|
5953
6228
|
const [, , command, subcommand] = process.argv;
|
|
@@ -5971,6 +6246,7 @@ async function main() {
|
|
|
5971
6246
|
const session = await applySavedSession(process.argv.slice(4));
|
|
5972
6247
|
if (session.notice) console.error(session.notice);
|
|
5973
6248
|
const rest = session.argv;
|
|
6249
|
+
if (command === "feedback") await finish(await runFeedbackCommand([...subcommand ? [subcommand] : [], ...rest]));
|
|
5974
6250
|
if (command === "migrate") await finish(await runMigrateCommand(subcommand, rest));
|
|
5975
6251
|
if (command === "validate") await finish(await runValidateCommand([...subcommand ? [subcommand] : [], ...rest]));
|
|
5976
6252
|
if (command === "burrowguard") await finish(await runBurrowGuardCommand(subcommand, rest));
|
|
@@ -5981,252 +6257,159 @@ async function main() {
|
|
|
5981
6257
|
}
|
|
5982
6258
|
if (command === "domains") {
|
|
5983
6259
|
if (subcommand === "add" || subcommand === "create") {
|
|
5984
|
-
|
|
5985
|
-
if (result.error) console.error(result.error);
|
|
5986
|
-
process.exit(result.exitCode);
|
|
6260
|
+
await finish(await runAddCommand(rest));
|
|
5987
6261
|
}
|
|
5988
6262
|
if (subcommand === "apply") {
|
|
5989
|
-
|
|
5990
|
-
if (result.error) console.error(result.error);
|
|
5991
|
-
process.exit(result.exitCode);
|
|
6263
|
+
await finish(await runApplyCommand(rest));
|
|
5992
6264
|
}
|
|
5993
6265
|
if (subcommand === "get") {
|
|
5994
|
-
|
|
5995
|
-
if (result.error) console.error(result.error);
|
|
5996
|
-
process.exit(result.exitCode);
|
|
6266
|
+
await finish(await runGetCommand3(rest));
|
|
5997
6267
|
}
|
|
5998
6268
|
if (subcommand === "list") {
|
|
5999
|
-
|
|
6000
|
-
if (result.error) console.error(result.error);
|
|
6001
|
-
process.exit(result.exitCode);
|
|
6269
|
+
await finish(await runListCommand3(rest));
|
|
6002
6270
|
}
|
|
6003
6271
|
if (subcommand === "delete" || subcommand === "remove") {
|
|
6004
|
-
|
|
6005
|
-
if (result.error) console.error(result.error);
|
|
6006
|
-
process.exit(result.exitCode);
|
|
6272
|
+
await finish(await runDeleteCommand2(rest));
|
|
6007
6273
|
}
|
|
6008
6274
|
if (subcommand === "update") {
|
|
6009
|
-
|
|
6010
|
-
if (result.error) console.error(result.error);
|
|
6011
|
-
process.exit(result.exitCode);
|
|
6275
|
+
await finish(await runUpdateCommand2(rest));
|
|
6012
6276
|
}
|
|
6013
6277
|
if (subcommand === "verify") {
|
|
6014
|
-
|
|
6015
|
-
if (result.error) console.error(result.error);
|
|
6016
|
-
process.exit(result.exitCode);
|
|
6278
|
+
await finish(await runVerifyCommand(rest));
|
|
6017
6279
|
}
|
|
6018
6280
|
}
|
|
6019
6281
|
if (command === "received-emails") {
|
|
6020
6282
|
if (subcommand === "list") {
|
|
6021
|
-
|
|
6022
|
-
if (result.error) console.error(result.error);
|
|
6023
|
-
process.exit(result.exitCode);
|
|
6283
|
+
await finish(await runListCommand4(rest));
|
|
6024
6284
|
}
|
|
6025
6285
|
if (subcommand === "get") {
|
|
6026
|
-
|
|
6027
|
-
if (result.error) console.error(result.error);
|
|
6028
|
-
process.exit(result.exitCode);
|
|
6286
|
+
await finish(await runGetCommand4(rest));
|
|
6029
6287
|
}
|
|
6030
6288
|
}
|
|
6031
6289
|
if (command === "emails") {
|
|
6032
6290
|
if (subcommand === "send") {
|
|
6033
|
-
|
|
6034
|
-
process.exit(result.exitCode);
|
|
6291
|
+
await finish(await runSendCommandWithClient(rest), { quiet: true });
|
|
6035
6292
|
}
|
|
6036
6293
|
if (subcommand === "batch") {
|
|
6037
|
-
|
|
6038
|
-
if (result.error) console.error(result.error);
|
|
6039
|
-
process.exit(result.exitCode);
|
|
6294
|
+
await finish(await runBatchCommandWithClient(rest));
|
|
6040
6295
|
}
|
|
6041
6296
|
if (subcommand === "cancel") {
|
|
6042
|
-
|
|
6043
|
-
if (result.error) console.error(result.error);
|
|
6044
|
-
process.exit(result.exitCode);
|
|
6297
|
+
await finish(await runCancelCommandWithClient(rest));
|
|
6045
6298
|
}
|
|
6046
6299
|
if (subcommand === "resend") {
|
|
6047
|
-
|
|
6048
|
-
if (result.error) console.error(result.error);
|
|
6049
|
-
process.exit(result.exitCode);
|
|
6300
|
+
await finish(await runResendCommandWithClient(rest));
|
|
6050
6301
|
}
|
|
6051
6302
|
if (subcommand === "list") {
|
|
6052
|
-
|
|
6053
|
-
if (result.error) console.error(result.error);
|
|
6054
|
-
process.exit(result.exitCode);
|
|
6303
|
+
await finish(await runListCommandWithClient(rest));
|
|
6055
6304
|
}
|
|
6056
6305
|
if (subcommand === "insights") {
|
|
6057
|
-
|
|
6058
|
-
if (result.error) console.error(result.error);
|
|
6059
|
-
process.exit(result.exitCode);
|
|
6306
|
+
await finish(await runInsightsCommandWithClient(rest));
|
|
6060
6307
|
}
|
|
6061
6308
|
if (subcommand === "get") {
|
|
6062
|
-
|
|
6063
|
-
if (result.error) console.error(result.error);
|
|
6064
|
-
process.exit(result.exitCode);
|
|
6309
|
+
await finish(await runGetCommandWithClient(rest));
|
|
6065
6310
|
}
|
|
6066
6311
|
}
|
|
6067
6312
|
if (command === "events") {
|
|
6068
6313
|
if (subcommand === "send" || subcommand === "trigger") {
|
|
6069
|
-
|
|
6070
|
-
if (result.error) console.error(result.error);
|
|
6071
|
-
process.exit(result.exitCode);
|
|
6314
|
+
await finish(await runSendEventCommand(rest));
|
|
6072
6315
|
}
|
|
6073
6316
|
}
|
|
6074
6317
|
if (command === "automations") {
|
|
6075
6318
|
if (subcommand === "list") {
|
|
6076
|
-
|
|
6077
|
-
if (result.error) console.error(result.error);
|
|
6078
|
-
process.exit(result.exitCode);
|
|
6319
|
+
await finish(await runListCommand2(rest));
|
|
6079
6320
|
}
|
|
6080
6321
|
if (subcommand === "get") {
|
|
6081
|
-
|
|
6082
|
-
if (result.error) console.error(result.error);
|
|
6083
|
-
process.exit(result.exitCode);
|
|
6322
|
+
await finish(await runGetCommand2(rest));
|
|
6084
6323
|
}
|
|
6085
6324
|
if (subcommand === "create" || subcommand === "add") {
|
|
6086
|
-
|
|
6087
|
-
if (result.error) console.error(result.error);
|
|
6088
|
-
process.exit(result.exitCode);
|
|
6325
|
+
await finish(await runCreateCommand(rest));
|
|
6089
6326
|
}
|
|
6090
6327
|
if (subcommand === "update") {
|
|
6091
|
-
|
|
6092
|
-
if (result.error) console.error(result.error);
|
|
6093
|
-
process.exit(result.exitCode);
|
|
6328
|
+
await finish(await runUpdateCommand(rest));
|
|
6094
6329
|
}
|
|
6095
6330
|
if (subcommand === "activate") {
|
|
6096
|
-
|
|
6097
|
-
if (result.error) console.error(result.error);
|
|
6098
|
-
process.exit(result.exitCode);
|
|
6331
|
+
await finish(await runActivateCommand(rest));
|
|
6099
6332
|
}
|
|
6100
6333
|
if (subcommand === "pause") {
|
|
6101
|
-
|
|
6102
|
-
if (result.error) console.error(result.error);
|
|
6103
|
-
process.exit(result.exitCode);
|
|
6334
|
+
await finish(await runPauseCommand(rest));
|
|
6104
6335
|
}
|
|
6105
6336
|
if (subcommand === "delete" || subcommand === "remove") {
|
|
6106
|
-
|
|
6107
|
-
if (result.error) console.error(result.error);
|
|
6108
|
-
process.exit(result.exitCode);
|
|
6337
|
+
await finish(await runDeleteCommand(rest));
|
|
6109
6338
|
}
|
|
6110
6339
|
}
|
|
6111
6340
|
if (command === "webhooks") {
|
|
6112
6341
|
if (subcommand === "deliveries") {
|
|
6113
|
-
|
|
6114
|
-
if (result.error) console.error(result.error);
|
|
6115
|
-
process.exit(result.exitCode);
|
|
6342
|
+
await finish(await runDeliveriesCommand(rest));
|
|
6116
6343
|
}
|
|
6117
6344
|
if (subcommand === "list") {
|
|
6118
|
-
|
|
6119
|
-
if (result.error) console.error(result.error);
|
|
6120
|
-
process.exit(result.exitCode);
|
|
6345
|
+
await finish(await runListCommand5(rest));
|
|
6121
6346
|
}
|
|
6122
6347
|
if (subcommand === "get") {
|
|
6123
|
-
|
|
6124
|
-
if (result.error) console.error(result.error);
|
|
6125
|
-
process.exit(result.exitCode);
|
|
6348
|
+
await finish(await runGetCommand5(rest));
|
|
6126
6349
|
}
|
|
6127
6350
|
if (subcommand === "create") {
|
|
6128
|
-
|
|
6129
|
-
if (result.error) console.error(result.error);
|
|
6130
|
-
process.exit(result.exitCode);
|
|
6351
|
+
await finish(await runCreateCommand2(rest));
|
|
6131
6352
|
}
|
|
6132
6353
|
if (subcommand === "update") {
|
|
6133
|
-
|
|
6134
|
-
if (result.error) console.error(result.error);
|
|
6135
|
-
process.exit(result.exitCode);
|
|
6354
|
+
await finish(await runUpdateCommand3(rest));
|
|
6136
6355
|
}
|
|
6137
6356
|
if (subcommand === "delete") {
|
|
6138
|
-
|
|
6139
|
-
if (result.error) console.error(result.error);
|
|
6140
|
-
process.exit(result.exitCode);
|
|
6357
|
+
await finish(await runDeleteCommand3(rest));
|
|
6141
6358
|
}
|
|
6142
6359
|
}
|
|
6143
6360
|
if (command === "suppressions") {
|
|
6144
6361
|
if (subcommand === "list") {
|
|
6145
|
-
|
|
6146
|
-
if (result.error) console.error(result.error);
|
|
6147
|
-
process.exit(result.exitCode);
|
|
6362
|
+
await finish(await runListCommand6(rest));
|
|
6148
6363
|
}
|
|
6149
6364
|
if (subcommand === "add" || subcommand === "create") {
|
|
6150
|
-
|
|
6151
|
-
if (result.error) console.error(result.error);
|
|
6152
|
-
process.exit(result.exitCode);
|
|
6365
|
+
await finish(await runAddCommand2(rest));
|
|
6153
6366
|
}
|
|
6154
6367
|
if (subcommand === "remove" || subcommand === "delete") {
|
|
6155
|
-
|
|
6156
|
-
if (result.error) console.error(result.error);
|
|
6157
|
-
process.exit(result.exitCode);
|
|
6368
|
+
await finish(await runRemoveCommand(rest));
|
|
6158
6369
|
}
|
|
6159
6370
|
}
|
|
6160
6371
|
if (command === "routes") {
|
|
6161
|
-
|
|
6162
|
-
if (result.error) console.error(result.error);
|
|
6163
|
-
process.exit(result.exitCode);
|
|
6372
|
+
await finish(await runRoutesCommand(subcommand, rest));
|
|
6164
6373
|
}
|
|
6165
6374
|
if (command === "templates") {
|
|
6166
6375
|
if (subcommand === "list") {
|
|
6167
|
-
|
|
6168
|
-
if (result.error) console.error(result.error);
|
|
6169
|
-
process.exit(result.exitCode);
|
|
6376
|
+
await finish(await runListCommand7(rest));
|
|
6170
6377
|
}
|
|
6171
6378
|
if (subcommand === "starters") {
|
|
6172
|
-
|
|
6173
|
-
if (result.error) console.error(result.error);
|
|
6174
|
-
process.exit(result.exitCode);
|
|
6379
|
+
await finish(await runListStartersCommand(rest));
|
|
6175
6380
|
}
|
|
6176
6381
|
if (subcommand === "from-starter") {
|
|
6177
|
-
|
|
6178
|
-
if (result.error) console.error(result.error);
|
|
6179
|
-
process.exit(result.exitCode);
|
|
6382
|
+
await finish(await runFromStarterCommand(rest));
|
|
6180
6383
|
}
|
|
6181
6384
|
if (subcommand === "create" || subcommand === "add") {
|
|
6182
|
-
|
|
6183
|
-
if (result.error) console.error(result.error);
|
|
6184
|
-
process.exit(result.exitCode);
|
|
6385
|
+
await finish(await runCreateCommand3(rest));
|
|
6185
6386
|
}
|
|
6186
6387
|
if (subcommand === "get") {
|
|
6187
|
-
|
|
6188
|
-
if (result.error) console.error(result.error);
|
|
6189
|
-
process.exit(result.exitCode);
|
|
6388
|
+
await finish(await runGetCommand6(rest));
|
|
6190
6389
|
}
|
|
6191
6390
|
if (subcommand === "update") {
|
|
6192
|
-
|
|
6193
|
-
if (result.error) console.error(result.error);
|
|
6194
|
-
process.exit(result.exitCode);
|
|
6391
|
+
await finish(await runUpdateCommand4(rest));
|
|
6195
6392
|
}
|
|
6196
6393
|
if (subcommand === "publish") {
|
|
6197
|
-
|
|
6198
|
-
if (result.error) console.error(result.error);
|
|
6199
|
-
process.exit(result.exitCode);
|
|
6394
|
+
await finish(await runPublishCommand(rest));
|
|
6200
6395
|
}
|
|
6201
6396
|
if (subcommand === "push") {
|
|
6202
|
-
|
|
6203
|
-
if (result.error) console.error(result.error);
|
|
6204
|
-
process.exit(result.exitCode);
|
|
6397
|
+
await finish(await runPushCommand(rest));
|
|
6205
6398
|
}
|
|
6206
6399
|
if (subcommand === "versions") {
|
|
6207
|
-
|
|
6208
|
-
if (result.error) console.error(result.error);
|
|
6209
|
-
process.exit(result.exitCode);
|
|
6400
|
+
await finish(await runVersionsCommand(rest));
|
|
6210
6401
|
}
|
|
6211
6402
|
if (subcommand === "restore") {
|
|
6212
|
-
|
|
6213
|
-
if (result.error) console.error(result.error);
|
|
6214
|
-
process.exit(result.exitCode);
|
|
6403
|
+
await finish(await runRestoreCommand(rest));
|
|
6215
6404
|
}
|
|
6216
6405
|
if (subcommand === "test-send") {
|
|
6217
|
-
|
|
6218
|
-
if (result.error) console.error(result.error);
|
|
6219
|
-
process.exit(result.exitCode);
|
|
6406
|
+
await finish(await runTestSendCommand(rest));
|
|
6220
6407
|
}
|
|
6221
6408
|
if (subcommand === "duplicate") {
|
|
6222
|
-
|
|
6223
|
-
if (result.error) console.error(result.error);
|
|
6224
|
-
process.exit(result.exitCode);
|
|
6409
|
+
await finish(await runDuplicateCommand(rest));
|
|
6225
6410
|
}
|
|
6226
6411
|
if (subcommand === "delete" || subcommand === "remove") {
|
|
6227
|
-
|
|
6228
|
-
if (result.error) console.error(result.error);
|
|
6229
|
-
process.exit(result.exitCode);
|
|
6412
|
+
await finish(await runDeleteCommand4(rest));
|
|
6230
6413
|
}
|
|
6231
6414
|
}
|
|
6232
6415
|
if (command === "integrations") {
|
|
@@ -6234,19 +6417,13 @@ async function main() {
|
|
|
6234
6417
|
const action = rest[0];
|
|
6235
6418
|
const actionArgs = rest.slice(1);
|
|
6236
6419
|
if (action === "status" || action === "get") {
|
|
6237
|
-
|
|
6238
|
-
if (result.error) console.error(result.error);
|
|
6239
|
-
process.exit(result.exitCode);
|
|
6420
|
+
await finish(await runTwilioStatusCommand(actionArgs));
|
|
6240
6421
|
}
|
|
6241
6422
|
if (action === "connect" || action === "set") {
|
|
6242
|
-
|
|
6243
|
-
if (result.error) console.error(result.error);
|
|
6244
|
-
process.exit(result.exitCode);
|
|
6423
|
+
await finish(await runTwilioConnectCommand(actionArgs));
|
|
6245
6424
|
}
|
|
6246
6425
|
if (action === "disconnect" || action === "delete" || action === "remove") {
|
|
6247
|
-
|
|
6248
|
-
if (result.error) console.error(result.error);
|
|
6249
|
-
process.exit(result.exitCode);
|
|
6426
|
+
await finish(await runTwilioDisconnectCommand(actionArgs));
|
|
6250
6427
|
}
|
|
6251
6428
|
}
|
|
6252
6429
|
}
|
|
@@ -6278,27 +6455,25 @@ async function main() {
|
|
|
6278
6455
|
}
|
|
6279
6456
|
if (command === "keys") {
|
|
6280
6457
|
if (subcommand === "list") {
|
|
6281
|
-
|
|
6282
|
-
if (result.error) console.error(result.error);
|
|
6283
|
-
process.exit(result.exitCode);
|
|
6458
|
+
await finish(await runListKeysCommandWithClient(rest));
|
|
6284
6459
|
}
|
|
6285
6460
|
if (subcommand === "create") {
|
|
6286
|
-
|
|
6287
|
-
if (result.error) console.error(result.error);
|
|
6288
|
-
process.exit(result.exitCode);
|
|
6461
|
+
await finish(await runCreateKeyCommandWithClient(rest));
|
|
6289
6462
|
}
|
|
6290
6463
|
if (subcommand === "delete") {
|
|
6291
|
-
|
|
6292
|
-
if (result.error) console.error(result.error);
|
|
6293
|
-
process.exit(result.exitCode);
|
|
6464
|
+
await finish(await runDeleteKeyCommandWithClient(rest));
|
|
6294
6465
|
}
|
|
6295
6466
|
}
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
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 });
|
|
6300
6476
|
}
|
|
6301
6477
|
main().catch((error) => {
|
|
6302
|
-
|
|
6303
|
-
process.exit(1);
|
|
6478
|
+
fail(1, error instanceof Error ? error.message : String(error));
|
|
6304
6479
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groundmail-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.1",
|
|
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.55.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^9.0.0",
|