@wirecat/drive-cli 0.65.0 → 0.67.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 (233) hide show
  1. package/contracts/wirecat.json +2899 -0
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bin/drive.js.map +1 -1
  4. package/dist/browse.d.ts +1 -1
  5. package/dist/browse.d.ts.map +1 -1
  6. package/dist/browse.js +1 -1
  7. package/dist/bundle/{all-profiles-PD7GJHFA.js → all-profiles-DVZUVAPQ.js} +14 -14
  8. package/dist/bundle/{anthropic-PJKFON5H.js → anthropic-Y45C45O2.js} +20 -13
  9. package/dist/bundle/{app-server-6ELQA6FJ.js → app-server-GTXUOUGD.js} +67 -56
  10. package/dist/bundle/{bun-P54TGES2.js → bun-QVJV76QJ.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-TND5ZRJH.js → bun-sqlite-CC7PIAMH.js} +9 -9
  12. package/dist/bundle/{chunk-Y5PKRITX.js → chunk-2MEVCMBW.js} +5 -5
  13. package/dist/bundle/{chunk-ZILALBYQ.js → chunk-2PIA45FC.js} +7 -5
  14. package/dist/bundle/{chunk-SIWXYB4E.js → chunk-2Y3YBDZX.js} +3123 -2851
  15. package/dist/bundle/{chunk-54V4H6PM.js → chunk-3RG6LL25.js} +12 -12
  16. package/dist/bundle/{chunk-UTNRBOEN.js → chunk-4G7WQNG7.js} +3 -2
  17. package/dist/bundle/{chunk-OWMZUWCM.js → chunk-4VH7M2OD.js} +6 -14
  18. package/dist/bundle/{chunk-EM7NL5ES.js → chunk-5DMPGTNR.js} +3 -3
  19. package/dist/bundle/{chunk-W2XY6C5S.js → chunk-5TK2YQCO.js} +2 -2
  20. package/dist/bundle/{chunk-NQ5XMSLA.js → chunk-5TSILGTO.js} +21668 -28647
  21. package/dist/bundle/{chunk-FBHSWQU7.js → chunk-6ERQE4FS.js} +319 -102
  22. package/dist/bundle/{chunk-4AOINPN2.js → chunk-7AZCAUST.js} +8 -2
  23. package/dist/bundle/{chunk-DA63E2UM.js → chunk-7J2IP3WL.js} +18 -15
  24. package/dist/bundle/{chunk-JPPPLKAO.js → chunk-7JKECODO.js} +1 -2
  25. package/dist/bundle/{chunk-SEQWBZYH.js → chunk-AAZPDWRD.js} +1 -1
  26. package/dist/bundle/{chunk-CWLL63JD.js → chunk-ABJQ6IDU.js} +17 -17
  27. package/dist/bundle/{chunk-PHOL2DZM.js → chunk-AJ3DFPRT.js} +63 -5
  28. package/dist/bundle/{chunk-4EDWLR22.js → chunk-AZKFZ7J7.js} +1 -1
  29. package/dist/bundle/{chunk-IMHW7VIV.js → chunk-BHSLMJF7.js} +5 -5
  30. package/dist/bundle/{chunk-EHU6EYGO.js → chunk-C72WYRXD.js} +12 -12
  31. package/dist/bundle/chunk-CWDC6QJM.js +72 -0
  32. package/dist/bundle/{chunk-TTP4NOP3.js → chunk-D4MVEOU2.js} +4 -4
  33. package/dist/bundle/{chunk-ZR2EJPMQ.js → chunk-DAFKV6DJ.js} +226 -18
  34. package/dist/bundle/{chunk-RNHGQ35R.js → chunk-E3XA56TS.js} +1 -1
  35. package/dist/bundle/{chunk-ELJUBPY4.js → chunk-EA2OB75T.js} +1 -1
  36. package/dist/bundle/{chunk-7TAP7Y2E.js → chunk-ETAFFY3J.js} +196 -112
  37. package/dist/bundle/{chunk-D6Z43SOG.js → chunk-EXWOOST5.js} +402 -362
  38. package/dist/bundle/{chunk-MCPOZNWG.js → chunk-FIVFP53N.js} +1 -1
  39. package/dist/bundle/{chunk-HP3NT6JJ.js → chunk-FOMQ4MG3.js} +3 -3
  40. package/dist/bundle/{chunk-VMAMRFFC.js → chunk-FS2PG2PE.js} +117 -44
  41. package/dist/bundle/{chunk-6DCLZLGX.js → chunk-HCZYJMBP.js} +1 -1
  42. package/dist/bundle/{chunk-OFJXHEFT.js → chunk-HJF2QGOX.js} +93 -31
  43. package/dist/bundle/{chunk-XPWZSW6Y.js → chunk-IJCUAKR5.js} +4 -4
  44. package/dist/bundle/{chunk-O6K2E7OA.js → chunk-IRULPE5M.js} +1522 -1107
  45. package/dist/bundle/{chunk-EU5MD24W.js → chunk-JCNEPYQZ.js} +13 -13
  46. package/dist/bundle/{chunk-VDZY3L7U.js → chunk-JEMBW6IO.js} +1 -1
  47. package/dist/bundle/{chunk-Z2ADO6UA.js → chunk-JJHDV32D.js} +2 -2
  48. package/dist/bundle/{chunk-FA6JNXCC.js → chunk-JLUQZZ26.js} +8 -8
  49. package/dist/bundle/{chunk-WRAUO5EJ.js → chunk-JO7BJYAP.js} +45 -22
  50. package/dist/bundle/{chunk-TOVWMURV.js → chunk-JRFKCYMW.js} +22 -7
  51. package/dist/bundle/{chunk-M7ELUGU6.js → chunk-JY2GZDJL.js} +4 -4
  52. package/dist/bundle/chunk-LSAIXPAX.js +47 -0
  53. package/dist/bundle/{chunk-WVJHZIDH.js → chunk-LXRBTXCZ.js} +3 -3
  54. package/dist/bundle/{chunk-RX5CJ55S.js → chunk-M4OP5ASJ.js} +1 -1
  55. package/dist/bundle/{chunk-F56DRBGY.js → chunk-MBLB4TQI.js} +75 -20
  56. package/dist/bundle/{chunk-4Y5YBFMS.js → chunk-MEQNAZ6R.js} +7 -7
  57. package/dist/bundle/{chunk-XYE7XZPB.js → chunk-MEY7URZZ.js} +39 -35
  58. package/dist/bundle/{chunk-IBO23OID.js → chunk-MF46W7PQ.js} +2 -2
  59. package/dist/bundle/{chunk-7AQGVX5O.js → chunk-MW46BLWH.js} +60 -29
  60. package/dist/bundle/{chunk-VHQYWFWV.js → chunk-NFIR346J.js} +1 -1
  61. package/dist/bundle/{chunk-NI5PD5KM.js → chunk-NWYVOHIX.js} +18611 -16472
  62. package/dist/bundle/chunk-NYECVHFH.js +10283 -0
  63. package/dist/bundle/{chunk-D7WB54P7.js → chunk-OOBSSU2G.js} +546 -457
  64. package/dist/bundle/{chunk-VLXWAH5E.js → chunk-P6A77LMP.js} +4 -4
  65. package/dist/bundle/{chunk-ZD4MB7NH.js → chunk-PDHN4GHU.js} +5 -40
  66. package/dist/bundle/{chunk-PLP5527C.js → chunk-PV3AWPHR.js} +5 -5
  67. package/dist/bundle/{chunk-TMHF4BCL.js → chunk-QOKPRFHM.js} +2 -2
  68. package/dist/bundle/{chunk-JMJIH6JH.js → chunk-RC72RU66.js} +6 -6
  69. package/dist/bundle/{chunk-NQRTKYJB.js → chunk-RLH6BOEG.js} +47 -80
  70. package/dist/bundle/{chunk-II4S2DBJ.js → chunk-SJE7UGOW.js} +12 -6
  71. package/dist/bundle/{chunk-LMKPP2JP.js → chunk-SXJDCRXE.js} +1 -1
  72. package/dist/bundle/{chunk-B2LPCHQN.js → chunk-T2VAEDJS.js} +4 -4
  73. package/dist/bundle/{chunk-I272E6UR.js → chunk-U2ERT45N.js} +54 -117
  74. package/dist/bundle/{chunk-A27UVLPK.js → chunk-UFNE57VY.js} +3 -3
  75. package/dist/bundle/{chunk-5XSBCMAF.js → chunk-ULH3TNUP.js} +4 -4
  76. package/dist/bundle/{chunk-3ONWN3IA.js → chunk-UOAHZV3K.js} +161 -48
  77. package/dist/bundle/{chunk-ECEP4SO3.js → chunk-UPCEHSIZ.js} +10 -10
  78. package/dist/bundle/{chunk-42G2XNPN.js → chunk-V7E25BUU.js} +2 -2
  79. package/dist/bundle/{chunk-EZ2OLYEK.js → chunk-VZ5KETIX.js} +14 -5
  80. package/dist/bundle/{chunk-X7YGGWXI.js → chunk-WBKYZZQT.js} +3 -2
  81. package/dist/bundle/{chunk-GW3LBY3T.js → chunk-WKIQKGOF.js} +146 -133
  82. package/dist/bundle/{chunk-O7ZDCOZE.js → chunk-WWW7YTFG.js} +1 -1
  83. package/dist/bundle/{chunk-2AFI4KGI.js → chunk-XZCF5XU7.js} +7 -7
  84. package/dist/bundle/chunk-Y2QVNVHK.js +70 -0
  85. package/dist/bundle/{chunk-WRMJN6UQ.js → chunk-Y5WSRG3F.js} +3 -3
  86. package/dist/bundle/{chunk-A4QNADEX.js → chunk-YI4DXASF.js} +49 -49
  87. package/dist/bundle/{chunk-SS4LKLD7.js → chunk-YVUAG7RF.js} +371 -362
  88. package/dist/bundle/chunk-ZEPDEFVT.js +71 -0
  89. package/dist/bundle/{chunk-SE352DBY.js → chunk-ZH4H5XTA.js} +1 -1
  90. package/dist/bundle/{chunk-3HXNDF6Q.js → chunk-ZK46UHDP.js} +2 -2
  91. package/dist/bundle/{chunk-SNLSEYJO.js → chunk-ZU5VQYNY.js} +1 -1
  92. package/dist/bundle/cli-U4LSBYDV.js +1101 -0
  93. package/dist/bundle/command-contract-UU5T24ZZ.js +41 -0
  94. package/dist/bundle/{command-server-entry-36JXYIJB.js → command-server-entry-PK6FBUPO.js} +31 -30
  95. package/dist/bundle/{decode-T5ZW57WZ.js → decode-3ZE6NBKV.js} +8 -8
  96. package/dist/bundle/{dispatch-RMA2XFYA.js → dispatch-WBEOHZDV.js} +9 -9
  97. package/dist/bundle/drive.js +13 -13
  98. package/dist/bundle/{echarts-KQ44LPSF.js → echarts-6FWNCNXK.js} +2 -2
  99. package/dist/bundle/{embed-Q7XST53J.js → embed-DGYBBZUW.js} +9 -9
  100. package/dist/bundle/{embedder-RWZSBVW2.js → embedder-O7A6VMWI.js} +12 -12
  101. package/dist/bundle/entry-CDJ2QSU2.js +25 -0
  102. package/dist/bundle/{failure-7NP4QPIN.js → failure-X6PSLVSO.js} +4 -4
  103. package/dist/bundle/first-run-UOQW7DN5.js +30 -0
  104. package/dist/bundle/first-screen-SNDV4YKF.js +39 -0
  105. package/dist/bundle/google-HPX52KMC.js +45 -0
  106. package/dist/bundle/{google-api-P5DRHD7L.js → google-api-HIMN4XL5.js} +68 -63
  107. package/dist/bundle/grants-RO42I6E4.js +111 -0
  108. package/dist/bundle/{identity-VDV6CHRW.js → identity-NFGHDPLL.js} +8 -6
  109. package/dist/bundle/{instructions-Q45FVY6H.js → instructions-6JAQYCM6.js} +1 -1
  110. package/dist/bundle/{login-XKN3NI6X.js → login-RZOQN63N.js} +73 -70
  111. package/dist/bundle/{mcp-7KQUJNFN.js → mcp-TDKGDB4V.js} +2 -2
  112. package/dist/bundle/{node-MSW565D3.js → node-KSIX3GIH.js} +2 -2
  113. package/dist/bundle/{node-sqlite-S74XVVHL.js → node-sqlite-4FJ6WJXN.js} +10 -10
  114. package/dist/bundle/oauth-BKZAMFKK.js +22 -0
  115. package/dist/bundle/{open-P7UQG7XJ.js → open-4AQJGH42.js} +8 -8
  116. package/dist/bundle/{openai-DDHJ57KZ.js → openai-24F2OX55.js} +28 -21
  117. package/dist/bundle/{process-NMUB5SHK.js → process-7NOA2T7H.js} +1 -1
  118. package/dist/bundle/{program-PJNWP6JW.js → program-7JHMLDEX.js} +306 -692
  119. package/dist/bundle/{prompt-VOSMK4C2.js → prompt-NM66MAZ4.js} +8 -8
  120. package/dist/bundle/{reasons-KDAXOC5S.js → reasons-KSYP5VDJ.js} +5 -5
  121. package/dist/bundle/{recognize-GZIY63HS.js → recognize-DBKV2JYZ.js} +7 -7
  122. package/dist/bundle/{remote-V3YGN7LN.js → remote-ABWUTBVB.js} +13 -10
  123. package/dist/bundle/{rerank-XRU6AVN7.js → rerank-FQAU4ENY.js} +10 -10
  124. package/dist/bundle/{serve-NDOAFA57.js → serve-QLJG4QZD.js} +12 -12
  125. package/dist/bundle/server-NUBLY5SV.js +74 -0
  126. package/dist/bundle/{server-BKGWJYMC.js → server-VGZNK5XD.js} +47 -45
  127. package/dist/bundle/{services-TYDMFQCA.js → services-5KARVUHK.js} +44 -34
  128. package/dist/bundle/{sqlite-runtime-UAFJKSJR.js → sqlite-runtime-ILF6EFQJ.js} +9 -9
  129. package/dist/bundle/{start-2ZLDP2OE.js → start-C6EXYXAL.js} +7 -7
  130. package/dist/bundle/{state-6SP27J2K.js → state-R2M56GPU.js} +9 -9
  131. package/dist/bundle/{store-4UUY545Q.js → store-2OBVMUQL.js} +21 -19
  132. package/dist/bundle/{store-EJN27MXI.js → store-DA4K7HWW.js} +23 -21
  133. package/dist/bundle/store-maintenance-command-KSIPI5B5.js +65 -0
  134. package/dist/bundle/tokens-VQDGSHRB.js +111 -0
  135. package/dist/commands/config.d.ts.map +1 -1
  136. package/dist/commands/config.js +5 -3
  137. package/dist/commands/config.js.map +1 -1
  138. package/dist/commands/discovery.d.ts +0 -1
  139. package/dist/commands/discovery.d.ts.map +1 -1
  140. package/dist/commands/discovery.js +6 -26
  141. package/dist/commands/discovery.js.map +1 -1
  142. package/dist/commands/knowledge.d.ts.map +1 -1
  143. package/dist/commands/knowledge.js +7 -6
  144. package/dist/commands/knowledge.js.map +1 -1
  145. package/dist/commands/search.d.ts.map +1 -1
  146. package/dist/commands/search.js +15 -12
  147. package/dist/commands/search.js.map +1 -1
  148. package/dist/commands/sync.d.ts.map +1 -1
  149. package/dist/commands/sync.js +2 -1
  150. package/dist/commands/sync.js.map +1 -1
  151. package/dist/commands/transcripts.d.ts +4 -0
  152. package/dist/commands/transcripts.d.ts.map +1 -0
  153. package/dist/commands/transcripts.js +42 -0
  154. package/dist/commands/transcripts.js.map +1 -0
  155. package/dist/config.d.ts +10 -0
  156. package/dist/config.d.ts.map +1 -1
  157. package/dist/config.js +17 -3
  158. package/dist/config.js.map +1 -1
  159. package/dist/contract-overrides.d.ts +16 -4
  160. package/dist/contract-overrides.d.ts.map +1 -1
  161. package/dist/contract-overrides.js +86 -410
  162. package/dist/contract-overrides.js.map +1 -1
  163. package/dist/errors.d.ts.map +1 -1
  164. package/dist/errors.js +4 -0
  165. package/dist/errors.js.map +1 -1
  166. package/dist/google-api.d.ts.map +1 -1
  167. package/dist/google-api.js +4 -1
  168. package/dist/google-api.js.map +1 -1
  169. package/dist/google.d.ts.map +1 -1
  170. package/dist/google.js +31 -28
  171. package/dist/google.js.map +1 -1
  172. package/dist/identity.d.ts +4 -0
  173. package/dist/identity.d.ts.map +1 -1
  174. package/dist/identity.js +22 -0
  175. package/dist/identity.js.map +1 -1
  176. package/dist/knowledge.js +2 -2
  177. package/dist/knowledge.js.map +1 -1
  178. package/dist/list-queries.d.ts +10 -0
  179. package/dist/list-queries.d.ts.map +1 -1
  180. package/dist/list-queries.js +12 -1
  181. package/dist/list-queries.js.map +1 -1
  182. package/dist/login.d.ts.map +1 -1
  183. package/dist/login.js +2 -2
  184. package/dist/login.js.map +1 -1
  185. package/dist/model.d.ts +4 -1
  186. package/dist/model.d.ts.map +1 -1
  187. package/dist/program.d.ts.map +1 -1
  188. package/dist/program.js +10 -6
  189. package/dist/program.js.map +1 -1
  190. package/dist/reasons.d.ts.map +1 -1
  191. package/dist/reasons.js +0 -1
  192. package/dist/reasons.js.map +1 -1
  193. package/dist/state.d.ts.map +1 -1
  194. package/dist/state.js +2 -0
  195. package/dist/state.js.map +1 -1
  196. package/dist/store-transition.js +2 -2
  197. package/dist/store-transition.js.map +1 -1
  198. package/dist/store.d.ts.map +1 -1
  199. package/dist/store.js +7 -7
  200. package/dist/store.js.map +1 -1
  201. package/dist/sync.d.ts.map +1 -1
  202. package/dist/sync.js +5 -1
  203. package/dist/sync.js.map +1 -1
  204. package/dist/tokens.d.ts +9 -2
  205. package/dist/tokens.d.ts.map +1 -1
  206. package/dist/tokens.js +18 -15
  207. package/dist/tokens.js.map +1 -1
  208. package/dist/transcripts.d.ts +21 -0
  209. package/dist/transcripts.d.ts.map +1 -0
  210. package/dist/transcripts.js +48 -0
  211. package/dist/transcripts.js.map +1 -0
  212. package/dist/version.d.ts +1 -1
  213. package/dist/version.js +1 -1
  214. package/dist/wcat.d.ts +3 -0
  215. package/dist/wcat.d.ts.map +1 -0
  216. package/dist/wcat.js +4 -0
  217. package/dist/wcat.js.map +1 -0
  218. package/package.json +7 -7
  219. package/dist/bundle/chunk-CGQRZRTH.js +0 -26
  220. package/dist/bundle/chunk-IKHOIXJR.js +0 -27
  221. package/dist/bundle/chunk-SBZB7HMU.js +0 -1055
  222. package/dist/bundle/command-contract-25E4PYMD.js +0 -40
  223. package/dist/bundle/dist-PY3MVR3G.js +0 -21
  224. package/dist/bundle/entry-HPLW4QL2.js +0 -25
  225. package/dist/bundle/first-run-RL3RKYZW.js +0 -30
  226. package/dist/bundle/first-screen-NX3TM2VJ.js +0 -38
  227. package/dist/bundle/google-DPD5N6AQ.js +0 -42
  228. package/dist/bundle/grants-TX4MHLI4.js +0 -109
  229. package/dist/bundle/oauth-6R7AWAES.js +0 -22
  230. package/dist/bundle/server-QD2MUJJZ.js +0 -72
  231. package/dist/bundle/store-maintenance-command-LETURZDC.js +0 -60
  232. package/dist/bundle/tokens-MTFJPTYT.js +0 -107
  233. /package/dist/bundle/{chunk-YVNHQFLC.js → chunk-XWBPP2HX.js} +0 -0
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  refuseLacking
5
- } from "./chunk-WRAUO5EJ.js";
5
+ } from "./chunk-JO7BJYAP.js";
6
6
  import {
7
7
  FloodMemory,
8
8
  OFFLINE,
@@ -18,10 +18,10 @@ import {
18
18
  servicesFor,
19
19
  throughWrapper,
20
20
  withFileLockAsync
21
- } from "./chunk-O6K2E7OA.js";
21
+ } from "./chunk-IRULPE5M.js";
22
22
  import {
23
23
  servingProfiles
24
- } from "./chunk-EM7NL5ES.js";
24
+ } from "./chunk-5DMPGTNR.js";
25
25
  import {
26
26
  asFirstWord,
27
27
  baseContext,
@@ -32,14 +32,15 @@ import {
32
32
  recalledAccount,
33
33
  rememberAccount,
34
34
  rootOf2 as rootOf
35
- } from "./chunk-SIWXYB4E.js";
35
+ } from "./chunk-2Y3YBDZX.js";
36
36
  import {
37
37
  providerErrorKey
38
- } from "./chunk-DA63E2UM.js";
38
+ } from "./chunk-7J2IP3WL.js";
39
39
  import {
40
40
  AUTHORITY_KEY,
41
41
  CEILING_KEY,
42
42
  DEFAULT_PERMISSIONS,
43
+ KEYED_UNDER_HOUSEKEEPING,
43
44
  WRITE_KEYS,
44
45
  codeOf,
45
46
  currentOperation,
@@ -48,7 +49,7 @@ import {
48
49
  limitBatch,
49
50
  readKeysForCommand,
50
51
  skipFlagFor
51
- } from "./chunk-F56DRBGY.js";
52
+ } from "./chunk-MBLB4TQI.js";
52
53
  import {
53
54
  chatReferenceOf,
54
55
  ensureAccount,
@@ -56,21 +57,21 @@ import {
56
57
  isId,
57
58
  openStore,
58
59
  pickPerson
59
- } from "./chunk-NI5PD5KM.js";
60
+ } from "./chunk-NWYVOHIX.js";
60
61
  import {
61
62
  isCliFailure
62
- } from "./chunk-4AOINPN2.js";
63
+ } from "./chunk-7AZCAUST.js";
63
64
  import {
64
65
  resolvePaths
65
- } from "./chunk-7AQGVX5O.js";
66
+ } from "./chunk-MW46BLWH.js";
66
67
  import {
67
68
  CliError
68
- } from "./chunk-ELJUBPY4.js";
69
+ } from "./chunk-EA2OB75T.js";
69
70
  import {
70
71
  __name
71
72
  } from "./chunk-ZVVMGPBJ.js";
