@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
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./index-2wchnyk6.js";
|
|
4
4
|
import {
|
|
5
5
|
withReadOnlySessionDb
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-b9j85d29.js";
|
|
7
7
|
import {
|
|
8
8
|
log
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-4x691bz5.js";
|
|
10
10
|
import {
|
|
11
11
|
getHarness
|
|
12
12
|
} from "./index-37yzyeca.js";
|
|
@@ -419,15 +419,38 @@ var SESSION_SCOPED_TABLES = [
|
|
|
419
419
|
{ table: "embedding_measurement_corpus" },
|
|
420
420
|
{ table: "pending_session_cleanup", harnessScoped: true },
|
|
421
421
|
{ table: "message_history_fts" },
|
|
422
|
+
{ table: "message_fts_rowid_map" },
|
|
422
423
|
{ table: "message_history_source", harnessScoped: true },
|
|
423
424
|
{ table: "message_history_index", harnessScoped: true },
|
|
424
425
|
{ table: "lkg_slots" }
|
|
425
426
|
];
|
|
426
|
-
function deleteSessionScopedRows(db, sessionIds, harness) {
|
|
427
|
+
function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
427
428
|
if (sessionIds.length === 0)
|
|
428
|
-
return;
|
|
429
|
-
|
|
429
|
+
return 0;
|
|
430
|
+
let deletableSessionIds = [...sessionIds];
|
|
431
|
+
if (options.rustModuleCleanupAcknowledged !== true) {
|
|
432
|
+
const placeholders2 = sessionIds.map(() => "?").join(", ");
|
|
433
|
+
const harnessPredicate = harness === undefined ? "" : " AND harness = ?";
|
|
434
|
+
const protectedRows = db.prepare(`SELECT session_id
|
|
435
|
+
FROM pending_session_cleanup
|
|
436
|
+
WHERE session_id IN (${placeholders2})
|
|
437
|
+
AND harness LIKE '%:rust'${harnessPredicate}`).all(...sessionIds, ...harness === undefined ? [] : [`${harness}:rust`]);
|
|
438
|
+
const protectedSessionIds = new Set(protectedRows.map((row) => row.session_id));
|
|
439
|
+
deletableSessionIds = sessionIds.filter((sessionId) => !protectedSessionIds.has(sessionId));
|
|
440
|
+
}
|
|
441
|
+
if (deletableSessionIds.length === 0)
|
|
442
|
+
return 0;
|
|
443
|
+
const placeholders = deletableSessionIds.map(() => "?").join(", ");
|
|
430
444
|
for (const definition of SESSION_SCOPED_TABLES) {
|
|
445
|
+
if (definition.table === "message_history_fts") {
|
|
446
|
+
db.prepare(`DELETE FROM message_history_fts
|
|
447
|
+
WHERE rowid IN (
|
|
448
|
+
SELECT fts_rowid
|
|
449
|
+
FROM message_fts_rowid_map
|
|
450
|
+
WHERE session_id IN (${placeholders})
|
|
451
|
+
)`).run(...deletableSessionIds);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
431
454
|
const predicates = [`session_id IN (${placeholders})`];
|
|
432
455
|
if (definition.extraPredicate)
|
|
433
456
|
predicates.push(definition.extraPredicate);
|
|
@@ -436,10 +459,11 @@ function deleteSessionScopedRows(db, sessionIds, harness) {
|
|
|
436
459
|
predicates.push("harness = ?");
|
|
437
460
|
const statement = db.prepare(`DELETE FROM ${definition.table} WHERE ${predicates.join(" AND ")}`);
|
|
438
461
|
if (bindHarness)
|
|
439
|
-
statement.run(...
|
|
462
|
+
statement.run(...deletableSessionIds, harness);
|
|
440
463
|
else
|
|
441
|
-
statement.run(...
|
|
464
|
+
statement.run(...deletableSessionIds);
|
|
442
465
|
}
|
|
466
|
+
return deletableSessionIds.length;
|
|
443
467
|
}
|
|
444
468
|
|
|
445
469
|
// src/features/magic-context/storage-meta-session.ts
|
|
@@ -540,15 +564,28 @@ function advanceToolReclaimWatermark(db, sessionId, maxTagNumber) {
|
|
|
540
564
|
db.prepare("UPDATE session_meta SET tool_reclaim_watermark = MAX(COALESCE(tool_reclaim_watermark, 0), ?) WHERE session_id = ?").run(maxTagNumber, sessionId);
|
|
541
565
|
})();
|
|
542
566
|
}
|
|
543
|
-
function
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
567
|
+
function rustCleanupHarness() {
|
|
568
|
+
return `${getHarness()}:rust`;
|
|
569
|
+
}
|
|
570
|
+
function markSessionCleanupPending(db, sessionId, rustModuleCleanupRequired = false) {
|
|
571
|
+
const row = db.prepare(`INSERT INTO pending_session_cleanup (session_id, harness, requested_at, last_attempt_at)
|
|
572
|
+
VALUES (?, ?, ?, NULL)
|
|
573
|
+
ON CONFLICT(session_id) DO UPDATE SET
|
|
574
|
+
harness = CASE
|
|
575
|
+
WHEN pending_session_cleanup.harness LIKE '%:rust'
|
|
576
|
+
THEN pending_session_cleanup.harness
|
|
577
|
+
ELSE excluded.harness
|
|
578
|
+
END,
|
|
579
|
+
requested_at = MIN(pending_session_cleanup.requested_at, excluded.requested_at)
|
|
580
|
+
RETURNING harness`).get(sessionId, rustModuleCleanupRequired ? rustCleanupHarness() : getHarness(), Date.now());
|
|
581
|
+
return row.harness.endsWith(":rust");
|
|
549
582
|
}
|
|
550
583
|
function retryPendingSessionCleanups(db, limit = 200) {
|
|
551
|
-
const rows = db.prepare(
|
|
584
|
+
const rows = db.prepare(`SELECT session_id
|
|
585
|
+
FROM pending_session_cleanup
|
|
586
|
+
WHERE harness NOT LIKE '%:rust'
|
|
587
|
+
ORDER BY requested_at ASC, session_id ASC
|
|
588
|
+
LIMIT ?`).all(Math.max(1, Math.floor(limit)));
|
|
552
589
|
const failedSessionIds = [];
|
|
553
590
|
let cleared = 0;
|
|
554
591
|
for (const row of rows) {
|
|
@@ -562,12 +599,39 @@ function retryPendingSessionCleanups(db, limit = 200) {
|
|
|
562
599
|
}
|
|
563
600
|
return { attempted: rows.length, cleared, failedSessionIds };
|
|
564
601
|
}
|
|
565
|
-
function
|
|
602
|
+
async function retryPendingRustSessionCleanupsForProject(db, projectPath, deleteSession, limit = 200) {
|
|
603
|
+
const harness = getHarness();
|
|
604
|
+
const rows = db.prepare(`SELECT pending.session_id
|
|
605
|
+
FROM pending_session_cleanup pending
|
|
606
|
+
JOIN session_projects projects
|
|
607
|
+
ON projects.session_id = pending.session_id
|
|
608
|
+
AND projects.harness = ?
|
|
609
|
+
WHERE pending.harness = ?
|
|
610
|
+
AND projects.project_path = ?
|
|
611
|
+
ORDER BY pending.requested_at ASC, pending.session_id ASC
|
|
612
|
+
LIMIT ?`).all(harness, rustCleanupHarness(), projectPath, Math.max(1, Math.floor(limit)));
|
|
613
|
+
const failedSessionIds = [];
|
|
614
|
+
let cleared = 0;
|
|
615
|
+
for (const row of rows) {
|
|
616
|
+
try {
|
|
617
|
+
db.prepare("UPDATE pending_session_cleanup SET last_attempt_at = ? WHERE session_id = ?").run(Date.now(), row.session_id);
|
|
618
|
+
await deleteSession(row.session_id);
|
|
619
|
+
clearSession(db, row.session_id, true);
|
|
620
|
+
cleared += 1;
|
|
621
|
+
} catch {
|
|
622
|
+
failedSessionIds.push(row.session_id);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return { attempted: rows.length, cleared, failedSessionIds };
|
|
626
|
+
}
|
|
627
|
+
function clearSession(db, sessionId, rustModuleCleanupAcknowledged = false) {
|
|
566
628
|
const transactionStartedAt = performance.now();
|
|
567
629
|
db.transaction(() => {
|
|
568
|
-
deleteSessionScopedRows(db, [sessionId]
|
|
630
|
+
deleteSessionScopedRows(db, [sessionId], undefined, {
|
|
631
|
+
rustModuleCleanupAcknowledged
|
|
632
|
+
});
|
|
569
633
|
})();
|
|
570
634
|
logSlowWriteTransaction("clear-session", transactionStartedAt);
|
|
571
635
|
}
|
|
572
636
|
|
|
573
|
-
export { logSlowWriteTransaction, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, deleteSessionScopedRows, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, clearSession };
|
|
637
|
+
export { logSlowWriteTransaction, ensureSessionMetaRow, persistCachedM0, clearCachedM0M1, SESSION_SCOPED_TABLES, deleteSessionScopedRows, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isMidTurn
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-b9j85d29.js";
|
|
4
4
|
import {
|
|
5
5
|
sessionLog
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-4x691bz5.js";
|
|
7
7
|
import {
|
|
8
8
|
__require
|
|
9
9
|
} from "./index-1yh8g550.js";
|
|
@@ -171,7 +171,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
|
|
|
171
171
|
queueIgnoredNotification({ client, sessionId, text, params, forcePersist });
|
|
172
172
|
return "queued";
|
|
173
173
|
}
|
|
174
|
-
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-
|
|
174
|
+
const { waitForSafeNotificationTarget } = await import("./safe-notification-target-2a8py95v.js");
|
|
175
175
|
if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
|
|
176
176
|
sessionLog(sessionId, "notification skipped (session not titled yet)");
|
|
177
177
|
return "skipped";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA40BvE,QAAA,MAAM,MAAM,EAAE,YAGb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|