proton-mail-bridge-client 1.14.0 → 1.15.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAYV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAq/E1B,wBAAgB,kBAAkB,IAAI,gBAAgB,CAuFrD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4yEP;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmD1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAYnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAwD,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC5H,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAYV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAq/E1B,wBAAgB,kBAAkB,IAAI,gBAAgB,CA0FrD;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAq2EP;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmD1C"}
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { AuditService } from "./services/audit-service.js";
13
13
  import { BackgroundSyncService } from "./services/background-sync-service.js";
14
14
  import { DraftStoreService } from "./services/draft-store-service.js";
15
15
  import { LocalIndexService } from "./services/local-index-service.js";
16
- import { SimpleIMAPService } from "./services/simple-imap-service.js";
16
+ import { isLikelyAuthenticationError, isLikelyConnectionError, SimpleIMAPService } from "./services/simple-imap-service.js";
17
17
  import { SMTPService } from "./services/smtp-service.js";
18
18
  import { ensureValidEmails, isTextLikeMimeType, isValidEmail, lowerCaseAddress, normalizeBoolean, normalizeLimit, normalizeJsonValue, parseEmails, renderMarkdown, stringifyForJson, } from "./utils/helpers.js";
19
19
  import { logger } from "./utils/logger.js";
@@ -1043,7 +1043,7 @@ const TOOLS = [
1043
1043
  },
