@wirecat/zoom-cli 0.71.0 → 0.72.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 (156) hide show
  1. package/dist/answers.d.ts +56 -0
  2. package/dist/answers.d.ts.map +1 -1
  3. package/dist/bin/zm.js +2 -2
  4. package/dist/bundle/{all-profiles-O4YNVPZX.js → all-profiles-XFIPF4GF.js} +12 -12
  5. package/dist/bundle/answer-policy-AT6CDEE5.js +110 -0
  6. package/dist/bundle/{anthropic-7GGRX3RX.js → anthropic-SSUBR3BC.js} +18 -11
  7. package/dist/bundle/{app-server-CPMKM3HI.js → app-server-7DJHHF2F.js} +68 -56
  8. package/dist/bundle/{bun-POHZKEPV.js → bun-6HBYWQIX.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-PGYMBPEL.js → bun-sqlite-4L3Q55NB.js} +10 -6
  10. package/dist/bundle/{chunk-Q2SUFGSH.js → chunk-23J2ANZ7.js} +2 -2
  11. package/dist/bundle/{chunk-FSHCAWZS.js → chunk-24OFZNRC.js} +13119 -10386
  12. package/dist/bundle/{chunk-LE7MDAQG.js → chunk-2MIBRVSV.js} +2 -2
  13. package/dist/bundle/{chunk-DIQLXAAZ.js → chunk-37NF5CBJ.js} +4 -4
  14. package/dist/bundle/chunk-3KRTEX5M.js +53 -0
  15. package/dist/bundle/{chunk-IED3NS7G.js → chunk-4SY67IUA.js} +30 -30
  16. package/dist/bundle/{chunk-CKPCVEXU.js → chunk-4XQWF3U2.js} +6 -6
  17. package/dist/bundle/{chunk-CT4WVR4N.js → chunk-4YIGXTBP.js} +3 -3
  18. package/dist/bundle/{chunk-YPO2U2YB.js → chunk-5AELTC52.js} +388 -143
  19. package/dist/bundle/{chunk-USQ23X5V.js → chunk-5MGICK47.js} +750 -734
  20. package/dist/bundle/{chunk-DK6ICIGL.js → chunk-5X4IY5JH.js} +2025 -1302
  21. package/dist/bundle/{chunk-EOSVN2ER.js → chunk-63QXCE5Z.js} +242 -242
  22. package/dist/bundle/{chunk-OE7EIP5L.js → chunk-6DCLZLGX.js} +1 -1
  23. package/dist/bundle/chunk-7GLJSJ7M.js +16 -0
  24. package/dist/bundle/{chunk-X3ZDN3U7.js → chunk-7IFO43Q5.js} +2 -2
  25. package/dist/bundle/{chunk-YD2RYVMK.js → chunk-7JYMGXLI.js} +41 -39
  26. package/dist/bundle/{chunk-DSVZEXYJ.js → chunk-7OD3522V.js} +3541 -3346
  27. package/dist/bundle/{chunk-2FV5JUQU.js → chunk-7S4D5SM2.js} +41 -35
  28. package/dist/bundle/{chunk-VRH7VRTK.js → chunk-7SUWPMZG.js} +10 -15
  29. package/dist/bundle/{chunk-4QPQ7MDA.js → chunk-ADKMBXY4.js} +1 -1
  30. package/dist/bundle/{chunk-MRI6QMZ3.js → chunk-B3SILJBU.js} +18 -18
  31. package/dist/bundle/{chunk-7ROXXRGG.js → chunk-CANRIRNZ.js} +6678 -5185
  32. package/dist/bundle/{chunk-DRBQDCDU.js → chunk-CW46FWKW.js} +38 -123
  33. package/dist/bundle/{chunk-GXF5HFFP.js → chunk-D24OQAHM.js} +4 -4
  34. package/dist/bundle/{chunk-ZBKWRYRS.js → chunk-D5EUMWD5.js} +3 -3
  35. package/dist/bundle/{chunk-QVSLSWAL.js → chunk-DEPXZJ2V.js} +21 -150
  36. package/dist/bundle/{chunk-TM4JSVGQ.js → chunk-DOCVEKP2.js} +39 -44
  37. package/dist/bundle/{chunk-BBTQIVFP.js → chunk-EFF2XBHP.js} +2 -2
  38. package/dist/bundle/{chunk-XRFHQGOD.js → chunk-EG25AY4L.js} +1 -1
  39. package/dist/bundle/{chunk-FEM2JQN2.js → chunk-ELJUBPY4.js} +1 -1
  40. package/dist/bundle/{chunk-2U6SER67.js → chunk-ERJYJ36F.js} +2 -2
  41. package/dist/bundle/chunk-FSCPQQS5.js +244 -0
  42. package/dist/bundle/{chunk-P3XC6EDU.js → chunk-H53WFZBN.js} +11 -130
  43. package/dist/bundle/{chunk-RN4EHCC5.js → chunk-I7CUMZD6.js} +3 -3
  44. package/dist/bundle/{chunk-ALIT5QFT.js → chunk-IACWKZWS.js} +1 -1
  45. package/dist/bundle/{chunk-MW4EGDDV.js → chunk-IFBIXU6C.js} +2 -2
  46. package/dist/bundle/{chunk-5K7OGPGA.js → chunk-IU4DUUB3.js} +7 -7
  47. package/dist/bundle/{chunk-INVTDIF6.js → chunk-IXO4SCKE.js} +1 -1
  48. package/dist/bundle/{chunk-OHWMIUCT.js → chunk-JAEPK457.js} +244 -245
  49. package/dist/bundle/{chunk-HB6XJQ3Y.js → chunk-JFPUYQSP.js} +5 -5
  50. package/dist/bundle/{chunk-IAV5BG3I.js → chunk-JG4MNYG2.js} +1 -1
  51. package/dist/bundle/{chunk-ZBFL5JPT.js → chunk-JRCH4YZP.js} +16 -10
  52. package/dist/bundle/{chunk-M76MXMLY.js → chunk-JZ4XNNL7.js} +1 -1
  53. package/dist/bundle/chunk-K6HR6HCO.js +32 -0
  54. package/dist/bundle/{chunk-DHWBSXG3.js → chunk-KFZL67JP.js} +323 -55
  55. package/dist/bundle/{chunk-X4GWR6GO.js → chunk-KPIQXFNB.js} +375 -10
  56. package/dist/bundle/{chunk-OWEBWDHV.js → chunk-KWURWGGB.js} +80 -5
  57. package/dist/bundle/{chunk-Q5PI72CR.js → chunk-LA6QUVGQ.js} +3 -2
  58. package/dist/bundle/{chunk-5J4AMBMM.js → chunk-LLUNHAZ7.js} +4 -4
  59. package/dist/bundle/{chunk-2RUAMDVV.js → chunk-LTWJM3ED.js} +17 -17
  60. package/dist/bundle/{chunk-2U27KIKU.js → chunk-M3DMXDX6.js} +6 -6
  61. package/dist/bundle/{chunk-VW6BF6M7.js → chunk-MCPOZNWG.js} +1 -1
  62. package/dist/bundle/{chunk-CRFOGYDG.js → chunk-MSQHSW4C.js} +2 -2
  63. package/dist/bundle/chunk-N4QNYWWG.js +71 -0
  64. package/dist/bundle/chunk-NMZQTYKJ.js +18 -0
  65. package/dist/bundle/{chunk-2KESWII5.js → chunk-OHCLQJOV.js} +3 -3
  66. package/dist/bundle/{chunk-4QUFFB2U.js → chunk-OP5PGE2N.js} +4 -4
  67. package/dist/bundle/{chunk-Q3XLZIY3.js → chunk-OY6N2ABP.js} +29 -23
  68. package/dist/bundle/chunk-PJWSGXOB.js +185 -0
  69. package/dist/bundle/{chunk-633QXP57.js → chunk-QA6KIL7Q.js} +10 -8
  70. package/dist/bundle/{chunk-N2FNMION.js → chunk-QQUY4MZY.js} +1 -1
  71. package/dist/bundle/{chunk-X277FBTF.js → chunk-QW7YTRV2.js} +3 -3
  72. package/dist/bundle/chunk-RJTGENHZ.js +109 -0
  73. package/dist/bundle/{chunk-ULDXZ6LH.js → chunk-RLCVPECY.js} +63 -63
  74. package/dist/bundle/{chunk-BGTEVIW4.js → chunk-RN5SU2RN.js} +6 -6
  75. package/dist/bundle/{chunk-P3ASN72F.js → chunk-RX5CJ55S.js} +1 -1
  76. package/dist/bundle/{chunk-7QC4M4HS.js → chunk-RZUJMAMK.js} +4 -4
  77. package/dist/bundle/{chunk-OORMSM6O.js → chunk-S7SXSHRC.js} +21 -21
  78. package/dist/bundle/{chunk-GGS6D4W4.js → chunk-SXZGCD6E.js} +3 -3
  79. package/dist/bundle/{chunk-64ZHF6PJ.js → chunk-T27IMG6X.js} +3 -1
  80. package/dist/bundle/{chunk-VJXHIUFP.js → chunk-TF2WKPNW.js} +15 -15
  81. package/dist/bundle/{chunk-QTHIU7CO.js → chunk-U32VL3MA.js} +1 -1
  82. package/dist/bundle/{chunk-RQG5VOGH.js → chunk-U3NJBGLA.js} +3 -3
  83. package/dist/bundle/{chunk-WOIHSQAL.js → chunk-UVZLK3M4.js} +33 -9
  84. package/dist/bundle/{chunk-XI3VIQKW.js → chunk-VIV64MQM.js} +560 -537
  85. package/dist/bundle/{chunk-CFQF6IGY.js → chunk-W3YTVEWV.js} +69 -6
  86. package/dist/bundle/{chunk-54YDWBYG.js → chunk-WLVG4RBZ.js} +1 -1
  87. package/dist/bundle/{chunk-77TCCHMP.js → chunk-WOAYHCM2.js} +1 -1
  88. package/dist/bundle/{chunk-5LJTU4LY.js → chunk-WXTYYWZI.js} +13 -13
  89. package/dist/bundle/{chunk-MEED7YFG.js → chunk-WZGKHTA4.js} +2 -2
  90. package/dist/bundle/{chunk-I4DFFR7F.js → chunk-X2MP634F.js} +14 -5
  91. package/dist/bundle/{chunk-RGJ7OWHU.js → chunk-XPWZSW6Y.js} +61 -21
  92. package/dist/bundle/{chunk-SELXER2Q.js → chunk-YVVJ6Y5C.js} +7 -7
  93. package/dist/bundle/{chunk-4LAQDZXU.js → chunk-ZHA56THL.js} +790 -70
  94. package/dist/bundle/{chunk-ZVI6TFQR.js → chunk-ZVFYGTGJ.js} +17 -17
  95. package/dist/bundle/{chunk-GL3MYFMX.js → chunk-ZW5KHKMA.js} +5 -5
  96. package/dist/bundle/{cli-KHMEUXNG.js → cli-IYYI7GAM.js} +158 -96
  97. package/dist/bundle/command-contract-TX7NSUBM.js +42 -0
  98. package/dist/bundle/command-server-entry-FXX4LJWF.js +171 -0
  99. package/dist/bundle/config-YKNM33J7.js +96 -0
  100. package/dist/bundle/{decode-7RP4HSVE.js → decode-SRGOOGBW.js} +6 -6
  101. package/dist/bundle/{dispatch-IZCAK47P.js → dispatch-OUHRPFUL.js} +11 -11
  102. package/dist/bundle/{dist-BFT2SUBV.js → dist-UZLNLAIO.js} +52 -31
  103. package/dist/bundle/{echarts-T2BSQ2YV.js → echarts-7CM2MCMW.js} +2 -2
  104. package/dist/bundle/{embed-BAS6YPDT.js → embed-VEE56BOB.js} +7 -7
  105. package/dist/bundle/{embedder-5XD5FCAO.js → embedder-SZFYR543.js} +10 -10
  106. package/dist/bundle/{failure-R2OIHCE5.js → failure-MZBNM7M5.js} +3 -3
  107. package/dist/bundle/first-run-KWC7RKF2.js +29 -0
  108. package/dist/bundle/first-screen-DWKMNSEI.js +40 -0
  109. package/dist/bundle/{folders-ZXTOFY4T.js → folders-UQXRSDJJ.js} +5 -5
  110. package/dist/bundle/{instructions-XZPROPKY.js → instructions-R7OHVAWH.js} +1 -1
  111. package/dist/bundle/{main-TZXKGL3L.js → main-EFUN2O3K.js} +21 -20
  112. package/dist/bundle/{mcp-M4QN2E7R.js → mcp-7KQUJNFN.js} +2 -2
  113. package/dist/bundle/{meetings-JB2ISPND.js → meetings-5I2BDNTA.js} +7 -7
  114. package/dist/bundle/{node-A3B3MJWX.js → node-3N2JGZ7V.js} +2 -2
  115. package/dist/bundle/{node-sqlite-QVWDLGDX.js → node-sqlite-2UVEE2WM.js} +11 -7
  116. package/dist/bundle/{oauth-YA6IYV4O.js → oauth-AYGD7UU3.js} +8 -8
  117. package/dist/bundle/{open-SY7TXJBS.js → open-3GUVDLGD.js} +6 -6
  118. package/dist/bundle/openai-NHCDLWWY.js +28 -0
  119. package/dist/bundle/{output-file-YGQYZCBJ.js → output-file-72JFXVHQ.js} +6 -6
  120. package/dist/bundle/{process-6HNBTJIY.js → process-YAHHUFR5.js} +1 -1
  121. package/dist/bundle/{program-77BUCJ4H.js → program-OSZROCTK.js} +97 -91
  122. package/dist/bundle/{prompt-YDG73YDS.js → prompt-HMCW4XQJ.js} +6 -6
  123. package/dist/bundle/{recognize-ECXDGTB7.js → recognize-VF5CA7EM.js} +5 -5
  124. package/dist/bundle/{remote-K4JHGBVJ.js → remote-5C6VTPR2.js} +10 -8
  125. package/dist/bundle/{rerank-IU2YYD4T.js → rerank-ER7NEDOI.js} +8 -8
  126. package/dist/bundle/run-log-JKTLKXSK.js +124 -0
  127. package/dist/bundle/{serve-3XWIF3HI.js → serve-QJWXJOM7.js} +10 -10
  128. package/dist/bundle/{server-56VYOHWP.js → server-KCIK3Y2P.js} +50 -48
  129. package/dist/bundle/server-LLGFDLLJ.js +75 -0
  130. package/dist/bundle/{services-X7IPEGQ5.js → services-LQMYJQG3.js} +62 -45
  131. package/dist/bundle/{speech-E2OBQWYA.js → speech-74GJQNQH.js} +20 -17
  132. package/dist/bundle/{state-4GMJYK4H.js → state-4XDGCHDF.js} +7 -7
  133. package/dist/bundle/{store-LA4TV4DM.js → store-5Y5HK2L2.js} +22 -19
  134. package/dist/bundle/{store-KPI7GB5Y.js → store-Y56AHJ2Y.js} +42 -27
  135. package/dist/bundle/store-connection-4WI32AYU.js +89 -0
  136. package/dist/bundle/store-maintenance-command-PCXO5AH4.js +65 -0
  137. package/dist/bundle/{streaming-EJ3NM2C2.js → streaming-E5CR6HSR.js} +7 -7
  138. package/dist/bundle/{tokens-BE6CJMR5.js → tokens-E2QNVC4F.js} +7 -7
  139. package/dist/bundle/zm.js +34 -10
  140. package/dist/bundle/{zoom-app-QEJBTIJ4.js → zoom-app-NVL7HEAX.js} +8 -8
  141. package/dist/version.d.ts +1 -1
  142. package/dist/version.js +1 -1
  143. package/package.json +3 -3
  144. package/dist/bundle/answer-policy-PPSPMCLH.js +0 -104
  145. package/dist/bundle/chunk-KMV7GZB6.js +0 -35
  146. package/dist/bundle/chunk-UG447QY2.js +0 -27
  147. package/dist/bundle/command-contract-4K6XXZYE.js +0 -41
  148. package/dist/bundle/config-EEDB632I.js +0 -90
  149. package/dist/bundle/first-run-23WWZ2PW.js +0 -28
  150. package/dist/bundle/first-screen-6HFUYVFR.js +0 -39
  151. package/dist/bundle/openai-2AU24NRN.js +0 -25
  152. package/dist/bundle/run-log-LFEXNZ74.js +0 -118
  153. package/dist/bundle/server-YSTMUZ22.js +0 -72
  154. package/dist/bundle/store-connection-AZTIF6IH.js +0 -83
  155. package/dist/bundle/store-maintenance-command-LR572PS4.js +0 -61
  156. /package/dist/bundle/{chunk-VOXIGICJ.js → chunk-YVNHQFLC.js} +0 -0
