chatlab-cli 0.33.0 → 0.34.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-IHRNO7J4.mjs → chat-command-XPY3WURC.mjs} +9 -9
- package/dist/{chunk-KWJ5FZ74.mjs → chunk-AQPDZAWB.mjs} +385 -248
- package/dist/chunk-AQPDZAWB.mjs.map +1 -0
- package/dist/{chunk-RHA534GU.mjs → chunk-BQ3QN4QT.mjs} +3 -3
- package/dist/{chunk-NHTOSDYI.mjs → chunk-DGF3S3TZ.mjs} +2 -2
- package/dist/{chunk-4V6UP7EW.mjs → chunk-IGEHMLHM.mjs} +2 -2
- package/dist/{chunk-NSWFHMBZ.mjs → chunk-IGK6UMN2.mjs} +11 -11
- package/dist/{chunk-U4F6BNGZ.mjs → chunk-ISRLGLUL.mjs} +2 -2
- package/dist/{chunk-HGV4MUIW.mjs → chunk-JCSPDTZL.mjs} +15 -62
- package/dist/chunk-JCSPDTZL.mjs.map +1 -0
- package/dist/{chunk-S7YPBKQ3.mjs → chunk-JTOHAMIW.mjs} +2 -2
- package/dist/{chunk-C3B7RXES.mjs → chunk-OLE2USEN.mjs} +626 -318
- package/dist/chunk-OLE2USEN.mjs.map +1 -0
- package/dist/{chunk-YAQLYL52.mjs → chunk-QZCNVAH6.mjs} +2 -2
- package/dist/{chunk-YAQLYL52.mjs.map → chunk-QZCNVAH6.mjs.map} +1 -1
- package/dist/{chunk-ZERQIKI4.mjs → chunk-S5NCEESV.mjs} +3 -3
- package/dist/{chunk-ZTMZ7S7T.mjs → chunk-UO2XVFY6.mjs} +31 -20
- package/dist/chunk-UO2XVFY6.mjs.map +1 -0
- package/dist/cli.mjs +9 -9
- package/dist/contacts-worker.mjs +2 -2
- package/dist/global-insight-worker.mjs +2 -2
- package/dist/{http-Y2WC2UK4.mjs → http-HV6XWU6X.mjs} +12 -12
- package/dist/{import-4HF2UNQI.mjs → import-DP2XLZ2H.mjs} +8 -8
- package/dist/index.mjs +12 -12
- package/dist/{mcp-DJPDRFTW.mjs → mcp-QDPFBPGW.mjs} +9 -9
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-R7MZLKXQ.mjs → src-B3A2QHP5.mjs} +9 -7
- package/dist/{stream-import-DX57ANUL.mjs → stream-import-KEGNP3QK.mjs} +8 -8
- package/dist/{worker-runtime-QMN7OKOZ.mjs → worker-runtime-MDYKX3BW.mjs} +6 -6
- package/dist-cli-web/assets/{ActionToolsPanel.vue_vue_type_script_setup_true_lang-hwRVh048.js → ActionToolsPanel.vue_vue_type_script_setup_true_lang-JxPR2O6b.js} +5 -5
- package/dist-cli-web/assets/{BufferResource-DwfMBlAa.js → BufferResource--dSbJb0k.js} +1 -1
- package/dist-cli-web/assets/{CanvasRenderer-q312LRsp.js → CanvasRenderer-Cm_dmJXZ.js} +1 -1
- package/dist-cli-web/assets/{DataDirCleanupNotice--ee1dY0d.js → DataDirCleanupNotice-B0s5txX3.js} +1 -1
- package/dist-cli-web/assets/{EChartWordcloud-BaMgUl0Y.js → EChartWordcloud-CwMVJLBO.js} +1 -1
- package/dist-cli-web/assets/{Filter-BOb5cLBx.js → Filter-BjYScRpK.js} +1 -1
- package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-BshQybD_.js +1 -0
- package/dist-cli-web/assets/{MessageExportModal-CFbovWh1.js → MessageExportModal-DAJW2mFj.js} +1 -1
- package/dist-cli-web/assets/{PageHeader-B3-W9mvh.js → PageHeader-BKAjCuqs.js} +1 -1
- package/dist-cli-web/assets/{RelationshipGalaxyCanvas-GEpsKHxV.js → RelationshipGalaxyCanvas-mlZs7k4L.js} +14 -14
- package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-BluPHjCR.css → RelationshipGalaxyThreeCanvas-CeYJABxI.css} +1 -1
- package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-DHOU66Gj.js → RelationshipGalaxyThreeCanvas-DgMG3jdU.js} +14 -14
- package/dist-cli-web/assets/{RenderTargetSystem-PEnnW2yb.js → RenderTargetSystem-D00Ex44y.js} +1 -1
- package/dist-cli-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-sNw3hP4c.js → ThemeCard.vue_vue_type_script_setup_true_lang-Dsb6lzs-.js} +1 -1
- package/dist-cli-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-BtUvMehe.js → TimeSelect.vue_vue_type_script_setup_true_lang-BfR3tlkz.js} +1 -1
- package/dist-cli-web/assets/{WebGLRenderer-BjP_1do7.js → WebGLRenderer-CTTusm2n.js} +1 -1
- package/dist-cli-web/assets/{WebGPURenderer-ldVv92u7.js → WebGPURenderer-pyv3EXor.js} +1 -1
- package/dist-cli-web/assets/{annual-summary-time-range-BHClzNvd.js → annual-summary-time-range-C_d1oZrj.js} +1 -1
- package/dist-cli-web/assets/{base-DBJ95yXf.js → base-D91aVUwM.js} +1 -1
- package/dist-cli-web/assets/{browserAll-CPoMOLKh.js → browserAll-C9fW936Y.js} +1 -1
- package/dist-cli-web/assets/{cli-web-B5VYO-Dh.js → cli-web-C7uGKz_E.js} +1 -1
- package/dist-cli-web/assets/{dateFormat-Cf2xuaE-.js → dateFormat-rY43adcv.js} +1 -1
- package/dist-cli-web/assets/{fetch-CtyVktRW.js → fetch-C6po4XYB.js} +1 -1
- package/dist-cli-web/assets/{fetch-J67jyI2k.js → fetch-CNy9OQ2g.js} +1 -1
- package/dist-cli-web/assets/{fetch-BuWxo6oK.js → fetch-CS3T-v-1.js} +1 -1
- package/dist-cli-web/assets/{fetch-C0HHT1Yn.js → fetch-CbnX5VoM.js} +1 -1
- package/dist-cli-web/assets/fetch-CrSz5KJy.js +1 -0
- package/dist-cli-web/assets/{fetch-CXIdj2-_.js → fetch-DG3AeEjW.js} +1 -1
- package/dist-cli-web/assets/{fetch-B1km2u3N.js → fetch-DYNgtIcU.js} +1 -1
- package/dist-cli-web/assets/{fetch-DGi_9my2.js → fetch-DZPC3D8R.js} +1 -1
- package/dist-cli-web/assets/{fetch-BFDKzf1P.js → fetch-Kk2knkEo.js} +1 -1
- package/dist-cli-web/assets/{fetch-Dr41uuXL.js → fetch-PLrI3V67.js} +1 -1
- package/dist-cli-web/assets/{index-BGiTw98l.js → index-2-OaYdzt.js} +1 -1
- package/dist-cli-web/assets/index-2S80bo1s.js +2 -0
- package/dist-cli-web/assets/index-3YO6RI5e.js +2 -0
- package/dist-cli-web/assets/index-BKo68Iu5.js +1 -0
- package/dist-cli-web/assets/{index-Bf3gFaid.js → index-BrkDgcJ6.js} +1 -1
- package/dist-cli-web/assets/{index-5UdyJtVU.js → index-CGI3Y8pq.js} +1 -1
- package/dist-cli-web/assets/index-CW9H_fBd.js +53 -0
- package/dist-cli-web/assets/{index-Ba21yU86.js → index-DA3Q0TGT.js} +1 -1
- package/dist-cli-web/assets/{index-B7R74Yp7.js → index-DFHYr_-u.js} +1 -1
- package/dist-cli-web/assets/index-DmwA85vG.js +173 -0
- package/dist-cli-web/assets/index-DrjoMv9s.css +1 -0
- package/dist-cli-web/assets/{index-DzQT-qXF.js → index-DsdMsKYT.js} +1 -1
- package/dist-cli-web/assets/{index-DtlTo3nt.js → index-JYfjMRb-.js} +1 -1
- package/dist-cli-web/assets/index-Jhwca9kg.css +1 -0
- package/dist-cli-web/assets/index-ZTgfCZvY.js +64 -0
- package/dist-cli-web/assets/index-vtF05fh7.css +1 -0
- package/dist-cli-web/assets/{people-page-header-BvQy1GQj.js → people-page-header-D-LWaEqn.js} +1 -1
- package/dist-cli-web/assets/{webworkerAll-DgKQKbNn.js → webworkerAll-CPOVECup.js} +1 -1
- package/dist-cli-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-C3B7RXES.mjs.map +0 -1
- package/dist/chunk-HGV4MUIW.mjs.map +0 -1
- package/dist/chunk-KWJ5FZ74.mjs.map +0 -1
- package/dist/chunk-ZTMZ7S7T.mjs.map +0 -1
- package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-DK2z0Jrh.js +0 -1
- package/dist-cli-web/assets/fetch-80O3EH4a.js +0 -1
- package/dist-cli-web/assets/index-7jm3YI9u.js +0 -53
- package/dist-cli-web/assets/index-ByQSR8Bj.js +0 -2
- package/dist-cli-web/assets/index-CPZYydbc.js +0 -2
- package/dist-cli-web/assets/index-D8Q3U-6e.js +0 -1
- package/dist-cli-web/assets/index-DGtDxRCd.js +0 -173
- package/dist-cli-web/assets/index-DTxnpQiv.css +0 -1
- package/dist-cli-web/assets/index-gpTDI3sq.js +0 -64
- package/dist-cli-web/assets/index-lwhCMqhd.css +0 -1
- package/dist-cli-web/assets/index-qsbWn8VP.css +0 -1
- /package/dist/{chat-command-IHRNO7J4.mjs.map → chat-command-XPY3WURC.mjs.map} +0 -0
- /package/dist/{chunk-RHA534GU.mjs.map → chunk-BQ3QN4QT.mjs.map} +0 -0
- /package/dist/{chunk-NHTOSDYI.mjs.map → chunk-DGF3S3TZ.mjs.map} +0 -0
- /package/dist/{chunk-4V6UP7EW.mjs.map → chunk-IGEHMLHM.mjs.map} +0 -0
- /package/dist/{chunk-NSWFHMBZ.mjs.map → chunk-IGK6UMN2.mjs.map} +0 -0
- /package/dist/{chunk-U4F6BNGZ.mjs.map → chunk-ISRLGLUL.mjs.map} +0 -0
- /package/dist/{chunk-S7YPBKQ3.mjs.map → chunk-JTOHAMIW.mjs.map} +0 -0
- /package/dist/{chunk-ZERQIKI4.mjs.map → chunk-S5NCEESV.mjs.map} +0 -0
- /package/dist/{http-Y2WC2UK4.mjs.map → http-HV6XWU6X.mjs.map} +0 -0
- /package/dist/{import-4HF2UNQI.mjs.map → import-DP2XLZ2H.mjs.map} +0 -0
- /package/dist/{mcp-DJPDRFTW.mjs.map → mcp-QDPFBPGW.mjs.map} +0 -0
- /package/dist/{src-R7MZLKXQ.mjs.map → src-B3A2QHP5.mjs.map} +0 -0
- /package/dist/{stream-import-DX57ANUL.mjs.map → stream-import-KEGNP3QK.mjs.map} +0 -0
- /package/dist/{worker-runtime-QMN7OKOZ.mjs.map → worker-runtime-MDYKX3BW.mjs.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
createEmptyContactsDiagnostics,
|
|
10
10
|
normalizeContactsTimeRangePreset,
|
|
11
11
|
resolveContactsTimeRange
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IGEHMLHM.mjs";
|
|
13
13
|
import {
|
|
14
14
|
PEOPLE_RELATIONSHIPS_ALGORITHM_VERSION,
|
|
15
15
|
buildPeopleRelationshipsNeighborhoodGraph,
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
computePeopleRelationshipsSnapshot,
|
|
19
19
|
normalizePeopleRelationshipsTimeRangePreset,
|
|
20
20
|
resolvePeopleRelationshipsTimeRange
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JTOHAMIW.mjs";
|
|
22
22
|
import {
|
|
23
23
|
ANNUAL_SUMMARY_ALGORITHM_VERSION
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-QZCNVAH6.mjs";
|
|
25
25
|
import {
|
|
26
26
|
BUILTIN_MODELS,
|
|
27
27
|
BUILTIN_PROVIDERS,
|
|
@@ -51,11 +51,14 @@ import {
|
|
|
51
51
|
deleteAuthProfile,
|
|
52
52
|
deleteMember,
|
|
53
53
|
deleteMembers,
|
|
54
|
+
deriveAuthProfileName,
|
|
54
55
|
generateIncrementalSessionIndex,
|
|
55
56
|
generateMessageKey,
|
|
56
57
|
generateSessionIndex,
|
|
57
58
|
getAnnualSummarySnapshotPath,
|
|
59
|
+
getBuiltinModelById,
|
|
58
60
|
getBuiltinModelsByProvider,
|
|
61
|
+
getBuiltinProviderById,
|
|
59
62
|
getChatSessionList,
|
|
60
63
|
getContactsDir,
|
|
61
64
|
getContactsFactsCacheDir,
|
|
@@ -80,6 +83,7 @@ import {
|
|
|
80
83
|
isNameMatchPlatform,
|
|
81
84
|
isReasoningModel,
|
|
82
85
|
isSupportedChatLabFormatVersion,
|
|
86
|
+
loadAuthProfiles,
|
|
83
87
|
matchOwnerProfile,
|
|
84
88
|
mergeConfirmedNames,
|
|
85
89
|
mergeMembers,
|
|
@@ -88,6 +92,7 @@ import {
|
|
|
88
92
|
normalizeBuiltinToolNames,
|
|
89
93
|
openBetterSqliteDatabase,
|
|
90
94
|
readAnnualSummarySnapshot,
|
|
95
|
+
readJsonFile,
|
|
91
96
|
renameSession,
|
|
92
97
|
resolveApiKey,
|
|
93
98
|
saveSegmentSummary,
|
|
@@ -100,10 +105,12 @@ import {
|
|
|
100
105
|
truncateToolResultText,
|
|
101
106
|
updateMemberAliases,
|
|
102
107
|
updateSessionOwnerId,
|
|
108
|
+
withFileLock,
|
|
103
109
|
writeAnnualSummarySnapshot,
|
|
104
110
|
writeAuthProfile,
|
|
111
|
+
writeJsonFileAtomically,
|
|
105
112
|
writeParseResultToDb
|
|
106
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-OLE2USEN.mjs";
|
|
107
114
|
import {
|
|
108
115
|
__commonJS,
|
|
109
116
|
__export,
|
|
@@ -1461,7 +1468,7 @@ var require_pend = __commonJS({
|
|
|
1461
1468
|
var require_fd_slicer = __commonJS({
|
|
1462
1469
|
"../../packages/node-runtime/node_modules/yauzl/fd-slicer.js"(exports) {
|
|
1463
1470
|
"use strict";
|
|
1464
|
-
var
|
|
1471
|
+
var fs36 = __require("fs");
|
|
1465
1472
|
var util = __require("util");
|
|
1466
1473
|
var stream = __require("stream");
|
|
1467
1474
|
var Readable = stream.Readable;
|
|
@@ -1481,7 +1488,7 @@ var require_fd_slicer = __commonJS({
|
|
|
1481
1488
|
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
1482
1489
|
var self = this;
|
|
1483
1490
|
self.pend.go(function(cb) {
|
|
1484
|
-
|
|
1491
|
+
fs36.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
1485
1492
|
cb();
|
|
1486
1493
|
callback(err, bytesRead, buffer2);
|
|
1487
1494
|
});
|
|
@@ -1498,7 +1505,7 @@ var require_fd_slicer = __commonJS({
|
|
|
1498
1505
|
self.refCount -= 1;
|
|
1499
1506
|
if (self.refCount < 0) throw new Error("invalid unref");
|
|
1500
1507
|
if (self.refCount > 0) return;
|
|
1501
|
-
|
|
1508
|
+
fs36.close(self.fd, onCloseDone);
|
|
1502
1509
|
function onCloseDone(err) {
|
|
1503
1510
|
if (err) {
|
|
1504
1511
|
self.emit("error", err);
|
|
@@ -1530,7 +1537,7 @@ var require_fd_slicer = __commonJS({
|
|
|
1530
1537
|
}
|
|
1531
1538
|
self.context.pend.go(function(cb) {
|
|
1532
1539
|
var buffer = Buffer.allocUnsafe(toRead);
|
|
1533
|
-
|
|
1540
|
+
fs36.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
1534
1541
|
if (err) {
|
|
1535
1542
|
self.destroy(err);
|
|
1536
1543
|
} else if (bytesRead === 0) {
|
|
@@ -1892,7 +1899,7 @@ var require_crc32 = __commonJS({
|
|
|
1892
1899
|
var require_yauzl = __commonJS({
|
|
1893
1900
|
"../../packages/node-runtime/node_modules/yauzl/index.js"(exports) {
|
|
1894
1901
|
"use strict";
|
|
1895
|
-
var
|
|
1902
|
+
var fs36 = __require("fs");
|
|
1896
1903
|
var zlib = __require("zlib");
|
|
1897
1904
|
var fd_slicer = require_fd_slicer();
|
|
1898
1905
|
var util = __require("util");
|
|
@@ -1961,10 +1968,10 @@ var require_yauzl = __commonJS({
|
|
|
1961
1968
|
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1962
1969
|
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1963
1970
|
if (callback == null) callback = defaultCallback;
|
|
1964
|
-
|
|
1971
|
+
fs36.open(path30, "r", function(err, fd) {
|
|
1965
1972
|
if (err) return callback(err);
|
|
1966
1973
|
fromFd(fd, options2, function(err2, zipfile) {
|
|
1967
|
-
if (err2)
|
|
1974
|
+
if (err2) fs36.close(fd, defaultCallback);
|
|
1968
1975
|
callback(err2, zipfile);
|
|
1969
1976
|
});
|
|
1970
1977
|
});
|
|
@@ -1981,7 +1988,7 @@ var require_yauzl = __commonJS({
|
|
|
1981
1988
|
if (options2.validateEntrySizes == null) options2.validateEntrySizes = true;
|
|
1982
1989
|
if (options2.strictFileNames == null) options2.strictFileNames = false;
|
|
1983
1990
|
if (callback == null) callback = defaultCallback;
|
|
1984
|
-
|
|
1991
|
+
fs36.fstat(fd, function(err, stats) {
|
|
1985
1992
|
if (err) return callback(err);
|
|
1986
1993
|
var reader = new fd_slicer.FdSlicer(fd);
|
|
1987
1994
|
fromRandomAccessReader(reader, stats.size, options2, callback);
|
|
@@ -9751,8 +9758,8 @@ var AssistantManager = class {
|
|
|
9751
9758
|
}
|
|
9752
9759
|
// ==================== Init ====================
|
|
9753
9760
|
init() {
|
|
9754
|
-
const { fs:
|
|
9755
|
-
|
|
9761
|
+
const { fs: fs36, assistantsDir } = this.deps;
|
|
9762
|
+
fs36.ensureDir(assistantsDir);
|
|
9756
9763
|
const { generalCreated, generalUpdated } = this.syncGeneralAssistants();
|
|
9757
9764
|
this.loadAll();
|
|
9758
9765
|
this.initialized = true;
|
|
@@ -9764,25 +9771,25 @@ var AssistantManager = class {
|
|
|
9764
9771
|
return { total: this.cache.size, generalCreated, generalUpdated };
|
|
9765
9772
|
}
|
|
9766
9773
|
syncGeneralAssistants() {
|
|
9767
|
-
const { fs:
|
|
9774
|
+
const { fs: fs36, assistantsDir } = this.deps;
|
|
9768
9775
|
let generalCreated = false;
|
|
9769
9776
|
let generalUpdated = false;
|
|
9770
9777
|
for (const id of this.generalIds) {
|
|
9771
9778
|
const config = this.getBuiltinConfig(id);
|
|
9772
9779
|
if (!config) continue;
|
|
9773
|
-
const filePath =
|
|
9774
|
-
if (!
|
|
9775
|
-
|
|
9780
|
+
const filePath = fs36.joinPath(assistantsDir, `${id}.md`);
|
|
9781
|
+
if (!fs36.fileExists(filePath)) {
|
|
9782
|
+
fs36.writeFile(filePath, serializeAssistant(this.withBuiltinTracking(config)));
|
|
9776
9783
|
generalCreated = true;
|
|
9777
9784
|
continue;
|
|
9778
9785
|
}
|
|
9779
9786
|
try {
|
|
9780
|
-
const existing = parseAssistantFile(
|
|
9787
|
+
const existing = parseAssistantFile(fs36.readFile(filePath), filePath);
|
|
9781
9788
|
if (!existing) continue;
|
|
9782
9789
|
if (existing.builtinId !== id) {
|
|
9783
9790
|
try {
|
|
9784
9791
|
const backupId = this.backupAssistantOccupyingReservedId(existing);
|
|
9785
|
-
|
|
9792
|
+
fs36.writeFile(filePath, serializeAssistant(this.withBuiltinTracking(config)));
|
|
9786
9793
|
generalCreated = true;
|
|
9787
9794
|
this.deps.logger?.info("AssistantManager", "Backed up assistant occupying reserved default ID", {
|
|
9788
9795
|
reservedId: id,
|
|
@@ -9798,7 +9805,7 @@ var AssistantManager = class {
|
|
|
9798
9805
|
continue;
|
|
9799
9806
|
}
|
|
9800
9807
|
if (!this.shouldUpgradeBuiltin(existing, config)) continue;
|
|
9801
|
-
|
|
9808
|
+
fs36.writeFile(filePath, serializeAssistant(this.withBuiltinTracking(config, existing.id)));
|
|
9802
9809
|
generalUpdated = true;
|
|
9803
9810
|
this.deps.logger?.info("AssistantManager", "Updated unmodified default assistant template", {
|
|
9804
9811
|
id,
|
|
@@ -9814,14 +9821,14 @@ var AssistantManager = class {
|
|
|
9814
9821
|
return { generalCreated, generalUpdated };
|
|
9815
9822
|
}
|
|
9816
9823
|
backupAssistantOccupyingReservedId(config) {
|
|
9817
|
-
const { fs:
|
|
9824
|
+
const { fs: fs36, assistantsDir } = this.deps;
|
|
9818
9825
|
const baseId = this.deps.generateId?.() || `custom_${Date.now().toString(36)}`;
|
|
9819
9826
|
let backupId = baseId;
|
|
9820
9827
|
let suffix = 2;
|
|
9821
|
-
while (this.generalIds.includes(backupId) ||
|
|
9828
|
+
while (this.generalIds.includes(backupId) || fs36.fileExists(fs36.joinPath(assistantsDir, `${backupId}.md`))) {
|
|
9822
9829
|
backupId = `${baseId}_${suffix++}`;
|
|
9823
9830
|
}
|
|
9824
|
-
|
|
9831
|
+
fs36.writeFile(fs36.joinPath(assistantsDir, `${backupId}.md`), serializeAssistant({ ...config, id: backupId }));
|
|
9825
9832
|
return backupId;
|
|
9826
9833
|
}
|
|
9827
9834
|
getConfigDigest(config) {
|
|
@@ -9858,13 +9865,13 @@ var AssistantManager = class {
|
|
|
9858
9865
|
return { isUnmodified, isOutdated };
|
|
9859
9866
|
}
|
|
9860
9867
|
loadAll() {
|
|
9861
|
-
const { fs:
|
|
9868
|
+
const { fs: fs36, assistantsDir } = this.deps;
|
|
9862
9869
|
this.cache.clear();
|
|
9863
|
-
const files =
|
|
9870
|
+
const files = fs36.listFiles(assistantsDir, ".md");
|
|
9864
9871
|
for (const file of files) {
|
|
9865
9872
|
try {
|
|
9866
|
-
const filePath =
|
|
9867
|
-
const content =
|
|
9873
|
+
const filePath = fs36.joinPath(assistantsDir, file);
|
|
9874
|
+
const content = fs36.readFile(filePath);
|
|
9868
9875
|
const config = parseAssistantFile(content, filePath);
|
|
9869
9876
|
if (config) {
|
|
9870
9877
|
this.cache.set(config.id, config);
|
|
@@ -10933,21 +10940,21 @@ var SkillManagerCore = class {
|
|
|
10933
10940
|
}
|
|
10934
10941
|
// ==================== Init ====================
|
|
10935
10942
|
init() {
|
|
10936
|
-
const { fs:
|
|
10937
|
-
|
|
10943
|
+
const { fs: fs36, skillsDir } = this.deps;
|
|
10944
|
+
fs36.ensureDir(skillsDir);
|
|
10938
10945
|
this.loadAll();
|
|
10939
10946
|
this.initialized = true;
|
|
10940
10947
|
this.deps.logger?.info("SkillManager", "Initialized", { total: this.cache.size });
|
|
10941
10948
|
return { total: this.cache.size };
|
|
10942
10949
|
}
|
|
10943
10950
|
loadAll() {
|
|
10944
|
-
const { fs:
|
|
10951
|
+
const { fs: fs36, skillsDir } = this.deps;
|
|
10945
10952
|
this.cache.clear();
|
|
10946
|
-
const files =
|
|
10953
|
+
const files = fs36.listFiles(skillsDir, ".md");
|
|
10947
10954
|
for (const file of files) {
|
|
10948
10955
|
try {
|
|
10949
|
-
const filePath =
|
|
10950
|
-
const content =
|
|
10956
|
+
const filePath = fs36.joinPath(skillsDir, file);
|
|
10957
|
+
const content = fs36.readFile(filePath);
|
|
10951
10958
|
const def = parseSkillFile(content, filePath);
|
|
10952
10959
|
if (def) {
|
|
10953
10960
|
this.cache.set(def.id, def);
|
|
@@ -15353,19 +15360,26 @@ var LLMConfigStore = class {
|
|
|
15353
15360
|
this.resolveApiKey = deps.resolveApiKey;
|
|
15354
15361
|
this.onStoreLoaded = deps.onStoreLoaded;
|
|
15355
15362
|
}
|
|
15363
|
+
withStoreLock(action) {
|
|
15364
|
+
return this.storage.withLock ? this.storage.withLock("llm-config", action) : action();
|
|
15365
|
+
}
|
|
15356
15366
|
loadStore() {
|
|
15357
15367
|
const store = this.storage.readJson("llm-config");
|
|
15358
15368
|
if (!store) {
|
|
15359
15369
|
return { configs: [], defaultAssistant: null, fastModel: null };
|
|
15360
15370
|
}
|
|
15361
15371
|
this.onStoreLoaded?.(store.configs);
|
|
15362
|
-
const
|
|
15372
|
+
const sanitizedConfigs = store.configs.map((config) => ({
|
|
15373
|
+
...config,
|
|
15374
|
+
apiKey: config.apiKey?.startsWith("enc:") ? "" : config.apiKey || ""
|
|
15375
|
+
}));
|
|
15376
|
+
const resolvedConfigs = this.resolveApiKey ? sanitizedConfigs.map((config) => {
|
|
15363
15377
|
const profileKey = this.resolveApiKey(
|
|
15364
15378
|
config.provider,
|
|
15365
15379
|
config.authProfile
|
|
15366
15380
|
);
|
|
15367
|
-
return { ...config, apiKey: profileKey || config.apiKey
|
|
15368
|
-
}) :
|
|
15381
|
+
return { ...config, apiKey: profileKey || config.apiKey };
|
|
15382
|
+
}) : sanitizedConfigs;
|
|
15369
15383
|
return {
|
|
15370
15384
|
...store,
|
|
15371
15385
|
configs: resolvedConfigs,
|
|
@@ -15417,103 +15431,113 @@ var LLMConfigStore = class {
|
|
|
15417
15431
|
return store.configs.find((c) => c.id === id) || null;
|
|
15418
15432
|
}
|
|
15419
15433
|
addConfig(config) {
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
const now = Date.now();
|
|
15425
|
-
const newConfig = {
|
|
15426
|
-
...config,
|
|
15427
|
-
id: this.generateId(),
|
|
15428
|
-
createdAt: now,
|
|
15429
|
-
updatedAt: now
|
|
15430
|
-
};
|
|
15431
|
-
store.configs.push(newConfig);
|
|
15432
|
-
if (store.configs.length === 1) {
|
|
15433
|
-
store.defaultAssistant = { configId: newConfig.id, modelId: newConfig.model || "" };
|
|
15434
|
-
}
|
|
15435
|
-
if (newConfig.apiKey && this.onApiKeyCreated) {
|
|
15436
|
-
const profileName = this.onApiKeyCreated(newConfig, newConfig.apiKey);
|
|
15437
|
-
if (profileName) {
|
|
15438
|
-
;
|
|
15439
|
-
newConfig.authProfile = profileName;
|
|
15434
|
+
return this.withStoreLock(() => {
|
|
15435
|
+
const store = this.loadStore();
|
|
15436
|
+
if (store.configs.length >= MAX_CONFIG_COUNT) {
|
|
15437
|
+
return { success: false, error: this.t("llm.maxConfigs", { count: MAX_CONFIG_COUNT }) };
|
|
15440
15438
|
}
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15439
|
+
const now = Date.now();
|
|
15440
|
+
const newConfig = {
|
|
15441
|
+
...config,
|
|
15442
|
+
id: this.generateId(),
|
|
15443
|
+
createdAt: now,
|
|
15444
|
+
updatedAt: now
|
|
15445
|
+
};
|
|
15446
|
+
store.configs.push(newConfig);
|
|
15447
|
+
if (store.configs.length === 1) {
|
|
15448
|
+
store.defaultAssistant = { configId: newConfig.id, modelId: newConfig.model || "" };
|
|
15449
|
+
}
|
|
15450
|
+
if (newConfig.apiKey && this.onApiKeyCreated) {
|
|
15451
|
+
const profileName = this.onApiKeyCreated(newConfig, newConfig.apiKey);
|
|
15452
|
+
if (profileName) {
|
|
15453
|
+
;
|
|
15454
|
+
newConfig.authProfile = profileName;
|
|
15455
|
+
}
|
|
15456
|
+
}
|
|
15457
|
+
this.saveStore(store);
|
|
15458
|
+
return { success: true, config: { ...newConfig, apiKey: "" } };
|
|
15459
|
+
});
|
|
15444
15460
|
}
|
|
15445
15461
|
updateConfig(id, updates) {
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
|
|
15461
|
-
|
|
15462
|
-
|
|
15463
|
-
|
|
15464
|
-
|
|
15465
|
-
|
|
15466
|
-
|
|
15462
|
+
return this.withStoreLock(() => {
|
|
15463
|
+
const store = this.loadStore();
|
|
15464
|
+
const index = store.configs.findIndex((c) => c.id === id);
|
|
15465
|
+
if (index === -1) {
|
|
15466
|
+
return { success: false, error: this.t("llm.configNotFound") };
|
|
15467
|
+
}
|
|
15468
|
+
const oldConfig = store.configs[index];
|
|
15469
|
+
const oldProfileName = oldConfig.authProfile;
|
|
15470
|
+
const updated = {
|
|
15471
|
+
...oldConfig,
|
|
15472
|
+
...updates,
|
|
15473
|
+
updatedAt: Date.now()
|
|
15474
|
+
};
|
|
15475
|
+
store.configs[index] = updated;
|
|
15476
|
+
let oldProfileToDelete = null;
|
|
15477
|
+
if (updates.apiKey && this.onApiKeyCreated) {
|
|
15478
|
+
const profileName = this.onApiKeyCreated(updated, updates.apiKey);
|
|
15479
|
+
if (profileName) {
|
|
15480
|
+
;
|
|
15481
|
+
store.configs[index].authProfile = profileName;
|
|
15482
|
+
if (oldProfileName && oldProfileName !== profileName && !isAuthProfileUsed(store.configs, oldProfileName, oldConfig.provider)) {
|
|
15483
|
+
oldProfileToDelete = oldConfig;
|
|
15484
|
+
}
|
|
15467
15485
|
}
|
|
15468
15486
|
}
|
|
15469
|
-
|
|
15470
|
-
|
|
15471
|
-
|
|
15472
|
-
|
|
15487
|
+
this.saveStore(store);
|
|
15488
|
+
if (oldProfileToDelete) this.onApiKeyDeleted?.(oldProfileToDelete);
|
|
15489
|
+
return { success: true };
|
|
15490
|
+
});
|
|
15473
15491
|
}
|
|
15474
15492
|
deleteConfig(id) {
|
|
15475
|
-
|
|
15476
|
-
|
|
15477
|
-
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
store.defaultAssistant
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
store.fastModel
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15493
|
+
return this.withStoreLock(() => {
|
|
15494
|
+
const store = this.loadStore();
|
|
15495
|
+
const index = store.configs.findIndex((c) => c.id === id);
|
|
15496
|
+
if (index === -1) {
|
|
15497
|
+
return { success: false, error: this.t("llm.configNotFound") };
|
|
15498
|
+
}
|
|
15499
|
+
const deleted = store.configs[index];
|
|
15500
|
+
store.configs.splice(index, 1);
|
|
15501
|
+
const fallback = store.configs[0];
|
|
15502
|
+
if (store.defaultAssistant?.configId === id) {
|
|
15503
|
+
store.defaultAssistant = fallback ? { configId: fallback.id, modelId: fallback.model || "" } : null;
|
|
15504
|
+
}
|
|
15505
|
+
if (store.fastModel?.configId === id) {
|
|
15506
|
+
store.fastModel = fallback ? { configId: fallback.id, modelId: fallback.model || "" } : null;
|
|
15507
|
+
}
|
|
15508
|
+
this.saveStore(store);
|
|
15509
|
+
const deletedProfileName = getAuthProfile(deleted);
|
|
15510
|
+
if (!deletedProfileName || !isAuthProfileUsed(store.configs, deletedProfileName, deleted.provider)) {
|
|
15511
|
+
this.onApiKeyDeleted?.(deleted);
|
|
15512
|
+
}
|
|
15513
|
+
return { success: true };
|
|
15514
|
+
});
|
|
15495
15515
|
}
|
|
15496
15516
|
setDefaultAssistantModel(configId, modelId) {
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
return { success: false, error: this.t("llm.configNotFound") };
|
|
15501
|
-
}
|
|
15502
|
-
store.defaultAssistant = { configId, modelId };
|
|
15503
|
-
this.saveStore(store);
|
|
15504
|
-
return { success: true };
|
|
15505
|
-
}
|
|
15506
|
-
setFastModel(slot) {
|
|
15507
|
-
const store = this.loadStore();
|
|
15508
|
-
if (slot !== null) {
|
|
15509
|
-
const config = store.configs.find((c) => c.id === slot.configId);
|
|
15517
|
+
return this.withStoreLock(() => {
|
|
15518
|
+
const store = this.loadStore();
|
|
15519
|
+
const config = store.configs.find((c) => c.id === configId);
|
|
15510
15520
|
if (!config) {
|
|
15511
15521
|
return { success: false, error: this.t("llm.configNotFound") };
|
|
15512
15522
|
}
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15523
|
+
store.defaultAssistant = { configId, modelId };
|
|
15524
|
+
this.saveStore(store);
|
|
15525
|
+
return { success: true };
|
|
15526
|
+
});
|
|
15527
|
+
}
|
|
15528
|
+
setFastModel(slot) {
|
|
15529
|
+
return this.withStoreLock(() => {
|
|
15530
|
+
const store = this.loadStore();
|
|
15531
|
+
if (slot !== null) {
|
|
15532
|
+
const config = store.configs.find((c) => c.id === slot.configId);
|
|
15533
|
+
if (!config) {
|
|
15534
|
+
return { success: false, error: this.t("llm.configNotFound") };
|
|
15535
|
+
}
|
|
15536
|
+
}
|
|
15537
|
+
store.fastModel = slot;
|
|
15538
|
+
this.saveStore(store);
|
|
15539
|
+
return { success: true };
|
|
15540
|
+
});
|
|
15517
15541
|
}
|
|
15518
15542
|
hasActiveConfig() {
|
|
15519
15543
|
return this.getDefaultAssistantConfig() !== null;
|
|
@@ -15521,20 +15545,30 @@ var LLMConfigStore = class {
|
|
|
15521
15545
|
};
|
|
15522
15546
|
|
|
15523
15547
|
// ../../packages/node-runtime/src/ai/file-config-storage.ts
|
|
15524
|
-
import * as fs28 from "fs";
|
|
15525
15548
|
import * as path22 from "path";
|
|
15526
15549
|
function createFileConfigStorage(baseDir) {
|
|
15550
|
+
const heldLocks = /* @__PURE__ */ new Set();
|
|
15551
|
+
const getFilePath = (key) => path22.join(baseDir, `${key}.json`);
|
|
15527
15552
|
return {
|
|
15528
15553
|
readJson(key) {
|
|
15529
|
-
|
|
15530
|
-
return JSON.parse(fs28.readFileSync(path22.join(baseDir, `${key}.json`), "utf-8"));
|
|
15531
|
-
} catch {
|
|
15532
|
-
return null;
|
|
15533
|
-
}
|
|
15554
|
+
return readJsonFile(getFilePath(key));
|
|
15534
15555
|
},
|
|
15535
15556
|
writeJson(key, data) {
|
|
15536
|
-
|
|
15537
|
-
|
|
15557
|
+
const filePath = getFilePath(key);
|
|
15558
|
+
const write = () => writeJsonFileAtomically(filePath, data);
|
|
15559
|
+
if (heldLocks.has(key)) write();
|
|
15560
|
+
else withFileLock(filePath, write);
|
|
15561
|
+
},
|
|
15562
|
+
withLock(key, action) {
|
|
15563
|
+
if (heldLocks.has(key)) return action();
|
|
15564
|
+
return withFileLock(getFilePath(key), () => {
|
|
15565
|
+
heldLocks.add(key);
|
|
15566
|
+
try {
|
|
15567
|
+
return action();
|
|
15568
|
+
} finally {
|
|
15569
|
+
heldLocks.delete(key);
|
|
15570
|
+
}
|
|
15571
|
+
});
|
|
15538
15572
|
}
|
|
15539
15573
|
};
|
|
15540
15574
|
}
|
|
@@ -15542,23 +15576,57 @@ function createFileConfigStorage(baseDir) {
|
|
|
15542
15576
|
// ../../packages/node-runtime/src/ai/auth-profile-llm-config-store.ts
|
|
15543
15577
|
var defaultDeps = {
|
|
15544
15578
|
resolveApiKey: (provider, authProfile) => resolveApiKey(provider, authProfile) || void 0,
|
|
15579
|
+
loadAuthProfiles,
|
|
15545
15580
|
writeAuthProfile,
|
|
15546
15581
|
deleteAuthProfile
|
|
15547
15582
|
};
|
|
15548
15583
|
function getAuthProfile2(config) {
|
|
15549
15584
|
return config.authProfile;
|
|
15550
15585
|
}
|
|
15551
|
-
function
|
|
15586
|
+
function getNamedAuthProfile(config) {
|
|
15587
|
+
return config.name?.toLowerCase().replace(/\s+/g, "-") || config.provider;
|
|
15588
|
+
}
|
|
15589
|
+
function restoreLegacyAuthProfileReferences(configs, authProfiles) {
|
|
15590
|
+
const usedProfiles = new Set(configs.map(getAuthProfile2).filter((name) => Boolean(name)));
|
|
15591
|
+
for (const config of configs) {
|
|
15592
|
+
if (getAuthProfile2(config)) continue;
|
|
15593
|
+
const namedProfile = getNamedAuthProfile(config);
|
|
15594
|
+
const namedProfileValue = authProfiles.profiles[namedProfile];
|
|
15595
|
+
if (namedProfileValue?.provider === config.provider && !usedProfiles.has(namedProfile)) {
|
|
15596
|
+
;
|
|
15597
|
+
config.authProfile = namedProfile;
|
|
15598
|
+
usedProfiles.add(namedProfile);
|
|
15599
|
+
continue;
|
|
15600
|
+
}
|
|
15601
|
+
const baseName = deriveAuthProfileName(config.provider, config);
|
|
15602
|
+
for (let index = 1; index <= Object.keys(authProfiles.profiles).length; index++) {
|
|
15603
|
+
const candidate = index === 1 ? baseName : `${baseName}-${index}`;
|
|
15604
|
+
const profile = authProfiles.profiles[candidate];
|
|
15605
|
+
if (!profile || profile.provider !== config.provider || usedProfiles.has(candidate)) continue;
|
|
15606
|
+
config.authProfile = candidate;
|
|
15607
|
+
usedProfiles.add(candidate);
|
|
15608
|
+
break;
|
|
15609
|
+
}
|
|
15610
|
+
}
|
|
15611
|
+
}
|
|
15612
|
+
function createAuthProfileLlmConfigStore(storage, deps = {}) {
|
|
15613
|
+
const resolvedDeps = { ...defaultDeps, ...deps };
|
|
15552
15614
|
return new LLMConfigStore(storage, {
|
|
15553
|
-
|
|
15615
|
+
t: deps.t,
|
|
15616
|
+
generateId: deps.generateId,
|
|
15617
|
+
onStoreLoaded: (configs) => {
|
|
15618
|
+
restoreLegacyAuthProfileReferences(configs, resolvedDeps.loadAuthProfiles());
|
|
15619
|
+
deps.onStoreLoaded?.(configs);
|
|
15620
|
+
},
|
|
15621
|
+
resolveApiKey: resolvedDeps.resolveApiKey,
|
|
15554
15622
|
onApiKeyCreated: (config, apiKey) => {
|
|
15555
|
-
const profileName = config
|
|
15556
|
-
|
|
15623
|
+
const profileName = getNamedAuthProfile(config);
|
|
15624
|
+
resolvedDeps.writeAuthProfile(profileName, { type: "api_key", provider: config.provider, key: apiKey });
|
|
15557
15625
|
return profileName;
|
|
15558
15626
|
},
|
|
15559
15627
|
onApiKeyDeleted: (config) => {
|
|
15560
15628
|
const profileName = getAuthProfile2(config);
|
|
15561
|
-
if (profileName)
|
|
15629
|
+
if (profileName) resolvedDeps.deleteAuthProfile(profileName);
|
|
15562
15630
|
}
|
|
15563
15631
|
});
|
|
15564
15632
|
}
|
|
@@ -15572,43 +15640,52 @@ var CustomProviderStore = class {
|
|
|
15572
15640
|
this.storage = storage;
|
|
15573
15641
|
}
|
|
15574
15642
|
storage;
|
|
15643
|
+
withLock(action) {
|
|
15644
|
+
return this.storage.withLock ? this.storage.withLock("custom-providers", action) : action();
|
|
15645
|
+
}
|
|
15575
15646
|
getAll() {
|
|
15576
15647
|
return this.storage.readJson("custom-providers") ?? [];
|
|
15577
15648
|
}
|
|
15578
15649
|
add(input) {
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15594
|
-
|
|
15595
|
-
|
|
15650
|
+
return this.withLock(() => {
|
|
15651
|
+
const providers = this.getAll();
|
|
15652
|
+
const newProvider = {
|
|
15653
|
+
id: generateCustomId(),
|
|
15654
|
+
name: input.name,
|
|
15655
|
+
kind: input.kind || "openai-compatible",
|
|
15656
|
+
defaultBaseUrl: input.defaultBaseUrl,
|
|
15657
|
+
authMode: "api-key",
|
|
15658
|
+
supportsCustomModels: input.supportsCustomModels ?? true,
|
|
15659
|
+
modelIds: input.modelIds ?? [],
|
|
15660
|
+
builtin: false,
|
|
15661
|
+
enabledByDefault: false,
|
|
15662
|
+
website: input.website,
|
|
15663
|
+
consoleUrl: input.consoleUrl
|
|
15664
|
+
};
|
|
15665
|
+
providers.push(newProvider);
|
|
15666
|
+
this.storage.writeJson("custom-providers", providers);
|
|
15667
|
+
return newProvider;
|
|
15668
|
+
});
|
|
15596
15669
|
}
|
|
15597
15670
|
update(id, updates) {
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
|
|
15602
|
-
|
|
15603
|
-
|
|
15671
|
+
return this.withLock(() => {
|
|
15672
|
+
const providers = this.getAll();
|
|
15673
|
+
const index = providers.findIndex((p) => p.id === id);
|
|
15674
|
+
if (index === -1) return { success: false, error: "Custom provider not found" };
|
|
15675
|
+
providers[index] = { ...providers[index], ...updates };
|
|
15676
|
+
this.storage.writeJson("custom-providers", providers);
|
|
15677
|
+
return { success: true };
|
|
15678
|
+
});
|
|
15604
15679
|
}
|
|
15605
15680
|
delete(id) {
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15681
|
+
return this.withLock(() => {
|
|
15682
|
+
const providers = this.getAll();
|
|
15683
|
+
const index = providers.findIndex((p) => p.id === id);
|
|
15684
|
+
if (index === -1) return { success: false, error: "Custom provider not found" };
|
|
15685
|
+
providers.splice(index, 1);
|
|
15686
|
+
this.storage.writeJson("custom-providers", providers);
|
|
15687
|
+
return { success: true };
|
|
15688
|
+
});
|
|
15612
15689
|
}
|
|
15613
15690
|
};
|
|
15614
15691
|
var CustomModelStore = class {
|
|
@@ -15616,51 +15693,96 @@ var CustomModelStore = class {
|
|
|
15616
15693
|
this.storage = storage;
|
|
15617
15694
|
}
|
|
15618
15695
|
storage;
|
|
15696
|
+
withLock(action) {
|
|
15697
|
+
return this.storage.withLock ? this.storage.withLock("custom-models", action) : action();
|
|
15698
|
+
}
|
|
15619
15699
|
getAll() {
|
|
15620
15700
|
return this.storage.readJson("custom-models") ?? [];
|
|
15621
15701
|
}
|
|
15622
15702
|
add(input) {
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15703
|
+
return this.withLock(() => {
|
|
15704
|
+
const models = this.getAll();
|
|
15705
|
+
if (models.find((m) => m.id === input.id && m.providerId === input.providerId)) {
|
|
15706
|
+
return {
|
|
15707
|
+
success: false,
|
|
15708
|
+
error: `Model "${input.id}" already exists under provider "${input.providerId}"`
|
|
15709
|
+
};
|
|
15710
|
+
}
|
|
15711
|
+
const newModel = {
|
|
15712
|
+
id: input.id,
|
|
15713
|
+
providerId: input.providerId,
|
|
15714
|
+
name: input.name,
|
|
15715
|
+
description: input.description,
|
|
15716
|
+
contextWindow: input.contextWindow,
|
|
15717
|
+
capabilities: input.capabilities ?? ["chat"],
|
|
15718
|
+
recommendedFor: input.recommendedFor ?? ["chat"],
|
|
15719
|
+
status: input.status ?? "stable",
|
|
15720
|
+
builtin: false,
|
|
15721
|
+
editable: true
|
|
15628
15722
|
};
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
name: input.name,
|
|
15634
|
-
description: input.description,
|
|
15635
|
-
contextWindow: input.contextWindow,
|
|
15636
|
-
capabilities: input.capabilities ?? ["chat"],
|
|
15637
|
-
recommendedFor: input.recommendedFor ?? ["chat"],
|
|
15638
|
-
status: input.status ?? "stable",
|
|
15639
|
-
builtin: false,
|
|
15640
|
-
editable: true
|
|
15641
|
-
};
|
|
15642
|
-
models.push(newModel);
|
|
15643
|
-
this.storage.writeJson("custom-models", models);
|
|
15644
|
-
return { success: true, model: newModel };
|
|
15723
|
+
models.push(newModel);
|
|
15724
|
+
this.storage.writeJson("custom-models", models);
|
|
15725
|
+
return { success: true, model: newModel };
|
|
15726
|
+
});
|
|
15645
15727
|
}
|
|
15646
15728
|
update(providerId, modelId, updates) {
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15729
|
+
return this.withLock(() => {
|
|
15730
|
+
const models = this.getAll();
|
|
15731
|
+
const index = models.findIndex((m) => m.id === modelId && m.providerId === providerId);
|
|
15732
|
+
if (index === -1) return { success: false, error: "Custom model not found" };
|
|
15733
|
+
models[index] = { ...models[index], ...updates };
|
|
15734
|
+
this.storage.writeJson("custom-models", models);
|
|
15735
|
+
return { success: true };
|
|
15736
|
+
});
|
|
15653
15737
|
}
|
|
15654
15738
|
delete(providerId, modelId) {
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15739
|
+
return this.withLock(() => {
|
|
15740
|
+
const models = this.getAll();
|
|
15741
|
+
const index = models.findIndex((m) => m.id === modelId && m.providerId === providerId);
|
|
15742
|
+
if (index === -1) return { success: false, error: "Custom model not found" };
|
|
15743
|
+
models.splice(index, 1);
|
|
15744
|
+
this.storage.writeJson("custom-models", models);
|
|
15745
|
+
return { success: true };
|
|
15746
|
+
});
|
|
15661
15747
|
}
|
|
15662
15748
|
};
|
|
15663
15749
|
|
|
15750
|
+
// ../../packages/node-runtime/src/ai/llm-runtime-stores.ts
|
|
15751
|
+
function ensureLegacyCustomModels(configs, customModelStore) {
|
|
15752
|
+
for (const config of configs) {
|
|
15753
|
+
const providerId = config.provider;
|
|
15754
|
+
if (config.model && getBuiltinProviderById(providerId) && !getBuiltinModelById(providerId, config.model)) {
|
|
15755
|
+
customModelStore.add({
|
|
15756
|
+
id: config.model,
|
|
15757
|
+
providerId,
|
|
15758
|
+
name: config.model,
|
|
15759
|
+
capabilities: ["chat"],
|
|
15760
|
+
recommendedFor: ["chat"],
|
|
15761
|
+
status: "stable"
|
|
15762
|
+
});
|
|
15763
|
+
}
|
|
15764
|
+
}
|
|
15765
|
+
}
|
|
15766
|
+
function createLlmRuntimeStores(aiDataDir, options2 = {}) {
|
|
15767
|
+
const storage = createFileConfigStorage(aiDataDir);
|
|
15768
|
+
const customProviderStore = new CustomProviderStore(storage);
|
|
15769
|
+
const customModelStore = new CustomModelStore(storage);
|
|
15770
|
+
const llmConfigStore = createAuthProfileLlmConfigStore(storage, {
|
|
15771
|
+
...options2.authProfileDeps,
|
|
15772
|
+
t: options2.t,
|
|
15773
|
+
generateId: options2.generateId,
|
|
15774
|
+
onStoreLoaded: (configs) => {
|
|
15775
|
+
ensureLegacyCustomModels(configs, customModelStore);
|
|
15776
|
+
options2.onStoreLoaded?.(configs);
|
|
15777
|
+
}
|
|
15778
|
+
});
|
|
15779
|
+
return {
|
|
15780
|
+
llmConfigStore,
|
|
15781
|
+
customProviderStore,
|
|
15782
|
+
customModelStore
|
|
15783
|
+
};
|
|
15784
|
+
}
|
|
15785
|
+
|
|
15664
15786
|
// ../../packages/node-runtime/src/ai/llm-builder.ts
|
|
15665
15787
|
function normalizeAnthropicBaseUrl(url) {
|
|
15666
15788
|
return url.replace(/\/v1\/?$/, "");
|
|
@@ -16382,7 +16504,7 @@ function exportWithFormat(params, openDatabase) {
|
|
|
16382
16504
|
}
|
|
16383
16505
|
|
|
16384
16506
|
// ../../packages/node-runtime/src/merger/temp-db.ts
|
|
16385
|
-
import * as
|
|
16507
|
+
import * as fs28 from "fs";
|
|
16386
16508
|
import * as path23 from "path";
|
|
16387
16509
|
var TEMP_DB_SCHEMA = `
|
|
16388
16510
|
CREATE TABLE IF NOT EXISTS meta (
|
|
@@ -16628,18 +16750,18 @@ function exportSessionToJson(db) {
|
|
|
16628
16750
|
}
|
|
16629
16751
|
function deleteTempDatabase(dbPath) {
|
|
16630
16752
|
try {
|
|
16631
|
-
if (
|
|
16753
|
+
if (fs28.existsSync(dbPath)) fs28.unlinkSync(dbPath);
|
|
16632
16754
|
const walPath = dbPath + "-wal";
|
|
16633
16755
|
const shmPath = dbPath + "-shm";
|
|
16634
|
-
if (
|
|
16635
|
-
if (
|
|
16756
|
+
if (fs28.existsSync(walPath)) fs28.unlinkSync(walPath);
|
|
16757
|
+
if (fs28.existsSync(shmPath)) fs28.unlinkSync(shmPath);
|
|
16636
16758
|
} catch {
|
|
16637
16759
|
}
|
|
16638
16760
|
}
|
|
16639
16761
|
function cleanupTempDatabases(tempDir) {
|
|
16640
16762
|
try {
|
|
16641
|
-
if (!
|
|
16642
|
-
const files =
|
|
16763
|
+
if (!fs28.existsSync(tempDir)) return;
|
|
16764
|
+
const files = fs28.readdirSync(tempDir);
|
|
16643
16765
|
for (const file of files) {
|
|
16644
16766
|
if (file.startsWith("merge_") && file.endsWith(".db")) {
|
|
16645
16767
|
deleteTempDatabase(path23.join(tempDir, file));
|
|
@@ -17027,7 +17149,7 @@ function clearSessionOwner(adapter, sessionId) {
|
|
|
17027
17149
|
}
|
|
17028
17150
|
|
|
17029
17151
|
// ../../packages/node-runtime/src/services/contacts/overrides.ts
|
|
17030
|
-
import
|
|
17152
|
+
import fs29 from "fs";
|
|
17031
17153
|
import path24 from "path";
|
|
17032
17154
|
var CONTACT_OVERRIDES_FILE_NAME = "contact-overrides.json";
|
|
17033
17155
|
var CONTACT_OVERRIDES_TMP_PREFIX = "contact-overrides.tmp-";
|
|
@@ -17043,19 +17165,19 @@ function getContactOverridesPath(snapshotDir) {
|
|
|
17043
17165
|
}
|
|
17044
17166
|
function readContactOverrides(snapshotDir) {
|
|
17045
17167
|
const filePath = getContactOverridesPath(snapshotDir);
|
|
17046
|
-
if (!
|
|
17168
|
+
if (!fs29.existsSync(filePath)) return createEmptyContactOverridesFile();
|
|
17047
17169
|
try {
|
|
17048
|
-
return normalizeContactOverrides(JSON.parse(
|
|
17170
|
+
return normalizeContactOverrides(JSON.parse(fs29.readFileSync(filePath, "utf-8")));
|
|
17049
17171
|
} catch (error) {
|
|
17050
17172
|
appLogger.warn("contacts", "contact overrides file is unreadable", error);
|
|
17051
17173
|
return createEmptyContactOverridesFile();
|
|
17052
17174
|
}
|
|
17053
17175
|
}
|
|
17054
17176
|
function writeContactOverrides(snapshotDir, overrides) {
|
|
17055
|
-
if (!
|
|
17177
|
+
if (!fs29.existsSync(snapshotDir)) fs29.mkdirSync(snapshotDir, { recursive: true });
|
|
17056
17178
|
const tmpPath = path24.join(snapshotDir, `${CONTACT_OVERRIDES_TMP_PREFIX}${process.pid}-${Date.now()}`);
|
|
17057
|
-
|
|
17058
|
-
|
|
17179
|
+
fs29.writeFileSync(tmpPath, JSON.stringify(normalizeContactOverrides(overrides), null, 2), "utf-8");
|
|
17180
|
+
fs29.renameSync(tmpPath, getContactOverridesPath(snapshotDir));
|
|
17059
17181
|
}
|
|
17060
17182
|
function normalizeContactOverrides(value) {
|
|
17061
17183
|
const input = isRecord3(value) ? value : {};
|
|
@@ -17090,7 +17212,7 @@ function buildContactsSignature(adapter, timeRangePreset) {
|
|
|
17090
17212
|
}
|
|
17091
17213
|
|
|
17092
17214
|
// ../../packages/node-runtime/src/services/contacts/snapshot.ts
|
|
17093
|
-
import
|
|
17215
|
+
import fs30 from "fs";
|
|
17094
17216
|
import path25 from "path";
|
|
17095
17217
|
var CONTACTS_SNAPSHOT_TMP_PREFIX = "contacts-snapshot.tmp-";
|
|
17096
17218
|
function getContactsSnapshotPath(snapshotDir, timeRangePreset) {
|
|
@@ -17099,14 +17221,14 @@ function getContactsSnapshotPath(snapshotDir, timeRangePreset) {
|
|
|
17099
17221
|
}
|
|
17100
17222
|
function readContactsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
|
|
17101
17223
|
const snapshotPath = getContactsSnapshotPath(snapshotDir, timeRangePreset);
|
|
17102
|
-
if (!
|
|
17224
|
+
if (!fs30.existsSync(snapshotPath)) return null;
|
|
17103
17225
|
try {
|
|
17104
|
-
return JSON.parse(
|
|
17226
|
+
return JSON.parse(fs30.readFileSync(snapshotPath, "utf-8"));
|
|
17105
17227
|
} catch (error) {
|
|
17106
17228
|
const ts = options2.now?.() ?? Date.now();
|
|
17107
17229
|
const backupPath = path25.join(snapshotDir, `contacts-snapshot.corrupt-${ts}.json`);
|
|
17108
17230
|
try {
|
|
17109
|
-
|
|
17231
|
+
fs30.renameSync(snapshotPath, backupPath);
|
|
17110
17232
|
} catch (renameError) {
|
|
17111
17233
|
appLogger.warn("contacts", "failed to backup corrupt contacts snapshot", renameError);
|
|
17112
17234
|
}
|
|
@@ -17115,17 +17237,17 @@ function readContactsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
|
|
|
17115
17237
|
}
|
|
17116
17238
|
}
|
|
17117
17239
|
function writeContactsSnapshot(snapshotDir, snapshot) {
|
|
17118
|
-
if (!
|
|
17240
|
+
if (!fs30.existsSync(snapshotDir)) fs30.mkdirSync(snapshotDir, { recursive: true });
|
|
17119
17241
|
const tmpPath = path25.join(snapshotDir, `${CONTACTS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
|
|
17120
|
-
|
|
17121
|
-
|
|
17242
|
+
fs30.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
17243
|
+
fs30.renameSync(tmpPath, getContactsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
|
|
17122
17244
|
}
|
|
17123
17245
|
function cleanupContactsSnapshotTempFiles(snapshotDir) {
|
|
17124
|
-
if (!
|
|
17125
|
-
for (const name of
|
|
17246
|
+
if (!fs30.existsSync(snapshotDir)) return;
|
|
17247
|
+
for (const name of fs30.readdirSync(snapshotDir)) {
|
|
17126
17248
|
if (!name.startsWith(CONTACTS_SNAPSHOT_TMP_PREFIX)) continue;
|
|
17127
17249
|
try {
|
|
17128
|
-
|
|
17250
|
+
fs30.rmSync(path25.join(snapshotDir, name), { force: true });
|
|
17129
17251
|
} catch (error) {
|
|
17130
17252
|
appLogger.warn("contacts", "failed to remove contacts snapshot temp file", error);
|
|
17131
17253
|
}
|
|
@@ -17623,7 +17745,7 @@ function buildPeopleRelationshipsSignature(adapter, timeRangePreset) {
|
|
|
17623
17745
|
}
|
|
17624
17746
|
|
|
17625
17747
|
// ../../packages/node-runtime/src/services/people/relationships/snapshot.ts
|
|
17626
|
-
import
|
|
17748
|
+
import fs31 from "fs";
|
|
17627
17749
|
import path26 from "path";
|
|
17628
17750
|
var PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX = "people-relationships-snapshot.tmp-";
|
|
17629
17751
|
function getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset) {
|
|
@@ -17632,14 +17754,14 @@ function getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset) {
|
|
|
17632
17754
|
}
|
|
17633
17755
|
function readPeopleRelationshipsSnapshot(snapshotDir, timeRangePreset, options2 = {}) {
|
|
17634
17756
|
const snapshotPath = getPeopleRelationshipsSnapshotPath(snapshotDir, timeRangePreset);
|
|
17635
|
-
if (!
|
|
17757
|
+
if (!fs31.existsSync(snapshotPath)) return null;
|
|
17636
17758
|
try {
|
|
17637
|
-
return JSON.parse(
|
|
17759
|
+
return JSON.parse(fs31.readFileSync(snapshotPath, "utf-8"));
|
|
17638
17760
|
} catch (error) {
|
|
17639
17761
|
const ts = options2.now?.() ?? Date.now();
|
|
17640
17762
|
const backupPath = path26.join(snapshotDir, `graph-snapshot.corrupt-${ts}.json`);
|
|
17641
17763
|
try {
|
|
17642
|
-
|
|
17764
|
+
fs31.renameSync(snapshotPath, backupPath);
|
|
17643
17765
|
} catch (renameError) {
|
|
17644
17766
|
appLogger.warn("people-relationships", "failed to backup corrupt people relationships snapshot", renameError);
|
|
17645
17767
|
}
|
|
@@ -17648,17 +17770,17 @@ function readPeopleRelationshipsSnapshot(snapshotDir, timeRangePreset, options2
|
|
|
17648
17770
|
}
|
|
17649
17771
|
}
|
|
17650
17772
|
function writePeopleRelationshipsSnapshot(snapshotDir, snapshot) {
|
|
17651
|
-
if (!
|
|
17773
|
+
if (!fs31.existsSync(snapshotDir)) fs31.mkdirSync(snapshotDir, { recursive: true });
|
|
17652
17774
|
const tmpPath = path26.join(snapshotDir, `${PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX}${process.pid}-${Date.now()}`);
|
|
17653
|
-
|
|
17654
|
-
|
|
17775
|
+
fs31.writeFileSync(tmpPath, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
17776
|
+
fs31.renameSync(tmpPath, getPeopleRelationshipsSnapshotPath(snapshotDir, snapshot.timeRange.preset));
|
|
17655
17777
|
}
|
|
17656
17778
|
function cleanupPeopleRelationshipsSnapshotTempFiles(snapshotDir) {
|
|
17657
|
-
if (!
|
|
17658
|
-
for (const name of
|
|
17779
|
+
if (!fs31.existsSync(snapshotDir)) return;
|
|
17780
|
+
for (const name of fs31.readdirSync(snapshotDir)) {
|
|
17659
17781
|
if (!name.startsWith(PEOPLE_RELATIONSHIPS_SNAPSHOT_TMP_PREFIX)) continue;
|
|
17660
17782
|
try {
|
|
17661
|
-
|
|
17783
|
+
fs31.rmSync(path26.join(snapshotDir, name), { force: true });
|
|
17662
17784
|
} catch (error) {
|
|
17663
17785
|
appLogger.warn("people-relationships", "failed to remove people relationships snapshot temp file", error);
|
|
17664
17786
|
}
|
|
@@ -17794,8 +17916,10 @@ var DefaultPeopleRelationshipsService = class {
|
|
|
17794
17916
|
const snapshot = this.getSnapshotForResponse(timeRangePreset);
|
|
17795
17917
|
const status = this.getCacheStatus(signature, timeRangePreset);
|
|
17796
17918
|
const includeSnapshot = shouldIncludeSnapshot(status, options2.acceptStale);
|
|
17797
|
-
const
|
|
17798
|
-
const
|
|
17919
|
+
const graphScope = normalizePeopleRelationshipsGraphScope(options2.graphScope);
|
|
17920
|
+
const scopedSnapshot = snapshot ? buildNeighborhoodSnapshotForScope(snapshot, graphScope) : null;
|
|
17921
|
+
const graph = includeSnapshot && scopedSnapshot ? buildPeopleRelationshipsNeighborhoodGraph(scopedSnapshot, key) : emptyGraph();
|
|
17922
|
+
const contact = includeSnapshot ? scopedSnapshot?.nodes.find((node) => node.key === key) ?? null : null;
|
|
17799
17923
|
return {
|
|
17800
17924
|
contact,
|
|
17801
17925
|
graph,
|
|
@@ -17927,7 +18051,7 @@ var DefaultPeopleRelationshipsService = class {
|
|
|
17927
18051
|
const graph = includeSnapshot && snapshot ? buildGraphForScope(snapshot, graphScope) : emptyGraph();
|
|
17928
18052
|
return {
|
|
17929
18053
|
graph,
|
|
17930
|
-
searchResults: includeSnapshot && snapshot ? buildSearchResults(snapshot, options2.query, graph) : [],
|
|
18054
|
+
searchResults: includeSnapshot && snapshot ? buildSearchResults(snapshot, options2.query, graph, graphScope) : [],
|
|
17931
18055
|
diagnostics: includeSnapshot ? sanitizePeopleRelationshipsDiagnostics(snapshot?.diagnostics ?? createEmptyDiagnostics()) : createEmptyDiagnostics(),
|
|
17932
18056
|
algorithmVersion: includeSnapshot ? snapshot?.algorithmVersion ?? PEOPLE_RELATIONSHIPS_ALGORITHM_VERSION : PEOPLE_RELATIONSHIPS_ALGORITHM_VERSION,
|
|
17933
18057
|
timeRange: snapshot?.timeRange ?? resolvePeopleRelationshipsTimeRange(timeRangePreset, null),
|
|
@@ -17985,6 +18109,16 @@ function buildFriendsRelationshipsGraph(snapshot) {
|
|
|
17985
18109
|
communities: filterCommunitiesForNodes(snapshot.communities, nodes)
|
|
17986
18110
|
};
|
|
17987
18111
|
}
|
|
18112
|
+
function buildNeighborhoodSnapshotForScope(snapshot, scope) {
|
|
18113
|
+
if (scope !== "friends") return snapshot;
|
|
18114
|
+
const graph = buildFriendsRelationshipsGraph(snapshot);
|
|
18115
|
+
return {
|
|
18116
|
+
...snapshot,
|
|
18117
|
+
nodes: graph.nodes,
|
|
18118
|
+
edges: graph.edges,
|
|
18119
|
+
communities: graph.communities
|
|
18120
|
+
};
|
|
18121
|
+
}
|
|
17988
18122
|
function buildCloseRelationshipsGraph(snapshot) {
|
|
17989
18123
|
const selectedKeys = /* @__PURE__ */ new Set();
|
|
17990
18124
|
for (const node of snapshot.nodes) {
|
|
@@ -18025,11 +18159,12 @@ function filterCommunitiesForNodes(communities, nodes) {
|
|
|
18025
18159
|
size: communitySizes.get(community.id) ?? community.size
|
|
18026
18160
|
}));
|
|
18027
18161
|
}
|
|
18028
|
-
function buildSearchResults(snapshot, queryInput, graph) {
|
|
18162
|
+
function buildSearchResults(snapshot, queryInput, graph, graphScope) {
|
|
18029
18163
|
const query = queryInput?.trim().toLowerCase() ?? "";
|
|
18030
18164
|
if (!query) return [];
|
|
18031
18165
|
const visibleKeys = new Set(graph.nodes.map((node) => node.key));
|
|
18032
|
-
|
|
18166
|
+
const searchableNodes = graphScope === "friends" ? graph.nodes : snapshot.nodes;
|
|
18167
|
+
return searchableNodes.filter((node) => node.searchText.includes(query)).sort(compareNodes).slice(0, snapshot.limits.searchResultLimit).map((node) => ({
|
|
18033
18168
|
key: node.key,
|
|
18034
18169
|
kind: node.kind,
|
|
18035
18170
|
displayName: node.displayName,
|
|
@@ -18180,7 +18315,7 @@ __export(relationships_exports, {
|
|
|
18180
18315
|
});
|
|
18181
18316
|
|
|
18182
18317
|
// ../../packages/node-runtime/src/services/global-insight/service.ts
|
|
18183
|
-
import
|
|
18318
|
+
import fs32 from "fs";
|
|
18184
18319
|
|
|
18185
18320
|
// ../../packages/node-runtime/src/services/global-insight/signature.ts
|
|
18186
18321
|
function buildAnnualSummarySignature(adapter, range) {
|
|
@@ -18413,6 +18548,7 @@ var DefaultGlobalInsightService = class {
|
|
|
18413
18548
|
latestDataYear: includeSnapshot ? snapshot?.latestDataYear ?? null : null,
|
|
18414
18549
|
metrics: includeSnapshot ? snapshot?.metrics ?? null : null,
|
|
18415
18550
|
monthlyActivity: includeSnapshot ? snapshot?.monthlyActivity ?? [] : [],
|
|
18551
|
+
monthlyDirectContacts: includeSnapshot ? snapshot?.monthlyDirectContacts ?? [] : [],
|
|
18416
18552
|
dailyActivity: includeSnapshot ? snapshot?.dailyActivity ?? [] : [],
|
|
18417
18553
|
messageTypes: includeSnapshot ? snapshot?.messageTypes ?? [] : [],
|
|
18418
18554
|
textLength: includeSnapshot ? snapshot?.textLength ?? null : null,
|
|
@@ -18433,7 +18569,7 @@ var DefaultGlobalInsightService = class {
|
|
|
18433
18569
|
}
|
|
18434
18570
|
getSnapshot(range) {
|
|
18435
18571
|
const key = toAnnualSummaryRangeKey(range);
|
|
18436
|
-
if (this.snapshots.has(key) && !
|
|
18572
|
+
if (this.snapshots.has(key) && !fs32.existsSync(getAnnualSummarySnapshotPath(this.snapshotDir, range))) {
|
|
18437
18573
|
this.snapshots.delete(key);
|
|
18438
18574
|
}
|
|
18439
18575
|
if (!this.snapshots.has(key)) {
|
|
@@ -18481,7 +18617,7 @@ __export(global_insight_exports, {
|
|
|
18481
18617
|
});
|
|
18482
18618
|
|
|
18483
18619
|
// ../../packages/node-runtime/src/semantic-index/config.ts
|
|
18484
|
-
import
|
|
18620
|
+
import fs33 from "fs";
|
|
18485
18621
|
import path27 from "path";
|
|
18486
18622
|
var DEFAULT_SEMANTIC_INDEX_MODEL_DOWNLOAD_SOURCE = "huggingface";
|
|
18487
18623
|
var SEMANTIC_INDEX_CONFIG_VERSION = 1;
|
|
@@ -18571,9 +18707,9 @@ var SemanticIndexConfigStore = class {
|
|
|
18571
18707
|
return this.set({ ...this.get(), enabled });
|
|
18572
18708
|
}
|
|
18573
18709
|
get() {
|
|
18574
|
-
if (!
|
|
18710
|
+
if (!fs33.existsSync(this.filePath)) return defaultSemanticIndexConfig();
|
|
18575
18711
|
try {
|
|
18576
|
-
const raw = JSON.parse(
|
|
18712
|
+
const raw = JSON.parse(fs33.readFileSync(this.filePath, "utf-8"));
|
|
18577
18713
|
return normalizeConfig(raw);
|
|
18578
18714
|
} catch {
|
|
18579
18715
|
return defaultSemanticIndexConfig();
|
|
@@ -18582,8 +18718,8 @@ var SemanticIndexConfigStore = class {
|
|
|
18582
18718
|
set(config) {
|
|
18583
18719
|
const normalized = normalizeConfig(config);
|
|
18584
18720
|
const dir = path27.dirname(this.filePath);
|
|
18585
|
-
if (!
|
|
18586
|
-
|
|
18721
|
+
if (!fs33.existsSync(dir)) fs33.mkdirSync(dir, { recursive: true });
|
|
18722
|
+
fs33.writeFileSync(this.filePath, JSON.stringify(normalized, null, 2), "utf-8");
|
|
18587
18723
|
return normalized;
|
|
18588
18724
|
}
|
|
18589
18725
|
resolveModelId() {
|
|
@@ -20682,7 +20818,7 @@ ${text}`;
|
|
|
20682
20818
|
};
|
|
20683
20819
|
|
|
20684
20820
|
// ../../packages/node-runtime/src/services/merge-cache.ts
|
|
20685
|
-
import * as
|
|
20821
|
+
import * as fs34 from "fs";
|
|
20686
20822
|
import * as path29 from "path";
|
|
20687
20823
|
import * as crypto from "crypto";
|
|
20688
20824
|
var MergeSessionCache = class {
|
|
@@ -20692,8 +20828,8 @@ var MergeSessionCache = class {
|
|
|
20692
20828
|
constructor(pathProvider, options2) {
|
|
20693
20829
|
this.tempDir = pathProvider.getTempDir();
|
|
20694
20830
|
this.nativeBinding = options2?.nativeBinding;
|
|
20695
|
-
if (!
|
|
20696
|
-
|
|
20831
|
+
if (!fs34.existsSync(this.tempDir)) {
|
|
20832
|
+
fs34.mkdirSync(this.tempDir, { recursive: true });
|
|
20697
20833
|
}
|
|
20698
20834
|
}
|
|
20699
20835
|
generateTempDbPath(filename) {
|
|
@@ -20711,7 +20847,7 @@ var MergeSessionCache = class {
|
|
|
20711
20847
|
/** Open a TempDbReader for a given handle. Caller must close the reader. */
|
|
20712
20848
|
openReader(handle) {
|
|
20713
20849
|
const entry = this.cache.get(handle);
|
|
20714
|
-
if (!entry || !
|
|
20850
|
+
if (!entry || !fs34.existsSync(entry.tempDbPath)) return null;
|
|
20715
20851
|
const adapter = openBetterSqliteDatabase(entry.tempDbPath, {
|
|
20716
20852
|
readonly: true,
|
|
20717
20853
|
nativeBinding: this.nativeBinding
|
|
@@ -20756,7 +20892,7 @@ var MergeSessionCache = class {
|
|
|
20756
20892
|
};
|
|
20757
20893
|
|
|
20758
20894
|
// ../../packages/node-runtime/src/services/push-importer.ts
|
|
20759
|
-
import * as
|
|
20895
|
+
import * as fs35 from "fs";
|
|
20760
20896
|
var SYSTEM_SENDER_ID = "SYSTEM";
|
|
20761
20897
|
var SYSTEM_MEMBER_NAME = "\u7CFB\u7EDF\u6D88\u606F";
|
|
20762
20898
|
function isRecord4(value) {
|
|
@@ -21123,7 +21259,7 @@ async function executePushImportUnlocked(deps, sessionId, payload) {
|
|
|
21123
21259
|
return { ok: false, reason: "invalid_payload", message: "sessionId contains invalid characters" };
|
|
21124
21260
|
}
|
|
21125
21261
|
const dbPath = deps.getDbPath(sessionId);
|
|
21126
|
-
const isNew = !
|
|
21262
|
+
const isNew = !fs35.existsSync(dbPath);
|
|
21127
21263
|
const validationError = validatePayload(payload, isNew);
|
|
21128
21264
|
if (validationError) {
|
|
21129
21265
|
return { ok: false, reason: "invalid_payload", message: validationError };
|
|
@@ -21357,6 +21493,7 @@ export {
|
|
|
21357
21493
|
createAuthProfileLlmConfigStore,
|
|
21358
21494
|
CustomProviderStore,
|
|
21359
21495
|
CustomModelStore,
|
|
21496
|
+
createLlmRuntimeStores,
|
|
21360
21497
|
normalizeAnthropicBaseUrl,
|
|
21361
21498
|
normalizeOpenAICompatibleBaseUrl,
|
|
21362
21499
|
buildPiModel,
|
|
@@ -21449,4 +21586,4 @@ export {
|
|
|
21449
21586
|
hashImportBody,
|
|
21450
21587
|
ImportIdempotencyCache
|
|
21451
21588
|
};
|
|
21452
|
-
//# sourceMappingURL=chunk-
|
|
21589
|
+
//# sourceMappingURL=chunk-AQPDZAWB.mjs.map
|