@mgcrea/mcp-apple-mail 1.26.0 → 1.28.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 CHANGED
@@ -190,6 +190,12 @@ filename is reduced to its basename first — a sender who names their attachmen
190
190
  `../../../.ssh/authorized_keys` gets a file called `authorized_keys` in your downloads folder and
191
191
  nothing else. Existing files are never overwritten unless you ask.
192
192
 
193
+ Going the other way, `send_message`, `reply_to_message` and `forward_message` take `attachments`,
194
+ absolute paths that Mail reads and attaches. On a draft, the default, you see the files before
195
+ anything goes. Attaching and sending in one call (`sendNow`) is refused unless
196
+ `APPLE_MAIL_ALLOW_FILE_SEND` is set, because nobody looks and a path is a way to mail out anything
197
+ this server can read.
198
+
193
199
  **No shell.** The one place this package spawns a process uses `execFile`, never `exec`, and no
194
200
  caller input is ever interpolated into script text. Scripts are static constants piped to
195
201
  `osascript` over stdin; every value travels as a JSON argument. A mailbox named
@@ -213,6 +219,7 @@ and a tripwire that refuses to run any script containing a `${`.
213
219
  | `APPLE_MAIL_MAX_RESULTS` | `200` | Ceiling for search results. |
214
220
  | `APPLE_MAIL_BODY_MAX_BYTES` | `262144` | Body truncation, to protect the context window. |
215
221
  | `APPLE_MAIL_ATTACHMENT_DIR` | `~/Downloads` | The only directory attachments may be saved into. |
222
+ | `APPLE_MAIL_ALLOW_FILE_SEND` | off | Let a compose tool attach local files and send in the same call. |
216
223
  | `APPLE_MAIL_MAILBOX_CACHE_TTL_MS` | `60000` | How long the account/mailbox map is cached. |
217
224
 
218
225
  ## Notes
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as loadConfig, b as MAIL_SURFACE, j as BUILD_INFO, r as createServer } from "./server-69NtCX3D.js";
2
+ import { a as loadConfig, b as MAIL_SURFACE, j as BUILD_INFO, r as createServer } from "./server-BnjMqr5E.js";
3
3
  import { runStdioServer } from "@mgcrea/mcp-apple-core";
4
4
  //#region src/cli.ts
5
5
  const LOG_PREFIX = "apple-mail-mcp";
package/dist/index.d.ts CHANGED
@@ -92,6 +92,7 @@ declare const ConfigSchema: z.ZodObject<{
92
92
  bodyScanMax: z.ZodDefault<z.ZodNumber>;
93
93
  bodyScanBytes: z.ZodDefault<z.ZodNumber>;
94
94
  attachmentDir: z.ZodDefault<z.ZodString>;
95
+ allowFileSend: z.ZodDefault<z.ZodBoolean>;
95
96
  mailboxCacheTtlMs: z.ZodDefault<z.ZodNumber>;
96
97
  }, z.core.$strict>;
97
98
  type Config = z.infer<typeof ConfigSchema>;
@@ -1018,6 +1019,7 @@ declare class AppleMailClient {
1018
1019
  bcc: string[];
1019
1020
  subject: string;
1020
1021
  body: string;
1022
+ attachments?: string[];
1021
1023
  sendNow: boolean;
1022
1024
  }): Promise<unknown>;
