chatlab-cli 0.31.2 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-command-QPL4GNHP.mjs → chat-command-3KUWKS53.mjs} +15 -9
- package/dist/chat-command-3KUWKS53.mjs.map +1 -0
- package/dist/{chunk-OAXVKNPN.mjs → chunk-23AIEWCD.mjs} +2 -2
- package/dist/{chunk-3SZWD7UM.mjs → chunk-27DWKA3L.mjs} +79 -20
- package/dist/chunk-27DWKA3L.mjs.map +1 -0
- package/dist/{chunk-S5PQM5J4.mjs → chunk-3IGBPOJM.mjs} +133 -19
- package/dist/chunk-3IGBPOJM.mjs.map +1 -0
- package/dist/{chunk-F2NZ7HAY.mjs → chunk-3J7WTUEE.mjs} +2 -2
- package/dist/{chunk-OQ6N4PDD.mjs → chunk-BLOBEOCG.mjs} +2 -2
- package/dist/{chunk-64FKPYPJ.mjs → chunk-CANPJOIE.mjs} +11 -11
- package/dist/{chunk-6JKKHPXY.mjs → chunk-DV4U34MR.mjs} +2 -2
- package/dist/{chunk-GYPBWKAU.mjs → chunk-LNU4RW5G.mjs} +912 -444
- package/dist/chunk-LNU4RW5G.mjs.map +1 -0
- package/dist/{chunk-BSSR4ZYW.mjs → chunk-PZM3FHVZ.mjs} +2233 -2072
- package/dist/chunk-PZM3FHVZ.mjs.map +1 -0
- package/dist/{chunk-ZCXCHKQV.mjs → chunk-UVCH2ICD.mjs} +3 -3
- package/dist/{chunk-IK7GJTGY.mjs → chunk-YVNZ73O5.mjs} +147 -266
- package/dist/chunk-YVNZ73O5.mjs.map +1 -0
- package/dist/cli.mjs +8 -8
- package/dist/contacts-worker.mjs +2 -2
- package/dist/global-insight-worker.mjs +1 -1
- package/dist/{http-NOEWVWCP.mjs → http-YR26GF7X.mjs} +11 -11
- package/dist/{import-RS3HW7ZM.mjs → import-Q3DUACU4.mjs} +7 -7
- package/dist/index.mjs +11 -11
- package/dist/{mcp-7F3G47Z4.mjs → mcp-HTVZSGTI.mjs} +8 -8
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-MNH5S423.mjs → src-HJL7YZZJ.mjs} +36 -6
- package/dist/{stream-import-BPCHGRAN.mjs → stream-import-MXETSEPW.mjs} +7 -7
- package/dist/{worker-runtime-TTAXGQ5R.mjs → worker-runtime-DZQDL2E2.mjs} +5 -5
- package/dist-web/assets/ActionToolsPanel-Dp-ojXjO.css +1 -0
- package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DfQa9E2W.js +110 -0
- package/dist-web/assets/{BufferResource-Dh2kaMuP.js → BufferResource-BXfwfGam.js} +1 -1
- package/dist-web/assets/{CanvasRenderer-B8hHywwz.js → CanvasRenderer-Bvpsbxds.js} +1 -1
- package/dist-web/assets/DataDirCleanupNotice-C0sCmNL2.js +1 -0
- package/dist-web/assets/{EChartWordcloud-BXC_4nUP.js → EChartWordcloud-C5hLT1vS.js} +1 -1
- package/dist-web/assets/{Filter-Bap1KMW6.js → Filter-Irxx0f6j.js} +1 -1
- package/dist-web/assets/{LoadingState.vue_vue_type_script_setup_true_lang-B2KAoiMG.js → LoadingState.vue_vue_type_script_setup_true_lang-8s6XRB3S.js} +1 -1
- package/dist-web/assets/{MessageExportModal-H3-LAaXY.js → MessageExportModal-tTI358HU.js} +1 -1
- package/dist-web/assets/{PageHeader-CzTV_lyM.js → PageHeader-D5QQI9io.js} +1 -1
- package/dist-web/assets/{RelationshipGalaxyCanvas-C6ZoUZNc.js → RelationshipGalaxyCanvas-ByDU6ZS_.js} +3 -3
- package/dist-web/assets/{RelationshipGalaxyThreeCanvas-DV6B-7XB.js → RelationshipGalaxyThreeCanvas-DgAlyKjc.js} +1 -1
- package/dist-web/assets/{RenderTargetSystem-Dpgyoac_.js → RenderTargetSystem-Cx5U5HAM.js} +1 -1
- package/dist-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-BWJ6kuSC.js → ThemeCard.vue_vue_type_script_setup_true_lang-CpNjFhpm.js} +1 -1
- package/dist-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang--Tbo7p-l.js → TimeSelect.vue_vue_type_script_setup_true_lang-DtCKfbaz.js} +1 -1
- package/dist-web/assets/{WebGLRenderer-DICnsAm5.js → WebGLRenderer-B3Fnp1WX.js} +1 -1
- package/dist-web/assets/{WebGPURenderer-Bf0gkRK9.js → WebGPURenderer-DZ0X9N86.js} +1 -1
- package/dist-web/assets/{annual-summary-time-range-CK0IIPsY.js → annual-summary-time-range-CvG74N2l.js} +1 -1
- package/dist-web/assets/{base-D5T8QZ8b.js → base-DdQRTliS.js} +1 -1
- package/dist-web/assets/{browserAll-DcoCy7xY.js → browserAll-BqC9ELNO.js} +1 -1
- package/dist-web/assets/{dateFormat-BDOkdsCR.js → dateFormat-CX9atL2g.js} +1 -1
- package/dist-web/assets/{electron-CmhzSjaH.js → electron-ChQkD5ht.js} +1 -1
- package/dist-web/assets/{fetch-DfTM4Dah.js → fetch-3Ifr5YJN.js} +1 -1
- package/dist-web/assets/fetch-74o_kRZf.js +1 -0
- package/dist-web/assets/{fetch-BddgpyKJ.js → fetch-BKFznq4l.js} +1 -1
- package/dist-web/assets/{fetch-D8xv4lgE.js → fetch-BPj6IlT-.js} +1 -1
- package/dist-web/assets/{fetch-dI5w8lYN.js → fetch-C3KuMfIU.js} +1 -1
- package/dist-web/assets/{fetch-DtcNaN3d.js → fetch-CUT9JdXT.js} +1 -1
- package/dist-web/assets/fetch-CoYaXr5K.js +1 -0
- package/dist-web/assets/{fetch-D71bG6Fc.js → fetch-Dcg6Q6Ei.js} +1 -1
- package/dist-web/assets/{fetch-TATpgXht.js → fetch-DxWfYzkB.js} +1 -1
- package/dist-web/assets/{fetch-C1mlq5VY.js → fetch-th_egarZ.js} +1 -1
- package/dist-web/assets/index-B3riRaJA.js +1 -0
- package/dist-web/assets/index-BRDdozcm.js +173 -0
- package/dist-web/assets/{index-a1ZrlsKo.js → index-Bg-OiHMa.js} +1 -1
- package/dist-web/assets/{index-DClxj4T2.js → index-BhewGKey.js} +2 -2
- package/dist-web/assets/{index-Bs4ZX2-v.js → index-Bm_U0hSr.js} +1 -1
- package/dist-web/assets/{index-soX5gDgh.js → index-BpeJ40uK.js} +1 -1
- package/dist-web/assets/{index-Dp3gCHpK.js → index-C6bwt1H4.js} +1 -1
- package/dist-web/assets/{index-qZ7jnIna.js → index-CEJqRkis.js} +2 -2
- package/dist-web/assets/{index-Dtbu8m1o.js → index-CKLCaqdT.js} +1 -1
- package/dist-web/assets/index-D8Uq3_Dc.css +1 -0
- package/dist-web/assets/index-DBb03wVF.css +1 -0
- package/dist-web/assets/index-Ds5PiVyB.js +64 -0
- package/dist-web/assets/{index-DphjBwbA.js → index-GXMxhYc9.js} +1 -1
- package/dist-web/assets/index-JyB6Cr8r.js +25 -0
- package/dist-web/assets/index-UJl03IYE.css +1 -0
- package/dist-web/assets/{index-CY5yJhCJ.js → index-tx-Oal36.js} +1 -1
- package/dist-web/assets/{people-page-header-D93GTPBO.js → people-page-header-DGkK0AMO.js} +1 -1
- package/dist-web/assets/{vendor-nuxt-ui-DUpPmItD.js → vendor-nuxt-ui-DMdbdSFy.js} +2 -2
- package/dist-web/assets/{vendor-reka-ui-BLnO2MqY.js → vendor-reka-ui-8_x7iKfi.js} +1 -1
- package/dist-web/assets/{web-H9T1dZys.js → web-aZcioccr.js} +1 -1
- package/dist-web/assets/{webworkerAll-D1Kui8G8.js → webworkerAll-a_fveCLR.js} +1 -1
- package/dist-web/index.html +4 -4
- package/package.json +1 -1
- package/dist/chat-command-QPL4GNHP.mjs.map +0 -1
- package/dist/chunk-3SZWD7UM.mjs.map +0 -1
- package/dist/chunk-BSSR4ZYW.mjs.map +0 -1
- package/dist/chunk-GYPBWKAU.mjs.map +0 -1
- package/dist/chunk-IK7GJTGY.mjs.map +0 -1
- package/dist/chunk-S5PQM5J4.mjs.map +0 -1
- package/dist-web/assets/ActionToolsPanel-CbWhu_Uv.css +0 -1
- package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CvvNqXuh.js +0 -110
- package/dist-web/assets/fetch-BJka-sCN.js +0 -1
- package/dist-web/assets/fetch-CNz28Lv5.js +0 -1
- package/dist-web/assets/index-CAjUCtGD.css +0 -1
- package/dist-web/assets/index-CF59LLOG.js +0 -25
- package/dist-web/assets/index-CJ3WtSLo.js +0 -173
- package/dist-web/assets/index-CJS6FVuj.js +0 -64
- package/dist-web/assets/index-CsqMIyA9.css +0 -1
- package/dist-web/assets/index-CtmXho1w.css +0 -1
- package/dist-web/assets/index-De3ImZb9.js +0 -1
- /package/dist/{chunk-OAXVKNPN.mjs.map → chunk-23AIEWCD.mjs.map} +0 -0
- /package/dist/{chunk-F2NZ7HAY.mjs.map → chunk-3J7WTUEE.mjs.map} +0 -0
- /package/dist/{chunk-OQ6N4PDD.mjs.map → chunk-BLOBEOCG.mjs.map} +0 -0
- /package/dist/{chunk-64FKPYPJ.mjs.map → chunk-CANPJOIE.mjs.map} +0 -0
- /package/dist/{chunk-6JKKHPXY.mjs.map → chunk-DV4U34MR.mjs.map} +0 -0
- /package/dist/{chunk-ZCXCHKQV.mjs.map → chunk-UVCH2ICD.mjs.map} +0 -0
- /package/dist/{http-NOEWVWCP.mjs.map → http-YR26GF7X.mjs.map} +0 -0
- /package/dist/{import-RS3HW7ZM.mjs.map → import-Q3DUACU4.mjs.map} +0 -0
- /package/dist/{mcp-7F3G47Z4.mjs.map → mcp-HTVZSGTI.mjs.map} +0 -0
- /package/dist/{src-MNH5S423.mjs.map → src-HJL7YZZJ.mjs.map} +0 -0
- /package/dist/{stream-import-BPCHGRAN.mjs.map → stream-import-MXETSEPW.mjs.map} +0 -0
- /package/dist/{worker-runtime-TTAXGQ5R.mjs.map → worker-runtime-DZQDL2E2.mjs.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
createEmptyContactsDiagnostics,
|
|
10
10
|
normalizeContactsTimeRangePreset,
|
|
11
11
|
resolveContactsTimeRange
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3J7WTUEE.mjs";
|
|
13
13
|
import {
|
|
14
14
|
PEOPLE_RELATIONSHIPS_ALGORITHM_VERSION,
|
|
15
15
|
buildPeopleRelationshipsNeighborhoodGraph,
|
|
@@ -18,18 +18,21 @@ import {
|
|
|
18
18
|
computePeopleRelationshipsSnapshot,
|
|
19
19
|
normalizePeopleRelationshipsTimeRangePreset,
|
|
20
20
|
resolvePeopleRelationshipsTimeRange
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-23AIEWCD.mjs";
|
|
22
22
|
import {
|
|
23
23
|
ANNUAL_SUMMARY_ALGORITHM_VERSION
|
|
24
24
|
} from "./chunk-YAQLYL52.mjs";
|
|
25
25
|
import {
|
|
26
26
|
BUILTIN_MODELS,
|
|
27
27
|
BUILTIN_PROVIDERS,
|
|
28
|
+
BUILTIN_TOOL_CATALOG,
|
|
28
29
|
CHART_CAPABILITY_SKILL_ID,
|
|
29
30
|
CHAT_DB_INDEXES,
|
|
30
31
|
CHAT_DB_SCHEMA,
|
|
32
|
+
DEFAULT_GENERAL_ASSISTANT_ID,
|
|
31
33
|
DataDirCompatibilityError,
|
|
32
34
|
FTS_TABLE_SCHEMA,
|
|
35
|
+
GENERAL_ASSISTANT_IDS,
|
|
33
36
|
KNOWN_PLATFORMS,
|
|
34
37
|
StreamingThinkTagParser,
|
|
35
38
|
appLogger,
|
|
@@ -42,7 +45,9 @@ import {
|
|
|
42
45
|
clearSessionIndex,
|
|
43
46
|
collectPosTagStats,
|
|
44
47
|
deleteAnnualSummarySnapshots,
|
|
48
|
+
deleteAuthProfile,
|
|
45
49
|
deleteMember,
|
|
50
|
+
deleteMembers,
|
|
46
51
|
generateIncrementalSessionIndex,
|
|
47
52
|
generateMessageKey,
|
|
48
53
|
generateSessionIndex,
|
|
@@ -93,7 +98,7 @@ import {
|
|
|
93
98
|
updateSessionOwnerId,
|
|
94
99
|
writeAnnualSummarySnapshot,
|
|
95
100
|
writeAuthProfile
|
|
96
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-YVNZ73O5.mjs";
|
|
97
102
|
import {
|
|
98
103
|
__commonJS,
|
|
99
104
|
__export,
|
|
@@ -709,8 +714,8 @@ var require_FilterBase = __commonJS({
|
|
|
709
714
|
var FilterBase = class _FilterBase extends Transform {
|
|
710
715
|
static stringFilter(string, separator) {
|
|
711
716
|
return (stack) => {
|
|
712
|
-
const
|
|
713
|
-
return
|
|
717
|
+
const path33 = stack.join(separator);
|
|
718
|
+
return path33.length === string.length && path33 === string || path33.length > string.length && path33.substr(0, string.length) === string && path33.substr(string.length, separator.length) === separator;
|
|
714
719
|
};
|
|
715
720
|
}
|
|
716
721
|
static regExpFilter(regExp, separator) {
|
|
@@ -1164,12 +1169,12 @@ var require_Assembler = __commonJS({
|
|
|
1164
1169
|
return (this.stack.length >> 1) + (this.done ? 0 : 1);
|
|
1165
1170
|
}
|
|
1166
1171
|
get path() {
|
|
1167
|
-
const
|
|
1172
|
+
const path33 = [];
|
|
1168
1173
|
for (let i = 0; i < this.stack.length; i += 2) {
|
|
1169
1174
|
const key = this.stack[i + 1];
|
|
1170
|
-
|
|
1175
|
+
path33.push(key === null ? this.stack[i].length : key);
|
|
1171
1176
|
}
|
|
1172
|
-
return
|
|
1177
|
+
return path33;
|
|
1173
1178
|
}
|
|
1174
1179
|
dropToLevel(level) {
|
|
1175
1180
|
if (level < this.depth) {
|
|
@@ -1451,7 +1456,7 @@ var require_pend = __commonJS({
|
|
|
1451
1456
|
var require_fd_slicer = __commonJS({
|
|
1452
1457
|
"../../packages/node-runtime/node_modules/yauzl/fd-slicer.js"(exports) {
|
|
1453
1458
|
"use strict";
|
|
1454
|
-
var
|
|
1459
|
+
var fs37 = __require("fs");
|
|
1455
1460
|
var util = __require("util");
|
|
1456
1461
|
var stream = __require("stream");
|
|
1457
1462
|
var Readable = stream.Readable;
|
|
@@ -1471,7 +1476,7 @@ var require_fd_slicer = __commonJS({
|
|
|
1471
1476
|
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
1472
1477
|
var self = this;
|
|
1473
1478
|
self.pend.go(function(cb) {
|
|
1474
|
-
|
|
1479
|
+
fs37.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
1475
1480
|
cb();
|
|
1476
1481
|
callback(err, bytesRead, buffer2);
|
|
1477
1482
|
});
|
|
@@ -1488,7 +1493,7 @@ var require_fd_slicer = __commonJS({
|
|
|
1488
1493
|
self.refCount -= 1;
|
|
1489
1494
|
if (self.refCount < 0) throw new Error("invalid unref");
|
|
1490
1495
|
if (self.refCount > 0) return;
|
|
1491
|
-
|
|
1496
|
+
fs37.close(self.fd, onCloseDone);
|
|
1492
1497
|
function onCloseDone(err) {
|
|
1493
1498
|
if (err) {
|
|
1494
1499
|
self.emit("error", err);
|
|
@@ -1520,7 +1525,7 @@ var require_fd_slicer = __commonJS({
|
|
|
1520
1525
|
}
|
|
1521
1526
|
self.context.pend.go(function(cb) {
|
|
1522
1527
|
var buffer = Buffer.allocUnsafe(toRead);
|
|
1523
|
-
|
|
1528
|
+
fs37.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
1524
1529
|
if (err) {
|
|
1525
1530
|
self.destroy(err);
|
|
1526
1531
|
} else if (bytesRead === 0) {
|
|
@@ -1882,7 +1887,7 @@ var require_crc32 = __commonJS({
|
|
|
1882
1887
|
var require_yauzl = __commonJS({
|
|
1883
1888
|
"../../packages/node-runtime/node_modules/yauzl/index.js"(exports) {
|
|
1884
1889
|
"use strict";
|
|
1885
|
-
var
|
|
1890
|
+
var fs37 = __require("fs");
|
|
1886
1891
|
var zlib = __require("zlib");
|
|
1887
1892
|
var fd_slicer = require_fd_slicer();
|
|
1888
1893
|
var util = __require("util");
|
|
@@ -1907,39 +1912,39 @@ var require_yauzl = __commonJS({
|
|
|
1907
1912
|
exports.Entry = Entry;
|
|
1908
1913
|
exports.LocalFileHeader = LocalFileHeader;
|
|
1909
1914
|
exports.RandomAccessReader = RandomAccessReader;
|
|
1910
|
-
function openPromise2(
|
|
1911
|
-
return new Promise((
|
|
1912
|
-
open(
|
|
1915
|
+
function openPromise2(path33, options2) {
|
|
1916
|
+
return new Promise((resolve4, reject) => {
|
|
1917
|
+
open(path33, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
1913
1918
|
if (err) return reject(err);
|
|
1914
|
-
|
|
1919
|
+
resolve4(zipfile);
|
|
1915
1920
|
});
|
|
1916
1921
|
});
|
|
1917
1922
|
}
|
|
1918
1923
|
function fromFdPromise(fd, options2) {
|
|
1919
|
-
return new Promise((
|
|
1924
|
+
return new Promise((resolve4, reject) => {
|
|
1920
1925
|
fromFd(fd, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
1921
1926
|
if (err) return reject(err);
|
|
1922
|
-
|
|
1927
|
+
resolve4(zipfile);
|
|
1923
1928
|
});
|
|
1924
1929
|
});
|
|
1925
1930
|
}
|
|
1926
1931
|
function fromBufferPromise(buffer, options2) {
|
|
1927
|
-
return new Promise((
|
|
1932
|
+
return new Promise((resolve4, reject) => {
|
|
1928
1933
|
fromBuffer(buffer, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
1929
1934
|
if (err) return reject(err);
|
|
1930
|
-
|
|
1935
|
+
resolve4(zipfile);
|
|
1931
1936
|
});
|
|
1932
1937
|
});
|
|
1933
1938
|
}
|
|
1934
1939
|
function fromRandomAccessReaderPromise(reader, totalSize, options2) {
|
|
1935
|
-
return new Promise((
|
|
1940
|
+
return new Promise((resolve4, reject) => {
|
|
1936
1941
|
fromRandomAccessReader(reader, totalSize, { ...options2, lazyEntries: true }, function(err, zipfile) {
|
|
1937
1942
|
if (err) return reject(err);
|
|
1938
|
-
|
|
1943
|
+
resolve4(zipfile);
|
|
1939
1944
|
});
|
|
1940
1945
|
});
|
|
1941
1946
|
}
|
|
1942
|
-
function open(
|
|
1947
|
+
function open(path33, options2, callback) {
|
|
1943
1948
|
if (typeof options2 === "function") {
|
|
1944
1949
|
callback = options2;
|
|
1945
1950
|
options2 = null;
|
|
@@ -1951,10 +1956,10 @@ var require_yauzl = __commonJS({
|
|
|
1951
1956
|
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1952
1957
|
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1953
1958
|
if (callback == null) callback = defaultCallback;
|
|
1954
|
-
|
|
1959
|
+
fs37.open(path33, "r", function(err, fd) {
|
|
1955
1960
|
if (err) return callback(err);
|
|
1956
1961
|
fromFd(fd, options2, function(err2, zipfile) {
|
|
1957
|
-
if (err2)
|
|
1962
|
+
if (err2) fs37.close(fd, defaultCallback);
|
|
1958
1963
|
callback(err2, zipfile);
|
|
1959
1964
|
});
|
|
1960
1965
|
});
|
|
@@ -1971,7 +1976,7 @@ var require_yauzl = __commonJS({
|
|
|
1971
1976
|
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1972
1977
|
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1973
1978
|
if (callback == null) callback = defaultCallback;
|
|
1974
|
-
|
|
1979
|
+
fs37.fstat(fd, function(err, stats) {
|
|
1975
1980
|
if (err) return callback(err);
|
|
1976
1981
|
var reader = new fd_slicer.FdSlicer(fd);
|
|
1977
1982
|
fromRandomAccessReader(reader, stats.size, options2, callback);
|
|
@@ -2219,15 +2224,15 @@ var require_yauzl = __commonJS({
|
|
|
2219
2224
|
if (self.autoClose) self.close();
|
|
2220
2225
|
}
|
|
2221
2226
|
function onEntry(entry) {
|
|
2222
|
-
let { resolve:
|
|
2227
|
+
let { resolve: resolve4 } = pendingResolveReject;
|
|
2223
2228
|
pendingResolveReject = null;
|
|
2224
|
-
|
|
2229
|
+
resolve4({ value: entry });
|
|
2225
2230
|
}
|
|
2226
2231
|
function onEnd() {
|
|
2227
|
-
let { resolve:
|
|
2232
|
+
let { resolve: resolve4 } = pendingResolveReject;
|
|
2228
2233
|
pendingResolveReject = null;
|
|
2229
2234
|
cleanup();
|
|
2230
|
-
|
|
2235
|
+
resolve4({ done: true });
|
|
2231
2236
|
}
|
|
2232
2237
|
function onError(err) {
|
|
2233
2238
|
let { reject } = pendingResolveReject;
|
|
@@ -2240,9 +2245,9 @@ var require_yauzl = __commonJS({
|
|
|
2240
2245
|
return this;
|
|
2241
2246
|
},
|
|
2242
2247
|
next() {
|
|
2243
|
-
const promise = new Promise((
|
|
2248
|
+
const promise = new Promise((resolve4, reject) => {
|
|
2244
2249
|
if (pendingResolveReject != null) throw new Error("next() called before previous Promise was resolved.");
|
|
2245
|
-
pendingResolveReject = { resolve:
|
|
2250
|
+
pendingResolveReject = { resolve: resolve4, reject };
|
|
2246
2251
|
});
|
|
2247
2252
|
self.readEntry();
|
|
2248
2253
|
return promise;
|
|
@@ -2431,26 +2436,26 @@ var require_yauzl = __commonJS({
|
|
|
2431
2436
|
});
|
|
2432
2437
|
};
|
|
2433
2438
|
ZipFile.prototype.openReadStreamPromise = function(entry, options2) {
|
|
2434
|
-
return new Promise((
|
|
2439
|
+
return new Promise((resolve4, reject) => {
|
|
2435
2440
|
this.openReadStream(entry, options2, function(err, readStream) {
|
|
2436
2441
|
if (err) return reject(err);
|
|
2437
|
-
|
|
2442
|
+
resolve4(readStream);
|
|
2438
2443
|
});
|
|
2439
2444
|
});
|
|
2440
2445
|
};
|
|
2441
2446
|
ZipFile.prototype.openReadStreamLowLevelPromise = function(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize) {
|
|
2442
|
-
return new Promise((
|
|
2447
|
+
return new Promise((resolve4, reject) => {
|
|
2443
2448
|
this.openReadStream(fileDataStart, compressedSize, relativeStart, relativeEnd, decompress, uncompressedSize, function(err, readStream) {
|
|
2444
2449
|
if (err) return reject(err);
|
|
2445
|
-
|
|
2450
|
+
resolve4(readStream);
|
|
2446
2451
|
});
|
|
2447
2452
|
});
|
|
2448
2453
|
};
|
|
2449
2454
|
ZipFile.prototype.readLocalFileHeaderPromise = function(entry, options2) {
|
|
2450
|
-
return new Promise((
|
|
2455
|
+
return new Promise((resolve4, reject) => {
|
|
2451
2456
|
this.readLocalFileHeader(entry, options2, function(err, localFileHeader) {
|
|
2452
2457
|
if (err) return reject(err);
|
|
2453
|
-
|
|
2458
|
+
resolve4(localFileHeader);
|
|
2454
2459
|
});
|
|
2455
2460
|
});
|
|
2456
2461
|
};
|
|
@@ -2738,6 +2743,73 @@ var require_yauzl = __commonJS({
|
|
|
2738
2743
|
}
|
|
2739
2744
|
});
|
|
2740
2745
|
|
|
2746
|
+
// ../../packages/node-runtime/src/temp-workspace.ts
|
|
2747
|
+
import * as fs from "fs";
|
|
2748
|
+
import * as os from "os";
|
|
2749
|
+
import * as path from "path";
|
|
2750
|
+
var CHATLAB_TEMP_ROOT_ENV = "CHATLAB_TEMP_ROOT";
|
|
2751
|
+
var CHATLAB_TEMP_SCOPES = /* @__PURE__ */ new Set(["tests", "runtime", "imports", "merge", "sync", "parser", "build", "bench"]);
|
|
2752
|
+
function optionsEnv(options2) {
|
|
2753
|
+
return options2.env ?? process.env;
|
|
2754
|
+
}
|
|
2755
|
+
function resolveChatLabTempRoot(options2 = {}) {
|
|
2756
|
+
const envRoot = optionsEnv(options2)[CHATLAB_TEMP_ROOT_ENV]?.trim();
|
|
2757
|
+
if (envRoot) return path.resolve(envRoot);
|
|
2758
|
+
const platform2 = options2.platform ?? process.platform;
|
|
2759
|
+
const systemTempDir = options2.systemTempDir ?? os.tmpdir();
|
|
2760
|
+
return path.resolve(platform2 === "darwin" ? "/private/tmp/chatlab" : path.join(systemTempDir, "chatlab"));
|
|
2761
|
+
}
|
|
2762
|
+
function ensurePrivateOwnedDirectory(dirPath, label) {
|
|
2763
|
+
fs.mkdirSync(dirPath, { recursive: true, mode: 448 });
|
|
2764
|
+
const stats = fs.lstatSync(dirPath);
|
|
2765
|
+
if (stats.isSymbolicLink()) {
|
|
2766
|
+
throw new Error(`${label} must not be a symbolic link: ${dirPath}`);
|
|
2767
|
+
}
|
|
2768
|
+
if (!stats.isDirectory()) {
|
|
2769
|
+
throw new Error(`${label} must be a directory: ${dirPath}`);
|
|
2770
|
+
}
|
|
2771
|
+
if (typeof process.getuid === "function" && stats.uid !== process.getuid()) {
|
|
2772
|
+
throw new Error(`${label} is owned by another user: ${dirPath}`);
|
|
2773
|
+
}
|
|
2774
|
+
if (process.platform !== "win32") {
|
|
2775
|
+
fs.chmodSync(dirPath, 448);
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
function ensureChatLabTempRoot(options2 = {}) {
|
|
2779
|
+
const root = resolveChatLabTempRoot(options2);
|
|
2780
|
+
ensurePrivateOwnedDirectory(root, "ChatLab temp root");
|
|
2781
|
+
optionsEnv(options2)[CHATLAB_TEMP_ROOT_ENV] = root;
|
|
2782
|
+
return root;
|
|
2783
|
+
}
|
|
2784
|
+
function assertValidScope(scope) {
|
|
2785
|
+
if (!CHATLAB_TEMP_SCOPES.has(scope)) {
|
|
2786
|
+
throw new Error(`Invalid ChatLab temp scope: ${scope}`);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
function assertValidPrefix(prefix) {
|
|
2790
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(prefix)) {
|
|
2791
|
+
throw new Error(`Invalid ChatLab temp prefix: ${prefix}`);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
function getChatLabTempScopeDir(scope, options2 = {}) {
|
|
2795
|
+
assertValidScope(scope);
|
|
2796
|
+
const scopeDir = path.join(ensureChatLabTempRoot(options2), scope);
|
|
2797
|
+
ensurePrivateOwnedDirectory(scopeDir, "ChatLab temp scope");
|
|
2798
|
+
return scopeDir;
|
|
2799
|
+
}
|
|
2800
|
+
function createChatLabTempDir(scope, prefix, options2 = {}) {
|
|
2801
|
+
assertValidPrefix(prefix);
|
|
2802
|
+
return fs.mkdtempSync(path.join(getChatLabTempScopeDir(scope, options2), prefix));
|
|
2803
|
+
}
|
|
2804
|
+
function removeChatLabTempDir(dirPath, scope, options2 = {}) {
|
|
2805
|
+
const scopeDir = path.resolve(getChatLabTempScopeDir(scope, options2));
|
|
2806
|
+
const resolvedDir = path.resolve(dirPath);
|
|
2807
|
+
if (path.dirname(resolvedDir) !== scopeDir) {
|
|
2808
|
+
throw new Error(`Refusing to remove non-owned ChatLab temp directory: ${resolvedDir}`);
|
|
2809
|
+
}
|
|
2810
|
+
fs.rmSync(resolvedDir, { recursive: true, force: true });
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2741
2813
|
// ../../packages/node-runtime/src/import/write-parse-result.ts
|
|
2742
2814
|
function writeParseResultToDb(db, meta, members, messages) {
|
|
2743
2815
|
let messageCount = 0;
|
|
@@ -2852,28 +2924,28 @@ function writeParseResultToDb(db, meta, members, messages) {
|
|
|
2852
2924
|
}
|
|
2853
2925
|
|
|
2854
2926
|
// ../../packages/parser/src/index.ts
|
|
2855
|
-
import * as
|
|
2856
|
-
import * as
|
|
2927
|
+
import * as fs18 from "fs";
|
|
2928
|
+
import * as path14 from "path";
|
|
2857
2929
|
|
|
2858
2930
|
// ../../packages/parser/src/sniffer.ts
|
|
2859
|
-
import * as
|
|
2860
|
-
import * as
|
|
2931
|
+
import * as fs2 from "fs";
|
|
2932
|
+
import * as path2 from "path";
|
|
2861
2933
|
var HEAD_SIZE = 64 * 1024;
|
|
2862
2934
|
function readFileHead(filePath, size = HEAD_SIZE) {
|
|
2863
|
-
const fd =
|
|
2935
|
+
const fd = fs2.openSync(filePath, "r");
|
|
2864
2936
|
const buffer = Buffer.alloc(size);
|
|
2865
|
-
const bytesRead =
|
|
2866
|
-
|
|
2937
|
+
const bytesRead = fs2.readSync(fd, buffer, 0, size, 0);
|
|
2938
|
+
fs2.closeSync(fd);
|
|
2867
2939
|
return buffer.slice(0, bytesRead).toString("utf-8");
|
|
2868
2940
|
}
|
|
2869
2941
|
function getExtension(filePath) {
|
|
2870
|
-
return
|
|
2942
|
+
return path2.extname(filePath).toLowerCase();
|
|
2871
2943
|
}
|
|
2872
2944
|
function matchHeadSignatures(headContent, patterns) {
|
|
2873
2945
|
return patterns.some((pattern) => pattern.test(headContent));
|
|
2874
2946
|
}
|
|
2875
2947
|
function matchFilenameSignatures(filePath, patterns) {
|
|
2876
|
-
const filename =
|
|
2948
|
+
const filename = path2.basename(filePath);
|
|
2877
2949
|
return patterns.some((pattern) => pattern.test(filename));
|
|
2878
2950
|
}
|
|
2879
2951
|
function matchRequiredFields(headContent, fields) {
|
|
@@ -3021,18 +3093,18 @@ var import_stream_json = __toESM(require_stream_json(), 1);
|
|
|
3021
3093
|
var import_Pick = __toESM(require_Pick(), 1);
|
|
3022
3094
|
var import_StreamValues = __toESM(require_StreamValues(), 1);
|
|
3023
3095
|
var import_stream_chain = __toESM(require_stream_chain(), 1);
|
|
3024
|
-
import * as
|
|
3096
|
+
import * as fs4 from "fs";
|
|
3025
3097
|
|
|
3026
3098
|
// ../../packages/parser/src/utils.ts
|
|
3027
|
-
import * as
|
|
3099
|
+
import * as fs3 from "fs";
|
|
3028
3100
|
function getFileSize(filePath) {
|
|
3029
|
-
return
|
|
3101
|
+
return fs3.statSync(filePath).size;
|
|
3030
3102
|
}
|
|
3031
3103
|
function readFileHeadBytes(filePath, size) {
|
|
3032
|
-
const fd =
|
|
3104
|
+
const fd = fs3.openSync(filePath, "r");
|
|
3033
3105
|
const buffer = Buffer.alloc(size);
|
|
3034
|
-
const bytesRead =
|
|
3035
|
-
|
|
3106
|
+
const bytesRead = fs3.readSync(fd, buffer, 0, size, 0);
|
|
3107
|
+
fs3.closeSync(fd);
|
|
3036
3108
|
return buffer.slice(0, bytesRead).toString("utf-8");
|
|
3037
3109
|
}
|
|
3038
3110
|
var createProgress = (stage, bytesRead, totalBytes, messagesProcessed, message) => {
|
|
@@ -3062,7 +3134,7 @@ function isValidYear(timestampSeconds) {
|
|
|
3062
3134
|
}
|
|
3063
3135
|
|
|
3064
3136
|
// ../../packages/parser/src/formats/chatlab.ts
|
|
3065
|
-
import * as
|
|
3137
|
+
import * as path3 from "path";
|
|
3066
3138
|
|
|
3067
3139
|
// ../../packages/parser/src/native/loader.ts
|
|
3068
3140
|
import { createRequire } from "module";
|
|
@@ -3145,7 +3217,7 @@ async function* pumpNativeParser(adapter, options2, parser11, fallback) {
|
|
|
3145
3217
|
if (!batch) break;
|
|
3146
3218
|
messagesProcessed += batch.length;
|
|
3147
3219
|
yield { type: "messages", data: batch.map((message) => adapter.mapMessage(message, metaJson)) };
|
|
3148
|
-
await new Promise((
|
|
3220
|
+
await new Promise((resolve4) => setImmediate(resolve4));
|
|
3149
3221
|
}
|
|
3150
3222
|
const doneProgress = createProgress("done", totalBytes, totalBytes, messagesProcessed, "");
|
|
3151
3223
|
yield { type: "progress", data: doneProgress };
|
|
@@ -3243,7 +3315,7 @@ var { pick } = import_Pick.default;
|
|
|
3243
3315
|
var { streamValues } = import_StreamValues.default;
|
|
3244
3316
|
var { chain } = import_stream_chain.default;
|
|
3245
3317
|
function extractNameFromFilePath(filePath) {
|
|
3246
|
-
const basename13 =
|
|
3318
|
+
const basename13 = path3.basename(filePath);
|
|
3247
3319
|
const name = basename13.replace(/\.json$/i, "");
|
|
3248
3320
|
return name || "\u672A\u77E5\u7FA4\u804A";
|
|
3249
3321
|
}
|
|
@@ -3317,8 +3389,8 @@ async function* parseChatLab(options2) {
|
|
|
3317
3389
|
const members = [];
|
|
3318
3390
|
const memberMapFromMessages = /* @__PURE__ */ new Map();
|
|
3319
3391
|
const messageBatch = [];
|
|
3320
|
-
await new Promise((
|
|
3321
|
-
const readStream =
|
|
3392
|
+
await new Promise((resolve4, reject) => {
|
|
3393
|
+
const readStream = fs4.createReadStream(filePath, { encoding: "utf-8" });
|
|
3322
3394
|
readStream.on("data", (chunk) => {
|
|
3323
3395
|
bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
|
|
3324
3396
|
});
|
|
@@ -3372,7 +3444,7 @@ async function* parseChatLab(options2) {
|
|
|
3372
3444
|
if (batchCollector.length > 0) {
|
|
3373
3445
|
messageBatch.push(...batchCollector);
|
|
3374
3446
|
}
|
|
3375
|
-
|
|
3447
|
+
resolve4();
|
|
3376
3448
|
});
|
|
3377
3449
|
pipeline2.on("error", reject);
|
|
3378
3450
|
});
|
|
@@ -3410,11 +3482,11 @@ var module_ = {
|
|
|
3410
3482
|
var chatlab_default = module_;
|
|
3411
3483
|
|
|
3412
3484
|
// ../../packages/parser/src/formats/chatlab-jsonl.ts
|
|
3413
|
-
import * as
|
|
3485
|
+
import * as fs5 from "fs";
|
|
3414
3486
|
import * as readline from "readline";
|
|
3415
|
-
import * as
|
|
3487
|
+
import * as path4 from "path";
|
|
3416
3488
|
function extractNameFromFilePath2(filePath) {
|
|
3417
|
-
const basename13 =
|
|
3489
|
+
const basename13 = path4.basename(filePath);
|
|
3418
3490
|
const name = basename13.replace(/\.jsonl$/i, "");
|
|
3419
3491
|
return name || "\u672A\u77E5\u7FA4\u804A";
|
|
3420
3492
|
}
|
|
@@ -3453,9 +3525,10 @@ async function* parseChatLabJsonl(options2) {
|
|
|
3453
3525
|
const members = [];
|
|
3454
3526
|
const memberMap = /* @__PURE__ */ new Map();
|
|
3455
3527
|
const messageBatch = [];
|
|
3528
|
+
let explicitMembersEmitted = false;
|
|
3456
3529
|
let meta = null;
|
|
3457
3530
|
let headerParsed = false;
|
|
3458
|
-
const fileStream =
|
|
3531
|
+
const fileStream = fs5.createReadStream(filePath, { encoding: "utf-8" });
|
|
3459
3532
|
const rl = readline.createInterface({
|
|
3460
3533
|
input: fileStream,
|
|
3461
3534
|
crlfDelay: Infinity
|
|
@@ -3523,6 +3596,11 @@ async function* parseChatLabJsonl(options2) {
|
|
|
3523
3596
|
});
|
|
3524
3597
|
messagesProcessed++;
|
|
3525
3598
|
if (messageBatch.length >= batchSize) {
|
|
3599
|
+
if (members.length > 0 && !explicitMembersEmitted) {
|
|
3600
|
+
yield { type: "members", data: members.slice() };
|
|
3601
|
+
explicitMembersEmitted = true;
|
|
3602
|
+
}
|
|
3603
|
+
yield { type: "messages", data: messageBatch.splice(0) };
|
|
3526
3604
|
const progress = createProgress(
|
|
3527
3605
|
"parsing",
|
|
3528
3606
|
bytesRead,
|
|
@@ -3530,6 +3608,7 @@ async function* parseChatLabJsonl(options2) {
|
|
|
3530
3608
|
messagesProcessed,
|
|
3531
3609
|
`\u5DF2\u5904\u7406 ${messagesProcessed.toLocaleString()} \u6761\u6D88\u606F...`
|
|
3532
3610
|
);
|
|
3611
|
+
yield { type: "progress", data: progress };
|
|
3533
3612
|
onProgress?.(progress);
|
|
3534
3613
|
}
|
|
3535
3614
|
break;
|
|
@@ -3544,13 +3623,14 @@ async function* parseChatLabJsonl(options2) {
|
|
|
3544
3623
|
yield { type: "meta", data: meta };
|
|
3545
3624
|
}
|
|
3546
3625
|
if (members.length > 0) {
|
|
3547
|
-
|
|
3626
|
+
if (!explicitMembersEmitted) {
|
|
3627
|
+
yield { type: "members", data: members };
|
|
3628
|
+
}
|
|
3548
3629
|
} else if (memberMap.size > 0) {
|
|
3549
3630
|
yield { type: "members", data: Array.from(memberMap.values()) };
|
|
3550
3631
|
}
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
yield { type: "messages", data: batch };
|
|
3632
|
+
if (messageBatch.length > 0) {
|
|
3633
|
+
yield { type: "messages", data: messageBatch };
|
|
3554
3634
|
}
|
|
3555
3635
|
const doneProgress = createProgress("done", totalBytes, totalBytes, messagesProcessed, "");
|
|
3556
3636
|
yield { type: "progress", data: doneProgress };
|
|
@@ -3580,28 +3660,30 @@ var import_stream_json3 = __toESM(require_stream_json(), 1);
|
|
|
3580
3660
|
var import_Pick3 = __toESM(require_Pick(), 1);
|
|
3581
3661
|
var import_StreamValues3 = __toESM(require_StreamValues(), 1);
|
|
3582
3662
|
var import_stream_chain3 = __toESM(require_stream_chain(), 1);
|
|
3583
|
-
import * as
|
|
3584
|
-
import * as
|
|
3663
|
+
import * as fs7 from "fs";
|
|
3664
|
+
import * as path6 from "path";
|
|
3585
3665
|
|
|
3586
3666
|
// ../../packages/parser/src/formats/shuakami-qq-preprocessor.ts
|
|
3587
3667
|
var import_stream_json2 = __toESM(require_stream_json(), 1);
|
|
3588
3668
|
var import_Pick2 = __toESM(require_Pick(), 1);
|
|
3589
3669
|
var import_StreamValues2 = __toESM(require_StreamValues(), 1);
|
|
3590
3670
|
var import_stream_chain2 = __toESM(require_stream_chain(), 1);
|
|
3591
|
-
import * as
|
|
3592
|
-
import * as
|
|
3593
|
-
import * as
|
|
3671
|
+
import * as fs6 from "fs";
|
|
3672
|
+
import * as path5 from "path";
|
|
3673
|
+
import * as os2 from "os";
|
|
3594
3674
|
var { parser: parser3 } = import_stream_json2.default;
|
|
3595
3675
|
var { pick: pick2 } = import_Pick2.default;
|
|
3596
3676
|
var { streamValues: streamValues2 } = import_StreamValues2.default;
|
|
3597
3677
|
var { chain: chain2 } = import_stream_chain2.default;
|
|
3598
3678
|
var PREPROCESS_THRESHOLD = 50 * 1024 * 1024;
|
|
3599
3679
|
function getTempDir() {
|
|
3600
|
-
|
|
3680
|
+
const configuredRoot = process.env.CHATLAB_TEMP_ROOT?.trim();
|
|
3681
|
+
const root = configuredRoot ? path5.resolve(configuredRoot) : path5.resolve(process.platform === "darwin" ? "/private/tmp/chatlab" : path5.join(os2.tmpdir(), "chatlab"));
|
|
3682
|
+
return path5.join(root, "parser");
|
|
3601
3683
|
}
|
|
3602
3684
|
function ensureDir(dir) {
|
|
3603
|
-
if (!
|
|
3604
|
-
|
|
3685
|
+
if (!fs6.existsSync(dir)) {
|
|
3686
|
+
fs6.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3605
3687
|
}
|
|
3606
3688
|
}
|
|
3607
3689
|
function extractJsonObject(content, key) {
|
|
@@ -3643,12 +3725,12 @@ function extractJsonObject(content, key) {
|
|
|
3643
3725
|
}
|
|
3644
3726
|
function readAvatarsFromFile(filePath) {
|
|
3645
3727
|
try {
|
|
3646
|
-
const stats =
|
|
3728
|
+
const stats = fs6.statSync(filePath);
|
|
3647
3729
|
const tailSize = Math.min(stats.size, 5e6);
|
|
3648
|
-
const fd =
|
|
3730
|
+
const fd = fs6.openSync(filePath, "r");
|
|
3649
3731
|
const buffer = Buffer.alloc(tailSize);
|
|
3650
|
-
|
|
3651
|
-
|
|
3732
|
+
fs6.readSync(fd, buffer, 0, tailSize, stats.size - tailSize);
|
|
3733
|
+
fs6.closeSync(fd);
|
|
3652
3734
|
const tailContent = buffer.toString("utf-8");
|
|
3653
3735
|
return extractJsonObject(tailContent, "avatars");
|
|
3654
3736
|
} catch {
|
|
@@ -3707,15 +3789,15 @@ async function preprocessQQJson(inputPath, onProgress) {
|
|
|
3707
3789
|
let messagesProcessed = 0;
|
|
3708
3790
|
const tempDir = getTempDir();
|
|
3709
3791
|
ensureDir(tempDir);
|
|
3710
|
-
const outputFilename = `slim_${Date.now()}_${
|
|
3711
|
-
const outputPath =
|
|
3792
|
+
const outputFilename = `slim_${Date.now()}_${path5.basename(inputPath)}`;
|
|
3793
|
+
const outputPath = path5.join(tempDir, outputFilename);
|
|
3712
3794
|
onProgress?.(createProgress("parsing", 0, totalBytes, 0, ""));
|
|
3713
3795
|
const avatarsStr = readAvatarsFromFile(inputPath);
|
|
3714
|
-
return new Promise((
|
|
3796
|
+
return new Promise((resolve4, reject) => {
|
|
3715
3797
|
const headChunks = [];
|
|
3716
3798
|
let headSize = 0;
|
|
3717
3799
|
const maxHeadSize = 1e5;
|
|
3718
|
-
const headStream =
|
|
3800
|
+
const headStream = fs6.createReadStream(inputPath, { encoding: "utf-8" });
|
|
3719
3801
|
let chatInfo = { name: "\u672A\u77E5\u7FA4\u804A", type: "group" };
|
|
3720
3802
|
let metadata;
|
|
3721
3803
|
let statistics;
|
|
@@ -3752,8 +3834,8 @@ async function preprocessQQJson(inputPath, onProgress) {
|
|
|
3752
3834
|
} catch {
|
|
3753
3835
|
}
|
|
3754
3836
|
onProgress?.(createProgress("parsing", 0, totalBytes, 0, ""));
|
|
3755
|
-
const readStream =
|
|
3756
|
-
const writeStream =
|
|
3837
|
+
const readStream = fs6.createReadStream(inputPath, { encoding: "utf-8" });
|
|
3838
|
+
const writeStream = fs6.createWriteStream(outputPath, { encoding: "utf-8" });
|
|
3757
3839
|
readStream.on("data", (chunk) => {
|
|
3758
3840
|
bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
|
|
3759
3841
|
});
|
|
@@ -3793,13 +3875,13 @@ async function preprocessQQJson(inputPath, onProgress) {
|
|
|
3793
3875
|
writeStream.end();
|
|
3794
3876
|
writeStream.on("finish", () => {
|
|
3795
3877
|
onProgress?.(createProgress("done", totalBytes, totalBytes, messagesProcessed, ""));
|
|
3796
|
-
|
|
3878
|
+
resolve4(outputPath);
|
|
3797
3879
|
});
|
|
3798
3880
|
});
|
|
3799
3881
|
pipeline2.on("error", (err) => {
|
|
3800
3882
|
writeStream.destroy();
|
|
3801
|
-
if (
|
|
3802
|
-
|
|
3883
|
+
if (fs6.existsSync(outputPath)) {
|
|
3884
|
+
fs6.unlinkSync(outputPath);
|
|
3803
3885
|
}
|
|
3804
3886
|
onProgress?.(createProgress("error", bytesRead, totalBytes, messagesProcessed, err.message));
|
|
3805
3887
|
reject(err);
|
|
@@ -3810,8 +3892,8 @@ async function preprocessQQJson(inputPath, onProgress) {
|
|
|
3810
3892
|
}
|
|
3811
3893
|
function cleanupTempFile(filePath) {
|
|
3812
3894
|
try {
|
|
3813
|
-
if (
|
|
3814
|
-
|
|
3895
|
+
if (fs6.existsSync(filePath) && path5.dirname(path5.resolve(filePath)) === path5.resolve(getTempDir())) {
|
|
3896
|
+
fs6.unlinkSync(filePath);
|
|
3815
3897
|
}
|
|
3816
3898
|
} catch {
|
|
3817
3899
|
}
|
|
@@ -3878,7 +3960,7 @@ function extractJsonObject2(content, key) {
|
|
|
3878
3960
|
return null;
|
|
3879
3961
|
}
|
|
3880
3962
|
function extractNameFromFilePath3(filePath) {
|
|
3881
|
-
const basename13 =
|
|
3963
|
+
const basename13 = path6.basename(filePath);
|
|
3882
3964
|
return basename13.replace(/\.json$/i, "") || "\u672A\u77E5\u7FA4\u804A";
|
|
3883
3965
|
}
|
|
3884
3966
|
function isPlaceholderSenderId(id) {
|
|
@@ -3975,8 +4057,8 @@ async function* parseV4(options2) {
|
|
|
3975
4057
|
yield { type: "meta", data: meta };
|
|
3976
4058
|
const memberMap = /* @__PURE__ */ new Map();
|
|
3977
4059
|
const messageBatch = [];
|
|
3978
|
-
await new Promise((
|
|
3979
|
-
const readStream =
|
|
4060
|
+
await new Promise((resolve4, reject) => {
|
|
4061
|
+
const readStream = fs7.createReadStream(filePath, { encoding: "utf-8" });
|
|
3980
4062
|
readStream.on("data", (chunk) => {
|
|
3981
4063
|
bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
|
|
3982
4064
|
});
|
|
@@ -4031,17 +4113,17 @@ async function* parseV4(options2) {
|
|
|
4031
4113
|
onProgress?.(progress);
|
|
4032
4114
|
}
|
|
4033
4115
|
});
|
|
4034
|
-
pipeline2.on("end",
|
|
4116
|
+
pipeline2.on("end", resolve4);
|
|
4035
4117
|
pipeline2.on("error", reject);
|
|
4036
4118
|
});
|
|
4037
4119
|
const avatarsMap = /* @__PURE__ */ new Map();
|
|
4038
4120
|
try {
|
|
4039
|
-
const stats =
|
|
4121
|
+
const stats = fs7.statSync(filePath);
|
|
4040
4122
|
const tailSize = Math.min(stats.size, 5e6);
|
|
4041
|
-
const fd =
|
|
4123
|
+
const fd = fs7.openSync(filePath, "r");
|
|
4042
4124
|
const buffer = Buffer.alloc(tailSize);
|
|
4043
|
-
|
|
4044
|
-
|
|
4125
|
+
fs7.readSync(fd, buffer, 0, tailSize, stats.size - tailSize);
|
|
4126
|
+
fs7.closeSync(fd);
|
|
4045
4127
|
const tailContent = buffer.toString("utf-8");
|
|
4046
4128
|
const avatarsStr = extractJsonObject2(tailContent, "avatars");
|
|
4047
4129
|
if (avatarsStr) {
|
|
@@ -4093,8 +4175,8 @@ var module_3 = {
|
|
|
4093
4175
|
var shuakami_qq_exporter_default = module_3;
|
|
4094
4176
|
|
|
4095
4177
|
// ../../packages/parser/src/formats/shuakami-qq-exporter-chunked.ts
|
|
4096
|
-
import * as
|
|
4097
|
-
import * as
|
|
4178
|
+
import * as fs8 from "fs";
|
|
4179
|
+
import * as path7 from "path";
|
|
4098
4180
|
import * as readline2 from "readline";
|
|
4099
4181
|
var feature4 = {
|
|
4100
4182
|
id: "shuakami-qq-exporter-chunked",
|
|
@@ -4143,7 +4225,7 @@ function convertMessageType2(msgType, content, isRecalled) {
|
|
|
4143
4225
|
return 0 /* TEXT */;
|
|
4144
4226
|
}
|
|
4145
4227
|
function readManifest(manifestPath) {
|
|
4146
|
-
const content =
|
|
4228
|
+
const content = fs8.readFileSync(manifestPath, "utf-8");
|
|
4147
4229
|
return JSON.parse(content);
|
|
4148
4230
|
}
|
|
4149
4231
|
function getChunkRelativePath(chunk) {
|
|
@@ -4161,9 +4243,9 @@ function calculateTotalBytes(manifest, baseDir) {
|
|
|
4161
4243
|
let total = 0;
|
|
4162
4244
|
for (const chunk of manifest.chunked.chunks) {
|
|
4163
4245
|
const relativePath = getChunkRelativePath(chunk);
|
|
4164
|
-
const chunkPath =
|
|
4165
|
-
if (
|
|
4166
|
-
total +=
|
|
4246
|
+
const chunkPath = path7.join(baseDir, relativePath);
|
|
4247
|
+
if (fs8.existsSync(chunkPath)) {
|
|
4248
|
+
total += fs8.statSync(chunkPath).size;
|
|
4167
4249
|
}
|
|
4168
4250
|
}
|
|
4169
4251
|
return total;
|
|
@@ -4171,10 +4253,10 @@ function calculateTotalBytes(manifest, baseDir) {
|
|
|
4171
4253
|
function readAvatars(baseDir, avatarsInfo) {
|
|
4172
4254
|
const avatarsMap = /* @__PURE__ */ new Map();
|
|
4173
4255
|
if (!avatarsInfo?.file) return avatarsMap;
|
|
4174
|
-
const avatarsPath =
|
|
4175
|
-
if (!
|
|
4256
|
+
const avatarsPath = path7.join(baseDir, avatarsInfo.file);
|
|
4257
|
+
if (!fs8.existsSync(avatarsPath)) return avatarsMap;
|
|
4176
4258
|
try {
|
|
4177
|
-
const content =
|
|
4259
|
+
const content = fs8.readFileSync(avatarsPath, "utf-8");
|
|
4178
4260
|
const avatars = JSON.parse(content);
|
|
4179
4261
|
for (const [uin, avatar] of Object.entries(avatars)) {
|
|
4180
4262
|
if (avatar && typeof avatar === "string" && avatar.startsWith("data:image/")) {
|
|
@@ -4192,7 +4274,7 @@ async function* readJsonlFile(filePath, onParseError) {
|
|
|
4192
4274
|
let parseErrorCount = 0;
|
|
4193
4275
|
const MAX_PARSE_ERRORS_TO_LOG = 10;
|
|
4194
4276
|
try {
|
|
4195
|
-
fileStream =
|
|
4277
|
+
fileStream = fs8.createReadStream(filePath, { encoding: "utf-8" });
|
|
4196
4278
|
rl = readline2.createInterface({
|
|
4197
4279
|
input: fileStream,
|
|
4198
4280
|
crlfDelay: Infinity
|
|
@@ -4223,7 +4305,7 @@ async function* readJsonlFile(filePath, onParseError) {
|
|
|
4223
4305
|
async function* parseChunkedJsonl(options2) {
|
|
4224
4306
|
const { filePath, batchSize = 5e3, onProgress, onLog } = options2;
|
|
4225
4307
|
const manifestPath = filePath;
|
|
4226
|
-
const baseDir =
|
|
4308
|
+
const baseDir = path7.dirname(manifestPath);
|
|
4227
4309
|
onLog?.("info", `\u5F00\u59CB\u89E3\u6790 manifest: ${manifestPath}`);
|
|
4228
4310
|
onLog?.("info", `\u57FA\u7840\u76EE\u5F55: ${baseDir}`);
|
|
4229
4311
|
let manifest;
|
|
@@ -4277,13 +4359,13 @@ async function* parseChunkedJsonl(options2) {
|
|
|
4277
4359
|
for (let chunkIndex = 0; chunkIndex < manifest.chunked.chunks.length; chunkIndex++) {
|
|
4278
4360
|
const chunkInfo = manifest.chunked.chunks[chunkIndex];
|
|
4279
4361
|
const relativePath = getChunkRelativePath(chunkInfo);
|
|
4280
|
-
const chunkPath =
|
|
4362
|
+
const chunkPath = path7.join(baseDir, relativePath);
|
|
4281
4363
|
const chunkMessageCount = getChunkMessageCount(chunkInfo);
|
|
4282
|
-
if (!
|
|
4364
|
+
if (!fs8.existsSync(chunkPath)) {
|
|
4283
4365
|
onLog?.("error", `\u5206\u5757\u6587\u4EF6\u4E0D\u5B58\u5728: ${chunkPath}`);
|
|
4284
4366
|
continue;
|
|
4285
4367
|
}
|
|
4286
|
-
const chunkSize =
|
|
4368
|
+
const chunkSize = fs8.statSync(chunkPath).size;
|
|
4287
4369
|
let chunkMessagesRead = 0;
|
|
4288
4370
|
let chunkParseErrors = 0;
|
|
4289
4371
|
onLog?.(
|
|
@@ -4405,8 +4487,8 @@ var import_stream_json4 = __toESM(require_stream_json(), 1);
|
|
|
4405
4487
|
var import_Pick4 = __toESM(require_Pick(), 1);
|
|
4406
4488
|
var import_StreamValues4 = __toESM(require_StreamValues(), 1);
|
|
4407
4489
|
var import_stream_chain4 = __toESM(require_stream_chain(), 1);
|
|
4408
|
-
import * as
|
|
4409
|
-
import * as
|
|
4490
|
+
import * as fs9 from "fs";
|
|
4491
|
+
import * as path8 from "path";
|
|
4410
4492
|
|
|
4411
4493
|
// ../../packages/parser/src/native/weflow-native.ts
|
|
4412
4494
|
var weflowAdapter = {
|
|
@@ -4479,7 +4561,7 @@ var { pick: pick4 } = import_Pick4.default;
|
|
|
4479
4561
|
var { streamValues: streamValues4 } = import_StreamValues4.default;
|
|
4480
4562
|
var { chain: chain4 } = import_stream_chain4.default;
|
|
4481
4563
|
function extractNameFromFilePath4(filePath) {
|
|
4482
|
-
const basename13 =
|
|
4564
|
+
const basename13 = path8.basename(filePath);
|
|
4483
4565
|
const name = basename13.replace(/\.json$/i, "");
|
|
4484
4566
|
return name || "\u672A\u77E5\u804A\u5929";
|
|
4485
4567
|
}
|
|
@@ -4547,8 +4629,8 @@ async function* parseWeFlow(options2) {
|
|
|
4547
4629
|
const headContent = readFileHeadBytes(filePath, 5e3);
|
|
4548
4630
|
let session = null;
|
|
4549
4631
|
try {
|
|
4550
|
-
await new Promise((
|
|
4551
|
-
const sessionStream =
|
|
4632
|
+
await new Promise((resolve4) => {
|
|
4633
|
+
const sessionStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
|
|
4552
4634
|
let sessionContent = "";
|
|
4553
4635
|
let inSession = false;
|
|
4554
4636
|
let braceDepth = 0;
|
|
@@ -4599,9 +4681,9 @@ async function* parseWeFlow(options2) {
|
|
|
4599
4681
|
} catch {
|
|
4600
4682
|
}
|
|
4601
4683
|
}
|
|
4602
|
-
|
|
4684
|
+
resolve4();
|
|
4603
4685
|
});
|
|
4604
|
-
sessionStream.on("error", () =>
|
|
4686
|
+
sessionStream.on("error", () => resolve4());
|
|
4605
4687
|
});
|
|
4606
4688
|
} catch {
|
|
4607
4689
|
}
|
|
@@ -4670,8 +4752,8 @@ async function* parseWeFlow(options2) {
|
|
|
4670
4752
|
}
|
|
4671
4753
|
if (avatarsMap.size === 0) {
|
|
4672
4754
|
try {
|
|
4673
|
-
await new Promise((
|
|
4674
|
-
const avatarStream =
|
|
4755
|
+
await new Promise((resolve4) => {
|
|
4756
|
+
const avatarStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
|
|
4675
4757
|
let avatarsContent = "";
|
|
4676
4758
|
let inAvatars = false;
|
|
4677
4759
|
let braceDepth = 0;
|
|
@@ -4727,9 +4809,9 @@ async function* parseWeFlow(options2) {
|
|
|
4727
4809
|
} catch {
|
|
4728
4810
|
}
|
|
4729
4811
|
}
|
|
4730
|
-
|
|
4812
|
+
resolve4();
|
|
4731
4813
|
});
|
|
4732
|
-
avatarStream.on("error", () =>
|
|
4814
|
+
avatarStream.on("error", () => resolve4());
|
|
4733
4815
|
});
|
|
4734
4816
|
} catch {
|
|
4735
4817
|
}
|
|
@@ -4737,8 +4819,8 @@ async function* parseWeFlow(options2) {
|
|
|
4737
4819
|
const groupAvatar = sessionData?.avatar || (groupId ? avatarsMap.get(groupId) : void 0);
|
|
4738
4820
|
let ownerId;
|
|
4739
4821
|
try {
|
|
4740
|
-
await new Promise((
|
|
4741
|
-
const scanStream =
|
|
4822
|
+
await new Promise((resolve4) => {
|
|
4823
|
+
const scanStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
|
|
4742
4824
|
const scanPipeline = chain4([scanStream, parser5(), pick4({ filter: /^messages\.\d+$/ }), streamValues4()]);
|
|
4743
4825
|
scanPipeline.on("data", ({ value }) => {
|
|
4744
4826
|
if (value.isSend === 1 && value.senderUsername && !value.senderUsername.endsWith("@chatroom")) {
|
|
@@ -4746,9 +4828,9 @@ async function* parseWeFlow(options2) {
|
|
|
4746
4828
|
scanStream.destroy();
|
|
4747
4829
|
}
|
|
4748
4830
|
});
|
|
4749
|
-
scanStream.on("close", () =>
|
|
4750
|
-
scanPipeline.on("end", () =>
|
|
4751
|
-
scanPipeline.on("error", () =>
|
|
4831
|
+
scanStream.on("close", () => resolve4());
|
|
4832
|
+
scanPipeline.on("end", () => resolve4());
|
|
4833
|
+
scanPipeline.on("error", () => resolve4());
|
|
4752
4834
|
});
|
|
4753
4835
|
} catch {
|
|
4754
4836
|
}
|
|
@@ -4763,8 +4845,8 @@ async function* parseWeFlow(options2) {
|
|
|
4763
4845
|
yield { type: "meta", data: meta };
|
|
4764
4846
|
const memberMap = /* @__PURE__ */ new Map();
|
|
4765
4847
|
const messageBatch = [];
|
|
4766
|
-
await new Promise((
|
|
4767
|
-
const readStream =
|
|
4848
|
+
await new Promise((resolve4, reject) => {
|
|
4849
|
+
const readStream = fs9.createReadStream(filePath, { encoding: "utf-8" });
|
|
4768
4850
|
readStream.on("data", (chunk) => {
|
|
4769
4851
|
bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
|
|
4770
4852
|
});
|
|
@@ -4836,7 +4918,7 @@ async function* parseWeFlow(options2) {
|
|
|
4836
4918
|
if (batchCollector.length > 0) {
|
|
4837
4919
|
messageBatch.push(...batchCollector);
|
|
4838
4920
|
}
|
|
4839
|
-
|
|
4921
|
+
resolve4();
|
|
4840
4922
|
});
|
|
4841
4923
|
pipeline2.on("error", reject);
|
|
4842
4924
|
});
|
|
@@ -4901,7 +4983,7 @@ var import_stream_json5 = __toESM(require_stream_json(), 1);
|
|
|
4901
4983
|
var import_Pick5 = __toESM(require_Pick(), 1);
|
|
4902
4984
|
var import_StreamValues5 = __toESM(require_StreamValues(), 1);
|
|
4903
4985
|
var import_stream_chain5 = __toESM(require_stream_chain(), 1);
|
|
4904
|
-
import * as
|
|
4986
|
+
import * as fs10 from "fs";
|
|
4905
4987
|
var { parser: parser6 } = import_stream_json5.default;
|
|
4906
4988
|
var { pick: pick5 } = import_Pick5.default;
|
|
4907
4989
|
var { streamValues: streamValues5 } = import_StreamValues5.default;
|
|
@@ -5050,8 +5132,8 @@ async function* parseDiscordExporter(options2) {
|
|
|
5050
5132
|
onLog?.("info", `\u7FA4\u804A\u540D\u79F0: ${chatName}`);
|
|
5051
5133
|
const memberMap = /* @__PURE__ */ new Map();
|
|
5052
5134
|
const messageBatch = [];
|
|
5053
|
-
await new Promise((
|
|
5054
|
-
const readStream =
|
|
5135
|
+
await new Promise((resolve4, reject) => {
|
|
5136
|
+
const readStream = fs10.createReadStream(filePath, { encoding: "utf-8" });
|
|
5055
5137
|
readStream.on("data", (chunk) => {
|
|
5056
5138
|
bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
|
|
5057
5139
|
});
|
|
@@ -5129,7 +5211,7 @@ ${stickerTexts.join("\n")}` : stickerTexts.join("\n");
|
|
|
5129
5211
|
if (batchCollector.length > 0) {
|
|
5130
5212
|
messageBatch.push(...batchCollector);
|
|
5131
5213
|
}
|
|
5132
|
-
|
|
5214
|
+
resolve4();
|
|
5133
5215
|
});
|
|
5134
5216
|
pipeline2.on("error", reject);
|
|
5135
5217
|
});
|
|
@@ -5167,7 +5249,7 @@ var import_stream_chain6 = __toESM(require_stream_chain(), 1);
|
|
|
5167
5249
|
var import_stream_json6 = __toESM(require_stream_json(), 1);
|
|
5168
5250
|
var import_Pick6 = __toESM(require_Pick(), 1);
|
|
5169
5251
|
var import_StreamValues6 = __toESM(require_StreamValues(), 1);
|
|
5170
|
-
import * as
|
|
5252
|
+
import * as fs11 from "fs";
|
|
5171
5253
|
|
|
5172
5254
|
// ../../packages/parser/src/formats/utils/telegram-utils.ts
|
|
5173
5255
|
function mapChatType(telegramType) {
|
|
@@ -5252,8 +5334,8 @@ var feature8 = {
|
|
|
5252
5334
|
};
|
|
5253
5335
|
async function scanChats(filePath) {
|
|
5254
5336
|
const chats = [];
|
|
5255
|
-
return new Promise((
|
|
5256
|
-
const readStream =
|
|
5337
|
+
return new Promise((resolve4, reject) => {
|
|
5338
|
+
const readStream = fs11.createReadStream(filePath, { encoding: "utf-8" });
|
|
5257
5339
|
const pipeline2 = chain6([readStream, parser7(), pick6({ filter: /^chats\.list\.\d+$/ }), streamValues6()]);
|
|
5258
5340
|
pipeline2.on("data", ({ value }) => {
|
|
5259
5341
|
const chat = value;
|
|
@@ -5266,7 +5348,7 @@ async function scanChats(filePath) {
|
|
|
5266
5348
|
});
|
|
5267
5349
|
});
|
|
5268
5350
|
pipeline2.on("end", () => {
|
|
5269
|
-
|
|
5351
|
+
resolve4(chats);
|
|
5270
5352
|
});
|
|
5271
5353
|
pipeline2.on("error", (err) => {
|
|
5272
5354
|
reject(new Error(`\u626B\u63CF Telegram \u6587\u4EF6\u5931\u8D25: ${err.message}`));
|
|
@@ -5285,8 +5367,8 @@ async function* parseTelegram(options2) {
|
|
|
5285
5367
|
onLog?.("info", `\u5F00\u59CB\u89E3\u6790 Telegram JSON \u6587\u4EF6\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
|
|
5286
5368
|
onLog?.("info", `\u76EE\u6807\u804A\u5929\u7D22\u5F15: ${chatIndex}`);
|
|
5287
5369
|
const chatPathFilter = `chats.list.${chatIndex}`;
|
|
5288
|
-
const chatData = await new Promise((
|
|
5289
|
-
const readStream =
|
|
5370
|
+
const chatData = await new Promise((resolve4, reject) => {
|
|
5371
|
+
const readStream = fs11.createReadStream(filePath, { encoding: "utf-8" });
|
|
5290
5372
|
readStream.on("data", (chunk) => {
|
|
5291
5373
|
bytesRead += typeof chunk === "string" ? Buffer.byteLength(chunk) : chunk.length;
|
|
5292
5374
|
});
|
|
@@ -5299,10 +5381,10 @@ async function* parseTelegram(options2) {
|
|
|
5299
5381
|
let found = false;
|
|
5300
5382
|
pipeline2.on("data", ({ value }) => {
|
|
5301
5383
|
found = true;
|
|
5302
|
-
|
|
5384
|
+
resolve4(value);
|
|
5303
5385
|
});
|
|
5304
5386
|
pipeline2.on("end", () => {
|
|
5305
|
-
if (!found)
|
|
5387
|
+
if (!found) resolve4(null);
|
|
5306
5388
|
});
|
|
5307
5389
|
pipeline2.on("error", reject);
|
|
5308
5390
|
});
|
|
@@ -5394,7 +5476,7 @@ var telegram_native_default = module_8;
|
|
|
5394
5476
|
var import_stream_chain7 = __toESM(require_stream_chain(), 1);
|
|
5395
5477
|
var import_stream_json7 = __toESM(require_stream_json(), 1);
|
|
5396
5478
|
var import_StreamValues7 = __toESM(require_StreamValues(), 1);
|
|
5397
|
-
import * as
|
|
5479
|
+
import * as fs12 from "fs";
|
|
5398
5480
|
var { chain: chain7 } = import_stream_chain7.default;
|
|
5399
5481
|
var { parser: parser8 } = import_stream_json7.default;
|
|
5400
5482
|
var { streamValues: streamValues7 } = import_StreamValues7.default;
|
|
@@ -5423,18 +5505,18 @@ async function* parseTelegramSingle(options2) {
|
|
|
5423
5505
|
yield { type: "progress", data: initialProgress };
|
|
5424
5506
|
onProgress?.(initialProgress);
|
|
5425
5507
|
onLog?.("info", `\u5F00\u59CB\u89E3\u6790 Telegram \u5355\u804A\u5929 JSON \u6587\u4EF6\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
|
|
5426
|
-
const chatData = await new Promise((
|
|
5427
|
-
const readStream =
|
|
5508
|
+
const chatData = await new Promise((resolve4, reject) => {
|
|
5509
|
+
const readStream = fs12.createReadStream(filePath, { encoding: "utf-8" });
|
|
5428
5510
|
const pipeline2 = chain7([readStream, parser8(), streamValues7()]);
|
|
5429
5511
|
let found = false;
|
|
5430
5512
|
pipeline2.on("data", ({ value }) => {
|
|
5431
5513
|
if (!found) {
|
|
5432
5514
|
found = true;
|
|
5433
|
-
|
|
5515
|
+
resolve4(value);
|
|
5434
5516
|
}
|
|
5435
5517
|
});
|
|
5436
5518
|
pipeline2.on("end", () => {
|
|
5437
|
-
if (!found)
|
|
5519
|
+
if (!found) resolve4(null);
|
|
5438
5520
|
});
|
|
5439
5521
|
pipeline2.on("error", reject);
|
|
5440
5522
|
});
|
|
@@ -5522,11 +5604,11 @@ var module_9 = {
|
|
|
5522
5604
|
var telegram_native_single_default = module_9;
|
|
5523
5605
|
|
|
5524
5606
|
// ../../packages/parser/src/formats/whatsapp-native-txt.ts
|
|
5525
|
-
import * as
|
|
5526
|
-
import * as
|
|
5607
|
+
import * as fs13 from "fs";
|
|
5608
|
+
import * as path9 from "path";
|
|
5527
5609
|
import * as readline3 from "readline";
|
|
5528
5610
|
function extractNameFromFilePath5(filePath) {
|
|
5529
|
-
const basename13 =
|
|
5611
|
+
const basename13 = path9.basename(filePath);
|
|
5530
5612
|
const matchZhCn = basename13.match(/^与(.+?)的\s*WhatsApp\s*聊天\.txt$/i);
|
|
5531
5613
|
if (matchZhCn) return matchZhCn[1].trim();
|
|
5532
5614
|
const matchZhTw = basename13.match(/^與(.+?)的\s*WhatsApp\s*對話\.txt$/i);
|
|
@@ -5534,7 +5616,7 @@ function extractNameFromFilePath5(filePath) {
|
|
|
5534
5616
|
return basename13.replace(/\.txt$/i, "") || "\u672A\u77E5\u804A\u5929";
|
|
5535
5617
|
}
|
|
5536
5618
|
function shouldInferPrivateChatName(filePath, fallbackName) {
|
|
5537
|
-
const basename13 =
|
|
5619
|
+
const basename13 = path9.basename(filePath);
|
|
5538
5620
|
return /^_chat\.txt$/i.test(basename13) || /^whatsapp(?:[-_\s].*)?$/i.test(fallbackName);
|
|
5539
5621
|
}
|
|
5540
5622
|
function inferPrivateChatName(memberMap, fallbackName) {
|
|
@@ -5713,7 +5795,7 @@ async function* parseWhatsApp(options2) {
|
|
|
5713
5795
|
messagesProcessed++;
|
|
5714
5796
|
}
|
|
5715
5797
|
};
|
|
5716
|
-
const fileStream =
|
|
5798
|
+
const fileStream = fs13.createReadStream(filePath, { encoding: "utf-8" });
|
|
5717
5799
|
const rl = readline3.createInterface({
|
|
5718
5800
|
input: fileStream,
|
|
5719
5801
|
crlfDelay: Infinity
|
|
@@ -5834,11 +5916,11 @@ var module_10 = {
|
|
|
5834
5916
|
var whatsapp_native_txt_default = module_10;
|
|
5835
5917
|
|
|
5836
5918
|
// ../../packages/parser/src/formats/qq-native-txt.ts
|
|
5837
|
-
import * as
|
|
5838
|
-
import * as
|
|
5919
|
+
import * as fs14 from "fs";
|
|
5920
|
+
import * as path10 from "path";
|
|
5839
5921
|
import * as readline4 from "readline";
|
|
5840
5922
|
function extractNameFromFilePath6(filePath) {
|
|
5841
|
-
const basename13 =
|
|
5923
|
+
const basename13 = path10.basename(filePath);
|
|
5842
5924
|
const name = basename13.replace(/\.txt$/i, "");
|
|
5843
5925
|
return name || "\u672A\u77E5\u7FA4\u804A";
|
|
5844
5926
|
}
|
|
@@ -5920,7 +6002,7 @@ async function* parseTxt(options2) {
|
|
|
5920
6002
|
messagesProcessed++;
|
|
5921
6003
|
}
|
|
5922
6004
|
};
|
|
5923
|
-
const fileStream =
|
|
6005
|
+
const fileStream = fs14.createReadStream(filePath, { encoding: "utf-8" });
|
|
5924
6006
|
const rl = readline4.createInterface({
|
|
5925
6007
|
input: fileStream,
|
|
5926
6008
|
crlfDelay: Infinity
|
|
@@ -6020,8 +6102,8 @@ var module_11 = {
|
|
|
6020
6102
|
var qq_native_txt_default = module_11;
|
|
6021
6103
|
|
|
6022
6104
|
// ../../packages/parser/src/formats/instagram-native.ts
|
|
6023
|
-
import * as
|
|
6024
|
-
import * as
|
|
6105
|
+
import * as fs15 from "fs";
|
|
6106
|
+
import * as path11 from "path";
|
|
6025
6107
|
var feature12 = {
|
|
6026
6108
|
id: "instagram-native",
|
|
6027
6109
|
name: "Instagram \u5B98\u65B9\u5BFC\u51FA",
|
|
@@ -6047,7 +6129,7 @@ function decodeInstagramText(text) {
|
|
|
6047
6129
|
}
|
|
6048
6130
|
}
|
|
6049
6131
|
function extractNameFromFilePath7(filePath) {
|
|
6050
|
-
const basename13 =
|
|
6132
|
+
const basename13 = path11.basename(filePath);
|
|
6051
6133
|
return basename13.replace(/\.json$/i, "") || "\u672A\u77E5\u5BF9\u8BDD";
|
|
6052
6134
|
}
|
|
6053
6135
|
function isSystemMessage2(content) {
|
|
@@ -6116,7 +6198,7 @@ async function* parseInstagram(options2) {
|
|
|
6116
6198
|
onLog?.("info", `\u5F00\u59CB\u89E3\u6790 Instagram \u804A\u5929\u8BB0\u5F55\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
|
|
6117
6199
|
let data;
|
|
6118
6200
|
try {
|
|
6119
|
-
const content =
|
|
6201
|
+
const content = fs15.readFileSync(filePath, "utf-8");
|
|
6120
6202
|
data = JSON.parse(content);
|
|
6121
6203
|
} catch (error) {
|
|
6122
6204
|
const err = new Error(`\u65E0\u6CD5\u89E3\u6790 Instagram JSON \u6587\u4EF6: ${error}`);
|
|
@@ -6211,8 +6293,8 @@ var import_stream_chain8 = __toESM(require_stream_chain(), 1);
|
|
|
6211
6293
|
var import_stream_json8 = __toESM(require_stream_json(), 1);
|
|
6212
6294
|
var import_Pick7 = __toESM(require_Pick(), 1);
|
|
6213
6295
|
var import_StreamValues8 = __toESM(require_StreamValues(), 1);
|
|
6214
|
-
import * as
|
|
6215
|
-
import * as
|
|
6296
|
+
import * as fs16 from "fs";
|
|
6297
|
+
import * as path12 from "path";
|
|
6216
6298
|
var { chain: chain8 } = import_stream_chain8.default;
|
|
6217
6299
|
var { parser: parser9 } = import_stream_json8.default;
|
|
6218
6300
|
var { pick: pick7 } = import_Pick7.default;
|
|
@@ -6295,12 +6377,12 @@ function normalizeIdentity(user) {
|
|
|
6295
6377
|
};
|
|
6296
6378
|
}
|
|
6297
6379
|
function readJson(filePath) {
|
|
6298
|
-
return JSON.parse(
|
|
6380
|
+
return JSON.parse(fs16.readFileSync(filePath, "utf8"));
|
|
6299
6381
|
}
|
|
6300
6382
|
function resolveManifestFile(manifestDir, relativePath) {
|
|
6301
|
-
const resolved =
|
|
6302
|
-
const relative2 =
|
|
6303
|
-
if (relative2.startsWith("..") ||
|
|
6383
|
+
const resolved = path12.resolve(manifestDir, relativePath);
|
|
6384
|
+
const relative2 = path12.relative(manifestDir, resolved);
|
|
6385
|
+
if (relative2.startsWith("..") || path12.isAbsolute(relative2)) {
|
|
6304
6386
|
throw new Error(`Google Chat manifest path escapes its directory: ${relativePath}`);
|
|
6305
6387
|
}
|
|
6306
6388
|
return resolved;
|
|
@@ -6313,7 +6395,7 @@ function readManifest2(filePath) {
|
|
|
6313
6395
|
if (manifest.chatType !== "private" && manifest.chatType !== "group") {
|
|
6314
6396
|
throw new Error("Invalid Google Chat chat type");
|
|
6315
6397
|
}
|
|
6316
|
-
const manifestDir =
|
|
6398
|
+
const manifestDir = path12.dirname(filePath);
|
|
6317
6399
|
return {
|
|
6318
6400
|
manifest,
|
|
6319
6401
|
userInfoPath: resolveManifestFile(manifestDir, manifest.userInfoFile),
|
|
@@ -6391,7 +6473,7 @@ async function* parseGoogleChat(options2) {
|
|
|
6391
6473
|
});
|
|
6392
6474
|
}
|
|
6393
6475
|
yield { type: "members", data: Array.from(memberMap.values()) };
|
|
6394
|
-
const readStream =
|
|
6476
|
+
const readStream = fs16.createReadStream(messagesPath, { encoding: "utf8" });
|
|
6395
6477
|
let bytesRead = 0;
|
|
6396
6478
|
let messagesProcessed = 0;
|
|
6397
6479
|
readStream.on("data", (chunk) => {
|
|
@@ -6444,8 +6526,8 @@ var module_13 = {
|
|
|
6444
6526
|
var google_chat_takeout_default = module_13;
|
|
6445
6527
|
|
|
6446
6528
|
// ../../packages/parser/src/formats/line-native-txt.ts
|
|
6447
|
-
import * as
|
|
6448
|
-
import * as
|
|
6529
|
+
import * as fs17 from "fs";
|
|
6530
|
+
import * as path13 from "path";
|
|
6449
6531
|
var feature14 = {
|
|
6450
6532
|
id: "line-native-txt",
|
|
6451
6533
|
name: "LINE \u5B98\u65B9\u5BFC\u51FA TXT",
|
|
@@ -6473,7 +6555,7 @@ var feature14 = {
|
|
|
6473
6555
|
}
|
|
6474
6556
|
};
|
|
6475
6557
|
function extractNameFromFilePath8(filePath) {
|
|
6476
|
-
const basename13 =
|
|
6558
|
+
const basename13 = path13.basename(filePath, ".txt");
|
|
6477
6559
|
const name = basename13.replace(/^\[LINE\]\s*/i, "").trim();
|
|
6478
6560
|
return name || "\u672A\u77E5\u804A\u5929";
|
|
6479
6561
|
}
|
|
@@ -6653,7 +6735,7 @@ async function* parseLINE(options2) {
|
|
|
6653
6735
|
yield { type: "progress", data: initialProgress };
|
|
6654
6736
|
onProgress?.(initialProgress);
|
|
6655
6737
|
onLog?.("info", `\u5F00\u59CB\u89E3\u6790 LINE \u5BFC\u51FA\u6587\u4EF6\uFF0C\u5927\u5C0F: ${(totalBytes / 1024 / 1024).toFixed(2)} MB`);
|
|
6656
|
-
const content =
|
|
6738
|
+
const content = fs17.readFileSync(filePath, "utf-8");
|
|
6657
6739
|
const lines = content.split("\n").map((line) => line.replace(/\r$/, ""));
|
|
6658
6740
|
let currentDate = null;
|
|
6659
6741
|
let chatName = extractNameFromFilePath8(filePath);
|
|
@@ -6957,24 +7039,27 @@ async function* parseFileWithFormat(formatId, options2) {
|
|
|
6957
7039
|
yield* parser11.parse(options2);
|
|
6958
7040
|
}
|
|
6959
7041
|
function findEntryFileInDirectory(dirPath, maxDepth = 1) {
|
|
7042
|
+
const supportedExtensions = new Set(
|
|
7043
|
+
sniffer.getSupportedFormats().flatMap((feature15) => feature15.extensions).map((extension) => extension.toLowerCase())
|
|
7044
|
+
);
|
|
6960
7045
|
function walk(current, depth) {
|
|
6961
7046
|
if (depth > maxDepth) return null;
|
|
6962
7047
|
let entries;
|
|
6963
7048
|
try {
|
|
6964
|
-
entries =
|
|
7049
|
+
entries = fs18.readdirSync(current, { withFileTypes: true });
|
|
6965
7050
|
} catch {
|
|
6966
7051
|
return null;
|
|
6967
7052
|
}
|
|
6968
7053
|
for (const entry of entries) {
|
|
6969
|
-
const full =
|
|
6970
|
-
if (entry.isFile() && entry.name.
|
|
7054
|
+
const full = path14.join(current, entry.name);
|
|
7055
|
+
if (entry.isFile() && supportedExtensions.has(path14.extname(entry.name).toLowerCase())) {
|
|
6971
7056
|
const format = detectFormat(full);
|
|
6972
7057
|
if (format) return full;
|
|
6973
7058
|
}
|
|
6974
7059
|
}
|
|
6975
7060
|
for (const entry of entries) {
|
|
6976
7061
|
if (entry.isDirectory()) {
|
|
6977
|
-
const found = walk(
|
|
7062
|
+
const found = walk(path14.join(current, entry.name), depth + 1);
|
|
6978
7063
|
if (found) return found;
|
|
6979
7064
|
}
|
|
6980
7065
|
}
|
|
@@ -7023,8 +7108,8 @@ function logNativeParserStatus() {
|
|
|
7023
7108
|
}
|
|
7024
7109
|
|
|
7025
7110
|
// ../../packages/node-runtime/src/import/perf-logger.ts
|
|
7026
|
-
import * as
|
|
7027
|
-
import * as
|
|
7111
|
+
import * as fs19 from "fs";
|
|
7112
|
+
import * as path15 from "path";
|
|
7028
7113
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
7029
7114
|
LogLevel2["ERROR"] = "ERROR";
|
|
7030
7115
|
LogLevel2["INFO"] = "INFO";
|
|
@@ -7036,11 +7121,11 @@ var currentLogFile = null;
|
|
|
7036
7121
|
var errorCount = 0;
|
|
7037
7122
|
function initPerfLog(sessionId, logDir) {
|
|
7038
7123
|
try {
|
|
7039
|
-
if (!
|
|
7040
|
-
|
|
7124
|
+
if (!fs19.existsSync(logDir)) {
|
|
7125
|
+
fs19.mkdirSync(logDir, { recursive: true });
|
|
7041
7126
|
}
|
|
7042
|
-
currentLogFile =
|
|
7043
|
-
|
|
7127
|
+
currentLogFile = path15.join(logDir, `import_${sessionId}_${Date.now()}.log`);
|
|
7128
|
+
fs19.writeFileSync(currentLogFile, `=== Import Log ===
|
|
7044
7129
|
Start time: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
7045
7130
|
|
|
7046
7131
|
`, "utf-8");
|
|
@@ -7061,7 +7146,7 @@ function logPerf(event, messagesProcessed, batchSize) {
|
|
|
7061
7146
|
const logLine = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${event} | messages: ${messagesProcessed.toLocaleString()} | elapsed: ${duration}ms | speed: ${speed.toLocaleString()}/s | memory: ${memory}MB` + (batchSize ? ` | batch: ${batchSize}` : "") + "\n";
|
|
7062
7147
|
if (currentLogFile) {
|
|
7063
7148
|
try {
|
|
7064
|
-
|
|
7149
|
+
fs19.appendFileSync(currentLogFile, logLine, "utf-8");
|
|
7065
7150
|
} catch {
|
|
7066
7151
|
}
|
|
7067
7152
|
}
|
|
@@ -7071,7 +7156,7 @@ function logPerf(event, messagesProcessed, batchSize) {
|
|
|
7071
7156
|
function logPerfDetail(detail) {
|
|
7072
7157
|
if (currentLogFile) {
|
|
7073
7158
|
try {
|
|
7074
|
-
|
|
7159
|
+
fs19.appendFileSync(currentLogFile, ` ${detail}
|
|
7075
7160
|
`, "utf-8");
|
|
7076
7161
|
} catch {
|
|
7077
7162
|
}
|
|
@@ -7091,7 +7176,7 @@ function writeLogLine(level, message) {
|
|
|
7091
7176
|
const logLine = `[${(/* @__PURE__ */ new Date()).toISOString()}] [${level}] ${message}
|
|
7092
7177
|
`;
|
|
7093
7178
|
try {
|
|
7094
|
-
|
|
7179
|
+
fs19.appendFileSync(currentLogFile, logLine, "utf-8");
|
|
7095
7180
|
} catch {
|
|
7096
7181
|
}
|
|
7097
7182
|
}
|
|
@@ -7116,7 +7201,7 @@ Total members: ${totalMembers.toLocaleString()}
|
|
|
7116
7201
|
Errors: ${errorCount}
|
|
7117
7202
|
`;
|
|
7118
7203
|
try {
|
|
7119
|
-
|
|
7204
|
+
fs19.appendFileSync(currentLogFile, summary, "utf-8");
|
|
7120
7205
|
} catch {
|
|
7121
7206
|
}
|
|
7122
7207
|
}
|
|
@@ -7215,8 +7300,8 @@ function segmentText(text, locale, minLength) {
|
|
|
7215
7300
|
}
|
|
7216
7301
|
|
|
7217
7302
|
// ../../packages/node-runtime/src/nlp/dict-manager.ts
|
|
7218
|
-
import * as
|
|
7219
|
-
import * as
|
|
7303
|
+
import * as fs20 from "fs";
|
|
7304
|
+
import * as path16 from "path";
|
|
7220
7305
|
import { createHash } from "crypto";
|
|
7221
7306
|
var DICT_DOWNLOAD_URL_BASE = "https://chatlab.fun/assets/nlp";
|
|
7222
7307
|
var DICT_SHA256 = {
|
|
@@ -7228,19 +7313,19 @@ var AVAILABLE_DICTS = [
|
|
|
7228
7313
|
{ id: "zh-TW", label: "\u7E41\u9AD4\u4E2D\u6587", locale: "zh-TW" }
|
|
7229
7314
|
];
|
|
7230
7315
|
function getDictFilePath(nlpDir, dictId) {
|
|
7231
|
-
return
|
|
7316
|
+
return path16.join(nlpDir, `${dictId}.dict`);
|
|
7232
7317
|
}
|
|
7233
7318
|
function isDictDownloaded(nlpDir, dictId) {
|
|
7234
|
-
return
|
|
7319
|
+
return fs20.existsSync(getDictFilePath(nlpDir, dictId));
|
|
7235
7320
|
}
|
|
7236
7321
|
function getDictList(nlpDir) {
|
|
7237
7322
|
return AVAILABLE_DICTS.map((d) => {
|
|
7238
7323
|
const filePath = getDictFilePath(nlpDir, d.id);
|
|
7239
|
-
const downloaded =
|
|
7324
|
+
const downloaded = fs20.existsSync(filePath);
|
|
7240
7325
|
let fileSize;
|
|
7241
7326
|
if (downloaded) {
|
|
7242
7327
|
try {
|
|
7243
|
-
fileSize =
|
|
7328
|
+
fileSize = fs20.statSync(filePath).size;
|
|
7244
7329
|
} catch {
|
|
7245
7330
|
}
|
|
7246
7331
|
}
|
|
@@ -7249,9 +7334,9 @@ function getDictList(nlpDir) {
|
|
|
7249
7334
|
}
|
|
7250
7335
|
function loadDictBuffer(nlpDir, dictId) {
|
|
7251
7336
|
const filePath = getDictFilePath(nlpDir, dictId);
|
|
7252
|
-
if (!
|
|
7337
|
+
if (!fs20.existsSync(filePath)) return null;
|
|
7253
7338
|
try {
|
|
7254
|
-
return
|
|
7339
|
+
return fs20.readFileSync(filePath);
|
|
7255
7340
|
} catch (error) {
|
|
7256
7341
|
console.error(`[NLP DictManager] Failed to read dict file: ${filePath}`, error);
|
|
7257
7342
|
return null;
|
|
@@ -7261,7 +7346,7 @@ async function downloadDict(nlpDir, dictId, onProgress) {
|
|
|
7261
7346
|
if (!AVAILABLE_DICTS.find((d) => d.id === dictId)) {
|
|
7262
7347
|
return { success: false, error: `Unknown dict: ${dictId}` };
|
|
7263
7348
|
}
|
|
7264
|
-
|
|
7349
|
+
fs20.mkdirSync(nlpDir, { recursive: true });
|
|
7265
7350
|
const url = `${DICT_DOWNLOAD_URL_BASE}/${dictId}.dict`;
|
|
7266
7351
|
const filePath = getDictFilePath(nlpDir, dictId);
|
|
7267
7352
|
const tmpPath = filePath + ".tmp";
|
|
@@ -7302,16 +7387,16 @@ async function downloadDict(nlpDir, dictId, onProgress) {
|
|
|
7302
7387
|
if (actualSha256 !== expectedSha256) {
|
|
7303
7388
|
return { success: false, error: "Dictionary integrity check failed (SHA256 mismatch)" };
|
|
7304
7389
|
}
|
|
7305
|
-
|
|
7306
|
-
if (
|
|
7307
|
-
|
|
7390
|
+
fs20.writeFileSync(tmpPath, buffer);
|
|
7391
|
+
if (fs20.existsSync(filePath)) fs20.unlinkSync(filePath);
|
|
7392
|
+
fs20.renameSync(tmpPath, filePath);
|
|
7308
7393
|
clearJiebaInstance(dictId);
|
|
7309
|
-
console.log(`[NLP DictManager] Dict downloaded: ${dictId} (${
|
|
7394
|
+
console.log(`[NLP DictManager] Dict downloaded: ${dictId} (${fs20.statSync(filePath).size} bytes)`);
|
|
7310
7395
|
return { success: true };
|
|
7311
7396
|
} catch (error) {
|
|
7312
|
-
if (
|
|
7397
|
+
if (fs20.existsSync(tmpPath)) {
|
|
7313
7398
|
try {
|
|
7314
|
-
|
|
7399
|
+
fs20.unlinkSync(tmpPath);
|
|
7315
7400
|
} catch {
|
|
7316
7401
|
}
|
|
7317
7402
|
}
|
|
@@ -7322,9 +7407,9 @@ async function downloadDict(nlpDir, dictId, onProgress) {
|
|
|
7322
7407
|
}
|
|
7323
7408
|
function deleteDict(nlpDir, dictId) {
|
|
7324
7409
|
const filePath = getDictFilePath(nlpDir, dictId);
|
|
7325
|
-
if (!
|
|
7410
|
+
if (!fs20.existsSync(filePath)) return { success: true };
|
|
7326
7411
|
try {
|
|
7327
|
-
|
|
7412
|
+
fs20.unlinkSync(filePath);
|
|
7328
7413
|
clearJiebaInstance(dictId);
|
|
7329
7414
|
console.log(`[NLP DictManager] Dict deleted: ${dictId}`);
|
|
7330
7415
|
return { success: true };
|
|
@@ -7424,7 +7509,7 @@ function searchByFts(db, keywords, limit = 1e3, offset = 0) {
|
|
|
7424
7509
|
}
|
|
7425
7510
|
|
|
7426
7511
|
// ../../packages/node-runtime/src/import/streaming-importer.ts
|
|
7427
|
-
import * as
|
|
7512
|
+
import * as fs21 from "fs";
|
|
7428
7513
|
|
|
7429
7514
|
// ../../packages/node-runtime/src/import/message-deduplicator.ts
|
|
7430
7515
|
function generateFallbackMessageKey(message) {
|
|
@@ -7456,7 +7541,7 @@ function registerMessageAndCheckDuplicate(message, state) {
|
|
|
7456
7541
|
// ../../packages/node-runtime/src/import/streaming-importer.ts
|
|
7457
7542
|
var BATCH_COMMIT_SIZE = 5e4;
|
|
7458
7543
|
var CHECKPOINT_INTERVAL = 2e5;
|
|
7459
|
-
var yieldToEventLoop = () => new Promise((
|
|
7544
|
+
var yieldToEventLoop = () => new Promise((resolve4) => setImmediate(resolve4));
|
|
7460
7545
|
function defaultGenerateSessionId() {
|
|
7461
7546
|
const ts = Date.now();
|
|
7462
7547
|
const rand = Math.random().toString(36).substring(2, 8);
|
|
@@ -7959,7 +8044,7 @@ async function streamParseFileInfo(filePath, deps) {
|
|
|
7959
8044
|
if (!formatFeature) {
|
|
7960
8045
|
throw new Error("Unrecognized file format");
|
|
7961
8046
|
}
|
|
7962
|
-
const fileSize =
|
|
8047
|
+
const fileSize = fs21.statSync(filePath).size;
|
|
7963
8048
|
deps.onProgress({
|
|
7964
8049
|
stage: "parsing",
|
|
7965
8050
|
bytesRead: 0,
|
|
@@ -8048,7 +8133,7 @@ async function streamParseFileInfo(filePath, deps) {
|
|
|
8048
8133
|
}
|
|
8049
8134
|
db.close();
|
|
8050
8135
|
try {
|
|
8051
|
-
if (
|
|
8136
|
+
if (fs21.existsSync(tempDbPath)) fs21.unlinkSync(tempDbPath);
|
|
8052
8137
|
} catch {
|
|
8053
8138
|
}
|
|
8054
8139
|
throw error;
|
|
@@ -8693,8 +8778,8 @@ async function analyzeAutoImportFile(filePath, deps, options2 = {}) {
|
|
|
8693
8778
|
}
|
|
8694
8779
|
|
|
8695
8780
|
// ../../packages/node-runtime/src/import/import-lock.ts
|
|
8696
|
-
import * as
|
|
8697
|
-
import * as
|
|
8781
|
+
import * as fs22 from "fs";
|
|
8782
|
+
import * as path17 from "path";
|
|
8698
8783
|
import { randomUUID } from "crypto";
|
|
8699
8784
|
var IMPORT_LOCK_FILENAME = ".chatlab-import.lock";
|
|
8700
8785
|
var IMPORT_IN_PROGRESS_ERROR_KEY = "error.import_in_progress";
|
|
@@ -8708,7 +8793,7 @@ var ImportInProgressError = class extends Error {
|
|
|
8708
8793
|
};
|
|
8709
8794
|
function parseOwner(lockPath) {
|
|
8710
8795
|
try {
|
|
8711
|
-
const parsed = JSON.parse(
|
|
8796
|
+
const parsed = JSON.parse(fs22.readFileSync(lockPath, "utf-8"));
|
|
8712
8797
|
if (typeof parsed.pid !== "number" || !Number.isInteger(parsed.pid) || parsed.pid <= 0 || typeof parsed.token !== "string" || parsed.token.length === 0 || typeof parsed.startedAt !== "number") {
|
|
8713
8798
|
return null;
|
|
8714
8799
|
}
|
|
@@ -8731,13 +8816,13 @@ function removeStaleLock(lockPath) {
|
|
|
8731
8816
|
if (isProcessRunning(owner.pid)) return false;
|
|
8732
8817
|
} else {
|
|
8733
8818
|
try {
|
|
8734
|
-
if (Date.now() -
|
|
8819
|
+
if (Date.now() - fs22.statSync(lockPath).mtimeMs < 5e3) return false;
|
|
8735
8820
|
} catch {
|
|
8736
8821
|
return true;
|
|
8737
8822
|
}
|
|
8738
8823
|
}
|
|
8739
8824
|
try {
|
|
8740
|
-
|
|
8825
|
+
fs22.unlinkSync(lockPath);
|
|
8741
8826
|
appLogger.warn("import-lock", "Removed stale import lock", { ownerPid: owner?.pid });
|
|
8742
8827
|
return true;
|
|
8743
8828
|
} catch {
|
|
@@ -8746,7 +8831,7 @@ function removeStaleLock(lockPath) {
|
|
|
8746
8831
|
}
|
|
8747
8832
|
function releaseLock(lockPath, fd, owner) {
|
|
8748
8833
|
try {
|
|
8749
|
-
|
|
8834
|
+
fs22.closeSync(fd);
|
|
8750
8835
|
} catch (error) {
|
|
8751
8836
|
appLogger.error("import-lock", "Failed to close import lock", error);
|
|
8752
8837
|
}
|
|
@@ -8755,19 +8840,19 @@ function releaseLock(lockPath, fd, owner) {
|
|
|
8755
8840
|
appLogger.warn("import-lock", "Import lock ownership changed before release");
|
|
8756
8841
|
return;
|
|
8757
8842
|
}
|
|
8758
|
-
|
|
8843
|
+
fs22.unlinkSync(lockPath);
|
|
8759
8844
|
appLogger.info("import-lock", "Import lock released");
|
|
8760
8845
|
} catch (error) {
|
|
8761
8846
|
appLogger.error("import-lock", "Failed to release import lock", error);
|
|
8762
8847
|
}
|
|
8763
8848
|
}
|
|
8764
8849
|
async function withDataDirImportLock(userDataDir, task) {
|
|
8765
|
-
|
|
8766
|
-
const lockPath =
|
|
8850
|
+
fs22.mkdirSync(userDataDir, { recursive: true });
|
|
8851
|
+
const lockPath = path17.join(userDataDir, IMPORT_LOCK_FILENAME);
|
|
8767
8852
|
let fd = null;
|
|
8768
8853
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
8769
8854
|
try {
|
|
8770
|
-
fd =
|
|
8855
|
+
fd = fs22.openSync(lockPath, "wx");
|
|
8771
8856
|
break;
|
|
8772
8857
|
} catch (error) {
|
|
8773
8858
|
const code = error.code;
|
|
@@ -8786,8 +8871,8 @@ async function withDataDirImportLock(userDataDir, task) {
|
|
|
8786
8871
|
startedAt: Date.now()
|
|
8787
8872
|
};
|
|
8788
8873
|
try {
|
|
8789
|
-
|
|
8790
|
-
|
|
8874
|
+
fs22.writeFileSync(fd, JSON.stringify(owner), "utf-8");
|
|
8875
|
+
fs22.fsyncSync(fd);
|
|
8791
8876
|
appLogger.info("import-lock", "Import lock acquired");
|
|
8792
8877
|
return await task();
|
|
8793
8878
|
} finally {
|
|
@@ -8807,8 +8892,8 @@ var ArchiveImportError = class extends Error {
|
|
|
8807
8892
|
|
|
8808
8893
|
// ../../packages/node-runtime/src/import/archive/archive-reader.ts
|
|
8809
8894
|
var import_yauzl = __toESM(require_yauzl(), 1);
|
|
8810
|
-
import * as
|
|
8811
|
-
import * as
|
|
8895
|
+
import * as fs23 from "fs";
|
|
8896
|
+
import * as path18 from "path";
|
|
8812
8897
|
import { pipeline } from "stream/promises";
|
|
8813
8898
|
var DEFAULT_MAX_ENTRIES = 1e5;
|
|
8814
8899
|
var DEFAULT_MAX_ENTRY_BYTES = 20 * 1024 * 1024 * 1024;
|
|
@@ -8927,8 +9012,8 @@ var ZipArchiveReader = class {
|
|
|
8927
9012
|
await this.visitEntries(async (entry, openStream) => {
|
|
8928
9013
|
const destination = targets.get(entry.name);
|
|
8929
9014
|
if (!destination || entry.isDirectory) return;
|
|
8930
|
-
|
|
8931
|
-
await pipeline(await openStream(),
|
|
9015
|
+
fs23.mkdirSync(path18.dirname(destination), { recursive: true });
|
|
9016
|
+
await pipeline(await openStream(), fs23.createWriteStream(destination, { flags: "wx" }));
|
|
8932
9017
|
remaining.delete(entry.name);
|
|
8933
9018
|
});
|
|
8934
9019
|
if (remaining.size > 0) {
|
|
@@ -8945,8 +9030,8 @@ var import_stream_chain9 = __toESM(require_stream_chain(), 1);
|
|
|
8945
9030
|
var import_stream_json9 = __toESM(require_stream_json(), 1);
|
|
8946
9031
|
var import_Pick8 = __toESM(require_Pick(), 1);
|
|
8947
9032
|
var import_StreamValues9 = __toESM(require_StreamValues(), 1);
|
|
8948
|
-
import * as
|
|
8949
|
-
import * as
|
|
9033
|
+
import * as fs24 from "fs";
|
|
9034
|
+
import * as path19 from "path";
|
|
8950
9035
|
var { chain: chain9 } = import_stream_chain9.default;
|
|
8951
9036
|
var { parser: parser10 } = import_stream_json9.default;
|
|
8952
9037
|
var { pick: pick8 } = import_Pick8.default;
|
|
@@ -9075,16 +9160,16 @@ var GoogleChatTakeoutResolver = class {
|
|
|
9075
9160
|
`Google Chat conversation is missing required files: ${chat.chatId}`
|
|
9076
9161
|
);
|
|
9077
9162
|
}
|
|
9078
|
-
|
|
9163
|
+
fs24.mkdirSync(targetDir, { recursive: true });
|
|
9079
9164
|
await reader.pipeEntries(
|
|
9080
9165
|
/* @__PURE__ */ new Map([
|
|
9081
|
-
[userInfoEntry,
|
|
9082
|
-
[groupInfoEntry,
|
|
9083
|
-
[messagesEntry,
|
|
9166
|
+
[userInfoEntry, path19.join(targetDir, "user_info.json")],
|
|
9167
|
+
[groupInfoEntry, path19.join(targetDir, "group_info.json")],
|
|
9168
|
+
[messagesEntry, path19.join(targetDir, "messages.json")]
|
|
9084
9169
|
])
|
|
9085
9170
|
);
|
|
9086
|
-
const manifestPath =
|
|
9087
|
-
|
|
9171
|
+
const manifestPath = path19.join(targetDir, "google-chat-import.json");
|
|
9172
|
+
fs24.writeFileSync(
|
|
9088
9173
|
manifestPath,
|
|
9089
9174
|
JSON.stringify(
|
|
9090
9175
|
{
|
|
@@ -9107,8 +9192,8 @@ var GoogleChatTakeoutResolver = class {
|
|
|
9107
9192
|
};
|
|
9108
9193
|
|
|
9109
9194
|
// ../../packages/node-runtime/src/import/archive/source-manager.ts
|
|
9110
|
-
import * as
|
|
9111
|
-
import * as
|
|
9195
|
+
import * as fs25 from "fs";
|
|
9196
|
+
import * as path20 from "path";
|
|
9112
9197
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
9113
9198
|
var DEFAULT_TTL_MS = 30 * 60 * 1e3;
|
|
9114
9199
|
var ArchiveImportSourceManager = class {
|
|
@@ -9119,11 +9204,11 @@ var ArchiveImportSourceManager = class {
|
|
|
9119
9204
|
now;
|
|
9120
9205
|
resolvers;
|
|
9121
9206
|
constructor(options2 = {}) {
|
|
9122
|
-
this.tempRoot = options2.tempRoot ??
|
|
9207
|
+
this.tempRoot = options2.tempRoot ?? createChatLabTempDir("imports", "sources-");
|
|
9123
9208
|
this.ttlMs = options2.ttlMs ?? DEFAULT_TTL_MS;
|
|
9124
9209
|
this.now = options2.now ?? Date.now;
|
|
9125
9210
|
this.resolvers = options2.resolvers ?? [new GoogleChatTakeoutResolver()];
|
|
9126
|
-
|
|
9211
|
+
fs25.mkdirSync(this.tempRoot, { recursive: true });
|
|
9127
9212
|
}
|
|
9128
9213
|
prepareLocalArchive(archivePath) {
|
|
9129
9214
|
return this.prepareArchive(archivePath, false);
|
|
@@ -9180,7 +9265,7 @@ var ArchiveImportSourceManager = class {
|
|
|
9180
9265
|
`Archive conversation was not found: ${chatId}`
|
|
9181
9266
|
);
|
|
9182
9267
|
}
|
|
9183
|
-
const materializedDir =
|
|
9268
|
+
const materializedDir = fs25.mkdtempSync(path20.join(this.tempRoot, `materialized-${sourceId}-`));
|
|
9184
9269
|
try {
|
|
9185
9270
|
const reader = new ZipArchiveReader(record.archivePath);
|
|
9186
9271
|
const materialized = await record.resolver.materialize(reader, chat, materializedDir);
|
|
@@ -9231,7 +9316,7 @@ var ArchiveImportSourceManager = class {
|
|
|
9231
9316
|
}
|
|
9232
9317
|
removePath(targetPath) {
|
|
9233
9318
|
try {
|
|
9234
|
-
|
|
9319
|
+
fs25.rmSync(targetPath, { recursive: true, force: true });
|
|
9235
9320
|
} catch {
|
|
9236
9321
|
}
|
|
9237
9322
|
}
|
|
@@ -9301,12 +9386,12 @@ ${rawErrorLabel}: ${details}`;
|
|
|
9301
9386
|
}
|
|
9302
9387
|
|
|
9303
9388
|
// ../../packages/node-runtime/src/ai/assistant-parser.ts
|
|
9304
|
-
import * as
|
|
9389
|
+
import * as path21 from "path";
|
|
9305
9390
|
import matter from "gray-matter";
|
|
9306
9391
|
function parseAssistantFile(content, filePath) {
|
|
9307
9392
|
try {
|
|
9308
9393
|
const { data: fm, content: body } = matter(content);
|
|
9309
|
-
const id = fm.id ??
|
|
9394
|
+
const id = fm.id ?? path21.basename(filePath, ".md");
|
|
9310
9395
|
const name = fm.name;
|
|
9311
9396
|
if (!name) return null;
|
|
9312
9397
|
return {
|
|
@@ -9316,6 +9401,8 @@ function parseAssistantFile(content, filePath) {
|
|
|
9316
9401
|
presetQuestions: parseStringArray(fm.presetQuestions),
|
|
9317
9402
|
allowedBuiltinTools: normalizeBuiltinToolNames(parseStringArray(fm.allowedBuiltinTools)),
|
|
9318
9403
|
builtinId: typeof fm.builtinId === "string" ? fm.builtinId : void 0,
|
|
9404
|
+
builtinVersion: parsePositiveInteger(fm.builtinVersion),
|
|
9405
|
+
builtinDigest: typeof fm.builtinDigest === "string" ? fm.builtinDigest : void 0,
|
|
9319
9406
|
applicableChatTypes: parseChatTypes(fm.applicableChatTypes),
|
|
9320
9407
|
supportedLocales: parseStringArray(fm.supportedLocales)
|
|
9321
9408
|
};
|
|
@@ -9329,6 +9416,8 @@ function serializeAssistant(config) {
|
|
|
9329
9416
|
name: config.name
|
|
9330
9417
|
};
|
|
9331
9418
|
if (config.builtinId) fm.builtinId = config.builtinId;
|
|
9419
|
+
if (config.builtinVersion) fm.builtinVersion = config.builtinVersion;
|
|
9420
|
+
if (config.builtinDigest) fm.builtinDigest = config.builtinDigest;
|
|
9332
9421
|
if (config.applicableChatTypes?.length) fm.applicableChatTypes = config.applicableChatTypes;
|
|
9333
9422
|
if (config.supportedLocales?.length) fm.supportedLocales = config.supportedLocales;
|
|
9334
9423
|
if (config.allowedBuiltinTools?.length) fm.allowedBuiltinTools = normalizeBuiltinToolNames(config.allowedBuiltinTools);
|
|
@@ -9341,12 +9430,145 @@ function parseStringArray(raw) {
|
|
|
9341
9430
|
if (Array.isArray(raw)) return raw.map(String).filter(Boolean);
|
|
9342
9431
|
return [];
|
|
9343
9432
|
}
|
|
9433
|
+
function parsePositiveInteger(raw) {
|
|
9434
|
+
return typeof raw === "number" && Number.isInteger(raw) && raw > 0 ? raw : void 0;
|
|
9435
|
+
}
|
|
9344
9436
|
function parseChatTypes(raw) {
|
|
9345
9437
|
if (!Array.isArray(raw)) return void 0;
|
|
9346
9438
|
const valid = raw.filter((v) => v === "group" || v === "private");
|
|
9347
9439
|
return valid.length > 0 ? valid : void 0;
|
|
9348
9440
|
}
|
|
9349
9441
|
|
|
9442
|
+
// ../../packages/node-runtime/src/ai/default-assistants.ts
|
|
9443
|
+
var ALL_ANALYSIS_TOOL_NAMES = BUILTIN_TOOL_CATALOG.filter((tool) => tool.category === "analysis").map(
|
|
9444
|
+
(tool) => tool.name
|
|
9445
|
+
);
|
|
9446
|
+
var DEFAULT_GENERAL_ASSISTANT_CONFIGS = [
|
|
9447
|
+
{
|
|
9448
|
+
id: "general_cn",
|
|
9449
|
+
name: "\u901A\u7528\u5206\u6790\u52A9\u624B",
|
|
9450
|
+
builtinVersion: 2,
|
|
9451
|
+
supportedLocales: ["zh-CN"],
|
|
9452
|
+
allowedBuiltinTools: [...ALL_ANALYSIS_TOOL_NAMES],
|
|
9453
|
+
presetQuestions: [
|
|
9454
|
+
"\u6700\u8FD1\u90FD\u5728\u804A\u4EC0\u4E48\uFF1F",
|
|
9455
|
+
"\u8C01\u662F\u6700\u6D3B\u8DC3\u7684\u4EBA\uFF1F",
|
|
9456
|
+
"\u804A\u5929\u7684\u6D3B\u8DC3\u65F6\u95F4\u662F\u4EC0\u4E48\u65F6\u5019\uFF1F",
|
|
9457
|
+
"\u5E2E\u6211\u641C\u7D22\u5173\u4E8E\u300C\u65C5\u6E38\u300D\u7684\u804A\u5929\u8BB0\u5F55",
|
|
9458
|
+
"\u5206\u6790\u4E00\u4E0B\u804A\u5929\u6D3B\u8DC3\u65F6\u95F4\u6BB5"
|
|
9459
|
+
],
|
|
9460
|
+
systemPrompt: `\u4F60\u662F ChatLab \u91CC\u7684\u804A\u5929\u8BB0\u5F55\u5206\u6790\u642D\u6863\u3002\u4F60\u64C5\u957F\u4ECE\u7FA4\u804A\u6216\u79C1\u804A\u8BB0\u5F55\u4E2D\u68B3\u7406\u4E8B\u5B9E\u3001\u65F6\u95F4\u7EBF\u3001\u8BDD\u9898\u53D8\u5316\u3001\u4E92\u52A8\u65B9\u5F0F\u548C\u503C\u5F97\u6CE8\u610F\u7684\u6A21\u5F0F\uFF0C\u5E2E\u52A9\u7528\u6237\u66F4\u6E05\u695A\u5730\u7406\u89E3\u4E00\u6BB5\u5BF9\u8BDD\uFF0C\u800C\u4E0D\u662F\u673A\u68B0\u5730\u751F\u6210\u5206\u6790\u62A5\u544A\u3002
|
|
9461
|
+
|
|
9462
|
+
## \u4EA4\u6D41\u65B9\u5F0F
|
|
9463
|
+
|
|
9464
|
+
- \u8DDF\u968F\u7528\u6237\u4F7F\u7528\u7684\u8BED\u8A00\u548C\u4EA4\u6D41\u65B9\u5F0F\uFF0C\u8BF4\u81EA\u7136\u3001\u76F4\u63A5\u7684\u4EBA\u8BDD\uFF0C\u907F\u514D\u5BA2\u670D\u8154\u548C\u8FC7\u5EA6\u6B63\u5F0F\u7684\u8868\u8FBE\u3002
|
|
9465
|
+
- \u7B80\u5355\u95EE\u9898\u76F4\u63A5\u56DE\u7B54\uFF1B\u590D\u6742\u95EE\u9898\u518D\u5206\u5C42\u8BF4\u660E\u3002\u53EA\u6709\u786E\u5B9E\u6709\u52A9\u4E8E\u7406\u89E3\u65F6\uFF0C\u624D\u4F7F\u7528\u6807\u9898\u3001\u5217\u8868\u6216\u8868\u683C\u3002
|
|
9466
|
+
- \u5728\u8BC1\u636E\u5141\u8BB8\u65F6\u7ED9\u51FA\u660E\u786E\u5224\u65AD\uFF0C\u4E0D\u4E3A\u4E86\u663E\u5F97\u4E2D\u7ACB\u800C\u53EA\u7F57\u5217\u53EF\u80FD\u6027\uFF1B\u65E0\u6CD5\u786E\u8BA4\u7684\u90E8\u5206\u8981\u5766\u7387\u8BF4\u660E\u3002
|
|
9467
|
+
- \u8BED\u6C14\u53EF\u4EE5\u8F7B\u677E\u3001\u6709\u4E00\u70B9\u81EA\u7136\u7684\u5E7D\u9ED8\u611F\uFF0C\u4F46\u4E0D\u8981\u4E3A\u4E86\u6D3B\u8DC3\u6C14\u6C1B\u5F3A\u884C\u73A9\u6897\u3001\u5806\u8868\u60C5\u6216\u727A\u7272\u51C6\u786E\u6027\u3002
|
|
9468
|
+
|
|
9469
|
+
## \u5206\u6790\u8FB9\u754C
|
|
9470
|
+
|
|
9471
|
+
- \u660E\u786E\u533A\u5206\u804A\u5929\u8BB0\u5F55\u4E2D\u80FD\u591F\u786E\u8BA4\u7684\u4E8B\u5B9E\u3001\u57FA\u4E8E\u8BC1\u636E\u4F5C\u51FA\u7684\u63A8\u65AD\uFF0C\u4EE5\u53CA\u6682\u65F6\u65E0\u6CD5\u5224\u65AD\u7684\u90E8\u5206\u3002
|
|
9472
|
+
- \u6D89\u53CA\u6027\u683C\u3001\u60C5\u7EEA\u3001\u5173\u7CFB\u548C\u52A8\u673A\u65F6\u5C24\u5176\u8C28\u614E\uFF0C\u4E0D\u66FF\u5F53\u4E8B\u4EBA\u7F16\u9020\u5FC3\u7406\u6D3B\u52A8\uFF0C\u4E5F\u4E0D\u8F7B\u6613\u7ED9\u4EBA\u8D34\u6807\u7B7E\u3002
|
|
9473
|
+
- \u53EF\u4EE5\u9002\u91CF\u5F15\u7528\u6709\u4EE3\u8868\u6027\u7684\u539F\u8BDD\u548C\u6570\u636E\u652F\u6491\u7ED3\u8BBA\uFF0C\u4F46\u4E0D\u8981\u5927\u6BB5\u5806\u780C\u804A\u5929\u8BB0\u5F55\u3002
|
|
9474
|
+
- \u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u4E0D\u8BF4\u6559\u3001\u4E0D\u64C5\u81EA\u7ED9\u4EBA\u751F\u5EFA\u8BAE\uFF0C\u4E5F\u4E0D\u628A\u6BCF\u6B21\u56DE\u7B54\u90FD\u5199\u6210\u603B\u7ED3\u62A5\u544A\u3002`
|
|
9475
|
+
},
|
|
9476
|
+
{
|
|
9477
|
+
id: "general_tw",
|
|
9478
|
+
name: "\u901A\u7528\u5206\u6790\u52A9\u624B",
|
|
9479
|
+
builtinVersion: 2,
|
|
9480
|
+
supportedLocales: ["zh-TW"],
|
|
9481
|
+
allowedBuiltinTools: [...ALL_ANALYSIS_TOOL_NAMES],
|
|
9482
|
+
presetQuestions: [
|
|
9483
|
+
"\u6700\u8FD1\u90FD\u5728\u804A\u4EC0\u9EBC\uFF1F",
|
|
9484
|
+
"\u8AB0\u662F\u6700\u6D3B\u8E8D\u7684\u4EBA\uFF1F",
|
|
9485
|
+
"\u804A\u5929\u7684\u6D3B\u8E8D\u6642\u9593\u662F\u4EC0\u9EBC\u6642\u5019\uFF1F",
|
|
9486
|
+
"\u5E6B\u6211\u641C\u5C0B\u95DC\u65BC\u300C\u65C5\u904A\u300D\u7684\u804A\u5929\u8A18\u9304",
|
|
9487
|
+
"\u5206\u6790\u4E00\u4E0B\u804A\u5929\u6D3B\u8E8D\u6642\u6BB5"
|
|
9488
|
+
],
|
|
9489
|
+
systemPrompt: `\u4F60\u662F ChatLab \u88E1\u7684\u804A\u5929\u8A18\u9304\u5206\u6790\u642D\u6A94\u3002\u4F60\u64C5\u9577\u5F9E\u7FA4\u804A\u6216\u79C1\u804A\u8A18\u9304\u4E2D\u68B3\u7406\u4E8B\u5BE6\u3001\u6642\u9593\u7DDA\u3001\u8A71\u984C\u8B8A\u5316\u3001\u4E92\u52D5\u65B9\u5F0F\u548C\u503C\u5F97\u6CE8\u610F\u7684\u6A21\u5F0F\uFF0C\u5E6B\u52A9\u4F7F\u7528\u8005\u66F4\u6E05\u695A\u5730\u7406\u89E3\u4E00\u6BB5\u5C0D\u8A71\uFF0C\u800C\u4E0D\u662F\u6A5F\u68B0\u5730\u7522\u751F\u5206\u6790\u5831\u544A\u3002
|
|
9490
|
+
|
|
9491
|
+
## \u4EA4\u6D41\u65B9\u5F0F
|
|
9492
|
+
|
|
9493
|
+
- \u8DDF\u96A8\u4F7F\u7528\u8005\u4F7F\u7528\u7684\u8A9E\u8A00\u548C\u4EA4\u6D41\u65B9\u5F0F\uFF0C\u8AAA\u81EA\u7136\u3001\u76F4\u63A5\u7684\u4EBA\u8A71\uFF0C\u907F\u514D\u5BA2\u670D\u8154\u548C\u904E\u5EA6\u6B63\u5F0F\u7684\u8868\u9054\u3002
|
|
9494
|
+
- \u7C21\u55AE\u554F\u984C\u76F4\u63A5\u56DE\u7B54\uFF1B\u8907\u96DC\u554F\u984C\u518D\u5206\u5C64\u8AAA\u660E\u3002\u53EA\u6709\u78BA\u5BE6\u6709\u52A9\u65BC\u7406\u89E3\u6642\uFF0C\u624D\u4F7F\u7528\u6A19\u984C\u3001\u5217\u8868\u6216\u8868\u683C\u3002
|
|
9495
|
+
- \u5728\u8B49\u64DA\u5141\u8A31\u6642\u7D66\u51FA\u660E\u78BA\u5224\u65B7\uFF0C\u4E0D\u70BA\u4E86\u986F\u5F97\u4E2D\u7ACB\u800C\u53EA\u7F85\u5217\u53EF\u80FD\u6027\uFF1B\u7121\u6CD5\u78BA\u8A8D\u7684\u90E8\u5206\u8981\u5766\u7387\u8AAA\u660E\u3002
|
|
9496
|
+
- \u8A9E\u6C23\u53EF\u4EE5\u8F15\u9B06\u3001\u6709\u4E00\u9EDE\u81EA\u7136\u7684\u5E7D\u9ED8\u611F\uFF0C\u4F46\u4E0D\u8981\u70BA\u4E86\u6D3B\u8E8D\u6C23\u6C1B\u5F37\u884C\u73A9\u6897\u3001\u5806\u8868\u60C5\u6216\u72A7\u7272\u6E96\u78BA\u6027\u3002
|
|
9497
|
+
|
|
9498
|
+
## \u5206\u6790\u908A\u754C
|
|
9499
|
+
|
|
9500
|
+
- \u660E\u78BA\u5340\u5206\u804A\u5929\u8A18\u9304\u4E2D\u80FD\u5920\u78BA\u8A8D\u7684\u4E8B\u5BE6\u3001\u57FA\u65BC\u8B49\u64DA\u4F5C\u51FA\u7684\u63A8\u8AD6\uFF0C\u4EE5\u53CA\u66AB\u6642\u7121\u6CD5\u5224\u65B7\u7684\u90E8\u5206\u3002
|
|
9501
|
+
- \u6D89\u53CA\u6027\u683C\u3001\u60C5\u7DD2\u3001\u95DC\u4FC2\u548C\u52D5\u6A5F\u6642\u5C24\u5176\u8B39\u614E\uFF0C\u4E0D\u66FF\u7576\u4E8B\u4EBA\u7DE8\u9020\u5FC3\u7406\u6D3B\u52D5\uFF0C\u4E5F\u4E0D\u8F15\u6613\u7D66\u4EBA\u8CBC\u6A19\u7C64\u3002
|
|
9502
|
+
- \u53EF\u4EE5\u9069\u91CF\u5F15\u7528\u6709\u4EE3\u8868\u6027\u7684\u539F\u8A71\u548C\u8CC7\u6599\u652F\u6490\u7D50\u8AD6\uFF0C\u4F46\u4E0D\u8981\u5927\u6BB5\u5806\u780C\u804A\u5929\u8A18\u9304\u3002
|
|
9503
|
+
- \u9664\u975E\u4F7F\u7528\u8005\u660E\u78BA\u8981\u6C42\uFF0C\u4E0D\u8AAA\u6559\u3001\u4E0D\u64C5\u81EA\u7D66\u4EBA\u751F\u5EFA\u8B70\uFF0C\u4E5F\u4E0D\u628A\u6BCF\u6B21\u56DE\u7B54\u90FD\u5BEB\u6210\u7E3D\u7D50\u5831\u544A\u3002`
|
|
9504
|
+
},
|
|
9505
|
+
{
|
|
9506
|
+
id: "general_en",
|
|
9507
|
+
name: "General Analysis Assistant",
|
|
9508
|
+
builtinVersion: 2,
|
|
9509
|
+
supportedLocales: ["en"],
|
|
9510
|
+
allowedBuiltinTools: [...ALL_ANALYSIS_TOOL_NAMES],
|
|
9511
|
+
presetQuestions: [
|
|
9512
|
+
"What have people been chatting about recently?",
|
|
9513
|
+
"Who are the most active members?",
|
|
9514
|
+
'Search chat records about "travel"',
|
|
9515
|
+
"Analyze the active hours of the chat"
|
|
9516
|
+
],
|
|
9517
|
+
systemPrompt: `You are ChatLab's chat analysis partner. You help users make sense of group or private chat records by clarifying facts, timelines, topic shifts, interaction patterns, and other details worth noticing. Your job is to help the user understand a conversation, not to mechanically produce an analysis report.
|
|
9518
|
+
|
|
9519
|
+
## How to Communicate
|
|
9520
|
+
|
|
9521
|
+
- Match the user's language and conversational style. Sound natural and direct, not like customer support or a formal report.
|
|
9522
|
+
- Answer simple questions directly. Add structure only for genuinely complex questions, and use headings, lists, or tables only when they improve understanding.
|
|
9523
|
+
- Give a clear judgment when the evidence supports one instead of merely listing possibilities. Be candid about anything that cannot be established.
|
|
9524
|
+
- A relaxed tone and light, natural humor are welcome, but never force jokes, emojis, or entertainment at the expense of accuracy.
|
|
9525
|
+
|
|
9526
|
+
## Analysis Boundaries
|
|
9527
|
+
|
|
9528
|
+
- Clearly distinguish what the chat records establish, what is a reasonable inference, and what remains unknown.
|
|
9529
|
+
- Be especially careful with personality, emotion, relationships, and motives. Do not invent inner states or casually label people.
|
|
9530
|
+
- Use a small number of representative quotes or data points when they support the conclusion, but do not dump large blocks of chat logs.
|
|
9531
|
+
- Unless the user asks, do not moralize, give unsolicited life advice, or turn every response into a summary report.`
|
|
9532
|
+
},
|
|
9533
|
+
{
|
|
9534
|
+
id: "general_ja",
|
|
9535
|
+
name: "\u6C4E\u7528\u5206\u6790\u30A2\u30B7\u30B9\u30BF\u30F3\u30C8",
|
|
9536
|
+
builtinVersion: 2,
|
|
9537
|
+
supportedLocales: ["ja"],
|
|
9538
|
+
allowedBuiltinTools: [...ALL_ANALYSIS_TOOL_NAMES],
|
|
9539
|
+
presetQuestions: [
|
|
9540
|
+
"\u6700\u8FD1\u307F\u3093\u306A\u4F55\u3092\u8A71\u3057\u3066\u308B\uFF1F",
|
|
9541
|
+
"\u4E00\u756A\u30A2\u30AF\u30C6\u30A3\u30D6\u306A\u30E1\u30F3\u30D0\u30FC\u306F\u8AB0\uFF1F",
|
|
9542
|
+
"\u300C\u65C5\u884C\u300D\u306B\u95A2\u3059\u308B\u30C1\u30E3\u30C3\u30C8\u8A18\u9332\u3092\u691C\u7D22\u3057\u3066",
|
|
9543
|
+
"\u30C1\u30E3\u30C3\u30C8\u306E\u6D3B\u767A\u306A\u6642\u9593\u5E2F\u3092\u5206\u6790\u3057\u3066"
|
|
9544
|
+
],
|
|
9545
|
+
systemPrompt: `\u3042\u306A\u305F\u306F ChatLab \u306E\u30C1\u30E3\u30C3\u30C8\u5206\u6790\u30D1\u30FC\u30C8\u30CA\u30FC\u3067\u3059\u3002\u30B0\u30EB\u30FC\u30D7\u30C1\u30E3\u30C3\u30C8\u3084\u500B\u4EBA\u30C1\u30E3\u30C3\u30C8\u306E\u8A18\u9332\u304B\u3089\u3001\u4E8B\u5B9F\u3001\u6642\u7CFB\u5217\u3001\u8A71\u984C\u306E\u5909\u5316\u3001\u3084\u308A\u53D6\u308A\u306E\u50BE\u5411\u3001\u6CE8\u76EE\u3059\u3079\u304D\u70B9\u3092\u6574\u7406\u3057\u3001\u6A5F\u68B0\u7684\u306A\u5206\u6790\u30EC\u30DD\u30FC\u30C8\u3067\u306F\u306A\u304F\u3001\u4F1A\u8A71\u3092\u3088\u308A\u6DF1\u304F\u7406\u89E3\u3067\u304D\u308B\u56DE\u7B54\u3092\u5C4A\u3051\u307E\u3059\u3002
|
|
9546
|
+
|
|
9547
|
+
## \u30B3\u30DF\u30E5\u30CB\u30B1\u30FC\u30B7\u30E7\u30F3
|
|
9548
|
+
|
|
9549
|
+
- \u30E6\u30FC\u30B6\u30FC\u306E\u8A00\u8A9E\u3068\u8A71\u3057\u65B9\u306B\u5408\u308F\u305B\u3001\u30AB\u30B9\u30BF\u30DE\u30FC\u30B5\u30DD\u30FC\u30C8\u3084\u5805\u3044\u5831\u544A\u66F8\u306E\u3088\u3046\u3067\u306F\u306A\u304F\u3001\u81EA\u7136\u3067\u7387\u76F4\u306A\u8A00\u8449\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
9550
|
+
- \u7C21\u5358\u306A\u8CEA\u554F\u306B\u306F\u7AEF\u7684\u306B\u7B54\u3048\u3001\u8907\u96D1\u306A\u8CEA\u554F\u3060\u3051\u3092\u6574\u7406\u3057\u3066\u8AAC\u660E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u898B\u51FA\u3057\u3001\u7B87\u6761\u66F8\u304D\u3001\u8868\u306F\u7406\u89E3\u3092\u52A9\u3051\u308B\u5834\u5408\u306B\u3060\u3051\u4F7F\u3044\u307E\u3059\u3002
|
|
9551
|
+
- \u6839\u62E0\u304C\u5341\u5206\u306A\u3089\u66D6\u6627\u306B\u53EF\u80FD\u6027\u3092\u4E26\u3079\u308B\u3060\u3051\u3067\u306A\u304F\u3001\u660E\u78BA\u306A\u5224\u65AD\u3092\u793A\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u78BA\u8A8D\u3067\u304D\u306A\u3044\u3053\u3068\u306F\u7387\u76F4\u306B\u4F1D\u3048\u307E\u3059\u3002
|
|
9552
|
+
- \u8EFD\u304F\u81EA\u7136\u306A\u30E6\u30FC\u30E2\u30A2\u306F\u69CB\u3044\u307E\u305B\u3093\u304C\u3001\u7121\u7406\u306B\u5197\u8AC7\u3084\u7D75\u6587\u5B57\u3092\u5165\u308C\u305F\u308A\u3001\u6B63\u78BA\u3055\u3092\u640D\u306A\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
9553
|
+
|
|
9554
|
+
## \u5206\u6790\u4E0A\u306E\u5883\u754C
|
|
9555
|
+
|
|
9556
|
+
- \u8A18\u9332\u304B\u3089\u78BA\u8A8D\u3067\u304D\u308B\u4E8B\u5B9F\u3001\u6839\u62E0\u306B\u57FA\u3065\u304F\u63A8\u6E2C\u3001\u73FE\u6642\u70B9\u3067\u306F\u5224\u65AD\u3067\u304D\u306A\u3044\u3053\u3068\u3092\u660E\u78BA\u306B\u533A\u5225\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
9557
|
+
- \u6027\u683C\u3001\u611F\u60C5\u3001\u4EBA\u9593\u95A2\u4FC2\u3001\u52D5\u6A5F\u306B\u3064\u3044\u3066\u306F\u7279\u306B\u614E\u91CD\u306B\u6271\u3044\u3001\u672C\u4EBA\u306E\u5185\u9762\u3092\u4F5C\u308A\u4E0A\u3052\u305F\u308A\u3001\u5B89\u6613\u306B\u30EC\u30C3\u30C6\u30EB\u3092\u8CBC\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
9558
|
+
- \u7D50\u8AD6\u3092\u652F\u3048\u308B\u5834\u5408\u306F\u4EE3\u8868\u7684\u306A\u767A\u8A00\u3084\u30C7\u30FC\u30BF\u3092\u5C11\u91CF\u5F15\u7528\u3067\u304D\u307E\u3059\u304C\u3001\u9577\u3044\u30C1\u30E3\u30C3\u30C8\u30ED\u30B0\u3092\u305D\u306E\u307E\u307E\u4E26\u3079\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
9559
|
+
- \u30E6\u30FC\u30B6\u30FC\u304C\u6C42\u3081\u306A\u3044\u9650\u308A\u3001\u8AAC\u6559\u3001\u983C\u307E\u308C\u3066\u3044\u306A\u3044\u4EBA\u751F\u76F8\u8AC7\u3001\u6BCE\u56DE\u306E\u30EC\u30DD\u30FC\u30C8\u5316\u306F\u907F\u3051\u3066\u304F\u3060\u3055\u3044\u3002`
|
|
9560
|
+
}
|
|
9561
|
+
];
|
|
9562
|
+
var DEFAULT_GENERAL_ASSISTANT_RAW_CONFIGS = DEFAULT_GENERAL_ASSISTANT_CONFIGS.map((config) => ({
|
|
9563
|
+
id: config.id,
|
|
9564
|
+
content: serializeAssistant(config)
|
|
9565
|
+
}));
|
|
9566
|
+
var LEGACY_GENERAL_ASSISTANT_DIGESTS = {
|
|
9567
|
+
general_cn: ["42989d512b8eca58839e838639f17d04413bf67c0253f7b5998f46b89ad0d330"],
|
|
9568
|
+
general_en: ["3c6d223362dfc8bc863427768090c8794e0b1f8d1ec5f17068949ad728b3f9f6"],
|
|
9569
|
+
general_ja: ["729a52d6ab4bd23f5ed5f84913b24c82e862246abc0ee70caec2244297a91d63"]
|
|
9570
|
+
};
|
|
9571
|
+
|
|
9350
9572
|
// ../../packages/node-runtime/src/ai/assistant-manager.ts
|
|
9351
9573
|
function toSummary2(config) {
|
|
9352
9574
|
return {
|
|
@@ -9363,18 +9585,22 @@ var AssistantManager = class {
|
|
|
9363
9585
|
deps;
|
|
9364
9586
|
generalIds;
|
|
9365
9587
|
builtinCache = /* @__PURE__ */ new Map();
|
|
9588
|
+
builtinDigestCache = /* @__PURE__ */ new Map();
|
|
9366
9589
|
cache = /* @__PURE__ */ new Map();
|
|
9367
9590
|
initialized = false;
|
|
9368
9591
|
constructor(deps) {
|
|
9369
9592
|
this.deps = deps;
|
|
9370
|
-
this.generalIds = deps.generalIds
|
|
9593
|
+
this.generalIds = [...deps.generalIds ?? GENERAL_ASSISTANT_IDS];
|
|
9371
9594
|
this.initBuiltinCache();
|
|
9372
9595
|
}
|
|
9373
9596
|
initBuiltinCache() {
|
|
9374
9597
|
if (!this.deps.builtinRawConfigs) return;
|
|
9375
9598
|
for (const { id, content } of this.deps.builtinRawConfigs) {
|
|
9376
9599
|
const config = parseAssistantFile(content, `${id}.md`);
|
|
9377
|
-
if (config)
|
|
9600
|
+
if (config) {
|
|
9601
|
+
this.builtinCache.set(config.id, config);
|
|
9602
|
+
this.builtinDigestCache.set(config.id, this.getConfigDigest(config));
|
|
9603
|
+
}
|
|
9378
9604
|
}
|
|
9379
9605
|
}
|
|
9380
9606
|
getBuiltinConfig(id) {
|
|
@@ -9385,38 +9611,120 @@ var AssistantManager = class {
|
|
|
9385
9611
|
}
|
|
9386
9612
|
// ==================== Init ====================
|
|
9387
9613
|
init() {
|
|
9388
|
-
const { fs:
|
|
9389
|
-
|
|
9390
|
-
const generalCreated = this.
|
|
9614
|
+
const { fs: fs37, assistantsDir } = this.deps;
|
|
9615
|
+
fs37.ensureDir(assistantsDir);
|
|
9616
|
+
const { generalCreated, generalUpdated } = this.syncGeneralAssistants();
|
|
9391
9617
|
this.loadAll();
|
|
9392
9618
|
this.initialized = true;
|
|
9393
9619
|
this.deps.logger?.info("AssistantManager", "Initialized", {
|
|
9394
9620
|
total: this.cache.size,
|
|
9395
|
-
generalCreated
|
|
9621
|
+
generalCreated,
|
|
9622
|
+
generalUpdated
|
|
9396
9623
|
});
|
|
9397
|
-
return { total: this.cache.size, generalCreated };
|
|
9624
|
+
return { total: this.cache.size, generalCreated, generalUpdated };
|
|
9398
9625
|
}
|
|
9399
|
-
|
|
9400
|
-
const { fs:
|
|
9401
|
-
let
|
|
9626
|
+
syncGeneralAssistants() {
|
|
9627
|
+
const { fs: fs37, assistantsDir } = this.deps;
|
|
9628
|
+
let generalCreated = false;
|
|
9629
|
+
let generalUpdated = false;
|
|
9402
9630
|
for (const id of this.generalIds) {
|
|
9403
9631
|
const config = this.getBuiltinConfig(id);
|
|
9404
9632
|
if (!config) continue;
|
|
9405
|
-
const filePath =
|
|
9406
|
-
if (
|
|
9407
|
-
|
|
9408
|
-
|
|
9633
|
+
const filePath = fs37.joinPath(assistantsDir, `${id}.md`);
|
|
9634
|
+
if (!fs37.fileExists(filePath)) {
|
|
9635
|
+
fs37.writeFile(filePath, serializeAssistant(this.withBuiltinTracking(config)));
|
|
9636
|
+
generalCreated = true;
|
|
9637
|
+
continue;
|
|
9638
|
+
}
|
|
9639
|
+
try {
|
|
9640
|
+
const existing = parseAssistantFile(fs37.readFile(filePath), filePath);
|
|
9641
|
+
if (!existing) continue;
|
|
9642
|
+
if (existing.builtinId !== id) {
|
|
9643
|
+
try {
|
|
9644
|
+
const backupId = this.backupAssistantOccupyingReservedId(existing);
|
|
9645
|
+
fs37.writeFile(filePath, serializeAssistant(this.withBuiltinTracking(config)));
|
|
9646
|
+
generalCreated = true;
|
|
9647
|
+
this.deps.logger?.info("AssistantManager", "Backed up assistant occupying reserved default ID", {
|
|
9648
|
+
reservedId: id,
|
|
9649
|
+
backupId
|
|
9650
|
+
});
|
|
9651
|
+
} catch (error) {
|
|
9652
|
+
this.deps.logger?.error(
|
|
9653
|
+
"AssistantManager",
|
|
9654
|
+
`Failed to migrate assistant occupying reserved default ID: ${id}`,
|
|
9655
|
+
error
|
|
9656
|
+
);
|
|
9657
|
+
}
|
|
9658
|
+
continue;
|
|
9659
|
+
}
|
|
9660
|
+
if (!this.shouldUpgradeBuiltin(existing, config)) continue;
|
|
9661
|
+
fs37.writeFile(filePath, serializeAssistant(this.withBuiltinTracking(config, existing.id)));
|
|
9662
|
+
generalUpdated = true;
|
|
9663
|
+
this.deps.logger?.info("AssistantManager", "Updated unmodified default assistant template", {
|
|
9664
|
+
id,
|
|
9665
|
+
fromVersion: existing.builtinVersion,
|
|
9666
|
+
toVersion: config.builtinVersion
|
|
9667
|
+
});
|
|
9668
|
+
} catch (error) {
|
|
9669
|
+
this.deps.logger?.warn("AssistantManager", `Failed to inspect default assistant: ${id}`, {
|
|
9670
|
+
error: String(error)
|
|
9671
|
+
});
|
|
9672
|
+
}
|
|
9409
9673
|
}
|
|
9410
|
-
return
|
|
9674
|
+
return { generalCreated, generalUpdated };
|
|
9675
|
+
}
|
|
9676
|
+
backupAssistantOccupyingReservedId(config) {
|
|
9677
|
+
const { fs: fs37, assistantsDir } = this.deps;
|
|
9678
|
+
const baseId = this.deps.generateId?.() || `custom_${Date.now().toString(36)}`;
|
|
9679
|
+
let backupId = baseId;
|
|
9680
|
+
let suffix = 2;
|
|
9681
|
+
while (this.generalIds.includes(backupId) || fs37.fileExists(fs37.joinPath(assistantsDir, `${backupId}.md`))) {
|
|
9682
|
+
backupId = `${baseId}_${suffix++}`;
|
|
9683
|
+
}
|
|
9684
|
+
fs37.writeFile(fs37.joinPath(assistantsDir, `${backupId}.md`), serializeAssistant({ ...config, id: backupId }));
|
|
9685
|
+
return backupId;
|
|
9686
|
+
}
|
|
9687
|
+
getConfigDigest(config) {
|
|
9688
|
+
return this.deps.contentHash(
|
|
9689
|
+
JSON.stringify({
|
|
9690
|
+
name: config.name,
|
|
9691
|
+
systemPrompt: config.systemPrompt,
|
|
9692
|
+
presetQuestions: config.presetQuestions,
|
|
9693
|
+
allowedBuiltinTools: config.allowedBuiltinTools ?? [],
|
|
9694
|
+
applicableChatTypes: config.applicableChatTypes ?? [],
|
|
9695
|
+
supportedLocales: config.supportedLocales ?? []
|
|
9696
|
+
})
|
|
9697
|
+
);
|
|
9698
|
+
}
|
|
9699
|
+
withBuiltinTracking(config, id = config.id) {
|
|
9700
|
+
return {
|
|
9701
|
+
...config,
|
|
9702
|
+
id,
|
|
9703
|
+
builtinId: config.id,
|
|
9704
|
+
builtinVersion: config.builtinVersion,
|
|
9705
|
+
builtinDigest: this.builtinDigestCache.get(config.id) ?? this.getConfigDigest(config)
|
|
9706
|
+
};
|
|
9707
|
+
}
|
|
9708
|
+
shouldUpgradeBuiltin(existing, builtin) {
|
|
9709
|
+
const comparison = this.compareBuiltin(existing, builtin);
|
|
9710
|
+
return comparison.isUnmodified && comparison.isOutdated;
|
|
9711
|
+
}
|
|
9712
|
+
compareBuiltin(existing, builtin) {
|
|
9713
|
+
const builtinDigest = this.builtinDigestCache.get(builtin.id) ?? this.getConfigDigest(builtin);
|
|
9714
|
+
const existingDigest = this.getConfigDigest(existing);
|
|
9715
|
+
const knownBaseDigests = existing.builtinDigest ? [existing.builtinDigest] : this.deps.legacyBuiltinDigests?.[builtin.id] ?? [];
|
|
9716
|
+
const isUnmodified = existingDigest === builtinDigest || knownBaseDigests.includes(existingDigest);
|
|
9717
|
+
const isOutdated = existing.builtinDigest !== builtinDigest || existing.builtinVersion !== builtin.builtinVersion;
|
|
9718
|
+
return { isUnmodified, isOutdated };
|
|
9411
9719
|
}
|
|
9412
9720
|
loadAll() {
|
|
9413
|
-
const { fs:
|
|
9721
|
+
const { fs: fs37, assistantsDir } = this.deps;
|
|
9414
9722
|
this.cache.clear();
|
|
9415
|
-
const files =
|
|
9723
|
+
const files = fs37.listFiles(assistantsDir, ".md");
|
|
9416
9724
|
for (const file of files) {
|
|
9417
9725
|
try {
|
|
9418
|
-
const filePath =
|
|
9419
|
-
const content =
|
|
9726
|
+
const filePath = fs37.joinPath(assistantsDir, file);
|
|
9727
|
+
const content = fs37.readFile(filePath);
|
|
9420
9728
|
const config = parseAssistantFile(content, filePath);
|
|
9421
9729
|
if (config) {
|
|
9422
9730
|
this.cache.set(config.id, config);
|
|
@@ -9437,6 +9745,23 @@ var AssistantManager = class {
|
|
|
9437
9745
|
this.ensureInitialized();
|
|
9438
9746
|
return this.cache.get(id) ?? null;
|
|
9439
9747
|
}
|
|
9748
|
+
getAssistantUpgradeInfo(id) {
|
|
9749
|
+
this.ensureInitialized();
|
|
9750
|
+
if (!this.generalIds.includes(id)) return null;
|
|
9751
|
+
const existing = this.cache.get(id);
|
|
9752
|
+
if (!existing?.builtinId) return null;
|
|
9753
|
+
const builtin = this.getBuiltinConfig(existing.builtinId);
|
|
9754
|
+
if (!builtin) return null;
|
|
9755
|
+
const comparison = this.compareBuiltin(existing, builtin);
|
|
9756
|
+
if (!comparison.isOutdated || comparison.isUnmodified) return null;
|
|
9757
|
+
return {
|
|
9758
|
+
assistantId: existing.id,
|
|
9759
|
+
builtinId: existing.builtinId,
|
|
9760
|
+
name: existing.name,
|
|
9761
|
+
currentVersion: existing.builtinVersion ?? null,
|
|
9762
|
+
latestVersion: builtin.builtinVersion ?? null
|
|
9763
|
+
};
|
|
9764
|
+
}
|
|
9440
9765
|
hasAssistant(id) {
|
|
9441
9766
|
this.ensureInitialized();
|
|
9442
9767
|
return this.cache.has(id);
|
|
@@ -9455,7 +9780,7 @@ var AssistantManager = class {
|
|
|
9455
9780
|
if (!builtinConfig) return { success: false, error: `Builtin assistant not found: ${builtinId}` };
|
|
9456
9781
|
const existing = this.findByBuiltinId(builtinId);
|
|
9457
9782
|
if (existing) return { success: false, error: `Assistant already imported: ${builtinId}` };
|
|
9458
|
-
return this.saveToDisk(
|
|
9783
|
+
return this.saveToDisk(this.withBuiltinTracking(builtinConfig));
|
|
9459
9784
|
}
|
|
9460
9785
|
reimportAssistant(id) {
|
|
9461
9786
|
this.ensureInitialized();
|
|
@@ -9464,7 +9789,7 @@ var AssistantManager = class {
|
|
|
9464
9789
|
if (!existing.builtinId) return { success: false, error: "Only imported builtin assistants can be reimported" };
|
|
9465
9790
|
const builtinConfig = this.getBuiltinConfig(existing.builtinId);
|
|
9466
9791
|
if (!builtinConfig) return { success: false, error: `Builtin template not found: ${existing.builtinId}` };
|
|
9467
|
-
return this.saveToDisk(
|
|
9792
|
+
return this.saveToDisk(this.withBuiltinTracking(builtinConfig, existing.id));
|
|
9468
9793
|
}
|
|
9469
9794
|
importAssistantFromMd(rawMd) {
|
|
9470
9795
|
this.ensureInitialized();
|
|
@@ -9508,7 +9833,55 @@ var AssistantManager = class {
|
|
|
9508
9833
|
if (!existing?.builtinId) return { success: false, error: "Only builtin assistants can be reset" };
|
|
9509
9834
|
const builtinConfig = this.getBuiltinConfig(existing.builtinId);
|
|
9510
9835
|
if (!builtinConfig) return { success: false, error: `Builtin config not found: ${existing.builtinId}` };
|
|
9511
|
-
|
|
9836
|
+
const result = this.saveToDisk(this.withBuiltinTracking(builtinConfig, existing.id));
|
|
9837
|
+
if (result.success) {
|
|
9838
|
+
this.deps.logger?.info("AssistantManager", "Reset builtin assistant to default template", {
|
|
9839
|
+
id: existing.id,
|
|
9840
|
+
builtinId: existing.builtinId
|
|
9841
|
+
});
|
|
9842
|
+
}
|
|
9843
|
+
return result;
|
|
9844
|
+
}
|
|
9845
|
+
upgradeAssistantWithBackup(id, backupName) {
|
|
9846
|
+
this.ensureInitialized();
|
|
9847
|
+
const upgradeInfo = this.getAssistantUpgradeInfo(id);
|
|
9848
|
+
if (!upgradeInfo) return { success: false, error: `No assistant upgrade available: ${id}` };
|
|
9849
|
+
const existing = this.cache.get(id);
|
|
9850
|
+
const builtin = this.getBuiltinConfig(upgradeInfo.builtinId);
|
|
9851
|
+
const normalizedBackupName = backupName.trim() || `${existing.name} (Legacy Backup)`;
|
|
9852
|
+
const backupConfig = {
|
|
9853
|
+
...existing,
|
|
9854
|
+
id: this.deps.generateId?.() || `custom_${Date.now().toString(36)}`,
|
|
9855
|
+
name: normalizedBackupName,
|
|
9856
|
+
builtinId: void 0,
|
|
9857
|
+
builtinVersion: void 0,
|
|
9858
|
+
builtinDigest: void 0
|
|
9859
|
+
};
|
|
9860
|
+
const existingBackup = Array.from(this.cache.values()).find(
|
|
9861
|
+
(config) => !config.builtinId && this.getConfigDigest(config) === this.getConfigDigest(backupConfig)
|
|
9862
|
+
);
|
|
9863
|
+
const backupId = existingBackup?.id ?? backupConfig.id;
|
|
9864
|
+
if (!existingBackup) {
|
|
9865
|
+
const backupResult = this.saveToDisk(backupConfig);
|
|
9866
|
+
if (!backupResult.success) return backupResult;
|
|
9867
|
+
}
|
|
9868
|
+
const upgradeResult = this.saveToDisk(this.withBuiltinTracking(builtin, existing.id));
|
|
9869
|
+
if (!upgradeResult.success) {
|
|
9870
|
+
this.deps.logger?.warn("AssistantManager", "Default assistant upgrade failed after backup", {
|
|
9871
|
+
id: existing.id,
|
|
9872
|
+
builtinId: existing.builtinId,
|
|
9873
|
+
backupId
|
|
9874
|
+
});
|
|
9875
|
+
return { ...upgradeResult, backupId };
|
|
9876
|
+
}
|
|
9877
|
+
this.deps.logger?.info("AssistantManager", "Backed up and upgraded default assistant", {
|
|
9878
|
+
id: existing.id,
|
|
9879
|
+
builtinId: existing.builtinId,
|
|
9880
|
+
backupId,
|
|
9881
|
+
fromVersion: existing.builtinVersion,
|
|
9882
|
+
toVersion: builtin.builtinVersion
|
|
9883
|
+
});
|
|
9884
|
+
return { success: true, backupId };
|
|
9512
9885
|
}
|
|
9513
9886
|
// ==================== Internal ====================
|
|
9514
9887
|
findByBuiltinId(builtinId) {
|
|
@@ -9528,12 +9901,12 @@ var AssistantManager = class {
|
|
|
9528
9901
|
};
|
|
9529
9902
|
|
|
9530
9903
|
// ../../packages/node-runtime/src/ai/skill-parser.ts
|
|
9531
|
-
import * as
|
|
9904
|
+
import * as path22 from "path";
|
|
9532
9905
|
import matter2 from "gray-matter";
|
|
9533
9906
|
function parseSkillFile(content, filePath) {
|
|
9534
9907
|
try {
|
|
9535
9908
|
const { data: fm, content: prompt } = matter2(content);
|
|
9536
|
-
const id = fm.id ??
|
|
9909
|
+
const id = fm.id ?? path22.basename(filePath, ".md");
|
|
9537
9910
|
const name = fm.name;
|
|
9538
9911
|
if (!name) return null;
|
|
9539
9912
|
return {
|
|
@@ -9552,7 +9925,7 @@ function parseSkillFile(content, filePath) {
|
|
|
9552
9925
|
function extractSkillId(content, filePath) {
|
|
9553
9926
|
try {
|
|
9554
9927
|
const { data: fm } = matter2(content);
|
|
9555
|
-
return fm.id ??
|
|
9928
|
+
return fm.id ?? path22.basename(filePath, ".md");
|
|
9556
9929
|
} catch {
|
|
9557
9930
|
return null;
|
|
9558
9931
|
}
|
|
@@ -9571,9 +9944,9 @@ function validateChatScope(raw) {
|
|
|
9571
9944
|
|
|
9572
9945
|
// ../../packages/node-runtime/src/ai/chats.ts
|
|
9573
9946
|
import Database from "better-sqlite3";
|
|
9574
|
-
import * as
|
|
9575
|
-
import * as
|
|
9576
|
-
var DEFAULT_GENERAL_ID =
|
|
9947
|
+
import * as fs26 from "fs";
|
|
9948
|
+
import * as path23 from "path";
|
|
9949
|
+
var DEFAULT_GENERAL_ID = DEFAULT_GENERAL_ASSISTANT_ID;
|
|
9577
9950
|
var defaultLogger = {
|
|
9578
9951
|
warn(_category, message, extra) {
|
|
9579
9952
|
console.warn(`[AI Chats] ${message}`, extra ?? "");
|
|
@@ -9591,14 +9964,14 @@ var AIChatManager = class {
|
|
|
9591
9964
|
this.nativeBinding = options2?.nativeBinding;
|
|
9592
9965
|
}
|
|
9593
9966
|
ensureDir(dir) {
|
|
9594
|
-
if (!
|
|
9595
|
-
|
|
9967
|
+
if (!fs26.existsSync(dir)) {
|
|
9968
|
+
fs26.mkdirSync(dir, { recursive: true });
|
|
9596
9969
|
}
|
|
9597
9970
|
}
|
|
9598
9971
|
getDb() {
|
|
9599
9972
|
if (this.db) return this.db;
|
|
9600
9973
|
this.ensureDir(this.aiDataDir);
|
|
9601
|
-
const dbPath =
|
|
9974
|
+
const dbPath = path23.join(this.aiDataDir, "conversations.db");
|
|
9602
9975
|
this.db = this.nativeBinding ? new Database(dbPath, { nativeBinding: this.nativeBinding }) : new Database(dbPath);
|
|
9603
9976
|
this.db.pragma("journal_mode = WAL");
|
|
9604
9977
|
this.db.exec(`
|
|
@@ -9841,16 +10214,16 @@ var AIChatManager = class {
|
|
|
9841
10214
|
if (allRows.length === 0) return [];
|
|
9842
10215
|
const rowMap = new Map(allRows.map((row) => [row.id, row]));
|
|
9843
10216
|
let currentId = leafMessageId ?? this.getActiveMessageId(aiChatId);
|
|
9844
|
-
const
|
|
10217
|
+
const path33 = [];
|
|
9845
10218
|
const seen = /* @__PURE__ */ new Set();
|
|
9846
10219
|
while (currentId && !seen.has(currentId)) {
|
|
9847
10220
|
seen.add(currentId);
|
|
9848
10221
|
const row = rowMap.get(currentId);
|
|
9849
10222
|
if (!row) break;
|
|
9850
|
-
|
|
10223
|
+
path33.push(row);
|
|
9851
10224
|
currentId = row.parentId;
|
|
9852
10225
|
}
|
|
9853
|
-
return
|
|
10226
|
+
return path33.length > 0 ? path33.reverse() : allRows;
|
|
9854
10227
|
}
|
|
9855
10228
|
// ==================== 生命周期 ====================
|
|
9856
10229
|
close() {
|
|
@@ -10420,21 +10793,21 @@ var SkillManagerCore = class {
|
|
|
10420
10793
|
}
|
|
10421
10794
|
// ==================== Init ====================
|
|
10422
10795
|
init() {
|
|
10423
|
-
const { fs:
|
|
10424
|
-
|
|
10796
|
+
const { fs: fs37, skillsDir } = this.deps;
|
|
10797
|
+
fs37.ensureDir(skillsDir);
|
|
10425
10798
|
this.loadAll();
|
|
10426
10799
|
this.initialized = true;
|
|
10427
10800
|
this.deps.logger?.info("SkillManager", "Initialized", { total: this.cache.size });
|
|
10428
10801
|
return { total: this.cache.size };
|
|
10429
10802
|
}
|
|
10430
10803
|
loadAll() {
|
|
10431
|
-
const { fs:
|
|
10804
|
+
const { fs: fs37, skillsDir } = this.deps;
|
|
10432
10805
|
this.cache.clear();
|
|
10433
|
-
const files =
|
|
10806
|
+
const files = fs37.listFiles(skillsDir, ".md");
|
|
10434
10807
|
for (const file of files) {
|
|
10435
10808
|
try {
|
|
10436
|
-
const filePath =
|
|
10437
|
-
const content =
|
|
10809
|
+
const filePath = fs37.joinPath(skillsDir, file);
|
|
10810
|
+
const content = fs37.readFile(filePath);
|
|
10438
10811
|
const def = parseSkillFile(content, filePath);
|
|
10439
10812
|
if (def) {
|
|
10440
10813
|
this.cache.set(def.id, def);
|
|
@@ -10586,8 +10959,8 @@ var SkillManagerCore = class {
|
|
|
10586
10959
|
};
|
|
10587
10960
|
|
|
10588
10961
|
// ../../packages/node-runtime/src/ai/skill-manager.ts
|
|
10589
|
-
import * as
|
|
10590
|
-
import * as
|
|
10962
|
+
import * as fs27 from "fs";
|
|
10963
|
+
import * as path24 from "path";
|
|
10591
10964
|
var SKILLS_DIR_NAME = "skills";
|
|
10592
10965
|
var defaultLogger2 = {
|
|
10593
10966
|
info: () => {
|
|
@@ -10597,26 +10970,26 @@ var defaultLogger2 = {
|
|
|
10597
10970
|
};
|
|
10598
10971
|
var nodeFs = {
|
|
10599
10972
|
ensureDir(dir) {
|
|
10600
|
-
|
|
10973
|
+
fs27.mkdirSync(dir, { recursive: true });
|
|
10601
10974
|
},
|
|
10602
10975
|
listFiles(dir, ext) {
|
|
10603
|
-
if (!
|
|
10604
|
-
return
|
|
10976
|
+
if (!fs27.existsSync(dir)) return [];
|
|
10977
|
+
return fs27.readdirSync(dir).filter((file) => file.endsWith(ext));
|
|
10605
10978
|
},
|
|
10606
10979
|
readFile(filePath) {
|
|
10607
|
-
return
|
|
10980
|
+
return fs27.readFileSync(filePath, "utf-8");
|
|
10608
10981
|
},
|
|
10609
10982
|
writeFile(filePath, content) {
|
|
10610
|
-
|
|
10983
|
+
fs27.writeFileSync(filePath, content, "utf-8");
|
|
10611
10984
|
},
|
|
10612
10985
|
deleteFile(filePath) {
|
|
10613
|
-
|
|
10986
|
+
fs27.unlinkSync(filePath);
|
|
10614
10987
|
},
|
|
10615
10988
|
fileExists(filePath) {
|
|
10616
|
-
return
|
|
10989
|
+
return fs27.existsSync(filePath);
|
|
10617
10990
|
},
|
|
10618
10991
|
joinPath(...parts) {
|
|
10619
|
-
return
|
|
10992
|
+
return path24.join(...parts);
|
|
10620
10993
|
}
|
|
10621
10994
|
};
|
|
10622
10995
|
var SkillManager = class {
|
|
@@ -10626,7 +10999,7 @@ var SkillManager = class {
|
|
|
10626
10999
|
this.logger = logger ?? defaultLogger2;
|
|
10627
11000
|
this.core = new SkillManagerCore({
|
|
10628
11001
|
fs: nodeFs,
|
|
10629
|
-
skillsDir:
|
|
11002
|
+
skillsDir: path24.join(aiDataDir, SKILLS_DIR_NAME),
|
|
10630
11003
|
builtinRawSkills: [],
|
|
10631
11004
|
logger: {
|
|
10632
11005
|
info: () => {
|
|
@@ -13352,26 +13725,34 @@ var zh_CN_default = {
|
|
|
13352
13725
|
- \u53EA\u6709\u5DE5\u5177\u8FD4\u56DE\u7684\u6D88\u606F\u3001\u7EDF\u8BA1\u6216\u6570\u636E\u5E93\u6982\u89C8\u53EF\u4EE5\u4F5C\u4E3A\u4E8B\u5B9E\u4F9D\u636E\uFF1B\u5DE5\u5177\u6CA1\u6709\u8FD4\u56DE\u8DB3\u591F\u8BC1\u636E\u65F6\uFF0C\u660E\u786E\u8BF4\u660E\u6570\u636E\u4E0D\u8DB3\uFF0C\u4E0D\u8981\u7F16\u9020\u4E0D\u5B58\u5728\u7684\u804A\u5929\u8BB0\u5F55\u3002`,
|
|
13353
13726
|
currentTask: "\u5F53\u524D\u4EFB\u52A1",
|
|
13354
13727
|
skillPriorityNote: "\u6CE8\u610F\uFF1A\u5728\u6267\u884C\u6B64\u4EFB\u52A1\u65F6\uFF0C\u8BF7\u4F18\u5148\u9075\u5FAA\u4EE5\u4E0B\u4EFB\u52A1\u7684\u8F93\u51FA\u683C\u5F0F\u8981\u6C42\uFF0C\u8FD9\u53EF\u4EE5\u8986\u76D6\u4F60\u7684\u5E38\u89C4\u56DE\u590D\u4E60\u60EF\u3002",
|
|
13355
|
-
responseInstruction: "\u6839\u636E\u7528\u6237\u7684\u95EE\u9898\uFF0C\u9009\u62E9\u5408\u9002\u7684\u5DE5\u5177\u83B7\u53D6\u6570\u636E\uFF0C\u7136\u540E\
|
|
13728
|
+
responseInstruction: "\u6839\u636E\u7528\u6237\u7684\u95EE\u9898\uFF0C\u5728\u9700\u8981\u65F6\u9009\u62E9\u5408\u9002\u7684\u5DE5\u5177\u83B7\u53D6\u6570\u636E\uFF0C\u7136\u540E\u81EA\u7136\u3001\u76F4\u63A5\u5730\u7ED9\u51FA\u56DE\u7B54\u3002",
|
|
13356
13729
|
fallbackRoleDefinition: {
|
|
13357
|
-
group: `\u4F60\u662F\
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
\
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13730
|
+
group: `\u4F60\u662F ChatLab \u91CC\u7684\u7FA4\u804A\u8BB0\u5F55\u5206\u6790\u642D\u6863\uFF0C\u5E2E\u52A9\u7528\u6237\u4ECE\u804A\u5929\u8BB0\u5F55\u4E2D\u7406\u89E3\u4E8B\u5B9E\u3001\u53D8\u5316\u548C\u4E92\u52A8\u6A21\u5F0F\uFF0C\u800C\u4E0D\u662F\u673A\u68B0\u5730\u751F\u6210\u5206\u6790\u62A5\u544A\u3002
|
|
13731
|
+
|
|
13732
|
+
## \u4EA4\u6D41\u65B9\u5F0F
|
|
13733
|
+
- \u8DDF\u968F\u7528\u6237\u7684\u8BED\u8A00\u548C\u4EA4\u6D41\u65B9\u5F0F\uFF0C\u8BF4\u81EA\u7136\u3001\u76F4\u63A5\u7684\u4EBA\u8BDD\uFF0C\u907F\u514D\u5BA2\u670D\u8154\u548C\u8FC7\u5EA6\u6B63\u5F0F\u7684\u8868\u8FBE\u3002
|
|
13734
|
+
- \u7B80\u5355\u95EE\u9898\u76F4\u63A5\u56DE\u7B54\uFF1B\u590D\u6742\u95EE\u9898\u518D\u5206\u5C42\u8BF4\u660E\u3002\u6807\u9898\u3001\u5217\u8868\u548C\u8868\u683C\u53EA\u5728\u6709\u52A9\u4E8E\u7406\u89E3\u65F6\u4F7F\u7528\u3002
|
|
13735
|
+
- \u5728\u8BC1\u636E\u5141\u8BB8\u65F6\u7ED9\u51FA\u660E\u786E\u5224\u65AD\uFF1B\u65E0\u6CD5\u786E\u8BA4\u7684\u90E8\u5206\u8981\u5766\u7387\u8BF4\u660E\u3002
|
|
13736
|
+
- \u53EF\u4EE5\u6709\u4E00\u70B9\u81EA\u7136\u7684\u5E7D\u9ED8\u611F\uFF0C\u4F46\u4E0D\u8981\u5F3A\u884C\u73A9\u6897\u3001\u5806\u8868\u60C5\u6216\u727A\u7272\u51C6\u786E\u6027\u3002
|
|
13737
|
+
|
|
13738
|
+
## \u5206\u6790\u8FB9\u754C
|
|
13739
|
+
- \u533A\u5206\u80FD\u591F\u786E\u8BA4\u7684\u4E8B\u5B9E\u3001\u57FA\u4E8E\u8BC1\u636E\u7684\u63A8\u65AD\uFF0C\u4EE5\u53CA\u6682\u65F6\u65E0\u6CD5\u5224\u65AD\u7684\u90E8\u5206\u3002
|
|
13740
|
+
- \u6D89\u53CA\u6027\u683C\u3001\u60C5\u7EEA\u3001\u5173\u7CFB\u548C\u52A8\u673A\u65F6\u5C24\u5176\u8C28\u614E\uFF0C\u4E0D\u7F16\u9020\u5FC3\u7406\u6D3B\u52A8\uFF0C\u4E5F\u4E0D\u8F7B\u6613\u7ED9\u4EBA\u8D34\u6807\u7B7E\u3002
|
|
13741
|
+
- \u9002\u91CF\u5F15\u7528\u6709\u4EE3\u8868\u6027\u7684\u539F\u8BDD\u548C\u6570\u636E\uFF0C\u4E0D\u8981\u5927\u6BB5\u5806\u780C\u804A\u5929\u8BB0\u5F55\u3002
|
|
13742
|
+
- \u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u4E0D\u8BF4\u6559\u3001\u4E0D\u64C5\u81EA\u7ED9\u4EBA\u751F\u5EFA\u8BAE\uFF0C\u4E5F\u4E0D\u628A\u6BCF\u6B21\u56DE\u7B54\u90FD\u5199\u6210\u603B\u7ED3\u62A5\u544A\u3002`,
|
|
13743
|
+
private: `\u4F60\u662F ChatLab \u91CC\u7684\u79C1\u804A\u8BB0\u5F55\u5206\u6790\u642D\u6863\uFF0C\u5E2E\u52A9\u7528\u6237\u4ECE\u804A\u5929\u8BB0\u5F55\u4E2D\u7406\u89E3\u4E8B\u5B9E\u3001\u53D8\u5316\u548C\u4E92\u52A8\u65B9\u5F0F\uFF0C\u800C\u4E0D\u662F\u673A\u68B0\u5730\u751F\u6210\u5206\u6790\u62A5\u544A\u3002
|
|
13744
|
+
|
|
13745
|
+
## \u4EA4\u6D41\u65B9\u5F0F
|
|
13746
|
+
- \u8DDF\u968F\u7528\u6237\u7684\u8BED\u8A00\u548C\u4EA4\u6D41\u65B9\u5F0F\uFF0C\u8BF4\u81EA\u7136\u3001\u76F4\u63A5\u7684\u4EBA\u8BDD\uFF0C\u907F\u514D\u5BA2\u670D\u8154\u548C\u8FC7\u5EA6\u6B63\u5F0F\u7684\u8868\u8FBE\u3002
|
|
13747
|
+
- \u7B80\u5355\u95EE\u9898\u76F4\u63A5\u56DE\u7B54\uFF1B\u590D\u6742\u95EE\u9898\u518D\u5206\u5C42\u8BF4\u660E\u3002\u6807\u9898\u3001\u5217\u8868\u548C\u8868\u683C\u53EA\u5728\u6709\u52A9\u4E8E\u7406\u89E3\u65F6\u4F7F\u7528\u3002
|
|
13748
|
+
- \u5728\u8BC1\u636E\u5141\u8BB8\u65F6\u7ED9\u51FA\u660E\u786E\u5224\u65AD\uFF1B\u65E0\u6CD5\u786E\u8BA4\u7684\u90E8\u5206\u8981\u5766\u7387\u8BF4\u660E\u3002
|
|
13749
|
+
- \u53EF\u4EE5\u6709\u4E00\u70B9\u81EA\u7136\u7684\u5E7D\u9ED8\u611F\uFF0C\u4F46\u4E0D\u8981\u5F3A\u884C\u73A9\u6897\u3001\u5806\u8868\u60C5\u6216\u727A\u7272\u51C6\u786E\u6027\u3002
|
|
13750
|
+
|
|
13751
|
+
## \u5206\u6790\u8FB9\u754C
|
|
13752
|
+
- \u533A\u5206\u80FD\u591F\u786E\u8BA4\u7684\u4E8B\u5B9E\u3001\u57FA\u4E8E\u8BC1\u636E\u7684\u63A8\u65AD\uFF0C\u4EE5\u53CA\u6682\u65F6\u65E0\u6CD5\u5224\u65AD\u7684\u90E8\u5206\u3002
|
|
13753
|
+
- \u6D89\u53CA\u6027\u683C\u3001\u60C5\u7EEA\u3001\u5173\u7CFB\u548C\u52A8\u673A\u65F6\u5C24\u5176\u8C28\u614E\uFF0C\u4E0D\u7F16\u9020\u5FC3\u7406\u6D3B\u52A8\uFF0C\u4E5F\u4E0D\u8F7B\u6613\u7ED9\u4EBA\u8D34\u6807\u7B7E\u3002
|
|
13754
|
+
- \u9002\u91CF\u5F15\u7528\u6709\u4EE3\u8868\u6027\u7684\u539F\u8BDD\u548C\u6570\u636E\uFF0C\u4E0D\u8981\u5927\u6BB5\u5806\u780C\u804A\u5929\u8BB0\u5F55\u3002
|
|
13755
|
+
- \u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u4E0D\u8BF4\u6559\u3001\u4E0D\u64C5\u81EA\u7ED9\u4EBA\u751F\u5EFA\u8BAE\uFF0C\u4E5F\u4E0D\u628A\u6BCF\u6B21\u56DE\u7B54\u90FD\u5199\u6210\u603B\u7ED3\u62A5\u544A\u3002`
|
|
13375
13756
|
}
|
|
13376
13757
|
}
|
|
13377
13758
|
},
|
|
@@ -13707,22 +14088,34 @@ Usage rules:
|
|
|
13707
14088
|
- Only messages, statistics, or database overviews returned by tools may be used as factual basis. If tools do not return enough evidence, say the data is insufficient and do not fabricate nonexistent chat records.`,
|
|
13708
14089
|
currentTask: "Current Task",
|
|
13709
14090
|
skillPriorityNote: "Note: When executing this task, prioritize the output format requirements below. This can override your usual response style.",
|
|
13710
|
-
responseInstruction: "Based on the user's question,
|
|
14091
|
+
responseInstruction: "Based on the user's question, use appropriate tools when needed, then answer naturally and directly.",
|
|
13711
14092
|
fallbackRoleDefinition: {
|
|
13712
|
-
group: `You are
|
|
13713
|
-
|
|
14093
|
+
group: `You are ChatLab's group chat analysis partner. Help users understand facts, changes, and interaction patterns in their chat records instead of mechanically producing analysis reports.
|
|
14094
|
+
|
|
14095
|
+
## How to Communicate
|
|
14096
|
+
- Match the user's language and conversational style. Sound natural and direct, not like customer support or a formal report.
|
|
14097
|
+
- Answer simple questions directly. Add structure only for complex questions, and use headings, lists, or tables only when they improve understanding.
|
|
14098
|
+
- Give a clear judgment when the evidence supports one, and be candid about anything that cannot be established.
|
|
14099
|
+
- Light, natural humor is welcome, but never force jokes, emojis, or entertainment at the expense of accuracy.
|
|
14100
|
+
|
|
14101
|
+
## Analysis Boundaries
|
|
14102
|
+
- Distinguish established facts, evidence-based inferences, and what remains unknown.
|
|
14103
|
+
- Be especially careful with personality, emotion, relationships, and motives. Do not invent inner states or casually label people.
|
|
14104
|
+
- Use a small number of representative quotes or data points, but do not dump large blocks of chat logs.
|
|
14105
|
+
- Unless the user asks, do not moralize, give unsolicited life advice, or turn every response into a summary report.`,
|
|
14106
|
+
private: `You are ChatLab's private chat analysis partner. Help users understand facts, changes, and interaction patterns in their chat records instead of mechanically producing analysis reports.
|
|
13714
14107
|
|
|
13715
|
-
##
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
Your task is to help users understand and analyze their private chat data.
|
|
14108
|
+
## How to Communicate
|
|
14109
|
+
- Match the user's language and conversational style. Sound natural and direct, not like customer support or a formal report.
|
|
14110
|
+
- Answer simple questions directly. Add structure only for complex questions, and use headings, lists, or tables only when they improve understanding.
|
|
14111
|
+
- Give a clear judgment when the evidence supports one, and be candid about anything that cannot be established.
|
|
14112
|
+
- Light, natural humor is welcome, but never force jokes, emojis, or entertainment at the expense of accuracy.
|
|
13721
14113
|
|
|
13722
|
-
##
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
14114
|
+
## Analysis Boundaries
|
|
14115
|
+
- Distinguish established facts, evidence-based inferences, and what remains unknown.
|
|
14116
|
+
- Be especially careful with personality, emotion, relationships, and motives. Do not invent inner states or casually label people.
|
|
14117
|
+
- Use a small number of representative quotes or data points, but do not dump large blocks of chat logs.
|
|
14118
|
+
- Unless the user asks, do not moralize, give unsolicited life advice, or turn every response into a summary report.`
|
|
13726
14119
|
}
|
|
13727
14120
|
}
|
|
13728
14121
|
},
|
|
@@ -14054,26 +14447,34 @@ var ja_JP_default = {
|
|
|
14054
14447
|
- \u30E6\u30FC\u30B6\u30FC\u304C\u30C1\u30E3\u30C3\u30C8\u5185\u5BB9\u3001\u6700\u8FD1\u306E\u8A71\u984C\u3001\u8AB0\u304B\u306E\u767A\u8A00\u3001\u30E9\u30F3\u30AD\u30F3\u30B0/\u7D71\u8A08\u3001\u3042\u308B\u8A71\u984C\u304C\u51FA\u305F\u304B\u3069\u3046\u304B\u3001\u307E\u305F\u306F\u539F\u6587\u5F15\u7528\u3092\u6C42\u3081\u305F\u5834\u5408\u306F\u3001\u5FC5\u305A\u5148\u306B\u9069\u5207\u306A\u30C7\u30FC\u30BF\u30C4\u30FC\u30EB\u3067\u73FE\u5728\u306E\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u691C\u7D22\u3059\u308B\u3002
|
|
14055
14448
|
- \u65B0\u3057\u3044\u30C1\u30E3\u30C3\u30C8\u8A18\u9332\u304C\u8FFD\u52A0\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u3001\u73FE\u5728\u306E\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306F\u53E4\u3044\u30A6\u30A3\u30F3\u30C9\u30A6\u5C65\u6B74\u3068\u7570\u306A\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B\u3002\u6700\u65B0\u306E\u8A3C\u62E0\u53D6\u5F97\u306B\u306F get_chat_overview \u307E\u305F\u306F get_recent_messages/search_messages \u3092\u512A\u5148\u3059\u308B\u3002
|
|
14056
14449
|
- \u4E8B\u5B9F\u6839\u62E0\u3068\u3057\u3066\u4F7F\u3048\u308B\u306E\u306F\u3001\u30C4\u30FC\u30EB\u304C\u8FD4\u3057\u305F\u30E1\u30C3\u30BB\u30FC\u30B8\u3001\u7D71\u8A08\u3001\u307E\u305F\u306F\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u6982\u8981\u306E\u307F\u3002\u30C4\u30FC\u30EB\u304C\u5341\u5206\u306A\u8A3C\u62E0\u3092\u8FD4\u3055\u306A\u3044\u5834\u5408\u306F\u3001\u30C7\u30FC\u30BF\u4E0D\u8DB3\u3068\u660E\u793A\u3057\u3001\u5B58\u5728\u3057\u306A\u3044\u30C1\u30E3\u30C3\u30C8\u8A18\u9332\u3092\u4F5C\u3089\u306A\u3044\u3002`,
|
|
14057
|
-
responseInstruction: "\u30E6\u30FC\u30B6\u30FC\u306E\u8CEA\u554F\u306B\u5FDC\u3058\u3066\u9069\u5207\u306A\u30C4\u30FC\u30EB\
|
|
14450
|
+
responseInstruction: "\u30E6\u30FC\u30B6\u30FC\u306E\u8CEA\u554F\u306B\u5FDC\u3058\u3066\u5FC5\u8981\u306A\u5834\u5408\u306F\u9069\u5207\u306A\u30C4\u30FC\u30EB\u3067\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u3001\u81EA\u7136\u304B\u3064\u7387\u76F4\u306B\u56DE\u7B54\u3059\u308B\u3002",
|
|
14058
14451
|
fallbackRoleDefinition: {
|
|
14059
|
-
group: `\u3042\u306A\u305F\u306F\u30D7\
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
\
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14452
|
+
group: `\u3042\u306A\u305F\u306F ChatLab \u306E\u30B0\u30EB\u30FC\u30D7\u30C1\u30E3\u30C3\u30C8\u5206\u6790\u30D1\u30FC\u30C8\u30CA\u30FC\u3067\u3059\u3002\u6A5F\u68B0\u7684\u306A\u5206\u6790\u30EC\u30DD\u30FC\u30C8\u3067\u306F\u306A\u304F\u3001\u8A18\u9332\u306B\u3042\u308B\u4E8B\u5B9F\u3001\u5909\u5316\u3001\u3084\u308A\u53D6\u308A\u306E\u50BE\u5411\u3092\u30E6\u30FC\u30B6\u30FC\u304C\u7406\u89E3\u3067\u304D\u308B\u3088\u3046\u652F\u63F4\u3057\u307E\u3059\u3002
|
|
14453
|
+
|
|
14454
|
+
## \u30B3\u30DF\u30E5\u30CB\u30B1\u30FC\u30B7\u30E7\u30F3
|
|
14455
|
+
- \u30E6\u30FC\u30B6\u30FC\u306E\u8A00\u8A9E\u3068\u8A71\u3057\u65B9\u306B\u5408\u308F\u305B\u3001\u30AB\u30B9\u30BF\u30DE\u30FC\u30B5\u30DD\u30FC\u30C8\u3084\u5805\u3044\u5831\u544A\u66F8\u306E\u3088\u3046\u3067\u306F\u306A\u304F\u3001\u81EA\u7136\u3067\u7387\u76F4\u306A\u8A00\u8449\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
14456
|
+
- \u7C21\u5358\u306A\u8CEA\u554F\u306B\u306F\u7AEF\u7684\u306B\u7B54\u3048\u3001\u8907\u96D1\u306A\u8CEA\u554F\u3060\u3051\u3092\u6574\u7406\u3057\u3066\u8AAC\u660E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u898B\u51FA\u3057\u3001\u7B87\u6761\u66F8\u304D\u3001\u8868\u306F\u7406\u89E3\u3092\u52A9\u3051\u308B\u5834\u5408\u306B\u3060\u3051\u4F7F\u3044\u307E\u3059\u3002
|
|
14457
|
+
- \u6839\u62E0\u304C\u5341\u5206\u306A\u3089\u660E\u78BA\u306A\u5224\u65AD\u3092\u793A\u3057\u3001\u78BA\u8A8D\u3067\u304D\u306A\u3044\u3053\u3068\u306F\u7387\u76F4\u306B\u4F1D\u3048\u3066\u304F\u3060\u3055\u3044\u3002
|
|
14458
|
+
- \u8EFD\u304F\u81EA\u7136\u306A\u30E6\u30FC\u30E2\u30A2\u306F\u69CB\u3044\u307E\u305B\u3093\u304C\u3001\u7121\u7406\u306B\u5197\u8AC7\u3084\u7D75\u6587\u5B57\u3092\u5165\u308C\u305F\u308A\u3001\u6B63\u78BA\u3055\u3092\u640D\u306A\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
14459
|
+
|
|
14460
|
+
## \u5206\u6790\u4E0A\u306E\u5883\u754C
|
|
14461
|
+
- \u78BA\u8A8D\u3067\u304D\u308B\u4E8B\u5B9F\u3001\u6839\u62E0\u306B\u57FA\u3065\u304F\u63A8\u6E2C\u3001\u73FE\u6642\u70B9\u3067\u306F\u5224\u65AD\u3067\u304D\u306A\u3044\u3053\u3068\u3092\u533A\u5225\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
14462
|
+
- \u6027\u683C\u3001\u611F\u60C5\u3001\u4EBA\u9593\u95A2\u4FC2\u3001\u52D5\u6A5F\u306F\u7279\u306B\u614E\u91CD\u306B\u6271\u3044\u3001\u5185\u9762\u3092\u4F5C\u308A\u4E0A\u3052\u305F\u308A\u3001\u5B89\u6613\u306B\u30EC\u30C3\u30C6\u30EB\u3092\u8CBC\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
14463
|
+
- \u4EE3\u8868\u7684\u306A\u767A\u8A00\u3084\u30C7\u30FC\u30BF\u306F\u5C11\u91CF\u5F15\u7528\u3067\u304D\u307E\u3059\u304C\u3001\u9577\u3044\u30C1\u30E3\u30C3\u30C8\u30ED\u30B0\u3092\u305D\u306E\u307E\u307E\u4E26\u3079\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
14464
|
+
- \u30E6\u30FC\u30B6\u30FC\u304C\u6C42\u3081\u306A\u3044\u9650\u308A\u3001\u8AAC\u6559\u3001\u983C\u307E\u308C\u3066\u3044\u306A\u3044\u4EBA\u751F\u76F8\u8AC7\u3001\u6BCE\u56DE\u306E\u30EC\u30DD\u30FC\u30C8\u5316\u306F\u907F\u3051\u3066\u304F\u3060\u3055\u3044\u3002`,
|
|
14465
|
+
private: `\u3042\u306A\u305F\u306F ChatLab \u306E\u500B\u4EBA\u30C1\u30E3\u30C3\u30C8\u5206\u6790\u30D1\u30FC\u30C8\u30CA\u30FC\u3067\u3059\u3002\u6A5F\u68B0\u7684\u306A\u5206\u6790\u30EC\u30DD\u30FC\u30C8\u3067\u306F\u306A\u304F\u3001\u8A18\u9332\u306B\u3042\u308B\u4E8B\u5B9F\u3001\u5909\u5316\u3001\u3084\u308A\u53D6\u308A\u306E\u50BE\u5411\u3092\u30E6\u30FC\u30B6\u30FC\u304C\u7406\u89E3\u3067\u304D\u308B\u3088\u3046\u652F\u63F4\u3057\u307E\u3059\u3002
|
|
14466
|
+
|
|
14467
|
+
## \u30B3\u30DF\u30E5\u30CB\u30B1\u30FC\u30B7\u30E7\u30F3
|
|
14468
|
+
- \u30E6\u30FC\u30B6\u30FC\u306E\u8A00\u8A9E\u3068\u8A71\u3057\u65B9\u306B\u5408\u308F\u305B\u3001\u30AB\u30B9\u30BF\u30DE\u30FC\u30B5\u30DD\u30FC\u30C8\u3084\u5805\u3044\u5831\u544A\u66F8\u306E\u3088\u3046\u3067\u306F\u306A\u304F\u3001\u81EA\u7136\u3067\u7387\u76F4\u306A\u8A00\u8449\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
14469
|
+
- \u7C21\u5358\u306A\u8CEA\u554F\u306B\u306F\u7AEF\u7684\u306B\u7B54\u3048\u3001\u8907\u96D1\u306A\u8CEA\u554F\u3060\u3051\u3092\u6574\u7406\u3057\u3066\u8AAC\u660E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u898B\u51FA\u3057\u3001\u7B87\u6761\u66F8\u304D\u3001\u8868\u306F\u7406\u89E3\u3092\u52A9\u3051\u308B\u5834\u5408\u306B\u3060\u3051\u4F7F\u3044\u307E\u3059\u3002
|
|
14470
|
+
- \u6839\u62E0\u304C\u5341\u5206\u306A\u3089\u660E\u78BA\u306A\u5224\u65AD\u3092\u793A\u3057\u3001\u78BA\u8A8D\u3067\u304D\u306A\u3044\u3053\u3068\u306F\u7387\u76F4\u306B\u4F1D\u3048\u3066\u304F\u3060\u3055\u3044\u3002
|
|
14471
|
+
- \u8EFD\u304F\u81EA\u7136\u306A\u30E6\u30FC\u30E2\u30A2\u306F\u69CB\u3044\u307E\u305B\u3093\u304C\u3001\u7121\u7406\u306B\u5197\u8AC7\u3084\u7D75\u6587\u5B57\u3092\u5165\u308C\u305F\u308A\u3001\u6B63\u78BA\u3055\u3092\u640D\u306A\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
14472
|
+
|
|
14473
|
+
## \u5206\u6790\u4E0A\u306E\u5883\u754C
|
|
14474
|
+
- \u78BA\u8A8D\u3067\u304D\u308B\u4E8B\u5B9F\u3001\u6839\u62E0\u306B\u57FA\u3065\u304F\u63A8\u6E2C\u3001\u73FE\u6642\u70B9\u3067\u306F\u5224\u65AD\u3067\u304D\u306A\u3044\u3053\u3068\u3092\u533A\u5225\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
14475
|
+
- \u6027\u683C\u3001\u611F\u60C5\u3001\u4EBA\u9593\u95A2\u4FC2\u3001\u52D5\u6A5F\u306F\u7279\u306B\u614E\u91CD\u306B\u6271\u3044\u3001\u5185\u9762\u3092\u4F5C\u308A\u4E0A\u3052\u305F\u308A\u3001\u5B89\u6613\u306B\u30EC\u30C3\u30C6\u30EB\u3092\u8CBC\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
14476
|
+
- \u4EE3\u8868\u7684\u306A\u767A\u8A00\u3084\u30C7\u30FC\u30BF\u306F\u5C11\u91CF\u5F15\u7528\u3067\u304D\u307E\u3059\u304C\u3001\u9577\u3044\u30C1\u30E3\u30C3\u30C8\u30ED\u30B0\u3092\u305D\u306E\u307E\u307E\u4E26\u3079\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
14477
|
+
- \u30E6\u30FC\u30B6\u30FC\u304C\u6C42\u3081\u306A\u3044\u9650\u308A\u3001\u8AAC\u6559\u3001\u983C\u307E\u308C\u3066\u3044\u306A\u3044\u4EBA\u751F\u76F8\u8AC7\u3001\u6BCE\u56DE\u306E\u30EC\u30DD\u30FC\u30C8\u5316\u306F\u907F\u3051\u3066\u304F\u3060\u3055\u3044\u3002`
|
|
14077
14478
|
}
|
|
14078
14479
|
}
|
|
14079
14480
|
},
|
|
@@ -14405,26 +14806,34 @@ var zh_TW_default = {
|
|
|
14405
14806
|
- \u53EA\u8981\u4F7F\u7528\u8005\u8A62\u554F\u804A\u5929\u7D00\u9304\u5167\u5BB9\u3001\u6700\u8FD1\u804A\u4EC0\u9EBC\u3001\u67D0\u4EBA\u8AAA\u904E\u4EC0\u9EBC\u3001\u7D71\u8A08\u6392\u884C\u3001\u662F\u5426\u51FA\u73FE\u904E\u67D0\u8A71\u984C\u6216\u8981\u6C42\u5F15\u7528\u539F\u8A71\uFF0C\u5FC5\u9808\u5148\u547C\u53EB\u5408\u9069\u7684\u8CC7\u6599\u5DE5\u5177\u6AA2\u7D22\u76EE\u524D\u8CC7\u6599\u5EAB\u3002
|
|
14406
14807
|
- \u5982\u679C\u5DF2\u8FFD\u52A0\u65B0\u804A\u5929\u7D00\u9304\uFF0C\u76EE\u524D\u8CC7\u6599\u5EAB\u53EF\u80FD\u4E0D\u540C\u65BC\u820A\u8996\u7A97\u6B77\u53F2\uFF1B\u512A\u5148\u4F7F\u7528 get_chat_overview \u6216 get_recent_messages/search_messages \u53D6\u5F97\u6700\u65B0\u8B49\u64DA\u3002
|
|
14407
14808
|
- \u53EA\u6709\u5DE5\u5177\u56DE\u50B3\u7684\u8A0A\u606F\u3001\u7D71\u8A08\u6216\u8CC7\u6599\u5EAB\u6982\u89BD\u53EF\u4EE5\u4F5C\u70BA\u4E8B\u5BE6\u4F9D\u64DA\uFF1B\u5DE5\u5177\u6C92\u6709\u56DE\u50B3\u8DB3\u5920\u8B49\u64DA\u6642\uFF0C\u660E\u78BA\u8AAA\u660E\u8CC7\u6599\u4E0D\u8DB3\uFF0C\u4E0D\u8981\u7DE8\u9020\u4E0D\u5B58\u5728\u7684\u804A\u5929\u7D00\u9304\u3002`,
|
|
14408
|
-
responseInstruction: "\u6839\u64DA\u4F7F\u7528\u8005\u7684\u554F\u984C\uFF0C\u9078\u64C7\u5408\u9069\u7684\u5DE5\u5177\u53D6\u5F97\u8CC7\u6599\uFF0C\u7136\u5F8C\
|
|
14809
|
+
responseInstruction: "\u6839\u64DA\u4F7F\u7528\u8005\u7684\u554F\u984C\uFF0C\u5728\u9700\u8981\u6642\u9078\u64C7\u5408\u9069\u7684\u5DE5\u5177\u53D6\u5F97\u8CC7\u6599\uFF0C\u7136\u5F8C\u81EA\u7136\u3001\u76F4\u63A5\u5730\u7D66\u51FA\u56DE\u7B54\u3002",
|
|
14409
14810
|
fallbackRoleDefinition: {
|
|
14410
|
-
group: `\u4F60\u662F\
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
\
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14811
|
+
group: `\u4F60\u662F ChatLab \u88E1\u7684\u7FA4\u804A\u8A18\u9304\u5206\u6790\u642D\u6A94\uFF0C\u5E6B\u52A9\u4F7F\u7528\u8005\u5F9E\u804A\u5929\u8A18\u9304\u4E2D\u7406\u89E3\u4E8B\u5BE6\u3001\u8B8A\u5316\u548C\u4E92\u52D5\u6A21\u5F0F\uFF0C\u800C\u4E0D\u662F\u6A5F\u68B0\u5730\u7522\u751F\u5206\u6790\u5831\u544A\u3002
|
|
14812
|
+
|
|
14813
|
+
## \u4EA4\u6D41\u65B9\u5F0F
|
|
14814
|
+
- \u8DDF\u96A8\u4F7F\u7528\u8005\u7684\u8A9E\u8A00\u548C\u4EA4\u6D41\u65B9\u5F0F\uFF0C\u8AAA\u81EA\u7136\u3001\u76F4\u63A5\u7684\u4EBA\u8A71\uFF0C\u907F\u514D\u5BA2\u670D\u8154\u548C\u904E\u5EA6\u6B63\u5F0F\u7684\u8868\u9054\u3002
|
|
14815
|
+
- \u7C21\u55AE\u554F\u984C\u76F4\u63A5\u56DE\u7B54\uFF1B\u8907\u96DC\u554F\u984C\u518D\u5206\u5C64\u8AAA\u660E\u3002\u6A19\u984C\u3001\u5217\u8868\u548C\u8868\u683C\u53EA\u5728\u6709\u52A9\u65BC\u7406\u89E3\u6642\u4F7F\u7528\u3002
|
|
14816
|
+
- \u5728\u8B49\u64DA\u5141\u8A31\u6642\u7D66\u51FA\u660E\u78BA\u5224\u65B7\uFF1B\u7121\u6CD5\u78BA\u8A8D\u7684\u90E8\u5206\u8981\u5766\u7387\u8AAA\u660E\u3002
|
|
14817
|
+
- \u53EF\u4EE5\u6709\u4E00\u9EDE\u81EA\u7136\u7684\u5E7D\u9ED8\u611F\uFF0C\u4F46\u4E0D\u8981\u5F37\u884C\u73A9\u6897\u3001\u5806\u8868\u60C5\u6216\u72A7\u7272\u6E96\u78BA\u6027\u3002
|
|
14818
|
+
|
|
14819
|
+
## \u5206\u6790\u908A\u754C
|
|
14820
|
+
- \u5340\u5206\u80FD\u5920\u78BA\u8A8D\u7684\u4E8B\u5BE6\u3001\u57FA\u65BC\u8B49\u64DA\u7684\u63A8\u8AD6\uFF0C\u4EE5\u53CA\u66AB\u6642\u7121\u6CD5\u5224\u65B7\u7684\u90E8\u5206\u3002
|
|
14821
|
+
- \u6D89\u53CA\u6027\u683C\u3001\u60C5\u7DD2\u3001\u95DC\u4FC2\u548C\u52D5\u6A5F\u6642\u5C24\u5176\u8B39\u614E\uFF0C\u4E0D\u7DE8\u9020\u5FC3\u7406\u6D3B\u52D5\uFF0C\u4E5F\u4E0D\u8F15\u6613\u7D66\u4EBA\u8CBC\u6A19\u7C64\u3002
|
|
14822
|
+
- \u9069\u91CF\u5F15\u7528\u6709\u4EE3\u8868\u6027\u7684\u539F\u8A71\u548C\u8CC7\u6599\uFF0C\u4E0D\u8981\u5927\u6BB5\u5806\u780C\u804A\u5929\u8A18\u9304\u3002
|
|
14823
|
+
- \u9664\u975E\u4F7F\u7528\u8005\u660E\u78BA\u8981\u6C42\uFF0C\u4E0D\u8AAA\u6559\u3001\u4E0D\u64C5\u81EA\u7D66\u4EBA\u751F\u5EFA\u8B70\uFF0C\u4E5F\u4E0D\u628A\u6BCF\u6B21\u56DE\u7B54\u90FD\u5BEB\u6210\u7E3D\u7D50\u5831\u544A\u3002`,
|
|
14824
|
+
private: `\u4F60\u662F ChatLab \u88E1\u7684\u79C1\u804A\u8A18\u9304\u5206\u6790\u642D\u6A94\uFF0C\u5E6B\u52A9\u4F7F\u7528\u8005\u5F9E\u804A\u5929\u8A18\u9304\u4E2D\u7406\u89E3\u4E8B\u5BE6\u3001\u8B8A\u5316\u548C\u4E92\u52D5\u65B9\u5F0F\uFF0C\u800C\u4E0D\u662F\u6A5F\u68B0\u5730\u7522\u751F\u5206\u6790\u5831\u544A\u3002
|
|
14825
|
+
|
|
14826
|
+
## \u4EA4\u6D41\u65B9\u5F0F
|
|
14827
|
+
- \u8DDF\u96A8\u4F7F\u7528\u8005\u7684\u8A9E\u8A00\u548C\u4EA4\u6D41\u65B9\u5F0F\uFF0C\u8AAA\u81EA\u7136\u3001\u76F4\u63A5\u7684\u4EBA\u8A71\uFF0C\u907F\u514D\u5BA2\u670D\u8154\u548C\u904E\u5EA6\u6B63\u5F0F\u7684\u8868\u9054\u3002
|
|
14828
|
+
- \u7C21\u55AE\u554F\u984C\u76F4\u63A5\u56DE\u7B54\uFF1B\u8907\u96DC\u554F\u984C\u518D\u5206\u5C64\u8AAA\u660E\u3002\u6A19\u984C\u3001\u5217\u8868\u548C\u8868\u683C\u53EA\u5728\u6709\u52A9\u65BC\u7406\u89E3\u6642\u4F7F\u7528\u3002
|
|
14829
|
+
- \u5728\u8B49\u64DA\u5141\u8A31\u6642\u7D66\u51FA\u660E\u78BA\u5224\u65B7\uFF1B\u7121\u6CD5\u78BA\u8A8D\u7684\u90E8\u5206\u8981\u5766\u7387\u8AAA\u660E\u3002
|
|
14830
|
+
- \u53EF\u4EE5\u6709\u4E00\u9EDE\u81EA\u7136\u7684\u5E7D\u9ED8\u611F\uFF0C\u4F46\u4E0D\u8981\u5F37\u884C\u73A9\u6897\u3001\u5806\u8868\u60C5\u6216\u72A7\u7272\u6E96\u78BA\u6027\u3002
|
|
14831
|
+
|
|
14832
|
+
## \u5206\u6790\u908A\u754C
|
|
14833
|
+
- \u5340\u5206\u80FD\u5920\u78BA\u8A8D\u7684\u4E8B\u5BE6\u3001\u57FA\u65BC\u8B49\u64DA\u7684\u63A8\u8AD6\uFF0C\u4EE5\u53CA\u66AB\u6642\u7121\u6CD5\u5224\u65B7\u7684\u90E8\u5206\u3002
|
|
14834
|
+
- \u6D89\u53CA\u6027\u683C\u3001\u60C5\u7DD2\u3001\u95DC\u4FC2\u548C\u52D5\u6A5F\u6642\u5C24\u5176\u8B39\u614E\uFF0C\u4E0D\u7DE8\u9020\u5FC3\u7406\u6D3B\u52D5\uFF0C\u4E5F\u4E0D\u8F15\u6613\u7D66\u4EBA\u8CBC\u6A19\u7C64\u3002
|
|
14835
|
+
- \u9069\u91CF\u5F15\u7528\u6709\u4EE3\u8868\u6027\u7684\u539F\u8A71\u548C\u8CC7\u6599\uFF0C\u4E0D\u8981\u5927\u6BB5\u5806\u780C\u804A\u5929\u8A18\u9304\u3002
|
|
14836
|
+
- \u9664\u975E\u4F7F\u7528\u8005\u660E\u78BA\u8981\u6C42\uFF0C\u4E0D\u8AAA\u6559\u3001\u4E0D\u64C5\u81EA\u7D66\u4EBA\u751F\u5EFA\u8B70\uFF0C\u4E5F\u4E0D\u628A\u6BCF\u6B21\u56DE\u7B54\u90FD\u5BEB\u6210\u7E3D\u7D50\u5831\u544A\u3002`
|
|
14428
14837
|
}
|
|
14429
14838
|
}
|
|
14430
14839
|
},
|
|
@@ -14456,9 +14865,9 @@ var localeMap = {
|
|
|
14456
14865
|
"ja-JP": ja_JP_default,
|
|
14457
14866
|
"zh-TW": zh_TW_default
|
|
14458
14867
|
};
|
|
14459
|
-
function getNestedValue(obj,
|
|
14868
|
+
function getNestedValue(obj, path33) {
|
|
14460
14869
|
let current = obj;
|
|
14461
|
-
for (const segment2 of
|
|
14870
|
+
for (const segment2 of path33.split(".")) {
|
|
14462
14871
|
if (current == null || typeof current !== "object") return void 0;
|
|
14463
14872
|
current = current[segment2];
|
|
14464
14873
|
}
|
|
@@ -14971,6 +15380,49 @@ var LLMConfigStore = class {
|
|
|
14971
15380
|
}
|
|
14972
15381
|
};
|
|
14973
15382
|
|
|
15383
|
+
// ../../packages/node-runtime/src/ai/file-config-storage.ts
|
|
15384
|
+
import * as fs28 from "fs";
|
|
15385
|
+
import * as path25 from "path";
|
|
15386
|
+
function createFileConfigStorage(baseDir) {
|
|
15387
|
+
return {
|
|
15388
|
+
readJson(key) {
|
|
15389
|
+
try {
|
|
15390
|
+
return JSON.parse(fs28.readFileSync(path25.join(baseDir, `${key}.json`), "utf-8"));
|
|
15391
|
+
} catch {
|
|
15392
|
+
return null;
|
|
15393
|
+
}
|
|
15394
|
+
},
|
|
15395
|
+
writeJson(key, data) {
|
|
15396
|
+
fs28.mkdirSync(baseDir, { recursive: true });
|
|
15397
|
+
fs28.writeFileSync(path25.join(baseDir, `${key}.json`), JSON.stringify(data, null, 2), "utf-8");
|
|
15398
|
+
}
|
|
15399
|
+
};
|
|
15400
|
+
}
|
|
15401
|
+
|
|
15402
|
+
// ../../packages/node-runtime/src/ai/auth-profile-llm-config-store.ts
|
|
15403
|
+
var defaultDeps = {
|
|
15404
|
+
resolveApiKey: (provider, authProfile) => resolveApiKey(provider, authProfile) || void 0,
|
|
15405
|
+
writeAuthProfile,
|
|
15406
|
+
deleteAuthProfile
|
|
15407
|
+
};
|
|
15408
|
+
function getAuthProfile2(config) {
|
|
15409
|
+
return config.authProfile;
|
|
15410
|
+
}
|
|
15411
|
+
function createAuthProfileLlmConfigStore(storage, deps = defaultDeps) {
|
|
15412
|
+
return new LLMConfigStore(storage, {
|
|
15413
|
+
resolveApiKey: deps.resolveApiKey,
|
|
15414
|
+
onApiKeyCreated: (config, apiKey) => {
|
|
15415
|
+
const profileName = config.name?.toLowerCase().replace(/\s+/g, "-") || config.provider;
|
|
15416
|
+
deps.writeAuthProfile(profileName, { type: "api_key", provider: config.provider, key: apiKey });
|
|
15417
|
+
return profileName;
|
|
15418
|
+
},
|
|
15419
|
+
onApiKeyDeleted: (config) => {
|
|
15420
|
+
const profileName = getAuthProfile2(config);
|
|
15421
|
+
if (profileName) deps.deleteAuthProfile(profileName);
|
|
15422
|
+
}
|
|
15423
|
+
});
|
|
15424
|
+
}
|
|
15425
|
+
|
|
14974
15426
|
// ../../packages/node-runtime/src/ai/custom-store.ts
|
|
14975
15427
|
function generateCustomId() {
|
|
14976
15428
|
return `custom:${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
@@ -15790,8 +16242,8 @@ function exportWithFormat(params, openDatabase) {
|
|
|
15790
16242
|
}
|
|
15791
16243
|
|
|
15792
16244
|
// ../../packages/node-runtime/src/merger/temp-db.ts
|
|
15793
|
-
import * as
|
|
15794
|
-
import * as
|
|
16245
|
+
import * as fs29 from "fs";
|
|
16246
|
+
import * as path26 from "path";
|
|
15795
16247
|
var TEMP_DB_SCHEMA = `
|
|
15796
16248
|
CREATE TABLE IF NOT EXISTS meta (
|
|
15797
16249
|
name TEXT NOT NULL,
|
|
@@ -16036,21 +16488,21 @@ function exportSessionToJson(db) {
|
|
|
16036
16488
|
}
|
|
16037
16489
|
function deleteTempDatabase(dbPath) {
|
|
16038
16490
|
try {
|
|
16039
|
-
if (
|
|
16491
|
+
if (fs29.existsSync(dbPath)) fs29.unlinkSync(dbPath);
|
|
16040
16492
|
const walPath = dbPath + "-wal";
|
|
16041
16493
|
const shmPath = dbPath + "-shm";
|
|
16042
|
-
if (
|
|
16043
|
-
if (
|
|
16494
|
+
if (fs29.existsSync(walPath)) fs29.unlinkSync(walPath);
|
|
16495
|
+
if (fs29.existsSync(shmPath)) fs29.unlinkSync(shmPath);
|
|
16044
16496
|
} catch {
|
|
16045
16497
|
}
|
|
16046
16498
|
}
|
|
16047
16499
|
function cleanupTempDatabases(tempDir) {
|
|
16048
16500
|
try {
|
|
16049
|
-
if (!
|
|
16050
|
-
const files =
|
|
16501
|
+
if (!fs29.existsSync(tempDir)) return;
|
|
16502
|
+
const files = fs29.readdirSync(tempDir);
|
|
16051
16503
|
for (const file of files) {
|
|
16052
16504
|
if (file.startsWith("merge_") && file.endsWith(".db")) {
|
|
16053
|
-
deleteTempDatabase(
|
|
16505
|
+
deleteTempDatabase(path26.join(tempDir, file));
|
|
16054
16506
|
}
|
|
16055
16507
|
}
|
|
16056
16508
|
} catch {
|
|
@@ -16129,6 +16581,7 @@ function deleteSession(adapter, sessionId) {
|
|
|
16129
16581
|
var member_service_exports = {};
|
|
16130
16582
|
__export(member_service_exports, {
|
|
16131
16583
|
deleteMember: () => deleteMember2,
|
|
16584
|
+
deleteMembers: () => deleteMembers2,
|
|
16132
16585
|
getMemberNameHistory: () => getMemberNameHistory2,
|
|
16133
16586
|
getMembers: () => getMembers,
|
|
16134
16587
|
getMembersPaginated: () => getMembersPaginated2,
|
|
@@ -16162,6 +16615,10 @@ function deleteMember2(adapter, sessionId, memberId) {
|
|
|
16162
16615
|
const db = adapter.ensureWritable(sessionId);
|
|
16163
16616
|
return deleteMember(db, memberId);
|
|
16164
16617
|
}
|
|
16618
|
+
function deleteMembers2(adapter, sessionId, memberIds) {
|
|
16619
|
+
const db = adapter.ensureWritable(sessionId);
|
|
16620
|
+
return deleteMembers(db, memberIds);
|
|
16621
|
+
}
|
|
16165
16622
|
function getMemberNameHistory2(adapter, sessionId, memberId) {
|
|
16166
16623
|
const db = adapter.ensureReadonly(sessionId);
|
|
16167
16624
|
return getMemberNameHistory(db, memberId);
|
|
@@ -16430,8 +16887,8 @@ function clearSessionOwner(adapter, sessionId) {
|
|
|
16430
16887
|
}
|
|
16431
16888
|
|
|
16432
16889
|
// ../../packages/node-runtime/src/services/contacts/overrides.ts
|
|
16433
|
-
import
|
|
16434
|
-
import
|
|
16890
|
+
import fs30 from "fs";
|
|
16891
|
+
import path27 from "path";
|
|
16435
16892
|
var CONTACT_OVERRIDES_FILE_NAME = "contact-overrides.json";
|
|
16436
16893
|
var CONTACT_OVERRIDES_TMP_PREFIX = "contact-overrides.tmp-";
|
|
16437
16894
|
var CONTACT_OVERRIDES_VERSION = 1;
|
|
@@ -16442,23 +16899,23 @@ function createEmptyContactOverridesFile() {
|
|
|
16442
16899
|
};
|
|
16443
16900
|
}
|
|
16444
16901
|
function getContactOverridesPath(snapshotDir) {
|
|
16445
|
-
return
|
|
16902
|
+
return path27.join(snapshotDir, CONTACT_OVERRIDES_FILE_NAME);
|
|
16446
16903
|
}
|
|
16447
16904
|
function readContactOverrides(snapshotDir) {
|
|
16448
16905
|
const filePath = getContactOverridesPath(snapshotDir);
|
|
16449
|
-
if (!
|
|
16906
|
+
if (!fs30.existsSync(filePath)) return createEmptyContactOverridesFile();
|
|
16450
16907
|
try {
|
|
16451
|
-
return normalizeContactOverrides(JSON.parse(
|
|
16908
|
+
return normalizeContactOverrides(JSON.parse(fs30.readFileSync(filePath, "utf-8")));
|
|
16452
16909
|
} catch (error) {
|
|
16453
16910
|
appLogger.warn("contacts", "contact overrides file is unreadable", error);
|
|
16454
16911
|
return createEmptyContactOverridesFile();
|
|
16455
16912
|
}
|
|
16456
16913
|
}
|
|
16457
16914
|
function writeContactOverrides(snapshotDir, overrides) {
|
|
16458
|
-
if (!
|
|
16459
|
-
const tmpPath =
|
|
16460
|
-
|
|
16461
|
-
|
|
16915
|
+
if (!fs30.existsSync(snapshotDir)) fs30.mkdirSync(snapshotDir, { recursive: true });
|
|
16916
|
+
const tmpPath = path27.join(snapshotDir, `${CONTACT_OVERRIDES_TMP_PREFIX}${process.pid}-${Date.now()}`);
|
|
16917
|
+
fs30.writeFileSync(tmpPath, JSON.stringify(normalizeContactOverrides(overrides), null, 2), "utf-8");
|
|
16918
|
+
fs30.renameSync(tmpPath, getContactOverridesPath(snapshotDir));
|
|
16462
16919
|
}
|
|
16463
16920
|
function normalizeContactOverrides(value) {
|
|
16464
16921
|
const input = isRecord2(value) ? value : {};
|
|
@@ -16493,23 +16950,23 @@ function buildContactsSignature(adapter, timeRangePreset) {
|
|
|
16493
16950
|
}
|
|
16494
16951
|
|
|
16495
16952
|
// ../../packages/node-runtime/src/services/contacts/snapshot.ts
|
|
16496
|
-
import
|
|
16497
|
-
import
|
|
16953
|
+
import fs31 from "fs";
|
|
16954
|
+
import path28 from "path";
|
|
16498
16955
|
var CONTACTS_SNAPSHOT_TMP_PREFIX = "contacts-snapshot.tmp-";
|
|
16499
16956
|
function getContactsSnapshotPath(snapshotDir, timeRangePreset) {
|
|
16500
16957
|
const preset = normalizeContactsTimeRangePreset(timeRangePreset);
|
|
16501
|
-
return
|
|
16958
|
+
return path28.join(snapshotDir, `contacts-snapshot-${preset}.json`);
|
|
16502
16959
|
}
|
|
16503
16960
|
function readContactsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
|
|
16504
16961
|
const snapshotPath = getContactsSnapshotPath(snapshotDir, timeRangePreset);
|
|
16505
|
-
if (!
|
|
16962
|
+
if (!fs31.existsSync(snapshotPath)) return null;
|
|
16506
16963
|
try {
|
|
16507
|
-
return JSON.parse(
|
|
16964
|
+
return JSON.parse(fs31.readFileSync(snapshotPath, "utf-8"));
|
|
16508
16965
|
} catch (error) {
|
|
16509
16966
|
const ts = options2.now?.() ?? Date.now();
|
|
16510
|
-
const backupPath =
|
|
16967
|
+
const backupPath = path28.join(snapshotDir, `contacts-snapshot.corrupt-${ts}.json`);
|
|
16511
16968
|
try {
|
|
16512
|
-
|
|
16969
|
+
fs31.renameSync(snapshotPath, backupPath);
|
|
16513
16970
|
} catch (renameError) {
|
|
16514
16971
|
appLogger.warn("contacts", "failed to backup corrupt contacts snapshot", renameError);
|
|
16515
16972
|
}
|
|
@@ -16518,17 +16975,17 @@ function readContactsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
|
|
|
16518
16975
|
}
|
|
16519
16976
|
}
|
|
16520
16977
|
function writeContactsSnapshot(snapshotDir, snapshot) {
|
|
16521
|
-
if (!
|
|
16522
|
-
const tmpPath =
|
|
16523
|
-
|
|
16524
|
-
|
|
16978
|
+
if (!fs31.existsSync(snapshotDir)) fs31.mkdirSync(snapshotDir, { recursive: true });
|
|
16979
|
+
const tmpPath = path28.join(snapshotDir, `${CONTACTS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
|
|
16980
|
+
fs31.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
16981
|
+
fs31.renameSync(tmpPath, getContactsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
|
|
16525
16982
|
}
|
|
16526
16983
|
function cleanupContactsSnapshotTempFiles(snapshotDir) {
|
|
16527
|
-
if (!
|
|
16528
|
-
for (const name of
|
|
16984
|
+
if (!fs31.existsSync(snapshotDir)) return;
|
|
16985
|
+
for (const name of fs31.readdirSync(snapshotDir)) {
|
|
16529
16986
|
if (!name.startsWith(CONTACTS_SNAPSHOT_TMP_PREFIX)) continue;
|
|
16530
16987
|
try {
|
|
16531
|
-
|
|
16988
|
+
fs31.rmSync(path28.join(snapshotDir, name), { force: true });
|
|
16532
16989
|
} catch (error) {
|
|
16533
16990
|
appLogger.warn("contacts", "failed to remove contacts snapshot temp file", error);
|
|
16534
16991
|
}
|
|
@@ -16566,7 +17023,7 @@ function createWorker(workerData, entryUrlInput) {
|
|
|
16566
17023
|
return new Worker(bootstrap, options2);
|
|
16567
17024
|
}
|
|
16568
17025
|
function createContactsWorkerRunner(options2) {
|
|
16569
|
-
return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((
|
|
17026
|
+
return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((resolve4, reject) => {
|
|
16570
17027
|
if (signal.aborted) {
|
|
16571
17028
|
reject(createAbortError());
|
|
16572
17029
|
return;
|
|
@@ -16597,7 +17054,7 @@ function createContactsWorkerRunner(options2) {
|
|
|
16597
17054
|
if (message.type === "success" && message.snapshot) {
|
|
16598
17055
|
settled = true;
|
|
16599
17056
|
signal.removeEventListener("abort", abort);
|
|
16600
|
-
|
|
17057
|
+
resolve4(message.snapshot);
|
|
16601
17058
|
void worker.terminate();
|
|
16602
17059
|
return;
|
|
16603
17060
|
}
|
|
@@ -17026,23 +17483,23 @@ function buildPeopleRelationshipsSignature(adapter, timeRangePreset) {
|
|
|
17026
17483
|
}
|
|
17027
17484
|
|
|
17028
17485
|
// ../../packages/node-runtime/src/services/people/relationships/snapshot.ts
|
|
17029
|
-
import
|
|
17030
|
-
import
|
|
17486
|
+
import fs32 from "fs";
|
|
17487
|
+
import path29 from "path";
|
|
17031
17488
|
var PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX = "people-relationships-snapshot.tmp-";
|
|
17032
17489
|
function getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset) {
|
|
17033
17490
|
const preset = normalizePeopleRelationshipsTimeRangePreset(timeRangePreset);
|
|
17034
|
-
return
|
|
17491
|
+
return path29.join(snapshotDir, `graph-snapshot-${preset}.json`);
|
|
17035
17492
|
}
|
|
17036
17493
|
function readPeopleRelationshipsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
|
|
17037
17494
|
const snapshotPath = getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset);
|
|
17038
|
-
if (!
|
|
17495
|
+
if (!fs32.existsSync(snapshotPath)) return null;
|
|
17039
17496
|
try {
|
|
17040
|
-
return JSON.parse(
|
|
17497
|
+
return JSON.parse(fs32.readFileSync(snapshotPath, "utf-8"));
|
|
17041
17498
|
} catch (error) {
|
|
17042
17499
|
const ts = options2.now?.() ?? Date.now();
|
|
17043
|
-
const backupPath =
|
|
17500
|
+
const backupPath = path29.join(snapshotDir, `graph-snapshot.corrupt-${ts}.json`);
|
|
17044
17501
|
try {
|
|
17045
|
-
|
|
17502
|
+
fs32.renameSync(snapshotPath, backupPath);
|
|
17046
17503
|
} catch (renameError) {
|
|
17047
17504
|
appLogger.warn("people-relationships", "failed to backup corrupt people relationships snapshot", renameError);
|
|
17048
17505
|
}
|
|
@@ -17051,17 +17508,17 @@ function readPeopleRelationshipsSnapshot(snapshotDir, timeRangePreset, options2
|
|
|
17051
17508
|
}
|
|
17052
17509
|
}
|
|
17053
17510
|
function writePeopleRelationshipsSnapshot(snapshotDir, snapshot) {
|
|
17054
|
-
if (!
|
|
17055
|
-
const tmpPath =
|
|
17056
|
-
|
|
17057
|
-
|
|
17511
|
+
if (!fs32.existsSync(snapshotDir)) fs32.mkdirSync(snapshotDir, { recursive: true });
|
|
17512
|
+
const tmpPath = path29.join(snapshotDir, `${PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
|
|
17513
|
+
fs32.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
17514
|
+
fs32.renameSync(tmpPath, getPeopleRelationshipsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
|
|
17058
17515
|
}
|
|
17059
17516
|
function cleanupPeopleRelationshipsSnapshotTempFiles(snapshotDir) {
|
|
17060
|
-
if (!
|
|
17061
|
-
for (const name of
|
|
17517
|
+
if (!fs32.existsSync(snapshotDir)) return;
|
|
17518
|
+
for (const name of fs32.readdirSync(snapshotDir)) {
|
|
17062
17519
|
if (!name.startsWith(PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX)) continue;
|
|
17063
17520
|
try {
|
|
17064
|
-
|
|
17521
|
+
fs32.rmSync(path29.join(snapshotDir, name), { force: true });
|
|
17065
17522
|
} catch (error) {
|
|
17066
17523
|
appLogger.warn("people-relationships", "failed to remove people relationships snapshot temp file", error);
|
|
17067
17524
|
}
|
|
@@ -17099,7 +17556,7 @@ function createWorker2(workerData, entryUrlInput) {
|
|
|
17099
17556
|
return new Worker2(bootstrap, options2);
|
|
17100
17557
|
}
|
|
17101
17558
|
function createPeopleRelationshipsWorkerRunner(options2) {
|
|
17102
|
-
return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((
|
|
17559
|
+
return ({ signature, timeRangePreset, signal, onProgress }) => new Promise((resolve4, reject) => {
|
|
17103
17560
|
if (signal.aborted) {
|
|
17104
17561
|
reject(createAbortError2());
|
|
17105
17562
|
return;
|
|
@@ -17130,7 +17587,7 @@ function createPeopleRelationshipsWorkerRunner(options2) {
|
|
|
17130
17587
|
if (message.type === "success" && message.snapshot) {
|
|
17131
17588
|
settled = true;
|
|
17132
17589
|
signal.removeEventListener("abort", abort);
|
|
17133
|
-
|
|
17590
|
+
resolve4(message.snapshot);
|
|
17134
17591
|
void worker.terminate();
|
|
17135
17592
|
return;
|
|
17136
17593
|
}
|
|
@@ -17583,7 +18040,7 @@ __export(relationships_exports, {
|
|
|
17583
18040
|
});
|
|
17584
18041
|
|
|
17585
18042
|
// ../../packages/node-runtime/src/services/global-insight/service.ts
|
|
17586
|
-
import
|
|
18043
|
+
import fs33 from "fs";
|
|
17587
18044
|
|
|
17588
18045
|
// ../../packages/node-runtime/src/services/global-insight/signature.ts
|
|
17589
18046
|
function buildAnnualSummarySignature(adapter, range) {
|
|
@@ -17610,7 +18067,7 @@ function resolveDefaultAnnualSummaryWorkerEntryUrl(currentModuleUrl = import.met
|
|
|
17610
18067
|
return entryExists(sibling) ? sibling : new URL("./global-insight-worker.js", moduleUrl);
|
|
17611
18068
|
}
|
|
17612
18069
|
function createAnnualSummaryWorkerRunner(options2) {
|
|
17613
|
-
return ({ signature, range, signal, onProgress }) => new Promise((
|
|
18070
|
+
return ({ signature, range, signal, onProgress }) => new Promise((resolve4, reject) => {
|
|
17614
18071
|
if (signal.aborted) {
|
|
17615
18072
|
reject(new Error("annual summary worker aborted"));
|
|
17616
18073
|
return;
|
|
@@ -17641,7 +18098,7 @@ function createAnnualSummaryWorkerRunner(options2) {
|
|
|
17641
18098
|
if (message.type === "success" && message.snapshot) {
|
|
17642
18099
|
settled = true;
|
|
17643
18100
|
signal.removeEventListener("abort", abort);
|
|
17644
|
-
|
|
18101
|
+
resolve4(message.snapshot);
|
|
17645
18102
|
void worker.terminate();
|
|
17646
18103
|
return;
|
|
17647
18104
|
}
|
|
@@ -17836,7 +18293,7 @@ var DefaultGlobalInsightService = class {
|
|
|
17836
18293
|
}
|
|
17837
18294
|
getSnapshot(range) {
|
|
17838
18295
|
const key = toAnnualSummaryRangeKey(range);
|
|
17839
|
-
if (this.snapshots.has(key) && !
|
|
18296
|
+
if (this.snapshots.has(key) && !fs33.existsSync(getAnnualSummarySnapshotPath(this.snapshotDir, range))) {
|
|
17840
18297
|
this.snapshots.delete(key);
|
|
17841
18298
|
}
|
|
17842
18299
|
if (!this.snapshots.has(key)) {
|
|
@@ -17884,8 +18341,8 @@ __export(global_insight_exports, {
|
|
|
17884
18341
|
});
|
|
17885
18342
|
|
|
17886
18343
|
// ../../packages/node-runtime/src/semantic-index/config.ts
|
|
17887
|
-
import
|
|
17888
|
-
import
|
|
18344
|
+
import fs34 from "fs";
|
|
18345
|
+
import path30 from "path";
|
|
17889
18346
|
var DEFAULT_SEMANTIC_INDEX_MODEL_DOWNLOAD_SOURCE = "huggingface";
|
|
17890
18347
|
var SEMANTIC_INDEX_CONFIG_VERSION = 1;
|
|
17891
18348
|
var SEARCH_MAX_RESULTS_DEFAULT = 10;
|
|
@@ -17974,9 +18431,9 @@ var SemanticIndexConfigStore = class {
|
|
|
17974
18431
|
return this.set({ ...this.get(), enabled });
|
|
17975
18432
|
}
|
|
17976
18433
|
get() {
|
|
17977
|
-
if (!
|
|
18434
|
+
if (!fs34.existsSync(this.filePath)) return defaultSemanticIndexConfig();
|
|
17978
18435
|
try {
|
|
17979
|
-
const raw = JSON.parse(
|
|
18436
|
+
const raw = JSON.parse(fs34.readFileSync(this.filePath, "utf-8"));
|
|
17980
18437
|
return normalizeConfig(raw);
|
|
17981
18438
|
} catch {
|
|
17982
18439
|
return defaultSemanticIndexConfig();
|
|
@@ -17984,9 +18441,9 @@ var SemanticIndexConfigStore = class {
|
|
|
17984
18441
|
}
|
|
17985
18442
|
set(config) {
|
|
17986
18443
|
const normalized = normalizeConfig(config);
|
|
17987
|
-
const dir =
|
|
17988
|
-
if (!
|
|
17989
|
-
|
|
18444
|
+
const dir = path30.dirname(this.filePath);
|
|
18445
|
+
if (!fs34.existsSync(dir)) fs34.mkdirSync(dir, { recursive: true });
|
|
18446
|
+
fs34.writeFileSync(this.filePath, JSON.stringify(normalized, null, 2), "utf-8");
|
|
17990
18447
|
return normalized;
|
|
17991
18448
|
}
|
|
17992
18449
|
resolveModelId() {
|
|
@@ -17995,7 +18452,7 @@ var SemanticIndexConfigStore = class {
|
|
|
17995
18452
|
};
|
|
17996
18453
|
|
|
17997
18454
|
// ../../packages/node-runtime/src/semantic-index/service.ts
|
|
17998
|
-
import
|
|
18455
|
+
import path31 from "path";
|
|
17999
18456
|
|
|
18000
18457
|
// ../../packages/node-runtime/src/semantic-index/chunker-config.ts
|
|
18001
18458
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -18316,8 +18773,8 @@ function createEmbedder(config, deps = {}) {
|
|
|
18316
18773
|
if (!config.api || !config.api.baseUrl || !config.api.model) {
|
|
18317
18774
|
throw new Error("semantic index API config incomplete: baseUrl and model are required");
|
|
18318
18775
|
}
|
|
18319
|
-
const
|
|
18320
|
-
const apiKey =
|
|
18776
|
+
const resolve4 = deps.resolveApiKey ?? resolveApiKey;
|
|
18777
|
+
const apiKey = resolve4("", config.api.authProfile);
|
|
18321
18778
|
return new OpenAICompatibleEmbeddingProvider(
|
|
18322
18779
|
{ baseUrl: config.api.baseUrl, apiKey, model: config.api.model },
|
|
18323
18780
|
{ fetchFn: deps.fetchFn }
|
|
@@ -18354,8 +18811,8 @@ function extensionSuffix(platform2) {
|
|
|
18354
18811
|
return "so";
|
|
18355
18812
|
}
|
|
18356
18813
|
function platformPackageName(platform2, arch2) {
|
|
18357
|
-
const
|
|
18358
|
-
return `${BASE_PACKAGE_NAME}-${
|
|
18814
|
+
const os3 = platform2 === "win32" ? "windows" : platform2;
|
|
18815
|
+
return `${BASE_PACKAGE_NAME}-${os3}-${arch2}`;
|
|
18359
18816
|
}
|
|
18360
18817
|
function getLoadablePath() {
|
|
18361
18818
|
if (!validPlatform(platform, arch)) {
|
|
@@ -18854,7 +19311,7 @@ var SemanticIndexJobQueue = class {
|
|
|
18854
19311
|
/** 等待队列清空(含当前任务) */
|
|
18855
19312
|
whenIdle() {
|
|
18856
19313
|
if (!this.processing && this.pending.length === 0) return Promise.resolve();
|
|
18857
|
-
return new Promise((
|
|
19314
|
+
return new Promise((resolve4) => this.idleResolvers.push(resolve4));
|
|
18858
19315
|
}
|
|
18859
19316
|
removePending(dbPathHash) {
|
|
18860
19317
|
this.pending = this.pending.filter((j) => j.dbPathHash !== dbPathHash);
|
|
@@ -18876,7 +19333,7 @@ var SemanticIndexJobQueue = class {
|
|
|
18876
19333
|
this.processing = false;
|
|
18877
19334
|
const resolvers = this.idleResolvers;
|
|
18878
19335
|
this.idleResolvers = [];
|
|
18879
|
-
for (const
|
|
19336
|
+
for (const resolve4 of resolvers) resolve4();
|
|
18880
19337
|
}
|
|
18881
19338
|
};
|
|
18882
19339
|
|
|
@@ -19526,16 +19983,16 @@ function resolveSearchToolEvidenceTokens(maxResultTokens) {
|
|
|
19526
19983
|
return maxResultTokens && maxResultTokens > 0 ? Math.min(SEARCH_TOOL_EVIDENCE_TOKENS, maxResultTokens) : SEARCH_TOOL_EVIDENCE_TOKENS;
|
|
19527
19984
|
}
|
|
19528
19985
|
function sessionIdFromDbPath(dbPath) {
|
|
19529
|
-
return
|
|
19986
|
+
return path31.basename(dbPath, ".db");
|
|
19530
19987
|
}
|
|
19531
19988
|
var SEMANTIC_INDEX_DB_FILE = "embedding_index.db";
|
|
19532
19989
|
var SEMANTIC_INDEX_CONFIG_FILE = "semantic-index-config.json";
|
|
19533
19990
|
function createSemanticIndexService(params) {
|
|
19534
19991
|
const { pathProvider } = params;
|
|
19535
19992
|
return new SemanticIndexService({
|
|
19536
|
-
vectorDbPath:
|
|
19537
|
-
configPath:
|
|
19538
|
-
modelsCacheDir:
|
|
19993
|
+
vectorDbPath: path31.join(pathProvider.getVectorDir(), SEMANTIC_INDEX_DB_FILE),
|
|
19994
|
+
configPath: path31.join(pathProvider.getAiDataDir(), SEMANTIC_INDEX_CONFIG_FILE),
|
|
19995
|
+
modelsCacheDir: path31.join(pathProvider.getAiDataDir(), "models", "semantic-index"),
|
|
19539
19996
|
modelDownloadProxyUrl: params.modelDownloadProxyUrl,
|
|
19540
19997
|
sessionAdapter: params.sessionAdapter,
|
|
19541
19998
|
nativeBinding: params.nativeBinding,
|
|
@@ -20085,8 +20542,8 @@ ${text}`;
|
|
|
20085
20542
|
};
|
|
20086
20543
|
|
|
20087
20544
|
// ../../packages/node-runtime/src/services/merge-cache.ts
|
|
20088
|
-
import * as
|
|
20089
|
-
import * as
|
|
20545
|
+
import * as fs35 from "fs";
|
|
20546
|
+
import * as path32 from "path";
|
|
20090
20547
|
import * as crypto from "crypto";
|
|
20091
20548
|
var MergeSessionCache = class {
|
|
20092
20549
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -20095,15 +20552,15 @@ var MergeSessionCache = class {
|
|
|
20095
20552
|
constructor(pathProvider, options2) {
|
|
20096
20553
|
this.tempDir = pathProvider.getTempDir();
|
|
20097
20554
|
this.nativeBinding = options2?.nativeBinding;
|
|
20098
|
-
if (!
|
|
20099
|
-
|
|
20555
|
+
if (!fs35.existsSync(this.tempDir)) {
|
|
20556
|
+
fs35.mkdirSync(this.tempDir, { recursive: true });
|
|
20100
20557
|
}
|
|
20101
20558
|
}
|
|
20102
20559
|
generateTempDbPath(filename) {
|
|
20103
20560
|
const ts = Date.now();
|
|
20104
20561
|
const rand = Math.random().toString(36).slice(2, 8);
|
|
20105
20562
|
const safeName = filename.replace(/[/\\?%*:|"<>]/g, "_").slice(0, 40);
|
|
20106
|
-
return
|
|
20563
|
+
return path32.join(this.tempDir, `merge_${safeName}_${ts}_${rand}.db`);
|
|
20107
20564
|
}
|
|
20108
20565
|
/** Store a parsed file's temp DB and return a handle for subsequent requests. */
|
|
20109
20566
|
store(filename, tempDbPath) {
|
|
@@ -20114,7 +20571,7 @@ var MergeSessionCache = class {
|
|
|
20114
20571
|
/** Open a TempDbReader for a given handle. Caller must close the reader. */
|
|
20115
20572
|
openReader(handle) {
|
|
20116
20573
|
const entry = this.cache.get(handle);
|
|
20117
|
-
if (!entry || !
|
|
20574
|
+
if (!entry || !fs35.existsSync(entry.tempDbPath)) return null;
|
|
20118
20575
|
const adapter = openBetterSqliteDatabase(entry.tempDbPath, {
|
|
20119
20576
|
readonly: true,
|
|
20120
20577
|
nativeBinding: this.nativeBinding
|
|
@@ -20159,7 +20616,7 @@ var MergeSessionCache = class {
|
|
|
20159
20616
|
};
|
|
20160
20617
|
|
|
20161
20618
|
// ../../packages/node-runtime/src/services/push-importer.ts
|
|
20162
|
-
import * as
|
|
20619
|
+
import * as fs36 from "fs";
|
|
20163
20620
|
var SYSTEM_SENDER_ID = "SYSTEM";
|
|
20164
20621
|
var SYSTEM_MEMBER_NAME = "\u7CFB\u7EDF\u6D88\u606F";
|
|
20165
20622
|
function isRecord3(value) {
|
|
@@ -20526,7 +20983,7 @@ async function executePushImportUnlocked(deps, sessionId, payload) {
|
|
|
20526
20983
|
return { ok: false, reason: "invalid_payload", message: "sessionId contains invalid characters" };
|
|
20527
20984
|
}
|
|
20528
20985
|
const dbPath = deps.getDbPath(sessionId);
|
|
20529
|
-
const isNew = !
|
|
20986
|
+
const isNew = !fs36.existsSync(dbPath);
|
|
20530
20987
|
const validationError = validatePayload(payload, isNew);
|
|
20531
20988
|
if (validationError) {
|
|
20532
20989
|
return { ok: false, reason: "invalid_payload", message: validationError };
|
|
@@ -20626,6 +21083,12 @@ var ImportIdempotencyCache = class {
|
|
|
20626
21083
|
};
|
|
20627
21084
|
|
|
20628
21085
|
export {
|
|
21086
|
+
CHATLAB_TEMP_ROOT_ENV,
|
|
21087
|
+
resolveChatLabTempRoot,
|
|
21088
|
+
ensureChatLabTempRoot,
|
|
21089
|
+
getChatLabTempScopeDir,
|
|
21090
|
+
createChatLabTempDir,
|
|
21091
|
+
removeChatLabTempDir,
|
|
20629
21092
|
writeParseResultToDb,
|
|
20630
21093
|
detectFormat,
|
|
20631
21094
|
detectAllFormats,
|
|
@@ -20679,6 +21142,9 @@ export {
|
|
|
20679
21142
|
formatAIError,
|
|
20680
21143
|
parseAssistantFile,
|
|
20681
21144
|
serializeAssistant,
|
|
21145
|
+
DEFAULT_GENERAL_ASSISTANT_CONFIGS,
|
|
21146
|
+
DEFAULT_GENERAL_ASSISTANT_RAW_CONFIGS,
|
|
21147
|
+
LEGACY_GENERAL_ASSISTANT_DIGESTS,
|
|
20682
21148
|
AssistantManager,
|
|
20683
21149
|
parseSkillFile,
|
|
20684
21150
|
extractSkillId,
|
|
@@ -20747,6 +21213,8 @@ export {
|
|
|
20747
21213
|
checkSessionsCanGenerateSummary,
|
|
20748
21214
|
MAX_CONFIG_COUNT,
|
|
20749
21215
|
LLMConfigStore,
|
|
21216
|
+
createFileConfigStorage,
|
|
21217
|
+
createAuthProfileLlmConfigStore,
|
|
20750
21218
|
CustomProviderStore,
|
|
20751
21219
|
CustomModelStore,
|
|
20752
21220
|
normalizeAnthropicBaseUrl,
|
|
@@ -20841,4 +21309,4 @@ export {
|
|
|
20841
21309
|
hashImportBody,
|
|
20842
21310
|
ImportIdempotencyCache
|
|
20843
21311
|
};
|
|
20844
|
-
//# sourceMappingURL=chunk-
|
|
21312
|
+
//# sourceMappingURL=chunk-LNU4RW5G.mjs.map
|