@wirecat/tg-cli 0.117.0 → 0.118.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 (90) hide show
  1. package/dist/bin/tg.js +2 -2
  2. package/dist/bundle/{adapter-VNQ72MBK.js → adapter-4YNP6VCO.js} +39 -39
  3. package/dist/bundle/{all-profiles-3W2UQTCK.js → all-profiles-MIQDYAGO.js} +6 -6
  4. package/dist/bundle/{anthropic-DFUW2KTG.js → anthropic-NTASPJYE.js} +3 -3
  5. package/dist/bundle/{app-server-5XJIMLHB.js → app-server-UJZBJ2SK.js} +36 -36
  6. package/dist/bundle/{bot-api-HRRBF3W6.js → bot-api-JZAD4L3N.js} +40 -40
  7. package/dist/bundle/{bot-history-GBH5XE4N.js → bot-history-OUDHH3NU.js} +12 -12
  8. package/dist/bundle/{bun-ZMOYGG6F.js → bun-EC4HDIRD.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-6FZFMA7K.js → bun-sqlite-A4HJR6KO.js} +2 -2
  10. package/dist/bundle/{chunk-HORGORHK.js → chunk-2KQHUBTV.js} +10 -10
  11. package/dist/bundle/{chunk-6GFUL4OU.js → chunk-2NA5KVP6.js} +15 -12
  12. package/dist/bundle/{chunk-C6TUVV7E.js → chunk-4BV4UMBB.js} +470 -209
  13. package/dist/bundle/{chunk-EZTYJ43A.js → chunk-57LKX6N2.js} +1 -1
  14. package/dist/bundle/{chunk-4JDGN6OD.js → chunk-5IIU7X4S.js} +1 -1
  15. package/dist/bundle/{chunk-2XLKZL6K.js → chunk-5LDWBEWU.js} +42 -26
  16. package/dist/bundle/{chunk-MLHKQDUN.js → chunk-5QYU7B27.js} +268 -153
  17. package/dist/bundle/{chunk-AG6HWPQP.js → chunk-65XV5PPI.js} +2 -2
  18. package/dist/bundle/{chunk-RDSLSV4M.js → chunk-6AXUEJGL.js} +1 -1
  19. package/dist/bundle/{chunk-HWYSRB64.js → chunk-6RI4TEIC.js} +2 -2
  20. package/dist/bundle/{chunk-7Y3RUEVY.js → chunk-6ZMTEUVU.js} +4 -4
  21. package/dist/bundle/{chunk-56Q5JV3Z.js → chunk-76EKXFX2.js} +1 -1
  22. package/dist/bundle/{chunk-TFBHDIGY.js → chunk-BNEP5EOV.js} +17 -3
  23. package/dist/bundle/{chunk-V47NPSSV.js → chunk-CEY43D3A.js} +29 -27
  24. package/dist/bundle/{chunk-G7B5UIE7.js → chunk-DKFC5ZZ3.js} +37 -11
  25. package/dist/bundle/{chunk-UGPZCNYC.js → chunk-DSZJREEO.js} +353 -286
  26. package/dist/bundle/{chunk-L5WNE4WS.js → chunk-EPXVRJAX.js} +1 -1
  27. package/dist/bundle/{chunk-66FZBLRJ.js → chunk-EQJ6NLF5.js} +12 -12
  28. package/dist/bundle/{chunk-B2YPB5AE.js → chunk-FHMK6OK4.js} +8 -8
  29. package/dist/bundle/{chunk-3GRX7WP6.js → chunk-G3RT2EQI.js} +1 -1
  30. package/dist/bundle/{chunk-TG6ZYL4B.js → chunk-GI4MTNA2.js} +7 -7
  31. package/dist/bundle/{chunk-AUBRELCM.js → chunk-GIM37COQ.js} +2 -2
  32. package/dist/bundle/{chunk-SQXB5ZUZ.js → chunk-GLRRCKP6.js} +2 -2
  33. package/dist/bundle/{chunk-VMCQGZIA.js → chunk-GXCJ47SJ.js} +381 -292
  34. package/dist/bundle/{chunk-UYK5AXSW.js → chunk-H6S3C3MH.js} +2 -2
  35. package/dist/bundle/{chunk-VRDVXXXD.js → chunk-HJNRIK5X.js} +6 -6
  36. package/dist/bundle/{chunk-HZZGOLGP.js → chunk-I4TI5HDJ.js} +9 -9
  37. package/dist/bundle/{chunk-MP7M6FFU.js → chunk-JLJKGKU2.js} +5 -5
  38. package/dist/bundle/{chunk-F6KBVIJP.js → chunk-JPVFYMSQ.js} +21 -13
  39. package/dist/bundle/{chunk-Z4QKLHJW.js → chunk-JWPSVS6C.js} +8692 -3312
  40. package/dist/bundle/{chunk-ZPILMEFY.js → chunk-JZETEZHC.js} +7 -20
  41. package/dist/bundle/{chunk-EA2PGDER.js → chunk-KEDHX6XG.js} +2 -2
  42. package/dist/bundle/{chunk-PTIB7NEE.js → chunk-MBH7IKLT.js} +1 -1
  43. package/dist/bundle/{chunk-YIXXH74F.js → chunk-MZNOASAW.js} +1 -1
  44. package/dist/bundle/{chunk-GFHNQBD2.js → chunk-NKFTZVQU.js} +1 -1
  45. package/dist/bundle/{chunk-2452HCIV.js → chunk-NMT2VGEI.js} +2 -2
  46. package/dist/bundle/{chunk-KVTLT4V7.js → chunk-OTQDJUES.js} +5 -5
  47. package/dist/bundle/{chunk-Q7O4CQDO.js → chunk-PB252TT3.js} +1 -1
  48. package/dist/bundle/{chunk-V2T7NYNU.js → chunk-PO74BDER.js} +23 -21
  49. package/dist/bundle/{chunk-X3CD475M.js → chunk-PW3HFIJA.js} +203 -155
  50. package/dist/bundle/{chunk-6HRN7BW6.js → chunk-PWCQC56A.js} +1 -1
  51. package/dist/bundle/{chunk-3RJYLN5V.js → chunk-RG2E7ZQZ.js} +117 -14
  52. package/dist/bundle/{chunk-RDH2QBUE.js → chunk-TMTEWOQS.js} +1 -1
  53. package/dist/bundle/{chunk-7NBUT62O.js → chunk-TSTEZNSX.js} +1 -1
  54. package/dist/bundle/{chunk-XW5C4TI7.js → chunk-Y64SI2RO.js} +47 -1
  55. package/dist/bundle/{chunk-FEKXHILZ.js → chunk-YEOSV6JC.js} +1 -1
  56. package/dist/bundle/{chunk-EL6I4WTB.js → chunk-YPRUWRKE.js} +1 -1
  57. package/dist/bundle/{chunk-M7V5XRM6.js → chunk-ZMUC3UQO.js} +2 -2
  58. package/dist/bundle/{chunk-FAHHERJ7.js → chunk-ZXXTJF4Z.js} +4 -4
  59. package/dist/bundle/{command-contract-KMMHARMR.js → command-contract-7GZ6HAA6.js} +12 -12
  60. package/dist/bundle/{decode-YMSOY2AY.js → decode-NMNPLKNR.js} +2 -2
  61. package/dist/bundle/{echarts-7XS55TQY.js → echarts-S46LEIPS.js} +2 -2
  62. package/dist/bundle/{embed-QTOE7NN3.js → embed-I5ZYHGYC.js} +3 -3
  63. package/dist/bundle/{embedder-KBBRYSNH.js → embedder-LTJI67N2.js} +6 -6
  64. package/dist/bundle/{entry-HGEUYYMX.js → entry-O6BUPXF7.js} +4 -4
  65. package/dist/bundle/{first-run-CSGMEJXY.js → first-run-PMZNCDGD.js} +5 -5
  66. package/dist/bundle/{first-screen-K2PBNJNE.js → first-screen-BGML5DSO.js} +13 -13
  67. package/dist/bundle/{instructions-S6ZXCTFH.js → instructions-AUEGY3VO.js} +1 -1
  68. package/dist/bundle/{node-LCIUWXXG.js → node-XRA7RBCQ.js} +2 -2
  69. package/dist/bundle/{node-sqlite-HL4WY4N2.js → node-sqlite-DEZO6LRS.js} +3 -3
  70. package/dist/bundle/{oauth-U4KIMDKG.js → oauth-DAVC7WCD.js} +4 -4
  71. package/dist/bundle/{open-EH7OS7M7.js → open-DE2YO4T7.js} +2 -2
  72. package/dist/bundle/{openai-W5TB3NA5.js → openai-5BKGAULH.js} +10 -10
  73. package/dist/bundle/{process-3CVLTCTA.js → process-4ZHPNUIQ.js} +1 -1
  74. package/dist/bundle/{program-LOIZTK2P.js → program-EGTKSNB4.js} +42 -42
  75. package/dist/bundle/{prompt-IDNH7N3W.js → prompt-HWCWHHPE.js} +2 -2
  76. package/dist/bundle/{recognize-G5EWYXIF.js → recognize-NG6RXNGF.js} +1 -1
  77. package/dist/bundle/{remote-4XTBZVZD.js → remote-ZKXIIGYH.js} +4 -4
  78. package/dist/bundle/{rerank-OWSTDLZN.js → rerank-TX5QFURV.js} +4 -4
  79. package/dist/bundle/{serve-YCPSEWP3.js → serve-XAS6DECW.js} +6 -6
  80. package/dist/bundle/{server-ODG4A2KK.js → server-CNPIWBYU.js} +28 -28
  81. package/dist/bundle/server-FRTKLHZF.js +60 -0
  82. package/dist/bundle/{state-OL2235G5.js → state-3HTUETTS.js} +3 -3
  83. package/dist/bundle/{store-5AACYNDM.js → store-B5VZWJHN.js} +17 -9
  84. package/dist/bundle/store-maintenance-command-VG3CLELA.js +50 -0
  85. package/dist/bundle/tg.js +3 -3
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +2 -2
  89. package/dist/bundle/server-KELKX6S3.js +0 -60
  90. package/dist/bundle/store-maintenance-command-3J7WZYVN.js +0 -50
