@wirecat/mail-cli 0.29.0 → 0.30.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 (99) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/bin/mail.js +2 -2
  3. package/dist/bundle/{all-profiles-Q4E2LPB4.js → all-profiles-523GLORJ.js} +7 -7
  4. package/dist/bundle/{anthropic-S3N4JDJU.js → anthropic-KKYGROQR.js} +2 -2
  5. package/dist/bundle/{app-server-E44CAPPI.js → app-server-RJR7U5NT.js} +44 -44
  6. package/dist/bundle/{bun-RDYA5FCZ.js → bun-EBQHHLKR.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-FPVHKI24.js → bun-sqlite-LTG2RRSL.js} +3 -3
  8. package/dist/bundle/{chunk-UUM7AF32.js → chunk-26H2HVJD.js} +2 -2
  9. package/dist/bundle/{chunk-3RBUACSJ.js → chunk-2M7PPII5.js} +71 -71
  10. package/dist/bundle/{chunk-FOZXPSHA.js → chunk-3ECFSRLQ.js} +3 -3
  11. package/dist/bundle/{chunk-DIOHJT2W.js → chunk-3HCEKXXB.js} +6 -6
  12. package/dist/bundle/{chunk-FHQ32JKS.js → chunk-4F7WQHDO.js} +1 -1
  13. package/dist/bundle/{chunk-TXDA437R.js → chunk-54JKDFOV.js} +1 -1
  14. package/dist/bundle/{chunk-5ZJ6IHVE.js → chunk-5X5A3CAX.js} +1 -1
  15. package/dist/bundle/{chunk-RFM3AAK5.js → chunk-6C7SA4LD.js} +52 -52
  16. package/dist/bundle/{chunk-7AO73MJZ.js → chunk-A3YXTDTP.js} +15 -15
  17. package/dist/bundle/{chunk-WSHPLO4Q.js → chunk-B3NXAN6J.js} +147 -391
  18. package/dist/bundle/{chunk-7ESXP4TG.js → chunk-BOGGQOVO.js} +1 -1
  19. package/dist/bundle/{chunk-MT5KDBOM.js → chunk-CWAA73PJ.js} +5 -5
  20. package/dist/bundle/{chunk-HKC6ZJA5.js → chunk-D3J4T5OZ.js} +12 -12
  21. package/dist/bundle/{chunk-NWA7JS74.js → chunk-DBI22GQL.js} +378 -293
  22. package/dist/bundle/{chunk-FDGCTY6J.js → chunk-E2SL7HIZ.js} +9 -9
  23. package/dist/bundle/{chunk-45ET53MO.js → chunk-ENKZEQ4Y.js} +2 -2
  24. package/dist/bundle/{chunk-IKTBM64M.js → chunk-F22PLRCG.js} +7 -7
  25. package/dist/bundle/{chunk-7E4KECG4.js → chunk-FL2TKSZY.js} +1 -1
  26. package/dist/bundle/{chunk-ATJANIQR.js → chunk-FYXGD6R6.js} +2 -2
  27. package/dist/bundle/{chunk-2MTIGJHQ.js → chunk-GCSFZTRI.js} +9 -8
  28. package/dist/bundle/{chunk-YAQGWHMH.js → chunk-GDFJKUMK.js} +6 -6
  29. package/dist/bundle/{chunk-YSR2XBDO.js → chunk-GXKFRZUP.js} +3 -3
  30. package/dist/bundle/{chunk-VERUQQZS.js → chunk-HVJ2WQI7.js} +10 -10
  31. package/dist/bundle/{chunk-ODPYXNHI.js → chunk-HZUUVNWC.js} +1 -1
  32. package/dist/bundle/{chunk-KBTVVHFP.js → chunk-IIV43UIC.js} +12 -12
  33. package/dist/bundle/{chunk-VFRI6RF7.js → chunk-IJONJTST.js} +1 -1
  34. package/dist/bundle/{chunk-3AH7UEM6.js → chunk-J5PUHGK2.js} +1 -1
  35. package/dist/bundle/{chunk-NUHUTJTM.js → chunk-JKWNPRZD.js} +1 -1
  36. package/dist/bundle/{chunk-PIKOQWTL.js → chunk-K5FTIIYR.js} +4 -4
  37. package/dist/bundle/{chunk-WZNQ2P7H.js → chunk-KE2RQUQO.js} +1307 -1307
  38. package/dist/bundle/{chunk-Z5D6CRY6.js → chunk-KIZYN3NG.js} +322 -11
  39. package/dist/bundle/{chunk-FM4B357N.js → chunk-L2D5QYI3.js} +2 -2
  40. package/dist/bundle/{chunk-UH7FYLFL.js → chunk-LM4K6K2R.js} +4 -4
  41. package/dist/bundle/{chunk-KSFPMRH6.js → chunk-LN2LWPN2.js} +1 -1
  42. package/dist/bundle/{chunk-UQZJ2GFQ.js → chunk-MP572GP7.js} +2 -2
  43. package/dist/bundle/{chunk-ZPVVSA5R.js → chunk-MVDP7VL6.js} +1 -1
  44. package/dist/bundle/{chunk-BPHLFSUO.js → chunk-NMN7RTX5.js} +15 -15
  45. package/dist/bundle/{chunk-OLTJB5PW.js → chunk-NV2REPY6.js} +1 -1
  46. package/dist/bundle/{chunk-MVGFB7IS.js → chunk-ONA3UI3R.js} +2 -2
  47. package/dist/bundle/{chunk-5PDWUD3W.js → chunk-Q23EEGPC.js} +1 -1
  48. package/dist/bundle/{chunk-ZIFB6KGQ.js → chunk-QGIQ62KV.js} +1554 -940
  49. package/dist/bundle/{chunk-PYOM4J73.js → chunk-R3IFRHZ2.js} +2 -2
  50. package/dist/bundle/{chunk-XEMARUGS.js → chunk-RLPWLGP6.js} +7 -7
  51. package/dist/bundle/{chunk-YRER6N3Y.js → chunk-S2KKQA7O.js} +29 -29
  52. package/dist/bundle/{chunk-VXHL3XI6.js → chunk-SN5V6CKH.js} +2 -2
  53. package/dist/bundle/{chunk-IZEK7JI7.js → chunk-SNZFQ5SS.js} +6 -2
  54. package/dist/bundle/{chunk-D4QALV67.js → chunk-SPWKGRTO.js} +1 -1
  55. package/dist/bundle/{chunk-RGIEG4XK.js → chunk-T7A6HSBF.js} +1 -1
  56. package/dist/bundle/{chunk-6B2BBL35.js → chunk-TIMBTN5Z.js} +5 -5
  57. package/dist/bundle/{chunk-44IAJV2T.js → chunk-U7VYDTXN.js} +16 -16
  58. package/dist/bundle/{chunk-KNTAOY5J.js → chunk-WHS3CTTM.js} +7 -7
  59. package/dist/bundle/{chunk-W32UQL5I.js → chunk-WXQK5RO5.js} +21 -21
  60. package/dist/bundle/{chunk-DMW6J2P3.js → chunk-XGEPAJBY.js} +1 -1
  61. package/dist/bundle/{chunk-BDWOTD7E.js → chunk-YMJXGIYG.js} +80 -80
  62. package/dist/bundle/{chunk-PCYTU7HS.js → chunk-YNI57LTZ.js} +1 -1
  63. package/dist/bundle/{chunk-KTLJ6F2B.js → chunk-ZG2XBWFT.js} +3 -3
  64. package/dist/bundle/{command-contract-TMLXLGVT.js → command-contract-ETECA2AC.js} +15 -15
  65. package/dist/bundle/{command-server-entry-PFUR2W7X.js → command-server-entry-BFXRYTBC.js} +21 -21
  66. package/dist/bundle/{decode-SIVT4JWX.js → decode-4QRYNPD5.js} +2 -2
  67. package/dist/bundle/{dist-YWSF5MHP.js → dist-MHJPECI4.js} +11 -11
  68. package/dist/bundle/{echarts-CABLIXX7.js → echarts-EJXBKCJT.js} +2 -2
  69. package/dist/bundle/{embed-OHENS6RB.js → embed-46WZZMUQ.js} +3 -3
  70. package/dist/bundle/{embedder-JINT4Y4O.js → embedder-56WHJKJE.js} +6 -6
  71. package/dist/bundle/{first-run-LU2MAK2B.js → first-run-CATDBOBV.js} +6 -6
  72. package/dist/bundle/first-screen-WCDR3QUR.js +34 -0
  73. package/dist/bundle/{instructions-3D22PA4T.js → instructions-Z7GVGWXS.js} +1 -1
  74. package/dist/bundle/mail.js +2 -2
  75. package/dist/bundle/{node-42G4RGMW.js → node-L2PVEW3N.js} +2 -2
  76. package/dist/bundle/{node-sqlite-KQZM5M3N.js → node-sqlite-RIGII7U7.js} +4 -4
  77. package/dist/bundle/{oauth-7BNCNKQV.js → oauth-OWT6NYRS.js} +4 -4
  78. package/dist/bundle/{open-ULOQOP7K.js → open-D3SPYL7O.js} +2 -2
  79. package/dist/bundle/{openai-O5AH6VGT.js → openai-IPTZDMFD.js} +12 -12
  80. package/dist/bundle/{process-6D767IDN.js → process-MNZTQ2DA.js} +1 -1
  81. package/dist/bundle/{program-OE7MFRMJ.js → program-QCHTCOCR.js} +1210 -1019
  82. package/dist/bundle/{prompt-WN7EBVKT.js → prompt-BN6AKRWN.js} +2 -2
  83. package/dist/bundle/{recognize-IX33XEXZ.js → recognize-I5TH7OEW.js} +1 -1
  84. package/dist/bundle/{remote-22N3FQUC.js → remote-R324LAUL.js} +6 -6
  85. package/dist/bundle/{rerank-IGX4EFA2.js → rerank-ZMGZCUJV.js} +4 -4
  86. package/dist/bundle/{serve-XWIRR2QZ.js → serve-YUFZSNJC.js} +6 -6
  87. package/dist/bundle/{server-DBS4WC6T.js → server-54ULZ3RA.js} +35 -35
  88. package/dist/bundle/server-UD75CYDG.js +68 -0
  89. package/dist/bundle/{sqlite-runtime-WFBTXXXJ.js → sqlite-runtime-AYQTUQXM.js} +3 -3
  90. package/dist/bundle/{state-4J5ERHJA.js → state-PHEBOYYI.js} +3 -3
  91. package/dist/bundle/{store-YRBX7XLM.js → store-4PHDSXEV.js} +13 -13
  92. package/dist/bundle/{store-YSP2NPRJ.js → store-NGX3A5XT.js} +19 -15
  93. package/dist/bundle/store-maintenance-command-WHBIV6HC.js +58 -0
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +2 -2
  97. package/dist/bundle/first-screen-KZNLKRRQ.js +0 -34
  98. package/dist/bundle/server-D5OTVERP.js +0 -68
  99. package/dist/bundle/store-maintenance-command-SH6IB7S6.js +0 -58
