@wirecat/mail-cli 0.9.0 → 0.11.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +4 -4
  3. package/dist/bin/mail.js +2 -2
  4. package/dist/bundle/{all-profiles-X6ROLLMF.js → all-profiles-OJPRIFKU.js} +9 -9
  5. package/dist/bundle/{anthropic-MPARKCMJ.js → anthropic-3AXHD4WH.js} +6 -6
  6. package/dist/bundle/{app-server-JQ5XCXWT.js → app-server-V4KHCUGE.js} +45 -46
  7. package/dist/bundle/{bun-H7LT5433.js → bun-ISYNUTQJ.js} +2 -2
  8. package/dist/bundle/{bun-sqlite-AGK2BHAN.js → bun-sqlite-FH3D4AXL.js} +5 -5
  9. package/dist/bundle/{chunk-IYC3IHEZ.js → chunk-2TTCKOQ7.js} +2 -2
  10. package/dist/bundle/{chunk-5NYUCY5W.js → chunk-35Y3INBK.js} +2 -2
  11. package/dist/bundle/{chunk-UHBCL66Y.js → chunk-44LVUMS2.js} +1 -1
  12. package/dist/bundle/{chunk-U6BDAY55.js → chunk-4D52FA34.js} +1 -1
  13. package/dist/bundle/{chunk-L3KMVMRJ.js → chunk-4DPICEPQ.js} +2 -2
  14. package/dist/bundle/{chunk-6FBBDIX6.js → chunk-4GPPRLIG.js} +7 -42
  15. package/dist/bundle/{chunk-BNPCRWZ6.js → chunk-5TACUBRJ.js} +8 -8
  16. package/dist/bundle/{chunk-PC3AFEEA.js → chunk-6LNRNQHJ.js} +4 -4
  17. package/dist/bundle/{chunk-3LMWAO6A.js → chunk-6QNPJSRM.js} +6 -6
  18. package/dist/bundle/{chunk-PXQ7A5HQ.js → chunk-6UT3MXOB.js} +3 -3
  19. package/dist/bundle/{chunk-SEL7SJCM.js → chunk-AJ4JS2ZR.js} +36 -11
  20. package/dist/bundle/{chunk-RGM66WZ3.js → chunk-BYQ3Z6UL.js} +3 -3
  21. package/dist/bundle/{chunk-FEA5E7WQ.js → chunk-DN54W657.js} +2 -2
  22. package/dist/bundle/{chunk-J4MY3QIN.js → chunk-F3QDSQ7V.js} +34 -28
  23. package/dist/bundle/{chunk-YXQIZORE.js → chunk-FYMQPAE5.js} +4 -4
  24. package/dist/bundle/{chunk-2FDROA4Q.js → chunk-G2WDY5XB.js} +2 -2
  25. package/dist/bundle/{chunk-KWHFDVAF.js → chunk-GAIVTJ3E.js} +121 -32
  26. package/dist/bundle/{chunk-INVEYTAL.js → chunk-GFCNSU3B.js} +48 -48
  27. package/dist/bundle/{chunk-SYFBRZ5F.js → chunk-GUFWLTOW.js} +2 -2
  28. package/dist/bundle/{chunk-YLSV3WOO.js → chunk-GYNHU56E.js} +4 -4
  29. package/dist/bundle/{chunk-CHK3V7FG.js → chunk-HVVLSCFB.js} +1 -1
  30. package/dist/bundle/{chunk-4EFKQXA5.js → chunk-IG2WXKIT.js} +8 -8
  31. package/dist/bundle/{chunk-3Y7H3CXI.js → chunk-IS6KAUSG.js} +2 -5
  32. package/dist/bundle/{chunk-24MHYGNE.js → chunk-IWHXM2S7.js} +1620 -671
  33. package/dist/bundle/{chunk-TVZFDVZP.js → chunk-IXYKM7OJ.js} +13 -13
  34. package/dist/bundle/{chunk-ZISFMUYB.js → chunk-JAWJZTFL.js} +18 -18
  35. package/dist/bundle/{chunk-PEF637VV.js → chunk-JIIEJLAX.js} +4 -4
  36. package/dist/bundle/{chunk-DLB2JPLU.js → chunk-JNUKTAMZ.js} +1 -1
  37. package/dist/bundle/{chunk-25N52S7U.js → chunk-K2F7YMMM.js} +6 -6
  38. package/dist/bundle/{chunk-OZGDPG6I.js → chunk-KJP2B65C.js} +30 -30
  39. package/dist/bundle/{chunk-EUJTQY43.js → chunk-KVN4RY7E.js} +52 -53
  40. package/dist/bundle/{chunk-JZMPDFM4.js → chunk-L3PVAY3M.js} +2 -2
  41. package/dist/bundle/{chunk-64FN5JK6.js → chunk-LIQ5LICB.js} +3 -3
  42. package/dist/bundle/{chunk-DQHAXX33.js → chunk-LXHLQ6RK.js} +7 -7
  43. package/dist/bundle/{chunk-HZ42NO25.js → chunk-MDIRW3AT.js} +2 -2
  44. package/dist/bundle/{chunk-K3RWO7LR.js → chunk-N6P55LDU.js} +84 -8
  45. package/dist/bundle/{chunk-PTDJXPXG.js → chunk-NBQQ2ZTF.js} +19 -14
  46. package/dist/bundle/{chunk-NAIJNJZZ.js → chunk-NSDOYHIS.js} +10 -8
  47. package/dist/bundle/{chunk-VOGSDGVL.js → chunk-OHC4GVWV.js} +2 -2
  48. package/dist/bundle/{chunk-QO4K6R7K.js → chunk-PLPSFJO6.js} +6 -6
  49. package/dist/bundle/{chunk-3W6VSSQQ.js → chunk-PSXAC6OO.js} +1 -1
  50. package/dist/bundle/{chunk-4MIC7S7B.js → chunk-QB54TE52.js} +1 -1
  51. package/dist/bundle/{chunk-QXXBDW6N.js → chunk-QPQSMJBW.js} +10 -10
  52. package/dist/bundle/{chunk-SUB4DRMA.js → chunk-S64N24ON.js} +3 -3
  53. package/dist/bundle/{chunk-M55XFZMG.js → chunk-SW5NVASW.js} +9 -9
  54. package/dist/bundle/{chunk-N6YA4OQI.js → chunk-SYBMOE6F.js} +865 -838
  55. package/dist/bundle/{chunk-Z3TZTOR2.js → chunk-T3AGR4TI.js} +4840 -894
  56. package/dist/bundle/{chunk-JYVZDJNO.js → chunk-TTKNBUMT.js} +45 -5
  57. package/dist/bundle/{chunk-ROZBXOES.js → chunk-TZGQPTZ2.js} +1 -1
  58. package/dist/bundle/{chunk-FUDHVV4R.js → chunk-UDJIC6YL.js} +67 -30
  59. package/dist/bundle/{chunk-HWLAV2HM.js → chunk-V6K2GX2Y.js} +17 -17
  60. package/dist/bundle/{chunk-65SVO3T7.js → chunk-VEXXVLBM.js} +3 -3
  61. package/dist/bundle/{chunk-NTWORG4T.js → chunk-WL7CYT7O.js} +1 -1
  62. package/dist/bundle/{chunk-DL32PWLR.js → chunk-X37KLD23.js} +14 -14
  63. package/dist/bundle/{chunk-5PWKPRTD.js → chunk-XTIQFMZH.js} +4 -4
  64. package/dist/bundle/{chunk-GPCKNZIA.js → chunk-YDUES6ET.js} +4 -4
  65. package/dist/bundle/{chunk-TKFQ3GNY.js → chunk-YRZ23RCS.js} +164 -59
  66. package/dist/bundle/command-contract-TW44FY47.js +33 -0
  67. package/dist/bundle/{decode-ZATANRER.js → decode-FM4C2WWG.js} +5 -5
  68. package/dist/bundle/{dispatch-5C6XNGEE.js → dispatch-K3HG4RYT.js} +8 -8
  69. package/dist/bundle/{dist-JN22LNLZ.js → dist-7LNVI7VB.js} +17 -13
  70. package/dist/bundle/{echarts-WKTVUY3O.js → echarts-5C2A72XM.js} +2 -2
  71. package/dist/bundle/{embed-AVKPYK4V.js → embed-N56P6YVY.js} +6 -6
  72. package/dist/bundle/{embedder-PSV2E5TR.js → embedder-QLYKFLOL.js} +9 -9
  73. package/dist/bundle/{failure-YRGRZBTX.js → failure-5ZLVZTRU.js} +2 -2
  74. package/dist/bundle/{first-run-YN4SF5RZ.js → first-run-VMF4PJ7Q.js} +11 -11
  75. package/dist/bundle/first-screen-ZN7ODW5K.js +31 -0
  76. package/dist/bundle/{instructions-W5SJW23S.js → instructions-QA5FHDOJ.js} +1 -1
  77. package/dist/bundle/mail.js +12 -12
  78. package/dist/bundle/{mcp-B25MZCS7.js → mcp-LO2XDBBC.js} +2 -2
  79. package/dist/bundle/{node-BHBFRH6H.js → node-OXJZWUYZ.js} +2 -2
  80. package/dist/bundle/{node-sqlite-7FHC3W5U.js → node-sqlite-7GCEI67B.js} +5 -5
  81. package/dist/bundle/{oauth-ORPM6FLL.js → oauth-VTPIYBTP.js} +7 -7
  82. package/dist/bundle/{open-AY5KLPWO.js → open-7XX3YF2X.js} +4 -4
  83. package/dist/bundle/{openai-U7VALRI7.js → openai-D3KRCXSY.js} +14 -14
  84. package/dist/bundle/{process-7AWARSC5.js → process-KFI7SXQD.js} +1 -1
  85. package/dist/bundle/{program-2W4J47LM.js → program-INCGQV4G.js} +1334 -857
  86. package/dist/bundle/{prompt-STNX6JL7.js → prompt-TBZT3APW.js} +5 -5
  87. package/dist/bundle/{recognize-2XWWTN6Y.js → recognize-WQSE5ZPL.js} +4 -4
  88. package/dist/bundle/{remote-OIC32DKQ.js → remote-J5HHRNVQ.js} +7 -7
  89. package/dist/bundle/{rerank-IFTSO576.js → rerank-DP2Y3WDT.js} +7 -7
  90. package/dist/bundle/{serve-P2D2AJAU.js → serve-VXPOQDQO.js} +9 -9
  91. package/dist/bundle/{server-DFEJBMXO.js → server-OSBNGA2F.js} +37 -38
  92. package/dist/bundle/server-XHWSCXVX.js +62 -0
  93. package/dist/bundle/{sqlite-runtime-DD4Y35DQ.js → sqlite-runtime-XY32WOIT.js} +5 -5
  94. package/dist/bundle/{state-XUSQMIKJ.js → state-KPOPMR6O.js} +6 -6
  95. package/dist/bundle/{store-T3PKOLER.js → store-FWRGNGP3.js} +25 -17
  96. package/dist/bundle/{store-EQC5DKSY.js → store-UBI2YCRC.js} +13 -13
  97. package/dist/bundle/store-maintenance-command-3ZXPEIGF.js +52 -0
  98. package/dist/commands/login.d.ts.map +1 -1
  99. package/dist/commands/login.js +2 -1
  100. package/dist/commands/login.js.map +1 -1
  101. package/dist/commands/session-start.d.ts.map +1 -1
  102. package/dist/commands/session-start.js +3 -3
  103. package/dist/commands/session-start.js.map +1 -1
  104. package/dist/commands/sync.d.ts.map +1 -1
  105. package/dist/commands/sync.js +22 -7
  106. package/dist/commands/sync.js.map +1 -1
  107. package/dist/config.d.ts +6 -0
  108. package/dist/config.d.ts.map +1 -1
  109. package/dist/mail/imap/connection.d.ts.map +1 -1
  110. package/dist/mail/imap/connection.js +6 -4
  111. package/dist/mail/imap/connection.js.map +1 -1
  112. package/dist/mail/imap/errors.d.ts +7 -0
  113. package/dist/mail/imap/errors.d.ts.map +1 -1
  114. package/dist/mail/imap/errors.js +8 -4
  115. package/dist/mail/imap/errors.js.map +1 -1
  116. package/dist/mail/imap/read.d.ts.map +1 -1
  117. package/dist/mail/imap/read.js +36 -20
  118. package/dist/mail/imap/read.js.map +1 -1
  119. package/dist/mail/imap/search.d.ts +7 -2
  120. package/dist/mail/imap/search.d.ts.map +1 -1
  121. package/dist/mail/imap/search.js +13 -7
  122. package/dist/mail/imap/search.js.map +1 -1
  123. package/dist/mail/imap/write.d.ts.map +1 -1
  124. package/dist/mail/imap/write.js +2 -1
  125. package/dist/mail/imap/write.js.map +1 -1
  126. package/dist/mail/organise.d.ts.map +1 -1
  127. package/dist/mail/organise.js +92 -87
  128. package/dist/mail/organise.js.map +1 -1
  129. package/dist/mail/send.d.ts.map +1 -1
  130. package/dist/mail/send.js +26 -5
  131. package/dist/mail/send.js.map +1 -1
  132. package/dist/oauth.d.ts +0 -3
  133. package/dist/oauth.d.ts.map +1 -1
  134. package/dist/oauth.js +2 -33
  135. package/dist/oauth.js.map +1 -1
  136. package/dist/providers.d.ts.map +1 -1
  137. package/dist/providers.js +2 -1
  138. package/dist/providers.js.map +1 -1
  139. package/dist/reasons.d.ts.map +1 -1
  140. package/dist/reasons.js +0 -3
  141. package/dist/reasons.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.d.ts.map +1 -1
  144. package/dist/version.js +1 -1
  145. package/dist/version.js.map +1 -1
  146. package/package.json +3 -3
  147. package/skills/mail-cli/SKILL.md +1 -0
  148. package/dist/bundle/chunk-EVG7MOAH.js +0 -3604
  149. package/dist/bundle/command-contract-T3H5CAX3.js +0 -34
  150. package/dist/bundle/first-screen-IJJZJP6Q.js +0 -32
  151. package/dist/bundle/server-6D7W5Q4A.js +0 -63
  152. package/dist/bundle/store-maintenance-command-7YQZXE4V.js +0 -52
  153. /package/dist/bundle/{chunk-EKRM2QJB.js → chunk-MRLSUCHT.js} +0 -0
