@wirecat/zoom-cli 0.70.0 → 0.71.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 (144) hide show
  1. package/dist/answer-entities.d.ts +2 -0
  2. package/dist/answer-entities.d.ts.map +1 -1
  3. package/dist/bin/zm.js +2 -2
  4. package/dist/bundle/{all-profiles-GE2TFJJP.js → all-profiles-O4YNVPZX.js} +7 -7
  5. package/dist/bundle/{answer-policy-GOXSDYDD.js → answer-policy-PPSPMCLH.js} +52 -52
  6. package/dist/bundle/{anthropic-FA6NHENI.js → anthropic-7GGRX3RX.js} +13 -4
  7. package/dist/bundle/{app-server-IRADMSNX.js → app-server-CPMKM3HI.js} +46 -46
  8. package/dist/bundle/{bun-ZYZGGCX5.js → bun-POHZKEPV.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-Y24TUIGS.js → bun-sqlite-PGYMBPEL.js} +2 -2
  10. package/dist/bundle/{chunk-DCUWJITQ.js → chunk-2FV5JUQU.js} +38 -592
  11. package/dist/bundle/{chunk-DNR4B5YV.js → chunk-2KESWII5.js} +2 -2
  12. package/dist/bundle/{chunk-KWRCP55G.js → chunk-2RUAMDVV.js} +10 -10
  13. package/dist/bundle/{chunk-IS3ZTT2Z.js → chunk-2U27KIKU.js} +2 -2
  14. package/dist/bundle/chunk-4LAQDZXU.js +1635 -0
  15. package/dist/bundle/{chunk-6IF5ZHDS.js → chunk-4QPQ7MDA.js} +1 -1
  16. package/dist/bundle/{chunk-MVOMLJYQ.js → chunk-4QUFFB2U.js} +3 -3
  17. package/dist/bundle/{chunk-AUNW7N4I.js → chunk-54YDWBYG.js} +1 -1
  18. package/dist/bundle/{chunk-AISJCF7A.js → chunk-5J4AMBMM.js} +4 -4
  19. package/dist/bundle/{chunk-UVPL7YAY.js → chunk-5K7OGPGA.js} +4 -4
  20. package/dist/bundle/{chunk-RO3ZR4VP.js → chunk-5LJTU4LY.js} +12 -12
  21. package/dist/bundle/{chunk-YTN2JN6N.js → chunk-633QXP57.js} +9 -7
  22. package/dist/bundle/{chunk-DXCTW3MV.js → chunk-64ZHF6PJ.js} +1 -1
  23. package/dist/bundle/{chunk-JRO2FWO2.js → chunk-77TCCHMP.js} +1 -1
  24. package/dist/bundle/{chunk-CIZ25UPK.js → chunk-7ROXXRGG.js} +2282 -1087
  25. package/dist/bundle/{chunk-OA37BWE5.js → chunk-ALIT5QFT.js} +1 -1
  26. package/dist/bundle/{chunk-V2E7QFZ3.js → chunk-BBTQIVFP.js} +1 -1
  27. package/dist/bundle/{chunk-M7E44TMT.js → chunk-BGTEVIW4.js} +5 -5
  28. package/dist/bundle/{chunk-2QFPVUM3.js → chunk-CFQF6IGY.js} +2 -2
  29. package/dist/bundle/{chunk-XWQNJKTP.js → chunk-CKPCVEXU.js} +5 -5
  30. package/dist/bundle/{chunk-L24UOUWG.js → chunk-CRFOGYDG.js} +1 -1
  31. package/dist/bundle/{chunk-OAQLVV6W.js → chunk-CT4WVR4N.js} +2 -2
  32. package/dist/bundle/{chunk-SNIY3JDN.js → chunk-DHWBSXG3.js} +20 -20
  33. package/dist/bundle/{chunk-CHGUNZ3L.js → chunk-DIQLXAAZ.js} +3 -3
  34. package/dist/bundle/{chunk-RRRJCHUC.js → chunk-DK6ICIGL.js} +3141 -982
  35. package/dist/bundle/{chunk-YUHM2OJM.js → chunk-DRBQDCDU.js} +9 -9
  36. package/dist/bundle/{chunk-LAG5O2FV.js → chunk-DSVZEXYJ.js} +1093 -895
  37. package/dist/bundle/{chunk-4DSIWYGO.js → chunk-FSHCAWZS.js} +29110 -16686
  38. package/dist/bundle/{chunk-SVF3NDAO.js → chunk-GGS6D4W4.js} +2 -2
  39. package/dist/bundle/{chunk-V5GRSOCZ.js → chunk-GL3MYFMX.js} +3 -3
  40. package/dist/bundle/{chunk-VSLDWT4E.js → chunk-GXF5HFFP.js} +3 -3
  41. package/dist/bundle/{chunk-ZV3INEKM.js → chunk-HB6XJQ3Y.js} +4 -4
  42. package/dist/bundle/{chunk-GB5X3GBE.js → chunk-I4DFFR7F.js} +2 -2
  43. package/dist/bundle/{chunk-ZS55EERO.js → chunk-IAV5BG3I.js} +1 -1
  44. package/dist/bundle/{chunk-VNU5L37V.js → chunk-IED3NS7G.js} +27 -35
  45. package/dist/bundle/{chunk-W7ZEEC4K.js → chunk-INVTDIF6.js} +1 -1
  46. package/dist/bundle/{chunk-GVT5363M.js → chunk-KMV7GZB6.js} +1 -1
  47. package/dist/bundle/{chunk-LXXCLQCW.js → chunk-LE7MDAQG.js} +2 -2
  48. package/dist/bundle/{chunk-2JEM2YNV.js → chunk-M76MXMLY.js} +1 -1
  49. package/dist/bundle/{chunk-RWIILYKW.js → chunk-MEED7YFG.js} +1 -1
  50. package/dist/bundle/{chunk-56OV5ASY.js → chunk-MRI6QMZ3.js} +9 -9
  51. package/dist/bundle/{chunk-BSS6HX4O.js → chunk-MW4EGDDV.js} +2 -2
  52. package/dist/bundle/{chunk-6HJFIMT7.js → chunk-N2FNMION.js} +1 -1
  53. package/dist/bundle/{chunk-J3SKXICS.js → chunk-OHWMIUCT.js} +139 -544
  54. package/dist/bundle/{chunk-M7VUXXGS.js → chunk-OWEBWDHV.js} +58 -3
  55. package/dist/bundle/{chunk-BVWF4B33.js → chunk-P3XC6EDU.js} +15 -19
  56. package/dist/bundle/{chunk-JULBAECW.js → chunk-Q2SUFGSH.js} +16 -6
  57. package/dist/bundle/{chunk-QL7EMFIC.js → chunk-Q3XLZIY3.js} +16 -16
  58. package/dist/bundle/{chunk-M6JIXMQZ.js → chunk-Q5PI72CR.js} +1 -1
  59. package/dist/bundle/{chunk-X4ZF4XXI.js → chunk-QTHIU7CO.js} +1 -1
  60. package/dist/bundle/{chunk-CSEBB4OP.js → chunk-QVSLSWAL.js} +7 -7
  61. package/dist/bundle/{chunk-VJ5ZU4UF.js → chunk-RN4EHCC5.js} +2 -2
  62. package/dist/bundle/{chunk-D3PNCJD5.js → chunk-SELXER2Q.js} +3 -3
  63. package/dist/bundle/{chunk-YJSPBUGB.js → chunk-TM4JSVGQ.js} +38 -49
  64. package/dist/bundle/{chunk-5XWCBLUR.js → chunk-UG447QY2.js} +1 -1
  65. package/dist/bundle/{chunk-RIPAUCKJ.js → chunk-ULDXZ6LH.js} +64 -57
  66. package/dist/bundle/chunk-USQ23X5V.js +1227 -0
  67. package/dist/bundle/{chunk-PV6OHXHN.js → chunk-VJXHIUFP.js} +14 -14
  68. package/dist/bundle/{chunk-3KC7C465.js → chunk-VRH7VRTK.js} +7 -7
  69. package/dist/bundle/{chunk-ZSKE7N2U.js → chunk-X277FBTF.js} +2 -2
  70. package/dist/bundle/{chunk-KM736RMJ.js → chunk-X3ZDN3U7.js} +1 -1
  71. package/dist/bundle/{chunk-CEJJBZAE.js → chunk-X4GWR6GO.js} +8 -8
  72. package/dist/bundle/chunk-XI3VIQKW.js +756 -0
  73. package/dist/bundle/{chunk-IWPXWGF7.js → chunk-YD2RYVMK.js} +33 -33
  74. package/dist/bundle/{chunk-RB33VTUW.js → chunk-YPO2U2YB.js} +473 -118
  75. package/dist/bundle/{chunk-IINZIP73.js → chunk-ZBFL5JPT.js} +7 -6
  76. package/dist/bundle/{chunk-QO2KPU26.js → chunk-ZVI6TFQR.js} +100 -43
  77. package/dist/bundle/{cli-VRSQ7HAE.js → cli-KHMEUXNG.js} +117 -64
  78. package/dist/bundle/command-contract-4K6XXZYE.js +41 -0
  79. package/dist/bundle/config-EEDB632I.js +90 -0
  80. package/dist/bundle/{decode-523PUQMR.js → decode-7RP4HSVE.js} +2 -2
  81. package/dist/bundle/{dist-6WWKPEVW.js → dist-BFT2SUBV.js} +60 -40
  82. package/dist/bundle/{echarts-S5UMX2D3.js → echarts-T2BSQ2YV.js} +2 -2
  83. package/dist/bundle/{embed-ODPDVHUK.js → embed-BAS6YPDT.js} +3 -3
  84. package/dist/bundle/{embedder-PAXRBSZE.js → embedder-5XD5FCAO.js} +6 -6
  85. package/dist/bundle/{first-run-NVTDR5VO.js → first-run-23WWZ2PW.js} +5 -5
  86. package/dist/bundle/first-screen-6HFUYVFR.js +39 -0
  87. package/dist/bundle/{instructions-DUB7E6C5.js → instructions-XZPROPKY.js} +1 -1
  88. package/dist/bundle/{main-A7JSYQI6.js → main-TZXKGL3L.js} +12 -12
  89. package/dist/bundle/{meetings-BDZQV3HR.js → meetings-JB2ISPND.js} +3 -1
  90. package/dist/bundle/{node-E25KP53H.js → node-A3B3MJWX.js} +2 -2
  91. package/dist/bundle/{node-sqlite-PHWDFZCP.js → node-sqlite-QVWDLGDX.js} +3 -3
  92. package/dist/bundle/{oauth-G2K46IYP.js → oauth-YA6IYV4O.js} +4 -4
  93. package/dist/bundle/{open-INWS5HIZ.js → open-SY7TXJBS.js} +2 -2
  94. package/dist/bundle/{openai-T44ORVGQ.js → openai-2AU24NRN.js} +8 -8
  95. package/dist/bundle/{process-UJ2JHMJN.js → process-6HNBTJIY.js} +1 -1
  96. package/dist/bundle/{program-LYTGFV6L.js → program-77BUCJ4H.js} +78 -89
  97. package/dist/bundle/{prompt-VTUCRCE4.js → prompt-YDG73YDS.js} +2 -2
  98. package/dist/bundle/{recognize-3CEPOW2F.js → recognize-ECXDGTB7.js} +1 -1
  99. package/dist/bundle/{remote-DRQEXEZL.js → remote-K4JHGBVJ.js} +4 -4
  100. package/dist/bundle/{rerank-UL4KNNVN.js → rerank-IU2YYD4T.js} +4 -4
  101. package/dist/bundle/{run-log-UZAB5CWF.js → run-log-LFEXNZ74.js} +50 -50
  102. package/dist/bundle/{serve-P5UWUOWQ.js → serve-3XWIF3HI.js} +6 -6
  103. package/dist/bundle/{server-M6XK2Y3X.js → server-56VYOHWP.js} +38 -38
  104. package/dist/bundle/server-YSTMUZ22.js +72 -0
  105. package/dist/bundle/{services-4HRYNY62.js → services-X7IPEGQ5.js} +85 -33
  106. package/dist/bundle/{speech-BBPBMFAO.js → speech-E2OBQWYA.js} +10 -10
  107. package/dist/bundle/{state-GDSUNUSY.js → state-4GMJYK4H.js} +3 -3
  108. package/dist/bundle/{store-VWLABMLF.js → store-KPI7GB5Y.js} +37 -19
  109. package/dist/bundle/{store-LBQ6FZP2.js → store-LA4TV4DM.js} +19 -13
  110. package/dist/bundle/store-connection-AZTIF6IH.js +83 -0
  111. package/dist/bundle/store-maintenance-command-LR572PS4.js +61 -0
  112. package/dist/bundle/zm.js +2 -2
  113. package/dist/bundle/{zoom-app-YIEJLWCW.js → zoom-app-QEJBTIJ4.js} +2 -2
  114. package/dist/contract-overrides.d.ts.map +1 -1
  115. package/dist/contract-overrides.js +0 -6
  116. package/dist/contract-overrides.js.map +1 -1
  117. package/dist/ingestion-search-commands.d.ts.map +1 -1
  118. package/dist/ingestion-search-commands.js +0 -10
  119. package/dist/ingestion-search-commands.js.map +1 -1
  120. package/dist/meeting-integration-commands.d.ts.map +1 -1
  121. package/dist/meeting-integration-commands.js +8 -6
  122. package/dist/meeting-integration-commands.js.map +1 -1
  123. package/dist/meeting-integration.d.ts +3 -1
  124. package/dist/meeting-integration.d.ts.map +1 -1
  125. package/dist/store-connection.d.ts.map +1 -1
  126. package/dist/store-connection.js +4 -3
  127. package/dist/store-connection.js.map +1 -1
  128. package/dist/unified-search.d.ts +4 -4
  129. package/dist/unified-search.d.ts.map +1 -1
  130. package/dist/unified-search.js +1 -24
  131. package/dist/unified-search.js.map +1 -1
  132. package/dist/version.d.ts +1 -1
  133. package/dist/version.js +1 -1
  134. package/package.json +3 -3
  135. package/skills/zoom-cli/SKILL.md +2 -2
  136. package/dist/bundle/chunk-AT2XKNFN.js +0 -342
  137. package/dist/bundle/chunk-VE2VNECR.js +0 -380
  138. package/dist/bundle/chunk-Y6C3N7YG.js +0 -12434
  139. package/dist/bundle/command-contract-RPRKHVU6.js +0 -41
  140. package/dist/bundle/config-QU6A6VIO.js +0 -90
  141. package/dist/bundle/first-screen-5RWZDWLK.js +0 -39
  142. package/dist/bundle/server-F3NPVMS2.js +0 -72
  143. package/dist/bundle/store-connection-XEBFP56U.js +0 -83
  144. package/dist/bundle/store-maintenance-command-G43JN57J.js +0 -61
