chatlab-cli 0.31.2-beta.1 → 0.31.3

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 (111) hide show
  1. package/dist/{chat-command-V6NYTTPD.mjs → chat-command-ZIXKNLSE.mjs} +15 -9
  2. package/dist/chat-command-ZIXKNLSE.mjs.map +1 -0
  3. package/dist/{chunk-HUKZ2PBC.mjs → chunk-23AIEWCD.mjs} +2 -2
  4. package/dist/{chunk-ZF67S6RY.mjs → chunk-3J7WTUEE.mjs} +2 -2
  5. package/dist/{chunk-5G2INROS.mjs → chunk-75FZ26HM.mjs} +419 -89
  6. package/dist/chunk-75FZ26HM.mjs.map +1 -0
  7. package/dist/{chunk-54GVCXHZ.mjs → chunk-BLOBEOCG.mjs} +2 -2
  8. package/dist/{chunk-LWC7JQ2W.mjs → chunk-DV4U34MR.mjs} +2 -2
  9. package/dist/{chunk-OIZ64ET3.mjs → chunk-EINCXXWY.mjs} +3 -3
  10. package/dist/{chunk-7TDYBU5L.mjs → chunk-FDLLEDNW.mjs} +79 -20
  11. package/dist/chunk-FDLLEDNW.mjs.map +1 -0
  12. package/dist/{chunk-67HNEIKY.mjs → chunk-GZO3NAHC.mjs} +52 -100
  13. package/dist/chunk-GZO3NAHC.mjs.map +1 -0
  14. package/dist/{chunk-SJQVAKFA.mjs → chunk-MFOCDGCC.mjs} +15 -3
  15. package/dist/chunk-MFOCDGCC.mjs.map +1 -0
  16. package/dist/{chunk-WL2ISRYH.mjs → chunk-UIUEG7JB.mjs} +11 -11
  17. package/dist/{chunk-XZ5FFDLX.mjs → chunk-YVNZ73O5.mjs} +31 -136
  18. package/dist/chunk-YVNZ73O5.mjs.map +1 -0
  19. package/dist/cli.mjs +8 -8
  20. package/dist/contacts-worker.mjs +2 -2
  21. package/dist/global-insight-worker.mjs +1 -1
  22. package/dist/{http-AMDWRKOH.mjs → http-WDG2OHOV.mjs} +11 -11
  23. package/dist/{import-WIJHB4LH.mjs → import-4BDC37F7.mjs} +7 -7
  24. package/dist/index.mjs +11 -11
  25. package/dist/{mcp-NC5YNTM5.mjs → mcp-4KUVRGFF.mjs} +8 -8
  26. package/dist/people-relationships-worker.mjs +2 -2
  27. package/dist/semantic-index-worker.mjs +1 -1
  28. package/dist/{src-UY4GCVNF.mjs → src-ZOCLFBCJ.mjs} +12 -6
  29. package/dist/{stream-import-JKQYRISL.mjs → stream-import-ERTT7U6V.mjs} +7 -7
  30. package/dist/{worker-runtime-KKUOJJTN.mjs → worker-runtime-2TUZHV7W.mjs} +5 -5
  31. package/dist-web/assets/ActionToolsPanel-Dp-ojXjO.css +1 -0
  32. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-GgQ5ueMX.js +110 -0
  33. package/dist-web/assets/{BufferResource-i1amDJTV.js → BufferResource-DgKoy0Ii.js} +1 -1
  34. package/dist-web/assets/{CanvasRenderer-DGa7AjdC.js → CanvasRenderer-CKpp71xg.js} +1 -1
  35. package/dist-web/assets/{EChartWordcloud-BXC_4nUP.js → EChartWordcloud-CSOuFvyM.js} +1 -1
  36. package/dist-web/assets/{Filter-BTlq0yU-.js → Filter-D32zqY5x.js} +1 -1
  37. package/dist-web/assets/{LoadingState.vue_vue_type_script_setup_true_lang-B2KAoiMG.js → LoadingState.vue_vue_type_script_setup_true_lang-DUAtrSZD.js} +1 -1
  38. package/dist-web/assets/{MessageExportModal-D9C5t_zF.js → MessageExportModal-BYLw4vZ8.js} +1 -1
  39. package/dist-web/assets/{PageHeader-BEWr2vsg.js → PageHeader-Dmu6cdAk.js} +1 -1
  40. package/dist-web/assets/{RelationshipGalaxyCanvas-CSgPNRif.js → RelationshipGalaxyCanvas-DsMOubHV.js} +3 -3
  41. package/dist-web/assets/{RelationshipGalaxyThreeCanvas-CBAnU8vN.js → RelationshipGalaxyThreeCanvas-Dh5HjVHr.js} +1 -1
  42. package/dist-web/assets/{RenderTargetSystem-Ctlu222X.js → RenderTargetSystem-CovK4x_D.js} +1 -1
  43. package/dist-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-BWJ6kuSC.js → ThemeCard.vue_vue_type_script_setup_true_lang-DhUfYrEx.js} +1 -1
  44. package/dist-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-D5vov0eO.js → TimeSelect.vue_vue_type_script_setup_true_lang-CaumhCAS.js} +1 -1
  45. package/dist-web/assets/{WebGLRenderer-D2Zvhmcw.js → WebGLRenderer-CawhbcYU.js} +1 -1
  46. package/dist-web/assets/{WebGPURenderer-BOtP6h9o.js → WebGPURenderer-B7P1D2sA.js} +1 -1
  47. package/dist-web/assets/{annual-summary-time-range-CK0IIPsY.js → annual-summary-time-range-Bya4h2j6.js} +1 -1
  48. package/dist-web/assets/{base-BMjDSaj6.js → base-ClGWE9aq.js} +1 -1
  49. package/dist-web/assets/{browserAll-BhwLvWQY.js → browserAll-CtQkc1DF.js} +1 -1
  50. package/dist-web/assets/{dateFormat-dteP1INW.js → dateFormat-Cfb89ZjM.js} +1 -1
  51. package/dist-web/assets/{electron-DCgfulPE.js → electron-Brd7jS6W.js} +1 -1
  52. package/dist-web/assets/{fetch-rJA9qLvd.js → fetch-BJ3lnhzK.js} +1 -1
  53. package/dist-web/assets/{fetch-6q7oz7ZO.js → fetch-BoB63ns8.js} +1 -1
  54. package/dist-web/assets/fetch-BtK7YvLp.js +1 -0
  55. package/dist-web/assets/{fetch-D5BrGna5.js → fetch-CeREJiFL.js} +1 -1
  56. package/dist-web/assets/{fetch-DgXWr9nB.js → fetch-D2hvh7lO.js} +1 -1
  57. package/dist-web/assets/{fetch-B_0HIxs5.js → fetch-DVGCzZ0E.js} +1 -1
  58. package/dist-web/assets/{fetch-CubnKpLG.js → fetch-DWoMmOlr.js} +1 -1
  59. package/dist-web/assets/{fetch-BxHdB6X1.js → fetch-DkfUUq-R.js} +1 -1
  60. package/dist-web/assets/{fetch-CpvfCafG.js → fetch-Dr_Fjtvp.js} +1 -1
  61. package/dist-web/assets/{fetch-DvZuLuTE.js → fetch-u7ivV7Uy.js} +1 -1
  62. package/dist-web/assets/{index-Cj2GU1SR.js → index-BHnQaeQY.js} +1 -1
  63. package/dist-web/assets/{index-BfGKlkx3.js → index-BXaKyn8J.js} +2 -2
  64. package/dist-web/assets/{index-Bs15Yc7I.js → index-BzH9cnfy.js} +1 -1
  65. package/dist-web/assets/{index-DXcFBsM1.js → index-CuPE4SSh.js} +1 -1
  66. package/dist-web/assets/index-D-qNxFxp.js +173 -0
  67. package/dist-web/assets/index-D494nYee.js +64 -0
  68. package/dist-web/assets/index-D8Uq3_Dc.css +1 -0
  69. package/dist-web/assets/index-DBb03wVF.css +1 -0
  70. package/dist-web/assets/{index-DaZnh1zP.js → index-DJ8kB4US.js} +2 -2
  71. package/dist-web/assets/{index-BoalB6nB.js → index-DNMWR2Vj.js} +1 -1
  72. package/dist-web/assets/{index-Bp5VKUF9.js → index-DSPls1YV.js} +1 -1
  73. package/dist-web/assets/{index-WJCmqKnh.js → index-DcAqhCpS.js} +1 -1
  74. package/dist-web/assets/{index-t6s0nOlb.js → index-DnkaYOFI.js} +1 -1
  75. package/dist-web/assets/index-_UKteDZB.js +25 -0
  76. package/dist-web/assets/index-gi0wgh0M.css +1 -0
  77. package/dist-web/assets/{index-CUzFFw5b.js → index-w_1EjXiF.js} +1 -1
  78. package/dist-web/assets/{people-page-header-D93GTPBO.js → people-page-header-YGQM9G53.js} +1 -1
  79. package/dist-web/assets/{vendor-nuxt-ui-DUpPmItD.js → vendor-nuxt-ui-DmkGVKod.js} +2 -2
  80. package/dist-web/assets/{vendor-reka-ui-BLnO2MqY.js → vendor-reka-ui-BkhadcDj.js} +1 -1
  81. package/dist-web/assets/{web-BoTDL3HM.js → web-zXxtk2KZ.js} +1 -1
  82. package/dist-web/assets/{webworkerAll-c0ZvpENM.js → webworkerAll-BzRoT-6m.js} +1 -1
  83. package/dist-web/index.html +4 -4
  84. package/package.json +1 -1
  85. package/dist/chat-command-V6NYTTPD.mjs.map +0 -1
  86. package/dist/chunk-5G2INROS.mjs.map +0 -1
  87. package/dist/chunk-67HNEIKY.mjs.map +0 -1
  88. package/dist/chunk-7TDYBU5L.mjs.map +0 -1
  89. package/dist/chunk-SJQVAKFA.mjs.map +0 -1
  90. package/dist/chunk-XZ5FFDLX.mjs.map +0 -1
  91. package/dist-web/assets/ActionToolsPanel-BL0GQR6r.css +0 -1
  92. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DVdpZpfD.js +0 -110
  93. package/dist-web/assets/fetch-BbU4MPPu.js +0 -1
  94. package/dist-web/assets/index-CAjUCtGD.css +0 -1
  95. package/dist-web/assets/index-CLijvqy3.js +0 -173
  96. package/dist-web/assets/index-CsqMIyA9.css +0 -1
  97. package/dist-web/assets/index-CtmXho1w.css +0 -1
  98. package/dist-web/assets/index-D7aKwT6w.js +0 -64
  99. package/dist-web/assets/index-DeV8SAiM.js +0 -25
  100. /package/dist/{chunk-HUKZ2PBC.mjs.map → chunk-23AIEWCD.mjs.map} +0 -0
  101. /package/dist/{chunk-ZF67S6RY.mjs.map → chunk-3J7WTUEE.mjs.map} +0 -0
  102. /package/dist/{chunk-54GVCXHZ.mjs.map → chunk-BLOBEOCG.mjs.map} +0 -0
  103. /package/dist/{chunk-LWC7JQ2W.mjs.map → chunk-DV4U34MR.mjs.map} +0 -0
  104. /package/dist/{chunk-OIZ64ET3.mjs.map → chunk-EINCXXWY.mjs.map} +0 -0
  105. /package/dist/{chunk-WL2ISRYH.mjs.map → chunk-UIUEG7JB.mjs.map} +0 -0
  106. /package/dist/{http-AMDWRKOH.mjs.map → http-WDG2OHOV.mjs.map} +0 -0
  107. /package/dist/{import-WIJHB4LH.mjs.map → import-4BDC37F7.mjs.map} +0 -0
  108. /package/dist/{mcp-NC5YNTM5.mjs.map → mcp-4KUVRGFF.mjs.map} +0 -0
  109. /package/dist/{src-UY4GCVNF.mjs.map → src-ZOCLFBCJ.mjs.map} +0 -0
  110. /package/dist/{stream-import-JKQYRISL.mjs.map → stream-import-ERTT7U6V.mjs.map} +0 -0
  111. /package/dist/{worker-runtime-KKUOJJTN.mjs.map → worker-runtime-2TUZHV7W.mjs.map} +0 -0