@@ -4,15 +4,18 @@ import {
4
4
  OFFLINE,
5
5
  capability,
6
6
  chatIdIn,
7
+ profilesOnAccount,
7
8
  refuseLacking,
8
9
  servicesFor,
9
10
  throughWrapper
10
- } from "./chunk-N6YA4OQI.js";
11
+ } from "./chunk-SYBMOE6F.js";
11
12
  import {
13
+ chatReferenceOf,
14
+ ensureAccount,
12
15
  foldName,
13
16
  isId,
14
17
  pickPerson
15
- } from "./chunk-K3RWO7LR.js";
18
+ } from "./chunk-N6P55LDU.js";
16
19
  import {
17
20
  LOG_ATTRIBUTES,
18
21
  MESSENGER_CHANGE_REFUSAL,
@@ -24,6 +27,7 @@ import {
24
27
  environmentOf,
25
28
  fromLogAttributes,
26
29
  issueMessage,
30
+ limitBatch,
27
31
  logAttributes,
28
32
  permissionIssues,
29
33
  publicIssue,
@@ -31,7 +35,7 @@ import {
31
35
  recalledAccount,
32
36
  rememberAccount,
33
37
  rootOf2 as rootOf
34
- } from "./chunk-Z3TZTOR2.js";
38
+ } from "./chunk-T3AGR4TI.js";
35
39
  import {
36
40
  AUTHORITY_KEY,
37
41
  CEILING_KEY,
@@ -42,34 +46,34 @@ import {
42
46
  levelFor,
43
47
  readKeysForCommand,
44
48
  skipFlagFor
45
- } from "./chunk-SEL7SJCM.js";
49
+ } from "./chunk-AJ4JS2ZR.js";
46
50
  import {
47
51
  isCliFailure,
48
52
  providerErrorKey
49
- } from "./chunk-M55XFZMG.js";
53
+ } from "./chunk-SW5NVASW.js";
50
54
  import {
51
55
  servingProfiles
52
- } from "./chunk-RGM66WZ3.js";
56
+ } from "./chunk-BYQ3Z6UL.js";
53
57
  import {
54
58
  openStore
55
- } from "./chunk-24MHYGNE.js";
59
+ } from "./chunk-IWHXM2S7.js";
56
60
  import {
57
61
  logRecordOf,
58
62
  realSleep,
59
63
  resolvePaths,
60
64
  writeSecurely
61
- } from "./chunk-ZISFMUYB.js";
65
+ } from "./chunk-JAWJZTFL.js";
62
66
  import {
63
67
  CliError
64
- } from "./chunk-L3KMVMRJ.js";
68
+ } from "./chunk-4DPICEPQ.js";
65
69
  import {
66
70
  __name
67
71
  } from "./chunk-ZVVMGPBJ.js";
