@cortexkit/opencode-magic-context 0.49.41 → 0.49.43

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 (75) hide show
  1. package/dist/auto-search-worker.js +1 -1
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/{context-3szg46w6.js → context-zf1yj1g0.js} +167 -47
  4. package/dist/hooks/magic-context/host-served-rows.d.ts +17 -0
  5. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
  6. package/dist/hooks/magic-context/lkg-replay.d.ts +2 -0
  7. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  8. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +2 -0
  9. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  10. package/dist/hooks/magic-context/transform.d.ts +3 -0
  11. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  12. package/dist/{index-j8gv6ajw.js → index-1zv08avf.js} +4 -4
  13. package/dist/{index-4y35msh5.js → index-29gd1zcx.js} +1 -1
  14. package/dist/{index-aed5qpyv.js → index-5m2azs6v.js} +3 -3
  15. package/dist/{index-216tae7b.js → index-adt3jghq.js} +16 -15
  16. package/dist/{index-bgxpadsx.js → index-ayk4we2k.js} +11 -5
  17. package/dist/{index-j5qma52p.js → index-fas76dft.js} +2 -2
  18. package/dist/{index-9z4d2ha0.js → index-gsqz39wk.js} +1 -1
  19. package/dist/{index-9fgmkfaf.js → index-kfsqk1q7.js} +1 -1
  20. package/dist/{index-z7etaphs.js → index-n8bsqg7b.js} +4 -4
  21. package/dist/{index-hb76vdmm.js → index-p2e7j9p1.js} +1 -1
  22. package/dist/{index-72czy45z.js → index-rdx17j04.js} +36 -8
  23. package/dist/{v2/server-z9zygwse.js → index-s9x93tfs.js} +32 -1
  24. package/dist/{index-j105mf16.js → index-xjw9rres.js} +1 -1
  25. package/dist/{index-q9gamh8e.js → index-xmqj3cf5.js} +5 -5
  26. package/dist/{index-ryz4pdvf.js → index-z6v8086q.js} +2 -2
  27. package/dist/{index-tn9drm1a.js → index-zqsp3z0d.js} +1 -1
  28. package/dist/index.js +17 -17
  29. package/dist/{message-index-bounded-jqm3ezva.js → message-index-bounded-5mj8p6nq.js} +2 -2
  30. package/dist/migration-worker.js +1 -1
  31. package/dist/raw-ordinal-warmup-worker.js +3 -3
  32. package/dist/{read-session-chunk-26yrrhyz.js → read-session-chunk-k70bhfjm.js} +1 -1
  33. package/dist/{recomp-orchestrator-7v52khmf.js → recomp-orchestrator-2q4rmerf.js} +6 -6
  34. package/dist/{render-gqdq6t7f.js → render-36fvvwz6.js} +5 -5
  35. package/dist/{search-vqkmmy9c.js → search-6v2na3af.js} +4 -4
  36. package/dist/{search-archive-kfwpk73t.js → search-archive-jwb2ctnq.js} +3 -3
  37. package/dist/{store-s3eykdjt.js → store-pd1e9hnr.js} +1 -1
  38. package/dist/{transform-postprocess-phase-6fpgz12m.js → transform-postprocess-phase-0ms3ga4h.js} +7 -7
  39. package/dist/v2/auto-search-worker.js +1 -1
  40. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  41. package/dist/v2/{context-eq5bhf40.js → context-2xr6vbt2.js} +175 -50
  42. package/dist/v2/fold/code-mode-catalog.d.ts +10 -0
  43. package/dist/v2/fold/code-mode-catalog.d.ts.map +1 -1
  44. package/dist/v2/fold/instruction-supersession.d.ts +9 -0
  45. package/dist/v2/fold/instruction-supersession.d.ts.map +1 -0
  46. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  47. package/dist/v2/hooks/context.d.ts.map +1 -1
  48. package/dist/v2/hooks/payload.d.ts +2 -1
  49. package/dist/v2/hooks/payload.d.ts.map +1 -1
  50. package/dist/v2/{message-index-bounded-dgd8a2x1.js → message-index-bounded-5341qsqd.js} +2 -2
  51. package/dist/v2/migration-worker.js +1 -1
  52. package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
  53. package/dist/v2/{read-session-chunk-tqnh1ret.js → read-session-chunk-dgmq3ntm.js} +1 -1
  54. package/dist/v2/{recomp-orchestrator-kep59sph.js → recomp-orchestrator-2vmyhtst.js} +5 -5
  55. package/dist/v2/{render-yyv8nv4p.js → render-kz0f40ws.js} +5 -5
  56. package/dist/v2/{search-cb1kdgqw.js → search-a9hwy1sw.js} +3 -3
  57. package/dist/v2/{search-archive-gagdnrb3.js → search-archive-wajxd01m.js} +3 -3
  58. package/dist/v2/{server-g3gqq4ac.js → server-09td1wgc.js} +1 -1
  59. package/dist/v2/{server-dt9b00ja.js → server-3m7p4g9w.js} +1 -1
  60. package/dist/v2/{server-hewk7z3z.js → server-5ydn39x3.js} +5 -5
  61. package/dist/v2/{server-t8y64xj7.js → server-7qc9tk6z.js} +36 -8
  62. package/dist/v2/{server-r4mmc670.js → server-dqs8e4yt.js} +1 -1
  63. package/dist/v2/{server-jd7vzwn4.js → server-kqrpt2ht.js} +1 -1
  64. package/dist/v2/{server-qjyp27vf.js → server-p78wdf43.js} +1 -1
  65. package/dist/v2/{server-2d01821b.js → server-qehn6btp.js} +2 -2
  66. package/dist/{index-z9zygwse.js → v2/server-s9x93tfs.js} +32 -1
  67. package/dist/v2/{server-2tp6y1qs.js → server-sfcp13bn.js} +4 -4
  68. package/dist/v2/{server-6emy0v9a.js → server-ymn9w46x.js} +1 -1
  69. package/dist/v2/server.js +2 -2
  70. package/dist/v2/{store-z3qe67cg.js → store-pebs9m52.js} +1 -1
  71. package/dist/v2/{v2-archive-reader-2rv5dz7k.js → v2-archive-reader-ag6sk771.js} +1 -1
  72. package/dist/v2/{wrapup-orchestrator-1mgx1nym.js → wrapup-orchestrator-2a077zew.js} +5 -5
  73. package/dist/{v2-archive-reader-4hz9pnmy.js → v2-archive-reader-chk95syc.js} +1 -1
  74. package/dist/{wrapup-orchestrator-yy0n9mxy.js → wrapup-orchestrator-rhs675kj.js} +7 -7
  75. package/package.json +1 -1
