@wirecat/drive-cli 0.64.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 (182) hide show
  1. package/dist/bin/drive.js +2 -2
  2. package/dist/bundle/{all-profiles-BPPT2AK5.js → all-profiles-PD7GJHFA.js} +14 -13
  3. package/dist/bundle/{anthropic-JW6GOJUD.js → anthropic-PJKFON5H.js} +20 -11
  4. package/dist/bundle/{app-server-KAQIOJMZ.js → app-server-6ELQA6FJ.js} +59 -56
  5. package/dist/bundle/{bun-UT7GNTPV.js → bun-P54TGES2.js} +2 -2
  6. package/dist/bundle/{bun-sqlite-2OIVV3LS.js → bun-sqlite-TND5ZRJH.js} +12 -8
  7. package/dist/bundle/chunk-2AFI4KGI.js +185 -0
  8. package/dist/bundle/{chunk-WWCYTMAV.js → chunk-3HXNDF6Q.js} +2 -2
  9. package/dist/bundle/{chunk-46CD64J2.js → chunk-3ONWN3IA.js} +166 -53
  10. package/dist/bundle/{chunk-4YRENUB5.js → chunk-42G2XNPN.js} +2 -2
  11. package/dist/bundle/chunk-4AOINPN2.js +66 -0
  12. package/dist/bundle/{chunk-ZF6GUZCE.js → chunk-4EDWLR22.js} +1 -1
  13. package/dist/bundle/{chunk-BEZJA44H.js → chunk-4Y5YBFMS.js} +7 -7
  14. package/dist/bundle/{chunk-B7XBIOMR.js → chunk-54V4H6PM.js} +16 -16
  15. package/dist/bundle/{chunk-4CNTID2X.js → chunk-5XSBCMAF.js} +4 -4
  16. package/dist/bundle/{chunk-IDAK4DDK.js → chunk-6DCLZLGX.js} +1 -1
  17. package/dist/bundle/{chunk-G4KEKKDE.js → chunk-7AQGVX5O.js} +20 -20
  18. package/dist/bundle/{chunk-34BIDKF4.js → chunk-7TAP7Y2E.js} +508 -155
  19. package/dist/bundle/{chunk-BZ2ZKILM.js → chunk-A27UVLPK.js} +3 -3
  20. package/dist/bundle/{chunk-SIOIMO62.js → chunk-A4QNADEX.js} +57 -51
  21. package/dist/bundle/{chunk-FXBHOCJK.js → chunk-ADLS6FVG.js} +1 -1
  22. package/dist/bundle/{chunk-66AF4FBW.js → chunk-B2LPCHQN.js} +4 -4
  23. package/dist/bundle/{chunk-M73NNJ3X.js → chunk-CGQRZRTH.js} +2 -2
  24. package/dist/bundle/{chunk-KVW4XNKB.js → chunk-CWLL63JD.js} +107 -48
  25. package/dist/bundle/{chunk-CPMRM3GQ.js → chunk-D6Z43SOG.js} +1592 -335
  26. package/dist/bundle/{chunk-QXCKJUZY.js → chunk-D7WB54P7.js} +111 -27
  27. package/dist/bundle/{chunk-VT2UFYPJ.js → chunk-DA63E2UM.js} +13 -9
  28. package/dist/bundle/{chunk-2FEZ24DK.js → chunk-ECEP4SO3.js} +20 -20
  29. package/dist/bundle/{chunk-ZSZJLJIA.js → chunk-EHU6EYGO.js} +38 -28
  30. package/dist/bundle/{chunk-EJ4PNHPP.js → chunk-ELJUBPY4.js} +1 -1
  31. package/dist/bundle/{chunk-F2VDAG32.js → chunk-EM7NL5ES.js} +3 -3
  32. package/dist/bundle/{chunk-O2QO5UZC.js → chunk-EU5MD24W.js} +13 -13
  33. package/dist/bundle/{chunk-KIN6PDFE.js → chunk-EZ2OLYEK.js} +4 -4
  34. package/dist/bundle/{chunk-OH3K2E7X.js → chunk-F56DRBGY.js} +655 -1220
  35. package/dist/bundle/{chunk-VIJ6ACYB.js → chunk-FA6JNXCC.js} +8 -8
  36. package/dist/bundle/{chunk-KE4XPPRQ.js → chunk-FBHSWQU7.js} +1531 -136
  37. package/dist/bundle/{chunk-ZRZ4HTCK.js → chunk-GW3LBY3T.js} +51 -67
  38. package/dist/bundle/{chunk-6B37XO6B.js → chunk-HP3NT6JJ.js} +3 -3
  39. package/dist/bundle/{chunk-IX7NQJLY.js → chunk-I272E6UR.js} +9 -8
  40. package/dist/bundle/{chunk-5HSRQ53R.js → chunk-IBO23OID.js} +2 -2
  41. package/dist/bundle/{chunk-EZ6O3ST3.js → chunk-II4S2DBJ.js} +3 -3
  42. package/dist/bundle/{chunk-3NULZGQU.js → chunk-IKHOIXJR.js} +2 -2
  43. package/dist/bundle/{chunk-JRXFW7HE.js → chunk-IMHW7VIV.js} +5 -5
  44. package/dist/bundle/{chunk-USLZE36C.js → chunk-JMJIH6JH.js} +6 -6
  45. package/dist/bundle/{chunk-C7WBNOYW.js → chunk-JPPPLKAO.js} +26 -1
  46. package/dist/bundle/{chunk-EQEGJVO2.js → chunk-LMKPP2JP.js} +1 -1
  47. package/dist/bundle/{chunk-G3NULXOM.js → chunk-M7ELUGU6.js} +4 -4
  48. package/dist/bundle/{chunk-6G53ZFUT.js → chunk-MCPOZNWG.js} +1 -1
  49. package/dist/bundle/{chunk-EWGVDFPT.js → chunk-NI5PD5KM.js} +39203 -35871
  50. package/dist/bundle/{chunk-AHB4OJCI.js → chunk-NQ5XMSLA.js} +3678 -2049
  51. package/dist/bundle/chunk-NQRTKYJB.js +257 -0
  52. package/dist/bundle/{chunk-3J5KAFNA.js → chunk-O6K2E7OA.js} +3917 -3005
  53. package/dist/bundle/{chunk-J62DI53V.js → chunk-O7ZDCOZE.js} +1 -1
  54. package/dist/bundle/{chunk-XPXKD63J.js → chunk-OFJXHEFT.js} +13 -13
  55. package/dist/bundle/chunk-OWMZUWCM.js +109 -0
  56. package/dist/bundle/chunk-PHOL2DZM.js +138 -0
  57. package/dist/bundle/{chunk-KG2XKEHL.js → chunk-PLP5527C.js} +5 -5
  58. package/dist/bundle/{chunk-5ZBR55US.js → chunk-RNHGQ35R.js} +1 -1
  59. package/dist/bundle/{chunk-IK6KH3RE.js → chunk-RX5CJ55S.js} +1 -1
  60. package/dist/bundle/{chunk-K6BSB53R.js → chunk-SE352DBY.js} +1 -1
  61. package/dist/bundle/chunk-SEQWBZYH.js +18 -0
  62. package/dist/bundle/{chunk-LOMW6F2E.js → chunk-SIWXYB4E.js} +3734 -3448
  63. package/dist/bundle/{chunk-GW3U6OLD.js → chunk-SNLSEYJO.js} +1 -1
  64. package/dist/bundle/{chunk-UJR272CP.js → chunk-SS4LKLD7.js} +52 -605
  65. package/dist/bundle/{chunk-BEUAICUD.js → chunk-TMHF4BCL.js} +2 -2
  66. package/dist/bundle/{chunk-BDYWZ7JE.js → chunk-TOVWMURV.js} +30 -6
  67. package/dist/bundle/{chunk-N622LRPM.js → chunk-TTP4NOP3.js} +4 -4
  68. package/dist/bundle/chunk-UTNRBOEN.js +53 -0
  69. package/dist/bundle/{chunk-36GPBPWM.js → chunk-VDZY3L7U.js} +3 -1
  70. package/dist/bundle/chunk-VHQYWFWV.js +13 -0
  71. package/dist/bundle/{chunk-VPLFD5RJ.js → chunk-VLXWAH5E.js} +4 -4
  72. package/dist/bundle/{chunk-UIEA6FIV.js → chunk-VMAMRFFC.js} +23 -23
  73. package/dist/bundle/{chunk-HW4UPST2.js → chunk-W2XY6C5S.js} +2 -2
  74. package/dist/bundle/{chunk-P7DEGRZA.js → chunk-WRAUO5EJ.js} +22 -24
  75. package/dist/bundle/{chunk-QEAD2LF4.js → chunk-WRMJN6UQ.js} +3 -3
  76. package/dist/bundle/{chunk-UD55VB2N.js → chunk-WVJHZIDH.js} +3 -3
  77. package/dist/bundle/{chunk-B67BLRAI.js → chunk-X7YGGWXI.js} +1 -59
  78. package/dist/bundle/{chunk-EC2XGDKJ.js → chunk-XPWZSW6Y.js} +4 -4
  79. package/dist/bundle/{chunk-E2LBCCTG.js → chunk-XYE7XZPB.js} +5 -5
  80. package/dist/bundle/{chunk-TNV2FXVK.js → chunk-Y5PKRITX.js} +5 -5
  81. package/dist/bundle/{chunk-5OFA5EXE.js → chunk-Z2ADO6UA.js} +2 -2
  82. package/dist/bundle/{chunk-PBMSBCVB.js → chunk-ZD4MB7NH.js} +1 -1
  83. package/dist/bundle/{chunk-2W464HAE.js → chunk-ZILALBYQ.js} +4 -4
  84. package/dist/bundle/{chunk-OEVHZOHC.js → chunk-ZR2EJPMQ.js} +44 -15
  85. package/dist/bundle/command-contract-25E4PYMD.js +40 -0
  86. package/dist/bundle/command-server-entry-36JXYIJB.js +170 -0
  87. package/dist/bundle/{decode-HTOQ6S3V.js → decode-T5ZW57WZ.js} +8 -8
  88. package/dist/bundle/{dispatch-SH5SP6LA.js → dispatch-RMA2XFYA.js} +9 -9
  89. package/dist/bundle/drive.js +11 -11
  90. package/dist/bundle/{echarts-KFHB6SLX.js → echarts-KQ44LPSF.js} +2 -2
  91. package/dist/bundle/{embed-YATFB2PN.js → embed-Q7XST53J.js} +9 -9
  92. package/dist/bundle/{embedder-MQPDFGTJ.js → embedder-RWZSBVW2.js} +12 -12
  93. package/dist/bundle/entry-HPLW4QL2.js +25 -0
  94. package/dist/bundle/{failure-4FQL4XJI.js → failure-7NP4QPIN.js} +4 -4
  95. package/dist/bundle/first-run-RL3RKYZW.js +30 -0
  96. package/dist/bundle/first-screen-NX3TM2VJ.js +38 -0
  97. package/dist/bundle/google-DPD5N6AQ.js +42 -0
  98. package/dist/bundle/{google-api-QMFGCXBM.js → google-api-P5DRHD7L.js} +61 -55
  99. package/dist/bundle/grants-TX4MHLI4.js +109 -0
  100. package/dist/bundle/{identity-FYVDK4M2.js → identity-VDV6CHRW.js} +6 -6
  101. package/dist/bundle/{instructions-D3GF3B7M.js → instructions-Q45FVY6H.js} +1 -1
  102. package/dist/bundle/{login-COFZ2IWP.js → login-XKN3NI6X.js} +67 -61
  103. package/dist/bundle/{mcp-RKJG22KM.js → mcp-7KQUJNFN.js} +2 -2
  104. package/dist/bundle/{node-OFICOKX3.js → node-MSW565D3.js} +2 -2
  105. package/dist/bundle/{node-KM3CUABH.js → node-P4E63KXA.js} +9 -9
  106. package/dist/bundle/{node-sqlite-DNBTDOXD.js → node-sqlite-S74XVVHL.js} +13 -9
  107. package/dist/bundle/oauth-6R7AWAES.js +22 -0
  108. package/dist/bundle/{open-PTPR2YWX.js → open-P7UQG7XJ.js} +8 -8
  109. package/dist/bundle/{openai-2KV5LUW4.js → openai-DDHJ57KZ.js} +19 -40
  110. package/dist/bundle/{process-EAW6NST2.js → process-NMUB5SHK.js} +1 -1
  111. package/dist/bundle/{program-6UV5Q5YN.js → program-PJNWP6JW.js} +294 -137
  112. package/dist/bundle/{prompt-634TPMJK.js → prompt-VOSMK4C2.js} +8 -8
  113. package/dist/bundle/{reasons-DDWCEYSQ.js → reasons-KDAXOC5S.js} +5 -5
  114. package/dist/bundle/{recognize-SJO6QUDW.js → recognize-GZIY63HS.js} +7 -7
  115. package/dist/bundle/{remote-6JXZITKF.js → remote-V3YGN7LN.js} +10 -10
  116. package/dist/bundle/{rerank-MD5VOPQ6.js → rerank-XRU6AVN7.js} +10 -10
  117. package/dist/bundle/{serve-LZTROA2M.js → serve-NDOAFA57.js} +12 -12
  118. package/dist/bundle/{server-NSA3UAFY.js → server-BKGWJYMC.js} +46 -44
  119. package/dist/bundle/server-QD2MUJJZ.js +72 -0
  120. package/dist/bundle/{services-F5A6XQCV.js → services-TYDMFQCA.js} +101 -41
  121. package/dist/bundle/{sqlite-runtime-7YF6REKS.js → sqlite-runtime-UAFJKSJR.js} +9 -9
  122. package/dist/bundle/{start-MUFLE6FA.js → start-2ZLDP2OE.js} +7 -7
  123. package/dist/bundle/{state-UC54F3YZ.js → state-6SP27J2K.js} +9 -9
  124. package/dist/bundle/{store-J53YNAH6.js → store-4UUY545Q.js} +25 -18
  125. package/dist/bundle/{store-F5FJGWMR.js → store-EJN27MXI.js} +61 -28
  126. package/dist/bundle/store-maintenance-command-LETURZDC.js +60 -0
  127. package/dist/bundle/tokens-MTFJPTYT.js +107 -0
  128. package/dist/commands/config.d.ts.map +1 -1
  129. package/dist/commands/config.js +6 -5
  130. package/dist/commands/config.js.map +1 -1
  131. package/dist/commands/context.d.ts +4 -2
  132. package/dist/commands/context.d.ts.map +1 -1
  133. package/dist/commands/context.js.map +1 -1
  134. package/dist/commands/documents.d.ts +2 -0
  135. package/dist/commands/documents.d.ts.map +1 -1
  136. package/dist/commands/documents.js +39 -3
  137. package/dist/commands/documents.js.map +1 -1
  138. package/dist/config.d.ts +13 -0
  139. package/dist/config.d.ts.map +1 -1
  140. package/dist/config.js +32 -2
  141. package/dist/config.js.map +1 -1
  142. package/dist/documents-add.d.ts +49 -0
  143. package/dist/documents-add.d.ts.map +1 -0
  144. package/dist/documents-add.js +122 -0
  145. package/dist/documents-add.js.map +1 -0
  146. package/dist/errors.d.ts +1 -0
  147. package/dist/errors.d.ts.map +1 -1
  148. package/dist/errors.js +9 -1
  149. package/dist/errors.js.map +1 -1
  150. package/dist/knowledge.d.ts +1 -1
  151. package/dist/knowledge.d.ts.map +1 -1
  152. package/dist/knowledge.js +15 -17
  153. package/dist/knowledge.js.map +1 -1
  154. package/dist/model.d.ts +3 -0
  155. package/dist/model.d.ts.map +1 -1
  156. package/dist/model.js.map +1 -1
  157. package/dist/program.d.ts.map +1 -1
  158. package/dist/program.js +22 -15
  159. package/dist/program.js.map +1 -1
  160. package/dist/reasons.d.ts.map +1 -1
  161. package/dist/reasons.js +25 -0
  162. package/dist/reasons.js.map +1 -1
  163. package/dist/store.d.ts.map +1 -1
  164. package/dist/store.js +20 -0
  165. package/dist/store.js.map +1 -1
  166. package/dist/version.d.ts +1 -1
  167. package/dist/version.js +1 -1
  168. package/package.json +4 -4
  169. package/dist/bundle/chunk-DD7EFG6B.js +0 -35
  170. package/dist/bundle/chunk-GSMYXGFR.js +0 -62
  171. package/dist/bundle/command-contract-H5OYJOPF.js +0 -38
  172. package/dist/bundle/entry-YZBB647C.js +0 -22
  173. package/dist/bundle/first-run-5JT3UQZB.js +0 -30
  174. package/dist/bundle/first-screen-BEMDEWO7.js +0 -36
  175. package/dist/bundle/google-DVADVICN.js +0 -36
  176. package/dist/bundle/grants-WKB2E4TA.js +0 -103
  177. package/dist/bundle/oauth-PDQHWFBF.js +0 -22
  178. package/dist/bundle/server-GT7X666D.js +0 -69
  179. package/dist/bundle/store-maintenance-command-GJVXLBAB.js +0 -58
  180. package/dist/bundle/tokens-H2EJKGA5.js +0 -101
  181. package/dist/bundle/{chunk-SW6C6WH5.js → chunk-YVNHQFLC.js} +0 -0
  182. package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-CE73EWJ2.js} +3 -3
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  filesPresent,
5
5
  sharedModelsDirectory
