@wirecat/tg-cli 0.119.0 → 0.120.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 (107) hide show
  1. package/contracts/wirecat.json +2 -0
  2. package/dist/bin/tg.js +2 -2
  3. package/dist/bundle/{adapter-NEQQOANM.js → adapter-OJKHXGBC.js} +49 -49
  4. package/dist/bundle/{all-profiles-QFT46FTF.js → all-profiles-URIWNL23.js} +10 -10
  5. package/dist/bundle/{anthropic-UJ4RYCWU.js → anthropic-YUKNB63B.js} +5 -5
  6. package/dist/bundle/{app-server-NE3EL5IK.js → app-server-H5QNHGH4.js} +43 -43
  7. package/dist/bundle/{bot-api-D4H5SCP5.js → bot-api-27GN4Y3D.js} +49 -49
  8. package/dist/bundle/{bot-history-KF2PUMWA.js → bot-history-VVSWLVZM.js} +18 -18
  9. package/dist/bundle/{bun-F7MH5YKA.js → bun-PAAJX3GU.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-FYDJXUHF.js → bun-sqlite-TPEBWFZH.js} +5 -5
  11. package/dist/bundle/{chunk-XM3P7LLT.js → chunk-34DSPJNN.js} +2 -2
  12. package/dist/bundle/{chunk-QD27C3BG.js → chunk-3FPFRDG2.js} +10 -8
  13. package/dist/bundle/{chunk-OG2CG2GS.js → chunk-3GLLWDM6.js} +12 -12
  14. package/dist/bundle/{chunk-FQ3C6DFV.js → chunk-3SANNNWS.js} +3 -3
  15. package/dist/bundle/{chunk-G3MQOH6Z.js → chunk-4JATS2J5.js} +3 -3
  16. package/dist/bundle/{chunk-6OE5I3PR.js → chunk-4OWY7QBE.js} +6 -6
  17. package/dist/bundle/{chunk-QG5U6HCI.js → chunk-4W4EVVL4.js} +4 -4
  18. package/dist/bundle/{chunk-JKKEMVW3.js → chunk-6XHZV7AQ.js} +4 -4
  19. package/dist/bundle/{chunk-IAGX5VFL.js → chunk-7DPWVKYS.js} +4 -4
  20. package/dist/bundle/{chunk-5EHJWIW4.js → chunk-7I6YVQHW.js} +2 -2
  21. package/dist/bundle/{chunk-TKHEVAEG.js → chunk-7N4IUEX3.js} +8 -8
  22. package/dist/bundle/{chunk-HV5YYAJX.js → chunk-7VNV426X.js} +51 -18
  23. package/dist/bundle/{chunk-YMWPRHXG.js → chunk-7WS3ULOO.js} +1185 -426
  24. package/dist/bundle/{chunk-FJKP6MMP.js → chunk-B7B65ZLU.js} +2 -2
  25. package/dist/bundle/{chunk-3EQ7USKJ.js → chunk-CGUDXNJE.js} +2 -2
  26. package/dist/bundle/{chunk-4AACB23H.js → chunk-CLTMVPGT.js} +13 -13
  27. package/dist/bundle/{chunk-FQZSS3AB.js → chunk-CLURRDNU.js} +6 -6
  28. package/dist/bundle/{chunk-RGU2G3KL.js → chunk-CYWV2RLN.js} +4 -4
  29. package/dist/bundle/{chunk-F223KYWG.js → chunk-D2WNQJUQ.js} +1 -1
  30. package/dist/bundle/{chunk-6ERQJRL2.js → chunk-DDKFAUQD.js} +2 -2
  31. package/dist/bundle/{chunk-Z4CGZAFQ.js → chunk-DE7QIEUP.js} +34 -34
  32. package/dist/bundle/{chunk-7VUNJDYU.js → chunk-DH7VKHTZ.js} +4 -4
  33. package/dist/bundle/{chunk-L33G5ARH.js → chunk-DQTQO6PB.js} +1005 -768
  34. package/dist/bundle/{chunk-TEZKCH5B.js → chunk-FATTEYZH.js} +2 -2
  35. package/dist/bundle/{chunk-23JGV5FQ.js → chunk-FPWXG53C.js} +11 -11
  36. package/dist/bundle/{chunk-MDLSI3EN.js → chunk-H5XC2WYO.js} +35 -589
  37. package/dist/bundle/{chunk-UBCLVM7C.js → chunk-HDSKBXAF.js} +3 -3
  38. package/dist/bundle/{chunk-X5PDWCG7.js → chunk-HIBYYKGO.js} +1 -1
  39. package/dist/bundle/{chunk-HPQQ76WF.js → chunk-JJY3TQTM.js} +3 -3
  40. package/dist/bundle/{chunk-D6YTBJY6.js → chunk-JQLGS3SG.js} +1 -1
  41. package/dist/bundle/{chunk-2BAJ6ORN.js → chunk-JSEIT2WO.js} +1 -1
  42. package/dist/bundle/{chunk-BXIPT2BO.js → chunk-KLHOQ6XQ.js} +1 -1
  43. package/dist/bundle/{chunk-CX2WCEQU.js → chunk-KP26Y5OA.js} +1440 -248
  44. package/dist/bundle/{chunk-3K65KTXD.js → chunk-KRCMKFUV.js} +2 -2
  45. package/dist/bundle/{chunk-HGMMRT4G.js → chunk-KTV5Y5EX.js} +2 -2
  46. package/dist/bundle/{chunk-7C6POLLO.js → chunk-KW6JZGG3.js} +1 -1
  47. package/dist/bundle/{chunk-D4Y2KL5V.js → chunk-LLCGOZ44.js} +4 -4
  48. package/dist/bundle/{chunk-FRW3CWC7.js → chunk-LS72R7DN.js} +34 -34
  49. package/dist/bundle/{chunk-NDSRND3E.js → chunk-LVGX7VTD.js} +4 -4
  50. package/dist/bundle/{chunk-5FEEFXJA.js → chunk-MCPOZNWG.js} +1 -1
  51. package/dist/bundle/{chunk-6K5R3YPN.js → chunk-MMPISXSU.js} +2 -2
  52. package/dist/bundle/{chunk-65BWMPCI.js → chunk-MTD6WZKV.js} +2 -2
  53. package/dist/bundle/{chunk-TT4CIXVH.js → chunk-PDYTNTQI.js} +6 -6
  54. package/dist/bundle/{chunk-KBHK5UGL.js → chunk-RX5CJ55S.js} +1 -1
  55. package/dist/bundle/{chunk-QTFXYR5W.js → chunk-S6OC367D.js} +4 -4
  56. package/dist/bundle/{chunk-DQELQ7BL.js → chunk-THJHYMFR.js} +1293 -1525
  57. package/dist/bundle/{chunk-RUNFFBJU.js → chunk-U2TPRUWK.js} +84 -72
  58. package/dist/bundle/{chunk-V5Z2JO6X.js → chunk-U6HEZPCR.js} +19 -19
  59. package/dist/bundle/{chunk-SMHLQEE2.js → chunk-VUBZFMGP.js} +2 -2
  60. package/dist/bundle/{chunk-W2BIBPRU.js → chunk-VUUR2SRS.js} +67 -44
  61. package/dist/bundle/{chunk-KC4MQRAB.js → chunk-WGGSFGNZ.js} +8 -8
  62. package/dist/bundle/{chunk-ZEQ7ONPZ.js → chunk-WLBPNLDF.js} +3 -3
  63. package/dist/bundle/{chunk-QQ3QZFFD.js → chunk-WQ55F4Y3.js} +8 -8
  64. package/dist/bundle/{chunk-72QLHHSO.js → chunk-YBOVL25O.js} +17 -15
  65. package/dist/bundle/{chunk-S3HAFJVC.js → chunk-YDROJG2Y.js} +86 -29
  66. package/dist/bundle/{chunk-CIDFV3IT.js → chunk-YQKEPT22.js} +1 -1
  67. package/dist/bundle/{chunk-XDMJVWWR.js → chunk-ZON7K5QE.js} +3 -3
  68. package/dist/bundle/{chunk-ROOUBFUW.js → chunk-ZRRZTPSB.js} +18152 -17010
  69. package/dist/bundle/command-contract-KW6FNOJO.js +33 -0
  70. package/dist/bundle/{decode-5N4ERCHC.js → decode-RVWSCZW4.js} +5 -5
  71. package/dist/bundle/{dispatch-TBGXBDHE.js → dispatch-U2DW6UI7.js} +8 -8
  72. package/dist/bundle/{echarts-YDEBAMXT.js → echarts-6VNUD3JF.js} +2 -2
  73. package/dist/bundle/{embed-T7H62XFR.js → embed-LWLCQKIK.js} +6 -6
  74. package/dist/bundle/{embedder-AW3O2TR3.js → embedder-CXKHLRJT.js} +9 -9
  75. package/dist/bundle/{entry-L2LJ2VPY.js → entry-HV4NSX3Z.js} +7 -7
  76. package/dist/bundle/{failure-AWHPW2HE.js → failure-HJD7S5UA.js} +2 -2
  77. package/dist/bundle/{first-run-6PBZSRZU.js → first-run-OPI6NIWQ.js} +11 -11
  78. package/dist/bundle/first-screen-BVQLF4LN.js +31 -0
  79. package/dist/bundle/{instructions-C3NJERO7.js → instructions-TK4HXL3A.js} +1 -1
  80. package/dist/bundle/{mcp-CWLASTLV.js → mcp-7KQUJNFN.js} +2 -2
  81. package/dist/bundle/{node-P3CIIYWU.js → node-WFPNBUCU.js} +2 -2
  82. package/dist/bundle/{node-sqlite-YVHMNRVA.js → node-sqlite-L5BRGJLK.js} +6 -6
  83. package/dist/bundle/{oauth-5OQYA2SV.js → oauth-CGVWL35B.js} +7 -7
  84. package/dist/bundle/{open-YGWUVSU7.js → open-HLL55C5S.js} +5 -5
  85. package/dist/bundle/{openai-U45JBQ6F.js → openai-YFCNXIJ4.js} +14 -14
  86. package/dist/bundle/{process-DCYX5EDG.js → process-4A5JP5LO.js} +1 -1
  87. package/dist/bundle/{program-UZBFH2EZ.js → program-IFGQGSUF.js} +52 -52
  88. package/dist/bundle/{prompt-HPVTPTFI.js → prompt-B5FYE2DQ.js} +5 -5
  89. package/dist/bundle/{proxy-transport-D7MCHGSV.js → proxy-transport-ENU2SJYT.js} +5 -5
  90. package/dist/bundle/{recognize-IJCPFJ76.js → recognize-ZHMHGIV3.js} +4 -4
  91. package/dist/bundle/{remote-MWDYQWFW.js → remote-A3W5HE52.js} +7 -7
  92. package/dist/bundle/{rerank-SXG64475.js → rerank-HWJAQOZM.js} +7 -7
  93. package/dist/bundle/{serve-KJQENHEH.js → serve-PP326Q2F.js} +9 -9
  94. package/dist/bundle/{server-MXVXZWN6.js → server-MV6CL63L.js} +35 -35
  95. package/dist/bundle/server-TZGGOJ26.js +60 -0
  96. package/dist/bundle/{state-CKKJWH27.js → state-Y3RJ7ZXB.js} +6 -6
  97. package/dist/bundle/{store-R3BE4V56.js → store-EVNI2MHZ.js} +13 -13
  98. package/dist/bundle/store-maintenance-command-XPQE47RE.js +49 -0
  99. package/dist/bundle/tg.js +13 -13
  100. package/dist/version.d.ts +1 -1
  101. package/dist/version.js +1 -1
  102. package/package.json +3 -3
  103. package/dist/bundle/command-contract-7TGMZRBE.js +0 -33
  104. package/dist/bundle/first-screen-UKCD7D2R.js +0 -31
  105. package/dist/bundle/server-RTMCRKQF.js +0 -60
  106. package/dist/bundle/store-maintenance-command-KDGBSBNU.js +0 -49
  107. /package/dist/bundle/{chunk-DWX4DE2I.js → chunk-YVNHQFLC.js} +0 -0