@@ -8,7 +8,7 @@ import {
8
8
  releaseCompartmentLeaseBestEffort,
9
9
  getCompartments,
10
10
  getLastCompartmentEndMessage
11
- } from "./index-72czy45z.js";
11
+ } from "./index-rdx17j04.js";
12
12
  import {
13
13
  inRootAsyncContext2
14
14
  } from "./index-gzy5w8ya.js";
@@ -20,7 +20,7 @@ import {
20
20
  getHistorianFailureState,
21
21
  clearEmergencyRecovery,
22
22
  prepareRawSessionOrdinals2
23
- } from "./index-tn9drm1a.js";
23
+ } from "./index-zqsp3z0d.js";
24
24
  import {
25
25
  pushNotification2
26
26
  } from "./index-x8a7jmkh.js";
@@ -32,14 +32,14 @@ import {
32
32
  getActiveCompartmentRun,
33
33
  markActiveCompartmentRunPublished,
34
34
  registerActiveCompartmentRun
35
- } from "./index-q9gamh8e.js";
35
+ } from "./index-xmqj3cf5.js";
36
36
  import {
37
37
  sendStatusNotification2
38
38
  } from "./index-ae1ar4v1.js";
39
39
  import {
40
40
  setRecompStarting2,
41
41
  setRecompTerminal2
42
- } from "./index-aed5qpyv.js";
42
+ } from "./index-5m2azs6v.js";
43
43
 
44
44
  // src/hooks/magic-context/wrapup-orchestrator.ts
45
45
  import * as crypto from "node:crypto";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-66a50f3e.js";
7
7
  import {
8
8
  markHostUnservedRow
9
- } from "./index-z9zygwse.js";
9
+ } from "./index-s9x93tfs.js";
10
10
 
11
11
  // src/v2/fold/restore.ts
12
12
  import { fileURLToPath } from "node:url";
@@ -3,14 +3,14 @@ import {
3
3
  } from "./index-jrfre9ah.js";
