chatlab-cli 0.29.0 → 0.30.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-JKG3FY5B.mjs → chat-command-UZ23GKO7.mjs} +8 -8
- package/dist/{chunk-KL2NGIMQ.mjs → chunk-4IZ3WKYU.mjs} +429 -272
- package/dist/chunk-4IZ3WKYU.mjs.map +1 -0
- package/dist/{chunk-CIB23U32.mjs → chunk-5UBHNQFZ.mjs} +101 -41
- package/dist/chunk-5UBHNQFZ.mjs.map +1 -0
- package/dist/{chunk-WPI6YSAR.mjs → chunk-7BZLS2KW.mjs} +4114 -3962
- package/dist/chunk-7BZLS2KW.mjs.map +1 -0
- package/dist/{chunk-QQK7MLCR.mjs → chunk-A2SANKG4.mjs} +121 -32
- package/dist/chunk-A2SANKG4.mjs.map +1 -0
- package/dist/{chunk-D4WTE7LV.mjs → chunk-CNSYXRJP.mjs} +2 -2
- package/dist/{chunk-I35WHWA6.mjs → chunk-FCCL5Z4W.mjs} +3 -3
- package/dist/chunk-M55KW2HA.mjs +2323 -0
- package/dist/chunk-M55KW2HA.mjs.map +1 -0
- package/dist/{chunk-2MZ6G4AC.mjs → chunk-MUPILWAZ.mjs} +2 -2
- package/dist/{chunk-7RW4CQAO.mjs → chunk-P3ZOLTGS.mjs} +3 -3
- package/dist/{chunk-6FPEP2ZX.mjs → chunk-RDR6PS2R.mjs} +2 -2
- package/dist/{chunk-SKUG5XVD.mjs → chunk-ZFU2CHW3.mjs} +5 -4
- package/dist/cli.mjs +7 -7
- package/dist/contacts-worker.mjs +2 -2
- package/dist/{http-5E7ARYFW.mjs → http-UWRA5FLB.mjs} +11 -11
- package/dist/{import-3KG6VK6O.mjs → import-745KQL7N.mjs} +7 -7
- package/dist/index.mjs +11 -11
- package/dist/{mcp-JBI4CUQT.mjs → mcp-UHN5JOHC.mjs} +8 -8
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-UTBQAOJ3.mjs → src-Y7MDRXLJ.mjs} +12 -6
- package/dist/{stream-import-7HZ4IRYJ.mjs → stream-import-3JMXQD7P.mjs} +7 -7
- package/dist/{worker-runtime-ALS4MR2A.mjs → worker-runtime-63RYMGZI.mjs} +5 -5
- package/dist-web/assets/{BufferResource-MsqP5sq3.js → BufferResource-BVdJ_I5X.js} +1 -1
- package/dist-web/assets/CanvasRenderer-BaRuT54R.js +1 -0
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-N5CoiJzN.js +110 -0
- package/dist-web/assets/{Filter-wRJtdXx9.js → Filter-B7cNFtuE.js} +1 -1
- package/dist-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-D_dJuLWJ.js +1 -0
- package/dist-web/assets/{MessageExportModal-BCrMf5Kw.js → MessageExportModal-B2Qm6VVj.js} +1 -1
- package/dist-web/assets/{PageHeader-C_yw54le.js → PageHeader-PjlWy9fC.js} +1 -1
- package/dist-web/assets/{RelationshipGalaxyCanvas-DTzJq7q7.js → RelationshipGalaxyCanvas-11MafciW.js} +3 -3
- package/dist-web/assets/{RelationshipGalaxyThreeCanvas-DIE-0_iM.js → RelationshipGalaxyThreeCanvas-C1I4B8NX.js} +1 -1
- package/dist-web/assets/{RenderTargetSystem-BSAQFamI.js → RenderTargetSystem-Chkz1WlI.js} +1 -1
- package/dist-web/assets/{WebGLRenderer-lfzmCZNT.js → WebGLRenderer-xK19ru58.js} +1 -1
- package/dist-web/assets/{WebGPURenderer-BnEdfdr_.js → WebGPURenderer-CL5ZaKsn.js} +1 -1
- package/dist-web/assets/{browserAll-gRNfDyPu.js → browserAll-CyyNzRD_.js} +1 -1
- package/dist-web/assets/electron-MXaTKaMu.js +1 -0
- package/dist-web/assets/{fetch-BW3aO7PS.js → fetch-D1dDiFO4.js} +1 -1
- package/dist-web/assets/{fetch-DPCJ-1l-.js → fetch-DDnVXGte.js} +1 -1
- package/dist-web/assets/{fetch-C1fI_KOX.js → fetch-DTwdRTXM.js} +1 -1
- package/dist-web/assets/{fetch-CQt-gb-f.js → fetch-DaaJwT-5.js} +1 -1
- package/dist-web/assets/{fetch-gMB4wuBd.js → fetch-DeA0ztwT.js} +1 -1
- package/dist-web/assets/fetch-DpnIGZSN.js +17 -0
- package/dist-web/assets/{fetch-CFRoSIAn.js → fetch-DsE-xcP2.js} +1 -1
- package/dist-web/assets/{fetch-mFlEBZyB.js → fetch-DsTgYu_X.js} +1 -1
- package/dist-web/assets/{fetch-CN91TIwV.js → fetch-hKE53UO4.js} +1 -1
- package/dist-web/assets/{fetch-BwF5hNuF.js → fetch-u9GTMhMF.js} +1 -1
- package/dist-web/assets/index-BVkE4qis.js +22 -0
- package/dist-web/assets/index-BcXLcFnV.css +1 -0
- package/dist-web/assets/{index-Bg4GGPXv.js → index-BnHKyESZ.js} +1 -1
- package/dist-web/assets/index-Btr5H7d-.js +2 -0
- package/dist-web/assets/{index-MBRD3wPd.css → index-C1p9CbmN.css} +1 -1
- package/dist-web/assets/index-COpza1A4.css +1 -0
- package/dist-web/assets/index-D04LWJop.js +173 -0
- package/dist-web/assets/index-DFCYmzGE.js +2 -0
- package/dist-web/assets/{index-DveHdPfK.js → index-DqXHRIhI.js} +1 -1
- package/dist-web/assets/{index-ZdCB7xcf.js → index-DqtXt3wl.js} +4 -4
- package/dist-web/assets/index-Dszv-QFp.js +64 -0
- package/dist-web/assets/index-DzLrWGXu.js +1 -0
- package/dist-web/assets/{vendor-nuxt-ui-Dr2T8_OZ.js → vendor-nuxt-ui-DaLxYaC4.js} +1 -1
- package/dist-web/assets/{web-BakeV58u.js → web-DPVWfPS-.js} +1 -1
- package/dist-web/assets/{webworkerAll-D_6PgURS.js → webworkerAll-DF5QV_vN.js} +1 -1
- package/dist-web/index.html +3 -3
- package/package.json +1 -1
- package/dist/chunk-ARZM6HBX.mjs +0 -542
- package/dist/chunk-ARZM6HBX.mjs.map +0 -1
- package/dist/chunk-CIB23U32.mjs.map +0 -1
- package/dist/chunk-KL2NGIMQ.mjs.map +0 -1
- package/dist/chunk-QQK7MLCR.mjs.map +0 -1
- package/dist/chunk-WPI6YSAR.mjs.map +0 -1
- package/dist-web/assets/CanvasRenderer-BKCvcc2p.js +0 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-HGJb0Et1.js +0 -110
- package/dist-web/assets/electron-BHaEaaZP.js +0 -1
- package/dist-web/assets/fetch-CBZbgZqk.js +0 -17
- package/dist-web/assets/index--6C0sK6a.css +0 -1
- package/dist-web/assets/index-B6wEGata.js +0 -173
- package/dist-web/assets/index-BgVbj5qX.js +0 -12
- package/dist-web/assets/index-BkoXaBV_.js +0 -64
- package/dist-web/assets/index-C56IuV5U.css +0 -1
- package/dist-web/assets/index-CLRaKwpT.js +0 -2
- package/dist-web/assets/index-Dj1BSD7O.js +0 -1
- package/dist-web/assets/index-RoDgJcHU.js +0 -2
- package/dist-web/assets/index-aljYO5ms.js +0 -1
- /package/dist/{chat-command-JKG3FY5B.mjs.map → chat-command-UZ23GKO7.mjs.map} +0 -0
- /package/dist/{chunk-D4WTE7LV.mjs.map → chunk-CNSYXRJP.mjs.map} +0 -0
- /package/dist/{chunk-I35WHWA6.mjs.map → chunk-FCCL5Z4W.mjs.map} +0 -0
- /package/dist/{chunk-2MZ6G4AC.mjs.map → chunk-MUPILWAZ.mjs.map} +0 -0
- /package/dist/{chunk-7RW4CQAO.mjs.map → chunk-P3ZOLTGS.mjs.map} +0 -0
- /package/dist/{chunk-6FPEP2ZX.mjs.map → chunk-RDR6PS2R.mjs.map} +0 -0
- /package/dist/{chunk-SKUG5XVD.mjs.map → chunk-ZFU2CHW3.mjs.map} +0 -0
- /package/dist/{http-5E7ARYFW.mjs.map → http-UWRA5FLB.mjs.map} +0 -0
- /package/dist/{import-3KG6VK6O.mjs.map → import-745KQL7N.mjs.map} +0 -0
- /package/dist/{mcp-JBI4CUQT.mjs.map → mcp-UHN5JOHC.mjs.map} +0 -0
- /package/dist/{src-UTBQAOJ3.mjs.map → src-Y7MDRXLJ.mjs.map} +0 -0
- /package/dist/{stream-import-7HZ4IRYJ.mjs.map → stream-import-3JMXQD7P.mjs.map} +0 -0
- /package/dist/{worker-runtime-ALS4MR2A.mjs.map → worker-runtime-63RYMGZI.mjs.map} +0 -0
package/dist/chunk-ARZM6HBX.mjs
DELETED
|
@@ -1,542 +0,0 @@
|
|
|
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
|
-
assertCliDataDirCompatible
|
|
9
|
-
} from "./chunk-6FPEP2ZX.mjs";
|
|
10
|
-
import {
|
|
11
|
-
getVersion
|
|
12
|
-
} from "./chunk-5ADKYYNA.mjs";
|
|
13
|
-
import {
|
|
14
|
-
resolveCliPath
|
|
15
|
-
} from "./chunk-FJ35V3TE.mjs";
|
|
16
|
-
import {
|
|
17
|
-
NodePathProvider,
|
|
18
|
-
applyPendingNodeDataDirMigrationIfNeeded,
|
|
19
|
-
getSystemLogsDir,
|
|
20
|
-
hasPendingElectronDataWarning
|
|
21
|
-
} from "./chunk-7RW4CQAO.mjs";
|
|
22
|
-
import {
|
|
23
|
-
AIChatManager
|
|
24
|
-
} from "./chunk-QQK7MLCR.mjs";
|
|
25
|
-
import {
|
|
26
|
-
DEFAULT_API_PORT,
|
|
27
|
-
DatabaseManager,
|
|
28
|
-
appLogger,
|
|
29
|
-
executeReadonlySql,
|
|
30
|
-
getConfigPath,
|
|
31
|
-
getMemberActivity,
|
|
32
|
-
getMembers,
|
|
33
|
-
getSessionMeta,
|
|
34
|
-
getSessionOverview,
|
|
35
|
-
initAppLogger,
|
|
36
|
-
loadConfig,
|
|
37
|
-
searchMessagesLike,
|
|
38
|
-
verifyCliDataPath
|
|
39
|
-
} from "./chunk-WPI6YSAR.mjs";
|
|
40
|
-
|
|
41
|
-
// src/cli.ts
|
|
42
|
-
import * as fs from "fs";
|
|
43
|
-
import { execSync } from "child_process";
|
|
44
|
-
import { Command } from "commander";
|
|
45
|
-
|
|
46
|
-
// src/http/port.ts
|
|
47
|
-
import * as net from "net";
|
|
48
|
-
function isPortAvailable(port, host) {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
const server = net.createServer();
|
|
51
|
-
server.once("error", (err) => {
|
|
52
|
-
if (err.code === "EADDRINUSE") {
|
|
53
|
-
resolve(false);
|
|
54
|
-
} else {
|
|
55
|
-
reject(err);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
server.once("listening", () => server.close(() => resolve(true)));
|
|
59
|
-
server.listen(port, host);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function formatPortInUseError(port) {
|
|
63
|
-
return [
|
|
64
|
-
``,
|
|
65
|
-
` \u2716 Error: port ${port} is already in use.`,
|
|
66
|
-
``,
|
|
67
|
-
` Another process (possibly a ChatLab instance) is using this port. You can:`,
|
|
68
|
-
` \u2022 Use another port: chatlab start --port <port>`,
|
|
69
|
-
` \u2022 Find the process: lsof -iTCP:${port} -sTCP:LISTEN`,
|
|
70
|
-
``
|
|
71
|
-
].join("\n");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/cli.ts
|
|
75
|
-
var program = new Command();
|
|
76
|
-
program.name("chatlab").description("ChatLab - Chat history analysis tool").version(getVersion(), "-v, --version");
|
|
77
|
-
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
78
|
-
if (actionCommand.name() === "update") return;
|
|
79
|
-
const { checkForUpdatesInteractive } = await import("./update-checker-LGMTEKMT.mjs");
|
|
80
|
-
await checkForUpdatesInteractive();
|
|
81
|
-
});
|
|
82
|
-
program.command("update").description("Update ChatLab CLI to the latest version").action(async () => {
|
|
83
|
-
const { performCliSelfUpdate } = await import("./update-checker-LGMTEKMT.mjs");
|
|
84
|
-
const result = await performCliSelfUpdate({
|
|
85
|
-
write: (text) => process.stderr.write(text)
|
|
86
|
-
});
|
|
87
|
-
if (result.success) {
|
|
88
|
-
console.error(" Updated successfully. Please restart chatlab to use the new version.\n");
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
console.error(` Update failed: ${result.error || "unknown error"}
|
|
92
|
-
`);
|
|
93
|
-
process.exitCode = 1;
|
|
94
|
-
});
|
|
95
|
-
program.command("sessions").description("List all imported chat sessions").option("--format <format>", "Output format (table|json)", "table").action((options) => {
|
|
96
|
-
const { dbManager } = initRuntime();
|
|
97
|
-
const sessionIds = dbManager.listSessionIds();
|
|
98
|
-
if (sessionIds.length === 0) {
|
|
99
|
-
console.log("No chat sessions found.");
|
|
100
|
-
console.log(`Data directory: ${dbManager["pathProvider"].getUserDataDir()}`);
|
|
101
|
-
dbManager.closeAll();
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const sessions = sessionIds.map((id) => {
|
|
105
|
-
const db = dbManager.open(id);
|
|
106
|
-
if (!db) return null;
|
|
107
|
-
const meta = getSessionMeta(db);
|
|
108
|
-
if (!meta) return null;
|
|
109
|
-
const overview = getSessionOverview(db);
|
|
110
|
-
return { id, ...meta, ...overview };
|
|
111
|
-
}).filter(Boolean);
|
|
112
|
-
if (options.format === "json") {
|
|
113
|
-
console.log(JSON.stringify(sessions, null, 2));
|
|
114
|
-
} else {
|
|
115
|
-
console.log(`${sessions.length} session(s) found:
|
|
116
|
-
`);
|
|
117
|
-
for (const s of sessions) {
|
|
118
|
-
if (!s) continue;
|
|
119
|
-
const timeRange = formatTimeRange(s.firstMessageTs, s.lastMessageTs);
|
|
120
|
-
console.log(` ${s.name}`);
|
|
121
|
-
console.log(` ID: ${s.id}`);
|
|
122
|
-
console.log(
|
|
123
|
-
` Platform: ${s.platform} | Type: ${s.type} | Members: ${s.totalMembers} | Messages: ${s.totalMessages}`
|
|
124
|
-
);
|
|
125
|
-
if (timeRange) console.log(` Range: ${timeRange}`);
|
|
126
|
-
console.log();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
dbManager.closeAll();
|
|
130
|
-
});
|
|
131
|
-
program.command("stats <session-id>").description("Show session statistics overview").option("--format <format>", "Output format (table|json)", "table").option("--top <n>", "Show top N active members", "10").action((sessionId, options) => {
|
|
132
|
-
const { dbManager } = initRuntime();
|
|
133
|
-
const db = dbManager.open(sessionId);
|
|
134
|
-
if (!db) {
|
|
135
|
-
console.error(`Session ${sessionId} not found`);
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
const meta = getSessionMeta(db);
|
|
139
|
-
const overview = getSessionOverview(db);
|
|
140
|
-
const topMembers = getMemberActivity(db).slice(0, parseInt(options.top));
|
|
141
|
-
if (options.format === "json") {
|
|
142
|
-
console.log(JSON.stringify({ meta, overview, topMembers }, null, 2));
|
|
143
|
-
} else {
|
|
144
|
-
console.log(`
|
|
145
|
-
Session: ${meta?.name}`);
|
|
146
|
-
console.log(`Platform: ${meta?.platform} | Type: ${meta?.type}`);
|
|
147
|
-
console.log(`Total messages: ${overview.totalMessages}`);
|
|
148
|
-
console.log(`Total members: ${overview.totalMembers}`);
|
|
149
|
-
console.log(`Time range: ${formatTimeRange(overview.firstMessageTs, overview.lastMessageTs)}`);
|
|
150
|
-
if (topMembers.length > 0) {
|
|
151
|
-
console.log(`
|
|
152
|
-
Activity ranking (Top ${options.top}):`);
|
|
153
|
-
for (const [i, m] of topMembers.entries()) {
|
|
154
|
-
console.log(` ${i + 1}. ${m.name} - ${m.messageCount} messages (${m.percentage}%)`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
dbManager.closeAll();
|
|
159
|
-
});
|
|
160
|
-
program.command("search <session-id> <keyword>").description("Search messages by keyword").option("--limit <n>", "Max results to return", "20").option("--format <format>", "Output format (table|json)", "table").action((sessionId, keyword, options) => {
|
|
161
|
-
const { dbManager } = initRuntime();
|
|
162
|
-
const db = dbManager.open(sessionId);
|
|
163
|
-
if (!db) {
|
|
164
|
-
console.error(`Session ${sessionId} not found`);
|
|
165
|
-
process.exit(1);
|
|
166
|
-
}
|
|
167
|
-
const limit = parseInt(options.limit);
|
|
168
|
-
const result = searchMessagesLike(db, keyword, { limit });
|
|
169
|
-
if (options.format === "json") {
|
|
170
|
-
console.log(JSON.stringify(result, null, 2));
|
|
171
|
-
} else {
|
|
172
|
-
console.log(
|
|
173
|
-
`Search "${keyword}" - ${result.total} result(s)${result.hasMore ? " (showing first " + limit + ")" : ""}:
|
|
174
|
-
`
|
|
175
|
-
);
|
|
176
|
-
for (const msg of result.messages) {
|
|
177
|
-
const time = new Date(msg.timestamp * 1e3).toLocaleString();
|
|
178
|
-
console.log(` [${time}] ${msg.senderName}: ${msg.content}`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
dbManager.closeAll();
|
|
182
|
-
});
|
|
183
|
-
program.command("members <session-id>").description("List session members").option("--format <format>", "Output format (table|json)", "table").action((sessionId, options) => {
|
|
184
|
-
const { dbManager } = initRuntime();
|
|
185
|
-
const db = dbManager.open(sessionId);
|
|
186
|
-
if (!db) {
|
|
187
|
-
console.error(`Session ${sessionId} not found`);
|
|
188
|
-
process.exit(1);
|
|
189
|
-
}
|
|
190
|
-
const members = getMembers(db);
|
|
191
|
-
if (options.format === "json") {
|
|
192
|
-
console.log(JSON.stringify(members, null, 2));
|
|
193
|
-
} else {
|
|
194
|
-
console.log(`${members.length} member(s):
|
|
195
|
-
`);
|
|
196
|
-
for (const [i, m] of members.entries()) {
|
|
197
|
-
console.log(` ${i + 1}. ${m.name} (${m.platformId}) - ${m.messageCount} messages`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
dbManager.closeAll();
|
|
201
|
-
});
|
|
202
|
-
program.command("query <session-id>").description("Execute a read-only SQL query on a session database").requiredOption("--sql <sql>", "SQL query statement").option("--format <format>", "Output format (table|json)", "table").action((sessionId, options) => {
|
|
203
|
-
const { dbManager } = initRuntime();
|
|
204
|
-
const db = dbManager.open(sessionId);
|
|
205
|
-
if (!db) {
|
|
206
|
-
console.error(`Session ${sessionId} not found`);
|
|
207
|
-
process.exit(1);
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
const result = executeReadonlySql(db, options.sql);
|
|
211
|
-
if (options.format === "json") {
|
|
212
|
-
console.log(JSON.stringify(result, null, 2));
|
|
213
|
-
} else {
|
|
214
|
-
if (result.rows.length === 0) {
|
|
215
|
-
console.log("No results.");
|
|
216
|
-
} else {
|
|
217
|
-
printTable(result.columns, result.rows);
|
|
218
|
-
console.log(`
|
|
219
|
-
${result.rowCount} row(s)${result.truncated ? " (truncated)" : ""}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
} catch (err) {
|
|
223
|
-
console.error(`SQL error: ${err instanceof Error ? err.message : err}`);
|
|
224
|
-
process.exit(1);
|
|
225
|
-
}
|
|
226
|
-
dbManager.closeAll();
|
|
227
|
-
});
|
|
228
|
-
program.command("import <file>").description("Import a chat history file (14+ formats: QQ/WeChat/Telegram/WhatsApp/LINE/Discord/Instagram, etc.)").option("--session-id <id>", "Specify session ID (auto-generated if omitted)").option("--format <id>", "Specify format ID (skip auto-detection)").action(async (file, options) => {
|
|
229
|
-
if (!fs.existsSync(file)) {
|
|
230
|
-
console.error(`File not found: ${file}`);
|
|
231
|
-
process.exit(1);
|
|
232
|
-
}
|
|
233
|
-
const { streamImport, detectFormat } = await import("./import-3KG6VK6O.mjs");
|
|
234
|
-
const { dbManager, pathProvider } = initRuntime();
|
|
235
|
-
const nativeBinding = resolveNativeBinding();
|
|
236
|
-
const format = detectFormat(file);
|
|
237
|
-
if (!format && !options.format) {
|
|
238
|
-
console.error(`Unrecognized file format: ${file}`);
|
|
239
|
-
console.error('Use --format <id> to specify manually, or run "chatlab formats" to see supported formats');
|
|
240
|
-
process.exit(1);
|
|
241
|
-
}
|
|
242
|
-
console.log(`Importing: ${file}`);
|
|
243
|
-
if (format) console.log(` Format: ${format.name} (${format.platform})`);
|
|
244
|
-
try {
|
|
245
|
-
const result = await streamImport(dbManager, file, {
|
|
246
|
-
formatId: options.format,
|
|
247
|
-
nativeBinding,
|
|
248
|
-
onProgress: (p) => {
|
|
249
|
-
process.stdout.write(`\r ${p.stage}: ${p.progress}%`);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
if (result.success) {
|
|
253
|
-
console.log(`
|
|
254
|
-
|
|
255
|
-
Import succeeded!`);
|
|
256
|
-
console.log(` Session ID: ${result.sessionId}`);
|
|
257
|
-
console.log(` Messages written: ${result.diagnostics?.messagesWritten ?? 0}`);
|
|
258
|
-
console.log(` Messages skipped: ${result.diagnostics?.messagesSkipped ?? 0}`);
|
|
259
|
-
if (result.sessionId) {
|
|
260
|
-
try {
|
|
261
|
-
const { PreferencesManager, createDatabaseManagerAdapter, ownerProfileService } = await import("./src-UTBQAOJ3.mjs");
|
|
262
|
-
const applied = ownerProfileService.tryApplyOwnerProfile(
|
|
263
|
-
createDatabaseManagerAdapter(dbManager),
|
|
264
|
-
new PreferencesManager(pathProvider.getSystemDir()),
|
|
265
|
-
result.sessionId
|
|
266
|
-
);
|
|
267
|
-
if (applied.applied) {
|
|
268
|
-
console.log(` Owner auto-detected: ${applied.ownerId}`);
|
|
269
|
-
}
|
|
270
|
-
} catch (ownerErr) {
|
|
271
|
-
console.warn(` Owner profile apply skipped: ${ownerErr instanceof Error ? ownerErr.message : ownerErr}`);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
} else {
|
|
275
|
-
console.error(`
|
|
276
|
-
|
|
277
|
-
Import failed: ${result.error}`);
|
|
278
|
-
process.exit(1);
|
|
279
|
-
}
|
|
280
|
-
} catch (err) {
|
|
281
|
-
console.error(`
|
|
282
|
-
|
|
283
|
-
Import error: ${err instanceof Error ? err.message : err}`);
|
|
284
|
-
process.exit(1);
|
|
285
|
-
} finally {
|
|
286
|
-
dbManager.closeAll();
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
program.command("formats").description("List all supported chat history formats").action(async () => {
|
|
290
|
-
const { getSupportedFormats } = await import("./import-3KG6VK6O.mjs");
|
|
291
|
-
const formats = getSupportedFormats();
|
|
292
|
-
console.log(`${formats.length} supported format(s):
|
|
293
|
-
`);
|
|
294
|
-
for (const f of formats) {
|
|
295
|
-
console.log(` ${f.id.padEnd(30)} ${f.name} (${f.platform}) [${f.extensions.join(", ")}]`);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
program.command("mcp").description("Start MCP Server (stdio transport, for ClaudeCode / Cursor / AI agents)").action(async () => {
|
|
299
|
-
const { startCliMcpServer } = await import("./mcp-JBI4CUQT.mjs");
|
|
300
|
-
await startCliMcpServer();
|
|
301
|
-
});
|
|
302
|
-
program.command("chat").description("Ask ChatLab AI about an imported chat session").option("--session-id <id>", "Source chat session ID").option("--ai-chat-id <id>", "Existing AI chat ID to continue").option("-q, --question <text>", "Question to ask").option("--json", "Output structured JSON").option("--include-events", "Include all agent stream chunks in JSON output").option("--no-stream", "Disable streaming output").option("--locale <locale>", "AI response locale", "zh-CN").action(async (options) => {
|
|
303
|
-
const { runChatCommand } = await import("./chat-command-JKG3FY5B.mjs");
|
|
304
|
-
const { dbManager, pathProvider } = initRuntime();
|
|
305
|
-
const aiChatManager = new AIChatManager(pathProvider.getAiDataDir(), { nativeBinding: resolveNativeBinding() });
|
|
306
|
-
try {
|
|
307
|
-
await runChatCommand(
|
|
308
|
-
{
|
|
309
|
-
sessionId: options.sessionId,
|
|
310
|
-
aiChatId: options.aiChatId,
|
|
311
|
-
question: options.question,
|
|
312
|
-
json: !!options.json,
|
|
313
|
-
stream: options.stream,
|
|
314
|
-
locale: options.locale,
|
|
315
|
-
includeEvents: !!options.includeEvents
|
|
316
|
-
},
|
|
317
|
-
{ dbManager, pathProvider, aiChatManager }
|
|
318
|
-
);
|
|
319
|
-
} catch (error) {
|
|
320
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
321
|
-
process.exitCode = 1;
|
|
322
|
-
} finally {
|
|
323
|
-
aiChatManager.close();
|
|
324
|
-
dbManager.closeAll();
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
program.command("start").description("Start ChatLab (HTTP API + Web UI)").option("--port <port>", "Server port", String(DEFAULT_API_PORT)).option("--host <host>", "Listen address", "127.0.0.1").option("--token <token>", "Custom Bearer Token (reads from config or auto-generates if omitted)").option("--headless", "API-only mode, do not serve the Web UI").option("--require-auth", "Require Bearer token for all routes including /_web/*").option("--no-open", "Do not auto-open the browser").option("--daemon", "Run as a resident system service (auto-start on login, macOS/Linux)").action(async (options) => {
|
|
328
|
-
if (options.daemon) {
|
|
329
|
-
const { serviceInstall } = await import("./service-KGL3RAIA.mjs");
|
|
330
|
-
serviceInstall({
|
|
331
|
-
port: parseInt(options.port, 10),
|
|
332
|
-
host: options.host,
|
|
333
|
-
token: options.token || void 0,
|
|
334
|
-
headless: options.headless,
|
|
335
|
-
requireAuth: options.requireAuth || void 0
|
|
336
|
-
});
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
const { startHttpServer } = await import("./http-5E7ARYFW.mjs");
|
|
340
|
-
const port = parseInt(options.port, 10);
|
|
341
|
-
let webRoot;
|
|
342
|
-
if (!options.headless) {
|
|
343
|
-
const webDir = resolveCliPath("dist-web");
|
|
344
|
-
if (fs.existsSync(webDir)) {
|
|
345
|
-
webRoot = webDir;
|
|
346
|
-
} else {
|
|
347
|
-
console.warn("Warning: dist-web/ not found, starting in API-only mode");
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
try {
|
|
351
|
-
if (!await isPortAvailable(port, options.host)) {
|
|
352
|
-
console.error(formatPortInUseError(port));
|
|
353
|
-
process.exit(1);
|
|
354
|
-
}
|
|
355
|
-
const info = await startHttpServer({
|
|
356
|
-
port,
|
|
357
|
-
host: options.host,
|
|
358
|
-
token: options.token || void 0,
|
|
359
|
-
webRoot,
|
|
360
|
-
requireAuth: options.requireAuth || void 0
|
|
361
|
-
});
|
|
362
|
-
const { startPeriodicUpdateCheck } = await import("./update-checker-LGMTEKMT.mjs");
|
|
363
|
-
startPeriodicUpdateCheck();
|
|
364
|
-
const displayHost = info.host === "0.0.0.0" ? "127.0.0.1" : info.host;
|
|
365
|
-
const url = `http://${displayHost}:${info.port}`;
|
|
366
|
-
console.log(`
|
|
367
|
-
ChatLab v${getVersion()}`);
|
|
368
|
-
if (webRoot) console.log(` Web UI: ${url}/`);
|
|
369
|
-
console.log(` API: ${url}`);
|
|
370
|
-
console.log(` Token: ${info.token}`);
|
|
371
|
-
console.log(`
|
|
372
|
-
Example:`);
|
|
373
|
-
console.log(` curl -H "Authorization: Bearer ${info.token}" ${url}/api/v1/status`);
|
|
374
|
-
if (webRoot && options.open) {
|
|
375
|
-
openBrowser(url);
|
|
376
|
-
console.log(`
|
|
377
|
-
Browser opened. Press Ctrl+C to stop.
|
|
378
|
-
`);
|
|
379
|
-
} else {
|
|
380
|
-
console.log(`
|
|
381
|
-
Press Ctrl+C to stop.
|
|
382
|
-
`);
|
|
383
|
-
}
|
|
384
|
-
const shutdown = async () => {
|
|
385
|
-
console.log("\nShutting down...");
|
|
386
|
-
const { stopHttpServer } = await import("./http-5E7ARYFW.mjs");
|
|
387
|
-
await stopHttpServer();
|
|
388
|
-
process.exit(0);
|
|
389
|
-
};
|
|
390
|
-
process.on("SIGINT", shutdown);
|
|
391
|
-
process.on("SIGTERM", shutdown);
|
|
392
|
-
} catch (err) {
|
|
393
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
394
|
-
if (message.includes("EADDRINUSE")) {
|
|
395
|
-
console.error(formatPortInUseError(port));
|
|
396
|
-
} else {
|
|
397
|
-
console.error(`Startup failed: ${message}`);
|
|
398
|
-
}
|
|
399
|
-
process.exit(1);
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
var configCmd = program.command("config").description("Configuration management");
|
|
403
|
-
configCmd.command("path").description("Show config file path").action(() => {
|
|
404
|
-
console.log(getConfigPath());
|
|
405
|
-
});
|
|
406
|
-
configCmd.command("show").description("Show current configuration").action(() => {
|
|
407
|
-
const config = loadConfig();
|
|
408
|
-
console.log(JSON.stringify(config, null, 2));
|
|
409
|
-
});
|
|
410
|
-
program.command("stop").description("Stop the resident service and remove auto-start (reverse of start --daemon)").action(async () => {
|
|
411
|
-
const { serviceUninstall } = await import("./service-KGL3RAIA.mjs");
|
|
412
|
-
serviceUninstall();
|
|
413
|
-
});
|
|
414
|
-
program.command("status").description("Show resident service status").action(async () => {
|
|
415
|
-
const { getServiceStatus } = await import("./service-KGL3RAIA.mjs");
|
|
416
|
-
const svc = getServiceStatus();
|
|
417
|
-
console.log("\nChatLab Status");
|
|
418
|
-
console.log("\u2500".repeat(36));
|
|
419
|
-
console.log(` Logs: ${getSystemLogsDir()}`);
|
|
420
|
-
if (svc.installed) {
|
|
421
|
-
const portStr = svc.port ? `http://${svc.host ?? "127.0.0.1"}:${svc.port}` : "";
|
|
422
|
-
console.log(` Service: ${svc.running ? "running" : "installed (not running)"}`);
|
|
423
|
-
if (portStr) console.log(` Address: ${portStr}`);
|
|
424
|
-
console.log(` Auto-start: enabled`);
|
|
425
|
-
console.log(`
|
|
426
|
-
Use \`chatlab stop\` to remove the service.
|
|
427
|
-
`);
|
|
428
|
-
} else {
|
|
429
|
-
console.log(` Service: not installed`);
|
|
430
|
-
console.log(` Auto-start: disabled`);
|
|
431
|
-
console.log(`
|
|
432
|
-
Use \`chatlab start --daemon\` to install as a system service.
|
|
433
|
-
`);
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
function openBrowser(url) {
|
|
437
|
-
try {
|
|
438
|
-
const cmd = process.platform === "darwin" ? `open "${url}"` : process.platform === "win32" ? `start "" "${url}"` : `xdg-open "${url}"`;
|
|
439
|
-
execSync(cmd, { stdio: "ignore" });
|
|
440
|
-
} catch {
|
|
441
|
-
console.log(` Open manually: ${url}`);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
function resolveNativeBinding() {
|
|
445
|
-
if (process.versions.electron) return void 0;
|
|
446
|
-
const nativePath = resolveCliPath("native/better_sqlite3.node");
|
|
447
|
-
if (fs.existsSync(nativePath)) return nativePath;
|
|
448
|
-
return void 0;
|
|
449
|
-
}
|
|
450
|
-
function initRuntime() {
|
|
451
|
-
let config = loadConfig();
|
|
452
|
-
const pendingMigration = applyPendingNodeDataDirMigrationIfNeeded();
|
|
453
|
-
if (!pendingMigration.skipped) {
|
|
454
|
-
if (pendingMigration.success) {
|
|
455
|
-
console.log("[Migration] Pending data directory migration completed");
|
|
456
|
-
config = loadConfig();
|
|
457
|
-
} else {
|
|
458
|
-
console.error("[Migration] Pending data directory migration failed:", pendingMigration.error);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
const userDataDir = config.data.user_data_dir || void 0;
|
|
462
|
-
const pathProvider = new NodePathProvider(userDataDir);
|
|
463
|
-
pathProvider.ensureAllDirs();
|
|
464
|
-
const runtime = assertCliDataDirCompatible(pathProvider, "cli");
|
|
465
|
-
if (hasPendingElectronDataWarning() || !verifyCliDataPath(pathProvider.getDatabaseDir())) {
|
|
466
|
-
printElectronDataError();
|
|
467
|
-
process.exit(1);
|
|
468
|
-
}
|
|
469
|
-
const nativeBinding = resolveNativeBinding();
|
|
470
|
-
const dbManager = new DatabaseManager(pathProvider, { nativeBinding, runtime });
|
|
471
|
-
return { config, pathProvider, dbManager };
|
|
472
|
-
}
|
|
473
|
-
function printElectronDataError() {
|
|
474
|
-
console.error("\n" + "=".repeat(68));
|
|
475
|
-
console.error(" ChatLab: Electron desktop data not found");
|
|
476
|
-
console.error("=".repeat(68));
|
|
477
|
-
console.error("");
|
|
478
|
-
console.error(" Detected that ChatLab desktop app was installed on this machine,");
|
|
479
|
-
console.error(" but could not locate your chat databases.");
|
|
480
|
-
console.error("");
|
|
481
|
-
console.error(" This usually means you changed the data directory in desktop settings.");
|
|
482
|
-
console.error("");
|
|
483
|
-
console.error(" To fix this, choose one of:");
|
|
484
|
-
console.error("");
|
|
485
|
-
console.error(" 1. Open ChatLab desktop app \u2014 it will auto-migrate your data");
|
|
486
|
-
console.error(" 2. Set the data directory manually:");
|
|
487
|
-
console.error(' export CHATLAB_DATA_DIR="/path/to/your/data"');
|
|
488
|
-
console.error(" 3. Edit ~/.chatlab/config.toml:");
|
|
489
|
-
console.error(" [data]");
|
|
490
|
-
console.error(' user_data_dir = "/path/to/your/data"');
|
|
491
|
-
console.error("");
|
|
492
|
-
console.error("=".repeat(68) + "\n");
|
|
493
|
-
}
|
|
494
|
-
function formatTimeRange(first, last) {
|
|
495
|
-
if (!first || !last) return "Unknown";
|
|
496
|
-
const from = new Date(first * 1e3).toLocaleDateString();
|
|
497
|
-
const to = new Date(last * 1e3).toLocaleDateString();
|
|
498
|
-
return `${from} ~ ${to}`;
|
|
499
|
-
}
|
|
500
|
-
function printTable(columns, rows) {
|
|
501
|
-
const widths = columns.map((col) => {
|
|
502
|
-
const maxData = rows.reduce((max, row) => {
|
|
503
|
-
const val = String(row[col] ?? "");
|
|
504
|
-
return Math.max(max, val.length);
|
|
505
|
-
}, 0);
|
|
506
|
-
return Math.max(col.length, Math.min(maxData, 40));
|
|
507
|
-
});
|
|
508
|
-
const header = columns.map((col, i) => col.padEnd(widths[i])).join(" | ");
|
|
509
|
-
const separator = widths.map((w) => "-".repeat(w)).join("-+-");
|
|
510
|
-
console.log(header);
|
|
511
|
-
console.log(separator);
|
|
512
|
-
for (const row of rows) {
|
|
513
|
-
const line = columns.map((col, i) => {
|
|
514
|
-
const val = String(row[col] ?? "");
|
|
515
|
-
return val.length > 40 ? val.slice(0, 37) + "..." : val.padEnd(widths[i]);
|
|
516
|
-
}).join(" | ");
|
|
517
|
-
console.log(line);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
function run(argv) {
|
|
521
|
-
initAppLogger(getSystemLogsDir());
|
|
522
|
-
process.on("uncaughtException", (error) => {
|
|
523
|
-
console.error("Uncaught Exception:", error);
|
|
524
|
-
appLogger.error("crash", "uncaughtException", error);
|
|
525
|
-
process.exit(1);
|
|
526
|
-
});
|
|
527
|
-
process.on("unhandledRejection", (reason) => {
|
|
528
|
-
console.error("Unhandled Rejection:", reason);
|
|
529
|
-
appLogger.error("crash", "unhandledRejection", reason);
|
|
530
|
-
process.exit(1);
|
|
531
|
-
});
|
|
532
|
-
program.parse(argv);
|
|
533
|
-
}
|
|
534
|
-
var isDirectRun = process.argv[1]?.endsWith("cli.ts") || process.argv[1]?.endsWith("cli.js");
|
|
535
|
-
if (isDirectRun) {
|
|
536
|
-
run();
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
export {
|
|
540
|
-
run
|
|
541
|
-
};
|
|
542
|
-
//# sourceMappingURL=chunk-ARZM6HBX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/http/port.ts"],"sourcesContent":["/**\n * ChatLab CLI entry point\n *\n * Dev: pnpm --filter chatlab-cli run cli -- sessions\n */\n\nimport * as fs from 'fs'\nimport { execSync } from 'child_process'\nimport { Command } from 'commander'\nimport { DEFAULT_API_PORT, loadConfig, getConfigPath } from '@openchatlab/config'\nimport {\n NodePathProvider,\n DatabaseManager,\n AIChatManager,\n applyPendingNodeDataDirMigrationIfNeeded,\n hasPendingElectronDataWarning,\n verifyCliDataPath,\n initAppLogger,\n appLogger,\n getSystemLogsDir,\n} from '@openchatlab/node-runtime'\nimport {\n getSessionMeta,\n getSessionOverview,\n getMemberActivity,\n searchMessagesLike,\n getMembers,\n executeReadonlySql,\n} from '@openchatlab/core'\nimport { getVersion } from './version'\nimport { resolveCliPath } from './paths'\nimport { isPortAvailable, formatPortInUseError } from './http/port'\nimport { assertCliDataDirCompatible } from './runtime-compat'\n\nconst program = new Command()\n\nprogram.name('chatlab').description('ChatLab - Chat history analysis tool').version(getVersion(), '-v, --version')\n\nprogram.hook('preAction', async (_thisCommand, actionCommand) => {\n if (actionCommand.name() === 'update') return\n const { checkForUpdatesInteractive } = await import('./update-checker')\n await checkForUpdatesInteractive()\n})\n\nprogram\n .command('update')\n .description('Update ChatLab CLI to the latest version')\n .action(async () => {\n const { performCliSelfUpdate } = await import('./update-checker')\n const result = await performCliSelfUpdate({\n write: (text) => process.stderr.write(text),\n })\n\n if (result.success) {\n console.error(' Updated successfully. Please restart chatlab to use the new version.\\n')\n return\n }\n\n console.error(` Update failed: ${result.error || 'unknown error'}\\n`)\n process.exitCode = 1\n })\n\nprogram\n .command('sessions')\n .description('List all imported chat sessions')\n .option('--format <format>', 'Output format (table|json)', 'table')\n .action((options) => {\n const { dbManager } = initRuntime()\n const sessionIds = dbManager.listSessionIds()\n\n if (sessionIds.length === 0) {\n console.log('No chat sessions found.')\n console.log(`Data directory: ${dbManager['pathProvider'].getUserDataDir()}`)\n dbManager.closeAll()\n return\n }\n\n const sessions = sessionIds\n .map((id) => {\n const db = dbManager.open(id)\n if (!db) return null\n const meta = getSessionMeta(db)\n if (!meta) return null\n const overview = getSessionOverview(db)\n return { id, ...meta, ...overview }\n })\n .filter(Boolean)\n\n if (options.format === 'json') {\n console.log(JSON.stringify(sessions, null, 2))\n } else {\n console.log(`${sessions.length} session(s) found:\\n`)\n for (const s of sessions) {\n if (!s) continue\n const timeRange = formatTimeRange(s.firstMessageTs, s.lastMessageTs)\n console.log(` ${s.name}`)\n console.log(` ID: ${s.id}`)\n console.log(\n ` Platform: ${s.platform} | Type: ${s.type} | Members: ${s.totalMembers} | Messages: ${s.totalMessages}`\n )\n if (timeRange) console.log(` Range: ${timeRange}`)\n console.log()\n }\n }\n\n dbManager.closeAll()\n })\n\nprogram\n .command('stats <session-id>')\n .description('Show session statistics overview')\n .option('--format <format>', 'Output format (table|json)', 'table')\n .option('--top <n>', 'Show top N active members', '10')\n .action((sessionId, options) => {\n const { dbManager } = initRuntime()\n const db = dbManager.open(sessionId)\n if (!db) {\n console.error(`Session ${sessionId} not found`)\n process.exit(1)\n }\n\n const meta = getSessionMeta(db)\n const overview = getSessionOverview(db)\n const topMembers = getMemberActivity(db).slice(0, parseInt(options.top))\n\n if (options.format === 'json') {\n console.log(JSON.stringify({ meta, overview, topMembers }, null, 2))\n } else {\n console.log(`\\nSession: ${meta?.name}`)\n console.log(`Platform: ${meta?.platform} | Type: ${meta?.type}`)\n console.log(`Total messages: ${overview.totalMessages}`)\n console.log(`Total members: ${overview.totalMembers}`)\n console.log(`Time range: ${formatTimeRange(overview.firstMessageTs, overview.lastMessageTs)}`)\n\n if (topMembers.length > 0) {\n console.log(`\\nActivity ranking (Top ${options.top}):`)\n for (const [i, m] of topMembers.entries()) {\n console.log(` ${i + 1}. ${m.name} - ${m.messageCount} messages (${m.percentage}%)`)\n }\n }\n }\n\n dbManager.closeAll()\n })\n\nprogram\n .command('search <session-id> <keyword>')\n .description('Search messages by keyword')\n .option('--limit <n>', 'Max results to return', '20')\n .option('--format <format>', 'Output format (table|json)', 'table')\n .action((sessionId, keyword, options) => {\n const { dbManager } = initRuntime()\n const db = dbManager.open(sessionId)\n if (!db) {\n console.error(`Session ${sessionId} not found`)\n process.exit(1)\n }\n\n const limit = parseInt(options.limit)\n const result = searchMessagesLike(db, keyword, { limit })\n\n if (options.format === 'json') {\n console.log(JSON.stringify(result, null, 2))\n } else {\n console.log(\n `Search \"${keyword}\" - ${result.total} result(s)${result.hasMore ? ' (showing first ' + limit + ')' : ''}:\\n`\n )\n for (const msg of result.messages) {\n const time = new Date(msg.timestamp * 1000).toLocaleString()\n console.log(` [${time}] ${msg.senderName}: ${msg.content}`)\n }\n }\n\n dbManager.closeAll()\n })\n\nprogram\n .command('members <session-id>')\n .description('List session members')\n .option('--format <format>', 'Output format (table|json)', 'table')\n .action((sessionId, options) => {\n const { dbManager } = initRuntime()\n const db = dbManager.open(sessionId)\n if (!db) {\n console.error(`Session ${sessionId} not found`)\n process.exit(1)\n }\n\n const members = getMembers(db)\n\n if (options.format === 'json') {\n console.log(JSON.stringify(members, null, 2))\n } else {\n console.log(`${members.length} member(s):\\n`)\n for (const [i, m] of members.entries()) {\n console.log(` ${i + 1}. ${m.name} (${m.platformId}) - ${m.messageCount} messages`)\n }\n }\n\n dbManager.closeAll()\n })\n\nprogram\n .command('query <session-id>')\n .description('Execute a read-only SQL query on a session database')\n .requiredOption('--sql <sql>', 'SQL query statement')\n .option('--format <format>', 'Output format (table|json)', 'table')\n .action((sessionId, options) => {\n const { dbManager } = initRuntime()\n const db = dbManager.open(sessionId)\n if (!db) {\n console.error(`Session ${sessionId} not found`)\n process.exit(1)\n }\n\n try {\n const result = executeReadonlySql(db, options.sql)\n if (options.format === 'json') {\n console.log(JSON.stringify(result, null, 2))\n } else {\n if (result.rows.length === 0) {\n console.log('No results.')\n } else {\n printTable(result.columns, result.rows)\n console.log(`\\n${result.rowCount} row(s)${result.truncated ? ' (truncated)' : ''}`)\n }\n }\n } catch (err) {\n console.error(`SQL error: ${err instanceof Error ? err.message : err}`)\n process.exit(1)\n }\n\n dbManager.closeAll()\n })\n\nprogram\n .command('import <file>')\n .description('Import a chat history file (14+ formats: QQ/WeChat/Telegram/WhatsApp/LINE/Discord/Instagram, etc.)')\n .option('--session-id <id>', 'Specify session ID (auto-generated if omitted)')\n .option('--format <id>', 'Specify format ID (skip auto-detection)')\n .action(async (file, options) => {\n if (!fs.existsSync(file)) {\n console.error(`File not found: ${file}`)\n process.exit(1)\n }\n\n const { streamImport, detectFormat } = await import('./import')\n const { dbManager, pathProvider } = initRuntime()\n const nativeBinding = resolveNativeBinding()\n\n const format = detectFormat(file)\n if (!format && !options.format) {\n console.error(`Unrecognized file format: ${file}`)\n console.error('Use --format <id> to specify manually, or run \"chatlab formats\" to see supported formats')\n process.exit(1)\n }\n\n console.log(`Importing: ${file}`)\n if (format) console.log(` Format: ${format.name} (${format.platform})`)\n\n try {\n const result = await streamImport(dbManager, file, {\n formatId: options.format,\n nativeBinding,\n onProgress: (p) => {\n process.stdout.write(`\\r ${p.stage}: ${p.progress}%`)\n },\n })\n\n if (result.success) {\n console.log(`\\n\\nImport succeeded!`)\n console.log(` Session ID: ${result.sessionId}`)\n console.log(` Messages written: ${result.diagnostics?.messagesWritten ?? 0}`)\n console.log(` Messages skipped: ${result.diagnostics?.messagesSkipped ?? 0}`)\n\n if (result.sessionId) {\n try {\n const { PreferencesManager, createDatabaseManagerAdapter, ownerProfileService } =\n await import('@openchatlab/node-runtime')\n const applied = ownerProfileService.tryApplyOwnerProfile(\n createDatabaseManagerAdapter(dbManager),\n new PreferencesManager(pathProvider.getSystemDir()),\n result.sessionId\n )\n if (applied.applied) {\n console.log(` Owner auto-detected: ${applied.ownerId}`)\n }\n } catch (ownerErr) {\n console.warn(` Owner profile apply skipped: ${ownerErr instanceof Error ? ownerErr.message : ownerErr}`)\n }\n }\n } else {\n console.error(`\\n\\nImport failed: ${result.error}`)\n process.exit(1)\n }\n } catch (err) {\n console.error(`\\n\\nImport error: ${err instanceof Error ? err.message : err}`)\n process.exit(1)\n } finally {\n dbManager.closeAll()\n }\n })\n\nprogram\n .command('formats')\n .description('List all supported chat history formats')\n .action(async () => {\n const { getSupportedFormats } = await import('./import')\n const formats = getSupportedFormats()\n console.log(`${formats.length} supported format(s):\\n`)\n for (const f of formats) {\n console.log(` ${f.id.padEnd(30)} ${f.name} (${f.platform}) [${f.extensions.join(', ')}]`)\n }\n })\n\nprogram\n .command('mcp')\n .description('Start MCP Server (stdio transport, for ClaudeCode / Cursor / AI agents)')\n .action(async () => {\n const { startCliMcpServer } = await import('./mcp')\n await startCliMcpServer()\n })\n\nprogram\n .command('chat')\n .description('Ask ChatLab AI about an imported chat session')\n .option('--session-id <id>', 'Source chat session ID')\n .option('--ai-chat-id <id>', 'Existing AI chat ID to continue')\n .option('-q, --question <text>', 'Question to ask')\n .option('--json', 'Output structured JSON')\n .option('--include-events', 'Include all agent stream chunks in JSON output')\n .option('--no-stream', 'Disable streaming output')\n .option('--locale <locale>', 'AI response locale', 'zh-CN')\n .action(async (options) => {\n const { runChatCommand } = await import('./ai/chat-command')\n const { dbManager, pathProvider } = initRuntime()\n const aiChatManager = new AIChatManager(pathProvider.getAiDataDir(), { nativeBinding: resolveNativeBinding() })\n\n try {\n await runChatCommand(\n {\n sessionId: options.sessionId,\n aiChatId: options.aiChatId,\n question: options.question,\n json: !!options.json,\n stream: options.stream,\n locale: options.locale,\n includeEvents: !!options.includeEvents,\n },\n { dbManager, pathProvider, aiChatManager }\n )\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error))\n process.exitCode = 1\n } finally {\n aiChatManager.close()\n dbManager.closeAll()\n }\n })\n\nprogram\n .command('start')\n .description('Start ChatLab (HTTP API + Web UI)')\n .option('--port <port>', 'Server port', String(DEFAULT_API_PORT))\n .option('--host <host>', 'Listen address', '127.0.0.1')\n .option('--token <token>', 'Custom Bearer Token (reads from config or auto-generates if omitted)')\n .option('--headless', 'API-only mode, do not serve the Web UI')\n .option('--require-auth', 'Require Bearer token for all routes including /_web/*')\n .option('--no-open', 'Do not auto-open the browser')\n .option('--daemon', 'Run as a resident system service (auto-start on login, macOS/Linux)')\n .action(async (options) => {\n // --daemon: install as system service and exit\n if (options.daemon) {\n const { serviceInstall } = await import('./daemon/service')\n serviceInstall({\n port: parseInt(options.port, 10),\n host: options.host,\n token: options.token || undefined,\n headless: options.headless,\n requireAuth: options.requireAuth || undefined,\n })\n return\n }\n\n const { startHttpServer } = await import('./http')\n const port = parseInt(options.port, 10)\n\n let webRoot: string | undefined\n if (!options.headless) {\n const webDir = resolveCliPath('dist-web')\n if (fs.existsSync(webDir)) {\n webRoot = webDir\n } else {\n console.warn('Warning: dist-web/ not found, starting in API-only mode')\n }\n }\n\n try {\n // 启动前预检端口,快速失败,避免无谓的初始化后再报 EADDRINUSE;\n // 置于 try 内确保非 EADDRINUSE 错误(EACCES/EADDRNOTAVAIL 等)\n // 也能走到统一的 Startup failed 错误处理路径。\n if (!(await isPortAvailable(port, options.host))) {\n console.error(formatPortInUseError(port))\n process.exit(1)\n }\n\n const info = await startHttpServer({\n port,\n host: options.host,\n token: options.token || undefined,\n webRoot,\n requireAuth: options.requireAuth || undefined,\n })\n\n const { startPeriodicUpdateCheck } = await import('./update-checker')\n startPeriodicUpdateCheck()\n\n const displayHost = info.host === '0.0.0.0' ? '127.0.0.1' : info.host\n const url = `http://${displayHost}:${info.port}`\n\n console.log(`\\nChatLab v${getVersion()}`)\n if (webRoot) console.log(` Web UI: ${url}/`)\n console.log(` API: ${url}`)\n console.log(` Token: ${info.token}`)\n console.log(`\\nExample:`)\n console.log(` curl -H \"Authorization: Bearer ${info.token}\" ${url}/api/v1/status`)\n\n if (webRoot && options.open) {\n openBrowser(url)\n console.log(`\\nBrowser opened. Press Ctrl+C to stop.\\n`)\n } else {\n console.log(`\\nPress Ctrl+C to stop.\\n`)\n }\n\n const shutdown = async () => {\n console.log('\\nShutting down...')\n const { stopHttpServer } = await import('./http')\n await stopHttpServer()\n process.exit(0)\n }\n\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : String(err)\n if (message.includes('EADDRINUSE')) {\n // 极低概率的 TOCTOU 竞态(预检通过后端口被占),复用统一文案\n console.error(formatPortInUseError(port))\n } else {\n console.error(`Startup failed: ${message}`)\n }\n process.exit(1)\n }\n })\n\nconst configCmd = program.command('config').description('Configuration management')\n\nconfigCmd\n .command('path')\n .description('Show config file path')\n .action(() => {\n console.log(getConfigPath())\n })\n\nconfigCmd\n .command('show')\n .description('Show current configuration')\n .action(() => {\n const config = loadConfig()\n console.log(JSON.stringify(config, null, 2))\n })\n\nprogram\n .command('stop')\n .description('Stop the resident service and remove auto-start (reverse of start --daemon)')\n .action(async () => {\n const { serviceUninstall } = await import('./daemon/service')\n serviceUninstall()\n })\n\nprogram\n .command('status')\n .description('Show resident service status')\n .action(async () => {\n const { getServiceStatus } = await import('./daemon/service')\n const svc = getServiceStatus()\n\n console.log('\\nChatLab Status')\n console.log('─'.repeat(36))\n console.log(` Logs: ${getSystemLogsDir()}`)\n\n if (svc.installed) {\n const portStr = svc.port ? `http://${svc.host ?? '127.0.0.1'}:${svc.port}` : ''\n console.log(` Service: ${svc.running ? 'running' : 'installed (not running)'}`)\n if (portStr) console.log(` Address: ${portStr}`)\n console.log(` Auto-start: enabled`)\n console.log(`\\n Use \\`chatlab stop\\` to remove the service.\\n`)\n } else {\n console.log(` Service: not installed`)\n console.log(` Auto-start: disabled`)\n console.log(`\\n Use \\`chatlab start --daemon\\` to install as a system service.\\n`)\n }\n })\n\n// --- 工具函数 ---\n\nfunction openBrowser(url: string): void {\n try {\n const cmd =\n process.platform === 'darwin'\n ? `open \"${url}\"`\n : process.platform === 'win32'\n ? `start \"\" \"${url}\"`\n : `xdg-open \"${url}\"`\n execSync(cmd, { stdio: 'ignore' })\n } catch {\n console.log(` Open manually: ${url}`)\n }\n}\n\n/**\n * Resolve standalone better-sqlite3 native module path.\n * Used in non-Electron environments to avoid electron-rebuild conflicts.\n */\nfunction resolveNativeBinding(): string | undefined {\n if (process.versions.electron) return undefined\n const nativePath = resolveCliPath('native/better_sqlite3.node')\n if (fs.existsSync(nativePath)) return nativePath\n return undefined\n}\n\nfunction initRuntime() {\n let config = loadConfig()\n const pendingMigration = applyPendingNodeDataDirMigrationIfNeeded()\n if (!pendingMigration.skipped) {\n if (pendingMigration.success) {\n console.log('[Migration] Pending data directory migration completed')\n config = loadConfig()\n } else {\n console.error('[Migration] Pending data directory migration failed:', pendingMigration.error)\n }\n }\n const userDataDir = config.data.user_data_dir || undefined\n const pathProvider = new NodePathProvider(userDataDir)\n pathProvider.ensureAllDirs()\n const runtime = assertCliDataDirCompatible(pathProvider, 'cli')\n\n if (hasPendingElectronDataWarning() || !verifyCliDataPath(pathProvider.getDatabaseDir())) {\n printElectronDataError()\n process.exit(1)\n }\n\n const nativeBinding = resolveNativeBinding()\n const dbManager = new DatabaseManager(pathProvider, { nativeBinding, runtime })\n return { config, pathProvider, dbManager }\n}\n\nfunction printElectronDataError(): void {\n console.error('\\n' + '='.repeat(68))\n console.error(' ChatLab: Electron desktop data not found')\n console.error('='.repeat(68))\n console.error('')\n console.error(' Detected that ChatLab desktop app was installed on this machine,')\n console.error(' but could not locate your chat databases.')\n console.error('')\n console.error(' This usually means you changed the data directory in desktop settings.')\n console.error('')\n console.error(' To fix this, choose one of:')\n console.error('')\n console.error(' 1. Open ChatLab desktop app — it will auto-migrate your data')\n console.error(' 2. Set the data directory manually:')\n console.error(' export CHATLAB_DATA_DIR=\"/path/to/your/data\"')\n console.error(' 3. Edit ~/.chatlab/config.toml:')\n console.error(' [data]')\n console.error(' user_data_dir = \"/path/to/your/data\"')\n console.error('')\n console.error('='.repeat(68) + '\\n')\n}\n\nfunction formatTimeRange(first: number | null, last: number | null): string {\n if (!first || !last) return 'Unknown'\n const from = new Date(first * 1000).toLocaleDateString()\n const to = new Date(last * 1000).toLocaleDateString()\n return `${from} ~ ${to}`\n}\n\nfunction printTable(columns: string[], rows: Record<string, unknown>[]): void {\n const widths = columns.map((col) => {\n const maxData = rows.reduce((max, row) => {\n const val = String(row[col] ?? '')\n return Math.max(max, val.length)\n }, 0)\n return Math.max(col.length, Math.min(maxData, 40))\n })\n\n const header = columns.map((col, i) => col.padEnd(widths[i])).join(' | ')\n const separator = widths.map((w) => '-'.repeat(w)).join('-+-')\n console.log(header)\n console.log(separator)\n\n for (const row of rows) {\n const line = columns\n .map((col, i) => {\n const val = String(row[col] ?? '')\n return val.length > 40 ? val.slice(0, 37) + '...' : val.padEnd(widths[i])\n })\n .join(' | ')\n console.log(line)\n }\n}\n\n/** CLI entry function */\nexport function run(argv?: string[]): void {\n // Logs go to ~/.chatlab/logs/app.log regardless of configured user data dir.\n initAppLogger(getSystemLogsDir())\n process.on('uncaughtException', (error) => {\n console.error('Uncaught Exception:', error)\n appLogger.error('crash', 'uncaughtException', error)\n process.exit(1)\n })\n process.on('unhandledRejection', (reason) => {\n console.error('Unhandled Rejection:', reason)\n appLogger.error('crash', 'unhandledRejection', reason)\n process.exit(1)\n })\n program.parse(argv)\n}\n\n// Auto-execute when run directly as a script\nconst isDirectRun = process.argv[1]?.endsWith('cli.ts') || process.argv[1]?.endsWith('cli.js')\nif (isDirectRun) {\n run()\n}\n","/**\n * 端口可用性检测与错误文案\n */\n\nimport * as net from 'net'\n\n/**\n * 检测指定端口在给定 host 上是否可用。\n * 使用 net.createServer() 试探性绑定,无副作用(成功后立即释放)。\n */\nexport function isPortAvailable(port: number, host: string): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const server = net.createServer()\n server.once('error', (err: NodeJS.ErrnoException) => {\n if (err.code === 'EADDRINUSE') {\n resolve(false)\n } else {\n reject(err)\n }\n })\n server.once('listening', () => server.close(() => resolve(true)))\n server.listen(port, host)\n })\n}\n\n/**\n * 返回端口被占用时统一的友好报错文案。\n */\nexport function formatPortInUseError(port: number): string {\n return [\n ``,\n ` ✖ Error: port ${port} is already in use.`,\n ``,\n ` Another process (possibly a ChatLab instance) is using this port. You can:`,\n ` • Use another port: chatlab start --port <port>`,\n ` • Find the process: lsof -iTCP:${port} -sTCP:LISTEN`,\n ``,\n ].join('\\n')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAY,QAAQ;AACpB,SAAS,gBAAgB;AACzB,SAAS,eAAe;;;ACJxB,YAAY,SAAS;AAMd,SAAS,gBAAgB,MAAc,MAAgC;AAC5E,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAa,iBAAa;AAChC,WAAO,KAAK,SAAS,CAAC,QAA+B;AACnD,UAAI,IAAI,SAAS,cAAc;AAC7B,gBAAQ,KAAK;AAAA,MACf,OAAO;AACL,eAAO,GAAG;AAAA,MACZ;AAAA,IACF,CAAC;AACD,WAAO,KAAK,aAAa,MAAM,OAAO,MAAM,MAAM,QAAQ,IAAI,CAAC,CAAC;AAChE,WAAO,OAAO,MAAM,IAAI;AAAA,EAC1B,CAAC;AACH;AAKO,SAAS,qBAAqB,MAAsB;AACzD,SAAO;AAAA,IAC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