@wirecat/mail-cli 0.23.0 → 0.24.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 (121) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/bin/mail.js +2 -2
  3. package/dist/bundle/{all-profiles-CI32WFEV.js → all-profiles-VS7P6DJY.js} +11 -11
  4. package/dist/bundle/{anthropic-ICSOMJIN.js → anthropic-C5JXKGBS.js} +16 -7
  5. package/dist/bundle/{app-server-3F4ZB7DH.js → app-server-HU3LVU42.js} +51 -50
  6. package/dist/bundle/{bun-7AHNFZMZ.js → bun-QLFX47WZ.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-UIWRS4HI.js → bun-sqlite-W4PGAKVY.js} +5 -5
  8. package/dist/bundle/{chunk-ETIUB2DF.js → chunk-3FD3IATT.js} +6 -6
  9. package/dist/bundle/{chunk-6FSLEARF.js → chunk-3KSK5BBB.js} +2 -2
  10. package/dist/bundle/{chunk-I3YNNSGB.js → chunk-4QNHAM3J.js} +2 -2
  11. package/dist/bundle/{chunk-7SWWVDEZ.js → chunk-4W4EVVL4.js} +61 -21
  12. package/dist/bundle/{chunk-JDKC7EXM.js → chunk-5NLHDK7P.js} +50 -46
  13. package/dist/bundle/{chunk-AHRHP2H2.js → chunk-5X3GU5LI.js} +6 -6
  14. package/dist/bundle/{chunk-KNRONMVG.js → chunk-64ZG5ERD.js} +2 -2
  15. package/dist/bundle/{chunk-RIAZTS6C.js → chunk-6PWCQKMD.js} +12 -12
  16. package/dist/bundle/{chunk-4PNIZUEC.js → chunk-6VV7J2TN.js} +36 -57
  17. package/dist/bundle/{chunk-5AS5N7V5.js → chunk-A6J4MPTI.js} +3 -1
  18. package/dist/bundle/{chunk-ZYHBMDNU.js → chunk-AUTX2MLF.js} +11 -9
  19. package/dist/bundle/{chunk-5Y2WRUYP.js → chunk-B72343TK.js} +2 -2
  20. package/dist/bundle/{chunk-7SIWMF77.js → chunk-BFQQV22T.js} +1 -1
  21. package/dist/bundle/chunk-C3NYJW6B.js +1542 -0
  22. package/dist/bundle/{chunk-7ZDH2XEY.js → chunk-C5BMCLCQ.js} +4 -4
  23. package/dist/bundle/{chunk-JO4BJYVE.js → chunk-DW3F6DUW.js} +1 -1
  24. package/dist/bundle/chunk-EKGRNFYQ.js +18 -0
  25. package/dist/bundle/{chunk-4YTX5YAU.js → chunk-FKWUUCX2.js} +1361 -1539
  26. package/dist/bundle/{chunk-LLYVBO3R.js → chunk-FNLUKODV.js} +19 -19
  27. package/dist/bundle/{chunk-HGV7DSSA.js → chunk-H5FJTHVA.js} +2 -2
  28. package/dist/bundle/{chunk-3QVGB2CI.js → chunk-HBZAJINU.js} +4 -4
  29. package/dist/bundle/{chunk-BT7UUI6E.js → chunk-IRUN4XOV.js} +2 -2
  30. package/dist/bundle/{chunk-4TKQIXND.js → chunk-JMLIKXFO.js} +2 -2
  31. package/dist/bundle/{chunk-XV3M3NAN.js → chunk-JOQGJUFT.js} +1 -1
  32. package/dist/bundle/{chunk-NEDYKKJJ.js → chunk-JWMLMAHP.js} +4 -4
  33. package/dist/bundle/{chunk-5QQOUYNA.js → chunk-KGOVFEWZ.js} +3 -3
  34. package/dist/bundle/{chunk-NKDYHAHP.js → chunk-KV4VTKF3.js} +3 -3
  35. package/dist/bundle/chunk-LVGX7VTD.js +138 -0
  36. package/dist/bundle/{chunk-3DQYO7FB.js → chunk-MCPOZNWG.js} +1 -1
  37. package/dist/bundle/{chunk-SCH3NC5X.js → chunk-MTO6YVMN.js} +3 -3
  38. package/dist/bundle/{chunk-R4RAWEMV.js → chunk-NCRSE647.js} +286 -48
  39. package/dist/bundle/{chunk-UTLJQG6Q.js → chunk-NSIN5IM4.js} +8 -8
  40. package/dist/bundle/{chunk-IMIY7HQB.js → chunk-NWKKPDZV.js} +2 -2
  41. package/dist/bundle/chunk-O373QEAJ.js +1243 -0
  42. package/dist/bundle/{chunk-OMW37FXK.js → chunk-OQW6GHUA.js} +1 -1
  43. package/dist/bundle/{chunk-D6WTKSRA.js → chunk-PRQ2U7HF.js} +2 -2
  44. package/dist/bundle/{chunk-HRIYU2HJ.js → chunk-PT6MF2VU.js} +469 -120
  45. package/dist/bundle/{chunk-B6GITVDX.js → chunk-Q4OKEN3B.js} +7 -7
  46. package/dist/bundle/{chunk-ELGEHZK2.js → chunk-Q6K2XUGU.js} +1 -1
  47. package/dist/bundle/{chunk-CNYQ3TTZ.js → chunk-QI3PXUOJ.js} +43 -595
  48. package/dist/bundle/{chunk-SGMENSI6.js → chunk-QVMOEB3I.js} +391 -16
  49. package/dist/bundle/{chunk-S2U5BXWS.js → chunk-RLQZFZLK.js} +80 -5
  50. package/dist/bundle/{chunk-SETCGPFG.js → chunk-RN7OI5KL.js} +9 -8
  51. package/dist/bundle/{chunk-5J4WNTTM.js → chunk-RNZKQMFY.js} +14 -14
  52. package/dist/bundle/{chunk-WQRX4RQS.js → chunk-RUASZW3M.js} +5 -5
  53. package/dist/bundle/{chunk-UHC5I3JV.js → chunk-RX5CJ55S.js} +1 -1
  54. package/dist/bundle/{chunk-FHCOGR7S.js → chunk-SWKQ6IAR.js} +3 -3
  55. package/dist/bundle/{chunk-KJQZXCNK.js → chunk-TI7ZIPA2.js} +4 -4
  56. package/dist/bundle/{chunk-7DFWXIY5.js → chunk-TLEBSMC7.js} +1997 -768
  57. package/dist/bundle/{chunk-5Z7LZAVP.js → chunk-U6MMQNNK.js} +6 -6
  58. package/dist/bundle/{chunk-HN6PB7F5.js → chunk-VNKWSCN7.js} +99 -42
  59. package/dist/bundle/{chunk-DALBYUPC.js → chunk-VUBZFMGP.js} +2 -2
  60. package/dist/bundle/{chunk-XP5FBDIG.js → chunk-VVL4MKYH.js} +1 -1
  61. package/dist/bundle/{chunk-TEL2OMS5.js → chunk-WOX7FZJP.js} +686 -220
  62. package/dist/bundle/{chunk-2BAO4T4Z.js → chunk-X47BL4M5.js} +13 -13
  63. package/dist/bundle/{chunk-GOMJNH56.js → chunk-X7J3TTDO.js} +8 -8
  64. package/dist/bundle/{chunk-FVKZ55I2.js → chunk-XBEO472U.js} +29976 -16640
  65. package/dist/bundle/{chunk-UA4BOLIY.js → chunk-YA45XV6G.js} +4 -4
  66. package/dist/bundle/{chunk-FIZWQTUC.js → chunk-YBQ5AYLZ.js} +3 -3
  67. package/dist/bundle/{chunk-AFPETMXZ.js → chunk-YI544LHI.js} +13 -136
  68. package/dist/bundle/chunk-ZO4MQWIK.js +188 -0
  69. package/dist/bundle/{chunk-7OVVX4F4.js → chunk-ZR2BDNGG.js} +1 -1
  70. package/dist/bundle/command-contract-ERYYPAD2.js +35 -0
  71. package/dist/bundle/command-server-entry-5E3PPDE5.js +164 -0
  72. package/dist/bundle/{decode-BJXABRAN.js → decode-AVWV7SVZ.js} +5 -5
  73. package/dist/bundle/{dispatch-G4CYFWQ2.js → dispatch-BXPHSNK5.js} +10 -10
  74. package/dist/bundle/{dist-LLEA6R4V.js → dist-PIOOKBWT.js} +78 -44
  75. package/dist/bundle/{echarts-YPTKBOZV.js → echarts-7K6YQV52.js} +2 -2
  76. package/dist/bundle/{embed-DMROTI5M.js → embed-4NT76GJK.js} +6 -6
  77. package/dist/bundle/{embedder-DWMHXCHJ.js → embedder-ITQFF7EN.js} +9 -9
  78. package/dist/bundle/{failure-FFPK2WYB.js → failure-3Q65JOPD.js} +2 -2
  79. package/dist/bundle/{first-run-FQOEF2IO.js → first-run-PM74YU4X.js} +11 -11
  80. package/dist/bundle/first-screen-WBVGVSMY.js +33 -0
  81. package/dist/bundle/{instructions-OGKMROLD.js → instructions-JDSITYHV.js} +1 -1
  82. package/dist/bundle/mail.js +37 -13
  83. package/dist/bundle/{mcp-CFVG2OUS.js → mcp-7KQUJNFN.js} +2 -2
  84. package/dist/bundle/{node-HIKYE546.js → node-D6YIJOJI.js} +2 -2
  85. package/dist/bundle/{node-sqlite-3GJAG7VO.js → node-sqlite-PJOHHB4X.js} +6 -6
  86. package/dist/bundle/{oauth-H3DB6IHI.js → oauth-BOWJ3IBT.js} +7 -7
  87. package/dist/bundle/{open-DJ2PRG74.js → open-FIAKKZMW.js} +5 -5
  88. package/dist/bundle/{openai-MDBRYB55.js → openai-QL54VVLC.js} +16 -37
  89. package/dist/bundle/{process-4LBD72JH.js → process-AYHK7WRC.js} +1 -1
  90. package/dist/bundle/{program-F6WK6RX4.js → program-6FKWOTBK.js} +3206 -1603
  91. package/dist/bundle/{prompt-UNPUG6SO.js → prompt-XJZCBELC.js} +5 -5
  92. package/dist/bundle/{recognize-DMIO4PDB.js → recognize-OQKWAHBY.js} +4 -4
  93. package/dist/bundle/{remote-24HJA72D.js → remote-NLVUZ5WK.js} +7 -7
  94. package/dist/bundle/{rerank-PTNCHHIU.js → rerank-NRPZDTJ7.js} +7 -7
  95. package/dist/bundle/{serve-T6JHM2YD.js → serve-O4YUI7F6.js} +9 -9
  96. package/dist/bundle/server-6OT5ZEWL.js +66 -0
  97. package/dist/bundle/{server-BWEYRUR3.js → server-WAL3M4OO.js} +40 -40
  98. package/dist/bundle/{sqlite-runtime-ZJ4EH5ZM.js → sqlite-runtime-5YHGI4D4.js} +6 -6
  99. package/dist/bundle/{state-KSN4OFYW.js → state-WYYOJ7KK.js} +6 -6
  100. package/dist/bundle/{store-OIEZJEA7.js → store-6BJO3F2J.js} +22 -16
  101. package/dist/bundle/{store-GVBW2ZFK.js → store-X72GOJHD.js} +50 -22
  102. package/dist/bundle/store-maintenance-command-ASS7RBYC.js +54 -0
  103. package/dist/commands/rules.d.ts.map +1 -1
  104. package/dist/commands/rules.js +29 -7
  105. package/dist/commands/rules.js.map +1 -1
  106. package/dist/commands/sync.d.ts +0 -1
  107. package/dist/commands/sync.d.ts.map +1 -1
  108. package/dist/commands/sync.js +8 -2
  109. package/dist/commands/sync.js.map +1 -1
  110. package/dist/config.d.ts +4 -0
  111. package/dist/config.d.ts.map +1 -1
  112. package/dist/version.d.ts +1 -1
  113. package/dist/version.js +1 -1
  114. package/package.json +4 -4
  115. package/dist/bundle/chunk-5AQ4S4TZ.js +0 -12172
  116. package/dist/bundle/chunk-B4MWHI2V.js +0 -380
  117. package/dist/bundle/command-contract-UIRWJVEY.js +0 -35
  118. package/dist/bundle/first-screen-B6LF5464.js +0 -33
  119. package/dist/bundle/server-VUQNR5ZD.js +0 -65
  120. package/dist/bundle/store-maintenance-command-KJ54HLUQ.js +0 -54
  121. /package/dist/bundle/{chunk-QZLK2ISN.js → chunk-YVNHQFLC.js} +0 -0
