@wirecat/drive-cli 0.52.1 → 0.54.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 (218) hide show
  1. package/dist/bin/drive.js +2 -2
  2. package/dist/bin/drive.js.map +1 -1
  3. package/dist/bundle/{chunk-ZWSG7OCA.js → all-profiles-LFIPUPZI.js} +13 -8
  4. package/dist/bundle/{anthropic-KW6KU36Y.js → anthropic-G5ZRRWG4.js} +5 -5
  5. package/dist/bundle/{app-server-TCJZ333E.js → app-server-UVWATOQC.js} +48 -56
  6. package/dist/bundle/{bun-7SYKSCLA.js → bun-DNEFTPTR.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-RI7DR6RZ.js → bun-sqlite-FWBYHIXB.js} +4 -4
  8. package/dist/bundle/{chunk-CM7GAXGD.js → chunk-2CQT2WWN.js} +5 -5
  9. package/dist/bundle/{chunk-HQVJK5E7.js → chunk-2D6AAGBP.js} +246 -383
  10. package/dist/bundle/{chunk-FG4XXZZE.js → chunk-2FFXRWI2.js} +2 -2
  11. package/dist/bundle/{chunk-2UIMEMWU.js → chunk-2HQPJ366.js} +3 -3
  12. package/dist/bundle/{chunk-CB7SBYLO.js → chunk-2HWOGSTA.js} +57 -37
  13. package/dist/bundle/{chunk-7XKAVMCF.js → chunk-2MSJVFAS.js} +8 -8
  14. package/dist/bundle/{chunk-NSIFQ5OP.js → chunk-2NWFZ43Q.js} +1 -1
  15. package/dist/bundle/{chunk-H47W2J6S.js → chunk-2Q3S47BC.js} +1312 -626
  16. package/dist/bundle/{chunk-O6IOL6RX.js → chunk-47MEPBWG.js} +21 -21
  17. package/dist/bundle/{chunk-725OHXKR.js → chunk-4RDXCE45.js} +2226 -37
  18. package/dist/bundle/{chunk-UR32UWTQ.js → chunk-5BPOAHVD.js} +13 -2
  19. package/dist/bundle/{chunk-5FONRUG6.js → chunk-5D4AEUVA.js} +1 -23
  20. package/dist/bundle/{chunk-VZ2I62HN.js → chunk-5LNOVPOR.js} +2 -2
  21. package/dist/bundle/{chunk-EKFEY3KP.js → chunk-5WQN2TUM.js} +1 -1
  22. package/dist/bundle/{chunk-ALJWBGD5.js → chunk-6MGSFYGL.js} +1 -1
  23. package/dist/bundle/{chunk-WUX7AUOQ.js → chunk-6RAEXK7Y.js} +26 -26
  24. package/dist/bundle/{chunk-BSSCTWWK.js → chunk-6SOQJRGI.js} +4 -4
  25. package/dist/bundle/{chunk-CKBHR7QO.js → chunk-75DSLCPC.js} +1 -1
  26. package/dist/bundle/{chunk-VSOLLTYT.js → chunk-76JIVDKC.js} +7 -2
  27. package/dist/bundle/{chunk-33NVQGUY.js → chunk-7WCZ2OZ5.js} +6 -6
  28. package/dist/bundle/{chunk-IDUNJCFO.js → chunk-7XU3TR7K.js} +2 -2
  29. package/dist/bundle/{chunk-7SH4JHYW.js → chunk-A4FTLORC.js} +12 -12
  30. package/dist/bundle/{chunk-CITFEQ6S.js → chunk-AACQA2CO.js} +1 -1
  31. package/dist/bundle/{chunk-PSNHPFSK.js → chunk-AAHIBA36.js} +1 -1
  32. package/dist/bundle/{chunk-PEOCBV2Z.js → chunk-BWBVBW5T.js} +8 -8
  33. package/dist/bundle/{chunk-A4UNTWAX.js → chunk-CVALO727.js} +99 -30
  34. package/dist/bundle/{chunk-G6QF5KWF.js → chunk-FHW4ENRF.js} +37 -43
  35. package/dist/bundle/{chunk-LONV6HIK.js → chunk-HAHARAJD.js} +455 -40
  36. package/dist/bundle/{chunk-2623YE5I.js → chunk-IBRXVPBI.js} +97 -99
  37. package/dist/bundle/{chunk-IWFBAWZK.js → chunk-IKODUUQG.js} +292 -19
  38. package/dist/bundle/{chunk-PQJYM5ES.js → chunk-IOMSC4ZG.js} +3 -3
  39. package/dist/bundle/{chunk-YKZ4IPLB.js → chunk-JKEAZBEZ.js} +7 -7
  40. package/dist/bundle/{chunk-FCJAHD4R.js → chunk-KIQIF5M7.js} +3 -3
  41. package/dist/bundle/{chunk-KYVXMEBC.js → chunk-KT5G3KVS.js} +3 -3
  42. package/dist/bundle/{chunk-W7IK7E4B.js → chunk-L3RV42O3.js} +20 -22
  43. package/dist/bundle/{chunk-NHBUTCNR.js → chunk-LQXLWHKM.js} +9 -9
  44. package/dist/bundle/{chunk-WBTVGFXI.js → chunk-MATUQFYL.js} +11 -11
  45. package/dist/bundle/{chunk-54O62JWP.js → chunk-MULPNGM2.js} +29 -10
  46. package/dist/bundle/{chunk-FJW3DDCF.js → chunk-N4OO3SPQ.js} +5 -5
  47. package/dist/bundle/{chunk-6DHQTUB2.js → chunk-NDWWGBSM.js} +1 -1
  48. package/dist/bundle/{chunk-DLAFGSTN.js → chunk-NHDSJMAR.js} +1 -1
  49. package/dist/bundle/{chunk-PQYVPCJ2.js → chunk-O6YYFVDD.js} +38 -37
  50. package/dist/bundle/{chunk-I7UH5CTA.js → chunk-OYGEBFFO.js} +12 -14
  51. package/dist/bundle/chunk-P7E7K467.js +110 -0
  52. package/dist/bundle/{chunk-ZNZUZGSV.js → chunk-PKNTBZXN.js} +176 -49
  53. package/dist/bundle/{chunk-YNFELLNQ.js → chunk-PU4GANCD.js} +3 -3
  54. package/dist/bundle/{chunk-5PLJKSG4.js → chunk-Q46JLJ5O.js} +7 -9
  55. package/dist/bundle/{chunk-R276546S.js → chunk-QKHFQHE7.js} +1 -1
  56. package/dist/bundle/{chunk-RNSP57TC.js → chunk-QUJCD5U7.js} +4 -4
  57. package/dist/bundle/{chunk-43QVYW3K.js → chunk-RIYXQFKU.js} +262 -88
  58. package/dist/bundle/{chunk-2AUXBJRX.js → chunk-RWEFKLXJ.js} +104 -29
  59. package/dist/bundle/{chunk-WQJBAWQP.js → chunk-SBOTSSYV.js} +879 -508
  60. package/dist/bundle/{chunk-PAXKALHV.js → chunk-U3BOQ63L.js} +118 -7
  61. package/dist/bundle/{chunk-VJZST5RD.js → chunk-UBJX5D2O.js} +2 -2
  62. package/dist/bundle/{chunk-HX7Y2ASG.js → chunk-VCGQMTHW.js} +26318 -15143
  63. package/dist/bundle/{chunk-7YMDL4JQ.js → chunk-VKYCMXEQ.js} +8 -5
  64. package/dist/bundle/{chunk-ZSXRDF6I.js → chunk-VX4RAT3A.js} +1 -1
  65. package/dist/bundle/{chunk-NYOPEHEU.js → chunk-W5SYBHRX.js} +8 -3
  66. package/dist/bundle/{chunk-XOLQSCMF.js → chunk-WGSTTWM5.js} +6 -6
  67. package/dist/bundle/{chunk-WLFUBNFX.js → chunk-WJRE45Z6.js} +4 -4
  68. package/dist/bundle/{chunk-IEXPOEEO.js → chunk-WQPTZHHR.js} +17 -26
  69. package/dist/bundle/{chunk-JEOYFKUK.js → chunk-WSX5UQNT.js} +2 -2
  70. package/dist/bundle/{chunk-LJAX6YCF.js → chunk-WYDYSQ7T.js} +2 -2
  71. package/dist/bundle/{chunk-C6Z25IBJ.js → chunk-XCUUYQN7.js} +4 -4
  72. package/dist/bundle/{chunk-GVCN3GLZ.js → chunk-YOHOQ6ZR.js} +4 -4
  73. package/dist/bundle/chunk-YZ5VMR2S.js +5305 -0
  74. package/dist/bundle/{chunk-ZDLIO76S.js → chunk-ZMMOVTUB.js} +2 -2
  75. package/dist/bundle/command-contract-VZ3ZJLEF.js +35 -0
  76. package/dist/bundle/{decode-EDN2ARXZ.js → decode-DN2DDFET.js} +4 -4
  77. package/dist/bundle/drive.js +11 -22
  78. package/dist/bundle/{echarts-GXY34GHA.js → echarts-VMHZ2UYP.js} +2 -2
  79. package/dist/bundle/{embed-3GSQIQXE.js → embed-MDN7R7BA.js} +5 -5
  80. package/dist/bundle/{embedder-6ULWRG3R.js → embedder-KEVEDNDJ.js} +8 -8
  81. package/dist/bundle/{entry-IPRJLFHO.js → entry-HTNK5TJQ.js} +6 -6
  82. package/dist/bundle/{first-run-FGHGWHC2.js → first-run-QNMCMP67.js} +9 -9
  83. package/dist/bundle/first-screen-RQBEHUQC.js +33 -0
  84. package/dist/bundle/{google-BD3ZNFVJ.js → google-QAKMV57Q.js} +9 -9
  85. package/dist/bundle/{chunk-GR5GGZKH.js → google-api-UJJS7ECO.js} +62 -6
  86. package/dist/bundle/grants-VMPKFEC2.js +98 -0
  87. package/dist/bundle/{identity-U7IHZEMR.js → identity-UODE3QAL.js} +4 -2
  88. package/dist/bundle/{instructions-K5BEQM4C.js → instructions-IWLHCDC7.js} +1 -1
  89. package/dist/bundle/{login-7HRYPZMM.js → login-GIZXEN7I.js} +60 -68
  90. package/dist/bundle/{mcp-WSGVVZWI.js → mcp-RUYPQVYS.js} +2 -2
  91. package/dist/bundle/{node-ZYWB7IET.js → node-25IJLDBZ.js} +2 -2
  92. package/dist/bundle/{node-sqlite-J3OODPYK.js → node-sqlite-DYR4FEI4.js} +4 -4
  93. package/dist/bundle/{oauth-L4VTCBLF.js → oauth-FLHXEDDY.js} +7 -7
  94. package/dist/bundle/{open-SGUN7ZVF.js → open-FWDZB7KX.js} +3 -3
  95. package/dist/bundle/{openai-RLVISEDH.js → openai-HB7UGKPW.js} +13 -13
  96. package/dist/bundle/{process-ZXO2MWRJ.js → process-P6TW37HQ.js} +1 -1
  97. package/dist/bundle/{program-YVLXSKZV.js → program-DVUNLXXS.js} +730 -919
  98. package/dist/bundle/{prompt-AUWTBLO7.js → prompt-MKWMYO3B.js} +4 -4
  99. package/dist/bundle/{reasons-J57GSRWN.js → reasons-25BEO2NE.js} +3 -3
  100. package/dist/bundle/{recognize-ORX2UBQW.js → recognize-VXGNPROM.js} +3 -3
  101. package/dist/bundle/{remote-AGIJY73X.js → remote-H5ZWLJHR.js} +6 -6
  102. package/dist/bundle/{rerank-R6PE44M5.js → rerank-5A3JDK7O.js} +6 -6
  103. package/dist/bundle/{chunk-G7DCVJ4F.js → serve-QNPNEZVR.js} +10 -7
  104. package/dist/bundle/{chunk-F7UUZATI.js → server-GWBVIRLY.js} +42 -15
  105. package/dist/bundle/server-QJU3HEGM.js +63 -0
  106. package/dist/bundle/{services-HZFTTZSF.js → services-PFXEWHJG.js} +30 -31
  107. package/dist/bundle/{sqlite-runtime-DTGPR2T2.js → sqlite-runtime-RGFISYXM.js} +4 -4
  108. package/dist/bundle/{state-WG3JKJM3.js → state-BUSX5BXF.js} +5 -5
  109. package/dist/bundle/{store-EV72MT5U.js → store-FIEE5HHG.js} +14 -16
  110. package/dist/bundle/{store-33VHIMEO.js → store-HFF5KQ44.js} +12 -14
  111. package/dist/bundle/store-maintenance-command-Z4SPEQUM.js +52 -0
  112. package/dist/bundle/{chunk-GNI7INK6.js → terminal-DHJ4D3BC.js} +2 -3
  113. package/dist/bundle/tokens-B6MUZRFM.js +96 -0
  114. package/dist/commands/context.d.ts +14 -13
  115. package/dist/commands/context.d.ts.map +1 -1
  116. package/dist/commands/context.js.map +1 -1
  117. package/dist/commands/documents.d.ts.map +1 -1
  118. package/dist/commands/documents.js +1 -4
  119. package/dist/commands/documents.js.map +1 -1
  120. package/dist/commands/mirrors.d.ts.map +1 -1
  121. package/dist/commands/mirrors.js +1 -2
  122. package/dist/commands/mirrors.js.map +1 -1
  123. package/dist/commands/upgrade.d.ts +1 -1
  124. package/dist/commands/upgrade.d.ts.map +1 -1
  125. package/dist/commands/upgrade.js +4 -9
  126. package/dist/commands/upgrade.js.map +1 -1
  127. package/dist/config.d.ts +182 -0
  128. package/dist/config.d.ts.map +1 -1
  129. package/dist/config.js +38 -3
  130. package/dist/config.js.map +1 -1
  131. package/dist/contract-overrides.d.ts +0 -3
  132. package/dist/contract-overrides.d.ts.map +1 -1
  133. package/dist/contract-overrides.js +0 -234
  134. package/dist/contract-overrides.js.map +1 -1
  135. package/dist/first-screen.d.ts +3 -2
  136. package/dist/first-screen.d.ts.map +1 -1
  137. package/dist/first-screen.js +17 -22
  138. package/dist/first-screen.js.map +1 -1
  139. package/dist/grants.d.ts +9 -0
  140. package/dist/grants.d.ts.map +1 -0
  141. package/dist/grants.js +30 -0
  142. package/dist/grants.js.map +1 -0
  143. package/dist/identity.d.ts.map +1 -1
  144. package/dist/identity.js +2 -0
  145. package/dist/identity.js.map +1 -1
  146. package/dist/login.d.ts.map +1 -1
  147. package/dist/login.js +2 -4
  148. package/dist/login.js.map +1 -1
  149. package/dist/policy-keys.d.ts +12 -0
  150. package/dist/policy-keys.d.ts.map +1 -0
  151. package/dist/policy-keys.js +107 -0
  152. package/dist/policy-keys.js.map +1 -0
  153. package/dist/policy.d.ts +1 -8
  154. package/dist/policy.d.ts.map +1 -1
  155. package/dist/policy.js +2 -105
  156. package/dist/policy.js.map +1 -1
  157. package/dist/program.d.ts +8 -4
  158. package/dist/program.d.ts.map +1 -1
  159. package/dist/program.js +251 -222
  160. package/dist/program.js.map +1 -1
  161. package/dist/testing/mcp.d.ts +28 -0
  162. package/dist/testing/mcp.d.ts.map +1 -0
  163. package/dist/testing/mcp.js +56 -0
  164. package/dist/testing/mcp.js.map +1 -0
  165. package/dist/tokens.d.ts.map +1 -1
  166. package/dist/tokens.js +0 -9
  167. package/dist/tokens.js.map +1 -1
  168. package/dist/version.d.ts +1 -1
  169. package/dist/version.js +1 -1
  170. package/package.json +6 -5
  171. package/scenarios/agent-access.md +4 -2
  172. package/dist/bundle/all-profiles-CYW6XBBS.js +0 -26
  173. package/dist/bundle/chunk-234MHU76.js +0 -384
  174. package/dist/bundle/chunk-BBYD2FA3.js +0 -9
  175. package/dist/bundle/chunk-DO4PDQY5.js +0 -48
  176. package/dist/bundle/chunk-FDWYPONW.js +0 -1988
  177. package/dist/bundle/chunk-FQRJWVEB.js +0 -2
  178. package/dist/bundle/chunk-GJN5B5JK.js +0 -522
  179. package/dist/bundle/chunk-NPSZPUK6.js +0 -193
  180. package/dist/bundle/chunk-PDGECM5D.js +0 -138
  181. package/dist/bundle/chunk-Q765VPZY.js +0 -421
  182. package/dist/bundle/chunk-QYUHS6DE.js +0 -1714
  183. package/dist/bundle/chunk-WQRGA75U.js +0 -256
  184. package/dist/bundle/chunk-YVPHJHIL.js +0 -15572
  185. package/dist/bundle/chunk-Z47LOJUS.js +0 -484
  186. package/dist/bundle/command-contract-I2YB5IXI.js +0 -38
  187. package/dist/bundle/failure-IXS2ZHA5.js +0 -37
  188. package/dist/bundle/first-screen-M62KTPZG.js +0 -36
  189. package/dist/bundle/google-api-BDUWZMRV.js +0 -83
  190. package/dist/bundle/mcp-F67RATLF.js +0 -502
  191. package/dist/bundle/mcp-JZSYPQA4.js +0 -96
  192. package/dist/bundle/serve-VOBAQHAQ.js +0 -20
  193. package/dist/bundle/server-24PS4M7U.js +0 -70
  194. package/dist/bundle/server-G6HFZ2CK.js +0 -57
  195. package/dist/bundle/store-maintenance-command-ZTUEI4EC.js +0 -58
  196. package/dist/bundle/terminal-TFCTWLOS.js +0 -11
  197. package/dist/bundle/tokens-XMOGQFI6.js +0 -102
  198. package/dist/commands/doctor.d.ts +0 -56
  199. package/dist/commands/doctor.d.ts.map +0 -1
  200. package/dist/commands/doctor.js +0 -75
  201. package/dist/commands/doctor.js.map +0 -1
  202. package/dist/commands/mcp.d.ts +0 -6
  203. package/dist/commands/mcp.d.ts.map +0 -1
  204. package/dist/commands/mcp.js +0 -156
  205. package/dist/commands/mcp.js.map +0 -1
  206. package/dist/commands/skill.d.ts +0 -6
  207. package/dist/commands/skill.d.ts.map +0 -1
  208. package/dist/commands/skill.js +0 -34
  209. package/dist/commands/skill.js.map +0 -1
  210. package/dist/failure.d.ts +0 -88
  211. package/dist/failure.d.ts.map +0 -1
  212. package/dist/failure.js +0 -60
  213. package/dist/failure.js.map +0 -1
  214. package/dist/mcp.d.ts +0 -175
  215. package/dist/mcp.d.ts.map +0 -1
  216. package/dist/mcp.js +0 -412
  217. package/dist/mcp.js.map +0 -1
  218. /package/dist/bundle/{chunk-62EDJKGP.js → chunk-HEA3XVAJ.js} +0 -0
@@ -1,13 +1,5 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
- import {
4
- classify,
5
- documentExtractor,
6
- documentKind,
7
- engineMissing,
8
- extractText,
9
- importEngine
10
- } from "./chunk-WUX7AUOQ.js";
11
3
  import {
12
4
  acquireLock,
13
5
  openOrdinaryFile,
@@ -15,27 +7,20 @@ import {
15
7
  sameOrdinaryFile,
16
8
  syncDirectory,
17
9
  writeFileAtomic
18
- } from "./chunk-7SH4JHYW.js";
10
+ } from "./chunk-A4FTLORC.js";
19
11
  import {
20
- MAX_ACTIONS,
21
- ModerationRules,
22
- act,
23
- defaultRules,
24
- gather,
25
- isId,
26
- judge,
27
- moderationPathFor,
28
- nextPoint,
29
- pickChat,
30
- pickPerson,
31
- someUndone,
32
- validateFormattedText,
33
- visibleFormattedText
34
- } from "./chunk-Z47LOJUS.js";
12
+ classify,
13
+ documentExtractor,
14
+ documentKind,
15
+ engineMissing,
16
+ extractText,
17
+ importEngine
18
+ } from "./chunk-6RAEXK7Y.js";
35
19
  import {
36
20
  DEFAULT_IMAGE_MODEL,
37
21
  DEFAULT_RERANK_MODEL,
38
22
  DEFAULT_TEXT_MODEL,
23
+ LEVELS,
39
24
  LINK,
40
25
  WEIGHTS,
41
26
  agenda,
@@ -58,23 +43,23 @@ import {
58
43
  typedCommand,
59
44
  vectorModelKey,
60
45
  withAttempt
61
- } from "./chunk-LONV6HIK.js";
46
+ } from "./chunk-HAHARAJD.js";
62
47
  import {
63
48
  isCliFailure
64
- } from "./chunk-VSOLLTYT.js";
49
+ } from "./chunk-76JIVDKC.js";
65
50
  import {
66
51
  isNewer,
67
52
  updateCommand
68
- } from "./chunk-7YMDL4JQ.js";
53
+ } from "./chunk-VKYCMXEQ.js";
69
54
  import {
70
55
  MAX_MODEL_IMAGE_BYTES
71
- } from "./chunk-VZ2I62HN.js";
56
+ } from "./chunk-5LNOVPOR.js";
72
57
  import {
73
58
  OPENAI_URL,
74
59
  openRemote,
75
60
  remoteKey,
76
61
  remoteModel
77
- } from "./chunk-2UIMEMWU.js";
62
+ } from "./chunk-2HQPJ366.js";
78
63
  import {
79
64
  defaultThreads,
80
65
  installNativeRuntime,
@@ -83,11 +68,11 @@ import {
83
68
  placedText,
84
69
  runEmbedders,
85
70
  textModelsDirectory
86
- } from "./chunk-CM7GAXGD.js";
71
+ } from "./chunk-2CQT2WWN.js";
87
72
  import {
88
73
  installFiles,
89
74
  megabytes
90
- } from "./chunk-BSSCTWWK.js";
75
+ } from "./chunk-6SOQJRGI.js";
91
76
  import {
92
77
  AGENDA_COLUMNS,
93
78
  CHAT_COLUMNS,
@@ -95,17 +80,21 @@ import {
95
80
  CHUNK_CHARS,
96
81
  CONTEXT_MAX_READ_BYTES,
97
82
  CONVERSATION_COLUMNS,
83
+ COUNTER_FIELDS,
98
84
  EVIDENCE_FINDINGS_KIND,
99
85
  FIELD_VERSION,
86
+ INTERNAL_NOTES,
100
87
  MENTION_QUERY,
101
88
  MESSAGE_PARSING,
102
89
  NOT_FILES,
103
90
  PRESET_VERSION,
104
91
  QUERY_LIMITS,
105
92
  QUERY_VERSION,
93
+ RANKING_TOKENIZER_VERSION,
106
94
  SEARCH_QUERY,
107
95
  TASK_RELATION_KINDS,
108
96
  TRACKED_CHAT_COLUMNS,
97
+ UNKNOWN_PROVIDER,
109
98
  attachmentColumns,
110
99
  calendarKey,
111
100
  calendarMoment,
@@ -116,12 +105,16 @@ import {
116
105
  contextEvidenceRequest,
117
106
  contextSource,
118
107
  correctWords,
108
+ counterFreshness,
109
+ counterObservationTime,
119
110
  cutChunks,
120
111
  entriesOfList,
121
112
  exhausted,
122
113
  fetchedKey,
123
114
  findMentions,
124
115
  fitting,
116
+ formatLocator,
117
+ formatReference,
125
118
  googleDocumentId,
126
119
  googleDocumentLinks,
127
120
  hasStems,
@@ -130,52 +123,40 @@ import {
130
123
  inSource,
131
124
  inboxKey,
132
125
  isAccountList,
126
+ isFolderProvider,
127
+ isKind,
128
+ isLocator,
133
129
  isStemmed,
130
+ kindIn,
131
+ kindOf,
134
132
  matchDownloads,
135
133
  messageOfEmail,
136
134
  normalizeVocabularyName,
135
+ parseLocator,
136
+ parseReference,
137
+ providerNamed,
137
138
  queryFilter,
138
139
  rankingContextRange,
140
+ rankingOptions,
139
141
  searchError,
140
142
  sourceOf,
141
143
  threadConversation,
142
144
  validateAst,
143
145
  validateFields
144
- } from "./chunk-WQJBAWQP.js";
146
+ } from "./chunk-SBOTSSYV.js";
145
147
  import {
146
148
  MAX_TEXT_CHARS,
147
149
  attachmentMaxBytes,
148
150
  pdfPreviewLimits
149
- } from "./chunk-JEOYFKUK.js";
150
- import {
151
- COUNTER_FIELDS,
152
- INTERNAL_NOTES,
153
- RANKING_TOKENIZER_VERSION,
154
- UNKNOWN_PROVIDER,
155
- counterFreshness,
156
- counterObservationTime,
157
- formatLocator,
158
- formatReference,
159
- isFolderProvider,
160
- isKind,
161
- isLocator,
162
- kindIn,
163
- kindOf,
164
- parseLocator,
165
- parseReference,
166
- providerNamed,
167
- rankingOptions
168
- } from "./chunk-234MHU76.js";
151
+ } from "./chunk-WSX5UQNT.js";
169
152
  import {
153
+ MEETING_FINDINGS_KIND,
170
154
  TASK_KINDS,
171
155
  TASK_ORIGINS,
172
156
  TASK_STATES,
173
- createTaskService
174
- } from "./chunk-PDGECM5D.js";
175
- import {
176
- MEETING_FINDINGS_KIND,
177
157
  canonicalMeetingReference,
178
158
  createMeetingContext,
159
+ createTaskService,
179
160
  formatMeetingReference,
180
161
  liftMeetingFields,
181
162
  meetingCueFingerprint,
@@ -190,7 +171,7 @@ import {
190
171
  validateMeetingHitSearch,
191
172
  validateMeetingPassage,
192
173
  validateMeetingSeriesHistory
193
- } from "./chunk-ZNZUZGSV.js";
174
+ } from "./chunk-PKNTBZXN.js";
194
175
  import {
195
176
  dateRange,
196
177
  implicitTextTerms,
@@ -200,46 +181,93 @@ import {
200
181
  timezoneOf,
201
182
  validateQuery,
202
183
  walkQuery
203
- } from "./chunk-NHBUTCNR.js";
184
+ } from "./chunk-LQXLWHKM.js";
204
185
  import {
205
186
  DEFAULT_STEMMERS,
206
187
  createStemmer,
207
188
  fold,
208
189
  normalize
209
- } from "./chunk-7XKAVMCF.js";
190
+ } from "./chunk-2MSJVFAS.js";
210
191
  import {
211
192
  DEFAULT_TASK_CATEGORIES,
212
193
  FALLBACK_CATEGORY
213
- } from "./chunk-XOLQSCMF.js";
194
+ } from "./chunk-WGSTTWM5.js";
214
195
  import {
215
196
  storePath,
216
197
  wirecatDirectory
217
- } from "./chunk-VJZST5RD.js";
198
+ } from "./chunk-UBJX5D2O.js";
218
199
  import {
219
200
  resolvePaths,
220
- singleLine
221
- } from "./chunk-HQVJK5E7.js";
201
+ singleLine,
202
+ visibleControls,
203
+ writeSecurely
204
+ } from "./chunk-2D6AAGBP.js";
222
205
  import {
223
206
  CliError,
224
207
  array,
208
+ getDotPath,
209
+ integer,
225
210
  isCliError,
226
211
  maxLength,
227
212
  minLength,
228
213
  minValue,
214
+ nullable,
229
215
  number,
230
216
  optional,
217
+ picklist,
231
218
  pipe,
219
+ record,
232
220
  regex,
233
221
  safeInteger,
234
222
  safeParse,
235
223
  strictObject,
236
- string
237
- } from "./chunk-YKZ4IPLB.js";
224
+ string,
225
+ transform,
226
+ unknown
227
+ } from "./chunk-JKEAZBEZ.js";
238
228
  import {
239
229
  __name
240
230
  } from "./chunk-ZVVMGPBJ.js";
241
231
 
242
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/deps.js
232
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/resolve.js
233
+ var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
234
+ var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase(), "foldName");
235
+ var pickChat = /* @__PURE__ */ __name((reference, chats) => {
236
+ const wanted = foldName(reference.trim());
237
+ const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
238
+ if (matches.length === 1 && matches[0])
239
+ return matches[0];
240
+ if (matches.length === 0)
241
+ throw new CliError("not_found", `no chat matches "${reference}"`);
242
+ throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
243
+ }, "pickChat");
244
+ var pickPerson = /* @__PURE__ */ __name((reference, people) => {
245
+ const trimmed = reference.trim();
246
+ const known2 = people.get(trimmed);
247
+ if (known2)
248
+ return known2;
249
+ if (isId(trimmed))
250
+ throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
251
+ const wanted = foldName(trimmed.replace(/^@/, ""));
252
+ const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
253
+ const fields = /* @__PURE__ */ __name((person) => [person.alias, person.name, person.username].filter(isPresent).map(foldName), "fields");
254
+ const exact = everyone.filter((person) => fields(person).includes(wanted));
255
+ const matches = exact.length > 0 ? exact : everyone.filter((person) => fields(person).some((one) => one.includes(wanted)));
256
+ if (matches.length === 1 && matches[0])
257
+ return matches[0];
258
+ if (matches.length === 0)
259
+ throw new CliError("not_found", `nobody matches "${reference}"`);
260
+ throw ambiguous(reference, "people", matches.map(({ id: id2, name, username }) => ({ id: id2, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
261
+ }, "pickPerson");
262
+ var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label) => {
263
+ const width = Math.max(...candidates.map(({ id: id2 }) => id2.length));
264
+ const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label(candidate)}`).join("\n");
265
+ return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
266
+ ${lines}`, { candidates });
267
+ }, "ambiguous");
268
+ var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
269
+
270
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/deps.js
243
271
  var accountStore = /* @__PURE__ */ __name(async (deps) => (await deps.store()).forAccount(await deps.account()), "accountStore");
244
272
  var crossAccount = /* @__PURE__ */ __name((deps, _reason) => deps.store(), "crossAccount");
245
273
  var NO_LOCAL_STORE = "this answer comes from the messenger, not from the local store";
@@ -317,7 +345,7 @@ var storeOnlyDeps = /* @__PURE__ */ __name((store, account2, { app, env }) => {
317
345
  return { ...storedDeps(messenger, store, account2, guard), ...env === void 0 ? {} : { env } };
318
346
  }, "storeOnlyDeps");
319
347
 
320
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/botcheck/check.js
348
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/botcheck/check.js
321
349
  var DAY_MS = 864e5;
322
350
  var NEW_DAYS = 30;
323
351
  var SAME_TEXT_MIN = 20;
@@ -334,19 +362,19 @@ var repeated = /* @__PURE__ */ __name((messages) => {
334
362
  }, "repeated");