@@ -2,11 +2,11 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  renderMessages
5
- } from "./chunk-KM736RMJ.js";
5
+ } from "./chunk-X3ZDN3U7.js";
6
6
  import {
7
7
  answerOf,
8
8
  messengerContext
9
- } from "./chunk-DCUWJITQ.js";
9
+ } from "./chunk-2FV5JUQU.js";
10
10
  import {
11
11
  chatEventAnswer,
12
12
  memberAnswer,
@@ -15,14 +15,14 @@ import {
15
15
  serveRelay,
16
16
  typedQuery,
17
17
  withQuery
18
- } from "./chunk-QL7EMFIC.js";
18
+ } from "./chunk-Q3XLZIY3.js";
19
19
  import {
20
20
  holdLock,
21
21
  lockPath,
22
22
  releaseLock,
23
23
  servingProfiles,
24
24
  takeLock
25
- } from "./chunk-SVF3NDAO.js";
25
+ } from "./chunk-GGS6D4W4.js";
26
26
  import {
27
27
  FETCHING,
28
28
  RULES_VERSION,
@@ -39,14 +39,15 @@ import {
39
39
  servicesFor,
40
40
  syncsOneChat,
41
41
  withTimeLimit
42
- } from "./chunk-RRRJCHUC.js";
42
+ } from "./chunk-DK6ICIGL.js";
43
43
  import {
44
44
  QUICK_HEALTH_CHECKS,
45
- explainDamage,
46
45
  fts5Tables,
47
46
  invalidJson,
47
+ lossUnknown,
48
+ storeDamageReport,
48
49
  storeHealth
49
- } from "./chunk-QO2KPU26.js";
50
+ } from "./chunk-ZVI6TFQR.js";
50
51
  import {
51
52
  Command,
52
53
  LOCAL_READ,
@@ -68,19 +69,18 @@ import {
68
69
  snakeKeys,
69
70
  storeTable,
70
71
  withoutProviderRefs
71
- } from "./chunk-LAG5O2FV.js";
72
+ } from "./chunk-DSVZEXYJ.js";
72
73
  import {
73
74
  holdersOf
74
- } from "./chunk-OA37BWE5.js";
75
+ } from "./chunk-ALIT5QFT.js";
75
76
  import {
76
77
  codeOf,
77
- currentRun,
78
78
  modelTarget,
79
79
  parseDuration
80
- } from "./chunk-J3SKXICS.js";
80
+ } from "./chunk-OHWMIUCT.js";
81
81
  import {
82
82
  levelFor
83
- } from "./chunk-M6JIXMQZ.js";
83
+ } from "./chunk-Q5PI72CR.js";
84
84
  import {
85
85
  CORPORA,
86
86
  MIGRATIONS,
@@ -94,6 +94,7 @@ import {
94
94
  fillTrigrams,
95
95
  fillVectorIndexes,
96
96
  involvementStoreOver,
97
+ isDerivedTable,
97
98
  migrate,
98
99
  noteIndexState,
99
100
  openSqlite,
@@ -114,29 +115,31 @@ import {
114
115
  storeClients,
115
116
  storeContents,
116
117
  vectorIndexCounts
117
- } from "./chunk-4DSIWYGO.js";
118
- import {
119
- formatLocator,
120
- parseLocator
121
- } from "./chunk-Y6C3N7YG.js";
118
+ } from "./chunk-FSHCAWZS.js";
122
119
  import {
120
+ currentRun,
123
121
  readDamageMark,
124
122
  readHealthMark,
123
+ readJournalMark,
125
124
  recordDeepCheck
126
- } from "./chunk-VE2VNECR.js";
125
+ } from "./chunk-USQ23X5V.js";
127
126
  import {
128
127
  failureKey,
129
128
  isStoreDamage
130
- } from "./chunk-RWIILYKW.js";
129
+ } from "./chunk-MEED7YFG.js";
130
+ import {
131
+ formatLocator,
132
+ parseLocator
133
+ } from "./chunk-XI3VIQKW.js";
131
134
  import {
132
135
  readSecret
133
- } from "./chunk-VJ5ZU4UF.js";
136
+ } from "./chunk-RN4EHCC5.js";
134
137
  import {
135
138
  storePath
136
- } from "./chunk-GVT5363M.js";
139
+ } from "./chunk-KMV7GZB6.js";
137
140
  import {
138
141
  openCache
139
- } from "./chunk-M7E44TMT.js";
142
+ } from "./chunk-BGTEVIW4.js";
140
143
  import {
141
144
  queryFieldsOf
142
145
  } from "./chunk-EOSVN2ER.js";
