@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.d.cts CHANGED
@@ -832,6 +832,7 @@ declare class StreamerServer {
832
832
  private pendingQuestionKey;
833
833
  private pendingPermission;
834
834
  private scanner;
835
+ private scannerPersistenceDisabled;
835
836
  private allScanners;
836
837
  private scannerReady;
837
838
  private scannerStale;
@@ -911,6 +912,7 @@ declare class StreamerServer {
911
912
  private handleGetPopularProjects;
912
913
  private buildStatCache;
913
914
  private codexScanOpts;
915
+ private newScanner;
914
916
  private getScanner;
915
917
  private getFreshScanner;
916
918
  private findJsonlPath;
package/dist/index.d.ts CHANGED
@@ -832,6 +832,7 @@ declare class StreamerServer {
832
832
  private pendingQuestionKey;
833
833
  private pendingPermission;
834
834
  private scanner;
835
+ private scannerPersistenceDisabled;
835
836
  private allScanners;
836
837
  private scannerReady;
837
838
  private scannerStale;
@@ -911,6 +912,7 @@ declare class StreamerServer {
911
912
  private handleGetPopularProjects;
912
913
  private buildStatCache;
913
914
  private codexScanOpts;
915
+ private newScanner;
914
916
  private getScanner;
915
917
  private getFreshScanner;
916
918
  private findJsonlPath;
package/dist/index.js CHANGED
@@ -1317,6 +1317,11 @@ function buildSpawnEnv() {
1317
1317
  if (env.CLAUDE_API_KEY) {
1318
1318
  env.ANTHROPIC_API_KEY = env.CLAUDE_API_KEY;
1319
1319
  }
1320
+ for (const key of Object.keys(env)) {
1321
+ if (key === "CLAUDECODE" || key.startsWith("CLAUDE_CODE_")) {
1322
+ delete env[key];
1323
+ }
1324
+ }
1320
1325
  return env;
1321
1326
  }
1322
1327
  var PTYManager = class {
@@ -4783,6 +4788,11 @@ var StreamerServer = class {
4783
4788
  // /input { keys }. Cleared when the gate closes.
4784
4789
  pendingPermission = /* @__PURE__ */ new Map();
4785
4790
  scanner = null;
4791
+ // Set when better-sqlite3 is unusable (e.g. node ABI mismatch made
4792
+ // ConversationCache.open throw). All scanners are then built with
4793
+ // persistent: false so requests serve from disk instead of 500ing on
4794
+ // every touch of the scanner's own SQLite index.
4795
+ scannerPersistenceDisabled = false;
4786
4796
  // Tracks every ConversationScanner ever created so close() can shut them all
4787
4797
  // down and release SQLite handles (open handles block temp-dir deletion on Windows).
4788
4798
  allScanners = /* @__PURE__ */ new Set();
@@ -5282,11 +5292,12 @@ var StreamerServer = class {
5282
5292
  const message = err instanceof Error ? err.message : String(err);
5283
5293
  const abiMismatch = message.includes("NODE_MODULE_VERSION") || message.includes("was compiled against a different Node.js version");
5284
5294
  this.log.error(
5285
- `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})`,
5295
+ `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})`,
5286
5296
  { error: message, abiMismatch, event: "cache.open_failed" }
5287
5297
  );
5298
+ this.scannerPersistenceDisabled = true;
5288
5299
  }
5289
- const warmupScanner = new ConversationScanner();
5300
+ const warmupScanner = this.newScanner();
5290
5301
  this.allScanners.add(warmupScanner);
5291
5302
  const warmupStatCache = this.buildStatCache(null);
5292
5303
  const shouldEmitProgress = createScanProgressThrottle();
@@ -5303,6 +5314,10 @@ var StreamerServer = class {
5303
5314
  }
5304
5315
  }
5305
5316
  }).then(async () => {
5317
+ if (!this.scannerReady && !this.scanner) {
5318
+ this.scanner = warmupScanner;
5319
+ this.scannerReady = Promise.resolve();
5320
+ }
5306
5321
  if (!this.cache) return;
5307
5322
  const metas = [...warmupScanner.getMetadataCache().values()];
5308
5323
  const upsertedIds = new Set(this.cache.upsertFromScannerMeta(metas));
@@ -5351,10 +5366,6 @@ var StreamerServer = class {
5351
5366
  event: "cache.warmup_failed"
5352
5367
  });
5353
5368
  }).finally(() => {
5354
- if (!this.scannerReady && !this.scanner) {
5355
- this.scanner = warmupScanner;
5356
- this.scannerReady = Promise.resolve();
5357
- }
5358
5369
  this.cacheReady = true;
5359
5370
  this.wsHub.broadcast({ type: "cache_ready" });
5360
5371
  resolveWarm();
@@ -5737,6 +5748,11 @@ var StreamerServer = class {
5737
5748
  // this — its per-file refreshFile (in findConversationByUuid) already
5738
5749
  // reconciles the one conversation being requested, so paying a full-tree
5739
5750
  // rescan just because some OTHER file changed is the stall this avoids.
5751
+ newScanner() {
5752
+ return new ConversationScanner(
5753
+ this.scannerPersistenceDisabled ? { persistent: false } : void 0
5754
+ );
5755
+ }
5740
5756
  async getScanner(skipStaleRescan = false) {
5741
5757
  if (this.scannerReady) {
5742
5758
  await this.scannerReady;
@@ -5753,14 +5769,20 @@ var StreamerServer = class {
5753
5769
  }
5754
5770
  this.scannerStale = false;
5755
5771
  const statCache = this.buildStatCache(this.scanner);
5756
- this.scanner = new ConversationScanner();
5772
+ this.scanner = this.newScanner();
5757
5773
  this.allScanners.add(this.scanner);
5758
5774
  this.scannerReady = this.scanner.scan({
5759
5775
  ...this.scanProfiles ? { profiles: this.scanProfiles } : {},
5760
5776
  ...this.codexScanOpts(),
5761
5777
  ...statCache ? { statCache } : {}
5762
5778
  });
5763
- await this.scannerReady;
5779
+ try {
5780
+ await this.scannerReady;
5781
+ } catch (err) {
5782
+ this.scanner = null;
5783
+ this.scannerReady = null;
5784
+ throw err;
5785
+ }
5764
5786
  const scanner = this.scanner;
5765
5787
  if (!scanner) return this.getScanner();
5766
5788
  return scanner;
@@ -5815,7 +5837,7 @@ var StreamerServer = class {
5815
5837
  const filePath2 = this.findJsonlPath(uuid);
5816
5838
  if (filePath2) {
5817
5839
  const account = this.cache?.getMetaById(uuid)?.account ?? void 0;
5818
- const coldScanner = this.scanner ?? new ConversationScanner();
5840
+ const coldScanner = this.scanner ?? this.newScanner();
5819
5841
  const page = await coldScanner.parseSingleFilePage(filePath2, account, {
5820
5842
  limit: Number.MAX_SAFE_INTEGER
5821
5843
  });