@threadbase-sh/streamer 1.31.0 → 1.31.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
@@ -29489,6 +29489,7 @@ var require_receiver = __commonJS({
29489
29489
  this._opcode = 0;
29490
29490
  this._totalPayloadLength = 0;
29491
29491
  this._messageLength = 0;
29492
+ this._numFragments = 0;
29492
29493
  this._fragments = [];
29493
29494
  this._errored = false;
29494
29495
  this._loop = false;
@@ -29839,23 +29840,23 @@ var require_receiver = __commonJS({
29839
29840
  this.controlMessage(data, cb2);
29840
29841
  return;
29841
29842
  }
29843
+ if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
29844
+ const error51 = this.createError(
29845
+ RangeError,
29846
+ "Too many message fragments",
29847
+ false,
29848
+ 1008,
29849
+ "WS_ERR_TOO_MANY_BUFFERED_PARTS"
29850
+ );
29851
+ cb2(error51);
29852
+ return;
29853
+ }
29842
29854
  if (this._compressed) {
29843
29855
  this._state = INFLATING;
29844
29856
  this.decompress(data, cb2);
29845
29857
  return;
29846
29858
  }
29847
29859
  if (data.length) {
29848
- if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
29849
- const error51 = this.createError(
29850
- RangeError,
29851
- "Too many message fragments",
29852
- false,
29853
- 1008,
29854
- "WS_ERR_TOO_MANY_BUFFERED_PARTS"
29855
- );
29856
- cb2(error51);
29857
- return;
29858
- }
29859
29860
  this._messageLength = this._totalPayloadLength;
29860
29861
  this._fragments.push(data);
29861
29862
  }
@@ -29885,17 +29886,6 @@ var require_receiver = __commonJS({
29885
29886
  cb2(error51);
29886
29887
  return;
29887
29888
  }
29888
- if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
29889
- const error51 = this.createError(
29890
- RangeError,
29891
- "Too many message fragments",
29892
- false,
29893
- 1008,
29894
- "WS_ERR_TOO_MANY_BUFFERED_PARTS"
29895
- );
29896
- cb2(error51);
29897
- return;
29898
- }
29899
29889
  this._fragments.push(buf);
29900
29890
  }
29901
29891
  this.dataMessage(cb2);