@@ -1821,7 +1824,7 @@ var require_liquid_node = __commonJS({
1821
1824
  return readFileAsync(filepath, "utf8");
1822
1825
  }
1823
1826
  __name(readFile, "readFile");
1824
- function existsSync10(filepath) {
1827
+ function existsSync11(filepath) {
1825
1828
  try {
1826
1829
  fs$1.statSync(filepath);
1827
1830
  return true;
@@ -1829,11 +1832,11 @@ var require_liquid_node = __commonJS({
1829
1832
  return false;
1830
1833
  }
1831
1834
  }
1832
- __name(existsSync10, "existsSync");
1833
- function readFileSync5(filepath) {
1835
+ __name(existsSync11, "existsSync");
1836
+ function readFileSync6(filepath) {
1834
1837
  return fs$1.readFileSync(filepath, "utf8");
1835
1838
  }
1836
- __name(readFileSync5, "readFileSync");
1839
+ __name(readFileSync6, "readFileSync");
1837
1840
  function resolve2(root, file2, ext) {
1838
1841
  if (!path.extname(file2))
1839
1842
  file2 += ext;
@@ -1847,10 +1850,10 @@ var require_liquid_node = __commonJS({
1847
1850
  }
1848
1851
  }
1849
1852
  __name(fallback, "fallback");
1850
- function dirname3(filepath) {
1853
+ function dirname4(filepath) {
1851
1854
  return path.dirname(filepath);
1852
1855
  }
1853
- __name(dirname3, "dirname");
1856
+ __name(dirname4, "dirname");
1854
1857
  var realpathAsync = promisify(fs$1.realpath);
1855
1858
  async function contains(root, file2) {
1856
1859
  try {
@@ -1878,11 +1881,11 @@ var require_liquid_node = __commonJS({
1878
1881
  __proto__: null,
1879
1882
  exists,
1880
1883
  readFile,
1881
- existsSync: existsSync10,
1882
- readFileSync: readFileSync5,
1884
+ existsSync: existsSync11,
1885
+ readFileSync: readFileSync6,
1883
1886
  resolve: resolve2,
1884
1887
  fallback,
1885
- dirname: dirname3,
1888
+ dirname: dirname4,
1886
1889
  contains,
1887
1890
  containsSync,
1888
1891
  sep: path.sep
@@ -3607,7 +3610,7 @@ var require_liquid_node = __commonJS({
3607
3610
  uri_escape,
3608
3611
  slugify
3609
3612
  });
3610
- var join5 = argumentsToValue(function(v, arg) {
3613
+ var join6 = argumentsToValue(function(v, arg) {
3611
3614
  const array2 = toArray(v);
3612
3615
  const sep = isNil(arg) ? " " : stringify(arg);
3613
3616
  let outputSize = sep.length * Math.max(array2.length - 1, 0);
@@ -3883,7 +3886,7 @@ var require_liquid_node = __commonJS({
3883
3886
  __name(sample, "sample");
3884
3887
  var arrayFilters = /* @__PURE__ */ Object.freeze({
3885
3888
  __proto__: null,
3886
- join: join5,
3889
+ join: join6,
3887
3890
  last,
3888
3891
  first,
3889
3892
  reverse,
@@ -5507,11 +5510,11 @@ var require_liquid_node = __commonJS({
5507
5510
  }
5508
5511
  });
5509
5512
 
5510
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5511
- import { chmodSync, constants, copyFileSync, existsSync as existsSync9, mkdirSync, realpathSync as realpathSync2, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
5512
- import { dirname as dirname2, resolve } from "node:path";
5513
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5514
+ import { chmodSync, constants, copyFileSync, existsSync as existsSync10, mkdirSync, realpathSync as realpathSync3, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
5515
+ import { dirname as dirname3, resolve } from "node:path";
5513
5516
 
5514
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/sealed.js
5517
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/sealed.js
5515
5518
  import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
5516
5519
  import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
5517
5520
  import { Transform } from "node:stream";
@@ -5618,7 +5621,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
5618
5621
  renameSync(pending, to);
5619
5622
  }, "unsealFile");
5620
5623
 
5621
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5624
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5622
5625
  var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
5623
5626
  var fileSchemaOf = /* @__PURE__ */ __name((database) => {
5624
5627
  const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
@@ -5642,7 +5645,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
5642
5645
  };
5643
5646
  }, "compatibilityOf");
5644
5647
 
5645
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/store/repair.js
5648
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/repair.js
5646
5649
  import { createHash as createHash2 } from "node:crypto";
5647
5650
  var COPY_MARK = "__repair_";
5648
5651
  var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
@@ -5896,17 +5899,99 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
5896
5899
  return found;
5897
5900
  }, "deleteCopy");
5898
5901
 
5899
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5902
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5900
5903
  import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
5901
5904
 
5902
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
5905
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
5903
5906
  import { existsSync as existsSync3 } from "node:fs";
5904
5907
 
5905
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/store/recover.js
5908
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/recover.js
5906
5909
  import { execFileSync, spawn } from "node:child_process";
5907
5910
  import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
5908
5911
  import { basename, dirname, join } from "node:path";
5909
5912
  import { Transform as Transform2 } from "node:stream";
5913
+
5914
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/refill.js
5915
+ var REFILL_MARGIN_MS = 864e5;
5916
+ var TIME_KEYS = 1e12;
5917
+ var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
5918
+ var forgetCoverageSince = /* @__PURE__ */ __name((database, cutoff, now = Date.now()) => {
5919
+ database.exec("BEGIN");
5920
+ try {
5921
+ const refetch = forget(database, cutoff, now);
5922
+ database.exec("COMMIT");
5923
+ return refetch;
5924
+ } catch (error) {
5925
+ database.exec("ROLLBACK");
5926
+ throw error;
5927
+ }
5928
+ }, "forgetCoverageSince");
5929
+ var forget = /* @__PURE__ */ __name((database, cutoff, now) => {
5930
+ const chats = /* @__PURE__ */ new Map();
5931
+ const held = database.prepare(`SELECT c.id, c.account_id, c.external_id AS chat, a.provider, a.external_id AS account,
5932
+ max(r.to_key) AS top FROM sync_ranges r JOIN chats c ON c.id = r.chat_id JOIN accounts a ON a.id = c.account_id
5933
+ GROUP BY c.id`).all();
5934
+ for (const row of held) {
5935
+ const chat = Number(row.id);
5936
+ const top = Number(row.top);
5937
+ const keepTo = cutoff === null ? null : top >= TIME_KEYS ? cutoff : database.prepare(`SELECT max(CAST(external_id AS INTEGER)) AS k FROM messages WHERE chat_id = ? AND sent_at < ? AND ${integerId}`).get(chat, cutoff)?.k;
5938
+ if (keepTo !== null && top <= keepTo)
5939
+ continue;
5940
+ if (keepTo === null)
5941
+ database.prepare("DELETE FROM sync_ranges WHERE chat_id = ?").run(chat);
5942
+ else {
5943
+ database.prepare("DELETE FROM sync_ranges WHERE chat_id = ? AND from_key > ?").run(chat, keepTo);
5944
+ database.prepare("UPDATE sync_ranges SET to_key = ?, updated_at = ? WHERE chat_id = ? AND to_key > ?").run(keepTo, now, chat, keepTo);
5945
+ }
5946
+ const account = Number(row.account_id);
5947
+ const external = String(row.chat);
5948
+ database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(account, `fetched:${external}`);
5949
+ database.prepare(`DELETE FROM sync_cursors WHERE account_id = ? AND key = ? AND NOT EXISTS
5950
+ (SELECT 1 FROM sync_ranges WHERE chat_id = ? AND from_key <= CAST(sync_cursors.value AS INTEGER))`).run(account, `history_start:${external}`, chat);
5951
+ const key = `${row.provider}\0${row.account}`;
5952
+ const one = chats.get(key) ?? { provider: String(row.provider), account: String(row.account), chats: 0 };
5953
+ one.chats += 1;
5954
+ chats.set(key, one);
5955
+ }
5956
+ return {
5957
+ since: cutoff === null ? null : new Date(cutoff).toISOString(),
5958
+ chats: [...chats.values()],
5959
+ mail: forgetMail(database, cutoff, now)
5960
+ };
5961
+ }, "forget");
5962
+ var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
5963
+ const folders = /* @__PURE__ */ new Map();
5964
+ const points = database.prepare(`SELECT s.account_id, s.key, s.value, a.external_id AS account FROM sync_cursors s
5965
+ JOIN accounts a ON a.id = s.account_id WHERE a.provider = 'email' AND s.key LIKE 'mail_resume:%'`).all();
5966
+ for (const row of points) {
5967
+ let point;
5968
+ try {
5969
+ point = JSON.parse(String(row.value));
5970
+ } catch {
5971
+ continue;
5972
+ }
5973
+ const account = String(row.account);
5974
+ if (!Array.isArray(point.done)) {
5975
+ if (cutoff !== null && Date.parse(point.updatedAt ?? "") < cutoff)
5976
+ continue;
5977
+ database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(Number(row.account_id), String(row.key));
5978
+ folders.set(account, (folders.get(account) ?? 0) + 1);
5979
+ continue;
5980
+ }
5981
+ const folder = String(row.key).slice("mail_resume:".length);
5982
+ const last = cutoff === null ? null : database.prepare(`SELECT max(l.uid) AS uid FROM email_locations l JOIN emails e ON e.id = l.email_id
5983
+ WHERE l.mailbox_id = (SELECT id FROM mailboxes WHERE account_id = ? AND external_id = ?)
5984
+ AND l.uidvalidity = ? AND coalesce(e.received_at, e.sent_at) < ?`).get(Number(row.account_id), folder, point.validity ?? "", cutoff)?.uid;
5985
+ const done = last === null ? [] : point.done.filter(([from]) => from <= last).map(([from, to]) => [from, Math.min(to, last)]);
5986
+ if (JSON.stringify(done) === JSON.stringify(point.done))
5987
+ continue;
5988
+ database.prepare("UPDATE sync_cursors SET value = ?, updated_at = ? WHERE account_id = ? AND key = ?").run(JSON.stringify({ ...point, done }), now, Number(row.account_id), String(row.key));
5989
+ folders.set(account, (folders.get(account) ?? 0) + 1);
5990
+ }
5991
+ return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
5992
+ }, "forgetMail");
5993
+
5994
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/recover.js
5910
5995
  var SQLITE3_MINIMUM = [3, 43, 0];
5911
5996
  var STORE_PARTS = ["", "-wal", "-shm"];
5912
5997
  var RECOVER_LOCK = ".recover-lock";
@@ -6001,9 +6086,12 @@ var storeHolders = /* @__PURE__ */ __name((path) => {
6001
6086
  return { pid, name };
6002
6087
  });
6003
6088
  }, "storeHolders");
6004
- var tableRows = /* @__PURE__ */ __name((database) => {
6089
+ var dataTables = /* @__PURE__ */ __name((database) => {
6005
6090
  const indexes = fts5Tables(database).map((index) => index.name);
6006
- const tables = database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND rootpage > 0 AND name NOT LIKE 'sqlite_%' AND name NOT LIKE 'vector_index_%' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !indexes.some((index) => name.startsWith(`${index}_`)));
6091
+ return database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND rootpage > 0 AND name NOT LIKE 'sqlite_%' AND name NOT LIKE 'vector_index_%' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !indexes.some((index) => name.startsWith(`${index}_`)));
6092
+ }, "dataTables");
6093
+ var tableRows = /* @__PURE__ */ __name((database) => {
6094
+ const tables = dataTables(database);
6007
6095
  return Object.fromEntries(tables.map((table) => {
6008
6096
  try {
6009
6097
  return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
@@ -6012,6 +6100,117 @@ var tableRows = /* @__PURE__ */ __name((database) => {
6012
6100
  }
6013
6101
  }));
6014
6102
  }, "tableRows");
6103
+ var sourceTables = /* @__PURE__ */ __name((database) => {
6104
+ const withoutRowid = new Set(database.prepare("SELECT name FROM pragma_table_list WHERE wr = 1").all().map((row) => String(row.name)));
6105
+ return dataTables(database).filter((table) => table !== LOST_AND_FOUND && !withoutRowid.has(table) && !isDerivedTable(table));
6106
+ }, "sourceTables");
6107
+ var indexedButGone = /* @__PURE__ */ __name((database) => {
6108
+ const found = {};
6109
+ for (const table of sourceTables(database)) {
6110
+ const indexes = database.prepare("SELECT name FROM pragma_index_list(?) WHERE partial = 0 ORDER BY name").all(table).map((row) => String(row.name));
6111
+ for (const index of indexes) {
6112
+ const columns = database.prepare("SELECT cid, name FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno").all(index);
6113
+ if (columns.some((column) => Number(column.cid) < 0))
6114
+ continue;
6115
+ const keys = columns.map((column) => `"${String(column.name)}"`).join(", ");
6116
+ const grouped = `${keys}, row_id`;
6117
+ let rows;
6118
+ try {
6119
+ rows = Number(database.prepare(`SELECT count(*) AS n FROM (SELECT 1 FROM (SELECT ${keys}, rowid AS row_id, 1 AS side FROM "${table}" INDEXED BY "${index}" UNION ALL SELECT ${keys}, rowid, 2 FROM "${table}" NOT INDEXED) GROUP BY ${grouped} HAVING max(side) = 1)`).get()?.n);
6120
+ } catch {
6121
+ continue;
6122
+ }
6123
+ if (rows > (found[table]?.rows ?? 0))
6124
+ found[table] = { rows, index };
6125
+ }
6126
+ }
6127
+ return found;
6128
+ }, "indexedButGone");
6129
+ var storedAs = /* @__PURE__ */ __name((declared) => {
6130
+ const type = declared.toUpperCase();
6131
+ if (type.includes("INT"))
6132
+ return ["integer"];
6133
+ if (/CHAR|CLOB|TEXT/.test(type))
6134
+ return ["text"];
6135
+ if (type === "" || type.includes("BLOB"))
6136
+ return null;
6137
+ if (/REAL|FLOA|DOUB/.test(type))
6138
+ return ["real", "integer"];
6139
+ return null;
6140
+ }, "storedAs");
6141
+ var columnsOf = /* @__PURE__ */ __name((database, table) => {
6142
+ const all = database.prepare('SELECT name, type, "notnull" AS required, dflt_value, pk FROM pragma_table_info(?)').all(table);
6143
+ const keys = all.filter((column) => Number(column.pk) > 0);
6144
+ return all.map((column) => ({
6145
+ name: String(column.name),
6146
+ type: String(column.type),
6147
+ required: Number(column.required) === 1,
6148
+ hasDefault: column.dflt_value !== null,
6149
+ rowid: keys.length === 1 && Number(column.pk) === 1 && String(column.type).toUpperCase() === "INTEGER"
6150
+ }));
6151
+ }, "columnsOf");
6152
+ var fits = /* @__PURE__ */ __name((columns, fields, types) => fields <= columns.length && columns.every((column, at) => {
6153
+ if (at >= fields)
6154
+ return !column.required || column.hasDefault;
6155
+ const type = types[at];
6156
+ if (column.rowid)
6157
+ return type === "null" || type === "integer";
6158
+ if (type === "null")
6159
+ return !column.required;
6160
+ const allowed = storedAs(column.type);
6161
+ return allowed === null || allowed.includes(type);
6162
+ }), "fits");
6163
+ var placeLostRows = /* @__PURE__ */ __name((database) => {
6164
+ if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND))
6165
+ return {};
6166
+ const fields = database.prepare("SELECT name FROM pragma_table_info(?) WHERE name GLOB 'c[0-9]*'").all(LOST_AND_FOUND).map((row) => String(row.name));
6167
+ const tables = sourceTables(database).map((table) => ({ table, columns: columnsOf(database, table) }));
6168
+ const rows = database.prepare(`SELECT rowid AS at, nfield, ${fields.map((field) => `typeof(${field}) AS "${field}"`).join(", ")} FROM ${LOST_AND_FOUND} WHERE id IS NOT NULL`).all();
6169
+ const placed = {};
6170
+ const triggers = [];
6171
+ const quiet = /* @__PURE__ */ __name((table) => {
6172
+ if (table in placed)
6173
+ return;
6174
+ placed[table] = 0;
6175
+ for (const row of database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?").all(table)) {
6176
+ triggers.push(String(row.sql));
6177
+ database.exec(`DROP TRIGGER "${String(row.name)}"`);
6178
+ }
6179
+ }, "quiet");
6180
+ database.exec("PRAGMA foreign_keys = OFF");
6181
+ database.exec("BEGIN");
6182
+ try {
6183
+ for (const row of rows) {
6184
+ const count3 = Number(row.nfield);
6185
+ const types = fields.slice(0, count3).map((field) => String(row[field]));
6186
+ const fitting = tables.filter(({ columns: columns2 }) => fits(columns2, count3, types));
6187
+ if (fitting.length !== 1)
6188
+ continue;
6189
+ const { table, columns } = fitting[0];
6190
+ quiet(table);
6191
+ const given = columns.slice(0, count3);
6192
+ const names = [...given.some((column) => column.rowid) ? [] : ["rowid"], ...given.map((column) => column.name)];
6193
+ const values = [
6194
+ ...given.some((column) => column.rowid) ? [] : ["id"],
6195
+ ...given.map((column, at) => column.rowid ? "id" : `c${at}`)
6196
+ ];
6197
+ const inserted = database.prepare(`INSERT OR IGNORE INTO "${table}" (${names.map((name) => `"${name}"`).join(", ")}) SELECT ${values.join(", ")} FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
6198
+ if (Number(inserted.changes) === 0)
6199
+ continue;
6200
+ placed[table] = (placed[table] ?? 0) + 1;
6201
+ database.prepare(`DELETE FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
6202
+ }
6203
+ for (const sql of triggers)
6204
+ database.exec(sql);
6205
+ database.exec("COMMIT");
6206
+ } catch (error) {
6207
+ database.exec("ROLLBACK");
6208
+ throw error;
6209
+ } finally {
6210
+ database.exec("PRAGMA foreign_keys = ON");
6211
+ }
6212
+ return Object.fromEntries(Object.entries(placed).filter(([, rows2]) => rows2 > 0));
6213
+ }, "placeLostRows");
6015
6214
  var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
6016
6215
  const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
6017
6216
  stdio: ["ignore", "pipe", "pipe"]
@@ -6208,6 +6407,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6208
6407
  throw error;
6209
6408
  throw new CliError("configuration_error", "the store file's header or schema is damaged, so its tables cannot be listed and it cannot be recovered; the file was left as it was", { reason: "store.unreadable" });
6210
6409
  }
6410
+ note("looking for rows the indexes list and the tables no longer hold");
6411
+ const gone = indexedButGone(watch);
6412
+ const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
6211
6413
  const before = { data: dataVersion(), inode: statSync2(path).ino };
6212
6414
  const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
6213
6415
  const target = `${path}.recovering-${stamp}`;
@@ -6236,7 +6438,10 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6236
6438
  let json;
6237
6439
  let fetch;
6238
6440
  let schema;
6441
+ let placed;
6442
+ let refetch;
6239
6443
  try {
6444
+ placed = placeLostRows(opened.database);
6240
6445
  kept = tableRows(opened.database);
6241
6446
  migrate(opened.database, { command, ...version ? { version } : {} });
6242
6447
  note("clearing values that are not valid JSON");
@@ -6245,6 +6450,8 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6245
6450
  note("looking for rows that point at rows that were lost");
6246
6451
  dangling = danglingRows(opened.database);
6247
6452
  fetch = mailToFetch(opened.database);
6453
+ const good = lastKnownGood === null ? Number.NaN : Date.parse(lastKnownGood);
6454
+ refetch = forgetCoverageSince(opened.database, Number.isNaN(good) ? null : good - REFILL_MARGIN_MS, now());
6248
6455
  schema = fileSchemaOf(opened.database).version;
6249
6456
  opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
6250
6457
  } catch (error) {
@@ -6274,16 +6481,29 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6274
6481
  if (existsSync2(`${target}${suffix}`))
6275
6482
  renameSync2(`${target}${suffix}`, `${path}${suffix}`);
6276
6483
  recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
6277
- const lost = Object.entries(rowsBefore).map(([table, before2]) => ({ table, before: before2, read: read[table] ?? 0, kept: kept[table] ?? 0 })).filter(({ before: before2, read: read2, kept: kept2 }) => before2 === null || before2 > kept2 || read2 > kept2);
6484
+ const lost = Object.entries(rowsBefore).map(([table, before2]) => {
6485
+ const goneAtLeast = Math.max(0, (gone[table]?.rows ?? 0) - (placed[table] ?? 0));
6486
+ return {
6487
+ table,
6488
+ before: before2,
6489
+ read: read[table] ?? 0,
6490
+ kept: kept[table] ?? 0,
6491
+ goneAtLeast,
6492
+ seenIn: goneAtLeast > 0 ? gone[table]?.index ?? null : null
6493
+ };
6494
+ }).filter(({ before: before2, read: read2, kept: kept2, goneAtLeast }) => before2 === null || before2 > kept2 || read2 > kept2 || goneAtLeast > 0);
6278
6495
  const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
6279
6496
  return {
6280
6497
  path,
6281
6498
  keptAt,
6282
6499
  sqlite3: program.version,
6283
6500
  lost,
6501
+ placed,
6502
+ lastKnownGood,
6284
6503
  dangling,
6285
6504
  invalidJson: json,
6286
6505
  mailToFetch: fetch,
6506
+ refetch,
6287
6507
  rebuilt,
6288
6508
  copyErrors,
6289
6509
  health,
@@ -6299,7 +6519,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6299
6519
  }
6300
6520
  }, "recoverLocked");
6301
6521
 
6302
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
6522
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
6303
6523
  var COUNTED = [
6304
6524
  "accounts",
6305
6525
  "chats",
@@ -6332,18 +6552,23 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
6332
6552
  }
6333
6553
  } catch {
6334
6554
  }
6555
+ const journal = readJournalMark(path);
6335
6556
  recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema });
6336
6557
  const mark = readDamageMark(path);
6337
- const explanation = explainDamage(health, command, mark);
6558
+ const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
6338
6559
  const inUse = storeHolders(path) ?? null;
6339
6560
  const timers = activeTimers() ?? null;
6340
6561
  const sqlite3 = sqlite3Program();
6341
- const next = health.ok ? [] : [
6342
- ...timers?.length ? [stopTimers(timers)] : [],
6343
- ...(inUse ?? []).map(({ pid, name }) => `stop ${name} (process ${pid}): it has the store open`),
6344
- ...sqlite3.usable ? [] : ["install sqlite3 3.43 or newer (apt install sqlite3, brew install sqlite)"],
6345
- `${command} store recover run`
6346
- ];
6562
+ const report = storeDamageReport({
6563
+ health,
6564
+ command,
6565
+ mark,
6566
+ journal,
6567
+ lastOkAt: lastKnownGood,
6568
+ holders: inUse,
6569
+ timers,
6570
+ sqlite3Usable: sqlite3.usable
6571
+ });
6347
6572
  return {
6348
6573
  path,
6349
6574
  exists: true,
@@ -6354,13 +6579,13 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
6354
6579
  damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
6355
6580
  invalidJson: health.invalidJson ?? [],
6356
6581
  rows,
6357
- explanation,
6582
+ report,
6358
6583
  damageMark: mark ? (({ inode: _, ...seen }) => seen)(mark) : null,
6359
- lastKnownGood: readHealthMark(path)?.last_ok_at ?? null,
6584
+ lastKnownGood,
6360
6585
  inUse,
6361
6586
  timers,
6362
6587
  sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
6363
- next
6588
+ next: report?.steps.map((step) => step.command) ?? []
6364
6589
  };
6365
6590
  }, "storeRecoveryCheck");
6366
6591
  var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
@@ -6386,12 +6611,27 @@ var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, no
6386
6611
  next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
6387
6612
  };
6388
6613
  }, "storeRecoveryRun");
6614
+ var refetchNotes = /* @__PURE__ */ __name(({ since, chats, mail }) => {
6615
+ const from = since === null ? "from the start" : `from ${since} on`;
6616
+ const marked = [
6617
+ ...chats.map(({ provider, account, chats: chats2 }) => `${chats2} chats of ${provider} ${account}`),
6618
+ ...mail.map(({ account, folders }) => `${folders} mail folders of ${account}`)
6619
+ ];
6620
+ return [
6621
+ marked.length > 0 ? `marked as not fetched ${from}, so the next sync or serve fetches it again: ${marked.join(", ")}` : `nothing held ${from} was marked as fetched, so there is nothing to fetch again`,
6622
+ ...chats.filter(({ provider }) => provider === "whatsapp").map(({ account }) => `whatsapp ${account}: WhatsApp cannot be asked for its chats, so only what the phone pushes while serve runs comes back`),
6623
+ "notes, memories, tags and whatever else only this store held cannot be fetched again"
6624
+ ];
6625
+ }, "refetchNotes");
6389
6626
  var recoveryNotes = /* @__PURE__ */ __name((answer) => {
6390
6627
  if ("keptAt" in answer) {
6391
- const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
6628
+ const lost = answer.lost.map(({ table, before, read, kept, goneAtLeast, seenIn }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}` + (goneAtLeast > 0 ? `; at least ${goneAtLeast} rows are gone (the index ${seenIn} lists them)` : ""));
6392
6629
  return [
6393
6630
  `recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
6394
- ...lost.length ? lost : ["no table lost a row"],
6631
+ ...lost,
6632
+ ...Object.entries(answer.placed).map(([table, rows]) => `${table}: ${rows} rows found on pages no table claimed were put back`),
6633
+ ...refetchNotes(answer.refetch),
6634
+ lossUnknown(answer.lastKnownGood, lost.some((line) => line.includes("are gone"))),
6395
6635
  ...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
6396
6636
  ...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
6397
6637
  ...answer.next.map((line) => `next: ${line}`)
@@ -6399,13 +6639,16 @@ var recoveryNotes = /* @__PURE__ */ __name((answer) => {
6399
6639
  }
6400
6640
  if (!answer.exists)
6401
6641
  return ["no store yet"];
6402
- if (answer.ok)
6642
+ const report = answer.report;
6643
+ if (!report)
6403
6644
  return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
6404
- const why = answer.explanation;
6405
6645
  return [
6406
- ...why ? [why.what, ...why.impact, why.externalUnaffected] : [],
6407
- answer.lastKnownGood ? `the store last passed a deep check at ${answer.lastKnownGood}` : "no deep check that passed is on record for this store",
6408
- ...answer.next.map((line) => `next: ${line}`)
6646
+ report.whatHappened,
6647
+ ...report.impact,
6648
+ report.externalDataSafe,
6649
+ report.loss,
6650
+ ...report.likelyCauses.map(({ cause, check: check2 }) => `maybe: ${cause} \u2014 check: ${check2}`),
6651
+ ...report.steps.map(({ command, why, destructive }) => `next: ${command} # ${destructive ? "changes things: " : ""}${why}`)
6409
6652
  ];
6410
6653
  }, "recoveryNotes");
6411
6654
  var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
@@ -6432,7 +6675,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
6432
6675
  return recover;
6433
6676
  }, "storeRecoverCommand");
6434
6677
 
6435
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/store-info.js
6678
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
6436
6679
  var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
6437
6680
  var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
6438
6681
  var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
@@ -6482,7 +6725,7 @@ var sharedStoreCommand = /* @__PURE__ */ __name((app) => {
6482
6725
  return app ? store.addCommand(storeRecoverCommand(app)) : store;
6483
6726
  }, "sharedStoreCommand");
6484
6727
 
6485
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
6728
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
6486
6729
  var ENCRYPT_OPTION = [
6487
6730
  "--encrypt",
6488
6731
  "compress and encrypt with a password, typed at a hidden prompt or piped on stdin; it is never kept \u2014 lose it and the file cannot be opened"
@@ -6501,7 +6744,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
6501
6744
  return password;
6502
6745
  }, "passwordOf");
6503
6746
 
6504
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/rules.js
6747
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/rules.js
6505
6748
  import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
6506
6749
  import { join as join2 } from "node:path";
6507
6750
  var REPLY_ACTIONS = ["reply", "task"];
@@ -6672,7 +6915,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
6672
6915
  }, "problem");
