apple-mail-mcp 2.14.0 → 2.14.1

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.
Files changed (2) hide show
  1. package/build/index.js +57 -7
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -79470,16 +79470,61 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79470
79470
  set _sMiss to ""
79471
79471
  set _sPairs to {}
79472
79472
  set _sChunk to ${chunk}
79473
+ -- The mailbox's MEASURED length, emitted only when it disagrees with the
79474
+ -- count (#187). -1 = "not measured", which is the normal case: the probe
79475
+ -- only runs a binary search when the count's last position is unreadable.
79476
+ -- Initialised here, not in the else-branch, or the skipped/unavailable
79477
+ -- paths would reference an unbound variable when emitting.
79478
+ set _sTrue to -1
79473
79479
  if ${countVar} < 0 then
79474
79480
  set _sStatus to "unavailable"
79475
79481
  else if ${countVar} > ${max} then
79476
79482
  set _sStatus to "skipped"
79477
79483
  set _sPayload to "mailbox holds " & (${countVar} as string) & " messages, above ${AUDIT_SNAPSHOT_MAX_ENV}=${max}"
79478
79484
  else
79485
+ -- #187: the count can read HIGH, and an out-of-range range RAISES as
79486
+ -- a whole rather than clamping. On a mailbox smaller than one chunk
79487
+ -- there is only ONE slice, so a high count made it fail entirely:
79488
+ -- _sPairs stayed empty, the status collapsed to "unavailable", and
79489
+ -- the record carried no holes and no warning. The collateral
79490
+ -- instrument switched itself off in exactly the stale direction #155
79491
+ -- evidences, silently.
79492
+ --
79493
+ -- So establish a bound that actually EXISTS before slicing. If the
79494
+ -- last position the count claims is readable, the count is not high
79495
+ -- and this costs one probe. Otherwise binary-search the true end,
79496
+ -- which is O(log n) probes and also MEASURES how stale the count is.
79497
+ set _sBound to ${countVar}
79498
+ if _sBound > 0 then
79499
+ set _sEndOk to false
79500
+ try
79501
+ get id of message _sBound of ${mbVar}
79502
+ set _sEndOk to true
79503
+ end try
79504
+ if not _sEndOk then
79505
+ set _sLoB to 0
79506
+ set _sHiB to _sBound
79507
+ repeat while (_sHiB - _sLoB) > 1
79508
+ set _sMid to (_sLoB + _sHiB) div 2
79509
+ set _sMidOk to false
79510
+ try
79511
+ get id of message _sMid of ${mbVar}
79512
+ set _sMidOk to true
79513
+ end try
79514
+ if _sMidOk then
79515
+ set _sLoB to _sMid
79516
+ else
79517
+ set _sHiB to _sMid
79518
+ end if
79519
+ end repeat
79520
+ set _sBound to _sLoB
79521
+ set _sTrue to _sLoB
79522
+ end if
79523
+ end if
79479
79524
  set _sLo to 1
79480
- repeat while _sLo <= ${countVar}
79525
+ repeat while _sLo <= _sBound
79481
79526
  set _sHi to _sLo + _sChunk - 1
79482
- if _sHi > ${countVar} then set _sHi to ${countVar}
79527
+ if _sHi > _sBound then set _sHi to _sBound
79483
79528
  set _sGot to false
79484
79529
  repeat with _sTry from 1 to ${SNAPSHOT_SLICE_ATTEMPTS}
79485
79530
  set _sIds to {}
@@ -79537,7 +79582,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79537
79582
  -- PARTIAL under the existing rules and withholds the halves a
79538
79583
  -- truncation would poison.
79539
79584
  try
79540
- set _sOverId to ((id of message (${countVar} + 1) of ${mbVar}) as string)
79585
+ set _sOverId to ((id of message (_sBound + 1) of ${mbVar}) as string)
79541
79586
  -- A specifier that CLAMPS rather than raising hands back the LAST
79542
79587
  -- message instead of failing. That is not evidence of a truncation,
79543
79588
  -- so only an id this enumeration did not already record counts.
@@ -79547,7 +79592,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79547
79592
  end repeat
79548
79593
  if not _sSeen then
79549
79594
  if _sMiss is not "" then set _sMiss to _sMiss & ","
79550
- set _sMiss to _sMiss & ((${countVar} + 1) as string) & "-end"
79595
+ set _sMiss to _sMiss & ((_sBound + 1) as string) & "-end"
79551
79596
  end if
79552
79597
  end try
79553
79598
  if _sMiss is not "" then
@@ -79562,7 +79607,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79562
79607
  set _sPayload to _sPairs as string
79563
79608
  set AppleScript's text item delimiters to _sTid
79564
79609
  end if
79565
- set _out to _out & "${SNAP_TAG}${FIELD_SEP}" & ${acctExpr} & "${FIELD_SEP}" & ${mbExpr} & "${FIELD_SEP}${phase}${FIELD_SEP}" & _sStatus & "${FIELD_SEP}" & _sPayload & "${FIELD_SEP}" & _sMiss & "${RECORD_SEP}"`;
79610
+ set _out to _out & "${SNAP_TAG}${FIELD_SEP}" & ${acctExpr} & "${FIELD_SEP}" & ${mbExpr} & "${FIELD_SEP}${phase}${FIELD_SEP}" & _sStatus & "${FIELD_SEP}" & _sPayload & "${FIELD_SEP}" & _sMiss & "${FIELD_SEP}" & (_sTrue as string) & "${RECORD_SEP}"`;
79566
79611
  }
