apple-mail-mcp 2.19.13 → 2.19.14
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/build/cli.js +22 -4
- package/build/index.js +41 -11
- package/package.json +1 -1
package/build/cli.js
CHANGED
|
@@ -58391,6 +58391,13 @@ function structuredRow(m, account, path) {
|
|
|
58391
58391
|
...env.messageId ? { messageId: env.messageId } : {}
|
|
58392
58392
|
};
|
|
58393
58393
|
}
|
|
58394
|
+
function describeMailboxFailure(error) {
|
|
58395
|
+
const raw = error instanceof Error ? error.message : String(error);
|
|
58396
|
+
const oneLine = raw.split("\n")[0].trim();
|
|
58397
|
+
const looksSensitive = /pass(word)?\s*[:=]|authorization:\s*\S|bearer\s+\S{10,}/i.test(oneLine);
|
|
58398
|
+
const safe = looksSensitive ? "IMAP error (detail redacted \u2014 response text looked like it might contain a credential)" : oneLine || "unknown error";
|
|
58399
|
+
return safe.length > 300 ? `${safe.slice(0, 300)}\u2026` : safe;
|
|
58400
|
+
}
|
|
58394
58401
|
function hasMailboxFlag(mailbox, wanted) {
|
|
58395
58402
|
const normalized = wanted.toLowerCase();
|
|
58396
58403
|
return [...mailbox.flags ?? []].some((flag) => flag.toLowerCase() === normalized);
|
|
@@ -58472,6 +58479,7 @@ async function run(args, listMode, deps) {
|
|
|
58472
58479
|
const newestPerMailbox = offset + limit;
|
|
58473
58480
|
const fetched = [];
|
|
58474
58481
|
const failedMailboxes = [];
|
|
58482
|
+
const failedMailboxReasons = {};
|
|
58475
58483
|
let totalMatched = 0;
|
|
58476
58484
|
for (const path of paths) {
|
|
58477
58485
|
try {
|
|
@@ -58480,14 +58488,16 @@ async function run(args, listMode, deps) {
|
|
|
58480
58488
|
fetched.push(...result.messages.map((message) => ({ message, path })));
|
|
58481
58489
|
} catch (error) {
|
|
58482
58490
|
failedMailboxes.push(path);
|
|
58491
|
+
failedMailboxReasons[path] = describeMailboxFailure(error);
|
|
58483
58492
|
console.error(
|
|
58484
58493
|
`IMAP ${listMode ? "list" : "search"} failed for account "${cfg.accountLabel}", mailbox "${path}": ${String(error)}`
|
|
58485
58494
|
);
|
|
58486
58495
|
}
|
|
58487
58496
|
}
|
|
58488
58497
|
if (failedMailboxes.length === paths.length) {
|
|
58498
|
+
const detail = failedMailboxes.map((path) => `${path} (${failedMailboxReasons[path]})`).join(", ");
|
|
58489
58499
|
throw new Error(
|
|
58490
|
-
`IMAP ${listMode ? "list" : "search"} failed in every requested mailbox for account ${cfg.accountLabel}: ${
|
|
58500
|
+
`IMAP ${listMode ? "list" : "search"} failed in every requested mailbox for account ${cfg.accountLabel}: ${detail}.`
|
|
58491
58501
|
);
|
|
58492
58502
|
}
|
|
58493
58503
|
let ordered = fetched;
|
|
@@ -58509,7 +58519,7 @@ async function run(args, listMode, deps) {
|
|
|
58509
58519
|
const partial = failedMailboxes.length > 0;
|
|
58510
58520
|
const failureNote = partial ? `
|
|
58511
58521
|
|
|
58512
|
-
Partial result. Could not search mailbox(es): ${failedMailboxes.map((path) => `"${path}"`).join(", ")}.` : "";
|
|
58522
|
+
Partial result. Could not search mailbox(es): ${failedMailboxes.map((path) => `"${path}" (${failedMailboxReasons[path]})`).join(", ")}.` : "";
|
|
58513
58523
|
const verb = listMode ? "listed" : "matched";
|
|
58514
58524
|
const scope = unscopedSearch ? allMailboxCount === 1 ? `mailbox "${paths[0]}"` : `${allMailboxCount} selectable mailboxes` : `mailbox "${paths[0]}"`;
|
|
58515
58525
|
if (messages.length === 0) {
|
|
@@ -58518,14 +58528,22 @@ Partial result. Could not search mailbox(es): ${failedMailboxes.map((path) => `"
|
|
|
58518
58528
|
messages,
|
|
58519
58529
|
count: 0,
|
|
58520
58530
|
partial,
|
|
58521
|
-
failedMailboxes
|
|
58531
|
+
failedMailboxes,
|
|
58532
|
+
failedMailboxReasons
|
|
58522
58533
|
};
|
|
58523
58534
|
}
|
|
58524
58535
|
const text = `Found ${rows.length} message(s) via IMAP (server-side, account ${cfg.accountLabel}, ${scope}; ${totalMatched} total ${verb}):
|
|
58525
58536
|
` + rows.join("\n") + `
|
|
58526
58537
|
|
|
58527
58538
|
Note: these IMAP IDs (imap:\u2026) work with get-message and the message mutations (mark/flag/move/delete-message), which route back to IMAP.` + failureNote;
|
|
58528
|
-
return {
|
|
58539
|
+
return {
|
|
58540
|
+
text,
|
|
58541
|
+
messages,
|
|
58542
|
+
count: messages.length,
|
|
58543
|
+
partial,
|
|
58544
|
+
failedMailboxes,
|
|
58545
|
+
failedMailboxReasons
|
|
58546
|
+
};
|
|
58529
58547
|
},
|
|
58530
58548
|
true
|
|
58531
58549
|
);
|
package/build/index.js
CHANGED
|
@@ -65720,6 +65720,13 @@ function structuredRow(m, account, path) {
|
|
|
65720
65720
|
...env.messageId ? { messageId: env.messageId } : {}
|
|
65721
65721
|
};
|
|
65722
65722
|
}
|
|
65723
|
+
function describeMailboxFailure(error2) {
|
|
65724
|
+
const raw = error2 instanceof Error ? error2.message : String(error2);
|
|
65725
|
+
const oneLine = raw.split("\n")[0].trim();
|
|
65726
|
+
const looksSensitive = /pass(word)?\s*[:=]|authorization:\s*\S|bearer\s+\S{10,}/i.test(oneLine);
|
|
65727
|
+
const safe = looksSensitive ? "IMAP error (detail redacted \u2014 response text looked like it might contain a credential)" : oneLine || "unknown error";
|
|
65728
|
+
return safe.length > 300 ? `${safe.slice(0, 300)}\u2026` : safe;
|
|
65729
|
+
}
|
|
65723
65730
|
function hasMailboxFlag(mailbox, wanted) {
|
|
65724
65731
|
const normalized = wanted.toLowerCase();
|
|
65725
65732
|
return [...mailbox.flags ?? []].some((flag) => flag.toLowerCase() === normalized);
|
|
@@ -65801,6 +65808,7 @@ async function run(args, listMode, deps) {
|
|
|
65801
65808
|
const newestPerMailbox = offset + limit;
|
|
65802
65809
|
const fetched = [];
|
|
65803
65810
|
const failedMailboxes = [];
|
|
65811
|
+
const failedMailboxReasons = {};
|
|
65804
65812
|
let totalMatched = 0;
|
|
65805
65813
|
for (const path of paths) {
|
|
65806
65814
|
try {
|
|
@@ -65809,14 +65817,16 @@ async function run(args, listMode, deps) {
|
|
|
65809
65817
|
fetched.push(...result.messages.map((message) => ({ message, path })));
|
|
65810
65818
|
} catch (error2) {
|
|
65811
65819
|
failedMailboxes.push(path);
|
|
65820
|
+
failedMailboxReasons[path] = describeMailboxFailure(error2);
|
|
65812
65821
|
console.error(
|
|
65813
65822
|
`IMAP ${listMode ? "list" : "search"} failed for account "${cfg.accountLabel}", mailbox "${path}": ${String(error2)}`
|
|
65814
65823
|
);
|
|
65815
65824
|
}
|
|
65816
65825
|
}
|
|
65817
65826
|
if (failedMailboxes.length === paths.length) {
|
|
65827
|
+
const detail = failedMailboxes.map((path) => `${path} (${failedMailboxReasons[path]})`).join(", ");
|
|
65818
65828
|
throw new Error(
|
|
65819
|
-
`IMAP ${listMode ? "list" : "search"} failed in every requested mailbox for account ${cfg.accountLabel}: ${
|
|
65829
|
+
`IMAP ${listMode ? "list" : "search"} failed in every requested mailbox for account ${cfg.accountLabel}: ${detail}.`
|
|
65820
65830
|
);
|
|
65821
65831
|
}
|
|
65822
65832
|
let ordered = fetched;
|
|
@@ -65838,7 +65848,7 @@ async function run(args, listMode, deps) {
|
|
|
65838
65848
|
const partial2 = failedMailboxes.length > 0;
|
|
65839
65849
|
const failureNote = partial2 ? `
|
|
65840
65850
|
|
|
65841
|
-
Partial result. Could not search mailbox(es): ${failedMailboxes.map((path) => `"${path}"`).join(", ")}.` : "";
|
|
65851
|
+
Partial result. Could not search mailbox(es): ${failedMailboxes.map((path) => `"${path}" (${failedMailboxReasons[path]})`).join(", ")}.` : "";
|
|
65842
65852
|
const verb = listMode ? "listed" : "matched";
|
|
65843
65853
|
const scope = unscopedSearch ? allMailboxCount === 1 ? `mailbox "${paths[0]}"` : `${allMailboxCount} selectable mailboxes` : `mailbox "${paths[0]}"`;
|
|
65844
65854
|
if (messages.length === 0) {
|
|
@@ -65847,14 +65857,22 @@ Partial result. Could not search mailbox(es): ${failedMailboxes.map((path) => `"
|
|
|
65847
65857
|
messages,
|
|
65848
65858
|
count: 0,
|
|
65849
65859
|
partial: partial2,
|
|
65850
|
-
failedMailboxes
|
|
65860
|
+
failedMailboxes,
|
|
65861
|
+
failedMailboxReasons
|
|
65851
65862
|
};
|
|
65852
65863
|
}
|
|
65853
65864
|
const text = `Found ${rows.length} message(s) via IMAP (server-side, account ${cfg.accountLabel}, ${scope}; ${totalMatched} total ${verb}):
|
|
65854
65865
|
` + rows.join("\n") + `
|
|
65855
65866
|
|
|
65856
65867
|
Note: these IMAP IDs (imap:\u2026) work with get-message and the message mutations (mark/flag/move/delete-message), which route back to IMAP.` + failureNote;
|
|
65857
|
-
return {
|
|
65868
|
+
return {
|
|
65869
|
+
text,
|
|
65870
|
+
messages,
|
|
65871
|
+
count: messages.length,
|
|
65872
|
+
partial: partial2,
|
|
65873
|
+
failedMailboxes,
|
|
65874
|
+
failedMailboxReasons
|
|
65875
|
+
};
|
|
65858
65876
|
},
|
|
65859
65877
|
true
|
|
65860
65878
|
);
|
|
@@ -87359,6 +87377,7 @@ async function fanOutImapMessages(args, kind, deps = {}, configs = resolveImapCo
|
|
|
87359
87377
|
const accountsQueried = [];
|
|
87360
87378
|
const accountsFailed = [];
|
|
87361
87379
|
const failedMailboxes = [];
|
|
87380
|
+
const failedMailboxReasons = {};
|
|
87362
87381
|
for (const config2 of configs) {
|
|
87363
87382
|
const perAccountArgs = { ...args, account: void 0 };
|
|
87364
87383
|
try {
|
|
@@ -87368,12 +87387,15 @@ async function fanOutImapMessages(args, kind, deps = {}, configs = resolveImapCo
|
|
|
87368
87387
|
failedMailboxes.push(
|
|
87369
87388
|
...res.failedMailboxes.map((mailbox) => `${config2.accountLabel} / ${mailbox}`)
|
|
87370
87389
|
);
|
|
87390
|
+
for (const [mailbox, reason] of Object.entries(res.failedMailboxReasons)) {
|
|
87391
|
+
failedMailboxReasons[`${config2.accountLabel} / ${mailbox}`] = reason;
|
|
87392
|
+
}
|
|
87371
87393
|
} catch (e) {
|
|
87372
87394
|
accountsFailed.push(config2.accountLabel);
|
|
87373
87395
|
console.error(`IMAP fan-out failed for account "${config2.accountLabel}": ${String(e)}`);
|
|
87374
87396
|
}
|
|
87375
87397
|
}
|
|
87376
|
-
return { rows, accountsQueried, accountsFailed, failedMailboxes };
|
|
87398
|
+
return { rows, accountsQueried, accountsFailed, failedMailboxes, failedMailboxReasons };
|
|
87377
87399
|
}
|
|
87378
87400
|
function configMatchesAccount(config2, account) {
|
|
87379
87401
|
const name = account.name.trim().toLowerCase();
|
|
@@ -87973,7 +87995,10 @@ var LIST_OUTPUT_SCHEMA = {
|
|
|
87973
87995
|
skippedLargeMailboxes: external_exports.array(external_exports.string()).optional(),
|
|
87974
87996
|
notSearchedMailboxes: external_exports.array(external_exports.string()).optional(),
|
|
87975
87997
|
timedOutAccounts: external_exports.array(external_exports.string()).optional(),
|
|
87976
|
-
failedMailboxes: external_exports.array(external_exports.string()).optional()
|
|
87998
|
+
failedMailboxes: external_exports.array(external_exports.string()).optional(),
|
|
87999
|
+
// Underlying error text per entry in `failedMailboxes`, same keys (#246
|
|
88000
|
+
// follow-up) — declared so a client can rely on it rather than parse text.
|
|
88001
|
+
failedMailboxReasons: external_exports.record(external_exports.string(), external_exports.string()).optional()
|
|
87977
88002
|
};
|
|
87978
88003
|
var BATCH_COUNT_OUTPUT_SCHEMA = {
|
|
87979
88004
|
ok: external_exports.boolean().optional(),
|
|
@@ -88063,7 +88088,8 @@ function mergedMessageResponse(fan, apple, limit, verb) {
|
|
|
88063
88088
|
skippedLargeMailboxes: diagnostics.skippedLargeMailboxes,
|
|
88064
88089
|
notSearchedMailboxes: diagnostics.notSearchedMailboxes,
|
|
88065
88090
|
timedOutAccounts: diagnostics.timedOutAccounts,
|
|
88066
|
-
failedMailboxes: fan.failedMailboxes
|
|
88091
|
+
failedMailboxes: fan.failedMailboxes,
|
|
88092
|
+
failedMailboxReasons: fan.failedMailboxReasons
|
|
88067
88093
|
};
|
|
88068
88094
|
const coverageBlock = partialCoverageBlock(diagnostics);
|
|
88069
88095
|
if (merged.length === 0) {
|
|
@@ -88165,7 +88191,8 @@ registerTool(
|
|
|
88165
88191
|
messages: r.messages,
|
|
88166
88192
|
count: r.count,
|
|
88167
88193
|
partial: r.partial,
|
|
88168
|
-
failedMailboxes: r.failedMailboxes
|
|
88194
|
+
failedMailboxes: r.failedMailboxes,
|
|
88195
|
+
failedMailboxReasons: r.failedMailboxReasons
|
|
88169
88196
|
});
|
|
88170
88197
|
}
|
|
88171
88198
|
const fan = await fanOutImapMessages(imapArgs, "search");
|
|
@@ -88548,7 +88575,8 @@ ${r.text}`, {
|
|
|
88548
88575
|
messages: r.messages,
|
|
88549
88576
|
count: r.count,
|
|
88550
88577
|
partial: r.partial,
|
|
88551
|
-
failedMailboxes: r.failedMailboxes
|
|
88578
|
+
failedMailboxes: r.failedMailboxes,
|
|
88579
|
+
failedMailboxReasons: r.failedMailboxReasons
|
|
88552
88580
|
});
|
|
88553
88581
|
}
|
|
88554
88582
|
const fan = await fanOutImapMessages({ subject: base, mailbox, limit }, "search");
|
|
@@ -88585,7 +88613,8 @@ ${r.text}`, {
|
|
|
88585
88613
|
messages: orderedRows,
|
|
88586
88614
|
count: orderedRows.length,
|
|
88587
88615
|
partial: partial2,
|
|
88588
|
-
failedMailboxes: fan.failedMailboxes
|
|
88616
|
+
failedMailboxes: fan.failedMailboxes,
|
|
88617
|
+
failedMailboxReasons: fan.failedMailboxReasons
|
|
88589
88618
|
};
|
|
88590
88619
|
if (orderedRows.length === 0) {
|
|
88591
88620
|
return successResponse(`No messages found in thread "${base}".${coverage}`, structured2);
|
|
@@ -88649,7 +88678,8 @@ registerTool(
|
|
|
88649
88678
|
messages: r.messages,
|
|
88650
88679
|
count: r.count,
|
|
88651
88680
|
partial: r.partial,
|
|
88652
|
-
failedMailboxes: r.failedMailboxes
|
|
88681
|
+
failedMailboxes: r.failedMailboxes,
|
|
88682
|
+
failedMailboxReasons: r.failedMailboxReasons
|
|
88653
88683
|
});
|
|
88654
88684
|
}
|
|
88655
88685
|
const fan = await fanOutImapMessages({ mailbox, limit, offset, from, unreadOnly }, "list");
|
package/package.json
CHANGED