@@ -1,78 +1,76 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
+ FloodMemory,
4
5
  OFFLINE,
6
+ RecipientList,
5
7
  capability,
8
+ ceilingRefusal,
6
9
  chatIdIn,
10
+ floodPathFor,
11
+ guardFor,
12
+ holdEnd,
7
13
  profilesOnAccount,
14
+ recipientsPathFor,
8
15
  refuseLacking,
9
16
  servicesFor,
10
- throughWrapper
11
- } from "./chunk-7DFWXIY5.js";
12
- import {
13
- chatReferenceOf,
14
- ensureAccount,
15
- foldName,
16
- isId,
17
- pickPerson
18
- } from "./chunk-AFPETMXZ.js";
17
+ throughWrapper,
18
+ withFileLockAsync
19
+ } from "./chunk-TLEBSMC7.js";
19
20
  import {
20
21
  servingProfiles
21
- } from "./chunk-FIZWQTUC.js";
22
+ } from "./chunk-YBQ5AYLZ.js";
22
23
  import {
23
- LOG_ATTRIBUTES,
24
- MESSENGER_CHANGE_REFUSAL,
25
24
  asFirstWord,
26
25
  baseContext,
27
26
  codeOf,
28
27
  currentOperation,
29
- currentRun,
30
28
  environmentOf,
31
- fromLogAttributes,
32
29
  issueMessage,
33
30
  limitBatch,
34
- logAttributes,
35
31
  permissionIssues,
36
32
  publicIssue,
37
- readOnlyRefusal,
38
33
  recalledAccount,
39
34
  rememberAccount,
40
35
  rootOf2 as rootOf
41
- } from "./chunk-4YTX5YAU.js";
36
+ } from "./chunk-FKWUUCX2.js";
42
37
  import {
43
38
  AUTHORITY_KEY,
44
39
  CEILING_KEY,
45
40
  DEFAULT_PERMISSIONS,
46
41
  WRITE_KEYS,
47
42
  keyForCommand,
48
- keyForWrite,
49
43
  levelFor,
50
44
  readKeysForCommand,
51
45
  skipFlagFor
52
- } from "./chunk-B6GITVDX.js";
46
+ } from "./chunk-Q4OKEN3B.js";
53
47
  import {
54
48
  providerErrorKey
55
- } from "./chunk-ZYHBMDNU.js";
49
+ } from "./chunk-AUTX2MLF.js";
56
50
  import {
57
51
  openStore
58
- } from "./chunk-FVKZ55I2.js";
52
+ } from "./chunk-XBEO472U.js";
53
+ import {
54
+ chatReferenceOf,
55
+ ensureAccount,
56
+ foldName,
57
+ isId,
58
+ pickPerson
59
+ } from "./chunk-C3NYJW6B.js";
59
60
  import {
60
61
  isCliFailure
61
- } from "./chunk-6FSLEARF.js";
62
+ } from "./chunk-3KSK5BBB.js";
62
63
  import {
63
- logRecordOf,
64
- realSleep,
65
- resolvePaths,
66
- writeSecurely
67
- } from "./chunk-LLYVBO3R.js";
64
+ resolvePaths
65
+ } from "./chunk-FNLUKODV.js";
68
66
  import {
69
67
  CliError
70
- } from "./chunk-DALBYUPC.js";
68
+ } from "./chunk-VUBZFMGP.js";
71
69
  import {
72
70
  __name
73
71
  } from "./chunk-ZVVMGPBJ.js";
