chatlab-cli 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/{chat-command-B7POB3C3.mjs → chat-command-7WL5NMZ6.mjs} +5 -5
  3. package/dist/{chunk-I7BHOZPX.mjs → chunk-55WR6WKW.mjs} +84 -19
  4. package/dist/{chunk-I7BHOZPX.mjs.map → chunk-55WR6WKW.mjs.map} +1 -1
  5. package/dist/{chunk-3FUF3PEY.mjs → chunk-GFRG7TZQ.mjs} +27 -12
  6. package/dist/chunk-GFRG7TZQ.mjs.map +1 -0
  7. package/dist/{chunk-N3G43SCQ.mjs → chunk-GPF34WXV.mjs} +2560 -324
  8. package/dist/chunk-GPF34WXV.mjs.map +1 -0
  9. package/dist/{chunk-WQMKKUSD.mjs → chunk-VASK54KT.mjs} +2 -2
  10. package/dist/{chunk-3JNVGW62.mjs → chunk-WGS33EWH.mjs} +2 -2
  11. package/dist/{chunk-RJ4D4QWK.mjs → chunk-XNU5X7EV.mjs} +3 -3
  12. package/dist/{chunk-SIVERPF5.mjs → chunk-YQ2FJGBT.mjs} +172 -18
  13. package/dist/chunk-YQ2FJGBT.mjs.map +1 -0
  14. package/dist/{chunk-YUFYTDRH.mjs → chunk-YZDEZ6UI.mjs} +3 -3
  15. package/dist/{chunk-SAE2H2LN.mjs → chunk-ZSFVX6FM.mjs} +3 -3
  16. package/dist/cli.mjs +4 -4
  17. package/dist/{http-A54ZBBAY.mjs → http-C2FBHNZG.mjs} +9 -9
  18. package/dist/{import-EA3TB3S2.mjs → import-ED6JCPSJ.mjs} +5 -5
  19. package/dist/index.mjs +9 -9
  20. package/dist/{mcp-DJDOWHH3.mjs → mcp-5JIBER4M.mjs} +5 -5
  21. package/dist/semantic-index-worker.mjs +1 -1
  22. package/dist/{src-EKPMJRG6.mjs → src-WBNM42SL.mjs} +21 -3
  23. package/dist/{stream-import-FQFNRQ2B.mjs → stream-import-37U3SROO.mjs} +4 -4
  24. package/dist/{worker-runtime-UH2OBO3T.mjs → worker-runtime-6DGYL4TF.mjs} +2 -2
  25. package/dist-web/assets/{DebugToolsPanel.vue_vue_type_script_setup_true_lang-NL1sTF6i.js → DebugToolsPanel.vue_vue_type_script_setup_true_lang-CCz0Syxo.js} +5 -5
  26. package/dist-web/assets/{MessageExportModal-B60rvfCh.js → MessageExportModal-Dd6R-cX_.js} +1 -1
  27. package/dist-web/assets/electron-D9vE5t3H.js +1 -0
  28. package/dist-web/assets/electron-DGxVMsvC.js +1 -0
  29. package/dist-web/assets/{electron-BRUg9LnY.js → electron-DjminAKK.js} +1 -1
  30. package/dist-web/assets/{fetch-DSN-QYZE.js → fetch-B_kLRm6-.js} +1 -1
  31. package/dist-web/assets/{fetch-DLAp7h55.js → fetch-CURbMNJV.js} +1 -1
  32. package/dist-web/assets/fetch-Cle6QKmL.js +3 -0
  33. package/dist-web/assets/{fetch-BIpjJHxj.js → fetch-DFCYOQe5.js} +1 -1
  34. package/dist-web/assets/{fetch-DNSaxRnL.js → fetch-DOhCQ5J8.js} +1 -1
  35. package/dist-web/assets/{fetch-DE8gj5Ke.js → fetch-DV8A1dGB.js} +1 -1
  36. package/dist-web/assets/{fetch-C-m3IysH.js → fetch-Wad5mWVH.js} +1 -1
  37. package/dist-web/assets/{fetch-BRsMdFcn.js → fetch-r83wdzHy.js} +1 -1
  38. package/dist-web/assets/{fetch-Cma-mZjd.js → fetch-srCJzcWc.js} +1 -1
  39. package/dist-web/assets/{fetch-woAa3H2L.js → fetch-uM3erGZm.js} +1 -1
  40. package/dist-web/assets/index-7E5GSvR2.css +1 -0
  41. package/dist-web/assets/index-BCRHSc1k.js +173 -0
  42. package/dist-web/assets/{index-r_zHR2t9.js → index-BIvLzdwg.js} +1 -1
  43. package/dist-web/assets/{index-o6veAyTB.js → index-BpszRZ8V.js} +3 -3
  44. package/dist-web/assets/index-D5UgZUpS.js +12 -0
  45. package/dist-web/assets/{index-iwqJDVMJ.js → index-hOsKRsp6.js} +2 -2
  46. package/dist-web/assets/{index-B9I-Y3fR.js → index-tkbEq8av.js} +1 -1
  47. package/dist-web/assets/web-D27K6zSX.js +1 -0
  48. package/dist-web/index.html +2 -2
  49. package/package.json +1 -1
  50. package/dist/chunk-3FUF3PEY.mjs.map +0 -1
  51. package/dist/chunk-N3G43SCQ.mjs.map +0 -1
  52. package/dist/chunk-SIVERPF5.mjs.map +0 -1
  53. package/dist-web/assets/electron-2m4Vdk2z.js +0 -1
  54. package/dist-web/assets/electron-CRSL7qPM.js +0 -1
  55. package/dist-web/assets/fetch-DOEbyLSD.js +0 -3
  56. package/dist-web/assets/index-B3mDjury.js +0 -11
  57. package/dist-web/assets/index-GAU7LI1r.js +0 -173
  58. package/dist-web/assets/index-YmzTgkb2.css +0 -1
  59. package/dist-web/assets/web-C2UtGskd.js +0 -1
  60. /package/dist/{chat-command-B7POB3C3.mjs.map → chat-command-7WL5NMZ6.mjs.map} +0 -0
  61. /package/dist/{chunk-WQMKKUSD.mjs.map → chunk-VASK54KT.mjs.map} +0 -0
  62. /package/dist/{chunk-3JNVGW62.mjs.map → chunk-WGS33EWH.mjs.map} +0 -0
  63. /package/dist/{chunk-RJ4D4QWK.mjs.map → chunk-XNU5X7EV.mjs.map} +0 -0
  64. /package/dist/{chunk-YUFYTDRH.mjs.map → chunk-YZDEZ6UI.mjs.map} +0 -0
  65. /package/dist/{chunk-SAE2H2LN.mjs.map → chunk-ZSFVX6FM.mjs.map} +0 -0
  66. /package/dist/{http-A54ZBBAY.mjs.map → http-C2FBHNZG.mjs.map} +0 -0
  67. /package/dist/{import-EA3TB3S2.mjs.map → import-ED6JCPSJ.mjs.map} +0 -0
  68. /package/dist/{mcp-DJDOWHH3.mjs.map → mcp-5JIBER4M.mjs.map} +0 -0
  69. /package/dist/{src-EKPMJRG6.mjs.map → src-WBNM42SL.mjs.map} +0 -0
  70. /package/dist/{stream-import-FQFNRQ2B.mjs.map → stream-import-37U3SROO.mjs.map} +0 -0
  71. /package/dist/{worker-runtime-UH2OBO3T.mjs.map → worker-runtime-6DGYL4TF.mjs.map} +0 -0