@@ -2,9 +2,10 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  storePath
5
- } from "./chunk-TXDA437R.js";
5
+ } from "./chunk-54JKDFOV.js";
6
6
  import {
7
- resolvePaths
7
+ resolvePaths,
8
+ writeSecurely
8
9
  } from "./chunk-7MEVD5PI.js";
9
10
  import {
10
11
  CliError,
@@ -14,11 +15,295 @@ import {
14
15
  __name
15
16
  } from "./chunk-ZVVMGPBJ.js";
16
17
 
17
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/store/shared-config.js
18
- import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
18
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/store/shared-config.js
19
+ import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
19
20
  import { dirname, join, resolve } from "node:path";
20
21
 
21
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
22
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/domain/config-repair.js
23
+ var REPAIR_WORDS = {
24
+ byte_order_mark: "an invisible byte-order mark at the start",
25
+ comment: "a comment, which JSON does not allow",
26
+ trailing_comma: "a comma before a closing bracket",
27
+ missing_comma: "a missing comma",
28
+ unquoted_key: "a key without double quotes",
29
+ single_quotes: "text in single quotes",
30
+ missing_closer: "the file stops before its closing brackets \u2014 whatever followed this line was already lost"
31
+ };
32
+ var GiveUp = class {
33
+ static {
34
+ __name(this, "GiveUp");
35
+ }
36
+ at;
37
+ why;
38
+ constructor(at, why) {
39
+ this.at = at;
40
+ this.why = why;
41
+ }
42
+ };
43
+ var NUMBER = /^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?/;
44
+ var LITERAL = /^(true|false|null)/;
45
+ var KEY = /^[A-Za-z_$][\w$.-]*/;
46
+ var ENDS_VALUE = /^[\s,\]}/]?$/;
47
+ var repairConfigText = /* @__PURE__ */ __name((text) => {
48
+ try {
49
+ JSON.parse(text);
50
+ return { state: "valid" };
51
+ } catch {
52
+ }
53
+ const fixes = [];
54
+ const lineAt = /* @__PURE__ */ __name((offset) => text.slice(0, offset).split("\n").length, "lineAt");
55
+ const fix = /* @__PURE__ */ __name((kind, offset) => fixes.push({ kind, line: lineAt(offset) }), "fix");
56
+ const giveUp = /* @__PURE__ */ __name((why, offset = at) => {
57
+ throw new GiveUp(offset, why);
58
+ }, "giveUp");
59
+ let at = 0;
60
+ let truncated = false;
61
+ let last = "open";
62
+ let lastEnd = 0;
63
+ const previous = /* @__PURE__ */ __name(() => last, "previous");
64
+ const skip = /* @__PURE__ */ __name(() => {
65
+ for (; ; ) {
66
+ while (/\s/.test(text[at] ?? ""))
67
+ at++;
68
+ if (text.startsWith("//", at)) {
69
+ fix("comment", at);
70
+ while (at < text.length && text[at] !== "\n")
71
+ at++;
72
+ } else if (text.startsWith("/*", at)) {
73
+ const end = text.indexOf("*/", at + 2);
74
+ if (end < 0)
75
+ giveUp("a /* comment is never closed");
76
+ fix("comment", at);
77
+ at = end + 2;
78
+ } else
79
+ return;
80
+ }
81
+ }, "skip");
82
+ const string = /* @__PURE__ */ __name(() => {
83
+ const quote = text[at];
84
+ const start = at;
85
+ if (quote === "'")
86
+ fix("single_quotes", at);
87
+ at++;
88
+ let body = "";
89
+ for (; ; ) {
90
+ if (at >= text.length)
91
+ giveUp("the file stops inside a quoted text", start);
92
+ const char = text[at];
93
+ if (char === quote)
94
+ break;
95
+ if (text.charCodeAt(at) < 32)
96
+ giveUp("a line break inside a quoted text");
97
+ if (char === "\\") {
98
+ const next = text[at + 1] ?? "";
99
+ if (quote === "'" && next === "'")
100
+ body += "'";
101
+ else if (/^["\\/bfnrt]$/.test(next))
102
+ body += `\\${next}`;
103
+ else if (next === "u" && /^[0-9a-fA-F]{4}$/.test(text.slice(at + 2, at + 6))) {
104
+ body += text.slice(at, at + 6);
105
+ at += 4;
106
+ } else
107
+ giveUp("an escape JSON has no meaning for");
108
+ at += 2;
109
+ continue;
110
+ }
111
+ body += char === '"' ? '\\"' : char;
112
+ at++;
113
+ }
114
+ at++;
115
+ return JSON.parse(`"${body}"`);
116
+ }, "string");
117
+ const key = /* @__PURE__ */ __name(() => {
118
+ const char = text[at] ?? "";
119
+ if (char === '"' || char === "'")
120
+ return string();
121
+ const word = KEY.exec(text.slice(at))?.[0];
122
+ if (!word)
123
+ return giveUp("something other than a key where a key should be");
124
+ fix("unquoted_key", at);
125
+ at += word.length;
126
+ return word;
127
+ }, "key");
128
+ const scalar = /* @__PURE__ */ __name(() => {
129
+ const char = text[at] ?? "";
130
+ if (char === '"' || char === "'")
131
+ return { json: JSON.stringify(string()) };
132
+ const word = (NUMBER.exec(text.slice(at)) ?? LITERAL.exec(text.slice(at)))?.[0];
133
+ if (!word || !ENDS_VALUE.test(text[at + word.length] ?? ""))
134
+ return giveUp("a value that is not JSON \u2014 text needs quotes, and only true, false and null go without");
135
+ if (at + word.length === text.length && NUMBER.test(word))
136
+ giveUp("the file stops inside a number");
137
+ at += word.length;
138
+ return { json: word };
139
+ }, "scalar");
140
+ const members = /* @__PURE__ */ __name((close, one) => {
141
+ const out = [];
142
+ at++;
143
+ last = "open";
144
+ let comma = -1;
145
+ for (; ; ) {
146
+ skip();
147
+ if (truncated)
148
+ return out;
149
+ if (at >= text.length) {
150
+ if (previous() === "close")
151
+ giveUp("the file stops after a closing bracket, so which brackets are missing has two readings");
152
+ if (previous() === "comma")
153
+ fix("trailing_comma", comma);
154
+ fix("missing_closer", text.length);
155
+ truncated = true;
156
+ return out;
157
+ }
158
+ const char = text[at];
159
+ if (char === close) {
160
+ if (previous() === "comma")
161
+ fix("trailing_comma", comma);
162
+ at++;
163
+ last = "close";
164
+ return out;
165
+ }
166
+ if (char === "}" || char === "]")
167
+ giveUp(`a ${char} where ${close} should close`);
168
+ if (char === ",") {
169
+ if (previous() !== "value" && previous() !== "close")
170
+ giveUp("a comma with nothing before it");
171
+ comma = at;
172
+ at++;
173
+ last = "comma";
174
+ continue;
175
+ }
176
+ if (previous() === "value" || previous() === "close") {
177
+ if (lineAt(at) === lineAt(lastEnd))
178
+ giveUp("two entries on one line with no comma between them");
179
+ fix("missing_comma", lastEnd);
180
+ }
181
+ out.push(one());
182
+ }
183
+ }, "members");
184
+ const value = /* @__PURE__ */ __name(() => {
185
+ const char = text[at] ?? "";
186
+ let node;
187
+ if (char === "{") {
188
+ const seen = /* @__PURE__ */ new Set();
189
+ node = {
190
+ object: members("}", () => {
191
+ const start = at;
192
+ const name = key();
193
+ if (seen.has(name))
194
+ giveUp("a key appears twice in one object", start);
195
+ seen.add(name);
196
+ skip();
197
+ if (at >= text.length)
198
+ giveUp("the file stops after a key, before its value");
199
+ if (text[at] !== ":")
200
+ giveUp("a key with no colon after it");
201
+ at++;
202
+ skip();
203
+ if (at >= text.length)
204
+ giveUp("the file stops after a key, before its value");
205
+ return [name, value()];
206
+ })
207
+ };
208
+ } else if (char === "[") {
209
+ node = {
210
+ array: members("]", () => {
211
+ return value();
212
+ })
213
+ };
214
+ } else
215
+ node = scalar();
216
+ if (!truncated) {
217
+ last = "json" in node ? "value" : "close";
218
+ lastEnd = at;
219
+ }
220
+ return node;
221
+ }, "value");
222
+ try {
223
+ if (text.includes("\0") || text.includes(String.fromCharCode(65533)))
224
+ giveUp("the file is not text", 0);
225
+ if (text.charCodeAt(0) === 65279) {
226
+ fix("byte_order_mark", 0);
227
+ at = 1;
228
+ }
229
+ skip();
230
+ if (text[at] !== "{")
231
+ giveUp(at >= text.length ? "the file is empty" : "the file does not start with {");
232
+ const root = value();
233
+ skip();
234
+ if (at < text.length)
235
+ giveUp("more text after the closing }");
236
+ const repaired = `${serialise(root, "")}
237
+ `;
238
+ JSON.parse(repaired);
239
+ return { state: "repaired", text: repaired, fixes };
240
+ } catch (error) {
241
+ if (!(error instanceof GiveUp))
242
+ throw error;
243
+ const before = text.slice(0, error.at).split("\n");
244
+ return {
245
+ state: "refused",
246
+ line: before.length,
247
+ column: (before.at(-1)?.length ?? 0) + 1,
248
+ why: error.why
249
+ };
250
+ }
251
+ }, "repairConfigText");
252
+ var serialise = /* @__PURE__ */ __name((node, indent) => {
253
+ if ("json" in node)
254
+ return node.json;
255
+ const inner = `${indent} `;
256
+ const parts = "object" in node ? node.object.map(([name, item]) => `${inner}${JSON.stringify(name)}: ${serialise(item, inner)}`) : node.array.map((item) => `${inner}${serialise(item, inner)}`);
257
+ const [open, close] = "object" in node ? ["{", "}"] : ["[", "]"];
258
+ return parts.length === 0 ? `${open}${close}` : `${open}
259
+ ${parts.join(",\n")}
260
+ ${indent}${close}`;
261
+ }, "serialise");
262
+ var SAFE_REPAIRS = /* @__PURE__ */ new Set([
263
+ "byte_order_mark",
264
+ "comment",
265
+ "trailing_comma",
266
+ "missing_comma"
267
+ ]);
268
+ var FIX_FOR = {
269
+ unquoted_key: /* @__PURE__ */ __name((line) => `put the key on line ${line} in double quotes`, "unquoted_key"),
270
+ single_quotes: /* @__PURE__ */ __name((line) => `use double quotes for the text on line ${line}`, "single_quotes"),
271
+ missing_closer: /* @__PURE__ */ __name((line) => `add the closing } or ] the file lacks after line ${line}, and check that nothing after it was lost`, "missing_closer")
272
+ };
273
+ var FIX_FOR_REFUSAL = [
274
+ [/no comma between/, (line, before) => `add a comma after ${before} on line ${line}`],
275
+ [/no colon after/, (line) => `add a colon after the key on line ${line}`],
276
+ [/comma with nothing before/, (line) => `remove the extra comma on line ${line}`],
277
+ [/inside a quoted text/, (line) => `close the quotes on line ${line}`],
278
+ [/value that is not JSON/, (line) => `put the value on line ${line} in double quotes`],
279
+ [/key appears twice/, (line) => `keep one of the two keys named on line ${line}; the file holds both`]
280
+ ];
281
+ var shown = /* @__PURE__ */ __name((line) => line.trim().replace(/("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^\s"',:{}[\]]+)(\s*:)?/g, (token, _value, key) => key || /^(true|false|null)$/.test(token) ? token : '"\u2026"'), "shown");
282
+ var explainBrokenJson = /* @__PURE__ */ __name((text, result) => {
283
+ const lines = text.replace(/^\uFEFF/u, "").split(/\r?\n/);
284
+ const around = /* @__PURE__ */ __name((line2) => {
285
+ const near = lines[line2 - 1]?.trim() ? lines[line2 - 1] : lines[line2 - 2];
286
+ return near ? ` \u2014 near \`${shown(near)}\`` : "";
287
+ }, "around");
288
+ if (result.state === "repaired") {
289
+ const asked = result.fixes.find((one) => !SAFE_REPAIRS.has(one.kind)) ?? result.fixes[0];
290
+ if (!asked)
291
+ return "it is not valid JSON";
292
+ const fix2 = FIX_FOR[asked.kind]?.(asked.line);
293
+ return `line ${asked.line} has ${REPAIR_WORDS[asked.kind]}${around(asked.line)}${fix2 ? `; likely fix: ${fix2}` : ""}`;
294
+ }
295
+ if (result.state === "valid")
296
+ return "it is valid JSON";
297
+ const { line, why } = result;
298
+ const column = line === 1 && text.charCodeAt(0) === 65279 ? result.column - 1 : result.column;
299
+ const head = (lines[line - 1] ?? "").slice(0, column - 1);
300
+ const entry = head.slice(Math.max(head.lastIndexOf(","), head.lastIndexOf("{"), head.lastIndexOf("[")) + 1);
301
+ const before = shown(entry) || shown(lines[line - 2] ?? "");
302
+ const fix = FIX_FOR_REFUSAL.find(([pattern]) => pattern.test(why))?.[1](line, `\`${before}\``);
303
+ return `line ${line}, column ${column}: ${why}${around(line)}; likely fix: ${fix ?? "correct that part by hand"}`;
304
+ }, "explainBrokenJson");
305
+
306
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
22
307
  var DEFAULT_TASK_CATEGORIES = [
23
308
  {
24
309
  name: "taxes",
@@ -773,7 +1058,7 @@ var storedTaskCategories = /* @__PURE__ */ __name((json) => {
773
1058
  }
774
1059
  }, "storedTaskCategories");
775
1060
 
776
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/store/shared-config.js
1061
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/store/shared-config.js
777
1062
  var SECTION = "task_categories";
778
1063
  var sharedConfigPath = /* @__PURE__ */ __name((store, env = process.env) => {
779
1064
  const paths = resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env });
@@ -781,10 +1066,33 @@ var sharedConfigPath = /* @__PURE__ */ __name((store, env = process.env) => {
781
1066
  return join(paths.config, "config.json");
782
1067
  return resolve(store) === resolve(storePath({ ...env, MESSAGING_STORE: void 0 })) ? join(paths.config, "config.json") : join(dirname(store), "config.json");
783
1068
  }, "sharedConfigPath");
1069
+ var backupPathFor = /* @__PURE__ */ __name((file) => {
1070
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
1071
+ let path = `${file}.bak-${stamp}`;
1072
+ for (let n = 2; existsSync(path); n++)
1073
+ path = `${file}.bak-${stamp}-${n}`;
1074
+ return path;
1075
+ }, "backupPathFor");
1076
+ var mended = /* @__PURE__ */ __name((path, bytes) => {
1077
+ const text = bytes.toString("utf8");
1078
+ const result = repairConfigText(text);
1079
+ if (result.state === "repaired" && result.fixes.every((one) => SAFE_REPAIRS.has(one.kind))) {
1080
+ try {
1081
+ writeSecurely(backupPathFor(path), bytes, statSync(path).mode & 511);
1082
+ writeSecurely(path, result.text, 384);
1083
+ } catch {
1084
+ }
1085
+ return JSON.parse(result.text);
1086
+ }
1087
+ throw new CliError("configuration_error", `${path} is not valid JSON, ${explainBrokenJson(text, result)}`, {
1088
+ reason: "config.invalid_json",
1089
+ file: path
1090
+ });
1091
+ }, "mended");
784
1092
  var readJson = /* @__PURE__ */ __name((path) => {
785
- let text;
1093
+ let bytes;
786
1094
  try {
787
- text = readFileSync(path, "utf8");
1095
+ bytes = readFileSync(path);
788
1096
  } catch (error) {
789
1097
  if (error.code === "ENOENT")
790
1098
  return void 0;
@@ -792,9 +1100,9 @@ var readJson = /* @__PURE__ */ __name((path) => {
792
1100
  }
793
1101
  let parsed;
794
1102
  try {
795
- parsed = JSON.parse(text.replace(/^\uFEFF/u, ""));
796
- } catch (error) {
797
- throw new CliError("configuration_error", `${path} is not valid JSON: ${error.message}`);
1103
+ parsed = JSON.parse(bytes.toString("utf8"));
1104
+ } catch {
1105
+ parsed = mended(path, bytes);
798
1106
  }
799
1107
  if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
800
1108
  throw new CliError("configuration_error", `${path} must hold a JSON object`);
@@ -869,6 +1177,8 @@ var taskCategoriesReader = /* @__PURE__ */ __name((path) => {
869
1177
  }, "taskCategoriesReader");
870
1178
 
871
1179
  export {
1180
+ REPAIR_WORDS,
1181
+ repairConfigText,
872
1182
  DEFAULT_TASK_CATEGORIES,
873
1183
  FALLBACK_CATEGORY,
874
1184
  unlistedNote,
@@ -876,6 +1186,7 @@ export {
876
1186
  taskCategoryValue,
877
1187
  storedTaskCategories,
878
1188
  sharedConfigPath,
1189
+ backupPathFor,
879
1190
  readTaskCategoryEdits,
880
1191
  applyTaskCategoryEdits,
881
1192
  editsFrom,
@@ -8,12 +8,12 @@ import {
8
8
  ACCESS_SECONDS,
9
9
  REFRESH_SECONDS,
10
10
  readStored
11
- } from "./chunk-PIKOQWTL.js";
11
+ } from "./chunk-K5FTIIYR.js";
12
12
  import {
13
13
  __name
14
14
  } from "./chunk-ZVVMGPBJ.js";
15
15
 
16
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/mcp/http/oauth.js
16
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/mcp/http/oauth.js
17
17
  import { createHash, randomBytes, randomInt, timingSafeEqual } from "node:crypto";
18
18
  import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
19
19
  import { dirname } from "node:path";
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  commandPathOf,
5
5
  outputOf
6
- } from "./chunk-KTLJ6F2B.js";
6
+ } from "./chunk-ZG2XBWFT.js";
7
7
  import {
8
8
  wrapAnsi
9
9
  } from "./chunk-HTQTIKWP.js";
@@ -17,7 +17,7 @@ import {
17
17
  environmentOf,
18
18
  metaOf,
19
19
  takesProfile
20
- } from "./chunk-WSHPLO4Q.js";
20
+ } from "./chunk-B3NXAN6J.js";
21
21
  import {
22
22
  writes
23
23
  } from "./chunk-ECZSYLSL.js";
@@ -28,7 +28,7 @@ import {
28
28
  __name
29
29
  } from "./chunk-ZVVMGPBJ.js";
30
30
 
31
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/cli/help/command-help.js
31
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/help/command-help.js
32
32
  var ARGUMENT_KINDS = {
33
33
  chat: "chat",
34
34
  chats: "chat",
@@ -221,7 +221,7 @@ var installCommandHelp = /* @__PURE__ */ __name((program, { profile = true } = {
221
221
  command.addHelpText("after", () => commandHelpText(command));
222
222
  }, "installCommandHelp");
223
223
 
224
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/cli/help/first-screen.js
224
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/help/first-screen.js
225
225
  var WIRECAT_TOOLS = [
226
226
  {
227
227
  command: "tg",
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
8
8
  var botInstructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => [
9
9
  `The owner's ${name} bot "${profile}", through the official Bot API \u2014 not the owner's personal account. What it writes, people see as the bot.`,
10
10
  "Use these tools to read the chats this bot is in, find a message or a person, and \u2014 when the profile allows \u2014 write as the bot.",
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  readSharedSection,
5
5
  writeSharedSection
6
- } from "./chunk-Z5D6CRY6.js";
6
+ } from "./chunk-KIZYN3NG.js";
7
7
  import {
8
8
  CliError
9
9
  } from "./chunk-7KCBPAQS.js";
@@ -11,7 +11,7 @@ import {
11
11
  __name
12
12
  } from "./chunk-ZVVMGPBJ.js";
13
13
 
14
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/cli/setup-answers.js
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/setup-answers.js
15
15
  var PERMISSION_ANSWERS = ["readonly", "allow"];
16
16
  var QUESTIONS = ["languages", "tools", "permissions"];
17
17
  var SECTION = "setup";
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/runs/secrets.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/runs/secrets.js
8
8
  var SECRET_WORDS = /* @__PURE__ */ new Set([
9
9
  "authorization",
10
10
  "cookie",
@@ -6,13 +6,13 @@ import {
6
6
  agentArguments,
7
7
  agentJson,
8
8
  commandAvailability
9
- } from "./chunk-FDGCTY6J.js";
9
+ } from "./chunk-E2SL7HIZ.js";
10
10
  import {
11
11
  failureContext
12
- } from "./chunk-IZEK7JI7.js";
12
+ } from "./chunk-SNZFQ5SS.js";
13
13
  import {
14
14
  callerOf
15
- } from "./chunk-VXHL3XI6.js";
15
+ } from "./chunk-SN5V6CKH.js";
16
16
  import {
17
17
  QUERY_ARGUMENT,
18
18
  lentConnection,
@@ -20,10 +20,10 @@ import {
20
20
  refuseLacking,
21
21
  servicesFor,
22
22
  storeModeDeps
23
- } from "./chunk-NWA7JS74.js";
23
+ } from "./chunk-DBI22GQL.js";
24
24
  import {
25
25
  MAX_BUFFERED_INPUT
26
- } from "./chunk-FHQ32JKS.js";
26
+ } from "./chunk-4F7WQHDO.js";
27
27
  import {
28
28
  DEFAULT_OUTPUT_BYTES,
29
29
  ENTITIES,
@@ -38,32 +38,32 @@ import {
38
38
  refuseStoreChange,
39
39
  sealed,
40
40
  startRecording
41
- } from "./chunk-WSHPLO4Q.js";
41
+ } from "./chunk-B3NXAN6J.js";
42
42
  import {
43
43
  authorityAllowed,
44
44
  botApiAllowed,
45
45
  keyForCommand,
46
46
  levelFor,
47
47
  readKeysForCommand
48
- } from "./chunk-2MTIGJHQ.js";
48
+ } from "./chunk-GCSFZTRI.js";
49
49
  import {
50
50
  currentCaller,
51
51
  keepsSuccess,
52
52
  runContextOf,
53
53
  withCaller
54
- } from "./chunk-XEMARUGS.js";
54
+ } from "./chunk-RLPWLGP6.js";
55
55
  import {
56
56
  enclosingTraceId,
57
57
  inRun,
58
58
  newRunId,
59
59
  traceOf
60
- } from "./chunk-BDWOTD7E.js";
60
+ } from "./chunk-YMJXGIYG.js";
61
61
  import {
62
62
  queryDescription
63
- } from "./chunk-3RBUACSJ.js";
63
+ } from "./chunk-2M7PPII5.js";
64
64
  import {
65
65
  storeDamaged
66
- } from "./chunk-NUHUTJTM.js";
66
+ } from "./chunk-JKWNPRZD.js";
67
67
  import {
68
68
  captureStreams,
69
69
  traceIdOf
@@ -115,7 +115,7 @@ import {
115
115
  __name
116
116
  } from "./chunk-ZVVMGPBJ.js";
117
117
 
118
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/mcp/agent.js
118
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/mcp/agent.js
119
119
  import { Readable } from "node:stream";
120
120
 
121
121
  // node_modules/.pnpm/@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/lint.js
@@ -3287,7 +3287,7 @@ var VOCABULARY = defineVocabulary({
3287
3287
  ]
3288
3288
  });
3289
3289
 
3290
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/mcp/agent.js
3290
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/mcp/agent.js
3291
3291
  var TYPES = new Map(VOCABULARY.flags.map((flag) => [flag.name, flag.type]));
3292
3292
  var snake = /* @__PURE__ */ __name((name) => name.replaceAll("|", "_or_").replace(/[^a-z0-9]+/gi, "_"), "snake");
3293
3293
  var longOf = /* @__PURE__ */ __name((option) => option.flags.match(/--[a-z0-9][a-z0-9-]*/)?.[0], "longOf");
@@ -3514,7 +3514,7 @@ var runCommandForAgent = /* @__PURE__ */ __name(async (program, path, input, ctx
3514
3514
  }
3515
3515
  }, "runCommandForAgent");
3516
3516
 
3517
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/mcp/tool.js
3517
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/mcp/tool.js
3518
3518
  var limit = optional(pipe(number(), integer(), minValue(1), maxValue(100), description("how many")));
3519
3519
  var page = optional(pipe(number(), integer(), minValue(1), description("which page, from 1")));
3520
3520
  var message = pipe(
@@ -3773,7 +3773,7 @@ var failed = /* @__PURE__ */ __name((error, errors, effects) => {
3773
3773
  return mcpErrorResult(JSON.parse(agentJson(errorObjectOf(storeDamaged(error), context))));
3774
3774
  }, "failed");
3775
3775
 
3776
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/mcp/surface.js
3776
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/mcp/surface.js
3777
3777
  import { randomUUID } from "node:crypto";
3778
3778
  var MATCHES = 8;
3779
3779
  var ANSWER = answerSchema();
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/store/driver.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/store/driver.js
8
8
  var TIME_LIMIT_FUNCTION = "wc_time_limit";
9
9
  var TimeLimitReached = class extends Error {
10
10
  static {
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  alive
5
- } from "./chunk-7ESXP4TG.js";
5
+ } from "./chunk-BOGGQOVO.js";
6
6
  import {
7
7
  resolvePaths,
8
8
  writeSecurely
@@ -11,7 +11,7 @@ import {
11
11
  __name
12
12
  } from "./chunk-ZVVMGPBJ.js";
13
13
 
14
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/background/lock.js
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/background/lock.js
15
15
  import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
16
16
  import { dirname, join } from "node:path";
17
17
  var lockPath = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "serve", `${profile}.lock`), "lockPath");
@@ -132,7 +132,7 @@ var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
132
132
  }, "parseRateLimitReset");
133
133
  var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
134
134
 
135
- // node_modules/.pnpm/@wirecat+cli-core@0.657.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_6ef853dd58e888f20a16b5fe978b097f/node_modules/@wirecat/cli-core/dist/models/endpoint.js
135
+ // node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/models/endpoint.js
136
136
  var endpoint = /* @__PURE__ */ __name((value) => {
137
137
  try {
138
138
  const url = new URL(value);