6
- } from "./chunk-66AF4FBW.js";
6
+ } from "./chunk-B2LPCHQN.js";
7
7
  import {
8
8
  PRIORITY_LABELS,
9
9
  TAG_TYPES,
@@ -14,23 +14,15 @@ import {
14
14
  id,
15
15
  text,
16
16
  time
17
- } from "./chunk-CPMRM3GQ.js";
17
+ } from "./chunk-D6Z43SOG.js";
18
18
  import {
19
19
  readSharedSection,
20
20
  sharedConfigPath,
21
21
  writeSharedSection
22
- } from "./chunk-BEZJA44H.js";
22
+ } from "./chunk-4Y5YBFMS.js";
23
23
  import {
24
24
  storePath
25
- } from "./chunk-DD7EFG6B.js";
26
- import {
27
- createRecordLog,
28
- resolvePaths,
29
- writeSecurely
30
- } from "./chunk-G4KEKKDE.js";
31
- import {
32
- traceIdOf
33
- } from "./chunk-HW4UPST2.js";
25
+ } from "./chunk-UTNRBOEN.js";
34
26
  import {
35
27
  array,
36
28
  boolean,
@@ -46,7 +38,6 @@ import {
46
38
  optional,
47
39
  picklist,
48
40
  pipe,
49
- record,
50
41
  reference,
51
42
  regex,
52
43
  safeParse,
@@ -55,515 +46,436 @@ import {
55
46
  string,
56
47
  trim,
57
48
  url
58
- } from "./chunk-BDYWZ7JE.js";
49
+ } from "./chunk-TOVWMURV.js";
59
50
  import {
60
51
  CliError,
61
52
  isCliError
62
- } from "./chunk-EJ4PNHPP.js";
53
+ } from "./chunk-ELJUBPY4.js";
63
54
  import {
64
55
  __name
65
56
  } from "./chunk-ZVVMGPBJ.js";
66
57
 