@@ -26,7 +26,7 @@ import {
26
26
  getSessionOverview,
27
27
  getWeekdayActivity,
28
28
  searchMessagesByKeywords
29
- } from "./chunk-I7BHOZPX.mjs";
29
+ } from "./chunk-55WR6WKW.mjs";
30
30
 
31
31
  // ../../packages/tools/src/definitions/sql-query.ts
32
32
  var inputSchema = {
@@ -1828,4 +1828,4 @@ export {
1828
1828
  MCP_TOOL_REGISTRY,
1829
1829
  CoreDataProvider
1830
1830
  };
1831
- //# sourceMappingURL=chunk-WQMKKUSD.mjs.map
1831
+ //# sourceMappingURL=chunk-VASK54KT.mjs.map
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  DataDirCompatibilityError,
12
12
  assertDataDirCompatible
13
- } from "./chunk-I7BHOZPX.mjs";
13
+ } from "./chunk-55WR6WKW.mjs";
14
14
 
15
15
  // src/runtime-compat.ts
16
16
  function assertCliDataDirCompatible(pathProvider, kind, options) {
@@ -37,4 +37,4 @@ function formatCliDataDirCompatibilityError(error, runtime) {
37
37
  export {
38
38
  assertCliDataDirCompatible
39
39
  };
40
- //# sourceMappingURL=chunk-3JNVGW62.mjs.map
40
+ //# sourceMappingURL=chunk-WGS33EWH.mjs.map
@@ -8,7 +8,7 @@ import {
8
8
  AGENT_TOOL_REGISTRY,
9
9
  CoreDataProvider,
10
10
  SEMANTIC_SEARCH_TOOL_NAME
11
- } from "./chunk-WQMKKUSD.mjs";
11
+ } from "./chunk-VASK54KT.mjs";
12
12
  import {
13
13
  AgentEventHandler,
14
14
  AiLogger,
@@ -47,7 +47,7 @@ import {
47
47
  runAgentCore,
48
48
  shouldUseChartCapabilityForMessage,
49
49
  wrapWithChartSchemaGate
50
- } from "./chunk-I7BHOZPX.mjs";
50
+ } from "./chunk-55WR6WKW.mjs";
51
51
 
52
52
  // src/ai/logger.ts
53
53
  var logger = null;
@@ -582,4 +582,4 @@ export {
582
582
  closeServerAiLogger,
583
583
  createCliRunAgentStream
584
584
  };
585
- //# sourceMappingURL=chunk-RJ4D4QWK.mjs.map
585
+ //# sourceMappingURL=chunk-XNU5X7EV.mjs.map
@@ -8,14 +8,14 @@ import {
8
8
  closeServerAiLogger,
9
9
  createCliRunAgentStream,
10
10
  initServerAiLogger
11
- } from "./chunk-RJ4D4QWK.mjs";
11
+ } from "./chunk-XNU5X7EV.mjs";
12
12
  import {
13
13
  AGENT_TOOL_REGISTRY,
14
14
  CoreDataProvider
15
- } from "./chunk-WQMKKUSD.mjs";
15
+ } from "./chunk-VASK54KT.mjs";
16
16
  import {
17
17
  assertCliDataDirCompatible
18
- } from "./chunk-3JNVGW62.mjs";
18
+ } from "./chunk-WGS33EWH.mjs";
19
19
  import {
20
20
  getVersion
21
21
  } from "./chunk-5ADKYYNA.mjs";