@@ -1,12 +1,9 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
- import {
4
- renderMessages
5
- } from "./chunk-X3ZDN3U7.js";
6
3
  import {
7
4
  answerOf,
8
5
  messengerContext
9
- } from "./chunk-2FV5JUQU.js";
6
+ } from "./chunk-7S4D5SM2.js";
10
7
  import {
11
8
  chatEventAnswer,
12
9
  memberAnswer,
@@ -15,14 +12,17 @@ import {
15
12
  serveRelay,
16
13
  typedQuery,
17
14
  withQuery
18
- } from "./chunk-Q3XLZIY3.js";
15
+ } from "./chunk-OY6N2ABP.js";
16
+ import {
17
+ renderMessages
18
+ } from "./chunk-7IFO43Q5.js";
19
19
  import {
20
20
  holdLock,
21
21
  lockPath,
22
22
  releaseLock,
23
23
  servingProfiles,
24
24
  takeLock
25
- } from "./chunk-GGS6D4W4.js";
25
+ } from "./chunk-SXZGCD6E.js";
26
26
  import {
27
27
  FETCHING,
28
28
  RULES_VERSION,
@@ -35,11 +35,12 @@ import {
35
35
  onlineDeps,
36
36
  openRequestTask,
37
37
  patiently,
38
+ refuseLockedOutput,
38
39
  senderIsMe,
39
40
  servicesFor,
40
41
  syncsOneChat,
41
42
  withTimeLimit
42
- } from "./chunk-DK6ICIGL.js";
43
+ } from "./chunk-5X4IY5JH.js";
43
44
  import {
44
45
  QUICK_HEALTH_CHECKS,
45
46
  fts5Tables,
@@ -47,40 +48,10 @@ import {
47
48
  lossUnknown,
48
49
  storeDamageReport,
49
50
  storeHealth
50
- } from "./chunk-ZVI6TFQR.js";
51
- import {
52
- Command,
53
- LOCAL_READ,
54
- LOCAL_WRITE,
55
- REMOTE_READ,
56
- REMOTE_WRITE,
57
- annotate,
58
- destroysNothing,
59
- environmentOf,
60
- itemOf,
61
- jsonlRecords,
62
- lineOf,
63
- listOf,
64
- nextStep,
65
- outputFor,
66
- recalledAccount,
67
- recordLogFor,
68
- renderAnswer,
69
- snakeKeys,
70
- storeTable,
71
- withoutProviderRefs
72
- } from "./chunk-DSVZEXYJ.js";
51
+ } from "./chunk-ZVFYGTGJ.js";
73
52
  import {
74
- holdersOf
75
- } from "./chunk-ALIT5QFT.js";
76
- import {
77
- codeOf,
78
- modelTarget,
79
- parseDuration
80
- } from "./chunk-OHWMIUCT.js";
81
- import {
82
- levelFor
83
- } from "./chunk-Q5PI72CR.js";
53
+ readSecret
54
+ } from "./chunk-I7CUMZD6.js";
84
55
  import {
85
56
  CORPORA,
86
57
  MIGRATIONS,
@@ -115,44 +86,87 @@ import {
115
86
  storeClients,
116
87
  storeContents,
117
88
  vectorIndexCounts
118
- } from "./chunk-FSHCAWZS.js";
89
+ } from "./chunk-24OFZNRC.js";
90
+ import {
91
+ openCache
92
+ } from "./chunk-RN5SU2RN.js";
93
+ import {
94
+ Command,
95
+ LOCAL_READ,
96
+ LOCAL_WRITE,
97
+ REMOTE_READ,
98
+ REMOTE_WRITE,
99
+ annotate,
100
+ commandAt,
101
+ destroysNothing,
102
+ environmentOf,
103
+ itemOf,
104
+ jsonlRecords,
105
+ lineOf,
106
+ listOf,
107
+ nextStep,
108
+ outputFor,
109
+ recalledAccount,
110
+ recordLogFor,
111
+ renderAnswer,
112
+ snakeKeys,
113
+ storeTable,
114
+ withoutProviderRefs
115
+ } from "./chunk-7OD3522V.js";
116
+ import {
117
+ holdersOf
118
+ } from "./chunk-IACWKZWS.js";
119
+ import {
120
+ codeOf,
121
+ modelTarget,
122
+ parseDuration
123
+ } from "./chunk-JAEPK457.js";
124
+ import {
125
+ levelFor
126
+ } from "./chunk-LA6QUVGQ.js";
127
+ import {
128
+ modelAddressAllowed,
129
+ onThisComputer
130
+ } from "./chunk-K6HR6HCO.js";
119
131
  import {
120
132
  currentRun,
121
133
  readDamageMark,
122
134
  readHealthMark,
123
135
  readJournalMark,
124
136
  recordDeepCheck
125
- } from "./chunk-USQ23X5V.js";
137
+ } from "./chunk-5MGICK47.js";
126
138
  import {
127
139
  failureKey,
128
140
  isStoreDamage
129
- } from "./chunk-MEED7YFG.js";
141
+ } from "./chunk-WZGKHTA4.js";
130
142
  import {
131
143
  formatLocator,
132
144
  parseLocator
133
- } from "./chunk-XI3VIQKW.js";
145
+ } from "./chunk-VIV64MQM.js";
134
146
  import {
135
- readSecret
136
- } from "./chunk-RN4EHCC5.js";
147
+ readSharedSection,
148
+ sharedConfigPath,
149
+ writeSharedSection
150
+ } from "./chunk-IU4DUUB3.js";
137
151
  import {
138
152
  storePath
139
- } from "./chunk-KMV7GZB6.js";
140
- import {
141
- openCache
142
- } from "./chunk-BGTEVIW4.js";
153
+ } from "./chunk-3KRTEX5M.js";
143
154
  import {
144
155
  queryFieldsOf
145
- } from "./chunk-EOSVN2ER.js";
156
+ } from "./chunk-63QXCE5Z.js";
146
157
  import {
158
+ Credentials,
159
+ isMovedRun,
147
160
  resolvePaths,
148
161
  writeSecurely
149
- } from "./chunk-OORMSM6O.js";
162
+ } from "./chunk-S7SXSHRC.js";
150
163
  import {
151
164
  array,
152
165
  boolean,
153
166
  check,
154
167
  forward,
155
168
  getDotPath,
169
+ maxLength,
156
170
  minLength,
157
171
  nullable,
158
172
  object,
@@ -167,10 +181,10 @@ import {
167
181
  string,
168
182
  transform,
169
183
  trim
170
- } from "./chunk-WOIHSQAL.js";
184
+ } from "./chunk-UVZLK3M4.js";
171
185
  import {
172
186
  CliError
173
- } from "./chunk-FEM2JQN2.js";
187
+ } from "./chunk-ELJUBPY4.js";
174
188
  import {
175
189
  __commonJS,
176
190
  __name,
@@ -5510,11 +5524,11 @@ var require_liquid_node = __commonJS({
5510
5524
  }
5511
5525
  });
