@wirecat/drive-cli 0.63.0 → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/README.md +2 -1
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bundle/{all-profiles-GZJS3UKC.js → all-profiles-PD7GJHFA.js} +14 -13
  4. package/dist/bundle/{anthropic-RGV3WXX5.js → anthropic-PJKFON5H.js} +25 -14
  5. package/dist/bundle/{app-server-AA2PJ7PV.js → app-server-6ELQA6FJ.js} +59 -56
  6. package/dist/bundle/{bun-OXZYIA3R.js → bun-P54TGES2.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-D45NSDM3.js → bun-sqlite-TND5ZRJH.js} +12 -8
  8. package/dist/bundle/chunk-2AFI4KGI.js +185 -0
  9. package/dist/bundle/{chunk-Q5DJTRKV.js → chunk-3HXNDF6Q.js} +2 -2
  10. package/dist/bundle/{chunk-DJHLVUL6.js → chunk-3ONWN3IA.js} +278 -49
  11. package/dist/bundle/{chunk-WYGWWHZP.js → chunk-42G2XNPN.js} +2 -2
  12. package/dist/bundle/chunk-4AOINPN2.js +66 -0
  13. package/dist/bundle/{chunk-J4DIHPZ6.js → chunk-4EDWLR22.js} +1 -1
  14. package/dist/bundle/{chunk-ABYGSJZ4.js → chunk-4Y5YBFMS.js} +7 -7
  15. package/dist/bundle/{chunk-YGU6ULU5.js → chunk-54V4H6PM.js} +16 -16
  16. package/dist/bundle/{chunk-2TFXK3R4.js → chunk-5XSBCMAF.js} +4 -4
  17. package/dist/bundle/{chunk-2HF2MRXI.js → chunk-6DCLZLGX.js} +1 -1
  18. package/dist/bundle/{chunk-OD4U7GUY.js → chunk-7AQGVX5O.js} +20 -20
  19. package/dist/bundle/{chunk-YIP7ELON.js → chunk-7TAP7Y2E.js} +727 -518
  20. package/dist/bundle/{chunk-TF23BZW5.js → chunk-A27UVLPK.js} +3 -3
  21. package/dist/bundle/{chunk-LZEOQW7S.js → chunk-A4QNADEX.js} +58 -52
  22. package/dist/bundle/{chunk-FXBHOCJK.js → chunk-ADLS6FVG.js} +1 -1
  23. package/dist/bundle/{chunk-LMAVCYLQ.js → chunk-B2LPCHQN.js} +4 -4
  24. package/dist/bundle/{chunk-5PPL7JDM.js → chunk-CGQRZRTH.js} +2 -2
  25. package/dist/bundle/{chunk-VAUMOZU5.js → chunk-CWLL63JD.js} +107 -48
  26. package/dist/bundle/{chunk-V3NVXIQR.js → chunk-D6Z43SOG.js} +1563 -266
  27. package/dist/bundle/{chunk-OXY6SSZG.js → chunk-D7WB54P7.js} +127 -28
  28. package/dist/bundle/{chunk-VJEOGKAN.js → chunk-DA63E2UM.js} +13 -9
  29. package/dist/bundle/{chunk-EOOGWUTP.js → chunk-ECEP4SO3.js} +20 -20
  30. package/dist/bundle/{chunk-NEFSGCVA.js → chunk-EHU6EYGO.js} +38 -28
  31. package/dist/bundle/{chunk-4OSSOWDM.js → chunk-ELJUBPY4.js} +1 -1
  32. package/dist/bundle/{chunk-FRIJUILO.js → chunk-EM7NL5ES.js} +3 -3
  33. package/dist/bundle/{chunk-3BZRKLJ6.js → chunk-EU5MD24W.js} +13 -13
  34. package/dist/bundle/{chunk-MOTRI3SY.js → chunk-EZ2OLYEK.js} +24 -2
  35. package/dist/bundle/{chunk-6MQSQ4LX.js → chunk-F56DRBGY.js} +370 -717
  36. package/dist/bundle/{chunk-ZOJU7ZFI.js → chunk-FA6JNXCC.js} +8 -8
  37. package/dist/bundle/{chunk-ND6LLYGF.js → chunk-FBHSWQU7.js} +1531 -136
  38. package/dist/bundle/{chunk-Z42YYLTS.js → chunk-GW3LBY3T.js} +74 -72
  39. package/dist/bundle/{chunk-Y6GNA7HE.js → chunk-HP3NT6JJ.js} +23 -5
  40. package/dist/bundle/{chunk-DJ3SDJZY.js → chunk-I272E6UR.js} +9 -8
  41. package/dist/bundle/{chunk-L37LMMRJ.js → chunk-IBO23OID.js} +2 -2
  42. package/dist/bundle/{chunk-CE2TJBLP.js → chunk-II4S2DBJ.js} +3 -3
  43. package/dist/bundle/{chunk-ZM5J6ZMB.js → chunk-IKHOIXJR.js} +2 -2
  44. package/dist/bundle/{chunk-PO5RQQIG.js → chunk-IMHW7VIV.js} +5 -5
  45. package/dist/bundle/{chunk-3HK5WMI5.js → chunk-JMJIH6JH.js} +6 -6
  46. package/dist/bundle/{chunk-FUITWY7O.js → chunk-JPPPLKAO.js} +26 -1
  47. package/dist/bundle/{chunk-4S4JMW6I.js → chunk-LMKPP2JP.js} +1 -1
  48. package/dist/bundle/{chunk-HZZCEQTH.js → chunk-M7ELUGU6.js} +4 -4
  49. package/dist/bundle/{chunk-ZMOUUOT2.js → chunk-MCPOZNWG.js} +1 -1
  50. package/dist/bundle/{chunk-XNVFKMVR.js → chunk-NI5PD5KM.js} +39485 -35729
  51. package/dist/bundle/{chunk-2TDUGC5D.js → chunk-NQ5XMSLA.js} +4927 -1978
  52. package/dist/bundle/chunk-NQRTKYJB.js +257 -0
  53. package/dist/bundle/{chunk-44SBK6KB.js → chunk-O6K2E7OA.js} +4201 -2565
  54. package/dist/bundle/{chunk-534OBX5Y.js → chunk-O7ZDCOZE.js} +1 -1
  55. package/dist/bundle/{chunk-7EMQ26BA.js → chunk-OFJXHEFT.js} +13 -13
  56. package/dist/bundle/chunk-OWMZUWCM.js +109 -0
  57. package/dist/bundle/chunk-PHOL2DZM.js +138 -0
  58. package/dist/bundle/{chunk-UQLWMGSD.js → chunk-PLP5527C.js} +5 -5
  59. package/dist/bundle/{chunk-3QINVLZI.js → chunk-RNHGQ35R.js} +1 -1
  60. package/dist/bundle/{chunk-27YUUGXQ.js → chunk-RX5CJ55S.js} +1 -1
  61. package/dist/bundle/{chunk-XIUDS3OK.js → chunk-SE352DBY.js} +1 -1
  62. package/dist/bundle/chunk-SEQWBZYH.js +18 -0
  63. package/dist/bundle/{chunk-33MGFUED.js → chunk-SIWXYB4E.js} +3789 -3538
  64. package/dist/bundle/{chunk-4CIZWCXV.js → chunk-SNLSEYJO.js} +1 -1
  65. package/dist/bundle/{chunk-XDC3TWTL.js → chunk-SS4LKLD7.js} +52 -605
  66. package/dist/bundle/{chunk-BKYMKVHT.js → chunk-TMHF4BCL.js} +2 -2
  67. package/dist/bundle/{chunk-FEZF3TII.js → chunk-TOVWMURV.js} +74 -6
  68. package/dist/bundle/{chunk-QCKZ3GAA.js → chunk-TTP4NOP3.js} +4 -4
  69. package/dist/bundle/chunk-UTNRBOEN.js +53 -0
  70. package/dist/bundle/{chunk-2NIC72HH.js → chunk-VDZY3L7U.js} +3 -1
  71. package/dist/bundle/chunk-VHQYWFWV.js +13 -0
  72. package/dist/bundle/{chunk-VKPCONDQ.js → chunk-VLXWAH5E.js} +4 -4
  73. package/dist/bundle/{chunk-6KQJSFYF.js → chunk-VMAMRFFC.js} +23 -23
  74. package/dist/bundle/{chunk-6EY46GAN.js → chunk-W2XY6C5S.js} +2 -2
  75. package/dist/bundle/{chunk-J24ZFCWM.js → chunk-WRAUO5EJ.js} +22 -24
  76. package/dist/bundle/{chunk-S4RXABDR.js → chunk-WRMJN6UQ.js} +3 -3
  77. package/dist/bundle/{chunk-UPOSDTPT.js → chunk-WVJHZIDH.js} +3 -3
  78. package/dist/bundle/{chunk-E4SDKMBJ.js → chunk-X7YGGWXI.js} +1 -59
  79. package/dist/bundle/{chunk-O2XOX4HB.js → chunk-XPWZSW6Y.js} +50 -34
  80. package/dist/bundle/{chunk-PDCCYHCH.js → chunk-XYE7XZPB.js} +5 -5
  81. package/dist/bundle/{chunk-RKELRWH7.js → chunk-Y5PKRITX.js} +5 -5
  82. package/dist/bundle/{chunk-XR6ESRU6.js → chunk-Z2ADO6UA.js} +2 -2
  83. package/dist/bundle/{chunk-YUWPNG7B.js → chunk-ZD4MB7NH.js} +1 -1
  84. package/dist/bundle/{chunk-TWUH22Z5.js → chunk-ZILALBYQ.js} +4 -4
  85. package/dist/bundle/{chunk-SXM6MHRR.js → chunk-ZR2EJPMQ.js} +44 -15
  86. package/dist/bundle/command-contract-25E4PYMD.js +40 -0
  87. package/dist/bundle/command-server-entry-36JXYIJB.js +170 -0
  88. package/dist/bundle/{decode-G5YEIPNC.js → decode-T5ZW57WZ.js} +8 -8
  89. package/dist/bundle/{dispatch-GEFIXA6X.js → dispatch-RMA2XFYA.js} +11 -11
  90. package/dist/bundle/drive.js +11 -11
  91. package/dist/bundle/{echarts-W2CWHNXR.js → echarts-KQ44LPSF.js} +2 -2
  92. package/dist/bundle/{embed-OBFFPVF4.js → embed-Q7XST53J.js} +9 -9
  93. package/dist/bundle/{embedder-NGCBQHIG.js → embedder-RWZSBVW2.js} +12 -12
  94. package/dist/bundle/entry-HPLW4QL2.js +25 -0
  95. package/dist/bundle/{failure-GV77W3CD.js → failure-7NP4QPIN.js} +4 -4
  96. package/dist/bundle/first-run-RL3RKYZW.js +30 -0
  97. package/dist/bundle/first-screen-NX3TM2VJ.js +38 -0
  98. package/dist/bundle/google-DPD5N6AQ.js +42 -0
  99. package/dist/bundle/{google-api-Z3NSTBBR.js → google-api-P5DRHD7L.js} +61 -56
  100. package/dist/bundle/grants-TX4MHLI4.js +109 -0
  101. package/dist/bundle/{identity-OM6GFZ7T.js → identity-VDV6CHRW.js} +6 -6
  102. package/dist/bundle/{instructions-YQBQSYSS.js → instructions-Q45FVY6H.js} +1 -1
  103. package/dist/bundle/{login-7RYSDVN3.js → login-XKN3NI6X.js} +67 -62
  104. package/dist/bundle/{mcp-GWDA3HOA.js → mcp-7KQUJNFN.js} +2 -2
  105. package/dist/bundle/{node-IVU33RL7.js → node-MSW565D3.js} +2 -2
  106. package/dist/bundle/{node-KM3CUABH.js → node-P4E63KXA.js} +9 -9
  107. package/dist/bundle/{node-sqlite-SIH5BEW2.js → node-sqlite-S74XVVHL.js} +13 -9
  108. package/dist/bundle/oauth-6R7AWAES.js +22 -0
  109. package/dist/bundle/{open-IAO2SNII.js → open-P7UQG7XJ.js} +8 -8
  110. package/dist/bundle/{openai-SGOUBHXP.js → openai-DDHJ57KZ.js} +19 -40
  111. package/dist/bundle/{process-BPBMV3AT.js → process-NMUB5SHK.js} +1 -1
  112. package/dist/bundle/{program-MYKKJ4F6.js → program-PJNWP6JW.js} +517 -330
  113. package/dist/bundle/prompt-VOSMK4C2.js +19 -0
  114. package/dist/bundle/{reasons-57J2D77K.js → reasons-KDAXOC5S.js} +5 -5
  115. package/dist/bundle/{recognize-A5C5RPB3.js → recognize-GZIY63HS.js} +7 -7
  116. package/dist/bundle/{remote-VWYFLRGO.js → remote-V3YGN7LN.js} +10 -10
  117. package/dist/bundle/{rerank-4NGQWREA.js → rerank-XRU6AVN7.js} +10 -10
  118. package/dist/bundle/{serve-Y6LQTFH5.js → serve-NDOAFA57.js} +12 -12
  119. package/dist/bundle/{server-6AUHIIUA.js → server-BKGWJYMC.js} +46 -44
  120. package/dist/bundle/server-QD2MUJJZ.js +72 -0
  121. package/dist/bundle/{services-2W4J7EMW.js → services-TYDMFQCA.js} +129 -39
  122. package/dist/bundle/{sqlite-runtime-P6BBDX2H.js → sqlite-runtime-UAFJKSJR.js} +9 -9
  123. package/dist/bundle/{start-AFFA3LKM.js → start-2ZLDP2OE.js} +30 -8
  124. package/dist/bundle/{state-PXKKXR3R.js → state-6SP27J2K.js} +9 -9
  125. package/dist/bundle/{store-CN6JEUC4.js → store-4UUY545Q.js} +42 -18
  126. package/dist/bundle/{store-IVV2BAGZ.js → store-EJN27MXI.js} +69 -28
  127. package/dist/bundle/store-maintenance-command-LETURZDC.js +60 -0
  128. package/dist/bundle/tokens-MTFJPTYT.js +107 -0
  129. package/dist/commands/account.d.ts +4 -0
  130. package/dist/commands/account.d.ts.map +1 -0
  131. package/dist/commands/account.js +33 -0
  132. package/dist/commands/account.js.map +1 -0
  133. package/dist/commands/config.d.ts.map +1 -1
  134. package/dist/commands/config.js +6 -5
  135. package/dist/commands/config.js.map +1 -1
  136. package/dist/commands/context.d.ts +4 -2
  137. package/dist/commands/context.d.ts.map +1 -1
  138. package/dist/commands/context.js.map +1 -1
  139. package/dist/commands/documents.d.ts +2 -0
  140. package/dist/commands/documents.d.ts.map +1 -1
  141. package/dist/commands/documents.js +39 -3
  142. package/dist/commands/documents.js.map +1 -1
  143. package/dist/config.d.ts +13 -0
  144. package/dist/config.d.ts.map +1 -1
  145. package/dist/config.js +32 -2
  146. package/dist/config.js.map +1 -1
  147. package/dist/documents-add.d.ts +49 -0
  148. package/dist/documents-add.d.ts.map +1 -0
  149. package/dist/documents-add.js +122 -0
  150. package/dist/documents-add.js.map +1 -0
  151. package/dist/errors.d.ts +1 -0
  152. package/dist/errors.d.ts.map +1 -1
  153. package/dist/errors.js +9 -1
  154. package/dist/errors.js.map +1 -1
  155. package/dist/knowledge.d.ts +1 -1
  156. package/dist/knowledge.d.ts.map +1 -1
  157. package/dist/knowledge.js +15 -17
  158. package/dist/knowledge.js.map +1 -1
  159. package/dist/model.d.ts +3 -0
  160. package/dist/model.d.ts.map +1 -1
  161. package/dist/model.js.map +1 -1
  162. package/dist/profile-lock.d.ts +1 -0
  163. package/dist/profile-lock.d.ts.map +1 -1
  164. package/dist/profile-lock.js +1 -0
  165. package/dist/profile-lock.js.map +1 -1
  166. package/dist/program.d.ts.map +1 -1
  167. package/dist/program.js +24 -15
  168. package/dist/program.js.map +1 -1
  169. package/dist/reasons.d.ts.map +1 -1
  170. package/dist/reasons.js +25 -0
  171. package/dist/reasons.js.map +1 -1
  172. package/dist/store.d.ts.map +1 -1
  173. package/dist/store.js +20 -0
  174. package/dist/store.js.map +1 -1
  175. package/dist/version.d.ts +1 -1
  176. package/dist/version.js +1 -1
  177. package/package.json +4 -4
  178. package/dist/bundle/chunk-AEX37ETW.js +0 -35
  179. package/dist/bundle/chunk-OTROVC4E.js +0 -62
  180. package/dist/bundle/chunk-Z5KC7XBR.js +0 -33
  181. package/dist/bundle/command-contract-BRW3AP44.js +0 -38
  182. package/dist/bundle/entry-ET6HGM7A.js +0 -22
  183. package/dist/bundle/first-run-JG52UZVO.js +0 -30
  184. package/dist/bundle/first-screen-CIL3GFAA.js +0 -36
  185. package/dist/bundle/google-CIWUVJ5C.js +0 -36
  186. package/dist/bundle/grants-3S4RL3WB.js +0 -104
  187. package/dist/bundle/oauth-PT4JEHLL.js +0 -22
  188. package/dist/bundle/prompt-3ZM64DCB.js +0 -17
  189. package/dist/bundle/server-PFHI35HA.js +0 -69
  190. package/dist/bundle/store-maintenance-command-MSY2QNEH.js +0 -59
  191. package/dist/bundle/tokens-P4LPNUFW.js +0 -102
  192. package/dist/bundle/{chunk-ZQ3GWKDQ.js → chunk-YVNHQFLC.js} +0 -0
  193. package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-CE73EWJ2.js} +3 -3
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  filesPresent,
5
5
  sharedModelsDirectory