@@ -25,16 +25,20 @@ import {
25
25
  import {
26
26
  importData,
27
27
  parseFile
28
- } from "./chunk-YUFYTDRH.mjs";
28
+ } from "./chunk-YZDEZ6UI.mjs";
29
29
  import {
30
30
  analyzeIncrementalImport,
31
31
  analyzeNewImport,
32
32
  incrementalImport,
33
33
  streamImport
34
- } from "./chunk-SAE2H2LN.mjs";
34
+ } from "./chunk-ZSFVX6FM.mjs";
35
35
  import {
36
+ AnalyticsService,
37
+ ArchiveImportError,
38
+ ArchiveImportSourceManager,
36
39
  NodePathProvider,
37
40
  PreferencesManager,
41
+ appLogger,
38
42
  applyPendingNodeDataDirMigrationIfNeeded,
39
43
  buildMergedOutput,
40
44
  checkConflictsFromSources,
@@ -50,10 +54,11 @@ import {
50
54
  getPendingNodeDataDirMigration,
51
55
  getSupportedFormats,
52
56
  hasPendingElectronDataWarning,
57
+ initAppLogger,
53
58
  scanMultiChatFile,
54
59
  serializeChatLabToJsonl,
55
60
  streamParseFileInfo
56
- } from "./chunk-N3G43SCQ.mjs";
61
+ } from "./chunk-GPF34WXV.mjs";
57
62
  import {
58
63
  AIChatManager,
59
64
  ALL_MIGRATIONS,
@@ -77,6 +82,7 @@ import {
77
82
  computeWordFrequency,
78
83
  countMessagesTokens,
79
84
  createDatabaseManagerAdapter,
85
+ deleteAuthProfile,
80
86
  deleteDict,
81
87
  downloadDict,
82
88
  ensureDefaultDict,
@@ -143,7 +149,7 @@ import {
143
149
  verifyCliDataPath,
144
150
  writeAuthProfile,
145
151
  writeConfigField
146
- } from "./chunk-I7BHOZPX.mjs";
152
+ } from "./chunk-55WR6WKW.mjs";
147
153
 
148
154
  // src/http/index.ts
149
155
  import * as fs11 from "fs";
@@ -1636,7 +1642,10 @@ function registerSemanticIndexRoutes(server2, ctx) {
1636
1642
  apiKeySet: resolveSemanticIndexApiKeySet(config, ctx.resolveApiKey),
1637
1643
  configured: isSemanticIndexConfigured(config)
1638
1644
  });
