lody 0.79.1 → 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.
|
|
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
|
@@ -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.
|
|
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
|
|
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
|
|
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({
|
|
@@ -167180,16 +167182,20 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
167180
167182
|
}
|
|
167181
167183
|
}
|
|
167182
167184
|
const execFileAsync = promisify$1(execFile$1);
|
|
167183
|
-
const
|
|
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;
|
|
167184
167190
|
const DARWIN_PRESSURE_NORMAL = 1;
|
|
167185
167191
|
const DARWIN_PRESSURE_WARNING = 2;
|
|
167186
167192
|
const DARWIN_PRESSURE_CRITICAL = 4;
|
|
167187
|
-
async function getMemoryPressureSnapshot() {
|
|
167193
|
+
async function getMemoryPressureSnapshot(options = {}) {
|
|
167188
167194
|
const [windowsStatus, darwinPressureLevel] = await Promise.all([
|
|
167189
|
-
getWindowsMemoryStatus(),
|
|
167195
|
+
getWindowsMemoryStatus(options.force === true),
|
|
167190
167196
|
getDarwinMemoryPressureLevel()
|
|
167191
167197
|
]);
|
|
167192
|
-
const systemAvailable = await getSystemAvailableMemoryBytes(
|
|
167198
|
+
const systemAvailable = await getSystemAvailableMemoryBytes();
|
|
167193
167199
|
const cgroup = readCgroupMemoryState();
|
|
167194
167200
|
const availableMemoryBytes = cgroup !== null ? Math.min(systemAvailable, cgroup.hardHeadroomBytes + cgroup.reclaimableBytes) : systemAvailable;
|
|
167195
167201
|
const effectiveMemoryLimitBytes = getEffectiveMemoryLimitBytes();
|
|
@@ -167206,7 +167212,13 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
167206
167212
|
...windowsStatus ? {
|
|
167207
167213
|
availableCommitBytes: windowsStatus.availableCommitBytes,
|
|
167208
167214
|
commitLimitBytes: windowsStatus.commitLimitBytes,
|
|
167209
|
-
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
|
+
} : {}
|
|
167210
167222
|
} : {}
|
|
167211
167223
|
};
|
|
167212
167224
|
}
|
|
@@ -167218,10 +167230,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
167218
167230
|
}
|
|
167219
167231
|
return totalMem;
|
|
167220
167232
|
}
|
|
167221
|
-
async function getSystemAvailableMemoryBytes(
|
|
167222
|
-
if (windowsStatus) {
|
|
167223
|
-
return Math.max(windowsStatus.availableBytes, os__default$1.freemem());
|
|
167224
|
-
}
|
|
167233
|
+
async function getSystemAvailableMemoryBytes() {
|
|
167225
167234
|
const darwinAvailable = await getDarwinAvailableMemoryBytes();
|
|
167226
167235
|
if (darwinAvailable !== null) {
|
|
167227
167236
|
return darwinAvailable;
|
|
@@ -167229,26 +167238,38 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
167229
167238
|
return getSystemAvailableMemoryBytesSync();
|
|
167230
167239
|
}
|
|
167231
167240
|
function getSystemAvailableMemoryBytesSync() {
|
|
167232
|
-
|
|
167233
|
-
|
|
167234
|
-
|
|
167235
|
-
|
|
167236
|
-
|
|
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 {
|
|
167237
167249
|
}
|
|
167238
|
-
} catch {
|
|
167239
167250
|
}
|
|
167240
167251
|
return os__default$1.freemem();
|
|
167241
167252
|
}
|
|
167242
|
-
async function
|
|
167243
|
-
|
|
167244
|
-
|
|
167245
|
-
|
|
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("; ");
|
|
167246
167272
|
try {
|
|
167247
|
-
const script = `
|
|
167248
|
-
$mem = Get-CimInstance -ClassName Win32_PerfFormattedData_PerfOS_Memory |
|
|
167249
|
-
Select-Object AvailableBytes, CommitLimit, CommittedBytes
|
|
167250
|
-
$mem | ConvertTo-Json -Compress
|
|
167251
|
-
`;
|
|
167252
167273
|
const { stdout } = await execFileAsync("powershell.exe", [
|
|
167253
167274
|
"-NoProfile",
|
|
167254
167275
|
"-NonInteractive",
|
|
@@ -167258,32 +167279,178 @@ $mem | ConvertTo-Json -Compress
|
|
|
167258
167279
|
script
|
|
167259
167280
|
], {
|
|
167260
167281
|
encoding: "utf8",
|
|
167261
|
-
timeout:
|
|
167282
|
+
timeout: WINDOWS_MEMORY_PROBE_TIMEOUT_MS,
|
|
167262
167283
|
windowsHide: true
|
|
167263
167284
|
});
|
|
167264
|
-
return parseWindowsMemoryStatus(String(stdout ?? ""));
|
|
167285
|
+
return parseWindowsMemoryStatus(String(stdout ?? ""), os__default$1.totalmem());
|
|
167265
167286
|
} catch {
|
|
167266
167287
|
return null;
|
|
167267
167288
|
}
|
|
167268
167289
|
}
|
|
167269
|
-
|
|
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;
|
|
167270
167311
|
try {
|
|
167271
|
-
|
|
167272
|
-
|
|
167273
|
-
|
|
167274
|
-
|
|
167275
|
-
if (!Number.isFinite(availableBytes) || availableBytes < 0 || !Number.isFinite(commitLimitBytes) || commitLimitBytes <= 0 || !Number.isFinite(committedBytes) || committedBytes < 0) {
|
|
167276
|
-
return null;
|
|
167312
|
+
return await probe;
|
|
167313
|
+
} finally {
|
|
167314
|
+
if (windowsMemoryProbeInFlight === probe) {
|
|
167315
|
+
windowsMemoryProbeInFlight = null;
|
|
167277
167316
|
}
|
|
167278
|
-
|
|
167279
|
-
|
|
167280
|
-
|
|
167281
|
-
|
|
167282
|
-
|
|
167283
|
-
|
|
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;
|
|
167284
167325
|
} catch {
|
|
167285
167326
|
return null;
|
|
167286
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;
|
|
167287
167454
|
}
|
|
167288
167455
|
async function getDarwinMemoryPressureLevel() {
|
|
167289
167456
|
if (process.platform !== "darwin") {
|
|
@@ -167295,7 +167462,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
167295
167462
|
"kern.memorystatus_vm_pressure_level"
|
|
167296
167463
|
], {
|
|
167297
167464
|
encoding: "utf8",
|
|
167298
|
-
timeout:
|
|
167465
|
+
timeout: DARWIN_MEMORY_PROBE_TIMEOUT_MS
|
|
167299
167466
|
});
|
|
167300
167467
|
return parseDarwinPressureLevel(String(stdout ?? ""));
|
|
167301
167468
|
} catch {
|
|
@@ -167320,7 +167487,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
167320
167487
|
try {
|
|
167321
167488
|
const { stdout } = await execFileAsync("vm_stat", [], {
|
|
167322
167489
|
encoding: "utf8",
|
|
167323
|
-
timeout:
|
|
167490
|
+
timeout: DARWIN_MEMORY_PROBE_TIMEOUT_MS
|
|
167324
167491
|
});
|
|
167325
167492
|
const parsed = parseDarwinAvailableMemoryBytes(String(stdout ?? ""));
|
|
167326
167493
|
if (parsed !== null) {
|
|
@@ -167502,6 +167669,24 @@ $mem | ConvertTo-Json -Compress
|
|
|
167502
167669
|
function getWindowsCommitThresholdBytes(memoryThresholdBytes) {
|
|
167503
167670
|
return Math.max(WINDOWS_COMMIT_THRESHOLD_FLOOR_BYTES, Math.min(WINDOWS_COMMIT_THRESHOLD_CEILING_BYTES, memoryThresholdBytes));
|
|
167504
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
|
+
}
|
|
167505
167690
|
function evaluateMemoryPressure(snapshot, thresholds2) {
|
|
167506
167691
|
if (thresholds2.platform === "darwin") {
|
|
167507
167692
|
if (snapshot.memoryPressureLevel === DARWIN_PRESSURE_CRITICAL) {
|
|
@@ -167524,7 +167709,9 @@ $mem | ConvertTo-Json -Compress
|
|
|
167524
167709
|
reason: null
|
|
167525
167710
|
};
|
|
167526
167711
|
}
|
|
167527
|
-
|
|
167712
|
+
if (thresholds2.platform === "win32") {
|
|
167713
|
+
return evaluateWindowsMemoryPressure(snapshot, thresholds2);
|
|
167714
|
+
}
|
|
167528
167715
|
const cgroup = snapshot.cgroup;
|
|
167529
167716
|
if (cgroup) {
|
|
167530
167717
|
const hostLow = snapshot.hostAvailableBytes !== void 0 && snapshot.hostAvailableBytes < thresholds2.thresholdBytes;
|
|
@@ -167544,13 +167731,6 @@ $mem | ConvertTo-Json -Compress
|
|
|
167544
167731
|
reason: "cgroup_low_headroom"
|
|
167545
167732
|
};
|
|
167546
167733
|
}
|
|
167547
|
-
if (commitPressure) {
|
|
167548
|
-
return {
|
|
167549
|
-
evict: true,
|
|
167550
|
-
block: true,
|
|
167551
|
-
reason: "commit"
|
|
167552
|
-
};
|
|
167553
|
-
}
|
|
167554
167734
|
return {
|
|
167555
167735
|
evict: false,
|
|
167556
167736
|
block: false,
|
|
@@ -167558,7 +167738,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
167558
167738
|
};
|
|
167559
167739
|
}
|
|
167560
167740
|
const physicalPressure = snapshot.availableMemoryBytes < thresholds2.thresholdBytes;
|
|
167561
|
-
const reason = physicalPressure
|
|
167741
|
+
const reason = physicalPressure ? "physical" : null;
|
|
167562
167742
|
return {
|
|
167563
167743
|
evict: reason !== null,
|
|
167564
167744
|
block: reason !== null,
|
|
@@ -167577,7 +167757,7 @@ $mem | ConvertTo-Json -Compress
|
|
|
167577
167757
|
this.deps.logger.debug("[GC] Session GC is disabled");
|
|
167578
167758
|
return;
|
|
167579
167759
|
}
|
|
167580
|
-
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`;
|
|
167581
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})`);
|
|
167582
167762
|
this.sweepInterval = setInterval(() => void this.sweep(), this.config.sweepIntervalMs);
|
|
167583
167763
|
}
|
|
@@ -167718,7 +167898,13 @@ $mem | ConvertTo-Json -Compress
|
|
|
167718
167898
|
availableCommitBytes: snapshot.availableCommitBytes,
|
|
167719
167899
|
commitThresholdBytes,
|
|
167720
167900
|
commitLimitBytes: snapshot.commitLimitBytes,
|
|
167721
|
-
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
|
+
} : {}
|
|
167722
167908
|
} : {}
|
|
167723
167909
|
};
|
|
167724
167910
|
}
|
|
@@ -167732,12 +167918,13 @@ $mem | ConvertTo-Json -Compress
|
|
|
167732
167918
|
if (snapshot.memoryPressureLevel !== void 0) {
|
|
167733
167919
|
return `kernel pressure level ${snapshot.memoryPressureLevel}`;
|
|
167734
167920
|
}
|
|
167921
|
+
const mb = (bytes) => Math.round(bytes / 1024 / 1024);
|
|
167735
167922
|
const cgroup = snapshot.cgroup;
|
|
167736
167923
|
if (cgroup) {
|
|
167737
|
-
const mb = (bytes) => Math.round(bytes / 1024 / 1024);
|
|
167738
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`;
|
|
167739
167925
|
}
|
|
167740
|
-
const
|
|
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)` : "";
|
|
167741
167928
|
return `${Math.round(snapshot.availableMemoryBytes / 1024 / 1024)}MB available (threshold: ${Math.round(thresholdBytes / 1024 / 1024)}MB)${commitText}`;
|
|
167742
167929
|
}
|
|
167743
167930
|
async getIdleCandidates() {
|
|
@@ -179284,7 +179471,9 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179284
179471
|
class MemoryPressureSampler {
|
|
179285
179472
|
constructor(logger2, options = {}) {
|
|
179286
179473
|
this.logger = logger2;
|
|
179287
|
-
this.probe = options.probe ?? getMemoryPressureSnapshot
|
|
179474
|
+
this.probe = options.probe ?? ((force) => getMemoryPressureSnapshot({
|
|
179475
|
+
force
|
|
179476
|
+
}));
|
|
179288
179477
|
this.now = options.now ?? (() => performance.now());
|
|
179289
179478
|
this.sampleIntervalMs = options.sampleIntervalMs ?? platformSampleIntervalMs();
|
|
179290
179479
|
this.maxStaleMs = options.maxStaleMs ?? this.sampleIntervalMs * 3;
|
|
@@ -179298,11 +179487,11 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179298
179487
|
timer = null;
|
|
179299
179488
|
start() {
|
|
179300
179489
|
if (this.timer) return;
|
|
179301
|
-
void this.
|
|
179490
|
+
void this.sample(false).catch((error2) => {
|
|
179302
179491
|
this.logger.debug(`Initial memory pressure sample failed: ${formatErrorMessage(error2)}`);
|
|
179303
179492
|
});
|
|
179304
179493
|
this.timer = setInterval(() => {
|
|
179305
|
-
void this.
|
|
179494
|
+
void this.sample(false).catch((error2) => {
|
|
179306
179495
|
this.logger.debug(`Memory pressure sample failed: ${formatErrorMessage(error2)}`);
|
|
179307
179496
|
});
|
|
179308
179497
|
}, this.sampleIntervalMs);
|
|
@@ -179316,33 +179505,41 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179316
179505
|
async getLatest() {
|
|
179317
179506
|
const cached2 = this.cached;
|
|
179318
179507
|
if (!cached2) {
|
|
179319
|
-
return await this.
|
|
179508
|
+
return await this.sample(false);
|
|
179320
179509
|
}
|
|
179321
179510
|
const ageMs = Math.max(0, this.now() - cached2.sampledAtMs);
|
|
179322
179511
|
if (ageMs >= this.sampleIntervalMs) {
|
|
179323
|
-
void this.
|
|
179512
|
+
void this.sample(false).catch((error2) => {
|
|
179324
179513
|
this.logger.debug(`Memory pressure refresh failed: ${formatErrorMessage(error2)}`);
|
|
179325
179514
|
});
|
|
179326
179515
|
}
|
|
179327
179516
|
if (ageMs <= this.maxStaleMs) {
|
|
179328
179517
|
return cached2.snapshot;
|
|
179329
179518
|
}
|
|
179330
|
-
return await this.
|
|
179519
|
+
return await this.sample(false);
|
|
179331
179520
|
}
|
|
179332
179521
|
async refresh() {
|
|
179333
|
-
|
|
179334
|
-
|
|
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;
|
|
179335
179528
|
}
|
|
179336
|
-
const
|
|
179529
|
+
const promise2 = this.probe(force).then((snapshot) => {
|
|
179337
179530
|
this.cached = {
|
|
179338
179531
|
snapshot,
|
|
179339
179532
|
sampledAtMs: this.now()
|
|
179340
179533
|
};
|
|
179341
179534
|
return snapshot;
|
|
179342
179535
|
});
|
|
179536
|
+
const operation = {
|
|
179537
|
+
promise: promise2,
|
|
179538
|
+
forced: force
|
|
179539
|
+
};
|
|
179343
179540
|
this.inFlight = operation;
|
|
179344
179541
|
try {
|
|
179345
|
-
return await
|
|
179542
|
+
return await promise2;
|
|
179346
179543
|
} finally {
|
|
179347
179544
|
if (this.inFlight === operation) {
|
|
179348
179545
|
this.inFlight = null;
|
|
@@ -213719,7 +213916,7 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
|
213719
213916
|
data = createReviewBundleSnapshot(bundle);
|
|
213720
213917
|
}
|
|
213721
213918
|
const { injectReviewSnapshot } = await import("./chunks/index-VoI6Ds2-.js");
|
|
213722
|
-
const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-
|
|
213919
|
+
const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-BJIn--4M.js").then(async (m) => {
|
|
213723
213920
|
await m.__tla;
|
|
213724
213921
|
return m;
|
|
213725
213922
|
});
|