@wirecat/tg-cli 0.126.0 → 0.128.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 (97) hide show
  1. package/dist/bin/tg.js +2 -2
  2. package/dist/bundle/{adapter-BXU3AVB7.js → adapter-JOI34QLS.js} +43 -43
  3. package/dist/bundle/{all-profiles-G5A6IROO.js → all-profiles-2BZEE7J2.js} +18 -28
  4. package/dist/bundle/{anthropic-SINVEVEM.js → anthropic-NW7DL3S3.js} +2 -2
  5. package/dist/bundle/{app-server-IHIQXPJF.js → app-server-RUTYKELF.js} +39 -54
  6. package/dist/bundle/{bot-api-LGAVVYRM.js → bot-api-DW6NAZAQ.js} +44 -44
  7. package/dist/bundle/{bot-history-5C35FGCD.js → bot-history-FAJ2W42U.js} +12 -12
  8. package/dist/bundle/{bun-2GK3YOP3.js → bun-IVP5LSVI.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-7DGADK3E.js → bun-sqlite-ATPCJ4CT.js} +3 -3
  10. package/dist/bundle/{chunk-Y5DGB7GP.js → chunk-2A3TC52A.js} +7 -7
  11. package/dist/bundle/{chunk-Y4724JRR.js → chunk-2IL4YDGG.js} +2 -2
  12. package/dist/bundle/{chunk-2F2UMQMB.js → chunk-2QHIOPSA.js} +182 -399
  13. package/dist/bundle/{chunk-SXVB2CVR.js → chunk-3UGRMFWK.js} +2 -2
  14. package/dist/bundle/{chunk-QCLMP635.js → chunk-4DSIGS2E.js} +5 -5
  15. package/dist/bundle/{chunk-HPFB4Y7P.js → chunk-5AP25FMW.js} +1 -1
  16. package/dist/bundle/{chunk-CK7DSGIK.js → chunk-7D6LI2N7.js} +322 -11
  17. package/dist/bundle/{chunk-2LN6OJUB.js → chunk-7I5NMVX7.js} +1 -1
  18. package/dist/bundle/{chunk-JQ2RKLPU.js → chunk-AF2XVV5P.js} +648 -239
  19. package/dist/bundle/{chunk-MP47TE77.js → chunk-BVCRDHI2.js} +3 -3
  20. package/dist/bundle/{chunk-7UACPXDC.js → chunk-E56QE3UC.js} +987 -768
  21. package/dist/bundle/{chunk-ACLUVZ4I.js → chunk-EAUHYQUK.js} +40 -48
  22. package/dist/bundle/{chunk-L5PYWQDA.js → chunk-F4UIBEQK.js} +2 -2
  23. package/dist/bundle/{chunk-FYOHGIQP.js → chunk-FHGAJK4I.js} +16 -13
  24. package/dist/bundle/{chunk-AA2NZAUT.js → chunk-G3PL3R45.js} +1 -1
  25. package/dist/bundle/{chunk-W75SKUY4.js → chunk-GYO4WXLG.js} +2 -2
  26. package/dist/bundle/{chunk-GIY56MIB.js → chunk-IHLNXL2D.js} +1 -1
  27. package/dist/bundle/{chunk-MA2XHO4O.js → chunk-IIHCSJV2.js} +641 -389
  28. package/dist/bundle/{chunk-N2JSMP4N.js → chunk-IV2KJQ5F.js} +16 -15
  29. package/dist/bundle/{chunk-QGLB4D7J.js → chunk-J3SX36NE.js} +1 -1
  30. package/dist/bundle/{chunk-XGBXRDJP.js → chunk-JI2PFQFL.js} +5 -5
  31. package/dist/bundle/{chunk-RFDPU4NO.js → chunk-JJGPU24U.js} +4 -4
  32. package/dist/bundle/{chunk-5NLAGTWU.js → chunk-KF2Q776U.js} +7 -7
  33. package/dist/bundle/{chunk-F34EE5Y2.js → chunk-KKZQK6IK.js} +2 -2
  34. package/dist/bundle/{chunk-5GINYFD4.js → chunk-LTADKMP5.js} +1 -1
  35. package/dist/bundle/{chunk-J2BUWK5U.js → chunk-MC6FOTCV.js} +98 -6
  36. package/dist/bundle/{chunk-63DSHUNP.js → chunk-MDGLKMLD.js} +5 -5
  37. package/dist/bundle/{chunk-PJ6FZXUR.js → chunk-MGBVVQTU.js} +2 -2
  38. package/dist/bundle/{chunk-K4DXGJK4.js → chunk-MOUPWPNL.js} +10 -10
  39. package/dist/bundle/{chunk-G4VVBR6U.js → chunk-NXDQXDRN.js} +3 -3
  40. package/dist/bundle/{chunk-SL4S5GFR.js → chunk-ODBK56ZR.js} +1 -1
  41. package/dist/bundle/{chunk-QYLYMOXN.js → chunk-OX6574YV.js} +11 -11
  42. package/dist/bundle/{chunk-4GR5YYGA.js → chunk-PJA43HVE.js} +2 -2
  43. package/dist/bundle/{chunk-GI2ZUNOH.js → chunk-Q3ZO6Q3M.js} +4 -4
  44. package/dist/bundle/{chunk-OXB5P37M.js → chunk-QO4ON2X7.js} +1 -1
  45. package/dist/bundle/{chunk-NJ3FSKSU.js → chunk-QYN5RDTZ.js} +2 -2
  46. package/dist/bundle/{chunk-GOGGRLS6.js → chunk-R4QVV3LN.js} +27 -12
  47. package/dist/bundle/{chunk-AZ7DSHQO.js → chunk-RIGNCUZD.js} +1 -1
  48. package/dist/bundle/{chunk-QMEPKUG3.js → chunk-RZFIQMOA.js} +55 -52
  49. package/dist/bundle/{chunk-G4RCT5RH.js → chunk-SDLJJF7E.js} +12 -12
  50. package/dist/bundle/{chunk-JAKP5RWM.js → chunk-T2CWSFGY.js} +1558 -928
  51. package/dist/bundle/{chunk-W35POPPX.js → chunk-TGUXKG4B.js} +16 -16
  52. package/dist/bundle/{chunk-W725T2V7.js → chunk-TQFUAKU6.js} +1 -1
  53. package/dist/bundle/{chunk-UIFQEXVP.js → chunk-UURJO46N.js} +1 -1
  54. package/dist/bundle/{chunk-AKUBJHE5.js → chunk-WG3BF7SA.js} +1 -1
  55. package/dist/bundle/{chunk-7FL2N6DM.js → chunk-WMF6SL5D.js} +1 -1
  56. package/dist/bundle/{chunk-ZXCQF6XV.js → chunk-WMUPZ3IY.js} +10 -10
  57. package/dist/bundle/{chunk-KSLZEXRF.js → chunk-WPMJQIEU.js} +1 -1
  58. package/dist/bundle/{chunk-QOINWAQD.js → chunk-XYAH6QQO.js} +2 -2
  59. package/dist/bundle/{chunk-DGGAYHLN.js → chunk-YSXDCSBP.js} +33 -23
  60. package/dist/bundle/{chunk-AYEQMXRE.js → chunk-YVV5S2QA.js} +1 -1
  61. package/dist/bundle/{chunk-P2GNIWGG.js → chunk-ZVLYK6CZ.js} +6 -6
  62. package/dist/bundle/{command-contract-ZEYY3ZXK.js → command-contract-3BSXDYBC.js} +13 -13
  63. package/dist/bundle/{command-server-entry-UWY6PQIV.js → command-server-entry-BU3X4XNL.js} +20 -20
  64. package/dist/bundle/{decode-QGMFQ6XX.js → decode-NXB7E46F.js} +2 -2
  65. package/dist/bundle/{echarts-GHU3GEWV.js → echarts-NAXLKJLA.js} +2 -2
  66. package/dist/bundle/{embed-6DMEWQDO.js → embed-LB6ONWHX.js} +3 -3
  67. package/dist/bundle/{embedder-W2L7YZPW.js → embedder-WE7B2RU5.js} +6 -6
  68. package/dist/bundle/{entry-LPEXVFQC.js → entry-W6Y52ZRN.js} +6 -6
  69. package/dist/bundle/{first-run-3UJ6SJF5.js → first-run-NVYNZZA6.js} +5 -5
  70. package/dist/bundle/{first-screen-VCSY5QH5.js → first-screen-Z6TVHK6I.js} +14 -14
  71. package/dist/bundle/{instructions-RUVAH2IS.js → instructions-MRUC57NS.js} +1 -1
  72. package/dist/bundle/{node-RYSNHVBX.js → node-G7PMDYQV.js} +2 -2
  73. package/dist/bundle/{node-sqlite-J6ZL4LUY.js → node-sqlite-RXWQ3SES.js} +4 -4
  74. package/dist/bundle/{oauth-B2QNZNSC.js → oauth-6ZWOL6KX.js} +4 -4
  75. package/dist/bundle/{open-OMUP5P6V.js → open-V7LMZCFI.js} +2 -2
  76. package/dist/bundle/{openai-BT4BP4VQ.js → openai-P472V4ZM.js} +12 -12
  77. package/dist/bundle/{process-HG3QDD54.js → process-GSNPENHL.js} +1 -1
  78. package/dist/bundle/{program-P2VATMKJ.js → program-IELITPKT.js} +46 -46
  79. package/dist/bundle/{prompt-BTIHH3Z4.js → prompt-2CP6CQ5N.js} +2 -2
  80. package/dist/bundle/{recognize-CTSJXPIG.js → recognize-R2DEQ5TC.js} +1 -1
  81. package/dist/bundle/{remote-2FIGCMKL.js → remote-JG3POFES.js} +6 -6
  82. package/dist/bundle/{rerank-TI5SLEF4.js → rerank-TVMR3OLL.js} +4 -4
  83. package/dist/bundle/{serve-IO3IM5C7.js → serve-DBWSMLPH.js} +6 -6
  84. package/dist/bundle/{server-WEPFFTYA.js → server-EXJ2WNZY.js} +37 -35
  85. package/dist/bundle/server-SXNFFAIR.js +61 -0
  86. package/dist/bundle/{sqlite-runtime-CTEYXX7L.js → sqlite-runtime-AWMY7W4Q.js} +3 -3
  87. package/dist/bundle/{state-GFHVDGHM.js → state-HN44BWNQ.js} +3 -3
  88. package/dist/bundle/{store-RCK6HT4F.js → store-GIYS3LHV.js} +9 -9
  89. package/dist/bundle/{store-Y5XC4LEM.js → store-LOVKYQDC.js} +15 -11
  90. package/dist/bundle/store-maintenance-command-X3VOYNCG.js +52 -0
  91. package/dist/bundle/tg.js +3 -3
  92. package/dist/version.d.ts +1 -1
  93. package/dist/version.js +1 -1
  94. package/package.json +2 -2
  95. package/dist/bundle/chunk-BSKYPHLB.js +0 -76
  96. package/dist/bundle/server-RIGXUTKZ.js +0 -62
  97. package/dist/bundle/store-maintenance-command-XH6VMCDU.js +0 -52
