@cortexkit/opencode-magic-context 0.49.50 → 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-4js5qnnm.js → context-bkkd7br4.js} +14 -14
- package/dist/features/magic-context/search-rerank.d.ts +2 -2
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- 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-5g6npyw5.js → index-kanfby7e.js} +137 -41
- package/dist/{index-mjh63zvw.js → index-q9m97m5g.js} +1 -1
- package/dist/{index-5t1mr0bt.js → index-qbda6a8k.js} +25 -7
- 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-edv0gy1d.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-qkr7z6d0.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-ggvexvv7.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-3qf9n5ck.js → server-xjzx27w2.js} +24 -6
- 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
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { Database } from "../../shared/sqlite";
|
|
2
|
+
import type { PrefixTrimRefusal } from "./inject-compartments";
|
|
2
3
|
/** A summary boundary omitted from a request is missing only if the store no longer holds its row. */
|
|
3
4
|
export declare function storedHistoryBoundaryPresence(db: Database, sessionId: string): boolean | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Why the summarized history could not be cut out of the request: the prefix
|
|
7
|
+
* trim's own reason, or a boundary row the host store no longer holds (the
|
|
8
|
+
* history-boundary repair re-anchors that one on a later pass).
|
|
9
|
+
*/
|
|
10
|
+
export type HistoryBoundaryRefusalCause = PrefixTrimRefusal | "boundary-missing-from-store";
|
|
11
|
+
/**
|
|
12
|
+
* What changes the state on the next send. `send-again`: overflow recovery is
|
|
13
|
+
* armed or still making progress, so the next pass summarizes and drops more.
|
|
14
|
+
* `flush`: recovery already ran on this state and could not make room, or the
|
|
15
|
+
* request size could not be measured with confidence.
|
|
16
|
+
*/
|
|
17
|
+
export type HistoryBoundaryRefusalRemedy = "send-again" | "flush";
|
|
18
|
+
/** The text a person sees for this refusal, on every platform alike. */
|
|
19
|
+
export declare function historyBoundaryRefusalText(cause: HistoryBoundaryRefusalCause | undefined, remedy: HistoryBoundaryRefusalRemedy): string;
|
|
4
20
|
/**
|
|
5
21
|
* The transform could not cut the conversation at the history boundary, and
|
|
6
22
|
* the uncut request is larger than the model's context window. Sending it
|
|
@@ -11,9 +27,12 @@ export declare function storedHistoryBoundaryPresence(db: Database, sessionId: s
|
|
|
11
27
|
export declare class UnresolvedHistoryBoundaryError extends Error {
|
|
12
28
|
readonly estimatedTokens: number;
|
|
13
29
|
readonly contextLimitTokens: number;
|
|
14
|
-
readonly
|
|
30
|
+
readonly refusalCause?: HistoryBoundaryRefusalCause | undefined;
|
|
31
|
+
readonly remedy: HistoryBoundaryRefusalRemedy;
|
|
15
32
|
readonly code = "UNRESOLVED_HISTORY_BOUNDARY";
|
|
16
33
|
readonly recoverable = true;
|
|
17
|
-
constructor(estimatedTokens: number, contextLimitTokens: number,
|
|
34
|
+
constructor(estimatedTokens: number, contextLimitTokens: number, refusalCause?: HistoryBoundaryRefusalCause | undefined, remedy?: HistoryBoundaryRefusalRemedy);
|
|
18
35
|
}
|
|
36
|
+
/** The cause a person is told: a missing boundary row outranks the trim's own reason. */
|
|
37
|
+
export declare function historyBoundaryRefusalCause(trimRefusal: PrefixTrimRefusal | null | undefined, boundaryInStore: boolean | undefined): HistoryBoundaryRefusalCause | undefined;
|
|
19
38
|
//# sourceMappingURL=unresolved-history-boundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unresolved-history-boundary.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/unresolved-history-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"unresolved-history-boundary.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/unresolved-history-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,sGAAsG;AACtG,wBAAgB,6BAA6B,CACzC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,GAClB,OAAO,GAAG,SAAS,CAWrB;AAED;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,GAAG,6BAA6B,CAAC;AAE5F;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,YAAY,GAAG,OAAO,CAAC;AAWlE,wEAAwE;AACxE,wBAAgB,0BAA0B,CACtC,KAAK,EAAE,2BAA2B,GAAG,SAAS,EAC9C,MAAM,EAAE,4BAA4B,GACrC,MAAM,CAMR;AAED;;;;;;GAMG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IAKjD,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,kBAAkB,EAAE,MAAM;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,2BAA2B;IACnD,QAAQ,CAAC,MAAM,EAAE,4BAA4B;IAPjD,QAAQ,CAAC,IAAI,iCAAiC;IAC9C,QAAQ,CAAC,WAAW,QAAQ;gBAGf,eAAe,EAAE,MAAM,EACvB,kBAAkB,EAAE,MAAM,EAC1B,YAAY,CAAC,EAAE,2BAA2B,YAAA,EAC1C,MAAM,GAAE,4BAAsC;CAK9D;AAED,yFAAyF;AACzF,wBAAgB,2BAA2B,CACvC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EACjD,eAAe,EAAE,OAAO,GAAG,SAAS,GACrC,2BAA2B,GAAG,SAAS,CAGzC"}
|
|
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
140
|
import("./store-reader-3eh1s1m8.js"),
|
|
141
141
|
import("./store-h20ny8b8.js"),
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
142
|
+
import("./read-session-chunk-bfv831yx.js"),
|
|
143
|
+
import("./render-b3zcz9x4.js"),
|
|
144
|
+
import("./search-archive-dp9afcv1.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
getRawSessionTagKeysThrough2,
|
|
73
73
|
getLegacyProtectedTailStartOrdinal2,
|
|
74
74
|
readSessionChunk2
|
|
75
|
-
} from "./index-
|
|
75
|
+
} from "./index-9gs34125.js";
|
|
76
76
|
import {
|
|
77
77
|
getHarness2,
|
|
78
78
|
harnessOwnsOpenCodeStore2
|
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
LATEST_SUPPORTED_VERSION,
|
|
152
152
|
getPersistedSchemaVersion,
|
|
153
153
|
openDatabase
|
|
154
|
-
} from "./index-
|
|
154
|
+
} from "./index-a4zmmhxs.js";
|
|
155
155
|
import {
|
|
156
156
|
areRustHistorianSyntheticParts2,
|
|
157
157
|
isStrictGapHealingMessage2,
|
|
@@ -237,14 +237,14 @@ import {
|
|
|
237
237
|
getProjectState,
|
|
238
238
|
recordSubagentInvocation,
|
|
239
239
|
getLatestHistorianInvocationId
|
|
240
|
-
} from "./index-
|
|
240
|
+
} from "./index-x7jcqpy6.js";
|
|
241
241
|
import {
|
|
242
242
|
clearCompressionDepth,
|
|
243
243
|
clearCompressionDepthRange,
|
|
244
244
|
toMessageIndexSource,
|
|
245
245
|
clearIndexedMessagesInTransaction,
|
|
246
246
|
indexSourcesAfterOrdinal
|
|
247
|
-
} from "./index-
|
|
247
|
+
} from "./index-x4h461yf.js";
|
|
248
248
|
import {
|
|
249
249
|
stripWellFormedLeadingTagPrefix,
|
|
250
250
|
peelLeadingMcTagNotation,
|
|
@@ -289,7 +289,7 @@ import {
|
|
|
289
289
|
userFacingFailureCode,
|
|
290
290
|
promoteSessionFactsDurable,
|
|
291
291
|
embedPromotedFacts
|
|
292
|
-
} from "./index-
|
|
292
|
+
} from "./index-xqhejxmd.js";
|
|
293
293
|
import {
|
|
294
294
|
isMarkerCandidateBasisCurrent2,
|
|
295
295
|
invalidateMarkerCandidateBasis2,
|
|
@@ -8171,7 +8171,7 @@ function updateUserMemoryContent(db, id, content) {
|
|
|
8171
8171
|
db.prepare("UPDATE user_memories SET content = ?, updated_at = ? WHERE id = ?").run(content, Date.now(), id);
|
|
8172
8172
|
}
|
|
8173
8173
|
function dismissUserMemory(db, id) {
|
|
8174
|
-
db.prepare("UPDATE user_memories SET status = 'dismissed', updated_at = ? WHERE id = ?").run(Date.now(), id);
|
|
8174
|
+
db.prepare("UPDATE user_memories SET status = 'dismissed', updated_at = ? WHERE id = ? AND status = 'active'").run(Date.now(), id);
|
|
8175
8175
|
}
|
|
8176
8176
|
function parseCandidateIds(raw) {
|
|
8177
8177
|
try {
|
|
@@ -11977,10 +11977,10 @@ function findHostCompactionWindow(messages, readMagicContextSummaryMessageId) {
|
|
|
11977
11977
|
completedAt
|
|
11978
11978
|
};
|
|
11979
11979
|
}
|
|
11980
|
-
function
|
|
11980
|
+
function boundaryOrderAgainstWindow(sessionId, boundary, firstLiveId) {
|
|
11981
11981
|
const cached = precedesVerdictBySession.get(sessionId);
|
|
11982
11982
|
if (cached && cached.boundary === boundary && cached.firstLiveId === firstLiveId) {
|
|
11983
|
-
return cached.
|
|
11983
|
+
return cached.verdict;
|
|
11984
11984
|
}
|
|
11985
11985
|
let order = null;
|
|
11986
11986
|
try {
|
|
@@ -11993,9 +11993,9 @@ function boundaryPrecedesWindow(sessionId, boundary, firstLiveId) {
|
|
|
11993
11993
|
sessionLog2(sessionId, `prefix trim: placing boundary ${boundary} failed:`, error);
|
|
11994
11994
|
order = null;
|
|
11995
11995
|
}
|
|
11996
|
-
const
|
|
11997
|
-
precedesVerdictBySession.set(sessionId, { boundary, firstLiveId,
|
|
11998
|
-
return
|
|
11996
|
+
const verdict = order === null || !Number.isFinite(order) ? "unknown" : order < 0 ? "precedes" : "not-before";
|
|
11997
|
+
precedesVerdictBySession.set(sessionId, { boundary, firstLiveId, verdict });
|
|
11998
|
+
return verdict;
|
|
11999
11999
|
}
|
|
12000
12000
|
function logBoundaryPrecedesWindow(options, boundary, firstLiveId) {
|
|
12001
12001
|
const { sessionId } = options;
|
|
@@ -12009,9 +12009,10 @@ function classifyAbsentBoundary(options, messages, boundary) {
|
|
|
12009
12009
|
const { sessionId } = options;
|
|
12010
12010
|
const pass = options.isCacheBustingPass ? "priced" : "defer";
|
|
12011
12011
|
const firstLiveId = firstPersistedLiveId(messages);
|
|
12012
|
-
|
|
12012
|
+
const order = firstLiveId === null ? "unknown" : boundaryOrderAgainstWindow(sessionId, boundary, firstLiveId);
|
|
12013
|
+
if (firstLiveId !== null && order === "precedes") {
|
|
12013
12014
|
logBoundaryPrecedesWindow(options, boundary, firstLiveId);
|
|
12014
|
-
return "boundary-precedes-window";
|
|
12015
|
+
return { status: "boundary-precedes-window" };
|
|
12015
12016
|
}
|
|
12016
12017
|
precedesWindowLoggedBySession.delete(sessionId);
|
|
12017
12018
|
const current = absentBoundaryEpisodeBySession.get(sessionId);
|
|
@@ -12021,7 +12022,10 @@ function classifyAbsentBoundary(options, messages, boundary) {
|
|
|
12021
12022
|
if (episode.passes === 1 || options.isCacheBustingPass) {
|
|
12022
12023
|
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)`);
|
|
12023
12024
|
}
|
|
12024
|
-
return
|
|
12025
|
+
return {
|
|
12026
|
+
status: "refused",
|
|
12027
|
+
refusal: order === "not-before" ? "boundary-not-in-request" : "boundary-unordered"
|
|
12028
|
+
};
|
|
12025
12029
|
}
|
|
12026
12030
|
function isSyntheticPrefixHead(message) {
|
|
12027
12031
|
if (message.info.id !== undefined || message.info.role !== "user" || message.parts.length === 0) {
|
|
@@ -12035,17 +12039,14 @@ function capturePrefixTrimSourceOrder(messages) {
|
|
|
12035
12039
|
let syntheticHeadCount = 0;
|
|
12036
12040
|
let sawPersistedRow = false;
|
|
12037
12041
|
let invalidReason = null;
|
|
12038
|
-
for (const
|
|
12042
|
+
for (const message of messages) {
|
|
12039
12043
|
const id = message.info.id;
|
|
12040
12044
|
if (isHostRenderedSystemMessage(message))
|
|
12041
12045
|
continue;
|
|
12042
12046
|
if (typeof id !== "string" || id.length === 0) {
|
|
12043
|
-
if (!sawPersistedRow && isSyntheticPrefixHead(message))
|
|
12047
|
+
if (!sawPersistedRow && isSyntheticPrefixHead(message))
|
|
12044
12048
|
syntheticHeadCount += 1;
|
|
12045
|
-
|
|
12046
|
-
}
|
|
12047
|
-
invalidReason = `source message at index ${index} has no stable id outside the synthetic head`;
|
|
12048
|
-
break;
|
|
12049
|
+
continue;
|
|
12049
12050
|
}
|
|
12050
12051
|
sawPersistedRow = true;
|
|
12051
12052
|
if (seen.has(id)) {
|
|
@@ -12094,21 +12095,49 @@ function reanchorStoredBoundary(options, boundary) {
|
|
|
12094
12095
|
}
|
|
12095
12096
|
function trimToPreparedPrefix(options, prepared) {
|
|
12096
12097
|
if (options.compactionOff || !options.messages)
|
|
12097
|
-
return "not-attempted";
|
|
12098
|
+
return { status: "not-attempted" };
|
|
12099
|
+
const messages = options.messages;
|
|
12098
12100
|
const boundary = prepared.preparedTrimBoundaryId;
|
|
12099
|
-
let
|
|
12101
|
+
let outcome = { status: "not-required" };
|
|
12100
12102
|
if (boundary) {
|
|
12101
12103
|
const retireDecisions = (messageIds) => {
|
|
12102
12104
|
queueAutoSearchHintDecisionRetirement(options.db, options.sessionId, new Set(messageIds));
|
|
12103
12105
|
};
|
|
12106
|
+
const trimAtVisibleBoundary = (reanchor) => {
|
|
12107
|
+
const index = findBoundaryIndex(options.sessionId, messages, boundary);
|
|
12108
|
+
if (index >= 0) {
|
|
12109
|
+
const cut = index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1);
|
|
12110
|
+
const unplaced = messages.slice(0, cut).filter(isHostRenderedSystemMessage);
|
|
12111
|
+
const removed = messages.splice(0, cut, ...unplaced);
|
|
12112
|
+
retireDecisions(removed.map((message) => message.info.id).filter((id) => typeof id === "string"));
|
|
12113
|
+
resetPrefixTrimFallbackState(options.sessionId);
|
|
12114
|
+
return { status: "applied" };
|
|
12115
|
+
}
|
|
12116
|
+
if (reanchor) {
|
|
12117
|
+
const reanchored = reanchorStoredBoundary(options, boundary);
|
|
12118
|
+
if (reanchored && reanchored.messageIds[0] !== boundary) {
|
|
12119
|
+
return trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared);
|
|
12120
|
+
}
|
|
12121
|
+
}
|
|
12122
|
+
return classifyAbsentBoundary(options, messages, boundary);
|
|
12123
|
+
};
|
|
12104
12124
|
const sourceOrder = options.prefixTrimSourceOrder;
|
|
12105
12125
|
if (sourceOrder) {
|
|
12106
|
-
const
|
|
12107
|
-
|
|
12108
|
-
|
|
12126
|
+
const pass = options.isCacheBustingPass ? "priced" : "defer";
|
|
12127
|
+
const refuse = (reason, refusal) => {
|
|
12128
|
+
sessionLog2(options.sessionId, `prefix trim: boundary ${boundary}; pass=${pass}; no in-pass trim applied (${reason})`);
|
|
12129
|
+
return { status: "refused", refusal };
|
|
12130
|
+
};
|
|
12131
|
+
const placeWithoutSourceOrder = (reason) => {
|
|
12132
|
+
sessionLog2(options.sessionId, `prefix trim: boundary ${boundary}; pass=${pass}; source order not usable (${reason}); placing the boundary by the live messages`);
|
|
12133
|
+
const served = resolveHostServedBoundaryId2(options.sessionId, boundary);
|
|
12134
|
+
const copies = messages.filter((message) => message.info.id === boundary || message.info.id === served).length;
|
|
12135
|
+
if (copies > 1)
|
|
12136
|
+
return refuse(`boundary ${boundary} appears ${copies} times in the live messages`, "boundary-unordered");
|
|
12137
|
+
return trimAtVisibleBoundary(false);
|
|
12109
12138
|
};
|
|
12110
12139
|
if (sourceOrder.invalidReason) {
|
|
12111
|
-
|
|
12140
|
+
outcome = placeWithoutSourceOrder(sourceOrder.invalidReason);
|
|
12112
12141
|
} else {
|
|
12113
12142
|
const sourcePosition = new Map;
|
|
12114
12143
|
sourceOrder.messageIds.forEach((id, index) => {
|
|
@@ -12117,7 +12146,7 @@ function trimToPreparedPrefix(options, prepared) {
|
|
|
12117
12146
|
const boundaryPosition = sourcePosition.get(boundary) ?? sourcePosition.get(resolveHostServedBoundaryId2(options.sessionId, boundary));
|
|
12118
12147
|
if (boundaryPosition === undefined) {
|
|
12119
12148
|
const reanchored = reanchorStoredBoundary(options, boundary);
|
|
12120
|
-
|
|
12149
|
+
outcome = reanchored ? trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared) : refuse("boundary absent from immutable source order", "boundary-unordered");
|
|
12121
12150
|
} else {
|
|
12122
12151
|
let lastSourcePosition = -1;
|
|
12123
12152
|
let sawPersistedRow = false;
|
|
@@ -12125,17 +12154,29 @@ function trimToPreparedPrefix(options, prepared) {
|
|
|
12125
12154
|
let firstLiveId;
|
|
12126
12155
|
let liveOrderError = null;
|
|
12127
12156
|
const retained = [];
|
|
12128
|
-
|
|
12157
|
+
let unplaced = [];
|
|
12158
|
+
const placeUnplaced = (cut) => {
|
|
12159
|
+
for (const message of unplaced) {
|
|
12160
|
+
if (!cut || isHostRenderedSystemMessage(message))
|
|
12161
|
+
retained.push(message);
|
|
12162
|
+
}
|
|
12163
|
+
unplaced = [];
|
|
12164
|
+
};
|
|
12165
|
+
for (const message of options.messages) {
|
|
12129
12166
|
const id = message.info.id;
|
|
12130
12167
|
if (isHostRenderedSystemMessage(message)) {
|
|
12168
|
+
if (unplaced.length > 0) {
|
|
12169
|
+
unplaced.push(message);
|
|
12170
|
+
continue;
|
|
12171
|
+
}
|
|
12131
12172
|
retained.push(message);
|
|
12132
12173
|
continue;
|
|
12133
12174
|
}
|
|
12134
12175
|
if (typeof id !== "string" || id.length === 0) {
|
|
12135
12176
|
if (!sawPersistedRow && isSyntheticPrefixHead(message))
|
|
12136
12177
|
continue;
|
|
12137
|
-
|
|
12138
|
-
|
|
12178
|
+
unplaced.push(message);
|
|
12179
|
+
continue;
|
|
12139
12180
|
}
|
|
12140
12181
|
sawPersistedRow = true;
|
|
12141
12182
|
const position = sourcePosition.get(id);
|
|
@@ -12152,44 +12193,31 @@ function trimToPreparedPrefix(options, prepared) {
|
|
|
12152
12193
|
firstLiveId = id;
|
|
12153
12194
|
}
|
|
12154
12195
|
lastSourcePosition = position;
|
|
12196
|
+
placeUnplaced(position <= boundaryPosition);
|
|
12155
12197
|
if (position > boundaryPosition || position === boundaryPosition && isPartialCompartmentEnd(options.db, options.sessionId, boundary))
|
|
12156
12198
|
retained.push(message);
|
|
12157
12199
|
}
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12200
|
+
placeUnplaced(false);
|
|
12201
|
+
if (liveOrderError) {
|
|
12202
|
+
outcome = placeWithoutSourceOrder(liveOrderError);
|
|
12203
|
+
} else {
|
|
12161
12204
|
if (firstLiveId && firstLivePosition !== undefined && firstLivePosition > boundaryPosition) {
|
|
12162
12205
|
logBoundaryPrecedesWindow(options, boundary, firstLiveId);
|
|
12163
12206
|
}
|
|
12164
12207
|
options.messages.splice(0, options.messages.length, ...retained);
|
|
12165
12208
|
const preserveBoundary = isPartialCompartmentEnd(options.db, options.sessionId, boundary);
|
|
12166
12209
|
retireDecisions(sourceOrder.messageIds.slice(0, boundaryPosition + (preserveBoundary ? 0 : 1)));
|
|
12167
|
-
|
|
12210
|
+
outcome = { status: "applied" };
|
|
12168
12211
|
}
|
|
12169
12212
|
}
|
|
12170
12213
|
}
|
|
12171
12214
|
} else {
|
|
12172
|
-
|
|
12173
|
-
if (index >= 0) {
|
|
12174
|
-
const cut = index + (isPartialCompartmentEnd(options.db, options.sessionId, boundary) ? 0 : 1);
|
|
12175
|
-
const unplaced = options.messages.slice(0, cut).filter(isHostRenderedSystemMessage);
|
|
12176
|
-
const removed = options.messages.splice(0, cut, ...unplaced);
|
|
12177
|
-
retireDecisions(removed.map((message) => message.info.id).filter((id) => typeof id === "string"));
|
|
12178
|
-
resetPrefixTrimFallbackState(options.sessionId);
|
|
12179
|
-
status = "applied";
|
|
12180
|
-
} else {
|
|
12181
|
-
const reanchored = reanchorStoredBoundary(options, boundary);
|
|
12182
|
-
if (reanchored && reanchored.messageIds[0] !== boundary) {
|
|
12183
|
-
status = trimToPreparedPrefix({ ...options, prefixTrimSourceOrder: reanchored }, prepared);
|
|
12184
|
-
} else {
|
|
12185
|
-
status = classifyAbsentBoundary(options, options.messages, boundary);
|
|
12186
|
-
}
|
|
12187
|
-
}
|
|
12215
|
+
outcome = trimAtVisibleBoundary(true);
|
|
12188
12216
|
}
|
|
12189
12217
|
}
|
|
12190
12218
|
if (prepared.m0RematerializedThisPass || options.isCacheBustingPass && !prepared.materializationContentionRetryExhausted)
|
|
12191
12219
|
clearInjectionCache(options.sessionId);
|
|
12192
|
-
return
|
|
12220
|
+
return outcome;
|
|
12193
12221
|
}
|
|
12194
12222
|
function prepareCachedM0M1Replay(db, sessionId) {
|
|
12195
12223
|
const row = readCachedM0M1Row(db, sessionId);
|
|
@@ -12242,15 +12270,16 @@ function injectM0M1(options) {
|
|
|
12242
12270
|
const prepared = options.preparedPrefix;
|
|
12243
12271
|
if (prepared?.preparedMessages) {
|
|
12244
12272
|
const head = prepared.preparedMessages;
|
|
12245
|
-
let
|
|
12273
|
+
let prefixTrim = { status: "not-attempted" };
|
|
12246
12274
|
if (options.messages) {
|
|
12247
|
-
|
|
12275
|
+
prefixTrim = trimToPreparedPrefix(options, prepared);
|
|
12248
12276
|
options.messages.unshift(...structuredClone(head));
|
|
12249
12277
|
}
|
|
12250
12278
|
return {
|
|
12251
12279
|
...prepared,
|
|
12252
12280
|
prependedMessageCount: options.messages ? head.length : 0,
|
|
12253
|
-
prefixTrimStatus
|
|
12281
|
+
prefixTrimStatus: prefixTrim.status,
|
|
12282
|
+
prefixTrimRefusal: prefixTrim.refusal
|
|
12254
12283
|
};
|
|
12255
12284
|
}
|
|
12256
12285
|
hydrateCachedM0Mural(options.db, options.sessionId, options.state);
|
|
@@ -12407,9 +12436,9 @@ function injectM0M1(options) {
|
|
|
12407
12436
|
contentHash: options.state.cachedM0MuralHash ?? undefined
|
|
12408
12437
|
} : undefined;
|
|
12409
12438
|
let prependedMessageCount = prependM0M1Messages(options.sessionId, preparedMessages, m0Text, m1Text, muralForWire);
|
|
12410
|
-
let
|
|
12439
|
+
let prefixTrim = { status: "not-attempted" };
|
|
12411
12440
|
if (options.messages) {
|
|
12412
|
-
|
|
12441
|
+
prefixTrim = trimToPreparedPrefix(options, {
|
|
12413
12442
|
m0RematerializedThisPass: rematerialized,
|
|
12414
12443
|
materializationContentionRetryExhausted: contentionExhausted,
|
|
12415
12444
|
preparedTrimBoundaryId
|
|
@@ -12427,7 +12456,8 @@ function injectM0M1(options) {
|
|
|
12427
12456
|
m1Text,
|
|
12428
12457
|
preparedMessages,
|
|
12429
12458
|
preparedTrimBoundaryId,
|
|
12430
|
-
prefixTrimStatus
|
|
12459
|
+
prefixTrimStatus: prefixTrim.status,
|
|
12460
|
+
...prefixTrim.refusal ? { prefixTrimRefusal: prefixTrim.refusal } : {}
|
|
12431
12461
|
};
|
|
12432
12462
|
}
|
|
12433
12463
|
|
|
@@ -16276,6 +16306,11 @@ function persistFilteredNoise(db, sessionId, chunk, eligibleEnd) {
|
|
|
16276
16306
|
const start = chunk.startIndex;
|
|
16277
16307
|
if (chunk.text || chunk.messageCount !== 0 || eligibleEnd <= start || rows.length !== eligibleEnd - start || rows.some((row, index) => row.ordinal !== start + index || !row.messageId))
|
|
16278
16308
|
return false;
|
|
16309
|
+
const endId = rows[rows.length - 1].messageId;
|
|
16310
|
+
if (!hasRawSessionMessageById2(sessionId, endId)) {
|
|
16311
|
+
sessionLog2(sessionId, `historian skipped a filtered-noise marker for ordinals ${start}-${eligibleEnd - 1}: its end row ${endId} is no longer in the host store`);
|
|
16312
|
+
return false;
|
|
16313
|
+
}
|
|
16279
16314
|
const saved = db.transaction(() => {
|
|
16280
16315
|
const prior = getCompartments(db, sessionId);
|
|
16281
16316
|
const last = prior.at(-1);
|
|
@@ -119,11 +119,11 @@ import {
|
|
|
119
119
|
saveSourceContent,
|
|
120
120
|
replaceSourceContent,
|
|
121
121
|
getSourceContents
|
|
122
|
-
} from "./index-
|
|
122
|
+
} from "./index-x7jcqpy6.js";
|
|
123
123
|
import {
|
|
124
124
|
cleanSearchText,
|
|
125
125
|
matchedSearchSnippet
|
|
126
|
-
} from "./index-
|
|
126
|
+
} from "./index-x4h461yf.js";
|
|
127
127
|
import {
|
|
128
128
|
stripSystemInjection,
|
|
129
129
|
isTextPart,
|
|
@@ -221,7 +221,7 @@ import {
|
|
|
221
221
|
extractToolCallObservation,
|
|
222
222
|
ToolMutationBatch,
|
|
223
223
|
createToolDropTarget
|
|
224
|
-
} from "./index-
|
|
224
|
+
} from "./index-9gs34125.js";
|
|
225
225
|
import {
|
|
226
226
|
isValidLanguageCode
|
|
227
227
|
} from "./index-jjy5a5w0.js";
|
|
@@ -237,7 +237,7 @@ import {
|
|
|
237
237
|
getMessageIndexEpoch,
|
|
238
238
|
isMessageIndexSearchable,
|
|
239
239
|
createAutoSearchDiagnostics
|
|
240
|
-
} from "./index-
|
|
240
|
+
} from "./index-g3j49m95.js";
|
|
241
241
|
import {
|
|
242
242
|
openCodeDbExists,
|
|
243
243
|
withReadOnlySessionDb,
|
|
@@ -266,10 +266,10 @@ import {
|
|
|
266
266
|
peekNoteNudgeText,
|
|
267
267
|
markNoteNudgeDelivered,
|
|
268
268
|
getActiveCompartmentRun
|
|
269
|
-
} from "./index-
|
|
269
|
+
} from "./index-42n4fhxy.js";
|
|
270
270
|
import {
|
|
271
271
|
userFacingFailureCode
|
|
272
|
-
} from "./index-
|
|
272
|
+
} from "./index-xqhejxmd.js";
|
|
273
273
|
import {
|
|
274
274
|
normalizeProtectedToolName,
|
|
275
275
|
mergeProtectedTools
|
|
@@ -8061,6 +8061,7 @@ async function runPostTransformPhase2(args) {
|
|
|
8061
8061
|
prefixMutationPermitted: isCacheBustingPass,
|
|
8062
8062
|
bustedThisPass,
|
|
8063
8063
|
prefixTrimStatus: deliveredPrefix?.prefixTrimStatus ?? null,
|
|
8064
|
+
prefixTrimRefusal: deliveredPrefix?.prefixTrimRefusal ?? null,
|
|
8064
8065
|
thinkingBindingRecovery,
|
|
8065
8066
|
proactiveThinkingStrip,
|
|
8066
8067
|
thinkingReleasedForFit
|
|
@@ -3545,7 +3545,7 @@ function normalizeDetectedLimitModelKey(modelKey) {
|
|
|
3545
3545
|
return typeof modelKey === "string" && modelKey.length > 0 ? piModelRefToCanonical(modelKey) : null;
|
|
3546
3546
|
}
|
|
3547
3547
|
function normalizeEmergencyRecoveryOrigin(value) {
|
|
3548
|
-
return value === "provider_overflow" || value === "proactive_model_shrink" ? value : null;
|
|
3548
|
+
return value === "provider_overflow" || value === "proactive_model_shrink" || value === "history_boundary_over_window" ? value : null;
|
|
3549
3549
|
}
|
|
3550
3550
|
function parseOverflowState(result, modelKey) {
|
|
3551
3551
|
if (!result) {
|
|
@@ -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-bfv831yx.js"));
|
|
1027
1027
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-hp2jgn49.js"));
|
|
1028
1028
|
if (signal.aborted)
|
|
1029
1029
|
return;
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-9gs34125.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-0jc25yjf.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
releaseCompartmentLeaseBestEffort,
|
|
9
9
|
getCompartments,
|
|
10
10
|
getLastCompartmentEndMessage
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-x7jcqpy6.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-
|
|
23
|
+
} from "./index-9gs34125.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-
|
|
35
|
+
} from "./index-42n4fhxy.js";
|
|
36
36
|
import {
|
|
37
37
|
sendStatusNotification2
|
|
38
38
|
} from "./index-r9agn061.js";
|
|
39
39
|
import {
|
|
40
40
|
setRecompStarting2,
|
|
41
41
|
setRecompTerminal2
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-qtpkkzan.js";
|
|
43
43
|
|
|
44
44
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
45
45
|
import * as crypto from "node:crypto";
|