67
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/runs/scope.js
68
- import { AsyncLocalStorage } from "node:async_hooks";
69
- import { randomBytes } from "node:crypto";
70
-
71
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/runs/run.js
72
- import { randomUUID } from "node:crypto";
73
- import { appendFileSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
74
- import { userInfo } from "node:os";
75
- import { join, sep } from "node:path";
76
-
77
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/runs/log-keys.js
78
- var snake = /* @__PURE__ */ __name((key) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`), "snake");
79
- var camel = /* @__PURE__ */ __name((key) => key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase()), "camel");
80
- var renamed = /* @__PURE__ */ __name((record2, name) => Object.fromEntries(Object.entries(record2).map(([key, value]) => [name(key), value])), "renamed");
81
- var logAttributes = /* @__PURE__ */ __name((event) => renamed(event, snake), "logAttributes");
82
- var fromLogAttributes = /* @__PURE__ */ __name((attributes) => renamed(attributes, camel), "fromLogAttributes");
83
- var snakeLogger = /* @__PURE__ */ __name((logger) => ({
84
- debug: /* @__PURE__ */ __name((event, message) => logger.debug(logAttributes(event), message), "debug"),
85
- info: /* @__PURE__ */ __name((event, message) => logger.info(logAttributes(event), message), "info"),
86
- warn: /* @__PURE__ */ __name((event, message) => logger.warn(logAttributes(event), message), "warn"),
87
- error: /* @__PURE__ */ __name((event, message) => logger.error(logAttributes(event), message), "error")
88
- }), "snakeLogger");
89
-
90
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/runs/log-attributes.js
91
- var diagnostic = {
92
- event: true,
93
- operation: true,
94
- opcode: true,
95
- seq: true,
96
- status: true,
97
- method: true,
98
- endpointTemplate: true,
99
- bytes: true,
100
- ids: true,
101
- counts: true,
102
- durationMs: true,
103
- outcome: true,
104
- errorCode: true,
105
- providerError: true,
106
- level: true,
107
- transport: true,
108
- attempt: true,
109
- waitMs: true,
110
- code: true,
111
- detail: true,
112
- reason: true,
113
- ageMs: true
114
- };
115
- var send = {
116
- profile: true,
117
- chatId: true,
118
- outcome: true,
119
- kind: true,
120
- action: true,
121
- people: true,
122
- messageId: true,
123
- key: true,
124
- count: true,
125
- forEveryone: true,
126
- sendId: true,
127
- operationId: true,
128
- parentOperationId: true,
129
- replyTo: true,
130
- threadId: true,
131
- sendAs: true,
132
- resultChatId: true,
133
- length: true,
134
- attachments: true,
135
- scheduledFor: true,
136
- notify: true,
137
- origin: true,
138
- reservation: true,
139
- errorCode: true
58
+ // 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/permissions.js
59
+ var LEVELS = ["deny", "readonly", "ask", "allow"];
60
+ var DANGEROUS = /* @__PURE__ */ new Set(["messages.delete", "bot.messages.delete", "topics.delete", "chats.delete", "chats.clear"]);
61
+ var skipFlagFor = /* @__PURE__ */ __name((key) => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes", "skipFlagFor");
62
+ var DEFAULT_PERMISSIONS = {
63
+ "messages.delete": "ask",
64
+ "account.sessions.end": "ask",
65
+ "bot.messages.delete": "ask",
66
+ "topics.enable": "ask",
67
+ "topics.delete": "ask",
68
+ "chats.delete": "ask",
69
+ "chats.clear": "ask",
70
+ // NEED-568: a rule writes to people with nobody typing a command; it waits for the owner's own allow.
71
+ "replies.send": "deny",
72
+ // NEED-1662: an agent that changes settings, schedules or recipients could lift its own limits; the owner opts in.
73
+ "mcp.authority": "deny",
74
+ // NEED-1663: writes no level stopped before, so MCP could not offer them; over MCP `ask` goes ahead.
75
+ "store.backup": "ask",
76
+ "store.restore": "ask",
77
+ "store.migrate": "ask",
78
+ "store.repair": "ask",
79
+ "store.reset": "ask",
80
+ "store.import": "ask",
81
+ "store.clear": "ask",
82
+ "store.decrypt": "ask",
83
+ "store.copies.delete": "ask",
84
+ "server.start": "ask",
85
+ "server.stop": "ask",
86
+ "server.restart": "ask",
87
+ "models.download": "ask",
88
+ // NEED-2357.f: many MCP clients (ChatGPT) cannot answer a question, and a switch deletes nothing; kept as a key so a
89
+ // profile can still deny it.
90
+ "models.set": "allow",
91
+ "models.add": "ask",
92
+ "images.models.download": "ask",
93
+ "schedule.run": "ask",
94
+ "schedule.exec": "ask",
95
+ "doctor.reports.create": "ask"
140
96
  };
141
- var background = [
142
- "job",
143
- "pid",
97
+ var KEYED_UNDER_HOUSEKEEPING = new Set(Object.keys(DEFAULT_PERMISSIONS).filter((key) => /^(store|server|models|images|schedule|doctor)\./.test(key)));
98
+ var AUTHORITY_KEY = "mcp.authority";
99
+ var authorityAllowed = /* @__PURE__ */ __name((levels) => {
100
+ const { level } = levelFor(levels, AUTHORITY_KEY);
101
+ return level === "allow" || level === "ask";
102
+ }, "authorityAllowed");
103
+ var BOT_API_KEY = "bot.api";
104
+ var isBotApi = /* @__PURE__ */ __name((path) => path[0] === "bot" && path[1] === "api", "isBotApi");
105
+ var botApiAllowed = /* @__PURE__ */ __name((levels) => {
106
+ const { level } = levelFor(levels, BOT_API_KEY, { ...DEFAULT_PERMISSIONS, [BOT_API_KEY]: "deny" });
107
+ return level === "allow" || level === "ask";
108
+ }, "botApiAllowed");
109
+ var RESOURCES = [
110
+ "messages",
111
+ "drafts",
112
+ "reactions",
113
+ "polls",
114
+ "topics",
115
+ "chats",
116
+ "contacts",
117
+ "account",
118
+ "bot",
119
+ "conversations",
120
+ "tags",
121
+ "mentions",
122
+ "search",
123
+ "searches",
124
+ "tasks",
125
+ "replies",
126
+ "attachments",
127
+ "stats",
128
+ "store",
129
+ "metadata",
130
+ "mcp",
131
+ "server",
132
+ "models",
144
133
  "schedule",
145
- "exitCode",
146
- "tool",
147
- "tier",
148
- "actorType",
149
- "actorId",
150
- "agent",
151
- "targetType",
152
- "targetId"
134
+ "doctor",
135
+ "images"
153
136
  ];
154
- var crash = ["errorClass", "frames"];
155
- var dropped = ["dropped"];
156
- var LOG_ATTRIBUTES = [
157
- ...new Set([...Object.keys(diagnostic), ...Object.keys(send), ...background, ...crash, ...dropped].map((key) => Object.keys(logAttributes({ [key]: true }))[0]))
158
- ].sort();
159
-
160
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/runs/run.js
161
- var KEEP_RUNS_FOR_DAYS = 30;
162
- var KEEP_SUCCESSFUL_RUNS_FOR_DAYS = 7;
163
- var RUNS_SIZE_LIMIT_MB = 200;
164
- var runsDirFor = /* @__PURE__ */ __name((app, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "runs"), "runsDirFor");
165
- var startRun = /* @__PURE__ */ __name((options) => {
166
- const now = options.now ?? (() => /* @__PURE__ */ new Date());
167
- const startedAt = options.startedAt ?? now();
168
- const id2 = options.runId ?? newRunId(startedAt, options.command);
169
- const dir = join(options.runsDir, day(startedAt), id2);
170
- pruneRuns(options.runsDir, {
171
- keepDays: options.keepDays ?? KEEP_RUNS_FOR_DAYS,
172
- keepSuccessDays: options.keepSuccessDays ?? KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
173
- maxBytes: options.maxBytes ?? RUNS_SIZE_LIMIT_MB * 1024 * 1024,
174
- now: startedAt
175
- });
176
- refuseRealStateInTests(dir);
177
- const metadata = {
178
- runId: id2,
179
- command: options.command,
180
- ...options.profile === void 0 ? {} : { profile: options.profile },
181
- startedAt: startedAt.toISOString(),
182
- status: "running",
183
- cliVersion: options.cliVersion,
184
- runtime: runtime(),
185
- platform: process.platform,
186
- arch: process.arch,
187
- ...options.traceId === void 0 ? {} : { traceId: options.traceId },
188
- ...options.context
189
- };
190
- let file;
191
- const opened = /* @__PURE__ */ __name(() => {
192
- if (file)
193
- return file;
194
- mkdirSync(dir, { recursive: true, mode: 448 });
195
- const events = join(dir, "events.jsonl");
196
- writeFileSync(events, "", { flag: "a", mode: 384 });
197
- file = snakeLogger(createRecordLog({
198
- to: events,
199
- runId: id2,
200
- command: options.command,
201
- resource: { service: options.service, version: options.cliVersion },
202
- allow: LOG_ATTRIBUTES,
203
- ...options.traceId === void 0 ? {} : { traceId: options.traceId },
204
- ...options.onError === void 0 ? {} : { onError: options.onError }
205
- }));
206
- writeRunFile(dir, metadata);
207
- return file;
208
- }, "opened");
209
- if (!options.lazy)
210
- opened();
211
- let finished = false;
212
- const operations = /* @__PURE__ */ new Set();
213
- const codes = /* @__PURE__ */ new Set();
214
- const noted = /* @__PURE__ */ __name((level) => (event, message) => {
215
- const { operation, errorCode, error_code, code } = event;
216
- if (typeof operation === "string")
217
- operations.add(operation);
218
- for (const value of [errorCode, error_code, code])
219
- if (typeof value === "string")
220
- codes.add(value);
221
- if (finished)
222
- return;
223
- opened()[level](event, message);
224
- }, "noted");
225
- const logger = { debug: noted("debug"), info: noted("info"), warn: noted("warn"), error: noted("error") };
226
- return {
227
- id: id2,
228
- dir,
229
- logger,
230
- finish: /* @__PURE__ */ __name(async (status, extra = {}) => {
231
- if (finished)
232
- return;
233
- finished = true;
234
- const completedAt = now();
235
- const final = {
236
- ...metadata,
237
- ...extra,
238
- status,
239
- completedAt: completedAt.toISOString(),
240
- durationMs: completedAt.getTime() - startedAt.getTime(),
241
- operations: [...operations].sort(),
242
- codes: [...codes].sort()
243
- };
244
- if (file || status !== "success") {
245
- opened();
246
- writeRunFile(dir, final);
247
- return;
248
- }
249
- try {
250
- mkdirSync(join(dir, ".."), { recursive: true, mode: 448 });
251
- appendIndex(join(dir, ".."), runFileOf(final));
252
- } catch (error) {
253
- options.onError?.(error);
254
- }
255
- }, "finish")
256
- };
257
- }, "startRun");
258
- var refuseRealStateInTests = /* @__PURE__ */ __name((dir, env = process.env) => {
259
- if (env.VITEST === void 0)
260
- return;
261
- let home;
262
- try {
263
- home = userInfo().homedir;
264
- } catch {
265
- return;
266
- }
267
- if (dir.startsWith(join(home, ".local", "share") + sep))
268
- throw new Error(`a test opened a run in the real data folder: ${dir}`);
269
- }, "refuseRealStateInTests");
270
- var runtime = /* @__PURE__ */ __name(() => {
271
- const bun = process.versions.bun;
272
- return bun ? `bun ${bun}` : `node ${process.versions.node}`;
273
- }, "runtime");
274
- var newRunId = /* @__PURE__ */ __name((startedAt, command) => {
275
- const stamp = startedAt.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
276
- const slug2 = command.replace(/[^a-z0-9]+/gi, "-").toLowerCase();
277
- return `${stamp}-${slug2}-${randomUUID().slice(0, 6)}`;
278
- }, "newRunId");
279
- var INDEX = "index.jsonl";
280
- var appendIndex = /* @__PURE__ */ __name((dayDir, written) => {
281
- appendFileSync(join(dayDir, INDEX), `${JSON.stringify(written)}
282
- `, { mode: 384 });
283
- }, "appendIndex");
284
- var writeRunFile = /* @__PURE__ */ __name((dir, metadata) => {
285
- const written = runFileOf(metadata);
286
- writeSecurely(join(dir, "run.json"), `${JSON.stringify(written, null, 2)}
287
- `, 384);
288
- try {
289
- appendIndex(join(dir, ".."), written);
290
- } catch {
291
- }
292
- }, "writeRunFile");
293
- var matchesListFilter = /* @__PURE__ */ __name((run, filter) => (filter.runId === void 0 || run.runId === filter.runId) && (filter.command === void 0 || run.command === filter.command) && (filter.profile === void 0 || run.profile === filter.profile) && (filter.status === void 0 || run.status === filter.status) && (filter.errorCode === void 0 || run.errorCode === filter.errorCode), "matchesListFilter");
294
- var listRuns = /* @__PURE__ */ __name((runsDir, { since, atLeast = Number.POSITIVE_INFINITY, filter = {} } = {}) => {
295
- const first = since === void 0 ? void 0 : day(new Date(since));
296
- const runs = [];
297
- for (const date of days(runsDir).sort().reverse()) {
298
- if (first !== void 0 && date < first || runs.length >= atLeast)
299
- break;
300
- for (const metadata of runsOfDay(join(runsDir, date))) {
301
- if (matchesListFilter(metadata, filter))
302
- runs.push(metadata);
303
- }
304
- }
305
- return runs;
306
- }, "listRuns");
307
- var indexedRuns = /* @__PURE__ */ __name((dayDir) => {
308
- const latest = /* @__PURE__ */ new Map();
309
- let raw = "";
310
- try {
311
- raw = readFileSync(join(dayDir, INDEX), "utf8");
312
- } catch {
313
- }
314
- for (const line of raw.split("\n")) {
315
- if (line.trim() === "")
316
- continue;
317
- try {
318
- const metadata = metadataOf(JSON.parse(line));
319
- if (typeof metadata.runId === "string")
320
- latest.set(metadata.runId, metadata);
321
- } catch {
322
- }
323
- }
324
- return latest;
325
- }, "indexedRuns");
326
- var runsOfDay = /* @__PURE__ */ __name((dayDir) => {
327
- const latest = indexedRuns(dayDir);
328
- for (const entry of safeReaddir(dayDir)) {
329
- if (entry === INDEX || entry.startsWith(".") || latest.has(entry))
330
- continue;
331
- const metadata = readRun(join(dayDir, entry));
332
- if (metadata)
333
- latest.set(metadata.runId, metadata);
334
- }
335
- return [...latest.values()].sort((a, b) => a.runId < b.runId ? 1 : a.runId > b.runId ? -1 : 0);
336
- }, "runsOfDay");
337
- var findRun = /* @__PURE__ */ __name((runsDir, id2) => {
338
- const stamped = /^(\d{4})(\d{2})(\d{2})T/.exec(id2);
339
- const likely = stamped ? [`${stamped[1]}-${stamped[2]}-${stamped[3]}`] : [];
340
- const dates = [.../* @__PURE__ */ new Set([...likely, ...days(runsDir)])];
341
- for (const date of dates) {
342
- const dir = join(runsDir, date, id2);
343
- const metadata = readRun(dir);
344
- if (metadata)
345
- return { dir, metadata };
346
- }
347
- for (const date of dates) {
348
- const metadata = indexedRuns(join(runsDir, date)).get(id2);
349
- if (metadata)
350
- return { dir: join(runsDir, date, id2), metadata };
351
- }
352
- return void 0;
353
- }, "findRun");
354
- var readEvents = /* @__PURE__ */ __name((dir) => {
355
- let raw;
356
- try {
357
- raw = readFileSync(join(dir, "events.jsonl"), "utf8");
358
- } catch {
359
- return [];
360
- }
361
- const events = [];
362
- for (const line of raw.split("\n")) {
363
- if (line.trim() === "")
364
- continue;
365
- try {
366
- const parsed = JSON.parse(line);
367
- if (parsed !== null && typeof parsed === "object")
368
- events.push(eventOf(parsed));
369
- } catch {
370
- }
371
- }
372
- return events;
373
- }, "readEvents");
374
- var eventOf = /* @__PURE__ */ __name((line) => {
375
- const { attributes, time: time2, severity } = line;
376
- if (attributes === null || typeof attributes !== "object")
377
- return logAttributes(line);
378
- return { time: time2, severity, ...logAttributes(attributes) };
379
- }, "eventOf");
380
- var pruneRuns = /* @__PURE__ */ __name((runsDir, { keepDays, keepSuccessDays = keepDays, maxBytes, now }) => {
381
- const cutoff = day(new Date(now.getTime() - keepDays * DAY_MS));
382
- const successCutoff = day(new Date(now.getTime() - Math.min(keepSuccessDays, keepDays) * DAY_MS));
383
- let removed = 0;
384
- for (const date of days(runsDir)) {
385
- if (date >= cutoff) {
386
- if (date < successCutoff)
387
- dropSuccesses(join(runsDir, date));
388
- continue;
389
- }
390
- try {
391
- rmSync(join(runsDir, date), { recursive: true, force: true });
392
- removed += 1;
393
- } catch {
394
- }
395
- }
396
- if (maxBytes !== void 0)
397
- removed += fitSize(runsDir, maxBytes, now);
398
- return removed;
399
- }, "pruneRuns");
400
- var DAY_MS = 24 * 60 * 60 * 1e3;
401
- var SUCCESSES_DROPPED = ".successes-dropped";
402
- var SIZE_CHECKED = ".size-checked";
403
- var dropSuccesses = /* @__PURE__ */ __name((dayDir) => {
404
- const marker = join(dayDir, SUCCESSES_DROPPED);
405
- try {
406
- statSync(marker);
407
- return;
408
- } catch {
409
- }
410
- try {
411
- const kept = [];
412
- for (const [id2, metadata] of indexedRuns(dayDir)) {
413
- if (metadata.status === "success")
414
- rmSync(join(dayDir, id2), { recursive: true, force: true });
415
- else
416
- kept.push(JSON.stringify(runFileOf(metadata)));
417
- }
418
- for (const entry of safeReaddir(dayDir)) {
419
- if (entry === INDEX || entry.startsWith("."))
137
+ var layerPermissions = /* @__PURE__ */ __name((layers) => {
138
+ const levels = {};
139
+ const sources = {};
140
+ for (const [from, layer] of layers) {
141
+ const nearer = Object.keys(levels);
142
+ for (const [key, level] of Object.entries(layer ?? {})) {
143
+ if (nearer.some((named) => key === named || key.startsWith(`${named}.`)))
420
144
  continue;
421
- if (readRun(join(dayDir, entry))?.status === "success")
422
- rmSync(join(dayDir, entry), { recursive: true, force: true });
423
- }
424
- writeSecurely(join(dayDir, INDEX), kept.map((line) => `${line}
425
- `).join(""), 384);
426
- writeFileSync(marker, "", { mode: 384 });
427
- } catch {
428
- }
429
- }, "dropSuccesses");
430
- var sizeOf = /* @__PURE__ */ __name((path) => {
431
- let total = 0;
432
- for (const entry of safeReaddir(path)) {
433
- const full = join(path, entry);
434
- try {
435
- const stat = statSync(full);
436
- total += stat.isDirectory() ? sizeOf(full) : stat.size;
437
- } catch {
438
- }
439
- }
440
- return total;
441
- }, "sizeOf");
442
- var fitSize = /* @__PURE__ */ __name((runsDir, maxBytes, now) => {
443
- const stamp = join(runsDir, SIZE_CHECKED);
444
- const today = day(now);
445
- try {
446
- if (readFileSync(stamp, "utf8").trim() === today)
447
- return 0;
448
- } catch {
449
- }
450
- const dates = days(runsDir).sort();
451
- const sizes = new Map(dates.map((date) => [date, sizeOf(join(runsDir, date))]));
452
- let total = [...sizes.values()].reduce((sum, size) => sum + size, 0);
453
- let removed = 0;
454
- for (const date of dates) {
455
- if (total <= maxBytes || date === today)
456
- break;
457
- dropSuccesses(join(runsDir, date));
458
- const after = sizeOf(join(runsDir, date));
459
- total -= (sizes.get(date) ?? 0) - after;
460
- sizes.set(date, after);
461
- }
462
- for (const date of dates) {
463
- if (total <= maxBytes || date === today)
464
- break;
465
- try {
466
- rmSync(join(runsDir, date), { recursive: true, force: true });
467
- total -= sizes.get(date) ?? 0;
468
- removed += 1;
469
- } catch {
145
+ levels[key] = level;
146
+ sources[key] = from;
470
147
  }
471
148
  }
472
- try {
473
- mkdirSync(runsDir, { recursive: true, mode: 448 });
474
- writeFileSync(stamp, today, { mode: 384 });
475
- } catch {
476
- }
477
- return removed;
478
- }, "fitSize");
479
- var day = /* @__PURE__ */ __name((date) => date.toISOString().slice(0, 10), "day");
480
- var days = /* @__PURE__ */ __name((runsDir) => safeReaddir(runsDir).filter((entry) => /^\d{4}-\d{2}-\d{2}$/.test(entry)), "days");
481
- var readRun = /* @__PURE__ */ __name((dir) => {
482
- try {
483
- return metadataOf(JSON.parse(readFileSync(join(dir, "run.json"), "utf8")));
484
- } catch {
485
- return void 0;
149
+ return { levels, sources };
150
+ }, "layerPermissions");
151
+ var CEILING_KEY = "*";
152
+ var ALLOWED = { level: "allow", key: null };
153
+ var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
154
+ var nearest = /* @__PURE__ */ __name((levels, key) => {
155
+ for (let parts = key.split("."); parts.length > 0; parts = parts.slice(0, -1)) {
156
+ const named = parts.join(".");
157
+ const level = levels[named];
158
+ if (level)
159
+ return { level, key: named, depth: parts.length };
486
160
  }
487
- }, "readRun");
488
- var safeReaddir = /* @__PURE__ */ __name((dir) => {
489
- try {
490
- return readdirSync(dir);
491
- } catch {
492
- return [];
161
+ return void 0;
162
+ }, "nearest");
163
+ var levelFor = /* @__PURE__ */ __name((permissions, key, defaults = DEFAULT_PERMISSIONS) => {
164
+ const found = profileLevel(permissions, key, defaults);
165
+ const ceiling = permissions[CEILING_KEY];
166
+ return ceiling && ORDER[ceiling] < ORDER[found.level] ? { level: ceiling, key: CEILING_KEY } : found;
167
+ }, "levelFor");
168
+ var profileLevel = /* @__PURE__ */ __name((permissions, key, defaults) => {
169
+ const own = nearest(permissions, key);
170
+ const builtIn = nearest(defaults, key);
171
+ if (!builtIn || own && own.depth >= builtIn.depth)
172
+ return own ? { level: own.level, key: own.key } : ALLOWED;
173
+ if (!own || ORDER[builtIn.level] <= ORDER[own.level])
174
+ return { level: builtIn.level, key: builtIn.key };
175
+ return { level: own.level, key: own.key };
176
+ }, "profileLevel");
177
+ var CHAT_KEYS = {
178
+ settings: "chats.update",
179
+ "requests.accept": "chats.requests.confirm",
180
+ "requests.decline": "chats.requests.reject",
181
+ "link.create": "chats.links.create",
182
+ "link.reset": "chats.links.reset",
183
+ "link.revoke": "chats.links.remove",
184
+ "link.update": "chats.links.update"
185
+ };
186
+ var ACCOUNT_KEYS = {
187
+ "contact-add": "contacts.add",
188
+ "contact-remove": "contacts.remove",
189
+ "contact-import": "contacts.import",
190
+ "contact-rename": "contacts.rename",
191
+ "contact-block": "contacts.block",
192
+ "contact-unblock": "contacts.unblock",
193
+ profile: "account.update",
194
+ "folder-create": "chats.folders.create",
195
+ "folder-update": "chats.folders.update",
196
+ "folder-delete": "chats.folders.delete",
197
+ "folder-order": "chats.folders.order",
198
+ "folder-join": "chats.folders.join",
199
+ "sessions-end": "account.sessions.end",
200
+ "chat-mute": "chats.mute",
201
+ "chat-unmute": "chats.unmute",
202
+ "chat-archive": "chats.archive",
203
+ "chat-unarchive": "chats.unarchive",
204
+ "chat-pin": "chats.pin",
205
+ "chat-unpin": "chats.unpin",
206
+ "chat-mark-unread": "chats.mark-unread",
207
+ "message-star": "messages.star",
208
+ "message-unstar": "messages.unstar",
209
+ // A mail CLI names its own key on every write; these only answer `keyForWrite` when one is left out.
210
+ "message-flag": "messages.update",
211
+ "message-move": "messages.move",
212
+ "message-copy": "messages.copy",
213
+ "message-delete": "messages.trash",
214
+ "message-restore": "messages.restore",
215
+ privacy: "account.privacy.set"
216
+ };
217
+ var KIND_KEYS = {
218
+ message: "messages.send",
219
+ forward: "messages.forward",
220
+ edit: "messages.edit",
221
+ pin: "messages.pin",
222
+ reaction: "reactions",
223
+ read: "chats.mark-read",
224
+ delete: "messages.delete"
225
+ };
226
+ var keyForWrite = /* @__PURE__ */ __name((kind, action) => {
227
+ if (kind === "chat")
228
+ return CHAT_KEYS[action] ?? `chats.${action ?? "update"}`;
229
+ if (kind === "account") {
230
+ const key = ACCOUNT_KEYS[action];
231
+ if (!key)
232
+ throw new Error(`an account change without a known action: ${action}`);
233
+ return key;
493
234
  }
494
- }, "safeReaddir");
495
- var runFileOf = /* @__PURE__ */ __name(({ partial, ...metadata }) => ({
496
- ...logAttributes(metadata),
497
- ...partial ? { partial: { ...logAttributes(partial), failures: partial.failures.map((failure) => logAttributes(failure)) } } : {}
498
- }), "runFileOf");
499
- var metadataOf = /* @__PURE__ */ __name((parsed) => {
500
- const { partial, ...metadata } = fromLogAttributes(parsed);
501
- if (partial === null || typeof partial !== "object")
502
- return metadata;
503
- const { failures, ...rest } = fromLogAttributes(partial);
504
- return {
505
- ...metadata,
506
- partial: {
507
- ...rest,
508
- failures: Array.isArray(failures) ? failures.map((failure) => fromLogAttributes(failure)) : []
509
- }
510
- };
511
- }, "metadataOf");
512
-
513
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/runs/scope.js
514
- var scopes = new AsyncLocalStorage();
515
- var processScope;
516
- var currentRun = /* @__PURE__ */ __name(() => {
517
- const scope = scopes.getStore();
518
- if (scope)
519
- return scope;
520
- processScope ??= {
521
- runId: newRunId(/* @__PURE__ */ new Date(), "process"),
522
- command: "",
523
- startedAt: Date.now(),
524
- ...traceOf(process.env)
525
- };
526
- return processScope;
527
- }, "currentRun");
528
- var inRun = /* @__PURE__ */ __name((scope, body) => scopes.run(scope, body), "inRun");
529
- var runEvent = /* @__PURE__ */ __name((event) => scopes.getStore()?.events?.(event), "runEvent");
530
- var typedCommand = /* @__PURE__ */ __name((tool, words2, profile = currentRun().profile) => [tool, profile, words2].filter((part) => part !== void 0 && part !== "").join(" "), "typedCommand");
531
- var useAsProcessRun = /* @__PURE__ */ __name((scope) => {
532
- processScope = scope;
533
- }, "useAsProcessRun");
534
- var processRun = /* @__PURE__ */ __name(() => processScope, "processRun");
535
- var enclosingTraceId = /* @__PURE__ */ __name(() => scopes.getStore()?.traceId, "enclosingTraceId");
536
- var traceOf = /* @__PURE__ */ __name((env) => {
537
- const traceId = traceIdOf(env.TRACEPARENT);
538
- return traceId === void 0 ? {} : { traceId };
539
- }, "traceOf");
540
- var childTrace = /* @__PURE__ */ __name(() => {
541
- const hex = /* @__PURE__ */ __name((bytes) => randomBytes(bytes).toString("hex"), "hex");
542
- const traceId = hex(16);
543
- return { traceId, traceparent: `00-${traceId}-${hex(8)}-01` };
544
- }, "childTrace");
545
- var attempts = new AsyncLocalStorage();
546
- var withAttempt = /* @__PURE__ */ __name((attempt, work) => attempts.run(attempt, work), "withAttempt");
547
- var currentAttempt = /* @__PURE__ */ __name(() => attempts.getStore(), "currentAttempt");
548
-
549
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/domain/duration.js
550
- var DURATION = /^(\d+)(ms|s|m|h|d)$/;
551
- var UNIT_MS = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
552
- var parseDuration = /* @__PURE__ */ __name((value, source) => {
553
- const match = DURATION.exec(value.trim());
554
- if (!match?.[1] || !match[2]) {
555
- throw new CliError("validation_error", `${source} takes a duration with a unit \u2014 500ms, 30s, 2m, 4h or 1d \u2014 not "${value}"`);
235
+ return KIND_KEYS[kind];
236
+ }, "keyForWrite");
237
+ var writeOfKey = /* @__PURE__ */ __name((key) => {
238
+ const account = Object.entries(ACCOUNT_KEYS).find(([, named]) => named === key)?.[0];
239
+ if (account)
240
+ return { kind: "account", action: account };
241
+ const kind = Object.entries(KIND_KEYS).find(([, named]) => named === key || key.startsWith(`${named}.`))?.[0];
242
+ if (kind)
243
+ return { kind };
244
+ if (key === "messages.unpin")
245
+ return { kind: "pin" };
246
+ if (key.startsWith("chats.")) {
247
+ const action = Object.entries(CHAT_KEYS).find(([, named]) => named === key)?.[0] ?? key.slice("chats.".length);
248
+ return { kind: "chat", action };
556
249
  }
557
- const ms = Number(match[1]) * (UNIT_MS[match[2]] ?? 0);
558
- if (ms <= 0)
559
- throw new CliError("validation_error", `${source} has to be more than zero, and "${value}" is not`);
560
- return ms;
561
- }, "parseDuration");
562
-
563
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/embeddings/models.js
564
- var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`, "huggingFace");
565
- var e5 = huggingFace("Xenova/multilingual-e5-small", "761b726dd34fb83930e26aab4e9ac3899aa1fa78");
566
- var e5Large = huggingFace("Xenova/multilingual-e5-large", "00fc3aeb3dbb95842de2ac1961d33c6319acf57b");
250
+ return {};
251
+ }, "writeOfKey");
252
+ var NAMED_WRITE_KEYS = [
253
+ "drafts",
254
+ "store.gaps.repair",
255
+ "messages.sync-first",
256
+ "messages.server-search",
257
+ "messages.press",
258
+ "chats.start",
259
+ "chats.app",
260
+ "stats.messages.counters.sync",
261
+ "stats.messages.show.sync-first",
262
+ "stats.messages.top.sync-first",
263
+ "stats.contacts.top.sync-first",
264
+ "account.sessions.list",
265
+ "attachments.extract",
266
+ "attachments.move",
267
+ "attachments.update",
268
+ "bot.callbacks.answer",
269
+ "bot.chats.action",
270
+ "bot.chats.admins.add",
271
+ "bot.chats.admins.remove",
272
+ "bot.chats.leave",
273
+ "bot.chats.members.remove",
274
+ "bot.chats.moderate",
275
+ "bot.messages.delete",
276
+ "bot.messages.edit",
277
+ "bot.messages.pin",
278
+ "bot.messages.send",
279
+ "bot.messages.unpin",
280
+ "chats.admins.add",
281
+ "chats.admins.remove",
282
+ "chats.links.create",
283
+ "chats.links.reset",
284
+ "chats.links.remove",
285
+ "chats.links.update",
286
+ "chats.members.add",
287
+ "chats.members.remove",
288
+ "chats.moderate",
289
+ "conversations.embeddings",
290
+ "conversations.links",
291
+ "polls.close",
292
+ "polls.create",
293
+ "polls.vote",
294
+ "searches.clear",
295
+ "searches.create",
296
+ "searches.delete",
297
+ "contacts.aliases.set",
298
+ "contacts.aliases.remove",
299
+ "contacts.notes.add",
300
+ "contacts.notes.edit",
301
+ "contacts.notes.remove",
302
+ "tags.rebuild",
303
+ "metadata.sync",
304
+ "mentions.rebuild",
305
+ "mentions.confirm",
306
+ "mentions.reject",
307
+ "tags.add",
308
+ "tags.remove",
309
+ "tasks.acknowledge",
310
+ "tasks.add",
311
+ "tasks.claim",
312
+ "tasks.close",
313
+ "tasks.duplicates.defer",
314
+ "tasks.duplicates.reject",
315
+ "tasks.link",
316
+ "tasks.merge",
317
+ "tasks.update",
318
+ "tasks.release",
319
+ "tasks.scan",
320
+ "tasks.unmerge",
321
+ "topics.create",
322
+ "topics.edit",
323
+ "topics.enable"
324
+ ];
325
+ var WRITE_KEYS = [
326
+ .../* @__PURE__ */ new Set([
327
+ ...NAMED_WRITE_KEYS,
328
+ ...Object.keys(DEFAULT_PERMISSIONS),
329
+ ...Object.values(KIND_KEYS),
330
+ ...Object.values(ACCOUNT_KEYS),
331
+ ...Object.values(CHAT_KEYS)
332
+ ])
333
+ ];
334
+ var HOUSEKEEPING = /* @__PURE__ */ new Set([
335
+ "help",
336
+ "guide",
337
+ "config",
338
+ "session",
339
+ "doctor",
340
+ "commands",
341
+ "complete",
342
+ "upgrade",
343
+ "skill",
344
+ "models",
345
+ "server",
346
+ // What a schedule runs is checked by its own key when it runs; an agent runs read-only.
347
+ "schedule",
348
+ "runs",
349
+ "sends",
350
+ "recipients",
351
+ "flood",
352
+ "mcp",
353
+ // Its commands read the rules or flip the pause switch; what a rule sends is checked as `replies.send`.
354
+ "replies"
355
+ ]);
356
+ var BOT_HOUSEKEEPING = /* @__PURE__ */ new Set(["auth", "list", "sends", "recipients", "mcp"]);
357
+ var STORE_MAINTENANCE = /* @__PURE__ */ new Set(["info", "check", "copies"]);
358
+ var SHOW_MESSAGES = /* @__PURE__ */ new Set(["inbox", "review", "watch", "serve", "store", "conversations", "projects"]);
359
+ var readKeysForCommand = /* @__PURE__ */ __name((path) => {
360
+ if (path[0] === "bot")
361
+ return readKeysForCommand(path.slice(1)).map((key2) => `bot.${key2}`);
362
+ const key = keyForCommand(path);
363
+ if (!key)
364
+ return [];
365
+ if (path[0] === "attachments" && path[1] === "download")
366
+ return [key, "messages", "chats"];
367
+ if (path[0] === "attachments" && (path[1] === "extract" || path[1] === "show"))
368
+ return [key, "messages"];
369
+ if (path[0] === "store" && path[1] === "gaps" && path[2] === "repair")
370
+ return [key, "messages"];
371
+ if (path[0] === "store" && ["reset", "clear", "decrypt"].includes(path[1] ?? ""))
372
+ return [key, "messages"];
373
+ if (path[0] === "search") {
374
+ if (path[1] === "notes")
375
+ return [key];
376
+ if (path[1] === "topics")
377
+ return [key, "topics"];
378
+ if (path[1] === "conversations")
379
+ return [key, "messages", "conversations"];
380
+ return [key, "messages"];
381
+ }
382
+ if (path[0] !== "stats")
383
+ return [key];
384
+ const resource = path[1] === "charts" ? "chats" : path[1];
385
+ return [
386
+ .../* @__PURE__ */ new Set([
387
+ key,
388
+ "messages",
389
+ ...["chats", "contacts", "tasks"].includes(resource ?? "") ? [resource] : []
390
+ ])
391
+ ];
392
+ }, "readKeysForCommand");
393
+ var keyForCommand = /* @__PURE__ */ __name((path) => {
394
+ if (path.length === 0)
395
+ return null;
396
+ const [top, next] = path;
397
+ if (top === "bot") {
398
+ if (next === void 0 || BOT_HOUSEKEEPING.has(next))
399
+ return null;
400
+ const inner = keyForCommand(path.slice(1));
401
+ return `bot.${inner ?? path.slice(1).join(".")}`;
402
+ }
403
+ if (KEYED_UNDER_HOUSEKEEPING.has(path.join(".")))
404
+ return path.join(".");
405
+ if (top === void 0 || HOUSEKEEPING.has(top) || top === "search" && next === "runs")
406
+ return null;
407
+ if (top === "images" && next === "models")
408
+ return null;
409
+ if (top === "attachments" && (next === "check" || next === "jobs"))
410
+ return null;
411
+ if (top === "attachments" && next === "download")
412
+ return "messages";
413
+ if (top === "store" && next !== void 0 && STORE_MAINTENANCE.has(next))
414
+ return null;
415
+ if (top === "conversations" && next === "links")
416
+ return path[2] === "rebuild" ? "conversations.links.rebuild" : "conversations.links";
417
+ if (top === "conversations" && (next === "embeddings" || next === "embed") || top === "images" && next === "embed" || top === "conversations" && next === "rebuild")
418
+ return "conversations.embeddings";
419
+ if (top === "attachments" && next === "list" || top === "chats" && next === "documents")
420
+ return "messages";
421
+ if (top === "mentions")
422
+ return next === "rebuild" || next === "confirm" || next === "reject" ? `mentions.${next}` : "messages";
423
+ if (top === "store" && (next === "gaps" || next === "jobs"))
424
+ return path.join(".");
425
+ if (SHOW_MESSAGES.has(top) || top === "contacts" && (next === "context" || next === "prepare" || next === "events"))
426
+ return "messages";
427
+ if (RESOURCES.includes(top))
428
+ return path.join(".");
429
+ return void 0;
430
+ }, "keyForCommand");
431
+ var RESOURCE_KEY = new RegExp(`^(${RESOURCES.join("|")})(\\.[a-z][a-z-]*)*$`);
432
+ var COMMAND_PATH_KEY = /^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/;
433
+ var permissionOverrides = /* @__PURE__ */ __name((entries = [], shape = RESOURCE_KEY) => {
434
+ const levels = {};
435
+ const example = shape === RESOURCE_KEY ? "messages.send=allow" : "api=readonly";
436
+ for (const entry of entries) {
437
+ const [key = "", level = "", extra] = entry.split("=");
438
+ if (!shape.test(key) || !LEVELS.includes(level) || extra !== void 0)
439
+ throw new CliError("validation_error", `--permission takes a command path and level, e.g. ${example} (deny, readonly, ask, allow)`);
440
+ levels[key] = level;
441
+ }
442
+ return levels;
443
+ }, "permissionOverrides");
444
+ var assertOverridesTighten = /* @__PURE__ */ __name((overrides, profile, defaults = DEFAULT_PERMISSIONS) => {
445
+ for (const [key, level] of Object.entries(overrides)) {
446
+ const under = Object.keys(profile).filter((named) => named.startsWith(`${key}.`));
447
+ const lifted = [key, ...under].find((named) => ORDER[level] > ORDER[levelFor(profile, named, defaults).level]);
448
+ if (lifted !== void 0)
449
+ throw new CliError("validation_error", `--permission ${key}=${level} would loosen ${lifted} from ${levelFor(profile, lifted, defaults).level}; it only tightens \u2014 change the profile's permissions to loosen it`, { key, lifted });
450
+ }
451
+ }, "assertOverridesTighten");
452
+ var assertRetentionEvidenceRead = /* @__PURE__ */ __name((permissions) => {
453
+ for (const permission of ["stats.chats.retention", "chats"]) {
454
+ if (levelFor(permissions, permission).level === "deny")
455
+ throw new CliError("permission_error", `profile denies ${permission}`, { permission });
456
+ }
457
+ }, "assertRetentionEvidenceRead");
458
+
459
+ // 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/domain/duration.js
460
+ var DURATION = /^(\d+)(ms|s|m|h|d)$/;
461
+ var UNIT_MS = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
462
+ var parseDuration = /* @__PURE__ */ __name((value, source) => {
463
+ const match = DURATION.exec(value.trim());
464
+ if (!match?.[1] || !match[2]) {
465
+ throw new CliError("validation_error", `${source} takes a duration with a unit \u2014 500ms, 30s, 2m, 4h or 1d \u2014 not "${value}"`);
466
+ }
467
+ const ms = Number(match[1]) * (UNIT_MS[match[2]] ?? 0);
468
+ if (ms <= 0)
469
+ throw new CliError("validation_error", `${source} has to be more than zero, and "${value}" is not`);
470
+ return ms;
471
+ }, "parseDuration");
472
+
473
+ // 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/embeddings/models.js
474
+ import { existsSync } from "node:fs";
475
+ import { join } from "node:path";
476
+ var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`, "huggingFace");
477
+ var e5 = huggingFace("Xenova/multilingual-e5-small", "761b726dd34fb83930e26aab4e9ac3899aa1fa78");
478
+ var e5Large = huggingFace("Xenova/multilingual-e5-large", "00fc3aeb3dbb95842de2ac1961d33c6319acf57b");
567
479
  var gemma = huggingFace("onnx-community/embeddinggemma-300m-ONNX", "5090578d9565bb06545b4552f76e6bc2c93e4a66");
568
480
  var TEXT_MODELS = [
569
481
  {
@@ -607,9 +519,13 @@ var TEXT_MODELS = [
607
519
  languages: "over 100 languages \u2014 the best of the two on chat, about seven times slower",
608
520
  licence: "Gemma Terms of Use",
609
521
  terms: "https://ai.google.dev/gemma/terms",
522
+ // Gemma Terms of Use §3.1: every copy carries this notice and the use restrictions of §3.2.
523
+ notice: "Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms. Its use is restricted by the Gemma Prohibited Use Policy: https://ai.google.dev/gemma/prohibited_use_policy",
610
524
  dims: 768,
611
525
  maxTokens: 2048,
612
- chunksPerSecond: 2,
526
+ // 2026-11-08, 1,200-character chunks, 8 threads on the Ryzen AI 9 HX 470: 8.3 chunks/s against e5-small's 52.7, so
527
+ // 5 on the scale e5-small's 31 sets. It was 2, which held a memo sync to 39 chunks.
528
+ chunksPerSecond: 5,
613
529
  pooling: "sentence_embedding",
614
530
  prefix: { query: "task: search result | query: ", passage: "title: none | text: " },
615
531
  onnx: "onnx/model_q4.onnx",
@@ -676,7 +592,8 @@ var TEXT_MODELS = [
676
592
  ]
677
593
  }
678
594
  ];
679
- var DEFAULT_TEXT_MODEL = "e5-small";
595
+ var DEFAULT_TEXT_MODEL = "embeddinggemma";
596
+ var PREVIOUS_DEFAULT_TEXT_MODEL = "e5-small";
680
597
  var SECTION = "text_models";
681
598
  var slug = pipe(string(), regex(/^[a-z0-9][a-z0-9._-]{0,62}$/, "is not a model id: a-z, 0-9, . _ -"));
682
599
  var words = pipe(string(), trim(), minLength(1), maxLength(300));
@@ -743,9 +660,17 @@ var textModel = /* @__PURE__ */ __name((id2, env = process.env) => {
743
660
  }
744
661
  return found;
745
662
  }, "textModel");
663
+ var downloaded = /* @__PURE__ */ __name((id2, env) => {
664
+ const model = TEXT_MODELS.find((one) => one.id === id2);
665
+ const directory = sharedModelsDirectory("text", env);
666
+ return model !== void 0 && filesPresent(model.files.map((file) => [file, join(directory, model.id, file.name)]));
667
+ }, "downloaded");
746
668
  var chosenTextModel = /* @__PURE__ */ __name((env = process.env) => {
747
669
  const use = readTextModelsSection(env).use;
748
- return use === void 0 ? { id: DEFAULT_TEXT_MODEL, from: "default" } : { id: use, from: "chosen" };
670
+ if (use !== void 0)
671
+ return { id: use, from: "chosen" };
672
+ const kept = !downloaded(DEFAULT_TEXT_MODEL, env) && existsSync(join(sharedModelsDirectory("text", env), PREVIOUS_DEFAULT_TEXT_MODEL));
673
+ return { id: kept ? PREVIOUS_DEFAULT_TEXT_MODEL : DEFAULT_TEXT_MODEL, from: "default" };
749
674
  }, "chosenTextModel");
750
675
  var mmarco = huggingFace("cross-encoder/mmarco-mMiniLMv2-L12-H384-v1", "1427fd652930e4ba29e8149678df786c240d8825");
751
676
  var bge = huggingFace("onnx-community/bge-reranker-v2-m3-ONNX", "6f5ff65298512715a1e669753bc754d2bc8f367b");
@@ -800,661 +725,29 @@ var RERANK_MODELS = [
800
725
  bytes: 17082900
801
726
  },
802
727
  {
803
- name: "tokenizer_config.json",
804
- url: bge("tokenizer_config.json"),
805
- sha256: "b87c8703482b0300d3da30e201519aa641f6a450f5eb5bf1e624afbf70c74d80",
806
- bytes: 1203
807
- }
808
- ]
809
- }
810
- ];
811
- var DEFAULT_RERANK_MODEL = "mmarco";
812
- var rerankModel = /* @__PURE__ */ __name((id2) => {
813
- const found = RERANK_MODELS.find((model) => model.id === id2);
814
- if (!found) {
815
- throw new CliError("validation_error", `no reranker ${id2} \u2014 one of: ${RERANK_MODELS.map((model) => model.id).join(", ")}`);
816
- }
817
- return found;
818
- }, "rerankModel");
819
- var vectorModelKey = /* @__PURE__ */ __name((model) => {
820
- const weights = model.custom ? model.files.find(({ name }) => name === model.onnx)?.sha256.slice(0, 12) : void 0;
821
- return `local:${model.id}${weights ? `@${weights}` : ""}:${model.dims}`;
822
- }, "vectorModelKey");
823
- var meaningFloor = /* @__PURE__ */ __name((key) => key === "local:e5-small:384" ? 0.8 : 0, "meaningFloor");
824
-
825
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/sends/permissions.js
826
- var LEVELS = ["deny", "readonly", "ask", "allow"];
827
- var DANGEROUS = /* @__PURE__ */ new Set(["messages.delete", "bot.messages.delete", "topics.delete", "chats.delete", "chats.clear"]);
828
- var skipFlagFor = /* @__PURE__ */ __name((key) => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes", "skipFlagFor");
829
- var DEFAULT_PERMISSIONS = {
830
- "messages.delete": "ask",
831
- "account.sessions.end": "ask",
832
- "bot.messages.delete": "ask",
833
- "topics.enable": "ask",
834
- "topics.delete": "ask",
835
- "chats.delete": "ask",
836
- "chats.clear": "ask",
837
- // NEED-568: a rule writes to people with nobody typing a command; it waits for the owner's own allow.
838
- "replies.send": "deny",
839
- // NEED-1662: an agent that changes settings, schedules or recipients could lift its own limits; the owner opts in.
840
- "mcp.authority": "deny",
841
- // NEED-1663: writes no level stopped before, so MCP could not offer them; over MCP `ask` goes ahead.
842
- "store.backup": "ask",
843
- "store.restore": "ask",
844
- "store.migrate": "ask",
845
- "store.repair": "ask",
846
- "store.reset": "ask",
847
- "store.clear": "ask",
848
- "store.decrypt": "ask",
849
- "store.copies.delete": "ask",
850
- "server.start": "ask",
851
- "server.stop": "ask",
852
- "server.restart": "ask",
853
- "models.download": "ask",
854
- // NEED-2357.f: many MCP clients (ChatGPT) cannot answer a question, and a switch deletes nothing; kept as a key so a
855
- // profile can still deny it.
856
- "models.set": "allow",
857
- "models.add": "ask",
858
- "images.models.download": "ask",
859
- "schedule.run": "ask",
860
- "schedule.exec": "ask",
861
- "doctor.reports.create": "ask"
862
- };
863
- var KEYED_UNDER_HOUSEKEEPING = new Set(Object.keys(DEFAULT_PERMISSIONS).filter((key) => /^(store|server|models|images|schedule|doctor)\./.test(key)));
864
- var AUTHORITY_KEY = "mcp.authority";
865
- var authorityAllowed = /* @__PURE__ */ __name((levels) => {
866
- const { level } = levelFor(levels, AUTHORITY_KEY);
867
- return level === "allow" || level === "ask";
868
- }, "authorityAllowed");
869
- var BOT_API_KEY = "bot.api";
870
- var isBotApi = /* @__PURE__ */ __name((path) => path[0] === "bot" && path[1] === "api", "isBotApi");
871
- var botApiAllowed = /* @__PURE__ */ __name((levels) => {
872
- const { level } = levelFor(levels, BOT_API_KEY, { ...DEFAULT_PERMISSIONS, [BOT_API_KEY]: "deny" });
873
- return level === "allow" || level === "ask";
874
- }, "botApiAllowed");
875
- var RESOURCES = [
876
- "messages",
877
- "drafts",
878
- "reactions",
879
- "polls",
880
- "topics",
881
- "chats",
882
- "contacts",
883
- "account",
884
- "bot",
885
- "conversations",
886
- "tags",
887
- "mentions",
888
- "search",
889
- "searches",
890
- "tasks",
891
- "replies",
892
- "attachments",
893
- "stats",
894
- "store",
895
- "metadata",
896
- "mcp",
897
- "server",
898
- "models",
899
- "schedule",
900
- "doctor",
901
- "images"
902
- ];
903
- var layerPermissions = /* @__PURE__ */ __name((layers) => {
904
- const levels = {};
905
- const sources = {};
906
- for (const [from, layer] of layers) {
907
- const nearer = Object.keys(levels);
908
- for (const [key, level] of Object.entries(layer ?? {})) {
909
- if (nearer.some((named) => key === named || key.startsWith(`${named}.`)))
910
- continue;
911
- levels[key] = level;
912
- sources[key] = from;
913
- }
914
- }
915
- return { levels, sources };
916
- }, "layerPermissions");
917
- var CEILING_KEY = "*";
918
- var ALLOWED = { level: "allow", key: null };
919
- var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
920
- var nearest = /* @__PURE__ */ __name((levels, key) => {
921
- for (let parts = key.split("."); parts.length > 0; parts = parts.slice(0, -1)) {
922
- const named = parts.join(".");
923
- const level = levels[named];
924
- if (level)
925
- return { level, key: named, depth: parts.length };
926
- }
927
- return void 0;
928
- }, "nearest");
929
- var levelFor = /* @__PURE__ */ __name((permissions, key, defaults = DEFAULT_PERMISSIONS) => {
930
- const found = profileLevel(permissions, key, defaults);
931
- const ceiling = permissions[CEILING_KEY];
932
- return ceiling && ORDER[ceiling] < ORDER[found.level] ? { level: ceiling, key: CEILING_KEY } : found;
933
- }, "levelFor");
934
- var profileLevel = /* @__PURE__ */ __name((permissions, key, defaults) => {
935
- const own = nearest(permissions, key);
936
- const builtIn = nearest(defaults, key);
937
- if (!builtIn || own && own.depth >= builtIn.depth)
938
- return own ? { level: own.level, key: own.key } : ALLOWED;
939
- if (!own || ORDER[builtIn.level] <= ORDER[own.level])
940
- return { level: builtIn.level, key: builtIn.key };
941
- return { level: own.level, key: own.key };
942
- }, "profileLevel");
943
- var CHAT_KEYS = {
944
- settings: "chats.update",
945
- "requests.accept": "chats.requests.confirm",
946
- "requests.decline": "chats.requests.reject",
947
- "link.create": "chats.links.create",
948
- "link.reset": "chats.links.reset",
949
- "link.revoke": "chats.links.remove",
950
- "link.update": "chats.links.update"
951
- };
952
- var ACCOUNT_KEYS = {
953
- "contact-add": "contacts.add",
954
- "contact-remove": "contacts.remove",
955
- "contact-import": "contacts.import",
956
- "contact-rename": "contacts.rename",
957
- "contact-block": "contacts.block",
958
- "contact-unblock": "contacts.unblock",
959
- profile: "account.update",
960
- "folder-create": "chats.folders.create",
961
- "folder-update": "chats.folders.update",
962
- "folder-delete": "chats.folders.delete",
963
- "folder-order": "chats.folders.order",
964
- "folder-join": "chats.folders.join",
965
- "sessions-end": "account.sessions.end",
966
- "chat-mute": "chats.mute",
967
- "chat-unmute": "chats.unmute",
968
- "chat-archive": "chats.archive",
969
- "chat-unarchive": "chats.unarchive",
970
- "chat-pin": "chats.pin",
971
- "chat-unpin": "chats.unpin",
972
- "chat-mark-unread": "chats.mark-unread",
973
- "message-star": "messages.star",
974
- "message-unstar": "messages.unstar",
975
- // A mail CLI names its own key on every write; these only answer `keyForWrite` when one is left out.
976
- "message-flag": "messages.update",
977
- "message-move": "messages.move",
978
- "message-copy": "messages.copy",
979
- "message-delete": "messages.trash",
980
- "message-restore": "messages.restore",
981
- privacy: "account.privacy.set"
982
- };
983
- var KIND_KEYS = {
984
- message: "messages.send",
985
- forward: "messages.forward",
986
- edit: "messages.edit",
987
- pin: "messages.pin",
988
- reaction: "reactions",
989
- read: "chats.mark-read",
990
- delete: "messages.delete"
991
- };
992
- var keyForWrite = /* @__PURE__ */ __name((kind, action) => {
993
- if (kind === "chat")
994
- return CHAT_KEYS[action] ?? `chats.${action ?? "update"}`;
995
- if (kind === "account") {
996
- const key = ACCOUNT_KEYS[action];
997
- if (!key)
998
- throw new Error(`an account change without a known action: ${action}`);
999
- return key;
1000
- }
1001
- return KIND_KEYS[kind];
1002
- }, "keyForWrite");
1003
- var writeOfKey = /* @__PURE__ */ __name((key) => {
1004
- const account = Object.entries(ACCOUNT_KEYS).find(([, named]) => named === key)?.[0];
1005
- if (account)
1006
- return { kind: "account", action: account };
1007
- const kind = Object.entries(KIND_KEYS).find(([, named]) => named === key || key.startsWith(`${named}.`))?.[0];
1008
- if (kind)
1009
- return { kind };
1010
- if (key === "messages.unpin")
1011
- return { kind: "pin" };
1012
- if (key.startsWith("chats.")) {
1013
- const action = Object.entries(CHAT_KEYS).find(([, named]) => named === key)?.[0] ?? key.slice("chats.".length);
1014
- return { kind: "chat", action };
1015
- }
1016
- return {};
1017
- }, "writeOfKey");
1018
- var NAMED_WRITE_KEYS = [
1019
- "drafts",
1020
- "store.gaps.repair",
1021
- "messages.sync-first",
1022
- "messages.server-search",
1023
- "messages.press",
1024
- "chats.start",
1025
- "chats.app",
1026
- "stats.messages.counters.sync",
1027
- "stats.messages.show.sync-first",
1028
- "stats.messages.top.sync-first",
1029
- "stats.contacts.top.sync-first",
1030
- "account.sessions.list",
1031
- "attachments.extract",
1032
- "attachments.move",
1033
- "attachments.update",
1034
- "bot.callbacks.answer",
1035
- "bot.chats.action",
1036
- "bot.chats.admins.add",
1037
- "bot.chats.admins.remove",
1038
- "bot.chats.leave",
1039
- "bot.chats.members.remove",
1040
- "bot.chats.moderate",
1041
- "bot.messages.delete",
1042
- "bot.messages.edit",
1043
- "bot.messages.pin",
1044
- "bot.messages.send",
1045
- "bot.messages.unpin",
1046
- "chats.admins.add",
1047
- "chats.admins.remove",
1048
- "chats.links.create",
1049
- "chats.links.reset",
1050
- "chats.links.remove",
1051
- "chats.links.update",
1052
- "chats.members.add",
1053
- "chats.members.remove",
1054
- "chats.moderate",
1055
- "conversations.embeddings",
1056
- "conversations.links",
1057
- "polls.close",
1058
- "polls.create",
1059
- "polls.vote",
1060
- "searches.clear",
1061
- "searches.create",
1062
- "searches.delete",
1063
- "contacts.aliases.set",
1064
- "contacts.aliases.remove",
1065
- "contacts.notes.add",
1066
- "contacts.notes.edit",
1067
- "contacts.notes.remove",
1068
- "tags.rebuild",
1069
- "metadata.sync",
1070
- "mentions.rebuild",
1071
- "mentions.confirm",
1072
- "mentions.reject",
1073
- "tags.add",
1074
- "tags.remove",
1075
- "tasks.acknowledge",
1076
- "tasks.add",
1077
- "tasks.claim",
1078
- "tasks.close",
1079
- "tasks.duplicates.defer",
1080
- "tasks.duplicates.reject",
1081
- "tasks.link",
1082
- "tasks.merge",
1083
- "tasks.update",
1084
- "tasks.release",
1085
- "tasks.scan",
1086
- "tasks.unmerge",
1087
- "topics.create",
1088
- "topics.edit",
1089
- "topics.enable"
1090
- ];
1091
- var WRITE_KEYS = [
1092
- .../* @__PURE__ */ new Set([
1093
- ...NAMED_WRITE_KEYS,
1094
- ...Object.keys(DEFAULT_PERMISSIONS),
1095
- ...Object.values(KIND_KEYS),
1096
- ...Object.values(ACCOUNT_KEYS),
1097
- ...Object.values(CHAT_KEYS)
1098
- ])
1099
- ];
1100
- var HOUSEKEEPING = /* @__PURE__ */ new Set([
1101
- "help",
1102
- "guide",
1103
- "config",
1104
- "session",
1105
- "doctor",
1106
- "commands",
1107
- "complete",
1108
- "upgrade",
1109
- "skill",
1110
- "models",
1111
- "server",
1112
- // What a schedule runs is checked by its own key when it runs; an agent runs read-only.
1113
- "schedule",
1114
- "runs",
1115
- "sends",
1116
- "recipients",
1117
- "flood",
1118
- "mcp",
1119
- // Its commands read the rules or flip the pause switch; what a rule sends is checked as `replies.send`.
1120
- "replies"
1121
- ]);
1122
- var BOT_HOUSEKEEPING = /* @__PURE__ */ new Set(["auth", "list", "sends", "recipients", "mcp"]);
1123
- var STORE_MAINTENANCE = /* @__PURE__ */ new Set(["info", "check", "copies"]);
1124
- var SHOW_MESSAGES = /* @__PURE__ */ new Set(["inbox", "review", "watch", "serve", "store", "conversations", "projects"]);
1125
- var readKeysForCommand = /* @__PURE__ */ __name((path) => {
1126
- if (path[0] === "bot")
1127
- return readKeysForCommand(path.slice(1)).map((key2) => `bot.${key2}`);
1128
- const key = keyForCommand(path);
1129
- if (!key)
1130
- return [];
1131
- if (path[0] === "attachments" && path[1] === "download")
1132
- return [key, "messages", "chats"];
1133
- if (path[0] === "attachments" && (path[1] === "extract" || path[1] === "show"))
1134
- return [key, "messages"];
1135
- if (path[0] === "store" && path[1] === "gaps" && path[2] === "repair")
1136
- return [key, "messages"];
1137
- if (path[0] === "store" && ["reset", "clear", "decrypt"].includes(path[1] ?? ""))
1138
- return [key, "messages"];
1139
- if (path[0] === "search") {
1140
- if (path[1] === "notes")
1141
- return [key];
1142
- if (path[1] === "topics")
1143
- return [key, "topics"];
1144
- if (path[1] === "conversations")
1145
- return [key, "messages", "conversations"];
1146
- return [key, "messages"];
1147
- }
1148
- if (path[0] !== "stats")
1149
- return [key];
1150
- const resource = path[1] === "charts" ? "chats" : path[1];
1151
- return [
1152
- .../* @__PURE__ */ new Set([
1153
- key,
1154
- "messages",
1155
- ...["chats", "contacts", "tasks"].includes(resource ?? "") ? [resource] : []
1156
- ])
1157
- ];
1158
- }, "readKeysForCommand");
1159
- var keyForCommand = /* @__PURE__ */ __name((path) => {
1160
- if (path.length === 0)
1161
- return null;
1162
- const [top, next] = path;
1163
- if (top === "bot") {
1164
- if (next === void 0 || BOT_HOUSEKEEPING.has(next))
1165
- return null;
1166
- const inner = keyForCommand(path.slice(1));
1167
- return `bot.${inner ?? path.slice(1).join(".")}`;
1168
- }
1169
- if (KEYED_UNDER_HOUSEKEEPING.has(path.join(".")))
1170
- return path.join(".");
1171
- if (top === void 0 || HOUSEKEEPING.has(top) || top === "search" && next === "runs")
1172
- return null;
1173
- if (top === "images" && next === "models")
1174
- return null;
1175
- if (top === "attachments" && (next === "check" || next === "jobs"))
1176
- return null;
1177
- if (top === "attachments" && next === "download")
1178
- return "messages";
1179
- if (top === "store" && next !== void 0 && STORE_MAINTENANCE.has(next))
1180
- return null;
1181
- if (top === "conversations" && next === "links")
1182
- return path[2] === "rebuild" ? "conversations.links.rebuild" : "conversations.links";
1183
- if (top === "conversations" && (next === "embeddings" || next === "embed") || top === "images" && next === "embed" || top === "conversations" && next === "rebuild")
1184
- return "conversations.embeddings";
1185
- if (top === "attachments" && next === "list" || top === "chats" && next === "documents")
1186
- return "messages";
1187
- if (top === "mentions")
1188
- return next === "rebuild" || next === "confirm" || next === "reject" ? `mentions.${next}` : "messages";
1189
- if (top === "store" && (next === "gaps" || next === "jobs"))
1190
- return path.join(".");
1191
- if (SHOW_MESSAGES.has(top) || top === "contacts" && (next === "context" || next === "prepare" || next === "events"))
1192
- return "messages";
1193
- if (RESOURCES.includes(top))
1194
- return path.join(".");
1195
- return void 0;
1196
- }, "keyForCommand");
1197
- var RESOURCE_KEY = new RegExp(`^(${RESOURCES.join("|")})(\\.[a-z][a-z-]*)*$`);
1198
- var COMMAND_PATH_KEY = /^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/;
1199
- var permissionOverrides = /* @__PURE__ */ __name((entries = [], shape = RESOURCE_KEY) => {
1200
- const levels = {};
1201
- const example = shape === RESOURCE_KEY ? "messages.send=allow" : "api=readonly";
1202
- for (const entry of entries) {
1203
- const [key = "", level = "", extra] = entry.split("=");
1204
- if (!shape.test(key) || !LEVELS.includes(level) || extra !== void 0)
1205
- throw new CliError("validation_error", `--permission takes a command path and level, e.g. ${example} (deny, readonly, ask, allow)`);
1206
- levels[key] = level;
1207
- }
1208
- return levels;
1209
- }, "permissionOverrides");
1210
- var assertOverridesTighten = /* @__PURE__ */ __name((overrides, profile, defaults = DEFAULT_PERMISSIONS) => {
1211
- for (const [key, level] of Object.entries(overrides)) {
1212
- const under = Object.keys(profile).filter((named) => named.startsWith(`${key}.`));
1213
- const lifted = [key, ...under].find((named) => ORDER[level] > ORDER[levelFor(profile, named, defaults).level]);
1214
- if (lifted !== void 0)
1215
- throw new CliError("validation_error", `--permission ${key}=${level} would loosen ${lifted} from ${levelFor(profile, lifted, defaults).level}; it only tightens \u2014 change the profile's permissions to loosen it`, { key, lifted });
1216
- }
1217
- }, "assertOverridesTighten");
1218
- var assertRetentionEvidenceRead = /* @__PURE__ */ __name((permissions) => {
1219
- for (const permission of ["stats.chats.retention", "chats"]) {
1220
- if (levelFor(permissions, permission).level === "deny")
1221
- throw new CliError("permission_error", `profile denies ${permission}`, { permission });
1222
- }
1223
- }, "assertRetentionEvidenceRead");
1224
-
1225
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/sends/guarded.js
1226
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
1227
- var sentIds = /* @__PURE__ */ __name((typed, message) => ({
1228
- messageId: message.id,
1229
- ...message.chatId && message.chatId !== typed ? { resultChatId: message.chatId } : {}
1230
- }), "sentIds");
1231
- var current = new AsyncLocalStorage2();
1232
- var writesInFlight = new AsyncLocalStorage2();
1233
- var parents = /* @__PURE__ */ new WeakMap();
1234
- var stopped = /* @__PURE__ */ new WeakMap();
1235
- var scopesFor = /* @__PURE__ */ __name((scope = writesInFlight.getStore()) => {
1236
- const result = [];
1237
- for (let at = scope; at; at = parents.get(at))
1238
- result.push(at);
1239
- return result;
1240
- }, "scopesFor");
1241
- var withWriteScope = /* @__PURE__ */ __name((scope, body) => {
1242
- const parent = writesInFlight.getStore();
1243
- if (parent && parent !== scope)
1244
- parents.set(scope, parent);
1245
- return writesInFlight.run(scope, body);
1246
- }, "withWriteScope");
1247
- var stopWrites = /* @__PURE__ */ __name((scope, reason) => {
1248
- stopped.set(scope, reason);
1249
- for (const write of scope)
1250
- write.cut();
1251
- }, "stopWrites");
1252
- var refuseStopped = /* @__PURE__ */ __name((scopes2) => {
1253
- for (const scope of scopes2)
1254
- if (stopped.has(scope))
1255
- throw stopped.get(scope);
1256
- }, "refuseStopped");
1257
- var currentOperation = /* @__PURE__ */ __name(() => current.getStore(), "currentOperation");
1258
- var guardedWrite = /* @__PURE__ */ __name(async (guard, attempt, act, settled = () => ({}), prepare) => {
1259
- const scopes2 = scopesFor();
1260
- refuseStopped(scopes2);
1261
- try {
1262
- await guard.ask?.(attempt);
1263
- refuseStopped(scopes2);
1264
- if (guard.reserve) {
1265
- guard.check(attempt, { reserve: false });
1266
- await guard.reserve(attempt);
1267
- } else
1268
- guard.check(attempt);
1269
- } catch (error) {
1270
- guard.record({ ...attempt, outcome: "refused", errorCode: codeOf(error) });
1271
- throw error;
1272
- }
1273
- try {
1274
- refuseStopped(scopes2);
1275
- } catch (error) {
1276
- guard.record({ ...attempt, outcome: "failed", errorCode: codeOf(error) });
1277
- throw error;
1278
- }
1279
- let recorded = false;
1280
- const once = /* @__PURE__ */ __name((entry) => {
1281
- if (recorded)
1282
- return;
1283
- recorded = true;
1284
- guard.record(entry);
1285
- }, "once");
1286
- let cancelled = false;
1287
- const flight = {
1288
- operationId: attempt.operationId,
1289
- preparing: prepare !== void 0,
1290
- cut: /* @__PURE__ */ __name(() => {
1291
- cancelled = true;
1292
- once({
1293
- ...attempt,
1294
- outcome: flight.preparing ? "failed" : "outcome_unknown",
1295
- errorCode: flight.preparing ? "timeout" : "outcome_unknown"
1296
- });
1297
- }, "cut")
1298
- };
1299
- for (const scope of scopes2)
1300
- scope.add(flight);
1301
- try {
1302
- if (prepare !== void 0)
1303
- await prepare();
1304
- if (cancelled)
1305
- throw new CliError("timeout", "the command ended before sending; nothing was sent", { sent: false });
1306
- flight.preparing = false;
1307
- const done = await current.run(attempt.operationId, act);
1308
- if (cancelled)
1309
- throw new CliError("outcome_unknown", "the command ended with a write in flight; check its result before continuing", { operation_id: attempt.operationId });
1310
- once({ ...attempt, ...settled(done), outcome: "sent" });
1311
- return done;
1312
- } catch (error) {
1313
- const code = codeOf(error);
1314
- once({ ...attempt, outcome: code === "outcome_unknown" ? "outcome_unknown" : "failed", errorCode: code });
1315
- if (code === "outcome_unknown" && error instanceof Error)
1316
- throw new CliError("outcome_unknown", error.message, {
1317
- ...error.details,
1318
- operation_id: attempt.operationId,
1319
- retryable: false
1320
- });
1321
- if (flight.preparing && isCliError(error) && error.details.sent === void 0)
1322
- throw new CliError(error.code, error.message, { ...error.details, sent: false });
1323
- throw error;
1324
- } finally {
1325
- for (const scope of scopes2)
1326
- scope.delete(flight);
1327
- }
1328
- }, "guardedWrite");
1329
- var codeOf = /* @__PURE__ */ __name((error) => typeof error?.code === "string" ? error.code : "unknown", "codeOf");
1330
-
1331
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/models/endpoint.js
1332
- var endpoint = /* @__PURE__ */ __name((value) => {
1333
- try {
1334
- const url2 = new URL(value);
1335
- return ["https:", "http:"].includes(url2.protocol) && !url2.username && !url2.password && !url2.search && !url2.hash;
1336
- } catch {
1337
- return false;
1338
- }
1339
- }, "endpoint");
1340
-
1341
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/models/settings.js
1342
- var MODEL_FIELDS = ["provider", "model", "base_url"];
1343
- var modelSettingsShape = record(pipe(string(), regex(/^[a-z][a-z0-9-]*$/)), strictObject({
1344
- provider: optional(picklist(["off", "openai", "anthropic"])),
1345
- model: optional(pipe(string(), trim(), minLength(1), maxLength(200))),
1346
- base_url: optional(pipe(string(), check((value) => endpoint(value), "use an HTTP/S endpoint without credentials, query or fragment")))
1347
- }));
1348
- var resolveModelSettings = /* @__PURE__ */ __name((prefix, layers, env) => {
1349
- const configured = layers.map(([from, scope]) => [from, scope?.models ?? {}]);
1350
- const purposes = /* @__PURE__ */ new Set([
1351
- "default",
1352
- "analysis",
1353
- "replies",
1354
- ...configured.flatMap(([, models2]) => Object.keys(models2))
1355
- ]);
1356
- for (const name of Object.keys(env)) {
1357
- const match = new RegExp(`^${prefix}_MODELS_([A-Z][A-Z0-9_]*)_(PROVIDER|MODEL|BASE_URL)$`).exec(name);
1358
- if (match?.[1])
1359
- purposes.add(match[1].toLowerCase().replaceAll("_", "-"));
728
+ name: "tokenizer_config.json",
729
+ url: bge("tokenizer_config.json"),
730
+ sha256: "b87c8703482b0300d3da30e201519aa641f6a450f5eb5bf1e624afbf70c74d80",
731
+ bytes: 1203
732
+ }
733
+ ]
1360
734
  }
