@openclaw/imessage 2026.8.1-beta.3 → 2026.8.2

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 (156) hide show
  1. package/dist/{accounts-D00Njxg2.js → accounts-CCirBEIm.js} +4 -5
  2. package/dist/{actions.runtime-B_xJiBXF.js → actions.runtime-UDLBuS_8.js} +5 -5
  3. package/dist/api.js +6 -5
  4. package/dist/{approval-handler.runtime-BKku8aUf.js → approval-handler.runtime-ZaQQ2c4l.js} +9 -8
  5. package/dist/{approval-reactions-BME5eA6T.js → approval-reactions-B2-_97DN.js} +7 -11
  6. package/dist/{channel-BFQTpvrG.js → channel-B0wzN0uJ.js} +18 -16
  7. package/dist/channel-config-api.js +1 -1
  8. package/dist/channel-plugin-api.js +1 -1
  9. package/dist/{channel.runtime-BjkXwX9_.js → channel.runtime-lJfW7FBd.js} +60 -13
  10. package/dist/{config-schema-DV0KP5nC.js → config-schema-DuGbA8Kp.js} +8 -7
  11. package/dist/contract-api.js +1 -1
  12. package/dist/doctor-contract-api.js +8 -281
  13. package/dist/{group-policy-Ca3c5KES.js → group-policy-fYokgrgz.js} +25 -23
  14. package/dist/media-contract-api.js +1 -1
  15. package/dist/{media-contract-BEgdvYhW.js → media-contract-pns3TSS5.js} +3 -2
  16. package/dist/{message-tool-api-TZiNYA17.js → message-tool-api-CLWaomvw.js} +9 -7
  17. package/dist/message-tool-api.js +1 -1
  18. package/dist/{monitor-Uv5RaRTk.js → monitor-CSTZ-GFU.js} +304 -40
  19. package/dist/{question-reactions-to0i8vxE.js → question-reactions-viP7ZcyG.js} +1 -1
  20. package/dist/{reaction-context-DaNrZqYo.js → reaction-context-BAYI7pz0.js} +2 -2
  21. package/dist/{remote-file-CDuk0joc.js → remote-file-CmdycSRk.js} +9 -8
  22. package/dist/runtime-Cza4CY5T.js +8 -0
  23. package/dist/runtime-api.js +10 -9
  24. package/dist/{sanitize-outbound-DaLmdkbf.js → sanitize-outbound-DKRlFQoD.js} +371 -80
  25. package/dist/{send-Dake4Awx.js → send-DxhFcMfW.js} +146 -24
  26. package/dist/state-contract-DvahEY4X.js +56 -0
  27. package/dist/state-migrations-BhY4RwjU.js +277 -0
  28. package/node_modules/typebox/build/format/date.d.mts +1 -1
  29. package/node_modules/typebox/build/format/date.mjs +1 -1
  30. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  31. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  32. package/node_modules/typebox/build/format/email.d.mts +1 -1
  33. package/node_modules/typebox/build/format/email.mjs +2 -2
  34. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  35. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  36. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  37. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  38. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  39. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  40. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  41. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  42. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  43. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  44. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  45. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  46. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +41 -0
  47. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  48. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  49. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  50. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  51. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  52. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  53. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  54. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  55. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  56. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  57. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  58. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  59. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  60. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  61. package/node_modules/typebox/build/format/iri.mjs +26 -8
  62. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  63. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  64. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  65. package/node_modules/typebox/build/format/regex.mjs +2 -6
  66. package/node_modules/typebox/build/format/time.d.mts +2 -2
  67. package/node_modules/typebox/build/format/time.mjs +19 -14
  68. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  69. package/node_modules/typebox/build/format/uri.mjs +3 -130
  70. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  71. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  72. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  73. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  74. package/node_modules/typebox/build/format/url.d.mts +3 -3
  75. package/node_modules/typebox/build/format/url.mjs +4 -5
  76. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  77. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  78. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  79. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  80. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  81. package/node_modules/typebox/build/guard/string.mjs +7 -7
  82. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  83. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  84. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  85. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  86. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  87. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  88. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  89. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  90. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  91. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  92. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  93. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  94. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  95. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  96. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  97. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  98. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  99. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  100. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  101. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  102. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  103. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  104. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  105. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  106. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  107. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  108. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  109. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  110. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  111. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  112. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  113. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  114. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  115. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  116. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  117. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  118. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  119. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  120. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  121. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  122. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  123. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  124. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  125. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  126. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  127. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  128. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  129. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  130. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  131. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  132. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  133. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  134. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  135. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  136. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  137. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  138. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  139. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  140. package/node_modules/typebox/package.json +27 -27
  141. package/node_modules/typebox/readme.md +79 -82
  142. package/openclaw.plugin.json +0 -6
  143. package/package.json +5 -5
  144. package/dist/catchup-Dh-Rv4Ur.js +0 -294
  145. package/dist/monitor-reply-cache-BdeUQaHO.js +0 -353
  146. package/dist/persisted-echo-cache-DGxy-J4t.js +0 -143
  147. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  148. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  149. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  150. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  151. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  152. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  153. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  154. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  155. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  156. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -1,21 +1,21 @@