1639
- server2.get("/_web/ai/semantic-index/config", async () => configResponse(configStore.get()));
1645
+ server2.get("/_web/ai/semantic-index/config", async () => ({
1646
+ ...configResponse(configStore.get()),
1647
+ modelStatus: "idle"
1648
+ }));
1640
1649
  server2.put(
1641
1650
  "/_web/ai/semantic-index/config",
1642
1651
  async (request) => {
@@ -1644,7 +1653,7 @@ function registerSemanticIndexRoutes(server2, ctx) {
1644
1653
  apiKey: request.body.apiKey,
1645
1654
  writeAuthProfile: ctx.writeAuthProfile
1646
1655
  });
1647
- return configResponse(config);
1656
+ return { ...configResponse(config), modelStatus: "idle" };
1648
1657
  }
1649
1658
  );
1650
1659
  }
@@ -1657,14 +1666,20 @@ function registerSemanticIndexRoutes(server2, ctx) {
1657
1666
  return {
1658
1667
  config: await service.getConfig(),
1659
1668
  apiKeySet: await service.hasApiKey(),
1660
- configured: await service.isConfigured()
1669
+ configured: await service.isConfigured(),
1670
+ modelStatus: await service.getModelStatus()
1661
1671
  };
1662
1672
  });
1663
1673
  server2.put(
1664
1674
  "/_web/ai/semantic-index/config",
1665
1675
  async (request) => {
1666
1676
  const config = await service.setConfig(request.body.config, { apiKey: request.body.apiKey });
1667
- return { config, apiKeySet: await service.hasApiKey(), configured: await service.isConfigured() };
1677
+ return {
1678
+ config,
1679
+ apiKeySet: await service.hasApiKey(),
1680
+ configured: await service.isConfigured(),
1681
+ modelStatus: await service.getModelStatus()
1682
+ };
1668
1683
  }
1669
1684
  );
1670
1685
  server2.get("/_web/ai/semantic-index/enabled", async () => {
@@ -1685,7 +1700,7 @@ function registerSemanticIndexRoutes(server2, ctx) {
1685
1700
  });
1686
1701
  };
1687
1702
  sessionAction("/_web/ai/semantic-index/enable", (id) => service.enable(id));
1688
- sessionAction("/_web/ai/semantic-index/disable", (id) => service.disable(id));
1703
+ sessionAction("/_web/ai/semantic-index/remove", (id) => service.remove(id));
1689
1704
  sessionAction("/_web/ai/semantic-index/build", (id) => service.build(id));
1690
1705
  sessionAction("/_web/ai/semantic-index/pause", (id) => service.pause(id));
1691
1706
  sessionAction("/_web/ai/semantic-index/cancel", (id) => service.cancel(id));
@@ -2128,6 +2143,45 @@ function registerCacheRoutes(server2, ctx) {
2128
2143
  });
2129
2144
  }
2130
2145
 
