@wirecat/drive-cli 0.52.0 → 0.53.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 (194) hide show
  1. package/README.md +2 -2
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bin/drive.js.map +1 -1
  4. package/dist/bundle/{chunk-ZWSG7OCA.js → all-profiles-WRN35CUF.js} +11 -6
  5. package/dist/bundle/{anthropic-KW6KU36Y.js → anthropic-DZASXWG3.js} +1 -1
  6. package/dist/bundle/{app-server-TCJZ333E.js → app-server-4VHT7QZN.js} +33 -41
  7. package/dist/bundle/{bun-sqlite-RI7DR6RZ.js → bun-sqlite-2GOM5PM3.js} +1 -1
  8. package/dist/bundle/{chunk-LONV6HIK.js → chunk-2HHOMN2G.js} +440 -25
  9. package/dist/bundle/{chunk-4A2PIGC6.js → chunk-2PVDFLJJ.js} +8 -3
  10. package/dist/bundle/{chunk-725OHXKR.js → chunk-3RYX7IB6.js} +2218 -30
  11. package/dist/bundle/{chunk-CB7SBYLO.js → chunk-54BYJQ77.js} +41 -21
  12. package/dist/bundle/{chunk-5FONRUG6.js → chunk-5D4AEUVA.js} +1 -23
  13. package/dist/bundle/{chunk-RNSP57TC.js → chunk-6BNALDGA.js} +1 -1
  14. package/dist/bundle/{chunk-H47W2J6S.js → chunk-6XYGTRMQ.js} +812 -381
  15. package/dist/bundle/{chunk-UR32UWTQ.js → chunk-7IUMHMTP.js} +11 -0
  16. package/dist/bundle/{chunk-W7IK7E4B.js → chunk-BEL4XZ3M.js} +5 -7
  17. package/dist/bundle/{chunk-43QVYW3K.js → chunk-CL4GVCXS.js} +230 -56
  18. package/dist/bundle/{chunk-PQYVPCJ2.js → chunk-CNKILAWA.js} +18 -24
  19. package/dist/bundle/chunk-DOZOLBXE.js +110 -0
  20. package/dist/bundle/{chunk-2AUXBJRX.js → chunk-DT2YCB2V.js} +84 -11
  21. package/dist/bundle/{chunk-HQVJK5E7.js → chunk-DZMK255Y.js} +210 -357
  22. package/dist/bundle/{chunk-G6QF5KWF.js → chunk-E6XDFMRZ.js} +22 -28
  23. package/dist/bundle/{chunk-DW46P2DY.js → chunk-EKFEY3KP.js} +1 -1
  24. package/dist/bundle/{chunk-54O62JWP.js → chunk-F3KHUJEE.js} +24 -5
  25. package/dist/bundle/{chunk-I7UH5CTA.js → chunk-FXWBUTR7.js} +7 -9
  26. package/dist/bundle/{chunk-ZNZUZGSV.js → chunk-GE4DP24O.js} +131 -4
  27. package/dist/bundle/{chunk-PEOCBV2Z.js → chunk-GPJEYW2J.js} +1 -1
  28. package/dist/bundle/{chunk-A4UNTWAX.js → chunk-HM352LJR.js} +84 -15
  29. package/dist/bundle/{chunk-KYVXMEBC.js → chunk-IAQ4L6SM.js} +1 -1
  30. package/dist/bundle/{chunk-PQJYM5ES.js → chunk-IJFZKQC4.js} +1 -1
  31. package/dist/bundle/{chunk-O6IOL6RX.js → chunk-KPBCGUJC.js} +1 -1
  32. package/dist/bundle/{chunk-XOLQSCMF.js → chunk-KXMJE3XC.js} +2 -2
  33. package/dist/bundle/{chunk-33NVQGUY.js → chunk-LSGAJYVN.js} +2 -2
  34. package/dist/bundle/{chunk-2UIMEMWU.js → chunk-MK3N7WX7.js} +1 -1
  35. package/dist/bundle/{chunk-IDUNJCFO.js → chunk-OQMK6WXQ.js} +1 -1
  36. package/dist/bundle/{chunk-CM7GAXGD.js → chunk-PC4UA6UN.js} +1 -1
  37. package/dist/bundle/{chunk-YNFELLNQ.js → chunk-PIMMF67N.js} +2 -2
  38. package/dist/bundle/{chunk-WBTVGFXI.js → chunk-PR3DA7KA.js} +9 -9
  39. package/dist/bundle/{chunk-VJZST5RD.js → chunk-QXYGK6G5.js} +1 -1
  40. package/dist/bundle/{chunk-WQJBAWQP.js → chunk-R4TE4ZSD.js} +549 -224
  41. package/dist/bundle/{chunk-BSSCTWWK.js → chunk-RNIHKIQP.js} +1 -1
  42. package/dist/bundle/{chunk-PAXKALHV.js → chunk-SIWBUGBU.js} +116 -5
  43. package/dist/bundle/{chunk-2623YE5I.js → chunk-SQHPJBNO.js} +6 -8
  44. package/dist/bundle/chunk-SVTYS36O.js +5305 -0
  45. package/dist/bundle/{chunk-WLFUBNFX.js → chunk-T334CFU4.js} +2 -2
  46. package/dist/bundle/{chunk-UC22Q5KU.js → chunk-TZLO3ZZF.js} +16 -16
  47. package/dist/bundle/{chunk-5PLJKSG4.js → chunk-UFWK3L5Z.js} +4 -6
  48. package/dist/bundle/{chunk-FCJAHD4R.js → chunk-VTWADVEQ.js} +2 -2
  49. package/dist/bundle/{chunk-HX7Y2ASG.js → chunk-WJRJBQIM.js} +26040 -15126
  50. package/dist/bundle/{chunk-VSOLLTYT.js → chunk-YLKQSVLI.js} +5 -0
  51. package/dist/bundle/{chunk-IWFBAWZK.js → chunk-YQOVVCIA.js} +282 -10
  52. package/dist/bundle/{chunk-7YMDL4JQ.js → chunk-ZG6X24ON.js} +4 -1
  53. package/dist/bundle/{command-contract-I2YB5IXI.js → command-contract-D4UG3D33.js} +12 -15
  54. package/dist/bundle/{decode-EDN2ARXZ.js → decode-WAPM2VBH.js} +1 -1
  55. package/dist/bundle/drive.js +10 -21
  56. package/dist/bundle/{embed-3GSQIQXE.js → embed-HW3N3KNP.js} +4 -4
  57. package/dist/bundle/{embedder-6ULWRG3R.js → embedder-7WNFXYYP.js} +4 -4
  58. package/dist/bundle/{entry-IPRJLFHO.js → entry-J7YIRDPD.js} +4 -4
  59. package/dist/bundle/{first-run-FGHGWHC2.js → first-run-53CL2IYH.js} +6 -6
  60. package/dist/bundle/{first-screen-M62KTPZG.js → first-screen-2KT7HM2K.js} +13 -16
  61. package/dist/bundle/{google-BD3ZNFVJ.js → google-5NNVARNR.js} +2 -2
  62. package/dist/bundle/{chunk-GR5GGZKH.js → google-api-EQQH53QD.js} +60 -4
  63. package/dist/bundle/grants-4NETZ4MR.js +98 -0
  64. package/dist/bundle/{identity-QLBSASO5.js → identity-LBTXDMTA.js} +4 -2
  65. package/dist/bundle/{login-VNZKRSAD.js → login-Y6ENYKC3.js} +50 -52
  66. package/dist/bundle/{node-sqlite-J3OODPYK.js → node-sqlite-FSQIKGED.js} +1 -1
  67. package/dist/bundle/{oauth-L4VTCBLF.js → oauth-HF5USWXY.js} +5 -5
  68. package/dist/bundle/{open-SGUN7ZVF.js → open-NHGJENCX.js} +2 -2
  69. package/dist/bundle/{openai-RLVISEDH.js → openai-3JCJYKNX.js} +6 -6
  70. package/dist/bundle/{program-6S5EH7BS.js → program-QAJ66K3Z.js} +715 -904
  71. package/dist/bundle/{prompt-AUWTBLO7.js → prompt-LQJBCCUF.js} +3 -3
  72. package/dist/bundle/{reasons-M5AKCNCU.js → reasons-J57GSRWN.js} +1 -1
  73. package/dist/bundle/{recognize-ORX2UBQW.js → recognize-QM3LN4ZF.js} +1 -1
  74. package/dist/bundle/{remote-AGIJY73X.js → remote-WREGEZJQ.js} +5 -5
  75. package/dist/bundle/{rerank-R6PE44M5.js → rerank-YFUB6J6M.js} +4 -4
  76. package/dist/bundle/{chunk-G7DCVJ4F.js → serve-7NFEZ564.js} +7 -4
  77. package/dist/bundle/{chunk-F7UUZATI.js → server-KBCFZ2AU.js} +38 -11
  78. package/dist/bundle/server-UYVL2CFI.js +63 -0
  79. package/dist/bundle/{services-HZFTTZSF.js → services-C3XWRA2W.js} +16 -21
  80. package/dist/bundle/{sqlite-runtime-DTGPR2T2.js → sqlite-runtime-H3TSAMIN.js} +3 -3
  81. package/dist/bundle/{state-WG3JKJM3.js → state-S2Q53L6L.js} +3 -3
  82. package/dist/bundle/{store-33VHIMEO.js → store-H345VQHP.js} +6 -8
  83. package/dist/bundle/{store-EV72MT5U.js → store-I27LAJPU.js} +7 -9
  84. package/dist/bundle/store-maintenance-command-3XA73XMC.js +52 -0
  85. package/dist/bundle/{chunk-GNI7INK6.js → terminal-DHJ4D3BC.js} +2 -3
  86. package/dist/bundle/tokens-7MUGKFEM.js +96 -0
  87. package/dist/commands/context.d.ts +14 -13
  88. package/dist/commands/context.d.ts.map +1 -1
  89. package/dist/commands/context.js.map +1 -1
  90. package/dist/commands/documents.d.ts.map +1 -1
  91. package/dist/commands/documents.js +1 -4
  92. package/dist/commands/documents.js.map +1 -1
  93. package/dist/commands/mirrors.d.ts.map +1 -1
  94. package/dist/commands/mirrors.js +1 -2
  95. package/dist/commands/mirrors.js.map +1 -1
  96. package/dist/commands/session.d.ts.map +1 -1
  97. package/dist/commands/session.js +2 -1
  98. package/dist/commands/session.js.map +1 -1
  99. package/dist/commands/upgrade.d.ts +1 -1
  100. package/dist/commands/upgrade.d.ts.map +1 -1
  101. package/dist/commands/upgrade.js +4 -9
  102. package/dist/commands/upgrade.js.map +1 -1
  103. package/dist/config.d.ts +182 -0
  104. package/dist/config.d.ts.map +1 -1
  105. package/dist/config.js +38 -3
  106. package/dist/config.js.map +1 -1
  107. package/dist/contract-overrides.d.ts +0 -3
  108. package/dist/contract-overrides.d.ts.map +1 -1
  109. package/dist/contract-overrides.js +0 -234
  110. package/dist/contract-overrides.js.map +1 -1
  111. package/dist/first-screen.d.ts +3 -2
  112. package/dist/first-screen.d.ts.map +1 -1
  113. package/dist/first-screen.js +17 -22
  114. package/dist/first-screen.js.map +1 -1
  115. package/dist/grants.d.ts +9 -0
  116. package/dist/grants.d.ts.map +1 -0
  117. package/dist/grants.js +30 -0
  118. package/dist/grants.js.map +1 -0
  119. package/dist/identity.d.ts.map +1 -1
  120. package/dist/identity.js +2 -0
  121. package/dist/identity.js.map +1 -1
  122. package/dist/login.d.ts.map +1 -1
  123. package/dist/login.js +7 -3
  124. package/dist/login.js.map +1 -1
  125. package/dist/policy-keys.d.ts +12 -0
  126. package/dist/policy-keys.d.ts.map +1 -0
  127. package/dist/policy-keys.js +107 -0
  128. package/dist/policy-keys.js.map +1 -0
  129. package/dist/policy.d.ts +1 -8
  130. package/dist/policy.d.ts.map +1 -1
  131. package/dist/policy.js +2 -105
  132. package/dist/policy.js.map +1 -1
  133. package/dist/program.d.ts +8 -4
  134. package/dist/program.d.ts.map +1 -1
  135. package/dist/program.js +251 -222
  136. package/dist/program.js.map +1 -1
  137. package/dist/reasons.js +1 -1
  138. package/dist/reasons.js.map +1 -1
  139. package/dist/testing/mcp.d.ts +28 -0
  140. package/dist/testing/mcp.d.ts.map +1 -0
  141. package/dist/testing/mcp.js +56 -0
  142. package/dist/testing/mcp.js.map +1 -0
  143. package/dist/tokens.d.ts +0 -2
  144. package/dist/tokens.d.ts.map +1 -1
  145. package/dist/tokens.js +12 -13
  146. package/dist/tokens.js.map +1 -1
  147. package/dist/version.d.ts +1 -1
  148. package/dist/version.js +1 -1
  149. package/package.json +4 -3
  150. package/scenarios/agent-access.md +4 -2
  151. package/dist/bundle/all-profiles-CYW6XBBS.js +0 -26
  152. package/dist/bundle/chunk-234MHU76.js +0 -384
  153. package/dist/bundle/chunk-4CPLOMRK.js +0 -1714
  154. package/dist/bundle/chunk-4Z6TCU5T.js +0 -9
  155. package/dist/bundle/chunk-DO4PDQY5.js +0 -48
  156. package/dist/bundle/chunk-FDWYPONW.js +0 -1988
  157. package/dist/bundle/chunk-FQRJWVEB.js +0 -2
  158. package/dist/bundle/chunk-NPSZPUK6.js +0 -193
  159. package/dist/bundle/chunk-PDGECM5D.js +0 -138
  160. package/dist/bundle/chunk-Q765VPZY.js +0 -421
  161. package/dist/bundle/chunk-WQRGA75U.js +0 -256
  162. package/dist/bundle/chunk-X6ID5EAR.js +0 -522
  163. package/dist/bundle/chunk-YVPHJHIL.js +0 -15572
  164. package/dist/bundle/chunk-Z47LOJUS.js +0 -484
  165. package/dist/bundle/failure-4CVEVY45.js +0 -37
  166. package/dist/bundle/google-api-BDUWZMRV.js +0 -83
  167. package/dist/bundle/mcp-5SNSMI2M.js +0 -502
  168. package/dist/bundle/mcp-JZSYPQA4.js +0 -96
  169. package/dist/bundle/serve-VOBAQHAQ.js +0 -20
  170. package/dist/bundle/server-24PS4M7U.js +0 -70
  171. package/dist/bundle/server-G6HFZ2CK.js +0 -57
  172. package/dist/bundle/store-maintenance-command-ZTUEI4EC.js +0 -58
  173. package/dist/bundle/terminal-TFCTWLOS.js +0 -11
  174. package/dist/bundle/tokens-XDQXUFDQ.js +0 -104
  175. package/dist/commands/doctor.d.ts +0 -56
  176. package/dist/commands/doctor.d.ts.map +0 -1
  177. package/dist/commands/doctor.js +0 -75
  178. package/dist/commands/doctor.js.map +0 -1
  179. package/dist/commands/mcp.d.ts +0 -6
  180. package/dist/commands/mcp.d.ts.map +0 -1
  181. package/dist/commands/mcp.js +0 -156
  182. package/dist/commands/mcp.js.map +0 -1
  183. package/dist/commands/skill.d.ts +0 -6
  184. package/dist/commands/skill.d.ts.map +0 -1
  185. package/dist/commands/skill.js +0 -34
  186. package/dist/commands/skill.js.map +0 -1
  187. package/dist/failure.d.ts +0 -88
  188. package/dist/failure.d.ts.map +0 -1
  189. package/dist/failure.js +0 -60
  190. package/dist/failure.js.map +0 -1
  191. package/dist/mcp.d.ts +0 -175
  192. package/dist/mcp.d.ts.map +0 -1
  193. package/dist/mcp.js +0 -412
  194. package/dist/mcp.js.map +0 -1
@@ -4,59 +4,23 @@ import {
4
4
  MAX_TEXT_CHARS
5
5
  } from "./chunk-JEOYFKUK.js";
