chatlab-cli 0.22.0 → 0.23.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/{chunk-3UBWLWXB.mjs → chunk-3MX7VF2B.mjs} +2 -2
- package/dist/chunk-5ADKYYNA.mjs +28 -0
- package/dist/chunk-5ADKYYNA.mjs.map +1 -0
- package/dist/{chunk-4U45E7TO.mjs → chunk-643S2N2U.mjs} +2 -2
- package/dist/{chunk-AMMSVJG4.mjs → chunk-D2BR3MFN.mjs} +132 -43
- package/dist/chunk-D2BR3MFN.mjs.map +1 -0
- package/dist/{chunk-6NB475AA.mjs → chunk-FJ35V3TE.mjs} +2 -17
- package/dist/chunk-FJ35V3TE.mjs.map +1 -0
- package/dist/{chunk-QJQJIUUS.mjs → chunk-G7Q7EQ3V.mjs} +618 -108
- package/dist/chunk-G7Q7EQ3V.mjs.map +1 -0
- package/dist/{chunk-6GLMVWGA.mjs → chunk-NTWDG52H.mjs} +66 -68
- package/dist/chunk-NTWDG52H.mjs.map +1 -0
- package/dist/{chunk-D2XJ4Z7G.mjs → chunk-WTQ7LAZR.mjs} +2 -2
- package/dist/cli.mjs +4 -3
- package/dist/{http-R5UECMPJ.mjs → http-2DN3XOXO.mjs} +8 -7
- package/dist/{import-3LOWRXWA.mjs → import-LCBSBLYF.mjs} +4 -4
- package/dist/index.mjs +10 -9
- package/dist/{mcp-WBHNLED2.mjs → mcp-AR7HBIK4.mjs} +8 -6
- package/dist/{mcp-WBHNLED2.mjs.map → mcp-AR7HBIK4.mjs.map} +1 -1
- package/dist/service-WNEVPQ4N.mjs +258 -0
- package/dist/service-WNEVPQ4N.mjs.map +1 -0
- package/dist/{src-UHM2UDRD.mjs → src-EGXULYFQ.mjs} +2 -2
- package/dist/{stream-import-V6Z7DXSW.mjs → stream-import-QM5R5FDG.mjs} +3 -3
- package/dist/{update-checker-MQMQ6A4B.mjs → update-checker-JG5K67O2.mjs} +3 -2
- package/dist/{update-checker-MQMQ6A4B.mjs.map → update-checker-JG5K67O2.mjs.map} +1 -1
- package/dist-web/assets/{DebugToolsPanel-DkbsB6lr.css → DebugToolsPanel-D9O_4J04.css} +1 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-hp9Mjpub.js +161 -0
- package/dist-web/assets/{EChartWordcloud-Ubal_aYg.js → EChartWordcloud-Cenbzcyj.js} +1 -1
- package/dist-web/assets/MessageExportModal-CvocO88D.js +1 -0
- package/dist-web/assets/electron-DpE69lO4.js +1 -0
- package/dist-web/assets/electron-SyPZX9OU.js +1 -0
- package/dist-web/assets/{fetch-BS4SlQjA.js → fetch-B7OBmANJ.js} +1 -1
- package/dist-web/assets/{fetch-o5NJ2uWE.js → fetch-BikSxuED.js} +1 -1
- package/dist-web/assets/fetch-BwMZFwbF.js +1 -0
- package/dist-web/assets/fetch-CfTcWxqG.js +1 -0
- package/dist-web/assets/fetch-DTP8Q782.js +17 -0
- package/dist-web/assets/{fetch-W43zfemj.js → fetch-LBHcBBkv.js} +1 -1
- package/dist-web/assets/http-C741fIwb.js +1 -0
- package/dist-web/assets/index-B6dkyIiA.js +2 -0
- package/dist-web/assets/index-CALU1QPF.js +163 -0
- package/dist-web/assets/{index-BJUGnYn5.js → index-CHkXbqMb.js} +1 -1
- package/dist-web/assets/index-CvuHOeoU.css +1 -0
- package/dist-web/assets/{index-BE64tUWq.css → index-CxMP0DNd.css} +1 -1
- package/dist-web/assets/index-DOS5o2_H.js +7 -0
- package/dist-web/assets/{index-CbQMfheg.css → index-DuepdDzz.css} +1 -1
- package/dist-web/assets/index-niwrSprs.js +173 -0
- package/dist-web/assets/model-catalog-DUuKjIVU.js +1 -0
- package/dist-web/assets/{vendor-nuxt-ui-7OAuiz_i.js → vendor-nuxt-ui-CuCZ1aRl.js} +2 -2
- package/dist-web/assets/vendor-reka-ui-BrTYuIfH.js +11 -0
- package/dist-web/assets/{web-CZe0Ismu.js → web-DGd63PrV.js} +1 -1
- package/dist-web/index.html +4 -4
- package/package.json +1 -1
- package/dist/chunk-6GLMVWGA.mjs.map +0 -1
- package/dist/chunk-6NB475AA.mjs.map +0 -1
- package/dist/chunk-AMMSVJG4.mjs.map +0 -1
- package/dist/chunk-QJQJIUUS.mjs.map +0 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-CxYyne-Q.js +0 -147
- package/dist-web/assets/MessageExportModal-De5_tX6a.js +0 -1
- package/dist-web/assets/electron-8qi0d92j.js +0 -1
- package/dist-web/assets/electron-H65bUnhW.js +0 -1
- package/dist-web/assets/fetch-CclRWOHf.js +0 -1
- package/dist-web/assets/fetch-Q-PqsiMb.js +0 -17
- package/dist-web/assets/fetch-cFjLAPG2.js +0 -1
- package/dist-web/assets/http-CeXMt-Fv.js +0 -1
- package/dist-web/assets/index-B_31fXeB.js +0 -2
- package/dist-web/assets/index-CbOwHYzO.css +0 -1
- package/dist-web/assets/index-DKMUn8F5.js +0 -173
- package/dist-web/assets/index-D_ksezTw.js +0 -163
- package/dist-web/assets/index-Dhg3SDb6.js +0 -7
- package/dist-web/assets/vendor-reka-ui-CW2cIgMu.js +0 -11
- /package/dist/{chunk-3UBWLWXB.mjs.map → chunk-3MX7VF2B.mjs.map} +0 -0
- /package/dist/{chunk-4U45E7TO.mjs.map → chunk-643S2N2U.mjs.map} +0 -0
- /package/dist/{chunk-D2XJ4Z7G.mjs.map → chunk-WTQ7LAZR.mjs.map} +0 -0
- /package/dist/{http-R5UECMPJ.mjs.map → http-2DN3XOXO.mjs.map} +0 -0
- /package/dist/{import-3LOWRXWA.mjs.map → import-LCBSBLYF.mjs.map} +0 -0
- /package/dist/{src-UHM2UDRD.mjs.map → src-EGXULYFQ.mjs.map} +0 -0
- /package/dist/{stream-import-V6Z7DXSW.mjs.map → stream-import-QM5R5FDG.mjs.map} +0 -0
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
generateMessageKey,
|
|
12
12
|
openBetterSqliteDatabase,
|
|
13
13
|
writeParseResultToDb
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-G7Q7EQ3V.mjs";
|
|
15
15
|
|
|
16
16
|
// src/import/chatlab-reader.ts
|
|
17
17
|
import * as fs from "fs";
|
|
@@ -392,4 +392,4 @@ export {
|
|
|
392
392
|
parseFile,
|
|
393
393
|
importData
|
|
394
394
|
};
|
|
395
|
-
//# sourceMappingURL=chunk-
|
|
395
|
+
//# sourceMappingURL=chunk-3MX7VF2B.mjs.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module';
|
|
2
|
+
import { dirname as __pathDirname } from 'path';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
resolveCliPath
|
|
9
|
+
} from "./chunk-FJ35V3TE.mjs";
|
|
10
|
+
|
|
11
|
+
// src/version.ts
|
|
12
|
+
import { readFileSync } from "fs";
|
|
13
|
+
var cached;
|
|
14
|
+
function getVersion() {
|
|
15
|
+
if (cached) return cached;
|
|
16
|
+
try {
|
|
17
|
+
const pkgPath = resolveCliPath("package.json");
|
|
18
|
+
cached = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
|
|
19
|
+
} catch {
|
|
20
|
+
cached = "0.0.0-dev";
|
|
21
|
+
}
|
|
22
|
+
return cached;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
getVersion
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-5ADKYYNA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["import { readFileSync } from 'fs'\nimport { resolveCliPath } from './paths'\n\nlet cached: string | undefined\n\n/**\n * Read version from apps/cli/package.json at runtime.\n * Works for both tsx dev (src/) and bundled (dist/).\n */\nexport function getVersion(): string {\n if (cached) return cached\n try {\n const pkgPath = resolveCliPath('package.json')\n cached = JSON.parse(readFileSync(pkgPath, 'utf-8')).version\n } catch {\n cached = '0.0.0-dev'\n }\n return cached!\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,oBAAoB;AAG7B,IAAI;AAMG,SAAS,aAAqB;AACnC,MAAI,OAAQ,QAAO;AACnB,MAAI;AACF,UAAM,UAAU,eAAe,cAAc;AAC7C,aAAS,KAAK,MAAM,aAAa,SAAS,OAAO,CAAC,EAAE;AAAA,EACtD,QAAQ;AACN,aAAS;AAAA,EACX;AACA,SAAO;AACT;","names":[]}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
incrementalImport,
|
|
14
14
|
openBetterSqliteDatabase,
|
|
15
15
|
streamingImport
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-G7Q7EQ3V.mjs";
|
|
17
17
|
|
|
18
18
|
// src/import/stream-import.ts
|
|
19
19
|
import * as fs from "fs";
|
|
@@ -141,4 +141,4 @@ export {
|
|
|
141
141
|
analyzeIncrementalImport2 as analyzeIncrementalImport,
|
|
142
142
|
analyzeNewImport2 as analyzeNewImport
|
|
143
143
|
};
|
|
144
|
-
//# sourceMappingURL=chunk-
|
|
144
|
+
//# sourceMappingURL=chunk-643S2N2U.mjs.map
|
|
@@ -7,21 +7,20 @@ const __dirname = __pathDirname(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
importData,
|
|
9
9
|
parseFile
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3MX7VF2B.mjs";
|
|
11
11
|
import {
|
|
12
12
|
analyzeIncrementalImport,
|
|
13
13
|
analyzeNewImport,
|
|
14
14
|
incrementalImport,
|
|
15
15
|
streamImport
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-643S2N2U.mjs";
|
|
17
17
|
import {
|
|
18
18
|
AGENT_TOOL_REGISTRY,
|
|
19
19
|
CoreDataProvider
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WTQ7LAZR.mjs";
|
|
21
21
|
import {
|
|
22
|
-
getVersion
|
|
23
|
-
|
|
24
|
-
} from "./chunk-6NB475AA.mjs";
|
|
22
|
+
getVersion
|
|
23
|
+
} from "./chunk-5ADKYYNA.mjs";
|
|
25
24
|
import {
|
|
26
25
|
AIConversationManager,
|
|
27
26
|
ALL_MIGRATIONS,
|
|
@@ -115,7 +114,10 @@ import {
|
|
|
115
114
|
verifyCliDataPath,
|
|
116
115
|
writeAuthProfile,
|
|
117
116
|
writeConfigField
|
|
118
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-G7Q7EQ3V.mjs";
|
|
118
|
+
import {
|
|
119
|
+
resolveCliPath
|
|
120
|
+
} from "./chunk-FJ35V3TE.mjs";
|
|
119
121
|
|
|
120
122
|
// src/http/index.ts
|
|
121
123
|
import * as fs14 from "fs";
|
|
@@ -847,6 +849,9 @@ function registerSqlRoutes(server2, adapter) {
|
|
|
847
849
|
|
|
848
850
|
// src/http/routes/web/session-index.ts
|
|
849
851
|
function registerSessionIndexRoutes(server2, adapter) {
|
|
852
|
+
server2.get("/_web/sessions/index-stats", async () => {
|
|
853
|
+
return session_index_service_exports.getAllIndexStats(adapter);
|
|
854
|
+
});
|
|
850
855
|
server2.post("/_web/sessions/:id/generate-index", async (request) => {
|
|
851
856
|
const gapThreshold = request.body?.gapThreshold ?? 1800;
|
|
852
857
|
const sessionCount = session_index_service_exports.generateIndex(adapter, request.params.id, gapThreshold);
|
|
@@ -1065,10 +1070,11 @@ function createSummaryDeps(dbManager2) {
|
|
|
1065
1070
|
function registerSummaryRoutes(server2, dbManager2, adapter) {
|
|
1066
1071
|
const deps = createSummaryDeps(dbManager2);
|
|
1067
1072
|
server2.post("/_web/sessions/:id/summaries/generate", async (request, reply) => {
|
|
1068
|
-
const { chatSessionId, locale, forceRegenerate } = request.body;
|
|
1073
|
+
const { chatSessionId, locale, forceRegenerate, strategy } = request.body;
|
|
1069
1074
|
const result = await summary_service_exports.generateSummary(adapter, request.params.id, chatSessionId, deps, {
|
|
1070
1075
|
locale,
|
|
1071
|
-
forceRegenerate
|
|
1076
|
+
forceRegenerate,
|
|
1077
|
+
strategy
|
|
1072
1078
|
});
|
|
1073
1079
|
if ("error" in result && !result.success) {
|
|
1074
1080
|
return reply.code(400).send({ error: result.error });
|
|
@@ -1086,6 +1092,10 @@ function registerSummaryRoutes(server2, dbManager2, adapter) {
|
|
|
1086
1092
|
}
|
|
1087
1093
|
return result;
|
|
1088
1094
|
});
|
|
1095
|
+
server2.post("/_web/sessions/:id/summaries/check-can-generate", async (request) => {
|
|
1096
|
+
const { chatSessionIds } = request.body;
|
|
1097
|
+
return summary_service_exports.checkCanGenerate(adapter, request.params.id, chatSessionIds);
|
|
1098
|
+
});
|
|
1089
1099
|
}
|
|
1090
1100
|
|
|
1091
1101
|
// src/http/routes/web/import.ts
|
|
@@ -1344,9 +1354,16 @@ data: ${JSON.stringify(eventData)}
|
|
|
1344
1354
|
cleanupTemp(tmpPath, tmpDir);
|
|
1345
1355
|
}
|
|
1346
1356
|
});
|
|
1357
|
+
const DEMO_FILES = [
|
|
1358
|
+
"demo-group.json",
|
|
1359
|
+
"demo-private-A-cuilan.json",
|
|
1360
|
+
"demo-private-B-wukong.json",
|
|
1361
|
+
"demo-private-C-spider.json"
|
|
1362
|
+
];
|
|
1347
1363
|
server2.post("/_web/demo/import", async (request, reply) => {
|
|
1348
1364
|
const locale = request.body?.locale || "en";
|
|
1349
1365
|
const nativeBinding = resolveNativeBinding();
|
|
1366
|
+
const total = DEMO_FILES.length;
|
|
1350
1367
|
reply.raw.writeHead(200, {
|
|
1351
1368
|
"Content-Type": "text/event-stream",
|
|
1352
1369
|
"Cache-Control": "no-cache",
|
|
@@ -1359,36 +1376,37 @@ data: ${JSON.stringify(eventData)}
|
|
|
1359
1376
|
`);
|
|
1360
1377
|
}
|
|
1361
1378
|
const tmpDir = fs4.mkdtempSync(path3.join(os.tmpdir(), "chatlab-demo-"));
|
|
1362
|
-
const groupPath = path3.join(tmpDir, "demo-group.json");
|
|
1363
|
-
const privatePath = path3.join(tmpDir, "demo-private.json");
|
|
1364
1379
|
try {
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
const groupResult = await streamImport(dbManager2, groupPath, { nativeBinding });
|
|
1380
|
+
const localPaths = [];
|
|
1381
|
+
for (let i = 0; i < total; i++) {
|
|
1382
|
+
sendEvent("progress", { stage: "downloading", current: i + 1, total });
|
|
1383
|
+
const localPath = path3.join(tmpDir, DEMO_FILES[i]);
|
|
1384
|
+
const resp = await fetch(`${DEMO_BASE_URL}/${locale}/${DEMO_FILES[i]}`, {
|
|
1385
|
+
signal: AbortSignal.timeout(6e4)
|
|
1386
|
+
});
|
|
1387
|
+
if (!resp.ok) throw new Error(`Download demo failed (${DEMO_FILES[i]}): ${resp.status}`);
|
|
1388
|
+
fs4.writeFileSync(localPath, Buffer.from(await resp.arrayBuffer()));
|
|
1389
|
+
localPaths.push(localPath);
|
|
1390
|
+
}
|
|
1391
|
+
sendEvent("progress", { stage: "importing", current: 1, total });
|
|
1392
|
+
const groupResult = await streamImport(dbManager2, localPaths[0], { nativeBinding });
|
|
1379
1393
|
if (!groupResult.success) throw new Error(groupResult.error || "Failed to import group demo");
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1394
|
+
const privateSessionIds = [];
|
|
1395
|
+
for (let i = 1; i < localPaths.length; i++) {
|
|
1396
|
+
sendEvent("progress", { stage: "importing", current: i + 1, total });
|
|
1397
|
+
const result = await streamImport(dbManager2, localPaths[i], { nativeBinding });
|
|
1398
|
+
if (!result.success) throw new Error(result.error || `Failed to import private demo: ${DEMO_FILES[i]}`);
|
|
1399
|
+
if (result.sessionId) privateSessionIds.push(result.sessionId);
|
|
1400
|
+
}
|
|
1401
|
+
sendEvent("progress", { stage: "done", current: total, total });
|
|
1384
1402
|
sendEvent("result", {
|
|
1385
1403
|
success: true,
|
|
1386
1404
|
groupSessionId: groupResult.sessionId,
|
|
1387
|
-
|
|
1405
|
+
privateSessionIds
|
|
1388
1406
|
});
|
|
1389
1407
|
} catch (err) {
|
|
1390
1408
|
const message = err instanceof Error ? err.message : String(err);
|
|
1391
|
-
sendEvent("progress", { stage: "error", current: 0, total
|
|
1409
|
+
sendEvent("progress", { stage: "error", current: 0, total, message });
|
|
1392
1410
|
sendEvent("result", { success: false, error: message });
|
|
1393
1411
|
} finally {
|
|
1394
1412
|
reply.raw.end();
|
|
@@ -1480,7 +1498,7 @@ function registerMergeRoutes(server2, dbManager2, mergeCache) {
|
|
|
1480
1498
|
const merged = buildMergedOutput(dataSources, outputName);
|
|
1481
1499
|
let sessionId;
|
|
1482
1500
|
if (andImport) {
|
|
1483
|
-
const { streamImport: serverStreamImport } = await import("./stream-import-
|
|
1501
|
+
const { streamImport: serverStreamImport } = await import("./stream-import-QM5R5FDG.mjs");
|
|
1484
1502
|
const jsonData = JSON.stringify(merged.chatLabData);
|
|
1485
1503
|
const tmpDir = fs5.mkdtempSync(path4.join(os2.tmpdir(), "chatlab-merged-"));
|
|
1486
1504
|
const tmpPath = path4.join(tmpDir, `${outputName}.json`);
|
|
@@ -1533,7 +1551,7 @@ function registerMergeRoutes(server2, dbManager2, mergeCache) {
|
|
|
1533
1551
|
const db = ensureDb2(dbManager2, sid);
|
|
1534
1552
|
const exported = exportSessionToJson(db);
|
|
1535
1553
|
const { db: tempDb, tempDbPath } = mergeCache.createTempDatabase(exported.meta.name);
|
|
1536
|
-
const { TempDbWriter } = await import("./src-
|
|
1554
|
+
const { TempDbWriter } = await import("./src-EGXULYFQ.mjs");
|
|
1537
1555
|
const writer = new TempDbWriter(tempDb);
|
|
1538
1556
|
writer.writeMeta({
|
|
1539
1557
|
name: exported.meta.name,
|
|
@@ -2091,6 +2109,7 @@ async function runServerAgent(options) {
|
|
|
2091
2109
|
const {
|
|
2092
2110
|
userMessage,
|
|
2093
2111
|
conversationId,
|
|
2112
|
+
historyLeafMessageId,
|
|
2094
2113
|
chatType = "group",
|
|
2095
2114
|
locale = "zh-CN",
|
|
2096
2115
|
assistantSystemPrompt,
|
|
@@ -2103,7 +2122,8 @@ async function runServerAgent(options) {
|
|
|
2103
2122
|
abortSignal,
|
|
2104
2123
|
ownerInfo,
|
|
2105
2124
|
mentionedMembers,
|
|
2106
|
-
dataSnapshot
|
|
2125
|
+
dataSnapshot,
|
|
2126
|
+
thinkingLevel
|
|
2107
2127
|
} = options;
|
|
2108
2128
|
const aiLogger = getServerAiLogger();
|
|
2109
2129
|
const llmConfig = getDefaultAssistantConfig(aiDataDir);
|
|
@@ -2133,7 +2153,7 @@ async function runServerAgent(options) {
|
|
|
2133
2153
|
context: {},
|
|
2134
2154
|
systemPrompt
|
|
2135
2155
|
});
|
|
2136
|
-
if (compressionConfig?.enabled) {
|
|
2156
|
+
if (compressionConfig?.enabled && historyLeafMessageId === void 0) {
|
|
2137
2157
|
const llmAdapter = createCompressionLlmAdapter({
|
|
2138
2158
|
piModel,
|
|
2139
2159
|
apiKey: llmConfig.apiKey,
|
|
@@ -2158,6 +2178,11 @@ async function runServerAgent(options) {
|
|
|
2158
2178
|
}
|
|
2159
2179
|
});
|
|
2160
2180
|
}
|
|
2181
|
+
} else if (compressionConfig?.enabled && historyLeafMessageId !== void 0) {
|
|
2182
|
+
aiLogger?.info?.("Compression", "Skipping compression for edited branch request", {
|
|
2183
|
+
conversationId,
|
|
2184
|
+
historyLeafMessageId
|
|
2185
|
+
});
|
|
2161
2186
|
}
|
|
2162
2187
|
if (abortSignal?.aborted) {
|
|
2163
2188
|
handler.emitStatus("aborted", [], { force: true });
|
|
@@ -2166,7 +2191,7 @@ async function runServerAgent(options) {
|
|
|
2166
2191
|
}
|
|
2167
2192
|
let history = [];
|
|
2168
2193
|
try {
|
|
2169
|
-
history = convManager2.getHistoryForAgent(conversationId);
|
|
2194
|
+
history = convManager2.getHistoryForAgent(conversationId, void 0, historyLeafMessageId);
|
|
2170
2195
|
} catch {
|
|
2171
2196
|
}
|
|
2172
2197
|
handler.emitStatus("preparing", [], { pendingUserMessage: userMessage, force: true });
|
|
@@ -2183,6 +2208,7 @@ async function runServerAgent(options) {
|
|
|
2183
2208
|
maxToolRounds: 5,
|
|
2184
2209
|
abortSignal,
|
|
2185
2210
|
steerMessage,
|
|
2211
|
+
thinkingLevel,
|
|
2186
2212
|
onConvertToLlm: (filteredMessages) => {
|
|
2187
2213
|
cachedMessages = filteredMessages;
|
|
2188
2214
|
},
|
|
@@ -2305,6 +2331,23 @@ function deleteCustomModel(aiDataDir, providerId, modelId) {
|
|
|
2305
2331
|
return { success: true };
|
|
2306
2332
|
}
|
|
2307
2333
|
|
|
2334
|
+
// src/http/routes/ai-config-display.ts
|
|
2335
|
+
var NO_KEY_PLACEHOLDER = "sk-no-key-required";
|
|
2336
|
+
function hasRealApiKey(apiKey) {
|
|
2337
|
+
return !!apiKey && apiKey !== NO_KEY_PLACEHOLDER;
|
|
2338
|
+
}
|
|
2339
|
+
function toLlmConfigDisplay(config, resolveApiKey2) {
|
|
2340
|
+
const { apiKey: _rawApiKey, ...rest } = config;
|
|
2341
|
+
const provider = typeof config.provider === "string" ? config.provider : "";
|
|
2342
|
+
const authProfile = typeof config.authProfile === "string" ? config.authProfile : void 0;
|
|
2343
|
+
const resolvedApiKey = provider ? resolveApiKey2(provider, authProfile) : "";
|
|
2344
|
+
return {
|
|
2345
|
+
...rest,
|
|
2346
|
+
apiKey: "",
|
|
2347
|
+
apiKeySet: hasRealApiKey(resolvedApiKey || "")
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2308
2351
|
// src/http/routes/ai.ts
|
|
2309
2352
|
function getAiDir(dbManager2) {
|
|
2310
2353
|
const pathProvider = dbManager2["pathProvider"];
|
|
@@ -2400,10 +2443,7 @@ function registerAiRoutes(server2, dbManager2, convManager2) {
|
|
|
2400
2443
|
if (!fs10.existsSync(configPath)) return { configs: [], defaultAssistant: null, fastModel: null };
|
|
2401
2444
|
try {
|
|
2402
2445
|
const data = JSON.parse(fs10.readFileSync(configPath, "utf-8"));
|
|
2403
|
-
const configs = (data.configs || []).map((c) =>
|
|
2404
|
-
const { apiKey: _k, ...rest } = c;
|
|
2405
|
-
return { ...rest, apiKey: "" };
|
|
2406
|
-
});
|
|
2446
|
+
const configs = (data.configs || []).map((c) => toLlmConfigDisplay(c, resolveApiKey));
|
|
2407
2447
|
return {
|
|
2408
2448
|
configs,
|
|
2409
2449
|
defaultAssistant: data.defaultAssistant ?? null,
|
|
@@ -2606,6 +2646,51 @@ data: ${JSON.stringify(data)}
|
|
|
2606
2646
|
server2.get("/_web/ai/conversations/:id/messages", async (request) => {
|
|
2607
2647
|
return convManager2.getMessages(request.params.id);
|
|
2608
2648
|
});
|
|
2649
|
+
server2.post("/_web/ai/conversations/:id/messages/:messageId/delete-from", async (request, reply) => {
|
|
2650
|
+
const { id, messageId } = request.params;
|
|
2651
|
+
if (!id || typeof id !== "string" || !messageId || typeof messageId !== "string") {
|
|
2652
|
+
return reply.code(400).send({ error: "conversation id and messageId are required" });
|
|
2653
|
+
}
|
|
2654
|
+
convManager2.deleteMessagesFrom(id, messageId);
|
|
2655
|
+
return { success: true };
|
|
2656
|
+
});
|
|
2657
|
+
server2.post("/_web/ai/conversations/:id/fork", async (request, reply) => {
|
|
2658
|
+
const { upToMessageId, title } = request.body;
|
|
2659
|
+
if (!upToMessageId || typeof upToMessageId !== "string") {
|
|
2660
|
+
return reply.code(400).send({ error: "upToMessageId is required" });
|
|
2661
|
+
}
|
|
2662
|
+
return convManager2.forkConversation(request.params.id, upToMessageId, title);
|
|
2663
|
+
});
|
|
2664
|
+
server2.put("/_web/ai/messages/:messageId/content", async (request, reply) => {
|
|
2665
|
+
const { content } = request.body;
|
|
2666
|
+
if (!content || typeof content !== "string") {
|
|
2667
|
+
return reply.code(400).send({ error: "content is required" });
|
|
2668
|
+
}
|
|
2669
|
+
convManager2.updateMessageContent(request.params.messageId, content);
|
|
2670
|
+
return { success: true };
|
|
2671
|
+
});
|
|
2672
|
+
server2.post("/_web/ai/conversations/:id/messages/:messageId/delete-relink", async (request, reply) => {
|
|
2673
|
+
const { id, messageId } = request.params;
|
|
2674
|
+
if (!id || !messageId) {
|
|
2675
|
+
return reply.code(400).send({ error: "conversation id and messageId are required" });
|
|
2676
|
+
}
|
|
2677
|
+
convManager2.deleteAndRelinkMessage(id, messageId);
|
|
2678
|
+
return { success: true };
|
|
2679
|
+
});
|
|
2680
|
+
server2.post("/_web/ai/conversations/:id/messages/insert-after", async (request, reply) => {
|
|
2681
|
+
const { afterMessageId, role, content, contentBlocks, tokenUsage } = request.body;
|
|
2682
|
+
if (!afterMessageId || typeof afterMessageId !== "string") {
|
|
2683
|
+
return reply.code(400).send({ error: "afterMessageId is required" });
|
|
2684
|
+
}
|
|
2685
|
+
return convManager2.insertMessageAfter(
|
|
2686
|
+
request.params.id,
|
|
2687
|
+
afterMessageId,
|
|
2688
|
+
role,
|
|
2689
|
+
content,
|
|
2690
|
+
contentBlocks,
|
|
2691
|
+
tokenUsage
|
|
2692
|
+
);
|
|
2693
|
+
});
|
|
2609
2694
|
server2.get("/_web/ai/conversations/:id/token-usage", async (request) => {
|
|
2610
2695
|
return convManager2.getConversationTokenUsage(request.params.id);
|
|
2611
2696
|
});
|
|
@@ -2614,13 +2699,15 @@ data: ${JSON.stringify(data)}
|
|
|
2614
2699
|
const {
|
|
2615
2700
|
userMessage,
|
|
2616
2701
|
conversationId,
|
|
2702
|
+
historyLeafMessageId,
|
|
2617
2703
|
sessionId,
|
|
2618
2704
|
chatType,
|
|
2619
2705
|
locale,
|
|
2620
2706
|
assistantId,
|
|
2621
2707
|
compressionConfig,
|
|
2622
2708
|
ownerInfo,
|
|
2623
|
-
mentionedMembers
|
|
2709
|
+
mentionedMembers,
|
|
2710
|
+
thinkingLevel
|
|
2624
2711
|
} = request.body;
|
|
2625
2712
|
const requestId = `req_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
2626
2713
|
const abortController = new AbortController();
|
|
@@ -2707,6 +2794,7 @@ data: ${JSON.stringify(data)}
|
|
|
2707
2794
|
await runServerAgent({
|
|
2708
2795
|
userMessage,
|
|
2709
2796
|
conversationId,
|
|
2797
|
+
historyLeafMessageId,
|
|
2710
2798
|
chatType,
|
|
2711
2799
|
locale,
|
|
2712
2800
|
assistantSystemPrompt,
|
|
@@ -2719,7 +2807,8 @@ data: ${JSON.stringify(data)}
|
|
|
2719
2807
|
abortSignal: abortController.signal,
|
|
2720
2808
|
ownerInfo,
|
|
2721
2809
|
mentionedMembers,
|
|
2722
|
-
dataSnapshot
|
|
2810
|
+
dataSnapshot,
|
|
2811
|
+
thinkingLevel
|
|
2723
2812
|
});
|
|
2724
2813
|
} catch (error) {
|
|
2725
2814
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -3789,4 +3878,4 @@ export {
|
|
|
3789
3878
|
startHttpServer,
|
|
3790
3879
|
stopHttpServer
|
|
3791
3880
|
};
|
|
3792
|
-
//# sourceMappingURL=chunk-
|
|
3881
|
+
//# sourceMappingURL=chunk-D2BR3MFN.mjs.map
|