@dbx-tools/appkit-email-shared 0.1.78 → 0.1.79

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 CHANGED
@@ -24,15 +24,26 @@ import {
24
24
  } from "@dbx-tools/appkit-email-shared";
25
25
 
26
26
  const draft: EmailMessage = emailMessageSchema.parse({
27
- to: "alice@example.com",
27
+ to: ["alice@example.com", "bob@example.com"],
28
28
  subject: "Status",
29
29
  body: "# Update\n- shipped\n- tested",
30
+ cc: ["lead@example.com"],
31
+ attachments: [{ filename: "report.pdf", path: "/tmp/report.pdf" }],
30
32
  });
31
33
  ```
32
34
 
33
- `emailMessageSchema` is the `send_email` tool's input (recipient,
34
- subject, Markdown body, optional `cc` / `bcc`); `emailResultSchema` is
35
- the dispatch result returned to the model.
35
+ `emailMessageSchema` is the `send_email` tool's input: one or more `to`
36
+ recipients, a subject, a Markdown `body`, and optional `cc` / `bcc`
37
+ arrays and `attachments`. Each attachment carries a `filename` plus
38
+ either inline `content` (with an optional `encoding` such as `base64`)
39
+ or a `path` (local file, `data:` URI, or https URL), and an optional
40
+ `contentType`. `emailResultSchema` is the dispatch result returned to
41
+ the model (`recipient` echoes the comma-joined `to` list).
42
+
43
+ `emailSendersSchema` / `EmailSenders` type the plugin's `GET /senders`
44
+ payload - the permitted `From` options for the current user (`senders`),
45
+ the `defaultSender` among them, and whether the list is an enforced
46
+ `restricted` allow-list - so a compose UI can populate a sender dropdown.
36
47
 
37
48
  > Note: array fields intentionally omit `.min()` / `.nonempty()` so the
38
49
  > generated JSON schema carries no `minItems`, which some Model Serving
package/dist/index.d.ts CHANGED
@@ -1,13 +1,30 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  //#region packages/appkit-email-shared/src/protocol.d.ts
4
+ /** Schema for a single file attached to an outbound email. */
5
+ declare const emailAttachmentSchema: z.ZodObject<{
6
+ filename: z.ZodString;
7
+ content: z.ZodOptional<z.ZodString>;
8
+ encoding: z.ZodOptional<z.ZodString>;
9
+ path: z.ZodOptional<z.ZodString>;
10
+ contentType: z.ZodOptional<z.ZodString>;
11
+ }, z.core.$strip>;
12
+ /** A single file attached to an {@link EmailMessage}. */
13
+ type EmailAttachment = z.infer<typeof emailAttachmentSchema>;
4
14
  /** Schema for the email a model asks to send (the tool input). */
5
15
  declare const emailMessageSchema: z.ZodObject<{
6
- to: z.ZodString;
16
+ to: z.ZodArray<z.ZodString>;
7
17
  subject: z.ZodString;
8
18
  body: z.ZodString;
9
19
  cc: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
20
  bcc: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
+ filename: z.ZodString;
23
+ content: z.ZodOptional<z.ZodString>;
24
+ encoding: z.ZodOptional<z.ZodString>;
25
+ path: z.ZodOptional<z.ZodString>;
26
+ contentType: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>>>;
11
28
  }, z.core.$strip>;
12
29
  /** A validated outbound email message. */
13
30
  type EmailMessage = z.infer<typeof emailMessageSchema>;
@@ -20,5 +37,22 @@ declare const emailResultSchema: z.ZodObject<{
20
37
  }, z.core.$strip>;
21
38
  /** The outcome of dispatching an {@link EmailMessage}. */
22
39
  type EmailResult = z.infer<typeof emailResultSchema>;
40
+ /**
41
+ * Schema for the sender options a UI can offer for the `From` address -
42
+ * the payload of the plugin's `GET /senders` route. When the plugin
43
+ * configures a sender allow-list, `senders` holds the concrete addresses
44
+ * the current user may send as (domain wildcards expanded against the
45
+ * user's local part) and `restricted` is true; a picker should require a
46
+ * choice from the list. When unrestricted, `senders` holds at most the
47
+ * single default address (if one can be resolved) and `restricted` is
48
+ * false, so a UI may allow free entry.
49
+ */
50
+ declare const emailSendersSchema: z.ZodObject<{
51
+ senders: z.ZodArray<z.ZodString>;
52
+ defaultSender: z.ZodOptional<z.ZodString>;
53
+ restricted: z.ZodBoolean;
54
+ }, z.core.$strip>;
55
+ /** Sender options for a `From` picker (see {@link emailSendersSchema}). */
56
+ type EmailSenders = z.infer<typeof emailSendersSchema>;
23
57
  //#endregion
24
- export { EmailMessage, EmailResult, emailMessageSchema, emailResultSchema };
58
+ export { EmailAttachment, EmailMessage, EmailResult, EmailSenders, emailAttachmentSchema, emailMessageSchema, emailResultSchema, emailSendersSchema };
package/dist/index.js CHANGED
@@ -1,9 +1,17 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  //#region packages/appkit-email-shared/src/protocol.ts
4
+ /** Schema for a single file attached to an outbound email. */
5
+ const emailAttachmentSchema = z.object({
6
+ filename: z.string().describe("File name shown to the recipient (e.g. \"report.pdf\")."),
7
+ content: z.string().optional().describe("Inline file content as a string. For binary data set `encoding` (e.g. \"base64\"). Provide this or `path`, not both."),
8
+ encoding: z.string().optional().describe("Encoding of `content` (e.g. \"base64\", \"utf-8\", \"hex\"). Defaults to utf-8 when omitted."),
9
+ path: z.string().optional().describe("Read the content from here instead of inlining it: a local file path, a data: URI, or an https URL. Provide this or `content`, not both."),
10
+ contentType: z.string().optional().describe("MIME type override (e.g. \"application/pdf\"). Inferred from the filename when omitted.")
11
+ });
4
12
  /** Schema for the email a model asks to send (the tool input). */
5
13
  const emailMessageSchema = z.object({
6
- to: z.string().describe("Single recipient email address (e.g. \"alice@example.com\"). Comma-separate multiple recipients yourself."),
14
+ to: z.array(z.string()).describe("One or more recipient email addresses (e.g. [\"alice@example.com\", \"bob@example.com\"]). Provide at least one."),
7
15
  subject: z.string().describe("Subject line. Keep it short and specific."),
8
16
  body: z.string().describe([
9
17
  "Email body in GitHub-Flavored Markdown; it is rendered to HTML before sending.",
@@ -12,16 +20,32 @@ const emailMessageSchema = z.object({
12
20
  "Do NOT format with ASCII art: no '=====' or '-----' divider lines, and never hand-draw tables or bar charts with spaces, pipes, or '#'. Use the Markdown constructs above instead.",
13
21
  "Be self-contained: the recipient has none of the chat context."
14
22
  ].join(" ")),
15
- cc: z.array(z.string()).optional().describe("Optional CC recipient addresses."),
16
- bcc: z.array(z.string()).optional().describe("Optional BCC recipient addresses.")
23
+ cc: z.array(z.string()).optional().describe("Optional CC recipient addresses (one or more)."),
24
+ bcc: z.array(z.string()).optional().describe("Optional BCC recipient addresses (one or more)."),
25
+ attachments: z.array(emailAttachmentSchema).optional().describe("Optional file attachments to include with the message.")
17
26
  });
18
27
  /** Schema for the dispatch result returned to the model after a send. */
19
28
  const emailResultSchema = z.object({
20
29
  sent: z.boolean().describe("True once the message was handed to the SMTP server."),
21
- recipient: z.string().describe("Echo of the `to` field for confirmation."),
30
+ recipient: z.string().describe("Echo of the `to` recipients (comma-joined) for confirmation."),
22
31
  from: z.string().describe("The resolved sender address the message was actually sent from."),
23
32
  messageId: z.string().optional().describe("SMTP message id assigned by the server, when one was returned.")
24
33
  });
34
+ /**
35
+ * Schema for the sender options a UI can offer for the `From` address -
36
+ * the payload of the plugin's `GET /senders` route. When the plugin
37
+ * configures a sender allow-list, `senders` holds the concrete addresses
38
+ * the current user may send as (domain wildcards expanded against the
39
+ * user's local part) and `restricted` is true; a picker should require a
40
+ * choice from the list. When unrestricted, `senders` holds at most the
41
+ * single default address (if one can be resolved) and `restricted` is
42
+ * false, so a UI may allow free entry.
43
+ */
44
+ const emailSendersSchema = z.object({
45
+ senders: z.array(z.string()).describe("Permitted sender addresses to offer as `From` choices."),
46
+ defaultSender: z.string().optional().describe("The address a send uses by default (first `senders` entry, if any)."),
47
+ restricted: z.boolean().describe("True when `senders` is an enforced allow-list rather than a hint.")
48
+ });
25
49
 
26
50
  //#endregion
27
- export { emailMessageSchema, emailResultSchema };
51
+ export { emailAttachmentSchema, emailMessageSchema, emailResultSchema, emailSendersSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbx-tools/appkit-email-shared",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "dependencies": {
5
5
  "zod": "^4.3.6"
6
6
  },