@wirecat/drive-cli 0.63.0 → 0.65.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 (193) hide show
  1. package/README.md +2 -1
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bundle/{all-profiles-GZJS3UKC.js → all-profiles-PD7GJHFA.js} +14 -13
  4. package/dist/bundle/{anthropic-RGV3WXX5.js → anthropic-PJKFON5H.js} +25 -14
  5. package/dist/bundle/{app-server-AA2PJ7PV.js → app-server-6ELQA6FJ.js} +59 -56
  6. package/dist/bundle/{bun-OXZYIA3R.js → bun-P54TGES2.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-D45NSDM3.js → bun-sqlite-TND5ZRJH.js} +12 -8
  8. package/dist/bundle/chunk-2AFI4KGI.js +185 -0
  9. package/dist/bundle/{chunk-Q5DJTRKV.js → chunk-3HXNDF6Q.js} +2 -2
  10. package/dist/bundle/{chunk-DJHLVUL6.js → chunk-3ONWN3IA.js} +278 -49
  11. package/dist/bundle/{chunk-WYGWWHZP.js → chunk-42G2XNPN.js} +2 -2
  12. package/dist/bundle/chunk-4AOINPN2.js +66 -0
  13. package/dist/bundle/{chunk-J4DIHPZ6.js → chunk-4EDWLR22.js} +1 -1
  14. package/dist/bundle/{chunk-ABYGSJZ4.js → chunk-4Y5YBFMS.js} +7 -7
  15. package/dist/bundle/{chunk-YGU6ULU5.js → chunk-54V4H6PM.js} +16 -16
  16. package/dist/bundle/{chunk-2TFXK3R4.js → chunk-5XSBCMAF.js} +4 -4
  17. package/dist/bundle/{chunk-2HF2MRXI.js → chunk-6DCLZLGX.js} +1 -1
  18. package/dist/bundle/{chunk-OD4U7GUY.js → chunk-7AQGVX5O.js} +20 -20
  19. package/dist/bundle/{chunk-YIP7ELON.js → chunk-7TAP7Y2E.js} +727 -518
  20. package/dist/bundle/{chunk-TF23BZW5.js → chunk-A27UVLPK.js} +3 -3
  21. package/dist/bundle/{chunk-LZEOQW7S.js → chunk-A4QNADEX.js} +58 -52
  22. package/dist/bundle/{chunk-FXBHOCJK.js → chunk-ADLS6FVG.js} +1 -1
  23. package/dist/bundle/{chunk-LMAVCYLQ.js → chunk-B2LPCHQN.js} +4 -4
  24. package/dist/bundle/{chunk-5PPL7JDM.js → chunk-CGQRZRTH.js} +2 -2
  25. package/dist/bundle/{chunk-VAUMOZU5.js → chunk-CWLL63JD.js} +107 -48
  26. package/dist/bundle/{chunk-V3NVXIQR.js → chunk-D6Z43SOG.js} +1563 -266
  27. package/dist/bundle/{chunk-OXY6SSZG.js → chunk-D7WB54P7.js} +127 -28
  28. package/dist/bundle/{chunk-VJEOGKAN.js → chunk-DA63E2UM.js} +13 -9
  29. package/dist/bundle/{chunk-EOOGWUTP.js → chunk-ECEP4SO3.js} +20 -20
  30. package/dist/bundle/{chunk-NEFSGCVA.js → chunk-EHU6EYGO.js} +38 -28
  31. package/dist/bundle/{chunk-4OSSOWDM.js → chunk-ELJUBPY4.js} +1 -1
  32. package/dist/bundle/{chunk-FRIJUILO.js → chunk-EM7NL5ES.js} +3 -3
  33. package/dist/bundle/{chunk-3BZRKLJ6.js → chunk-EU5MD24W.js} +13 -13
  34. package/dist/bundle/{chunk-MOTRI3SY.js → chunk-EZ2OLYEK.js} +24 -2
  35. package/dist/bundle/{chunk-6MQSQ4LX.js → chunk-F56DRBGY.js} +370 -717
  36. package/dist/bundle/{chunk-ZOJU7ZFI.js → chunk-FA6JNXCC.js} +8 -8
  37. package/dist/bundle/{chunk-ND6LLYGF.js → chunk-FBHSWQU7.js} +1531 -136
  38. package/dist/bundle/{chunk-Z42YYLTS.js → chunk-GW3LBY3T.js} +74 -72
  39. package/dist/bundle/{chunk-Y6GNA7HE.js → chunk-HP3NT6JJ.js} +23 -5
  40. package/dist/bundle/{chunk-DJ3SDJZY.js → chunk-I272E6UR.js} +9 -8
  41. package/dist/bundle/{chunk-L37LMMRJ.js → chunk-IBO23OID.js} +2 -2
  42. package/dist/bundle/{chunk-CE2TJBLP.js → chunk-II4S2DBJ.js} +3 -3
  43. package/dist/bundle/{chunk-ZM5J6ZMB.js → chunk-IKHOIXJR.js} +2 -2
  44. package/dist/bundle/{chunk-PO5RQQIG.js → chunk-IMHW7VIV.js} +5 -5
  45. package/dist/bundle/{chunk-3HK5WMI5.js → chunk-JMJIH6JH.js} +6 -6
  46. package/dist/bundle/{chunk-FUITWY7O.js → chunk-JPPPLKAO.js} +26 -1
  47. package/dist/bundle/{chunk-4S4JMW6I.js → chunk-LMKPP2JP.js} +1 -1
  48. package/dist/bundle/{chunk-HZZCEQTH.js → chunk-M7ELUGU6.js} +4 -4
  49. package/dist/bundle/{chunk-ZMOUUOT2.js → chunk-MCPOZNWG.js} +1 -1
  50. package/dist/bundle/{chunk-XNVFKMVR.js → chunk-NI5PD5KM.js} +39485 -35729
  51. package/dist/bundle/{chunk-2TDUGC5D.js → chunk-NQ5XMSLA.js} +4927 -1978
  52. package/dist/bundle/chunk-NQRTKYJB.js +257 -0
  53. package/dist/bundle/{chunk-44SBK6KB.js → chunk-O6K2E7OA.js} +4201 -2565
  54. package/dist/bundle/{chunk-534OBX5Y.js → chunk-O7ZDCOZE.js} +1 -1
  55. package/dist/bundle/{chunk-7EMQ26BA.js → chunk-OFJXHEFT.js} +13 -13
  56. package/dist/bundle/chunk-OWMZUWCM.js +109 -0
  57. package/dist/bundle/chunk-PHOL2DZM.js +138 -0
  58. package/dist/bundle/{chunk-UQLWMGSD.js → chunk-PLP5527C.js} +5 -5
  59. package/dist/bundle/{chunk-3QINVLZI.js → chunk-RNHGQ35R.js} +1 -1
  60. package/dist/bundle/{chunk-27YUUGXQ.js → chunk-RX5CJ55S.js} +1 -1
  61. package/dist/bundle/{chunk-XIUDS3OK.js → chunk-SE352DBY.js} +1 -1
  62. package/dist/bundle/chunk-SEQWBZYH.js +18 -0
  63. package/dist/bundle/{chunk-33MGFUED.js → chunk-SIWXYB4E.js} +3789 -3538
  64. package/dist/bundle/{chunk-4CIZWCXV.js → chunk-SNLSEYJO.js} +1 -1
  65. package/dist/bundle/{chunk-XDC3TWTL.js → chunk-SS4LKLD7.js} +52 -605
  66. package/dist/bundle/{chunk-BKYMKVHT.js → chunk-TMHF4BCL.js} +2 -2
  67. package/dist/bundle/{chunk-FEZF3TII.js → chunk-TOVWMURV.js} +74 -6
  68. package/dist/bundle/{chunk-QCKZ3GAA.js → chunk-TTP4NOP3.js} +4 -4
  69. package/dist/bundle/chunk-UTNRBOEN.js +53 -0
  70. package/dist/bundle/{chunk-2NIC72HH.js → chunk-VDZY3L7U.js} +3 -1
  71. package/dist/bundle/chunk-VHQYWFWV.js +13 -0
  72. package/dist/bundle/{chunk-VKPCONDQ.js → chunk-VLXWAH5E.js} +4 -4
  73. package/dist/bundle/{chunk-6KQJSFYF.js → chunk-VMAMRFFC.js} +23 -23
  74. package/dist/bundle/{chunk-6EY46GAN.js → chunk-W2XY6C5S.js} +2 -2
  75. package/dist/bundle/{chunk-J24ZFCWM.js → chunk-WRAUO5EJ.js} +22 -24
  76. package/dist/bundle/{chunk-S4RXABDR.js → chunk-WRMJN6UQ.js} +3 -3
  77. package/dist/bundle/{chunk-UPOSDTPT.js → chunk-WVJHZIDH.js} +3 -3
  78. package/dist/bundle/{chunk-E4SDKMBJ.js → chunk-X7YGGWXI.js} +1 -59
  79. package/dist/bundle/{chunk-O2XOX4HB.js → chunk-XPWZSW6Y.js} +50 -34
  80. package/dist/bundle/{chunk-PDCCYHCH.js → chunk-XYE7XZPB.js} +5 -5
  81. package/dist/bundle/{chunk-RKELRWH7.js → chunk-Y5PKRITX.js} +5 -5
  82. package/dist/bundle/{chunk-XR6ESRU6.js → chunk-Z2ADO6UA.js} +2 -2
  83. package/dist/bundle/{chunk-YUWPNG7B.js → chunk-ZD4MB7NH.js} +1 -1
  84. package/dist/bundle/{chunk-TWUH22Z5.js → chunk-ZILALBYQ.js} +4 -4
  85. package/dist/bundle/{chunk-SXM6MHRR.js → chunk-ZR2EJPMQ.js} +44 -15
  86. package/dist/bundle/command-contract-25E4PYMD.js +40 -0
  87. package/dist/bundle/command-server-entry-36JXYIJB.js +170 -0
  88. package/dist/bundle/{decode-G5YEIPNC.js → decode-T5ZW57WZ.js} +8 -8
  89. package/dist/bundle/{dispatch-GEFIXA6X.js → dispatch-RMA2XFYA.js} +11 -11
  90. package/dist/bundle/drive.js +11 -11
  91. package/dist/bundle/{echarts-W2CWHNXR.js → echarts-KQ44LPSF.js} +2 -2
  92. package/dist/bundle/{embed-OBFFPVF4.js → embed-Q7XST53J.js} +9 -9
  93. package/dist/bundle/{embedder-NGCBQHIG.js → embedder-RWZSBVW2.js} +12 -12
  94. package/dist/bundle/entry-HPLW4QL2.js +25 -0
  95. package/dist/bundle/{failure-GV77W3CD.js → failure-7NP4QPIN.js} +4 -4
  96. package/dist/bundle/first-run-RL3RKYZW.js +30 -0
  97. package/dist/bundle/first-screen-NX3TM2VJ.js +38 -0
  98. package/dist/bundle/google-DPD5N6AQ.js +42 -0
  99. package/dist/bundle/{google-api-Z3NSTBBR.js → google-api-P5DRHD7L.js} +61 -56
  100. package/dist/bundle/grants-TX4MHLI4.js +109 -0
  101. package/dist/bundle/{identity-OM6GFZ7T.js → identity-VDV6CHRW.js} +6 -6
  102. package/dist/bundle/{instructions-YQBQSYSS.js → instructions-Q45FVY6H.js} +1 -1
  103. package/dist/bundle/{login-7RYSDVN3.js → login-XKN3NI6X.js} +67 -62
  104. package/dist/bundle/{mcp-GWDA3HOA.js → mcp-7KQUJNFN.js} +2 -2
  105. package/dist/bundle/{node-IVU33RL7.js → node-MSW565D3.js} +2 -2
  106. package/dist/bundle/{node-KM3CUABH.js → node-P4E63KXA.js} +9 -9
  107. package/dist/bundle/{node-sqlite-SIH5BEW2.js → node-sqlite-S74XVVHL.js} +13 -9
  108. package/dist/bundle/oauth-6R7AWAES.js +22 -0
  109. package/dist/bundle/{open-IAO2SNII.js → open-P7UQG7XJ.js} +8 -8
  110. package/dist/bundle/{openai-SGOUBHXP.js → openai-DDHJ57KZ.js} +19 -40
  111. package/dist/bundle/{process-BPBMV3AT.js → process-NMUB5SHK.js} +1 -1
  112. package/dist/bundle/{program-MYKKJ4F6.js → program-PJNWP6JW.js} +517 -330
  113. package/dist/bundle/prompt-VOSMK4C2.js +19 -0
  114. package/dist/bundle/{reasons-57J2D77K.js → reasons-KDAXOC5S.js} +5 -5
  115. package/dist/bundle/{recognize-A5C5RPB3.js → recognize-GZIY63HS.js} +7 -7
  116. package/dist/bundle/{remote-VWYFLRGO.js → remote-V3YGN7LN.js} +10 -10
  117. package/dist/bundle/{rerank-4NGQWREA.js → rerank-XRU6AVN7.js} +10 -10
  118. package/dist/bundle/{serve-Y6LQTFH5.js → serve-NDOAFA57.js} +12 -12
  119. package/dist/bundle/{server-6AUHIIUA.js → server-BKGWJYMC.js} +46 -44
  120. package/dist/bundle/server-QD2MUJJZ.js +72 -0
  121. package/dist/bundle/{services-2W4J7EMW.js → services-TYDMFQCA.js} +129 -39
  122. package/dist/bundle/{sqlite-runtime-P6BBDX2H.js → sqlite-runtime-UAFJKSJR.js} +9 -9
  123. package/dist/bundle/{start-AFFA3LKM.js → start-2ZLDP2OE.js} +30 -8
  124. package/dist/bundle/{state-PXKKXR3R.js → state-6SP27J2K.js} +9 -9
  125. package/dist/bundle/{store-CN6JEUC4.js → store-4UUY545Q.js} +42 -18
  126. package/dist/bundle/{store-IVV2BAGZ.js → store-EJN27MXI.js} +69 -28
  127. package/dist/bundle/store-maintenance-command-LETURZDC.js +60 -0
  128. package/dist/bundle/tokens-MTFJPTYT.js +107 -0
  129. package/dist/commands/account.d.ts +4 -0
  130. package/dist/commands/account.d.ts.map +1 -0
  131. package/dist/commands/account.js +33 -0
  132. package/dist/commands/account.js.map +1 -0
  133. package/dist/commands/config.d.ts.map +1 -1
  134. package/dist/commands/config.js +6 -5
  135. package/dist/commands/config.js.map +1 -1
  136. package/dist/commands/context.d.ts +4 -2
  137. package/dist/commands/context.d.ts.map +1 -1
  138. package/dist/commands/context.js.map +1 -1
  139. package/dist/commands/documents.d.ts +2 -0
  140. package/dist/commands/documents.d.ts.map +1 -1
  141. package/dist/commands/documents.js +39 -3
  142. package/dist/commands/documents.js.map +1 -1
  143. package/dist/config.d.ts +13 -0
  144. package/dist/config.d.ts.map +1 -1
  145. package/dist/config.js +32 -2
  146. package/dist/config.js.map +1 -1
  147. package/dist/documents-add.d.ts +49 -0
  148. package/dist/documents-add.d.ts.map +1 -0
  149. package/dist/documents-add.js +122 -0
  150. package/dist/documents-add.js.map +1 -0
  151. package/dist/errors.d.ts +1 -0
  152. package/dist/errors.d.ts.map +1 -1
  153. package/dist/errors.js +9 -1
  154. package/dist/errors.js.map +1 -1
  155. package/dist/knowledge.d.ts +1 -1
  156. package/dist/knowledge.d.ts.map +1 -1
  157. package/dist/knowledge.js +15 -17
  158. package/dist/knowledge.js.map +1 -1
  159. package/dist/model.d.ts +3 -0
  160. package/dist/model.d.ts.map +1 -1
  161. package/dist/model.js.map +1 -1
  162. package/dist/profile-lock.d.ts +1 -0
  163. package/dist/profile-lock.d.ts.map +1 -1
  164. package/dist/profile-lock.js +1 -0
  165. package/dist/profile-lock.js.map +1 -1
  166. package/dist/program.d.ts.map +1 -1
  167. package/dist/program.js +24 -15
  168. package/dist/program.js.map +1 -1
  169. package/dist/reasons.d.ts.map +1 -1
  170. package/dist/reasons.js +25 -0
  171. package/dist/reasons.js.map +1 -1
  172. package/dist/store.d.ts.map +1 -1
  173. package/dist/store.js +20 -0
  174. package/dist/store.js.map +1 -1
  175. package/dist/version.d.ts +1 -1
  176. package/dist/version.js +1 -1
  177. package/package.json +4 -4
  178. package/dist/bundle/chunk-AEX37ETW.js +0 -35
  179. package/dist/bundle/chunk-OTROVC4E.js +0 -62
  180. package/dist/bundle/chunk-Z5KC7XBR.js +0 -33
  181. package/dist/bundle/command-contract-BRW3AP44.js +0 -38
  182. package/dist/bundle/entry-ET6HGM7A.js +0 -22
  183. package/dist/bundle/first-run-JG52UZVO.js +0 -30
  184. package/dist/bundle/first-screen-CIL3GFAA.js +0 -36
  185. package/dist/bundle/google-CIWUVJ5C.js +0 -36
  186. package/dist/bundle/grants-3S4RL3WB.js +0 -104
  187. package/dist/bundle/oauth-PT4JEHLL.js +0 -22
  188. package/dist/bundle/prompt-3ZM64DCB.js +0 -17
  189. package/dist/bundle/server-PFHI35HA.js +0 -69
  190. package/dist/bundle/store-maintenance-command-MSY2QNEH.js +0 -59
  191. package/dist/bundle/tokens-P4LPNUFW.js +0 -102
  192. package/dist/bundle/{chunk-ZQ3GWKDQ.js → chunk-YVNHQFLC.js} +0 -0
  193. package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-CE73EWJ2.js} +3 -3
