@wirecat/tg-cli 0.109.0 → 0.111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/bin/tg.js +2 -2
  2. package/dist/bundle/{adapter-6JLFYFL5.js → adapter-WFC2JAD4.js} +45 -45
  3. package/dist/bundle/{all-profiles-X7Y3T5S4.js → all-profiles-FEUSGHT7.js} +8 -8
  4. package/dist/bundle/{anthropic-LGVXAADT.js → anthropic-O646SJIJ.js} +5 -5
  5. package/dist/bundle/{app-server-UI3AFSJX.js → app-server-7P23Y45A.js} +40 -40
  6. package/dist/bundle/{bot-api-TQYRNYJQ.js → bot-api-WTJCL6VF.js} +46 -46
  7. package/dist/bundle/{bot-history-DDNTNMNB.js → bot-history-5J2Q4SPC.js} +15 -15
  8. package/dist/bundle/{bun-WXGS6HML.js → bun-KUKVEKDW.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-M6JEXKRT.js → bun-sqlite-2G5TXHYE.js} +4 -4
  10. package/dist/bundle/{chunk-P5ILJ7MN.js → chunk-2K6IGVSI.js} +5 -5
  11. package/dist/bundle/{chunk-WHYS6OSG.js → chunk-2ZH3PUQX.js} +2 -2
  12. package/dist/bundle/{chunk-YYOIULA2.js → chunk-33HEHPIK.js} +8 -8
  13. package/dist/bundle/{chunk-4R4AH6FM.js → chunk-3BD24JYK.js} +98 -94
  14. package/dist/bundle/{chunk-AGVKIJB7.js → chunk-3WUTBGZE.js} +6 -6
  15. package/dist/bundle/{chunk-7T7ILNCU.js → chunk-43ZFY6TW.js} +2 -2
  16. package/dist/bundle/{chunk-CVLDXFRP.js → chunk-5FJQG5UZ.js} +10 -9
  17. package/dist/bundle/{chunk-XJVGCCQE.js → chunk-5ZPLOYTP.js} +1911 -630
  18. package/dist/bundle/{chunk-3PEZWXKO.js → chunk-7665YBJ7.js} +6 -6
  19. package/dist/bundle/{chunk-UUQ3BH2Z.js → chunk-7GQLD5TJ.js} +2 -2
  20. package/dist/bundle/{chunk-VFVMB3NV.js → chunk-ABVHA4K6.js} +5 -5
  21. package/dist/bundle/{chunk-IULYECPC.js → chunk-AUWYMMYL.js} +4 -4
  22. package/dist/bundle/{chunk-YXCQ4DLZ.js → chunk-BNQOUCL2.js} +1 -1
  23. package/dist/bundle/{chunk-N5FSRC6H.js → chunk-BWRCPMMC.js} +41 -31
  24. package/dist/bundle/{chunk-IV2QWSPG.js → chunk-CJUSP5X2.js} +12 -3
  25. package/dist/bundle/{chunk-CH2ESVV5.js → chunk-COHMFCHD.js} +42 -24
  26. package/dist/bundle/{chunk-2ILQYCBY.js → chunk-DEG4JJHG.js} +568 -297
  27. package/dist/bundle/{chunk-DO33KAMM.js → chunk-DREEXESG.js} +96 -60
  28. package/dist/bundle/{chunk-NAVNCM5K.js → chunk-EB44Z44U.js} +1 -1
  29. package/dist/bundle/{chunk-XMMWKHNY.js → chunk-EO563SUX.js} +7 -7
  30. package/dist/bundle/{chunk-ZMZKZL3Y.js → chunk-HN6ZMUAS.js} +1 -1
  31. package/dist/bundle/{chunk-ZUOS7QUB.js → chunk-ITSSCYLP.js} +11 -11
  32. package/dist/bundle/{chunk-BESIMQ5U.js → chunk-J2Z5E7TO.js} +1 -1
  33. package/dist/bundle/{chunk-N56WXUCW.js → chunk-J4QVXR5I.js} +2 -2
  34. package/dist/bundle/{chunk-MF6NKU3Z.js → chunk-K457FHD4.js} +33 -23
  35. package/dist/bundle/{chunk-M62LF3QE.js → chunk-KE47Y4PW.js} +941 -494
  36. package/dist/bundle/{chunk-DZVYGBZB.js → chunk-KLHLWKWC.js} +67 -54
  37. package/dist/bundle/{chunk-SH63Q4QR.js → chunk-LLAZSGS7.js} +22 -22
  38. package/dist/bundle/{chunk-WNTXIQMB.js → chunk-MSGYLWCH.js} +2 -2
  39. package/dist/bundle/{chunk-ZFMS5G4H.js → chunk-NIKYFRDQ.js} +2 -2
  40. package/dist/bundle/{chunk-7AJ2IESO.js → chunk-NQAV7U7C.js} +1 -1
  41. package/dist/bundle/{chunk-GUFM5RLW.js → chunk-ONHHBPV3.js} +2 -2
  42. package/dist/bundle/{chunk-BHPCZCX7.js → chunk-OYVDWHP5.js} +2 -2
  43. package/dist/bundle/{chunk-25VC6U3A.js → chunk-PNUHAHTF.js} +1 -1
  44. package/dist/bundle/{chunk-ZHP44EML.js → chunk-PQGWEFJ2.js} +3 -3
  45. package/dist/bundle/{chunk-KHKC236O.js → chunk-QAC6Z675.js} +2 -2
  46. package/dist/bundle/{chunk-P57R2P75.js → chunk-QEAMO2TS.js} +7 -7
  47. package/dist/bundle/{chunk-RD2NLJSU.js → chunk-QLLPZWYZ.js} +4 -4
  48. package/dist/bundle/{chunk-BZIZLEJN.js → chunk-QVM2HKJP.js} +4 -4
  49. package/dist/bundle/{chunk-UIPBAT2T.js → chunk-T6DSAROY.js} +17 -14
  50. package/dist/bundle/{chunk-S7B6MTXX.js → chunk-TWZTQHP6.js} +6 -6
  51. package/dist/bundle/{chunk-VYR2IIWW.js → chunk-UDYCZ5KB.js} +1 -1
  52. package/dist/bundle/{chunk-QQF7RDLR.js → chunk-UFIUMPXP.js} +4 -4
  53. package/dist/bundle/{chunk-DLAFGSTN.js → chunk-UIPT6IAU.js} +1 -1
  54. package/dist/bundle/{chunk-INYO2QFW.js → chunk-UMUJHC4M.js} +3 -3
  55. package/dist/bundle/{chunk-TMXNMO66.js → chunk-UPRYEDAV.js} +3 -3
  56. package/dist/bundle/{chunk-IGIPIO4J.js → chunk-VIEVOF3O.js} +11 -11
  57. package/dist/bundle/{chunk-5SUFMBU5.js → chunk-WDRNVSWF.js} +45 -45
  58. package/dist/bundle/{chunk-C3RX3UOE.js → chunk-XIRASTVS.js} +11 -11
  59. package/dist/bundle/{chunk-OHLMHBDI.js → chunk-XXOJ7PQY.js} +32 -31
  60. package/dist/bundle/{chunk-CHI6D4D6.js → chunk-YFK3DNNP.js} +4 -4
  61. package/dist/bundle/{chunk-AD3QPYI3.js → chunk-YG4BO7N3.js} +2 -2
  62. package/dist/bundle/{chunk-76C5SSMR.js → chunk-ZCHC7TYO.js} +12 -12
  63. package/dist/bundle/{chunk-P55L4S6N.js → chunk-ZCV4UEVH.js} +3 -3
  64. package/dist/bundle/command-contract-JCRVVL7P.js +32 -0
  65. package/dist/bundle/{decode-RKPOGPBE.js → decode-QJNVAAKJ.js} +4 -4
  66. package/dist/bundle/{echarts-H5QQRBHI.js → echarts-2EDY7OUX.js} +2 -2
  67. package/dist/bundle/{embed-7TVAPNP7.js → embed-PZSXOQJO.js} +5 -5
  68. package/dist/bundle/{embedder-YOOHWWN6.js → embedder-O4EGMMUU.js} +8 -8
  69. package/dist/bundle/{entry-SAKW5HEZ.js → entry-DVLMQM6J.js} +5 -5
  70. package/dist/bundle/{first-run-C744N572.js → first-run-J67KTUWA.js} +9 -9
  71. package/dist/bundle/first-screen-PYEE5NMQ.js +30 -0
  72. package/dist/bundle/{identity-NRWTZIQ4.js → identity-DSYY4FLQ.js} +3 -3
  73. package/dist/bundle/{instructions-6LWRAW47.js → instructions-O535XB2L.js} +1 -1
  74. package/dist/bundle/{mcp-WSGVVZWI.js → mcp-EMNFFY4N.js} +2 -2
  75. package/dist/bundle/{node-XN4PIVWW.js → node-S3VEQNTE.js} +2 -2
  76. package/dist/bundle/{node-sqlite-PCBGROGQ.js → node-sqlite-3DNWF2BW.js} +4 -4
  77. package/dist/bundle/{oauth-PX6NGHUV.js → oauth-IU2RAZ3D.js} +6 -6
  78. package/dist/bundle/{open-BKJGJ6GX.js → open-M2IPPXMI.js} +3 -3
  79. package/dist/bundle/{openai-MJP7CZXP.js → openai-GDI7HISL.js} +13 -13
  80. package/dist/bundle/{process-4PRR3MLT.js → process-3IGMEATV.js} +1 -1
  81. package/dist/bundle/{program-7YZUO42B.js → program-P7YPHVLD.js} +50 -48
  82. package/dist/bundle/{prompt-CILSZC2R.js → prompt-S6R7IHDK.js} +4 -4
  83. package/dist/bundle/{proxy-transport-FWGKTYBL.js → proxy-transport-OROEVBCG.js} +4 -4
  84. package/dist/bundle/{recognize-AVFDJAIL.js → recognize-PFZRQ3P4.js} +3 -3
  85. package/dist/bundle/{remote-2VYXGOM4.js → remote-Q37V7LUX.js} +6 -6
  86. package/dist/bundle/{rerank-6FU2JPCD.js → rerank-V5YQQQAM.js} +6 -6
  87. package/dist/bundle/{serve-3YQOHBR6.js → serve-5CAD2UVG.js} +8 -8
  88. package/dist/bundle/{server-TPK3LNEX.js → server-R6YAO2SG.js} +32 -32
  89. package/dist/bundle/server-RUQLAWWS.js +56 -0
  90. package/dist/bundle/{state-LLUNBLZE.js → state-Y3A2NEM3.js} +5 -5
  91. package/dist/bundle/{store-27FQ743G.js → store-H5K32CNI.js} +10 -10
  92. package/dist/bundle/store-maintenance-command-QZDC4WKW.js +45 -0
  93. package/dist/bundle/tg.js +4 -4
  94. package/dist/program.d.ts.map +1 -1
  95. package/dist/program.js +2 -1
  96. package/dist/program.js.map +1 -1
  97. package/dist/version.d.ts +1 -1
  98. package/dist/version.js +1 -1
  99. package/package.json +3 -3
  100. package/skills/tg-cli/SKILL.md +14 -9
  101. package/dist/bundle/command-contract-E2MWR3T3.js +0 -32
  102. package/dist/bundle/first-screen-7GKUEIWS.js +0 -30
  103. package/dist/bundle/server-S2K4YDDG.js +0 -56
  104. package/dist/bundle/store-maintenance-command-AFJMKEBK.js +0 -45
  105. /package/dist/bundle/{chunk-62EDJKGP.js → chunk-NPGVOZVK.js} +0 -0
@@ -10,6 +10,8 @@ import {
10
10
  MEMORY_KINDS,
11
11
  MEMORY_SCOPES,
12
12
  MeetingError,
13
+ OPERATORS_BY_TYPE,
14
+ PRIORITY_LABELS,
13
15
  QUERY_LIMITS,
14
16
  RELATION_KINDS,
15
17
  REVIEW_LIMIT,
@@ -22,6 +24,7 @@ import {
22
24
  aggregateMeetingStats,
23
25
  calendarText,
24
26
  canonicalMeetingReference,
27
+ checkedScore,
25
28
  dateRange,
26
29
  defineQuery,
27
30
  entryInWindow,
@@ -29,8 +32,10 @@ import {
29
32
  findingFingerprint,
30
33
  findingHash,
31
34
  formatMeetingReference,
35
+ isClosedState,
32
36
  joinKeyOf,
33
37
  joinUrlWithoutQuery,
38
+ legacyPriority,
34
39
  linkKind,
35
40
  matches,
36
41
  meetingCueFingerprint,
@@ -39,6 +44,8 @@ import {
39
44
  normalizeTag,
40
45
  parseMeetingQuery,
41
46
  parseMeetingReference,
47
+ priorityBand,
48
+ priorityLabel,
42
49
  queryAstSchema,
43
50
  queryError,
44
51
  tagOf,
@@ -52,7 +59,7 @@ import {
52
59
  validateQuery,
53
60
  walkQuery,
54
61
  zonedMoment
55
- } from "./chunk-DO33KAMM.js";
62
+ } from "./chunk-DREEXESG.js";
56
63
  import {
57
64
  DEFAULT_STEMMERS,
58
65
  DEFAULT_STEMMERS_VERSION,
@@ -65,21 +72,21 @@ import {
65
72
  fold,
66
73
  normalize,
67
74
  parseStemmers
68
- } from "./chunk-YYOIULA2.js";
75
+ } from "./chunk-33HEHPIK.js";
69
76
  import {
70
77
  DEFAULT_TASK_CATEGORIES,
71
78
  sharedConfigPath,
72
79
  storedTaskCategories,
73
80
  taskCategoriesReader
74
- } from "./chunk-AGVKIJB7.js";
81
+ } from "./chunk-3WUTBGZE.js";
75
82
  import {
76
83
  storePath
77
- } from "./chunk-UUQ3BH2Z.js";
84
+ } from "./chunk-7GQLD5TJ.js";
78
85
  import {
79
86
  PRAGMAS,
80
87
  quietSqliteWarning,
81
88
  storeCapable
82
- } from "./chunk-S7B6MTXX.js";
89
+ } from "./chunk-TWZTQHP6.js";
83
90
  import {
84
91
  SQLiteTable,
85
92
  TableAliasProxyHandler,
@@ -104,10 +111,10 @@ import {
104
111
  sql,
105
112
  sqliteTable,
106
113
  text
107
- } from "./chunk-ZMZKZL3Y.js";
114
+ } from "./chunk-HN6ZMUAS.js";
108
115
  import {
109
116
  singleLine
110
- } from "./chunk-N5FSRC6H.js";
117
+ } from "./chunk-BWRCPMMC.js";
111
118
  import {
112
119
  CliError,
113
120
  array,
@@ -125,7 +132,7 @@ import {
125
132
  safeParse,
126
133
  strictObject,
127
134
  string
128
- } from "./chunk-XMMWKHNY.js";
135
+ } from "./chunk-EO563SUX.js";
129
136
  import {
130
137
  resolveFrom
131
138
  } from "./chunk-Y5E2WNWB.js";
@@ -133,7 +140,7 @@ import {
133
140
  __name
134
141
  } from "./chunk-ZVVMGPBJ.js";
135
142
 
136
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/account-store.js
143
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/account-store.js
137
144
  var bindArea = /* @__PURE__ */ __name(({ keyed, whole }, account) => {
138
145
  const methods = whole;
139
146
  return Object.fromEntries(Object.keys(keyed).map((name) => [
@@ -149,7 +156,7 @@ var once = /* @__PURE__ */ __name((build) => {
149
156
  };
150
157
  }, "once");
151
158
  var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
152
- const bound4 = /* @__PURE__ */ __name((area) => once(() => bindArea(area(), account)), "bound");
159
+ const bound5 = /* @__PURE__ */ __name((area) => once(() => bindArea(area(), account)), "bound");
153
160
  const ownAttachment = /* @__PURE__ */ __name((attachmentPk) => {
154
161
  const pk = owners.accountPk();
155
162
  if (pk === void 0 || owners.attachmentAccount(attachmentPk) !== pk)
@@ -192,9 +199,9 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
192
199
  return id2 === void 0 ? [] : store.meetings.search(query, { ...filter, accountId: id2 });
193
200
  }, "search")
194
201
  };
195
- const accounts2 = bound4(areas.accounts);
196
- const chats2 = bound4(areas.chats);
197
- const sync = bound4(areas.sync);
202
+ const accounts2 = bound5(areas.accounts);
203
+ const chats2 = bound5(areas.chats);
204
+ const sync = bound5(areas.sync);
198
205
  const messages2 = once(() => ({
199
206
  ...bindArea(areas.messages(), account),
200
207
  find: /* @__PURE__ */ __name((filter) => store.messages.find({ ...filter, account }), "find"),
@@ -211,13 +218,13 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
211
218
  return store.attachments.keepAttachmentText(attachmentPk, entry2);
212
219
  }, "keepAttachmentText")
213
220
  }));
214
- const roster = bound4(areas.roster);
215
- const people2 = bound4(areas.people);
216
- const conversations2 = bound4(areas.conversations);
217
- const vectors = bound4(areas.vectors);
218
- const counters = bound4(areas.counters);
219
- const tags = bound4(areas.tags);
220
- const mentions3 = bound4(areas.mentions);
221
+ const roster = bound5(areas.roster);
222
+ const people2 = bound5(areas.people);
223
+ const conversations2 = bound5(areas.conversations);
224
+ const vectors = bound5(areas.vectors);
225
+ const counters = bound5(areas.counters);
226
+ const tags = bound5(areas.tags);
227
+ const mentions3 = bound5(areas.mentions);
221
228
  return {
222
229
  account,
223
230
  get accounts() {
@@ -261,7 +268,7 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
261
268
  };
262
269
  }, "bindAccount");
263
270
 
264
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/providers.js
271
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/providers.js
265
272
  var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events"];
