@cortexkit/opencode-magic-context 0.41.0 → 0.41.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/config/schema/magic-context.d.ts +15 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-xj1r88a7.js → conflict-warning-hook-rf17b6et.js} +3 -3
- package/dist/{derive-budgets-3xfyphvk.js → derive-budgets-9q2d3r93.js} +2 -2
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +16 -17
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/context-authority.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +21 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -6
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-failure.d.ts +10 -2
- package/dist/features/magic-context/memory/embedding-failure.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +19 -2
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts +10 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts +3 -0
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +4 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts +2 -0
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts +3 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-web-entry.d.ts +2 -0
- package/dist/features/magic-context/memory/transformers-web-entry.d.ts.map +1 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +28 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +15 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +18 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +19 -2
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts +3 -2
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +2 -2
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-ops.d.ts +2 -0
- package/dist/features/magic-context/storage-ops.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +13 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/hooks/magic-context/boundary-execution.d.ts +3 -0
- package/dist/hooks/magic-context/boundary-execution.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +4 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/live-session-state.d.ts +3 -1
- package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +9 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +13 -37
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +12 -5
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts +3 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +28 -2
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-b4gv9f7g.js → index-4x691bz5.js} +87 -2
- package/dist/{index-knna83k0.js → index-9j3tx8hy.js} +1 -1
- package/dist/{index-jmwq2wxr.js → index-b9j85d29.js} +1 -1
- package/dist/{index-2bykz3bx.js → index-cvda5jb3.js} +7 -2
- package/dist/{index-bf799gbq.js → index-d1mxrd3p.js} +0 -1
- package/dist/{index-dmgbar7r.js → index-eq9wr75c.js} +2 -2
- package/dist/{index-w8rkbhn6.js → index-j8r0ejb3.js} +1232 -261
- package/dist/{index-26ds03jd.js → index-vnz6jvdc.js} +1 -1
- package/dist/{index-x9dmzyp5.js → index-y1yr57fw.js} +81 -17
- package/dist/{index-88za3sz8.js → index-zwjhba2r.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1771 -1109
- package/dist/{model-resolution-jgrkt0z2.js → model-resolution-6w6wzw18.js} +1 -1
- package/dist/plugin/dream-timer.d.ts +4 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/embedding-routing.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{recomp-orchestrator-1w4xj6jt.js → recomp-orchestrator-m37p3fq6.js} +6 -6
- package/dist/{safe-notification-target-p0c0csxw.js → safe-notification-target-2a8py95v.js} +2 -2
- package/dist/{send-session-notification-kn34g7mx.js → send-session-notification-bw7eex6w.js} +3 -3
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/logger.d.ts.map +1 -1
- package/dist/shared/model-resolution.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +3 -1
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/summarize-child-stderr.d.ts +2 -0
- package/dist/shared/summarize-child-stderr.d.ts.map +1 -0
- package/dist/shared/test-temp-dir.d.ts +40 -0
- package/dist/shared/test-temp-dir.d.ts.map +1 -0
- package/dist/shared/window-geometry.d.ts +2 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/{storage-meta-session-snbzd26z.js → storage-meta-session-dse3qv6s.js} +5 -3
- package/dist/{task-config-ty08ptc2.js → task-config-gv6s04fp.js} +2 -2
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +2 -0
- package/dist/tools/ctx-memory/types.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/transformers-node-wasm.js +25676 -0
- package/dist/transformers-web.js +24570 -0
- package/dist/transformers.node-b1wa0hgx.js +28808 -0
- package/package.json +8 -3
- package/src/config/index.test.ts +50 -4
- package/src/config/latch-permanence-guard.test.ts +5 -0
- package/src/config/schema/magic-context.test.ts +20 -0
- package/src/config/schema/magic-context.ts +8 -0
- package/src/shared/conflict-detector.test.ts +6 -19
- package/src/shared/conflict-fixer.test.ts +5 -8
- package/src/shared/index.ts +1 -0
- package/src/shared/logger.test.ts +135 -40
- package/src/shared/logger.ts +115 -2
- package/src/shared/model-resolution.test.ts +21 -19
- package/src/shared/model-resolution.ts +0 -1
- package/src/shared/rpc-utils.test.ts +246 -5
- package/src/shared/rpc-utils.ts +340 -49
- package/src/shared/summarize-child-stderr.test.ts +55 -0
- package/src/shared/summarize-child-stderr.ts +33 -0
- package/src/shared/test-temp-dir.test.ts +57 -0
- package/src/shared/test-temp-dir.ts +165 -0
- package/src/shared/window-geometry.ts +9 -0
- /package/dist/{index-rpgg35ms.js → index-8sseka65.js} +0 -0
|
@@ -213,6 +213,11 @@ var buffer = [];
|
|
|
213
213
|
var flushTimer = null;
|
|
214
214
|
var FLUSH_INTERVAL_MS = 500;
|
|
215
215
|
var BUFFER_SIZE_LIMIT = 50;
|
|
216
|
+
var MAX_LOG_FILE_BYTES = 32 * 1024 * 1024;
|
|
217
|
+
var SIZE_CHECK_INTERVAL_FLUSHES = 64;
|
|
218
|
+
var activeLogFile = null;
|
|
219
|
+
var activeLogSize = null;
|
|
220
|
+
var flushesSinceSizeCheck = 0;
|
|
216
221
|
var swallowedWriteCount = 0;
|
|
217
222
|
var lastErrorMessage = null;
|
|
218
223
|
var lastErrorTime = null;
|
|
@@ -226,6 +231,73 @@ function recordSwallowedWrite(error) {
|
|
|
226
231
|
function ensureDir(filePath) {
|
|
227
232
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
228
233
|
}
|
|
234
|
+
function isMissingFile(error) {
|
|
235
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
236
|
+
}
|
|
237
|
+
function getCurrentLogSize(logFile) {
|
|
238
|
+
if (activeLogFile === logFile && activeLogSize !== null && flushesSinceSizeCheck < SIZE_CHECK_INTERVAL_FLUSHES) {
|
|
239
|
+
return activeLogSize;
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
const stat = fs.statSync(logFile);
|
|
243
|
+
if (!stat.isFile()) {
|
|
244
|
+
throw new Error(`Magic Context log path is not a regular file: ${logFile}`);
|
|
245
|
+
}
|
|
246
|
+
fs.chmodSync(logFile, 384);
|
|
247
|
+
activeLogFile = logFile;
|
|
248
|
+
activeLogSize = stat.size;
|
|
249
|
+
flushesSinceSizeCheck = 0;
|
|
250
|
+
return stat.size;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (!isMissingFile(error))
|
|
253
|
+
throw error;
|
|
254
|
+
activeLogFile = logFile;
|
|
255
|
+
activeLogSize = 0;
|
|
256
|
+
flushesSinceSizeCheck = 0;
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function capLogData(data) {
|
|
261
|
+
if (Buffer.byteLength(data) <= MAX_LOG_FILE_BYTES)
|
|
262
|
+
return data;
|
|
263
|
+
let bounded = Buffer.from(data).subarray(0, MAX_LOG_FILE_BYTES).toString("utf8");
|
|
264
|
+
while (Buffer.byteLength(bounded) > MAX_LOG_FILE_BYTES) {
|
|
265
|
+
bounded = bounded.slice(0, -1);
|
|
266
|
+
}
|
|
267
|
+
return bounded;
|
|
268
|
+
}
|
|
269
|
+
function writeBoundedPredecessor(logFile, predecessorPath, size) {
|
|
270
|
+
const predecessorFd = fs.openSync(predecessorPath, "w", 384);
|
|
271
|
+
try {
|
|
272
|
+
fs.fchmodSync(predecessorFd, 384);
|
|
273
|
+
const bytesToCopy = Math.min(size, MAX_LOG_FILE_BYTES);
|
|
274
|
+
const sourceFd = fs.openSync(logFile, "r");
|
|
275
|
+
try {
|
|
276
|
+
const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, bytesToCopy));
|
|
277
|
+
let remaining = bytesToCopy;
|
|
278
|
+
let position = Math.max(0, size - bytesToCopy);
|
|
279
|
+
while (remaining > 0) {
|
|
280
|
+
const bytesRead = fs.readSync(sourceFd, chunk, 0, Math.min(chunk.length, remaining), position);
|
|
281
|
+
if (bytesRead === 0)
|
|
282
|
+
break;
|
|
283
|
+
fs.writeSync(predecessorFd, chunk, 0, bytesRead);
|
|
284
|
+
remaining -= bytesRead;
|
|
285
|
+
position += bytesRead;
|
|
286
|
+
}
|
|
287
|
+
} finally {
|
|
288
|
+
fs.closeSync(sourceFd);
|
|
289
|
+
}
|
|
290
|
+
} finally {
|
|
291
|
+
fs.closeSync(predecessorFd);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function rotateLogFile(logFile, size) {
|
|
295
|
+
const predecessorPath = `${logFile}.1`;
|
|
296
|
+
writeBoundedPredecessor(logFile, predecessorPath, size);
|
|
297
|
+
fs.truncateSync(logFile, 0);
|
|
298
|
+
activeLogSize = 0;
|
|
299
|
+
flushesSinceSizeCheck = 0;
|
|
300
|
+
}
|
|
229
301
|
function flush() {
|
|
230
302
|
if (flushTimer) {
|
|
231
303
|
clearTimeout(flushTimer);
|
|
@@ -233,13 +305,26 @@ function flush() {
|
|
|
233
305
|
}
|
|
234
306
|
if (buffer.length === 0)
|
|
235
307
|
return;
|
|
236
|
-
const
|
|
308
|
+
const bufferedData = buffer.join("");
|
|
237
309
|
buffer = [];
|
|
238
310
|
try {
|
|
311
|
+
const data = capLogData(bufferedData);
|
|
239
312
|
const logFile = getMagicContextLogPath();
|
|
240
313
|
ensureDir(logFile);
|
|
241
|
-
|
|
314
|
+
let currentSize = getCurrentLogSize(logFile);
|
|
315
|
+
const dataSize = Buffer.byteLength(data);
|
|
316
|
+
if (currentSize > 0 && currentSize + dataSize > MAX_LOG_FILE_BYTES) {
|
|
317
|
+
rotateLogFile(logFile, currentSize);
|
|
318
|
+
currentSize = 0;
|
|
319
|
+
}
|
|
320
|
+
fs.appendFileSync(logFile, data, { encoding: "utf8", mode: 384 });
|
|
321
|
+
activeLogFile = logFile;
|
|
322
|
+
activeLogSize = currentSize + dataSize;
|
|
323
|
+
flushesSinceSizeCheck++;
|
|
242
324
|
} catch (error) {
|
|
325
|
+
activeLogFile = null;
|
|
326
|
+
activeLogSize = null;
|
|
327
|
+
flushesSinceSizeCheck = 0;
|
|
243
328
|
recordSwallowedWrite(error);
|
|
244
329
|
}
|
|
245
330
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./index-2wchnyk6.js";
|
|
4
4
|
import {
|
|
5
5
|
sessionLog
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-4x691bz5.js";
|
|
7
7
|
import {
|
|
8
8
|
getDataDir,
|
|
9
9
|
getHarness,
|
|
@@ -215,6 +215,11 @@ function readWindowOverlayFile(path, log = (message) => sessionLog("global", mes
|
|
|
215
215
|
return parsed.overlay;
|
|
216
216
|
}
|
|
217
217
|
function setWindowOverlayPath(path) {
|
|
218
|
+
if (configuredOverlayPath === path)
|
|
219
|
+
return;
|
|
220
|
+
reloadWindowOverlay(path);
|
|
221
|
+
}
|
|
222
|
+
function reloadWindowOverlay(path) {
|
|
218
223
|
configuredOverlayPath = path;
|
|
219
224
|
loadedOverlayPath = undefined;
|
|
220
225
|
loadedOverlay = undefined;
|
|
@@ -730,4 +735,4 @@ function resolveHistorianContextLimit(historianModelOverride) {
|
|
|
730
735
|
return DEFAULT_HISTORIAN_CONTEXT_FALLBACK;
|
|
731
736
|
}
|
|
732
737
|
|
|
733
|
-
export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision, deriveTriggerBudget, deriveHistorianChunkTokens, resolveHistorianContextLimit };
|
|
738
|
+
export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, reloadWindowOverlay, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision, deriveTriggerBudget, deriveHistorianChunkTokens, resolveHistorianContextLimit };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./index-8mtsfhyg.js";
|
|
4
4
|
import {
|
|
5
5
|
waitForSafeNotificationTarget
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-vnz6jvdc.js";
|
|
7
7
|
import {
|
|
8
8
|
log
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-4x691bz5.js";
|
|
10
10
|
import {
|
|
11
11
|
__require
|
|
12
12
|
} from "./index-1yh8g550.js";
|