6
- } from "./chunk-LMAVCYLQ.js";
6
+ } from "./chunk-B2LPCHQN.js";
7
7
  import {
8
8
  PRIORITY_LABELS,
9
9
  TAG_TYPES,
@@ -14,530 +14,48 @@ import {
14
14
  id,
15
15
  text,
16
16
  time
17
- } from "./chunk-V3NVXIQR.js";
17
+ } from "./chunk-D6Z43SOG.js";
18
18
  import {
19
- createRecordLog,
20
- resolvePaths,
21
- writeSecurely
22
- } from "./chunk-OD4U7GUY.js";
19
+ readSharedSection,
20
+ sharedConfigPath,
21
+ writeSharedSection
22
+ } from "./chunk-4Y5YBFMS.js";
23
23
  import {
24
- traceIdOf
25
- } from "./chunk-6EY46GAN.js";
24
+ storePath
25
+ } from "./chunk-UTNRBOEN.js";
26
26
  import {
27
27
  array,
28
28
  boolean,
29
+ check,
30
+ getDotPath,
31
+ integer,
32
+ maxLength,
33
+ maxValue,
34
+ minLength,
35
+ minValue,
29
36
  nullable,
30
37
  number,
31
38
  optional,
32
39
  picklist,
40
+ pipe,
33
41
  reference,
34
- strictObject
35
- } from "./chunk-FEZF3TII.js";
42
+ regex,
43
+ safeParse,
44
+ startsWith,
45
+ strictObject,
46
+ string,
47
+ trim,
48
+ url
49
+ } from "./chunk-TOVWMURV.js";
36
50
  import {
37
51
  CliError,
38
52
  isCliError
39
- } from "./chunk-4OSSOWDM.js";
53
+ } from "./chunk-ELJUBPY4.js";
40
54
  import {
41
55
  __name
42
56
  } from "./chunk-ZVVMGPBJ.js";