72
73
 
73
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
74
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
74
75
  import { openSync } from "node:fs";
75
76
  import { createInterface } from "node:readline";
76
77
  import { ReadStream } from "node:tty";
@@ -125,97 +126,7 @@ var terminalAsker = /* @__PURE__ */ __name((command) => async (key, request) =>
125
126
  throw new CliError("cancelled", `${key}: not done \u2014 the answer was no`);
126
127
  }, "terminalAsker");
127
128
 
128
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/sends/pace.js
129
- import { readFileSync, renameSync, writeFileSync } from "node:fs";
130
- import { join } from "node:path";
131
- var DEFAULT_PACE = { perMinute: 60, burst: 20 };
132
- var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
133
- var Pacer = class {
134
- static {
135
- __name(this, "Pacer");
136
- }
137
- path;
138
- rate;
139
- now;
140
- constructor(path, rate, now = Date.now) {
141
- this.path = path;
142
- this.rate = rate;
143
- this.now = now;
144
- }
145
- get interval() {
146
- return this.rate.perMinute > 0 ? 6e4 / this.rate.perMinute : 0;
147
- }
148
- /** When this call may go; reserved at once, so the next caller in any process lines up behind it. */
149
- async reserve() {
150
- const now = this.now();
151
- if (this.interval === 0)
152
- return now;
153
- return withFileLockAsync(this.path, "the request pace", () => {
154
- const tat = Math.max(this.read(), now);
155
- this.write(tat + this.interval);
156
- return Math.max(now, tat - this.rate.burst * this.interval);
157
- });
158
- }
159
- /** The messenger asked every caller to wait: nothing goes before `now + waitMs`, in any process. */
160
- async holdFor(waitMs) {
161
- if (this.interval === 0)
162
- return;
163
- await withFileLockAsync(this.path, "the request pace", () => {
164
- const hold = this.now() + waitMs + this.rate.burst * this.interval;
165
- this.write(Math.max(this.read(), hold));
166
- });
167
- }
168
- /** The owner's `flood clear`: every process may go again at once. */
169
- async reset() {
170
- await withFileLockAsync(this.path, "the request pace", () => this.write(0));
171
- }
172
- read() {
173
- try {
174
- const tat = Number(JSON.parse(readFileSync(this.path, "utf8")).tat);
175
- return Number.isFinite(tat) ? tat : 0;
176
- } catch {
177
- return 0;
178
- }
179
- }
180
- write(tat) {
181
- const temporary = `${this.path}.${process.pid}.tmp`;
182
- writeFileSync(temporary, JSON.stringify({ tat }), { mode: 384 });
183
- renameSync(temporary, this.path);
184
- }
185
- };
186
- var ANNOUNCE_WAIT_MS = 5e3;
187
- var LONGEST_PACE_WAIT_MS = 5 * 6e4;
188
- var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
189
- const { name, operation, warn } = options;
190
- const now = options.now ?? Date.now;
191
- let at = now();
192
- try {
193
- at = await pacer.reserve();
194
- } catch (error) {
195
- warn?.(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
196
- event: "warning",
197
- code: "wait_not_remembered",
198
- operation
199
- });
200
- }
201
- const waitMs = at - now();
202
- if (waitMs <= 0)
203
- return;
204
- if (waitMs > LONGEST_PACE_WAIT_MS)
205
- throw new CliError("rate_limited", `${name} asked this profile to wait, ${Math.ceil(waitMs / 1e3)} s are left \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at).toISOString(), remembered: true });
206
- if (waitMs >= ANNOUNCE_WAIT_MS) {
207
- const seconds = Math.ceil(waitMs / 1e3);
208
- warn?.(`waiting ${seconds} s to keep this profile's pace with ${name}`, {
209
- event: "warning",
210
- code: "pace_wait",
211
- operation,
212
- counts: { seconds }
213
- });
214
- }
215
- await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
216
- }, "waitForTurn");
217
-
218
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
129
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
219
130
  var HOUSEKEEPING = /* @__PURE__ */ new Set([
220
131
  "help",
221
132
  "guide",
@@ -229,7 +140,7 @@ var HOUSEKEEPING = /* @__PURE__ */ new Set([
229
140
  "mcp",
230
141
  "runs"
231
142
  ]);
232
- var commandPathKey = /* @__PURE__ */ __name((path) => path[0] === void 0 || HOUSEKEEPING.has(path[0]) ? null : path.join("."), "commandPathKey");
143
+ var commandPathKey = /* @__PURE__ */ __name((path) => path[0] === void 0 || HOUSEKEEPING.has(path[0]) && !KEYED_UNDER_HOUSEKEEPING.has(path.join(".")) ? null : path.join("."), "commandPathKey");
233
144
  var commandPermissions = /* @__PURE__ */ __name(({ keyOf = commandPathKey, extra = [], defaults = {}, alsoChecks } = {}) => ({
234
145
  keyOf,
235
146
  extra: [AUTHORITY_KEY, ...extra],
@@ -295,271 +206,75 @@ var refuseUnknownPermissionKeys = /* @__PURE__ */ __name((command, settings, too
295
206
  throw new CliError("validation_error", `--permission ${key} names no command`, { permission: key });
296
207
  }, "refuseUnknownPermissionKeys");
297
208
 
298
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
299
- var LONG_LIVED = /* @__PURE__ */ new Set(["self", "newSendId", "close", "formatMarkdown", "formatHtml", "storedChats"]);
300
- var LISTENING = /* @__PURE__ */ new Set(["watch", "feed", "listen", "listenHistory"]);
301
- var BLOCKING = /* @__PURE__ */ new Set(["frozen", "limited", "banned"]);
302
- var chatOf = /* @__PURE__ */ __name((args) => typeof args[0] === "string" && /^-?\d+$/.test(args[0]) ? args[0] : void 0, "chatOf");
303
- var flooded = /* @__PURE__ */ __name((messenger, memory, { name, warn, pacer }) => {
304
- const kept = /* @__PURE__ */ __name(async (operation, what2) => {
305
- try {
306
- await what2();
307
- } catch (error) {
308
- warn(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
309
- event: "warning",
310
- code: "wait_not_remembered",
311
- operation
312
- });
313
- }
314
- }, "kept");
315
- const noted = /* @__PURE__ */ __name(async (operation, chatId, error) => {
316
- if (!isCliFailure(error))
317
- return;
318
- const details = error.details ?? {};
319
- const standing = details.standing;
320
- if (standing && BLOCKING.has(standing.state)) {
321
- await kept(operation, () => {
322
- const block = memory.block({
323
- state: standing.state,
324
- hint: standing.hint ?? error.message,
325
- ...standing.until ? { until: standing.until } : {}
326
- });
327
- warn(`writes from this profile are held ${holdEnd(block)}: ${block.hint}`, {
328
- event: "warning",
329
- code: `account_${block.state}`,
330
- operation
331
- });
332
- });
209
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
210
+ var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
211
+ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events, pending, announcing, deletedWithoutChat, profile, rekeyed, rekeyPacing = REKEY_PACING, closing, namesFromStore, recipientIds, countsUnread = false, historyLimits, command = "cli" }) => {
212
+ let warned = false;
213
+ let limitedNoted = false;
214
+ const limited = /* @__PURE__ */ __name(async (opened, batch) => {
215
+ if (!historyLimits || !batch.messages?.length)
216
+ return { batch, skipped: /* @__PURE__ */ new Map() };
217
+ const shapes = await opened.chats.historyShapes(account, [...new Set(batch.messages.map((one) => one.chatId))]);
218
+ return limitBatch(batch, (chatId) => shapes.get(chatId), (chatId) => shapes.get(chatId)?.included === true, historyLimits);
219
+ }, "limited");
220
+ const noteLimited = /* @__PURE__ */ __name((skipped) => {
221
+ if (skipped.size === 0)
333
222
  return;
223
+ const counts = {
224
+ chats: skipped.size,
225
+ messages: 0,
226
+ group_too_large: 0,
227
+ older_than_window: 0
228
+ };
229
+ for (const skip of skipped.values()) {
230
+ counts.messages = (counts.messages ?? 0) + skip.messages;
231
+ counts[skip.reason] = (counts[skip.reason] ?? 0) + 1;
334
232
  }
335
- const waitMs = Number(details.retry_after_ms);
336
- if (error.code !== "rate_limited" || details.remembered === true || !Number.isFinite(waitMs) || waitMs <= 0)
233
+ const warning = { event: "warning", code: "history_limited", operation: "history.save", counts };
234
+ events(warning);
235
+ if (limitedNoted)
337
236
  return;
338
- const providerError = providerErrorKey(details.provider_error);
339
- await kept(operation, () => {
340
- const deadline = memory.remember({
341
- operation,
342
- ...chatId ? { chatId } : {},
343
- ...providerError ? { providerError } : {},
344
- waitMs
345
- });
346
- warn(`${name} asked to wait before ${operation} again \u2014 until ${deadline.until}`, {
347
- event: "warning",
348
- code: "flood_wait",
349
- operation,
350
- counts: { seconds: Math.ceil(waitMs / 1e3) }
351
- });
352
- });
353
- if (pacer)
354
- await kept(operation, () => pacer.holdFor(waitMs));
355
- }, "noted");
356
- const turn = /* @__PURE__ */ __name(async (operation) => {
357
- if (pacer)
358
- await waitForTurn(pacer, { name, operation, warn });
359
- }, "turn");
360
- return throughWrapper(messenger, {}, (operation, call) => {
361
- if (LONG_LIVED.has(operation))
362
- return call;
363
- if (LISTENING.has(operation))
364
- return (async (...args) => {
365
- try {
366
- return await call(...args);
367
- } catch (error) {
368
- await noted(operation, void 0, error);
369
- throw error;
370
- }
371
- });
372
- return (async (...args) => {
373
- const chatId = chatOf(args);
374
- const owed = memory.owed(operation, chatId);
375
- if (owed) {
376
- const waitMs = Math.max(0, Date.parse(owed.until) - Date.now());
377
- throw new CliError("rate_limited", `${name} asked to wait before ${operation} again, ${Math.ceil(waitMs / 1e3)} s are left \u2014 nothing was sent to ${name}`, {
378
- retry_after_ms: waitMs,
379
- retry_at: owed.until,
380
- remembered: true,
381
- ...owed.providerError ? { provider_error: owed.providerError } : {}
237
+ limitedNoted = true;
238
+ warn(`history limits left out ${counts.messages} pushed messages of ${skipped.size} chats (big groups, older than the window) \u2014 \`${command} store status\` lists them; \`${command} messages sync <chat> --full-history\` fetches one and keeps it in full`, warning);
239
+ }, "noteLimited");
240
+ let recorded = profile === void 0;
241
+ const notWritten = /* @__PURE__ */ __name((operation, error) => {
242
+ const warning = { event: "warning", code: "store_not_written", operation };
243
+ events(warning);
244
+ if (!warned)
245
+ warn(`not saved to the local store: ${error instanceof Error ? error.message : String(error)}`, warning);
246
+ warned = true;
247
+ }, "notWritten");
248
+ const attempt = /* @__PURE__ */ __name(async (operation, write) => {
249
+ try {
250
+ const opened = await store();
251
+ if (!opened)
252
+ return false;
253
+ await write(opened);
254
+ if (opened && !recorded && profile) {
255
+ recorded = true;
256
+ await Promise.resolve().then(() => opened.accounts.saveProfile(profile.app, profile.name, account)).catch(() => {
382
257
  });
383
258
  }
384
- await turn(operation);
385
- try {
386
- return await call(...args);
387
- } catch (error) {
388
- await noted(operation, chatId, error);
389
- throw error;
390
- }
391
- });
392
- });
393
- }, "flooded");
394
-
395
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
396
- var observed = /* @__PURE__ */ __name((messenger, events) => {
397
- const timed = /* @__PURE__ */ __name(async (operation, named, work, after) => {
398
- const write = currentOperation();
399
- const marked = /* @__PURE__ */ __name((part = {}) => write === void 0 ? part : { ...part, ids: { ...part.ids, operation: write } }, "marked");
400
- events({ event: "request", operation, level: "operation", ...marked(named) });
401
- const started = performance.now();
402
- const durationMs = /* @__PURE__ */ __name(() => Math.round(performance.now() - started), "durationMs");
259
+ return true;
260
+ } catch (error) {
261
+ notWritten(operation, error);
262
+ return false;
263
+ }
264
+ }, "attempt");
265
+ const save = /* @__PURE__ */ __name((operation, writing) => {
266
+ const saving = attempt(operation, writing);
267
+ pending?.add(saving);
268
+ return saving.finally(() => pending?.delete(saving));
269
+ }, "save");
270
+ const { chats, history, around, people } = messenger;
271
+ const followed = /* @__PURE__ */ __name(async (opened, scoped, held) => {
272
+ let answered;
403
273
  try {
404
- const answer = await work();
405
- events({
406
- event: "response",
407
- operation,
408
- level: "operation",
409
- durationMs: durationMs(),
410
- outcome: "ok",
411
- ...marked(after?.(answer))
412
- });
413
- return answer;
274
+ answered = await messenger.resolve(held.id);
414
275
  } catch (error) {
415
- const providerError = isCliFailure(error) ? providerErrorKey(error.details?.provider_error) : void 0;
416
- events({
417
- event: "response",
418
- operation,
419
- level: "operation",
420
- durationMs: durationMs(),
421
- outcome: "error",
422
- errorCode: isCliFailure(error) ? error.code : "generic_failure",
423
- ...providerError ? { providerError } : {},
424
- ...marked()
425
- });
426
- throw error;
427
- }
428
- }, "timed");
429
- const counted = /* @__PURE__ */ __name(async (operation, onItem, work, count) => {
430
- const counts = {};
431
- await timed(operation, {}, () => work((item, ...rest) => {
432
- count(item, counts);
433
- return onItem(item, ...rest);
434
- }), () => ({ counts }));
435
- }, "counted");
436
- const mint = messenger.newSendId;
437
- const { chats, history, contact, around, watch, feed, listen, listenHistory } = messenger;
438
- return throughWrapper(messenger, {
439
- self: /* @__PURE__ */ __name(() => messenger.self(), "self"),
440
- ...mint ? { newSendId: /* @__PURE__ */ __name(() => mint.call(messenger), "newSendId") } : {},
441
- me: /* @__PURE__ */ __name(() => timed("account.me", {}, () => messenger.me()), "me"),
442
- ...chats ? {
443
- chats: /* @__PURE__ */ __name((window) => timed("chats.list", {}, () => chats.call(messenger, window), (page) => ({ counts: { chats: page.items.length } })), "chats")
444
- } : {},
445
- ...history ? {
446
- history: /* @__PURE__ */ __name((reference, options) => timed("messages.list", {}, () => history.call(messenger, reference, options), (page) => ({
447
- ...page.items[0] ? { ids: { chat: page.items[0].chatId } } : {},
448
- counts: { messages: page.items.length }
449
- })), "history")
450
- } : {},
451
- resolve: /* @__PURE__ */ __name((reference) => timed("chats.resolve", {}, () => messenger.resolve(reference), (chat) => ({ ids: { chat: chat.id } })), "resolve"),
452
- chat: /* @__PURE__ */ __name((reference) => timed("chats.show", {}, () => messenger.chat(reference), (card) => ({ ids: { chat: card.id }, ...card.members ? { counts: { members: card.members.length } } : {} })), "chat"),
453
- ...contact ? {
454
- contact: /* @__PURE__ */ __name((reference) => timed("contacts.show", {}, () => contact.call(messenger, reference), (card) => ({ ids: { person: card.id }, counts: { chats: card.chats.length } })), "contact")
455
- } : {},
456
- ...around ? {
457
- around: /* @__PURE__ */ __name((reference, messageId, window) => timed("messages.around", { ids: { message_id: messageId } }, () => around.call(messenger, reference, messageId, window), (items) => ({
458
- ...items[0] ? { ids: { chat: items[0].chatId, message_id: messageId } } : {},
459
- counts: { messages: items.length }
460
- })), "around")
461
- } : {},
462
- send: /* @__PURE__ */ __name((chatId, text, options) => timed("messages.send", {
463
- ids: {
464
- chat: chatId,
465
- send: options.sendId,
466
- ...options.replyTo ? { reply: options.replyTo } : {},
467
- ...options.threadId ? { thread: options.threadId } : {}
468
- }
469
- }, () => messenger.send(chatId, text, options), (sent) => ({ ids: { chat: sent.message.chatId || chatId, message_id: sent.message.id } })), "send"),
470
- ...watch ? {
471
- watch: /* @__PURE__ */ __name((onEvent, signal, onReady) => counted("messages.watch", onEvent, (counting) => watch.call(messenger, counting, signal, onReady), byEvent), "watch")
472
- } : {},
473
- ...feed ? { feed: /* @__PURE__ */ __name((onBatch, signal) => timed("history.feed", {}, () => feed.call(messenger, onBatch, signal)), "feed") } : {},
474
- ...listen ? {
475
- listen: /* @__PURE__ */ __name((onEvent, signal) => counted("messages.listen", onEvent, (counting) => listen.call(messenger, counting, signal), byEvent), "listen")
476
- } : {},
477
- ...listenHistory ? {
478
- listenHistory: /* @__PURE__ */ __name((onBatch, signal) => counted("history.listen", onBatch, (counting) => listenHistory.call(messenger, counting, signal), byPart), "listenHistory")
479
- } : {},
480
- logout: /* @__PURE__ */ __name(() => timed("session.logout", {}, () => messenger.logout()), "logout"),
481
- close: /* @__PURE__ */ __name(() => messenger.close(), "close")
482
- }, (name, call) => (...args) => timed(`adapter.${name}`, {}, () => call(...args)));
483
- }, "observed");
484
- var byEvent = /* @__PURE__ */ __name((event, counts) => {
485
- counts[event.event] = (counts[event.event] ?? 0) + 1;
486
- }, "byEvent");
487
- var byPart = /* @__PURE__ */ __name((batch, counts) => {
488
- counts.batches = (counts.batches ?? 0) + 1;
489
- for (const [part, items] of Object.entries(batch))
490
- if (Array.isArray(items) && items.length > 0)
491
- counts[part] = (counts[part] ?? 0) + items.length;
492
- }, "byPart");
493
-
494
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
495
- var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
496
- var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events, pending, announcing, deletedWithoutChat, profile, rekeyed, rekeyPacing = REKEY_PACING, closing, namesFromStore, recipientIds, countsUnread = false, historyLimits, command = "cli" }) => {
497
- let warned = false;
498
- let limitedNoted = false;
499
- const limited = /* @__PURE__ */ __name(async (opened, batch) => {
500
- if (!historyLimits || !batch.messages?.length)
501
- return { batch, skipped: /* @__PURE__ */ new Map() };
502
- const shapes = await opened.chats.historyShapes(account, [...new Set(batch.messages.map((one) => one.chatId))]);
503
- return limitBatch(batch, (chatId) => shapes.get(chatId), (chatId) => shapes.get(chatId)?.included === true, historyLimits);
504
- }, "limited");
505
- const noteLimited = /* @__PURE__ */ __name((skipped) => {
506
- if (skipped.size === 0)
507
- return;
508
- const counts = {
509
- chats: skipped.size,
510
- messages: 0,
511
- group_too_large: 0,
512
- older_than_window: 0
513
- };
514
- for (const skip of skipped.values()) {
515
- counts.messages = (counts.messages ?? 0) + skip.messages;
516
- counts[skip.reason] = (counts[skip.reason] ?? 0) + 1;
517
- }
518
- const warning = { event: "warning", code: "history_limited", operation: "history.save", counts };
519
- events(warning);
520
- if (limitedNoted)
521
- return;
522
- limitedNoted = true;
523
- warn(`history limits left out ${counts.messages} pushed messages of ${skipped.size} chats (big groups, older than the window) \u2014 \`${command} store status\` lists them; \`${command} messages sync <chat> --full-history\` fetches one and keeps it in full`, warning);
524
- }, "noteLimited");
525
- let recorded = profile === void 0;
526
- const notWritten = /* @__PURE__ */ __name((operation, error) => {
527
- const warning = { event: "warning", code: "store_not_written", operation };
528
- events(warning);
529
- if (!warned)
530
- warn(`not saved to the local store: ${error instanceof Error ? error.message : String(error)}`, warning);
531
- warned = true;
532
- }, "notWritten");
533
- const attempt = /* @__PURE__ */ __name(async (operation, write) => {
534
- try {
535
- const opened = await store();
536
- if (!opened)
537
- return false;
538
- await write(opened);
539
- if (opened && !recorded && profile) {
540
- recorded = true;
541
- await Promise.resolve().then(() => opened.accounts.saveProfile(profile.app, profile.name, account)).catch(() => {
542
- });
543
- }
544
- return true;
545
- } catch (error) {
546
- notWritten(operation, error);
547
- return false;
548
- }
549
- }, "attempt");
550
- const save = /* @__PURE__ */ __name((operation, writing) => {
551
- const saving = attempt(operation, writing);
552
- pending?.add(saving);
553
- return saving.finally(() => pending?.delete(saving));
554
- }, "save");
555
- const { chats, history, around, people } = messenger;
556
- const followed = /* @__PURE__ */ __name(async (opened, scoped, held) => {
557
- let answered;
558
- try {
559
- answered = await messenger.resolve(held.id);
560
- } catch (error) {
561
- if (codeOf(error) === "not_found")
562
- return void 0;
276
+ if (codeOf(error) === "not_found")
277
+ return void 0;
563
278
  throw error;
564
279
  }
565
280
  if (answered.id === held.id)
@@ -1067,7 +782,298 @@ var keep = /* @__PURE__ */ __name(async (store, account, event, seenAt, among, c
1067
782
  }
1068
783
  }, "keep");
1069
784
 
1070
- // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
785
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/sends/pace.js
786
+ import { readFileSync, renameSync, writeFileSync } from "node:fs";
787
+ import { join } from "node:path";
788
+ var DEFAULT_PACE = { perMinute: 60, burst: 20 };
789
+ var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
790
+ var Pacer = class {
791
+ static {
792
+ __name(this, "Pacer");
793
+ }
794
+ path;
795
+ rate;
796
+ now;
797
+ constructor(path, rate, now = Date.now) {
798
+ this.path = path;
799
+ this.rate = rate;
800
+ this.now = now;
801
+ }
802
+ get interval() {
803
+ return this.rate.perMinute > 0 ? 6e4 / this.rate.perMinute : 0;
804
+ }
805
+ /** When this call may go; reserved at once, so the next caller in any process lines up behind it. */
806
+ async reserve() {
807
+ if (this.interval === 0)
808
+ return this.now();
809
+ return withFileLockAsync(this.path, "the request pace", () => {
810
+ const now = this.now();
811
+ const tat = Math.max(this.read(now), now);
812
+ this.write(tat + this.interval, now);
813
+ return Math.max(now, tat - this.rate.burst * this.interval);
814
+ });
815
+ }
816
+ /** The messenger asked every caller to wait: nothing goes before `now + waitMs`, in any process. */
817
+ async holdFor(waitMs) {
818
+ if (this.interval === 0)
819
+ return;
820
+ await withFileLockAsync(this.path, "the request pace", () => {
821
+ const now = this.now();
822
+ const hold = now + waitMs + this.rate.burst * this.interval;
823
+ this.write(Math.max(this.read(now), hold), now);
824
+ });
825
+ }
826
+ /** The owner's `flood clear`: every process may go again at once. */
827
+ async reset() {
828
+ await withFileLockAsync(this.path, "the request pace", () => this.write(0, this.now()));
829
+ }
830
+ read(now) {
831
+ try {
832
+ const file = JSON.parse(readFileSync(this.path, "utf8"));
833
+ const tat = Number(file.tat);
834
+ if (!Number.isFinite(tat))
835
+ return 0;
836
+ const at = Number(file.at);
837
+ return Number.isFinite(at) && at > now ? now + Math.max(0, tat - at) : tat;
838
+ } catch {
839
+ return 0;
840
+ }
841
+ }
842
+ write(tat, at) {
843
+ const temporary = `${this.path}.${process.pid}.tmp`;
844
+ writeFileSync(temporary, JSON.stringify({ tat, at }), { mode: 384 });
845
+ renameSync(temporary, this.path);
846
+ }
847
+ };
848
+ var ANNOUNCE_WAIT_MS = 5e3;
849
+ var LONGEST_PACE_WAIT_MS = 5 * 6e4;
850
+ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
851
+ const { name, operation, warn } = options;
852
+ const now = options.now ?? Date.now;
853
+ let at = now();
854
+ try {
855
+ at = await pacer.reserve();
856
+ } catch (error) {
857
+ warn?.(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
858
+ event: "warning",
859
+ code: "wait_not_remembered",
860
+ operation
861
+ });
862
+ }
863
+ const waitMs = at - now();
864
+ if (waitMs <= 0)
865
+ return;
866
+ if (waitMs > (options.longestWaitMs ?? LONGEST_PACE_WAIT_MS))
867
+ throw new CliError("rate_limited", `this profile's next request to ${name} has to wait ${Math.ceil(waitMs / 1e3)} s more \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at).toISOString(), remembered: true });
868
+ if (waitMs >= ANNOUNCE_WAIT_MS) {
869
+ const seconds = Math.ceil(waitMs / 1e3);
870
+ warn?.(`waiting ${seconds} s to keep this profile's pace with ${name}`, {
871
+ event: "warning",
872
+ code: "pace_wait",
873
+ operation,
874
+ counts: { seconds }
875
+ });
876
+ }
877
+ await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
878
+ }, "waitForTurn");
879
+
880
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
881
+ var LONG_LIVED = /* @__PURE__ */ new Set(["self", "newSendId", "close", "formatMarkdown", "formatHtml", "storedChats"]);
882
+ var LISTENING = /* @__PURE__ */ new Set(["watch", "feed", "listen", "listenHistory"]);
883
+ var BLOCKING = /* @__PURE__ */ new Set(["frozen", "limited", "banned"]);
884
+ var chatOf = /* @__PURE__ */ __name((args) => typeof args[0] === "string" && /^-?\d+$/.test(args[0]) ? args[0] : void 0, "chatOf");
885
+ var flooded = /* @__PURE__ */ __name((messenger, memory, { name, warn, pacer }) => {
886
+ const kept = /* @__PURE__ */ __name(async (operation, what2) => {
887
+ try {
888
+ await what2();
889
+ } catch (error) {
890
+ warn(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
891
+ event: "warning",
892
+ code: "wait_not_remembered",
893
+ operation
894
+ });
895
+ }
896
+ }, "kept");
897
+ const noted = /* @__PURE__ */ __name(async (operation, chatId, error) => {
898
+ if (!isCliFailure(error))
899
+ return;
900
+ const details = error.details ?? {};
901
+ const standing = details.standing;
902
+ if (standing && BLOCKING.has(standing.state)) {
903
+ await kept(operation, () => {
904
+ const block = memory.block({
905
+ state: standing.state,
906
+ hint: standing.hint ?? error.message,
907
+ ...standing.until ? { until: standing.until } : {}
908
+ });
909
+ warn(`writes from this profile are held ${holdEnd(block)}: ${block.hint}`, {
910
+ event: "warning",
911
+ code: `account_${block.state}`,
912
+ operation
913
+ });
914
+ });
915
+ return;
916
+ }
917
+ const waitMs = Number(details.retry_after_ms);
918
+ if (error.code !== "rate_limited" || details.remembered === true || !Number.isFinite(waitMs) || waitMs <= 0)
919
+ return;
920
+ const providerError = providerErrorKey(details.provider_error);
921
+ await kept(operation, () => {
922
+ const deadline = memory.remember({
923
+ operation,
924
+ ...chatId ? { chatId } : {},
925
+ ...providerError ? { providerError } : {},
926
+ waitMs
927
+ });
928
+ warn(`${name} asked to wait before ${operation} again \u2014 until ${deadline.until}`, {
929
+ event: "warning",
930
+ code: "flood_wait",
931
+ operation,
932
+ counts: { seconds: Math.ceil(waitMs / 1e3) }
933
+ });
934
+ });
935
+ if (pacer)
936
+ await kept(operation, () => pacer.holdFor(waitMs));
937
+ }, "noted");
938
+ const turn = /* @__PURE__ */ __name(async (operation) => {
939
+ if (pacer)
940
+ await waitForTurn(pacer, { name, operation, warn });
941
+ }, "turn");
942
+ return throughWrapper(messenger, {}, (operation, call) => {
943
+ if (LONG_LIVED.has(operation))
944
+ return call;
945
+ if (LISTENING.has(operation))
946
+ return (async (...args) => {
947
+ try {
948
+ return await call(...args);
949
+ } catch (error) {
950
+ await noted(operation, void 0, error);
951
+ throw error;
952
+ }
953
+ });
954
+ return (async (...args) => {
955
+ const chatId = chatOf(args);
956
+ const owed = memory.owed(operation, chatId);
957
+ if (owed) {
958
+ const waitMs = Math.max(0, Date.parse(owed.until) - Date.now());
959
+ throw new CliError("rate_limited", `${name} asked to wait before ${operation} again, ${Math.ceil(waitMs / 1e3)} s are left \u2014 nothing was sent to ${name}`, {
960
+ retry_after_ms: waitMs,
961
+ retry_at: owed.until,
962
+ remembered: true,
963
+ ...owed.providerError ? { provider_error: owed.providerError } : {}
964
+ });
965
+ }
966
+ await turn(operation);
967
+ try {
968
+ return await call(...args);
969
+ } catch (error) {
970
+ await noted(operation, chatId, error);
971
+ throw error;
972
+ }
973
+ });
974
+ });
975
+ }, "flooded");
976
+
977
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
978
+ var observed = /* @__PURE__ */ __name((messenger, events) => {
979
+ const timed = /* @__PURE__ */ __name(async (operation, named, work, after) => {
980
+ const write = currentOperation();
981
+ const marked = /* @__PURE__ */ __name((part = {}) => write === void 0 ? part : { ...part, ids: { ...part.ids, operation: write } }, "marked");
982
+ events({ event: "request", operation, level: "operation", ...marked(named) });
983
+ const started = performance.now();
984
+ const durationMs = /* @__PURE__ */ __name(() => Math.round(performance.now() - started), "durationMs");
985
+ try {
986
+ const answer = await work();
987
+ events({
988
+ event: "response",
989
+ operation,
990
+ level: "operation",
991
+ durationMs: durationMs(),
992
+ outcome: "ok",
993
+ ...marked(after?.(answer))
994
+ });
995
+ return answer;
996
+ } catch (error) {
997
+ const providerError = isCliFailure(error) ? providerErrorKey(error.details?.provider_error) : void 0;
998
+ events({
999
+ event: "response",
1000
+ operation,
1001
+ level: "operation",
1002
+ durationMs: durationMs(),
1003
+ outcome: "error",
1004
+ errorCode: isCliFailure(error) ? error.code : "generic_failure",
1005
+ ...providerError ? { providerError } : {},
1006
+ ...marked()
1007
+ });
1008
+ throw error;
1009
+ }
1010
+ }, "timed");
1011
+ const counted = /* @__PURE__ */ __name(async (operation, onItem, work, count) => {
1012
+ const counts = {};
1013
+ await timed(operation, {}, () => work((item, ...rest) => {
1014
+ count(item, counts);
1015
+ return onItem(item, ...rest);
1016
+ }), () => ({ counts }));
1017
+ }, "counted");
1018
+ const mint = messenger.newSendId;
1019
+ const { chats, history, contact, around, watch, feed, listen, listenHistory } = messenger;
1020
+ return throughWrapper(messenger, {
1021
+ self: /* @__PURE__ */ __name(() => messenger.self(), "self"),
1022
+ ...mint ? { newSendId: /* @__PURE__ */ __name(() => mint.call(messenger), "newSendId") } : {},
1023
+ me: /* @__PURE__ */ __name(() => timed("account.me", {}, () => messenger.me()), "me"),
1024
+ ...chats ? {
1025
+ chats: /* @__PURE__ */ __name((window) => timed("chats.list", {}, () => chats.call(messenger, window), (page) => ({ counts: { chats: page.items.length } })), "chats")
1026
+ } : {},
1027
+ ...history ? {
1028
+ history: /* @__PURE__ */ __name((reference, options) => timed("messages.list", {}, () => history.call(messenger, reference, options), (page) => ({
1029
+ ...page.items[0] ? { ids: { chat: page.items[0].chatId } } : {},
1030
+ counts: { messages: page.items.length }
1031
+ })), "history")
1032
+ } : {},
1033
+ resolve: /* @__PURE__ */ __name((reference) => timed("chats.resolve", {}, () => messenger.resolve(reference), (chat) => ({ ids: { chat: chat.id } })), "resolve"),
1034
+ chat: /* @__PURE__ */ __name((reference) => timed("chats.show", {}, () => messenger.chat(reference), (card) => ({ ids: { chat: card.id }, ...card.members ? { counts: { members: card.members.length } } : {} })), "chat"),
1035
+ ...contact ? {
1036
+ contact: /* @__PURE__ */ __name((reference) => timed("contacts.show", {}, () => contact.call(messenger, reference), (card) => ({ ids: { person: card.id }, counts: { chats: card.chats.length } })), "contact")
1037
+ } : {},
1038
+ ...around ? {
1039
+ around: /* @__PURE__ */ __name((reference, messageId, window) => timed("messages.around", { ids: { message_id: messageId } }, () => around.call(messenger, reference, messageId, window), (items) => ({
1040
+ ...items[0] ? { ids: { chat: items[0].chatId, message_id: messageId } } : {},
1041
+ counts: { messages: items.length }
1042
+ })), "around")
1043
+ } : {},
1044
+ send: /* @__PURE__ */ __name((chatId, text, options) => timed("messages.send", {
1045
+ ids: {
1046
+ chat: chatId,
1047
+ send: options.sendId,
1048
+ ...options.replyTo ? { reply: options.replyTo } : {},
1049
+ ...options.threadId ? { thread: options.threadId } : {}
1050
+ }
1051
+ }, () => messenger.send(chatId, text, options), (sent) => ({ ids: { chat: sent.message.chatId || chatId, message_id: sent.message.id } })), "send"),
1052
+ ...watch ? {
1053
+ watch: /* @__PURE__ */ __name((onEvent, signal, onReady) => counted("messages.watch", onEvent, (counting) => watch.call(messenger, counting, signal, onReady), byEvent), "watch")
1054
+ } : {},
1055
+ ...feed ? { feed: /* @__PURE__ */ __name((onBatch, signal) => timed("history.feed", {}, () => feed.call(messenger, onBatch, signal)), "feed") } : {},
1056
+ ...listen ? {
1057
+ listen: /* @__PURE__ */ __name((onEvent, signal) => counted("messages.listen", onEvent, (counting) => listen.call(messenger, counting, signal), byEvent), "listen")
1058
+ } : {},
1059
+ ...listenHistory ? {
1060
+ listenHistory: /* @__PURE__ */ __name((onBatch, signal) => counted("history.listen", onBatch, (counting) => listenHistory.call(messenger, counting, signal), byPart), "listenHistory")
1061
+ } : {},
1062
+ logout: /* @__PURE__ */ __name(() => timed("session.logout", {}, () => messenger.logout()), "logout"),
1063
+ close: /* @__PURE__ */ __name(() => messenger.close(), "close")
1064
+ }, (name, call) => (...args) => timed(`adapter.${name}`, {}, () => call(...args)));
1065
+ }, "observed");
1066
+ var byEvent = /* @__PURE__ */ __name((event, counts) => {
1067
+ counts[event.event] = (counts[event.event] ?? 0) + 1;
1068
+ }, "byEvent");
1069
+ var byPart = /* @__PURE__ */ __name((batch, counts) => {
1070
+ counts.batches = (counts.batches ?? 0) + 1;
1071
+ for (const [part, items] of Object.entries(batch))
1072
+ if (Array.isArray(items) && items.length > 0)
1073
+ counts[part] = (counts[part] ?? 0) + items.length;
1074
+ }, "byPart");
1075
+
1076
+ // node_modules/.pnpm/@wirecat+cli-core@0.652.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_8be4ae3be01c4720e564a3a01e19fd64/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
1071
1077
  var lazyStore = /* @__PURE__ */ __name((env, command, version) => {
1072
1078
  let opened;
1073
1079
  return {
@@ -1475,9 +1481,12 @@ export {
1475
1481
  commandPermissions,
1476
1482
  knownPermissionKeys,
1477
1483
  knownBeside,
1484
+ unknownPermissionKeys,
1478
1485
  unknownPermissionIssues,
1479
1486
  refuseUnknownPermissionKeys,
1487
+ stored,
1480
1488
  fill,
1489
+ connectFor,
1481
1490
  connectedFor,
1482
1491
  refuseLocalWrite,
1483
1492
  messengerContext