6
6
  import {
7
- COUNTER_FIELDS,
8
- DOCUMENT_ACCOUNT_PROVIDERS,
9
- INTERNAL_NOTES,
10
- UNKNOWN_PROVIDER,
11
- addProvider,
12
- canonicalReference,
13
- counterFreshness,
14
- counterObservationTime,
15
- filesAccountSql,
16
- folderProviderOf,
17
- folderProviderSql,
18
- formatLocator,
19
- formatReference,
20
- isDocumentAccountProvider,
21
- isFolderProvider,
22
- isKind,
23
- isLocator,
24
- kindIn,
25
- kindOf,
26
- needsRankingContext,
27
- parseLocator,
28
- parseReference,
29
- providerEntryOf,
30
- providerNamed,
31
- providers,
32
- rankingQuestion,
33
- rankingScore,
34
- rankingWords,
35
- useStoredProviders,
36
- validCounter
37
- } from "./chunk-234MHU76.js";
38
- import {
7
+ CHAT_MESSAGES_READ,
39
8
  FACT_STATUSES,
40
9
  FACT_TYPES,
41
10
  LINK_KINDS,
42
11
  LINK_ORIGINS,
12
+ MEETING_FINDINGS_KIND,
43
13
  MEMORY_KINDS,
44
14
  MEMORY_SCOPES,
15
+ MeetingError,
45
16
  RELATION_KINDS,
17
+ REVIEW_LIMIT,
46
18
  TASK_KINDS,
47
19
  TASK_ORIGINS,
48
20
  TASK_STATES,
49
21
  TASK_TYPES,
50
22
  TASK_VERDICTS,
51
23
  WORK_TASK_TYPES,
52
- linkKind,
53
- matches
54
- } from "./chunk-PDGECM5D.js";
55
- import {
56
- CHAT_MESSAGES_READ,
57
- MEETING_FINDINGS_KIND,
58
- MeetingError,
59
- REVIEW_LIMIT,
60
24
  aggregateMeetingStats,
61
25
  calendarText,
62
26
  canonicalMeetingReference,
@@ -67,6 +31,8 @@ import {
67
31
  formatMeetingReference,
68
32
  joinKeyOf,
69
33
  joinUrlWithoutQuery,
34
+ linkKind,
35
+ matches,
70
36
  meetingCueFingerprint,
71
37
  meetingFindingFingerprint,
72
38
  normalizeMeetingParticipantQuery,
@@ -80,7 +46,7 @@ import {
80
46
  validateMeetingPreparationContext,
81
47
  validateMeetingRelatedHistory,
82
48
  validateMeetingSeriesHistory
83
- } from "./chunk-ZNZUZGSV.js";
49
+ } from "./chunk-GE4DP24O.js";
84
50
  import {
85
51
  QUERY_LIMITS,
86
52
  dateRange,
@@ -110,18 +76,18 @@ import {
110
76
  sharedConfigPath,
111
77
  storedTaskCategories,
112
78
  taskCategoriesReader
113
- } from "./chunk-XOLQSCMF.js";
79
+ } from "./chunk-KXMJE3XC.js";
114
80
  import {
115
81
  storePath
116
- } from "./chunk-VJZST5RD.js";
82
+ } from "./chunk-QXYGK6G5.js";
117
83
  import {
118
84
  PRAGMAS,
119
85
  quietSqliteWarning,
120
86
  storeCapable
121
- } from "./chunk-33NVQGUY.js";
87
+ } from "./chunk-LSGAJYVN.js";
122
88
  import {
123
89
  singleLine
124
- } from "./chunk-HQVJK5E7.js";
90
+ } from "./chunk-DZMK255Y.js";
125
91
  import {
126
92
  CliError,
127
93
  array,
@@ -300,6 +266,97 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
300
266
  };
301
267
  }, "bindAccount");
302
268
 
269
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/providers.js
270
+ var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events"];
271
+ var PROVIDERS = [
272
+ { name: "telegram", kind: "messages", aliases: ["tg"] },
273
+ { name: "telegram-bot", kind: "messages", aliases: ["tg-bot"] },
274
+ { name: "max", kind: "messages", aliases: [] },
275
+ { name: "max-bot", kind: "messages", aliases: [] },
276
+ { name: "whatsapp", kind: "messages", aliases: ["wa"] },
277
+ { name: "whatsapp-bot", kind: "messages", aliases: ["wa-bot"] },
278
+ { name: "email", kind: "mail", aliases: [] },
279
+ { name: "notes", kind: "notes", aliases: [] },
280
+ { name: "local", kind: "notes", aliases: [] },
281
+ { name: "obsidian", kind: "notes", aliases: [] },
282
+ { name: "zoom", kind: "meetings", aliases: [] }
283
+ ];
284
+ var FOLDER_PROVIDERS = ["local", "obsidian", "folder"];
285
+ var isFolderProvider = /* @__PURE__ */ __name((provider) => FOLDER_PROVIDERS.includes(provider), "isFolderProvider");
286
+ var folderProviderSql = /* @__PURE__ */ __name((column2 = "provider") => `${column2} IN (${FOLDER_PROVIDERS.map((name) => `'${name}'`).join(", ")})`, "folderProviderSql");
287
+ var folderProviderOf = /* @__PURE__ */ __name((format) => format === "markdown" ? "local" : "obsidian", "folderProviderOf");
288
+ var DOCUMENT_ACCOUNT_PROVIDERS = ["google-drive"];
289
+ var isDocumentAccountProvider = /* @__PURE__ */ __name((provider) => DOCUMENT_ACCOUNT_PROVIDERS.includes(provider), "isDocumentAccountProvider");
290
+ var filesAccountSql = /* @__PURE__ */ __name((column2 = "provider") => `${column2} IN (${[...FOLDER_PROVIDERS, ...DOCUMENT_ACCOUNT_PROVIDERS].map((name) => `'${name}'`).join(", ")})`, "filesAccountSql");
291
+ var INTERNAL_NOTES = "internal";
292
+ var UNKNOWN_PROVIDER = "unknown provider \u2014 run its CLI once";
293
+ var WORD = /^[a-z0-9][a-z0-9_-]*$/;
294
+ var invalid = /* @__PURE__ */ __name((message2) => {
295
+ throw new CliError("validation_error", message2);
296
+ }, "invalid");
297
+ var wordOf = /* @__PURE__ */ __name((value, what) => typeof value === "string" && WORD.test(value) ? value : invalid(`${what} is lowercase letters, digits, - and _ \u2014 not ${JSON.stringify(value)}`), "wordOf");
298
+ var providerEntryOf = /* @__PURE__ */ __name((value) => {
299
+ if (typeof value !== "object" || value === null || Array.isArray(value))
300
+ return invalid("a provider entry is an object");
301
+ const { name, kind: kind3, aliases: aliases2 = [], command } = value;
302
+ const named2 = wordOf(name, "a provider's name");
303
+ if (typeof kind3 !== "string" || !KINDS.includes(kind3))
304
+ invalid(`provider ${named2}'s kind is one of ${KINDS.join(", ")} \u2014 not ${JSON.stringify(kind3)}`);
305
+ if (!Array.isArray(aliases2))
306
+ invalid(`provider ${named2}'s aliases are a list`);
307
+ return {
308
+ name: named2,
309
+ kind: kind3,
310
+ aliases: [...new Set(aliases2.map((alias2) => wordOf(alias2, `an alias of ${named2}`)))],
311
+ ...command === void 0 ? {} : { command: wordOf(command, `the command of ${named2}`) }
312
+ };
313
+ }, "providerEntryOf");
314
+ var describe = /* @__PURE__ */ __name(({ name, kind: kind3, command }) => `${name} (${kind3}${command ? `, from ${command}` : ""})`, "describe");
315
+ var wordsOf = /* @__PURE__ */ __name(({ name, aliases: aliases2 }) => [name, ...aliases2], "wordsOf");
316
+ var joined = /* @__PURE__ */ __name((known2, entry2) => {
317
+ const same = known2.find(({ name }) => name === entry2.name);
318
+ if (same && same.kind !== entry2.kind)
319
+ invalid(`two provider entries disagree on the kind: ${describe(same)} and ${describe(entry2)}`);
320
+ const merged = same ? {
321
+ ...same,
322
+ aliases: [.../* @__PURE__ */ new Set([...same.aliases, ...entry2.aliases])],
323
+ ...entry2.command ? { command: entry2.command } : {}
324
+ } : entry2;
325
+ const others = known2.filter((one) => one !== same);
326
+ for (const word of wordsOf(merged)) {
327
+ const owner = others.find((one) => wordsOf(one).includes(word));
328
+ if (owner)
329
+ invalid(`"${word}" names two providers: ${describe(owner)} and ${describe(merged)}`);
330
+ }
331
+ return same ? known2.map((one) => one === same ? merged : one) : [...known2, merged];
332
+ }, "joined");
333
+ var registry = PROVIDERS;
334
+ var providers = /* @__PURE__ */ __name(() => registry, "providers");
335
+ var useStoredProviders = /* @__PURE__ */ __name((entries) => {
336
+ const left = [];
337
+ registry = entries.reduce((known2, entry2) => {
338
+ try {
339
+ return joined(known2, providerEntryOf(entry2));
340
+ } catch (error) {
341
+ if (!(error instanceof CliError))
342
+ throw error;
343
+ left.push(entry2);
344
+ return known2;
345
+ }
346
+ }, PROVIDERS);
347
+ return left;
348
+ }, "useStoredProviders");
349
+ var addProvider = /* @__PURE__ */ __name((entry2) => {
350
+ registry = joined(registry, providerEntryOf(entry2));
351
+ }, "addProvider");
352
+ var isKind = /* @__PURE__ */ __name((word) => KINDS.includes(word.toLowerCase()), "isKind");
353
+ var providerNamed = /* @__PURE__ */ __name((word) => {
354
+ const wanted = word.toLowerCase();
355
+ return registry.find((entry2) => wordsOf(entry2).includes(wanted));
356
+ }, "providerNamed");
357
+ var kindIn = /* @__PURE__ */ __name((provider) => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind, "kindIn");
358
+ var kindOf = /* @__PURE__ */ __name((provider) => kindIn(provider) ?? "messages", "kindOf");
359
+
303
360
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/search/query.js
304
361
  var isBotProvider = /* @__PURE__ */ __name((provider) => provider.endsWith("-bot"), "isBotProvider");
305
362
  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");
@@ -339,7 +396,7 @@ var itemsOf = /* @__PURE__ */ __name((value) => {
339
396
  }, "itemsOf");
340
397
  var groupName = /* @__PURE__ */ __name((name) => GROUP_NAME.test(name) ? name : fail2(`a group name is letters, digits, - and _ \u2014 not "${name}"`), "groupName");
341
398
  var groupMembers = /* @__PURE__ */ __name((value) => itemsOf(value).map((item) => item.toLowerCase().startsWith("group:") ? fail2(`a group lists accounts, not other groups \u2014 "${item}"`) : item.includes(":") && item.split(":")[1] === "" ? fail2(`"${item}" names no account after the colon`) : item), "groupMembers");
342
- var describe = /* @__PURE__ */ __name((accounts2) => accounts2.map(({ provider, account, name }) => `${provider}:${account}${name ? ` (${name})` : ""}`).join(", "), "describe");
399
+ var describe2 = /* @__PURE__ */ __name((accounts2) => accounts2.map(({ provider, account, name }) => `${provider}:${account}${name ? ` (${name})` : ""}`).join(", "), "describe");
343
400
  var kindHere = /* @__PURE__ */ __name((provider, running) => provider === running.provider ? kindOf(provider) : kindIn(provider), "kindHere");
344
401
  var heldOf = /* @__PURE__ */ __name((stored3, running) => [
345
402
  ...stored3.filter(({ provider }) => kindIn(provider) !== "notes" && !isDocumentAccountProvider(provider)).map(({ provider, account, name }) => ({ provider, account, name, kind: kindHere(provider, running) })),
@@ -360,7 +417,7 @@ var heldOf = /* @__PURE__ */ __name((stored3, running) => [
360
417
  }))
361
418
  ], "heldOf");
362
419
  var storedAs = /* @__PURE__ */ __name((held, key2) => held.filter(({ stored: stored3 }) => stored3?.provider === key2.provider && (key2.account === "" || stored3.account === key2.account)), "storedAs");
