@wirecat/bitrix24-cli 0.4.0 → 0.5.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 (248) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +84 -9
  3. package/dist/api-keys.d.ts +18 -13
  4. package/dist/api-keys.d.ts.map +1 -1
  5. package/dist/api-keys.js +79 -22
  6. package/dist/api-keys.js.map +1 -1
  7. package/dist/bin/b24.js +2 -2
  8. package/dist/bitrix/errors.js +1 -1
  9. package/dist/bitrix/errors.js.map +1 -1
  10. package/dist/bitrix/transport.d.ts +1 -1
  11. package/dist/bitrix/transport.d.ts.map +1 -1
  12. package/dist/bitrix/transport.js +20 -6
  13. package/dist/bitrix/transport.js.map +1 -1
  14. package/dist/body.d.ts +14 -0
  15. package/dist/body.d.ts.map +1 -0
  16. package/dist/body.js +44 -0
  17. package/dist/body.js.map +1 -0
  18. package/dist/bundle/{chunk-JAS3OZSP.js → all-profiles-CANIDIDS.js} +12 -7
  19. package/dist/bundle/{anthropic-QCYLKSJJ.js → anthropic-JUJB4DCF.js} +5 -5
  20. package/dist/bundle/{app-server-FSLZ2Y6N.js → app-server-3V5Z4PTK.js} +68 -54
  21. package/dist/bundle/b24.js +18 -12
  22. package/dist/bundle/{bun-UYRQXF33.js → bun-LKMV5TY7.js} +2 -2
  23. package/dist/bundle/{bun-sqlite-GXME7EMT.js → bun-sqlite-S56EF74S.js} +3 -3
  24. package/dist/bundle/{chunk-D2IRPC5I.js → chunk-2I4KWS3H.js} +6 -6
  25. package/dist/bundle/chunk-36PO5NWY.js +147 -0
  26. package/dist/bundle/{chunk-COOOXDKZ.js → chunk-42F7Q7V6.js} +3 -3
  27. package/dist/bundle/{chunk-POUSZWMP.js → chunk-4D3K6GZW.js} +18 -4
  28. package/dist/bundle/chunk-5D4MJQ6X.js +22 -0
  29. package/dist/bundle/chunk-5JOPERVF.js +84 -0
  30. package/dist/bundle/chunk-6A4UPWDC.js +15 -0
  31. package/dist/bundle/{chunk-O7FVOICH.js → chunk-6MGWIZG4.js} +1 -1
  32. package/dist/bundle/{chunk-B252WFK7.js → chunk-6YJTNZ7U.js} +13 -13
  33. package/dist/bundle/{chunk-2D5W4LWL.js → chunk-7FBFJ6B4.js} +4 -2
  34. package/dist/bundle/chunk-7VCMOTQP.js +55 -0
  35. package/dist/bundle/{chunk-6BLVBGRK.js → chunk-A5IMMGYU.js} +36 -34
  36. package/dist/bundle/{chunk-66QLBRIT.js → chunk-ASEHTBNK.js} +1 -1
  37. package/dist/bundle/{chunk-MY6FAZRA.js → chunk-B6LPJYPQ.js} +2 -2
  38. package/dist/bundle/{chunk-EQLWU6ZB.js → chunk-BHEE2K6C.js} +7 -7
  39. package/dist/bundle/chunk-BYZQBE63.js +971 -0
  40. package/dist/bundle/{chunk-J7OMY6EO.js → chunk-COKGNTDQ.js} +1477 -723
  41. package/dist/bundle/{chunk-QVZSLBR6.js → chunk-DVFYRQGE.js} +1 -1
  42. package/dist/bundle/{chunk-Q7Z5IMVY.js → chunk-DVSIBZ3G.js} +1 -1
  43. package/dist/bundle/chunk-EJEIXC6Y.js +273 -0
  44. package/dist/bundle/chunk-EYTGCM44.js +130 -0
  45. package/dist/bundle/{chunk-SBW2Y7AZ.js → chunk-EYYOKT23.js} +26 -26
  46. package/dist/bundle/{chunk-Y5PPMGCS.js → chunk-FCWPIWSR.js} +2 -2
  47. package/dist/bundle/{chunk-AOUNT22U.js → chunk-FSWRMQWX.js} +2 -2
  48. package/dist/bundle/{chunk-ADLS6FVG.js → chunk-FXBHOCJK.js} +1 -1
  49. package/dist/bundle/chunk-G5MW6RCM.js +723 -0
  50. package/dist/bundle/{chunk-4OVK5XW2.js → chunk-GLTKRLFT.js} +8 -8
  51. package/dist/bundle/chunk-GUUZQ7NE.js +581 -0
  52. package/dist/bundle/{chunk-XOPMSWFC.js → chunk-H6RIPOOI.js} +36 -3
  53. package/dist/bundle/{chunk-GTMCLOYY.js → chunk-HGFNC4CR.js} +1447 -430
  54. package/dist/bundle/{chunk-IF27EQN6.js → chunk-IERYD2N2.js} +6 -6
  55. package/dist/bundle/{chunk-Q4ILKTV4.js → chunk-IGCLMEMB.js} +3 -3
  56. package/dist/bundle/{chunk-2IZ6GGU2.js → chunk-J7WCSZ2Q.js} +410 -918
  57. package/dist/bundle/{chunk-CR3TLGM4.js → chunk-JZYHQ4HB.js} +3 -3
  58. package/dist/bundle/{chunk-XR5SUCAC.js → chunk-K4QM3X5F.js} +4 -4
  59. package/dist/bundle/{chunk-OWILUBCI.js → chunk-KFSMY7SZ.js} +2 -2
  60. package/dist/bundle/{chunk-AMVRNYD6.js → chunk-KPEDH5T4.js} +1 -1
  61. package/dist/bundle/{chunk-NEK7LKC6.js → chunk-KUY7LII2.js} +4 -4
  62. package/dist/bundle/{chunk-NDSOBIR3.js → chunk-LFXDHLFR.js} +3 -3
  63. package/dist/bundle/{chunk-ZU4HXKEW.js → chunk-LGLT4JB6.js} +3 -3
  64. package/dist/bundle/{chunk-EIGPMMGC.js → chunk-LM4OOBAW.js} +3 -3
  65. package/dist/bundle/chunk-M74BSKMA.js +234 -0
  66. package/dist/bundle/{chunk-MPI2FDJ4.js → chunk-MMMT6ORT.js} +11 -11
  67. package/dist/bundle/{chunk-F5NH3UJQ.js → chunk-NGYD6QTE.js} +2 -2
  68. package/dist/bundle/{chunk-6ERX33NC.js → chunk-NO6QOPVT.js} +10 -19
  69. package/dist/bundle/chunk-O6XC7DZI.js +804 -0
  70. package/dist/bundle/chunk-OE3NFB53.js +64 -0
  71. package/dist/bundle/{chunk-VTIUWHZ3.js → chunk-OUMFNB34.js} +13 -149
  72. package/dist/bundle/{chunk-VMQL4GNH.js → chunk-P2RQTNVJ.js} +806 -850
  73. package/dist/bundle/{chunk-XKQZLR2X.js → chunk-PBIBGIZ7.js} +1 -1
  74. package/dist/bundle/{chunk-YFZXI3NN.js → chunk-Q6VQHTRW.js} +2 -2
  75. package/dist/bundle/{chunk-OKDC6CLH.js → chunk-QHBCNVUG.js} +5 -5
  76. package/dist/bundle/{chunk-WJRBX5QB.js → chunk-QNOXAQ6Y.js} +4 -4
  77. package/dist/bundle/{chunk-GTFRSYYJ.js → chunk-R5F2O5GX.js} +7 -269
  78. package/dist/bundle/{chunk-OCRCVLZQ.js → chunk-R5PBSKJL.js} +1 -1
  79. package/dist/bundle/{chunk-JB7OXYAU.js → chunk-RS2BARUU.js} +4 -4
  80. package/dist/bundle/chunk-TG3DSPT5.js +14 -0
  81. package/dist/bundle/{chunk-UH56WLDS.js → chunk-U22JMKUO.js} +6 -125
  82. package/dist/bundle/chunk-U66Q5TVK.js +106 -0
  83. package/dist/bundle/{chunk-NWKXMMON.js → chunk-UCHMQWON.js} +136 -33
  84. package/dist/bundle/{chunk-DQIQIZQS.js → chunk-VMJS7FJZ.js} +451 -433
  85. package/dist/bundle/{chunk-IWEWDVZ6.js → chunk-VMVAQHDC.js} +77 -615
  86. package/dist/bundle/{chunk-M5XMAUGZ.js → chunk-WWMCJFMT.js} +2 -2
  87. package/dist/bundle/{chunk-OYLJHX74.js → chunk-XTA5TN3H.js} +1 -1
  88. package/dist/bundle/{chunk-ELBOQHJA.js → chunk-XUHHBEA7.js} +652 -131
  89. package/dist/bundle/{chunk-BHZ5VDDY.js → chunk-YDZHO4LT.js} +13 -13
  90. package/dist/bundle/{chunk-NKLLI4B2.js → chunk-ZKINZFIT.js} +6 -6
  91. package/dist/bundle/{chunk-GTDOUP6L.js → chunk-ZSQXSIFQ.js} +85 -38
  92. package/dist/bundle/{chunk-LAYH344Y.js → chunk-ZZEHDIEG.js} +58 -54
  93. package/dist/bundle/command-contract-OQV6H7SR.js +36 -0
  94. package/dist/bundle/{decode-IF2F2SFC.js → decode-QSTBX4MG.js} +3 -3
  95. package/dist/bundle/{echarts-WDDVEJO2.js → echarts-JZELFH2N.js} +2 -2
  96. package/dist/bundle/{embed-VDUGYEAR.js → embed-4RIW2LVH.js} +4 -4
  97. package/dist/bundle/{embedder-DUN62H3Z.js → embedder-SW7DTWSL.js} +7 -7
  98. package/dist/bundle/{first-run-NDGYBQEN.js → first-run-7AISOSOM.js} +8 -8
  99. package/dist/bundle/first-screen-NMHNFZ2B.js +34 -0
  100. package/dist/bundle/{instructions-JIIKWS7X.js → instructions-BZE5YUGG.js} +1 -1
  101. package/dist/bundle/{mcp-33JX6KP4.js → mcp-SDWHDJTY.js} +2 -2
  102. package/dist/bundle/{node-P4E63KXA.js → node-KM3CUABH.js} +9 -9
  103. package/dist/bundle/{node-K57WT42O.js → node-LTKZIO4U.js} +2 -2
  104. package/dist/bundle/{node-sqlite-KS6ORRIG.js → node-sqlite-HQ5PN2RH.js} +4 -4
  105. package/dist/bundle/{oauth-SLSANN37.js → oauth-UH6FOZQL.js} +5 -5
  106. package/dist/bundle/{open-WJPHADEX.js → open-TSUP3XGL.js} +3 -3
  107. package/dist/bundle/{openai-HXB3GTOD.js → openai-GVEE52E3.js} +14 -14
  108. package/dist/bundle/{process-P73TFAXT.js → process-AGXY76ZE.js} +1 -1
  109. package/dist/bundle/{program-7BMG5NIN.js → program-BI4A4HFJ.js} +1045 -1048
  110. package/dist/bundle/{prompt-WDPV37R4.js → prompt-NRSUY7FA.js} +3 -3
  111. package/dist/bundle/{recognize-CXIFL6IV.js → recognize-NPDPQ6PJ.js} +2 -2
  112. package/dist/bundle/{remote-Q4VJ4OQW.js → remote-HFASMVLB.js} +5 -5
  113. package/dist/bundle/{rerank-SUFYK63I.js → rerank-TL6Z6F7K.js} +5 -5
  114. package/dist/bundle/{chunk-XG6QKS7L.js → serve-VB4DHDZQ.js} +8 -6
  115. package/dist/bundle/server-T5EDRPJI.js +68 -0
  116. package/dist/bundle/{chunk-K7XWCZF6.js → server-Z6MW6C37.js} +50 -14
  117. package/dist/bundle/source-4IGO5J7E.js +237 -0
  118. package/dist/bundle/sqlite-runtime-YS4POY3W.js +17 -0
  119. package/dist/bundle/{state-EZCCXQV7.js → state-ISZVVZGR.js} +4 -4
  120. package/dist/bundle/store-IZJBAKJV.js +58 -0
  121. package/dist/bundle/{store-MZ7JBYR6.js → store-L76MSQC3.js} +17 -12
  122. package/dist/bundle/store-PBTIB7BD.js +207 -0
  123. package/dist/bundle/store-maintenance-command-YFKII7TF.js +58 -0
  124. package/dist/bundle/writer-3O5EYMFE.js +214 -0
  125. package/dist/commands/api.d.ts.map +1 -1
  126. package/dist/commands/api.js +34 -33
  127. package/dist/commands/api.js.map +1 -1
  128. package/dist/commands/crm-shared.d.ts +4 -0
  129. package/dist/commands/crm-shared.d.ts.map +1 -0
  130. package/dist/commands/crm-shared.js +94 -0
  131. package/dist/commands/crm-shared.js.map +1 -0
  132. package/dist/commands/crm-writes.d.ts +0 -1
  133. package/dist/commands/crm-writes.d.ts.map +1 -1
  134. package/dist/commands/crm-writes.js +31 -92
  135. package/dist/commands/crm-writes.js.map +1 -1
  136. package/dist/commands/crm.d.ts.map +1 -1
  137. package/dist/commands/crm.js +1 -45
  138. package/dist/commands/crm.js.map +1 -1
  139. package/dist/commands/session.d.ts.map +1 -1
  140. package/dist/commands/session.js +1 -0
  141. package/dist/commands/session.js.map +1 -1
  142. package/dist/commands/write.d.ts +1 -6
  143. package/dist/commands/write.d.ts.map +1 -1
  144. package/dist/commands/write.js +7 -16
  145. package/dist/commands/write.js.map +1 -1
  146. package/dist/config.d.ts +0 -5
  147. package/dist/config.d.ts.map +1 -1
  148. package/dist/config.js +6 -9
  149. package/dist/config.js.map +1 -1
  150. package/dist/crm/capabilities.d.ts +7 -0
  151. package/dist/crm/capabilities.d.ts.map +1 -0
  152. package/dist/crm/capabilities.js +7 -0
  153. package/dist/crm/capabilities.js.map +1 -0
  154. package/dist/crm/conditions.d.ts +1 -1
  155. package/dist/crm/conditions.d.ts.map +1 -1
  156. package/dist/crm/conditions.js +3 -5
  157. package/dist/crm/conditions.js.map +1 -1
  158. package/dist/crm/custom-query.d.ts +1 -1
  159. package/dist/crm/custom-query.d.ts.map +1 -1
  160. package/dist/crm/custom-query.js +2 -2
  161. package/dist/crm/custom-query.js.map +1 -1
  162. package/dist/crm/deal.d.ts +4 -28
  163. package/dist/crm/deal.d.ts.map +1 -1
  164. package/dist/crm/deal.js +15 -48
  165. package/dist/crm/deal.js.map +1 -1
  166. package/dist/crm/fields.d.ts +2 -26
  167. package/dist/crm/fields.d.ts.map +1 -1
  168. package/dist/crm/fields.js +2 -67
  169. package/dist/crm/fields.js.map +1 -1
  170. package/dist/crm/items.d.ts.map +1 -1
  171. package/dist/crm/items.js +6 -5
  172. package/dist/crm/items.js.map +1 -1
  173. package/dist/crm/lead.d.ts +5 -37
  174. package/dist/crm/lead.d.ts.map +1 -1
  175. package/dist/crm/lead.js +15 -61
  176. package/dist/crm/lead.js.map +1 -1
  177. package/dist/crm/pipelines.d.ts +5 -0
  178. package/dist/crm/pipelines.d.ts.map +1 -0
  179. package/dist/crm/pipelines.js +54 -0
  180. package/dist/crm/pipelines.js.map +1 -0
  181. package/dist/crm/product.d.ts.map +1 -1
  182. package/dist/crm/product.js +2 -2
  183. package/dist/crm/product.js.map +1 -1
  184. package/dist/crm/rest3-fields.d.ts +3 -0
  185. package/dist/crm/rest3-fields.d.ts.map +1 -0
  186. package/dist/crm/rest3-fields.js +38 -0
  187. package/dist/crm/rest3-fields.js.map +1 -0
  188. package/dist/crm/source.d.ts +15 -0
  189. package/dist/crm/source.d.ts.map +1 -0
  190. package/dist/crm/source.js +122 -0
  191. package/dist/crm/source.js.map +1 -0
  192. package/dist/crm/user.d.ts.map +1 -1
  193. package/dist/crm/user.js +2 -2
  194. package/dist/crm/user.js.map +1 -1
  195. package/dist/crm/values.d.ts +19 -4
  196. package/dist/crm/values.d.ts.map +1 -1
  197. package/dist/crm/values.js +28 -2
  198. package/dist/crm/values.js.map +1 -1
  199. package/dist/crm/writer.d.ts +9 -0
  200. package/dist/crm/writer.d.ts.map +1 -0
  201. package/dist/crm/writer.js +119 -0
  202. package/dist/crm/writer.js.map +1 -0
  203. package/dist/program.d.ts.map +1 -1
  204. package/dist/program.js +51 -6
  205. package/dist/program.js.map +1 -1
  206. package/dist/store.d.ts +15 -0
  207. package/dist/store.d.ts.map +1 -0
  208. package/dist/store.js +33 -0
  209. package/dist/store.js.map +1 -0
  210. package/dist/version.d.ts +1 -1
  211. package/dist/version.js +1 -1
  212. package/package.json +4 -6
  213. package/skills/bitrix24-cli/SKILL.md +16 -15
  214. package/dist/bundle/all-profiles-MBQZCOVK.js +0 -24
  215. package/dist/bundle/chunk-UCLWWSQK.js +0 -48
  216. package/dist/bundle/command-contract-UON4EIC4.js +0 -30
  217. package/dist/bundle/first-screen-QAVKP5RF.js +0 -28
  218. package/dist/bundle/mcp-57EQ6QJO.js +0 -171
  219. package/dist/bundle/mcp-PFJER2DE.js +0 -87
  220. package/dist/bundle/serve-B7PGFOC2.js +0 -19
  221. package/dist/bundle/server-4DBNJWW6.js +0 -58
  222. package/dist/bundle/server-OKE7SXJ2.js +0 -45
  223. package/dist/bundle/store-maintenance-command-T5QZMENJ.js +0 -47
  224. package/dist/commands/doctor.d.ts +0 -77
  225. package/dist/commands/doctor.d.ts.map +0 -1
  226. package/dist/commands/doctor.js +0 -74
  227. package/dist/commands/doctor.js.map +0 -1
  228. package/dist/commands/fields.d.ts +0 -3
  229. package/dist/commands/fields.d.ts.map +0 -1
  230. package/dist/commands/fields.js +0 -45
  231. package/dist/commands/fields.js.map +0 -1
  232. package/dist/commands/mcp.d.ts +0 -3
  233. package/dist/commands/mcp.d.ts.map +0 -1
  234. package/dist/commands/mcp.js +0 -97
  235. package/dist/commands/mcp.js.map +0 -1
  236. package/dist/crm/pipeline.d.ts +0 -17
  237. package/dist/crm/pipeline.d.ts.map +0 -1
  238. package/dist/crm/pipeline.js +0 -42
  239. package/dist/crm/pipeline.js.map +0 -1
  240. package/dist/crm/stage.d.ts +0 -20
  241. package/dist/crm/stage.d.ts.map +0 -1
  242. package/dist/crm/stage.js +0 -65
  243. package/dist/crm/stage.js.map +0 -1
  244. package/dist/mcp.d.ts +0 -29
  245. package/dist/mcp.d.ts.map +0 -1
  246. package/dist/mcp.js +0 -102
  247. package/dist/mcp.js.map +0 -1
  248. /package/dist/bundle/{chunk-NDTJE6JQ.js → chunk-ZQ3GWKDQ.js} +0 -0