43
57
 
44
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/runs/scope.js
45
- import { AsyncLocalStorage } from "node:async_hooks";
46
- import { randomBytes } from "node:crypto";
47
-
48
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/runs/run.js
49
- import { randomUUID } from "node:crypto";
50
- import { appendFileSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
51
- import { userInfo } from "node:os";
52
- import { join, sep } from "node:path";
53
-
54
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/runs/log-keys.js
55
- var snake = /* @__PURE__ */ __name((key) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`), "snake");
56
- var camel = /* @__PURE__ */ __name((key) => key.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase()), "camel");
57
- var renamed = /* @__PURE__ */ __name((record, name) => Object.fromEntries(Object.entries(record).map(([key, value]) => [name(key), value])), "renamed");
58
- var logAttributes = /* @__PURE__ */ __name((event) => renamed(event, snake), "logAttributes");
59
- var fromLogAttributes = /* @__PURE__ */ __name((attributes) => renamed(attributes, camel), "fromLogAttributes");
60
- var snakeLogger = /* @__PURE__ */ __name((logger) => ({
61
- debug: /* @__PURE__ */ __name((event, message) => logger.debug(logAttributes(event), message), "debug"),
62
- info: /* @__PURE__ */ __name((event, message) => logger.info(logAttributes(event), message), "info"),
63
- warn: /* @__PURE__ */ __name((event, message) => logger.warn(logAttributes(event), message), "warn"),
64
- error: /* @__PURE__ */ __name((event, message) => logger.error(logAttributes(event), message), "error")
65
- }), "snakeLogger");
66
-
67
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/runs/log-attributes.js
68
- var diagnostic = {
69
- event: true,
70
- operation: true,
71
- opcode: true,
72
- seq: true,
73
- status: true,
74
- method: true,
75
- endpointTemplate: true,
76
- bytes: true,
77
- ids: true,
78
- counts: true,
79
- durationMs: true,
80
- outcome: true,
81
- errorCode: true,
82
- providerError: true,
83
- level: true,
84
- transport: true,
85
- attempt: true,
86
- waitMs: true,
87
- code: true,
88
- detail: true,
89
- reason: true,
90
- ageMs: true
91
- };
92
- var send = {
93
- profile: true,
94
- chatId: true,
95
- outcome: true,
96
- kind: true,
97
- action: true,
98
- people: true,
99
- messageId: true,
100
- key: true,
101
- count: true,
102
- forEveryone: true,
103
- sendId: true,
104
- operationId: true,
105
- parentOperationId: true,
106
- replyTo: true,
107
- threadId: true,
108
- sendAs: true,
109
- resultChatId: true,
110
- length: true,
111
- attachments: true,
112
- scheduledFor: true,
113
- notify: true,
114
- origin: true,
115
- reservation: true,
116
- errorCode: true
117
- };
118
- var background = [
119
- "job",
120
- "pid",
121
- "schedule",
122
- "exitCode",
123
- "tool",
124
- "tier",
125
- "actorType",
126
- "actorId",
127
- "agent",
128
- "targetType",
129
- "targetId"
130
- ];
131
- var crash = ["errorClass", "frames"];
132
- var dropped = ["dropped"];
133
- var LOG_ATTRIBUTES = [
134
- ...new Set([...Object.keys(diagnostic), ...Object.keys(send), ...background, ...crash, ...dropped].map((key) => Object.keys(logAttributes({ [key]: true }))[0]))
135
- ].sort();
136
-
137
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/runs/run.js
138
- var KEEP_RUNS_FOR_DAYS = 30;
139
- var KEEP_SUCCESSFUL_RUNS_FOR_DAYS = 7;
140
- var RUNS_SIZE_LIMIT_MB = 200;
141
- var runsDirFor = /* @__PURE__ */ __name((app, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "runs"), "runsDirFor");
142
- var startRun = /* @__PURE__ */ __name((options) => {
143
- const now = options.now ?? (() => /* @__PURE__ */ new Date());
144
- const startedAt = options.startedAt ?? now();
145
- const id2 = options.runId ?? newRunId(startedAt, options.command);
146
- const dir = join(options.runsDir, day(startedAt), id2);
147
- pruneRuns(options.runsDir, {
148
- keepDays: options.keepDays ?? KEEP_RUNS_FOR_DAYS,
149
- keepSuccessDays: options.keepSuccessDays ?? KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
150
- maxBytes: options.maxBytes ?? RUNS_SIZE_LIMIT_MB * 1024 * 1024,
151
- now: startedAt
152
- });
153
- refuseRealStateInTests(dir);
154
- const metadata = {
155
- runId: id2,
156
- command: options.command,
157
- ...options.profile === void 0 ? {} : { profile: options.profile },
158
- startedAt: startedAt.toISOString(),
159
- status: "running",
160
- cliVersion: options.cliVersion,
161
- runtime: runtime(),
162
- platform: process.platform,
163
- arch: process.arch,
164
- ...options.traceId === void 0 ? {} : { traceId: options.traceId },
165
- ...options.context
166
- };
167
- let file;
168
- const opened = /* @__PURE__ */ __name(() => {
169
- if (file)
170
- return file;
171
- mkdirSync(dir, { recursive: true, mode: 448 });
172
- const events = join(dir, "events.jsonl");
173
- writeFileSync(events, "", { flag: "a", mode: 384 });
174
- file = snakeLogger(createRecordLog({
175
- to: events,
176
- runId: id2,
177
- command: options.command,
178
- resource: { service: options.service, version: options.cliVersion },
179
- allow: LOG_ATTRIBUTES,
180
- ...options.traceId === void 0 ? {} : { traceId: options.traceId },
181
- ...options.onError === void 0 ? {} : { onError: options.onError }
182
- }));
183
- writeRunFile(dir, metadata);
184
- return file;
185
- }, "opened");
186
- if (!options.lazy)
187
- opened();
188
- let finished = false;
189
- const operations = /* @__PURE__ */ new Set();
190
- const codes = /* @__PURE__ */ new Set();
191
- const noted = /* @__PURE__ */ __name((level) => (event, message) => {
192
- const { operation, errorCode, error_code, code } = event;
193
- if (typeof operation === "string")
194
- operations.add(operation);
195
- for (const value of [errorCode, error_code, code])
196
- if (typeof value === "string")
197
- codes.add(value);
198
- if (finished)
199
- return;
200
- opened()[level](event, message);
201
- }, "noted");
202
- const logger = { debug: noted("debug"), info: noted("info"), warn: noted("warn"), error: noted("error") };
203
- return {
204
- id: id2,
205
- dir,
206
- logger,
207
- finish: /* @__PURE__ */ __name(async (status, extra = {}) => {
208
- if (finished)
209
- return;
210
- finished = true;
211
- const completedAt = now();
212
- const final = {
213
- ...metadata,
214
- ...extra,
215
- status,
216
- completedAt: completedAt.toISOString(),
217
- durationMs: completedAt.getTime() - startedAt.getTime(),
218
- operations: [...operations].sort(),
219
- codes: [...codes].sort()
220
- };
221
- if (file || status !== "success") {
222
- opened();
223
- writeRunFile(dir, final);
224
- return;
225
- }
226
- try {
227
- mkdirSync(join(dir, ".."), { recursive: true, mode: 448 });
228
- appendIndex(join(dir, ".."), runFileOf(final));
229
- } catch (error) {
230
- options.onError?.(error);
231
- }
232
- }, "finish")
233
- };
234
- }, "startRun");
235
- var refuseRealStateInTests = /* @__PURE__ */ __name((dir, env = process.env) => {
236
- if (env.VITEST === void 0)
237
- return;
238
- let home;
239
- try {
240
- home = userInfo().homedir;
241
- } catch {
242
- return;
243
- }
244
- if (dir.startsWith(join(home, ".local", "share") + sep))
245
- throw new Error(`a test opened a run in the real data folder: ${dir}`);
246
- }, "refuseRealStateInTests");
247
- var runtime = /* @__PURE__ */ __name(() => {
248
- const bun = process.versions.bun;
249
- return bun ? `bun ${bun}` : `node ${process.versions.node}`;
250
- }, "runtime");
251
- var newRunId = /* @__PURE__ */ __name((startedAt, command) => {
252
- const stamp = startedAt.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
253
- const slug = command.replace(/[^a-z0-9]+/gi, "-").toLowerCase();
254
- return `${stamp}-${slug}-${randomUUID().slice(0, 6)}`;
255
- }, "newRunId");
256
- var INDEX = "index.jsonl";
257
- var appendIndex = /* @__PURE__ */ __name((dayDir, written) => {
258
- appendFileSync(join(dayDir, INDEX), `${JSON.stringify(written)}
259
- `, { mode: 384 });
260
- }, "appendIndex");
261
- var writeRunFile = /* @__PURE__ */ __name((dir, metadata) => {
262
- const written = runFileOf(metadata);
263
- writeSecurely(join(dir, "run.json"), `${JSON.stringify(written, null, 2)}
264
- `, 384);
265
- try {
266
- appendIndex(join(dir, ".."), written);
267
- } catch {
268
- }
269
- }, "writeRunFile");
270
- 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");
271
- var listRuns = /* @__PURE__ */ __name((runsDir, { since, atLeast = Number.POSITIVE_INFINITY, filter = {} } = {}) => {
272
- const first = since === void 0 ? void 0 : day(new Date(since));
273
- const runs = [];
274
- for (const date of days(runsDir).sort().reverse()) {
275
- if (first !== void 0 && date < first || runs.length >= atLeast)
276
- break;
277
- for (const metadata of runsOfDay(join(runsDir, date))) {
278
- if (matchesListFilter(metadata, filter))
279
- runs.push(metadata);
280
- }
281
- }
282
- return runs;
283
- }, "listRuns");
284
- var indexedRuns = /* @__PURE__ */ __name((dayDir) => {
285
- const latest = /* @__PURE__ */ new Map();
286
- let raw = "";
287
- try {
288
- raw = readFileSync(join(dayDir, INDEX), "utf8");
289
- } catch {
290
- }
291
- for (const line of raw.split("\n")) {
292
- if (line.trim() === "")
293
- continue;
294
- try {
295
- const metadata = metadataOf(JSON.parse(line));
296
- if (typeof metadata.runId === "string")
297
- latest.set(metadata.runId, metadata);
298
- } catch {
299
- }
300
- }
301
- return latest;
302
- }, "indexedRuns");
303
- var runsOfDay = /* @__PURE__ */ __name((dayDir) => {
304
- const latest = indexedRuns(dayDir);
305
- for (const entry of safeReaddir(dayDir)) {
306
- if (entry === INDEX || entry.startsWith(".") || latest.has(entry))
307
- continue;
308
- const metadata = readRun(join(dayDir, entry));
309
- if (metadata)
310
- latest.set(metadata.runId, metadata);
311
- }
312
- return [...latest.values()].sort((a, b) => a.runId < b.runId ? 1 : a.runId > b.runId ? -1 : 0);
313
- }, "runsOfDay");
314
- var findRun = /* @__PURE__ */ __name((runsDir, id2) => {
315
- const stamped = /^(\d{4})(\d{2})(\d{2})T/.exec(id2);
316
- const likely = stamped ? [`${stamped[1]}-${stamped[2]}-${stamped[3]}`] : [];
317
- const dates = [.../* @__PURE__ */ new Set([...likely, ...days(runsDir)])];
318
- for (const date of dates) {
319
- const dir = join(runsDir, date, id2);
320
- const metadata = readRun(dir);
321
- if (metadata)
322
- return { dir, metadata };
323
- }
324
- for (const date of dates) {
325
- const metadata = indexedRuns(join(runsDir, date)).get(id2);
326
- if (metadata)
327
- return { dir: join(runsDir, date, id2), metadata };
328
- }
329
- return void 0;
330
- }, "findRun");
331
- var readEvents = /* @__PURE__ */ __name((dir) => {
332
- let raw;
333
- try {
334
- raw = readFileSync(join(dir, "events.jsonl"), "utf8");
335
- } catch {
336
- return [];
337
- }
338
- const events = [];
339
- for (const line of raw.split("\n")) {
340
- if (line.trim() === "")
341
- continue;
342
- try {
343
- const parsed = JSON.parse(line);
344
- if (parsed !== null && typeof parsed === "object")
345
- events.push(eventOf(parsed));
346
- } catch {
347
- }
348
- }
349
- return events;
350
- }, "readEvents");
351
- var eventOf = /* @__PURE__ */ __name((line) => {
352
- const { attributes, time: time2, severity } = line;
353
- if (attributes === null || typeof attributes !== "object")
354
- return logAttributes(line);
355
- return { time: time2, severity, ...logAttributes(attributes) };
356
- }, "eventOf");
357
- var pruneRuns = /* @__PURE__ */ __name((runsDir, { keepDays, keepSuccessDays = keepDays, maxBytes, now }) => {
358
- const cutoff = day(new Date(now.getTime() - keepDays * DAY_MS));
359
- const successCutoff = day(new Date(now.getTime() - Math.min(keepSuccessDays, keepDays) * DAY_MS));
360
- let removed = 0;
361
- for (const date of days(runsDir)) {
362
- if (date >= cutoff) {
363
- if (date < successCutoff)
364
- dropSuccesses(join(runsDir, date));
365
- continue;
366
- }
367
- try {
368
- rmSync(join(runsDir, date), { recursive: true, force: true });
369
- removed += 1;
370
- } catch {
371
- }
372
- }
373
- if (maxBytes !== void 0)
374
- removed += fitSize(runsDir, maxBytes, now);
375
- return removed;
376
- }, "pruneRuns");
377
- var DAY_MS = 24 * 60 * 60 * 1e3;
378
- var SUCCESSES_DROPPED = ".successes-dropped";
379
- var SIZE_CHECKED = ".size-checked";
380
- var dropSuccesses = /* @__PURE__ */ __name((dayDir) => {
381
- const marker = join(dayDir, SUCCESSES_DROPPED);
382
- try {
383
- statSync(marker);
384
- return;
385
- } catch {
386
- }
387
- try {
388
- const kept = [];
389
- for (const [id2, metadata] of indexedRuns(dayDir)) {
390
- if (metadata.status === "success")
391
- rmSync(join(dayDir, id2), { recursive: true, force: true });
392
- else
393
- kept.push(JSON.stringify(runFileOf(metadata)));
394
- }
395
- for (const entry of safeReaddir(dayDir)) {
396
- if (entry === INDEX || entry.startsWith("."))
397
- continue;
398
- if (readRun(join(dayDir, entry))?.status === "success")
399
- rmSync(join(dayDir, entry), { recursive: true, force: true });
400
- }
401
- writeSecurely(join(dayDir, INDEX), kept.map((line) => `${line}
402
- `).join(""), 384);
403
- writeFileSync(marker, "", { mode: 384 });
404
- } catch {
405
- }
406
- }, "dropSuccesses");
407
- var sizeOf = /* @__PURE__ */ __name((path) => {
408
- let total = 0;
409
- for (const entry of safeReaddir(path)) {
410
- const full = join(path, entry);
411
- try {
412
- const stat = statSync(full);
413
- total += stat.isDirectory() ? sizeOf(full) : stat.size;
414
- } catch {
415
- }
416
- }
417
- return total;
418
- }, "sizeOf");
419
- var fitSize = /* @__PURE__ */ __name((runsDir, maxBytes, now) => {
420
- const stamp = join(runsDir, SIZE_CHECKED);
421
- const today = day(now);
422
- try {
423
- if (readFileSync(stamp, "utf8").trim() === today)
424
- return 0;
425
- } catch {
426
- }
427
- const dates = days(runsDir).sort();
428
- const sizes = new Map(dates.map((date) => [date, sizeOf(join(runsDir, date))]));
429
- let total = [...sizes.values()].reduce((sum, size) => sum + size, 0);
430
- let removed = 0;
431
- for (const date of dates) {
432
- if (total <= maxBytes || date === today)
433
- break;
434
- dropSuccesses(join(runsDir, date));
435
- const after = sizeOf(join(runsDir, date));
436
- total -= (sizes.get(date) ?? 0) - after;
437
- sizes.set(date, after);
438
- }
439
- for (const date of dates) {
440
- if (total <= maxBytes || date === today)
441
- break;
442
- try {
443
- rmSync(join(runsDir, date), { recursive: true, force: true });
444
- total -= sizes.get(date) ?? 0;
445
- removed += 1;
446
- } catch {
447
- }
448
- }
449
- try {
450
- mkdirSync(runsDir, { recursive: true, mode: 448 });
451
- writeFileSync(stamp, today, { mode: 384 });
452
- } catch {
453
- }
454
- return removed;
455
- }, "fitSize");
456
- var day = /* @__PURE__ */ __name((date) => date.toISOString().slice(0, 10), "day");
457
- var days = /* @__PURE__ */ __name((runsDir) => safeReaddir(runsDir).filter((entry) => /^\d{4}-\d{2}-\d{2}$/.test(entry)), "days");
458
- var readRun = /* @__PURE__ */ __name((dir) => {
459
- try {
460
- return metadataOf(JSON.parse(readFileSync(join(dir, "run.json"), "utf8")));
461
- } catch {
462
- return void 0;
463
- }
464
- }, "readRun");
465
- var safeReaddir = /* @__PURE__ */ __name((dir) => {
466
- try {
467
- return readdirSync(dir);
468
- } catch {
469
- return [];
470
- }
471
- }, "safeReaddir");
472
- var runFileOf = /* @__PURE__ */ __name(({ partial, ...metadata }) => ({
473
- ...logAttributes(metadata),
474
- ...partial ? { partial: { ...logAttributes(partial), failures: partial.failures.map((failure) => logAttributes(failure)) } } : {}
475
- }), "runFileOf");
476
- var metadataOf = /* @__PURE__ */ __name((parsed) => {
477
- const { partial, ...metadata } = fromLogAttributes(parsed);
478
- if (partial === null || typeof partial !== "object")
479
- return metadata;
480
- const { failures, ...rest } = fromLogAttributes(partial);
481
- return {
482
- ...metadata,
483
- partial: {
484
- ...rest,
485
- failures: Array.isArray(failures) ? failures.map((failure) => fromLogAttributes(failure)) : []
486
- }
487
- };
488
- }, "metadataOf");
489
-
490
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/runs/scope.js
491
- var scopes = new AsyncLocalStorage();
492
- var processScope;
493
- var currentRun = /* @__PURE__ */ __name(() => {
494
- const scope = scopes.getStore();
495
- if (scope)
496
- return scope;
497
- processScope ??= {
498
- runId: newRunId(/* @__PURE__ */ new Date(), "process"),
499
- command: "",
500
- startedAt: Date.now(),
501
- ...traceOf(process.env)
502
- };
503
- return processScope;
504
- }, "currentRun");
505
- var inRun = /* @__PURE__ */ __name((scope, body) => scopes.run(scope, body), "inRun");
506
- var runEvent = /* @__PURE__ */ __name((event) => scopes.getStore()?.events?.(event), "runEvent");
507
- var typedCommand = /* @__PURE__ */ __name((tool, words, profile = currentRun().profile) => [tool, profile, words].filter((part) => part !== void 0 && part !== "").join(" "), "typedCommand");
508
- var useAsProcessRun = /* @__PURE__ */ __name((scope) => {
509
- processScope = scope;
510
- }, "useAsProcessRun");
511
- var processRun = /* @__PURE__ */ __name(() => processScope, "processRun");
512
- var enclosingTraceId = /* @__PURE__ */ __name(() => scopes.getStore()?.traceId, "enclosingTraceId");
513
- var traceOf = /* @__PURE__ */ __name((env) => {
514
- const traceId = traceIdOf(env.TRACEPARENT);
515
- return traceId === void 0 ? {} : { traceId };
516
- }, "traceOf");
517
- var childTrace = /* @__PURE__ */ __name(() => {
518
- const hex = /* @__PURE__ */ __name((bytes) => randomBytes(bytes).toString("hex"), "hex");
519
- const traceId = hex(16);
520
- return { traceId, traceparent: `00-${traceId}-${hex(8)}-01` };
521
- }, "childTrace");
522
- var attempts = new AsyncLocalStorage();
523
- var withAttempt = /* @__PURE__ */ __name((attempt, work) => attempts.run(attempt, work), "withAttempt");
524
- var currentAttempt = /* @__PURE__ */ __name(() => attempts.getStore(), "currentAttempt");
525
-
526
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/domain/duration.js
527
- var DURATION = /^(\d+)(ms|s|m|h|d)$/;
528
- var UNIT_MS = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
529
- var parseDuration = /* @__PURE__ */ __name((value, source) => {
530
- const match = DURATION.exec(value.trim());
531
- if (!match?.[1] || !match[2]) {
532
- throw new CliError("validation_error", `${source} takes a duration with a unit \u2014 500ms, 30s, 2m, 4h or 1d \u2014 not "${value}"`);
533
- }
534
- const ms = Number(match[1]) * (UNIT_MS[match[2]] ?? 0);
535
- if (ms <= 0)
536
- throw new CliError("validation_error", `${source} has to be more than zero, and "${value}" is not`);
537
- return ms;
538
- }, "parseDuration");
539
-
540
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/permissions.js
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
541
59
  var LEVELS = ["deny", "readonly", "ask", "allow"];
542
60
  var DANGEROUS = /* @__PURE__ */ new Set(["messages.delete", "bot.messages.delete", "topics.delete", "chats.delete", "chats.clear"]);
543
61
  var skipFlagFor = /* @__PURE__ */ __name((key) => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes", "skipFlagFor");
@@ -559,6 +77,7 @@ var DEFAULT_PERMISSIONS = {
559
77
  "store.migrate": "ask",
560
78
  "store.repair": "ask",
561
79
  "store.reset": "ask",
80
+ "store.import": "ask",
562
81
  "store.clear": "ask",
563
82
  "store.decrypt": "ask",
564
83
  "store.copies.delete": "ask",
@@ -566,6 +85,10 @@ var DEFAULT_PERMISSIONS = {
566
85
  "server.stop": "ask",
567
86
  "server.restart": "ask",
568
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",
569
92
  "images.models.download": "ask",
570
93
  "schedule.run": "ask",
571
94
  "schedule.exec": "ask",
@@ -933,120 +456,32 @@ var assertRetentionEvidenceRead = /* @__PURE__ */ __name((permissions) => {
933
456
  }
934
457
  }, "assertRetentionEvidenceRead");
935
458
 
936
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/sends/guarded.js
937
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
938
- var sentIds = /* @__PURE__ */ __name((typed, message) => ({
939
- messageId: message.id,
940
- ...message.chatId && message.chatId !== typed ? { resultChatId: message.chatId } : {}
941
- }), "sentIds");
942
- var current = new AsyncLocalStorage2();
943
- var writesInFlight = new AsyncLocalStorage2();
944
- var parents = /* @__PURE__ */ new WeakMap();
945
- var stopped = /* @__PURE__ */ new WeakMap();
946
- var scopesFor = /* @__PURE__ */ __name((scope = writesInFlight.getStore()) => {
947
- const result = [];
948
- for (let at = scope; at; at = parents.get(at))
949
- result.push(at);
950
- return result;
951
- }, "scopesFor");
952
- var withWriteScope = /* @__PURE__ */ __name((scope, body) => {
953
- const parent = writesInFlight.getStore();
954
- if (parent && parent !== scope)
955
- parents.set(scope, parent);
956
- return writesInFlight.run(scope, body);
957
- }, "withWriteScope");
958
- var stopWrites = /* @__PURE__ */ __name((scope, reason) => {
959
- stopped.set(scope, reason);
960
- for (const write of scope)
961
- write.cut();
962
- }, "stopWrites");
963
- var refuseStopped = /* @__PURE__ */ __name((scopes2) => {
964
- for (const scope of scopes2)
965
- if (stopped.has(scope))
966
- throw stopped.get(scope);
967
- }, "refuseStopped");
968
- var currentOperation = /* @__PURE__ */ __name(() => current.getStore(), "currentOperation");
969
- var guardedWrite = /* @__PURE__ */ __name(async (guard, attempt, act, settled = () => ({}), prepare) => {
970
- const scopes2 = scopesFor();
971
- refuseStopped(scopes2);
972
- try {
973
- await guard.ask?.(attempt);
974
- refuseStopped(scopes2);
975
- if (guard.reserve) {
976
- guard.check(attempt, { reserve: false });
977
- await guard.reserve(attempt);
978
- } else
979
- guard.check(attempt);
980
- } catch (error) {
981
- guard.record({ ...attempt, outcome: "refused", errorCode: codeOf(error) });
982
- throw error;
983
- }
984
- try {
985
- refuseStopped(scopes2);
986
- } catch (error) {
987
- guard.record({ ...attempt, outcome: "failed", errorCode: codeOf(error) });
988
- throw error;
989
- }
990
- let recorded = false;
991
- const once = /* @__PURE__ */ __name((entry) => {
992
- if (recorded)
993
- return;
994
- recorded = true;
995
- guard.record(entry);
996
- }, "once");
997
- let cancelled = false;
998
- const flight = {
999
- operationId: attempt.operationId,
1000
- preparing: prepare !== void 0,
1001
- cut: /* @__PURE__ */ __name(() => {
1002
- cancelled = true;
1003
- once({
1004
- ...attempt,
1005
- outcome: flight.preparing ? "failed" : "outcome_unknown",
1006
- errorCode: flight.preparing ? "timeout" : "outcome_unknown"
1007
- });
1008
- }, "cut")
1009
- };
1010
- for (const scope of scopes2)
1011
- scope.add(flight);
1012
- try {
1013
- if (prepare !== void 0)
1014
- await prepare();
1015
- if (cancelled)
1016
- throw new CliError("timeout", "the command ended before sending; nothing was sent", { sent: false });
1017
- flight.preparing = false;
1018
- const done = await current.run(attempt.operationId, act);
1019
- if (cancelled)
1020
- throw new CliError("outcome_unknown", "the command ended with a write in flight; check its result before continuing", { operation_id: attempt.operationId });
1021
- once({ ...attempt, ...settled(done), outcome: "sent" });
1022
- return done;
1023
- } catch (error) {
1024
- const code = codeOf(error);
1025
- once({ ...attempt, outcome: code === "outcome_unknown" ? "outcome_unknown" : "failed", errorCode: code });
1026
- if (code === "outcome_unknown" && error instanceof Error)
1027
- throw new CliError("outcome_unknown", error.message, {
1028
- ...error.details,
1029
- operation_id: attempt.operationId,
1030
- retryable: false
1031
- });
1032
- if (flight.preparing && isCliError(error) && error.details.sent === void 0)
1033
- throw new CliError(error.code, error.message, { ...error.details, sent: false });
1034
- throw error;
1035
- } finally {
1036
- for (const scope of scopes2)
1037
- scope.delete(flight);
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}"`);
1038
466
  }
