@threadbase-sh/streamer 1.24.0 → 1.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1369,6 +1369,11 @@ function buildSpawnEnv() {
1369
1369
  if (env.CLAUDE_API_KEY) {
1370
1370
  env.ANTHROPIC_API_KEY = env.CLAUDE_API_KEY;
1371
1371
  }
1372
+ for (const key of Object.keys(env)) {
1373
+ if (key === "CLAUDECODE" || key.startsWith("CLAUDE_CODE_")) {
1374
+ delete env[key];
1375
+ }
1376
+ }
1372
1377
  return env;
1373
1378
  }
1374
1379
  var PTYManager = class {
@@ -4822,6 +4827,11 @@ var StreamerServer = class {
4822
4827
  // /input { keys }. Cleared when the gate closes.
4823
4828
  pendingPermission = /* @__PURE__ */ new Map();
4824
4829
  scanner = null;
4830
+ // Set when better-sqlite3 is unusable (e.g. node ABI mismatch made
4831
+ // ConversationCache.open throw). All scanners are then built with
4832
+ // persistent: false so requests serve from disk instead of 500ing on
4833
+ // every touch of the scanner's own SQLite index.
4834
+ scannerPersistenceDisabled = false;
4825
4835
  // Tracks every ConversationScanner ever created so close() can shut them all
4826
4836
  // down and release SQLite handles (open handles block temp-dir deletion on Windows).
4827
4837
  allScanners = /* @__PURE__ */ new Set();
@@ -5321,11 +5331,12 @@ var StreamerServer = class {
5321
5331
  const message = err instanceof Error ? err.message : String(err);
5322
5332
  const abiMismatch = message.includes("NODE_MODULE_VERSION") || message.includes("was compiled against a different Node.js version");
5323
5333
  this.log.error(
5324
- `ConversationCache failed to open \u2014 running WITHOUT cache; /api/conversations, /api/conversations/count and /project-chats will 500.` + (abiMismatch ? ` Fix: npm rebuild better-sqlite3` : "") + ` (${message})`,
5334
+ `ConversationCache failed to open \u2014 running WITHOUT cache; /api/conversations, /api/conversations/count and /project-chats serve from disk (degraded).` + (abiMismatch ? ` Fix: npm rebuild better-sqlite3` : "") + ` (${message})`,
5325
5335
  { error: message, abiMismatch, event: "cache.open_failed" }
5326
5336
  );
5337
+ this.scannerPersistenceDisabled = true;
5327
5338
  }
5328
- const warmupScanner = new import_scanner2.ConversationScanner();
5339
+ const warmupScanner = this.newScanner();
5329
5340
  this.allScanners.add(warmupScanner);
5330
5341
  const warmupStatCache = this.buildStatCache(null);
5331
5342
  const shouldEmitProgress = createScanProgressThrottle();
@@ -5342,6 +5353,10 @@ var StreamerServer = class {
5342
5353
  }
5343
5354
  }
5344
5355
  }).then(async () => {
5356
+ if (!this.scannerReady && !this.scanner) {
5357
+ this.scanner = warmupScanner;
5358
+ this.scannerReady = Promise.resolve();
5359
+ }
5345
5360
  if (!this.cache) return;
5346
5361
  const metas = [...warmupScanner.getMetadataCache().values()];
5347
5362
  const upsertedIds = new Set(this.cache.upsertFromScannerMeta(metas));
@@ -5390,10 +5405,6 @@ var StreamerServer = class {
5390
5405
  event: "cache.warmup_failed"
5391
5406
  });
5392
5407
  }).finally(() => {
5393
- if (!this.scannerReady && !this.scanner) {
5394
- this.scanner = warmupScanner;
5395
- this.scannerReady = Promise.resolve();
5396
- }
5397
5408
  this.cacheReady = true;
5398
5409
  this.wsHub.broadcast({ type: "cache_ready" });
5399
5410
  resolveWarm();
@@ -5776,6 +5787,11 @@ var StreamerServer = class {
5776
5787
  // this — its per-file refreshFile (in findConversationByUuid) already
5777
5788
  // reconciles the one conversation being requested, so paying a full-tree
5778
5789
  // rescan just because some OTHER file changed is the stall this avoids.
5790
+ newScanner() {
5791
+ return new import_scanner2.ConversationScanner(
5792
+ this.scannerPersistenceDisabled ? { persistent: false } : void 0
5793
+ );
5794
+ }
5779
5795
  async getScanner(skipStaleRescan = false) {
5780
5796
  if (this.scannerReady) {
5781
5797
  await this.scannerReady;
@@ -5792,14 +5808,20 @@ var StreamerServer = class {
5792
5808
  }
5793
5809
  this.scannerStale = false;
5794
5810
  const statCache = this.buildStatCache(this.scanner);
5795
- this.scanner = new import_scanner2.ConversationScanner();
5811
+ this.scanner = this.newScanner();
5796
5812
  this.allScanners.add(this.scanner);
5797
5813
  this.scannerReady = this.scanner.scan({
5798
5814
  ...this.scanProfiles ? { profiles: this.scanProfiles } : {},
5799
5815
  ...this.codexScanOpts(),
5800
5816
  ...statCache ? { statCache } : {}
5801
5817
  });
5802
- await this.scannerReady;
5818
+ try {
5819
+ await this.scannerReady;
5820
+ } catch (err) {
5821
+ this.scanner = null;
5822
+ this.scannerReady = null;
5823
+ throw err;
5824
+ }
5803
5825
  const scanner = this.scanner;
5804
5826
  if (!scanner) return this.getScanner();
5805
5827
  return scanner;
@@ -5854,7 +5876,7 @@ var StreamerServer = class {
5854
5876
  const filePath2 = this.findJsonlPath(uuid);
5855
5877
  if (filePath2) {
5856
5878
  const account = this.cache?.getMetaById(uuid)?.account ?? void 0;
5857
- const coldScanner = this.scanner ?? new import_scanner2.ConversationScanner();
5879
+ const coldScanner = this.scanner ?? this.newScanner();
5858
5880
  const page = await coldScanner.parseSingleFilePage(filePath2, account, {
5859
5881
  limit: Number.MAX_SAFE_INTEGER
5860
5882
  });