@wirecat/mail-cli 0.22.0 → 0.23.1

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 (125) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +2 -1
  3. package/dist/bin/mail.js +2 -2
  4. package/dist/bundle/{all-profiles-DTUWUCQQ.js → all-profiles-FJHJCGRU.js} +9 -9
  5. package/dist/bundle/{anthropic-YJAEQSNT.js → anthropic-AFL7NKVZ.js} +9 -7
  6. package/dist/bundle/{app-server-3ZXSTBA3.js → app-server-WKCBJMHI.js} +46 -46
  7. package/dist/bundle/{bun-34VBM7C5.js → bun-HQATAQJQ.js} +2 -2
  8. package/dist/bundle/{bun-sqlite-GCT7ROCK.js → bun-sqlite-4ECAV7OU.js} +4 -4
  9. package/dist/bundle/{chunk-RFB27ACZ.js → chunk-2HXHAFRP.js} +2 -2
  10. package/dist/bundle/{chunk-MD64ITYO.js → chunk-34743C4C.js} +1 -1
  11. package/dist/bundle/{chunk-Z75WYAX6.js → chunk-3OZKDC6Y.js} +8 -7
  12. package/dist/bundle/{chunk-UWL2IOII.js → chunk-3QVGB2CI.js} +2 -2
  13. package/dist/bundle/{chunk-3HDQVTND.js → chunk-3UFD76IR.js} +5 -5
  14. package/dist/bundle/{chunk-SCIC2CJS.js → chunk-4IFX4HV2.js} +4 -4
  15. package/dist/bundle/{chunk-QE72KTS7.js → chunk-4IWJARFA.js} +1 -1
  16. package/dist/bundle/{chunk-ZZSHGCRC.js → chunk-4YJJQNNJ.js} +4 -4
  17. package/dist/bundle/{chunk-RPCKBXKN.js → chunk-5UKBUI4I.js} +2 -2
  18. package/dist/bundle/{chunk-J4UZXBEV.js → chunk-76RTQYJQ.js} +1 -1
  19. package/dist/bundle/{chunk-I2SDXWLR.js → chunk-7YRKUEYE.js} +118 -54
  20. package/dist/bundle/{chunk-ZKLXSVIO.js → chunk-AGNAT7CM.js} +1 -1
  21. package/dist/bundle/{chunk-HSBGNVEL.js → chunk-B6QMMRIM.js} +361 -188
  22. package/dist/bundle/{chunk-WBAA2X3E.js → chunk-BVJQBAGL.js} +11 -11
  23. package/dist/bundle/{chunk-TCCN5TON.js → chunk-CBWA2T3N.js} +24 -2
  24. package/dist/bundle/{chunk-P6FT6YYT.js → chunk-CCYHBNRL.js} +16 -16
  25. package/dist/bundle/{chunk-B74SOC4R.js → chunk-CUOCDJFI.js} +8 -8
  26. package/dist/bundle/{chunk-RY7PBP4F.js → chunk-CYQVWITQ.js} +16 -16
  27. package/dist/bundle/{chunk-566MEXK5.js → chunk-E7ZVKQHG.js} +3 -3
  28. package/dist/bundle/{chunk-HJ2CXDKJ.js → chunk-EXPR6QAX.js} +26 -12
  29. package/dist/bundle/{chunk-LTXYJAJK.js → chunk-FWFNUJQD.js} +24 -63
  30. package/dist/bundle/{chunk-VINSQR4X.js → chunk-GJNFNC76.js} +7 -7
  31. package/dist/bundle/{chunk-BHNBWFT5.js → chunk-GOMJNH56.js} +44 -0
  32. package/dist/bundle/{chunk-7XLOWYGD.js → chunk-HOKGIYUO.js} +39 -4
  33. package/dist/bundle/{chunk-FTI73RLC.js → chunk-KKGX7JMX.js} +2 -2
  34. package/dist/bundle/{chunk-BMV56JCL.js → chunk-LLYVBO3R.js} +1 -1
  35. package/dist/bundle/{chunk-QTMVGOSF.js → chunk-LQDMUMA2.js} +1336 -796
  36. package/dist/bundle/{chunk-VQZCIDSO.js → chunk-M7RGG3UU.js} +3 -3
  37. package/dist/bundle/{chunk-R3WPMQYZ.js → chunk-MBKNL5TX.js} +632 -435
  38. package/dist/bundle/{chunk-AF62BPIW.js → chunk-MUDHCYN4.js} +5 -5
  39. package/dist/bundle/{chunk-25PD6FZY.js → chunk-NKBAZ4VC.js} +2 -2
  40. package/dist/bundle/{chunk-2PPEDB67.js → chunk-NMGF3UOZ.js} +30 -30
  41. package/dist/bundle/{chunk-KMQAHDBM.js → chunk-NOA6E6MM.js} +2173 -1297
  42. package/dist/bundle/{chunk-J2U6LUT5.js → chunk-OJCUSHZG.js} +3 -3
  43. package/dist/bundle/{chunk-T3DTYJTG.js → chunk-OU5CWCG2.js} +1 -1
  44. package/dist/bundle/{chunk-OKO2Q6H6.js → chunk-PMIKRELC.js} +2 -2
  45. package/dist/bundle/{chunk-RT6SLZBI.js → chunk-QR7JZM3D.js} +1 -1
  46. package/dist/bundle/{chunk-O3M2S62X.js → chunk-QUKD5SO2.js} +3 -3
  47. package/dist/bundle/{chunk-SFC46MP2.js → chunk-QV3M2MHG.js} +10 -10
  48. package/dist/bundle/{chunk-SYEICLTR.js → chunk-R554W7ZO.js} +1 -1
  49. package/dist/bundle/{chunk-NOVBK4SY.js → chunk-R5MYOLQP.js} +12 -12
  50. package/dist/bundle/{chunk-4FWJNIPH.js → chunk-ROKTS7WM.js} +1 -1
  51. package/dist/bundle/{chunk-GAPQENMY.js → chunk-S5OTP7XS.js} +22 -4
  52. package/dist/bundle/{chunk-HRRSTIGP.js → chunk-SBGXKM4U.js} +10 -6
  53. package/dist/bundle/{chunk-ODFHIXMA.js → chunk-SNTLN2QT.js} +1 -1
  54. package/dist/bundle/{chunk-VDUGE6TH.js → chunk-SR3ADLGX.js} +2 -2
  55. package/dist/bundle/{chunk-4WIEVQ2Q.js → chunk-UMXVQIGD.js} +137 -9
  56. package/dist/bundle/{chunk-HN43G27G.js → chunk-V3TDQUXD.js} +45 -27
  57. package/dist/bundle/{chunk-3DSYLE5N.js → chunk-V7CFZ773.js} +2 -2
  58. package/dist/bundle/{chunk-LF5XM4HE.js → chunk-VAMCRP47.js} +1 -1
  59. package/dist/bundle/{chunk-Z7N4MGOQ.js → chunk-VFKX5UMJ.js} +5 -5
  60. package/dist/bundle/{chunk-72N26BQM.js → chunk-VYHIX3OP.js} +88 -88
  61. package/dist/bundle/{chunk-P2QJA7S5.js → chunk-VYIIX6VN.js} +1 -1
  62. package/dist/bundle/{chunk-V6OIIVH3.js → chunk-WN4HP7IZ.js} +11 -11
  63. package/dist/bundle/{chunk-MDDB7M7Z.js → chunk-ZXIPJF3Y.js} +1 -1
  64. package/dist/bundle/command-contract-IIHBNF7J.js +35 -0
  65. package/dist/bundle/{decode-BIOOL5E4.js → decode-QXKTMOTH.js} +4 -4
  66. package/dist/bundle/{dispatch-R5OF2FVZ.js → dispatch-G4CYFWQ2.js} +1 -1
  67. package/dist/bundle/{dist-TJVIRLE5.js → dist-5FX36DAW.js} +44 -22
  68. package/dist/bundle/{echarts-ECPGMKXO.js → echarts-HHUM43TU.js} +2 -2
  69. package/dist/bundle/{embed-F7JFSLHN.js → embed-SRZSDZVI.js} +5 -5
  70. package/dist/bundle/{embedder-U4G74HV3.js → embedder-WZIZCWLX.js} +8 -8
  71. package/dist/bundle/{failure-WYKVF6RH.js → failure-FFPK2WYB.js} +1 -1
  72. package/dist/bundle/{first-run-JTYPUYQP.js → first-run-6DVWZ3JQ.js} +8 -8
  73. package/dist/bundle/first-screen-SRZ7NYHZ.js +33 -0
  74. package/dist/bundle/{instructions-WNCGZ7OJ.js → instructions-UWONE6UT.js} +1 -1
  75. package/dist/bundle/mail.js +5 -5
  76. package/dist/bundle/{node-UIRGGMGT.js → node-HLAOYJDB.js} +2 -2
  77. package/dist/bundle/{node-sqlite-4ZM7OPRF.js → node-sqlite-RO66I7W6.js} +5 -5
  78. package/dist/bundle/{oauth-5RAJZPBW.js → oauth-VNLB2TET.js} +6 -6
  79. package/dist/bundle/{open-7ORCHOAI.js → open-QQSG343L.js} +4 -4
  80. package/dist/bundle/{openai-XSJNXJA7.js → openai-JTFC7OGF.js} +12 -12
  81. package/dist/bundle/{process-ZLO72UVZ.js → process-3CZAXR6P.js} +1 -1
  82. package/dist/bundle/{program-MXGQFQJG.js → program-XTOS4RAM.js} +4528 -2579
  83. package/dist/bundle/{prompt-IDUPCUGM.js → prompt-HGQ6GPYL.js} +6 -4
  84. package/dist/bundle/{recognize-OS3EZKIM.js → recognize-2SHMNEIZ.js} +3 -3
  85. package/dist/bundle/{remote-PF4LZR65.js → remote-GBQC3433.js} +6 -6
  86. package/dist/bundle/{rerank-CQNZF3JI.js → rerank-FQHQXFNR.js} +6 -6
  87. package/dist/bundle/{serve-Y2DDLGBT.js → serve-THU67QUZ.js} +8 -8
  88. package/dist/bundle/{server-TVRT7YEY.js → server-LOT3CLYX.js} +36 -36
  89. package/dist/bundle/server-VKMUX7ZT.js +65 -0
  90. package/dist/bundle/{sqlite-runtime-5343C3OE.js → sqlite-runtime-NOOUMBC4.js} +5 -5
  91. package/dist/bundle/{state-4GBTMPIV.js → state-KSKZCV2U.js} +5 -5
  92. package/dist/bundle/{store-QA6QJ5BB.js → store-BAKSHTKF.js} +37 -14
  93. package/dist/bundle/{store-OLBLTQPT.js → store-OHNZOQ7U.js} +30 -18
  94. package/dist/bundle/store-maintenance-command-ROQHJVEA.js +54 -0
  95. package/dist/commands/account-remove.d.ts +3 -0
  96. package/dist/commands/account-remove.d.ts.map +1 -0
  97. package/dist/commands/account-remove.js +65 -0
  98. package/dist/commands/account-remove.js.map +1 -0
  99. package/dist/commands/account.d.ts.map +1 -1
  100. package/dist/commands/account.js +3 -1
  101. package/dist/commands/account.js.map +1 -1
  102. package/dist/commands/context.d.ts +3 -1
  103. package/dist/commands/context.d.ts.map +1 -1
  104. package/dist/commands/context.js.map +1 -1
  105. package/dist/commands/rules.d.ts.map +1 -1
  106. package/dist/commands/rules.js +29 -7
  107. package/dist/commands/rules.js.map +1 -1
  108. package/dist/commands/sync.d.ts +0 -1
  109. package/dist/commands/sync.d.ts.map +1 -1
  110. package/dist/commands/sync.js +8 -2
  111. package/dist/commands/sync.js.map +1 -1
  112. package/dist/mail/changes.d.ts +1 -0
  113. package/dist/mail/changes.d.ts.map +1 -1
  114. package/dist/mail/changes.js +1 -1
  115. package/dist/mail/changes.js.map +1 -1
  116. package/dist/providers.js +2 -2
  117. package/dist/providers.js.map +1 -1
  118. package/dist/version.d.ts +1 -1
  119. package/dist/version.js +1 -1
  120. package/package.json +3 -3
  121. package/dist/bundle/chunk-QPRXTLMD.js +0 -33
  122. package/dist/bundle/command-contract-Y4ZQAJEC.js +0 -35
  123. package/dist/bundle/first-screen-W6RWTAU7.js +0 -33
  124. package/dist/bundle/server-I3IALQMC.js +0 -65
  125. package/dist/bundle/store-maintenance-command-LB6CMGP4.js +0 -55