4
4
  import {
5
5
  clearEmergencyRecovery
6
- } from "./index-tn9drm1a.js";
6
+ } from "./index-zqsp3z0d.js";
7
7
  import {
8
8
  requestPendingMaterialization,
9
9
  dropSlot
10
- } from "./index-72czy45z.js";
10
+ } from "./index-rdx17j04.js";
11
11
  import {
12
12
  executeContextRecomp
13
- } from "./index-q9gamh8e.js";
13
+ } from "./index-xmqj3cf5.js";
14
14
  import {
15
15
  renderUserFacingFailure,
16
16
  userFacingFailureCode
@@ -191,7 +191,7 @@ import {
191
191
  snapRangeToCompartments,
192
192
  getActiveCompartmentRun,
193
193
  startCompartmentAgent
194
- } from "./index-q9gamh8e.js";
194
+ } from "./index-xmqj3cf5.js";
195
195
  import {
196
196
  hasTrustedAbsoluteWall,
197
197
  applyProvenInputFloor,
@@ -416,7 +416,7 @@ import {
416
416
  readRawSessionMessageById2,
417
417
  readSessionChunk2,
418
418
  readRawSessionSeedTail2
419
- } from "./index-tn9drm1a.js";
419
+ } from "./index-zqsp3z0d.js";
420
420
  import {
421
421
  BoundedSessionMap,
422
422
  getMeasuredToolDefinitionTokens
@@ -446,7 +446,7 @@ import {
446
446
  runSqliteOptimize,
447
447
  openDatabase,
448
448
  openCurrentDatabase
449
- } from "./index-9fgmkfaf.js";
449
+ } from "./index-kfsqk1q7.js";
450
450
  import {
451
451
  unescapeXml,
452
452
  resolveWorkspaceShareCategories,
@@ -555,10 +555,10 @@ import {
555
555
  GLOBAL_USER_PROFILE_PROJECT_PATH,
556
556
  getProjectState,
557
557
  bumpProjectUserProfileVersion
558
- } from "./index-72czy45z.js";
558
+ } from "./index-rdx17j04.js";
559
559
  import {
560
560
  getLastIndexedOrdinal
561
- } from "./index-9z4d2ha0.js";
561
+ } from "./index-gsqz39wk.js";
562
562
  import {
563
563
  SESSION_NOTE_CONDITION_ERROR,
564
564
  getNoteByIdInScope,
@@ -691,13 +691,13 @@ import {
691
691
  resolveMemoriesByIdsForSearch2,
692
692
  unifiedSearch2,
693
693
  formatSearchResults2
694
- } from "./index-j5qma52p.js";
694
+ } from "./index-fas76dft.js";
695
695
  import {
696
696
  scheduleReconciliation,
697
697
  scheduleIncrementalIndex,
698
698
  getMessageIndexQueueHeapStats,
699
699
  clearSessionTracking
700
- } from "./index-hb76vdmm.js";
700
+ } from "./index-p2e7j9p1.js";
701
701
  import {
702
702
  flushIgnoredMessages2,
703
703
  clearIgnoredMessages2,
@@ -707,7 +707,7 @@ import {
707
707
  import {
708
708
  setRecompStarting2,
709
709
  setRecompTerminal2
710
- } from "./index-aed5qpyv.js";
710
+ } from "./index-5m2azs6v.js";
711
711
  import {
712
712
  makeToolCompositeKey,
713
713
  searchMessageHistoryOffThread,
@@ -772,7 +772,7 @@ import {
772
772
  abortSessionFailClosed2,
773
773
  evaluateEmergencyFailClosed2,
774
774
  runPostTransformPhase2
775
- } from "./index-bgxpadsx.js";
775
+ } from "./index-ayk4we2k.js";
776
776
  import {
777
777
  ANNOUNCEMENT_VERSION2,
778
778
  ANNOUNCEMENT_FEATURES2,
@@ -787,13 +787,13 @@ import {
787
787
  renderMessageByOrdinal2,
788
788
  renderVerboseRangeForTool2,
789
789
  renderItemByTag2
790
- } from "./index-j105mf16.js";
790
+ } from "./index-xjw9rres.js";
791
791
  import {
792
792
  readV2ArchiveOffThread2
793
- } from "./index-z7etaphs.js";
793
+ } from "./index-n8bsqg7b.js";
794
794
  import {
795
795
  renderSearchArchiveOffThread2
796
- } from "./index-ryz4pdvf.js";
796
+ } from "./index-z6v8086q.js";
797
797
  import {
798
798
  COMPACTION_ENABLED_PATH,
799
799
  isDreamerRunnable,
@@ -802,7 +802,7 @@ import {
802
802
  import {
803
803
  takeCoveredInstructionRows,
804
804
  cloneKeepingCoveredInstructionMarks
805
- } from "./index-z9zygwse.js";
805
+ } from "./index-s9x93tfs.js";
806
806
  import {
807
807
  __toESM
808
808
  } from "./index-22jkk6wg.js";
@@ -16418,7 +16418,7 @@ function registerRpcHandlers(rpcServer, args) {
16418
16418
  const db = readDatabase();
16419
16419
  if (!db)
16420
16420
  return { ok: false, error: "db unavailable" };
16421
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-7v52khmf.js"));
16421
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-2q4rmerf.js"));
16422
16422
  const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-14p3yje4.js"));
16423
16423
  log2(`[rpc] recomp requested for session ${sessionId}`);
16424
16424
  if (!args.client && !args.hiddenCompletionExecutor) {
@@ -16503,7 +16503,7 @@ function registerRpcHandlers(rpcServer, args) {
16503
16503
  const db = readDatabase();
16504
16504
  if (!db)
16505
16505
  return { ok: false, error: "db unavailable" };
16506
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-yy0n9mxy.js"));
16506
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-rhs675kj.js"));
16507
16507
  const model = liveSessionState.liveModelBySession.get(sessionId);
16508
16508
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
16509
16509
  const ctx = {
@@ -25402,6 +25402,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
25402
25402
  sessionId,
25403
25403
  db,
25404
25404
  messages,
25405
+ reclaimHostRows: deps.reclaimHostRows,
25405
25406
  tags: activeTags,
25406
25407
  targets,
25407
25408
  reasoningByMessage,
@@ -120,11 +120,11 @@ import {
120
120
  saveSourceContent,
121
121
  replaceSourceContent,
122
122
  getSourceContents
123
- } from "./index-72czy45z.js";
123
+ } from "./index-rdx17j04.js";
124
124
  import {
125
125
  cleanSearchText,
126
126
  matchedSearchSnippet
127
- } from "./index-9z4d2ha0.js";
127
+ } from "./index-gsqz39wk.js";
128
128
  import {
129
129
  stripSystemInjection,
130
130
  isTextPart,
@@ -222,7 +222,7 @@ import {
222
222
  extractToolCallObservation,
223
223
  ToolMutationBatch,
224
224
  createToolDropTarget
225
- } from "./index-tn9drm1a.js";
225
+ } from "./index-zqsp3z0d.js";
226
226
  import {
227
227
  isValidLanguageCode
228
228
  } from "./index-c5dzns43.js";
@@ -238,7 +238,7 @@ import {
238
238
  getMessageIndexEpoch,
239
239
  isMessageIndexSearchable,
240
240
  createAutoSearchDiagnostics
241
- } from "./index-hb76vdmm.js";
241
+ } from "./index-p2e7j9p1.js";
242
242
  import {
243
243
  openCodeDbExists,
244
244
  withReadOnlySessionDb,
@@ -266,7 +266,7 @@ import {
266
266
  peekNoteNudgeText,
267
267
  markNoteNudgeDelivered,
268
268
  getActiveCompartmentRun
269
- } from "./index-q9gamh8e.js";
269
+ } from "./index-xmqj3cf5.js";
270
270
  import {
271
271
  userFacingFailureCode
272
272
  } from "./index-xnm0wq1r.js";
@@ -6707,6 +6707,11 @@ async function runPostTransformPhase2(args) {
6707
6707
  recordFirstApplicationWireEdit(false);
6708
6708
  firstApplicationLocations.set(message, Math.min(firstApplicationLocations.get(message) ?? Infinity, partIndex));
6709
6709
  };
6710
+ const hostRowReclaim = args.reclaimHostRows?.(args.sessionId, args.messages, !compactionOff && isCacheBustingPass);
6711
+ for (const message of hostRowReclaim?.edits ?? []) {
6712
+ const index = args.messages.indexOf(message);
6713
+ recordFirstApplicationWireEdit(index < 0 || servesThinkingBlock2(args.messages.slice(index + 1), args.resolvedProviderID, args.resolvedModelID));
6714
+ }
6710
6715
  let heuristicOrReasoningDidMutate = false;
6711
6716
  let heuristicOrReasoningEditBesidesTrim = false;
6712
6717
  let droppedCount = 0;
@@ -7667,6 +7672,7 @@ async function runPostTransformPhase2(args) {
7667
7672
  failPass("proactive-thinking-strip-persistence-failure");
7668
7673
  }
7669
7674
  }
7675
+ hostRowReclaim?.commit();
7670
7676
  let settledDroppedReasoning = 0;
7671
7677
  if (!canUseEmptySentinels) {
7672
7678
  let mode = "legacy";
@@ -69,14 +69,14 @@ import {
69
69
  import {
70
70
  matchedSearchSnippet,
71
71
  getIndexedMessageCorpusSize
72
- } from "./index-9z4d2ha0.js";
72
+ } from "./index-gsqz39wk.js";
73
73
  import {
74
74
  getMessageIndexEpoch,
75
75
  isMessageIndexSearchable,
76
76
  withMemoryHintContent,
77
77
  autoSearchRelevance,
78
78
  recordAutoSearchLane
79
- } from "./index-hb76vdmm.js";
79
+ } from "./index-p2e7j9p1.js";
80
80
  import {
81
81
  MESSAGE_FTS_SESSION_FILTER_SQL,
82
82
  withMessageFtsSessionFilter
@@ -9,7 +9,7 @@ import {
9
9
  } from "./index-4xyjr62e.js";
10
10
  import {
11
11
  cleanUserText2
12
- } from "./index-tn9drm1a.js";
12
+ } from "./index-zqsp3z0d.js";
13
13
  import {
14
14
  recordMessageFtsRowid2,
15
15
  recordIndexedMessageTime2,
@@ -1024,7 +1024,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1024
1024
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1025
1025
  if (signal.aborted || !readsOpenCodeStore)
1026
1026
  return;
1027
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-26yrrhyz.js"));
1027
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-k70bhfjm.js"));
1028
1028
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-39bm498k.js"));
1029
1029
  if (signal.aborted)
1030
1030
  return;
@@ -138,10 +138,10 @@ async function serveV2ArchiveReads2(port, openConnections) {
138
138
  ] = await Promise.all([
139
139
  import("./sqlite-zdgm52sv.js"),
140
140
  import("./store-reader-yh19h38c.js"),
141
- import("./store-s3eykdjt.js"),
142
- import("./read-session-chunk-26yrrhyz.js"),
143
- import("./render-gqdq6t7f.js"),
144
- import("./search-archive-kfwpk73t.js"),
141
+ import("./store-pd1e9hnr.js"),
142
+ import("./read-session-chunk-k70bhfjm.js"),
143
+ import("./render-36fvvwz6.js"),
144
+ import("./search-archive-jwb2ctnq.js"),
145
145
  import("./expand-attachments-h33jbgyz.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -28,7 +28,7 @@ import {
28
28
  clearIndexedMessages,
29
29
  indexSingleMessage,
30
30
  indexMessagesAfterOrdinal
31
- } from "./index-9z4d2ha0.js";
31
+ } from "./index-gsqz39wk.js";
32
32
 
33
33
  // src/features/magic-context/message-index-async.ts
34
34
  var indexCancellations = new Map;
@@ -63,7 +63,7 @@ import {
63
63
  serializeProcessedImageMarkers,
64
64
  getPendingPiCompactionMarkerState,
65
65
  logPiCompactionMarkerClear
66
- } from "./index-tn9drm1a.js";
66
+ } from "./index-zqsp3z0d.js";
67
67
  import {
68
68
  stripTagPrefix,
69
69
  isRecord,
@@ -85,9 +85,12 @@ import {
85
85
  V2StoreReader2
86
86
  } from "./index-66a50f3e.js";
87
87
  import {
88
+ markHostInstructionRow,
89
+ hostInstructionRowID,
90
+ isRetiredInstructionRow,
88
91
  markCoveredInstructionRow,
89
92
  isCoveredInstructionRow
90
- } from "./index-z9zygwse.js";
93
+ } from "./index-s9x93tfs.js";
91
94
  import {
92
95
  piModelRefToCanonical
93
96
  } from "./index-avwt563y.js";
@@ -2257,6 +2260,15 @@ function projectEntryWithDigests(messages, digests) {
2257
2260
  });
2258
2261
  if (isCoveredInstructionRow(message.info))
2259
2262
  markCoveredInstructionRow(projection);
2263
+ const instructionID = hostInstructionRowID(message.info);
2264
+ if (instructionID) {
2265
+ markHostInstructionRow(projection, { id: instructionID });
2266
+ const retiredDigest = lkgContentDigest({ ...message, parts: [] });
2267
+ Object.defineProperty(projection, "retiredContentDigest", {
2268
+ value: () => retiredDigest,
2269
+ enumerable: false
2270
+ });
2271
+ }
2260
2272
  return projection;
2261
2273
  });