@@ -2,7 +2,26 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  refuseLacking
5
- } from "./chunk-J24ZFCWM.js";
5
+ } from "./chunk-WRAUO5EJ.js";
6
+ import {
7
+ FloodMemory,
8
+ OFFLINE,
9
+ RecipientList,
10
+ capability,
11
+ ceilingRefusal,
12
+ chatIdIn,
13
+ floodPathFor,
14
+ guardFor,
15
+ holdEnd,
16
+ profilesOnAccount,
17
+ recipientsPathFor,
18
+ servicesFor,
19
+ throughWrapper,
20
+ withFileLockAsync
21
+ } from "./chunk-O6K2E7OA.js";
22
+ import {
23
+ servingProfiles
24
+ } from "./chunk-EM7NL5ES.js";
6
25
  import {
7
26
  asFirstWord,
8
27
  baseContext,
@@ -13,68 +32,45 @@ import {
13
32
  recalledAccount,
14
33
  rememberAccount,
15
34
  rootOf2 as rootOf
16
- } from "./chunk-33MGFUED.js";
35
+ } from "./chunk-SIWXYB4E.js";
17
36
  import {
18
37
  providerErrorKey
19
- } from "./chunk-VJEOGKAN.js";
20
- import {
21
- MESSENGER_CHANGE_REFUSAL,
22
- readOnlyRefusal
23
- } from "./chunk-ZM5J6ZMB.js";
24
- import {
25
- servingProfiles
26
- } from "./chunk-FRIJUILO.js";
27
- import {
28
- OFFLINE,
29
- capability,
30
- chatIdIn,
31
- chatReferenceOf,
32
- ensureAccount,
33
- foldName,
34
- isId,
35
- pickPerson,
36
- profilesOnAccount,
37
- servicesFor,
38
- throughWrapper
39
- } from "./chunk-44SBK6KB.js";
38
+ } from "./chunk-DA63E2UM.js";
40
39
  import {
41
40
  AUTHORITY_KEY,
42
41
  CEILING_KEY,
43
42
  DEFAULT_PERMISSIONS,
44
- LOG_ATTRIBUTES,
45
43
  WRITE_KEYS,
46
44
  codeOf,
47
45
  currentOperation,
48
- currentRun,
49
- fromLogAttributes,
50
46
  keyForCommand,
51
- keyForWrite,
52
47
  levelFor,
53
48
  limitBatch,
54
- logAttributes,
55
49
  readKeysForCommand,
56
50
  skipFlagFor
57
- } from "./chunk-6MQSQ4LX.js";
51
+ } from "./chunk-F56DRBGY.js";
58
52
  import {
59
- openStore
60
- } from "./chunk-XNVFKMVR.js";
53
+ chatReferenceOf,
54
+ ensureAccount,
55
+ foldName,
56
+ isId,
57
+ openStore,
58
+ pickPerson
59
+ } from "./chunk-NI5PD5KM.js";
61
60
  import {
62
61
  isCliFailure
63
- } from "./chunk-E4SDKMBJ.js";
62
+ } from "./chunk-4AOINPN2.js";
64
63
  import {
65
- logRecordOf,
66
- realSleep,
67
- resolvePaths,
68
- writeSecurely
69
- } from "./chunk-OD4U7GUY.js";
64
+ resolvePaths
65
+ } from "./chunk-7AQGVX5O.js";
70
66
  import {
71
67
  CliError
72
- } from "./chunk-4OSSOWDM.js";
68
+ } from "./chunk-ELJUBPY4.js";
73
69
  import {
74
70
  __name
75
71
  } from "./chunk-ZVVMGPBJ.js";