2146
+ // ../../packages/http-routes/src/routes/web/telemetry.ts
2147
+ function registerTelemetryRoutes(server2, ctx) {
2148
+ server2.get("/_web/telemetry/enabled", async () => {
2149
+ return { enabled: ctx.analyticsService?.getEnabled() ?? false };
2150
+ });
2151
+ server2.post("/_web/telemetry/enabled", async (req) => {
2152
+ if (!ctx.analyticsService || typeof req.body?.enabled !== "boolean") return { success: false };
2153
+ ctx.analyticsService.setEnabled(req.body.enabled);
2154
+ return { success: true };
2155
+ });
2156
+ server2.post(
2157
+ "/_web/telemetry/track",
2158
+ async (req, reply) => {
2159
+ if (!ctx.analyticsService) return { ok: true };
2160
+ const { eventName, properties } = req.body ?? {};
2161
+ if (!eventName) return reply.code(400).send({ error: "eventName required" });
2162
+ if (eventName === "app_active") {
2163
+ await ctx.analyticsService.trackDailyActive(properties);
2164
+ } else {
2165
+ await ctx.analyticsService.track(eventName, properties);
2166
+ }
2167
+ return { ok: true };
2168
+ }
2169
+ );
2170
+ }
2171
+
2172
+ // ../../packages/http-routes/src/routes/web/logs.ts
2173
+ function registerLogRoutes(server2, _ctx) {
2174
+ server2.post("/_web/logs/report", async (req, reply) => {
2175
+ const { level, message, stack, url } = req.body ?? {};
2176
+ if (!message) return reply.code(400).send({ error: "message required" });
2177
+ const detail = [url ? `url=${url}` : null, stack ? `
2178
+ ${stack}` : null].filter(Boolean).join(" ");
2179
+ if (level === "warn") appLogger.warn("web", message, detail || void 0);
2180
+ else appLogger.error("web", message, detail || void 0);
2181
+ return { ok: true };
2182
+ });
2183
+ }
2184
+
2131
2185
  // ../../packages/http-routes/src/register.ts
2132
2186
  function registerSharedRoutes(server2, ctx, options) {
2133
2187
  const resolvedCtx = ctx.preferencesManager ? ctx : { ...ctx, preferencesManager: new PreferencesManager(ctx.pathProvider.getSystemDir()) };
@@ -2166,6 +2220,8 @@ function registerSharedRoutes(server2, ctx, options) {
2166
2220
  registerSemanticIndexRoutes(server2, resolvedCtx);
2167
2221
  registerMergeRoutes(server2, resolvedCtx);
2168
2222
  registerCacheRoutes(server2, resolvedCtx);
2223
+ registerTelemetryRoutes(server2, resolvedCtx);
2224
+ registerLogRoutes(server2, resolvedCtx);
2169
2225
  }
2170
2226
 
2171
2227
  // ../../packages/http-routes/src/auth.ts
@@ -2219,7 +2275,7 @@ function createServer() {
2219
2275
  bodyLimit: JSON_BODY_LIMIT
2220
2276
  });
2221
2277
  server2.addHook("onRequest", authHook);