1361
- const models = {};
1362
- const sources = {};
1363
- for (const purpose of purposes) {
1364
- const resolved = {};
1365
- for (const field of MODEL_FIELDS) {
1366
- const variable = `${prefix}_MODELS_${purpose.replaceAll("-", "_").toUpperCase()}_${field.toUpperCase()}`;
1367
- const candidates = [
1368
- [variable, env[variable]?.trim() || void 0],
1369
- ...configured.map(([from, model]) => [
1370
- `${from}: models.${purpose}.${field}`,
1371
- model[purpose]?.[field]
1372
- ]),
1373
- ...purpose === "default" ? [] : [
1374
- [
1375
- `${prefix}_MODELS_DEFAULT_${field.toUpperCase()}`,
1376
- env[`${prefix}_MODELS_DEFAULT_${field.toUpperCase()}`]?.trim() || void 0
1377
- ],
1378
- ...configured.map(([from, model]) => [
1379
- `${from}: models.default.${field}`,
1380
- model.default?.[field]
1381
- ])
1382
- ]
1383
- ];
1384
- const selected = candidates.find(([, value]) => value !== void 0);
1385
- if (selected)
1386
- resolved[field] = selected[1];
1387
- sources[`models.${purpose}.${field}`] = selected?.[0] ?? "default";
1388
- }
1389
- if (Object.keys(resolved).length)
1390
- models[purpose] = resolved;
735
+ ];
736
+ var DEFAULT_RERANK_MODEL = "mmarco";
737
+ var rerankModel = /* @__PURE__ */ __name((id2) => {
738
+ const found = RERANK_MODELS.find((model) => model.id === id2);
739
+ if (!found) {
740
+ throw new CliError("validation_error", `no reranker ${id2} \u2014 one of: ${RERANK_MODELS.map((model) => model.id).join(", ")}`);
1391
741
  }
1392
- const checked = safeParse(modelSettingsShape, models);
1393
- if (!checked.success)
1394
- throw new CliError("configuration_error", `models.${getDotPath(checked.issues[0]) ?? "settings"} is invalid`);
1395
- return { models: checked.output, sources };
1396
- }, "resolveModelSettings");
1397
- var modelTarget = /* @__PURE__ */ __name((settings, purpose) => {
1398
- const configured = { ...settings.models?.default, ...settings.models?.[purpose] };
1399
- if (configured.provider === void 0 || configured.provider === "off")
1400
- return void 0;
1401
- if (!configured.model)
1402
- throw new CliError("configuration_error", `set models.${purpose}.model before calling its provider`);
1403
- return {
1404
- provider: configured.provider,
1405
- model: configured.model,
1406
- ...configured.base_url === void 0 ? {} : { baseUrl: configured.base_url }
1407
- };
1408
- }, "modelTarget");
1409
-
1410
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/services/history-limits.js
1411
- var HISTORY_MAX_DAYS = 1095;
1412
- var DEFAULT_HISTORY_LIMITS = { dialogDays: 1095, groupDays: 365, groupMembersMax: 50 };
1413
- var DAY_MS2 = 24 * 60 * 60 * 1e3;
1414
- var historyWindow = /* @__PURE__ */ __name((shape, limits, now) => {
1415
- const group = shape !== void 0 && shape.kind !== "dialog" && shape.kind !== "saved";
1416
- if (group && (shape.participantsCount ?? 0) > limits.groupMembersMax)
1417
- return { skip: "group_too_large", members: shape.participantsCount ?? 0 };
1418
- const days2 = group ? limits.groupDays : limits.dialogDays;
1419
- return { keepFrom: now - Math.min(days2, HISTORY_MAX_DAYS) * DAY_MS2 };
1420
- }, "historyWindow");
1421
- var limitBatch = /* @__PURE__ */ __name((batch, shapes, included, limits, now = Date.now()) => {
1422
- const skipped = /* @__PURE__ */ new Map();
1423
- if (!batch.messages?.length)
1424
- return { batch, skipped };
1425
- const named = new Map((batch.chats ?? []).map((chat) => [chat.id, chat]));
1426
- const windows = /* @__PURE__ */ new Map();
1427
- const windowOf = /* @__PURE__ */ __name((chatId) => {
1428
- if (!windows.has(chatId)) {
1429
- const chat = named.get(chatId);
1430
- const shape = chat ? { kind: chat.kind, participantsCount: chat.participantsCount ?? null } : shapes(chatId);
1431
- windows.set(chatId, included(chatId) ? void 0 : historyWindow(shape, limits, now));
1432
- }
1433
- return windows.get(chatId);
1434
- }, "windowOf");
1435
- const messages = batch.messages.filter((message) => {
1436
- const window = windowOf(message.chatId);
1437
- if (window === void 0)
1438
- return true;
1439
- const at = Date.parse(message.timestamp);
1440
- if ("keepFrom" in window && !(at < window.keepFrom))
1441
- return true;
1442
- const reason = "skip" in window ? window.skip : "older_than_window";
1443
- const held = skipped.get(message.chatId);
1444
- const iso = new Date(at).toISOString();
1445
- skipped.set(message.chatId, {
1446
- reason,
1447
- messages: (held?.messages ?? 0) + 1,
1448
- oldestAt: held && held.oldestAt < iso ? held.oldestAt : iso,
1449
- newestAt: held && held.newestAt > iso ? held.newestAt : iso,
1450
- ..."skip" in window ? { members: window.members } : { keptFrom: new Date(window.keepFrom).toISOString() }
1451
- });
1452
- return false;
1453
- });
1454
- return { batch: { ...batch, messages }, skipped };
1455
- }, "limitBatch");
742
+ return found;
743
+ }, "rerankModel");
744
+ var vectorModelKey = /* @__PURE__ */ __name((model) => {
745
+ const weights = model.custom ? model.files.find(({ name }) => name === model.onnx)?.sha256.slice(0, 12) : void 0;
746
+ return `local:${model.id}${weights ? `@${weights}` : ""}:${model.dims}`;
747
+ }, "vectorModelKey");
748
+ var meaningFloor = /* @__PURE__ */ __name((key) => key === "local:e5-small:384" ? 0.8 : 0, "meaningFloor");
1456
749
 
