chatlab-cli 0.31.2-beta.1 → 0.31.2

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 (92) hide show
  1. package/dist/{chat-command-V6NYTTPD.mjs → chat-command-QPL4GNHP.mjs} +8 -8
  2. package/dist/{chunk-7TDYBU5L.mjs → chunk-3SZWD7UM.mjs} +4 -4
  3. package/dist/{chunk-WL2ISRYH.mjs → chunk-64FKPYPJ.mjs} +11 -11
  4. package/dist/{chunk-LWC7JQ2W.mjs → chunk-6JKKHPXY.mjs} +2 -2
  5. package/dist/{chunk-67HNEIKY.mjs → chunk-BSSR4ZYW.mjs} +1878 -2038
  6. package/dist/chunk-BSSR4ZYW.mjs.map +1 -0
  7. package/dist/{chunk-ZF67S6RY.mjs → chunk-F2NZ7HAY.mjs} +2 -2
  8. package/dist/{chunk-5G2INROS.mjs → chunk-GYPBWKAU.mjs} +356 -483
  9. package/dist/chunk-GYPBWKAU.mjs.map +1 -0
  10. package/dist/{chunk-XZ5FFDLX.mjs → chunk-IK7GJTGY.mjs} +131 -117
  11. package/dist/chunk-IK7GJTGY.mjs.map +1 -0
  12. package/dist/{chunk-HUKZ2PBC.mjs → chunk-OAXVKNPN.mjs} +2 -2
  13. package/dist/{chunk-54GVCXHZ.mjs → chunk-OQ6N4PDD.mjs} +2 -2
  14. package/dist/{chunk-SJQVAKFA.mjs → chunk-S5PQM5J4.mjs} +4 -5
  15. package/dist/chunk-S5PQM5J4.mjs.map +1 -0
  16. package/dist/{chunk-OIZ64ET3.mjs → chunk-ZCXCHKQV.mjs} +3 -3
  17. package/dist/cli.mjs +8 -8
  18. package/dist/contacts-worker.mjs +2 -2
  19. package/dist/global-insight-worker.mjs +1 -1
  20. package/dist/{http-AMDWRKOH.mjs → http-NOEWVWCP.mjs} +11 -11
  21. package/dist/{import-WIJHB4LH.mjs → import-RS3HW7ZM.mjs} +7 -7
  22. package/dist/index.mjs +11 -11
  23. package/dist/{mcp-NC5YNTM5.mjs → mcp-7F3G47Z4.mjs} +8 -8
  24. package/dist/people-relationships-worker.mjs +2 -2
  25. package/dist/semantic-index-worker.mjs +1 -1
  26. package/dist/{src-UY4GCVNF.mjs → src-MNH5S423.mjs} +6 -22
  27. package/dist/{stream-import-JKQYRISL.mjs → stream-import-BPCHGRAN.mjs} +7 -7
  28. package/dist/{worker-runtime-KKUOJJTN.mjs → worker-runtime-TTAXGQ5R.mjs} +5 -5
  29. package/dist-web/assets/{ActionToolsPanel-BL0GQR6r.css → ActionToolsPanel-CbWhu_Uv.css} +1 -1
  30. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CvvNqXuh.js +110 -0
  31. package/dist-web/assets/{BufferResource-i1amDJTV.js → BufferResource-Dh2kaMuP.js} +1 -1
  32. package/dist-web/assets/{CanvasRenderer-DGa7AjdC.js → CanvasRenderer-B8hHywwz.js} +1 -1
  33. package/dist-web/assets/{Filter-BTlq0yU-.js → Filter-Bap1KMW6.js} +1 -1
  34. package/dist-web/assets/{MessageExportModal-D9C5t_zF.js → MessageExportModal-H3-LAaXY.js} +1 -1
  35. package/dist-web/assets/{PageHeader-BEWr2vsg.js → PageHeader-CzTV_lyM.js} +1 -1
  36. package/dist-web/assets/{RelationshipGalaxyCanvas-CSgPNRif.js → RelationshipGalaxyCanvas-C6ZoUZNc.js} +3 -3
  37. package/dist-web/assets/{RelationshipGalaxyThreeCanvas-CBAnU8vN.js → RelationshipGalaxyThreeCanvas-DV6B-7XB.js} +1 -1
  38. package/dist-web/assets/{RenderTargetSystem-Ctlu222X.js → RenderTargetSystem-Dpgyoac_.js} +1 -1
  39. package/dist-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-D5vov0eO.js → TimeSelect.vue_vue_type_script_setup_true_lang--Tbo7p-l.js} +1 -1
  40. package/dist-web/assets/{WebGLRenderer-D2Zvhmcw.js → WebGLRenderer-DICnsAm5.js} +1 -1
  41. package/dist-web/assets/{WebGPURenderer-BOtP6h9o.js → WebGPURenderer-Bf0gkRK9.js} +1 -1
  42. package/dist-web/assets/{base-BMjDSaj6.js → base-D5T8QZ8b.js} +1 -1
  43. package/dist-web/assets/{browserAll-BhwLvWQY.js → browserAll-DcoCy7xY.js} +1 -1
  44. package/dist-web/assets/{dateFormat-dteP1INW.js → dateFormat-BDOkdsCR.js} +1 -1
  45. package/dist-web/assets/{electron-DCgfulPE.js → electron-CmhzSjaH.js} +1 -1
  46. package/dist-web/assets/{fetch-BbU4MPPu.js → fetch-BJka-sCN.js} +1 -1
  47. package/dist-web/assets/{fetch-CubnKpLG.js → fetch-BddgpyKJ.js} +1 -1
  48. package/dist-web/assets/{fetch-DgXWr9nB.js → fetch-C1mlq5VY.js} +1 -1
  49. package/dist-web/assets/{fetch-rJA9qLvd.js → fetch-CNz28Lv5.js} +1 -1
  50. package/dist-web/assets/{fetch-D5BrGna5.js → fetch-D71bG6Fc.js} +1 -1
  51. package/dist-web/assets/{fetch-CpvfCafG.js → fetch-D8xv4lgE.js} +1 -1
  52. package/dist-web/assets/{fetch-6q7oz7ZO.js → fetch-DfTM4Dah.js} +1 -1
  53. package/dist-web/assets/{fetch-B_0HIxs5.js → fetch-DtcNaN3d.js} +1 -1
  54. package/dist-web/assets/{fetch-DvZuLuTE.js → fetch-TATpgXht.js} +1 -1
  55. package/dist-web/assets/{fetch-BxHdB6X1.js → fetch-dI5w8lYN.js} +1 -1
  56. package/dist-web/assets/{index-DXcFBsM1.js → index-Bs4ZX2-v.js} +1 -1
  57. package/dist-web/assets/index-CF59LLOG.js +25 -0
  58. package/dist-web/assets/{index-CLijvqy3.js → index-CJ3WtSLo.js} +1 -1
  59. package/dist-web/assets/{index-D7aKwT6w.js → index-CJS6FVuj.js} +3 -3
  60. package/dist-web/assets/{index-Cj2GU1SR.js → index-CY5yJhCJ.js} +1 -1
  61. package/dist-web/assets/{index-DaZnh1zP.js → index-DClxj4T2.js} +2 -2
  62. package/dist-web/assets/{index-BoalB6nB.js → index-De3ImZb9.js} +1 -1
  63. package/dist-web/assets/{index-CUzFFw5b.js → index-Dp3gCHpK.js} +1 -1
  64. package/dist-web/assets/{index-Bp5VKUF9.js → index-DphjBwbA.js} +1 -1
  65. package/dist-web/assets/{index-Bs15Yc7I.js → index-Dtbu8m1o.js} +1 -1
  66. package/dist-web/assets/{index-t6s0nOlb.js → index-a1ZrlsKo.js} +1 -1
  67. package/dist-web/assets/{index-BfGKlkx3.js → index-qZ7jnIna.js} +2 -2
  68. package/dist-web/assets/{index-WJCmqKnh.js → index-soX5gDgh.js} +1 -1
  69. package/dist-web/assets/{web-BoTDL3HM.js → web-H9T1dZys.js} +1 -1
  70. package/dist-web/assets/{webworkerAll-c0ZvpENM.js → webworkerAll-D1Kui8G8.js} +1 -1
  71. package/dist-web/index.html +1 -1
  72. package/package.json +1 -1
  73. package/dist/chunk-5G2INROS.mjs.map +0 -1
  74. package/dist/chunk-67HNEIKY.mjs.map +0 -1
  75. package/dist/chunk-SJQVAKFA.mjs.map +0 -1
  76. package/dist/chunk-XZ5FFDLX.mjs.map +0 -1
  77. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DVdpZpfD.js +0 -110
  78. package/dist-web/assets/index-DeV8SAiM.js +0 -25
  79. /package/dist/{chat-command-V6NYTTPD.mjs.map → chat-command-QPL4GNHP.mjs.map} +0 -0
  80. /package/dist/{chunk-7TDYBU5L.mjs.map → chunk-3SZWD7UM.mjs.map} +0 -0
  81. /package/dist/{chunk-WL2ISRYH.mjs.map → chunk-64FKPYPJ.mjs.map} +0 -0
  82. /package/dist/{chunk-LWC7JQ2W.mjs.map → chunk-6JKKHPXY.mjs.map} +0 -0
  83. /package/dist/{chunk-ZF67S6RY.mjs.map → chunk-F2NZ7HAY.mjs.map} +0 -0
  84. /package/dist/{chunk-HUKZ2PBC.mjs.map → chunk-OAXVKNPN.mjs.map} +0 -0
  85. /package/dist/{chunk-54GVCXHZ.mjs.map → chunk-OQ6N4PDD.mjs.map} +0 -0
  86. /package/dist/{chunk-OIZ64ET3.mjs.map → chunk-ZCXCHKQV.mjs.map} +0 -0
  87. /package/dist/{http-AMDWRKOH.mjs.map → http-NOEWVWCP.mjs.map} +0 -0
  88. /package/dist/{import-WIJHB4LH.mjs.map → import-RS3HW7ZM.mjs.map} +0 -0
  89. /package/dist/{mcp-NC5YNTM5.mjs.map → mcp-7F3G47Z4.mjs.map} +0 -0
  90. /package/dist/{src-UY4GCVNF.mjs.map → src-MNH5S423.mjs.map} +0 -0
  91. /package/dist/{stream-import-JKQYRISL.mjs.map → stream-import-BPCHGRAN.mjs.map} +0 -0
  92. /package/dist/{worker-runtime-KKUOJJTN.mjs.map → worker-runtime-TTAXGQ5R.mjs.map} +0 -0
@@ -9,7 +9,7 @@ import {
9
9
  createEmptyContactsDiagnostics,
10
10
  normalizeContactsTimeRangePreset,
11
11
  resolveContactsTimeRange
12
- } from "./chunk-ZF67S6RY.mjs";
12
+ } from "./chunk-F2NZ7HAY.mjs";
13
13
  import {
14
14
  PEOPLE_RELATIONSHIPS_ALGORITHM_VERSION,
15
15
  buildPeopleRelationshipsNeighborhoodGraph,
@@ -18,7 +18,7 @@ import {
18
18
  computePeopleRelationshipsSnapshot,
19
19
  normalizePeopleRelationshipsTimeRangePreset,
20
20
  resolvePeopleRelationshipsTimeRange
21
- } from "./chunk-HUKZ2PBC.mjs";
21
+ } from "./chunk-OAXVKNPN.mjs";
22
22
  import {
23
23
  ANNUAL_SUMMARY_ALGORITHM_VERSION
24
24
  } from "./chunk-YAQLYL52.mjs";