266
273
  var PROVIDERS = [
267
274
  { name: "telegram", kind: "messages", aliases: ["tg"] },
@@ -352,7 +359,7 @@ var providerNamed = /* @__PURE__ */ __name((word) => {
352
359
  var kindIn = /* @__PURE__ */ __name((provider) => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind, "kindIn");
353
360
  var kindOf = /* @__PURE__ */ __name((provider) => kindIn(provider) ?? "messages", "kindOf");
354
361
 
355
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/query.js
362
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/query.js
356
363
  var isBotProvider = /* @__PURE__ */ __name((provider) => provider.endsWith("-bot"), "isBotProvider");
357
364
  var inSource = /* @__PURE__ */ __name((source2, provider) => source2 === "all" || source2 === "bots" && isBotProvider(provider) || source2 === "personal" && !isBotProvider(provider) || source2 === provider || providerNamed(source2)?.name === provider || isKind(source2) && kindOf(provider) === source2, "inSource");
358
365
  var fail = /* @__PURE__ */ __name((message2) => {
@@ -375,7 +382,7 @@ var sourceOf = /* @__PURE__ */ __name((name, value, providers2) => {
375
382
  return fail(`${name} takes ${[...sources, "messages", "mail"].join(", ")} \u2014 not "${value}"`);
376
383
  }, "sourceOf");
377
384
 
378
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/account-list.js
385
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/account-list.js
379
386
  var ACCOUNT_GROUPS = "accountGroups";
380
387
  var ACCOUNT_GROUPS_SETTING = "account_groups";
381
388
  var GROUP_NAME = /^[a-z0-9][a-z0-9_-]*$/i;
@@ -562,7 +569,7 @@ var fitting = /* @__PURE__ */ __name((entries, kinds2, what, reasonOf = (kind3)
562
569
  return { accounts: [...chosen.values()], skipped };
563
570
  }, "fitting");
564
571
 
565
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
572
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
566
573
  var IndexBuilderOn = class {
567
574
  static {
568
575
  __name(this, "IndexBuilderOn");
@@ -757,7 +764,7 @@ function alias(table, alias2) {
757
764
  }
758
765
  __name(alias, "alias");
759
766
 
760
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
767
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
761
768
  var ENTITY_TABLES = {
762
769
  account: "accounts",
763
770
  attachment: "attachments",
@@ -797,7 +804,7 @@ var orphanPointers = /* @__PURE__ */ __name((database) => pointerPairs(database)
797
804
  return { table, pointer, type, count, known: known2 };
798
805
  }).filter(({ count }) => count > 0)), "orphanPointers");
799
806
 
800
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
807
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
801
808
  var canonicalTags = sqliteTable("canonical_tags", {
802
809
  id: integer("id").primaryKey(),
803
810
  name: text("name").notNull().unique(),
@@ -806,7 +813,7 @@ var canonicalTags = sqliteTable("canonical_tags", {
806
813
  updatedAt: integer("updated_at").notNull()
807
814
  });
808
815
 
809
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
816
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
810
817
  var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
811
818
  sourceKey: text("source_key").notNull(),
812
819
  collection: text("collection").notNull(),
@@ -816,13 +823,13 @@ var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
816
823
  createdAt: integer("created_at").notNull()
817
824
  }, (table) => [primaryKey({ columns: [table.sourceKey, table.collection] })]);
818
825
 
819
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
826
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
820
827
  var documentIndexPending = sqliteTable("document_index_pending", {
821
828
  id: integer("id").notNull(),
822
829
  indexableType: text("indexable_type").notNull()
823
830
  }, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
824
831
 
825
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
832
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
826
833
  var tagRedirects = sqliteTable("tag_redirects", {
827
834
  sourceId: integer("source_id").primaryKey().references(() => canonicalTags.id),
828
835
  survivorId: integer("survivor_id").notNull().references(() => canonicalTags.id),
@@ -848,7 +855,7 @@ var tagConsolidations = sqliteTable("tag_consolidations", {
848
855
  index("tag_consolidations_by_actor_type_actor_id").on(table.actorType, table.actorId)
849
856
  ]);
850
857
 
851
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
858
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
852
859
  var accounts = sqliteTable("accounts", {
853
860
  id: integer("id").primaryKey(),
854
861
  provider: text("provider").notNull(),
@@ -1921,7 +1928,10 @@ var tasks = sqliteTable("tasks", {
1921
1928
  closeSuggestedById: integer("close_suggested_by_id"),
1922
1929
  closeSuggestedCertainty: real("close_suggested_certainty"),
1923
1930
  closeSuggestedReason: text("close_suggested_reason"),
1924
- closeSuggestedAt: integer("close_suggested_at")
1931
+ closeSuggestedAt: integer("close_suggested_at"),
1932
+ priorityScore: real("priority_score"),
1933
+ agent: text("agent"),
1934
+ revision: integer("revision").notNull().default(1)
1925
1935
  }, (table) => [
1926
1936
  unique().on(table.projectId, table.number),
1927
1937
  index("tasks_by_title_folded").on(table.titleFolded),
@@ -2344,7 +2354,7 @@ var storeSettings = sqliteTable("store_settings", {
2344
2354
  at: integer("at").notNull()
2345
2355
  });
2346
2356
 
2347
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
2357
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
2348
2358
  var ARMS = [
2349
2359
  [
2350
2360
  "message",
@@ -2471,7 +2481,7 @@ var drainInvolvementQueue = /* @__PURE__ */ __name((database, cap = QUEUE_CAP) =
2471
2481
  return recomputed;
2472
2482
  }, "drainInvolvementQueue");
2473
2483
 
2474
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/mentions.js
2484
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/mentions.js
2475
2485
  import { domainToUnicode } from "node:url";
2476
2486
 
2477
2487
  // node_modules/.pnpm/psl@1.15.0/node_modules/psl/dist/psl.mjs
@@ -12493,7 +12503,7 @@ var oa = /* @__PURE__ */ __name((e) => {
12493
12503
  }, "oa");
12494
12504
  var na = { parse: O, get: aa, isValid: oa };
12495
12505
 
12496
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
12506
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
12497
12507
  var LINK = /https?:\/\/(?:(?:docs|drive|sheets|slides)\.google\.com|forms\.gle)(?:[/?#][^\s<>"'`]*)?/gi;
12498
12508
  var ID = /^[\w-]{10,}$/;
12499
12509
  var trimUrl = /* @__PURE__ */ __name((url) => {
@@ -12534,7 +12544,7 @@ var googleDocumentLinks = /* @__PURE__ */ __name((text5) => [...text5.matchAll(L
12534
12544
  return { url, documentId: googleDocumentId(url) };
12535
12545
  }), "googleDocumentLinks");
12536
12546
 
12537
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
12547
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
12538
12548
  var PHONE_PLANS = [
12539
12549
  {
12540
12550
  country: "us",
@@ -12914,7 +12924,7 @@ var PHONE_PLANS = [
12914
12924
  }
12915
12925
  ];
12916
12926
 
12917
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/phones.js
12927
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/phones.js
12918
12928
  var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
12919
12929
  var DEFAULT_PHONE_COUNTRIES = ["ru"];
12920
12930
  var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
@@ -12955,7 +12965,7 @@ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
12955
12965
  return void 0;
12956
12966
  }, "nationalPhone");
12957
12967
 
12958
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/places.js
12968
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/places.js
12959
12969
  var BEFORE = [
12960
12970
  [/^(?:ул\.?|улиц[аеыу]|улицей)$/iu, "\u0443\u043B\u0438\u0446\u0430"],
12961
12971
  [/^(?:пр-т|просп\.?|проспект[аеу]?)$/iu, "\u043F\u0440\u043E\u0441\u043F\u0435\u043A\u0442"],
@@ -13215,7 +13225,7 @@ var findPlaces = /* @__PURE__ */ __name((text5) => {
13215
13225
  return found2.sort((a, b) => a.start - b.start);
13216
13226
  }, "findPlaces");
13217
13227
 
13218
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/mentions.js
13228
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/mentions.js
13219
13229
  var MENTION_KINDS = ["phone", "email", "url", "document", "person-name", "place"];
13220
13230
  var MENTION_VERSIONS = {
13221
13231
  phone: 1,
@@ -13405,7 +13415,7 @@ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE
13405
13415
  };
13406
13416
  }, "typedPhone");
13407
13417
 
13408
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/first-names.js
13418
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/first-names.js
13409
13419
  var RUSSIAN = "\u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440 \u0410\u043B\u0435\u043A\u0441\u0435\u0439 \u0410\u043D\u0430\u0442\u043E\u043B\u0438\u0439 \u0410\u043D\u0434\u0440\u0435\u0439 \u0410\u043D\u0442\u043E\u043D \u0410\u0440\u043A\u0430\u0434\u0438\u0439 \u0410\u0440\u0441\u0435\u043D\u0438\u0439 \u0410\u0440\u0442\u0451\u043C \u0410\u0440\u0442\u0435\u043C \u0410\u0440\u0442\u0443\u0440 \u0411\u043E\u0440\u0438\u0441 \u0412\u0430\u0434\u0438\u043C \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D \u0412\u0430\u043B\u0435\u0440\u0438\u0439 \u0412\u0430\u0441\u0438\u043B\u0438\u0439 \u0412\u0438\u043A\u0442\u043E\u0440 \u0412\u0438\u0442\u0430\u043B\u0438\u0439 \u0412\u043B\u0430\u0434\u0438\u043C\u0438\u0440 \u0412\u043B\u0430\u0434\u0438\u0441\u043B\u0430\u0432 \u0412\u0441\u0435\u0432\u043E\u043B\u043E\u0434 \u0412\u044F\u0447\u0435\u0441\u043B\u0430\u0432 \u0413\u0435\u043D\u043D\u0430\u0434\u0438\u0439 \u0413\u0435\u043E\u0440\u0433\u0438\u0439 \u0413\u043B\u0435\u0431 \u0413\u0440\u0438\u0433\u043E\u0440\u0438\u0439 \u0414\u0430\u043D\u0438\u0438\u043B \u0414\u0430\u043D\u0438\u043B\u0430 \u0414\u0435\u043D\u0438\u0441 \u0414\u043C\u0438\u0442\u0440\u0438\u0439 \u0415\u0432\u0433\u0435\u043D\u0438\u0439 \u0415\u0433\u043E\u0440 \u0418\u0432\u0430\u043D \u0418\u0433\u043E\u0440\u044C \u0418\u043B\u044C\u044F \u041A\u0438\u0440\u0438\u043B\u043B \u041A\u043E\u043D\u0441\u0442\u0430\u043D\u0442\u0438\u043D \u041B\u0435\u043E\u043D\u0438\u0434 \u041C\u0430\u043A\u0441\u0438\u043C \u041C\u0430\u0440\u0430\u0442 \u041C\u0430\u0442\u0432\u0435\u0439 \u041C\u0438\u0445\u0430\u0438\u043B \u041D\u0438\u043A\u0438\u0442\u0430 \u041D\u0438\u043A\u043E\u043B\u0430\u0439 \u041E\u043B\u0435\u0433 \u041F\u0430\u0432\u0435\u043B \u041F\u0451\u0442\u0440 \u041F\u0435\u0442\u0440 \u0420\u043E\u0434\u0438\u043E\u043D \u0420\u043E\u0441\u0442\u0438\u0441\u043B\u0430\u0432 \u0420\u0443\u0441\u043B\u0430\u043D \u0420\u0443\u0441\u0442\u0430\u043C \u0421\u0435\u043C\u0451\u043D \u0421\u0435\u043C\u0435\u043D \u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u0442\u0430\u043D\u0438\u0441\u043B\u0430\u0432 \u0421\u0442\u0435\u043F\u0430\u043D \u0422\u0438\u043C\u043E\u0444\u0435\u0439 \u0422\u0438\u043C\u0443\u0440 \u0424\u0451\u0434\u043E\u0440 \u0424\u0435\u0434\u043E\u0440 \u0424\u0438\u043B\u0438\u043F\u043F \u042D\u0434\u0443\u0430\u0440\u0434 \u042E\u0440\u0438\u0439 \u042F\u0440\u043E\u0441\u043B\u0430\u0432 \u042F\u043A\u043E\u0432 \u042D\u043B\u044C\u0434\u0430\u0440 \u0414\u0430\u0432\u0438\u0434 \u0417\u0430\u0445\u0430\u0440 \u0421\u0430\u0432\u0435\u043B\u0438\u0439 \u041C\u0438\u0440\u043E\u043D \u041F\u043B\u0430\u0442\u043E\u043D \u0414\u0435\u043C\u0438\u0434 \u0410\u0440\u0441\u0435\u043D \u041D\u0443\u0440\u043B\u0430\u043D \u0410\u043D\u0437\u043E\u0440 \u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440\u0430 \u0410\u043B\u0438\u043D\u0430 \u0410\u043B\u0438\u0441\u0430 \u0410\u043B\u043B\u0430 \u0410\u043D\u0430\u0441\u0442\u0430\u0441\u0438\u044F \u0410\u043D\u0433\u0435\u043B\u0438\u043D\u0430 \u0410\u043D\u043D\u0430 \u0410\u043D\u0442\u043E\u043D\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u0440\u0438\u044F \u0412\u0430\u0440\u0432\u0430\u0440\u0430 \u0412\u0435\u0440\u043E\u043D\u0438\u043A\u0430 \u0412\u0438\u043A\u0442\u043E\u0440\u0438\u044F \u0413\u0430\u043B\u0438\u043D\u0430 \u0414\u0430\u0440\u044C\u044F \u0414\u0438\u0430\u043D\u0430 \u0415\u0432\u0433\u0435\u043D\u0438\u044F \u0415\u043A\u0430\u0442\u0435\u0440\u0438\u043D\u0430 \u0415\u043B\u0435\u043D\u0430 \u0415\u043B\u0438\u0437\u0430\u0432\u0435\u0442\u0430 \u0416\u0430\u043D\u043D\u0430 \u0417\u0438\u043D\u0430\u0438\u0434\u0430 \u041A\u0430\u0440\u0438\u043D\u0430 \u041A\u0438\u0440\u0430 \u041A\u043B\u0430\u0432\u0434\u0438\u044F \u041A\u0440\u0438\u0441\u0442\u0438\u043D\u0430 \u041A\u0441\u0435\u043D\u0438\u044F \u041B\u0430\u0440\u0438\u0441\u0430 \u041B\u0438\u0434\u0438\u044F \u041B\u044E\u0434\u043C\u0438\u043B\u0430 \u041C\u0430\u0440\u0433\u0430\u0440\u0438\u0442\u0430 \u041C\u0430\u0440\u0438\u043D\u0430 \u041C\u0430\u0440\u0438\u044F \u041C\u0438\u043B\u0430\u043D\u0430 \u041D\u0430\u0442\u0430\u043B\u044C\u044F \u041D\u0430\u0442\u0430\u043B\u0438\u044F \u041D\u0438\u043D\u0430 \u041E\u043A\u0441\u0430\u043D\u0430 \u041E\u043B\u0435\u0441\u044F \u041E\u043B\u044C\u0433\u0430 \u041F\u043E\u043B\u0438\u043D\u0430 \u0420\u0430\u0438\u0441\u0430 \u0421\u0432\u0435\u0442\u043B\u0430\u043D\u0430 \u0421\u043E\u0444\u0438\u044F \u0421\u043E\u0444\u044C\u044F \u0422\u0430\u0438\u0441\u0438\u044F \u0422\u0430\u043C\u0430\u0440\u0430 \u0422\u0430\u0442\u044C\u044F\u043D\u0430 \u0423\u043B\u044C\u044F\u043D\u0430 \u042E\u043B\u0438\u044F \u042D\u043B\u044C\u0432\u0438\u0440\u0430 \u0420\u0435\u0433\u0438\u043D\u0430 \u0421\u043D\u0435\u0436\u0430\u043D\u0430 \u0410\u043B\u0451\u043D\u0430 \u0410\u043B\u0435\u043D\u0430 \u0412\u0430\u0441\u0438\u043B\u0438\u0441\u0430 \u0410\u0440\u0438\u043D\u0430 \u0415\u0441\u0435\u043D\u0438\u044F \u042D\u0432\u0435\u043B\u0438\u043D\u0430 \u0421\u0430\u0448\u0430 \u0416\u0435\u043D\u044F \u0412\u0430\u043B\u044F \u0414\u0438\u043C\u0430 \u041C\u0438\u0448\u0430 \u041A\u043E\u043B\u044F \u041F\u0435\u0442\u044F \u0412\u0430\u0441\u044F \u0421\u0435\u0440\u0451\u0436\u0430 \u0421\u0435\u0440\u0435\u0436\u0430 \u041F\u0430\u0448\u0430 \u041B\u0451\u0448\u0430 \u041B\u0435\u0448\u0430 \u0412\u0438\u0442\u044F \u041A\u043E\u0441\u0442\u044F \u0412\u043E\u0432\u0430 \u0412\u043E\u043B\u043E\u0434\u044F \u0412\u0430\u043D\u044F \u0413\u043E\u0448\u0430 \u0413\u0440\u0438\u0448\u0430 \u0422\u043E\u043B\u044F \u0411\u043E\u0440\u044F \u0421\u0442\u0430\u0441 \u0422\u0451\u043C\u0430 \u0422\u0430\u043D\u044F \u041A\u0430\u0442\u044F \u041B\u0435\u043D\u0430 \u041D\u0430\u0442\u0430\u0448\u0430 \u0421\u0432\u0435\u0442\u0430 \u042E\u043B\u044F \u041D\u0430\u0441\u0442\u044F \u0414\u0430\u0448\u0430 \u041C\u0430\u0448\u0430 \u041B\u044E\u0434\u0430 \u0413\u0430\u043B\u044F \u0412\u0438\u043A\u0430 \u041A\u0441\u044E\u0448\u0430 \u041B\u0438\u0437\u0430 \u0421\u043E\u043D\u044F \u041D\u0430\u0434\u044F \u041B\u0435\u0440\u0430 \u0410\u043B\u0451\u0448\u0430 \u0410\u043B\u0435\u0448\u0430 \u041C\u0438\u0442\u044F \u0421\u0435\u043D\u044F \u0424\u0435\u0434\u044F \u0416\u0435\u043D\u0435\u0447\u043A\u0430 \u041E\u043B\u0435\u043D\u044C\u043A\u0430 \u0422\u0430\u043D\u0435\u0447\u043A\u0430";
13410
13420
  var EUROPEAN = "James John Robert Michael William David Richard Joseph Thomas Charles Christopher Daniel Matthew Anthony Donald Steven Paul Andrew Joshua Kenneth Kevin Brian George Timothy Ronald Edward Jason Jeffrey Ryan Jacob Gary Nicholas Eric Jonathan Stephen Larry Justin Scott Brandon Benjamin Samuel Gregory Alexander Patrick Raymond Dennis Jerry Tyler Aaron Nathan Henry Peter Zachary Douglas Harold Kyle Noah Ethan Oliver Harry Lucas Liam Mary Patricia Jennifer Linda Elizabeth Barbara Susan Jessica Sarah Karen Lisa Nancy Betty Margaret Sandra Ashley Kimberly Emily Donna Michelle Carol Amanda Dorothy Melissa Deborah Stephanie Rebecca Sharon Laura Cynthia Kathleen Angela Shirley Anna Brenda Pamela Emma Nicole Helen Samantha Katherine Christine Rachel Carolyn Janet Catherine Maria Heather Diane Ruth Julie Olivia Joyce Kelly Lauren Christina Joan Evelyn Judith Megan Andrea Cheryl Hannah Jacqueline Martha Teresa Sara Madison Frances Kathryn Janice Abigail Alice Julia Judy Sophia Denise Doris Marilyn Danielle Beverly Isabella Theresa Diana Natalie Charlotte Marie Kayla Alexis Javier Carlos Antonio Manuel Francisco Juan Pedro Alejandro Miguel Rafael Pablo Sergio Fernando Jorge Luis Alberto \xC1lvaro Diego Adri\xE1n Rub\xE9n Iv\xE1n \xD3scar Andr\xE9s Ra\xFAl Enrique Vicente Joaqu\xEDn Ignacio Gonzalo Marcos V\xEDctor Jaime Alfonso Guillermo Tom\xE1s Emilio Gabriel Nicol\xE1s Mart\xEDn Jordi Josep Xavier Luc\xEDa Carmen Isabel Cristina Marta Elena Raquel Silvia Beatriz Paula Nuria N\xFAria Sonia Alicia Irene Montserrat Inmaculada Noelia Lorena Sof\xEDa Valeria Claudia Natalia Sandra Ver\xF3nica Esther Yolanda Vanesa Laia Klaus J\xFCrgen Wolfgang Stefan Andreas Matthias Markus Tobias Florian Lukas Jonas Maximilian Sebastian Dirk Sabine Ursula Petra Monika Katrin Anja Pierre Michel Philippe Alain Fran\xE7ois Christophe Laurent Olivier Julien Mathieu S\xE9bastien Guillaume Antoine Camille Nathalie Isabelle Sylvie Sophie C\xE9line Aur\xE9lie Chlo\xE9 Manon Giuseppe Giovanni Marco Luca Francesco Alessandro Matteo Lorenzo Stefano Paolo Roberto Davide Simone Federico Giulia Francesca Chiara Valentina Alessia Martina Elisa Jo\xE3o Pedro Tiago Beatriz In\xEAs Mariana Piotr Krzysztof Tomasz Marcin Agnieszka Katarzyna Ma\u0142gorzata Magdalena";
13411
13421
  var WORDS = "\u0412\u0435\u0440\u0430 \u041D\u0430\u0434\u0435\u0436\u0434\u0430 \u041B\u044E\u0431\u043E\u0432\u044C \u0421\u043B\u0430\u0432\u0430 \u0420\u043E\u043C\u0430\u043D \u0420\u043E\u0437\u0430 \u041C\u0430\u0439\u044F \u041B\u0438\u043B\u0438\u044F \u0417\u043B\u0430\u0442\u0430 \u041C\u0438\u043B\u0430 \u041D\u0438\u043A\u0430 \u041B\u0435\u0432 \u0413\u043B\u043E\u0440\u0438\u044F Will Mark Rose Grace Hope Faith Bill Frank Jack June April Summer Amber Ruby Lily Daisy Victoria Virginia Georgia Florence Sydney Chelsea Jordan Austin Dallas Mercedes Dolores Rosa Pilar Marina Esperanza Gloria Amparo Consuelo Roc\xEDo Salvador Santiago Jes\xFAs \xC1ngeles Hugo Ram\xF3n Christian Felix F\xE9lix Mario Martin Victor Pierre Paz Merc\xE8 Estrella Aurora Concepci\xF3n Remedios Soledad Milagros Angel \xC1ngel Dawn Joy Holly Ivy Iris Violet Pearl";
@@ -13413,7 +13423,7 @@ var NOT_NAMES = ["\u0436\u0435\u043D\u0430", "\u0436\u0435\u043D\u044B", "\u0436
13413
13423
  var FIRST_NAMES = [...new Set(`${RUSSIAN} ${EUROPEAN}`.split(" "))];
13414
13424
  var NAME_WORDS = WORDS.split(" ");
13415
13425
 
13416
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/person-names.js
13426
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/person-names.js
13417
13427
  var LATIN_TO_CYRILLIC = {
13418
13428
  shch: "\u0449",
13419
13429
  sch: "\u0449",
@@ -13621,7 +13631,7 @@ var findUnknownNames = /* @__PURE__ */ __name((text5, stem, taken) => {
13621
13631
  return found2;
13622
13632
  }, "findUnknownNames");
13623
13633
 
13624
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/attachments.js
13634
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/attachments.js
13625
13635
  var NOT_FILES = /* @__PURE__ */ new Set([
13626
13636
  "webpage",
13627
13637
  "share",
@@ -13653,7 +13663,7 @@ var matchDownloads = /* @__PURE__ */ __name((stored3, files2) => {
13653
13663
  });
13654
13664
  }, "matchDownloads");
13655
13665
 
13656
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
13666
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
13657
13667
  var QUERY_VERSION = 1;
13658
13668
  var QUERY_LIMITS2 = {
13659
13669
  ...QUERY_LIMITS,
@@ -13684,7 +13694,7 @@ function exhausted(budget) {
13684
13694
  }
13685
13695
  __name(exhausted, "exhausted");
13686
13696
 
13687
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
13697
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
13688
13698
  var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
13689
13699
  var literal2 = /* @__PURE__ */ __name((c) => ({
13690
13700
  kind: "char",
@@ -14084,7 +14094,7 @@ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
14084
14094
  return out;
14085
14095
  }, "foldRegex");
14086
14096
 
14087
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
14097
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
14088
14098
  var PRESET_VERSION = 1;
14089
14099
  var PRESETS = {
14090
14100
  password: {
@@ -14138,7 +14148,7 @@ var PRESETS = {
14138
14148
  }
14139
14149
  };
14140
14150
 
14141
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
14151
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
14142
14152
  var FIELD_VERSION = 2;
14143
14153
  var UNITS = {
14144
14154
  "": 1,
@@ -14162,9 +14172,9 @@ var filled = /* @__PURE__ */ __name((node) => {
14162
14172
  searchError("query.missing-value", node.span);
14163
14173
  }, "filled");
14164
14174
  var validateSize = /* @__PURE__ */ __name((node) => {
14165
- for (const bound4 of node.operator === "range" ? [node.value, node.upper] : [node.value])
14166
- if (bound4 !== void 0 && bound4 !== "*")
14167
- parseBytes(bound4, node.span);
14175
+ for (const bound5 of node.operator === "range" ? [node.value, node.upper] : [node.value])
14176
+ if (bound5 !== void 0 && bound5 !== "*")
14177
+ parseBytes(bound5, node.span);
14168
14178
  }, "validateSize");
14169
14179
  var validateTag = /* @__PURE__ */ __name((node) => {
14170
14180
  if (tagOf(node.value) === void 0)
@@ -14537,8 +14547,8 @@ var MESSAGES = { entity: "message", backend: "sql", fields: QUERY_FIELDS };
14537
14547
  var NEAR_FIELDS = /* @__PURE__ */ new Set(["text", "exact", "transcript", "content"]);
14538
14548
  var validateFields = /* @__PURE__ */ __name((ast) => {
14539
14549
  for (const node of walkQuery(ast.root)) {
14540
- const field3 = QUERY_FIELDS.find(({ name }) => name === node.field);
14541
- if (!field3 && ["after", "before"].includes(node.field)) {
14550
+ const field4 = QUERY_FIELDS.find(({ name }) => name === node.field);
14551
+ if (!field4 && ["after", "before"].includes(node.field)) {
14542
14552
  const plain2 = ["term", "phrase"].includes(node.operator) && /^[\w:.+-]+$/u.test(node.value);
14543
14553
  searchError("legacy_date_field", node.span, plain2 ? `use date${node.field === "after" ? ">=" : "<"}${node.value}` : "use date>=YYYY-MM-DD or date:[a TO b]");
14544
14554
  }
@@ -14546,8 +14556,8 @@ var validateFields = /* @__PURE__ */ __name((ast) => {
14546
14556
  searchError("query.unsupported-operator", node.span, `"a b"~N takes words: ${[...NEAR_FIELDS].join(", ")}`);
14547
14557
  if (node.slop !== void 0 && node.slop > MOST_WORDS_APART)
14548
14558
  searchError("query.invalid-number", node.span, `words at most ${MOST_WORDS_APART} apart: "a b"~${MOST_WORDS_APART}`);
14549
- if (field3 && node.operator === "wildcard" && !field3.operators.includes("wildcard"))
14550
- searchError("query.unsupported-operator", node.span, `${field3.name} takes ${field3.operators.join(", ")}`);
14559
+ if (field4 && node.operator === "wildcard" && !field4.operators.includes("wildcard"))
14560
+ searchError("query.unsupported-operator", node.span, `${field4.name} takes ${field4.operators.join(", ")}`);
14551
14561
  }
14552
14562
  return validateQuery(ast, MESSAGES, SEARCH_QUERY);
14553
14563
  }, "validateFields");
@@ -14587,16 +14597,16 @@ var validateAst = /* @__PURE__ */ __name((input) => {
14587
14597
  return validateFields(parsed2.output);
14588
14598
  }, "validateAst");
14589
14599
 
14590
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
14600
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
14591
14601
  var hasText = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "text" || node.field === "exact" : node.clauses.some(({ node: node2 }) => hasText(node2)), "hasText");
14592
14602
  var isStemmed = /* @__PURE__ */ __name((node) => node.field === "text" && (node.operator === "term" || node.operator === "phrase") && node.value !== "", "isStemmed");
14593
14603
  var hasStems = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? isStemmed(node) : node.clauses.some(({ node: node2 }) => hasStems(node2)), "hasStems");
14594
14604
 
14595
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
14605
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
14596
14606
  var LIVE = "mn.kind = 'url' AND mn.status <> 'dismissed'";
14597
14607
  var MAIL_ROWS = `SELECT mn.source_id FROM mentions mn WHERE mn.source_type = 'email' AND ${LIVE}`;
14598
- var linkMatch = /* @__PURE__ */ __name((field3, typed, mail, mentioned2) => {
14599
- if (field3 === "url") {
14608
+ var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
14609
+ if (field4 === "url") {
14600
14610
  const value = normalizedValue(typed);
14601
14611
  const origin = mail ? trackedOrigin(value) : void 0;
14602
14612
  if (origin === void 0)
@@ -14616,7 +14626,7 @@ var linkMatch = /* @__PURE__ */ __name((field3, typed, mail, mentioned2) => {
14616
14626
  };
14617
14627
  }, "linkMatch");
14618
14628
 
14619
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
14629
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
14620
14630
  var SETTING = "phoneCountries";
14621
14631
  var savedPhoneCountries = /* @__PURE__ */ __name((database) => {
14622
14632
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING);
@@ -14647,7 +14657,7 @@ var valueMatch = /* @__PURE__ */ __name((database, typed) => {
14647
14657
  return { sql: "mn.value = ?", params: [phone?.value ?? normalizedValue(typed, { phoneCountries })] };
14648
14658
  }, "valueMatch");
14649
14659
 
14650
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/locator.js
14660
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/locator.js
14651
14661
  var SCHEME = "msg:";
14652
14662
  var formatLocator = /* @__PURE__ */ __name(({ provider, account, chat: chat2, message: message2 }) => SCHEME + [provider, account, chat2, message2].map(encodeURIComponent).join("/"), "formatLocator");
14653
14663
  var isLocator = /* @__PURE__ */ __name((reference2) => reference2.trim().startsWith(SCHEME), "isLocator");
@@ -14661,7 +14671,7 @@ var parseLocator = /* @__PURE__ */ __name((reference2) => {
14661
14671
  return { provider, account, chat: chat2, message: message2 };
14662
14672
  }, "parseLocator");
14663
14673
 
14664
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
14674
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
14665
14675
  var normalizeVocabularyName = /* @__PURE__ */ __name((input) => {
14666
14676
  if (typeof input !== "string" || input.length > 200 || /[\p{Cc}\p{Cf}]/u.test(input))
14667
14677
  throw new CliError("validation_error", "a vocabulary name takes 1\u2013200 characters without control characters");
@@ -14689,7 +14699,7 @@ var vocabularySimilarity = /* @__PURE__ */ __name((left, right) => {
14689
14699
  return 2 * intersection2 / (aa2.size + bb.size);
14690
14700
  }, "vocabularySimilarity");
14691
14701
 
14692
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
14702
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
14693
14703
  import { createHash } from "node:crypto";
14694
14704
  var folded2 = /* @__PURE__ */ __name((name) => {
14695
14705
  try {
@@ -14755,30 +14765,30 @@ var guardTagCreation = /* @__PURE__ */ __name((context, name, kind3, by, options
14755
14765
  });
14756
14766
  }, "guardTagCreation");
14757
14767
 
14758
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
14768
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
14759
14769
  var invalid2 = /* @__PURE__ */ __name((message2) => {
14760
14770
  throw new CliError("validation_error", message2);
14761
14771
  }, "invalid");
14762
- var record2 = /* @__PURE__ */ __name((value, fields4, field3) => {
14772
+ var record2 = /* @__PURE__ */ __name((value, fields4, field4) => {
14763
14773
  if (!value || typeof value !== "object" || Array.isArray(value))
14764
- return invalid2(`${field3} must be an object`);
14774
+ return invalid2(`${field4} must be an object`);
14765
14775
  for (const key2 of Object.keys(value))
14766
14776
  if (!fields4.includes(key2))
14767
- invalid2(`unknown ${field3} field: ${key2}`);
14777
+ invalid2(`unknown ${field4} field: ${key2}`);
14768
14778
  return value;
14769
14779
  }, "record");
14770
- var tagId = /* @__PURE__ */ __name((value, field3) => {
14780
+ var tagId = /* @__PURE__ */ __name((value, field4) => {
14771
14781
  if (typeof value !== "string" || value.length > 16 || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
14772
- return invalid2(`${field3} must be a positive canonical tag id`);
14782
+ return invalid2(`${field4} must be a positive canonical tag id`);
14773
14783
  return value;
14774
14784
  }, "tagId");
14775
14785
  var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
14776
14786
  const input = record2(snapshot2, ["complete", "tags", "redirects"], "snapshot");
14777
14787
  if (input.complete !== true)
14778
14788
  invalid2("snapshot.complete must be true; partial tag graphs cannot resolve labels");
14779
- for (const field3 of ["tags", "redirects"])
14780
- if (!Array.isArray(input[field3]) || input[field3].length > 4096)
14781
- invalid2(`snapshot.${field3} must be an array of at most 4096 rows`);
14789
+ for (const field4 of ["tags", "redirects"])
14790
+ if (!Array.isArray(input[field4]) || input[field4].length > 4096)
14791
+ invalid2(`snapshot.${field4} must be an array of at most 4096 rows`);
14782
14792
  const ids = /* @__PURE__ */ new Set();
14783
14793
  for (const [index2, value] of snapshot2.tags.entries()) {
14784
14794
  const row2 = record2(value, ["id", "kind"], `tags[${index2}]`);
@@ -14832,7 +14842,7 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
14832
14842
  };
14833
14843
  }, "createTagRedirectIndex");
14834
14844
 
14835
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
14845
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
14836
14846
  var tagCanonicalId = /* @__PURE__ */ __name((database, id2) => {
14837
14847
  const row2 = database.prepare("SELECT canonical_id FROM resolved_tags WHERE id=?").get(id2);
14838
14848
  if (!row2)
@@ -14860,7 +14870,7 @@ var tagRedirectSnapshot = /* @__PURE__ */ __name((database) => {
14860
14870
  return snapshot2;
14861
14871
  }, "tagRedirectSnapshot");
14862
14872
 
14863
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
14873
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
14864
14874
  import { createHash as createHash2 } from "node:crypto";
14865
14875
  var TASK_KEY_PREFIXES = {
14866
14876
  question: "Q",
@@ -14888,7 +14898,7 @@ var taskAccountOf = /* @__PURE__ */ __name((database, rowId) => {
14888
14898
  return row2 && String(row2.key) === inboxKey(String(row2.name)) ? String(row2.name) : void 0;
14889
14899
  }, "taskAccountOf");
14890
14900
 
14891
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/references.js
14901
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/references.js
14892
14902
  var SIMPLE_REFERENCES = [
14893
14903
  "note",
14894
14904
  "document",
@@ -14960,7 +14970,7 @@ var folderPath = /* @__PURE__ */ __name((path) => {
14960
14970
  }, "folderPath");
14961
14971
  var canonicalReference = /* @__PURE__ */ __name((text5) => formatReference(parseReference(text5)), "canonicalReference");
14962
14972
 
14963
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
14973
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
14964
14974
  var storedThing = /* @__PURE__ */ __name((type, id2) => ({ type: String(type), id: Number(id2) }), "storedThing");
14965
14975
  var REFERABLE = {
14966
14976
  note: { tombstone: true },
@@ -15118,7 +15128,7 @@ var taskIdOf = /* @__PURE__ */ __name((database, rowId) => {
15118
15128
  }, "taskIdOf");
15119
15129
  var canonicalThingReference = /* @__PURE__ */ __name((reference2) => reference2.trim().startsWith("meeting:") ? canonicalMeetingReference(reference2) : canonicalReference(reference2), "canonicalThingReference");
15120
15130
 
15121
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
15131
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
15122
15132
  var toMs = /* @__PURE__ */ __name((iso11) => {
15123
15133
  if (iso11 === null || iso11 === void 0)
15124
15134
  return null;
@@ -15132,7 +15142,7 @@ var present = /* @__PURE__ */ __name((entries) => Object.fromEntries(Object.entr
15132
15142
  var DELIVERY = { delivered: 1, read: 2 };
15133
15143
  var deliveryOf = /* @__PURE__ */ __name((stored3) => stored3 === DELIVERY.read ? "read" : stored3 === DELIVERY.delivered ? "delivered" : void 0, "deliveryOf");
15134
15144
 
15135
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
15145
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
15136
15146
  var TAG_KINDS = ["tag", "topic"];
15137
15147
  var TAGGABLE = { chat: "chat", contact: "identity", message: "message", task: "task" };
15138
15148
  var TAG_TYPE = {
@@ -15200,12 +15210,19 @@ var createTag = /* @__PURE__ */ __name((context, name, kind3, by, options = {})
15200
15210
  var ensureTag = /* @__PURE__ */ __name((context, name) => {
15201
15211
  return canonicalTagNamed(context.database, name) ?? createTag(context, name, "tag", "owner");
15202
15212
  }, "ensureTag");
15213
+ var taskTagsChanged = /* @__PURE__ */ __name((context, thing, changes, author) => {
15214
+ if (thing.type !== "task" || [...changes.added ?? [], ...changes.removed ?? []].length === 0)
15215
+ return;
15216
+ const at = context.now();
15217
+ context.database.prepare("UPDATE tasks SET updated_at = ? WHERE id = ?").run(at, thing.id);
15218
+ context.database.prepare("INSERT INTO task_events (task_id, actor_type, actor_id, kind, changes, created_at) VALUES (?, ?, ?, 'tags', ?, ?)").run(thing.id, author?.type ?? null, author?.id ?? null, JSON.stringify({ tags: [changes.removed ?? [], changes.added ?? []] }), at);
15219
+ }, "taskTagsChanged");
15203
15220
  var addTags = /* @__PURE__ */ __name((context, thing, tags, source2 = "owner", author) => {
15204
15221
  const { database, now: now2 } = context;
15205
15222
  const insert = database.prepare("INSERT INTO taggings (tag_id, taggable_type, taggable_id, main, source, author_type, author_id, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?, ?, ?, ?) ON CONFLICT (tag_id, taggable_type, taggable_id) DO NOTHING");
15206
15223
  const claim3 = database.prepare("UPDATE taggings SET source = 'owner', updated_at = ? WHERE tag_id = ? AND taggable_type = ? AND taggable_id = ? AND source <> 'owner'");
15207
15224
  const at = now2();
15208
- return tags.filter((name) => {
15225
+ const fresh = tags.filter((name) => {
15209
15226
  const tag2 = ensureTag(context, name);
15210
15227
  const held = database.prepare("SELECT source,author_type,author_id FROM taggings WHERE tag_id IN (SELECT ? UNION ALL SELECT source_id FROM tag_redirects WHERE survivor_id=?) AND taggable_type=? AND taggable_id=?").all(tag2.id, tag2.id, thing.type, thing.id);
15211
15228
  if (held.some((row2) => row2.source === source2 && row2.author_type === (author?.type ?? null) && row2.author_id === (author?.id ?? null)))
@@ -15215,10 +15232,13 @@ var addTags = /* @__PURE__ */ __name((context, thing, tags, source2 = "owner", a
15215
15232
  claim3.run(at, tag2.id, thing.type, thing.id);
15216
15233
  return added && held.length === 0;
15217
15234
  });
15235
+ taskTagsChanged(context, thing, { added: fresh }, author);
15236
+ return fresh;
15218
15237
  }, "addTags");
15219
- var removeTags = /* @__PURE__ */ __name(({ database }, thing, tags, source2) => {
15238
+ var removeTags = /* @__PURE__ */ __name((context, thing, tags, source2) => {
15239
+ const { database } = context;
15220
15240
  const remove = database.prepare("DELETE FROM taggings WHERE tag_id=? AND taggable_type=? AND taggable_id=?");
15221
- return tags.filter((name) => {
15241
+ const removed = tags.filter((name) => {
15222
15242
  const tag2 = canonicalTagNamed(database, name);
15223
15243
  if (!tag2)
15224
15244
  return false;
@@ -15248,6 +15268,8 @@ var removeTags = /* @__PURE__ */ __name(({ database }, thing, tags, source2) =>
15248
15268
  }
15249
15269
  return changed;
15250
15270
  });
15271
+ taskTagsChanged(context, thing, { removed });
15272
+ return removed;
15251
15273
  }, "removeTags");
15252
15274
  var liveTagging = /* @__PURE__ */ __name((alias2) => `NOT (${alias2}.taggable_type = 'document' AND EXISTS (SELECT 1 FROM documents dt WHERE dt.id = ${alias2}.taggable_id AND dt.deleted_at IS NOT NULL))`, "liveTagging");
15253
15275
  var labelsOf = /* @__PURE__ */ __name((database, thing, tag2) => database.prepare(`SELECT t.name,CASE WHEN min(g.source)='file' AND max(g.source)='file' THEN 'file' ELSE 'owner' END AS source FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE g.taggable_type=? AND g.taggable_id=?${tag2 === void 0 ? "" : " AND t.name = ?"} GROUP BY t.canonical_id ORDER BY t.name`).all(thing.type, thing.id, ...tag2 === void 0 ? [] : [tag2]).map((row2) => ({ tag: String(row2.name), origin: row2.source === "file" ? "file" : "owner" })), "labelsOf");
@@ -15323,7 +15345,7 @@ var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
15323
15345
  return result;
15324
15346
  }, "tagsOf");
15325
15347
 
15326
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
15348
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
15327
15349
  var speech = /* @__PURE__ */ __name((alias2) => `(coalesce(${alias2}.extractor,'') LIKE 'speech:%' OR ${alias2}.kind IN ('voice','video_note') OR coalesce(${alias2}.mime,'')='audio/ogg')`, "speech");
15328
15350
  var SPEECH = speech("att");
15329
15351
  var mentionText = /* @__PURE__ */ __name((alias2) => `CASE WHEN coalesce(json_extract(${alias2}.contact, '$.phone'), '') <> '' THEN 'phone: ' || json_extract(${alias2}.contact, '$.phone') ELSE ${alias2}.text END`, "mentionText");
@@ -15360,8 +15382,8 @@ var wordMatch = /* @__PURE__ */ __name((corpus, match) => ({
15360
15382
  exact: true,
15361
15383
  fts: match
15362
15384
  }), "wordMatch");
15363
- var tooManyWords = /* @__PURE__ */ __name(({ field: field3, operator, value, span }, alone) => {
15364
- const term = `${field3}:${operator === "regex" ? `/${value}/` : value}`;
15385
+ var tooManyWords = /* @__PURE__ */ __name(({ field: field4, operator, value, span }, alone) => {
15386
+ const term = `${field4}:${operator === "regex" ? `/${value}/` : value}`;
15365
15387
  throw new CliError("validation_error", `search: ${term}${alone ? " matches" : " and the patterns before it match"} more than ${QUERY_LIMITS2.expansions} indexed words, the term expansions budget \u2014 use a longer prefix, or body:/\u2026/ inside one chat`, {
15366
15388
  reason: "query.too-large",
15367
15389
  budget: "term expansions",
@@ -15573,13 +15595,13 @@ var mentions2 = /* @__PURE__ */ __name((node, scope3) => {
15573
15595
  searchError("query.invalid-reference", node.span);
15574
15596
  return always(mentioned(scope3, `mn.status = 'linked' AND (${target[0]})`, target[1]));
15575
15597
  }, "mentions");
15576
- var link = /* @__PURE__ */ __name((field3) => ({ value }, scope3) => always({
15577
- ...linkMatch(field3, value, scope3.mail, (where, params) => mentioned(scope3, where, params)),
15598
+ var link = /* @__PURE__ */ __name((field4) => ({ value }, scope3) => always({
15599
+ ...linkMatch(field4, value, scope3.mail, (where, params) => mentioned(scope3, where, params)),
15578
15600
  exact: true
15579
15601
  }), "link");
15580
- var found = /* @__PURE__ */ __name(({ field: field3, value }, scope3) => {
15581
- const match = field3 === "domain" ? void 0 : valueMatch(scope3.database, value);
15582
- return always(match === void 0 ? mentioned(scope3, "mn.domain = ? AND mn.status <> 'dismissed'", [siteOf(value.toLowerCase())]) : mentioned(scope3, `mn.kind = ? AND ${match.sql} AND mn.status <> 'dismissed'`, [field3, ...match.params]));
15602
+ var found = /* @__PURE__ */ __name(({ field: field4, value }, scope3) => {
15603
+ const match = field4 === "domain" ? void 0 : valueMatch(scope3.database, value);
15604
+ return always(match === void 0 ? mentioned(scope3, "mn.domain = ? AND mn.status <> 'dismissed'", [siteOf(value.toLowerCase())]) : mentioned(scope3, `mn.kind = ? AND ${match.sql} AND mn.status <> 'dismissed'`, [field4, ...match.params]));
15583
15605
  }, "found");
15584
15606
  var tag = /* @__PURE__ */ __name((node, { corpus, database }) => {
15585
15607
  const selected = tagOf(node.value);
@@ -15678,7 +15700,7 @@ var FIELD_COMPILERS = {
15678
15700
  subject
15679
15701
  };
15680
15702
 
15681
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
15703
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
15682
15704
  var placeOf = /* @__PURE__ */ __name((database) => {
15683
15705
  const exact = database.prepare("SELECT id FROM places WHERE folded = ?");
15684
15706
  const onStreet = database.prepare("SELECT id FROM places WHERE substr(folded, 1, ?) = ? LIMIT 2");
@@ -15694,7 +15716,7 @@ var placeOf = /* @__PURE__ */ __name((database) => {
15694
15716
  };
15695
15717
  }, "placeOf");
15696
15718
 
15697
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
15719
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
15698
15720
  var DRAIN_ON_WRITE = 500;
15699
15721
  var METHOD = "rules";
15700
15722
  var telegramLink = /* @__PURE__ */ __name((database) => {
@@ -15857,7 +15879,7 @@ var drainMentions = /* @__PURE__ */ __name((database, now2, limit = DRAIN_ON_WRI
15857
15879
  return queued.length;
15858
15880
  }, "drainMentions");
15859
15881
 
15860
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
15882
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
15861
15883
  var indexRow = /* @__PURE__ */ __name((database, name) => {
15862
15884
  const exists2 = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'search_index_state'").get();
15863
15885
  if (!exists2)
@@ -15865,7 +15887,7 @@ var indexRow = /* @__PURE__ */ __name((database, name) => {
15865
15887
  return database.prepare("SELECT * FROM search_index_state WHERE name = ?").get(name);
15866
15888
  }, "indexRow");
15867
15889
 
15868
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
15890
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
15869
15891
  var INDEX = "message_stems";
15870
15892
  var SETTING2 = "searchStemmers";
15871
15893
  var DRAIN_ON_WRITE2 = 500;
@@ -15987,7 +16009,7 @@ var stemmerCache = /* @__PURE__ */ __name(() => {
15987
16009
  };
15988
16010
  }, "stemmerCache");
15989
16011
 
15990
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
16012
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
15991
16013
  var SQLITE_BUSY = 5;
15992
16014
  var pause = new Int32Array(new SharedArrayBuffer(4));
15993
16015
  var isBusy = /* @__PURE__ */ __name((error) => {
@@ -16024,7 +16046,14 @@ var connectionOf = /* @__PURE__ */ __name((database) => {
16024
16046
  return connection;
16025
16047
  }, "connectionOf");
16026
16048
  var write = /* @__PURE__ */ __name((database, body2, { beforeCommit } = {}) => transact(database, body2, true, beforeCommit), "write");
16027
- var writeBatch = /* @__PURE__ */ __name((database, body2) => transact(database, body2, false), "writeBatch");
16049
+ var writeBatch = /* @__PURE__ */ __name((database, body2) => {
16050
+ const outer = connectionOf(database).depth === 0;
16051
+ const result = transact(database, body2, false);
16052
+ if (outer)
16053
+ Atomics.wait(pause, 0, 0, BATCH_PAUSE_MS);
16054
+ return result;
16055
+ }, "writeBatch");
16056
+ var BATCH_PAUSE_MS = 2;
16028
16057
  var transact = /* @__PURE__ */ __name((database, body2, drain, beforeCommit) => {
16029
16058
  const connection = connectionOf(database);
16030
16059
  if (connection.reading)
@@ -16075,7 +16104,7 @@ var read = /* @__PURE__ */ __name((database, body2) => {
16075
16104
  }
16076
16105
  }, "read");
16077
16106
 
16078
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
16107
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
16079
16108
  var source = /* @__PURE__ */ __name((model, dims) => `SELECT k.id, k.chunkable_type,
16080
16109
  coalesce(CASE k.chunkable_type
16081
16110
  WHEN 'image' THEN (SELECT ch.account_id FROM attachments a JOIN messages m ON m.id = a.attachable_id
@@ -16217,7 +16246,7 @@ var dropUnusedVectors = /* @__PURE__ */ __name((database, hashes) => {
16217
16246
  }, "dropUnusedVectors");
16218
16247
  var dropAllUnusedVectors = /* @__PURE__ */ __name((database) => database.prepare("DELETE FROM embeddings WHERE NOT EXISTS (SELECT 1 FROM chunks k WHERE k.content_hash = embeddings.content_hash) RETURNING 1").all().length, "dropAllUnusedVectors");
16219
16248
 
16220
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
16249
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
16221
16250
  var accountPk = /* @__PURE__ */ __name(({ orm, now: now2 }, { provider, account, scope: scope3 }, name = null) => Number(orm.insert(accounts).values({ provider, externalId: account, name, scope: scope3 ?? "personal", createdAt: now2(), updatedAt: now2() }).onConflictDoUpdate({
16222
16251
  target: [accounts.provider, accounts.externalId],
16223
16252
  set: {
@@ -16323,7 +16352,7 @@ var dropOrphanPeople = /* @__PURE__ */ __name((database, unseenBefore) => {
16323
16352
  AND id NOT IN (SELECT id FROM (${referencesTo(database, "persons", /* @__PURE__ */ new Set(["identity_links"]))}) WHERE id IS NOT NULL)`).run(JSON.stringify(persons2));
16324
16353
  }, "dropOrphanPeople");
16325
16354
 
16326
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
16355
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
16327
16356
  var FOLDED = [
16328
16357
  { table: "tasks", column: "title" },
16329
16358
  { table: "tasks", column: "close_reason" },
@@ -16360,7 +16389,7 @@ var fillFolded = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
16360
16389
  return filled2;
16361
16390
  }, "fillFolded");
16362
16391
 
16363
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
16392
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
16364
16393
  import { createHash as createHash3 } from "node:crypto";
16365
16394
  var CHUNK_CHARS = 1200;
16366
16395
  var CHUNK_OVERLAP = 150;
@@ -16465,7 +16494,7 @@ var cutChunks = /* @__PURE__ */ __name((members2, limit = CHUNK_CHARS, check3, c
16465
16494
  return chunks2;
16466
16495
  }, "cutChunks");
16467
16496
 
16468
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/task-signature.js
16497
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/task-signature.js
16469
16498
  var DAY = 864e5;
16470
16499
  var CURRENCY = [
16471
16500
  [/^(₽|руб.*|р\.?|rub)$/u, "RUB"],
@@ -16582,7 +16611,7 @@ var dueDayOf = /* @__PURE__ */ __name((text5, createdMs) => {
16582
16611
  return best?.day ?? null;
16583
16612
  }, "dueDayOf");
16584
16613
 
16585
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
16614
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
16586
16615
  var DAY2 = 864e5;
16587
16616
  var STOP_WORDS = new Set([
16588
16617
  // Russian and English as the test set ran them, already folded (пожалуйста → пожалуиста).
@@ -16685,7 +16714,7 @@ var LEVEL_REASONS = {
16685
16714
  person: { same: "same person", different: "different person" },
16686
16715
  amount: { equal: "same amount", different: "different amount" }
16687
16716
  };
16688
- var weightOf = /* @__PURE__ */ __name((field3, level) => TASK_SIMILARITY_WEIGHTS[field3][level].weight, "weightOf");
16717
+ var weightOf = /* @__PURE__ */ __name((field4, level) => TASK_SIMILARITY_WEIGHTS[field4][level].weight, "weightOf");
16689
16718
  var plural = /* @__PURE__ */ __name((count, word) => `${count} ${word}${count === 1 ? "" : "s"}`, "plural");
16690
16719
  var bandOf = /* @__PURE__ */ __name((score) => score >= TASK_SIMILARITY_BANDS.likely ? "likely" : score >= TASK_SIMILARITY_BANDS.maybe ? "maybe" : "different", "bandOf");
16691
16720
  var compareTasks = /* @__PURE__ */ __name((a, b, { replyChain = false } = {}) => {
@@ -16737,7 +16766,7 @@ var rankCandidates = /* @__PURE__ */ __name((views, candidates) => candidates.ma
16737
16766
  ...compareViews(subjectViews ?? views, candidate, replyChain === void 0 ? {} : { replyChain })
16738
16767
  })).sort((a, b) => b.score - a.score), "rankCandidates");
16739
16768
 
16740
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
16769
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
16741
16770
  var currentChunks = /* @__PURE__ */ __name((chatKey) => sql`SELECT k.content_hash, k.chunkable_id AS conversation_id, r.first_message_id,
16742
16771
  r.last_message_id, r.text_start, r.text_end FROM chunks k JOIN chunk_messages r ON r.chunk_id = k.id
16743
16772
  JOIN conversations c ON k.chunkable_type = 'conversation' AND c.id = k.chunkable_id
@@ -17008,7 +17037,7 @@ var readiness = /* @__PURE__ */ __name(({ orm }, chatKey, model) => {
17008
17037
  };
17009
17038
  }, "readiness");
17010
17039
 
17011
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
17040
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
17012
17041
  var DOCUMENT_PICTURE = "document_picture";
17013
17042
  var SCAN_PAGE2 = 5e3;
17014
17043
  var idOf = /* @__PURE__ */ __name((ref3) => {
@@ -17071,7 +17100,7 @@ var documentPicturesOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
17071
17100
  }, "nearestPictures")
17072
17101
  }), "documentPicturesOver");
17073
17102
 
17074
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
17103
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
17075
17104
  var glob = /* @__PURE__ */ __name((value) => [...fold(value).matchAll(/\\(.)|([*?])|(.)/gsu)].map(([, escaped2, wildcard, plain2]) => {
17076
17105
  const literal4 = escaped2 ?? plain2 ?? "";
17077
17106
  return wildcard ?? (/[*?[]/u.test(literal4) ? `[${literal4}]` : literal4);
@@ -17136,7 +17165,7 @@ var compile = /* @__PURE__ */ __name((node, columns, options) => {
17136
17165
  var queryFilter = /* @__PURE__ */ __name((ast, columns, options = {}) => compile(ast.root, columns, options), "queryFilter");
17137
17166
  var bound2 = /* @__PURE__ */ __name(({ sql: text5, params }) => sql.join(text5.split("?").map((part, at) => at < params.length ? sql`${sql.raw(part)}${params[at]}` : sql.raw(part)), sql``), "bound");
17138
17167
 
17139
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
17168
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
17140
17169
  var toJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.stringify(value), "toJson");
17141
17170
  var fromJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.parse(String(value)), "fromJson");
17142
17171
  var int = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "int");
@@ -17226,7 +17255,7 @@ var linkMeeting = /* @__PURE__ */ __name((database, id2, eventId, now2, mode = "
17226
17255
  });
17227
17256
  }, "linkMeeting");
17228
17257
 
17229
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
17258
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
17230
17259
  var EVENT_TEXT = "trim(coalesce(e.description, '') || ' ' || coalesce(e.location, '') || ' ' || coalesce((SELECT group_concat(p.name, ' ') FROM calendar_entries ce JOIN calendar_entry_participants p ON p.entry_id = ce.id WHERE ce.event_id = e.id AND ce.deleted_at IS NULL AND p.resource = 0 AND p.name IS NOT NULL), ''))";
17231
17260
  var UNSEARCHED_EVENT_TYPES = [
17232
17261
  "working-location",
@@ -17301,7 +17330,7 @@ var holdingText = /* @__PURE__ */ __name((type, column2, search2) => {
17301
17330
  if ([...text5].length < 3)
17302
17331
  throw new CliError("validation_error", "search needs at least three characters");
17303
17332
  const queued = `SELECT id FROM ${type}_index_pending WHERE indexable_type = '${type}'`;
17304
- const state = /* @__PURE__ */ __name((field3) => `(SELECT ${field3} FROM search_index_state WHERE name = '${type}_trigrams')`, "state");
17333
+ const state = /* @__PURE__ */ __name((field4) => `(SELECT ${field4} FROM search_index_state WHERE name = '${type}_trigrams')`, "state");
17305
17334
  return {
17306
17335
  sql: `${column2} IN (SELECT rowid FROM ${type}_trigrams WHERE ${type}_trigrams MATCH ? AND rowid NOT IN (${queued}) UNION ALL SELECT r.id FROM ${type}s r WHERE (r.id IN (${queued}) OR (r.id > ${state("filled_through")} AND r.id <= ${state("watermark")})) AND instr(lower(coalesce(r.body, '')), lower(?)) > 0)`,
17307
17336
  params: [`"${text5.replaceAll('"', '""')}"`, search2]
@@ -17456,7 +17485,7 @@ var resetNoteIndex = /* @__PURE__ */ __name((database) => {
17456
17485
  return true;
17457
17486
  }, "resetNoteIndex");
17458
17487
 
17459
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
17488
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
17460
17489
  var keyOf3 = /* @__PURE__ */ __name((name) => fold(name).trim().replace(/^@/, ""), "keyOf");
17461
17490
  var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
17462
17491
  for (const key2 of new Set(names.filter((name) => !!name?.trim()).map(keyOf3))) {
@@ -17475,7 +17504,7 @@ var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
17475
17504
  }
17476
17505
  }, "resolvePersonLinks");
17477
17506
 
17478
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
17507
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
17479
17508
  var flag2 = /* @__PURE__ */ __name((value) => value === void 0 || value === null ? null : Number(value), "flag");
17480
17509
  var prepare = /* @__PURE__ */ __name((orm) => ({
17481
17510
  find: orm.select({
@@ -17700,7 +17729,7 @@ var meetingIdentityPk = /* @__PURE__ */ __name((context, accountId, identity) =>
17700
17729
  }, "meetingIdentityPk");
17701
17730
  var phoneOf = /* @__PURE__ */ __name(({ orm }, provider, nativeId) => orm.select({ phone: identities.phone }).from(identities).where(and(eq(identities.provider, provider), eq(identities.externalId, nativeId))).get()?.phone ?? null, "phoneOf");
17702
17731
 
17703
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
17732
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
17704
17733
  var chatOf = /* @__PURE__ */ __name(({ orm }, accountKey, chatKey) => orm.select({ id: chats.externalId }).from(chats).where(and(eq(chats.id, chatKey), eq(chats.accountId, accountKey))).get()?.id, "chatOf");
17705
17734
  var findChatPk = /* @__PURE__ */ __name(({ orm }, accountKey, chatId) => orm.select({ pk: chats.id }).from(chats).where(and(eq(chats.accountId, accountKey), eq(chats.externalId, chatId))).get()?.pk, "findChatPk");
17706
17735
  var chatPkFor = /* @__PURE__ */ __name((context, accountKey, chatId) => findChatPk(context, accountKey, chatId) ?? Number(context.orm.insert(chats).values({
@@ -17980,11 +18009,11 @@ var replaceAutoTags = /* @__PURE__ */ __name((context, key2, chatId, algorithm,
17980
18009
  }
17981
18010
  }, "replaceAutoTags");
17982
18011
 
17983
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/counters.js
18012
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/counters.js
17984
18013
  var COUNTER_FIELDS = ["views", "reactions", "comments"];
17985
18014
  var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
17986
- var counterValue = /* @__PURE__ */ __name((message2, field3) => {
17987
- const value = field3 === "reactions" ? message2.reactions?.total : message2.providerMetadata?.[field3];
18015
+ var counterValue = /* @__PURE__ */ __name((message2, field4) => {
18016
+ const value = field4 === "reactions" ? message2.reactions?.total : message2.providerMetadata?.[field4];
17988
18017
  return validCounter(value) ? value : null;
17989
18018
  }, "counterValue");
17990
18019
  var counterObservationTime = /* @__PURE__ */ __name((observation, now2) => {
@@ -17997,14 +18026,14 @@ var counterObservationTime = /* @__PURE__ */ __name((observation, now2) => {
17997
18026
  }, "counterObservationTime");
17998
18027
  var observedCounters = /* @__PURE__ */ __name((message2, observedAt, fields4, source2 = "remote_fetch") => {
17999
18028
  const observations = {};
18000
- for (const field3 of fields4) {
18001
- const value = counterValue(message2, field3);
18029
+ for (const field4 of fields4) {
18030
+ const value = counterValue(message2, field4);
18002
18031
  if (value !== null)
18003
- observations[field3] = {
18032
+ observations[field4] = {
18004
18033
  value,
18005
18034
  observedAt,
18006
18035
  source: source2,
18007
- ...field3 === "reactions" && message2.reactions ? { reactions: message2.reactions } : {}
18036
+ ...field4 === "reactions" && message2.reactions ? { reactions: message2.reactions } : {}
18008
18037
  };
18009
18038
  }
18010
18039
  return { ...message2, counterObservations: observations };
@@ -18017,7 +18046,7 @@ var counterFreshness = /* @__PURE__ */ __name((states) => {
18017
18046
  return states.some((one) => one.freshness === "stale") ? "stale" : "fresh";
18018
18047
  }, "counterFreshness");
18019
18048
 
18020
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
18049
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
18021
18050
  var GREETING = new RegExp("^(hi|hello|hey|dear|greetings|good (morning|afternoon|evening)|\u043F\u0440\u0438\u0432\u0435\u0442|\u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439(\u0442\u0435)?|\u0434\u043E\u0431\u0440(\u044B\u0439|\u043E\u0435|\u043E\u0433\u043E) (\u0434\u0435\u043D\u044C|\u0432\u0435\u0447\u0435\u0440|\u0443\u0442\u0440\u043E|\u0443\u0442\u0440\u0430|\u0434\u043D\u044F)|hola|buen(os|as) (d\xEDas|dias|tardes|noches)|estimad[oa]s?|querid[oa]s?)(?![\\p{L}\\p{N}])([\\s,]+\\p{L}[\\p{L}.'\u2019-]*){0,3}\\s*[,!.:]?$", "iu");
18022
18051
  var SIGN_OFF = /^(best|best regards|best wishes|kind regards|warm regards|regards|thanks|thanks again|thanks a lot|thank you|many thanks|cheers|sincerely|yours|yours truly|yours sincerely|br|с уважением|спасибо|заранее спасибо|всего доброго|всего хорошего|un saludo|saludos|saludos cordiales|atentamente|gracias|muchas gracias)[\s,.!]*$/iu;
18023
18052
  var ATTRIBUTION = /(wrote|написал[аи]?|escribió|a écrit|schrieb)\s*:\s*$/iu;
@@ -18098,7 +18127,7 @@ var mailCore = /* @__PURE__ */ __name((body2, earlier) => {
18098
18127
  return withoutSignOff(withoutGreeting(kept)).join("\n").trim();
18099
18128
  }, "mailCore");
18100
18129
 
18101
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
18130
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
18102
18131
  var titleOf = /* @__PURE__ */ __name((subject2) => subject2?.replace(/^\s*((re|fwd?|aw|wg)\s*:\s*)+/i, "").trim() || null, "titleOf");
18103
18132
  var MAIL_PIECES = `(SELECT k.id, k.content_hash, k.chunkable_type AS type, k.chunkable_id AS owner, k.position,
18104
18133
  k.start_offset, k.end_offset, k.account_id, k.occurred_at, a.attachable_id AS email_id,
@@ -18208,7 +18237,7 @@ var drainEmailIndex = /* @__PURE__ */ __name((database, stemmerFor2) => {
18208
18237
  return emails3 + threads;
18209
18238
  }, "drainEmailIndex");
18210
18239
 
18211
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
18240
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
18212
18241
  var locate = /* @__PURE__ */ __name((database, accountId, emailId, where) => database.prepare(`INSERT OR REPLACE INTO email_locations (mailbox_id, uidvalidity, uid, email_id)
18213
18242
  SELECT id, ?, ?, ? FROM mailboxes WHERE account_id = ? AND external_id = ?`).run(where.uidvalidity, where.uid, emailId, accountId, where.folder), "locate");
18214
18243
  var folderEmails = /* @__PURE__ */ __name((database, accountId, folder, uidvalidity) => database.prepare(`SELECT l.uid, e.external_id, coalesce(e.received_at, e.sent_at) AS at, e.read, e.flagged,
@@ -18254,7 +18283,7 @@ var forgetLocations = /* @__PURE__ */ __name((database, accountId, folder, uidva
18254
18283
  leave.run(emailId, Number(box.id), emailId, Number(box.id));
18255
18284
  }, "forgetLocations");
18256
18285
 
18257
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
18286
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
18258
18287
  var recountEmailThread = /* @__PURE__ */ __name((database, threadId, now2) => database.prepare(`UPDATE email_threads SET
18259
18288
  emails_count = (SELECT count(*) FROM emails WHERE email_thread_id = ? AND deleted_at IS NULL),
18260
18289
  last_email_at = (SELECT max(coalesce(sent_at, received_at)) FROM emails
@@ -18304,7 +18333,7 @@ var markEmailsRestored = /* @__PURE__ */ __name((database, accountId, externalId
18304
18333
  return threads.length;
18305
18334
  }, "markEmailsRestored");
18306
18335
 
18307
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
18336
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
18308
18337
  var sorted = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(sorted) : value !== null && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key2) => [key2, sorted(value[key2])])) : value, "sorted");
18309
18338
  var conditionsKey = /* @__PURE__ */ __name((conditions) => JSON.stringify(sorted(conditions)), "conditionsKey");
18310
18339
  var ruleOf = /* @__PURE__ */ __name((row2) => ({
@@ -18371,7 +18400,7 @@ var mailRulesOver = /* @__PURE__ */ __name((database) => ({
18371
18400
  }
18372
18401
  }), "mailRulesOver");
18373
18402
 
18374
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
18403
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
18375
18404
  var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates, reason, now2) => {
18376
18405
  database.prepare(`INSERT INTO link_reviews (linkable_type, linkable_id, entity_type, candidates, reason, status, created_at, updated_at)
18377
18406
  VALUES (?, ?, ?, ?, ?, 'open', ?, ?)
@@ -18379,7 +18408,7 @@ var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates,
18379
18408
  reason = excluded.reason, updated_at = excluded.updated_at WHERE link_reviews.status = 'open'`).run(linkable.type, linkable.id, entity, JSON.stringify([...candidates].sort((a, b) => a - b)), reason, now2, now2);
18380
18409
  }, "reviewLink");
18381
18410
 
18382
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
18411
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
18383
18412
  function checkMeetingCancelled(signal) {
18384
18413
  if (!signal?.aborted)
18385
18414
  return;
@@ -18390,7 +18419,7 @@ function checkMeetingCancelled(signal) {
18390
18419
  }
18391
18420
  __name(checkMeetingCancelled, "checkMeetingCancelled");
18392
18421
 
18393
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
18422
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
18394
18423
  var meetingOf = /* @__PURE__ */ __name((row2) => ({
18395
18424
  id: Number(row2.id),
18396
18425
  accountId: Number(row2.account_id),
@@ -18440,7 +18469,7 @@ var transcriptRowOf = /* @__PURE__ */ __name((row2) => ({
18440
18469
  createdAt: Number(row2.created_at)
18441
18470
  }), "transcriptRowOf");
18442
18471
 
18443
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
18472
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
18444
18473
  var MEETING_TEXT = ["external_id", "title", "description", "location", "join_url", "timezone", "metadata"];
18445
18474
  var TRANSCRIPT_TEXT = ["source", "format", "language", "content_hash", "metadata"];
18446
18475
  var ROW_TEXT = ["speaker_name", "text", "normalized_text", "metadata"];
@@ -18607,7 +18636,7 @@ var meetingReadsOver = /* @__PURE__ */ __name(({ database }) => ({
18607
18636
  }
18608
18637
  }), "meetingReadsOver");
18609
18638
 
18610
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
18639
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
18611
18640
  var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
18612
18641
  const clauses = ["m.account_id=?", "m.deleted_at IS NULL"];
18613
18642
  const params = [input.accountId];
@@ -18650,7 +18679,7 @@ var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
18650
18679
  return { clauses, params };
18651
18680
  }, "meetingSelectionSql");
18652
18681
 
18653
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
18682
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
18654
18683
  var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
18655
18684
  async meetingChatLines(input) {
18656
18685
  checkMeetingCancelled(input.signal);
@@ -18678,7 +18707,7 @@ var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
18678
18707
  }
18679
18708
  }), "meetingChatLinesOver");
18680
18709
 
18681
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
18710
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
18682
18711
  var MESSAGE_FIELDS = {
18683
18712
  pk: messages.id,
18684
18713
  nativeId: messages.externalId,
@@ -18845,7 +18874,7 @@ var chatActivity = /* @__PURE__ */ __name(({ database }, accountKey, since, wher
18845
18874
  storedAt: toIso(Number(database.prepare("SELECT max(created_at) AS at FROM messages WHERE account_id = ?").get(accountKey)?.at) || null)
18846
18875
  }), "chatActivity");
18847
18876
 
18848
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
18877
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
18849
18878
  var HIT_FIELDS = {
18850
18879
  ...MESSAGE_FIELDS,
18851
18880
  chatTitle: sql`${chats.title}`.as("chat_title"),
@@ -18944,7 +18973,7 @@ var directReplies = /* @__PURE__ */ __name((context, parents, limit) => {
18944
18973
  };
18945
18974
  }, "directReplies");
18946
18975
 
18947
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
18976
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
18948
18977
  var identityRow = /* @__PURE__ */ __name(({ orm }, { provider, id: id2 }) => orm.select({ pk: identities.id, personPk: identityLinks.personId }).from(identities).innerJoin(identityLinks, eq(identityLinks.identityId, identities.id)).where(and(eq(identities.provider, provider), eq(identities.externalId, id2))).get(), "identityRow");
18949
18978
  var required = /* @__PURE__ */ __name((context, ref3) => {
18950
18979
  const found2 = identityRow(context, ref3);
@@ -19075,7 +19104,7 @@ var mentioning = /* @__PURE__ */ __name((context, accountKey, { id: id2, usernam
19075
19104
  }, "mentioning");
19076
19105
  var escaped = /* @__PURE__ */ __name((text5) => text5.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "escaped");
19077
19106
 
19078
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
19107
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
19079
19108
  var missing2 = /* @__PURE__ */ __name(() => {
19080
19109
  throw new CliError("not_found", "Meeting, participant or selected target not found");
19081
19110
  }, "missing");
@@ -19197,7 +19226,7 @@ function meetingContextLinksOver(context) {
19197
19226
  }
19198
19227
  __name(meetingContextLinksOver, "meetingContextLinksOver");
19199
19228
 
19200
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
19229
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
19201
19230
  var INDEX_CODES = { meeting_transcript_row: 1, meeting_chat_message: 2, meeting_summary: 3 };
19202
19231
  var meetingRowid = /* @__PURE__ */ __name((type, id2) => id2 * 4 + INDEX_CODES[type], "meetingRowid");
19203
19232
  var summaryOf = /* @__PURE__ */ __name((row2) => ({
@@ -19226,7 +19255,7 @@ var indexedText = /* @__PURE__ */ __name((database, type, id2) => {
19226
19255
  return row2 ? summaryText(summaryOf(row2)) : null;
19227
19256
  }, "indexedText");
19228
19257
 
19229
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
19258
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
19230
19259
  var summaryBytes = ["title", "overview", "sections", "next_steps", "content"].map((key2) => `coalesce(length(CAST(s.${key2} AS BLOB)),0)`).join("+");
19231
19260
  var meetingCurrentIndexRows = `
19232
19261
  SELECT 'meeting_transcript_row' AS indexable_type,r.id,r.id*4+1 AS rid,1 AS live,coalesce(length(CAST(r.text AS BLOB)),0) AS bytes FROM meeting_transcript_rows r JOIN meeting_transcripts t ON t.id=r.meeting_transcript_id JOIN meetings m ON m.id=t.meeting_id WHERE m.account_id=? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL
@@ -19257,7 +19286,7 @@ var invalidateMeetingStems = /* @__PURE__ */ __name((database, type, id2) => {
19257
19286
  }, "invalidateMeetingStems");
19258
19287
  var meetingStemmableText = /* @__PURE__ */ __name((text5) => text5.replace(/[\p{L}\p{N}\p{M}\p{Co}]+/gu, (token) => token.length <= 1024 ? token : ""), "meetingStemmableText");
19259
19288
 
19260
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
19289
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
19261
19290
  function meetingHitIndexOver({ database, now: now2 }) {
19262
19291
  return {
19263
19292
  async indexSearch(original) {
@@ -19325,10 +19354,10 @@ function meetingHitIndexOver({ database, now: now2 }) {
19325
19354
  }
19326
19355
  __name(meetingHitIndexOver, "meetingHitIndexOver");
19327
19356
 
19328
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
19357
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
19329
19358
  import { createHash as createHash4 } from "node:crypto";
19330
19359
 
19331
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/trigrams.js
19360
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/trigrams.js
19332
19361
  var trigrams = /* @__PURE__ */ __name((term) => {
19333
19362
  const padded = ` ${term} `;
19334
19363
  const pieces = /* @__PURE__ */ new Set();
@@ -19337,7 +19366,7 @@ var trigrams = /* @__PURE__ */ __name((term) => {
19337
19366
  return [...pieces];
19338
19367
  }, "trigrams");
19339
19368
 
19340
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/correct.js
19369
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/correct.js
19341
19370
  var SHORTEST_CORRECTION = 3;
19342
19371
  var maxEdits = /* @__PURE__ */ __name((word) => word.length <= 4 ? 1 : 2, "maxEdits");
19343
19372
  var editDistance = /* @__PURE__ */ __name((a, b, max) => {
@@ -19384,7 +19413,7 @@ var correctWords = /* @__PURE__ */ __name(async (vocabulary, words3) => {
19384
19413
  return corrections;
19385
19414
  }, "correctWords");
19386
19415
 
19387
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/garbled.js
19416
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/garbled.js
19388
19417
  var SHORTEST_GARBLED = 4;
19389
19418
  var MOST_WIDENED = 64;
19390
19419
  var plain = /* @__PURE__ */ __name((word) => word.replaceAll("\u044D", "\u0435"), "plain");
@@ -19476,7 +19505,7 @@ var widenWords = /* @__PURE__ */ __name((probes, vocabulary, stem, known2) => {
19476
19505
  return found2.map((words3) => words3.sort((a, b) => a.distance - b.distance || b.docs - a.docs || a.term.localeCompare(b.term)).slice(0, MOST_WIDENED).map((word) => word.term));
19477
19506
  }, "widenWords");
19478
19507
 
19479
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
19508
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
19480
19509
  import { readFileSync } from "node:fs";
19481
19510
  var loaded;
19482
19511
  var dictionary = /* @__PURE__ */ __name(() => {
@@ -19535,7 +19564,7 @@ var knownRussianWord = /* @__PURE__ */ __name((word) => {
19535
19564
  return false;
19536
19565
  }, "knownRussianWord");
19537
19566
 
19538
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
19567
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
19539
19568
  var WORD3 = /[\p{L}\p{N}\p{M}]+/gu;
19540
19569
  var MOST_WORDS = 128;
19541
19570
  var quote = /* @__PURE__ */ __name((word) => `"${word.replaceAll('"', '""')}"`, "quote");
@@ -19762,7 +19791,7 @@ var matchMeetingText = /* @__PURE__ */ __name((tree, text5, stemmer) => {
19762
19791
  return check3(tree);
19763
19792
  }, "matchMeetingText");
19764
19793
 
19765
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
19794
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
19766
19795
  var fail3 = /* @__PURE__ */ __name((message2) => {
19767
19796
  throw new CliError("validation_error", message2);
19768
19797
  }, "fail");
@@ -19939,7 +19968,7 @@ function meetingHitSearchOver({ database }) {
19939
19968
  }
19940
19969
  __name(meetingHitSearchOver, "meetingHitSearchOver");
19941
19970
 
19942
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
19971
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
19943
19972
  import { createHash as createHash5 } from "node:crypto";
19944
19973
  var cursorOf2 = /* @__PURE__ */ __name((value, key2) => {
19945
19974
  if (value === void 0)
@@ -20029,7 +20058,7 @@ var meetingParticipantSearchOver = /* @__PURE__ */ __name((context) => ({
20029
20058
  }
20030
20059
  }), "meetingParticipantSearchOver");
20031
20060
 
20032
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
20061
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
20033
20062
  var preparationQueries = {
20034
20063
  participants: {
20035
20064
  fields: "p.id, p.identity_id, p.display_name, l.person_id",
@@ -20079,7 +20108,7 @@ var preparationQueries = {
20079
20108
  }
20080
20109
  };
20081
20110
 
20082
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
20111
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
20083
20112
  var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
20084
20113
  async preparationContext(original) {
20085
20114
  const input = validateMeetingPreparationContext(original);
@@ -20093,7 +20122,7 @@ var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
20093
20122
  let total = 0;
20094
20123
  for (const key2 of keys) {
20095
20124
  const query = preparationQueries[key2];
20096
- const bytes3 = query.text.map((field3) => `coalesce(length(CAST(${field3} AS BLOB)),0)`).join("+");
20125
+ const bytes3 = query.text.map((field4) => `coalesce(length(CAST(${field4} AS BLOB)),0)`).join("+");
20097
20126
  const probe = database.prepare(`SELECT coalesce(sum(read_bytes),0) AS read_bytes FROM (SELECT ${bytes3} AS read_bytes ${query.from})`).get(...params(key2));
20098
20127
  total += Number(probe?.read_bytes);
20099
20128
  if (!Number.isSafeInteger(total) || total < 0 || total > maxReadBytes)
@@ -20120,7 +20149,7 @@ var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
20120
20149
  }
20121
20150
  }), "meetingPreparationContextOver");
20122
20151
 
20123
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
20152
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
20124
20153
  var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
20125
20154
  SELECT m.id FROM meetings m JOIN meeting_series s ON s.id=m.meeting_series_id
20126
20155
  WHERE m.id IN (${Array.from({ length: anchors }, () => "?").join(",")}) AND m.account_id=? AND s.account_id=?
@@ -20134,7 +20163,7 @@ var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
20134
20163
  JOIN main.projects p ON p.id=l.to_id WHERE p.account_id IS NULL AND p.deleted_at IS NULL
20135
20164
  )`, "preparationSubjects");
20136
20165
 
20137
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
20166
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
20138
20167
  var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => ({
20139
20168
  async preparationKnowledge(original) {
20140
20169
  const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
@@ -20179,7 +20208,7 @@ var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => (
20179
20208
  }
20180
20209
  }), "meetingPreparationKnowledgeOver");
20181
20210
 
20182
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
20211
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
20183
20212
  var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
20184
20213
  async preparationNotes(original) {
20185
20214
  const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
@@ -20232,7 +20261,7 @@ var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
20232
20261
  }
20233
20262
  }), "meetingPreparationNotesOver");
20234
20263
 
20235
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
20264
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
20236
20265
  var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
20237
20266
  async relatedHistory(original) {
20238
20267
  const input = validateMeetingRelatedHistory(original);
@@ -20303,7 +20332,7 @@ var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
20303
20332
  }
20304
20333
  }), "meetingRelatedHistoryOver");
20305
20334
 
20306
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
20335
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
20307
20336
  var number2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "number");
20308
20337
  var text2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : String(value), "text");
20309
20338
  var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
@@ -20384,7 +20413,7 @@ var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
20384
20413
  }
20385
20414
  }), "meetingReviewOver");
20386
20415
 
20387
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
20416
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
20388
20417
  var bytes2 = "length(CAST(external_id AS BLOB)) + coalesce(length(CAST(title AS BLOB)), 0)";
20389
20418
  var ensureBytes2 = /* @__PURE__ */ __name((size2, budget) => {
20390
20419
  if (!Number.isSafeInteger(size2) || size2 < 0 || size2 > budget)
@@ -20438,7 +20467,7 @@ var meetingSeriesHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
20438
20467
  }
20439
20468
  }), "meetingSeriesHistoryOver");
20440
20469
 
20441
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
20470
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
20442
20471
  var MOST_ROWS = 5e5;
20443
20472
  var meetingStatsOver = /* @__PURE__ */ __name(({ database }) => ({
20444
20473
  async meetingStats(input) {
@@ -20485,7 +20514,7 @@ var meetingStatsOver = /* @__PURE__ */ __name(({ database }) => ({
20485
20514
  }
20486
20515
  }), "meetingStatsOver");
20487
20516
 
20488
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
20517
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
20489
20518
  var CURSOR_KEY = "meetings";
20490
20519
  var seriesOf2 = /* @__PURE__ */ __name((row2) => ({
20491
20520
  id: Number(row2.id),
@@ -21037,7 +21066,33 @@ var meetingStoreOver = /* @__PURE__ */ __name((context) => {
21037
21066
  };
21038
21067
  }, "meetingStoreOver");
21039
21068
 
21040
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
21069
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
21070
+ var syncStateOf = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
21071
+ const row2 = orm.select({ value: syncCursors.value, at: syncCursors.updatedAt }).from(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).get();
21072
+ return row2 ? { value: row2.value, at: toIso(row2.at) } : void 0;
21073
+ }, "syncStateOf");
21074
+ var writeState = /* @__PURE__ */ __name(({ orm, now: now2 }, accountKey, name, value) => {
21075
+ orm.insert(syncCursors).values({ accountId: accountKey, key: name, value, createdAt: now2(), updatedAt: now2() }).onConflictDoUpdate({
21076
+ target: [syncCursors.accountId, syncCursors.key],
21077
+ set: { value: sql`excluded.value`, updatedAt: sql`excluded.updated_at` }
21078
+ }).run();
21079
+ }, "writeState");
21080
+ var clearState = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
21081
+ orm.delete(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).run();
21082
+ }, "clearState");
21083
+ var claim2 = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, anchor, holder, forMs) => {
21084
+ const at = now2();
21085
+ return orm.insert(fetchLeases).values({ chatId: chatKey, anchor, holder, expiresAt: at + forMs }).onConflictDoUpdate({
21086
+ target: [fetchLeases.chatId, fetchLeases.anchor],
21087
+ set: { holder: sql`excluded.holder`, expiresAt: sql`excluded.expires_at` },
21088
+ setWhere: or(eq(fetchLeases.holder, sql`excluded.holder`), lte(fetchLeases.expiresAt, at))
21089
+ }).returning({ chatId: fetchLeases.chatId }).all().length > 0;
21090
+ }, "claim");
21091
+ var release = /* @__PURE__ */ __name(({ orm }, chatKey, anchor, holder) => {
21092
+ orm.delete(fetchLeases).where(and(eq(fetchLeases.chatId, chatKey), eq(fetchLeases.anchor, anchor), eq(fetchLeases.holder, holder))).run();
21093
+ }, "release");
21094
+
21095
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
21041
21096
  var threadConversation = /* @__PURE__ */ __name((place, builtAt) => ({
21042
21097
  id: `email:${place.emailId}`,
21043
21098
  chatId: place.threadExternalId,
@@ -21190,9 +21245,9 @@ var saveEmail = /* @__PURE__ */ __name((database, orm, accountId, threadId, mail
21190
21245
  ["metadata", "metadata", toJson],
21191
21246
  ["mailRuleId", "mail_rule_id", (v) => v]
21192
21247
  ];
21193
- for (const [field3, column2, encode] of optional)
21194
- if (mail[field3] !== void 0)
21195
- values.push([column2, encode(mail[field3])]);
21248
+ for (const [field4, column2, encode] of optional)
21249
+ if (mail[field4] !== void 0)
21250
+ values.push([column2, encode(mail[field4])]);
21196
21251
  const found2 = database.prepare("SELECT id, email_thread_id FROM emails WHERE account_id = ? AND external_id = ?").get(accountId, mail.externalId);
21197
21252
  let emailId;
21198
21253
  if (found2) {
@@ -21202,13 +21257,13 @@ var saveEmail = /* @__PURE__ */ __name((database, orm, accountId, threadId, mail
21202
21257
  const columns = ["account_id", "external_id", ...values.map(([c]) => c), "created_at", "updated_at"];
21203
21258
  emailId = Number(database.prepare(`INSERT INTO emails (${columns.join(", ")}) VALUES (${columns.map(() => "?").join(", ")}) RETURNING id`).get(accountId, mail.externalId, ...values.map(([, v]) => v), now2, now2)?.id);
21204
21259
  }
21205
- if (ROLES.some(([field3]) => mail[field3] !== void 0)) {
21260
+ if (ROLES.some(([field4]) => mail[field4] !== void 0)) {
21206
21261
  database.prepare("DELETE FROM email_recipients WHERE email_id = ?").run(emailId);
21207
21262
  const insert = database.prepare(`INSERT INTO email_recipients (email_id, identity_id, address, name, role, position, created_at, updated_at)
21208
21263
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`);
21209
21264
  let position2 = 0;
21210
- for (const [field3, role] of ROLES)
21211
- for (const recipient2 of mail[field3] ?? []) {
21265
+ for (const [field4, role] of ROLES)
21266
+ for (const recipient2 of mail[field4] ?? []) {
21212
21267
  const address = recipient2.address.trim().toLowerCase();
21213
21268
  const identity = addressIdentity(database, orm, accountId, recipient2, now2);
21214
21269
  insert.run(emailId, identity, address, recipient2.name, role, position2++, now2, now2);
@@ -21370,12 +21425,21 @@ var emailHitsByPk = /* @__PURE__ */ __name((database, pks) => {
21370
21425
  ];
21371
21426
  });
21372
21427
  }, "emailHitsByPk");
21373
- var mailStoreOver = /* @__PURE__ */ __name(({ database, orm }, stemmerFor2 = stemmerCache()) => ({
21428
+ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm, now: now2 }, stemmerFor2 = stemmerCache()) => ({
21374
21429
  rules: mailRulesOver(database),
21375
21430
  async saveThread(input) {
21376
21431
  const id2 = write(database, () => saveThread(database, orm, input));
21377
21432
  return threadDetails(database, id2);
21378
21433
  },
21434
+ async saveThreads(inputs, states = []) {
21435
+ const ids = write(database, () => {
21436
+ const saved = inputs.map((input) => saveThread(database, orm, input));
21437
+ for (const { accountId, name, value } of states)
21438
+ writeState({ orm, now: now2 }, accountId, name, value);
21439
+ return saved;
21440
+ });
21441
+ return ids.map((id2) => threadDetails(database, id2));
21442
+ },
21379
21443
  async threads(filter = {}) {
21380
21444
  const [limit, offset] = page(filter);
21381
21445
  return database.prepare(`SELECT * FROM email_threads WHERE (? IS NULL OR account_id = ?) AND (? OR deleted_at IS NULL)
@@ -21434,7 +21498,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm }, stemmerFor2 = ste
21434
21498
  dmarc: str(row2.dmarc)
21435
21499
  }));
21436
21500
  },
21437
- async setSenderScores(accountId, scores, now2) {
21501
+ async setSenderScores(accountId, scores, now3) {
21438
21502
  return write(database, () => {
21439
21503
  const link3 = database.prepare(`INSERT INTO account_identities
21440
21504
  (account_id, identity_id, created_at, updated_at, mail_score, mail_signals, mail_scored_at, mail_demoted)
@@ -21443,7 +21507,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm }, stemmerFor2 = ste
21443
21507
  mail_signals = excluded.mail_signals, mail_scored_at = excluded.mail_scored_at,
21444
21508
  mail_demoted = excluded.mail_demoted`);
21445
21509
  for (const { address, score, signals, demoted } of scores)
21446
- link3.run(accountId, identityOf2(database, { address, name: null }, now2), now2, now2, score, JSON.stringify(signals), now2, demoted ? 1 : null);
21510
+ link3.run(accountId, identityOf2(database, { address, name: null }, now3), now3, now3, score, JSON.stringify(signals), now3, demoted ? 1 : null);
21447
21511
  return scores.length;
21448
21512
  });
21449
21513
  },
@@ -21456,9 +21520,9 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm }, stemmerFor2 = ste
21456
21520
  kind: str(b.kind)
21457
21521
  }));
21458
21522
  },
21459
- async setMailboxes(accountId, scanned, found2, now2) {
21523
+ async setMailboxes(accountId, scanned, found2, now3) {
21460
21524
  return write(database, () => {
21461
- const boxes = new Map(scanned.map((box) => [box.externalId, mailboxPk(database, accountId, box, now2)]));
21525
+ const boxes = new Map(scanned.map((box) => [box.externalId, mailboxPk(database, accountId, box, now3)]));
21462
21526
  const lookup = database.prepare("SELECT id FROM emails WHERE account_id = ? AND external_id = ?");
21463
21527
  const leave = database.prepare(`DELETE FROM email_mailboxes WHERE email_id = ? AND mailbox_id IN (SELECT value FROM json_each(?))
21464
21528
  AND mailbox_id NOT IN (SELECT value FROM json_each(?))`);
@@ -21475,22 +21539,22 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm }, stemmerFor2 = ste
21475
21539
  });
21476
21540
  leave.run(Number(row2.id), JSON.stringify([...boxes.values()]), JSON.stringify(kept));
21477
21541
  for (const pk of kept)
21478
- join(database, Number(row2.id), pk, now2);
21542
+ join(database, Number(row2.id), pk, now3);
21479
21543
  count++;
21480
21544
  }
21481
21545
  return count;
21482
21546
  });
21483
21547
  },
21484
- async setFlags(accountId, flags, now2) {
21548
+ async setFlags(accountId, flags, now3) {
21485
21549
  return write(database, () => {
21486
- return setEmailFlags(database, accountId, flags, now2);
21550
+ return setEmailFlags(database, accountId, flags, now3);
21487
21551
  });
21488
21552
  },
21489
21553
  folderEmails: /* @__PURE__ */ __name(async (accountId, folder, uidvalidity) => folderEmails(database, accountId, folder, uidvalidity), "folderEmails"),
21490
21554
  setLocations: /* @__PURE__ */ __name(async (accountId, folder, uidvalidity, found2) => write(database, () => setLocations(database, accountId, folder, uidvalidity, found2)), "setLocations"),
21491
21555
  forgetLocations: /* @__PURE__ */ __name(async (accountId, folder, uidvalidity, uids) => write(database, () => forgetLocations(database, accountId, folder, uidvalidity, uids)), "forgetLocations"),
21492
- markDeleted: /* @__PURE__ */ __name(async (accountId, externalIds, now2) => write(database, () => markEmailsDeleted(database, accountId, externalIds, now2)), "markDeleted"),
21493
- markRestored: /* @__PURE__ */ __name(async (accountId, externalIds, now2) => write(database, () => markEmailsRestored(database, accountId, externalIds, now2)), "markRestored"),
21556
+ markDeleted: /* @__PURE__ */ __name(async (accountId, externalIds, now3) => write(database, () => markEmailsDeleted(database, accountId, externalIds, now3)), "markDeleted"),
21557
+ markRestored: /* @__PURE__ */ __name(async (accountId, externalIds, now3) => write(database, () => markEmailsRestored(database, accountId, externalIds, now3)), "markRestored"),
21494
21558
  async chunksToEmbed(model, { after: after2, limit }) {
21495
21559
  drainEmailIndex(database, stemmerFor2);
21496
21560
  const file = database.prepare("SELECT text FROM attachments WHERE id = ?");
@@ -21585,7 +21649,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm }, stemmerFor2 = ste
21585
21649
  }
21586
21650
  }), "mailStoreOver");
21587
21651
 
21588
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/search/dictionary.js
21652
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/search/dictionary.js
21589
21653
  import { readFileSync as readFileSync2 } from "node:fs";
21590
21654
  var DICTIONARIES = Object.fromEntries(LANGUAGES.map(({ name, dictionary: dictionary3 }) => [name, dictionary3]));
21591
21655
  var folded4 = /* @__PURE__ */ __name((word) => /^[а-яё'-]*$/.test(word) ? word.replaceAll("\u0451", "\u0435").replaceAll("\u0439", "\u0438") : fold(word), "folded");
@@ -21675,7 +21739,7 @@ var knownWord = /* @__PURE__ */ __name((languages) => {
21675
21739
  }, "knownWord");
21676
21740
  var dictionaryLanguages = /* @__PURE__ */ __name((stemmers) => [stemmers.cyrillic, ...stemmers.latin.split(",")].filter((name) => Object.hasOwn(DICTIONARIES, name)), "dictionaryLanguages");
21677
21741
 
21678
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
21742
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
21679
21743
  var predicates = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? [node] : node.clauses.flatMap(({ node: node2 }) => predicates(node2)), "predicates");
21680
21744
  var readsTranscripts = /* @__PURE__ */ __name((node) => (node.operator === "term" || node.operator === "phrase") && /[\p{L}\p{N}]/u.test(normalize(node.value)) && (node.field === "transcript" || node.implicit === true && (node.field === "text" || node.field === "exact")), "readsTranscripts");
21681
21745
  var LATIN_NUMBERS = new Set(`zero one two three four five six seven eight nine ten eleven twelve twenty thirty forty fifty sixty seventy
@@ -21761,7 +21825,7 @@ var spokenTranscripts = /* @__PURE__ */ __name((database, item, speaking, keys)
21761
21825
  return found2;
21762
21826
  }, "spokenTranscripts");
21763
21827
 
21764
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
21828
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
21765
21829
  var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, found2, pks) => {
21766
21830
  const placeLeaves = leaves.filter(({ node }) => (node.operator === "term" || node.operator === "phrase") && (node.implicit || node.field === "content" || node.field === "transcript"));
21767
21831
  if (!placeLeaves.length || !pks.length || found2.length !== pks.length)
@@ -21808,7 +21872,7 @@ var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, f
21808
21872
  });
21809
21873
  }, "placeHits");
21810
21874
 
21811
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
21875
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
21812
21876
  var MESSAGES2 = {
21813
21877
  rows: "messages",
21814
21878
  threads: "chats",
@@ -21844,17 +21908,18 @@ var GROUPS = {
21844
21908
  var matchQuery = /* @__PURE__ */ __name((context, execution) => runQuery(context, execution), "matchQuery");
21845
21909
  var countQuery = /* @__PURE__ */ __name((context, execution, by) => runQuery(context, execution, by), "countQuery");
21846
21910
  var queryMessagePks = /* @__PURE__ */ __name((context, execution) => runQuery(context, execution, "pks"), "queryMessagePks");
21847
- var countMatches = /* @__PURE__ */ __name((context, execution, cap) => {
21911
+ var countMatches = /* @__PURE__ */ __name((context, execution, cap) => matchingPks(context, execution, cap)?.length, "countMatches");
21912
+ var matchingPks = /* @__PURE__ */ __name((context, execution, cap) => {
21848
21913
  const { database, check: check3, where, from: from2, withRanking, ranked, leaves } = compileQuery(context, {
21849
21914
  ...execution,
21850
21915
  newest: true
21851
21916
  });
21852
21917
  if (leaves.some(({ test }) => test))
21853
21918
  return void 0;
21854
- const row2 = database.prepare(`SELECT count(*) AS n FROM (${withRanking}SELECT m.id ${from2} WHERE ${where.sql} LIMIT ?)`).get(...ranked.params, ...where.params, cap + 1);
21919
+ const rows = database.prepare(`${withRanking}SELECT m.id ${from2} WHERE ${where.sql} LIMIT ?`).all(...ranked.params, ...where.params, cap + 1);
21855
21920
  check3();
21856
- return Number(row2?.n ?? 0);
21857
- }, "countMatches");
21921
+ return rows.map(({ id: id2 }) => Number(id2));
21922
+ }, "matchingPks");
21858
21923
  var compileQuery = /* @__PURE__ */ __name((context, execution, boundedAttachments = false) => {
21859
21924
  const { database } = context;
21860
21925
  const corpus = execution.corpus === "mail" ? MAIL : MESSAGES2;
@@ -22281,7 +22346,7 @@ var runQuery = /* @__PURE__ */ __name(async (context, execution, by) => {
22281
22346
  };
22282
22347
  }, "runQuery");
22283
22348
 
22284
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
22349
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
22285
22350
  function invalidMetadata() {
22286
22351
  throw new CliError("validation_error", "stored counter metadata is malformed \u2014 check the store before refreshing");
22287
22352
  }
@@ -22319,10 +22384,10 @@ var counterStates = /* @__PURE__ */ __name(({ database }, messagePk, now2, maxAg
22319
22384
  }, "counterStates");
22320
22385
  var applyCounterObservations = /* @__PURE__ */ __name((context, messagePk, observations) => {
22321
22386
  const { database, now: now2 } = context;
22322
- const validated = Object.entries(observations).map(([field3, observation]) => {
22323
- if (!COUNTER_FIELDS.includes(field3) || !observation)
22387
+ const validated = Object.entries(observations).map(([field4, observation]) => {
22388
+ if (!COUNTER_FIELDS.includes(field4) || !observation)
22324
22389
  throw new CliError("validation_error", "unknown counter observation field");
22325
- return { field: field3, observation, at: counterObservationTime(observation, now2()) };
22390
+ return { field: field4, observation, at: counterObservationTime(observation, now2()) };
22326
22391
  });
22327
22392
  if (!validated.length)
22328
22393
  return 0;
@@ -22344,20 +22409,20 @@ var applyCounterObservations = /* @__PURE__ */ __name((context, messagePk, obser
22344
22409
  const metadata3 = validated.some((one) => one.field !== "reactions") ? object(message2.metadata) : {};
22345
22410
  let reactions = message2.reactions === null ? null : String(message2.reactions);
22346
22411
  let updated = 0;
22347
- for (const { field: field3, observation, at } of validated) {
22348
- const existing = database.prepare("SELECT value,created_at FROM message_counter_observations WHERE message_id=? AND counter=?").get(messagePk, field3);
22412
+ for (const { field: field4, observation, at } of validated) {
22413
+ const existing = database.prepare("SELECT value,created_at FROM message_counter_observations WHERE message_id=? AND counter=?").get(messagePk, field4);
22349
22414
  const oldWins = existing && Number(existing.created_at) > at;
22350
22415
  const value = oldWins ? Number(existing.value) : observation.value;
22351
- if (field3 === "reactions") {
22416
+ if (field4 === "reactions") {
22352
22417
  if (!oldWins && observation.reactions)
22353
22418
  reactions = JSON.stringify(observation.reactions);
22354
22419
  else
22355
22420
  reactions = JSON.stringify({ total: value, mine: null, counts: [] });
22356
22421
  } else
22357
- metadata3[field3] = value;
22422
+ metadata3[field4] = value;
22358
22423
  if (oldWins)
22359
22424
  continue;
22360
- database.prepare("INSERT INTO message_counter_observations(message_id,counter,value,created_at,source) VALUES(?,?,?,?,?) ON CONFLICT(message_id,counter) DO UPDATE SET value=excluded.value,created_at=excluded.created_at,source=excluded.source").run(messagePk, field3, value, at, observation.source);
22425
+ database.prepare("INSERT INTO message_counter_observations(message_id,counter,value,created_at,source) VALUES(?,?,?,?,?) ON CONFLICT(message_id,counter) DO UPDATE SET value=excluded.value,created_at=excluded.created_at,source=excluded.source").run(messagePk, field4, value, at, observation.source);
22361
22426
  updated++;
22362
22427
  }
22363
22428
  if (validated.length)
@@ -22383,7 +22448,7 @@ var counterTargets = /* @__PURE__ */ __name((context, execution, options) => wit
22383
22448
  };
22384
22449
  }), "counterTargets");
22385
22450
 
22386
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
22451
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
22387
22452
  var NOT_FILE_LIST = [...NOT_FILES].map((kind3) => `'${kind3}'`).join(",");
22388
22453
  var fileAttachments = /* @__PURE__ */ __name(({ database }, accountKey, { chatKey, messageId, beforePk, limit }) => database.prepare(`SELECT att.id AS pk, c.external_id AS chat_id, m.external_id AS message_id, att.position, att.kind, att.name, att.mime,
22389
22454
  att.size, att.local_path, att.extraction AS origin, att.size AS read_bytes, att.extraction_error AS error, att.content_sha256, att.extractor
@@ -22502,7 +22567,7 @@ var attachmentViews = /* @__PURE__ */ __name(({ database }, accountKey, { chatKe
22502
22567
  }));
22503
22568
  }, "attachmentViews");
22504
22569
 
22505
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
22570
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
22506
22571
  var transcript = /* @__PURE__ */ __name(({ orm }, chatKey, messageId) => orm.select({ text: messageTranscripts.text, source: messageTranscripts.source }).from(messageTranscripts).where(and(eq(messageTranscripts.chatId, chatKey), eq(messageTranscripts.messageExternalId, messageId))).get(), "transcript");
22507
22572
  var keepTranscript = /* @__PURE__ */ __name((context, chatKey, messageId, text5, source2) => {
22508
22573
  const { orm, database, now: now2 } = context;
@@ -22540,7 +22605,7 @@ var intoVoiceAttachment = /* @__PURE__ */ __name((context, messagePk) => {
22540
22605
  keepText(context, Number(row2.id), { text: String(row2.text), origin: "extracted", extractor: `speech:${row2.source}` });
22541
22606
  }, "intoVoiceAttachment");
22542
22607
 
22543
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
22608
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
22544
22609
  var FIELDS = [
22545
22610
  "threadExternalId",
22546
22611
  "senderIdentityId",
@@ -22661,9 +22726,9 @@ var upsertMessage = /* @__PURE__ */ __name((context, key2, accountKey, chatKey,
22661
22726
  const previous = JSON.parse(found2.providerMetadata);
22662
22727
  const incoming = JSON.parse(String(fields4.metadata ?? "{}"));
22663
22728
  if (previous && incoming && !Array.isArray(previous) && !Array.isArray(incoming)) {
22664
- for (const field3 of ["views", "comments"])
22665
- if (!validCounter(incoming[field3]) && validCounter(previous[field3]))
22666
- incoming[field3] = previous[field3];
22729
+ for (const field4 of ["views", "comments"])
22730
+ if (!validCounter(incoming[field4]) && validCounter(previous[field4]))
22731
+ incoming[field4] = previous[field4];
22667
22732
  fields4.metadata = JSON.stringify(edit ? { ...previous, ...incoming } : incoming);
22668
22733
  }
22669
22734
  } catch {
@@ -22857,33 +22922,7 @@ var writeDerivedReactions = /* @__PURE__ */ __name((context, chatKey, messageId)
22857
22922
  reactionStatementsOf(context.database).total.run(JSON.stringify(derived), chatKey, messageId);
22858
22923
  }, "writeDerivedReactions");
22859
22924
 
22860
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
22861
- var syncStateOf = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
22862
- const row2 = orm.select({ value: syncCursors.value, at: syncCursors.updatedAt }).from(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).get();
22863
- return row2 ? { value: row2.value, at: toIso(row2.at) } : void 0;
22864
- }, "syncStateOf");
22865
- var writeState = /* @__PURE__ */ __name(({ orm, now: now2 }, accountKey, name, value) => {
22866
- orm.insert(syncCursors).values({ accountId: accountKey, key: name, value, createdAt: now2(), updatedAt: now2() }).onConflictDoUpdate({
22867
- target: [syncCursors.accountId, syncCursors.key],
22868
- set: { value: sql`excluded.value`, updatedAt: sql`excluded.updated_at` }
22869
- }).run();
22870
- }, "writeState");
22871
- var clearState = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
22872
- orm.delete(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).run();
22873
- }, "clearState");
22874
- var claim2 = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, anchor, holder, forMs) => {
22875
- const at = now2();
22876
- return orm.insert(fetchLeases).values({ chatId: chatKey, anchor, holder, expiresAt: at + forMs }).onConflictDoUpdate({
22877
- target: [fetchLeases.chatId, fetchLeases.anchor],
22878
- set: { holder: sql`excluded.holder`, expiresAt: sql`excluded.expires_at` },
22879
- setWhere: or(eq(fetchLeases.holder, sql`excluded.holder`), lte(fetchLeases.expiresAt, at))
22880
- }).returning({ chatId: fetchLeases.chatId }).all().length > 0;
22881
- }, "claim");
22882
- var release = /* @__PURE__ */ __name(({ orm }, chatKey, anchor, holder) => {
22883
- orm.delete(fetchLeases).where(and(eq(fetchLeases.chatId, chatKey), eq(fetchLeases.anchor, anchor), eq(fetchLeases.holder, holder))).run();
22884
- }, "release");
22885
-
22886
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/keys.js
22925
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/keys.js
22887
22926
  var keysOver = /* @__PURE__ */ __name((context) => {
22888
22927
  const findAccountPk2 = /* @__PURE__ */ __name((key2) => findAccountPk(context, key2), "findAccountPk");
22889
22928
  const findChatPk2 = /* @__PURE__ */ __name((accountKey, chatId) => findChatPk(context, accountKey, chatId), "findChatPk");
@@ -22904,7 +22943,7 @@ var keysOver = /* @__PURE__ */ __name((context) => {
22904
22943
  };
22905
22944
  }, "keysOver");
22906
22945
 
22907
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
22946
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
22908
22947
  var accountGroupsOf = /* @__PURE__ */ __name((database) => {
22909
22948
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(ACCOUNT_GROUPS);
22910
22949
  if (!row2)
@@ -22939,7 +22978,7 @@ var saveProfile = /* @__PURE__ */ __name((database, app, profile, key2, now2) =>
22939
22978
  database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(PROFILES, JSON.stringify(profiles), now2);
22940
22979
  }, "saveProfile");
22941
22980
 
22942
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
22981
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
22943
22982
  var BOT_KINDS = ["agent", "script", "integration"];
22944
22983
  var ownerPerson = /* @__PURE__ */ __name((database) => {
22945
22984
  const found2 = database.prepare("SELECT id FROM persons WHERE owner = 1 ORDER BY id LIMIT 1").get();
@@ -22975,7 +23014,7 @@ var originOfActor = /* @__PURE__ */ __name((database, type, id2) => {
22975
23014
  return database.prepare("SELECT name FROM bots WHERE id = ?").get(Number(id2))?.name === "rule" ? "rule" : "agent";
22976
23015
  }, "originOfActor");
22977
23016
 
22978
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
23017
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
22979
23018
  var linkOwnIdentities = /* @__PURE__ */ __name((context) => {
22980
23019
  const owner = ownerPerson(context.database).id;
22981
23020
  const strays = context.database.prepare("SELECT DISTINCT l.person_id AS person FROM identity_links l JOIN identities i ON i.id = l.identity_id JOIN accounts a ON a.provider = i.provider AND a.external_id = i.external_id WHERE l.person_id <> ?").all(owner);
@@ -22996,7 +23035,7 @@ var linkToOwner = /* @__PURE__ */ __name((context, ref3) => {
22996
23035
  return personOf(context, ref3);
22997
23036
  }, "linkToOwner");
22998
23037
 
22999
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
23038
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
23000
23039
  var PROVIDERS_SETTING = "providers";
23001
23040
  var storedProvidersOf = /* @__PURE__ */ __name((database) => {
23002
23041
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(PROVIDERS_SETTING);
@@ -23031,7 +23070,7 @@ var registerProvider = /* @__PURE__ */ __name((database, value, now2) => {
23031
23070
  });
23032
23071
  }, "registerProvider");
23033
23072
 
23034
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
23073
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
23035
23074
  var DAY3 = 864e5;
23036
23075
  var RECENTLY_CLOSED_MS = 14 * DAY3;
23037
23076
  var TEXT_LIMIT = 20;
@@ -23170,7 +23209,7 @@ var taskSimilarityOver = /* @__PURE__ */ __name((context) => {
23170
23209
  drainCorpus(database, CORPORA.task, stemmerFor2);
23171
23210
  const stemmer = stemmerFor2(storeStemmers(database) ?? DEFAULT_STEMMERS);
23172
23211
  const since = now2() - RECENTLY_CLOSED_MS;
23173
- const live2 = "t.project_id = ? AND t.deleted_at IS NULL AND t.id <> ? AND (t.status = 'open' OR t.closed_at >= ?)";
23212
+ const live2 = "t.project_id = ? AND t.deleted_at IS NULL AND t.id <> ? AND (t.status NOT IN ('done', 'dismissed') OR t.closed_at >= ?)";
23174
23213
  const scope3 = [side.project, side.row ?? -1, since];
23175
23214
  const found2 = /* @__PURE__ */ new Map();
23176
23215
  const add = /* @__PURE__ */ __name((id2, by) => found2.set(id2, (found2.get(id2) ?? /* @__PURE__ */ new Set()).add(by)), "add");
@@ -23230,7 +23269,7 @@ var taskSimilarityOver = /* @__PURE__ */ __name((context) => {
23230
23269
  };
23231
23270
  }, "taskSimilarityOver");
23232
23271
 
23233
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
23272
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
23234
23273
  var SETTING3 = "taskCategories";
23235
23274
  var savedTaskCategories = /* @__PURE__ */ __name((database) => {
23236
23275
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING3);
@@ -23239,7 +23278,7 @@ var savedTaskCategories = /* @__PURE__ */ __name((database) => {
23239
23278
  var storeTaskCategories = /* @__PURE__ */ __name((database) => savedTaskCategories(database) ?? DEFAULT_TASK_CATEGORIES, "storeTaskCategories");
23240
23279
  var unlistedTaskCategories = /* @__PURE__ */ __name((database, list) => {
23241
23280
  const listed = new Set(list.map(({ name }) => name));
23242
- return database.prepare("SELECT category, COUNT(*) AS total, SUM(status = 'open') AS open FROM tasks WHERE category IS NOT NULL AND deleted_at IS NULL GROUP BY category ORDER BY category").all().map((row2) => ({ name: String(row2.category), open: Number(row2.open), total: Number(row2.total) })).filter(({ name }) => !listed.has(name));
23281
+ return database.prepare("SELECT category, COUNT(*) AS total, SUM(status NOT IN ('done', 'dismissed')) AS open FROM tasks WHERE category IS NOT NULL AND deleted_at IS NULL GROUP BY category ORDER BY category").all().map((row2) => ({ name: String(row2.category), open: Number(row2.open), total: Number(row2.total) })).filter(({ name }) => !listed.has(name));
23243
23282
  }, "unlistedTaskCategories");
23244
23283
  var saveTaskCategories = /* @__PURE__ */ __name((database, categories, now2) => {
23245
23284
  if (categories === void 0) {
@@ -23249,7 +23288,7 @@ var saveTaskCategories = /* @__PURE__ */ __name((database, categories, now2) =>
23249
23288
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(SETTING3, JSON.stringify(categories), now2);
23250
23289
  }, "saveTaskCategories");
23251
23290
 
23252
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
23291
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
23253
23292
  var DEFAULT_AGENT_CLOSE = { allowed: true, min: 0.8 };
23254
23293
  var ALLOWED = "taskAgentClose";
23255
23294
  var MIN = "taskAgentCloseMin";
@@ -23305,7 +23344,7 @@ var SUGGESTION_COLUMNS = [
23305
23344
  ];
23306
23345
  var CLEAR_SUGGESTION = SUGGESTION_COLUMNS.map((column2) => `${column2} = NULL`).join(", ");
23307
23346
 
23308
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
23347
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
23309
23348
  var EXCERPT_CHARS = 280;
23310
23349
  var excerptOf = /* @__PURE__ */ __name((text5) => {
23311
23350
  if (text5 == null)
@@ -23348,7 +23387,7 @@ var evidenceSourcesOf = /* @__PURE__ */ __name((database, from2) => database.pre
23348
23387
  };
23349
23388
  }), "evidenceSourcesOf");
23350
23389
 
23351
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/attachments/limits.js
23390
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/attachments/limits.js
23352
23391
  var MAX_FILE_BYTES = 50 * 1024 * 1024;
23353
23392
  var MAX_TEXT_CHARS = 2e6;
23354
23393
  var ATTACHMENT_LIMIT_ENV = [
@@ -23374,7 +23413,7 @@ var pdfPreviewLimits = /* @__PURE__ */ __name((env = process.env) => {
23374
23413
  return { pixels, bytes: positive(env, "MESSAGING_PDF_PREVIEW_MAX_MIB", 8 * 1024 * 1024, 1024 * 1024) };
23375
23414
  }, "pdfPreviewLimits");
23376
23415
 
23377
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/ulid.js
23416
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/ulid.js
23378
23417
  import { randomBytes } from "node:crypto";
23379
23418
  var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
23380
23419
  var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
@@ -23387,16 +23426,16 @@ var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
23387
23426
  return time3 + random;
23388
23427
  }, "ulid");
23389
23428
 
23390
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
23429
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
23391
23430
  var FOLDED_FIELDS = ["title", "site", "language", "author"];
23392
23431
  var encodeDocumentMetadata = /* @__PURE__ */ __name((meta, sections) => {
23393
23432
  if (!meta && !sections?.length)
23394
23433
  return null;
23395
23434
  const folded5 = {};
23396
- for (const field3 of FOLDED_FIELDS) {
23397
- const value = meta?.[field3];
23435
+ for (const field4 of FOLDED_FIELDS) {
23436
+ const value = meta?.[field4];
23398
23437
  if (typeof value === "string" && value !== "")
23399
- folded5[field3] = normalize(value);
23438
+ folded5[field4] = normalize(value);
23400
23439
  }
23401
23440
  const keywords = meta?.keywords;
23402
23441
  if (Array.isArray(keywords) && keywords.length)
@@ -23408,7 +23447,7 @@ var languageOf = /* @__PURE__ */ __name((meta) => {
23408
23447
  return typeof language === "string" && language !== "" ? language : null;
23409
23448
  }, "languageOf");
23410
23449
 
23411
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
23450
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
23412
23451
  var isObject = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isObject");
23413
23452
  var objectOf = /* @__PURE__ */ __name((value) => {
23414
23453
  if (isObject(value))
@@ -23651,7 +23690,7 @@ var filesStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
23651
23690
  };
23652
23691
  }, "filesStoreOver");
23653
23692
 
23654
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
23693
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
23655
23694
  var IMPORTED_DOCUMENT_QUERY = defineQuery({
23656
23695
  entity: "document",
23657
23696
  backend: "sql",
@@ -23697,7 +23736,7 @@ var importedDocumentWhere = /* @__PURE__ */ __name((database, query) => {
23697
23736
  return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns);
23698
23737
  }, "importedDocumentWhere");
23699
23738
 
23700
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
23739
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
23701
23740
  var NOTE_FORMATS = ["obsidian", "markdown"];
23702
23741
  var iso2 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
23703
23742
  var optionalIso = /* @__PURE__ */ __name((value) => value == null ? null : iso2(value), "optionalIso");
@@ -24207,7 +24246,7 @@ var notesStoreOver = /* @__PURE__ */ __name((context) => {
24207
24246
  };
24208
24247
  }, "notesStoreOver");
24209
24248
 
24210
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
24249
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
24211
24250
  var NAMED = "SELECT m.*, b.name AS author_name FROM memories m LEFT JOIN bots b ON m.author_type = 'bot' AND b.id = m.author_id";
24212
24251
  var iso3 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
24213
24252
  var oneOf2 = /* @__PURE__ */ __name((value, allowed, what) => {
@@ -24254,6 +24293,16 @@ var subjectOf = /* @__PURE__ */ __name((database, row2) => {
24254
24293
  subjectIsOwner: Number(named2?.owner) === 1
24255
24294
  };
24256
24295
  }, "subjectOf");
24296
+ var highestKey = /* @__PURE__ */ __name((table) => `ids.${table}.highest`, "highestKey");
24297
+ var nextId = /* @__PURE__ */ __name((database, table) => {
24298
+ const kept = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(highestKey(table));
24299
+ const highest = database.prepare(`SELECT max(id) AS id FROM ${table}`).get();
24300
+ return Math.max(Number(kept?.value ?? 0), Number(highest?.id ?? 0)) + 1;
24301
+ }, "nextId");
24302
+ var keepHighestId = /* @__PURE__ */ __name((database, table, at) => {
24303
+ const highest = nextId(database, table) - 1;
24304
+ database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(highestKey(table), String(highest), at);
24305
+ }, "keepHighestId");
24257
24306
  var dropLinksOf = /* @__PURE__ */ __name((database, thing) => {
24258
24307
  const count = Number(database.prepare("SELECT count(*) AS n FROM links WHERE (from_type = ? AND from_id = ?) OR (to_type = ? AND to_id = ?)").get(thing.type, thing.id, thing.type, thing.id)?.n);
24259
24308
  database.prepare("DELETE FROM links WHERE to_type = ? AND to_id = ?").run(thing.type, thing.id);
@@ -24332,7 +24381,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
24332
24381
  const subject2 = input.subject === void 0 ? void 0 : requiredThing(database, input.subject, "the subject");
24333
24382
  const replaced = input.supersedes === void 0 ? void 0 : Number(rowOf(input.supersedes).id);
24334
24383
  const at = now2();
24335
- const made = Number(database.prepare("INSERT INTO memories (kind, body, subject_type, subject_id, author_type, author_id, model, confidence, status, last_verified_at, supersedes_id, scope, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(kind3, body2, subject2?.type ?? null, subject2?.id ?? null, actor.type, actor.id, model, input.confidence ?? null, status, status === "confirmed" ? at : null, replaced ?? null, scope3, at, at)?.id);
24384
+ const made = Number(database.prepare("INSERT INTO memories (id, kind, body, subject_type, subject_id, author_type, author_id, model, confidence, status, last_verified_at, supersedes_id, scope, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(nextId(database, "memories"), kind3, body2, subject2?.type ?? null, subject2?.id ?? null, actor.type, actor.id, model, input.confidence ?? null, status, status === "confirmed" ? at : null, replaced ?? null, scope3, at, at)?.id);
24336
24385
  linkEvidence(context, { type: "memory", id: made }, input.evidence, input.author === "owner" ? "owner" : "agent");
24337
24386
  if (replaced !== void 0)
24338
24387
  database.prepare("UPDATE memories SET status = 'superseded', updated_at = ? WHERE id = ?").run(at, replaced);
@@ -24350,6 +24399,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
24350
24399
  remove: /* @__PURE__ */ __name(async (reference2) => {
24351
24400
  const id2 = Number(rowOf(reference2).id);
24352
24401
  const links2 = erase(database, () => {
24402
+ keepHighestId(database, "memories", now2());
24353
24403
  database.prepare("UPDATE memories SET supersedes_id = NULL WHERE supersedes_id = ?").run(id2);
24354
24404
  const count = dropLinksOf(database, { type: "memory", id: id2 });
24355
24405
  database.prepare("DELETE FROM memories WHERE id = ?").run(id2);
@@ -24371,7 +24421,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
24371
24421
  };
24372
24422
  }, "memoriesStoreOver");
24373
24423
 
24374
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
24424
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
24375
24425
  var DEFAULT_FIRST_PASS_PER_CHAT = 0;
24376
24426
  var KEY = "taskFirstPassPerChat";
24377
24427
  var firstPassPerChatOf = /* @__PURE__ */ __name((value, setting = "task_first_pass_per_chat") => {
@@ -24391,7 +24441,180 @@ var saveFirstPassPerChat = /* @__PURE__ */ __name((database, value, now2) => {
24391
24441
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(KEY, String(value), now2);
24392
24442
  }, "saveFirstPassPerChat");
24393
24443
 
24394
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
24444
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-board.js
24445
+ var field = /* @__PURE__ */ __name((name, type, example, more = {}) => ({
24446
+ name,
24447
+ type,
24448
+ operators: OPERATORS_BY_TYPE[type],
24449
+ example,
24450
+ ...more
24451
+ }), "field");
24452
+ var PROJECT_TASK_FIELDS = [
24453
+ field("state", "enum", "state:todo", { values: TASK_STATES }),
24454
+ field("kind", "enum", "kind:bug", { values: TASK_TYPES }),
24455
+ field("project", "kw", "project:HRB", {
24456
+ relation: "a project by its key or project:<id>; project:* is every project, and lists project tasks only"
24457
+ }),
24458
+ field("assignee", "kw", 'assignee:"person:12"', {
24459
+ relation: "who does it: any, none, or a person (person:12 in quotes, or the bare 12)"
24460
+ }),
24461
+ field("priority", "kw", "priority:high", {
24462
+ operators: ["term", "range", "wildcard"],
24463
+ relation: "low, medium, high, critical or none; a range of labels or of the 0\u20131 number: priority:[high TO critical]"
24464
+ }),
24465
+ field("agent", "kw", "agent:hermes", { relation: "the agent working on it, by name; none or any" }),
24466
+ field("due", "time", "due:[today TO 2026-12-31]", { relation: "the due date; NOT due:* has none" }),
24467
+ field("overdue", "bool", "overdue:true", { relation: "open work whose due date has passed" }),
24468
+ field("closed", "time", "closed:>=14d", { relation: "when it was done or dismissed" }),
24469
+ field("ready", "bool", "ready:true", { relation: "open work whose blocked-by tasks are all done" }),
24470
+ field("text", "txt", "text:invoice", { relation: "words of the title and description; a bare word means this" })
24471
+ ];
24472
+ var OPEN = "t.status NOT IN ('done', 'dismissed')";
24473
+ var OWNER_PROJECTS = `SELECT id FROM projects WHERE deleted_at IS NULL AND length(key) <> ${INBOX_KEY_LENGTH}`;
24474
+ var ASSIGNED = "SELECT 1 FROM task_assignments a WHERE a.task_id = t.id AND a.assignee_type = 'person' AND a.role = 'assignee'";
24475
+ var UNFINISHED_BLOCKER = "SELECT 1 FROM links l LEFT JOIN tasks b ON b.id = l.to_id LEFT JOIN projects bp ON bp.id = b.project_id WHERE l.from_type = 'task' AND l.to_type = 'task' AND l.kind = 'blocked-by' AND l.from_id = t.id AND l.confirmed = 1 AND l.anchor IS NULL AND (b.id IS NULL OR b.deleted_at IS NOT NULL OR bp.deleted_at IS NOT NULL OR b.status <> 'done')";
24476
+ var wordsMatch = /* @__PURE__ */ __name((node) => {
24477
+ const words3 = taskWordsOf(node.value.replaceAll("*", " ")).split(/\s+/).filter((word) => /[\p{L}\p{N}]/u.test(word));
24478
+ if (words3.length === 0)
24479
+ return void 0;
24480
+ const quoted3 = /* @__PURE__ */ __name((text5) => `"${text5.replaceAll('"', '""')}"`, "quoted");
24481
+ return `normalized_text : (${node.operator === "phrase" ? quoted3(words3.join(" ")) : words3.map((word) => `${quoted3(word)}*`).join(" AND ")})`;
24482
+ }, "wordsMatch");
24483
+ var projectWhere = /* @__PURE__ */ __name((node) => {
24484
+ if (node.operator === "wildcard" && node.value === "*")
24485
+ return { sql: "1", params: [] };
24486
+ const id2 = /^project:(\d+)$/.exec(node.value.trim())?.[1];
24487
+ if (id2 !== void 0)
24488
+ return { sql: "t.project_id = ?", params: [Number(id2)] };
24489
+ const key2 = node.value.trim().toUpperCase();
24490
+ return {
24491
+ sql: `t.project_id IN (SELECT id FROM projects WHERE key ${node.operator === "wildcard" ? "GLOB" : "="} ?)`,
24492
+ params: [key2]
24493
+ };
24494
+ }, "projectWhere");
24495
+ var assigneeWhere = /* @__PURE__ */ __name((node) => {
24496
+ const value = node.value.trim().toLowerCase();
24497
+ if (value === "any" || node.operator === "wildcard" && value === "*")
24498
+ return { sql: `EXISTS (${ASSIGNED})`, params: [] };
24499
+ if (value === "none")
24500
+ return { sql: `NOT EXISTS (${ASSIGNED})`, params: [] };
24501
+ const id2 = /^(?:person:)?(\d+)$/.exec(value)?.[1];
24502
+ if (id2 === void 0)
24503
+ throw new CliError("validation_error", `assignee: takes any, none or "person:<id>", not "${node.value}"`);
24504
+ return { sql: `EXISTS (${ASSIGNED} AND a.assignee_id = ?)`, params: [Number(id2)] };
24505
+ }, "assigneeWhere");
24506
+ var bound3 = /* @__PURE__ */ __name((value, side, node) => {
24507
+ const word = value.trim().toLowerCase();
24508
+ if (word === "*")
24509
+ return void 0;
24510
+ if (PRIORITY_LABELS.includes(word))
24511
+ return priorityBand(word)[side];
24512
+ const number3 = Number(word);
24513
+ if (word === "" || !Number.isFinite(number3) || number3 < 0 || number3 > 1)
24514
+ throw new CliError("validation_error", `priority: takes ${PRIORITY_LABELS.join(", ")}, none, or 0 to 1, not "${node.value}"`);
24515
+ return number3;
24516
+ }, "bound");
24517
+ var priorityWhere = /* @__PURE__ */ __name((node) => {
24518
+ const score = "t.priority_score";
24519
+ if (node.operator === "wildcard") {
24520
+ if (node.value === "*")
24521
+ return { sql: `${score} IS NOT NULL`, params: [] };
24522
+ throw new CliError("validation_error", "priority: takes a label, none, or a range");
24523
+ }
24524
+ if (node.operator !== "range") {
24525
+ const word = node.value.trim().toLowerCase();
24526
+ if (word === "none")
24527
+ return { sql: `${score} IS NULL`, params: [] };
24528
+ if (!PRIORITY_LABELS.includes(word))
24529
+ throw new CliError("validation_error", `priority: takes ${PRIORITY_LABELS.join(", ")} or none; a number goes in a range`);
24530
+ const { from: from2, to } = priorityBand(word);
24531
+ return { sql: `${score} >= ? AND ${score} ${to === 1 ? "<=" : "<"} ?`, params: [from2, to] };
24532
+ }
24533
+ const lower = bound3(node.value, "from", node);
24534
+ const upperWord = (node.upper ?? "*").trim().toLowerCase();
24535
+ const upper = bound3(upperWord, "to", node);
24536
+ const labelUpper = PRIORITY_LABELS.includes(upperWord);
24537
+ const parts2 = [`${score} IS NOT NULL`];
24538
+ const params = [];
24539
+ if (lower !== void 0) {
24540
+ parts2.push(`${score} ${node.lower_inclusive === false ? ">" : ">="} ?`);
24541
+ params.push(lower);
24542
+ }
24543
+ if (upper !== void 0) {
24544
+ parts2.push(`${score} ${labelUpper ? upper === 1 ? "<=" : "<" : node.upper_inclusive === false ? "<" : "<="} ?`);
24545
+ params.push(upper);
24546
+ }
24547
+ return { sql: parts2.join(" AND "), params };
24548
+ }, "priorityWhere");
24549
+ var agentWhere = /* @__PURE__ */ __name((node) => {
24550
+ const value = node.value.trim().toLowerCase();
24551
+ if (value === "none")
24552
+ return { sql: "t.agent IS NULL", params: [] };
24553
+ if (value === "any" || node.operator === "wildcard" && value === "*")
24554
+ return { sql: "t.agent IS NOT NULL", params: [] };
24555
+ return node.operator === "wildcard" ? { sql: "lower(t.agent) GLOB ?", params: [value] } : { sql: "lower(t.agent) = ?", params: [value] };
24556
+ }, "agentWhere");
24557
+ var truth = /* @__PURE__ */ __name((node, sql2) => ({
24558
+ sql: node.value.toLowerCase() === "true" ? sql2 : `NOT (${sql2})`,
24559
+ params: []
24560
+ }), "truth");
24561
+ var projectTaskColumns = /* @__PURE__ */ __name((now2) => ({
24562
+ state: { type: "enum", sql: "t.status" },
24563
+ kind: { type: "enum", sql: "t.type" },
24564
+ project: { where: projectWhere },
24565
+ assignee: { where: assigneeWhere },
24566
+ priority: { where: priorityWhere },
24567
+ agent: { where: agentWhere },
24568
+ due: { type: "time", sql: "t.due_at" },
24569
+ closed: { type: "time", sql: "t.closed_at" },
24570
+ overdue: { where: /* @__PURE__ */ __name((node) => truth(node, `${OPEN} AND t.due_at IS NOT NULL AND t.due_at < ${Number(now2)}`), "where") },
24571
+ ready: { where: /* @__PURE__ */ __name((node) => truth(node, `${OPEN} AND NOT EXISTS (${UNFINISHED_BLOCKER})`), "where") },
24572
+ text: {
24573
+ where: /* @__PURE__ */ __name((node) => {
24574
+ const match = wordsMatch(node);
24575
+ const byKey = { sql: "t.key = ?", params: [node.value.trim().toUpperCase()] };
24576
+ if (match === void 0)
24577
+ return byKey;
24578
+ return {
24579
+ sql: `(t.id IN (SELECT rowid FROM task_words WHERE task_words MATCH ?) OR ${byKey.sql})`,
24580
+ params: [match, ...byKey.params]
24581
+ };
24582
+ }, "where")
24583
+ }
24584
+ }), "projectTaskColumns");
24585
+ var BOARD_SCOPE = `t.deleted_at IS NULL AND t.project_id IN (${OWNER_PROJECTS})`;
24586
+ var STATE_ORDER = `CASE t.status ${TASK_STATES.map((state, at) => `WHEN '${state}' THEN ${at}`).join(" ")} END`;
24587
+ var boardOrder = /* @__PURE__ */ __name((sort, descending) => {
24588
+ const direction = descending ? "DESC" : "ASC";
24589
+ const first = {
24590
+ priority: ["t.priority_score IS NULL", `t.priority_score ${descending ? "ASC" : "DESC"}`],
24591
+ due: ["t.due_at IS NULL", `t.due_at ${direction}`],
24592
+ created: [`t.created_at ${direction}`],
24593
+ updated: [`t.updated_at ${direction}`],
24594
+ key: [`(SELECT key FROM projects WHERE id = t.project_id) ${direction}`, `t.number ${direction}`],
24595
+ state: [`${STATE_ORDER} ${direction}`]
24596
+ }[sort];
24597
+ return [...first, "t.priority_score IS NULL", "t.priority_score DESC", "t.created_at", "t.id"].join(", ");
24598
+ }, "boardOrder");
24599
+ var withoutField = /* @__PURE__ */ __name((query, name) => {
24600
+ if (query === void 0)
24601
+ return void 0;
24602
+ const strip = /* @__PURE__ */ __name((node) => {
24603
+ if (walkQuery(node).every((leaf2) => leaf2.field === name))
24604
+ return void 0;
24605
+ if (node.kind === "predicate" || node.clauses.some((clause) => clause.occur === "should"))
24606
+ return node;
24607
+ const clauses = node.clauses.flatMap((clause) => {
24608
+ const kept = strip(clause.node);
24609
+ return kept === void 0 ? [] : [{ ...clause, node: kept }];
24610
+ });
24611
+ return clauses.length === 0 ? void 0 : { ...node, clauses };
24612
+ }, "strip");
24613
+ const root = strip(query.root);
24614
+ return root === void 0 ? void 0 : { ...query, root };
24615
+ }, "withoutField");
24616
+
24617
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
24395
24618
  var TASK_RELATION_KINDS = [
24396
24619
  "blocked-by",
24397
24620
  "follow-up-of",
@@ -24503,7 +24726,7 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
24503
24726
  task: ref3(Number(row2.to_id)),
24504
24727
  state: row2.status == null || row2.deleted_at != null || row2.project_deleted != null ? "unavailable" : row2.status === "dismissed" ? "dismissed" : "open"
24505
24728
  }));
24506
- return { ready: liveTask(database, rowId).status === "open" && blockers.length === 0, blockers };
24729
+ return { ready: !isClosedState(String(liveTask(database, rowId).status)) && blockers.length === 0, blockers };
24507
24730
  }), "taskReadiness"),
24508
24731
  readyTasks: /* @__PURE__ */ __name(async (project, options = {}) => read(database, () => {
24509
24732
  const limit = options.limit ?? 50;
@@ -24512,7 +24735,7 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
24512
24735
  const row2 = project.startsWith("project:") ? database.prepare("SELECT id FROM projects WHERE id=? AND account_id IS NULL AND deleted_at IS NULL").get(project.slice(8)) : database.prepare("SELECT id FROM projects WHERE key=? AND account_id IS NULL AND deleted_at IS NULL").get(project.trim().toUpperCase());
24513
24736
  if (!row2)
24514
24737
  throw new CliError("not_found", "the owner project is unavailable");
24515
- const rows = database.prepare("SELECT coalesce(t.package_id,t.key) AS id,t.key,substr(t.title,1,300) AS title FROM tasks t WHERE t.project_id=? AND t.status='open' AND t.deleted_at IS NULL AND NOT EXISTS (SELECT 1 FROM links l LEFT JOIN tasks b ON b.id=l.to_id LEFT JOIN projects p ON p.id=b.project_id WHERE l.from_type='task' AND l.to_type='task' AND l.kind='blocked-by' AND l.from_id=t.id AND l.confirmed=1 AND l.anchor IS NULL AND (b.id IS NULL OR b.deleted_at IS NOT NULL OR p.deleted_at IS NOT NULL OR b.status!='done')) ORDER BY coalesce(t.priority,5),t.number,t.id LIMIT ?").all(Number(row2.id), limit + 1);
24738
+ const rows = database.prepare("SELECT coalesce(t.package_id,t.key) AS id,t.key,substr(t.title,1,300) AS title FROM tasks t WHERE t.project_id=? AND t.status NOT IN ('done','dismissed') AND t.deleted_at IS NULL AND NOT EXISTS (SELECT 1 FROM links l LEFT JOIN tasks b ON b.id=l.to_id LEFT JOIN projects p ON p.id=b.project_id WHERE l.from_type='task' AND l.to_type='task' AND l.kind='blocked-by' AND l.from_id=t.id AND l.confirmed=1 AND l.anchor IS NULL AND (b.id IS NULL OR b.deleted_at IS NOT NULL OR p.deleted_at IS NOT NULL OR b.status!='done')) ORDER BY t.priority_score IS NULL,t.priority_score DESC,t.number,t.id LIMIT ?").all(Number(row2.id), limit + 1);
24516
24739
  return {
24517
24740
  items: rows.slice(0, limit).map((value) => ({ id: String(value.id), key: String(value.key), title: String(value.title ?? "") })),
24518
24741
  hasMore: rows.length > limit
@@ -24521,7 +24744,7 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
24521
24744
  };
24522
24745
  }, "taskRelationsStoreOver");
24523
24746
 
24524
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
24747
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
24525
24748
  var TASK_ROLES = ["assignee", "reviewer", "watcher"];
24526
24749
  var iso4 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
24527
24750
  var recordTaskEvent = /* @__PURE__ */ __name((database, task, actor, kind3, changes, at) => {
@@ -24534,11 +24757,11 @@ var textOf3 = /* @__PURE__ */ __name((value, what, max) => {
24534
24757
  return text5;
24535
24758
  }, "textOf");
24536
24759
  var claimOf = /* @__PURE__ */ __name((row2, at) => row2.claimed_by != null && Number(row2.claimed_until) >= at ? { claimedBy: String(row2.claimed_by), claimedUntil: iso4(row2.claimed_until) } : { claimedBy: null, claimedUntil: null }, "claimOf");
24537
- var priorityOf = /* @__PURE__ */ __name((value) => {
24538
- if (value !== null && !(Number.isInteger(value) && value >= 0 && value <= 4))
24539
- throw new CliError("validation_error", "a priority is 0 (urgent) to 4 (low)");
24540
- return value;
24541
- }, "priorityOf");
24760
+ var checkRevision = /* @__PURE__ */ __name((row2, expected) => {
24761
+ if (expected === void 0 || Number(row2.revision) === expected)
24762
+ return;
24763
+ throw new CliError("configuration_error", `task ${String(row2.key)} changed since revision ${expected}; it is at ${String(row2.revision)}: read it again`, { reason: "task.stale", revision: Number(row2.revision) });
24764
+ }, "checkRevision");
24542
24765
  var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24543
24766
  const { database, now: now2 } = context;
24544
24767
  const required3 = /* @__PURE__ */ __name((id2) => {
@@ -24591,7 +24814,10 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24591
24814
  description: row2.description == null ? null : String(row2.description),
24592
24815
  type: row2.type,
24593
24816
  status: row2.status,
24594
- priority: row2.priority == null ? null : Number(row2.priority),
24817
+ priority: row2.priority_score == null ? null : Number(row2.priority_score),
24818
+ priorityLabel: priorityLabel(row2.priority_score == null ? null : Number(row2.priority_score)),
24819
+ agent: row2.agent == null ? null : String(row2.agent),
24820
+ revision: Number(row2.revision),
24595
24821
  parent: row2.parent_id == null ? null : reference2(Number(row2.parent_id)),
24596
24822
  source: row2.source_locator == null ? null : String(row2.source_locator),
24597
24823
  dueAt: iso4(row2.due_at),
@@ -24608,6 +24834,19 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24608
24834
  updatedAt: iso4(row2.updated_at)
24609
24835
  };
24610
24836
  }, "detailsOf");
24837
+ const stemmerFor2 = stemmerCache();
24838
+ const touch = /* @__PURE__ */ __name((task, at) => database.prepare("UPDATE tasks SET updated_at = ? WHERE id = ?").run(at, task), "touch");
24839
+ const boardWhere = /* @__PURE__ */ __name((query, zone, at) => {
24840
+ if (query === void 0)
24841
+ return { sql: BOARD_SCOPE, params: [] };
24842
+ const where = queryFilter(query, projectTaskColumns(at), {
24843
+ command: "tasks list",
24844
+ now: at,
24845
+ ...zone ? { zone } : {}
24846
+ });
24847
+ return { sql: `${BOARD_SCOPE} AND (${where.sql})`, params: where.params };
24848
+ }, "boardWhere");
24849
+ const countOf = /* @__PURE__ */ __name((where) => Number(database.prepare(`SELECT count(*) AS n FROM tasks t WHERE ${where.sql}`).get(...where.params)?.n ?? 0), "countOf");
24611
24850
  const rowById = /* @__PURE__ */ __name((id2) => database.prepare("SELECT * FROM tasks WHERE id = ?").get(id2), "rowById");
24612
24851
  const details2 = /* @__PURE__ */ __name((id2) => detailsOf(rowById(id2)), "details");
24613
24852
  const edit = /* @__PURE__ */ __name((task, fields4, actor, created = false) => {
@@ -24615,13 +24854,13 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24615
24854
  const at = now2();
24616
24855
  const set = [];
24617
24856
  const values = [];
24618
- const change = /* @__PURE__ */ __name((column2, value, event) => {
24857
+ const change = /* @__PURE__ */ __name((column2, value, event, key2 = column2) => {
24619
24858
  if ((before2[column2] ?? null) === value)
24620
24859
  return;
24621
24860
  set.push(`${column2} = ?`);
24622
24861
  values.push(value);
24623
24862
  if (event)
24624
- recordTaskEvent(database, task, actor, event, { [column2]: [before2[column2] ?? null, value] }, at);
24863
+ recordTaskEvent(database, task, actor, event, { [key2]: [before2[column2] ?? null, value] }, at);
24625
24864
  }, "change");
24626
24865
  if (fields4.title !== void 0) {
24627
24866
  const title = textOf3(fields4.title, "a task's title", 300);
@@ -24630,23 +24869,35 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24630
24869
  }
24631
24870
  if (fields4.description !== void 0)
24632
24871
  change("description", fields4.description === null ? null : textOf3(fields4.description, "a description", 2e4), created ? void 0 : "description");
24633
- if (fields4.priority !== void 0)
24634
- change("priority", priorityOf(fields4.priority), "priority");
24872
+ if (fields4.priority !== void 0) {
24873
+ const score = fields4.priority === null ? null : checkedScore(fields4.priority);
24874
+ change("priority_score", score, "priority", "priority");
24875
+ change("priority", legacyPriority(score));
24876
+ }
24877
+ if (fields4.agent !== void 0)
24878
+ change("agent", fields4.agent === null ? null : textOf3(fields4.agent, "an agent's name", 100), "agent");
24635
24879
  if (fields4.parent !== void 0)
24636
24880
  change("parent_id", fields4.parent === null ? null : parentOf(task, Number(before2.project_id), fields4.parent));
24637
24881
  if (fields4.dueAt !== void 0)
24638
24882
  change("due_at", fields4.dueAt === null ? null : fields4.dueAt.getTime(), "due");
24639
24883
  if (fields4.nextCheckAt !== void 0)
24640
- change("next_check_at", fields4.nextCheckAt === null ? null : fields4.nextCheckAt.getTime());
24884
+ change("next_check_at", fields4.nextCheckAt === null ? null : fields4.nextCheckAt.getTime(), "next-check");
24641
24885
  if (fields4.status !== void 0) {
24642
24886
  if (!TASK_STATES.includes(fields4.status))
24643
24887
  throw new CliError("validation_error", `a task's status is one of ${TASK_STATES.join(", ")}`);
24644
- const closed = fields4.status !== "open";
24888
+ if ((fields4.status === "todo" || fields4.status === "in_progress") && String(database.prepare("SELECT key FROM projects WHERE id = ?").get(Number(before2.project_id))?.key).length === INBOX_KEY_LENGTH)
24889
+ throw new CliError("validation_error", "a task from a message is open, done or dismissed; todo and in_progress are for a project task");
24890
+ const closed = isClosedState(fields4.status);
24891
+ const reopened = !closed && isClosedState(String(before2.status));
24645
24892
  if (before2.status !== fields4.status) {
24646
24893
  change("status", fields4.status, "status");
24647
- change("closed_at", closed ? at : null);
24648
- change("closed_by_type", closed ? actor.type : null);
24649
- change("closed_by_id", closed ? actor.id : null);
24894
+ if (fields4.status === "in_progress" && before2.started_at == null)
24895
+ change("started_at", at);
24896
+ if (closed || reopened) {
24897
+ change("closed_at", closed ? at : null);
24898
+ change("closed_by_type", closed ? actor.type : null);
24899
+ change("closed_by_id", closed ? actor.id : null);
24900
+ }
24650
24901
  if (closed) {
24651
24902
  change("claimed_by", null);
24652
24903
  change("claimed_until", null);
@@ -24654,6 +24905,10 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24654
24905
  change(column2, null);
24655
24906
  } else
24656
24907
  change("close_certainty", null);
24908
+ if (reopened && fields4.reason === void 0) {
24909
+ change("close_reason", null);
24910
+ change("close_reason_folded", null);
24911
+ }
24657
24912
  }
24658
24913
  }
24659
24914
  if (fields4.reason !== void 0) {
@@ -24667,6 +24922,64 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24667
24922
  return;
24668
24923
  database.prepare(`UPDATE tasks SET ${set.join(", ")}, updated_at = ? WHERE id = ?`).run(...values, at, task);
24669
24924
  }, "edit");
24925
+ const columnOf = /* @__PURE__ */ __name((task, status) => database.prepare(`SELECT t.id, t.key, coalesce(t.priority_score, 0) AS score FROM tasks t WHERE ${BOARD_SCOPE} AND t.status = ? AND t.id <> ? ORDER BY ${boardOrder("priority", false)}`).all(status, task).map((row2) => ({ id: Number(row2.id), key: String(row2.key), score: Number(row2.score) })), "columnOf");
24926
+ const moveTask = /* @__PURE__ */ __name((task, row2, move2, actor) => {
24927
+ if (move2.before !== void 0 && move2.after !== void 0)
24928
+ throw new CliError("validation_error", "give --before or --after, not both");
24929
+ if (!database.prepare(`SELECT 1 FROM tasks t WHERE t.id = ? AND ${BOARD_SCOPE}`).get(task))
24930
+ throw new CliError("validation_error", "only a project task moves on the board");
24931
+ const neighbour = move2.before ?? move2.after;
24932
+ if (neighbour === void 0) {
24933
+ const status2 = move2.status ?? row2.status;
24934
+ if (columnOf(task, status2).length > 0 || move2.status === void 0)
24935
+ throw new CliError("validation_error", "say where it goes: --before <key> or --after <key>");
24936
+ const from3 = priorityLabel(row2.priority_score == null ? null : Number(row2.priority_score));
24937
+ edit(task, { status: move2.status }, actor);
24938
+ return { label: { from: from3, to: from3, changed: false }, renumbered: [] };
24939
+ }
24940
+ const target = required3(neighbour);
24941
+ const anchor = database.prepare(`SELECT t.key, t.status FROM tasks t WHERE t.id = ? AND ${BOARD_SCOPE}`).get(target);
24942
+ if (target === task)
24943
+ throw new CliError("validation_error", "a task moves beside another task, not itself");
24944
+ if (!anchor)
24945
+ throw new CliError("validation_error", `${neighbour} is not on a project's board`);
24946
+ const status = anchor.status;
24947
+ if (move2.status !== void 0 && move2.status !== status)
24948
+ throw new CliError("validation_error", `${String(anchor.key)} is in ${status}, not ${move2.status}: pick a task in the ${move2.status} column`, { reason: "task.column", anchor: String(anchor.key), anchorStatus: status, requestedStatus: move2.status });
24949
+ const column2 = columnOf(task, status);
24950
+ const at = column2.findIndex(({ id: id2 }) => id2 === target);
24951
+ const index2 = move2.before === void 0 ? at + 1 : at;
24952
+ const above = column2[index2 - 1];
24953
+ const below = column2[index2];
24954
+ const STEP = 1 / 64;
24955
+ const score = above === void 0 ? Math.min(1, (below?.score ?? 0) + STEP) : below === void 0 ? Math.max(0, above.score - STEP) : (above.score + below.score) / 2;
24956
+ const roomy = (above === void 0 || score < above.score) && (below === void 0 || score > below.score);
24957
+ const from2 = priorityLabel(row2.priority_score == null ? null : Number(row2.priority_score));
24958
+ const renumbered = [];
24959
+ let given = score;
24960
+ if (!roomy || above !== void 0 && below !== void 0 && above.score - below.score < 1e-9) {
24961
+ const label = priorityLabel((above ?? below)?.score ?? 0);
24962
+ const band = priorityBand(label);
24963
+ const inBand = /* @__PURE__ */ __name((one) => priorityLabel(one.score) === label, "inBand");
24964
+ const ordered = [...column2.slice(0, index2), { id: task, key: String(row2.key), score }, ...column2.slice(index2)];
24965
+ const spread = ordered.filter((one) => one.id === task || inBand(one));
24966
+ const gap = (band.to - band.from) / (spread.length + 1);
24967
+ spread.forEach((one, place) => {
24968
+ const value = band.to - gap * (place + 1);
24969
+ if (one.id === task) {
24970
+ given = value;
24971
+ return;
24972
+ }
24973
+ if (one.score === value)
24974
+ return;
24975
+ edit(one.id, { priority: value }, actor);
24976
+ renumbered.push(one.key);
24977
+ });
24978
+ }
24979
+ edit(task, { priority: given, status }, actor);
24980
+ const to = priorityLabel(given);
24981
+ return { label: { from: from2, to, changed: from2 !== to }, renumbered };
24982
+ }, "moveTask");
24670
24983
  return {
24671
24984
  ...taskRelationsStoreOver(context, (task, actor, kind3, changes, at) => recordTaskEvent(database, task, actor, kind3, changes, at)),
24672
24985
  create: /* @__PURE__ */ __name((input, by) => {
@@ -24688,22 +25001,36 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24688
25001
  });
24689
25002
  return details2(made);
24690
25003
  }, "create"),
24691
- edit: /* @__PURE__ */ __name(async (id2, fields4, by) => {
25004
+ edit: /* @__PURE__ */ __name(async (id2, fields4, by, check3 = {}) => {
24692
25005
  const task = required3(id2);
24693
- write(database, () => edit(task, fields4, authorActor(context, by).actor));
25006
+ write(database, () => {
25007
+ checkRevision(rowById(task), check3.revision);
25008
+ edit(task, fields4, authorActor(context, by).actor);
25009
+ });
24694
25010
  return details2(task);
24695
25011
  }, "edit"),
24696
- assign: /* @__PURE__ */ __name((id2, { to, role }, by) => {
25012
+ move: /* @__PURE__ */ __name(async (id2, move2, by, check3 = {}) => {
25013
+ const task = required3(id2);
25014
+ return write(database, () => {
25015
+ const row2 = rowById(task);
25016
+ checkRevision(row2, check3.revision);
25017
+ const moved = moveTask(task, row2, move2, authorActor(context, by).actor);
25018
+ return { ...moved, task: details2(task) };
25019
+ });
25020
+ }, "move"),
25021
+ assign: /* @__PURE__ */ __name((id2, { to, role }, by, check3 = {}) => {
24697
25022
  if (!TASK_ROLES.includes(role))
24698
25023
  throw new CliError("validation_error", `a role is one of ${TASK_ROLES.join(", ")}`);
24699
25024
  const task = required3(id2);
24700
25025
  write(database, () => {
25026
+ checkRevision(rowById(task), check3.revision);
24701
25027
  const person2 = personOf2(to);
24702
25028
  const held = database.prepare("SELECT 1 FROM task_assignments WHERE task_id = ? AND assignee_type = 'person' AND assignee_id = ? AND role = ?").get(task, person2, role);
24703
25029
  if (held)
24704
25030
  return;
24705
25031
  const at = now2();
24706
25032
  database.prepare("INSERT INTO task_assignments (task_id, assignee_type, assignee_id, role, created_at, updated_at) VALUES (?, 'person', ?, ?, ?, ?)").run(task, person2, role, at, at);
25033
+ touch(task, at);
24707
25034
  const changes = { [role]: [null, `person:${person2}`] };
24708
25035
  recordTaskEvent(database, task, authorActor(context, by).actor, "assigned", changes, at);
24709
25036
  });
@@ -24724,15 +25051,18 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24724
25051
  const row2 = database.prepare("SELECT p.id FROM messages m JOIN identity_links il ON il.identity_id = m.sender_identity_id JOIN persons p ON p.id = il.person_id WHERE m.id = ? AND m.outgoing = 0 AND p.owner = 0").get(thing.id);
24725
25052
  return row2 ? `person:${String(row2.id)}` : void 0;
24726
25053
  }, "sourceSender"),
24727
- unassign: /* @__PURE__ */ __name(async (id2, { to, role }, by) => {
25054
+ unassign: /* @__PURE__ */ __name(async (id2, { to, role }, by, check3 = {}) => {
24728
25055
  const task = required3(id2);
24729
25056
  write(database, () => {
25057
+ checkRevision(rowById(task), check3.revision);
24730
25058
  const person2 = personOf2(to);
24731
25059
  const removed = database.prepare("DELETE FROM task_assignments WHERE task_id = ? AND assignee_type = 'person' AND assignee_id = ? AND role = ?").run(task, person2, role).changes;
24732
25060
  if (removed === 0)
24733
25061
  return;
25062
+ const at = now2();
25063
+ touch(task, at);
24734
25064
  const changes = { [role]: [`person:${person2}`, null] };
24735
- recordTaskEvent(database, task, authorActor(context, by).actor, "unassigned", changes, now2());
25065
+ recordTaskEvent(database, task, authorActor(context, by).actor, "unassigned", changes, at);
24736
25066
  });
24737
25067
  return details2(task);
24738
25068
  }, "unassign"),
@@ -24749,15 +25079,21 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24749
25079
  throw new CliError("validation_error", `a task's type is one of ${TASK_TYPES.join(", ")}`);
24750
25080
  const projectId = project === void 0 ? null : projectOf(project);
24751
25081
  const person2 = assignee === void 0 ? null : personOf2(assignee);
24752
- return database.prepare(`SELECT * FROM tasks t WHERE deleted_at IS NULL AND (? IS NULL OR project_id = ?) AND (? IS NULL OR type = ?) AND (? IS NULL OR status = ?) AND (? IS NULL OR EXISTS (SELECT 1 FROM task_assignments a WHERE a.task_id = t.id AND a.assignee_type = 'person' AND a.assignee_id = ?)) AND (${where?.sql || "1"}) ORDER BY coalesce(priority, 5), created_at, id LIMIT ?`).all(projectId, projectId, type ?? null, type ?? null, status ?? null, status ?? null, person2, person2, ...where?.params ?? [], Math.min(Math.max(limit, 1), 500)).map(detailsOf);
25082
+ return database.prepare(`SELECT * FROM tasks t WHERE deleted_at IS NULL AND (? IS NULL OR project_id = ?) AND (? IS NULL OR type = ?) AND (? IS NULL OR status = ?) AND (? IS NULL OR EXISTS (SELECT 1 FROM task_assignments a WHERE a.task_id = t.id AND a.assignee_type = 'person' AND a.assignee_id = ?)) AND (${where?.sql || "1"}) ORDER BY priority_score IS NULL, priority_score DESC, created_at, id LIMIT ?`).all(projectId, projectId, type ?? null, type ?? null, status ?? null, status ?? null, person2, person2, ...where?.params ?? [], Math.min(Math.max(limit, 1), 500)).map(detailsOf);
24753
25083
  }, "find"),
24754
25084
  claim: /* @__PURE__ */ __name(async (id2, holder, until) => {
24755
25085
  const task = required3(id2);
24756
25086
  const at = now2();
24757
- const won = write(database, () => database.prepare("UPDATE tasks SET claimed_by = ?, claimed_until = ?, updated_at = ? WHERE id = ? AND status = 'open' AND (claimed_by IS NULL OR claimed_until < ? OR claimed_by = ?) RETURNING id").get(holder, until.getTime(), at, task, at, holder));
25087
+ const won = write(database, () => {
25088
+ const before2 = claimOf(rowById(task), at).claimedBy;
25089
+ const claimed = database.prepare("UPDATE tasks SET claimed_by = ?, claimed_until = ?, updated_at = ? WHERE id = ? AND status NOT IN ('done', 'dismissed') AND (claimed_by IS NULL OR claimed_until < ? OR claimed_by = ?) RETURNING id").get(holder, until.getTime(), at, task, at, holder);
25090
+ if (claimed)
25091
+ recordTaskEvent(database, task, null, "claimed", { claimed_by: [before2, holder] }, at);
25092
+ return claimed;
25093
+ });
24758
25094
  if (!won) {
24759
25095
  const row2 = rowById(task);
24760
- if (row2.status !== "open")
25096
+ if (isClosedState(String(row2.status)))
24761
25097
  throw new CliError("validation_error", `task ${String(row2.key)} is ${String(row2.status)}; only an open task is claimed`);
24762
25098
  throw new CliError("validation_error", `${String(row2.claimed_by)} holds task ${String(row2.key)} until ${iso4(row2.claimed_until)}; wait for it, or ask them to release it`, { reason: "task.claimed", holder: String(row2.claimed_by), until: iso4(row2.claimed_until) });
24763
25099
  }
@@ -24772,13 +25108,66 @@ var workTaskOperationsOver = /* @__PURE__ */ __name((context) => {
24772
25108
  throw new CliError("validation_error", `${claimedBy} holds task ${String(row2.key)}; only they or the owner release it`, {
24773
25109
  reason: "task.claimed"
24774
25110
  });
24775
- database.prepare("UPDATE tasks SET claimed_by = NULL, claimed_until = NULL, updated_at = ? WHERE id = ?").run(now2(), task);
25111
+ const at = now2();
25112
+ database.prepare("UPDATE tasks SET claimed_by = NULL, claimed_until = NULL, updated_at = ? WHERE id = ?").run(at, task);
25113
+ if (claimedBy !== null)
25114
+ recordTaskEvent(database, task, null, "released", { claimed_by: [claimedBy, null] }, at);
24776
25115
  });
24777
25116
  return details2(task);
24778
25117
  }, "release"),
24779
- events: /* @__PURE__ */ __name(async (id2) => database.prepare("SELECT actor_type, actor_id, kind, changes, created_at FROM task_events WHERE task_id = ? ORDER BY id").all(required3(id2)).map((row2) => ({
25118
+ board: /* @__PURE__ */ __name(async (query, { limit, offset = 0, sort = "priority", descending = false, zone }) => {
25119
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 500)
25120
+ throw new CliError("validation_error", "a page of tasks holds 1\u2013500");
25121
+ drainCorpus(database, CORPORA.task, stemmerFor2);
25122
+ const where = boardWhere(query, zone, now2());
25123
+ const rows = database.prepare(`SELECT t.* FROM tasks t WHERE ${where.sql} ORDER BY ${boardOrder(sort, descending)} LIMIT ? OFFSET ?`).all(...where.params, limit, offset);
25124
+ return { items: rows.map(detailsOf), total: countOf(where) };
25125
+ }, "board"),
25126
+ boardCounts: /* @__PURE__ */ __name(async (query, { zone } = {}) => {
25127
+ drainCorpus(database, CORPORA.task, stemmerFor2);
25128
+ const at = now2();
25129
+ const without = /* @__PURE__ */ __name((name) => boardWhere(withoutField(query, name), zone, at), "without");
25130
+ const grouped = /* @__PURE__ */ __name((name, select2, from2, group) => {
25131
+ const where = without(name);
25132
+ return database.prepare(`SELECT ${select2}, count(*) AS n FROM tasks t ${from2} WHERE ${where.sql} GROUP BY ${group}`).all(...where.params);
25133
+ }, "grouped");
25134
+ const project = grouped("project", "p.key, p.name", "JOIN projects p ON p.id = t.project_id", "p.id").map((row2) => ({ value: String(row2.key), name: String(row2.name), count: Number(row2.n) })).sort((a, b) => a.value.localeCompare(b.value));
25135
+ const assigned = grouped("assignee", "a.assignee_id AS person, pe.name", "LEFT JOIN task_assignments a ON a.task_id = t.id AND a.assignee_type = 'person' AND a.role = 'assignee' LEFT JOIN persons pe ON pe.id = a.assignee_id", "a.assignee_id");
25136
+ const assignee = assigned.map((row2) => ({
25137
+ value: row2.person == null ? "none" : `person:${row2.person}`,
25138
+ name: row2.name == null ? null : String(row2.name),
25139
+ count: Number(row2.n)
25140
+ })).sort((a, b) => b.count - a.count || a.value.localeCompare(b.value));
25141
+ const priorities = /* @__PURE__ */ new Map();
25142
+ for (const row2 of grouped("priority", "t.priority_score", "", "t.priority_score")) {
25143
+ const label = priorityLabel(row2.priority_score == null ? null : Number(row2.priority_score)) ?? "none";
25144
+ priorities.set(label, (priorities.get(label) ?? 0) + Number(row2.n));
25145
+ }
25146
+ const states = new Map(grouped("state", "t.status", "", "t.status").map((row2) => [row2.status, Number(row2.n)]));
25147
+ return {
25148
+ total: countOf(boardWhere(query, zone, at)),
25149
+ project,
25150
+ assignee,
25151
+ priority: [...[...PRIORITY_LABELS].reverse(), "none"].map((value) => ({
25152
+ value,
25153
+ count: priorities.get(value) ?? 0
25154
+ })),
25155
+ state: TASK_STATES.map((value) => ({ value, count: states.get(value) ?? 0 }))
25156
+ };
25157
+ }, "boardCounts"),
25158
+ taskPeople: /* @__PURE__ */ __name(async () => database.prepare("SELECT p.id, p.name, p.owner, count(DISTINCT t.id) AS n FROM persons p LEFT JOIN task_assignments a ON a.assignee_type = 'person' AND a.assignee_id = p.id LEFT JOIN tasks t ON t.id = a.task_id AND t.deleted_at IS NULL WHERE p.owner = 1 OR t.id IS NOT NULL GROUP BY p.id ORDER BY p.owner DESC, p.name COLLATE NOCASE, p.id").all().map((row2) => ({
25159
+ person: `person:${row2.id}`,
25160
+ name: row2.name == null ? null : String(row2.name),
25161
+ owner: Number(row2.owner) === 1,
25162
+ tasks: Number(row2.n)
25163
+ })), "taskPeople"),
25164
+ events: /* @__PURE__ */ __name(async (id2) => database.prepare("SELECT e.actor_type, e.actor_id, e.kind, e.changes, e.created_at, CASE e.actor_type WHEN 'person' THEN p.name WHEN 'bot' THEN b.name END AS actor_name FROM task_events e LEFT JOIN persons p ON e.actor_type = 'person' AND p.id = e.actor_id LEFT JOIN bots b ON e.actor_type = 'bot' AND b.id = e.actor_id WHERE e.task_id = ? ORDER BY e.id").all(required3(id2)).map((row2) => ({
24780
25165
  kind: row2.kind,
24781
- actor: row2.actor_type == null ? null : { type: row2.actor_type, id: Number(row2.actor_id) },
25166
+ actor: row2.actor_type == null ? null : {
25167
+ type: row2.actor_type,
25168
+ id: Number(row2.actor_id),
25169
+ name: row2.actor_name == null ? null : String(row2.actor_name)
25170
+ },
24782
25171
  changes: row2.changes == null ? null : JSON.parse(String(row2.changes)),
24783
25172
  at: iso4(row2.created_at)
24784
25173
  })), "events")
@@ -24789,11 +25178,11 @@ var workTasksOver = /* @__PURE__ */ __name((context) => {
24789
25178
  return {
24790
25179
  ...operations,
24791
25180
  create: /* @__PURE__ */ __name(async (input, by) => operations.create(input, by), "create"),
24792
- assign: /* @__PURE__ */ __name(async (id2, assignment, by) => operations.assign(id2, assignment, by), "assign")
25181
+ assign: /* @__PURE__ */ __name(async (id2, assignment, by, check3) => operations.assign(id2, assignment, by, check3), "assign")
24793
25182
  };
24794
25183
  }, "workTasksOver");
24795
25184
 
24796
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
25185
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
24797
25186
  var taskCloseOver = /* @__PURE__ */ __name((context) => {
24798
25187
  const { database, now: now2 } = context;
24799
25188
  const liveRow = /* @__PURE__ */ __name((id2) => {
@@ -24811,7 +25200,7 @@ var taskCloseOver = /* @__PURE__ */ __name((context) => {
24811
25200
  closeSuggestion: /* @__PURE__ */ __name(async (id2) => closeSuggestionOf(database, liveRow(id2)), "closeSuggestion"),
24812
25201
  suggestClose: /* @__PURE__ */ __name(async (id2, suggestion, by) => write(database, () => {
24813
25202
  const row2 = liveRow(id2);
24814
- if (row2.status !== "open")
25203
+ if (isClosedState(String(row2.status)))
24815
25204
  throw new CliError("validation_error", `task ${String(row2.key)} is already ${String(row2.status)}`, {
24816
25205
  reason: "task.closed"
24817
25206
  });
@@ -24834,12 +25223,15 @@ var taskCloseOver = /* @__PURE__ */ __name((context) => {
24834
25223
  }), "suggestClose"),
24835
25224
  recordCloseCertainty: /* @__PURE__ */ __name(async (id2, certainty) => write(database, () => {
24836
25225
  const row2 = liveRow(id2);
24837
- database.prepare("UPDATE tasks SET close_certainty = ? WHERE id = ?").run(certaintyOf(certainty), Number(row2.id));
25226
+ const value = certaintyOf(certainty);
25227
+ database.prepare("UPDATE tasks SET close_certainty = ? WHERE id = ?").run(value, Number(row2.id));
25228
+ if ((row2.close_certainty ?? null) !== value)
25229
+ recordTaskEvent(database, Number(row2.id), null, "close-certainty", { close_certainty: [row2.close_certainty ?? null, value] }, now2());
24838
25230
  }), "recordCloseCertainty")
24839
25231
  };
24840
25232
  }, "taskCloseOver");
24841
25233
 
24842
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
25234
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
24843
25235
  var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
24844
25236
  const { database, now: now2 } = context;
24845
25237
  const required3 = /* @__PURE__ */ __name((id2) => {
@@ -24926,7 +25318,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
24926
25318
  }, "linkMessage");
24927
25319
  const followUp = /* @__PURE__ */ __name(async (row2, candidates, by) => write(database, () => {
24928
25320
  for (const one of candidates) {
24929
- if (one.status === "open" || one.band === "different")
25321
+ if (!isClosedState(one.status) || one.band === "different")
24930
25322
  continue;
24931
25323
  const closed = required3(one.key);
24932
25324
  if (mergedInto(closed))
@@ -24946,7 +25338,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
24946
25338
  const alike = (await similarity.similar({ task: String(row2.key) }, { limit: 40 })).filter((one) => one.band !== "different");
24947
25339
  if (!linked)
24948
25340
  await followUp(row2, alike, { bot: "rule" });
24949
- const found2 = linked ? alike : alike.filter((one) => one.status === "open");
25341
+ const found2 = linked ? alike : alike.filter((one) => !isClosedState(one.status));
24950
25342
  if (found2.length === 0)
24951
25343
  return 0;
24952
25344
  return write(database, () => {
@@ -24995,7 +25387,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
24995
25387
  const a = required3(dup);
24996
25388
  const b = required3(into);
24997
25389
  sameInbox(a, b);
24998
- if (a.status !== "open")
25390
+ if (isClosedState(String(a.status)))
24999
25391
  throw new CliError("validation_error", `task ${String(a.key)} is already ${String(a.status)}; a merge closes an open task \u2014 reopen it with tasks unmerge if a merge closed it`, { reason: "task.closed" });
25000
25392
  const onward = mergedInto(b);
25001
25393
  if (onward)
@@ -25057,7 +25449,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
25057
25449
  };
25058
25450
  }, "taskPairsOver");
25059
25451
 
25060
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
25452
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
25061
25453
  var COLUMNS3 = "t.id AS row_id, t.package_id, t.source_locator, t.source_kind, t.source_group, t.type, t.status, t.close_reason, t.source, t.created_at, t.due_at, t.closed_at, t.closed_by_type, t.closed_by_id, t.key, t.category, t.claimed_by, t.claimed_until, p.name AS account";
25062
25454
  var taskStoreOver = /* @__PURE__ */ __name((context) => {
25063
25455
  const { database, now: now2 } = context;
@@ -25185,8 +25577,8 @@ var taskStoreOver = /* @__PURE__ */ __name((context) => {
25185
25577
  write(database, () => {
25186
25578
  const before2 = database.prepare("SELECT status, due_at FROM tasks WHERE id = ?").get(row2);
25187
25579
  const at = now2();
25188
- database.prepare("UPDATE tasks SET status = ?, close_reason = ?, close_reason_folded = ?, due_at = ?, closed_at = ?, closed_by_type = ?, closed_by_id = ?, updated_at = ?, claimed_by = CASE WHEN ? = 'open' THEN claimed_by END, claimed_until = CASE WHEN ? = 'open' THEN claimed_until END, close_certainty = CASE WHEN ? = 'open' THEN NULL ELSE close_certainty END WHERE id = ?").run(task.state, task.reason ?? null, folded3(task.reason), time(task.dueAt), time(task.closedAt), closedBy?.type ?? null, closedBy?.id ?? null, at, task.state, task.state, task.state, row2);
25189
- if (task.state !== "open")
25580
+ database.prepare("UPDATE tasks SET status = ?, close_reason = ?, close_reason_folded = ?, due_at = ?, closed_at = ?, closed_by_type = ?, closed_by_id = ?, updated_at = ?, claimed_by = CASE WHEN ? NOT IN ('done', 'dismissed') THEN claimed_by END, claimed_until = CASE WHEN ? NOT IN ('done', 'dismissed') THEN claimed_until END, close_certainty = CASE WHEN ? NOT IN ('done', 'dismissed') THEN NULL ELSE close_certainty END WHERE id = ?").run(task.state, task.reason ?? null, folded3(task.reason), time(task.dueAt), time(task.closedAt), closedBy?.type ?? null, closedBy?.id ?? null, at, task.state, task.state, task.state, row2);
25581
+ if (isClosedState(task.state))
25190
25582
  database.prepare(`UPDATE tasks SET ${CLEAR_SUGGESTION} WHERE id = ?`).run(row2);
25191
25583
  if (before2.status !== task.state)
25192
25584
  recordTaskEvent(database, row2, closedBy ?? null, "status", { status: [before2.status, task.state] }, at);
@@ -25202,7 +25594,10 @@ var taskStoreOver = /* @__PURE__ */ __name((context) => {
25202
25594
  const row2 = required3(id2);
25203
25595
  const at = now2();
25204
25596
  write(database, () => {
25597
+ const before2 = database.prepare("SELECT resolution FROM tasks WHERE id = ?").get(row2)?.resolution ?? null;
25205
25598
  database.prepare("UPDATE tasks SET resolution = ?, updated_at = ? WHERE id = ?").run(text5, at, row2);
25599
+ if (before2 !== text5)
25600
+ recordTaskEvent(database, row2, null, "resolution", { resolution: [before2, text5] }, at);
25206
25601
  if (!by)
25207
25602
  return;
25208
25603
  database.prepare(`DELETE FROM links WHERE from_type = 'task' AND from_id = ? AND kind = ${linkKind("answered-by")}`).run(row2);
@@ -25213,7 +25608,14 @@ var taskStoreOver = /* @__PURE__ */ __name((context) => {
25213
25608
  judge: /* @__PURE__ */ __name(async (id2, verdict) => {
25214
25609
  if (verdict !== null && !TASK_VERDICTS.includes(verdict))
25215
25610
  throw new CliError("validation_error", `a verdict is one of ${TASK_VERDICTS.join(", ")}`);
25216
- database.prepare("UPDATE tasks SET verdict = ?, updated_at = ? WHERE id = ?").run(verdict, now2(), required3(id2));
25611
+ const row2 = required3(id2);
25612
+ write(database, () => {
25613
+ const at = now2();
25614
+ const before2 = database.prepare("SELECT verdict FROM tasks WHERE id = ?").get(row2)?.verdict ?? null;
25615
+ database.prepare("UPDATE tasks SET verdict = ?, updated_at = ? WHERE id = ?").run(verdict, at, row2);
25616
+ if (before2 !== verdict)
25617
+ recordTaskEvent(database, row2, null, "verdict", { verdict: [before2, verdict] }, at);
25618
+ });
25217
25619
  }, "judge")
25218
25620
  };
25219
25621
  }, "taskStoreOver");
@@ -25252,7 +25654,7 @@ var oneOf3 = /* @__PURE__ */ __name((values, value, column2) => {
25252
25654
  throw new CliError("configuration_error", `the store holds a task with an unknown ${column2} "${String(value)}"`);
25253
25655
  }, "oneOf");
25254
25656
 
25255
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/accounts.js
25657
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/accounts.js
25256
25658
  var accountAccountsOver = /* @__PURE__ */ __name((context) => {
25257
25659
  const { database } = context;
25258
25660
  const { accountPk: accountPk2, findAccountPk: findAccountPk2 } = keysOver(context);
@@ -25297,7 +25699,7 @@ var accountsStoreOver = /* @__PURE__ */ __name((context, keyed) => {
25297
25699
  };
25298
25700
  }, "accountsStoreOver");
25299
25701
 
25300
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
25702
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
25301
25703
  var refColumn = /* @__PURE__ */ __name((ref3) => ref3 && Object.keys(ref3).length > 0 ? { providerRef: JSON.stringify(ref3) } : {}, "refColumn");
25302
25704
  var updatePlaced = /* @__PURE__ */ __name(({ orm }, chatKey, messageId, files2, change) => {
25303
25705
  const message2 = orm.select({ pk: messages.id }).from(messages).where(and(eq(messages.chatId, chatKey), eq(messages.externalId, messageId))).get();
@@ -25321,7 +25723,7 @@ var keepDownloads = /* @__PURE__ */ __name((context, chatKey, messageId, files2)
25321
25723
  })), "keepDownloads");
25322
25724
  var keepProviderRefs = /* @__PURE__ */ __name((context, chatKey, messageId, files2) => updatePlaced(context, chatKey, messageId, files2.filter((file) => Object.keys(file.providerRef).length > 0), (file) => refColumn(file.providerRef)), "keepProviderRefs");
25323
25725
 
25324
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/attachments.js
25726
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/attachments.js
25325
25727
  var accountAttachmentsOver = /* @__PURE__ */ __name((context) => {
25326
25728
  const { database } = context;
25327
25729
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -25378,7 +25780,7 @@ var attachmentsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
25378
25780
  }, "keepAttachmentText")
25379
25781
  }), "attachmentsStoreOver");
25380
25782
 
25381
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
25783
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
25382
25784
  var chatRow = /* @__PURE__ */ __name((context, accountKey, chatId) => context.database.prepare("SELECT * FROM chats WHERE account_id = ? AND external_id = ?").get(accountKey, chatId), "chatRow");
25383
25785
  var pointerMover = /* @__PURE__ */ __name((context, type) => {
25384
25786
  const statements = pointerPairs(context.database).filter(({ table }) => table !== "involvements").map(({ table, pointer }) => {
@@ -25525,14 +25927,14 @@ var moveChat = /* @__PURE__ */ __name((context, key2, accountKey, old, twin, fro
25525
25927
  throw new CliError("validation_error", `a ${String(old.kind)} and a ${String(twin.kind)} are not one chat`);
25526
25928
  const strict = stricterPrivacy(context, accountKey, privacyOf(old), privacyOf(twin));
25527
25929
  moved = absorb(context, kept, Number(twin.id));
25528
- const fields4 = MESSENGER_FIELDS.map((field3) => `${field3} = coalesce(?, ${field3})`).join(", ");
25930
+ const fields4 = MESSENGER_FIELDS.map((field4) => `${field4} = coalesce(?, ${field4})`).join(", ");
25529
25931
  context.database.prepare(
25530
25932
  // Left only when both were: a complete chat list that named the new id before the re-key marked the old one.
25531
25933
  `UPDATE chats SET ${fields4}, kind = CASE WHEN kind = 'unknown' THEN ? ELSE kind END,
25532
25934
  membership_state = CASE WHEN ? IS NULL THEN nullif(membership_state, 'left') ELSE coalesce(nullif(?, 'left'), membership_state) END,
25533
25935
  muted_until = CASE WHEN ? IS NULL THEN muted_until ELSE ? END,
25534
25936
  searchable = ?, scope = ?, last_message_at = ?, updated_at = ? WHERE id = ?`
25535
- ).run(...MESSENGER_FIELDS.map((field3) => scalar(twin[field3])), scalar(twin.kind), scalar(twin.membership_state), scalar(twin.membership_state), scalar(twin.muted), scalar(twin.muted_until), strict.searchable, strict.scope, latest(old.last_message_at, twin.last_message_at), context.now(), kept);
25937
+ ).run(...MESSENGER_FIELDS.map((field4) => scalar(twin[field4])), scalar(twin.kind), scalar(twin.membership_state), scalar(twin.membership_state), scalar(twin.muted), scalar(twin.muted_until), strict.searchable, strict.scope, latest(old.last_message_at, twin.last_message_at), context.now(), kept);
25536
25938
  }
25537
25939
  context.database.prepare("UPDATE chats SET external_id = ?, updated_at = ? WHERE id = ?").run(to, context.now(), kept);
25538
25940
  renameText(context, key2, accountKey, from2, to);
@@ -25558,7 +25960,7 @@ var rekeyChats = /* @__PURE__ */ __name((context, key2, accountKey, pairs, lockM
25558
25960
  return done;
25559
25961
  }, "rekeyChats");
25560
25962
 
25561
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
25963
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
25562
25964
  var historyStartKey = /* @__PURE__ */ __name((chatId) => `history_start:${chatId}`, "historyStartKey");
25563
25965
  var fetchedKey = /* @__PURE__ */ __name((chatId) => `fetched:${chatId}`, "fetchedKey");
25564
25966
  var CHAT_LIST_KEY = "chat_list_complete";
@@ -25590,7 +25992,7 @@ var chatCompleteness = /* @__PURE__ */ __name(({ database }, accountKey, chatIds
25590
25992
  });
25591
25993
  }, "chatCompleteness");
25592
25994
 
25593
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/chats.js
25995
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/chats.js
25594
25996
  var chatsStoreOver = /* @__PURE__ */ __name((context) => {
25595
25997
  const { database } = context;
25596
25998
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, writeState: writeState2 } = keysOver(context);
@@ -25697,7 +26099,7 @@ var chatsStoreOver = /* @__PURE__ */ __name((context) => {
25697
26099
  };
25698
26100
  }, "chatsStoreOver");
25699
26101
 
25700
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
26102
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
25701
26103
  import { createHash as createHash6 } from "node:crypto";
25702
26104
  var BATCH_CONTEXT = 50;
25703
26105
  var replied = /* @__PURE__ */ __name((m) => sql`EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
@@ -25835,7 +26237,7 @@ var saveAnswers = /* @__PURE__ */ __name((context, id2, answer) => {
25835
26237
  var clearAnswers = /* @__PURE__ */ __name(({ orm }, chatKey, model) => Number(orm.all(sql`DELETE FROM message_links WHERE chat_id = ${chatKey} AND source = 'agent'
25836
26238
  ${model === void 0 ? sql`` : sql`AND method = ${model}`} RETURNING 1 AS n`).length), "clearAnswers");
25837
26239
 
25838
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
26240
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
25839
26241
  import { setTimeout } from "node:timers/promises";
25840
26242
  var position = /* @__PURE__ */ __name((sentAt, pk) => `${sentAt}:${pk}`, "position");
25841
26243
  var linkInputs = /* @__PURE__ */ __name(({ orm }, chatKey, { after: after2, limit }) => {
@@ -26147,7 +26549,7 @@ var agentAnswers = /* @__PURE__ */ __name(({ orm }, chatKey) => new Map(orm.all(
26147
26549
  AND NOT EXISTS (SELECT 1 FROM messages d
26148
26550
  WHERE d.id IN (l.message_id, l.parent_id) AND d.deleted_at > l.created_at)`).map(({ id: id2, parent: parent2 }) => [id2, parent2])), "agentAnswers");
26149
26551
 
26150
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/conversations.js
26552
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/conversations.js
26151
26553
  var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
26152
26554
  const { database } = context;
26153
26555
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -26254,7 +26656,7 @@ var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
26254
26656
  };
26255
26657
  }, "conversationsStoreOver");
26256
26658
 
26257
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/counters.js
26659
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/counters.js
26258
26660
  var LIVE_MESSAGE = "SELECT m.id AS pk FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id WHERE ac.provider=? AND ac.external_id=? AND c.external_id=? AND m.external_id=? AND m.deleted_at IS NULL";
26259
26661
  var accountCountersOver = /* @__PURE__ */ __name((context) => {
26260
26662
  const { database } = context;
@@ -26279,7 +26681,7 @@ var countersStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
26279
26681
  counterTargets: /* @__PURE__ */ __name(async (execution, options) => counterTargets(context, execution, options), "counterTargets")
26280
26682
  }), "countersStoreOver");
26281
26683
 
26282
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
26684
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
26283
26685
  var MENTION_STATUSES = ["found", "linked", "dismissed"];
26284
26686
  var MENTION_QUERY = defineQuery({
26285
26687
  entity: "mention",
@@ -26495,7 +26897,7 @@ var listPlaces = /* @__PURE__ */ __name((database, { limit, offset }) => {
26495
26897
  return { items: hasMore ? rows.slice(0, limit) : rows, hasMore };
26496
26898
  }, "listPlaces");
26497
26899
 
26498
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/mentions.js
26900
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/mentions.js
26499
26901
  var accountMentionsOver = /* @__PURE__ */ __name((context) => {
26500
26902
  const { database } = context;
26501
26903
  const { findAccountPk: findAccountPk2 } = keysOver(context);
@@ -26530,7 +26932,7 @@ var mentionsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
26530
26932
  places: /* @__PURE__ */ __name(async (window) => listPlaces(context.database, window), "places")
26531
26933
  }), "mentionsStoreOver");
26532
26934
 
26533
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
26935
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
26534
26936
  var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messageId) => {
26535
26937
  const read2 = database.prepare("SELECT m.id, m.external_id, m.text, m.sent_at, m.sender_name, coalesce(m.sender_chat_external_id, i.external_id) AS sender_id FROM messages m LEFT JOIN identities i ON i.id = m.sender_identity_id WHERE m.chat_id = ? AND m.deleted_at IS NULL AND (m.text LIKE '%google.com%' OR m.text LIKE '%forms.gle%') " + (messageId === void 0 ? "" : "AND m.external_id = ? ") + "ORDER BY m.sent_at DESC, m.id DESC");
26536
26938
  const rows = messageId === void 0 ? read2.all(chatKey) : read2.all(chatKey, messageId);
@@ -26545,7 +26947,7 @@ var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messag
26545
26947
  }));
26546
26948
  }, "documentLinkMessages");
26547
26949
 
26548
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
26950
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
26549
26951
  var stemmerFor = stemmerCache();
26550
26952
  var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit }) => {
26551
26953
  if (wanted.length > 50 || !Number.isInteger(limit) || limit < 1 || limit > 100)
@@ -26555,13 +26957,12 @@ var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit
26555
26957
  if (!wanted.length || !stemmers || !stemsState(database)?.ready)
26556
26958
  return wanted.map(() => []);
26557
26959
  const stemmer = stemmerFor(stemmers);
26558
- database.exec("CREATE VIRTUAL TABLE IF NOT EXISTS temp.message_stem_counts USING fts5vocab(main, message_stems, col)");
26559
- const count = database.prepare("SELECT doc FROM temp.message_stem_counts WHERE term = ? AND col = 'stems'");
26960
+ const count = database.prepare("SELECT count(*) AS doc FROM (SELECT rowid FROM message_stems WHERE message_stems MATCH ? LIMIT ?)");
26560
26961
  const counts = /* @__PURE__ */ new Map();
26561
26962
  const countOf = /* @__PURE__ */ __name((stem) => {
26562
26963
  let found2 = counts.get(stem);
26563
26964
  if (found2 === void 0) {
26564
- found2 = Number(count.get(stem)?.doc ?? 0);
26965
+ found2 = Number(count.get(`stems : "${stem.replaceAll('"', '""')}"`, rareAt + 1)?.doc ?? 0);
26565
26966
  counts.set(stem, found2);
26566
26967
  }
26567
26968
  return found2;
@@ -26590,7 +26991,7 @@ var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit
26590
26991
  });
26591
26992
  }, "laterSharingRare");
26592
26993
 
26593
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/messages.js
26994
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/messages.js
26594
26995
  var accountMessagesOver = /* @__PURE__ */ __name((context) => {
26595
26996
  const { database } = context;
26596
26997
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf, chatPkFor: chatPkFor2, answeredChatPk: answeredChatPk2, upsertMessage: upsertMessage2 } = keysOver(context);
@@ -26725,7 +27126,7 @@ var messagesStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
26725
27126
  laterSharingRare: /* @__PURE__ */ __name(async (wanted, options) => laterSharingRare(context, wanted, options), "laterSharingRare")
26726
27127
  }), "messagesStoreOver");
26727
27128
 
26728
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
27129
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
26729
27130
  var GLOBAL_PROJECT = "SELECT id FROM main.projects WHERE account_id IS NULL AND deleted_at IS NULL";
26730
27131
  var iso5 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
26731
27132
  var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: accounts2, limit }) => {
@@ -26765,7 +27166,7 @@ var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: a
26765
27166
  }));
26766
27167
  const tasks2 = database.prepare(`SELECT t.id,t.title,t.due_at,t.project_id,t.source_locator,t.created_at,group_concat(DISTINCT ta.role) AS role
26767
27168
  FROM task_assignments ta JOIN tasks t ON t.id=ta.task_id JOIN main.projects p ON p.id=t.project_id
26768
- WHERE ta.assignee_type='person' AND ta.assignee_id=? AND t.deleted_at IS NULL AND t.status='open'
27169
+ WHERE ta.assignee_type='person' AND ta.assignee_id=? AND t.deleted_at IS NULL AND t.status NOT IN ('done','dismissed')
26769
27170
  AND p.deleted_at IS NULL AND (p.account_id IS NULL OR p.account_id IN (SELECT a.id FROM accounts a
26770
27171
  JOIN json_each(?) k ON a.provider=json_extract(k.value,'$.provider')
26771
27172
  AND a.external_id=json_extract(k.value,'$.account')))
@@ -26782,7 +27183,7 @@ var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: a
26782
27183
  });
26783
27184
  }, "personPreparation");
26784
27185
 
26785
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
27186
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
26786
27187
  var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds) => {
26787
27188
  const id2 = Number(uid);
26788
27189
  if (!/^[1-9]\d*$/.test(uid) || !Number.isSafeInteger(id2) || !accountIds.length || accountIds.length > 1e3 || accountIds.some((account) => !Number.isSafeInteger(account) || account <= 0))
@@ -26790,7 +27191,7 @@ var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds
26790
27191
  return Boolean(database.prepare("SELECT 1 FROM persons p JOIN identity_links l ON l.person_id=p.id JOIN account_identities a ON a.identity_id=l.identity_id WHERE p.id=? AND a.account_id IN (SELECT value FROM json_each(?)) LIMIT 1").get(id2, JSON.stringify(accountIds)));
26791
27192
  }, "personSeenInAccounts");
26792
27193
 
26793
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
27194
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
26794
27195
  var required2 = /* @__PURE__ */ __name(({ database }, key2, personId) => {
26795
27196
  const row2 = database.prepare("SELECT a.id AS account_id, i.id AS identity_id FROM accounts a JOIN account_identities ai ON ai.account_id=a.id JOIN identities i ON i.id=ai.identity_id WHERE a.provider=? AND a.external_id=? AND i.provider=? AND i.external_id=?").get(key2.provider, key2.account, key2.provider, personId);
26796
27197
  if (!row2)
@@ -26856,7 +27257,7 @@ var removeNote = /* @__PURE__ */ __name((context, key2, personId, id2) => {
26856
27257
  return { id: id2, personId, removed: true };
26857
27258
  }, "removeNote");
26858
27259
 
26859
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/people.js
27260
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/people.js
26860
27261
  var accountPeopleOver = /* @__PURE__ */ __name((context) => {
26861
27262
  const { database } = context;
26862
27263
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, identityPk: identityPk2 } = keysOver(context);
@@ -26931,13 +27332,13 @@ var peopleStoreOver = /* @__PURE__ */ __name((context, keyed) => {
26931
27332
  };
26932
27333
  }, "peopleStoreOver");
26933
27334
 
26934
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
27335
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
26935
27336
  import { createHash as createHash8 } from "node:crypto";
26936
27337
 
26937
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
27338
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
26938
27339
  import { createHash as createHash7 } from "node:crypto";
26939
27340
 
26940
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
27341
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
26941
27342
  var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
26942
27343
  var AUTHOR_MEASURES = [
26943
27344
  "messages",
@@ -27077,7 +27478,7 @@ var withoutUrls = /* @__PURE__ */ __name((text5) => text5.replace(/\S+/gu, (toke
27077
27478
  var rankingWords = /* @__PURE__ */ __name((text5) => withoutUrls(text5).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
27078
27479
  var rankingQuestion = /* @__PURE__ */ __name((text5) => withoutUrls(text5).includes("?"), "rankingQuestion");
27079
27480
 
27080
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
27481
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
27081
27482
  var RANKING_GRAPH_LIMITS = { nodes: 5e4, depth: 256, work: 1e7, bytes: 8388608 };
27082
27483
  var exhausted2 = /* @__PURE__ */ __name((budget) => {
27083
27484
  throw new CliError("validation_error", `ranking exceeded ${budget} \u2014 narrow its chat or date scope`, {
@@ -27299,7 +27700,7 @@ var rankReplyGraph = /* @__PURE__ */ __name((nodes, check3 = () => {
27299
27700
  };
27300
27701
  }, "rankReplyGraph");
27301
27702
 
27302
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
27703
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
27303
27704
  var adminEntityKey = /* @__PURE__ */ __name((row2) => JSON.stringify([row2.account.provider, row2.account.account, row2.id]), "adminEntityKey");
27304
27705
  var personKey = /* @__PURE__ */ __name((node) => JSON.stringify([node.account.provider, node.account.account, node.sender]), "personKey");
27305
27706
  var locator = /* @__PURE__ */ __name((node) => formatLocator({ ...node.account, chat: node.chatId, message: node.id }), "locator");
@@ -27473,7 +27874,7 @@ var calculateAdminStatistics = /* @__PURE__ */ __name((nodes, stays, options, in
27473
27874
  return { items, evidence, summary, graph: graph.quality };
27474
27875
  }, "calculateAdminStatistics");
27475
27876
 
27476
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
27877
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
27477
27878
  var rankingContextRange = /* @__PURE__ */ __name((root) => {
27478
27879
  const dates = [];
27479
27880
  const visit = /* @__PURE__ */ __name((node, required3) => {
@@ -27495,7 +27896,7 @@ var rankingContextRange = /* @__PURE__ */ __name((root) => {
27495
27896
  return dates[0].node.resolution.date;
27496
27897
  }, "rankingContextRange");
27497
27898
 
27498
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
27899
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
27499
27900
  var reactionCounts = /* @__PURE__ */ __name((stored3) => {
27500
27901
  let counts;
27501
27902
  try {
@@ -27513,9 +27914,9 @@ var reactionCounts = /* @__PURE__ */ __name((stored3) => {
27513
27914
  var column = /* @__PURE__ */ __name((name) => `"${name.replaceAll('"', '""')}"`, "column");
27514
27915
  var finite = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null, "finite");
27515
27916
  var metadata2 = /* @__PURE__ */ __name((alias2) => `CASE WHEN json_valid(${alias2}.metadata) THEN ${alias2}.metadata ELSE '{}' END`, "metadata");
27516
- var rankingCounter = /* @__PURE__ */ __name((alias2, field3, reactions = false) => {
27917
+ var rankingCounter = /* @__PURE__ */ __name((alias2, field4, reactions = false) => {
27517
27918
  const source2 = reactions ? `CASE WHEN json_valid(${alias2}.reactions) THEN ${alias2}.reactions ELSE '{}' END` : metadata2(alias2);
27518
- const path = reactions ? "$.total" : `$.${field3}`;
27919
+ const path = reactions ? "$.total" : `$.${field4}`;
27519
27920
  const value = `json_extract(${source2},'${path}')`;
27520
27921
  return `CASE WHEN json_type(${source2},'${path}') IN ('integer','real') AND ${value}>=0 AND ${value}<=1.7976931348623157e308 THEN CAST(${value} AS REAL) END`;
27521
27922
  }, "rankingCounter");
@@ -27790,7 +28191,7 @@ var rankQuery = /* @__PURE__ */ __name((context, execution, request, inspect) =>
27790
28191
  });
27791
28192
  }, "rankQuery");
27792
28193
 
27793
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
28194
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
27794
28195
  function fail4(message2, reason = "query.too-large") {
27795
28196
  throw new CliError("validation_error", message2, { reason, complete: false });
27796
28197
  }
@@ -27811,12 +28212,12 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
27811
28212
  } else
27812
28213
  scope3 += " AND c.searchable=1";
27813
28214
  const where = `m.deleted_at IS NULL AND ${scope3} AND (m.sent_at BETWEEN ? AND ?${options.report === "newcomers" ? "" : " OR m.id IN (SELECT id FROM selected)"})`;
27814
- const bound4 = [...selection.params, ...params, lower, options.cutoff];
27815
- const size2 = database.prepare(`${prefix}SELECT count(*) AS n,sum(length(cast(m.text AS BLOB))+length(cast(coalesce(m.metadata,'') AS BLOB))+length(cast(${snapshot} AS BLOB))) AS bytes ${joined3} WHERE ${where}`).get(...bound4);
28215
+ const bound5 = [...selection.params, ...params, lower, options.cutoff];
28216
+ const size2 = database.prepare(`${prefix}SELECT count(*) AS n,sum(length(cast(m.text AS BLOB))+length(cast(coalesce(m.metadata,'') AS BLOB))+length(cast(${snapshot} AS BLOB))) AS bytes ${joined3} WHERE ${where}`).get(...bound5);
27816
28217
  check3();
27817
28218
  if (Number(size2?.n ?? 0) > RANKING_GRAPH_LIMITS.nodes || Number(size2?.bytes ?? 0) > RANKING_GRAPH_LIMITS.bytes)
27818
28219
  fail4("admin statistics context exceeds node/byte budgets \u2014 narrow chat/date scope");
27819
- const raw = database.prepare(`${prefix}SELECT m.id AS pk,m.external_id AS id,c.id AS chat_id,ac.id AS account_id,c.external_id AS chat,c.title AS title,c.kind,ac.provider,ac.external_id AS account,i.external_id AS sender,m.sender_chat_external_id AS sender_chat,i.bot,m.sent_at,m.text,m.metadata,${rankingCounter("m", "views")} AS views,${rankingCounter("m", "comments")} AS comments,m.id IN (SELECT id FROM selected) AS selected ${joined3} WHERE ${where} ORDER BY m.id`).all(...bound4);
28220
+ const raw = database.prepare(`${prefix}SELECT m.id AS pk,m.external_id AS id,c.id AS chat_id,ac.id AS account_id,c.external_id AS chat,c.title AS title,c.kind,ac.provider,ac.external_id AS account,i.external_id AS sender,m.sender_chat_external_id AS sender_chat,i.bot,m.sent_at,m.text,m.metadata,${rankingCounter("m", "views")} AS views,${rankingCounter("m", "comments")} AS comments,m.id IN (SELECT id FROM selected) AS selected ${joined3} WHERE ${where} ORDER BY m.id`).all(...bound5);
27820
28221
  const nodes = raw.map((row2) => {
27821
28222
  let metadata3 = {};
27822
28223
  try {
@@ -27967,7 +28368,7 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
27967
28368
  return result;
27968
28369
  }), "adminStatisticsQuery");
27969
28370
 
27970
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
28371
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
27971
28372
  var conversationEligibility = /* @__PURE__ */ __name(async (context, execution) => {
27972
28373
  if (!execution.accounts.length)
27973
28374
  return { conversations: [], chats: [] };
@@ -27985,7 +28386,7 @@ var conversationEligibility = /* @__PURE__ */ __name(async (context, execution)
27985
28386
  return { conversations: conversations2, chats: chats2 };
27986
28387
  }, "conversationEligibility");
27987
28388
 
27988
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
28389
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
27989
28390
  import { createHash as createHash9 } from "node:crypto";
27990
28391
  var EVIDENCE_BYTES = 64 * 1024;
27991
28392
  var FINGERPRINT_BYTES = 8 * 1024 * 1024;
@@ -28135,7 +28536,7 @@ var rankingEvidence = /* @__PURE__ */ __name((context, execution, request) => {
28135
28536
  return result;
28136
28537
  }, "rankingEvidence");
28137
28538
 
28138
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/queries.js
28539
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/queries.js
28139
28540
  var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
28140
28541
  const mailIndexed = /* @__PURE__ */ __name((execution) => {
28141
28542
  if (execution.corpus === "mail")
@@ -28146,6 +28547,7 @@ var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
28146
28547
  matchQuery: /* @__PURE__ */ __name(async (execution) => matchQuery(context, mailIndexed(execution)), "matchQuery"),
28147
28548
  countQuery: /* @__PURE__ */ __name(async (execution, by) => countQuery(context, mailIndexed(execution), by), "countQuery"),
28148
28549
  countMatches: /* @__PURE__ */ __name(async (execution, cap) => countMatches(context, mailIndexed(execution), cap), "countMatches"),
28550
+ matchingPks: /* @__PURE__ */ __name(async (execution, cap) => matchingPks(context, mailIndexed(execution), cap), "matchingPks"),
28149
28551
  conversationEligibility: /* @__PURE__ */ __name(async (execution) => conversationEligibility(context, execution), "conversationEligibility"),
28150
28552
  rankQuery: /* @__PURE__ */ __name(async (execution, request) => rankQuery(context, execution, request), "rankQuery"),
28151
28553
  rankingEvidence: /* @__PURE__ */ __name(async (execution, request) => rankingEvidence(context, execution, request), "rankingEvidence"),
@@ -28153,7 +28555,7 @@ var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
28153
28555
  };
28154
28556
  }, "queriesStoreOver");
28155
28557
 
28156
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
28558
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
28157
28559
  var saveChatEvents = /* @__PURE__ */ __name((context, accountKey, provider, chatKey, events3) => {
28158
28560
  const { database, now: now2 } = context;
28159
28561
  const insert = database.prepare(`INSERT INTO chat_events (chat_id, source_id, action, actor_identity_id, title, happened_at, created_at, updated_at)
@@ -28192,10 +28594,10 @@ var chatEventsOf = /* @__PURE__ */ __name(({ database }, chatKey, { since = 0, l
28192
28594
  }));
28193
28595
  }, "chatEventsOf");
28194
28596
 
28195
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
28597
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
28196
28598
  import { createHash as createHash10 } from "node:crypto";
28197
28599
 
28198
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/calendar.js
28600
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/calendar.js
28199
28601
  var calendarKey = /* @__PURE__ */ __name((zone, by) => {
28200
28602
  const format = new Intl.DateTimeFormat("en-CA", {
28201
28603
  timeZone: zone,
@@ -28210,7 +28612,7 @@ var calendarKey = /* @__PURE__ */ __name((zone, by) => {
28210
28612
  };
28211
28613
  }, "calendarKey");
28212
28614
 
28213
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/retention.js
28615
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/retention.js
28214
28616
  var RETENTION_TOLERANCE = 864e5;
28215
28617
  var validateRetentionOptions = /* @__PURE__ */ __name((options) => {
28216
28618
  const { since, until, cutoff, checkpoints, within, limit, by } = options;
@@ -28264,7 +28666,7 @@ var retentionCohorts = /* @__PURE__ */ __name((stays, options) => {
28264
28666
  return [...groups.values()].sort((a, b) => a.cohort.localeCompare(b.cohort));
28265
28667
  }, "retentionCohorts");
28266
28668
 
28267
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
28669
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
28268
28670
  var iso6 = /* @__PURE__ */ __name((at) => new Date(at).toISOString(), "iso");
28269
28671
  var week = /* @__PURE__ */ __name((day) => {
28270
28672
  const date3 = /* @__PURE__ */ new Date(`${day}T00:00:00Z`);
@@ -28400,7 +28802,7 @@ var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId
28400
28802
  };
28401
28803
  }, "retentionQuery");
28402
28804
 
28403
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
28805
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
28404
28806
  var iso7 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
28405
28807
  var marksOf = /* @__PURE__ */ __name(({ isBot, flagged, deleted, hasPhoto }) => ({
28406
28808
  ...isBot === void 0 ? {} : { bot: isBot },
@@ -28531,7 +28933,7 @@ var trackedChats = /* @__PURE__ */ __name((context, accountKey, where) => contex
28531
28933
  lastCount: memberCountsOf(context, pk).at(-1) ?? null
28532
28934
  })), "trackedChats");
28533
28935
 
28534
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/roster.js
28936
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/roster.js
28535
28937
  var rosterStoreOver = /* @__PURE__ */ __name((context) => {
28536
28938
  const { database } = context;
28537
28939
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, writeMembers: writeMembers2 } = keysOver(context);
@@ -28587,7 +28989,7 @@ var rosterStoreOver = /* @__PURE__ */ __name((context) => {
28587
28989
  };
28588
28990
  }, "rosterStoreOver");
28589
28991
 
28590
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
28992
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
28591
28993
  var pendingNormalization = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL").get()?.n), "pendingNormalization");
28592
28994
  var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatch, until = /* @__PURE__ */ __name(() => false, "until") } = {}) => {
28593
28995
  const next = database.prepare(`SELECT id AS pk, text FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL AND id > ? ORDER BY id LIMIT ?`);
@@ -28611,7 +29013,7 @@ var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatc
28611
29013
  }
28612
29014
  }, "backfillNormalized");
28613
29015
 
28614
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
29016
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
28615
29017
  var INDEX2 = "message_words";
28616
29018
  var searchIndexState2 = /* @__PURE__ */ __name((database) => {
28617
29019
  const row2 = indexRow(database, INDEX2);
@@ -28738,7 +29140,7 @@ var resetSearchIndex = /* @__PURE__ */ __name((database) => {
28738
29140
  });
28739
29141
  }, "resetSearchIndex");
28740
29142
 
28741
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
29143
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
28742
29144
  var fillStems = /* @__PURE__ */ __name((database, { batch = 5e3, until = /* @__PURE__ */ __name(() => false, "until"), onBatch, now: now2 = Date.now } = {}) => {
28743
29145
  const filled2 = { stemmed: 0, drained: 0 };
28744
29146
  const before2 = stemsState(database);
@@ -28833,7 +29235,7 @@ var followDefaultStemmers = /* @__PURE__ */ __name((database, now2 = Date.now) =
28833
29235
  return resetStems(database, { now: now2 });
28834
29236
  }, "followDefaultStemmers");
28835
29237
 
28836
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
29238
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
28837
29239
  var VOCABULARY = "SELECT term, doc FROM message_words_vocab WHERE col = 'normalized_text'";
28838
29240
  var knownTerms = /* @__PURE__ */ __name(({ database }, terms2) => {
28839
29241
  const lookup = database.prepare(`${VOCABULARY} AND term >= ? AND term <= ? LIMIT 1`);
@@ -28855,7 +29257,7 @@ var termCandidates = /* @__PURE__ */ __name(({ database }, pieces, { shortest, l
28855
29257
  });
28856
29258
  }, "termCandidates");
28857
29259
 
28858
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/search-index.js
29260
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/search-index.js
28859
29261
  var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
28860
29262
  const { database } = context;
28861
29263
  const stemmerFor2 = stemmerCache();
@@ -28877,7 +29279,7 @@ var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
28877
29279
  };
28878
29280
  }, "searchIndexStoreOver");
28879
29281
 
28880
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
29282
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
28881
29283
  var HISTORY_KEPT = 1e3;
28882
29284
  var commandFilter = /* @__PURE__ */ __name((commands) => commands ? { sql: ` AND command IN (${commands.map(() => "?").join(", ")})`, values: [...commands] } : { sql: "", values: [] }, "commandFilter");
28883
29285
  var COLUMNS5 = "id, name, command, params, language, version, fields_version, created_at, updated_at, last_run_at, runs";
@@ -28946,7 +29348,7 @@ var clearHistory = /* @__PURE__ */ __name(({ database }, commands) => {
28946
29348
  return database.prepare(`DELETE FROM searches WHERE name IS NULL${only.sql}`).run(...only.values).changes;
28947
29349
  }, "clearHistory");
28948
29350
 
28949
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/searches.js
29351
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/searches.js
28950
29352
  var searchesStoreOver = /* @__PURE__ */ __name((context) => {
28951
29353
  const { database } = context;
28952
29354
  return {
@@ -28970,7 +29372,7 @@ var searchesStoreOver = /* @__PURE__ */ __name((context) => {
28970
29372
  };
28971
29373
  }, "searchesStoreOver");
28972
29374
 
28973
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
29375
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
28974
29376
  var ACTION_TIERS = ["read", "draft", "write-private", "write-public", "destructive", "admin"];
28975
29377
  var ACTION_OUTCOMES = ["ok", "refused", "failed"];
28976
29378
  var CODE = /^[a-z][a-z0-9_]{0,63}$/;
@@ -29013,7 +29415,7 @@ var agentActionsStoreOver = /* @__PURE__ */ __name((context, afterRecord = () =>
29013
29415
  };
29014
29416
  }, "agentActionsStoreOver");
29015
29417
 
29016
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
29418
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
29017
29419
  var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
29018
29420
  }) => {
29019
29421
  const { database, now: now2 } = context;
@@ -29072,7 +29474,7 @@ var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
29072
29474
  };
29073
29475
  }, "botUpdateStoreOver");
29074
29476
 
29075
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
29477
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
29076
29478
  var DAY4 = 864e5;
29077
29479
  var listEvents = /* @__PURE__ */ __name((database, filter) => {
29078
29480
  const clauses = ["e.deleted_at IS NULL"];
@@ -29091,6 +29493,7 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
29091
29493
  }, "dated");
29092
29494
  dated("end_date > ?", filter.fromDate, "coalesce(e.ends_at, e.starts_at + 1) > ?", filter.from);
29093
29495
  dated("start_date < ?", filter.toDate, "e.starts_at < ?", filter.to);
29496
+ dated("start_date >= ?", filter.startsFromDate, "e.starts_at >= ?", filter.startsFrom);
29094
29497
  const longest = /* @__PURE__ */ __name(() => Number(database.prepare("SELECT coalesce(max(ends_at - starts_at), 0) AS ms FROM events WHERE deleted_at IS NULL").get()?.ms ?? 0), "longest");
29095
29498
  if (filter.from !== void 0) {
29096
29499
  clauses.push("e.starts_at >= ?");
@@ -29100,6 +29503,10 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
29100
29503
  clauses.push("e.starts_at < ?");
29101
29504
  params.push(filter.to + DAY4);
29102
29505
  }
29506
+ if (filter.startsFrom !== void 0 && filter.startsFromDate !== void 0) {
29507
+ clauses.push("e.starts_at >= ?");
29508
+ params.push(filter.startsFrom - DAY4);
29509
+ }
29103
29510
  if (filter.calendarId !== void 0) {
29104
29511
  clauses.push(entries("ce.calendar_id = ?"));
29105
29512
  params.push(filter.calendarId);
@@ -29152,7 +29559,7 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
29152
29559
  return database.prepare(`SELECT e.* FROM events e WHERE ${clauses.join(" AND ")} ORDER BY ${filter.newest ? "e.starts_at DESC, e.id DESC" : "e.starts_at, e.id"} LIMIT ? OFFSET ?`).all(...params, limit, offset).map(eventOf);
29153
29560
  }, "listEvents");
29154
29561
 
29155
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
29562
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
29156
29563
  var calendarOf = /* @__PURE__ */ __name((row2) => ({
29157
29564
  id: Number(row2.id),
29158
29565
  accountId: Number(row2.account_id),
@@ -29732,7 +30139,7 @@ var eventStoreOver = /* @__PURE__ */ __name((context) => {
29732
30139
  };
29733
30140
  }, "eventStoreOver");
29734
30141
 
29735
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
30142
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
29736
30143
  var CATALOG_QUERY = defineQuery({
29737
30144
  entity: "document",
29738
30145
  backend: "sql",
@@ -29770,7 +30177,7 @@ var objectOf2 = /* @__PURE__ */ __name((value) => {
29770
30177
  throw new CliError("invalid_response", "stored catalog metadata must be an object");
29771
30178
  return parsed2;
29772
30179
  }, "objectOf");
29773
- var field = /* @__PURE__ */ __name((value, max = 4e3) => {
30180
+ var field2 = /* @__PURE__ */ __name((value, max = 4e3) => {
29774
30181
  if (typeof value !== "string" || !value || value.length > max)
29775
30182
  throw new CliError("validation_error", "catalog field is empty or too long");
29776
30183
  return value;
@@ -29805,7 +30212,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
29805
30212
  throw new CliError("not_found", "catalog account is not in the local store");
29806
30213
  return Number(id2);
29807
30214
  }, "account");
29808
- const bound4 = /* @__PURE__ */ __name((id2, includeInactive = false) => {
30215
+ const bound5 = /* @__PURE__ */ __name((id2, includeInactive = false) => {
29809
30216
  const scope3 = "account_id = ? AND json_type(metadata, '$.catalog') = 'object'" + (includeInactive ? "" : " AND json_extract(metadata, '$.catalog.active') = 1 AND deleted_at IS NULL");
29810
30217
  const budget = database.prepare(`SELECT count(*) AS entries, sum(length(metadata)) AS bytes FROM documents WHERE ${scope3}`).get(id2);
29811
30218
  if (Number(budget?.bytes ?? 0) > 32 * 1024 * 1024)
@@ -29820,14 +30227,14 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
29820
30227
  throw new CliError("validation_error", "catalog writes take at most 200 entries");
29821
30228
  const seen = /* @__PURE__ */ new Set();
29822
30229
  const checked = inputs.map((input) => {
29823
- field(input.externalId);
30230
+ field2(input.externalId);
29824
30231
  if (seen.has(input.externalId))
29825
30232
  throw new CliError("validation_error", "catalog batch repeats an external id");
29826
30233
  seen.add(input.externalId);
29827
30234
  if (!["file", "folder"].includes(input.kind) || typeof input.name !== "string" || input.name.length > 4e3 || !Array.isArray(input.parents) || input.parents.length > 100)
29828
30235
  throw new CliError("validation_error", "invalid catalog name, kind or parents");
29829
30236
  for (const parent2 of input.parents)
29830
- field(parent2);
30237
+ field2(parent2);
29831
30238
  if (input.actors !== void 0) {
29832
30239
  if (!Array.isArray(input.actors) || input.actors.length > 100)
29833
30240
  throw new CliError("validation_error", "invalid catalog actors");
@@ -29836,7 +30243,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
29836
30243
  throw new CliError("validation_error", "invalid catalog actor");
29837
30244
  for (const value of [actor.id, actor.name, actor.email, actor.role])
29838
30245
  if (value !== void 0)
29839
- field(value);
30246
+ field2(value);
29840
30247
  }
29841
30248
  }
29842
30249
  if (input.size !== void 0 && (!Number.isSafeInteger(input.size) || input.size < 0))
@@ -29888,7 +30295,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
29888
30295
  const id2 = account(accountId);
29889
30296
  if (externalIds.length > 1e4)
29890
30297
  throw new CliError("validation_error", "catalog scope exceeds 10000 entries");
29891
- const current = [...new Set(externalIds.map((key2) => field(key2)))];
30298
+ const current = [...new Set(externalIds.map((key2) => field2(key2)))];
29892
30299
  return write(database, () => {
29893
30300
  const retired = database.prepare("UPDATE documents SET metadata=json_set(metadata, '$.catalog.active', json('false')) WHERE account_id=? AND json_type(metadata, '$.catalog')='object' AND json_extract(metadata, '$.catalog.active')=1" + (current.length ? " AND external_id NOT IN (SELECT value FROM json_each(?))" : "") + " RETURNING id").all(...current.length ? [id2, JSON.stringify(current)] : [id2]);
29894
30301
  const at = now2();
@@ -29967,14 +30374,14 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
29967
30374
  if (compiled.sql)
29968
30375
  add(compiled.sql, ...compiled.params);
29969
30376
  }
29970
- bound4(id2, query.includeInactive);
30377
+ bound5(id2, query.includeInactive);
29971
30378
  const found2 = database.prepare(`SELECT d.id, d.external_id, d.title, d.front_matter, d.metadata, d.deleted_at, d.body IS NOT NULL AS has_body FROM documents d WHERE ${clauses.join(" AND ")} ORDER BY d.external_id LIMIT ? OFFSET ?`).all(...params, limit + 1, offset);
29972
30379
  return { items: found2.slice(0, limit).map(entryOf2), hasMore: found2.length > limit };
29973
30380
  }, "list")
29974
30381
  };
29975
30382
  }, "catalogStoreOver");
29976
30383
 
29977
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/context/evidence.js
30384
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/context/evidence.js
29978
30385
  import { createHash as createHash11 } from "node:crypto";
29979
30386
  var CONTEXT_MAX_READ_BYTES = 262144;
29980
30387
  var CONTEXT_SOURCE_KINDS = ["message", "mail", "document", "meeting"];
@@ -30072,20 +30479,20 @@ var contextEvidenceRequest = /* @__PURE__ */ __name((input) => {
30072
30479
  return { source: source2, query, chat: chat2, senders, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal: input.signal };
30073
30480
  }, "contextEvidenceRequest");
30074
30481
 
30075
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
30482
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
30076
30483
  var drive = "CASE WHEN json_valid(n.front_matter) THEN json_extract(n.front_matter,'$.source')='google-drive' ELSE 0 END";
30077
- var field2 = /* @__PURE__ */ __name((name) => `CASE WHEN (${drive}) THEN
30484
+ var field3 = /* @__PURE__ */ __name((name) => `CASE WHEN (${drive}) THEN
30078
30485
  CASE WHEN json_type(n.front_matter,'$.${name}')='text' THEN json_extract(n.front_matter,'$.${name}') END END`, "field");
30079
30486
  var preferred = /* @__PURE__ */ __name((column2) => `(SELECT f.${column2} FROM files f JOIN documents d ON d.id = f.document_id WHERE f.document_id = n.id
30080
30487
  ORDER BY ${PREFERRED_FILE} LIMIT 1)`, "preferred");
30081
- var modified = `round(unixepoch(${field2("modifiedAt")},'subsec')*1000)`;
30488
+ var modified = `round(unixepoch(${field3("modifiedAt")},'subsec')*1000)`;
30082
30489
  var remoteTime = `coalesce(${preferred("external_updated_at")},n.external_updated_at,${modified})`;
30083
30490
  var contextDocumentTime = `coalesce(${remoteTime},n.updated_at)`;
30084
30491
  var contextDocumentTimeKind = `CASE WHEN (${remoteTime}) IS NOT NULL
30085
30492
  THEN 'source-modified' ELSE 'stored-update' END`;
30086
- var contextDocumentUrl = `coalesce(${preferred("url")},n.url,${field2("sourceUrl")})`;
30493
+ var contextDocumentUrl = `coalesce(${preferred("url")},n.url,${field3("sourceUrl")})`;
30087
30494
 
30088
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
30495
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
30089
30496
  var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
30090
30497
  const { source: source2, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal } = request;
30091
30498
  signal?.throwIfAborted();
@@ -30184,7 +30591,7 @@ var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
30184
30591
  });
30185
30592
  }, "readMeetingContextEvidence");
30186
30593
 
30187
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
30594
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
30188
30595
  var corpora = {
30189
30596
  message: {
30190
30597
  table: "messages",
@@ -30413,7 +30820,7 @@ var contextRecordsOver = /* @__PURE__ */ __name(({ database }) => ({
30413
30820
  }
30414
30821
  }), "contextRecordsOver");
30415
30822
 
30416
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
30823
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
30417
30824
  var NOTE_FIELDS = [
30418
30825
  "text",
30419
30826
  "exact",
@@ -30430,7 +30837,7 @@ var NOTE_FIELDS = [
30430
30837
  "source"
30431
30838
  ];
30432
30839
  var quoted2 = /* @__PURE__ */ __name((value) => `"${value.replaceAll('"', '""')}"`, "quoted");
30433
- var bound3 = /* @__PURE__ */ __name((sql2, ...params) => ({ sql: sql2, params, exact: true }), "bound");
30840
+ var bound4 = /* @__PURE__ */ __name((sql2, ...params) => ({ sql: sql2, params, exact: true }), "bound");
30434
30841
  var combine2 = /* @__PURE__ */ __name((parts2, operator) => ({
30435
30842
  sql: parts2.length ? `(${parts2.map(({ sql: sql2 }) => sql2).join(` ${operator} `)})` : operator === "AND" ? "1" : "0",
30436
30843
  params: parts2.flatMap(({ params }) => params),
@@ -30445,8 +30852,8 @@ var CORPORA2 = [
30445
30852
  words: "document_words",
30446
30853
  stems: "document_stems",
30447
30854
  live: "coalesce(json_extract(n.metadata, '$.catalog.active'), 1)=1",
30448
- inAccounts: /* @__PURE__ */ __name((ids) => bound3("n.folder_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))", ids), "inAccounts"),
30449
- tagged: /* @__PURE__ */ __name((tag2) => bound3(`(n.id IN (SELECT g.taggable_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE t.name = ? AND g.taggable_type = 'document') OR n.folder_id IN (SELECT g.taggable_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE t.name = ? AND g.taggable_type = 'account') OR EXISTS (SELECT 1 FROM links l JOIN resolved_tags t ON t.id=l.to_id WHERE l.from_type = 'account' AND l.from_id = n.folder_id AND l.kind = ${linkKind("labelled")} AND l.to_type = 'tag' AND t.name = ? AND substr(n.path, 1, length(l.anchor) + 1) = l.anchor || '/'))`, tag2, tag2, tag2), "tagged")
30855
+ inAccounts: /* @__PURE__ */ __name((ids) => bound4("n.folder_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))", ids), "inAccounts"),
30856
+ tagged: /* @__PURE__ */ __name((tag2) => bound4(`(n.id IN (SELECT g.taggable_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE t.name = ? AND g.taggable_type = 'document') OR n.folder_id IN (SELECT g.taggable_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE t.name = ? AND g.taggable_type = 'account') OR EXISTS (SELECT 1 FROM links l JOIN resolved_tags t ON t.id=l.to_id WHERE l.from_type = 'account' AND l.from_id = n.folder_id AND l.kind = ${linkKind("labelled")} AND l.to_type = 'tag' AND t.name = ? AND substr(n.path, 1, length(l.anchor) + 1) = l.anchor || '/'))`, tag2, tag2, tag2), "tagged")
30450
30857
  },
30451
30858
  {
30452
30859
  type: "note",
@@ -30455,7 +30862,7 @@ var CORPORA2 = [
30455
30862
  view: "(SELECT id, NULL AS folder_id, NULL AS path, title, body AS text, NULL AS metadata, updated_at AS at, deleted_at FROM notes)",
30456
30863
  words: "note_words",
30457
30864
  stems: "note_stems",
30458
- tagged: /* @__PURE__ */ __name((tag2) => bound3("n.id IN (SELECT g.taggable_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE t.name = ? AND g.taggable_type = 'note')", tag2), "tagged")
30865
+ tagged: /* @__PURE__ */ __name((tag2) => bound4("n.id IN (SELECT g.taggable_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id WHERE t.name = ? AND g.taggable_type = 'note')", tag2), "tagged")
30459
30866
  }
30460
30867
  ];
30461
30868
  var matchedRows = /* @__PURE__ */ __name((context, query) => {
@@ -30520,17 +30927,17 @@ var searchCorpus = /* @__PURE__ */ __name((context, query, corpus) => {
30520
30927
  let titles;
30521
30928
  const foldedTitles = /* @__PURE__ */ __name(() => titles ??= database.prepare(`SELECT id, title FROM ${corpus.view} n WHERE n.title IS NOT NULL AND n.deleted_at IS NULL`).all().map((row2) => ({ id: Number(row2.id), title: normalize(String(row2.title)) })), "foldedTitles");
30522
30929
  const leaf2 = /* @__PURE__ */ __name((node) => {
30523
- const { field: field3, operator, value } = node;
30524
- if (!corpus.fields.includes(field3))
30525
- searchError("query.unsupported-field", node.span, `${field3}: is not ${corpus.noun === "event" ? "an" : "a"} ${corpus.noun} field \u2014 ${corpus.noun}s take ${corpus.fields.join(", ")}`);
30526
- if ((field3 === "text" || field3 === "exact") && value === "")
30527
- return bound3("0");
30930
+ const { field: field4, operator, value } = node;
30931
+ if (!corpus.fields.includes(field4))
30932
+ searchError("query.unsupported-field", node.span, `${field4}: is not ${corpus.noun === "event" ? "an" : "a"} ${corpus.noun} field \u2014 ${corpus.noun}s take ${corpus.fields.join(", ")}`);
30933
+ if ((field4 === "text" || field4 === "exact") && value === "")
30934
+ return bound4("0");
30528
30935
  if (isStemmed(node)) {
30529
30936
  if (!query.stemmer)
30530
30937
  throw new Error("a stemmed leaf reached the notes search without the store's stemmer");
30531
30938
  const text5 = normalize(value);
30532
30939
  if (!/[\p{L}\p{N}]/u.test(text5))
30533
- return bound3("0");
30940
+ return bound4("0");
30534
30941
  const stems = query.stemmer.phrases(value);
30535
30942
  return {
30536
30943
  sql: `n.id IN (SELECT rowid FROM ${corpus.words} WHERE ${corpus.words} MATCH ?)${stems ? ` OR n.id IN (SELECT rowid FROM ${corpus.stems} WHERE ${corpus.stems} MATCH ?)` : ""}`,
@@ -30540,11 +30947,11 @@ var searchCorpus = /* @__PURE__ */ __name((context, query, corpus) => {
30540
30947
  ...stems ? { stems } : {}
30541
30948
  };
30542
30949
  }
30543
- if (field3 === "text" || field3 === "exact") {
30950
+ if (field4 === "text" || field4 === "exact") {
30544
30951
  if (operator === "term" || operator === "phrase") {
30545
30952
  const text5 = normalize(value);
30546
30953
  const stems = query.stemmer?.phrases(value);
30547
- return /[\p{L}\p{N}]/u.test(text5) ? { ...wordMatch2(quoted2(text5)), ...stems ? { stems } : {} } : bound3("0");
30954
+ return /[\p{L}\p{N}]/u.test(text5) ? { ...wordMatch2(quoted2(text5)), ...stems ? { stems } : {} } : bound4("0");
30548
30955
  }
30549
30956
  const pattern = operator === "wildcard" ? wildcardPattern(normalize(value)) : foldRegex(value, node.span);
30550
30957
  const matcher = automaton(pattern, node);
@@ -30557,54 +30964,54 @@ var searchCorpus = /* @__PURE__ */ __name((context, query, corpus) => {
30557
30964
  check3();
30558
30965
  return matcher.test(String(term), budget) ? [quoted2(String(term))] : [];
30559
30966
  });
30560
- return matches2.length ? wordMatch2(matches2.join(" OR ")) : bound3("0");
30967
+ return matches2.length ? wordMatch2(matches2.join(" OR ")) : bound4("0");
30561
30968
  }
30562
- if (field3 === "body") {
30969
+ if (field4 === "body") {
30563
30970
  if (operator === "term" || operator === "phrase")
30564
- return bound3("n.text = ?", value);
30971
+ return bound4("n.text = ?", value);
30565
30972
  const matcher = automaton(operator === "wildcard" ? wildcardPattern(value) : value, node);
30566
30973
  tests.set(node, (text5) => matcher.test(text5, budget));
30567
30974
  return { sql: "1", params: [], exact: false };
30568
30975
  }
30569
- if (field3 === "tag") {
30976
+ if (field4 === "tag") {
30570
30977
  const tag2 = tagOf(value);
30571
30978
  if (tag2 === void 0)
30572
30979
  searchError("query.invalid-tag", node.span);
30573
- return corpus.tagged?.(canonicalTagNamed(database, tag2)?.name ?? tag2) ?? bound3("0");
30980
+ return corpus.tagged?.(canonicalTagNamed(database, tag2)?.name ?? tag2) ?? bound4("0");
30574
30981
  }
30575
- if (field3 === "source")
30576
- return bound3(value.toLowerCase() === (corpus.type === "note" ? "internal" : "file") ? "1" : "0");
30577
- if (field3 === "has") {
30982
+ if (field4 === "source")
30983
+ return bound4(value.toLowerCase() === (corpus.type === "note" ? "internal" : "file") ? "1" : "0");
30984
+ if (field4 === "has") {
30578
30985
  if (value.toLowerCase() !== "text")
30579
30986
  searchError("query.unknown-value", node.span, `has:${value} is a message field \u2014 notes take has:text`);
30580
- return bound3("length(trim(coalesce(n.text,''))) > 0");
30987
+ return bound4("length(trim(coalesce(n.text,''))) > 0");
30581
30988
  }
30582
- if (field3 === "title" || field3 === "site" || field3 === "lang" || field3 === "author" || field3 === "keyword") {
30989
+ if (field4 === "title" || field4 === "site" || field4 === "lang" || field4 === "author" || field4 === "keyword") {
30583
30990
  const wanted = normalize(value);
30584
30991
  if (wanted === "")
30585
- return bound3("0");
30992
+ return bound4("0");
30586
30993
  const folded5 = /* @__PURE__ */ __name((key2) => `coalesce(json_extract(n.metadata, '$.folded.${key2}'), '')`, "folded");
30587
- if (field3 === "keyword")
30588
- return bound3("EXISTS (SELECT 1 FROM json_each(n.metadata, '$.folded.keywords') WHERE value = ?)", wanted);
30589
- if (field3 === "lang")
30590
- return bound3(`(${folded5("language")} = ? OR ${folded5("language")} LIKE ? || '-%')`, wanted, wanted);
30591
- if (field3 === "title") {
30994
+ if (field4 === "keyword")
30995
+ return bound4("EXISTS (SELECT 1 FROM json_each(n.metadata, '$.folded.keywords') WHERE value = ?)", wanted);
30996
+ if (field4 === "lang")
30997
+ return bound4(`(${folded5("language")} = ? OR ${folded5("language")} LIKE ? || '-%')`, wanted, wanted);
30998
+ if (field4 === "title") {
30592
30999
  check3();
30593
31000
  const ids = foldedTitles().flatMap(({ id: id2, title }) => title.includes(wanted) ? [id2] : []);
30594
- return bound3(`(instr(${folded5("title")}, ?) > 0 OR n.id IN (SELECT value FROM json_each(?)))`, wanted, JSON.stringify(ids));
31001
+ return bound4(`(instr(${folded5("title")}, ?) > 0 OR n.id IN (SELECT value FROM json_each(?)))`, wanted, JSON.stringify(ids));
30595
31002
  }
30596
- return bound3(`instr(${folded5(field3)}, ?) > 0`, wanted);
31003
+ return bound4(`instr(${folded5(field4)}, ?) > 0`, wanted);
30597
31004
  }
30598
- if (field3 === "date") {
31005
+ if (field4 === "date") {
30599
31006
  const range = node.resolution?.date;
30600
31007
  if (!range)
30601
31008
  searchError("query.invalid-ast", node.span);
30602
31009
  return combine2([
30603
- ...range.lower === void 0 ? [] : [bound3(`n.at ${range.lower_inclusive ? ">=" : ">"} ?`, range.lower)],
30604
- ...range.upper === void 0 ? [] : [bound3(`n.at ${range.upper_inclusive ? "<=" : "<"} ?`, range.upper)]
31010
+ ...range.lower === void 0 ? [] : [bound4(`n.at ${range.lower_inclusive ? ">=" : ">"} ?`, range.lower)],
31011
+ ...range.upper === void 0 ? [] : [bound4(`n.at ${range.upper_inclusive ? "<=" : "<"} ?`, range.upper)]
30605
31012
  ], "AND");
30606
31013
  }
30607
- return bound3([corpus.noun, `${corpus.noun}s`].includes(value.toLowerCase()) ? "1" : "0");
31014
+ return bound4([corpus.noun, `${corpus.noun}s`].includes(value.toLowerCase()) ? "1" : "0");
30608
31015
  }, "leaf");
30609
31016
  const compile2 = /* @__PURE__ */ __name((node) => {
30610
31017
  if (node.kind === "predicate") {
@@ -30635,10 +31042,10 @@ var searchCorpus = /* @__PURE__ */ __name((context, query, corpus) => {
30635
31042
  const expression = compile2(query.root);
30636
31043
  const stemmed = [...fragments.keys()].some(isStemmed);
30637
31044
  const scope3 = combine2([
30638
- bound3("n.deleted_at IS NULL"),
30639
- ...corpus.live ? [bound3(corpus.live)] : [],
31045
+ bound4("n.deleted_at IS NULL"),
31046
+ ...corpus.live ? [bound4(corpus.live)] : [],
30640
31047
  ...query.accountIds?.length && corpus.inAccounts ? [corpus.inAccounts(JSON.stringify(query.accountIds))] : [],
30641
- ...query.ids ? [bound3("n.id IN (SELECT value FROM json_each(?))", JSON.stringify(query.ids))] : []
31048
+ ...query.ids ? [bound4("n.id IN (SELECT value FROM json_each(?))", JSON.stringify(query.ids))] : []
30642
31049
  ], "AND");
30643
31050
  const where = combine2([scope3, expression], "AND");
30644
31051
  const ranking = query.newest ? void 0 : required3(query.root, stemmed ? "stems" : "fts");
@@ -30843,7 +31250,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
30843
31250
  };
30844
31251
  }, "noteSearchOver");
30845
31252
 
30846
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
31253
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
30847
31254
  var EVENT_FIELDS = ["text", "exact", "body", "title", "date", "in"];
30848
31255
  var inEventAccounts = /* @__PURE__ */ __name((event) => searchableCopy(event, "c.account_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))"), "inEventAccounts");
30849
31256
  var EVENT_CORPUS = {
@@ -30975,7 +31382,7 @@ var eventSearchOver = /* @__PURE__ */ __name((context) => {
30975
31382
  };
30976
31383
  }, "eventSearchOver");
30977
31384
 
30978
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
31385
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
30979
31386
  var EVIDENCE_FINDINGS_KIND = "evidence_findings";
30980
31387
  var reference = /* @__PURE__ */ __name((raw) => {
30981
31388
  if (/^document:[1-9]\d*$/.test(raw))
@@ -30988,7 +31395,7 @@ var reference = /* @__PURE__ */ __name((raw) => {
30988
31395
  }, "reference");
30989
31396
  var validateEvidenceFindings = /* @__PURE__ */ __name((input) => validateFindings(input, { plural: "evidence findings", singular: "evidence finding", cited: "reference", reference }), "validateEvidenceFindings");
30990
31397
 
30991
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/domain/moment.js
31398
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/domain/moment.js
30992
31399
  var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false } = {}) => {
30993
31400
  try {
30994
31401
  return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
@@ -31000,7 +31407,7 @@ var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false
31000
31407
  }
31001
31408
  }, "calendarMoment");
31002
31409
 
31003
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
31410
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
31004
31411
  var NAMED3 = "SELECT f.*, b.name AS author_name FROM facts f LEFT JOIN bots b ON f.author_type = 'bot' AND b.id = f.author_id";
31005
31412
  var iso8 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
31006
31413
  var oneOf4 = /* @__PURE__ */ __name((value, allowed, what) => {
@@ -31038,12 +31445,12 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
31038
31445
  const accept = /* @__PURE__ */ __name((id2) => {
31039
31446
  const row2 = database.prepare("SELECT * FROM facts WHERE id = ?").get(id2);
31040
31447
  if (row2.status !== "proposed" && row2.status !== "accepted")
31041
- throw new CliError("validation_error", `a ${String(row2.status)} decision cannot be accepted`);
31448
+ throw new CliError("validation_error", `a ${String(row2.status)} fact cannot be accepted`);
31042
31449
  const { actor } = authorActor(context, "owner");
31043
31450
  const at = now2();
31044
31451
  database.prepare("UPDATE facts SET status = 'accepted', confirmed_by_type = ?, confirmed_by_id = ?, updated_at = ? WHERE id = ?").run(actor.type, actor.id, at, id2);
31045
31452
  if (row2.supersedes_id != null)
31046
- database.prepare("UPDATE facts SET status = 'superseded', updated_at = ? WHERE id = ? AND status = 'accepted'").run(at, Number(row2.supersedes_id));
31453
+ database.prepare("UPDATE facts SET status = 'superseded', updated_at = ? WHERE id = ? AND status IN ('proposed', 'accepted')").run(at, Number(row2.supersedes_id));
31047
31454
  }, "accept");
31048
31455
  return {
31049
31456
  add: /* @__PURE__ */ __name((input) => {
@@ -31055,20 +31462,18 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
31055
31462
  const occurredAt = input.occurredAt === void 0 ? null : calendarMoment(input.occurredAt, "occurredAt");
31056
31463
  if (occurredAt !== null && !Number.isFinite(occurredAt))
31057
31464
  throw new CliError("validation_error", "occurredAt takes an ISO timestamp");
31058
- if (input.supersedes !== void 0 && type !== "decision")
31059
- throw new CliError("validation_error", "only a decision supersedes another");
31060
31465
  const id2 = write(database, () => {
31061
31466
  const project = input.project === void 0 ? void 0 : requiredThing(database, input.project, "the project");
31062
31467
  if (project && project.type !== "project")
31063
31468
  throw new CliError("validation_error", `${input.project} is not a project`);
31064
31469
  const subject2 = input.subject === void 0 ? void 0 : requiredThing(database, input.subject, "the subject");
31065
31470
  const replaced = input.supersedes === void 0 ? void 0 : rowOf(input.supersedes);
31066
- if (replaced && replaced.type !== "decision")
31067
- throw new CliError("validation_error", `${input.supersedes} is not a decision`);
31471
+ if (replaced && replaced.status !== "proposed" && replaced.status !== "accepted")
31472
+ throw new CliError("validation_error", `${input.supersedes} is ${String(replaced.status)}; only a proposed or accepted fact can be corrected`);
31068
31473
  const owner = input.by === "owner";
31069
31474
  const { actor, model } = authorActor(context, input.by);
31070
31475
  const at = now2();
31071
- const made = Number(database.prepare("INSERT INTO facts (type, statement, status, project_id, subject_type, subject_id, occurred_at, supersedes_id, author_type, author_id, model, scope, source, created_at, updated_at) VALUES (?, ?, 'proposed', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(type, statement, project?.id ?? null, subject2?.type ?? null, subject2?.id ?? null, occurredAt, replaced === void 0 ? null : Number(replaced.id), actor.type, actor.id, model, scope3, owner ? "owner" : "agent", at, at)?.id);
31476
+ const made = Number(database.prepare("INSERT INTO facts (id, type, statement, status, project_id, subject_type, subject_id, occurred_at, supersedes_id, author_type, author_id, model, scope, source, created_at, updated_at) VALUES (?, ?, ?, 'proposed', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(nextId(database, "facts"), type, statement, project?.id ?? null, subject2?.type ?? null, subject2?.id ?? null, occurredAt, replaced === void 0 ? null : Number(replaced.id), actor.type, actor.id, model, scope3, owner ? "owner" : "agent", at, at)?.id);
31072
31477
  linkEvidence(context, { type: "fact", id: made }, input.evidence ?? [], owner ? "owner" : "agent");
31073
31478
  if (input.createdFrom !== void 0) {
31074
31479
  const from2 = requiredThing(database, input.createdFrom, "the source");
@@ -31112,6 +31517,9 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
31112
31517
  const id2 = Number(row2.id);
31113
31518
  const twin = row2.source === "memory" && row2.metadata != null ? migratedFrom(String(row2.metadata)) : void 0;
31114
31519
  const links2 = erase(database, () => {
31520
+ keepHighestId(database, "facts", now2());
31521
+ if (twin !== void 0)
31522
+ keepHighestId(database, "memories", now2());
31115
31523
  database.prepare("UPDATE facts SET supersedes_id = NULL WHERE supersedes_id = ?").run(id2);
31116
31524
  const count = dropLinksOf(database, { type: "fact", id: id2 });
31117
31525
  database.prepare("DELETE FROM links WHERE from_type = 'fact' AND from_id = ?").run(id2);
@@ -31148,7 +31556,7 @@ var factsStoreOver = /* @__PURE__ */ __name((context) => {
31148
31556
  };
31149
31557
  }, "factsStoreOver");
31150
31558
 
31151
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
31559
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
31152
31560
  var invalid4 = /* @__PURE__ */ __name((message2) => {
31153
31561
  throw new CliError("validation_error", message2);
31154
31562
  }, "invalid");
@@ -31238,7 +31646,7 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind3) => {
31238
31646
  return { snapshot: snapshot2, snapshotParts, previous, outcomes };
31239
31647
  }, "findingsCoreOver");
31240
31648
 
31241
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
31649
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
31242
31650
  var PROPOSAL_STATUSES = ["proposed", "approved", "rejected", "executed", "failed"];
31243
31651
  var PROPOSAL_VERDICTS = ["useful", "not_useful"];
31244
31652
  var iso9 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
@@ -31384,7 +31792,7 @@ var proposedActionsStoreOver = /* @__PURE__ */ __name((context) => {
31384
31792
  };
31385
31793
  }, "proposedActionsStoreOver");
31386
31794
 
31387
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
31795
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
31388
31796
  var stale = /* @__PURE__ */ __name(() => {
31389
31797
  throw new CliError("validation_error", "evidence findings changed since they were read; stage a new batch", {
31390
31798
  reason: "evidence-findings.stale"
@@ -31550,7 +31958,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31550
31958
  };
31551
31959
  }, "evidenceFindingsStoreOver");
31552
31960
 
31553
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
31961
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
31554
31962
  var pendingInvolvements = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM involvement_pending").get()?.n ?? 0), "pendingInvolvements");
31555
31963
  var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => ({
31556
31964
  rebuild: /* @__PURE__ */ __name((personId) => write(database, () => {
@@ -31575,7 +31983,7 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
31575
31983
  ...since === void 0 ? [] : [["AND i.occurred_at>=?", since]],
31576
31984
  ...until === void 0 ? [] : [["AND i.occurred_at<=?", until]]
31577
31985
  ];
31578
- const bound4 = before2 === void 0 ? [] : [before2.at, before2.at, before2.id];
31986
+ const bound5 = before2 === void 0 ? [] : [before2.at, before2.at, before2.id];
31579
31987
  const account = only === void 0 ? [] : [only.provider, only.account];
31580
31988
  return database.prepare(`SELECT i.*, a.provider, a.external_id AS account, c.external_id AS chat, m.external_id AS message
31581
31989
  FROM involvements i LEFT JOIN projects pr ON pr.id=i.project_id
@@ -31584,7 +31992,7 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
31584
31992
  LEFT JOIN chats c ON c.id=CASE WHEN i.subject_type='chat' THEN i.subject_id ELSE m.chat_id END
31585
31993
  WHERE i.person_id=? ${filters.map(([sql2]) => sql2).join(" ")}
31586
31994
  ${before2 === void 0 ? "" : "AND (i.occurred_at<? OR (i.occurred_at=? AND i.id<?))"}
31587
- ${only === void 0 ? "" : "AND (a.provider IS NULL OR a.provider<>? OR a.external_id=?)"} ORDER BY i.occurred_at DESC, i.id DESC LIMIT ?`).all(personId, ...filters.map(([, value]) => value), ...bound4, ...account, limit).map((row2) => ({
31995
+ ${only === void 0 ? "" : "AND (a.provider IS NULL OR a.provider<>? OR a.external_id=?)"} ORDER BY i.occurred_at DESC, i.id DESC LIMIT ?`).all(personId, ...filters.map(([, value]) => value), ...bound5, ...account, limit).map((row2) => ({
31588
31996
  id: Number(row2.id),
31589
31997
  personId: Number(row2.person_id),
31590
31998
  identityId: row2.identity_id == null ? null : Number(row2.identity_id),
@@ -31603,7 +32011,7 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
31603
32011
  }, "forPerson")
31604
32012
  }), "involvementStoreOver");
31605
32013
 
31606
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
32014
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
31607
32015
  import { createHash as createHash12 } from "node:crypto";
31608
32016
  var fields3 = "id,from_id,to_id,source,confirmed,updated_at,length(evidence) AS evidenceLength,substr(evidence,1,2000) AS evidence";
31609
32017
  var id = /* @__PURE__ */ __name((value) => {
@@ -31689,24 +32097,24 @@ var meetingProjectsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 })
31689
32097
  };
31690
32098
  }, "meetingProjectsStoreOver");
31691
32099
 
31692
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
32100
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
31693
32101
  import { createHash as createHash15 } from "node:crypto";
31694
32102
 
31695
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
32103
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
31696
32104
  import { createHash as createHash14 } from "node:crypto";
31697
32105
 
31698
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
32106
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
31699
32107
  import { createHash as createHash13 } from "node:crypto";
31700
32108
 
31701
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
31702
- var consolidationId = /* @__PURE__ */ __name((value, field3) => {
32109
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
32110
+ var consolidationId = /* @__PURE__ */ __name((value, field4) => {
31703
32111
  if (typeof value !== "string" || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
31704
- throw new CliError("validation_error", `${field3} must be a positive canonical tag id`);
32112
+ throw new CliError("validation_error", `${field4} must be a positive canonical tag id`);
31705
32113
  return Number(value);
31706
32114
  }, "consolidationId");
31707
- var bounded = /* @__PURE__ */ __name((value, max, field3) => {
32115
+ var bounded = /* @__PURE__ */ __name((value, max, field4) => {
31708
32116
  if (!Number.isSafeInteger(value) || value < 1 || value > max)
31709
- throw new CliError("validation_error", `${field3} must be an integer from 1 to ${max}`);
32117
+ throw new CliError("validation_error", `${field4} must be an integer from 1 to ${max}`);
31710
32118
  return value;
31711
32119
  }, "bounded");
31712
32120
  var consolidationInput = /* @__PURE__ */ __name((options, apply = false) => {
@@ -31721,9 +32129,9 @@ var consolidationInput = /* @__PURE__ */ __name((options, apply = false) => {
31721
32129
  "signal",
31722
32130
  ...apply ? ["by", "expectedPreviewFingerprint", "idempotencyKey"] : ["sampleLimit"]
31723
32131
  ]);
31724
- for (const field3 of Object.keys(options))
31725
- if (!allowed.has(field3))
31726
- throw new CliError("validation_error", `unknown consolidation field: ${field3}`);
32132
+ for (const field4 of Object.keys(options))
32133
+ if (!allowed.has(field4))
32134
+ throw new CliError("validation_error", `unknown consolidation field: ${field4}`);
31727
32135
  const source2 = consolidationId(options.sourceId, "sourceId");
31728
32136
  const survivor = consolidationId(options.survivorId, "survivorId");
31729
32137
  if (source2 === survivor)
@@ -31749,7 +32157,7 @@ var consolidationApplyInput = /* @__PURE__ */ __name((options) => {
31749
32157
  return input;
31750
32158
  }, "consolidationApplyInput");
31751
32159
 
31752
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
32160
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
31753
32161
  var receiptOf = /* @__PURE__ */ __name((row2) => ({
31754
32162
  id: String(row2.id),
31755
32163
  sourceId: String(row2.source_id),
@@ -31824,7 +32232,7 @@ var applyTagConsolidation = /* @__PURE__ */ __name((context, preview, options) =
31824
32232
  }, { beforeCommit: check3 });
31825
32233
  }, "applyTagConsolidation");
31826
32234
 
31827
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
32235
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
31828
32236
  var selections = [
31829
32237
  ["taggings", "tag_id IN (SELECT value FROM json_each(?))"],
31830
32238
  ["aliases", "aliasable_type='tag' AND aliasable_id IN (SELECT value FROM json_each(?))"],
@@ -31907,9 +32315,9 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
31907
32315
  totals.survivor++;
31908
32316
  byTargetType.set(type, totals);
31909
32317
  }
31910
- const counts = /* @__PURE__ */ __name((values, field3) => ({
31911
- source: values.filter((row2) => sourceMembers.has(Number(row2[field3]))).length,
31912
- survivor: values.filter((row2) => !sourceMembers.has(Number(row2[field3]))).length
32318
+ const counts = /* @__PURE__ */ __name((values, field4) => ({
32319
+ source: values.filter((row2) => sourceMembers.has(Number(row2[field4]))).length,
32320
+ survivor: values.filter((row2) => !sourceMembers.has(Number(row2[field4]))).length
31913
32321
  }), "counts");
31914
32322
  const overlaps = /* @__PURE__ */ __name((values, key2) => {
31915
32323
  const targets = new Set(values.filter((row2) => sourceMembers.has(Number(row2.tag_id))).map(key2));
@@ -31968,7 +32376,7 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
31968
32376
  };
31969
32377
  }, "previewRows");
31970
32378
 
31971
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
32379
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
31972
32380
  var kinds = ["project", "tag", "topic"];
31973
32381
  var cancelled2 = /* @__PURE__ */ __name((signal) => {
31974
32382
  if (signal?.aborted)
@@ -32232,7 +32640,7 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
32232
32640
  };
32233
32641
  }, "vocabularyStoreOver");
32234
32642
 
32235
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
32643
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
32236
32644
  var TYPED_KEY_PREFIXES = new Set(Object.values(TASK_KEY_PREFIXES));
32237
32645
  var ORGANIZATION_KINDS = ["company", "team", "family", "community"];
32238
32646
  var PROJECT_TYPES = ["work", "client", "personal", "oss", "other"];
@@ -32456,7 +32864,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
32456
32864
  }, "due");
32457
32865
  const openTask = /* @__PURE__ */ __name((key2, id2) => {
32458
32866
  const row2 = taskRowOf(database, id2);
32459
- const open = row2 !== void 0 && taskAccountOf(database, row2) === taskAccount(key2) && database.prepare("SELECT status FROM tasks WHERE id = ?").get(row2)?.status === "open";
32867
+ const open = row2 !== void 0 && taskAccountOf(database, row2) === taskAccount(key2) && !isClosedState(String(database.prepare("SELECT status FROM tasks WHERE id = ?").get(row2)?.status ?? "done"));
32460
32868
  if (!open)
32461
32869
  throw new CliError("validation_error", "a reminder requires an open task in this account");
32462
32870
  return row2;
@@ -32728,7 +33136,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
32728
33136
  if (!Number.isInteger(lease) || lease < 1e3 || lease > 36e5)
32729
33137
  throw new CliError("validation_error", "lease takes 1000\u20133600000 milliseconds");
32730
33138
  const accountId = account(key2), at = now2();
32731
- const rows = database.prepare("SELECT r.id FROM reminders r JOIN tasks t ON t.id = r.task_id WHERE r.account_id=? AND r.due_at<=? AND t.status = 'open' AND (r.state='pending' OR (r.state='leased' AND r.lease_until<=?)) ORDER BY r.due_at, r.id LIMIT ?").all(accountId, at, at, limit);
33139
+ const rows = database.prepare("SELECT r.id FROM reminders r JOIN tasks t ON t.id = r.task_id WHERE r.account_id=? AND r.due_at<=? AND t.status NOT IN ('done','dismissed') AND (r.state='pending' OR (r.state='leased' AND r.lease_until<=?)) ORDER BY r.due_at, r.id LIMIT ?").all(accountId, at, at, limit);
32732
33140
  const claimed = [];
32733
33141
  for (const row2 of rows) {
32734
33142
  const receipt = ulid(at);
@@ -32754,7 +33162,7 @@ var projectKey = /* @__PURE__ */ __name((name) => {
32754
33162
  return key2.padEnd(3, "X");
32755
33163
  }, "projectKey");
32756
33164
 
32757
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
33165
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
32758
33166
  var DAY5 = 864e5;
32759
33167
  var SETTING4 = "logs_pruned_at";
32760
33168
  var LOG_RETENTION = { agentActionsMs: 90 * DAY5, botUpdatePayloadsMs: 30 * DAY5 };
@@ -32781,7 +33189,7 @@ var logPruner = /* @__PURE__ */ __name((database, now2) => {
32781
33189
  };
32782
33190
  }, "logPruner");
32783
33191
 
32784
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
33192
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
32785
33193
  var stale2 = /* @__PURE__ */ __name(() => {
32786
33194
  throw new CliError("validation_error", "meeting findings changed since they were read; stage a new batch", {
32787
33195
  reason: "meeting-findings.stale"
@@ -32950,7 +33358,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32950
33358
  };
32951
33359
  }, "meetingFindingsStoreOver");
32952
33360
 
32953
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
33361
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
32954
33362
  var RANK_BATCH = 512;
32955
33363
  var LIVE3 = "FROM chunks k JOIN meeting_transcripts t ON k.chunkable_type = 'meeting_transcript' AND t.id = k.chunkable_id JOIN meetings m ON m.id = t.meeting_id WHERE m.account_id = ? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL";
32956
33364
  var limitOf = /* @__PURE__ */ __name((value, name, max = 1e3) => {
@@ -33221,7 +33629,7 @@ var meetingVectorsOver = /* @__PURE__ */ __name((context) => ({
33221
33629
  }
33222
33630
  }), "meetingVectorsOver");
33223
33631
 
33224
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
33632
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
33225
33633
  var OTHER_SOURCES = ["document", "note", "email"];
33226
33634
  var TEXTS = {
33227
33635
  document: "JOIN documents s ON mn.source_type = 'document' AND s.id = mn.source_id AND s.deleted_at IS NULL WHERE 1 ",
@@ -33322,11 +33730,11 @@ var sourceMentionStoreOver = /* @__PURE__ */ __name((context) => {
33322
33730
  };
33323
33731
  }, "sourceMentionStoreOver");
33324
33732
 
33325
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
33733
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
33326
33734
  import { mkdirSync, statSync, writeFileSync } from "node:fs";
33327
33735
  import { dirname } from "node:path";
33328
33736
 
33329
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
33737
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
33330
33738
  import { readFileSync as readFileSync3 } from "node:fs";
33331
33739
  var CLIENTS_SETTING = "clients";
33332
33740
  var coreVersion = (() => {
@@ -33384,7 +33792,7 @@ var refusalAdvice = /* @__PURE__ */ __name((clients, command, schema) => {
33384
33792
  return mover ? `${own} (${mover.command} ${mover.version} moved the store to schema ${schema})` : own;
33385
33793
  }, "refusalAdvice");
33386
33794
 
33387
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
33795
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
33388
33796
  var GENERATED = [
33389
33797
  {
33390
33798
  "name": "20261010184427_initial",
@@ -34247,10 +34655,33 @@ WHERE json_type(params, '$.selection') = 'object';`
34247
34655
  "CREATE TRIGGER document_trigrams_bd BEFORE DELETE ON documents BEGIN\n DELETE FROM document_trigrams WHERE rowid = old.id;\nEND;",
34248
34656
  "-- The trigrams hold JS-normalized text, which SQL cannot produce: fillTrigrams fills the rows stored before this\n-- version, up to `watermark`, and a search reads the rest of them by their text meanwhile.\nINSERT INTO search_index_state (name, watermark, filled_through, terms_through, normalizer_version)\n SELECT 'note_trigrams', coalesce(max(id), 0), 0, 0, 1 FROM notes\n UNION ALL SELECT 'document_trigrams', coalesce(max(id), 0), 0, 0, 1 FROM documents;"
34249
34657
  ]
34658
+ },
34659
+ {
34660
+ "name": "20261031230945_version-41-task-fields",
34661
+ "statements": [
34662
+ "ALTER TABLE `tasks` ADD `priority_score` real;",
34663
+ "ALTER TABLE `tasks` ADD `agent` text;",
34664
+ "ALTER TABLE `tasks` ADD `revision` integer DEFAULT 1 NOT NULL;",
34665
+ "-- 0 urgent \u2026 4 low land inside the critical, high, medium and low quarters, with room on either side for moves.\nUPDATE tasks SET priority_score = CASE priority WHEN 0 THEN 0.875 WHEN 1 THEN 0.625 WHEN 2 THEN 0.375 WHEN 3 THEN 0.1875 WHEN 4 THEN 0.0625 END WHERE priority IS NOT NULL;",
34666
+ "-- A build before version 41 writes only `priority`; these keep the score in step with what it wrote.\nCREATE TRIGGER tasks_priority_score_ai AFTER INSERT ON tasks WHEN new.priority IS NOT NULL AND new.priority_score IS NULL BEGIN\n UPDATE tasks SET priority_score = CASE new.priority WHEN 0 THEN 0.875 WHEN 1 THEN 0.625 WHEN 2 THEN 0.375 WHEN 3 THEN 0.1875 WHEN 4 THEN 0.0625 END WHERE id = new.id;\nEND;",
34667
+ "CREATE TRIGGER tasks_priority_score_au AFTER UPDATE OF priority ON tasks WHEN new.priority IS NOT old.priority AND new.priority_score IS old.priority_score BEGIN\n UPDATE tasks SET priority_score = CASE new.priority WHEN 0 THEN 0.875 WHEN 1 THEN 0.625 WHEN 2 THEN 0.375 WHEN 3 THEN 0.1875 WHEN 4 THEN 0.0625 END WHERE id = new.id;\nEND;",
34668
+ "-- Every build's write bumps it, older ones too, so a stale copy is caught whoever wrote last.\nCREATE TRIGGER tasks_revision_au AFTER UPDATE ON tasks WHEN new.revision IS old.revision BEGIN\n UPDATE tasks SET revision = old.revision + 1 WHERE id = new.id;\nEND;"
34669
+ ]
34670
+ },
34671
+ {
34672
+ "name": "20261101002523_version-42-task-revision",
34673
+ "statements": [
34674
+ "-- A claim renewed, a follow-up time or a close suggestion is an agent at work, not a change a person could overwrite;\n-- bumping on those made the board report a conflict while an agent simply worked.\nDROP TRIGGER tasks_revision_au;",
34675
+ "CREATE TRIGGER tasks_revision_au AFTER UPDATE OF title, description, status, priority, priority_score, agent, due_at, project_id, parent_id ON tasks\n WHEN new.revision IS old.revision AND (new.title IS NOT old.title OR new.description IS NOT old.description\n OR new.status IS NOT old.status OR new.priority IS NOT old.priority OR new.priority_score IS NOT old.priority_score\n OR new.agent IS NOT old.agent OR new.due_at IS NOT old.due_at OR new.project_id IS NOT old.project_id\n OR new.parent_id IS NOT old.parent_id) BEGIN\n UPDATE tasks SET revision = old.revision + 1 WHERE id = new.id;\nEND;",
34676
+ "CREATE TRIGGER tasks_revision_assignment_ai AFTER INSERT ON task_assignments BEGIN\n UPDATE tasks SET revision = revision + 1 WHERE id = new.task_id;\nEND;",
34677
+ "CREATE TRIGGER tasks_revision_assignment_ad AFTER DELETE ON task_assignments BEGIN\n UPDATE tasks SET revision = revision + 1 WHERE id = old.task_id;\nEND;",
34678
+ "CREATE TRIGGER tasks_revision_tagging_ai AFTER INSERT ON taggings WHEN new.taggable_type = 'task' BEGIN\n UPDATE tasks SET revision = revision + 1 WHERE id = new.taggable_id;\nEND;",
34679
+ "CREATE TRIGGER tasks_revision_tagging_ad AFTER DELETE ON taggings WHEN old.taggable_type = 'task' BEGIN\n UPDATE tasks SET revision = revision + 1 WHERE id = old.taggable_id;\nEND;"
34680
+ ]
34250
34681
  }
34251
34682
  ];
34252
34683
 
34253
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
34684
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
34254
34685
  var MANIFEST = [
34255
34686
  { name: "20261010184427_initial", version: 1, minCompatible: 1 },
34256
34687
  { name: "20261011035353_version-2-facts", version: 2, minCompatible: 1 },
@@ -34304,7 +34735,9 @@ var MANIFEST = [
34304
34735
  { name: "20261029224106_version-38-folded-names", version: 38, minCompatible: 34 },
34305
34736
  { name: "20261029224107_version-38-folded-triggers", version: 38, minCompatible: 34 },
34306
34737
  { name: "20261030114008_version-39-email-locations", version: 39, minCompatible: 34 },
34307
- { name: "20261030225520_version-40-note-trigrams", version: 40, minCompatible: 34 }
34738
+ { name: "20261030225520_version-40-note-trigrams", version: 40, minCompatible: 34 },
34739
+ { name: "20261031230945_version-41-task-fields", version: 41, minCompatible: 34 },
34740
+ { name: "20261101002523_version-42-task-revision", version: 42, minCompatible: 34 }
34308
34741
  ];
34309
34742
  var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated = GENERATED) => {
34310
34743
  const migrations = [];
@@ -34328,7 +34761,7 @@ var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated
34328
34761
  return migrations;
34329
34762
  }, "generatedMigrations");
34330
34763
 
34331
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/migrations.js
34764
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/migrations.js
34332
34765
  var MIGRATIONS = generatedMigrations();
34333
34766
  var HISTORY = `CREATE TABLE IF NOT EXISTS schema_migrations (
34334
34767
  version INTEGER PRIMARY KEY,
@@ -34381,7 +34814,7 @@ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now:
34381
34814
  }
34382
34815
  }, "migrate");
34383
34816
 
34384
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
34817
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
34385
34818
  var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
34386
34819
  const pending = database.prepare("SELECT id, join_url FROM meetings WHERE join_url IS NOT NULL AND join_key IS NULL AND id > ? ORDER BY id LIMIT ?");
34387
34820
  if (pending.get(0, 1) === void 0)
@@ -34403,7 +34836,7 @@ var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
34403
34836
  }
34404
34837
  }, "fillJoinKeys");
34405
34838
 
34406
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
34839
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
34407
34840
  var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
34408
34841
  const opened = "Bun" in globalThis ? await openUnderBun(path, readOnly) : await openUnderNode(path, readOnly);
34409
34842
  try {
@@ -34416,8 +34849,8 @@ var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {})
34416
34849
  }, "openSqlite");
34417
34850
  var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
34418
34851
  quietSqliteWarning();
34419
- const { drizzle } = await import("./node-XN4PIVWW.js");
34420
- const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-PCBGROGQ.js");
34852
+ const { drizzle } = await import("./node-S3VEQNTE.js");
34853
+ const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-3DNWF2BW.js");
34421
34854
  const client = await nodeClient(path, { readOnly });
34422
34855
  try {
34423
34856
  return { database: cacheOverNodeSqlite(client), orm: drizzle({ client }) };
@@ -34427,8 +34860,8 @@ var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
34427
34860
  }
34428
34861
  }, "openUnderNode");
34429
34862
  var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
34430
- const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-M6JEXKRT.js");
34431
- const { drizzle } = await import("./bun-WXGS6HML.js");
34863
+ const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-2G5TXHYE.js");
34864
+ const { drizzle } = await import("./bun-KUKVEKDW.js");
34432
34865
  const client = await bunClient(path, readOnly ? { readonly: true, create: false } : void 0);
34433
34866
  try {
34434
34867
  return { database: cacheOverBunSqlite(client), orm: drizzle({ client }) };
@@ -34438,7 +34871,7 @@ var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
34438
34871
  }
34439
34872
  }, "openUnderBun");
34440
34873
 
34441
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
34874
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
34442
34875
  var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
34443
34876
  const ours = MIGRATIONS.at(-1)?.version ?? 0;
34444
34877
  if (!database.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='schema_migrations'").get())
@@ -34453,7 +34886,7 @@ var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
34453
34886
  throw new CliError("configuration_error", `The store requires schema ${minCompatible}, but this tool supports ${ours}; ${refusalAdvice(storeClients(database), command, version)}`);
34454
34887
  }, "assertReadCompatible");
34455
34888
 
34456
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
34889
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
34457
34890
  var BACKFILL_ON_OPEN = 5e3;
34458
34891
  var NOT_WRITABLE = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EROFS"]);
34459
34892
  var createWritable = /* @__PURE__ */ __name((file) => {
@@ -34509,10 +34942,10 @@ var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Da
34509
34942
  }
34510
34943
  }, "openStoreContext");
34511
34944
 
34512
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
34945
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
34513
34946
  import { createHash as createHash16 } from "node:crypto";
34514
34947
 
34515
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
34948
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
34516
34949
  var text3 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
34517
34950
  var ref = text3(2048);
34518
34951
  var timestamp2 = pipe(number(), safeInteger(), minValue(0));
@@ -34578,10 +35011,10 @@ var projectAnnotationsSchema = strictObject({
34578
35011
  }))
34579
35012
  });
34580
35013
 
34581
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
35014
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
34582
35015
  var PROJECT_ANNOTATIONS_MAX_BYTES = 4 * 1024 * 1024;
34583
- var invalid7 = /* @__PURE__ */ __name((field3) => {
34584
- throw new CliError("validation_error", `invalid project annotations.${field3}`);
35016
+ var invalid7 = /* @__PURE__ */ __name((field4) => {
35017
+ throw new CliError("validation_error", `invalid project annotations.${field4}`);
34585
35018
  }, "invalid");
34586
35019
  var canonical = /* @__PURE__ */ __name((ref3) => {
34587
35020
  try {
@@ -34682,7 +35115,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
34682
35115
  invalid7("external.unused");
34683
35116
  }, "validateProjectAnnotationsGraph");
34684
35117
 
34685
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
35118
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
34686
35119
  var hash = pipe(string(), regex(/^[a-f0-9]{64}$/));
34687
35120
  var ref2 = pipe(string(), minLength(1), maxLength(2048));
34688
35121
  var targetSchema = strictObject({
@@ -34702,8 +35135,8 @@ var kind2 = /* @__PURE__ */ __name((ref3) => {
34702
35135
  const parsed2 = parseReference(ref3);
34703
35136
  return "provider" in parsed2 ? `${parsed2.type}:${parsed2.provider}` : parsed2.type;
34704
35137
  }, "kind");
34705
- var invalid8 = /* @__PURE__ */ __name((field3) => {
34706
- throw new CliError("validation_error", `invalid project annotation plan.${field3}`);
35138
+ var invalid8 = /* @__PURE__ */ __name((field4) => {
35139
+ throw new CliError("validation_error", `invalid project annotation plan.${field4}`);
34707
35140
  }, "invalid");
34708
35141
  var projectAnnotationBindingSources = /* @__PURE__ */ __name((manifest, bindings) => {
34709
35142
  if (!bindings || typeof bindings !== "object" || Array.isArray(bindings) || Object.keys(bindings).length > 1001)
@@ -34788,7 +35221,7 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
34788
35221
  };
34789
35222
  }, "planBoundProjectAnnotations");
34790
35223
 
34791
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
35224
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
34792
35225
  import { createHash as createHash17 } from "node:crypto";
34793
35226
  var text4 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
34794
35227
  var timestamp3 = pipe(number(), safeInteger(), minValue(0));
@@ -34835,8 +35268,8 @@ var snapshotGraph = /* @__PURE__ */ __name((value) => ({
34835
35268
  external: value.external
34836
35269
  }), "snapshotGraph");
34837
35270
  var decodeProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3) => {
34838
- const invalid10 = /* @__PURE__ */ __name((field3) => {
34839
- throw new CliError("validation_error", `invalid project annotation snapshot.${field3}`);
35271
+ const invalid10 = /* @__PURE__ */ __name((field4) => {
35272
+ throw new CliError("validation_error", `invalid project annotation snapshot.${field4}`);
34840
35273
  }, "invalid");
34841
35274
  if (typeof json3 !== "string" || Buffer.byteLength(json3) > PROJECT_ANNOTATIONS_MAX_BYTES)
34842
35275
  return invalid10("bytes");
@@ -34852,13 +35285,13 @@ var decodeProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3) => {
34852
35285
  const snapshot2 = checked.output;
34853
35286
  if (snapshot2.aliases.length + snapshot2.facts.length + snapshot2.links.length + snapshot2.external.length > 1e3)
34854
35287
  return invalid10("record budget");
34855
- for (const field3 of ["description", "status", "owner"])
34856
- if (snapshot2.project[field3] !== null && !snapshot2.project[field3].trim())
34857
- return invalid10(`project.${field3}`);
35288
+ for (const field4 of ["description", "status", "owner"])
35289
+ if (snapshot2.project[field4] !== null && !snapshot2.project[field4].trim())
35290
+ return invalid10(`project.${field4}`);
34858
35291
  for (const alias2 of snapshot2.aliases)
34859
- for (const field3 of ["name", "source"])
34860
- if (!alias2[field3].trim())
34861
- return invalid10(`aliases.${field3}`);
35292
+ for (const field4 of ["name", "source"])
35293
+ if (!alias2[field4].trim())
35294
+ return invalid10(`aliases.${field4}`);
34862
35295
  if (snapshot2.project.updated_at < snapshot2.project.created_at)
34863
35296
  return invalid10("project.updated_at");
34864
35297
  for (const alias2 of snapshot2.aliases)
@@ -34882,14 +35315,14 @@ var projectAnnotationSnapshotFingerprint = /* @__PURE__ */ __name((json3) => {
34882
35315
  })).digest("hex");
34883
35316
  }, "projectAnnotationSnapshotFingerprint");
34884
35317
 
34885
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
35318
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
34886
35319
  var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false) => {
34887
35320
  if (!request || typeof request !== "object" || Array.isArray(request))
34888
35321
  throw new CliError("validation_error", "project annotation request is required");
34889
35322
  const fields4 = ["snapshot", "project", "bindings", "maxReadBytes", ...restore ? ["fingerprint"] : []];
34890
- for (const field3 of Object.keys(request))
34891
- if (!fields4.includes(field3))
34892
- throw new CliError("validation_error", `unknown project annotation field ${field3}`);
35323
+ for (const field4 of Object.keys(request))
35324
+ if (!fields4.includes(field4))
35325
+ throw new CliError("validation_error", `unknown project annotation field ${field4}`);
34893
35326
  const snapshot2 = decodeProjectAnnotationSnapshot(request.snapshot);
34894
35327
  projectAnnotationBindingSources(snapshot2, request.bindings);
34895
35328
  if (typeof request.project !== "string" || !/^project:[1-9]\d*$/.test(request.project) || !Number.isSafeInteger(Number(request.project.slice(8))))
@@ -34899,7 +35332,7 @@ var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false)
34899
35332
  return { snapshot: snapshot2, projectId: Number(request.project.slice(8)) };
34900
35333
  }, "projectAnnotationRequest");
34901
35334
 
34902
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
35335
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
34903
35336
  var SnapshotBudget = class {
34904
35337
  static {
34905
35338
  __name(this, "SnapshotBudget");
@@ -34919,19 +35352,19 @@ var SnapshotBudget = class {
34919
35352
  this.bytes += bytes3;
34920
35353
  }
34921
35354
  rows(database, from2, fields4, parameters) {
34922
- const bytes3 = fields4.map((field3) => `coalesce(length(CAST(${field3} AS BLOB)),0)`).join("+");
35355
+ const bytes3 = fields4.map((field4) => `coalesce(length(CAST(${field4} AS BLOB)),0)`).join("+");
34923
35356
  const sized = database.prepare(`SELECT ${bytes3} AS bytes ${from2} LIMIT 1001`).all(...parameters);
34924
35357
  this.reserve(sized.length, sized.reduce((sum, row2) => sum + Number(row2.bytes) + 128, 0));
34925
35358
  }
34926
35359
  };
34927
35360
 
34928
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
35361
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
34929
35362
  import { createHash as createHash19 } from "node:crypto";
34930
35363
 
34931
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
35364
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
34932
35365
  var planProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3, target, bindings) => planBoundProjectAnnotations(decodeProjectAnnotationSnapshot(json3), projectAnnotationSnapshotFingerprint(json3), target, bindings), "planProjectAnnotationSnapshot");
34933
35366
 
34934
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
35367
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
34935
35368
  import { createHash as createHash18 } from "node:crypto";
34936
35369
  var invalid9 = /* @__PURE__ */ __name(() => {
34937
35370
  throw new CliError("configuration_error", "project snapshot has an unavailable or unsupported dependency");
@@ -35074,7 +35507,7 @@ var ProjectSnapshotSources = class {
35074
35507
  }
35075
35508
  };
35076
35509
 
35077
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
35510
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
35078
35511
  var unsupported = /* @__PURE__ */ __name(() => {
35079
35512
  throw new CliError("configuration_error", "project snapshot has unsupported metadata, deletion or account scope");
35080
35513
  }, "unsupported");
@@ -35245,7 +35678,7 @@ var projectAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId, bud
35245
35678
  return { snapshot: snapshot2, read_bytes: budget.bytes, records: budget.records };
35246
35679
  }), "projectAnnotationSnapshot");
35247
35680
 
35248
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
35681
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
35249
35682
  var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId, manifest, bindings, budget) => read(database, () => {
35250
35683
  const current = projectAnnotationSnapshot(database, projectId, budget).snapshot;
35251
35684
  const sources = new ProjectSnapshotSources(database, budget);
@@ -35282,7 +35715,7 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId, man
35282
35715
  if (project && names.has(normalizeVocabularyName(String(alias2.name))))
35283
35716
  namespace.add(`project:${project.id}`);
35284
35717
  }
35285
- const descriptor_conflicts = ["key", "name"].filter((field3) => current.project[field3] !== manifest.project[field3]);
35718
+ const descriptor_conflicts = ["key", "name"].filter((field4) => current.project[field4] !== manifest.project[field4]);
35286
35719
  const target = {
35287
35720
  project: current.project.ref,
35288
35721
  annotation_count: current.aliases.length + current.facts.length + current.links.length,
@@ -35307,7 +35740,7 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId, man
35307
35740
  };
35308
35741
  }), "previewAnnotationSnapshot");
35309
35742
 
35310
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
35743
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
35311
35744
  var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId, snapshot2, bindings) => {
35312
35745
  const mappings = { ...bindings };
35313
35746
  const resolve = /* @__PURE__ */ __name((ref3) => {
@@ -35326,7 +35759,7 @@ var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId, snap
35326
35759
  const author = resolve(fact.author), confirmed = resolve(fact.confirmed_by);
35327
35760
  if (!author)
35328
35761
  throw new CliError("validation_error", "project annotation author is required");
35329
- const row2 = database.prepare("INSERT INTO facts(type,statement,status,project_id,subject_type,subject_id,occurred_at,supersedes_id,author_type,author_id,model,confirmed_by_type,confirmed_by_id,scope,source,created_at,updated_at) VALUES(?,?,?,?,NULL,NULL,?,NULL,?,?,?,?,?,?,?,?,?) RETURNING id").get(fact.type, fact.statement, fact.status, projectId, fact.occurred_at, author.type, author.id, fact.model, confirmed?.type ?? null, confirmed?.id ?? null, fact.scope, fact.source, fact.created_at, fact.updated_at);
35762
+ const row2 = database.prepare("INSERT INTO facts(id,type,statement,status,project_id,subject_type,subject_id,occurred_at,supersedes_id,author_type,author_id,model,confirmed_by_type,confirmed_by_id,scope,source,created_at,updated_at) VALUES(?,?,?,?,?,NULL,NULL,?,NULL,?,?,?,?,?,?,?,?,?) RETURNING id").get(nextId(database, "facts"), fact.type, fact.statement, fact.status, projectId, fact.occurred_at, author.type, author.id, fact.model, confirmed?.type ?? null, confirmed?.id ?? null, fact.scope, fact.source, fact.created_at, fact.updated_at);
35330
35763
  if (!row2)
35331
35764
  throw new CliError("configuration_error", "project annotation fact insertion failed");
35332
35765
  mappings[fact.ref] = `fact:${row2.id}`;
@@ -35349,7 +35782,7 @@ var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId, snap
35349
35782
  return mappings;
35350
35783
  }, "restoreAnnotationRecords");
35351
35784
 
35352
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
35785
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
35353
35786
  var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
35354
35787
  async preview(request) {
35355
35788
  const { snapshot: snapshot2, projectId } = projectAnnotationRequest(request);
@@ -35379,7 +35812,7 @@ var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
35379
35812
  }
35380
35813
  }), "projectAnnotationStoreOver");
35381
35814
 
35382
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
35815
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
35383
35816
  var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to) => {
35384
35817
  const touching = and(eq(syncRanges.chatId, chatKey), lte(syncRanges.fromKey, to + 1), gte(syncRanges.toKey, from2 - 1));
35385
35818
  let merged = { from: from2, to };
@@ -35392,7 +35825,7 @@ var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to)
35392
35825
  }, "markRange");
35393
35826
  var ranges = /* @__PURE__ */ __name(({ orm }, chatKey) => orm.select({ from: syncRanges.fromKey, to: syncRanges.toKey }).from(syncRanges).where(eq(syncRanges.chatId, chatKey)).orderBy(syncRanges.fromKey).all(), "ranges");
35394
35827
 
35395
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
35828
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
35396
35829
  var keyOf4 = /* @__PURE__ */ __name(({ provider, account }) => `task_rules_until:${provider}:${account}`, "keyOf");
35397
35830
  var taskRulesStop = /* @__PURE__ */ __name((database, account) => {
35398
35831
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(keyOf4(account));
@@ -35402,7 +35835,7 @@ var setTaskRulesStop = /* @__PURE__ */ __name((database, account, until, now2) =
35402
35835
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(keyOf4(account), JSON.stringify(until), now2);
35403
35836
  }, "setTaskRulesStop");
35404
35837
 
35405
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sync.js
35838
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sync.js
35406
35839
  var syncStoreOver = /* @__PURE__ */ __name((context) => {
35407
35840
  const { database } = context;
35408
35841
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, identityPk: identityPk2, writeMembers: writeMembers2, writeState: writeState2 } = keysOver(context);
@@ -35458,7 +35891,7 @@ var syncStoreOver = /* @__PURE__ */ __name((context) => {
35458
35891
  };
35459
35892
  }, "syncStoreOver");
35460
35893
 
35461
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/tags.js
35894
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/tags.js
35462
35895
  var tagsStoreOver = /* @__PURE__ */ __name((context) => {
35463
35896
  const { database } = context;
35464
35897
  return {
@@ -35480,7 +35913,7 @@ var tagsStoreOver = /* @__PURE__ */ __name((context) => {
35480
35913
  };
35481
35914
  }, "tagsStoreOver");
35482
35915
 
35483
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
35916
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
35484
35917
  var IS_IMAGE = sql`(a.kind = 'photo' OR a.mime LIKE 'image/%')`;
35485
35918
  var neighbours = /* @__PURE__ */ __name(({ orm }, chatKey, messagePk, sentAt, { messages: messages2, withinMs }, side) => orm.all(sql`SELECT sender_name AS sender, text, sent_at AS sentAt FROM messages
35486
35919
  WHERE chat_id = ${chatKey} AND deleted_at IS NULL AND trim(text) <> '' AND id <> ${messagePk}
@@ -35607,7 +36040,7 @@ var savePictureChunks = /* @__PURE__ */ __name(({ orm, now: now2, database }, ac
35607
36040
  dropUnusedVectors(database, released.map(({ hash: hash2 }) => hash2));
35608
36041
  }, "savePictureChunks");
35609
36042
 
35610
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
36043
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
35611
36044
  var messagesToEmbed = /* @__PURE__ */ __name(({ orm }, accountPk2, { chatKey, model, after: after2, limit }) => orm.all(sql`SELECT m.id AS messagePk, m.text, m.sent_at AS sentAt, k.content_hash AS hash,
35612
36045
  EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ${model} AND v.content_hash = k.content_hash) AS embedded
35613
36046
  FROM messages m
@@ -35654,6 +36087,12 @@ var messageRows = /* @__PURE__ */ __name(({ orm }, accountPk2, { chatKey, model,
35654
36087
  ${since === void 0 ? sql`` : sql`AND m.sent_at >= ${since}`}
35655
36088
  ${before2 === void 0 ? sql`` : sql`AND m.sent_at < ${before2}`}
35656
36089
  ${"ids" in rows ? sql`AND k.id IN (SELECT value FROM json_each(${JSON.stringify(rows.ids)})) ORDER BY k.id` : sql`AND k.id > ${rows.after} ORDER BY k.id LIMIT ${SCAN_PAGE6}`}`), "messageRows");
36090
+ var scoreMessages = /* @__PURE__ */ __name(({ orm }, accountPk2, { model, query, pks }) => orm.all(sql`SELECT ch.external_id AS chatId, m.external_id AS messageId, v.vector
36091
+ FROM chunks k CROSS JOIN messages m ON m.id = k.chunkable_id AND m.deleted_at IS NULL
36092
+ JOIN chats ch ON ch.id = m.chat_id AND ch.searchable = 1
36093
+ JOIN embeddings v ON v.model = ${model} AND v.content_hash = k.content_hash
36094
+ WHERE k.chunkable_type = 'message' AND k.position = 0 AND k.account_id = ${accountPk2}
36095
+ AND k.chunkable_id IN (SELECT value FROM json_each(${JSON.stringify(pks)}))`).map(({ chatId, messageId, vector }) => ({ chatId, messageId, score: dot(query, vector) })).sort((a, b) => b.score - a.score), "scoreMessages");
35657
36096
  var nearestMessages = /* @__PURE__ */ __name((context, accountPk2, { limit, query, ...filter }) => {
35658
36097
  const score = /* @__PURE__ */ __name((row2) => ({
35659
36098
  id: row2.id,
@@ -35690,7 +36129,7 @@ var nearestMessages = /* @__PURE__ */ __name((context, accountPk2, { limit, quer
35690
36129
  return plain2(best(found2));
35691
36130
  }, "nearestMessages");
35692
36131
 
35693
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/vectors.js
36132
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/vectors.js
35694
36133
  var accountVectorsOver = /* @__PURE__ */ __name((context, mail) => {
35695
36134
  const { database } = context;
35696
36135
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -35831,6 +36270,10 @@ var accountVectorsOver = /* @__PURE__ */ __name((context, mail) => {
35831
36270
  query
35832
36271
  });
35833
36272
  }, "nearestMessages"),
36273
+ scoreMessages: /* @__PURE__ */ __name(async (key2, options) => {
36274
+ const accountPk2 = findAccountPk2(key2);
36275
+ return accountPk2 === void 0 ? [] : scoreMessages(context, accountPk2, options);
36276
+ }, "scoreMessages"),
35834
36277
  vectorStatus: /* @__PURE__ */ __name(async (key2, chatId, model) => {
35835
36278
  const chatKey = chatKeyOf(key2, chatId);
35836
36279
  return chatKey === void 0 ? { chunks: 0, embedded: 0 } : vectorStatus(context, chatKey, model);
@@ -35944,7 +36387,7 @@ var vectorsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
35944
36387
  embeddedHashes: /* @__PURE__ */ __name(async (model, hashes) => embeddedHashes(context, model, hashes), "embeddedHashes")
35945
36388
  }), "vectorsStoreOver");
35946
36389
 
35947
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
36390
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
35948
36391
  import { existsSync, readFileSync as readFileSync4 } from "node:fs";
35949
36392
  import { dirname as dirname2, join as join2 } from "node:path";
35950
36393
  var BOOKKEEPING = ["schema_migrations", "store_settings"];
@@ -36032,10 +36475,10 @@ var lastBackup = /* @__PURE__ */ __name((path) => {
36032
36475
  }
36033
36476
  }, "lastBackup");
36034
36477
 
36035
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/providers.js
36478
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/providers.js
36036
36479
  var registerProvider2 = /* @__PURE__ */ __name((store, entry2) => store.accounts.registerProvider(entry2), "registerProvider");
36037
36480
 
36038
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
36481
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
36039
36482
  var COUNTED_TABLES = [
36040
36483
  "accounts",
36041
36484
  "chats",
@@ -36120,7 +36563,7 @@ var storeContents = /* @__PURE__ */ __name((database) => {
36120
36563
  };
36121
36564
  }, "storeContents");
36122
36565
 
36123
- // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.67.0_commander@15._175d7b0a70ee7b08949f50032917d93e/node_modules/@wirecat/cli-core/dist/store/store.js
36566
+ // node_modules/.pnpm/@wirecat+cli-core@0.517.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.68.1_commander@15._6629eebba461c30d3c69d5318744d1d9/node_modules/@wirecat/cli-core/dist/store/store.js
36124
36567
  var openStore = /* @__PURE__ */ __name(async (options = {}) => {
36125
36568
  const context = await openStoreContext(options);
36126
36569
  try {
@@ -36346,6 +36789,7 @@ export {
36346
36789
  formatLocator,
36347
36790
  isLocator,
36348
36791
  parseLocator,
36792
+ normalizeVocabularyName,
36349
36793
  inboxKey,
36350
36794
  formatReference,
36351
36795
  parseReference,
@@ -36408,7 +36852,10 @@ export {
36408
36852
  resetSearchIndex,
36409
36853
  fillStems,
36410
36854
  resetStems,
36855
+ CONTEXT_MAX_READ_BYTES,
36856
+ contextEvidenceFingerprint,
36411
36857
  contextSource,
36858
+ contextEvidenceRequest,
36412
36859
  calendarMoment,
36413
36860
  involvementStoreOver,
36414
36861
  OTHER_SOURCES,