5512
5526
 
5513
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5527
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5514
5528
  import { chmodSync, constants, copyFileSync, existsSync as existsSync10, mkdirSync, realpathSync as realpathSync3, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
5515
5529
  import { dirname as dirname3, resolve } from "node:path";
5516
5530
 
5517
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/sealed.js
5531
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/sealed.js
5518
5532
  import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
5519
5533
  import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
5520
5534
  import { Transform } from "node:stream";
@@ -5621,7 +5635,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
5621
5635
  renameSync(pending, to);
5622
5636
  }, "unsealFile");
5623
5637
 
5624
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5638
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5625
5639
  var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
5626
5640
  var fileSchemaOf = /* @__PURE__ */ __name((database) => {
5627
5641
  const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
@@ -5645,7 +5659,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
5645
5659
  };
5646
5660
  }, "compatibilityOf");
5647
5661
 
5648
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/repair.js
5662
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/repair.js
5649
5663
  import { createHash as createHash2 } from "node:crypto";
5650
5664
  var COPY_MARK = "__repair_";
5651
5665
  var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
@@ -5899,19 +5913,19 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
5899
5913
  return found;
5900
5914
  }, "deleteCopy");
5901
5915
 
5902
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5916
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5903
5917
  import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
5904
5918
 
5905
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
5919
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
5906
5920
  import { existsSync as existsSync3 } from "node:fs";
5907
5921
 
5908
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/recover.js
5922
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/recover.js
5909
5923
  import { execFileSync, spawn } from "node:child_process";
5910
5924
  import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
5911
5925
  import { basename, dirname, join } from "node:path";
5912
5926
  import { Transform as Transform2 } from "node:stream";
5913
5927
 
