chatlab-cli 0.22.1 → 0.23.1
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/README.md +53 -30
- package/dist/{chunk-OC2W5Q5T.mjs → chunk-3MX7VF2B.mjs} +2 -2
- package/dist/chunk-5ADKYYNA.mjs +28 -0
- package/dist/chunk-5ADKYYNA.mjs.map +1 -0
- package/dist/{chunk-QRC3RSER.mjs → chunk-643S2N2U.mjs} +2 -2
- package/dist/{chunk-LZ3W6NS5.mjs → chunk-AHQQQ5HZ.mjs} +101 -69
- package/dist/chunk-AHQQQ5HZ.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-SQKT45MM.mjs → chunk-G7Q7EQ3V.mjs} +546 -84
- package/dist/chunk-G7Q7EQ3V.mjs.map +1 -0
- package/dist/{chunk-XPBPKH6B.mjs → chunk-L37WJ33K.mjs} +134 -37
- package/dist/chunk-L37WJ33K.mjs.map +1 -0
- package/dist/{chunk-Z2LYMKCC.mjs → chunk-WTQ7LAZR.mjs} +2 -2
- package/dist/cli.mjs +4 -3
- package/dist/{http-O5P4BYXU.mjs → http-JDORENHT.mjs} +8 -7
- package/dist/{import-BDLL3DG7.mjs → import-LCBSBLYF.mjs} +4 -4
- package/dist/index.mjs +10 -9
- package/dist/{mcp-L2TPZFE7.mjs → mcp-AR7HBIK4.mjs} +8 -6
- package/dist/{mcp-L2TPZFE7.mjs.map → mcp-AR7HBIK4.mjs.map} +1 -1
- package/dist/service-WCGGRZTA.mjs +258 -0
- package/dist/service-WCGGRZTA.mjs.map +1 -0
- package/dist/{src-FVJL5ENA.mjs → src-EGXULYFQ.mjs} +2 -2
- package/dist/{stream-import-ZTEW3YVL.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-Yzfz2ntn.css} +1 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-DXxg55kL.js +161 -0
- package/dist-web/assets/{EChartWordcloud-Ubal_aYg.js → EChartWordcloud-Cenbzcyj.js} +1 -1
- package/dist-web/assets/MessageExportModal-DMHA4X0b.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-BxE8RQYE.js +1 -0
- package/dist-web/assets/fetch-CvfdN4gM.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-BUfibEyG.css +1 -0
- package/dist-web/assets/{index-DOwQB7In.js → index-C2439065.js} +6 -6
- package/dist-web/assets/index-CD5Fz-JY.js +7 -0
- package/dist-web/assets/index-DC0LjKV6.js +2 -0
- package/dist-web/assets/index-Dl-X-izi.css +1 -0
- package/dist-web/assets/index-DywUneNT.css +1 -0
- package/dist-web/assets/index-JvmxkAGk.js +173 -0
- package/dist-web/assets/index-vEVpfw-R.js +163 -0
- package/dist-web/assets/model-catalog-DUuKjIVU.js +1 -0
- package/dist-web/assets/{vendor-nuxt-ui-7OAuiz_i.js → vendor-nuxt-ui-3XQAyMd0.js} +2 -2
- package/dist-web/assets/vendor-reka-ui-BrTYuIfH.js +11 -0
- package/dist-web/assets/{web-Cx5APyCN.js → web-Bm94rL5B.js} +1 -1
- package/dist-web/index.html +4 -4
- package/package.json +3 -2
- package/dist/chunk-6NB475AA.mjs.map +0 -1
- package/dist/chunk-LZ3W6NS5.mjs.map +0 -1
- package/dist/chunk-SQKT45MM.mjs.map +0 -1
- package/dist/chunk-XPBPKH6B.mjs.map +0 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-CqacsKDU.js +0 -147
- package/dist-web/assets/MessageExportModal-D1GY6WSV.js +0 -1
- package/dist-web/assets/electron-8qi0d92j.js +0 -1
- package/dist-web/assets/electron-CsUM2O_Y.js +0 -1
- package/dist-web/assets/fetch-BOogCPfg.js +0 -1
- package/dist-web/assets/fetch-CclRWOHf.js +0 -1
- package/dist-web/assets/fetch-CxwnEEqk.js +0 -17
- package/dist-web/assets/http-CeXMt-Fv.js +0 -1
- package/dist-web/assets/index-BE64tUWq.css +0 -1
- package/dist-web/assets/index-CM29Kc4p.js +0 -173
- package/dist-web/assets/index-CbQMfheg.css +0 -1
- package/dist-web/assets/index-D183wYuz.js +0 -7
- package/dist-web/assets/index-DSpvXged.css +0 -1
- package/dist-web/assets/index-DTxRy2FH.js +0 -163
- package/dist-web/assets/index-grds3iG-.js +0 -2
- package/dist-web/assets/vendor-reka-ui-CW2cIgMu.js +0 -11
- /package/dist/{chunk-OC2W5Q5T.mjs.map → chunk-3MX7VF2B.mjs.map} +0 -0
- /package/dist/{chunk-QRC3RSER.mjs.map → chunk-643S2N2U.mjs.map} +0 -0
- /package/dist/{chunk-Z2LYMKCC.mjs.map → chunk-WTQ7LAZR.mjs.map} +0 -0
- /package/dist/{http-O5P4BYXU.mjs.map → http-JDORENHT.mjs.map} +0 -0
- /package/dist/{import-BDLL3DG7.mjs.map → import-LCBSBLYF.mjs.map} +0 -0
- /package/dist/{src-FVJL5ENA.mjs.map → src-EGXULYFQ.mjs.map} +0 -0
- /package/dist/{stream-import-ZTEW3YVL.mjs.map → stream-import-QM5R5FDG.mjs.map} +0 -0
|
@@ -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);
|
|
@@ -1349,9 +1354,16 @@ data: ${JSON.stringify(eventData)}
|
|
|
1349
1354
|
cleanupTemp(tmpPath, tmpDir);
|
|
1350
1355
|
}
|
|
1351
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
|
+
];
|
|
1352
1363
|
server2.post("/_web/demo/import", async (request, reply) => {
|
|
1353
1364
|
const locale = request.body?.locale || "en";
|
|
1354
1365
|
const nativeBinding = resolveNativeBinding();
|
|
1366
|
+
const total = DEMO_FILES.length;
|
|
1355
1367
|
reply.raw.writeHead(200, {
|
|
1356
1368
|
"Content-Type": "text/event-stream",
|
|
1357
1369
|
"Cache-Control": "no-cache",
|
|
@@ -1364,36 +1376,37 @@ data: ${JSON.stringify(eventData)}
|
|
|
1364
1376
|
`);
|
|
1365
1377
|
}
|
|
1366
1378
|
const tmpDir = fs4.mkdtempSync(path3.join(os.tmpdir(), "chatlab-demo-"));
|
|
1367
|
-
const groupPath = path3.join(tmpDir, "demo-group.json");
|
|
1368
|
-
const privatePath = path3.join(tmpDir, "demo-private.json");
|
|
1369
1379
|
try {
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
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 });
|
|
1384
1393
|
if (!groupResult.success) throw new Error(groupResult.error || "Failed to import group demo");
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
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 });
|
|
1389
1402
|
sendEvent("result", {
|
|
1390
1403
|
success: true,
|
|
1391
1404
|
groupSessionId: groupResult.sessionId,
|
|
1392
|
-
|
|
1405
|
+
privateSessionIds
|
|
1393
1406
|
});
|
|
1394
1407
|
} catch (err) {
|
|
1395
1408
|
const message = err instanceof Error ? err.message : String(err);
|
|
1396
|
-
sendEvent("progress", { stage: "error", current: 0, total
|
|
1409
|
+
sendEvent("progress", { stage: "error", current: 0, total, message });
|
|
1397
1410
|
sendEvent("result", { success: false, error: message });
|
|
1398
1411
|
} finally {
|
|
1399
1412
|
reply.raw.end();
|
|
@@ -1485,7 +1498,7 @@ function registerMergeRoutes(server2, dbManager2, mergeCache) {
|
|
|
1485
1498
|
const merged = buildMergedOutput(dataSources, outputName);
|
|
1486
1499
|
let sessionId;
|
|
1487
1500
|
if (andImport) {
|
|
1488
|
-
const { streamImport: serverStreamImport } = await import("./stream-import-
|
|
1501
|
+
const { streamImport: serverStreamImport } = await import("./stream-import-QM5R5FDG.mjs");
|
|
1489
1502
|
const jsonData = JSON.stringify(merged.chatLabData);
|
|
1490
1503
|
const tmpDir = fs5.mkdtempSync(path4.join(os2.tmpdir(), "chatlab-merged-"));
|
|
1491
1504
|
const tmpPath = path4.join(tmpDir, `${outputName}.json`);
|
|
@@ -1538,7 +1551,7 @@ function registerMergeRoutes(server2, dbManager2, mergeCache) {
|
|
|
1538
1551
|
const db = ensureDb2(dbManager2, sid);
|
|
1539
1552
|
const exported = exportSessionToJson(db);
|
|
1540
1553
|
const { db: tempDb, tempDbPath } = mergeCache.createTempDatabase(exported.meta.name);
|
|
1541
|
-
const { TempDbWriter } = await import("./src-
|
|
1554
|
+
const { TempDbWriter } = await import("./src-EGXULYFQ.mjs");
|
|
1542
1555
|
const writer = new TempDbWriter(tempDb);
|
|
1543
1556
|
writer.writeMeta({
|
|
1544
1557
|
name: exported.meta.name,
|
|
@@ -2096,6 +2109,7 @@ async function runServerAgent(options) {
|
|
|
2096
2109
|
const {
|
|
2097
2110
|
userMessage,
|
|
2098
2111
|
conversationId,
|
|
2112
|
+
historyLeafMessageId,
|
|
2099
2113
|
chatType = "group",
|
|
2100
2114
|
locale = "zh-CN",
|
|
2101
2115
|
assistantSystemPrompt,
|
|
@@ -2108,7 +2122,8 @@ async function runServerAgent(options) {
|
|
|
2108
2122
|
abortSignal,
|
|
2109
2123
|
ownerInfo,
|
|
2110
2124
|
mentionedMembers,
|
|
2111
|
-
dataSnapshot
|
|
2125
|
+
dataSnapshot,
|
|
2126
|
+
thinkingLevel
|
|
2112
2127
|
} = options;
|
|
2113
2128
|
const aiLogger = getServerAiLogger();
|
|
2114
2129
|
const llmConfig = getDefaultAssistantConfig(aiDataDir);
|
|
@@ -2138,7 +2153,7 @@ async function runServerAgent(options) {
|
|
|
2138
2153
|
context: {},
|
|
2139
2154
|
systemPrompt
|
|
2140
2155
|
});
|
|
2141
|
-
if (compressionConfig?.enabled) {
|
|
2156
|
+
if (compressionConfig?.enabled && historyLeafMessageId === void 0) {
|
|
2142
2157
|
const llmAdapter = createCompressionLlmAdapter({
|
|
2143
2158
|
piModel,
|
|
2144
2159
|
apiKey: llmConfig.apiKey,
|
|
@@ -2163,6 +2178,11 @@ async function runServerAgent(options) {
|
|
|
2163
2178
|
}
|
|
2164
2179
|
});
|
|
2165
2180
|
}
|
|
2181
|
+
} else if (compressionConfig?.enabled && historyLeafMessageId !== void 0) {
|
|
2182
|
+
aiLogger?.info?.("Compression", "Skipping compression for edited branch request", {
|
|
2183
|
+
conversationId,
|
|
2184
|
+
historyLeafMessageId
|
|
2185
|
+
});
|
|
2166
2186
|
}
|
|
2167
2187
|
if (abortSignal?.aborted) {
|
|
2168
2188
|
handler.emitStatus("aborted", [], { force: true });
|
|
@@ -2171,7 +2191,7 @@ async function runServerAgent(options) {
|
|
|
2171
2191
|
}
|
|
2172
2192
|
let history = [];
|
|
2173
2193
|
try {
|
|
2174
|
-
history = convManager2.getHistoryForAgent(conversationId);
|
|
2194
|
+
history = convManager2.getHistoryForAgent(conversationId, void 0, historyLeafMessageId);
|
|
2175
2195
|
} catch {
|
|
2176
2196
|
}
|
|
2177
2197
|
handler.emitStatus("preparing", [], { pendingUserMessage: userMessage, force: true });
|
|
@@ -2188,6 +2208,7 @@ async function runServerAgent(options) {
|
|
|
2188
2208
|
maxToolRounds: 5,
|
|
2189
2209
|
abortSignal,
|
|
2190
2210
|
steerMessage,
|
|
2211
|
+
thinkingLevel,
|
|
2191
2212
|
onConvertToLlm: (filteredMessages) => {
|
|
2192
2213
|
cachedMessages = filteredMessages;
|
|
2193
2214
|
},
|
|
@@ -2625,6 +2646,51 @@ data: ${JSON.stringify(data)}
|
|
|
2625
2646
|
server2.get("/_web/ai/conversations/:id/messages", async (request) => {
|
|
2626
2647
|
return convManager2.getMessages(request.params.id);
|
|
2627
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
|
+
});
|
|
2628
2694
|
server2.get("/_web/ai/conversations/:id/token-usage", async (request) => {
|
|
2629
2695
|
return convManager2.getConversationTokenUsage(request.params.id);
|
|
2630
2696
|
});
|
|
@@ -2633,13 +2699,15 @@ data: ${JSON.stringify(data)}
|
|
|
2633
2699
|
const {
|
|
2634
2700
|
userMessage,
|
|
2635
2701
|
conversationId,
|
|
2702
|
+
historyLeafMessageId,
|
|
2636
2703
|
sessionId,
|
|
2637
2704
|
chatType,
|
|
2638
2705
|
locale,
|
|
2639
2706
|
assistantId,
|
|
2640
2707
|
compressionConfig,
|
|
2641
2708
|
ownerInfo,
|
|
2642
|
-
mentionedMembers
|
|
2709
|
+
mentionedMembers,
|
|
2710
|
+
thinkingLevel
|
|
2643
2711
|
} = request.body;
|
|
2644
2712
|
const requestId = `req_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
2645
2713
|
const abortController = new AbortController();
|
|
@@ -2726,6 +2794,7 @@ data: ${JSON.stringify(data)}
|
|
|
2726
2794
|
await runServerAgent({
|
|
2727
2795
|
userMessage,
|
|
2728
2796
|
conversationId,
|
|
2797
|
+
historyLeafMessageId,
|
|
2729
2798
|
chatType,
|
|
2730
2799
|
locale,
|
|
2731
2800
|
assistantSystemPrompt,
|
|
@@ -2738,7 +2807,8 @@ data: ${JSON.stringify(data)}
|
|
|
2738
2807
|
abortSignal: abortController.signal,
|
|
2739
2808
|
ownerInfo,
|
|
2740
2809
|
mentionedMembers,
|
|
2741
|
-
dataSnapshot
|
|
2810
|
+
dataSnapshot,
|
|
2811
|
+
thinkingLevel
|
|
2742
2812
|
});
|
|
2743
2813
|
} catch (error) {
|
|
2744
2814
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -2830,6 +2900,32 @@ function registerPreferencesRoutes(server2, pathProvider) {
|
|
|
2830
2900
|
});
|
|
2831
2901
|
}
|
|
2832
2902
|
|
|
2903
|
+
// src/http/routes/proxy.ts
|
|
2904
|
+
var PROXY_TARGET = "https://chatlab.fun";
|
|
2905
|
+
function registerProxyRoutes(server2) {
|
|
2906
|
+
server2.get("/_proxy/chatlab.fun/*", async (request, reply) => {
|
|
2907
|
+
const subPath = request.params["*"] ?? "";
|
|
2908
|
+
const queryString = new URLSearchParams(
|
|
2909
|
+
request.query
|
|
2910
|
+
).toString();
|
|
2911
|
+
const targetUrl = queryString ? `${PROXY_TARGET}/${subPath}?${queryString}` : `${PROXY_TARGET}/${subPath}`;
|
|
2912
|
+
try {
|
|
2913
|
+
const upstream = await fetch(targetUrl, {
|
|
2914
|
+
headers: { Accept: request.headers.accept ?? "*/*" },
|
|
2915
|
+
signal: AbortSignal.timeout(1e4)
|
|
2916
|
+
});
|
|
2917
|
+
const contentType = upstream.headers.get("content-type") ?? "application/octet-stream";
|
|
2918
|
+
const body = Buffer.from(await upstream.arrayBuffer());
|
|
2919
|
+
reply.code(upstream.status).header("content-type", contentType).send(body);
|
|
2920
|
+
} catch (err) {
|
|
2921
|
+
reply.code(502).send({
|
|
2922
|
+
error: "Proxy error",
|
|
2923
|
+
message: err instanceof Error ? err.message : String(err)
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2833
2929
|
// ../../packages/sync/src/types.ts
|
|
2834
2930
|
var noop = () => {
|
|
2835
2931
|
};
|
|
@@ -3765,6 +3861,7 @@ async function startHttpServer(options) {
|
|
|
3765
3861
|
initSync(server, dbManager, pathProvider, { port, host, token });
|
|
3766
3862
|
if (options?.webRoot && fs14.existsSync(options.webRoot)) {
|
|
3767
3863
|
setWebMode(true);
|
|
3864
|
+
registerProxyRoutes(server);
|
|
3768
3865
|
const fastifyStatic = await import("@fastify/static");
|
|
3769
3866
|
await server.register(fastifyStatic.default, {
|
|
3770
3867
|
root: options.webRoot,
|
|
@@ -3808,4 +3905,4 @@ export {
|
|
|
3808
3905
|
startHttpServer,
|
|
3809
3906
|
stopHttpServer
|
|
3810
3907
|
};
|
|
3811
|
-
//# sourceMappingURL=chunk-
|
|
3908
|
+
//# sourceMappingURL=chunk-L37WJ33K.mjs.map
|