6673
6916
  var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
6674
6917
 
6675
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/state.js
6918
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/state.js
6676
6919
  import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
6677
6920
  import { join as join3 } from "node:path";
6678
6921
  var ANSWERED_KEPT = 1e3;
@@ -6725,7 +6968,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
6725
6968
  }, "recordReply");
6726
6969
  var broken2 = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply state ${path} cannot be read (${why}) \u2014 fix or move the file`), "broken");
6727
6970
 
6728
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/decide.js
6971
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/decide.js
6729
6972
  var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
6730
6973
  var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
6731
6974
  const { message, chat, owner, sender } = incoming;
@@ -6831,10 +7074,10 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
6831
7074
  return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
6832
7075
  }, "filled");
6833
7076
 
6834
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/template.js
7077
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/template.js
6835
7078
  var import_liquidjs2 = __toESM(require_liquid_node(), 1);
6836
7079
 
6837
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/render/liquid.js
7080
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/render/liquid.js
6838
7081
  var import_liquidjs = __toESM(require_liquid_node(), 1);
6839
7082
  var safeLiquid = /* @__PURE__ */ __name((limits) => {
6840
7083
  const engine = new import_liquidjs.Liquid({
@@ -6861,7 +7104,7 @@ var safeLiquid = /* @__PURE__ */ __name((limits) => {
6861
7104
  return engine;
6862
7105
  }, "safeLiquid");
6863
7106
 
6864
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/template.js
7107
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/template.js
6865
7108
  var TEMPLATE_LIMITS = {
6866
7109
  parse: 32768,
6867
7110
  renders: 2e3,
@@ -7000,7 +7243,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
7000
7243
  }
7001
7244
  }, "renderReplyTemplate");
7002
7245
 
7003
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
7246
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
7004
7247
  var DRY_RUN_DAYS = 7;
7005
7248
  var PAGE = 500;
7006
7249
  var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
@@ -7114,7 +7357,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
7114
7357
  }
7115
7358
  }, "storedSince");
7116
7359
 
7117
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/consents.js
7360
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/consents.js
7118
7361
  import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
7119
7362
  import { join as join4 } from "node:path";
7120
7363
  var shape = strictObject({
@@ -7139,7 +7382,7 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
7139
7382
  return consent.provider === provider && !consent.deniedChats.includes(chat);
7140
7383
  }, "mayModelReply");
7141
7384
 
7142
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/rendering.js
7385
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/rendering.js
7143
7386
  var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
7144
7387
  ai: true
7145
7388
  }) => async (rule2, message, chat, now) => {
@@ -7186,7 +7429,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
7186
7429
  return result2;
7187
7430
  }, "replyRenderer");
7188
7431
 
7189
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/replies/serve.js
7432
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/serve.js
7190
7433
  var NOT_ALLOWED = "replies.send is not allow";
7191
7434
  var NO_RULES = "no rules";
7192
7435
  var ONLY_TASK = "opened a task, sent nothing";
@@ -7279,7 +7522,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
7279
7522
  return { skip: why };
7280
7523
  }, "replyTo");
7281
7524
 
7282
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
7525
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
7283
7526
  var START_SYNC_DELAY_MS = 3e4;
7284
7527
  var START_SYNC_BUDGET_MS = 5 * 6e4;
7285
7528
  var START_SYNC_WINDOW_MS = 7 * 864e5;
@@ -7356,7 +7599,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn,
7356
7599
  };
7357
7600
  }, "startSync");
7358
7601
 
7359
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
7602
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
7360
7603
  var FIRST_FETCH_MS = 6e4;
7361
7604
  var DAY_MS = 864e5;
7362
7605
  var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
@@ -7410,7 +7653,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs =
7410
7653
  };
7411
7654
  }, "memberFetches");
7412
7655
 
7413
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
7656
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
7414
7657
  var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
7415
7658
  var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
7416
7659
  if (context.format === "pretty") {
@@ -7443,7 +7686,93 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
7443
7686
  return context;
7444
7687
  }, "recordDiagnostics");
7445
7688
 
7446
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7689
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
7690
+ import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
7691
+ import { dirname as dirname2, join as join5 } from "node:path";
7692
+ var OUTDATED_CHECK_MS = 6e4;
7693
+ var ownPackageRoot = /* @__PURE__ */ __name((running, script = process.argv[1]) => {
7694
+ let dir;
7695
+ try {
7696
+ dir = dirname2(realpathSync2(script ?? ""));
7697
+ } catch {
7698
+ return void 0;
7699
+ }
7700
+ for (let up = 0; up < 8; up++) {
7701
+ const manifest = join5(dir, "package.json");
7702
+ if (existsSync8(manifest))
7703
+ return installedVersion(dir) === running ? dir : void 0;
7704
+ const parent = dirname2(dir);
7705
+ if (parent === dir)
7706
+ return void 0;
7707
+ dir = parent;
7708
+ }
7709
+ return void 0;
7710
+ }, "ownPackageRoot");
7711
+ var installedVersion = /* @__PURE__ */ __name((root) => {
7712
+ try {
7713
+ const { version } = JSON.parse(readFileSync5(join5(root, "package.json"), "utf8"));
7714
+ return typeof version === "string" ? version : void 0;
7715
+ } catch {
7716
+ return void 0;
7717
+ }
7718
+ }, "installedVersion");
7719
+ var newer = /* @__PURE__ */ __name((one, other) => {
7720
+ const parts = /* @__PURE__ */ __name((version) => version.split(/[.+-]/, 3).map(Number), "parts");
7721
+ const [a, b] = [parts(one), parts(other)];
7722
+ for (let i = 0; i < 3; i++)
7723
+ if ((a[i] ?? 0) !== (b[i] ?? 0))
7724
+ return (a[i] ?? 0) > (b[i] ?? 0);
7725
+ return false;
7726
+ }, "newer");
7727
+ var outdatedReason = /* @__PURE__ */ __name(async ({ command, running, storePath: storePath2, packageRoot, speaks = SPEAKS }) => {
7728
+ const installed = packageRoot === void 0 ? void 0 : installedVersion(packageRoot);
7729
+ if (installed !== void 0 && newer(installed, running))
7730
+ return `${command} ${installed} is installed and this serve runs ${running}: stopping so it starts again on ${installed}`;
7731
+ if (!existsSync8(storePath2))
7732
+ return void 0;
7733
+ let schema;
7734
+ try {
7735
+ const { database } = await openSqlite(storePath2, { readOnly: true });
7736
+ try {
7737
+ schema = fileSchemaOf(database);
7738
+ } finally {
7739
+ database.close();
7740
+ }
7741
+ } catch {
7742
+ return void 0;
7743
+ }
7744
+ if (writableBy(schema, speaks))
7745
+ return void 0;
7746
+ return `the store is at format ${schema.version} and needs at least ${schema.minCompatible}; this serve (${command} ${running}) speaks ${speaks} and can no longer write it: stopping \u2014 \`${command} upgrade\` if it does not start again on a newer version`;
7747
+ }, "outdatedReason");
7748
+ var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs = OUTDATED_CHECK_MS }) => {
7749
+ let busy = false;
7750
+ let done = false;
7751
+ const timer = setInterval(() => {
7752
+ if (busy || done)
7753
+ return;
7754
+ busy = true;
7755
+ check2().then((reason) => {
7756
+ if (reason === void 0 || done)
7757
+ return;
7758
+ done = true;
7759
+ clearInterval(timer);
7760
+ onOutdated(reason);
7761
+ }).catch(() => {
7762
+ }).finally(() => {
7763
+ busy = false;
7764
+ });
7765
+ }, everyMs);
7766
+ timer.unref();
7767
+ return {
7768
+ stop: /* @__PURE__ */ __name(() => {
7769
+ done = true;
7770
+ clearInterval(timer);
7771
+ }, "stop")
7772
+ };
7773
+ }, "watchOutdated");
7774
+
7775
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7447
7776
  var STEMS_EVERY_MS = 3e4;
