lody 0.79.0 → 0.79.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.
@@ -76,7 +76,7 @@ let __tla = Promise.all([
76
76
  }
77
77
  })()
78
78
  ]).then(async () => {
79
- const reviewViewerVersion = "0.79.0";
79
+ const reviewViewerVersion = "0.79.2";
80
80
  const reviewViewerSha256 = "41b6ffd0acff2c355e190b604776a89138f9598a1772d09390a6d5af514e71bb";
81
81
  const reviewViewerFileName = "standalone.html";
82
82
  const DEFAULT_CDN_BASES = [
package/dist/index.js CHANGED
@@ -23229,7 +23229,7 @@ ${context2.authorReply.trim()}
23229
23229
  const line3 = buffer2.slice(0, newlineIndex).trim();
23230
23230
  buffer2 = buffer2.slice(newlineIndex + 1);
23231
23231
  if (line3) {
23232
- if (line3.length > options.maxBufferBytes) {
23232
+ if (options.maxBufferBytes !== void 0 && line3.length > options.maxBufferBytes) {
23233
23233
  options.onOverflow?.();
23234
23234
  } else {
23235
23235
  options.onLine(line3);
@@ -23237,7 +23237,7 @@ ${context2.authorReply.trim()}
23237
23237
  }
23238
23238
  newlineIndex = buffer2.indexOf("\n");
23239
23239
  }
23240
- if (buffer2.length > options.maxBufferBytes) {
23240
+ if (options.maxBufferBytes !== void 0 && buffer2.length > options.maxBufferBytes) {
23241
23241
  buffer2 = "";
23242
23242
  discardingOversizedLine = true;
23243
23243
  options.onOverflow?.();
@@ -24638,7 +24638,7 @@ ${peerId}`;
24638
24638
  const getSessionIdFromRoomId = (roomId) => isSessionDocRoomId(roomId) ? roomId.slice(SESSION_DOC_PREFIX.length) : null;
24639
24639
  const isMachineDocRoomId = (roomId) => roomId.startsWith(MACHINE_DOC_PREFIX);
24640
24640
  const name$1 = "@lody/cli-cloud";
24641
- const version$7 = "0.79.0";
24641
+ const version$7 = "0.79.2";
24642
24642
  const type$2 = "module";
24643
24643
  const scripts = {
24644
24644
  "dev": "node dev.mjs",
@@ -129597,16 +129597,18 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
129597
129597
  return "The machine is at critical memory pressure \u2014 macOS is reclaiming memory and terminating processes to keep up. The turn was not started; free memory and retry.";
129598
129598
  }
129599
129599
  const mb = (bytes) => `${Math.round(bytes / 1024 / 1024)}MB`;
129600
+ if (result.effectiveAvailableCommitBytes !== void 0 && result.commitThresholdBytes !== void 0) {
129601
+ return `The machine has run out of committable memory: ${mb(result.availableCommitBytes ?? 0)} below the commit limit plus ${mb(result.commitGrowthBytes ?? 0)} the page file can still grow, against a safety margin of ${mb(result.commitThresholdBytes)}. The turn was not started; close some programs, or raise the page file maximum, and retry.`;
129602
+ }
129600
129603
  const availableMb = mb(result.availableMemoryBytes);
129601
129604
  const marginMb = mb(result.thresholdBytes);
129602
- const commitText = result.availableCommitBytes !== void 0 && (result.pressureReason === "commit" || result.pressureReason === "physical_and_commit") && result.commitThresholdBytes !== void 0 ? ` Commit headroom is ${mb(result.availableCommitBytes)} (safety margin: ${mb(result.commitThresholdBytes)}).` : "";
129603
129605
  const cgroup = result.cgroup;
129604
129606
  if (cgroup) {
129605
129607
  const hostText = result.hostAvailableBytes !== void 0 ? `host available ${mb(result.hostAvailableBytes)}, ` : "";
129606
129608
  const stallText = cgroup.psiSomeAvg10 !== null ? `stalled ${cgroup.psiSomeAvg10}% of the last 10s on reclaim` : "PSI unavailable; hard headroom is below the floor";
129607
- return `The machine is under memory pressure and ${stallText}. cgroup ${cgroup.path}: ${mb(cgroup.currentBytes)} of ${mb(cgroup.maxBytes)} used, ${mb(cgroup.hardHeadroomBytes)} unused plus ${mb(cgroup.reclaimableBytes)} reclaimable cache/slab; ${hostText}safety margin ${marginMb}. The turn was not started; free memory and retry.${commitText}`;
129609
+ return `The machine is under memory pressure and ${stallText}. cgroup ${cgroup.path}: ${mb(cgroup.currentBytes)} of ${mb(cgroup.maxBytes)} used, ${mb(cgroup.hardHeadroomBytes)} unused plus ${mb(cgroup.reclaimableBytes)} reclaimable cache/slab; ${hostText}safety margin ${marginMb}. The turn was not started; free memory and retry.`;
129608
129610
  }
129609
- return `The machine is under memory pressure (${availableMb} available, safety margin ${marginMb}). The turn was not started; free memory and retry.${commitText}`;
129611
+ return `The machine is under memory pressure (${availableMb} available, safety margin ${marginMb}). The turn was not started; free memory and retry.`;
129610
129612
  }
129611
129613
  recordKnownChatFailureAndHaltEffect(options) {
129612
129614
  return this.tryPromise(() => this.recordKnownChatFailure(options)).pipe(flatMap$2(() => fail(new SessionTurnHalted({
@@ -165465,6 +165467,9 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
165465
165467
  this.logger.error(`[${sessionId}] Backfill gave up for ${fileId}; block stays local (pending on other devices)`);
165466
165468
  return;
165467
165469
  }
165470
+ if (this.sessionFileBackfillStopped || !this.remoteBackfillEnabled) {
165471
+ return;
165472
+ }
165468
165473
  await delay$1(sessionFileBackfillDelayMs(attempt));
165469
165474
  }
165470
165475
  }
@@ -167177,16 +167182,20 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167177
167182
  }
167178
167183
  }
167179
167184
  const execFileAsync = promisify$1(execFile$1);
167180
- const MEMORY_PROBE_TIMEOUT_MS = 1e3;
167185
+ const DARWIN_MEMORY_PROBE_TIMEOUT_MS = 1e3;
167186
+ const WINDOWS_MEMORY_PROBE_TIMEOUT_MS = 5e3;
167187
+ const WINDOWS_MEMORY_CACHE_TTL_MS = 3e4;
167188
+ const MIB$2 = 1024 * 1024;
167189
+ const GIB$1 = 1024 * MIB$2;
167181
167190
  const DARWIN_PRESSURE_NORMAL = 1;
167182
167191
  const DARWIN_PRESSURE_WARNING = 2;
167183
167192
  const DARWIN_PRESSURE_CRITICAL = 4;
167184
- async function getMemoryPressureSnapshot() {
167193
+ async function getMemoryPressureSnapshot(options = {}) {
167185
167194
  const [windowsStatus, darwinPressureLevel] = await Promise.all([
167186
- getWindowsMemoryStatus(),
167195
+ getWindowsMemoryStatus(options.force === true),
167187
167196
  getDarwinMemoryPressureLevel()
167188
167197
  ]);
167189
- const systemAvailable = await getSystemAvailableMemoryBytes(windowsStatus);
167198
+ const systemAvailable = await getSystemAvailableMemoryBytes();
167190
167199
  const cgroup = readCgroupMemoryState();
167191
167200
  const availableMemoryBytes = cgroup !== null ? Math.min(systemAvailable, cgroup.hardHeadroomBytes + cgroup.reclaimableBytes) : systemAvailable;
167192
167201
  const effectiveMemoryLimitBytes = getEffectiveMemoryLimitBytes();
@@ -167203,7 +167212,13 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167203
167212
  ...windowsStatus ? {
167204
167213
  availableCommitBytes: windowsStatus.availableCommitBytes,
167205
167214
  commitLimitBytes: windowsStatus.commitLimitBytes,
167206
- committedBytes: windowsStatus.committedBytes
167215
+ committedBytes: windowsStatus.committedBytes,
167216
+ ...windowsStatus.commitGrowthBytes !== null ? {
167217
+ commitGrowthBytes: windowsStatus.commitGrowthBytes
167218
+ } : {},
167219
+ ...windowsStatus.effectiveAvailableCommitBytes !== void 0 ? {
167220
+ effectiveAvailableCommitBytes: windowsStatus.effectiveAvailableCommitBytes
167221
+ } : {}
167207
167222
  } : {}
167208
167223
  };
167209
167224
  }
@@ -167215,10 +167230,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167215
167230
  }
167216
167231
  return totalMem;
167217
167232
  }
167218
- async function getSystemAvailableMemoryBytes(windowsStatus) {
167219
- if (windowsStatus) {
167220
- return Math.max(windowsStatus.availableBytes, os__default$1.freemem());
167221
- }
167233
+ async function getSystemAvailableMemoryBytes() {
167222
167234
  const darwinAvailable = await getDarwinAvailableMemoryBytes();
167223
167235
  if (darwinAvailable !== null) {
167224
167236
  return darwinAvailable;
@@ -167226,26 +167238,38 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167226
167238
  return getSystemAvailableMemoryBytesSync();
167227
167239
  }
167228
167240
  function getSystemAvailableMemoryBytesSync() {
167229
- try {
167230
- const meminfo = readFileSync$1("/proc/meminfo", "utf8");
167231
- const match5 = meminfo.match(/MemAvailable:\s+(\d+)/);
167232
- if (match5?.[1]) {
167233
- return parseInt(match5[1], 10) * 1024;
167241
+ if (process.platform === "linux") {
167242
+ try {
167243
+ const meminfo = readFileSync$1("/proc/meminfo", "utf8");
167244
+ const match5 = meminfo.match(/MemAvailable:\s+(\d+)/);
167245
+ if (match5?.[1]) {
167246
+ return parseInt(match5[1], 10) * 1024;
167247
+ }
167248
+ } catch {
167234
167249
  }
167235
- } catch {
167236
167250
  }
167237
167251
  return os__default$1.freemem();
167238
167252
  }
167239
- async function getWindowsMemoryStatus() {
167240
- if (process.platform !== "win32") {
167241
- return null;
167242
- }
167253
+ async function probeWindowsMemoryStatus() {
167254
+ const script = [
167255
+ '$ErrorActionPreference = "SilentlyContinue"',
167256
+ "$perf = Get-CimInstance -ClassName Win32_PerfFormattedData_PerfOS_Memory",
167257
+ "$os = Get-CimInstance -ClassName Win32_OperatingSystem",
167258
+ "$cs = Get-CimInstance -ClassName Win32_ComputerSystem",
167259
+ "$usage = @(Get-CimInstance -ClassName Win32_PageFileUsage)",
167260
+ "$setting = @(Get-CimInstance -ClassName Win32_PageFileSetting)",
167261
+ '$disks = @(Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3")',
167262
+ "$out = @{ CommitLimit = $perf.CommitLimit }",
167263
+ "$out.CommittedBytes = $perf.CommittedBytes",
167264
+ "$out.TotalVirtualMemorySize = $os.TotalVirtualMemorySize",
167265
+ "$out.FreeVirtualMemory = $os.FreeVirtualMemory",
167266
+ "$out.AutomaticManagedPagefile = [bool]$cs.AutomaticManagedPagefile",
167267
+ "$out.PageFiles = @($usage | Select-Object Name, AllocatedBaseSize)",
167268
+ "$out.PageFileSettings = @($setting | Select-Object Name, MaximumSize)",
167269
+ "$out.Volumes = @($disks | Select-Object DeviceID, FreeSpace, Size)",
167270
+ "$out | ConvertTo-Json -Compress -Depth 4"
167271
+ ].join("; ");
167243
167272
  try {
167244
- const script = `
167245
- $mem = Get-CimInstance -ClassName Win32_PerfFormattedData_PerfOS_Memory |
167246
- Select-Object AvailableBytes, CommitLimit, CommittedBytes
167247
- $mem | ConvertTo-Json -Compress
167248
- `;
167249
167273
  const { stdout } = await execFileAsync("powershell.exe", [
167250
167274
  "-NoProfile",
167251
167275
  "-NonInteractive",
@@ -167255,32 +167279,178 @@ $mem | ConvertTo-Json -Compress
167255
167279
  script
167256
167280
  ], {
167257
167281
  encoding: "utf8",
167258
- timeout: MEMORY_PROBE_TIMEOUT_MS,
167282
+ timeout: WINDOWS_MEMORY_PROBE_TIMEOUT_MS,
167259
167283
  windowsHide: true
167260
167284
  });
167261
- return parseWindowsMemoryStatus(String(stdout ?? ""));
167285
+ return parseWindowsMemoryStatus(String(stdout ?? ""), os__default$1.totalmem());
167262
167286
  } catch {
167263
167287
  return null;
167264
167288
  }
167265
167289
  }
167266
- function parseWindowsMemoryStatus(rawJson) {
167290
+ let windowsMemoryCache = null;
167291
+ let windowsMemoryProbeInFlight = null;
167292
+ async function getWindowsMemoryStatus(force) {
167293
+ if (process.platform !== "win32") {
167294
+ return null;
167295
+ }
167296
+ const cached2 = windowsMemoryCache;
167297
+ if (!force && cached2 !== null && Date.now() - cached2.sampledAtMs < WINDOWS_MEMORY_CACHE_TTL_MS) {
167298
+ return cached2.status;
167299
+ }
167300
+ if (windowsMemoryProbeInFlight !== null) {
167301
+ return await windowsMemoryProbeInFlight;
167302
+ }
167303
+ const probe = probeWindowsMemoryStatus().then((status) => {
167304
+ windowsMemoryCache = {
167305
+ status,
167306
+ sampledAtMs: Date.now()
167307
+ };
167308
+ return status;
167309
+ });
167310
+ windowsMemoryProbeInFlight = probe;
167267
167311
  try {
167268
- const parsed = JSON.parse(rawJson);
167269
- const availableBytes = Number(parsed.AvailableBytes);
167270
- const commitLimitBytes = Number(parsed.CommitLimit);
167271
- const committedBytes = Number(parsed.CommittedBytes);
167272
- if (!Number.isFinite(availableBytes) || availableBytes < 0 || !Number.isFinite(commitLimitBytes) || commitLimitBytes <= 0 || !Number.isFinite(committedBytes) || committedBytes < 0) {
167273
- return null;
167312
+ return await probe;
167313
+ } finally {
167314
+ if (windowsMemoryProbeInFlight === probe) {
167315
+ windowsMemoryProbeInFlight = null;
167274
167316
  }
167275
- return {
167276
- availableBytes,
167277
- commitLimitBytes,
167278
- committedBytes,
167279
- availableCommitBytes: Math.max(0, commitLimitBytes - committedBytes)
167280
- };
167317
+ }
167318
+ }
167319
+ function parseWindowsMemoryStatus(rawJson, totalPhysicalBytes) {
167320
+ let parsed;
167321
+ try {
167322
+ const value = JSON.parse(rawJson);
167323
+ if (typeof value !== "object" || value === null) return null;
167324
+ parsed = value;
167281
167325
  } catch {
167282
167326
  return null;
167283
167327
  }
167328
+ const commit = readWindowsCommitTotals(parsed);
167329
+ if (commit === null) return null;
167330
+ const config2 = {
167331
+ automaticManagedPagefile: parsed.AutomaticManagedPagefile === true,
167332
+ pageFiles: readCimRows(parsed.PageFiles).flatMap((row) => {
167333
+ const name2 = readNonEmptyString(row.Name);
167334
+ const allocatedBytes = readMegabytes(row.AllocatedBaseSize);
167335
+ return name2 !== null && allocatedBytes !== null ? [
167336
+ {
167337
+ name: name2,
167338
+ allocatedBytes
167339
+ }
167340
+ ] : [];
167341
+ }),
167342
+ pageFileSettings: readCimRows(parsed.PageFileSettings).flatMap((row) => {
167343
+ const name2 = readNonEmptyString(row.Name);
167344
+ const maximumBytes = readMegabytes(row.MaximumSize);
167345
+ return name2 !== null && maximumBytes !== null ? [
167346
+ {
167347
+ name: name2,
167348
+ maximumBytes
167349
+ }
167350
+ ] : [];
167351
+ }),
167352
+ volumes: readCimRows(parsed.Volumes).flatMap((row) => {
167353
+ const name2 = readNonEmptyString(row.DeviceID);
167354
+ const freeBytes = readNumber(row.FreeSpace);
167355
+ const sizeBytes = readNumber(row.Size);
167356
+ return name2 !== null && freeBytes !== null && sizeBytes !== null ? [
167357
+ {
167358
+ name: name2,
167359
+ freeBytes,
167360
+ sizeBytes
167361
+ }
167362
+ ] : [];
167363
+ })
167364
+ };
167365
+ const commitGrowthBytes = computeWindowsCommitGrowthBytes(config2, {
167366
+ totalPhysicalBytes,
167367
+ commitLimitBytes: commit.commitLimitBytes
167368
+ });
167369
+ return {
167370
+ commitLimitBytes: commit.commitLimitBytes,
167371
+ committedBytes: commit.committedBytes,
167372
+ availableCommitBytes: commit.availableCommitBytes,
167373
+ commitGrowthBytes,
167374
+ ...commitGrowthBytes !== null ? {
167375
+ effectiveAvailableCommitBytes: commit.availableCommitBytes + commitGrowthBytes
167376
+ } : {}
167377
+ };
167378
+ }
167379
+ function readWindowsCommitTotals(parsed) {
167380
+ const perfLimit = readNumber(parsed.CommitLimit);
167381
+ const perfCommitted = readNumber(parsed.CommittedBytes);
167382
+ if (perfLimit !== null && perfLimit > 0 && perfCommitted !== null) {
167383
+ return {
167384
+ commitLimitBytes: perfLimit,
167385
+ committedBytes: Math.min(perfCommitted, perfLimit),
167386
+ availableCommitBytes: Math.max(0, perfLimit - perfCommitted)
167387
+ };
167388
+ }
167389
+ const osLimit = readKilobytes(parsed.TotalVirtualMemorySize);
167390
+ const osFree = readKilobytes(parsed.FreeVirtualMemory);
167391
+ if (osLimit !== null && osLimit > 0 && osFree !== null) {
167392
+ const available = Math.min(osFree, osLimit);
167393
+ return {
167394
+ commitLimitBytes: osLimit,
167395
+ committedBytes: osLimit - available,
167396
+ availableCommitBytes: available
167397
+ };
167398
+ }
167399
+ return null;
167400
+ }
167401
+ function computeWindowsCommitGrowthBytes(config2, inputs) {
167402
+ const { totalPhysicalBytes, commitLimitBytes } = inputs;
167403
+ const volumeByKey = new Map(config2.volumes.map((volume) => [
167404
+ volumeKey(volume.name),
167405
+ volume
167406
+ ]));
167407
+ const maximumByName = new Map(config2.pageFileSettings.map((setting) => [
167408
+ setting.name.toLowerCase(),
167409
+ setting.maximumBytes
167410
+ ]));
167411
+ if (config2.pageFiles.length === 0) {
167412
+ if (commitLimitBytes > totalPhysicalBytes + EMPTY_PAGE_FILE_TOLERANCE_BYTES) return null;
167413
+ if (!config2.automaticManagedPagefile) return 0;
167414
+ return config2.volumes.reduce((largest, volume) => Math.max(largest, Math.min(systemManagedMaxBytes(totalPhysicalBytes, volume.sizeBytes), volume.freeBytes)), 0);
167415
+ }
167416
+ let growthBytes = 0;
167417
+ for (const pageFile of config2.pageFiles) {
167418
+ const volume = volumeByKey.get(volumeKey(pageFile.name));
167419
+ if (volume === void 0) return null;
167420
+ const configuredMaximum = config2.automaticManagedPagefile ? 0 : maximumByName.get(pageFile.name.toLowerCase()) ?? 0;
167421
+ const maximumBytes = configuredMaximum > 0 ? configuredMaximum : systemManagedMaxBytes(totalPhysicalBytes, volume.sizeBytes);
167422
+ growthBytes += Math.min(Math.max(0, maximumBytes - pageFile.allocatedBytes), volume.freeBytes);
167423
+ }
167424
+ return growthBytes;
167425
+ }
167426
+ const EMPTY_PAGE_FILE_TOLERANCE_BYTES = 64 * MIB$2;
167427
+ function systemManagedMaxBytes(totalPhysicalBytes, volumeSizeBytes) {
167428
+ return Math.min(Math.max(3 * totalPhysicalBytes, 4 * GIB$1), Math.floor(volumeSizeBytes / 8));
167429
+ }
167430
+ function volumeKey(name2) {
167431
+ return name2.slice(0, 2).toUpperCase();
167432
+ }
167433
+ function readCimRows(value) {
167434
+ const rows = Array.isArray(value) ? value : [
167435
+ value
167436
+ ];
167437
+ return rows.filter((row) => typeof row === "object" && row !== null);
167438
+ }
167439
+ function readNumber(value) {
167440
+ if (typeof value !== "number" && typeof value !== "string") return null;
167441
+ const parsed = Number(value);
167442
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
167443
+ }
167444
+ function readKilobytes(value) {
167445
+ const parsed = readNumber(value);
167446
+ return parsed === null ? null : parsed * 1024;
167447
+ }
167448
+ function readMegabytes(value) {
167449
+ const parsed = readNumber(value);
167450
+ return parsed === null ? null : parsed * MIB$2;
167451
+ }
167452
+ function readNonEmptyString(value) {
167453
+ return typeof value === "string" && value.length > 0 ? value : null;
167284
167454
  }
167285
167455
  async function getDarwinMemoryPressureLevel() {
167286
167456
  if (process.platform !== "darwin") {
@@ -167292,7 +167462,7 @@ $mem | ConvertTo-Json -Compress
167292
167462
  "kern.memorystatus_vm_pressure_level"
167293
167463
  ], {
167294
167464
  encoding: "utf8",
167295
- timeout: MEMORY_PROBE_TIMEOUT_MS
167465
+ timeout: DARWIN_MEMORY_PROBE_TIMEOUT_MS
167296
167466
  });
167297
167467
  return parseDarwinPressureLevel(String(stdout ?? ""));
167298
167468
  } catch {
@@ -167317,7 +167487,7 @@ $mem | ConvertTo-Json -Compress
167317
167487
  try {
167318
167488
  const { stdout } = await execFileAsync("vm_stat", [], {
167319
167489
  encoding: "utf8",
167320
- timeout: MEMORY_PROBE_TIMEOUT_MS
167490
+ timeout: DARWIN_MEMORY_PROBE_TIMEOUT_MS
167321
167491
  });
167322
167492
  const parsed = parseDarwinAvailableMemoryBytes(String(stdout ?? ""));
167323
167493
  if (parsed !== null) {
@@ -167499,6 +167669,24 @@ $mem | ConvertTo-Json -Compress
167499
167669
  function getWindowsCommitThresholdBytes(memoryThresholdBytes) {
167500
167670
  return Math.max(WINDOWS_COMMIT_THRESHOLD_FLOOR_BYTES, Math.min(WINDOWS_COMMIT_THRESHOLD_CEILING_BYTES, memoryThresholdBytes));
167501
167671
  }
167672
+ function evaluateWindowsMemoryPressure(snapshot, thresholds2) {
167673
+ const physicalLow = snapshot.availableMemoryBytes < thresholds2.thresholdBytes;
167674
+ const commitLow = snapshot.availableCommitBytes !== void 0 && snapshot.availableCommitBytes < thresholds2.commitThresholdBytes;
167675
+ const commitExhausted = snapshot.effectiveAvailableCommitBytes !== void 0 && snapshot.effectiveAvailableCommitBytes < thresholds2.commitThresholdBytes;
167676
+ if (commitExhausted) {
167677
+ return {
167678
+ evict: true,
167679
+ block: true,
167680
+ reason: physicalLow ? "physical_and_commit" : "commit"
167681
+ };
167682
+ }
167683
+ const reason = physicalLow && commitLow ? "physical_and_commit" : physicalLow ? "physical" : commitLow ? "commit" : null;
167684
+ return {
167685
+ evict: reason !== null,
167686
+ block: false,
167687
+ reason
167688
+ };
167689
+ }
167502
167690
  function evaluateMemoryPressure(snapshot, thresholds2) {
167503
167691
  if (thresholds2.platform === "darwin") {
167504
167692
  if (snapshot.memoryPressureLevel === DARWIN_PRESSURE_CRITICAL) {
@@ -167521,7 +167709,9 @@ $mem | ConvertTo-Json -Compress
167521
167709
  reason: null
167522
167710
  };
167523
167711
  }
167524
- const commitPressure = snapshot.availableCommitBytes !== void 0 && snapshot.availableCommitBytes < thresholds2.commitThresholdBytes;
167712
+ if (thresholds2.platform === "win32") {
167713
+ return evaluateWindowsMemoryPressure(snapshot, thresholds2);
167714
+ }
167525
167715
  const cgroup = snapshot.cgroup;
167526
167716
  if (cgroup) {
167527
167717
  const hostLow = snapshot.hostAvailableBytes !== void 0 && snapshot.hostAvailableBytes < thresholds2.thresholdBytes;
@@ -167541,13 +167731,6 @@ $mem | ConvertTo-Json -Compress
167541
167731
  reason: "cgroup_low_headroom"
167542
167732
  };
167543
167733
  }
167544
- if (commitPressure) {
167545
- return {
167546
- evict: true,
167547
- block: true,
167548
- reason: "commit"
167549
- };
167550
- }
167551
167734
  return {
167552
167735
  evict: false,
167553
167736
  block: false,
@@ -167555,7 +167738,7 @@ $mem | ConvertTo-Json -Compress
167555
167738
  };
167556
167739
  }
167557
167740
  const physicalPressure = snapshot.availableMemoryBytes < thresholds2.thresholdBytes;
167558
- const reason = physicalPressure && commitPressure ? "physical_and_commit" : physicalPressure ? "physical" : commitPressure ? "commit" : null;
167741
+ const reason = physicalPressure ? "physical" : null;
167559
167742
  return {
167560
167743
  evict: reason !== null,
167561
167744
  block: reason !== null,
@@ -167574,7 +167757,7 @@ $mem | ConvertTo-Json -Compress
167574
167757
  this.deps.logger.debug("[GC] Session GC is disabled");
167575
167758
  return;
167576
167759
  }
167577
- const pressureSignal = this.platform === "darwin" ? "kern.memorystatus_vm_pressure_level" : `available<${Math.round(this.config.memoryThresholdBytes / 1024 / 1024)}MB`;
167760
+ const pressureSignal = this.platform === "darwin" ? "kern.memorystatus_vm_pressure_level" : this.platform === "win32" ? `commit+pagefile-growth<${Math.round(getWindowsCommitThresholdBytes(this.config.memoryThresholdBytes) / 1024 / 1024)}MB` : `available<${Math.round(this.config.memoryThresholdBytes / 1024 / 1024)}MB`;
167578
167761
  this.deps.logger.debug(`[GC] Starting session GC (interval=${this.config.sweepIntervalMs}ms, idleTimeout=${this.config.idleTimeoutMs}ms, pressureSignal=${pressureSignal}, maxEvictionsPerCall=${this.config.maxEvictionsPerCall})`);
167579
167762
  this.sweepInterval = setInterval(() => void this.sweep(), this.config.sweepIntervalMs);
167580
167763
  }
@@ -167715,7 +167898,13 @@ $mem | ConvertTo-Json -Compress
167715
167898
  availableCommitBytes: snapshot.availableCommitBytes,
167716
167899
  commitThresholdBytes,
167717
167900
  commitLimitBytes: snapshot.commitLimitBytes,
167718
- committedBytes: snapshot.committedBytes
167901
+ committedBytes: snapshot.committedBytes,
167902
+ ...snapshot.commitGrowthBytes !== void 0 ? {
167903
+ commitGrowthBytes: snapshot.commitGrowthBytes
167904
+ } : {},
167905
+ ...snapshot.effectiveAvailableCommitBytes !== void 0 ? {
167906
+ effectiveAvailableCommitBytes: snapshot.effectiveAvailableCommitBytes
167907
+ } : {}
167719
167908
  } : {}
167720
167909
  };
167721
167910
  }
@@ -167729,12 +167918,13 @@ $mem | ConvertTo-Json -Compress
167729
167918
  if (snapshot.memoryPressureLevel !== void 0) {
167730
167919
  return `kernel pressure level ${snapshot.memoryPressureLevel}`;
167731
167920
  }
167921
+ const mb = (bytes) => Math.round(bytes / 1024 / 1024);
167732
167922
  const cgroup = snapshot.cgroup;
167733
167923
  if (cgroup) {
167734
- const mb = (bytes) => Math.round(bytes / 1024 / 1024);
167735
167924
  return `cgroup ${cgroup.path}: hard headroom ${mb(cgroup.hardHeadroomBytes)}MB + reclaimable ${mb(cgroup.reclaimableBytes)}MB (of ${mb(cgroup.stat.activeFileBytes)}MB active file cache not counted), host available ${snapshot.hostAvailableBytes !== void 0 ? mb(snapshot.hostAvailableBytes) : "?"}MB, PSI some avg10 ${cgroup.psiSomeAvg10 ?? "?"}, threshold ${mb(thresholdBytes)}MB`;
167736
167925
  }
167737
- const commitText = snapshot.availableCommitBytes !== void 0 ? `, commit headroom ${Math.round(snapshot.availableCommitBytes / 1024 / 1024)}MB (threshold: ${Math.round(commitThresholdBytes / 1024 / 1024)}MB)` : "";
167926
+ const growthText = snapshot.commitGrowthBytes !== void 0 ? `${mb(snapshot.commitGrowthBytes)}MB page file growth` : "page file growth unknown";
167927
+ const commitText = snapshot.availableCommitBytes !== void 0 ? `, commit headroom ${mb(snapshot.availableCommitBytes)}MB + ${growthText} (threshold: ${mb(commitThresholdBytes)}MB)` : "";
167738
167928
  return `${Math.round(snapshot.availableMemoryBytes / 1024 / 1024)}MB available (threshold: ${Math.round(thresholdBytes / 1024 / 1024)}MB)${commitText}`;
167739
167929
  }
167740
167930
  async getIdleCandidates() {
@@ -178621,7 +178811,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
178621
178811
  }
178622
178812
  roomMessageChain = roomMessageChain.then(() => handleMessage(config2, connection2, touchedEngines, message)).catch((error2) => logMessageHandlingError(config2.logger, error2));
178623
178813
  },
178624
- maxBufferBytes: LOCAL_LORO_DATA_PLANE_MAX_FRAME_BYTES,
178814
+ maxBufferBytes: config2.maxFrameBytes ?? LOCAL_LORO_DATA_PLANE_MAX_FRAME_BYTES,
178625
178815
  onOverflow: () => {
178626
178816
  connection2.send({
178627
178817
  type: "error",
@@ -179281,7 +179471,9 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
179281
179471
  class MemoryPressureSampler {
179282
179472
  constructor(logger2, options = {}) {
179283
179473
  this.logger = logger2;
179284
- this.probe = options.probe ?? getMemoryPressureSnapshot;
179474
+ this.probe = options.probe ?? ((force) => getMemoryPressureSnapshot({
179475
+ force
179476
+ }));
179285
179477
  this.now = options.now ?? (() => performance.now());
179286
179478
  this.sampleIntervalMs = options.sampleIntervalMs ?? platformSampleIntervalMs();
179287
179479
  this.maxStaleMs = options.maxStaleMs ?? this.sampleIntervalMs * 3;
@@ -179295,11 +179487,11 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
179295
179487
  timer = null;
179296
179488
  start() {
179297
179489
  if (this.timer) return;
179298
- void this.refresh().catch((error2) => {
179490
+ void this.sample(false).catch((error2) => {
179299
179491
  this.logger.debug(`Initial memory pressure sample failed: ${formatErrorMessage(error2)}`);
179300
179492
  });
179301
179493
  this.timer = setInterval(() => {
179302
- void this.refresh().catch((error2) => {
179494
+ void this.sample(false).catch((error2) => {
179303
179495
  this.logger.debug(`Memory pressure sample failed: ${formatErrorMessage(error2)}`);
179304
179496
  });
179305
179497
  }, this.sampleIntervalMs);
@@ -179313,33 +179505,41 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
179313
179505
  async getLatest() {
179314
179506
  const cached2 = this.cached;
179315
179507
  if (!cached2) {
179316
- return await this.refresh();
179508
+ return await this.sample(false);
179317
179509
  }
179318
179510
  const ageMs = Math.max(0, this.now() - cached2.sampledAtMs);
179319
179511
  if (ageMs >= this.sampleIntervalMs) {
179320
- void this.refresh().catch((error2) => {
179512
+ void this.sample(false).catch((error2) => {
179321
179513
  this.logger.debug(`Memory pressure refresh failed: ${formatErrorMessage(error2)}`);
179322
179514
  });
179323
179515
  }
179324
179516
  if (ageMs <= this.maxStaleMs) {
179325
179517
  return cached2.snapshot;
179326
179518
  }
179327
- return await this.refresh();
179519
+ return await this.sample(false);
179328
179520
  }
179329
179521
  async refresh() {
179330
- if (this.inFlight) {
179331
- return await this.inFlight;
179522
+ return await this.sample(true);
179523
+ }
179524
+ async sample(force) {
179525
+ const inFlight = this.inFlight;
179526
+ if (inFlight !== null && (!force || inFlight.forced)) {
179527
+ return await inFlight.promise;
179332
179528
  }
179333
- const operation = this.probe().then((snapshot) => {
179529
+ const promise2 = this.probe(force).then((snapshot) => {
179334
179530
  this.cached = {
179335
179531
  snapshot,
179336
179532
  sampledAtMs: this.now()
179337
179533
  };
179338
179534
  return snapshot;
179339
179535
  });
179536
+ const operation = {
179537
+ promise: promise2,
179538
+ forced: force
179539
+ };
179340
179540
  this.inFlight = operation;
179341
179541
  try {
179342
- return await operation;
179542
+ return await promise2;
179343
179543
  } finally {
179344
179544
  if (this.inFlight === operation) {
179345
179545
  this.inFlight = null;
@@ -213716,7 +213916,7 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
213716
213916
  data = createReviewBundleSnapshot(bundle);
213717
213917
  }
213718
213918
  const { injectReviewSnapshot } = await import("./chunks/index-VoI6Ds2-.js");
213719
- const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer--d2HZGpO.js").then(async (m) => {
213919
+ const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-BJIn--4M.js").then(async (m) => {
213720
213920
  await m.__tla;
213721
213921
  return m;
213722
213922
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lody",
3
- "version": "0.79.0",
3
+ "version": "0.79.2",
4
4
  "description": "Lody Agent CLI tool for managing remote command execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",