@@ -2,18 +2,21 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  renderMessages
5
- } from "./chunk-ZKLXSVIO.js";
5
+ } from "./chunk-AGNAT7CM.js";
6
6
  import {
7
7
  answerOf,
8
8
  messengerContext
9
- } from "./chunk-72N26BQM.js";
9
+ } from "./chunk-VYHIX3OP.js";
10
10
  import {
11
11
  FETCHING,
12
12
  RULES_VERSION,
13
13
  applyTaskRulesOnArrival,
14
14
  capability,
15
15
  chatEventAnswer,
16
+ embeddingKeys,
17
+ endpointKeyName,
16
18
  memberAnswer,
19
+ modelGateway,
17
20
  newSendId,
18
21
  onlineDeps,
19
22
  openRequestTask,
@@ -27,19 +30,17 @@ import {
27
30
  typedQuery,
28
31
  withQuery,
29
32
  withTimeLimit
30
- } from "./chunk-QTMVGOSF.js";
33
+ } from "./chunk-LQDMUMA2.js";
31
34
  import {
32
- checkedOptions,
33
- range
34
- } from "./chunk-QPRXTLMD.js";
35
- import {
36
- messagesFor,
37
- systemFor,
38
- validateImages
39
- } from "./chunk-TCCN5TON.js";
35
+ holdLock,
36
+ lockPath,
37
+ releaseLock,
38
+ servingProfiles,
39
+ takeLock
40
+ } from "./chunk-M7RGG3UU.js";
40
41
  import {
41
42
  readSecret
42
- } from "./chunk-GAPQENMY.js";
43
+ } from "./chunk-S5OTP7XS.js";
43
44
  import {
44
45
  Command,
45
46
  LOCAL_READ,
@@ -50,8 +51,6 @@ import {
50
51
  codeOf,
51
52
  currentRun,
52
53
  destroysNothing,
53
- endpoint,
54
- envName,
55
54
  environmentOf,
56
55
  itemOf,
57
56
  jsonlRecords,
@@ -67,27 +66,20 @@ import {
67
66
  snakeKeys,
68
67
  storeTable,
69
68
  withoutProviderRefs
70
- } from "./chunk-HSBGNVEL.js";
69
+ } from "./chunk-B6QMMRIM.js";
71
70
  import {
72
71
  levelFor
73
- } from "./chunk-HRRSTIGP.js";
74
- import {
75
- holdLock,
76
- lockPath,
77
- releaseLock,
78
- servingProfiles,
79
- takeLock
80
- } from "./chunk-VQZCIDSO.js";
72
+ } from "./chunk-SBGXKM4U.js";
81
73
  import {
82
74
  holdersOf
83
- } from "./chunk-T3DTYJTG.js";
75
+ } from "./chunk-OU5CWCG2.js";
84
76
  import {
85
77
  QUICK_HEALTH_CHECKS,
86
78
  explainDamage,
87
79
  fts5Tables,
88
80
  invalidJson,
89
81
  storeHealth
90
- } from "./chunk-RY7PBP4F.js";
82
+ } from "./chunk-CYQVWITQ.js";
91
83
  import {
92
84
  CORPORA,
93
85
  MIGRATIONS,
@@ -101,6 +93,7 @@ import {
101
93
  fillTrigrams,
102
94
  fillVectorIndexes,
103
95
  involvementStoreOver,
96
+ isDerivedTable,
104
97
  migrate,
105
98
  noteIndexState,
106
99
  openSqlite,
@@ -121,45 +114,41 @@ import {
121
114
  storeClients,
122
115
  storeContents,
123
116
  vectorIndexCounts
124
- } from "./chunk-KMQAHDBM.js";
117
+ } from "./chunk-NOA6E6MM.js";
125
118
  import {
126
119
  formatLocator,
127
120
  parseLocator
128
- } from "./chunk-LTXYJAJK.js";
121
+ } from "./chunk-FWFNUJQD.js";
129
122
  import {
130
123
  readDamageMark,
131
124
  readHealthMark,
132
125
  recordDeepCheck
133
- } from "./chunk-HJ2CXDKJ.js";
126
+ } from "./chunk-EXPR6QAX.js";
134
127
  import {
135
128
  queryFieldsOf
136
- } from "./chunk-I2SDXWLR.js";
129
+ } from "./chunk-7YRKUEYE.js";
137
130
  import {
138
131
  failureKey,
139
132
  isStoreDamage
140
- } from "./chunk-SYEICLTR.js";
133
+ } from "./chunk-R554W7ZO.js";
141
134
  import {
142
135
  storePath
143
- } from "./chunk-RPCKBXKN.js";
136
+ } from "./chunk-5UKBUI4I.js";
144
137
  import {
145
138
  openCache
146
- } from "./chunk-AF62BPIW.js";
139
+ } from "./chunk-MUDHCYN4.js";
147
140
  import {
148
- Credentials,
149
- pathsAreOverridden,
150
141
  resolvePaths,
151
142
  writeSecurely
152
- } from "./chunk-BMV56JCL.js";
143
+ } from "./chunk-LLYVBO3R.js";
153
144
  import {
154
145
  array,
155
146
  boolean,
156
147
  check,
157
148
  forward,
158
149
  getDotPath,
159
- integer,
160
150
  minLength,
161
151
  nullable,
162
- number,
163
152
  object,
164
153
  optional,
165
154
  parse,
@@ -171,9 +160,8 @@ import {
171
160
  strictObject,
172
161
  string,
173
162
  transform,
174
- trim,
175
- union
176
- } from "./chunk-BHNBWFT5.js";
163
+ trim
164
+ } from "./chunk-GOMJNH56.js";
177
165
  import {
178
166
  CliError
179
167
  } from "./chunk-DALBYUPC.js";