68
72
 
69
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/guard.js
73
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/guard.js
70
74
  import { randomUUID } from "node:crypto";
71
75
 
72
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/flood.js
76
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/flood.js
73
77
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
74
78
  import { dirname, join } from "node:path";
75
79
  var MOST_DEADLINES = 50;
@@ -153,11 +157,11 @@ var FloodMemory = class {
153
157
  }
154
158
  };
155
159
 
156
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/journal.js
160
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/journal.js
157
161
  import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
158
162
  import { dirname as dirname3, join as join2 } from "node:path";
159
163
 
160
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/file-lock.js
164
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/file-lock.js
161
165
  import { closeSync, mkdirSync as mkdirSync2, openSync, statSync, unlinkSync } from "node:fs";
162
166
  import { dirname as dirname2 } from "node:path";
163
167
  var LOCK_WAIT_MS = 5e3;
@@ -224,7 +228,7 @@ var lockTime = /* @__PURE__ */ __name((lock) => {
224
228
  }
225
229
  }, "lockTime");
226
230
 
227
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/journal.js
231
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/journal.js
228
232
  var sendsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "sends", `${profile}.jsonl`), "sendsPathFor");
229
233
  var SendJournal = class {
230
234
  static {
@@ -301,7 +305,7 @@ var withSendId = /* @__PURE__ */ __name((entry) => {
301
305
  return cid === void 0 || rest.sendId !== void 0 ? rest : { ...rest, sendId: String(cid) };
302
306
  }, "withSendId");
303
307
 
304
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/recipients.js
308
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/recipients.js
305
309
  import { existsSync, readFileSync as readFileSync3, rmSync } from "node:fs";
306
310
  import { join as join3 } from "node:path";
307
311
  var recipientsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.recipients.json`), "recipientsPathFor");
@@ -413,7 +417,7 @@ var RecipientList = class {
413
417
  }
414
418
  };
415
419
 
416
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/guard.js
420
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/guard.js
417
421
  var HOUR_MS = 60 * 60 * 1e3;
418
422
  var READS_UNDER_HOLD = /* @__PURE__ */ new Set([
419
423
  "attachments.extract",
@@ -606,7 +610,7 @@ var guardFor = /* @__PURE__ */ __name((app, settings, warn, env = process.env, a
606
610
  }), "guardFor");
607
611
  var journalFailure = /* @__PURE__ */ __name((error) => error?.code ?? (error instanceof Error ? error.name : "error"), "journalFailure");
608
612
 
609
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
613
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
610
614
  import { openSync as openSync2 } from "node:fs";
611
615
  import { createInterface } from "node:readline";
612
616
  import { ReadStream } from "node:tty";
@@ -661,7 +665,7 @@ var terminalAsker = /* @__PURE__ */ __name((command) => async (key, request) =>
661
665
  throw new CliError("cancelled", `${key}: not done \u2014 the answer was no`);
662
666
  }, "terminalAsker");
663
667
 
664
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/sends/pace.js
668
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/sends/pace.js
665
669
  import { readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
666
670
  import { join as join4 } from "node:path";
667
671
  var DEFAULT_PACE = { perMinute: 60, burst: 20 };
@@ -720,7 +724,7 @@ var Pacer = class {
720
724
  }
721
725
  };
722
726
 
723
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
727
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
724
728
  var HOUSEKEEPING = /* @__PURE__ */ new Set([
725
729
  "help",
726
730
  "guide",
@@ -799,7 +803,7 @@ var refuseUnknownPermissionKeys = /* @__PURE__ */ __name((command, settings, too
799
803
  throw new CliError("validation_error", `--permission ${key} names no command`, { permission: key });
800
804
  }, "refuseUnknownPermissionKeys");
801
805
 
802
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
806
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
803
807
  var LONG_LIVED = /* @__PURE__ */ new Set(["self", "newSendId", "close", "formatMarkdown", "formatHtml", "storedChats"]);
804
808
  var LISTENING = /* @__PURE__ */ new Set(["watch", "feed", "listen", "listenHistory"]);
805
809
  var BLOCKING = /* @__PURE__ */ new Set(["frozen", "limited", "banned"]);
@@ -918,7 +922,7 @@ var flooded = /* @__PURE__ */ __name((messenger, memory, { name, warn, pacer })
918
922
  });
919
923
  }, "flooded");
920
924
 
921
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
925
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
922
926
  var observed = /* @__PURE__ */ __name((messenger, events) => {
923
927
  const timed = /* @__PURE__ */ __name(async (operation, named, work, after) => {
924
928
  const write = currentOperation();
@@ -954,9 +958,9 @@ var observed = /* @__PURE__ */ __name((messenger, events) => {
954
958
  }, "timed");
955
959
  const counted = /* @__PURE__ */ __name(async (operation, onItem, work, count) => {
956
960
  const counts = {};
957
- await timed(operation, {}, () => work((item) => {
961
+ await timed(operation, {}, () => work((item, ...rest) => {
958
962
  count(item, counts);
959
- onItem(item);
963
+ return onItem(item, ...rest);
960
964
  }), () => ({ counts }));
961
965
  }, "counted");
962
966
  const mint = messenger.newSendId;
@@ -1017,10 +1021,37 @@ var byPart = /* @__PURE__ */ __name((batch, counts) => {
1017
1021
  counts[part] = (counts[part] ?? 0) + items.length;
1018
1022
  }, "byPart");
1019
1023
 
1020
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
1024
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
1021
1025
  var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
1022
- var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events, pending, announcing, deletedWithoutChat, profile, rekeyed, rekeyPacing = REKEY_PACING, closing, namesFromStore, recipientIds, countsUnread = false }) => {
1026
+ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events, pending, announcing, deletedWithoutChat, profile, rekeyed, rekeyPacing = REKEY_PACING, closing, namesFromStore, recipientIds, countsUnread = false, historyLimits, command = "cli" }) => {
1023
1027
  let warned = false;
1028
+ let limitedNoted = false;
1029
+ const limited = /* @__PURE__ */ __name(async (opened, batch) => {
1030
+ if (!historyLimits || !batch.messages?.length)
1031
+ return { batch, skipped: /* @__PURE__ */ new Map() };
1032
+ const shapes = await opened.chats.historyShapes(account, [...new Set(batch.messages.map((one) => one.chatId))]);
1033
+ return limitBatch(batch, (chatId) => shapes.get(chatId), (chatId) => shapes.get(chatId)?.included === true, historyLimits);
1034
+ }, "limited");
1035
+ const noteLimited = /* @__PURE__ */ __name((skipped) => {
1036
+ if (skipped.size === 0)
1037
+ return;
1038
+ const counts = {
1039
+ chats: skipped.size,
1040
+ messages: 0,
1041
+ group_too_large: 0,
1042
+ older_than_window: 0
1043
+ };
1044
+ for (const skip of skipped.values()) {
1045
+ counts.messages = (counts.messages ?? 0) + skip.messages;
1046
+ counts[skip.reason] = (counts[skip.reason] ?? 0) + 1;
1047
+ }
1048
+ const warning = { event: "warning", code: "history_limited", operation: "history.save", counts };
1049
+ events(warning);
1050
+ if (limitedNoted)
1051
+ return;
1052
+ limitedNoted = true;
1053
+ warn(`history limits left out ${counts.messages} pushed messages of ${skipped.size} chats (big groups, older than the window) \u2014 \`${command} store status\` lists them; \`${command} messages sync <chat> --full-history\` fetches one and keeps it in full`, warning);
1054
+ }, "noteLimited");
1024
1055
  let recorded = profile === void 0;