@@ -2,12 +2,12 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError
5
- } from "./chunk-SMHLQEE2.js";
5
+ } from "./chunk-VUBZFMGP.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/search/languages.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/search/languages.js
11
11
  var LANGUAGES = [
12
12
  { name: "russian", code: "ru", label: "Russian", script: "cyrillic", dictionary: "dictionary-ru" },
13
13
  { name: "english", code: "en", label: "English", script: "latin", dictionary: "dictionary-en" },
@@ -15,12 +15,12 @@ var LANGUAGES = [
15
15
  ];
16
16
  var languagesOf = /* @__PURE__ */ __name((script) => LANGUAGES.filter((one) => one.script === script).map(({ name }) => name), "languagesOf");
17
17
 
18
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/store/normalize.js
18
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/normalize.js
19
19
  var NORMALIZER_VERSION = 1;
20
20
  var fold = /* @__PURE__ */ __name((text) => text.normalize("NFKD").replace(new RegExp("\\p{M}+", "gu"), "").normalize("NFC").toLowerCase(), "fold");
21
21
  var normalize = /* @__PURE__ */ __name((text) => fold(text).replace(new RegExp("\\p{Cc}", "gu"), " ").replace(/\s+/gu, " ").trim(), "normalize");
22
22
 
23
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/search/snowball/base-stemmer.js
23
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/search/snowball/base-stemmer.js
24
24
  var BaseStemmer = class {
25
25
  static {
26
26
  __name(this, "BaseStemmer");
@@ -395,7 +395,7 @@ var BaseStemmer = class {
395
395
  }
396
396
  };
397
397
 
398
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/search/snowball/english-stemmer.js
398
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/search/snowball/english-stemmer.js
399
399
  var a_0 = [
400
400
  ["arsen", -1],
401
401
  ["commun", -1],
@@ -1096,7 +1096,7 @@ var english_stemmer_default = class extends BaseStemmer {
1096
1096
  stemWord = this.stem;
1097
1097
  };
1098
1098
 
1099
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/search/snowball/russian-stemmer.js
1099
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/search/snowball/russian-stemmer.js
1100
1100
  var a_02 = [
1101
1101
  ["\u0432", 1],
1102
1102
  ["\u0438\u0432", 2, 1],
@@ -1519,7 +1519,7 @@ var russian_stemmer_default = class extends BaseStemmer {
1519
1519
  stemWord = this.stem;
1520
1520
  };
1521
1521
 
1522
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/search/snowball/spanish-stemmer.js
1522
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/search/snowball/spanish-stemmer.js
1523
1523
  var a_03 = [
1524
1524
  ["", 6],
1525
1525
  ["\xE1", 1, 1],
@@ -2195,7 +2195,7 @@ var spanish_stemmer_default = class extends BaseStemmer {
2195
2195
  stemWord = this.stem;
2196
2196
  };
2197
2197
 
2198
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/search/stem.js
2198
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/search/stem.js
2199
2199
  var SNOWBALL_VERSION = "3.1.1";
2200
2200
  var CYRILLIC_STEMMERS = [...languagesOf("cyrillic"), "none"];
2201
2201
  var LATIN_STEMMERS = [...languagesOf("latin"), "none"];
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  hostFetch
5
- } from "./chunk-NDSRND3E.js";
5
+ } from "./chunk-LVGX7VTD.js";
6
6
  import {
7
7
  ADMIN_RIGHTS,
8
8
  BotTokenStore,
@@ -16,46 +16,48 @@ import {
16
16
  privateFiles,
17
17
  providerRequest,
18
18
  withSqliteSidecars
19
- } from "./chunk-L33G5ARH.js";
19
+ } from "./chunk-DQTQO6PB.js";
20
20
  import {
21
21
  parseProxy,
22
22
  proxyAddress,
23
23
  proxyError,
24
24
  proxyLabel,
25
25
  proxySetting
26
- } from "./chunk-TEZKCH5B.js";
26
+ } from "./chunk-FATTEYZH.js";
27
27
  import {
28
28
  messengerContext
29
- } from "./chunk-MDLSI3EN.js";
29
+ } from "./chunk-H5XC2WYO.js";
30
30
  import {
31
31
  uploadBlob
32
- } from "./chunk-YMWPRHXG.js";
32
+ } from "./chunk-7WS3ULOO.js";
33
33
  import {
34
34
  asFirstWord,
35
- currentAttempt,
36
35
  environmentOf,
37
36
  fromFile,
38
37
  settingsFor
39
- } from "./chunk-DQELQ7BL.js";
38
+ } from "./chunk-THJHYMFR.js";
39
+ import {
40
+ currentAttempt
41
+ } from "./chunk-KP26Y5OA.js";
40
42
  import {
41
43
  DESKTOP,
42
44
  TG
43
- } from "./chunk-3K65KTXD.js";
45
+ } from "./chunk-KRCMKFUV.js";
44
46
  import {
45
47
  Credentials,
46
48
  pathsAreOverridden,
47
49
  resolvePaths
48
- } from "./chunk-V5Z2JO6X.js";
50
+ } from "./chunk-U6HEZPCR.js";
49
51
  import {
50
52
  optional
51
- } from "./chunk-KC4MQRAB.js";
53
+ } from "./chunk-WGGSFGNZ.js";
52
54
  import {
53
55
  importFrom
54
56
  } from "./chunk-Y5E2WNWB.js";