1
- import { d as resolveIMessageChatDbLookupPath, l as resolveIMessageRemoteHost, n as hasExclusiveIMessageLocalDatabase, o as resolveIMessageAccount } from "./accounts-D00Njxg2.js";
2
- import { l as parseIMessageTarget, n as formatIMessageChatTarget, s as normalizeIMessageHandle } from "./message-tool-api-TZiNYA17.js";
3
- import { c as rememberIMessageReplyCache, h as chatContextFromIMessageTarget, p as getOptionalIMessageRuntime, v as resolveIMessageDirectChatService } from "./monitor-reply-cache-BdeUQaHO.js";
4
- import { a as IMessageRpcRequestError, n as sanitizeIMessageFinalOutboundText, o as createIMessageRpcClient, t as protectIMessageFencedRoleMarkers } from "./sanitize-outbound-DaLmdkbf.js";
5
- import { _ as imessageApprovalAuth, g as getIMessageApprovalApprovers } from "./group-policy-Ca3c5KES.js";
6
- import { a as rememberPersistedIMessageEcho, r as forgetPersistedIMessageEchoKey } from "./persisted-echo-cache-DGxy-J4t.js";
7
- import { d as normalizeConversationKey, f as normalizeIMessageGuid, i as registerIMessageApprovalReactionTarget, l as enumerateApprovalTargetKeys, s as buildIMessageApprovalConversationKeyForInbound, u as enumerateConversationKeyForms } from "./approval-reactions-BME5eA6T.js";
8
- import { i as runIMessageCliJsonCommand, r as resolveAuthorizedIMessageReplyReference, t as withIMessageRemoteFile } from "./remote-file-CDuk0joc.js";
1
+ import { d as resolveIMessageChatDbLookupPath, l as resolveIMessageRemoteHost, n as hasExclusiveIMessageLocalDatabase, o as resolveIMessageAccount } from "./accounts-CCirBEIm.js";
2
+ import { l as parseIMessageTarget, n as formatIMessageChatTarget, s as normalizeIMessageHandle } from "./message-tool-api-CLWaomvw.js";
3
+ import { a as IMessageRpcRequestError, h as chatContextFromIMessageTarget, n as sanitizeIMessageFinalOutboundText, o as createIMessageRpcClient, t as protectIMessageFencedRoleMarkers, u as rememberIMessageReplyCache, v as resolveIMessageDirectChatService } from "./sanitize-outbound-DKRlFQoD.js";
4
+ import { l as getIMessageApprovalApprovers, u as imessageApprovalAuth } from "./group-policy-fYokgrgz.js";
5
+ import { n as getOptionalIMessageRuntime, t as getIMessageRuntime } from "./runtime-Cza4CY5T.js";
6
+ import { c as IMESSAGE_SENT_ECHOES_TTL_MS, d as resolveIMessageEchoMediaKey, p as resolveIMessageSentEchoEntryKey, s as IMESSAGE_SENT_ECHOES_NAMESPACE } from "./state-contract-DvahEY4X.js";
7
+ import { d as normalizeConversationKey, f as normalizeIMessageGuid, i as registerIMessageApprovalReactionTarget, l as enumerateApprovalTargetKeys, s as buildIMessageApprovalConversationKeyForInbound, u as enumerateConversationKeyForms } from "./approval-reactions-B2-_97DN.js";
8
+ import { i as runIMessageCliJsonCommand, r as resolveAuthorizedIMessageReplyReference, t as withIMessageRemoteFile } from "./remote-file-CmdycSRk.js";
9
9
  import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
10
10
  import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
11
11
  import { accessSync, constants } from "node:fs";
12
12
  import { basename } from "node:path";
13
13
  import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
14
- import { sleep } from "openclaw/plugin-sdk/runtime-env";
14
+ import { logVerbose, sleep } from "openclaw/plugin-sdk/runtime-env";
15
+ import { extractOriginalFilename, kindFromMime, resolveOutboundAttachmentFromUrl } from "openclaw/plugin-sdk/media-runtime";
15
16
  import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
16
17
  import { PlatformMessageNotDispatchedError, isApprovalNotFoundError } from "openclaw/plugin-sdk/error-runtime";
17
18
  import { addApprovalReactionHintToText, createApprovalReactionTargetStore, listApprovalReactionBindings } from "openclaw/plugin-sdk/approval-reaction-runtime";
18
- import { extractOriginalFilename, kindFromMime, resolveOutboundAttachmentFromUrl } from "openclaw/plugin-sdk/media-runtime";
19
19
  import { convertMarkdownTables, stripInlineDirectiveTagsForDelivery } from "openclaw/plugin-sdk/text-chunking";
20
20
  import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
21
21
  import { openNodeSqliteDatabase } from "openclaw/plugin-sdk/sqlite-runtime";
