chatlab-cli 0.31.2-beta.1 → 0.31.2
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-V6NYTTPD.mjs → chat-command-QPL4GNHP.mjs} +8 -8
- package/dist/{chunk-7TDYBU5L.mjs → chunk-3SZWD7UM.mjs} +4 -4
- package/dist/{chunk-WL2ISRYH.mjs → chunk-64FKPYPJ.mjs} +11 -11
- package/dist/{chunk-LWC7JQ2W.mjs → chunk-6JKKHPXY.mjs} +2 -2
- package/dist/{chunk-67HNEIKY.mjs → chunk-BSSR4ZYW.mjs} +1878 -2038
- package/dist/chunk-BSSR4ZYW.mjs.map +1 -0
- package/dist/{chunk-ZF67S6RY.mjs → chunk-F2NZ7HAY.mjs} +2 -2
- package/dist/{chunk-5G2INROS.mjs → chunk-GYPBWKAU.mjs} +356 -483
- package/dist/chunk-GYPBWKAU.mjs.map +1 -0
- package/dist/{chunk-XZ5FFDLX.mjs → chunk-IK7GJTGY.mjs} +131 -117
- package/dist/chunk-IK7GJTGY.mjs.map +1 -0
- package/dist/{chunk-HUKZ2PBC.mjs → chunk-OAXVKNPN.mjs} +2 -2
- package/dist/{chunk-54GVCXHZ.mjs → chunk-OQ6N4PDD.mjs} +2 -2
- package/dist/{chunk-SJQVAKFA.mjs → chunk-S5PQM5J4.mjs} +4 -5
- package/dist/chunk-S5PQM5J4.mjs.map +1 -0
- package/dist/{chunk-OIZ64ET3.mjs → chunk-ZCXCHKQV.mjs} +3 -3
- package/dist/cli.mjs +8 -8
- package/dist/contacts-worker.mjs +2 -2
- package/dist/global-insight-worker.mjs +1 -1
- package/dist/{http-AMDWRKOH.mjs → http-NOEWVWCP.mjs} +11 -11
- package/dist/{import-WIJHB4LH.mjs → import-RS3HW7ZM.mjs} +7 -7
- package/dist/index.mjs +11 -11
- package/dist/{mcp-NC5YNTM5.mjs → mcp-7F3G47Z4.mjs} +8 -8
- package/dist/people-relationships-worker.mjs +2 -2
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-UY4GCVNF.mjs → src-MNH5S423.mjs} +6 -22
- package/dist/{stream-import-JKQYRISL.mjs → stream-import-BPCHGRAN.mjs} +7 -7
- package/dist/{worker-runtime-KKUOJJTN.mjs → worker-runtime-TTAXGQ5R.mjs} +5 -5
- package/dist-web/assets/{ActionToolsPanel-BL0GQR6r.css → ActionToolsPanel-CbWhu_Uv.css} +1 -1
- package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CvvNqXuh.js +110 -0
- package/dist-web/assets/{BufferResource-i1amDJTV.js → BufferResource-Dh2kaMuP.js} +1 -1
- package/dist-web/assets/{CanvasRenderer-DGa7AjdC.js → CanvasRenderer-B8hHywwz.js} +1 -1
- package/dist-web/assets/{Filter-BTlq0yU-.js → Filter-Bap1KMW6.js} +1 -1
- package/dist-web/assets/{MessageExportModal-D9C5t_zF.js → MessageExportModal-H3-LAaXY.js} +1 -1
- package/dist-web/assets/{PageHeader-BEWr2vsg.js → PageHeader-CzTV_lyM.js} +1 -1
- package/dist-web/assets/{RelationshipGalaxyCanvas-CSgPNRif.js → RelationshipGalaxyCanvas-C6ZoUZNc.js} +3 -3
- package/dist-web/assets/{RelationshipGalaxyThreeCanvas-CBAnU8vN.js → RelationshipGalaxyThreeCanvas-DV6B-7XB.js} +1 -1
- package/dist-web/assets/{RenderTargetSystem-Ctlu222X.js → RenderTargetSystem-Dpgyoac_.js} +1 -1
- package/dist-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-D5vov0eO.js → TimeSelect.vue_vue_type_script_setup_true_lang--Tbo7p-l.js} +1 -1
- package/dist-web/assets/{WebGLRenderer-D2Zvhmcw.js → WebGLRenderer-DICnsAm5.js} +1 -1
- package/dist-web/assets/{WebGPURenderer-BOtP6h9o.js → WebGPURenderer-Bf0gkRK9.js} +1 -1
- package/dist-web/assets/{base-BMjDSaj6.js → base-D5T8QZ8b.js} +1 -1
- package/dist-web/assets/{browserAll-BhwLvWQY.js → browserAll-DcoCy7xY.js} +1 -1
- package/dist-web/assets/{dateFormat-dteP1INW.js → dateFormat-BDOkdsCR.js} +1 -1
- package/dist-web/assets/{electron-DCgfulPE.js → electron-CmhzSjaH.js} +1 -1
- package/dist-web/assets/{fetch-BbU4MPPu.js → fetch-BJka-sCN.js} +1 -1
- package/dist-web/assets/{fetch-CubnKpLG.js → fetch-BddgpyKJ.js} +1 -1
- package/dist-web/assets/{fetch-DgXWr9nB.js → fetch-C1mlq5VY.js} +1 -1
- package/dist-web/assets/{fetch-rJA9qLvd.js → fetch-CNz28Lv5.js} +1 -1
- package/dist-web/assets/{fetch-D5BrGna5.js → fetch-D71bG6Fc.js} +1 -1
- package/dist-web/assets/{fetch-CpvfCafG.js → fetch-D8xv4lgE.js} +1 -1
- package/dist-web/assets/{fetch-6q7oz7ZO.js → fetch-DfTM4Dah.js} +1 -1
- package/dist-web/assets/{fetch-B_0HIxs5.js → fetch-DtcNaN3d.js} +1 -1
- package/dist-web/assets/{fetch-DvZuLuTE.js → fetch-TATpgXht.js} +1 -1
- package/dist-web/assets/{fetch-BxHdB6X1.js → fetch-dI5w8lYN.js} +1 -1
- package/dist-web/assets/{index-DXcFBsM1.js → index-Bs4ZX2-v.js} +1 -1
- package/dist-web/assets/index-CF59LLOG.js +25 -0
- package/dist-web/assets/{index-CLijvqy3.js → index-CJ3WtSLo.js} +1 -1
- package/dist-web/assets/{index-D7aKwT6w.js → index-CJS6FVuj.js} +3 -3
- package/dist-web/assets/{index-Cj2GU1SR.js → index-CY5yJhCJ.js} +1 -1
- package/dist-web/assets/{index-DaZnh1zP.js → index-DClxj4T2.js} +2 -2
- package/dist-web/assets/{index-BoalB6nB.js → index-De3ImZb9.js} +1 -1
- package/dist-web/assets/{index-CUzFFw5b.js → index-Dp3gCHpK.js} +1 -1
- package/dist-web/assets/{index-Bp5VKUF9.js → index-DphjBwbA.js} +1 -1
- package/dist-web/assets/{index-Bs15Yc7I.js → index-Dtbu8m1o.js} +1 -1
- package/dist-web/assets/{index-t6s0nOlb.js → index-a1ZrlsKo.js} +1 -1
- package/dist-web/assets/{index-BfGKlkx3.js → index-qZ7jnIna.js} +2 -2
- package/dist-web/assets/{index-WJCmqKnh.js → index-soX5gDgh.js} +1 -1
- package/dist-web/assets/{web-BoTDL3HM.js → web-H9T1dZys.js} +1 -1
- package/dist-web/assets/{webworkerAll-c0ZvpENM.js → webworkerAll-D1Kui8G8.js} +1 -1
- package/dist-web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-5G2INROS.mjs.map +0 -1
- package/dist/chunk-67HNEIKY.mjs.map +0 -1
- package/dist/chunk-SJQVAKFA.mjs.map +0 -1
- package/dist/chunk-XZ5FFDLX.mjs.map +0 -1
- package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DVdpZpfD.js +0 -110
- package/dist-web/assets/index-DeV8SAiM.js +0 -25
- /package/dist/{chat-command-V6NYTTPD.mjs.map → chat-command-QPL4GNHP.mjs.map} +0 -0
- /package/dist/{chunk-7TDYBU5L.mjs.map → chunk-3SZWD7UM.mjs.map} +0 -0
- /package/dist/{chunk-WL2ISRYH.mjs.map → chunk-64FKPYPJ.mjs.map} +0 -0
- /package/dist/{chunk-LWC7JQ2W.mjs.map → chunk-6JKKHPXY.mjs.map} +0 -0
- /package/dist/{chunk-ZF67S6RY.mjs.map → chunk-F2NZ7HAY.mjs.map} +0 -0
- /package/dist/{chunk-HUKZ2PBC.mjs.map → chunk-OAXVKNPN.mjs.map} +0 -0
- /package/dist/{chunk-54GVCXHZ.mjs.map → chunk-OQ6N4PDD.mjs.map} +0 -0
- /package/dist/{chunk-OIZ64ET3.mjs.map → chunk-ZCXCHKQV.mjs.map} +0 -0
- /package/dist/{http-AMDWRKOH.mjs.map → http-NOEWVWCP.mjs.map} +0 -0
- /package/dist/{import-WIJHB4LH.mjs.map → import-RS3HW7ZM.mjs.map} +0 -0
- /package/dist/{mcp-NC5YNTM5.mjs.map → mcp-7F3G47Z4.mjs.map} +0 -0
- /package/dist/{src-UY4GCVNF.mjs.map → src-MNH5S423.mjs.map} +0 -0
- /package/dist/{stream-import-JKQYRISL.mjs.map → stream-import-BPCHGRAN.mjs.map} +0 -0
- /package/dist/{worker-runtime-KKUOJJTN.mjs.map → worker-runtime-TTAXGQ5R.mjs.map} +0 -0
|
@@ -235,9 +235,72 @@ function parseValueByType(section, key, expectedType, rawValue) {
|
|
|
235
235
|
return rawValue;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
// ../../packages/config/src/
|
|
238
|
+
// ../../packages/config/src/auth-profiles.ts
|
|
239
239
|
import * as fs3 from "fs";
|
|
240
240
|
import * as path3 from "path";
|
|
241
|
+
var AUTH_PROFILES_FILE = "auth-profiles.json";
|
|
242
|
+
function getAuthProfilesPath() {
|
|
243
|
+
return path3.join(getConfigDir(), AUTH_PROFILES_FILE);
|
|
244
|
+
}
|
|
245
|
+
function loadAuthProfiles() {
|
|
246
|
+
const filePath = getAuthProfilesPath();
|
|
247
|
+
if (!fs3.existsSync(filePath)) {
|
|
248
|
+
return { version: 1, profiles: {} };
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
252
|
+
const data = JSON.parse(content);
|
|
253
|
+
if (!data.profiles || typeof data.profiles !== "object") {
|
|
254
|
+
return { version: 1, profiles: {} };
|
|
255
|
+
}
|
|
256
|
+
return data;
|
|
257
|
+
} catch {
|
|
258
|
+
return { version: 1, profiles: {} };
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function getApiKeyByProfile(profileName) {
|
|
262
|
+
const data = loadAuthProfiles();
|
|
263
|
+
const profile = data.profiles[profileName];
|
|
264
|
+
return profile?.key || "";
|
|
265
|
+
}
|
|
266
|
+
function getApiKeyByProvider(provider) {
|
|
267
|
+
const data = loadAuthProfiles();
|
|
268
|
+
for (const profile of Object.values(data.profiles)) {
|
|
269
|
+
if (profile.provider === provider) {
|
|
270
|
+
return profile.key || "";
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return "";
|
|
274
|
+
}
|
|
275
|
+
function resolveApiKey(provider, authProfile) {
|
|
276
|
+
if (authProfile) {
|
|
277
|
+
const key = getApiKeyByProfile(authProfile);
|
|
278
|
+
if (key) return key;
|
|
279
|
+
}
|
|
280
|
+
return getApiKeyByProvider(provider);
|
|
281
|
+
}
|
|
282
|
+
function writeAuthProfile(name, profile) {
|
|
283
|
+
const configDir = getConfigDir();
|
|
284
|
+
if (!fs3.existsSync(configDir)) {
|
|
285
|
+
fs3.mkdirSync(configDir, { recursive: true });
|
|
286
|
+
}
|
|
287
|
+
const data = loadAuthProfiles();
|
|
288
|
+
data.profiles[name] = profile;
|
|
289
|
+
const filePath = getAuthProfilesPath();
|
|
290
|
+
fs3.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: "utf-8", mode: 384 });
|
|
291
|
+
}
|
|
292
|
+
function deleteAuthProfile(name) {
|
|
293
|
+
const data = loadAuthProfiles();
|
|
294
|
+
if (!(name in data.profiles)) return false;
|
|
295
|
+
delete data.profiles[name];
|
|
296
|
+
const filePath = getAuthProfilesPath();
|
|
297
|
+
fs3.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: "utf-8", mode: 384 });
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ../../packages/config/src/migrations/runner.ts
|
|
302
|
+
import * as fs4 from "fs";
|
|
303
|
+
import * as path4 from "path";
|
|
241
304
|
var VERSION_FILE = ".migration-version";
|
|
242
305
|
var MigrationRunner = class {
|
|
243
306
|
migrations;
|
|
@@ -247,10 +310,10 @@ var MigrationRunner = class {
|
|
|
247
310
|
this.context = context;
|
|
248
311
|
}
|
|
249
312
|
getCurrentVersion() {
|
|
250
|
-
const versionPath =
|
|
313
|
+
const versionPath = path4.join(this.context.dataDir, VERSION_FILE);
|
|
251
314
|
try {
|
|
252
|
-
if (
|
|
253
|
-
const raw =
|
|
315
|
+
if (fs4.existsSync(versionPath)) {
|
|
316
|
+
const raw = fs4.readFileSync(versionPath, "utf-8").trim();
|
|
254
317
|
const ver = parseInt(raw, 10);
|
|
255
318
|
return Number.isFinite(ver) ? ver : 0;
|
|
256
319
|
}
|
|
@@ -259,12 +322,12 @@ var MigrationRunner = class {
|
|
|
259
322
|
return 0;
|
|
260
323
|
}
|
|
261
324
|
writeVersion(version) {
|
|
262
|
-
const versionPath =
|
|
325
|
+
const versionPath = path4.join(this.context.dataDir, VERSION_FILE);
|
|
263
326
|
try {
|
|
264
|
-
if (!
|
|
265
|
-
|
|
327
|
+
if (!fs4.existsSync(this.context.dataDir)) {
|
|
328
|
+
fs4.mkdirSync(this.context.dataDir, { recursive: true });
|
|
266
329
|
}
|
|
267
|
-
|
|
330
|
+
fs4.writeFileSync(versionPath, String(version), "utf-8");
|
|
268
331
|
} catch (err) {
|
|
269
332
|
this.context.logger.error("Migration", `Failed to write version file: ${err}`);
|
|
270
333
|
}
|
|
@@ -296,8 +359,8 @@ var MigrationRunner = class {
|
|
|
296
359
|
};
|
|
297
360
|
|
|
298
361
|
// ../../packages/config/src/migrations/m001-legacy-to-multi-config.ts
|
|
299
|
-
import * as
|
|
300
|
-
import * as
|
|
362
|
+
import * as fs5 from "fs";
|
|
363
|
+
import * as path5 from "path";
|
|
301
364
|
import { randomUUID } from "crypto";
|
|
302
365
|
function isLegacyFlatConfig(data) {
|
|
303
366
|
if (!data || typeof data !== "object") return false;
|
|
@@ -309,9 +372,9 @@ var m001LegacyToMultiConfig = {
|
|
|
309
372
|
name: "legacy-to-multi-config",
|
|
310
373
|
description: "Convert legacy flat LLM config to multi-config format",
|
|
311
374
|
async up(ctx) {
|
|
312
|
-
const configPath =
|
|
313
|
-
if (!
|
|
314
|
-
const raw =
|
|
375
|
+
const configPath = path5.join(ctx.aiDataDir, "llm-config.json");
|
|
376
|
+
if (!fs5.existsSync(configPath)) return;
|
|
377
|
+
const raw = fs5.readFileSync(configPath, "utf-8");
|
|
315
378
|
let data;
|
|
316
379
|
try {
|
|
317
380
|
data = JSON.parse(raw);
|
|
@@ -337,24 +400,24 @@ var m001LegacyToMultiConfig = {
|
|
|
337
400
|
defaultAssistant: { configId: newConfig.id, modelId: newConfig.model },
|
|
338
401
|
fastModel: null
|
|
339
402
|
};
|
|
340
|
-
|
|
403
|
+
fs5.writeFileSync(configPath, JSON.stringify(migrated, null, 2), "utf-8");
|
|
341
404
|
ctx.logger.info("Migration", "Legacy config migrated to multi-config format");
|
|
342
405
|
}
|
|
343
406
|
};
|
|
344
407
|
|
|
345
408
|
// ../../packages/config/src/migrations/m002-schema-v2.ts
|
|
346
|
-
import * as
|
|
347
|
-
import * as
|
|
409
|
+
import * as fs6 from "fs";
|
|
410
|
+
import * as path6 from "path";
|
|
348
411
|
var m002SchemaV2 = {
|
|
349
412
|
version: 2,
|
|
350
413
|
name: "schema-v2",
|
|
351
414
|
description: "Upgrade LLM config to schema v2 (remove deprecated fields)",
|
|
352
415
|
async up(ctx) {
|
|
353
|
-
const configPath =
|
|
354
|
-
if (!
|
|
416
|
+
const configPath = path6.join(ctx.aiDataDir, "llm-config.json");
|
|
417
|
+
if (!fs6.existsSync(configPath)) return;
|
|
355
418
|
let data;
|
|
356
419
|
try {
|
|
357
|
-
data = JSON.parse(
|
|
420
|
+
data = JSON.parse(fs6.readFileSync(configPath, "utf-8"));
|
|
358
421
|
} catch {
|
|
359
422
|
return;
|
|
360
423
|
}
|
|
@@ -368,23 +431,23 @@ var m002SchemaV2 = {
|
|
|
368
431
|
});
|
|
369
432
|
data.configs = cleanedConfigs;
|
|
370
433
|
data.schemaVersion = 2;
|
|
371
|
-
|
|
434
|
+
fs6.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf-8");
|
|
372
435
|
}
|
|
373
436
|
};
|
|
374
437
|
|
|
375
438
|
// ../../packages/config/src/migrations/m003-schema-v3.ts
|
|
376
|
-
import * as
|
|
377
|
-
import * as
|
|
439
|
+
import * as fs7 from "fs";
|
|
440
|
+
import * as path7 from "path";
|
|
378
441
|
var m003SchemaV3 = {
|
|
379
442
|
version: 3,
|
|
380
443
|
name: "schema-v3-dual-slot",
|
|
381
444
|
description: "Upgrade LLM config to schema v3 (dual-slot model selection)",
|
|
382
445
|
async up(ctx) {
|
|
383
|
-
const configPath =
|
|
384
|
-
if (!
|
|
446
|
+
const configPath = path7.join(ctx.aiDataDir, "llm-config.json");
|
|
447
|
+
if (!fs7.existsSync(configPath)) return;
|
|
385
448
|
let data;
|
|
386
449
|
try {
|
|
387
|
-
data = JSON.parse(
|
|
450
|
+
data = JSON.parse(fs7.readFileSync(configPath, "utf-8"));
|
|
388
451
|
} catch {
|
|
389
452
|
return;
|
|
390
453
|
}
|
|
@@ -398,7 +461,7 @@ var m003SchemaV3 = {
|
|
|
398
461
|
data.fastModel = data.fastModel ?? null;
|
|
399
462
|
data.schemaVersion = 3;
|
|
400
463
|
delete data.activeConfigId;
|
|
401
|
-
|
|
464
|
+
fs7.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf-8");
|
|
402
465
|
}
|
|
403
466
|
};
|
|
404
467
|
|
|
@@ -407,9 +470,9 @@ import * as fs9 from "fs";
|
|
|
407
470
|
import * as path9 from "path";
|
|
408
471
|
|
|
409
472
|
// ../../packages/config/src/migrations/crypto-legacy.ts
|
|
410
|
-
import * as
|
|
473
|
+
import * as fs8 from "fs";
|
|
411
474
|
import * as os2 from "os";
|
|
412
|
-
import * as
|
|
475
|
+
import * as path8 from "path";
|
|
413
476
|
import { createDecipheriv, createHash } from "crypto";
|
|
414
477
|
import { execSync } from "child_process";
|
|
415
478
|
var ENCRYPTED_PREFIX = "enc:";
|
|
@@ -421,8 +484,8 @@ function isEncrypted(value) {
|
|
|
421
484
|
}
|
|
422
485
|
function readKeyFromFile(keyPath) {
|
|
423
486
|
try {
|
|
424
|
-
if (
|
|
425
|
-
const key =
|
|
487
|
+
if (fs8.existsSync(keyPath)) {
|
|
488
|
+
const key = fs8.readFileSync(keyPath, "utf-8").trim();
|
|
426
489
|
if (key.length >= 32) return key;
|
|
427
490
|
}
|
|
428
491
|
} catch {
|
|
@@ -431,14 +494,14 @@ function readKeyFromFile(keyPath) {
|
|
|
431
494
|
}
|
|
432
495
|
function getAllDeviceKeyPaths() {
|
|
433
496
|
const home = os2.homedir();
|
|
434
|
-
const paths = [
|
|
497
|
+
const paths = [path8.join(home, ".chatlab", DEVICE_KEY_FILE)];
|
|
435
498
|
if (process.platform === "darwin") {
|
|
436
|
-
paths.push(
|
|
499
|
+
paths.push(path8.join(home, "Library", "Application Support", "ChatLab", "data", DEVICE_KEY_FILE));
|
|
437
500
|
} else if (process.platform === "win32") {
|
|
438
|
-
const appData = process.env.APPDATA ||
|
|
439
|
-
paths.push(
|
|
501
|
+
const appData = process.env.APPDATA || path8.join(home, "AppData", "Roaming");
|
|
502
|
+
paths.push(path8.join(appData, "ChatLab", "data", DEVICE_KEY_FILE));
|
|
440
503
|
} else {
|
|
441
|
-
paths.push(
|
|
504
|
+
paths.push(path8.join(home, ".config", "ChatLab", "data", DEVICE_KEY_FILE));
|
|
442
505
|
}
|
|
443
506
|
return paths;
|
|
444
507
|
}
|
|
@@ -519,69 +582,6 @@ function decryptApiKey(encrypted) {
|
|
|
519
582
|
return "";
|
|
520
583
|
}
|
|
521
584
|
|
|
522
|
-
// ../../packages/config/src/auth-profiles.ts
|
|
523
|
-
import * as fs8 from "fs";
|
|
524
|
-
import * as path8 from "path";
|
|
525
|
-
var AUTH_PROFILES_FILE = "auth-profiles.json";
|
|
526
|
-
function getAuthProfilesPath() {
|
|
527
|
-
return path8.join(getConfigDir(), AUTH_PROFILES_FILE);
|
|
528
|
-
}
|
|
529
|
-
function loadAuthProfiles() {
|
|
530
|
-
const filePath = getAuthProfilesPath();
|
|
531
|
-
if (!fs8.existsSync(filePath)) {
|
|
532
|
-
return { version: 1, profiles: {} };
|
|
533
|
-
}
|
|
534
|
-
try {
|
|
535
|
-
const content = fs8.readFileSync(filePath, "utf-8");
|
|
536
|
-
const data = JSON.parse(content);
|
|
537
|
-
if (!data.profiles || typeof data.profiles !== "object") {
|
|
538
|
-
return { version: 1, profiles: {} };
|
|
539
|
-
}
|
|
540
|
-
return data;
|
|
541
|
-
} catch {
|
|
542
|
-
return { version: 1, profiles: {} };
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
function getApiKeyByProfile(profileName) {
|
|
546
|
-
const data = loadAuthProfiles();
|
|
547
|
-
const profile = data.profiles[profileName];
|
|
548
|
-
return profile?.key || "";
|
|
549
|
-
}
|
|
550
|
-
function getApiKeyByProvider(provider) {
|
|
551
|
-
const data = loadAuthProfiles();
|
|
552
|
-
for (const profile of Object.values(data.profiles)) {
|
|
553
|
-
if (profile.provider === provider) {
|
|
554
|
-
return profile.key || "";
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return "";
|
|
558
|
-
}
|
|
559
|
-
function resolveApiKey(provider, authProfile) {
|
|
560
|
-
if (authProfile) {
|
|
561
|
-
const key = getApiKeyByProfile(authProfile);
|
|
562
|
-
if (key) return key;
|
|
563
|
-
}
|
|
564
|
-
return getApiKeyByProvider(provider);
|
|
565
|
-
}
|
|
566
|
-
function writeAuthProfile(name, profile) {
|
|
567
|
-
const configDir = getConfigDir();
|
|
568
|
-
if (!fs8.existsSync(configDir)) {
|
|
569
|
-
fs8.mkdirSync(configDir, { recursive: true });
|
|
570
|
-
}
|
|
571
|
-
const data = loadAuthProfiles();
|
|
572
|
-
data.profiles[name] = profile;
|
|
573
|
-
const filePath = getAuthProfilesPath();
|
|
574
|
-
fs8.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: "utf-8", mode: 384 });
|
|
575
|
-
}
|
|
576
|
-
function deleteAuthProfile(name) {
|
|
577
|
-
const data = loadAuthProfiles();
|
|
578
|
-
if (!(name in data.profiles)) return false;
|
|
579
|
-
delete data.profiles[name];
|
|
580
|
-
const filePath = getAuthProfilesPath();
|
|
581
|
-
fs8.writeFileSync(filePath, JSON.stringify(data, null, 2), { encoding: "utf-8", mode: 384 });
|
|
582
|
-
return true;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
585
|
// ../../packages/config/src/migrations/m004-encrypted-keys-to-auth-profiles.ts
|
|
586
586
|
function deriveProfileName(provider, config) {
|
|
587
587
|
if (provider !== "openai-compatible") {
|
|
@@ -4634,6 +4634,26 @@ function getMembers(db) {
|
|
|
4634
4634
|
ORDER BY messageCount DESC`
|
|
4635
4635
|
).all();
|
|
4636
4636
|
}
|
|
4637
|
+
function getMembersDetailed(db) {
|
|
4638
|
+
const rows = db.prepare(
|
|
4639
|
+
`SELECT
|
|
4640
|
+
m.id as id,
|
|
4641
|
+
m.platform_id as platformId,
|
|
4642
|
+
COALESCE(m.account_name, m.platform_id) as accountName,
|
|
4643
|
+
m.group_nickname as groupNickname,
|
|
4644
|
+
(SELECT COUNT(*) FROM message WHERE sender_id = m.id) as messageCount
|
|
4645
|
+
FROM member m
|
|
4646
|
+
WHERE COALESCE(m.account_name, '') != '\u7CFB\u7EDF\u6D88\u606F'
|
|
4647
|
+
ORDER BY messageCount DESC`
|
|
4648
|
+
).all();
|
|
4649
|
+
return rows.map((row) => ({
|
|
4650
|
+
id: Number(row.id),
|
|
4651
|
+
platformId: String(row.platformId),
|
|
4652
|
+
accountName: String(row.accountName || row.platformId),
|
|
4653
|
+
groupNickname: row.groupNickname ? String(row.groupNickname) : null,
|
|
4654
|
+
messageCount: Number(row.messageCount)
|
|
4655
|
+
}));
|
|
4656
|
+
}
|
|
4637
4657
|
function executeReadonlySql(db, sql, maxRows = 1e3) {
|
|
4638
4658
|
const result = executeSql(db, sql, { maxRows });
|
|
4639
4659
|
return {
|
|
@@ -5014,20 +5034,14 @@ function mergeMembers(db, memberId1, memberId2) {
|
|
|
5014
5034
|
return false;
|
|
5015
5035
|
}
|
|
5016
5036
|
}
|
|
5017
|
-
function deleteMembers(db, memberIds) {
|
|
5018
|
-
const uniqueMemberIds = Array.from(new Set(memberIds));
|
|
5019
|
-
if (uniqueMemberIds.length === 0) return false;
|
|
5020
|
-
const placeholders = uniqueMemberIds.map(() => "?").join(", ");
|
|
5021
|
-
db.transaction(() => {
|
|
5022
|
-
db.prepare(`DELETE FROM message WHERE sender_id IN (${placeholders})`).run(...uniqueMemberIds);
|
|
5023
|
-
db.prepare(`DELETE FROM member_name_history WHERE member_id IN (${placeholders})`).run(...uniqueMemberIds);
|
|
5024
|
-
db.prepare(`DELETE FROM member WHERE id IN (${placeholders})`).run(...uniqueMemberIds);
|
|
5025
|
-
});
|
|
5026
|
-
return true;
|
|
5027
|
-
}
|
|
5028
5037
|
function deleteMember(db, memberId) {
|
|
5029
5038
|
try {
|
|
5030
|
-
|
|
5039
|
+
db.transaction(() => {
|
|
5040
|
+
db.prepare("DELETE FROM message WHERE sender_id = ?").run(memberId);
|
|
5041
|
+
db.prepare("DELETE FROM member_name_history WHERE member_id = ?").run(memberId);
|
|
5042
|
+
db.prepare("DELETE FROM member WHERE id = ?").run(memberId);
|
|
5043
|
+
});
|
|
5044
|
+
return true;
|
|
5031
5045
|
} catch {
|
|
5032
5046
|
return false;
|
|
5033
5047
|
}
|
|
@@ -7942,15 +7956,15 @@ function tokenizeQueryForFts(keywords) {
|
|
|
7942
7956
|
import * as fs13 from "fs";
|
|
7943
7957
|
import * as os3 from "os";
|
|
7944
7958
|
import * as path13 from "path";
|
|
7945
|
-
var SYSTEM_SUBDIRS = ["ai", "settings", "cache", "logs", "nlp"];
|
|
7959
|
+
var SYSTEM_SUBDIRS = ["ai", "settings", "cache", "logs", "temp", "nlp"];
|
|
7946
7960
|
var STORAGE_CONFIG_FILE = "storage.json";
|
|
7947
|
-
function getElectronUserDataDir(
|
|
7948
|
-
const home =
|
|
7949
|
-
switch (
|
|
7961
|
+
function getElectronUserDataDir() {
|
|
7962
|
+
const home = os3.homedir();
|
|
7963
|
+
switch (process.platform) {
|
|
7950
7964
|
case "darwin":
|
|
7951
7965
|
return path13.join(home, "Library", "Application Support", "ChatLab");
|
|
7952
7966
|
case "win32": {
|
|
7953
|
-
const appData =
|
|
7967
|
+
const appData = process.env.APPDATA || path13.join(home, "AppData", "Roaming");
|
|
7954
7968
|
return path13.join(appData, "ChatLab");
|
|
7955
7969
|
}
|
|
7956
7970
|
default:
|
|
@@ -9269,6 +9283,7 @@ export {
|
|
|
9269
9283
|
searchMessagesLike,
|
|
9270
9284
|
searchMessagesByKeywords,
|
|
9271
9285
|
getMembers,
|
|
9286
|
+
getMembersDetailed,
|
|
9272
9287
|
executeReadonlySql,
|
|
9273
9288
|
executeSql,
|
|
9274
9289
|
getSchemaDetailed,
|
|
@@ -9282,7 +9297,6 @@ export {
|
|
|
9282
9297
|
computeResponseTimeStats,
|
|
9283
9298
|
updateMemberAliases,
|
|
9284
9299
|
mergeMembers,
|
|
9285
|
-
deleteMembers,
|
|
9286
9300
|
deleteMember,
|
|
9287
9301
|
getCatchphraseAnalysis,
|
|
9288
9302
|
getRelationshipStats,
|
|
@@ -9371,4 +9385,4 @@ export {
|
|
|
9371
9385
|
StaticPathProvider,
|
|
9372
9386
|
createDatabaseManagerAdapter
|
|
9373
9387
|
};
|
|
9374
|
-
//# sourceMappingURL=chunk-
|
|
9388
|
+
//# sourceMappingURL=chunk-IK7GJTGY.mjs.map
|