74
72
 
75
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
73
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
76
74
  import { openSync } from "node:fs";
77
75
  import { createInterface } from "node:readline";
78
76
  import { ReadStream } from "node:tty";
@@ -127,551 +125,11 @@ var terminalAsker = /* @__PURE__ */ __name((command) => async (key, request) =>
127
125
  throw new CliError("cancelled", `${key}: not done \u2014 the answer was no`);
128
126
  }, "terminalAsker");
129
127
 
130
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/guard.js
131
- import { randomUUID } from "node:crypto";
132
-
133
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/flood.js
134
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
135
- import { dirname, join } from "node:path";
136
- var MOST_DEADLINES = 50;
137
- var LIMITED_HOLD_MS = 60 * 60 * 1e3;
138
- var FROZEN_HOLD_MS = 24 * 60 * 60 * 1e3;
139
- var NO_END = "9999-12-31T23:59:59.999Z";
140
- var holdEnd = /* @__PURE__ */ __name((block, show = (iso) => iso) => block.until === null ? "until lifted" : `until ${show(block.until)}`, "holdEnd");
141
- var floodPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "flood", `${profile}.json`), "floodPathFor");
142
- var FloodMemory = class {
143
- static {
144
- __name(this, "FloodMemory");
145
- }
146
- path;
147
- now;
148
- constructor(path, now = Date.now) {
149
- this.path = path;
150
- this.now = now;
151
- }
152
- /** What is still in force; anything expired is left out. */
153
- read() {
154
- const now = this.now();
155
- let raw;
156
- try {
157
- raw = JSON.parse(readFileSync(this.path, "utf8"));
158
- } catch {
159
- return { deadlines: [] };
160
- }
161
- const alive = /* @__PURE__ */ __name((until) => typeof until === "string" && Date.parse(until) > now, "alive");
162
- const deadlines = Array.isArray(raw.deadlines) ? raw.deadlines.filter((one) => typeof one?.operation === "string" && alive(one.until)) : [];
163
- const block = raw.sendBlock && (raw.sendBlock.until === NO_END ? { ...raw.sendBlock, until: null } : raw.sendBlock);
164
- const held = block && (block.until === null || alive(block.until));
165
- return { deadlines, ...held ? { sendBlock: block } : {} };
166
- }
167
- /** The deadline this call is still under: one for its chat, or one for the call in every chat. */
168
- owed(operation, chatId) {
169
- return this.read().deadlines.filter((one) => one.operation === operation && (one.chatId === void 0 || one.chatId === chatId)).sort((a, b) => b.until.localeCompare(a.until))[0];
170
- }
171
- remember(deadline) {
172
- const { waitMs, ...rest } = deadline;
173
- const kept = { ...rest, until: new Date(this.now() + waitMs).toISOString() };
174
- const state = this.read();
175
- const others = state.deadlines.filter((one) => one.operation !== kept.operation || one.chatId !== kept.chatId);
176
- const deadlines = [...others, kept].sort((a, b) => b.until.localeCompare(a.until)).slice(0, MOST_DEADLINES);
177
- this.#write({ ...state, deadlines });
178
- return kept;
179
- }
180
- sendBlock() {
181
- return this.read().sendBlock;
182
- }
183
- /** A ban the messenger gave no end for holds until lifted; a spam limit or a freeze without one, for a while. */
184
- block(block) {
185
- const now = this.now();
186
- const holdMs = { limited: LIMITED_HOLD_MS, frozen: FROZEN_HOLD_MS, banned: void 0 }[block.state];
187
- const kept = {
188
- ...block,
189
- since: new Date(now).toISOString(),
190
- until: block.until ?? (holdMs === void 0 ? null : new Date(now + holdMs).toISOString())
191
- };
192
- this.#write({ ...this.read(), sendBlock: kept });
193
- return kept;
194
- }
195
- /** Lifts only a block of this state: an account found not frozen may still be limited for spam. */
196
- unblock(state) {
197
- const { sendBlock, ...rest } = this.read();
198
- if (sendBlock?.state === state)
199
- this.#write(rest);
200
- }
201
- /** Forgets every wait and lifts the hold, and answers with what was still in force. */
202
- clear() {
203
- const cleared = this.read();
204
- this.#write({ deadlines: [] });
205
- return cleared;
206
- }
207
- #write({ sendBlock, ...rest }) {
208
- const state = sendBlock ? { ...rest, sendBlock: { ...sendBlock, until: sendBlock.until ?? NO_END } } : rest;
209
- mkdirSync(dirname(this.path), { recursive: true, mode: 448 });
210
- const temporary = `${this.path}.${process.pid}.tmp`;
211
- writeFileSync(temporary, `${JSON.stringify(state)}
212
- `, { mode: 384 });
213
- renameSync(temporary, this.path);
214
- }
215
- };
216
-
217
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/journal.js
218
- import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
219
- import { dirname as dirname3, join as join2 } from "node:path";
220
-
221
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/file-lock.js
222
- import { closeSync, mkdirSync as mkdirSync2, openSync as openSync2, statSync, unlinkSync } from "node:fs";
223
- import { dirname as dirname2 } from "node:path";
224
- var LOCK_WAIT_MS = 5e3;
225
- var LOCK_STALE_MS = 3e4;
226
- var RETRY_MS = 20;
227
- var pause = new Int32Array(new SharedArrayBuffer(4));
228
- var withFileLock = /* @__PURE__ */ __name((path, what2, body, waitMs = LOCK_WAIT_MS) => {
229
- const lock = lockFor(path);
230
- const deadline = Date.now() + waitMs;
231
- while (!taken(lock)) {
232
- if (Date.now() >= deadline)
233
- throw lockTimeout(what2, waitMs, lock);
234
- Atomics.wait(pause, 0, 0, RETRY_MS);
235
- }
236
- return holding(lock, body);
237
- }, "withFileLock");
238
- var withFileLockAsync = /* @__PURE__ */ __name(async (path, what2, body, waitMs = LOCK_WAIT_MS, sleep = realSleep) => {
239
- const lock = lockFor(path);
240
- const deadline = Date.now() + waitMs;
241
- while (!taken(lock)) {
242
- if (Date.now() >= deadline)
243
- throw lockTimeout(what2, waitMs, lock);
244
- await sleep(RETRY_MS);
245
- }
246
- return holding(lock, body);
247
- }, "withFileLockAsync");
248
- var lockFor = /* @__PURE__ */ __name((path) => {
249
- mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
250
- return `${path}.lock`;
251
- }, "lockFor");
252
- var taken = /* @__PURE__ */ __name((lock) => {
253
- for (; ; ) {
254
- try {
255
- closeSync(openSync2(lock, "wx", 384));
256
- return true;
257
- } catch (error) {
258
- if (error.code !== "EEXIST")
259
- throw error;
260
- if (Date.now() - lockTime(lock) <= LOCK_STALE_MS)
261
- return false;
262
- try {
263
- unlinkSync(lock);
264
- } catch {
265
- }
266
- }
267
- }
268
- }, "taken");
269
- var holding = /* @__PURE__ */ __name((lock, body) => {
270
- try {
271
- return body();
272
- } finally {
273
- try {
274
- unlinkSync(lock);
275
- } catch {
276
- }
277
- }
278
- }, "holding");
279
- var lockTimeout = /* @__PURE__ */ __name((what2, waitMs, lock) => new CliError("timeout", `${what2} stayed locked for ${waitMs / 1e3}s (${lock})`), "lockTimeout");
280
- var lockTime = /* @__PURE__ */ __name((lock) => {
281
- try {
282
- return statSync(lock).mtimeMs;
283
- } catch {
284
- return Date.now();
285
- }
286
- }, "lockTime");
287
-
288
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/journal.js
289
- var sendsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "sends", `${profile}.jsonl`), "sendsPathFor");
290
- var SendJournal = class {
291
- static {
292
- __name(this, "SendJournal");
293
- }
294
- path;
295
- resource;
296
- constructor(path, resource = { service: "unknown", version: "unknown" }) {
297
- this.path = path;
298
- this.resource = resource;
299
- }
300
- /**
301
- * Runs `body` with the journal to itself, across processes: two sends at the limit must not both
302
- * read "one left". A lock file opened with `wx`, because `flock` is not there on Windows.
303
- */
304
- locked(body) {
305
- return withFileLock(this.path, "the send journal", body);
306
- }
307
- /** `locked` without blocking the thread while another process holds the journal: what `serve` uses. */
308
- lockedAsync(body) {
309
- return withFileLockAsync(this.path, "the send journal", body);
310
- }
311
- append(entry) {
312
- const { at, ...attributes } = entry;
313
- const { runId, command, traceId } = currentRun();
314
- const record = logRecordOf({
315
- severity: entry.outcome === "sent" || entry.outcome === "reserved" ? "info" : "warn",
316
- event: logAttributes({ event: "send.recorded", ...attributes }),
317
- time: at,
318
- runId,
319
- ...traceId === void 0 ? {} : { traceId },
320
- command,
321
- resource: this.resource,
322
- allow: LOG_ATTRIBUTES
323
- });
324
- mkdirSync3(dirname3(this.path), { recursive: true, mode: 448 });
325
- appendFileSync(this.path, `${JSON.stringify(record)}
326
- `, { mode: 384 });
327
- }
328
- /**
329
- * Oldest first, each reservation folded into its outcome; one with no outcome yet is in flight,
330
- * or its process died. A line that does not parse is skipped: a torn last write must not block sending.
331
- */
332
- entries(filter) {
333
- const lines = this.#lines();
334
- const settled2 = new Set(lines.filter((entry) => entry.outcome !== "reserved").map((entry) => entry.reservation));
335
- const entries = lines.filter((entry) => entry.outcome !== "reserved" || !settled2.has(entry.reservation)).map(({ reservation, ...entry }) => entry.outcome === "reserved" ? { ...entry, reservation } : entry).map(withSendId);
336
- return filter === void 0 ? entries : entries.filter((entry) => (filter.outcome === void 0 || entry.outcome === filter.outcome) && (filter.chatId === void 0 || entry.chatId === filter.chatId) && (filter.operationId === void 0 || entry.operationId === filter.operationId) && (filter.errorCode === void 0 || entry.errorCode === filter.errorCode) && (filter.key === void 0 || entry.key === filter.key));
337
- }
338
- #lines() {
339
- let text;
340
- try {
341
- text = readFileSync2(this.path, "utf8");
342
- } catch {
343
- return [];
344
- }
345
- return text.split("\n").filter((line) => line.trim() !== "").flatMap((line) => {
346
- try {
347
- return [entryOf(JSON.parse(line))];
348
- } catch {
349
- return [];
350
- }
351
- });
352
- }
353
- };
354
- var entryOf = /* @__PURE__ */ __name((line) => {
355
- if (!("attributes" in line))
356
- return line;
357
- const { event: _, ...attributes } = line.attributes;
358
- return { at: line.time, ...fromLogAttributes(attributes) };
359
- }, "entryOf");
360
- var withSendId = /* @__PURE__ */ __name((entry) => {
361
- const { cid, ...rest } = entry;
362
- return cid === void 0 || rest.sendId !== void 0 ? rest : { ...rest, sendId: String(cid) };
363
- }, "withSendId");
364
-
365
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/recipients.js
366
- import { existsSync, readFileSync as readFileSync3, rmSync } from "node:fs";
367
- import { join as join3 } from "node:path";
368
- var recipientsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.recipients.json`), "recipientsPathFor");
369
- var RecipientList = class {
370
- static {
371
- __name(this, "RecipientList");
372
- }
373
- path;
374
- command;
375
- lockWaitMs;
376
- /** `command` names the program in the hint that turns the list off. */
377
- constructor(path, command, lockWaitMs) {
378
- this.path = path;
379
- this.command = command;
380
- this.lockWaitMs = lockWaitMs;
381
- }
382
- /** `undefined` when the list is off. A file that cannot be read refuses rather than opening up. */
383
- read() {
384
- if (!existsSync(this.path))
385
- return void 0;
386
- try {
387
- const parsed = JSON.parse(readFileSync3(this.path, "utf8"));
388
- if (!Array.isArray(parsed.chats))
389
- throw new Error("no `chats` array");
390
- return parsed.chats;
391
- } catch (error) {
392
- throw new CliError("configuration_error", `the recipient list ${this.path} cannot be read (${error instanceof Error ? error.message : String(error)}) \u2014 fix the file or turn the list off with \`${this.command} recipients clear\``);
393
- }
394
- }
395
- list(filter = {}) {
396
- const chats = this.read();
397
- return {
398
- state: chats === void 0 ? "off" : chats.length === 0 ? "empty" : "on",
399
- items: (chats ?? []).filter((chat) => (filter.id === void 0 || chat.id === filter.id) && (filter.title === void 0 || chat.title?.toLocaleLowerCase() === filter.title.toLocaleLowerCase()))
400
- };
401
- }
402
- /** Whether it was new. Adding one again fills in a partner an older entry was stored without. */
403
- add(recipient) {
404
- return this.#locked(() => this.#added(recipient));
405
- }
406
- /** `add` waiting for the lock on timers: `recipients add` connects, so it runs inside `serve` when one holds the account. */
407
- addAsync(recipient) {
408
- return withFileLockAsync(this.path, "the recipient list", () => this.#added(recipient), this.lockWaitMs);
409
- }
410
- #added(recipient) {
411
- const chats = this.read() ?? [];
412
- const known = chats.find((chat) => chat.id === recipient.id);
413
- if (known) {
414
- if (recipient.partnerId && !known.partnerId) {
415
- this.#write(chats.map((chat) => chat === known ? { ...known, partnerId: recipient.partnerId } : chat));
416
- }
417
- return false;
418
- }
419
- this.#write([...chats, recipient]);
420
- return true;
421
- }
422
- /** The id or the title as it was stored; `undefined` when neither matched. */
423
- remove(reference) {
424
- return this.#locked(() => {
425
- const chats = this.read() ?? [];
426
- const wanted = reference.trim();
427
- const gone = chats.find((chat) => chat.id === wanted) ?? chats.find((chat) => chat.title?.toLocaleLowerCase() === wanted.toLocaleLowerCase());
428
- if (gone)
429
- this.#write(chats.filter((chat) => chat !== gone));
430
- return gone;
431
- });
432
- }
433
- /**
434
- * The chat the messenger now names `to`: its entry, and a partner of that id, follow it. Only an entry already there
435
- * changes, and no list is created, so the list never opens up. Whether anything changed.
436
- */
437
- async rekey(from, to) {
438
- if (from === to)
439
- return false;
440
- return withFileLockAsync(this.path, "the recipient list", () => {
441
- const chats = this.read();
442
- if (!chats?.some((chat) => chat.id === from || chat.partnerId === from))
443
- return false;
444
- const held = chats.some((chat) => chat.id === to);
445
- this.#write(chats.filter((chat) => !(held && chat.id === from)).map((chat) => ({
446
- ...chat,
447
- ...chat.id === from ? { id: to } : {},
448
- ...chat.partnerId === from ? { partnerId: to } : {}
449
- })));
450
- return true;
451
- }, this.lockWaitMs);
452
- }
453
- /** Whether there was a list to turn off. */
454
- off() {
455
- return this.#locked(() => {
456
- if (!existsSync(this.path))
457
- return false;
458
- rmSync(this.path);
459
- return true;
460
- });
461
- }
462
- /**
463
- * Every change reads and writes under one lock: a `serve` re-keying while the owner removes a chat must not write
464
- * the removed chat back. A lock held too long refuses the change and leaves the list as it was. Blocks the thread
465
- * while it waits: for callers that cannot be async, and `recipients remove` and `clear`, which never
466
- * connect and so never run inside `serve`.
467
- */
468
- #locked(body) {
469
- return withFileLock(this.path, "the recipient list", body, this.lockWaitMs);
470
- }
471
- #write(chats) {
472
- writeSecurely(this.path, `${JSON.stringify({ chats }, null, 2)}
473
- `, 384);
474
- }
475
- };
476
-
477
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/guard.js
478
- var HOUR_MS = 60 * 60 * 1e3;
479
- var READS_UNDER_HOLD = /* @__PURE__ */ new Set([
480
- "attachments.extract",
481
- "conversations.embeddings",
482
- "conversations.links",
483
- "messages.server-search",
484
- "messages.sync-first",
485
- "stats.contacts.top.sync-first",
486
- "stats.messages.counters.sync",
487
- "stats.messages.show.sync-first",
488
- "stats.messages.top.sync-first",
489
- "store.gaps.repair"
490
- ]);
491
- var countsTowardLimit = /* @__PURE__ */ __name(({ kind = "message", action, notify }) => kind === "message" || kind === "forward" || kind === "edit" || kind === "delete" || kind === "pin" && notify === true || action === "create" || action === "members.add" || action === "requests.accept" || action === "join" || action === "contact-import", "countsTowardLimit");
492
- var weightOf = /* @__PURE__ */ __name(({ kind = "message", action, count, people }) => kind === "delete" || kind === "message" && action === void 0 ? Math.max(1, count ?? 1) : action === "create" || action === "members.add" || action === "requests.accept" || action === "contact-import" ? Math.max(1, people ?? count ?? 1) : 1, "weightOf");
493
- var timeOf = /* @__PURE__ */ __name((entry) => Date.parse(entry.scheduledFor ?? entry.at), "timeOf");
494
- var ceilingRefusal = /* @__PURE__ */ __name((key, command) => new CliError("permission_error", `${key} is not allowed: setup's answer keeps every WireCat tool read-only; the owner changes it at a terminal with \`${command} setup\``, { permission: key }), "ceilingRefusal");
495
- var levelRefusal = /* @__PURE__ */ __name((refused, fix = `${refused.command} ${refused.profile} config set permissions.${refused.key} allow`) => refused.named === CEILING_KEY ? ceilingRefusal(refused.key, refused.command) : new CliError("permission_error", `profile ${refused.profile} does not let ${refused.key} write (permissions.${refused.named} is ${refused.level}, from the ${refused.permissionSources[refused.named ?? ""] ?? "default"}); to allow it: ${fix}`, { permission: refused.key }), "levelRefusal");
496
- var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipients.command, readOnlyLock, permissions, permissionSources = {}, permissionDefaults, permissionFix, ask = refuseToAsk, sendsPerHour, journal, flood, warn, now = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "now") }) => {
497
- const currentPermissions = /* @__PURE__ */ __name(() => typeof permissions === "function" ? permissions() : permissions, "currentPermissions");
498
- let reservation;
499
- const answered = /* @__PURE__ */ new WeakSet();
500
- const refuseReadOnly = /* @__PURE__ */ __name(() => {
501
- if (readOnlyLock)
502
- throw readOnlyRefusal(readOnlyLock, MESSENGER_CHANGE_REFUSAL);
503
- }, "refuseReadOnly");
504
- const refuseHeld = /* @__PURE__ */ __name(({ key }) => {
505
- if (key !== void 0 && READS_UNDER_HOLD.has(key))
506
- return;
507
- const block = flood?.sendBlock();
508
- if (!block)
509
- return;
510
- throw new CliError("permission_error", `profile ${profile} holds its writes ${holdEnd(block)}: ${block.hint} \u2014 reads still work; do not retry: the owner checks the account with \`${command} ${profile} doctor --online\`, and lifts the hold with \`${command} ${profile} flood clear\` once it is over`, { sendBlock: block, standing: { state: block.state, hint: block.hint } });
511
- }, "refuseHeld");
512
- const permitted = /* @__PURE__ */ __name((request) => {
513
- const { chatId, kind = "message", action, personIds } = request;
514
- refuseReadOnly();
515
- const levels = currentPermissions();
516
- if (levels !== void 0) {
517
- const key = request.key ?? keyForWrite(kind, action);
518
- const { level, key: named } = levelFor(levels, key, permissionDefaults);
519
- if (level === "deny" || level === "readonly")
520
- throw levelRefusal({ profile, command, key, level, named, permissionSources }, permissionFix?.(request, key));
521
- if (level === "ask" && !answered.has(request)) {
522
- throw new CliError("confirmation_required", `${key} asks before it acts, and it was not asked`);
523
- }
524
- }
525
- const allowed = recipients.read();
526
- if (chatId !== null && allowed && !allowed.some((chat) => chat.id === chatId)) {
527
- throw new CliError("confirmation_required", `chat ${chatId} is not on the recipient list of profile ${profile} \u2014 the owner adds it with \`${command} ${profile} recipients add ${chatId}\``, { chat_id: chatId });
528
- }
529
- const strangers = allowed ? (personIds ?? []).filter((id) => !allowed.some((chat) => chat.partnerId === id)) : [];
530
- if (strangers.length > 0) {
531
- throw new CliError("confirmation_required", `${strangers.join(", ")} ${strangers.length === 1 ? "is" : "are"} not on the recipient list of profile ${profile} \u2014 the owner adds the one-to-one chat with each person (\`${command} ${profile} recipients add <chat>\`); a chat added to the list earlier is added again to be recognised`, { person_ids: strangers });
532
- }
533
- }, "permitted");
534
- const withinLimit = /* @__PURE__ */ __name((request, entries) => {
535
- const { chatId, sendId } = request;
536
- const asked = { ...request, people: request.personIds?.length ?? request.count };
537
- const count = weightOf(asked);
538
- if (count > sendsPerHour) {
539
- throw new CliError("rate_limited", `${count} at once is more than the hourly limit of profile ${profile} (sendsPerHour ${sendsPerHour}) \u2014 do fewer at a time`);
540
- }
541
- const at = request.scheduledFor ? Date.parse(request.scheduledFor) : now().getTime();
542
- const counted = entries.filter(countsTowardLimit).filter((entry) => entry.outcome === "sent" || entry.outcome === "outcome_unknown" || entry.outcome === "reserved").filter((entry) => Math.abs(timeOf(entry) - at) < HOUR_MS);
543
- const unsure = /* @__PURE__ */ __name((entry) => entry.outcome === "outcome_unknown", "unsure");
544
- const same = /* @__PURE__ */ __name((a, b) => a.sendId !== void 0 && a.sendId === b.sendId && a.chatId === b.chatId, "same");
545
- const last = [...counted].reverse().find((entry) => same(entry, { chatId, sendId }));
546
- if (sendId !== void 0 && last && unsure(last)) {
547
- if (last.sendAs !== request.sendAs) {
548
- throw new CliError("validation_error", "this send id was tried under another identity; repeat it with the same --send-as, or it may post twice", { operation_id: sendId, retryable: false });
549
- }
550
- return false;
551
- }
552
- const recent = counted.filter((entry, index) => !(unsure(entry) && counted.slice(index + 1).some((later) => same(later, entry)))).map((entry) => ({ time: timeOf(entry), weight: weightOf(entry) })).sort((a, b) => a.time - b.time);
553
- const used = recent.reduce((sum, { weight }) => sum + weight, 0);
554
- if (used + count > sendsPerHour) {
555
- let freed = 0;
556
- const opening = recent.find(({ weight }) => {
557
- freed += weight;
558
- return used - freed + count <= sendsPerHour;
559
- });
560
- const nextMs = (opening?.time ?? 0) + HOUR_MS;
561
- const next = new Date(nextMs).toISOString();
562
- throw new CliError("rate_limited", `profile ${profile} has sent ${used} messages in the hour around ${new Date(at).toISOString()}, and its limit is ${sendsPerHour} (sendsPerHour) \u2014 the next send is possible at ${next}`, { retry_after_ms: nextMs - now().getTime(), retry_at: next });
563
- }
564
- return true;
565
- }, "withinLimit");
566
- const counting = /* @__PURE__ */ __name((request) => {
567
- permitted(request);
568
- refuseHeld(request);
569
- const asked = { ...request, people: request.personIds?.length ?? request.count };
570
- const creatingTopic = request.kind === "chat" && request.action === "topic-create";
571
- if (!countsTowardLimit(asked) && !creatingTopic)
572
- return void 0;
573
- const checked = /* @__PURE__ */ __name((entries) => {
574
- if (!creatingTopic)
575
- return withinLimit(request, entries);
576
- if (request.sendId === void 0)
577
- throw new CliError("validation_error", "a topic creation needs an attempt id");
578
- if (entries.some((entry) => entry.action === "topic-create" && entry.sendId === request.sendId && ["sent", "outcome_unknown", "reserved"].includes(entry.outcome))) {
579
- throw new CliError("validation_error", "this topic creation was already attempted; check topics list and do not repeat an unknown creation", { operation_id: request.sendId, retryable: false });
580
- }
581
- return true;
582
- }, "checked");
583
- const reserving = /* @__PURE__ */ __name(() => {
584
- if (!checked(journal.entries()))
585
- return;
586
- const id = randomUUID();
587
- const { chatId, kind, action, sendId, operationId, scheduledFor, notify } = request;
588
- journal.append({
589
- at: now().toISOString(),
590
- profile,
591
- chatId,
592
- outcome: "reserved",
593
- reservation: id,
594
- ...kind ? { kind } : {},
595
- ...action ? { action } : {},
596
- ...asked.people === void 0 ? {} : kind === "delete" || kind === "message" || kind === void 0 ? { count: asked.people } : { people: asked.people },
597
- ...sendId === void 0 ? {} : { sendId },
598
- ...operationId === void 0 ? {} : { operationId },
599
- ...scheduledFor ? { scheduledFor } : {},
600
- ...notify === void 0 ? {} : { notify }
601
- });
602
- reservation = id;
603
- }, "reserving");
604
- return { checked, reserving };
605
- }, "counting");
606
- return {
607
- ask: /* @__PURE__ */ __name(async (request) => {
608
- refuseReadOnly();
609
- const levels = currentPermissions();
610
- if (levels === void 0)
611
- return;
612
- const key = request.key ?? keyForWrite(request.kind ?? "message", request.action);
613
- if (levelFor(levels, key, permissionDefaults).level !== "ask")
614
- return;
615
- refuseHeld(request);
616
- await ask(key, request);
617
- answered.add(request);
618
- }, "ask"),
619
- check: /* @__PURE__ */ __name((request, { reserve = true } = {}) => {
620
- const counted = counting(request);
621
- if (!counted)
622
- return;
623
- if (reserve)
624
- journal.locked(counted.reserving);
625
- else
626
- counted.checked(journal.entries());
627
- }, "check"),
628
- reserve: /* @__PURE__ */ __name(async (request) => {
629
- const counted = counting(request);
630
- if (counted)
631
- await journal.lockedAsync(counted.reserving);
632
- }, "reserve"),
633
- // After a send, a failure to write here must not become the command's answer: the message is
634
- // already with a person, and an error would invite the caller to send it again.
635
- record: /* @__PURE__ */ __name((entry) => {
636
- const { personIds: _, ...kept } = entry;
637
- const settles = entry.outcome === "refused" ? void 0 : reservation;
638
- reservation = void 0;
639
- try {
640
- journal.append({ at: now().toISOString(), profile, ...kept, ...settles ? { reservation: settles } : {} });
641
- } catch (error) {
642
- warn(`this send is not in the send journal: ${journalFailure(error)}`, {
643
- event: "warning",
644
- code: "send_not_journaled",
645
- operation: "sends.journal"
646
- });
647
- }
648
- }, "record")
649
- };
650
- }, "sendGuard");
651
- var refuseToAsk = /* @__PURE__ */ __name(async (key) => {
652
- throw new CliError("confirmation_required", `${key} asks before it acts (its permission level is ask), and nobody is here to answer \u2014 add ${skipFlagFor(key)} to go ahead`);
653
- }, "refuseToAsk");
654
- var guardFor = /* @__PURE__ */ __name((app, settings, warn, env = process.env, ask) => sendGuard({
655
- profile: settings.profile,
656
- command: app.command,
657
- ...settings.readOnlyLock ? { readOnlyLock: settings.readOnlyLock } : {},
658
- permissions: /* @__PURE__ */ __name(() => settings.permissions, "permissions"),
659
- permissionSources: settings.permissionSources,
660
- ...settings.permissionDefaults ? { permissionDefaults: settings.permissionDefaults } : {},
661
- ...ask ? { ask } : {},
662
- sendsPerHour: settings.sendsPerHour,
663
- journal: new SendJournal(sendsPathFor(app, settings.profile, env), { service: app.command, version: app.version }),
664
- recipients: new RecipientList(recipientsPathFor(app, settings.profile, env), app.command),
665
- flood: new FloodMemory(floodPathFor(app, settings.profile, env)),
666
- warn
667
- }), "guardFor");
668
- var journalFailure = /* @__PURE__ */ __name((error) => error?.code ?? (error instanceof Error ? error.name : "error"), "journalFailure");
669
-
670
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/sends/pace.js
671
- import { readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
672
- import { join as join4 } from "node:path";
128
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/sends/pace.js
129
+ import { readFileSync, renameSync, writeFileSync } from "node:fs";
130
+ import { join } from "node:path";
673
131
  var DEFAULT_PACE = { perMinute: 60, burst: 20 };
674
- var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
132
+ var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
675
133
  var Pacer = class {
676
134
  static {
677
135
  __name(this, "Pacer");
@@ -713,7 +171,7 @@ var Pacer = class {
713
171
  }
714
172
  read() {
715
173
  try {
716
- const tat = Number(JSON.parse(readFileSync4(this.path, "utf8")).tat);
174
+ const tat = Number(JSON.parse(readFileSync(this.path, "utf8")).tat);
717
175
  return Number.isFinite(tat) ? tat : 0;
718
176
  } catch {
719
177
  return 0;
@@ -721,8 +179,8 @@ var Pacer = class {
721
179
  }
722
180
  write(tat) {
723
181
  const temporary = `${this.path}.${process.pid}.tmp`;
724
- writeFileSync2(temporary, JSON.stringify({ tat }), { mode: 384 });
725
- renameSync2(temporary, this.path);
182
+ writeFileSync(temporary, JSON.stringify({ tat }), { mode: 384 });
183
+ renameSync(temporary, this.path);
726
184
  }
727
185
  };
728
186
  var ANNOUNCE_WAIT_MS = 5e3;
@@ -757,7 +215,7 @@ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
757
215
  await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
758
216
  }, "waitForTurn");
759
217
 
760
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
218
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
761
219
  var HOUSEKEEPING = /* @__PURE__ */ new Set([
762
220
  "help",
763
221
  "guide",
@@ -837,7 +295,7 @@ var refuseUnknownPermissionKeys = /* @__PURE__ */ __name((command, settings, too
837
295
  throw new CliError("validation_error", `--permission ${key} names no command`, { permission: key });
838
296
  }, "refuseUnknownPermissionKeys");
839
297
 
840
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
298
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
841
299
  var LONG_LIVED = /* @__PURE__ */ new Set(["self", "newSendId", "close", "formatMarkdown", "formatHtml", "storedChats"]);
842
300
  var LISTENING = /* @__PURE__ */ new Set(["watch", "feed", "listen", "listenHistory"]);
843
301
  var BLOCKING = /* @__PURE__ */ new Set(["frozen", "limited", "banned"]);
@@ -934,7 +392,7 @@ var flooded = /* @__PURE__ */ __name((messenger, memory, { name, warn, pacer })
934
392
  });
935
393
  }, "flooded");
936
394
 
937
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
395
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
938
396
  var observed = /* @__PURE__ */ __name((messenger, events) => {
939
397
  const timed = /* @__PURE__ */ __name(async (operation, named, work, after) => {
940
398
  const write = currentOperation();
@@ -1033,7 +491,7 @@ var byPart = /* @__PURE__ */ __name((batch, counts) => {
1033
491
  counts[part] = (counts[part] ?? 0) + items.length;
1034
492
  }, "byPart");
1035
493
 
1036
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
494
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
1037
495
  var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
1038
496
  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" }) => {
1039
497
  let warned = false;
@@ -1154,13 +612,13 @@ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events,
1154
612
  }
1155
613
  if (round !== rekeyRound)
1156
614
  return;
1157
- const taken2 = pass?.taken ?? rest.length;
1158
- rekeysQueued -= taken2;
615
+ const taken = pass?.taken ?? rest.length;
616
+ rekeysQueued -= taken;
1159
617
  for (const { from, to } of pass?.applied ?? [])
1160
618
  await Promise.resolve().then(() => rekeyed?.(from, to)).catch((error) => notWritten("history.rekey", error));
1161
619
  for (const { error } of pass?.refused ?? [])
1162
620
  notWritten("history.rekey", error);
1163
- rest = rest.slice(taken2);
621
+ rest = rest.slice(taken);
1164
622
  if (rest.length > 0)
1165
623
  await new Promise((resolve) => setTimeout(resolve, rekeyPacing.pauseMs));
1166
624
  }
@@ -1609,7 +1067,7 @@ var keep = /* @__PURE__ */ __name(async (store, account, event, seenAt, among, c
1609
1067
  }
1610
1068
  }, "keep");
1611
1069
 
1612
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
1070
+ // node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
1613
1071
  var lazyStore = /* @__PURE__ */ __name((env, command, version) => {
1614
1072
  let opened;
1615
1073
  return {
@@ -1951,6 +1409,7 @@ var messengerContext = /* @__PURE__ */ __name((command, messenger, resolving = {
1951
1409
  history: base.settings.record,
1952
1410
  searchCatchUp: base.settings.searchCatchUp,
1953
1411
  ...base.settings.historyLimits ? { historyLimits: base.settings.historyLimits } : {},
1412
+ historyMuted: base.settings.historyMuted,
1954
1413
  pictures: base.settings.pictureSearch,
1955
1414
  reranker: base.settings.searchReranker,
1956
1415
  guard,
@@ -2007,22 +1466,11 @@ var messengerContext = /* @__PURE__ */ __name((command, messenger, resolving = {
2007
1466
  }, "messengerContext");
2008
1467
 
2009
1468
  export {
2010
- sendsPathFor,
2011
- SendJournal,
2012
1469
  answerOf,
2013
1470
  terminalAsker,
2014
- holdEnd,
2015
- floodPathFor,
2016
- FloodMemory,
2017
1471
  DEFAULT_PACE,
2018
1472
  pacePathFor,
2019
1473
  Pacer,
2020
- recipientsPathFor,
2021
- RecipientList,
2022
- ceilingRefusal,
2023
- levelRefusal,
2024
- sendGuard,
2025
- guardFor,
2026
1474
  commandPermissions,
2027
1475
  knownPermissionKeys,
2028
1476
  knownBeside,