1025
1056
  const notWritten = /* @__PURE__ */ __name((operation, error) => {
1026
1057
  const warning = { event: "warning", code: "store_not_written", operation };
@@ -1032,15 +1063,18 @@ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events,
1032
1063
  const attempt = /* @__PURE__ */ __name(async (operation, write) => {
1033
1064
  try {
1034
1065
  const opened = await store();
1035
- if (opened)
1036
- await write(opened);
1066
+ if (!opened)
1067
+ return false;
1068
+ await write(opened);
1037
1069
  if (opened && !recorded && profile) {
1038
1070
  recorded = true;
1039
1071
  await Promise.resolve().then(() => opened.accounts.saveProfile(profile.app, profile.name, account)).catch(() => {
1040
1072
  });
1041
1073
  }
1074
+ return true;
1042
1075
  } catch (error) {
1043
1076
  notWritten(operation, error);
1077
+ return false;
1044
1078
  }
1045
1079
  }, "attempt");
1046
1080
  const save = /* @__PURE__ */ __name((operation, writing) => {
@@ -1138,7 +1172,13 @@ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events,
1138
1172
  rekeysQueued += rekeys.length;
1139
1173
  const saving = previous.then(async () => {
1140
1174
  await saveRekeys(rekeys, round);
1141
- await attempt(operation, (opened) => fill(opened, account, batch));
1175
+ return attempt(operation, async (opened) => {
1176
+ const { batch: kept, skipped } = await limited(opened, batch);
1177
+ await fill(opened, account, kept);
1178
+ if (skipped.size > 0)
1179
+ await opened.chats.recordHistorySkips(account, skipped);
1180
+ noteLimited(skipped);
1181
+ });
1142
1182
  });
1143
1183
  previous = saving;
1144
1184
  pending?.add(saving);
@@ -1148,10 +1188,11 @@ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events,
1148
1188
  pending?.delete(saving);
1149
1189
  rekeysOnly.delete(saving);
1150
1190
  });
1151
- onBatch(batch);
1191
+ void onBatch(batch, saving);
1192
+ return saving;
1152
1193
  };
1153
1194
  }, "saveBatches");
