@wirecat/mail-cli 0.0.0-stage → 0.1.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 (226) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/LICENSE +204 -0
  3. package/README.md +141 -2
  4. package/dist/bin/mail.d.ts +3 -0
  5. package/dist/bin/mail.d.ts.map +1 -0
  6. package/dist/bin/mail.js +36 -0
  7. package/dist/bin/mail.js.map +1 -0
  8. package/dist/bundle/all-profiles-TKMBELRZ.js +286 -0
  9. package/dist/bundle/anthropic-7LMUAEIZ.js +72 -0
  10. package/dist/bundle/app-server-JGMIJDD4.js +229 -0
  11. package/dist/bundle/bun-XRO6XJHQ.js +169 -0
  12. package/dist/bundle/bun-sqlite-Z54LEHVM.js +71 -0
  13. package/dist/bundle/chunk-2LLNPNMB.js +24 -0
  14. package/dist/bundle/chunk-3E3WA2L6.js +1932 -0
  15. package/dist/bundle/chunk-3KEVLSNN.js +138 -0
  16. package/dist/bundle/chunk-3KOA73LS.js +3416 -0
  17. package/dist/bundle/chunk-4E7BN3TC.js +122 -0
  18. package/dist/bundle/chunk-4FEMINO2.js +409 -0
  19. package/dist/bundle/chunk-5BVIWP3S.js +71 -0
  20. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  21. package/dist/bundle/chunk-5NYMNSSO.js +264 -0
  22. package/dist/bundle/chunk-5WGEUDE4.js +27 -0
  23. package/dist/bundle/chunk-6MAZWSC3.js +132 -0
  24. package/dist/bundle/chunk-75CWWETH.js +379 -0
  25. package/dist/bundle/chunk-7SXGLT6T.js +444 -0
  26. package/dist/bundle/chunk-BTQX2ZSZ.js +288 -0
  27. package/dist/bundle/chunk-CEW6KIFA.js +1193 -0
  28. package/dist/bundle/chunk-CH6RXYAX.js +82 -0
  29. package/dist/bundle/chunk-D72URWJE.js +532 -0
  30. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  31. package/dist/bundle/chunk-EOEDICIE.js +6848 -0
  32. package/dist/bundle/chunk-F6D6PJ34.js +100 -0
  33. package/dist/bundle/chunk-FDCGTODC.js +78 -0
  34. package/dist/bundle/chunk-FZ5FXIG6.js +18 -0
  35. package/dist/bundle/chunk-GAH7N7HO.js +8181 -0
  36. package/dist/bundle/chunk-GK4M2SUP.js +195 -0
  37. package/dist/bundle/chunk-GN62YOT5.js +161 -0
  38. package/dist/bundle/chunk-GQQJOH7A.js +7050 -0
  39. package/dist/bundle/chunk-GWDCKUBI.js +781 -0
  40. package/dist/bundle/chunk-HTQTIKWP.js +928 -0
  41. package/dist/bundle/chunk-IK5TH3O7.js +217 -0
  42. package/dist/bundle/chunk-J3QXTBD2.js +2742 -0
  43. package/dist/bundle/chunk-J6MSJLIW.js +45 -0
  44. package/dist/bundle/chunk-JBBZCTTF.js +76 -0
  45. package/dist/bundle/chunk-JVMVLITS.js +260 -0
  46. package/dist/bundle/chunk-K4FVKPDQ.js +525 -0
  47. package/dist/bundle/chunk-KHTO2Q6E.js +886 -0
  48. package/dist/bundle/chunk-KM7Q67Z3.js +63 -0
  49. package/dist/bundle/chunk-LQ37ALDJ.js +2416 -0
  50. package/dist/bundle/chunk-MNOIRJEO.js +2315 -0
  51. package/dist/bundle/chunk-MS53RALV.js +168 -0
  52. package/dist/bundle/chunk-NK7EB63L.js +36225 -0
  53. package/dist/bundle/chunk-NPGVOZVK.js +2 -0
  54. package/dist/bundle/chunk-OTUOZ33L.js +82 -0
  55. package/dist/bundle/chunk-P7P5MNAU.js +46 -0
  56. package/dist/bundle/chunk-QLEUNU6G.js +537 -0
  57. package/dist/bundle/chunk-QQB7WT7R.js +216 -0
  58. package/dist/bundle/chunk-QX7RCLRS.js +23 -0
  59. package/dist/bundle/chunk-T6464KYA.js +35130 -0
  60. package/dist/bundle/chunk-TE5U5OAM.js +73 -0
  61. package/dist/bundle/chunk-TI6VBZKJ.js +166 -0
  62. package/dist/bundle/chunk-TQFCPUIM.js +53 -0
  63. package/dist/bundle/chunk-TVREDYX4.js +3574 -0
  64. package/dist/bundle/chunk-TWPDVUBR.js +106 -0
  65. package/dist/bundle/chunk-TWTATDM7.js +461 -0
  66. package/dist/bundle/chunk-UH4DDRHA.js +2989 -0
  67. package/dist/bundle/chunk-VEIZZRQ5.js +630 -0
  68. package/dist/bundle/chunk-WLFLBWNH.js +54 -0
  69. package/dist/bundle/chunk-WXAXYJJ7.js +486 -0
  70. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  71. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  72. package/dist/bundle/chunk-YO4CUH5E.js +33 -0
  73. package/dist/bundle/chunk-YPQQ5J4X.js +849 -0
  74. package/dist/bundle/chunk-Z34ICZA3.js +1028 -0
  75. package/dist/bundle/chunk-ZANYM66S.js +58 -0
  76. package/dist/bundle/chunk-ZD3WUGR2.js +142 -0
  77. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  78. package/dist/bundle/command-contract-WU434ZUL.js +34 -0
  79. package/dist/bundle/decode-YB3ZDTES.js +162 -0
  80. package/dist/bundle/dispatch-EUKKT3PD.js +411 -0
  81. package/dist/bundle/dist-A6GKSKFC.js +2072 -0
  82. package/dist/bundle/dist-X36THCOF.js +7577 -0
  83. package/dist/bundle/echarts-YNGCOYHW.js +42501 -0
  84. package/dist/bundle/embed-LWNHIRBQ.js +37 -0
  85. package/dist/bundle/embedder-2LYD3U37.js +110 -0
  86. package/dist/bundle/failure-OAIC5VAP.js +24 -0
  87. package/dist/bundle/first-run-N3HJKGU7.js +27 -0
  88. package/dist/bundle/first-screen-4U2DMV3G.js +32 -0
  89. package/dist/bundle/instructions-GJHHFV64.js +11 -0
  90. package/dist/bundle/mail.js +166 -0
  91. package/dist/bundle/mcp-L7SRVDRN.js +167 -0
  92. package/dist/bundle/node-GFOH6FKP.js +176 -0
  93. package/dist/bundle/node-KM3CUABH.js +2340 -0
  94. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  95. package/dist/bundle/node-sqlite-NBXQXBIU.js +63 -0
  96. package/dist/bundle/oauth-56EFO5AQ.js +19 -0
  97. package/dist/bundle/open-2V7QZQJP.js +21 -0
  98. package/dist/bundle/openai-V3SVACVL.js +251 -0
  99. package/dist/bundle/process-XVDX4SPD.js +91 -0
  100. package/dist/bundle/program-ILID6EAT.js +35542 -0
  101. package/dist/bundle/prompt-YKWAI222.js +14 -0
  102. package/dist/bundle/recognize-PAR66KVM.js +25 -0
  103. package/dist/bundle/remote-CE43TKXC.js +28 -0
  104. package/dist/bundle/rerank-M7S7P2TW.js +51 -0
  105. package/dist/bundle/serve-ENPMIV6J.js +197 -0
  106. package/dist/bundle/server-JRTHUCVY.js +63 -0
  107. package/dist/bundle/server-MBEZLVKZ.js +189 -0
  108. package/dist/bundle/sqlite-runtime-HVGDHBJJ.js +18 -0
  109. package/dist/bundle/state-QZSOSKBD.js +35 -0
  110. package/dist/bundle/store-2BUX6LVX.js +124 -0
  111. package/dist/bundle/store-UJ7SNKXI.js +141 -0
  112. package/dist/bundle/store-maintenance-command-I7V5C44K.js +52 -0
  113. package/dist/commands/account.d.ts +3 -0
  114. package/dist/commands/account.d.ts.map +1 -0
  115. package/dist/commands/account.js +47 -0
  116. package/dist/commands/account.js.map +1 -0
  117. package/dist/commands/context.d.ts +41 -0
  118. package/dist/commands/context.d.ts.map +1 -0
  119. package/dist/commands/context.js +52 -0
  120. package/dist/commands/context.js.map +1 -0
  121. package/dist/commands/doctor.d.ts +77 -0
  122. package/dist/commands/doctor.d.ts.map +1 -0
  123. package/dist/commands/doctor.js +74 -0
  124. package/dist/commands/doctor.js.map +1 -0
  125. package/dist/commands/folders.d.ts +3 -0
  126. package/dist/commands/folders.d.ts.map +1 -0
  127. package/dist/commands/folders.js +36 -0
  128. package/dist/commands/folders.js.map +1 -0
  129. package/dist/commands/login.d.ts +5 -0
  130. package/dist/commands/login.d.ts.map +1 -0
  131. package/dist/commands/login.js +21 -0
  132. package/dist/commands/login.js.map +1 -0
  133. package/dist/commands/mailbox.d.ts +16 -0
  134. package/dist/commands/mailbox.d.ts.map +1 -0
  135. package/dist/commands/mailbox.js +54 -0
  136. package/dist/commands/mailbox.js.map +1 -0
  137. package/dist/commands/mcp.d.ts +3 -0
  138. package/dist/commands/mcp.d.ts.map +1 -0
  139. package/dist/commands/mcp.js +97 -0
  140. package/dist/commands/mcp.js.map +1 -0
  141. package/dist/commands/session.d.ts +3 -0
  142. package/dist/commands/session.d.ts.map +1 -0
  143. package/dist/commands/session.js +211 -0
  144. package/dist/commands/session.js.map +1 -0
  145. package/dist/commands/setup.d.ts +3 -0
  146. package/dist/commands/setup.d.ts.map +1 -0
  147. package/dist/commands/setup.js +156 -0
  148. package/dist/commands/setup.js.map +1 -0
  149. package/dist/commands/status.d.ts +3 -0
  150. package/dist/commands/status.d.ts.map +1 -0
  151. package/dist/commands/status.js +89 -0
  152. package/dist/commands/status.js.map +1 -0
  153. package/dist/commands/sync.d.ts +3 -0
  154. package/dist/commands/sync.d.ts.map +1 -0
  155. package/dist/commands/sync.js +190 -0
  156. package/dist/commands/sync.js.map +1 -0
  157. package/dist/config.d.ts +190 -0
  158. package/dist/config.d.ts.map +1 -0
  159. package/dist/config.js +46 -0
  160. package/dist/config.js.map +1 -0
  161. package/dist/discovery.d.ts +42 -0
  162. package/dist/discovery.d.ts.map +1 -0
  163. package/dist/discovery.js +179 -0
  164. package/dist/discovery.js.map +1 -0
  165. package/dist/identity.d.ts +5 -0
  166. package/dist/identity.d.ts.map +1 -0
  167. package/dist/identity.js +16 -0
  168. package/dist/identity.js.map +1 -0
  169. package/dist/index.d.ts +3 -0
  170. package/dist/index.d.ts.map +1 -0
  171. package/dist/index.js +3 -0
  172. package/dist/index.js.map +1 -0
  173. package/dist/mail/imap-errors.d.ts +4 -0
  174. package/dist/mail/imap-errors.d.ts.map +1 -0
  175. package/dist/mail/imap-errors.js +41 -0
  176. package/dist/mail/imap-errors.js.map +1 -0
  177. package/dist/mail/imap-messages.d.ts +18 -0
  178. package/dist/mail/imap-messages.d.ts.map +1 -0
  179. package/dist/mail/imap-messages.js +66 -0
  180. package/dist/mail/imap-messages.js.map +1 -0
  181. package/dist/mail/imap.d.ts +67 -0
  182. package/dist/mail/imap.d.ts.map +1 -0
  183. package/dist/mail/imap.js +348 -0
  184. package/dist/mail/imap.js.map +1 -0
  185. package/dist/mail/parse.d.ts +18 -0
  186. package/dist/mail/parse.d.ts.map +1 -0
  187. package/dist/mail/parse.js +31 -0
  188. package/dist/mail/parse.js.map +1 -0
  189. package/dist/mail/port.d.ts +50 -0
  190. package/dist/mail/port.d.ts.map +1 -0
  191. package/dist/mail/port.js +4 -0
  192. package/dist/mail/port.js.map +1 -0
  193. package/dist/mcp.d.ts +29 -0
  194. package/dist/mcp.d.ts.map +1 -0
  195. package/dist/mcp.js +98 -0
  196. package/dist/mcp.js.map +1 -0
  197. package/dist/profile.d.ts +16 -0
  198. package/dist/profile.d.ts.map +1 -0
  199. package/dist/profile.js +31 -0
  200. package/dist/profile.js.map +1 -0
  201. package/dist/program.d.ts +6 -0
  202. package/dist/program.d.ts.map +1 -0
  203. package/dist/program.js +52 -0
  204. package/dist/program.js.map +1 -0
  205. package/dist/providers.d.ts +53 -0
  206. package/dist/providers.d.ts.map +1 -0
  207. package/dist/providers.js +106 -0
  208. package/dist/providers.js.map +1 -0
  209. package/dist/secret.d.ts +30 -0
  210. package/dist/secret.d.ts.map +1 -0
  211. package/dist/secret.js +68 -0
  212. package/dist/secret.js.map +1 -0
  213. package/dist/store.d.ts +12 -0
  214. package/dist/store.d.ts.map +1 -0
  215. package/dist/store.js +25 -0
  216. package/dist/store.js.map +1 -0
  217. package/dist/sync.d.ts +26 -0
  218. package/dist/sync.d.ts.map +1 -0
  219. package/dist/sync.js +75 -0
  220. package/dist/sync.js.map +1 -0
  221. package/dist/version.d.ts +2 -0
  222. package/dist/version.d.ts.map +1 -0
  223. package/dist/version.js +2 -0
  224. package/dist/version.js.map +1 -0
  225. package/package.json +83 -4
  226. package/skills/mail-cli/SKILL.md +27 -0