5914
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/refill.js
5928
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/refill.js
5915
5929
  var REFILL_MARGIN_MS = 864e5;
5916
5930
  var TIME_KEYS = 1e12;
5917
5931
  var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
@@ -5991,7 +6005,7 @@ var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
5991
6005
  return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
5992
6006
  }, "forgetMail");
5993
6007
 
5994
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/store/recover.js
6008
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/recover.js
5995
6009
  var SQLITE3_MINIMUM = [3, 43, 0];
5996
6010
  var STORE_PARTS = ["", "-wal", "-shm"];
5997
6011
  var RECOVER_LOCK = ".recover-lock";
@@ -6519,7 +6533,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
6519
6533
  }
6520
6534
  }, "recoverLocked");
6521
6535
 
6522
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
6536
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
6523
6537
  var COUNTED = [
6524
6538
  "accounts",
6525
6539
  "chats",
@@ -6675,7 +6689,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
6675
6689
  return recover;
6676
6690
  }, "storeRecoverCommand");
6677
6691
 
6678
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
6692
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-info.js
6679
6693
  var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
6680
6694
  var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
6681
6695
  var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
@@ -6725,7 +6739,7 @@ var sharedStoreCommand = /* @__PURE__ */ __name((app) => {
6725
6739
  return app ? store.addCommand(storeRecoverCommand(app)) : store;
6726
6740
  }, "sharedStoreCommand");
6727
6741
 
6728
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
6742
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
6729
6743
  var ENCRYPT_OPTION = [
6730
6744
  "--encrypt",
6731
6745
  "compress and encrypt with a password, typed at a hidden prompt or piped on stdin; it is never kept \u2014 lose it and the file cannot be opened"
@@ -6744,7 +6758,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
6744
6758
  return password;
6745
6759
  }, "passwordOf");
6746
6760
 
6747
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/rules.js
6761
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/rules.js
6748
6762
  import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
6749
6763
  import { join as join2 } from "node:path";
6750
6764
  var REPLY_ACTIONS = ["reply", "task"];
@@ -6915,7 +6929,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
6915
6929
  }, "problem");
6916
6930
  var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
6917
6931
 
6918
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/state.js
6932
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/state.js
6919
6933
  import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
6920
6934
  import { join as join3 } from "node:path";
6921
6935
  var ANSWERED_KEPT = 1e3;
@@ -6968,7 +6982,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
6968
6982
  }, "recordReply");