@@ -5,7 +5,7 @@ import {
5
5
  id,
6
6
  text,
7
7
  time
8
- } from "./chunk-C6TUVV7E.js";
8
+ } from "./chunk-4BV4UMBB.js";
9
9
  import {
10
10
  array,
11
11
  nullable,
@@ -18,7 +18,7 @@ import {
18
18
  unknown
19
19
  } from "./chunk-EPCFXKTX.js";
20
20
 
21
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/entities/note.js
21
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/entities/note.js
22
22
  var link = {
23
23
  target_text: nullable(text),
24
24
  kind: text,
@@ -7,7 +7,7 @@ import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/cli/input-policy.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/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();
@@ -8,12 +8,12 @@ import {
8
8
  ACCESS_SECONDS,
9
9
  REFRESH_SECONDS,
10
10
  readStored
11
- } from "./chunk-FAHHERJ7.js";
11
+ } from "./chunk-ZXXTJF4Z.js";
12
12
  import {
13
13
  __name
14
14
  } from "./chunk-ZVVMGPBJ.js";
15
15
 
16
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/http/oauth.js
16
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/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";
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  storePath
5
- } from "./chunk-3GRX7WP6.js";
5
+ } from "./chunk-G3RT2EQI.js";
6
6
  import {
7
7
  resolvePaths
8
8
  } from "./chunk-YHZFGUAP.js";
