@cortexkit/opencode-magic-context 0.49.24 → 0.49.26
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 +4 -4
- package/dist/chunk-embedding-write-worker.js +5 -5
- package/dist/{compartment-chunk-embedding-eypvn607.js → compartment-chunk-embedding-96ec8a7h.js} +3 -3
- package/dist/{conflict-warning-hook-a27bhggg.js → conflict-warning-hook-dv8fdc2w.js} +4 -4
- package/dist/{context-tvrjhnmj.js → context-pjqa24nd.js} +30 -24
- package/dist/{embedding-backfill-vddgmem3.js → embedding-backfill-a91rvdf9.js} +5 -5
- package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -57
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +14 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +11 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/foreign-text-parts.d.ts +47 -0
- package/dist/hooks/magic-context/foreign-text-parts.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +21 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +20 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-messages.d.ts +15 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +7 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-2haxh8h3.js → index-064v90e8.js} +1 -1
- package/dist/{index-p6evxfcc.js → index-40ma8m0c.js} +7 -49
- package/dist/{index-6g7tyb6e.js → index-56tfs78r.js} +96 -41
- package/dist/{index-jrjr58ez.js → index-6g1zq1sk.js} +3 -3
- package/dist/{index-3d5wnkq7.js → index-6tmf87w0.js} +1 -1
- package/dist/index-cfaet9cg.js +405 -0
- package/dist/{index-t1zk694n.js → index-dn2ke3b9.js} +30 -14
- package/dist/{index-t6j3qxnd.js → index-e5b61ty6.js} +1 -1
- package/dist/{index-dds7cxhz.js → index-hjnrp6vy.js} +67 -21
- package/dist/{index-c9zrgcnt.js → index-j43m40zd.js} +1 -1
- package/dist/{index-7tdtpqrg.js → index-m8va3mma.js} +39 -6
- package/dist/{index-z928hmnp.js → index-mphkpyap.js} +1 -1
- package/dist/{index-21bkd3m6.js → index-r3bteyev.js} +5 -5
- package/dist/{index-8e9qsnrw.js → index-rp78nqvr.js} +169 -11
- package/dist/{index-z05n7702.js → index-sgchhbvy.js} +1 -1
- package/dist/{index-jd0y50w3.js → index-va2g2q57.js} +3 -3
- package/dist/{index-jcr6pe7z.js → index-w55zp7kf.js} +1 -1
- package/dist/{index-szf8r0ba.js → index-xbbgcwd2.js} +1 -1
- package/dist/{index-7516anfj.js → index-xyx2ge2y.js} +4 -4
- package/dist/{index-57jf5ztp.js → index-zn2n24yr.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -35
- package/dist/{message-fts-rowid-map-9e1getgs.js → message-fts-rowid-map-4ksatb6f.js} +2 -2
- package/dist/{message-index-bounded-k8pgrxad.js → message-index-bounded-whh5wv4a.js} +7 -7
- package/dist/{message-index-1sgzev6c.js → message-index-ywx53y30.js} +7 -7
- package/dist/migration-worker.js +4 -4
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-rstzmb60.js → project-embedding-registry-t9fx6jwh.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-q9z6s48t.js → read-session-chunk-mqmkgdx0.js} +6 -4
- package/dist/{read-session-raw-s4amywnh.js → read-session-raw-dy2xxafq.js} +3 -1
- package/dist/{recomp-orchestrator-hr8ddk8z.js → recomp-orchestrator-qwcz86r1.js} +14 -14
- package/dist/{search-archive-c00etw7k.js → search-archive-8md3twv2.js} +5 -5
- package/dist/{search-3zjjmc60.js → search-y2t97tbb.js} +11 -11
- package/dist/{send-session-notification-ygj4mja0.js → send-session-notification-kzazs7fy.js} +3 -3
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-rredw6bz.js → transform-postprocess-phase-ppm1tfa7.js} +14 -14
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +5 -5
- package/dist/v2/{compartment-chunk-embedding-tk6g4q80.js → compartment-chunk-embedding-5rmrn09z.js} +3 -3
- package/dist/v2/{context-zbydzq4g.js → context-10pj3bwd.js} +245 -45
- package/dist/v2/{embedding-backfill-w5qp7t28.js → embedding-backfill-r9mzt2eg.js} +5 -5
- package/dist/v2/hooks/context.d.ts +4 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-pqk3a55v.js → message-fts-rowid-map-2s3ta05x.js} +2 -2
- package/dist/v2/{message-index-bounded-a9xa8wsq.js → message-index-bounded-f4269d3a.js} +6 -6
- package/dist/v2/{message-index-5gnnn64b.js → message-index-v6g8mgn7.js} +6 -6
- package/dist/v2/migration-worker.js +4 -4
- package/dist/v2/{project-embedding-registry-e7zftfvj.js → project-embedding-registry-tgtmart7.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
- package/dist/v2/{read-session-chunk-qqvda7zv.js → read-session-chunk-ym5zvexn.js} +5 -3
- package/dist/v2/{read-session-raw-ppjxnqk4.js → read-session-raw-484g8kf2.js} +3 -1
- package/dist/v2/{recomp-orchestrator-nmt9y25j.js → recomp-orchestrator-b44s2snm.js} +11 -11
- package/dist/v2/{search-6dawx2gt.js → search-75tf953m.js} +10 -10
- package/dist/v2/{search-archive-dhqj1w31.js → search-archive-pmf2c1kb.js} +4 -4
- package/dist/v2/{send-session-notification-f8scq6ae.js → send-session-notification-gd21f5rq.js} +1 -1
- package/dist/v2/{server-y9ncq4ck.js → server-317f3x9y.js} +3 -3
- package/dist/v2/{server-wxrdher8.js → server-4frtg2z1.js} +1 -1
- package/dist/v2/server-7d6m1p2b.js +361 -0
- package/dist/v2/{server-pw21ypwb.js → server-7dpnt0ys.js} +1 -1
- package/dist/v2/{server-r209n2fk.js → server-9zh78t8y.js} +65 -19
- package/dist/v2/{server-swvhxhxz.js → server-erk2bvdf.js} +39 -6
- package/dist/v2/{server-q5z0gag0.js → server-hnmm8yzq.js} +1 -1
- package/dist/v2/{server-gwmshgx9.js → server-jcsw05aa.js} +29 -13
- package/dist/v2/{server-mefps930.js → server-k46ec388.js} +7 -49
- package/dist/v2/{server-9xbbaekh.js → server-nmwhe524.js} +1 -1
- package/dist/v2/{server-9e55n4wx.js → server-vjer2jdn.js} +5 -5
- package/dist/v2/{server-16dpnz56.js → server-w7x9wgm0.js} +2 -2
- package/dist/v2/{server-8j2e7t31.js → server-wj8h2q21.js} +1 -1
- package/dist/v2/server.js +2 -2
- package/dist/v2/{wrapup-orchestrator-9z81xj66.js → wrapup-orchestrator-gwww44st.js} +11 -11
- package/dist/{wrapup-orchestrator-dbnb530w.js → wrapup-orchestrator-a9r8r4sk.js} +15 -15
- package/package.json +1 -1
- package/dist/index-j76ah6d7.js +0 -120
- package/dist/v2/server-d1dzgvwd.js +0 -120
|
@@ -92,12 +92,13 @@ import {
|
|
|
92
92
|
readRawSessionMessageIdOrdinalsForRange2,
|
|
93
93
|
hasRawSessionMessageById2,
|
|
94
94
|
readRawSessionMessageOrdinalById2,
|
|
95
|
+
resolveHistorianChunkStart2,
|
|
95
96
|
compareRawSessionMessageOrder2,
|
|
96
97
|
getRawSessionMessageCount2,
|
|
97
98
|
getRawSessionTagKeysThrough2,
|
|
98
99
|
getLegacyProtectedTailStartOrdinal2,
|
|
99
100
|
readSessionChunk2
|
|
100
|
-
} from "./index-
|
|
101
|
+
} from "./index-dn2ke3b9.js";
|
|
101
102
|
import {
|
|
102
103
|
getHarness2,
|
|
103
104
|
harnessOwnsOpenCodeStore2
|
|
@@ -164,7 +165,7 @@ import {
|
|
|
164
165
|
LATEST_SUPPORTED_VERSION,
|
|
165
166
|
getPersistedSchemaVersion,
|
|
166
167
|
openDatabase
|
|
167
|
-
} from "./index-
|
|
168
|
+
} from "./index-6g1zq1sk.js";
|
|
168
169
|
import {
|
|
169
170
|
inRootAsyncContext2,
|
|
170
171
|
Database2,
|
|
@@ -185,8 +186,9 @@ import {
|
|
|
185
186
|
isStrictGapHealingMessage2,
|
|
186
187
|
noteRawSessionSummaryRowWritten2,
|
|
187
188
|
RawOrdinalsNotReady2,
|
|
189
|
+
dropRawSessionOrdinalCheckpoints2,
|
|
188
190
|
runSessionWarmupWorker
|
|
189
|
-
} from "./index-
|
|
191
|
+
} from "./index-m8va3mma.js";
|
|
190
192
|
import {
|
|
191
193
|
layoutLkgPrefix,
|
|
192
194
|
assembleLkgPrefix,
|
|
@@ -213,8 +215,9 @@ import {
|
|
|
213
215
|
claimOpenCodeDbDiagnosticOnce
|
|
214
216
|
} from "./index-58e3y90n.js";
|
|
215
217
|
import {
|
|
218
|
+
BoundedSessionMap,
|
|
216
219
|
getMeasuredToolDefinitionTokens
|
|
217
|
-
} from "./index-
|
|
220
|
+
} from "./index-cfaet9cg.js";
|
|
218
221
|
import {
|
|
219
222
|
invalidateAutoEmbedSession,
|
|
220
223
|
drainBackgroundBatches,
|
|
@@ -223,7 +226,7 @@ import {
|
|
|
223
226
|
getProjectChunkEmbeddingModelId2,
|
|
224
227
|
getProjectEmbeddingMaxInputTokens2,
|
|
225
228
|
embedItemsForProject2
|
|
226
|
-
} from "./index-
|
|
229
|
+
} from "./index-sgchhbvy.js";
|
|
227
230
|
import {
|
|
228
231
|
buildCanonicalChunkTextFromFts2,
|
|
229
232
|
buildCompartmentSummaryFallbackText2,
|
|
@@ -233,9 +236,8 @@ import {
|
|
|
233
236
|
replaceCompartmentChunkEmbeddings2,
|
|
234
237
|
deleteChunkEmbedBackoffForSession2,
|
|
235
238
|
chunkWindowSourceKey2
|
|
236
|
-
} from "./index-
|
|
239
|
+
} from "./index-6tmf87w0.js";
|
|
237
240
|
import {
|
|
238
|
-
BoundedSessionMap,
|
|
239
241
|
clearCompressionDepth,
|
|
240
242
|
clearCompressionDepthRange,
|
|
241
243
|
clearLkgFenceProcessState,
|
|
@@ -250,7 +252,7 @@ import {
|
|
|
250
252
|
toMessageIndexSource2,
|
|
251
253
|
clearIndexedMessagesInTransaction2,
|
|
252
254
|
indexSourcesAfterOrdinal2
|
|
253
|
-
} from "./index-
|
|
255
|
+
} from "./index-40ma8m0c.js";
|
|
254
256
|
import {
|
|
255
257
|
stripWellFormedLeadingTagPrefix,
|
|
256
258
|
stripTagPrefix,
|
|
@@ -268,7 +270,7 @@ import {
|
|
|
268
270
|
openCodeDbExists,
|
|
269
271
|
withReadOnlySessionDb,
|
|
270
272
|
getMessageTimesFromOpenCodeDb
|
|
271
|
-
} from "./index-
|
|
273
|
+
} from "./index-j43m40zd.js";
|
|
272
274
|
import {
|
|
273
275
|
renderUserFacingFailure,
|
|
274
276
|
userFacingFailureCode,
|
|
@@ -277,7 +279,7 @@ import {
|
|
|
277
279
|
insertPrimerCandidates,
|
|
278
280
|
promoteSessionFactsDurable,
|
|
279
281
|
embedPromotedFacts
|
|
280
|
-
} from "./index-
|
|
282
|
+
} from "./index-mphkpyap.js";
|
|
281
283
|
import {
|
|
282
284
|
pushNotification2
|
|
283
285
|
} from "./index-x8a7jmkh.js";
|
|
@@ -297,7 +299,7 @@ import {
|
|
|
297
299
|
} from "./index-qgh1qwjj.js";
|
|
298
300
|
import {
|
|
299
301
|
sendStatusNotification2
|
|
300
|
-
} from "./index-
|
|
302
|
+
} from "./index-w55zp7kf.js";
|
|
301
303
|
import {
|
|
302
304
|
isCompactionEnabled,
|
|
303
305
|
migrateLegacyAgentEnabledInMemory
|
|
@@ -5410,13 +5412,13 @@ function identity(slot) {
|
|
|
5410
5412
|
slot.inputContentDigests
|
|
5411
5413
|
])).update(slot.jsonPrefix).digest("hex");
|
|
5412
5414
|
}
|
|
5413
|
-
function envelope(modelKey, systemPromptTokens, agentName) {
|
|
5415
|
+
function envelope(modelKey, systemPromptTokens, agentName, sessionId) {
|
|
5414
5416
|
const slash = modelKey.indexOf("/");
|
|
5415
5417
|
return JSON.stringify([
|
|
5416
5418
|
modelKey,
|
|
5417
5419
|
systemPromptTokens,
|
|
5418
5420
|
agentName,
|
|
5419
|
-
getMeasuredToolDefinitionTokens(modelKey.slice(0, slash), modelKey.slice(slash + 1), agentName)
|
|
5421
|
+
getMeasuredToolDefinitionTokens(modelKey.slice(0, slash), modelKey.slice(slash + 1), agentName, sessionId)
|
|
5420
5422
|
]);
|
|
5421
5423
|
}
|
|
5422
5424
|
function beginV2LkgRequest(sessionId, modelKey, previousResponseId, responseAfterSequence) {
|
|
@@ -5448,7 +5450,7 @@ function noteCapturedLkgRequest(args) {
|
|
|
5448
5450
|
request,
|
|
5449
5451
|
slot: identity(args.slot),
|
|
5450
5452
|
prefixCount: JSON.parse(args.slot.jsonPrefix).length,
|
|
5451
|
-
envelope: envelope(request.modelKey, args.systemPromptTokens, args.agentName)
|
|
5453
|
+
envelope: envelope(request.modelKey, args.systemPromptTokens, args.agentName, args.sessionId)
|
|
5452
5454
|
});
|
|
5453
5455
|
}
|
|
5454
5456
|
function noteLkgProviderResponse(args) {
|
|
@@ -5479,7 +5481,7 @@ function noteLkgProviderResponse(args) {
|
|
|
5479
5481
|
}
|
|
5480
5482
|
function measuredLkgPrefix(args) {
|
|
5481
5483
|
const capture = captures.get(args.sessionId);
|
|
5482
|
-
if (!capture?.usage || !args.slot || capture.slot !== identity(args.slot) || capture.request.modelKey !== args.modelKey || capture.envelope !== envelope(args.modelKey, args.systemPromptTokens, args.agentName))
|
|
5484
|
+
if (!capture?.usage || !args.slot || capture.slot !== identity(args.slot) || capture.request.modelKey !== args.modelKey || capture.envelope !== envelope(args.modelKey, args.systemPromptTokens, args.agentName, args.sessionId))
|
|
5483
5485
|
return;
|
|
5484
5486
|
const appendedMessages = args.messages.slice(capture.prefixCount);
|
|
5485
5487
|
if (appendedMessages[0]?.info.id !== capture.usage.responseId || appendedMessages[0]?.info.role !== "assistant" || JSON.stringify(args.messages.slice(0, capture.prefixCount)) !== args.slot.jsonPrefix)
|
|
@@ -20115,6 +20117,24 @@ function shouldSuppressHistorianAlert(sessionId) {
|
|
|
20115
20117
|
lastHistorianAlertBySession.set(sessionId, Date.now());
|
|
20116
20118
|
return false;
|
|
20117
20119
|
}
|
|
20120
|
+
function isServingOrdinalDriftSignal(detail) {
|
|
20121
|
+
if (!detail)
|
|
20122
|
+
return false;
|
|
20123
|
+
if (detail === "raw message count shrank")
|
|
20124
|
+
return true;
|
|
20125
|
+
return /(?:offset|protectedTailStart|eligibleEnd) ordinal \d+ id changed$/.test(detail);
|
|
20126
|
+
}
|
|
20127
|
+
function shouldRefuseStaleSnapshotForDrift(sessionId, detail) {
|
|
20128
|
+
if (hasRawMessageProvider2(sessionId) || !openCodeDbExists())
|
|
20129
|
+
return false;
|
|
20130
|
+
return isServingOrdinalDriftSignal(detail);
|
|
20131
|
+
}
|
|
20132
|
+
function dropDriftedServingOrdinalRanks(sessionId, detail) {
|
|
20133
|
+
if (hasRawMessageProvider2(sessionId) || !openCodeDbExists())
|
|
20134
|
+
return;
|
|
20135
|
+
withReadOnlySessionDb((reader) => dropRawSessionOrdinalCheckpoints2(reader, sessionId));
|
|
20136
|
+
sessionLog2(sessionId, `historian: dropped drifted ordinal checkpoints after exact-read disagreement (${detail}); the next run rebuilds them from a full scan`);
|
|
20137
|
+
}
|
|
20118
20138
|
function findDanglingPublicationBoundary(sessionId, compartments, messageExists = hasRawSessionMessageById2) {
|
|
20119
20139
|
for (const compartment of compartments) {
|
|
20120
20140
|
if (!messageExists(sessionId, compartment.startMessageId)) {
|
|
@@ -20282,7 +20302,16 @@ async function runCompartmentAgent(deps) {
|
|
|
20282
20302
|
}
|
|
20283
20303
|
return;
|
|
20284
20304
|
}
|
|
20285
|
-
|
|
20305
|
+
let offset;
|
|
20306
|
+
try {
|
|
20307
|
+
offset = resolveHistorianChunkStart2(sessionId, priorCompartments[priorCompartments.length - 1] ?? null);
|
|
20308
|
+
} catch (error) {
|
|
20309
|
+
if (error instanceof RawOrdinalsNotReady2) {
|
|
20310
|
+
deferUntilOrdinalsReady("chunk start unreadable");
|
|
20311
|
+
return;
|
|
20312
|
+
}
|
|
20313
|
+
throw error;
|
|
20314
|
+
}
|
|
20286
20315
|
let boundarySnapshot = deps.boundarySnapshot ?? null;
|
|
20287
20316
|
if (!boundarySnapshot) {
|
|
20288
20317
|
telemetry.failureReason = "missing protected-tail boundary snapshot";
|
|
@@ -20292,17 +20321,34 @@ async function runCompartmentAgent(deps) {
|
|
|
20292
20321
|
}
|
|
20293
20322
|
let validation = { ok: true };
|
|
20294
20323
|
if (boundarySnapshot.rawRangeFingerprint.length > 0) {
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
20299
|
-
|
|
20324
|
+
let checked;
|
|
20325
|
+
try {
|
|
20326
|
+
checked = await validateBoundarySnapshotOffThread({
|
|
20327
|
+
db,
|
|
20328
|
+
snapshot: boundarySnapshot,
|
|
20329
|
+
currentContextLimit: deps.currentContextLimit ?? boundarySnapshot.contextLimit
|
|
20330
|
+
});
|
|
20331
|
+
} catch (error) {
|
|
20332
|
+
if (error instanceof RawOrdinalsNotReady2) {
|
|
20333
|
+
deferUntilOrdinalsReady("boundary validation unreadable");
|
|
20334
|
+
return;
|
|
20335
|
+
}
|
|
20336
|
+
throw error;
|
|
20337
|
+
}
|
|
20300
20338
|
if (checked.kind === "not-ready") {
|
|
20301
20339
|
deferUntilOrdinalsReady(`boundary validation ${checked.reason}`);
|
|
20302
20340
|
return;
|
|
20303
20341
|
}
|
|
20304
20342
|
validation = checked.result;
|
|
20305
20343
|
}
|
|
20344
|
+
if (!validation.ok && validation.reason === "stale_snapshot" && shouldRefuseStaleSnapshotForDrift(sessionId, validation.detail)) {
|
|
20345
|
+
dropDriftedServingOrdinalRanks(sessionId, validation.detail ?? validation.reason ?? "stale_snapshot");
|
|
20346
|
+
sessionLog2(sessionId, `historian: refusing to publish over a stale protected-tail snapshot (was: ${validation.detail ?? "stale"}); ending the run without publishing`);
|
|
20347
|
+
telemetry.status = "noop";
|
|
20348
|
+
telemetry.failureReason = "stale_snapshot";
|
|
20349
|
+
rollbackDrainReservation();
|
|
20350
|
+
return;
|
|
20351
|
+
}
|
|
20306
20352
|
if (!validation.ok && validation.reason === "stale_snapshot") {
|
|
20307
20353
|
const refreshed = deps.refreshBoundarySnapshot ? deps.refreshBoundarySnapshot(boundarySnapshot, validation) : resolveOpenCodeProtectedTailBoundary({
|
|
20308
20354
|
db,
|
|
@@ -566,6 +566,20 @@ function survivingAnchor(db, set) {
|
|
|
566
566
|
}
|
|
567
567
|
var ordinalCheckpoints = new WeakMap;
|
|
568
568
|
var ordinalSummarySeeds = new WeakMap;
|
|
569
|
+
function hasLateCommitBehindCheckpoint(db, sessionId, scan) {
|
|
570
|
+
const tail = scan.checkpoints?.at(-1);
|
|
571
|
+
if (!tail || scan.maxRowid === undefined)
|
|
572
|
+
return false;
|
|
573
|
+
const row = db.prepare(`SELECT COUNT(*) AS count FROM message
|
|
574
|
+
WHERE rowid > ? AND +session_id = ?
|
|
575
|
+
AND (time_created, id) <= (?, ?)
|
|
576
|
+
AND NOT (${EXCLUDED_ROW_SQL})`).get(scan.maxRowid, sessionId, tail.timeCreated, tail.id);
|
|
577
|
+
return typeof row?.count === "number" && row.count > 0;
|
|
578
|
+
}
|
|
579
|
+
function discardRetainedOrdinalRanks(db, sessionId) {
|
|
580
|
+
ordinalCheckpoints.get(db)?.delete(sessionId);
|
|
581
|
+
ordinalSummarySeeds.get(db)?.delete(sessionId);
|
|
582
|
+
}
|
|
569
583
|
var ORDINAL_LOOKUP_LIMIT = 512;
|
|
570
584
|
function currentOrdinalCheckpoints(db, sessionId) {
|
|
571
585
|
const cached = ordinalCheckpoints.get(db)?.get(sessionId);
|
|
@@ -596,10 +610,16 @@ function extendOrdinalCheckpoints(db, sessionId, scan, limit) {
|
|
|
596
610
|
scan.sessionRows = points.at(-1)?.storedCount ?? 0;
|
|
597
611
|
}
|
|
598
612
|
const tail = points.at(-1);
|
|
599
|
-
const rows = db.prepare(`SELECT id, time_created AS timeCreated, ${EXCLUDED_ROW_SQL} AS excluded FROM message
|
|
613
|
+
const rows = db.prepare(`SELECT id, time_created AS timeCreated, rowid AS rowid, ${EXCLUDED_ROW_SQL} AS excluded FROM message
|
|
600
614
|
WHERE session_id=?${tail ? " AND (time_created,id) > (?,?)" : ""}
|
|
601
615
|
ORDER BY time_created,id${limit === undefined ? "" : ` LIMIT ${limit + 1}`}`).all(sessionId, ...tail ? [tail.timeCreated, tail.id] : []);
|
|
602
616
|
ordinalJsonRowsRead += rows.length;
|
|
617
|
+
if (hasLateCommitBehindCheckpoint(db, sessionId, scan)) {
|
|
618
|
+
discardRetainedOrdinalRanks(db, sessionId);
|
|
619
|
+
if (isMainThread)
|
|
620
|
+
forgetRawSessionSummaryRows2(sessionId);
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
603
623
|
if (limit !== undefined && rows.length > limit)
|
|
604
624
|
return false;
|
|
605
625
|
let total = scan.total ?? 0;
|
|
@@ -616,6 +636,13 @@ function extendOrdinalCheckpoints(db, sessionId, scan, limit) {
|
|
|
616
636
|
scan.checkpoints = points;
|
|
617
637
|
scan.sessionRows += rows.length;
|
|
618
638
|
scan.total = total;
|
|
639
|
+
if (rows.length > 0) {
|
|
640
|
+
let maxRowid = scan.maxRowid ?? -1;
|
|
641
|
+
for (const row of rows)
|
|
642
|
+
if (row.rowid > maxRowid)
|
|
643
|
+
maxRowid = row.rowid;
|
|
644
|
+
scan.maxRowid = maxRowid;
|
|
645
|
+
}
|
|
619
646
|
return true;
|
|
620
647
|
}
|
|
621
648
|
|
|
@@ -636,6 +663,10 @@ function rawOrdinalSummarySeed2(db, sessionId) {
|
|
|
636
663
|
ids: [...new Set([...seed.scan.ids, ...writtenSummaryIds.get(sessionId) ?? []])]
|
|
637
664
|
};
|
|
638
665
|
}
|
|
666
|
+
function dropRawSessionOrdinalCheckpoints2(db, sessionId) {
|
|
667
|
+
discardRetainedOrdinalRanks(db, sessionId);
|
|
668
|
+
forgetRawSessionSummaryRows2(sessionId);
|
|
669
|
+
}
|
|
639
670
|
function boundedOrdinalPrefix(db, sessionId, through) {
|
|
640
671
|
const cached = currentOrdinalCheckpoints(db, sessionId);
|
|
641
672
|
if (cached && through === null)
|
|
@@ -674,8 +705,7 @@ function boundedOrdinalPrefix(db, sessionId, through) {
|
|
|
674
705
|
}
|
|
675
706
|
function scanRawSessionSummaryRows2(db, sessionId, previous) {
|
|
676
707
|
return withReadSnapshot(db, () => {
|
|
677
|
-
if (previous?.checkpoints) {
|
|
678
|
-
extendOrdinalCheckpoints(db, sessionId, previous);
|
|
708
|
+
if (previous?.checkpoints && extendOrdinalCheckpoints(db, sessionId, previous)) {
|
|
679
709
|
return previous;
|
|
680
710
|
}
|
|
681
711
|
if (previous) {
|
|
@@ -707,12 +737,15 @@ function scanRawSessionSummaryRows2(db, sessionId, previous) {
|
|
|
707
737
|
}
|
|
708
738
|
anchors.sort((left, right) => right.rowid - left.rowid);
|
|
709
739
|
anchors.length = Math.min(anchors.length, SUMMARY_ANCHOR_LIMIT);
|
|
710
|
-
const keys = db.prepare(`SELECT id, time_created AS timeCreated, ${EXCLUDED_ROW_SQL} AS excluded FROM message WHERE session_id = ?
|
|
740
|
+
const keys = db.prepare(`SELECT id, time_created AS timeCreated, rowid AS rowid, ${EXCLUDED_ROW_SQL} AS excluded FROM message WHERE session_id = ?
|
|
711
741
|
ORDER BY time_created, id`).all(sessionId);
|
|
712
742
|
const checkpoints = [];
|
|
713
743
|
let total = 0;
|
|
744
|
+
let maxRowid;
|
|
714
745
|
for (let index = 0;index < keys.length; index++) {
|
|
715
746
|
const key = keys[index];
|
|
747
|
+
if (typeof key.rowid === "number")
|
|
748
|
+
maxRowid = maxRowid === undefined ? key.rowid : Math.max(maxRowid, key.rowid);
|
|
716
749
|
if (key.excluded !== 1)
|
|
717
750
|
total++;
|
|
718
751
|
if (index % 256 === 255 || index === keys.length - 1)
|
|
@@ -723,7 +756,7 @@ function scanRawSessionSummaryRows2(db, sessionId, previous) {
|
|
|
723
756
|
storedCount: index + 1
|
|
724
757
|
});
|
|
725
758
|
}
|
|
726
|
-
return { anchors, ids, sessionRows, checkpoints, total };
|
|
759
|
+
return { anchors, ids, sessionRows, checkpoints, total, maxRowid };
|
|
727
760
|
});
|
|
728
761
|
}
|
|
729
762
|
function getRawSessionSummaryEpoch2(sessionId) {
|
|
@@ -1297,4 +1330,4 @@ function recordFailure(key, sessionId, failure, detail) {
|
|
|
1297
1330
|
log2(`[magic-context] WARN canonical ordinal warm-up failed for ${sessionId} (${failure}: ${detail}); counts remain bounded and callers must defer or retry`);
|
|
1298
1331
|
}
|
|
1299
1332
|
|
|
1300
|
-
export { areRustHistorianSyntheticParts2, isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|
|
1333
|
+
export { areRustHistorianSyntheticParts2, isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, dropRawSessionOrdinalCheckpoints2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
loadCompartmentChunkEmbeddingsForSearch2,
|
|
25
25
|
peekCompartmentChunkSearchPool2,
|
|
26
26
|
warmCompartmentChunkSearchPool2
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-6tmf87w0.js";
|
|
28
28
|
import {
|
|
29
29
|
recordEmbeddingMeasurement,
|
|
30
30
|
saveCommitEmbedding,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
enqueueShadowEmbeddingItems2,
|
|
42
42
|
getProjectEmbeddingSnapshot2,
|
|
43
43
|
embedItemsForProject2
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-sgchhbvy.js";
|
|
45
45
|
import {
|
|
46
46
|
getProjectEmbeddings2
|
|
47
47
|
} from "./index-4dhv7mqz.js";
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
isEmbeddingEnabled,
|
|
51
51
|
embedText,
|
|
52
52
|
ensureMemoryEmbeddings2
|
|
53
|
-
} from "./index-
|
|
53
|
+
} from "./index-e5b61ty6.js";
|
|
54
54
|
import {
|
|
55
55
|
ModuleMemoryAuthorityError2,
|
|
56
56
|
getMemoriesByProject2,
|
|
@@ -65,13 +65,13 @@ import {
|
|
|
65
65
|
sanitizeFtsQuery,
|
|
66
66
|
searchMemoriesFTS,
|
|
67
67
|
searchMemoriesFTSUnion
|
|
68
|
-
} from "./index-
|
|
68
|
+
} from "./index-mphkpyap.js";
|
|
69
69
|
import {
|
|
70
70
|
cleanSearchText,
|
|
71
71
|
keywordRelevance,
|
|
72
72
|
matchedSearchSnippet,
|
|
73
73
|
getIndexedMessageCorpusSize2
|
|
74
|
-
} from "./index-
|
|
74
|
+
} from "./index-40ma8m0c.js";
|
|
75
75
|
import {
|
|
76
76
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
77
77
|
withMessageFtsSessionFilter
|
|
@@ -98,13 +98,13 @@ import {
|
|
|
98
98
|
getProjectEmbeddingSnapshot2,
|
|
99
99
|
embedTextForProject2,
|
|
100
100
|
embedBatchForProject2
|
|
101
|
-
} from "./index-
|
|
101
|
+
} from "./index-sgchhbvy.js";
|
|
102
102
|
import {
|
|
103
103
|
createWorkerShutdown
|
|
104
104
|
} from "./index-cpjk5jd2.js";
|
|
105
105
|
import {
|
|
106
106
|
runSessionWarmupWorker
|
|
107
|
-
} from "./index-
|
|
107
|
+
} from "./index-m8va3mma.js";
|
|
108
108
|
import {
|
|
109
109
|
getMaxM0MutationId,
|
|
110
110
|
getLastCompartmentEndMessage,
|
|
@@ -140,12 +140,11 @@ import {
|
|
|
140
140
|
peekNoteNudgeText,
|
|
141
141
|
markNoteNudgeDelivered,
|
|
142
142
|
getActiveCompartmentRun
|
|
143
|
-
} from "./index-
|
|
143
|
+
} from "./index-hjnrp6vy.js";
|
|
144
144
|
import {
|
|
145
|
-
BoundedSessionMap,
|
|
146
145
|
cleanSearchText,
|
|
147
146
|
matchedSearchSnippet
|
|
148
|
-
} from "./index-
|
|
147
|
+
} from "./index-40ma8m0c.js";
|
|
149
148
|
import {
|
|
150
149
|
stripSystemInjection,
|
|
151
150
|
isTextPart,
|
|
@@ -243,7 +242,7 @@ import {
|
|
|
243
242
|
extractToolCallObservation,
|
|
244
243
|
ToolMutationBatch,
|
|
245
244
|
createToolDropTarget
|
|
246
|
-
} from "./index-
|
|
245
|
+
} from "./index-dn2ke3b9.js";
|
|
247
246
|
import {
|
|
248
247
|
isValidLanguageCode
|
|
249
248
|
} from "./index-nxrsns5x.js";
|
|
@@ -254,10 +253,13 @@ import {
|
|
|
254
253
|
openCodeDbExists,
|
|
255
254
|
withReadOnlySessionDb,
|
|
256
255
|
getMessageTimesFromOpenCodeDb
|
|
257
|
-
} from "./index-
|
|
256
|
+
} from "./index-j43m40zd.js";
|
|
257
|
+
import {
|
|
258
|
+
BoundedSessionMap
|
|
259
|
+
} from "./index-cfaet9cg.js";
|
|
258
260
|
import {
|
|
259
261
|
userFacingFailureCode
|
|
260
|
-
} from "./index-
|
|
262
|
+
} from "./index-mphkpyap.js";
|
|
261
263
|
import {
|
|
262
264
|
normalizeProtectedToolName,
|
|
263
265
|
mergeProtectedTools
|
|
@@ -3222,6 +3224,23 @@ function applyCompressedText(target, tagNumber, originalText, depth, state) {
|
|
|
3222
3224
|
target.setContent(`${target.textPrefix ?? ""}${compressed}`, { keepReasoning: true });
|
|
3223
3225
|
return target.getContent ? target.getContent() !== before : true;
|
|
3224
3226
|
}
|
|
3227
|
+
function cavemanReplayText(tagNumber, originalText, depth, state, textPrefix) {
|
|
3228
|
+
const level = DEPTH_TO_LEVEL[depth];
|
|
3229
|
+
if (!level)
|
|
3230
|
+
return null;
|
|
3231
|
+
let served = null;
|
|
3232
|
+
if (!state.currentRules || state.legacyReasoningTags.has(tagNumber)) {
|
|
3233
|
+
const legacy = cavemanCompress(originalText, level, "ascii-v1");
|
|
3234
|
+
if (legacy.length > 0)
|
|
3235
|
+
served = { text: legacy, dropsReasoning: true };
|
|
3236
|
+
if (!state.currentRules)
|
|
3237
|
+
return served;
|
|
3238
|
+
}
|
|
3239
|
+
const compressed = cavemanCompress(originalText, level, CURRENT_CAVEMAN_RULES, wordRulesFor(state));
|
|
3240
|
+
if (compressed.length === 0)
|
|
3241
|
+
return served;
|
|
3242
|
+
return { text: `${textPrefix}${compressed}`, dropsReasoning: served?.dropsReasoning ?? false };
|
|
3243
|
+
}
|
|
3225
3244
|
function replayCavemanCompression(sessionId, db, targets, tags) {
|
|
3226
3245
|
const compressedTags = tags.filter((tag) => tag.type === "message" && tag.status === "active" && tag.cavemanDepth > 0 && targets.has(tag.tagNumber));
|
|
3227
3246
|
if (compressedTags.length === 0)
|
|
@@ -4546,6 +4565,58 @@ function stripStructuralNoise(messages) {
|
|
|
4546
4565
|
}
|
|
4547
4566
|
return strippedParts;
|
|
4548
4567
|
}
|
|
4568
|
+
// src/hooks/magic-context/foreign-text-parts.ts
|
|
4569
|
+
function hasStringId(part) {
|
|
4570
|
+
return part !== null && typeof part === "object" && typeof part.id === "string";
|
|
4571
|
+
}
|
|
4572
|
+
function lastStoredPartIndex(parts) {
|
|
4573
|
+
for (let index = parts.length - 1;index >= 0; index -= 1) {
|
|
4574
|
+
if (hasStringId(parts[index]))
|
|
4575
|
+
return index;
|
|
4576
|
+
}
|
|
4577
|
+
return -1;
|
|
4578
|
+
}
|
|
4579
|
+
function collectForeignTextParts(messages) {
|
|
4580
|
+
let foreign;
|
|
4581
|
+
for (const message of messages) {
|
|
4582
|
+
if (typeof message.info.id !== "string")
|
|
4583
|
+
continue;
|
|
4584
|
+
if (!message.parts.some(hasStringId))
|
|
4585
|
+
continue;
|
|
4586
|
+
for (const part of message.parts) {
|
|
4587
|
+
if (isTextPart(part) && !hasStringId(part)) {
|
|
4588
|
+
foreign ??= new WeakSet;
|
|
4589
|
+
foreign.add(part);
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
return foreign;
|
|
4594
|
+
}
|
|
4595
|
+
var legacyForeignTextTags = new Map;
|
|
4596
|
+
function rememberLegacyForeignTextTags(sessionId, tagNumbers) {
|
|
4597
|
+
for (const tagNumber of tagNumbers) {
|
|
4598
|
+
let known = legacyForeignTextTags.get(sessionId);
|
|
4599
|
+
if (!known) {
|
|
4600
|
+
known = new Set;
|
|
4601
|
+
legacyForeignTextTags.set(sessionId, known);
|
|
4602
|
+
}
|
|
4603
|
+
known.add(tagNumber);
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
4606
|
+
function isLegacyForeignTextTag(sessionId, tagNumber) {
|
|
4607
|
+
return legacyForeignTextTags.get(sessionId)?.has(tagNumber) ?? false;
|
|
4608
|
+
}
|
|
4609
|
+
var pendingOpForTagStatements = new WeakMap;
|
|
4610
|
+
function discardPendingOpForForeignTag(db, sessionId, tagNumber) {
|
|
4611
|
+
let statement = pendingOpForTagStatements.get(db);
|
|
4612
|
+
if (!statement) {
|
|
4613
|
+
statement = db.prepare("SELECT 1 AS present FROM pending_ops WHERE session_id = ? AND tag_id = ? LIMIT 1");
|
|
4614
|
+
pendingOpForTagStatements.set(db, statement);
|
|
4615
|
+
}
|
|
4616
|
+
if (statement.get(sessionId, tagNumber))
|
|
4617
|
+
removePendingOp(db, sessionId, tagNumber);
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4549
4620
|
// src/hooks/magic-context/tag-id-fallback.ts
|
|
4550
4621
|
function parseScopedContentId(contentId) {
|
|
4551
4622
|
const match = /^(.*):(p|file)(\d+)$/.exec(contentId);
|
|
@@ -4737,6 +4808,62 @@ function deriveToolOwnerMessageId(sessionId, db, message, obs, unpaired, cache,
|
|
|
4737
4808
|
}
|
|
4738
4809
|
return obs.callId;
|
|
4739
4810
|
}
|
|
4811
|
+
function serveLegacyForeignText(legacy, current, options) {
|
|
4812
|
+
const prefixed = options.skipPrefixInjection ? current : prependTag(legacy.tagNumber, current);
|
|
4813
|
+
if (options.pastPartialEnd)
|
|
4814
|
+
return { text: prefixed, dropsReasoning: false };
|
|
4815
|
+
if (legacy.status === "dropped") {
|
|
4816
|
+
return { text: buildReplacementContent(legacy.tagNumber), dropsReasoning: true };
|
|
4817
|
+
}
|
|
4818
|
+
const unchanged = legacy.savedText !== undefined && stripTagPrefix(current) === legacy.savedText;
|
|
4819
|
+
if (legacy.status === "active" && legacy.cavemanDepth > 0 && options.caveman && unchanged && legacy.savedText) {
|
|
4820
|
+
const replayed = cavemanReplayText(legacy.tagNumber, legacy.savedText, legacy.cavemanDepth, options.caveman, options.skipPrefixInjection ? "" : prependTag(legacy.tagNumber, ""));
|
|
4821
|
+
if (replayed)
|
|
4822
|
+
return replayed;
|
|
4823
|
+
}
|
|
4824
|
+
return { text: prefixed, dropsReasoning: false };
|
|
4825
|
+
}
|
|
4826
|
+
function findLegacyForeignTextTags(sessionId, messages, assignments, db, isForeignTextPart, inertWhitespaceTagNumbers) {
|
|
4827
|
+
const legacy = new Map;
|
|
4828
|
+
for (const message of messages) {
|
|
4829
|
+
const messageId = typeof message.info.id === "string" ? message.info.id : null;
|
|
4830
|
+
if (!messageId)
|
|
4831
|
+
continue;
|
|
4832
|
+
const firstTrailingIndex = lastStoredPartIndex(message.parts) + 1;
|
|
4833
|
+
for (let partIndex = firstTrailingIndex;partIndex < message.parts.length; partIndex += 1) {
|
|
4834
|
+
const part = message.parts[partIndex];
|
|
4835
|
+
if (!isTextPart(part) || !isForeignTextPart(part))
|
|
4836
|
+
continue;
|
|
4837
|
+
const contentId = `${messageId}:p${partIndex}`;
|
|
4838
|
+
const tagNumber = assignments.get(contentId) ?? getTagNumberByMessageId2(db, sessionId, contentId);
|
|
4839
|
+
if (tagNumber === null || tagNumber === undefined)
|
|
4840
|
+
continue;
|
|
4841
|
+
if (inertWhitespaceTagNumbers.has(tagNumber))
|
|
4842
|
+
continue;
|
|
4843
|
+
const tag = getTagById2(db, sessionId, tagNumber);
|
|
4844
|
+
if (tag?.type !== "message")
|
|
4845
|
+
continue;
|
|
4846
|
+
legacy.set(part, {
|
|
4847
|
+
tagNumber,
|
|
4848
|
+
status: tag.status,
|
|
4849
|
+
cavemanDepth: tag.cavemanDepth
|
|
4850
|
+
});
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
if (legacy.size > 0) {
|
|
4854
|
+
const tagNumbers = [...legacy.values()].map((entry) => entry.tagNumber);
|
|
4855
|
+
rememberLegacyForeignTextTags(sessionId, tagNumbers);
|
|
4856
|
+
for (const tagNumber of tagNumbers)
|
|
4857
|
+
discardPendingOpForForeignTag(db, sessionId, tagNumber);
|
|
4858
|
+
const compressed = [...legacy.values()].filter((entry) => entry.status === "active" && entry.cavemanDepth > 0);
|
|
4859
|
+
if (compressed.length > 0) {
|
|
4860
|
+
const saved = getSourceContents(db, sessionId, compressed.map((entry) => entry.tagNumber));
|
|
4861
|
+
for (const entry of compressed)
|
|
4862
|
+
entry.savedText = saved.get(entry.tagNumber);
|
|
4863
|
+
}
|
|
4864
|
+
}
|
|
4865
|
+
return legacy;
|
|
4866
|
+
}
|
|
4740
4867
|
function collectRelevantSourceTagIds(messages, assignments) {
|
|
4741
4868
|
const currentMessageIds = new Set(messages.flatMap((message) => typeof message.info.id === "string" ? [message.info.id] : []));
|
|
4742
4869
|
const relevantTagIds = new Set;
|
|
@@ -4859,8 +4986,17 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4859
4986
|
logTransformTiming(sessionId, "tag.inertWhitespace", tInertWhitespace);
|
|
4860
4987
|
const assignments = tagger.getAssignments(sessionId);
|
|
4861
4988
|
const resolver = createExistingTagResolver(sessionId, tagger, db);
|
|
4989
|
+
const foreignTextParts = options.foreignTextParts;
|
|
4990
|
+
const isForeignTextPart = (part) => foreignTextParts !== undefined && part !== null && typeof part === "object" && foreignTextParts.has(part);
|
|
4991
|
+
const legacyForeignTags = findLegacyForeignTextTags(sessionId, messages, assignments, db, isForeignTextPart, inertWhitespaceTagNumbers);
|
|
4992
|
+
const legacyForeignTagNumbers = new Set([...legacyForeignTags.values()].map((legacy) => legacy.tagNumber));
|
|
4993
|
+
let cavemanState;
|
|
4994
|
+
const legacyCavemanState = () => {
|
|
4995
|
+
cavemanState ??= options.replaysCaveman ? getCavemanReplayState(db, sessionId) : null;
|
|
4996
|
+
return cavemanState;
|
|
4997
|
+
};
|
|
4862
4998
|
const tGetSourceContents = performance.now();
|
|
4863
|
-
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments));
|
|
4999
|
+
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments).filter((tagNumber) => !legacyForeignTagNumbers.has(tagNumber)));
|
|
4864
5000
|
logTransformTiming(sessionId, "tag.getSourceContents", tGetSourceContents);
|
|
4865
5001
|
let partialEndsCache;
|
|
4866
5002
|
const loadPartialEnds = () => {
|
|
@@ -4954,6 +5090,28 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4954
5090
|
}
|
|
4955
5091
|
ownerByPartKey.set(part, { ownerMsgId, callId: toolObservation.callId });
|
|
4956
5092
|
}
|
|
5093
|
+
if (messageId && isTextPart(part) && isForeignTextPart(part)) {
|
|
5094
|
+
const legacy = legacyForeignTags.get(part);
|
|
5095
|
+
if (legacy) {
|
|
5096
|
+
const partialEnd = getPartialEnds().get(messageId);
|
|
5097
|
+
const served = serveLegacyForeignText(legacy, part.text, {
|
|
5098
|
+
skipPrefixInjection,
|
|
5099
|
+
pastPartialEnd: partialEnd !== undefined && partIndex > partialEnd,
|
|
5100
|
+
caveman: legacy.cavemanDepth > 0 ? legacyCavemanState() : null
|
|
5101
|
+
});
|
|
5102
|
+
part.text = served.text;
|
|
5103
|
+
if (served.dropsReasoning) {
|
|
5104
|
+
for (const thinkingPart of messageThinkingParts) {
|
|
5105
|
+
if (protectedThinkingParts.has(thinkingPart))
|
|
5106
|
+
continue;
|
|
5107
|
+
if (partialEnd !== undefined && message.parts.indexOf(thinkingPart) > partialEnd)
|
|
5108
|
+
continue;
|
|
5109
|
+
neutralizeDroppedReasoningPart(thinkingPart);
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
continue;
|
|
5114
|
+
}
|
|
4957
5115
|
if (messageId && isTextPart(part)) {
|
|
4958
5116
|
const textPart = part;
|
|
4959
5117
|
const thinkingParts = messageThinkingParts;
|
|
@@ -4995,7 +5153,7 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4995
5153
|
}
|
|
4996
5154
|
} else {
|
|
4997
5155
|
existingTagId = resolver.resolve(messageId, "message", contentId, textOrdinal, {
|
|
4998
|
-
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber)
|
|
5156
|
+
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber) && !legacyForeignTagNumbers.has(tagNumber)
|
|
4999
5157
|
});
|
|
5000
5158
|
if (existingTagId === undefined && inertWhitespaceTagNumbers.has(tagger.getTag(sessionId, contentId, "message") ?? -1)) {
|
|
5001
5159
|
tagger.unbindTag(sessionId, contentId);
|
|
@@ -7423,4 +7581,4 @@ function checkM0MutationDriftAndSignal2(args) {
|
|
|
7423
7581
|
return false;
|
|
7424
7582
|
}
|
|
7425
7583
|
|
|
7426
|
-
export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, diagnosticStateChanged, clearDiagnosticLogState, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRidePermitted, reclaimRideLabel, pendingDropEligibilityKey, createPendingDropEligibilityCache, readExecuteReclaimState, writeExecuteReclaimState, maintainExecuteFloorMark, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, withTransformTimingSummary, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, servesThinkingBlock2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
|
|
7584
|
+
export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, diagnosticStateChanged, clearDiagnosticLogState, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRidePermitted, reclaimRideLabel, pendingDropEligibilityKey, createPendingDropEligibilityCache, readExecuteReclaimState, writeExecuteReclaimState, maintainExecuteFloorMark, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, collectForeignTextParts, isLegacyForeignTextTag, withTransformTimingSummary, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, servesThinkingBlock2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
countSessionCompartmentEmbedCoverage2,
|
|
42
42
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
43
43
|
countUnembeddedSessionCompartmentsPolite2
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-6tmf87w0.js";
|
|
45
45
|
import {
|
|
46
46
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
47
47
|
} from "./index-nxrsns5x.js";
|