chatlab-cli 0.31.1 → 0.31.2-beta.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.
Files changed (129) hide show
  1. package/dist/{chat-command-MOETAGU5.mjs → chat-command-V6NYTTPD.mjs} +8 -8
  2. package/dist/{chunk-ZVWUR7ET.mjs → chunk-54GVCXHZ.mjs} +2 -2
  3. package/dist/{chunk-KCPGEILH.mjs → chunk-5G2INROS.mjs} +483 -356
  4. package/dist/chunk-5G2INROS.mjs.map +1 -0
  5. package/dist/{chunk-SZEBCNBB.mjs → chunk-67HNEIKY.mjs} +2084 -1924
  6. package/dist/chunk-67HNEIKY.mjs.map +1 -0
  7. package/dist/{chunk-VOVLPSG6.mjs → chunk-7TDYBU5L.mjs} +4 -4
  8. package/dist/{chunk-LJXSUN25.mjs → chunk-HUKZ2PBC.mjs} +2 -2
  9. package/dist/{chunk-3VMKS7PU.mjs → chunk-LWC7JQ2W.mjs} +2 -2
  10. package/dist/{chunk-N5AGDT7I.mjs → chunk-OIZ64ET3.mjs} +3 -3
  11. package/dist/{chunk-E6W2RURS.mjs → chunk-SJQVAKFA.mjs} +5 -4
  12. package/dist/chunk-SJQVAKFA.mjs.map +1 -0
  13. package/dist/{chunk-2IXPWPLR.mjs → chunk-WL2ISRYH.mjs} +11 -11
  14. package/dist/{chunk-DQ45LDKZ.mjs → chunk-XZ5FFDLX.mjs} +125 -136
  15. package/dist/chunk-XZ5FFDLX.mjs.map +1 -0
  16. package/dist/{chunk-7HBVGVOB.mjs → chunk-ZF67S6RY.mjs} +2 -2
  17. package/dist/cli.mjs +8 -8
  18. package/dist/contacts-worker.mjs +2 -2
  19. package/dist/global-insight-worker.mjs +1 -1
  20. package/dist/{http-M6NHWJZD.mjs → http-AMDWRKOH.mjs} +11 -11
  21. package/dist/{import-SEYHFXS5.mjs → import-WIJHB4LH.mjs} +7 -7
  22. package/dist/index.mjs +11 -11
  23. package/dist/{mcp-MIPFYRLV.mjs → mcp-NC5YNTM5.mjs} +8 -8
  24. package/dist/people-relationships-worker.mjs +2 -2
  25. package/dist/semantic-index-worker.mjs +1 -1
  26. package/dist/{src-7OD6RD5V.mjs → src-UY4GCVNF.mjs} +22 -6
  27. package/dist/{stream-import-AWEHGQJY.mjs → stream-import-JKQYRISL.mjs} +7 -7
  28. package/dist/{worker-runtime-TGYMASIE.mjs → worker-runtime-KKUOJJTN.mjs} +5 -5
  29. package/dist-web/assets/{ActionToolsPanel-fAio70bI.css → ActionToolsPanel-BL0GQR6r.css} +1 -1
  30. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DVdpZpfD.js +110 -0
  31. package/dist-web/assets/{BufferResource-CHI62pIA.js → BufferResource-i1amDJTV.js} +1 -1
  32. package/dist-web/assets/{CanvasRenderer-OZRoiF0j.js → CanvasRenderer-DGa7AjdC.js} +1 -1
  33. package/dist-web/assets/EChartWordcloud-BXC_4nUP.js +1 -0
  34. package/dist-web/assets/{Filter-DNb5VErW.js → Filter-BTlq0yU-.js} +1 -1
  35. package/dist-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-B2KAoiMG.js +1 -0
  36. package/dist-web/assets/MessageExportModal-D9C5t_zF.js +1 -0
  37. package/dist-web/assets/PageHeader-BEWr2vsg.js +1 -0
  38. package/dist-web/assets/{RelationshipGalaxyCanvas-ioRNObb5.js → RelationshipGalaxyCanvas-CSgPNRif.js} +4 -4
  39. package/dist-web/assets/{RelationshipGalaxyThreeCanvas-L1Y43p1A.js → RelationshipGalaxyThreeCanvas-CBAnU8vN.js} +1 -1
  40. package/dist-web/assets/{RenderTargetSystem-fJ7D7Chv.js → RenderTargetSystem-Ctlu222X.js} +1 -1
  41. package/dist-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-BWJ6kuSC.js +1 -0
  42. package/dist-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-D5vov0eO.js +1 -0
  43. package/dist-web/assets/{WebGLRenderer-BD3ZUtxH.js → WebGLRenderer-D2Zvhmcw.js} +1 -1
  44. package/dist-web/assets/{WebGPURenderer-DZXYsT6D.js → WebGPURenderer-BOtP6h9o.js} +1 -1
  45. package/dist-web/assets/annual-summary-time-range-CK0IIPsY.js +1 -0
  46. package/dist-web/assets/{base-DTElkJcC.js → base-BMjDSaj6.js} +1 -1
  47. package/dist-web/assets/{browserAll-ChT6N6a9.js → browserAll-BhwLvWQY.js} +1 -1
  48. package/dist-web/assets/dateFormat-dteP1INW.js +1 -0
  49. package/dist-web/assets/{electron-CIzyGxH_.js → electron-DCgfulPE.js} +1 -1
  50. package/dist-web/assets/{fetch-CuiQUcO_.js → fetch-6q7oz7ZO.js} +1 -1
  51. package/dist-web/assets/{fetch-Avtnh8cJ.js → fetch-B_0HIxs5.js} +1 -1
  52. package/dist-web/assets/{fetch-DnGx-1_t.js → fetch-BbU4MPPu.js} +1 -1
  53. package/dist-web/assets/{fetch-Dd6t3p1r.js → fetch-BxHdB6X1.js} +1 -1
  54. package/dist-web/assets/{fetch-qC7om4QG.js → fetch-CpvfCafG.js} +1 -1
  55. package/dist-web/assets/{fetch-wSSfDBdV.js → fetch-CubnKpLG.js} +1 -1
  56. package/dist-web/assets/{fetch-CyKILLnB.js → fetch-D5BrGna5.js} +1 -1
  57. package/dist-web/assets/{fetch-C9rx2isC.js → fetch-DgXWr9nB.js} +1 -1
  58. package/dist-web/assets/{fetch-Ccq_0ecb.js → fetch-DvZuLuTE.js} +1 -1
  59. package/dist-web/assets/{fetch-BFnrBahy.js → fetch-rJA9qLvd.js} +1 -1
  60. package/dist-web/assets/index-BfGKlkx3.js +2 -0
  61. package/dist-web/assets/index-BoalB6nB.js +1 -0
  62. package/dist-web/assets/index-Bp5VKUF9.js +1 -0
  63. package/dist-web/assets/index-Bs15Yc7I.js +1 -0
  64. package/dist-web/assets/index-CAjUCtGD.css +1 -0
  65. package/dist-web/assets/index-CLijvqy3.js +173 -0
  66. package/dist-web/assets/{index-DXHYzIIj.js → index-CUzFFw5b.js} +1 -1
  67. package/dist-web/assets/index-Cj2GU1SR.js +1 -0
  68. package/dist-web/assets/{index-y7cxH1Et.css → index-CsqMIyA9.css} +1 -1
  69. package/dist-web/assets/index-CtmXho1w.css +1 -0
  70. package/dist-web/assets/index-D7aKwT6w.js +64 -0
  71. package/dist-web/assets/index-DXcFBsM1.js +24 -0
  72. package/dist-web/assets/index-DaZnh1zP.js +2 -0
  73. package/dist-web/assets/index-DeV8SAiM.js +25 -0
  74. package/dist-web/assets/index-WJCmqKnh.js +1 -0
  75. package/dist-web/assets/index-t6s0nOlb.js +1 -0
  76. package/dist-web/assets/people-page-header-D93GTPBO.js +1 -0
  77. package/dist-web/assets/vendor-nuxt-ui-DUpPmItD.js +15 -0
  78. package/dist-web/assets/vendor-reka-ui-BLnO2MqY.js +15 -0
  79. package/dist-web/assets/vendor-snapdom--nZvo8Sg.js +8 -0
  80. package/dist-web/assets/web-BoTDL3HM.js +1 -0
  81. package/dist-web/assets/{webworkerAll-C3dAOQj4.js → webworkerAll-c0ZvpENM.js} +1 -1
  82. package/dist-web/index.html +5 -5
  83. package/package.json +1 -1
  84. package/dist/chunk-DQ45LDKZ.mjs.map +0 -1
  85. package/dist/chunk-E6W2RURS.mjs.map +0 -1
  86. package/dist/chunk-KCPGEILH.mjs.map +0 -1
  87. package/dist/chunk-SZEBCNBB.mjs.map +0 -1
  88. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CkDGVRXe.js +0 -110
  89. package/dist-web/assets/EChartWordcloud-DU3ZYdgz.js +0 -1
  90. package/dist-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-DACMroOe.js +0 -1
  91. package/dist-web/assets/MessageExportModal-CqP-w7HP.js +0 -1
  92. package/dist-web/assets/PageHeader-Ck8ULyZH.js +0 -1
  93. package/dist-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-BoZyssJF.js +0 -1
  94. package/dist-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-7SEaCxDL.js +0 -1
  95. package/dist-web/assets/annual-summary-time-range-DVLXK1r4.js +0 -1
  96. package/dist-web/assets/dateFormat-D9WibwOu.js +0 -1
  97. package/dist-web/assets/index-BH9jI5kV.js +0 -173
  98. package/dist-web/assets/index-BWtNqcYK.js +0 -22
  99. package/dist-web/assets/index-Bkq7-GBp.js +0 -1
  100. package/dist-web/assets/index-Bqr-LkS1.css +0 -1
  101. package/dist-web/assets/index-C6qtsaP7.js +0 -1
  102. package/dist-web/assets/index-C_0GHEcb.css +0 -1
  103. package/dist-web/assets/index-ChFGuu70.js +0 -1
  104. package/dist-web/assets/index-CiS20iAR.js +0 -24
  105. package/dist-web/assets/index-CqD6u57u.js +0 -1
  106. package/dist-web/assets/index-CzDG8LVr.js +0 -2
  107. package/dist-web/assets/index-D0Euk-vQ.js +0 -1
  108. package/dist-web/assets/index-D26BWhHz.js +0 -1
  109. package/dist-web/assets/index-Dq8u7gMb.js +0 -2
  110. package/dist-web/assets/index-u_UH6rDY.js +0 -64
  111. package/dist-web/assets/people-page-header-BdKM1qhX.js +0 -1
  112. package/dist-web/assets/vendor-nuxt-ui-CS1uxE9C.js +0 -15
  113. package/dist-web/assets/vendor-reka-ui-Cta6JPvN.js +0 -11
  114. package/dist-web/assets/vendor-snapdom-XnBoh1gd.js +0 -8
  115. package/dist-web/assets/web-BDBdpdK7.js +0 -1
  116. /package/dist/{chat-command-MOETAGU5.mjs.map → chat-command-V6NYTTPD.mjs.map} +0 -0
  117. /package/dist/{chunk-ZVWUR7ET.mjs.map → chunk-54GVCXHZ.mjs.map} +0 -0
  118. /package/dist/{chunk-VOVLPSG6.mjs.map → chunk-7TDYBU5L.mjs.map} +0 -0
  119. /package/dist/{chunk-LJXSUN25.mjs.map → chunk-HUKZ2PBC.mjs.map} +0 -0
  120. /package/dist/{chunk-3VMKS7PU.mjs.map → chunk-LWC7JQ2W.mjs.map} +0 -0
  121. /package/dist/{chunk-N5AGDT7I.mjs.map → chunk-OIZ64ET3.mjs.map} +0 -0
  122. /package/dist/{chunk-2IXPWPLR.mjs.map → chunk-WL2ISRYH.mjs.map} +0 -0
  123. /package/dist/{chunk-7HBVGVOB.mjs.map → chunk-ZF67S6RY.mjs.map} +0 -0
  124. /package/dist/{http-M6NHWJZD.mjs.map → http-AMDWRKOH.mjs.map} +0 -0
  125. /package/dist/{import-SEYHFXS5.mjs.map → import-WIJHB4LH.mjs.map} +0 -0
  126. /package/dist/{mcp-MIPFYRLV.mjs.map → mcp-NC5YNTM5.mjs.map} +0 -0
  127. /package/dist/{src-7OD6RD5V.mjs.map → src-UY4GCVNF.mjs.map} +0 -0
  128. /package/dist/{stream-import-AWEHGQJY.mjs.map → stream-import-JKQYRISL.mjs.map} +0 -0
  129. /package/dist/{worker-runtime-TGYMASIE.mjs.map → worker-runtime-KKUOJJTN.mjs.map} +0 -0
