@mgcrea/mcp-apple-mail 1.22.1 → 1.24.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/dist/cli.js +1 -1
- package/dist/index.d.ts +113 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{server-DsaFsRg0.js → server-Bowuusph.js} +717 -82
- package/dist/server-Bowuusph.js.map +1 -0
- package/package.json +2 -2
- package/dist/server-DsaFsRg0.js.map +0 -1
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-
|
|
2
|
+
import { a as loadConfig, b as MAIL_SURFACE, j as BUILD_INFO, r as createServer } from "./server-Bowuusph.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
|
@@ -103,11 +103,45 @@ type Config = z.infer<typeof ConfigSchema>;
|
|
|
103
103
|
declare const loadConfig: (env?: NodeJS.ProcessEnv) => Config;
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region src/client/ax.d.ts
|
|
106
|
+
/** One keystroke, as `apple_desktop_key` takes it. */
|
|
107
|
+
type Keystroke = {
|
|
108
|
+
key: string;
|
|
109
|
+
modifiers?: string[];
|
|
110
|
+
};
|
|
106
111
|
type ComposerRef = {
|
|
107
112
|
window: string;
|
|
108
113
|
body: string;
|
|
109
114
|
index: number;
|
|
110
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* A composer's own text, told apart from the original it quotes.
|
|
118
|
+
*
|
|
119
|
+
* MEASURED, macOS 27.0 (build 26A428), on a reply composer: `AXBlockQuoteLevel`
|
|
120
|
+
* reads 0 on every block the sender wrote and 1 on every block from the
|
|
121
|
+
* attribution line — `On <date>, <who> wrote:` — down, including the quoted
|
|
122
|
+
* message's images and links. The split is exact, which is what makes replacing
|
|
123
|
+
* a reply's text without touching its quote possible at all.
|
|
124
|
+
*
|
|
125
|
+
* **A FORWARD is quoted too**, and that was worth measuring rather than assuming:
|
|
126
|
+
* a forward reads as prose with a `Begin forwarded message:` header and nothing
|
|
127
|
+
* about it looks like a quotation, but that line and everything under it read
|
|
128
|
+
* level 1 on the same build. Had they read 0 the whole forwarded message would
|
|
129
|
+
* have counted as the sender's own text and been offered up for replacement.
|
|
130
|
+
*
|
|
131
|
+
* `blocks` counts the top-level elements above that boundary, NOT rendered
|
|
132
|
+
* lines: a paragraph that wraps is one block and two lines. So it is a floor for
|
|
133
|
+
* how many times the selection has to be extended, never a target — see
|
|
134
|
+
* `selectOwnText` in `revise.ts`, which converges upwards from it and verifies
|
|
135
|
+
* the answer before anything is replaced.
|
|
136
|
+
*/
|
|
137
|
+
type ComposerBody = {
|
|
138
|
+
/** What the sender wrote, blocks joined by newlines. "" when they wrote nothing. */
|
|
139
|
+
text: string;
|
|
140
|
+
/** Top-level elements above the quote. */
|
|
141
|
+
blocks: number;
|
|
142
|
+
/** Whether a quoted original follows. */
|
|
143
|
+
quoted: boolean;
|
|
144
|
+
};
|
|
111
145
|
type ReachReport = {
|
|
112
146
|
ok: boolean;
|
|
113
147
|
/** `accessibility` when Mail's windows cannot be read; null when they can. */
|
|
@@ -166,6 +200,20 @@ declare class MailAxLane {
|
|
|
166
200
|
* a new composer on screen.
|
|
167
201
|
*/
|
|
168
202
|
findComposer(subject: string, timeoutMs: number): Promise<ComposerRef | null>;
|
|
203
|
+
/**
|
|
204
|
+
* Every composer currently under this subject, in window order.
|
|
205
|
+
*
|
|
206
|
+
* `findComposer` takes the first match because it is looking for a window it
|
|
207
|
+
* just opened. Rewriting one that was already there is the opposite problem:
|
|
208
|
+
* the caller has to know whether the subject picks out ONE composer, because
|
|
209
|
+
* two under one title cannot be told apart — handles are minted per call —
|
|
210
|
+
* and replacing the body of the wrong one destroys what somebody wrote. So
|
|
211
|
+
* this returns the list and lets `revise.ts` refuse on its length.
|
|
212
|
+
*
|
|
213
|
+
* Does not poll. Nothing here opened a window, so there is nothing to wait
|
|
214
|
+
* for: the composer either is on screen or is not.
|
|
215
|
+
*/
|
|
216
|
+
findComposers(subject: string): Promise<ComposerRef[]>;
|
|
169
217
|
/** Bring Mail to the front. A synthetic keystroke lands in whatever is frontmost. */
|
|
170
218
|
activate(): Promise<void>;
|
|
171
219
|
/**
|
|
@@ -232,6 +280,25 @@ declare class MailAxLane {
|
|
|
232
280
|
* typed.
|
|
233
281
|
*/
|
|
234
282
|
paste(ref: ComposerRef, focusTimeoutMs?: number): Promise<boolean>;
|
|
283
|
+
/**
|
|
284
|
+
* Focus the composer's body and send a burst of keystrokes to it.
|
|
285
|
+
*
|
|
286
|
+
* What `paste` was, generalised, because replacing a reply's text without
|
|
287
|
+
* touching its quote is a sequence rather than one key: the caret goes to the
|
|
288
|
+
* top of the document, the selection is walked down to the end of the
|
|
289
|
+
* sender's own text, and only then is anything pasted over it.
|
|
290
|
+
*
|
|
291
|
+
* Sent through `apple_desktop_run` so a burst is ONE round trip. That is not
|
|
292
|
+
* only speed: every stroke in a run is checked before the first one is posted,
|
|
293
|
+
* and the run stops at the first failure, so a selection cannot be left
|
|
294
|
+
* half-extended by a refusal partway through.
|
|
295
|
+
*
|
|
296
|
+
* Each stroke names the body's handle, so the desktop server brings Mail
|
|
297
|
+
* forward before posting and refuses rather than typing into whatever the
|
|
298
|
+
* person at the keyboard just switched to.
|
|
299
|
+
*/
|
|
300
|
+
keys(ref: ComposerRef, strokes: Keystroke[], focusTimeoutMs?: number): Promise<boolean>;
|
|
301
|
+
composerBody(body: string): Promise<ComposerBody | null>;
|
|
235
302
|
/**
|
|
236
303
|
* Send the composer, or save it as a draft.
|
|
237
304
|
*
|
|
@@ -295,6 +362,19 @@ declare class MailAxLane {
|
|
|
295
362
|
maxQuoteLevel(body: string): Promise<number>;
|
|
296
363
|
}
|
|
297
364
|
//#endregion
|
|
365
|
+
//#region src/client/compose.d.ts
|
|
366
|
+
/**
|
|
367
|
+
* The pasteboard, as a seam.
|
|
368
|
+
*
|
|
369
|
+
* Injectable because the real one is shared machine state: a test that called
|
|
370
|
+
* `pbcopy` would clobber whatever the person running it had copied, which is
|
|
371
|
+
* not a thing a test suite may do.
|
|
372
|
+
*/
|
|
373
|
+
type Clipboard = {
|
|
374
|
+
read(): Promise<string | null>;
|
|
375
|
+
write(text: string): Promise<void>;
|
|
376
|
+
};
|
|
377
|
+
//#endregion
|
|
298
378
|
//#region src/client/mime.d.ts
|
|
299
379
|
type Attachment = {
|
|
300
380
|
filename: string | null;
|
|
@@ -581,6 +661,15 @@ type AppleMailClientOptions = {
|
|
|
581
661
|
* what the server does.
|
|
582
662
|
*/
|
|
583
663
|
ax?: MailAxLane | null | undefined;
|
|
664
|
+
/**
|
|
665
|
+
* The pasteboard, for tests.
|
|
666
|
+
*
|
|
667
|
+
* The same seam `compose.ts` already documents, hoisted to the client because
|
|
668
|
+
* `updateDraft` reaches the composer through it too. The real pasteboard is
|
|
669
|
+
* shared machine state and a test that wrote to it would clobber whatever the
|
|
670
|
+
* person running it had copied.
|
|
671
|
+
*/
|
|
672
|
+
clipboard?: Clipboard | undefined;
|
|
584
673
|
};
|
|
585
674
|
declare class AppleMailClient {
|
|
586
675
|
#private;
|
|
@@ -829,13 +918,31 @@ declare class AppleMailClient {
|
|
|
829
918
|
note?: string;
|
|
830
919
|
}>;
|
|
831
920
|
/**
|
|
832
|
-
* Replace a saved draft's body
|
|
921
|
+
* Replace a saved draft's body, editing it where that is possible and
|
|
922
|
+
* recreating it where it is not.
|
|
923
|
+
*
|
|
924
|
+
* ## Two lanes, and the order between them is the whole point
|
|
925
|
+
*
|
|
926
|
+
* **Editing the open composer comes first.** A draft whose composer is still
|
|
927
|
+
* on screen — which is every draft this server has just written, because
|
|
928
|
+
* nothing here closes one — can have its body replaced in that window, and
|
|
929
|
+
* the save lands on the same draft. Threading, attachments and the quoted
|
|
930
|
+
* original survive because nothing is remade. See `revise.ts`.
|
|
931
|
+
*
|
|
932
|
+
* **Recreating is the fallback.** It composes a replacement and deletes the
|
|
933
|
+
* original, which is the only thing Mail's scripting interface allows, and it
|
|
934
|
+
* is why `UPDATE_DRAFT` refuses a reply or a draft carrying attachments.
|
|
935
|
+
* Those refusals are costs of recreating, not of editing, so they must never
|
|
936
|
+
* be reached while a window that could simply be edited is open.
|
|
937
|
+
*
|
|
938
|
+
* The preflight that decides is only paid when there is a lane to decide for:
|
|
939
|
+
* with no accessibility lane — a package installed from npm and run by hand —
|
|
940
|
+
* this goes straight to recreation and costs exactly what it always did.
|
|
833
941
|
*
|
|
834
|
-
* The refusals
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
* message string.
|
|
942
|
+
* The refusals on both lanes come back as ordinary results carrying
|
|
943
|
+
* `replaced: false` rather than as thrown errors: a caller that cannot rewrite
|
|
944
|
+
* this draft still wants to know WHY and what to do instead, and both travel
|
|
945
|
+
* better as data than as a message string.
|
|
839
946
|
*
|
|
840
947
|
* What is enforced here instead is the shape of the request, before Mail is
|
|
841
948
|
* touched at all: an empty body would silently blank a draft the user wrote,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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/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;;;;;;;;;;;;;;;;;;;;;;;GA8CP,EAAA,KAAA;KAEC,SAAS,EAAE,aAAa;;;;;cAMvB,aAAU,MAAS,OAAO,eAA2B
|
|
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;;;;;;;;;;;;;;;;;;;;;;;GA8CP,EAAA,KAAA;KAEC,SAAS,EAAE,aAAa;;;;;cAMvB,aAAU,MAAS,OAAO,eAA2B;;;;KC+B7D;EAAc;EAAa;;KA2BpB;EAAgB;EAAgB;EAAc;;;;;;;;;;;;;;;;;;;;;;;KAuB9C;;EAEV;;EAEA;;EAEA;;KAGU;EACV;;EAEA;EACA;;cAGW;;UAGJ;;SAKA,KAAK,MAAK,OAAO,aAA2B;EAKnD;;EAKA,SAAS;;;;;;;;;;;;;;;;;;EAyBH,SAAS,QAAQ;;;;;;;;;SAqBhB,aAAa;;;;;;;;;;;;;;;;;EA0Bd,aAAa,iBAAiB,oBAAoB,QAAQ;;;;;;;;;;;;;;EA8B1D,cAAc,kBAAkB,QAAQ;;EAyBxC,YAAY;;;;;;;;;;;;;EAgBZ,SAAS,eAAe;;;;;;;;;;;;;;;;;;;;;;;E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4GP,SAAS,aAAa,gBAAgB,QAAQ;EAa9C,cAAc;IAClB;IACA;MACE;IAAU;IAAe;;;;;;;;;;EAsCvB,eACJ,aACA;IAAQ;MACP;IACD,SAAS;IACT,QAAQ;IACR;;IAEA;;EA2BI,iBACJ,aACA;IAAQ;IAAgB;MACvB;IACD;IACA;IACA;IACA;IACA;;;;;;;;;;;;;;;EA2HI,oBAAoB;IAEtB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;;;;;;;EA0HE,eACJ,aACA,kBACA;IAAQ;MACP;IAAU;IAAc;IAAe;;;EA+CpC,SACJ,gBACA;IAAS;IAAgB;IAAmB;IAAoB;MAC/D;IAAU;IAAiB;IAAgB;;EA6BxC,aACJ,gBACA;IAAQ;IAA4B;MACnC;IAAU;IAAe;IAAgB;IAAqB;;EAqD3D,eAAe,iBAAiB;IACpC;IACA;IACA;IACA;;;;;;;;;;;;;;EAuCI,cACJ,cACA,mBACC;IACD;IACA;IACA;IACA;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEI,YACJ,aACA;IAAQ;IAAc;MACrB,QAAQ;EAsCL,gBAAgB,mBAAmB;EAKnC,YAAY;IAChB;IACA;IACA;IACA;IACA;IACA;IACA;MACE;EAaE,eACJ,aACA;IACE;IACA;IACA;IACA;IACA;MAED;;;;;;;;;;;;;;;;;;;;;cC1zCQ;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-
|
|
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-Bowuusph.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 };
|