1039
- }, "guardedWrite");
1040
- var codeOf = /* @__PURE__ */ __name((error) => typeof error?.code === "string" ? error.code : "unknown", "codeOf");
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");
1041
472
 
1042
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/embeddings/models.js
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";
1043
476
  var huggingFace = /* @__PURE__ */ __name((repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`, "huggingFace");
1044
477
  var e5 = huggingFace("Xenova/multilingual-e5-small", "761b726dd34fb83930e26aab4e9ac3899aa1fa78");
478
+ var e5Large = huggingFace("Xenova/multilingual-e5-large", "00fc3aeb3dbb95842de2ac1961d33c6319acf57b");
1045
479
  var gemma = huggingFace("onnx-community/embeddinggemma-300m-ONNX", "5090578d9565bb06545b4552f76e6bc2c93e4a66");
1046
480
  var TEXT_MODELS = [
1047
481
  {
1048
482
  id: "e5-small",
1049
483
  title: "multilingual-e5-small, 8-bit",
484
+ size: "small",
1050
485
  languages: "about 100 languages, Russian and English among them",
1051
486
  licence: "MIT",
1052
487
  dims: 384,
@@ -1080,12 +515,17 @@ var TEXT_MODELS = [
1080
515
  {
1081
516
  id: "embeddinggemma",
1082
517
  title: "EmbeddingGemma 300M, 4-bit",
518
+ size: "medium",
1083
519
  languages: "over 100 languages \u2014 the best of the two on chat, about seven times slower",
1084
520
  licence: "Gemma Terms of Use",
1085
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",
1086
524
  dims: 768,
1087
525
  maxTokens: 2048,
1088
- 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,
1089
529
  pooling: "sentence_embedding",
1090
530
  prefix: { query: "task: search result | query: ", passage: "title: none | text: " },
1091
531
  onnx: "onnx/model_q4.onnx",
@@ -1116,16 +556,122 @@ var TEXT_MODELS = [
1116
556
  bytes: 1156830
1117
557
  }
1118
558
  ]
559
+ },
560
+ {
561
+ id: "e5-large",
562
+ title: "multilingual-e5-large, 8-bit",
563
+ size: "large",
564
+ languages: "about 100 languages, Russian and English among them \u2014 reads better than e5-small, several times slower",
565
+ licence: "MIT",
566
+ dims: 1024,
567
+ maxTokens: 512,
568
+ // 2026-11-07, one 8-thread session on the Ryzen AI 9 HX 470 while other benchmarks ran: 3.4 chunks/s.
569
+ chunksPerSecond: 4,
570
+ pooling: "mean",
571
+ prefix: { query: "query: ", passage: "passage: " },
572
+ onnx: "onnx/model_quantized.onnx",
573
+ files: [
574
+ {
575
+ name: "onnx/model_quantized.onnx",
576
+ url: e5Large("onnx/model_quantized.onnx"),
577
+ sha256: "0a8d65db9a36f810ba5da15249f13145fcdc7890e6656f1fd38cd8b7c4db1fca",
578
+ bytes: 561768762
579
+ },
580
+ {
581
+ name: "tokenizer.json",
582
+ url: e5Large("tokenizer.json"),
583
+ sha256: "62c24cdc13d4c9952d63718d6c9fa4c287974249e16b7ade6d5a85e7bbb75626",
584
+ bytes: 17082660
585
+ },
586
+ {
587
+ name: "tokenizer_config.json",
588
+ url: e5Large("tokenizer_config.json"),
589
+ sha256: "efb5c0d09722e5fe59a462cd2a9976ee216d55b037597d997cd3fe833216da15",
590
+ bytes: 418
591
+ }
592
+ ]
1119
593
  }
1120
594
  ];
1121
- var DEFAULT_TEXT_MODEL = "e5-small";
1122
- var textModel = /* @__PURE__ */ __name((id2) => {
1123
- const found = TEXT_MODELS.find((model) => model.id === id2);
595
+ var DEFAULT_TEXT_MODEL = "embeddinggemma";
596
+ var PREVIOUS_DEFAULT_TEXT_MODEL = "e5-small";
597
+ var SECTION = "text_models";
598
+ var slug = pipe(string(), regex(/^[a-z0-9][a-z0-9._-]{0,62}$/, "is not a model id: a-z, 0-9, . _ -"));
599
+ var words = pipe(string(), trim(), minLength(1), maxLength(300));
600
+ var fileName = pipe(string(), check((name) => /^[\w.-]+(\/[\w.-]+)*$/.test(name) && !name.split("/").some((part) => part === ".." || part === "."), "is not a file inside the model's folder"));
601
+ var modelFile = strictObject({
602
+ name: fileName,
603
+ url: pipe(string(), url(), startsWith("https://", "has to be an https address")),
604
+ sha256: pipe(string(), regex(/^[0-9a-f]{64}$/, "has to be a sha256 in hex")),
605
+ bytes: pipe(number(), integer(), minValue(1))
606
+ });
607
+ var CustomTextModelShape = pipe(strictObject({
608
+ id: slug,
609
+ title: words,
610
+ languages: words,
611
+ licence: words,
612
+ terms: optional(pipe(string(), url())),
613
+ dims: pipe(number(), integer(), minValue(1), maxValue(8192)),
614
+ maxTokens: pipe(number(), integer(), minValue(16), maxValue(32768)),
615
+ chunksPerSecond: optional(pipe(number(), minValue(0.01))),
616
+ pooling: picklist(["mean", "sentence_embedding"]),
617
+ prefix: strictObject({
618
+ query: pipe(string(), maxLength(200)),
619
+ passage: pipe(string(), maxLength(200))
620
+ }),
621
+ onnx: fileName,
622
+ externalData: optional(fileName),
623
+ files: pipe(array(modelFile), minLength(1), maxLength(16))
624
+ }), check((model) => !TEXT_MODELS.some((one) => one.id === model.id), "takes the id of a model this version ships; choose another"), check((model) => {
625
+ const names = model.files.map(({ name }) => name);
626
+ return [model.onnx, model.externalData, "tokenizer.json", "tokenizer_config.json"].every((name) => name === void 0 || names.includes(name));
627
+ }, "has to list its onnx file, its external data and tokenizer.json and tokenizer_config.json among files"));
628
+ var TextModelsSection = strictObject({
629
+ use: optional(slug),
630
+ custom: optional(array(CustomTextModelShape))
631
+ });
632
+ var textModelsFile = /* @__PURE__ */ __name((env = process.env) => sharedConfigPath(storePath(env), env), "textModelsFile");
633
+ var readTextModelsSection = /* @__PURE__ */ __name((env = process.env) => {
634
+ const path = textModelsFile(env);
635
+ const section = readSharedSection(path, SECTION);
636
+ if (section === void 0)
637
+ return {};
638
+ const checked = safeParse(TextModelsSection, section);
639
+ if (!checked.success) {
640
+ const issue = checked.issues[0];
641
+ const at = issue ? getDotPath(issue) : null;
642
+ throw new CliError("configuration_error", `${path}: ${SECTION}${at ? `.${at}` : ""} ${issue?.message ?? "is not valid"}`);
643
+ }
644
+ const ids = checked.output.custom?.map(({ id: id2 }) => id2) ?? [];
645
+ const twice = ids.find((id2, at) => ids.indexOf(id2) !== at);
646
+ if (twice)
647
+ throw new CliError("configuration_error", `${path}: ${SECTION}.custom names ${twice} twice`);
648
+ return checked.output;
649
+ }, "readTextModelsSection");
650
+ var writeTextModelsSection = /* @__PURE__ */ __name((section, env = process.env) => writeSharedSection(textModelsFile(env), SECTION, section.use === void 0 && !section.custom?.length ? void 0 : section), "writeTextModelsSection");
651
+ var textModels = /* @__PURE__ */ __name((env = process.env) => [
652
+ ...TEXT_MODELS,
653
+ ...(readTextModelsSection(env).custom ?? []).map((model) => ({ ...model, custom: true }))
654
+ ], "textModels");
655
+ var textModel = /* @__PURE__ */ __name((id2, env = process.env) => {
656
+ const known = textModels(env);
657
+ const found = known.find((model) => model.id === id2);
1124
658
  if (!found) {
1125
- throw new CliError("validation_error", `no text model ${id2} \u2014 one of: ${TEXT_MODELS.map((model) => model.id).join(", ")}`);
659
+ throw new CliError("validation_error", `no text model ${id2} \u2014 one of: ${known.map((model) => model.id).join(", ")}`);
1126
660
  }
1127
661
  return found;
1128
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");
668
+ var chosenTextModel = /* @__PURE__ */ __name((env = process.env) => {
669
+ const use = readTextModelsSection(env).use;
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" };
674
+ }, "chosenTextModel");
1129
675
  var mmarco = huggingFace("cross-encoder/mmarco-mMiniLMv2-L12-H384-v1", "1427fd652930e4ba29e8149678df786c240d8825");
1130
676
  var bge = huggingFace("onnx-community/bge-reranker-v2-m3-ONNX", "6f5ff65298512715a1e669753bc754d2bc8f367b");
1131
677
  var RERANK_MODELS = [
@@ -1195,57 +741,13 @@ var rerankModel = /* @__PURE__ */ __name((id2) => {
1195
741
  }
1196
742
  return found;
1197
743
  }, "rerankModel");
1198
- var vectorModelKey = /* @__PURE__ */ __name((model) => `local:${model.id}:${model.dims}`, "vectorModelKey");
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");
1199
748
  var meaningFloor = /* @__PURE__ */ __name((key) => key === "local:e5-small:384" ? 0.8 : 0, "meaningFloor");
1200
749
 
1201
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/services/history-limits.js
1202
- var HISTORY_MAX_DAYS = 1095;
1203
- var DEFAULT_HISTORY_LIMITS = { dialogDays: 1095, groupDays: 365, groupMembersMax: 50 };
1204
- var DAY_MS2 = 24 * 60 * 60 * 1e3;
1205
- var historyWindow = /* @__PURE__ */ __name((shape, limits, now) => {
1206
- const group = shape !== void 0 && shape.kind !== "dialog" && shape.kind !== "saved";
1207
- if (group && (shape.participantsCount ?? 0) > limits.groupMembersMax)
1208
- return { skip: "group_too_large", members: shape.participantsCount ?? 0 };
1209
- const days2 = group ? limits.groupDays : limits.dialogDays;
1210
- return { keepFrom: now - Math.min(days2, HISTORY_MAX_DAYS) * DAY_MS2 };
1211
- }, "historyWindow");
1212
- var limitBatch = /* @__PURE__ */ __name((batch, shapes, included, limits, now = Date.now()) => {
1213
- const skipped = /* @__PURE__ */ new Map();
1214
- if (!batch.messages?.length)
1215
- return { batch, skipped };
1216
- const named = new Map((batch.chats ?? []).map((chat) => [chat.id, chat]));
1217
- const windows = /* @__PURE__ */ new Map();
1218
- const windowOf = /* @__PURE__ */ __name((chatId) => {
1219
- if (!windows.has(chatId)) {
1220
- const chat = named.get(chatId);
1221
- const shape = chat ? { kind: chat.kind, participantsCount: chat.participantsCount ?? null } : shapes(chatId);
1222
- windows.set(chatId, included(chatId) ? void 0 : historyWindow(shape, limits, now));
1223
- }
1224
- return windows.get(chatId);
1225
- }, "windowOf");
1226
- const messages = batch.messages.filter((message) => {
1227
- const window = windowOf(message.chatId);
1228
- if (window === void 0)
1229
- return true;
1230
- const at = Date.parse(message.timestamp);
1231
- if ("keepFrom" in window && !(at < window.keepFrom))
1232
- return true;
1233
- const reason = "skip" in window ? window.skip : "older_than_window";
1234
- const held = skipped.get(message.chatId);
1235
- const iso = new Date(at).toISOString();
1236
- skipped.set(message.chatId, {
1237
- reason,
1238
- messages: (held?.messages ?? 0) + 1,
1239
- oldestAt: held && held.oldestAt < iso ? held.oldestAt : iso,
1240
- newestAt: held && held.newestAt > iso ? held.newestAt : iso,
1241
- ..."skip" in window ? { members: window.members } : { keptFrom: new Date(window.keepFrom).toISOString() }
1242
- });
1243
- return false;
1244
- });
1245
- return { batch: { ...batch, messages }, skipped };
1246
- }, "limitBatch");
1247
-
1248
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1249
751
  var closeSuggestion = strictObject({
1250
752
  as: picklist(["done", "dismissed"]),
1251
753
  /** The agent's name. */
@@ -1307,7 +809,7 @@ var task = strictObject({
1307
809
  updated_at: optional(time)
1308
810
  });
1309
811
 
1310
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1311
813
  var agendaChat = strictObject({
1312
814
  chat: reference,
1313
815
  title: nullable(text),
@@ -1377,7 +879,7 @@ var agenda = strictObject({
1377
879
  unlisted_categories: array(strictObject({ name: text, open_tasks: number() }))
1378
880
  });
1379
881
 
1380
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1381
883
  var attachment = strictObject({
1382
884
  /** The message it came with, as a locator; absent inside that message. */
1383
885
  message: optional(reference),
@@ -1415,7 +917,7 @@ var attachment = strictObject({
1415
917
  });
1416
918
  var hitFile = strictObject({ position: count, kind: text, name: optional(text), size: optional(count) });
1417
919
 
1418
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1419
921
  var conversation = strictObject({
1420
922
  id,
1421
923
  chat: reference,
@@ -1430,7 +932,7 @@ var conversation = strictObject({
1430
932
  rules_version: count
1431
933
  });
1432
934
 
1433
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1434
936
  var tagging = strictObject({
1435
937
  tag: text,
1436
938
  type: picklist(TAG_TYPES),
@@ -1443,7 +945,160 @@ var tagging = strictObject({
1443
945
  created_at: time
1444
946
  });
1445
947
 
1446
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1447
1102
  import { join as join2 } from "node:path";
1448
1103
  var clip = /* @__PURE__ */ __name((name) => `https://huggingface.co/Xenova/clip-vit-base-patch32/resolve/d15189d7028b43f1d3e65039190477f6af591c2a/${name}`, "clip");
1449
1104
  var IMAGE_MODELS = [
@@ -1497,7 +1152,7 @@ var imageModelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedM
1497
1152
  var placedImage = /* @__PURE__ */ __name((model, directory) => model.files.map((file) => [file, join2(directory, model.id, file.name)]), "placedImage");
1498
1153
  var isImageModelInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placedImage(model, directory)), "isImageModelInstalled");
1499
1154
 
1500
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/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
1501
1156
  var WEIGHTS = {
1502
1157
  bot: 3,
1503
1158
  scam: 3,
@@ -1522,47 +1177,23 @@ var LINK = /https?:\/\/|t\.me\/|www\./i;
1522
1177
  var DIGITS = /\d{5,}/;
1523
1178
  var oddName = /* @__PURE__ */ __name((name) => !name?.trim() || DIGITS.test(name) || LINK.test(name), "oddName");
1524
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
+
1525
1196
  export {
1526
- logAttributes,
1527
- fromLogAttributes,
1528
- snakeLogger,
1529
- LOG_ATTRIBUTES,
1530
- KEEP_RUNS_FOR_DAYS,
1531
- KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
1532
- RUNS_SIZE_LIMIT_MB,
1533
- runsDirFor,
1534
- startRun,
1535
- runtime,
1536
- newRunId,
1537
- listRuns,
1538
- findRun,
1539
- readEvents,
1540
- currentRun,
1541
- inRun,
1542
- runEvent,
1543
- typedCommand,
1544
- useAsProcessRun,
1545
- processRun,
1546
- enclosingTraceId,
1547
- traceOf,
1548
- childTrace,
1549
- withAttempt,
1550
- currentAttempt,
1551
- sentIds,
1552
- withWriteScope,
1553
- stopWrites,
1554
- currentOperation,
1555
- guardedWrite,
1556
- codeOf,
1557
- parseDuration,
1558
- TEXT_MODELS,
1559
- DEFAULT_TEXT_MODEL,
1560
- textModel,
1561
- RERANK_MODELS,
1562
- DEFAULT_RERANK_MODEL,
1563
- rerankModel,
1564
- vectorModelKey,
1565
- meaningFloor,
1566
1197
  LEVELS,
1567
1198
  skipFlagFor,
1568
1199
  DEFAULT_PERMISSIONS,
@@ -1585,10 +1216,6 @@ export {
1585
1216
  permissionOverrides,
1586
1217
  assertOverridesTighten,
1587
1218
  assertRetentionEvidenceRead,
1588
- HISTORY_MAX_DAYS,
1589
- DEFAULT_HISTORY_LIMITS,
1590
- historyWindow,
1591
- limitBatch,
1592
1219
  closeSuggestion,
1593
1220
  task,
1594
1221
  agenda,
@@ -1598,7 +1225,33 @@ export {
1598
1225
  LINK,
1599
1226
  oddName,
1600
1227
  conversation,
1228
+ progressOf,
1601
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,
1602
1255
  IMAGE_MODELS,
1603
1256
  DEFAULT_IMAGE_MODEL,
1604
1257
  imageModel,