6969
6983
  var broken2 = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply state ${path} cannot be read (${why}) \u2014 fix or move the file`), "broken");
6970
6984
 
6971
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/decide.js
6985
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/decide.js
6972
6986
  var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
6973
6987
  var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
6974
6988
  const { message, chat, owner, sender } = incoming;
@@ -7074,10 +7088,10 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
7074
7088
  return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
7075
7089
  }, "filled");
7076
7090
 
7077
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/template.js
7091
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/template.js
7078
7092
  var import_liquidjs2 = __toESM(require_liquid_node(), 1);
7079
7093
 
7080
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/render/liquid.js
7094
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/render/liquid.js
7081
7095
  var import_liquidjs = __toESM(require_liquid_node(), 1);
7082
7096
  var safeLiquid = /* @__PURE__ */ __name((limits) => {
7083
7097
  const engine = new import_liquidjs.Liquid({
@@ -7104,7 +7118,7 @@ var safeLiquid = /* @__PURE__ */ __name((limits) => {
7104
7118
  return engine;
7105
7119
  }, "safeLiquid");
7106
7120
 
7107
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/template.js
7121
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/template.js
7108
7122
  var TEMPLATE_LIMITS = {
7109
7123
  parse: 32768,
7110
7124
  renders: 2e3,
@@ -7243,7 +7257,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
7243
7257
  }
7244
7258
  }, "renderReplyTemplate");
7245
7259
 
7246
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
7260
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
7247
7261
  var DRY_RUN_DAYS = 7;
7248
7262
  var PAGE = 500;
7249
7263
  var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
@@ -7357,7 +7371,192 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
7357
7371
  }
7358
7372
  }, "storedSince");
7359
7373
 
7360
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/consents.js
7374
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/models/ai.js
7375
+ var AI_PROVIDERS = ["anthropic", "openai", "ollama"];
7376
+ var DEFAULT_BASE_URL = {
7377
+ anthropic: "https://api.anthropic.com",
7378
+ openai: "https://api.openai.com/v1",
7379
+ ollama: "http://127.0.0.1:11434/v1"
7380
+ };
7381
+ var OFFICIAL = {
7382
+ "https://api.openai.com": "openai",
7383
+ "https://api.anthropic.com": "anthropic"
7384
+ };
7385
+ var SECTION = "ai";
7386
+ var aiAddressAllowed = modelAddressAllowed;
7387
+ var consentShape = strictObject({
7388
+ origin: string(),
7389
+ model: string(),
7390
+ at: string()
7391
+ });
7392
+ var settingShape = strictObject({
7393
+ provider: picklist(AI_PROVIDERS),
7394
+ model: pipe(string(), trim(), minLength(1), maxLength(200)),
7395
+ base_url: optional(pipe(string(), check(aiAddressAllowed, "use https, or http only on this computer"))),
7396
+ images: optional(consentShape)
7397
+ });
7398
+ var aiSettingPath = /* @__PURE__ */ __name((env) => sharedConfigPath(storePath(env), env), "aiSettingPath");
7399
+ var readAiSetting = /* @__PURE__ */ __name((path) => {
7400
+ const section = readSharedSection(path, SECTION);
7401
+ if (section === void 0)
7402
+ return void 0;
7403
+ const checked = safeParse(settingShape, section);
7404
+ if (!checked.success)
7405
+ throw new CliError("configuration_error", `${path}: ai.${getDotPath(checked.issues[0]) ?? "setting"} is invalid`, {
7406
+ reason: "ai.setting-invalid"
7407
+ });
7408
+ return checked.output;
7409
+ }, "readAiSetting");
7410
+ var writeAiSetting = /* @__PURE__ */ __name((path, setting) => writeSharedSection(path, SECTION, setting), "writeAiSetting");
7411
+ var aiSettingOf = /* @__PURE__ */ __name((given) => {
7412
+ const draft = {
7413
+ provider: given.provider,
7414
+ model: given.model,
7415
+ ...given.baseUrl?.trim() ? { base_url: given.baseUrl.trim().replace(/\/+$/, "") } : {}
7416
+ };
7417
+ const checked = safeParse(settingShape, draft);
7418
+ if (!checked.success) {
7419
+ const field = getDotPath(checked.issues[0]);
7420
+ throw new CliError("validation_error", field === "provider" ? `the provider is one of ${AI_PROVIDERS.join(", ")}` : field === "base_url" ? "this address is not allowed: use https, or http only on this computer" : "name the model, 1 to 200 characters", { reason: field === "base_url" ? "ai.address-refused" : "ai.setting-invalid" });
7421
+ }
7422
+ if (checked.output.provider === "ollama" && !onThisComputer(aiBaseUrl(checked.output)))
7423
+ throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "ai.address-refused" });
7424
+ return given.allowImages ? {
7425
+ ...checked.output,
7426
+ images: { origin: aiOrigin(checked.output), model: checked.output.model, at: (/* @__PURE__ */ new Date()).toISOString() }
7427
+ } : checked.output;
7428
+ }, "aiSettingOf");
7429
+ var aiBaseUrl = /* @__PURE__ */ __name((setting) => setting.base_url ?? DEFAULT_BASE_URL[setting.provider], "aiBaseUrl");
7430
+ var aiOrigin = /* @__PURE__ */ __name((setting) => new URL(aiBaseUrl(setting)).origin, "aiOrigin");
7431
+ var aiTarget = /* @__PURE__ */ __name((setting) => ({
7432
+ provider: setting.provider === "anthropic" ? "anthropic" : "openai",
7433
+ model: setting.model,
7434
+ baseUrl: aiBaseUrl(setting)
7435
+ }), "aiTarget");
7436
+ var aiImagesAllowed = /* @__PURE__ */ __name((setting) => setting.images?.origin === aiOrigin(setting) && setting.images.model === setting.model, "aiImagesAllowed");
7437
+ var aiKeys = /* @__PURE__ */ __name((app, env, keyring) => {
7438
+ const where = { appName: "WireCat", prefix: "WIRECAT", env };
7439
+ const credentials = new Credentials({
7440
+ configDir: resolvePaths(where).config,
7441
+ service: "WireCat",
7442
+ // A tool run with its own folders moved (MEMO_CONFIG_DIR…) is a test or a sandbox, not the owner.
7443
+ isolated: isMovedRun(where) || isMovedRun({ appName: app.appName, prefix: app.envPrefix, env }),
7444
+ env,
7445
+ ...keyring ? { keyring } : {},
7446
+ warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
7447
+ `), "warn")
7448
+ });
7449
+ const account = /* @__PURE__ */ __name((origin) => `ai:${origin}`, "account");
7450
+ return {
7451
+ read: /* @__PURE__ */ __name((origin) => {
7452
+ const stored = credentials.read(account(origin));
7453
+ if (stored)
7454
+ return { key: stored.secret, source: stored.source };
7455
+ const official = OFFICIAL[origin];
7456
+ const legacy = official ?? (origin.startsWith("https://") ? endpointKeyName(origin) : void 0);
7457
+ const found = legacy === void 0 ? void 0 : embeddingKeys(app, env, keyring).read(legacy);
7458
+ return found ? { key: found.key, source: found.source === "env" ? "environment" : found.source } : void 0;
7459
+ }, "read"),
7460
+ write: /* @__PURE__ */ __name((origin, key) => credentials.write(account(origin), key, { signIn: true }), "write"),
7461
+ remove: /* @__PURE__ */ __name((origin) => credentials.remove(account(origin)), "remove")
7462
+ };
7463
+ }, "aiKeys");
7464
+ var aiNeedsKey = /* @__PURE__ */ __name((setting) => aiLeavesComputer(setting), "aiNeedsKey");
7465
+ var aiTakesKey = /* @__PURE__ */ __name((setting) => setting.provider !== "ollama", "aiTakesKey");
7466
+ var keyFor = /* @__PURE__ */ __name((setting, deps) => aiTakesKey(setting) ? aiKeys(deps.app, deps.env, deps.keyring).read(aiOrigin(setting))?.key : void 0, "keyFor");
7467
+ var gatewayFor = /* @__PURE__ */ __name((setting, deps, key) => modelGateway({
7468
+ resolve: /* @__PURE__ */ __name(() => aiTarget(setting), "resolve"),
7469
+ consent: /* @__PURE__ */ __name(() => true, "consent"),
7470
+ key: /* @__PURE__ */ __name(() => key, "key"),
7471
+ env: deps.env,
7472
+ ...deps.fetch ? { fetch: deps.fetch } : {},
7473
+ ...deps.signal ? { signal: deps.signal } : {}
7474
+ }), "gatewayFor");
7475
+ var aiLeavesComputer = /* @__PURE__ */ __name((setting) => !onThisComputer(aiBaseUrl(setting)), "aiLeavesComputer");
7476
+ var sharedModel = /* @__PURE__ */ __name((deps) => {
7477
+ const setting = readAiSetting(aiSettingPath(deps.env));
7478
+ if (!setting)
7479
+ return void 0;
7480
+ return { target: { ...aiTarget(setting), baseUrl: aiBaseUrl(setting) }, key: keyFor(setting, deps), setting };
7481
+ }, "sharedModel");
7482
+ var aiTextReader = /* @__PURE__ */ __name((deps) => {
7483
+ const setting = readAiSetting(aiSettingPath(deps.env));
7484
+ if (!setting)
7485
+ return { refused: "ai.not-set" };
7486
+ const key = keyFor(setting, deps);
7487
+ if (aiNeedsKey(setting) && !key)
7488
+ return { refused: "ai.key-missing" };
7489
+ const gateway = gatewayFor(setting, deps, key);
7490
+ return {
7491
+ by: `${setting.provider}/${setting.model}`,
7492
+ leavesComputer: aiLeavesComputer(setting),
7493
+ complete: /* @__PURE__ */ __name(async (request) => (await gateway.complete(request)).text, "complete")
7494
+ };
7495
+ }, "aiTextReader");
7496
+ var reasonOf = /* @__PURE__ */ __name((error) => {
7497
+ if (!(error instanceof CliError))
7498
+ return "ai.failed";
7499
+ if (error.code === "rate_limited")
7500
+ return "ai.rate-limited";
7501
+ const { reason, status } = error.details;
7502
+ if (reason === "model.key-rejected")
7503
+ return "ai.key-rejected";
7504
+ if (reason === "model.unreachable")
7505
+ return "ai.unreachable";
7506
+ if (reason === "model.empty-answer")
7507
+ return "ai.empty-answer";
7508
+ if (status === 402)
7509
+ return "ai.no-credit";
7510
+ if (status === 404)
7511
+ return "ai.model-unknown";
7512
+ if (typeof status === "number" && status >= 500)
7513
+ return "ai.provider-error";
7514
+ return "ai.failed";
7515
+ }, "reasonOf");
7516
+ var checkAi = /* @__PURE__ */ __name(async (deps) => {
7517
+ const setting = readAiSetting(aiSettingPath(deps.env));
7518
+ if (!setting)
7519
+ return { ok: false, reason: "ai.not-set", ms: null };
7520
+ const key = keyFor(setting, deps);
7521
+ if (aiNeedsKey(setting) && !key)
7522
+ return { ok: false, reason: "ai.key-missing", ms: null };
7523
+ const started = Date.now();
7524
+ try {
7525
+ await gatewayFor(setting, deps, key).complete({
7526
+ purpose: "check",
7527
+ system: "Reply with the word OK.",
7528
+ prompt: "OK?",
7529
+ // Reasoning models spend tokens before they answer; too low a cap reads as a broken setup.
7530
+ maxTokens: 2048
7531
+ });
7532
+ return { ok: true, reason: "ai.ok", ms: Date.now() - started };
7533
+ } catch (error) {
7534
+ return { ok: false, reason: reasonOf(error), ms: null };
7535
+ }
7536
+ }, "checkAi");
7537
+
7538
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/models/purpose.js
7539
+ var HOSTED = {
7540
+ openai: "https://api.openai.com/v1",
7541
+ anthropic: "https://api.anthropic.com"
7542
+ };
7543
+ var purposeModel = /* @__PURE__ */ __name((settings, purpose, deps) => {
7544
+ const configured = modelTarget(settings, purpose);
7545
+ if (configured) {
7546
+ const baseUrl = configured.baseUrl ?? HOSTED[configured.provider] ?? "";
7547
+ return {
7548
+ target: { ...configured, baseUrl },
7549
+ key: /* @__PURE__ */ __name(() => embeddingKeys(deps.app, deps.env, deps.keyring).read(configured.baseUrl === void 0 ? configured.provider : endpointKeyName(configured.baseUrl))?.key, "key")
7550
+ };
7551
+ }
7552
+ const provider = settings.models?.[purpose]?.provider ?? settings.models?.default?.provider;
7553
+ if (provider === "off")
7554
+ return void 0;
7555
+ const shared = sharedModel(deps);
7556
+ return shared ? { target: shared.target, key: /* @__PURE__ */ __name(() => shared.key, "key"), shared: shared.setting } : void 0;
7557
+ }, "purposeModel");
7558
+
7559
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/consents.js
7361
7560
  import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
7362
7561
  import { join as join4 } from "node:path";
7363
7562
  var shape = strictObject({
@@ -7382,19 +7581,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
7382
7581
  return consent.provider === provider && !consent.deniedChats.includes(chat);
7383
7582
  }, "mayModelReply");
7384
7583
 
7385
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/rendering.js
7584
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/rendering.js
7386
7585
  var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
7387
7586
  ai: true
7388
7587
  }) => async (rule2, message, chat, now) => {
7588
+ const deps = { app, env, keyring: options.keyring };
7389
7589
  let called;
7390
7590
  const gateway = modelGateway({
7391
7591
  signal: options.signal,
7592
+ env,
7392
7593
  resolve: /* @__PURE__ */ __name((purpose) => {
7393
- called = modelTarget(settings(), purpose);
7394
- return called;
7594
+ called = purposeModel(settings(), purpose, deps);
7595
+ return called?.target;
7395
7596
  }, "resolve"),
7396
7597
  consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
7397
- key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env, options.keyring).read(target.baseUrl === void 0 ? provider : endpointKeyName(target.baseUrl))?.key, "key")
7598
+ key: /* @__PURE__ */ __name(() => called?.key(), "key")
7398
7599
  });
7399
7600
  if (options.signal?.aborted)
7400
7601
  throw new CliError("cancelled", "reply rendering cancelled");
@@ -7416,9 +7617,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
7416
7617
  });
7417
7618
  if (options.signal?.aborted)
7418
7619
  throw new CliError("cancelled", "reply rendering cancelled");
