@mindstudio-ai/local-model-tunnel 0.5.51 → 0.5.53

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.
@@ -289,16 +289,16 @@ var DevPollError = class extends Error {
289
289
  import fs2 from "fs";
290
290
  import { join as join2 } from "path";
291
291
  var NdjsonLog = class {
292
- constructor(filename, maxLines = 500, keepLines = 300, maxBytes = 2 * 1024 * 1024) {
292
+ constructor(filename, maxLines = 500, maxBytes = 2 * 1024 * 1024, keepBytes = 1 * 1024 * 1024) {
293
293
  this.filename = filename;
294
294
  this.maxLines = maxLines;
295
- this.keepLines = keepLines;
296
295
  this.maxBytes = maxBytes;
296
+ this.keepBytes = keepBytes;
297
297
  }
298
298
  filename;
299
299
  maxLines;
300
- keepLines;
301
300
  maxBytes;
301
+ keepBytes;
302
302
  fd = null;
303
303
  logPath = null;
304
304
  lineCount = 0;
@@ -316,6 +316,7 @@ var NdjsonLog = class {
316
316
  this.lineCount = 0;
317
317
  }
318
318
  this.fd = fs2.openSync(this.logPath, "a");
319
+ this.maybeRotate();
319
320
  log.debug("logging", `${this.filename} log initialized`, {
320
321
  path: this.logPath,
321
322
  existingEntries: this.lineCount
@@ -362,7 +363,14 @@ var NdjsonLog = class {
362
363
  this.rotating = true;
363
364
  const content = fs2.readFileSync(this.logPath, "utf-8");
364
365
  const lines = content.split("\n").filter((l) => l.trim());
365
- const kept = lines.slice(-this.keepLines);
366
+ const kept = [];
367
+ let bytes = 0;
368
+ for (let i = lines.length - 1; i >= 0; i--) {
369
+ const lineBytes = Buffer.byteLength(lines[i], "utf-8") + 1;
370
+ if (bytes + lineBytes > this.keepBytes && kept.length > 0) break;
371
+ kept.unshift(lines[i]);
372
+ bytes += lineBytes;
373
+ }
366
374
  fs2.closeSync(this.fd);
367
375
  fs2.writeFileSync(this.logPath, kept.join("\n") + "\n", "utf-8");
368
376
  this.fd = fs2.openSync(this.logPath, "a");
@@ -3401,4 +3409,4 @@ export {
3401
3409
  watchTableFiles,
3402
3410
  watchConfigFile
3403
3411
  };
3404
- //# sourceMappingURL=chunk-ZLWMDAZU.js.map
3412
+ //# sourceMappingURL=chunk-4HSYB4GX.js.map