chatlab-cli 0.28.0 → 0.28.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/dist/{chat-command-7WL5NMZ6.mjs → chat-command-ISJ2DC7R.mjs} +5 -5
- package/dist/{chunk-VASK54KT.mjs → chunk-3QBVO4J7.mjs} +2 -2
- package/dist/chunk-5FGB42EQ.mjs +7 -0
- package/dist/{chunk-YQ2FJGBT.mjs → chunk-AB6TAXTQ.mjs} +83 -46
- package/dist/chunk-AB6TAXTQ.mjs.map +1 -0
- package/dist/{chunk-XNU5X7EV.mjs → chunk-ERAAWLEF.mjs} +3 -3
- package/dist/{chunk-GFRG7TZQ.mjs → chunk-GHTGFM6O.mjs} +14 -14
- package/dist/{chunk-WGS33EWH.mjs → chunk-NJB2NNB2.mjs} +2 -2
- package/dist/{chunk-ZSFVX6FM.mjs → chunk-T7IETWHN.mjs} +6 -22
- package/dist/chunk-T7IETWHN.mjs.map +1 -0
- package/dist/chunk-YBS3YQB6.mjs +1336 -0
- package/dist/chunk-YBS3YQB6.mjs.map +1 -0
- package/dist/{chunk-55WR6WKW.mjs → chunk-ZVDOFWL7.mjs} +13327 -4696
- package/dist/chunk-ZVDOFWL7.mjs.map +1 -0
- package/dist/cli.mjs +4 -4
- package/dist/{http-C2FBHNZG.mjs → http-MBILV37U.mjs} +9 -9
- package/dist/{import-ED6JCPSJ.mjs → import-EYV3GXHE.mjs} +5 -12
- package/dist/index.mjs +9 -9
- package/dist/{mcp-5JIBER4M.mjs → mcp-H55AEXU5.mjs} +5 -5
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-WBNM42SL.mjs → src-36ZIR65K.mjs} +30 -28
- package/dist/{stream-import-37U3SROO.mjs → stream-import-YZMZ56B5.mjs} +4 -4
- package/dist/stream-import-YZMZ56B5.mjs.map +1 -0
- package/dist/undici-ZSXBT7EA.mjs +18389 -0
- package/dist/undici-ZSXBT7EA.mjs.map +1 -0
- package/dist/{worker-runtime-6DGYL4TF.mjs → worker-runtime-YDYS2C6T.mjs} +9 -5
- package/dist/worker-runtime-YDYS2C6T.mjs.map +1 -0
- package/dist-web/assets/{DebugToolsPanel.vue_vue_type_script_setup_true_lang-CCz0Syxo.js → DebugToolsPanel.vue_vue_type_script_setup_true_lang-Do3x4aL3.js} +5 -5
- package/dist-web/assets/{MessageExportModal-Dd6R-cX_.js → MessageExportModal-rijqUusq.js} +1 -1
- package/dist-web/assets/{electron-DjminAKK.js → electron-DWDCqx_d.js} +1 -1
- package/dist-web/assets/{fetch-B_kLRm6-.js → fetch-29ZBtGV0.js} +1 -1
- package/dist-web/assets/{fetch-DFCYOQe5.js → fetch-BAxKmbKF.js} +1 -1
- package/dist-web/assets/{fetch-srCJzcWc.js → fetch-BYczbT4C.js} +1 -1
- package/dist-web/assets/{fetch-DOhCQ5J8.js → fetch-BcxrU2mr.js} +1 -1
- package/dist-web/assets/{fetch-DV8A1dGB.js → fetch-Bh1fo3Df.js} +1 -1
- package/dist-web/assets/{fetch-Wad5mWVH.js → fetch-C3yhWO2S.js} +1 -1
- package/dist-web/assets/{fetch-CURbMNJV.js → fetch-Da_TBxrX.js} +1 -1
- package/dist-web/assets/{fetch-uM3erGZm.js → fetch-DyD8wDhb.js} +1 -1
- package/dist-web/assets/{fetch-Cle6QKmL.js → fetch-TCeykOkO.js} +1 -1
- package/dist-web/assets/{fetch-r83wdzHy.js → fetch-tIIVdXSv.js} +1 -1
- package/dist-web/assets/index-BzjLqlW_.js +173 -0
- package/dist-web/assets/{index-BpszRZ8V.js → index-C74qEDFh.js} +3 -3
- package/dist-web/assets/index-CM6xNPFp.css +1 -0
- package/dist-web/assets/index-CgK2LLIF.js +12 -0
- package/dist-web/assets/{index-hOsKRsp6.js → index-CjkOvM3N.js} +2 -2
- package/dist-web/assets/{index-BIvLzdwg.js → index-Dno7CADA.js} +1 -1
- package/dist-web/assets/{index-tkbEq8av.js → index-fbWrQpgH.js} +1 -1
- package/dist-web/assets/{web-D27K6zSX.js → web-H3XLx159.js} +1 -1
- package/dist-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-55WR6WKW.mjs.map +0 -1
- package/dist/chunk-GPF34WXV.mjs +0 -9573
- package/dist/chunk-GPF34WXV.mjs.map +0 -1
- package/dist/chunk-YQ2FJGBT.mjs.map +0 -1
- package/dist/chunk-YZDEZ6UI.mjs +0 -389
- package/dist/chunk-YZDEZ6UI.mjs.map +0 -1
- package/dist/chunk-ZSFVX6FM.mjs.map +0 -1
- package/dist/worker-runtime-6DGYL4TF.mjs.map +0 -1
- package/dist-web/assets/index-7E5GSvR2.css +0 -1
- package/dist-web/assets/index-BCRHSc1k.js +0 -173
- package/dist-web/assets/index-D5UgZUpS.js +0 -12
- /package/dist/{chat-command-7WL5NMZ6.mjs.map → chat-command-ISJ2DC7R.mjs.map} +0 -0
- /package/dist/{chunk-VASK54KT.mjs.map → chunk-3QBVO4J7.mjs.map} +0 -0
- /package/dist/{http-C2FBHNZG.mjs.map → chunk-5FGB42EQ.mjs.map} +0 -0
- /package/dist/{chunk-XNU5X7EV.mjs.map → chunk-ERAAWLEF.mjs.map} +0 -0
- /package/dist/{chunk-GFRG7TZQ.mjs.map → chunk-GHTGFM6O.mjs.map} +0 -0
- /package/dist/{chunk-WGS33EWH.mjs.map → chunk-NJB2NNB2.mjs.map} +0 -0
- /package/dist/{import-ED6JCPSJ.mjs.map → http-MBILV37U.mjs.map} +0 -0
- /package/dist/{src-WBNM42SL.mjs.map → import-EYV3GXHE.mjs.map} +0 -0
- /package/dist/{mcp-5JIBER4M.mjs.map → mcp-H55AEXU5.mjs.map} +0 -0
- /package/dist/{stream-import-37U3SROO.mjs.map → src-36ZIR65K.mjs.map} +0 -0
|
@@ -6,10 +6,10 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
createCliRunAgentStream
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-ERAAWLEF.mjs";
|
|
10
|
+
import "./chunk-3QBVO4J7.mjs";
|
|
11
|
+
import "./chunk-YBS3YQB6.mjs";
|
|
12
|
+
import "./chunk-ZVDOFWL7.mjs";
|
|
13
13
|
import "./chunk-GFHSSCCR.mjs";
|
|
14
14
|
|
|
15
15
|
// src/ai/chat-command.ts
|
|
@@ -302,4 +302,4 @@ export {
|
|
|
302
302
|
runChatCommand,
|
|
303
303
|
runChatTurn
|
|
304
304
|
};
|
|
305
|
-
//# sourceMappingURL=chat-command-
|
|
305
|
+
//# sourceMappingURL=chat-command-ISJ2DC7R.mjs.map
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
getSessionOverview,
|
|
27
27
|
getWeekdayActivity,
|
|
28
28
|
searchMessagesByKeywords
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-ZVDOFWL7.mjs";
|
|
30
30
|
|
|
31
31
|
// ../../packages/tools/src/definitions/sql-query.ts
|
|
32
32
|
var inputSchema = {
|
|
@@ -1828,4 +1828,4 @@ export {
|
|
|
1828
1828
|
MCP_TOOL_REGISTRY,
|
|
1829
1829
|
CoreDataProvider
|
|
1830
1830
|
};
|
|
1831
|
-
//# sourceMappingURL=chunk-
|
|
1831
|
+
//# sourceMappingURL=chunk-3QBVO4J7.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
//# sourceMappingURL=chunk-5FGB42EQ.mjs.map
|
|
@@ -8,60 +8,48 @@ import {
|
|
|
8
8
|
closeServerAiLogger,
|
|
9
9
|
createCliRunAgentStream,
|
|
10
10
|
initServerAiLogger
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ERAAWLEF.mjs";
|
|
12
12
|
import {
|
|
13
13
|
AGENT_TOOL_REGISTRY,
|
|
14
14
|
CoreDataProvider
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3QBVO4J7.mjs";
|
|
16
16
|
import {
|
|
17
17
|
assertCliDataDirCompatible
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NJB2NNB2.mjs";
|
|
19
19
|
import {
|
|
20
20
|
getVersion
|
|
21
21
|
} from "./chunk-5ADKYYNA.mjs";
|
|
22
22
|
import {
|
|
23
23
|
resolveCliPath
|
|
24
24
|
} from "./chunk-FJ35V3TE.mjs";
|
|
25
|
-
import {
|
|
26
|
-
importData,
|
|
27
|
-
parseFile
|
|
28
|
-
} from "./chunk-YZDEZ6UI.mjs";
|
|
29
25
|
import {
|
|
30
26
|
analyzeIncrementalImport,
|
|
31
27
|
analyzeNewImport,
|
|
32
28
|
incrementalImport,
|
|
33
29
|
streamImport
|
|
34
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-T7IETWHN.mjs";
|
|
35
31
|
import {
|
|
36
32
|
AnalyticsService,
|
|
37
|
-
ArchiveImportError,
|
|
38
|
-
ArchiveImportSourceManager,
|
|
39
33
|
NodePathProvider,
|
|
40
34
|
PreferencesManager,
|
|
41
|
-
appLogger,
|
|
42
35
|
applyPendingNodeDataDirMigrationIfNeeded,
|
|
43
36
|
buildMergedOutput,
|
|
44
37
|
checkConflictsFromSources,
|
|
45
38
|
createJiebaNlpProvider,
|
|
46
39
|
createNodeDataDirSwitch,
|
|
47
40
|
createSemanticIndexWorkerRuntimeClient,
|
|
48
|
-
detectAllFormats,
|
|
49
|
-
detectFormat,
|
|
50
|
-
findEntryFileInDirectory,
|
|
51
41
|
getDbFileVersion,
|
|
52
42
|
getDefaultNodeUserDataDir,
|
|
53
43
|
getOrComputeAnalysisCache,
|
|
54
44
|
getPendingNodeDataDirMigration,
|
|
55
|
-
getSupportedFormats,
|
|
56
45
|
hasPendingElectronDataWarning,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
serializeChatLabToJsonl,
|
|
60
|
-
streamParseFileInfo
|
|
61
|
-
} from "./chunk-GPF34WXV.mjs";
|
|
46
|
+
serializeChatLabToJsonl
|
|
47
|
+
} from "./chunk-YBS3YQB6.mjs";
|
|
62
48
|
import {
|
|
63
49
|
AIChatManager,
|
|
64
50
|
ALL_MIGRATIONS,
|
|
51
|
+
ArchiveImportError,
|
|
52
|
+
ArchiveImportSourceManager,
|
|
65
53
|
AssistantManager,
|
|
66
54
|
BUILTIN_MODELS,
|
|
67
55
|
BUILTIN_PROVIDERS,
|
|
@@ -78,12 +66,15 @@ import {
|
|
|
78
66
|
SemanticIndexConfigStore,
|
|
79
67
|
SkillManagerCore,
|
|
80
68
|
TempDbWriter,
|
|
69
|
+
appLogger,
|
|
81
70
|
buildPiModel,
|
|
82
71
|
computeWordFrequency,
|
|
83
72
|
countMessagesTokens,
|
|
84
73
|
createDatabaseManagerAdapter,
|
|
85
74
|
deleteAuthProfile,
|
|
86
75
|
deleteDict,
|
|
76
|
+
detectAllFormats,
|
|
77
|
+
detectFormat,
|
|
87
78
|
downloadDict,
|
|
88
79
|
ensureDefaultDict,
|
|
89
80
|
executeReadonlySql,
|
|
@@ -91,6 +82,7 @@ import {
|
|
|
91
82
|
exportSessionToJson,
|
|
92
83
|
export_service_exports,
|
|
93
84
|
fetchRemoteModels,
|
|
85
|
+
findEntryFileInDirectory,
|
|
94
86
|
getAvailableYears,
|
|
95
87
|
getBuiltinModelsByProvider,
|
|
96
88
|
getCatchphraseAnalysis,
|
|
@@ -103,6 +95,7 @@ import {
|
|
|
103
95
|
getDragonKingAnalysis,
|
|
104
96
|
getHourlyActivity,
|
|
105
97
|
getLanguagePreferenceAnalysis,
|
|
98
|
+
getLastPlatformMessageId,
|
|
106
99
|
getLaughAnalysis,
|
|
107
100
|
getLongMessageCount,
|
|
108
101
|
getMemberActivity,
|
|
@@ -122,11 +115,13 @@ import {
|
|
|
122
115
|
getSessionInfo,
|
|
123
116
|
getSessionMeta,
|
|
124
117
|
getSessionOverview,
|
|
118
|
+
getSupportedFormats,
|
|
125
119
|
getTextLengthPercentiles,
|
|
126
120
|
getTextStats,
|
|
127
121
|
getTimeRange,
|
|
128
122
|
getWeekdayActivity,
|
|
129
123
|
getYearlyActivity,
|
|
124
|
+
initAppLogger,
|
|
130
125
|
initNlpDir,
|
|
131
126
|
isDictDownloaded,
|
|
132
127
|
isNewerStableVersion,
|
|
@@ -136,20 +131,23 @@ import {
|
|
|
136
131
|
mergeRulesForLocale,
|
|
137
132
|
owner_profile_service_exports,
|
|
138
133
|
persistSemanticIndexConfig,
|
|
134
|
+
pushImport,
|
|
139
135
|
queryMessages,
|
|
140
136
|
resolveApiKey,
|
|
141
137
|
resolveSemanticIndexApiKeySet,
|
|
142
138
|
runSimpleLlmStream,
|
|
139
|
+
scanMultiChatFile,
|
|
143
140
|
segmentText,
|
|
144
141
|
session_index_service_exports,
|
|
145
142
|
session_service_exports,
|
|
143
|
+
streamParseFileInfo,
|
|
146
144
|
stripAvatarFields,
|
|
147
145
|
summary_service_exports,
|
|
148
146
|
validateApiKey,
|
|
149
147
|
verifyCliDataPath,
|
|
150
148
|
writeAuthProfile,
|
|
151
149
|
writeConfigField
|
|
152
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-ZVDOFWL7.mjs";
|
|
153
151
|
|
|
154
152
|
// src/http/index.ts
|
|
155
153
|
import * as fs11 from "fs";
|
|
@@ -168,6 +166,8 @@ var HTTP_STATUS = {
|
|
|
168
166
|
["SQL_EXECUTION_ERROR" /* SQL_EXECUTION_ERROR */]: 400,
|
|
169
167
|
["EXPORT_TOO_LARGE" /* EXPORT_TOO_LARGE */]: 400,
|
|
170
168
|
["BODY_TOO_LARGE" /* BODY_TOO_LARGE */]: 413,
|
|
169
|
+
["IMPORT_IN_PROGRESS" /* IMPORT_IN_PROGRESS */]: 409,
|
|
170
|
+
["IMPORT_FAILED" /* IMPORT_FAILED */]: 500,
|
|
171
171
|
["DATA_DIR_INCOMPATIBLE" /* DATA_DIR_INCOMPATIBLE */]: 409,
|
|
172
172
|
["SERVER_ERROR" /* SERVER_ERROR */]: 500
|
|
173
173
|
};
|
|
@@ -187,6 +187,9 @@ function unauthorized(message = "Invalid or missing token") {
|
|
|
187
187
|
function sessionNotFound(id) {
|
|
188
188
|
return new ApiError("SESSION_NOT_FOUND" /* SESSION_NOT_FOUND */, `Session not found: ${id}`);
|
|
189
189
|
}
|
|
190
|
+
function invalidPayload(message) {
|
|
191
|
+
return new ApiError("INVALID_PAYLOAD" /* INVALID_PAYLOAD */, message);
|
|
192
|
+
}
|
|
190
193
|
function sqlExecutionError(message) {
|
|
191
194
|
return new ApiError("SQL_EXECUTION_ERROR" /* SQL_EXECUTION_ERROR */, message);
|
|
192
195
|
}
|
|
@@ -199,6 +202,12 @@ function exportTooLarge(count, limit) {
|
|
|
199
202
|
function serverError(message = "Internal server error") {
|
|
200
203
|
return new ApiError("SERVER_ERROR" /* SERVER_ERROR */, message);
|
|
201
204
|
}
|
|
205
|
+
function importInProgress() {
|
|
206
|
+
return new ApiError("IMPORT_IN_PROGRESS" /* IMPORT_IN_PROGRESS */, "Another import is already in progress");
|
|
207
|
+
}
|
|
208
|
+
function importFailed(message) {
|
|
209
|
+
return new ApiError("IMPORT_FAILED" /* IMPORT_FAILED */, message);
|
|
210
|
+
}
|
|
202
211
|
function dataDirIncompatible(message) {
|
|
203
212
|
return new ApiError("DATA_DIR_INCOMPATIBLE" /* DATA_DIR_INCOMPATIBLE */, message);
|
|
204
213
|
}
|
|
@@ -347,7 +356,9 @@ function registerRestSessionRoutes(server2, ctx) {
|
|
|
347
356
|
messageCount: info.messageCount,
|
|
348
357
|
memberCount: info.memberCount,
|
|
349
358
|
firstTimestamp: info.firstMessageTs,
|
|
350
|
-
lastTimestamp: info.lastMessageTs
|
|
359
|
+
lastTimestamp: info.lastMessageTs,
|
|
360
|
+
lastPlatformMessageId: getLastPlatformMessageId(db),
|
|
361
|
+
importedAt: info.importedAt
|
|
351
362
|
});
|
|
352
363
|
});
|
|
353
364
|
server2.get("/api/v1/sessions/:id/messages", async (request) => {
|
|
@@ -468,6 +479,39 @@ function registerRestSessionRoutes(server2, ctx) {
|
|
|
468
479
|
});
|
|
469
480
|
}
|
|
470
481
|
|
|
482
|
+
// ../../packages/http-routes/src/routes/imports.ts
|
|
483
|
+
function registerImportRoutes(server2, ctx) {
|
|
484
|
+
server2.post(
|
|
485
|
+
"/api/v1/imports/:sessionId",
|
|
486
|
+
async (request, reply) => {
|
|
487
|
+
const { sessionId } = request.params;
|
|
488
|
+
const contentType = request.headers["content-type"] || "";
|
|
489
|
+
if (!contentType.includes("application/json")) {
|
|
490
|
+
const err = invalidPayload("Content-Type must be application/json (JSONL is not yet supported)");
|
|
491
|
+
return reply.code(err.statusCode).send(errorResponse(err));
|
|
492
|
+
}
|
|
493
|
+
if (request.headers["x-dry-run"] === "true") {
|
|
494
|
+
const err = invalidPayload("X-Dry-Run is not yet supported");
|
|
495
|
+
return reply.code(err.statusCode).send(errorResponse(err));
|
|
496
|
+
}
|
|
497
|
+
const outcome = await pushImport(ctx.dbManager, sessionId, request.body ?? {});
|
|
498
|
+
if (!outcome.ok) {
|
|
499
|
+
if (outcome.reason === "import_in_progress") {
|
|
500
|
+
const err2 = importInProgress();
|
|
501
|
+
return reply.code(err2.statusCode).send(errorResponse(err2));
|
|
502
|
+
}
|
|
503
|
+
if (outcome.reason === "invalid_payload") {
|
|
504
|
+
const err2 = invalidPayload(outcome.message);
|
|
505
|
+
return reply.code(err2.statusCode).send(errorResponse(err2));
|
|
506
|
+
}
|
|
507
|
+
const err = importFailed(outcome.message);
|
|
508
|
+
return reply.code(err.statusCode).send(errorResponse(err));
|
|
509
|
+
}
|
|
510
|
+
return successResponse(outcome.result);
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
|
|
471
515
|
// ../../packages/http-routes/src/routes/web/sessions.ts
|
|
472
516
|
function registerSessionRoutes(server2, ctx) {
|
|
473
517
|
const { sessionAdapter: adapter } = ctx;
|
|
@@ -2187,6 +2231,7 @@ function registerSharedRoutes(server2, ctx, options) {
|
|
|
2187
2231
|
const resolvedCtx = ctx.preferencesManager ? ctx : { ...ctx, preferencesManager: new PreferencesManager(ctx.pathProvider.getSystemDir()) };
|
|
2188
2232
|
registerSystemRoutes(server2, resolvedCtx);
|
|
2189
2233
|
registerRestSessionRoutes(server2, resolvedCtx);
|
|
2234
|
+
registerImportRoutes(server2, resolvedCtx);
|
|
2190
2235
|
registerSessionRoutes(server2, resolvedCtx);
|
|
2191
2236
|
registerMemberRoutes(server2, resolvedCtx);
|
|
2192
2237
|
registerPreferencesRoutes(server2, resolvedCtx);
|
|
@@ -2334,7 +2379,7 @@ function cleanupTemp(...paths) {
|
|
|
2334
2379
|
}
|
|
2335
2380
|
}
|
|
2336
2381
|
}
|
|
2337
|
-
function
|
|
2382
|
+
function registerImportRoutes2(server2, dbManager2, options = {}) {
|
|
2338
2383
|
const sourceManager = options.sourceManager ?? new ArchiveImportSourceManager({
|
|
2339
2384
|
tempRoot: fs6.mkdtempSync(path7.join(os2.tmpdir(), "chatlab-import-sources-"))
|
|
2340
2385
|
});
|
|
@@ -2785,7 +2830,7 @@ function registerWebRoutes(server2, dbManager2, options) {
|
|
|
2785
2830
|
const resolvedPathProvider = options?.pathProvider ?? fallbackPathProvider;
|
|
2786
2831
|
const ai = options?.aiContext;
|
|
2787
2832
|
const cliStreamImport = async (dm, filePath) => {
|
|
2788
|
-
const { streamImport: streamImport2 } = await import("./stream-import-
|
|
2833
|
+
const { streamImport: streamImport2 } = await import("./stream-import-YZMZ56B5.mjs");
|
|
2789
2834
|
const result = await streamImport2(dm, filePath);
|
|
2790
2835
|
if (!result.sessionId) throw new Error("Import succeeded but no sessionId returned");
|
|
2791
2836
|
return { sessionId: result.sessionId };
|
|
@@ -2836,7 +2881,7 @@ function registerWebRoutes(server2, dbManager2, options) {
|
|
|
2836
2881
|
},
|
|
2837
2882
|
ai ? { requireAi: true } : void 0
|
|
2838
2883
|
);
|
|
2839
|
-
|
|
2884
|
+
registerImportRoutes2(server2, dbManager2);
|
|
2840
2885
|
server2.get("/_web/system/check-update", async () => {
|
|
2841
2886
|
const currentVersion = getVersion();
|
|
2842
2887
|
try {
|
|
@@ -3287,7 +3332,8 @@ var PullEngine = class {
|
|
|
3287
3332
|
this.logger.info(`[Pull] Skipping "${sess.name}": session no longer exists`);
|
|
3288
3333
|
return { success: true, newMessageCount: 0 };
|
|
3289
3334
|
}
|
|
3290
|
-
|
|
3335
|
+
const importStatusSessionId = sess.targetSessionId || deriveLocalSessionId(ds.baseUrl, sess.remoteSessionId);
|
|
3336
|
+
if (this.isImporting(importStatusSessionId)) {
|
|
3291
3337
|
this.logger.info(`[Pull] Skipping "${sess.name}": import in progress`);
|
|
3292
3338
|
return { success: false, newMessageCount: 0, error: "Import in progress" };
|
|
3293
3339
|
}
|
|
@@ -3704,22 +3750,17 @@ var DirectImporter = class {
|
|
|
3704
3750
|
}
|
|
3705
3751
|
async incrementalImportFile(sessionId, tempFile) {
|
|
3706
3752
|
try {
|
|
3707
|
-
const data = await parseFile(tempFile);
|
|
3708
3753
|
this.dbManager.close(sessionId);
|
|
3709
|
-
const result = await
|
|
3710
|
-
sessionId
|
|
3711
|
-
});
|
|
3754
|
+
const result = await incrementalImport(this.dbManager, sessionId, tempFile);
|
|
3712
3755
|
if (result.success) {
|
|
3756
|
+
const newMessageCount = result.newMessageCount;
|
|
3757
|
+
const duplicateCount = result.batch?.duplicateCount ?? 0;
|
|
3713
3758
|
this.logger.info(
|
|
3714
|
-
`[DirectImporter] Incremental OK: +${
|
|
3759
|
+
`[DirectImporter] Incremental OK: +${newMessageCount} messages (${duplicateCount} duplicates skipped)`
|
|
3715
3760
|
);
|
|
3716
|
-
return {
|
|
3717
|
-
success: true,
|
|
3718
|
-
newMessageCount: result.messageCount,
|
|
3719
|
-
sessionId
|
|
3720
|
-
};
|
|
3761
|
+
return { success: true, newMessageCount, sessionId };
|
|
3721
3762
|
}
|
|
3722
|
-
if (result.error
|
|
3763
|
+
if (result.error === "error.session_not_found" || result.error?.includes("no such table")) {
|
|
3723
3764
|
return { success: false, newMessageCount: 0, sessionId, needFullResync: true };
|
|
3724
3765
|
}
|
|
3725
3766
|
return { success: false, newMessageCount: 0, sessionId, error: result.error };
|
|
@@ -3730,15 +3771,11 @@ var DirectImporter = class {
|
|
|
3730
3771
|
}
|
|
3731
3772
|
async fullImportFile(tempFile, externalId) {
|
|
3732
3773
|
try {
|
|
3733
|
-
const
|
|
3734
|
-
const result = await importData(this.dbManager, data, {
|
|
3735
|
-
sessionId: externalId
|
|
3736
|
-
});
|
|
3774
|
+
const result = await streamImport(this.dbManager, tempFile, { sessionId: externalId });
|
|
3737
3775
|
if (result.success) {
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
return { success: true, newMessageCount: result.messageCount, sessionId: externalId };
|
|
3776
|
+
const newMessageCount = result.diagnostics?.messagesWritten ?? 0;
|
|
3777
|
+
this.logger.info(`[DirectImporter] Full import OK: +${newMessageCount} messages`);
|
|
3778
|
+
return { success: true, newMessageCount, sessionId: result.sessionId ?? externalId };
|
|
3742
3779
|
}
|
|
3743
3780
|
return { success: false, newMessageCount: 0, error: result.error };
|
|
3744
3781
|
} catch (err) {
|
|
@@ -4052,4 +4089,4 @@ export {
|
|
|
4052
4089
|
startHttpServer,
|
|
4053
4090
|
stopHttpServer
|
|
4054
4091
|
};
|
|
4055
|
-
//# sourceMappingURL=chunk-
|
|
4092
|
+
//# sourceMappingURL=chunk-AB6TAXTQ.mjs.map
|