7419
- const current = modelTarget(settings(), "replies");
7420
- const baseUrl = called?.baseUrl ?? (called?.provider === "anthropic" ? "https://api.anthropic.com" : "https://api.openai.com/v1");
7421
- if (!called || JSON.stringify(current) !== JSON.stringify(called) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.provider, baseUrl), message.chatId)) {
7620
+ const current = purposeModel(settings(), "replies", deps)?.target;
7621
+ if (!called || JSON.stringify(current) !== JSON.stringify(called.target) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.target.provider, called.target.baseUrl), message.chatId)) {
7422
7622
  throw new CliError("permission_error", "reply model consent or configuration changed during rendering");
7423
7623
  }
7424
7624
  return result3;
@@ -7429,7 +7629,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
7429
7629
  return result2;
7430
7630
  }, "replyRenderer");
7431
7631
 
7432
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/replies/serve.js
7632
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/serve.js
7433
7633
  var NOT_ALLOWED = "replies.send is not allow";
7434
7634
  var NO_RULES = "no rules";
7435
7635
  var ONLY_TASK = "opened a task, sent nothing";
@@ -7522,7 +7722,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
7522
7722
  return { skip: why };
7523
7723
  }, "replyTo");
7524
7724
 
7525
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
7725
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
7526
7726
  var START_SYNC_DELAY_MS = 3e4;
7527
7727
  var START_SYNC_BUDGET_MS = 5 * 6e4;
7528
7728
  var START_SYNC_WINDOW_MS = 7 * 864e5;
@@ -7599,7 +7799,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn,
7599
7799
  };
7600
7800
  }, "startSync");
7601
7801
 
7602
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
7802
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
7603
7803
  var FIRST_FETCH_MS = 6e4;
7604
7804
  var DAY_MS = 864e5;
7605
7805
  var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
@@ -7653,7 +7853,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs =
7653
7853
  };
7654
7854
  }, "memberFetches");
7655
7855
 
7656
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
7856
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
7657
7857
  var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
7658
7858
  var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
7659
7859
  if (context.format === "pretty") {
@@ -7686,7 +7886,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
7686
7886
  return context;
7687
7887
  }, "recordDiagnostics");
7688
7888
 
7689
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
7889
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
7690
7890
  import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
7691
7891
  import { dirname as dirname2, join as join5 } from "node:path";
7692
7892
  var OUTDATED_CHECK_MS = 6e4;
@@ -7772,7 +7972,7 @@ var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs
7772
7972
  };
7773
7973
  }, "watchOutdated");
7774
7974
 
7775
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7975
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7776
7976
  var STEMS_EVERY_MS = 3e4;
7777
7977
  var STEMS_SLICE_MS = 2e3;
7778
7978
  var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
@@ -7812,7 +8012,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
7812
8012
  };
7813
8013
  }, "stemFills");
7814
8014
 
7815
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
8015
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7816
8016
  var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
7817
8017
  var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
7818
8018
  kind: attachment.kind,
@@ -7824,6 +8024,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
7824
8024
  width: attachment.width,
7825
8025
  height: attachment.height,
7826
8026
  duration: attachment.duration,
8027
+ local_path: attachment.localPath,
7827
8028
  contact: attachment.contact && defined({
7828
8029
  name: attachment.contact.name,
7829
8030
  first_name: attachment.contact.firstName,
@@ -7907,7 +8108,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
7907
8108
  locale: messenger.app.locale
7908
8109
  }), "viewOf");
7909
8110
 
7910
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
8111
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7911
8112
  var observed = /* @__PURE__ */ __name((value) => ({
7912
8113
  value: value.value,
7913
8114
  observed_at: value.observedAt,
@@ -7974,7 +8175,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
7974
8175
  }
7975
8176
  }, "watchEventItem");
7976
8177
 
7977
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
8178
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7978
8179
  var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
7979
8180
  output: { entity: "watch_item" },
7980
8181
  effects: REMOTE_READ,
@@ -8129,7 +8330,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
8129
8330
  }
8130
8331
  }, "describe");
8131
8332
 