7448
7777
  var STEMS_SLICE_MS = 2e3;
7449
7778
  var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
@@ -7483,7 +7812,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
7483
7812
  };
7484
7813
  }, "stemFills");
7485
7814
 
7486
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7815
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7487
7816
  var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
7488
7817
  var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
7489
7818
  kind: attachment.kind,
@@ -7502,7 +7831,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
7502
7831
  phone: attachment.contact.phone,
7503
7832
  user_id: attachment.contact.userId
7504
7833
  }),
7505
- buttons: attachment.buttons
7834
+ buttons: attachment.buttons?.map((row) => row.map(({ data: _data, ...button }) => button))
7506
7835
  }), "attachmentItem");
7507
7836
  var quotedItem = /* @__PURE__ */ __name((quoted) => quoted === null ? null : {
7508
7837
  id: quoted.id,
@@ -7578,7 +7907,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
7578
7907
  locale: messenger.app.locale
7579
7908
  }), "viewOf");
7580
7909
 
7581
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7910
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7582
7911
  var observed = /* @__PURE__ */ __name((value) => ({
7583
7912
  value: value.value,
7584
7913
  observed_at: value.observedAt,
@@ -7645,7 +7974,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
7645
7974
  }
7646
7975
  }, "watchEventItem");
7647
7976
 