@@ -29918,6 +29908,7 @@ var require_receiver = __commonJS({
29918
29908
  this._totalPayloadLength = 0;
29919
29909
  this._messageLength = 0;
29920
29910
  this._fragmented = 0;
29911
+ this._numFragments = 0;
29921
29912
  this._fragments = [];
29922
29913
  if (this._opcode === 2) {
29923
29914
  let data;
@@ -31418,8 +31409,8 @@ var require_websocket = __commonJS({
31418
31409
  autoPong: true,
31419
31410
  closeTimeout: CLOSE_TIMEOUT,
31420
31411
  protocolVersion: protocolVersions[1],
31421
- maxBufferedChunks: 1024 * 1024,
31422
- maxFragments: 128 * 1024,
31412
+ maxBufferedChunks: 256 * 1024,
31413
+ maxFragments: 16 * 1024,
31423
31414
  maxPayload: 100 * 1024 * 1024,
31424
31415
  skipUTF8Validation: false,
31425
31416
  perMessageDeflate: true,
@@ -32006,9 +31997,9 @@ var require_websocket_server = __commonJS({
32006
31997
  * called
32007
31998
  * @param {Function} [options.handleProtocols] A hook to handle protocols
32008
31999
  * @param {String} [options.host] The hostname where to bind the server
32009
- * @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
32000
+ * @param {Number} [options.maxBufferedChunks=262144] The maximum number of
32010
32001
  * buffered data chunks
32011
- * @param {Number} [options.maxFragments=131072] The maximum number of message
32002
+ * @param {Number} [options.maxFragments=16384] The maximum number of message
32012
32003
  * fragments
32013
32004
  * @param {Number} [options.maxPayload=104857600] The maximum allowed message
32014
32005
  * size
@@ -32031,8 +32022,8 @@ var require_websocket_server = __commonJS({
32031
32022
  options = {
32032
32023
  allowSynchronousEvents: true,
32033
32024
  autoPong: true,
32034
- maxBufferedChunks: 1024 * 1024,
32035
- maxFragments: 128 * 1024,
32025
+ maxBufferedChunks: 256 * 1024,
32026
+ maxFragments: 16 * 1024,
32036
32027
  maxPayload: 100 * 1024 * 1024,
32037
32028
  skipUTF8Validation: false,
32038
32029
  perMessageDeflate: false,
@@ -145337,14 +145328,8 @@ var StreamerServer = class {
145337
145328
  this.conversationsRepo = new ConversationsRepository(this.cache);
145338
145329
  this.sessionsRepo = new SessionsRepository(this.sessionStore);
145339
145330
  this.cacheMetadataRepo = new CacheMetadataRepository(db);
145340
- if (this.scanProfiles && this.scanProfiles.length > 0) {
145341
- for (const profile of this.scanProfiles) {
145342
- if (profile.enabled) {
145343
- this.fileWatcher.watchDirectory((0, import_path23.join)(profile.configDir, "projects"));
145344
- }
145345
- }
145346
- } else {
145347
- this.fileWatcher.watchDirectory((0, import_path23.join)((0, import_os11.homedir)(), ".claude", "projects"));
145331
+ for (const dir of this.projectsDirs()) {
145332
+ this.fileWatcher.watchDirectory(dir);
145348
145333
  }
145349
145334
  } catch (err) {
145350
145335
  const message = err instanceof Error ? err.message : String(err);
@@ -145925,20 +145910,35 @@ var StreamerServer = class {
145925
145910
  await this.scannerReady;
145926
145911
  return scanner;
145927
145912
  }
145913
+ /**
145914
+ * The projects dirs disk discovery should walk — the single source of truth
145915
+ * for "where do this server's JSONLs live", mirroring the warm-up watcher
145916
+ * (see listen()). Derived from the enabled scanProfiles' configDirs, or the
145917
+ * real ~/.claude/projects when no profiles are configured. An all-disabled
145918
+ * profile set intentionally yields [] (nothing to discover), matching the
145919
+ * watcher — it does NOT fall back to home in that case.
145920
+ */
145921
+ projectsDirs() {
145922
+ if (this.scanProfiles && this.scanProfiles.length > 0) {
145923
+ return this.scanProfiles.filter((p2) => p2.enabled).map((p2) => (0, import_path23.join)(p2.configDir, "projects"));
145924
+ }
145925
+ return [(0, import_path23.join)((0, import_os11.homedir)(), ".claude", "projects")];
145926
+ }
145928
145927
  findJsonlPath(uuid3) {
145929
- const projectsDir = (0, import_path23.join)((0, import_os11.homedir)(), ".claude", "projects");
145930
- if (!(0, import_fs26.existsSync)(projectsDir)) return null;
145931
145928
  const filename = `${uuid3}.jsonl`;
145932
- for (const dir of (0, import_fs26.readdirSync)(projectsDir)) {
145933
- const fp = (0, import_path23.join)(projectsDir, dir, filename);
145934
- if ((0, import_fs26.existsSync)(fp)) return fp;
145935
- const projectDir = (0, import_path23.join)(projectsDir, dir);
145936
- try {
145937
- for (const sub of (0, import_fs26.readdirSync)(projectDir)) {
145938
- const subagentPath = (0, import_path23.join)(projectDir, sub, "subagents", filename);
145939
- if ((0, import_fs26.existsSync)(subagentPath)) return subagentPath;
145929
+ for (const projectsDir of this.projectsDirs()) {
145930
+ if (!(0, import_fs26.existsSync)(projectsDir)) continue;
145931
+ for (const dir of (0, import_fs26.readdirSync)(projectsDir)) {
145932
+ const fp = (0, import_path23.join)(projectsDir, dir, filename);
145933
+ if ((0, import_fs26.existsSync)(fp)) return fp;
145934
+ const projectDir = (0, import_path23.join)(projectsDir, dir);
145935
+ try {
145936
+ for (const sub of (0, import_fs26.readdirSync)(projectDir)) {
145937
+ const subagentPath = (0, import_path23.join)(projectDir, sub, "subagents", filename);
145938
+ if ((0, import_fs26.existsSync)(subagentPath)) return subagentPath;
145939
+ }
145940
+ } catch {
145940
145941
  }
145941
- } catch {
145942
145942
  }
145943
145943
  }
145944
145944
  return null;
@@ -146485,7 +146485,10 @@ var StreamerServer = class {
146485
146485
  const projectPath = jsonlCwd ?? conv?.projectPath;
146486
146486
  if (!projectPath) {
146487
146487
  if (!conv && !jsonlPath) {
146488
- json2(res, 404, { error: "Conversation not found" });
146488
+ json2(res, 404, {
146489
+ error: "Conversation history file is missing; it can no longer be resumed",
146490
+ code: "history_file_missing"
146491
+ });
146489
146492
  return;
146490
146493
  }
146491
146494
  json2(res, 400, { error: "Could not determine project path" });