8132
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
8333
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
8133
8334
  var serveCommand = /* @__PURE__ */ __name((messenger) => {
8134
8335
  const command = annotate(new Command("serve"), {
8135
8336
  output: { entity: "serve_summary" },
@@ -8412,7 +8613,7 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
8412
8613
  };
8413
8614
  }, "tasking");
8414
8615
 
8415
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
8616
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
8416
8617
  import { existsSync as existsSync9 } from "node:fs";
8417
8618
  var PATH = "store tables list";
8418
8619
  var STORE_TABLES_QUERY = {
@@ -8429,14 +8630,14 @@ var filterOf = /* @__PURE__ */ __name((words) => {
8429
8630
  const kind = terms.get("kind");
8430
8631
  return { ...name === void 0 ? {} : { name }, ...kind === void 0 ? {} : { kind } };
8431
8632
  }, "filterOf");
8432
- var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
8433
- const tables = new Command("tables").description("the tables of the local archive");
8633
+ var storeTablesCommand = /* @__PURE__ */ __name((owner) => {
8634
+ const tables = new Command("tables").description("the tables of the local store");
8434
8635
  withQuery(annotate(tables.command("list"), {
8435
8636
  effects: LOCAL_READ,
8436
8637
  examples: [
8437
- `${messenger.app.command} store tables list`,
8438
- `${messenger.app.command} store tables list kind:data`,
8439
- `${messenger.app.command} store tables list --full --json`
8638
+ `${owner.app.command} store tables list`,
8639
+ `${owner.app.command} store tables list kind:data`,
8640
+ `${owner.app.command} store tables list --full --json`
8440
8641
  ]
8441
8642
  }), STORE_TABLES_QUERY).summary("every table of the local archive, with its kind and row count").description("every table of the local archive: its kind (data, search index, part of a search index, internal) and its rows, a search index's rows not counted; --full adds each table's size on disk, which reads the whole file (about ten seconds for 3 GB); changes nothing").action(async function(words) {
8442
8643
  const filter = filterOf(words);
@@ -8455,7 +8656,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
8455
8656
  return tables;
8456
8657
  }, "storeTablesCommand");
8457
8658
 
8458
- // node_modules/.pnpm/@wirecat+cli-core@0.620.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_737712cd0065e7e21fd5896a79d0773d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
8659
+ // node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
8459
8660
  var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
8460
8661
  var WORD_INDEX = "message_words";
8461
8662
  var schemaOf = /* @__PURE__ */ __name((database) => {
@@ -8540,27 +8741,52 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
8540
8741
  }
8541
8742
  }, "storeSummary");
8542
8743
  var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
8543
- var storeMaintenanceCommands = /* @__PURE__ */ __name((messenger) => [
8744
+ var chatty = /* @__PURE__ */ __name((owner) => owner.provider !== void 0, "chatty");
8745
+ var archive = /* @__PURE__ */ __name((owner) => chatty(owner) ? "local archive" : "local store", "archive");
8746
+ var createdBy = /* @__PURE__ */ __name((owner) => chatty(owner) ? `the first \`${owner.app.command}\` command that reads a chat creates it` : `the first \`${owner.app.command}\` command that saves anything creates it`, "createdBy");
8747
+ var storeMaintenanceCommands = /* @__PURE__ */ __name((owner) => [
8544
8748
  storeInfoCommand(),
8545
- checkCommand(messenger),
8546
- migrateCommand(messenger),
8547
- reindexCommand(messenger),
8749
+ checkCommand(owner),
8750
+ migrateCommand(owner),
8751
+ reindexCommand(owner),
8548
8752
  backupCommand(),
8549
- restoreCommand(messenger),
8753
+ restoreCommand(owner),
8550
8754
  decryptCommand(),
8551
- repairCommand(messenger),
8552
- resetCommand(messenger),
8755
+ repairCommand(owner),
8756
+ resetCommand(owner),
8553
8757
  copiesCommand(),
8554
- storeTablesCommand(messenger),
8555
- storeRecoverCommand({ command: messenger.app.command, version: messenger.app.version })
8758
+ storeTablesCommand(owner),
8759
+ storeRecoverCommand({ command: owner.app.command, version: owner.app.version })
8556
8760
  ], "storeMaintenanceCommands");
8557
- var refuseWhileServing = /* @__PURE__ */ __name((command, messenger) => {
8558
- const serving = servingProfiles(messenger.app, environmentOf(command).env ?? process.env);
8761
+ var EXAMPLES = {
8762
+ backup: "./backup.db",
8763
+ check: "",
8764
+ "copies delete": "messages_copy_1",
8765
+ decrypt: "./backup.enc --output ./restored.db",
8766
+ info: "",
8767
+ migrate: "",
8768
+ rebuild: "",
8769
+ repair: "--dry-run",
8770
+ reset: "",
8771
+ restore: "./backup.db"
8772
+ };
8773
+ var addStoreMaintenanceCommands = /* @__PURE__ */ __name((store, owner, profile) => {
8774
+ for (const command of storeMaintenanceCommands(owner))
8775
+ store.addCommand(command);
8776
+ for (const [path, args] of Object.entries(EXAMPLES)) {
8777
+ const command = commandAt(store, path);
8778
+ if (command)
8779
+ annotate(command, { examples: [`${owner.app.command} ${profile} store ${path} ${args}`.trimEnd()] });
8780
+ }
8781
+ return store;
8782
+ }, "addStoreMaintenanceCommands");
8783
+ var refuseWhileServing = /* @__PURE__ */ __name((command, owner) => {
8784
+ const serving = servingProfiles(owner.app, environmentOf(command).env ?? process.env);
8559
8785
  if (serving.length > 0) {
8560
- throw new CliError("validation_error", `${messenger.app.command} serve is running for ${serving.join(", ")} \u2014 ${serving.map((profile) => `\`${messenger.app.command} ${profile} server stop\``).join(", ")} first`);
8786
+ throw new CliError("validation_error", `${owner.app.command} serve is running for ${serving.join(", ")} \u2014 ${serving.map((profile) => `\`${owner.app.command} ${profile} server stop\``).join(", ")} first`);
8561
8787
  }
8562
8788
  }, "refuseWhileServing");
8563
- var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("repair"), { output: { entity: "store_repair" }, effects: LOCAL_WRITE }).summary("repair table shapes while keeping the old tables").description("bring every table to this build's shape, deleting nothing: a table of the wrong shape is kept as a copy beside a new one").option("--dry-run", "say what it would do, and change nothing").action(async function() {
8789
+ var repairCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("repair"), { output: { entity: "store_repair" }, effects: LOCAL_WRITE }).summary("repair table shapes while keeping the old tables").description("bring every table to this build's shape, deleting nothing: a table of the wrong shape is kept as a copy beside a new one").option("--dry-run", "say what it would do, and change nothing").action(async function() {
8564
8790
  const { renderer, format } = outputFor(this);
8565
8791
  const { dryRun: dryRun2 } = this.opts();
8566
8792
  const path = storePath(environmentOf(this).env ?? process.env);
@@ -8569,13 +8795,13 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
8569
8795
  return;
8570
8796
  }
8571
8797
  if (!dryRun2)
8572
- refuseWhileServing(this, messenger);
8798
+ refuseWhileServing(this, owner);
8573
8799
  const fresh = await openCache(":memory:");
8574
8800
  try {
8575
8801
  const report = await reading(path, (database) => repairStore(database, fresh, { dryRun: dryRun2 === true }));
8576
8802
  result(this, { path, ...report });
8577
8803
  if (format === "pretty")
8578
- for (const note of notesOf(report, messenger.app.command))
8804
+ for (const note of notesOf(report, owner.app.command))
8579
8805
  renderer.note(note);
8580
8806
  } finally {
8581
8807
  fresh.close();
@@ -8609,7 +8835,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
8609
8835
  const deleted = await reading(path, (database) => deleteCopy(database, name));
8610
8836
  result(this, { path, deleted });
8611
8837
  })), "copiesCommand");
8612
- var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary("check the local archive for problems").description("whether the store is healthy \u2014 integrity, search indexes, disk, and which chats are behind").action(async function() {
8838
+ var checkCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary(`check the ${archive(owner)} for problems`).description(`whether the store is healthy \u2014 integrity, search indexes, disk${chatty(owner) ? ", and which chats are behind" : ""}`).action(async function() {
8613
8839
  const { renderer } = outputFor(this);
8614
8840
  const path = storePath(environmentOf(this).env ?? process.env);
8615
8841
  if (!existsSync10(path)) {
@@ -8623,7 +8849,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
8623
8849
  result(this, { path, exists: true, ok: false, opens: false, error: messageOf2(error) });
8624
8850
  return;
8625
8851
  }
8626
- const { command } = messenger.app;
8852
+ const { command } = owner.app;
8627
8853
  const next = /* @__PURE__ */ new Map();
8628
8854
  const step = /* @__PURE__ */ __name((id, args = {}) => {
8629
8855
  if (!next.has(id))
@@ -8639,10 +8865,10 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
8639
8865
  step("store.reindex");
8640
8866
  else if (stems && !stems.ready)
8641
8867
  step("store.migrate");
8642
- const behind = answer.chatsBehind.find((chat) => chat.provider === messenger.provider);
8643
- if (behind && messenger.history !== "store")
8868
+ const behind = answer.chatsBehind.find((chat) => chat.provider === owner.provider);
8869
+ if (behind && owner.history !== "store")
8644
8870
  step("messages.sync");
8645
- else if (behind && syncsOneChat(messenger))
8871
+ else if (behind && syncsOneChat(owner))
8646
8872
  step("messages.sync", { chat: behind.chat });
8647
8873
  result(this, answer, [...next.values()]);
8648
8874
  if (answer.schema.version < SPEAKS) {
@@ -8657,7 +8883,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
8657
8883
  renderer.note(`${orphans} pointers name a row that is gone or a type the store does not know \u2014 see orphan_pointers`);
8658
8884
  if (answer.vectors && answer.vectors.unused > 0)
8659
8885
  renderer.note(`${answer.vectors.unused} vectors belong to no text the store still holds \u2014 \`${command} store rebuild\` drops them`);
8660
- const older = answer.conversations.filter((chat) => chat.provider === messenger.provider && !chat.current).length;
8886
+ const older = answer.conversations.filter((chat) => chat.provider === owner.provider && !chat.current).length;
8661
8887
  if (older > 0) {
8662
8888
  renderer.note(`${older} chats' conversations were built by older rules \u2014 \`${command} conversations links rebuild --chat <chat>\``);
8663
8889
  }
@@ -8760,19 +8986,19 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
8760
8986
  held: row.held === null ? null : isoOf(row.held),
8761
8987
  refreshed: isoOf(row.refreshed)
8762
8988
  })), "chatsBehind");
8763
- var migrateCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary("migrate an older local archive").description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
8989
+ var migrateCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary(`migrate an older ${archive(owner)}`).description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
8764
8990
  const { renderer } = outputFor(this);
8765
8991
  const path = storePath(environmentOf(this).env ?? process.env);
8766
8992
  if (!existsSync10(path)) {
8767
8993
  result(this, { path, exists: false });
8768
- renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
8994
+ renderer.note(`no store yet \u2014 ${createdBy(owner)}`);
8769
8995
  return;
8770
8996
  }
8771
8997
  const answer = await reading(path, (database) => {
8772
8998
  const from = schemaOf(database).version;
8773
8999
  migrate(database, {
8774
- command: messenger.app.command,
8775
- version: messenger.app.version,
9000
+ command: owner.app.command,
9001
+ version: owner.app.version,
8776
9002
  rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
8777
9003
  });
8778
9004
  const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
@@ -8824,7 +9050,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
8824
9050
  note(`indexing ${pending} notes`);
8825
9051
  return { notesIndexed: drainNoteIndex(database, stemmerCache()) };
8826
9052
  }, "buildNoteIndex");
8827
- var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary("rebuild the local archive's search indexes").description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
9053
+ var reindexCommand = /* @__PURE__ */ __name((owner) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary(`rebuild the ${archive(owner)}'s search indexes`).description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
8828
9054
  const { renderer } = outputFor(this);
8829
9055
  const path = storePath(environmentOf(this).env ?? process.env);
8830
9056
  if (!existsSync10(path)) {
@@ -8869,6 +9095,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
8869
9095
  const { encrypt } = this.opts();
8870
9096
  const path = storePath(environmentOf(this).env ?? process.env);
8871
9097
  const target = resolve(file2);
9098
+ const { app, env } = environmentOf(this);
9099
+ if (app)
9100
+ refuseLockedOutput(target, app, env ?? process.env, "<file>");
8872
9101
  if (!existsSync10(path))
8873
9102
  throw new CliError("not_found", `no store at ${path} to back up`);
8874
9103
  if (existsSync10(target))
@@ -8913,37 +9142,37 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
8913
9142
  await unsealFile(from, to, await passwordOf(this, { twice: false }));
8914
9143
  result(this, { path: to, from, bytes: bytesOf2(to) });
8915
9144
  }), "decryptCommand");
8916
- var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup and keep the current store, or roll back a breaking upgrade").description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools cannot open), put its tables back in the store and return it to that version instead").argument("<file>", "a file `store backup` wrote, or a rollback copy; one written with --encrypt asks for its password").action(async function(file2) {
9145
+ var restoreCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup and keep the current store, or roll back a breaking upgrade").description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools cannot open), put its tables back in the store and return it to that version instead").argument("<file>", "a file `store backup` wrote, or a rollback copy; one written with --encrypt asks for its password").action(async function(file2) {
8917
9146
  const path = storePath(environmentOf(this).env ?? process.env);
8918
9147
  const given = resolve(file2);
8919
9148
  if (!existsSync10(given))
8920
9149
  throw new CliError("not_found", `no file at ${given}`);
8921
- refuseWhileServing(this, messenger);
9150
+ refuseWhileServing(this, owner);
8922
9151
  if (!isSealed(given))
8923
- return restoreFrom(this, messenger, given, given);
9152
+ return restoreFrom(this, owner, given, given);
8924
9153
  const opened = `${path}.unsealing-${process.pid}`;
8925
9154
  mkdirSync(dirname3(path), { recursive: true, mode: 448 });
8926
9155
  try {
8927
9156
  await unsealFile(given, opened, await passwordOf(this, { twice: false }));
8928
- await restoreFrom(this, messenger, opened, given);
9157
+ await restoreFrom(this, owner, opened, given);
8929
9158
  } finally {
8930
9159
  rmSync3(opened, { force: true });
8931
9160
  }
8932
9161
  }), "restoreCommand");
8933
- var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
9162
+ var restoreFrom = /* @__PURE__ */ __name(async (command, owner, backup, given) => {
8934
9163
  const { renderer } = outputFor(command);
8935
9164
  const path = storePath(environmentOf(command).env ?? process.env);
8936
9165
  if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
8937
9166
  throw new CliError("validation_error", `${backup} is the store itself`);
8938
9167
  }
8939
9168
  if (await isRollbackCopy(backup))
8940
- return rollBackFrom(command, messenger, backup);
9169
+ return rollBackFrom(command, owner, backup);
8941
9170
  const schema = await backupSchema(backup);
8942
9171
  const stamp = stampNow();
8943
9172
  const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
8944
9173
  if (kept) {
8945
9174
  const waitMs = environmentOf(command).storeLockWaitMs;
8946
- await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
9175
+ await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
8947
9176
  } else
8948
9177
  mkdirSync(dirname3(path), { recursive: true, mode: 448 });
8949
9178
  const incoming = `${path}.restoring-${stamp}`;
@@ -8971,13 +9200,13 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
8971
9200
  return false;
8972
9201
  }
8973
9202
  }, "isRollbackCopy");
