groundmail-cli 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +51 -5
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2113,7 +2113,7 @@ function trimUrl(value) {
2113
2113
  }
2114
2114
 
2115
2115
  // package.json
2116
- var version = "0.42.0";
2116
+ var version = "0.43.0";
2117
2117
 
2118
2118
  // src/user-agent.ts
2119
2119
  var AGENT_ENV = [
@@ -4967,11 +4967,17 @@ var VALUE_FLAGS6 = [
4967
4967
  "--text",
4968
4968
  "--html",
4969
4969
  "--idempotency-key",
4970
- "--forward-from"
4970
+ "--forward-from",
4971
+ "--owner-email",
4972
+ "--code",
4973
+ "--source"
4971
4974
  ];
4972
- var BOOLEAN_FLAGS = ["--json", "--yes", "--unread", "--archived", "--include-held", "--reply-all"];
4975
+ var BOOLEAN_FLAGS = ["--instant", "--json", "--yes", "--unread", "--archived", "--include-held", "--reply-all"];
4973
4976
  var USAGE3 = [
4974
- "Usage: 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]",
4977
+ "Usage: groundmail mailboxes create --instant [--local-part signup-bot] [--owner-email you@example.com] [--json]",
4978
+ " groundmail mailboxes owner <mailbox> --owner-email you@example.com",
4979
+ " groundmail mailboxes verify <mailbox> --code 482913",
4980
+ " 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]",
4975
4981
  " groundmail mailboxes list [--tenant <tenant>] [--limit 25] [--cursor \u2026] [--json]",
4976
4982
  " groundmail mailboxes get <mailbox> [--json]",
4977
4983
  " groundmail mailboxes delete <mailbox> --yes",
@@ -5098,13 +5104,38 @@ function paging(args) {
5098
5104
  if (typeof limit === "object") return limit;
5099
5105
  return { ...limit !== void 0 ? { limit } : {}, ...args.values["--cursor"] ? { cursor: args.values["--cursor"] } : {} };
5100
5106
  }
5107
+ async function createInstant(args) {
5108
+ const { createInstantMailbox } = await import("groundmail");
5109
+ const v = args.values;
5110
+ try {
5111
+ const created = await createInstantMailbox(
5112
+ {
5113
+ ...v["--local-part"] ? { local_part: v["--local-part"] } : {},
5114
+ ...v["--display-name"] ? { display_name: v["--display-name"] } : {},
5115
+ ...v["--owner-email"] ? { owner_email: v["--owner-email"] } : {},
5116
+ source: v["--source"] ?? "cli"
5117
+ },
5118
+ { ...v["--base-url"] ? { baseUrl: v["--base-url"] } : {} }
5119
+ );
5120
+ if (args.booleans["--json"] === true) console.log(JSON.stringify(created));
5121
+ else {
5122
+ console.log(created.mailbox.address);
5123
+ console.log(`Key (shown once): ${created.api_key}`);
5124
+ console.log("Set it as GROUNDMAIL_API_KEY. This mailbox can receive now. To send, name your person: groundmail mailboxes owner");
5125
+ }
5126
+ return { exitCode: 0 };
5127
+ } catch (error) {
5128
+ return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
5129
+ }
5130
+ }
5101
5131
  async function runMailboxesCommand(subcommand, argv, env = process.env) {
5102
- if (!subcommand || !["create", "list", "get", "delete", "forward", "threads", "read", "wait", "send", "reply"].includes(subcommand)) {
5132
+ if (!subcommand || !["create", "owner", "verify", "list", "get", "delete", "forward", "threads", "read", "wait", "send", "reply"].includes(subcommand)) {
5103
5133
  return { exitCode: 1, error: USAGE3 };
5104
5134
  }
5105
5135
  const parsed = parseArgs(argv, { values: VALUE_FLAGS6, booleans: BOOLEAN_FLAGS });
5106
5136
  if (!parsed.ok) return { exitCode: 1, error: parsed.error };
5107
5137
  const { args } = parsed;
5138
+ if (subcommand === "create" && args.booleans["--instant"] === true) return createInstant(args);
5108
5139
  const apiKey = args.values["--api-key"] || env.GROUNDMAIL_API_KEY;
5109
5140
  if (!apiKey) return { exitCode: 1, error: "Missing API key. Run groundmail login, set GROUNDMAIL_API_KEY or pass --api-key." };
5110
5141
  const json = args.booleans["--json"] === true;
@@ -5118,6 +5149,18 @@ async function runMailboxesCommand(subcommand, argv, env = process.env) {
5118
5149
  const ref = mailbox;
5119
5150
  try {
5120
5151
  const client2 = await createMailboxesClient(apiKey, v["--base-url"]);
5152
+ if (subcommand === "owner") {
5153
+ if (!v["--owner-email"]) return { exitCode: 1, error: "Missing --owner-email." };
5154
+ const owner = await client2.mailboxes.setOwner(ref, v["--owner-email"]);
5155
+ print(owner, () => `Code sent to ${owner.owner_email}. Ask them for it, then run: groundmail mailboxes verify ${ref} --code <code>`);
5156
+ return { exitCode: 0 };
5157
+ }
5158
+ if (subcommand === "verify") {
5159
+ if (!v["--code"]) return { exitCode: 1, error: "Missing --code." };
5160
+ const verified = await client2.mailboxes.verifyOwner(ref, v["--code"]);
5161
+ print(verified, () => "Verified. This mailbox now has a normal account, with the same key.");
5162
+ return { exitCode: 0 };
5163
+ }
5121
5164
  if (subcommand === "create") {
5122
5165
  const params = createParams(args);
5123
5166
  if ("error" in params) return { exitCode: 1, error: params.error };
@@ -5272,6 +5315,9 @@ var USAGE_LINES = [
5272
5315
  " groundmail test-inbox address [--prefix signup] a fresh address on your team's test domain (mail there is caught, never delivered)",
5273
5316
  " groundmail test-inbox wait --to <address> [--timeout 30] [--since <iso>] [--json] wait for an email; prints its code and links (exit 2 on timeout)",
5274
5317
  " groundmail test-inbox list [--to <address>] [--since <iso>] [--json]",
5318
+ " groundmail mailboxes create --instant [--owner-email you@example.com] no account or key needed",
5319
+ " groundmail mailboxes owner <mailbox> --owner-email you@example.com send your person a code",
5320
+ " groundmail mailboxes verify <mailbox> --code 482913 unlock sending",
5275
5321
  " 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",
5276
5322
  " groundmail mailboxes list [--tenant <tenant>] [--limit 25] [--cursor \u2026] [--json]",
5277
5323
  " groundmail mailboxes get <mailbox> [--json]",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail-cli",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Groundmail CLI — send transactional email 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.45.0"
41
+ "groundmail": "0.46.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.5.0",