79567
79612
  /**
79568
79613
  * AppleScript capturing the message the op is ABOUT to touch into `_pre`,
@@ -79623,13 +79668,15 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79623
79668
  continue;
79624
79669
  }
79625
79670
  if (f[0] === SNAP_TAG) {
79671
+ const measured = f[7] !== void 0 && f[7] !== "" ? Number(f[7]) : -1;
79626
79672
  snaps.push({
79627
79673
  account: f[1] ?? "",
79628
79674
  mailbox: f[2] ?? "",
79629
79675
  phase: f[3] === "after" ? "after" : "before",
79630
79676
  status: f[4] ?? "",
79631
79677
  payload: f[5] ?? "",
79632
- miss: f[6] ?? ""
79678
+ miss: f[6] ?? "",
79679
+ ...Number.isFinite(measured) && measured >= 0 ? { measuredLength: measured } : {}
79633
79680
  });
79634
79681
  continue;
79635
79682
  }
@@ -79813,6 +79860,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79813
79860
  const unrequested = disappeared.filter(
79814
79861
  (e) => !requestedNumericIds.has(canonicalNumericId(e.id))
79815
79862
  );
79863
+ const countStale = [b, a].filter((s) => s.measuredLength !== void 0).map((s) => ({ phase: s.phase, measuredLength: s.measuredLength }));
79816
79864
  const holes = [b, a].filter((s) => s.miss !== "").map((s) => ({ phase: s.phase, ranges: s.miss }));
79817
79865
  if (holes.length === 0) {
79818
79866
  collateral.push({
@@ -79821,7 +79869,8 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79821
79869
  snapshot: "ok",
79822
79870
  disappeared,
79823
79871
  unrequested,
79824
- appeared
79872
+ appeared,
79873
+ ...countStale.length ? { countStale } : {}
79825
79874
  });
79826
79875
  continue;
79827
79876
  }
@@ -79833,6 +79882,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
79833
79882
  account: g.account,
79834
79883
  mailbox: g.mailbox,
79835
79884
  snapshot: "partial",
79885
+ ...countStale.length ? { countStale } : {},
79836
79886
  skipReason: `Mail would not read ${holes.map((h) => `${h.ranges} (${h.phase})`).join(", ")} of this mailbox, so the snapshot has a hole in it. ` + (derivable.length > 0 ? `Still derivable and reported: ${derivable.join(" and ")}. ` : `Neither half of the diff is derivable from it. `) + `Anything the unread range could refute is omitted rather than guessed \u2014 an absent field here means "not computable", not "empty".`,
79837
79887
  unobserved: holes,
79838
79888
  ...a.miss === "" ? { disappeared, unrequested } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-mail-mcp",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "description": "MCP server for Apple Mail - read, search, send, and manage emails via Claude and other AI assistants",
5
5
  "type": "module",
6
6
  "main": "build/index.js",