8974
- var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
9203
+ var rollBackFrom = /* @__PURE__ */ __name(async (command, owner, copy) => {
8975
9204
  const { renderer } = outputFor(command);
8976
9205
  const path = storePath(environmentOf(command).env ?? process.env);
8977
9206
  if (!existsSync10(path))
8978
9207
  throw new CliError("not_found", `no store at ${path} to roll back`);
8979
9208
  const waitMs = environmentOf(command).storeLockWaitMs;
8980
- await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
9209
+ await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
8981
9210
  const { database } = await openSqlite(path);
8982
9211
  let rolled;
8983
9212
  try {
@@ -9022,8 +9251,8 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
9022
9251
  return schema;
9023
9252
  }, "backupSchema");
9024
9253
  var STORE_LOCK_WAIT_MS = 1e3;
9025
- var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
9026
- const { command } = messenger.app;
9254
+ var quiesce = /* @__PURE__ */ __name(async (path, owner, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
9255
+ const { command } = owner.app;
9027
9256
  const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
9028
9257
  const holders = holdersOf(files);
9029
9258
  if (holders === void 0) {
@@ -9045,21 +9274,21 @@ var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs
9045
9274
  database.close();
9046
9275
  }
9047
9276
  }, "quiesce");
9048
- var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("reset"), { output: { entity: "store_reset" }, effects: LOCAL_WRITE }).summary("back up the local archive and replace it with an empty one").description("back the store up beside itself, then delete it and start an empty one at this build's schema; asks first, or --yes").option("--no-backup", "delete the store without backing it up first").option("--dry-run", "list every table it would empty, with its rows, and delete nothing").action(async function({ backup: keep, dryRun: dryRun2 }) {
9277
+ var resetCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("reset"), { output: { entity: "store_reset" }, effects: LOCAL_WRITE }).summary(`back up the ${archive(owner)} and replace it with an empty one`).description("back the store up beside itself, then delete it and start an empty one at this build's schema; asks first, or --yes").option("--no-backup", "delete the store without backing it up first").option("--dry-run", "list every table it would empty, with its rows, and delete nothing").action(async function({ backup: keep, dryRun: dryRun2 }) {
9049
9278
  const { renderer } = outputFor(this);
9050
- const { command } = messenger.app;
9279
+ const { command } = owner.app;
9051
9280
  const env = environmentOf(this).env ?? process.env;
9052
9281
  const path = storePath(env);
9053
9282
  if (!existsSync10(path)) {
9054
9283
  result(this, { path, exists: false, reset: false });
9055
- renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
9284
+ renderer.note(`no store at ${path} \u2014 nothing to reset; ${createdBy(owner)}`);
9056
9285
  return;
9057
9286
  }
9058
9287
  if (dryRun2) {
9059
- result(this, await resetPreview(path, messenger, env, keep));
9288
+ result(this, await resetPreview(path, owner, env, keep));
9060
9289
  return;
9061
9290
  }
9062
- refuseWhileServing(this, messenger);
9291
+ refuseWhileServing(this, owner);
9063
9292
  if (this.optsWithGlobals().yes !== true) {
9064
9293
  const what = `this deletes the store at ${path} and starts an empty one, ${keep ? "after a backup beside it" : "with no backup"}`;
9065
9294
  const answer = await answerOf(this, `${what}. Go ahead? [y/N] `);
@@ -9068,7 +9297,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
9068
9297
  if (!/^\s*y(es)?\s*$/i.test(answer))
9069
9298
  throw new CliError("cancelled", "cancelled \u2014 the store is unchanged");
9070
9299
  }
9071
- await quiesce(path, messenger, "reset", (message) => renderer.warn(message), environmentOf(this).storeLockWaitMs);
9300
+ await quiesce(path, owner, "reset", (message) => renderer.warn(message), environmentOf(this).storeLockWaitMs);
9072
9301
  const backup = keep ? `${path}.backup-${stampNow()}` : null;
9073
9302
  let backedUp = null;
9074
9303
  if (backup) {
@@ -9094,10 +9323,10 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
9094
9323
  renderer.note(backup ? `the store is empty at schema ${schema}; \`${command} store restore ${backup}\` puts the old one back once a build can read it` : `the store is empty at schema ${schema}; there is no backup`);
9095
9324
  }), "resetCommand");
9096
9325
  var STORE_PARTS2 = ["", "-wal", "-shm"];
9097
- var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
9326
+ var resetPreview = /* @__PURE__ */ __name(async (path, owner, env, keep) => {
9098
9327
  const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
9099
9328
  const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
9100
- const serving = servingProfiles(messenger.app, env).length > 0;
9329
+ const serving = servingProfiles(owner.app, env).length > 0;
9101
9330
  const read = await readingOnly(path, (database) => ({
9102
9331
  schema: schemaOf(database).version,
9103
9332
  tables: emptiedTables(database)
@@ -9153,6 +9382,21 @@ export {
9153
9382
  DRY_RUN_DAYS,
9154
9383
  dryRun,
9155
9384
  senderFacts,
9385
+ AI_PROVIDERS,
9386
+ aiSettingPath,
9387
+ readAiSetting,
9388
+ writeAiSetting,
9389
+ aiSettingOf,
9390
+ aiBaseUrl,
9391
+ aiOrigin,
9392
+ aiImagesAllowed,
9393
+ aiKeys,
9394
+ aiTakesKey,
9395
+ aiLeavesComputer,
9396
+ sharedModel,
9397
+ aiTextReader,
9398
+ checkAi,
9399
+ purposeModel,
9156
9400
  replyConsentPathFor,
9157
9401
  readReplyConsent,
9158
9402
  writeReplyConsent,
@@ -9181,5 +9425,6 @@ export {
9181
9425
  serveCommand,
9182
9426
  storeSummary,
9183
9427
  storeMaintenanceCommands,
9428
+ addStoreMaintenanceCommands,
9184
9429
  buildStems
9185
9430
  };