@@ -94,14 +94,14 @@ const iMessageApprovalControlBindings = {
94
94
  const TARGET_NAMESPACE = "imessage.approval-polls";
95
95
  const TOMBSTONE_NAMESPACE = "imessage.approval-poll-tombstones";
96
96
  const MAX_ENTRIES = 1e3;
97
- const DEFAULT_TARGET_TTL_MS = 1440 * 60 * 1e3;
97
+ const DEFAULT_TARGET_TTL_MS = 864e5;
98
98
  /**
99
99
  * Messages has no close-poll API, so a resolved approval's balloon stays
100
100
  * tappable forever. Tombstones outlive the binding so late taps are swallowed
101
101
  * instead of reaching the agent as "Poll vote: ..." prose. Persisted, because a
102
102
  * gateway restart must not turn old polls back into chat noise.
103
103
  */
104
- const TOMBSTONE_TTL_MS = 720 * 60 * 60 * 1e3;
104
+ const TOMBSTONE_TTL_MS = 2592e6;
105
105
  const APPROVAL_DECISIONS = /* @__PURE__ */ new Set([
106
106
  "allow-once",
107
107
  "allow-always",
@@ -453,6 +453,127 @@ const iMessageApprovalPollTargets = {
453
453
  clearForTest: clearIMessageApprovalPollTargetsForTest
454
454
  };
455
455
  //#endregion
456
+ //#region extensions/imessage/src/monitor/echo-text-corruption.ts
457
+ function isLeadingEchoTextCorruptionMarker(code) {
458
+ return code === 0 || code === 65279 || code === 65533 || code === 65534 || code === 65535;
459
+ }
460
+ function stripLeadingEchoTextCorruptionMarkers(text) {
461
+ let offset = 0;
462
+ while (offset < text.length && isLeadingEchoTextCorruptionMarker(text.charCodeAt(offset))) offset += 1;
463
+ return offset === 0 ? text : text.slice(offset);
464
+ }
465
+ //#endregion
466
+ //#region extensions/imessage/src/monitor/persisted-echo-cache.ts
467
+ function normalizeText(text) {
468
+ if (!text) return;
469
+ return stripLeadingEchoTextCorruptionMarkers(text.replace(/\r\n?/g, "\n").trim()).trim() || void 0;
470
+ }
471
+ function normalizeMessageId(messageId) {
472
+ const normalized = messageId?.trim();
473
+ if (!normalized || normalized === "ok" || normalized === "unknown") return;
474
+ return normalized;
475
+ }
476
+ let mirror = null;
477
+ let persistenceFailureLogged = false;
478
+ function reportFailure(scope, err) {
479
+ if (persistenceFailureLogged) return;
480
+ persistenceFailureLogged = true;
481
+ logVerbose(`imessage echo-cache: ${scope} disabled after first failure: ${String(err)}`);
482
+ }
483
+ function normalizeMedia(media) {
484
+ if (!resolveIMessageEchoMediaKey(media)) return;
485
+ const contentType = media?.contentType?.trim().toLowerCase() || void 0;
486
+ const kind = media?.kind ?? void 0;
487
+ return {
488
+ ...kind ? { kind } : {},
489
+ ...contentType ? { contentType } : {}
490
+ };
491
+ }
492
+ function openPersistedEchoStore() {
493
+ return getIMessageRuntime().state.openSyncKeyedStore({
494
+ namespace: IMESSAGE_SENT_ECHOES_NAMESPACE,
495
+ maxEntries: 256
496
+ });
497
+ }
498
+ function remainingTtlMs(timestamp) {
499
+ const remaining = IMESSAGE_SENT_ECHOES_TTL_MS - Math.max(0, Date.now() - timestamp);
500
+ return remaining > 0 ? remaining : void 0;
501
+ }
502
+ function resolveEntryTtlMs(entry, ttlMs) {
503
+ if (typeof ttlMs === "number" && Number.isFinite(ttlMs) && ttlMs > 0) return ttlMs;
504
+ return remainingTtlMs(entry.timestamp);
505
+ }
506
+ function isLiveEntry(entry, now = Date.now()) {
507
+ const cutoff = now - IMESSAGE_SENT_ECHOES_TTL_MS;
508
+ return entry.timestamp >= cutoff && (entry.expiresAt == null || entry.expiresAt > now);
509
+ }
510
+ function loadMirrorFromStore() {
511
+ try {
512
+ mirror = openPersistedEchoStore().entries().map(({ value }) => value).filter((entry) => isLiveEntry(entry)).toSorted((a, b) => a.timestamp - b.timestamp).slice(-256);
513
+ } catch (err) {
514
+ reportFailure("read", err);
515
+ mirror = [];
516
+ }
517
+ }
518
+ function readRecentEntries() {
519
+ loadMirrorFromStore();
520
+ return mirror ?? [];
521
+ }
522
+ function persistEntry(entry, ttlMs) {
523
+ const effectiveTtlMs = resolveEntryTtlMs(entry, ttlMs);
524
+ if (!effectiveTtlMs) return;
525
+ const key = resolveIMessageSentEchoEntryKey(entry);
526
+ try {
527
+ openPersistedEchoStore().register(key, entry, { ttlMs: effectiveTtlMs });
528
+ } catch (err) {
529
+ reportFailure("write", err);
530
+ return;
531
+ }
532
+ return key;
533
+ }
534
+ function rememberPersistedIMessageEcho(params) {
535
+ const text = normalizeText(params.text);
536
+ const media = normalizeMedia(params.media);
537
+ const messageId = normalizeMessageId(params.messageId);
538
+ const entry = {
539
+ scope: params.scope,
540
+ timestamp: Date.now(),
541
+ ...text ? { text } : {},
542
+ ...media ? { media } : {},
543
+ ...messageId ? { messageId } : {},
544
+ ...params.pending ? { pending: true } : {}
545
+ };
546
+ if (typeof params.ttlMs === "number" && Number.isFinite(params.ttlMs) && params.ttlMs > 0) entry.expiresAt = entry.timestamp + params.ttlMs;
547
+ if (!entry.text && !entry.media && !entry.messageId) return;
548
+ loadMirrorFromStore();
549
+ const key = persistEntry(entry, params.ttlMs);
550
+ mirror = [...mirror ?? [], entry].filter((candidate) => isLiveEntry(candidate)).slice(-256);
551
+ return key;
552
+ }
553
+ function forgetPersistedIMessageEchoKey(key) {
554
+ if (!key) return;
555
+ try {
556
+ openPersistedEchoStore().delete(key);
557
+ } catch (err) {
558
+ reportFailure("delete", err);
559
+ }
560
+ mirror = (mirror ?? []).filter((entry) => resolveIMessageSentEchoEntryKey(entry) !== key);
561
+ }
562
+ function hasPersistedIMessageEcho(params) {
563
+ const text = normalizeText(params.text);
564
+ const mediaKey = resolveIMessageEchoMediaKey(params.media);
565
+ const messageId = normalizeMessageId(params.messageId);
566
+ if (!text && !mediaKey && !messageId) return false;
567
+ for (const entry of readRecentEntries()) {
568
+ if (entry.scope !== params.scope) continue;
569
+ if (messageId && entry.messageId === messageId) return true;
570
+ const hasConflictingMessageIds = Boolean(messageId && entry.messageId && messageId !== entry.messageId);
571
+ if (text && (!hasConflictingMessageIds || params.skipIdShortCircuit) && entry.text === text && (!entry.pending || params.includePendingText)) return true;
572
+ if (mediaKey && !hasConflictingMessageIds && resolveIMessageEchoMediaKey(entry.media) === mediaKey && (!entry.pending || params.includePendingText)) return true;
573
+ }
574
+ return false;
575
+ }
576
+ //#endregion
456
577
  //#region extensions/imessage/src/send.ts
457
578
  const MIN_PENDING_PERSISTED_ECHO_TTL_MS = 6e4;
458
579
  const PENDING_PERSISTED_ECHO_GRACE_MS = 5e3;
@@ -722,16 +843,17 @@ async function trySendAttachmentForTarget(params) {
722
843
  if (params.target.kind === "handle" && !params.audioAsVoice && params.sendTransport !== "bridge" && (params.service === "sms" || params.service === "imessage")) return null;
723
844
  if (params.remoteHost && params.sendTransport === "applescript") return null;
724
845
  let attachmentChatTarget = null;
725
- if (params.remoteHost) if (params.target.kind === "chat_guid") attachmentChatTarget = params.target.chatGuid;
726
- else if (params.target.kind === "chat_identifier") attachmentChatTarget = params.target.chatIdentifier;
727
- else if (params.target.kind === "handle") {
728
- const normalizedHandle = normalizeIMessageHandle(params.target.to);
729
- if (normalizedHandle) {
730
- const service = params.target.service !== "auto" ? params.target.service : params.service;
731
- attachmentChatTarget = `${service === "sms" ? "SMS" : service === "imessage" ? "iMessage" : "any"};-;${normalizedHandle}`;
732
- }
733
- } else attachmentChatTarget = formatIMessageChatTarget(params.target.chatId);
734
- else try {
846
+ if (params.remoteHost) {
847
+ if (params.target.kind === "chat_guid") attachmentChatTarget = params.target.chatGuid;
848
+ else if (params.target.kind === "chat_identifier") attachmentChatTarget = params.target.chatIdentifier;
849
+ else if (params.target.kind === "handle") {
850
+ const normalizedHandle = normalizeIMessageHandle(params.target.to);
851
+ if (normalizedHandle) {
852
+ const service = params.target.service !== "auto" ? params.target.service : params.service;
853
+ attachmentChatTarget = `${service === "sms" ? "SMS" : service === "imessage" ? "iMessage" : "any"};-;${normalizedHandle}`;
854
+ }
855
+ } else attachmentChatTarget = formatIMessageChatTarget(params.target.chatId);
856
+ } else try {
735
857
  attachmentChatTarget = await resolveAttachmentChatTarget({
736
858
  target: params.target,
737
859
  service: params.service,
@@ -881,7 +1003,7 @@ async function sendMessageIMessage(to, text, opts) {
881
1003
  const timeoutMs = opts.timeoutMs ?? Math.max(account.config.probeTimeoutMs ?? 0, 18e4);
882
1004
  const pendingEchoTtlMs = resolvePendingPersistedEchoTtlMs(timeoutMs);
883
1005
  const region = opts.region?.trim() || account.config.region?.trim() || "US";
884
- const maxBytes = typeof opts.maxBytes === "number" ? opts.maxBytes : typeof account.config.mediaMaxMb === "number" ? account.config.mediaMaxMb * 1024 * 1024 : 16 * 1024 * 1024;
1006
+ const maxBytes = typeof opts.maxBytes === "number" ? opts.maxBytes : typeof account.config.mediaMaxMb === "number" ? account.config.mediaMaxMb * 1024 * 1024 : 16777216;
885
1007
  let message = opts.approvalPrompt ? addApprovalReactionHintToText({
886
1008
  text,
887
1009
  allowedDecisions: opts.approvalPrompt.allowedDecisions
@@ -1173,4 +1295,4 @@ async function sendMessageIMessage(to, text, opts) {
1173
1295
  }
1174
1296
  }
1175
1297
  //#endregion
1176
- export { maybeResolveIMessageApprovalPollVote as a, mapSentPollOptionsToDecisions as i, buildApprovalPollOptions as n, iMessageApprovalControlBindings as o, iMessageApprovalPollTargets as r, sendMessageIMessage as t };
1298
+ export { iMessageApprovalPollTargets as a, iMessageApprovalControlBindings as c, buildApprovalPollOptions as i, hasPersistedIMessageEcho as n, mapSentPollOptionsToDecisions as o, stripLeadingEchoTextCorruptionMarkers as r, maybeResolveIMessageApprovalPollVote as s, sendMessageIMessage as t };
@@ -0,0 +1,56 @@
1
+ import { createHash } from "node:crypto";
2
+ //#region extensions/imessage/src/state-contract.ts
3
+ const IMESSAGE_REPLY_CACHE_NAMESPACE = "imessage.reply-cache";
4
+ const IMESSAGE_REPLY_CACHE_MAX_ENTRIES = 2e3;
5
+ const IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE = "imessage.reply-cache-counter";
6
+ const IMESSAGE_REPLY_CACHE_COUNTER_KEY = "short-id-counter";
7
+ const IMESSAGE_REPLY_CACHE_TTL_MS = 216e5;
8
+ function resolveIMessageReplyCacheEntryKey(messageId) {
9
+ return createHash("sha256").update(messageId, "utf8").digest("hex").slice(0, 32);
10
+ }
11
+ const MAX_FAILURE_RETRY_MAP_SIZE = 512;
12
+ const MAX_FAILURE_RETRY_MAP_JSON_BYTES = 48e3;
13
+ const textEncoder = new TextEncoder();
14
+ const IMESSAGE_CATCHUP_CURSOR_NAMESPACE = "imessage.catchup-cursors";
15
+ function resolveIMessageCatchupCursorKey(accountId) {
16
+ return createHash("sha256").update(accountId, "utf8").digest("hex").slice(0, 32);
17
+ }
18
+ /**
19
+ * Bound the retry map so a pathological storm of unique failing GUIDs
20
+ * cannot grow the cursor value without limit. Keeps the `maxSize` entries
21
+ * with the highest counts (closest to give-up) when over the bound.
22
+ */
23
+ function capFailureRetriesMap(map, maxSize = MAX_FAILURE_RETRY_MAP_SIZE, maxBytes = MAX_FAILURE_RETRY_MAP_JSON_BYTES) {
24
+ const entries = Object.entries(map);
25
+ if (entries.length <= maxSize && textEncoder.encode(JSON.stringify(map)).byteLength <= maxBytes) return map;
26
+ entries.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]));
27
+ const capped = {};
28
+ for (const [guid, count] of entries.slice(0, maxSize)) {
29
+ capped[guid] = count;
30
+ if (textEncoder.encode(JSON.stringify(capped)).byteLength > maxBytes) {
31
+ delete capped[guid];
32
+ break;
33
+ }
34
+ }
35
+ return capped;
36
+ }
37
+ const IMESSAGE_SENT_ECHOES_TTL_MS = 432e5;
38
+ const IMESSAGE_SENT_ECHOES_NAMESPACE = "imessage.sent-echoes";
39
+ function resolveIMessageSentEchoEntryKey(entry) {
40
+ return createHash("sha256").update(JSON.stringify([
41
+ entry.scope,
42
+ entry.text ?? "",
43
+ resolveIMessageEchoMediaKey(entry.media) ?? "",
44
+ entry.messageId ?? "",
45
+ entry.timestamp
46
+ ])).digest("hex").slice(0, 32);
47
+ }
48
+ function resolveIMessageEchoMediaKey(media) {
49
+ const contentType = media?.contentType?.trim().toLowerCase() || void 0;
50
+ const kind = media?.kind && media.kind !== "unknown" ? media.kind : void 0;
51
+ if (kind) return `kind:${kind}`;
52
+ const normalizedContentType = contentType?.split(";", 1)[0]?.trim();
53
+ return normalizedContentType ? `mime:${normalizedContentType}` : void 0;
54
+ }
55
+ //#endregion
56
+ export { IMESSAGE_REPLY_CACHE_NAMESPACE as a, IMESSAGE_SENT_ECHOES_TTL_MS as c, resolveIMessageEchoMediaKey as d, resolveIMessageReplyCacheEntryKey as f, IMESSAGE_REPLY_CACHE_MAX_ENTRIES as i, capFailureRetriesMap as l, IMESSAGE_REPLY_CACHE_COUNTER_KEY as n, IMESSAGE_REPLY_CACHE_TTL_MS as o, resolveIMessageSentEchoEntryKey as p, IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE as r, IMESSAGE_SENT_ECHOES_NAMESPACE as s, IMESSAGE_CATCHUP_CURSOR_NAMESPACE as t, resolveIMessageCatchupCursorKey as u };
@@ -0,0 +1,277 @@
1
+ import { a as resolveDefaultIMessageAccountId, i as listIMessageAccountIds, o as resolveIMessageAccount } from "./accounts-CCirBEIm.js";
2
+ import { a as IMESSAGE_REPLY_CACHE_NAMESPACE, c as IMESSAGE_SENT_ECHOES_TTL_MS, f as resolveIMessageReplyCacheEntryKey, i as IMESSAGE_REPLY_CACHE_MAX_ENTRIES, l as capFailureRetriesMap, n as IMESSAGE_REPLY_CACHE_COUNTER_KEY, o as IMESSAGE_REPLY_CACHE_TTL_MS, p as resolveIMessageSentEchoEntryKey, r as IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE, s as IMESSAGE_SENT_ECHOES_NAMESPACE, t as IMESSAGE_CATCHUP_CURSOR_NAMESPACE, u as resolveIMessageCatchupCursorKey } from "./state-contract-DvahEY4X.js";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { asFiniteNumber, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
6
+ import { createHash } from "node:crypto";
7
+ import { fileExists } from "openclaw/plugin-sdk/security-runtime";
8
+ import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
9
+ //#region extensions/imessage/src/state-migrations.ts
10
+ function resolveMigrationStateDir(params) {
11
+ return params.stateDir ?? resolveStateDir(params.env);
12
+ }
13
+ function remainingTtlMs(timestamp, ttlMs) {
14
+ const remaining = ttlMs - Math.max(0, Date.now() - timestamp);
15
+ return remaining > 0 ? remaining : void 0;
16
+ }
17
+ function readJsonl(pathValue) {
18
+ try {
19
+ return fs.readFileSync(pathValue, "utf8").split(/\n+/).flatMap((line) => {
20
+ if (!line) return [];
21
+ try {
22
+ return [JSON.parse(line)];
23
+ } catch {
24
+ return [];
25
+ }
26
+ });
27
+ } catch (err) {
28
+ throw new Error(`Failed reading ${pathValue}: ${String(err)}`, { cause: err });
29
+ }
30
+ }
31
+ function parseReplyCacheEntry(raw) {
32
+ if (!raw || typeof raw !== "object") return null;
33
+ const parsed = raw;
34
+ if (typeof parsed.accountId !== "string" || typeof parsed.messageId !== "string" || typeof parsed.shortId !== "string" || typeof parsed.timestamp !== "number") return null;
35
+ return {
36
+ accountId: parsed.accountId,
37
+ messageId: parsed.messageId,
38
+ shortId: parsed.shortId,
39
+ timestamp: parsed.timestamp,
40
+ ...typeof parsed.chatGuid === "string" ? { chatGuid: parsed.chatGuid } : {},
41
+ ...typeof parsed.chatIdentifier === "string" ? { chatIdentifier: parsed.chatIdentifier } : {},
42
+ ...typeof parsed.chatId === "number" ? { chatId: parsed.chatId } : {},
43
+ ...typeof parsed.isFromMe === "boolean" ? { isFromMe: parsed.isFromMe } : {}
44
+ };
45
+ }
46
+ function readReplyCacheMaxShortId(sourcePath) {
47
+ let max = 0;
48
+ for (const raw of readJsonl(sourcePath)) {
49
+ if (!raw || typeof raw !== "object") continue;
50
+ const shortId = raw.shortId;
51
+ if (typeof shortId !== "string") continue;
52
+ const numeric = Number.parseInt(shortId, 10);
53
+ if (Number.isFinite(numeric) && numeric > max) max = numeric;
54
+ }
55
+ return max;
56
+ }
57
+ function readReplyCounterValue(value) {
58
+ if (!value || typeof value !== "object") return null;
59
+ const counter = value.counter;
60
+ return asFiniteNumber(counter) ?? null;
61
+ }
62
+ function shouldReplaceReplyCounter(existingValue, incomingValue) {
63
+ const incomingCounter = readReplyCounterValue(incomingValue);
64
+ if (incomingCounter === null) return false;
65
+ const existingCounter = readReplyCounterValue(existingValue);
66
+ return existingCounter === null || incomingCounter > existingCounter;
67
+ }
68
+ function parseSentEchoEntry(raw) {
69
+ if (!raw || typeof raw !== "object") return null;
70
+ const parsed = raw;
71
+ if (typeof parsed.scope !== "string" || typeof parsed.timestamp !== "number") return null;
72
+ return {
73
+ scope: parsed.scope,
74
+ timestamp: parsed.timestamp,
75
+ ...typeof parsed.text === "string" ? { text: parsed.text } : {},
76
+ ...typeof parsed.messageId === "string" ? { messageId: parsed.messageId } : {}
77
+ };
78
+ }
79
+ function listReplyCacheEntries(sourcePath) {
80
+ const entriesByKey = /* @__PURE__ */ new Map();
81
+ for (const entry of readJsonl(sourcePath).map(parseReplyCacheEntry)) {
82
+ if (!entry) continue;
83
+ const ttlMs = remainingTtlMs(entry.timestamp, IMESSAGE_REPLY_CACHE_TTL_MS);
84
+ if (!ttlMs) continue;
85
+ const key = resolveIMessageReplyCacheEntryKey(entry.messageId);
86
+ entriesByKey.delete(key);
87
+ entriesByKey.set(key, {
88
+ value: entry,
89
+ ttlMs
90
+ });
91
+ }
92
+ return [...entriesByKey.entries()].slice(-IMESSAGE_REPLY_CACHE_MAX_ENTRIES).map(([key, entry]) => ({
93
+ key,
94
+ value: entry.value,
95
+ ttlMs: entry.ttlMs
96
+ }));
97
+ }
98
+ function listSentEchoEntries(sourcePath) {
99
+ return readJsonl(sourcePath).map(parseSentEchoEntry).filter((entry) => Boolean(entry)).slice(-256).flatMap((entry) => {
100
+ const ttlMs = remainingTtlMs(entry.timestamp, IMESSAGE_SENT_ECHOES_TTL_MS);
101
+ if (!ttlMs) return [];
102
+ return [{
103
+ key: resolveIMessageSentEchoEntryKey(entry),
104
+ value: entry,
105
+ ttlMs
106
+ }];
107
+ });
108
+ }
109
+ function resolveLegacyCatchupCursorPath(stateDir, accountId) {
110
+ const safePrefix = accountId.replace(/[^a-zA-Z0-9_-]/g, "_") || "account";
111
+ const hash = createHash("sha256").update(accountId, "utf8").digest("hex").slice(0, 12);
112
+ return path.join(stateDir, "imessage", "catchup", `${safePrefix}__${hash}.json`);
113
+ }
114
+ function listLegacyCatchupCursorPaths(stateDir) {
115
+ const dir = path.join(stateDir, "imessage", "catchup");
116
+ try {
117
+ return fs.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path.join(dir, entry.name));
118
+ } catch {
119
+ return [];
120
+ }
121
+ }
122
+ function normalizeCatchupCursor(raw) {
123
+ if (!raw || typeof raw !== "object") return null;
124
+ const value = raw;
125
+ if (typeof value.lastSeenMs !== "number" || !Number.isFinite(value.lastSeenMs) || typeof value.lastSeenRowid !== "number" || !Number.isFinite(value.lastSeenRowid)) return null;
126
+ const failureRetries = sanitizeCatchupFailureRetries(value.failureRetries);
127
+ const hasRetries = Object.keys(failureRetries).length > 0;
128
+ return {
129
+ lastSeenMs: value.lastSeenMs,
130
+ lastSeenRowid: value.lastSeenRowid,
131
+ updatedAt: typeof value.updatedAt === "number" ? value.updatedAt : 0,
132
+ ...hasRetries ? { failureRetries } : {}
133
+ };
134
+ }
135
+ function readCatchupCursor(sourcePath) {
136
+ let parsed;
137
+ try {
138
+ parsed = JSON.parse(fs.readFileSync(sourcePath, "utf8"));
139
+ } catch (err) {
140
+ throw new Error(`Failed reading ${sourcePath}: ${String(err)}`, { cause: err });
141
+ }
142
+ const cursor = normalizeCatchupCursor(parsed);
143
+ if (!cursor) throw new Error(`Invalid iMessage catchup cursor: ${sourcePath}`);
144
+ return cursor;
145
+ }
146
+ function sanitizeCatchupFailureRetries(raw) {
147
+ if (!raw || typeof raw !== "object") return {};
148
+ const out = {};
149
+ for (const [guid, count] of Object.entries(raw)) if (typeof count === "number" && Number.isFinite(count) && count > 0) out[guid] = Math.floor(count);
150
+ return capFailureRetriesMap(out);
151
+ }
152
+ function shouldReplaceCatchupCursor(existingValue, incomingValue) {
153
+ const incoming = normalizeCatchupCursor(incomingValue);
154
+ if (!incoming) return false;
155
+ const existing = normalizeCatchupCursor(existingValue);
156
+ return !existing || incoming.lastSeenRowid > existing.lastSeenRowid || incoming.lastSeenRowid === existing.lastSeenRowid && incoming.lastSeenMs > existing.lastSeenMs;
157
+ }
158
+ function detectReplyCacheMigration(params) {
159
+ const stateDir = resolveMigrationStateDir(params);
160
+ const sourcePath = path.join(stateDir, "imessage", "reply-cache.jsonl");
161
+ if (!fileExists(sourcePath)) return [];
162
+ const plans = [];
163
+ plans.push({
164
+ kind: "plugin-state-import",
165
+ label: "iMessage reply short-id counter",
166
+ sourcePath,
167
+ targetPath: `plugin state:${IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE}`,
168
+ pluginId: "imessage",
169
+ namespace: IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE,
170
+ maxEntries: 1,
171
+ scopeKey: "",
172
+ stateDir,
173
+ preview: `- iMessage reply short-id counter: ${sourcePath} → plugin state (${IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE})`,
174
+ readEntries: () => {
175
+ const maxShortId = readReplyCacheMaxShortId(sourcePath);
176
+ return maxShortId > 0 ? [{
177
+ key: IMESSAGE_REPLY_CACHE_COUNTER_KEY,
178
+ value: { counter: maxShortId }
179
+ }] : [];
180
+ },
181
+ shouldReplaceExistingEntry: ({ existingValue, incomingValue }) => shouldReplaceReplyCounter(existingValue, incomingValue)
182
+ });
183
+ plans.push({
184
+ kind: "plugin-state-import",
185
+ label: "iMessage reply short-id cache",
186
+ sourcePath,
187
+ targetPath: `plugin state:${IMESSAGE_REPLY_CACHE_NAMESPACE}`,
188
+ pluginId: "imessage",
189
+ namespace: IMESSAGE_REPLY_CACHE_NAMESPACE,
190
+ maxEntries: IMESSAGE_REPLY_CACHE_MAX_ENTRIES,
191
+ scopeKey: "",
192
+ stateDir,
193
+ cleanupSource: "rename",
194
+ cleanupWhenEmpty: true,
195
+ preview: `- iMessage reply short-id cache: ${sourcePath} → plugin state (${IMESSAGE_REPLY_CACHE_NAMESPACE})`,
196
+ readEntries: () => listReplyCacheEntries(sourcePath)
197
+ });
198
+ return plans;
199
+ }
200
+ function detectSentEchoMigration(params) {
201
+ const stateDir = resolveMigrationStateDir(params);
202
+ const sourcePath = path.join(stateDir, "imessage", "sent-echoes.jsonl");
203
+ if (!fileExists(sourcePath)) return [];
204
+ return [{
205
+ kind: "plugin-state-import",
206
+ label: "iMessage sent-echo dedupe cache",
207
+ sourcePath,
208
+ targetPath: `plugin state:${IMESSAGE_SENT_ECHOES_NAMESPACE}`,
209
+ pluginId: "imessage",
210
+ namespace: IMESSAGE_SENT_ECHOES_NAMESPACE,
211
+ maxEntries: 256,
212
+ scopeKey: "",
213
+ stateDir,
214
+ cleanupSource: "rename",
215
+ cleanupWhenEmpty: true,
216
+ preview: `- iMessage sent-echo dedupe cache: ${sourcePath} → plugin state (${IMESSAGE_SENT_ECHOES_NAMESPACE})`,
217
+ readEntries: () => listSentEchoEntries(sourcePath)
218
+ }];
219
+ }
220
+ function detectCatchupCursorMigrations(params) {
221
+ const stateDir = resolveMigrationStateDir(params);
222
+ const accountIds = uniqueStrings([resolveDefaultIMessageAccountId(params.cfg), ...listIMessageAccountIds(params.cfg)].map((accountId) => resolveIMessageAccount({
223
+ cfg: params.cfg,
224
+ accountId
225
+ }).accountId));
226
+ const configuredPaths = new Set(accountIds.map((accountId) => resolveLegacyCatchupCursorPath(stateDir, accountId)));
227
+ const configuredPlans = accountIds.flatMap((accountId) => {
228
+ const sourcePath = resolveLegacyCatchupCursorPath(stateDir, accountId);
229
+ if (!fileExists(sourcePath)) return [];
230
+ return {
231
+ kind: "plugin-state-import",
232
+ label: "iMessage catchup cursor",
233
+ sourcePath,
234
+ targetPath: `plugin state:${IMESSAGE_CATCHUP_CURSOR_NAMESPACE}`,
235
+ pluginId: "imessage",
236
+ namespace: IMESSAGE_CATCHUP_CURSOR_NAMESPACE,
237
+ maxEntries: 256,
238
+ scopeKey: "",
239
+ stateDir,
240
+ cleanupSource: "rename",
241
+ preview: `- iMessage catchup cursor: ${sourcePath} → plugin state (${IMESSAGE_CATCHUP_CURSOR_NAMESPACE})`,
242
+ readEntries: () => {
243
+ const cursor = readCatchupCursor(sourcePath);
244
+ return [{
245
+ key: resolveIMessageCatchupCursorKey(accountId),
246
+ value: cursor
247
+ }];
248
+ },
249
+ shouldReplaceExistingEntry: (replaceParams) => shouldReplaceCatchupCursor(replaceParams.existingValue, replaceParams.incomingValue)
250
+ };
251
+ });
252
+ const orphanPlans = listLegacyCatchupCursorPaths(stateDir).filter((sourcePath) => !configuredPaths.has(sourcePath)).map((sourcePath) => ({
253
+ kind: "plugin-state-import",
254
+ label: "iMessage orphan catchup cursor",
255
+ sourcePath,
256
+ targetPath: `plugin state:${IMESSAGE_CATCHUP_CURSOR_NAMESPACE}`,
257
+ pluginId: "imessage",
258
+ namespace: IMESSAGE_CATCHUP_CURSOR_NAMESPACE,
259
+ maxEntries: 256,
260
+ scopeKey: "",
261
+ stateDir,
262
+ cleanupSource: "rename",
263
+ cleanupWhenEmpty: true,
264
+ preview: `- iMessage orphan catchup cursor: ${sourcePath} → archived legacy state`,
265
+ readEntries: () => []
266
+ }));
267
+ return [...configuredPlans, ...orphanPlans];
268
+ }
269
+ async function detectIMessageLegacyStateMigrations(params) {
270
+ return [
271
+ ...detectCatchupCursorMigrations(params),
272
+ ...detectReplyCacheMigration(params),
273
+ ...detectSentEchoMigration(params)
274
+ ];
275
+ }
276
+ //#endregion
277
+ export { detectIMessageLegacyStateMigrations };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns true if the value is a ISO8601 Date component string
3
- * @source ajv-formats
3
+ * @description https://datatracker.ietf.org/doc/html/rfc3339
4
4
  * @example `2020-12-12`
5
5
  */
6
6
  export declare function IsDate(value: string): boolean;
@@ -5,7 +5,7 @@ function IsLeapYear(year) {
5
5
  }
6
6
  /**
7
7
  * Returns true if the value is a ISO8601 Date component string
8
- * @source ajv-formats
8
+ * @description https://datatracker.ietf.org/doc/html/rfc3339
9
9
  * @example `2020-12-12`
10
10
  */
11
11
  export function IsDate(value) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns true if the value is a ISO8601 DateTime string
3
- * @source ajv-formats
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc3339
4
4
  * @example `2020-12-12T20:20:40+00:00`
5
5
  */
6
- export declare function IsDateTime(value: string, strictTimeZone?: boolean): boolean;
6
+ export declare function IsDateTime(value: string): boolean;
@@ -2,10 +2,10 @@ import { IsDate } from './date.mjs';
2
2
  import { IsTime } from './time.mjs';
3
3
  /**
4
4
  * Returns true if the value is a ISO8601 DateTime string
5
- * @source ajv-formats
5
+ * @specification https://datatracker.ietf.org/doc/html/rfc3339
6
6
  * @example `2020-12-12T20:20:40+00:00`
7
7
  */
8
- export function IsDateTime(value, strictTimeZone = true) {
8
+ export function IsDateTime(value) {
9
9
  const dateTime = value.split(/T/i);
10
- return dateTime.length === 2 && IsDate(dateTime[0]) && IsTime(dateTime[1], strictTimeZone);
10
+ return dateTime.length === 2 && IsDate(dateTime[0]) && IsTime(dateTime[1]);
11
11
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Returns true if the value is an Email
3
- * @specification ajv-formats
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc5322
4
4
  */
5
5
  export declare function IsEmail(value: string): boolean;
@@ -1,7 +1,7 @@
1
- const Email = /^(?!.*\.\.)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i;
1
+ const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
2
2
  /**
3
3
  * Returns true if the value is an Email
4
- * @specification ajv-formats
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc5322
5
5
  */
6
6
  export function IsEmail(value) {
7
7
  return Email.test(value);
@@ -1,4 +1,4 @@
1
- import * as Idna from './_idna.mjs';
1
+ import * as Idna from './idna/index.mjs';
2
2
  /**
3
3
  * Returns true if the value is a valid hostname.
4
4
  * @specification https://tools.ietf.org/html/rfc1123
@@ -6,13 +6,5 @@ import * as Idna from './_idna.mjs';
6
6
  * @specification https://tools.ietf.org/html/rfc5892
7
7
  */
8
8
  export function IsHostname(value) {
9
- if (value.length === 0 || value.length > 253)
10
- return false;
11
- if (value.charCodeAt(value.length - 1) === 46)
12
- return false;
13
- for (const label of value.split('.')) {
14
- if (!Idna.IsLabel(label))
15
- return false;
16
- }
17
- return true;
9
+ return Idna.IsHostname(value);
18
10
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Returns true if the value is an IdnEmail
3
- * @specification ajv-formats (unicode-extension)
3
+ * @specification https://datatracker.ietf.org/doc/html/rfc4952
4
4
  */
5
5
  export declare function IsIdnEmail(value: string): boolean;
@@ -1,8 +1,8 @@
1
- const IdnEmail = /^(?!.*\.\.)[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+(?:\.[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+)*@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?)*$/iu;
1
+ const IdnEmail = /^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;
2
2
  /**
3
3
  * Returns true if the value is an IdnEmail
4
- * @specification ajv-formats (unicode-extension)
4
+ * @specification https://datatracker.ietf.org/doc/html/rfc4952
5
5
  */
6
6
  export function IsIdnEmail(value) {
7
- return IdnEmail.test(value);
7
+ return IdnEmail.test(value.normalize('NFC'));
8
8
  }