@@ -7,23 +7,25 @@ const __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  closeServerAiLogger,
9
9
  createCliRunAgentStream,
10
+ getAssistantManager,
10
11
  getServerAiLogger,
12
+ getSkillManagerCore,
11
13
  initServerAiLogger
12
- } from "./chunk-7TDYBU5L.mjs";
14
+ } from "./chunk-FDLLEDNW.mjs";
13
15
  import {
14
16
  AGENT_TOOL_REGISTRY,
15
17
  CoreDataProvider
16
- } from "./chunk-LWC7JQ2W.mjs";
18
+ } from "./chunk-DV4U34MR.mjs";
17
19
  import {
18
20
  analyzeIncrementalImport,
19
21
  analyzeNewImport,
20
22
  autoImport,
21
23
  incrementalImport,
22
24
  streamImport
23
- } from "./chunk-OIZ64ET3.mjs";
25
+ } from "./chunk-EINCXXWY.mjs";
24
26
  import {
25
27
  assertCliDataDirCompatible
26
- } from "./chunk-54GVCXHZ.mjs";
28
+ } from "./chunk-BLOBEOCG.mjs";
27
29
  import {
28
30
  getVersion
29
31
  } from "./chunk-5ADKYYNA.mjs";
@@ -41,12 +43,11 @@ import {
41
43
  getPendingNodeDataDirMigration,
42
44
  hasPendingElectronDataWarning,
43
45
  serializeChatLabToJsonl
44
- } from "./chunk-SJQVAKFA.mjs";
46
+ } from "./chunk-MFOCDGCC.mjs";
45
47
  import {
46
48
  AIChatManager,
47
49
  ArchiveImportError,
48
50
  ArchiveImportSourceManager,
49
- AssistantManager,
50
51
  CustomModelStore,
51
52
  CustomProviderStore,
52
53
  IMPORT_IN_PROGRESS_ERROR_KEY,
@@ -55,7 +56,6 @@ import {
55
56
  MergeSessionCache,
56
57
  SEMANTIC_INDEX_CONFIG_FILE,
57
58
  SemanticIndexConfigStore,
58
- SkillManagerCore,
59
59
  TempDbWriter,
60
60
  buildPiModel,
61
61
  computeWordFrequency,
@@ -98,7 +98,7 @@ import {
98
98
  streamParseFileInfo,
99
99
  summary_service_exports,
100
100
  validateApiKey
101
- } from "./chunk-5G2INROS.mjs";
101
+ } from "./chunk-75FZ26HM.mjs";
102
102
  import {
103
103
  resolveCliPath
104
104
  } from "./chunk-FJ35V3TE.mjs";
@@ -160,10 +160,10 @@ import {
160
160
  stripAvatarFields,
161
161
  verifyCliDataPath,
162
162
  writeConfigField
163
- } from "./chunk-XZ5FFDLX.mjs";
163
+ } from "./chunk-YVNZ73O5.mjs";
164
164
 