@@ -354,14 +342,14 @@ var require_liquid_node = __commonJS({
354
342
  return value !== null && (type === "object" || type === "function");
355
343
  }
356
344
  __name(isObject, "isObject");
357
- function range2(start, stop, step = 1) {
345
+ function range(start, stop, step = 1) {
358
346
  const arr = [];
359
347
  for (let i = start; i < stop; i += step) {
360
348
  arr.push(i);
361
349
  }
362
350
  return arr;
363
351
  }
364
- __name(range2, "range");
352
+ __name(range, "range");
365
353
  function padStart(str, length, ch = " ") {
366
354
  return pad(str, length, ch, (str2, ch2) => ch2 + str2);
367
355
  }
@@ -555,7 +543,7 @@ var require_liquid_node = __commonJS({
555
543
  const lines = token.input.split("\n");
556
544
  const begin = Math.max(line - 2, 1);
557
545
  const end = Math.min(line + 3, lines.length);
558
- const context = range2(begin, end + 1).map((lineNumber) => {
546
+ const context = range(begin, end + 1).map((lineNumber) => {
559
547
  const rowIndicator = lineNumber === line ? ">> " : " ";
560
548
  const num = padStart(String(lineNumber), String(end).length);
561
549
  let text = `${rowIndicator}${num}| `;
@@ -1133,8 +1121,8 @@ var require_liquid_node = __commonJS({
1133
1121
  valid() {
1134
1122
  return !isNaN(this.getTime());
1135
1123
  }
1136
- format(options2) {
1137
- return this.DateTimeFormat && this.DateTimeFormat(this.locale, options2).format(this.displayDate);
1124
+ format(options) {
1125
+ return this.DateTimeFormat && this.DateTimeFormat(this.locale, options).format(this.displayDate);
1138
1126
  }
1139
1127
  /**
1140
1128
  * Create a Date object fixed to it's declared Timezone. Both
@@ -1218,11 +1206,11 @@ var require_liquid_node = __commonJS({
1218
1206
  static {
1219
1207
  __name(this, "TagToken");
1220
1208
  }
1221
- constructor(input, begin, end, options2, file2) {
1222
- const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options2;
1209
+ constructor(input, begin, end, options, file2) {
1210
+ const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
1223
1211
  const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
1224
1212
  super(exports.TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file2);
1225
- this.tokenizer = new Tokenizer(input, options2.operators, file2, this.contentRange, options2.groupedExpressions);
1213
+ this.tokenizer = new Tokenizer(input, options.operators, file2, this.contentRange, options.groupedExpressions);
1226
1214
  this.name = this.tokenizer.readTagName();
1227
1215
  this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
1228
1216
  this.tokenizer.skipBlank();
@@ -1233,8 +1221,8 @@ var require_liquid_node = __commonJS({
1233
1221
  static {
1234
1222
  __name(this, "OutputToken");
1235
1223
  }
1236
- constructor(input, begin, end, options2, file2) {
1237
- const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } = options2;
1224
+ constructor(input, begin, end, options, file2) {
1225
+ const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } = options;
1238
1226
  const valueRange = [begin + outputDelimiterLeft.length, end - outputDelimiterRight.length];
1239
1227
  super(exports.TokenKind.Output, valueRange, input, begin, end, trimOutputLeft, trimOutputRight, file2);
1240
1228
  }
@@ -1453,9 +1441,9 @@ var require_liquid_node = __commonJS({
1453
1441
  static {
1454
1442
  __name(this, "LiquidTagToken");
1455
1443
  }
1456
- constructor(input, begin, end, options2, file2) {
1444
+ constructor(input, begin, end, options, file2) {
1457
1445
  super(exports.TokenKind.Tag, [begin, end], input, begin, end, false, false, file2);
1458
- this.tokenizer = new Tokenizer(input, options2.operators, file2, this.contentRange, options2.groupedExpressions);
1446
+ this.tokenizer = new Tokenizer(input, options.operators, file2, this.contentRange, options.groupedExpressions);
1459
1447
  this.name = this.tokenizer.readTagName();
1460
1448
  this.tokenizer.assert(this.name, "illegal liquid tag syntax");
1461
1449
  this.tokenizer.skipBlank();
@@ -1529,11 +1517,11 @@ var require_liquid_node = __commonJS({
1529
1517
  static {
1530
1518
  __name(this, "Filter");
1531
1519
  }
1532
- constructor(token, options2, liquid) {
1520
+ constructor(token, options, liquid) {
1533
1521
  this.token = token;
1534
1522
  this.name = token.name;
1535
- this.handler = isFunction(options2) ? options2 : isFunction(options2?.handler) ? options2.handler : identify;
1536
- this.raw = !isFunction(options2) && !!options2?.raw;
1523
+ this.handler = isFunction(options) ? options : isFunction(options?.handler) ? options.handler : identify;
1524
+ this.raw = !isFunction(options) && !!options?.raw;
1537
1525
  this.args = token.args;
1538
1526
  this.liquid = liquid;
1539
1527
  }
@@ -1636,7 +1624,7 @@ var require_liquid_node = __commonJS({
1636
1624
  const low = yield evalTokenValue(token.lhs, ctx);
1637
1625
  const high = yield evalTokenValue(token.rhs, ctx);
1638
1626
  ctx.memoryLimit.use(high - low + 1);
1639
- return range2(+low, +high + 1);
1627
+ return range(+low, +high + 1);
1640
1628
  }
1641
1629
  __name(evalRangeToken, "evalRangeToken");
1642
1630
  function* toPostfix(tokens) {
@@ -1830,7 +1818,7 @@ var require_liquid_node = __commonJS({
1830
1818
  return readFileAsync(filepath, "utf8");
1831
1819
  }
1832
1820
  __name(readFile, "readFile");
1833
- function existsSync10(filepath) {
1821
+ function existsSync11(filepath) {
1834
1822
  try {
1835
1823
  fs$1.statSync(filepath);
1836
1824
  return true;
@@ -1838,11 +1826,11 @@ var require_liquid_node = __commonJS({
1838
1826
  return false;
1839
1827
  }
1840
1828
  }
1841
- __name(existsSync10, "existsSync");
1842
- function readFileSync5(filepath) {
1829
+ __name(existsSync11, "existsSync");
1830
+ function readFileSync6(filepath) {
1843
1831
  return fs$1.readFileSync(filepath, "utf8");
1844
1832
  }
1845
- __name(readFileSync5, "readFileSync");
1833
+ __name(readFileSync6, "readFileSync");
1846
1834
  function resolve2(root, file2, ext) {
1847
1835
  if (!path.extname(file2))
1848
1836
  file2 += ext;
@@ -1856,10 +1844,10 @@ var require_liquid_node = __commonJS({
1856
1844
  }
1857
1845
  }
1858
1846
  __name(fallback, "fallback");
1859
- function dirname3(filepath) {
1847
+ function dirname4(filepath) {
1860
1848
  return path.dirname(filepath);
1861
1849
  }
1862
- __name(dirname3, "dirname");
1850
+ __name(dirname4, "dirname");
1863
1851
  var realpathAsync = promisify(fs$1.realpath);
1864
1852
  async function contains(root, file2) {
1865
1853
  try {
@@ -1887,11 +1875,11 @@ var require_liquid_node = __commonJS({
1887
1875
  __proto__: null,
1888
1876
  exists,
1889
1877
  readFile,
1890
- existsSync: existsSync10,
1891
- readFileSync: readFileSync5,
1878
+ existsSync: existsSync11,
1879
+ readFileSync: readFileSync6,
1892
1880
  resolve: resolve2,
1893
1881
  fallback,
1894
- dirname: dirname3,
1882
+ dirname: dirname4,
1895
1883
  contains,
1896
1884
  containsSync,
1897
1885
  sep: path.sep
@@ -2117,41 +2105,41 @@ var require_liquid_node = __commonJS({
2117
2105
  parseLimit: Infinity,
2118
2106
  renderLimit: Infinity
2119
2107
  };
2120
- function normalize(options2) {
2121
- if (options2.hasOwnProperty("root")) {
2122
- if (!options2.hasOwnProperty("partials"))
2123
- options2.partials = options2.root;
2124
- if (!options2.hasOwnProperty("layouts"))
2125
- options2.layouts = options2.root;
2126
- }
2127
- if (options2.hasOwnProperty("cache")) {
2108
+ function normalize(options) {
2109
+ if (options.hasOwnProperty("root")) {
2110
+ if (!options.hasOwnProperty("partials"))
2111
+ options.partials = options.root;
2112
+ if (!options.hasOwnProperty("layouts"))
2113
+ options.layouts = options.root;
2114
+ }
2115
+ if (options.hasOwnProperty("cache")) {
2128
2116
  let cache;
2129
- if (typeof options2.cache === "number")
2130
- cache = options2.cache > 0 ? new LRU(options2.cache) : void 0;
2131
- else if (typeof options2.cache === "object")
2132
- cache = options2.cache;
2117
+ if (typeof options.cache === "number")
2118
+ cache = options.cache > 0 ? new LRU(options.cache) : void 0;
2119
+ else if (typeof options.cache === "object")
2120
+ cache = options.cache;
2133
2121
  else
2134
- cache = options2.cache ? new LRU(1024) : void 0;
2135
- options2.cache = cache;
2122
+ cache = options.cache ? new LRU(1024) : void 0;
2123
+ options.cache = cache;
2136
2124
  }
2137
- options2 = { ...defaultOptions, ...options2.jekyllInclude ? { dynamicPartials: false } : {}, ...options2 };
2138
- if ((!options2.fs.dirname || !options2.fs.sep) && options2.relativeReference) {
2125
+ options = { ...defaultOptions, ...options.jekyllInclude ? { dynamicPartials: false } : {}, ...options };
2126
+ if ((!options.fs.dirname || !options.fs.sep) && options.relativeReference) {
2139
2127
  console.warn("[LiquidJS] `fs.dirname` and `fs.sep` are required for relativeReference, set relativeReference to `false` to suppress this warning");
2140
- options2.relativeReference = false;
2128
+ options.relativeReference = false;
2141
2129
  }
2142
- options2.root = normalizeDirectoryList(options2.root);
2143
- options2.partials = normalizeDirectoryList(options2.partials);
2144
- options2.layouts = normalizeDirectoryList(options2.layouts);
2145
- options2.outputEscape = options2.outputEscape && getOutputEscapeFunction(options2.outputEscape);
2146
- if (!options2.locale) {
2147
- options2.locale = getDateTimeFormat()?.().resolvedOptions().locale ?? "en-US";
2130
+ options.root = normalizeDirectoryList(options.root);
2131
+ options.partials = normalizeDirectoryList(options.partials);
2132
+ options.layouts = normalizeDirectoryList(options.layouts);
2133
+ options.outputEscape = options.outputEscape && getOutputEscapeFunction(options.outputEscape);
2134
+ if (!options.locale) {
2135
+ options.locale = getDateTimeFormat()?.().resolvedOptions().locale ?? "en-US";
2148
2136
  }
2149
- if (options2.templates) {
2150
- options2.fs = new MapFS(options2.templates);
2151
- options2.relativeReference = true;
2152
- options2.root = options2.partials = options2.layouts = ".";
2137
+ if (options.templates) {
2138
+ options.fs = new MapFS(options.templates);
2139
+ options.relativeReference = true;
2140
+ options.root = options.partials = options.layouts = ".";
2153
2141
  }
2154
- return options2;
2142
+ return options;
2155
2143
  }
2156
2144
  __name(normalize, "normalize");
2157
2145
  function getOutputEscapeFunction(nameOrFunction) {
@@ -2172,14 +2160,14 @@ var require_liquid_node = __commonJS({
2172
2160
  return list;
2173
2161
  }
2174
2162
  __name(normalizeDirectoryList, "normalizeDirectoryList");
2175
- function whiteSpaceCtrl(tokens, options2) {
2163
+ function whiteSpaceCtrl(tokens, options) {
2176
2164
  let inRaw = false;
2177
2165
  for (let i = 0; i < tokens.length; i++) {
2178
2166
  const token = tokens[i];
2179
2167
  if (!isDelimitedToken(token))
2180
2168
  continue;
2181
2169
  if (!inRaw && token.trimLeft) {
2182
- trimLeft(tokens[i - 1], options2.greedy);
2170
+ trimLeft(tokens[i - 1], options.greedy);
2183
2171
  }
2184
2172
  if (isTagToken(token)) {
2185
2173
  if (token.name === "raw")
@@ -2188,7 +2176,7 @@ var require_liquid_node = __commonJS({
2188
2176
  inRaw = false;
2189
2177
  }
2190
2178
  if (!inRaw && token.trimRight) {
2191
- trimRight(tokens[i + 1], options2.greedy);
2179
+ trimRight(tokens[i + 1], options.greedy);
2192
2180
  }
2193
2181
  }
2194
2182
  }
@@ -2215,12 +2203,12 @@ var require_liquid_node = __commonJS({
2215
2203
  static {
2216
2204
  __name(this, "Tokenizer");
2217
2205
  }
2218
- constructor(input, operators = defaultOptions.operators, file2, range3, groupedExpressions = false) {
2206
+ constructor(input, operators = defaultOptions.operators, file2, range2, groupedExpressions = false) {
2219
2207
  this.input = input;
2220
2208
  this.file = file2;
2221
2209
  this.rawBeginAt = -1;
2222
- this.p = range3 ? range3[0] : 0;
2223
- this.N = range3 ? range3[1] : input.length;
2210
+ this.p = range2 ? range2[0] : 0;
2211
+ this.N = range2 ? range2[1] : input.length;
2224
2212
  this.opTrie = createTrie(operators);
2225
2213
  this.literalTrie = createTrie(literalValues);
2226
2214
  this.groupedExpressions = groupedExpressions;
@@ -2320,23 +2308,23 @@ var require_liquid_node = __commonJS({
2320
2308
  const value = this.readValue();
2321
2309
  return [key.getText(), value];
2322
2310
  }
2323
- readTopLevelTokens(options2 = defaultOptions) {
2311
+ readTopLevelTokens(options = defaultOptions) {
2324
2312
  const tokens = [];
2325
2313
  while (this.p < this.N) {
2326
- const token = this.readTopLevelToken(options2);
2314
+ const token = this.readTopLevelToken(options);
2327
2315
  tokens.push(token);
2328
2316
  }
2329
- whiteSpaceCtrl(tokens, options2);
2317
+ whiteSpaceCtrl(tokens, options);
2330
2318
  return tokens;
2331
2319
  }
2332
- readTopLevelToken(options2) {
2333
- const { tagDelimiterLeft, outputDelimiterLeft } = options2;
2320
+ readTopLevelToken(options) {
2321
+ const { tagDelimiterLeft, outputDelimiterLeft } = options;
2334
2322
  if (this.rawBeginAt > -1)
2335
- return this.readEndrawOrRawContent(options2);
2323
+ return this.readEndrawOrRawContent(options);
2336
2324
  if (this.match(tagDelimiterLeft))
2337
- return this.readTagToken(options2);
2325
+ return this.readTagToken(options);
2338
2326
  if (this.match(outputDelimiterLeft))
2339
- return this.readOutputToken(options2);
2327
+ return this.readOutputToken(options);
2340
2328
  return this.readHTMLToken([tagDelimiterLeft, outputDelimiterLeft]);
2341
2329
  }
2342
2330
  readHTMLToken(stopStrings) {
@@ -2348,13 +2336,13 @@ var require_liquid_node = __commonJS({
2348
2336
  }
2349
2337
  return new HTMLToken(this.input, begin, this.p, this.file);
2350
2338
  }
2351
- readTagToken(options2) {
2339
+ readTagToken(options) {
2352
2340
  const { file: file2, input } = this;
2353
2341
  const begin = this.p;
2354
- if (this.readToDelimiter(options2.tagDelimiterRight) === -1) {
2342
+ if (this.readToDelimiter(options.tagDelimiterRight) === -1) {
2355
2343
  throw this.error(`tag ${this.snapshot(begin)} not closed`, begin);
2356
2344
  }
2357
- const token = new TagToken(input, begin, this.p, options2, file2);
2345
+ const token = new TagToken(input, begin, this.p, options, file2);
2358
2346
  if (token.name === "raw")
2359
2347
  this.rawBeginAt = begin;
2360
2348
  return token;
@@ -2372,17 +2360,17 @@ var require_liquid_node = __commonJS({
2372
2360
  }
2373
2361
  return -1;
2374
2362
  }
2375
- readOutputToken(options2 = defaultOptions) {
2363
+ readOutputToken(options = defaultOptions) {
2376
2364
  const { file: file2, input } = this;
2377
- const { outputDelimiterRight } = options2;
2365
+ const { outputDelimiterRight } = options;
2378
2366
  const begin = this.p;
2379
2367
  if (this.readToDelimiter(outputDelimiterRight, true) === -1) {
2380
2368
  throw this.error(`output ${this.snapshot(begin)} not closed`, begin);
2381
2369
  }
2382
- return new OutputToken(input, begin, this.p, options2, file2);
2370
+ return new OutputToken(input, begin, this.p, options, file2);
2383
2371
  }
2384
- readEndrawOrRawContent(options2) {
2385
- const { tagDelimiterLeft, tagDelimiterRight } = options2;
2372
+ readEndrawOrRawContent(options) {
2373
+ const { tagDelimiterLeft, tagDelimiterRight } = options;
2386
2374
  const begin = this.p;
2387
2375
  let leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
2388
2376
  while (this.p < this.N) {
@@ -2395,7 +2383,7 @@ var require_liquid_node = __commonJS({
2395
2383
  const end = this.p;
2396
2384
  if (begin === leftPos) {
2397
2385
  this.rawBeginAt = -1;
2398
- return new TagToken(this.input, begin, end, options2, this.file);
2386
+ return new TagToken(this.input, begin, end, options, this.file);
2399
2387
  } else {
2400
2388
  this.p = leftPos;
2401
2389
  return new HTMLToken(this.input, begin, leftPos, this.file);
@@ -2408,22 +2396,22 @@ var require_liquid_node = __commonJS({
2408
2396
  }
2409
2397
  throw this.error(`raw ${this.snapshot(this.rawBeginAt)} not closed`, begin);
2410
2398
  }
2411
- readLiquidTagTokens(options2 = defaultOptions) {
2399
+ readLiquidTagTokens(options = defaultOptions) {
2412
2400
  const tokens = [];
2413
2401
  while (this.p < this.N) {
2414
- const token = this.readLiquidTagToken(options2);
2402
+ const token = this.readLiquidTagToken(options);
2415
2403
  token && tokens.push(token);
2416
2404
  }
2417
2405
  return tokens;
2418
2406
  }
2419
- readLiquidTagToken(options2) {
2407
+ readLiquidTagToken(options) {
2420
2408
  this.skipBlank();
2421
2409
  if (this.end())
2422
2410
  return;
2423
2411
  const begin = this.p;
2424
2412
  this.readToDelimiter("\n");
2425
2413
  const end = this.p;
2426
- return new LiquidTagToken(this.input, begin, end, options2, this.file);
2414
+ return new LiquidTagToken(this.input, begin, end, options, this.file);
2427
2415
  }
2428
2416
  error(msg, pos = this.p) {
2429
2417
  return new TokenizationError(msg, new IdentifierToken(this.input, pos, this.N, this.file));
@@ -2635,12 +2623,12 @@ var require_liquid_node = __commonJS({
2635
2623
  }
2636
2624
  return new QuotedToken(this.input, begin, this.p, this.file);
2637
2625
  }
2638
- *readFileNameTemplate(options2) {
2639
- const { outputDelimiterLeft } = options2;
2626
+ *readFileNameTemplate(options) {
2627
+ const { outputDelimiterLeft } = options;
2640
2628
  const htmlStopStrings = [",", " ", "\r", "\n", " ", outputDelimiterLeft];
2641
2629
  const htmlStopStringSet = new Set(htmlStopStrings);
2642
2630
  while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
2643
- yield this.match(outputDelimiterLeft) ? this.readOutputToken(options2) : this.readHTMLToken(htmlStopStrings);
2631
+ yield this.match(outputDelimiterLeft) ? this.readOutputToken(options) : this.readHTMLToken(htmlStopStrings);
2644
2632
  }
2645
2633
  }
2646
2634
  match(word) {
@@ -2715,7 +2703,7 @@ var require_liquid_node = __commonJS({
2715
2703
  this.token = token;
2716
2704
  }
2717
2705
  };
2718
- var Tag2 = class extends TemplateImpl {
2706
+ var Tag3 = class extends TemplateImpl {
2719
2707
  static {
2720
2708
  __name(this, "Tag");
2721
2709
  }
@@ -2745,17 +2733,17 @@ var require_liquid_node = __commonJS({
2745
2733
  return hash;
2746
2734
  }
2747
2735
  };
2748
- function createTagClass(options2) {
2749
- return class extends Tag2 {
2736
+ function createTagClass(options) {
2737
+ return class extends Tag3 {
2750
2738
  constructor(token, tokens, liquid) {
2751
2739
  super(token, tokens, liquid);
2752
- if (isFunction(options2.parse)) {
2753
- options2.parse.call(this, token, tokens);
2740
+ if (isFunction(options.parse)) {
2741
+ options.parse.call(this, token, tokens);
2754
2742
  }
2755
2743
  }
2756
2744
  *render(ctx, emitter) {
2757
2745
  const hash = yield new Hash(this.token.args, ctx.opts.keyValueSeparator).render(ctx);
2758
- return yield options2.render.call(this, ctx, emitter, hash);
2746
+ return yield options.render.call(this, ctx, emitter, hash);
2759
2747
  }
2760
2748
  };
2761
2749
  }
@@ -2972,13 +2960,13 @@ var require_liquid_node = __commonJS({
2972
2960
  };
2973
2961
  }
2974
2962
  __name(_analyze, "_analyze");
2975
- function analyze(template2, options2 = {}) {
2976
- const opts = { ...defaultStaticAnalysisOptions, ...options2 };
2963
+ function analyze(template2, options = {}) {
2964
+ const opts = { ...defaultStaticAnalysisOptions, ...options };
2977
2965
  return toPromise(_analyze(template2, opts.partials, false));
2978
2966
  }
2979
2967
  __name(analyze, "analyze");
2980
- function analyzeSync(template2, options2 = {}) {
2981
- const opts = { ...defaultStaticAnalysisOptions, ...options2 };
2968
+ function analyzeSync(template2, options = {}) {
2969
+ const opts = { ...defaultStaticAnalysisOptions, ...options };
2982
2970
  return toValueSync(_analyze(template2, opts.partials, true));
2983
2971
  }
2984
2972
  __name(analyzeSync, "analyzeSync");
@@ -3154,17 +3142,17 @@ var require_liquid_node = __commonJS({
3154
3142
  static {
3155
3143
  __name(this, "Loader");
3156
3144
  }
3157
- constructor(options2) {
3158
- this.options = options2;
3159
- if (options2.relativeReference) {
3160
- const sep = options2.fs.sep;
3145
+ constructor(options) {
3146
+ this.options = options;
3147
+ if (options.relativeReference) {
3148
+ const sep = options.fs.sep;
3161
3149
  assert(sep, "`fs.sep` is required for relative reference");
3162
3150
  const prefixes = ["." + sep, ".." + sep, "./", "../"];
3163
3151
  this.shouldLoadRelative = (referencedFile) => prefixes.some((prefix) => referencedFile.startsWith(prefix));
3164
3152
  } else {
3165
3153
  this.shouldLoadRelative = (_referencedFile) => false;
3166
3154
  }
3167
- const fs2 = options2.fs;
3155
+ const fs2 = options.fs;
3168
3156
  this.contains = toLiquidAsync(fs2.contains?.bind(fs2) || (async () => true), fs2.containsSync?.bind(fs2) || (() => true));
3169
3157
  this.exists = toLiquidAsync(fs2.exists?.bind(fs2) || (async () => false), fs2.existsSync?.bind(fs2));
3170
3158
  }
@@ -3616,7 +3604,7 @@ var require_liquid_node = __commonJS({
3616
3604
  uri_escape,
3617
3605
  slugify
3618
3606
  });
3619
- var join5 = argumentsToValue(function(v, arg) {
3607
+ var join6 = argumentsToValue(function(v, arg) {
3620
3608
  const array2 = toArray(v);
3621
3609
  const sep = isNil(arg) ? " " : stringify(arg);
3622
3610
  let outputSize = sep.length * Math.max(array2.length - 1, 0);
@@ -3892,7 +3880,7 @@ var require_liquid_node = __commonJS({
3892
3880
  __name(sample, "sample");
3893
3881
  var arrayFilters = /* @__PURE__ */ Object.freeze({
3894
3882
  __proto__: null,
3895
- join: join5,
3883
+ join: join6,
3896
3884
  last,
3897
3885
  first,
3898
3886
  reverse,
@@ -4314,7 +4302,7 @@ var require_liquid_node = __commonJS({
4314
4302
  ...cryptoFilters,
4315
4303
  ...misc
4316
4304
  };
4317
- var AssignTag = class extends Tag2 {
4305
+ var AssignTag = class extends Tag3 {
4318
4306
  static {
4319
4307
  __name(this, "AssignTag");
4320
4308
  }
@@ -4339,7 +4327,7 @@ var require_liquid_node = __commonJS({
4339
4327
  }
4340
4328
  };
4341
4329
  var MODIFIERS = ["offset", "limit", "reversed"];
4342
- var ForTag = class extends Tag2 {
4330
+ var ForTag = class extends Tag3 {
4343
4331
  static {
4344
4332
  __name(this, "ForTag");
4345
4333
  }
@@ -4432,7 +4420,7 @@ var require_liquid_node = __commonJS({
4432
4420
  return arr.slice(0, count3);
4433
4421
  }
4434
4422
  __name(limit2, "limit");
4435
- var CaptureTag = class extends Tag2 {
4423
+ var CaptureTag = class extends Tag3 {
4436
4424
  static {
4437
4425
  __name(this, "CaptureTag");
4438
4426
  }
@@ -4470,7 +4458,7 @@ var require_liquid_node = __commonJS({
4470
4458
  yield this.identifier;
4471
4459
  }
4472
4460
  };
4473
- var CaseTag = class extends Tag2 {
4461
+ var CaseTag = class extends Tag3 {
4474
4462
  static {
4475
4463
  __name(this, "CaseTag");
4476
4464
  }
@@ -4543,7 +4531,7 @@ var require_liquid_node = __commonJS({
4543
4531
  return templates;
4544
4532
  }
4545
4533
  };
4546
- var CommentTag = class extends Tag2 {
4534
+ var CommentTag = class extends Tag3 {
4547
4535
  static {
4548
4536
  __name(this, "CommentTag");
4549
4537
  }
@@ -4559,7 +4547,7 @@ var require_liquid_node = __commonJS({
4559
4547
  render() {
4560
4548
  }
4561
4549
  };
4562
- var RenderTag = class extends Tag2 {
4550
+ var RenderTag = class extends Tag3 {
4563
4551
  static {
4564
4552
  __name(this, "RenderTag");
4565
4553
  }
@@ -4706,7 +4694,7 @@ var require_liquid_node = __commonJS({
4706
4694
  return yield evalToken(file2, ctx);
4707
4695
  }
4708
4696
  __name(renderFilePath, "renderFilePath");
4709
- var IncludeTag = class extends Tag2 {
4697
+ var IncludeTag = class extends Tag3 {
4710
4698
  static {
4711
4699
  __name(this, "IncludeTag");
4712
4700
  }
@@ -4774,7 +4762,7 @@ var require_liquid_node = __commonJS({
4774
4762
  }
4775
4763
  }
4776
4764
  };
4777
- var DecrementTag = class extends Tag2 {
4765
+ var DecrementTag = class extends Tag3 {
4778
4766
  static {
4779
4767
  __name(this, "DecrementTag");
4780
4768
  }
@@ -4794,7 +4782,7 @@ var require_liquid_node = __commonJS({
4794
4782
  yield this.identifier;
4795
4783
  }
4796
4784
  };
4797
- var CycleTag = class extends Tag2 {
4785
+ var CycleTag = class extends Tag3 {
4798
4786
  static {
4799
4787
  __name(this, "CycleTag");
4800
4788
  }
@@ -4838,7 +4826,7 @@ var require_liquid_node = __commonJS({
4838
4826
  }
4839
4827
  }
4840
4828
  };
4841
- var IfTag = class extends Tag2 {
4829
+ var IfTag = class extends Tag3 {
4842
4830
  static {
4843
4831
  __name(this, "IfTag");
4844
4832
  }
@@ -4888,7 +4876,7 @@ var require_liquid_node = __commonJS({
4888
4876
  return this.branches.map((b) => b.value);
4889
4877
  }
4890
4878
  };
4891
- var IncrementTag = class extends Tag2 {
4879
+ var IncrementTag = class extends Tag3 {
4892
4880
  static {
4893
4881
  __name(this, "IncrementTag");
4894
4882
  }
@@ -4910,7 +4898,7 @@ var require_liquid_node = __commonJS({
4910
4898
  yield this.identifier;
4911
4899
  }
4912
4900
  };
4913
- var LayoutTag = class extends Tag2 {
4901
+ var LayoutTag = class extends Tag3 {
4914
4902
  static {
4915
4903
  __name(this, "LayoutTag");
4916
4904
  }
@@ -4965,7 +4953,7 @@ var require_liquid_node = __commonJS({
4965
4953
  }
4966
4954
  }
4967
4955
  };
4968
- var BlockTag = class extends Tag2 {
4956
+ var BlockTag = class extends Tag3 {
4969
4957
  static {
4970
4958
  __name(this, "BlockTag");
4971
4959
  }
@@ -5014,7 +5002,7 @@ var require_liquid_node = __commonJS({
5014
5002
  return ["block"];
5015
5003
  }
5016
5004
  };
5017
- var RawTag = class extends Tag2 {
5005
+ var RawTag = class extends Tag3 {
5018
5006
  static {
5019
5007
  __name(this, "RawTag");
5020
5008
  }
@@ -5058,7 +5046,7 @@ var require_liquid_node = __commonJS({
5058
5046
  return this.col() === this.cols;
5059
5047
  }
5060
5048
  };
5061
- var TablerowTag = class extends Tag2 {
5049
+ var TablerowTag = class extends Tag3 {
5062
5050
  static {
5063
5051
  __name(this, "TablerowTag");
5064
5052
  }
@@ -5122,7 +5110,7 @@ var require_liquid_node = __commonJS({
5122
5110
  return [this.variable, "tablerowloop"];
5123
5111
  }
5124
5112
  };
5125
- var UnlessTag = class extends Tag2 {
5113
+ var UnlessTag = class extends Tag3 {
5126
5114
  static {
5127
5115
  __name(this, "UnlessTag");
5128
5116
  }
@@ -5181,7 +5169,7 @@ var require_liquid_node = __commonJS({
5181
5169
  return this.branches.map((b) => b.value);
5182
5170
  }
5183
5171
  };
5184
- var BreakTag = class extends Tag2 {
5172
+ var BreakTag = class extends Tag3 {
5185
5173
  static {
5186
5174
  __name(this, "BreakTag");
5187
5175
  }
@@ -5189,7 +5177,7 @@ var require_liquid_node = __commonJS({
5189
5177
  ctx.breakCalled = true;
5190
5178
  }
5191
5179
  };
5192
- var ContinueTag = class extends Tag2 {
5180
+ var ContinueTag = class extends Tag3 {
5193
5181
  static {
5194
5182
  __name(this, "ContinueTag");
5195
5183
  }
@@ -5197,7 +5185,7 @@ var require_liquid_node = __commonJS({
5197
5185
  ctx.continueCalled = true;
5198
5186
  }
5199
5187
  };
5200
- var EchoTag = class extends Tag2 {
5188
+ var EchoTag = class extends Tag3 {
5201
5189
  static {
5202
5190
  __name(this, "EchoTag");
5203
5191
  }
@@ -5220,7 +5208,7 @@ var require_liquid_node = __commonJS({
5220
5208
  }
5221
5209
  }
5222
5210
  };
5223
- var LiquidTag = class extends Tag2 {
5211
+ var LiquidTag = class extends Tag3 {
5224
5212
  static {
5225
5213
  __name(this, "LiquidTag");
5226
5214
  }
@@ -5236,7 +5224,7 @@ var require_liquid_node = __commonJS({
5236
5224
  return this.templates;
5237
5225
  }
5238
5226
  };
5239
- var InlineCommentTag = class extends Tag2 {
5227
+ var InlineCommentTag = class extends Tag3 {
5240
5228
  static {
5241
5229
  __name(this, "InlineCommentTag");
5242
5230
  }
@@ -5379,76 +5367,76 @@ var require_liquid_node = __commonJS({
5379
5367
  self.renderFile(filePath, ctx).then((html) => callback(null, html), callback);
5380
5368
  };
5381
5369
  }
5382
- async analyze(template2, options2 = {}) {
5383
- return analyze(template2, options2);
5370
+ async analyze(template2, options = {}) {
5371
+ return analyze(template2, options);
5384
5372
  }
5385
- analyzeSync(template2, options2 = {}) {
5386
- return analyzeSync(template2, options2);
5373
+ analyzeSync(template2, options = {}) {
5374
+ return analyzeSync(template2, options);
5387
5375
  }
5388
- async parseAndAnalyze(html, filename, options2 = {}) {
5389
- return analyze(this.parse(html, filename), options2);
5376
+ async parseAndAnalyze(html, filename, options = {}) {
5377
+ return analyze(this.parse(html, filename), options);
5390
5378
  }
5391
- parseAndAnalyzeSync(html, filename, options2 = {}) {
5392
- return analyzeSync(this.parse(html, filename), options2);
5379
+ parseAndAnalyzeSync(html, filename, options = {}) {
5380
+ return analyzeSync(this.parse(html, filename), options);
5393
5381
  }
5394
5382
  /** Return an array of all variables without their properties. */
5395
- async variables(template2, options2 = {}) {
5396
- const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options2);
5383
+ async variables(template2, options = {}) {
5384
+ const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
5397
5385
  return Object.keys(analysis.variables);
5398
5386
  }
5399
5387
  /** Return an array of all variables without their properties. */
5400
- variablesSync(template2, options2 = {}) {
5401
- const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options2);
5388
+ variablesSync(template2, options = {}) {
5389
+ const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
5402
5390
  return Object.keys(analysis.variables);
5403
5391
  }
5404
5392
  /** Return an array of all variables including their properties/paths. */
5405
- async fullVariables(template2, options2 = {}) {
5406
- const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options2);
5393
+ async fullVariables(template2, options = {}) {
5394
+ const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
5407
5395
  return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
5408
5396
  }
5409
5397
  /** Return an array of all variables including their properties/paths. */
5410
- fullVariablesSync(template2, options2 = {}) {
5411
- const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options2);
5398
+ fullVariablesSync(template2, options = {}) {
5399
+ const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
5412
5400
  return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
5413
5401
  }
5414
5402
  /** Return an array of all variables, each as an array of properties/segments. */
5415
- async variableSegments(template2, options2 = {}) {
5416
- const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options2);
5403
+ async variableSegments(template2, options = {}) {
5404
+ const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
5417
5405
  return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
5418
5406
  }
5419
5407
  /** Return an array of all variables, each as an array of properties/segments. */
5420
- variableSegmentsSync(template2, options2 = {}) {
5421
- const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options2);
5408
+ variableSegmentsSync(template2, options = {}) {
5409
+ const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
5422
5410
  return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
5423
5411
  }
5424
5412
  /** Return an array of all expected context variables without their properties. */
5425
- async globalVariables(template2, options2 = {}) {
5426
- const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options2);
5413
+ async globalVariables(template2, options = {}) {
5414
+ const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
5427
5415
  return Object.keys(analysis.globals);
5428
5416
  }
5429
5417
  /** Return an array of all expected context variables without their properties. */
5430
- globalVariablesSync(template2, options2 = {}) {
5431
- const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options2);
5418
+ globalVariablesSync(template2, options = {}) {
5419
+ const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
5432
5420
  return Object.keys(analysis.globals);
5433
5421
  }
5434
5422
  /** Return an array of all expected context variables including their properties/paths. */
5435
- async globalFullVariables(template2, options2 = {}) {
5436
- const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options2);
5423
+ async globalFullVariables(template2, options = {}) {
5424
+ const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
5437
5425
  return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
5438
5426
  }
5439
5427
  /** Return an array of all expected context variables including their properties/paths. */
5440
- globalFullVariablesSync(template2, options2 = {}) {
5441
- const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options2);
5428
+ globalFullVariablesSync(template2, options = {}) {
5429
+ const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
5442
5430
  return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
5443
5431
  }
5444
5432
  /** Return an array of all expected context variables, each as an array of properties/segments. */
5445
- async globalVariableSegments(template2, options2 = {}) {
5446
- const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options2);
5433
+ async globalVariableSegments(template2, options = {}) {
5434
+ const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
5447
5435
  return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
5448
5436
  }
5449
5437
  /** Return an array of all expected context variables, each as an array of properties/segments. */
5450
- globalVariableSegmentsSync(template2, options2 = {}) {
5451
- const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options2);
5438
+ globalVariableSegmentsSync(template2, options = {}) {
5439
+ const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
5452
5440
  return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
5453
5441
  }
5454
5442
  };
@@ -5486,7 +5474,7 @@ var require_liquid_node = __commonJS({
5486
5474
  exports.RenderError = RenderError;
5487
5475
  exports.RenderTag = RenderTag;
5488
5476
  exports.TablerowTag = TablerowTag;
5489
- exports.Tag = Tag2;
5477
+ exports.Tag = Tag3;
5490
5478
  exports.TagToken = TagToken;
5491
5479
  exports.Token = Token;
5492
5480
  exports.TokenizationError = TokenizationError;
@@ -5516,11 +5504,11 @@ var require_liquid_node = __commonJS({
5516
5504
  }
5517
5505
  });
5518
5506
 
5519
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5520
- 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";
5521
- import { dirname as dirname2, resolve } from "node:path";
5507
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5508
+ 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";
5509
+ import { dirname as dirname3, resolve } from "node:path";
5522
5510
 
5523
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/sealed.js
5511
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/sealed.js
5524
5512
  import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
5525
5513
  import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
5526
5514
  import { Transform } from "node:stream";
@@ -5627,7 +5615,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
5627
5615
  renameSync(pending, to);
5628
5616
  }, "unsealFile");
5629
5617
 
5630
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5618
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5631
5619
  var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
5632
5620
  var fileSchemaOf = /* @__PURE__ */ __name((database) => {
5633
5621
  const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
@@ -5651,7 +5639,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
5651
5639
  };
5652
5640
  }, "compatibilityOf");
5653
5641
 
5654
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/repair.js
5642
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/store/repair.js
5655
5643
  import { createHash as createHash2 } from "node:crypto";
5656
5644
  var COPY_MARK = "__repair_";
5657
5645
  var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
@@ -5905,17 +5893,99 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
5905
5893
  return found;
5906
5894
  }, "deleteCopy");
5907
5895
 
5908
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5896
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5909
5897
  import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
5910
5898
 
5911
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
5899
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
5912
5900
  import { existsSync as existsSync3 } from "node:fs";
5913
5901
 
5914
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/recover.js
5902
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/store/recover.js
5915
5903
  import { execFileSync, spawn } from "node:child_process";
5916
5904
  import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
5917
5905
  import { basename, dirname, join } from "node:path";
5918
5906
  import { Transform as Transform2 } from "node:stream";
5907
+
5908
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/store/refill.js
5909
+ var REFILL_MARGIN_MS = 864e5;
5910
+ var TIME_KEYS = 1e12;
5911
+ var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
5912
+ var forgetCoverageSince = /* @__PURE__ */ __name((database, cutoff, now = Date.now()) => {
5913
+ database.exec("BEGIN");
5914
+ try {
5915
+ const refetch = forget(database, cutoff, now);
5916
+ database.exec("COMMIT");
5917
+ return refetch;
5918
+ } catch (error) {
5919
+ database.exec("ROLLBACK");
5920
+ throw error;
5921
+ }
5922
+ }, "forgetCoverageSince");
5923
+ var forget = /* @__PURE__ */ __name((database, cutoff, now) => {
5924
+ const chats = /* @__PURE__ */ new Map();
5925
+ const held = database.prepare(`SELECT c.id, c.account_id, c.external_id AS chat, a.provider, a.external_id AS account,
5926
+ 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
5927
+ GROUP BY c.id`).all();
5928
+ for (const row of held) {
5929
+ const chat = Number(row.id);
5930
+ const top = Number(row.top);
5931
+ 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;
5932
+ if (keepTo !== null && top <= keepTo)
5933
+ continue;
5934
+ if (keepTo === null)
5935
+ database.prepare("DELETE FROM sync_ranges WHERE chat_id = ?").run(chat);
5936
+ else {
5937
+ database.prepare("DELETE FROM sync_ranges WHERE chat_id = ? AND from_key > ?").run(chat, keepTo);
5938
+ database.prepare("UPDATE sync_ranges SET to_key = ?, updated_at = ? WHERE chat_id = ? AND to_key > ?").run(keepTo, now, chat, keepTo);
5939
+ }
5940
+ const account = Number(row.account_id);
5941
+ const external = String(row.chat);
5942
+ database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(account, `fetched:${external}`);
5943
+ database.prepare(`DELETE FROM sync_cursors WHERE account_id = ? AND key = ? AND NOT EXISTS
5944
+ (SELECT 1 FROM sync_ranges WHERE chat_id = ? AND from_key <= CAST(sync_cursors.value AS INTEGER))`).run(account, `history_start:${external}`, chat);
5945
+ const key = `${row.provider}\0${row.account}`;
5946
+ const one = chats.get(key) ?? { provider: String(row.provider), account: String(row.account), chats: 0 };
5947
+ one.chats += 1;
5948
+ chats.set(key, one);
5949
+ }
5950
+ return {
5951
+ since: cutoff === null ? null : new Date(cutoff).toISOString(),
5952
+ chats: [...chats.values()],
5953
+ mail: forgetMail(database, cutoff, now)
5954
+ };
5955
+ }, "forget");
5956
+ var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
5957
+ const folders = /* @__PURE__ */ new Map();
5958
+ const points = database.prepare(`SELECT s.account_id, s.key, s.value, a.external_id AS account FROM sync_cursors s
5959
+ JOIN accounts a ON a.id = s.account_id WHERE a.provider = 'email' AND s.key LIKE 'mail_resume:%'`).all();
5960
+ for (const row of points) {
5961
+ let point;
5962
+ try {
5963
+ point = JSON.parse(String(row.value));
5964
+ } catch {
5965
+ continue;
5966
+ }
5967
+ const account = String(row.account);
5968
+ if (!Array.isArray(point.done)) {
5969
+ if (cutoff !== null && Date.parse(point.updatedAt ?? "") < cutoff)
5970
+ continue;
5971
+ database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(Number(row.account_id), String(row.key));
5972
+ folders.set(account, (folders.get(account) ?? 0) + 1);
5973
+ continue;
5974
+ }
5975
+ const folder = String(row.key).slice("mail_resume:".length);
5976
+ 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
5977
+ WHERE l.mailbox_id = (SELECT id FROM mailboxes WHERE account_id = ? AND external_id = ?)
5978
+ AND l.uidvalidity = ? AND coalesce(e.received_at, e.sent_at) < ?`).get(Number(row.account_id), folder, point.validity ?? "", cutoff)?.uid;
5979
+ const done = last === null ? [] : point.done.filter(([from]) => from <= last).map(([from, to]) => [from, Math.min(to, last)]);
5980
+ if (JSON.stringify(done) === JSON.stringify(point.done))
5981
+ continue;
5982
+ 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));
5983
+ folders.set(account, (folders.get(account) ?? 0) + 1);
5984
+ }
5985
+ return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
5986
+ }, "forgetMail");
5987
+
5988
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/store/recover.js
5919
5989
  var SQLITE3_MINIMUM = [3, 43, 0];
5920
5990
  var STORE_PARTS = ["", "-wal", "-shm"];
5921
5991
  var RECOVER_LOCK = ".recover-lock";
@@ -6010,9 +6080,12 @@ var storeHolders = /* @__PURE__ */ __name((path) => {
6010
6080
  return { pid, name };
6011
6081
  });
6012
6082
  }, "storeHolders");
6013
- var tableRows = /* @__PURE__ */ __name((database) => {
6083
+ var dataTables = /* @__PURE__ */ __name((database) => {
6014
6084
  const indexes = fts5Tables(database).map((index) => index.name);
6015
- 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}_`)));
6085
+ 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}_`)));
6086
+ }, "dataTables");
6087
+ var tableRows = /* @__PURE__ */ __name((database) => {
6088
+ const tables = dataTables(database);
6016
6089
  return Object.fromEntries(tables.map((table) => {
6017
6090
  try {
6018
6091
  return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
@@ -6021,6 +6094,117 @@ var tableRows = /* @__PURE__ */ __name((database) => {
6021
6094
  }
6022
6095
  }));
6023
6096
  }, "tableRows");
6097
+ var sourceTables = /* @__PURE__ */ __name((database) => {
6098
+ const withoutRowid = new Set(database.prepare("SELECT name FROM pragma_table_list WHERE wr = 1").all().map((row) => String(row.name)));
6099
+ return dataTables(database).filter((table) => table !== LOST_AND_FOUND && !withoutRowid.has(table) && !isDerivedTable(table));
6100
+ }, "sourceTables");
6101
+ var indexedButGone = /* @__PURE__ */ __name((database) => {
6102
+ const found = {};
6103
+ for (const table of sourceTables(database)) {
6104
+ const indexes = database.prepare("SELECT name FROM pragma_index_list(?) WHERE partial = 0 ORDER BY name").all(table).map((row) => String(row.name));
6105
+ for (const index of indexes) {
6106
+ const columns = database.prepare("SELECT cid, name FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno").all(index);
6107
+ if (columns.some((column) => Number(column.cid) < 0))
6108
+ continue;
6109
+ const keys = columns.map((column) => `"${String(column.name)}"`).join(", ");
6110
+ const grouped = `${keys}, row_id`;
6111
+ let rows;
6112
+ try {
6113
+ 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);
6114
+ } catch {
6115
+ continue;
6116
+ }
6117
+ if (rows > (found[table]?.rows ?? 0))
6118
+ found[table] = { rows, index };
6119
+ }
6120
+ }
6121
+ return found;
6122
+ }, "indexedButGone");
6123
+ var storedAs = /* @__PURE__ */ __name((declared) => {
6124
+ const type = declared.toUpperCase();
6125
+ if (type.includes("INT"))
6126
+ return ["integer"];
6127
+ if (/CHAR|CLOB|TEXT/.test(type))
6128
+ return ["text"];
6129
+ if (type === "" || type.includes("BLOB"))
6130
+ return null;
6131
+ if (/REAL|FLOA|DOUB/.test(type))
6132
+ return ["real", "integer"];
6133
+ return null;
6134
+ }, "storedAs");
6135
+ var columnsOf = /* @__PURE__ */ __name((database, table) => {
6136
+ const all = database.prepare('SELECT name, type, "notnull" AS required, dflt_value, pk FROM pragma_table_info(?)').all(table);
6137
+ const keys = all.filter((column) => Number(column.pk) > 0);
6138
+ return all.map((column) => ({
6139
+ name: String(column.name),
6140
+ type: String(column.type),
6141
+ required: Number(column.required) === 1,
6142
+ hasDefault: column.dflt_value !== null,
6143
+ rowid: keys.length === 1 && Number(column.pk) === 1 && String(column.type).toUpperCase() === "INTEGER"
6144
+ }));
6145
+ }, "columnsOf");
6146
+ var fits = /* @__PURE__ */ __name((columns, fields, types) => fields <= columns.length && columns.every((column, at) => {
6147
+ if (at >= fields)
6148
+ return !column.required || column.hasDefault;
6149
+ const type = types[at];
6150
+ if (column.rowid)
6151
+ return type === "null" || type === "integer";
6152
+ if (type === "null")
6153
+ return !column.required;
6154
+ const allowed = storedAs(column.type);
6155
+ return allowed === null || allowed.includes(type);
6156
+ }), "fits");
6157
+ var placeLostRows = /* @__PURE__ */ __name((database) => {
6158
+ if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND))
6159
+ return {};
6160
+ 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));
6161
+ const tables = sourceTables(database).map((table) => ({ table, columns: columnsOf(database, table) }));
6162
+ 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();
6163
+ const placed = {};
6164
+ const triggers = [];
6165
+ const quiet = /* @__PURE__ */ __name((table) => {
6166
+ if (table in placed)
6167
+ return;
6168
+ placed[table] = 0;
6169
+ for (const row of database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?").all(table)) {
6170
+ triggers.push(String(row.sql));
6171
+ database.exec(`DROP TRIGGER "${String(row.name)}"`);
6172
+ }
6173
+ }, "quiet");
6174
+ database.exec("PRAGMA foreign_keys = OFF");
6175
+ database.exec("BEGIN");
6176
+ try {
6177
+ for (const row of rows) {
6178
+ const count3 = Number(row.nfield);
6179
+ const types = fields.slice(0, count3).map((field) => String(row[field]));
6180
+ const fitting = tables.filter(({ columns: columns2 }) => fits(columns2, count3, types));
6181
+ if (fitting.length !== 1)
6182
+ continue;
6183
+ const { table, columns } = fitting[0];
6184
+ quiet(table);
6185
+ const given = columns.slice(0, count3);
6186
+ const names = [...given.some((column) => column.rowid) ? [] : ["rowid"], ...given.map((column) => column.name)];
6187
+ const values = [
6188
+ ...given.some((column) => column.rowid) ? [] : ["id"],
6189
+ ...given.map((column, at) => column.rowid ? "id" : `c${at}`)
6190
+ ];
6191
+ 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));
6192
+ if (Number(inserted.changes) === 0)
6193
+ continue;
6194
+ placed[table] = (placed[table] ?? 0) + 1;
6195
+ database.prepare(`DELETE FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
6196
+ }
6197
+ for (const sql of triggers)
6198
+ database.exec(sql);
6199
+ database.exec("COMMIT");
6200
+ } catch (error) {
6201
+ database.exec("ROLLBACK");
6202
+ throw error;
6203
+ } finally {
6204
+ database.exec("PRAGMA foreign_keys = ON");
6205
+ }
6206
+ return Object.fromEntries(Object.entries(placed).filter(([, rows2]) => rows2 > 0));
6207
+ }, "placeLostRows");
6024
6208
  var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
6025
6209
  const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
6026
6210
  stdio: ["ignore", "pipe", "pipe"]
@@ -6217,6 +6401,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6217
6401
  throw error;
6218
6402
  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" });
6219
6403
  }
6404
+ note("looking for rows the indexes list and the tables no longer hold");
6405
+ const gone = indexedButGone(watch);
6406
+ const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
6220
6407
  const before = { data: dataVersion(), inode: statSync2(path).ino };
6221
6408
  const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
6222
6409
  const target = `${path}.recovering-${stamp}`;
@@ -6243,9 +6430,12 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6243
6430
  let kept;
6244
6431
  let dangling;
6245
6432
  let json;
6246
- let fetch2;
6433
+ let fetch;
6247
6434
  let schema;
6435
+ let placed;
6436
+ let refetch;
6248
6437
  try {
6438
+ placed = placeLostRows(opened.database);
6249
6439
  kept = tableRows(opened.database);
6250
6440
  migrate(opened.database, { command, ...version ? { version } : {} });
6251
6441
  note("clearing values that are not valid JSON");
@@ -6253,7 +6443,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6253
6443
  rebuilt = rebuildDerived(opened.database, { now, note });
6254
6444
  note("looking for rows that point at rows that were lost");
6255
6445
  dangling = danglingRows(opened.database);
6256
- fetch2 = mailToFetch(opened.database);
6446
+ fetch = mailToFetch(opened.database);
6447
+ const good = lastKnownGood === null ? Number.NaN : Date.parse(lastKnownGood);
6448
+ refetch = forgetCoverageSince(opened.database, Number.isNaN(good) ? null : good - REFILL_MARGIN_MS, now());
6257
6449
  schema = fileSchemaOf(opened.database).version;
6258
6450
  opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
6259
6451
  } catch (error) {
@@ -6283,16 +6475,29 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6283
6475
  if (existsSync2(`${target}${suffix}`))
6284
6476
  renameSync2(`${target}${suffix}`, `${path}${suffix}`);
6285
6477
  recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
6286
- 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);
6478
+ const lost = Object.entries(rowsBefore).map(([table, before2]) => {
6479
+ const goneAtLeast = Math.max(0, (gone[table]?.rows ?? 0) - (placed[table] ?? 0));
6480
+ return {
6481
+ table,
6482
+ before: before2,
6483
+ read: read[table] ?? 0,
6484
+ kept: kept[table] ?? 0,
6485
+ goneAtLeast,
6486
+ seenIn: goneAtLeast > 0 ? gone[table]?.index ?? null : null
6487
+ };
6488
+ }).filter(({ before: before2, read: read2, kept: kept2, goneAtLeast }) => before2 === null || before2 > kept2 || read2 > kept2 || goneAtLeast > 0);
6287
6489
  const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
6288
6490
  return {
6289
6491
  path,
6290
6492
  keptAt,
6291
6493
  sqlite3: program.version,
6292
6494
  lost,
6495
+ placed,
6496
+ lastKnownGood,
6293
6497
  dangling,
6294
6498
  invalidJson: json,
6295
- mailToFetch: fetch2,
6499
+ mailToFetch: fetch,
6500
+ refetch,
6296
6501
  rebuilt,
6297
6502
  copyErrors,
6298
6503
  health,
@@ -6308,7 +6513,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6308
6513
  }
6309
6514
  }, "recoverLocked");
6310
6515
 
6311
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
6516
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
6312
6517
  var COUNTED = [
6313
6518
  "accounts",
6314
6519
  "chats",
@@ -6395,12 +6600,28 @@ var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, no
6395
6600
  next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
6396
6601
  };
6397
6602
  }, "storeRecoveryRun");
6603
+ var refetchNotes = /* @__PURE__ */ __name(({ since, chats, mail }) => {
6604
+ const from = since === null ? "from the start" : `from ${since} on`;
6605
+ const marked = [
6606
+ ...chats.map(({ provider, account, chats: chats2 }) => `${chats2} chats of ${provider} ${account}`),
6607
+ ...mail.map(({ account, folders }) => `${folders} mail folders of ${account}`)
6608
+ ];
6609
+ return [
6610
+ 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`,
6611
+ ...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`),
6612
+ "notes, memories, tags and whatever else only this store held cannot be fetched again"
6613
+ ];
6614
+ }, "refetchNotes");
6398
6615
  var recoveryNotes = /* @__PURE__ */ __name((answer) => {
6399
6616
  if ("keptAt" in answer) {
6400
- const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
6617
+ 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)` : ""));
6618
+ const since = answer.lastKnownGood ? `since the last deep check that passed (${answer.lastKnownGood})` : "since the store was made (no deep check that passed is on record)";
6401
6619
  return [
6402
6620
  `recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
6403
- ...lost.length ? lost : ["no table lost a row"],
6621
+ ...lost,
6622
+ ...Object.entries(answer.placed).map(([table, rows]) => `${table}: ${rows} rows found on pages no table claimed were put back`),
6623
+ ...refetchNotes(answer.refetch),
6624
+ `${lost.some((line) => line.includes("are gone")) ? "more rows may be gone" : "how many rows were lost is unknown"}: damage can take rows written ${since} without leaving a trace; a sync fetches again what the servers still hold`,
6404
6625
  ...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
6405
6626
  ...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
6406
6627
  ...answer.next.map((line) => `next: ${line}`)
@@ -6441,7 +6662,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
6441
6662
  return recover;
6442
6663
  }, "storeRecoverCommand");
6443
6664
 
6444
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/store-info.js
6665
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
6445
6666
  var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
6446
6667
  var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
6447
6668
  var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
@@ -6487,7 +6708,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
6487
6708
  renderAnswer(this, outputFor(this), itemOf(answer));
6488
6709
  }), "storeInfoCommand");
6489
6710
 
6490
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
6711
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
6491
6712
  var ENCRYPT_OPTION = [
6492
6713
  "--encrypt",
6493
6714
  "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"
@@ -6506,7 +6727,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
6506
6727
  return password;
6507
6728
  }, "passwordOf");
6508
6729
 
6509
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/rules.js
6730
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/rules.js
6510
6731
  import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
6511
6732
  import { join as join2 } from "node:path";
6512
6733
  var REPLY_ACTIONS = ["reply", "task"];
@@ -6677,7 +6898,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
6677
6898
  }, "problem");
6678
6899
  var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
6679
6900
 
6680
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/state.js
6901
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/state.js
6681
6902
  import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
6682
6903
  import { join as join3 } from "node:path";
6683
6904
  var ANSWERED_KEPT = 1e3;
@@ -6730,7 +6951,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
6730
6951
  }, "recordReply");
6731
6952
  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");
6732
6953
 
6733
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/decide.js
6954
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/decide.js
6734
6955
  var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
6735
6956
  var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
6736
6957
  const { message, chat, owner, sender } = incoming;
@@ -6836,8 +7057,37 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
6836
7057
  return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
6837
7058
  }, "filled");
6838
7059
 
6839
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/template.js
7060
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/template.js
7061
+ var import_liquidjs2 = __toESM(require_liquid_node(), 1);
7062
+
7063
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/render/liquid.js
6840
7064
  var import_liquidjs = __toESM(require_liquid_node(), 1);
7065
+ var safeLiquid = /* @__PURE__ */ __name((limits) => {
7066
+ const engine = new import_liquidjs.Liquid({
7067
+ ownPropertyOnly: true,
7068
+ strictVariables: true,
7069
+ strictFilters: true,
7070
+ lenientIf: false,
7071
+ parseLimit: limits.parse,
7072
+ renderLimit: limits.milliseconds,
7073
+ memoryLimit: limits.memory,
7074
+ preserveTimezones: true
7075
+ });
7076
+ for (const name of ["include", "render", "layout"]) {
7077
+ engine.registerTag(name, class extends import_liquidjs.Tag {
7078
+ constructor(token, tokens, liquid) {
7079
+ super(token, tokens, liquid);
7080
+ throw new Error("templates cannot read files");
7081
+ }
7082
+ render() {
7083
+ return "";
7084
+ }
7085
+ });
7086
+ }
7087
+ return engine;
7088
+ }, "safeLiquid");
7089
+
7090
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/template.js
6841
7091
  var TEMPLATE_LIMITS = {
6842
7092
  parse: 32768,
6843
7093
  renders: 2e3,
@@ -6891,28 +7141,8 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
6891
7141
  hourCycle: "h23"
6892
7142
  }).formatToParts(input.now).map(({ type, value }) => [type, value]));
6893
7143
  const localTime = `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}${parts.timeZoneName?.replace("GMT", "") || "+00:00"}`;
6894
- const engine = new import_liquidjs.Liquid({
6895
- ownPropertyOnly: true,
6896
- strictVariables: true,
6897
- strictFilters: true,
6898
- lenientIf: false,
6899
- parseLimit: limits.parse,
6900
- renderLimit: limits.milliseconds,
6901
- memoryLimit: limits.memory,
6902
- preserveTimezones: true
6903
- });
6904
- for (const name2 of ["include", "render", "layout"]) {
6905
- engine.registerTag(name2, class extends import_liquidjs.Tag {
6906
- constructor(token, tokens, liquid) {
6907
- super(token, tokens, liquid);
6908
- throw new Error("reply templates cannot read files");
6909
- }
6910
- render() {
6911
- return "";
6912
- }
6913
- });
6914
- }
6915
- engine.registerTag("ai", class extends import_liquidjs.Tag {
7144
+ const engine = safeLiquid({ parse: limits.parse, memory: limits.memory, milliseconds: limits.milliseconds });
7145
+ engine.registerTag("ai", class extends import_liquidjs2.Tag {
6916
7146
  body = [];
6917
7147
  fallback = null;
6918
7148
  constructor(token, tokens, liquid, parser) {
@@ -6973,7 +7203,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
6973
7203
  });
6974
7204
  const templates = engine.parse(source);
6975
7205
  const name = input.senderName?.trim() ?? "";
6976
- const context = new import_liquidjs.Context({
7206
+ const context = new import_liquidjs2.Context({
6977
7207
  sender: { firstName: name.split(/\s+/)[0] ?? "", name },
6978
7208
  chat: { title: input.chat.title ?? "", kind: input.chat.kind },
6979
7209
  now: localTime
@@ -6996,7 +7226,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
6996
7226
  }
6997
7227
  }, "renderReplyTemplate");
6998
7228
 
6999
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
7229
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
7000
7230
  var DRY_RUN_DAYS = 7;
7001
7231
  var PAGE = 500;
7002
7232
  var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
@@ -7110,143 +7340,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
7110
7340
  }
7111
7341
  }, "storedSince");
7112
7342
 
7113
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/embeddings/keys.js
7114
- var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
7115
- const host = new URL(baseUrl).host;
7116
- return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
7117
- }, "endpointKeyName");
7118
- var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) => {
7119
- const where = { appName: app.appName, prefix: app.envPrefix, env };
7120
- const credentials = /* @__PURE__ */ __name((provider) => new Credentials({
7121
- configDir: resolvePaths(where).config,
7122
- service: app.appName,
7123
- ...["openai", "anthropic"].includes(provider) ? { envVar: envName(app, `${provider.toUpperCase()}_API_KEY`) } : {},
7124
- isolated: pathsAreOverridden(where),
7125
- env,
7126
- ...keyring ? { keyring } : {},
7127
- warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
7128
- `), "warn")
7129
- }), "credentials");
7130
- const account = /* @__PURE__ */ __name((provider) => `embeddings:${provider}`, "account");
7131
- return {
7132
- read: /* @__PURE__ */ __name((provider) => {
7133
- const stored = credentials(provider).read(account(provider));
7134
- if (stored)
7135
- return { key: stored.secret, source: stored.source };
7136
- const shared = ["openai", "anthropic"].includes(provider) ? env[`${provider.toUpperCase()}_API_KEY`]?.trim() : void 0;
7137
- return shared ? { key: shared, source: "env" } : void 0;
7138
- }, "read"),
7139
- write: /* @__PURE__ */ __name((provider, key) => credentials(provider).write(account(provider), key, { signIn: true }), "write"),
7140
- remove: /* @__PURE__ */ __name((provider) => credentials(provider).remove(account(provider)), "remove")
7141
- };
7142
- }, "embeddingKeys");
7143
-
7144
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/models/openai.js
7145
- var options = strictObject({
7146
- temperature: range(0, 2),
7147
- top_p: range(0, 1),
7148
- presence_penalty: range(-2, 2),
7149
- frequency_penalty: range(-2, 2),
7150
- seed: optional(pipe(number(), integer())),
7151
- stop: optional(union([string(), array(string())])),
7152
- response_format: optional(strictObject({ type: picklist(["text", "json_object"]) }))
7153
- });
7154
- var openai = {
7155
- images: true,
7156
- baseUrl: "https://api.openai.com/v1",
7157
- validate: /* @__PURE__ */ __name((given) => checkedOptions("openai", options, given), "validate"),
7158
- complete: /* @__PURE__ */ __name((target, request, checked, apiKey, fetcher) => withTimeLimit(12e4, async (deadline) => {
7159
- const response = await fetcher(`${target.baseUrl.replace(/\/+$/, "")}/chat/completions`, {
7160
- method: "POST",
7161
- headers: { "Content-Type": "application/json", ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {} },
7162
- body: JSON.stringify({
7163
- ...checked,
7164
- model: target.model,
7165
- messages: [
7166
- { role: "system", content: systemFor(request) },
7167
- ...messagesFor(request),
7168
- ...request.images === void 0 ? [] : [
7169
- {
7170
- role: "user",
7171
- content: request.images.map((image) => ({
7172
- type: "image_url",
7173
- image_url: { url: `data:${image.mimeType};base64,${image.data}`, detail: "high" }
7174
- }))
7175
- }
7176
- ]
7177
- ],
7178
- ...new URL(target.baseUrl).hostname === "api.openai.com" ? { max_completion_tokens: request.maxTokens } : { max_tokens: request.maxTokens }
7179
- }),
7180
- signal: deadline,
7181
- redirect: "error"
7182
- });
7183
- if (!response.ok)
7184
- throw new Error("provider rejected request");
7185
- const body = await response.json();
7186
- const choice = body.choices?.[0];
7187
- if (choice?.finish_reason !== "stop" || typeof choice.message?.content !== "string" || !Number.isInteger(body.usage?.total_tokens) || (body.usage?.total_tokens ?? 0) < 1)
7188
- throw new Error("incomplete response");
7189
- return { text: choice.message.content, tokens: body.usage?.total_tokens };
7190
- }), "complete")
7191
- };
7192
-
7193
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/models/index.js
7194
- var modelGateway = /* @__PURE__ */ __name((deps) => ({
7195
- complete: /* @__PURE__ */ __name(async (request) => {
7196
- if (deps.signal?.aborted)
7197
- throw new CliError("cancelled", "model request cancelled");
7198
- const target = deps.resolve(request.purpose);
7199
- if (!target || target.provider === "off")
7200
- throw new CliError("configuration_error", `models.${request.purpose}.provider is not configured; no model was called`);
7201
- if (!request.purpose || !Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1 || typeof request.prompt !== "string")
7202
- throw new CliError("validation_error", "a model request needs a purpose, prompt and positive whole maxTokens");
7203
- validateImages(request.images);
7204
- let adapter = deps.adapters?.[target.provider];
7205
- if (!adapter && target.provider === "openai")
7206
- adapter = openai;
7207
- if (!adapter && target.provider === "anthropic")
7208
- adapter = (await import("./anthropic-YJAEQSNT.js")).anthropic;
7209
- if (!adapter)
7210
- throw new CliError("validation_error", `no model adapter for ${target.provider}`);
7211
- if (request.images !== void 0 && adapter.images !== true)
7212
- throw new CliError("validation_error", "the model adapter does not support image inputs");
7213
- const options2 = adapter.validate(request.options ?? {});
7214
- const baseUrl = target.baseUrl ?? adapter.baseUrl;
7215
- if (!target.model.trim() || !endpoint(baseUrl))
7216
- throw new CliError("validation_error", "a model target needs a model and an HTTP/S endpoint without credentials, query or fragment");
7217
- if (!await deps.consent(request, { ...target, baseUrl }))
7218
- throw new CliError("permission_error", `model consent for ${request.purpose} is missing; no data was sent`);
7219
- const apiKey = await deps.key?.(target.provider, target);
7220
- if (deps.signal?.aborted)
7221
- throw new CliError("cancelled", "model request cancelled");
7222
- const fetcher = deps.fetch ?? fetch;
7223
- let limited = false;
7224
- const cancellable = /* @__PURE__ */ __name(async (input, init) => {
7225
- const signal = init?.signal ?? (input instanceof Request ? input.signal : void 0);
7226
- const response = await fetcher(input, {
7227
- ...init,
7228
- signal: deps.signal ? AbortSignal.any([deps.signal, ...signal ? [signal] : []]) : signal
7229
- });
7230
- if (response.status === 429)
7231
- limited = true;
7232
- return response;
7233
- }, "cancellable");
7234
- try {
7235
- const answer = await adapter.complete({ ...target, baseUrl }, request, options2, apiKey, cancellable);
7236
- if (deps.signal?.aborted)
7237
- throw new Error("cancelled");
7238
- if (typeof answer.text !== "string" || !Number.isSafeInteger(answer.tokens) || answer.tokens < 1)
7239
- throw new Error("incomplete");
7240
- return { ...answer, provider: target.provider, model: target.model };
7241
- } catch {
7242
- if (limited)
7243
- throw new CliError("rate_limited", `${request.purpose} provider rate limit reached; no result was stored`);
7244
- throw new CliError("invalid_response", `${request.purpose} provider failed or returned an incomplete response; no result was stored`);
7245
- }
7246
- }, "complete")
7247
- }), "modelGateway");
7248
-
7249
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/consents.js
7343
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/consents.js
7250
7344
  import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
7251
7345
  import { join as join4 } from "node:path";
7252
7346
  var shape = strictObject({
@@ -7271,21 +7365,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
7271
7365
  return consent.provider === provider && !consent.deniedChats.includes(chat);
7272
7366
  }, "mayModelReply");
7273
7367
 
7274
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/rendering.js
7275
- var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options2 = {
7368
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/rendering.js
7369
+ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
7276
7370
  ai: true
7277
7371
  }) => async (rule2, message, chat, now) => {
7278
7372
  let called;
7279
7373
  const gateway = modelGateway({
7280
- signal: options2.signal,
7374
+ signal: options.signal,
7281
7375
  resolve: /* @__PURE__ */ __name((purpose) => {
7282
7376
  called = modelTarget(settings(), purpose);
7283
7377
  return called;
7284
7378
  }, "resolve"),
7285
7379
  consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
7286
- key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env, options2.keyring).read(target.baseUrl === void 0 ? provider : endpointKeyName(target.baseUrl))?.key, "key")
7380
+ key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env, options.keyring).read(target.baseUrl === void 0 ? provider : endpointKeyName(target.baseUrl))?.key, "key")
7287
7381
  });
7288
- if (options2.signal?.aborted)
7382
+ if (options.signal?.aborted)
7289
7383
  throw new CliError("cancelled", "reply rendering cancelled");
7290
7384
  const result2 = await renderReplyTemplate(rule2.reply, {
7291
7385
  senderName: message.senderName,
@@ -7293,8 +7387,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
7293
7387
  now,
7294
7388
  timezone: rule2.when.hours?.timezone,
7295
7389
  data: message.text,
7296
- allowAI: options2.ai === true,
7297
- preview: options2.preview === true,
7390
+ allowAI: options.ai === true,
7391
+ preview: options.preview === true,
7298
7392
  complete: /* @__PURE__ */ __name(async (prompt, data) => {
7299
7393
  const result3 = await gateway.complete({
7300
7394
  purpose: "replies",
@@ -7303,7 +7397,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
7303
7397
  data,
7304
7398
  maxTokens: 512
7305
7399
  });
7306
- if (options2.signal?.aborted)
7400
+ if (options.signal?.aborted)
7307
7401
  throw new CliError("cancelled", "reply rendering cancelled");
7308
7402
  const current = modelTarget(settings(), "replies");
7309
7403
  const baseUrl = called?.baseUrl ?? (called?.provider === "anthropic" ? "https://api.anthropic.com" : "https://api.openai.com/v1");
@@ -7318,7 +7412,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
7318
7412
  return result2;
7319
7413
  }, "replyRenderer");
7320
7414
 
7321
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/replies/serve.js
7415
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/replies/serve.js
7322
7416
  var NOT_ALLOWED = "replies.send is not allow";
7323
7417
  var NO_RULES = "no rules";
7324
7418
  var ONLY_TASK = "opened a task, sent nothing";
@@ -7411,12 +7505,12 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
7411
7505
  return { skip: why };
7412
7506
  }, "replyTo");
7413
7507
 
7414
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
7508
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
7415
7509
  var START_SYNC_DELAY_MS = 3e4;
7416
7510
  var START_SYNC_BUDGET_MS = 5 * 6e4;
7417
7511
  var START_SYNC_WINDOW_MS = 7 * 864e5;
7418
7512
  var START_SYNC_PER_CHAT = 500;
7419
- var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note, warn, delayMs = START_SYNC_DELAY_MS, budgetMs = START_SYNC_BUDGET_MS, windowMs = START_SYNC_WINDOW_MS, now = Date.now }) => {
7513
+ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn, delayMs = START_SYNC_DELAY_MS, budgetMs = START_SYNC_BUDGET_MS, windowMs = START_SYNC_WINDOW_MS, now = Date.now }) => {
7420
7514
  const controller = new AbortController();
7421
7515
  let timer;
7422
7516
  let pass = Promise.resolve();
@@ -7444,7 +7538,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
7444
7538
  if (stop.aborted)
7445
7539
  break;
7446
7540
  try {
7447
- summary.fetched += (await fetch2(chat.id, Math.max(held ?? anywhere, floor), stop)).fetched;
7541
+ summary.fetched += (await fetch(chat.id, Math.max(held ?? anywhere, floor), stop)).fetched;
7448
7542
  summary.chats += 1;
7449
7543
  } catch (error) {
7450
7544
  if (stop.aborted)
@@ -7488,10 +7582,10 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
7488
7582
  };
7489
7583
  }, "startSync");
7490
7584
 
7491
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
7585
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
7492
7586
  var FIRST_FETCH_MS = 6e4;
7493
7587
  var DAY_MS = 864e5;
7494
- var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
7588
+ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
7495
7589
  let timer;
7496
7590
  let round = Promise.resolve();
7497
7591
  let stopped = false;
@@ -7504,7 +7598,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
7504
7598
  if (lastCount?.day === today)
7505
7599
  continue;
7506
7600
  try {
7507
- await fetch2(store, account, chatId);
7601
+ await fetch(store, account, chatId);
7508
7602
  done.fetched += 1;
7509
7603
  } catch (error) {
7510
7604
  done.failed += 1;
@@ -7542,7 +7636,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
7542
7636
  };
7543
7637
  }, "memberFetches");
7544
7638
 
7545
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
7639
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
7546
7640
  var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
7547
7641
  var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
7548
7642
  if (context.format === "pretty") {
@@ -7575,7 +7669,93 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
7575
7669
  return context;
7576
7670
  }, "recordDiagnostics");
7577
7671
 
7578
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7672
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
7673
+ import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
7674
+ import { dirname as dirname2, join as join5 } from "node:path";
7675
+ var OUTDATED_CHECK_MS = 6e4;
7676
+ var ownPackageRoot = /* @__PURE__ */ __name((running, script = process.argv[1]) => {
7677
+ let dir;
7678
+ try {
7679
+ dir = dirname2(realpathSync2(script ?? ""));
7680
+ } catch {
7681
+ return void 0;
7682
+ }
7683
+ for (let up = 0; up < 8; up++) {
7684
+ const manifest = join5(dir, "package.json");
7685
+ if (existsSync8(manifest))
7686
+ return installedVersion(dir) === running ? dir : void 0;
7687
+ const parent = dirname2(dir);
7688
+ if (parent === dir)
7689
+ return void 0;
7690
+ dir = parent;
7691
+ }
7692
+ return void 0;
7693
+ }, "ownPackageRoot");
7694
+ var installedVersion = /* @__PURE__ */ __name((root) => {
7695
+ try {
7696
+ const { version } = JSON.parse(readFileSync5(join5(root, "package.json"), "utf8"));
7697
+ return typeof version === "string" ? version : void 0;
7698
+ } catch {
7699
+ return void 0;
7700
+ }
7701
+ }, "installedVersion");
7702
+ var newer = /* @__PURE__ */ __name((one, other) => {
7703
+ const parts = /* @__PURE__ */ __name((version) => version.split(/[.+-]/, 3).map(Number), "parts");
7704
+ const [a, b] = [parts(one), parts(other)];
7705
+ for (let i = 0; i < 3; i++)
7706
+ if ((a[i] ?? 0) !== (b[i] ?? 0))
7707
+ return (a[i] ?? 0) > (b[i] ?? 0);
7708
+ return false;
7709
+ }, "newer");
7710
+ var outdatedReason = /* @__PURE__ */ __name(async ({ command, running, storePath: storePath2, packageRoot, speaks = SPEAKS }) => {
7711
+ const installed = packageRoot === void 0 ? void 0 : installedVersion(packageRoot);
7712
+ if (installed !== void 0 && newer(installed, running))
7713
+ return `${command} ${installed} is installed and this serve runs ${running}: stopping so it starts again on ${installed}`;
7714
+ if (!existsSync8(storePath2))
7715
+ return void 0;
7716
+ let schema;
7717
+ try {
7718
+ const { database } = await openSqlite(storePath2, { readOnly: true });
7719
+ try {
7720
+ schema = fileSchemaOf(database);
7721
+ } finally {
7722
+ database.close();
7723
+ }
7724
+ } catch {
7725
+ return void 0;
7726
+ }
7727
+ if (writableBy(schema, speaks))
7728
+ return void 0;
7729
+ 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`;
7730
+ }, "outdatedReason");
7731
+ var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs = OUTDATED_CHECK_MS }) => {
7732
+ let busy = false;
7733
+ let done = false;
7734
+ const timer = setInterval(() => {
7735
+ if (busy || done)
7736
+ return;
7737
+ busy = true;
7738
+ check2().then((reason) => {
7739
+ if (reason === void 0 || done)
7740
+ return;
7741
+ done = true;
7742
+ clearInterval(timer);
7743
+ onOutdated(reason);
7744
+ }).catch(() => {
7745
+ }).finally(() => {
7746
+ busy = false;
7747
+ });
7748
+ }, everyMs);
7749
+ timer.unref();
7750
+ return {
7751
+ stop: /* @__PURE__ */ __name(() => {
7752
+ done = true;
7753
+ clearInterval(timer);
7754
+ }, "stop")
7755
+ };
7756
+ }, "watchOutdated");
7757
+
7758
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7579
7759
  var STEMS_EVERY_MS = 3e4;
7580
7760
  var STEMS_SLICE_MS = 2e3;
7581
7761
  var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
@@ -7615,7 +7795,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
7615
7795
  };
7616
7796
  }, "stemFills");
7617
7797
 
7618
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7798
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7619
7799
  var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
7620
7800
  var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
7621
7801
  kind: attachment.kind,
@@ -7710,7 +7890,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
7710
7890
  locale: messenger.app.locale
7711
7891
  }), "viewOf");
7712
7892
 
7713
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7893
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7714
7894
  var observed = /* @__PURE__ */ __name((value) => ({
7715
7895
  value: value.value,
7716
7896
  observed_at: value.observedAt,
@@ -7777,7 +7957,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
7777
7957
  }
7778
7958
  }, "watchEventItem");
7779
7959
 
7780
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7960
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7781
7961
  var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
7782
7962
  output: { entity: "watch_item" },
7783
7963
  effects: REMOTE_READ,
@@ -7932,7 +8112,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
7932
8112
  }
7933
8113
  }, "describe");
7934
8114
 
7935
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
8115
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
7936
8116
  var serveCommand = /* @__PURE__ */ __name((messenger) => {
7937
8117
  const command = annotate(new Command("serve"), {
7938
8118
  output: { entity: "serve_summary" },
@@ -7956,8 +8136,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7956
8136
  }
7957
8137
  let relaying;
7958
8138
  const onReady = /* @__PURE__ */ __name(() => {
7959
- const listening = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
7960
- holdLock(path, listening);
8139
+ const listening2 = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
8140
+ holdLock(path, listening2);
7961
8141
  note({
7962
8142
  code: "listening",
7963
8143
  text: `listening for profile ${context.profile}, catching up on what arrived while it was down`
@@ -7966,7 +8146,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7966
8146
  return;
7967
8147
  relaying = relay.open(path, context.profile).then((address) => {
7968
8148
  if (address)
7969
- holdLock(path, { ...listening, relay: address });
8149
+ holdLock(path, { ...listening2, relay: address });
7970
8150
  }).catch((error) => {
7971
8151
  const errorCode = failureKey(error);
7972
8152
  warn({ code: "relay_failed", errorCode, text: `commands cannot run through this serve: ${errorCode}` });
@@ -7975,7 +8155,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7975
8155
  const counts = {};
7976
8156
  const rules = replying(context, messenger, Date.parse(startedAt));
7977
8157
  const tasks = tasking(context, warn);
7978
- const { handled, startSyncDelayMs } = environmentOf(this);
8158
+ const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
7979
8159
  const count3 = /* @__PURE__ */ __name((event) => {
7980
8160
  counts[event.event] = (counts[event.event] ?? 0) + 1;
7981
8161
  if (event.event === "message") {
@@ -8047,9 +8227,25 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
8047
8227
  withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
8048
8228
  warn
8049
8229
  });
8230
+ const listening = new AbortController();
8231
+ let outdated;
8232
+ const packageRoot = outdatedHook?.packageRoot ?? ownPackageRoot(version);
8233
+ const watch = watchOutdated({
8234
+ check: /* @__PURE__ */ __name(() => outdatedReason({
8235
+ command: messenger.app.command,
8236
+ running: version,
8237
+ storePath: storePath(context.env),
8238
+ packageRoot
8239
+ }), "check"),
8240
+ onOutdated: /* @__PURE__ */ __name((reason) => {
8241
+ outdated = reason;
8242
+ listening.abort();
8243
+ }, "onOutdated"),
8244
+ ...outdatedHook?.everyMs === void 0 ? {} : { everyMs: outdatedHook.everyMs }
8245
+ });
8050
8246
  try {
8051
8247
  await listenUntilStopped(this, context, relay?.messenger ?? messenger, count3, {
8052
- stop: new AbortController(),
8248
+ stop: listening,
8053
8249
  catchUp: true,
8054
8250
  onReady,
8055
8251
  connected: /* @__PURE__ */ __name((open) => {
@@ -8062,6 +8258,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
8062
8258
  }, "connected")
8063
8259
  });
8064
8260
  } finally {
8261
+ watch.stop();
8065
8262
  await relaying;
8066
8263
  await relay?.close();
8067
8264
  rules.stop();
@@ -8072,6 +8269,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
8072
8269
  await tasks.settled();
8073
8270
  releaseLock(path);
8074
8271
  }
8272
+ if (outdated !== void 0)
8273
+ throw new CliError("configuration_error", outdated, { reason: "serve.outdated" });
8075
8274
  renderAnswer(this, context, itemOf({
8076
8275
  profile: context.profile,
8077
8276
  started_at: startedAt,
@@ -8196,8 +8395,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
8196
8395
  };
8197
8396
  }, "tasking");
8198
8397
 
8199
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
8200
- import { existsSync as existsSync8 } from "node:fs";
8398
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
8399
+ import { existsSync as existsSync9 } from "node:fs";
8201
8400
  var PATH = "store tables list";
8202
8401
  var STORE_TABLES_QUERY = {
8203
8402
  entity: "store_table",
@@ -8226,7 +8425,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
8226
8425
  const filter = filterOf(words);
8227
8426
  const { full } = this.optsWithGlobals();
8228
8427
  const path = storePath(environmentOf(this).env ?? process.env);
8229
- if (!existsSync8(path))
8428
+ if (!existsSync9(path))
8230
8429
  throw new CliError("not_found", `no store at ${path}`);
8231
8430
  const items = await readStoreTables(path, { filter, sizes: full === true });
8232
8431
  renderAnswer(this, outputFor(this), listOf(PATH, {
@@ -8239,7 +8438,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
8239
8438
  return tables;
8240
8439
  }, "storeTablesCommand");
8241
8440
 
8242
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
8441
+ // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_89df442a19027064da492ef27322716d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
8243
8442
  var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
8244
8443
  var WORD_INDEX = "message_words";
8245
8444
  var schemaOf = /* @__PURE__ */ __name((database) => {
@@ -8248,7 +8447,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
8248
8447
  }, "schemaOf");
8249
8448
  var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
8250
8449
  var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
8251
- var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync9(path) ? statSync4(path).size : 0, "bytesOf");
8450
+ var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync10(path) ? statSync4(path).size : 0, "bytesOf");
8252
8451
  var reading = /* @__PURE__ */ __name(async (path, read) => {
8253
8452
  const database = await openCache(path);
8254
8453
  try {
@@ -8275,7 +8474,7 @@ var fileSchema = /* @__PURE__ */ __name(async (path) => {
8275
8474
  }, "fileSchema");
8276
8475
  var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
8277
8476
  const path = storePath(env);
8278
- if (!existsSync9(path))
8477
+ if (!existsSync10(path))
8279
8478
  return { path, exists: false };
8280
8479
  const checked = await storeHealth(path, { deep });
8281
8480
  const recorded = deep ? recordDeepCheck(path, checked, {
@@ -8345,7 +8544,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
8345
8544
  const { renderer, format } = outputFor(this);
8346
8545
  const { dryRun: dryRun2 } = this.opts();
8347
8546
  const path = storePath(environmentOf(this).env ?? process.env);
8348
- if (!existsSync9(path)) {
8547
+ if (!existsSync10(path)) {
8349
8548
  result(this, { path, exists: false });
8350
8549
  return;
8351
8550
  }
@@ -8385,7 +8584,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
8385
8584
  }, "notesOf");
8386
8585
  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) {
8387
8586
  const path = storePath(environmentOf(this).env ?? process.env);
8388
- if (!existsSync9(path))
8587
+ if (!existsSync10(path))
8389
8588
  throw new CliError("not_found", `no store at ${path}`);
8390
8589
  const deleted = await reading(path, (database) => deleteCopy(database, name));
8391
8590
  result(this, { path, deleted });
@@ -8393,7 +8592,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
8393
8592
  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() {
8394
8593
  const { renderer } = outputFor(this);
8395
8594
  const path = storePath(environmentOf(this).env ?? process.env);
8396
- if (!existsSync9(path)) {
8595
+ if (!existsSync10(path)) {
8397
8596
  result(this, { path, exists: false, ok: true });
8398
8597
  return;
8399
8598
  }
@@ -8456,7 +8655,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
8456
8655
  ...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
8457
8656
  ]);
8458
8657
  const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
8459
- const { bavail, bsize } = statfsSync2(dirname2(path));
8658
+ const { bavail, bsize } = statfsSync2(dirname3(path));
8460
8659
  const free = Number(bavail) * Number(bsize);
8461
8660
  const behind = schema.version > 0 ? chatsBehind(database) : [];
8462
8661
  const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
@@ -8544,7 +8743,7 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
8544
8743
  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() {
8545
8744
  const { renderer } = outputFor(this);
8546
8745
  const path = storePath(environmentOf(this).env ?? process.env);
8547
- if (!existsSync9(path)) {
8746
+ if (!existsSync10(path)) {
8548
8747
  result(this, { path, exists: false });
8549
8748
  renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
8550
8749
  return;
@@ -8608,7 +8807,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
8608
8807
  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() {
8609
8808
  const { renderer } = outputFor(this);
8610
8809
  const path = storePath(environmentOf(this).env ?? process.env);
8611
- if (!existsSync9(path)) {
8810
+ if (!existsSync10(path)) {
8612
8811
  result(this, { path, exists: false });
8613
8812
  return;
8614
8813
  }
@@ -8650,9 +8849,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
8650
8849
  const { encrypt } = this.opts();
8651
8850
  const path = storePath(environmentOf(this).env ?? process.env);
8652
8851
  const target = resolve(file2);
8653
- if (!existsSync9(path))
8852
+ if (!existsSync10(path))
8654
8853
  throw new CliError("not_found", `no store at ${path} to back up`);
8655
- if (existsSync9(target))
8854
+ if (existsSync10(target))
8656
8855
  throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
8657
8856
  const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
8658
8857
  const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
@@ -8685,11 +8884,11 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
8685
8884
  const { output } = this.opts();
8686
8885
  const from = resolve(file2);
8687
8886
  const to = resolve(output);
8688
- if (!existsSync9(from))
8887
+ if (!existsSync10(from))
8689
8888
  throw new CliError("not_found", `no file at ${from}`);
8690
8889
  if (!isSealed(from))
8691
8890
  throw new CliError("validation_error", `${from} was not written with --encrypt`);
8692
- if (existsSync9(to))
8891
+ if (existsSync10(to))
8693
8892
  throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
8694
8893
  await unsealFile(from, to, await passwordOf(this, { twice: false }));
8695
8894
  result(this, { path: to, from, bytes: bytesOf2(to) });
@@ -8697,13 +8896,13 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
8697
8896
  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) {
8698
8897
  const path = storePath(environmentOf(this).env ?? process.env);
8699
8898
  const given = resolve(file2);
8700
- if (!existsSync9(given))
8899
+ if (!existsSync10(given))
8701
8900
  throw new CliError("not_found", `no file at ${given}`);
8702
8901
  refuseWhileServing(this, messenger);
8703
8902
  if (!isSealed(given))
8704
8903
  return restoreFrom(this, messenger, given, given);
8705
8904
  const opened = `${path}.unsealing-${process.pid}`;
8706
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
8905
+ mkdirSync(dirname3(path), { recursive: true, mode: 448 });
8707
8906
  try {
8708
8907
  await unsealFile(given, opened, await passwordOf(this, { twice: false }));
8709
8908
  await restoreFrom(this, messenger, opened, given);
@@ -8714,26 +8913,26 @@ var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command(
8714
8913
  var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
8715
8914
  const { renderer } = outputFor(command);
8716
8915
  const path = storePath(environmentOf(command).env ?? process.env);
8717
- if (existsSync9(path) && realpathSync2(backup) === realpathSync2(path)) {
8916
+ if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
8718
8917
  throw new CliError("validation_error", `${backup} is the store itself`);
8719
8918
  }
8720
8919
  if (await isRollbackCopy(backup))
8721
8920
  return rollBackFrom(command, messenger, backup);
8722
8921
  const schema = await backupSchema(backup);
8723
8922
  const stamp = stampNow();
8724
- const kept = existsSync9(path) ? `${path}.before-restore-${stamp}` : null;
8923
+ const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
8725
8924
  if (kept) {
8726
8925
  const waitMs = environmentOf(command).storeLockWaitMs;
8727
8926
  await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
8728
8927
  } else
8729
- mkdirSync(dirname2(path), { recursive: true, mode: 448 });
8928
+ mkdirSync(dirname3(path), { recursive: true, mode: 448 });
8730
8929
  const incoming = `${path}.restoring-${stamp}`;
8731
8930
  copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
8732
8931
  chmodSync(incoming, 384);
8733
8932
  if (kept) {
8734
8933
  renameSync3(path, kept);
8735
8934
  for (const suffix of ["-wal", "-shm"])
8736
- if (existsSync9(`${path}${suffix}`))
8935
+ if (existsSync10(`${path}${suffix}`))
8737
8936
  renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
8738
8937
  }
8739
8938
  renameSync3(incoming, path);
@@ -8755,7 +8954,7 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
8755
8954
  var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
8756
8955
  const { renderer } = outputFor(command);
8757
8956
  const path = storePath(environmentOf(command).env ?? process.env);
8758
- if (!existsSync9(path))
8957
+ if (!existsSync10(path))
8759
8958
  throw new CliError("not_found", `no store at ${path} to roll back`);
8760
8959
  const waitMs = environmentOf(command).storeLockWaitMs;
8761
8960
  await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
@@ -8805,7 +9004,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
8805
9004
  var STORE_LOCK_WAIT_MS = 1e3;
8806
9005
  var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
8807
9006
  const { command } = messenger.app;
8808
- const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync9(file2)).map((file2) => realpathSync2(file2));
9007
+ const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
8809
9008
  const holders = holdersOf(files);
8810
9009
  if (holders === void 0) {
8811
9010
  warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
@@ -8831,7 +9030,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
8831
9030
  const { command } = messenger.app;
8832
9031
  const env = environmentOf(this).env ?? process.env;
8833
9032
  const path = storePath(env);
8834
- if (!existsSync9(path)) {
9033
+ if (!existsSync10(path)) {
8835
9034
  result(this, { path, exists: false, reset: false });
8836
9035
  renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
8837
9036
  return;
@@ -8876,8 +9075,8 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
8876
9075
  }), "resetCommand");
8877
9076
  var STORE_PARTS2 = ["", "-wal", "-shm"];
8878
9077
  var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
8879
- const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync9(file2));
8880
- const holders = holdersOf(files.map((file2) => realpathSync2(file2)));
9078
+ const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
9079
+ const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
8881
9080
  const serving = servingProfiles(messenger.app, env).length > 0;
8882
9081
  const read = await readingOnly(path, (database) => ({
8883
9082
  schema: schemaOf(database).version,
@@ -8905,6 +9104,7 @@ var isoOf = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOStrin
8905
9104
  var messageOf2 = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
8906
9105
 
8907
9106
  export {
9107
+ safeLiquid,
8908
9108
  REPLY_ACTIONS,
8909
9109
  REPLY_MODELS,
8910
9110
  REPLY_KINDS,
@@ -8920,9 +9120,6 @@ export {
8920
9120
  paused,
8921
9121
  DRY_RUN_DAYS,
8922
9122
  dryRun,
8923
- endpointKeyName,
8924
- embeddingKeys,
8925
- modelGateway,
8926
9123
  replyConsentPathFor,
8927
9124
  readReplyConsent,
8928
9125
  writeReplyConsent,