@@ -17,7 +17,7 @@ import {
17
17
  __name
18
18
  } from "./chunk-ZVVMGPBJ.js";
19
19
 
20
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/models/options.js
20
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/models/options.js
21
21
  var checkedOptions = /* @__PURE__ */ __name((provider, schema, options) => {
22
22
  const parsed = safeParse(schema, options);
23
23
  if (!parsed.success) {
@@ -27,7 +27,7 @@ var checkedOptions = /* @__PURE__ */ __name((provider, schema, options) => {
27
27
  }, "checkedOptions");
28
28
  var range = /* @__PURE__ */ __name((min, max) => optional(pipe(number(), finite(), minValue(min), maxValue(max))), "range");
29
29
 
30
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/models/types.js
30
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/models/types.js
31
31
  var MAX_MODEL_IMAGE_BYTES = 4 * 1024 * 1024;
32
32
  var validateImages = /* @__PURE__ */ __name((images) => {
33
33
  if (images === void 0)
@@ -5,7 +5,7 @@ import {
5
5
  installFiles,
6
6
  megabytes,
7
7
  sharedModelsDirectory
8
- } from "./chunk-MP47TE77.js";
8
+ } from "./chunk-BVCRDHI2.js";
9
9
  import {
10
10
  importFrom
11
11
  } from "./chunk-Y5E2WNWB.js";
@@ -16,12 +16,12 @@ import {
16
16
  __name
17
17
  } from "./chunk-ZVVMGPBJ.js";
18
18
 
19
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
19
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
20
20
  import { readFileSync as readFileSync2 } from "node:fs";
21
21
  import { availableParallelism } from "node:os";
22
22
  import { basename, join as join2 } from "node:path";
23
23
 
24
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/embeddings/onnx-runtime.js
24
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/embeddings/onnx-runtime.js
25
25
  import { createHash } from "node:crypto";
26
26
  import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
27
27
  import { join } from "node:path";
@@ -678,7 +678,7 @@ var Unzip = /* @__PURE__ */ (function() {
678
678
  return Unzip2;
679
679
  })();
680
680
 
681
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/embeddings/onnx-runtime.js
681
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/embeddings/onnx-runtime.js
682
682
  var ONNX_RUNTIME_VERSION = "1.30.0";
683
683
  var release = /* @__PURE__ */ __name((name, sha256, bytes) => ({
684
684
  name,
@@ -858,7 +858,7 @@ var openSession = /* @__PURE__ */ __name(async (bytes, threads, options = {}) =>
858
858
  return { ort, session: await ort.InferenceSession.create(bytes, options) };
859
859
  }, "openSession");
860
860
 
861
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
861
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
862
862
  var textModelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedModelsDirectory("text", env), "textModelsDirectory");
863
863
  var placedText = /* @__PURE__ */ __name((model, directory) => model.files.map((file) => [file, join2(directory, model.id, file.name)]), "placedText");
864
864
  var isTextModelInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placedText(model, directory)), "isTextModelInstalled");
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  openCache
5
- } from "./chunk-XGBXRDJP.js";
5
+ } from "./chunk-JI2PFQFL.js";
6
6
  import {
7
7
  CliError,
8
8
  isCliError
@@ -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-W725T2V7.js";
5
+ } from "./chunk-TQFUAKU6.js";
6
6
  import {
7
- resolvePaths
7
+ resolvePaths,
8
+ writeSecurely
8
9
  } from "./chunk-NM5GBJME.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.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/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.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/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.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
22
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/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.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/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.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/store/shared-config.js
1061
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/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,
@@ -7,7 +7,7 @@ import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._6e2e147598ef84d8ba691d078b64b926/node_modules/@wirecat/cli-core/dist/cli/input-policy.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.99.0_commander@15._e11817b5a9b273e1a17561462f2db6c9/node_modules/@wirecat/cli-core/dist/cli/input-policy.js
11
11
  var MAX_BUFFERED_INPUT = 16 * 1024 * 1024;
12
12
  var MAX_SECRET_INPUT = 64 * 1024;
13
13
  var policies = /* @__PURE__ */ new WeakMap();