363
- var registry = /* @__PURE__ */ __name(() => providers().map(({ name, aliases: aliases2 }) => aliases2.length ? `${name} (${aliases2.join(", ")})` : name).join(", "), "registry");
420
+ var registry2 = /* @__PURE__ */ __name(() => providers().map(({ name, aliases: aliases2 }) => aliases2.length ? `${name} (${aliases2.join(", ")})` : name).join(", "), "registry");
364
421
  var providerOf = /* @__PURE__ */ __name((prefix, held, { running, profiles }) => {
365
422
  const wanted = prefix.toLowerCase();
366
423
  if (wanted === running.command?.toLowerCase())
@@ -374,7 +431,7 @@ var providerOf = /* @__PURE__ */ __name((prefix, held, { running, profiles }) =>
374
431
  const recorded = Object.values(profiles[wanted] ?? {})[0];
375
432
  if (recorded)
376
433
  return recorded.provider;
377
- return fail2(`${prefix} is not a provider \u2014 they are ${registry()}; the store holds ${providers2.join(", ")}`);
434
+ return fail2(`${prefix} is not a provider \u2014 they are ${registry2()}; the store holds ${providers2.join(", ")}`);
378
435
  }, "providerOf");
379
436
  var profilesOf = /* @__PURE__ */ __name((provider, profiles) => Object.values(profiles).flatMap((named2) => Object.entries(named2).filter(([, key2]) => key2.provider === provider)), "profilesOf");
380
437
  var accountOf = /* @__PURE__ */ __name((prefix, ref3, held, context) => {
@@ -418,9 +475,9 @@ var accountOf = /* @__PURE__ */ __name((prefix, ref3, held, context) => {
418
475
  if (byName.length === 1)
419
476
  return byName[0];
420
477
  if (byName.length > 1 || byProfile.length > 1)
421
- fail2(`${provider}:${ref3} names more than one account \u2014 use the id: ${describe(ofProvider)}`);
478
+ fail2(`${provider}:${ref3} names more than one account \u2014 use the id: ${describe2(ofProvider)}`);
422
479
  const names = profilesOf(provider, context.profiles).map(([name]) => name);
423
- return fail2(`no ${provider} account "${ref3}" \u2014 the store holds ${describe(ofProvider) || "none"}` + (names.length ? `; profiles: ${[...new Set(names)].join(", ")}` : ""));
480
+ return fail2(`no ${provider} account "${ref3}" \u2014 the store holds ${describe2(ofProvider) || "none"}` + (names.length ? `; profiles: ${[...new Set(names)].join(", ")}` : ""));
424
481
  }, "accountOf");
425
482
  var accountsOfWord = /* @__PURE__ */ __name((word, held, context) => {
426
483
  const wanted = word.toLowerCase();
@@ -13404,7 +13461,7 @@ var LATIN_UNIT = new RegExp(Object.keys(LATIN_TO_CYRILLIC).join("|"), "g");
13404
13461
  var cyrillicOf = /* @__PURE__ */ __name((latin) => latin.toLowerCase().replace(/ey$/, "\u0435\u0439").replace(/i?y$/, "\u0438\u0439").replace(LATIN_UNIT, (unit) => LATIN_TO_CYRILLIC[unit] ?? unit), "cyrillicOf");
13405
13462
  var MIN_STEM = 2;
13406
13463
  var MIN_WORD = 4;
13407
- var WORD = new RegExp("(?<![\\p{L}\\p{N}])\\p{Lu}\\p{Ll}{3,}(?![\\p{L}\\p{N}])", "gu");
13464
+ var WORD2 = new RegExp("(?<![\\p{L}\\p{N}])\\p{Lu}\\p{Ll}{3,}(?![\\p{L}\\p{N}])", "gu");
13408
13465
  var NAME_WORD = new RegExp("^\\p{L}{3,}$", "u");
13409
13466
  var MAX_ENDING = 3;
13410
13467
  var keyOf2 = /* @__PURE__ */ __name((stem, word) => `s:${stem.stemToken(word)}`, "keyOf");
@@ -13453,7 +13510,7 @@ var findNames = /* @__PURE__ */ __name((text5, index2) => {
13453
13510
  return [];
13454
13511
  const found2 = [];
13455
13512
  let previous;
13456
- for (const match of text5.matchAll(WORD)) {
13513
+ for (const match of text5.matchAll(WORD2)) {
13457
13514
  const bearers = POLITE.test(match[0]) ? void 0 : bearersOf(index2, match[0]);
13458
13515
  const start = match.index;
13459
13516
  const end = start + match[0].length;
@@ -13518,7 +13575,7 @@ var nameForms = /* @__PURE__ */ __name(() => {
13518
13575
  }, "nameForms");
13519
13576
  var roleOf = /* @__PURE__ */ __name((word) => PATRONYMIC.test(word) ? "patronymic" : nameForms().get(word.toLowerCase()), "roleOf");
13520
13577
  var findUnknownNames = /* @__PURE__ */ __name((text5, stem, taken) => {
13521
- const words3 = [...text5.matchAll(WORD)].map((match) => ({ text: match[0], start: match.index, end: match.index + match[0].length })).filter((word) => !taken.some((one) => word.start < one.end && word.end > one.start));
13578
+ const words3 = [...text5.matchAll(WORD2)].map((match) => ({ text: match[0], start: match.index, end: match.index + match[0].length })).filter((word) => !taken.some((one) => word.start < one.end && word.end > one.start));
13522
13579
  const adjacent = /* @__PURE__ */ __name((a, b) => {
13523
13580
  const left = words3[a];
13524
13581
  const right = words3[b];
@@ -14646,6 +14703,20 @@ var valueMatch = /* @__PURE__ */ __name((database, typed) => {
14646
14703
  return { sql: "mn.value = ?", params: [phone?.value ?? normalizedValue(typed, { phoneCountries })] };
14647
14704
  }, "valueMatch");
14648
14705
 
14706
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/locator.js
14707
+ var SCHEME = "msg:";
14708
+ var formatLocator = /* @__PURE__ */ __name(({ provider, account, chat: chat2, message: message2 }) => SCHEME + [provider, account, chat2, message2].map(encodeURIComponent).join("/"), "formatLocator");
14709
+ var isLocator = /* @__PURE__ */ __name((reference2) => reference2.trim().startsWith(SCHEME), "isLocator");
14710
+ var parseLocator = /* @__PURE__ */ __name((reference2) => {
14711
+ const trimmed = reference2.trim();
14712
+ const parts2 = trimmed.startsWith(SCHEME) ? trimmed.slice(SCHEME.length).split("/") : [];
14713
+ if (parts2.length !== 4 || parts2.some((part) => part === "")) {
14714
+ throw new CliError("validation_error", `"${singleLine(reference2)}" is not a message locator \u2014 expected msg:<provider>/<account>/<chat>/<message>`);
14715
+ }
14716
+ const [provider, account, chat2, message2] = parts2.map(decodeURIComponent);
14717
+ return { provider, account, chat: chat2, message: message2 };
14718
+ }, "parseLocator");
14719
+
14649
14720
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
14650
14721
  var normalizeVocabularyName = /* @__PURE__ */ __name((input) => {
14651
14722
  if (typeof input !== "string" || input.length > 200 || /[\p{Cc}\p{Cf}]/u.test(input))
@@ -14741,37 +14812,37 @@ var guardTagCreation = /* @__PURE__ */ __name((context, name, kind3, by, options
14741
14812
  }, "guardTagCreation");
14742
14813
 
14743
14814
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
14744
- var invalid = /* @__PURE__ */ __name((message2) => {
14815
+ var invalid2 = /* @__PURE__ */ __name((message2) => {
14745
14816
  throw new CliError("validation_error", message2);
14746
14817
  }, "invalid");
14747
14818
  var record2 = /* @__PURE__ */ __name((value, fields4, field3) => {
14748
14819
  if (!value || typeof value !== "object" || Array.isArray(value))
14749
- return invalid(`${field3} must be an object`);
14820
+ return invalid2(`${field3} must be an object`);
14750
14821
  for (const key2 of Object.keys(value))
14751
14822
  if (!fields4.includes(key2))
14752
- invalid(`unknown ${field3} field: ${key2}`);
14823
+ invalid2(`unknown ${field3} field: ${key2}`);
14753
14824
  return value;
14754
14825
  }, "record");
14755
14826
  var tagId = /* @__PURE__ */ __name((value, field3) => {
14756
14827
  if (typeof value !== "string" || value.length > 16 || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
14757
- return invalid(`${field3} must be a positive canonical tag id`);
14828
+ return invalid2(`${field3} must be a positive canonical tag id`);
14758
14829
  return value;
14759
14830
  }, "tagId");
14760
14831
  var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
14761
14832
  const input = record2(snapshot2, ["complete", "tags", "redirects"], "snapshot");
14762
14833
  if (input.complete !== true)
14763
- invalid("snapshot.complete must be true; partial tag graphs cannot resolve labels");
14834
+ invalid2("snapshot.complete must be true; partial tag graphs cannot resolve labels");
14764
14835
  for (const field3 of ["tags", "redirects"])
14765
14836
  if (!Array.isArray(input[field3]) || input[field3].length > 4096)
14766
- invalid(`snapshot.${field3} must be an array of at most 4096 rows`);
14837
+ invalid2(`snapshot.${field3} must be an array of at most 4096 rows`);
14767
14838
  const ids = /* @__PURE__ */ new Set();
14768
14839
  for (const [index2, value] of snapshot2.tags.entries()) {
14769
14840
  const row2 = record2(value, ["id", "kind"], `tags[${index2}]`);
14770
14841
  const id2 = tagId(row2.id, `tags[${index2}].id`);
14771
14842
  if (row2.kind !== "tag")
14772
- invalid(`tags[${index2}].kind must be tag; topics and projects cannot redirect`);
14843
+ invalid2(`tags[${index2}].kind must be tag; topics and projects cannot redirect`);
14773
14844
  if (ids.has(id2))
14774
- invalid(`tags[${index2}].id is duplicated`);
14845
+ invalid2(`tags[${index2}].id is duplicated`);
14775
14846
  ids.add(id2);
14776
14847
  }
14777
14848
  const edges = /* @__PURE__ */ new Map();
@@ -14780,9 +14851,9 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
14780
14851
  const source2 = tagId(row2.sourceId, `redirects[${index2}].sourceId`);
14781
14852
  const survivor = tagId(row2.survivorId, `redirects[${index2}].survivorId`);
14782
14853
  if (!ids.has(source2) || !ids.has(survivor))
14783
- invalid(`redirects[${index2}] names an unavailable tag`);
14854
+ invalid2(`redirects[${index2}] names an unavailable tag`);
14784
14855
  if (edges.has(source2))
14785
- invalid(`redirects[${index2}].sourceId has more than one redirect`);
14856
+ invalid2(`redirects[${index2}].sourceId has more than one redirect`);
14786
14857
  edges.set(source2, survivor);
14787
14858
  }
14788
14859
  const paths = /* @__PURE__ */ new Map();
@@ -14794,9 +14865,9 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
14794
14865
  while (edges.has(current)) {
14795
14866
  const next = edges.get(current);
14796
14867
  if (path.includes(next))
14797
- invalid("redirects contain a cycle");
14868
+ invalid2("redirects contain a cycle");
14798
14869
  if (path.length > 16)
14799
- invalid("redirects exceed the maximum of 16 hops");
14870
+ invalid2("redirects exceed the maximum of 16 hops");
14800
14871
  path.push(next);
14801
14872
  current = next;
14802
14873
  }
@@ -14873,6 +14944,78 @@ var taskAccountOf = /* @__PURE__ */ __name((database, rowId) => {
14873
14944
  return row2 && String(row2.key) === inboxKey(String(row2.name)) ? String(row2.name) : void 0;
14874
14945
  }, "taskAccountOf");
14875
14946
 
14947
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/references.js
14948
+ var SIMPLE_REFERENCES = [
14949
+ "note",
14950
+ "document",
14951
+ "person",
14952
+ "organization",
14953
+ "project",
14954
+ "task",
14955
+ "memory",
14956
+ "fact",
14957
+ "bot",
14958
+ "entity"
14959
+ ];
14960
+ var parts = /* @__PURE__ */ __name((rest, count, reference2, shape) => {
14961
+ const split = rest.split("/");
14962
+ if (split.length !== count || split.some((part) => part === ""))
14963
+ throw new CliError("validation_error", `"${singleLine(reference2)}" is not a reference \u2014 expected ${shape}`);
14964
+ return split.map(decodeURIComponent);
14965
+ }, "parts");
14966
+ var formatReference = /* @__PURE__ */ __name((reference2) => {
14967
+ switch (reference2.type) {
14968
+ case "message":
14969
+ return formatLocator(reference2);
14970
+ case "chat":
14971
+ return `chat:${[reference2.provider, reference2.account, reference2.chat].map(encodeURIComponent).join("/")}`;
14972
+ case "contact":
14973
+ return `contact:${[reference2.provider, reference2.id].map(encodeURIComponent).join("/")}`;
14974
+ case "folder":
14975
+ return reference2.path === null ? `folder:${encodeURIComponent(reference2.id)}` : `folder:${encodeURIComponent(reference2.id)}/${encodeURIComponent(reference2.path)}`;
14976
+ default:
14977
+ return `${reference2.type}:${reference2.id}`;
14978
+ }
14979
+ }, "formatReference");
14980
+ var parseReference = /* @__PURE__ */ __name((text5) => {
14981
+ const reference2 = text5.trim();
14982
+ const colon = reference2.indexOf(":");
14983
+ const prefix = colon < 0 ? "" : reference2.slice(0, colon);
14984
+ const rest = reference2.slice(colon + 1);
14985
+ switch (prefix) {
14986
+ case "msg":
14987
+ return { type: "message", ...parseLocator(reference2) };
14988
+ case "chat": {
14989
+ const [provider, account, chat2] = parts(rest, 3, reference2, "chat:<provider>/<account>/<chat>");
14990
+ return { type: "chat", provider, account, chat: chat2 };
14991
+ }
14992
+ case "contact": {
14993
+ const [provider, id2] = parts(rest, 2, reference2, "contact:<provider>/<id>");
14994
+ return { type: "contact", provider, id: id2 };
14995
+ }
14996
+ case "folder": {
14997
+ const slash = rest.indexOf("/");
14998
+ const id2 = decodeURIComponent(slash < 0 ? rest : rest.slice(0, slash));
14999
+ const path = slash < 0 ? null : folderPath(decodeURIComponent(rest.slice(slash + 1)));
15000
+ if (!id2.trim() || path === "")
15001
+ throw new CliError("validation_error", `"${singleLine(reference2)}" is not a reference \u2014 expected folder:<id>[/<path>]`);
15002
+ return { type: "folder", id: id2, path };
15003
+ }
15004
+ default:
15005
+ if (SIMPLE_REFERENCES.includes(prefix)) {
15006
+ if (!rest.trim())
15007
+ throw new CliError("validation_error", `"${singleLine(reference2)}" names no ${prefix}`);
15008
+ return { type: prefix, id: rest };
15009
+ }
15010
+ throw new CliError("validation_error", `"${singleLine(reference2)}" is not a reference \u2014 expected msg:, chat:, contact:, folder:, ${SIMPLE_REFERENCES.filter((one) => one !== "entity").join(":, ")}:`);
15011
+ }
15012
+ }, "parseReference");
15013
+ var folderPath = /* @__PURE__ */ __name((path) => {
15014
+ const clean = path.split("/").filter((part) => part !== "" && part !== ".").join("/");
15015
+ return clean === "" ? path.trim() === "" ? "" : null : clean;
15016
+ }, "folderPath");
15017
+ var canonicalReference = /* @__PURE__ */ __name((text5) => formatReference(parseReference(text5)), "canonicalReference");
15018
+
14876
15019
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
14877
15020
  var storedThing = /* @__PURE__ */ __name((type, id2) => ({ type: String(type), id: Number(id2) }), "storedThing");
14878
15021
  var REFERABLE = {
@@ -15179,7 +15322,7 @@ var setMainTopic = /* @__PURE__ */ __name((context, thing, topic2) => {
15179
15322
  var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
15180
15323
  const selectedTag = filter.tag === void 0 ? void 0 : canonicalTagNamed(database, filter.tag)?.id ?? -1;
15181
15324
  const tagged = selectedTag === void 0 ? "" : " AND t.canonical_id=(SELECT canonical_id FROM resolved_tags WHERE id=?)";
15182
- const parts = [
15325
+ const parts2 = [
15183
15326
  {
15184
15327
  type: "chat",
15185
15328
  sql: "SELECT t.name AS tag, g.taggable_type AS type, g.created_at, c.external_id AS chat_id, c.title AS chat_title, c.title_folded AS name_folded, NULL AS person_id, NULL AS name, NULL AS message_id, g.source, g.taggable_id AS target_id, t.canonical_id AS tag_id, NULL AS task_id FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id JOIN chats c ON c.id=g.taggable_id JOIN accounts a ON a.id=c.account_id WHERE g.taggable_type='chat' AND a.provider=? AND a.external_id=?",
@@ -15211,7 +15354,7 @@ var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
15211
15354
  params: [inboxKey(`${key2.provider}:${key2.account}`)]
15212
15355
  }
15213
15356
  ];
15214
- const chosen = parts.filter(({ type }) => filter.type === void 0 || filter.type === type);
15357
+ const chosen = parts2.filter(({ type }) => filter.type === void 0 || filter.type === type);
15215
15358
  const union = chosen.map(({ sql: sql2 }) => sql2 + tagged).join(" UNION ALL ");
15216
15359
  const where = [
15217
15360
  ...filter.where ? [filter.where] : [],
@@ -15248,10 +15391,10 @@ var ftsMatch = /* @__PURE__ */ __name((node) => {
15248
15391
  return words3.length > 1 ? nearMatch(words3, node.slop) : quoted(text5);
15249
15392
  }, "ftsMatch");
15250
15393
  var nearMatch = /* @__PURE__ */ __name((words3, apart) => `NEAR(${words3.map(quoted).join(" ")}, ${apart})`, "nearMatch");
15251
- var combine = /* @__PURE__ */ __name((parts, operator) => ({
15252
- sql: parts.length ? `(${parts.map(({ sql: sql2 }) => sql2).join(` ${operator} `)})` : operator === "AND" ? "1" : "0",
15253
- params: parts.flatMap(({ params }) => params),
15254
- exact: parts.every(({ exact }) => exact)
15394
+ var combine = /* @__PURE__ */ __name((parts2, operator) => ({
15395
+ sql: parts2.length ? `(${parts2.map(({ sql: sql2 }) => sql2).join(` ${operator} `)})` : operator === "AND" ? "1" : "0",
15396
+ params: parts2.flatMap(({ params }) => params),
15397
+ exact: parts2.every(({ exact }) => exact)
15255
15398
  }), "combine");
15256
15399
  var prefixOf = /* @__PURE__ */ __name((pattern) => {
15257
15400
  if (pattern.includes("|"))
@@ -15541,14 +15684,14 @@ var is2 = /* @__PURE__ */ __name(({ value }, { mail }) => {
15541
15684
  }, "is");
15542
15685
  var subject = /* @__PURE__ */ __name(({ operator, value }, { corpus, mail }) => {
15543
15686
  const wanted = normalize(value);
15544
- const parts = wanted.match(/[\p{L}\p{N}]+/gu) ?? [];
15545
- if (!mail || !parts.length)
15687
+ const parts2 = wanted.match(/[\p{L}\p{N}]+/gu) ?? [];
15688
+ if (!mail || !parts2.length)
15546
15689
  return always(bound("0"));
15547
15690
  return {
15548
- fragment: { ...wordMatch(corpus, parts.map(quoted).join(" AND ")), exact: false },
15691
+ fragment: { ...wordMatch(corpus, parts2.map(quoted).join(" AND ")), exact: false },
15549
15692
  test: /* @__PURE__ */ __name((text5) => {
15550
15693
  const heading = normalize(text5.slice(0, Math.max(0, text5.indexOf("\n\n"))));
15551
- return operator === "phrase" ? heading.includes(wanted) : parts.every((word) => new RegExp(`(^|[^\\p{L}\\p{N}])${word}`, "u").test(heading));
15694
+ return operator === "phrase" ? heading.includes(wanted) : parts2.every((word) => new RegExp(`(^|[^\\p{L}\\p{N}])${word}`, "u").test(heading));
15552
15695
  }, "test")
15553
15696
  };
15554
15697
  }, "subject");
@@ -17029,9 +17172,9 @@ var leaf = /* @__PURE__ */ __name((node, columns, options) => {
17029
17172
  return node.operator === "wildcard" ? { sql: `lower(${sql2}) LIKE ? ESCAPE '\\'`, params: [like(node.value)] } : { sql: `lower(${sql2}) = ?`, params: [node.value.toLowerCase()] };
17030
17173
  }
17031
17174
  }, "leaf");
17032
- var all = /* @__PURE__ */ __name((parts) => ({
17033
- sql: parts.map(({ sql: sql2 }) => `(${sql2})`).join(" AND "),
17034
- params: parts.flatMap(({ params }) => params)
17175
+ var all = /* @__PURE__ */ __name((parts2) => ({
17176
+ sql: parts2.map(({ sql: sql2 }) => `(${sql2})`).join(" AND "),
17177
+ params: parts2.flatMap(({ params }) => params)
17035
17178
  }), "all");
17036
17179
  var known = /* @__PURE__ */ __name((where) => where.known ? where : { sql: `IFNULL((${where.sql}), 0)`, params: where.params }, "known");
17037
17180
  var compile = /* @__PURE__ */ __name((node, columns, options) => {
@@ -17039,12 +17182,12 @@ var compile = /* @__PURE__ */ __name((node, columns, options) => {
17039
17182
  return known(leaf(node, columns, options));
17040
17183
  const of = /* @__PURE__ */ __name((occur) => node.clauses.filter((clause) => clause.occur === occur).map((clause) => compile(clause.node, columns, options)), "of");
17041
17184
  const [must, should, mustNot] = [of("must"), of("should"), of("must_not")];
17042
- const parts = [
17185
+ const parts2 = [
17043
17186
  ...must,
17044
17187
  ...must.length === 0 && should.length > 0 ? [{ sql: should.map(({ sql: sql2 }) => `(${sql2})`).join(" OR "), params: should.flatMap(({ params }) => params) }] : [],
17045
17188
  ...mustNot.map(({ sql: sql2, params }) => ({ sql: `NOT (${sql2})`, params }))
17046
17189
  ];
17047
- return all(parts);
17190
+ return all(parts2);
17048
17191
  }, "compile");
17049
17192
  var queryFilter = /* @__PURE__ */ __name((ast, columns, options = {}) => compile(ast.root, columns, options), "queryFilter");
17050
17193
  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");
@@ -17893,6 +18036,25 @@ var replaceAutoTags = /* @__PURE__ */ __name((context, key2, chatId, algorithm,
17893
18036
  }
17894
18037
  }, "replaceAutoTags");
17895
18038
 
18039
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/counters.js
18040
+ var COUNTER_FIELDS = ["views", "reactions", "comments"];
18041
+ var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
18042
+ var counterObservationTime = /* @__PURE__ */ __name((observation, now2) => {
18043
+ const at = Date.parse(observation.observedAt);
18044
+ if (!validCounter(observation.value) || !Number.isSafeInteger(at) || at < 0 || at > now2 || !["remote_fetch", "remote_update"].includes(observation.source))
18045
+ throw new CliError("validation_error", "counter observation needs a valid value, source and nonfuture observation time");
18046
+ if (observation.reactions && (!validCounter(observation.reactions.total) || observation.reactions.total !== observation.value))
18047
+ throw new CliError("validation_error", "reaction observation payload and total disagree");
18048
+ return at;
18049
+ }, "counterObservationTime");
18050
+ var counterFreshness = /* @__PURE__ */ __name((states) => {
18051
+ if (!states.length || states.every((one) => one.freshness === "unknown"))
18052
+ return "unknown";
18053
+ if (states.some((one) => one.freshness === "unknown"))
18054
+ return "partial";
18055
+ return states.some((one) => one.freshness === "stale") ? "stale" : "fresh";
18056
+ }, "counterFreshness");
18057
+
17896
18058
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
17897
18059
  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");
17898
18060
  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;
@@ -18728,7 +18890,7 @@ var HIT_FIELDS = {
18728
18890
  provider: sql`${accounts.provider}`.as("provider"),
18729
18891
  accountNativeId: sql`${accounts.externalId}`.as("account_native_id")
18730
18892
  };
18731
- var wordsOf = /* @__PURE__ */ __name((text5) => {
18893
+ var wordsOf2 = /* @__PURE__ */ __name((text5) => {
18732
18894
  const words3 = (text5.match(/[\p{L}\p{N}]+/gu) ?? []).filter((word) => [...word].length >= 3);
18733
18895
  if (words3.length === 0)
18734
18896
  throw new CliError("validation_error", "search needs a word of three letters or more");
@@ -18749,7 +18911,7 @@ var matching = /* @__PURE__ */ __name((context, { provider, account, accounts: w
18749
18911
  throw new CliError("validation_error", "a read across accounts names their provider");
18750
18912
  }
18751
18913
  const ids = senders?.length ? [...new Set(senders)] : void 0;
18752
- return and(isNull(messages.deletedAt), trimmed ? sql`${messages.id} IN (SELECT rowid FROM messages_fts WHERE messages_fts MATCH ${wordsOf(trimmed)})` : void 0, scopeProvider === void 0 ? void 0 : eq(accounts.provider, scopeProvider), account ? eq(accounts.externalId, account.account) : void 0, within ? inArray(accounts.externalId, within) : void 0, chatId === void 0 ? eq(chats.searchable, 1) : eq(chats.externalId, chatId), ids ? and(eq(identities.provider, accounts.provider), inArray(identities.externalId, ids)) : void 0, ids && together ? inArray(messages.chatId, everyoneWrote(context, ids, scopeProvider)) : void 0);
18914
+ return and(isNull(messages.deletedAt), trimmed ? sql`${messages.id} IN (SELECT rowid FROM messages_fts WHERE messages_fts MATCH ${wordsOf2(trimmed)})` : void 0, scopeProvider === void 0 ? void 0 : eq(accounts.provider, scopeProvider), account ? eq(accounts.externalId, account.account) : void 0, within ? inArray(accounts.externalId, within) : void 0, chatId === void 0 ? eq(chats.searchable, 1) : eq(chats.externalId, chatId), ids ? and(eq(identities.provider, accounts.provider), inArray(identities.externalId, ids)) : void 0, ids && together ? inArray(messages.chatId, everyoneWrote(context, ids, scopeProvider)) : void 0);
18753
18915
  }, "matching");
18754
18916
  var everyoneWrote = /* @__PURE__ */ __name(({ orm }, ids, scopeProvider) => {
18755
18917
  const written = alias(messages, "m2");
@@ -19412,7 +19574,7 @@ var knownRussianWord = /* @__PURE__ */ __name((word) => {
19412
19574
  }, "knownRussianWord");
19413
19575
 
19414
19576
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
19415
- var WORD2 = /[\p{L}\p{N}\p{M}]+/gu;
19577
+ var WORD3 = /[\p{L}\p{N}\p{M}]+/gu;
19416
19578
  var MOST_WORDS = 128;
19417
19579
  var quote = /* @__PURE__ */ __name((word) => `"${word.replaceAll('"', '""')}"`, "quote");
19418
19580
  var speakers = /* @__PURE__ */ __name((database, accountId) => {
@@ -19487,8 +19649,8 @@ ${matches2.map((speaker) => ` ${singleLine(speaker.label)}`).join("\n")}`, { ca
19487
19649
  }, "pickSpeaker");
19488
19650
  var resolveMeetingQuery = /* @__PURE__ */ __name((database, accountId, ast, state) => {
19489
19651
  const all2 = [];
19490
- const wordsOf2 = /* @__PURE__ */ __name((value, exact) => {
19491
- const words3 = (value.match(WORD2) ?? []).filter((raw) => normalize(raw)).map((raw) => {
19652
+ const wordsOf3 = /* @__PURE__ */ __name((value, exact) => {
19653
+ const words3 = (value.match(WORD3) ?? []).filter((raw) => normalize(raw)).map((raw) => {
19492
19654
  const literal4 = normalize(raw);
19493
19655
  return {
19494
19656
  raw,
@@ -19515,7 +19677,7 @@ var resolveMeetingQuery = /* @__PURE__ */ __name((database, accountId, ast, stat
19515
19677
  if (node.field === "from")
19516
19678
  return pickSpeaker(database, accountId, node.value);
19517
19679
  const exact = node.field === "exact";
19518
- const words3 = wordsOf2(node.value, exact);
19680
+ const words3 = wordsOf3(node.value, exact);
19519
19681
  if (node.operator === "phrase" && node.slop !== void 0 && words3.length > 1)
19520
19682
  return { kind: "near", exact, words: words3, lines: node.slop };
19521
19683
  return { kind: node.operator === "phrase" && words3.length > 1 ? "phrase" : "words", exact, words: words3 };
@@ -19555,8 +19717,8 @@ var meetingQuerySql = /* @__PURE__ */ __name((tree, state) => {
19555
19717
  }
19556
19718
  return `SELECT rid,min(tier) AS tier FROM (${select2}) GROUP BY rid`;
19557
19719
  }, "word");
19558
- const all2 = /* @__PURE__ */ __name((parts) => parts.length === 1 ? parts[0] : `SELECT rid,max(tier) AS tier FROM (${parts.join(" UNION ALL ")}) GROUP BY rid HAVING count(*)=${parts.length}`, "all");
19559
- const any2 = /* @__PURE__ */ __name((parts) => parts.length === 1 ? parts[0] : `SELECT rid,min(tier) AS tier FROM (${parts.join(" UNION ALL ")}) GROUP BY rid`, "any");
19720
+ const all2 = /* @__PURE__ */ __name((parts2) => parts2.length === 1 ? parts2[0] : `SELECT rid,max(tier) AS tier FROM (${parts2.join(" UNION ALL ")}) GROUP BY rid HAVING count(*)=${parts2.length}`, "all");
19721
+ const any2 = /* @__PURE__ */ __name((parts2) => parts2.length === 1 ? parts2[0] : `SELECT rid,min(tier) AS tier FROM (${parts2.join(" UNION ALL ")}) GROUP BY rid`, "any");
19560
19722
  const nothing = "SELECT NULL AS rid,0 AS tier WHERE 0";
19561
19723
  const compile2 = /* @__PURE__ */ __name((node) => {
19562
19724
  if (node.kind === "words")
@@ -20650,21 +20812,21 @@ var saveTranscripts = /* @__PURE__ */ __name((database, meetingId, transcripts,
20650
20812
  return counts;
20651
20813
  }, "saveTranscripts");
20652
20814
  var append = /* @__PURE__ */ __name((context, input) => {
20653
- const invalid8 = /* @__PURE__ */ __name((message2) => {
20815
+ const invalid10 = /* @__PURE__ */ __name((message2) => {
20654
20816
  throw new MeetingError("validation_error", message2);
20655
20817
  }, "invalid");
20656
20818
  if (!Number.isSafeInteger(input.accountId) || input.accountId <= 0 || !input.externalId?.trim() || !Number.isSafeInteger(input.now) || !Array.isArray(input.transcripts) || input.transcripts.length === 0)
20657
- invalid8("Invalid transcript append");
20819
+ invalid10("Invalid transcript append");
20658
20820
  if (input.create && (!Number.isSafeInteger(input.create.startedAt) || Math.abs(input.create.startedAt) > 864e13))
20659
- invalid8("Invalid meeting start");
20821
+ invalid10("Invalid meeting start");
20660
20822
  const sources = /* @__PURE__ */ new Set();
20661
20823
  for (const transcript2 of input.transcripts) {
20662
20824
  if (!transcript2.source?.trim() || !transcript2.contentHash?.trim() || sources.has(transcript2.source))
20663
- invalid8("Expected distinct transcript sources and nonempty hashes");
20825
+ invalid10("Expected distinct transcript sources and nonempty hashes");
20664
20826
  sources.add(transcript2.source);
20665
20827
  for (const row2 of transcript2.rows)
20666
20828
  if ("speakerParticipantPosition" in row2 || "speakerParticipantId" in row2)
20667
- invalid8("Appended transcript rows must be unlinked");
20829
+ invalid10("Appended transcript rows must be unlinked");
20668
20830
  }
20669
20831
  const { database } = context;
20670
20832
  return write(database, () => {
@@ -21592,21 +21754,21 @@ var transcriptTerms = /* @__PURE__ */ __name((database, root, item) => {
21592
21754
  return terms2;
21593
21755
  }, "transcriptTerms");
21594
21756
  var transcriptCondition = /* @__PURE__ */ __name((terms2, part = "all") => {
21595
- const parts = [];
21757
+ const parts2 = [];
21596
21758
  const words3 = /* @__PURE__ */ __name((match) => ({
21597
21759
  sql: "att.id IN (SELECT rowid FROM attachment_words WHERE attachment_words MATCH ?)",
21598
21760
  params: [match]
21599
21761
  }), "words");
21600
21762
  if (part === "all" || part === "typed")
21601
- parts.push(words3(terms2.match));
21763
+ parts2.push(words3(terms2.match));
21602
21764
  if ((part === "all" || part === "forms") && terms2.stems)
21603
- parts.push({
21765
+ parts2.push({
21604
21766
  sql: "att.id IN (SELECT rowid FROM transcript_stems WHERE transcript_stems MATCH ?)",
21605
21767
  params: [`stems : (${terms2.stems})`]
21606
21768
  });
21607
21769
  if ((part === "all" || part === "widened") && terms2.widened.length)
21608
- parts.push(words3(terms2.widened.map(quoted).join(" OR ")));
21609
- return parts.length ? { sql: `(${parts.map(({ sql: sql2 }) => sql2).join(" OR ")})`, params: parts.flatMap(({ params }) => params) } : { sql: "0", params: [] };
21770
+ parts2.push(words3(terms2.widened.map(quoted).join(" OR ")));
21771
+ return parts2.length ? { sql: `(${parts2.map(({ sql: sql2 }) => sql2).join(" OR ")})`, params: parts2.flatMap(({ params }) => params) } : { sql: "0", params: [] };
21610
21772
  }, "transcriptCondition");
21611
21773
  var transcriptItems = /* @__PURE__ */ __name((item, terms2, part) => {
21612
21774
  const condition = transcriptCondition(terms2, part);
@@ -21895,11 +22057,11 @@ var compileQuery = /* @__PURE__ */ __name((context, execution, boundedAttachment
21895
22057
  const required3 = node.clauses.filter(({ occur }) => occur === "must");
21896
22058
  const optional = node.clauses.filter(({ occur }) => occur === "should");
21897
22059
  if (required3.length) {
21898
- const parts2 = required3.flatMap(({ node: node2 }) => requiredText(node2, index2) ?? []);
21899
- return parts2.length ? parts2.map((part) => `(${part})`).join(" AND ") : void 0;
22060
+ const parts3 = required3.flatMap(({ node: node2 }) => requiredText(node2, index2) ?? []);
22061
+ return parts3.length ? parts3.map((part) => `(${part})`).join(" AND ") : void 0;
21900
22062
  }
21901
- const parts = optional.map(({ node: node2 }) => requiredText(node2, index2));
21902
- return parts.length && parts.every((part) => part !== void 0) ? parts.map((part) => `(${part})`).join(" OR ") : void 0;
22063
+ const parts2 = optional.map(({ node: node2 }) => requiredText(node2, index2));
22064
+ return parts2.length && parts2.every((part) => part !== void 0) ? parts2.map((part) => `(${part})`).join(" OR ") : void 0;
21903
22065
  }, "requiredText");
21904
22066
  const stemmed = [...fragments.keys()].some(isStemmed);
21905
22067
  const elsewhere = [...fragments.values()].some(({ fragment }) => fragment.elsewhere);
@@ -21922,10 +22084,10 @@ var compileQuery = /* @__PURE__ */ __name((context, execution, boundedAttachment
21922
22084
  }
21923
22085
  const required3 = node.clauses.filter(({ occur }) => occur === "must");
21924
22086
  const optional = node.clauses.filter(({ occur }) => occur === "should");
21925
- const parts = required3.length ? required3.flatMap(({ node: node2 }) => driverOf(node2) ?? []) : optional.map(({ node: node2 }) => driverOf(node2));
21926
- if (!parts.length || parts.some((part) => part === void 0))
22087
+ const parts2 = required3.length ? required3.flatMap(({ node: node2 }) => driverOf(node2) ?? []) : optional.map(({ node: node2 }) => driverOf(node2));
22088
+ if (!parts2.length || parts2.some((part) => part === void 0))
21927
22089
  return void 0;
21928
- const sets = parts;
22090
+ const sets = parts2;
21929
22091
  return {
21930
22092
  sql: sets.map(({ sql: sql2 }) => `SELECT id FROM (${sql2})`).join(required3.length ? " INTERSECT " : " UNION "),
21931
22093
  params: sets.flatMap(({ params }) => params)
@@ -21960,9 +22122,9 @@ var compileQuery = /* @__PURE__ */ __name((context, execution, boundedAttachment
21960
22122
  const one = said(node, part);
21961
22123
  return { sql: `SELECT attachable_id, ${tier} FROM (${one.sql})`, params: one.params };
21962
22124
  }), "spoken");
21963
- const parts = [...spoken("forms", 2), ...spoken("widened", 5)];
21964
- ranked.sql.push(`s(id, tier) AS MATERIALIZED (SELECT att.attachable_id, min(CASE WHEN ${SPEECH} THEN 1 ELSE 4 END) FROM attachments att WHERE att.attachable_type='${corpus.item}' AND att.id IN (SELECT rowid FROM attachment_words WHERE attachment_words MATCH ?) GROUP BY att.attachable_id UNION ALL SELECT attachable_id, 3 FROM (${namedSql})${parts.map(({ sql: sql2 }) => ` UNION ALL ${sql2}`).join("")})`);
21965
- ranked.params.push(places2.join(" OR "), places2.join(" OR "), ...parts.flatMap(({ params }) => params));
22125
+ const parts2 = [...spoken("forms", 2), ...spoken("widened", 5)];
22126
+ ranked.sql.push(`s(id, tier) AS MATERIALIZED (SELECT att.attachable_id, min(CASE WHEN ${SPEECH} THEN 1 ELSE 4 END) FROM attachments att WHERE att.attachable_type='${corpus.item}' AND att.id IN (SELECT rowid FROM attachment_words WHERE attachment_words MATCH ?) GROUP BY att.attachable_id UNION ALL SELECT attachable_id, 3 FROM (${namedSql})${parts2.map(({ sql: sql2 }) => ` UNION ALL ${sql2}`).join("")})`);
22127
+ ranked.params.push(places2.join(" OR "), places2.join(" OR "), ...parts2.flatMap(({ params }) => params));
21966
22128
  }
21967
22129
  const placeTier = places2.length && !execution.newest ? "coalesce((SELECT min(tier) FROM s WHERE s.id=m.id), 6)," : "";
21968
22130
  if (exactTier) {
@@ -23817,8 +23979,8 @@ var notesStoreOver = /* @__PURE__ */ __name((context) => {
23817
23979
  const candidates = !found2 && !place && localSave(folder, input.frontMatter) ? sameContent(hash2, text5) : [];
23818
23980
  if (candidates.length === 1) {
23819
23981
  const id3 = candidates[0];
23820
- const joined3 = documentRow(String(id3));
23821
- if (joined3.deleted_at != null)
23982
+ const joined4 = documentRow(String(id3));
23983
+ if (joined4.deleted_at != null)
23822
23984
  database.prepare("UPDATE documents SET deleted_at = NULL, body = ?, updated_at = ? WHERE id = ?").run(text5, at, id3);
23823
23985
  syncFile(database, at, id3, { place: here, method: "content-hash" });
23824
23986
  followPreferred(id3, at);
@@ -26803,6 +26965,146 @@ import { createHash as createHash8 } from "node:crypto";
26803
26965
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
26804
26966
  import { createHash as createHash7 } from "node:crypto";
26805
26967
 
26968
+ // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
26969
+ var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
26970
+ var AUTHOR_MEASURES = [
26971
+ "messages",
26972
+ "words",
26973
+ "reactions",
26974
+ "replies",
26975
+ "answers",
26976
+ "answer-time",
26977
+ "threads",
26978
+ "active-days"
26979
+ ];
26980
+ var CONTEXT = /* @__PURE__ */ new Set([
26981
+ "replies",
26982
+ "replies-from-others",
26983
+ "replies-from-others-per-message",
26984
+ "thread-size",
26985
+ "threads",
26986
+ "answers",
26987
+ "answer-time"
26988
+ ]);
26989
+ var needsRankingContext = /* @__PURE__ */ __name((options) => options.components.some((name) => CONTEXT.has(name)), "needsRankingContext");
26990
+ var presets = {
26991
+ helpful: { answers: 0.5, "replies-from-others": 0.25, reactions: 0.25 },
26992
+ active: { "active-days": 0.6, messages: 0.4 },
26993
+ engaging: { "reactions-per-message": 0.5, "replies-from-others-per-message": 0.5 }
26994
+ };
26995
+ function invalid3(message2) {
26996
+ throw new CliError("validation_error", message2, { reason: "ranking.invalid" });
26997
+ }
26998
+ __name(invalid3, "invalid");
26999
+ var rankingOptions = /* @__PURE__ */ __name((target, input) => {
27000
+ const measures = target === "messages" ? MESSAGE_MEASURES : AUTHOR_MEASURES;
27001
+ const { measure, score, weights: given, minMessages } = input;
27002
+ const messageKind = input.messageKind ?? "all";
27003
+ if (!["all", "posts", "comments"].includes(messageKind))
27004
+ invalid3("message_kind takes all, posts or comments");
27005
+ if (target === "messages" && minMessages !== void 0)
27006
+ invalid3("min_messages applies to stats contacts top");
27007
+ if (minMessages !== void 0 && (!Number.isSafeInteger(minMessages) || minMessages < 1))
27008
+ invalid3("min_messages takes a positive integer");
27009
+ if (measure !== void 0 && !measures.includes(measure))
27010
+ invalid3(`--measure takes ${measures.join(", ")}`);
27011
+ if (measure !== void 0 && (score !== void 0 || given !== void 0))
27012
+ invalid3("--measure cannot be combined with --score or --weights");
27013
+ if (score !== void 0 && !["helpful", "active", "engaging"].includes(score))
27014
+ invalid3("--score takes helpful, active or engaging");
27015
+ if (target === "messages" && score !== void 0 && score !== "engaging")
27016
+ invalid3("helpful and active scores apply to authors only");
27017
+ const scoring = score !== void 0 || given !== void 0;
27018
+ const preset2 = score;
27019
+ let weights = null;
27020
+ if (scoring) {
27021
+ let raw = given !== void 0 ? given : target === "messages" ? { reactions: 0.5, "replies-from-others": 0.5 } : presets[preset2];
27022
+ if (typeof raw === "string") {
27023
+ try {
27024
+ raw = JSON.parse(raw);
27025
+ } catch {
27026
+ invalid3("--weights takes a JSON object of component weights");
27027
+ }
27028
+ }
27029
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
27030
+ invalid3("--weights takes a JSON object of component weights");
27031
+ const allowed = target === "messages" ? [...MESSAGE_MEASURES, "replies-from-others"] : [
27032
+ ...AUTHOR_MEASURES.filter((name) => name !== "answer-time"),
27033
+ "replies-from-others",
27034
+ "reactions-per-message",
27035
+ "replies-from-others-per-message"
27036
+ ];
27037
+ const entries = Object.entries(raw);
27038
+ for (const [name, weight] of entries) {
27039
+ if (!allowed.includes(name))
27040
+ invalid3(`unknown ${target} score component: ${name}`);
27041
+ if (typeof weight !== "number" || !Number.isFinite(weight) || weight < 0)
27042
+ invalid3(`weight for ${name} must be a finite nonnegative number`);
27043
+ }
27044
+ if (!entries.some(([, weight]) => weight > 0))
27045
+ invalid3("--weights needs at least one positive weight");
27046
+ weights = Object.fromEntries(entries);
27047
+ }
27048
+ const selected = measure ?? (target === "messages" ? "reactions" : "messages");
27049
+ return {
27050
+ target,
27051
+ messageKind,
27052
+ minMessages: minMessages ?? (target === "contacts" && score === "engaging" ? 5 : 1),
27053
+ measure: scoring ? "score" : selected,
27054
+ order: !scoring && selected === "answer-time" ? "ascending" : "descending",
27055
+ weights,
27056
+ preset: scoring ? preset2 ?? "custom" : null,
27057
+ components: weights === null ? [selected] : Object.entries(weights).filter(([, weight]) => weight > 0).map(([name]) => name)
27058
+ };
27059
+ }, "rankingOptions");
27060
+ var rankingScore = /* @__PURE__ */ __name((raw, maxima, weights) => {
27061
+ const entries = Object.entries(weights).filter(([, weight]) => weight > 0);
27062
+ const scale = Math.max(...entries.map(([, weight]) => weight));
27063
+ const denominator = entries.reduce((sum2, [, weight]) => sum2 + weight / scale, 0);
27064
+ if (!Number.isFinite(scale) || scale <= 0 || !Number.isFinite(denominator) || denominator <= 0)
27065
+ return null;
27066
+ const normalized = {};
27067
+ const contributions = {};
27068
+ let sum = 0;
27069
+ for (const [name, weight] of entries) {
27070
+ const value = raw[name];
27071
+ const maximum = maxima[name];
27072
+ if (value == null || !Number.isFinite(value) || value < 0 || maximum === void 0 || !Number.isFinite(maximum) || maximum < value)
27073
+ return null;
27074
+ const part = maximum === 0 ? 0 : value / maximum;
27075
+ normalized[name] = part;
27076
+ contributions[name] = 100 * part * (weight / scale) / denominator;
27077
+ sum += contributions[name];
27078
+ }
27079
+ return { score: Math.min(100, sum), normalized, contributions };
27080
+ }, "rankingScore");
27081
+ var RANKING_TOKENIZER_VERSION = 1;
27082
+ var withoutUrls = /* @__PURE__ */ __name((text5) => text5.replace(/\S+/gu, (token) => {
27083
+ for (let offset = 0; ; ) {
27084
+ const marker = token.indexOf("://", offset);
27085
+ if (marker < 0)
27086
+ break;
27087
+ let start = marker;
27088
+ while (start > 0 && /[a-z0-9+.-]/iu.test(token[start - 1]))
27089
+ start--;
27090
+ if (/^[a-z][a-z0-9+.-]*$/iu.test(token.slice(start, marker)) && (start === 0 || !/\w/u.test(token[start - 1])))
27091
+ return token.slice(0, start);
27092
+ offset = marker + 3;
27093
+ }
27094
+ const folded5 = token.toLowerCase();
27095
+ for (let offset = 0; ; ) {
27096
+ const start = folded5.indexOf("www.", offset);
27097
+ if (start < 0)
27098
+ break;
27099
+ if (start === 0 || !/\w/u.test(token[start - 1]))
27100
+ return token.slice(0, start);
27101
+ offset = start + 4;
27102
+ }
27103
+ return token;
27104
+ }), "withoutUrls");
27105
+ var rankingWords = /* @__PURE__ */ __name((text5) => withoutUrls(text5).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
27106
+ var rankingQuestion = /* @__PURE__ */ __name((text5) => withoutUrls(text5).includes("?"), "rankingQuestion");
27107
+
26806
27108
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
26807
27109
  var RANKING_GRAPH_LIMITS = { nodes: 5e4, depth: 256, work: 1e7, bytes: 8388608 };
26808
27110
  var exhausted2 = /* @__PURE__ */ __name((budget) => {
@@ -27271,7 +27573,7 @@ var periodOf = /* @__PURE__ */ __name((range) => {
27271
27573
  }
27272
27574
  return { sql: clauses.join(" AND ") || "1", params };
27273
27575
  }, "periodOf");
27274
- var joined = "FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id LEFT JOIN identities i ON i.id=m.sender_identity_id";
27576
+ var joined2 = "FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id LEFT JOIN identities i ON i.id=m.sender_identity_id";
27275
27577
  var graphColumns = `m.id AS pk,m.external_id AS id,c.external_id AS chat,ac.provider,ac.external_id AS account,c.kind,
27276
27578
  coalesce(i.external_id,m.sender_chat_external_id) AS sender,m.sender_chat_external_id IS NOT NULL AS sender_chat,
27277
27579
  m.sent_at AS at,${metadata2("m")} AS metadata`;
@@ -27283,11 +27585,11 @@ var graphIn = /* @__PURE__ */ __name((context, execution, request, check3) => {
27283
27585
  const params = [...scope3.params, ...period.params];
27284
27586
  const questions = request.options.components.some((name) => ["answers", "answer-time"].includes(name));
27285
27587
  const body2 = questions ? "m.text" : "''";
27286
- const size2 = database.prepare(`SELECT count(*) AS n,sum(length(cast(${body2} AS BLOB))+length(cast(${metadata2("m")} AS BLOB))) AS bytes ${joined} WHERE ${where}`).get(...params);
27588
+ const size2 = database.prepare(`SELECT count(*) AS n,sum(length(cast(${body2} AS BLOB))+length(cast(${metadata2("m")} AS BLOB))) AS bytes ${joined2} WHERE ${where}`).get(...params);
27287
27589
  check3();
27288
27590
  if (Number(size2?.n ?? 0) > RANKING_GRAPH_LIMITS.nodes || Number(size2?.bytes ?? 0) > RANKING_GRAPH_LIMITS.bytes)
27289
27591
  throw new CliError("validation_error", "ranking reply context exceeds its node or byte budget \u2014 narrow chat/date scope", { reason: "query.too-large", budget: "reply context", complete: false });
27290
- const rows = database.prepare(`SELECT ${graphColumns},${body2} AS text,(${period.sql}) AS event,m.id IN (SELECT id FROM ranking_selected) AS selected ${joined} WHERE ${where}`).all(...period.params, ...params);
27592
+ const rows = database.prepare(`SELECT ${graphColumns},${body2} AS text,(${period.sql}) AS event,m.id IN (SELECT id FROM ranking_selected) AS selected ${joined2} WHERE ${where}`).all(...period.params, ...params);
27291
27593
  const nodes = [];
27292
27594
  const keys = /* @__PURE__ */ new Set();
27293
27595
  const key2 = /* @__PURE__ */ __name((provider, account, chat2, id2) => JSON.stringify([provider, account, chat2, id2]), "key");
@@ -27323,7 +27625,7 @@ var graphIn = /* @__PURE__ */ __name((context, execution, request, check3) => {
27323
27625
  for (const row2 of rows)
27324
27626
  add(row2);
27325
27627
  const missing4 = /* @__PURE__ */ new Set();
27326
- const parentQuery = database.prepare(`SELECT ${graphColumns} ${joined} WHERE m.deleted_at IS NULL AND ${scope3.sql} AND ac.provider=? AND ac.external_id=? AND c.external_id=? AND m.external_id=?`);
27628
+ const parentQuery = database.prepare(`SELECT ${graphColumns} ${joined2} WHERE m.deleted_at IS NULL AND ${scope3.sql} AND ac.provider=? AND ac.external_id=? AND c.external_id=? AND m.external_id=?`);
27327
27629
  for (let index2 = 0; index2 < nodes.length; index2++) {
27328
27630
  check3();
27329
27631
  const node = nodes[index2];
@@ -27405,8 +27707,8 @@ var rankQuery = /* @__PURE__ */ __name((context, execution, request, inspect) =>
27405
27707
  check3();
27406
27708
  for (const row2 of rows2) {
27407
27709
  check3();
27408
- const parts = format ? Object.fromEntries(format.formatToParts(Number(row2.sent_at)).map(({ type, value }) => [type, value])) : void 0;
27409
- update.run(words3 ? rankingWords(String(row2.text)) : null, parts ? `${parts.year}-${parts.month}-${parts.day}` : null, Number(row2.pk));
27710
+ const parts2 = format ? Object.fromEntries(format.formatToParts(Number(row2.sent_at)).map(({ type, value }) => [type, value])) : void 0;
27711
+ update.run(words3 ? rankingWords(String(row2.text)) : null, parts2 ? `${parts2.year}-${parts2.month}-${parts2.day}` : null, Number(row2.pk));
27410
27712
  }
27411
27713
  after2 = Number(rows2.at(-1)?.pk);
27412
27714
  }
@@ -27521,13 +27823,13 @@ function fail4(message2, reason = "query.too-large") {
27521
27823
  throw new CliError("validation_error", message2, { reason, complete: false });
27522
27824
  }
27523
27825
  __name(fail4, "fail");
27524
- var joined2 = "FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id LEFT JOIN identities i ON i.id=m.sender_identity_id";
27826
+ var joined3 = "FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id LEFT JOIN identities i ON i.id=m.sender_identity_id";
27525
27827
  var attachmentSnapshot = `(SELECT json_group_array(json_object('position',position,'kind',kind,'mime',mime,'name',name,'title',title,'url',url,'size',size,'width',width,'height',height,'duration',duration,'localPath',local_path)) FROM attachments WHERE attachable_type='message' AND attachable_id=m.id)`;
27526
27828
  var snapshot = `json_object('edited',m.edited_at,'senderName',m.sender_name,'reply',m.reply_to,'forward',m.forward,'reactions',m.reactions,'outgoing',m.outgoing,'thread',m.thread_external_id,'attachments',${attachmentSnapshot},'counterObservations',(SELECT json_group_array(json_object('counter',counter,'value',value,'at',created_at,'source',source)) FROM message_counter_observations WHERE message_id=m.id))`;
27527
27829
  var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request) => withQuerySelection(context, execution, (selection, check3) => {
27528
27830
  const { database } = context, { options } = request;
27529
27831
  const prefix = `WITH selected AS (${selection.sql}) `;
27530
- const root = database.prepare(`${prefix}SELECT min(m.sent_at) AS oldest,count(*) AS total ${joined2} WHERE m.id IN (SELECT id FROM selected)`).get(...selection.params);
27832
+ const root = database.prepare(`${prefix}SELECT min(m.sent_at) AS oldest,count(*) AS total ${joined3} WHERE m.id IN (SELECT id FROM selected)`).get(...selection.params);
27531
27833
  const lower = options.report === "newcomers" ? options.joinSince : Number(root?.oldest ?? options.cutoff);
27532
27834
  const params = execution.accounts.flatMap((account) => [account.provider, account.account]);
27533
27835
  let scope3 = `(${execution.accounts.map(() => "(ac.provider=? AND ac.external_id=?)").join(" OR ") || "0"})`;
@@ -27538,11 +27840,11 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
27538
27840
  scope3 += " AND c.searchable=1";
27539
27841
  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)"})`;
27540
27842
  const bound4 = [...selection.params, ...params, lower, options.cutoff];
27541
- 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 ${joined2} WHERE ${where}`).get(...bound4);
27843
+ 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);
27542
27844
  check3();
27543
27845
  if (Number(size2?.n ?? 0) > RANKING_GRAPH_LIMITS.nodes || Number(size2?.bytes ?? 0) > RANKING_GRAPH_LIMITS.bytes)
27544
27846
  fail4("admin statistics context exceeds node/byte budgets \u2014 narrow chat/date scope");
27545
- 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 ${joined2} WHERE ${where} ORDER BY m.id`).all(...bound4);
27847
+ 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);
27546
27848
  const nodes = raw.map((row2) => {
27547
27849
  let metadata3 = {};
27548
27850
  try {
@@ -30157,10 +30459,10 @@ var NOTE_FIELDS = [
30157
30459
  ];
30158
30460
  var quoted2 = /* @__PURE__ */ __name((value) => `"${value.replaceAll('"', '""')}"`, "quoted");
30159
30461
  var bound3 = /* @__PURE__ */ __name((sql2, ...params) => ({ sql: sql2, params, exact: true }), "bound");
30160
- var combine2 = /* @__PURE__ */ __name((parts, operator) => ({
30161
- sql: parts.length ? `(${parts.map(({ sql: sql2 }) => sql2).join(` ${operator} `)})` : operator === "AND" ? "1" : "0",
30162
- params: parts.flatMap(({ params }) => params),
30163
- exact: parts.every(({ exact }) => exact)
30462
+ var combine2 = /* @__PURE__ */ __name((parts2, operator) => ({
30463
+ sql: parts2.length ? `(${parts2.map(({ sql: sql2 }) => sql2).join(` ${operator} `)})` : operator === "AND" ? "1" : "0",
30464
+ params: parts2.flatMap(({ params }) => params),
30465
+ exact: parts2.every(({ exact }) => exact)
30164
30466
  }), "combine");
30165
30467
  var CORPORA2 = [
30166
30468
  {
@@ -30339,22 +30641,22 @@ var searchCorpus = /* @__PURE__ */ __name((context, query, corpus) => {
30339
30641
  fragments.set(node, wrapped);
30340
30642
  return wrapped;
30341
30643
  }
30342
- const parts = node.clauses.map(({ occur, node: node2 }) => ({ occur, part: compile2(node2) }));
30343
- const must = parts.filter(({ occur }) => occur === "must").map(({ part }) => part);
30344
- const should = parts.filter(({ occur }) => occur === "should").map(({ part }) => part);
30345
- const not = parts.filter(({ occur }) => occur === "must_not").map(({ part }) => part.exact ? { ...part, sql: `NOT coalesce(${part.sql},0)` } : { sql: "1", params: [], exact: false });
30644
+ const parts2 = node.clauses.map(({ occur, node: node2 }) => ({ occur, part: compile2(node2) }));
30645
+ const must = parts2.filter(({ occur }) => occur === "must").map(({ part }) => part);
30646
+ const should = parts2.filter(({ occur }) => occur === "should").map(({ part }) => part);
30647
+ const not = parts2.filter(({ occur }) => occur === "must_not").map(({ part }) => part.exact ? { ...part, sql: `NOT coalesce(${part.sql},0)` } : { sql: "1", params: [], exact: false });
30346
30648
  return combine2([must.length ? combine2(must, "AND") : combine2(should, "OR"), ...not], "AND");
30347
30649
  }, "compile");
30348
30650
  const required3 = /* @__PURE__ */ __name((node, index2) => {
30349
30651
  if (node.kind === "predicate")
30350
30652
  return fragments.get(node)?.[index2];
30351
30653
  const must = node.clauses.filter(({ occur }) => occur === "must");
30352
- const parts = (must.length ? must : node.clauses.filter(({ occur }) => occur === "should")).map(({ node: node2 }) => required3(node2, index2));
30654
+ const parts2 = (must.length ? must : node.clauses.filter(({ occur }) => occur === "should")).map(({ node: node2 }) => required3(node2, index2));
30353
30655
  if (must.length) {
30354
- const known2 = parts.filter((part) => part !== void 0);
30656
+ const known2 = parts2.filter((part) => part !== void 0);
30355
30657
  return known2.length ? known2.map((part) => `(${part})`).join(" AND ") : void 0;
30356
30658
  }
30357
- return parts.length && parts.every((part) => part !== void 0) ? parts.map((part) => `(${part})`).join(" OR ") : void 0;
30659
+ return parts2.length && parts2.every((part) => part !== void 0) ? parts2.map((part) => `(${part})`).join(" OR ") : void 0;
30358
30660
  }, "required");
30359
30661
  return read(database, () => {
30360
30662
  check3();
@@ -30875,12 +31177,12 @@ var factsStoreOver = /* @__PURE__ */ __name((context) => {
30875
31177
  }, "factsStoreOver");
30876
31178
 
30877
31179
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
30878
- var invalid2 = /* @__PURE__ */ __name((message2) => {
31180
+ var invalid4 = /* @__PURE__ */ __name((message2) => {
30879
31181
  throw new CliError("validation_error", message2);
30880
31182
  }, "invalid");
30881
31183
  var findingsAgent = /* @__PURE__ */ __name((agent) => {
30882
31184
  if (!agent || typeof agent.bot !== "string" || !agent.bot.trim() || agent.bot.length > 200 || agent.bot === "owner" || agent.model !== void 0 && (typeof agent.model !== "string" || agent.model.length > 200))
30883
- return invalid2("findings must name an agent author independently of their payload");
31185
+ return invalid4("findings must name an agent author independently of their payload");
30884
31186
  return { bot: agent.bot, ...agent.model === void 0 ? {} : { model: agent.model } };
30885
31187
  }, "findingsAgent");
30886
31188
  var findingsCoreOver = /* @__PURE__ */ __name((context, kind3) => {
@@ -30892,7 +31194,7 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind3) => {
30892
31194
  for (const finding of input.findings) {
30893
31195
  const project = requiredThing(database, finding.project, "the project");
30894
31196
  if (project.type !== "project")
30895
- return invalid2("a finding needs an owner project");
31197
+ return invalid4("a finding needs an owner project");
30896
31198
  const projectRow = database.prepare("SELECT id,key,name,description,type,scope,updated_at FROM projects WHERE id=? AND account_id IS NULL AND deleted_at IS NULL").get(project.id);
30897
31199
  if (!projectRow)
30898
31200
  throw new CliError("not_found", "the owner project is unavailable");
@@ -30900,7 +31202,7 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind3) => {
30900
31202
  if (finding.kind === "task" && finding.assignee) {
30901
31203
  const person2 = requiredThing(database, finding.assignee, "the assignee");
30902
31204
  if (person2.type !== "person")
30903
- return invalid2("the assignee must be a stored person");
31205
+ return invalid4("the assignee must be a stored person");
30904
31206
  const personRow = database.prepare("SELECT id,name,updated_at FROM persons WHERE id=?").get(person2.id);
30905
31207
  if (!personRow)
30906
31208
  throw new CliError("not_found", "the assignee is unavailable");
@@ -30949,7 +31251,7 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind3) => {
30949
31251
  const prior = previous(account, fingerprint2);
30950
31252
  if (prior) {
30951
31253
  if (accepted.includes(finding.id) && prior.status === "rejected")
30952
- return invalid2("this unchanged finding was already rejected; changed evidence needs a new candidate");
31254
+ return invalid4("this unchanged finding was already rejected; changed evidence needs a new candidate");
30953
31255
  return { ...prior, id: finding.id, reused: true };
30954
31256
  }
30955
31257
  const status = accepted.includes(finding.id) ? "accepted" : "rejected";
@@ -31116,7 +31418,7 @@ var stale = /* @__PURE__ */ __name(() => {
31116
31418
  reason: "evidence-findings.stale"
31117
31419
  });
31118
31420
  }, "stale");
31119
- var invalid3 = /* @__PURE__ */ __name((message2) => {
31421
+ var invalid5 = /* @__PURE__ */ __name((message2) => {
31120
31422
  throw new CliError("validation_error", message2);
31121
31423
  }, "invalid");
31122
31424
  var TEXT_BUDGET = 262144;
@@ -31126,18 +31428,18 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31126
31428
  const core = findingsCoreOver(context, EVIDENCE_FINDINGS_KIND);
31127
31429
  const load = /* @__PURE__ */ __name((id2) => {
31128
31430
  if (typeof id2 !== "string" || !/^[1-9]\d*$/.test(id2) || !Number.isSafeInteger(Number(id2)))
31129
- return invalid3("a findings batch needs a stored ID");
31431
+ return invalid5("a findings batch needs a stored ID");
31130
31432
  const row2 = database.prepare("SELECT length(CAST(payload AS BLOB)) AS bytes,length(CAST(result AS BLOB)) AS result_bytes FROM proposed_actions WHERE id=? AND account_id IS NULL AND kind=?").get(Number(id2), EVIDENCE_FINDINGS_KIND);
31131
31433
  if (!row2)
31132
31434
  throw new CliError("not_found", "the evidence findings batch is unavailable");
31133
31435
  if (Number(row2.bytes) > 1e5 || Number(row2.result_bytes) > 65536)
31134
- return invalid3("stored findings exceed the read budget");
31436
+ return invalid5("stored findings exceed the read budget");
31135
31437
  return proposals.get(id2);
31136
31438
  }, "load");
31137
31439
  const view = /* @__PURE__ */ __name((proposal) => {
31138
31440
  const input = proposal.payload;
31139
31441
  if (!input || !proposal.target || !["proposed", "approved"].includes(proposal.status))
31140
- return invalid3("invalid stored findings batch");
31442
+ return invalid5("invalid stored findings batch");
31141
31443
  return {
31142
31444
  id: proposal.id,
31143
31445
  project: proposal.target,
@@ -31167,7 +31469,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31167
31469
  return stale();
31168
31470
  readBytes += Buffer.byteLength(record4.text) + Buffer.byteLength(record4.title ?? "");
31169
31471
  if (readBytes > TEXT_BUDGET)
31170
- return invalid3(`finding evidence exceeds the ${TEXT_BUDGET}-byte stored text budget`);
31472
+ return invalid5(`finding evidence exceeds the ${TEXT_BUDGET}-byte stored text budget`);
31171
31473
  const fingerprint2 = contextEvidenceFingerprint(record4);
31172
31474
  if (fingerprint2 !== evidence.fingerprint)
31173
31475
  return stale();
@@ -31184,7 +31486,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31184
31486
  ...raw.model === void 0 ? {} : { model: raw.model }
31185
31487
  });
31186
31488
  if (typeof raw.reason !== "string" || !raw.reason.trim() || raw.reason.length > 2e3)
31187
- return invalid3("an agent deciding for the owner gives a reason of 1\u20132000 characters");
31489
+ return invalid5("an agent deciding for the owner gives a reason of 1\u20132000 characters");
31188
31490
  return {
31189
31491
  author: agent,
31190
31492
  decision: { by: "agent", bot: agent.bot, model: agent.model ?? null, reason: raw.reason.trim() }
@@ -31195,7 +31497,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31195
31497
  const input = validateEvidenceFindings(raw);
31196
31498
  const projects2 = new Set(input.findings.map((finding) => finding.project));
31197
31499
  if (projects2.size !== 1)
31198
- return invalid3("an evidence findings batch is about one project");
31500
+ return invalid5("an evidence findings batch is about one project");
31199
31501
  const by = findingsAgent(rawAgent);
31200
31502
  return write(database, () => {
31201
31503
  const { actor } = authorActor(context, by);
@@ -31204,14 +31506,14 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31204
31506
  if (held) {
31205
31507
  const proposal = load(String(held.id));
31206
31508
  if (proposal.payload.inputHash !== inputHash)
31207
- return invalid3("the findings batch key was already used for different input");
31509
+ return invalid5("the findings batch key was already used for different input");
31208
31510
  return view(proposal);
31209
31511
  }
31210
31512
  const snapshotHash = snapshot2(input);
31211
31513
  const snapshotParts = core.snapshotParts(input, cite());
31212
31514
  const fingerprints = input.findings.map(findingFingerprint);
31213
31515
  if (new Set(fingerprints).size !== fingerprints.length)
31214
- return invalid3("the batch contains duplicate findings");
31516
+ return invalid5("the batch contains duplicate findings");
31215
31517
  return view(proposals.propose({
31216
31518
  kind: EVIDENCE_FINDINGS_KIND,
31217
31519
  by,
@@ -31223,12 +31525,12 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31223
31525
  get: /* @__PURE__ */ __name(async (id2) => view(load(id2)), "get"),
31224
31526
  list: /* @__PURE__ */ __name(async ({ project, limit = 20, offset = 0, status } = {}) => {
31225
31527
  if (status !== void 0 && status !== "proposed" && status !== "reviewed")
31226
- return invalid3("finding status is proposed or reviewed");
31528
+ return invalid5("finding status is proposed or reviewed");
31227
31529
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50 || !Number.isSafeInteger(offset) || offset < 0)
31228
- return invalid3("findings lists take 1\u201350 items and a nonnegative offset");
31530
+ return invalid5("findings lists take 1\u201350 items and a nonnegative offset");
31229
31531
  const projectId = project === void 0 ? null : /^project:([1-9]\d*)$/.exec(project)?.[1];
31230
31532
  if (projectId === void 0)
31231
- return invalid3("a findings list filters by a project reference");
31533
+ return invalid5("a findings list filters by a project reference");
31232
31534
  const ids = database.prepare("SELECT id FROM proposed_actions WHERE account_id IS NULL AND kind=? AND (? IS NULL OR (target_type='project' AND target_id=?)) AND (? IS NULL OR status=?) ORDER BY id DESC LIMIT ? OFFSET ?").all(EVIDENCE_FINDINGS_KIND, projectId, projectId === null ? null : Number(projectId), status ?? null, status === "reviewed" ? "approved" : status ?? null, limit + 1, offset);
31233
31535
  return { items: ids.slice(0, limit).map((row2) => view(load(String(row2.id)))), hasMore: ids.length > limit };
31234
31536
  }, "list"),
@@ -31238,29 +31540,29 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
31238
31540
  if (!decision || typeof decision.fingerprint !== "string" || decision.fingerprint !== batch.fingerprint)
31239
31541
  return stale();
31240
31542
  if (!Array.isArray(decision.accept) || decision.accept.length > 16 || new Set(decision.accept).size !== decision.accept.length || decision.accept.some((candidate) => !batch.input.findings.some((finding) => finding.id === candidate)))
31241
- return invalid3("accept only unique IDs shown in this batch");
31543
+ return invalid5("accept only unique IDs shown in this batch");
31242
31544
  const accepted = [...decision.accept].sort();
31243
31545
  const { author, decision: decidedBy } = decider(decision.by);
31244
31546
  if (batch.receipt) {
31245
31547
  if (JSON.stringify(batch.receipt.accepted) !== JSON.stringify(accepted))
31246
- return invalid3("this findings batch was already reviewed with a different decision");
31548
+ return invalid5("this findings batch was already reviewed with a different decision");
31247
31549
  return batch;
31248
31550
  }
31249
31551
  const input = proposal.payload;
31250
31552
  if (accepted.length) {
31251
- const parts = input.snapshotParts;
31252
- if (!parts) {
31553
+ const parts2 = input.snapshotParts;
31554
+ if (!parts2) {
31253
31555
  if (snapshot2(batch.input) !== input.snapshotHash)
31254
31556
  return stale();
31255
31557
  } else {
31256
31558
  const chosen = { ...batch.input, findings: batch.input.findings.filter((f) => accepted.includes(f.id)) };
31257
31559
  const now2 = core.snapshotParts(chosen, cite());
31258
- if (Object.entries(now2).some(([key2, hash2]) => parts[key2] !== hash2))
31560
+ if (Object.entries(now2).some(([key2, hash2]) => parts2[key2] !== hash2))
31259
31561
  return stale();
31260
31562
  }
31261
31563
  }
31262
31564
  if (proposal.proposedBy.type !== "bot" || !proposal.proposedBy.name)
31263
- return invalid3("a findings author must be an agent");
31565
+ return invalid5("a findings author must be an agent");
31264
31566
  const agent = {
31265
31567
  bot: proposal.proposedBy.name,
31266
31568
  ...input.agentModel === null ? {} : { model: input.agentModel }
@@ -31808,16 +32110,16 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
31808
32110
  const expected = options.expectedFingerprint;
31809
32111
  if (expected !== void 0 && typeof expected !== "string")
31810
32112
  throw new CliError("validation_error", "invalid vocabulary preview fingerprint");
31811
- const parts = expected?.match(/^v1:(all|project|tag|topic):(all|personal|work):[a-f0-9]{64}$/);
31812
- if (expected !== void 0 && !parts)
32113
+ const parts2 = expected?.match(/^v1:(all|project|tag|topic):(all|personal|work):[a-f0-9]{64}$/);
32114
+ if (expected !== void 0 && !parts2)
31813
32115
  throw new CliError("validation_error", "invalid vocabulary preview fingerprint");
31814
32116
  const current = catalog({
31815
- ...parts?.[1] && parts[1] !== "all" ? { kind: parts[1] } : {},
31816
- ...parts?.[2] && parts[2] !== "all" ? { scope: parts[2] } : {}
32117
+ ...parts2?.[1] && parts2[1] !== "all" ? { kind: parts2[1] } : {},
32118
+ ...parts2?.[2] && parts2[2] !== "all" ? { scope: parts2[2] } : {}
31817
32119
  });
31818
32120
  if (expected !== void 0 && expected !== current.fingerprint)
31819
32121
  throw new CliError("configuration_error", "vocabulary changed since the preview", { reason: "vocabulary.stale" });
31820
- return parts && (parts[1] !== "all" || parts[2] !== "all") ? catalog() : current;
32122
+ return parts2 && (parts2[1] !== "all" || parts2[2] !== "all") ? catalog() : current;
31821
32123
  }, "writable");
31822
32124
  const targetEntry = /* @__PURE__ */ __name((current, target) => {
31823
32125
  if (!target || typeof target !== "object")
@@ -32513,7 +32815,7 @@ var stale2 = /* @__PURE__ */ __name(() => {
32513
32815
  reason: "meeting-findings.stale"
32514
32816
  });
32515
32817
  }, "stale");
32516
- var invalid4 = /* @__PURE__ */ __name((message2) => {
32818
+ var invalid6 = /* @__PURE__ */ __name((message2) => {
32517
32819
  throw new CliError("validation_error", message2);
32518
32820
  }, "invalid");
32519
32821
  var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
@@ -32521,7 +32823,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32521
32823
  const proposals = proposalOperationsOver(context);
32522
32824
  const accountId = /* @__PURE__ */ __name((key2) => {
32523
32825
  if (!key2 || typeof key2.provider !== "string" || !key2.provider.trim() || typeof key2.account !== "string" || !key2.account.trim())
32524
- return invalid4("choose a meeting provider and account");
32826
+ return invalid6("choose a meeting provider and account");
32525
32827
  const row2 = database.prepare("SELECT id,scope FROM accounts WHERE provider=? AND external_id=?").get(key2.provider, key2.account);
32526
32828
  if (!row2 || key2.scope !== void 0 && row2.scope !== key2.scope)
32527
32829
  throw new CliError("not_found", "the meeting account is unavailable");
@@ -32529,18 +32831,18 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32529
32831
  }, "accountId");
32530
32832
  const load = /* @__PURE__ */ __name((account, id2) => {
32531
32833
  if (typeof id2 !== "string" || !/^[1-9]\d*$/.test(id2) || !Number.isSafeInteger(Number(id2)))
32532
- return invalid4("a findings batch needs a stored ID");
32834
+ return invalid6("a findings batch needs a stored ID");
32533
32835
  const row2 = database.prepare("SELECT length(CAST(payload AS BLOB)) AS bytes,length(CAST(result AS BLOB)) AS result_bytes FROM proposed_actions WHERE id=? AND account_id=? AND kind=?").get(Number(id2), account, MEETING_FINDINGS_KIND);
32534
32836
  if (!row2)
32535
32837
  throw new CliError("not_found", "the findings batch is unavailable for this account");
32536
32838
  if (Number(row2.bytes) > 1e5 || Number(row2.result_bytes) > 65536)
32537
- return invalid4("stored findings exceed the read budget");
32839
+ return invalid6("stored findings exceed the read budget");
32538
32840
  return proposals.get(id2);
32539
32841
  }, "load");
32540
32842
  const view = /* @__PURE__ */ __name((proposal) => {
32541
32843
  const input = proposal.payload;
32542
32844
  if (!input || !proposal.account || !["proposed", "approved"].includes(proposal.status))
32543
- return invalid4("invalid stored findings batch");
32845
+ return invalid6("invalid stored findings batch");
32544
32846
  return {
32545
32847
  id: proposal.id,
32546
32848
  account: proposal.account,
@@ -32566,7 +32868,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32566
32868
  throw new CliError("not_found", "the cited cue belongs to another account");
32567
32869
  const membership = database.prepare("SELECT id,updated_at,confirmed,source FROM links WHERE from_type='meeting' AND from_id=? AND to_type='project' AND to_id=? AND kind='member-of' AND anchor IS NULL AND confirmed=1").get(parsed2.meetingId, projectId);
32568
32870
  if (!membership)
32569
- return invalid4("each cited meeting needs confirmed membership in the finding's project");
32871
+ return invalid6("each cited meeting needs confirmed membership in the finding's project");
32570
32872
  seen.set(`${finding.project}/${parsed2.meetingId}`, membership);
32571
32873
  if (seen.has(evidence.reference)) {
32572
32874
  if (seen.get(evidence.reference) !== evidence.fingerprint)
@@ -32580,7 +32882,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32580
32882
  return stale2();
32581
32883
  readBytes += Number(budget.bytes);
32582
32884
  if (!Number.isSafeInteger(readBytes) || readBytes > 65536)
32583
- return invalid4("finding evidence exceeds the 65536-byte stored text budget");
32885
+ return invalid6("finding evidence exceeds the 65536-byte stored text budget");
32584
32886
  const row2 = database.prepare(`SELECT t.content_hash,r.start_ms,r.end_ms,r.speaker_participant_id,r.speaker_name,r.text ${query}`).get(...params);
32585
32887
  if (!row2)
32586
32888
  return stale2();
@@ -32605,7 +32907,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32605
32907
  stage: /* @__PURE__ */ __name(async (key2, raw, agent) => {
32606
32908
  const input = validateMeetingFindings(raw);
32607
32909
  if (!agent || typeof agent.bot !== "string" || !agent.bot.trim() || agent.bot.length > 200 || agent.bot === "owner" || agent.model !== void 0 && (typeof agent.model !== "string" || agent.model.length > 200))
32608
- return invalid4("findings must name an agent author independently of their payload");
32910
+ return invalid6("findings must name an agent author independently of their payload");
32609
32911
  const by = { bot: agent.bot, ...agent.model === void 0 ? {} : { model: agent.model } };
32610
32912
  return write(database, () => {
32611
32913
  const account = accountId(key2);
@@ -32615,13 +32917,13 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32615
32917
  if (held) {
32616
32918
  const proposal = load(account, String(held.id));
32617
32919
  if (proposal.payload.inputHash !== inputHash)
32618
- return invalid4("the findings batch key was already used for different input");
32920
+ return invalid6("the findings batch key was already used for different input");
32619
32921
  return view(proposal);
32620
32922
  }
32621
32923
  const snapshotHash = snapshot2(account, input);
32622
32924
  const fingerprints = input.findings.map(meetingFindingFingerprint);
32623
32925
  if (new Set(fingerprints).size !== fingerprints.length)
32624
- return invalid4("the batch contains duplicate findings");
32926
+ return invalid6("the batch contains duplicate findings");
32625
32927
  return view(proposals.propose({
32626
32928
  kind: MEETING_FINDINGS_KIND,
32627
32929
  by,
@@ -32633,9 +32935,9 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32633
32935
  get: /* @__PURE__ */ __name(async (key2, id2) => view(load(accountId(key2), id2)), "get"),
32634
32936
  list: /* @__PURE__ */ __name(async (key2, { limit = 20, offset = 0, status } = {}) => {
32635
32937
  if (status !== void 0 && status !== "proposed" && status !== "reviewed")
32636
- return invalid4("finding status is proposed or reviewed");
32938
+ return invalid6("finding status is proposed or reviewed");
32637
32939
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50 || !Number.isSafeInteger(offset) || offset < 0)
32638
- return invalid4("findings lists take 1\u201350 items and a nonnegative offset");
32940
+ return invalid6("findings lists take 1\u201350 items and a nonnegative offset");
32639
32941
  const account = accountId(key2);
32640
32942
  const ids = database.prepare("SELECT id FROM proposed_actions WHERE account_id=? AND kind=? AND (? IS NULL OR status=?) ORDER BY id DESC LIMIT ? OFFSET ?").all(account, MEETING_FINDINGS_KIND, status ?? null, status === "reviewed" ? "approved" : status ?? null, limit + 1, offset);
32641
32943
  return {
@@ -32650,18 +32952,18 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
32650
32952
  if (!decision || typeof decision.fingerprint !== "string" || decision.fingerprint !== batch.fingerprint)
32651
32953
  return stale2();
32652
32954
  if (!Array.isArray(decision.accept) || decision.accept.length > 16 || new Set(decision.accept).size !== decision.accept.length || decision.accept.some((candidate) => !batch.input.findings.some((finding) => finding.id === candidate)))
32653
- return invalid4("accept only unique IDs shown in this batch");
32955
+ return invalid6("accept only unique IDs shown in this batch");
32654
32956
  const accepted = [...decision.accept].sort();
32655
32957
  if (batch.receipt) {
32656
32958
  if (JSON.stringify(batch.receipt.accepted) !== JSON.stringify(accepted))
32657
- return invalid4("this findings batch was already reviewed with a different decision");
32959
+ return invalid6("this findings batch was already reviewed with a different decision");
32658
32960
  return batch;
32659
32961
  }
32660
32962
  const input = proposal.payload;
32661
32963
  if (accepted.length && snapshot2(account, batch.input) !== input.snapshotHash)
32662
32964
  return stale2();
32663
32965
  if (proposal.proposedBy.type !== "bot" || !proposal.proposedBy.name)
32664
- return invalid4("a findings author must be an agent");
32966
+ return invalid6("a findings author must be an agent");
32665
32967
  const agent = {
32666
32968
  bot: proposal.proposedBy.name,
32667
32969
  ...input.agentModel === null ? {} : { model: input.agentModel }
@@ -34143,7 +34445,7 @@ var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {})
34143
34445
  var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
34144
34446
  quietSqliteWarning();
34145
34447
  const { drizzle } = await import("./node-ZYWB7IET.js");
34146
- const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-J3OODPYK.js");
34448
+ const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-FSQIKGED.js");
34147
34449
  const client = await nodeClient(path, { readOnly });
34148
34450
  try {
34149
34451
  return { database: cacheOverNodeSqlite(client), orm: drizzle({ client }) };
@@ -34153,7 +34455,7 @@ var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
34153
34455
  }
34154
34456
  }, "openUnderNode");
34155
34457
  var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
34156
- const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-RI7DR6RZ.js");
34458
+ const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-2GOM5PM3.js");
34157
34459
  const { drizzle } = await import("./bun-7SYKSCLA.js");
34158
34460
  const client = await bunClient(path, readOnly ? { readonly: true, create: false } : void 0);
34159
34461
  try {
@@ -34309,14 +34611,14 @@ var projectAnnotationsSchema = strictObject({
34309
34611
 
34310
34612
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
34311
34613
  var PROJECT_ANNOTATIONS_MAX_BYTES = 4 * 1024 * 1024;
34312
- var invalid5 = /* @__PURE__ */ __name((field3) => {
34614
+ var invalid7 = /* @__PURE__ */ __name((field3) => {
34313
34615
  throw new CliError("validation_error", `invalid project annotations.${field3}`);
34314
34616
  }, "invalid");
34315
34617
  var canonical = /* @__PURE__ */ __name((ref3) => {
34316
34618
  try {
34317
34619
  return ref3.startsWith("meeting:") ? canonicalMeetingReference(ref3) : canonicalReference(ref3);
34318
34620
  } catch {
34319
- return invalid5("reference");
34621
+ return invalid7("reference");
34320
34622
  }
34321
34623
  }, "canonical");
34322
34624
  var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, additionalActors = []) => {
@@ -34325,37 +34627,37 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
34325
34627
  const used = /* @__PURE__ */ new Set();
34326
34628
  const kind3 = /* @__PURE__ */ __name((ref3, kinds2) => {
34327
34629
  if (canonical(ref3) !== ref3 || !kinds2.includes(parseReference(ref3).type) || !/^[a-z]+:[1-9]\d*$/.test(ref3))
34328
- invalid5("reference kind");
34630
+ invalid7("reference kind");
34329
34631
  }, "kind");
34330
34632
  kind3(manifest.project.ref, ["project"]);
34331
34633
  for (const fact of manifest.facts) {
34332
34634
  kind3(fact.ref, ["fact"]);
34333
34635
  if (owned.has(fact.ref))
34334
- invalid5("facts.duplicate");
34636
+ invalid7("facts.duplicate");
34335
34637
  owned.add(fact.ref);
34336
34638
  kind3(fact.author, ["person", "bot"]);
34337
34639
  if (fact.confirmed_by !== null)
34338
34640
  kind3(fact.confirmed_by, ["person", "bot"]);
34339
34641
  if (fact.updated_at < fact.created_at)
34340
- invalid5("facts.updated_at");
34642
+ invalid7("facts.updated_at");
34341
34643
  if (fact.type !== "decision" && (fact.supersedes !== null || ["superseded", "reversed"].includes(fact.status)))
34342
- invalid5("facts.lifecycle");
34644
+ invalid7("facts.lifecycle");
34343
34645
  if (fact.supersedes === fact.ref)
34344
- invalid5("facts.supersedes");
34646
+ invalid7("facts.supersedes");
34345
34647
  }
34346
34648
  for (const item of manifest.external) {
34347
34649
  if (canonical(item.ref) !== item.ref || owned.has(item.ref) || external.has(item.ref))
34348
- invalid5("external.ref");
34650
+ invalid7("external.ref");
34349
34651
  external.add(item.ref);
34350
34652
  const body2 = /^(msg|document|note|meeting):/.test(item.ref);
34351
34653
  if (body2 !== (item.content_sha256 !== null))
34352
- invalid5("external.content_sha256");
34654
+ invalid7("external.content_sha256");
34353
34655
  }
34354
34656
  const dependency = /* @__PURE__ */ __name((ref3) => {
34355
34657
  if (ref3 === null)
34356
34658
  return;
34357
34659
  if (canonical(ref3) !== ref3 || !owned.has(ref3) && !external.has(ref3))
34358
- invalid5("missing dependency");
34660
+ invalid7("missing dependency");
34359
34661
  used.add(ref3);
34360
34662
  }, "dependency");
34361
34663
  if (manifest.project.organization !== null)
@@ -34369,7 +34671,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
34369
34671
  for (const alias2 of manifest.aliases) {
34370
34672
  const name = normalizeVocabularyName(alias2);
34371
34673
  if (aliases2.has(name))
34372
- invalid5("aliases.duplicate");
34674
+ invalid7("aliases.duplicate");
34373
34675
  aliases2.add(name);
34374
34676
  }
34375
34677
  for (const fact of manifest.facts) {
@@ -34378,7 +34680,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
34378
34680
  if (fact.supersedes !== null) {
34379
34681
  kind3(fact.supersedes, ["fact"]);
34380
34682
  if (!manifest.facts.some((previous2) => previous2.ref === fact.supersedes && previous2.type === "decision"))
34381
- invalid5("facts.supersedes outside project");
34683
+ invalid7("facts.supersedes outside project");
34382
34684
  }
34383
34685
  }
34384
34686
  const previous = new Map(manifest.facts.map((fact) => [fact.ref, fact.supersedes]));
@@ -34387,7 +34689,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
34387
34689
  let ref3 = fact.ref;
34388
34690
  while (ref3) {
34389
34691
  if (path.has(ref3))
34390
- invalid5("facts.supersedes cycle");
34692
+ invalid7("facts.supersedes cycle");
34391
34693
  path.add(ref3);
34392
34694
  ref3 = previous.get(ref3);
34393
34695
  }
@@ -34395,36 +34697,36 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
34395
34697
  const links2 = /* @__PURE__ */ new Set();
34396
34698
  for (const link3 of manifest.links) {
34397
34699
  if (!/^link:[1-9]\d*$/.test(link3.ref) || links2.has(link3.ref))
34398
- invalid5("links.ref");
34700
+ invalid7("links.ref");
34399
34701
  links2.add(link3.ref);
34400
34702
  if (!owned.has(link3.from) && (link3.to === null || !owned.has(link3.to)))
34401
- invalid5("links.outside project");
34703
+ invalid7("links.outside project");
34402
34704
  if (link3.to === null && link3.target_text === null)
34403
- invalid5("links.target_text");
34705
+ invalid7("links.target_text");
34404
34706
  if (link3.updated_at < link3.created_at)
34405
- invalid5("links.updated_at");
34707
+ invalid7("links.updated_at");
34406
34708
  for (const ref3 of [link3.from, link3.to])
34407
34709
  dependency(ref3);
34408
34710
  }
34409
34711
  for (const ref3 of external)
34410
34712
  if (!used.has(ref3))
34411
- invalid5("external.unused");
34713
+ invalid7("external.unused");
34412
34714
  }, "validateProjectAnnotationsGraph");
34413
34715
  var decodeProjectAnnotations = /* @__PURE__ */ __name((json3) => {
34414
34716
  if (typeof json3 !== "string" || Buffer.byteLength(json3) > PROJECT_ANNOTATIONS_MAX_BYTES)
34415
- invalid5("bytes");
34717
+ invalid7("bytes");
34416
34718
  let input;
34417
34719
  try {
34418
34720
  input = JSON.parse(json3);
34419
34721
  } catch {
34420
- return invalid5("json");
34722
+ return invalid7("json");
34421
34723
  }
34422
34724
  const parsed2 = safeParse(projectAnnotationsSchema, input);
34423
34725
  if (!parsed2.success)
34424
- return invalid5(parsed2.issues[0]?.path?.map((part) => String(part.key)).join(".") ?? "manifest");
34726
+ return invalid7(parsed2.issues[0]?.path?.map((part) => String(part.key)).join(".") ?? "manifest");
34425
34727
  const manifest = parsed2.output;
34426
34728
  if (manifest.aliases.length + manifest.facts.length + manifest.links.length + manifest.external.length > 1e3)
34427
- invalid5("record budget");
34729
+ invalid7("record budget");
34428
34730
  validateProjectAnnotationsGraph(manifest);
34429
34731
  return manifest;
34430
34732
  }, "decodeProjectAnnotations");
@@ -34460,23 +34762,23 @@ var kind2 = /* @__PURE__ */ __name((ref3) => {
34460
34762
  const parsed2 = parseReference(ref3);
34461
34763
  return "provider" in parsed2 ? `${parsed2.type}:${parsed2.provider}` : parsed2.type;
34462
34764
  }, "kind");
34463
- var invalid6 = /* @__PURE__ */ __name((field3) => {
34765
+ var invalid8 = /* @__PURE__ */ __name((field3) => {
34464
34766
  throw new CliError("validation_error", `invalid project annotation plan.${field3}`);
34465
34767
  }, "invalid");
34466
34768
  var projectAnnotationBindingSources = /* @__PURE__ */ __name((manifest, bindings) => {
34467
34769
  if (!bindings || typeof bindings !== "object" || Array.isArray(bindings) || Object.keys(bindings).length > 1001)
34468
- return invalid6("bindings");
34770
+ return invalid8("bindings");
34469
34771
  if (Object.getPrototypeOf(bindings) !== Object.prototype && Object.getPrototypeOf(bindings) !== null)
34470
- return invalid6("bindings");
34772
+ return invalid8("bindings");
34471
34773
  const required3 = /* @__PURE__ */ new Set([manifest.project.ref, ...manifest.external.map((item) => item.ref)]);
34472
34774
  for (const [source2, destination] of Object.entries(bindings))
34473
34775
  if (!required3.has(source2) || typeof destination !== "string" || destination.length > 2048)
34474
- return invalid6("bindings");
34776
+ return invalid8("bindings");
34475
34777
  for (const destination of Object.values(bindings)) {
34476
34778
  try {
34477
34779
  kind2(destination);
34478
34780
  } catch {
34479
- return invalid6("bindings.reference");
34781
+ return invalid8("bindings.reference");
34480
34782
  }
34481
34783
  }
34482
34784
  return required3;
@@ -34484,17 +34786,17 @@ var projectAnnotationBindingSources = /* @__PURE__ */ __name((manifest, bindings
34484
34786
  var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fingerprint, target, bindings) => {
34485
34787
  const checked = safeParse(targetSchema, target);
34486
34788
  if (!checked.success)
34487
- return invalid6(checked.issues[0]?.path?.map((p) => String(p.key)).join(".") ?? "target");
34789
+ return invalid8(checked.issues[0]?.path?.map((p) => String(p.key)).join(".") ?? "target");
34488
34790
  const required3 = projectAnnotationBindingSources(manifest, bindings);
34489
34791
  const destinations = /* @__PURE__ */ new Map();
34490
34792
  for (const item of checked.output.external) {
34491
34793
  try {
34492
34794
  kind2(item.ref);
34493
34795
  } catch {
34494
- return invalid6("target.external.ref");
34796
+ return invalid8("target.external.ref");
34495
34797
  }
34496
34798
  if (destinations.has(item.ref) || item.ref === target.project)
34497
- return invalid6("target.external.duplicate");
34799
+ return invalid8("target.external.duplicate");
34498
34800
  destinations.set(item.ref, item.content_sha256);
34499
34801
  }
34500
34802
  const missing_bindings = [], conflicts = [];
@@ -34511,7 +34813,7 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
34511
34813
  continue;
34512
34814
  }
34513
34815
  } catch {
34514
- return invalid6("bindings.reference");
34816
+ return invalid8("bindings.reference");
34515
34817
  }
34516
34818
  if (used.has(destination))
34517
34819
  conflicts.push({ reference: source2, reason: "duplicate" });
@@ -34594,38 +34896,38 @@ var snapshotGraph = /* @__PURE__ */ __name((value) => ({
34594
34896
  external: value.external
34595
34897
  }), "snapshotGraph");
34596
34898
  var decodeProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3) => {
34597
- const invalid8 = /* @__PURE__ */ __name((field3) => {
34899
+ const invalid10 = /* @__PURE__ */ __name((field3) => {
34598
34900
  throw new CliError("validation_error", `invalid project annotation snapshot.${field3}`);
34599
34901
  }, "invalid");
34600
34902
  if (typeof json3 !== "string" || Buffer.byteLength(json3) > PROJECT_ANNOTATIONS_MAX_BYTES)
34601
- return invalid8("bytes");
34903
+ return invalid10("bytes");
34602
34904
  let value;
34603
34905
  try {
34604
34906
  value = JSON.parse(json3);
34605
34907
  } catch {
34606
- return invalid8("json");
34908
+ return invalid10("json");
34607
34909
  }
34608
34910
  const checked = safeParse(projectAnnotationSnapshotSchema, value);
34609
34911
  if (!checked.success)
34610
- return invalid8(checked.issues[0]?.path?.map((p) => String(p.key)).join(".") ?? "manifest");
34912
+ return invalid10(checked.issues[0]?.path?.map((p) => String(p.key)).join(".") ?? "manifest");
34611
34913
  const snapshot2 = checked.output;
34612
34914
  if (snapshot2.aliases.length + snapshot2.facts.length + snapshot2.links.length + snapshot2.external.length > 1e3)
34613
- return invalid8("record budget");
34915
+ return invalid10("record budget");
34614
34916
  for (const field3 of ["description", "status", "owner"])
34615
34917
  if (snapshot2.project[field3] !== null && !snapshot2.project[field3].trim())
34616
- return invalid8(`project.${field3}`);
34918
+ return invalid10(`project.${field3}`);
34617
34919
  for (const alias2 of snapshot2.aliases)
34618
34920
  for (const field3 of ["name", "source"])
34619
34921
  if (!alias2[field3].trim())
34620
- return invalid8(`aliases.${field3}`);
34922
+ return invalid10(`aliases.${field3}`);
34621
34923
  if (snapshot2.project.updated_at < snapshot2.project.created_at)
34622
- return invalid8("project.updated_at");
34924
+ return invalid10("project.updated_at");
34623
34925
  for (const alias2 of snapshot2.aliases)
34624
34926
  if (alias2.updated_at < alias2.created_at)
34625
- return invalid8("aliases.updated_at");
34927
+ return invalid10("aliases.updated_at");
34626
34928
  for (const fact of snapshot2.facts)
34627
34929
  if (!fact.statement.trim())
34628
- return invalid8("facts.statement");
34930
+ return invalid10("facts.statement");
34629
34931
  validateProjectAnnotationsGraph(snapshotGraph(snapshot2), snapshot2.project.owner === null ? [] : [snapshot2.project.owner]);
34630
34932
  return snapshot2;
34631
34933
  }, "decodeProjectAnnotationSnapshot");
@@ -34692,7 +34994,7 @@ var planProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3, target, bindi
34692
34994
 
34693
34995
  // node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
34694
34996
  import { createHash as createHash19 } from "node:crypto";
34695
- var invalid7 = /* @__PURE__ */ __name(() => {
34997
+ var invalid9 = /* @__PURE__ */ __name(() => {
34696
34998
  throw new CliError("configuration_error", "project snapshot has an unavailable or unsupported dependency");
34697
34999
  }, "invalid");
34698
35000
  var scalar2 = /* @__PURE__ */ new Set([
@@ -34761,14 +35063,14 @@ var ProjectSnapshotSources = class {
34761
35063
  if (type === null && id2 === null)
34762
35064
  return null;
34763
35065
  if (typeof type !== "string" || !scalar2.has(type) || typeof id2 !== "number" || !Number.isSafeInteger(id2) || id2 < 1)
34764
- return invalid7();
35066
+ return invalid9();
34765
35067
  const key2 = `${type}:${id2}`, cached = this.byThing.get(key2);
34766
35068
  if (cached)
34767
35069
  return cached;
34768
35070
  if (type === "project" || type === "organization") {
34769
35071
  const table = type === "project" ? "projects" : "organizations";
34770
35072
  if (!this.database.prepare(`SELECT 1 FROM ${table} WHERE id=? AND deleted_at IS NULL`).get(id2))
34771
- return invalid7();
35073
+ return invalid9();
34772
35074
  }
34773
35075
  const identifier = {
34774
35076
  message: [
@@ -34790,7 +35092,7 @@ var ProjectSnapshotSources = class {
34790
35092
  this.budget.rows(this.database, selection[0], [...selection[1]], [id2]);
34791
35093
  const thing = storedThing(type, id2), ref3 = referenceOfThing(this.database, thing);
34792
35094
  if (!ref3)
34793
- return invalid7();
35095
+ return invalid9();
34794
35096
  this.byThing.set(key2, ref3);
34795
35097
  this.references.set(ref3, thing);
34796
35098
  return ref3;
@@ -34809,12 +35111,12 @@ var ProjectSnapshotSources = class {
34809
35111
  return this.transcript(thing.id);
34810
35112
  const spec = texts[thing.type];
34811
35113
  if (!spec)
34812
- return invalid7();
35114
+ return invalid9();
34813
35115
  const from2 = `FROM ${spec.table} n ${spec.join ?? ""} WHERE n.id=? AND ${spec.where}`;
34814
35116
  this.budget.rows(this.database, from2, spec.fields, [thing.id]);
34815
35117
  const row2 = this.database.prepare(`SELECT ${spec.fields.map((f, i) => `${f} AS v${i}`).join(",")} ${from2}`).get(thing.id);
34816
35118
  if (!row2)
34817
- return invalid7();
35119
+ return invalid9();
34818
35120
  return this.digest(thing.type, spec.fields.map((_f, i) => row2[`v${i}`]));
34819
35121
  }
34820
35122
  transcript(id2) {
@@ -34822,7 +35124,7 @@ var ProjectSnapshotSources = class {
34822
35124
  this.budget.rows(this.database, from2, ["n.format", "n.language", "n.source"], [id2]);
34823
35125
  const header = this.database.prepare(`SELECT n.format,n.language,n.source ${from2}`).get(id2);
34824
35126
  if (!header)
34825
- return invalid7();
35127
+ return invalid9();
34826
35128
  const rows = "FROM meeting_transcript_rows n WHERE n.meeting_transcript_id=?";
34827
35129
  this.budget.rows(this.database, rows, ["n.position", "n.start_ms", "n.end_ms", "n.speaker_name", "n.text"], [id2]);
34828
35130
  const cues = this.database.prepare(`SELECT n.position,n.start_ms,n.end_ms,n.speaker_name,n.text ${rows} ORDER BY n.position LIMIT 1001`).all(id2);
@@ -36063,6 +36365,17 @@ var storeOver = /* @__PURE__ */ __name((context) => {
36063
36365
  }, "storeOver");
36064
36366
 
36065
36367
  export {
36368
+ isFolderProvider,
36369
+ folderProviderSql,
36370
+ folderProviderOf,
36371
+ isDocumentAccountProvider,
36372
+ filesAccountSql,
36373
+ INTERNAL_NOTES,
36374
+ UNKNOWN_PROVIDER,
36375
+ isKind,
36376
+ providerNamed,
36377
+ kindIn,
36378
+ kindOf,
36066
36379
  isBotProvider,
36067
36380
  inSource,
36068
36381
  sourceOf,
@@ -36098,10 +36411,15 @@ export {
36098
36411
  hasStems,
36099
36412
  savedPhoneCountries,
36100
36413
  saveStorePhoneCountries,
36414
+ formatLocator,
36415
+ isLocator,
36416
+ parseLocator,
36101
36417
  normalizeVocabularyName,
36102
36418
  createTagRedirectIndex,
36103
36419
  tagMemberIds,
36104
36420
  inboxKey,
36421
+ formatReference,
36422
+ parseReference,
36105
36423
  storedThing,
36106
36424
  thingOf,
36107
36425
  referenceOfThing,
@@ -36126,6 +36444,9 @@ export {
36126
36444
  CHAT_COLUMNS,
36127
36445
  TRACKED_CHAT_COLUMNS,
36128
36446
  titlePart,
36447
+ COUNTER_FIELDS,
36448
+ counterObservationTime,
36449
+ counterFreshness,
36129
36450
  AGENDA_COLUMNS,
36130
36451
  correctWords,
36131
36452
  threadConversation,
@@ -36154,6 +36475,10 @@ export {
36154
36475
  CONVERSATION_COLUMNS,
36155
36476
  MENTION_STATUSES,
36156
36477
  MENTION_QUERY,
36478
+ MESSAGE_MEASURES,
36479
+ AUTHOR_MEASURES,
36480
+ rankingOptions,
36481
+ RANKING_TOKENIZER_VERSION,
36157
36482
  rankingContextRange,
36158
36483
  calendarKey,
36159
36484
  pendingNormalization,