335
363
  var scorePerson = /* @__PURE__ */ __name(({ subject, provider, activity, photos, registries, now = /* @__PURE__ */ new Date() }) => {
336
364
  const reasons = [];
337
- const unknown = [];
365
+ const unknown2 = [];
338
366
  const add = /* @__PURE__ */ __name((reason, source, detail) => reasons.push({ reason, weight: WEIGHTS[reason], source, ...detail ? { detail } : {} }), "add");
339
367
  const young = /* @__PURE__ */ __name((at) => now.getTime() - Date.parse(at) < NEW_DAYS * DAY_MS, "young");
340
368
  const { flags } = subject;
341
369
  for (const flag of ["bot", "scam", "fake", "deleted"]) {
342
370
  if (flags?.[flag] === void 0)
343
- unknown.push(flag);
371
+ unknown2.push(flag);
344
372
  else if (flags[flag])
345
373
  add(flag, "messenger");
346
374
  }
347
375
  const withPhoto = subject.hasPhoto ?? (photos ? photos.count > 0 : void 0);
348
376
  if (withPhoto === void 0)
349
- unknown.push("no_photo");
377
+ unknown2.push("no_photo");
350
378
  else if (!withPhoto)
351
379
  add("no_photo", "messenger");
352
380
  if (subject.usernames.length === 0)
@@ -354,26 +382,26 @@ var scorePerson = /* @__PURE__ */ __name(({ subject, provider, activity, photos,
354
382
  if (oddName(subject.name))
355
383
  add("odd_name", "messenger");
356
384
  if (subject.bio === void 0)
357
- unknown.push("no_bio");
385
+ unknown2.push("no_bio");
358
386
  else if (!subject.bio?.trim())
359
387
  add("no_bio", "messenger");
360
388
  if (subject.registered === void 0 || subject.registered === null)
361
- unknown.push("new_account");
389
+ unknown2.push("new_account");
362
390
  else if (young(subject.registered.at))
363
391
  add("new_account", subject.registered.source, subject.registered.at);
364
392
  if (photos === void 0)
365
- unknown.push("photo_recent");
393
+ unknown2.push("photo_recent");
366
394
  else if (photos.oldestAt && young(photos.oldestAt))
367
395
  add("photo_recent", "messenger", photos.oldestAt);
368
396
  if (activity === void 0 || activity.chatsStored === 0)
369
- unknown.push("never_wrote", "link_first", "same_text");
397
+ unknown2.push("never_wrote", "link_first", "same_text");
370
398
  else {
371
399
  const { messages, complete } = activity;
372
400
  if (messages.length === 0)
373
401
  add("never_wrote", "store");
374
402
  const first = complete ? messages.at(-1) : void 0;
375
403
  if (!complete)
376
- unknown.push("link_first");
404
+ unknown2.push("link_first");
377
405
  else if (first && (first.forwardedFrom !== null || LINK.test(first.text)))
378
406
  add("link_first", "store");
379
407
  const chats = repeated(messages);
@@ -389,12 +417,12 @@ var scorePerson = /* @__PURE__ */ __name(({ subject, provider, activity, photos,
389
417
  score: reasons.reduce((total, { weight }) => total + weight, 0),
390
418
  reasons: reasons.sort((a, b) => b.weight - a.weight),
391
419
  registries,
392
- unknown,
420
+ unknown: unknown2,
393
421
  checkedAt: now.toISOString()
394
422
  };
395
423
  }, "scorePerson");
396
424
 
397
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/botcheck/registries.js
425
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/botcheck/registries.js
398
426
  var REGISTRIES = {
399
427
  cas: { title: "Combot Anti-Spam (CAS)", docs: "https://cas.chat/api" },
400
428
  lols: { title: "lols.bot", docs: "https://api.lols.bot/lols-bot.json" }
@@ -424,16 +452,16 @@ var isObject = /* @__PURE__ */ __name((value) => typeof value === "object" && va
424
452
  var askCas = /* @__PURE__ */ __name(async (id2, options = {}) => {
425
453
  const checkedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
426
454
  const got = await getJson(`https://api.cas.chat/check?user_id=${encodeURIComponent(id2)}`, options.casKey ? { authorization: `Bearer ${options.casKey}` } : {}, options);
427
- const unknown = /* @__PURE__ */ __name((detail) => ({ name: "cas", answer: "unknown", checkedAt, detail }), "unknown");
455
+ const unknown2 = /* @__PURE__ */ __name((detail) => ({ name: "cas", answer: "unknown", checkedAt, detail }), "unknown");
428
456
  if ("failed" in got)
429
- return unknown(got.failed);
457
+ return unknown2(got.failed);
430
458
  if (got.status === 401)
431
- return unknown(options.casKey ? "refused the key" : "now asks for a key from combot.org");
459
+ return unknown2(options.casKey ? "refused the key" : "now asks for a key from combot.org");
432
460
  const { body } = got;
433
461
  if (!isObject(body) || typeof body.ok !== "boolean")
434
- return unknown("answered in an unexpected shape");
462
+ return unknown2("answered in an unexpected shape");
435
463
  if (!body.ok) {
436
- return body.description === "Record not found." ? { name: "cas", answer: "clean", checkedAt } : unknown(typeof body.description === "string" ? body.description : "refused");
464
+ return body.description === "Record not found." ? { name: "cas", answer: "clean", checkedAt } : unknown2(typeof body.description === "string" ? body.description : "refused");
437
465
  }
438
466
  const result = isObject(body.result) ? body.result : {};
439
467
  const offenses = typeof result.offenses === "number" ? result.offenses : void 0;
@@ -449,12 +477,12 @@ var askCas = /* @__PURE__ */ __name(async (id2, options = {}) => {
449
477
  var askLols = /* @__PURE__ */ __name(async (id2, options = {}) => {
450
478
  const checkedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
451
479
  const got = await getJson(`https://api.lols.bot/account?id=${encodeURIComponent(id2)}`, {}, options);
452
- const unknown = /* @__PURE__ */ __name((detail) => ({ name: "lols", answer: "unknown", checkedAt, detail }), "unknown");
480
+ const unknown2 = /* @__PURE__ */ __name((detail) => ({ name: "lols", answer: "unknown", checkedAt, detail }), "unknown");
453
481
  if ("failed" in got)
454
- return unknown(got.failed);
482
+ return unknown2(got.failed);
455
483
  const { body } = got;
456
484
  if (got.status !== 200 || !isObject(body) || body.ok !== true || typeof body.banned !== "boolean") {
457
- return unknown(`answered ${got.status} in an unexpected shape`);
485
+ return unknown2(`answered ${got.status} in an unexpected shape`);
458
486
  }
459
487
  const reasons = [
460
488
  ...body.banned ? ["lols_banned"] : [],
@@ -479,7 +507,7 @@ var notCovered = /* @__PURE__ */ __name((messenger, now = /* @__PURE__ */ new Da
479
507
  detail: `lists Telegram accounts only, not ${messenger} ones`
480
508
  })), "notCovered");
481
509
 
482
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/botcheck/service.js
510
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/botcheck/service.js
483
511
  var ACTIVITY_MESSAGES = 1e3;
484
512
  var botCheckService = /* @__PURE__ */ __name((deps) => {
485
513
  const subjectOf = /* @__PURE__ */ __name(async (reference) => {
@@ -567,7 +595,7 @@ var botCheckService = /* @__PURE__ */ __name((deps) => {
567
595
  };
568
596
  }, "botCheckService");
569
597
 
570
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/chat-coverage.js
598
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/chat-coverage.js
571
599
  var chatCoverage = /* @__PURE__ */ __name(async (store, account2, chatIds) => {
572
600
  const ids = [...new Set(chatIds)];
573
601
  if (ids.length === 0)
@@ -593,7 +621,7 @@ var chatCoverage = /* @__PURE__ */ __name(async (store, account2, chatIds) => {
593
621
  }));
594
622
  }, "chatCoverage");
595
623
 
596
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/context/evidence-response.js
624
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/context/evidence-response.js
597
625
  var contextSourceKey = /* @__PURE__ */ __name((source) => JSON.stringify([source.kind, source.accountId, source.provider, source.account]), "contextSourceKey");
598
626
  var validateContextEvidencePage = /* @__PURE__ */ __name((page, request) => {
599
627
  const fail3 = /* @__PURE__ */ __name(() => {
@@ -657,7 +685,7 @@ var validateContextEvidencePage = /* @__PURE__ */ __name((page, request) => {
657
685
  }
658
686
  }, "validateContextEvidencePage");
659
687
 
660
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/context/read-budget.js
688
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/context/read-budget.js
661
689
  var contextReadBudget = /* @__PURE__ */ __name((limits = {}) => {
662
690
  if (!limits || typeof limits !== "object" || Array.isArray(limits))
663
691
  throw new CliError("validation_error", "limits needs a context read allowance");
@@ -710,7 +738,7 @@ var contextReadBudget = /* @__PURE__ */ __name((limits = {}) => {
710
738
  };
711
739
  }, "contextReadBudget");
712
740
 
713
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/context-evidence.js
741
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/context-evidence.js
714
742
  var createContextEvidenceReader = /* @__PURE__ */ __name((port, allowed, limits) => {
715
743
  if (!port || typeof port.read !== "function")
716
744
  throw new CliError("configuration_error", "context evidence reader is unavailable");
@@ -754,7 +782,7 @@ var createContextEvidenceReader = /* @__PURE__ */ __name((port, allowed, limits)
754
782
  };
755
783
  }, "createContextEvidenceReader");
756
784
 
757
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/excerpt.js
785
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/excerpt.js
758
786
  var queryWords = /* @__PURE__ */ __name((query) => query.toLowerCase().split(/\s+/).map((word) => word.replace(/^[\p{L}_]+:/u, "").replace(/~\d+$/u, "").replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, "")).filter((word) => word.length > 2 && !["and", "or", "not"].includes(word)), "queryWords");
759
787
  var excerpt = /* @__PURE__ */ __name((text2, query, size4 = 240, options = {}) => {
760
788
  const flat = text2.replace(/\s+/g, " ").trim();
@@ -770,23 +798,23 @@ var excerpt = /* @__PURE__ */ __name((text2, query, size4 = 240, options = {}) =
770
798
  }, "excerpt");
771
799
  var withExcerpt = /* @__PURE__ */ __name(({ matchedText, ...hit }, query) => ({ ...hit, excerpt: excerpt(matchedText ?? hit.text, query) }), "withExcerpt");
772
800
 
773
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive.js
801
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive.js
774
802
  import { setTimeout as sleep } from "node:timers/promises";
775
803
 
776
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive-files.js
804
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive-files.js
777
805
  import { lstat } from "node:fs/promises";
778
806
 
779
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-store.js
807
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-store.js
780
808
  import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
781
809
  import { open as open2, rename as rename2, unlink as unlink2 } from "node:fs/promises";
782
810
  import { join as join2 } from "node:path";
783
811
 
784
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-metadata.js
812
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-metadata.js
785
813
  import { createHash } from "node:crypto";
786
814
  var metadataLimit = 16384;
787
815
  var partialIdentity = /* @__PURE__ */ __name((locator) => JSON.stringify([locator.provider, locator.account, locator.occurrenceId, locator.assetId]), "partialIdentity");
788
816
  var missing = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT", "missing");
789
- var fingerprintPartial = /* @__PURE__ */ __name(async (file, signal, length) => {
817
+ var fingerprintPartial = /* @__PURE__ */ __name(async (file2, signal, length) => {
790
818
  const hash3 = createHash("sha256");
791
819
  let size4 = 0;
792
820
  const buffer = Buffer.alloc(65536);
@@ -795,7 +823,7 @@ var fingerprintPartial = /* @__PURE__ */ __name(async (file, signal, length) =>
795
823
  const wanted = length === void 0 ? buffer.length : Math.min(buffer.length, length - size4);
796
824
  if (wanted === 0)
797
825
  break;
798
- const count2 = (await file.read(buffer, 0, wanted, size4)).bytesRead;
826
+ const count2 = (await file2.read(buffer, 0, wanted, size4)).bytesRead;
799
827
  signal?.throwIfAborted();
800
828
  if (count2 === 0)
801
829
  break;
@@ -805,9 +833,9 @@ var fingerprintPartial = /* @__PURE__ */ __name(async (file, signal, length) =>
805
833
  return { offset: size4, sha256: hash3.copy().digest("hex"), hash: hash3 };
806
834
  }, "fingerprintPartial");
807
835
  var readPartialMetadata = /* @__PURE__ */ __name(async (path, locator, maxBytes, signal) => {
808
- let file;
836
+ let file2;
809
837
  try {
810
- file = await openOrdinaryFile(path);
838
+ file2 = await openOrdinaryFile(path);
811
839
  } catch (error) {
812
840
  if (missing(error))
813
841
  return null;
@@ -815,13 +843,13 @@ var readPartialMetadata = /* @__PURE__ */ __name(async (path, locator, maxBytes,
815
843
  }
816
844
  try {
817
845
  signal?.throwIfAborted();
818
- if ((await file.stat()).size > metadataLimit)
846
+ if ((await file2.stat()).size > metadataLimit)
819
847
  throw new Error("metadata limit");
820
848
  const bytes2 = Buffer.alloc(metadataLimit + 1);
821
849
  let size4 = 0;
822
850
  while (size4 < bytes2.length) {
823
851
  signal?.throwIfAborted();
824
- const count2 = (await file.read(bytes2, size4, bytes2.length - size4, size4)).bytesRead;
852
+ const count2 = (await file2.read(bytes2, size4, bytes2.length - size4, size4)).bytesRead;
825
853
  if (!count2)
826
854
  break;
827
855
  size4 += count2;
@@ -837,17 +865,17 @@ var readPartialMetadata = /* @__PURE__ */ __name(async (path, locator, maxBytes,
837
865
  signal?.throwIfAborted();
838
866
  throw new CliError("validation_error", "recording partial metadata is invalid");
839
867
  } finally {
840
- await file.close();
868
+ await file2.close();
841
869
  }
842
870
  }, "readPartialMetadata");
843
871
 
844
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-writer.js
872
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-writer.js
845
873
  import { randomUUID } from "node:crypto";
846
874
  import { open, rename, unlink } from "node:fs/promises";
847
875
  import { join } from "node:path";
848
876
  var partialWriter = /* @__PURE__ */ __name(async (input) => {
849
- const { file, signal, partial } = input;
850
- const owned = await file.stat({ bigint: true });
877
+ const { file: file2, signal, partial } = input;
878
+ const owned = await file2.stat({ bigint: true });
851
879
  let size4 = input.fingerprint.offset;
852
880
  const hash3 = input.fingerprint.hash;
853
881
  let closed = false;
@@ -861,7 +889,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
861
889
  }, "usable");
862
890
  const checkpoint = /* @__PURE__ */ __name(async () => {
863
891
  await usable();
864
- await file.sync();
892
+ await file2.sync();
865
893
  if (!partial.validator || !input.persistent) {
866
894
  await syncDirectory(input.root);
867
895
  signal?.throwIfAborted();
@@ -899,7 +927,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
899
927
  try {
900
928
  while (offset < bytes2.length) {
901
929
  signal?.throwIfAborted();
902
- const written = (await file.write(bytes2, offset, bytes2.length - offset, size4 + offset)).bytesWritten;
930
+ const written = (await file2.write(bytes2, offset, bytes2.length - offset, size4 + offset)).bytesWritten;
903
931
  if (written === 0)
904
932
  throw new CliError("configuration_error", "recording partial write did not progress");
905
933
  offset += written;
@@ -924,7 +952,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
924
952
  return;
925
953
  closed = true;
926
954
  try {
927
- await file.close();
955
+ await file2.close();
928
956
  } catch (error) {
929
957
  input.complete(null);
930
958
  throw error;
@@ -933,7 +961,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
933
961
  };
934
962
  }, "partialWriter");
935
963
 
936
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-store.js
964
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-partial-store.js
937
965
  var NativeRecordingPartialStore = class {
938
966
  static {
939
967
  __name(this, "NativeRecordingPartialStore");
@@ -971,14 +999,14 @@ var NativeRecordingPartialStore = class {
971
999
  const value = await readPartialMetadata(this.metadataPath, this.locator, this.options.maxBytes, this.options.signal);
972
1000
  if (!value)
973
1001
  return null;
974
- const file = await openOrdinaryFile(this.path);
1002
+ const file2 = await openOrdinaryFile(this.path);
975
1003
  try {
976
- const actual = await fingerprintPartial(file, this.options.signal, value.offset);
1004
+ const actual = await fingerprintPartial(file2, this.options.signal, value.offset);
977
1005
  if (actual.offset !== value.offset || actual.sha256 !== value.sha256)
978
1006
  throw new CliError("validation_error", "recording partial checksum does not match");
979
1007
  return value;
980
1008
  } finally {
981
- await file.close();
1009
+ await file2.close();
982
1010
  }
983
1011
  }
984
1012
  async open(locator, options) {
@@ -994,12 +1022,12 @@ var NativeRecordingPartialStore = class {
994
1022
  if (resume && (partialIdentity(resume.locator) !== partialIdentity(this.locator) || !Number.isSafeInteger(resume.offset) || resume.offset < 0 || resume.offset > this.options.maxBytes))
995
1023
  throw new CliError("validation_error", "recording partial scope changed");
996
1024
  this.completed = null;
997
- let file;
1025
+ let file2;
998
1026
  if (resume) {
999
- file = await openOrdinaryFile(this.path, { writable: true });
1027
+ file2 = await openOrdinaryFile(this.path, { writable: true });
1000
1028
  } else {
1001
1029
  const temp = join2(this.root, `${this.options.prefix}${randomUUID2()}.tmp`);
1002
- file = await open2(temp, "wx+", 384);
1030
+ file2 = await open2(temp, "wx+", 384);
1003
1031
  try {
1004
1032
  await rename2(temp, this.path);
1005
1033
  await unlink2(this.metadataPath).catch((error) => {
@@ -1007,19 +1035,19 @@ var NativeRecordingPartialStore = class {
1007
1035
  throw error;
1008
1036
  });
1009
1037
  } catch (error) {
1010
- await file.close();
1038
+ await file2.close();
1011
1039
  await unlink2(temp).catch(() => void 0);
1012
1040
  throw error;
1013
1041
  }
1014
1042
  }
1015
1043
  try {
1016
- const fingerprint = await fingerprintPartial(file, this.options.signal, resume?.offset);
1044
+ const fingerprint = await fingerprintPartial(file2, this.options.signal, resume?.offset);
1017
1045
  if (resume && (fingerprint.offset !== resume.offset || fingerprint.sha256 !== resume.sha256))
1018
1046
  throw new CliError("validation_error", "recording partial changed before append");
1019
- if (resume && (await file.stat()).size > fingerprint.offset)
1020
- await file.truncate(fingerprint.offset);
1047
+ if (resume && (await file2.stat()).size > fingerprint.offset)
1048
+ await file2.truncate(fingerprint.offset);
1021
1049
  return await partialWriter({
1022
- file,
1050
+ file: file2,
1023
1051
  path: this.path,
1024
1052
  root: this.root,
1025
1053
  metadataPath: this.metadataPath,
@@ -1034,36 +1062,36 @@ var NativeRecordingPartialStore = class {
1034
1062
  }, "complete")
1035
1063
  });
1036
1064
  } catch (error) {
1037
- await file.close();
1065
+ await file2.close();
1038
1066
  throw error;
1039
1067
  }
1040
1068
  }
1041
1069
  };
1042
1070
 
1043
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication.js
1071
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication.js
1044
1072
  import { createHash as createHash3 } from "node:crypto";
1045
1073
  import { link } from "node:fs/promises";
1046
1074
  import { basename, dirname, join as join4, resolve } from "node:path";
1047
1075
 
1048
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication-files.js
1076
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication-files.js
1049
1077
  import { unlink as unlink3 } from "node:fs/promises";
1050
1078
  var verifiedPublicationFile = /* @__PURE__ */ __name(async (path, expected, signal, writable = false) => {
1051
1079
  signal?.throwIfAborted();
1052
- const file = await openOrdinaryFile(path, { writable });
1080
+ const file2 = await openOrdinaryFile(path, { writable });
1053
1081
  try {
1054
- if ((await file.stat()).size !== expected.size)
1082
+ if ((await file2.stat()).size !== expected.size)
1055
1083
  throw new CliError("validation_error", "recording recovery final checksum does not match");
1056
- const actual = await fingerprintPartial(file, signal, expected.size);
1084
+ const actual = await fingerprintPartial(file2, signal, expected.size);
1057
1085
  if (actual.offset !== expected.size || actual.sha256 !== expected.sha256)
1058
1086
  throw new CliError("validation_error", "recording recovery final checksum does not match");
1059
- return file;
1087
+ return file2;
1060
1088
  } catch (error) {
1061
- await file.close();
1089
+ await file2.close();
1062
1090
  throw error;
1063
1091
  }
1064
1092
  }, "verifiedPublicationFile");
1065
- var assertPublicationIdentity = /* @__PURE__ */ __name(async (path, file) => {
1066
- if (!await sameOrdinaryFile(path, await file.stat({ bigint: true })))
1093
+ var assertPublicationIdentity = /* @__PURE__ */ __name(async (path, file2) => {
1094
+ if (!await sameOrdinaryFile(path, await file2.stat({ bigint: true })))
1067
1095
  throw new CliError("validation_error", "recording publication path changed");
1068
1096
  }, "assertPublicationIdentity");
1069
1097
  var commitPublication = /* @__PURE__ */ __name(async (root, partialPath, finalPath, partial, final, commit, signal) => {
@@ -1080,29 +1108,29 @@ var commitPublication = /* @__PURE__ */ __name(async (root, partialPath, finalPa
1080
1108
  signal?.throwIfAborted();
1081
1109
  }, "commitPublication");
1082
1110
 
1083
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication-journal.js
1111
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication-journal.js
1084
1112
  import { randomUUID as randomUUID3 } from "node:crypto";
1085
1113
  import { open as open3, rename as rename3, unlink as unlink4 } from "node:fs/promises";
1086
1114
  import { join as join3 } from "node:path";
1087
1115
  var readPublicationJournal = /* @__PURE__ */ __name(async (path, codec, limit, signal) => {
1088
1116
  signal?.throwIfAborted();
1089
- let file;
1117
+ let file2;
1090
1118
  try {
1091
- file = await openOrdinaryFile(path);
1119
+ file2 = await openOrdinaryFile(path);
1092
1120
  } catch (error) {
1093
1121
  if (missing(error))
1094
1122
  return null;
1095
1123
  throw error;
1096
1124
  }
1097
1125
  try {
1098
- if ((await file.stat()).size > limit)
1126
+ if ((await file2.stat()).size > limit)
1099
1127
  throw new Error("metadata limit");
1100
- const identity = await file.stat({ bigint: true });
1128
+ const identity = await file2.stat({ bigint: true });
1101
1129
  const bytes2 = Buffer.alloc(limit + 1);
1102
1130
  let size4 = 0;
1103
1131
  while (size4 < bytes2.length) {
1104
1132
  signal?.throwIfAborted();
1105
- const count2 = (await file.read(bytes2, size4, bytes2.length - size4, size4)).bytesRead;
1133
+ const count2 = (await file2.read(bytes2, size4, bytes2.length - size4, size4)).bytesRead;
1106
1134
  if (!count2)
1107
1135
  break;
1108
1136
  size4 += count2;
@@ -1118,7 +1146,7 @@ var readPublicationJournal = /* @__PURE__ */ __name(async (path, codec, limit, s
1118
1146
  signal?.throwIfAborted();
1119
1147
  throw new CliError("validation_error", "recording recovery record does not match this scoped asset");
1120
1148
  } finally {
1121
- await file.close();
1149
+ await file2.close();
1122
1150
  }
1123
1151
  }, "readPublicationJournal");
1124
1152
  var writePublicationJournal = /* @__PURE__ */ __name(async (root, path, prefix, value, codec, limit, signal) => {
@@ -1153,7 +1181,7 @@ var writePublicationJournal = /* @__PURE__ */ __name(async (root, path, prefix,
1153
1181
  }
1154
1182
  }, "writePublicationJournal");
1155
1183
 
1156
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication.js
1184
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/persistence/native/recording-publication.js
1157
1185
  var NativeRecordingPublication = class {
1158
1186
  static {
1159
1187
  __name(this, "NativeRecordingPublication");
@@ -1226,7 +1254,7 @@ var NativeRecordingPublication = class {
1226
1254
  }
1227
1255
  };
1228
1256
 
1229
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive-manifest.js
1257
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive-manifest.js
1230
1258
  import { createHash as createHash4 } from "node:crypto";
1231
1259
  import { readdir } from "node:fs/promises";
1232
1260
  import { isAbsolute, join as join5, resolve as resolve2 } from "node:path";
@@ -1255,18 +1283,18 @@ var parseMediaEntry = /* @__PURE__ */ __name((value) => {
1255
1283
  }, "parseMediaEntry");
1256
1284
  var mediaFingerprint = /* @__PURE__ */ __name(async (path, signal) => {
1257
1285
  signal?.throwIfAborted();
1258
- const file = await openOrdinaryFile(path);
1286
+ const file2 = await openOrdinaryFile(path);
1259
1287
  try {
1260
1288
  const hash3 = createHash4("sha256");
1261
1289
  let size4 = 0;
1262
- for await (const chunk of file.createReadStream({ autoClose: false, ...signal ? { signal } : {} })) {
1290
+ for await (const chunk of file2.createReadStream({ autoClose: false, ...signal ? { signal } : {} })) {
1263
1291
  signal?.throwIfAborted();
1264
1292
  hash3.update(chunk);
1265
1293
  size4 += chunk.length;
1266
1294
  }
1267
1295
  return { size: size4, sha256: hash3.digest("hex") };
1268
1296
  } finally {
1269
- await file.close();
1297
+ await file2.close();
1270
1298
  }
1271
1299
  }, "mediaFingerprint");
1272
1300
  var readMediaManifests = /* @__PURE__ */ __name(async (root, signal) => {
@@ -1313,10 +1341,10 @@ var commitMediaEntry = /* @__PURE__ */ __name((root, one, beforePublish) => writ
1313
1341
  beforePublish
1314
1342
  }), "commitMediaEntry");
1315
1343
 
1316
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive-files.js
1344
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive-files.js
1317
1345
  var validator = '"media-completed-v1"';
1318
1346
  var maximumFileBytes = 64 * 1024 * 1024 * 1024;
1319
- var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind, file, beforeWrite, signal, metadata = {}) => {
1347
+ var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind, file2, beforeWrite, signal, metadata = {}) => {
1320
1348
  const key = mediaKey(identity);
1321
1349
  const locator = {
1322
1350
  provider: identity.provider,
@@ -1376,7 +1404,7 @@ var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind, file,
1376
1404
  await publication.publish(storage.path, intent, () => commit(intent));
1377
1405
  return intent;
1378
1406
  }
1379
- const remote = await file();
1407
+ const remote = await file2();
1380
1408
  if (remote.size !== void 0 && (!Number.isSafeInteger(remote.size) || remote.size < 0 || remote.size > maximumFileBytes))
1381
1409
  throw new CliError("validation_error", "invalid media download size");
1382
1410
  await beforeWrite();
@@ -1414,7 +1442,7 @@ var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind, file,
1414
1442
  return entry;
1415
1443
  }, "archiveMediaFile");
1416
1444
 
1417
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive-locks.js
1445
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive-locks.js
1418
1446
  import { mkdir, realpath } from "node:fs/promises";
1419
1447
  import { join as join6, resolve as resolve3 } from "node:path";
1420
1448
  var archiveLocations = /* @__PURE__ */ __name(async (initial, signal) => {
@@ -1481,7 +1509,7 @@ var withMediaArchiveLocks = /* @__PURE__ */ __name(async (directory, signal, run
1481
1509
  throw new CliError("validation_error", "archive locations changed during locking; run the command again");
1482
1510
  }, "withMediaArchiveLocks");
1483
1511
 
1484
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive.js
1512
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive.js
1485
1513
  var validateMediaSince = /* @__PURE__ */ __name((value, flag = "--since-time") => {
1486
1514
  if (value === void 0)
1487
1515
  return void 0;
@@ -1530,10 +1558,10 @@ var saveMessage = /* @__PURE__ */ __name(async (root, account2, message, ports,
1530
1558
  name: one.name ?? null
1531
1559
  })), download.files);
1532
1560
  const index = positions.indexOf(position);
1533
- const file = download.files[index];
1534
- if (!file)
1561
+ const file2 = download.files[index];
1562
+ if (!file2)
1535
1563
  throw new CliError("invalid_response", "the messenger did not return an identifiable attachment");
1536
- return file;
1564
+ return file2;
1537
1565
  }, beforeWrite, options.signal, { messageTime: new Date(message.timestamp).toISOString(), ...attachment2.mime ? { mime: attachment2.mime } : {} });
1538
1566
  known2.set(key, entry);
1539
1567
  saved++;
@@ -1634,7 +1662,7 @@ var archiveMedia = /* @__PURE__ */ __name(async (ports, options) => {
1634
1662
  }, { create: true });
1635
1663
  }, "archiveMedia");
1636
1664
 
1637
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive-move.js
1665
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/media-archive-move.js
1638
1666
  import { realpath as realpath2, unlink as unlink5 } from "node:fs/promises";
1639
1667
  import { basename as basename2, dirname as dirname2, join as join7, resolve as resolve4 } from "node:path";
1640
1668
  var canonicalDestination = /* @__PURE__ */ __name(async (directory) => {
@@ -1650,16 +1678,16 @@ var canonicalDestination = /* @__PURE__ */ __name(async (directory) => {
1650
1678
  var image = /* @__PURE__ */ __name((entry) => ["photo", "image"].includes(entry.kind) || entry.mime?.startsWith("image/"), "image");
1651
1679
  var removeLocalCopy = /* @__PURE__ */ __name(async (root, entry, beforeWrite, signal) => {
1652
1680
  const path = join7(root, entry.path);
1653
- let file;
1681
+ let file2;
1654
1682
  try {
1655
- file = await openOrdinaryFile(path);
1683
+ file2 = await openOrdinaryFile(path);
1656
1684
  } catch (error) {
1657
1685
  if (missingMediaFile(error))
1658
1686
  return;
1659
1687
  throw error;
1660
1688
  }
1661
1689
  try {
1662
- const identity = await file.stat({ bigint: true });
1690
+ const identity = await file2.stat({ bigint: true });
1663
1691
  const proof = await mediaFingerprint(path, signal);
1664
1692
  if (proof.size !== entry.size || proof.sha256 !== entry.sha256 || !await sameOrdinaryFile(path, identity))
1665
1693
  throw new CliError("validation_error", "local image changed during rotation; it was preserved");
@@ -1671,7 +1699,7 @@ var removeLocalCopy = /* @__PURE__ */ __name(async (root, entry, beforeWrite, si
1671
1699
  await unlink5(path);
1672
1700
  await syncDirectory(root);
1673
1701
  } finally {
1674
- await file.close();
1702
+ await file2.close();
1675
1703
  }
1676
1704
  }, "removeLocalCopy");
1677
1705
  var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
@@ -1736,7 +1764,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
1736
1764
  for (const entry of candidates) {
1737
1765
  await beforeWrite();
1738
1766
  if (!known2.has(mediaKey(entry))) {
1739
- const file = await openOrdinaryFile(join7(root, entry.path));
1767
+ const file2 = await openOrdinaryFile(join7(root, entry.path));
1740
1768
  try {
1741
1769
  const identity = {
1742
1770
  provider: entry.provider,
@@ -1748,7 +1776,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
1748
1776
  const copied = await archiveMediaFile(target, identity, entry.kind, async () => ({
1749
1777
  kind: entry.kind,
1750
1778
  size: entry.size,
1751
- bytes: /* @__PURE__ */ __name(() => file.createReadStream({ autoClose: false, ...options.signal ? { signal: options.signal } : {} }), "bytes")
1779
+ bytes: /* @__PURE__ */ __name(() => file2.createReadStream({ autoClose: false, ...options.signal ? { signal: options.signal } : {} }), "bytes")
1752
1780
  }), beforeWrite, options.signal, {
1753
1781
  messageTime: entry.messageTime,
1754
1782
  mime: entry.mime,
@@ -1756,7 +1784,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
1756
1784
  });
1757
1785
  known2.set(mediaKey(entry), copied);
1758
1786
  } finally {
1759
- await file.close();
1787
+ await file2.close();
1760
1788
  }
1761
1789
  }
1762
1790
  const receipt = parseMediaEntry({ ...entry, relocatedTo: target });
@@ -1787,8 +1815,8 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
1787
1815
  }, { additional: [target], createAdditional: !options.dryRun });
1788
1816
  }, "moveMediaArchive");
1789
1817
 
1790
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/model-downloads.js
1791
- var bytesOf = /* @__PURE__ */ __name((model) => model.files.reduce((sum2, file) => sum2 + file.bytes, 0), "bytesOf");
1818
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/model-downloads.js
1819
+ var bytesOf = /* @__PURE__ */ __name((model) => model.files.reduce((sum2, file2) => sum2 + file2.bytes, 0), "bytesOf");
1792
1820
  var nativeRuntime = /* @__PURE__ */ __name(async ({ env, progress = /* @__PURE__ */ __name(() => {
1793
1821
  }, "progress") }) => {
1794
1822
  try {
@@ -1810,7 +1838,7 @@ var downloadTextModel = /* @__PURE__ */ __name(async (id2, { env, progress = /*
1810
1838
  }
1811
1839
  await nativeRuntime({ env, progress });
1812
1840
  progress(`${model.id}: loading it once to check it works`);
1813
- const { openEmbedder: openEmbedder2 } = await import("./embed-3GSQIQXE.js");
1841
+ const { openEmbedder: openEmbedder2 } = await import("./embed-MDN7R7BA.js");
1814
1842
  const embedder = await openEmbedder2(model, directory);
1815
1843
  try {
1816
1844
  const [vector] = await embedder.embed(["check"], "query");
@@ -1831,7 +1859,7 @@ var downloadRerankModel = /* @__PURE__ */ __name(async (id2, { env, progress = /
1831
1859
  }
1832
1860
  await nativeRuntime({ env, progress });
1833
1861
  progress(`${model.id}: loading it once to check it works`);
1834
- const { openReranker } = await import("./rerank-R6PE44M5.js");
1862
+ const { openReranker } = await import("./rerank-5A3JDK7O.js");
1835
1863
  const reranker = await openReranker(model, directory);
1836
1864
  try {
1837
1865
  await reranker.score("check", ["check"]);
@@ -1849,7 +1877,7 @@ var downloadImageModel = /* @__PURE__ */ __name(async (id2, { env, progress = /*
1849
1877
  await installFiles(placedImage(model, directory), { progress });
1850
1878
  }
1851
1879
  progress(`${model.id}: loading it once to check it works`);
1852
- const { openPictureEmbedder } = await import("./embedder-6ULWRG3R.js");
1880
+ const { openPictureEmbedder } = await import("./embedder-KEVEDNDJ.js");
1853
1881
  const embedder = await openPictureEmbedder(model, directory);
1854
1882
  try {
1855
1883
  const vector = await embedder.embedQuery("check");
@@ -1861,7 +1889,7 @@ var downloadImageModel = /* @__PURE__ */ __name(async (id2, { env, progress = /*
1861
1889
  return { model, directory };
1862
1890
  }, "downloadImageModel");
1863
1891
 
1864
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/project-gathering-around.js
1892
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/project-gathering-around.js
1865
1893
  var storedMessageNeighbours = /* @__PURE__ */ __name((messages) => ({
1866
1894
  async around(ref, window2) {
1867
1895
  const at = parseLocator(ref);
@@ -1957,7 +1985,7 @@ var storedNeighbours = /* @__PURE__ */ __name((store) => {
1957
1985
  };
1958
1986
  }, "storedNeighbours");
1959
1987
 
1960
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/project-gathering-request.js
1988
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/project-gathering-request.js
1961
1989
  import { createHash as createHash5 } from "node:crypto";
1962
1990
  var DAY = 864e5;
1963
1991
  var MAX_TIME = 864e13;
@@ -1976,15 +2004,16 @@ var BUDGETS = {
1976
2004
  maxReadBytes: [2097152, 16777216],
1977
2005
  maxPageBytes: [65536, 262144],
1978
2006
  maxElapsedMs: [6e4, 6e5],
1979
- maxItems: [100, 500]
2007
+ maxItems: [100, 500],
2008
+ maxFetchMs: [18e4, 18e5]
1980
2009
  };
1981
2010
  var fail = /* @__PURE__ */ __name((message, param) => {
1982
2011
  throw new CliError("validation_error", message, param ? { param } : void 0);
1983
2012
  }, "fail");
1984
2013
  var known = /* @__PURE__ */ __name((value, allowed, prefix) => {
1985
- const unknown = Object.keys(value).find((key) => !allowed.includes(key));
1986
- if (unknown)
1987
- fail(`${prefix}${unknown} is not supported`, `${prefix}${unknown}`);
2014
+ const unknown2 = Object.keys(value).find((key) => !allowed.includes(key));
2015
+ if (unknown2)
2016
+ fail(`${prefix}${unknown2} is not supported`, `${prefix}${unknown2}`);
1988
2017
  }, "known");
1989
2018
  var text = /* @__PURE__ */ __name((value, name, max) => typeof value === "string" && value.trim() && Buffer.byteLength(value) <= max ? value.trim() : fail(`${name} needs 1\u2013${max} UTF-8 bytes`, name), "text");
1990
2019
  var whole = /* @__PURE__ */ __name((value, name, low, high) => Number.isSafeInteger(value) && value >= low && value <= high ? value : fail(`${name} must be a whole number from ${low} to ${high}`, name), "whole");
@@ -2272,12 +2301,80 @@ var decodeCheckpoint = /* @__PURE__ */ __name((text2, plan) => {
2272
2301
  return value;
2273
2302
  }, "decodeCheckpoint");
2274
2303
 
2275
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/project-gathering.js
2304
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/project-gathering.js
2276
2305
  var terminal = /* @__PURE__ */ new Set(["done", "unavailable", "failed"]);
2277
2306
  var PAGE = 20;
2278
2307
  var PEOPLE = 20;
2279
2308
  var CONTEXTS = ["person-only", "sender", "linked-chat", "project"];
2280
2309
  var contextOf = /* @__PURE__ */ __name((lane) => lane.kinds.includes("linked-chat") ? "linked-chat" : lane.kinds.includes("sender") ? "sender" : lane.kinds.every((k) => k === "person") ? "person-only" : "project", "contextOf");
2310
+ var heldForWindow = /* @__PURE__ */ __name((row, after) => {
2311
+ if (!row)
2312
+ return false;
2313
+ const { state, upToDate, gaps } = row.completeness;
2314
+ if (state === "complete")
2315
+ return upToDate !== false;
2316
+ const oldest = row.held.oldestAt === null ? Number.NaN : Date.parse(row.held.oldestAt);
2317
+ return upToDate === true && !gaps && oldest <= after;
2318
+ }, "heldForWindow");
2319
+ var fetchLinkedChats = /* @__PURE__ */ __name(async (ports, plan, window2, now, signal) => {
2320
+ const wanted = [];
2321
+ for (const linked of plan.linkedChats) {
2322
+ if (linked.source === null)
2323
+ continue;
2324
+ const account2 = { provider: linked.provider, account: linked.account };
2325
+ const [row] = await ports.coverage(account2, [linked.chat]);
2326
+ if (!heldForWindow(row, window2.after))
2327
+ wanted.push({ ...linked, account: account2 });
2328
+ }
2329
+ const deadline = now() + plan.budgets.maxFetchMs;
2330
+ const results = [];
2331
+ for (const [index, linked] of wanted.entries()) {
2332
+ signal?.throwIfAborted();
2333
+ const started = now();
2334
+ const left = deadline - started;
2335
+ if (left <= 0) {
2336
+ results.push({ chat: linked.ref, state: "skipped", reason: "fetch-budget", elapsedMs: 0 });
2337
+ continue;
2338
+ }
2339
+ const budget = new AbortController();
2340
+ const timer = setTimeout(() => budget.abort(new CliError("timeout", "the fetch budget ran out")), left);
2341
+ const onProgress = ports.onFetchProgress;
2342
+ try {
2343
+ const answer = await ports.fetcher.fetch({
2344
+ account: linked.account,
2345
+ chatId: linked.chat,
2346
+ after: window2.after,
2347
+ before: window2.before,
2348
+ until: deadline,
2349
+ signal: signal ? AbortSignal.any([signal, budget.signal]) : budget.signal,
2350
+ ...onProgress ? { onProgress: /* @__PURE__ */ __name((progress) => onProgress({ ...progress, chat: linked.ref, index, of: wanted.length }), "onProgress") } : {}
2351
+ });
2352
+ if (!["complete", "partial", "failed"].includes(answer?.state))
2353
+ throw new CliError("invalid_response", "chat fetch returned an unknown state");
2354
+ const cut = budget.signal.aborted || now() > deadline;
2355
+ results.push({
2356
+ chat: linked.ref,
2357
+ state: cut && answer.state === "complete" ? "partial" : answer.state,
2358
+ reason: answer.reason ?? (cut && answer.state !== "failed" ? "fetch-budget" : null),
2359
+ elapsedMs: now() - started
2360
+ });
2361
+ } catch (error) {
2362
+ signal?.throwIfAborted();
2363
+ if (!(error instanceof CliError))
2364
+ throw error;
2365
+ const cut = budget.signal.aborted;
2366
+ results.push({
2367
+ chat: linked.ref,
2368
+ state: cut ? "partial" : "failed",
2369
+ reason: cut ? "fetch-budget" : error.code,
2370
+ elapsedMs: now() - started
2371
+ });
2372
+ } finally {
2373
+ clearTimeout(timer);
2374
+ }
2375
+ }
2376
+ return results;
2377
+ }, "fetchLinkedChats");
2281
2378
  var gatherProjectEvidence = /* @__PURE__ */ __name(async (ports, request) => {
2282
2379
  if (!ports?.evidence || typeof ports.evidence.read !== "function")
2283
2380
  throw new CliError("configuration_error", "stored context reads are unavailable in this store");
@@ -2289,34 +2386,20 @@ var gatherProjectEvidence = /* @__PURE__ */ __name(async (ports, request) => {
2289
2386
  const units2 = projectUnits(plan, window2);
2290
2387
  if (request.budgets?.maxReads === void 0)
2291
2388
  plan.budgets.maxReads = Math.min(512, Math.max(48, units2.length));
2292
- if (previous && (previous.units.length !== units2.length || previous.fetched.length !== plan.sources.length))
2389
+ if (previous && previous.units.length !== units2.length)
2293
2390
  throw new CliError("validation_error", "invalid project gathering checkpoint", { param: "checkpoint" });
2294
2391
  const progress = previous?.units.map((u) => ({ ...u })) ?? units2.map(() => ({ state: "pending", pages: 0, cursor: null, code: null }));
2295
- const fetched = previous?.fetched.map((f) => ({ ...f })) ?? plan.sources.map(() => ({ state: "not-requested", history: null, code: null }));
2392
+ let fetched = previous?.fetched.map((f) => ({ ...f })) ?? [];
2296
2393
  const seen = new Set(previous?.seen ?? []);
2297
2394
  const signal = plan.signal;
2298
2395
  const queries = plan.lanes.flatMap((lane) => lane.query === null ? [] : [lane.query]);
2299
- if (plan.fetch === "before-read" && !ports.fetcher)
2300
- throw new CliError("configuration_error", "this host cannot fetch source history; use fetch none", {
2396
+ if (plan.fetch === "before-read" && (!ports.fetcher || !ports.coverage))
2397
+ throw new CliError("configuration_error", "this host cannot fetch chat history; use fetch none", {
2301
2398
  param: "fetch"
2302
2399
  });
2303
- if (plan.fetch === "before-read" && ports.fetcher)
2304
- for (const [index, source] of plan.sources.entries()) {
2305
- if (fetched[index]?.state !== "not-requested")
2306
- continue;
2307
- signal?.throwIfAborted();
2308
- try {
2309
- const answer = await ports.fetcher.fetch({ source, after: window2.after, before: window2.before, signal });
2310
- if (!["fetched", "unsupported"].includes(answer?.status) || !["complete", "partial", "unknown"].includes(answer?.history))
2311
- throw new CliError("invalid_response", "source fetch returned an unknown status");
2312
- fetched[index] = { state: answer.status, history: answer.history, code: null };
2313
- } catch (error) {
2314
- signal?.throwIfAborted();
2315
- if (!(error instanceof CliError))
2316
- throw error;
2317
- fetched[index] = { state: "failed", history: null, code: error.code };
2318
- }
2319
- }
2400
+ if (plan.fetch === "before-read" && ports.fetcher && ports.coverage && previous === null)
2401
+ fetched = await fetchLinkedChats(ports, plan, window2, now, signal);
2402
+ const readFrom = now();
2320
2403
  const indexed = { state: "as-is", mail: 0, documents: 0, code: null };
2321
2404
  const kinds = [...new Set(plan.sources.map((source) => source.kind))].filter((kind) => kind !== "message");
2322
2405
  if (plan.index === "update" && kinds.length) {
@@ -2419,7 +2502,7 @@ var gatherProjectEvidence = /* @__PURE__ */ __name(async (ports, request) => {
2419
2502
  capped2.add(unit.lane.id);
2420
2503
  continue;
2421
2504
  }
2422
- stopped = usage.reads >= plan.budgets.maxReads ? "reads" : usage.readBytes >= plan.budgets.maxReadBytes ? "read-bytes" : now() - started >= plan.budgets.maxElapsedMs ? "elapsed" : usage.items >= plan.budgets.maxItems ? "items" : null;
2505
+ stopped = usage.reads >= plan.budgets.maxReads ? "reads" : usage.readBytes >= plan.budgets.maxReadBytes ? "read-bytes" : now() - readFrom >= plan.budgets.maxElapsedMs ? "elapsed" : usage.items >= plan.budgets.maxItems ? "items" : null;
2423
2506
  if (stopped)
2424
2507
  break;
2425
2508
  const readPage = /* @__PURE__ */ __name(async (allowance, limit) => {
@@ -2575,7 +2658,7 @@ var gatherProjectEvidence = /* @__PURE__ */ __name(async (ports, request) => {
2575
2658
  scope: { origin: plan.scope, sources: plan.sources },
2576
2659
  lanes: plan.lanes,
2577
2660
  linkedChats: linkedRows,
2578
- fetch: fetched.map((f, index) => ({ source: index, ...f })),
2661
+ fetch: fetched,
2579
2662
  index: indexed,
2580
2663
  units: units2.map((unit, index) => ({
2581
2664
  lane: unit.lane.id,
@@ -2622,7 +2705,7 @@ var peopleOf = /* @__PURE__ */ __name((items, senderOf) => {
2622
2705
  return [...byKey.values()].sort((a, b) => b.items - a.items || a.name.localeCompare(b.name));
2623
2706
  }, "peopleOf");
2624
2707
 
2625
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidate-matching.js
2708
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidate-matching.js
2626
2709
  var normalizedText = /* @__PURE__ */ __name((text2) => text2.normalize("NFKC").toLowerCase().replace(/\s+/gu, " "), "normalizedText");
2627
2710
  var termsOf = /* @__PURE__ */ __name((entry) => [
2628
2711
  { name: entry.name, kind: "canonical" },
@@ -2683,11 +2766,11 @@ var matchProjectCandidates = /* @__PURE__ */ __name((catalog, input) => matchVoc
2683
2766
  }))
2684
2767
  ]).map(({ entry, matches, omitted }) => ({
2685
2768
  project: { reference: `project:${entry.id}`, id: entry.id, name: entry.name, key: entry.key },
2686
- matches: matches.map(({ term, source, ambiguous }) => ({ term, source, ambiguous })),
2769
+ matches: matches.map(({ term, source, ambiguous: ambiguous2 }) => ({ term, source, ambiguous: ambiguous2 })),
2687
2770
  omittedMatches: omitted
2688
2771
  })), "matchProjectCandidates");
2689
2772
 
2690
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/project-gathering-mentions.js
2773
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/project-gathering-mentions.js
2691
2774
  var KINDS = ["project", "tag", "topic"];
2692
2775
  var findEvidenceMentions = /* @__PURE__ */ __name(async (vocabulary, gathering, options = {}) => {
2693
2776
  if (typeof vocabulary?.vocabulary !== "function")
@@ -2722,7 +2805,7 @@ var findEvidenceMentions = /* @__PURE__ */ __name(async (vocabulary, gathering,
2722
2805
  continue;
2723
2806
  items.push({
2724
2807
  target: { kind, id: entry.id, reference, name: entry.name, key: entry.key },
2725
- matches: matches.map(({ term, source, ambiguous }) => ({ term, ambiguous, ...source })),
2808
+ matches: matches.map(({ term, source, ambiguous: ambiguous2 }) => ({ term, ambiguous: ambiguous2, ...source })),
2726
2809
  omittedMatches: omitted
2727
2810
  });
2728
2811
  }
@@ -2742,7 +2825,173 @@ var findEvidenceMentions = /* @__PURE__ */ __name(async (vocabulary, gathering,
2742
2825
  };
2743
2826
  }, "findEvidenceMentions");
2744
2827
 
2745
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/ports/messenger.js
2828
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/stored-project-gathering.js
2829
+ var PROJECT_ID = /^project:[1-9]\d*$/;
2830
+ var canonicalProjectRef = /* @__PURE__ */ __name(async (store, reference) => {
2831
+ if (PROJECT_ID.test(reference)) {
2832
+ const catalog = await store.knowledge.vocabulary({ kind: "project" });
2833
+ if (!catalog.entries.some((entry2) => entry2.id === reference.slice(8)))
2834
+ throw new CliError("not_found", "the owner project is unavailable");
2835
+ return reference;
2836
+ }
2837
+ const found = await store.knowledge.resolveVocabulary(reference, { kind: "project" });
2838
+ const [entry] = found.matches;
2839
+ if (found.matches.length !== 1 || !entry)
2840
+ throw new CliError(found.matches.length ? "validation_error" : "not_found", found.matches.length ? `${reference} names ${found.matches.length} projects; give one by its key or project:<id>` : `no project ${reference}`, { candidates: found.matches.map((one) => ({ id: one.id, key: one.key, name: one.name })) });
2841
+ return `project:${entry.id}`;
2842
+ }, "canonicalProjectRef");
2843
+ var projectOf = /* @__PURE__ */ __name(async (store, reference) => {
2844
+ const id2 = /^(project:)?[1-9]\d*$/.test(reference);
2845
+ let ref;
2846
+ try {
2847
+ ref = await canonicalProjectRef(store, id2 && !reference.startsWith("project:") ? `project:${reference}` : reference);
2848
+ } catch (error) {
2849
+ if (!id2 && error instanceof CliError && error.code === "not_found")
2850
+ return { ref: null, name: reference, key: null, aliases: [] };
2851
+ throw error;
2852
+ }
2853
+ const entry = (await store.knowledge.vocabulary({ kind: "project" })).entries.find((one) => one.id === ref.slice(8));
2854
+ if (!entry)
2855
+ throw new CliError("not_found", "the owner project is unavailable");
2856
+ return { ref, name: entry.name, key: entry.key, aliases: entry.aliases.map((alias) => alias.name) };
2857
+ }, "projectOf");
2858
+ var withOwner = /* @__PURE__ */ __name(async (store, reference) => {
2859
+ if (reference.trim() !== "person:me")
2860
+ return reference;
2861
+ const owner = await store.people.owner();
2862
+ if (owner === void 0 || owner.identities.length === 0)
2863
+ throw new CliError("not_found", "person:me: no person is marked as you in the store; mark yours with `<messenger> <profile> contacts link <your id> me`", { reason: "person.no-owner" });
2864
+ return `person:${owner.uid}`;
2865
+ }, "withOwner");
2866
+ var sendersOf = /* @__PURE__ */ __name((person) => person.identities.map((identity) => ({ provider: identity.provider, id: String(identity.id) })), "sendersOf");
2867
+ var contactOf = /* @__PURE__ */ __name(async (store, contact) => {
2868
+ const reference = await withOwner(store, contact);
2869
+ if (!reference.startsWith("person:"))
2870
+ return [{ name: contact }];
2871
+ const person = await store.people.personByUid(reference.slice("person:".length));
2872
+ if (!person)
2873
+ throw new CliError("not_found", `no person ${contact}`, { param: "contact" });
2874
+ const senders = sendersOf(person);
2875
+ const aliases = /* @__PURE__ */ new Set();
2876
+ for (const identity of person.identities)
2877
+ for (const account2 of identity.accounts) {
2878
+ const alias = await store.people.privateContact({ provider: identity.provider, account: account2 }, identity.id).then((one) => one.alias).catch((error) => {
2879
+ if (error instanceof CliError && error.code === "not_found")
2880
+ return null;
2881
+ throw error;
2882
+ });
2883
+ if (alias)
2884
+ aliases.add(alias);
2885
+ }
2886
+ if (!senders.length && !aliases.size)
2887
+ throw new CliError("validation_error", `${contact} has no stored identity or alias to search by; pass a name the texts use to --contact`, { param: "contact" });
2888
+ const names2 = [...aliases].map((name) => ({ name, reference: contact }));
2889
+ return senders.length ? [{ reference: contact, senders }, ...names2] : names2;
2890
+ }, "contactOf");
2891
+ var LINKED_CHATS = 16;
2892
+ var CORE_LIMIT = 16;
2893
+ var memberRefsOf = /* @__PURE__ */ __name(async (store, project) => {
2894
+ if (!project)
2895
+ return [];
2896
+ const refs = [];
2897
+ for (const relation of await store.knowledge.relations(null, project))
2898
+ if (relation.confirmed && relation.kind === "member-of" && relation.to === project && /^person:.+/.test(relation.from))
2899
+ refs.push(relation.from);
2900
+ return [...new Set(refs)].sort();
2901
+ }, "memberRefsOf");
2902
+ var memberLanesOf = /* @__PURE__ */ __name(async (store, project, given, room) => {
2903
+ const lanes = [];
2904
+ const left = [];
2905
+ for (const reference of (await memberRefsOf(store, project)).filter((one) => !given.has(one))) {
2906
+ const person = await store.people.personByUid(reference.slice("person:".length));
2907
+ const senders = person ? sendersOf(person) : [];
2908
+ if (!senders.length)
2909
+ left.push({ source: reference, kind: "member", reason: "no-identity" });
2910
+ else if (lanes.length >= room)
2911
+ left.push({ source: reference, kind: "member", reason: "member-limit" });
2912
+ else
2913
+ lanes.push({ reference, senders });
2914
+ }
2915
+ return { lanes, left };
2916
+ }, "memberLanesOf");
2917
+ var linkedChatsOf = /* @__PURE__ */ __name(async (store, project) => {
2918
+ if (!project)
2919
+ return [];
2920
+ const chats = [];
2921
+ for (const relation of await store.knowledge.relations(null, project)) {
2922
+ if (!relation.confirmed || relation.kind !== "member-of" || relation.to !== project)
2923
+ continue;
2924
+ if (!relation.from.startsWith("chat:"))
2925
+ continue;
2926
+ const reference = parseReference(relation.from);
2927
+ if (reference.type === "chat")
2928
+ chats.push(reference);
2929
+ }
2930
+ return chats.map(({ provider, account: account2, chat }) => ({ provider, account: account2, chat }));
2931
+ }, "linkedChatsOf");
2932
+ var gatherStoredProject = /* @__PURE__ */ __name(async (store, input) => {
2933
+ if (input.asOf !== void 0 && input.after !== void 0 && input.asOf <= input.after)
2934
+ throw new CliError("validation_error", "--before-time must be later than --since-time", { param: "before_time" });
2935
+ if (!store.contextEvidence)
2936
+ throw new CliError("configuration_error", "Stored context reads are unavailable in this store");
2937
+ const project = await projectOf(store, input.project);
2938
+ const { sources, unread, scope } = input.sources;
2939
+ if (sources.length === 0)
2940
+ throw new CliError("not_found", "no selected source holds anything to read", { param: "source" });
2941
+ const contacts = (await Promise.all([...new Set(input.people ?? [])].map((contact) => contactOf(store, contact)))).flat();
2942
+ const aliases = [.../* @__PURE__ */ new Set([...project.aliases, ...input.aliases ?? []])].filter((alias) => alias !== project.name);
2943
+ const searchLanes = 1 + (project.key ? 1 : 0) + aliases.length + (input.keywords?.length ?? 0) + contacts.filter((one) => one.name).length;
2944
+ const room = Math.min(CORE_LIMIT - contacts.length, CORE_LIMIT - searchLanes - contacts.filter((one) => one.senders).length);
2945
+ const members = await memberLanesOf(store, project.ref, new Set(contacts.flatMap((one) => one.reference ?? [])), room);
2946
+ const people = [...contacts, ...members.lanes];
2947
+ const linked = await linkedChatsOf(store, project.ref);
2948
+ const linkedChats = linked.slice(0, LINKED_CHATS);
2949
+ const budgets = {
2950
+ ...input.maxReads === void 0 ? {} : { maxReads: input.maxReads },
2951
+ ...input.limit === void 0 ? {} : { maxItems: input.limit },
2952
+ ...input.maxFetchMs === void 0 ? {} : { maxFetchMs: input.maxFetchMs }
2953
+ };
2954
+ const gathered = await gatherProjectEvidence({
2955
+ evidence: store.contextEvidence,
2956
+ neighbours: storedNeighbours(store),
2957
+ coverage: /* @__PURE__ */ __name((account2, chatIds) => chatCoverage(store, account2, chatIds), "coverage"),
2958
+ ...store.contextIndex ? { index: store.contextIndex } : {},
2959
+ ...input.fetcher ? { fetcher: input.fetcher } : {},
2960
+ ...input.onFetchProgress ? { onFetchProgress: input.onFetchProgress } : {}
2961
+ }, {
2962
+ project: {
2963
+ name: project.name,
2964
+ ...project.key ? { key: project.key } : {},
2965
+ ...aliases.length ? { aliases } : {}
2966
+ },
2967
+ index: input.catchUp === false ? "as-is" : "update",
2968
+ around: { before: input.beforeN ?? 2, after: input.afterN ?? 2 },
2969
+ ...input.keywords?.length ? { keywords: input.keywords } : {},
2970
+ ...people.length ? { people } : {},
2971
+ ...linkedChats.length ? { linkedChats } : {},
2972
+ ...input.fetcher ? { fetch: "before-read" } : {},
2973
+ sources,
2974
+ scope,
2975
+ ...input.days === void 0 ? {} : { lookbackDays: input.days },
2976
+ ...input.after === void 0 ? {} : { after: input.after },
2977
+ ...input.asOf === void 0 ? {} : { asOf: input.asOf },
2978
+ ...input.checkpoint === void 0 ? {} : { checkpoint: input.checkpoint },
2979
+ ...Object.keys(budgets).length ? { budgets } : {},
2980
+ ...input.signal ? { signal: input.signal } : {}
2981
+ });
2982
+ const mentions = await findEvidenceMentions(store.knowledge, gathered, { exclude: project.ref });
2983
+ const unreadChats = [
2984
+ ...gathered.linkedChats.filter((one) => one.state === "out-of-scope").map((one) => ({ source: one.ref, kind: "linked-chat", reason: "out-of-scope" })),
2985
+ ...linked.slice(LINKED_CHATS).map((one) => ({
2986
+ source: formatReference({ type: "chat", ...one }),
2987
+ kind: "linked-chat",
2988
+ reason: "linked-chat-limit"
2989
+ }))
2990
+ ];
2991
+ return { projectRef: project.ref, unreadSources: [...unread, ...unreadChats, ...members.left], ...gathered, mentions };
2992
+ }, "gatherStoredProject");
2993
+
2994
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/ports/messenger.js
2746
2995
  var throughWrapper = /* @__PURE__ */ __name((inner, handled, wrap = (_, call) => call) => new Proxy(handled, {
2747
2996
  get: /* @__PURE__ */ __name((own, key) => {
2748
2997
  if (key in own)
@@ -2759,24 +3008,24 @@ var capability = /* @__PURE__ */ __name((adapter, method, what) => {
2759
3008
  return found.bind(adapter);
2760
3009
  }, "capability");
2761
3010
 
2762
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/sends/send-id.js
3011
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/sends/send-id.js
2763
3012
  import { randomBytes } from "node:crypto";
2764
3013
  var newSendId = /* @__PURE__ */ __name(() => randomBytes(8).readBigInt64BE().toString(), "newSendId");
2765
3014
  var newOperationId = newSendId;
2766
3015
 
2767
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/account.js
3016
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/account.js
2768
3017
  var accountService = /* @__PURE__ */ __name((deps) => {
2769
3018
  const online = /* @__PURE__ */ __name(async (command) => {
2770
3019
  if (deps.offline)
2771
3020
  throw new CliError("validation_error", `\`${command}\` changes the account; not with --offline`);
2772
3021
  return deps.connection();
2773
3022
  }, "online");
2774
- const onOneChat = /* @__PURE__ */ __name(async (command, chat, action, write) => {
3023
+ const onOneChat = /* @__PURE__ */ __name(async (command, chat, action2, write) => {
2775
3024
  const connection = await online(command);
2776
3025
  const act2 = write(connection);
2777
3026
  const { id: chatId } = await connection.resolve(chat);
2778
3027
  const operationId = newOperationId();
2779
- await guardedWrite(deps.guard, { operationId, chatId, kind: "account", action }, () => act2(chatId));
3028
+ await guardedWrite(deps.guard, { operationId, chatId, kind: "account", action: action2 }, () => act2(chatId));
2780
3029
  return { operationId, chatId };
2781
3030
  }, "onOneChat");
2782
3031
  return {
@@ -2836,7 +3085,7 @@ var accountService = /* @__PURE__ */ __name((deps) => {
2836
3085
  };
2837
3086
  }, "accountService");
2838
3087
 
2839
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/send-time.js
3088
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/send-time.js
2840
3089
  var MINUTE = 6e4;
2841
3090
  var YEAR = 365 * 24 * 60 * MINUTE;
2842
3091
  var DELAY = /^(\d+)(m|h|d)$/;
@@ -2855,7 +3104,7 @@ var sendTime = /* @__PURE__ */ __name((value, now = Date.now(), flag = "--at-tim
2855
3104
  return new Date(at - at % MINUTE).toISOString();
2856
3105
  }, "sendTime");
2857
3106
 
2858
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/admin.js
3107
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/admin.js
2859
3108
  var recordMembership = /* @__PURE__ */ __name(async (deps, operationId, done2, change, fix, write) => {
2860
3109
  try {
2861
3110
  const held = await accountStoreIfOpen(deps);
@@ -2866,7 +3115,7 @@ var recordMembership = /* @__PURE__ */ __name(async (deps, operationId, done2, c
2866
3115
  throw new CliError(isCliError(error) ? error.code : "invalid_response", `${done2}, but the local store could not ${change} (${reason}) \u2014 do not run it again; ${fix}`, { operation_id: operationId, retryable: false });
2867
3116
  }
2868
3117
  }, "recordMembership");
2869
- var reportedFix = /* @__PURE__ */ __name((deps, chatId, shows, action) => `it may show as ${shows} until the messenger reports the ${action}; \`${typedCommand(deps.messenger.app.command, `chats show ${chatId}`)}\` says when it has`, "reportedFix");
3118
+ var reportedFix = /* @__PURE__ */ __name((deps, chatId, shows, action2) => `it may show as ${shows} until the messenger reports the ${action2}; \`${typedCommand(deps.messenger.app.command, `chats show ${chatId}`)}\` says when it has`, "reportedFix");
2870
3119
  var adminService = /* @__PURE__ */ __name((deps) => {
2871
3120
  const online = /* @__PURE__ */ __name(async (command) => {
2872
3121
  if (deps.offline)
@@ -2879,16 +3128,16 @@ var adminService = /* @__PURE__ */ __name((deps) => {
2879
3128
  throw new CliError("validation_error", "a group needs a title");
2880
3129
  const connection = await online("chats create");
2881
3130
  const create = capability(connection, "createGroup", "create a group");
2882
- const personIds = people.length === 0 ? [] : await capability(connection, "people", "find people")(people);
3131
+ const personIds2 = people.length === 0 ? [] : await capability(connection, "people", "find people")(people);
2883
3132
  const operationId = newOperationId();
2884
- const chat = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "create", personIds, people: personIds.length }, () => create(title.trim(), personIds, { channel }), (made) => ({ chatId: made.id }));
3133
+ const chat = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "create", personIds: personIds2, people: personIds2.length }, () => create(title.trim(), personIds2, { channel }), (made) => ({ chatId: made.id }));
2885
3134
  return { operationId, chat };
2886
3135
  }, "create"),
2887
3136
  join: /* @__PURE__ */ __name(async (link4) => {
2888
3137
  const connection = await online("chats join");
2889
- const join10 = capability(connection, "join", "join a chat by its link");
3138
+ const join11 = capability(connection, "join", "join a chat by its link");
2890
3139
  const operationId = newOperationId();
2891
- const joined = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "join" }, () => join10(link4.trim()), (answer) => "requested" in answer ? {} : { chatId: answer.id });
3140
+ const joined = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "join" }, () => join11(link4.trim()), (answer) => "requested" in answer ? {} : { chatId: answer.id });
2892
3141
  if ("requested" in joined)
2893
3142
  return { operationId, requested: true };
2894
3143
  const fix = deps.reads === "store" ? reportedFix(deps, joined.id, "left", "join") : `an online \`${typedCommand(deps.messenger.app.command, "chats list")}\` that shows the chat corrects it`;
@@ -2942,8 +3191,8 @@ var adminService = /* @__PURE__ */ __name((deps) => {
2942
3191
  const update = capability(connection, "updateGroup", "change a group");
2943
3192
  const { id: chatId } = await connection.resolve(chat);
2944
3193
  const operationId = newOperationId();
2945
- const action = profile ? "update" : "settings";
2946
- const card = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action }, () => update(chatId, change));
3194
+ const action2 = profile ? "update" : "settings";
3195
+ const card = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: action2 }, () => update(chatId, change));
2947
3196
  return { operationId, chat: card };
2948
3197
  }, "update"),
2949
3198
  link: /* @__PURE__ */ __name(async (chat) => {
@@ -2982,9 +3231,9 @@ var adminService = /* @__PURE__ */ __name((deps) => {
2982
3231
  if (window2.search?.trim() === "" || window2.link?.trim() === "")
2983
3232
  throw new CliError("validation_error", "a name or a link needs a value");
2984
3233
  const connection = await deps.connection();
2985
- const list2 = capability(connection, "joinRequests", "read join requests");
3234
+ const list3 = capability(connection, "joinRequests", "read join requests");
2986
3235
  const { id: chatId } = await connection.resolve(chat);
2987
- return { chatId, ...await list2(chatId, window2) };
3236
+ return { chatId, ...await list3(chatId, window2) };
2988
3237
  }, "requests"),
2989
3238
  answerRequest: /* @__PURE__ */ __name(async (chat, person, accept) => {
2990
3239
  const connection = await online(`chats requests ${accept ? "accept" : "decline"}`);
@@ -2997,10 +3246,10 @@ var adminService = /* @__PURE__ */ __name((deps) => {
2997
3246
  }, "answerRequest"),
2998
3247
  answerAllRequests: /* @__PURE__ */ __name(async (chat, accept, { link: link4 }) => {
2999
3248
  const connection = await online(`chats requests ${accept ? "accept" : "decline"} --all`);
3000
- const list2 = capability(connection, "joinRequests", "read join requests");
3249
+ const list3 = capability(connection, "joinRequests", "read join requests");
3001
3250
  const answerAll = capability(connection, "answerAllJoinRequests", "answer every join request at once");
3002
3251
  const { id: chatId } = await connection.resolve(chat);
3003
- const page = await list2(chatId, { limit: 100, ...link4 === void 0 ? {} : { link: link4 } });
3252
+ const page = await list3(chatId, { limit: 100, ...link4 === void 0 ? {} : { link: link4 } });
3004
3253
  const counted2 = page.total ?? page.items.length;
3005
3254
  if (page.total === void 0 && page.hasMore)
3006
3255
  throw new CliError("validation_error", "too many requests to count; answer them by person, or by --link");
@@ -3021,9 +3270,9 @@ var adminService = /* @__PURE__ */ __name((deps) => {
3021
3270
  if (deps.offline)
3022
3271
  throw new CliError("validation_error", "invite links are read from the messenger; not with --offline");
3023
3272
  const connection = await deps.connection();
3024
- const list2 = capability(connection, "inviteLinks", "list invite links");
3273
+ const list3 = capability(connection, "inviteLinks", "list invite links");
3025
3274
  const { id: chatId } = await connection.resolve(chat);
3026
- return { chatId, ...await list2(chatId, window2) };
3275
+ return { chatId, ...await list3(chatId, window2) };
3027
3276
  }, "links"),
3028
3277
  revokeLink: /* @__PURE__ */ __name(async (chat, link4) => {
3029
3278
  if (link4.trim() === "")
@@ -3057,20 +3306,20 @@ var adminService = /* @__PURE__ */ __name((deps) => {
3057
3306
  addMembers: /* @__PURE__ */ __name(async (chat, people, options) => {
3058
3307
  const connection = await online("chats members add");
3059
3308
  const add = capability(connection, "addMembers", "add people to a group");
3060
- const personIds = await capability(connection, "people", "find people")(people);
3309
+ const personIds2 = await capability(connection, "people", "find people")(people);
3061
3310
  const { id: chatId } = await connection.resolve(chat);
3062
3311
  const operationId = newOperationId();
3063
- const { notAdded } = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.add", personIds, people: personIds.length }, () => add(chatId, personIds, options));
3064
- return { operationId, chatId, added: personIds.filter((id2) => !notAdded.includes(id2)), notAdded };
3312
+ const { notAdded } = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.add", personIds: personIds2, people: personIds2.length }, () => add(chatId, personIds2, options));
3313
+ return { operationId, chatId, added: personIds2.filter((id2) => !notAdded.includes(id2)), notAdded };
3065
3314
  }, "addMembers"),
3066
3315
  removeMembers: /* @__PURE__ */ __name(async (chat, people) => {
3067
3316
  const connection = await online("chats members remove");
3068
3317
  const remove = capability(connection, "removeMembers", "remove people from a group");
3069
- const personIds = await capability(connection, "people", "find people")(people);
3318
+ const personIds2 = await capability(connection, "people", "find people")(people);
3070
3319
  const { id: chatId } = await connection.resolve(chat);
3071
3320
  const operationId = newOperationId();
3072
- await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.remove", people: personIds.length }, () => remove(chatId, personIds));
3073
- return { operationId, chatId, removed: personIds };
3321
+ await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.remove", people: personIds2.length }, () => remove(chatId, personIds2));
3322
+ return { operationId, chatId, removed: personIds2 };
3074
3323
  }, "removeMembers"),
3075
3324
  addAdmin: /* @__PURE__ */ __name(async (chat, person, rights) => {
3076
3325
  if (rights.length === 0)
@@ -3102,10 +3351,10 @@ var linkLimits = /* @__PURE__ */ __name(({ approval, expires, maxUses }) => {
3102
3351
  return expires === void 0 ? void 0 : sendTime(expires, Date.now(), "--expire-time");
3103
3352
  }, "linkLimits");
3104
3353
 
3105
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/ports/traits.js
3354
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/ports/traits.js
3106
3355
  var syncsOneChat = /* @__PURE__ */ __name((messenger) => messenger.history !== "store" || messenger.historyOnDemand === true, "syncsOneChat");
3107
3356
 
3108
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/mail-search.js
3357
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/mail-search.js
3109
3358
  var THREADS_PAGE = 500;
3110
3359
  var threadsOf = /* @__PURE__ */ __name(async (store, key) => {
3111
3360
  const account2 = await store.accounts.storedAccount(key).catch(() => void 0);
@@ -3184,7 +3433,7 @@ var readMail = /* @__PURE__ */ __name(async (store, locator, { before: before2 =
3184
3433
  return thread.slice(Math.max(0, at - before2), at + after + 1).map((hit) => hit.id === message ? { ...hit, anchor: true } : hit);
3185
3434
  }, "readMail");
3186
3435
 
3187
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/message-resolution.js
3436
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/message-resolution.js
3188
3437
  var readChatId = /* @__PURE__ */ __name(async (deps, reference, store, account2) => {
3189
3438
  if (deps.reads !== "store")
3190
3439
  return keptChatId(deps.messenger, reference, store, account2);
@@ -3331,7 +3580,7 @@ var senderAmong = /* @__PURE__ */ __name(async (store, accounts, reference) => {
3331
3580
  }
3332
3581
  }, "senderAmong");
3333
3582
 
3334
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/search-kind.js
3583
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/search-kind.js
3335
3584
  var NO_MAIL = "no_mail";
3336
3585
  var MAIL = "email";
3337
3586
  var listContextOf = /* @__PURE__ */ __name(async (store, account2, app, stored) => {
@@ -3378,7 +3627,7 @@ var accountsOfKind = /* @__PURE__ */ __name((kind, chosen, held, explicit, comma
3378
3627
  return chosenMail.map(({ provider, account: account2 }) => ({ provider, account: account2 }));
3379
3628
  }, "accountsOfKind");
3380
3629
 
3381
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages-search.js
3630
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages-search.js
3382
3631
  var MAIL_FIELDS = /* @__PURE__ */ new Set(["to", "cc", "bcc", "subject", "mailbox", "label", "is"]);
3383
3632
  var positiveSources = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "in" ? [node.value.toLowerCase()] : [] : node.clauses.filter(({ occur }) => occur !== "must_not").flatMap(({ node: node2 }) => positiveSources(node2)), "positiveSources");
3384
3633
  var prepareLucene = /* @__PURE__ */ __name(async (store, account2, request, messenger) => {
@@ -3423,16 +3672,16 @@ var prepareLucene = /* @__PURE__ */ __name(async (store, account2, request, mess
3423
3672
  if (request.senders !== void 0 && leaves.some(({ field }) => field === "from"))
3424
3673
  throw new CliError("validation_error", "--from and from: together \u2014 name the people once");
3425
3674
  const chosen = request.accounts ?? listed?.accounts ?? (source !== void 0 ? held.filter(({ provider }) => inSource(source, provider)) : sources.length ? held.filter(({ provider }) => sources.some((source2) => inSource(source2, provider))) : [account2]);
3426
- const unknown = chosen.filter(({ provider }) => provider !== account2.provider && kindIn(provider) === void 0);
3427
- const unknownSkipped = unknown.map(({ provider, account: account3 }) => ({
3675
+ const unknown2 = chosen.filter(({ provider }) => provider !== account2.provider && kindIn(provider) === void 0);
3676
+ const unknownSkipped = unknown2.map(({ provider, account: account3 }) => ({
3428
3677
  source: `${provider}:${account3}`,
3429
3678
  code: "not_found",
3430
3679
  reason: UNKNOWN_PROVIDER
3431
3680
  }));
3432
- if (unknown.length > 0 && unknown.length === chosen.length)
3681
+ if (unknown2.length > 0 && unknown2.length === chosen.length)
3433
3682
  throw new CliError("not_found", `this search reads nothing: ${unknownSkipped.map(({ source: source2 }) => source2).join(", ")} (${UNKNOWN_PROVIDER})`);
3434
3683
  const skipped = [...listed?.skipped ?? [], ...unknownSkipped];
3435
- const accounts = accountsOfKind(request.kind, chosen.filter((one) => !unknown.includes(one)), held, source ?? (sources.includes("email") ? "email" : sources[0]), messenger.app?.command, request.mailAccount, listed !== void 0 || request.accounts !== void 0);
3684
+ const accounts = accountsOfKind(request.kind, chosen.filter((one) => !unknown2.includes(one)), held, source ?? (sources.includes("email") ? "email" : sources[0]), messenger.app?.command, request.mailAccount, listed !== void 0 || request.accounts !== void 0);
3436
3685
  const scopeAccounts = accounts.map(({ provider, account: account3 }) => ({ provider, account: account3 }));
3437
3686
  const chatLookup = scopeAccounts.some(({ provider }) => provider === MAIL) ? withMailThreads(store) : store;
3438
3687
  const mailField = leaves.find(({ field, value }) => MAIL_FIELDS.has(field) && !(field === "is" && value.toLowerCase() === "starred" && messenger.messageStars === true));
@@ -3726,7 +3975,7 @@ var statsLucene = /* @__PURE__ */ __name(async (store, account2, request, messen
3726
3975
  };
3727
3976
  }, "statsLucene");
3728
3977
 
3729
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/moment.js
3978
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/moment.js
3730
3979
  var AGO = /^(\d+)(m|h|d)$/;
3731
3980
  var AGO_MS = { m: 6e4, h: 36e5, d: 864e5 };
3732
3981
  var DATE = /^\d{4}-\d{2}-\d{2}/;
@@ -3766,7 +4015,7 @@ var dateWindow = /* @__PURE__ */ __name(({ sinceTime, untilTime, zone, now = Dat
3766
4015
  };
3767
4016
  }, "dateWindow");
3768
4017
 
3769
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/rankings-selection.js
4018
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/rankings-selection.js
3770
4019
  var RANKING_SELECTION_BYTES = 64 * 1024;
3771
4020
  var object = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0, "object");
3772
4021
  function invalid(message = "ranking selection is invalid \u2014 obtain a new drilldown from stats top") {
@@ -3935,7 +4184,7 @@ var readRankingSelection = /* @__PURE__ */ __name(async (store, input) => {
3935
4184
  };
3936
4185
  }, "readRankingSelection");
3937
4186
 
3938
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/search-record.js
4187
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/search-record.js
3939
4188
  var canonical = /* @__PURE__ */ __name((value, nested = false) => Array.isArray(value) ? value.map((one) => canonical(one, true)) : value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0 && (nested || one !== false)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, one]) => [key, canonical(one, true)])) : value, "canonical");
3940
4189
  var searchRecordOf = /* @__PURE__ */ __name((command, params) => ({
3941
4190
  command,
@@ -3945,7 +4194,7 @@ var searchRecordOf = /* @__PURE__ */ __name((command, params) => ({
3945
4194
  fieldsVersion: FIELD_VERSION
3946
4195
  }), "searchRecordOf");
3947
4196
 
3948
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/admin-statistics.js
4197
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/admin-statistics.js
3949
4198
  function invalid2(message) {
3950
4199
  throw new CliError("validation_error", message);
3951
4200
  }
@@ -4239,7 +4488,7 @@ var adminStatisticsService = /* @__PURE__ */ __name((deps) => ({
4239
4488
  }, "evidence")
4240
4489
  }), "adminStatisticsService");
4241
4490
 
4242
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/thread.js
4491
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/thread.js
4243
4492
  var threadIdOf = /* @__PURE__ */ __name((value) => {
4244
4493
  if (value === void 0)
4245
4494
  return void 0;
@@ -4249,7 +4498,7 @@ var threadIdOf = /* @__PURE__ */ __name((value) => {
4249
4498
  return id2;
4250
4499
  }, "threadIdOf");
4251
4500
 
4252
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/questions.js
4501
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/questions.js
4253
4502
  var LINKS = /https?:\/\/\S+/g;
4254
4503
  var unanswered = /* @__PURE__ */ __name((messages, { answerers: answerers2, before: before2 }) => questions(messages, { answerers: answerers2 }).filter(({ question, answer }) => answer === void 0 && Date.parse(question.timestamp) < before2).map(({ question }) => question), "unanswered");
4255
4504
  var questions = /* @__PURE__ */ __name((messages, { answerers: answerers2 }) => {
@@ -4276,7 +4525,7 @@ var questions = /* @__PURE__ */ __name((messages, { answerers: answerers2 }) =>
4276
4525
  });
4277
4526
  }, "questions");
4278
4527
 
4279
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/chat-stats.js
4528
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/chat-stats.js
4280
4529
  var TOP_POSTS = 5;
4281
4530
  var JOINS = /* @__PURE__ */ new Set(["join", "add"]);
4282
4531
  var LEAVES = /* @__PURE__ */ new Set(["leave", "remove"]);
@@ -4293,7 +4542,7 @@ var chatStats = /* @__PURE__ */ __name((messages, { chatId, since, until, comple
4293
4542
  complete: completeness.state === "complete" && events?.more !== true,
4294
4543
  completeness,
4295
4544
  messages: held.length,
4296
- senders: sendersOf(held),
4545
+ senders: sendersOf2(held),
4297
4546
  replies: held.filter((one) => (one.replyToId ?? one.replyTo?.id) !== void 0).length,
4298
4547
  threads: held.filter((one) => replied.has(one.id) && (one.replyToId ?? one.replyTo?.id) === void 0).length,
4299
4548
  reactions: sum(held.map(reactionsOf)),
@@ -4311,7 +4560,7 @@ var chatStats = /* @__PURE__ */ __name((messages, { chatId, since, until, comple
4311
4560
  ...by ? { series: seriesOf(held, events, by, timezone) } : {}
4312
4561
  };
4313
4562
  }, "chatStats");
4314
- var sendersOf = /* @__PURE__ */ __name((messages) => new Set(messages.flatMap(({ senderId }) => senderId ?? [])).size, "sendersOf");
4563
+ var sendersOf2 = /* @__PURE__ */ __name((messages) => new Set(messages.flatMap(({ senderId }) => senderId ?? [])).size, "sendersOf");
4315
4564
  var reactionsOf = /* @__PURE__ */ __name(({ reactions }) => reactions?.total ?? 0, "reactionsOf");
4316
4565
  var counted = /* @__PURE__ */ __name((message, name) => {
4317
4566
  const value = message.providerMetadata?.[name];
@@ -4379,7 +4628,7 @@ var seriesOf = /* @__PURE__ */ __name((messages, events, by, timezone) => {
4379
4628
  return [...rows.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([key, found]) => ({
4380
4629
  key,
4381
4630
  messages: found.messages.length,
4382
- senders: sendersOf(found.messages),
4631
+ senders: sendersOf2(found.messages),
4383
4632
  ...events ? { joined: found.joined, left: found.left } : {}
4384
4633
  }));
4385
4634
  }, "seriesOf");
@@ -4393,7 +4642,7 @@ var median = /* @__PURE__ */ __name((values) => {
4393
4642
  return Math.round(sorted.length % 2 === 0 ? ((sorted[middle - 1] ?? upper) + upper) / 2 : upper);
4394
4643
  }, "median");
4395
4644
 
4396
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/member-history.js
4645
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/member-history.js
4397
4646
  var memberEvents = /* @__PURE__ */ __name((stays, revisions, since = 0) => {
4398
4647
  const events = [];
4399
4648
  for (const stay of stays) {
@@ -4425,7 +4674,7 @@ var memberEvents = /* @__PURE__ */ __name((stays, revisions, since = 0) => {
4425
4674
  return events.filter(({ at }) => Date.parse(at) >= since).sort((a, b) => Date.parse(a.at) - Date.parse(b.at) || a.id.localeCompare(b.id));
4426
4675
  }, "memberEvents");
4427
4676
 
4428
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/members-audit.js
4677
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/members-audit.js
4429
4678
  var AUDIT_PAGE = 200;
4430
4679
  var AUDIT_BUDGET = 10;
4431
4680
  var AUDIT_PAUSE_MS = 1e3;
@@ -4473,7 +4722,7 @@ var auditMembers = /* @__PURE__ */ __name((members, { firstMessages, self, minSc
4473
4722
  };
4474
4723
  }).filter(({ score }) => score >= minScore).sort((a, b) => b.score - a.score || a.id.localeCompare(b.id));
4475
4724
  const carried = /* @__PURE__ */ __name((field) => members.some((member) => member[field] !== void 0), "carried");
4476
- const unknown = [
4725
+ const unknown2 = [
4477
4726
  ...carried("isBot") ? [] : ["bot"],
4478
4727
  ...carried("flagged") ? [] : ["scam", "fake"],
4479
4728
  ...carried("deleted") ? [] : ["deleted"],
@@ -4482,7 +4731,7 @@ var auditMembers = /* @__PURE__ */ __name((members, { firstMessages, self, minSc
4482
4731
  ...carried("joinedAt") ? [] : ["burst_join"],
4483
4732
  ...carried("invitedBy") ? [] : ["mass_invited"]
4484
4733
  ];
4485
- return { items, unknown };
4734
+ return { items, unknown: unknown2 };
4486
4735
  }, "auditMembers");
4487
4736
  var burstJoins = /* @__PURE__ */ __name((members) => {
4488
4737
  const joined = members.flatMap(({ id: id2, joinedAt }) => joinedAt ? [{ id: id2, at: Date.parse(joinedAt) }] : []).sort((a, b) => a.at - b.at);
@@ -4505,7 +4754,7 @@ var burstJoins = /* @__PURE__ */ __name((members) => {
4505
4754
  return found;
4506
4755
  }, "burstJoins");
4507
4756
 
4508
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/chats.js
4757
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/chats.js
4509
4758
  var EVENTS_DAYS = 7;
4510
4759
  var TRACKED_DAYS = 30;
4511
4760
  var STATS_PAGE = 1e3;
@@ -4530,11 +4779,11 @@ var deepChecks = /* @__PURE__ */ __name(async (deps, items, deep, pauseMs, regis
4530
4779
  }
4531
4780
  if (index > 0)
4532
4781
  await new Promise((resolve7) => setTimeout(resolve7, pauseMs));
4533
- const { score, reasons, registries, unknown } = await checks.person(item.id, {
4782
+ const { score, reasons, registries, unknown: unknown2 } = await checks.person(item.id, {
4534
4783
  registries: true,
4535
4784
  ...registry ? { registry } : {}
4536
4785
  });
4537
- checked2.push({ ...item, check: { score, reasons, registries, unknown } });
4786
+ checked2.push({ ...item, check: { score, reasons, registries, unknown: unknown2 } });
4538
4787
  }
4539
4788
  return checked2;
4540
4789
  }, "deepChecks");
@@ -4643,7 +4892,7 @@ var chatsService = /* @__PURE__ */ __name((deps) => ({
4643
4892
  const { chatId: id2, members: read, more, participants } = await readMembers(connection, chat, budget, pauseMs);
4644
4893
  const held = await accountStoreIfOpen(deps);
4645
4894
  const stored = held ? await storedFacts(held, id2) : void 0;
4646
- const { items: judged, unknown } = auditMembers(read, {
4895
+ const { items: judged, unknown: unknown2 } = auditMembers(read, {
4647
4896
  firstMessages: stored?.firstMessages,
4648
4897
  self: connection.self(),
4649
4898
  minScore
@@ -4654,7 +4903,7 @@ var chatsService = /* @__PURE__ */ __name((deps) => ({
4654
4903
  read: read.length,
4655
4904
  participantsCount: participants ?? stored?.participantsCount ?? null,
4656
4905
  more,
4657
- unknown,
4906
+ unknown: unknown2,
4658
4907
  ...stored?.completeness ? { completeness: stored.completeness } : {},
4659
4908
  ...stored?.completeness && stored.completeness.state !== "complete" && syncsOneChat(deps.messenger) ? { fetch: typedCommand(deps.messenger.app.command, `messages sync ${id2}`) } : {},
4660
4909
  items
@@ -4800,7 +5049,7 @@ var storedMembers = /* @__PURE__ */ __name(async (store, chatId) => {
4800
5049
  return members.length === 0 ? null : members;
4801
5050
  }, "storedMembers");
4802
5051
 
4803
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/task-categories.js
5052
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/task-categories.js
4804
5053
  var names = /* @__PURE__ */ __name((categories) => categories.map(({ name }) => name).join(", "), "names");
4805
5054
  var taskCategoryOf = /* @__PURE__ */ __name((categories = DEFAULT_TASK_CATEGORIES, flag = "--category") => (typed) => {
4806
5055
  const name = typed.trim().toLowerCase();
@@ -4850,7 +5099,7 @@ var categorize = /* @__PURE__ */ __name((text2, categories = DEFAULT_TASK_CATEGO
4850
5099
  return best.name;
4851
5100
  }, "categorize");
4852
5101
 
4853
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/task-rules.js
5102
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/task-rules.js
4854
5103
  var taskAccount = /* @__PURE__ */ __name(({ provider, account: account2 }) => `${provider}:${account2}`, "taskAccount");
4855
5104
  var RULES_IN = {
4856
5105
  dialog: "all",
@@ -5056,7 +5305,7 @@ var applyTaskRulesToChats = /* @__PURE__ */ __name(async (store, account2, chatI
5056
5305
  return passes;
5057
5306
  }, "applyTaskRulesToChats");
5058
5307
 
5059
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/task-tag-filters.js
5308
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/task-tag-filters.js
5060
5309
  var taskTagFilters = /* @__PURE__ */ __name(async (store, query) => {
5061
5310
  const tags = /* @__PURE__ */ new Map();
5062
5311
  for (const node of query ? walkQuery(query.root) : [])
@@ -5065,7 +5314,7 @@ var taskTagFilters = /* @__PURE__ */ __name(async (store, query) => {
5065
5314
  return tags;
5066
5315
  }, "taskTagFilters");
5067
5316
 
5068
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/agenda.js
5317
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/agenda.js
5069
5318
  var DAY2 = 864e5;
5070
5319
  var CLAIMS = ["none", "mine", "others", "any"];
5071
5320
  var TASK_FIELDS = /* @__PURE__ */ new Set(["tag", "category", "claimed"]);
@@ -5153,8 +5402,8 @@ var agendaService = /* @__PURE__ */ __name((deps, now = Date.now) => ({
5153
5402
  waiting: chats.filter((chat) => chat.lastFromOwner === true && silentFor(chat) >= waiting),
5154
5403
  unsynced: chats.filter((chat) => chat.lastMessage === null)
5155
5404
  };
5156
- const covered = new Map((await chatCoverage(store, account2, Object.values(shown).flatMap((list2) => list2.map(({ chatId }) => chatId)))).map((one) => [one.chatId, one]));
5157
- const withCoverage = /* @__PURE__ */ __name((list2) => list2.map((chat) => ({ ...chat, coverage: covered.get(chat.chatId) })), "withCoverage");
5405
+ const covered = new Map((await chatCoverage(store, account2, Object.values(shown).flatMap((list3) => list3.map(({ chatId }) => chatId)))).map((one) => [one.chatId, one]));
5406
+ const withCoverage = /* @__PURE__ */ __name((list3) => list3.map((chat) => ({ ...chat, coverage: covered.get(chat.chatId) })), "withCoverage");
5158
5407
  const inList = new Set((await store.tasks.categories()).map(({ name }) => name));
5159
5408
  const unlisted = /* @__PURE__ */ new Map();
5160
5409
  for (const { category } of open7)
@@ -5307,10 +5556,10 @@ var agendaItem = /* @__PURE__ */ __name((shown) => {
5307
5556
  };
5308
5557
  }, "agendaItem");
5309
5558
 
5310
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/archive.js
5559
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/archive.js
5311
5560
  import { setTimeout as sleep3 } from "node:timers/promises";
5312
5561
 
5313
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/backfill-estimate.js
5562
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/backfill-estimate.js
5314
5563
  var REQUEST_MS = 400;
5315
5564
  var estimateBackfill = /* @__PURE__ */ __name(({ ranges, held, newest, page, maxPages, pauseMs }) => {
5316
5565
  const lowest = ranges[0];
@@ -5333,13 +5582,13 @@ var estimateBackfill = /* @__PURE__ */ __name(({ ranges, held, newest, page, max
5333
5582
  };
5334
5583
  }, "estimateBackfill");
5335
5584
 
5336
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/recovery.js
5585
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/recovery.js
5337
5586
  var withRecovery = /* @__PURE__ */ __name((error) => ({
5338
5587
  ...error,
5339
5588
  retryable: typeof error.retryable === "boolean" ? error.retryable : error.code === "rate_limited" || error.status === 429
5340
5589
  }), "withRecovery");
5341
5590
 
5342
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/batch.js
5591
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/batch.js
5343
5592
  var actionable = /* @__PURE__ */ __name((error) => {
5344
5593
  if (isCliFailure(error))
5345
5594
  return withRecovery({ code: error.code, message: error.message, ...error.details });
@@ -5422,7 +5671,7 @@ var mergeBatches = /* @__PURE__ */ __name((a, b) => {
5422
5671
  };
5423
5672
  }, "mergeBatches");
5424
5673
 
5425
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/patience.js
5674
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/patience.js
5426
5675
  import { setTimeout as sleep2 } from "node:timers/promises";
5427
5676
  var LONGEST_WAIT_MS = 5 * 60 * 1e3;
5428
5677
  var patiently = /* @__PURE__ */ __name(async (request, note, stop) => {
@@ -5445,7 +5694,7 @@ var patiently = /* @__PURE__ */ __name(async (request, note, stop) => {
5445
5694
  }
5446
5695
  }, "patiently");
5447
5696
 
5448
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/conversations/link.js
5697
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/conversations/link.js
5449
5698
  var RULES_VERSION = 5;
5450
5699
  var LOOK_BACK = 50;
5451
5700
  var SAME_SENDER_WITHIN = 10;
@@ -5535,7 +5784,7 @@ var latest = /* @__PURE__ */ __name((window2, matches) => {
5535
5784
  var sameThread = /* @__PURE__ */ __name((a, b) => a.threadId === b.threadId, "sameThread");
5536
5785
  var link2 = /* @__PURE__ */ __name((message, parentId, source, kind, confidence, method) => ({ messageId: message.id, parentId, source, kind, confidence, method }), "link");
5537
5786
 
5538
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/images/context/index.js
5787
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/images/context/index.js
5539
5788
  var CONTEXT_MESSAGES = 3;
5540
5789
  var CONTEXT_MINUTES = 10;
5541
5790
  var MAX_CHARS = 1200;
@@ -5559,12 +5808,12 @@ var context = {
5559
5808
  }, "describe")
5560
5809
  };
5561
5810
 
5562
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/images/registry.js
5811
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/images/registry.js
5563
5812
  var BUILT_INS = [context];
5564
5813
  var providers = [...BUILT_INS];
5565
5814
  var registeredImageProviders = /* @__PURE__ */ __name(() => providers, "registeredImageProviders");
5566
5815
 
5567
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/conversations.js
5816
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/conversations.js
5568
5817
  var READ_PAGE = 5e3;
5569
5818
  var CHAIN = 50;
5570
5819
  var CONVERSATION_QUERY = {
@@ -5716,7 +5965,7 @@ var sized = /* @__PURE__ */ __name((size4) => {
5716
5965
  return size4;
5717
5966
  }, "sized");
5718
5967
 
5719
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/embeddings-maintenance.js
5968
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/embeddings-maintenance.js
5720
5969
  var REFRESH_BOUNDS = { maxChats: 20, maxChunks: 2e3 };
5721
5970
  var MESSAGE_PAGE = 5e3;
5722
5971
  var PER_SESSION = 8;
@@ -5735,7 +5984,7 @@ var embeddingTarget = /* @__PURE__ */ __name((deps, choice = DEFAULT_TEXT_MODEL)
5735
5984
  price: remote.price,
5736
5985
  installed: true,
5737
5986
  perBatch: PER_REQUEST * concurrency,
5738
- open: /* @__PURE__ */ __name(async () => (await import("./remote-AGIJY73X.js")).openRemote(remote, apiKey, { concurrency }), "open")
5987
+ open: /* @__PURE__ */ __name(async () => (await import("./remote-H5ZWLJHR.js")).openRemote(remote, apiKey, { concurrency }), "open")
5739
5988
  };
5740
5989
  }
5741
5990
  const model = textModel(choice);
@@ -5752,7 +6001,7 @@ var embeddingTarget = /* @__PURE__ */ __name((deps, choice = DEFAULT_TEXT_MODEL)
5752
6001
  if (!isTextModelInstalled(model, directory))
5753
6002
  throw notDownloaded(model.id);
5754
6003
  if (apart) {
5755
- const { openProcess } = await import("./process-ZXO2MWRJ.js");
6004
+ const { openProcess } = await import("./process-P6TW37HQ.js");
5756
6005
  return openProcess(model, directory, { threads: threads ?? defaultThreads() });
5757
6006
  }
5758
6007
  return openEmbedder(model, directory, { threads: threads ?? defaultThreads() });
@@ -6041,7 +6290,7 @@ var shaped = /* @__PURE__ */ __name(({ chatId, builtAt, algorithmVersion, pendin
6041
6290
  return { ...one, state };
6042
6291
  }, "shaped");
6043
6292
 
6044
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/search-catchup.js
6293
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/search-catchup.js
6045
6294
  var CATCH_UP_BOUNDS = { maxChunks: 500, maxMessages: 1e4, timeMs: 3e4 };
6046
6295
  var validateCatchUpBounds = /* @__PURE__ */ __name((options) => {
6047
6296
  for (const [key, value, maximum] of [
@@ -6094,7 +6343,7 @@ var catchUpSearch = /* @__PURE__ */ __name(async (deps, chat, options, signal, c
6094
6343
  }
6095
6344
  }, "catchUpSearch");
6096
6345
 
6097
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/archive.js
6346
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/archive.js
6098
6347
  var pushed = /* @__PURE__ */ __name((deps, what) => {
6099
6348
  if (deps.reads === "store") {
6100
6349
  throw new CliError("validation_error", `${what} asks for older history, and this messenger pushes its history instead \u2014 keep \`${typedCommand(deps.messenger.app.command, "serve")}\` running`);
@@ -6205,10 +6454,10 @@ var archiveService = /* @__PURE__ */ __name((deps) => {
6205
6454
  return deps.withConnection((adapter) => archiveService({ ...deps, withConnection: void 0, connection: /* @__PURE__ */ __name(async () => adapter, "connection") }).fetchAll(options));
6206
6455
  pushed(deps, "`messages sync --all`");
6207
6456
  const connection = await deps.connection();
6208
- const list2 = capability(connection, "chats", "list its chats");
6457
+ const list3 = capability(connection, "chats", "list its chats");
6209
6458
  const chats = [];
6210
6459
  for (let offset = 0; ; ) {
6211
- const page = await patiently(() => list2({ offset, limit: 100 }), options.note, options.stop);
6460
+ const page = await patiently(() => list3({ offset, limit: 100 }), options.note, options.stop);
6212
6461
  chats.push(...page.items);
6213
6462
  offset += page.items.length;
6214
6463
  if (!page.hasMore || page.items.length === 0)
@@ -6223,6 +6472,8 @@ var archiveService = /* @__PURE__ */ __name((deps) => {
6223
6472
  ...options,
6224
6473
  catchUp: catchingUp ? options.catchUp ?? {} : false
6225
6474
  });
6475
+ const finished = /* @__PURE__ */ __name(() => options.onChat?.({ chats: chats.length, done: answer.items.length, fetched: answer.fetched }), "finished");
6476
+ finished();
6226
6477
  for (const chat of chats) {
6227
6478
  if (options.stop.aborted || batch.stopped) {
6228
6479
  answer.stopped = true;
@@ -6230,6 +6481,7 @@ var archiveService = /* @__PURE__ */ __name((deps) => {
6230
6481
  }
6231
6482
  if (await upToDate(chat)) {
6232
6483
  answer.items.push({ chat: chat.id, title: chat.title, fetched: 0, complete: true, current: true });
6484
+ finished();
6233
6485
  continue;
6234
6486
  }
6235
6487
  try {
@@ -6256,6 +6508,7 @@ var archiveService = /* @__PURE__ */ __name((deps) => {
6256
6508
  const issue = batch.fail(chat.id, "history", error);
6257
6509
  answer.items.push({ chat: chat.id, title: chat.title, fetched: 0, complete: false, error: issue.code, issue });
6258
6510
  }
6511
+ finished();
6259
6512
  }
6260
6513
  if (batch.failed > 0)
6261
6514
  answer.batch = batch.result();
@@ -6411,7 +6664,7 @@ var timeOfKey = /* @__PURE__ */ __name(async (store, account2, chatId, key, byTi
6411
6664
  return message?.timestamp ?? fallback;
6412
6665
  }, "timeOfKey");
6413
6666
 
6414
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/archive-gaps.js
6667
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/archive-gaps.js
6415
6668
  import { createHash as createHash6, randomUUID as randomUUID4 } from "node:crypto";
6416
6669
  var GAP_BOUNDS = { maxGaps: 5, limit: 500, timeMs: 3e4 };
6417
6670
  var validateRepair = /* @__PURE__ */ __name((messenger, options) => {
@@ -6444,7 +6697,7 @@ var gapsService = /* @__PURE__ */ __name((deps) => {
6444
6697
  });
6445
6698
  const knownStart = await store.sync.syncState(account2, historyStartKey(chatId));
6446
6699
  const start = knownStart === null ? NaN : Number(knownStart?.value);
6447
- const unknown = { older: !Number.isSafeInteger(start) || !held[0] || held[0].from > start, newer: true };
6700
+ const unknown2 = { older: !Number.isSafeInteger(start) || !held[0] || held[0].from > start, newer: true };
6448
6701
  const identity = { account: account2, chat: chatId, ordering, held };
6449
6702
  return {
6450
6703
  version: 1,
@@ -6452,7 +6705,7 @@ var gapsService = /* @__PURE__ */ __name((deps) => {
6452
6705
  ...identity,
6453
6706
  limits: { ...GAP_BOUNDS, pageSize: (deps.messenger.fetching ?? FETCHING).page },
6454
6707
  gaps,
6455
- unknown,
6708
+ unknown: unknown2,
6456
6709
  fingerprint: createHash6("sha256").update(JSON.stringify(identity)).digest("hex")
6457
6710
  };
6458
6711
  }, "plan");
@@ -6548,16 +6801,16 @@ var gapsService = /* @__PURE__ */ __name((deps) => {
6548
6801
  return { plan, repair };
6549
6802
  }, "gapsService");
6550
6803
 
6551
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/attachments.js
6804
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/attachments.js
6552
6805
  import { createHash as createHash8 } from "node:crypto";
6553
6806
  import { constants as constants2 } from "node:fs";
6554
6807
  import { open as open6, readFile, stat as stat2 } from "node:fs/promises";
6555
6808
 
6556
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/attachments/directory.js
6809
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/attachments/directory.js
6557
6810
  import { lstat as lstat2, readdir as readdir2, realpath as realpath3 } from "node:fs/promises";
6558
6811
  import { basename as basename4, join as join8, relative as relative2, sep as sep2 } from "node:path";
6559
6812
 
6560
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/sends/upload.js
6813
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/sends/upload.js
6561
6814
  import { openAsBlob, realpathSync } from "node:fs";
6562
6815
  import { open as open4, stat } from "node:fs/promises";
6563
6816
  import { basename as basename3, dirname as dirname3, extname, isAbsolute as isAbsolute2, relative, resolve as resolve5, sep } from "node:path";
@@ -6576,13 +6829,13 @@ var SIGNATURES = {
6576
6829
  }, ".webp")
6577
6830
  };
6578
6831
  var fileHead = /* @__PURE__ */ __name(async (path) => {
6579
- const file = await open4(path, "r");
6832
+ const file2 = await open4(path, "r");
6580
6833
  try {
6581
6834
  const head = new Uint8Array(12);
6582
- const { bytesRead } = await file.read(head, 0, head.length, 0);
6835
+ const { bytesRead } = await file2.read(head, 0, head.length, 0);
6583
6836
  return head.subarray(0, bytesRead);
6584
6837
  } finally {
6585
- await file.close();
6838
+ await file2.close();
6586
6839
  }
6587
6840
  }, "fileHead");
6588
6841
  var typesText = /* @__PURE__ */ __name((types2) => types2.length < 2 ? types2[0] ?? "" : `${types2.slice(0, -1).join(", ")} or ${types2.at(-1)}`, "typesText");
@@ -6676,7 +6929,7 @@ var refusedPlace = /* @__PURE__ */ __name((path, app, env, platform = process.pl
6676
6929
  return names2.some((name, index) => parts.has(name) || /^\.env\./.test(name) || runs.some((run) => run.every((part, offset) => names2[index + offset] === part)));
6677
6930
  }, "named");
6678
6931
  const same2 = /* @__PURE__ */ __name((a, b) => fold2(a) === fold2(b), "same");
6679
- return [resolve5(path), real].some((candidate) => named2(candidate) || own.some((dir) => inside(fold2(candidate), fold2(dir))) || [store, `${store}-wal`, `${store}-shm`].some((file) => same2(candidate, file)));
6932
+ return [resolve5(path), real].some((candidate) => named2(candidate) || own.some((dir) => inside(fold2(candidate), fold2(dir))) || [store, `${store}-wal`, `${store}-shm`].some((file2) => same2(candidate, file2)));
6680
6933
  }, "refusedPlace");
6681
6934
  var inside = /* @__PURE__ */ __name((path, dir) => {
6682
6935
  const way = relative(resolve5(dir), path);
@@ -6724,9 +6977,9 @@ var checkFilename = /* @__PURE__ */ __name((filename, files) => {
6724
6977
  throw new CliError("validation_error", "--filename is a name, not a path: no / or \\, at most 255 characters");
6725
6978
  }, "checkFilename");
6726
6979
  var listOf = /* @__PURE__ */ __name((value) => value === void 0 ? [] : typeof value === "string" ? [value] : value, "listOf");
6727
- var readAttachments = /* @__PURE__ */ __name(async ({ photo, file, voice, asFile, filename, text: text2 }, read) => {
6980
+ var readAttachments = /* @__PURE__ */ __name(async ({ photo, file: file2, voice, asFile, filename, text: text2 }, read) => {
6728
6981
  const photos = listOf(photo);
6729
- const files = listOf(file);
6982
+ const files = listOf(file2);
6730
6983
  if (voice !== void 0 && (photos.length > 0 || files.length > 0 || (text2 ?? "").trim() !== "")) {
6731
6984
  throw new CliError("validation_error", "a voice message goes alone \u2014 no text, no file, no photo beside it");
6732
6985
  }
@@ -6759,7 +7012,7 @@ var readStickerFile = /* @__PURE__ */ __name(async (path, maxBytes, read) => {
6759
7012
  return { name, source };
6760
7013
  }, "readStickerFile");
6761
7014
 
6762
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/attachments/directory.js
7015
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/attachments/directory.js
6763
7016
  var MAX_FILES = 1e4;
6764
7017
  var directoryPaths = /* @__PURE__ */ __name(async (store, chat, directory, app, env) => {
6765
7018
  if (refusedPlace(directory, app, env))
@@ -6793,30 +7046,30 @@ var directoryPaths = /* @__PURE__ */ __name(async (store, chat, directory, app,
6793
7046
  throw new CliError("validation_error", "this chat holds too many attachments for directory matching; use recorded download paths");
6794
7047
  const groups = /* @__PURE__ */ new Map();
6795
7048
  const counts = /* @__PURE__ */ new Map();
6796
- for (const file of held.filter(({ kind }) => !NOT_FILES.has(kind))) {
6797
- const group = groups.get(file.messageId) ?? [];
6798
- group.push(file);
6799
- groups.set(file.messageId, group);
6800
- if (file.name)
6801
- counts.set(basename4(file.name), (counts.get(basename4(file.name)) ?? 0) + 1);
7049
+ for (const file2 of held.filter(({ kind }) => !NOT_FILES.has(kind))) {
7050
+ const group = groups.get(file2.messageId) ?? [];
7051
+ group.push(file2);
7052
+ groups.set(file2.messageId, group);
7053
+ if (file2.name)
7054
+ counts.set(basename4(file2.name), (counts.get(basename4(file2.name)) ?? 0) + 1);
6802
7055
  }
6803
7056
  const choices = /* @__PURE__ */ new Map();
6804
7057
  for (const group of groups.values()) {
6805
7058
  group.sort((a, b) => a.position - b.position);
6806
- const candidates = group.map((file, index) => {
6807
- const prefix = `${file.messageId}-${index + 1}`;
6808
- return [...files].filter(([name]) => name === prefix || name.startsWith(`${prefix}.`) || file.name !== null && name === `${prefix}-${basename4(file.name)}`).map(([, path]) => path);
7059
+ const candidates = group.map((file2, index) => {
7060
+ const prefix = `${file2.messageId}-${index + 1}`;
7061
+ return [...files].filter(([name]) => name === prefix || name.startsWith(`${prefix}.`) || file2.name !== null && name === `${prefix}-${basename4(file2.name)}`).map(([, path]) => path);
6809
7062
  });
6810
7063
  if (candidates.some((paths) => paths.length > 1))
6811
7064
  throw new CliError("validation_error", "more than one directory file matches a download ordinal");
6812
7065
  const complete = candidates.every((paths) => paths.length === 1);
6813
- group.forEach((file, index) => {
6814
- const own = file.name === null ? void 0 : basename4(file.name);
7066
+ group.forEach((file2, index) => {
7067
+ const own = file2.name === null ? void 0 : basename4(file2.name);
6815
7068
  const named2 = own && counts.get(own) === 1 ? files.get(own) : void 0;
6816
7069
  const canonical2 = complete ? candidates[index]?.[0] : void 0;
6817
7070
  if (named2 && canonical2 && named2 !== canonical2 || !complete && own && files.has(own) && (counts.get(own) ?? 0) > 1)
6818
7071
  throw new CliError("validation_error", "directory file names are ambiguous; use complete message-prefixed downloads");
6819
- choices.set(file.pk, canonical2 ?? named2 ?? null);
7072
+ choices.set(file2.pk, canonical2 ?? named2 ?? null);
6820
7073
  });
6821
7074
  }
6822
7075
  const uses = /* @__PURE__ */ new Map();
@@ -7869,7 +8122,7 @@ function imageSize(input) {
7869
8122
  }
7870
8123
  __name(imageSize, "imageSize");
7871
8124
 
7872
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/attachments/ocr.js
8125
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/attachments/ocr.js
7873
8126
  var MAX_PAGES = 20;
7874
8127
  var MAX_PIXELS = 2e7;
7875
8128
  var cancelled = /* @__PURE__ */ __name((signal) => {
@@ -8020,7 +8273,7 @@ var ocrPdf = /* @__PURE__ */ __name(async (bytes2, pipeline2, load, signal) => {
8020
8273
  }
8021
8274
  }, "ocrPdf");
8022
8275
 
8023
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/attachments/pdf-preview.js
8276
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/attachments/pdf-preview.js
8024
8277
  var pdfPreview = /* @__PURE__ */ __name(async (bytes2, page, signal, load = importEngine, env = process.env) => {
8025
8278
  const limits = pdfPreviewLimits(env);
8026
8279
  const cancelled4 = /* @__PURE__ */ __name(() => {
@@ -8097,7 +8350,7 @@ var pdfPreview = /* @__PURE__ */ __name(async (bytes2, page, signal, load = impo
8097
8350
  }
8098
8351
  }, "pdfPreview");
8099
8352
 
8100
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/attachments/transfer.js
8353
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/attachments/transfer.js
8101
8354
  import { createHash as createHash7 } from "node:crypto";
8102
8355
  import { constants } from "node:fs";
8103
8356
  import { lstat as lstat3, open as open5 } from "node:fs/promises";
@@ -8205,7 +8458,7 @@ var transferMime = /* @__PURE__ */ __name((head, hint, name = null) => {
8205
8458
  return hint !== null && /^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(hint) ? hint : "application/octet-stream";
8206
8459
  }, "transferMime");
8207
8460
 
8208
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/attachments.js
8461
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/attachments.js
8209
8462
  var ATTACHMENT_QUERY = {
8210
8463
  entity: "attachment",
8211
8464
  backend: "sql",
@@ -8224,7 +8477,7 @@ var ATTACHMENT_QUERY = {
8224
8477
  })
8225
8478
  };
8226
8479
  var PAGE3 = 200;
8227
- var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow = false, ocr, env = process.env) => {
8480
+ var outcome = /* @__PURE__ */ __name(async (file2, path, load, signal, noFollow = false, ocr, env = process.env) => {
8228
8481
  const maxBytes = attachmentMaxBytes(env);
8229
8482
  const tooLarge2 = /* @__PURE__ */ __name(() => ({
8230
8483
  status: "too-large",
@@ -8237,7 +8490,7 @@ var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow =
8237
8490
  const size4 = await stat2(path).then((found) => found.isFile() ? found.size : void 0, () => void 0);
8238
8491
  if (size4 === void 0)
8239
8492
  return { status: "missing" };
8240
- const hint = { kind: file.kind, name: file.name, mime: file.mime, path };
8493
+ const hint = { kind: file2.kind, name: file2.name, mime: file2.mime, path };
8241
8494
  const known2 = classify(hint);
8242
8495
  if (known2 === "unsupported")
8243
8496
  return { status: "unsupported" };
@@ -8259,7 +8512,7 @@ var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow =
8259
8512
  const isPdf = Buffer.from(bytes2.subarray(0, 5)).toString() === "%PDF-";
8260
8513
  const ocrCandidate = ocr !== void 0 && (known2 === "image" || isPdf);
8261
8514
  const localKind = documentKind(hint);
8262
- if (file.read?.origin === "extracted" && file.read.contentSha256 === sha && (!localKind || file.read.extractor === documentExtractor(localKind)) && (file.read.error === null || !ocrCandidate && file.read.error === "no_text") && (!ocrCandidate || file.read.extractor === ocr?.extractor && file.read.error === null))
8515
+ if (file2.read?.origin === "extracted" && file2.read.contentSha256 === sha && (!localKind || file2.read.extractor === documentExtractor(localKind)) && (file2.read.error === null || !ocrCandidate && file2.read.error === "no_text") && (!ocrCandidate || file2.read.extractor === ocr?.extractor && file2.read.error === null))
8263
8516
  return { status: "unchanged" };
8264
8517
  if (ocr && ocrCandidate) {
8265
8518
  const extraction2 = known2 === "image" ? await ocrImage(bytes2, ocr, signal) : await ocrPdf(bytes2, ocr, load, signal);
@@ -8270,23 +8523,23 @@ var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow =
8270
8523
  const extraction = await extractText(bytes2, hint, load, signal, env);
8271
8524
  return { status: extraction.status, extraction, bytes: size4, sha };
8272
8525
  }, "outcome");
8273
- var keep = /* @__PURE__ */ __name(async (store, file, extraction, bytes2, sha) => {
8526
+ var keep = /* @__PURE__ */ __name(async (store, file2, extraction, bytes2, sha) => {
8274
8527
  const base = { origin: "extracted", contentSha256: sha, bytes: bytes2 };
8275
8528
  if (extraction.status === "extracted") {
8276
- return store.attachments.keepAttachmentText(file.pk, {
8529
+ return store.attachments.keepAttachmentText(file2.pk, {
8277
8530
  ...base,
8278
8531
  text: extraction.text,
8279
8532
  extractor: extraction.extractor
8280
8533
  });
8281
8534
  } else if (extraction.status === "unreadable") {
8282
- return store.attachments.keepAttachmentText(file.pk, {
8535
+ return store.attachments.keepAttachmentText(file2.pk, {
8283
8536
  ...base,
8284
8537
  text: "",
8285
8538
  extractor: extraction.extractor,
8286
8539
  error: extraction.error
8287
8540
  });
8288
8541
  } else if (extraction.status === "needs-agent" && extraction.extractor) {
8289
- return store.attachments.keepAttachmentText(file.pk, {
8542
+ return store.attachments.keepAttachmentText(file2.pk, {
8290
8543
  ...base,
8291
8544
  text: "",
8292
8545
  extractor: extraction.extractor,
@@ -8364,9 +8617,9 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8364
8617
  let scanned = 0;
8365
8618
  const pending = [];
8366
8619
  const finished = /* @__PURE__ */ new Map();
8367
- const processFile = /* @__PURE__ */ __name(async (file, path) => {
8368
- deps.guard.check({ chatId: file.chatId, key: "attachments.extract" }, { reserve: false });
8369
- const { status, extraction, bytes: bytes2, sha, issue: limitIssue } = await outcome(file, path, load, signal, fromDir !== void 0, ocr, deps.env);
8620
+ const processFile = /* @__PURE__ */ __name(async (file2, path) => {
8621
+ deps.guard.check({ chatId: file2.chatId, key: "attachments.extract" }, { reserve: false });
8622
+ const { status, extraction, bytes: bytes2, sha, issue: limitIssue } = await outcome(file2, path, load, signal, fromDir !== void 0, ocr, deps.env);
8370
8623
  if (status === "unchanged") {
8371
8624
  run.unchanged += 1;
8372
8625
  return;
@@ -8379,8 +8632,8 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8379
8632
  run.complete = false;
8380
8633
  return;
8381
8634
  }
8382
- if (extraction && bytes2 !== void 0 && (!ocr || status === "extracted") && (status === "extracted" || file.read?.error !== null)) {
8383
- if (await keep(store, file, extraction, bytes2, sha) === false) {
8635
+ if (extraction && bytes2 !== void 0 && (!ocr || status === "extracted") && (status === "extracted" || file2.read?.error !== null)) {
8636
+ if (await keep(store, file2, extraction, bytes2, sha) === false) {
8384
8637
  run.unchanged += 1;
8385
8638
  read += 1;
8386
8639
  return;
@@ -8398,14 +8651,14 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8398
8651
  run.failed += 1;
8399
8652
  let issue;
8400
8653
  if (["missing", "too-large", "engine-missing", "unreadable"].includes(status)) {
8401
- issue = batch.fail(formatLocator({ ...account2, chat: file.chatId, message: file.messageId }), "extract", limitIssue ?? (extraction?.status === "unreadable" && extraction.issue ? extraction.issue : new CliError(status === "missing" ? "not_found" : "validation_error", status === "too-large" ? "attachment exceeds an extraction, decompression or OCR size limit" : extraction?.status === "engine-missing" ? `attachment engine-missing; ${engineMissing(extraction.engine)}; \`doctor\` lists the readers` : `attachment ${status}; retry or skip this item`, { limit_source: ocr ? "provider" : "local" })), file.position + 1);
8654
+ issue = batch.fail(formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }), "extract", limitIssue ?? (extraction?.status === "unreadable" && extraction.issue ? extraction.issue : new CliError(status === "missing" ? "not_found" : "validation_error", status === "too-large" ? "attachment exceeds an extraction, decompression or OCR size limit" : extraction?.status === "engine-missing" ? `attachment engine-missing; ${engineMissing(extraction.engine)}; \`doctor\` lists the readers` : `attachment ${status}; retry or skip this item`, { limit_source: ocr ? "provider" : "local" })), file2.position + 1);
8402
8655
  } else
8403
8656
  batch.ok();
8404
8657
  const item = {
8405
- ref: formatLocator({ ...account2, chat: file.chatId, message: file.messageId }),
8406
- attachment: file.position + 1,
8407
- kind: file.kind,
8408
- name: file.name,
8658
+ ref: formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }),
8659
+ attachment: file2.position + 1,
8660
+ kind: file2.kind,
8661
+ name: file2.name,
8409
8662
  status,
8410
8663
  ...issue ? { issue } : {},
8411
8664
  ...status === "needs-agent" ? { localPath: path } : {},
@@ -8416,22 +8669,22 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8416
8669
  ...extraction.pages === void 0 ? {} : { pages: extraction.pages, ocrPages: extraction.ocrPages }
8417
8670
  } : {}
8418
8671
  };
8419
- finished.set(file.pk, item);
8672
+ finished.set(file2.pk, item);
8420
8673
  onItem?.(item);
8421
8674
  }, "processFile");
8422
- const failedItem = /* @__PURE__ */ __name((file, stage, error) => {
8423
- const issue = batch.fail(formatLocator({ ...account2, chat: file.chatId, message: file.messageId }), stage, error, file.position + 1);
8675
+ const failedItem = /* @__PURE__ */ __name((file2, stage, error) => {
8676
+ const issue = batch.fail(formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }), stage, error, file2.position + 1);
8424
8677
  run.failed += 1;
8425
8678
  const item = {
8426
- ref: formatLocator({ ...account2, chat: file.chatId, message: file.messageId }),
8427
- attachment: file.position + 1,
8428
- kind: file.kind,
8429
- name: file.name,
8679
+ ref: formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }),
8680
+ attachment: file2.position + 1,
8681
+ kind: file2.kind,
8682
+ name: file2.name,
8430
8683
  status: "unreadable",
8431
8684
  error: issue.code,
8432
8685
  issue
8433
8686
  };
8434
- finished.set(file.pk, item);
8687
+ finished.set(file2.pk, item);
8435
8688
  onItem?.(item);
8436
8689
  }, "failedItem");
8437
8690
  try {
@@ -8442,7 +8695,7 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8442
8695
  ...beforePk === void 0 ? {} : { beforePk },
8443
8696
  limit: PAGE3
8444
8697
  });
8445
- for (const file of page) {
8698
+ for (const file2 of page) {
8446
8699
  while (pending.length && (pending.length >= concurrency || limit !== void 0 && read + pending.length >= limit))
8447
8700
  await pending.shift();
8448
8701
  if (batch.stopped || signal?.aborted || limit !== void 0 && read >= limit || scanLimit !== void 0 && scanned >= scanLimit) {
@@ -8451,31 +8704,31 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8451
8704
  run.cursor = String(beforePk);
8452
8705
  break walk;
8453
8706
  }
8454
- beforePk = file.pk;
8707
+ beforePk = file2.pk;
8455
8708
  scanned += 1;
8456
- let path = directory === void 0 ? file.localPath : directory.get(file.pk) ?? null;
8709
+ let path = directory === void 0 ? file2.localPath : directory.get(file2.pk) ?? null;
8457
8710
  if (directory && path)
8458
- await store.attachments.keepDownloads(file.chatId, file.messageId, [
8459
- { kind: file.kind, position: file.position, path }
8711
+ await store.attachments.keepDownloads(file2.chatId, file2.messageId, [
8712
+ { kind: file2.kind, position: file2.position, path }
8460
8713
  ]);
8461
8714
  if (selected && (path === null || !selected.has(path)))
8462
8715
  continue;
8463
- const message = `${file.chatId}/${file.messageId}`;
8716
+ const message = `${file2.chatId}/${file2.messageId}`;
8464
8717
  if (path === null && download && !fetched.has(message)) {
8465
8718
  fetched.add(message);
8466
8719
  try {
8467
- await download(file.chatId, file.messageId);
8720
+ await download(file2.chatId, file2.messageId);
8468
8721
  } catch (error) {
8469
- failedItem(file, "download", error);
8722
+ failedItem(file2, "download", error);
8470
8723
  }
8471
- path = await store.attachments.localPathOf(file.pk);
8724
+ path = await store.attachments.localPathOf(file2.pk);
8472
8725
  }
8473
8726
  if (path === null) {
8474
8727
  run.notDownloaded += 1;
8475
8728
  continue;
8476
8729
  }
8477
- const task2 = processFile(file, path).catch((error) => {
8478
- failedItem(file, "extract", error);
8730
+ const task2 = processFile(file2, path).catch((error) => {
8731
+ failedItem(file2, "extract", error);
8479
8732
  });
8480
8733
  void task2.catch(() => {
8481
8734
  });
@@ -8586,7 +8839,7 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
8586
8839
  }, "setText")
8587
8840
  }), "attachmentsService");
8588
8841
 
8589
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/chat-documents.js
8842
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/chat-documents.js
8590
8843
  var chatDocumentsService = /* @__PURE__ */ __name((deps) => ({
8591
8844
  list: /* @__PURE__ */ __name(async (chat, { limit, offset, ref }) => {
8592
8845
  const store = await accountStore(deps);
@@ -8616,7 +8869,7 @@ var chatDocumentsService = /* @__PURE__ */ __name((deps) => ({
8616
8869
  }, "list")
8617
8870
  }), "chatDocumentsService");
8618
8871
 
8619
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/retention.js
8872
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/retention.js
8620
8873
  var observationDuration = /* @__PURE__ */ __name((text2, flag) => {
8621
8874
  const match = /^(\d+(?:\.\d+)?)([smhdw])$/.exec(text2);
8622
8875
  const units2 = { s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
@@ -8703,7 +8956,7 @@ var isRetentionSelection = /* @__PURE__ */ __name((selection) => {
8703
8956
  }
8704
8957
  }, "isRetentionSelection");
8705
8958
 
8706
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/counters.js
8959
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/counters.js
8707
8960
  var counterFields = /* @__PURE__ */ __name((text2 = "views,reactions,comments") => {
8708
8961
  const fields = text2.split(",").map((one) => one.trim());
8709
8962
  if (!fields.length || fields.some((one) => !COUNTER_FIELDS.includes(one)) || new Set(fields).size !== fields.length)
@@ -8910,7 +9163,7 @@ var countersService = /* @__PURE__ */ __name((deps) => {
8910
9163
  };
8911
9164
  }, "countersService");
8912
9165
 
8913
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/search-refresh.js
9166
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/search-refresh.js
8914
9167
  var SYNC_KEY = "messages.sync-first";
8915
9168
  var SYNC_BOUNDS = { maxChats: 5, timeMs: 3e4, maxMessages: 500 };
8916
9169
  var keyOf2 = /* @__PURE__ */ __name((chat) => JSON.stringify([chat.account.provider, chat.account.account, chat.chatId]), "keyOf");
@@ -9042,7 +9295,7 @@ var withRefresh = /* @__PURE__ */ __name((found, refreshed) => ({
9042
9295
  ...!refreshed || refreshed.complete ? {} : { coverage: { ...found.coverage, state: "stale" } }
9043
9296
  }), "withRefresh");
9044
9297
 
9045
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/embeddings-search.js
9298
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/embeddings-search.js
9046
9299
  var CANDIDATES = 50;
9047
9300
  var WORD_HITS = 200;
9048
9301
  var RRF_K = 60;
@@ -9160,7 +9413,7 @@ var embeddingsSearch = /* @__PURE__ */ __name((deps) => {
9160
9413
  }, deps.messenger);
9161
9414
  const eligibility = filter === void 0 ? void 0 : await store.queries.conversationEligibility(prepared.execution);
9162
9415
  const selected = prepared.selectedChat;
9163
- const scopeOf2 = /* @__PURE__ */ __name((one) => selected ? selected.account.provider === one.provider && selected.account.account === one.account ? { chatId: selected.chatId } : null : {}, "scopeOf");
9416
+ const scopeOf3 = /* @__PURE__ */ __name((one) => selected ? selected.account.provider === one.provider && selected.account.account === one.account ? { chatId: selected.chatId } : null : {}, "scopeOf");
9164
9417
  const words2 = await byWords(query, prepared, eligibility?.conversations, since);
9165
9418
  const meaning = [];
9166
9419
  const sources = words2.sources;
@@ -9168,7 +9421,7 @@ var embeddingsSearch = /* @__PURE__ */ __name((deps) => {
9168
9421
  await withEmbedder(deps, target, choice, {}, async (embedder) => {
9169
9422
  const [vector] = await embedder.embed([query], "query");
9170
9423
  for (const one of prepared.scopeAccounts) {
9171
- const scope = scopeOf2(one);
9424
+ const scope = scopeOf3(one);
9172
9425
  if (scope === null)
9173
9426
  continue;
9174
9427
  const hits = await store.vectors.nearestConversations(one, {
@@ -9202,7 +9455,7 @@ var embeddingsSearch = /* @__PURE__ */ __name((deps) => {
9202
9455
  const scoped = [];
9203
9456
  const elsewhere = [];
9204
9457
  for (const one of prepared.scopeAccounts) {
9205
- const scope = scopeOf2(one);
9458
+ const scope = scopeOf3(one);
9206
9459
  if (scope === null)
9207
9460
  continue;
9208
9461
  const eligibleChats = eligibility?.chats.filter(({ account: account3 }) => account3.provider === one.provider && account3.account === one.account).map(({ chat: chat2 }) => chat2);
@@ -9317,13 +9570,13 @@ var meanOf = /* @__PURE__ */ __name((vectors) => {
9317
9570
  return mean.map((value) => value / length);
9318
9571
  }, "meanOf");
9319
9572
 
9320
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/embeddings.js
9573
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/embeddings.js
9321
9574
  var embeddingsService = /* @__PURE__ */ __name((deps) => ({
9322
9575
  ...embeddingsMaintenance(deps),
9323
9576
  ...embeddingsSearch(deps)
9324
9577
  }), "embeddingsService");
9325
9578
 
9326
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/folders.js
9579
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/folders.js
9327
9580
  var foldersService = /* @__PURE__ */ __name((deps) => {
9328
9581
  const online = /* @__PURE__ */ __name(async (command) => {
9329
9582
  if (deps.offline)
@@ -9456,15 +9709,15 @@ var foldersService = /* @__PURE__ */ __name((deps) => {
9456
9709
  if (link4.trim() === "")
9457
9710
  throw new CliError("validation_error", "give the folder's link");
9458
9711
  const connection = await online("chats folders join");
9459
- const join10 = capability(connection, "joinFolder", "join a shared folder");
9712
+ const join11 = capability(connection, "joinFolder", "join a shared folder");
9460
9713
  const operationId = newOperationId();
9461
- const folder = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action: "folder-join" }, () => join10(link4.trim()));
9714
+ const folder = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action: "folder-join" }, () => join11(link4.trim()));
9462
9715
  return { operationId, folder };
9463
9716
  }, "join")
9464
9717
  };
9465
9718
  }, "foldersService");
9466
9719
 
9467
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/inbox.js
9720
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/inbox.js
9468
9721
  var INBOX_CHATS = 20;
9469
9722
  var REVIEW_DAYS = 3;
9470
9723
  var UNANSWERED_HOURS = 24;
@@ -9672,7 +9925,7 @@ var inboxService = /* @__PURE__ */ __name((deps) => {
9672
9925
  };
9673
9926
  }, "inboxService");
9674
9927
 
9675
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/mentions.js
9928
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/mentions.js
9676
9929
  var REVIEW_COUNT = 500;
9677
9930
  var mentionsService = /* @__PURE__ */ __name((deps) => {
9678
9931
  const located = /* @__PURE__ */ __name(async () => {
@@ -9751,7 +10004,67 @@ var mentionsService = /* @__PURE__ */ __name((deps) => {
9751
10004
  };
9752
10005
  }, "mentionsService");
9753
10006
 
9754
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/message-link.js
10007
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/formatting.js
10008
+ var invalid3 = /* @__PURE__ */ __name(() => new CliError("validation_error", "the messenger formatter returned invalid text spans"), "invalid");
10009
+ var validateFormattedText = /* @__PURE__ */ __name((formatted2) => {
10010
+ const { text: text2, spans } = formatted2;
10011
+ if (typeof text2 !== "string" || !Array.isArray(spans) || spans.length > 100)
10012
+ throw invalid3();
10013
+ const boundary = /* @__PURE__ */ __name((at) => !(at > 0 && at < text2.length && /[\uD800-\uDBFF]/u.test(text2[at - 1] ?? "") && /[\uDC00-\uDFFF]/u.test(text2[at] ?? "")), "boundary");
10014
+ for (const span of spans) {
10015
+ if (![
10016
+ "bold",
10017
+ "italic",
10018
+ "strike",
10019
+ "underline",
10020
+ "code",
10021
+ "pre",
10022
+ "link",
10023
+ "blockquote",
10024
+ "spoiler",
10025
+ "highlight",
10026
+ "heading"
10027
+ ].includes(span.type) || !Number.isInteger(span.from) || !Number.isInteger(span.length) || span.from < 0 || span.length <= 0 || span.from + span.length > text2.length || !boundary(span.from) || !boundary(span.from + span.length))
10028
+ throw invalid3();
10029
+ if (span.type === "link") {
10030
+ if (!span.url || Array.from(span.url).some((char) => char.charCodeAt(0) <= 32 || char.charCodeAt(0) === 127))
10031
+ throw new CliError("validation_error", "a Markdown link needs an absolute http, https or mailto URL");
10032
+ let url;
10033
+ try {
10034
+ url = new URL(span.url);
10035
+ } catch {
10036
+ throw new CliError("validation_error", "a Markdown link needs an absolute http, https or mailto URL");
10037
+ }
10038
+ if (!["http:", "https:", "mailto:"].includes(url.protocol))
10039
+ throw new CliError("validation_error", "Markdown links support http, https and mailto URLs");
10040
+ }
10041
+ }
10042
+ return formatted2;
10043
+ }, "validateFormattedText");
10044
+ var visibleFormattedText = /* @__PURE__ */ __name((formatted2) => {
10045
+ validateFormattedText(formatted2);
10046
+ const text2 = visibleControls(formatted2.text);
10047
+ const positions = /* @__PURE__ */ new Map([[0, 0]]);
10048
+ let original = 0;
10049
+ let visible2 = 0;
10050
+ for (const character of formatted2.text) {
10051
+ const rendered = text2.startsWith(character, visible2) ? character : visibleControls(character);
10052
+ original += character.length;
10053
+ visible2 += rendered.length;
10054
+ positions.set(original, visible2);
10055
+ }
10056
+ return {
10057
+ text: text2,
10058
+ spans: formatted2.spans.map((span) => ({
10059
+ ...span,
10060
+ from: positions.get(span.from),
10061
+ length: positions.get(span.from + span.length) - positions.get(span.from),
10062
+ ...span.url === void 0 ? {} : { url: visibleControls(span.url) }
10063
+ }))
10064
+ };
10065
+ }, "visibleFormattedText");
10066
+
10067
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/message-link.js
9755
10068
  var messageLinkTarget = /* @__PURE__ */ __name((reference, message, provider) => {
9756
10069
  if (isLocator(reference)) {
9757
10070
  if (message !== void 0)
@@ -9798,7 +10111,7 @@ var validatePermalink = /* @__PURE__ */ __name((link4) => {
9798
10111
  return { url: link4.url, access: link4.access, reason: link4.reason };
9799
10112
  }, "validatePermalink");
9800
10113
 
9801
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/pin-duration.js
10114
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/pin-duration.js
9802
10115
  var spokenSeconds = /* @__PURE__ */ __name((seconds) => {
9803
10116
  if (seconds % 86400 === 0 && seconds > 86400)
9804
10117
  return `${seconds / 86400}d`;
@@ -9830,7 +10143,7 @@ var pinDurationOf = /* @__PURE__ */ __name((value, allowed, flag = "--expire-tim
9830
10143
  return seconds;
9831
10144
  }, "pinDurationOf");
9832
10145
 
9833
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/sends/send-as.js
10146
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/sends/send-as.js
9834
10147
  var sendAsCheck = /* @__PURE__ */ __name((connection, sendAs) => {
9835
10148
  if (sendAs === void 0) {
9836
10149
  const saved = connection.savedSender?.bind(connection);
@@ -9855,7 +10168,7 @@ var typedSendAs = /* @__PURE__ */ __name((typed) => {
9855
10168
  return sendAs;
9856
10169
  }, "typedSendAs");
9857
10170
 
9858
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/search/total.js
10171
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/search/total.js
9859
10172
  var TOTAL_CAP = 1e4;
9860
10173
  var totalOf = /* @__PURE__ */ __name((count2, shown, hasMore, exact = true) => {
9861
10174
  const least = shown + (hasMore ? 1 : 0);
@@ -9866,7 +10179,36 @@ var totalOf = /* @__PURE__ */ __name((count2, shown, hasMore, exact = true) => {
9866
10179
  return { value: count2, relation: exact ? "eq" : "gte" };
9867
10180
  }, "totalOf");
9868
10181
 
9869
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/search/question-plan.js
10182
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/search/lucene/meaning-parts.js
10183
+ var WORD_FIELDS = /* @__PURE__ */ new Set(["text", "exact"]);
10184
+ var fieldsOfQuery = /* @__PURE__ */ __name((root, everything) => {
10185
+ let narrows = false;
10186
+ const kept = /* @__PURE__ */ __name((node) => {
10187
+ if (node.kind === "boolean")
10188
+ return {
10189
+ ...node,
10190
+ clauses: node.clauses.map(({ occur, node: node2 }) => {
10191
+ if (occur !== "must_not")
10192
+ return { occur, node: kept(node2) };
10193
+ narrows = true;
10194
+ return { occur, node: node2 };
10195
+ })
10196
+ };
10197
+ if (!WORD_FIELDS.has(node.field)) {
10198
+ narrows = true;
10199
+ return node;
10200
+ }
10201
+ return { ...everything, span: node.span };
10202
+ }, "kept");
10203
+ const fields = kept(root);
10204
+ return narrows ? fields : void 0;
10205
+ }, "fieldsOfQuery");
10206
+ var meaningWords = /* @__PURE__ */ __name((root) => {
10207
+ const wanted = /* @__PURE__ */ __name((node) => node.kind === "boolean" ? node.clauses.flatMap(({ occur, node: node2 }) => occur === "must_not" ? [] : wanted(node2)) : WORD_FIELDS.has(node.field) && (node.operator === "term" || node.operator === "phrase") ? [node.value] : [], "wanted");
10208
+ return wanted(root).join(" ").trim();
10209
+ }, "meaningWords");
10210
+
10211
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/search/question-plan.js
9870
10212
  var words = /* @__PURE__ */ __name((text2) => normalize(text2).match(/[\p{L}\p{N}]+/gu) ?? [], "words");
9871
10213
  var scaffolding = new Set(words("what which how many much who where when is are was were do does did can could should we the a an for of to under from in on at has have \u0441\u043A\u043E\u043B\u044C\u043A\u043E \u043A\u0430\u043A\u043E\u0439 \u043A\u0430\u043A\u0430\u044F \u043A\u0430\u043A\u0438\u0435 \u043A\u0430\u043A\u043E\u0435 \u043A\u0442\u043E \u043A\u043E\u043C\u0443 \u043A\u0435\u043C \u0433\u0434\u0435 \u043A\u043E\u0433\u0434\u0430 \u043A\u0430\u043A \u0447\u0442\u043E \u0432\u043E \u043F\u043E \u043D\u0430 \u0432 \u043A \u0441 \u0443 \u0447\u0435\u0440\u0435\u0437 \u043B\u0438 \u0434\u043E\u043B\u0436\u0435\u043D \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0443\u0436\u043D\u043E \u0438\u0434\u0451\u0442 \u0438\u0434\u0435\u0442 \u043C\u043E\u0436\u043D\u043E \u043C\u043E\u0436\u0435\u0442 \u043C\u043E\u0433\u0443\u0442"));
9872
10214
  var questionWord = /\b(?:what|which|how|who|where|when|can|could|should)\b|(?:^|\s)(?:сколько|какой|какая|какие|какое|кто|кому|кем|где|когда|как|что|можно|может|могут|ли)(?:\s|$)/iu;
@@ -9982,7 +10324,7 @@ function planQuestion(text2, strict = false) {
9982
10324
  }
9983
10325
  __name(planQuestion, "planQuestion");
9984
10326
 
9985
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages-combined.js
10327
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages-combined.js
9986
10328
  var COMBINED_DEFAULTS = { candidateDepth: 300, rrfK: 60, rerank: "all", chatCap: 0 };
9987
10329
  var tokensOf = /* @__PURE__ */ __name((text2) => normalize(text2).match(/[\p{L}\p{N}\p{Co}\p{M}]+/gu) ?? [], "tokensOf");
9988
10330
  var searchCombined = /* @__PURE__ */ __name(async (store, account2, request, messenger = {}, options = COMBINED_DEFAULTS) => {
@@ -10009,11 +10351,11 @@ var searchCombined = /* @__PURE__ */ __name(async (store, account2, request, mes
10009
10351
  const corrections = expanding ? await correctWords(store.searchIndex, [...new Set(eligible.map((leaf) => normalize(leaf.value)))]) : /* @__PURE__ */ new Map();
10010
10352
  check();
10011
10353
  const bySpan = new Map(eligible.map((leaf) => [leaf.span.start, leaf]));
10012
- const transform = /* @__PURE__ */ __name((node, source, exact2 = false) => {
10354
+ const transform2 = /* @__PURE__ */ __name((node, source, exact2 = false) => {
10013
10355
  if (node.kind === "boolean")
10014
10356
  return {
10015
10357
  ...node,
10016
- clauses: node.clauses.map((clause) => ({ ...clause, node: transform(clause.node, source, exact2) }))
10358
+ clauses: node.clauses.map((clause) => ({ ...clause, node: transform2(clause.node, source, exact2) }))
10017
10359
  };
10018
10360
  if (exact2 && node.field === "text" && (node.operator === "term" || node.operator === "phrase"))
10019
10361
  return { ...node, field: "exact" };
@@ -10042,18 +10384,18 @@ var searchCombined = /* @__PURE__ */ __name(async (store, account2, request, mes
10042
10384
  const found = await read(execution.root, request.limit);
10043
10385
  return finish(found.items, found.hasMore, [], false, false);
10044
10386
  }
10045
- const exact = await read(transform(execution.root, "words", true), depth);
10387
+ const exact = await read(transform2(execution.root, "words", true), depth);
10046
10388
  const stemmed = await read(execution.root, depth);
10047
- const prefix = await read(transform(execution.root, "beginnings"), depth);
10048
- const fixed = corrections.size ? await read(transform(execution.root, "corrected"), depth) : { items: [], hasMore: false };
10049
- const fixedPrefixRoot = transform(execution.root, "corrected");
10389
+ const prefix = await read(transform2(execution.root, "beginnings"), depth);
10390
+ const fixed = corrections.size ? await read(transform2(execution.root, "corrected"), depth) : { items: [], hasMore: false };
10391
+ const fixedPrefixRoot = transform2(execution.root, "corrected");
10050
10392
  const correctedBeginnings = /* @__PURE__ */ __name((node) => node.kind === "boolean" ? { ...node, clauses: node.clauses.map((clause) => ({ ...clause, node: correctedBeginnings(clause.node) })) } : bySpan.has(node.span.start) && [...normalize(node.value)].length >= 3 ? { ...node, field: "exact", operator: "wildcard", value: `${normalize(node.value)}*` } : node, "correctedBeginnings");
10051
10393
  const fixedPrefix = corrections.size ? await read(correctedBeginnings(fixedPrefixRoot), depth) : { items: [], hasMore: false };
10052
10394
  const ranked = /* @__PURE__ */ new Map();
10053
10395
  const add = /* @__PURE__ */ __name((lists, source) => {
10054
10396
  const shares = /* @__PURE__ */ new Map();
10055
- for (const list2 of lists)
10056
- list2.items.forEach((hit, rank) => {
10397
+ for (const list3 of lists)
10398
+ list3.items.forEach((hit, rank) => {
10057
10399
  const share = 1 / (options.rrfK + rank + 1);
10058
10400
  const old = shares.get(hit.locator);
10059
10401
  if (!old || share > old.share)
@@ -10175,7 +10517,7 @@ var signals = /* @__PURE__ */ __name((hit, terms, corrections, execution, mode,
10175
10517
  return mode === "coverage" ? coverage * 4 : mode === "proximity" ? proximity : mode === "phrase" ? phrase : coverage * 4 + proximity + phrase;
10176
10518
  }, "signals");
10177
10519
 
10178
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages-discovery.js
10520
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages-discovery.js
10179
10521
  var MEANING_DEPTH = 100;
10180
10522
  var RRF_K2 = 60;
10181
10523
  var RERANK_DEPTH = 50;
@@ -10186,6 +10528,17 @@ var FOLLOW_UP_HITS = 5;
10186
10528
  var FOLLOW_UPS_PER_HIT = 2;
10187
10529
  var RARE_AT = 3;
10188
10530
  var FOLLOW_UP_CANDIDATES = 20;
10531
+ var RANK_WITHIN_MESSAGES = 1e5;
10532
+ var EVERY_MESSAGE = {
10533
+ kind: "predicate",
10534
+ field: "date",
10535
+ operator: "range",
10536
+ value: "*",
10537
+ upper: "*",
10538
+ lower_inclusive: true,
10539
+ upper_inclusive: true
10540
+ };
10541
+ var scopeOf2 = /* @__PURE__ */ __name((root) => root === void 0 ? {} : { ast: { version: 1, language: "lucene-v1", root } }, "scopeOf");
10189
10542
  var discoveryRequest = /* @__PURE__ */ __name((asked) => asked.ast !== void 0 || asked.exact || !asked.text ? asked : {
10190
10543
  ...asked,
10191
10544
  text: asked.text.replace(new RegExp("(?<=\\p{L})\\?(?=\\s|$)", "gu"), "").replace(/"(?:[^"\\]|\\.)*"|(?<=\d):(?=\d)/gu, (found) => found === ":" ? " " : found)
@@ -10195,17 +10548,23 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10195
10548
  const original = await prepareLucene(store, account2, request, messenger);
10196
10549
  const text2 = request.text ?? "";
10197
10550
  const plan = planQuestion(text2, request.ast !== void 0 || !!request.exact || !!request.newest);
10198
- if (request.ast !== void 0 || request.exact || request.newest || implicitTextTerms(text2).size === 0)
10551
+ if (request.ast !== void 0 || request.exact || request.newest)
10199
10552
  return searchLucene(store, account2, request, messenger);
10200
10553
  const implicit = implicitTextTerms(text2);
10201
- if (!plan.changed && walkQuery(original.execution.root).some((node) => (node.field === "text" || node.field === "exact") && (node.operator !== "term" || node.field === "exact" || !implicit.has(node.span.start))))
10554
+ const explicit = implicit.size === 0 || !plan.changed && walkQuery(original.execution.root).some((node) => (node.field === "text" || node.field === "exact") && (node.operator !== "term" || node.field === "exact" || !implicit.has(node.span.start)));
10555
+ const root = explicit ? validateFields(parseLucene(text2, { ...MESSAGE_PARSING, defaultField: "text" })).root : void 0;
10556
+ const question = root === void 0 ? text2 : meaningWords(root);
10557
+ if (!question)
10202
10558
  return searchLucene(store, account2, request, messenger);
10203
- const terms = [...new Set(plan.terms.concat(plan.aliases.flatMap((alias) => words(alias.split(" -> ")[1] ?? ""))))];
10559
+ const terms = root === void 0 ? [...new Set(plan.terms.concat(plan.aliases.flatMap((alias) => words(alias.split(" -> ")[1] ?? ""))))] : [...new Set(words(question))];
10204
10560
  if (!terms.length)
10205
10561
  return searchLucene(store, account2, request, messenger);
10206
10562
  if (terms.length > 64)
10207
10563
  exhausted("discovery terms");
10208
- const lane = meaning ? await meaning(text2, original.scopeAccounts) : void 0;
10564
+ const narrowing = root === void 0 ? void 0 : fieldsOfQuery(root, EVERY_MESSAGE);
10565
+ const scope = root === void 0 ? plan.scope ? { text: plan.scope } : {} : scopeOf2(narrowing);
10566
+ const within = scope.text !== void 0 || scope.ast !== void 0 ? () => filterPks(store, account2, { ...request, text: void 0, ast: void 0, ...scope }, messenger) : void 0;
10567
+ const lane = meaning ? await meaning(question, original.scopeAccounts, void 0, within) : void 0;
10209
10568
  let started = performance.now();
10210
10569
  const check = /* @__PURE__ */ __name(() => {
10211
10570
  if (request.signal?.aborted)
@@ -10220,7 +10579,7 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10220
10579
  const previous = union.get(m.locator);
10221
10580
  union.set(m.locator, { ...previous, ...m, fused: (previous?.fused ?? 0) + 1 / (60 + rank + 1) });
10222
10581
  }), "add");
10223
- for (const query of plan.changed ? [] : plan.queries) {
10582
+ for (const query of plan.changed || root !== void 0 ? [] : plan.queries) {
10224
10583
  check();
10225
10584
  const found = await searchCombined(store, account2, { ...request, text: query, limit: 300 }, messenger, {
10226
10585
  candidateDepth: 300,
@@ -10234,7 +10593,7 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10234
10593
  truncated ||= found.hasMore || found.query.combined.truncated;
10235
10594
  }
10236
10595
  check();
10237
- const relaxed = `(${terms.join(" OR ")})${plan.scope ? ` ${plan.scope}` : ""}`;
10596
+ const relaxed = root === void 0 ? `(${terms.join(" OR ")})${plan.scope ? ` ${plan.scope}` : ""}` : text2;
10238
10597
  const partialRequest = { ...request, text: relaxed, ast: void 0, limit: 300, context: 0, thread: void 0 };
10239
10598
  const partial = await searchLucene(store, account2, partialRequest, messenger);
10240
10599
  add(partial.items);
@@ -10257,8 +10616,9 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10257
10616
  }).filter((m) => !request.only || request.only.some((key) => key.provider === m.provider && key.account === m.account && key.chatId === m.chatId && key.id === m.id));
10258
10617
  const eligible = await searchLucene(store, account2, {
10259
10618
  ...request,
10260
- text: plan.scope || void 0,
10619
+ text: void 0,
10261
10620
  ast: void 0,
10621
+ ...scope,
10262
10622
  limit: 500,
10263
10623
  only,
10264
10624
  context: 0,
@@ -10317,7 +10677,7 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10317
10677
  candidates = candidates.map(described).sort((a, b) => (b.score ?? 0) - (a.score ?? 0) || Number(parentByLocator.has(b.locator)) - Number(parentByLocator.has(a.locator)));
10318
10678
  let meaningCandidates = 0;
10319
10679
  if (lane && "ranked" in lane) {
10320
- const near2 = await nearEligible(store, account2, request, messenger, lane.ranked, plan.scope);
10680
+ const near2 = await nearEligible(store, account2, request, messenger, lane.ranked, scope);
10321
10681
  meaningCandidates = near2.length;
10322
10682
  candidates = fusedWithMeaning(candidates, near2, described);
10323
10683
  }
@@ -10358,7 +10718,7 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10358
10718
  started += performance.now() - opening;
10359
10719
  }
10360
10720
  check();
10361
- const followUps = await followUpsOf(store, account2, request, messenger, candidates, plan.scope);
10721
+ const followUps = await followUpsOf(store, account2, request, messenger, candidates, scope);
10362
10722
  const items = await Promise.all(candidates.slice(0, request.limit).map(async ({ fused: _fused, ...hit }) => {
10363
10723
  const later = followUps.get(hit.locator);
10364
10724
  const m = later?.length ? { ...hit, followUps: later } : hit;
@@ -10384,14 +10744,14 @@ var searchDiscovery = /* @__PURE__ */ __name(async (store, account2, asked, mess
10384
10744
  query: {
10385
10745
  ...partial.query,
10386
10746
  discovery: {
10387
- method: "lexical-partial",
10747
+ method: root === void 0 ? "lexical-partial" : "lexical-strict",
10388
10748
  candidateDepth: 300,
10389
10749
  candidates: candidates.length,
10390
10750
  repliesAdded: replyCount,
10391
10751
  followUps: [...followUps.values()].reduce((sum2, later) => sum2 + later.length, 0),
10392
10752
  truncated,
10393
10753
  terms,
10394
- queries: [...plan.changed ? [] : plan.queries, relaxed],
10754
+ queries: [...plan.changed || root !== void 0 ? [] : plan.queries, relaxed],
10395
10755
  ...lane && "ranked" in lane ? { meaning: { model: lane.model, candidates: meaningCandidates } } : {},
10396
10756
  ...reranked ? { rerank: reranked } : {}
10397
10757
  }
@@ -10412,7 +10772,7 @@ var followUpsOf = /* @__PURE__ */ __name(async (store, account2, request, messen
10412
10772
  const out = /* @__PURE__ */ new Map();
10413
10773
  if (!only.length)
10414
10774
  return out;
10415
- const eligible = await searchLucene(store, account2, { ...request, text: scope || void 0, ast: void 0, limit: only.length, only, context: 0, thread: void 0 }, messenger);
10775
+ const eligible = await searchLucene(store, account2, { ...request, text: void 0, ast: void 0, ...scope, limit: only.length, only, context: 0, thread: void 0 }, messenger);
10416
10776
  const allowed = new Map(eligible.items.map((m) => [m.locator, m]));
10417
10777
  const shown = /* @__PURE__ */ new Set();
10418
10778
  head.forEach((hit, i) => {
@@ -10425,12 +10785,17 @@ var followUpsOf = /* @__PURE__ */ __name(async (store, account2, request, messen
10425
10785
  });
10426
10786
  return out;
10427
10787
  }, "followUpsOf");
10788
+ var filterPks = /* @__PURE__ */ __name(async (store, account2, request, messenger) => {
10789
+ const { execution } = await prepareLucene(store, account2, request, messenger);
10790
+ const pks = await store.queries.matchingPks(execution, RANK_WITHIN_MESSAGES);
10791
+ return pks === void 0 || pks.length > RANK_WITHIN_MESSAGES ? void 0 : pks;
10792
+ }, "filterPks");
10428
10793
  var nearEligible = /* @__PURE__ */ __name(async (store, account2, request, messenger, ranked, scope) => {
10429
10794
  const keyOf5 = /* @__PURE__ */ __name((one) => JSON.stringify([one.provider, one.account, one.chatId, one.id]), "keyOf");
10430
10795
  const only = ranked.slice(0, MEANING_DEPTH).filter((m) => !request.only || request.only.some((key) => keyOf5(key) === keyOf5(m))).map(({ provider, account: account3, chatId, id: id2 }) => ({ provider, account: account3, chatId, id: id2 }));
10431
10796
  if (!only.length)
10432
10797
  return [];
10433
- const eligible = await searchLucene(store, account2, { ...request, text: scope || void 0, ast: void 0, limit: only.length, only, context: 0, thread: void 0 }, messenger);
10798
+ const eligible = await searchLucene(store, account2, { ...request, text: void 0, ast: void 0, ...scope, limit: only.length, only, context: 0, thread: void 0 }, messenger);
10434
10799
  const hits = new Map(eligible.items.map((hit) => {
10435
10800
  const { provider, account: account3 } = parseLocator(hit.locator);
10436
10801
  return [keyOf5({ provider, account: account3, chatId: hit.chatId, id: hit.id }), hit];
@@ -10480,7 +10845,7 @@ var mixedWithReranker = /* @__PURE__ */ __name((head, scores) => {
10480
10845
  })).sort((a, b) => b.mixed - a.mixed).map(({ hit }) => hit);
10481
10846
  }, "mixedWithReranker");
10482
10847
 
10483
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/thread-context.js
10848
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/thread-context.js
10484
10849
  var THREAD_BOUNDS = { maxHops: 8, maxMessages: 50, maxBytes: 65536, withinMs: 864e5 };
10485
10850
  var bytes = /* @__PURE__ */ __name((items, links) => Buffer.byteLength(JSON.stringify({ items, links }), "utf8"), "bytes");
10486
10851
  var threadBounds = /* @__PURE__ */ __name((options = {}) => {
@@ -10679,7 +11044,7 @@ var readThreadContext = /* @__PURE__ */ __name(async (store, account2, chat, mes
10679
11044
  return result;
10680
11045
  }, "readThreadContext");
10681
11046
 
10682
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages-archive-search.js
11047
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages-archive-search.js
10683
11048
  var SEARCH_FILL_MS = 200;
10684
11049
  var statsStore = /* @__PURE__ */ __name(async (store, account2, request, messenger = {}) => {
10685
11050
  const stop = Date.now() + SEARCH_FILL_MS;
@@ -10746,12 +11111,12 @@ var accountOf2 = /* @__PURE__ */ __name((hit) => {
10746
11111
  }, "accountOf");
10747
11112
  var keyOf3 = /* @__PURE__ */ __name(({ provider, account: account2 }) => `${provider}/${account2}`, "keyOf");
10748
11113
 
10749
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/pictures.js
11114
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/pictures.js
10750
11115
  import { createHash as createHash9 } from "node:crypto";
10751
11116
  import { readFile as readFile2, stat as stat3 } from "node:fs/promises";
10752
11117
  import { setTimeout as sleep4 } from "node:timers/promises";
10753
11118
 
10754
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/models.js
11119
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/models.js
10755
11120
  var GROUP_SETTINGS = [
10756
11121
  "allCanPin",
10757
11122
  "onlyAdminsAdd",
@@ -10765,7 +11130,7 @@ var ADMIN_RIGHTS = ["read", "members", "admins", "info", "pin", "link", "post",
10765
11130
  var senderIsMe = /* @__PURE__ */ __name((message, account2) => message.outgoing === true || message.senderId !== null && String(message.senderId) === account2, "senderIsMe");
10766
11131
  var MEDIA_KINDS = ["photo", "video", "file", "audio", "link"];
10767
11132
 
10768
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/file-download.js
11133
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/file-download.js
10769
11134
  import { createWriteStream, mkdirSync } from "node:fs";
10770
11135
  import { link as link3, rm } from "node:fs/promises";
10771
11136
  import { basename as basename5, join as join9, resolve as resolve6 } from "node:path";
@@ -10812,18 +11177,18 @@ var downloadMessage = /* @__PURE__ */ __name(async (messages, chat, message, out
10812
11177
  var saveFiles = /* @__PURE__ */ __name(async (messages, chat, message, files, output, { unique = false, warn, onSaved, batch = batchProgress() }) => {
10813
11178
  const saved = [];
10814
11179
  const successful = [];
10815
- for (const [index, file] of files.entries()) {
11180
+ for (const [index, file2] of files.entries()) {
10816
11181
  if (batch.stopped)
10817
11182
  break;
10818
11183
  try {
10819
- const one = await save(file, output, `${message}-${index + 1}`, { unique });
11184
+ const one = await save(file2, output, `${message}-${index + 1}`, { unique });
10820
11185
  saved.push(one);
10821
- successful.push(file);
11186
+ successful.push(file2);
10822
11187
  batch.ok();
10823
11188
  onSaved?.(one);
10824
11189
  } catch (error) {
10825
- const issue = batch.fail(message, "download", error, (file.position ?? index) + 1);
10826
- warn(`message ${message}, attachment ${(file.position ?? index) + 1}: ${issue.code} \u2014 ${issue.message}`);
11190
+ const issue = batch.fail(message, "download", error, (file2.position ?? index) + 1);
11191
+ warn(`message ${message}, attachment ${(file2.position ?? index) + 1}: ${issue.code} \u2014 ${issue.message}`);
10827
11192
  }
10828
11193
  }
10829
11194
  await recordPaths(messages, chat, message, successful, saved, warn, (error) => batch.fail(message, "record_downloads", error));
@@ -10851,10 +11216,10 @@ var safeName = /* @__PURE__ */ __name((name, platform = process.platform) => {
10851
11216
  }
10852
11217
  return plain === "" ? void 0 : plain;
10853
11218
  }, "safeName");
10854
- var save = /* @__PURE__ */ __name(async (file, directory, fallbackName, { unique = false } = {}) => {
10855
- const own = safeName(file.name);
11219
+ var save = /* @__PURE__ */ __name(async (file2, directory, fallbackName, { unique = false } = {}) => {
11220
+ const own = safeName(file2.name);
10856
11221
  const fileName = /* @__PURE__ */ __name(() => {
10857
- const extension = EXTENSIONS[file.mime ?? ""] ?? BY_KIND[file.kind];
11222
+ const extension = EXTENSIONS[file2.mime ?? ""] ?? BY_KIND[file2.kind];
10858
11223
  return own ?? (extension ? `${fallbackName}.${extension}` : fallbackName);
10859
11224
  }, "fileName");
10860
11225
  const partial = join9(directory, `.${fileName()}.${process.pid}.part`);
@@ -10866,7 +11231,7 @@ var save = /* @__PURE__ */ __name(async (file, directory, fallbackName, { unique
10866
11231
  }
10867
11232
  });
10868
11233
  try {
10869
- await pipeline(Readable.from(file.bytes()), counting, createWriteStream(partial, { flags: "wx", mode: 384 }));
11234
+ await pipeline(Readable.from(file2.bytes()), counting, createWriteStream(partial, { flags: "wx", mode: 384 }));
10870
11235
  const name = fileName();
10871
11236
  const names2 = unique && own ? [name, `${fallbackName}-${own}`] : [name];
10872
11237
  for (const candidate of names2) {
@@ -10877,18 +11242,18 @@ var save = /* @__PURE__ */ __name(async (file, directory, fallbackName, { unique
10877
11242
  throw error;
10878
11243
  });
10879
11244
  if (!taken)
10880
- return { kind: file.kind, path: path2, bytes: bytes2 };
11245
+ return { kind: file2.kind, path: path2, bytes: bytes2 };
10881
11246
  }
10882
11247
  const path = resolve6(join9(directory, names2.at(-1) ?? name));
10883
11248
  if (unique)
10884
- return { kind: file.kind, path, bytes: bytes2, existing: true };
11249
+ return { kind: file2.kind, path, bytes: bytes2, existing: true };
10885
11250
  throw new CliError("validation_error", `${path} already exists \u2014 nothing was overwritten; choose --output-dir`);
10886
11251
  } finally {
10887
11252
  await rm(partial, { force: true });
10888
11253
  }
10889
11254
  }, "save");
10890
11255
 
10891
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/pictures.js
11256
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/pictures.js
10892
11257
  var PICTURE_MAX_BYTES = 25 * 1024 * 1024;
10893
11258
  var PICTURE_FLOOR = 0.25;
10894
11259
  var PAGE4 = 50;
@@ -10905,7 +11270,7 @@ var picturesService = /* @__PURE__ */ __name((deps) => {
10905
11270
  const directory = imageModelsDirectory(deps.env);
10906
11271
  if (!isImageModelInstalled(model2, directory))
10907
11272
  throw new CliError("not_found", missingModel(model2.id), { reason: "model.not-downloaded", model: model2.id });
10908
- const { openPictureEmbedder } = await import("./embedder-6ULWRG3R.js");
11273
+ const { openPictureEmbedder } = await import("./embedder-KEVEDNDJ.js");
10909
11274
  return openPictureEmbedder(model2, directory);
10910
11275
  }, "open");
10911
11276
  const embedder = /* @__PURE__ */ __name(() => {
@@ -10925,18 +11290,18 @@ var picturesService = /* @__PURE__ */ __name((deps) => {
10925
11290
  }
10926
11291
  }
10927
11292
  const images = (await files()).filter(({ kind, mime }) => kind === "photo" || mime?.startsWith("image/"));
10928
- const file = images.find(({ position }) => position === picture.position) ?? (images.every(({ position }) => position === void 0) ? images[0] : void 0);
10929
- if (!file || file.size !== void 0 && file.size > PICTURE_MAX_BYTES)
11293
+ const file2 = images.find(({ position }) => position === picture.position) ?? (images.every(({ position }) => position === void 0) ? images[0] : void 0);
11294
+ if (!file2 || file2.size !== void 0 && file2.size > PICTURE_MAX_BYTES)
10930
11295
  return void 0;
10931
11296
  const parts = [];
10932
11297
  let total = 0;
10933
- for await (const part of file.bytes()) {
11298
+ for await (const part of file2.bytes()) {
10934
11299
  total += part.length;
10935
11300
  if (total > PICTURE_MAX_BYTES)
10936
11301
  return void 0;
10937
11302
  parts.push(part);
10938
11303
  }
10939
- await read(file);
11304
+ await read(file2);
10940
11305
  return Buffer.concat(parts);
10941
11306
  }, "bytesOf");
10942
11307
  return {
@@ -10989,8 +11354,8 @@ var picturesService = /* @__PURE__ */ __name((deps) => {
10989
11354
  return downloaded.files;
10990
11355
  }, "files");
10991
11356
  try {
10992
- const bytes2 = await bytesOf2(picture, files, async (file) => {
10993
- const refreshed = refreshedFiles([file]);
11357
+ const bytes2 = await bytesOf2(picture, files, async (file2) => {
11358
+ const refreshed = refreshedFiles([file2]);
10994
11359
  if (refreshed.length === 0)
10995
11360
  return;
10996
11361
  await store.attachments.keepProviderRefs(account2, picture.chatId, picture.messageId, refreshed).catch(() => void 0);
@@ -11102,8 +11467,8 @@ var withPictures = /* @__PURE__ */ __name((messages, pictures) => ({
11102
11467
  }, "search")
11103
11468
  }), "withPictures");
11104
11469
 
11105
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages-meaning.js
11106
- var meaningLane = /* @__PURE__ */ __name((deps) => async (question, accounts, shared) => {
11470
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages-meaning.js
11471
+ var meaningLane = /* @__PURE__ */ __name((deps) => async (question, accounts, shared, within) => {
11107
11472
  const target = embeddingTarget(deps, DEFAULT_TEXT_MODEL);
11108
11473
  const skipped = /* @__PURE__ */ __name((reason, step) => ({
11109
11474
  skipped: { reason, model: target.id, ...step ? { step } : {} }
@@ -11121,10 +11486,11 @@ var meaningLane = /* @__PURE__ */ __name((deps) => async (question, accounts, sh
11121
11486
  try {
11122
11487
  const ranked = [];
11123
11488
  if (words2) {
11489
+ const pks = await within?.();
11124
11490
  const lookUp = /* @__PURE__ */ __name(async (embedder) => {
11125
11491
  const [query] = await embedder.embed([words2], "query");
11126
11492
  for (const one of ready) {
11127
- const near2 = await store.vectors.nearestMessages(one, {
11493
+ const near2 = pks ? await store.vectors.scoreMessages(one, { model: target.key, query, pks }) : await store.vectors.nearestMessages(one, {
11128
11494
  model: target.key,
11129
11495
  limit: MEANING_DEPTH,
11130
11496
  query
@@ -11150,7 +11516,7 @@ var meaningLane = /* @__PURE__ */ __name((deps) => async (question, accounts, sh
11150
11516
  }
11151
11517
  }, "meaningLane");
11152
11518
 
11153
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages-rerank.js
11519
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages-rerank.js
11154
11520
  var rerankLane = /* @__PURE__ */ __name((deps) => {
11155
11521
  const choice = deps.reranker ?? DEFAULT_RERANK_MODEL;
11156
11522
  if (choice === "off")
@@ -11162,9 +11528,9 @@ var rerankLane = /* @__PURE__ */ __name((deps) => {
11162
11528
  return { skipped: { reason: `${model.id} is not downloaded`, step: "models.download", model: model.id } };
11163
11529
  try {
11164
11530
  const warm = deps.embedders;
11165
- const reranker = warm ? await warm.reranker(`rerank:${model.id}`, async () => (await import("./process-ZXO2MWRJ.js")).openRerankerProcess(model, directory, {
11531
+ const reranker = warm ? await warm.reranker(`rerank:${model.id}`, async () => (await import("./process-P6TW37HQ.js")).openRerankerProcess(model, directory, {
11166
11532
  threads: defaultThreads()
11167
- })) : await (await import("./rerank-R6PE44M5.js")).openReranker(model, directory);
11533
+ })) : await (await import("./rerank-5A3JDK7O.js")).openReranker(model, directory);
11168
11534
  return {
11169
11535
  model: model.id,
11170
11536
  score: /* @__PURE__ */ __name((question, passages) => reranker.score(plainWords(question), passages), "score"),
@@ -11184,7 +11550,7 @@ var rerankLane = /* @__PURE__ */ __name((deps) => {
11184
11550
  };
11185
11551
  }, "rerankLane");
11186
11552
 
11187
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/document-pictures.js
11553
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/document-pictures.js
11188
11554
  import { createHash as createHash10 } from "node:crypto";
11189
11555
  var refOf = /* @__PURE__ */ __name((target) => target.ref ?? `document:${target.documentId}`, "refOf");
11190
11556
  var openPictureEmbedderFor = /* @__PURE__ */ __name(async ({ env, command } = {}) => {
@@ -11192,7 +11558,7 @@ var openPictureEmbedderFor = /* @__PURE__ */ __name(async ({ env, command } = {}
11192
11558
  const directory = imageModelsDirectory(env);
11193
11559
  if (!isImageModelInstalled(model, directory))
11194
11560
  throw new CliError("not_found", `the picture model is not downloaded \u2014 ${command === void 0 ? "install it with a WireCat CLI that has `images models download` (tg, max or wa); they share the model folder" : `\`${command} images models download ${model.id}\` fetches it`}`, { reason: "model.not-downloaded", model: model.id });
11195
- const { openPictureEmbedder } = await import("./embedder-6ULWRG3R.js");
11561
+ const { openPictureEmbedder } = await import("./embedder-KEVEDNDJ.js");
11196
11562
  return openPictureEmbedder(model, directory);
11197
11563
  }, "openPictureEmbedderFor");
11198
11564
  var savePicture = /* @__PURE__ */ __name(async (store, target, bytes2, options = {}) => {
@@ -11213,13 +11579,13 @@ var savePicture = /* @__PURE__ */ __name(async (store, target, bytes2, options =
11213
11579
  }, "savePicture");
11214
11580
  var removePicture = /* @__PURE__ */ __name((store, target) => store.notes.removePicture(refOf(target)), "removePicture");
11215
11581
 
11216
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/document-source.js
11217
- var documentSource = /* @__PURE__ */ __name((note, accounts, profiles, file) => {
11582
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/document-source.js
11583
+ var documentSource = /* @__PURE__ */ __name((note, accounts, profiles, file2) => {
11218
11584
  const metadata = note.frontMatter;
11219
11585
  const account2 = accounts.find(({ id: id2 }) => String(id2) === note.folderId);
11220
11586
  const remote = note.source === "file" && (account2 !== void 0 && kindIn(account2.provider) === "documents" || metadata?.source === "google-drive");
11221
11587
  const profile = remote && account2 ? Object.entries(profiles).flatMap(([command, named2]) => Object.entries(named2).map(([name, key]) => ({ command, name, key }))).find(({ key }) => key.provider === account2.provider && key.account === account2.account || isFolderProvider(key.provider) && key.account === account2.name) : void 0;
11222
- const url = file?.url ?? (remote && typeof metadata?.sourceUrl === "string" ? metadata.sourceUrl : void 0);
11588
+ const url = file2?.url ?? (remote && typeof metadata?.sourceUrl === "string" ? metadata.sourceUrl : void 0);
11223
11589
  return {
11224
11590
  kind: remote ? "document" : "note",
11225
11591
  provider: profile ? profile.command : "notes",
@@ -11228,7 +11594,7 @@ var documentSource = /* @__PURE__ */ __name((note, accounts, profiles, file) =>
11228
11594
  };
11229
11595
  }, "documentSource");
11230
11596
 
11231
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/notes-title-tier.js
11597
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/notes-title-tier.js
11232
11598
  var plainQueryWords = /* @__PURE__ */ __name((query) => {
11233
11599
  let root;
11234
11600
  try {
@@ -11255,7 +11621,7 @@ var titleTiers = /* @__PURE__ */ __name((hits, words2) => {
11255
11621
  return [...hits].sort((a, b) => rank(a) - rank(b));
11256
11622
  }, "titleTiers");
11257
11623
 
11258
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/notes-search.js
11624
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/notes-search.js
11259
11625
  var storeQuery = /* @__PURE__ */ __name(async (store, text2, { exact, timezone } = {}) => resolvedQuery(store, parsedQuery(text2, exact), timezone), "storeQuery");
11260
11626
  var parsedQuery = /* @__PURE__ */ __name((text2, exact) => validateFields(parseLucene(text2, { ...SEARCH_QUERY, defaultField: exact ? "exact" : "text" })).root, "parsedQuery");
11261
11627
  var resolvedQuery = /* @__PURE__ */ __name(async (store, root, timezone) => {
@@ -11433,33 +11799,8 @@ var noteSourceOfQuery = /* @__PURE__ */ __name((query) => {
11433
11799
  }
11434
11800
  return { source, rest };
11435
11801
  }, "noteSourceOfQuery");
11436
- var WORD_FIELDS = /* @__PURE__ */ new Set(["text", "exact"]);
11437
- var fieldsOfQuery = /* @__PURE__ */ __name((root) => {
11438
- let narrows = false;
11439
- const kept = /* @__PURE__ */ __name((node) => {
11440
- if (node.kind === "boolean")
11441
- return {
11442
- ...node,
11443
- clauses: node.clauses.map(({ occur, node: node2 }) => {
11444
- if (occur !== "must_not")
11445
- return { occur, node: kept(node2) };
11446
- narrows = true;
11447
- return { occur, node: node2 };
11448
- })
11449
- };
11450
- if (!WORD_FIELDS.has(node.field)) {
11451
- narrows = true;
11452
- return node;
11453
- }
11454
- return { kind: "predicate", field: "in", operator: "term", value: "notes", span: node.span };
11455
- }, "kept");
11456
- const fields = kept(root);
11457
- return narrows ? fields : void 0;
11458
- }, "fieldsOfQuery");
11459
- var meaningWords = /* @__PURE__ */ __name((root) => {
11460
- const wanted = /* @__PURE__ */ __name((node) => node.kind === "boolean" ? node.clauses.flatMap(({ occur, node: node2 }) => occur === "must_not" ? [] : wanted(node2)) : WORD_FIELDS.has(node.field) && (node.operator === "term" || node.operator === "phrase") ? [node.value] : [], "wanted");
11461
- return wanted(root).join(" ").trim();
11462
- }, "meaningWords");
11802
+ var EVERY_NOTE = { kind: "predicate", field: "in", operator: "term", value: "notes" };
11803
+ var fieldsOfQuery2 = /* @__PURE__ */ __name((root) => fieldsOfQuery(root, EVERY_NOTE), "fieldsOfQuery");
11463
11804
  var allOf = /* @__PURE__ */ __name((nodes) => nodes.length <= 1 ? nodes[0] : {
11464
11805
  kind: "boolean",
11465
11806
  clauses: nodes.map((node) => ({ occur: "must", node })),
@@ -11468,7 +11809,7 @@ var allOf = /* @__PURE__ */ __name((nodes) => nodes.length <= 1 ? nodes[0] : {
11468
11809
  var matching = /* @__PURE__ */ __name(async (store, refs, root, scope) => {
11469
11810
  if (refs.length === 0)
11470
11811
  return /* @__PURE__ */ new Map();
11471
- const resolved = await resolvedQuery(store, root ?? { kind: "predicate", field: "in", operator: "term", value: "notes", span: { start: 0, end: 0 } }, scope.timezone);
11812
+ const resolved = await resolvedQuery(store, root ?? { ...EVERY_NOTE, span: { start: 0, end: 0 } }, scope.timezone);
11472
11813
  const found = await store.notes.search({
11473
11814
  root: resolved.root,
11474
11815
  refs,
@@ -11532,7 +11873,7 @@ var searchNotes = /* @__PURE__ */ __name(async (store, query, { limit = 20, offs
11532
11873
  const parsed = query.trim() ? parsedQuery(query, exact) : void 0;
11533
11874
  const words2 = parsed === void 0 ? "" : meaningWords(parsed);
11534
11875
  const narrowing = allOf([
11535
- ...parsed === void 0 ? [] : [fieldsOfQuery(parsed)].filter((node) => node !== void 0),
11876
+ ...parsed === void 0 ? [] : [fieldsOfQuery2(parsed)].filter((node) => node !== void 0),
11536
11877
  ...filter === void 0 ? [] : [parsedQuery(filter)]
11537
11878
  ]);
11538
11879
  const text2 = [query.trim() ? `(${query})` : "", filter ?? ""].filter(Boolean).join(" AND ");
@@ -11599,7 +11940,7 @@ var searchNotes = /* @__PURE__ */ __name(async (store, query, { limit = 20, offs
11599
11940
  ...scope
11600
11941
  });
11601
11942
  const ranked = /* @__PURE__ */ new Map();
11602
- const add = /* @__PURE__ */ __name((list2, by) => list2.forEach(({ ref, note, at }, rank) => {
11943
+ const add = /* @__PURE__ */ __name((list3, by) => list3.forEach(({ ref, note, at }, rank) => {
11603
11944
  if (tierRefs.has(ref))
11604
11945
  return;
11605
11946
  const held = ranked.get(ref) ?? { note, at, score: 0, foundBy: [] };
@@ -11651,13 +11992,13 @@ var searchNotes = /* @__PURE__ */ __name(async (store, query, { limit = 20, offs
11651
11992
  ref,
11652
11993
  name
11653
11994
  ]));
11654
- for (const record of counts.values()) {
11655
- if (record.ref && names2.has(record.ref))
11656
- record.name = names2.get(record.ref) ?? record.name;
11657
- if (record.ref?.startsWith("person:"))
11658
- record.name = (await store.people.personByUid(record.ref.slice("person:".length)))?.name ?? record.name;
11659
- if (record.ref?.startsWith("note:") || record.ref?.startsWith("document:"))
11660
- record.name = (await store.notes.note(record.ref).catch(() => void 0))?.title ?? record.name;
11995
+ for (const record2 of counts.values()) {
11996
+ if (record2.ref && names2.has(record2.ref))
11997
+ record2.name = names2.get(record2.ref) ?? record2.name;
11998
+ if (record2.ref?.startsWith("person:"))
11999
+ record2.name = (await store.people.personByUid(record2.ref.slice("person:".length)))?.name ?? record2.name;
12000
+ if (record2.ref?.startsWith("note:") || record2.ref?.startsWith("document:"))
12001
+ record2.name = (await store.notes.note(record2.ref).catch(() => void 0))?.title ?? record2.name;
11661
12002
  }
11662
12003
  const lane = withPictures2 ? await pictureLane(store, words2, {
11663
12004
  folderIds,
@@ -11691,7 +12032,7 @@ var notesScopeOf = /* @__PURE__ */ __name((accounts) => {
11691
12032
  return { source: "internal" };
11692
12033
  return { folderIds, ...accounts.length > folderIds.length ? { withInternal: true } : {} };
11693
12034
  }, "notesScopeOf");
11694
- var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { accounts: list2, app, ...query }) => {
12035
+ var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { accounts: list3, app, ...query }) => {
11695
12036
  const own = app?.command ?? query.command;
11696
12037
  const what = `${own === void 0 ? "" : `${own} `}search notes`;
11697
12038
  const held = [
@@ -11699,12 +12040,12 @@ var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { acco
11699
12040
  ...(await store.notes.folders()).map(({ id: id2 }) => ({ provider: "notes", account: id2 })),
11700
12041
  ...(await store.notes.documentsAccounts()).map(({ id: id2 }) => ({ provider: "notes", account: id2 }))
11701
12042
  ];
11702
- const named2 = list2 === void 0 ? { accounts: held, skipped: [] } : fitting(entriesOfList(list2, await listContextOf(store, account2, app)), ["notes", "documents"], what);
12043
+ const named2 = list3 === void 0 ? { accounts: held, skipped: [] } : fitting(entriesOfList(list3, await listContextOf(store, account2, app)), ["notes", "documents"], what);
11703
12044
  const source = query.source ?? noteSourceOfQuery(text2).source;
11704
12045
  const typed = named2.accounts.filter(({ account: account3 }) => source === void 0 || account3 === INTERNAL_NOTES === (source === "internal"));
11705
- if (!typed.length && list2 !== void 0)
12046
+ if (!typed.length && list3 !== void 0)
11706
12047
  throw new CliError("validation_error", source === "internal" ? "the query's source:internal keeps the notes written in memo, and the --source list names none of them: add notes:internal to --source, or drop source:internal from the query" : "the query's source:file keeps the files from notes folders, and the --source list names none of them: add notes:<folder id> to --source, or drop source:file from the query");
11707
- const scope = list2 === void 0 ? {} : notesScopeOf(typed);
12048
+ const scope = list3 === void 0 ? {} : notesScopeOf(typed);
11708
12049
  const found = await searchNotes(store, text2, {
11709
12050
  ...query,
11710
12051
  ...scope,
@@ -11717,7 +12058,7 @@ var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { acco
11717
12058
  };
11718
12059
  }, "searchNotesOf");
11719
12060
 
11720
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/events-search.js
12061
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/events-search.js
11721
12062
  var MAX_EVENTS_OFFSET = 1e3;
11722
12063
  var iso = /* @__PURE__ */ __name((at) => at === null ? null : new Date(at).toISOString(), "iso");
11723
12064
  var accountIdsOf = /* @__PURE__ */ __name(async (store, accounts) => {
@@ -11809,7 +12150,7 @@ var searchEvents = /* @__PURE__ */ __name(async (store, query, { limit = 20, off
11809
12150
  ...truncated
11810
12151
  };
11811
12152
  const ranked = /* @__PURE__ */ new Map();
11812
- const add = /* @__PURE__ */ __name((list2, half) => list2.forEach((hit, rank) => {
12153
+ const add = /* @__PURE__ */ __name((list3, half) => list3.forEach((hit, rank) => {
11813
12154
  const held = ranked.get(keyOf4(hit)) ?? { hit, score: 0, by: [] };
11814
12155
  held.score += 1 / (RRF_K3 + rank + 1);
11815
12156
  held.by.push(half);
@@ -11829,7 +12170,7 @@ var searchEvents = /* @__PURE__ */ __name(async (store, query, { limit = 20, off
11829
12170
  };
11830
12171
  }, "searchEvents");
11831
12172
 
11832
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/search-all.js
12173
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/search-all.js
11833
12174
  var RESOURCES_SEARCHED = ["messages", "mail", "notes", "events"];
11834
12175
  var skippable = /* @__PURE__ */ __name((error) => error instanceof CliError && (error.code === "validation_error" || error.code === "not_found"), "skippable");
11835
12176
  var filtersBeside = /* @__PURE__ */ __name((text2) => {
@@ -11916,7 +12257,7 @@ var searchAll = /* @__PURE__ */ __name(async (store, account2, request, messenge
11916
12257
  return byWords;
11917
12258
  }
11918
12259
  messagesBy = { by: "words and meaning", ...lane.partly ? { meaningSkipped: lane.partly } : {} };
11919
- const near2 = await nearEligible(store, account2, query, messenger, lane.ranked, filters ?? "");
12260
+ const near2 = await nearEligible(store, account2, query, messenger, lane.ranked, filters ? { text: filters } : {});
11920
12261
  const fused2 = /* @__PURE__ */ new Map();
11921
12262
  byWords.forEach((item, rank) => {
11922
12263
  fused2.set(item.ref, { item, score: 1 / (RRF_K3 + rank + 1) });
@@ -12013,8 +12354,8 @@ var searchAll = /* @__PURE__ */ __name(async (store, account2, request, messenge
12013
12354
  await embedders.close();
12014
12355
  }
12015
12356
  const ranked = /* @__PURE__ */ new Map();
12016
- for (const list2 of lists)
12017
- list2.forEach((item, rank) => {
12357
+ for (const list3 of lists)
12358
+ list3.forEach((item, rank) => {
12018
12359
  const held = ranked.get(item.ref) ?? { item, score: 0 };
12019
12360
  held.score += 1 / (RRF_K3 + rank + 1);
12020
12361
  ranked.set(item.ref, held);
@@ -12037,7 +12378,7 @@ var searchAll = /* @__PURE__ */ __name(async (store, account2, request, messenge
12037
12378
  };
12038
12379
  }, "searchAll");
12039
12380
 
12040
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/search-all-meetings.js
12381
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/search-all-meetings.js
12041
12382
  var RESOURCES_SEARCHED_WITH_MEETINGS = [...RESOURCES_SEARCHED, "meetings"];
12042
12383
  var whole2 = /* @__PURE__ */ __name((value, minimum, maximum, label) => {
12043
12384
  if (!Number.isSafeInteger(value) || value < minimum || value > maximum)
@@ -12199,8 +12540,8 @@ var searchAllIncludingMeetings = /* @__PURE__ */ __name(async (store, account2,
12199
12540
  };
12200
12541
  }
12201
12542
  const ranked = /* @__PURE__ */ new Map();
12202
- for (const list2 of [legacy.items, meetings.items.map(({ item }) => item)])
12203
- list2.forEach((item, rank) => {
12543
+ for (const list3 of [legacy.items, meetings.items.map(({ item }) => item)])
12544
+ list3.forEach((item, rank) => {
12204
12545
  const key = item.kind === "meeting" ? JSON.stringify([item.kind, item.accountId, item.meetingId, item.scope, item.id]) : item.ref;
12205
12546
  const held = ranked.get(key) ?? { item, score: 0 };
12206
12547
  held.score += 1 / (RRF_K3 + rank + 1);
@@ -12284,7 +12625,7 @@ var searchAllOfSource = /* @__PURE__ */ __name(async (store, account2, source, r
12284
12625
  return { ...found, skipped: [...skipped, ...empty2, ...unnamed, ...found.skipped] };
12285
12626
  }, "searchAllOfSource");
12286
12627
 
12287
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/server-search.js
12628
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/server-search.js
12288
12629
  var SERVER_SEARCH_KEY = "messages.server-search";
12289
12630
  var SERVER_BOUNDS = { timeMs: 5e3, perCall: 100, maxCalls: 3 };
12290
12631
  var DEFAULT_BACKEND = "both";
@@ -12462,18 +12803,18 @@ var searchServer = /* @__PURE__ */ __name(async (deps, request) => {
12462
12803
  report.new += 1;
12463
12804
  byChat.set(hit.chatId, [...byChat.get(hit.chatId) ?? [], hit]);
12464
12805
  }
12465
- const unknown = [];
12806
+ const unknown2 = [];
12466
12807
  for (const [chatId, chat] of chats)
12467
12808
  if (!(await store.messages.messages(account2, chatId, { limit: 1 })).items.length)
12468
- unknown.push(chat);
12469
- if (unknown.length)
12470
- await store.chats.saveChats(account2, unknown);
12809
+ unknown2.push(chat);
12810
+ if (unknown2.length)
12811
+ await store.chats.saveChats(account2, unknown2);
12471
12812
  for (const [chatId, hits] of byChat)
12472
12813
  await store.messages.saveMessages(account2, chatId, hits.map(({ chatTitle, ...message }) => message), { via: "search" });
12473
12814
  return { report, sources };
12474
12815
  }, "searchServer");
12475
12816
 
12476
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/messages.js
12817
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/messages.js
12477
12818
  var DELETE_AT_ONCE = 10;
12478
12819
  var messagesService = /* @__PURE__ */ __name((deps) => {
12479
12820
  const { guard } = deps;
@@ -12899,7 +13240,7 @@ var checkMediaOptions = /* @__PURE__ */ __name((messenger, asked, attachments) =
12899
13240
  throw new CliError("validation_error", `${MEDIA_FLAGS[first]} needs a --photo or --file`);
12900
13241
  }, "checkMediaOptions");
12901
13242
 
12902
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/channel-tags.js
13243
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/domain/channel-tags.js
12903
13244
  var CHANNEL_TAG_RULES_VERSION = "keywords-v1";
12904
13245
  var RULES = {
12905
13246
  ai: [/\b(ai|gpt|llm|machine learning|artificial intelligence)\b/iu, /нейросет|искусственн/iu],
@@ -12914,7 +13255,7 @@ var classifyChannel = /* @__PURE__ */ __name((metadata) => Object.entries(RULES)
12914
13255
  return fields.length ? [{ tag, score: fields.length / 3, fields }] : [];
12915
13256
  }), "classifyChannel");
12916
13257
 
12917
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/metadata.js
13258
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/metadata.js
12918
13259
  var metadataService = /* @__PURE__ */ __name((deps) => {
12919
13260
  const held = /* @__PURE__ */ __name(async (reference, { includeLeft = false } = {}) => {
12920
13261
  const store = await deps.store();
@@ -13000,24 +13341,355 @@ var metadataService = /* @__PURE__ */ __name((deps) => {
13000
13341
  };
13001
13342
  }, "metadataService");
13002
13343
 
13003
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/moderation/run.js
13344
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/moderation/check.js
13345
+ var INVITE = /max\.ru\/join\/|(t|telegram)\.me\/(\+|joinchat\/)|tg:\/\/join/i;
13346
+ var LINK2 = /https?:\/\/\S+/i;
13347
+ var STRENGTH = { report: 0, delete: 1, remove: 2 };
13348
+ var judge = /* @__PURE__ */ __name(({ rules, messages, joined, answerers: answerers2, service, now, invites }) => {
13349
+ const invite = invites ? new RegExp(`${INVITE.source}|${invites.source}`, "i") : INVITE;
13350
+ const trusted = new Set(rules.trusted);
13351
+ const blocked = /* @__PURE__ */ __name((id2, name) => id2 !== null && rules.blocked.includes(id2) || name !== null && rules.blockedNames.some((part) => name.toLocaleLowerCase().includes(part.toLocaleLowerCase())), "blocked");
13352
+ const young = /* @__PURE__ */ __name((member) => rules.newAccount.days > 0 && typeof member.registeredAt === "string" && now - Date.parse(member.registeredAt) < rules.newAccount.days * 864e5, "young");
13353
+ const found = [];
13354
+ const add = /* @__PURE__ */ __name((finding) => {
13355
+ if (finding.action === "remove" && found.some((f) => f.action === "remove" && f.personId === finding.personId)) {
13356
+ return;
13357
+ }
13358
+ found.push(finding);
13359
+ }, "add");
13360
+ for (const member of joined) {
13361
+ if (trusted.has(member.id) || answerers2.has(member.id))
13362
+ continue;
13363
+ const person = { kind: "member", personId: member.id, personName: member.name };
13364
+ if (blocked(member.id, member.name)) {
13365
+ add({ ...person, rule: "blocked", action: rules.blockedPeople === "remove" ? "remove" : "report" });
13366
+ } else if (young(member)) {
13367
+ add({ ...person, rule: "newAccount", action: rules.newAccount.action });
13368
+ }
13369
+ }
13370
+ const flooding = floodOf(messages, rules.flood);
13371
+ for (const message of messages) {
13372
+ const id2 = message.senderId;
13373
+ if (id2 === null || message.outgoing === true || answerers2.has(id2) || trusted.has(id2))
13374
+ continue;
13375
+ if (service.has(message.id) || message.attachments.some((attachment2) => attachment2.kind === "control"))
13376
+ continue;
13377
+ const base = { kind: "message", personId: id2, personName: message.senderName, messageId: message.id };
13378
+ const text2 = message.text;
13379
+ const broken2 = [];
13380
+ if (blocked(id2, message.senderName))
13381
+ broken2.push(["blocked", rules.blockedPeople]);
13382
+ if (invite.test(text2))
13383
+ broken2.push(["invites", rules.invites]);
13384
+ if (LINK2.test(text2) || message.attachments.some((attachment2) => attachment2.kind === "share")) {
13385
+ broken2.push(["links", rules.links]);
13386
+ }
13387
+ if (message.forwardedFrom !== null)
13388
+ broken2.push(["forwards", rules.forwards]);
13389
+ if (flooding.has(message.id))
13390
+ broken2.push(["flood", rules.flood.action]);
13391
+ const strongest = broken2.reduce((best, rule) => best === void 0 || STRENGTH[rule[1]] > STRENGTH[best[1]] ? rule : best, void 0);
13392
+ if (strongest)
13393
+ add({ ...base, rule: strongest[0], action: strongest[1] });
13394
+ }
13395
+ return found;
13396
+ }, "judge");
13397
+ var floodOf = /* @__PURE__ */ __name((messages, flood) => {
13398
+ const window2 = flood.minutes * 6e4;
13399
+ const over = /* @__PURE__ */ new Set();
13400
+ const bySender = /* @__PURE__ */ new Map();
13401
+ for (const message of messages) {
13402
+ if (message.senderId === null)
13403
+ continue;
13404
+ const times = bySender.get(message.senderId) ?? [];
13405
+ const at = Date.parse(message.timestamp);
13406
+ times.push(at);
13407
+ bySender.set(message.senderId, times);
13408
+ if (times.filter((time) => at - time < window2).length > flood.messages)
13409
+ over.add(message.id);
13410
+ }
13411
+ return over;
13412
+ }, "floodOf");
13413
+ var act = /* @__PURE__ */ __name(async (moderator, findings, options) => {
13414
+ const { chatId, rules, allowDangerous, dryRun, maxActions, confirm, command } = options;
13415
+ const typed = options.commandFor ?? ((chat, finding) => commandFor(command, chat, finding));
13416
+ const rows = [];
13417
+ let acted = 0;
13418
+ let stopped;
13419
+ for (const finding of findings) {
13420
+ if (finding.action === "report") {
13421
+ rows.push({ ...finding, outcome: "reported" });
13422
+ continue;
13423
+ }
13424
+ const consent = finding.action;
13425
+ const level2 = rules.consent[consent];
13426
+ const row = /* @__PURE__ */ __name((outcome2, reason) => ({
13427
+ ...finding,
13428
+ outcome: outcome2,
13429
+ ...reason ? { reason } : {},
13430
+ ...outcome2 === "done" || outcome2 === "reported" ? {} : { command: typed(chatId, finding) }
13431
+ }), "row");
13432
+ if (level2 === "deny") {
13433
+ rows.push(row("forbidden", `consent.${consent} is deny`));
13434
+ continue;
13435
+ }
13436
+ if (level2 === "readonly") {
13437
+ rows.push(row("reported", `consent.${consent} is readonly`));
13438
+ continue;
13439
+ }
13440
+ if (dryRun) {
13441
+ rows.push(row("planned", "--dry-run"));
13442
+ continue;
13443
+ }
13444
+ if (stopped || acted >= maxActions) {
13445
+ rows.push(row("skipped", stopped ?? `over the limit of ${maxActions} actions per check`));
13446
+ continue;
13447
+ }
13448
+ if (level2 === "ask" && !allowDangerous) {
13449
+ const yes = confirm ? await confirm(finding) : void 0;
13450
+ if (yes === void 0) {
13451
+ rows.push(row("planned", `consent.${consent} is ask, and nobody is there to answer \u2014 run with --allow-dangerous`));
13452
+ continue;
13453
+ }
13454
+ if (!yes) {
13455
+ rows.push(row("declined", "the answer was no"));
13456
+ continue;
13457
+ }
13458
+ }
13459
+ acted += 1;
13460
+ try {
13461
+ if (finding.action === "delete" && finding.messageId) {
13462
+ await moderator.deleteMessage(chatId, finding.messageId);
13463
+ } else {
13464
+ await moderator.removePerson(chatId, finding.personId);
13465
+ }
13466
+ rows.push(row("done"));
13467
+ } catch (error) {
13468
+ const failure = asCliError(error);
13469
+ if (failure.code === "rate_limited")
13470
+ stopped = failure.message;
13471
+ const refused = ["rate_limited", "permission_error", "confirmation_required"].includes(failure.code);
13472
+ rows.push(row(refused ? "refused" : "failed", failure.message));
13473
+ }
13474
+ }
13475
+ return rows;
13476
+ }, "act");
13477
+ var asCliError = /* @__PURE__ */ __name((error) => error instanceof CliError ? error : new CliError("provider_error", error instanceof Error ? error.message : String(error)), "asCliError");
13478
+ var who = /* @__PURE__ */ __name((finding) => finding.personName ?? finding.personId, "who");
13479
+ var describe = /* @__PURE__ */ __name((finding) => finding.action === "delete" ? `delete message ${finding.messageId} from ${who(finding)} for everyone (${finding.rule})` : `remove ${who(finding)} from the group (${finding.rule})`, "describe");
13480
+ var commandFor = /* @__PURE__ */ __name((command, chatId, finding) => finding.action === "delete" ? `${command} messages delete ${chatId} ${finding.messageId} --for-everyone --allow-dangerous` : finding.action === "remove" ? `${command} chats members remove ${chatId} ${finding.personId}` : "", "commandFor");
13481
+ var CHECK_READS = 1e3;
13482
+ var PAGE5 = 100;
13483
+ var gather = /* @__PURE__ */ __name(async (adapter, chatId, since) => {
13484
+ const notes = [];
13485
+ const historyAfter = adapter.historyAfter;
13486
+ if (!historyAfter)
13487
+ throw new CliError("validation_error", "this messenger cannot read a chat forward from a time");
13488
+ const messages = [];
13489
+ let more = true;
13490
+ while (more && messages.length < CHECK_READS) {
13491
+ const last = messages.at(-1);
13492
+ const page = await historyAfter.call(adapter, chatId, {
13493
+ limit: PAGE5,
13494
+ after: last ? { id: last.id } : { time: since }
13495
+ });
13496
+ messages.push(...page.items);
13497
+ more = page.hasMore && page.items.length > 0;
13498
+ }
13499
+ const scanned = adapter.chatEvents ? (await adapter.chatEvents(chatId, { since })).events : [];
13500
+ const until = messages.at(-1)?.timestamp ?? null;
13501
+ const events = more && until !== null ? scanned.filter((event) => Date.parse(event.timestamp) <= Date.parse(until)) : scanned;
13502
+ if (!adapter.chatEvents)
13503
+ notes.push("this messenger does not say who joined, so only messages are judged");
13504
+ const joinedIds = new Set(events.filter((one) => one.event === "join" || one.event === "add").flatMap((one) => one.people.length > 0 ? one.people.map((person) => person.id) : one.by.id ? [one.by.id] : []));
13505
+ const joined = joinedIds.size === 0 || !adapter.members ? [] : (await adapter.members(chatId, { offset: 0 })).items.filter((member) => joinedIds.has(member.id));
13506
+ const admins = adapter.admins ? await adapter.admins(chatId) : null;
13507
+ if (admins === null)
13508
+ notes.push("the group's admins are not known, so only your own messages are exempt");
13509
+ return {
13510
+ messages,
13511
+ joined,
13512
+ answerers: new Set(admins ?? []),
13513
+ service: new Set(events.map((one) => one.messageId)),
13514
+ until,
13515
+ more,
13516
+ notes
13517
+ };
13518
+ }, "gather");
13519
+ var MAX_ACTIONS = 10;
13520
+ var undone = /* @__PURE__ */ __name((row) => ["planned", "skipped", "failed"].includes(row.outcome), "undone");
13521
+ var nextPoint = /* @__PURE__ */ __name((rows, found) => {
13522
+ const waiting = rows.filter(undone);
13523
+ if (waiting.some((row) => row.messageId === void 0))
13524
+ return null;
13525
+ const times = waiting.map((row) => found.messages.find((message) => message.id === row.messageId)?.timestamp).filter((time) => time !== void 0).map(Date.parse);
13526
+ if (times.length === 0)
13527
+ return found.until;
13528
+ return new Date(Math.min(...times) - 1).toISOString();
13529
+ }, "nextPoint");
13530
+ var someUndone = /* @__PURE__ */ __name((rows) => rows.some(undone), "someUndone");
13531
+
13532
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/moderation/rules.js
13533
+ import { existsSync, readFileSync } from "node:fs";
13534
+ import { join as join10 } from "node:path";
13535
+ var RULE_ACTIONS = ["report", "delete", "remove"];
13536
+ var OLD_LEVELS = { forbid: "deny", flag: "ask", confirm: "ask", allow: "allow" };
13537
+ var level = pipe(picklist([...LEVELS, ...Object.keys(OLD_LEVELS)]), transform((typed) => OLD_LEVELS[typed] ?? typed));
13538
+ var action = picklist(RULE_ACTIONS);
13539
+ var personIds = array(pipe(string(), regex(/^-?\d+$/, "a person id is digits")));
13540
+ var atLeast = /* @__PURE__ */ __name((min) => pipe(number(), integer(), minValue(min)), "atLeast");
13541
+ var groupRules = pipe(strictObject({
13542
+ title: nullable(string()),
13543
+ trusted: personIds,
13544
+ blocked: personIds,
13545
+ blockedNames: array(pipe(string(), minLength(1))),
13546
+ links: action,
13547
+ invites: action,
13548
+ forwards: action,
13549
+ blockedPeople: action,
13550
+ flood: strictObject({ messages: atLeast(1), minutes: atLeast(1), action }),
13551
+ /** 0 days turns the rule off. */
13552
+ newAccount: strictObject({ days: atLeast(0), action: picklist(["report", "remove"]) }),
13553
+ requests: optional(unknown()),
13554
+ consent: strictObject({
13555
+ delete: level,
13556
+ remove: level,
13557
+ accept: optional(unknown()),
13558
+ decline: optional(unknown())
13559
+ })
13560
+ }), transform(({ requests: _, consent: { accept: _accept, decline: _decline, ...consent }, ...rules }) => ({
13561
+ ...rules,
13562
+ consent
13563
+ })));
13564
+ var file = strictObject({
13565
+ groups: record(string(), groupRules),
13566
+ /** Where each group's next `chats moderate` starts, ISO 8601. */
13567
+ checkedUntil: optional(record(string(), string()))
13568
+ });
13569
+ var defaultRules = /* @__PURE__ */ __name((title) => ({
13570
+ title,
13571
+ trusted: [],
13572
+ blocked: [],
13573
+ blockedNames: [],
13574
+ links: "report",
13575
+ invites: "report",
13576
+ forwards: "report",
13577
+ blockedPeople: "report",
13578
+ flood: { messages: 5, minutes: 1, action: "report" },
13579
+ newAccount: { days: 7, action: "report" },
13580
+ consent: { delete: "ask", remove: "ask" }
13581
+ }), "defaultRules");
13582
+ var list2 = /* @__PURE__ */ __name((value) => value.split(",").map((item) => item.trim()).filter(Boolean), "list");
13583
+ var whole3 = /* @__PURE__ */ __name((value) => /^\d+$/.test(value.trim()) ? Number(value) : Number.NaN, "whole");
13584
+ var KEYS = {
13585
+ trusted: { help: "person ids, comma-separated; never acted on", parse: list2 },
13586
+ blocked: { help: "person ids, comma-separated", parse: list2 },
13587
+ blockedNames: { help: "parts of a name, comma-separated, any case", parse: list2 },
13588
+ links: { help: RULE_ACTIONS.join("|"), parse: String },
13589
+ invites: { help: RULE_ACTIONS.join("|"), parse: String },
13590
+ forwards: { help: RULE_ACTIONS.join("|"), parse: String },
13591
+ blockedPeople: { help: RULE_ACTIONS.join("|"), parse: String },
13592
+ "flood.messages": { help: "a whole number, 1 or more", parse: whole3 },
13593
+ "flood.minutes": { help: "a whole number, 1 or more", parse: whole3 },
13594
+ "flood.action": { help: RULE_ACTIONS.join("|"), parse: String },
13595
+ "newAccount.days": { help: "a whole number; 0 turns it off", parse: whole3 },
13596
+ "newAccount.action": { help: "report|remove", parse: String },
13597
+ "consent.delete": { help: LEVELS.join("|"), parse: String },
13598
+ "consent.remove": { help: LEVELS.join("|"), parse: String }
13599
+ };
13600
+ var RULE_KEYS = Object.keys(KEYS);
13601
+ var moderationPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join10(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.moderation.json`), "moderationPathFor");
13602
+ var ModerationRules = class {
13603
+ static {
13604
+ __name(this, "ModerationRules");
13605
+ }
13606
+ path;
13607
+ constructor(path) {
13608
+ this.path = path;
13609
+ }
13610
+ /** `undefined` when this group has no section yet. */
13611
+ read(chatId) {
13612
+ return this.#file().groups[chatId];
13613
+ }
13614
+ /** Writes the group's whole section — the defaults first, if it had none — with one key changed. */
13615
+ set(chatId, title, key, value) {
13616
+ const known2 = KEYS[key];
13617
+ if (!known2)
13618
+ throw invalid4(`no rule ${key} \u2014 one of: ${RULE_KEYS.join(", ")}`);
13619
+ const current = this.read(chatId) ?? defaultRules(title);
13620
+ const checked2 = safeParse(groupRules, assign(current, key, known2.parse(value)));
13621
+ if (!checked2.success)
13622
+ throw invalid4(`${key} ${JSON.stringify(value)} is not valid \u2014 ${known2.help}`);
13623
+ const saved = this.#file();
13624
+ this.#write({ ...saved, groups: { ...saved.groups, [chatId]: checked2.output } });
13625
+ return checked2.output;
13626
+ }
13627
+ /** Puts one key back to its default. */
13628
+ unset(chatId, title, key) {
13629
+ if (!KEYS[key])
13630
+ throw invalid4(`no rule ${key} \u2014 one of: ${RULE_KEYS.join(", ")}`);
13631
+ const current = this.read(chatId) ?? defaultRules(title);
13632
+ const changed = assign(current, key, lookup(defaultRules(title), key));
13633
+ const saved = this.#file();
13634
+ this.#write({ ...saved, groups: { ...saved.groups, [chatId]: changed } });
13635
+ return changed;
13636
+ }
13637
+ checkedUntil(chatId) {
13638
+ return this.#file().checkedUntil?.[chatId];
13639
+ }
13640
+ markChecked(chatId, at) {
13641
+ const saved = this.#file();
13642
+ this.#write({ ...saved, checkedUntil: { ...saved.checkedUntil, [chatId]: at } });
13643
+ }
13644
+ #file() {
13645
+ if (!existsSync(this.path))
13646
+ return { groups: {} };
13647
+ let parsed;
13648
+ try {
13649
+ parsed = JSON.parse(readFileSync(this.path, "utf8"));
13650
+ } catch (error) {
13651
+ throw broken(this.path, error instanceof Error ? error.message : String(error));
13652
+ }
13653
+ const checked2 = safeParse(file, parsed);
13654
+ if (!checked2.success) {
13655
+ const problems = checked2.issues.map((issue) => `${getDotPath(issue) ?? "file"}: ${issue.message}`);
13656
+ throw broken(this.path, problems.join("; "));
13657
+ }
13658
+ return checked2.output;
13659
+ }
13660
+ #write(content) {
13661
+ writeSecurely(this.path, `${JSON.stringify(content, null, 2)}
13662
+ `, 384);
13663
+ }
13664
+ };
13665
+ var invalid4 = /* @__PURE__ */ __name((message) => new CliError("validation_error", message), "invalid");
13666
+ var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the moderation rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
13667
+ var lookup = /* @__PURE__ */ __name((rules, key) => key.split(".").reduce((value, part) => value[part], rules), "lookup");
13668
+ var assign = /* @__PURE__ */ __name((rules, key, value) => {
13669
+ const [head, tail] = key.split(".");
13670
+ if (tail === void 0)
13671
+ return { ...rules, [head]: value };
13672
+ return { ...rules, [head]: { ...rules[head], [tail]: value } };
13673
+ }, "assign");
13674
+
13675
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/moderation/run.js
13004
13676
  var FIRST_LOOK_MS = 24 * 36e5;
13005
13677
  var moderateWith = /* @__PURE__ */ __name(async (run) => {
13006
13678
  const { chatId, title, rules, point, since, dryRun } = run;
13007
13679
  const saved = rules.read(chatId);
13008
- const groupRules = saved ?? defaultRules(title);
13680
+ const groupRules2 = saved ?? defaultRules(title);
13009
13681
  const last = point.read(chatId);
13010
13682
  const from = since ?? (last === void 0 ? Date.now() - FIRST_LOOK_MS : Date.parse(last));
13011
13683
  const found = await run.gather(from);
13012
13684
  const findings = judge({
13013
13685
  ...found,
13014
- rules: groupRules,
13686
+ rules: groupRules2,
13015
13687
  now: Date.now(),
13016
13688
  ...run.invites ? { invites: run.invites } : {}
13017
13689
  });
13018
13690
  const rows = await act(run.moderator, findings, {
13019
13691
  chatId,
13020
- rules: groupRules,
13692
+ rules: groupRules2,
13021
13693
  allowDangerous: run.allowDangerous,
13022
13694
  dryRun,
13023
13695
  maxActions: run.maxActions,
@@ -13037,9 +13709,9 @@ var moderateWith = /* @__PURE__ */ __name(async (run) => {
13037
13709
  return { chatId, rows, notes };
13038
13710
  }, "moderateWith");
13039
13711
 
13040
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/moderation.js
13712
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/moderation.js
13041
13713
  var moderationService = /* @__PURE__ */ __name((deps) => {
13042
- const file = /* @__PURE__ */ __name(() => new ModerationRules(moderationPathFor(deps.messenger.app, deps.profile ?? "default", deps.env ?? process.env)), "file");
13714
+ const file2 = /* @__PURE__ */ __name(() => new ModerationRules(moderationPathFor(deps.messenger.app, deps.profile ?? "default", deps.env ?? process.env)), "file");
13043
13715
  const group = /* @__PURE__ */ __name(async (chat) => {
13044
13716
  if (deps.offline)
13045
13717
  throw new CliError("validation_error", "a group's rules are kept by its id, which the messenger gives");
@@ -13057,18 +13729,18 @@ var moderationService = /* @__PURE__ */ __name((deps) => {
13057
13729
  return {
13058
13730
  rules: /* @__PURE__ */ __name(async (chat) => {
13059
13731
  const { id: id2, title } = await group(chat);
13060
- return shown(id2, title, file());
13732
+ return shown(id2, title, file2());
13061
13733
  }, "rules"),
13062
13734
  set: /* @__PURE__ */ __name(async (chat, key, value) => {
13063
13735
  refuseAge(key);
13064
13736
  const { id: id2, title } = await group(chat);
13065
- const rules = file();
13737
+ const rules = file2();
13066
13738
  rules.set(id2, title, key, value);
13067
13739
  return shown(id2, title, rules);
13068
13740
  }, "set"),
13069
13741
  unset: /* @__PURE__ */ __name(async (chat, key) => {
13070
13742
  const { id: id2, title } = await group(chat);
13071
- const rules = file();
13743
+ const rules = file2();
13072
13744
  rules.unset(id2, title, key);
13073
13745
  return shown(id2, title, rules);
13074
13746
  }, "unset"),
@@ -13077,7 +13749,7 @@ var moderationService = /* @__PURE__ */ __name((deps) => {
13077
13749
  throw new CliError("validation_error", "`chats moderate` asks the messenger what is new");
13078
13750
  const connection = await deps.connection();
13079
13751
  const { id: chatId, title } = await connection.resolve(chat);
13080
- const rules = file();
13752
+ const rules = file2();
13081
13753
  const { inviteLinks } = deps.messenger;
13082
13754
  return moderateWith({
13083
13755
  chatId,
@@ -13115,7 +13787,7 @@ var moderatorOf = /* @__PURE__ */ __name((adapter, deps) => ({
13115
13787
  }, "removePerson")
13116
13788
  }), "moderatorOf");
13117
13789
 
13118
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/person-context.js
13790
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/person-context.js
13119
13791
  var CONTEXT_MESSAGES2 = 10;
13120
13792
  var CONTEXT_BYTES = 64 * 1024;
13121
13793
  var toContext = /* @__PURE__ */ __name((key, message, chatTitle) => ({
@@ -13191,11 +13863,11 @@ var eventsOnce = /* @__PURE__ */ __name(async (store, filter, limit) => {
13191
13863
  }
13192
13864
  return { items, cut: true };
13193
13865
  }, "eventsOnce");
13194
- var readsOf = /* @__PURE__ */ __name((record, asked) => record.identities.flatMap((identity) => (identity.provider === asked.provider ? [asked.account] : identity.accounts).filter((account2) => identity.accounts.includes(account2)).map((account2) => ({ key: { provider: identity.provider, account: account2 }, identity }))), "readsOf");
13866
+ var readsOf = /* @__PURE__ */ __name((record2, asked) => record2.identities.flatMap((identity) => (identity.provider === asked.provider ? [asked.account] : identity.accounts).filter((account2) => identity.accounts.includes(account2)).map((account2) => ({ key: { provider: identity.provider, account: account2 }, identity }))), "readsOf");
13195
13867
  var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { messages = CONTEXT_MESSAGES2, bytes: bytes2 = CONTEXT_BYTES, since, now = Date.now() } = {}) => {
13196
13868
  const found = pickPerson(reference, await store.people.people(asked.provider, { account: asked.account }));
13197
- const record = await store.people.personOf({ provider: asked.provider, id: found.id });
13198
- if (!record)
13869
+ const record2 = await store.people.personOf({ provider: asked.provider, id: found.id });
13870
+ if (!record2)
13199
13871
  throw new CliError("not_found", `no person ${found.id} in the store`);
13200
13872
  const recent = /* @__PURE__ */ __name((message) => since === void 0 || Date.parse(message.timestamp) >= since, "recent");
13201
13873
  const shared = [];
@@ -13205,7 +13877,7 @@ var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { mes
13205
13877
  const theirs = [];
13206
13878
  const mentions = [];
13207
13879
  let cut = false;
13208
- for (const { key, identity } of readsOf(record, asked)) {
13880
+ for (const { key, identity } of readsOf(record2, asked)) {
13209
13881
  const chats = await store.chats.chatsWith(key, identity.id);
13210
13882
  for (const chat of chats) {
13211
13883
  shared.push({ ...key, chatId: chat.id, title: chat.title, kind: chat.kind, lastMessageAt: chat.lastMessageAt });
@@ -13253,7 +13925,7 @@ var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { mes
13253
13925
  mentions.push(...named2.items.filter((hit) => hit.senderId !== identity.id).map((hit) => toContext(key, hit, hit.chatTitle ?? null)).filter(recent));
13254
13926
  cut ||= named2.hasMore;
13255
13927
  }
13256
- const personId = Number(record.uid);
13928
+ const personId = Number(record2.uid);
13257
13929
  const upcoming = await eventsOnce(store, { personId, from: now }, messages);
13258
13930
  const upcomingIds = new Set(upcoming.items.map(({ id: id2 }) => id2));
13259
13931
  const past = await eventsOnce(store, { personId, to: now, newest: true, ...since === void 0 ? {} : { from: since } }, messages);
@@ -13273,7 +13945,7 @@ var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { mes
13273
13945
  cut ||= direct.length > messages || groups.length > messages || mentions.length > messages;
13274
13946
  const kept = withinBytes(lists, bytes2);
13275
13947
  return {
13276
- person: { ...record, provider: asked.provider, id: found.id },
13948
+ person: { ...record2, provider: asked.provider, id: found.id },
13277
13949
  shared: shared.sort((a, b) => Date.parse(b.lastMessageAt ?? "") - Date.parse(a.lastMessageAt ?? "")),
13278
13950
  last: {
13279
13951
  fromThem: each.find((message) => !message.outgoing) ?? null,
@@ -13348,8 +14020,8 @@ var lean = /* @__PURE__ */ __name((key, message, detail) => {
13348
14020
  var kindOf3 = /* @__PURE__ */ __name((chat, chatId, person) => chat && chat.kind !== "unknown" ? chat.kind : chatId === person ? "dialog" : chat?.kind ?? "unknown", "kindOf");
13349
14021
  var personMessages = /* @__PURE__ */ __name(async (store, asked, reference, { chats, limit = CHAT_MESSAGES, detail = 0 }) => {
13350
14022
  const found = pickPerson(reference, await store.people.people(asked.provider, { account: asked.account }));
13351
- const record = await store.people.personOf({ provider: asked.provider, id: found.id });
13352
- if (!record)
14023
+ const record2 = await store.people.personOf({ provider: asked.provider, id: found.id });
14024
+ if (!record2)
13353
14025
  throw new CliError("not_found", `no person ${found.id} in the store`);
13354
14026
  const stored = (await store.chats.chats(asked, {})).items;
13355
14027
  const held = new Map((await store.chats.chatCompleteness(asked, chats)).map((one) => [one.chatId, one.state]));
@@ -13365,16 +14037,16 @@ var personMessages = /* @__PURE__ */ __name(async (store, asked, reference, { ch
13365
14037
  });
13366
14038
  }
13367
14039
  return {
13368
- person: { uid: record.uid, provider: asked.provider, id: found.id, name: found.name ?? record.name },
14040
+ person: { uid: record2.uid, provider: asked.provider, id: found.id, name: found.name ?? record2.name },
13369
14041
  chats: answer,
13370
14042
  limits: { messages: limit }
13371
14043
  };
13372
14044
  }, "personMessages");
13373
14045
 
13374
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-evidence.js
14046
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-evidence.js
13375
14047
  import { createHash as createHash11 } from "node:crypto";
13376
14048
 
13377
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-reference.js
14049
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-reference.js
13378
14050
  var missing3 = /* @__PURE__ */ __name(() => new CliError("not_found", "the meeting evidence is unavailable for this account"), "missing");
13379
14051
  var authorizedMeetingMetadata = /* @__PURE__ */ __name(async (store, accountId, reference, options = {}) => {
13380
14052
  const parsed = parseMeetingReference(reference);
@@ -13422,7 +14094,7 @@ var resolveMeetingReference = /* @__PURE__ */ __name(async (store, accountId, re
13422
14094
  };
13423
14095
  }, "resolveMeetingReference");
13424
14096
 
13425
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-evidence.js
14097
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-evidence.js
13426
14098
  var hash = /* @__PURE__ */ __name((value) => createHash11("sha256").update(JSON.stringify(value)).digest("hex"), "hash");
13427
14099
  var checkMeetingCancelled = /* @__PURE__ */ __name((signal) => {
13428
14100
  if (signal?.aborted)
@@ -13621,7 +14293,7 @@ var readMeetingEvidence = /* @__PURE__ */ __name(async (store, accountId, refere
13621
14293
  return { ...packet, fingerprint: hash(packet) };
13622
14294
  }, "readMeetingEvidence");
13623
14295
 
13624
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/person-meeting-context.js
14296
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/person-meeting-context.js
13625
14297
  var personMeetingContext = /* @__PURE__ */ __name(async (store, personReference, options) => {
13626
14298
  const { meetings = 10, cues = 5, bytes: bytes2 = 64 * 1024, scanLimit = 1e3, since, signal } = options;
13627
14299
  const requestedAccounts = options.accountIds;
@@ -13720,7 +14392,7 @@ var personMeetingContext = /* @__PURE__ */ __name(async (store, personReference,
13720
14392
  };
13721
14393
  }, "personMeetingContext");
13722
14394
 
13723
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/person-preparation.js
14395
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/person-preparation.js
13724
14396
  var PREPARE_BYTES = 96 * 1024;
13725
14397
  var MEETINGS = 5;
13726
14398
  var CUES = 3;
@@ -13837,7 +14509,7 @@ var meetingsOf = /* @__PURE__ */ __name(async (store, uid, stored, since, left)
13837
14509
  }
13838
14510
  }, "meetingsOf");
13839
14511
 
13840
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/person-profile.js
14512
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/person-profile.js
13841
14513
  var personProfile = /* @__PURE__ */ __name(async (deps, person, known2) => {
13842
14514
  const online = deps.offline ? void 0 : await deps.connection();
13843
14515
  const held = await storeIfOpen(deps);
@@ -13883,7 +14555,7 @@ var activityIn = /* @__PURE__ */ __name(async (store, account2, facts) => {
13883
14555
  ...facts.chats,
13884
14556
  ...[...stats.values()].filter(({ chatId }) => !listed.has(chatId)).map(({ chatId, title, kind, lastAt }) => ({ id: chatId, title, kind, lastMessageAt: lastAt }))
13885
14557
  ];
13886
- const whole3 = new Set((await store.chats.chatCompleteness(account2, chats.map(({ id: id2 }) => id2))).filter(({ state }) => state === "complete").map(({ chatId }) => chatId));
14558
+ const whole4 = new Set((await store.chats.chatCompleteness(account2, chats.map(({ id: id2 }) => id2))).filter(({ state }) => state === "complete").map(({ chatId }) => chatId));
13887
14559
  return chats.map(({ id: id2, title, kind }) => {
13888
14560
  const one = stats.get(id2);
13889
14561
  return {
@@ -13893,7 +14565,7 @@ var activityIn = /* @__PURE__ */ __name(async (store, account2, facts) => {
13893
14565
  theirMessages: one?.messages ?? 0,
13894
14566
  firstAt: one?.firstAt ?? null,
13895
14567
  lastAt: one?.lastAt ?? null,
13896
- complete: whole3.has(id2)
14568
+ complete: whole4.has(id2)
13897
14569
  };
13898
14570
  });
13899
14571
  }, "activityIn");
@@ -13907,7 +14579,7 @@ var quiet = /* @__PURE__ */ __name((facts) => facts.chats.map(({ id: id2, title,
13907
14579
  complete: false
13908
14580
  })), "quiet");
13909
14581
 
13910
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/person-timeline.js
14582
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/person-timeline.js
13911
14583
  var TIMELINE_ITEMS = 50;
13912
14584
  var TIMELINE_MAX = 500;
13913
14585
  var SCOPES = ["personal", "work"];
@@ -13925,10 +14597,10 @@ var personTimeline = /* @__PURE__ */ __name(async (store, asked, reference, { sc
13925
14597
  if (since !== void 0 && until !== void 0 && since > until)
13926
14598
  throw new CliError("validation_error", "the start of the range is after its end");
13927
14599
  const found = pickPerson(reference, await store.people.people(asked.provider, { account: asked.account }));
13928
- const record = await store.people.personOf({ provider: asked.provider, id: found.id });
13929
- if (!record)
14600
+ const record2 = await store.people.personOf({ provider: asked.provider, id: found.id });
14601
+ if (!record2)
13930
14602
  throw new CliError("not_found", `no person ${found.id} in the store`);
13931
- const personId = Number(record.uid);
14603
+ const personId = Number(record2.uid);
13932
14604
  const pending = store.involvements.pending();
13933
14605
  const rows = store.involvements.forPerson(personId, {
13934
14606
  ...scope === void 0 ? {} : { scope },
@@ -13942,7 +14614,7 @@ var personTimeline = /* @__PURE__ */ __name(async (store, asked, reference, { sc
13942
14614
  const last = shown.at(-1);
13943
14615
  const hasMore = rows.length > limit;
13944
14616
  return {
13945
- person: { uid: record.uid, name: record.name },
14617
+ person: { uid: record2.uid, name: record2.name },
13946
14618
  items: shown.map((row) => ({
13947
14619
  at: new Date(row.occurredAt).toISOString(),
13948
14620
  subject: row.subjectType,
@@ -13962,7 +14634,7 @@ var personTimeline = /* @__PURE__ */ __name(async (store, asked, reference, { sc
13962
14634
  };
13963
14635
  }, "personTimeline");
13964
14636
 
13965
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/people.js
14637
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/people.js
13966
14638
  var peopleService = /* @__PURE__ */ __name((deps) => {
13967
14639
  const localCard = /* @__PURE__ */ __name(async (card, includeNotes = false) => {
13968
14640
  const held = await storeIfOpen(deps);
@@ -13979,20 +14651,20 @@ var peopleService = /* @__PURE__ */ __name((deps) => {
13979
14651
  const held = await storeIfOpen(deps);
13980
14652
  if (!held)
13981
14653
  return reference;
13982
- const lookup = await held.store.people.people(held.account.provider, { account: held.account.account });
14654
+ const lookup2 = await held.store.people.people(held.account.provider, { account: held.account.account });
13983
14655
  const wanted = reference.trim().toLowerCase();
13984
- return lookup.all().some((person) => person.alias?.toLowerCase().includes(wanted)) ? pickPerson(reference, lookup).id : reference;
14656
+ return lookup2.all().some((person) => person.alias?.toLowerCase().includes(wanted)) ? pickPerson(reference, lookup2).id : reference;
13985
14657
  }, "referenceOf");
13986
14658
  const online = /* @__PURE__ */ __name(async (command) => {
13987
14659
  if (deps.offline)
13988
14660
  throw new CliError("validation_error", `\`${command}\` changes the address book; not with --offline`);
13989
14661
  return deps.connection();
13990
14662
  }, "online");
13991
- const change = /* @__PURE__ */ __name(async (action, person, act2) => {
13992
- const connection = await online(`contacts ${action.slice("contact-".length)}`);
14663
+ const change = /* @__PURE__ */ __name(async (action2, person, act2) => {
14664
+ const connection = await online(`contacts ${action2.slice("contact-".length)}`);
13993
14665
  const [personId] = await capability(connection, "people", "find people")([await referenceOf(person)]);
13994
14666
  const operationId = newOperationId();
13995
- const done2 = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action }, () => act2(connection, personId));
14667
+ const done2 = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action: action2 }, () => act2(connection, personId));
13996
14668
  return { operationId, personId, done: done2 };
13997
14669
  }, "change");
13998
14670
  return {
@@ -14189,7 +14861,7 @@ var withoutPhone = /* @__PURE__ */ __name((answer) => {
14189
14861
  return rest;
14190
14862
  }, "withoutPhone");
14191
14863
 
14192
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/private-people.js
14864
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/private-people.js
14193
14865
  var noteItem = /* @__PURE__ */ __name((provider, note) => ({
14194
14866
  id: note.id,
14195
14867
  contact: formatReference({ type: "contact", provider, id: note.personId }),
@@ -14233,7 +14905,7 @@ var privatePeopleService = /* @__PURE__ */ __name((deps) => {
14233
14905
  };
14234
14906
  }, "privatePeopleService");
14235
14907
 
14236
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/rankings.js
14908
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/rankings.js
14237
14909
  var empty = /* @__PURE__ */ __name(() => ({
14238
14910
  total: 0,
14239
14911
  population: 0,
@@ -14489,7 +15161,7 @@ var rankingsService = /* @__PURE__ */ __name((deps) => ({
14489
15161
  }, "evidence")
14490
15162
  }), "rankingsService");
14491
15163
 
14492
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/searches.js
15164
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/searches.js
14493
15165
  var savedSearchItem = /* @__PURE__ */ __name((one) => ({
14494
15166
  id: one.id,
14495
15167
  name: one.name,
@@ -14618,7 +15290,7 @@ var searchesService = /* @__PURE__ */ __name((deps) => {
14618
15290
  };
14619
15291
  }, "searchesService");
14620
15292
 
14621
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/tags.js
15293
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/tags.js
14622
15294
  var TAGGING_QUERY = {
14623
15295
  entity: "tagging",
14624
15296
  backend: "sql",
@@ -14679,14 +15351,14 @@ var viewOf = /* @__PURE__ */ __name((account2, target) => target.type === "messa
14679
15351
  var tagsService = /* @__PURE__ */ __name((deps) => {
14680
15352
  const inStore = /* @__PURE__ */ __name(async (work) => work(await deps.store(), await deps.account()), "inStore");
14681
15353
  return {
14682
- add: /* @__PURE__ */ __name((given, list2) => inStore(async (store, account2) => {
14683
- const tags = tagsOf(list2);
15354
+ add: /* @__PURE__ */ __name((given, list3) => inStore(async (store, account2) => {
15355
+ const tags = tagsOf(list3);
14684
15356
  const target = await targetOf(deps, store, account2, given);
14685
15357
  const added = await store.tags.addTags(account2, target, tags);
14686
15358
  return { target: viewOf(account2, target), added, unchanged: tags.filter((tag) => !added.includes(tag)) };
14687
15359
  }), "add"),
14688
- remove: /* @__PURE__ */ __name((given, list2, source) => inStore(async (store, account2) => {
14689
- const tags = tagsOf(list2);
15360
+ remove: /* @__PURE__ */ __name((given, list3, source) => inStore(async (store, account2) => {
15361
+ const tags = tagsOf(list3);
14690
15362
  const target = await targetOf(deps, store, account2, given);
14691
15363
  const removed = await store.tags.removeTags(account2, target, tags, source);
14692
15364
  return { target: viewOf(account2, target), removed, unchanged: tags.filter((tag) => !removed.includes(tag)) };
@@ -14702,7 +15374,7 @@ var tagsService = /* @__PURE__ */ __name((deps) => {
14702
15374
  };
14703
15375
  }, "tagsService");
14704
15376
 
14705
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/tasks.js
15377
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/tasks.js
14706
15378
  var TASK_QUERY = {
14707
15379
  entity: "task",
14708
15380
  backend: "sql",
@@ -14846,21 +15518,21 @@ var tasksService = /* @__PURE__ */ __name((deps, categories) => {
14846
15518
  const author = by === "owner" ? "owner" : { bot: by };
14847
15519
  await store.tasks.edit(id2, fields, author);
14848
15520
  if (assignees !== void 0)
14849
- await assign(store, id2, assignees, author);
15521
+ await assign2(store, id2, assignees, author);
14850
15522
  return cardOf(store, id2);
14851
15523
  }, "planOf");
14852
- const assign = /* @__PURE__ */ __name(async (store, id2, given, by) => {
15524
+ const assign2 = /* @__PURE__ */ __name(async (store, id2, given, by) => {
14853
15525
  const wanted = /* @__PURE__ */ new Set();
14854
15526
  for (const one of given ?? []) {
14855
- const who = one.trim();
14856
- if (who === "sender") {
15527
+ const who2 = one.trim();
15528
+ if (who2 === "sender") {
14857
15529
  const sender = await store.tasks.sourceSender(id2);
14858
15530
  if (sender)
14859
15531
  wanted.add(sender);
14860
- } else if (/^person:\d+$/.test(who))
14861
- wanted.add(who);
15532
+ } else if (/^person:\d+$/.test(who2))
15533
+ wanted.add(who2);
14862
15534
  else
14863
- throw new CliError("validation_error", `an assignee is sender or person:<id>, not "${singleLine(who)}"`);
15535
+ throw new CliError("validation_error", `an assignee is sender or person:<id>, not "${singleLine(who2)}"`);
14864
15536
  }
14865
15537
  const current = (await store.tasks.details(id2)).assignments.filter((one) => one.role === "assignee");
14866
15538
  for (const one of current)
@@ -15182,7 +15854,7 @@ var taskView = /* @__PURE__ */ __name(async (store, account2, task2) => {
15182
15854
  };
15183
15855
  }, "taskView");
15184
15856
 
15185
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/topics.js
15857
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/topics.js
15186
15858
  var actionOf = /* @__PURE__ */ __name(({ title, closed, pinned, hidden }) => {
15187
15859
  const set = [closed, pinned, hidden].filter((one) => one !== void 0).length;
15188
15860
  if (title !== void 0 || set !== 1)
@@ -15329,8 +16001,8 @@ var topicsService = /* @__PURE__ */ __name((deps) => {
15329
16001
  const editTopic = capability(connection, "editTopic", "edit forum topics");
15330
16002
  const chatId = (await connection.resolve(chat)).id;
15331
16003
  const operationId = newOperationId();
15332
- const action = actionOf(change);
15333
- const topic = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action, key: "topics.edit", threadId: topicId }, () => editTopic(chatId, topicId, {
16004
+ const action2 = actionOf(change);
16005
+ const topic = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: action2, key: "topics.edit", threadId: topicId }, () => editTopic(chatId, topicId, {
15334
16006
  ...title === void 0 ? {} : { title },
15335
16007
  ...closed === void 0 ? {} : { closed },
15336
16008
  ...pinned === void 0 ? {} : { pinned },
@@ -15367,7 +16039,7 @@ var topicsService = /* @__PURE__ */ __name((deps) => {
15367
16039
  };
15368
16040
  }, "topicsService");
15369
16041
 
15370
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/evidence.js
16042
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/evidence.js
15371
16043
  import { createHash as createHash12, randomUUID as randomUUID5 } from "node:crypto";
15372
16044
  var hash2 = /* @__PURE__ */ __name((value) => createHash12("sha256").update(JSON.stringify(value)).digest("hex"), "hash");
15373
16045
  var positive = /* @__PURE__ */ __name((value, name, minimum = 1) => {
@@ -15441,7 +16113,7 @@ var prepareEvidencePacket = /* @__PURE__ */ __name(({ kind, source, page, limits
15441
16113
  return { ...content, id: randomUUID5(), fingerprint: hash2(content) };
15442
16114
  }, "prepareEvidencePacket");
15443
16115
 
15444
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/evidence-read.js
16116
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/evidence-read.js
15445
16117
  var readEvidencePacket = /* @__PURE__ */ __name(async (store, account2, { chat, limit, before: before2 }, messenger = {}) => {
15446
16118
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100)
15447
16119
  throw new CliError("validation_error", "evidence message limit must be an integer from 1 to 100");
@@ -15461,7 +16133,7 @@ var readEvidencePacket = /* @__PURE__ */ __name(async (store, account2, { chat,
15461
16133
  return { ...packet, nextBeforeId: older && last ? last.id : null };
15462
16134
  }, "readEvidencePacket");
15463
16135
 
15464
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-hit-search.js
16136
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-hit-search.js
15465
16137
  var refreshMeetingIndex = /* @__PURE__ */ __name(async (meetings, accountId, signal) => {
15466
16138
  let before2 = Number.POSITIVE_INFINITY;
15467
16139
  for (; ; ) {
@@ -15523,7 +16195,7 @@ var searchMeetingHits = /* @__PURE__ */ __name(async (store, query, request, opt
15523
16195
  return { ...result, selection };
15524
16196
  }, "searchMeetingHits");
15525
16197
 
15526
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-links.js
16198
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-links.js
15527
16199
  var readMeetingLinks = /* @__PURE__ */ __name(async (store, request) => {
15528
16200
  const { maxMessages, url, ...selecting } = request;
15529
16201
  const { input, selection } = await resolveMeetingSelection(store, selecting);
@@ -15562,24 +16234,24 @@ var readMeetingLinks = /* @__PURE__ */ __name(async (store, request) => {
15562
16234
  };
15563
16235
  }, "readMeetingLinks");
15564
16236
 
15565
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidates.js
16237
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidates.js
15566
16238
  import { createHash as createHash13 } from "node:crypto";
15567
16239
 
15568
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidate-validation.js
15569
- function invalid3(field, response = false) {
16240
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidate-validation.js
16241
+ function invalid5(field, response = false) {
15570
16242
  throw new CliError(response ? "invalid_response" : "validation_error", `invalid project candidate ${field}`);
15571
16243
  }
15572
- __name(invalid3, "invalid");
16244
+ __name(invalid5, "invalid");
15573
16245
  var object2 = /* @__PURE__ */ __name((value, fields, field) => {
15574
16246
  if (!value || typeof value !== "object" || Array.isArray(value))
15575
- invalid3(field);
16247
+ invalid5(field);
15576
16248
  for (const key of Object.keys(value))
15577
16249
  if (!fields.includes(key))
15578
- invalid3(`${field}.${key}`);
16250
+ invalid5(`${field}.${key}`);
15579
16251
  }, "object");
15580
16252
  var bounded = /* @__PURE__ */ __name((value, max, field) => {
15581
16253
  if (typeof value !== "string" || value.length > max)
15582
- invalid3(field);
16254
+ invalid5(field);
15583
16255
  return value;
15584
16256
  }, "bounded");
15585
16257
  var utf8 = /* @__PURE__ */ __name((value) => new TextEncoder().encode(value).byteLength, "utf8");
@@ -15594,10 +16266,10 @@ var candidateLimits = /* @__PURE__ */ __name((options = {}) => {
15594
16266
  for (const [key, value] of Object.entries(limits)) {
15595
16267
  const max = key === "limit" ? 10 : key === "maxProjects" ? 128 : 65536;
15596
16268
  if (!Number.isSafeInteger(value) || value < (key === "bytes" ? 1024 : 1) || value > max)
15597
- invalid3(key);
16269
+ invalid5(key);
15598
16270
  }
15599
16271
  if (options.signal !== void 0 && !(options.signal instanceof AbortSignal))
15600
- invalid3("signal");
16272
+ invalid5("signal");
15601
16273
  return limits;
15602
16274
  }, "candidateLimits");
15603
16275
  var candidateInput = /* @__PURE__ */ __name((input, accountId) => {
@@ -15605,11 +16277,11 @@ var candidateInput = /* @__PURE__ */ __name((input, accountId) => {
15605
16277
  const reference = bounded(input.reference, 200, "reference");
15606
16278
  const parent = parseMeetingReference(reference);
15607
16279
  if (parent.accountId !== accountId || parent.transcriptId !== void 0 || formatMeetingReference(parent) !== reference)
15608
- invalid3("reference");
16280
+ invalid5("reference");
15609
16281
  if (input.title !== void 0)
15610
16282
  bounded(input.title, 8192, "title");
15611
16283
  if (input.cues !== void 0 && (!Array.isArray(input.cues) || input.cues.length > 100))
15612
- invalid3("cues");
16284
+ invalid5("cues");
15613
16285
  let bytes2 = utf8(input.title ?? "");
15614
16286
  const cues = /* @__PURE__ */ new Map();
15615
16287
  for (const cue of input.cues ?? []) {
@@ -15617,74 +16289,74 @@ var candidateInput = /* @__PURE__ */ __name((input, accountId) => {
15617
16289
  const ref = bounded(cue.reference, 200, "cue.reference");
15618
16290
  bounded(cue.text, 65536, "cue.text");
15619
16291
  if (!/^[a-f0-9]{64}$/.test(bounded(cue.fingerprint, 64, "cue.fingerprint")))
15620
- invalid3("cue.fingerprint");
16292
+ invalid5("cue.fingerprint");
15621
16293
  if (cue.revision !== "current" && cue.revision !== "superseded")
15622
- invalid3("cue.revision");
16294
+ invalid5("cue.revision");
15623
16295
  const parsed = parseMeetingReference(ref);
15624
16296
  if (parsed.accountId !== accountId || parsed.meetingId !== parent.meetingId || parsed.cuePosition === void 0 || formatMeetingReference(parsed) !== ref)
15625
- invalid3("cue.reference");
16297
+ invalid5("cue.reference");
15626
16298
  bytes2 += utf8(cue.text);
15627
16299
  if (bytes2 > 65536)
15628
- invalid3("input bytes");
16300
+ invalid5("input bytes");
15629
16301
  const previous = cues.get(ref);
15630
16302
  if (previous && (previous.text !== cue.text || previous.fingerprint !== cue.fingerprint || previous.revision !== cue.revision))
15631
- invalid3("conflicting cue.reference");
16303
+ invalid5("conflicting cue.reference");
15632
16304
  cues.set(ref, { reference: ref, fingerprint: cue.fingerprint, text: cue.text, revision: cue.revision });
15633
16305
  }
15634
16306
  if (bytes2 > 65536)
15635
- invalid3("input bytes");
16307
+ invalid5("input bytes");
15636
16308
  return { reference, ...input.title === void 0 ? {} : { title: input.title }, cues: [...cues.values()] };
15637
16309
  }, "candidateInput");
15638
16310
  var candidateCatalog = /* @__PURE__ */ __name((catalog, limits) => {
15639
16311
  if (!catalog || !Array.isArray(catalog.entries) || catalog.entries.length > limits.maxProjects)
15640
- invalid3("catalog.entries", true);
16312
+ invalid5("catalog.entries", true);
15641
16313
  if (typeof catalog.fingerprint !== "string" || !catalog.fingerprint || catalog.fingerprint.length > 200 || /[\p{Cc}\p{Cf}]/u.test(catalog.fingerprint) || catalog.coverage?.complete !== true || catalog.coverage.maxEntries !== limits.maxProjects || catalog.coverage.maxReadBytes !== limits.maxVocabularyReadBytes)
15642
- invalid3("catalog.coverage", true);
16314
+ invalid5("catalog.coverage", true);
15643
16315
  let aliases = 0, bytes2 = 0;
15644
16316
  const ids = /* @__PURE__ */ new Set();
15645
16317
  const aliasIds = /* @__PURE__ */ new Set();
15646
16318
  const id2 = /* @__PURE__ */ __name((value) => {
15647
16319
  if (typeof value !== "string" || !/^[1-9]\d{0,15}$/.test(value) || !Number.isSafeInteger(Number(value)))
15648
- invalid3("catalog.id", true);
16320
+ invalid5("catalog.id", true);
15649
16321
  }, "id");
15650
16322
  const name = /* @__PURE__ */ __name((value) => {
15651
16323
  try {
15652
16324
  normalizeVocabularyName(value);
15653
16325
  } catch {
15654
- invalid3("catalog.name", true);
16326
+ invalid5("catalog.name", true);
15655
16327
  }
15656
16328
  bytes2 += utf8(value);
15657
16329
  }, "name");
15658
16330
  for (const entry of catalog.entries) {
15659
16331
  if (entry?.kind !== "project")
15660
- invalid3("catalog.kind", true);
16332
+ invalid5("catalog.kind", true);
15661
16333
  id2(entry.id);
15662
16334
  if (ids.has(entry.id))
15663
- invalid3("catalog.id", true);
16335
+ invalid5("catalog.id", true);
15664
16336
  ids.add(entry.id);
15665
16337
  name(entry.name);
15666
16338
  if (entry.key !== null)
15667
16339
  name(entry.key);
15668
16340
  if (!Array.isArray(entry.aliases))
15669
- invalid3("catalog.aliases", true);
16341
+ invalid5("catalog.aliases", true);
15670
16342
  aliases += entry.aliases.length;
15671
16343
  if (aliases > limits.maxProjects * 20)
15672
- invalid3("catalog.aliases", true);
16344
+ invalid5("catalog.aliases", true);
15673
16345
  for (const alias of entry.aliases) {
15674
16346
  if (!alias)
15675
- invalid3("catalog.alias", true);
16347
+ invalid5("catalog.alias", true);
15676
16348
  id2(alias.id);
15677
16349
  if (aliasIds.has(alias.id))
15678
- invalid3("catalog.alias.id", true);
16350
+ invalid5("catalog.alias.id", true);
15679
16351
  aliasIds.add(alias.id);
15680
16352
  name(alias.name);
15681
16353
  }
15682
16354
  if (bytes2 > limits.maxVocabularyReadBytes)
15683
- invalid3("catalog.bytes", true);
16355
+ invalid5("catalog.bytes", true);
15684
16356
  }
15685
16357
  }, "candidateCatalog");
15686
16358
 
15687
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidates.js
16359
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidates.js
15688
16360
  var createMeetingProjectCandidateReader = /* @__PURE__ */ __name((scope, accountId, ports) => {
15689
16361
  const fixed = snapshotMeetingScope(scope);
15690
16362
  if (!Number.isSafeInteger(accountId) || accountId < 1 || typeof ports?.vocabulary?.vocabulary !== "function")
@@ -15737,7 +16409,7 @@ var createMeetingProjectCandidateReader = /* @__PURE__ */ __name((scope, account
15737
16409
  };
15738
16410
  }, "createMeetingProjectCandidateReader");
15739
16411
 
15740
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-discovery.js
16412
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-project-discovery.js
15741
16413
  import { createHash as createHash14 } from "node:crypto";
15742
16414
  var scopeKeys = [
15743
16415
  "accountId",
@@ -15872,7 +16544,7 @@ var readMeetingProjectDiscovery = /* @__PURE__ */ __name(async (ports, projectNa
15872
16544
  };
15873
16545
  }, "readMeetingProjectDiscovery");
15874
16546
 
15875
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-review.js
16547
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-review.js
15876
16548
  var readMeetingReview = /* @__PURE__ */ __name(async (store, request) => {
15877
16549
  const { limit, ...selecting } = request;
15878
16550
  const { input, selection } = await resolveMeetingSelection(store, selecting);
@@ -15880,7 +16552,7 @@ var readMeetingReview = /* @__PURE__ */ __name(async (store, request) => {
15880
16552
  return { ...review, selection };
15881
16553
  }, "readMeetingReview");
15882
16554
 
15883
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-searches.js
16555
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-searches.js
15884
16556
  var KIND = ["meetings-search"];
15885
16557
  var meetingSearchesService = /* @__PURE__ */ __name((searches) => {
15886
16558
  const found = /* @__PURE__ */ __name(async (reference) => {
@@ -15894,9 +16566,9 @@ var meetingSearchesService = /* @__PURE__ */ __name((searches) => {
15894
16566
  });
15895
16567
  return search;
15896
16568
  }, "found");
15897
- const record = /* @__PURE__ */ __name(({ query, options }) => searchRecordOf("meetings-search", { ...options, text: query }), "record");
16569
+ const record2 = /* @__PURE__ */ __name(({ query, options }) => searchRecordOf("meetings-search", { ...options, text: query }), "record");
15898
16570
  return {
15899
- create: /* @__PURE__ */ __name(async (name, params, { replace = false } = {}) => (await searches()).saveSearch(nameOf(name), record(params), { replace }), "create"),
16571
+ create: /* @__PURE__ */ __name(async (name, params, { replace = false } = {}) => (await searches()).saveSearch(nameOf(name), record2(params), { replace }), "create"),
15900
16572
  list: /* @__PURE__ */ __name(async () => (await searches()).savedSearches(KIND), "list"),
15901
16573
  show: found,
15902
16574
  delete: /* @__PURE__ */ __name(async (reference) => (await searches()).deleteSearch((await found(reference)).id), "delete"),
@@ -15904,13 +16576,13 @@ var meetingSearchesService = /* @__PURE__ */ __name((searches) => {
15904
16576
  const search = await found(reference);
15905
16577
  const { text: text2, ...options } = search.params;
15906
16578
  const query = { query: String(text2 ?? ""), options };
15907
- await (await searches()).recordSearch(record(query), { saved: search.id });
16579
+ await (await searches()).recordSearch(record2(query), { saved: search.id });
15908
16580
  return { id: search.id, name: search.name, ...query };
15909
16581
  }, "run")
15910
16582
  };
15911
16583
  }, "meetingSearchesService");
15912
16584
 
15913
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-stats.js
16585
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-stats.js
15914
16586
  var readMeetingStats = /* @__PURE__ */ __name(async (store, request) => {
15915
16587
  const { timeZone, maxRows, ...selecting } = request;
15916
16588
  const { input, selection } = await resolveMeetingSelection(store, selecting);
@@ -15922,7 +16594,7 @@ var readMeetingStats = /* @__PURE__ */ __name(async (store, request) => {
15922
16594
  return { ...stats, selection };
15923
16595
  }, "readMeetingStats");
15924
16596
 
15925
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-hit-context.js
16597
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-hit-context.js
15926
16598
  import { createHash as createHash15 } from "node:crypto";
15927
16599
  var contextCue = /* @__PURE__ */ __name((cue) => ({
15928
16600
  ref: cue.reference,
@@ -16040,7 +16712,7 @@ var readMeetingHitContext = /* @__PURE__ */ __name(async (store, accountId, refe
16040
16712
  return { ...packet, fingerprint: createHash15("sha256").update(JSON.stringify(packet)).digest("hex") };
16041
16713
  }, "readMeetingHitContext");
16042
16714
 
16043
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-passage-format.js
16715
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-passage-format.js
16044
16716
  var visible = /* @__PURE__ */ __name((text2) => text2.replace(/[\p{Cc}\p{Cf}]/gu, (value) => value === "\n" || value === " " ? value : `\\u{${value.codePointAt(0)?.toString(16)}}`), "visible");
16045
16717
  var markdown = /* @__PURE__ */ __name((text2) => visible(text2).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replace(/[\\`*_[\]#|~]/g, "\\$&"), "markdown");
16046
16718
  var timestamp = /* @__PURE__ */ __name((ms) => {
@@ -16116,7 +16788,7 @@ var readMeetingPassage = /* @__PURE__ */ __name(async (store, accountId, referen
16116
16788
  return { packet, content };
16117
16789
  }, "readMeetingPassage");
16118
16790
 
16119
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-batch.js
16791
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-batch.js
16120
16792
  var createMeetingBatchReader = /* @__PURE__ */ __name((store, accountId) => {
16121
16793
  if (!Number.isSafeInteger(accountId) || accountId < 1)
16122
16794
  throw new CliError("validation_error", "choose a positive meeting account");
@@ -16130,10 +16802,10 @@ var createMeetingBatchReader = /* @__PURE__ */ __name((store, accountId) => {
16130
16802
  };
16131
16803
  }, "createMeetingBatchReader");
16132
16804
 
16133
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-combined.js
16805
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-combined.js
16134
16806
  import { createHash as createHash16 } from "node:crypto";
16135
16807
 
16136
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-semantic.js
16808
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-semantic.js
16137
16809
  var positive2 = /* @__PURE__ */ __name((value, name, max) => {
16138
16810
  if (!Number.isSafeInteger(value) || value < 1 || value > max)
16139
16811
  throw new CliError("validation_error", `Invalid ${name}`);
@@ -16285,7 +16957,7 @@ var applyMeetingEmbedding = /* @__PURE__ */ __name(async (store, accountId, embe
16285
16957
  };
16286
16958
  }, "applyMeetingEmbedding");
16287
16959
 
16288
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-combined.js
16960
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-combined.js
16289
16961
  var DEPTH = 200;
16290
16962
  var cursorOf3 = /* @__PURE__ */ __name((value, key) => {
16291
16963
  if (value === void 0)
@@ -16422,7 +17094,7 @@ var searchMeetingsCombined = /* @__PURE__ */ __name(async (store, embedder, type
16422
17094
  };
16423
17095
  }, "searchMeetingsCombined");
16424
17096
 
16425
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-context.js
17097
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-context.js
16426
17098
  var meetingReferences = /* @__PURE__ */ __name((values) => values.map((value) => formatMeetingReference(parseMeetingReference(value))), "meetingReferences");
16427
17099
  var checkCancelled = /* @__PURE__ */ __name((signal) => {
16428
17100
  if (!signal?.aborted)
@@ -16527,8 +17199,8 @@ var createMeetingContextService = /* @__PURE__ */ __name(async (store, input, op
16527
17199
  };
16528
17200
  }, "createMeetingContextService");
16529
17201
 
16530
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
16531
- var integer = /* @__PURE__ */ __name((value, name, max) => {
17202
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
17203
+ var integer2 = /* @__PURE__ */ __name((value, name, max) => {
16532
17204
  if (!Number.isSafeInteger(value) || value < 1 || value > max)
16533
17205
  throw new CliError("validation_error", `Invalid ${name}`);
16534
17206
  return value;
@@ -16548,7 +17220,7 @@ var validatedRemote = /* @__PURE__ */ __name((remote) => {
16548
17220
  throw new CliError("validation_error", "Embedding endpoint requires HTTP/S without credentials, query or fragment");
16549
17221
  if (typeof remote.model !== "string" || !/^[\w./:-]{1,200}$/.test(remote.model))
16550
17222
  throw new CliError("validation_error", "Invalid embedding model name");
16551
- const dims = integer(remote.dims, "embedding dimensions", 8192);
17223
+ const dims = integer2(remote.dims, "embedding dimensions", 8192);
16552
17224
  const baseUrl = remote.baseUrl.replace(/\/+$/, "");
16553
17225
  const result = remoteModel({ model: remote.model, dims, ...baseUrl === OPENAI_URL ? {} : { baseUrl } });
16554
17226
  return result;
@@ -16630,10 +17302,10 @@ var openMeetingEmbedder = /* @__PURE__ */ __name(async (choice, options = {}) =>
16630
17302
  const descriptor2 = meetingEmbeddingModel(choice);
16631
17303
  const { signal } = options;
16632
17304
  cancelled3(signal);
16633
- const maxInputBytes = integer(options.maxInputBytes ?? 1024 * 1024, "input byte budget", 16 * 1024 * 1024);
16634
- const maxResponseBytes = integer(options.maxResponseBytes ?? 8 * 1024 * 1024, "response byte budget", 64 * 1024 * 1024);
17305
+ const maxInputBytes = integer2(options.maxInputBytes ?? 1024 * 1024, "input byte budget", 16 * 1024 * 1024);
17306
+ const maxResponseBytes = integer2(options.maxResponseBytes ?? 8 * 1024 * 1024, "response byte budget", 64 * 1024 * 1024);
16635
17307
  if (options.threads !== void 0)
16636
- integer(options.threads, "embedding threads", 128);
17308
+ integer2(options.threads, "embedding threads", 128);
16637
17309
  let engine;
16638
17310
  let remoteFailure;
16639
17311
  if (typeof choice === "string") {
@@ -16754,7 +17426,7 @@ var openMeetingEmbedder = /* @__PURE__ */ __name(async (choice, options = {}) =>
16754
17426
  };
16755
17427
  }, "openMeetingEmbedder");
16756
17428
 
16757
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/context/communication-selection.js
17429
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/context/communication-selection.js
16758
17430
  var communicationFields = {
16759
17431
  sources: pipe(array(strictObject({
16760
17432
  id: pipe(string(), regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)),
@@ -16786,7 +17458,7 @@ var communicationRequest = /* @__PURE__ */ __name((value, preparationAfter) => {
16786
17458
  return { ...input, after, before: before2 };
16787
17459
  }, "communicationRequest");
16788
17460
 
16789
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-preparation-validation.js
17461
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-preparation-validation.js
16790
17462
  var MEETING_PREPARATION_LIMITS = {
16791
17463
  meetings: { min: 1, max: 20, default: 5 },
16792
17464
  cues: { min: 1, max: 100, default: 10 },
@@ -16872,7 +17544,7 @@ var preparationRequest = /* @__PURE__ */ __name((accountId, externalId, original
16872
17544
  return { ...input, history };
16873
17545
  }, "preparationRequest");
16874
17546
 
16875
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-communications-preparation.js
17547
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-communications-preparation.js
16876
17548
  var readPreparationCommunications = /* @__PURE__ */ __name(async (plan, signal) => {
16877
17549
  const section = {
16878
17550
  readUsage: plan.reader.usage(),
@@ -16923,9 +17595,9 @@ var readPreparationCommunications = /* @__PURE__ */ __name(async (plan, signal)
16923
17595
  continue;
16924
17596
  refs.add(item.ref);
16925
17597
  const text2 = excerpt(item.text, plan.input.query, 300, { literal: true });
16926
- const whole3 = item.text.replace(/\s+/g, " ").trim();
17598
+ const whole4 = item.text.replace(/\s+/g, " ").trim();
16927
17599
  const { sender: _, ...rest } = item;
16928
- items.push({ ...rest, text: text2, selectionId: read.id, textTruncated: text2 !== whole3 });
17600
+ items.push({ ...rest, text: text2, selectionId: read.id, textTruncated: text2 !== whole4 });
16929
17601
  }
16930
17602
  } catch (error) {
16931
17603
  preparationCancelled(signal);
@@ -16977,7 +17649,7 @@ var appendPreparationCommunications = /* @__PURE__ */ __name((result, read) => {
16977
17649
  result.knowledge.coverage.otherSources = "see-communications";
16978
17650
  }, "appendPreparationCommunications");
16979
17651
 
16980
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-communications-selection.js
17652
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-communications-selection.js
16981
17653
  var captureCommunicationSelections = /* @__PURE__ */ __name((port) => {
16982
17654
  if (port === void 0)
16983
17655
  return void 0;
@@ -17082,13 +17754,13 @@ var validatePreparationCommunications = /* @__PURE__ */ __name((section, request
17082
17754
  }
17083
17755
  }, "validatePreparationCommunications");
17084
17756
 
17085
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-knowledge-preparation.js
17086
- var invalid4 = /* @__PURE__ */ __name(() => {
17757
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-knowledge-preparation.js
17758
+ var invalid6 = /* @__PURE__ */ __name(() => {
17087
17759
  throw new CliError("invalid_response", "Preparation knowledge returned an invalid selection");
17088
17760
  }, "invalid");
17089
17761
  var factOf = /* @__PURE__ */ __name((fact, before2) => {
17090
17762
  if (!fact || typeof fact.ref !== "string" || !/^fact:[1-9]\d*$/.test(fact.ref) || !["fact", "statement", "question", "decision", "promise"].includes(fact.type) || typeof fact.statement !== "string" || !fact.statement.trim() || fact.subject !== null && (typeof fact.subject !== "string" || !/^(person|project):[1-9]\d*$/.test(fact.subject)) || fact.project !== null && (typeof fact.project !== "string" || !/^project:[1-9]\d*$/.test(fact.project)) || !Number.isSafeInteger(fact.updatedAt) || Math.abs(fact.updatedAt) > 864e13 || fact.updatedAt > before2 || typeof fact.sharedPerson !== "boolean" || typeof fact.sharedProject !== "boolean" || !(fact.sharedPerson || fact.sharedProject) || fact.sharedPerson && !fact.subject?.startsWith("person:") || fact.sharedProject && !fact.project && !fact.subject?.startsWith("project:"))
17091
- return invalid4();
17763
+ return invalid6();
17092
17764
  return {
17093
17765
  ref: fact.ref,
17094
17766
  type: fact.type,
@@ -17116,13 +17788,13 @@ var appendKnowledgePreparation = /* @__PURE__ */ __name(async (store, result, in
17116
17788
  });
17117
17789
  preparationCancelled(input.signal);
17118
17790
  if (!page || !Array.isArray(page.items) || page.items.length > limit || typeof page.hasMore !== "boolean")
17119
- return invalid4();
17791
+ return invalid6();
17120
17792
  const items = page.items.map((fact) => factOf(fact, input.after));
17121
17793
  if (new Set(items.map((fact) => fact.ref)).size !== items.length)
17122
- return invalid4();
17794
+ return invalid6();
17123
17795
  const readBytes = items.reduce((total, fact) => total + Buffer.byteLength(fact.statement + fact.type, "utf8"), 0);
17124
17796
  if (readBytes > input.maxReadBytes)
17125
- return invalid4();
17797
+ return invalid6();
17126
17798
  const knowledge = {
17127
17799
  anchors: result.items.map((item) => item.reference),
17128
17800
  items: [],
@@ -17151,13 +17823,13 @@ var appendKnowledgePreparation = /* @__PURE__ */ __name(async (store, result, in
17151
17823
  }
17152
17824
  }, "appendKnowledgePreparation");
17153
17825
 
17154
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-notes-preparation.js
17155
- var invalid5 = /* @__PURE__ */ __name(() => {
17826
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-notes-preparation.js
17827
+ var invalid7 = /* @__PURE__ */ __name(() => {
17156
17828
  throw new CliError("invalid_response", "Preparation notes returned an invalid selection");
17157
17829
  }, "invalid");
17158
17830
  var noteOf = /* @__PURE__ */ __name((note, before2, anchors) => {
17159
17831
  if (!note || typeof note.ref !== "string" || !/^note:[1-9]\d*$/.test(note.ref) || note.title !== null && typeof note.title !== "string" || typeof note.text !== "string" || !note.text.trim() || !Number.isSafeInteger(note.revision) || note.revision < 1 || !Number.isSafeInteger(note.updatedAt) || Math.abs(note.updatedAt) > 864e13 || note.updatedAt > before2 || note.person !== null && (typeof note.person !== "string" || !/^person:[1-9]\d*$/.test(note.person)) || note.project !== null && (typeof note.project !== "string" || !/^project:[1-9]\d*$/.test(note.project)) || note.meeting !== void 0 && note.meeting !== null && !anchors.has(note.meeting) || !(note.person || note.project || note.meeting))
17160
- return invalid5();
17832
+ return invalid7();
17161
17833
  return {
17162
17834
  ref: note.ref,
17163
17835
  title: note.title,
@@ -17185,18 +17857,18 @@ var appendNotesPreparation = /* @__PURE__ */ __name(async (store, result, input)
17185
17857
  });
17186
17858
  preparationCancelled(input.signal);
17187
17859
  if (!page || !Array.isArray(page.items) || page.items.length > limit || typeof page.hasMore !== "boolean")
17188
- return invalid5();
17860
+ return invalid7();
17189
17861
  const selection = page.selection === void 0 ? "owner-written-global-person/project-notes" : page.selection;
17190
17862
  if (!["owner-written-global-person/project-notes", "owner-written-meeting/person/project-notes"].includes(selection))
17191
- return invalid5();
17863
+ return invalid7();
17192
17864
  const anchors = new Set(result.items.map((item) => item.reference));
17193
17865
  const items = page.items.map((note) => noteOf(note, input.after, anchors));
17194
17866
  if (items.some((note) => note.meeting) && selection !== "owner-written-meeting/person/project-notes")
17195
- return invalid5();
17867
+ return invalid7();
17196
17868
  if (new Set(items.map((note) => note.ref)).size !== items.length)
17197
- return invalid5();
17869
+ return invalid7();
17198
17870
  if (items.reduce((total, note) => total + Buffer.byteLength((note.title ?? "") + note.text, "utf8"), 0) > input.maxReadBytes)
17199
- return invalid5();
17871
+ return invalid7();
17200
17872
  const notes = {
17201
17873
  anchors: result.items.map((item) => item.reference),
17202
17874
  items: [],
@@ -17225,7 +17897,7 @@ var appendNotesPreparation = /* @__PURE__ */ __name(async (store, result, input)
17225
17897
  }
17226
17898
  }, "appendNotesPreparation");
17227
17899
 
17228
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-preparation.js
17900
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-project-preparation.js
17229
17901
  var PAGE_LIMIT = 4;
17230
17902
  var size2 = /* @__PURE__ */ __name((value) => Buffer.byteLength(JSON.stringify(value), "utf8"), "size");
17231
17903
  var appendProjectPreparation = /* @__PURE__ */ __name(async (ports, result, input) => {
@@ -17275,7 +17947,7 @@ var appendProjectPreparation = /* @__PURE__ */ __name(async (ports, result, inpu
17275
17947
  }
17276
17948
  }, "appendProjectPreparation");
17277
17949
 
17278
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-related-preparation.js
17950
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-related-preparation.js
17279
17951
  var appendRelatedPreparation = /* @__PURE__ */ __name(async (store, result, input) => {
17280
17952
  if (!result.series || !result.items.length || result.coverage.outputLimited)
17281
17953
  return;
@@ -17347,7 +18019,7 @@ var appendRelatedPreparation = /* @__PURE__ */ __name(async (store, result, inpu
17347
18019
  }
17348
18020
  }, "appendRelatedPreparation");
17349
18021
 
17350
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-preparation.js
18022
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-preparation.js
17351
18023
  var size3 = /* @__PURE__ */ __name((value) => Buffer.byteLength(JSON.stringify(value), "utf8"), "size");
17352
18024
  var createMeetingPreparationService = /* @__PURE__ */ __name((scope, accountId, ports) => {
17353
18025
  const fixed = snapshotMeetingScope(scope);
@@ -17485,7 +18157,7 @@ var createMeetingPreparationService = /* @__PURE__ */ __name((scope, accountId,
17485
18157
  };
17486
18158
  }, "createMeetingPreparationService");
17487
18159
 
17488
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-task-proposal.js
18160
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-task-proposal.js
17489
18161
  import { createHash as createHash17 } from "node:crypto";
17490
18162
  var proposeMeetingTask = /* @__PURE__ */ __name(async (store, accountId, reference, kind) => {
17491
18163
  if (!TASK_KINDS.includes(kind))
@@ -17505,7 +18177,7 @@ var proposeMeetingTask = /* @__PURE__ */ __name(async (store, accountId, referen
17505
18177
  };
17506
18178
  }, "proposeMeetingTask");
17507
18179
 
17508
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-tasks.js
18180
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/meeting-tasks.js
17509
18181
  var accountSnapshot = /* @__PURE__ */ __name((key) => {
17510
18182
  const { provider, account: account2, scope } = key;
17511
18183
  if (!provider.trim() || provider.includes(":") || !account2.trim())
@@ -17568,7 +18240,7 @@ var readMeetingTask = /* @__PURE__ */ __name(async (store, account2, id2) => {
17568
18240
  }
17569
18241
  }, "readMeetingTask");
17570
18242
 
17571
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/package-upgrade.js
18243
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/package-upgrade.js
17572
18244
  var upgradePackage = /* @__PURE__ */ __name(async ({ current, command, packageName, check }, ports) => {
17573
18245
  const installer = ports.installer();
17574
18246
  const argv = updateCommand(installer, packageName);
@@ -17633,7 +18305,7 @@ var dayAfter = /* @__PURE__ */ __name((published) => {
17633
18305
  return Number.isNaN(time) ? null : new Date(time + 24 * 60 * 60 * 1e3).toISOString();
17634
18306
  }, "dayAfter");
17635
18307
 
17636
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/proposal-tasks.js
18308
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/proposal-tasks.js
17637
18309
  var proposalSource = /* @__PURE__ */ __name((id2) => `proposed-action:${id2}`, "proposalSource");
17638
18310
  var approveAsTask = /* @__PURE__ */ __name(async (store, id2) => {
17639
18311
  const proposal = await store.proposedActions.get(id2);
@@ -17662,22 +18334,22 @@ var approveAsTask = /* @__PURE__ */ __name(async (store, id2) => {
17662
18334
  return { proposal: await store.proposedActions.approve(proposal.id, { task: task2.id }), task: task2 };
17663
18335
  }, "approveAsTask");
17664
18336
 
17665
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/stored-meeting-project-candidate-validation.js
18337
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/stored-meeting-project-candidate-validation.js
17666
18338
  var storedCandidateRequest = /* @__PURE__ */ __name((reference, accountId, options) => {
17667
- const invalid6 = /* @__PURE__ */ __name((field) => {
18339
+ const invalid8 = /* @__PURE__ */ __name((field) => {
17668
18340
  throw new CliError("validation_error", `invalid stored project candidate ${field}`);
17669
18341
  }, "invalid");
17670
18342
  if (!options || typeof options !== "object" || Array.isArray(options))
17671
- invalid6("options");
18343
+ invalid8("options");
17672
18344
  const allowed = ["limit", "cues", "bytes", "maxReadBytes", "after", "afterTranscriptId", "signal"];
17673
18345
  for (const key of Object.keys(options))
17674
18346
  if (!allowed.includes(key))
17675
- invalid6(key);
18347
+ invalid8(key);
17676
18348
  if (typeof reference !== "string" || reference.length > 200)
17677
- invalid6("reference");
18349
+ invalid8("reference");
17678
18350
  const parsed = parseMeetingReference(reference);
17679
18351
  if (parsed.accountId !== accountId || parsed.transcriptId !== void 0 || formatMeetingReference(parsed) !== reference)
17680
- invalid6("reference");
18352
+ invalid8("reference");
17681
18353
  const limits = {
17682
18354
  limit: options.limit ?? 10,
17683
18355
  cues: options.cues ?? 20,
@@ -17687,24 +18359,24 @@ var storedCandidateRequest = /* @__PURE__ */ __name((reference, accountId, optio
17687
18359
  for (const [key, value] of Object.entries(limits)) {
17688
18360
  const max = key === "limit" ? 10 : key === "cues" ? 100 : 65536;
17689
18361
  if (!Number.isSafeInteger(value) || value < (key === "bytes" ? 2048 : 1) || value > max)
17690
- invalid6(key);
18362
+ invalid8(key);
17691
18363
  }
17692
18364
  const { after, afterTranscriptId, signal } = options;
17693
18365
  if (signal !== void 0 && !(signal instanceof AbortSignal))
17694
- invalid6("signal");
18366
+ invalid8("signal");
17695
18367
  if (after !== void 0) {
17696
18368
  if (typeof after !== "string" || after.length > 200)
17697
- invalid6("after");
18369
+ invalid8("after");
17698
18370
  const cursor = parseMeetingReference(after);
17699
18371
  if (cursor.accountId !== accountId || cursor.meetingId !== parsed.meetingId || cursor.cuePosition === void 0 || formatMeetingReference(cursor) !== after)
17700
- invalid6("after");
18372
+ invalid8("after");
17701
18373
  }
17702
18374
  if (afterTranscriptId !== void 0 && (!Number.isSafeInteger(afterTranscriptId) || afterTranscriptId < 1 || after !== void 0))
17703
- invalid6("afterTranscriptId");
18375
+ invalid8("afterTranscriptId");
17704
18376
  return { reference, limits, after, afterTranscriptId, signal };
17705
18377
  }, "storedCandidateRequest");
17706
18378
 
17707
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/stored-meeting-project-candidates.js
18379
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/stored-meeting-project-candidates.js
17708
18380
  var createStoredMeetingProjectCandidateReader = /* @__PURE__ */ __name((scope, accountId, ports) => {
17709
18381
  const fixed = snapshotMeetingScope(scope);
17710
18382
  const store = ports?.meetings;
@@ -17796,7 +18468,7 @@ var createStoredMeetingProjectCandidateReader = /* @__PURE__ */ __name((scope, a
17796
18468
  };
17797
18469
  }, "createStoredMeetingProjectCandidateReader");
17798
18470
 
17799
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/index.js
18471
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.0_commander@15.0.0_esbuild@0.28.2_type_438c1bd9283d857a9e801e9b977bafec/node_modules/@wirecat/cli-core/dist/services/index.js
17800
18472
  var servicesFor = /* @__PURE__ */ __name((deps) => {
17801
18473
  const pictures = picturesService(deps);
17802
18474
  const base = {
@@ -17844,6 +18516,10 @@ export {
17844
18516
  storedDeps,
17845
18517
  storeModeDeps,
17846
18518
  storeOnlyDeps,
18519
+ isId,
18520
+ foldName,
18521
+ pickChat,
18522
+ pickPerson,
17847
18523
  REGISTRIES,
17848
18524
  registriesCover,
17849
18525
  chatCoverage,
@@ -17861,6 +18537,8 @@ export {
17861
18537
  storedNeighbours,
17862
18538
  gatherProjectEvidence,
17863
18539
  findEvidenceMentions,
18540
+ canonicalProjectRef,
18541
+ gatherStoredProject,
17864
18542
  throughWrapper,
17865
18543
  capability,
17866
18544
  accountService,
@@ -17933,6 +18611,7 @@ export {
17933
18611
  reviewStart,
17934
18612
  kindsOf,
17935
18613
  inboxService,
18614
+ validateFormattedText,
17936
18615
  pinLengthHelp,
17937
18616
  pinDurationOf,
17938
18617
  sendAsCheck,
@@ -17977,6 +18656,13 @@ export {
17977
18656
  DELETE_AT_ONCE,
17978
18657
  messagesService,
17979
18658
  metadataService,
18659
+ describe,
18660
+ CHECK_READS,
18661
+ MAX_ACTIONS,
18662
+ defaultRules,
18663
+ RULE_KEYS,
18664
+ moderationPathFor,
18665
+ ModerationRules,
17980
18666
  moderateWith,
17981
18667
  moderationService,
17982
18668
  CONTEXT_MESSAGES2 as CONTEXT_MESSAGES,