2222
- server2.setErrorHandler((error, _request, reply) => {
2278
+ server2.setErrorHandler((error, request, reply) => {
2223
2279
  const apiError = apiErrorFromUnknown(error);
2224
2280
  if (apiError) {
2225
2281
  reply.code(apiError.statusCode).send(errorResponse(apiError));
@@ -2235,6 +2291,7 @@ function createServer() {
2235
2291
  reply.code(statusCode).send({ success: false, error: { code: "CLIENT_ERROR", message: error.message } });
2236
2292
  return;
2237
2293
  }
2294
+ appLogger.error("http", `${request.method} ${request.url} -> 500`, error);
2238
2295
  const err = serverError(error.message);
2239
2296
  reply.code(err.statusCode).send(errorResponse(err));
2240
2297
  });
@@ -2249,6 +2306,8 @@ import * as path9 from "path";
2249
2306
  import * as fs6 from "fs";
2250
2307
  import * as os2 from "os";
2251
2308
  import * as path7 from "path";
2309
+ import { randomUUID } from "crypto";
2310
+ import { pipeline } from "stream/promises";
2252
2311
 
2253
2312
  // src/http/routes/web/helpers.ts
2254
2313
  import * as fs5 from "fs";
@@ -2261,6 +2320,7 @@ function resolveNativeBinding() {
2261
2320
 
2262
2321
  // src/http/routes/web/import.ts
2263
2322
  var DEMO_BASE_URL = "https://chatlab.fun/assets/demo";
2323
+ var ARCHIVE_UPLOAD_LIMIT = 50 * 1024 * 1024 * 1024;
2264
2324
  function cleanupTemp(...paths) {
2265
2325
  for (const p of paths) {
2266
2326
  try {
@@ -2274,7 +2334,93 @@ function cleanupTemp(...paths) {
2274
2334
  }
2275
2335
  }
2276
2336
  }
2277
- function registerImportRoutes(server2, dbManager2) {
2337
+ function registerImportRoutes(server2, dbManager2, options = {}) {
2338
+ const sourceManager = options.sourceManager ?? new ArchiveImportSourceManager({
2339
+ tempRoot: fs6.mkdtempSync(path7.join(os2.tmpdir(), "chatlab-import-sources-"))
2340
+ });
2341
+ const runPreparedImport = options.runPreparedImport ?? (async (manifestPath, onProgress) => {
2342
+ const result = await streamImport(dbManager2, manifestPath, {
2343
+ formatId: "google-chat-takeout",
2344
+ nativeBinding: resolveNativeBinding(),
2345
+ onProgress
2346
+ });
2347
+ return {
2348
+ success: result.success,
2349
+ sessionId: result.sessionId,
2350
+ error: result.error,
2351
+ messageCount: result.diagnostics?.messagesWritten ?? 0,
2352
+ memberCount: 0
2353
+ };
2354
+ });
2355
+ server2.addHook("onClose", async () => {
2356
+ await sourceManager.close();
2357
+ });
2358
+ server2.post("/_web/import-sources", async (request, reply) => {
2359
+ const data = await request.file({
2360
+ limits: { fileSize: ARCHIVE_UPLOAD_LIMIT }
2361
+ });
2362
+ if (!data) return reply.code(400).send({ success: false, error: "error.no_file_selected" });
2363
+ const uploadPath = path7.join(os2.tmpdir(), `chatlab-archive-${randomUUID()}.zip`);
2364
+ try {
2365
+ await pipeline(data.file, fs6.createWriteStream(uploadPath, { flags: "wx" }));
2366
+ if (data.file.truncated) {
2367
+ cleanupTemp(uploadPath);
2368
+ return reply.code(413).send({ success: false, error: "error.archive_limit_exceeded" });
2369
+ }
2370
+ const source = await sourceManager.prepareOwnedArchive(uploadPath);
2371
+ return { success: true, source };
2372
+ } catch (error) {
2373
+ cleanupTemp(uploadPath);
2374
+ if (error instanceof ArchiveImportError) {
2375
+ return reply.code(400).send({ success: false, error: error.code });
2376
+ }
2377
+ return reply.code(400).send({
2378
+ success: false,
2379
+ error: error instanceof Error ? error.message : String(error)
2380
+ });
2381
+ }
2382
+ });
2383
+ server2.post(
2384
+ "/_web/import-sources/:sourceId/import",
2385
+ async (request, reply) => {
2386
+ const chatId = request.body?.chatId;
2387
+ if (!chatId) return reply.code(400).send({ success: false, error: "error.no_chat_selected" });
2388
+ reply.raw.writeHead(200, {
2389
+ "Content-Type": "text/event-stream",
2390
+ "Cache-Control": "no-cache",
2391
+ Connection: "keep-alive"
2392
+ });
2393
+ function sendEvent(event, eventData) {
2394
+ reply.raw.write(`event: ${event}
2395
+ data: ${JSON.stringify(eventData)}
2396
+
2397
+ `);
2398
+ }
2399
+ try {
2400
+ const result = await sourceManager.withMaterializedChat(
2401
+ request.params.sourceId,
2402
+ chatId,
2403
+ (manifestPath) => runPreparedImport(manifestPath, (progress) => sendEvent("progress", progress))
2404
+ );
2405
+ if (result.success) {
2406
+ sendEvent("done", result);
2407
+ } else {
2408
+ sendEvent("error", { success: false, error: result.error || "error.import_failed" });
2409
+ }
2410
+ } catch (error) {
2411
+ sendEvent("error", {
2412
+ success: false,
2413
+ error: error instanceof ArchiveImportError ? error.code : error instanceof Error ? error.message : String(error)
2414
+ });
2415
+ } finally {
2416
+ reply.raw.end();
2417
+ }
2418
+ }
2419
+ );
2420
+ server2.delete("/_web/import-sources/:sourceId", async (request) => {
2421
+ await sourceManager.release(request.params.sourceId);
2422
+ return { success: true };
2423
+ });
2278
2424
  server2.get("/_web/supported-formats", async () => {
2279
2425
  return getSupportedFormats();
2280
2426
  });
@@ -2639,7 +2785,7 @@ function registerWebRoutes(server2, dbManager2, options) {
2639
2785
  const resolvedPathProvider = options?.pathProvider ?? fallbackPathProvider;
2640
2786
  const ai = options?.aiContext;
2641
2787
  const cliStreamImport = async (dm, filePath) => {
2642
- const { streamImport: streamImport2 } = await import("./stream-import-FQFNRQ2B.mjs");
2788
+ const { streamImport: streamImport2 } = await import("./stream-import-37U3SROO.mjs");
2643
2789
  const result = await streamImport2(dm, filePath);
2644
2790
  if (!result.sessionId) throw new Error("Import succeeded but no sessionId returned");
2645
2791
  return { sessionId: result.sessionId };
@@ -2647,6 +2793,7 @@ function registerWebRoutes(server2, dbManager2, options) {
2647
2793
  const defaultUserDataDir = getDefaultNodeUserDataDir();
2648
2794
  const isCustom = path9.resolve(resolvedPathProvider.getUserDataDir()) !== path9.resolve(defaultUserDataDir);
2649
2795
  const semanticIndexService = options?.semanticIndexService;
2796
+ const analyticsService = "A-US-0629338532" ? new AnalyticsService(resolvedPathProvider.getSystemDir(), "A-US-0629338532", getVersion()) : void 0;
2650
2797
  registerSharedRoutes(
2651
2798
  server2,
2652
2799
  {
@@ -2656,6 +2803,7 @@ function registerWebRoutes(server2, dbManager2, options) {
2656
2803
  getVersion,
2657
2804
  nativeBinding: options?.nativeBinding,
2658
2805
  semanticIndexService,
2806
+ analyticsService,
2659
2807
  openDirectory: openDirectoryPath,
2660
2808
  showInFolder: showPathInFolder,
2661
2809
  downloadsDir: resolvedPathProvider.getDownloadsDir(),
@@ -2740,7 +2888,7 @@ function registerProxyRoutes(server2) {
2740
2888
  // src/ai/manager-factory.ts
2741
2889
  import * as fs7 from "fs";
2742
2890
  import * as path10 from "path";
2743
- import { createHash, randomUUID } from "crypto";
2891
+ import { createHash, randomUUID as randomUUID2 } from "crypto";
2744
2892
  var nodeFs = {
2745
2893
  ensureDir(dir) {
2746
2894
  if (!fs7.existsSync(dir)) fs7.mkdirSync(dir, { recursive: true });
@@ -2774,7 +2922,7 @@ function getAssistantManager(aiDataDir) {
2774
2922
  fs: nodeFs,
2775
2923
  assistantsDir: path10.join(aiDataDir, "assistants"),
2776
2924
  builtinRawConfigs: [],
2777
- generateId: () => `custom_${randomUUID().replace(/-/g, "").slice(0, 12)}`
2925
+ generateId: () => `custom_${randomUUID2().replace(/-/g, "").slice(0, 12)}`
2778
2926
  }),
2779
2927
  skill: new SkillManagerCore({
2780
2928
  fs: nodeFs,
@@ -3817,9 +3965,15 @@ async function startHttpServer(options) {
3817
3965
  const profileName = config2.name?.toLowerCase().replace(/\s+/g, "-") || config2.provider;
3818
3966
  writeAuthProfile(profileName, { type: "api_key", provider: config2.provider, key: apiKey });
3819
3967
  return profileName;
3968
+ },
3969
+ onApiKeyDeleted: (config2) => {
3970
+ const profileName = config2.authProfile;
3971
+ if (profileName) deleteAuthProfile(profileName);
3820
3972
  }
3821
3973
  });
3974
+ initAppLogger(pathProvider.getLogsDir());
3822
3975
  initServerAiLogger(pathProvider.getLogsDir());
3976
+ appLogger.info("server", `HTTP server starting on ${host}:${port}`);
3823
3977
  setAuthToken(token);
3824
3978
  setRequireAuth(!!(options?.requireAuth ?? config.api.require_auth));
3825
3979
  server = createServer();
@@ -3898,4 +4052,4 @@ export {
3898
4052
  startHttpServer,
3899
4053
  stopHttpServer
3900
4054
  };
3901
- //# sourceMappingURL=chunk-SIVERPF5.mjs.map
4055
+ //# sourceMappingURL=chunk-YQ2FJGBT.mjs.map