@cortexkit/pi-magic-context 0.49.89 → 0.49.90

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.
Files changed (2) hide show
  1. package/dist/index.js +44 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3624,7 +3624,7 @@ function startHostStallProfilerSwitch() {
3624
3624
  // package.json
3625
3625
  var package_default = {
3626
3626
  name: "@cortexkit/pi-magic-context",
3627
- version: "0.49.89",
3627
+ version: "0.49.90",
3628
3628
  type: "module",
3629
3629
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3630
3630
  main: "dist/index.js",
@@ -35712,6 +35712,49 @@ function dropCompartmentsAfter(db, sessionId, anchor, holderId, activeBranch = f
35712
35712
  }
35713
35713
  function repairMissingHistoryBoundary(args) {
35714
35714
  const { db, sessionId, isInHostStore, scope = "store" } = args;
35715
+ const removed = args.removedByCommittedRevert;
35716
+ if (removed) {
35717
+ const firstRemoved = removed.values().next().value;
35718
+ if (firstRemoved === undefined)
35719
+ return { kind: "intact" };
35720
+ const busy = {
35721
+ kind: "unresolved",
35722
+ reason: "busy",
35723
+ missingEndMessageId: firstRemoved
35724
+ };
35725
+ const holderId = crypto.randomUUID();
35726
+ if (getActiveCompartmentRun(sessionId) || !acquireCompartmentLease(db, sessionId, holderId))
35727
+ return busy;
35728
+ try {
35729
+ const boundaries = readStoreBoundaries(db, sessionId);
35730
+ const first = boundaries.findIndex(({ endMessageId }) => removed.has(endMessageId));
35731
+ const affected = boundaries[first];
35732
+ if (!affected)
35733
+ return { kind: "intact" };
35734
+ const previous = boundaries[first - 1];
35735
+ let anchor = null;
35736
+ if (previous) {
35737
+ const row = db.prepare("SELECT end_message AS endMessage FROM compartments WHERE session_id = ? AND sequence = ?").get(sessionId, previous.sequence);
35738
+ if (!row)
35739
+ return busy;
35740
+ anchor = { ...previous, endMessage: row.endMessage };
35741
+ }
35742
+ const dropped = dropCompartmentsAfter(db, sessionId, anchor, holderId, false, () => args.onRetire?.(boundaries.slice(first), anchor));
35743
+ if (dropped === null)
35744
+ return busy;
35745
+ invalidateAutoEmbedSession(sessionId);
35746
+ forgetCachedPrefix(sessionId);
35747
+ sessionLog2(sessionId, `committed revert history repair: removed compartments ${dropped.join(",")} and cleared the cached history; removed boundary ${affected.endMessageId}`);
35748
+ return {
35749
+ kind: "repaired",
35750
+ missingEndMessageId: affected.endMessageId,
35751
+ anchorEndMessageId: anchor?.endMessageId ?? "",
35752
+ droppedSequences: dropped
35753
+ };
35754
+ } finally {
35755
+ releaseCompartmentLeaseBestEffort(db, sessionId, holderId);
35756
+ }
35757
+ }
35715
35758
  const compartments = scope === "active-branch" ? db.prepare("SELECT sequence, COALESCE(end_message_id, '') AS endMessageId FROM compartments WHERE session_id = ? ORDER BY sequence").all(sessionId) : readStoreBoundaries(db, sessionId);
35716
35759
  let latestIndex = compartments.length - 1;
35717
35760
  while (latestIndex >= 0 && !compartments[latestIndex]?.endMessageId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.89",
3
+ "version": "0.49.90",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",