1457
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/entities/task.js
750
+ // 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/entities/task.js
1458
751
  var closeSuggestion = strictObject({
1459
752
  as: picklist(["done", "dismissed"]),
1460
753
  /** The agent's name. */
@@ -1516,7 +809,7 @@ var task = strictObject({
1516
809
  updated_at: optional(time)
1517
810
  });
1518
811
 
1519
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/entities/agenda.js
812
+ // 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/entities/agenda.js
1520
813
  var agendaChat = strictObject({
1521
814
  chat: reference,
1522
815
  title: nullable(text),
@@ -1586,7 +879,7 @@ var agenda = strictObject({
1586
879
  unlisted_categories: array(strictObject({ name: text, open_tasks: number() }))
1587
880
  });
1588
881
 
1589
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/entities/attachment.js
882
+ // 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/entities/attachment.js
1590
883
  var attachment = strictObject({
1591
884
  /** The message it came with, as a locator; absent inside that message. */
1592
885
  message: optional(reference),
@@ -1624,7 +917,7 @@ var attachment = strictObject({
1624
917
  });
1625
918
  var hitFile = strictObject({ position: count, kind: text, name: optional(text), size: optional(count) });
1626
919
 
1627
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/entities/conversation.js
920
+ // 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/entities/conversation.js
1628
921
  var conversation = strictObject({
1629
922
  id,
1630
923
  chat: reference,
@@ -1639,7 +932,7 @@ var conversation = strictObject({
1639
932
  rules_version: count
1640
933
  });
1641
934
 
1642
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/entities/tagging.js
935
+ // 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/entities/tagging.js
1643
936
  var tagging = strictObject({
1644
937
  tag: text,
1645
938
  type: picklist(TAG_TYPES),
@@ -1652,7 +945,160 @@ var tagging = strictObject({
1652
945
  created_at: time
1653
946
  });
1654
947
 
1655
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/images/picture/models.js
948
+ // 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/guarded.js
949
+ import { AsyncLocalStorage } from "node:async_hooks";
950
+ var sentIds = /* @__PURE__ */ __name((typed, message) => ({
951
+ messageId: message.id,
952
+ ...message.chatId && message.chatId !== typed ? { resultChatId: message.chatId } : {}
953
+ }), "sentIds");
954
+ var current = new AsyncLocalStorage();
955
+ var writesInFlight = new AsyncLocalStorage();
956
+ var parents = /* @__PURE__ */ new WeakMap();
957
+ var stopped = /* @__PURE__ */ new WeakMap();
958
+ var scopesFor = /* @__PURE__ */ __name((scope = writesInFlight.getStore()) => {
959
+ const result = [];
960
+ for (let at = scope; at; at = parents.get(at))
961
+ result.push(at);
962
+ return result;
963
+ }, "scopesFor");
964
+ var withWriteScope = /* @__PURE__ */ __name((scope, body) => {
965
+ const parent = writesInFlight.getStore();
966
+ if (parent && parent !== scope)
967
+ parents.set(scope, parent);
968
+ return writesInFlight.run(scope, body);
969
+ }, "withWriteScope");
970
+ var stopWrites = /* @__PURE__ */ __name((scope, reason) => {
971
+ stopped.set(scope, reason);
972
+ for (const write of scope)
973
+ write.cut();
974
+ }, "stopWrites");
975
+ var refuseStopped = /* @__PURE__ */ __name((scopes) => {
976
+ for (const scope of scopes)
977
+ if (stopped.has(scope))
978
+ throw stopped.get(scope);
979
+ }, "refuseStopped");
980
+ var currentOperation = /* @__PURE__ */ __name(() => current.getStore(), "currentOperation");
981
+ var guardedWrite = /* @__PURE__ */ __name(async (guard, attempt, act, settled = () => ({}), prepare) => {
982
+ const scopes = scopesFor();
983
+ refuseStopped(scopes);
984
+ try {
985
+ await guard.ask?.(attempt);
986
+ refuseStopped(scopes);
987
+ if (guard.reserve) {
988
+ guard.check(attempt, { reserve: false });
989
+ await guard.reserve(attempt);
990
+ } else
991
+ guard.check(attempt);
992
+ } catch (error) {
993
+ guard.record({ ...attempt, outcome: "refused", errorCode: codeOf(error) });
994
+ throw error;
995
+ }
996
+ try {
997
+ refuseStopped(scopes);
998
+ } catch (error) {
999
+ guard.record({ ...attempt, outcome: "failed", errorCode: codeOf(error) });
1000
+ throw error;
1001
+ }
1002
+ let recorded = false;
1003
+ const once = /* @__PURE__ */ __name((entry) => {
1004
+ if (recorded)
1005
+ return;
1006
+ recorded = true;
1007
+ guard.record(entry);
1008
+ }, "once");
1009
+ let cancelled = false;
1010
+ const flight = {
1011
+ operationId: attempt.operationId,
1012
+ preparing: prepare !== void 0,
1013
+ cut: /* @__PURE__ */ __name(() => {
1014
+ cancelled = true;
1015
+ once({
1016
+ ...attempt,
1017
+ outcome: flight.preparing ? "failed" : "outcome_unknown",
1018
+ errorCode: flight.preparing ? "timeout" : "outcome_unknown"
1019
+ });
1020
+ }, "cut")
1021
+ };
1022
+ for (const scope of scopes)
1023
+ scope.add(flight);
1024
+ try {
1025
+ if (prepare !== void 0)
1026
+ await prepare();
1027
+ if (cancelled)
1028
+ throw new CliError("timeout", "the command ended before sending; nothing was sent", { sent: false });
1029
+ flight.preparing = false;
1030
+ const done = await current.run(attempt.operationId, act);
1031
+ if (cancelled)
1032
+ throw new CliError("outcome_unknown", "the command ended with a write in flight; check its result before continuing", { operation_id: attempt.operationId });
1033
+ once({ ...attempt, ...settled(done), outcome: "sent" });
1034
+ return done;
1035
+ } catch (error) {
1036
+ const code = codeOf(error);
1037
+ once({ ...attempt, outcome: code === "outcome_unknown" ? "outcome_unknown" : "failed", errorCode: code });
1038
+ if (code === "outcome_unknown" && error instanceof Error)
1039
+ throw new CliError("outcome_unknown", error.message, {
1040
+ ...error.details,
1041
+ operation_id: attempt.operationId,
1042
+ retryable: false
1043
+ });
1044
+ if (flight.preparing && isCliError(error) && error.details.sent === void 0)
1045
+ throw new CliError(error.code, error.message, { ...error.details, sent: false });
1046
+ throw error;
1047
+ } finally {
1048
+ for (const scope of scopes)
1049
+ scope.delete(flight);
1050
+ }
1051
+ }, "guardedWrite");
1052
+ var codeOf = /* @__PURE__ */ __name((error) => typeof error?.code === "string" ? error.code : "unknown", "codeOf");
1053
+
1054
+ // 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/services/history-limits.js
1055
+ var HISTORY_MAX_DAYS = 1095;
1056
+ var DEFAULT_HISTORY_LIMITS = { dialogDays: 1095, groupDays: 365, groupMembersMax: 50 };
1057
+ var DAY_MS = 24 * 60 * 60 * 1e3;
1058
+ var historyWindow = /* @__PURE__ */ __name((shape, limits, now) => {
1059
+ const group = shape !== void 0 && shape.kind !== "dialog" && shape.kind !== "saved";
1060
+ if (group && (shape.participantsCount ?? 0) > limits.groupMembersMax)
1061
+ return { skip: "group_too_large", members: shape.participantsCount ?? 0 };
1062
+ const days = group ? limits.groupDays : limits.dialogDays;
1063
+ return { keepFrom: now - Math.min(days, HISTORY_MAX_DAYS) * DAY_MS };
1064
+ }, "historyWindow");
1065
+ var limitBatch = /* @__PURE__ */ __name((batch, shapes, included, limits, now = Date.now()) => {
1066
+ const skipped = /* @__PURE__ */ new Map();
1067
+ if (!batch.messages?.length)
1068
+ return { batch, skipped };
1069
+ const named = new Map((batch.chats ?? []).map((chat) => [chat.id, chat]));
1070
+ const windows = /* @__PURE__ */ new Map();
1071
+ const windowOf = /* @__PURE__ */ __name((chatId) => {
1072
+ if (!windows.has(chatId)) {
1073
+ const chat = named.get(chatId);
1074
+ const shape = chat ? { kind: chat.kind, participantsCount: chat.participantsCount ?? null } : shapes(chatId);
1075
+ windows.set(chatId, included(chatId) ? void 0 : historyWindow(shape, limits, now));
1076
+ }
1077
+ return windows.get(chatId);
1078
+ }, "windowOf");
1079
+ const messages = batch.messages.filter((message) => {
1080
+ const window = windowOf(message.chatId);
1081
+ if (window === void 0)
1082
+ return true;
1083
+ const at = Date.parse(message.timestamp);
1084
+ if ("keepFrom" in window && !(at < window.keepFrom))
1085
+ return true;
1086
+ const reason = "skip" in window ? window.skip : "older_than_window";
1087
+ const held = skipped.get(message.chatId);
1088
+ const iso = new Date(at).toISOString();
1089
+ skipped.set(message.chatId, {
1090
+ reason,
1091
+ messages: (held?.messages ?? 0) + 1,
1092
+ oldestAt: held && held.oldestAt < iso ? held.oldestAt : iso,
1093
+ newestAt: held && held.newestAt > iso ? held.newestAt : iso,
1094
+ ..."skip" in window ? { members: window.members } : { keptFrom: new Date(window.keepFrom).toISOString() }
1095
+ });
1096
+ return false;
1097
+ });
1098
+ return { batch: { ...batch, messages }, skipped };
1099
+ }, "limitBatch");
1100
+
1101
+ // 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/images/picture/models.js
1656
1102
  import { join as join2 } from "node:path";
1657
1103
  var clip = /* @__PURE__ */ __name((name) => `https://huggingface.co/Xenova/clip-vit-base-patch32/resolve/d15189d7028b43f1d3e65039190477f6af591c2a/${name}`, "clip");
1658
1104
  var IMAGE_MODELS = [
@@ -1706,7 +1152,7 @@ var imageModelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedM
1706
1152
  var placedImage = /* @__PURE__ */ __name((model, directory) => model.files.map((file) => [file, join2(directory, model.id, file.name)]), "placedImage");
1707
1153
  var isImageModelInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placedImage(model, directory)), "isImageModelInstalled");
1708
1154
 
1709
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/botcheck/reasons.js
1155
+ // 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/botcheck/reasons.js
1710
1156
  var WEIGHTS = {
1711
1157
  bot: 3,
1712
1158
  scam: 3,
@@ -1731,56 +1177,23 @@ var LINK = /https?:\/\/|t\.me\/|www\./i;
1731
1177
  var DIGITS = /\d{5,}/;
1732
1178
  var oddName = /* @__PURE__ */ __name((name) => !name?.trim() || DIGITS.test(name) || LINK.test(name), "oddName");
1733
1179
 
1180
+ // 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/background/checkpoints.js
1181
+ var progressOf = /* @__PURE__ */ __name((input) => {
1182
+ const total = input.total ?? null;
1183
+ const updated = input.updatedAt ?? null;
1184
+ return {
1185
+ job: input.job,
1186
+ profile: input.profile,
1187
+ done: input.done,
1188
+ total,
1189
+ remaining: total === null ? null : Math.max(0, total - input.done),
1190
+ state: input.complete ?? (total !== null && input.done >= total) ? "complete" : "partial",
1191
+ updated_at: updated,
1192
+ cursor_age_ms: updated === null ? null : Math.max(0, (input.now ?? /* @__PURE__ */ new Date()).getTime() - Date.parse(updated))
1193
+ };
1194
+ }, "progressOf");
1195
+
1734
1196
  export {
1735
- logAttributes,
1736
- fromLogAttributes,
1737
- snakeLogger,
1738
- LOG_ATTRIBUTES,
1739
- KEEP_RUNS_FOR_DAYS,
1740
- KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
1741
- RUNS_SIZE_LIMIT_MB,
1742
- runsDirFor,
1743
- startRun,
1744
- runtime,
1745
- newRunId,
1746
- listRuns,
1747
- findRun,
1748
- readEvents,
1749
- currentRun,
1750
- inRun,
1751
- runEvent,
1752
- typedCommand,
1753
- useAsProcessRun,
1754
- processRun,
1755
- enclosingTraceId,
1756
- traceOf,
1757
- childTrace,
1758
- withAttempt,
1759
- currentAttempt,
1760
- sentIds,
1761
- withWriteScope,
1762
- stopWrites,
1763
- currentOperation,
1764
- guardedWrite,
1765
- codeOf,
1766
- endpoint,
1767
- modelSettingsShape,
1768
- resolveModelSettings,
1769
- modelTarget,
1770
- parseDuration,
1771
- DEFAULT_TEXT_MODEL,
1772
- CustomTextModelShape,
1773
- textModelsFile,
1774
- readTextModelsSection,
1775
- writeTextModelsSection,
1776
- textModels,
1777
- textModel,
1778
- chosenTextModel,
1779
- RERANK_MODELS,
1780
- DEFAULT_RERANK_MODEL,
1781
- rerankModel,
1782
- vectorModelKey,
1783
- meaningFloor,
1784
1197
  LEVELS,
1785
1198
  skipFlagFor,
1786
1199
  DEFAULT_PERMISSIONS,
@@ -1803,10 +1216,6 @@ export {
1803
1216
  permissionOverrides,
1804
1217
  assertOverridesTighten,
1805
1218
  assertRetentionEvidenceRead,
1806
- HISTORY_MAX_DAYS,
1807
- DEFAULT_HISTORY_LIMITS,
1808
- historyWindow,
1809
- limitBatch,
1810
1219
  closeSuggestion,
1811
1220
  task,
1812
1221
  agenda,
@@ -1816,7 +1225,33 @@ export {
1816
1225
  LINK,
1817
1226
  oddName,
1818
1227
  conversation,
1228
+ progressOf,
1819
1229
  tagging,
1230
+ sentIds,
1231
+ withWriteScope,
1232
+ stopWrites,
1233
+ currentOperation,
1234
+ guardedWrite,
1235
+ codeOf,
1236
+ parseDuration,
1237
+ DEFAULT_TEXT_MODEL,
1238
+ PREVIOUS_DEFAULT_TEXT_MODEL,
1239
+ CustomTextModelShape,
1240
+ textModelsFile,
1241
+ readTextModelsSection,
1242
+ writeTextModelsSection,
1243
+ textModels,
1244
+ textModel,
1245
+ chosenTextModel,
1246
+ RERANK_MODELS,
1247
+ DEFAULT_RERANK_MODEL,
1248
+ rerankModel,
1249
+ vectorModelKey,
1250
+ meaningFloor,
1251
+ HISTORY_MAX_DAYS,
1252
+ DEFAULT_HISTORY_LIMITS,
1253
+ historyWindow,
1254
+ limitBatch,
1820
1255
  IMAGE_MODELS,
1821
1256
  DEFAULT_IMAGE_MODEL,
1822
1257
  imageModel,