chatlab-cli 0.31.0 → 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 (135) hide show
  1. package/dist/{chat-command-CHV7RLBH.mjs → chat-command-V6NYTTPD.mjs} +8 -8
  2. package/dist/{chunk-DA5T64RY.mjs → chunk-54GVCXHZ.mjs} +2 -2
  3. package/dist/{chunk-T64GA5HP.mjs → chunk-5G2INROS.mjs} +867 -537
  4. package/dist/chunk-5G2INROS.mjs.map +1 -0
  5. package/dist/{chunk-JH5RAJT2.mjs → chunk-67HNEIKY.mjs} +2083 -1858
  6. package/dist/chunk-67HNEIKY.mjs.map +1 -0
  7. package/dist/{chunk-RD335EMA.mjs → chunk-7TDYBU5L.mjs} +29 -52
  8. package/dist/chunk-7TDYBU5L.mjs.map +1 -0
  9. package/dist/{chunk-RDCUGC24.mjs → chunk-HUKZ2PBC.mjs} +2 -2
  10. package/dist/{chunk-YPQ72HMX.mjs → chunk-LWC7JQ2W.mjs} +44 -5
  11. package/dist/chunk-LWC7JQ2W.mjs.map +1 -0
  12. package/dist/{chunk-EXD2SXWL.mjs → chunk-OIZ64ET3.mjs} +40 -7
  13. package/dist/chunk-OIZ64ET3.mjs.map +1 -0
  14. package/dist/{chunk-WQCY45U2.mjs → chunk-SJQVAKFA.mjs} +5 -4
  15. package/dist/chunk-SJQVAKFA.mjs.map +1 -0
  16. package/dist/{chunk-DBBL74RK.mjs → chunk-WL2ISRYH.mjs} +164 -82
  17. package/dist/chunk-WL2ISRYH.mjs.map +1 -0
  18. package/dist/{chunk-UWWFOEGF.mjs → chunk-XZ5FFDLX.mjs} +143 -137
  19. package/dist/chunk-XZ5FFDLX.mjs.map +1 -0
  20. package/dist/{chunk-SNCXU2QL.mjs → chunk-ZF67S6RY.mjs} +2 -2
  21. package/dist/cli.mjs +9 -7
  22. package/dist/contacts-worker.mjs +2 -2
  23. package/dist/global-insight-worker.mjs +1 -1
  24. package/dist/{http-3B5ARN7A.mjs → http-AMDWRKOH.mjs} +11 -11
  25. package/dist/{import-2DZGNSEX.mjs → import-WIJHB4LH.mjs} +9 -7
  26. package/dist/index.mjs +12 -12
  27. package/dist/{mcp-44I6FUUQ.mjs → mcp-NC5YNTM5.mjs} +8 -8
  28. package/dist/people-relationships-worker.mjs +2 -2
  29. package/dist/semantic-index-worker.mjs +1 -1
  30. package/dist/{src-R3QX6L3L.mjs → src-UY4GCVNF.mjs} +34 -6
  31. package/dist/{stream-import-VUEL2TTU.mjs → stream-import-JKQYRISL.mjs} +9 -7
  32. package/dist/{worker-runtime-GJAOIIZW.mjs → worker-runtime-KKUOJJTN.mjs} +5 -5
  33. package/dist-web/assets/{ActionToolsPanel-fAio70bI.css → ActionToolsPanel-BL0GQR6r.css} +1 -1
  34. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DVdpZpfD.js +110 -0
  35. package/dist-web/assets/{BufferResource-BPGkshPa.js → BufferResource-i1amDJTV.js} +1 -1
  36. package/dist-web/assets/{CanvasRenderer-DTKkZhq4.js → CanvasRenderer-DGa7AjdC.js} +1 -1
  37. package/dist-web/assets/EChartWordcloud-BXC_4nUP.js +1 -0
  38. package/dist-web/assets/{Filter-CHXKzS2l.js → Filter-BTlq0yU-.js} +1 -1
  39. package/dist-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-B2KAoiMG.js +1 -0
  40. package/dist-web/assets/MessageExportModal-D9C5t_zF.js +1 -0
  41. package/dist-web/assets/PageHeader-BEWr2vsg.js +1 -0
  42. package/dist-web/assets/{RelationshipGalaxyCanvas-Dwdy5flh.js → RelationshipGalaxyCanvas-CSgPNRif.js} +4 -4
  43. package/dist-web/assets/{RelationshipGalaxyThreeCanvas-CtY4TGen.js → RelationshipGalaxyThreeCanvas-CBAnU8vN.js} +1 -1
  44. package/dist-web/assets/{RenderTargetSystem-BE56mKRG.js → RenderTargetSystem-Ctlu222X.js} +1 -1
  45. package/dist-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-BWJ6kuSC.js +1 -0
  46. package/dist-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-D5vov0eO.js +1 -0
  47. package/dist-web/assets/{WebGLRenderer-Dm18dxOf.js → WebGLRenderer-D2Zvhmcw.js} +1 -1
  48. package/dist-web/assets/{WebGPURenderer-BF6TF-is.js → WebGPURenderer-BOtP6h9o.js} +1 -1
  49. package/dist-web/assets/annual-summary-time-range-CK0IIPsY.js +1 -0
  50. package/dist-web/assets/{base-CFPyD9Gy.js → base-BMjDSaj6.js} +1 -1
  51. package/dist-web/assets/{browserAll-Cn_CfkXl.js → browserAll-BhwLvWQY.js} +1 -1
  52. package/dist-web/assets/dateFormat-dteP1INW.js +1 -0
  53. package/dist-web/assets/{electron-B6xOabTq.js → electron-DCgfulPE.js} +1 -1
  54. package/dist-web/assets/{fetch-DMLq3xPG.js → fetch-6q7oz7ZO.js} +1 -1
  55. package/dist-web/assets/{fetch-C_EfVFJi.js → fetch-B_0HIxs5.js} +1 -1
  56. package/dist-web/assets/{fetch-DylpNKCR.js → fetch-BbU4MPPu.js} +1 -1
  57. package/dist-web/assets/fetch-BxHdB6X1.js +6 -0
  58. package/dist-web/assets/{fetch-CEhUu1Yu.js → fetch-CpvfCafG.js} +1 -1
  59. package/dist-web/assets/{fetch-etgwVKIw.js → fetch-CubnKpLG.js} +1 -1
  60. package/dist-web/assets/{fetch-BRXmDI_2.js → fetch-D5BrGna5.js} +1 -1
  61. package/dist-web/assets/fetch-DgXWr9nB.js +31 -0
  62. package/dist-web/assets/{fetch-BPkgnY0R.js → fetch-DvZuLuTE.js} +1 -1
  63. package/dist-web/assets/{fetch-DL_u25Ui.js → fetch-rJA9qLvd.js} +1 -1
  64. package/dist-web/assets/index-BfGKlkx3.js +2 -0
  65. package/dist-web/assets/index-BoalB6nB.js +1 -0
  66. package/dist-web/assets/index-Bp5VKUF9.js +1 -0
  67. package/dist-web/assets/index-Bs15Yc7I.js +1 -0
  68. package/dist-web/assets/index-CAjUCtGD.css +1 -0
  69. package/dist-web/assets/index-CLijvqy3.js +173 -0
  70. package/dist-web/assets/{index-0x1QPzKZ.js → index-CUzFFw5b.js} +1 -1
  71. package/dist-web/assets/index-Cj2GU1SR.js +1 -0
  72. package/dist-web/assets/{index-y7cxH1Et.css → index-CsqMIyA9.css} +1 -1
  73. package/dist-web/assets/index-CtmXho1w.css +1 -0
  74. package/dist-web/assets/index-D7aKwT6w.js +64 -0
  75. package/dist-web/assets/index-DXcFBsM1.js +24 -0
  76. package/dist-web/assets/index-DaZnh1zP.js +2 -0
  77. package/dist-web/assets/index-DeV8SAiM.js +25 -0
  78. package/dist-web/assets/index-WJCmqKnh.js +1 -0
  79. package/dist-web/assets/index-t6s0nOlb.js +1 -0
  80. package/dist-web/assets/people-page-header-D93GTPBO.js +1 -0
  81. package/dist-web/assets/vendor-nuxt-ui-DUpPmItD.js +15 -0
  82. package/dist-web/assets/vendor-reka-ui-BLnO2MqY.js +15 -0
  83. package/dist-web/assets/vendor-snapdom--nZvo8Sg.js +8 -0
  84. package/dist-web/assets/web-BoTDL3HM.js +1 -0
  85. package/dist-web/assets/{webworkerAll-BKGP--A4.js → webworkerAll-c0ZvpENM.js} +1 -1
  86. package/dist-web/index.html +5 -5
  87. package/package.json +1 -1
  88. package/dist/chunk-DBBL74RK.mjs.map +0 -1
  89. package/dist/chunk-EXD2SXWL.mjs.map +0 -1
  90. package/dist/chunk-JH5RAJT2.mjs.map +0 -1
  91. package/dist/chunk-RD335EMA.mjs.map +0 -1
  92. package/dist/chunk-T64GA5HP.mjs.map +0 -1
  93. package/dist/chunk-UWWFOEGF.mjs.map +0 -1
  94. package/dist/chunk-WQCY45U2.mjs.map +0 -1
  95. package/dist/chunk-YPQ72HMX.mjs.map +0 -1
  96. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CdJT0t2f.js +0 -110
  97. package/dist-web/assets/EChartWordcloud-DU3ZYdgz.js +0 -1
  98. package/dist-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-DACMroOe.js +0 -1
  99. package/dist-web/assets/MessageExportModal-h-zl0dx1.js +0 -1
  100. package/dist-web/assets/PageHeader-CK0hTsdx.js +0 -1
  101. package/dist-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-BoZyssJF.js +0 -1
  102. package/dist-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-27hMyAUE.js +0 -1
  103. package/dist-web/assets/annual-summary-time-range-DVLXK1r4.js +0 -1
  104. package/dist-web/assets/dateFormat-BcqNKTQ1.js +0 -1
  105. package/dist-web/assets/fetch-BUm1isWe.js +0 -5
  106. package/dist-web/assets/fetch-CBOJwwJp.js +0 -17
  107. package/dist-web/assets/index-B5S9FnfP.js +0 -1
  108. package/dist-web/assets/index-BS6loLHW.js +0 -1
  109. package/dist-web/assets/index-BrTlAl8b.js +0 -1
  110. package/dist-web/assets/index-C3TnydSt.js +0 -24
  111. package/dist-web/assets/index-CAWO10k1.js +0 -2
  112. package/dist-web/assets/index-C_0GHEcb.css +0 -1
  113. package/dist-web/assets/index-Chm17wNe.js +0 -2
  114. package/dist-web/assets/index-DAr_2DlV.js +0 -173
  115. package/dist-web/assets/index-Em6upenM.js +0 -64
  116. package/dist-web/assets/index-FoTy2Cce.js +0 -1
  117. package/dist-web/assets/index-YADL4XIp.js +0 -22
  118. package/dist-web/assets/index-_6lck7Bv.css +0 -1
  119. package/dist-web/assets/index-aMIgqj43.js +0 -1
  120. package/dist-web/assets/index-zZVsV5HB.js +0 -1
  121. package/dist-web/assets/people-page-header-BdKM1qhX.js +0 -1
  122. package/dist-web/assets/vendor-nuxt-ui-CS1uxE9C.js +0 -15
  123. package/dist-web/assets/vendor-reka-ui-Cta6JPvN.js +0 -11
  124. package/dist-web/assets/vendor-snapdom-XnBoh1gd.js +0 -8
  125. package/dist-web/assets/web-BUZ-dZy0.js +0 -1
  126. /package/dist/{chat-command-CHV7RLBH.mjs.map → chat-command-V6NYTTPD.mjs.map} +0 -0
  127. /package/dist/{chunk-DA5T64RY.mjs.map → chunk-54GVCXHZ.mjs.map} +0 -0
  128. /package/dist/{chunk-RDCUGC24.mjs.map → chunk-HUKZ2PBC.mjs.map} +0 -0
  129. /package/dist/{chunk-SNCXU2QL.mjs.map → chunk-ZF67S6RY.mjs.map} +0 -0
  130. /package/dist/{http-3B5ARN7A.mjs.map → http-AMDWRKOH.mjs.map} +0 -0
  131. /package/dist/{import-2DZGNSEX.mjs.map → import-WIJHB4LH.mjs.map} +0 -0
  132. /package/dist/{mcp-44I6FUUQ.mjs.map → mcp-NC5YNTM5.mjs.map} +0 -0
  133. /package/dist/{src-R3QX6L3L.mjs.map → src-UY4GCVNF.mjs.map} +0 -0
  134. /package/dist/{stream-import-VUEL2TTU.mjs.map → stream-import-JKQYRISL.mjs.map} +0 -0
  135. /package/dist/{worker-runtime-GJAOIIZW.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") {
@@ -2830,7 +2830,8 @@ function getChatSessionList(db) {
2830
2830
  cs.message_count as messageCount,
2831
2831
  cs.summary,
2832
2832
  (SELECT mc.message_id FROM message_context mc
2833
- WHERE mc.segment_id = cs.id ORDER BY mc.message_id LIMIT 1) as firstMessageId
2833
+ JOIN message first_msg ON first_msg.id = mc.message_id
2834
+ WHERE mc.segment_id = cs.id ORDER BY first_msg.ts ASC, first_msg.id ASC LIMIT 1) as firstMessageId
2834
2835
  FROM segment cs
2835
2836
  ORDER BY cs.start_ts ASC`
2836
2837
  ).all();
@@ -4633,26 +4634,6 @@ function getMembers(db) {
4633
4634
  ORDER BY messageCount DESC`
4634
4635
  ).all();