@@ -24,7 +24,7 @@ import {
24
24
  priorityLabel,
25
25
  project,
26
26
  reminder
27
- } from "./chunk-6BLVBGRK.js";
27
+ } from "./chunk-A5IMMGYU.js";
28
28
  import {
29
29
  DEFAULT_STEMMERS,
30
30
  DEFAULT_STEMMERS_VERSION,
@@ -37,19 +37,30 @@ import {
37
37
  fold,
38
38
  normalize,
39
39
  parseStemmers
40
- } from "./chunk-4OVK5XW2.js";
40
+ } from "./chunk-GLTKRLFT.js";
41
41
  import {
42
42
  DEFAULT_TASK_CATEGORIES,
43
43
  sharedConfigPath,
44
44
  storedTaskCategories,
45
45
  taskCategoriesReader
46
- } from "./chunk-OKDC6CLH.js";
46
+ } from "./chunk-QHBCNVUG.js";
47
47
  import {
48
48
  refuseOwnerStoreInTests,
49
49
  storePath
50
- } from "./chunk-OWILUBCI.js";
50
+ } from "./chunk-KFSMY7SZ.js";
51
51
  import {
52
52
  COUNTER_FIELDS,
53
+ counterFreshness,
54
+ counterObservationTime,
55
+ needsRankingContext,
56
+ pointerOf,
57
+ rankingQuestion,
58
+ rankingScore,
59
+ rankingWords,
60
+ recordFingerprint,
61
+ validCounter
62
+ } from "./chunk-EJEIXC6Y.js";
63
+ import {
53
64
  DEAL_KINDS,
54
65
  DEAL_ROLES,
55
66
  DEAL_STATUSES,
@@ -59,8 +70,6 @@ import {
59
70
  UNKNOWN_PROVIDER,
60
71
  addProvider,
61
72
  canonicalReference,
62
- counterFreshness,
63
- counterObservationTime,
64
73
  dealLine,
65
74
  filesAccountSql,
66
75
  folderProviderOf,
@@ -73,33 +82,37 @@ import {
73
82
  isLocator,
74
83
  kindIn,
75
84
  kindOf,
76
- needsRankingContext,
77
85
  parseLocator,
78
86
  parseReference,
79
- pointerOf,
80
87
  providerEntryOf,
81
88
  providerLabel,
82
89
  providerNamed,
83
90
  providers,
84
- rankingQuestion,
85
- rankingScore,
86
- rankingWords,
87
- recordFingerprint,
88
- useStoredProviders,
89
- validCounter
90
- } from "./chunk-GTFRSYYJ.js";
91
+ useStoredProviders
92
+ } from "./chunk-R5F2O5GX.js";
91
93
  import {
92
- CHAT_MESSAGES_READ,
93
- FACT_TYPES,
94
94
  FINANCE_REVIEWS,
95
95
  INVOICE_DIRECTIONS,
96
96
  INVOICE_STATUSES,
97
- MEETING_FINDINGS_KIND,
98
97
  MONEY_DIRECTIONS,
99
- MeetingError,
100
- OPERATORS_BY_TYPE,
101
98
  ORDER_PURPOSES,
102
99
  ORDER_STATUSES,
100
+ invoiceLine,
101
+ invoiceTitle,
102
+ normalizeTag,
103
+ orderLine,
104
+ orderTitle,
105
+ paymentEntryTitle,
106
+ paymentLine,
107
+ settledStatus,
108
+ tagOf
109
+ } from "./chunk-5JOPERVF.js";
110
+ import {
111
+ CHAT_MESSAGES_READ,
112
+ FACT_TYPES,
113
+ MEETING_FINDINGS_KIND,
114
+ MeetingError,
115
+ OPERATORS_BY_TYPE,
103
116
  QUERY_LIMITS,
104
117
  REVIEW_LIMIT,
105
118
  aggregateMeetingCounts,
@@ -121,8 +134,6 @@ import {
121
134
  findingText,
122
135
  formatDecimal,
123
136
  formatMeetingReference,
124
- invoiceLine,
125
- invoiceTitle,
126
137
  joinKeyOf,
127
138
  joinUrlWithoutQuery,
128
139
  lineUnits,
@@ -133,22 +144,15 @@ import {
133
144
  moneyLabel,
134
145
  moneyOf,
135
146
  normalizeMeetingParticipantQuery,
136
- normalizeTag,
137
- orderLine,
138
- orderTitle,
139
147
  parseDecimal,
140
148
  parseMeetingQuery,
141
149
  parseMeetingReference,
142
- paymentEntryTitle,
143
- paymentLine,
144
150
  paymentTitle,
145
151
  quantityOf,
146
152
  queryAstSchema,
147
153
  queryError,
148
154
  queryFieldsOf,
149
155
  scaleOf,
150
- settledStatus,
151
- tagOf,
152
156
  timezoneOf,
153
157
  transcriptLanguage,
154
158
  validEvidence,
@@ -164,16 +168,17 @@ import {
164
168
  validateQuery,
165
169
  walkQuery,
166
170
  zonedMoment
167
- } from "./chunk-VMQL4GNH.js";
171
+ } from "./chunk-P2RQTNVJ.js";
168
172
  import {
169
173
  quietSqliteWarning,
170
174
  storeCapable
171
- } from "./chunk-D2IRPC5I.js";
175
+ } from "./chunk-2I4KWS3H.js";
172
176
  import {
173
177
  PRAGMAS,
174
178
  TIME_LIMIT_FUNCTION,
175
- TimeLimitReached
176
- } from "./chunk-2D5W4LWL.js";
179
+ TimeLimitReached,
180
+ isQueryOnly
181
+ } from "./chunk-7FBFJ6B4.js";
177
182
  import {
178
183
  CliError,
179
184
  array,
@@ -193,7 +198,7 @@ import {
193
198
  singleLine,
194
199
  strictObject,
195
200
  string
196
- } from "./chunk-SBW2Y7AZ.js";
201
+ } from "./chunk-EYYOKT23.js";
197
202
  import {
198
203
  resolveFrom
199
204
  } from "./chunk-Y5E2WNWB.js";
@@ -221,7 +226,7 @@ import {
221
226
  sql,
222
227
  sqliteTable,
223
228
  text
224
- } from "./chunk-OCRCVLZQ.js";
229
+ } from "./chunk-R5PBSKJL.js";
225
230
  import {
226
231
  __commonJS,
227
232
  __name,
@@ -9920,10 +9925,10 @@ var require_cjs = __commonJS({
9920
9925
  }
9921
9926
  __name(suffixLookup, "suffixLookup");
9922
9927
  var RESULT = getEmptyResult();
9923
- function parse(url, options) {
9928
+ function parse2(url, options) {
9924
9929
  return parseImpl(url, 5, suffixLookup, options, getEmptyResult());
9925
9930
  }
9926
- __name(parse, "parse");
9931
+ __name(parse2, "parse");
9927
9932
  function getHostname(url, options) {
9928
9933
  resetResult(RESULT);
9929
9934
  return parseImpl(url, 0, suffixLookup, options, RESULT).hostname;
@@ -9961,11 +9966,11 @@ var require_cjs = __commonJS({
9961
9966
  exports.getHostname = getHostname;
9962
9967
  exports.getPublicSuffix = getPublicSuffix;
9963
9968
  exports.getSubdomain = getSubdomain;
9964
- exports.parse = parse;
9969
+ exports.parse = parse2;
9965
9970
  }
9966
9971
  });
9967
9972
 
9968
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/account-store.js
9973
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/account-store.js
9969
9974
  var bindArea = /* @__PURE__ */ __name(({ keyed, whole }, account) => {
9970
9975
  const methods = whole;
9971
9976
  return Object.fromEntries(Object.keys(keyed).map((name) => [
@@ -10093,7 +10098,7 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
10093
10098
  };
10094
10099
  }, "bindAccount");
10095
10100
 
10096
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/query.js
10101
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/query.js
10097
10102
  var isBotProvider = /* @__PURE__ */ __name((provider) => provider.endsWith("-bot"), "isBotProvider");
10098
10103
  var inSource = /* @__PURE__ */ __name((source2, provider) => source2 === "all" || source2 === "bots" && isBotProvider(provider) || source2 === "personal" && !isBotProvider(provider) || source2 === provider || providerNamed(source2)?.name === provider || isKind(source2) && kindOf(provider) === source2, "inSource");
10099
10104
  var fail = /* @__PURE__ */ __name((message2) => {
@@ -10116,7 +10121,7 @@ var sourceOf = /* @__PURE__ */ __name((name, value, providers2) => {
10116
10121
  return fail(`${name} takes ${[...sources, "messages", "mail"].join(", ")} \u2014 not "${value}"`);
10117
10122
  }, "sourceOf");
10118
10123
 
10119
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/account-list.js
10124
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/account-list.js
10120
10125
  var ACCOUNT_GROUPS = "accountGroups";
10121
10126
  var ACCOUNT_GROUPS_SETTING = "account_groups";
10122
10127
  var GROUP_NAME = /^[a-z0-9][a-z0-9_-]*$/i;
@@ -10304,7 +10309,7 @@ var fitting = /* @__PURE__ */ __name((entries, kinds2, what, reasonOf2 = (kind3)
10304
10309
  return { accounts: [...chosen.values()], skipped };
10305
10310
  }, "fitting");
10306
10311
 
10307
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
10312
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
10308
10313
  var IndexBuilderOn = class {
10309
10314
  static {
10310
10315
  __name(this, "IndexBuilderOn");
@@ -10499,7 +10504,7 @@ function alias(table, alias2) {
10499
10504
  }
10500
10505
  __name(alias, "alias");
10501
10506
 
10502
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
10507
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
10503
10508
  var ENTITY_TABLES = {
10504
10509
  account: "accounts",
10505
10510
  attachment: "attachments",
@@ -10545,7 +10550,7 @@ var orphanPointers = /* @__PURE__ */ __name((database) => pointerPairs(database)
10545
10550
  return { table, pointer, type, count, known: known2 };
10546
10551
  }).filter(({ count }) => count > 0)), "orphanPointers");
10547
10552
 
10548
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
10553
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
10549
10554
  var canonicalTags = sqliteTable("canonical_tags", {
10550
10555
  id: integer("id").primaryKey(),
10551
10556
  name: text("name").notNull().unique(),
@@ -10554,7 +10559,7 @@ var canonicalTags = sqliteTable("canonical_tags", {
10554
10559
  updatedAt: integer("updated_at").notNull()
10555
10560
  });
10556
10561
 
10557
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
10562
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
10558
10563
  var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
10559
10564
  sourceKey: text("source_key").notNull(),
10560
10565
  collection: text("collection").notNull(),
@@ -10564,13 +10569,33 @@ var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
10564
10569
  createdAt: integer("created_at").notNull()
10565
10570
  }, (table) => [primaryKey({ columns: [table.sourceKey, table.collection] })]);
10566
10571
 
10567
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
10572
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
10568
10573
  var documentIndexPending = sqliteTable("document_index_pending", {
10569
10574
  id: integer("id").notNull(),
10570
10575
  indexableType: text("indexable_type").notNull()
10571
10576
  }, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
10572
10577
 
10573
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
10578
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/decision-requests.js
10579
+ var decisionRequests = sqliteTable("decision_requests", {
10580
+ id: integer("id").primaryKey(),
10581
+ tokenDigest: text("token_digest").notNull().unique(),
10582
+ proposalId: text("proposal_id").notNull(),
10583
+ action: text("action").notNull(),
10584
+ batchDigest: text("batch_digest").notNull(),
10585
+ channel: text("channel").notNull(),
10586
+ botProfile: text("bot_profile").notNull(),
10587
+ chatId: text("chat_id").notNull(),
10588
+ messageId: text("message_id").notNull(),
10589
+ ownerUserId: text("owner_user_id").notNull(),
10590
+ createdAt: integer("created_at").notNull(),
10591
+ expiresAt: integer("expires_at").notNull(),
10592
+ usedAt: integer("used_at"),
10593
+ cancelledAt: integer("cancelled_at")
10594
+ }, (table) => [
10595
+ index("decision_requests_by_channel_bot_profile_chat_id_message_id").on(table.channel, table.botProfile, table.chatId, table.messageId)
10596
+ ]);
10597
+
10598
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
10574
10599
  var tagRedirects = sqliteTable("tag_redirects", {
10575
10600
  sourceId: integer("source_id").primaryKey().references(() => canonicalTags.id),
10576
10601
  survivorId: integer("survivor_id").notNull().references(() => canonicalTags.id),
@@ -10596,7 +10621,7 @@ var tagConsolidations = sqliteTable("tag_consolidations", {
10596
10621
  index("tag_consolidations_by_actor_type_actor_id").on(table.actorType, table.actorId)
10597
10622
  ]);
10598
10623
 
10599
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
10624
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
10600
10625
  var accounts = sqliteTable("accounts", {
10601
10626
  id: integer("id").primaryKey(),
10602
10627
  provider: text("provider").notNull(),
@@ -11930,9 +11955,10 @@ var pipelines = sqliteTable("pipelines", {
11930
11955
  name: text("name").notNull(),
11931
11956
  nameFolded: text("name_folded").notNull(),
11932
11957
  createdAt: integer("created_at").notNull(),
11933
- updatedAt: integer("updated_at").notNull()
11958
+ updatedAt: integer("updated_at").notNull(),
11959
+ deletedAt: integer("deleted_at")
11934
11960
  }, (table) => [
11935
- uniqueIndex("pipelines_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
11961
+ uniqueIndex("pipelines_by_account_id_kind_external_id").on(table.accountId, table.kind, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
11936
11962
  uniqueIndex("pipelines_by_name_folded_kind").on(table.nameFolded, table.kind).where(sql`account_id IS NULL`)
11937
11963
  ]);
11938
11964
  var pipelineStages = sqliteTable("pipeline_stages", {
@@ -11944,7 +11970,8 @@ var pipelineStages = sqliteTable("pipeline_stages", {
11944
11970
  outcome: text("outcome").notNull().default("open"),
11945
11971
  externalId: text("external_id"),
11946
11972
  createdAt: integer("created_at").notNull(),
11947
- updatedAt: integer("updated_at").notNull()
11973
+ updatedAt: integer("updated_at").notNull(),
11974
+ deletedAt: integer("deleted_at")
11948
11975
  }, (table) => [
11949
11976
  unique().on(table.pipelineId, table.nameFolded),
11950
11977
  uniqueIndex("pipeline_stages_by_pipeline_id_external_id").on(table.pipelineId, table.externalId).where(sql`external_id IS NOT NULL`),
@@ -12024,6 +12051,21 @@ var pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
12024
12051
  index("pipeline_stage_changes_by_from_stage_id").on(table.fromStageId),
12025
12052
  index("pipeline_stage_changes_by_to_stage_id").on(table.toStageId)
12026
12053
  ]);
12054
+ var crmFields = sqliteTable("crm_fields", {
12055
+ id: integer("id").primaryKey(),
12056
+ accountId: integer("account_id").notNull().references(() => accounts.id),
12057
+ kind: text("kind").notNull(),
12058
+ code: text("code").notNull(),
12059
+ label: text("label"),
12060
+ type: text("type").notNull(),
12061
+ multiple: integer("multiple").notNull(),
12062
+ filterable: integer("filterable").notNull(),
12063
+ options: text("options"),
12064
+ position: integer("position").notNull(),
12065
+ createdAt: integer("created_at").notNull(),
12066
+ updatedAt: integer("updated_at").notNull(),
12067
+ deletedAt: integer("deleted_at")
12068
+ }, (table) => [unique().on(table.accountId, table.kind, table.code)]);
12027
12069
  var records = sqliteTable("records", {
12028
12070
  id: integer("id").primaryKey(),
12029
12071
  accountId: integer("account_id").notNull().references(() => accounts.id),
@@ -12365,7 +12407,7 @@ var storeSettings = sqliteTable("store_settings", {
12365
12407
  at: integer("at").notNull()
12366
12408
  });
12367
12409
 
12368
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
12410
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
12369
12411
  var ARMS = [
12370
12412
  [
12371
12413
  "message",
@@ -12492,7 +12534,7 @@ var drainInvolvementQueue = /* @__PURE__ */ __name((database, cap = QUEUE_CAP) =
12492
12534
  return recomputed;
12493
12535
  }, "drainInvolvementQueue");
12494
12536
 
12495
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/mentions.js
12537
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/mentions.js
12496
12538
  import { domainToUnicode } from "node:url";
12497
12539
 
12498
12540
  // node_modules/.pnpm/psl@1.15.0/node_modules/psl/dist/psl.mjs
@@ -22514,7 +22556,7 @@ var oa = /* @__PURE__ */ __name((e) => {
22514
22556
  }, "oa");
22515
22557
  var na = { parse: O, get: aa, isValid: oa };
22516
22558
 
22517
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
22559
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
22518
22560
  var LINK = /https?:\/\/(?:(?:docs|drive|sheets|slides)\.google\.com|forms\.gle)(?:[/?#][^\s<>"'`]*)?/gi;
22519
22561
  var ID = /^[\w-]{10,}$/;
22520
22562
  var trimUrl = /* @__PURE__ */ __name((url) => {
@@ -22555,7 +22597,7 @@ var googleDocumentLinks = /* @__PURE__ */ __name((text6) => [...text6.matchAll(L
22555
22597
  return { url, documentId: googleDocumentId(url) };
22556
22598
  }), "googleDocumentLinks");
22557
22599
 
22558
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
22600
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
22559
22601
  var PHONE_PLANS = [
22560
22602
  {
22561
22603
  country: "us",
@@ -22935,7 +22977,7 @@ var PHONE_PLANS = [
22935
22977
  }
22936
22978
  ];
22937
22979
 
22938
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/phones.js
22980
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/phones.js
22939
22981
  var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
22940
22982
  var DEFAULT_PHONE_COUNTRIES = ["ru"];
22941
22983
  var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
@@ -22976,7 +23018,7 @@ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
22976
23018
  return void 0;
22977
23019
  }, "nationalPhone");
22978
23020
 
22979
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/places.js
23021
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/places.js
22980
23022
  var BEFORE = [
22981
23023
  [/^(?:ул\.?|улиц[аеыу]|улицей)$/iu, "\u0443\u043B\u0438\u0446\u0430"],
22982
23024
  [/^(?:пр-т|просп\.?|проспект[аеу]?)$/iu, "\u043F\u0440\u043E\u0441\u043F\u0435\u043A\u0442"],
@@ -23236,7 +23278,7 @@ var findPlaces = /* @__PURE__ */ __name((text6) => {
23236
23278
  return found2.sort((a, b) => a.start - b.start);
23237
23279
  }, "findPlaces");
23238
23280
 
23239
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/mentions.js
23281
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/mentions.js
23240
23282
  var MENTION_KINDS = ["phone", "email", "url", "document", "person-name", "place"];
23241
23283
  var MENTION_VERSIONS = {
23242
23284
  phone: 1,
@@ -23426,7 +23468,7 @@ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE
23426
23468
  };
23427
23469
  }, "typedPhone");
23428
23470
 
23429
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/first-names.js
23471
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/first-names.js
23430
23472
  var RUSSIAN = "\u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440 \u0410\u043B\u0435\u043A\u0441\u0435\u0439 \u0410\u043D\u0430\u0442\u043E\u043B\u0438\u0439 \u0410\u043D\u0434\u0440\u0435\u0439 \u0410\u043D\u0442\u043E\u043D \u0410\u0440\u043A\u0430\u0434\u0438\u0439 \u0410\u0440\u0441\u0435\u043D\u0438\u0439 \u0410\u0440\u0442\u0451\u043C \u0410\u0440\u0442\u0435\u043C \u0410\u0440\u0442\u0443\u0440 \u0411\u043E\u0440\u0438\u0441 \u0412\u0430\u0434\u0438\u043C \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D \u0412\u0430\u043B\u0435\u0440\u0438\u0439 \u0412\u0430\u0441\u0438\u043B\u0438\u0439 \u0412\u0438\u043A\u0442\u043E\u0440 \u0412\u0438\u0442\u0430\u043B\u0438\u0439 \u0412\u043B\u0430\u0434\u0438\u043C\u0438\u0440 \u0412\u043B\u0430\u0434\u0438\u0441\u043B\u0430\u0432 \u0412\u0441\u0435\u0432\u043E\u043B\u043E\u0434 \u0412\u044F\u0447\u0435\u0441\u043B\u0430\u0432 \u0413\u0435\u043D\u043D\u0430\u0434\u0438\u0439 \u0413\u0435\u043E\u0440\u0433\u0438\u0439 \u0413\u043B\u0435\u0431 \u0413\u0440\u0438\u0433\u043E\u0440\u0438\u0439 \u0414\u0430\u043D\u0438\u0438\u043B \u0414\u0430\u043D\u0438\u043B\u0430 \u0414\u0435\u043D\u0438\u0441 \u0414\u043C\u0438\u0442\u0440\u0438\u0439 \u0415\u0432\u0433\u0435\u043D\u0438\u0439 \u0415\u0433\u043E\u0440 \u0418\u0432\u0430\u043D \u0418\u0433\u043E\u0440\u044C \u0418\u043B\u044C\u044F \u041A\u0438\u0440\u0438\u043B\u043B \u041A\u043E\u043D\u0441\u0442\u0430\u043D\u0442\u0438\u043D \u041B\u0435\u043E\u043D\u0438\u0434 \u041C\u0430\u043A\u0441\u0438\u043C \u041C\u0430\u0440\u0430\u0442 \u041C\u0430\u0442\u0432\u0435\u0439 \u041C\u0438\u0445\u0430\u0438\u043B \u041D\u0438\u043A\u0438\u0442\u0430 \u041D\u0438\u043A\u043E\u043B\u0430\u0439 \u041E\u043B\u0435\u0433 \u041F\u0430\u0432\u0435\u043B \u041F\u0451\u0442\u0440 \u041F\u0435\u0442\u0440 \u0420\u043E\u0434\u0438\u043E\u043D \u0420\u043E\u0441\u0442\u0438\u0441\u043B\u0430\u0432 \u0420\u0443\u0441\u043B\u0430\u043D \u0420\u0443\u0441\u0442\u0430\u043C \u0421\u0435\u043C\u0451\u043D \u0421\u0435\u043C\u0435\u043D \u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u0442\u0430\u043D\u0438\u0441\u043B\u0430\u0432 \u0421\u0442\u0435\u043F\u0430\u043D \u0422\u0438\u043C\u043E\u0444\u0435\u0439 \u0422\u0438\u043C\u0443\u0440 \u0424\u0451\u0434\u043E\u0440 \u0424\u0435\u0434\u043E\u0440 \u0424\u0438\u043B\u0438\u043F\u043F \u042D\u0434\u0443\u0430\u0440\u0434 \u042E\u0440\u0438\u0439 \u042F\u0440\u043E\u0441\u043B\u0430\u0432 \u042F\u043A\u043E\u0432 \u042D\u043B\u044C\u0434\u0430\u0440 \u0414\u0430\u0432\u0438\u0434 \u0417\u0430\u0445\u0430\u0440 \u0421\u0430\u0432\u0435\u043B\u0438\u0439 \u041C\u0438\u0440\u043E\u043D \u041F\u043B\u0430\u0442\u043E\u043D \u0414\u0435\u043C\u0438\u0434 \u0410\u0440\u0441\u0435\u043D \u041D\u0443\u0440\u043B\u0430\u043D \u0410\u043D\u0437\u043E\u0440 \u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440\u0430 \u0410\u043B\u0438\u043D\u0430 \u0410\u043B\u0438\u0441\u0430 \u0410\u043B\u043B\u0430 \u0410\u043D\u0430\u0441\u0442\u0430\u0441\u0438\u044F \u0410\u043D\u0433\u0435\u043B\u0438\u043D\u0430 \u0410\u043D\u043D\u0430 \u0410\u043D\u0442\u043E\u043D\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u0440\u0438\u044F \u0412\u0430\u0440\u0432\u0430\u0440\u0430 \u0412\u0435\u0440\u043E\u043D\u0438\u043A\u0430 \u0412\u0438\u043A\u0442\u043E\u0440\u0438\u044F \u0413\u0430\u043B\u0438\u043D\u0430 \u0414\u0430\u0440\u044C\u044F \u0414\u0438\u0430\u043D\u0430 \u0415\u0432\u0433\u0435\u043D\u0438\u044F \u0415\u043A\u0430\u0442\u0435\u0440\u0438\u043D\u0430 \u0415\u043B\u0435\u043D\u0430 \u0415\u043B\u0438\u0437\u0430\u0432\u0435\u0442\u0430 \u0416\u0430\u043D\u043D\u0430 \u0417\u0438\u043D\u0430\u0438\u0434\u0430 \u041A\u0430\u0440\u0438\u043D\u0430 \u041A\u0438\u0440\u0430 \u041A\u043B\u0430\u0432\u0434\u0438\u044F \u041A\u0440\u0438\u0441\u0442\u0438\u043D\u0430 \u041A\u0441\u0435\u043D\u0438\u044F \u041B\u0430\u0440\u0438\u0441\u0430 \u041B\u0438\u0434\u0438\u044F \u041B\u044E\u0434\u043C\u0438\u043B\u0430 \u041C\u0430\u0440\u0433\u0430\u0440\u0438\u0442\u0430 \u041C\u0430\u0440\u0438\u043D\u0430 \u041C\u0430\u0440\u0438\u044F \u041C\u0438\u043B\u0430\u043D\u0430 \u041D\u0430\u0442\u0430\u043B\u044C\u044F \u041D\u0430\u0442\u0430\u043B\u0438\u044F \u041D\u0438\u043D\u0430 \u041E\u043A\u0441\u0430\u043D\u0430 \u041E\u043B\u0435\u0441\u044F \u041E\u043B\u044C\u0433\u0430 \u041F\u043E\u043B\u0438\u043D\u0430 \u0420\u0430\u0438\u0441\u0430 \u0421\u0432\u0435\u0442\u043B\u0430\u043D\u0430 \u0421\u043E\u0444\u0438\u044F \u0421\u043E\u0444\u044C\u044F \u0422\u0430\u0438\u0441\u0438\u044F \u0422\u0430\u043C\u0430\u0440\u0430 \u0422\u0430\u0442\u044C\u044F\u043D\u0430 \u0423\u043B\u044C\u044F\u043D\u0430 \u042E\u043B\u0438\u044F \u042D\u043B\u044C\u0432\u0438\u0440\u0430 \u0420\u0435\u0433\u0438\u043D\u0430 \u0421\u043D\u0435\u0436\u0430\u043D\u0430 \u0410\u043B\u0451\u043D\u0430 \u0410\u043B\u0435\u043D\u0430 \u0412\u0430\u0441\u0438\u043B\u0438\u0441\u0430 \u0410\u0440\u0438\u043D\u0430 \u0415\u0441\u0435\u043D\u0438\u044F \u042D\u0432\u0435\u043B\u0438\u043D\u0430 \u0421\u0430\u0448\u0430 \u0416\u0435\u043D\u044F \u0412\u0430\u043B\u044F \u0414\u0438\u043C\u0430 \u041C\u0438\u0448\u0430 \u041A\u043E\u043B\u044F \u041F\u0435\u0442\u044F \u0412\u0430\u0441\u044F \u0421\u0435\u0440\u0451\u0436\u0430 \u0421\u0435\u0440\u0435\u0436\u0430 \u041F\u0430\u0448\u0430 \u041B\u0451\u0448\u0430 \u041B\u0435\u0448\u0430 \u0412\u0438\u0442\u044F \u041A\u043E\u0441\u0442\u044F \u0412\u043E\u0432\u0430 \u0412\u043E\u043B\u043E\u0434\u044F \u0412\u0430\u043D\u044F \u0413\u043E\u0448\u0430 \u0413\u0440\u0438\u0448\u0430 \u0422\u043E\u043B\u044F \u0411\u043E\u0440\u044F \u0421\u0442\u0430\u0441 \u0422\u0451\u043C\u0430 \u0422\u0430\u043D\u044F \u041A\u0430\u0442\u044F \u041B\u0435\u043D\u0430 \u041D\u0430\u0442\u0430\u0448\u0430 \u0421\u0432\u0435\u0442\u0430 \u042E\u043B\u044F \u041D\u0430\u0441\u0442\u044F \u0414\u0430\u0448\u0430 \u041C\u0430\u0448\u0430 \u041B\u044E\u0434\u0430 \u0413\u0430\u043B\u044F \u0412\u0438\u043A\u0430 \u041A\u0441\u044E\u0448\u0430 \u041B\u0438\u0437\u0430 \u0421\u043E\u043D\u044F \u041D\u0430\u0434\u044F \u041B\u0435\u0440\u0430 \u0410\u043B\u0451\u0448\u0430 \u0410\u043B\u0435\u0448\u0430 \u041C\u0438\u0442\u044F \u0421\u0435\u043D\u044F \u0424\u0435\u0434\u044F \u0416\u0435\u043D\u0435\u0447\u043A\u0430 \u041E\u043B\u0435\u043D\u044C\u043A\u0430 \u0422\u0430\u043D\u0435\u0447\u043A\u0430";
23431
23473
  var EUROPEAN = "James John Robert Michael William David Richard Joseph Thomas Charles Christopher Daniel Matthew Anthony Donald Steven Paul Andrew Joshua Kenneth Kevin Brian George Timothy Ronald Edward Jason Jeffrey Ryan Jacob Gary Nicholas Eric Jonathan Stephen Larry Justin Scott Brandon Benjamin Samuel Gregory Alexander Patrick Raymond Dennis Jerry Tyler Aaron Nathan Henry Peter Zachary Douglas Harold Kyle Noah Ethan Oliver Harry Lucas Liam Mary Patricia Jennifer Linda Elizabeth Barbara Susan Jessica Sarah Karen Lisa Nancy Betty Margaret Sandra Ashley Kimberly Emily Donna Michelle Carol Amanda Dorothy Melissa Deborah Stephanie Rebecca Sharon Laura Cynthia Kathleen Angela Shirley Anna Brenda Pamela Emma Nicole Helen Samantha Katherine Christine Rachel Carolyn Janet Catherine Maria Heather Diane Ruth Julie Olivia Joyce Kelly Lauren Christina Joan Evelyn Judith Megan Andrea Cheryl Hannah Jacqueline Martha Teresa Sara Madison Frances Kathryn Janice Abigail Alice Julia Judy Sophia Denise Doris Marilyn Danielle Beverly Isabella Theresa Diana Natalie Charlotte Marie Kayla Alexis Javier Carlos Antonio Manuel Francisco Juan Pedro Alejandro Miguel Rafael Pablo Sergio Fernando Jorge Luis Alberto \xC1lvaro Diego Adri\xE1n Rub\xE9n Iv\xE1n \xD3scar Andr\xE9s Ra\xFAl Enrique Vicente Joaqu\xEDn Ignacio Gonzalo Marcos V\xEDctor Jaime Alfonso Guillermo Tom\xE1s Emilio Gabriel Nicol\xE1s Mart\xEDn Jordi Josep Xavier Luc\xEDa Carmen Isabel Cristina Marta Elena Raquel Silvia Beatriz Paula Nuria N\xFAria Sonia Alicia Irene Montserrat Inmaculada Noelia Lorena Sof\xEDa Valeria Claudia Natalia Sandra Ver\xF3nica Esther Yolanda Vanesa Laia Klaus J\xFCrgen Wolfgang Stefan Andreas Matthias Markus Tobias Florian Lukas Jonas Maximilian Sebastian Dirk Sabine Ursula Petra Monika Katrin Anja Pierre Michel Philippe Alain Fran\xE7ois Christophe Laurent Olivier Julien Mathieu S\xE9bastien Guillaume Antoine Camille Nathalie Isabelle Sylvie Sophie C\xE9line Aur\xE9lie Chlo\xE9 Manon Giuseppe Giovanni Marco Luca Francesco Alessandro Matteo Lorenzo Stefano Paolo Roberto Davide Simone Federico Giulia Francesca Chiara Valentina Alessia Martina Elisa Jo\xE3o Pedro Tiago Beatriz In\xEAs Mariana Piotr Krzysztof Tomasz Marcin Agnieszka Katarzyna Ma\u0142gorzata Magdalena";
23432
23474
  var WORDS = "\u0412\u0435\u0440\u0430 \u041D\u0430\u0434\u0435\u0436\u0434\u0430 \u041B\u044E\u0431\u043E\u0432\u044C \u0421\u043B\u0430\u0432\u0430 \u0420\u043E\u043C\u0430\u043D \u0420\u043E\u0437\u0430 \u041C\u0430\u0439\u044F \u041B\u0438\u043B\u0438\u044F \u0417\u043B\u0430\u0442\u0430 \u041C\u0438\u043B\u0430 \u041D\u0438\u043A\u0430 \u041B\u0435\u0432 \u0413\u043B\u043E\u0440\u0438\u044F Will Mark Rose Grace Hope Faith Bill Frank Jack June April Summer Amber Ruby Lily Daisy Victoria Virginia Georgia Florence Sydney Chelsea Jordan Austin Dallas Mercedes Dolores Rosa Pilar Marina Esperanza Gloria Amparo Consuelo Roc\xEDo Salvador Santiago Jes\xFAs \xC1ngeles Hugo Ram\xF3n Christian Felix F\xE9lix Mario Martin Victor Pierre Paz Merc\xE8 Estrella Aurora Concepci\xF3n Remedios Soledad Milagros Angel \xC1ngel Dawn Joy Holly Ivy Iris Violet Pearl";
@@ -23434,7 +23476,7 @@ var NOT_NAMES = ["\u0436\u0435\u043D\u0430", "\u0436\u0435\u043D\u044B", "\u0436
23434
23476
  var FIRST_NAMES = [...new Set(`${RUSSIAN} ${EUROPEAN}`.split(" "))];
23435
23477
  var NAME_WORDS = WORDS.split(" ");
23436
23478
 
23437
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/person-names.js
23479
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/person-names.js
23438
23480
  var LATIN_TO_CYRILLIC = {
23439
23481
  shch: "\u0449",
23440
23482
  sch: "\u0449",
@@ -23642,7 +23684,7 @@ var findUnknownNames = /* @__PURE__ */ __name((text6, stem, taken) => {
23642
23684
  return found2;
23643
23685
  }, "findUnknownNames");
23644
23686
 
23645
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/attachments.js
23687
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/attachments.js
23646
23688
  var NOT_FILES = /* @__PURE__ */ new Set([
23647
23689
  "webpage",
23648
23690
  "share",
@@ -23682,7 +23724,7 @@ var matchDownloads = /* @__PURE__ */ __name((stored3, files2) => {
23682
23724
  });
23683
23725
  }, "matchDownloads");
23684
23726
 
23685
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
23727
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
23686
23728
  var QUERY_VERSION = 1;
23687
23729
  var QUERY_LIMITS2 = {
23688
23730
  ...QUERY_LIMITS,
@@ -23718,7 +23760,7 @@ function exhausted(budget) {
23718
23760
  }
23719
23761
  __name(exhausted, "exhausted");
23720
23762
 
23721
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
23763
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
23722
23764
  var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
23723
23765
  var literal2 = /* @__PURE__ */ __name((c) => ({
23724
23766
  kind: "char",
@@ -24118,7 +24160,7 @@ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
24118
24160
  return out;
24119
24161
  }, "foldRegex");
24120
24162
 
24121
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
24163
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
24122
24164
  var PRESET_VERSION = 1;
24123
24165
  var PRESETS = {
24124
24166
  password: {
@@ -24172,7 +24214,7 @@ var PRESETS = {
24172
24214
  }
24173
24215
  };
24174
24216
 
24175
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
24217
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
24176
24218
  var FIELD_VERSION = 2;
24177
24219
  var UNITS = {
24178
24220
  "": 1,
@@ -24633,12 +24675,12 @@ var validateAst = /* @__PURE__ */ __name((input) => {
24633
24675
  return validateFields(parsed3.output);
24634
24676
  }, "validateAst");
24635
24677
 
24636
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
24678
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
24637
24679
  var hasText = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "text" || node.field === "exact" : node.clauses.some(({ node: node2 }) => hasText(node2)), "hasText");
24638
24680
  var isStemmed = /* @__PURE__ */ __name((node) => node.field === "text" && (node.operator === "term" || node.operator === "phrase") && node.value !== "", "isStemmed");
24639
24681
  var hasStems = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? isStemmed(node) : node.clauses.some(({ node: node2 }) => hasStems(node2)), "hasStems");
24640
24682
 
24641
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
24683
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
24642
24684
  var LIVE = "mn.kind = 'url' AND mn.status <> 'dismissed'";
24643
24685
  var MAIL_ROWS = `SELECT mn.source_id FROM mentions mn WHERE mn.source_type = 'email' AND ${LIVE}`;
24644
24686
  var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
@@ -24662,7 +24704,7 @@ var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
24662
24704
  };
24663
24705
  }, "linkMatch");
24664
24706
 
24665
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
24707
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
24666
24708
  var SETTING = "phoneCountries";
24667
24709
  var savedPhoneCountries = /* @__PURE__ */ __name((database) => {
24668
24710
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING);
@@ -24693,7 +24735,7 @@ var valueMatch = /* @__PURE__ */ __name((database, typed) => {
24693
24735
  return { sql: "mn.value = ?", params: [phone?.value ?? normalizedValue(typed, { phoneCountries })] };
24694
24736
  }, "valueMatch");
24695
24737
 
24696
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
24738
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
24697
24739
  var normalizeVocabularyName = /* @__PURE__ */ __name((input) => {
24698
24740
  if (typeof input !== "string" || input.length > 200 || /[\p{Cc}\p{Cf}]/u.test(input))
24699
24741
  throw new CliError("validation_error", "a vocabulary name takes 1\u2013200 characters without control characters");
@@ -24721,7 +24763,7 @@ var vocabularySimilarity = /* @__PURE__ */ __name((left, right) => {
24721
24763
  return 2 * intersection2 / (aa2.size + bb.size);
24722
24764
  }, "vocabularySimilarity");
24723
24765
 
24724
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
24766
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
24725
24767
  import { createHash } from "node:crypto";
24726
24768
  var folded2 = /* @__PURE__ */ __name((name) => {
24727
24769
  try {
@@ -24787,7 +24829,7 @@ var guardTagCreation = /* @__PURE__ */ __name((context, name, kind3, by, options
24787
24829
  });
24788
24830
  }, "guardTagCreation");
24789
24831
 
24790
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
24832
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
24791
24833
  var invalid = /* @__PURE__ */ __name((message2) => {
24792
24834
  throw new CliError("validation_error", message2);
24793
24835
  }, "invalid");
@@ -24864,7 +24906,7 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
24864
24906
  };
24865
24907
  }, "createTagRedirectIndex");
24866
24908
 
24867
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
24909
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
24868
24910
  var tagCanonicalId = /* @__PURE__ */ __name((database, id2) => {
24869
24911
  const row2 = database.prepare("SELECT canonical_id FROM resolved_tags WHERE id=?").get(id2);
24870
24912
  if (!row2)
@@ -24892,7 +24934,7 @@ var tagRedirectSnapshot = /* @__PURE__ */ __name((database) => {
24892
24934
  return snapshot2;
24893
24935
  }, "tagRedirectSnapshot");
24894
24936
 
24895
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
24937
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
24896
24938
  import { createHash as createHash2 } from "node:crypto";
24897
24939
  var TASK_KEY_PREFIXES = {
24898
24940
  question: "Q",
@@ -24920,7 +24962,7 @@ var taskAccountOf = /* @__PURE__ */ __name((database, rowId) => {
24920
24962
  return row2 && String(row2.key) === inboxKey(String(row2.name)) ? String(row2.name) : void 0;
24921
24963
  }, "taskAccountOf");
24922
24964
 
24923
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
24965
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
24924
24966
  var storedThing = /* @__PURE__ */ __name((type, id2) => ({ type: String(type), id: Number(id2) }), "storedThing");
24925
24967
  var REFERABLE = {
24926
24968
  note: { tombstone: true },
@@ -25003,9 +25045,9 @@ var emailThreadOf = /* @__PURE__ */ __name((database, account, thread) => {
25003
25045
  }, "emailThreadOf");
25004
25046
  var referenceOfThing = /* @__PURE__ */ __name((database, thing) => {
25005
25047
  if (["meeting", "meeting_transcript", "meeting_transcript_row"].includes(thing.type)) {
25006
- const join3 = thing.type === "meeting" ? "FROM meetings m WHERE m.id=?" : thing.type === "meeting_transcript" ? "FROM meeting_transcripts t JOIN meetings m ON m.id=t.meeting_id WHERE t.id=?" : "FROM meeting_transcript_rows r JOIN meeting_transcripts t ON t.id=r.meeting_transcript_id JOIN meetings m ON m.id=t.meeting_id WHERE r.id=?";
25048
+ const join4 = thing.type === "meeting" ? "FROM meetings m WHERE m.id=?" : thing.type === "meeting_transcript" ? "FROM meeting_transcripts t JOIN meetings m ON m.id=t.meeting_id WHERE t.id=?" : "FROM meeting_transcript_rows r JOIN meeting_transcripts t ON t.id=r.meeting_transcript_id JOIN meetings m ON m.id=t.meeting_id WHERE r.id=?";
25007
25049
  const columns = thing.type === "meeting" ? "m.account_id,m.id AS meeting_id,m.deleted_at AS meeting_deleted" : `m.account_id,m.id AS meeting_id,m.deleted_at AS meeting_deleted,t.id AS transcript_id,t.deleted_at AS transcript_deleted${thing.type === "meeting_transcript_row" ? ",r.position" : ""}`;
25008
- const row2 = database.prepare(`SELECT ${columns} ${join3}`).get(thing.id);
25050
+ const row2 = database.prepare(`SELECT ${columns} ${join4}`).get(thing.id);
25009
25051
  if (!row2)
25010
25052
  return void 0;
25011
25053
  return formatMeetingReference({
@@ -25088,7 +25130,7 @@ var taskIdOf = /* @__PURE__ */ __name((database, rowId) => {
25088
25130
  return row2 ? String(row2.id ?? row2.key) : void 0;
25089
25131
  }, "taskIdOf");
25090
25132
 
25091
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
25133
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
25092
25134
  var toMs = /* @__PURE__ */ __name((iso14) => {
25093
25135
  if (iso14 === null || iso14 === void 0)
25094
25136
  return null;
@@ -25102,7 +25144,7 @@ var present = /* @__PURE__ */ __name((entries) => Object.fromEntries(Object.entr
25102
25144
  var DELIVERY = { delivered: 1, read: 2 };
25103
25145
  var deliveryOf = /* @__PURE__ */ __name((stored3) => stored3 === DELIVERY.read ? "read" : stored3 === DELIVERY.delivered ? "delivered" : void 0, "deliveryOf");
25104
25146
 
25105
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
25147
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
25106
25148
  var TAG_KINDS = ["tag", "topic"];
25107
25149
  var TAGGABLE = { chat: "chat", contact: "identity", message: "message", task: "task" };
25108
25150
  var TAG_TYPE = {
@@ -25305,7 +25347,7 @@ var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
25305
25347
  return result;
25306
25348
  }, "tagsOf");
25307
25349
 
25308
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
25350
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
25309
25351
  var speech = /* @__PURE__ */ __name((alias2) => `(coalesce(${alias2}.extractor,'') LIKE 'speech:%' OR ${alias2}.kind IN ('voice','video_note') OR coalesce(${alias2}.mime,'')='audio/ogg')`, "speech");
25310
25352
  var SPEECH = speech("att");
25311
25353
  var mentionText = /* @__PURE__ */ __name((alias2) => `CASE WHEN coalesce(json_extract(${alias2}.contact, '$.phone'), '') <> '' THEN 'phone: ' || json_extract(${alias2}.contact, '$.phone') ELSE ${alias2}.text END`, "mentionText");
@@ -25669,7 +25711,7 @@ var FIELD_COMPILERS = {
25669
25711
  subject
25670
25712
  };
25671
25713
 
25672
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
25714
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
25673
25715
  var placeOf = /* @__PURE__ */ __name((database) => {
25674
25716
  const exact = database.prepare("SELECT id FROM places WHERE folded = ?");
25675
25717
  const onStreet = database.prepare("SELECT id FROM places WHERE substr(folded, 1, ?) = ? LIMIT 2");
@@ -25685,7 +25727,7 @@ var placeOf = /* @__PURE__ */ __name((database) => {
25685
25727
  };
25686
25728
  }, "placeOf");
25687
25729
 
25688
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
25730
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
25689
25731
  var DRAIN_ON_WRITE = 500;
25690
25732
  var METHOD = "rules";
25691
25733
  var telegramLink = /* @__PURE__ */ __name((database) => {
@@ -25848,7 +25890,7 @@ var drainMentions = /* @__PURE__ */ __name((database, now2, limit = DRAIN_ON_WRI
25848
25890
  return queued.length;
25849
25891
  }, "drainMentions");
25850
25892
 
25851
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
25893
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
25852
25894
  var indexRow = /* @__PURE__ */ __name((database, name) => {
25853
25895
  const exists2 = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'search_index_state'").get();
25854
25896
  if (!exists2)
@@ -25856,7 +25898,7 @@ var indexRow = /* @__PURE__ */ __name((database, name) => {
25856
25898
  return database.prepare("SELECT * FROM search_index_state WHERE name = ?").get(name);
25857
25899
  }, "indexRow");
25858
25900
 
25859
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
25901
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
25860
25902
  var INDEX = "message_stems";
25861
25903
  var SETTING2 = "searchStemmers";
25862
25904
  var DRAIN_ON_WRITE2 = 500;
@@ -25978,7 +26020,7 @@ var stemmerCache = /* @__PURE__ */ __name(() => {
25978
26020
  };
25979
26021
  }, "stemmerCache");
25980
26022
 
25981
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
26023
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
25982
26024
  var SQLITE_BUSY = 5;
25983
26025
  var pause = new Int32Array(new SharedArrayBuffer(4));
25984
26026
  var isBusy = /* @__PURE__ */ __name((error) => {
@@ -26073,7 +26115,7 @@ var read = /* @__PURE__ */ __name((database, body2) => {
26073
26115
  }
26074
26116
  }, "read");
26075
26117
 
26076
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
26118
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
26077
26119
  var source = /* @__PURE__ */ __name((model, dims) => `SELECT k.id, k.chunkable_type,
26078
26120
  coalesce(CASE k.chunkable_type
26079
26121
  WHEN 'image' THEN (SELECT ch.account_id FROM attachments a JOIN messages m ON m.id = a.attachable_id
@@ -26215,7 +26257,7 @@ var dropUnusedVectors = /* @__PURE__ */ __name((database, hashes) => {
26215
26257
  }, "dropUnusedVectors");
26216
26258
  var dropAllUnusedVectors = /* @__PURE__ */ __name((database) => database.prepare("DELETE FROM embeddings WHERE NOT EXISTS (SELECT 1 FROM chunks k WHERE k.content_hash = embeddings.content_hash) RETURNING 1").all().length, "dropAllUnusedVectors");
26217
26259
 
26218
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
26260
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
26219
26261
  var accountPk = /* @__PURE__ */ __name(({ orm, now: now2 }, { provider, account, scope: scope3 }, name = null) => Number(orm.insert(accounts).values({ provider, externalId: account, name, scope: scope3 ?? "personal", createdAt: now2(), updatedAt: now2() }).onConflictDoUpdate({
26220
26262
  target: [accounts.provider, accounts.externalId],
26221
26263
  set: {
@@ -26287,6 +26329,7 @@ var purgeAccount = /* @__PURE__ */ __name(({ orm, database }, accountKey) => {
26287
26329
  orm.delete(accountIdentities).where(eq(accountIdentities.accountId, accountKey)).run();
26288
26330
  orm.update(projects).set({ accountId: null }).where(eq(projects.accountId, accountKey)).run();
26289
26331
  orm.run(sql`DELETE FROM files WHERE account_id = ${accountKey}`);
26332
+ orm.run(sql`DELETE FROM crm_fields WHERE account_id = ${accountKey}`);
26290
26333
  const recordsOf = sql`(SELECT id FROM records WHERE account_id = ${accountKey})`;
26291
26334
  orm.run(sql`DELETE FROM record_relations WHERE record_id IN ${recordsOf} OR target_id IN ${recordsOf}`);
26292
26335
  orm.run(sql`DELETE FROM records WHERE account_id = ${accountKey}`);
@@ -26324,7 +26367,7 @@ var dropOrphanPeople = /* @__PURE__ */ __name((database, unseenBefore) => {
26324
26367
  AND id NOT IN (SELECT id FROM (${referencesTo(database, "persons", /* @__PURE__ */ new Set(["identity_links"]))}) WHERE id IS NOT NULL)`).run(JSON.stringify(persons2));
26325
26368
  }, "dropOrphanPeople");
26326
26369
 
26327
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
26370
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
26328
26371
  var FOLDED = [
26329
26372
  { table: "tasks", column: "title" },
26330
26373
  { table: "tasks", column: "close_reason" },
@@ -26361,7 +26404,7 @@ var fillFolded = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
26361
26404
  return filled2;
26362
26405
  }, "fillFolded");
26363
26406
 
26364
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/history-skips.js
26407
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/history-skips.js
26365
26408
  var HISTORY_KEY = "$history";
26366
26409
  var objectOf = /* @__PURE__ */ __name((text6) => {
26367
26410
  if (typeof text6 !== "string")
@@ -26437,7 +26480,7 @@ var withoutHistory = /* @__PURE__ */ __name((metadata3) => {
26437
26480
  return rest;
26438
26481
  }, "withoutHistory");
26439
26482
 
26440
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
26483
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
26441
26484
  import { createHash as createHash3 } from "node:crypto";
26442
26485
  var CHUNK_CHARS = 1200;
26443
26486
  var CHUNK_OVERLAP = 150;
@@ -26542,7 +26585,7 @@ var cutChunks = /* @__PURE__ */ __name((members2, limit = CHUNK_CHARS, check3, c
26542
26585
  return chunks2;
26543
26586
  }, "cutChunks");
26544
26587
 
26545
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/task-signature.js
26588
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/task-signature.js
26546
26589
  var DAY = 864e5;
26547
26590
  var CURRENCY = [
26548
26591
  [/^(₽|руб.*|р\.?|rub)$/u, "RUB"],
@@ -26608,15 +26651,15 @@ var dayOf = /* @__PURE__ */ __name((ms) => {
26608
26651
  const date3 = new Date(ms);
26609
26652
  return Math.floor(Date.UTC(date3.getFullYear(), date3.getMonth(), date3.getDate()) / DAY);
26610
26653
  }, "dayOf");
26611
- var dateDay = /* @__PURE__ */ __name((year, month, day) => Math.floor(Date.UTC(year, month, day) / DAY), "dateDay");
26612
- var monthDate = /* @__PURE__ */ __name((year, word2 = "", day = "") => {
26654
+ var dateDay = /* @__PURE__ */ __name((year, month, day2) => Math.floor(Date.UTC(year, month, day2) / DAY), "dateDay");
26655
+ var monthDate = /* @__PURE__ */ __name((year, word2 = "", day2 = "") => {
26613
26656
  const month = monthIndex(word2);
26614
- return month < 0 || Number(day) > 31 ? void 0 : dateDay(year, month, Number(day));
26657
+ return month < 0 || Number(day2) > 31 ? void 0 : dateDay(year, month, Number(day2));
26615
26658
  }, "monthDate");
26616
- var nthDay = /* @__PURE__ */ __name((day, now2) => {
26659
+ var nthDay = /* @__PURE__ */ __name((day2, now2) => {
26617
26660
  const date3 = new Date(now2 * DAY);
26618
- const sameMonth = dateDay(date3.getUTCFullYear(), date3.getUTCMonth(), day);
26619
- return sameMonth >= now2 ? sameMonth : dateDay(date3.getUTCFullYear(), date3.getUTCMonth() + 1, day);
26661
+ const sameMonth = dateDay(date3.getUTCFullYear(), date3.getUTCMonth(), day2);
26662
+ return sameMonth >= now2 ? sameMonth : dateDay(date3.getUTCFullYear(), date3.getUTCMonth() + 1, day2);
26620
26663
  }, "nthDay");
26621
26664
  var monthEnd = /* @__PURE__ */ __name((now2) => {
26622
26665
  const date3 = new Date(now2 * DAY);
@@ -26624,10 +26667,10 @@ var monthEnd = /* @__PURE__ */ __name((now2) => {
26624
26667
  }, "monthEnd");
26625
26668
  var nextWeekday = /* @__PURE__ */ __name((word2, now2) => {
26626
26669
  const target = Math.max(RU_WEEKDAYS.findIndex((stem) => word2.startsWith(stem)), EN_WEEKDAYS.indexOf(word2), ES_WEEKDAYS.indexOf(word2));
26627
- let day = now2 + 1;
26628
- while (new Date(day * DAY).getUTCDay() !== target)
26629
- day++;
26630
- return day;
26670
+ let day2 = now2 + 1;
26671
+ while (new Date(day2 * DAY).getUTCDay() !== target)
26672
+ day2++;
26673
+ return day2;
26631
26674
  }, "nextWeekday");
26632
26675
  var words2 = /* @__PURE__ */ __name((source2) => new RegExp(`(?<![\\p{L}\\p{N}])(?:${source2})(?![\\p{L}\\p{N}])`, "gu"), "words");
26633
26676
  var ES_DAY = "(3[01]|[12]\\d|0?[1-9])";
@@ -26658,17 +26701,17 @@ var dueDayOf = /* @__PURE__ */ __name((text6, createdMs) => {
26658
26701
  let best;
26659
26702
  for (const [pattern, resolve] of DUE_PATTERNS)
26660
26703
  for (const match of text6.matchAll(pattern)) {
26661
- const day = resolve(match, now2, year);
26662
- if (day === void 0 || Number.isNaN(day))
26704
+ const day2 = resolve(match, now2, year);
26705
+ if (day2 === void 0 || Number.isNaN(day2))
26663
26706
  continue;
26664
26707
  if (!best || (match.index ?? 0) < best.index)
26665
- best = { index: match.index ?? 0, day };
26708
+ best = { index: match.index ?? 0, day: day2 };
26666
26709
  break;
26667
26710
  }
26668
26711
  return best?.day ?? null;
26669
26712
  }, "dueDayOf");
26670
26713
 
26671
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
26714
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
26672
26715
  var DAY2 = 864e5;
26673
26716
  var STOP_WORDS = new Set([
26674
26717
  // Russian and English as the test set ran them, already folded (пожалуйста → пожалуиста).
@@ -26823,7 +26866,7 @@ var rankCandidates = /* @__PURE__ */ __name((views, candidates) => candidates.ma
26823
26866
  ...compareViews(subjectViews ?? views, candidate, replyChain === void 0 ? {} : { replyChain })
26824
26867
  })).sort((a, b) => b.score - a.score), "rankCandidates");
26825
26868
 
26826
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
26869
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
26827
26870
  var currentChunks = /* @__PURE__ */ __name((chatKey) => sql`SELECT k.content_hash, k.chunkable_id AS conversation_id, r.first_message_id,
26828
26871
  r.last_message_id, r.text_start, r.text_end FROM chunks k JOIN chunk_messages r ON r.chunk_id = k.id
26829
26872
  JOIN conversations c ON k.chunkable_type = 'conversation' AND c.id = k.chunkable_id
@@ -27094,7 +27137,7 @@ var readiness = /* @__PURE__ */ __name(({ orm }, chatKey, model) => {
27094
27137
  };
27095
27138
  }, "readiness");
27096
27139
 
27097
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
27140
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
27098
27141
  var DOCUMENT_PICTURE = "document_picture";
27099
27142
  var SCAN_PAGE2 = 5e3;
27100
27143
  var idOf = /* @__PURE__ */ __name((ref3) => {
@@ -27157,7 +27200,7 @@ var documentPicturesOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
27157
27200
  }, "nearestPictures")
27158
27201
  }), "documentPicturesOver");
27159
27202
 
27160
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
27203
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
27161
27204
  var glob = /* @__PURE__ */ __name((value) => [...fold(value).matchAll(/\\(.)|([*?])|(.)/gsu)].map(([, escaped2, wildcard, plain2]) => {
27162
27205
  const literal4 = escaped2 ?? plain2 ?? "";
27163
27206
  return wildcard ?? (/[*?[]/u.test(literal4) ? `[${literal4}]` : literal4);
@@ -27222,7 +27265,7 @@ var compile = /* @__PURE__ */ __name((node, columns, options) => {
27222
27265
  var queryFilter = /* @__PURE__ */ __name((ast, columns, options = {}) => compile(ast.root, columns, options), "queryFilter");
27223
27266
  var bound2 = /* @__PURE__ */ __name(({ sql: text6, params }) => sql.join(text6.split("?").map((part, at) => at < params.length ? sql`${sql.raw(part)}${params[at]}` : sql.raw(part)), sql``), "bound");
27224
27267
 
27225
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
27268
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
27226
27269
  var toJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.stringify(value), "toJson");
27227
27270
  var fromJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.parse(String(value)), "fromJson");
27228
27271
  var int = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "int");
@@ -27312,7 +27355,7 @@ var linkMeeting = /* @__PURE__ */ __name((database, id2, eventId, now2, mode = "
27312
27355
  });
27313
27356
  }, "linkMeeting");
27314
27357
 
27315
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
27358
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
27316
27359
  var EVENT_TEXT = "trim(coalesce(e.description, '') || ' ' || coalesce(e.location, '') || ' ' || coalesce((SELECT group_concat(p.name, ' ') FROM calendar_entries ce JOIN calendar_entry_participants p ON p.entry_id = ce.id WHERE ce.event_id = e.id AND ce.deleted_at IS NULL AND p.resource = 0 AND p.name IS NOT NULL), ''))";
27317
27360
  var UNSEARCHED_EVENT_TYPES = [
27318
27361
  "working-location",
@@ -27497,6 +27540,8 @@ var writer2 = /* @__PURE__ */ __name((database, corpus, stemmer) => {
27497
27540
  };
27498
27541
  }, "writer");
27499
27542
  var drainCorpus = /* @__PURE__ */ __name((database, corpus, stemmerFor2, { batch = 200, until = /* @__PURE__ */ __name(() => false, "until") } = {}) => {
27543
+ if (isQueryOnly(database))
27544
+ return 0;
27500
27545
  if (corpus.type === "email" || corpus.type === "document")
27501
27546
  database.prepare(`UPDATE chunks SET account_id = (SELECT account_id FROM ${corpus.table} WHERE id = chunks.chunkable_id)
27502
27547
  WHERE chunkable_type = ? AND account_id IS NULL`).run(corpus.type);
@@ -27542,7 +27587,7 @@ var resetNoteIndex = /* @__PURE__ */ __name((database) => {
27542
27587
  return true;
27543
27588
  }, "resetNoteIndex");
27544
27589
 
27545
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
27590
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
27546
27591
  var keyOf3 = /* @__PURE__ */ __name((name) => fold(name).trim().replace(/^@/, ""), "keyOf");
27547
27592
  var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
27548
27593
  for (const key2 of new Set(names.filter((name) => !!name?.trim()).map(keyOf3))) {
@@ -27561,7 +27606,7 @@ var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
27561
27606
  }
27562
27607
  }, "resolvePersonLinks");
27563
27608
 
27564
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
27609
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
27565
27610
  var flag2 = /* @__PURE__ */ __name((value) => value === void 0 || value === null ? null : Number(value), "flag");
27566
27611
  var prepare = /* @__PURE__ */ __name((orm) => ({
27567
27612
  find: orm.select({
@@ -27786,7 +27831,7 @@ var meetingIdentityPk = /* @__PURE__ */ __name((context, accountId, identity) =>
27786
27831
  }, "meetingIdentityPk");
27787
27832
  var phoneOf = /* @__PURE__ */ __name(({ orm }, provider, nativeId) => orm.select({ phone: identities.phone }).from(identities).where(and(eq(identities.provider, provider), eq(identities.externalId, nativeId))).get()?.phone ?? null, "phoneOf");
27788
27833
 
27789
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
27834
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
27790
27835
  var chatOf = /* @__PURE__ */ __name(({ orm }, accountKey, chatKey) => orm.select({ id: chats.externalId }).from(chats).where(and(eq(chats.id, chatKey), eq(chats.accountId, accountKey))).get()?.id, "chatOf");
27791
27836
  var findChatPk = /* @__PURE__ */ __name(({ orm }, accountKey, chatId) => orm.select({ pk: chats.id }).from(chats).where(and(eq(chats.accountId, accountKey), eq(chats.externalId, chatId))).get()?.pk, "findChatPk");
27792
27837
  var chatPkFor = /* @__PURE__ */ __name((context, accountKey, chatId) => findChatPk(context, accountKey, chatId) ?? Number(context.orm.insert(chats).values({
@@ -28066,7 +28111,7 @@ var replaceAutoTags = /* @__PURE__ */ __name((context, key2, chatId, algorithm,
28066
28111
  }
28067
28112
  }, "replaceAutoTags");
28068
28113
 
28069
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/context/evidence.js
28114
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/context/evidence.js
28070
28115
  import { createHash as createHash4 } from "node:crypto";
28071
28116
  var CONTEXT_MAX_READ_BYTES = 262144;
28072
28117
  var CONTEXT_SOURCE_KINDS = ["message", "mail", "document", "meeting"];
@@ -28164,7 +28209,7 @@ var contextEvidenceRequest = /* @__PURE__ */ __name((input) => {
28164
28209
  return { source: source2, query, chat: chat2, senders, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal: input.signal };
28165
28210
  }, "contextEvidenceRequest");
28166
28211
 
28167
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/email-activity.js
28212
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/email-activity.js
28168
28213
  var MAIL_AGENDA_COLUMNS = { chat_kind: { type: "enum", sql: "'dialog'" } };
28169
28214
  var ACTIVITY = `
28170
28215
  SELECT t.external_id AS thread, t.subject, t.last_email_at, t.emails_count,
@@ -28239,9 +28284,18 @@ var emailMarks = /* @__PURE__ */ __name((database, accountId, externalIds) => {
28239
28284
  }
28240
28285
  return marks;
28241
28286
  }, "emailMarks");
28287
+ var writtenTo = /* @__PURE__ */ __name((database, addresses) => {
28288
+ if (addresses.length === 0)
28289
+ return /* @__PURE__ */ new Set();
28290
+ const rows = database.prepare(`SELECT DISTINCT lower(r.address) AS address FROM emails e JOIN email_recipients r ON r.email_id = e.id
28291
+ WHERE e.outgoing = 1 AND e.deleted_at IS NULL AND r.role IN ('to', 'cc')
28292
+ AND lower(r.address) IN (SELECT value FROM json_each(?))`).all(JSON.stringify(addresses.map((address) => address.toLowerCase())));
28293
+ return new Set(rows.map((row2) => String(row2.address)));
28294
+ }, "writtenTo");
28242
28295
  var MARKED = `
28243
28296
  SELECT e.id, e.external_id, t.external_id AS thread, coalesce(e.received_at, e.sent_at) AS at, e.created_at,
28244
- e.updated_at, coalesce(e.draft, 0) AS draft, json_extract(e.metadata, '$.partial') IS NOT NULL AS partial,
28297
+ e.updated_at, e.subject, e.from_address, coalesce(e.draft, 0) AS draft,
28298
+ coalesce(json_extract(e.headers, '$."list-id"'), json_extract(e.metadata, '$.listId')) IS NOT NULL AS listed, json_extract(e.metadata, '$.partial') IS NOT NULL AS partial,
28245
28299
  coalesce(json_extract(e.headers, '$."list-id"'), json_extract(e.metadata, '$.listId')) IS NOT NULL
28246
28300
  OR EXISTS (SELECT 1 FROM email_mailboxes m JOIN mailboxes b ON b.id = m.mailbox_id
28247
28301
  WHERE m.email_id = e.id AND b.kind = 'bulk') AS bulk,
@@ -28258,6 +28312,9 @@ var markedOf = /* @__PURE__ */ __name((row2) => ({
28258
28312
  storedAt: Number(row2.created_at),
28259
28313
  changedAt: Number(row2.updated_at),
28260
28314
  bulk: Boolean(row2.bulk),
28315
+ listed: Boolean(row2.listed),
28316
+ subject: row2.subject === null || row2.subject === void 0 ? null : String(row2.subject),
28317
+ from: row2.from_address === null || row2.from_address === void 0 ? null : String(row2.from_address),
28261
28318
  envelope: Boolean(row2.envelope),
28262
28319
  partial: Boolean(row2.partial),
28263
28320
  draft: Boolean(row2.draft),
@@ -28278,10 +28335,11 @@ var mailActivity = /* @__PURE__ */ __name((database) => ({
28278
28335
  newestEmailId: /* @__PURE__ */ __name(async (accountId) => Number(database.prepare("SELECT max(id) AS id FROM emails WHERE account_id = ?").get(accountId)?.id ?? 0), "newestEmailId"),
28279
28336
  statesLike: /* @__PURE__ */ __name(async (accountId, prefix) => database.prepare("SELECT key, value, updated_at FROM sync_cursors WHERE account_id = ? AND substr(key, 1, ?) = ?").all(accountId, prefix.length, prefix).map((row2) => ({ key: String(row2.key), value: String(row2.value), at: Number(row2.updated_at) })), "statesLike"),
28280
28337
  emailMarks: /* @__PURE__ */ __name(async (accountId, externalIds) => emailMarks(database, accountId, externalIds), "emailMarks"),
28338
+ writtenTo: /* @__PURE__ */ __name(async (addresses) => writtenTo(database, addresses), "writtenTo"),
28281
28339
  threadActivity: /* @__PURE__ */ __name(async (accountId, since, where) => threadActivity(database, accountId, since, where), "threadActivity")
28282
28340
  }), "mailActivity");
28283
28341
 
28284
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
28342
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
28285
28343
  var GREETING = new RegExp("^(hi|hello|hey|dear|greetings|good (morning|afternoon|evening)|\u043F\u0440\u0438\u0432\u0435\u0442|\u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439(\u0442\u0435)?|\u0434\u043E\u0431\u0440(\u044B\u0439|\u043E\u0435|\u043E\u0433\u043E) (\u0434\u0435\u043D\u044C|\u0432\u0435\u0447\u0435\u0440|\u0443\u0442\u0440\u043E|\u0443\u0442\u0440\u0430|\u0434\u043D\u044F)|hola|buen(os|as) (d\xEDas|dias|tardes|noches)|estimad[oa]s?|querid[oa]s?)(?![\\p{L}\\p{N}])([\\s,]+\\p{L}[\\p{L}.'\u2019-]*){0,3}\\s*[,!.:]?$", "iu");
28286
28344
  var SIGN_OFF = /^(best|best regards|best wishes|kind regards|warm regards|regards|thanks|thanks again|thanks a lot|thank you|many thanks|cheers|sincerely|yours|yours truly|yours sincerely|br|с уважением|спасибо|заранее спасибо|всего доброго|всего хорошего|un saludo|saludos|saludos cordiales|atentamente|gracias|muchas gracias)[\s,.!]*$/iu;
28287
28345
  var ATTRIBUTION = /(wrote|написал[аи]?|escribió|a écrit|schrieb)\s*:\s*$/iu;
@@ -28291,8 +28349,8 @@ var CONTENT = /^p\.?\s?s\b|\?|(\S+\s+){8}\S/iu;
28291
28349
  var unquoted = /* @__PURE__ */ __name((line) => line.replace(/^(\s*>)+\s?/, ""), "unquoted");
28292
28350
  var squash = /* @__PURE__ */ __name((text6) => text6.toLowerCase().replace(/\s+/g, " ").trim(), "squash");
28293
28351
  var flat = /* @__PURE__ */ __name((text6) => squash(text6.split("\n").map(unquoted).join("\n")), "flat");
28294
- var alreadyHeld = /* @__PURE__ */ __name((quote2, earlier) => {
28295
- const lines = quote2.map((line) => squash(unquoted(line))).filter((line) => line.length > 0);
28352
+ var alreadyHeld = /* @__PURE__ */ __name((quote3, earlier) => {
28353
+ const lines = quote3.map((line) => squash(unquoted(line))).filter((line) => line.length > 0);
28296
28354
  const total = lines.reduce((sum, line) => sum + line.length, 0);
28297
28355
  if (total === 0)
28298
28356
  return true;
@@ -28362,7 +28420,7 @@ var mailCore = /* @__PURE__ */ __name((body2, earlier) => {
28362
28420
  return withoutSignOff(withoutGreeting(kept)).join("\n").trim();
28363
28421
  }, "mailCore");
28364
28422
 
28365
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
28423
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
28366
28424
  var titleOf = /* @__PURE__ */ __name((subject2) => subject2?.replace(/^\s*((re|fwd?|aw|wg)\s*:\s*)+/i, "").trim() || null, "titleOf");
28367
28425
  var MAIL_PIECES = `(SELECT k.id, k.content_hash, k.chunkable_type AS type, k.chunkable_id AS owner, k.position,
28368
28426
  k.start_offset, k.end_offset, k.account_id, k.occurred_at, a.attachable_id AS email_id,
@@ -28472,7 +28530,7 @@ var drainEmailIndex = /* @__PURE__ */ __name((database, stemmerFor2) => {
28472
28530
  return emails3 + threads;
28473
28531
  }, "drainEmailIndex");
28474
28532
 
28475
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
28533
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
28476
28534
  var locate = /* @__PURE__ */ __name((database, accountId, emailId, where) => database.prepare(`INSERT OR REPLACE INTO email_locations (mailbox_id, uidvalidity, uid, email_id)
28477
28535
  SELECT id, ?, ?, ? FROM mailboxes WHERE account_id = ? AND external_id = ?`).run(where.uidvalidity, where.uid, emailId, accountId, where.folder), "locate");
28478
28536
  var folderEmails = /* @__PURE__ */ __name((database, accountId, folder, uidvalidity) => database.prepare(`SELECT l.uid, e.external_id, coalesce(e.received_at, e.sent_at) AS at, e.read, e.flagged,
@@ -28570,7 +28628,7 @@ var forgetLocations = /* @__PURE__ */ __name((database, accountId, folder, uidva
28570
28628
  var backfillSentAt = /* @__PURE__ */ __name((database, accountId, limit) => Number(database.prepare(`UPDATE emails SET sent_at = received_at WHERE id IN (
28571
28629
  SELECT id FROM emails WHERE account_id = ? AND sent_at IS NULL AND received_at IS NOT NULL LIMIT ?)`).run(accountId, limit).changes), "backfillSentAt");
28572
28630
 
28573
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
28631
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
28574
28632
  var recountEmailThread = /* @__PURE__ */ __name((database, threadId, now2) => database.prepare(`UPDATE email_threads SET
28575
28633
  emails_count = (SELECT count(*) FROM emails WHERE email_thread_id = ? AND deleted_at IS NULL),
28576
28634
  last_email_at = (SELECT max(coalesce(sent_at, received_at)) FROM emails
@@ -28620,7 +28678,67 @@ var markEmailsRestored = /* @__PURE__ */ __name((database, accountId, externalId
28620
28678
  return threads.length;
28621
28679
  }, "markEmailsRestored");
28622
28680
 
28623
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
28681
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-nearest.js
28682
+ var MAIL_PIECE_ROWS = `SELECT p.id, p.content_hash AS hash, p.type, p.owner, p.position, p.email_id AS email, v.vector
28683
+ FROM ${MAIL_PIECES} JOIN embeddings v ON v.model = ? AND v.content_hash = p.content_hash
28684
+ WHERE p.account_id = ?
28685
+ AND (? IS NULL OR p.thread_id IN (SELECT id FROM email_threads WHERE account_id = p.account_id AND external_id = ?))
28686
+ AND (? IS NULL OR p.occurred_at >= ?)`;
28687
+ var pieceKey = /* @__PURE__ */ __name((row2) => row2.type === "email_thread" ? `${row2.owner}:${row2.position}` : `email:${row2.email}`, "pieceKey");
28688
+ var filterParams = /* @__PURE__ */ __name((model, { accountId, threadExternalId, since }) => [
28689
+ model,
28690
+ accountId,
28691
+ threadExternalId ?? null,
28692
+ threadExternalId ?? null,
28693
+ since ?? null,
28694
+ since ?? null
28695
+ ], "filterParams");
28696
+ var byScore = /* @__PURE__ */ __name((best) => [...best.entries()].map(([key2, { score }]) => [key2, score]).sort(([, a], [, b]) => b - a), "byScore");
28697
+ var scannedMailPieces = /* @__PURE__ */ __name((database, model, query, filter) => {
28698
+ const page3 = database.prepare(`${MAIL_PIECE_ROWS} AND p.id > ? ORDER BY p.id LIMIT 500`);
28699
+ const best = /* @__PURE__ */ new Map();
28700
+ for (let after2 = 0; ; ) {
28701
+ const rows = page3.all(...filterParams(model, filter), after2);
28702
+ for (const row2 of rows) {
28703
+ const score = dot(query, row2.vector);
28704
+ const key2 = pieceKey(row2);
28705
+ if (score > (best.get(key2)?.score ?? Number.NEGATIVE_INFINITY))
28706
+ best.set(key2, { score });
28707
+ }
28708
+ if (rows.length < 500)
28709
+ break;
28710
+ after2 = Number(rows.at(-1)?.id);
28711
+ }
28712
+ return byScore(best);
28713
+ }, "scannedMailPieces");
28714
+ var indexedMailPieces = /* @__PURE__ */ __name((database, model, query, filter, depth) => {
28715
+ const candidates = database.prepare(`${MAIL_PIECE_ROWS} AND p.id IN (SELECT value FROM json_each(?)) ORDER BY p.id`);
28716
+ const merged = /* @__PURE__ */ new Map();
28717
+ for (const kind3 of ["email_thread", "attachment"]) {
28718
+ const found2 = searchIndex(database, model, { kind: kind3, account: filter.accountId, ...filter.since === void 0 ? {} : { since: filter.since } }, query, depth, (near2) => {
28719
+ const hashes = new Map(near2.map(({ id: id2, hash: hash2 }) => [id2, hash2]));
28720
+ const best = /* @__PURE__ */ new Map();
28721
+ for (const row2 of candidates.all(...filterParams(model, filter), JSON.stringify([...hashes.keys()]))) {
28722
+ if (hashes.get(Number(row2.id)) !== row2.hash)
28723
+ continue;
28724
+ const score = dot(query, row2.vector);
28725
+ const key2 = pieceKey(row2);
28726
+ if (score > (best.get(key2)?.score ?? Number.NEGATIVE_INFINITY))
28727
+ best.set(key2, { score, chunk: Number(row2.id) });
28728
+ }
28729
+ const results = byScore(best).slice(0, depth).map(([key2]) => [key2, best.get(key2)]);
28730
+ return { results, best: results.map(([, { chunk }]) => chunk) };
28731
+ });
28732
+ if (!found2)
28733
+ return void 0;
28734
+ for (const [key2, held] of found2)
28735
+ merged.set(key2, held);
28736
+ }
28737
+ return byScore(merged);
28738
+ }, "indexedMailPieces");
28739
+ var nearestMailPieces = /* @__PURE__ */ __name((database, model, query, filter, depth) => (filter.threadExternalId === void 0 ? indexedMailPieces(database, model, query, filter, depth) : void 0) ?? scannedMailPieces(database, model, query, filter), "nearestMailPieces");
28740
+
28741
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
28624
28742
  var sorted = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(sorted) : value !== null && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key2) => [key2, sorted(value[key2])])) : value, "sorted");
28625
28743
  var conditionsKey = /* @__PURE__ */ __name((conditions) => JSON.stringify(sorted(conditions)), "conditionsKey");
28626
28744
  var ruleOf = /* @__PURE__ */ __name((row2) => ({
@@ -28687,7 +28805,7 @@ var mailRulesOver = /* @__PURE__ */ __name((database) => ({
28687
28805
  }
28688
28806
  }), "mailRulesOver");
28689
28807
 
28690
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
28808
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
28691
28809
  var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates, reason, now2) => {
28692
28810
  database.prepare(`INSERT INTO link_reviews (linkable_type, linkable_id, entity_type, candidates, reason, status, created_at, updated_at)
28693
28811
  VALUES (?, ?, ?, ?, ?, 'open', ?, ?)
@@ -28695,7 +28813,7 @@ var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates,
28695
28813
  reason = excluded.reason, updated_at = excluded.updated_at WHERE link_reviews.status = 'open'`).run(linkable.type, linkable.id, entity, JSON.stringify([...candidates].sort((a, b) => a - b)), reason, now2, now2);
28696
28814
  }, "reviewLink");
28697
28815
 
28698
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
28816
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
28699
28817
  function checkMeetingCancelled(signal) {
28700
28818
  if (!signal?.aborted)
28701
28819
  return;
@@ -28706,7 +28824,7 @@ function checkMeetingCancelled(signal) {
28706
28824
  }
28707
28825
  __name(checkMeetingCancelled, "checkMeetingCancelled");
28708
28826
 
28709
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
28827
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
28710
28828
  var meetingOf = /* @__PURE__ */ __name((row2) => ({
28711
28829
  id: Number(row2.id),
28712
28830
  accountId: Number(row2.account_id),
@@ -28756,7 +28874,7 @@ var transcriptRowOf = /* @__PURE__ */ __name((row2) => ({
28756
28874
  createdAt: Number(row2.created_at)
28757
28875
  }), "transcriptRowOf");
28758
28876
 
28759
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
28877
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
28760
28878
  var MEETING_TEXT = ["external_id", "title", "description", "location", "join_url", "timezone", "metadata"];
28761
28879
  var TRANSCRIPT_TEXT = ["source", "format", "language", "content_hash", "metadata"];
28762
28880
  var ROW_TEXT = ["speaker_name", "text", "normalized_text", "metadata"];
@@ -28923,7 +29041,7 @@ var meetingReadsOver = /* @__PURE__ */ __name(({ database }) => ({
28923
29041
  }
28924
29042
  }), "meetingReadsOver");
28925
29043
 
28926
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
29044
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
28927
29045
  var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
28928
29046
  const clauses = ["m.account_id=?", "m.deleted_at IS NULL"];
28929
29047
  const params = [input.accountId];
@@ -28966,7 +29084,7 @@ var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
28966
29084
  return { clauses, params };
28967
29085
  }, "meetingSelectionSql");
28968
29086
 
28969
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
29087
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
28970
29088
  var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
28971
29089
  async meetingChatLines(input) {
28972
29090
  checkMeetingCancelled(input.signal);
@@ -28994,7 +29112,7 @@ var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
28994
29112
  }
28995
29113
  }), "meetingChatLinesOver");
28996
29114
 
28997
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
29115
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
28998
29116
  var MESSAGE_FIELDS = {
28999
29117
  pk: messages.id,
29000
29118
  nativeId: messages.externalId,
@@ -29165,7 +29283,7 @@ var chatActivity = /* @__PURE__ */ __name(({ database }, accountKey, since, wher
29165
29283
  storedAt: toIso(Number(database.prepare("SELECT max(created_at) AS at FROM messages WHERE account_id = ?").get(accountKey)?.at) || null)
29166
29284
  }), "chatActivity");
29167
29285
 
29168
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
29286
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
29169
29287
  var HIT_FIELDS = {
29170
29288
  ...MESSAGE_FIELDS,
29171
29289
  chatTitle: sql`${chats.title}`.as("chat_title"),
@@ -29264,7 +29382,7 @@ var directReplies = /* @__PURE__ */ __name((context, parents, limit) => {
29264
29382
  };
29265
29383
  }, "directReplies");
29266
29384
 
29267
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
29385
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
29268
29386
  var identityRow = /* @__PURE__ */ __name(({ orm }, { provider, id: id2 }) => orm.select({ pk: identities.id, personPk: identityLinks.personId }).from(identities).innerJoin(identityLinks, eq(identityLinks.identityId, identities.id)).where(and(eq(identities.provider, provider), eq(identities.externalId, id2))).get(), "identityRow");
29269
29387
  var required = /* @__PURE__ */ __name((context, ref3) => {
29270
29388
  const found2 = identityRow(context, ref3);
@@ -29395,7 +29513,7 @@ var mentioning = /* @__PURE__ */ __name((context, accountKey, { id: id2, usernam
29395
29513
  }, "mentioning");
29396
29514
  var escaped = /* @__PURE__ */ __name((text6) => text6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "escaped");
29397
29515
 
29398
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
29516
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
29399
29517
  var missing2 = /* @__PURE__ */ __name(() => {
29400
29518
  throw new CliError("not_found", "Meeting, participant or selected target not found");
29401
29519
  }, "missing");
@@ -29517,7 +29635,7 @@ function meetingContextLinksOver(context) {
29517
29635
  }
29518
29636
  __name(meetingContextLinksOver, "meetingContextLinksOver");
29519
29637
 
29520
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
29638
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
29521
29639
  var INDEX_CODES = { meeting_transcript_row: 1, meeting_chat_message: 2, meeting_summary: 3 };
29522
29640
  var meetingRowid = /* @__PURE__ */ __name((type, id2) => id2 * 4 + INDEX_CODES[type], "meetingRowid");
29523
29641
  var summaryOf = /* @__PURE__ */ __name((row2) => ({
@@ -29546,7 +29664,7 @@ var indexedText = /* @__PURE__ */ __name((database, type, id2) => {
29546
29664
  return row2 ? summaryText(summaryOf(row2)) : null;
29547
29665
  }, "indexedText");
29548
29666
 
29549
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
29667
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
29550
29668
  var summaryBytes = ["title", "overview", "sections", "next_steps", "content"].map((key2) => `coalesce(length(CAST(s.${key2} AS BLOB)),0)`).join("+");
29551
29669
  var meetingCurrentIndexRows = `
29552
29670
  SELECT 'meeting_transcript_row' AS indexable_type,r.id,r.id*4+1 AS rid,1 AS live,coalesce(length(CAST(r.text AS BLOB)),0) AS bytes FROM meeting_transcript_rows r JOIN meeting_transcripts t ON t.id=r.meeting_transcript_id JOIN meetings m ON m.id=t.meeting_id WHERE m.account_id=? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL
@@ -29577,7 +29695,7 @@ var invalidateMeetingStems = /* @__PURE__ */ __name((database, type, id2) => {
29577
29695
  }, "invalidateMeetingStems");
29578
29696
  var meetingStemmableText = /* @__PURE__ */ __name((text6) => text6.replace(/[\p{L}\p{N}\p{M}\p{Co}]+/gu, (token) => token.length <= 1024 ? token : ""), "meetingStemmableText");
29579
29697
 
29580
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
29698
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
29581
29699
  function meetingHitIndexOver({ database, now: now2 }) {
29582
29700
  return {
29583
29701
  async indexSearch(original) {
@@ -29645,10 +29763,10 @@ function meetingHitIndexOver({ database, now: now2 }) {
29645
29763
  }
29646
29764
  __name(meetingHitIndexOver, "meetingHitIndexOver");
29647
29765
 
29648
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
29766
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
29649
29767
  import { createHash as createHash5 } from "node:crypto";
29650
29768
 
29651
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/trigrams.js
29769
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/trigrams.js
29652
29770
  var trigrams = /* @__PURE__ */ __name((term) => {
29653
29771
  const padded = ` ${term} `;
29654
29772
  const pieces = /* @__PURE__ */ new Set();
@@ -29657,7 +29775,7 @@ var trigrams = /* @__PURE__ */ __name((term) => {
29657
29775
  return [...pieces];
29658
29776
  }, "trigrams");
29659
29777
 
29660
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/correct.js
29778
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/correct.js
29661
29779
  var SHORTEST_CORRECTION = 3;
29662
29780
  var maxEdits = /* @__PURE__ */ __name((word2) => word2.length <= 4 ? 1 : 2, "maxEdits");
29663
29781
  var editDistance = /* @__PURE__ */ __name((a, b, max) => {
@@ -29704,7 +29822,7 @@ var correctWords = /* @__PURE__ */ __name(async (vocabulary, words3) => {
29704
29822
  return corrections;
29705
29823
  }, "correctWords");
29706
29824
 
29707
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/garbled.js
29825
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/garbled.js
29708
29826
  var SHORTEST_GARBLED = 4;
29709
29827
  var MOST_WIDENED = 64;
29710
29828
  var plain = /* @__PURE__ */ __name((word2) => word2.replaceAll("\u044D", "\u0435"), "plain");
@@ -29796,7 +29914,7 @@ var widenWords = /* @__PURE__ */ __name((probes, vocabulary, stem, known2) => {
29796
29914
  return found2.map((words3) => words3.sort((a, b) => a.distance - b.distance || b.docs - a.docs || a.term.localeCompare(b.term)).slice(0, MOST_WIDENED).map((word2) => word2.term));
29797
29915
  }, "widenWords");
29798
29916
 
29799
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
29917
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
29800
29918
  import { readFileSync } from "node:fs";
29801
29919
  var loaded;
29802
29920
  var dictionary = /* @__PURE__ */ __name(() => {
@@ -29855,7 +29973,7 @@ var knownRussianWord = /* @__PURE__ */ __name((word2) => {
29855
29973
  return false;
29856
29974
  }, "knownRussianWord");
29857
29975
 
29858
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
29976
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
29859
29977
  var WORD2 = /[\p{L}\p{N}\p{M}]+/gu;
29860
29978
  var MOST_WORDS = 128;
29861
29979
  var quote = /* @__PURE__ */ __name((word2) => `"${word2.replaceAll('"', '""')}"`, "quote");
@@ -30082,7 +30200,7 @@ var matchMeetingText = /* @__PURE__ */ __name((tree, text6, stemmer) => {
30082
30200
  return check3(tree);
30083
30201
  }, "matchMeetingText");
30084
30202
 
30085
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
30203
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
30086
30204
  var fail3 = /* @__PURE__ */ __name((message2) => {
30087
30205
  throw new CliError("validation_error", message2);
30088
30206
  }, "fail");
@@ -30264,7 +30382,7 @@ function meetingHitSearchOver({ database }) {
30264
30382
  }
30265
30383
  __name(meetingHitSearchOver, "meetingHitSearchOver");
30266
30384
 
30267
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-languages.js
30385
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-languages.js
30268
30386
  var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
30269
30387
  async fillTranscriptLanguages({ accountId, apply, now: now2 }) {
30270
30388
  positiveReadInteger(accountId, "accountId");
@@ -30296,7 +30414,7 @@ var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
30296
30414
  }
30297
30415
  }), "meetingLanguagesOver");
30298
30416
 
30299
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
30417
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
30300
30418
  import { createHash as createHash6 } from "node:crypto";
30301
30419
  var cursorOf2 = /* @__PURE__ */ __name((value, key2) => {
30302
30420
  if (value === void 0)
@@ -30386,7 +30504,7 @@ var meetingParticipantSearchOver = /* @__PURE__ */ __name((context) => ({
30386
30504
  }
30387
30505
  }), "meetingParticipantSearchOver");
30388
30506
 
30389
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
30507
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
30390
30508
  var preparationQueries = {
30391
30509
  participants: {
30392
30510
  fields: "p.id, p.identity_id, p.display_name, l.person_id",
@@ -30436,7 +30554,7 @@ var preparationQueries = {
30436
30554
  }
30437
30555
  };
30438
30556
 
30439
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
30557
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
30440
30558
  var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
30441
30559
  async preparationContext(original) {
30442
30560
  const input = validateMeetingPreparationContext(original);
@@ -30477,7 +30595,7 @@ var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
30477
30595
  }
30478
30596
  }), "meetingPreparationContextOver");
30479
30597
 
30480
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
30598
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
30481
30599
  var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
30482
30600
  SELECT m.id FROM meetings m JOIN meeting_series s ON s.id=m.meeting_series_id
30483
30601
  WHERE m.id IN (${Array.from({ length: anchors }, () => "?").join(",")}) AND m.account_id=? AND s.account_id=?
@@ -30491,7 +30609,7 @@ var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
30491
30609
  JOIN main.projects p ON p.id=l.to_id WHERE p.account_id IS NULL AND p.deleted_at IS NULL
30492
30610
  )`, "preparationSubjects");
30493
30611
 
30494
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
30612
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
30495
30613
  var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => ({
30496
30614
  async preparationKnowledge(original) {
30497
30615
  const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
@@ -30536,7 +30654,7 @@ var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => (
30536
30654
  }
30537
30655
  }), "meetingPreparationKnowledgeOver");
30538
30656
 
30539
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
30657
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
30540
30658
  var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
30541
30659
  async preparationNotes(original) {
30542
30660
  const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
@@ -30589,7 +30707,7 @@ var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
30589
30707
  }
30590
30708
  }), "meetingPreparationNotesOver");
30591
30709
 
30592
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
30710
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
30593
30711
  var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
30594
30712
  async relatedHistory(original) {
30595
30713
  const input = validateMeetingRelatedHistory(original);
@@ -30660,7 +30778,7 @@ var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
30660
30778
  }
30661
30779
  }), "meetingRelatedHistoryOver");
30662
30780
 
30663
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
30781
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
30664
30782
  var number2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "number");
30665
30783
  var text2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : String(value), "text");
30666
30784
  var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
@@ -30741,7 +30859,7 @@ var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
30741
30859
  }
30742
30860
  }), "meetingReviewOver");
30743
30861
 
30744
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
30862
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
30745
30863
  var bytes2 = "length(CAST(external_id AS BLOB)) + coalesce(length(CAST(title AS BLOB)), 0)";
30746
30864
  var ensureBytes2 = /* @__PURE__ */ __name((size2, budget) => {
30747
30865
  if (!Number.isSafeInteger(size2) || size2 < 0 || size2 > budget)
@@ -30795,7 +30913,7 @@ var meetingSeriesHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
30795
30913
  }
30796
30914
  }), "meetingSeriesHistoryOver");
30797
30915
 
30798
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
30916
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
30799
30917
  var MOST_ROWS = 5e5;
30800
30918
  var meetingCountsSql = /* @__PURE__ */ __name((where) => `SELECT m.started_at, coalesce(m.duration_ms, m.ended_at - m.started_at) AS duration_ms,
30801
30919
  EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = m.id AND t.deleted_at IS NULL
@@ -30864,7 +30982,7 @@ var meetingStatsOver = /* @__PURE__ */ __name(({ database }) => ({
30864
30982
  }
30865
30983
  }), "meetingStatsOver");
30866
30984
 
30867
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
30985
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
30868
30986
  var CURSOR_KEY = "meetings";
30869
30987
  var seriesOf2 = /* @__PURE__ */ __name((row2) => ({
30870
30988
  id: Number(row2.id),
@@ -31433,7 +31551,7 @@ var meetingStoreOver = /* @__PURE__ */ __name((context) => {
31433
31551
  };
31434
31552
  }, "meetingStoreOver");
31435
31553
 
31436
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
31554
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
31437
31555
  var syncStateOf = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
31438
31556
  const row2 = orm.select({ value: syncCursors.value, at: syncCursors.updatedAt }).from(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).get();
31439
31557
  return row2 ? { value: row2.value, at: toIso(row2.at) } : void 0;
@@ -31459,7 +31577,7 @@ var release = /* @__PURE__ */ __name(({ orm }, chatKey, anchor, holder) => {
31459
31577
  orm.delete(fetchLeases).where(and(eq(fetchLeases.chatId, chatKey), eq(fetchLeases.anchor, anchor), eq(fetchLeases.holder, holder))).run();
31460
31578
  }, "release");
31461
31579
 
31462
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/thread-columns.js
31580
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/thread-columns.js
31463
31581
  var THREAD_COLUMNS = {
31464
31582
  subject: {
31465
31583
  where: /* @__PURE__ */ __name(({ value }) => ({
@@ -31476,7 +31594,7 @@ var threadRows = /* @__PURE__ */ __name((database, filter) => {
31476
31594
  AND (${filter.where?.sql ?? "1"}) ORDER BY coalesce(last_email_at, 0) DESC, id DESC LIMIT ? OFFSET ?`).all(filter.accountId ?? null, filter.accountId ?? null, filter.includeDeleted ? 1 : 0, ...filter.where?.params ?? [], limit, offset);
31477
31595
  }, "threadRows");
31478
31596
 
31479
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
31597
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
31480
31598
  var threadConversation = /* @__PURE__ */ __name((place, builtAt) => ({
31481
31599
  id: `email:${place.emailId}`,
31482
31600
  chatId: place.threadExternalId,
@@ -31964,28 +32082,10 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm, now: now2 }, stemme
31964
32082
  },
31965
32083
  async nearest(model, query, { accountId, limit, threadExternalId, since }) {
31966
32084
  drainEmailIndex(database, stemmerFor2);
31967
- const page3 = database.prepare(`SELECT p.id, p.type, p.owner, p.position, p.email_id AS email, v.vector FROM ${MAIL_PIECES}
31968
- JOIN embeddings v ON v.model = ? AND v.content_hash = p.content_hash
31969
- WHERE p.id > ? AND p.account_id = ?
31970
- AND (? IS NULL OR p.thread_id IN (SELECT id FROM email_threads WHERE account_id = p.account_id AND external_id = ?))
31971
- AND (? IS NULL OR p.occurred_at >= ?)
31972
- ORDER BY p.id LIMIT 500`);
31973
- const best = /* @__PURE__ */ new Map();
31974
- for (let after2 = 0; ; ) {
31975
- const rows = page3.all(model, after2, accountId, threadExternalId ?? null, threadExternalId ?? null, since ?? null, since ?? null);
31976
- for (const row2 of rows) {
31977
- const score = dot(query, row2.vector);
31978
- const key2 = row2.type === "email_thread" ? `${row2.owner}:${row2.position}` : `email:${row2.email}`;
31979
- if (score > (best.get(key2) ?? Number.NEGATIVE_INFINITY))
31980
- best.set(key2, score);
31981
- }
31982
- if (rows.length < 500)
31983
- break;
31984
- after2 = Number(rows.at(-1)?.id);
31985
- }
32085
+ const best = nearestMailPieces(database, model, query, { accountId, threadExternalId, since }, limit * 2);
31986
32086
  const threads = /* @__PURE__ */ new Map();
31987
32087
  const emails3 = /* @__PURE__ */ new Map();
31988
- for (const [key2, score] of [...best.entries()].sort(([, a], [, b]) => b - a)) {
32088
+ for (const [key2, score] of best) {
31989
32089
  if (emails3.size >= limit)
31990
32090
  break;
31991
32091
  const [owner, position2] = key2.split(":");
@@ -32032,7 +32132,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm, now: now2 }, stemme
32032
32132
  }
32033
32133
  }), "mailStoreOver");
32034
32134
 
32035
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/search/dictionary.js
32135
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/search/dictionary.js
32036
32136
  import { readFileSync as readFileSync2 } from "node:fs";
32037
32137
  var DICTIONARIES = Object.fromEntries(LANGUAGES.map(({ name, dictionary: dictionary3 }) => [name, dictionary3]));
32038
32138
  var folded4 = /* @__PURE__ */ __name((word2) => /^[а-яё'-]*$/.test(word2) ? word2.replaceAll("\u0451", "\u0435").replaceAll("\u0439", "\u0438") : fold(word2), "folded");
@@ -32122,7 +32222,7 @@ var knownWord = /* @__PURE__ */ __name((languages) => {
32122
32222
  }, "knownWord");
32123
32223
  var dictionaryLanguages = /* @__PURE__ */ __name((stemmers) => [stemmers.cyrillic, ...stemmers.latin.split(",")].filter((name) => Object.hasOwn(DICTIONARIES, name)), "dictionaryLanguages");
32124
32224
 
32125
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
32225
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
32126
32226
  var predicates = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? [node] : node.clauses.flatMap(({ node: node2 }) => predicates(node2)), "predicates");
32127
32227
  var readsTranscripts = /* @__PURE__ */ __name((node) => (node.operator === "term" || node.operator === "phrase") && /[\p{L}\p{N}]/u.test(normalize(node.value)) && (node.field === "transcript" || node.implicit === true && (node.field === "text" || node.field === "exact")), "readsTranscripts");
32128
32228
  var LATIN_NUMBERS = new Set(`zero one two three four five six seven eight nine ten eleven twelve twenty thirty forty fifty sixty seventy
@@ -32208,7 +32308,7 @@ var spokenTranscripts = /* @__PURE__ */ __name((database, item, speaking, keys)
32208
32308
  return found2;
32209
32309
  }, "spokenTranscripts");
32210
32310
 
32211
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
32311
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
32212
32312
  var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, found2, pks) => {
32213
32313
  const placeLeaves = leaves.filter(({ node }) => (node.operator === "term" || node.operator === "phrase") && (node.implicit || node.field === "content" || node.field === "transcript"));
32214
32314
  if (!placeLeaves.length || !pks.length || found2.length !== pks.length)
@@ -32255,7 +32355,7 @@ var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, f
32255
32355
  });
32256
32356
  }, "placeHits");
32257
32357
 
32258
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-groups.js
32358
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-groups.js
32259
32359
  var GROUPS = {
32260
32360
  chat: {
32261
32361
  key: "m.chat_id",
@@ -32277,7 +32377,7 @@ var GROUPS = {
32277
32377
  }
32278
32378
  };
32279
32379
 
32280
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
32380
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
32281
32381
  var MESSAGES2 = {
32282
32382
  rows: "messages",
32283
32383
  threads: "chats",
@@ -32760,7 +32860,7 @@ var runCompiled = /* @__PURE__ */ __name(async (context, execution, by) => {
32760
32860
  };
32761
32861
  }, "runCompiled");
32762
32862
 
32763
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
32863
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
32764
32864
  function invalidMetadata() {
32765
32865
  throw new CliError("validation_error", "stored counter metadata is malformed \u2014 check the store before refreshing");
32766
32866
  }
@@ -32769,7 +32869,7 @@ var counterStates = /* @__PURE__ */ __name(({ database }, messagePk, now2, maxAg
32769
32869
  const row2 = database.prepare("SELECT reactions,metadata FROM messages WHERE id=? AND deleted_at IS NULL").get(messagePk);
32770
32870
  if (!row2)
32771
32871
  return [];
32772
- const parse = /* @__PURE__ */ __name((raw) => {
32872
+ const parse2 = /* @__PURE__ */ __name((raw) => {
32773
32873
  try {
32774
32874
  const value = JSON.parse(String(raw ?? "{}"));
32775
32875
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -32777,7 +32877,7 @@ var counterStates = /* @__PURE__ */ __name(({ database }, messagePk, now2, maxAg
32777
32877
  return {};
32778
32878
  }
32779
32879
  }, "parse");
32780
- const metadata3 = parse(row2.metadata), reactions = parse(row2.reactions);
32880
+ const metadata3 = parse2(row2.metadata), reactions = parse2(row2.reactions);
32781
32881
  const records2 = database.prepare("SELECT counter,value,created_at,source FROM message_counter_observations WHERE message_id=?").all(messagePk);
32782
32882
  return COUNTER_FIELDS.map((counter) => {
32783
32883
  const raw = counter === "reactions" ? reactions.total : metadata3[counter];
@@ -32862,7 +32962,7 @@ var counterTargets = /* @__PURE__ */ __name((context, execution, options) => wit
32862
32962
  };
32863
32963
  }), "counterTargets");
32864
32964
 
32865
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
32965
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
32866
32966
  var NOT_FILE_LIST = [...NOT_FILES].map((kind3) => `'${kind3}'`).join(",");
32867
32967
  var fileAttachments = /* @__PURE__ */ __name(({ database }, accountKey, { chatKey, messageId, beforePk, limit }) => database.prepare(`SELECT att.id AS pk, c.external_id AS chat_id, m.external_id AS message_id, att.position, att.kind, att.name, att.mime,
32868
32968
  att.size, att.local_path, att.extraction AS origin, att.size AS read_bytes, att.extraction_error AS error, att.content_sha256, att.extractor
@@ -32981,7 +33081,7 @@ var attachmentViews = /* @__PURE__ */ __name(({ database }, accountKey, { chatKe
32981
33081
  }));
32982
33082
  }, "attachmentViews");
32983
33083
 
32984
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
33084
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
32985
33085
  var transcript = /* @__PURE__ */ __name(({ orm }, chatKey, messageId) => orm.select({ text: messageTranscripts.text, source: messageTranscripts.source }).from(messageTranscripts).where(and(eq(messageTranscripts.chatId, chatKey), eq(messageTranscripts.messageExternalId, messageId))).get(), "transcript");
32986
33086
  var keepTranscript = /* @__PURE__ */ __name((context, chatKey, messageId, text6, source2) => {
32987
33087
  const { orm, database, now: now2 } = context;
@@ -33019,7 +33119,7 @@ var intoVoiceAttachment = /* @__PURE__ */ __name((context, messagePk) => {
33019
33119
  keepText(context, Number(row2.id), { text: String(row2.text), origin: "extracted", extractor: `speech:${row2.source}` });
33020
33120
  }, "intoVoiceAttachment");
33021
33121
 
33022
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
33122
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
33023
33123
  var FIELDS = [
33024
33124
  "threadExternalId",
33025
33125
  "senderIdentityId",
@@ -33336,7 +33436,7 @@ var writeDerivedReactions = /* @__PURE__ */ __name((context, chatKey, messageId)
33336
33436
  reactionStatementsOf(context.database).total.run(JSON.stringify(derived), chatKey, messageId);
33337
33437
  }, "writeDerivedReactions");
33338
33438
 
33339
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/keys.js
33439
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/keys.js
33340
33440
  var keysOver = /* @__PURE__ */ __name((context) => {
33341
33441
  const findAccountPk2 = /* @__PURE__ */ __name((key2) => findAccountPk(context, key2), "findAccountPk");
33342
33442
  const findChatPk2 = /* @__PURE__ */ __name((accountKey, chatId) => findChatPk(context, accountKey, chatId), "findChatPk");
@@ -33357,7 +33457,7 @@ var keysOver = /* @__PURE__ */ __name((context) => {
33357
33457
  };
33358
33458
  }, "keysOver");
33359
33459
 
33360
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
33460
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
33361
33461
  var accountGroupsOf = /* @__PURE__ */ __name((database) => {
33362
33462
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(ACCOUNT_GROUPS);
33363
33463
  if (!row2)
@@ -33392,7 +33492,7 @@ var saveProfile = /* @__PURE__ */ __name((database, app, profile, key2, now2) =>
33392
33492
  database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(PROFILES, JSON.stringify(profiles), now2);
33393
33493
  }, "saveProfile");
33394
33494
 
33395
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
33495
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
33396
33496
  var BOT_KINDS = ["agent", "rule", "script", "integration"];
33397
33497
  var ownerPerson = /* @__PURE__ */ __name((database) => {
33398
33498
  const found2 = database.prepare("SELECT id FROM persons WHERE owner = 1 ORDER BY id LIMIT 1").get();
@@ -33449,7 +33549,7 @@ var proposedBySql = /* @__PURE__ */ __name((type, id2, by) => {
33449
33549
  return { sql: bot("pb.name = ?"), params: [by.bot] };
33450
33550
  }, "proposedBySql");
33451
33551
 
33452
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
33552
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
33453
33553
  var linkOwnIdentities = /* @__PURE__ */ __name((context) => {
33454
33554
  const owner = ownerPerson(context.database).id;
33455
33555
  const strays = context.database.prepare("SELECT DISTINCT l.person_id AS person FROM identity_links l JOIN identities i ON i.id = l.identity_id JOIN accounts a ON a.provider = i.provider AND a.external_id = i.external_id WHERE l.person_id <> ?").all(owner);
@@ -33470,7 +33570,7 @@ var linkToOwner = /* @__PURE__ */ __name((context, ref3) => {
33470
33570
  return personOf(context, ref3);
33471
33571
  }, "linkToOwner");
33472
33572
 
33473
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
33573
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
33474
33574
  var PROVIDERS_SETTING = "providers";
33475
33575
  var storedProvidersOf = /* @__PURE__ */ __name((database) => {
33476
33576
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(PROVIDERS_SETTING);
@@ -33505,7 +33605,7 @@ var registerProvider = /* @__PURE__ */ __name((database, value, now2) => {
33505
33605
  });
33506
33606
  }, "registerProvider");
33507
33607
 
33508
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
33608
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
33509
33609
  var DAY3 = 864e5;
33510
33610
  var RECENTLY_CLOSED_MS = 14 * DAY3;
33511
33611
  var TEXT_LIMIT = 20;
@@ -33704,7 +33804,7 @@ var taskSimilarityOver = /* @__PURE__ */ __name((context) => {
33704
33804
  };
33705
33805
  }, "taskSimilarityOver");
33706
33806
 
33707
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
33807
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
33708
33808
  var SETTING3 = "taskCategories";
33709
33809
  var savedTaskCategories = /* @__PURE__ */ __name((database) => {
33710
33810
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING3);
@@ -33723,7 +33823,7 @@ var saveTaskCategories = /* @__PURE__ */ __name((database, categories, now2) =>
33723
33823
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(SETTING3, JSON.stringify(categories), now2);
33724
33824
  }, "saveTaskCategories");
33725
33825
 
33726
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
33826
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
33727
33827
  var DEFAULT_AGENT_CLOSE = { allowed: true, min: 0.8 };
33728
33828
  var ALLOWED = "taskAgentClose";
33729
33829
  var MIN = "taskAgentCloseMin";
@@ -33779,10 +33879,10 @@ var SUGGESTION_COLUMNS = [
33779
33879
  ];
33780
33880
  var CLEAR_SUGGESTION = SUGGESTION_COLUMNS.map((column2) => `${column2} = NULL`).join(", ");
33781
33881
 
33782
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/mail-findings.js
33882
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/mail-findings.js
33783
33883
  var MAIL_FINDINGS_KIND = "mail_findings";
33784
33884
 
33785
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/decisions.js
33885
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/decisions.js
33786
33886
  var TASK_CLOSE_KIND = "task_close";
33787
33887
  var DEFAULT_DECISION_POLICY = { agentDecisions: false, ruleProposalsOwnerOnly: true };
33788
33888
  var isOwnerOnlyKind = /* @__PURE__ */ __name((kind3) => kind3 === MAIL_FINDINGS_KIND || kind3 === MEETING_FINDINGS_KIND || kind3 === TASK_CLOSE_KIND, "isOwnerOnlyKind");
@@ -33830,10 +33930,10 @@ var assertMayDecide = /* @__PURE__ */ __name((row2, by, policy = DEFAULT_DECISIO
33830
33930
  }, "assertMayDecide");
33831
33931
  var deciderAuthor = /* @__PURE__ */ __name((by) => by === "owner" ? "owner" : { bot: by.bot, ...by.model === void 0 ? {} : { model: by.model } }, "deciderAuthor");
33832
33932
 
33833
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/ref-summaries.js
33933
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/ref-summaries.js
33834
33934
  var oneLine = /* @__PURE__ */ __name((text6) => singleLine(text6.replace(/\s+/g, " ").trim()), "oneLine");
33835
33935
 
33836
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/ref-summaries.js
33936
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/ref-summaries.js
33837
33937
  var EXCERPT_CHARS = 280;
33838
33938
  var TITLE_CHARS = 120;
33839
33939
  var MEMORY_TITLE_CHARS = 80;
@@ -34206,7 +34306,7 @@ var refReadsOf = /* @__PURE__ */ __name((database, texts2, { excerpt = false } =
34206
34306
  var summaryOf2 = /* @__PURE__ */ __name(({ sender, excerpt, ...summary }, withExcerpt) => withExcerpt ? { ...summary, excerpt } : summary, "summaryOf");
34207
34307
  var refSummariesOf = /* @__PURE__ */ __name((database, texts2, options = {}) => new Map([...refReadsOf(database, texts2, options)].map(([text6, read2]) => [text6, summaryOf2(read2, options.excerpt === true)])), "refSummariesOf");
34208
34308
 
34209
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
34309
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
34210
34310
  var sourceOf3 = /* @__PURE__ */ __name((read2, ref3) => ({
34211
34311
  ref: ref3,
34212
34312
  kind: read2.kind,
@@ -34242,7 +34342,7 @@ var evidenceSourcesOf = /* @__PURE__ */ __name((database, from2) => {
34242
34342
  });
34243
34343
  }, "evidenceSourcesOf");
34244
34344
 
34245
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/attachments/limits.js
34345
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/attachments/limits.js
34246
34346
  var MAX_FILE_BYTES = 50 * 1024 * 1024;
34247
34347
  var MAX_TEXT_CHARS = 2e6;
34248
34348
  var ATTACHMENT_LIMIT_ENV = [
@@ -34268,7 +34368,7 @@ var pdfPreviewLimits = /* @__PURE__ */ __name((env = process.env) => {
34268
34368
  return { pixels, bytes: positive(env, "MESSAGING_PDF_PREVIEW_MAX_MIB", 8 * 1024 * 1024, 1024 * 1024) };
34269
34369
  }, "pdfPreviewLimits");
34270
34370
 
34271
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/ulid.js
34371
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/ulid.js
34272
34372
  import { randomBytes } from "node:crypto";
34273
34373
  var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
34274
34374
  var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
@@ -34281,7 +34381,7 @@ var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
34281
34381
  return time3 + random;
34282
34382
  }, "ulid");
34283
34383
 
34284
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
34384
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
34285
34385
  var FOLDED_FIELDS = ["title", "site", "language", "author"];
34286
34386
  var encodeDocumentMetadata = /* @__PURE__ */ __name((meta, sections) => {
34287
34387
  if (!meta && !sections?.length)
@@ -34302,7 +34402,7 @@ var languageOf = /* @__PURE__ */ __name((meta) => {
34302
34402
  return typeof language === "string" && language !== "" ? language : null;
34303
34403
  }, "languageOf");
34304
34404
 
34305
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
34405
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
34306
34406
  var isObject = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isObject");
34307
34407
  var objectOf2 = /* @__PURE__ */ __name((value) => {
34308
34408
  if (isObject(value))
@@ -34545,7 +34645,7 @@ var filesStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
34545
34645
  };
34546
34646
  }, "filesStoreOver");
34547
34647
 
34548
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
34648
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
34549
34649
  var IMPORTED_DOCUMENT_QUERY = defineQuery({
34550
34650
  entity: "document",
34551
34651
  backend: "sql",
@@ -34591,7 +34691,7 @@ var importedDocumentWhere = /* @__PURE__ */ __name((database, query) => {
34591
34691
  return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns);
34592
34692
  }, "importedDocumentWhere");
34593
34693
 
34594
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
34694
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
34595
34695
  var NOTE_FORMATS = ["obsidian", "markdown"];
34596
34696
  var iso2 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
34597
34697
  var optionalIso = /* @__PURE__ */ __name((value) => value == null ? null : iso2(value), "optionalIso");
@@ -35117,7 +35217,7 @@ var notesStoreOver = /* @__PURE__ */ __name((context) => {
35117
35217
  };
35118
35218
  }, "notesStoreOver");
35119
35219
 
35120
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
35220
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
35121
35221
  var NAMED = "SELECT m.*, b.name AS author_name, b.kind AS author_kind FROM memories m LEFT JOIN bots b ON m.author_type = 'bot' AND b.id = m.author_id";
35122
35222
  var iso3 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
35123
35223
  var oneOf2 = /* @__PURE__ */ __name((value, allowed, what) => {
@@ -35339,7 +35439,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
35339
35439
  };
35340
35440
  }, "memoriesStoreOver");
35341
35441
 
35342
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
35442
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
35343
35443
  var DEFAULT_FIRST_PASS_PER_CHAT = 0;
35344
35444
  var KEY = "taskFirstPassPerChat";
35345
35445
  var firstPassPerChatOf = /* @__PURE__ */ __name((value, setting = "task_first_pass_per_chat") => {
@@ -35359,7 +35459,7 @@ var saveFirstPassPerChat = /* @__PURE__ */ __name((database, value, now2) => {
35359
35459
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(KEY, String(value), now2);
35360
35460
  }, "saveFirstPassPerChat");
35361
35461
 
35362
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/external-links.js
35462
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/external-links.js
35363
35463
  var EXTERNAL_SERVICE = /^[a-z][a-z0-9-]{0,31}$/;
35364
35464
  var EXTERNAL_ID_CHARS = 200;
35365
35465
  var SOURCE_URL_CHARS = 2e3;
@@ -35386,7 +35486,8 @@ var sourceUrlOf = /* @__PURE__ */ __name((value, reason = "task.source-url") =>
35386
35486
  return text6;
35387
35487
  }, "sourceUrlOf");
35388
35488
 
35389
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-board.js
35489
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-board.js
35490
+ var TASK_SORTS = ["priority", "due", "created", "updated", "key", "state"];
35390
35491
  var field = /* @__PURE__ */ __name((name, type, example, more = {}) => ({
35391
35492
  name,
35392
35493
  type,
@@ -35608,7 +35709,7 @@ var withoutField = /* @__PURE__ */ __name((query, name) => {
35608
35709
  return root === void 0 ? void 0 : { ...query, root };
35609
35710
  }, "withoutField");
35610
35711
 
35611
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-comments.js
35712
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-comments.js
35612
35713
  var authorNamed = /* @__PURE__ */ __name((database, row2) => {
35613
35714
  if (row2.author_type == null)
35614
35715
  return null;
@@ -35636,7 +35737,7 @@ var addComment = /* @__PURE__ */ __name((context, task, body2, by) => {
35636
35737
  return commentsOf(database, task).find((one2) => one2.ref === `note:${made}`);
35637
35738
  }, "addComment");
35638
35739
 
35639
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
35740
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
35640
35741
  var TASK_RELATION_KINDS = [
35641
35742
  "blocked-by",
35642
35743
  "follow-up-of",
@@ -35766,8 +35867,33 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
35766
35867
  };
35767
35868
  }, "taskRelationsStoreOver");
35768
35869
 
35769
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
35870
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
35770
35871
  var TASK_ROLES = ["assignee", "reviewer", "watcher"];
35872
+ var TASK_EVENT_KINDS = [
35873
+ "created",
35874
+ "title",
35875
+ "description",
35876
+ "status",
35877
+ "assigned",
35878
+ "unassigned",
35879
+ "due",
35880
+ "priority",
35881
+ "moved",
35882
+ "linked",
35883
+ "unlinked",
35884
+ "category",
35885
+ "close-suggestion",
35886
+ "agent",
35887
+ "claimed",
35888
+ "released",
35889
+ "next-check",
35890
+ "resolution",
35891
+ "verdict",
35892
+ "close-certainty",
35893
+ "tags",
35894
+ "project",
35895
+ "type"
35896
+ ];
35771
35897
  var iso4 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
35772
35898
  var recordTaskEvent = /* @__PURE__ */ __name((database, task, actor, kind3, changes, at) => {
35773
35899
  database.prepare("INSERT INTO task_events (task_id, actor_type, actor_id, kind, changes, created_at) VALUES (?, ?, ?, ?, ?, ?)").run(task, actor?.type ?? null, actor?.id ?? null, kind3, changes === null ? null : JSON.stringify(changes), at);
@@ -36295,7 +36421,7 @@ var workTasksOver = /* @__PURE__ */ __name((context) => {
36295
36421
  };
36296
36422
  }, "workTasksOver");
36297
36423
 
36298
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
36424
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
36299
36425
  var taskCloseOver = /* @__PURE__ */ __name((context) => {
36300
36426
  const { database, now: now2 } = context;
36301
36427
  const liveRow = /* @__PURE__ */ __name((id2) => {
@@ -36344,7 +36470,8 @@ var taskCloseOver = /* @__PURE__ */ __name((context) => {
36344
36470
  };
36345
36471
  }, "taskCloseOver");
36346
36472
 
36347
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
36473
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
36474
+ var TASK_PAIR_DECISIONS = ["review", "unsure", "merged", "rejected", "unmerged", "attached", "new"];
36348
36475
  var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
36349
36476
  const { database, now: now2 } = context;
36350
36477
  const required3 = /* @__PURE__ */ __name((id2) => {
@@ -36562,7 +36689,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
36562
36689
  };
36563
36690
  }, "taskPairsOver");
36564
36691
 
36565
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-stats.js
36692
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-stats.js
36566
36693
  var ACCOUNT_SCOPE = "t.package_id IS NOT NULL AND t.deleted_at IS NULL AND t.project_id = ?";
36567
36694
  var TASK_STATS_SQL = {
36568
36695
  rows: /* @__PURE__ */ __name((board, filter) => `SELECT t.source_group, t.source_kind, t.project_id, t.status, t.created_at, t.closed_at FROM tasks t WHERE ${board ? BOARD_SCOPE : ACCOUNT_SCOPE}${filter} ORDER BY t.created_at, t.id`, "rows"),
@@ -36601,7 +36728,7 @@ var taskStatsOver = /* @__PURE__ */ __name(({ database }, inbox) => ({
36601
36728
  }, "statNames")
36602
36729
  }), "taskStatsOver");
36603
36730
 
36604
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
36731
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
36605
36732
  var COLUMNS3 = "t.id AS row_id, t.package_id, t.source_locator, t.source_kind, t.source_group, t.type, t.status, t.close_reason, t.source, t.created_at, t.due_at, t.closed_at, t.closed_by_type, t.closed_by_id, t.key, t.category, t.claimed_by, t.claimed_until, p.name AS account";
36606
36733
  var inboxProject = /* @__PURE__ */ __name(({ database, now: now2 }, account, create) => {
36607
36734
  const key2 = inboxKey(account);
@@ -36808,7 +36935,7 @@ var oneOf3 = /* @__PURE__ */ __name((values, value, column2) => {
36808
36935
  throw new CliError("configuration_error", `the store holds a task with an unknown ${column2} "${String(value)}"`);
36809
36936
  }, "oneOf");
36810
36937
 
36811
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/accounts.js
36938
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/accounts.js
36812
36939
  var accountAccountsOver = /* @__PURE__ */ __name((context) => {
36813
36940
  const { database } = context;
36814
36941
  const { accountPk: accountPk2, findAccountPk: findAccountPk2 } = keysOver(context);
@@ -36853,7 +36980,7 @@ var accountsStoreOver = /* @__PURE__ */ __name((context, keyed) => {
36853
36980
  };
36854
36981
  }, "accountsStoreOver");
36855
36982
 
36856
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
36983
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
36857
36984
  var refColumn = /* @__PURE__ */ __name((ref3) => ref3 && Object.keys(ref3).length > 0 ? { providerRef: JSON.stringify(ref3) } : {}, "refColumn");
36858
36985
  var updatePlaced = /* @__PURE__ */ __name(({ orm }, chatKey, messageId, files2, change) => {
36859
36986
  const message2 = orm.select({ pk: messages.id }).from(messages).where(and(eq(messages.chatId, chatKey), eq(messages.externalId, messageId))).get();
@@ -36877,7 +37004,7 @@ var keepDownloads = /* @__PURE__ */ __name((context, chatKey, messageId, files2)
36877
37004
  })), "keepDownloads");
36878
37005
  var keepProviderRefs = /* @__PURE__ */ __name((context, chatKey, messageId, files2) => updatePlaced(context, chatKey, messageId, files2.filter((file) => Object.keys(file.providerRef).length > 0), (file) => refColumn(file.providerRef)), "keepProviderRefs");
36879
37006
 
36880
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/attachments.js
37007
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/attachments.js
36881
37008
  var accountAttachmentsOver = /* @__PURE__ */ __name((context) => {
36882
37009
  const { database } = context;
36883
37010
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -36934,7 +37061,7 @@ var attachmentsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
36934
37061
  }, "keepAttachmentText")
36935
37062
  }), "attachmentsStoreOver");
36936
37063
 
36937
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
37064
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
36938
37065
  var chatRow = /* @__PURE__ */ __name((context, accountKey, chatId) => context.database.prepare("SELECT * FROM chats WHERE account_id = ? AND external_id = ?").get(accountKey, chatId), "chatRow");
36939
37066
  var pointerMover = /* @__PURE__ */ __name((context, type) => {
36940
37067
  const statements = pointerPairs(context.database).filter(({ table }) => table !== "involvements").map(({ table, pointer }) => {
@@ -37114,7 +37241,7 @@ var rekeyChats = /* @__PURE__ */ __name((context, key2, accountKey, pairs, lockM
37114
37241
  return done;
37115
37242
  }, "rekeyChats");
37116
37243
 
37117
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
37244
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
37118
37245
  var historyStartKey = /* @__PURE__ */ __name((chatId) => `history_start:${chatId}`, "historyStartKey");
37119
37246
  var fetchedKey = /* @__PURE__ */ __name((chatId) => `fetched:${chatId}`, "fetchedKey");
37120
37247
  var CHAT_LIST_KEY = "chat_list_complete";
@@ -37172,7 +37299,7 @@ var chatCoverage = /* @__PURE__ */ __name(({ database }, accountKey) => {
37172
37299
  return { ...coverage, oldestMessageAt: toIso(oldest) };
37173
37300
  }, "chatCoverage");
37174
37301
 
37175
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/chats.js
37302
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/chats.js
37176
37303
  var chatsStoreOver = /* @__PURE__ */ __name((context) => {
37177
37304
  const { database } = context;
37178
37305
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, writeState: writeState2 } = keysOver(context);
@@ -37307,7 +37434,7 @@ var chatsStoreOver = /* @__PURE__ */ __name((context) => {
37307
37434
  };
37308
37435
  }, "chatsStoreOver");
37309
37436
 
37310
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
37437
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
37311
37438
  import { createHash as createHash7 } from "node:crypto";
37312
37439
  var BATCH_CONTEXT = 50;
37313
37440
  var replied = /* @__PURE__ */ __name((m) => sql`EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
@@ -37445,7 +37572,7 @@ var saveAnswers = /* @__PURE__ */ __name((context, id2, answer) => {
37445
37572
  var clearAnswers = /* @__PURE__ */ __name(({ orm }, chatKey, model) => Number(orm.all(sql`DELETE FROM message_links WHERE chat_id = ${chatKey} AND source = 'agent'
37446
37573
  ${model === void 0 ? sql`` : sql`AND method = ${model}`} RETURNING 1 AS n`).length), "clearAnswers");
37447
37574
 
37448
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
37575
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
37449
37576
  import { setTimeout } from "node:timers/promises";
37450
37577
  var position = /* @__PURE__ */ __name((sentAt, pk) => `${sentAt}:${pk}`, "position");
37451
37578
  var linkInputs = /* @__PURE__ */ __name(({ orm }, chatKey, { after: after2, limit }) => {
@@ -37757,7 +37884,7 @@ var agentAnswers = /* @__PURE__ */ __name(({ orm }, chatKey) => new Map(orm.all(
37757
37884
  AND NOT EXISTS (SELECT 1 FROM messages d
37758
37885
  WHERE d.id IN (l.message_id, l.parent_id) AND d.deleted_at > l.created_at)`).map(({ id: id2, parent: parent2 }) => [id2, parent2])), "agentAnswers");
37759
37886
 
37760
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/conversations.js
37887
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/conversations.js
37761
37888
  var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
37762
37889
  const { database } = context;
37763
37890
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -37864,7 +37991,7 @@ var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
37864
37991
  };
37865
37992
  }, "conversationsStoreOver");
37866
37993
 
37867
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/counters.js
37994
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/counters.js
37868
37995
  var LIVE_MESSAGE = "SELECT m.id AS pk FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id WHERE ac.provider=? AND ac.external_id=? AND c.external_id=? AND m.external_id=? AND m.deleted_at IS NULL";
37869
37996
  var accountCountersOver = /* @__PURE__ */ __name((context) => {
37870
37997
  const { database } = context;
@@ -37889,7 +38016,7 @@ var countersStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
37889
38016
  counterTargets: /* @__PURE__ */ __name(async (execution, options) => counterTargets(context, execution, options), "counterTargets")
37890
38017
  }), "countersStoreOver");
37891
38018
 
37892
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
38019
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
37893
38020
  var MENTION_STATUSES = ["found", "linked", "dismissed"];
37894
38021
  var MENTION_QUERY = defineQuery({
37895
38022
  entity: "mention",
@@ -38105,7 +38232,7 @@ var listPlaces = /* @__PURE__ */ __name((database, { limit, offset }) => {
38105
38232
  return { items: hasMore ? rows.slice(0, limit) : rows, hasMore };
38106
38233
  }, "listPlaces");
38107
38234
 
38108
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/mentions.js
38235
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/mentions.js
38109
38236
  var accountMentionsOver = /* @__PURE__ */ __name((context) => {
38110
38237
  const { database } = context;
38111
38238
  const { findAccountPk: findAccountPk2 } = keysOver(context);
@@ -38140,7 +38267,7 @@ var mentionsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
38140
38267
  places: /* @__PURE__ */ __name(async (window) => listPlaces(context.database, window), "places")
38141
38268
  }), "mentionsStoreOver");
38142
38269
 
38143
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
38270
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
38144
38271
  var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messageId) => {
38145
38272
  const read2 = database.prepare("SELECT m.id, m.external_id, m.text, m.sent_at, m.sender_name, coalesce(m.sender_chat_external_id, i.external_id) AS sender_id FROM messages m LEFT JOIN identities i ON i.id = m.sender_identity_id WHERE m.chat_id = ? AND m.deleted_at IS NULL AND (m.text LIKE '%google.com%' OR m.text LIKE '%forms.gle%') " + (messageId === void 0 ? "" : "AND m.external_id = ? ") + "ORDER BY m.sent_at DESC, m.id DESC");
38146
38273
  const rows = messageId === void 0 ? read2.all(chatKey) : read2.all(chatKey, messageId);
@@ -38155,7 +38282,7 @@ var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messag
38155
38282
  }));
38156
38283
  }, "documentLinkMessages");
38157
38284
 
38158
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
38285
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
38159
38286
  var stemmerFor = stemmerCache();
38160
38287
  var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit }) => {
38161
38288
  if (wanted.length > 50 || !Number.isInteger(limit) || limit < 1 || limit > 100)
@@ -38199,7 +38326,7 @@ var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit
38199
38326
  });
38200
38327
  }, "laterSharingRare");
38201
38328
 
38202
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/messages.js
38329
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/messages.js
38203
38330
  var accountMessagesOver = /* @__PURE__ */ __name((context) => {
38204
38331
  const { database } = context;
38205
38332
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf, chatPkFor: chatPkFor2, answeredChatPk: answeredChatPk2, upsertMessage: upsertMessage2 } = keysOver(context);
@@ -38334,7 +38461,7 @@ var messagesStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
38334
38461
  laterSharingRare: /* @__PURE__ */ __name(async (wanted, options) => laterSharingRare(context, wanted, options), "laterSharingRare")
38335
38462
  }), "messagesStoreOver");
38336
38463
 
38337
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
38464
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
38338
38465
  var GLOBAL_PROJECT = "SELECT id FROM main.projects WHERE account_id IS NULL AND deleted_at IS NULL";
38339
38466
  var iso5 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
38340
38467
  var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: accounts2, limit }) => {
@@ -38391,7 +38518,7 @@ var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: a
38391
38518
  });
38392
38519
  }, "personPreparation");
38393
38520
 
38394
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
38521
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
38395
38522
  var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds) => {
38396
38523
  const id2 = Number(uid);
38397
38524
  if (!/^[1-9]\d*$/.test(uid) || !Number.isSafeInteger(id2) || !accountIds.length || accountIds.length > 1e3 || accountIds.some((account) => !Number.isSafeInteger(account) || account <= 0))
@@ -38399,7 +38526,7 @@ var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds
38399
38526
  return Boolean(database.prepare("SELECT 1 FROM persons p JOIN identity_links l ON l.person_id=p.id JOIN account_identities a ON a.identity_id=l.identity_id WHERE p.id=? AND a.account_id IN (SELECT value FROM json_each(?)) LIMIT 1").get(id2, JSON.stringify(accountIds)));
38400
38527
  }, "personSeenInAccounts");
38401
38528
 
38402
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
38529
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
38403
38530
  var required2 = /* @__PURE__ */ __name(({ database }, key2, personId) => {
38404
38531
  const row2 = database.prepare("SELECT a.id AS account_id, i.id AS identity_id FROM accounts a JOIN account_identities ai ON ai.account_id=a.id JOIN identities i ON i.id=ai.identity_id WHERE a.provider=? AND a.external_id=? AND i.provider=? AND i.external_id=?").get(key2.provider, key2.account, key2.provider, personId);
38405
38532
  if (!row2)
@@ -38465,7 +38592,7 @@ var removeNote = /* @__PURE__ */ __name((context, key2, personId, id2) => {
38465
38592
  return { id: id2, personId, removed: true };
38466
38593
  }, "removeNote");
38467
38594
 
38468
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/people.js
38595
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/people.js
38469
38596
  var accountPeopleOver = /* @__PURE__ */ __name((context) => {
38470
38597
  const { database } = context;
38471
38598
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, identityPk: identityPk2 } = keysOver(context);
@@ -38550,13 +38677,13 @@ var peopleStoreOver = /* @__PURE__ */ __name((context, keyed) => {
38550
38677
  };
38551
38678
  }, "peopleStoreOver");
38552
38679
 
38553
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
38680
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
38554
38681
  import { createHash as createHash9 } from "node:crypto";
38555
38682
 
38556
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
38683
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
38557
38684
  import { createHash as createHash8 } from "node:crypto";
38558
38685
 
38559
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
38686
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
38560
38687
  var RANKING_GRAPH_LIMITS = { nodes: 5e4, depth: 256, work: 1e7, bytes: 8388608 };
38561
38688
  var exhausted2 = /* @__PURE__ */ __name((budget) => {
38562
38689
  throw new CliError("validation_error", `ranking exceeded ${budget} \u2014 narrow its chat or date scope`, {
@@ -38778,7 +38905,7 @@ var rankReplyGraph = /* @__PURE__ */ __name((nodes, check3 = () => {
38778
38905
  };
38779
38906
  }, "rankReplyGraph");
38780
38907
 
38781
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
38908
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
38782
38909
  var adminEntityKey = /* @__PURE__ */ __name((row2) => JSON.stringify([row2.account.provider, row2.account.account, row2.id]), "adminEntityKey");
38783
38910
  var personKey = /* @__PURE__ */ __name((node) => JSON.stringify([node.account.provider, node.account.account, node.sender]), "personKey");
38784
38911
  var locator = /* @__PURE__ */ __name((node) => formatLocator({ ...node.account, chat: node.chatId, message: node.id }), "locator");
@@ -38952,7 +39079,7 @@ var calculateAdminStatistics = /* @__PURE__ */ __name((nodes, stays, options, in
38952
39079
  return { items, evidence, summary, graph: graph.quality };
38953
39080
  }, "calculateAdminStatistics");
38954
39081
 
38955
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
39082
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
38956
39083
  var rankingContextRange = /* @__PURE__ */ __name((root) => {
38957
39084
  const dates = [];
38958
39085
  const visit = /* @__PURE__ */ __name((node, required3) => {
@@ -38974,7 +39101,7 @@ var rankingContextRange = /* @__PURE__ */ __name((root) => {
38974
39101
  return dates[0].node.resolution.date;
38975
39102
  }, "rankingContextRange");
38976
39103
 
38977
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
39104
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
38978
39105
  var reactionCounts = /* @__PURE__ */ __name((stored3) => {
38979
39106
  let counts;
38980
39107
  try {
@@ -39269,7 +39396,7 @@ var rankQuery = /* @__PURE__ */ __name((context, execution, request, inspect) =>
39269
39396
  });
39270
39397
  }, "rankQuery");
39271
39398
 
39272
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
39399
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
39273
39400
  function fail4(message2, reason = "query.too-large") {
39274
39401
  throw new CliError("validation_error", message2, { reason, complete: false });
39275
39402
  }
@@ -39446,7 +39573,7 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
39446
39573
  return result;
39447
39574
  }), "adminStatisticsQuery");
39448
39575
 
39449
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
39576
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
39450
39577
  var conversationEligibility = /* @__PURE__ */ __name(async (context, execution) => {
39451
39578
  if (!execution.accounts.length)
39452
39579
  return { conversations: [], chats: [] };
@@ -39464,7 +39591,7 @@ var conversationEligibility = /* @__PURE__ */ __name(async (context, execution)
39464
39591
  return { conversations: conversations2, chats: chats2 };
39465
39592
  }, "conversationEligibility");
39466
39593
 
39467
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
39594
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
39468
39595
  import { createHash as createHash10 } from "node:crypto";
39469
39596
  var EVIDENCE_BYTES = 64 * 1024;
39470
39597
  var FINGERPRINT_BYTES = 8 * 1024 * 1024;
@@ -39614,7 +39741,7 @@ var rankingEvidence = /* @__PURE__ */ __name((context, execution, request) => {
39614
39741
  return result;
39615
39742
  }, "rankingEvidence");
39616
39743
 
39617
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/reply-times.js
39744
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/reply-times.js
39618
39745
  var FAR = Number.MAX_SAFE_INTEGER;
39619
39746
  var chatsIn = /* @__PURE__ */ __name((scope3, kinds2) => {
39620
39747
  const params = [...scope3.accounts.flatMap(({ provider, account }) => [provider, account]), ...kinds2];
@@ -39708,7 +39835,7 @@ var waitingChats = /* @__PURE__ */ __name((context, scope3, waits, cap) => {
39708
39835
  });
39709
39836
  }, "waitingChats");
39710
39837
 
39711
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/queries.js
39838
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/queries.js
39712
39839
  var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
39713
39840
  const mailIndexed = /* @__PURE__ */ __name((execution) => {
39714
39841
  if (execution.corpus === "mail")
@@ -39729,7 +39856,7 @@ var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
39729
39856
  };
39730
39857
  }, "queriesStoreOver");
39731
39858
 
39732
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
39859
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
39733
39860
  var saveChatEvents = /* @__PURE__ */ __name((context, accountKey, provider, chatKey, events3) => {
39734
39861
  const { database, now: now2 } = context;
39735
39862
  const insert = database.prepare(`INSERT INTO chat_events (chat_id, source_id, action, actor_identity_id, title, happened_at, created_at, updated_at)
@@ -39768,10 +39895,10 @@ var chatEventsOf = /* @__PURE__ */ __name(({ database }, chatKey, { since = 0, l
39768
39895
  }));
39769
39896
  }, "chatEventsOf");
39770
39897
 
39771
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
39898
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
39772
39899
  import { createHash as createHash11 } from "node:crypto";
39773
39900
 
39774
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/calendar.js
39901
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/calendar.js
39775
39902
  var calendarKey = /* @__PURE__ */ __name((zone, by) => {
39776
39903
  const format = new Intl.DateTimeFormat("en-CA", {
39777
39904
  timeZone: zone,
@@ -39785,13 +39912,13 @@ var calendarKey = /* @__PURE__ */ __name((zone, by) => {
39785
39912
  return `${part.year}-${part.month}-${part.day}${by === "hour" ? `T${part.hour}` : ""}`;
39786
39913
  };
39787
39914
  }, "calendarKey");
39788
- var weekKey = /* @__PURE__ */ __name((day) => {
39789
- const date3 = /* @__PURE__ */ new Date(`${day}T00:00:00Z`);
39915
+ var weekKey = /* @__PURE__ */ __name((day2) => {
39916
+ const date3 = /* @__PURE__ */ new Date(`${day2}T00:00:00Z`);
39790
39917
  date3.setUTCDate(date3.getUTCDate() - (date3.getUTCDay() + 6) % 7);
39791
39918
  return date3.toISOString().slice(0, 10);
39792
39919
  }, "weekKey");
39793
39920
 
39794
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/retention.js
39921
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/retention.js
39795
39922
  var RETENTION_TOLERANCE = 864e5;
39796
39923
  var validateRetentionOptions = /* @__PURE__ */ __name((options) => {
39797
39924
  const { since, until, cutoff, checkpoints, within, limit, by } = options;
@@ -39845,7 +39972,7 @@ var retentionCohorts = /* @__PURE__ */ __name((stays, options) => {
39845
39972
  return [...groups.values()].sort((a, b) => a.cohort.localeCompare(b.cohort));
39846
39973
  }, "retentionCohorts");
39847
39974
 
39848
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
39975
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
39849
39976
  var iso6 = /* @__PURE__ */ __name((at) => new Date(at).toISOString(), "iso");
39850
39977
  var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId, options, evidence) => {
39851
39978
  validateRetentionOptions(options);
@@ -39867,7 +39994,7 @@ var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId
39867
39994
  const activityStatement = database.prepare(`SELECT min(sent_at) AS at FROM messages WHERE chat_id=? AND sender_identity_id=? AND deleted_at IS NULL AND sent_at >= ? AND sent_at < ?`);
39868
39995
  const stays = raw.map((row2) => {
39869
39996
  const joinedAt = Number(row2.joined_at), pk = Number(row2.pk), end = joinedAt + options.within;
39870
- const day = dayOf2(joinedAt), cohort = options.by === "week" ? weekKey(day) : day;
39997
+ const day2 = dayOf2(joinedAt), cohort = options.by === "week" ? weekKey(day2) : day2;
39871
39998
  const absence = departureStatement.get(chatPk, Math.max(joinedAt, Number(row2.first_seen_at)), options.cutoff, pk);
39872
39999
  const upper = absence ? Number(absence.observed_at) : null;
39873
40000
  const positive2 = lastPositiveStatement.get(pk, upper ?? options.cutoff + 1);
@@ -39976,7 +40103,7 @@ var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId
39976
40103
  };
39977
40104
  }, "retentionQuery");
39978
40105
 
39979
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
40106
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
39980
40107
  var iso7 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
39981
40108
  var marksOf = /* @__PURE__ */ __name(({ isBot, flagged, deleted, hasPhoto }) => ({
39982
40109
  ...isBot === void 0 ? {} : { bot: isBot },
@@ -40049,14 +40176,14 @@ var saveRoster = /* @__PURE__ */ __name((context, accountKey, provider, chatKey,
40049
40176
  for (const person2 of present2)
40050
40177
  orm.insert(chatMembers).values({ chatId: chatKey, identityId: person2, createdAt: at }).run();
40051
40178
  }
40052
- const day = new Date(at).toISOString().slice(0, 10);
40179
+ const day2 = new Date(at).toISOString().slice(0, 10);
40053
40180
  const count = {
40054
40181
  reportedCount: participants3,
40055
40182
  listedCount: members2.length,
40056
40183
  completeList: complete ? 1 : 0,
40057
40184
  createdAt: at
40058
40185
  };
40059
- orm.insert(memberCounts).values({ chatId: chatKey, date: day, ...count }).onConflictDoUpdate({ target: [memberCounts.chatId, memberCounts.date], set: count }).run();
40186
+ orm.insert(memberCounts).values({ chatId: chatKey, date: day2, ...count }).onConflictDoUpdate({ target: [memberCounts.chatId, memberCounts.date], set: count }).run();
40060
40187
  return change;
40061
40188
  }, "saveRoster");
40062
40189
  var memberStaysOf = /* @__PURE__ */ __name(({ orm }, chatKey, since) => orm.select({
@@ -40107,7 +40234,7 @@ var trackedChats = /* @__PURE__ */ __name((context, accountKey, where) => contex
40107
40234
  lastCount: memberCountsOf(context, pk).at(-1) ?? null
40108
40235
  })), "trackedChats");
40109
40236
 
40110
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/roster.js
40237
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/roster.js
40111
40238
  var rosterStoreOver = /* @__PURE__ */ __name((context) => {
40112
40239
  const { database } = context;
40113
40240
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, writeMembers: writeMembers2 } = keysOver(context);
@@ -40163,7 +40290,7 @@ var rosterStoreOver = /* @__PURE__ */ __name((context) => {
40163
40290
  };
40164
40291
  }, "rosterStoreOver");
40165
40292
 
40166
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
40293
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
40167
40294
  var pendingNormalization = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL").get()?.n), "pendingNormalization");
40168
40295
  var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatch, until = /* @__PURE__ */ __name(() => false, "until") } = {}) => {
40169
40296
  const next = database.prepare(`SELECT id AS pk, text FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL AND id > ? ORDER BY id LIMIT ?`);
@@ -40187,7 +40314,7 @@ var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatc
40187
40314
  }
40188
40315
  }, "backfillNormalized");
40189
40316
 
40190
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
40317
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
40191
40318
  var INDEX2 = "message_words";
40192
40319
  var searchIndexState2 = /* @__PURE__ */ __name((database) => {
40193
40320
  const row2 = indexRow(database, INDEX2);
@@ -40314,7 +40441,7 @@ var resetSearchIndex = /* @__PURE__ */ __name((database) => {
40314
40441
  });
40315
40442
  }, "resetSearchIndex");
40316
40443
 
40317
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
40444
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
40318
40445
  var fillStems = /* @__PURE__ */ __name((database, { batch = 5e3, until = /* @__PURE__ */ __name(() => false, "until"), onBatch, now: now2 = Date.now } = {}) => {
40319
40446
  const filled2 = { stemmed: 0, drained: 0 };
40320
40447
  const before2 = stemsState(database);
@@ -40409,7 +40536,7 @@ var followDefaultStemmers = /* @__PURE__ */ __name((database, now2 = Date.now) =
40409
40536
  return resetStems(database, { now: now2 });
40410
40537
  }, "followDefaultStemmers");
40411
40538
 
40412
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
40539
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
40413
40540
  var VOCABULARY = "SELECT term, doc FROM message_words_vocab WHERE col = 'normalized_text'";
40414
40541
  var knownTerms = /* @__PURE__ */ __name(({ database }, terms2) => {
40415
40542
  const lookup = database.prepare(`${VOCABULARY} AND term >= ? AND term <= ? LIMIT 1`);
@@ -40431,7 +40558,7 @@ var termCandidates = /* @__PURE__ */ __name(({ database }, pieces, { shortest, l
40431
40558
  });
40432
40559
  }, "termCandidates");
40433
40560
 
40434
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/search-index.js
40561
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/search-index.js
40435
40562
  var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
40436
40563
  const { database } = context;
40437
40564
  const stemmerFor2 = stemmerCache();
@@ -40439,9 +40566,11 @@ var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
40439
40566
  knownTerms: /* @__PURE__ */ __name(async (terms2) => knownTerms(context, terms2), "knownTerms"),
40440
40567
  termCandidates: /* @__PURE__ */ __name(async (trigrams2, lengths) => termCandidates(context, trigrams2, lengths), "termCandidates"),
40441
40568
  searchIndexState: /* @__PURE__ */ __name(async () => searchIndexState2(database), "searchIndexState"),
40442
- fillSearchIndex: /* @__PURE__ */ __name(async ({ until } = {}) => fillSearchIndex(database, { now: context.now, ...until ? { until } : {} }), "fillSearchIndex"),
40569
+ fillSearchIndex: /* @__PURE__ */ __name(async ({ until } = {}) => isQueryOnly(database) ? { normalized: 0, indexed: 0, terms: 0 } : fillSearchIndex(database, { now: context.now, ...until ? { until } : {} }), "fillSearchIndex"),
40443
40570
  stemsState: /* @__PURE__ */ __name(async () => stemsState(database), "stemsState"),
40444
40571
  fillStems: /* @__PURE__ */ __name(async ({ until } = {}) => {
40572
+ if (isQueryOnly(database))
40573
+ return { stemmed: 0, drained: 0 };
40445
40574
  const filled2 = fillStems(database, { now: context.now, ...until ? { until } : {} });
40446
40575
  const transcripts = corpusIndexState(database, CORPORA.transcript);
40447
40576
  if (transcripts.wanted !== null && (transcripts.pending > 0 || transcripts.built !== transcripts.wanted))
@@ -40453,7 +40582,7 @@ var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
40453
40582
  };
40454
40583
  }, "searchIndexStoreOver");
40455
40584
 
40456
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
40585
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
40457
40586
  var HISTORY_KEPT = 1e3;
40458
40587
  var commandFilter = /* @__PURE__ */ __name((commands) => commands ? { sql: ` AND command IN (${commands.map(() => "?").join(", ")})`, values: [...commands] } : { sql: "", values: [] }, "commandFilter");
40459
40588
  var COLUMNS5 = "id, name, command, params, language, version, fields_version, created_at, updated_at, last_run_at, runs";
@@ -40522,7 +40651,7 @@ var clearHistory = /* @__PURE__ */ __name(({ database }, commands) => {
40522
40651
  return database.prepare(`DELETE FROM searches WHERE name IS NULL${only.sql}`).run(...only.values).changes;
40523
40652
  }, "clearHistory");
40524
40653
 
40525
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/searches.js
40654
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/searches.js
40526
40655
  var searchesStoreOver = /* @__PURE__ */ __name((context) => {
40527
40656
  const { database } = context;
40528
40657
  return {
@@ -40546,7 +40675,7 @@ var searchesStoreOver = /* @__PURE__ */ __name((context) => {
40546
40675
  };
40547
40676
  }, "searchesStoreOver");
40548
40677
 
40549
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
40678
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
40550
40679
  var ACTION_TIERS = ["read", "draft", "write-private", "write-public", "destructive", "admin"];
40551
40680
  var ACTION_OUTCOMES = ["ok", "refused", "failed"];
40552
40681
  var CODE = /^[a-z][a-z0-9_]{0,63}$/;
@@ -40589,7 +40718,7 @@ var agentActionsStoreOver = /* @__PURE__ */ __name((context, afterRecord = () =>
40589
40718
  };
40590
40719
  }, "agentActionsStoreOver");
40591
40720
 
40592
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
40721
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
40593
40722
  var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
40594
40723
  }) => {
40595
40724
  const { database, now: now2 } = context;
@@ -40648,7 +40777,7 @@ var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
40648
40777
  };
40649
40778
  }, "botUpdateStoreOver");
40650
40779
 
40651
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
40780
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
40652
40781
  var DAY4 = 864e5;
40653
40782
  var accountsOf = /* @__PURE__ */ __name((filter) => {
40654
40783
  if (filter.accountIds !== void 0 && filter.accountId !== void 0)
@@ -40757,7 +40886,7 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
40757
40886
  return database.prepare(`SELECT e.* FROM events e WHERE ${clauses.join(" AND ")} ORDER BY ${filter.newest ? "e.starts_at DESC, e.id DESC" : "e.starts_at, e.id"} LIMIT ? OFFSET ?`).all(...params, limit, offset).map(eventOf);
40758
40887
  }, "listEvents");
40759
40888
 
40760
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-forget.js
40889
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-forget.js
40761
40890
  var distinctIds = /* @__PURE__ */ __name((rows) => [...new Set(rows.map((row2) => Number(row2.id)))], "distinctIds");
40762
40891
  var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, accountId, cursorKey: cursorKey2, now: now2 }, refresh) => {
40763
40892
  const unseenBefore = unreferenced(database, "identities");
@@ -40812,7 +40941,7 @@ var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, account
40812
40941
  return { entries: entryIds.length, events: goneEvents.length };
40813
40942
  }, "forgetCalendarRows");
40814
40943
 
40815
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
40944
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
40816
40945
  var calendarOf = /* @__PURE__ */ __name((row2) => ({
40817
40946
  id: Number(row2.id),
40818
40947
  accountId: Number(row2.account_id),
@@ -41399,7 +41528,7 @@ var eventStoreOver = /* @__PURE__ */ __name((context) => {
41399
41528
  };
41400
41529
  }, "eventStoreOver");
41401
41530
 
41402
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
41531
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
41403
41532
  var CATALOG_QUERY = defineQuery({
41404
41533
  entity: "document",
41405
41534
  backend: "sql",
@@ -41641,7 +41770,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
41641
41770
  };
41642
41771
  }, "catalogStoreOver");
41643
41772
 
41644
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
41773
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
41645
41774
  var drive = "CASE WHEN json_valid(n.front_matter) THEN json_extract(n.front_matter,'$.source')='google-drive' ELSE 0 END";
41646
41775
  var field3 = /* @__PURE__ */ __name((name) => `CASE WHEN (${drive}) THEN
41647
41776
  CASE WHEN json_type(n.front_matter,'$.${name}')='text' THEN json_extract(n.front_matter,'$.${name}') END END`, "field");
@@ -41654,7 +41783,7 @@ var contextDocumentTimeKind = `CASE WHEN (${remoteTime}) IS NOT NULL
41654
41783
  THEN 'source-modified' ELSE 'stored-update' END`;
41655
41784
  var contextDocumentUrl = `coalesce(${preferred("url")},n.url,${field3("sourceUrl")})`;
41656
41785
 
41657
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
41786
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
41658
41787
  var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
41659
41788
  const { source: source2, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal } = request;
41660
41789
  signal?.throwIfAborted();
@@ -41753,7 +41882,7 @@ var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
41753
41882
  });
41754
41883
  }, "readMeetingContextEvidence");
41755
41884
 
41756
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
41885
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
41757
41886
  var corpora = {
41758
41887
  message: {
41759
41888
  table: "messages",
@@ -41992,7 +42121,282 @@ var contextRecordsOver = /* @__PURE__ */ __name(({ database }) => ({
41992
42121
  }
41993
42122
  }), "contextRecordsOver");
41994
42123
 
41995
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/finance.js
42124
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/crm.js
42125
+ var TABLES = { deal: "deals", lead: "leads" };
42126
+ var SOURCE = "crm";
42127
+ var crmIdentityId = /* @__PURE__ */ __name((key2, externalId, type = "contact") => `${key2.account}/${type}/${externalId}`, "crmIdentityId");
42128
+ var day = /* @__PURE__ */ __name((value, what) => {
42129
+ if (value === void 0 || value === null || value === "")
42130
+ return null;
42131
+ if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value) || Number.isNaN(Date.parse(value)))
42132
+ throw new CliError("validation_error", `${what} is YYYY-MM-DD, not ${JSON.stringify(value)}`);
42133
+ return value;
42134
+ }, "day");
42135
+ var epoch = /* @__PURE__ */ __name((value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.trunc(value) : fallback, "epoch");
42136
+ var textOf3 = /* @__PURE__ */ __name((value, most) => {
42137
+ if (typeof value !== "string")
42138
+ return null;
42139
+ const kept = value.trim().slice(0, most);
42140
+ return kept || null;
42141
+ }, "textOf");
42142
+ var crmCopiesOver = /* @__PURE__ */ __name((context, people2) => {
42143
+ const { database, now: now2 } = context;
42144
+ const author = /* @__PURE__ */ __name((key2) => authorActor(context, { bot: key2.provider, kind: "rule" }).actor, "author");
42145
+ const account = /* @__PURE__ */ __name((key2) => accountPk(context, key2), "account");
42146
+ const pipelineOf = /* @__PURE__ */ __name((accountId, kind3, externalId) => database.prepare("SELECT * FROM pipelines WHERE account_id = ? AND kind = ? AND external_id = ?").get(accountId, kind3, externalId), "pipelineOf");
42147
+ const savePipelines = /* @__PURE__ */ __name((key2, kind3, pipelines2) => write(database, () => {
42148
+ const accountId = account(key2);
42149
+ const at = now2();
42150
+ for (const pipeline of pipelines2) {
42151
+ const name = textOf3(pipeline.name, 80) ?? pipeline.externalId;
42152
+ const held = pipelineOf(accountId, kind3, pipeline.externalId);
42153
+ const id2 = held ? Number(held.id) : Number(database.prepare("INSERT INTO pipelines (account_id, external_id, kind, name, name_folded, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id").get(accountId, pipeline.externalId, kind3, name, fold(name), at, at)?.id);
42154
+ if (held && (held.name !== name || held.deleted_at != null))
42155
+ database.prepare("UPDATE pipelines SET name = ?, name_folded = ?, updated_at = ?, deleted_at = NULL WHERE id = ?").run(name, fold(name), at, id2);
42156
+ saveStages(id2, pipeline, at);
42157
+ }
42158
+ if (pipelines2.length === 0)
42159
+ return { saved: 0, skipped: [] };
42160
+ const listed = new Set(pipelines2.map(({ externalId }) => externalId));
42161
+ const mark = database.prepare("UPDATE pipelines SET deleted_at = ?, updated_at = ? WHERE id = ?");
42162
+ for (const row2 of database.prepare("SELECT id, external_id FROM pipelines WHERE account_id = ? AND kind = ? AND deleted_at IS NULL").all(accountId, kind3))
42163
+ if (!listed.has(String(row2.external_id)))
42164
+ mark.run(at, at, Number(row2.id));
42165
+ return { saved: pipelines2.length, skipped: [] };
42166
+ }), "savePipelines");
42167
+ const saveStages = /* @__PURE__ */ __name((pipelineId, pipeline, at) => {
42168
+ const ordered = [...pipeline.stages].sort((a, b) => a.position - b.position);
42169
+ const counts = /* @__PURE__ */ new Map();
42170
+ for (const stage of ordered)
42171
+ counts.set(fold(stage.name), (counts.get(fold(stage.name)) ?? 0) + 1);
42172
+ const wanted = ordered.map((stage, index2) => {
42173
+ const name = textOf3(stage.name, 80) ?? stage.externalId;
42174
+ const folded5 = (counts.get(fold(stage.name)) ?? 0) > 1 ? `${fold(name)} (${stage.externalId})` : fold(name);
42175
+ if (!STAGE_OUTCOMES.includes(stage.outcome))
42176
+ throw new CliError("invalid_response", `stage ${stage.externalId} has no known outcome: ${stage.outcome}`);
42177
+ return { ...stage, name, folded: folded5, position: index2 + 1 };
42178
+ });
42179
+ const held = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ?").all(pipelineId);
42180
+ const listed = new Set(wanted.map(({ externalId }) => externalId));
42181
+ const taken = new Set(wanted.map(({ folded: folded5 }) => folded5));
42182
+ const rename = database.prepare("UPDATE pipeline_stages SET name_folded = ? WHERE id = ?");
42183
+ const gone = database.prepare("UPDATE pipeline_stages SET deleted_at = ? WHERE id = ? AND deleted_at IS NULL");
42184
+ for (const row2 of held) {
42185
+ const kept = row2.external_id != null && listed.has(String(row2.external_id));
42186
+ if (kept)
42187
+ rename.run(`\0${row2.id}`, Number(row2.id));
42188
+ else if (taken.has(String(row2.name_folded)))
42189
+ rename.run(`${row2.name_folded} (${row2.external_id ?? row2.id})`, Number(row2.id));
42190
+ if (!kept)
42191
+ gone.run(at, Number(row2.id));
42192
+ }
42193
+ const byId2 = new Map(held.map((row2) => [String(row2.external_id), row2]));
42194
+ for (const stage of wanted) {
42195
+ const row2 = byId2.get(stage.externalId);
42196
+ if (row2)
42197
+ database.prepare("UPDATE pipeline_stages SET name = ?, name_folded = ?, position = ?, outcome = ?, updated_at = ?, deleted_at = NULL WHERE id = ?").run(stage.name, stage.folded, stage.position, stage.outcome, at, Number(row2.id));
42198
+ else
42199
+ database.prepare("INSERT INTO pipeline_stages (pipeline_id, name, name_folded, position, outcome, external_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(pipelineId, stage.name, stage.folded, stage.position, stage.outcome, stage.externalId, at, at);
42200
+ }
42201
+ }, "saveStages");
42202
+ const saveFields = /* @__PURE__ */ __name((key2, kind3, fields4) => write(database, () => {
42203
+ const accountId = account(key2);
42204
+ const at = now2();
42205
+ const skipped = [];
42206
+ const listed = /* @__PURE__ */ new Set();
42207
+ const upsert2 = database.prepare("INSERT INTO crm_fields (account_id, kind, code, label, type, multiple, filterable, options, position, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT (account_id, kind, code) DO UPDATE SET label = excluded.label, type = excluded.type, multiple = excluded.multiple, filterable = excluded.filterable, options = excluded.options, position = excluded.position, updated_at = excluded.updated_at, deleted_at = NULL");
42208
+ for (const field4 of fields4) {
42209
+ const code = typeof field4.code === "string" ? field4.code.trim() : "";
42210
+ if (!code || listed.has(code)) {
42211
+ skipped.push({
42212
+ externalId: code,
42213
+ reason: "crm.item-invalid",
42214
+ message: code ? `${kind3} field ${code} is listed twice` : `a ${kind3} field has no code`
42215
+ });
42216
+ continue;
42217
+ }
42218
+ listed.add(code);
42219
+ const options = field4.options?.map((option) => ({ id: String(option.id), label: String(option.label) }));
42220
+ upsert2.run(accountId, kind3, code, textOf3(field4.label, 200), textOf3(field4.type, 80) ?? "string", field4.multiple ? 1 : 0, field4.filterable ? 1 : 0, options ? JSON.stringify(options) : null, listed.size, at, at);
42221
+ }
42222
+ const mark = database.prepare("UPDATE crm_fields SET deleted_at = ?, updated_at = ? WHERE id = ?");
42223
+ for (const row2 of database.prepare("SELECT id, code FROM crm_fields WHERE account_id = ? AND kind = ? AND deleted_at IS NULL").all(accountId, kind3))
42224
+ if (!listed.has(String(row2.code)))
42225
+ mark.run(at, at, Number(row2.id));
42226
+ return { saved: listed.size, skipped };
42227
+ }), "saveFields");
42228
+ const fieldsOf3 = /* @__PURE__ */ __name((key2, kind3) => {
42229
+ const accountId = findAccountPk(context, key2);
42230
+ if (accountId === void 0)
42231
+ return [];
42232
+ return database.prepare("SELECT * FROM crm_fields WHERE account_id = ? AND kind = ? AND deleted_at IS NULL ORDER BY position, id").all(accountId, kind3).map((row2) => ({
42233
+ code: String(row2.code),
42234
+ label: row2.label == null ? null : String(row2.label),
42235
+ type: String(row2.type),
42236
+ multiple: Number(row2.multiple) === 1,
42237
+ filterable: Number(row2.filterable) === 1,
42238
+ ...row2.options == null ? {} : { options: JSON.parse(String(row2.options)) }
42239
+ }));
42240
+ }, "fieldsOf");
42241
+ const personIdOf = /* @__PURE__ */ __name((key2, externalId) => {
42242
+ const row2 = database.prepare("SELECT l.person_id FROM identities i JOIN identity_links l ON l.identity_id = i.id WHERE i.provider = ? AND i.external_id = ?").get(key2.provider, crmIdentityId(key2, externalId));
42243
+ return row2 ? Number(row2.person_id) : null;
42244
+ }, "personIdOf");
42245
+ const organizationIdOf = /* @__PURE__ */ __name((accountId, externalId) => {
42246
+ const row2 = database.prepare("SELECT entity_id FROM records WHERE account_id = ? AND type = 'organization' AND external_id = ? AND entity_type = 'organization'").get(accountId, externalId);
42247
+ return row2?.entity_id == null ? null : Number(row2.entity_id);
42248
+ }, "organizationIdOf");
42249
+ const saveItem = /* @__PURE__ */ __name((key2, accountId, kind3, item, at) => {
42250
+ const pipeline = pipelineOf(accountId, kind3, item.pipeline);
42251
+ const stage = pipeline && database.prepare("SELECT id, outcome FROM pipeline_stages WHERE pipeline_id = ? AND external_id = ?").get(Number(pipeline.id), item.stage);
42252
+ if (!pipeline || !stage)
42253
+ return {
42254
+ externalId: item.externalId,
42255
+ reason: "crm.stage-unknown",
42256
+ message: `${kind3} ${item.externalId} stands in stage ${item.stage} of pipeline ${item.pipeline}, which is not stored`
42257
+ };
42258
+ const title = textOf3(item.title, 200) ?? `${kind3} ${item.externalId}`;
42259
+ const given = item.amount != null && item.currency != null;
42260
+ const currency = given ? currencyOf(item.currency) : null;
42261
+ const amount = currency === null ? null : minorUnits(String(item.amount), currency, `${kind3} ${item.externalId}'s amount`);
42262
+ if (amount !== null && amount < 0)
42263
+ throw new CliError("validation_error", "an amount is 0 or more");
42264
+ if (item.status != null && !STAGE_OUTCOMES.includes(item.status))
42265
+ throw new CliError("validation_error", `${kind3} ${item.externalId}'s status is open, won or lost`);
42266
+ const status = item.status ?? String(stage.outcome);
42267
+ const closed = status === "open" ? null : day(item.closedDate, "a closed day") ?? new Date(epoch(item.updatedAt, at)).toISOString().slice(0, 10);
42268
+ const deal = kind3 === "lead" && item.deal ? database.prepare("SELECT id FROM deals WHERE account_id = ? AND external_id = ?").get(accountId, item.deal) : void 0;
42269
+ const metadata3 = {
42270
+ ...item.metadata ?? {},
42271
+ ...item.url ? { url: item.url } : {},
42272
+ ...item.assignee ? { assignee: crmIdentityId(key2, item.assignee, "user") } : {},
42273
+ ...item.closedReason && status !== "open" ? { closed_reason: textOf3(item.closedReason, 2e3) } : {}
42274
+ };
42275
+ const values = {
42276
+ title,
42277
+ organization: item.organization ? organizationIdOf(accountId, item.organization) : null,
42278
+ stage: Number(stage.id),
42279
+ status,
42280
+ currency,
42281
+ amount,
42282
+ close: day(item.closeDate, "an expected close day"),
42283
+ closed,
42284
+ metadata: Object.keys(metadata3).length ? JSON.stringify(metadata3) : null,
42285
+ created: epoch(item.createdAt, at),
42286
+ updated: epoch(item.updatedAt, at)
42287
+ };
42288
+ const table = TABLES[kind3];
42289
+ const held = database.prepare(`SELECT id FROM ${table} WHERE account_id = ? AND external_id = ?`).get(accountId, item.externalId);
42290
+ let id2;
42291
+ if (held) {
42292
+ id2 = Number(held.id);
42293
+ database.prepare(`UPDATE ${table} SET title = ?, organization_id = ?, stage_id = ?, status = ?, currency = ?, amount = ?, close_date = ?, closed_date = ?, metadata = ?, updated_at = ?, deleted_at = NULL` + (kind3 === "lead" ? ", deal_id = coalesce(?, deal_id)" : "") + " WHERE id = ?").run(values.title, values.organization, values.stage, values.status, values.currency, values.amount, values.close, values.closed, values.metadata, values.updated, ...kind3 === "lead" ? [deal ? Number(deal.id) : null] : [], id2);
42294
+ } else {
42295
+ const actor = author(key2);
42296
+ id2 = Number(database.prepare(`INSERT INTO ${table} (title, organization_id, stage_id, status, currency, amount, close_date, closed_date, account_id, external_id, author_type, author_id, source, metadata, created_at, updated_at` + (kind3 === "lead" ? ", deal_id" : "") + `) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?${kind3 === "lead" ? ", ?" : ""}) RETURNING id`).get(values.title, values.organization, values.stage, values.status, values.currency, values.amount, values.close, values.closed, accountId, item.externalId, actor.type, actor.id, SOURCE, values.metadata, values.created, values.updated, ...kind3 === "lead" ? [deal ? Number(deal.id) : null] : [])?.id);
42297
+ }
42298
+ database.prepare(`DELETE FROM links WHERE from_type = ? AND from_id = ? AND to_type = 'person' AND kind = ${linkKind("related-to")} AND source = ?`).run(kind3, id2, SOURCE);
42299
+ const link3 = database.prepare(`INSERT INTO links (from_type, from_id, to_type, to_id, kind, role, source, confirmed, created_at, author, updated_at) VALUES (?, ?, 'person', ?, ${linkKind("related-to")}, ?, ?, 1, ?, 'rule', ?)`);
42300
+ const seen = /* @__PURE__ */ new Set();
42301
+ for (const person2 of item.people ?? []) {
42302
+ const personId = personIdOf(key2, person2.externalId);
42303
+ const role = DEAL_ROLES.includes(person2.role) ? person2.role : "contact";
42304
+ if (personId === null || seen.has(personId))
42305
+ continue;
42306
+ seen.add(personId);
42307
+ link3.run(kind3, id2, personId, role, SOURCE, at, at);
42308
+ }
42309
+ return null;
42310
+ }, "saveItem");
42311
+ const saveItems = /* @__PURE__ */ __name((key2, kind3, items) => write(database, () => {
42312
+ const accountId = account(key2);
42313
+ const at = now2();
42314
+ const skipped = [];
42315
+ for (const item of items)
42316
+ try {
42317
+ const missing4 = saveItem(key2, accountId, kind3, item, at);
42318
+ if (missing4)
42319
+ skipped.push(missing4);
42320
+ } catch (error) {
42321
+ if (!(error instanceof CliError) || error.code !== "validation_error")
42322
+ throw error;
42323
+ skipped.push({ externalId: item.externalId, reason: "crm.item-invalid", message: error.message });
42324
+ }
42325
+ return { saved: items.length - skipped.length, skipped };
42326
+ }), "saveItems");
42327
+ const saveOrganizations = /* @__PURE__ */ __name((key2, organizations2) => write(database, () => {
42328
+ const accountId = account(key2);
42329
+ const at = now2();
42330
+ for (const organization2 of organizations2) {
42331
+ const name = textOf3(organization2.name, 200) ?? `${key2.provider} company ${organization2.externalId}`;
42332
+ const fields4 = {
42333
+ name,
42334
+ ...organization2.url ? { url: organization2.url } : {},
42335
+ ...organization2.metadata ?? {}
42336
+ };
42337
+ const fingerprint2 = recordFingerprint(fields4, []);
42338
+ const held = database.prepare("SELECT * FROM records WHERE account_id = ? AND type = 'organization' AND external_id = ?").get(accountId, organization2.externalId);
42339
+ const before2 = held ? JSON.parse(String(held.fields)).name : void 0;
42340
+ let entity = held?.entity_type === "organization" && held.entity_id != null ? Number(held.entity_id) : null;
42341
+ if (entity === null)
42342
+ entity = Number(database.prepare("INSERT INTO organizations (kind, name, scope, created_at, updated_at) VALUES ('company', ?, 'work', ?, ?) RETURNING id").get(name, at, at)?.id);
42343
+ else if (before2 !== name)
42344
+ database.prepare("UPDATE organizations SET name = ?, updated_at = ? WHERE id = ? AND name = ?").run(name, at, entity, typeof before2 === "string" ? before2 : name);
42345
+ if (held)
42346
+ database.prepare("UPDATE records SET fields = ?, fingerprint = ?, entity_type = 'organization', entity_id = ?, projected_fingerprint = ?, batch_id = ?, updated_at = ?, deleted_at = NULL WHERE id = ?").run(JSON.stringify(fields4), fingerprint2, entity, fingerprint2, SOURCE, at, Number(held.id));
42347
+ else
42348
+ database.prepare("INSERT INTO records (account_id, type, external_id, fields, fingerprint, entity_type, entity_id, projected_fingerprint, batch_id, created_at, updated_at) VALUES (?, 'organization', ?, ?, ?, 'organization', ?, ?, ?, ?, ?)").run(accountId, organization2.externalId, JSON.stringify(fields4), fingerprint2, entity, fingerprint2, SOURCE, at, at);
42349
+ }
42350
+ return { saved: organizations2.length, skipped: [] };
42351
+ }), "saveOrganizations");
42352
+ const stored3 = /* @__PURE__ */ __name((key2, kind3) => {
42353
+ const accountId = findAccountPk(context, key2);
42354
+ if (accountId === void 0 || kind3 === "person")
42355
+ return [];
42356
+ return kind3 === "organization" ? database.prepare("SELECT id, external_id, updated_at FROM records WHERE account_id = ? AND type = 'organization' AND deleted_at IS NULL").all(accountId) : database.prepare(`SELECT id, external_id, updated_at FROM ${TABLES[kind3]} WHERE account_id = ? AND deleted_at IS NULL`).all(accountId);
42357
+ }, "stored");
42358
+ const markDeleted2 = /* @__PURE__ */ __name((kind3, ids) => {
42359
+ const table = kind3 === "organization" ? "records" : TABLES[kind3];
42360
+ const mark = database.prepare(`UPDATE ${table} SET deleted_at = ? WHERE id = ?`);
42361
+ const at = now2();
42362
+ for (const id2 of ids)
42363
+ mark.run(at, id2);
42364
+ return ids.length;
42365
+ }, "markDeleted");
42366
+ return {
42367
+ savePipelines: /* @__PURE__ */ __name(async (key2, kind3, pipelines2) => savePipelines(key2, kind3, pipelines2), "savePipelines"),
42368
+ saveItems: /* @__PURE__ */ __name(async (key2, kind3, items) => saveItems(key2, kind3, items), "saveItems"),
42369
+ savePeople: /* @__PURE__ */ __name(async (key2, contacts2) => {
42370
+ await people2.savePeople(key2, contacts2.map((contact) => ({
42371
+ id: crmIdentityId(key2, contact.externalId),
42372
+ name: textOf3(contact.name, 200),
42373
+ email: textOf3(contact.email, 320)?.toLowerCase() ?? null,
42374
+ phone: textOf3(contact.phone, 64)
42375
+ })));
42376
+ return { saved: contacts2.length, skipped: [] };
42377
+ }, "savePeople"),
42378
+ saveOrganizations: /* @__PURE__ */ __name(async (key2, organizations2) => saveOrganizations(key2, organizations2), "saveOrganizations"),
42379
+ saveFields: /* @__PURE__ */ __name(async (key2, kind3, fields4) => saveFields(key2, kind3, fields4), "saveFields"),
42380
+ fields: /* @__PURE__ */ __name(async (key2, kind3) => fieldsOf3(key2, kind3), "fields"),
42381
+ remove: /* @__PURE__ */ __name(async (key2, kind3, externalIds) => write(database, () => {
42382
+ const gone = new Set(externalIds);
42383
+ return markDeleted2(kind3, stored3(key2, kind3).filter((row2) => gone.has(String(row2.external_id))).map((row2) => Number(row2.id)));
42384
+ }), "remove"),
42385
+ removeUnlisted: /* @__PURE__ */ __name(async (key2, kind3, listed, before2, { dryRun } = {}) => write(database, () => {
42386
+ const held = new Set(listed);
42387
+ const gone = stored3(key2, kind3).filter((row2) => !held.has(String(row2.external_id)) && Number(row2.updated_at) < before2).map((row2) => Number(row2.id));
42388
+ return dryRun ? gone.length : markDeleted2(kind3, gone);
42389
+ }), "removeUnlisted"),
42390
+ count: /* @__PURE__ */ __name(async (key2, kind3) => kind3 === "person" ? Number(database.prepare("SELECT count(*) AS n FROM identities WHERE provider = ? AND substr(external_id, 1, ?) = ?").get(key2.provider, key2.account.length + 1, `${key2.account}/`)?.n) : stored3(key2, kind3).length, "count"),
42391
+ refOf: /* @__PURE__ */ __name(async (key2, kind3, externalId) => {
42392
+ const accountId = findAccountPk(context, key2);
42393
+ const row2 = accountId === void 0 ? void 0 : database.prepare(`SELECT id FROM ${TABLES[kind3]} WHERE account_id = ? AND external_id = ?`).get(accountId, externalId);
42394
+ return row2 ? `${kind3}:${row2.id}` : null;
42395
+ }, "refOf")
42396
+ };
42397
+ }, "crmCopiesOver");
42398
+
42399
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/finance.js
41996
42400
  var refuse = /* @__PURE__ */ __name((message2, reason, code = "validation_error") => {
41997
42401
  throw new CliError(code, message2, { reason });
41998
42402
  }, "refuse");
@@ -42453,9 +42857,9 @@ var financeStoreOver = /* @__PURE__ */ __name((context) => {
42453
42857
  };
42454
42858
  }, "financeStoreOver");
42455
42859
 
42456
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/deals.js
42457
- var TABLES = { deal: "deals", lead: "leads" };
42458
- var itemsSql = /* @__PURE__ */ __name((kind3) => `SELECT d.*, s.name AS stage_name, s.pipeline_id, p.name AS pipeline_name, b.name AS author_name, b.kind AS author_kind, a.provider AS account_provider, a.external_id AS account_external_id FROM ${TABLES[kind3]} d JOIN pipeline_stages s ON s.id = d.stage_id JOIN pipelines p ON p.id = s.pipeline_id LEFT JOIN bots b ON d.author_type = 'bot' AND b.id = d.author_id LEFT JOIN accounts a ON a.id = d.account_id`, "itemsSql");
42860
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/deals.js
42861
+ var TABLES2 = { deal: "deals", lead: "leads" };
42862
+ var itemsSql = /* @__PURE__ */ __name((kind3) => `SELECT d.*, s.name AS stage_name, s.pipeline_id, p.name AS pipeline_name, b.name AS author_name, b.kind AS author_kind, a.provider AS account_provider, a.external_id AS account_external_id FROM ${TABLES2[kind3]} d JOIN pipeline_stages s ON s.id = d.stage_id JOIN pipelines p ON p.id = s.pipeline_id LEFT JOIN bots b ON d.author_type = 'bot' AND b.id = d.author_id LEFT JOIN accounts a ON a.id = d.account_id`, "itemsSql");
42459
42863
  var MAX_STAGES = 30;
42460
42864
  var MAX_PEOPLE = 20;
42461
42865
  var iso9 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
@@ -42469,6 +42873,16 @@ var jsonField = /* @__PURE__ */ __name((metadata3, key2) => {
42469
42873
  return null;
42470
42874
  }
42471
42875
  }, "jsonField");
42876
+ var isValue = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value) && "label" in value && "value" in value, "isValue");
42877
+ var providerMetadataOf = /* @__PURE__ */ __name((metadata3) => {
42878
+ if (metadata3 == null)
42879
+ return {};
42880
+ try {
42881
+ return Object.fromEntries(Object.entries(JSON.parse(String(metadata3))).filter(([, value]) => isValue(value)));
42882
+ } catch {
42883
+ return {};
42884
+ }
42885
+ }, "providerMetadataOf");
42472
42886
  var accountOf3 = /* @__PURE__ */ __name((provider, external) => provider == null ? null : { provider: String(provider), account: String(external) }, "accountOf");
42473
42887
  var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42474
42888
  const { database, now: now2 } = context;
@@ -42506,6 +42920,8 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42506
42920
  deal: row2.deal_id == null ? null : `deal:${row2.deal_id}`,
42507
42921
  account: accountOf3(row2.account_provider, row2.account_external_id),
42508
42922
  externalId: row2.external_id == null ? null : String(row2.external_id),
42923
+ assignee: jsonField(row2.metadata, "assignee"),
42924
+ providerMetadata: providerMetadataOf(row2.metadata),
42509
42925
  people: peopleOf(kind3, fields4.id),
42510
42926
  author: authorOf(row2),
42511
42927
  model: row2.model == null ? null : String(row2.model),
@@ -42527,18 +42943,19 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42527
42943
  const { kind: kind3, row: row2 } = rowOf2(reference2);
42528
42944
  return itemOf(kind3)(row2);
42529
42945
  }, "read");
42946
+ const inScope = /* @__PURE__ */ __name((scope3, row2) => scope3 === void 0 || (scope3 === "own" ? row2.account_id == null : row2.account_provider === scope3.provider && row2.account_external_id === scope3.account), "inScope");
42530
42947
  const kindOf4 = /* @__PURE__ */ __name((kind3) => kind3 === void 0 ? "deal" : oneOf4(kind3, DEAL_KINDS, "a kind"), "kindOf");
42531
- const pipelineRows = /* @__PURE__ */ __name((kind3) => database.prepare("SELECT p.*, a.provider AS account_provider, a.external_id AS account_external_id FROM pipelines p LEFT JOIN accounts a ON a.id = p.account_id WHERE (? IS NULL OR p.kind = ?) ORDER BY p.name_folded, p.id").all(kind3 ?? null, kind3 ?? null), "pipelineRows");
42948
+ const pipelineRows = /* @__PURE__ */ __name((kind3, scope3, { deleted = false } = {}) => database.prepare(`SELECT p.*, a.provider AS account_provider, a.external_id AS account_external_id FROM pipelines p LEFT JOIN accounts a ON a.id = p.account_id WHERE (? IS NULL OR p.kind = ?) ${deleted ? "" : "AND p.deleted_at IS NULL "}ORDER BY p.name_folded, p.id`).all(kind3 ?? null, kind3 ?? null).filter((row2) => inScope(scope3, row2)), "pipelineRows");
42532
42949
  const label = /* @__PURE__ */ __name((row2) => `pipeline:${row2.id} (${row2.name}${row2.account_provider == null ? "" : `, ${row2.account_provider}:${row2.account_external_id}`})`, "label");
42533
- const pipelineRow = /* @__PURE__ */ __name((reference2, kind3) => {
42950
+ const pipelineRow = /* @__PURE__ */ __name((reference2, kind3, scope3) => {
42534
42951
  const named2 = reference2.trim();
42535
42952
  if (/^pipeline:\d+$/.test(named2)) {
42536
- const row2 = pipelineRows(kind3).find((one2) => `pipeline:${one2.id}` === named2);
42953
+ const row2 = pipelineRows(kind3, scope3, { deleted: true }).find((one2) => `pipeline:${one2.id}` === named2);
42537
42954
  if (!row2)
42538
42955
  throw new CliError("not_found", `no ${kind3 ?? ""} pipeline ${named2}`, { reason: "pipeline.not-found" });
42539
42956
  return row2;
42540
42957
  }
42541
- const rows = pipelineRows(kind3).filter((one2) => one2.name_folded === fold(named2));
42958
+ const rows = pipelineRows(kind3, scope3).filter((one2) => one2.name_folded === fold(named2));
42542
42959
  if (rows.length === 0)
42543
42960
  throw new CliError("not_found", `no ${kind3 === void 0 ? "" : `${kind3} `}pipeline named ${named2}`, {
42544
42961
  reason: "pipeline.not-found"
@@ -42568,7 +42985,7 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42568
42985
  }));
42569
42986
  }, "pipelinesOf");
42570
42987
  const stageRow = /* @__PURE__ */ __name((stage, kind3, pipeline) => {
42571
- const rows = database.prepare("SELECT s.*, p.name AS pipeline_name FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.name_folded = ? AND p.kind = ? AND (? IS NULL OR p.id = ?) ORDER BY p.id").all(fold(stage.trim()), kind3, pipeline ?? null, pipeline ?? null);
42988
+ const rows = database.prepare("SELECT s.*, p.name AS pipeline_name FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.name_folded = ? AND p.kind = ? AND (? IS NULL OR p.id = ?) AND (? IS NOT NULL OR p.account_id IS NULL) ORDER BY p.id").all(fold(stage.trim()), kind3, pipeline ?? null, pipeline ?? null, pipeline ?? null);
42572
42989
  if (rows.length === 0)
42573
42990
  return refuse(`no stage named ${stage} in ${pipeline === void 0 ? `a ${kind3} pipeline` : "that pipeline"}`, "deal.stage");
42574
42991
  if (rows.length > 1)
@@ -42576,7 +42993,7 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42576
42993
  return rows[0];
42577
42994
  }, "stageRow");
42578
42995
  const firstStage = /* @__PURE__ */ __name((kind3, pipeline) => {
42579
- const pipelines2 = pipeline === void 0 ? pipelineRows(kind3) : [{ id: pipeline }];
42996
+ const pipelines2 = pipeline === void 0 ? pipelineRows(kind3, "own") : [{ id: pipeline }];
42580
42997
  if (pipelines2.length !== 1)
42581
42998
  return refuse(`name the stage: ${pipelines2.length === 0 ? `no ${kind3} pipeline is stored` : `more than one ${kind3} pipeline is stored`}`, "deal.stage");
42582
42999
  const row2 = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ? ORDER BY position, id LIMIT 1").get(Number(pipelines2[0]?.id));
@@ -42585,7 +43002,7 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42585
43002
  const funnelOf = /* @__PURE__ */ __name((pipeline, since) => {
42586
43003
  const kind3 = pipeline.kind;
42587
43004
  const cutoff = since === null ? null : Date.parse(`${since}T00:00:00Z`);
42588
- const items = database.prepare(`SELECT d.id, d.status, d.stage_id FROM ${TABLES[kind3]} d JOIN pipeline_stages s ON s.id = d.stage_id WHERE s.pipeline_id = ? AND d.deleted_at IS NULL AND (? IS NULL OR d.created_at >= ?)`).all(Number(pipeline.id), cutoff, cutoff);
43005
+ const items = database.prepare(`SELECT d.id, d.status, d.stage_id FROM ${TABLES2[kind3]} d JOIN pipeline_stages s ON s.id = d.stage_id WHERE s.pipeline_id = ? AND d.deleted_at IS NULL AND (? IS NULL OR d.created_at >= ?)`).all(Number(pipeline.id), cutoff, cutoff);
42589
43006
  const stages = database.prepare("SELECT id, position, outcome FROM pipeline_stages WHERE pipeline_id = ? ORDER BY position, id").all(Number(pipeline.id));
42590
43007
  const order = new Map(stages.map((stage, at) => [Number(stage.id), at]));
42591
43008
  const lostStage = new Set(stages.filter((stage) => stage.outcome === "lost").map((stage) => Number(stage.id)));
@@ -42624,11 +43041,13 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42624
43041
  };
42625
43042
  }, "funnelOf");
42626
43043
  const setStage = /* @__PURE__ */ __name((kind3, id2, stage, status, date3) => {
42627
- database.prepare(`UPDATE ${TABLES[kind3]} SET stage_id = ?, status = ?, closed_date = ?, updated_at = ? WHERE id = ?`).run(Number(stage.id), status, status === "open" ? null : date3, now2(), id2);
43044
+ database.prepare(`UPDATE ${TABLES2[kind3]} SET stage_id = ?, status = ?, closed_date = ?, updated_at = ? WHERE id = ?`).run(Number(stage.id), status, status === "open" ? null : date3, now2(), id2);
42628
43045
  }, "setStage");
42629
43046
  const notDeleted = /* @__PURE__ */ __name((row2, kind3, what) => {
42630
43047
  if (row2.deleted_at != null)
42631
43048
  refuse(`${kind3}:${row2.id} is deleted; it no longer ${what}`, "deal.closed");
43049
+ if (row2.account_id != null)
43050
+ refuse(`${kind3}:${row2.id} is a copy from ${row2.account_provider}:${row2.account_external_id}; change it there, and its next sync brings the change here`, "deal.copy");
42632
43051
  }, "notDeleted");
42633
43052
  return {
42634
43053
  addPipeline: /* @__PURE__ */ __name(({ name, kind: kind3, stages, by }) => {
@@ -42657,13 +43076,13 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42657
43076
  });
42658
43077
  return made;
42659
43078
  });
42660
- return pipelinesOf(pipelineRows(pipelineKind).filter((row2) => Number(row2.id) === id2))[0];
43079
+ return pipelinesOf(pipelineRows(pipelineKind, void 0, { deleted: true }).filter((row2) => Number(row2.id) === id2))[0];
42661
43080
  }, "addPipeline"),
42662
- pipelines: /* @__PURE__ */ __name((filter = {}) => pipelinesOf(pipelineRows(filter.kind === void 0 ? void 0 : kindOf4(filter.kind))), "pipelines"),
43081
+ pipelines: /* @__PURE__ */ __name((filter = {}) => pipelinesOf(pipelineRows(filter.kind === void 0 ? void 0 : kindOf4(filter.kind), filter.account)), "pipelines"),
42663
43082
  pipeline: /* @__PURE__ */ __name((reference2, options = {}) => {
42664
43083
  const kind3 = options.kind === void 0 ? void 0 : kindOf4(options.kind);
42665
43084
  const since = isoDate(options.since, "the first day counted");
42666
- return funnelOf(pipelinesOf([pipelineRow(reference2, kind3)])[0], since);
43085
+ return funnelOf(pipelinesOf([pipelineRow(reference2, kind3, options.account)])[0], since);
42667
43086
  }, "pipeline"),
42668
43087
  add: /* @__PURE__ */ __name((input) => {
42669
43088
  const kind3 = kindOf4(input.kind);
@@ -42685,7 +43104,7 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42685
43104
  if (!Array.isArray(evidence) || evidence.length > 8)
42686
43105
  refuse("evidence is at most 8 references", "deal.field");
42687
43106
  const id2 = write(database, () => {
42688
- const pipeline = input.pipeline === void 0 ? void 0 : Number(pipelineRow(input.pipeline, kind3).id);
43107
+ const pipeline = input.pipeline === void 0 ? void 0 : Number(pipelineRow(input.pipeline, kind3, "own").id);
42689
43108
  const stageText = text3(input.stage, "a stage's name", 80);
42690
43109
  const stage = stageText === null ? kind3 === "lead" ? firstStage(kind3, pipeline) : refuse("a deal starts in a stage", "deal.field") : stageRow(stageText, kind3, pipeline);
42691
43110
  const status = stage.outcome ?? "open";
@@ -42700,7 +43119,7 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42700
43119
  });
42701
43120
  const { actor, model } = authorActor(context, input.by);
42702
43121
  const at = now2();
42703
- const made = Number(database.prepare(`INSERT INTO ${TABLES[kind3]} (title, organization_id, project_id, stage_id, status, currency, amount, close_date, closed_date, author_type, author_id, model, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id`).get(title, organization2?.id ?? null, input.project === void 0 ? null : projectId(database, input.project), Number(stage.id), status, currency, amount, closeDate, status === "open" ? null : today(), actor.type, actor.id, model, source2, reason === null ? null : JSON.stringify({ reason }), at, at)?.id);
43122
+ const made = Number(database.prepare(`INSERT INTO ${TABLES2[kind3]} (title, organization_id, project_id, stage_id, status, currency, amount, close_date, closed_date, author_type, author_id, model, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id`).get(title, organization2?.id ?? null, input.project === void 0 ? null : projectId(database, input.project), Number(stage.id), status, currency, amount, closeDate, status === "open" ? null : today(), actor.type, actor.id, model, source2, reason === null ? null : JSON.stringify({ reason }), at, at)?.id);
42704
43123
  const link3 = database.prepare(`INSERT INTO links (from_type, from_id, to_type, to_id, kind, role, source, confirmed, created_at, author, updated_at) VALUES (?, ?, 'person', ?, ${linkKind("related-to")}, ?, ?, 1, ?, ?, ?)`);
42705
43124
  for (const person2 of persons2)
42706
43125
  link3.run(kind3, made, person2.id, person2.role, owner ? "owner" : "suggested", at, owner ? "owner" : "agent", at);
@@ -42718,17 +43137,21 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42718
43137
  const by = proposedBySql("d.author_type", "d.author_id", filter.proposedBy);
42719
43138
  const status = filter.status === void 0 ? null : oneOf4(filter.status, DEAL_STATUSES, "a status");
42720
43139
  const stage = filter.stage === void 0 ? null : fold(filter.stage.trim());
42721
- const pipeline = filter.pipeline === void 0 ? null : Number(pipelineRow(filter.pipeline, kind3).id);
43140
+ const pipeline = filter.pipeline === void 0 ? null : Number(pipelineRow(filter.pipeline, kind3, filter.account).id);
43141
+ const scope3 = filter.account;
43142
+ const own = scope3 === "own" ? 1 : 0;
43143
+ const provider = scope3 === void 0 || scope3 === "own" ? null : scope3.provider;
43144
+ const account = scope3 === void 0 || scope3 === "own" ? null : scope3.account;
42722
43145
  const limit = Math.min(Math.max(filter.limit ?? 100, 1), 500);
42723
- return database.prepare(`${itemsSql(kind3)} WHERE d.deleted_at IS NULL AND (? IS NULL OR d.status = ?) AND (? IS NULL OR d.project_id = ?) AND (? IS NULL OR s.name_folded = ?) AND (? IS NULL OR p.id = ?) AND (? IS NULL OR d.organization_id = ?) AND ${by.sql} ORDER BY d.created_at DESC, d.id DESC LIMIT ?`).all(status, status, project2, project2, stage, stage, pipeline, pipeline, organization2?.id ?? null, organization2?.id ?? null, ...by.params, limit).map(itemOf(kind3));
43146
+ return database.prepare(`${itemsSql(kind3)} WHERE d.deleted_at IS NULL AND (? IS NULL OR d.status = ?) AND (? IS NULL OR d.project_id = ?) AND (? IS NULL OR s.name_folded = ?) AND (? IS NULL OR p.id = ?) AND (? IS NULL OR d.organization_id = ?) AND (? = 0 OR d.account_id IS NULL) AND (? IS NULL OR (a.provider = ? AND a.external_id = ?)) AND ${by.sql} ORDER BY d.created_at DESC, d.id DESC LIMIT ? OFFSET ?`).all(status, status, project2, project2, stage, stage, pipeline, pipeline, organization2?.id ?? null, organization2?.id ?? null, own, provider, provider, account, ...by.params, limit, Math.max(0, Math.trunc(filter.offset ?? 0))).map(itemOf(kind3));
42724
43147
  }, "list"),
42725
- find: /* @__PURE__ */ __name(({ words: words3, anyWord, accounts: accounts2, limit }) => {
43148
+ find: /* @__PURE__ */ __name(({ words: words3, anyWord, accounts: accounts2, kinds: kinds2 = DEAL_KINDS, limit }) => {
42726
43149
  const wanted = [...new Set(words3.map((word2) => fold(word2).trim()).filter(Boolean))];
42727
43150
  if (!wanted.length)
42728
43151
  return [];
42729
43152
  const most = Math.min(Math.max(limit ?? 100, 1), 500);
42730
43153
  const within = accounts2?.map(({ provider, account }) => `${provider}\0${account}`);
42731
- const found2 = DEAL_KINDS.flatMap((kind3) => database.prepare(`SELECT d.id, d.title, d.updated_at, a.provider, a.external_id AS account FROM ${TABLES[kind3]} d LEFT JOIN accounts a ON a.id = d.account_id WHERE d.deleted_at IS NULL`).all().filter((row2) => within === void 0 || within.includes(`${row2.provider}\0${row2.account}`)).map((row2) => {
43154
+ const found2 = kinds2.flatMap((kind3) => database.prepare(`SELECT d.id, d.title, d.updated_at, a.provider, a.external_id AS account FROM ${TABLES2[kind3]} d LEFT JOIN accounts a ON a.id = d.account_id WHERE d.deleted_at IS NULL`).all().filter((row2) => within === void 0 || within.includes(`${row2.provider}\0${row2.account}`)).map((row2) => {
42732
43155
  const title = fold(String(row2.title));
42733
43156
  return { kind: kind3, row: row2, score: wanted.filter((word2) => title.includes(word2)).length };
42734
43157
  }).filter(({ score }) => anyWord ? score > 0 : score === wanted.length));
@@ -42745,15 +43168,15 @@ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
42745
43168
  close: /* @__PURE__ */ __name((reference2, { status, date: date3, reason, by }) => {
42746
43169
  authorActor(context, by);
42747
43170
  const outcome = oneOf4(status, ["won", "lost"], "a closed status");
42748
- const day = isoDate(date3, "the day it closed") ?? today();
43171
+ const day2 = isoDate(date3, "the day it closed") ?? today();
42749
43172
  const why = text3(reason, "why it closed", 2e3);
42750
43173
  const { kind: kind3, row: row2 } = rowOf2(reference2);
42751
43174
  notDeleted(row2, kind3, "closes");
42752
43175
  const stage = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ? AND outcome = ? ORDER BY position, id LIMIT 1").get(Number(row2.pipeline_id), outcome) ?? { id: row2.stage_id };
42753
43176
  write(database, () => {
42754
- setStage(kind3, Number(row2.id), stage, outcome, day);
43177
+ setStage(kind3, Number(row2.id), stage, outcome, day2);
42755
43178
  if (why !== null)
42756
- database.prepare(`UPDATE ${TABLES[kind3]} SET metadata = json_set(coalesce(metadata, '{}'), '$.closed_reason', ?) WHERE id = ?`).run(why, Number(row2.id));
43179
+ database.prepare(`UPDATE ${TABLES2[kind3]} SET metadata = json_set(coalesce(metadata, '{}'), '$.closed_reason', ?) WHERE id = ?`).run(why, Number(row2.id));
42757
43180
  });
42758
43181
  return read2(`${kind3}:${row2.id}`);
42759
43182
  }, "close")
@@ -42774,7 +43197,120 @@ var dealsStoreOver = /* @__PURE__ */ __name((context) => {
42774
43197
  };
42775
43198
  }, "dealsStoreOver");
42776
43199
 
42777
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
43200
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/decision-requests.js
43201
+ import { createHash as createHash12, randomBytes as randomBytes2 } from "node:crypto";
43202
+
43203
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/decision-requests.js
43204
+ var DECISION_ACTIONS = ["confirm", "reject", "ask-confirm", "ask-reject", "back", "later"];
43205
+ var DECISION_TTL_MS = 72 * 60 * 60 * 1e3;
43206
+ var CALLBACK_PREFIX = "wcr1:";
43207
+ var TOKEN2 = /^[A-Za-z0-9_-]{21}[AQgw]$/;
43208
+ var CALLBACK = /^wcr1:([A-Za-z0-9_-]{21}[AQgw])$/;
43209
+ var isDecisionToken = /* @__PURE__ */ __name((value) => typeof value === "string" && TOKEN2.test(value), "isDecisionToken");
43210
+ var callbackDataOf = /* @__PURE__ */ __name((token) => {
43211
+ if (!isDecisionToken(token))
43212
+ throw new TypeError("not a decision token");
43213
+ return `${CALLBACK_PREFIX}${token}`;
43214
+ }, "callbackDataOf");
43215
+ var parseCallbackData = /* @__PURE__ */ __name((data) => typeof data === "string" ? CALLBACK.exec(data)?.[1] : void 0, "parseCallbackData");
43216
+
43217
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/decision-requests.js
43218
+ var digestOf = /* @__PURE__ */ __name((token) => createHash12("sha256").update(token).digest("hex"), "digestOf");
43219
+ var newToken = /* @__PURE__ */ __name(() => randomBytes2(16).toString("base64url"), "newToken");
43220
+ var requestOf = /* @__PURE__ */ __name((row2) => ({
43221
+ proposalId: row2.proposal_id,
43222
+ action: row2.action,
43223
+ batchDigest: row2.batch_digest,
43224
+ channel: row2.channel,
43225
+ botProfile: row2.bot_profile,
43226
+ chatId: row2.chat_id,
43227
+ messageId: row2.message_id,
43228
+ ownerUserId: row2.owner_user_id,
43229
+ createdAt: row2.created_at,
43230
+ expiresAt: row2.expires_at
43231
+ }), "requestOf");
43232
+ var PRUNE_AFTER_MS = 30 * 24 * 60 * 60 * 1e3;
43233
+ var SAME_MESSAGE = "channel=? AND bot_profile=? AND chat_id=? AND message_id=?";
43234
+ var OPEN2 = "used_at IS NULL AND cancelled_at IS NULL";
43235
+ var decisionRequestStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
43236
+ const refusal2 = /* @__PURE__ */ __name((row2, at) => {
43237
+ if (!row2)
43238
+ return "decision.token-unknown";
43239
+ if (row2.used_at !== null)
43240
+ return "decision.token-used";
43241
+ if (row2.cancelled_at !== null)
43242
+ return "decision.token-cancelled";
43243
+ if (row2.expires_at <= at)
43244
+ return "decision.token-expired";
43245
+ return void 0;
43246
+ }, "refusal");
43247
+ return {
43248
+ create: /* @__PURE__ */ __name((input) => {
43249
+ const { actions, ...fields4 } = input;
43250
+ const text6 = [
43251
+ fields4.proposalId,
43252
+ fields4.batchDigest,
43253
+ fields4.channel,
43254
+ fields4.botProfile,
43255
+ fields4.chatId,
43256
+ fields4.messageId,
43257
+ fields4.ownerUserId
43258
+ ];
43259
+ if (text6.some((value) => typeof value !== "string" || value === ""))
43260
+ throw new CliError("validation_error", "a decision request needs its batch, message and owner", {
43261
+ reason: "decision.request-invalid"
43262
+ });
43263
+ if (actions.length === 0 || new Set(actions).size !== actions.length || actions.some((action) => !DECISION_ACTIONS.includes(action)))
43264
+ throw new CliError("validation_error", "a decision request needs distinct, known actions", {
43265
+ reason: "decision.request-invalid"
43266
+ });
43267
+ const at = now2();
43268
+ return write(database, () => actions.map((action) => {
43269
+ const token = newToken();
43270
+ database.prepare(`INSERT INTO decision_requests (token_digest, proposal_id, action, batch_digest, channel, bot_profile,
43271
+ chat_id, message_id, owner_user_id, created_at, expires_at) VALUES (?,?,?,?,?,?,?,?,?,?,?)`).run(digestOf(token), fields4.proposalId, action, fields4.batchDigest, fields4.channel, fields4.botProfile, fields4.chatId, fields4.messageId, fields4.ownerUserId, at, at + DECISION_TTL_MS);
43272
+ return { action, token };
43273
+ }));
43274
+ }, "create"),
43275
+ take: /* @__PURE__ */ __name((token, expect) => {
43276
+ if (!isDecisionToken(token))
43277
+ return { ok: false, reason: "decision.token-unknown" };
43278
+ const digest = digestOf(token);
43279
+ return write(database, () => {
43280
+ const at = now2();
43281
+ const row2 = database.prepare("SELECT * FROM decision_requests WHERE token_digest=?").get(digest);
43282
+ if (!row2)
43283
+ return { ok: false, reason: "decision.token-unknown" };
43284
+ if (expect.botProfile !== row2.bot_profile || expect.chatId !== row2.chat_id || expect.messageId !== row2.message_id || expect.ownerUserId !== row2.owner_user_id)
43285
+ return { ok: false, reason: "decision.token-mismatch" };
43286
+ const reason = refusal2(row2, at);
43287
+ if (reason)
43288
+ return { ok: false, reason };
43289
+ database.prepare("UPDATE decision_requests SET used_at=? WHERE id=?").run(at, row2.id);
43290
+ const { changes } = database.prepare(`UPDATE decision_requests SET cancelled_at=? WHERE ${SAME_MESSAGE} AND id<>? AND ${OPEN2}`).run(at, row2.channel, row2.bot_profile, row2.chat_id, row2.message_id, row2.id);
43291
+ return { ok: true, request: requestOf(row2), cancelled: Number(changes) };
43292
+ });
43293
+ }, "take"),
43294
+ cancelOpen: /* @__PURE__ */ __name((scope3 = {}) => {
43295
+ const filters = [];
43296
+ const values = [];
43297
+ if (scope3.channel !== void 0) {
43298
+ filters.push("channel=?");
43299
+ values.push(scope3.channel);
43300
+ }
43301
+ if (scope3.botProfile !== void 0) {
43302
+ filters.push("bot_profile=?");
43303
+ values.push(scope3.botProfile);
43304
+ }
43305
+ const where = [OPEN2, ...filters].join(" AND ");
43306
+ return write(database, () => Number(database.prepare(`UPDATE decision_requests SET cancelled_at=? WHERE ${where}`).run(now2(), ...values).changes));
43307
+ }, "cancelOpen"),
43308
+ prune: /* @__PURE__ */ __name((at = now2()) => write(database, () => Number(database.prepare(`DELETE FROM decision_requests WHERE expires_at < ?1 OR used_at < ?1 OR cancelled_at < ?1`).run(at - PRUNE_AFTER_MS).changes)), "prune"),
43309
+ open: /* @__PURE__ */ __name((message2) => database.prepare(`SELECT * FROM decision_requests WHERE ${SAME_MESSAGE} AND ${OPEN2} AND expires_at>? ORDER BY id`).all(message2.channel, message2.botProfile, message2.chatId, message2.messageId, now2()).map(requestOf), "open")
43310
+ };
43311
+ }, "decisionRequestStoreOver");
43312
+
43313
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
42778
43314
  var NOTE_FIELDS = [
42779
43315
  "text",
42780
43316
  "exact",
@@ -43084,7 +43620,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
43084
43620
  drain();
43085
43621
  const scope3 = live2(void 0, void 0);
43086
43622
  const texts2 = /* @__PURE__ */ new Map();
43087
- const textOf5 = /* @__PURE__ */ __name((owner) => {
43623
+ const textOf6 = /* @__PURE__ */ __name((owner) => {
43088
43624
  if (!texts2.has(owner)) {
43089
43625
  const [type, id2] = owner.split(":");
43090
43626
  const note2 = read2(String(type), Number(id2));
@@ -43097,7 +43633,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
43097
43633
  WHERE k.content_hash > ?${scope3.sql}
43098
43634
  AND NOT EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ? AND v.content_hash = k.content_hash)
43099
43635
  GROUP BY k.content_hash ORDER BY k.content_hash LIMIT ?`).all(after2 ?? "", ...scope3.params, model, limit).flatMap((row2) => {
43100
- const text6 = textOf5(String(row2.owner));
43636
+ const text6 = textOf6(String(row2.owner));
43101
43637
  return text6 === void 0 ? [] : [{ hash: String(row2.hash), text: text6.slice(Number(row2.start), Number(row2.end)) }];
43102
43638
  });
43103
43639
  }, "chunksToEmbed"),
@@ -43204,7 +43740,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
43204
43740
  };
43205
43741
  }, "noteSearchOver");
43206
43742
 
43207
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
43743
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
43208
43744
  var EVENT_FIELDS = ["text", "exact", "body", "title", "date", "in"];
43209
43745
  var inEventAccounts = /* @__PURE__ */ __name((event) => searchableCopy(event, "c.account_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))"), "inEventAccounts");
43210
43746
  var EVENT_CORPUS = {
@@ -43336,7 +43872,7 @@ var eventSearchOver = /* @__PURE__ */ __name((context) => {
43336
43872
  };
43337
43873
  }, "eventSearchOver");
43338
43874
 
43339
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-entries.js
43875
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-entries.js
43340
43876
  var refuse2 = /* @__PURE__ */ __name((message2, reason) => {
43341
43877
  throw new CliError("validation_error", message2, { reason });
43342
43878
  }, "refuse");
@@ -43414,7 +43950,7 @@ var paymentEntriesOver = /* @__PURE__ */ __name((context) => {
43414
43950
  };
43415
43951
  }, "paymentEntriesOver");
43416
43952
 
43417
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
43953
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
43418
43954
  var EVIDENCE_FINDINGS_KIND = "evidence_findings";
43419
43955
  var reference = /* @__PURE__ */ __name((raw) => {
43420
43956
  if (/^(document|note):[1-9]\d*$/.test(raw))
@@ -43440,7 +43976,7 @@ var validateEvidenceFindings = /* @__PURE__ */ __name((input) => {
43440
43976
  return valid;
43441
43977
  }, "validateEvidenceFindings");
43442
43978
 
43443
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/domain/moment.js
43979
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/domain/moment.js
43444
43980
  var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false } = {}) => {
43445
43981
  try {
43446
43982
  return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
@@ -43452,7 +43988,7 @@ var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false
43452
43988
  }
43453
43989
  }, "calendarMoment");
43454
43990
 
43455
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
43991
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
43456
43992
  var NAMED3 = "SELECT f.*, b.name AS author_name, b.kind AS author_kind FROM facts f LEFT JOIN bots b ON f.author_type = 'bot' AND b.id = f.author_id";
43457
43993
  var iso10 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
43458
43994
  var oneOf5 = /* @__PURE__ */ __name((value, allowed, what) => {
@@ -43661,7 +44197,7 @@ var factsStoreOver = /* @__PURE__ */ __name((context) => {
43661
44197
  };
43662
44198
  }, "factsStoreOver");
43663
44199
 
43664
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
44200
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
43665
44201
  var invalid2 = /* @__PURE__ */ __name((message2) => {
43666
44202
  throw new CliError("validation_error", message2);
43667
44203
  }, "invalid");
@@ -43765,7 +44301,7 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind3) => {
43765
44301
  return { snapshot: snapshot2, snapshotParts, previous, outcomes, create };
43766
44302
  }, "findingsCoreOver");
43767
44303
 
43768
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
44304
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
43769
44305
  var PROPOSAL_STATUSES = ["proposed", "approved", "rejected", "executed", "failed"];
43770
44306
  var PROPOSAL_VERDICTS = ["useful", "not_useful"];
43771
44307
  var iso11 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
@@ -43930,7 +44466,7 @@ var proposedActionsStoreOver = /* @__PURE__ */ __name((context) => {
43930
44466
  };
43931
44467
  }, "proposedActionsStoreOver");
43932
44468
 
43933
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
44469
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
43934
44470
  var stale = /* @__PURE__ */ __name(() => {
43935
44471
  throw new CliError("validation_error", "evidence findings changed since they were read; stage a new batch", {
43936
44472
  reason: "evidence-findings.stale"
@@ -44111,7 +44647,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
44111
44647
  };
44112
44648
  }, "evidenceFindingsStoreOver");
44113
44649
 
44114
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
44650
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
44115
44651
  var pendingInvolvements = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM involvement_pending").get()?.n ?? 0), "pendingInvolvements");
44116
44652
  var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => ({
44117
44653
  rebuild: /* @__PURE__ */ __name((personId) => write(database, () => {
@@ -44164,8 +44700,8 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
44164
44700
  }, "forPerson")
44165
44701
  }), "involvementStoreOver");
44166
44702
 
44167
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
44168
- import { createHash as createHash12 } from "node:crypto";
44703
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
44704
+ import { createHash as createHash13 } from "node:crypto";
44169
44705
  var fields3 = "id,from_id,to_id,source,confirmed,updated_at,length(evidence) AS evidenceLength,substr(evidence,1,2000) AS evidence";
44170
44706
  var id = /* @__PURE__ */ __name((value) => {
44171
44707
  if (typeof value !== "string" || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
@@ -44194,7 +44730,7 @@ var meetingProjectsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 })
44194
44730
  project: `project:${row2.to_id}`,
44195
44731
  confirmed: Number(row2.confirmed) === 1,
44196
44732
  provenance: row2.evidence == null ? null : String(row2.evidence),
44197
- fingerprint: createHash12("sha256").update(JSON.stringify([row2.id, row2.from_id, row2.to_id, row2.source, row2.confirmed, row2.evidence, row2.updated_at])).digest("hex")
44733
+ fingerprint: createHash13("sha256").update(JSON.stringify([row2.id, row2.from_id, row2.to_id, row2.source, row2.confirmed, row2.evidence, row2.updated_at])).digest("hex")
44198
44734
  };
44199
44735
  }, "linkOf");
44200
44736
  return {
@@ -44250,7 +44786,7 @@ var meetingProjectsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 })
44250
44786
  };
44251
44787
  }, "meetingProjectsStoreOver");
44252
44788
 
44253
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
44789
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
44254
44790
  var ORGANIZATIONS_QUERY = {
44255
44791
  entity: "organization",
44256
44792
  backend: "sql",
@@ -44291,7 +44827,7 @@ var REMINDERS_QUERY = {
44291
44827
  })
44292
44828
  };
44293
44829
 
44294
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/organizations.js
44830
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/organizations.js
44295
44831
  var organizationOf = /* @__PURE__ */ __name((row2) => ({
44296
44832
  id: String(row2.id),
44297
44833
  ref: `organization:${row2.id}`,
@@ -44324,7 +44860,7 @@ var organizationsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) =>
44324
44860
  }), "updateOrganization")
44325
44861
  }), "organizationsStoreOver");
44326
44862
 
44327
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/relation-proposals.js
44863
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/relation-proposals.js
44328
44864
  var relationOf = /* @__PURE__ */ __name((link3) => ({
44329
44865
  id: link3.id,
44330
44866
  from: link3.from,
@@ -44550,16 +45086,16 @@ var decidedOrigin = /* @__PURE__ */ __name((by) => by === "owner" ? { origin: "o
44550
45086
  provenance: `agent:${by.bot} for the owner: ${by.reason.trim()}`
44551
45087
  }, "decidedOrigin");
44552
45088
 
44553
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
45089
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
45090
+ import { createHash as createHash16 } from "node:crypto";
45091
+
45092
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
44554
45093
  import { createHash as createHash15 } from "node:crypto";
44555
45094
 
44556
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
45095
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
44557
45096
  import { createHash as createHash14 } from "node:crypto";
44558
45097
 
44559
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
44560
- import { createHash as createHash13 } from "node:crypto";
44561
-
44562
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
45098
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
44563
45099
  var consolidationId = /* @__PURE__ */ __name((value, field4) => {
44564
45100
  if (typeof value !== "string" || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
44565
45101
  throw new CliError("validation_error", `${field4} must be a positive canonical tag id`);
@@ -44610,7 +45146,7 @@ var consolidationApplyInput = /* @__PURE__ */ __name((options) => {
44610
45146
  return input;
44611
45147
  }, "consolidationApplyInput");
44612
45148
 
44613
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
45149
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
44614
45150
  var receiptOf = /* @__PURE__ */ __name((row2) => ({
44615
45151
  id: String(row2.id),
44616
45152
  sourceId: String(row2.source_id),
@@ -44634,7 +45170,7 @@ var applyTagConsolidation = /* @__PURE__ */ __name((context, preview, options) =
44634
45170
  check3();
44635
45171
  return write(database, () => {
44636
45172
  const owner = ownerPerson(database);
44637
- const request = createHash13("sha256").update(JSON.stringify([
45173
+ const request = createHash14("sha256").update(JSON.stringify([
44638
45174
  source2,
44639
45175
  survivor,
44640
45176
  owner.type,
@@ -44685,7 +45221,7 @@ var applyTagConsolidation = /* @__PURE__ */ __name((context, preview, options) =
44685
45221
  }, { beforeCommit: check3 });
44686
45222
  }, "applyTagConsolidation");
44687
45223
 
44688
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
45224
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
44689
45225
  var selections = [
44690
45226
  ["taggings", "tag_id IN (SELECT value FROM json_each(?))"],
44691
45227
  ["aliases", "aliasable_type='tag' AND aliasable_id IN (SELECT value FROM json_each(?))"],
@@ -44731,7 +45267,7 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
44731
45267
  const memberIds = JSON.stringify([...sourceMemberIds, ...survivorMemberIds].map(Number));
44732
45268
  const captured = JSON.stringify(graph);
44733
45269
  let readBytes = Buffer.byteLength(captured);
44734
- const hash2 = createHash14("sha256").update(JSON.stringify([source2, survivor, catalog.fingerprint, graph]));
45270
+ const hash2 = createHash15("sha256").update(JSON.stringify([source2, survivor, catalog.fingerprint, graph]));
44735
45271
  for (const [table, where] of selections) {
44736
45272
  cancelled(options);
44737
45273
  const parameters = table === "links" ? [memberIds, memberIds] : [memberIds];
@@ -44829,7 +45365,7 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
44829
45365
  };
44830
45366
  }, "previewRows");
44831
45367
 
44832
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
45368
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
44833
45369
  var kinds = ["project", "tag", "topic"];
44834
45370
  var cancelled2 = /* @__PURE__ */ __name((signal) => {
44835
45371
  if (signal?.aborted)
@@ -44921,7 +45457,7 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
44921
45457
  cancelled2(options.signal);
44922
45458
  return {
44923
45459
  entries,
44924
- fingerprint: `v1:${options.kind ?? "all"}:${options.scope ?? "all"}:${createHash15("sha256").update(JSON.stringify(entries)).digest("hex")}`,
45460
+ fingerprint: `v1:${options.kind ?? "all"}:${options.scope ?? "all"}:${createHash16("sha256").update(JSON.stringify(entries)).digest("hex")}`,
44925
45461
  coverage: { complete: true, maxEntries, maxReadBytes }
44926
45462
  };
44927
45463
  }), "catalog");
@@ -45093,7 +45629,7 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
45093
45629
  };
45094
45630
  }, "vocabularyStoreOver");
45095
45631
 
45096
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
45632
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
45097
45633
  var TYPED_KEY_PREFIXES = new Set(Object.values(TASK_KEY_PREFIXES));
45098
45634
  var ORGANIZATION_KINDS = ["company", "team", "family", "community"];
45099
45635
  var PROJECT_TYPES = ["work", "client", "personal", "oss", "other"];
@@ -45105,7 +45641,7 @@ var bounded2 = /* @__PURE__ */ __name((limit = 100, offset = 0) => {
45105
45641
  throw new CliError("validation_error", "limit takes 1\u2013500 and offset takes 0\u2013100000");
45106
45642
  return { limit, offset };
45107
45643
  }, "bounded");
45108
- var textOf3 = /* @__PURE__ */ __name((text6, max = 1e5) => {
45644
+ var textOf4 = /* @__PURE__ */ __name((text6, max = 1e5) => {
45109
45645
  const value = text6.trim();
45110
45646
  if (!value || value.length > max)
45111
45647
  throw new CliError("validation_error", `text takes 1\u2013${max} characters`);
@@ -45333,7 +45869,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45333
45869
  return { items: rows.slice(0, limit).map((row2) => String(row2.id ?? row2.key)), hasMore: rows.length > limit };
45334
45870
  }, "taskIds"),
45335
45871
  addAnnotation: /* @__PURE__ */ __name(async (key2, target, text6) => {
45336
- const body2 = textOf3(text6);
45872
+ const body2 = textOf4(text6);
45337
45873
  if (subfolder(target) !== null)
45338
45874
  throw new CliError("validation_error", "annotate a folder, not one of its subfolders");
45339
45875
  const thing = available(key2, target);
@@ -45358,7 +45894,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45358
45894
  annotation: /* @__PURE__ */ __name(async (key2, id2) => annotation(key2, id2), "annotation"),
45359
45895
  editAnnotation: /* @__PURE__ */ __name(async (key2, id2, text6, revision2) => {
45360
45896
  const held = annotation(key2, id2);
45361
- const changed = database.prepare("UPDATE notes SET body=?, revision=revision+1, updated_at=? WHERE id=? AND revision=?").run(textOf3(text6), now2(), Number(id2), revision2).changes;
45897
+ const changed = database.prepare("UPDATE notes SET body=?, revision=revision+1, updated_at=? WHERE id=? AND revision=?").run(textOf4(text6), now2(), Number(id2), revision2).changes;
45362
45898
  if (!changed)
45363
45899
  throw new CliError("validation_error", "annotation changed; read the current revision before editing");
45364
45900
  database.prepare("INSERT INTO note_revisions (note_id, body, revision, created_at) VALUES (?, ?, ?, ?)").run(Number(id2), held.text, held.revision, now2());
@@ -45431,11 +45967,11 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45431
45967
  }, "labelled"),
45432
45968
  addOrganization: /* @__PURE__ */ __name(async ({ kind: kind3, name, scope: scope3 = "personal" }) => {
45433
45969
  const at = now2();
45434
- const row2 = database.prepare("INSERT INTO organizations (kind, name, scope, created_at, updated_at) VALUES (?, ?, ?, ?, ?) RETURNING *").get(oneOf6(kind3, ORGANIZATION_KINDS, "an organization's kind"), textOf3(name, 200), oneOf6(scope3, SCOPES, "a scope"), at, at);
45970
+ const row2 = database.prepare("INSERT INTO organizations (kind, name, scope, created_at, updated_at) VALUES (?, ?, ?, ?, ?) RETURNING *").get(oneOf6(kind3, ORGANIZATION_KINDS, "an organization's kind"), textOf4(name, 200), oneOf6(scope3, SCOPES, "a scope"), at, at);
45435
45971
  return organizationOf(row2);
45436
45972
  }, "addOrganization"),
45437
45973
  addProject: /* @__PURE__ */ __name(async ({ name, key: key2, type = "other", organization: organization2, scope: scope3 = "personal", description }) => write(database, () => {
45438
- const title = textOf3(name, 200);
45974
+ const title = textOf4(name, 200);
45439
45975
  const organizationId = organization2 === void 0 ? null : (() => {
45440
45976
  const thing = thingOf(database, organization2);
45441
45977
  if (thing?.type !== "organization")
@@ -45470,7 +46006,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45470
46006
  chosen = `${wanted.slice(0, 4 - suffix.length)}${suffix}`;
45471
46007
  }
45472
46008
  const at = now2();
45473
- const row2 = database.prepare("INSERT INTO projects (key, name, name_folded, description, type, organization_id, scope, tasks_count, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, 0, 'active', ?, ?) RETURNING *").get(chosen, title, fold(title), description === void 0 ? null : textOf3(description, 2e3), oneOf6(type, PROJECT_TYPES, "a project's type"), organizationId, oneOf6(scope3, SCOPES, "a scope"), at, at);
46009
+ const row2 = database.prepare("INSERT INTO projects (key, name, name_folded, description, type, organization_id, scope, tasks_count, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, 0, 'active', ?, ?) RETURNING *").get(chosen, title, fold(title), description === void 0 ? null : textOf4(description, 2e3), oneOf6(type, PROJECT_TYPES, "a project's type"), organizationId, oneOf6(scope3, SCOPES, "a scope"), at, at);
45474
46010
  return projectOf2(row2);
45475
46011
  }), "addProject"),
45476
46012
  projects: /* @__PURE__ */ __name(async (query) => {
@@ -45634,7 +46170,7 @@ var projectKey = /* @__PURE__ */ __name((name) => {
45634
46170
  return key2.padEnd(3, "X");
45635
46171
  }, "projectKey");
45636
46172
 
45637
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
46173
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
45638
46174
  var DAY5 = 864e5;
45639
46175
  var SETTING4 = "logs_pruned_at";
45640
46176
  var LOG_RETENTION = { agentActionsMs: 90 * DAY5, botUpdatePayloadsMs: 30 * DAY5 };
@@ -45661,7 +46197,7 @@ var logPruner = /* @__PURE__ */ __name((database, now2) => {
45661
46197
  };
45662
46198
  }, "logPruner");
45663
46199
 
45664
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/mail/findings.js
46200
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/mail/findings.js
45665
46201
  var MAIL_FINDINGS_PER_RUN = 30;
45666
46202
  var MAIL_FINDINGS_PER_SENDER = 5;
45667
46203
  var invalid4 = /* @__PURE__ */ __name((message2) => {
@@ -46020,7 +46556,7 @@ var checkMailFindings = /* @__PURE__ */ __name((input) => {
46020
46556
  }, "checkMailFindings");
46021
46557
  var mailFindingFingerprint = /* @__PURE__ */ __name(({ id: _id, ...finding }) => findingHash(finding), "mailFindingFingerprint");
46022
46558
 
46023
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/mail/score.js
46559
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/mail/score.js
46024
46560
  var import_disposable_email_domains_js = __toESM(require_dist(), 1);
46025
46561
  var import_tldts = __toESM(require_cjs(), 1);
46026
46562
  var FREE_MAIL = /* @__PURE__ */ new Set([
@@ -46050,7 +46586,7 @@ var FREE_MAIL = /* @__PURE__ */ new Set([
46050
46586
  ]);
46051
46587
  var DAY_MS = 24 * 60 * 60 * 1e3;
46052
46588
 
46053
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/orders.js
46589
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/orders.js
46054
46590
  var ORDERS = "SELECT o.*, b.name AS author_name, b.kind AS author_kind FROM orders o LEFT JOIN bots b ON o.author_type = 'bot' AND b.id = o.author_id";
46055
46591
  var orderOperationsOver = /* @__PURE__ */ __name((context) => {
46056
46592
  const { database, now: now2 } = context;
@@ -46165,12 +46701,12 @@ var orderOperationsOver = /* @__PURE__ */ __name((context) => {
46165
46701
  setStatus: /* @__PURE__ */ __name((reference2, { status, date: date3, by }) => {
46166
46702
  ownerOnly(by, "moves an order on");
46167
46703
  const next = statusOf(status);
46168
- const day = isoDate(date3, "an order's delivery date");
46704
+ const day2 = isoDate(date3, "an order's delivery date");
46169
46705
  const row2 = rowOf2(reference2);
46170
46706
  if (row2.review === "rejected" || row2.deleted_at != null)
46171
46707
  refuse(`order:${row2.id} is ${row2.deleted_at != null ? "deleted" : "rejected"}`, "order.status");
46172
46708
  write(database, () => {
46173
- database.prepare("UPDATE orders SET status = ?, fulfilled_date = coalesce(?, fulfilled_date), updated_at = ? WHERE id = ?").run(next, next === "delivered" ? day : null, now2(), Number(row2.id));
46709
+ database.prepare("UPDATE orders SET status = ?, fulfilled_date = coalesce(?, fulfilled_date), updated_at = ? WHERE id = ?").run(next, next === "delivered" ? day2 : null, now2(), Number(row2.id));
46174
46710
  });
46175
46711
  return orderOf(rowOf2(`order:${row2.id}`));
46176
46712
  }, "setStatus"),
@@ -46202,7 +46738,7 @@ var ordersStoreOver = /* @__PURE__ */ __name((context) => {
46202
46738
  };
46203
46739
  }, "ordersStoreOver");
46204
46740
 
46205
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-findings.js
46741
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-findings.js
46206
46742
  var stale2 = /* @__PURE__ */ __name(() => {
46207
46743
  throw new CliError("validation_error", "mail findings cite mail that changed since it was read; stage a new batch", {
46208
46744
  reason: "mail-findings.stale"
@@ -46659,7 +47195,7 @@ ${evidence.join("\n")}`, agent);
46659
47195
  };
46660
47196
  }, "mailFindingsStoreOver");
46661
47197
 
46662
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
47198
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
46663
47199
  var stale3 = /* @__PURE__ */ __name(() => {
46664
47200
  throw new CliError("validation_error", "meeting findings changed since they were read; stage a new batch", {
46665
47201
  reason: "meeting-findings.stale"
@@ -46827,7 +47363,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
46827
47363
  };
46828
47364
  }, "meetingFindingsStoreOver");
46829
47365
 
46830
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
47366
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
46831
47367
  var RANK_BATCH = 512;
46832
47368
  var LIVE3 = "FROM chunks k JOIN meeting_transcripts t ON k.chunkable_type = 'meeting_transcript' AND t.id = k.chunkable_id JOIN meetings m ON m.id = t.meeting_id WHERE m.account_id = ? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL";
46833
47369
  var limitOf = /* @__PURE__ */ __name((value, name, max = 1e3) => {
@@ -46847,7 +47383,7 @@ var modelOf = /* @__PURE__ */ __name((model) => {
46847
47383
  var missing3 = /* @__PURE__ */ __name(() => {
46848
47384
  throw new CliError("not_found", "Current transcript not found");
46849
47385
  }, "missing");
46850
- var textOf4 = /* @__PURE__ */ __name((context, accountId, transcriptId, budget, signal) => {
47386
+ var textOf5 = /* @__PURE__ */ __name((context, accountId, transcriptId, budget, signal) => {
46851
47387
  const maxRows = limitOf(budget.maxRows ?? 1e4, "maxRows", 1e5);
46852
47388
  const maxBytes = limitOf(budget.maxTextBytes ?? 4 * 1024 * 1024, "maxTextBytes", 64 * 1024 * 1024);
46853
47389
  const parent2 = context.database.prepare("SELECT m.id AS meeting_id FROM meeting_transcripts t JOIN meetings m ON m.id=t.meeting_id WHERE t.id=? AND m.account_id=? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL").get(transcriptId, accountId) ?? missing3();
@@ -46881,14 +47417,14 @@ var textLoader = /* @__PURE__ */ __name((context, input) => {
46881
47417
  return existing;
46882
47418
  if (remaining <= 0)
46883
47419
  throw new CliError("validation_error", "Vector operation exceeds its aggregate text read budget");
46884
- const document = textOf4(context, input.accountId, id2, { ...input, maxTextBytes: remaining }, input.signal);
47420
+ const document = textOf5(context, input.accountId, id2, { ...input, maxTextBytes: remaining }, input.signal);
46885
47421
  remaining -= document.readBytes;
46886
47422
  loaded3.set(id2, document);
46887
47423
  return document;
46888
47424
  };
46889
47425
  }, "textLoader");
46890
47426
  var chunkText = /* @__PURE__ */ __name((context, accountId, row2, budget, signal, loaded3) => {
46891
- const document = loaded3 ?? textOf4(context, accountId, Number(row2.chunkable_id), budget, signal);
47427
+ const document = loaded3 ?? textOf5(context, accountId, Number(row2.chunkable_id), budget, signal);
46892
47428
  const start = Number(row2.start_offset), end = Number(row2.end_offset);
46893
47429
  const text6 = document.text.slice(start, end);
46894
47430
  if (chunkHash(text6) !== String(row2.content_hash))
@@ -47098,7 +47634,7 @@ var meetingVectorsOver = /* @__PURE__ */ __name((context) => ({
47098
47634
  }
47099
47635
  }), "meetingVectorsOver");
47100
47636
 
47101
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
47637
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
47102
47638
  var OTHER_SOURCES = ["document", "note", "email"];
47103
47639
  var TEXTS = {
47104
47640
  document: "JOIN documents s ON mn.source_type = 'document' AND s.id = mn.source_id AND s.deleted_at IS NULL WHERE 1 ",
@@ -47199,11 +47735,11 @@ var sourceMentionStoreOver = /* @__PURE__ */ __name((context) => {
47199
47735
  };
47200
47736
  }, "sourceMentionStoreOver");
47201
47737
 
47202
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
47203
- import { mkdirSync, statSync, writeFileSync } from "node:fs";
47204
- import { dirname } from "node:path";
47738
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
47739
+ import { accessSync, constants, existsSync, mkdirSync as mkdirSync2, statSync, writeFileSync as writeFileSync2 } from "node:fs";
47740
+ import { dirname as dirname2 } from "node:path";
47205
47741
 
47206
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
47742
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
47207
47743
  import { readFileSync as readFileSync3 } from "node:fs";
47208
47744
  var CLIENTS_SETTING = "clients";
47209
47745
  var coreVersion = (() => {
@@ -47261,7 +47797,7 @@ var refusalAdvice = /* @__PURE__ */ __name((clients, command, schema) => {
47261
47797
  return mover ? `${own} (${mover.command} ${mover.version} moved the store to schema ${schema})` : own;
47262
47798
  }, "refusalAdvice");
47263
47799
 
47264
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
47800
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
47265
47801
  var GENERATED = [
47266
47802
  {
47267
47803
  "name": "20261010184427_initial",
@@ -48310,10 +48846,298 @@ WHERE json_type(params, '$.selection') = 'object';`
48310
48846
  "-- The default lead pipeline, so a lead can be recorded before the owner or an agent makes one.\nINSERT INTO pipelines (kind, name, name_folded, created_at, updated_at)\n VALUES ('lead', 'Leads', 'leads', CAST(strftime('%s', 'now') AS INTEGER) * 1000, CAST(strftime('%s', 'now') AS INTEGER) * 1000);",
48311
48847
  "INSERT INTO pipeline_stages (pipeline_id, name, name_folded, position, outcome, created_at, updated_at)\n SELECT p.id, v.name, v.name, v.position, v.outcome, p.created_at, p.created_at FROM pipelines p,\n (SELECT 'new' AS name, 1 AS position, 'open' AS outcome UNION ALL SELECT 'contacted', 2, 'open'\n UNION ALL SELECT 'qualified', 3, 'open' UNION ALL SELECT 'won', 4, 'won' UNION ALL SELECT 'lost', 5, 'lost') v\n WHERE p.kind = 'lead' AND p.name_folded = 'leads' AND p.account_id IS NULL;"
48312
48848
  ]
48849
+ },
48850
+ {
48851
+ "name": "20261106165009_version-53-crm-pipelines",
48852
+ "statements": [
48853
+ "ALTER TABLE `pipeline_stages` ADD `deleted_at` integer;",
48854
+ "ALTER TABLE `pipelines` ADD `deleted_at` integer;",
48855
+ "DROP INDEX IF EXISTS `pipelines_by_account_id_external_id`;",
48856
+ "CREATE UNIQUE INDEX `pipelines_by_account_id_kind_external_id` ON `pipelines` (`account_id`,`kind`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;"
48857
+ ]
48858
+ },
48859
+ {
48860
+ "name": "20261106225547_version-54-crm-fields",
48861
+ "statements": [
48862
+ "CREATE TABLE `crm_fields` (\n `id` integer PRIMARY KEY,\n `account_id` integer NOT NULL,\n `kind` text NOT NULL,\n `code` text NOT NULL,\n `label` text,\n `type` text NOT NULL,\n `multiple` integer NOT NULL,\n `filterable` integer NOT NULL,\n `options` text,\n `position` integer NOT NULL,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n `deleted_at` integer,\n CONSTRAINT `fk_crm_fields_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`),\n CONSTRAINT `crm_fields_account_id_kind_code_unique` UNIQUE(`account_id`,`kind`,`code`)\n);"
48863
+ ]
48864
+ },
48865
+ {
48866
+ "name": "20261107032742_version-55-decision-requests",
48867
+ "statements": [
48868
+ "CREATE TABLE `decision_requests` (\n `id` integer PRIMARY KEY,\n `token_digest` text NOT NULL UNIQUE,\n `proposal_id` text NOT NULL,\n `action` text NOT NULL,\n `batch_digest` text NOT NULL,\n `channel` text NOT NULL,\n `bot_profile` text NOT NULL,\n `chat_id` text NOT NULL,\n `message_id` text NOT NULL,\n `owner_user_id` text NOT NULL,\n `created_at` integer NOT NULL,\n `expires_at` integer NOT NULL,\n `used_at` integer,\n `cancelled_at` integer\n);"
48869
+ ]
48870
+ },
48871
+ {
48872
+ "name": "20261107043407_version-55-decision-requests-index",
48873
+ "statements": [
48874
+ "CREATE INDEX `decision_requests_by_channel_bot_profile_chat_id_message_id` ON `decision_requests` (`channel`,`bot_profile`,`chat_id`,`message_id`);"
48875
+ ]
48313
48876
  }
48314
48877
  ];
48315
48878
 
48316
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
48879
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/rollback-copy.js
48880
+ import { mkdirSync, rmSync, statfsSync, writeFileSync } from "node:fs";
48881
+ import { basename, dirname, join as join2, parse } from "node:path";
48882
+ var DERIVED = /(_fts|_words|_stems|_trigrams|_pending)$|^(embeddings|chunks|chunk_messages|mentions|involvements|search_terms)$|^vector_index/;
48883
+ var isDerivedTable = /* @__PURE__ */ __name((name) => DERIVED.test(name), "isDerivedTable");
48884
+ var BOOKKEEPING = ["store_settings", "search_index_state"];
48885
+ var KEY3 = "rollback_copy:";
48886
+ var SCHEMA = "rollback_copy";
48887
+ var ROWID = "__rollback_rowid";
48888
+ var DAY_MS2 = 24 * 60 * 60 * 1e3;
48889
+ var HEADROOM = 256 * 1024 * 1024;
48890
+ var quote2 = /* @__PURE__ */ __name((name) => `"${name.replaceAll('"', '""')}"`, "quote");
48891
+ var megabytes = /* @__PURE__ */ __name((bytes3) => `${Math.ceil(bytes3 / 1024 / 1024)} MB`, "megabytes");
48892
+ var freeBytesOf = /* @__PURE__ */ __name((dir) => {
48893
+ const { bavail, bsize } = statfsSync(dir);
48894
+ return Number(bavail) * Number(bsize);
48895
+ }, "freeBytesOf");
48896
+ var tableIn = /* @__PURE__ */ __name((database, schema, name) => database.prepare(`SELECT 1 FROM ${schema}.sqlite_master WHERE type = 'table' AND name = ?`).get(name) !== void 0, "tableIn");
48897
+ var keepsRowid = /* @__PURE__ */ __name((database, schema, table) => Number(database.prepare("SELECT wr FROM pragma_table_list WHERE schema = ? AND name = ?").get(schema, table)?.wr) === 0, "keepsRowid");
48898
+ var columnsOf2 = /* @__PURE__ */ __name((database, schema, table) => database.prepare("SELECT name FROM pragma_table_info(?, ?)").all(table, schema).map((row2) => String(row2.name)), "columnsOf");
48899
+ var versionOf = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT max(version) AS version FROM main.schema_migrations").get()?.version ?? 0), "versionOf");
48900
+ var tableBytes = /* @__PURE__ */ __name((database, tables) => {
48901
+ try {
48902
+ return Number(database.prepare(`SELECT coalesce(sum(pgsize), 0) AS bytes FROM dbstat
48903
+ WHERE schema = 'main' AND aggregate = 1 AND name IN (${tables.map(() => "?").join(", ")})`).get(...tables)?.bytes ?? 0);
48904
+ } catch {
48905
+ const pragma = /* @__PURE__ */ __name((name) => Number(database.prepare(`PRAGMA ${name}`).get()?.[name] ?? 0), "pragma");
48906
+ return pragma("page_count") * pragma("page_size");
48907
+ }
48908
+ }, "tableBytes");
48909
+ var stampOf = /* @__PURE__ */ __name((at) => new Date(at).toISOString().replace(/[:.]/g, "-"), "stampOf");
48910
+ var attach = /* @__PURE__ */ __name((database, path) => database.prepare(`ATTACH DATABASE ? AS ${SCHEMA}`).run(path), "attach");
48911
+ var takeRollbackCopy = /* @__PURE__ */ __name((database, { from: from2, to, tables, at }, { store, freeBytes = freeBytesOf, warn = /* @__PURE__ */ __name((line) => process.stderr.write(`${line}
48912
+ `), "warn") }) => {
48913
+ const dir = join2(dirname(store), "backups");
48914
+ const present2 = [.../* @__PURE__ */ new Set([...BOOKKEEPING, ...tables])].filter((table) => tableIn(database, "main", table));
48915
+ const afterwards = `going back to schema ${from2} then needs an empty store, and its data pulled again from the sources`;
48916
+ let path;
48917
+ try {
48918
+ mkdirSync(dir, { recursive: true, mode: 448 });
48919
+ const needed = tableBytes(database, present2);
48920
+ const free = freeBytes(dir);
48921
+ if (free < needed + HEADROOM) {
48922
+ warn(`not enough free disk space for a rollback copy before schema ${to} (about ${megabytes(needed + HEADROOM)} needed, ${megabytes(free)} free in ${dir}) \u2014 migrating without one; ${afterwards}`);
48923
+ return void 0;
48924
+ }
48925
+ path = join2(dir, `${parse(store).name}-rollback-schema-${from2}-${stampOf(at)}.db`);
48926
+ writeFileSync(path, "", { flag: "wx", mode: 384 });
48927
+ attach(database, path);
48928
+ try {
48929
+ database.exec("BEGIN IMMEDIATE");
48930
+ try {
48931
+ const copied = versionOf(database);
48932
+ database.exec(`CREATE TABLE ${SCHEMA}.rollback_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL)`);
48933
+ database.exec(`CREATE TABLE ${SCHEMA}.rollback_schema AS
48934
+ SELECT m.type, m.name, m.tbl_name, m.sql, coalesce(l.type, m.type) AS kind
48935
+ FROM main.sqlite_master m LEFT JOIN pragma_table_list l ON l.schema = 'main' AND l.name = m.name
48936
+ ORDER BY m.rowid`);
48937
+ for (const table of present2) {
48938
+ const rowid = keepsRowid(database, "main", table) ? `rowid AS ${ROWID}, ` : "";
48939
+ database.exec(`CREATE TABLE ${SCHEMA}.${quote2(table)} AS SELECT ${rowid}* FROM main.${quote2(table)}`);
48940
+ }
48941
+ const meta = { from: copied, to, tables: present2, created_at: at };
48942
+ const insert = database.prepare(`INSERT INTO ${SCHEMA}.rollback_meta (key, value) VALUES (?, ?)`);
48943
+ for (const [key2, value] of Object.entries(meta))
48944
+ insert.run(key2, JSON.stringify(value));
48945
+ database.exec("COMMIT");
48946
+ return { path, from: copied, to };
48947
+ } catch (error) {
48948
+ database.exec("ROLLBACK");
48949
+ throw error;
48950
+ }
48951
+ } finally {
48952
+ database.exec(`DETACH DATABASE ${SCHEMA}`);
48953
+ }
48954
+ } catch (error) {
48955
+ if (path)
48956
+ rmSync(path, { force: true });
48957
+ warn(`the rollback copy before schema ${to} could not be written (${error instanceof Error ? error.message : String(error)}) \u2014 migrating without one; ${afterwards}`);
48958
+ return void 0;
48959
+ }
48960
+ }, "takeRollbackCopy");
48961
+ var recordRollbackCopy = /* @__PURE__ */ __name((database, copy, at) => {
48962
+ database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(`${KEY3}${basename(copy.path)}`, JSON.stringify({ path: copy.path, from: copy.from, to: copy.to, at }), at);
48963
+ }, "recordRollbackCopy");
48964
+ var discardRollbackCopy = /* @__PURE__ */ __name((copy) => rmSync(copy.path, { force: true }), "discardRollbackCopy");
48965
+ var pruneRollbackCopies = /* @__PURE__ */ __name((database, now2) => {
48966
+ const recorded = database.prepare("SELECT key, value FROM store_settings WHERE key LIKE 'rollback\\_copy:%' ESCAPE '\\'").all();
48967
+ if (recorded.length === 0)
48968
+ return;
48969
+ const version = versionOf(database);
48970
+ for (const { key: key2, value } of recorded) {
48971
+ let copy;
48972
+ try {
48973
+ copy = JSON.parse(String(value));
48974
+ } catch {
48975
+ continue;
48976
+ }
48977
+ if (typeof copy.path !== "string" || now2 - Number(copy.at) < DAY_MS2 || version < Number(copy.to))
48978
+ continue;
48979
+ if (!database.prepare("SELECT 1 FROM schema_migrations WHERE version = ?").get(Number(copy.to)))
48980
+ continue;
48981
+ rmSync(copy.path, { force: true });
48982
+ database.prepare("DELETE FROM store_settings WHERE key = ?").run(String(key2));
48983
+ }
48984
+ }, "pruneRollbackCopies");
48985
+ var objectsOf = /* @__PURE__ */ __name((database, sql2) => database.prepare(sql2).all().map((row2) => ({
48986
+ type: String(row2.type),
48987
+ name: String(row2.name),
48988
+ sql: row2.sql === null ? null : String(row2.sql),
48989
+ kind: String(row2.kind)
48990
+ })), "objectsOf");
48991
+ var currentObjects = /* @__PURE__ */ __name((database) => objectsOf(database, `SELECT m.type, m.name, m.sql, coalesce(l.type, m.type) AS kind
48992
+ FROM main.sqlite_master m LEFT JOIN pragma_table_list l ON l.schema = 'main' AND l.name = m.name`), "currentObjects");
48993
+ var internal = /* @__PURE__ */ __name(({ name, kind: kind3 }) => name.startsWith("sqlite_") || kind3 === "shadow", "internal");
48994
+ var metaOf = /* @__PURE__ */ __name((database) => {
48995
+ const values = new Map(database.prepare(`SELECT key, value FROM ${SCHEMA}.rollback_meta`).all().map((row2) => [String(row2.key), JSON.parse(String(row2.value))]));
48996
+ const tables = values.get("tables");
48997
+ return {
48998
+ from: Number(values.get("from")),
48999
+ to: Number(values.get("to")),
49000
+ tables: Array.isArray(tables) ? tables.map(String) : [],
49001
+ createdAt: Number(values.get("created_at"))
49002
+ };
49003
+ }, "metaOf");
49004
+ var contentOf = /* @__PURE__ */ __name((sql2) => /\bcontent\s*=\s*'([^']+)'/i.exec(sql2 ?? "")?.[1], "contentOf");
49005
+ var RANK = { table: 0, index: 1, view: 2, trigger: 3 };
49006
+ var rewind = /* @__PURE__ */ __name((database, saved, named2) => {
49007
+ const before2 = new Map(saved.map((object) => [object.name, object]));
49008
+ const same = /* @__PURE__ */ __name((object) => before2.get(object.name)?.type === object.type && before2.get(object.name)?.sql === object.sql, "same");
49009
+ const touched = new Set(named2);
49010
+ const rebuilt = [];
49011
+ for (const object of currentObjects(database)) {
49012
+ if (object.type === "trigger")
49013
+ database.exec(`DROP TRIGGER IF EXISTS ${quote2(object.name)}`);
49014
+ if (object.type === "view")
49015
+ database.exec(`DROP VIEW IF EXISTS ${quote2(object.name)}`);
49016
+ if (object.type === "index" && object.sql !== null && !same(object))
49017
+ database.exec(`DROP INDEX IF EXISTS ${quote2(object.name)}`);
49018
+ }
49019
+ for (const object of currentObjects(database)) {
49020
+ if (object.type !== "table" || internal(object))
49021
+ continue;
49022
+ const old = before2.get(object.name);
49023
+ if (named2.has(object.name) || !old || object.kind === "virtual" && !same(object)) {
49024
+ database.exec(`DROP TABLE ${quote2(object.name)}`);
49025
+ } else if (!same(object) && old.sql) {
49026
+ rebuild(database, object.name, old.sql);
49027
+ rebuilt.push(object.name);
49028
+ touched.add(object.name);
49029
+ }
49030
+ }
49031
+ const present2 = new Set(currentObjects(database).map(({ name }) => name));
49032
+ const missing4 = saved.filter((object) => !internal(object) && object.sql !== null && !present2.has(object.name)).sort((a, b) => (RANK[a.type] ?? 9) - (RANK[b.type] ?? 9));
49033
+ for (const object of missing4) {
49034
+ database.exec(object.sql);
49035
+ if (object.type === "table" && named2.has(object.name))
49036
+ restoreRows(database, object.name);
49037
+ if (object.kind === "virtual")
49038
+ touched.add(object.name);
49039
+ }
49040
+ for (const object of saved) {
49041
+ const content = contentOf(object.sql);
49042
+ if (object.kind !== "virtual" || !(content && (touched.has(content) || touched.has(object.name))))
49043
+ continue;
49044
+ database.exec(`INSERT INTO ${quote2(object.name)} (${quote2(object.name)}) VALUES ('rebuild')`);
49045
+ }
49046
+ return rebuilt;
49047
+ }, "rewind");
49048
+ var rebuild = /* @__PURE__ */ __name((database, table, sql2) => {
49049
+ const aside = `__rollback_${table}`;
49050
+ database.exec(`ALTER TABLE ${quote2(table)} RENAME TO ${quote2(aside)}`);
49051
+ database.exec(sql2);
49052
+ const kept = new Set(columnsOf2(database, "main", aside));
49053
+ const columns = columnsOf2(database, "main", table).filter((column2) => kept.has(column2));
49054
+ const rowid = keepsRowid(database, "main", table) ? ["rowid"] : [];
49055
+ const list2 = [...rowid, ...columns.map(quote2)].join(", ");
49056
+ database.exec(`INSERT INTO ${quote2(table)} (${list2}) SELECT ${list2} FROM ${quote2(aside)}`);
49057
+ database.exec(`DROP TABLE ${quote2(aside)}`);
49058
+ }, "rebuild");
49059
+ var restoreRows = /* @__PURE__ */ __name((database, table) => {
49060
+ const copied = new Set(columnsOf2(database, SCHEMA, table));
49061
+ const columns = columnsOf2(database, "main", table).filter((column2) => copied.has(column2));
49062
+ const rowid = keepsRowid(database, "main", table) && copied.has(ROWID);
49063
+ const into = [...rowid ? ["rowid"] : [], ...columns.map(quote2)].join(", ");
49064
+ const from2 = [...rowid ? [ROWID] : [], ...columns.map(quote2)].join(", ");
49065
+ database.exec(`INSERT INTO main.${quote2(table)} (${into}) SELECT ${from2} FROM ${SCHEMA}.${quote2(table)}`);
49066
+ }, "restoreRows");
49067
+ var rollBack = /* @__PURE__ */ __name((database, path) => {
49068
+ attach(database, path);
49069
+ let result;
49070
+ try {
49071
+ if (!tableIn(database, SCHEMA, "rollback_meta"))
49072
+ throw new CliError("validation_error", `${path} is not a rollback copy`);
49073
+ const meta = metaOf(database);
49074
+ const was = versionOf(database);
49075
+ if (!database.prepare("SELECT 1 FROM main.schema_migrations WHERE version = ?").get(meta.to)) {
49076
+ throw new CliError("validation_error", `the store is at schema ${was} and was never migrated to ${meta.to}, the schema this copy was taken before \u2014 nothing to roll back`);
49077
+ }
49078
+ const saved = objectsOf(database, `SELECT type, name, sql, kind FROM ${SCHEMA}.rollback_schema ORDER BY rowid`);
49079
+ database.exec("PRAGMA foreign_keys = OFF");
49080
+ database.exec("PRAGMA legacy_alter_table = ON");
49081
+ try {
49082
+ database.exec("BEGIN IMMEDIATE");
49083
+ try {
49084
+ const named2 = new Set(meta.tables);
49085
+ const rebuilt = rewind(database, saved, named2);
49086
+ database.prepare("DELETE FROM main.schema_migrations WHERE version > ?").run(meta.from);
49087
+ database.prepare("DELETE FROM main.store_settings WHERE key = ?").run(`${KEY3}${basename(path)}`);
49088
+ database.exec("COMMIT");
49089
+ const count = /* @__PURE__ */ __name((table) => Number(database.prepare(`SELECT count(*) AS n FROM main.${quote2(table)}`).get()?.n ?? 0), "count");
49090
+ result = {
49091
+ ...meta,
49092
+ was,
49093
+ restored: meta.tables.map((table) => ({ table, rows: count(table) })),
49094
+ rebuilt
49095
+ };
49096
+ } catch (error) {
49097
+ database.exec("ROLLBACK");
49098
+ throw error;
49099
+ }
49100
+ } finally {
49101
+ database.exec("PRAGMA legacy_alter_table = OFF");
49102
+ database.exec("PRAGMA foreign_keys = ON");
49103
+ }
49104
+ } finally {
49105
+ database.exec(`DETACH DATABASE ${SCHEMA}`);
49106
+ }
49107
+ const checked = [...result.restored.map(({ table }) => table), ...result.rebuilt];
49108
+ const foreignKeyViolations = checked.reduce((total, table) => total + database.prepare(`PRAGMA foreign_key_check(${quote2(table)})`).all().length, 0);
49109
+ return { ...result, foreignKeyViolations };
49110
+ }, "rollBack");
49111
+
49112
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
49113
+ var V31_TABLES = [
49114
+ "accounts",
49115
+ "account_identities",
49116
+ "agent_actions",
49117
+ "aliases",
49118
+ "attachments",
49119
+ "bot_updates",
49120
+ "chats",
49121
+ "documents",
49122
+ "email_threads",
49123
+ "emails",
49124
+ "facts",
49125
+ "links",
49126
+ "mail_rules",
49127
+ "mailboxes",
49128
+ "meeting_series",
49129
+ "meetings",
49130
+ "memories",
49131
+ "messages",
49132
+ "notes",
49133
+ "projects",
49134
+ "proposed_actions",
49135
+ "reminders",
49136
+ "store_settings",
49137
+ "sync_cursors",
49138
+ "syncs",
49139
+ "taggings"
49140
+ ];
48317
49141
  var MANIFEST = [
48318
49142
  { name: "20261010184427_initial", version: 1, minCompatible: 1 },
48319
49143
  { name: "20261011035353_version-2-facts", version: 2, minCompatible: 1 },
@@ -48350,14 +49174,24 @@ var MANIFEST = [
48350
49174
  { name: "20261021224625_version-28-chat-state", version: 28, minCompatible: 1 },
48351
49175
  { name: "20261023105057_version-29-transcript-words", version: 29, minCompatible: 1 },
48352
49176
  { name: "20261023105101_version-29-transcript-words-triggers", version: 29, minCompatible: 1 },
48353
- { name: "20261025064253_version-30-reviewed-tag-consolidation", version: 30, minCompatible: 30 },
49177
+ {
49178
+ name: "20261025064253_version-30-reviewed-tag-consolidation",
49179
+ version: 30,
49180
+ minCompatible: 30,
49181
+ tables: ["tags", "auto_tag_claims"]
49182
+ },
48354
49183
  { name: "20261025064302_version-30-resolved-tag-view", version: 30, minCompatible: 30 },
48355
- { name: "20261025070402_version-31-drive-account", version: 31, minCompatible: 31 },
48356
- { name: "20261025071848_version-32-files", version: 32, minCompatible: 32 },
49184
+ { name: "20261025070402_version-31-drive-account", version: 31, minCompatible: 31, tables: V31_TABLES },
49185
+ {
49186
+ name: "20261025071848_version-32-files",
49187
+ version: 32,
49188
+ minCompatible: 32,
49189
+ tables: ["accounts", "documents", "identities", "store_settings"]
49190
+ },
48357
49191
  { name: "20261025071850_version-32-files-data", version: 32, minCompatible: 32 },
48358
49192
  { name: "20261025072643_version-33-calendars", version: 33, minCompatible: 32 },
48359
49193
  { name: "20261025072644_version-33-calendars-triggers", version: 33, minCompatible: 32 },
48360
- { name: "20261025182500_version-34-vector-index", version: 34, minCompatible: 34 },
49194
+ { name: "20261025182500_version-34-vector-index", version: 34, minCompatible: 34, tables: [] },
48361
49195
  { name: "20261025182501_version-34-vector-index-triggers", version: 34, minCompatible: 34 },
48362
49196
  { name: "20261027102259_version-35-calendar-neutral", version: 35, minCompatible: 34 },
48363
49197
  { name: "20261027102302_version-35-calendar-neutral-data", version: 35, minCompatible: 34 },
@@ -48383,7 +49217,11 @@ var MANIFEST = [
48383
49217
  { name: "20261105125315_version-50-orders-rules", version: 50, minCompatible: 34 },
48384
49218
  { name: "20261105144549_version-51-task-links", version: 51, minCompatible: 34 },
48385
49219
  { name: "20261106010504_version-52-deals", version: 52, minCompatible: 34 },
48386
- { name: "20261106010507_version-52-deals-rules", version: 52, minCompatible: 34 }
49220
+ { name: "20261106010507_version-52-deals-rules", version: 52, minCompatible: 34 },
49221
+ { name: "20261106165009_version-53-crm-pipelines", version: 53, minCompatible: 34 },
49222
+ { name: "20261106225547_version-54-crm-fields", version: 54, minCompatible: 34 },
49223
+ { name: "20261107032742_version-55-decision-requests", version: 55, minCompatible: 34 },
49224
+ { name: "20261107043407_version-55-decision-requests-index", version: 55, minCompatible: 34 }
48387
49225
  ];
48388
49226
  var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated = GENERATED) => {
48389
49227
  const migrations = [];
@@ -48396,10 +49234,22 @@ var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated
48396
49234
  const last = migrations.at(-1);
48397
49235
  if (last && last.version !== entry2.version && entry2.minCompatible < last.minCompatible)
48398
49236
  throw new Error("migration minCompatible cannot decrease");
49237
+ const derived = entry2.tables?.filter(isDerivedTable) ?? [];
49238
+ if (derived.length > 0)
49239
+ throw new Error(`migration ${entry2.version} names derived tables (${derived.join(", ")}); they are rebuilt, never copied`);
48399
49240
  if (last?.version !== entry2.version) {
48400
- migrations.push({ version: entry2.version, minCompatible: entry2.minCompatible, statements: [...found2.statements] });
49241
+ if (last && entry2.minCompatible > last.minCompatible && entry2.tables === void 0)
49242
+ throw new Error(`migration ${entry2.version} raises minCompatible, so it names the base tables it changes (tables)`);
49243
+ migrations.push({
49244
+ version: entry2.version,
49245
+ minCompatible: entry2.minCompatible,
49246
+ statements: [...found2.statements],
49247
+ ...entry2.tables ? { tables: [...entry2.tables] } : {}
49248
+ });
48401
49249
  } else if (last.minCompatible !== entry2.minCompatible) {
48402
49250
  throw new Error(`the rows of version ${entry2.version} disagree on minCompatible`);
49251
+ } else if (entry2.tables && JSON.stringify(entry2.tables) !== JSON.stringify(last.tables)) {
49252
+ throw new Error(`the rows of version ${entry2.version} disagree on tables`);
48403
49253
  } else {
48404
49254
  last.statements.push(...found2.statements);
48405
49255
  }
@@ -48407,7 +49257,7 @@ var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated
48407
49257
  return migrations;
48408
49258
  }, "generatedMigrations");
48409
49259
 
48410
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/migrations.js
49260
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/migrations.js
48411
49261
  var MIGRATIONS = generatedMigrations();
48412
49262
  var HISTORY = `CREATE TABLE IF NOT EXISTS schema_migrations (
48413
49263
  version INTEGER PRIMARY KEY,
@@ -48421,12 +49271,36 @@ var fileState = /* @__PURE__ */ __name((database) => {
48421
49271
  const row2 = database.prepare("SELECT version, min_compatible FROM schema_migrations ORDER BY version DESC LIMIT 1").get();
48422
49272
  return { version: Number(row2?.version ?? 0), minCompatible: Number(row2?.min_compatible ?? 0) };
48423
49273
  }, "fileState");
48424
- var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now: now2 = Date.now, command, version, ownTable = OWN_TABLE } = {}) => {
49274
+ var copyBeforeBreaking = /* @__PURE__ */ __name((database, migrations, { ownTable, now: now2 }, options) => {
49275
+ if (!hasTable(database, "schema_migrations"))
49276
+ return void 0;
49277
+ const file = fileState(database);
49278
+ if (file.version === 0 || ownTable !== null && !hasTable(database, ownTable))
49279
+ return void 0;
49280
+ let floor = file.minCompatible;
49281
+ const tables = [];
49282
+ for (const migration of migrations) {
49283
+ if (migration.version <= file.version || migration.minCompatible <= floor)
49284
+ continue;
49285
+ floor = migration.minCompatible;
49286
+ for (const table of migration.tables ?? [])
49287
+ tables.push(table);
49288
+ }
49289
+ if (floor === file.minCompatible)
49290
+ return void 0;
49291
+ return takeRollbackCopy(database, { from: file.version, to: latest2(migrations), tables, at: now2() }, options);
49292
+ }, "copyBeforeBreaking");
49293
+ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now: now2 = Date.now, command, version, ownTable = OWN_TABLE, rollback } = {}) => {
48425
49294
  const ours = latest2(migrations);
49295
+ let copy = rollback ? copyBeforeBreaking(database, migrations, { ownTable, now: now2 }, rollback) : void 0;
48426
49296
  database.exec("BEGIN IMMEDIATE");
48427
49297
  try {
48428
49298
  database.exec(HISTORY);
48429
49299
  const file = fileState(database);
49300
+ if (copy && copy.from !== file.version) {
49301
+ discardRollbackCopy(copy);
49302
+ copy = void 0;
49303
+ }
48430
49304
  if (file.version > 0 && ownTable !== null && !hasTable(database, ownTable)) {
48431
49305
  throw new CliError("configuration_error", `the message store was written by another, incompatible tool (schema ${file.version} by its own numbering, with no meetings table) \u2014 this tool will not open or change it; move it aside to start a new store`);
48432
49306
  }
@@ -48449,6 +49323,8 @@ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now:
48449
49323
  }
48450
49324
  if (command && version)
48451
49325
  recordClient(database, { command, version, speaks: ours }, now2());
49326
+ if (copy)
49327
+ recordRollbackCopy(database, copy, now2());
48452
49328
  database.exec("COMMIT");
48453
49329
  return notice;
48454
49330
  } catch (error) {
@@ -48460,7 +49336,7 @@ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now:
48460
49336
  }
48461
49337
  }, "migrate");
48462
49338
 
48463
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
49339
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
48464
49340
  var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
48465
49341
  const pending = database.prepare("SELECT id, join_url FROM meetings WHERE join_url IS NOT NULL AND join_key IS NULL AND id > ? ORDER BY id LIMIT ?");
48466
49342
  if (pending.get(0, 1) === void 0)
@@ -48482,7 +49358,7 @@ var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
48482
49358
  }
48483
49359
  }, "fillJoinKeys");
48484
49360
 
48485
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
49361
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
48486
49362
  var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
48487
49363
  refuseOwnerStoreInTests(path);
48488
49364
  const opened = "Bun" in globalThis ? await openUnderBun(path, readOnly) : await openUnderNode(path, readOnly);
@@ -48496,8 +49372,8 @@ var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {})
48496
49372
  }, "openSqlite");
48497
49373
  var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
48498
49374
  quietSqliteWarning();
48499
- const { drizzle } = await import("./node-K57WT42O.js");
48500
- const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-KS6ORRIG.js");
49375
+ const { drizzle } = await import("./node-LTKZIO4U.js");
49376
+ const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-HQ5PN2RH.js");
48501
49377
  const client = await nodeClient(path, { readOnly });
48502
49378
  try {
48503
49379
  return { database: cacheOverNodeSqlite(client), orm: drizzle({ client }) };
@@ -48507,8 +49383,8 @@ var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
48507
49383
  }
48508
49384
  }, "openUnderNode");
48509
49385
  var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
48510
- const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-GXME7EMT.js");
48511
- const { drizzle } = await import("./bun-UYRQXF33.js");
49386
+ const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-S56EF74S.js");
49387
+ const { drizzle } = await import("./bun-LKMV5TY7.js");
48512
49388
  const client = await bunClient(path, readOnly ? { readonly: true, create: false } : void 0);
48513
49389
  try {
48514
49390
  return { database: cacheOverBunSqlite(client), orm: drizzle({ client }) };
@@ -48518,7 +49394,7 @@ var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
48518
49394
  }
48519
49395
  }, "openUnderBun");
48520
49396
 
48521
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-facts.js
49397
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-facts.js
48522
49398
  var PAYMENT_FACTS_TO_MOVE = "payment_facts_to_move";
48523
49399
  var paymentOf = /* @__PURE__ */ __name((metadata3) => {
48524
49400
  try {
@@ -48586,8 +49462,8 @@ var movePaymentFacts = /* @__PURE__ */ __name((context) => {
48586
49462
  });
48587
49463
  }, "movePaymentFacts");
48588
49464
 
48589
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
48590
- var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
49465
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
49466
+ var readCompatibility = /* @__PURE__ */ __name((database, command) => {
48591
49467
  const ours = MIGRATIONS.at(-1)?.version ?? 0;
48592
49468
  if (!database.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='schema_migrations'").get())
48593
49469
  throw new CliError("configuration_error", "The store has no schema history; initialize it explicitly before a read-only open");
@@ -48595,13 +49471,16 @@ var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
48595
49471
  const version = Number(row2?.version), minCompatible = Number(row2?.min_compatible);
48596
49472
  if (!Number.isSafeInteger(version) || !Number.isSafeInteger(minCompatible) || version < 1 || minCompatible < 1 || minCompatible > version)
48597
49473
  throw new CliError("configuration_error", "The store schema history is invalid; read-only opening cannot repair it");
48598
- if (version < ours)
48599
- throw new CliError("configuration_error", `The store needs schema ${ours} maintenance before a read-only open (found ${version})`);
48600
49474
  if (minCompatible > ours)
48601
49475
  throw new CliError("configuration_error", `The store requires schema ${minCompatible}, but this tool supports ${ours}; ${refusalAdvice(storeClients(database), command, version)}`);
49476
+ return version < ours ? "older" : "current";
49477
+ }, "readCompatibility");
49478
+ var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
49479
+ if (readCompatibility(database, command) === "older")
49480
+ throw new CliError("configuration_error", `The store needs schema ${MIGRATIONS.at(-1)?.version ?? 0} maintenance before a read-only open`);
48602
49481
  }, "assertReadCompatible");
48603
49482
 
48604
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/suggested-links.js
49483
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/suggested-links.js
48605
49484
  var SUGGESTED_LINKS_TO_MOVE = "suggested_links_to_move";
48606
49485
  var proposerOf2 = /* @__PURE__ */ __name((provenance2) => {
48607
49486
  if (provenance2?.startsWith("rule:"))
@@ -48647,7 +49526,7 @@ var moveSuggestedLinks = /* @__PURE__ */ __name((database, now2) => {
48647
49526
  });
48648
49527
  }, "moveSuggestedLinks");
48649
49528
 
48650
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/test-accounts.js
49529
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/test-accounts.js
48651
49530
  var TEST_ACCOUNTS_TO_PURGE = "test_accounts_to_purge";
48652
49531
  var TEST_PROVIDER = "chat";
48653
49532
  var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
@@ -48668,21 +49547,48 @@ var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
48668
49547
  }
48669
49548
  }, "purgeTestAccounts");
48670
49549
 
48671
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
49550
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
48672
49551
  var BACKFILL_ON_OPEN = 5e3;
48673
49552
  var NOT_WRITABLE = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EROFS"]);
48674
49553
  var createWritable = /* @__PURE__ */ __name((file) => {
48675
49554
  try {
48676
- mkdirSync(dirname(file), { recursive: true, mode: 448 });
48677
- writeFileSync(file, "", { flag: "a", mode: 384 });
49555
+ mkdirSync2(dirname2(file), { recursive: true, mode: 448 });
49556
+ if (existsSync(file))
49557
+ accessSync(file, constants.W_OK);
49558
+ else
49559
+ writeFileSync2(file, "", { flag: "wx", mode: 384 });
48678
49560
  } catch (error) {
49561
+ if (error.code === "EEXIST")
49562
+ return;
48679
49563
  if (!NOT_WRITABLE.has(error.code ?? ""))
48680
49564
  throw error;
48681
49565
  throw new CliError("permission_error", "the message store cannot be written from here; run where it is writable, or set MESSAGING_STORE", { reason: "store.not-writable" });
48682
49566
  }
48683
49567
  }, "createWritable");
48684
- var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Date.now, command, version, warn = /* @__PURE__ */ __name((line) => process.stderr.write(`${line}
48685
- `), "warn"), readOnly = false, decisions: decisions2 = DEFAULT_DECISION_POLICY } = {}) => {
49568
+ var openReadable = /* @__PURE__ */ __name(async (file, options) => {
49569
+ const first = await openSqlite(file, { readOnly: true });
49570
+ try {
49571
+ if (readCompatibility(first.database, options.command) === "current")
49572
+ return first;
49573
+ } catch (error) {
49574
+ first.database.close();
49575
+ throw error;
49576
+ }
49577
+ first.database.close();
49578
+ const writable = await openStoreContext({ ...options, path: file, readOnly: false });
49579
+ writable.database.close();
49580
+ const migrated = await openSqlite(file, { readOnly: true });
49581
+ try {
49582
+ assertReadCompatible(migrated.database, options.command);
49583
+ return migrated;
49584
+ } catch (error) {
49585
+ migrated.database.close();
49586
+ throw error;
49587
+ }
49588
+ }, "openReadable");
49589
+ var openStoreContext = /* @__PURE__ */ __name(async (options = {}) => {
49590
+ const { path, env, now: now2 = Date.now, command, version, warn = /* @__PURE__ */ __name((line) => process.stderr.write(`${line}
49591
+ `), "warn"), readOnly = false, decisions: decisions2 = DEFAULT_DECISION_POLICY } = options;
48686
49592
  if (typeof readOnly !== "boolean")
48687
49593
  throw new CliError("validation_error", "readOnly must be a boolean");
48688
49594
  await storeCapable();
@@ -48693,15 +49599,19 @@ var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Da
48693
49599
  throw new CliError("not_found", "The store does not exist as a file; read-only opening does not create it");
48694
49600
  } else
48695
49601
  createWritable(file);
48696
- const opened = await openSqlite(file, { readOnly });
49602
+ const opened = readOnly ? await openReadable(file, options) : await openSqlite(file, { readOnly });
48697
49603
  const database = opened.database;
48698
49604
  try {
48699
- if (readOnly)
48700
- assertReadCompatible(database, command);
48701
- else {
48702
- const notice = migrate(database, { now: now2, command, ...version ? { version } : {} });
49605
+ if (!readOnly) {
49606
+ const notice = migrate(database, {
49607
+ now: now2,
49608
+ command,
49609
+ ...version ? { version } : {},
49610
+ rollback: { store: file, warn }
49611
+ });
48703
49612
  if (notice)
48704
49613
  warn(notice);
49614
+ pruneRollbackCopies(database, now2());
48705
49615
  fillFiles(database, now2);
48706
49616
  fillFolded(database);
48707
49617
  fillJoinKeys(database);
@@ -48733,10 +49643,13 @@ var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Da
48733
49643
  }
48734
49644
  }, "openStoreContext");
48735
49645
 
48736
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
48737
- import { createHash as createHash16 } from "node:crypto";
49646
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
49647
+ import { createHash as createHash18 } from "node:crypto";
49648
+
49649
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
49650
+ import { createHash as createHash17 } from "node:crypto";
48738
49651
 
48739
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
49652
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
48740
49653
  var text4 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
48741
49654
  var ref = text4(2048);
48742
49655
  var timestamp2 = pipe(number(), safeInteger(), minValue(0));
@@ -48802,7 +49715,7 @@ var projectAnnotationsSchema = strictObject({
48802
49715
  }))
48803
49716
  });
48804
49717
 
48805
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
49718
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
48806
49719
  var PROJECT_ANNOTATIONS_MAX_BYTES = 4 * 1024 * 1024;
48807
49720
  var invalid7 = /* @__PURE__ */ __name((field4) => {
48808
49721
  throw new CliError("validation_error", `invalid project annotations.${field4}`);
@@ -48905,8 +49818,37 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
48905
49818
  if (!used.has(ref3))
48906
49819
  invalid7("external.unused");
48907
49820
  }, "validateProjectAnnotationsGraph");
49821
+ var decodeProjectAnnotations = /* @__PURE__ */ __name((json3) => {
49822
+ if (typeof json3 !== "string" || Buffer.byteLength(json3) > PROJECT_ANNOTATIONS_MAX_BYTES)
49823
+ invalid7("bytes");
49824
+ let input;
49825
+ try {
49826
+ input = JSON.parse(json3);
49827
+ } catch {
49828
+ return invalid7("json");
49829
+ }
49830
+ const parsed3 = safeParse(projectAnnotationsSchema, input);
49831
+ if (!parsed3.success)
49832
+ return invalid7(parsed3.issues[0]?.path?.map((part) => String(part.key)).join(".") ?? "manifest");
49833
+ const manifest = parsed3.output;
49834
+ if (manifest.aliases.length + manifest.facts.length + manifest.links.length + manifest.external.length > 1e3)
49835
+ invalid7("record budget");
49836
+ validateProjectAnnotationsGraph(manifest);
49837
+ return manifest;
49838
+ }, "decodeProjectAnnotations");
49839
+ var projectAnnotationsFingerprint = /* @__PURE__ */ __name((json3) => {
49840
+ const manifest = decodeProjectAnnotations(json3);
49841
+ const normalized = {
49842
+ ...manifest,
49843
+ aliases: manifest.aliases.toSorted(),
49844
+ facts: manifest.facts.toSorted((a, b) => a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0),
49845
+ links: manifest.links.toSorted((a, b) => a.ref.localeCompare(b.ref)),
49846
+ external: manifest.external.toSorted((a, b) => a.ref.localeCompare(b.ref))
49847
+ };
49848
+ return createHash17("sha256").update(JSON.stringify(normalized)).digest("hex");
49849
+ }, "projectAnnotationsFingerprint");
48908
49850
 
48909
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
49851
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
48910
49852
  var hash = pipe(string(), regex(/^[a-f0-9]{64}$/));
48911
49853
  var ref2 = pipe(string(), minLength(1), maxLength(2048));
48912
49854
  var targetSchema = strictObject({
@@ -48994,7 +49936,7 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
48994
49936
  }
48995
49937
  if (target.annotation_count > 0)
48996
49938
  conflicts.push({ reference: target.project, reason: "populated" });
48997
- const fingerprint2 = createHash16("sha256").update(JSON.stringify({
49939
+ const fingerprint2 = createHash18("sha256").update(JSON.stringify({
48998
49940
  manifest_fingerprint,
48999
49941
  target: {
49000
49942
  ...checked.output,
@@ -49011,9 +49953,10 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
49011
49953
  ready: missing_bindings.length === 0 && conflicts.length === 0
49012
49954
  };
49013
49955
  }, "planBoundProjectAnnotations");
49956
+ var planProjectAnnotations = /* @__PURE__ */ __name((json3, target, bindings) => planBoundProjectAnnotations(decodeProjectAnnotations(json3), projectAnnotationsFingerprint(json3), target, bindings), "planProjectAnnotations");
49014
49957
 
49015
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
49016
- import { createHash as createHash17 } from "node:crypto";
49958
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
49959
+ import { createHash as createHash19 } from "node:crypto";
49017
49960
  var text5 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
49018
49961
  var timestamp3 = pipe(number(), safeInteger(), minValue(0));
49019
49962
  var projectAnnotationSnapshotSchema = strictObject({
@@ -49097,7 +50040,7 @@ var decodeProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3) => {
49097
50040
  var projectAnnotationSnapshotFingerprint = /* @__PURE__ */ __name((json3) => {
49098
50041
  const snapshot2 = decodeProjectAnnotationSnapshot(json3);
49099
50042
  const order = /* @__PURE__ */ __name((a, b) => a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0, "order");
49100
- return createHash17("sha256").update(JSON.stringify({
50043
+ return createHash19("sha256").update(JSON.stringify({
49101
50044
  ...snapshot2,
49102
50045
  aliases: snapshot2.aliases.toSorted((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0),
49103
50046
  facts: snapshot2.facts.toSorted(order),
@@ -49106,7 +50049,7 @@ var projectAnnotationSnapshotFingerprint = /* @__PURE__ */ __name((json3) => {
49106
50049
  })).digest("hex");
49107
50050
  }, "projectAnnotationSnapshotFingerprint");
49108
50051
 
49109
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
50052
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
49110
50053
  var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false) => {
49111
50054
  if (!request || typeof request !== "object" || Array.isArray(request))
49112
50055
  throw new CliError("validation_error", "project annotation request is required");
@@ -49123,7 +50066,7 @@ var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false)
49123
50066
  return { snapshot: snapshot2, projectId: Number(request.project.slice(8)) };
49124
50067
  }, "projectAnnotationRequest");
49125
50068
 
49126
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
50069
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
49127
50070
  var SnapshotBudget = class {
49128
50071
  static {
49129
50072
  __name(this, "SnapshotBudget");
@@ -49149,14 +50092,14 @@ var SnapshotBudget = class {
49149
50092
  }
49150
50093
  };
49151
50094
 
49152
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
49153
- import { createHash as createHash19 } from "node:crypto";
50095
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
50096
+ import { createHash as createHash21 } from "node:crypto";
49154
50097
 
49155
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
50098
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
49156
50099
  var planProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3, target, bindings) => planBoundProjectAnnotations(decodeProjectAnnotationSnapshot(json3), projectAnnotationSnapshotFingerprint(json3), target, bindings), "planProjectAnnotationSnapshot");
49157
50100
 
49158
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
49159
- import { createHash as createHash18 } from "node:crypto";
50101
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
50102
+ import { createHash as createHash20 } from "node:crypto";
49160
50103
  var invalid9 = /* @__PURE__ */ __name(() => {
49161
50104
  throw new CliError("configuration_error", "project snapshot has an unavailable or unsupported dependency");
49162
50105
  }, "invalid");
@@ -49294,11 +50237,11 @@ var ProjectSnapshotSources = class {
49294
50237
  return this.digest("meeting_transcript", [header, cues]);
49295
50238
  }
49296
50239
  digest(kind3, content) {
49297
- return createHash18("sha256").update(JSON.stringify(["wirecat.project-source", 1, kind3, content])).digest("hex");
50240
+ return createHash20("sha256").update(JSON.stringify(["wirecat.project-source", 1, kind3, content])).digest("hex");
49298
50241
  }
49299
50242
  };
49300
50243
 
49301
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
50244
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
49302
50245
  var unsupported = /* @__PURE__ */ __name(() => {
49303
50246
  throw new CliError("configuration_error", "project snapshot has unsupported metadata, deletion or account scope");
49304
50247
  }, "unsupported");
@@ -49469,7 +50412,7 @@ var projectAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, bu
49469
50412
  return { snapshot: snapshot2, read_bytes: budget.bytes, records: budget.records };
49470
50413
  }), "projectAnnotationSnapshot");
49471
50414
 
49472
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
50415
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
49473
50416
  var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, manifest, bindings, budget) => read(database, () => {
49474
50417
  const current = projectAnnotationSnapshot(database, projectId2, budget).snapshot;
49475
50418
  const sources = new ProjectSnapshotSources(database, budget);
@@ -49510,7 +50453,7 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, ma
49510
50453
  const target = {
49511
50454
  project: current.project.ref,
49512
50455
  annotation_count: current.aliases.length + current.facts.length + current.links.length,
49513
- revision_sha256: createHash19("sha256").update(JSON.stringify({
50456
+ revision_sha256: createHash21("sha256").update(JSON.stringify({
49514
50457
  snapshot: projectAnnotationSnapshotFingerprint(JSON.stringify(current)),
49515
50458
  projects: projects2,
49516
50459
  aliases: aliases2,
@@ -49525,13 +50468,13 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, ma
49525
50468
  descriptor_conflicts,
49526
50469
  namespace_conflicts,
49527
50470
  ready: plan.ready && descriptor_conflicts.length === 0 && namespace_conflicts.length === 0,
49528
- fingerprint: createHash19("sha256").update(JSON.stringify({ plan: plan.fingerprint, descriptor_conflicts, namespace_conflicts })).digest("hex"),
50471
+ fingerprint: createHash21("sha256").update(JSON.stringify({ plan: plan.fingerprint, descriptor_conflicts, namespace_conflicts })).digest("hex"),
49529
50472
  read_bytes: budget.bytes,
49530
50473
  records: budget.records
49531
50474
  };
49532
50475
  }), "previewAnnotationSnapshot");
49533
50476
 
49534
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
50477
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
49535
50478
  var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, snapshot2, bindings) => {
49536
50479
  const mappings = { ...bindings };
49537
50480
  const resolve = /* @__PURE__ */ __name((ref3) => {
@@ -49573,7 +50516,7 @@ var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, sna
49573
50516
  return mappings;
49574
50517
  }, "restoreAnnotationRecords");
49575
50518
 
49576
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
50519
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
49577
50520
  var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
49578
50521
  async preview(request) {
49579
50522
  const { snapshot: snapshot2, projectId: projectId2 } = projectAnnotationRequest(request);
@@ -49603,7 +50546,7 @@ var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
49603
50546
  }
49604
50547
  }), "projectAnnotationStoreOver");
49605
50548
 
49606
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/records.js
50549
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/records.js
49607
50550
  var PROJECTED = {
49608
50551
  invoice: { roles: ["issuer", "counterparty", "project"], many: [] },
49609
50552
  payment: { roles: ["payer", "payee", "project", "settles"], many: ["settles"] }
@@ -50016,7 +50959,7 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
50016
50959
  };
50017
50960
  }, "recordStoreOver");
50018
50961
 
50019
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
50962
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
50020
50963
  var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to) => {
50021
50964
  const touching = and(eq(syncRanges.chatId, chatKey), lte(syncRanges.fromKey, to + 1), gte(syncRanges.toKey, from2 - 1));
50022
50965
  let merged = { from: from2, to };
@@ -50029,7 +50972,7 @@ var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to)
50029
50972
  }, "markRange");
50030
50973
  var ranges = /* @__PURE__ */ __name(({ orm }, chatKey) => orm.select({ from: syncRanges.fromKey, to: syncRanges.toKey }).from(syncRanges).where(eq(syncRanges.chatId, chatKey)).orderBy(syncRanges.fromKey).all(), "ranges");
50031
50974
 
50032
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-analysis-marks.js
50975
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-analysis-marks.js
50033
50976
  var prefixOf2 = /* @__PURE__ */ __name(({ provider, account }) => `task_analysis:${provider}:${account}:`, "prefixOf");
50034
50977
  var markOf = /* @__PURE__ */ __name((prefix, row2) => ({
50035
50978
  chatId: String(row2.key).slice(prefix.length),
@@ -50050,7 +50993,7 @@ var setTaskAnalysisMark = /* @__PURE__ */ __name((database, account, { chatId, c
50050
50993
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(prefixOf2(account) + chatId, JSON.stringify({ ...saved, checkedAt: checkedAt ?? new Date(now2).toISOString() }), now2);
50051
50994
  }, "setTaskAnalysisMark");
50052
50995
 
50053
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
50996
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
50054
50997
  var keyOf4 = /* @__PURE__ */ __name(({ provider, account }) => `task_rules_until:${provider}:${account}`, "keyOf");
50055
50998
  var taskRulesStop = /* @__PURE__ */ __name((database, account) => {
50056
50999
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(keyOf4(account));
@@ -50060,7 +51003,7 @@ var setTaskRulesStop = /* @__PURE__ */ __name((database, account, until, now2) =
50060
51003
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(keyOf4(account), JSON.stringify(until), now2);
50061
51004
  }, "setTaskRulesStop");
50062
51005
 
50063
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sync.js
51006
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sync.js
50064
51007
  var syncStoreOver = /* @__PURE__ */ __name((context) => {
50065
51008
  const { database } = context;
50066
51009
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, identityPk: identityPk2, writeMembers: writeMembers2, writeState: writeState2 } = keysOver(context);
@@ -50119,7 +51062,7 @@ var syncStoreOver = /* @__PURE__ */ __name((context) => {
50119
51062
  };
50120
51063
  }, "syncStoreOver");
50121
51064
 
50122
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/tags.js
51065
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/tags.js
50123
51066
  var tagsStoreOver = /* @__PURE__ */ __name((context) => {
50124
51067
  const { database } = context;
50125
51068
  return {
@@ -50141,7 +51084,7 @@ var tagsStoreOver = /* @__PURE__ */ __name((context) => {
50141
51084
  };
50142
51085
  }, "tagsStoreOver");
50143
51086
 
50144
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
51087
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
50145
51088
  var IS_IMAGE = sql`(a.kind = 'photo' OR a.mime LIKE 'image/%')`;
50146
51089
  var neighbours = /* @__PURE__ */ __name(({ orm }, chatKey, messagePk, sentAt, { messages: messages2, withinMs }, side) => orm.all(sql`SELECT sender_name AS sender, text, sent_at AS sentAt FROM messages
50147
51090
  WHERE chat_id = ${chatKey} AND deleted_at IS NULL AND trim(text) <> '' AND id <> ${messagePk}
@@ -50268,7 +51211,7 @@ var savePictureChunks = /* @__PURE__ */ __name(({ orm, now: now2, database }, ac
50268
51211
  dropUnusedVectors(database, released.map(({ hash: hash2 }) => hash2));
50269
51212
  }, "savePictureChunks");
50270
51213
 
50271
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
51214
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
50272
51215
  var messagesToEmbed = /* @__PURE__ */ __name(({ orm }, accountPk2, { chatKey, model, after: after2, limit }) => orm.all(sql`SELECT m.id AS messagePk, m.text, m.sent_at AS sentAt, k.content_hash AS hash,
50273
51216
  EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ${model} AND v.content_hash = k.content_hash) AS embedded
50274
51217
  FROM messages m
@@ -50357,7 +51300,7 @@ var nearestMessages = /* @__PURE__ */ __name((context, accountPk2, { limit, quer
50357
51300
  return plain2(best(found2));
50358
51301
  }, "nearestMessages");
50359
51302
 
50360
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/vectors.js
51303
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/vectors.js
50361
51304
  var accountVectorsOver = /* @__PURE__ */ __name((context, mail) => {
50362
51305
  const { database } = context;
50363
51306
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -50615,15 +51558,15 @@ var vectorsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
50615
51558
  embeddedHashes: /* @__PURE__ */ __name(async (model, hashes) => embeddedHashes(context, model, hashes), "embeddedHashes")
50616
51559
  }), "vectorsStoreOver");
50617
51560
 
50618
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
50619
- import { existsSync, readFileSync as readFileSync4 } from "node:fs";
50620
- import { dirname as dirname2, join as join2 } from "node:path";
50621
- var BOOKKEEPING = ["schema_migrations", "store_settings"];
51561
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
51562
+ import { existsSync as existsSync2, readFileSync as readFileSync4 } from "node:fs";
51563
+ import { dirname as dirname3, join as join3 } from "node:path";
51564
+ var BOOKKEEPING2 = ["schema_migrations", "store_settings"];
50622
51565
  var LISTED = `
50623
51566
  SELECT name, CASE
50624
51567
  WHEN type = 'virtual' THEN 'search_index'
50625
51568
  WHEN type = 'shadow' THEN 'search_index_part'
50626
- WHEN name LIKE 'sqlite\\_%' ESCAPE '\\' OR name IN (${BOOKKEEPING.map((name) => `'${name}'`).join(", ")})
51569
+ WHEN name LIKE 'sqlite\\_%' ESCAPE '\\' OR name IN (${BOOKKEEPING2.map((name) => `'${name}'`).join(", ")})
50627
51570
  THEN 'internal'
50628
51571
  ELSE 'data'
50629
51572
  END AS kind
@@ -50685,8 +51628,8 @@ var fileFacts = /* @__PURE__ */ __name((database, path) => {
50685
51628
  };
50686
51629
  }, "fileFacts");
50687
51630
  var lastBackup = /* @__PURE__ */ __name((path) => {
50688
- const marker = join2(dirname2(path), "backups", "last.json");
50689
- if (!existsSync(marker))
51631
+ const marker = join3(dirname3(path), "backups", "last.json");
51632
+ if (!existsSync2(marker))
50690
51633
  return null;
50691
51634
  try {
50692
51635
  const { at, file, checked } = JSON.parse(readFileSync4(marker, "utf8"));
@@ -50703,10 +51646,10 @@ var lastBackup = /* @__PURE__ */ __name((path) => {
50703
51646
  }
50704
51647
  }, "lastBackup");
50705
51648
 
50706
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/providers.js
51649
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/providers.js
50707
51650
  var registerProvider2 = /* @__PURE__ */ __name((store, entry2) => store.accounts.registerProvider(entry2), "registerProvider");
50708
51651
 
50709
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
51652
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
50710
51653
  var COUNTED_TABLES = [
50711
51654
  "accounts",
50712
51655
  "chats",
@@ -50791,7 +51734,7 @@ var storeContents = /* @__PURE__ */ __name((database) => {
50791
51734
  };
50792
51735
  }, "storeContents");
50793
51736
 
50794
- // node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/store/store.js
51737
+ // node_modules/.pnpm/@wirecat+cli-core@0.601.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_4fddd50439ae4e4f952967ea26554e7b/node_modules/@wirecat/cli-core/dist/store/store.js
50795
51738
  var openStore = /* @__PURE__ */ __name(async (options = {}) => {
50796
51739
  const context = await openStoreContext(options);
50797
51740
  try {
@@ -50858,6 +51801,8 @@ var storeOver = /* @__PURE__ */ __name((context) => {
50858
51801
  const finance = once3(() => financeStoreOver(context));
50859
51802
  const orders2 = once3(() => ordersStoreOver(context));
50860
51803
  const deals2 = once3(() => dealsStoreOver(context));
51804
+ const crm = once3(() => crmCopiesOver(context, accountPeopleOver(context)));
51805
+ const decisionRequests2 = once3(() => decisionRequestStoreOver(context));
50861
51806
  const records2 = once3(() => recordStoreOver(context));
50862
51807
  const memories2 = once3(() => memoriesStoreOver(context));
50863
51808
  const proposedActions2 = once3(() => proposedActionsStoreOver(context));
@@ -50971,6 +51916,12 @@ var storeOver = /* @__PURE__ */ __name((context) => {
50971
51916
  get deals() {
50972
51917
  return deals2();
50973
51918
  },
51919
+ get crm() {
51920
+ return crm();
51921
+ },
51922
+ get decisionRequests() {
51923
+ return decisionRequests2();
51924
+ },
50974
51925
  get records() {
50975
51926
  return records2();
50976
51927
  },
@@ -51000,6 +51951,7 @@ var storeOver = /* @__PURE__ */ __name((context) => {
51000
51951
  }, "storeOver");
51001
51952
 
51002
51953
  export {
51954
+ MAIL_FINDINGS_KIND,
51003
51955
  amountsOf,
51004
51956
  dueDayOf,
51005
51957
  isBotProvider,
@@ -51038,11 +51990,21 @@ export {
51038
51990
  savedPhoneCountries,
51039
51991
  saveStorePhoneCountries,
51040
51992
  normalizeVocabularyName,
51993
+ createTagRedirectIndex,
51994
+ tagMemberIds,
51041
51995
  inboxKey,
51996
+ storedThing,
51997
+ thingOf,
51998
+ referenceOfThing,
51999
+ stateOfThing,
52000
+ canonicalTagNamed,
51042
52001
  savedStemmers,
51043
52002
  stemmersOrigin,
51044
52003
  stemsState,
51045
52004
  stemmerCache,
52005
+ write,
52006
+ read,
52007
+ fillVectorIndexes,
51046
52008
  vectorIndexCounts,
51047
52009
  dropAllUnusedVectors,
51048
52010
  CHUNK_CHARS,
@@ -51050,7 +52012,10 @@ export {
51050
52012
  chunkHash,
51051
52013
  cutChunks,
51052
52014
  queryFilter,
52015
+ CORPORA,
52016
+ fillTrigrams,
51053
52017
  noteIndexState,
52018
+ drainCorpus,
51054
52019
  drainNoteIndex,
51055
52020
  resetNoteIndex,
51056
52021
  CHAT_COLUMNS,
@@ -51063,49 +52028,101 @@ export {
51063
52028
  MAIL_AGENDA_COLUMNS,
51064
52029
  AGENDA_COLUMNS,
51065
52030
  correctWords,
52031
+ drainMeetingIndex,
51066
52032
  THREAD_COLUMNS,
51067
52033
  threadConversation,
51068
52034
  messageOfEmail,
51069
52035
  resetAttachmentWords,
51070
52036
  attachmentColumns,
51071
52037
  accountGroupsOf,
52038
+ ownerPerson,
52039
+ botNamed,
51072
52040
  savedTaskCategories,
51073
52041
  DEFAULT_AGENT_CLOSE,
51074
52042
  certaintyOf,
51075
52043
  savedAgentClose,
52044
+ DEFAULT_DECISION_POLICY,
52045
+ isOwnerOnlyKind,
52046
+ mayDecide,
52047
+ assertMayDecide,
51076
52048
  MAX_FILE_BYTES,
51077
52049
  MAX_TEXT_CHARS,
51078
52050
  ATTACHMENT_LIMIT_ENV,
51079
52051
  attachmentMaxBytes,
51080
52052
  pdfPreviewLimits,
52053
+ syncFile,
52054
+ IMPORTED_DOCUMENT_QUERY,
51081
52055
  DEFAULT_FIRST_PASS_PER_CHAT,
51082
52056
  firstPassPerChatOf,
51083
52057
  savedFirstPassPerChat,
52058
+ TASK_SORTS,
52059
+ PROJECT_TASK_FIELDS,
51084
52060
  withoutField,
51085
52061
  TASK_RELATION_KINDS,
52062
+ TASK_ROLES,
52063
+ TASK_EVENT_KINDS,
52064
+ TASK_PAIR_DECISIONS,
51086
52065
  historyStartKey,
51087
52066
  fetchedKey,
51088
52067
  CHAT_LIST_KEY,
51089
52068
  CONVERSATION_COLUMNS,
51090
52069
  MENTION_STATUSES,
51091
52070
  MENTION_QUERY,
52071
+ rebuildMentions,
51092
52072
  delayStats,
51093
52073
  rankingContextRange,
51094
52074
  calendarKey,
51095
52075
  pendingNormalization,
52076
+ backfillNormalized,
51096
52077
  searchIndexState2 as searchIndexState,
51097
52078
  fillSearchIndex,
51098
52079
  resetSearchIndex,
51099
52080
  fillStems,
51100
52081
  resetStems,
52082
+ CATALOG_QUERY,
52083
+ crmIdentityId,
52084
+ DECISION_ACTIONS,
52085
+ DECISION_TTL_MS,
52086
+ CALLBACK_PREFIX,
52087
+ isDecisionToken,
52088
+ callbackDataOf,
52089
+ parseCallbackData,
52090
+ NOTE_FIELDS,
52091
+ EVENT_FIELDS,
52092
+ EVIDENCE_FINDINGS_KIND,
52093
+ validateEvidenceFindings,
51101
52094
  calendarMoment,
52095
+ PROPOSAL_STATUSES,
52096
+ proposerOfAction,
52097
+ assertGenericAction,
51102
52098
  involvementStoreOver,
52099
+ ORGANIZATIONS_QUERY,
52100
+ PROJECTS_QUERY,
52101
+ REMINDERS_QUERY,
52102
+ ORGANIZATION_KINDS,
52103
+ PROJECT_TYPES,
52104
+ SCOPES,
51103
52105
  OTHER_SOURCES,
51104
52106
  storeClients,
52107
+ rollBack,
51105
52108
  MIGRATIONS,
51106
52109
  migrate,
51107
52110
  openSqlite,
52111
+ assertReadCompatible,
51108
52112
  BACKFILL_ON_OPEN,
52113
+ openStoreContext,
52114
+ PROJECT_ANNOTATIONS_MAX_BYTES,
52115
+ decodeProjectAnnotations,
52116
+ projectAnnotationsFingerprint,
52117
+ projectAnnotationBindingSources,
52118
+ planProjectAnnotations,
52119
+ projectAnnotationSnapshotSchema,
52120
+ decodeProjectAnnotationSnapshot,
52121
+ projectAnnotationSnapshotFingerprint,
52122
+ SnapshotBudget,
52123
+ planProjectAnnotationSnapshot,
52124
+ projectAnnotationSnapshot,
52125
+ previewAnnotationSnapshot,
51109
52126
  readStoreTables,
51110
52127
  fileFacts,
51111
52128
  registerProvider2 as registerProvider,