2262
2274
  }
@@ -2366,7 +2378,7 @@ function outputMessageIsPostAnchor(message, inputIndexById, anchorIndex, systemI
2366
2378
  }
2367
2379
  function buildLkgPrefix(input, output, completeOutput = false) {
2368
2380
  const projected = asEntryProjection(input);
2369
- const anchorIndex = completeOutput && projected.length > 0 ? projected.length - 1 : findLkgAnchor(projected);
2381
+ let anchorIndex = completeOutput && projected.length > 0 ? projected.length - 1 : findLkgAnchor(projected);
2370
2382
  if (anchorIndex === null)
2371
2383
  return null;
2372
2384
  const ids = projected.map((message, index) => lkgInputIdentity(message.id, message.role, index));
@@ -2375,10 +2387,6 @@ function buildLkgPrefix(input, output, completeOutput = false) {
2375
2387
  const validIds = ids;
2376
2388
  if (new Set(validIds).size !== validIds.length)
2377
2389
  return null;
2378
- const anchorMessageId = validIds[anchorIndex];
2379
- const inputContentDigests = projected.slice(0, anchorIndex + 1).map((message) => message.contentDigest?.() ?? null);
2380
- if (inputContentDigests.some((digest) => digest === null))
2381
- return null;
2382
2390
  const inputIndexById = new Map(validIds.map((id, index) => [id, index]));
2383
2391
  const systemIndices = new Map;
2384
2392
  if (!completeOutput) {
@@ -2387,22 +2395,42 @@ function buildLkgPrefix(input, output, completeOutput = false) {
2387
2395
  const restoredCount = outputSystems.length - inputSystems.length;
2388
2396
  if (restoredCount < 0 || outputSystems.slice(0, restoredCount).some((message) => !isCoveredInstructionRow(message.info)))
2389
2397
  return null;
2398
+ let retirementAnchor = anchorIndex;
2399
+ let retirementExtensionValid = true;
2390
2400
  for (let index = 0;index < inputSystems.length; index += 1) {
2391
2401
  const source = inputSystems[index];
2392
2402
  const message = outputSystems[index + restoredCount];
2393
2403
  const digest = source.message.contentDigest?.();
2394
- if (!digest || lkgContentDigest(message) !== digest)
2404
+ const servedDigest = lkgContentDigest(message);
2405
+ const sourceID = hostInstructionRowID(source.message);
2406
+ const expectedDigest = isRetiredInstructionRow(message.info) ? sourceID && hostInstructionRowID(message.info) === sourceID ? source.message.retiredContentDigest?.() : undefined : digest;
2407
+ if (!digest)
2395
2408
  return null;
2409
+ if (!expectedDigest || servedDigest !== expectedDigest) {
2410
+ if (!isRetiredInstructionRow(message.info) || source.index <= anchorIndex)
2411
+ return null;
2412
+ retirementExtensionValid = false;
2413
+ } else if (isRetiredInstructionRow(message.info)) {
2414
+ retirementAnchor = Math.max(retirementAnchor, source.index);
2415
+ }
2396
2416
  if (isCoveredInstructionRow(message.info) && source.index > anchorIndex)
2397
2417
  return null;
2398
2418
  systemIndices.set(message, source.index);
2399
2419
  }
2420
+ if (retirementExtensionValid)
2421
+ anchorIndex = retirementAnchor;
2400
2422
  }
2423
+ const anchorMessageId = validIds[anchorIndex];
2424
+ const inputContentDigests = projected.slice(0, anchorIndex + 1).map((message) => message.contentDigest?.() ?? null);
2425
+ if (inputContentDigests.some((digest) => digest === null))
2426
+ return null;
2401
2427
  const prefix = [];
2402
2428
  for (const message of output) {
2403
2429
  const postAnchor = completeOutput ? false : outputMessageIsPostAnchor(message, inputIndexById, anchorIndex, systemIndices);
2404
2430
  if (postAnchor === null)
2405
2431
  return null;
2432
+ if (isRetiredInstructionRow(message.info) && messageRole(message) === "system" && messageParts(message).length === 0)
2433
+ continue;
2406
2434
  if (!postAnchor)
2407
2435
  prefix.push(providerVisibleMessage(message));
2408
2436
  }
@@ -57,6 +57,32 @@ function isHostRenderedSystemMessage(message) {
57
57
  return (typeof id !== "string" || id.length === 0) && message.info.role === "system";
58
58
  }
59
59
  var COVERED_INSTRUCTION_ROW = "coveredInstructionRow";
60
+ var HOST_INSTRUCTION_ROW = "hostInstructionRow";
61
+ var RETIRED_INSTRUCTION_ROW = "retiredInstructionRow";
62
+ function markHostInstructionRow(target, row) {
63
+ Object.defineProperty(target, HOST_INSTRUCTION_ROW, {
64
+ value: row,
65
+ enumerable: false,
66
+ configurable: true
67
+ });
68
+ }
69
+ function hostInstructionRow(target) {
70
+ return target[HOST_INSTRUCTION_ROW];
71
+ }
72
+ function hostInstructionRowID(target) {
73
+ const row = hostInstructionRow(target);
74
+ return typeof row?.id === "string" && row.id.length > 0 ? row.id : undefined;
75
+ }
76
+ function markRetiredInstructionRow(target) {
77
+ Object.defineProperty(target, RETIRED_INSTRUCTION_ROW, {
78
+ value: true,
79
+ enumerable: false,
80
+ configurable: true
81
+ });
82
+ }
83
+ function isRetiredInstructionRow(target) {
84
+ return target[RETIRED_INSTRUCTION_ROW] === true;
85
+ }
60
86
  function markCoveredInstructionRow(target) {
61
87
  Object.defineProperty(target, COVERED_INSTRUCTION_ROW, {
62
88
  value: true,
@@ -82,8 +108,13 @@ function cloneKeepingCoveredInstructionMarks(messages) {
82
108
  const copied = copy[index];
83
109
  if (copied && isCoveredInstructionRow(message.info))
84
110
  markCoveredInstructionRow(copied.info);
111
+ const row = hostInstructionRow(message.info);
112
+ if (copied && row !== undefined)
113
+ markHostInstructionRow(copied.info, row);
114
+ if (copied && isRetiredInstructionRow(message.info))
115
+ markRetiredInstructionRow(copied.info);
85
116
  });
86
117
  return copy;
87
118
  }
88
119
 
89
- export { markHostUnservedRow, isHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, markCoveredInstructionRow, isCoveredInstructionRow, takeCoveredInstructionRows, cloneKeepingCoveredInstructionMarks };
120
+ export { markHostUnservedRow, isHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, markHostInstructionRow, hostInstructionRow, hostInstructionRowID, markRetiredInstructionRow, isRetiredInstructionRow, markCoveredInstructionRow, isCoveredInstructionRow, takeCoveredInstructionRows, cloneKeepingCoveredInstructionMarks };
@@ -5,7 +5,7 @@ import {
5
5
  expandToolPart,
6
6
  visitRawSessionMessages2,
7
7
  readRawSessionMessageById2
8
- } from "./index-tn9drm1a.js";
8
+ } from "./index-zqsp3z0d.js";
9
9
  import {
10
10
  getTagById2
11
11
  } from "./index-8jjjmhab.js";
@@ -72,7 +72,7 @@ import {
72
72
  getRawSessionTagKeysThrough2,
73
73
  getLegacyProtectedTailStartOrdinal2,
74
74
  readSessionChunk2
75
- } from "./index-tn9drm1a.js";
75
+ } from "./index-zqsp3z0d.js";
76
76
  import {
77
77
  getHarness2,
78
78
  harnessOwnsOpenCodeStore2
@@ -153,7 +153,7 @@ import {
153
153
  LATEST_SUPPORTED_VERSION,
154
154
  getPersistedSchemaVersion,
155
155
  openDatabase
156
- } from "./index-9fgmkfaf.js";
156
+ } from "./index-kfsqk1q7.js";
157
157
  import {
158
158
  areRustHistorianSyntheticParts2,
159
159
  isStrictGapHealingMessage2,
@@ -239,14 +239,14 @@ import {
239
239
  getProjectState,
240
240
  recordSubagentInvocation,
241
241
  getLatestHistorianInvocationId
242
- } from "./index-72czy45z.js";
242
+ } from "./index-rdx17j04.js";
243
243
  import {
244
244
  clearCompressionDepth,
245
245
  clearCompressionDepthRange,
246
246
  toMessageIndexSource,
247
247
  clearIndexedMessagesInTransaction,
248
248
  indexSourcesAfterOrdinal
249
- } from "./index-9z4d2ha0.js";
249
+ } from "./index-gsqz39wk.js";
250
250
  import {
251
251
  stripWellFormedLeadingTagPrefix,
252
252
  peelLeadingMcTagNotation,
@@ -310,7 +310,7 @@ import {
310
310
  snapTerminalCompartmentToServedRow,
311
311
  isHostRenderedSystemMessage,
312
312
  markCoveredInstructionRow
313
- } from "./index-z9zygwse.js";
313
+ } from "./index-s9x93tfs.js";
314
314
  import {
315
315
  piModelRefToCanonical
316
316
  } from "./index-avwt563y.js";
@@ -19,10 +19,10 @@ import {
19
19
  rawMessageWorkerSource2,
20
20
  rawMessageOffThreadRangeReader2,
21
21
  readRawSessionMessageIdOrdinalsForRange2
22
- } from "./index-tn9drm1a.js";
22
+ } from "./index-zqsp3z0d.js";
23
23
  import {
24
24
  readV2ArchiveOffThread2
25
- } from "./index-z7etaphs.js";
25
+ } from "./index-n8bsqg7b.js";
26
26
 