55
57
  import {
56
58
  CliError,
57
59
  isCliError
58
- } from "./chunk-SMHLQEE2.js";
60
+ } from "./chunk-VUBZFMGP.js";
59
61
  import {
60
62
  __name
61
63
  } from "./chunk-ZVVMGPBJ.js";
@@ -171,7 +173,7 @@ var logOut = /* @__PURE__ */ __name(async (profile, sessionPath, context) => {
171
173
  checks: checkWords("tg", profile),
172
174
  ...keyring ? { keyring } : {}
173
175
  });
174
- const { TelegramAdapter } = await import("./adapter-NEQQOANM.js");
176
+ const { TelegramAdapter } = await import("./adapter-OJKHXGBC.js");
175
177
  const adapter = await TelegramAdapter.open({ credentials, sessionPath, ...through ? { proxy: through.proxy } : {} });
176
178
  try {
177
179
  await adapter.logout();
@@ -234,7 +236,7 @@ var telegramOf = /* @__PURE__ */ __name((command, base) => {
234
236
  throw new CliError(temporary ? "provider_unavailable" : "authentication_error", loggedIn ? `no Telegram app credentials found for profile "${profile}", although it has logged in on this machine \u2014 the keyring is probably out of reach (cron, ssh, an MCP client that trims the environment: set XDG_RUNTIME_DIR); \`tg ${asFirstWord(profile)}doctor\` shows it. Log in again only if they were removed` : `no Telegram app credentials for profile "${profile}" \u2014 run ${setup} in a local terminal first, or sign in from ${desktop}; agents: read \`tg skill show\``, temporary ? { reason: "credentials.unreachable" } : {});
235
237
  }
236
238
  const options = { credentials: resolved, sessionPath, ...connecting };
237
- return environment.adapter ? await environment.adapter(options) : await (await import("./adapter-NEQQOANM.js")).TelegramAdapter.open({
239
+ return environment.adapter ? await environment.adapter(options) : await (await import("./adapter-OJKHXGBC.js")).TelegramAdapter.open({
238
240
  ...options,
239
241
  ...proxyOption(proxy()),
240
242
  diagnostic: /* @__PURE__ */ __name((line) => base.streams.diagnostic(line), "diagnostic"),
@@ -959,7 +961,7 @@ var TELEGRAM_BOT = {
959
961
  const botId = token.split(":", 1)[0] ?? "";
960
962
  if (!/^\d+$/.test(botId))
961
963
  throw new CliError("authentication_error", "the bot token has no valid bot id");
962
- const reader = await (environment.botHistory ?? (await import("./bot-history-KF2PUMWA.js")).openBotHistory)({
964
+ const reader = await (environment.botHistory ?? (await import("./bot-history-VVSWLVZM.js")).openBotHistory)({
963
965
  credentials,
964
966
  sessionPath: botSessionFile(profile, botId, env),
965
967
  token,
@@ -979,7 +981,7 @@ var TELEGRAM_BOT = {
979
981
  return void 0;
980
982
  let personal;
981
983
  try {
982
- personal = environment.adapter ? await environment.adapter({ credentials, sessionPath: personalPath }) : await (await import("./adapter-NEQQOANM.js")).TelegramAdapter.open({
984
+ personal = environment.adapter ? await environment.adapter({ credentials, sessionPath: personalPath }) : await (await import("./adapter-OJKHXGBC.js")).TelegramAdapter.open({
983
985
  credentials,
984
986
  sessionPath: personalPath,
985
987
  checks: words,
@@ -2,19 +2,32 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  openSqlite
5
- } from "./chunk-ROOUBFUW.js";
5
+ } from "./chunk-ZRRZTPSB.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/store/damage.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/damage.js
11
11
  var DERIVED = /* @__PURE__ */ new Set(["mentions", "involvements", "embeddings"]);
12
12
  var named = /* @__PURE__ */ __name((tables) => tables.length <= 5 ? tables.join(", ") : `${tables.slice(0, 5).join(", ")} and ${tables.length - 5} more`, "named");
13
13
  var isDerivedTable = /* @__PURE__ */ __name((table, searchIndexes) => DERIVED.has(table) || table.startsWith("vector_index_") || searchIndexes.some((index) => table === index || table.startsWith(`${index}_`)), "isDerivedTable");
14
14
  var WIRECAT_UNITS = ["memo-*", "mail-*", "tg-*", "max-*", "wirecat-*"];
15
15
  var seen = /* @__PURE__ */ __name((mark) => `\`${mark.command}\` found the store damaged at ${mark.at} (${mark.error})`, "seen");
16
- var explainDamage = /* @__PURE__ */ __name((health, command, mark = null) => {
17
- if (health.ok && !mark)
16
+ var journalSeen = /* @__PURE__ */ __name((store, { seen: seen2, command, at }) => {
17
+ const wal = `${store.replace(/^.*\//, "")}-wal`;
18
+ return seen2 === "shm-without-wal" ? `the store's journal file (${wal}) was missing when \`${command}\` opened the store at ${at}: another program deleted it, or a tool crashed while closing` : `the store's journal file (${wal}) was deleted or replaced by another program while \`${command}\` had the store open (${at})`;
19
+ }, "journalSeen");
20
+ var lossUnknown = /* @__PURE__ */ __name((lastOkAt, gone = false) => {
21
+ const since = lastOkAt ? `since the last deep check that passed (${lastOkAt})` : "since the store was made (no deep check that passed is on record)";
22
+ return `${gone ? "more rows may be gone" : "how many rows were lost is unknown"}: damage can take rows written ${since} without leaving a trace; a sync fetches again what the servers still hold`;
23
+ }, "lossUnknown");
24
+ var stopWriters = /* @__PURE__ */ __name((timers) => ({
25
+ command: timers?.length ? `systemctl --user stop ${timers.join(" ")}` : `systemctl --user stop ${WIRECAT_UNITS.map((unit) => `'${unit}'`).join(" ")}`,
26
+ why: "a tool that writes while the store is recovered damages the new file too",
27
+ destructive: false
28
+ }), "stopWriters");
29
+ var storeDamageReport = /* @__PURE__ */ __name(({ health, command, mark = null, journal = null, lastOkAt = null, holders = null, timers = null, sqlite3Usable = true }) => {
30
+ if (health.ok && !mark && !journal)
18
31
  return null;
19
32
  const indexNames = (health.searchIndexes ?? []).map((index) => index.name);
20
33
  const badIndexes = (health.searchIndexes ?? []).filter((index) => !index.ok).map((index) => index.name);
@@ -23,38 +36,81 @@ var explainDamage = /* @__PURE__ */ __name((health, command, mark = null) => {
23
36
  const derived = [.../* @__PURE__ */ new Set([...tables.filter((table) => isDerivedTable(table, indexNames)), ...badIndexes])];
24
37
  const unopened = health.error !== void 0;
25
38
  const json = (health.invalidJson ?? []).map(({ table, column }) => `${table}.${column}`);
26
- const checked = health.ok ? `${seen(mark)}; the quick check reads too little to see it, and a deep check that passes clears it` : unopened ? `the store file cannot be opened: ${health.error}` : health.checked === "quick" ? "the store file's header or schema is damaged" : `the store file is damaged: ${health.problems ?? 0} problems` + (sources.length ? ` in the data of ${named(sources)}` : "") + (derived.length ? `${sources.length ? ", and" : " in"} the search data of ${named(derived)}` : "") + (json.length ? `; values that are not valid JSON in ${named(json)}` : "");
27
- const what = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
39
+ const damaged = !health.ok || mark !== null;
40
+ const folder = health.path.replace(/\/[^/]*$/, "");
41
+ const checked = !damaged ? `every page of the store reads, but ${journalSeen(health.path, journal)}; what was written into it may be lost` : health.ok ? `${seen(mark)}; the quick check reads too little to see it, and a deep check that passes clears it` : unopened ? `the store file cannot be opened: ${health.error}` : health.checked === "quick" ? "the store file's header or schema is damaged" : `the store file is damaged: ${health.problems ?? 0} problems` + (sources.length ? ` in the data of ${named(sources)}` : "") + (derived.length ? `${sources.length ? ", and" : " in"} the search data of ${named(derived)}` : "") + (json.length ? `; values that are not valid JSON in ${named(json)}` : "");
42
+ const whatHappened = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
28
43
  const impact = [
29
44
  ...sources.length ? [`some rows of ${named(sources)} cannot be read; a recovery keeps every row it can read and names the rest`] : [],
30
45
  ...derived.length ? [`searches may miss results or fail; ${named(derived)} hold nothing that is not elsewhere, and are rebuilt`] : [],
31
46
  ...json.length ? [`a read of a row with a broken JSON value fails ("malformed JSON"); a recovery clears those values`] : [],
32
- mark ? "reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered" : "reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"
47
+ ...!damaged ? ["everything works; rows written while the journal was gone may be missing, and a sync fetches them again"] : mark ? [
48
+ "reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered"
49
+ ] : ["reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"]
50
+ ];
51
+ const likelyCauses = [
52
+ ...journal ? [{ cause: journalSeen(health.path, journal), check: `ls -li --time-style=full-iso ${folder}/` }] : [],
53
+ ...holders?.length ? [
54
+ {
55
+ cause: `two programs wrote the file without seeing each other: ${holders.map(({ name, pid }) => `${name} (process ${pid})`).join(", ")} still ${holders.length === 1 ? "has" : "have"} it open`,
56
+ check: `fuser -v ${health.path}`
57
+ }
58
+ ] : [],
59
+ ...damaged ? [
60
+ {
61
+ cause: "the computer lost power or crashed while a tool was writing",
62
+ check: `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`
63
+ },
64
+ { cause: "the disk filled up while a tool was writing", check: `df -h ${folder}` },
65
+ {
66
+ cause: "the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
67
+ check: `findmnt -T ${folder}`
68
+ },
69
+ {
70
+ cause: "a fault of the disk itself",
71
+ check: "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata"
72
+ }
73
+ ] : []
74
+ ];
75
+ const steps = [
76
+ stopWriters(timers),
77
+ ...(holders ?? []).map(({ pid, name }) => ({
78
+ command: `kill ${pid}`,
79
+ why: `${name} (process ${pid}) has the store open`,
80
+ destructive: true
81
+ })),
82
+ ...damaged && !sqlite3Usable ? [
83
+ {
84
+ command: "sudo apt install sqlite3",
85
+ why: "the recovery copies rows with the sqlite3 program, 3.43 or newer (on macOS: brew install sqlite)",
86
+ destructive: false
87
+ }
88
+ ] : [],
89
+ ...damaged ? [
90
+ {
91
+ command: `${command} store recover run`,
92
+ why: "copies every readable row into a new file and puts it in place of the store; the damaged file is kept beside it, and it prints the syncs that fetch again what was lost",
93
+ destructive: true
94
+ }
95
+ ] : [],
96
+ {
97
+ command: `${command} store recover`,
98
+ why: "checks every page again; a check that passes lifts the damage mark",
99
+ destructive: false
100
+ }
33
101
  ];
34
102
  return {
35
- what,
36
- causes: [
37
- "the computer lost power or crashed, or the disk filled up, while a tool was writing",
38
- "the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
39
- "a fault of the disk itself"
40
- ],
41
- investigate: [
42
- `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`,
43
- "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata",
44
- `df -h ${health.path.replace(/\/[^/]*$/, "")}`,
45
- ...health.checked === "quick" || health.ok ? [`${command} store recover`] : []
46
- ],
103
+ whatHappened,
104
+ likelyCauses,
47
105
  impact,
48
- externalUnaffected: "only this computer's copy is damaged: Telegram, MAX, the mail servers and Google Drive keep their own data, so whatever is lost here can be fetched again by a sync",
49
- steps: [
50
- "stop every timer and server of the WireCat tools; `store recover run` lists the ones still running",
51
- `${command} store recover run`,
52
- "run the fetch commands it prints, then start the timers again"
53
- ]
106
+ externalDataSafe: "only this computer's copy is damaged: Telegram, MAX, WhatsApp, the mail servers and Google Drive keep their own data, so whatever is lost here can be fetched again by a sync",
107
+ lastOkAt,
108
+ loss: lossUnknown(lastOkAt),
109
+ steps
54
110
  };
55
- }, "explainDamage");
111
+ }, "storeDamageReport");
56
112
 
57
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/store/health.js
113
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/health.js
58
114
  import { existsSync, statSync } from "node:fs";
59
115
  var JSON_COLUMNS = {
60
116
  accounts: ["settings"],
@@ -196,11 +252,12 @@ var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) =>
196
252
  }
197
253
  }, "storeHealth");
198
254
 
199
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
255
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
200
256
  var MAX_BYTES = 16 * 1024 * 1024;
201
257
 
202
258
  export {
203
- explainDamage,
259
+ lossUnknown,
260
+ storeDamageReport,
204
261
  invalidJson,
205
262
  QUICK_HEALTH_CHECKS,
206
263
  fts5Tables,
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
8
8
  var instructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => {
9
9
  const all = typeof profile !== "string";
10
10
  const offers = /* @__PURE__ */ __name((key) => all || writes.includes(key), "offers");
@@ -2,16 +2,16 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  alive
5
- } from "./chunk-D6YTBJY6.js";
5
+ } from "./chunk-JQLGS3SG.js";
6
6
  import {
7
7
  resolvePaths,
8
8
  writeSecurely
9
- } from "./chunk-V5Z2JO6X.js";
9
+ } from "./chunk-U6HEZPCR.js";
10
10
  import {
11
11
  __name
12
12
  } from "./chunk-ZVVMGPBJ.js";
13
13
 
14
- // node_modules/.pnpm/@wirecat+cli-core@0.618.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.87.0_commander@15._c25084c4731872baba927966435ce31d/node_modules/@wirecat/cli-core/dist/background/lock.js
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/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");