@@ -0,0 +1,444 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ isContentKey
5
+ } from "./chunk-J3QXTBD2.js";
6
+ import {
7
+ errorCodes
8
+ } from "./chunk-5BVIWP3S.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-ZVVMGPBJ.js";
12
+
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/runs/run-context.js
14
+ import { AsyncLocalStorage } from "node:async_hooks";
15
+ import { createHash } from "node:crypto";
16
+
17
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
18
+ import { homedir } from "node:os";
19
+
20
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/errors/failures.js
21
+ var isCliFailure = /* @__PURE__ */ __name((value) => value instanceof Error && value.name === "CliError" && errorCodes.includes(value.code), "isCliFailure");
22
+ var isCommanderFailure = /* @__PURE__ */ __name((value) => {
23
+ const { code, exitCode } = value ?? {};
24
+ return value instanceof Error && typeof code === "string" && code.startsWith("commander.") && typeof exitCode === "number";
25
+ }, "isCommanderFailure");
26
+ var failureKey = /* @__PURE__ */ __name((error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error", "failureKey");
27
+
28
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/runs/events.js
29
+ var providerErrorKey = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(value) ? value : void 0, "providerErrorKey");
30
+ var renderEvent = /* @__PURE__ */ __name((event) => {
31
+ if (event.event === "warning") {
32
+ const counts = Object.entries(event.counts ?? {}).map(([field, count]) => `${count} ${field}`);
33
+ return [`${MARK.warning} ${(event.operation ?? "").padEnd(16)} ${event.code}`, ...counts, event.detail].filter(Boolean).join(" ");
34
+ }
35
+ const parts = [];
36
+ if (event.event === "cache") {
37
+ parts.push(event.reason);
38
+ if (event.ageMs !== void 0)
39
+ parts.push(`cached ${age(event.ageMs)}`);
40
+ } else {
41
+ if (event.opcode !== void 0)
42
+ parts.push(`op ${event.opcode}`, `seq ${event.seq}`);
43
+ if (event.method !== void 0 || event.endpointTemplate !== void 0)
44
+ parts.push([event.method, event.endpointTemplate].filter(Boolean).join(" "));
45
+ if (event.status !== void 0)
46
+ parts.push(`${event.status}`);
47
+ if (event.attempt !== void 0 && event.attempt > 1)
48
+ parts.push(`attempt ${event.attempt}`);
49
+ if (event.waitMs !== void 0)
50
+ parts.push(`waited ${age(event.waitMs)}`);
51
+ }
52
+ if (event.ids)
53
+ for (const [name, value] of Object.entries(event.ids))
54
+ parts.push(`${name} ${value}`);
55
+ if (event.event !== "cache") {
56
+ if (event.durationMs !== void 0)
57
+ parts.push(`${event.durationMs}ms`);
58
+ if (event.bytes !== void 0)
59
+ parts.push(size(event.bytes));
60
+ }
61
+ if (event.counts)
62
+ for (const [field, count] of Object.entries(event.counts))
63
+ parts.push(`${count} ${field}`);
64
+ if (event.event !== "cache") {
65
+ if (event.errorCode)
66
+ parts.push(event.errorCode);
67
+ if (event.providerError)
68
+ parts.push(event.providerError);
69
+ }
70
+ return `${MARK[event.event]} ${event.operation.padEnd(16)} ${parts.join(" ")}`.trimEnd();
71
+ }, "renderEvent");
72
+ var MARK = { request: "\u2192", response: "\u2190", cache: "\u2022", warning: "!" };
73
+ var age = /* @__PURE__ */ __name((ms) => ms < 1e3 ? `${ms}ms` : `${Math.round(ms / 1e3)}s`, "age");
74
+ var size = /* @__PURE__ */ __name((bytes) => bytes < 1e3 ? `${bytes} B` : `${(bytes / 1e3).toFixed(1)} kB`, "size");
75
+
76
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/runs/secrets.js
77
+ var SECRET_WORDS = /* @__PURE__ */ new Set([
78
+ "authorization",
79
+ "cookie",
80
+ "credential",
81
+ "credentials",
82
+ "passphrase",
83
+ "password",
84
+ "passwd",
85
+ "pwd",
86
+ "pass",
87
+ "passcode",
88
+ "pin",
89
+ "otp",
90
+ "2fa",
91
+ "secret",
92
+ "token",
93
+ "contrase\xF1a",
94
+ "contrasena",
95
+ "clave",
96
+ "\u043F\u0430\u0440\u043E\u043B\u044C",
97
+ "\u043F\u0438\u043D",
98
+ "\u043A\u043E\u0434",
99
+ ...["api", "auth", "service", "account", "db", "database", "priv", "private", "client"].map((word) => `${word}key`),
100
+ ...["db", "database", "key"].map((word) => `${word}pass`)
101
+ ]);
102
+ var secretNamed = /* @__PURE__ */ __name((name) => {
103
+ const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).map((word) => word.toLowerCase());
104
+ return words.some((word, at) => SECRET_WORDS.has(word) || SECRET_WORDS.has(word + (words[at + 1] ?? "")));
105
+ }, "secretNamed");
106
+ var START = "(?<![A-Za-z0-9_-])";
107
+ var END = "(?![A-Za-z0-9_-])";
108
+ var KNOWN_TOKENS = new RegExp(`${[
109
+ "gh[pousr]_[A-Za-z0-9]{36,}",
110
+ "github_pat_[A-Za-z0-9_]{22,}",
111
+ "sk-[A-Za-z0-9_-]{20,}",
112
+ "xox[abprs]-[A-Za-z0-9-]{10,}",
113
+ "(?:AKIA|ASIA)[A-Z0-9]{16}",
114
+ "AIza[A-Za-z0-9_-]{35}",
115
+ "(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}",
116
+ "npm_[A-Za-z0-9]{36}",
117
+ "eyJ[A-Za-z0-9_-]{5,}\\.eyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*"
118
+ ].map((pattern) => `${START}${pattern}${END}`).join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
119
+ var PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
120
+ var SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
121
+ var NAMED_PAIR = /(?<![\p{L}\p{N}])([\p{L}\p{N}_.-]*(?:token|pass|pwd|pin|otp|2fa|secret|credential|cookie|authorization|key|contrase|clave|пароль|пин|код)[\p{L}\p{N}_.-]*)(["']?\s*(?:=>|[:=])\s*["']?|\s+(?![\p{L}]+(?![\p{L}\p{N}])))((?:Bearer\s+|Basic\s+)?)([^\s"'&,;]+)/giu;
122
+ var looksRandom = /* @__PURE__ */ __name((run) => {
123
+ if (run.length < 20)
124
+ return false;
125
+ const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((kind) => kind.test(run)).length;
126
+ if (classes < 3)
127
+ return false;
128
+ let switches = 0;
129
+ for (let at = 1; at < run.length; at++) {
130
+ const [before, after] = [run[at - 1], run[at]];
131
+ if (/[a-z]/.test(before) && /[A-Z]/.test(after) || /[A-Z]/.test(before) && /[a-z]/.test(after))
132
+ switches += 1;
133
+ }
134
+ if (switches / run.length < 0.15)
135
+ return false;
136
+ const pieces = run.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? [];
137
+ if (pieces.join("").length / Math.max(pieces.length, 1) >= 2.75)
138
+ return false;
139
+ return entropy(run) >= 3.5;
140
+ }, "looksRandom");
141
+ var entropy = /* @__PURE__ */ __name((text) => {
142
+ const counts = /* @__PURE__ */ new Map();
143
+ for (const char of text)
144
+ counts.set(char, (counts.get(char) ?? 0) + 1);
145
+ let bits = 0;
146
+ for (const count of counts.values())
147
+ bits -= count / text.length * Math.log2(count / text.length);
148
+ return bits;
149
+ }, "entropy");
150
+ var withoutSecrets = /* @__PURE__ */ __name((text, mark = "[redacted]") => text.replace(PRIVATE_KEY, mark).replace(KNOWN_TOKENS, mark).replace(SCHEME, `$1$2${mark}`).replace(NAMED_PAIR, (whole, name, separator, scheme) => secretNamed(name) ? `${name}${separator}${scheme}${mark}` : whole).replace(/[!-~]{20,}/g, (token) => (
151
+ // A URL or a path is somebody's address, not a key; a credential in one is caught by the rules above.
152
+ token.includes("://") || /^(?:\/|~\/|\.\.?\/)/.test(token) ? token : token.replace(RUN, (run) => looksRandom(run) ? mark : run.replace(HEX, (hex) => entropy(hex) >= 3 ? mark : hex))
153
+ )), "withoutSecrets");
154
+ var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
155
+ var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
156
+
157
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
158
+ var MESSAGE_AT_MOST = 500;
159
+ var CAUSES_AT_MOST = 5;
160
+ var FRAMES_AT_MOST = 15;
161
+ var errorDetailOf = /* @__PURE__ */ __name((error, response) => {
162
+ const details = isCliFailure(error) ? { ...error.details } : {};
163
+ const thrown = error instanceof Error ? error : void 0;
164
+ const code = isCliFailure(error) ? error.code : codeOf(error);
165
+ const reason = typeof details.reason === "string" ? details.reason : void 0;
166
+ const causeCode = typeof details.cause_code === "string" && /^[A-Za-z0-9_.-]{1,40}$/.test(details.cause_code) ? details.cause_code : void 0;
167
+ const message = thrown ? redactText(thrown.message) : void 0;
168
+ const operation = stringOf(details.operation) ?? response?.operation;
169
+ const status = numberOf(details.status) ?? response?.status;
170
+ const method = stringOf(details.method) ?? response?.method;
171
+ const endpoint = stringOf(details.endpoint) ?? response?.endpointTemplate;
172
+ const key = providerErrorKey(details.provider_error) ?? providerErrorKey(response?.providerError);
173
+ const protocol = key !== void 0 && method === void 0 && endpoint === void 0;
174
+ const http = method !== void 0 || endpoint !== void 0 || status !== void 0 && !protocol ? {
175
+ ...method === void 0 ? {} : { method: method.toUpperCase().slice(0, 16) },
176
+ ...endpoint === void 0 ? {} : { endpoint_template: endpointTemplate(endpoint) },
177
+ ...status === void 0 ? {} : { status }
178
+ } : void 0;
179
+ const causes = causesOf(thrown?.cause ?? details.cause);
180
+ const stack = framesOf(thrown);
181
+ return {
182
+ class: classOf(error),
183
+ ...code === void 0 ? {} : { code },
184
+ ...reason === void 0 ? {} : { reason },
185
+ ...causeCode === void 0 ? {} : { cause_code: causeCode },
186
+ ...message ? { message } : {},
187
+ ...operation === void 0 ? {} : { operation },
188
+ ...http ? { http } : {},
189
+ ...key === void 0 ? {} : { provider: { key, ...protocol && status !== void 0 ? { code: status } : {} } },
190
+ ...causes.length > 0 ? { causes } : {},
191
+ ...stack.length > 0 ? { stack } : {}
192
+ };
193
+ }, "errorDetailOf");
194
+ var stringOf = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0, "stringOf");
195
+ var numberOf = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isInteger(value) ? value : void 0, "numberOf");
196
+ var classOf = /* @__PURE__ */ __name((error) => {
197
+ if (!(error instanceof Error))
198
+ return error === null ? "null" : typeof error;
199
+ const constructed = error.constructor?.name;
200
+ return constructed && constructed !== "Error" && constructed !== error.name ? constructed : error.name;
201
+ }, "classOf");
202
+ var codeOf = /* @__PURE__ */ __name((error) => {
203
+ const code = error?.code;
204
+ return typeof code === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(code) ? code : void 0;
205
+ }, "codeOf");
206
+ var causesOf = /* @__PURE__ */ __name((first) => {
207
+ const causes = [];
208
+ const seen = /* @__PURE__ */ new Set();
209
+ for (let cause = first; cause !== void 0 && cause !== null && causes.length < CAUSES_AT_MOST; ) {
210
+ if (seen.has(cause))
211
+ break;
212
+ seen.add(cause);
213
+ const message = cause instanceof Error ? redactText(cause.message) : void 0;
214
+ causes.push({ class: classOf(cause), ...message ? { message } : {} });
215
+ cause = cause instanceof Error ? cause.cause : void 0;
216
+ }
217
+ return causes;
218
+ }, "causesOf");
219
+ var framesOf = /* @__PURE__ */ __name((error, limit = FRAMES_AT_MOST) => {
220
+ const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
221
+ return stack.split("\n").filter((line) => line.trimStart().startsWith("at ")).flatMap((line) => {
222
+ const match = /^\s*at (?:async )?(?:(.+?) \()?(.+?):(\d+):\d+\)?$/.exec(line);
223
+ if (!match)
224
+ return [];
225
+ const [, fn, path = "", lineNumber] = match;
226
+ if (path.startsWith("node:"))
227
+ return [];
228
+ return [`${fn ?? "<anonymous>"} ${fileOf(path)}:${lineNumber}`];
229
+ }).slice(0, limit);
230
+ }, "framesOf");
231
+ var fileOf = /* @__PURE__ */ __name((path) => {
232
+ const plain = path.replace(/^file:\/\//, "");
233
+ const packaged = /\/node_modules\/((?:@[^/]+\/)?[^/]+\/.+)$/.exec(plain)?.[1];
234
+ if (packaged)
235
+ return packaged.replace(/\/(?:dist|src)\//, "/");
236
+ return /(?:^|\/)(?:dist|src)\/(.+)$/.exec(plain)?.[1] ?? plain.split("/").at(-1) ?? "?";
237
+ }, "fileOf");
238
+ var endpointTemplate = /* @__PURE__ */ __name((raw) => {
239
+ const trimmed = raw.trim().split(/[?#]/)[0] ?? "";
240
+ const origin = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/]*)/i.exec(trimmed);
241
+ const path = origin ? trimmed.slice(origin[0].length) : trimmed;
242
+ const scheme = origin ? `${trimmed.slice(0, trimmed.indexOf("://"))}://${origin[1]}` : "";
243
+ const segments = path.split("/").map((segment) => {
244
+ if (segment === "" || /^[:{].+/.test(segment))
245
+ return segment;
246
+ if (/^bot\d+:/.test(segment) || /^\d{6,}:[\w-]{20,}$/.test(segment))
247
+ return ":token";
248
+ if (/^-?\d+$/.test(segment) || /^[0-9a-f-]{16,}$/i.test(segment))
249
+ return ":id";
250
+ if (!/^[A-Za-z0-9._~-]{1,40}$/.test(segment))
251
+ return ":value";
252
+ return segment;
253
+ });
254
+ return `${scheme}${segments.join("/")}`.slice(0, 300);
255
+ }, "endpointTemplate");
256
+ var INTERNATIONAL_PHONE = /\+\d[\d\s()-]{6,}\d/.source;
257
+ var BARE_PHONE = /(^|[^\w-])\d{11,15}\b/.source;
258
+ var redactText = /* @__PURE__ */ __name((text) => {
259
+ const home = homedir();
260
+ let out = home && home !== "/" ? text.split(home).join("~") : text;
261
+ out = withoutSecrets(out.replace(/"[^"\n]*"|“[^”\n]*”|«[^»\n]*»/g, '"[redacted]"')).replace(/\b(bearer|basic|token|key|password|secret)(\s*[:=]\s*|\s+)[^\s'"]+/gi, "$1$2[redacted]").replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "[email]").replace(new RegExp(INTERNATIONAL_PHONE, "g"), "[number]").replace(new RegExp(BARE_PHONE, "g"), "$1[number]").replace(/\bbot\d+:[\w-]+/g, "bot[token]").replace(/\b\d{6,}:[\w-]{20,}\b/g, "[token]").replace(/(\?|&)[^\s#]*/g, "$1[redacted]").replace(/\b[A-Za-z0-9_-]{40,}\b/g, "[redacted]");
262
+ return out.length > MESSAGE_AT_MOST ? `${out.slice(0, MESSAGE_AT_MOST)}\u2026` : out;
263
+ }, "redactText");
264
+
265
+ // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/runs/run-context.js
266
+ var REDACTED = "[redacted]";
267
+ var keepsSuccess = /* @__PURE__ */ __name(({ record, fromFlag, env, caller, persistent = false }) => {
268
+ if (!record)
269
+ return false;
270
+ if (fromFlag)
271
+ return true;
272
+ if (persistent)
273
+ return false;
274
+ return caller !== void 0 || viaOf(env) !== "desktop";
275
+ }, "keepsSuccess");
276
+ var calls = new AsyncLocalStorage();
277
+ var withCaller = /* @__PURE__ */ __name((caller, work) => calls.run(caller, work), "withCaller");
278
+ var currentCaller = /* @__PURE__ */ __name(() => calls.getStore(), "currentCaller");
279
+ var clientHash = /* @__PURE__ */ __name((id) => createHash("sha256").update(id).digest("hex").slice(0, 8), "clientHash");
280
+ var viaOf = /* @__PURE__ */ __name((env) => env.WIRECAT_CALLER?.trim() === "desktop" ? "desktop" : "cli", "viaOf");
281
+ var agentOf = /* @__PURE__ */ __name((env) => {
282
+ const named = env.AI_AGENT?.trim().split("_")[0];
283
+ const kind = (named && plainWord(named) ? named.toLowerCase() : void 0) ?? (env.CLAUDECODE ? "claude-code" : void 0) ?? (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CODEX_SANDBOX ? "codex" : void 0) ?? (env.GEMINI_CLI ? "gemini-cli" : void 0) ?? (env.OPENCODE ? "opencode" : void 0) ?? (env.CURSOR_AGENT ? "cursor" : void 0) ?? // Only `exec` is the agent's own command: OpenClaw also sets `tui-local` for what the owner types in its TUI.
284
+ (env.OPENCLAW_SHELL?.trim() === "exec" ? "openclaw" : void 0);
285
+ if (!kind)
286
+ return void 0;
287
+ const session = sessionOf(kind, env);
288
+ return {
289
+ kind,
290
+ session_id: session && SESSION.test(session) ? session : null,
291
+ // OpenClaw passes the sender and chat ids of a chat-started run in this variable; only its presence is kept.
292
+ ...kind === "openclaw" && env.OPENCLAW_CHANNEL_CONTEXT?.trim() ? { from_chat: true } : {}
293
+ };
294
+ }, "agentOf");
295
+ var SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
296
+ var SESSION_VARIABLE = {
297
+ "claude-code": "CLAUDE_CODE_SESSION_ID",
298
+ codex: "CODEX_THREAD_ID",
299
+ opencode: "OPENCODE_SESSION_ID",
300
+ "hermes-agent": "HERMES_SESSION_ID"
301
+ };
302
+ var sessionOf = /* @__PURE__ */ __name((kind, env) => {
303
+ const variable = SESSION_VARIABLE[kind];
304
+ return (variable === void 0 ? void 0 : env[variable]?.trim()) || void 0;
305
+ }, "sessionOf");
306
+ var plainWord = /* @__PURE__ */ __name((word) => /^[A-Za-z][A-Za-z0-9.-]{0,39}$/.test(word), "plainWord");
307
+ var secretInputs = /* @__PURE__ */ new WeakSet();
308
+ var secretInput = /* @__PURE__ */ __name((input) => {
309
+ secretInputs.add(input);
310
+ return input;
311
+ }, "secretInput");
312
+ var secretShaped = /* @__PURE__ */ __name((word) => /:\/\/[^/@\s:]+:[^/@\s]+@/.test(word) || /(^|[^A-Za-z0-9_-])[A-Za-z0-9_-]{40,}($|[^A-Za-z0-9_-])/.test(word), "secretShaped");
313
+ var withoutPhones = /* @__PURE__ */ __name((word) => word.replace(new RegExp(INTERNATIONAL_PHONE, "g"), REDACTED).replace(new RegExp(BARE_PHONE, "g"), `$1${REDACTED}`), "withoutPhones");
314
+ var maskArgv = /* @__PURE__ */ __name((program, words, { keep = false } = {}) => {
315
+ const argv = [];
316
+ let unknownCommand;
317
+ let current = program;
318
+ let positional = 0;
319
+ let profileSeen = false;
320
+ let lost = false;
321
+ const raw = /* @__PURE__ */ __name((word) => keep && !secretShaped(word) ? withoutPhones(withoutSecrets(word, REDACTED)) : REDACTED, "raw");
322
+ const keptValue = /* @__PURE__ */ __name((name, value, input) => keep ? input && secretInputs.has(input) || secretNamed(name) ? REDACTED : raw(value) : maskedValue(name, value, input?.argChoices), "keptValue");
323
+ const optionFor = /* @__PURE__ */ __name((flag) => {
324
+ for (let at = current; at; at = at.parent) {
325
+ const found = at.options.find((option) => option.long === flag || option.short === flag);
326
+ if (found)
327
+ return found;
328
+ }
329
+ return void 0;
330
+ }, "optionFor");
331
+ for (let at = 0; at < words.length; at++) {
332
+ const word = words[at];
333
+ if (word === "--") {
334
+ argv.push("--");
335
+ for (let after = at + 1; after < words.length; after++)
336
+ argv.push(raw(words[after]));
337
+ break;
338
+ }
339
+ if (word.startsWith("-") && word.length > 1 && !NUMBER.test(word)) {
340
+ const equals = word.indexOf("=");
341
+ const flag = equals > 0 ? word.slice(0, equals) : word;
342
+ if (!/^--?[A-Za-z0-9][A-Za-z0-9-]*$/.test(flag)) {
343
+ argv.push(raw(word));
344
+ continue;
345
+ }
346
+ const option = optionFor(flag);
347
+ const name = option?.attributeName() ?? flag.replace(/^-+/, "");
348
+ if (equals > 0) {
349
+ argv.push(`${flag}=${keptValue(name, word.slice(equals + 1), option)}`);
350
+ continue;
351
+ }
352
+ argv.push(flag);
353
+ if (!option && keep && secretNamed(name) && words[at + 1] !== void 0 && !words[at + 1]?.startsWith("-")) {
354
+ at += 1;
355
+ argv.push(REDACTED);
356
+ continue;
357
+ }
358
+ if (!option || !(option.required || option.optional))
359
+ continue;
360
+ const takes = /* @__PURE__ */ __name((next) => next !== void 0 && (option.required || !next.startsWith("-") || NUMBER.test(next)), "takes");
361
+ if (takes(words[at + 1])) {
362
+ at += 1;
363
+ argv.push(keptValue(name, words[at], option));
364
+ while (option.variadic && words[at + 1] !== void 0 && !words[at + 1].startsWith("-")) {
365
+ at += 1;
366
+ argv.push(keptValue(name, words[at], option));
367
+ }
368
+ }
369
+ continue;
370
+ }
371
+ if (!lost && positional === 0) {
372
+ const sub = current.commands.find((one) => one.name() === word || one.aliases().includes(word));
373
+ if (sub) {
374
+ argv.push(word);
375
+ current = sub;
376
+ continue;
377
+ }
378
+ if (current === program && !profileSeen) {
379
+ profileSeen = true;
380
+ argv.push(keep ? raw(word) : PROFILE.test(word) && withoutPhones(withoutSecrets(word)) === word ? word : REDACTED);
381
+ continue;
382
+ }
383
+ if (current.commands.length > 0 && current.registeredArguments.length === 0) {
384
+ lost = true;
385
+ unknownCommand = commandLike(word);
386
+ argv.push(keep ? raw(word) : unknownCommand);
387
+ continue;
388
+ }
389
+ }
390
+ const declared = lost ? void 0 : current.registeredArguments;
391
+ const argument = declared?.[Math.min(positional, declared.length - 1)];
392
+ positional += 1;
393
+ argv.push(secretInputs.has(current) ? REDACTED : argument ? keptValue(argument.name(), word, argument) : raw(word));
394
+ }
395
+ return { argv, ...unknownCommand === void 0 ? {} : { unknownCommand } };
396
+ }, "maskArgv");
397
+ var NUMBER = /^-?\d+(\.\d+)?$/;
398
+ var PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
399
+ var commandLike = /* @__PURE__ */ __name((word) => /^[a-z][a-z0-9-]{0,31}$/i.test(word) && withoutSecrets(word) === word ? word : REDACTED, "commandLike");
400
+ var maskedValue = /* @__PURE__ */ __name((name, value, choices) => {
401
+ if (isContentKey(name))
402
+ return REDACTED;
403
+ if (name === "profile")
404
+ return PROFILE.test(value) ? value : REDACTED;
405
+ if (name === "json" || name === "fields")
406
+ return /^[a-z0-9_.,]{1,200}$/.test(value) ? value : REDACTED;
407
+ if (choices?.includes(value))
408
+ return value;
409
+ return safeShape(value) ? value : REDACTED;
410
+ }, "maskedValue");
411
+ var safeShape = /* @__PURE__ */ __name((value) => NUMBER.test(value) && !/^\d{11,}$/.test(value) || /^\d+(ms|s|m|h|d|w)$/.test(value) || /^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/.test(value) || value === "true" || value === "false", "safeShape");
412
+ var runContextOf = /* @__PURE__ */ __name(({ bin, command, program, argv, env, recordInput = false, caller }) => {
413
+ const masked = program && argv ? maskArgv(program, argv, { keep: recordInput === true }) : void 0;
414
+ const ifFailed = program && argv && recordInput === "failed" ? maskArgv(program, argv, { keep: true }) : void 0;
415
+ const agent = caller ? caller.agent : agentOf(env);
416
+ return {
417
+ cliCommand: command ? `${bin} ${command}` : bin,
418
+ ...masked ? { argv: masked.argv } : {},
419
+ ...ifFailed ? { argvIfFailed: ifFailed.argv } : {},
420
+ ...masked?.unknownCommand === void 0 ? {} : { unknownCommand: masked.unknownCommand },
421
+ ...agent ? { agent } : {},
422
+ via: caller?.via ?? viaOf(env),
423
+ ...caller?.mcp ? { mcp: caller.mcp } : {}
424
+ };
425
+ }, "runContextOf");
426
+
427
+ export {
428
+ isCliFailure,
429
+ isCommanderFailure,
430
+ failureKey,
431
+ providerErrorKey,
432
+ renderEvent,
433
+ errorDetailOf,
434
+ framesOf,
435
+ endpointTemplate,
436
+ keepsSuccess,
437
+ withCaller,
438
+ currentCaller,
439
+ clientHash,
440
+ agentOf,
441
+ secretInput,
442
+ maskArgv,
443
+ runContextOf
444
+ };