165
165
  // src/http/index.ts
166
- import * as fs12 from "fs";
166
+ import * as fs11 from "fs";
167
167
  import * as crypto4 from "crypto";
168
168
 
169
169
  // ../../packages/http-routes/src/server.ts
@@ -859,6 +859,9 @@ function registerAiAssistantRoutes(server2, ctx) {
859
859
  server2.get("/_web/ai/assistants", async () => {
860
860
  return mgr.getAllAssistants();
861
861
  });
862
+ server2.get("/_web/ai/assistants/:id/upgrade-status", async (request) => {
863
+ return mgr.getAssistantUpgradeInfo(request.params.id);
864
+ });
862
865
  server2.get("/_web/ai/assistants/:id", async (request, reply) => {
863
866
  const config = mgr.getAssistantConfig(request.params.id);
864
867
  if (!config) return reply.code(404).send({ error: "Not found" });
@@ -882,6 +885,14 @@ function registerAiAssistantRoutes(server2, ctx) {
882
885
  if (!result.success) return reply.code(400).send(result);
883
886
  return result;
884
887
  });
888
+ server2.post("/_web/ai/assistants/:id/upgrade", async (request, reply) => {
889
+ if (typeof request.body?.backupName !== "string") {
890
+ return reply.code(400).send({ success: false, error: "backupName must be a string" });
891
+ }
892
+ const result = mgr.upgradeAssistantWithBackup(request.params.id, request.body.backupName);
893
+ if (!result.success) return reply.code(400).send(result);
894
+ return result;
895
+ });
885
896
  server2.post("/_web/ai/assistants/import", async (request) => {
886
897
  return mgr.importAssistantFromMd(request.body.rawMd);
887
898
  });
@@ -1273,8 +1284,8 @@ function registerSemanticIndexRoutes(server2, ctx) {
1273
1284
  server2.post("/_web/ai/semantic-index/status", async (request) => {
1274
1285
  return { sessions: await service.statusForSessions(request.body.sessionIds ?? []) };
1275
1286
  });
1276
- const sessionAction = (path14, action) => {
1277
- server2.post(path14, async (request, reply) => {
1287
+ const sessionAction = (path13, action) => {
1288
+ server2.post(path13, async (request, reply) => {
1278
1289
  const { sessionId } = request.body;
1279
1290
  if (!sessionId) return reply.code(400).send({ error: "sessionId is required" });
1280
1291
  await action(sessionId);
@@ -3435,10 +3446,10 @@ function registerWebRoutes2(server2, dbManager2, options) {
3435
3446
  const resolvedPathProvider = options?.pathProvider ?? fallbackPathProvider;
3436
3447
  const ai = options?.aiContext;
3437
3448
  const cliStreamImport = async (dm, filePath) => {
3438
- const { streamImport: streamImport2 } = await import("./stream-import-JKQYRISL.mjs");
3449
+ const { streamImport: streamImport2 } = await import("./stream-import-ERTT7U6V.mjs");
3439
3450
  const result = await streamImport2(dm, filePath);
3440
3451
  if (!result.success) {
3441
- const { IMPORT_IN_PROGRESS_ERROR_KEY: IMPORT_IN_PROGRESS_ERROR_KEY2, ImportInProgressError: ImportInProgressError2 } = await import("./src-UY4GCVNF.mjs");
3452
+ const { IMPORT_IN_PROGRESS_ERROR_KEY: IMPORT_IN_PROGRESS_ERROR_KEY2, ImportInProgressError: ImportInProgressError2 } = await import("./src-ZOCLFBCJ.mjs");
3442
3453
  if (result.error === IMPORT_IN_PROGRESS_ERROR_KEY2) throw new ImportInProgressError2();
3443
3454
  throw new Error(result.error || "Import failed");
3444
3455
  }
@@ -3542,73 +3553,14 @@ function registerProxyRoutes(server2) {
3542
3553
  });
3543
3554
  }
3544
3555
 
3545
- // src/ai/manager-factory.ts
3546
- import * as fs8 from "fs";
3547
- import * as path11 from "path";
3548
- import { createHash, randomUUID as randomUUID2 } from "crypto";
3549
- var nodeFs = {
3550
- ensureDir(dir) {
3551
- if (!fs8.existsSync(dir)) fs8.mkdirSync(dir, { recursive: true });
3552
- },
3553
- listFiles(dir, ext) {
3554
- if (!fs8.existsSync(dir)) return [];
3555
- return fs8.readdirSync(dir).filter((f) => f.endsWith(ext));
3556
- },
3557
- readFile(filePath) {
3558
- return fs8.readFileSync(filePath, "utf-8");
3559
- },
3560
- writeFile(filePath, content) {
3561
- fs8.writeFileSync(filePath, content, "utf-8");
3562
- },
3563
- deleteFile(filePath) {
3564
- if (fs8.existsSync(filePath)) fs8.unlinkSync(filePath);
3565
- },
3566
- fileExists(filePath) {
3567
- return fs8.existsSync(filePath);
3568
- },
3569
- joinPath(...parts) {
3570
- return path11.join(...parts);
3571
- }
3572
- };
3573
- var managerCache = /* @__PURE__ */ new Map();
3574
- function getAssistantManager(aiDataDir) {
3575
- let cached = managerCache.get(aiDataDir);
3576
- if (!cached) {
3577
- cached = {
3578
- assistant: new AssistantManager({
3579
- fs: nodeFs,
3580
- assistantsDir: path11.join(aiDataDir, "assistants"),
3581
- builtinRawConfigs: [],
3582
- generateId: () => `custom_${randomUUID2().replace(/-/g, "").slice(0, 12)}`
3583
- }),
3584
- skill: new SkillManagerCore({
3585
- fs: nodeFs,
3586
- skillsDir: path11.join(aiDataDir, "skills"),
3587
- builtinRawSkills: [],
3588
- contentHash: (content) => createHash("md5").update(content).digest("hex")
3589
- })
3590
- };
3591
- managerCache.set(aiDataDir, cached);
3592
- }
3593
- return cached.assistant;
3594
- }
3595
- function getSkillManagerCore(aiDataDir) {
3596
- let cached = managerCache.get(aiDataDir);
3597
- if (!cached) {
3598
- getAssistantManager(aiDataDir);
3599
- cached = managerCache.get(aiDataDir);
3600
- }
3601
- return cached.skill;
3602
- }
3603
-
3604
3556
  // ../../packages/sync/src/types.ts
3605
3557
  var noop = () => {
3606
3558
  };
3607
3559
  var NOOP_LOGGER = { info: noop, warn: noop, error: noop };
3608
3560
 
3609
3561
  // ../../packages/sync/src/data-source-manager.ts
3610
- import * as fs9 from "fs";
3611
- import * as path12 from "path";
3562
+ import * as fs8 from "fs";
3563
+ import * as path11 from "path";
3612
3564
  import * as crypto from "crypto";
3613
3565
  var CONFIG_FILE = "data-sources.json";
3614
3566
  function generateId(prefix = "ds") {
@@ -3636,17 +3588,17 @@ var DataSourceManager = class {
3636
3588
  this.logger = logger ?? NOOP_LOGGER;
3637
3589
  }
3638
3590
  getConfigPath() {
3639
- return path12.join(this.configDir, CONFIG_FILE);
3591
+ return path11.join(this.configDir, CONFIG_FILE);
3640
3592
  }
3641
3593
  ensureDir() {
3642
- fs9.mkdirSync(this.configDir, { recursive: true });
3594
+ fs8.mkdirSync(this.configDir, { recursive: true });
3643
3595
  }
3644
3596
  // ==================== Load / Save ====================
3645
3597
  loadAll() {
3646
3598
  try {
3647
3599
  const filePath = this.getConfigPath();
3648
- if (fs9.existsSync(filePath)) {
3649
- const raw = fs9.readFileSync(filePath, "utf-8");
3600
+ if (fs8.existsSync(filePath)) {
3601
+ const raw = fs8.readFileSync(filePath, "utf-8");
3650
3602
  const parsed = JSON.parse(raw);
3651
3603
  if (!isValidDataSourceArray(parsed)) {
3652
3604
  this.logger.warn("[DataSource] Incompatible config format detected, returning empty.");
@@ -3665,7 +3617,7 @@ var DataSourceManager = class {
3665
3617
  saveAll(sources) {
3666
3618
  try {
3667
3619
  this.ensureDir();
3668
- fs9.writeFileSync(this.getConfigPath(), JSON.stringify(sources, null, 2), "utf-8");
3620
+ fs8.writeFileSync(this.getConfigPath(), JSON.stringify(sources, null, 2), "utf-8");
3669
3621
  } catch (err) {
3670
3622
  this.logger.error("[DataSource] Failed to save config", err);
3671
3623
  }
@@ -3759,7 +3711,7 @@ var DataSourceManager = class {
3759
3711
  };
3760
3712
 
3761
3713
  // ../../packages/sync/src/pull-engine.ts
3762
- import * as fs10 from "fs";
3714
+ import * as fs9 from "fs";
3763
3715
  import * as crypto2 from "crypto";
3764
3716
  var MAX_PAGES_PER_PULL = 5e3;
3765
3717
  var PULL_OVERLAP_SECONDS = 60;
@@ -3781,7 +3733,7 @@ function parseSyncFromFile(filePath) {
3781
3733
  try {
3782
3734
  const isJsonl = filePath.endsWith(".jsonl");
3783
3735
  if (isJsonl) {
3784
- const content = fs10.readFileSync(filePath, "utf-8");
3736
+ const content = fs9.readFileSync(filePath, "utf-8");
3785
3737
  const lines = content.trimEnd().split("\n");
3786
3738
  for (let i = lines.length - 1; i >= Math.max(0, lines.length - 5); i--) {
3787
3739
  try {
@@ -3800,7 +3752,7 @@ function parseSyncFromFile(filePath) {
3800
3752
  }
3801
3753
  return null;
3802
3754
  }
3803
- const raw = fs10.readFileSync(filePath, "utf-8");
3755
+ const raw = fs9.readFileSync(filePath, "utf-8");
3804
3756
  const parsed = JSON.parse(raw);
3805
3757
  if (parsed.sync && typeof parsed.sync === "object") {
3806
3758
  const s = parsed.sync;
@@ -3814,7 +3766,7 @@ function parseSyncFromFile(filePath) {
3814
3766
  function fileContainsMessages(filePath) {
3815
3767
  try {
3816
3768
  if (filePath.endsWith(".jsonl")) {
3817
- const content = fs10.readFileSync(filePath, "utf-8");
3769
+ const content = fs9.readFileSync(filePath, "utf-8");
3818
3770
  for (const line of content.split("\n")) {
3819
3771
  const trimmed = line.trim();
3820
3772
  if (!trimmed) continue;
@@ -3827,7 +3779,7 @@ function fileContainsMessages(filePath) {
3827
3779
  }
3828
3780
  return false;
3829
3781
  }
3830
- const raw = fs10.readFileSync(filePath, "utf-8");
3782
+ const raw = fs9.readFileSync(filePath, "utf-8");
3831
3783
  const parsed = JSON.parse(raw);
3832
3784
  return Array.isArray(parsed.messages) && parsed.messages.length > 0;
3833
3785
  } catch {
@@ -3844,7 +3796,7 @@ function getMaxMessageTimestampFromFile(filePath) {
3844
3796
  }
3845
3797
  };
3846
3798
  if (filePath.endsWith(".jsonl")) {
3847
- const content = fs10.readFileSync(filePath, "utf-8");
3799
+ const content = fs9.readFileSync(filePath, "utf-8");
3848
3800
  for (const line of content.split("\n")) {
3849
3801
  const trimmed = line.trim();
3850
3802
  if (!trimmed) continue;
@@ -3857,7 +3809,7 @@ function getMaxMessageTimestampFromFile(filePath) {
3857
3809
  }
3858
3810
  return maxTs;
3859
3811
  }
3860
- const raw = fs10.readFileSync(filePath, "utf-8");
3812
+ const raw = fs9.readFileSync(filePath, "utf-8");
3861
3813
  const parsed = JSON.parse(raw);
3862
3814
  if (Array.isArray(parsed.messages)) {
3863
3815
  for (const message of parsed.messages) {
@@ -3871,7 +3823,7 @@ function getMaxMessageTimestampFromFile(filePath) {
3871
3823
  }
3872
3824
  function cleanupTempFile(filePath) {
3873
3825
  try {
3874
- if (fs10.existsSync(filePath)) fs10.unlinkSync(filePath);
3826
+ if (fs9.existsSync(filePath)) fs9.unlinkSync(filePath);
3875
3827
  } catch {
3876
3828
  }
3877
3829
  }
@@ -3968,7 +3920,7 @@ var PullEngine = class {
3968
3920
  limit: ds.pullLimit
3969
3921
  });
3970
3922
  try {
3971
- const stat2 = fs10.statSync(tempFile);
3923
+ const stat2 = fs9.statSync(tempFile);
3972
3924
  this.logger.info(`[Pull] "${sess.name}" page ${pageCount}: fetched ${stat2.size} bytes`);
3973
3925
  const sync0 = parseSyncFromFile(tempFile);
3974
3926
  if (stat2.size < 1024) {
@@ -3988,7 +3940,7 @@ var PullEngine = class {
3988
3940
  offset,
3989
3941
  limit: ds.pullLimit
3990
3942
  });
3991
- const retryStat = fs10.statSync(retryFile);
3943
+ const retryStat = fs9.statSync(retryFile);
3992
3944
  this.logger.info(`[Pull] "${sess.name}" retry ${ri + 1}: fetched ${retryStat.size} bytes`);
3993
3945
  const retrySync = parseSyncFromFile(retryFile);
3994
3946
  if (retryStat.size < 1024 && !fileContainsMessages(retryFile) && retrySync?.hasMore === false) {
@@ -4338,12 +4290,12 @@ function reloadTimer(dsId, skipInitialPull = false) {
4338
4290
  }
4339
4291
 
4340
4292
  // src/sync/adapters.ts
4341
- import * as fs11 from "fs";
4342
- import * as path13 from "path";
4293
+ import * as fs10 from "fs";
4294
+ import * as path12 from "path";
4343
4295
  import * as crypto3 from "crypto";
4344
4296
  function getTempFilePath(ext) {
4345
4297
  const id = crypto3.randomBytes(8).toString("hex");
4346
- return path13.join(getChatLabTempScopeDir("sync"), `pull-${id}${ext}`);
4298
+ return path12.join(getChatLabTempScopeDir("sync"), `pull-${id}${ext}`);
4347
4299
  }
4348
4300
  var NodeFetcher = class {
4349
4301
  async fetchToTempFile(baseUrl, remoteSessionId, token, params) {
@@ -4360,7 +4312,7 @@ var NodeFetcher = class {
4360
4312
  const isJsonl = contentType.includes("ndjson") || contentType.includes("jsonl");
4361
4313
  const tempFile = getTempFilePath(isJsonl ? ".jsonl" : ".json");
4362
4314
  const buffer = Buffer.from(await response.arrayBuffer());
4363
- fs11.writeFileSync(tempFile, buffer);
4315
+ fs10.writeFileSync(tempFile, buffer);
4364
4316
  return tempFile;
4365
4317
  }
4366
4318
  };
@@ -4373,7 +4325,7 @@ var DirectImporter = class {
4373
4325
  }
4374
4326
  sessionExists(sessionId) {
4375
4327
  const dbPath = this.dbManager.getDbPath(sessionId);
4376
- if (!fs11.existsSync(dbPath)) return false;
4328
+ if (!fs10.existsSync(dbPath)) return false;
4377
4329
  try {
4378
4330
  const db = this.dbManager.openRawSessionDatabase(sessionId, { readonly: true });
4379
4331
  const row = db.prepare("SELECT COUNT(*) as cnt FROM sqlite_master WHERE type='table' AND name='message'").get();
@@ -4381,7 +4333,7 @@ var DirectImporter = class {
4381
4333
  if (row.cnt === 0) {
4382
4334
  this.logger.warn(`[DirectImporter] DB file exists but has no message table: ${sessionId}, removing`);
4383
4335
  try {
4384
- fs11.unlinkSync(dbPath);
4336
+ fs10.unlinkSync(dbPath);
4385
4337
  } catch {
4386
4338
  }
4387
4339
  return false;
@@ -4391,7 +4343,7 @@ var DirectImporter = class {
4391
4343
  if (error instanceof DataDirCompatibilityError) throw error;
4392
4344
  this.logger.warn(`[DirectImporter] Cannot validate DB file: ${sessionId}, removing`);
4393
4345
  try {
4394
- fs11.unlinkSync(dbPath);
4346
+ fs10.unlinkSync(dbPath);
4395
4347
  } catch {
4396
4348
  }
4397
4349
  return false;
@@ -4517,7 +4469,7 @@ var aiChatManager = null;
4517
4469
  function resolveNativeBinding2() {
4518
4470
  if (process.versions.electron) return void 0;
4519
4471
  const nativePath = resolveCliPath("native/better_sqlite3.node");
4520
- if (fs12.existsSync(nativePath)) return nativePath;
4472
+ if (fs11.existsSync(nativePath)) return nativePath;
4521
4473
  return void 0;
4522
4474
  }
4523
4475
  function ensureToken(config) {
@@ -4616,7 +4568,7 @@ async function startHttpServer(options) {
4616
4568
  }
4617
4569
  });
4618
4570
  initSync(server, dbManager, pathProvider, { port, host, token });
4619
- if (options?.webRoot && fs12.existsSync(options.webRoot)) {
4571
+ if (options?.webRoot && fs11.existsSync(options.webRoot)) {
4620
4572
  registerProxyRoutes(server);
4621
4573
  const fastifyStatic = await import("@fastify/static");
4622
4574
  await server.register(fastifyStatic.default, {
@@ -4657,4 +4609,4 @@ export {
4657
4609
  startHttpServer,
4658
4610
  stopHttpServer
4659
4611
  };
4660
- //# sourceMappingURL=chunk-67HNEIKY.mjs.map
4612
+ //# sourceMappingURL=chunk-GZO3NAHC.mjs.map