@@ -42,9 +42,7 @@ import {
42
42
  clearSessionIndex,
43
43
  collectPosTagStats,
44
44
  deleteAnnualSummarySnapshots,
45
- deleteAuthProfile,
46
45
  deleteMember,
47
- deleteMembers,
48
46
  generateIncrementalSessionIndex,
49
47
  generateMessageKey,
50
48
  generateSessionIndex,
@@ -95,7 +93,7 @@ import {
95
93
  updateSessionOwnerId,
96
94
  writeAnnualSummarySnapshot,
97
95
  writeAuthProfile
98
- } from "./chunk-XZ5FFDLX.mjs";
96
+ } from "./chunk-IK7GJTGY.mjs";
99
97
  import {
100
98
  __commonJS,
101
99
  __export,
@@ -711,8 +709,8 @@ var require_FilterBase = __commonJS({
711
709
  var FilterBase = class _FilterBase extends Transform {
712
710
  static stringFilter(string, separator) {
713
711
  return (stack) => {
714
- const path33 = stack.join(separator);
715
- return path33.length === string.length && path33 === string || path33.length > string.length && path33.substr(0, string.length) === string && path33.substr(string.length, separator.length) === separator;
712
+ const path31 = stack.join(separator);
713
+ return path31.length === string.length && path31 === string || path31.length > string.length && path31.substr(0, string.length) === string && path31.substr(string.length, separator.length) === separator;
716
714
  };
717
715
  }
718
716
  static regExpFilter(regExp, separator) {
@@ -1166,12 +1164,12 @@ var require_Assembler = __commonJS({
1166
1164
  return (this.stack.length >> 1) + (this.done ? 0 : 1);
1167
1165
  }
1168
1166
  get path() {
1169
- const path33 = [];
1167
+ const path31 = [];
1170
1168
  for (let i = 0; i < this.stack.length; i += 2) {
1171
1169
  const key = this.stack[i + 1];
1172
- path33.push(key === null ? this.stack[i].length : key);
1170
+ path31.push(key === null ? this.stack[i].length : key);
1173
1171
  }
1174
- return path33;
1172
+ return path31;
1175
1173
  }
1176
1174
  dropToLevel(level) {
1177
1175
  if (level < this.depth) {
@@ -1453,7 +1451,7 @@ var require_pend = __commonJS({
1453
1451
  var require_fd_slicer = __commonJS({
1454
1452
  "../../packages/node-runtime/node_modules/yauzl/fd-slicer.js"(exports) {
1455
1453
  "use strict";
1456
- var fs37 = __require("fs");
1454
+ var fs35 = __require("fs");
1457
1455
  var util = __require("util");
1458
1456
  var stream = __require("stream");
1459
1457
  var Readable = stream.Readable;
@@ -1473,7 +1471,7 @@ var require_fd_slicer = __commonJS({
1473
1471
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
1474
1472
  var self = this;
1475
1473
  self.pend.go(function(cb) {
1476
- fs37.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
1474
+ fs35.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
1477
1475
  cb();
1478
1476
  callback(err, bytesRead, buffer2);
1479
1477
  });
@@ -1490,7 +1488,7 @@ var require_fd_slicer = __commonJS({
1490
1488
  self.refCount -= 1;
1491
1489
  if (self.refCount < 0) throw new Error("invalid unref");
1492
1490
  if (self.refCount > 0) return;
1493
- fs37.close(self.fd, onCloseDone);
1491
+ fs35.close(self.fd, onCloseDone);
1494
1492
  function onCloseDone(err) {
1495
1493
  if (err) {
1496
1494
  self.emit("error", err);
@@ -1522,7 +1520,7 @@ var require_fd_slicer = __commonJS({
1522
1520
  }
1523
1521
  self.context.pend.go(function(cb) {
1524
1522
  var buffer = Buffer.allocUnsafe(toRead);
1525
- fs37.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
1523
+ fs35.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
1526
1524
  if (err) {
1527
1525
  self.destroy(err);
1528
1526
  } else if (bytesRead === 0) {
@@ -1884,7 +1882,7 @@ var require_crc32 = __commonJS({
1884
1882
  var require_yauzl = __commonJS({
1885
1883
  "../../packages/node-runtime/node_modules/yauzl/index.js"(exports) {
1886
1884
  "use strict";
1887
- var fs37 = __require("fs");
1885
+ var fs35 = __require("fs");
1888
1886
  var zlib = __require("zlib");
1889
1887
  var fd_slicer = require_fd_slicer();
1890
1888
  var util = __require("util");
@@ -1909,39 +1907,39 @@ var require_yauzl = __commonJS({
1909
1907
  exports.Entry = Entry;
1910
1908
  exports.LocalFileHeader = LocalFileHeader;
1911
1909
  exports.RandomAccessReader = RandomAccessReader;
1912
- function openPromise2(path33, options2) {
1913
- return new Promise((resolve4, reject) => {
1914
- open(path33, { ...options2, lazyEntries: true }, function(err, zipfile) {
1910
+ function openPromise2(path31, options2) {
1911
+ return new Promise((resolve2, reject) => {
1912
+ open(path31, { ...options2, lazyEntries: true }, function(err, zipfile) {
1915
1913
  if (err) return reject(err);
1916
- resolve4(zipfile);
1914
+ resolve2(zipfile);
1917
1915
  });
1918
1916
  });
1919
1917
  }
1920
1918
  function fromFdPromise(fd, options2) {
1921
- return new Promise((resolve4, reject) => {
1919
+ return new Promise((resolve2, reject) => {
1922
1920
  fromFd(fd, { ...options2, lazyEntries: true }, function(err, zipfile) {
1923
1921
  if (err) return reject(err);
1924
- resolve4(zipfile);
1922
+ resolve2(zipfile);
1925
1923
  });
1926
1924
  });
1927
1925
  }
1928
1926
  function fromBufferPromise(buffer, options2) {
1929
- return new Promise((resolve4, reject) => {
1927
+ return new Promise((resolve2, reject) => {
1930
1928
  fromBuffer(buffer, { ...options2, lazyEntries: true }, function(err, zipfile) {
1931
1929
  if (err) return reject(err);
1932
- resolve4(zipfile);
1930
+ resolve2(zipfile);
1933
1931
  });
1934
1932
  });
1935
1933
  }
1936
1934
  function fromRandomAccessReaderPromise(reader, totalSize, options2) {
1937
- return new Promise((resolve4, reject) => {
1935
+ return new Promise((resolve2, reject) => {
1938
1936
  fromRandomAccessReader(reader, totalSize, { ...options2, lazyEntries: true }, function(err, zipfile) {
1939
1937
  if (err) return reject(err);
1940
- resolve4(zipfile);
1938
+ resolve2(zipfile);
1941
1939
  });
1942
1940
  });
1943
1941
  }
1944
- function open(path33, options2, callback) {
1942
+ function open(path31, options2, callback) {
1945
1943
  if (typeof options2 === "function") {
1946
1944
  callback = options2;
1947
1945
  options2 = null;
@@ -1953,10 +1951,10 @@ var require_yauzl = __commonJS({
1953
1951
  if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
1954
1952
  if (options2.strictFileNames == null) options2.strictFileNames = false;
1955
1953
  if (callback == null) callback = defaultCallback;
1956
- fs37.open(path33, "r", function(err, fd) {
1954
+ fs35.open(path31, "r", function(err, fd) {
1957
1955
  if (err) return callback(err);
1958
1956
  fromFd(fd, options2, function(err2, zipfile) {
1959
- if (err2) fs37.close(fd, defaultCallback);
1957
+ if (err2) fs35.close(fd, defaultCallback);
1960
1958
  callback(err2, zipfile);
1961
1959
  });
1962
1960
  });
@@ -1973,7 +1971,7 @@ var require_yauzl = __commonJS({
1973
1971
  if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
1974
1972
  if (options2.strictFileNames == null) options2.strictFileNames = false;
1975
1973
  if (callback == null) callback = defaultCallback;
1976
- fs37.fstat(fd, function(err, stats) {
1974
+ fs35.fstat(fd, function(err, stats) {
1977
1975
  if (err) return callback(err);
1978
1976
  var reader = new fd_slicer.FdSlicer(fd);
1979
1977
  fromRandomAccessReader(reader, stats.size, options2, callback);
@@ -2221,15 +2219,15 @@ var require_yauzl = __commonJS({
2221
2219
  if (self.autoClose) self.close();
2222
2220
  }
2223
2221
  function onEntry(entry) {
2224
- let { resolve: resolve4 } = pendingResolveReject;
2222
+ let { resolve: resolve2 } = pendingResolveReject;
2225
2223
  pendingResolveReject = null;
2226
- resolve4({ value: entry });
2224
+ resolve2({ value: entry });
2227
2225
  }
2228
2226
  function onEnd() {
2229
- let { resolve: resolve4 } = pendingResolveReject;
2227
+ let { resolve: resolve2 } = pendingResolveReject;
2230
2228
  pendingResolveReject = null;
2231
2229
  cleanup();
2232
- resolve4({ done: true });
2230
+ resolve2({ done: true });
2233
2231
  }
2234
2232
  function onError(err) {
2235
2233
  let { reject } = pendingResolveReject;
@@ -2242,9 +2240,9 @@ var require_yauzl = __commonJS({
2242
2240
  return this;
2243
2241
  },
2244
2242
  next() {
2245
- const promise = new Promise((resolve4, reject) => {
2243
+ const promise = new Promise((resolve2, reject) => {
2246
2244
  if (pendingResolveReject != null) throw new Error("next() called before previous Promise was resolved.");
2247
- pendingResolveReject = { resolve: resolve4, reject };
2245
+ pendingResolveReject = { resolve: resolve2, reject };
2248
2246
  });
2249
2247
  self.readEntry();
2250
2248
  return promise;
@@ -2433,26 +2431,26 @@ var require_yauzl = __commonJS({
2433
2431
  });
2434
2432
  };
2435
2433
  ZipFile.prototype.openReadStreamPromise = function(entry, options2) {
2436
- return new Promise((resolve4, reject) => {
2434
+ return new Promise((resolve2, reject) => {
2437
2435
  this.openReadStream(entry, options2, function(err, readStream) {
2438
2436
  if (err) return reject(err);
2439
- resolve4(readStream);
2437
+ resolve2(readStream);
2440
2438
  });
2441
2439
  });
2442
2440
  };
2443
2441
  ZipFile.prototype.openReadStreamLowLevelPromise = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize) {
2444
- return new Promise((resolve4, reject) => {
2442
+ return new Promise((resolve2, reject) => {
2445
2443
  this.openReadStream(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, function(err, readStream) {
2446
2444
  if (err) return reject(err);
2447
- resolve4(readStream);
2445
+ resolve2(readStream);
2448
2446
  });
2449
2447
  });
2450
2448
  };
2451
2449
  ZipFile.prototype.readLocalFileHeaderPromise = function(entry, options2) {
2452
- return new Promise((resolve4, reject) => {
2450
+ return new Promise((resolve2, reject) => {
2453
2451
  this.readLocalFileHeader(entry, options2, function(err, localFileHeader) {
2454
2452
  if (err) return reject(err);
2455
- resolve4(localFileHeader);
2453
+ resolve2(localFileHeader);
2456
2454
  });
2457
2455
  });
2458
2456
  };
@@ -2740,73 +2738,6 @@ var require_yauzl = __commonJS({
2740
2738
  }
2741
2739
  });
2742
2740
 
2743
- // ../../packages/node-runtime/src/temp-workspace.ts
2744
- import * as fs from "fs";
2745
- import * as os from "os";
2746
- import * as path from "path";
2747
- var CHATLAB_TEMP_ROOT_ENV = "CHATLAB_TEMP_ROOT";
2748
- var CHATLAB_TEMP_SCOPES = /* @__PURE__ */ new Set(["tests", "runtime", "imports", "merge", "sync", "parser", "build", "bench"]);
2749
- function optionsEnv(options2) {
2750
- return options2.env ?? process.env;
2751
- }
2752
- function resolveChatLabTempRoot(options2 = {}) {
2753
- const envRoot = optionsEnv(options2)[CHATLAB_TEMP_ROOT_ENV]?.trim();
2754
- if (envRoot) return path.resolve(envRoot);
2755
- const platform2 = options2.platform ?? process.platform;
2756
- const systemTempDir = options2.systemTempDir ?? os.tmpdir();
2757
- return path.resolve(platform2 === "darwin" ? "/private/tmp/chatlab" : path.join(systemTempDir, "chatlab"));
2758
- }
2759
- function ensurePrivateOwnedDirectory(dirPath, label) {
2760
- fs.mkdirSync(dirPath, { recursive: true, mode: 448 });
2761
- const stats = fs.lstatSync(dirPath);
2762
- if (stats.isSymbolicLink()) {
2763
- throw new Error(`${label} must not be a symbolic link: ${dirPath}`);
2764
- }
2765
- if (!stats.isDirectory()) {
2766
- throw new Error(`${label} must be a directory: ${dirPath}`);
2767
- }
2768
- if (typeof process.getuid === "function" && stats.uid !== process.getuid()) {
2769
- throw new Error(`${label} is owned by another user: ${dirPath}`);
2770
- }
2771
- if (process.platform !== "win32") {
2772
- fs.chmodSync(dirPath, 448);
2773
- }
2774
- }
2775
- function ensureChatLabTempRoot(options2 = {}) {
2776
- const root = resolveChatLabTempRoot(options2);
2777
- ensurePrivateOwnedDirectory(root, "ChatLab temp root");
2778
- optionsEnv(options2)[CHATLAB_TEMP_ROOT_ENV] = root;
2779
- return root;
2780
- }
2781
- function assertValidScope(scope) {
2782
- if (!CHATLAB_TEMP_SCOPES.has(scope)) {
2783
- throw new Error(`Invalid ChatLab temp scope: ${scope}`);
2784
- }
2785
- }
2786
- function assertValidPrefix(prefix) {
2787
- if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(prefix)) {
2788
- throw new Error(`Invalid ChatLab temp prefix: ${prefix}`);
2789
- }
2790
- }
2791
- function getChatLabTempScopeDir(scope, options2 = {}) {
2792
- assertValidScope(scope);
2793
- const scopeDir = path.join(ensureChatLabTempRoot(options2), scope);
2794
- ensurePrivateOwnedDirectory(scopeDir, "ChatLab temp scope");
2795
- return scopeDir;
2796
- }
2797
- function createChatLabTempDir(scope, prefix, options2 = {}) {
2798
- assertValidPrefix(prefix);
2799
- return fs.mkdtempSync(path.join(getChatLabTempScopeDir(scope, options2), prefix));
2800
- }
2801
- function removeChatLabTempDir(dirPath, scope, options2 = {}) {
2802
- const scopeDir = path.resolve(getChatLabTempScopeDir(scope, options2));
2803
- const resolvedDir = path.resolve(dirPath);
2804
- if (path.dirname(resolvedDir) !== scopeDir) {
2805
- throw new Error(`Refusing to remove non-owned ChatLab temp directory: ${resolvedDir}`);
2806
- }
2807
- fs.rmSync(resolvedDir, { recursive: true, force: true });
2808
- }
2809
-
2810
2741
  // ../../packages/node-runtime/src/import/write-parse-result.ts
2811
2742
  function writeParseResultToDb(db, meta, members, messages) {
2812
2743
  let messageCount = 0;
@@ -2921,28 +2852,28 @@ function writeParseResultToDb(db, meta, members, messages) {
2921
2852
  }
2922
2853
 
2923
2854
  // ../../packages/parser/src/index.ts
2924
- import * as fs18 from "fs";
2925
- import * as path14 from "path";
2855
+ import * as fs17 from "fs";
2856
+ import * as path13 from "path";
2926
2857
 
2927
2858
  // ../../packages/parser/src/sniffer.ts
2928
- import * as fs2 from "fs";
2929
- import * as path2 from "path";
2859
+ import * as fs from "fs";
2860
+ import * as path from "path";
2930
2861
  var HEAD_SIZE = 64 * 1024;
2931
2862
  function readFileHead(filePath, size = HEAD_SIZE) {
2932
- const fd = fs2.openSync(filePath, "r");
2863
+ const fd = fs.openSync(filePath, "r");
2933
2864
  const buffer = Buffer.alloc(size);
2934
- const bytesRead = fs2.readSync(fd, buffer, 0, size, 0);
2935
- fs2.closeSync(fd);
2865
+ const bytesRead = fs.readSync(fd, buffer, 0, size, 0);
2866
+ fs.closeSync(fd);
2936
2867
  return buffer.slice(0, bytesRead).toString("utf-8");
2937
2868
  }
2938
2869
  function getExtension(filePath) {
2939
- return path2.extname(filePath).toLowerCase();
2870
+ return path.extname(filePath).toLowerCase();
2940
2871
  }
2941
2872
  function matchHeadSignatures(headContent, patterns) {
2942
2873
  return patterns.some((pattern) => pattern.test(headContent));
2943
2874
  }
2944
2875
  function matchFilenameSignatures(filePath, patterns) {
2945
- const filename = path2.basename(filePath);
2876
+ const filename = path.basename(filePath);
2946
2877
  return patterns.some((pattern) => pattern.test(filename));
2947
2878
  }
2948
2879
  function matchRequiredFields(headContent, fields) {
@@ -3090,18 +3021,18 @@ var import_stream_json = __toESM(require_stream_json(), 1);
3090
3021
  var import_Pick = __toESM(require_Pick(), 1);
3091
3022
  var import_StreamValues = __toESM(require_StreamValues(), 1);
3092
3023
  var import_stream_chain = __toESM(require_stream_chain(), 1);
3093
- import * as fs4 from "fs";
3024
+ import * as fs3 from "fs";
3094
3025
 
3095
3026
  // ../../packages/parser/src/utils.ts
3096
- import * as fs3 from "fs";
3027
+ import * as fs2 from "fs";
3097
3028
  function getFileSize(filePath) {
3098
- return fs3.statSync(filePath).size;
3029
+ return fs2.statSync(filePath).size;
3099
3030
  }
3100
3031
  function readFileHeadBytes(filePath, size) {
3101
- const fd = fs3.openSync(filePath, "r");
3032
+ const fd = fs2.openSync(filePath, "r");
3102
3033
  const buffer = Buffer.alloc(size);
3103
- const bytesRead = fs3.readSync(fd, buffer, 0, size, 0);
3104
- fs3.closeSync(fd);
3034
+ const bytesRead = fs2.readSync(fd, buffer, 0, size, 0);
3035
+ fs2.closeSync(fd);
3105
3036
  return buffer.slice(0, bytesRead).toString("utf-8");
3106
3037
  }
3107
3038
  var createProgress = (stage, bytesRead, totalBytes, messagesProcessed, message) => {
@@ -3131,7 +3062,7 @@ function isValidYear(timestampSeconds) {
3131
3062
  }
3132
3063
 
3133
3064
  // ../../packages/parser/src/formats/chatlab.ts
3134
- import * as path3 from "path";
3065
+ import * as path2 from "path";
3135
3066
 
3136
3067
  // ../../packages/parser/src/native/loader.ts
3137
3068
  import { createRequire } from "module";
@@ -3214,7 +3145,7 @@ async function* pumpNativeParser(adapter, options2, parser11, fallback) {
3214
3145
  if (!batch) break;
3215
3146
  messagesProcessed += batch.length;
3216
3147
  yield { type: "messages", data: batch.map((message) => adapter.mapMessage(message, metaJson)) };
3217
- await new Promise((resolve4) => setImmediate(resolve4));
3148
+ await new Promise((resolve2) => setImmediate(resolve2));
3218
3149
  }
3219
3150
  const doneProgress = createProgress("done", totalBytes, totalBytes, messagesProcessed, "");
3220
3151
  yield { type: "progress", data: doneProgress };
@@ -3312,7 +3243,7 @@ var { pick } = import_Pick.default;
3312
3243
  var { streamValues } = import_StreamValues.default;
3313
3244
  var { chain } = import_stream_chain.default;
3314
3245
  function extractNameFromFilePath(filePath) {
3315
- const basename13 = path3.basename(filePath);
3246
+ const basename13 = path2.basename(filePath);
3316
3247
  const name = basename13.replace(/\.json$/i, "");
3317
3248
  return name || "\u672A\u77E5\u7FA4\u804A";
3318
3249
  }
@@ -3386,8 +3317,8 @@ async function* parseChatLab(options2) {
3386
3317
  const members = [];
3387
3318
  const memberMapFromMessages = /* @__PURE__ */ new Map();
3388
3319
  const messageBatch = [];
3389
- await new Promise((resolve4, reject) => {
3390
- const readStream = fs4.createReadStream(filePath, { encoding: "utf-8" });
3320
+ await new Promise((resolve2, reject) => {
3321
+ const readStream = fs3.createReadStream(filePath, { encoding: "utf-8" });
3391
3322
  readStream.on("data", (chunk) => {
3392
3323
  bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
3393
3324
  });
@@ -3441,7 +3372,7 @@ async function* parseChatLab(options2) {
3441
3372
  if (batchCollector.length > 0) {
3442
3373
  messageBatch.push(...batchCollector);
3443
3374
  }
3444
- resolve4();
3375
+ resolve2();
3445
3376
  });
3446
3377
  pipeline2.on("error", reject);
3447
3378
  });
@@ -3479,11 +3410,11 @@ var module_ = {
3479
3410
  var chatlab_default = module_;
3480
3411
 
3481
3412
  // ../../packages/parser/src/formats/chatlab-jsonl.ts
3482
- import * as fs5 from "fs";
3413
+ import * as fs4 from "fs";
3483
3414
  import * as readline from "readline";
3484
- import * as path4 from "path";
3415
+ import * as path3 from "path";
3485
3416
  function extractNameFromFilePath2(filePath) {
3486
- const basename13 = path4.basename(filePath);
3417
+ const basename13 = path3.basename(filePath);
3487
3418
  const name = basename13.replace(/\.jsonl$/i, "");
3488
3419
  return name || "\u672A\u77E5\u7FA4\u804A";
3489
3420
  }
@@ -3524,7 +3455,7 @@ async function* parseChatLabJsonl(options2) {
3524
3455
  const messageBatch = [];
3525
3456
  let meta = null;
3526
3457
  let headerParsed = false;
3527
- const fileStream = fs5.createReadStream(filePath, { encoding: "utf-8" });
3458
+ const fileStream = fs4.createReadStream(filePath, { encoding: "utf-8" });
3528
3459
  const rl = readline.createInterface({
3529
3460
  input: fileStream,
3530
3461
  crlfDelay: Infinity
@@ -3649,30 +3580,28 @@ var import_stream_json3 = __toESM(require_stream_json(), 1);
3649
3580
  var import_Pick3 = __toESM(require_Pick(), 1);
3650
3581
  var import_StreamValues3 = __toESM(require_StreamValues(), 1);
3651
3582
  var import_stream_chain3 = __toESM(require_stream_chain(), 1);
3652
- import * as fs7 from "fs";
3653
- import * as path6 from "path";
3583
+ import * as fs6 from "fs";
3584
+ import * as path5 from "path";
3654
3585
 
3655
3586
  // ../../packages/parser/src/formats/shuakami-qq-preprocessor.ts
3656
3587
  var import_stream_json2 = __toESM(require_stream_json(), 1);
3657
3588
  var import_Pick2 = __toESM(require_Pick(), 1);
3658
3589
  var import_StreamValues2 = __toESM(require_StreamValues(), 1);
3659
3590
  var import_stream_chain2 = __toESM(require_stream_chain(), 1);
3660
- import * as fs6 from "fs";
3661
- import * as path5 from "path";
3662
- import * as os2 from "os";
3591
+ import * as fs5 from "fs";
3592
+ import * as path4 from "path";
3593
+ import * as os from "os";
3663
3594
  var { parser: parser3 } = import_stream_json2.default;
3664
3595
  var { pick: pick2 } = import_Pick2.default;
3665
3596
  var { streamValues: streamValues2 } = import_StreamValues2.default;
3666
3597
  var { chain: chain2 } = import_stream_chain2.default;
3667
3598
  var PREPROCESS_THRESHOLD = 50 * 1024 * 1024;
3668
3599
  function getTempDir() {
3669
- const configuredRoot = process.env.CHATLAB_TEMP_ROOT?.trim();
3670
- const root = configuredRoot ? path5.resolve(configuredRoot) : path5.resolve(process.platform === "darwin" ? "/private/tmp/chatlab" : path5.join(os2.tmpdir(), "chatlab"));
3671
- return path5.join(root, "parser");
3600
+ return path4.join(os.tmpdir(), "chatlab");
3672
3601
  }
3673
3602
  function ensureDir(dir) {
3674
- if (!fs6.existsSync(dir)) {
3675
- fs6.mkdirSync(dir, { recursive: true, mode: 448 });
3603
+ if (!fs5.existsSync(dir)) {
3604
+ fs5.mkdirSync(dir, { recursive: true });
3676
3605
  }
3677
3606
  }
3678
3607
  function extractJsonObject(content, key) {
@@ -3714,12 +3643,12 @@ function extractJsonObject(content, key) {
3714
3643
  }
3715
3644
  function readAvatarsFromFile(filePath) {
3716
3645
  try {
3717
- const stats = fs6.statSync(filePath);
3646
+ const stats = fs5.statSync(filePath);
3718
3647
  const tailSize = Math.min(stats.size, 5e6);
3719
- const fd = fs6.openSync(filePath, "r");
3648
+ const fd = fs5.openSync(filePath, "r");
3720
3649
  const buffer = Buffer.alloc(tailSize);
3721
- fs6.readSync(fd, buffer, 0, tailSize, stats.size - tailSize);
3722
- fs6.closeSync(fd);
3650
+ fs5.readSync(fd, buffer, 0, tailSize, stats.size - tailSize);
3651
+ fs5.closeSync(fd);
3723
3652
  const tailContent = buffer.toString("utf-8");
3724
3653
  return extractJsonObject(tailContent, "avatars");
3725
3654
  } catch {
@@ -3778,15 +3707,15 @@ async function preprocessQQJson(inputPath, onProgress) {
3778
3707
  let messagesProcessed = 0;
3779
3708
  const tempDir = getTempDir();
3780
3709
  ensureDir(tempDir);
3781
- const outputFilename = `slim_${Date.now()}_${path5.basename(inputPath)}`;
3782
- const outputPath = path5.join(tempDir, outputFilename);
3710
+ const outputFilename = `slim_${Date.now()}_${path4.basename(inputPath)}`;
3711
+ const outputPath = path4.join(tempDir, outputFilename);
3783
3712
  onProgress?.(createProgress("parsing", 0, totalBytes, 0, ""));
3784
3713
  const avatarsStr = readAvatarsFromFile(inputPath);
3785
- return new Promise((resolve4, reject) => {
3714
+ return new Promise((resolve2, reject) => {
3786
3715
  const headChunks = [];
3787
3716
  let headSize = 0;
3788
3717
  const maxHeadSize = 1e5;
3789
- const headStream = fs6.createReadStream(inputPath, { encoding: "utf-8" });
3718
+ const headStream = fs5.createReadStream(inputPath, { encoding: "utf-8" });
3790
3719
  let chatInfo = { name: "\u672A\u77E5\u7FA4\u804A", type: "group" };
3791
3720
  let metadata;
3792
3721
  let statistics;
@@ -3823,8 +3752,8 @@ async function preprocessQQJson(inputPath, onProgress) {
3823
3752
  } catch {
3824
3753
  }
3825
3754
  onProgress?.(createProgress("parsing", 0, totalBytes, 0, ""));
3826
- const readStream = fs6.createReadStream(inputPath, { encoding: "utf-8" });
3827
- const writeStream = fs6.createWriteStream(outputPath, { encoding: "utf-8" });
3755
+ const readStream = fs5.createReadStream(inputPath, { encoding: "utf-8" });
3756
+ const writeStream = fs5.createWriteStream(outputPath, { encoding: "utf-8" });
3828
3757
  readStream.on("data", (chunk) => {
3829
3758
  bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
3830
3759
  });
@@ -3864,13 +3793,13 @@ async function preprocessQQJson(inputPath, onProgress) {
3864
3793
  writeStream.end();
3865
3794
  writeStream.on("finish", () => {
3866
3795
  onProgress?.(createProgress("done", totalBytes, totalBytes, messagesProcessed, ""));
3867
- resolve4(outputPath);
3796
+ resolve2(outputPath);
3868
3797
  });
3869
3798
  });
3870
3799
  pipeline2.on("error", (err) => {
3871
3800
  writeStream.destroy();
3872
- if (fs6.existsSync(outputPath)) {
3873
- fs6.unlinkSync(outputPath);
3801
+ if (fs5.existsSync(outputPath)) {
3802
+ fs5.unlinkSync(outputPath);
3874
3803
  }
3875
3804
  onProgress?.(createProgress("error", bytesRead, totalBytes, messagesProcessed, err.message));
3876
3805
  reject(err);
@@ -3881,8 +3810,8 @@ async function preprocessQQJson(inputPath, onProgress) {
3881
3810
  }
3882
3811
  function cleanupTempFile(filePath) {
3883
3812
  try {
3884
- if (fs6.existsSync(filePath) && path5.dirname(path5.resolve(filePath)) === path5.resolve(getTempDir())) {
3885
- fs6.unlinkSync(filePath);
3813
+ if (fs5.existsSync(filePath) && filePath.includes(getTempDir())) {
3814
+ fs5.unlinkSync(filePath);
3886
3815
  }
3887
3816
  } catch {
3888
3817
  }
@@ -3949,7 +3878,7 @@ function extractJsonObject2(content, key) {
3949
3878
  return null;
3950
3879
  }
3951
3880
  function extractNameFromFilePath3(filePath) {
3952
- const basename13 = path6.basename(filePath);
3881
+ const basename13 = path5.basename(filePath);
3953
3882
  return basename13.replace(/\.json$/i, "") || "\u672A\u77E5\u7FA4\u804A";
3954
3883
  }
3955
3884
  function isPlaceholderSenderId(id) {
@@ -4046,8 +3975,8 @@ async function* parseV4(options2) {
4046
3975
  yield { type: "meta", data: meta };
4047
3976
  const memberMap = /* @__PURE__ */ new Map();
4048
3977
  const messageBatch = [];
4049
- await new Promise((resolve4, reject) => {
4050
- const readStream = fs7.createReadStream(filePath, { encoding: "utf-8" });
3978
+ await new Promise((resolve2, reject) => {
3979
+ const readStream = fs6.createReadStream(filePath, { encoding: "utf-8" });
4051
3980
  readStream.on("data", (chunk) => {
4052
3981
  bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
4053
3982
  });
@@ -4102,17 +4031,17 @@ async function* parseV4(options2) {
4102
4031
  onProgress?.(progress);
4103
4032
  }
4104
4033
  });
4105
- pipeline2.on("end", resolve4);
4034
+ pipeline2.on("end", resolve2);
4106
4035
  pipeline2.on("error", reject);
4107
4036
  });
4108
4037
  const avatarsMap = /* @__PURE__ */ new Map();
4109
4038
  try {
4110
- const stats = fs7.statSync(filePath);
4039
+ const stats = fs6.statSync(filePath);
4111
4040
  const tailSize = Math.min(stats.size, 5e6);
4112
- const fd = fs7.openSync(filePath, "r");
4041
+ const fd = fs6.openSync(filePath, "r");
4113
4042
  const buffer = Buffer.alloc(tailSize);
4114
- fs7.readSync(fd, buffer, 0, tailSize, stats.size - tailSize);
4115
- fs7.closeSync(fd);
4043
+ fs6.readSync(fd, buffer, 0, tailSize, stats.size - tailSize);
4044
+ fs6.closeSync(fd);
4116
4045
  const tailContent = buffer.toString("utf-8");
4117
4046
  const avatarsStr = extractJsonObject2(tailContent, "avatars");
4118
4047
  if (avatarsStr) {
@@ -4164,8 +4093,8 @@ var module_3 = {
4164
4093
  var shuakami_qq_exporter_default = module_3;
4165
4094
 
4166
4095
  // ../../packages/parser/src/formats/shuakami-qq-exporter-chunked.ts
4167
- import * as fs8 from "fs";
4168
- import * as path7 from "path";
4096
+ import * as fs7 from "fs";
4097
+ import * as path6 from "path";
4169
4098
  import * as readline2 from "readline";
4170
4099
  var feature4 = {
4171
4100
  id: "shuakami-qq-exporter-chunked",
@@ -4214,7 +4143,7 @@ function convertMessageType2(msgType, content, isRecalled) {
4214
4143
  return 0 /* TEXT */;
4215
4144
  }
4216
4145
  function readManifest(manifestPath) {
4217
- const content = fs8.readFileSync(manifestPath, "utf-8");
4146
+ const content = fs7.readFileSync(manifestPath, "utf-8");
4218
4147
  return JSON.parse(content);
4219
4148
  }
4220
4149
  function getChunkRelativePath(chunk) {
@@ -4232,9 +4161,9 @@ function calculateTotalBytes(manifest, baseDir) {
4232
4161
  let total = 0;
4233
4162
  for (const chunk of manifest.chunked.chunks) {
4234
4163
  const relativePath = getChunkRelativePath(chunk);
4235
- const chunkPath = path7.join(baseDir, relativePath);
4236
- if (fs8.existsSync(chunkPath)) {
4237
- total += fs8.statSync(chunkPath).size;
4164
+ const chunkPath = path6.join(baseDir, relativePath);
4165
+ if (fs7.existsSync(chunkPath)) {
4166
+ total += fs7.statSync(chunkPath).size;
4238
4167
  }
4239
4168
  }
4240
4169
  return total;
@@ -4242,10 +4171,10 @@ function calculateTotalBytes(manifest, baseDir) {
4242
4171
  function readAvatars(baseDir, avatarsInfo) {
4243
4172
  const avatarsMap = /* @__PURE__ */ new Map();
4244
4173
  if (!avatarsInfo?.file) return avatarsMap;
4245
- const avatarsPath = path7.join(baseDir, avatarsInfo.file);
4246
- if (!fs8.existsSync(avatarsPath)) return avatarsMap;
4174
+ const avatarsPath = path6.join(baseDir, avatarsInfo.file);
4175
+ if (!fs7.existsSync(avatarsPath)) return avatarsMap;
4247
4176
  try {
4248
- const content = fs8.readFileSync(avatarsPath, "utf-8");
4177
+ const content = fs7.readFileSync(avatarsPath, "utf-8");
4249
4178
  const avatars = JSON.parse(content);
4250
4179
  for (const [uin, avatar] of Object.entries(avatars)) {
4251
4180
  if (avatar && typeof avatar === "string" && avatar.startsWith("data:image/")) {
@@ -4263,7 +4192,7 @@ async function* readJsonlFile(filePath, onParseError) {
4263
4192
  let parseErrorCount = 0;
4264
4193
  const MAX_PARSE_ERRORS_TO_LOG = 10;
4265
4194
  try {
4266
- fileStream = fs8.createReadStream(filePath, { encoding: "utf-8" });
4195
+ fileStream = fs7.createReadStream(filePath, { encoding: "utf-8" });
4267
4196
  rl = readline2.createInterface({
4268
4197
  input: fileStream,
4269
4198
  crlfDelay: Infinity
@@ -4294,7 +4223,7 @@ async function* readJsonlFile(filePath, onParseError) {
4294
4223
  async function* parseChunkedJsonl(options2) {
4295
4224
  const { filePath, batchSize = 5e3, onProgress, onLog } = options2;
4296
4225
  const manifestPath = filePath;
4297
- const baseDir = path7.dirname(manifestPath);
4226
+ const baseDir = path6.dirname(manifestPath);
4298
4227
  onLog?.("info", `\u5F00\u59CB\u89E3\u6790 manifest: ${manifestPath}`);
4299
4228
  onLog?.("info", `\u57FA\u7840\u76EE\u5F55: ${baseDir}`);
4300
4229
  let manifest;
@@ -4348,13 +4277,13 @@ async function* parseChunkedJsonl(options2) {
4348
4277
  for (let chunkIndex = 0; chunkIndex < manifest.chunked.chunks.length; chunkIndex++) {
4349
4278
  const chunkInfo = manifest.chunked.chunks[chunkIndex];
4350
4279
  const relativePath = getChunkRelativePath(chunkInfo);
4351
- const chunkPath = path7.join(baseDir, relativePath);
4280
+ const chunkPath = path6.join(baseDir, relativePath);
4352
4281
  const chunkMessageCount = getChunkMessageCount(chunkInfo);
4353
- if (!fs8.existsSync(chunkPath)) {
4282
+ if (!fs7.existsSync(chunkPath)) {
4354
4283
  onLog?.("error", `\u5206\u5757\u6587\u4EF6\u4E0D\u5B58\u5728: ${chunkPath}`);
4355
4284
  continue;
4356
4285
  }
4357
- const chunkSize = fs8.statSync(chunkPath).size;
4286
+ const chunkSize = fs7.statSync(chunkPath).size;
4358
4287
  let chunkMessagesRead = 0;
4359
4288
  let chunkParseErrors = 0;
4360
4289
  onLog?.(
@@ -4476,8 +4405,8 @@ var import_stream_json4 = __toESM(require_stream_json(), 1);
4476
4405
  var import_Pick4 = __toESM(require_Pick(), 1);
4477
4406
  var import_StreamValues4 = __toESM(require_StreamValues(), 1);
4478
4407
  var import_stream_chain4 = __toESM(require_stream_chain(), 1);
4479
- import * as fs9 from "fs";
4480
- import * as path8 from "path";
4408
+ import * as fs8 from "fs";
4409
+ import * as path7 from "path";
4481
4410
 
4482
4411
  // ../../packages/parser/src/native/weflow-native.ts
4483
4412
  var weflowAdapter = {
@@ -4550,7 +4479,7 @@ var { pick: pick4 } = import_Pick4.default;
4550
4479
  var { streamValues: streamValues4 } = import_StreamValues4.default;
4551
4480
  var { chain: chain4 } = import_stream_chain4.default;
4552
4481
  function extractNameFromFilePath4(filePath) {
4553
- const basename13 = path8.basename(filePath);
4482
+ const basename13 = path7.basename(filePath);
4554
4483
  const name = basename13.replace(/\.json$/i, "");
4555
4484
  return name || "\u672A\u77E5\u804A\u5929";
4556
4485
  }
@@ -4618,8 +4547,8 @@ async function* parseWeFlow(options2) {
4618
4547
  const headContent = readFileHeadBytes(filePath, 5e3);
4619
4548
  let session = null;
4620
4549
  try {
4621
- await new Promise((resolve4) => {
4622
- const sessionStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
4550
+ await new Promise((resolve2) => {
4551
+ const sessionStream = fs8.createReadStream(filePath, { encoding: "utf-8" });
4623
4552
  let sessionContent = "";
4624
4553
  let inSession = false;
4625
4554
  let braceDepth = 0;
@@ -4670,9 +4599,9 @@ async function* parseWeFlow(options2) {
4670
4599
  } catch {
4671
4600
  }
4672
4601
  }
4673
- resolve4();
4602
+ resolve2();
4674
4603
  });
4675
- sessionStream.on("error", () => resolve4());
4604
+ sessionStream.on("error", () => resolve2());
4676
4605
  });
4677
4606
  } catch {
4678
4607
  }
@@ -4741,8 +4670,8 @@ async function* parseWeFlow(options2) {
4741
4670
  }
4742
4671
  if (avatarsMap.size === 0) {
4743
4672
  try {
4744
- await new Promise((resolve4) => {
4745
- const avatarStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
4673
+ await new Promise((resolve2) => {
4674
+ const avatarStream = fs8.createReadStream(filePath, { encoding: "utf-8" });
4746
4675
  let avatarsContent = "";
4747
4676
  let inAvatars = false;
4748
4677
  let braceDepth = 0;
@@ -4798,9 +4727,9 @@ async function* parseWeFlow(options2) {
4798
4727
  } catch {
4799
4728
  }
4800
4729
  }
4801
- resolve4();
4730
+ resolve2();
4802
4731
  });
4803
- avatarStream.on("error", () => resolve4());
4732
+ avatarStream.on("error", () => resolve2());
4804
4733
  });
4805
4734
  } catch {
4806
4735
  }
@@ -4808,8 +4737,8 @@ async function* parseWeFlow(options2) {
4808
4737
  const groupAvatar = sessionData?.avatar || (groupId ? avatarsMap.get(groupId) : void 0);
4809
4738
  let ownerId;
4810
4739
  try {
4811
- await new Promise((resolve4) => {
4812
- const scanStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
4740
+ await new Promise((resolve2) => {
4741
+ const scanStream = fs8.createReadStream(filePath, { encoding: "utf-8" });
4813
4742
  const scanPipeline = chain4([scanStream, parser5(), pick4({ filter: /^messages\.\d+$/ }), streamValues4()]);
4814
4743
  scanPipeline.on("data", ({ value }) => {
4815
4744
  if (value.isSend === 1 && value.senderUsername && !value.senderUsername.endsWith("@chatroom")) {
@@ -4817,9 +4746,9 @@ async function* parseWeFlow(options2) {
4817
4746
  scanStream.destroy();
4818
4747
  }
4819
4748
  });
4820
- scanStream.on("close", () => resolve4());
4821
- scanPipeline.on("end", () => resolve4());
4822
- scanPipeline.on("error", () => resolve4());
4749
+ scanStream.on("close", () => resolve2());
4750
+ scanPipeline.on("end", () => resolve2());
4751
+ scanPipeline.on("error", () => resolve2());
4823
4752
  });
4824
4753
  } catch {
4825
4754
  }
@@ -4834,8 +4763,8 @@ async function* parseWeFlow(options2) {
4834
4763
  yield { type: "meta", data: meta };
4835
4764
  const memberMap = /* @__PURE__ */ new Map();
4836
4765
  const messageBatch = [];
4837
- await new Promise((resolve4, reject) => {
4838
- const readStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
4766
+ await new Promise((resolve2, reject) => {
4767
+ const readStream = fs8.createReadStream(filePath, { encoding: "utf-8" });
4839
4768
  readStream.on("data", (chunk) => {
4840
4769
  bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
4841
4770
  });
@@ -4907,7 +4836,7 @@ async function* parseWeFlow(options2) {
4907
4836
  if (batchCollector.length > 0) {
4908
4837
  messageBatch.push(...batchCollector);
4909
4838
  }
4910
- resolve4();
4839
+ resolve2();
4911
4840
  });
4912
4841
  pipeline2.on("error", reject);
4913
4842
  });
@@ -4972,7 +4901,7 @@ var import_stream_json5 = __toESM(require_stream_json(), 1);
4972
4901
  var import_Pick5 = __toESM(require_Pick(), 1);
4973
4902
  var import_StreamValues5 = __toESM(require_StreamValues(), 1);
4974
4903
  var import_stream_chain5 = __toESM(require_stream_chain(), 1);
4975
- import * as fs10 from "fs";
4904
+ import * as fs9 from "fs";
4976
4905
  var { parser: parser6 } = import_stream_json5.default;
4977
4906
  var { pick: pick5 } = import_Pick5.default;
4978
4907
  var { streamValues: streamValues5 } = import_StreamValues5.default;
@@ -5121,8 +5050,8 @@ async function* parseDiscordExporter(options2) {
5121
5050
  onLog?.("info", `\u7FA4\u804A\u540D\u79F0: ${chatName}`);
5122
5051
  const memberMap = /* @__PURE__ */ new Map();
5123
5052
  const messageBatch = [];
5124
- await new Promise((resolve4, reject) => {
5125
- const readStream = fs10.createReadStream(filePath, { encoding: "utf-8" });
5053
+ await new Promise((resolve2, reject) => {
5054
+ const readStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
5126
5055
  readStream.on("data", (chunk) => {
5127
5056
  bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
5128
5057
  });
@@ -5200,7 +5129,7 @@ ${stickerTexts.join("\n")}` : stickerTexts.join("\n");
5200
5129
  if (batchCollector.length > 0) {
5201
5130
  messageBatch.push(...batchCollector);
5202
5131
  }
5203
- resolve4();
5132
+ resolve2();
5204
5133
  });
5205
5134
  pipeline2.on("error", reject);
5206
5135
  });
@@ -5238,7 +5167,7 @@ var import_stream_chain6 = __toESM(require_stream_chain(), 1);
5238
5167
  var import_stream_json6 = __toESM(require_stream_json(), 1);
5239
5168
  var import_Pick6 = __toESM(require_Pick(), 1);
5240
5169
  var import_StreamValues6 = __toESM(require_StreamValues(), 1);
5241
- import * as fs11 from "fs";
5170
+ import * as fs10 from "fs";
5242
5171
 
5243
5172
  // ../../packages/parser/src/formats/utils/telegram-utils.ts
5244
5173
  function mapChatType(telegramType) {
@@ -5323,8 +5252,8 @@ var feature8 = {
5323
5252
  };
5324
5253
  async function scanChats(filePath) {
5325
5254
  const chats = [];
5326
- return new Promise((resolve4, reject) => {
5327
- const readStream = fs11.createReadStream(filePath, { encoding: "utf-8" });
5255
+ return new Promise((resolve2, reject) => {
5256
+ const readStream = fs10.createReadStream(filePath, { encoding: "utf-8" });
5328
5257
  const pipeline2 = chain6([readStream, parser7(), pick6({ filter: /^chats\.list\.\d+$/ }), streamValues6()]);
5329
5258
  pipeline2.on("data", ({ value }) => {
5330
5259
  const chat = value;
@@ -5337,7 +5266,7 @@ async function scanChats(filePath) {
5337
5266
  });
5338
5267
  });
5339
5268
  pipeline2.on("end", () => {
5340
- resolve4(chats);
5269
+ resolve2(chats);
5341
5270
  });
5342
5271
  pipeline2.on("error", (err) => {
5343
5272
  reject(new Error(`\u626B\u63CF Telegram \u6587\u4EF6\u5931\u8D25: ${err.message}`));
@@ -5356,8 +5285,8 @@ async function* parseTelegram(options2) {
5356
5285
  onLog?.("info", `\u5F00\u59CB\u89E3\u6790 Telegram JSON \u6587\u4EF6\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
5357
5286
  onLog?.("info", `\u76EE\u6807\u804A\u5929\u7D22\u5F15: ${chatIndex}`);
5358
5287
  const chatPathFilter = `chats.list.${chatIndex}`;
5359
- const chatData = await new Promise((resolve4, reject) => {
5360
- const readStream = fs11.createReadStream(filePath, { encoding: "utf-8" });
5288
+ const chatData = await new Promise((resolve2, reject) => {
5289
+ const readStream = fs10.createReadStream(filePath, { encoding: "utf-8" });
5361
5290
  readStream.on("data", (chunk) => {
5362
5291
  bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
5363
5292
  });
@@ -5370,10 +5299,10 @@ async function* parseTelegram(options2) {
5370
5299
  let found = false;
5371
5300
  pipeline2.on("data", ({ value }) => {
5372
5301
  found = true;
5373
- resolve4(value);
5302
+ resolve2(value);
5374
5303
  });
5375
5304
  pipeline2.on("end", () => {
5376
- if (!found) resolve4(null);
5305
+ if (!found) resolve2(null);
5377
5306
  });
5378
5307
  pipeline2.on("error", reject);
5379
5308
  });
@@ -5465,7 +5394,7 @@ var telegram_native_default = module_8;
5465
5394
  var import_stream_chain7 = __toESM(require_stream_chain(), 1);
5466
5395
  var import_stream_json7 = __toESM(require_stream_json(), 1);
5467
5396
  var import_StreamValues7 = __toESM(require_StreamValues(), 1);
5468
- import * as fs12 from "fs";
5397
+ import * as fs11 from "fs";
5469
5398
  var { chain: chain7 } = import_stream_chain7.default;
5470
5399
  var { parser: parser8 } = import_stream_json7.default;
5471
5400
  var { streamValues: streamValues7 } = import_StreamValues7.default;
@@ -5494,18 +5423,18 @@ async function* parseTelegramSingle(options2) {
5494
5423
  yield { type: "progress", data: initialProgress };
5495
5424
  onProgress?.(initialProgress);
5496
5425
  onLog?.("info", `\u5F00\u59CB\u89E3\u6790 Telegram \u5355\u804A\u5929 JSON \u6587\u4EF6\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
5497
- const chatData = await new Promise((resolve4, reject) => {
5498
- const readStream = fs12.createReadStream(filePath, { encoding: "utf-8" });
5426
+ const chatData = await new Promise((resolve2, reject) => {
5427
+ const readStream = fs11.createReadStream(filePath, { encoding: "utf-8" });
5499
5428
  const pipeline2 = chain7([readStream, parser8(), streamValues7()]);
5500
5429
  let found = false;
5501
5430
  pipeline2.on("data", ({ value }) => {
5502
5431
  if (!found) {
5503
5432
  found = true;
5504
- resolve4(value);
5433
+ resolve2(value);
5505
5434
  }
5506
5435
  });
5507
5436
  pipeline2.on("end", () => {
5508
- if (!found) resolve4(null);
5437
+ if (!found) resolve2(null);
5509
5438
  });
5510
5439
  pipeline2.on("error", reject);
5511
5440
  });
@@ -5593,11 +5522,11 @@ var module_9 = {
5593
5522
  var telegram_native_single_default = module_9;
5594
5523
 
5595
5524
  // ../../packages/parser/src/formats/whatsapp-native-txt.ts
5596
- import * as fs13 from "fs";
5597
- import * as path9 from "path";
5525
+ import * as fs12 from "fs";
5526
+ import * as path8 from "path";
5598
5527
  import * as readline3 from "readline";
5599
5528
  function extractNameFromFilePath5(filePath) {
5600
- const basename13 = path9.basename(filePath);
5529
+ const basename13 = path8.basename(filePath);
5601
5530
  const matchZhCn = basename13.match(/^与(.+?)的\s*WhatsApp\s*聊天\.txt$/i);
5602
5531
  if (matchZhCn) return matchZhCn[1].trim();
5603
5532
  const matchZhTw = basename13.match(/^與(.+?)的\s*WhatsApp\s*對話\.txt$/i);
@@ -5605,7 +5534,7 @@ function extractNameFromFilePath5(filePath) {
5605
5534
  return basename13.replace(/\.txt$/i, "") || "\u672A\u77E5\u804A\u5929";
5606
5535
  }
5607
5536
  function shouldInferPrivateChatName(filePath, fallbackName) {
5608
- const basename13 = path9.basename(filePath);
5537
+ const basename13 = path8.basename(filePath);
5609
5538
  return /^_chat\.txt$/i.test(basename13) || /^whatsapp(?:[-_\s].*)?$/i.test(fallbackName);
5610
5539
  }
5611
5540
  function inferPrivateChatName(memberMap, fallbackName) {
@@ -5784,7 +5713,7 @@ async function* parseWhatsApp(options2) {
5784
5713
  messagesProcessed++;
5785
5714
  }
5786
5715
  };
5787
- const fileStream = fs13.createReadStream(filePath, { encoding: "utf-8" });
5716
+ const fileStream = fs12.createReadStream(filePath, { encoding: "utf-8" });
5788
5717
  const rl = readline3.createInterface({
5789
5718
  input: fileStream,
5790
5719
  crlfDelay: Infinity
@@ -5905,11 +5834,11 @@ var module_10 = {
5905
5834
  var whatsapp_native_txt_default = module_10;
5906
5835
 
5907
5836
  // ../../packages/parser/src/formats/qq-native-txt.ts
5908
- import * as fs14 from "fs";
5909
- import * as path10 from "path";
5837
+ import * as fs13 from "fs";
5838
+ import * as path9 from "path";
5910
5839
  import * as readline4 from "readline";
5911
5840
  function extractNameFromFilePath6(filePath) {
5912
- const basename13 = path10.basename(filePath);
5841
+ const basename13 = path9.basename(filePath);
5913
5842
  const name = basename13.replace(/\.txt$/i, "");
5914
5843
  return name || "\u672A\u77E5\u7FA4\u804A";
5915
5844
  }
@@ -5991,7 +5920,7 @@ async function* parseTxt(options2) {
5991
5920
  messagesProcessed++;
5992
5921
  }
5993
5922
  };
5994
- const fileStream = fs14.createReadStream(filePath, { encoding: "utf-8" });
5923
+ const fileStream = fs13.createReadStream(filePath, { encoding: "utf-8" });
5995
5924
  const rl = readline4.createInterface({
5996
5925
  input: fileStream,
5997
5926
  crlfDelay: Infinity
@@ -6091,8 +6020,8 @@ var module_11 = {
6091
6020
  var qq_native_txt_default = module_11;
6092
6021
 
6093
6022
  // ../../packages/parser/src/formats/instagram-native.ts
6094
- import * as fs15 from "fs";
6095
- import * as path11 from "path";
6023
+ import * as fs14 from "fs";
6024
+ import * as path10 from "path";
6096
6025
  var feature12 = {
6097
6026
  id: "instagram-native",
6098
6027
  name: "Instagram \u5B98\u65B9\u5BFC\u51FA",
@@ -6118,7 +6047,7 @@ function decodeInstagramText(text) {
6118
6047
  }
6119
6048
  }
6120
6049
  function extractNameFromFilePath7(filePath) {
6121
- const basename13 = path11.basename(filePath);
6050
+ const basename13 = path10.basename(filePath);
6122
6051
  return basename13.replace(/\.json$/i, "") || "\u672A\u77E5\u5BF9\u8BDD";
6123
6052
  }
6124
6053
  function isSystemMessage2(content) {
@@ -6187,7 +6116,7 @@ async function* parseInstagram(options2) {
6187
6116
  onLog?.("info", `\u5F00\u59CB\u89E3\u6790 Instagram \u804A\u5929\u8BB0\u5F55\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
6188
6117
  let data;
6189
6118
  try {
6190
- const content = fs15.readFileSync(filePath, "utf-8");
6119
+ const content = fs14.readFileSync(filePath, "utf-8");
6191
6120
  data = JSON.parse(content);
6192
6121
  } catch (error) {
6193
6122
  const err = new Error(`\u65E0\u6CD5\u89E3\u6790 Instagram JSON \u6587\u4EF6: ${error}`);
@@ -6282,8 +6211,8 @@ var import_stream_chain8 = __toESM(require_stream_chain(), 1);
6282
6211
  var import_stream_json8 = __toESM(require_stream_json(), 1);
6283
6212
  var import_Pick7 = __toESM(require_Pick(), 1);
6284
6213
  var import_StreamValues8 = __toESM(require_StreamValues(), 1);
6285
- import * as fs16 from "fs";
6286
- import * as path12 from "path";
6214
+ import * as fs15 from "fs";
6215
+ import * as path11 from "path";
6287
6216
  var { chain: chain8 } = import_stream_chain8.default;
6288
6217
  var { parser: parser9 } = import_stream_json8.default;
6289
6218
  var { pick: pick7 } = import_Pick7.default;
@@ -6366,12 +6295,12 @@ function normalizeIdentity(user) {
6366
6295
  };
6367
6296
  }
6368
6297
  function readJson(filePath) {
6369
- return JSON.parse(fs16.readFileSync(filePath, "utf8"));
6298
+ return JSON.parse(fs15.readFileSync(filePath, "utf8"));
6370
6299
  }
6371
6300
  function resolveManifestFile(manifestDir, relativePath) {
6372
- const resolved = path12.resolve(manifestDir, relativePath);
6373
- const relative2 = path12.relative(manifestDir, resolved);
6374
- if (relative2.startsWith("..") || path12.isAbsolute(relative2)) {
6301
+ const resolved = path11.resolve(manifestDir, relativePath);
6302
+ const relative2 = path11.relative(manifestDir, resolved);
6303
+ if (relative2.startsWith("..") || path11.isAbsolute(relative2)) {
6375
6304
  throw new Error(`Google Chat manifest path escapes its directory: ${relativePath}`);
6376
6305
  }
6377
6306
  return resolved;
@@ -6384,7 +6313,7 @@ function readManifest2(filePath) {
6384
6313
  if (manifest.chatType !== "private" && manifest.chatType !== "group") {
6385
6314
  throw new Error("Invalid Google Chat chat type");
6386
6315
  }
6387
- const manifestDir = path12.dirname(filePath);
6316
+ const manifestDir = path11.dirname(filePath);
6388
6317
  return {
6389
6318
  manifest,
6390
6319
  userInfoPath: resolveManifestFile(manifestDir, manifest.userInfoFile),
@@ -6462,7 +6391,7 @@ async function* parseGoogleChat(options2) {
6462
6391
  });
6463
6392
  }
6464
6393
  yield { type: "members", data: Array.from(memberMap.values()) };
6465
- const readStream = fs16.createReadStream(messagesPath, { encoding: "utf8" });
6394
+ const readStream = fs15.createReadStream(messagesPath, { encoding: "utf8" });
6466
6395
  let bytesRead = 0;
6467
6396
  let messagesProcessed = 0;
6468
6397
  readStream.on("data", (chunk) => {
@@ -6515,8 +6444,8 @@ var module_13 = {
6515
6444
  var google_chat_takeout_default = module_13;
6516
6445
 
6517
6446
  // ../../packages/parser/src/formats/line-native-txt.ts
6518
- import * as fs17 from "fs";
6519
- import * as path13 from "path";
6447
+ import * as fs16 from "fs";
6448
+ import * as path12 from "path";
6520
6449
  var feature14 = {
6521
6450
  id: "line-native-txt",
6522
6451
  name: "LINE \u5B98\u65B9\u5BFC\u51FA TXT",
@@ -6544,7 +6473,7 @@ var feature14 = {
6544
6473
  }
6545
6474
  };
6546
6475
  function extractNameFromFilePath8(filePath) {
6547
- const basename13 = path13.basename(filePath, ".txt");
6476
+ const basename13 = path12.basename(filePath, ".txt");
6548
6477
  const name = basename13.replace(/^\[LINE\]\s*/i, "").trim();
6549
6478
  return name || "\u672A\u77E5\u804A\u5929";
6550
6479
  }
@@ -6724,7 +6653,7 @@ async function* parseLINE(options2) {
6724
6653
  yield { type: "progress", data: initialProgress };
6725
6654
  onProgress?.(initialProgress);
6726
6655
  onLog?.("info", `\u5F00\u59CB\u89E3\u6790 LINE \u5BFC\u51FA\u6587\u4EF6\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
6727
- const content = fs17.readFileSync(filePath, "utf-8");
6656
+ const content = fs16.readFileSync(filePath, "utf-8");
6728
6657
  const lines = content.split("\n").map((line) => line.replace(/\r$/, ""));
6729
6658
  let currentDate = null;
6730
6659
  let chatName = extractNameFromFilePath8(filePath);
@@ -7032,12 +6961,12 @@ function findEntryFileInDirectory(dirPath, maxDepth = 1) {
7032
6961
  if (depth > maxDepth) return null;
7033
6962
  let entries;
7034
6963
  try {
7035
- entries = fs18.readdirSync(current, { withFileTypes: true });
6964
+ entries = fs17.readdirSync(current, { withFileTypes: true });
7036
6965
  } catch {
7037
6966
  return null;
7038
6967
  }
7039
6968
  for (const entry of entries) {
7040
- const full = path14.join(current, entry.name);
6969
+ const full = path13.join(current, entry.name);
7041
6970
  if (entry.isFile() && entry.name.endsWith(".json")) {
7042
6971
  const format = detectFormat(full);
7043
6972
  if (format) return full;
@@ -7045,7 +6974,7 @@ function findEntryFileInDirectory(dirPath, maxDepth = 1) {
7045
6974
  }
7046
6975
  for (const entry of entries) {
7047
6976
  if (entry.isDirectory()) {
7048
- const found = walk(path14.join(current, entry.name), depth + 1);
6977
+ const found = walk(path13.join(current, entry.name), depth + 1);
7049
6978
  if (found) return found;
7050
6979
  }
7051
6980
  }
@@ -7094,8 +7023,8 @@ function logNativeParserStatus() {
7094
7023
  }
7095
7024
 
7096
7025
  // ../../packages/node-runtime/src/import/perf-logger.ts
7097
- import * as fs19 from "fs";
7098
- import * as path15 from "path";
7026
+ import * as fs18 from "fs";
7027
+ import * as path14 from "path";
7099
7028
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
7100
7029
  LogLevel2["ERROR"] = "ERROR";
7101
7030
  LogLevel2["INFO"] = "INFO";
@@ -7107,11 +7036,11 @@ var currentLogFile = null;
7107
7036
  var errorCount = 0;
7108
7037
  function initPerfLog(sessionId, logDir) {
7109
7038
  try {
7110
- if (!fs19.existsSync(logDir)) {
7111
- fs19.mkdirSync(logDir, { recursive: true });
7039
+ if (!fs18.existsSync(logDir)) {
7040
+ fs18.mkdirSync(logDir, { recursive: true });
7112
7041
  }
7113
- currentLogFile = path15.join(logDir, `import_${sessionId}_${Date.now()}.log`);
7114
- fs19.writeFileSync(currentLogFile, `=== Import Log ===
7042
+ currentLogFile = path14.join(logDir, `import_${sessionId}_${Date.now()}.log`);
7043
+ fs18.writeFileSync(currentLogFile, `=== Import Log ===
7115
7044
  Start time: ${(/* @__PURE__ */ new Date()).toISOString()}
7116
7045
 
7117
7046
  `, "utf-8");
@@ -7132,7 +7061,7 @@ function logPerf(event, messagesProcessed, batchSize) {
7132
7061
  const logLine = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${event} | messages: ${messagesProcessed.toLocaleString()} | elapsed: ${duration}ms | speed: ${speed.toLocaleString()}/s | memory: ${memory}MB` + (batchSize ? ` | batch: ${batchSize}` : "") + "\n";
7133
7062
  if (currentLogFile) {
7134
7063
  try {
7135
- fs19.appendFileSync(currentLogFile, logLine, "utf-8");
7064
+ fs18.appendFileSync(currentLogFile, logLine, "utf-8");
7136
7065
  } catch {
7137
7066
  }
7138
7067
  }
@@ -7142,7 +7071,7 @@ function logPerf(event, messagesProcessed, batchSize) {
7142
7071
  function logPerfDetail(detail) {
7143
7072
  if (currentLogFile) {
7144
7073
  try {
7145
- fs19.appendFileSync(currentLogFile, ` ${detail}
7074
+ fs18.appendFileSync(currentLogFile, ` ${detail}
7146
7075
  `, "utf-8");
7147
7076
  } catch {
7148
7077
  }
@@ -7162,7 +7091,7 @@ function writeLogLine(level, message) {
7162
7091
  const logLine = `[${(/* @__PURE__ */ new Date()).toISOString()}] [${level}] ${message}
7163
7092
  `;
7164
7093
  try {
7165
- fs19.appendFileSync(currentLogFile, logLine, "utf-8");
7094
+ fs18.appendFileSync(currentLogFile, logLine, "utf-8");
7166
7095
  } catch {
7167
7096
  }
7168
7097
  }
@@ -7187,7 +7116,7 @@ Total members: ${totalMembers.toLocaleString()}
7187
7116
  Errors: ${errorCount}
7188
7117
  `;
7189
7118
  try {
7190
- fs19.appendFileSync(currentLogFile, summary, "utf-8");
7119
+ fs18.appendFileSync(currentLogFile, summary, "utf-8");
7191
7120
  } catch {
7192
7121
  }
7193
7122
  }
@@ -7286,8 +7215,8 @@ function segmentText(text, locale, minLength) {
7286
7215
  }
7287
7216
 
7288
7217
  // ../../packages/node-runtime/src/nlp/dict-manager.ts
7289
- import * as fs20 from "fs";
7290
- import * as path16 from "path";
7218
+ import * as fs19 from "fs";
7219
+ import * as path15 from "path";
7291
7220
  import { createHash } from "crypto";
7292
7221
  var DICT_DOWNLOAD_URL_BASE = "https://chatlab.fun/assets/nlp";
7293
7222
  var DICT_SHA256 = {
@@ -7299,19 +7228,19 @@ var AVAILABLE_DICTS = [
7299
7228
  { id: "zh-TW", label: "\u7E41\u9AD4\u4E2D\u6587", locale: "zh-TW" }
7300
7229
  ];
7301
7230
  function getDictFilePath(nlpDir, dictId) {
7302
- return path16.join(nlpDir, `${dictId}.dict`);
7231
+ return path15.join(nlpDir, `${dictId}.dict`);
7303
7232
  }
7304
7233
  function isDictDownloaded(nlpDir, dictId) {
7305
- return fs20.existsSync(getDictFilePath(nlpDir, dictId));
7234
+ return fs19.existsSync(getDictFilePath(nlpDir, dictId));
7306
7235
  }
7307
7236
  function getDictList(nlpDir) {
7308
7237
  return AVAILABLE_DICTS.map((d) => {
7309
7238
  const filePath = getDictFilePath(nlpDir, d.id);
7310
- const downloaded = fs20.existsSync(filePath);
7239
+ const downloaded = fs19.existsSync(filePath);
7311
7240
  let fileSize;
7312
7241
  if (downloaded) {
7313
7242
  try {
7314
- fileSize = fs20.statSync(filePath).size;
7243
+ fileSize = fs19.statSync(filePath).size;
7315
7244
  } catch {
7316
7245
  }
7317
7246
  }
@@ -7320,9 +7249,9 @@ function getDictList(nlpDir) {
7320
7249
  }
7321
7250
  function loadDictBuffer(nlpDir, dictId) {
7322
7251
  const filePath = getDictFilePath(nlpDir, dictId);
7323
- if (!fs20.existsSync(filePath)) return null;
7252
+ if (!fs19.existsSync(filePath)) return null;
7324
7253
  try {
7325
- return fs20.readFileSync(filePath);
7254
+ return fs19.readFileSync(filePath);
7326
7255
  } catch (error) {
7327
7256
  console.error(`[NLP DictManager] Failed to read dict file: ${filePath}`, error);
7328
7257
  return null;
@@ -7332,7 +7261,7 @@ async function downloadDict(nlpDir, dictId, onProgress) {
7332
7261
  if (!AVAILABLE_DICTS.find((d) => d.id === dictId)) {
7333
7262
  return { success: false, error: `Unknown dict: ${dictId}` };
7334
7263
  }
7335
- fs20.mkdirSync(nlpDir, { recursive: true });
7264
+ fs19.mkdirSync(nlpDir, { recursive: true });
7336
7265
  const url = `${DICT_DOWNLOAD_URL_BASE}/${dictId}.dict`;
7337
7266
  const filePath = getDictFilePath(nlpDir, dictId);
7338
7267
  const tmpPath = filePath + ".tmp";
@@ -7373,16 +7302,16 @@ async function downloadDict(nlpDir, dictId, onProgress) {
7373
7302
  if (actualSha256 !== expectedSha256) {
7374
7303
  return { success: false, error: "Dictionary integrity check failed (SHA256 mismatch)" };
7375
7304
  }
7376
- fs20.writeFileSync(tmpPath, buffer);
7377
- if (fs20.existsSync(filePath)) fs20.unlinkSync(filePath);
7378
- fs20.renameSync(tmpPath, filePath);
7305
+ fs19.writeFileSync(tmpPath, buffer);
7306
+ if (fs19.existsSync(filePath)) fs19.unlinkSync(filePath);
7307
+ fs19.renameSync(tmpPath, filePath);
7379
7308
  clearJiebaInstance(dictId);
7380
- console.log(`[NLP DictManager] Dict downloaded: ${dictId} (${fs20.statSync(filePath).size} bytes)`);
7309
+ console.log(`[NLP DictManager] Dict downloaded: ${dictId} (${fs19.statSync(filePath).size} bytes)`);
7381
7310
  return { success: true };
7382
7311
  } catch (error) {
7383
- if (fs20.existsSync(tmpPath)) {
7312
+ if (fs19.existsSync(tmpPath)) {
7384
7313
  try {
7385
- fs20.unlinkSync(tmpPath);
7314
+ fs19.unlinkSync(tmpPath);
7386
7315
  } catch {
7387
7316
  }
7388
7317
  }
@@ -7393,9 +7322,9 @@ async function downloadDict(nlpDir, dictId, onProgress) {
7393
7322
  }
7394
7323
  function deleteDict(nlpDir, dictId) {
7395
7324
  const filePath = getDictFilePath(nlpDir, dictId);
7396
- if (!fs20.existsSync(filePath)) return { success: true };
7325
+ if (!fs19.existsSync(filePath)) return { success: true };
7397
7326
  try {
7398
- fs20.unlinkSync(filePath);
7327
+ fs19.unlinkSync(filePath);
7399
7328
  clearJiebaInstance(dictId);
7400
7329
  console.log(`[NLP DictManager] Dict deleted: ${dictId}`);
7401
7330
  return { success: true };
@@ -7495,7 +7424,7 @@ function searchByFts(db, keywords, limit = 1e3, offset = 0) {
7495
7424
  }
7496
7425
 
7497
7426
  // ../../packages/node-runtime/src/import/streaming-importer.ts
7498
- import * as fs21 from "fs";
7427
+ import * as fs20 from "fs";
7499
7428
 
7500
7429
  // ../../packages/node-runtime/src/import/message-deduplicator.ts
7501
7430
  function generateFallbackMessageKey(message) {
@@ -7527,7 +7456,7 @@ function registerMessageAndCheckDuplicate(message, state) {
7527
7456
  // ../../packages/node-runtime/src/import/streaming-importer.ts
7528
7457
  var BATCH_COMMIT_SIZE = 5e4;
7529
7458
  var CHECKPOINT_INTERVAL = 2e5;
7530
- var yieldToEventLoop = () => new Promise((resolve4) => setImmediate(resolve4));
7459
+ var yieldToEventLoop = () => new Promise((resolve2) => setImmediate(resolve2));
7531
7460
  function defaultGenerateSessionId() {
7532
7461
  const ts = Date.now();
7533
7462
  const rand = Math.random().toString(36).substring(2, 8);
@@ -8030,7 +7959,7 @@ async function streamParseFileInfo(filePath, deps) {
8030
7959
  if (!formatFeature) {
8031
7960
  throw new Error("Unrecognized file format");
8032
7961
  }
8033
- const fileSize = fs21.statSync(filePath).size;
7962
+ const fileSize = fs20.statSync(filePath).size;
8034
7963
  deps.onProgress({
8035
7964
  stage: "parsing",
8036
7965
  bytesRead: 0,
@@ -8119,7 +8048,7 @@ async function streamParseFileInfo(filePath, deps) {
8119
8048
  }
8120
8049
  db.close();
8121
8050
  try {
8122
- if (fs21.existsSync(tempDbPath)) fs21.unlinkSync(tempDbPath);
8051
+ if (fs20.existsSync(tempDbPath)) fs20.unlinkSync(tempDbPath);
8123
8052
  } catch {
8124
8053
  }
8125
8054
  throw error;
@@ -8764,8 +8693,8 @@ async function analyzeAutoImportFile(filePath, deps, options2 = {}) {
8764
8693
  }
8765
8694
 
8766
8695
  // ../../packages/node-runtime/src/import/import-lock.ts
8767
- import * as fs22 from "fs";
8768
- import * as path17 from "path";
8696
+ import * as fs21 from "fs";
8697
+ import * as path16 from "path";
8769
8698
  import { randomUUID } from "crypto";
8770
8699
  var IMPORT_LOCK_FILENAME = ".chatlab-import.lock";
8771
8700
  var IMPORT_IN_PROGRESS_ERROR_KEY = "error.import_in_progress";
@@ -8779,7 +8708,7 @@ var ImportInProgressError = class extends Error {
8779
8708
  };
8780
8709
  function parseOwner(lockPath) {
8781
8710
  try {
8782
- const parsed = JSON.parse(fs22.readFileSync(lockPath, "utf-8"));
8711
+ const parsed = JSON.parse(fs21.readFileSync(lockPath, "utf-8"));
8783
8712
  if (typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid) || parsed.pid <= 0 || typeof parsed.token !== "string" || parsed.token.length === 0 || typeof parsed.startedAt !== "number") {
8784
8713
  return null;
8785
8714
  }
@@ -8802,13 +8731,13 @@ function removeStaleLock(lockPath) {
8802
8731
  if (isProcessRunning(owner.pid)) return false;
8803
8732
  } else {
8804
8733
  try {
8805
- if (Date.now() - fs22.statSync(lockPath).mtimeMs < 5e3) return false;
8734
+ if (Date.now() - fs21.statSync(lockPath).mtimeMs < 5e3) return false;
8806
8735
  } catch {
8807
8736
  return true;
8808
8737
  }
8809
8738
  }
8810
8739
  try {
8811
- fs22.unlinkSync(lockPath);
8740
+ fs21.unlinkSync(lockPath);
8812
8741
  appLogger.warn("import-lock", "Removed stale import lock", { ownerPid: owner?.pid });
8813
8742
  return true;
8814
8743
  } catch {
@@ -8817,7 +8746,7 @@ function removeStaleLock(lockPath) {
8817
8746
  }
8818
8747
  function releaseLock(lockPath, fd, owner) {
8819
8748
  try {
8820
- fs22.closeSync(fd);
8749
+ fs21.closeSync(fd);
8821
8750
  } catch (error) {
8822
8751
  appLogger.error("import-lock", "Failed to close import lock", error);
8823
8752
  }
@@ -8826,19 +8755,19 @@ function releaseLock(lockPath, fd, owner) {
8826
8755
  appLogger.warn("import-lock", "Import lock ownership changed before release");
8827
8756
  return;
8828
8757
  }
8829
- fs22.unlinkSync(lockPath);
8758
+ fs21.unlinkSync(lockPath);
8830
8759
  appLogger.info("import-lock", "Import lock released");
8831
8760
  } catch (error) {
8832
8761
  appLogger.error("import-lock", "Failed to release import lock", error);
8833
8762
  }
8834
8763
  }
8835
8764
  async function withDataDirImportLock(userDataDir, task) {
8836
- fs22.mkdirSync(userDataDir, { recursive: true });
8837
- const lockPath = path17.join(userDataDir, IMPORT_LOCK_FILENAME);
8765
+ fs21.mkdirSync(userDataDir, { recursive: true });
8766
+ const lockPath = path16.join(userDataDir, IMPORT_LOCK_FILENAME);
8838
8767
  let fd = null;
8839
8768
  for (let attempt = 0; attempt < 2; attempt++) {
8840
8769
  try {
8841
- fd = fs22.openSync(lockPath, "wx");
8770
+ fd = fs21.openSync(lockPath, "wx");
8842
8771
  break;
8843
8772
  } catch (error) {
8844
8773
  const code = error.code;
@@ -8857,8 +8786,8 @@ async function withDataDirImportLock(userDataDir, task) {
8857
8786
  startedAt: Date.now()
8858
8787
  };
8859
8788
  try {
8860
- fs22.writeFileSync(fd, JSON.stringify(owner), "utf-8");
8861
- fs22.fsyncSync(fd);
8789
+ fs21.writeFileSync(fd, JSON.stringify(owner), "utf-8");
8790
+ fs21.fsyncSync(fd);
8862
8791
  appLogger.info("import-lock", "Import lock acquired");
8863
8792
  return await task();
8864
8793
  } finally {
@@ -8878,8 +8807,8 @@ var ArchiveImportError = class extends Error {
8878
8807
 
8879
8808
  // ../../packages/node-runtime/src/import/archive/archive-reader.ts
8880
8809
  var import_yauzl = __toESM(require_yauzl(), 1);
8881
- import * as fs23 from "fs";
8882
- import * as path18 from "path";
8810
+ import * as fs22 from "fs";
8811
+ import * as path17 from "path";
8883
8812
  import { pipeline } from "stream/promises";
8884
8813
  var DEFAULT_MAX_ENTRIES = 1e5;
8885
8814
  var DEFAULT_MAX_ENTRY_BYTES = 20 * 1024 * 1024 * 1024;
@@ -8998,8 +8927,8 @@ var ZipArchiveReader = class {
8998
8927
  await this.visitEntries(async (entry, openStream) => {
8999
8928
  const destination = targets.get(entry.name);
9000
8929
  if (!destination || entry.isDirectory) return;
9001
- fs23.mkdirSync(path18.dirname(destination), { recursive: true });
9002
- await pipeline(await openStream(), fs23.createWriteStream(destination, { flags: "wx" }));
8930
+ fs22.mkdirSync(path17.dirname(destination), { recursive: true });
8931
+ await pipeline(await openStream(), fs22.createWriteStream(destination, { flags: "wx" }));
9003
8932
  remaining.delete(entry.name);
9004
8933
  });
9005
8934
  if (remaining.size > 0) {
@@ -9016,8 +8945,8 @@ var import_stream_chain9 = __toESM(require_stream_chain(), 1);
9016
8945
  var import_stream_json9 = __toESM(require_stream_json(), 1);
9017
8946
  var import_Pick8 = __toESM(require_Pick(), 1);
9018
8947
  var import_StreamValues9 = __toESM(require_StreamValues(), 1);
9019
- import * as fs24 from "fs";
9020
- import * as path19 from "path";
8948
+ import * as fs23 from "fs";
8949
+ import * as path18 from "path";
9021
8950
  var { chain: chain9 } = import_stream_chain9.default;
9022
8951
  var { parser: parser10 } = import_stream_json9.default;
9023
8952
  var { pick: pick8 } = import_Pick8.default;
@@ -9146,16 +9075,16 @@ var GoogleChatTakeoutResolver = class {
9146
9075
  `Google Chat conversation is missing required files: ${chat.chatId}`
9147
9076
  );
9148
9077
  }
9149
- fs24.mkdirSync(targetDir, { recursive: true });
9078
+ fs23.mkdirSync(targetDir, { recursive: true });
9150
9079
  await reader.pipeEntries(
9151
9080
  /* @__PURE__ */ new Map([
9152
- [userInfoEntry, path19.join(targetDir, "user_info.json")],
9153
- [groupInfoEntry, path19.join(targetDir, "group_info.json")],
9154
- [messagesEntry, path19.join(targetDir, "messages.json")]
9081
+ [userInfoEntry, path18.join(targetDir, "user_info.json")],
9082
+ [groupInfoEntry, path18.join(targetDir, "group_info.json")],
9083
+ [messagesEntry, path18.join(targetDir, "messages.json")]
9155
9084
  ])
9156
9085
  );
9157
- const manifestPath = path19.join(targetDir, "google-chat-import.json");
9158
- fs24.writeFileSync(
9086
+ const manifestPath = path18.join(targetDir, "google-chat-import.json");
9087
+ fs23.writeFileSync(
9159
9088
  manifestPath,
9160
9089
  JSON.stringify(
9161
9090
  {
@@ -9178,8 +9107,8 @@ var GoogleChatTakeoutResolver = class {
9178
9107
  };
9179
9108
 
9180
9109
  // ../../packages/node-runtime/src/import/archive/source-manager.ts
9181
- import * as fs25 from "fs";
9182
- import * as path20 from "path";
9110
+ import * as fs24 from "fs";
9111
+ import * as path19 from "path";
9183
9112
  import { randomUUID as randomUUID2 } from "crypto";
9184
9113
  var DEFAULT_TTL_MS = 30 * 60 * 1e3;
9185
9114
  var ArchiveImportSourceManager = class {
@@ -9190,11 +9119,11 @@ var ArchiveImportSourceManager = class {
9190
9119
  now;
9191
9120
  resolvers;
9192
9121
  constructor(options2 = {}) {
9193
- this.tempRoot = options2.tempRoot ?? createChatLabTempDir("imports", "sources-");
9122
+ this.tempRoot = options2.tempRoot ?? path19.join(process.cwd(), ".chatlab-import-sources");
9194
9123
  this.ttlMs = options2.ttlMs ?? DEFAULT_TTL_MS;
9195
9124
  this.now = options2.now ?? Date.now;
9196
9125
  this.resolvers = options2.resolvers ?? [new GoogleChatTakeoutResolver()];
9197
- fs25.mkdirSync(this.tempRoot, { recursive: true });
9126
+ fs24.mkdirSync(this.tempRoot, { recursive: true });
9198
9127
  }
9199
9128
  prepareLocalArchive(archivePath) {
9200
9129
  return this.prepareArchive(archivePath, false);
@@ -9251,7 +9180,7 @@ var ArchiveImportSourceManager = class {
9251
9180
  `Archive conversation was not found: ${chatId}`
9252
9181
  );
9253
9182
  }
9254
- const materializedDir = fs25.mkdtempSync(path20.join(this.tempRoot, `materialized-${sourceId}-`));
9183
+ const materializedDir = fs24.mkdtempSync(path19.join(this.tempRoot, `materialized-${sourceId}-`));
9255
9184
  try {
9256
9185
  const reader = new ZipArchiveReader(record.archivePath);
9257
9186
  const materialized = await record.resolver.materialize(reader, chat, materializedDir);
@@ -9302,7 +9231,7 @@ var ArchiveImportSourceManager = class {
9302
9231
  }
9303
9232
  removePath(targetPath) {
9304
9233
  try {
9305
- fs25.rmSync(targetPath, { recursive: true, force: true });
9234
+ fs24.rmSync(targetPath, { recursive: true, force: true });
9306
9235
  } catch {
9307
9236
  }
9308
9237
  }
@@ -9372,12 +9301,12 @@ ${rawErrorLabel}: ${details}`;
9372
9301
  }
9373
9302
 
9374
9303
  // ../../packages/node-runtime/src/ai/assistant-parser.ts
9375
- import * as path21 from "path";
9304
+ import * as path20 from "path";
9376
9305
  import matter from "gray-matter";
9377
9306
  function parseAssistantFile(content, filePath) {
9378
9307
  try {
9379
9308
  const { data: fm, content: body } = matter(content);
9380
- const id = fm.id ?? path21.basename(filePath, ".md");
9309
+ const id = fm.id ?? path20.basename(filePath, ".md");
9381
9310
  const name = fm.name;
9382
9311
  if (!name) return null;
9383
9312
  return {
@@ -9456,8 +9385,8 @@ var AssistantManager = class {
9456
9385
  }
9457
9386
  // ==================== Init ====================
9458
9387
  init() {
9459
- const { fs: fs37, assistantsDir } = this.deps;
9460
- fs37.ensureDir(assistantsDir);
9388
+ const { fs: fs35, assistantsDir } = this.deps;
9389
+ fs35.ensureDir(assistantsDir);
9461
9390
  const generalCreated = this.ensureGeneralAssistants();
9462
9391
  this.loadAll();
9463
9392
  this.initialized = true;
@@ -9468,26 +9397,26 @@ var AssistantManager = class {
9468
9397
  return { total: this.cache.size, generalCreated };
9469
9398
  }
9470
9399
  ensureGeneralAssistants() {
9471
- const { fs: fs37, assistantsDir } = this.deps;
9400
+ const { fs: fs35, assistantsDir } = this.deps;
9472
9401
  let anyCreated = false;
9473
9402
  for (const id of this.generalIds) {
9474
9403
  const config = this.getBuiltinConfig(id);
9475
9404
  if (!config) continue;
9476
- const filePath = fs37.joinPath(assistantsDir, `${id}.md`);
9477
- if (fs37.fileExists(filePath)) continue;
9478
- fs37.writeFile(filePath, serializeAssistant({ ...config, builtinId: config.id }));
9405
+ const filePath = fs35.joinPath(assistantsDir, `${id}.md`);
9406
+ if (fs35.fileExists(filePath)) continue;
9407
+ fs35.writeFile(filePath, serializeAssistant({ ...config, builtinId: config.id }));
9479
9408
  anyCreated = true;
9480
9409
  }
9481
9410
  return anyCreated;
9482
9411
  }
9483
9412
  loadAll() {
9484
- const { fs: fs37, assistantsDir } = this.deps;
9413
+ const { fs: fs35, assistantsDir } = this.deps;
9485
9414
  this.cache.clear();
9486
- const files = fs37.listFiles(assistantsDir, ".md");
9415
+ const files = fs35.listFiles(assistantsDir, ".md");
9487
9416
  for (const file of files) {
9488
9417
  try {
9489
- const filePath = fs37.joinPath(assistantsDir, file);
9490
- const content = fs37.readFile(filePath);
9418
+ const filePath = fs35.joinPath(assistantsDir, file);
9419
+ const content = fs35.readFile(filePath);
9491
9420
  const config = parseAssistantFile(content, filePath);
9492
9421
  if (config) {
9493
9422
  this.cache.set(config.id, config);
@@ -9599,12 +9528,12 @@ var AssistantManager = class {
9599
9528
  };
9600
9529
 
9601
9530
  // ../../packages/node-runtime/src/ai/skill-parser.ts
9602
- import * as path22 from "path";
9531
+ import * as path21 from "path";
9603
9532
  import matter2 from "gray-matter";
9604
9533
  function parseSkillFile(content, filePath) {
9605
9534
  try {
9606
9535
  const { data: fm, content: prompt } = matter2(content);
9607
- const id = fm.id ?? path22.basename(filePath, ".md");
9536
+ const id = fm.id ?? path21.basename(filePath, ".md");
9608
9537
  const name = fm.name;
9609
9538
  if (!name) return null;
9610
9539
  return {
@@ -9623,7 +9552,7 @@ function parseSkillFile(content, filePath) {
9623
9552
  function extractSkillId(content, filePath) {
9624
9553
  try {
9625
9554
  const { data: fm } = matter2(content);
9626
- return fm.id ?? path22.basename(filePath, ".md");
9555
+ return fm.id ?? path21.basename(filePath, ".md");
9627
9556
  } catch {
9628
9557
  return null;
9629
9558
  }
@@ -9642,8 +9571,8 @@ function validateChatScope(raw) {
9642
9571
 
9643
9572
  // ../../packages/node-runtime/src/ai/chats.ts
9644
9573
  import Database from "better-sqlite3";
9645
- import * as fs26 from "fs";
9646
- import * as path23 from "path";
9574
+ import * as fs25 from "fs";
9575
+ import * as path22 from "path";
9647
9576
  var DEFAULT_GENERAL_ID = "general_cn";
9648
9577
  var defaultLogger = {
9649
9578
  warn(_category, message, extra) {
@@ -9662,14 +9591,14 @@ var AIChatManager = class {
9662
9591
  this.nativeBinding = options2?.nativeBinding;
9663
9592
  }
9664
9593
  ensureDir(dir) {
9665
- if (!fs26.existsSync(dir)) {
9666
- fs26.mkdirSync(dir, { recursive: true });
9594
+ if (!fs25.existsSync(dir)) {
9595
+ fs25.mkdirSync(dir, { recursive: true });
9667
9596
  }
9668
9597
  }
9669
9598
  getDb() {
9670
9599
  if (this.db) return this.db;
9671
9600
  this.ensureDir(this.aiDataDir);
9672
- const dbPath = path23.join(this.aiDataDir, "conversations.db");
9601
+ const dbPath = path22.join(this.aiDataDir, "conversations.db");
9673
9602
  this.db = this.nativeBinding ? new Database(dbPath, { nativeBinding: this.nativeBinding }) : new Database(dbPath);
9674
9603
  this.db.pragma("journal_mode = WAL");
9675
9604
  this.db.exec(`
@@ -9912,16 +9841,16 @@ var AIChatManager = class {
9912
9841
  if (allRows.length === 0) return [];
9913
9842
  const rowMap = new Map(allRows.map((row) => [row.id, row]));
9914
9843
  let currentId = leafMessageId ?? this.getActiveMessageId(aiChatId);
9915
- const path33 = [];
9844
+ const path31 = [];
9916
9845
  const seen = /* @__PURE__ */ new Set();
9917
9846
  while (currentId && !seen.has(currentId)) {
9918
9847
  seen.add(currentId);
9919
9848
  const row = rowMap.get(currentId);
9920
9849
  if (!row) break;
9921
- path33.push(row);
9850
+ path31.push(row);
9922
9851
  currentId = row.parentId;
9923
9852
  }
9924
- return path33.length > 0 ? path33.reverse() : allRows;
9853
+ return path31.length > 0 ? path31.reverse() : allRows;
9925
9854
  }
9926
9855
  // ==================== 生命周期 ====================
9927
9856
  close() {
@@ -10491,21 +10420,21 @@ var SkillManagerCore = class {
10491
10420
  }
10492
10421
  // ==================== Init ====================
10493
10422
  init() {
10494
- const { fs: fs37, skillsDir } = this.deps;
10495
- fs37.ensureDir(skillsDir);
10423
+ const { fs: fs35, skillsDir } = this.deps;
10424
+ fs35.ensureDir(skillsDir);
10496
10425
  this.loadAll();
10497
10426
  this.initialized = true;
10498
10427
  this.deps.logger?.info("SkillManager", "Initialized", { total: this.cache.size });
10499
10428
  return { total: this.cache.size };
10500
10429
  }
10501
10430
  loadAll() {
10502
- const { fs: fs37, skillsDir } = this.deps;
10431
+ const { fs: fs35, skillsDir } = this.deps;
10503
10432
  this.cache.clear();
10504
- const files = fs37.listFiles(skillsDir, ".md");
10433
+ const files = fs35.listFiles(skillsDir, ".md");
10505
10434
  for (const file of files) {
10506
10435
  try {
10507
- const filePath = fs37.joinPath(skillsDir, file);
10508
- const content = fs37.readFile(filePath);
10436
+ const filePath = fs35.joinPath(skillsDir, file);
10437
+ const content = fs35.readFile(filePath);
10509
10438
  const def = parseSkillFile(content, filePath);
10510
10439
  if (def) {
10511
10440
  this.cache.set(def.id, def);
@@ -10657,8 +10586,8 @@ var SkillManagerCore = class {
10657
10586
  };
10658
10587
 
10659
10588
  // ../../packages/node-runtime/src/ai/skill-manager.ts
10660
- import * as fs27 from "fs";
10661
- import * as path24 from "path";
10589
+ import * as fs26 from "fs";
10590
+ import * as path23 from "path";
10662
10591
  var SKILLS_DIR_NAME = "skills";
10663
10592
  var defaultLogger2 = {
10664
10593
  info: () => {
@@ -10668,26 +10597,26 @@ var defaultLogger2 = {
10668
10597
  };
10669
10598
  var nodeFs = {
10670
10599
  ensureDir(dir) {
10671
- fs27.mkdirSync(dir, { recursive: true });
10600
+ fs26.mkdirSync(dir, { recursive: true });
10672
10601
  },
10673
10602
  listFiles(dir, ext) {
10674
- if (!fs27.existsSync(dir)) return [];
10675
- return fs27.readdirSync(dir).filter((file) => file.endsWith(ext));
10603
+ if (!fs26.existsSync(dir)) return [];
10604
+ return fs26.readdirSync(dir).filter((file) => file.endsWith(ext));
10676
10605
  },
10677
10606
  readFile(filePath) {
10678
- return fs27.readFileSync(filePath, "utf-8");
10607
+ return fs26.readFileSync(filePath, "utf-8");
10679
10608
  },
10680
10609
  writeFile(filePath, content) {
10681
- fs27.writeFileSync(filePath, content, "utf-8");
10610
+ fs26.writeFileSync(filePath, content, "utf-8");
10682
10611
  },
10683
10612
  deleteFile(filePath) {
10684
- fs27.unlinkSync(filePath);
10613
+ fs26.unlinkSync(filePath);
10685
10614
  },
10686
10615
  fileExists(filePath) {
10687
- return fs27.existsSync(filePath);
10616
+ return fs26.existsSync(filePath);
10688
10617
  },
10689
10618
  joinPath(...parts) {
10690
- return path24.join(...parts);
10619
+ return path23.join(...parts);
10691
10620
  }
10692
10621
  };
10693
10622
  var SkillManager = class {
@@ -10697,7 +10626,7 @@ var SkillManager = class {
10697
10626
  this.logger = logger ?? defaultLogger2;
10698
10627
  this.core = new SkillManagerCore({
10699
10628
  fs: nodeFs,
10700
- skillsDir: path24.join(aiDataDir, SKILLS_DIR_NAME),
10629
+ skillsDir: path23.join(aiDataDir, SKILLS_DIR_NAME),
10701
10630
  builtinRawSkills: [],
10702
10631
  logger: {
10703
10632
  info: () => {
@@ -14527,9 +14456,9 @@ var localeMap = {
14527
14456
  "ja-JP": ja_JP_default,
14528
14457
  "zh-TW": zh_TW_default
14529
14458
  };
14530
- function getNestedValue(obj, path33) {
14459
+ function getNestedValue(obj, path31) {
14531
14460
  let current = obj;
14532
- for (const segment2 of path33.split(".")) {
14461
+ for (const segment2 of path31.split(".")) {
14533
14462
  if (current == null || typeof current !== "object") return void 0;
14534
14463
  current = current[segment2];
14535
14464
  }
@@ -15042,49 +14971,6 @@ var LLMConfigStore = class {
15042
14971
  }
15043
14972
  };
15044
14973
 
15045
- // ../../packages/node-runtime/src/ai/file-config-storage.ts
15046
- import * as fs28 from "fs";
15047
- import * as path25 from "path";
15048
- function createFileConfigStorage(baseDir) {
15049
- return {
15050
- readJson(key) {
15051
- try {
15052
- return JSON.parse(fs28.readFileSync(path25.join(baseDir, `${key}.json`), "utf-8"));
15053
- } catch {
15054
- return null;
15055
- }
15056
- },
15057
- writeJson(key, data) {
15058
- fs28.mkdirSync(baseDir, { recursive: true });
15059
- fs28.writeFileSync(path25.join(baseDir, `${key}.json`), JSON.stringify(data, null, 2), "utf-8");
15060
- }
15061
- };
15062
- }
15063
-
15064
- // ../../packages/node-runtime/src/ai/auth-profile-llm-config-store.ts
15065
- var defaultDeps = {
15066
- resolveApiKey: (provider, authProfile) => resolveApiKey(provider, authProfile) || void 0,
15067
- writeAuthProfile,
15068
- deleteAuthProfile
15069
- };
15070
- function getAuthProfile2(config) {
15071
- return config.authProfile;
15072
- }
15073
- function createAuthProfileLlmConfigStore(storage, deps = defaultDeps) {
15074
- return new LLMConfigStore(storage, {
15075
- resolveApiKey: deps.resolveApiKey,
15076
- onApiKeyCreated: (config, apiKey) => {
15077
- const profileName = config.name?.toLowerCase().replace(/\s+/g, "-") || config.provider;
15078
- deps.writeAuthProfile(profileName, { type: "api_key", provider: config.provider, key: apiKey });
15079
- return profileName;
15080
- },
15081
- onApiKeyDeleted: (config) => {
15082
- const profileName = getAuthProfile2(config);
15083
- if (profileName) deps.deleteAuthProfile(profileName);
15084
- }
15085
- });
15086
- }
15087
-
15088
14974
  // ../../packages/node-runtime/src/ai/custom-store.ts
15089
14975
  function generateCustomId() {
15090
14976
  return `custom:${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
@@ -15904,8 +15790,8 @@ function exportWithFormat(params, openDatabase) {
15904
15790
  }
15905
15791
 
15906
15792
  // ../../packages/node-runtime/src/merger/temp-db.ts
15907
- import * as fs29 from "fs";
15908
- import * as path26 from "path";
15793
+ import * as fs27 from "fs";
15794
+ import * as path24 from "path";
15909
15795
  var TEMP_DB_SCHEMA = `
15910
15796
  CREATE TABLE IF NOT EXISTS meta (
15911
15797
  name TEXT NOT NULL,
@@ -16150,21 +16036,21 @@ function exportSessionToJson(db) {
16150
16036
  }
16151
16037
  function deleteTempDatabase(dbPath) {
16152
16038
  try {
16153
- if (fs29.existsSync(dbPath)) fs29.unlinkSync(dbPath);
16039
+ if (fs27.existsSync(dbPath)) fs27.unlinkSync(dbPath);
16154
16040
  const walPath = dbPath + "-wal";
16155
16041
  const shmPath = dbPath + "-shm";
16156
- if (fs29.existsSync(walPath)) fs29.unlinkSync(walPath);
16157
- if (fs29.existsSync(shmPath)) fs29.unlinkSync(shmPath);
16042
+ if (fs27.existsSync(walPath)) fs27.unlinkSync(walPath);
16043
+ if (fs27.existsSync(shmPath)) fs27.unlinkSync(shmPath);
16158
16044
  } catch {
16159
16045
  }
16160
16046
  }
16161
16047
  function cleanupTempDatabases(tempDir) {
16162
16048
  try {
16163
- if (!fs29.existsSync(tempDir)) return;
16164
- const files = fs29.readdirSync(tempDir);
16049
+ if (!fs27.existsSync(tempDir)) return;
16050
+ const files = fs27.readdirSync(tempDir);
16165
16051
  for (const file of files) {
16166
16052
  if (file.startsWith("merge_") && file.endsWith(".db")) {
16167
- deleteTempDatabase(path26.join(tempDir, file));
16053
+ deleteTempDatabase(path24.join(tempDir, file));
16168
16054
  }
16169
16055
  }
16170
16056
  } catch {
@@ -16243,7 +16129,6 @@ function deleteSession(adapter, sessionId) {
16243
16129
  var member_service_exports = {};
16244
16130
  __export(member_service_exports, {
16245
16131
  deleteMember: () => deleteMember2,
16246
- deleteMembers: () => deleteMembers2,
16247
16132
  getMemberNameHistory: () => getMemberNameHistory2,
16248
16133
  getMembers: () => getMembers,
16249
16134
  getMembersPaginated: () => getMembersPaginated2,
@@ -16277,10 +16162,6 @@ function deleteMember2(adapter, sessionId, memberId) {
16277
16162
  const db = adapter.ensureWritable(sessionId);
16278
16163
  return deleteMember(db, memberId);
16279
16164
  }
16280
- function deleteMembers2(adapter, sessionId, memberIds) {
16281
- const db = adapter.ensureWritable(sessionId);
16282
- return deleteMembers(db, memberIds);
16283
- }
16284
16165
  function getMemberNameHistory2(adapter, sessionId, memberId) {
16285
16166
  const db = adapter.ensureReadonly(sessionId);
16286
16167
  return getMemberNameHistory(db, memberId);
@@ -16549,8 +16430,8 @@ function clearSessionOwner(adapter, sessionId) {
16549
16430
  }
16550
16431
 
16551
16432
  // ../../packages/node-runtime/src/services/contacts/overrides.ts
16552
- import fs30 from "fs";
16553
- import path27 from "path";
16433
+ import fs28 from "fs";
16434
+ import path25 from "path";
16554
16435
  var CONTACT_OVERRIDES_FILE_NAME = "contact-overrides.json";
16555
16436
  var CONTACT_OVERRIDES_TMP_PREFIX = "contact-overrides.tmp-";
16556
16437
  var CONTACT_OVERRIDES_VERSION = 1;
@@ -16561,23 +16442,23 @@ function createEmptyContactOverridesFile() {
16561
16442
  };
16562
16443
  }
16563
16444
  function getContactOverridesPath(snapshotDir) {
16564
- return path27.join(snapshotDir, CONTACT_OVERRIDES_FILE_NAME);
16445
+ return path25.join(snapshotDir, CONTACT_OVERRIDES_FILE_NAME);
16565
16446
  }
16566
16447
  function readContactOverrides(snapshotDir) {
16567
16448
  const filePath = getContactOverridesPath(snapshotDir);
16568
- if (!fs30.existsSync(filePath)) return createEmptyContactOverridesFile();
16449
+ if (!fs28.existsSync(filePath)) return createEmptyContactOverridesFile();
16569
16450
  try {
16570
- return normalizeContactOverrides(JSON.parse(fs30.readFileSync(filePath, "utf-8")));
16451
+ return normalizeContactOverrides(JSON.parse(fs28.readFileSync(filePath, "utf-8")));
16571
16452
  } catch (error) {
16572
16453
  appLogger.warn("contacts", "contact overrides file is unreadable", error);
16573
16454
  return createEmptyContactOverridesFile();
16574
16455
  }
16575
16456
  }
16576
16457
  function writeContactOverrides(snapshotDir, overrides) {
16577
- if (!fs30.existsSync(snapshotDir)) fs30.mkdirSync(snapshotDir, { recursive: true });
16578
- const tmpPath = path27.join(snapshotDir, `${CONTACT_OVERRIDES_TMP_PREFIX}${process.pid}-${Date.now()}`);
16579
- fs30.writeFileSync(tmpPath, JSON.stringify(normalizeContactOverrides(overrides), null, 2), "utf-8");
16580
- fs30.renameSync(tmpPath, getContactOverridesPath(snapshotDir));
16458
+ if (!fs28.existsSync(snapshotDir)) fs28.mkdirSync(snapshotDir, { recursive: true });
16459
+ const tmpPath = path25.join(snapshotDir, `${CONTACT_OVERRIDES_TMP_PREFIX}${process.pid}-${Date.now()}`);
16460
+ fs28.writeFileSync(tmpPath, JSON.stringify(normalizeContactOverrides(overrides), null, 2), "utf-8");
16461
+ fs28.renameSync(tmpPath, getContactOverridesPath(snapshotDir));
16581
16462
  }
16582
16463
  function normalizeContactOverrides(value) {
16583
16464
  const input = isRecord2(value) ? value : {};
@@ -16612,23 +16493,23 @@ function buildContactsSignature(adapter, timeRangePreset) {
16612
16493
  }
16613
16494
 
16614
16495
  // ../../packages/node-runtime/src/services/contacts/snapshot.ts
16615
- import fs31 from "fs";
16616
- import path28 from "path";
16496
+ import fs29 from "fs";
16497
+ import path26 from "path";
16617
16498
  var CONTACTS_SNAPSHOT_TMP_PREFIX = "contacts-snapshot.tmp-";
16618
16499
  function getContactsSnapshotPath(snapshotDir, timeRangePreset) {
16619
16500
  const preset = normalizeContactsTimeRangePreset(timeRangePreset);
16620
- return path28.join(snapshotDir, `contacts-snapshot-${preset}.json`);
16501
+ return path26.join(snapshotDir, `contacts-snapshot-${preset}.json`);
16621
16502
  }
16622
16503
  function readContactsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
16623
16504
  const snapshotPath = getContactsSnapshotPath(snapshotDir, timeRangePreset);
16624
- if (!fs31.existsSync(snapshotPath)) return null;
16505
+ if (!fs29.existsSync(snapshotPath)) return null;
16625
16506
  try {
16626
- return JSON.parse(fs31.readFileSync(snapshotPath, "utf-8"));
16507
+ return JSON.parse(fs29.readFileSync(snapshotPath, "utf-8"));
16627
16508
  } catch (error) {
16628
16509
  const ts = options2.now?.() ?? Date.now();
16629
- const backupPath = path28.join(snapshotDir, `contacts-snapshot.corrupt-${ts}.json`);
16510
+ const backupPath = path26.join(snapshotDir, `contacts-snapshot.corrupt-${ts}.json`);
16630
16511
  try {
16631
- fs31.renameSync(snapshotPath, backupPath);
16512
+ fs29.renameSync(snapshotPath, backupPath);
16632
16513
  } catch (renameError) {
16633
16514
  appLogger.warn("contacts", "failed to backup corrupt contacts snapshot", renameError);
16634
16515
  }
@@ -16637,17 +16518,17 @@ function readContactsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
16637
16518
  }
16638
16519
  }
16639
16520
  function writeContactsSnapshot(snapshotDir, snapshot) {
16640
- if (!fs31.existsSync(snapshotDir)) fs31.mkdirSync(snapshotDir, { recursive: true });
16641
- const tmpPath = path28.join(snapshotDir, `${CONTACTS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
16642
- fs31.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
16643
- fs31.renameSync(tmpPath, getContactsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
16521
+ if (!fs29.existsSync(snapshotDir)) fs29.mkdirSync(snapshotDir, { recursive: true });
16522
+ const tmpPath = path26.join(snapshotDir, `${CONTACTS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
16523
+ fs29.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
16524
+ fs29.renameSync(tmpPath, getContactsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
16644
16525
  }
16645
16526
  function cleanupContactsSnapshotTempFiles(snapshotDir) {
16646
- if (!fs31.existsSync(snapshotDir)) return;
16647
- for (const name of fs31.readdirSync(snapshotDir)) {
16527
+ if (!fs29.existsSync(snapshotDir)) return;
16528
+ for (const name of fs29.readdirSync(snapshotDir)) {
16648
16529
  if (!name.startsWith(CONTACTS_SNAPSHOT_TMP_PREFIX)) continue;
16649
16530
  try {
16650
- fs31.rmSync(path28.join(snapshotDir, name), { force: true });
16531
+ fs29.rmSync(path26.join(snapshotDir, name), { force: true });
16651
16532
  } catch (error) {
16652
16533
  appLogger.warn("contacts", "failed to remove contacts snapshot temp file", error);
16653
16534
  }
@@ -16685,7 +16566,7 @@ function createWorker(workerData, entryUrlInput) {
16685
16566
  return new Worker(bootstrap, options2);
16686
16567
  }
16687
16568
  function createContactsWorkerRunner(options2) {
16688
- return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((resolve4, reject) => {
16569
+ return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((resolve2, reject) => {
16689
16570
  if (signal.aborted) {
16690
16571
  reject(createAbortError());
16691
16572
  return;
@@ -16716,7 +16597,7 @@ function createContactsWorkerRunner(options2) {
16716
16597
  if (message.type === "success" && message.snapshot) {
16717
16598
  settled = true;
16718
16599
  signal.removeEventListener("abort", abort);
16719
- resolve4(message.snapshot);
16600
+ resolve2(message.snapshot);
16720
16601
  void worker.terminate();
16721
16602
  return;
16722
16603
  }
@@ -17145,23 +17026,23 @@ function buildPeopleRelationshipsSignature(adapter, timeRangePreset) {
17145
17026
  }
17146
17027
 
17147
17028
  // ../../packages/node-runtime/src/services/people/relationships/snapshot.ts
17148
- import fs32 from "fs";
17149
- import path29 from "path";
17029
+ import fs30 from "fs";
17030
+ import path27 from "path";
17150
17031
  var PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX = "people-relationships-snapshot.tmp-";
17151
17032
  function getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset) {
17152
17033
  const preset = normalizePeopleRelationshipsTimeRangePreset(timeRangePreset);
17153
- return path29.join(snapshotDir, `graph-snapshot-${preset}.json`);
17034
+ return path27.join(snapshotDir, `graph-snapshot-${preset}.json`);
17154
17035
  }
17155
17036
  function readPeopleRelationshipsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
17156
17037
  const snapshotPath = getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset);
17157
- if (!fs32.existsSync(snapshotPath)) return null;
17038
+ if (!fs30.existsSync(snapshotPath)) return null;
17158
17039
  try {
17159
- return JSON.parse(fs32.readFileSync(snapshotPath, "utf-8"));
17040
+ return JSON.parse(fs30.readFileSync(snapshotPath, "utf-8"));
17160
17041
  } catch (error) {
17161
17042
  const ts = options2.now?.() ?? Date.now();
17162
- const backupPath = path29.join(snapshotDir, `graph-snapshot.corrupt-${ts}.json`);
17043
+ const backupPath = path27.join(snapshotDir, `graph-snapshot.corrupt-${ts}.json`);
17163
17044
  try {
17164
- fs32.renameSync(snapshotPath, backupPath);
17045
+ fs30.renameSync(snapshotPath, backupPath);
17165
17046
  } catch (renameError) {
17166
17047
  appLogger.warn("people-relationships", "failed to backup corrupt people relationships snapshot", renameError);
17167
17048
  }
@@ -17170,17 +17051,17 @@ function readPeopleRelationshipsSnapshot(snapshotDir, timeRangePreset, options2
17170
17051
  }
17171
17052
  }
17172
17053
  function writePeopleRelationshipsSnapshot(snapshotDir, snapshot) {
17173
- if (!fs32.existsSync(snapshotDir)) fs32.mkdirSync(snapshotDir, { recursive: true });
17174
- const tmpPath = path29.join(snapshotDir, `${PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
17175
- fs32.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
17176
- fs32.renameSync(tmpPath, getPeopleRelationshipsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
17054
+ if (!fs30.existsSync(snapshotDir)) fs30.mkdirSync(snapshotDir, { recursive: true });
17055
+ const tmpPath = path27.join(snapshotDir, `${PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
17056
+ fs30.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
17057
+ fs30.renameSync(tmpPath, getPeopleRelationshipsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
17177
17058
  }
17178
17059
  function cleanupPeopleRelationshipsSnapshotTempFiles(snapshotDir) {
17179
- if (!fs32.existsSync(snapshotDir)) return;
17180
- for (const name of fs32.readdirSync(snapshotDir)) {
17060
+ if (!fs30.existsSync(snapshotDir)) return;
17061
+ for (const name of fs30.readdirSync(snapshotDir)) {
17181
17062
  if (!name.startsWith(PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX)) continue;
17182
17063
  try {
17183
- fs32.rmSync(path29.join(snapshotDir, name), { force: true });
17064
+ fs30.rmSync(path27.join(snapshotDir, name), { force: true });
17184
17065
  } catch (error) {
17185
17066
  appLogger.warn("people-relationships", "failed to remove people relationships snapshot temp file", error);
17186
17067
  }
@@ -17218,7 +17099,7 @@ function createWorker2(workerData, entryUrlInput) {
17218
17099
  return new Worker2(bootstrap, options2);
17219
17100
  }
17220
17101
  function createPeopleRelationshipsWorkerRunner(options2) {
17221
- return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((resolve4, reject) => {
17102
+ return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((resolve2, reject) => {
17222
17103
  if (signal.aborted) {
17223
17104
  reject(createAbortError2());
17224
17105
  return;
@@ -17249,7 +17130,7 @@ function createPeopleRelationshipsWorkerRunner(options2) {
17249
17130
  if (message.type === "success" && message.snapshot) {
17250
17131
  settled = true;
17251
17132
  signal.removeEventListener("abort", abort);
17252
- resolve4(message.snapshot);
17133
+ resolve2(message.snapshot);
17253
17134
  void worker.terminate();
17254
17135
  return;
17255
17136
  }
@@ -17702,7 +17583,7 @@ __export(relationships_exports, {
17702
17583
  });
17703
17584
 
17704
17585
  // ../../packages/node-runtime/src/services/global-insight/service.ts
17705
- import fs33 from "fs";
17586
+ import fs31 from "fs";
17706
17587
 
17707
17588
  // ../../packages/node-runtime/src/services/global-insight/signature.ts
17708
17589
  function buildAnnualSummarySignature(adapter, range) {
@@ -17729,7 +17610,7 @@ function resolveDefaultAnnualSummaryWorkerEntryUrl(currentModuleUrl = import.met
17729
17610
  return entryExists(sibling) ? sibling : new URL("./global-insight-worker.js", moduleUrl);
17730
17611
  }
17731
17612
  function createAnnualSummaryWorkerRunner(options2) {
17732
- return ({ signature, range, signal, onProgress }) => new Promise((resolve4, reject) => {
17613
+ return ({ signature, range, signal, onProgress }) => new Promise((resolve2, reject) => {
17733
17614
  if (signal.aborted) {
17734
17615
  reject(new Error("annual summary worker aborted"));
17735
17616
  return;
@@ -17760,7 +17641,7 @@ function createAnnualSummaryWorkerRunner(options2) {
17760
17641
  if (message.type === "success" && message.snapshot) {
17761
17642
  settled = true;
17762
17643
  signal.removeEventListener("abort", abort);
17763
- resolve4(message.snapshot);
17644
+ resolve2(message.snapshot);
17764
17645
  void worker.terminate();
17765
17646
  return;
17766
17647
  }
@@ -17955,7 +17836,7 @@ var DefaultGlobalInsightService = class {
17955
17836
  }
17956
17837
  getSnapshot(range) {
17957
17838
  const key = toAnnualSummaryRangeKey(range);
17958
- if (this.snapshots.has(key) && !fs33.existsSync(getAnnualSummarySnapshotPath(this.snapshotDir, range))) {
17839
+ if (this.snapshots.has(key) && !fs31.existsSync(getAnnualSummarySnapshotPath(this.snapshotDir, range))) {
17959
17840
  this.snapshots.delete(key);
17960
17841
  }
17961
17842
  if (!this.snapshots.has(key)) {
@@ -18003,8 +17884,8 @@ __export(global_insight_exports, {
18003
17884
  });
18004
17885
 
18005
17886
  // ../../packages/node-runtime/src/semantic-index/config.ts
18006
- import fs34 from "fs";
18007
- import path30 from "path";
17887
+ import fs32 from "fs";
17888
+ import path28 from "path";
18008
17889
  var DEFAULT_SEMANTIC_INDEX_MODEL_DOWNLOAD_SOURCE = "huggingface";
18009
17890
  var SEMANTIC_INDEX_CONFIG_VERSION = 1;
18010
17891
  var SEARCH_MAX_RESULTS_DEFAULT = 10;
@@ -18093,9 +17974,9 @@ var SemanticIndexConfigStore = class {
18093
17974
  return this.set({ ...this.get(), enabled });
18094
17975
  }
18095
17976
  get() {
18096
- if (!fs34.existsSync(this.filePath)) return defaultSemanticIndexConfig();
17977
+ if (!fs32.existsSync(this.filePath)) return defaultSemanticIndexConfig();
18097
17978
  try {
18098
- const raw = JSON.parse(fs34.readFileSync(this.filePath, "utf-8"));
17979
+ const raw = JSON.parse(fs32.readFileSync(this.filePath, "utf-8"));
18099
17980
  return normalizeConfig(raw);
18100
17981
  } catch {
18101
17982
  return defaultSemanticIndexConfig();
@@ -18103,9 +17984,9 @@ var SemanticIndexConfigStore = class {
18103
17984
  }
18104
17985
  set(config) {
18105
17986
  const normalized = normalizeConfig(config);
18106
- const dir = path30.dirname(this.filePath);
18107
- if (!fs34.existsSync(dir)) fs34.mkdirSync(dir, { recursive: true });
18108
- fs34.writeFileSync(this.filePath, JSON.stringify(normalized, null, 2), "utf-8");
17987
+ const dir = path28.dirname(this.filePath);
17988
+ if (!fs32.existsSync(dir)) fs32.mkdirSync(dir, { recursive: true });
17989
+ fs32.writeFileSync(this.filePath, JSON.stringify(normalized, null, 2), "utf-8");
18109
17990
  return normalized;
18110
17991
  }
18111
17992
  resolveModelId() {
@@ -18114,7 +17995,7 @@ var SemanticIndexConfigStore = class {
18114
17995
  };
18115
17996
 
18116
17997
  // ../../packages/node-runtime/src/semantic-index/service.ts
18117
- import path31 from "path";
17998
+ import path29 from "path";
18118
17999
 
18119
18000
  // ../../packages/node-runtime/src/semantic-index/chunker-config.ts
18120
18001
  import { createHash as createHash2 } from "crypto";
@@ -18435,8 +18316,8 @@ function createEmbedder(config, deps = {}) {
18435
18316
  if (!config.api || !config.api.baseUrl || !config.api.model) {
18436
18317
  throw new Error("semantic index API config incomplete: baseUrl and model are required");
18437
18318
  }
18438
- const resolve4 = deps.resolveApiKey ?? resolveApiKey;
18439
- const apiKey = resolve4("", config.api.authProfile);
18319
+ const resolve2 = deps.resolveApiKey ?? resolveApiKey;
18320
+ const apiKey = resolve2("", config.api.authProfile);
18440
18321
  return new OpenAICompatibleEmbeddingProvider(
18441
18322
  { baseUrl: config.api.baseUrl, apiKey, model: config.api.model },
18442
18323
  { fetchFn: deps.fetchFn }
@@ -18473,8 +18354,8 @@ function extensionSuffix(platform2) {
18473
18354
  return "so";
18474
18355
  }
18475
18356
  function platformPackageName(platform2, arch2) {
18476
- const os3 = platform2 === "win32" ? "windows" : platform2;
18477
- return `${BASE_PACKAGE_NAME}-${os3}-${arch2}`;
18357
+ const os2 = platform2 === "win32" ? "windows" : platform2;
18358
+ return `${BASE_PACKAGE_NAME}-${os2}-${arch2}`;
18478
18359
  }
18479
18360
  function getLoadablePath() {
18480
18361
  if (!validPlatform(platform, arch)) {
@@ -18973,7 +18854,7 @@ var SemanticIndexJobQueue = class {
18973
18854
  /** 等待队列清空(含当前任务) */
18974
18855
  whenIdle() {
18975
18856
  if (!this.processing && this.pending.length === 0) return Promise.resolve();
18976
- return new Promise((resolve4) => this.idleResolvers.push(resolve4));
18857
+ return new Promise((resolve2) => this.idleResolvers.push(resolve2));
18977
18858
  }
18978
18859
  removePending(dbPathHash) {
18979
18860
  this.pending = this.pending.filter((j) => j.dbPathHash !== dbPathHash);
@@ -18995,7 +18876,7 @@ var SemanticIndexJobQueue = class {
18995
18876
  this.processing = false;
18996
18877
  const resolvers = this.idleResolvers;
18997
18878
  this.idleResolvers = [];
18998
- for (const resolve4 of resolvers) resolve4();
18879
+ for (const resolve2 of resolvers) resolve2();
18999
18880
  }
19000
18881
  };
19001
18882
 
@@ -19645,16 +19526,16 @@ function resolveSearchToolEvidenceTokens(maxResultTokens) {
19645
19526
  return maxResultTokens && maxResultTokens > 0 ? Math.min(SEARCH_TOOL_EVIDENCE_TOKENS, maxResultTokens) : SEARCH_TOOL_EVIDENCE_TOKENS;
19646
19527
  }
19647
19528
  function sessionIdFromDbPath(dbPath) {
19648
- return path31.basename(dbPath, ".db");
19529
+ return path29.basename(dbPath, ".db");
19649
19530
  }
19650
19531
  var SEMANTIC_INDEX_DB_FILE = "embedding_index.db";
19651
19532
  var SEMANTIC_INDEX_CONFIG_FILE = "semantic-index-config.json";
19652
19533
  function createSemanticIndexService(params) {
19653
19534
  const { pathProvider } = params;
19654
19535
  return new SemanticIndexService({
19655
- vectorDbPath: path31.join(pathProvider.getVectorDir(), SEMANTIC_INDEX_DB_FILE),
19656
- configPath: path31.join(pathProvider.getAiDataDir(), SEMANTIC_INDEX_CONFIG_FILE),
19657
- modelsCacheDir: path31.join(pathProvider.getAiDataDir(), "models", "semantic-index"),
19536
+ vectorDbPath: path29.join(pathProvider.getVectorDir(), SEMANTIC_INDEX_DB_FILE),
19537
+ configPath: path29.join(pathProvider.getAiDataDir(), SEMANTIC_INDEX_CONFIG_FILE),
19538
+ modelsCacheDir: path29.join(pathProvider.getAiDataDir(), "models", "semantic-index"),
19658
19539
  modelDownloadProxyUrl: params.modelDownloadProxyUrl,
19659
19540
  sessionAdapter: params.sessionAdapter,
19660
19541
  nativeBinding: params.nativeBinding,
@@ -20204,8 +20085,8 @@ ${text}`;
20204
20085
  };
20205
20086
 
20206
20087
  // ../../packages/node-runtime/src/services/merge-cache.ts
20207
- import * as fs35 from "fs";
20208
- import * as path32 from "path";
20088
+ import * as fs33 from "fs";
20089
+ import * as path30 from "path";
20209
20090
  import * as crypto from "crypto";
20210
20091
  var MergeSessionCache = class {
20211
20092
  cache = /* @__PURE__ */ new Map();
@@ -20214,15 +20095,15 @@ var MergeSessionCache = class {
20214
20095
  constructor(pathProvider, options2) {
20215
20096
  this.tempDir = pathProvider.getTempDir();
20216
20097
  this.nativeBinding = options2?.nativeBinding;
20217
- if (!fs35.existsSync(this.tempDir)) {
20218
- fs35.mkdirSync(this.tempDir, { recursive: true });
20098
+ if (!fs33.existsSync(this.tempDir)) {
20099
+ fs33.mkdirSync(this.tempDir, { recursive: true });
20219
20100
  }
20220
20101
  }
20221
20102
  generateTempDbPath(filename) {
20222
20103
  const ts = Date.now();
20223
20104
  const rand = Math.random().toString(36).slice(2, 8);
20224
20105
  const safeName = filename.replace(/[/\\?%*:|"<>]/g, "_").slice(0, 40);
20225
- return path32.join(this.tempDir, `merge_${safeName}_${ts}_${rand}.db`);
20106
+ return path30.join(this.tempDir, `merge_${safeName}_${ts}_${rand}.db`);
20226
20107
  }
20227
20108
  /** Store a parsed file's temp DB and return a handle for subsequent requests. */
20228
20109
  store(filename, tempDbPath) {
@@ -20233,7 +20114,7 @@ var MergeSessionCache = class {
20233
20114
  /** Open a TempDbReader for a given handle. Caller must close the reader. */
20234
20115
  openReader(handle) {
20235
20116
  const entry = this.cache.get(handle);
20236
- if (!entry || !fs35.existsSync(entry.tempDbPath)) return null;
20117
+ if (!entry || !fs33.existsSync(entry.tempDbPath)) return null;
20237
20118
  const adapter = openBetterSqliteDatabase(entry.tempDbPath, {
20238
20119
  readonly: true,
20239
20120
  nativeBinding: this.nativeBinding
@@ -20278,7 +20159,7 @@ var MergeSessionCache = class {
20278
20159
  };
20279
20160
 
20280
20161
  // ../../packages/node-runtime/src/services/push-importer.ts
20281
- import * as fs36 from "fs";
20162
+ import * as fs34 from "fs";
20282
20163
  var SYSTEM_SENDER_ID = "SYSTEM";
20283
20164
  var SYSTEM_MEMBER_NAME = "\u7CFB\u7EDF\u6D88\u606F";
20284
20165
  function isRecord3(value) {
@@ -20645,7 +20526,7 @@ async function executePushImportUnlocked(deps, sessionId, payload) {
20645
20526
  return { ok: false, reason: "invalid_payload", message: "sessionId contains invalid characters" };
20646
20527
  }
20647
20528
  const dbPath = deps.getDbPath(sessionId);
20648
- const isNew = !fs36.existsSync(dbPath);
20529
+ const isNew = !fs34.existsSync(dbPath);
20649
20530
  const validationError = validatePayload(payload, isNew);
20650
20531
  if (validationError) {
20651
20532
  return { ok: false, reason: "invalid_payload", message: validationError };
@@ -20745,12 +20626,6 @@ var ImportIdempotencyCache = class {
20745
20626
  };
20746
20627
 
20747
20628
  export {
20748
- CHATLAB_TEMP_ROOT_ENV,
20749
- resolveChatLabTempRoot,
20750
- ensureChatLabTempRoot,
20751
- getChatLabTempScopeDir,
20752
- createChatLabTempDir,
20753
- removeChatLabTempDir,
20754
20629
  writeParseResultToDb,
20755
20630
  detectFormat,
20756
20631
  detectAllFormats,
@@ -20872,8 +20747,6 @@ export {
20872
20747
  checkSessionsCanGenerateSummary,
20873
20748
  MAX_CONFIG_COUNT,
20874
20749
  LLMConfigStore,
20875
- createFileConfigStorage,
20876
- createAuthProfileLlmConfigStore,
20877
20750
  CustomProviderStore,
20878
20751
  CustomModelStore,
20879
20752
  normalizeAnthropicBaseUrl,
@@ -20968,4 +20841,4 @@ export {
20968
20841
  hashImportBody,
20969
20842
  ImportIdempotencyCache
20970
20843
  };
20971
- //# sourceMappingURL=chunk-5G2INROS.mjs.map
20844
+ //# sourceMappingURL=chunk-GYPBWKAU.mjs.map