1023
1025
  replyOrForward(ref: string, opts: {
@@ -1025,6 +1027,7 @@ declare class AppleMailClient {
1025
1027
  body?: string;
1026
1028
  to?: string[];
1027
1029
  replyToAll?: boolean;
1030
+ attachments?: string[];
1028
1031
  sendNow: boolean;
1029
1032
  }): Promise<unknown>;
1030
1033
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/build-info.ts","../src/client/errors.ts","../src/client/locate.ts","../src/config.ts","../src/client/ax.ts","../src/client/compose.ts","../src/client/mime.ts","../src/client/emlx.ts","../src/client/schema.ts","../src/client/envelope.ts","../src/client/mailbox-map.ts","../src/client/mail.ts","../src/client/ref.ts","../src/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;;cCWZ,6BAA6B;WACtB;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;KCTF;;EAEV;;EAEA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;KAKU;;EAEV;;EAEA;;EAEA;;EAEA;;cAiBW,sBAAmB,OAAU,kBAAqB;;;;;;;;;;;;;;;cC3CzD,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;GA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ACA,mBACC;IACD;IACA;IACA;IACA;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEI,YACJ,aACA;IAAQ;IAAc;MACrB,QAAQ;;;;;;;;;;;;EAiDL,eACJ;IAAQ;MACP,QAAQ;EAsEL,gBAAgB,mBAAmB;EAKnC,YAAY;IAChB;IACA;IACA;IACA;IACA;IACA;IACA;MACE;EAaE,eACJ,aACA;IACE;IACA;IACA;IACA;IACA;MAED;;;;;;;;;;;;;;;;;;;;;cCz4CQ;KAED;EACV;EACA;EACA;;cAKW,YAAS,KAAS;cAGlB,YAAS,gBAAkB;;cA2B3B,qBAAkB,MAAU,iBAAe,YAAY;;;cChDvD;cACA;KAED;EACV,QAAQ;EACR,SAAS;;EAET,YAAY;;KAGF;EACV,QAAQ;EACR,QAAQ;;;;;;;cAQG,eAAY,MAAU,wBAAsB;;;KCrB7C;;;;;EAKV;;;;;;;;;;;;cAaW,gBAAa,QAChB,WAAS,QACT,iBAAe,KAClB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/build-info.ts","../src/client/errors.ts","../src/client/locate.ts","../src/config.ts","../src/client/ax.ts","../src/client/compose.ts","../src/client/mime.ts","../src/client/emlx.ts","../src/client/schema.ts","../src/client/envelope.ts","../src/client/mailbox-map.ts","../src/client/mail.ts","../src/client/ref.ts","../src/server.ts","../src/tools/index.ts"],"mappings":";;;;;cAkBa,YAAY;;;;cCWZ,6BAA6B;WACtB;EAElB,YAAY;;;;;;;;;;;;;;;;;;;;KCTF;;EAEV;;EAEA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;;KAKU;;EAEV;;EAEA;;EAEA;;EAEA;;cAiBW,sBAAmB,OAAU,kBAAqB;;;;;;;;;;;;;;;cC3CzD,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;;GA8DP,EAAA,KAAA;KAEC,SAAS,EAAE,aAAa;;;;;cAMvB,aAAU,MAAS,OAAO,eAA2B;;;;KCe7D;EAAc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;IAAc;MACrB,QAAQ;;;;;;;;;;;;EAiDL,eACJ;IAAQ;MACP,QAAQ;EAsEL,gBAAgB,mBAAmB;EAKnC,YAAY;IAChB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;MACE;EAgBE,eACJ,aACA;IACE;IACA;IACA;IACA;IACA;IACA;MAED;;;;;;;;;;;;;;;;;;;;;cCl5CQ;KAED;EACV;EACA;EACA;;cAKW,YAAS,KAAS;cAGlB,YAAS,gBAAkB;;cA2B3B,qBAAkB,MAAU,iBAAe,YAAY;;;cChDvD;cACA;KAED;EACV,QAAQ;EACR,SAAS;;EAET,YAAY;;KAGF;EACV,QAAQ;EACR,QAAQ;;;;;;;cAQG,eAAY,MAAU,wBAAsB;;;KCrB7C;;;;;EAKV;;;;;;;;;;;;cAaW,gBAAa,QAChB,WAAS,QACT,iBAAe,KAClB"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as WritesDisabledError, C as MessageNotFoundError, D as ProtocolError, E as PreconditionError, O as SchemaDriftError, S as MailNotRunningError, T as PlatformError, _ as locateEnvelopeIndex, a as loadConfig, c as decodeRef, d as assertStaticScript, f as createOsascriptRunner, g as inspectFile, h as MailboxMap, i as registerTools, j as BUILD_INFO, k as TccDeniedError, l as encodeRef, m as withBusyRetry, n as SERVER_VERSION, o as AppleMailClient, p as mapOsaError, r as createServer, s as REF_VERSION, t as SERVER_NAME, u as groupRefsByMailbox, v as AppleMailError, w as OsascriptTimeoutError, x as MailBusyError, y as IndexUnavailableError } from "./server-69NtCX3D.js";
1
+ import { A as WritesDisabledError, C as MessageNotFoundError, D as ProtocolError, E as PreconditionError, O as SchemaDriftError, S as MailNotRunningError, T as PlatformError, _ as locateEnvelopeIndex, a as loadConfig, c as decodeRef, d as assertStaticScript, f as createOsascriptRunner, g as inspectFile, h as MailboxMap, i as registerTools, j as BUILD_INFO, k as TccDeniedError, l as encodeRef, m as withBusyRetry, n as SERVER_VERSION, o as AppleMailClient, p as mapOsaError, r as createServer, s as REF_VERSION, t as SERVER_NAME, u as groupRefsByMailbox, v as AppleMailError, w as OsascriptTimeoutError, x as MailBusyError, y as IndexUnavailableError } from "./server-BnjMqr5E.js";
2
2
  export { AppleMailClient, AppleMailError, BUILD_INFO, IndexUnavailableError, MailBusyError, MailNotRunningError, MailboxMap, MessageNotFoundError, OsascriptTimeoutError, PlatformError, PreconditionError, ProtocolError, REF_VERSION, SERVER_NAME, SERVER_VERSION, SchemaDriftError, TccDeniedError, WritesDisabledError, assertStaticScript, createOsascriptRunner, createServer, decodeRef, encodeRef, groupRefsByMailbox, inspectFile, loadConfig, locateEnvelopeIndex, mapOsaError, registerTools, withBusyRetry };
@@ -1,7 +1,7 @@
1
1
  import { AppBusyError as MailBusyError, AppNotRunningError as MailNotRunningError, AppleAutomationError, AppleAutomationError as AppleMailError, BaseConfigSchema, IndexUnavailableError, OsascriptTimeoutError, PlatformError, PreconditionError, ProtocolError, SchemaDriftError, TccDeniedError, WritesDisabledError, assertStaticScript, buildBaseDiagnostics, confirmArg, createOsascriptRunner, describeAggregation, detectEpoch, escapeLike, fingerprintSchema, groupByArg, inspectFile, interferenceNote, limitArg, mapOsaError, openAxChannel, openReadOnly, parseBool, parseBound, parseConfig, parseIntOpt, parseList, project, promptArg, readPackageIdentity, registerSurfaceResources, registerWorkflowPrompt, requiredPromptArg, resolveLimit, selectArg, tableMap, trimmed, watchInterference, withBusyRetry, withLazyTools, wrap, writeConfinedFile } from "@mgcrea/mcp-apple-core";
2
2
  import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
- import { basename, dirname, join } from "node:path";
4
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
5
5
  import { execFile } from "node:child_process";
6
6
  import { promisify } from "node:util";
7
7
  import { z } from "zod";
@@ -14,8 +14,8 @@ const pkg = readPackageIdentity(new URL("../package.json", import.meta.url), {
14
14
  const BUILD_INFO = {
15
15
  name: pkg.name,
16
16
  version: pkg.version,
17
- gitCommit: "8802834",
18
- gitCommitDate: "2026-10-06T12:47:35+02:00"
17
+ gitCommit: "6054516",
18
+ gitCommitDate: "2026-10-13T17:38:51+02:00"
19
19
  };
20
20
  //#endregion
21
21
  //#region src/client/errors.ts
@@ -1917,6 +1917,42 @@ function discardComposer(M, draft) {
1917
1917
  }
1918
1918
  }
1919
1919
 
1920
+ /**
1921
+ * Attach each file in list to an outgoing message, in order.
1922
+ *
1923
+ * The form measured to work on macOS 26.6 -- see docs/mail-compose.md,
1924
+ * "Attachments can be added". Mail places each one after the last paragraph,
1925
+ * inline, the way a file dragged into a composer is placed.
1926
+ *
1927
+ * Every path is one the client resolved and gated; this is the only Path call in
1928
+ * the bundle, and test/jxa.test.ts pins it. Stops at the first refusal and
1929
+ * names it, so a caller never sends a message missing a file it asked for.
1930
+ * count is what Mail read back, null when it would not say.
1931
+ */
1932
+ function attachFiles(M, msg, list) {
1933
+ list = list || [];
1934
+ for (var i = 0; i < list.length; i++) {
1935
+ try {
1936
+ msg.content.attachments.push(M.Attachment({ fileName: Path(list[i]) }));
1937
+ } catch (e) {
1938
+ return { ok: false, path: list[i], message: String(e && e.message ? e.message : e) };
1939
+ }
1940
+ }
1941
+ if (!list.length) return { ok: true, count: 0 };
1942
+ return { ok: true, count: prop(function () { return msg.content.attachments.length; }, null) };
1943
+ }
1944
+
1945
+ function attachmentFailure(failure, closed) {
1946
+ return err(
1947
+ "ATTACHMENT_FAILED",
1948
+ "Mail would not attach " + failure.path + ": " + failure.message + ". Nothing was sent. " +
1949
+ (closed
1950
+ ? "The composer this opened was closed again without saving, so a retry is safe."
1951
+ : "The composer could NOT be closed from here and is still open in Mail; close it before " +
1952
+ "retrying, or a retry leaves a second one behind.")
1953
+ );
1954
+ }
1955
+
1920
1956
  /**
1921
1957
  * Find the composer Mail just opened, by the subject Mail gave it.
1922
1958
  *
@@ -2721,6 +2757,11 @@ const SEND_MESSAGE = script(`
2721
2757
  }
2722
2758
  }
2723
2759
 
2760
+ // Before the send, and before anything else touches the window: a refused
2761
+ // file must leave nothing sent and nothing behind.
2762
+ var attached = attachFiles(M, msg, p.attachments);
2763
+ if (!attached.ok) return attachmentFailure(attached, discardComposer(M, msg));
2764
+
2724
2765
  pause(1.2);
2725
2766
  var unquoted = false;
2726
2767
  try { unquoted = stripCitation(String(p.subject || "")); } catch (e) { unquoted = false; }
@@ -2728,10 +2769,12 @@ const SEND_MESSAGE = script(`
2728
2769
  if (p.sendNow) {
2729
2770
  msg.send();
2730
2771
  return ok({ sent: true, unquoted: unquoted, subjectLength: String(p.subject || "").length,
2731
- recipientCount: (p.to || []).length + (p.cc || []).length + (p.bcc || []).length });
2772
+ recipientCount: (p.to || []).length + (p.cc || []).length + (p.bcc || []).length,
2773
+ attachments: attached.count });
2732
2774
  }
2733
2775
  return ok({ sent: false, draft: true, unquoted: unquoted, subjectLength: String(p.subject || "").length,
2734
2776
  recipientCount: (p.to || []).length + (p.cc || []).length + (p.bcc || []).length,
2777
+ attachments: attached.count,
2735
2778
  note: "Draft window is open in Mail for review." });
2736
2779
  `, { allowLaunch: true });
2737
2780
  /**
@@ -2961,6 +3004,19 @@ const UPDATE_DRAFT = script(`
2961
3004
  });
2962
3005
  }
2963
3006
 
3007
+ // Every row already carrying the subject, so none of them can be mistaken for
3008
+ // the replacement below: Mail keeps autosaved copies under one subject, and
3009
+ // taking one of those for confirmation deletes the original with nothing
3010
+ // saved in its place. Read before the composer exists, so an early autosave
3011
+ // of the replacement itself is not counted among them.
3012
+ var before = {};
3013
+ before[p.id] = true;
3014
+ var existing = prop(function () { return drafts.messages.whose({ subject: subject })(); }, []);
3015
+ for (var b = 0; b < existing.length; b++) {
3016
+ var bid = prop(function () { return existing[b].id(); }, null);
3017
+ if (bid !== null) before[bid] = true;
3018
+ }
3019
+
2964
3020
  var replacement = M.OutgoingMessage({ subject: subject, content: p.body || "", visible: true });
2965
3021
  M.outgoingMessages.push(replacement);
2966
3022
  if (sender) { try { replacement.sender = sender; } catch (e) {} }
@@ -2992,7 +3048,7 @@ const UPDATE_DRAFT = script(`
2992
3048
  var matches = prop(function () { return drafts.messages.whose({ subject: subject })(); }, []);
2993
3049
  for (var k = 0; k < matches.length; k++) {
2994
3050
  var mid = prop(function () { return matches[k].id(); }, null);
2995
- if (mid === null || mid === p.id) continue;
3051
+ if (mid === null || before[mid]) continue;
2996
3052
  if (newId === null || mid > newId) newId = mid;
2997
3053
  }
2998
3054
  }
@@ -3037,7 +3093,7 @@ const UPDATE_DRAFT = script(`
3037
3093
  var finals = prop(function () { return drafts.messages.whose({ subject: subject })(); }, []);
3038
3094
  for (var f = 0; f < finals.length; f++) {
3039
3095
  var fid = prop(function () { return finals[f].id(); }, null);
3040
- if (fid !== null && fid !== p.id && (settledId === newId || fid > settledId)) settledId = fid;
3096
+ if (fid !== null && !before[fid] && (settledId === newId || fid > settledId)) settledId = fid;
3041
3097
  }
3042
3098
 
3043
3099
  return ok({
@@ -3136,6 +3192,9 @@ const REPLY_OR_FORWARD = script(`
3136
3192
  }
3137
3193
  }
3138
3194
 
3195
+ var attached = attachFiles(M, draft, p.attachments);
3196
+ if (!attached.ok) return attachmentFailure(attached, discardComposer(M, draft));
3197
+
3139
3198
  var bodyArea = findBodyArea(win, 0);
3140
3199
  if (!bodyArea) {
3141
3200
  var closedNoBody = discardComposer(M, draft);
@@ -3360,7 +3419,14 @@ const OPEN_COMPOSER = script(`
3360
3419
  }
3361
3420
  }
3362
3421
 
3363
- return ok({ subject: subject });
3422
+ // Here or nowhere: the reference dies with this process, and nothing has
3423
+ // been typed yet, so a refusal can take the composer back.
3424
+ var attached = attachFiles(M, draft, p.attachments);
3425
+ if (!attached.ok) return attachmentFailure(attached, discardComposer(M, draft));
3426
+
3427
+ // Not a count on a reply or forward: content reads back as the attachment
3428
+ // characters alone there (docs/mail-compose.md), so it is the number pushed.
3429
+ return ok({ subject: subject, attachments: (p.attachments || []).length });
3364
3430
  `, { allowLaunch: true });
3365
3431
  //#endregion
3366
3432
  //#region src/client/compose.ts
@@ -3597,7 +3663,8 @@ const replyOrForwardNatively = async (lane, runner, params, opts = {}) => {
3597
3663
  const startedAt = Date.now();
3598
3664
  const reach = await lane.reach();
3599
3665
  if (!reach.ok) throw new Error(MailAxLane.grantMessage(params.mode));
3600
- const subject = (await runner.run(OPEN_COMPOSER, params)).subject;
3666
+ const opened = await runner.run(OPEN_COMPOSER, params);
3667
+ const subject = opened.subject;
3601
3668
  /**
3602
3669
  * A composer under this subject was open BEFORE this call opened one.
3603
3670
  *
@@ -3691,6 +3758,7 @@ const replyOrForwardNatively = async (lane, runner, params, opts = {}) => {
3691
3758
  bodyVerified,
3692
3759
  verifiedChars,
3693
3760
  sent,
3761
+ ...opened.attachments ? { attachments: opened.attachments } : {},
3694
3762
  note: params.sendNow ? sent ? "Sent." : `The ${params.mode} was composed and verified, but its window is still open ${sendTimeoutMs / 1e3}s after the send, so it may not have gone. Check Mail before retrying.` : "Draft window is open in Mail for review."
3695
3763
  };
3696
3764
  };
@@ -4593,6 +4661,7 @@ var AppleMailClient = class {
4593
4661
  async listMailboxes(opts) {
4594
4662
  const accounts = await this.accounts();
4595
4663
  const allowed = opts.accountUuids?.length ? accounts.filter((a) => opts.accountUuids?.includes(a.id)).map((a) => a.id) : accounts.map((a) => a.id);
4664
+ if (!allowed.length) return [];
4596
4665
  return withBusyRetry(() => this.runner.run(LIST_MAILBOXES, {
4597
4666
  accountUuids: allowed,
4598
4667
  withCounts: opts.withCounts
@@ -5372,6 +5441,7 @@ var AppleMailClient = class {
5372
5441
  return this.runner.run(CHECK_FOR_NEW_MAIL, { accountUuid: resolved?.id ?? null });
5373
5442
  }
5374
5443
  async sendMessage(opts) {
5444
+ const attachments = this.#resolveAttachments(opts.attachments, opts.sendNow);
5375
5445
  const account = opts.account ? await this.mailboxes.resolveAccount(opts.account) : null;
5376
5446
  return this.runner.run(SEND_MESSAGE, {
5377
5447
  senderAddress: account?.emailAddresses[0] ?? null,
@@ -5380,10 +5450,12 @@ var AppleMailClient = class {
5380
5450
  bcc: opts.bcc,
5381
5451
  subject: opts.subject,
5382
5452
  body: opts.body,
5453
+ attachments,
5383
5454
  sendNow: opts.sendNow
5384
5455
  });
5385
5456
  }
5386
5457
  async replyOrForward(ref, opts) {
5458
+ const attachments = this.#resolveAttachments(opts.attachments, opts.sendNow);
5387
5459
  const decoded = decodeRef(ref);
5388
5460
  const params = {
5389
5461
  accountUuid: decoded.accountUuid,
@@ -5393,11 +5465,33 @@ var AppleMailClient = class {
5393
5465
  body: opts.body ?? null,
5394
5466
  to: opts.to ?? [],
5395
5467
  replyToAll: opts.replyToAll ?? false,
5468
+ attachments,
5396
5469
  sendNow: opts.sendNow
5397
5470
  };
5398
5471
  if (this.#ax) return replyOrForwardNatively(this.#ax, this.runner, params, this.#clipboard ? { clipboard: this.#clipboard } : {});
5399
5472
  return this.runner.run(REPLY_OR_FORWARD, params);
5400
5473
  }
5474
+ /**
5475
+ * The files a compose call names, checked before Mail is asked anything.
5476
+ *
5477
+ * Two bounds, and the tool layer relies on both being here rather than in it.
5478
+ * The gate: attaching to a draft needs only writes, because a person sees the
5479
+ * file before it goes, but attaching and sending at once needs
5480
+ * `allowFileSend` -- see config.ts. The shape: absolute, present, a regular
5481
+ * file, so a directory or a dangling path fails with a sentence here rather
5482
+ * than as an Apple Event error out of Mail.
5483
+ */
5484
+ #resolveAttachments(paths, sendNow) {
5485
+ if (!paths?.length) return [];
5486
+ if (sendNow && !this.config.allowFileSend) throw new PreconditionError("Sending a local file immediately is off. Leave out sendNow to open a draft with the attachments for the user to review and send, or set APPLE_MAIL_ALLOW_FILE_SEND=1 to allow attaching and sending in one call.");
5487
+ return paths.map((path) => {
5488
+ if (!isAbsolute(path)) throw new PreconditionError(`"${path}" is not an absolute path. This server has no meaningful working directory, so a relative path cannot be resolved to the file you mean.`);
5489
+ const source = resolve(path);
5490
+ if (!existsSync(source)) throw new PreconditionError(`There is no file at ${source}.`);
5491
+ if (!statSync(source).isFile()) throw new PreconditionError(`${source} is not a regular file; Mail can only attach files.`);
5492
+ return source;
5493
+ });
5494
+ }
5401
5495
  #withRef(m) {
5402
5496
  const { id, accountUuid, mailbox, ...rest } = m;
5403
5497
  return {
@@ -5474,6 +5568,22 @@ const ConfigSchema = BaseConfigSchema.extend({
5474
5568
  * yet, and the filename — not the directory — is the attacker-controlled part.
5475
5569
  */
5476
5570
  attachmentDir: z.string().default(join(homedir(), "Downloads")),
5571
+ /**
5572
+ * Lets a compose tool attach a local file AND send it in the same call.
5573
+ *
5574
+ * A sub-gate of `allowWrites`, like Messages' flag of the same name, and
5575
+ * narrower than it: attaching to a draft needs only `allowWrites`, because a
5576
+ * draft is left on screen and a person sees the file before anything goes.
5577
+ * What this guards is `sendNow` with `attachments`, where nobody does. That is
5578
+ * the exfiltration primitive -- any file this process can read, in a stranger's
5579
+ * inbox -- and the untrusted text that would ask for it arrives through this
5580
+ * server's own read tools, with a `confirm` the model fills in itself.
5581
+ *
5582
+ * No directory confinement, for the reason Messages gives: any client that can
5583
+ * also write files defeats one with a copy, so it would be a speed bump that
5584
+ * reads as a boundary.
5585
+ */
5586
+ allowFileSend: z.boolean().default(false),
5477
5587
  mailboxCacheTtlMs: z.number().int().min(0).max(36e5).default(6e4)
5478
5588
  }).strict();
5479
5589
  /**
@@ -5497,6 +5607,7 @@ const loadConfig = (env = process.env) => {
5497
5607
  bodyScanMax: parseIntOpt(env.APPLE_MAIL_BODY_SCAN_MAX),
5498
5608
  bodyScanBytes: parseIntOpt(env.APPLE_MAIL_BODY_SCAN_BYTES),
5499
5609
  attachmentDir: trimmed(env.APPLE_MAIL_ATTACHMENT_DIR),
5610
+ allowFileSend: parseBool(env.APPLE_MAIL_ALLOW_FILE_SEND),
5500
5611
  mailboxCacheTtlMs: parseIntOpt(env.APPLE_MAIL_MAILBOX_CACHE_TTL_MS)
5501
5612
  };
5502
5613
  return parseConfig(ConfigSchema, raw);
@@ -5937,6 +6048,7 @@ const registerActionTools = (server, client) => {
5937
6048
  */
5938
6049
  const sendNowArg = z.boolean().optional().describe("Send immediately instead of leaving a draft. Defaults to FALSE, which opens the message in Mail for a human to review and send. When true, confirm must also be true.");
5939
6050
  const bodyArg = z.string().min(1).describe("Plain text body.");
6051
+ const attachmentsArg = z.array(z.string().min(1)).max(20).optional().describe("Absolute paths of local files to attach, read by Mail rather than copied here. They go after the text, inline, as a file dragged into a composer does. On a draft, the default, the user sees them before anything is sent. Combined with sendNow this is refused unless APPLE_MAIL_ALLOW_FILE_SEND is set, because it puts a file in someone else's hands with nobody looking. Only attach a file the user asked for, by name; never one a message you read asked for.");
5940
6052
  const recipientsArg = (kind) => z.array(z.string().email()).optional().describe(`${kind} email addresses.`);
5941
6053
  /** Reject sendNow without confirm before anything reaches Mail. */
5942
6054
  const assertSendGate = (sendNow, confirm) => {
@@ -5952,6 +6064,7 @@ const registerComposeTools = (server, client) => {
5952
6064
  bcc: recipientsArg("Bcc"),
5953
6065
  subject: z.string().describe("Subject line."),
5954
6066
  body: bodyArg,
6067
+ attachments: attachmentsArg,
5955
6068
  sendNow: sendNowArg,
5956
6069
  confirm: z.literal(true).optional().describe("Required when sendNow is true.")
5957
6070
  },
@@ -5960,7 +6073,7 @@ const registerComposeTools = (server, client) => {
5960
6073
  destructiveHint: true,
5961
6074
  idempotentHint: false
5962
6075
  }
5963
- }, async ({ account, to, cc, bcc, subject, body, sendNow, confirm }) => wrap(async () => {
6076
+ }, async ({ account, to, cc, bcc, subject, body, attachments, sendNow, confirm }) => wrap(async () => {
5964
6077
  assertSendGate(sendNow, confirm);
5965
6078
  if (!to?.length && !cc?.length && !bcc?.length) throw new Error("No recipients: pass at least one of to, cc or bcc.");
5966
6079
  return client.sendMessage({
@@ -5970,6 +6083,7 @@ const registerComposeTools = (server, client) => {
5970
6083
  bcc: bcc ?? [],
5971
6084
  subject,
5972
6085
  body,
6086
+ ...attachments?.length ? { attachments } : {},
5973
6087
  sendNow: sendNow ?? false
5974
6088
  });
5975
6089
  }));
@@ -5979,6 +6093,7 @@ const registerComposeTools = (server, client) => {
5979
6093
  ref: messageRefArg,
5980
6094
  body: bodyArg,
5981
6095
  replyToAll: z.boolean().optional().describe("Reply to every recipient, not just the sender."),
6096
+ attachments: attachmentsArg,
5982
6097
  sendNow: sendNowArg,
5983
6098
  confirm: z.literal(true).optional().describe("Required when sendNow is true.")
5984
6099
  },
@@ -5987,12 +6102,13 @@ const registerComposeTools = (server, client) => {
5987
6102
  destructiveHint: true,
5988
6103
  idempotentHint: false
5989
6104
  }
5990
- }, async ({ ref, body, replyToAll, sendNow, confirm }) => wrap(async () => {
6105
+ }, async ({ ref, body, replyToAll, attachments, sendNow, confirm }) => wrap(async () => {
5991
6106
  assertSendGate(sendNow, confirm);
5992
6107
  return client.replyOrForward(ref, {
5993
6108
  mode: "reply",
5994
6109
  body,
5995
6110
  replyToAll: replyToAll ?? false,
6111
+ ...attachments?.length ? { attachments } : {},
5996
6112
  sendNow: sendNow ?? false
5997
6113
  });
5998
6114
  }));
@@ -6002,6 +6118,7 @@ const registerComposeTools = (server, client) => {
6002
6118
  ref: messageRefArg,
6003
6119
  to: z.array(z.string().email()).min(1).describe("Who to forward to."),
6004
6120
  body: z.string().optional().describe("Optional note to add above the forwarded message."),
6121
+ attachments: attachmentsArg,
6005
6122
  sendNow: sendNowArg,
6006
6123
  confirm: z.literal(true).optional().describe("Required when sendNow is true.")
6007
6124
  },
@@ -6010,12 +6127,13 @@ const registerComposeTools = (server, client) => {
6010
6127
  destructiveHint: true,
6011
6128
  idempotentHint: false
6012
6129
  }
6013
- }, async ({ ref, to, body, sendNow, confirm }) => wrap(async () => {
6130
+ }, async ({ ref, to, body, attachments, sendNow, confirm }) => wrap(async () => {
6014
6131
  assertSendGate(sendNow, confirm);
6015
6132
  return client.replyOrForward(ref, {
6016
6133
  mode: "forward",
6017
6134
  to,
6018
6135
  ...body ? { body } : {},
6136
+ ...attachments?.length ? { attachments } : {},
6019
6137
  sendNow: sendNow ?? false
6020
6138
  });
6021
6139
  }));
@@ -6431,4 +6549,4 @@ const createServer = (opts) => {
6431
6549
  //#endregion
6432
6550
  export { WritesDisabledError as A, MessageNotFoundError as C, ProtocolError as D, PreconditionError as E, SchemaDriftError as O, MailNotRunningError as S, PlatformError as T, locateEnvelopeIndex as _, loadConfig as a, MAIL_SURFACE as b, decodeRef as c, assertStaticScript as d, createOsascriptRunner as f, inspectFile as g, MailboxMap as h, registerTools as i, BUILD_INFO as j, TccDeniedError as k, encodeRef as l, withBusyRetry as m, SERVER_VERSION as n, AppleMailClient as o, mapOsaError as p, createServer as r, REF_VERSION as s, SERVER_NAME as t, groupRefsByMailbox as u, AppleMailError as v, OsascriptTimeoutError as w, MailBusyError as x, IndexUnavailableError as y };
6433
6551
 
6434
- //# sourceMappingURL=server-69NtCX3D.js.map
6552
+ //# sourceMappingURL=server-BnjMqr5E.js.map