@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/cli.cjs CHANGED
@@ -139021,6 +139021,11 @@ function buildSpawnEnv() {
139021
139021
  if (env.CLAUDE_API_KEY) {
139022
139022
  env.ANTHROPIC_API_KEY = env.CLAUDE_API_KEY;
139023
139023
  }
139024
+ for (const key of Object.keys(env)) {
139025
+ if (key === "CLAUDECODE" || key.startsWith("CLAUDE_CODE_")) {
139026
+ delete env[key];
139027
+ }
139028
+ }
139024
139029
  return env;
139025
139030
  }
139026
139031
  var PTYManager = class {
@@ -142604,6 +142609,11 @@ var StreamerServer = class {
142604
142609
  // /input { keys }. Cleared when the gate closes.
142605
142610
  pendingPermission = /* @__PURE__ */ new Map();
142606
142611
  scanner = null;
142612
+ // Set when better-sqlite3 is unusable (e.g. node ABI mismatch made
142613
+ // ConversationCache.open throw). All scanners are then built with
142614
+ // persistent: false so requests serve from disk instead of 500ing on
142615
+ // every touch of the scanner's own SQLite index.
142616
+ scannerPersistenceDisabled = false;
142607
142617
  // Tracks every ConversationScanner ever created so close() can shut them all
142608
142618
  // down and release SQLite handles (open handles block temp-dir deletion on Windows).
142609
142619
  allScanners = /* @__PURE__ */ new Set();
@@ -143103,11 +143113,12 @@ var StreamerServer = class {
143103
143113
  const message = err instanceof Error ? err.message : String(err);
143104
143114
  const abiMismatch = message.includes("NODE_MODULE_VERSION") || message.includes("was compiled against a different Node.js version");
143105
143115
  this.log.error(
143106
- `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})`,
143116
+ `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})`,
143107
143117
  { error: message, abiMismatch, event: "cache.open_failed" }
143108
143118
  );
143119
+ this.scannerPersistenceDisabled = true;
143109
143120
  }
143110
- const warmupScanner = new ConversationScanner();
143121
+ const warmupScanner = this.newScanner();
143111
143122
  this.allScanners.add(warmupScanner);
143112
143123
  const warmupStatCache = this.buildStatCache(null);
143113
143124
  const shouldEmitProgress = createScanProgressThrottle();
@@ -143124,6 +143135,10 @@ var StreamerServer = class {
143124
143135
  }
143125
143136
  }
143126
143137
  }).then(async () => {
143138
+ if (!this.scannerReady && !this.scanner) {
143139
+ this.scanner = warmupScanner;
143140
+ this.scannerReady = Promise.resolve();
143141
+ }
143127
143142
  if (!this.cache) return;
143128
143143
  const metas = [...warmupScanner.getMetadataCache().values()];
143129
143144
  const upsertedIds = new Set(this.cache.upsertFromScannerMeta(metas));
@@ -143172,10 +143187,6 @@ var StreamerServer = class {
143172
143187
  event: "cache.warmup_failed"
143173
143188
  });
143174
143189
  }).finally(() => {
143175
- if (!this.scannerReady && !this.scanner) {
143176
- this.scanner = warmupScanner;
143177
- this.scannerReady = Promise.resolve();
143178
- }
143179
143190
  this.cacheReady = true;
143180
143191
  this.wsHub.broadcast({ type: "cache_ready" });
143181
143192
  resolveWarm();
@@ -143558,6 +143569,11 @@ var StreamerServer = class {
143558
143569
  // this — its per-file refreshFile (in findConversationByUuid) already
143559
143570
  // reconciles the one conversation being requested, so paying a full-tree
143560
143571
  // rescan just because some OTHER file changed is the stall this avoids.
143572
+ newScanner() {
143573
+ return new ConversationScanner(
143574
+ this.scannerPersistenceDisabled ? { persistent: false } : void 0
143575
+ );
143576
+ }
143561
143577
  async getScanner(skipStaleRescan = false) {
143562
143578
  if (this.scannerReady) {
143563
143579
  await this.scannerReady;
@@ -143574,14 +143590,20 @@ var StreamerServer = class {
143574
143590
  }
143575
143591
  this.scannerStale = false;
143576
143592
  const statCache = this.buildStatCache(this.scanner);
143577
- this.scanner = new ConversationScanner();
143593
+ this.scanner = this.newScanner();
143578
143594
  this.allScanners.add(this.scanner);
143579
143595
  this.scannerReady = this.scanner.scan({
143580
143596
  ...this.scanProfiles ? { profiles: this.scanProfiles } : {},
143581
143597
  ...this.codexScanOpts(),
143582
143598
  ...statCache ? { statCache } : {}
143583
143599
  });
143584
- await this.scannerReady;
143600
+ try {
143601
+ await this.scannerReady;
143602
+ } catch (err) {
143603
+ this.scanner = null;
143604
+ this.scannerReady = null;
143605
+ throw err;
143606
+ }
143585
143607
  const scanner = this.scanner;
143586
143608
  if (!scanner) return this.getScanner();
143587
143609
  return scanner;
@@ -143636,7 +143658,7 @@ var StreamerServer = class {
143636
143658
  const filePath2 = this.findJsonlPath(uuid3);
143637
143659
  if (filePath2) {
143638
143660
  const account = this.cache?.getMetaById(uuid3)?.account ?? void 0;
143639
- const coldScanner = this.scanner ?? new ConversationScanner();
143661
+ const coldScanner = this.scanner ?? this.newScanner();
143640
143662
  const page = await coldScanner.parseSingleFilePage(filePath2, account, {
143641
143663
  limit: Number.MAX_SAFE_INTEGER
143642
143664
  });