@cortexkit/pi-magic-context 0.43.2 → 0.44.1
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/{index-bfd52y8p.js → index-59dmj4zs.js} +26 -7
- package/dist/{index-5v60m046.js → index-5fw91enm.js} +1 -1
- package/dist/{index-17102c1m.js → index-97e5fzy3.js} +1 -1
- package/dist/{index-bkrh6jhp.js → index-mwpk0wn9.js} +738 -458
- package/dist/{index-mea04n1j.js → index-nm3c0sn8.js} +191 -37
- package/dist/index.js +1754 -792
- package/dist/{message-time-backfill-f0v3yvza.js → message-time-backfill-5yrp95cx.js} +3 -3
- package/dist/{read-session-chunk-ky2sprnf.js → read-session-chunk-ka7n4kah.js} +6 -2
- package/dist/{safe-notification-target-d7f3t5qk.js → safe-notification-target-y3hg2m7p.js} +2 -2
- package/dist/subagent-entry.js +6 -6
- package/package.json +4 -2
|
@@ -11,6 +11,9 @@ function setHarness(value) {
|
|
|
11
11
|
function getHarness() {
|
|
12
12
|
return currentHarness;
|
|
13
13
|
}
|
|
14
|
+
function harnessOwnsOpenCodeStore(harness = currentHarness) {
|
|
15
|
+
return harness === "opencode" || harness === "opencode2";
|
|
16
|
+
}
|
|
14
17
|
|
|
15
18
|
// ../plugin/src/shared/data-path.ts
|
|
16
19
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -320,6 +323,15 @@ var buffer = [];
|
|
|
320
323
|
var flushTimer = null;
|
|
321
324
|
var FLUSH_INTERVAL_MS = 500;
|
|
322
325
|
var BUFFER_SIZE_LIMIT = 50;
|
|
326
|
+
var MAX_BUFFERED_BYTES = 1024 * 1024;
|
|
327
|
+
var bufferedBytes = 0;
|
|
328
|
+
var droppedLines = 0;
|
|
329
|
+
function boundBuffer() {
|
|
330
|
+
while (bufferedBytes > MAX_BUFFERED_BYTES && buffer.length > 0) {
|
|
331
|
+
bufferedBytes -= Buffer.byteLength(buffer.shift() ?? "");
|
|
332
|
+
droppedLines++;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
323
335
|
var MAX_LOG_FILE_BYTES = 32 * 1024 * 1024;
|
|
324
336
|
var SIZE_CHECK_INTERVAL_FLUSHES = 64;
|
|
325
337
|
var activeLogFile = null;
|
|
@@ -410,12 +422,12 @@ function flush() {
|
|
|
410
422
|
clearTimeout(flushTimer);
|
|
411
423
|
flushTimer = null;
|
|
412
424
|
}
|
|
413
|
-
if (buffer.length === 0)
|
|
425
|
+
if (buffer.length === 0 && droppedLines === 0)
|
|
414
426
|
return;
|
|
415
|
-
const
|
|
416
|
-
|
|
427
|
+
const notice = droppedLines ? `[${new Date().toISOString()}] [magic-context][global] logger dropped ${droppedLines} ${droppedLines === 1 ? "line" : "lines"}: buffer exceeded ${MAX_BUFFERED_BYTES} bytes while writes were pending
|
|
428
|
+
` : "";
|
|
417
429
|
try {
|
|
418
|
-
const data = capLogData(
|
|
430
|
+
const data = capLogData(notice + buffer.join(""));
|
|
419
431
|
const logFile = getMagicContextLogPath();
|
|
420
432
|
ensureDir(logFile);
|
|
421
433
|
let currentSize = getCurrentLogSize(logFile);
|
|
@@ -425,6 +437,9 @@ function flush() {
|
|
|
425
437
|
currentSize = 0;
|
|
426
438
|
}
|
|
427
439
|
fs.appendFileSync(logFile, data, { encoding: "utf8", mode: 384 });
|
|
440
|
+
buffer = [];
|
|
441
|
+
bufferedBytes = 0;
|
|
442
|
+
droppedLines = 0;
|
|
428
443
|
activeLogFile = logFile;
|
|
429
444
|
activeLogSize = currentSize + dataSize;
|
|
430
445
|
flushesSinceSizeCheck++;
|
|
@@ -433,6 +448,7 @@ function flush() {
|
|
|
433
448
|
activeLogSize = null;
|
|
434
449
|
flushesSinceSizeCheck = 0;
|
|
435
450
|
recordSwallowedWrite(error);
|
|
451
|
+
boundBuffer();
|
|
436
452
|
}
|
|
437
453
|
}
|
|
438
454
|
function scheduleFlush() {
|
|
@@ -450,8 +466,11 @@ function log(message, data) {
|
|
|
450
466
|
const timestamp = new Date().toISOString();
|
|
451
467
|
const serialized = data === undefined ? "" : data instanceof Error ? ` ${sanitizeDiagnosticText(`${data.message}${data.stack ? `
|
|
452
468
|
${data.stack}` : ""}`)}` : ` ${JSON.stringify(sanitizeConfigValue(data))}`;
|
|
453
|
-
|
|
454
|
-
|
|
469
|
+
const line = `[${timestamp}] ${sanitizeDiagnosticText(message)}${serialized}
|
|
470
|
+
`;
|
|
471
|
+
buffer.push(line);
|
|
472
|
+
bufferedBytes += Buffer.byteLength(line);
|
|
473
|
+
boundBuffer();
|
|
455
474
|
if (buffer.length >= BUFFER_SIZE_LIMIT) {
|
|
456
475
|
flush();
|
|
457
476
|
} else {
|
|
@@ -469,4 +488,4 @@ if (!isTestEnv) {
|
|
|
469
488
|
process.on("exit", flush);
|
|
470
489
|
}
|
|
471
490
|
|
|
472
|
-
export { setHarness, getHarness, getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir, sanitizeDiagnosticText, hasShareabilitySensitiveText, log, sessionLog, flushLogger };
|
|
491
|
+
export { setHarness, getHarness, harnessOwnsOpenCodeStore, getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir, sanitizeDiagnosticText, hasShareabilitySensitiveText, log, sessionLog, flushLogger };
|