76
72
 
77
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/cli/messenger/ask.js
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
78
74
  import { openSync } from "node:fs";
79
75
  import { createInterface } from "node:readline";
80
76
  import { ReadStream } from "node:tty";
@@ -129,551 +125,11 @@ var terminalAsker = /* @__PURE__ */ __name((command) => async (key, request) =>
129
125
  throw new CliError("cancelled", `${key}: not done \u2014 the answer was no`);
130
126
  }, "terminalAsker");
131
127
 
132
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/guard.js
133
- import { randomUUID } from "node:crypto";
134
-
135
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/flood.js
136
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
137
- import { dirname, join } from "node:path";
138
- var MOST_DEADLINES = 50;
139
- var LIMITED_HOLD_MS = 60 * 60 * 1e3;
140
- var FROZEN_HOLD_MS = 24 * 60 * 60 * 1e3;
141
- var NO_END = "9999-12-31T23:59:59.999Z";
142
- var holdEnd = /* @__PURE__ */ __name((block, show = (iso) => iso) => block.until === null ? "until lifted" : `until ${show(block.until)}`, "holdEnd");
143
- var floodPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "flood", `${profile}.json`), "floodPathFor");
144
- var FloodMemory = class {
145
- static {
146
- __name(this, "FloodMemory");
147
- }
148
- path;
149
- now;
150
- constructor(path, now = Date.now) {
151
- this.path = path;
152
- this.now = now;
153
- }
154
- /** What is still in force; anything expired is left out. */
155
- read() {
156
- const now = this.now();
157
- let raw;
158
- try {
159
- raw = JSON.parse(readFileSync(this.path, "utf8"));
160
- } catch {
161
- return { deadlines: [] };
162
- }
163
- const alive = /* @__PURE__ */ __name((until) => typeof until === "string" && Date.parse(until) > now, "alive");
164
- const deadlines = Array.isArray(raw.deadlines) ? raw.deadlines.filter((one) => typeof one?.operation === "string" && alive(one.until)) : [];
165
- const block = raw.sendBlock && (raw.sendBlock.until === NO_END ? { ...raw.sendBlock, until: null } : raw.sendBlock);
166
- const held = block && (block.until === null || alive(block.until));
167
- return { deadlines, ...held ? { sendBlock: block } : {} };
168
- }
169
- /** The deadline this call is still under: one for its chat, or one for the call in every chat. */
170
- owed(operation, chatId) {
171
- return this.read().deadlines.filter((one) => one.operation === operation && (one.chatId === void 0 || one.chatId === chatId)).sort((a, b) => b.until.localeCompare(a.until))[0];
172
- }
173
- remember(deadline) {
174
- const { waitMs, ...rest } = deadline;
175
- const kept = { ...rest, until: new Date(this.now() + waitMs).toISOString() };
176
- const state = this.read();
177
- const others = state.deadlines.filter((one) => one.operation !== kept.operation || one.chatId !== kept.chatId);
178
- const deadlines = [...others, kept].sort((a, b) => b.until.localeCompare(a.until)).slice(0, MOST_DEADLINES);
179
- this.#write({ ...state, deadlines });
180
- return kept;
181
- }
182
- sendBlock() {
183
- return this.read().sendBlock;
184
- }
185
- /** A ban the messenger gave no end for holds until lifted; a spam limit or a freeze without one, for a while. */
186
- block(block) {
187
- const now = this.now();
188
- const holdMs = { limited: LIMITED_HOLD_MS, frozen: FROZEN_HOLD_MS, banned: void 0 }[block.state];
189
- const kept = {
190
- ...block,
191
- since: new Date(now).toISOString(),
192
- until: block.until ?? (holdMs === void 0 ? null : new Date(now + holdMs).toISOString())
193
- };
194
- this.#write({ ...this.read(), sendBlock: kept });
195
- return kept;
196
- }
197
- /** Lifts only a block of this state: an account found not frozen may still be limited for spam. */
198
- unblock(state) {
199
- const { sendBlock, ...rest } = this.read();
200
- if (sendBlock?.state === state)
201
- this.#write(rest);
202
- }
203
- /** Forgets every wait and lifts the hold, and answers with what was still in force. */
204
- clear() {
205
- const cleared = this.read();
206
- this.#write({ deadlines: [] });
207
- return cleared;
208
- }
209
- #write({ sendBlock, ...rest }) {
210
- const state = sendBlock ? { ...rest, sendBlock: { ...sendBlock, until: sendBlock.until ?? NO_END } } : rest;
211
- mkdirSync(dirname(this.path), { recursive: true, mode: 448 });
212
- const temporary = `${this.path}.${process.pid}.tmp`;
213
- writeFileSync(temporary, `${JSON.stringify(state)}
214
- `, { mode: 384 });
215
- renameSync(temporary, this.path);
216
- }
217
- };
218
-
219
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/journal.js
220
- import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
221
- import { dirname as dirname3, join as join2 } from "node:path";
222
-
223
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/file-lock.js
224
- import { closeSync, mkdirSync as mkdirSync2, openSync as openSync2, statSync, unlinkSync } from "node:fs";
225
- import { dirname as dirname2 } from "node:path";
226
- var LOCK_WAIT_MS = 5e3;
227
- var LOCK_STALE_MS = 3e4;
228
- var RETRY_MS = 20;
229
- var pause = new Int32Array(new SharedArrayBuffer(4));
230
- var withFileLock = /* @__PURE__ */ __name((path, what2, body, waitMs = LOCK_WAIT_MS) => {
231
- const lock = lockFor(path);
232
- const deadline = Date.now() + waitMs;
233
- while (!taken(lock)) {
234
- if (Date.now() >= deadline)
235
- throw lockTimeout(what2, waitMs, lock);
236
- Atomics.wait(pause, 0, 0, RETRY_MS);
237
- }
238
- return holding(lock, body);
239
- }, "withFileLock");
240
- var withFileLockAsync = /* @__PURE__ */ __name(async (path, what2, body, waitMs = LOCK_WAIT_MS, sleep = realSleep) => {
241
- const lock = lockFor(path);
242
- const deadline = Date.now() + waitMs;
243
- while (!taken(lock)) {
244
- if (Date.now() >= deadline)
245
- throw lockTimeout(what2, waitMs, lock);
246
- await sleep(RETRY_MS);
247
- }
248
- return holding(lock, body);
249
- }, "withFileLockAsync");
250
- var lockFor = /* @__PURE__ */ __name((path) => {
251
- mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
252
- return `${path}.lock`;
253
- }, "lockFor");
254
- var taken = /* @__PURE__ */ __name((lock) => {
255
- for (; ; ) {
256
- try {
257
- closeSync(openSync2(lock, "wx", 384));
258
- return true;
259
- } catch (error) {
260
- if (error.code !== "EEXIST")
261
- throw error;
262
- if (Date.now() - lockTime(lock) <= LOCK_STALE_MS)
263
- return false;
264
- try {
265
- unlinkSync(lock);
266
- } catch {
267
- }
268
- }
269
- }
270
- }, "taken");
271
- var holding = /* @__PURE__ */ __name((lock, body) => {
272
- try {
273
- return body();
274
- } finally {
275
- try {
276
- unlinkSync(lock);
277
- } catch {
278
- }
279
- }
280
- }, "holding");
281
- var lockTimeout = /* @__PURE__ */ __name((what2, waitMs, lock) => new CliError("timeout", `${what2} stayed locked for ${waitMs / 1e3}s (${lock})`), "lockTimeout");
282
- var lockTime = /* @__PURE__ */ __name((lock) => {
283
- try {
284
- return statSync(lock).mtimeMs;
285
- } catch {
286
- return Date.now();
287
- }
288
- }, "lockTime");
289
-
290
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/journal.js
291
- var sendsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "sends", `${profile}.jsonl`), "sendsPathFor");
292
- var SendJournal = class {
293
- static {
294
- __name(this, "SendJournal");
295
- }
296
- path;
297
- resource;
298
- constructor(path, resource = { service: "unknown", version: "unknown" }) {
299
- this.path = path;
300
- this.resource = resource;
301
- }
302
- /**
303
- * Runs `body` with the journal to itself, across processes: two sends at the limit must not both
304
- * read "one left". A lock file opened with `wx`, because `flock` is not there on Windows.
305
- */
306
- locked(body) {
307
- return withFileLock(this.path, "the send journal", body);
308
- }
309
- /** `locked` without blocking the thread while another process holds the journal: what `serve` uses. */
310
- lockedAsync(body) {
311
- return withFileLockAsync(this.path, "the send journal", body);
312
- }
313
- append(entry) {
314
- const { at, ...attributes } = entry;
315
- const { runId, command, traceId } = currentRun();
316
- const record = logRecordOf({
317
- severity: entry.outcome === "sent" || entry.outcome === "reserved" ? "info" : "warn",
318
- event: logAttributes({ event: "send.recorded", ...attributes }),
319
- time: at,
320
- runId,
321
- ...traceId === void 0 ? {} : { traceId },
322
- command,
323
- resource: this.resource,
324
- allow: LOG_ATTRIBUTES
325
- });
326
- mkdirSync3(dirname3(this.path), { recursive: true, mode: 448 });
327
- appendFileSync(this.path, `${JSON.stringify(record)}
328
- `, { mode: 384 });
329
- }
330
- /**
331
- * Oldest first, each reservation folded into its outcome; one with no outcome yet is in flight,
332
- * or its process died. A line that does not parse is skipped: a torn last write must not block sending.
333
- */
334
- entries(filter) {
335
- const lines = this.#lines();
336
- const settled2 = new Set(lines.filter((entry) => entry.outcome !== "reserved").map((entry) => entry.reservation));
337
- const entries = lines.filter((entry) => entry.outcome !== "reserved" || !settled2.has(entry.reservation)).map(({ reservation, ...entry }) => entry.outcome === "reserved" ? { ...entry, reservation } : entry).map(withSendId);
338
- return filter === void 0 ? entries : entries.filter((entry) => (filter.outcome === void 0 || entry.outcome === filter.outcome) && (filter.chatId === void 0 || entry.chatId === filter.chatId) && (filter.operationId === void 0 || entry.operationId === filter.operationId) && (filter.errorCode === void 0 || entry.errorCode === filter.errorCode) && (filter.key === void 0 || entry.key === filter.key));
339
- }
340
- #lines() {
341
- let text;
342
- try {
343
- text = readFileSync2(this.path, "utf8");
344
- } catch {
345
- return [];
346
- }
347
- return text.split("\n").filter((line) => line.trim() !== "").flatMap((line) => {
348
- try {
349
- return [entryOf(JSON.parse(line))];
350
- } catch {
351
- return [];
352
- }
353
- });
354
- }
355
- };
356
- var entryOf = /* @__PURE__ */ __name((line) => {
357
- if (!("attributes" in line))
358
- return line;
359
- const { event: _, ...attributes } = line.attributes;
360
- return { at: line.time, ...fromLogAttributes(attributes) };
361
- }, "entryOf");
362
- var withSendId = /* @__PURE__ */ __name((entry) => {
363
- const { cid, ...rest } = entry;
364
- return cid === void 0 || rest.sendId !== void 0 ? rest : { ...rest, sendId: String(cid) };
365
- }, "withSendId");
366
-
367
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/recipients.js
368
- import { existsSync, readFileSync as readFileSync3, rmSync } from "node:fs";
369
- import { join as join3 } from "node:path";
370
- var recipientsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.recipients.json`), "recipientsPathFor");
371
- var RecipientList = class {
372
- static {
373
- __name(this, "RecipientList");
374
- }
375
- path;
376
- command;
377
- lockWaitMs;
378
- /** `command` names the program in the hint that turns the list off. */
379
- constructor(path, command, lockWaitMs) {
380
- this.path = path;
381
- this.command = command;
382
- this.lockWaitMs = lockWaitMs;
383
- }
384
- /** `undefined` when the list is off. A file that cannot be read refuses rather than opening up. */
385
- read() {
386
- if (!existsSync(this.path))
387
- return void 0;
388
- try {
389
- const parsed = JSON.parse(readFileSync3(this.path, "utf8"));
390
- if (!Array.isArray(parsed.chats))
391
- throw new Error("no `chats` array");
392
- return parsed.chats;
393
- } catch (error) {
394
- throw new CliError("configuration_error", `the recipient list ${this.path} cannot be read (${error instanceof Error ? error.message : String(error)}) \u2014 fix the file or turn the list off with \`${this.command} recipients clear\``);
395
- }
396
- }
397
- list(filter = {}) {
398
- const chats = this.read();
399
- return {
400
- state: chats === void 0 ? "off" : chats.length === 0 ? "empty" : "on",
401
- items: (chats ?? []).filter((chat) => (filter.id === void 0 || chat.id === filter.id) && (filter.title === void 0 || chat.title?.toLocaleLowerCase() === filter.title.toLocaleLowerCase()))
402
- };
403
- }
404
- /** Whether it was new. Adding one again fills in a partner an older entry was stored without. */
405
- add(recipient) {
406
- return this.#locked(() => this.#added(recipient));
407
- }
408
- /** `add` waiting for the lock on timers: `recipients add` connects, so it runs inside `serve` when one holds the account. */
409
- addAsync(recipient) {
410
- return withFileLockAsync(this.path, "the recipient list", () => this.#added(recipient), this.lockWaitMs);
411
- }
412
- #added(recipient) {
413
- const chats = this.read() ?? [];
414
- const known = chats.find((chat) => chat.id === recipient.id);
415
- if (known) {
416
- if (recipient.partnerId && !known.partnerId) {
417
- this.#write(chats.map((chat) => chat === known ? { ...known, partnerId: recipient.partnerId } : chat));
418
- }
419
- return false;
420
- }
421
- this.#write([...chats, recipient]);
422
- return true;
423
- }
424
- /** The id or the title as it was stored; `undefined` when neither matched. */
425
- remove(reference) {
426
- return this.#locked(() => {
427
- const chats = this.read() ?? [];
428
- const wanted = reference.trim();
429
- const gone = chats.find((chat) => chat.id === wanted) ?? chats.find((chat) => chat.title?.toLocaleLowerCase() === wanted.toLocaleLowerCase());
430
- if (gone)
431
- this.#write(chats.filter((chat) => chat !== gone));
432
- return gone;
433
- });
434
- }
435
- /**
436
- * The chat the messenger now names `to`: its entry, and a partner of that id, follow it. Only an entry already there
437
- * changes, and no list is created, so the list never opens up. Whether anything changed.
438
- */
439
- async rekey(from, to) {
440
- if (from === to)
441
- return false;
442
- return withFileLockAsync(this.path, "the recipient list", () => {
443
- const chats = this.read();
444
- if (!chats?.some((chat) => chat.id === from || chat.partnerId === from))
445
- return false;
446
- const held = chats.some((chat) => chat.id === to);
447
- this.#write(chats.filter((chat) => !(held && chat.id === from)).map((chat) => ({
448
- ...chat,
449
- ...chat.id === from ? { id: to } : {},
450
- ...chat.partnerId === from ? { partnerId: to } : {}
451
- })));
452
- return true;
453
- }, this.lockWaitMs);
454
- }
455
- /** Whether there was a list to turn off. */
456
- off() {
457
- return this.#locked(() => {
458
- if (!existsSync(this.path))
459
- return false;
460
- rmSync(this.path);
461
- return true;
462
- });
463
- }
464
- /**
465
- * Every change reads and writes under one lock: a `serve` re-keying while the owner removes a chat must not write
466
- * the removed chat back. A lock held too long refuses the change and leaves the list as it was. Blocks the thread
467
- * while it waits: for callers that cannot be async, and `recipients remove` and `clear`, which never
468
- * connect and so never run inside `serve`.
469
- */
470
- #locked(body) {
471
- return withFileLock(this.path, "the recipient list", body, this.lockWaitMs);
472
- }
473
- #write(chats) {
474
- writeSecurely(this.path, `${JSON.stringify({ chats }, null, 2)}
475
- `, 384);
476
- }
477
- };
478
-
479
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/guard.js
480
- var HOUR_MS = 60 * 60 * 1e3;
481
- var READS_UNDER_HOLD = /* @__PURE__ */ new Set([
482
- "attachments.extract",
483
- "conversations.embeddings",
484
- "conversations.links",
485
- "messages.server-search",
486
- "messages.sync-first",
487
- "stats.contacts.top.sync-first",
488
- "stats.messages.counters.sync",
489
- "stats.messages.show.sync-first",
490
- "stats.messages.top.sync-first",
491
- "store.gaps.repair"
492
- ]);
493
- var countsTowardLimit = /* @__PURE__ */ __name(({ kind = "message", action, notify }) => kind === "message" || kind === "forward" || kind === "edit" || kind === "delete" || kind === "pin" && notify === true || action === "create" || action === "members.add" || action === "requests.accept" || action === "join" || action === "contact-import", "countsTowardLimit");
494
- var weightOf = /* @__PURE__ */ __name(({ kind = "message", action, count, people }) => kind === "delete" || kind === "message" && action === void 0 ? Math.max(1, count ?? 1) : action === "create" || action === "members.add" || action === "requests.accept" || action === "contact-import" ? Math.max(1, people ?? count ?? 1) : 1, "weightOf");
495
- var timeOf = /* @__PURE__ */ __name((entry) => Date.parse(entry.scheduledFor ?? entry.at), "timeOf");
496
- var ceilingRefusal = /* @__PURE__ */ __name((key, command) => new CliError("permission_error", `${key} is not allowed: setup's answer keeps every WireCat tool read-only; the owner changes it at a terminal with \`${command} setup\``, { permission: key }), "ceilingRefusal");
497
- var levelRefusal = /* @__PURE__ */ __name((refused, fix = `${refused.command} ${refused.profile} config set permissions.${refused.key} allow`) => refused.named === CEILING_KEY ? ceilingRefusal(refused.key, refused.command) : new CliError("permission_error", `profile ${refused.profile} does not let ${refused.key} write (permissions.${refused.named} is ${refused.level}, from the ${refused.permissionSources[refused.named ?? ""] ?? "default"}); to allow it: ${fix}`, { permission: refused.key }), "levelRefusal");
498
- var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipients.command, readOnlyLock, permissions, permissionSources = {}, permissionDefaults, permissionFix, ask = refuseToAsk, sendsPerHour, journal, flood, warn, now = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "now") }) => {
499
- const currentPermissions = /* @__PURE__ */ __name(() => typeof permissions === "function" ? permissions() : permissions, "currentPermissions");
500
- let reservation;
501
- const answered = /* @__PURE__ */ new WeakSet();
502
- const refuseReadOnly = /* @__PURE__ */ __name(() => {
503
- if (readOnlyLock)
504
- throw readOnlyRefusal(readOnlyLock, MESSENGER_CHANGE_REFUSAL);
505
- }, "refuseReadOnly");
506
- const refuseHeld = /* @__PURE__ */ __name(({ key }) => {
507
- if (key !== void 0 && READS_UNDER_HOLD.has(key))
508
- return;
509
- const block = flood?.sendBlock();
510
- if (!block)
511
- return;
512
- throw new CliError("permission_error", `profile ${profile} holds its writes ${holdEnd(block)}: ${block.hint} \u2014 reads still work; do not retry: the owner checks the account with \`${command} ${profile} doctor --online\`, and lifts the hold with \`${command} ${profile} flood clear\` once it is over`, { sendBlock: block, standing: { state: block.state, hint: block.hint } });
513
- }, "refuseHeld");
514
- const permitted = /* @__PURE__ */ __name((request) => {
515
- const { chatId, kind = "message", action, personIds } = request;
516
- refuseReadOnly();
517
- const levels = currentPermissions();
518
- if (levels !== void 0) {
519
- const key = request.key ?? keyForWrite(kind, action);
520
- const { level, key: named } = levelFor(levels, key, permissionDefaults);
521
- if (level === "deny" || level === "readonly")
522
- throw levelRefusal({ profile, command, key, level, named, permissionSources }, permissionFix?.(request, key));
523
- if (level === "ask" && !answered.has(request)) {
524
- throw new CliError("confirmation_required", `${key} asks before it acts, and it was not asked`);
525
- }
526
- }
527
- const allowed = recipients.read();
528
- if (chatId !== null && allowed && !allowed.some((chat) => chat.id === chatId)) {
529
- throw new CliError("confirmation_required", `chat ${chatId} is not on the recipient list of profile ${profile} \u2014 the owner adds it with \`${command} ${profile} recipients add ${chatId}\``, { chat_id: chatId });
530
- }
531
- const strangers = allowed ? (personIds ?? []).filter((id) => !allowed.some((chat) => chat.partnerId === id)) : [];
532
- if (strangers.length > 0) {
533
- throw new CliError("confirmation_required", `${strangers.join(", ")} ${strangers.length === 1 ? "is" : "are"} not on the recipient list of profile ${profile} \u2014 the owner adds the one-to-one chat with each person (\`${command} ${profile} recipients add <chat>\`); a chat added to the list earlier is added again to be recognised`, { person_ids: strangers });
534
- }
535
- }, "permitted");
536
- const withinLimit = /* @__PURE__ */ __name((request, entries) => {
537
- const { chatId, sendId } = request;
538
- const asked = { ...request, people: request.personIds?.length ?? request.count };
539
- const count = weightOf(asked);
540
- if (count > sendsPerHour) {
541
- throw new CliError("rate_limited", `${count} at once is more than the hourly limit of profile ${profile} (sendsPerHour ${sendsPerHour}) \u2014 do fewer at a time`);
542
- }
543
- const at = request.scheduledFor ? Date.parse(request.scheduledFor) : now().getTime();
544
- const counted = entries.filter(countsTowardLimit).filter((entry) => entry.outcome === "sent" || entry.outcome === "outcome_unknown" || entry.outcome === "reserved").filter((entry) => Math.abs(timeOf(entry) - at) < HOUR_MS);
545
- const unsure = /* @__PURE__ */ __name((entry) => entry.outcome === "outcome_unknown", "unsure");
546
- const same = /* @__PURE__ */ __name((a, b) => a.sendId !== void 0 && a.sendId === b.sendId && a.chatId === b.chatId, "same");
547
- const last = [...counted].reverse().find((entry) => same(entry, { chatId, sendId }));
548
- if (sendId !== void 0 && last && unsure(last)) {
549
- if (last.sendAs !== request.sendAs) {
550
- throw new CliError("validation_error", "this send id was tried under another identity; repeat it with the same --send-as, or it may post twice", { operation_id: sendId, retryable: false });
551
- }
552
- return false;
553
- }
554
- const recent = counted.filter((entry, index) => !(unsure(entry) && counted.slice(index + 1).some((later) => same(later, entry)))).map((entry) => ({ time: timeOf(entry), weight: weightOf(entry) })).sort((a, b) => a.time - b.time);
555
- const used = recent.reduce((sum, { weight }) => sum + weight, 0);
556
- if (used + count > sendsPerHour) {
557
- let freed = 0;
558
- const opening = recent.find(({ weight }) => {
559
- freed += weight;
560
- return used - freed + count <= sendsPerHour;
561
- });
562
- const nextMs = (opening?.time ?? 0) + HOUR_MS;
563
- const next = new Date(nextMs).toISOString();
564
- throw new CliError("rate_limited", `profile ${profile} has sent ${used} messages in the hour around ${new Date(at).toISOString()}, and its limit is ${sendsPerHour} (sendsPerHour) \u2014 the next send is possible at ${next}`, { retry_after_ms: nextMs - now().getTime(), retry_at: next });
565
- }
566
- return true;
567
- }, "withinLimit");
568
- const counting = /* @__PURE__ */ __name((request) => {
569
- permitted(request);
570
- refuseHeld(request);
571
- const asked = { ...request, people: request.personIds?.length ?? request.count };
572
- const creatingTopic = request.kind === "chat" && request.action === "topic-create";
573
- if (!countsTowardLimit(asked) && !creatingTopic)
574
- return void 0;
575
- const checked = /* @__PURE__ */ __name((entries) => {
576
- if (!creatingTopic)
577
- return withinLimit(request, entries);
578
- if (request.sendId === void 0)
579
- throw new CliError("validation_error", "a topic creation needs an attempt id");
580
- if (entries.some((entry) => entry.action === "topic-create" && entry.sendId === request.sendId && ["sent", "outcome_unknown", "reserved"].includes(entry.outcome))) {
581
- throw new CliError("validation_error", "this topic creation was already attempted; check topics list and do not repeat an unknown creation", { operation_id: request.sendId, retryable: false });
582
- }
583
- return true;
584
- }, "checked");
585
- const reserving = /* @__PURE__ */ __name(() => {
586
- if (!checked(journal.entries()))
587
- return;
588
- const id = randomUUID();
589
- const { chatId, kind, action, sendId, operationId, scheduledFor, notify } = request;
590
- journal.append({
591
- at: now().toISOString(),
592
- profile,
593
- chatId,
594
- outcome: "reserved",
595
- reservation: id,
596
- ...kind ? { kind } : {},
597
- ...action ? { action } : {},
598
- ...asked.people === void 0 ? {} : kind === "delete" || kind === "message" || kind === void 0 ? { count: asked.people } : { people: asked.people },
599
- ...sendId === void 0 ? {} : { sendId },
600
- ...operationId === void 0 ? {} : { operationId },
601
- ...scheduledFor ? { scheduledFor } : {},
602
- ...notify === void 0 ? {} : { notify }
603
- });
604
- reservation = id;
605
- }, "reserving");
606
- return { checked, reserving };
607
- }, "counting");
608
- return {
609
- ask: /* @__PURE__ */ __name(async (request) => {
610
- refuseReadOnly();
611
- const levels = currentPermissions();
612
- if (levels === void 0)
613
- return;
614
- const key = request.key ?? keyForWrite(request.kind ?? "message", request.action);
615
- if (levelFor(levels, key, permissionDefaults).level !== "ask")
616
- return;
617
- refuseHeld(request);
618
- await ask(key, request);
619
- answered.add(request);
620
- }, "ask"),
621
- check: /* @__PURE__ */ __name((request, { reserve = true } = {}) => {
622
- const counted = counting(request);
623
- if (!counted)
624
- return;
625
- if (reserve)
626
- journal.locked(counted.reserving);
627
- else
628
- counted.checked(journal.entries());
629
- }, "check"),
630
- reserve: /* @__PURE__ */ __name(async (request) => {
631
- const counted = counting(request);
632
- if (counted)
633
- await journal.lockedAsync(counted.reserving);
634
- }, "reserve"),
635
- // After a send, a failure to write here must not become the command's answer: the message is
636
- // already with a person, and an error would invite the caller to send it again.
637
- record: /* @__PURE__ */ __name((entry) => {
638
- const { personIds: _, ...kept } = entry;
639
- const settles = entry.outcome === "refused" ? void 0 : reservation;
640
- reservation = void 0;
641
- try {
642
- journal.append({ at: now().toISOString(), profile, ...kept, ...settles ? { reservation: settles } : {} });
643
- } catch (error) {
644
- warn(`this send is not in the send journal: ${journalFailure(error)}`, {
645
- event: "warning",
646
- code: "send_not_journaled",
647
- operation: "sends.journal"
648
- });
649
- }
650
- }, "record")
651
- };
652
- }, "sendGuard");
653
- var refuseToAsk = /* @__PURE__ */ __name(async (key) => {
654
- throw new CliError("confirmation_required", `${key} asks before it acts (its permission level is ask), and nobody is here to answer \u2014 add ${skipFlagFor(key)} to go ahead`);
655
- }, "refuseToAsk");
656
- var guardFor = /* @__PURE__ */ __name((app, settings, warn, env = process.env, ask) => sendGuard({
657
- profile: settings.profile,
658
- command: app.command,
659
- ...settings.readOnlyLock ? { readOnlyLock: settings.readOnlyLock } : {},
660
- permissions: /* @__PURE__ */ __name(() => settings.permissions, "permissions"),
661
- permissionSources: settings.permissionSources,
662
- ...settings.permissionDefaults ? { permissionDefaults: settings.permissionDefaults } : {},
663
- ...ask ? { ask } : {},
664
- sendsPerHour: settings.sendsPerHour,
665
- journal: new SendJournal(sendsPathFor(app, settings.profile, env), { service: app.command, version: app.version }),
666
- recipients: new RecipientList(recipientsPathFor(app, settings.profile, env), app.command),
667
- flood: new FloodMemory(floodPathFor(app, settings.profile, env)),
668
- warn
669
- }), "guardFor");
670
- var journalFailure = /* @__PURE__ */ __name((error) => error?.code ?? (error instanceof Error ? error.name : "error"), "journalFailure");
671
-
672
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/pace.js
673
- import { readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
674
- import { join as join4 } from "node:path";
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";
675
131
  var DEFAULT_PACE = { perMinute: 60, burst: 20 };
676
- var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
132
+ var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
677
133
  var Pacer = class {
678
134
  static {
679
135
  __name(this, "Pacer");
@@ -715,7 +171,7 @@ var Pacer = class {
715
171
  }
716
172
  read() {
717
173
  try {
718
- const tat = Number(JSON.parse(readFileSync4(this.path, "utf8")).tat);
174
+ const tat = Number(JSON.parse(readFileSync(this.path, "utf8")).tat);
719
175
  return Number.isFinite(tat) ? tat : 0;
720
176
  } catch {
721
177
  return 0;
@@ -723,8 +179,8 @@ var Pacer = class {
723
179
  }
724
180
  write(tat) {
725
181
  const temporary = `${this.path}.${process.pid}.tmp`;
726
- writeFileSync2(temporary, JSON.stringify({ tat }), { mode: 384 });
727
- renameSync2(temporary, this.path);
182
+ writeFileSync(temporary, JSON.stringify({ tat }), { mode: 384 });
183
+ renameSync(temporary, this.path);
728
184
  }
729
185
  };
730
186
  var ANNOUNCE_WAIT_MS = 5e3;
@@ -759,7 +215,7 @@ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
759
215
  await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
760
216
  }, "waitForTurn");
761
217
 
762
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/cli/permission-keys.js
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
763
219
  var HOUSEKEEPING = /* @__PURE__ */ new Set([
764
220
  "help",
765
221
  "guide",
@@ -839,7 +295,7 @@ var refuseUnknownPermissionKeys = /* @__PURE__ */ __name((command, settings, too
839
295
  throw new CliError("validation_error", `--permission ${key} names no command`, { permission: key });
840
296
  }, "refuseUnknownPermissionKeys");
841
297
 
842
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/cli/messenger/flooded.js
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
843
299
  var LONG_LIVED = /* @__PURE__ */ new Set(["self", "newSendId", "close", "formatMarkdown", "formatHtml", "storedChats"]);
844
300
  var LISTENING = /* @__PURE__ */ new Set(["watch", "feed", "listen", "listenHistory"]);
845
301
  var BLOCKING = /* @__PURE__ */ new Set(["frozen", "limited", "banned"]);
@@ -936,7 +392,7 @@ var flooded = /* @__PURE__ */ __name((messenger, memory, { name, warn, pacer })
936
392
  });
937
393
  }, "flooded");
938
394
 
939
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/cli/messenger/observed.js
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
940
396
  var observed = /* @__PURE__ */ __name((messenger, events) => {
941
397
  const timed = /* @__PURE__ */ __name(async (operation, named, work, after) => {
942
398
  const write = currentOperation();
@@ -1035,7 +491,7 @@ var byPart = /* @__PURE__ */ __name((batch, counts) => {
1035
491
  counts[part] = (counts[part] ?? 0) + items.length;
1036
492
  }, "byPart");
1037
493
 
1038
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/cli/messenger/stored.js
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
1039
495
  var REKEY_PACING = { lockMs: 50, pauseMs: 25 };
1040
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" }) => {
1041
497
  let warned = false;
@@ -1156,13 +612,13 @@ var stored = /* @__PURE__ */ __name((messenger, { account, store, warn, events,
1156
612
  }
1157
613
  if (round !== rekeyRound)
1158
614
  return;
1159
- const taken2 = pass?.taken ?? rest.length;
1160
- rekeysQueued -= taken2;
615
+ const taken = pass?.taken ?? rest.length;
616
+ rekeysQueued -= taken;
1161
617
  for (const { from, to } of pass?.applied ?? [])
1162
618
  await Promise.resolve().then(() => rekeyed?.(from, to)).catch((error) => notWritten("history.rekey", error));
1163
619
  for (const { error } of pass?.refused ?? [])
1164
620
  notWritten("history.rekey", error);
1165
- rest = rest.slice(taken2);
621
+ rest = rest.slice(taken);
1166
622
  if (rest.length > 0)
1167
623
  await new Promise((resolve) => setTimeout(resolve, rekeyPacing.pauseMs));
1168
624
  }
@@ -1611,7 +1067,7 @@ var keep = /* @__PURE__ */ __name(async (store, account, event, seenAt, among, c
1611
1067
  }
1612
1068
  }, "keep");
1613
1069
 
1614
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/cli/messenger/context.js
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
1615
1071
  var lazyStore = /* @__PURE__ */ __name((env, command, version) => {
1616
1072
  let opened;
1617
1073
  return {
@@ -1953,6 +1409,7 @@ var messengerContext = /* @__PURE__ */ __name((command, messenger, resolving = {
1953
1409
  history: base.settings.record,
1954
1410
  searchCatchUp: base.settings.searchCatchUp,
1955
1411
  ...base.settings.historyLimits ? { historyLimits: base.settings.historyLimits } : {},
1412
+ historyMuted: base.settings.historyMuted,
1956
1413
  pictures: base.settings.pictureSearch,
1957
1414
  reranker: base.settings.searchReranker,
1958
1415
  guard,
@@ -2011,17 +1468,6 @@ var messengerContext = /* @__PURE__ */ __name((command, messenger, resolving = {
2011
1468
  export {
2012
1469
  answerOf,
2013
1470
  terminalAsker,
2014
- holdEnd,
2015
- floodPathFor,
2016
- FloodMemory,
2017
- sendsPathFor,
2018
- SendJournal,
2019
- recipientsPathFor,
2020
- RecipientList,
2021
- ceilingRefusal,
2022
- levelRefusal,
2023
- sendGuard,
2024
- guardFor,
2025
1471
  DEFAULT_PACE,
2026
1472
  pacePathFor,
2027
1473
  Pacer,
@@ -2031,6 +1477,7 @@ export {
2031
1477
  knownBeside,
2032
1478
  unknownPermissionIssues,
2033
1479
  refuseUnknownPermissionKeys,
1480
+ fill,
2034
1481
  connectedFor,
2035
1482
  refuseLocalWrite,
2036
1483
  messengerContext