4635
4636
  }
4636
- function getMembersDetailed(db) {
4637
- const rows = db.prepare(
4638
- `SELECT
4639
- m.id as id,
4640
- m.platform_id as platformId,
4641
- COALESCE(m.account_name, m.platform_id) as accountName,
4642
- m.group_nickname as groupNickname,
4643
- (SELECT COUNT(*) FROM message WHERE sender_id = m.id) as messageCount
4644
- FROM member m
4645
- WHERE COALESCE(m.account_name, '') != '\u7CFB\u7EDF\u6D88\u606F'
4646
- ORDER BY messageCount DESC`
4647
- ).all();
4648
- return rows.map((row) => ({
4649
- id: Number(row.id),
4650
- platformId: String(row.platformId),
4651
- accountName: String(row.accountName || row.platformId),
4652
- groupNickname: row.groupNickname ? String(row.groupNickname) : null,
4653
- messageCount: Number(row.messageCount)
4654
- }));
4655
- }
4656
4637
  function executeReadonlySql(db, sql, maxRows = 1e3) {
4657
4638
  const result = executeSql(db, sql, { maxRows });
4658
4639
  return {
@@ -4857,11 +4838,12 @@ function getMembersWithAliases(db) {
4857
4838
  m.id, m.platform_id as platformId,
4858
4839
  m.account_name as accountName, m.group_nickname as groupNickname,
4859
4840
  ${aliasesSelect}, ${avatarSelect},
4860
- COUNT(msg.id) as messageCount
4841
+ COUNT(msg.id) as messageCount,
4842
+ MAX(msg.ts) as lastMessageTs
4861
4843
  FROM member m
4862
4844
  LEFT JOIN message msg ON m.id = msg.sender_id
4863
4845
  WHERE COALESCE(m.group_nickname, m.account_name, m.platform_id) != '\u7CFB\u7EDF\u6D88\u606F'
4864
- GROUP BY m.id ORDER BY messageCount DESC`
4846
+ GROUP BY m.id ORDER BY messageCount DESC, m.id ASC`
4865
4847
  ).all();
4866
4848
  return rows.map(mapMemberRow);
4867
4849
  }
@@ -4903,12 +4885,13 @@ function getMembersPaginated(db, params) {
4903
4885
  m.id, m.platform_id as platformId,
4904
4886
  m.account_name as accountName, m.group_nickname as groupNickname,
4905
4887
  ${aliasesSelect}, ${avatarSelect},
4906
- COUNT(msg.id) as messageCount
4888
+ COUNT(msg.id) as messageCount,
4889
+ MAX(msg.ts) as lastMessageTs
4907
4890
  FROM member m
4908
4891
  LEFT JOIN message msg ON m.id = msg.sender_id
4909
4892
  WHERE ${systemFilter} ${searchClause}
4910
4893
  GROUP BY m.id
4911
- ORDER BY messageCount ${sortDirection}
4894
+ ORDER BY messageCount ${sortDirection}, m.id ASC
4912
4895
  LIMIT ? OFFSET ?`
4913
4896
  ).all(...searchParams, pageSize, offset);
4914
4897
  return { members: rows.map(mapMemberRow), total, page, pageSize, totalPages };
@@ -4921,7 +4904,8 @@ function mapMemberRow(row) {
4921
4904
  groupNickname: row.groupNickname,
4922
4905
  aliases: row.aliases ? JSON.parse(row.aliases) : [],
4923
4906
  avatar: row.avatar ?? null,
4924
- messageCount: row.messageCount
4907
+ messageCount: row.messageCount,
4908
+ lastMessageTs: row.lastMessageTs == null ? null : Number(row.lastMessageTs)
4925
4909
  };
4926
4910
  }
4927
4911
  function executeParameterizedSql(db, query, params = {}) {
@@ -5030,14 +5014,20 @@ function mergeMembers(db, memberId1, memberId2) {
5030
5014
  return false;
5031
5015
  }
5032
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
+ }
5033
5028
  function deleteMember(db, memberId) {
5034
5029
  try {
5035
- db.transaction(() => {
5036
- db.prepare("DELETE FROM message WHERE sender_id = ?").run(memberId);
5037
- db.prepare("DELETE FROM member_name_history WHERE member_id = ?").run(memberId);
5038
- db.prepare("DELETE FROM member WHERE id = ?").run(memberId);
5039
- });
5040
- return true;
5030
+ return deleteMembers(db, [memberId]);
5041
5031
  } catch {
5042
5032
  return false;
5043
5033
  }
@@ -7952,15 +7942,15 @@ function tokenizeQueryForFts(keywords) {
7952
7942
  import * as fs13 from "fs";
7953
7943
  import * as os3 from "os";
7954
7944
  import * as path13 from "path";
7955
- var SYSTEM_SUBDIRS = ["ai", "settings", "cache", "logs", "temp", "nlp"];
7945
+ var SYSTEM_SUBDIRS = ["ai", "settings", "cache", "logs", "nlp"];
7956
7946
  var STORAGE_CONFIG_FILE = "storage.json";
7957
- function getElectronUserDataDir() {
7958
- const home = os3.homedir();
7959
- switch (process.platform) {
7947
+ function getElectronUserDataDir(options = {}) {
7948
+ const home = options.homeDir ?? os3.homedir();
7949
+ switch (options.platform ?? process.platform) {
7960
7950
  case "darwin":
7961
7951
  return path13.join(home, "Library", "Application Support", "ChatLab");
7962
7952
  case "win32": {
7963
- const appData = process.env.APPDATA || path13.join(home, "AppData", "Roaming");
7953
+ const appData = options.appDataDir ?? process.env.APPDATA ?? path13.join(home, "AppData", "Roaming");
7964
7954
  return path13.join(appData, "ChatLab");
7965
7955
  }
7966
7956
  default:
@@ -8994,6 +8984,22 @@ var DatabaseManager = class {
8994
8984
  return isChatSessionDb(db);
8995
8985
  });
8996
8986
  }
8987
+ /**
8988
+ * 只读列举聊天会话 ID,不触发数据库迁移或兼容门禁提升。
8989
+ */
8990
+ listSessionIdsReadonly() {
8991
+ this.assertCompatible();
8992
+ const dbDir = this.pathProvider.getDatabaseDir();
8993
+ if (!fs17.existsSync(dbDir)) return [];
8994
+ return fs17.readdirSync(dbDir).filter((fileName) => fileName.endsWith(".db")).map((fileName) => fileName.replace(".db", "")).filter((sessionId) => {
8995
+ const db = this.openRawSessionDatabase(sessionId, { readonly: true });
8996
+ try {
8997
+ return isChatSessionDb(db);
8998
+ } finally {
8999
+ db.close();
9000
+ }
9001
+ });
9002
+ }
8997
9003
  getUserDataDir() {
8998
9004
  return this.pathProvider.getUserDataDir();
8999
9005
  }
@@ -9263,7 +9269,6 @@ export {
9263
9269
  searchMessagesLike,
9264
9270
  searchMessagesByKeywords,
9265
9271
  getMembers,
9266
- getMembersDetailed,
9267
9272
  executeReadonlySql,
9268
9273
  executeSql,
9269
9274
  getSchemaDetailed,
@@ -9277,6 +9282,7 @@ export {
9277
9282
  computeResponseTimeStats,
9278
9283
  updateMemberAliases,
9279
9284
  mergeMembers,
9285
+ deleteMembers,
9280
9286
  deleteMember,
9281
9287
  getCatchphraseAnalysis,
9282
9288
  getRelationshipStats,
@@ -9365,4 +9371,4 @@ export {
9365
9371
  StaticPathProvider,
9366
9372
  createDatabaseManagerAdapter
9367
9373
  };
9368
- //# sourceMappingURL=chunk-UWWFOEGF.mjs.map
9374
+ //# sourceMappingURL=chunk-XZ5FFDLX.mjs.map