1154
- return throughWrapper(messenger, {
1195
+ const wrapped = throughWrapper(messenger, {
1155
1196
  ...messenger.forumState ? {
1156
1197
  forumState: /* @__PURE__ */ __name(async (chatId) => {
1157
1198
  const state = await capability(messenger, "forumState", "read forum settings")(chatId);
@@ -1372,7 +1413,54 @@ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events,
1372
1413
  return sent;
1373
1414
  }, "send")
1374
1415
  });
1416
+ const chatOf2 = /* @__PURE__ */ __name(async (typed) => {
1417
+ const named = chatReferenceOf(typed, account.provider);
1418
+ if (!named)
1419
+ return typed;
1420
+ let known;
1421
+ try {
1422
+ known = account.account;
1423
+ } catch {
1424
+ }
1425
+ await ensureAccount(named, { account: known, ...profile ? { profile: profile.name } : {} }, async (other) => {
1426
+ const opened = await store();
1427
+ return opened && profilesOnAccount(opened, profile?.app, account.provider)(other);
1428
+ });
1429
+ return named.chat;
1430
+ }, "chatOf");
1431
+ return withChatReferences(wrapped, chatOf2);
1375
1432
  }, "stored");
1433
+ var TYPED_CHAT = [
1434
+ "resolve",
1435
+ "chat",
1436
+ "history",
1437
+ "around",
1438
+ "historyAfter",
1439
+ "historyBefore",
1440
+ "historyFrom",
1441
+ "topics",
1442
+ "topic",
1443
+ "topicHistory",
1444
+ "download",
1445
+ "transcribe",
1446
+ "scheduled",
1447
+ "admins",
1448
+ "chatEvents",
1449
+ "leave",
1450
+ "group",
1451
+ "officialChatStats"
1452
+ ];
1453
+ var withChatReferences = /* @__PURE__ */ __name((adapter, chatOf2) => {
1454
+ const methods = adapter;
1455
+ const own = Object.fromEntries(TYPED_CHAT.flatMap((name) => {
1456
+ const method = methods[name];
1457
+ if (typeof method !== "function")
1458
+ return [];
1459
+ const call = /* @__PURE__ */ __name(async (typed, ...rest) => method.call(adapter, await chatOf2(typed), ...rest), "call");
1460
+ return [[name, call]];
1461
+ }));
1462
+ return throughWrapper(adapter, own);
1463
+ }, "withChatReferences");
1376
1464
  var saveSent = /* @__PURE__ */ __name((opened, account, typed, message, options, into = message.chatId || typed) => opened.messages.saveMessages(account, into, [message], { ...options, typedChatId: typed }), "saveSent");
1377
1465
  var storedChat = /* @__PURE__ */ __name(async (store, account, traits, reference) => {
1378
1466
  const bound = store.forAccount(account);
@@ -1509,7 +1597,7 @@ var keep = /* @__PURE__ */ __name(async (store, account, event, seenAt, among, c
1509
1597
  }
1510
1598
  }, "keep");
1511
1599
 
1512
- // node_modules/.pnpm/@wirecat+cli-core@0.542.0_@wirecat+cli-base@0.72.0_commander@15.0.0_esbuild@0.28.2_type_30804e4648080c93f4901a09634b7e87/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
1600
+ // node_modules/.pnpm/@wirecat+cli-core@0.550.0_@wirecat+cli-base@0.74.0_commander@15.0.0_esbuild@0.28.2_type_14b809de162f39c654f85ad24a8cdf95/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
1513
1601
  var lazyStore = /* @__PURE__ */ __name((env, command, version) => {
1514
1602
  let opened;
1515
1603
  return {
@@ -1687,7 +1775,8 @@ var connected = /* @__PURE__ */ __name((connection, { app, provider, name, delet
1687
1775
  rekeyed: /* @__PURE__ */ __name((from, to) => rekeyRecipients(app, settings.profile, env, renderer.warn, from, to), "rekeyed"),
1688
1776
  recipientIds: /* @__PURE__ */ __name(() => (new RecipientList(recipientsPathFor(app, settings.profile, env), app.command).read() ?? []).flatMap((recipient) => [recipient.id, ...recipient.partnerId ? [recipient.partnerId] : []]), "recipientIds"),
1689
1777
  ...history === "store" ? { namesFromStore: savedChatId ? { savedChatId } : {} } : {},
1690
- ...unreadCounts === "store" ? { countsUnread: true } : {}
1778
+ ...unreadCounts === "store" ? { countsUnread: true } : {},
1779
+ ...history === "store" && settings.historyLimits ? { historyLimits: settings.historyLimits, command: `${app.command} ${settings.profile}` } : {}
1691
1780
  });
1692
1781
  const passives = history === "store" && self !== null && !watching ? passivesOf(saving).map((passive) => listened(passive, events, renderer.warn, closeWaitMs)) : [];
1693
1782
  return {