7648
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7977
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7649
7978
  var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
7650
7979
  output: { entity: "watch_item" },
7651
7980
  effects: REMOTE_READ,
@@ -7800,7 +8129,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
7800
8129
  }
7801
8130
  }, "describe");
7802
8131
 
7803
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
8132
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
7804
8133
  var serveCommand = /* @__PURE__ */ __name((messenger) => {
7805
8134
  const command = annotate(new Command("serve"), {
7806
8135
  output: { entity: "serve_summary" },
@@ -7824,8 +8153,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7824
8153
  }
7825
8154
  let relaying;
7826
8155
  const onReady = /* @__PURE__ */ __name(() => {
7827
- const listening = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
7828
- holdLock(path, listening);
8156
+ const listening2 = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
8157
+ holdLock(path, listening2);
7829
8158
  note({
7830
8159
  code: "listening",
7831
8160
  text: `listening for profile ${context.profile}, catching up on what arrived while it was down`
@@ -7834,7 +8163,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7834
8163
  return;
7835
8164
  relaying = relay.open(path, context.profile).then((address) => {
7836
8165
  if (address)
7837
- holdLock(path, { ...listening, relay: address });
8166
+ holdLock(path, { ...listening2, relay: address });
7838
8167
  }).catch((error) => {
7839
8168
  const errorCode = failureKey(error);
7840
8169
  warn({ code: "relay_failed", errorCode, text: `commands cannot run through this serve: ${errorCode}` });
@@ -7843,7 +8172,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7843
8172
  const counts = {};
7844
8173
  const rules = replying(context, messenger, Date.parse(startedAt));
7845
8174
  const tasks = tasking(context, warn);
7846
- const { handled, startSyncDelayMs } = environmentOf(this);
8175
+ const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
7847
8176
  const count3 = /* @__PURE__ */ __name((event) => {
7848
8177
  counts[event.event] = (counts[event.event] ?? 0) + 1;
7849
8178
  if (event.event === "message") {
@@ -7915,9 +8244,25 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7915
8244
  withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
7916
8245
  warn
7917
8246
  });
8247
+ const listening = new AbortController();
8248
+ let outdated;
8249
+ const packageRoot = outdatedHook?.packageRoot ?? ownPackageRoot(version);
8250
+ const watch = watchOutdated({
8251
+ check: /* @__PURE__ */ __name(() => outdatedReason({
8252
+ command: messenger.app.command,
8253
+ running: version,
8254
+ storePath: storePath(context.env),
8255
+ packageRoot
8256
+ }), "check"),
8257
+ onOutdated: /* @__PURE__ */ __name((reason) => {
8258
+ outdated = reason;
8259
+ listening.abort();
8260
+ }, "onOutdated"),
8261
+ ...outdatedHook?.everyMs === void 0 ? {} : { everyMs: outdatedHook.everyMs }
8262
+ });
7918
8263
  try {
7919
8264
  await listenUntilStopped(this, context, relay?.messenger ?? messenger, count3, {
7920
- stop: new AbortController(),
8265
+ stop: listening,
7921
8266
  catchUp: true,
7922
8267
  onReady,
7923
8268
  connected: /* @__PURE__ */ __name((open) => {
@@ -7930,6 +8275,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7930
8275
  }, "connected")
7931
8276
  });
7932
8277
  } finally {
8278
+ watch.stop();
7933
8279
  await relaying;
7934
8280
  await relay?.close();
7935
8281
  rules.stop();
@@ -7940,6 +8286,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7940
8286
  await tasks.settled();
7941
8287
  releaseLock(path);
7942
8288
  }
8289
+ if (outdated !== void 0)
8290
+ throw new CliError("configuration_error", outdated, { reason: "serve.outdated" });
7943
8291
  renderAnswer(this, context, itemOf({
7944
8292
  profile: context.profile,
7945
8293
  started_at: startedAt,
@@ -8064,8 +8412,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
8064
8412
  };
8065
8413
  }, "tasking");
8066
8414
 
8067
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
8068
- import { existsSync as existsSync8 } from "node:fs";
8415
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
8416
+ import { existsSync as existsSync9 } from "node:fs";
8069
8417
  var PATH = "store tables list";
8070
8418
  var STORE_TABLES_QUERY = {
8071
8419
  entity: "store_table",
@@ -8094,7 +8442,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
8094
8442
  const filter = filterOf(words);
8095
8443
  const { full } = this.optsWithGlobals();
8096
8444
  const path = storePath(environmentOf(this).env ?? process.env);
8097
- if (!existsSync8(path))
8445
+ if (!existsSync9(path))
8098
8446
  throw new CliError("not_found", `no store at ${path}`);
8099
8447
  const items = await readStoreTables(path, { filter, sizes: full === true });
8100
8448
  renderAnswer(this, outputFor(this), listOf(PATH, {
@@ -8107,7 +8455,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
8107
8455
  return tables;
8108
8456
  }, "storeTablesCommand");
8109
8457
 
8110
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3bb6323e04e526bd9df39f840434b06b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
8458
+ // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
8111
8459
  var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
8112
8460
  var WORD_INDEX = "message_words";
8113
8461
  var schemaOf = /* @__PURE__ */ __name((database) => {
@@ -8116,7 +8464,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
8116
8464
  }, "schemaOf");
8117
8465
  var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
8118
8466
  var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
8119
- var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync9(path) ? statSync4(path).size : 0, "bytesOf");
8467
+ var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync10(path) ? statSync4(path).size : 0, "bytesOf");
8120
8468
  var reading = /* @__PURE__ */ __name(async (path, read) => {
8121
8469
  const database = await openCache(path);
8122
8470
  try {
@@ -8143,9 +8491,10 @@ var fileSchema = /* @__PURE__ */ __name(async (path) => {
8143
8491
  }, "fileSchema");
8144
8492
  var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
8145
8493
  const path = storePath(env);
8146
- if (!existsSync9(path))
8494
+ if (!existsSync10(path))
8147
8495
  return { path, exists: false };
8148
8496
  const checked = await storeHealth(path, { deep });
8497
+ const journal = readJournalMark(path);
8149
8498
  const recorded = deep ? recordDeepCheck(path, checked, {
8150
8499
  cli: command ?? "unknown",
8151
8500
  ...version ? { version } : {},
@@ -8163,13 +8512,15 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
8163
8512
  ...checked.invalidJson?.length ? { invalidJson: checked.invalidJson } : {},
8164
8513
  ...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
8165
8514
  };
8166
- const damage = command ? explainDamage(checked, command, mark) : null;
8515
+ const damage = command ? storeDamageReport({ health: checked, command, mark, journal, lastOkAt: lastKnownGood }) : null;
8167
8516
  const healthOf = {
8168
8517
  health,
8169
8518
  lastKnownGood,
8170
8519
  ...mark ? { damageMark: withoutInode(mark) } : {},
8520
+ ...journal ? { journalMark: journal } : {},
8171
8521
  ...recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {},
8172
- ...damage ? { damage } : {}
8522
+ // `what` keeps memo's doctor, which reads it, compiling until it moves to `whatHappened`.
8523
+ ...damage ? { damage: { what: damage.whatHappened, ...damage } } : {}
8173
8524
  };
8174
8525
  try {
8175
8526
  return await reading(path, (database) => {
@@ -8213,7 +8564,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
8213
8564
  const { renderer, format } = outputFor(this);
8214
8565
  const { dryRun: dryRun2 } = this.opts();
8215
8566
  const path = storePath(environmentOf(this).env ?? process.env);
8216
- if (!existsSync9(path)) {
8567
+ if (!existsSync10(path)) {
8217
8568
  result(this, { path, exists: false });
8218
8569
  return;
8219
8570
  }
@@ -8253,7 +8604,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
8253
8604
  }, "notesOf");
8254
8605
  var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").description("the tables `store repair` kept as copies").addCommand(annotate(new Command("delete"), { output: { entity: "store_copy_removal" }, effects: LOCAL_WRITE }).description("delete one copy `store repair` kept, named exactly; refuses any other table").argument("<name>", "the copy's name, as `store repair` printed it").action(async function(name) {
8255
8606
  const path = storePath(environmentOf(this).env ?? process.env);
8256
- if (!existsSync9(path))
8607
+ if (!existsSync10(path))
8257
8608
  throw new CliError("not_found", `no store at ${path}`);
8258
8609
  const deleted = await reading(path, (database) => deleteCopy(database, name));
8259
8610
  result(this, { path, deleted });
@@ -8261,7 +8612,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
8261
8612
  var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary("check the local archive for problems").description("whether the store is healthy \u2014 integrity, search indexes, disk, and which chats are behind").action(async function() {
8262
8613
  const { renderer } = outputFor(this);
8263
8614
  const path = storePath(environmentOf(this).env ?? process.env);
8264
- if (!existsSync9(path)) {
8615
+ if (!existsSync10(path)) {
8265
8616
  result(this, { path, exists: false, ok: true });
8266
8617
  return;
8267
8618
  }
@@ -8324,7 +8675,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
8324
8675
  ...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
8325
8676
  ]);
8326
8677
  const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
8327
- const { bavail, bsize } = statfsSync2(dirname2(path));
8678
+ const { bavail, bsize } = statfsSync2(dirname3(path));
8328
8679
  const free = Number(bavail) * Number(bsize);
8329
8680
  const behind = schema.version > 0 ? chatsBehind(database) : [];
8330
8681
  const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
@@ -8412,7 +8763,7 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
8412
8763
  var migrateCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary("migrate an older local archive").description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
8413
8764
  const { renderer } = outputFor(this);
8414
8765
  const path = storePath(environmentOf(this).env ?? process.env);
8415
- if (!existsSync9(path)) {
8766
+ if (!existsSync10(path)) {
8416
8767
  result(this, { path, exists: false });
8417
8768
  renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
8418
8769
  return;
@@ -8476,7 +8827,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
8476
8827
  var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary("rebuild the local archive's search indexes").description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
8477
8828
  const { renderer } = outputFor(this);
8478
8829
  const path = storePath(environmentOf(this).env ?? process.env);
8479
- if (!existsSync9(path)) {
8830
+ if (!existsSync10(path)) {
8480
8831
  result(this, { path, exists: false });
8481
8832
  return;
8482
8833
  }
@@ -8518,9 +8869,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
8518
8869
  const { encrypt } = this.opts();
8519
8870
  const path = storePath(environmentOf(this).env ?? process.env);
8520
8871
  const target = resolve(file2);
8521
- if (!existsSync9(path))
8872
+ if (!existsSync10(path))
8522
8873
  throw new CliError("not_found", `no store at ${path} to back up`);
8523
- if (existsSync9(target))
8874
+ if (existsSync10(target))
8524
8875
  throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
8525
8876
  const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
8526
8877
  const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
@@ -8553,11 +8904,11 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
8553
8904
  const { output } = this.opts();
8554
8905
  const from = resolve(file2);
8555
8906
  const to = resolve(output);
8556
- if (!existsSync9(from))
8907
+ if (!existsSync10(from))
8557
8908
  throw new CliError("not_found", `no file at ${from}`);
8558
8909
  if (!isSealed(from))
8559
8910
  throw new CliError("validation_error", `${from} was not written with --encrypt`);
8560
- if (existsSync9(to))
8911
+ if (existsSync10(to))
8561
8912
  throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
8562
8913
  await unsealFile(from, to, await passwordOf(this, { twice: false }));
8563
8914
  result(this, { path: to, from, bytes: bytesOf2(to) });
@@ -8565,13 +8916,13 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
8565
8916
  var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup and keep the current store, or roll back a breaking upgrade").description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools cannot open), put its tables back in the store and return it to that version instead").argument("<file>", "a file `store backup` wrote, or a rollback copy; one written with --encrypt asks for its password").action(async function(file2) {
8566
8917
  const path = storePath(environmentOf(this).env ?? process.env);
8567
8918
  const given = resolve(file2);
8568
- if (!existsSync9(given))
8919
+ if (!existsSync10(given))
8569
8920
  throw new CliError("not_found", `no file at ${given}`);
8570
8921
  refuseWhileServing(this, messenger);
8571
8922
  if (!isSealed(given))
8572
8923
  return restoreFrom(this, messenger, given, given);
8573
8924
  const opened = `${path}.unsealing-${process.pid}`;
8574
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
8925
+ mkdirSync(dirname3(path), { recursive: true, mode: 448 });
8575
8926
  try {
8576
8927
  await unsealFile(given, opened, await passwordOf(this, { twice: false }));
8577
8928
  await restoreFrom(this, messenger, opened, given);
@@ -8582,26 +8933,26 @@ var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command(
8582
8933
  var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
8583
8934
  const { renderer } = outputFor(command);
8584
8935
  const path = storePath(environmentOf(command).env ?? process.env);
8585
- if (existsSync9(path) && realpathSync2(backup) === realpathSync2(path)) {
8936
+ if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
8586
8937
  throw new CliError("validation_error", `${backup} is the store itself`);
8587
8938
  }
8588
8939
  if (await isRollbackCopy(backup))
8589
8940
  return rollBackFrom(command, messenger, backup);
8590
8941
  const schema = await backupSchema(backup);
8591
8942
  const stamp = stampNow();
8592
- const kept = existsSync9(path) ? `${path}.before-restore-${stamp}` : null;
8943
+ const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
8593
8944
  if (kept) {
8594
8945
  const waitMs = environmentOf(command).storeLockWaitMs;
8595
8946
  await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
8596
8947
  } else
8597
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
8948
+ mkdirSync(dirname3(path), { recursive: true, mode: 448 });
8598
8949
  const incoming = `${path}.restoring-${stamp}`;
8599
8950
  copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
8600
8951
  chmodSync(incoming, 384);
8601
8952
  if (kept) {
8602
8953
  renameSync3(path, kept);
8603
8954
  for (const suffix of ["-wal", "-shm"])
8604
- if (existsSync9(`${path}${suffix}`))
8955
+ if (existsSync10(`${path}${suffix}`))
8605
8956
  renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
8606
8957
  }
8607
8958
  renameSync3(incoming, path);
@@ -8623,7 +8974,7 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
8623
8974
  var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
8624
8975
  const { renderer } = outputFor(command);
8625
8976
  const path = storePath(environmentOf(command).env ?? process.env);
8626
- if (!existsSync9(path))
8977
+ if (!existsSync10(path))
8627
8978
  throw new CliError("not_found", `no store at ${path} to roll back`);
8628
8979
  const waitMs = environmentOf(command).storeLockWaitMs;
8629
8980
  await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
@@ -8673,7 +9024,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
8673
9024
  var STORE_LOCK_WAIT_MS = 1e3;
8674
9025
  var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
8675
9026
  const { command } = messenger.app;
8676
- const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync9(file2)).map((file2) => realpathSync2(file2));
9027
+ const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
8677
9028
  const holders = holdersOf(files);
8678
9029
  if (holders === void 0) {
8679
9030
  warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
@@ -8699,7 +9050,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
8699
9050
  const { command } = messenger.app;
8700
9051
  const env = environmentOf(this).env ?? process.env;
8701
9052
  const path = storePath(env);
8702
- if (!existsSync9(path)) {
9053
+ if (!existsSync10(path)) {
8703
9054
  result(this, { path, exists: false, reset: false });
8704
9055
  renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
8705
9056
  return;
@@ -8744,8 +9095,8 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
8744
9095
  }), "resetCommand");
8745
9096
  var STORE_PARTS2 = ["", "-wal", "-shm"];
8746
9097
  var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
8747
- const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync9(file2));
8748
- const holders = holdersOf(files.map((file2) => realpathSync2(file2)));
9098
+ const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
9099
+ const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
8749
9100
  const serving = servingProfiles(messenger.app, env).length > 0;
8750
9101
  const read = await readingOnly(path, (database) => ({
8751
9102
  schema: schemaOf(database).version,
@@ -8815,6 +9166,10 @@ export {
8815
9166
  FIRST_FETCH_MS,
8816
9167
  DAY_MS,
8817
9168
  memberFetches,
9169
+ OUTDATED_CHECK_MS,
9170
+ ownPackageRoot,
9171
+ outdatedReason,
9172
+ watchOutdated,
8818
9173
  STEMS_EVERY_MS,
8819
9174
  STEMS_SLICE_MS,
8820
9175
  stemFills,