@@ -235,72 +235,9 @@ function parseValueByType(section, key, expectedType, rawValue) {
235
235
  return rawValue;
236
236
  }
237
237
 
238
- // ../../packages/config/src/auth-profiles.ts
238
+ // ../../packages/config/src/migrations/runner.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";
304
241
  var VERSION_FILE = ".migration-version";
305
242
  var MigrationRunner = class {
306
243
  migrations;
@@ -310,10 +247,10 @@ var MigrationRunner = class {
310
247
  this.context = context;
311
248
  }
312
249
  getCurrentVersion() {
313
- const versionPath = path4.join(this.context.dataDir, VERSION_FILE);
250
+ const versionPath = path3.join(this.context.dataDir, VERSION_FILE);
314
251
  try {
315
- if (fs4.existsSync(versionPath)) {
316
- const raw = fs4.readFileSync(versionPath, "utf-8").trim();
252
+ if (fs3.existsSync(versionPath)) {
253
+ const raw = fs3.readFileSync(versionPath, "utf-8").trim();
317
254
  const ver = parseInt(raw, 10);
318
255
  return Number.isFinite(ver) ? ver : 0;
319
256
  }
@@ -322,12 +259,12 @@ var MigrationRunner = class {
322
259
  return 0;
323
260
  }
324
261
  writeVersion(version) {
325
- const versionPath = path4.join(this.context.dataDir, VERSION_FILE);
262
+ const versionPath = path3.join(this.context.dataDir, VERSION_FILE);
326
263
  try {
327
- if (!fs4.existsSync(this.context.dataDir)) {
328
- fs4.mkdirSync(this.context.dataDir, { recursive: true });
264
+ if (!fs3.existsSync(this.context.dataDir)) {
265
+ fs3.mkdirSync(this.context.dataDir, { recursive: true });
329
266
  }
330
- fs4.writeFileSync(versionPath, String(version), "utf-8");
267
+ fs3.writeFileSync(versionPath, String(version), "utf-8");
331
268
  } catch (err) {
332
269
  this.context.logger.error("Migration", `Failed to write version file: ${err}`);
333
270
  }
@@ -359,8 +296,8 @@ var MigrationRunner = class {
359
296
  };
360
297
 
361
298
  // ../../packages/config/src/migrations/m001-legacy-to-multi-config.ts
362
- import * as fs5 from "fs";
363
- import * as path5 from "path";
299
+ import * as fs4 from "fs";
300
+ import * as path4 from "path";
364
301
  import { randomUUID } from "crypto";
365
302
  function isLegacyFlatConfig(data) {
366
303
  if (!data || typeof data !== "object") return false;
@@ -372,9 +309,9 @@ var m001LegacyToMultiConfig = {
372
309
  name: "legacy-to-multi-config",
373
310
  description: "Convert legacy flat LLM config to multi-config format",
374
311
  async up(ctx) {
375
- const configPath = path5.join(ctx.aiDataDir, "llm-config.json");
376
- if (!fs5.existsSync(configPath)) return;
377
- const raw = fs5.readFileSync(configPath, "utf-8");
312
+ const configPath = path4.join(ctx.aiDataDir, "llm-config.json");
313
+ if (!fs4.existsSync(configPath)) return;
314
+ const raw = fs4.readFileSync(configPath, "utf-8");
378
315
  let data;
379
316
  try {
380
317
  data = JSON.parse(raw);
@@ -400,24 +337,24 @@ var m001LegacyToMultiConfig = {
400
337
  defaultAssistant: { configId: newConfig.id, modelId: newConfig.model },
401
338
  fastModel: null
402
339
  };
403
- fs5.writeFileSync(configPath, JSON.stringify(migrated, null, 2), "utf-8");
340
+ fs4.writeFileSync(configPath, JSON.stringify(migrated, null, 2), "utf-8");
404
341
  ctx.logger.info("Migration", "Legacy config migrated to multi-config format");
405
342
  }
406
343
  };
407
344
 
408
345
  // ../../packages/config/src/migrations/m002-schema-v2.ts
409
- import * as fs6 from "fs";
410
- import * as path6 from "path";
346
+ import * as fs5 from "fs";
347
+ import * as path5 from "path";
411
348
  var m002SchemaV2 = {
412
349
  version: 2,
413
350
  name: "schema-v2",
414
351
  description: "Upgrade LLM config to schema v2 (remove deprecated fields)",
415
352
  async up(ctx) {
416
- const configPath = path6.join(ctx.aiDataDir, "llm-config.json");
417
- if (!fs6.existsSync(configPath)) return;
353
+ const configPath = path5.join(ctx.aiDataDir, "llm-config.json");
354
+ if (!fs5.existsSync(configPath)) return;
418
355
  let data;
419
356
  try {
420
- data = JSON.parse(fs6.readFileSync(configPath, "utf-8"));
357
+ data = JSON.parse(fs5.readFileSync(configPath, "utf-8"));
421
358
  } catch {
422
359
  return;
423
360
  }
@@ -431,23 +368,23 @@ var m002SchemaV2 = {
431
368
  });
432
369
  data.configs = cleanedConfigs;
433
370
  data.schemaVersion = 2;
434
- fs6.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf-8");
371
+ fs5.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf-8");
435
372
  }
436
373
  };
437
374
 
438
375
  // ../../packages/config/src/migrations/m003-schema-v3.ts
439
- import * as fs7 from "fs";
440
- import * as path7 from "path";
376
+ import * as fs6 from "fs";
377
+ import * as path6 from "path";
441
378
  var m003SchemaV3 = {
442
379
  version: 3,
443
380
  name: "schema-v3-dual-slot",
444
381
  description: "Upgrade LLM config to schema v3 (dual-slot model selection)",
445
382
  async up(ctx) {
446
- const configPath = path7.join(ctx.aiDataDir, "llm-config.json");
447
- if (!fs7.existsSync(configPath)) return;
383
+ const configPath = path6.join(ctx.aiDataDir, "llm-config.json");
384
+ if (!fs6.existsSync(configPath)) return;
448
385
  let data;
449
386
  try {
450
- data = JSON.parse(fs7.readFileSync(configPath, "utf-8"));
387
+ data = JSON.parse(fs6.readFileSync(configPath, "utf-8"));
451
388
  } catch {
452
389
  return;
453
390
  }
@@ -461,7 +398,7 @@ var m003SchemaV3 = {
461
398
  data.fastModel = data.fastModel ?? null;
462
399
  data.schemaVersion = 3;
463
400
  delete data.activeConfigId;
464
- fs7.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf-8");
401
+ fs6.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf-8");
465
402
  }
466
403
  };
467
404
 
@@ -470,9 +407,9 @@ import * as fs9 from "fs";
470
407
  import * as path9 from "path";
471
408
 
472
409
  // ../../packages/config/src/migrations/crypto-legacy.ts
473
- import * as fs8 from "fs";
410
+ import * as fs7 from "fs";
474
411
  import * as os2 from "os";
475
- import * as path8 from "path";
412
+ import * as path7 from "path";
476
413
  import { createDecipheriv, createHash } from "crypto";
477
414
  import { execSync } from "child_process";
478
415
  var ENCRYPTED_PREFIX = "enc:";
@@ -484,8 +421,8 @@ function isEncrypted(value) {
484
421
  }
485
422
  function readKeyFromFile(keyPath) {
486
423
  try {
487
- if (fs8.existsSync(keyPath)) {
488
- const key = fs8.readFileSync(keyPath, "utf-8").trim();
424
+ if (fs7.existsSync(keyPath)) {
425
+ const key = fs7.readFileSync(keyPath, "utf-8").trim();
489
426
  if (key.length >= 32) return key;
490
427
  }
491
428
  } catch {
@@ -494,14 +431,14 @@ function readKeyFromFile(keyPath) {
494
431
  }
495
432
  function getAllDeviceKeyPaths() {
496
433
  const home = os2.homedir();
497
- const paths = [path8.join(home, ".chatlab", DEVICE_KEY_FILE)];
434
+ const paths = [path7.join(home, ".chatlab", DEVICE_KEY_FILE)];
498
435
  if (process.platform === "darwin") {
499
- paths.push(path8.join(home, "Library", "Application Support", "ChatLab", "data", DEVICE_KEY_FILE));
436
+ paths.push(path7.join(home, "Library", "Application Support", "ChatLab", "data", DEVICE_KEY_FILE));
500
437
  } else if (process.platform === "win32") {
501
- const appData = process.env.APPDATA || path8.join(home, "AppData", "Roaming");
502
- paths.push(path8.join(appData, "ChatLab", "data", DEVICE_KEY_FILE));
438
+ const appData = process.env.APPDATA || path7.join(home, "AppData", "Roaming");
439
+ paths.push(path7.join(appData, "ChatLab", "data", DEVICE_KEY_FILE));
503
440
  } else {
504
- paths.push(path8.join(home, ".config", "ChatLab", "data", DEVICE_KEY_FILE));
441
+ paths.push(path7.join(home, ".config", "ChatLab", "data", DEVICE_KEY_FILE));
505
442
  }
506
443
  return paths;
507
444
  }
@@ -582,6 +519,69 @@ function decryptApiKey(encrypted) {
582
519
  return "";
583
520
  }
584
521
 
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,26 +4634,6 @@ 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
- }
4657
4637
  function executeReadonlySql(db, sql, maxRows = 1e3) {
4658
4638
  const result = executeSql(db, sql, { maxRows });
4659
4639
  return {
@@ -4858,11 +4838,12 @@ function getMembersWithAliases(db) {
4858
4838
  m.id, m.platform_id as platformId,
4859
4839
  m.account_name as accountName, m.group_nickname as groupNickname,
4860
4840
  ${aliasesSelect}, ${avatarSelect},
4861
- COUNT(msg.id) as messageCount
4841
+ COUNT(msg.id) as messageCount,
4842
+ MAX(msg.ts) as lastMessageTs
4862
4843
  FROM member m
4863
4844
  LEFT JOIN message msg ON m.id = msg.sender_id
4864
4845
  WHERE COALESCE(m.group_nickname, m.account_name, m.platform_id) != '\u7CFB\u7EDF\u6D88\u606F'
4865
- GROUP BY m.id ORDER BY messageCount DESC`
4846
+ GROUP BY m.id ORDER BY messageCount DESC, m.id ASC`
4866
4847
  ).all();
4867
4848
  return rows.map(mapMemberRow);
4868
4849
  }
@@ -4904,12 +4885,13 @@ function getMembersPaginated(db, params) {
4904
4885
  m.id, m.platform_id as platformId,
4905
4886
  m.account_name as accountName, m.group_nickname as groupNickname,
4906
4887
  ${aliasesSelect}, ${avatarSelect},
4907
- COUNT(msg.id) as messageCount
4888
+ COUNT(msg.id) as messageCount,
4889
+ MAX(msg.ts) as lastMessageTs
4908
4890
  FROM member m
4909
4891
  LEFT JOIN message msg ON m.id = msg.sender_id
4910
4892
  WHERE ${systemFilter} ${searchClause}
4911
4893
  GROUP BY m.id
4912
- ORDER BY messageCount ${sortDirection}
4894
+ ORDER BY messageCount ${sortDirection}, m.id ASC
4913
4895
  LIMIT ? OFFSET ?`
4914
4896
  ).all(...searchParams, pageSize, offset);
4915
4897
  return { members: rows.map(mapMemberRow), total, page, pageSize, totalPages };
@@ -4922,7 +4904,8 @@ function mapMemberRow(row) {
4922
4904
  groupNickname: row.groupNickname,
4923
4905
  aliases: row.aliases ? JSON.parse(row.aliases) : [],
4924
4906
  avatar: row.avatar ?? null,
4925
- messageCount: row.messageCount
4907
+ messageCount: row.messageCount,
4908
+ lastMessageTs: row.lastMessageTs == null ? null : Number(row.lastMessageTs)
4926
4909
  };
4927
4910
  }
4928
4911
  function executeParameterizedSql(db, query, params = {}) {
@@ -5031,14 +5014,20 @@ function mergeMembers(db, memberId1, memberId2) {
5031
5014
  return false;
5032
5015
  }
5033
5016
  }
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
+ }
5034
5028
  function deleteMember(db, memberId) {
5035
5029
  try {
5036
- db.transaction(() => {
5037
- db.prepare("DELETE FROM message WHERE sender_id = ?").run(memberId);
5038
- db.prepare("DELETE FROM member_name_history WHERE member_id = ?").run(memberId);
5039
- db.prepare("DELETE FROM member WHERE id = ?").run(memberId);
5040
- });
5041
- return true;
5030
+ return deleteMembers(db, [memberId]);
5042
5031
  } catch {
5043
5032
  return false;
5044
5033
  }
@@ -7953,15 +7942,15 @@ function tokenizeQueryForFts(keywords) {
7953
7942
  import * as fs13 from "fs";
7954
7943
  import * as os3 from "os";
7955
7944
  import * as path13 from "path";
7956
- var SYSTEM_SUBDIRS = ["ai", "settings", "cache", "logs", "temp", "nlp"];
7945
+ var SYSTEM_SUBDIRS = ["ai", "settings", "cache", "logs", "nlp"];
7957
7946
  var STORAGE_CONFIG_FILE = "storage.json";
7958
- function getElectronUserDataDir() {
7959
- const home = os3.homedir();
7960
- switch (process.platform) {
7947
+ function getElectronUserDataDir(options = {}) {
7948
+ const home = options.homeDir ?? os3.homedir();
7949
+ switch (options.platform ?? process.platform) {
7961
7950
  case "darwin":
7962
7951
  return path13.join(home, "Library", "Application Support", "ChatLab");
7963
7952
  case "win32": {
7964
- const appData = process.env.APPDATA || path13.join(home, "AppData", "Roaming");
7953
+ const appData = options.appDataDir ?? process.env.APPDATA ?? path13.join(home, "AppData", "Roaming");
7965
7954
  return path13.join(appData, "ChatLab");
7966
7955
  }
7967
7956
  default:
@@ -9280,7 +9269,6 @@ export {
9280
9269
  searchMessagesLike,
9281
9270
  searchMessagesByKeywords,
9282
9271
  getMembers,
9283
- getMembersDetailed,
9284
9272
  executeReadonlySql,
9285
9273
  executeSql,
9286
9274
  getSchemaDetailed,
@@ -9294,6 +9282,7 @@ export {
9294
9282
  computeResponseTimeStats,
9295
9283
  updateMemberAliases,
9296
9284
  mergeMembers,
9285
+ deleteMembers,
9297
9286
  deleteMember,
9298
9287
  getCatchphraseAnalysis,
9299
9288
  getRelationshipStats,
@@ -9382,4 +9371,4 @@ export {
9382
9371
  StaticPathProvider,
9383
9372
  createDatabaseManagerAdapter
9384
9373
  };
9385
- //# sourceMappingURL=chunk-DQ45LDKZ.mjs.map
9374
+ //# sourceMappingURL=chunk-XZ5FFDLX.mjs.map