1044
1044
  {
1045
1045
  name: "run_doctor",
1046
- description: "Run a comprehensive production health check covering SMTP auth, IMAP auth, optional IMAP IDLE probe, SQLite index integrity, and runtime policy validation. Use to fully diagnose or validate the setup. Prefer get_connection_status for a quick protocol-only reachability check.",
1046
+ description: "Run a comprehensive production health check covering SMTP auth, IMAP auth, optional IMAP IDLE probe, SQLite index integrity, sync-failed drafts, runtime policy validation, and what this server can/cannot do (capabilities). Connection failures include a classified diagnosis (authentication_failed vs bridge_unreachable) with a specific fix. Use to fully diagnose or validate the setup. Prefer get_connection_status for a quick protocol-only reachability check.",
1047
1047
  annotations: { readOnlyHint: true },
1048
1048
  inputSchema: {
1049
1049
  type: "object",
@@ -2355,7 +2355,10 @@ export function buildConfigFromEnv() {
2355
2355
  allowRemoteDraftSync,
2356
2356
  allowedActions: parseAllowedActionsEnv("PROTONMAIL_ALLOWED_ACTIONS"),
2357
2357
  startupSync: parseBooleanEnv("PROTONMAIL_STARTUP_SYNC", autoSync),
2358
- autoSyncFolder: process.env.PROTONMAIL_AUTO_SYNC_FOLDER?.trim() || "INBOX",
2358
+ // Comma-separated; Sent is included by default so pendingOn/digest/follow-up
2359
+ // candidates don't misreport threads that were already answered — IDLE still
2360
+ // only watches the first folder (see BackgroundSyncService.primaryIdleFolder).
2361
+ autoSyncFolder: process.env.PROTONMAIL_AUTO_SYNC_FOLDER?.trim() || "INBOX,Sent",
2359
2362
  autoSyncFull: parseBooleanEnv("PROTONMAIL_AUTO_SYNC_FULL", false),
2360
2363
  autoSyncLimitPerFolder: parseIntegerEnv("PROTONMAIL_AUTO_SYNC_LIMIT_PER_FOLDER", 100, 1, 500),
2361
2364
  idleWatchEnabled,
@@ -3730,7 +3733,7 @@ export function createServer(config, options = {}) {
3730
3733
  const includeImap = normalizeBoolean(args.includeImap, true);
3731
3734
  const includeIdleProbe = normalizeBoolean(args.includeIdleProbe, false);
3732
3735
  const idleTimeoutSeconds = normalizeLimit(args.idleTimeoutSeconds, 5, 1, 60);
3733
- const [smtpStatus, imapStatus, indexStatus, integrity] = await Promise.all([
3736
+ const [smtpStatus, imapStatus, indexStatus, integrity, drafts] = await Promise.all([
3734
3737
  includeSmtp
3735
3738
  ? Promise.allSettled([smtpService.verifyConnection()]).then(([result]) => result)
3736
3739
  : Promise.resolve({ status: "fulfilled", value: undefined }),
@@ -3739,6 +3742,7 @@ export function createServer(config, options = {}) {
3739
3742
  : Promise.resolve({ status: "fulfilled", value: undefined }),
3740
3743
  localIndexService.getStatus(),
3741
3744
  localIndexService.runIntegrityCheck(),
3745
+ draftStore.listDrafts(true),
3742
3746
  ]);
3743
3747
  const idleProbe = includeIdleProbe
3744
3748
  ? await Promise.allSettled([
@@ -3748,6 +3752,24 @@ export function createServer(config, options = {}) {
3748
3752
  }),
3749
3753
  ]).then(([result]) => result)
3750
3754
  : undefined;
3755
+ // Classifies the connection failure into a specific, actionable cause —
3756
+ // without PROTONMAIL_DEBUG this used to just say "connection failed" for
3757
+ // both a wrong password and Bridge not being open at all.
3758
+ const diagnoseFailure = (reason) => {
3759
+ if (isLikelyAuthenticationError(reason)) {
3760
+ return {
3761
+ cause: "authentication_failed",
3762
+ suggestion: "PROTONMAIL_PASSWORD must be the Proton Bridge password (Bridge app -> account -> Mailbox details), not your Proton account password. Confirm you're signed in inside the Bridge app.",
3763
+ };
3764
+ }
3765
+ if (isLikelyConnectionError(reason)) {
3766
+ return {
3767
+ cause: "bridge_unreachable",
3768
+ suggestion: "Proton Bridge isn't reachable on the configured host/port. Make sure the Bridge app is running, and that PROTONMAIL_IMAP_HOST/PORT and PROTONMAIL_SMTP_HOST/PORT match Bridge's Mailbox details.",
3769
+ };
3770
+ }
3771
+ return undefined;
3772
+ };
3751
3773
  return createTextResult({
3752
3774
  checkedAt: new Date().toISOString(),
3753
3775
  runtime: sanitizeRuntimeConfig(config.runtime),
@@ -3761,6 +3783,7 @@ export function createServer(config, options = {}) {
3761
3783
  ? smtpStatus.reason.message
3762
3784
  : String(smtpStatus.reason)
3763
3785
  : "SMTP connection failed.",
3786
+ ...(smtpStatus.status === "rejected" ? { diagnosis: diagnoseFailure(smtpStatus.reason) } : {}),
3764
3787
  },
3765
3788
  imap: {
3766
3789
  ok: imapStatus.status === "fulfilled",
@@ -3773,6 +3796,7 @@ export function createServer(config, options = {}) {
3773
3796
  ? imapStatus.reason.message
3774
3797
  : String(imapStatus.reason)
3775
3798
  : "IMAP connection failed.",
3799
+ ...(imapStatus.status === "rejected" ? { diagnosis: diagnoseFailure(imapStatus.reason) } : {}),
3776
3800
  },
3777
3801
  idleProbe: idleProbe === undefined
3778
3802
  ? { skipped: true }
@@ -3789,9 +3813,28 @@ export function createServer(config, options = {}) {
3789
3813
  backgroundSync: backgroundSyncService.getStatus(),
3790
3814
  index: indexStatus,
3791
3815
  integrity,
3816
+ drafts: {
3817
+ total: drafts.length,
3818
+ syncFailed: drafts.filter((draft) => draft.remoteSyncState === "sync_failed").length,
3819
+ syncFailedIds: drafts
3820
+ .filter((draft) => draft.remoteSyncState === "sync_failed")
3821
+ .map((draft) => draft.id),
3822
+ },
3792
3823
  audit: {
3793
3824
  path: auditService.getPath(),
3794
3825
  },
3826
+ // What this server can and cannot do, given Proton Bridge only proxies
3827
+ // local IMAP/SMTP — prevents an agent from attempting an impossible
3828
+ // operation (e.g. server-side filters) and getting a confusing failure.
3829
+ capabilities: {
3830
+ supported: ["mail read/search/send", "folders", "labels (IMAP folders under Labels/)", "drafts", "local full-text index"],
3831
+ notSupported: [
3832
+ "server-side filters/rules (no ManageSieve access through Bridge)",
3833
+ "real contacts / address book (no CardDAV access through Bridge)",
3834
+ "calendar (no CalDAV access through Bridge)",
3835
+ "vacation responder (Proton account API only, not exposed via Bridge)",
3836
+ ],
3837
+ },
3795
3838
  });
3796
3839
  }
3797
3840
  case "get_runtime_status": {
@@ -4286,7 +4329,13 @@ export function createServer(config, options = {}) {
4286
4329
  throw error;
4287
4330
  }
4288
4331
  logger.error("Tool call failed", "MCPServer", { name, error });
4289
- throw new McpError(ErrorCode.InternalError, "An internal error occurred. Check get_logs for details.");
4332
+ if (isLikelyAuthenticationError(error)) {
4333
+ throw new McpError(ErrorCode.InternalError, "IMAP authentication failed. Check that PROTONMAIL_PASSWORD is your Proton Bridge password (not your Proton account password) and that you're signed in inside the Bridge app. Run run_doctor for a full connectivity check.");
4334
+ }
4335
+ if (isLikelyConnectionError(error)) {
4336
+ throw new McpError(ErrorCode.InternalError, "Could not connect to Proton Bridge. Make sure the Bridge app is running, and that PROTONMAIL_IMAP_HOST/PORT and PROTONMAIL_SMTP_HOST/PORT match the ports shown in Bridge's settings. Run run_doctor for a full connectivity check.");
4337
+ }
4338
+ throw new McpError(ErrorCode.InternalError, "An internal error occurred. Check get_logs for details, or run run_doctor for a full connectivity check.");
4290
4339
  }
4291
4340
  });
4292
4341
  return {