27
27
  // src/tools/ctx-expand/search-archive.ts
28
28
  var archiveReadsOnThisThread = 0;
@@ -85,7 +85,7 @@ import {
85
85
  import {
86
86
  markHostUnservedRow,
87
87
  isHostUnservedRow
88
- } from "./index-z9zygwse.js";
88
+ } from "./index-s9x93tfs.js";
89
89
  import {
90
90
  canonicalModelIdentity,
91
91
  piModelRefToCanonical
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  detectOverflow,
29
29
  isAnthropicFamilyRoute,
30
30
  readRawSessionMessages2
31
- } from "./index-tn9drm1a.js";
31
+ } from "./index-zqsp3z0d.js";
32
32
  import {
33
33
  setHarness2
34
34
  } from "./index-pavzsdc6.js";
@@ -84,7 +84,7 @@ import {
84
84
  checkCompactionMarkerConsistency,
85
85
  clearInjectionCache,
86
86
  clearNoteNudgeTriggerOnly
87
- } from "./index-q9gamh8e.js";
87
+ } from "./index-xmqj3cf5.js";
88
88
  import"./index-sd3egckz.js";
89
89
  import {
90
90
  hasTrustedAbsoluteWall,
@@ -171,7 +171,7 @@ import {
171
171
  parameterDescriptionsFor,
172
172
  MagicContextRpcServer,
173
173
  applyHiddenSubagentTemperature
174
- } from "./index-216tae7b.js";
174
+ } from "./index-adt3jghq.js";
175
175
  import {
176
176
  resolveOpenCodeDbPath,
177
177
  openCodeDbPathExists,
@@ -219,7 +219,7 @@ import {
219
219
  createDbLkgPersistence,
220
220
  registerLkgPersistence,
221
221
  dropSlot
222
- } from "./index-72czy45z.js";
222
+ } from "./index-rdx17j04.js";
223
223
  import {
224
224
  recordSessionProjectIdentity
225
225
  } from "./index-jz5bk7xd.js";