@@ -14,11 +14,11 @@ import {
14
14
  __name
15
15
  } from "./chunk-ZVVMGPBJ.js";
16
16
 
17
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/store/shared-config.js
17
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/store/shared-config.js
18
18
  import { mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
19
19
  import { dirname, join, resolve } from "node:path";
20
20
 
21
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
21
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
22
22
  var DEFAULT_TASK_CATEGORIES = [
23
23
  {
24
24
  name: "taxes",
@@ -773,7 +773,7 @@ var storedTaskCategories = /* @__PURE__ */ __name((json) => {
773
773
  }
774
774
  }, "storedTaskCategories");
775
775
 
776
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/store/shared-config.js
776
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/store/shared-config.js
777
777
  var SECTION = "task_categories";
778
778
  var sharedConfigPath = /* @__PURE__ */ __name((store, env = process.env) => {
779
779
  const paths = resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env });
@@ -7,7 +7,7 @@ import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/models/types.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/models/types.js
11
11
  var MAX_MODEL_IMAGE_BYTES = 4 * 1024 * 1024;
12
12
  var validateImages = /* @__PURE__ */ __name((images) => {
13
13
  if (images === void 0)
@@ -10,10 +10,10 @@ import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/speech/recognize.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/speech/recognize.js
14
14
  import { createRequire } from "node:module";
15
15
 
16
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/speech/ogg-limit.js
16
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/speech/ogg-limit.js
17
17
  var invalid = /* @__PURE__ */ __name(() => new CliError("validation_error", "local transcription needs a complete mono or stereo Ogg Opus recording"), "invalid");
18
18
  var checkOggDuration = /* @__PURE__ */ __name((bytes) => {
19
19
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
@@ -70,7 +70,7 @@ var checkOggDuration = /* @__PURE__ */ __name((bytes) => {
70
70
  throw invalid();
71
71
  }, "checkOggDuration");
72
72
 
73
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/speech/recognize.js
73
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/speech/recognize.js
74
74
  var SAMPLE_RATE = 16e3;
75
75
  var LEAD = SAMPLE_RATE / 2;
76
76
  var toModelRate = /* @__PURE__ */ __name((samples, rate) => {
@@ -195,9 +195,23 @@ var openRecognizer = /* @__PURE__ */ __name((model, path, vadModel) => {
195
195
  });
196
196
  return heard;
197
197
  }, "pieces");
198
+ const piecesUntil = /* @__PURE__ */ __name(async (pcm, signal) => {
199
+ const spans = [];
200
+ cut(vad, pcm, (span) => spans.push(span));
201
+ const heard = [];
202
+ for (const { start, end, samples } of spans) {
203
+ await new Promise((resolve) => setImmediate(resolve));
204
+ signal.throwIfAborted();
205
+ const text = piece(samples);
206
+ if (text)
207
+ heard.push({ start, end, text });
208
+ }
209
+ return heard;
210
+ }, "piecesUntil");
198
211
  return {
199
212
  recognize: /* @__PURE__ */ __name((pcm) => pieces(pcm).map(({ text }) => text).join(" "), "recognize"),
200
213
  pieces,
214
+ piecesUntil,
201
215
  free: /* @__PURE__ */ __name(() => {
202
216
  vad.free();
203
217
  engine.free();
@@ -20,7 +20,7 @@ import {
20
20
  tool,
21
21
  toolKey,
22
22
  toolsFromCommands
23
- } from "./chunk-6GFUL4OU.js";
23
+ } from "./chunk-2NA5KVP6.js";
24
24
  import {
25
25
  CHART_KINDS,
26
26
  CHART_SIZE,
@@ -34,23 +34,23 @@ import {
34
34
  registerPrompts,
35
35
  stdinFieldOf,
36
36
  syncsFirst
37
- } from "./chunk-2XLKZL6K.js";
37
+ } from "./chunk-5LDWBEWU.js";
38
38
  import {
39
39
  agentJson,
40
40
  skillResource
41
- } from "./chunk-3RJYLN5V.js";
41
+ } from "./chunk-RG2E7ZQZ.js";
42
42
  import {
43
43
  instructions
44
- } from "./chunk-GFHNQBD2.js";
44
+ } from "./chunk-NKFTZVQU.js";
45
45
  import {
46
46
  answeredWire
47
- } from "./chunk-PTIB7NEE.js";
47
+ } from "./chunk-MBH7IKLT.js";
48
48
  import {
49
49
  StdioServerTransport,
50
50
  callerOf,
51
51
  callingAgent,
52
52
  serveStdio
53
- } from "./chunk-EA2PGDER.js";
53
+ } from "./chunk-KEDHX6XG.js";
54
54
  import {
55
55
  McpServer,
56
56
  ResourceTemplate
@@ -58,7 +58,7 @@ import {
58
58
  import {
59
59
  connectedFor,
60
60
  guardFor
61
- } from "./chunk-V2T7NYNU.js";
61
+ } from "./chunk-PO74BDER.js";
62
62
  import {
63
63
  capability,
64
64
  dateWindow,
@@ -67,10 +67,10 @@ import {
67
67
  servicesFor,
68
68
  storedDeps,
69
69
  wholeList
70
- } from "./chunk-UGPZCNYC.js";
70
+ } from "./chunk-DSZJREEO.js";
71
71
  import {
72
72
  findCommand
73
- } from "./chunk-UYK5AXSW.js";
73
+ } from "./chunk-H6S3C3MH.js";
74
74
  import {
75
75
  DEFAULT_OUTPUT_BYTES,
76
76
  changesAuthorityAt,
@@ -86,27 +86,29 @@ import {
86
86
  sealed,
87
87
  snakeKeys,
88
88
  typedCommand
89
- } from "./chunk-X3CD475M.js";
89
+ } from "./chunk-PW3HFIJA.js";
90
90
  import {
91
- isCliFailure,
92
91
  withCaller
93
- } from "./chunk-ZPILMEFY.js";
92
+ } from "./chunk-JZETEZHC.js";
94
93
  import {
95
94
  readOnlyLockOf
96
- } from "./chunk-Q7O4CQDO.js";
95
+ } from "./chunk-PB252TT3.js";
97
96
  import {
98
97
  mcpHttpMarker
99
- } from "./chunk-FAHHERJ7.js";
98
+ } from "./chunk-ZXXTJF4Z.js";
100
99
  import {
101
100
  openStore,
102
101
  pdfPreviewLimits
103
- } from "./chunk-Z4QKLHJW.js";
102
+ } from "./chunk-JWPSVS6C.js";
104
103
  import {
105
104
  timezoneOf
106
- } from "./chunk-C6TUVV7E.js";
105
+ } from "./chunk-4BV4UMBB.js";
106
+ import {
107
+ isCliFailure
108
+ } from "./chunk-Y64SI2RO.js";
107
109
  import {
108
110
  warmEmbedders
109
- } from "./chunk-KVTLT4V7.js";
111
+ } from "./chunk-OTQDJUES.js";
110
112
  import {
111
113
  description,
112
114
  integer,
@@ -131,10 +133,10 @@ import {
131
133
  __name
132
134
  } from "./chunk-ZVVMGPBJ.js";
133
135
 
134
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/server.js
136
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/server.js
135
137
  import { randomUUID } from "node:crypto";
136
138
 
137
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/agent-log.js
139
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/agent-log.js
138
140
  var agentLog = /* @__PURE__ */ __name((open) => {
139
141
  let held;
140
142
  return {
@@ -153,7 +155,7 @@ var agentLog = /* @__PURE__ */ __name((open) => {
153
155
  };
154
156
  }, "agentLog");
155
157
 
156
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/resources.js
158
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/resources.js
157
159
  var LISTED = 100;
158
160
  var registerResources = /* @__PURE__ */ __name((server, session, { command, name, limit, recorded, withStore, messenger, guard, assertRead }) => {
159
161
  server.registerResource("chat", new ResourceTemplate(`${command}://chat/{id}`, {
@@ -191,7 +193,7 @@ var registerResources = /* @__PURE__ */ __name((server, session, { command, name
191
193
  });
192
194
  }, "registerResources");
193
195
 
194
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/session.js
196
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/session.js
195
197
  var HARMLESS = /* @__PURE__ */ new Set(["validation_error", "not_found", "permission_error", "confirmation_required", "rate_limited"]);
196
198
  var harmless = /* @__PURE__ */ __name((code) => HARMLESS.has(code), "harmless");
197
199
  var MessengerSession = class {
@@ -266,7 +268,7 @@ var MessengerSession = class {
266
268
  }
267
269
  };
268
270
 
269
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/tools/attachments.js
271
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/tools/attachments.js
270
272
  var attachmentsTools = /* @__PURE__ */ __name((messenger) => {
271
273
  const _command = messenger.app.command;
272
274
  return {
@@ -320,7 +322,7 @@ var attachmentsTools = /* @__PURE__ */ __name((messenger) => {
320
322
  };
321
323
  }, "attachmentsTools");
322
324
 
323
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/tools/messages-photo.js
325
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/tools/messages-photo.js
324
326
  var PHOTO_LIMIT = 512 * 1024;
325
327
  var IMAGE_TYPES = [
326
328
  ["image/jpeg", (b) => b[0] === 255 && b[1] === 216 && b[2] === 255],
@@ -374,7 +376,7 @@ var readUpTo = /* @__PURE__ */ __name(async (file, limit, saveIt) => {
374
376
  return new Uint8Array(Buffer.concat(chunks));
375
377
  }, "readUpTo");
376
378
 
377
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/tools/stats.js
379
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/tools/stats.js
378
380
  var statsTools = /* @__PURE__ */ __name((messenger) => ({
379
381
  stats_charts: tool({
380
382
  title: "A chart from a chat's statistics",
@@ -411,14 +413,14 @@ var statsTools = /* @__PURE__ */ __name((messenger) => ({
411
413
  })
412
414
  }), "statsTools");
413
415
 
414
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/tools.js
416
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/tools.js
415
417
  var pictureTools = /* @__PURE__ */ __name((messenger) => Object.fromEntries(Object.entries({
416
418
  ...messagesPhotoTools(messenger),
417
419
  ...attachmentsTools(messenger),
418
420
  ...statsTools(messenger)
419
421
  }).map(([name, definition]) => [name, { ...definition, input: strictObject(definition.input.entries) }])), "pictureTools");
420
422
 
421
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/server.js
423
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/mcp/server.js
422
424
  var PER_RUN = /* @__PURE__ */ new Set([
423
425
  "streams",
424
426
  "stdin",
@@ -742,7 +744,7 @@ var serveOverStdio = /* @__PURE__ */ __name(async (command, context, messenger,
742
744
  }, "serveOverStdio");
743
745
  var serveOverHttpUntilStopped = /* @__PURE__ */ __name(async (command, context, messenger, options, http) => {
744
746
  const { session, embedders, build, log } = createServer(command, context, messenger, options);
745
- const { serveOverHttp } = await import("./serve-YCPSEWP3.js");
747
+ const { serveOverHttp } = await import("./serve-XAS6DECW.js");
746
748
  const appName = messenger.app.command;
747
749
  const appEnvPrefix = messenger.app.envPrefix;
748
750
  const listening = await serveOverHttp(build, {
@@ -2,18 +2,19 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  openSqlite
5
- } from "./chunk-Z4QKLHJW.js";
5
+ } from "./chunk-JWPSVS6C.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-ZVVMGPBJ.js";
9
9
 
10
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/store/damage.js
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/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
- var explainDamage = /* @__PURE__ */ __name((health, command) => {
16
- if (health.ok)
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)
17
18
  return null;
18
19
  const indexNames = (health.searchIndexes ?? []).map((index) => index.name);
19
20
  const badIndexes = (health.searchIndexes ?? []).filter((index) => !index.ok).map((index) => index.name);
@@ -21,11 +22,14 @@ var explainDamage = /* @__PURE__ */ __name((health, command) => {
21
22
  const sources = tables.filter((table) => !isDerivedTable(table, indexNames));
22
23
  const derived = [.../* @__PURE__ */ new Set([...tables.filter((table) => isDerivedTable(table, indexNames)), ...badIndexes])];
23
24
  const unopened = health.error !== void 0;
24
- const what = 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)}` : "");
25
+ 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;
25
28
  const impact = [
26
29
  ...sources.length ? [`some rows of ${named(sources)} cannot be read; a recovery keeps every row it can read and names the rest`] : [],
27
30
  ...derived.length ? [`searches may miss results or fail; ${named(derived)} hold nothing that is not elsewhere, and are rebuilt`] : [],
28
- "reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"
31
+ ...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"
29
33
  ];
30
34
  return {
31
35
  what,
@@ -38,7 +42,7 @@ var explainDamage = /* @__PURE__ */ __name((health, command) => {
38
42
  `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`,
39
43
  "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata",
40
44
  `df -h ${health.path.replace(/\/[^/]*$/, "")}`,
41
- ...health.checked === "quick" ? [`${command} store recover`] : []
45
+ ...health.checked === "quick" || health.ok ? [`${command} store recover`] : []
42
46
  ],
43
47
  impact,
44
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",
@@ -50,8 +54,27 @@ var explainDamage = /* @__PURE__ */ __name((health, command) => {
50
54
  };
51
55
  }, "explainDamage");
52
56
 
53
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/store/health.js
57
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/store/health.js
54
58
  import { existsSync, statSync } from "node:fs";
59
+ var JSON_COLUMNS = {
60
+ accounts: ["settings"],
61
+ account_identities: ["mail_signals"],
62
+ bot_updates: ["payload"],
63
+ documents: ["front_matter"],
64
+ emails: ["headers"],
65
+ meeting_participants: ["sessions"],
66
+ messages: ["mentions", "reply_to"],
67
+ proposed_actions: ["payload", "result"],
68
+ searches: ["params"],
69
+ tag_consolidations: ["source_member_ids", "survivor_member_ids"],
70
+ task_events: ["changes"]
71
+ };
72
+ var jsonColumns = /* @__PURE__ */ __name((database) => database.prepare(`SELECT m.name AS "table", c.name AS "column", c."notnull" AS required FROM sqlite_master m, pragma_table_info(m.name) c
73
+ WHERE m.type = 'table' AND m.sql NOT LIKE 'CREATE VIRTUAL%' ORDER BY 1, 2`).all().map((row) => ({ table: String(row.table), column: String(row.column), required: Number(row.required) === 1 })).filter(({ table, column }) => column === "metadata" || JSON_COLUMNS[table]?.includes(column)), "jsonColumns");
74
+ var invalidJson = /* @__PURE__ */ __name((database) => jsonColumns(database).map((one) => ({
75
+ ...one,
76
+ rows: Number(database.prepare(`SELECT count(*) AS n FROM "${one.table}" WHERE "${one.column}" IS NOT NULL AND NOT json_valid("${one.column}")`).get()?.n)
77
+ })).filter(({ rows }) => rows > 0), "invalidJson");
55
78
  var QUICK_CHECK_LIMIT = 1e4;
56
79
  var QUICK_HEALTH_CHECKS = "the file header, its size against its page count, and the schema's own pages";
57
80
  var FTS5 = /^\s*CREATE\s+VIRTUAL\s+TABLE\s+\S+\s+USING\s+fts5\s*\(/i;
@@ -157,12 +180,14 @@ var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) =>
157
180
  const lines = checkLines(database);
158
181
  const pagesOk = lines.length === 1 && lines[0] === "ok";
159
182
  const indexes = searchIndexHealth(database);
183
+ const json = pagesOk ? invalidJson(database) : [];
160
184
  return done({
161
- ok: pagesOk && problems.length === 0 && indexes.every((index) => index.ok),
185
+ ok: pagesOk && problems.length === 0 && indexes.every((index) => index.ok) && json.length === 0,
162
186
  file,
163
187
  problems: pagesOk ? 0 : lines.length,
164
188
  damagedTables: pagesOk ? [] : damagedTables(database, lines),
165
- searchIndexes: indexes
189
+ searchIndexes: indexes,
190
+ invalidJson: json
166
191
  });
167
192
  } catch (error) {
168
193
  return done({ ok: false, error: messageOf(error) });
@@ -171,11 +196,12 @@ var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) =>
171
196
  }
172
197
  }, "storeHealth");
173
198
 
174
- // node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
199
+ // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
175
200
  var MAX_BYTES = 16 * 1024 * 1024;
176
201
 
177
202
  export {
178
203
  explainDamage,
204
+ invalidJson,
179
205
  QUICK_HEALTH_CHECKS,
180
206
  fts5Tables,
181
207
  storeHealth