run402 4.138.2 → 4.139.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/lib/domains.mjs CHANGED
@@ -32,6 +32,14 @@ Examples:
32
32
  run402 domains connect kysigned.com --project prj_123 --email-send --email-receive --mailbox-addresses primary --addresses info
33
33
  run402 domains connect example.com --project prj_123 --web --web-target production
34
34
  run402 domains connect example.com --project prj_123 --web --authority hosted-zone
35
+ run402 domains connect example.com --project prj_123 --email-send --email-receive --receive-strategy full-mx --catch-all letters
36
+
37
+ --catch-all <slug> on connect:
38
+ Names the mailbox that receives mail for every local part no other mailbox
39
+ owns and may send as any of them ('run402 email send --from <address>').
40
+ Compiles to mailbox_addresses { mode: primary, all_mailboxes: true,
41
+ catch_all: <slug>, addresses: <--addresses or []> }. Needs a domain-wide
42
+ receive strategy (full-mx or subdomain), never forwarding.
35
43
 
36
44
  --authority on connect:
37
45
  hosted-zone Run402 hosts the domain's DNS zone; the owner makes ONE nameserver
@@ -98,6 +106,7 @@ const CONNECT_VALUE_FLAGS = [
98
106
  "--mail-subdomain",
99
107
  "--mailbox-addresses",
100
108
  "--addresses",
109
+ "--catch-all",
101
110
  "--activation",
102
111
  "--authority",
103
112
  "--confirm-mx-takeover",
@@ -183,6 +192,21 @@ function parseMailboxAddressMode(value) {
183
192
  return value;
184
193
  }
185
194
 
195
+ const MAILBOX_SLUG_RE = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
196
+
197
+ function parseCatchAll(value) {
198
+ if (value === undefined || value === null) return null;
199
+ if (!MAILBOX_SLUG_RE.test(value)) {
200
+ fail({
201
+ code: "BAD_FLAG",
202
+ message: "--catch-all must be a mailbox slug (lowercase letters, digits, hyphens).",
203
+ hint: "Use the slug of an active mailbox of the project, e.g. --catch-all letters.",
204
+ details: { flag: "--catch-all", value },
205
+ });
206
+ }
207
+ return value;
208
+ }
209
+
186
210
  function parseAddresses(value) {
187
211
  if (!value) return [];
188
212
  return value.split(",").map((part) => part.trim()).filter(Boolean);
@@ -224,7 +248,19 @@ function desiredFromConnectFlags(domain, parsed) {
224
248
 
225
249
  const emailSend = parsed.includes("--email-send");
226
250
  const emailReceive = parsed.includes("--email-receive");
227
- const mailboxMode = parseMailboxAddressMode(flagValue(parsed, "--mailbox-addresses"));
251
+ const catchAll = parseCatchAll(flagValue(parsed, "--catch-all"));
252
+ let mailboxMode = parseMailboxAddressMode(flagValue(parsed, "--mailbox-addresses"));
253
+ if (catchAll) {
254
+ if (mailboxMode && mailboxMode !== "primary") {
255
+ fail({
256
+ code: "BAD_FLAG",
257
+ message: "--catch-all needs --mailbox-addresses primary (or no --mailbox-addresses).",
258
+ hint: "A catch-all receives beside all mailboxes at their slugs; drop --mailbox-addresses or set it to primary.",
259
+ details: { flag: "--catch-all", conflicting_flag: "--mailbox-addresses", value: mailboxMode },
260
+ });
261
+ }
262
+ mailboxMode = "primary";
263
+ }
228
264
  if (emailSend || emailReceive || mailboxMode) {
229
265
  const email = {};
230
266
  if (emailSend) email.send = { enabled: true };
@@ -241,7 +277,7 @@ function desiredFromConnectFlags(domain, parsed) {
241
277
  }
242
278
  if (mailboxMode) {
243
279
  const locals = parseAddresses(flagValue(parsed, "--addresses"));
244
- if ((mailboxMode === "primary" || mailboxMode === "alias") && locals.length === 0) {
280
+ if ((mailboxMode === "primary" || mailboxMode === "alias") && locals.length === 0 && !catchAll) {
245
281
  fail({
246
282
  code: "BAD_FLAG",
247
283
  message: "--addresses is required when --mailbox-addresses is primary or alias.",
@@ -253,6 +289,7 @@ function desiredFromConnectFlags(domain, parsed) {
253
289
  : parsed.includes("--no-create-mailboxes") ? false : false;
254
290
  email.mailbox_addresses = {
255
291
  mode: mailboxMode,
292
+ ...(catchAll ? { all_mailboxes: true, catch_all: catchAll } : {}),
256
293
  addresses: locals.map((local) => ({
257
294
  local_part: local,
258
295
  mailbox_slug: local,
@@ -278,7 +315,7 @@ function desiredFromConnectFlags(domain, parsed) {
278
315
  fail({
279
316
  code: "BAD_USAGE",
280
317
  message: "No desired domain capability selected.",
281
- hint: "Use --web, --email-send, --email-receive, and/or --mailbox-addresses.",
318
+ hint: "Use --web, --email-send, --email-receive, --mailbox-addresses, and/or --catch-all.",
282
319
  });
283
320
  }
284
321
  return desired;
package/lib/email.mjs CHANGED
@@ -97,7 +97,7 @@ Subcommands:
97
97
  --output is required: bytes are written
98
98
  to the file; stdout receives a JSON
99
99
  envelope { message_id, bytes, output }.
100
- reply <message_id> --html "..." [--text "..."] [--subject "..."] [--from-name "..."] [--project <project_id>]
100
+ reply <message_id> --html "..." [--text "..."] [--subject "..."] [--from-name "..."] [--from <address>] [--project <project_id>]
101
101
  Reply to an inbound message (threads via In-Reply-To)
102
102
  delete [<slug|mailbox_id>] --confirm [--project <project_id>]
103
103
  Delete the project's mailbox (irreversible)
@@ -120,7 +120,9 @@ Send modes:
120
120
  Template: --template <name> --var key=value [--var ...] OR --vars '{"k":"v",...}'
121
121
  Raw HTML: --subject "..." --html "..." [--text "..."] (both --subject and --html required)
122
122
  Raw HTML also supports: --attach <path>[:content-type] (repeatable; max 100, 15 MB total)
123
- Both modes support: --from-name "Display Name" --project <project_id>
123
+ Both modes support: --from-name "Display Name" --from <address> --project <project_id>
124
+ --from <address> sends as another local part of a custom domain; only that
125
+ domain's catch-all mailbox may use it (see 'run402 domains connect --catch-all').
124
126
 
125
127
  Choosing a mailbox:
126
128
  --mailbox <slug|id> Target a specific mailbox. Accepted by send, list, get,
@@ -195,6 +197,10 @@ Options:
195
197
  inferred from the extension when the :content-type
196
198
  suffix is omitted.
197
199
  --from-name "..." Display name for the From header
200
+ --from <address> Send as this address (sent as from_address). Only the
201
+ domain's catch-all mailbox may send as a local part no
202
+ mailbox owns; refusals are FROM_ADDRESS_NOT_ALLOWED,
203
+ FROM_ADDRESS_NOT_EFFECTIVE, SENDER_SUSPENDED.
198
204
  --mailbox <slug|id> Target mailbox. Omit to use default_outbound_mailbox_id.
199
205
  --project <project_id> Project ID (defaults to the active project)
200
206
  `,
@@ -610,7 +616,7 @@ async function updateMailbox(args) {
610
616
  }
611
617
 
612
618
  async function send(args) {
613
- const valueFlags = ["--template", "--to", "--bcc", "--subject", "--html", "--text", "--from-name", "--project", "--vars", "--var", "--mailbox", "--attach"];
619
+ const valueFlags = ["--template", "--to", "--bcc", "--subject", "--html", "--text", "--from-name", "--from", "--project", "--vars", "--var", "--mailbox", "--attach"];
614
620
  validateArgs(args, valueFlags);
615
621
  const template = strictFlagValue(args, "--template");
616
622
  const to = strictFlagValue(args, "--to");
@@ -618,6 +624,7 @@ async function send(args) {
618
624
  const html = strictFlagValue(args, "--html");
619
625
  const text = strictFlagValue(args, "--text");
620
626
  const fromName = strictFlagValue(args, "--from-name");
627
+ const fromAddress = strictFlagValue(args, "--from");
621
628
  const mailbox = strictFlagValue(args, "--mailbox");
622
629
  const projectId = resolveProjectId(strictFlagValue(args, "--project"));
623
630
  const variables = parseVars(args);
@@ -638,6 +645,7 @@ async function send(args) {
638
645
  html: html ?? undefined,
639
646
  text: text ?? undefined,
640
647
  from_name: fromName ?? undefined,
648
+ from_address: fromAddress ?? undefined,
641
649
  mailbox: mailbox ?? undefined,
642
650
  attachments: attachments.length ? attachments : undefined,
643
651
  });
@@ -735,13 +743,14 @@ async function getRaw(args) {
735
743
  }
736
744
 
737
745
  async function reply(args) {
738
- const valueFlags = ["--project", "--html", "--text", "--subject", "--from-name", "--mailbox"];
746
+ const valueFlags = ["--project", "--html", "--text", "--subject", "--from-name", "--from", "--mailbox"];
739
747
  validateArgs(args, valueFlags);
740
748
  const messageId = positionalArgs(args, valueFlags)[0] ?? null;
741
749
  const html = strictFlagValue(args, "--html");
742
750
  const text = strictFlagValue(args, "--text");
743
751
  const subjectOverride = strictFlagValue(args, "--subject");
744
752
  const fromName = strictFlagValue(args, "--from-name");
753
+ const fromAddress = strictFlagValue(args, "--from");
745
754
  const mailbox = strictFlagValue(args, "--mailbox");
746
755
  const projectId = resolveProjectId(strictFlagValue(args, "--project"));
747
756
 
@@ -782,6 +791,7 @@ async function reply(args) {
782
791
  html: html ?? undefined,
783
792
  text: text ?? undefined,
784
793
  from_name: fromName ?? undefined,
794
+ from_address: fromAddress ?? undefined,
785
795
  in_reply_to: messageId,
786
796
  mailbox: mailbox ?? undefined,
787
797
  });
package/lib/webhooks.mjs CHANGED
@@ -17,7 +17,7 @@ Actions:
17
17
  deliveries [--status <s>] [--mailbox <slug|id>] [--project <project_id>] List durable delivery rows (DLQ visibility)
18
18
  redrive <delivery_id> [--mailbox <slug|id>] [--project <project_id>] Re-queue a dead-lettered delivery
19
19
 
20
- Valid events: delivery, bounced, complained, reply_received, mailbox_suspended
20
+ Valid events: delivery, bounced, complained, reply_received, mailbox_suspended, sender_suspended
21
21
  Delivery statuses: pending, in_flight, delivered, failed_permanent (the DLQ)
22
22
 
23
23
  Webhook delivery is durable + at-least-once: failures retry with backoff, then
@@ -194,7 +194,7 @@ async function register(args) {
194
194
  fail({
195
195
  code: "BAD_USAGE",
196
196
  message: "Missing --events.",
197
- hint: "Valid events: delivery, bounced, complained, reply_received, mailbox_suspended",
197
+ hint: "Valid events: delivery, bounced, complained, reply_received, mailbox_suspended, sender_suspended",
198
198
  });
199
199
  }
200
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "run402",
3
- "version": "4.138.2",
3
+ "version": "4.139.0",
4
4
  "description": "CLI for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -68,7 +68,7 @@ const APPLY_TRANSIENT_RETRY_MAX_DELAY_MS = 15_000;
68
68
  /** A read or an idempotent request lost to a 502/503/504 or a dropped connection. */
69
69
  const TRANSIENT_REQUEST_MAX_ATTEMPTS = 3;
70
70
  const TRANSIENT_REQUEST_RETRY_BASE_DELAY_MS = 500;
71
- const EMAIL_TRIGGER_EVENTS = new Set(["reply_received", "delivery", "bounced", "complained", "mailbox_suspended"]);
71
+ const EMAIL_TRIGGER_EVENTS = new Set(["reply_received", "delivery", "bounced", "complained", "mailbox_suspended", "sender_suspended"]);
72
72
  const STATIC_ACTIVATION_FAILURE_CODES = new Set([
73
73
  "BAD_FIELD",
74
74
  "INVALID_SPEC",
@@ -2693,7 +2693,7 @@ function validateFunctionTriggers(value, resource) {
2693
2693
  }
2694
2694
  for (const [eventIndex, event] of obj.events.entries()) {
2695
2695
  if (typeof event !== "string" || !EMAIL_TRIGGER_EVENTS.has(event)) {
2696
- throw invalidSpec(`ReleaseSpec.${path}.events.${eventIndex} must be one of reply_received, delivery, bounced, complained`, `${path}.events.${eventIndex}`);
2696
+ throw invalidSpec(`ReleaseSpec.${path}.events.${eventIndex} must be one of reply_received, delivery, bounced, complained, mailbox_suspended, sender_suspended`, `${path}.events.${eventIndex}`);
2697
2697
  }
2698
2698
  }
2699
2699
  }