@@ -234,7 +234,7 @@ import {
234
234
  openDatabaseAsync,
235
235
  isDatabasePersisted,
236
236
  getDatabasePersistenceError
237
- } from "./index-9fgmkfaf.js";
237
+ } from "./index-kfsqk1q7.js";
238
238
  import {
239
239
  registerExitAbort,
240
240
  unregisterExitAbort
@@ -259,7 +259,7 @@ import"./index-g4t7850m.js";
259
259
  import {
260
260
  getDefaultSubcConnectionFile,
261
261
  SubcModuleTransport
262
- } from "./index-j5qma52p.js";
262
+ } from "./index-fas76dft.js";
263
263
  import"./index-qt1qqasc.js";
264
264
  import"./index-fw42ms3m.js";
265
265
  import {
@@ -297,7 +297,7 @@ import {
297
297
  import"./index-dcjkw41m.js";
298
298
  import {
299
299
  deleteIndexedMessage
300
- } from "./index-9z4d2ha0.js";
300
+ } from "./index-gsqz39wk.js";
301
301
  import"./index-66a50f3e.js";
302
302
  import"./index-2qbtqg1w.js";
303
303
  import {
@@ -319,13 +319,13 @@ import {
319
319
  clearToolPermissionDenied,
320
320
  collectForeignTextParts,
321
321
  resetDegradedCacheCount2
322
- } from "./index-bgxpadsx.js";
322
+ } from "./index-ayk4we2k.js";
323
323
  import {
324
324
  scheduleClearAndReindex
325
- } from "./index-hb76vdmm.js";
325
+ } from "./index-p2e7j9p1.js";
326
326
  import {
327
327
  runManagedRecomp2
328
- } from "./index-aed5qpyv.js";
328
+ } from "./index-5m2azs6v.js";
329
329
  import {
330
330
  isValidSemver,
331
331
  compareSemverCore
@@ -333,11 +333,11 @@ import {
333
333
  import"./index-fmsr7v69.js";
334
334
  import {
335
335
  runManagedWrapup2
336
- } from "./index-j8gv6ajw.js";
337
- import"./index-j105mf16.js";
336
+ } from "./index-1zv08avf.js";
337
+ import"./index-xjw9rres.js";
338
338
  import"./index-kaqs6h31.js";
339
- import"./index-z7etaphs.js";
340
- import"./index-ryz4pdvf.js";
339
+ import"./index-n8bsqg7b.js";
340
+ import"./index-z6v8086q.js";
341
341
  import {
342
342
  isDreamerRunnable,
343
343
  isSmartNoteSurfaceAvailable,
@@ -8205,7 +8205,7 @@ var require_src2 = __commonJS(function(exports, module) {
8205
8205
  // package.json
8206
8206
  var package_default = {
8207
8207
  name: "@cortexkit/opencode-magic-context",
8208
- version: "0.49.41",
8208
+ version: "0.49.43",
8209
8209
  type: "module",
8210
8210
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
8211
8211
  main: "dist/index.js",
@@ -12059,7 +12059,7 @@ async function setup(context) {
12059
12059
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
12060
12060
  log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
12061
12061
  }
12062
- const { registerContext } = await import("./context-3szg46w6.js");
12062
+ const { registerContext } = await import("./context-zf1yj1g0.js");
12063
12063
  setHarness2("opencode2");
12064
12064
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
12065
12065
  const duties = await registerContext(context);
@@ -12532,7 +12532,7 @@ var server = async (ctx) => {
12532
12532
  rustReplayParticipant: () => magicContextRuntime.magicContext?.getRustReplayParticipant?.() ?? null,
12533
12533
  onStorageBusyRefusal: async (sessionId, message) => {
12534
12534
  const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-14p3yje4.js"));
12535
- const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-6fpgz12m.js"));
12535
+ const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-0ms3ga4h.js"));
12536
12536
  await sendStatusNotification(ctx.client, sessionId, message, {
12537
12537
  toastDurationMs: 15000
12538
12538
  });