@cortexkit/opencode-magic-context 0.49.51 → 0.49.52
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/auto-search-worker.js +1 -1
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-r77d4fdy.js → context-bkkd7br4.js} +14 -14
- package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-recovery.d.ts +15 -0
- package/dist/hooks/magic-context/history-boundary-recovery.d.ts.map +1 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts +11 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts +1 -1
- package/dist/hooks/magic-context/persist-filtered-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +4 -2
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +21 -2
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
- package/dist/{index-ct3ettqt.js → index-0jc25yjf.js} +3 -3
- package/dist/{index-h8g08nxs.js → index-42n4fhxy.js} +92 -57
- package/dist/{index-wr2t8zb0.js → index-4xpff2m1.js} +7 -6
- package/dist/{index-07rp6xcn.js → index-9gs34125.js} +1 -1
- package/dist/{index-z4832qfe.js → index-a4zmmhxs.js} +1 -1
- package/dist/{index-5dptmnvd.js → index-fxgaaptn.js} +2 -2
- package/dist/{index-s131svmx.js → index-g3j49m95.js} +1 -1
- package/dist/{index-v4a1pnny.js → index-k2efzh9r.js} +4 -4
- package/dist/{index-gv7dwx5b.js → index-kanfby7e.js} +137 -41
- package/dist/{index-mjh63zvw.js → index-q9m97m5g.js} +1 -1
- package/dist/{index-30sf7e5k.js → index-qbda6a8k.js} +3 -3
- package/dist/{index-97bjd14c.js → index-qtpkkzan.js} +4 -4
- package/dist/{index-hkveze74.js → index-x4h461yf.js} +1 -1
- package/dist/{index-n0twfvah.js → index-x7jcqpy6.js} +1 -1
- package/dist/{index-cwj6qhmf.js → index-xqhejxmd.js} +7 -2
- package/dist/index.js +18 -18
- package/dist/{message-index-bounded-k0ebpy3y.js → message-index-bounded-71b75npz.js} +2 -2
- package/dist/migration-worker.js +1 -1
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-6712p893.js → read-session-chunk-bfv831yx.js} +1 -1
- package/dist/{recomp-orchestrator-8ebydg5j.js → recomp-orchestrator-8gj1b7pz.js} +7 -7
- package/dist/{render-dtc4qkq4.js → render-b3zcz9x4.js} +5 -5
- package/dist/{search-archive-f6hjbnsa.js → search-archive-dp9afcv1.js} +3 -3
- package/dist/{search-75bj2430.js → search-y3w590tn.js} +5 -5
- package/dist/shared/user-facing-codes.d.ts +7 -2
- package/dist/shared/user-facing-codes.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-1bg25094.js → transform-postprocess-phase-8awze16a.js} +8 -8
- package/dist/v2/auto-search-worker.js +1 -1
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-cpbhpxks.js → context-99v7x7fm.js} +135 -38
- package/dist/v2/{message-index-bounded-a36rw93p.js → message-index-bounded-2pev910h.js} +2 -2
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
- package/dist/v2/{read-session-chunk-hzhxvhyv.js → read-session-chunk-a454a4d2.js} +1 -1
- package/dist/v2/{recomp-orchestrator-yzr49pd0.js → recomp-orchestrator-03fskpsa.js} +6 -6
- package/dist/v2/{render-rhaevxv1.js → render-cryx4xsj.js} +5 -5
- package/dist/v2/{search-3yrdpr38.js → search-2qj4w7rw.js} +4 -4
- package/dist/v2/{search-archive-9924fyk8.js → search-archive-xw2rsq81.js} +3 -3
- package/dist/v2/{server-88yvx6r9.js → server-b3h8vqa6.js} +1 -1
- package/dist/v2/{server-0k586y7d.js → server-cpstyzvy.js} +3 -3
- package/dist/v2/{server-sgn61hht.js → server-dkfs58nq.js} +7 -2
- package/dist/v2/{server-16kfxcxj.js → server-kfw4m268.js} +1 -1
- package/dist/v2/{server-scp3y4dh.js → server-kreheyw5.js} +1 -1
- package/dist/v2/{server-3bfc26r7.js → server-qsvm6w79.js} +1 -1
- package/dist/v2/{server-jxrqsn84.js → server-txdsx71h.js} +1 -1
- package/dist/v2/{server-016a1whm.js → server-wq9y9a03.js} +92 -57
- package/dist/v2/{server-eznem83k.js → server-xjzx27w2.js} +2 -2
- package/dist/v2/{server-q93jdtz8.js → server-y5cma2j1.js} +2 -2
- package/dist/v2/server.js +2 -2
- package/dist/v2/{v2-archive-reader-5ggewg8q.js → v2-archive-reader-3575hw8s.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-36c5wyvq.js → wrapup-orchestrator-shzv6t4v.js} +6 -6
- package/dist/{v2-archive-reader-gx5ke1d7.js → v2-archive-reader-75fdm0te.js} +1 -1
- package/dist/{wrapup-orchestrator-ya31knav.js → wrapup-orchestrator-e0z7nvnx.js} +8 -8
- package/package.json +1 -1
- package/src/shared/user-facing-codes.ts +8 -2
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
renderMessageByOrdinal2,
|
|
3
3
|
renderVerboseRangeForTool2,
|
|
4
4
|
renderItemByTag2
|
|
5
|
-
} from "./server-
|
|
6
|
-
import"./server-
|
|
5
|
+
} from "./server-txdsx71h.js";
|
|
6
|
+
import"./server-b3h8vqa6.js";
|
|
7
7
|
import"./server-t8n27rbt.js";
|
|
8
|
-
import"./server-
|
|
8
|
+
import"./server-kfw4m268.js";
|
|
9
9
|
import"./server-2amn2s73.js";
|
|
10
10
|
import"./server-rthnpmbp.js";
|
|
11
|
-
import"./server-
|
|
11
|
+
import"./server-qsvm6w79.js";
|
|
12
12
|
import"./server-rcchadw0.js";
|
|
13
13
|
import"./server-1zx87sdm.js";
|
|
14
14
|
import"./server-7vrtk78d.js";
|
|
15
15
|
import"./server-0ms13pc8.js";
|
|
16
16
|
import"./server-g61hgy1y.js";
|
|
17
17
|
import"./server-mxsy9h1d.js";
|
|
18
|
-
import"./server-
|
|
18
|
+
import"./server-kreheyw5.js";
|
|
19
19
|
import"./server-fb3zxn06.js";
|
|
20
20
|
import"./server-58h6rrnx.js";
|
|
21
21
|
import"./server-fr0wbhdn.js";
|
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
resolveMemoriesByIdsForSearch2,
|
|
6
6
|
unifiedSearch2,
|
|
7
7
|
formatSearchResults2
|
|
8
|
-
} from "./server-
|
|
8
|
+
} from "./server-xjzx27w2.js";
|
|
9
9
|
import"./server-kaqs6h31.js";
|
|
10
|
-
import"./server-
|
|
10
|
+
import"./server-dkfs58nq.js";
|
|
11
11
|
import"./server-vjadwb3j.js";
|
|
12
12
|
import"./server-jjvbk92s.js";
|
|
13
13
|
import"./server-4h4acntc.js";
|
|
14
14
|
import"./server-4dhv7mqz.js";
|
|
15
15
|
import"./server-t8n27rbt.js";
|
|
16
|
-
import"./server-
|
|
16
|
+
import"./server-kfw4m268.js";
|
|
17
17
|
import"./server-2amn2s73.js";
|
|
18
18
|
import"./server-qt1qqasc.js";
|
|
19
|
-
import"./server-
|
|
19
|
+
import"./server-qsvm6w79.js";
|
|
20
20
|
import"./server-rcchadw0.js";
|
|
21
21
|
import"./server-1zx87sdm.js";
|
|
22
22
|
import"./server-7vrtk78d.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderSearchArchive2,
|
|
3
3
|
renderSearchArchiveOffThread2
|
|
4
|
-
} from "./server-
|
|
5
|
-
import"./server-
|
|
4
|
+
} from "./server-y5cma2j1.js";
|
|
5
|
+
import"./server-cpstyzvy.js";
|
|
6
6
|
import"./server-kaqs6h31.js";
|
|
7
|
-
import"./server-
|
|
7
|
+
import"./server-qsvm6w79.js";
|
|
8
8
|
import"./server-rcchadw0.js";
|
|
9
9
|
import"./server-1zx87sdm.js";
|
|
10
10
|
import"./server-7vrtk78d.js";
|
|
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
140
|
import("./store-reader-yaxtdy6f.js"),
|
|
141
141
|
import("./store-skkhh3rd.js"),
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
142
|
+
import("./read-session-chunk-a454a4d2.js"),
|
|
143
|
+
import("./render-cryx4xsj.js"),
|
|
144
|
+
import("./search-archive-xw2rsq81.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -42,8 +42,13 @@ var USER_FACING_FAILURES = {
|
|
|
42
42
|
},
|
|
43
43
|
history_boundary_unresolved: {
|
|
44
44
|
code: "MC-H04",
|
|
45
|
-
sentence: "This request was not sent:
|
|
46
|
-
action: "
|
|
45
|
+
sentence: "This request was not sent: it is larger than the model's context window, and Magic Context could not cut the already-summarized history out of it.",
|
|
46
|
+
action: "Run /ctx-flush to compress the history now, then send your message again."
|
|
47
|
+
},
|
|
48
|
+
history_boundary_recovering: {
|
|
49
|
+
code: "MC-H08",
|
|
50
|
+
sentence: "This request was not sent: it is larger than the model's context window, and Magic Context could not cut the already-summarized history out of it.",
|
|
51
|
+
action: "Send your message again: Magic Context will first summarize more of the history and drop old tool output to make it fit."
|
|
47
52
|
},
|
|
48
53
|
history_over_window_unmanaged: {
|
|
49
54
|
code: "MC-H06",
|
|
@@ -1023,7 +1023,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1023
1023
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1024
1024
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1025
1025
|
return;
|
|
1026
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1026
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-a454a4d2.js"));
|
|
1027
1027
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-baxebka0.js"));
|
|
1028
1028
|
if (signal.aborted)
|
|
1029
1029
|
return;
|
|
@@ -3447,7 +3447,7 @@ function normalizeDetectedLimitModelKey(modelKey) {
|
|
|
3447
3447
|
return typeof modelKey === "string" && modelKey.length > 0 ? piModelRefToCanonical(modelKey) : null;
|
|
3448
3448
|
}
|
|
3449
3449
|
function normalizeEmergencyRecoveryOrigin(value) {
|
|
3450
|
-
return value === "provider_overflow" || value === "proactive_model_shrink" ? value : null;
|
|
3450
|
+
return value === "provider_overflow" || value === "proactive_model_shrink" || value === "history_boundary_over_window" ? value : null;
|
|
3451
3451
|
}
|
|
3452
3452
|
function parseOverflowState(result, modelKey) {
|
|
3453
3453
|
if (!result) {
|
|
@@ -152,7 +152,7 @@ import {
|
|
|
152
152
|
getRawSessionTagKeysThrough2,
|
|
153
153
|
getLegacyProtectedTailStartOrdinal2,
|
|
154
154
|
readSessionChunk2
|
|
155
|
-
} from "./server-
|
|
155
|
+
} from "./server-qsvm6w79.js";
|
|
156
156
|
import {
|
|
157
157
|
BoundedSessionMap
|
|
158
158
|
} from "./server-kgq2e2hh.js";
|
|
@@ -162,7 +162,7 @@ import {
|
|
|
162
162
|
toMessageIndexSource,
|
|
163
163
|
clearIndexedMessagesInTransaction,
|
|
164
164
|
indexSourcesAfterOrdinal
|
|
165
|
-
} from "./server-
|
|
165
|
+
} from "./server-kfw4m268.js";
|
|
166
166
|
import {
|
|
167
167
|
COMPARTMENT_LEASE_RENEWAL_MS,
|
|
168
168
|
getCompartmentLeaseBlocker,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
getProjectState,
|
|
207
207
|
recordSubagentInvocation,
|
|
208
208
|
getLatestHistorianInvocationId
|
|
209
|
-
} from "./server-
|
|
209
|
+
} from "./server-b3h8vqa6.js";
|
|
210
210
|
import {
|
|
211
211
|
invalidateAutoEmbedSession
|
|
212
212
|
} from "./server-2amn2s73.js";
|
|
@@ -260,13 +260,13 @@ import {
|
|
|
260
260
|
userFacingFailureCode,
|
|
261
261
|
promoteSessionFactsDurable,
|
|
262
262
|
embedPromotedFacts
|
|
263
|
-
} from "./server-
|
|
263
|
+
} from "./server-dkfs58nq.js";
|
|
264
264
|
import {
|
|
265
265
|
getSchemaFenceRejection,
|
|
266
266
|
LATEST_SUPPORTED_VERSION,
|
|
267
267
|
getPersistedSchemaVersion,
|
|
268
268
|
openDatabase
|
|
269
|
-
} from "./server-
|
|
269
|
+
} from "./server-kreheyw5.js";
|
|
270
270
|
import {
|
|
271
271
|
parseCompartmentOutput,
|
|
272
272
|
resolveWorkspaceShareCategories,
|
|
@@ -2548,7 +2548,7 @@ function updateUserMemoryContent(db, id, content) {
|
|
|
2548
2548
|
db.prepare("UPDATE user_memories SET content = ?, updated_at = ? WHERE id = ?").run(content, Date.now(), id);
|
|
2549
2549
|
}
|
|
2550
2550
|
function dismissUserMemory(db, id) {
|
|
2551
|
-
db.prepare("UPDATE user_memories SET status = 'dismissed', updated_at = ? WHERE id = ?").run(Date.now(), id);
|
|
2551
|
+
db.prepare("UPDATE user_memories SET status = 'dismissed', updated_at = ? WHERE id = ? AND status = 'active'").run(Date.now(), id);
|
|
2552
2552
|
}
|
|
2553
2553
|
function parseCandidateIds(raw) {
|
|
2554
2554
|
try {
|
|
@@ -9838,10 +9838,10 @@ function findHostCompactionWindow(messages, readMagicContextSummaryMessageId) {
|
|
|
9838
9838
|
completedAt
|
|
9839
9839
|
};
|
|
9840
9840
|
}
|
|
9841
|
-
function
|
|
9841
|
+
function boundaryOrderAgainstWindow(sessionId, boundary, firstLiveId) {
|
|
9842
9842
|
const cached = precedesVerdictBySession.get(sessionId);
|
|
9843
9843
|
if (cached && cached.boundary === boundary && cached.firstLiveId === firstLiveId) {
|
|
9844
|
-
return cached.
|
|
9844
|
+
return cached.verdict;
|
|
9845
9845
|
}
|
|
9846
9846
|
let order = null;
|
|
9847
9847
|
try {
|
|
@@ -9854,9 +9854,9 @@ function boundaryPrecedesWindow(sessionId, boundary, firstLiveId) {
|
|
|
9854
9854
|
sessionLog2(sessionId, `prefix trim: placing boundary ${boundary} failed:`, error);
|
|
9855
9855
|
order = null;
|
|
9856
9856
|
}
|
|
9857
|
-
const
|
|
9858
|
-
precedesVerdictBySession.set(sessionId, { boundary, firstLiveId,
|
|
9859
|
-
return
|
|
9857
|
+
const verdict = order === null || !Number.isFinite(order) ? "unknown" : order < 0 ? "precedes" : "not-before";
|
|
9858
|
+
precedesVerdictBySession.set(sessionId, { boundary, firstLiveId, verdict });
|
|
9859
|
+
return verdict;
|
|
9860
9860
|
}
|
|
9861
9861
|
function logBoundaryPrecedesWindow(options, boundary, firstLiveId) {
|
|
9862
9862
|
const { sessionId } = options;
|
|
@@ -9870,9 +9870,10 @@ function classifyAbsentBoundary(options, messages, boundary) {
|
|
|
9870
9870
|
const { sessionId } = options;
|
|
9871
9871
|
const pass = options.isCacheBustingPass ? "priced" : "defer";
|
|
9872
9872
|
const firstLiveId = firstPersistedLiveId(messages);
|
|
9873
|
-
|
|
9873
|
+
const order = firstLiveId === null ? "unknown" : boundaryOrderAgainstWindow(sessionId, boundary, firstLiveId);
|
|
9874
|
+
if (firstLiveId !== null && order === "precedes") {
|
|
9874
9875
|
logBoundaryPrecedesWindow(options, boundary, firstLiveId);
|
|
9875
|
-
return "boundary-precedes-window";
|
|
9876
|
+
return { status: "boundary-precedes-window" };
|
|
9876
9877
|
}
|
|
9877
9878
|
precedesWindowLoggedBySession.delete(sessionId);
|
|
9878
9879
|
const current = absentBoundaryEpisodeBySession.get(sessionId);
|
|
@@ -9882,7 +9883,10 @@ function classifyAbsentBoundary(options, messages, boundary) {
|
|
|
9882
9883
|
if (episode.passes === 1 || options.isCacheBustingPass) {
|
|
9883
9884
|
sessionLog2(sessionId, `prefix trim: boundary ${boundary} absent from current messages; pass=${pass}; no in-pass trim applied (degraded pass ${episode.passes}; ${firstLiveId === null ? "no persisted live message to compare with" : `boundary does not sort before the first live message ${firstLiveId}`}; whole window served until a cache-busting pass moves the boundary into the window)`);
|
|
9884
9885
|
}
|
|
9885
|
-
return
|
|
9886
|
+
return {
|
|
9887
|
+
status: "refused",
|
|
9888
|
+
refusal: order === "not-before" ? "boundary-not-in-request" : "boundary-unordered"
|
|
9889
|
+
};
|
|
9886
9890
|
}
|
|
9887
9891
|
function isSyntheticPrefixHead(message) {
|
|
9888
9892
|
if (message.info.id !== undefined || message.info.role !== "user" || message.parts.length === 0) {
|
|
@@ -9896,17 +9900,14 @@ function capturePrefixTrimSourceOrder(messages) {
|
|
|
9896
9900
|
let syntheticHeadCount = 0;
|
|
9897
9901
|
let sawPersistedRow = false;
|
|
9898
9902
|
let invalidReason = null;
|
|
9899
|
-
for (const
|
|
9903
|
+
for (const message of messages) {
|
|
9900
9904
|
const id = message.info.id;
|
|
9901
9905
|
if (isHostRenderedSystemMessage(message))
|
|
9902
9906
|
continue;
|
|
9903
9907
|
if (typeof id !== "string" || id.length === 0) {
|
|
9904
|
-
if (!sawPersistedRow && isSyntheticPrefixHead(message))
|
|
9908
|
+
if (!sawPersistedRow && isSyntheticPrefixHead(message))
|
|
9905
9909
|
syntheticHeadCount += 1;
|
|
9906
|
-
|
|
9907
|
-
}
|
|
9908
|
-
invalidReason = `source message at index ${index} has no stable id outside the synthetic head`;
|
|
9909
|
-
break;
|
|
9910
|
+
continue;
|
|
9910
9911
|
}
|
|
9911
9912
|
sawPersistedRow = true;
|
|
9912
9913
|
if (seen.has(id)) {
|
|
@@ -9955,21 +9956,49 @@ function reanchorStoredBoundary(options, boundary) {
|
|
|
9955
9956
|
}
|
|
9956
9957
|
function trimToPreparedPrefix(options, prepared) {
|
|
9957
9958
|
if (options.compactionOff || !options.messages)
|
|
9958
|
-
return "not-attempted";
|
|
9959
|
+
return { status: "not-attempted" };
|
|
9960
|
+
const messages = options.messages;
|
|
9959
9961
|
const boundary = prepared.preparedTrimBoundaryId;
|
|
9960
|
-
let
|
|
9962
|
+
let outcome = { status: "not-required" };
|
|
9961
9963
|
if (boundary) {
|
|
9962
9964
|
const retireDecisions = (messageIds) => {
|
|
9963
9965
|
queueAutoSearchHintDecisionRetirement(options.db, options.sessionId, new Set(messageIds));
|
|
9964
9966
|
};
|
|
9967
|
+
const trimAtVisibleBoundary = (reanchor) => {
|
|
9968
|
+
const index = findBoundaryIndex(options.sessionId, messages, boundary);
|
|
9969
|
+
if (index >= 0) {
|
|
9970
|
+
const cut = index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1);
|
|
9971
|
+
const unplaced = messages.slice(0, cut).filter(isHostRenderedSystemMessage);
|
|
9972
|
+
const removed = messages.splice(0, cut, ...unplaced);
|
|
9973
|
+
retireDecisions(removed.map((message) => message.info.id).filter((id) => typeof id === "string"));
|
|
9974
|
+
resetPrefixTrimFallbackState(options.sessionId);
|
|
9975
|
+
return { status: "applied" };
|
|
9976
|
+
}
|
|
9977
|
+
if (reanchor) {
|
|
9978
|
+
const reanchored = reanchorStoredBoundary(options, boundary);
|
|
9979
|
+
if (reanchored && reanchored.messageIds[0] !== boundary) {
|
|
9980
|
+
return trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared);
|
|
9981
|
+
}
|
|
9982
|
+
}
|
|
9983
|
+
return classifyAbsentBoundary(options, messages, boundary);
|
|
9984
|
+
};
|
|
9965
9985
|
const sourceOrder = options.prefixTrimSourceOrder;
|
|
9966
9986
|
if (sourceOrder) {
|
|
9967
|
-
const
|
|
9968
|
-
|
|
9969
|
-
|
|
9987
|
+
const pass = options.isCacheBustingPass ? "priced" : "defer";
|
|
9988
|
+
const refuse = (reason, refusal) => {
|
|
9989
|
+
sessionLog2(options.sessionId, `prefix trim: boundary ${boundary}; pass=${pass}; no in-pass trim applied (${reason})`);
|
|
9990
|
+
return { status: "refused", refusal };
|
|
9991
|
+
};
|
|
9992
|
+
const placeWithoutSourceOrder = (reason) => {
|
|
9993
|
+
sessionLog2(options.sessionId, `prefix trim: boundary ${boundary}; pass=${pass}; source order not usable (${reason}); placing the boundary by the live messages`);
|
|
9994
|
+
const served = resolveHostServedBoundaryId2(options.sessionId, boundary);
|
|
9995
|
+
const copies = messages.filter((message) => message.info.id === boundary || message.info.id === served).length;
|
|
9996
|
+
if (copies > 1)
|
|
9997
|
+
return refuse(`boundary ${boundary} appears ${copies} times in the live messages`, "boundary-unordered");
|
|
9998
|
+
return trimAtVisibleBoundary(false);
|
|
9970
9999
|
};
|
|
9971
10000
|
if (sourceOrder.invalidReason) {
|
|
9972
|
-
|
|
10001
|
+
outcome = placeWithoutSourceOrder(sourceOrder.invalidReason);
|
|
9973
10002
|
} else {
|
|
9974
10003
|
const sourcePosition = new Map;
|
|
9975
10004
|
sourceOrder.messageIds.forEach((id, index) => {
|
|
@@ -9978,7 +10007,7 @@ function trimToPreparedPrefix(options, prepared) {
|
|
|
9978
10007
|
const boundaryPosition = sourcePosition.get(boundary) ?? sourcePosition.get(resolveHostServedBoundaryId2(options.sessionId, boundary));
|
|
9979
10008
|
if (boundaryPosition === undefined) {
|
|
9980
10009
|
const reanchored = reanchorStoredBoundary(options, boundary);
|
|
9981
|
-
|
|
10010
|
+
outcome = reanchored ? trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared) : refuse("boundary absent from immutable source order", "boundary-unordered");
|
|
9982
10011
|
} else {
|
|
9983
10012
|
let lastSourcePosition = -1;
|
|
9984
10013
|
let sawPersistedRow = false;
|
|
@@ -9986,17 +10015,29 @@ function trimToPreparedPrefix(options, prepared) {
|
|
|
9986
10015
|
let firstLiveId;
|
|
9987
10016
|
let liveOrderError = null;
|
|
9988
10017
|
const retained = [];
|
|
9989
|
-
|
|
10018
|
+
let unplaced = [];
|
|
10019
|
+
const placeUnplaced = (cut) => {
|
|
10020
|
+
for (const message of unplaced) {
|
|
10021
|
+
if (!cut || isHostRenderedSystemMessage(message))
|
|
10022
|
+
retained.push(message);
|
|
10023
|
+
}
|
|
10024
|
+
unplaced = [];
|
|
10025
|
+
};
|
|
10026
|
+
for (const message of options.messages) {
|
|
9990
10027
|
const id = message.info.id;
|
|
9991
10028
|
if (isHostRenderedSystemMessage(message)) {
|
|
10029
|
+
if (unplaced.length > 0) {
|
|
10030
|
+
unplaced.push(message);
|
|
10031
|
+
continue;
|
|
10032
|
+
}
|
|
9992
10033
|
retained.push(message);
|
|
9993
10034
|
continue;
|
|
9994
10035
|
}
|
|
9995
10036
|
if (typeof id !== "string" || id.length === 0) {
|
|
9996
10037
|
if (!sawPersistedRow && isSyntheticPrefixHead(message))
|
|
9997
10038
|
continue;
|
|
9998
|
-
|
|
9999
|
-
|
|
10039
|
+
unplaced.push(message);
|
|
10040
|
+
continue;
|
|
10000
10041
|
}
|
|
10001
10042
|
sawPersistedRow = true;
|
|
10002
10043
|
const position = sourcePosition.get(id);
|
|
@@ -10013,44 +10054,31 @@ function trimToPreparedPrefix(options, prepared) {
|
|
|
10013
10054
|
firstLiveId = id;
|
|
10014
10055
|
}
|
|
10015
10056
|
lastSourcePosition = position;
|
|
10057
|
+
placeUnplaced(position <= boundaryPosition);
|
|
10016
10058
|
if (position > boundaryPosition || position === boundaryPosition && isPartialCompartmentEnd(options.db, options.sessionId, boundary))
|
|
10017
10059
|
retained.push(message);
|
|
10018
10060
|
}
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10061
|
+
placeUnplaced(false);
|
|
10062
|
+
if (liveOrderError) {
|
|
10063
|
+
outcome = placeWithoutSourceOrder(liveOrderError);
|
|
10064
|
+
} else {
|
|
10022
10065
|
if (firstLiveId && firstLivePosition !== undefined && firstLivePosition > boundaryPosition) {
|
|
10023
10066
|
logBoundaryPrecedesWindow(options, boundary, firstLiveId);
|
|
10024
10067
|
}
|
|
10025
10068
|
options.messages.splice(0, options.messages.length, ...retained);
|
|
10026
10069
|
const preserveBoundary = isPartialCompartmentEnd(options.db, options.sessionId, boundary);
|
|
10027
10070
|
retireDecisions(sourceOrder.messageIds.slice(0, boundaryPosition + (preserveBoundary ? 0 : 1)));
|
|
10028
|
-
|
|
10071
|
+
outcome = { status: "applied" };
|
|
10029
10072
|
}
|
|
10030
10073
|
}
|
|
10031
10074
|
}
|
|
10032
10075
|
} else {
|
|
10033
|
-
|
|
10034
|
-
if (index >= 0) {
|
|
10035
|
-
const cut = index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1);
|
|
10036
|
-
const unplaced = options.messages.slice(0, cut).filter(isHostRenderedSystemMessage);
|
|
10037
|
-
const removed = options.messages.splice(0, cut, ...unplaced);
|
|
10038
|
-
retireDecisions(removed.map((message) => message.info.id).filter((id) => typeof id === "string"));
|
|
10039
|
-
resetPrefixTrimFallbackState(options.sessionId);
|
|
10040
|
-
status = "applied";
|
|
10041
|
-
} else {
|
|
10042
|
-
const reanchored = reanchorStoredBoundary(options, boundary);
|
|
10043
|
-
if (reanchored && reanchored.messageIds[0] !== boundary) {
|
|
10044
|
-
status = trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared);
|
|
10045
|
-
} else {
|
|
10046
|
-
status = classifyAbsentBoundary(options, options.messages, boundary);
|
|
10047
|
-
}
|
|
10048
|
-
}
|
|
10076
|
+
outcome = trimAtVisibleBoundary(true);
|
|
10049
10077
|
}
|
|
10050
10078
|
}
|
|
10051
10079
|
if (prepared.m0RematerializedThisPass || options.isCacheBustingPass && !prepared.materializationContentionRetryExhausted)
|
|
10052
10080
|
clearInjectionCache(options.sessionId);
|
|
10053
|
-
return
|
|
10081
|
+
return outcome;
|
|
10054
10082
|
}
|
|
10055
10083
|
function prepareCachedM0M1Replay(db, sessionId) {
|
|
10056
10084
|
const row = readCachedM0M1Row(db, sessionId);
|
|
@@ -10103,15 +10131,16 @@ function injectM0M1(options) {
|
|
|
10103
10131
|
const prepared = options.preparedPrefix;
|
|
10104
10132
|
if (prepared?.preparedMessages) {
|
|
10105
10133
|
const head = prepared.preparedMessages;
|
|
10106
|
-
let
|
|
10134
|
+
let prefixTrim = { status: "not-attempted" };
|
|
10107
10135
|
if (options.messages) {
|
|
10108
|
-
|
|
10136
|
+
prefixTrim = trimToPreparedPrefix(options, prepared);
|
|
10109
10137
|
options.messages.unshift(...structuredClone(head));
|
|
10110
10138
|
}
|
|
10111
10139
|
return {
|
|
10112
10140
|
...prepared,
|
|
10113
10141
|
prependedMessageCount: options.messages ? head.length : 0,
|
|
10114
|
-
prefixTrimStatus
|
|
10142
|
+
prefixTrimStatus: prefixTrim.status,
|
|
10143
|
+
prefixTrimRefusal: prefixTrim.refusal
|
|
10115
10144
|
};
|
|
10116
10145
|
}
|
|
10117
10146
|
hydrateCachedM0Mural(options.db, options.sessionId, options.state);
|
|
@@ -10268,9 +10297,9 @@ function injectM0M1(options) {
|
|
|
10268
10297
|
contentHash: options.state.cachedM0MuralHash ?? undefined
|
|
10269
10298
|
} : undefined;
|
|
10270
10299
|
let prependedMessageCount = prependM0M1Messages(options.sessionId, preparedMessages, m0Text, m1Text, muralForWire);
|
|
10271
|
-
let
|
|
10300
|
+
let prefixTrim = { status: "not-attempted" };
|
|
10272
10301
|
if (options.messages) {
|
|
10273
|
-
|
|
10302
|
+
prefixTrim = trimToPreparedPrefix(options, {
|
|
10274
10303
|
m0RematerializedThisPass: rematerialized,
|
|
10275
10304
|
materializationContentionRetryExhausted: contentionExhausted,
|
|
10276
10305
|
preparedTrimBoundaryId
|
|
@@ -10288,7 +10317,8 @@ function injectM0M1(options) {
|
|
|
10288
10317
|
m1Text,
|
|
10289
10318
|
preparedMessages,
|
|
10290
10319
|
preparedTrimBoundaryId,
|
|
10291
|
-
prefixTrimStatus
|
|
10320
|
+
prefixTrimStatus: prefixTrim.status,
|
|
10321
|
+
...prefixTrim.refusal ? { prefixTrimRefusal: prefixTrim.refusal } : {}
|
|
10292
10322
|
};
|
|
10293
10323
|
}
|
|
10294
10324
|
|
|
@@ -13393,6 +13423,11 @@ function persistFilteredNoise(db, sessionId, chunk, eligibleEnd) {
|
|
|
13393
13423
|
const start = chunk.startIndex;
|
|
13394
13424
|
if (chunk.text || chunk.messageCount !== 0 || eligibleEnd <= start || rows.length !== eligibleEnd - start || rows.some((row, index) => row.ordinal !== start + index || !row.messageId))
|
|
13395
13425
|
return false;
|
|
13426
|
+
const endId = rows[rows.length - 1].messageId;
|
|
13427
|
+
if (!hasRawSessionMessageById2(sessionId, endId)) {
|
|
13428
|
+
sessionLog2(sessionId, `historian skipped a filtered-noise marker for ordinals ${start}-${eligibleEnd - 1}: its end row ${endId} is no longer in the host store`);
|
|
13429
|
+
return false;
|
|
13430
|
+
}
|
|
13396
13431
|
const saved = db.transaction(() => {
|
|
13397
13432
|
const prior = getCompartments(db, sessionId);
|
|
13398
13433
|
const last = prior.at(-1);
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isMessageIndexReconciledThrough,
|
|
26
26
|
clearIndexedMessages,
|
|
27
27
|
indexMessagesAfterOrdinal
|
|
28
|
-
} from "./server-
|
|
28
|
+
} from "./server-kfw4m268.js";
|
|
29
29
|
import {
|
|
30
30
|
Priority,
|
|
31
31
|
AdmissionClass,
|
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
sanitizeFtsQuery,
|
|
82
82
|
searchMemoriesFTS,
|
|
83
83
|
searchMemoriesFTSUnion
|
|
84
|
-
} from "./server-
|
|
84
|
+
} from "./server-dkfs58nq.js";
|
|
85
85
|
import {
|
|
86
86
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
87
87
|
withMessageFtsSessionFilter
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./server-
|
|
22
|
+
} from "./server-qsvm6w79.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./server-
|
|
25
|
+
} from "./server-cpstyzvy.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
package/dist/v2/server.js
CHANGED
|
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7875
7875
|
// package.json
|
|
7876
7876
|
var package_default = {
|
|
7877
7877
|
name: "@cortexkit/opencode-magic-context",
|
|
7878
|
-
version: "0.49.
|
|
7878
|
+
version: "0.49.52",
|
|
7879
7879
|
type: "module",
|
|
7880
7880
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7881
7881
|
main: "dist/index.js",
|
|
@@ -8196,7 +8196,7 @@ async function setup(context) {
|
|
|
8196
8196
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8197
8197
|
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.`);
|
|
8198
8198
|
}
|
|
8199
|
-
const { registerContext } = await import("./context-
|
|
8199
|
+
const { registerContext } = await import("./context-99v7x7fm.js");
|
|
8200
8200
|
setHarness2("opencode2");
|
|
8201
8201
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8202
8202
|
const duties = await registerContext(context);
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
releaseCompartmentLeaseBestEffort,
|
|
12
12
|
getCompartments,
|
|
13
13
|
getLastCompartmentEndMessage
|
|
14
|
-
} from "./server-
|
|
14
|
+
} from "./server-b3h8vqa6.js";
|
|
15
15
|
import"./server-2amn2s73.js";
|
|
16
16
|
import"./server-3jc6qmdz.js";
|
|
17
17
|
import"./server-mxsy9h1d.js";
|
|
@@ -24,7 +24,7 @@ import"./server-1d042x6w.js";
|
|
|
24
24
|
import"./server-rz5jnhnv.js";
|
|
25
25
|
import"./server-966dq3pd.js";
|
|
26
26
|
import"./server-g61hgy1y.js";
|
|
27
|
-
import"./server-
|
|
27
|
+
import"./server-kfw4m268.js";
|
|
28
28
|
import {
|
|
29
29
|
getWrapupInProgressState,
|
|
30
30
|
acquireWrapupInProgress,
|
|
@@ -33,9 +33,9 @@ import {
|
|
|
33
33
|
getHistorianFailureState,
|
|
34
34
|
clearEmergencyRecovery,
|
|
35
35
|
prepareRawSessionOrdinals2
|
|
36
|
-
} from "./server-
|
|
36
|
+
} from "./server-qsvm6w79.js";
|
|
37
37
|
import"./server-ww7xbxxf.js";
|
|
38
|
-
import"./server-
|
|
38
|
+
import"./server-kreheyw5.js";
|
|
39
39
|
import"./server-1zx87sdm.js";
|
|
40
40
|
import"./server-rcchadw0.js";
|
|
41
41
|
import"./server-0ms13pc8.js";
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
registerActiveCompartmentRun,
|
|
64
64
|
setRecompStarting2,
|
|
65
65
|
setRecompTerminal2
|
|
66
|
-
} from "./server-
|
|
66
|
+
} from "./server-wq9y9a03.js";
|
|
67
67
|
import"./server-qt1qqasc.js";
|
|
68
68
|
import"./server-4h4acntc.js";
|
|
69
69
|
import"./server-qp5sj6n5.js";
|
|
@@ -71,7 +71,7 @@ import"./server-4dhv7mqz.js";
|
|
|
71
71
|
import"./server-brsx45r6.js";
|
|
72
72
|
import"./server-vjadwb3j.js";
|
|
73
73
|
import"./server-jjvbk92s.js";
|
|
74
|
-
import"./server-
|
|
74
|
+
import"./server-dkfs58nq.js";
|
|
75
75
|
import"./server-sb55ddgn.js";
|
|
76
76
|
import"./server-sa1fdt41.js";
|
|
77
77
|
import"./server-5kgesxck.js";
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runManagedWrapup2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-k2efzh9r.js";
|
|
4
|
+
import"./index-qtpkkzan.js";
|
|
5
|
+
import"./index-42n4fhxy.js";
|
|
6
6
|
import"./index-90z05d0p.js";
|
|
7
7
|
import"./index-sd3egckz.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-xqhejxmd.js";
|
|
9
9
|
import"./index-8d7gkgjs.js";
|
|
10
10
|
import"./index-jjvbk92s.js";
|
|
11
11
|
import"./index-bamnjp2t.js";
|
|
12
12
|
import"./index-4dhv7mqz.js";
|
|
13
|
-
import"./index-
|
|
13
|
+
import"./index-x7jcqpy6.js";
|
|
14
14
|
import"./index-25tm250q.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-x4h461yf.js";
|
|
16
16
|
import"./index-2amn2s73.js";
|
|
17
17
|
import"./index-6athgjba.js";
|
|
18
18
|
import"./index-gapnh6tk.js";
|
|
19
19
|
import"./index-r9agn061.js";
|
|
20
20
|
import"./index-qt1qqasc.js";
|
|
21
|
-
import"./index-
|
|
21
|
+
import"./index-9gs34125.js";
|
|
22
22
|
import"./index-bkg4hdyh.js";
|
|
23
23
|
import"./index-1zx87sdm.js";
|
|
24
24
|
import"./index-em92bp7f.js";
|
|
@@ -29,7 +29,7 @@ import"./index-jjy5a5w0.js";
|
|
|
29
29
|
import"./index-qperbvjn.js";
|
|
30
30
|
import"./index-hexdee98.js";
|
|
31
31
|
import"./index-hsyczpn7.js";
|
|
32
|
-
import"./index-
|
|
32
|
+
import"./index-a4zmmhxs.js";
|
|
33
33
|
import"./index-fb3zxn06.js";
|
|
34
34
|
import"./index-pb8ysnq2.js";
|
|
35
35
|
import"./index-fr0wbhdn.js";
|
package/package.json
CHANGED