@cortexkit/opencode-magic-context 0.49.25 → 0.49.27
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 +7 -7
- package/dist/{compartment-chunk-embedding-eypvn607.js → compartment-chunk-embedding-qgp0tbf7.js} +3 -3
- package/dist/config/schema/magic-context.d.ts +393 -393
- package/dist/{conflict-warning-hook-a27bhggg.js → conflict-warning-hook-tgnw019g.js} +4 -4
- package/dist/{context-keb00be8.js → context-t2k97d6v.js} +116 -116
- package/dist/{embedding-backfill-vddgmem3.js → embedding-backfill-cwnyr4fj.js} +5 -5
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +1 -4
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +1 -28
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/session-retention.fixture.d.ts +4 -0
- package/dist/features/magic-context/session-retention.fixture.d.ts.map +1 -0
- package/dist/features/magic-context/storage-session-tables.d.ts +5 -12
- package/dist/features/magic-context/storage-session-tables.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/compartment-trigger.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/historian-history-wait.d.ts +10 -0
- package/dist/hooks/magic-context/historian-history-wait.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +0 -5
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +0 -10
- package/dist/hooks/magic-context/raw-ordinal-warmup.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/tag-messages.d.ts +15 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +2 -2
- package/dist/hooks/magic-context/transform.d.ts +7 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-jcr6pe7z.js → index-077ht5cq.js} +1 -1
- package/dist/{index-ebsvmc5s.js → index-31y1mznz.js} +4 -4
- package/dist/{index-q7ywt6xt.js → index-4cpc59jv.js} +5 -5
- package/dist/{index-t6j3qxnd.js → index-4ypqzvhf.js} +1 -1
- package/dist/index-7gbcg8xv.js +559 -0
- package/dist/{index-9q1g3c5q.js → index-7kkphb6c.js} +1 -1
- package/dist/{index-bhyksfyy.js → index-89k1w6x2.js} +3 -3
- package/dist/{index-z05n7702.js → index-a2fz9hpa.js} +1 -1
- package/dist/{index-0s8454t2.js → index-dcqk0y27.js} +1560 -91
- package/dist/{index-n18sch77.js → index-dzfevacx.js} +9 -9
- package/dist/{index-axjgxeww.js → index-fq2p158w.js} +169 -13
- package/dist/{index-3d5wnkq7.js → index-mm93m7y6.js} +1 -1
- package/dist/{index-zzrzjnx5.js → index-n8qmmd7f.js} +3 -3
- package/dist/{index-whcgcfrv.js → index-np3rgfw4.js} +1 -1
- package/dist/{index-y6xpzjzr.js → index-qzbpbnqt.js} +585 -602
- package/dist/{index-7tdtpqrg.js → index-rverk2vz.js} +39 -8
- package/dist/{index-cfaet9cg.js → index-s1n8dd2n.js} +1 -1
- package/dist/{index-z928hmnp.js → index-t3rbb8wr.js} +2 -2
- package/dist/{index-2haxh8h3.js → index-tvzvjggy.js} +1 -1
- package/dist/{index-c9zrgcnt.js → index-v0dhhxsq.js} +1 -1
- package/dist/{index-szf8r0ba.js → index-v15ne3a3.js} +2 -5
- package/dist/{index-x9k3mqrf.js → index-xrnsygfq.js} +1 -1
- package/dist/{index-yrrsp47d.js → index-yzjhx10y.js} +20 -6
- package/dist/index.js +40 -38
- package/dist/{message-fts-rowid-map-9e1getgs.js → message-fts-rowid-map-va36knh4.js} +2 -4
- package/dist/{message-index-bounded-vaeqhp9w.js → message-index-bounded-7ayzb2ah.js} +22 -25
- package/dist/migration-worker.js +6 -6
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-rstzmb60.js → project-embedding-registry-94nncs5g.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +7 -30
- package/dist/{read-session-chunk-z5gnc0zb.js → read-session-chunk-jzb6w9w5.js} +8 -6
- package/dist/{read-session-raw-s4amywnh.js → read-session-raw-b2sd67v4.js} +3 -1
- package/dist/{recomp-orchestrator-qwqeskhq.js → recomp-orchestrator-02sa2ngr.js} +17 -17
- package/dist/{search-archive-mfabzyn2.js → search-archive-q1vw7zg4.js} +7 -7
- package/dist/{search-84zfqeky.js → search-spq6nfyf.js} +14 -15
- package/dist/{send-session-notification-ygj4mja0.js → send-session-notification-afzzqy5b.js} +3 -3
- package/dist/{storage-tags-a77q4v77.js → storage-tags-6hvkk01c.js} +2 -2
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-hr1ntmjj.js → transform-postprocess-phase-6menyyxc.js} +17 -17
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +7 -7
- package/dist/v2/{compartment-chunk-embedding-tk6g4q80.js → compartment-chunk-embedding-63dzs31c.js} +3 -3
- package/dist/v2/{context-y7wfvdve.js → context-na0esngr.js} +342 -218
- package/dist/v2/{embedding-backfill-w5qp7t28.js → embedding-backfill-rh5dgsva.js} +5 -5
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-pqk3a55v.js → message-fts-rowid-map-78awh03v.js} +2 -4
- package/dist/v2/{message-index-bounded-te303atj.js → message-index-bounded-n09b74vr.js} +21 -24
- package/dist/v2/migration-worker.js +6 -6
- package/dist/v2/{project-embedding-registry-e7zftfvj.js → project-embedding-registry-6pak822h.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +7 -30
- package/dist/v2/{read-session-chunk-knvkq1hf.js → read-session-chunk-vpt69tw9.js} +7 -5
- package/dist/v2/{read-session-raw-ppjxnqk4.js → read-session-raw-5x088amc.js} +3 -1
- package/dist/v2/{recomp-orchestrator-e8a4jpvr.js → recomp-orchestrator-txsmbnvw.js} +14 -14
- package/dist/v2/{search-archive-vrwgxv6z.js → search-archive-t9bcz4ht.js} +6 -6
- package/dist/v2/{search-hav4dggf.js → search-dcy9b6gd.js} +13 -14
- package/dist/v2/{send-session-notification-f8scq6ae.js → send-session-notification-vdsgnf4c.js} +1 -1
- package/dist/v2/{server-pw21ypwb.js → server-4sn3at8p.js} +1 -1
- package/dist/v2/{server-8j2e7t31.js → server-6avtp9jp.js} +1 -1
- package/dist/v2/{server-wwaw5npa.js → server-6g98c227.js} +1 -1
- package/dist/v2/{server-swvhxhxz.js → server-6vd2n183.js} +39 -8
- package/dist/v2/{server-wxrdher8.js → server-awr8qa4c.js} +2 -5
- package/dist/v2/{server-7d6m1p2b.js → server-cqjvxyrp.js} +1 -1
- package/dist/v2/{server-e75vag9d.js → server-e3hc93wk.js} +5 -5
- package/dist/v2/{server-7weh65vd.js → server-jj9qye8y.js} +1520 -79
- package/dist/v2/{server-fa7vtp40.js → server-nxas8v1d.js} +1 -1
- package/dist/v2/{server-tfawsj08.js → server-txbc3czn.js} +9 -9
- package/dist/v2/{server-rqebawx1.js → server-v77xa5wj.js} +1 -1
- package/dist/v2/{server-5brp2rfn.js → server-xkvxss5g.js} +19 -5
- package/dist/v2/{server-q5z0gag0.js → server-yqek3s4k.js} +1 -1
- package/dist/v2/server-z2n2xaeh.js +538 -0
- package/dist/v2/{server-9xbbaekh.js → server-z3mk9jdc.js} +2 -2
- package/dist/v2/{server-m6yyn961.js → server-zmcrvpm3.js} +2 -2
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-tags-q71rnr9f.js → storage-tags-18nbaanf.js} +2 -2
- package/dist/v2/store-reader.d.ts +0 -2
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-ycs8y6n4.js → wrapup-orchestrator-gjkszser.js} +14 -14
- package/dist/{wrapup-orchestrator-f642w8n3.js → wrapup-orchestrator-n5h5sr1x.js} +18 -18
- package/package.json +1 -1
- package/src/shared/write-transaction-attribution.test.ts +1 -6
- package/dist/index-awcftgmx.js +0 -2251
- package/dist/message-index-3g966xn7.js +0 -61
- package/dist/v2/message-index-fz6b4jeh.js +0 -60
- package/dist/v2/server-6a8pxpxg.js +0 -2220
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
loadCompartmentChunkEmbeddingsForSearch2,
|
|
25
25
|
peekCompartmentChunkSearchPool2,
|
|
26
26
|
warmCompartmentChunkSearchPool2
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-mm93m7y6.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-a2fz9hpa.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-4ypqzvhf.js";
|
|
54
54
|
import {
|
|
55
55
|
ModuleMemoryAuthorityError2,
|
|
56
56
|
getMemoriesByProject2,
|
|
@@ -65,27 +65,27 @@ import {
|
|
|
65
65
|
sanitizeFtsQuery,
|
|
66
66
|
searchMemoriesFTS,
|
|
67
67
|
searchMemoriesFTSUnion
|
|
68
|
-
} from "./index-
|
|
68
|
+
} from "./index-t3rbb8wr.js";
|
|
69
69
|
import {
|
|
70
70
|
cleanSearchText,
|
|
71
71
|
keywordRelevance,
|
|
72
72
|
matchedSearchSnippet,
|
|
73
|
-
|
|
74
|
-
} from "./index-
|
|
73
|
+
getIndexedMessageCorpusSize
|
|
74
|
+
} from "./index-7gbcg8xv.js";
|
|
75
75
|
import {
|
|
76
76
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
77
77
|
withMessageFtsSessionFilter
|
|
78
78
|
} from "./index-kaqs6h31.js";
|
|
79
79
|
import {
|
|
80
80
|
isRecord
|
|
81
|
-
} from "./index-
|
|
81
|
+
} from "./index-np3rgfw4.js";
|
|
82
82
|
import {
|
|
83
83
|
resolveWorkspaceShareCategories,
|
|
84
84
|
resolveWorkspaceIdentitySet,
|
|
85
85
|
expandWorkspaceIdentitySetWithAliases,
|
|
86
86
|
resolveStoredPathWorkspaceIdentity,
|
|
87
87
|
sourceNameForMemory
|
|
88
|
-
} from "./index-
|
|
88
|
+
} from "./index-7kkphb6c.js";
|
|
89
89
|
import {
|
|
90
90
|
isKnownAutocommit
|
|
91
91
|
} from "./index-8ajstryz.js";
|
|
@@ -2483,7 +2483,7 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2483
2483
|
return renderRows(args.limit);
|
|
2484
2484
|
}
|
|
2485
2485
|
const sanitizedProbes = probes.map((probe) => ({ probe, query: sanitizeFtsQuery(probe) })).filter((entry) => entry.query.length > 0);
|
|
2486
|
-
const corpusSize =
|
|
2486
|
+
const corpusSize = getIndexedMessageCorpusSize(args.db, args.sessionId, cutoff);
|
|
2487
2487
|
const probeCounts = countSessionFtsMatchesBatch(args.db, args.sessionId, sanitizedProbes.map((entry) => entry.query), cutoff, args.dateRange, sessionFirst);
|
|
2488
2488
|
const collectBaseDiagnostics = args.diagnostics !== undefined && cutoff !== null;
|
|
2489
2489
|
const baseOutcome = collectBaseDiagnostics && baseQuery.length > 0 ? runMessageFtsQueryWithDiagnostics({
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getTemporalDecisions,
|
|
8
8
|
freezeTemporalDecisions,
|
|
9
9
|
stableStringify
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-xrnsygfq.js";
|
|
11
11
|
import {
|
|
12
12
|
protectedToolTagNumbers,
|
|
13
13
|
stripPersistedAssistantText,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
adoptNullOwnerToolTag2,
|
|
75
75
|
getCandidateToolOwners2,
|
|
76
76
|
pickNearestPriorOwner2
|
|
77
|
-
} from "./index-
|
|
77
|
+
} from "./index-np3rgfw4.js";
|
|
78
78
|
import {
|
|
79
79
|
textMentionsRecentCommit,
|
|
80
80
|
hasMeaningfulUserText2,
|
|
@@ -98,13 +98,13 @@ import {
|
|
|
98
98
|
getProjectEmbeddingSnapshot2,
|
|
99
99
|
embedTextForProject2,
|
|
100
100
|
embedBatchForProject2
|
|
101
|
-
} from "./index-
|
|
101
|
+
} from "./index-a2fz9hpa.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-rverk2vz.js";
|
|
108
108
|
import {
|
|
109
109
|
getMaxM0MutationId,
|
|
110
110
|
getLastCompartmentEndMessage,
|
|
@@ -140,11 +140,11 @@ import {
|
|
|
140
140
|
peekNoteNudgeText,
|
|
141
141
|
markNoteNudgeDelivered,
|
|
142
142
|
getActiveCompartmentRun
|
|
143
|
-
} from "./index-
|
|
143
|
+
} from "./index-dcqk0y27.js";
|
|
144
144
|
import {
|
|
145
145
|
cleanSearchText,
|
|
146
146
|
matchedSearchSnippet
|
|
147
|
-
} from "./index-
|
|
147
|
+
} from "./index-7gbcg8xv.js";
|
|
148
148
|
import {
|
|
149
149
|
stripSystemInjection,
|
|
150
150
|
isTextPart,
|
|
@@ -242,7 +242,7 @@ import {
|
|
|
242
242
|
extractToolCallObservation,
|
|
243
243
|
ToolMutationBatch,
|
|
244
244
|
createToolDropTarget
|
|
245
|
-
} from "./index-
|
|
245
|
+
} from "./index-yzjhx10y.js";
|
|
246
246
|
import {
|
|
247
247
|
isValidLanguageCode
|
|
248
248
|
} from "./index-nxrsns5x.js";
|
|
@@ -253,13 +253,13 @@ import {
|
|
|
253
253
|
openCodeDbExists,
|
|
254
254
|
withReadOnlySessionDb,
|
|
255
255
|
getMessageTimesFromOpenCodeDb
|
|
256
|
-
} from "./index-
|
|
256
|
+
} from "./index-v0dhhxsq.js";
|
|
257
257
|
import {
|
|
258
258
|
BoundedSessionMap
|
|
259
|
-
} from "./index-
|
|
259
|
+
} from "./index-s1n8dd2n.js";
|
|
260
260
|
import {
|
|
261
261
|
userFacingFailureCode
|
|
262
|
-
} from "./index-
|
|
262
|
+
} from "./index-t3rbb8wr.js";
|
|
263
263
|
import {
|
|
264
264
|
normalizeProtectedToolName,
|
|
265
265
|
mergeProtectedTools
|
|
@@ -3224,6 +3224,23 @@ function applyCompressedText(target, tagNumber, originalText, depth, state) {
|
|
|
3224
3224
|
target.setContent(`${target.textPrefix ?? ""}${compressed}`, { keepReasoning: true });
|
|
3225
3225
|
return target.getContent ? target.getContent() !== before : true;
|
|
3226
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
|
+
}
|
|
3227
3244
|
function replayCavemanCompression(sessionId, db, targets, tags) {
|
|
3228
3245
|
const compressedTags = tags.filter((tag) => tag.type === "message" && tag.status === "active" && tag.cavemanDepth > 0 && targets.has(tag.tagNumber));
|
|
3229
3246
|
if (compressedTags.length === 0)
|
|
@@ -4548,6 +4565,58 @@ function stripStructuralNoise(messages) {
|
|
|
4548
4565
|
}
|
|
4549
4566
|
return strippedParts;
|
|
4550
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
|
+
|
|
4551
4620
|
// src/hooks/magic-context/tag-id-fallback.ts
|
|
4552
4621
|
function parseScopedContentId(contentId) {
|
|
4553
4622
|
const match = /^(.*):(p|file)(\d+)$/.exec(contentId);
|
|
@@ -4739,6 +4808,62 @@ function deriveToolOwnerMessageId(sessionId, db, message, obs, unpaired, cache,
|
|
|
4739
4808
|
}
|
|
4740
4809
|
return obs.callId;
|
|
4741
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
|
+
}
|
|
4742
4867
|
function collectRelevantSourceTagIds(messages, assignments) {
|
|
4743
4868
|
const currentMessageIds = new Set(messages.flatMap((message) => typeof message.info.id === "string" ? [message.info.id] : []));
|
|
4744
4869
|
const relevantTagIds = new Set;
|
|
@@ -4861,8 +4986,17 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4861
4986
|
logTransformTiming(sessionId, "tag.inertWhitespace", tInertWhitespace);
|
|
4862
4987
|
const assignments = tagger.getAssignments(sessionId);
|
|
4863
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
|
+
};
|
|
4864
4998
|
const tGetSourceContents = performance.now();
|
|
4865
|
-
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments));
|
|
4999
|
+
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments).filter((tagNumber) => !legacyForeignTagNumbers.has(tagNumber)));
|
|
4866
5000
|
logTransformTiming(sessionId, "tag.getSourceContents", tGetSourceContents);
|
|
4867
5001
|
let partialEndsCache;
|
|
4868
5002
|
const loadPartialEnds = () => {
|
|
@@ -4956,6 +5090,28 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4956
5090
|
}
|
|
4957
5091
|
ownerByPartKey.set(part, { ownerMsgId, callId: toolObservation.callId });
|
|
4958
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
|
+
}
|
|
4959
5115
|
if (messageId && isTextPart(part)) {
|
|
4960
5116
|
const textPart = part;
|
|
4961
5117
|
const thinkingParts = messageThinkingParts;
|
|
@@ -4997,7 +5153,7 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4997
5153
|
}
|
|
4998
5154
|
} else {
|
|
4999
5155
|
existingTagId = resolver.resolve(messageId, "message", contentId, textOrdinal, {
|
|
5000
|
-
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber)
|
|
5156
|
+
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber) && !legacyForeignTagNumbers.has(tagNumber)
|
|
5001
5157
|
});
|
|
5002
5158
|
if (existingTagId === undefined && inertWhitespaceTagNumbers.has(tagger.getTag(sessionId, contentId, "message") ?? -1)) {
|
|
5003
5159
|
tagger.unbindTag(sessionId, contentId);
|
|
@@ -7425,4 +7581,4 @@ function checkM0MutationDriftAndSignal2(args) {
|
|
|
7425
7581
|
return false;
|
|
7426
7582
|
}
|
|
7427
7583
|
|
|
7428
|
-
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 };
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./index-wfybj1dw.js";
|
|
14
14
|
import {
|
|
15
15
|
messageFtsOrdinalRangeIsMapped2
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-v15ne3a3.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
} from "./index-h7tgn49j.js";
|
|
4
4
|
import {
|
|
5
5
|
clearEmergencyRecovery
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-yzjhx10y.js";
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot,
|
|
10
10
|
executeContextRecomp
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-dcqk0y27.js";
|
|
12
12
|
import {
|
|
13
13
|
renderUserFacingFailure,
|
|
14
14
|
userFacingFailureCode
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-t3rbb8wr.js";
|
|
16
16
|
|
|
17
17
|
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
18
18
|
function resolveLiveModelKey(liveSessionState, sessionId) {
|