@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
|
@@ -286,7 +286,7 @@ import {
|
|
|
286
286
|
startCompartmentAgent,
|
|
287
287
|
setRecompStarting2,
|
|
288
288
|
setRecompTerminal2
|
|
289
|
-
} from "./server-
|
|
289
|
+
} from "./server-9zh78t8y.js";
|
|
290
290
|
import {
|
|
291
291
|
resolveHistorianModel2
|
|
292
292
|
} from "./server-5kym00ag.js";
|
|
@@ -311,7 +311,7 @@ import {
|
|
|
311
311
|
openDatabaseAsync,
|
|
312
312
|
isDatabasePersisted,
|
|
313
313
|
getDatabasePersistenceError
|
|
314
|
-
} from "./server-
|
|
314
|
+
} from "./server-317f3x9y.js";
|
|
315
315
|
import {
|
|
316
316
|
pruneMissingProjectIdentities,
|
|
317
317
|
setHomeProjectPermission,
|
|
@@ -337,7 +337,6 @@ import {
|
|
|
337
337
|
inspectProcessesAsync
|
|
338
338
|
} from "./server-k3t06fxr.js";
|
|
339
339
|
import {
|
|
340
|
-
BoundedSessionMap,
|
|
341
340
|
LkgRecoveryFenceError,
|
|
342
341
|
lkgServedArrayDigest,
|
|
343
342
|
takeLkgRecoveryLockSweepPage,
|
|
@@ -362,7 +361,7 @@ import {
|
|
|
362
361
|
clearIndexedMessages2,
|
|
363
362
|
indexMessagesAfterOrdinal2,
|
|
364
363
|
sweepOrphanedOpenCodeMessageIndexesCooperatively2
|
|
365
|
-
} from "./server-
|
|
364
|
+
} from "./server-k46ec388.js";
|
|
366
365
|
import"./server-51779zs2.js";
|
|
367
366
|
import {
|
|
368
367
|
inRootAsyncContext2,
|
|
@@ -388,7 +387,7 @@ import {
|
|
|
388
387
|
buildInMemoryTailRawMessages2,
|
|
389
388
|
RawOrdinalsNotReady2,
|
|
390
389
|
runSessionWarmupWorker
|
|
391
|
-
} from "./server-
|
|
390
|
+
} from "./server-erk2bvdf.js";
|
|
392
391
|
import {
|
|
393
392
|
resolveOpenCodeDbPath,
|
|
394
393
|
assertOpenCodeStoreGeneration,
|
|
@@ -717,13 +716,14 @@ import {
|
|
|
717
716
|
readRawSessionMessageById2,
|
|
718
717
|
readSessionChunk2,
|
|
719
718
|
readRawSessionSeedTail2
|
|
720
|
-
} from "./server-
|
|
719
|
+
} from "./server-jcsw05aa.js";
|
|
721
720
|
import {
|
|
721
|
+
BoundedSessionMap,
|
|
722
|
+
recordToolDefinitionSet,
|
|
722
723
|
getCurrentToolSetHash,
|
|
723
|
-
recordToolDefinition,
|
|
724
724
|
getMeasuredToolDefinitionTokens
|
|
725
|
-
} from "./server-
|
|
726
|
-
import"./server-
|
|
725
|
+
} from "./server-7d6m1p2b.js";
|
|
726
|
+
import"./server-4frtg2z1.js";
|
|
727
727
|
import {
|
|
728
728
|
SubcClient,
|
|
729
729
|
connectionFileExists,
|
|
@@ -734,7 +734,7 @@ import {
|
|
|
734
734
|
} from "./server-ab1g0wn9.js";
|
|
735
735
|
import {
|
|
736
736
|
deleteChunkEmbedBackoffForSession2
|
|
737
|
-
} from "./server-
|
|
737
|
+
} from "./server-7dpnt0ys.js";
|
|
738
738
|
import {
|
|
739
739
|
embedPauseBySession,
|
|
740
740
|
embedRunStateBySession,
|
|
@@ -764,7 +764,7 @@ import {
|
|
|
764
764
|
embedSessionCompartmentChunks2,
|
|
765
765
|
getEmbeddingCoverageStatus2,
|
|
766
766
|
getAutoEmbeddingSessionCoverage2
|
|
767
|
-
} from "./server-
|
|
767
|
+
} from "./server-hnmm8yzq.js";
|
|
768
768
|
import {
|
|
769
769
|
V2_MEMORY_CATEGORIES,
|
|
770
770
|
CATEGORY_PRIORITY
|
|
@@ -823,7 +823,7 @@ import {
|
|
|
823
823
|
readGitFileChangeTimesSince,
|
|
824
824
|
verificationFileExists,
|
|
825
825
|
normalizeVerificationFiles
|
|
826
|
-
} from "./server-
|
|
826
|
+
} from "./server-nmwhe524.js";
|
|
827
827
|
import {
|
|
828
828
|
deriveTriggerBudget2,
|
|
829
829
|
deriveHistorianChunkTokens2,
|
|
@@ -857,7 +857,7 @@ import {
|
|
|
857
857
|
} from "./server-vr4szghm.js";
|
|
858
858
|
import {
|
|
859
859
|
cosineSimilarity
|
|
860
|
-
} from "./server-
|
|
860
|
+
} from "./server-wj8h2q21.js";
|
|
861
861
|
import {
|
|
862
862
|
computeCueContentHash,
|
|
863
863
|
hasMuralCueColumns,
|
|
@@ -914,14 +914,14 @@ import {
|
|
|
914
914
|
resolveMemoriesByIdsForSearch2,
|
|
915
915
|
unifiedSearch2,
|
|
916
916
|
formatSearchResults2
|
|
917
|
-
} from "./server-
|
|
917
|
+
} from "./server-vjer2jdn.js";
|
|
918
918
|
import {
|
|
919
919
|
resolvePromptContext2
|
|
920
920
|
} from "./server-fmsr7v69.js";
|
|
921
921
|
import"./server-kaqs6h31.js";
|
|
922
922
|
import {
|
|
923
923
|
renderSearchArchiveOffThread2
|
|
924
|
-
} from "./server-
|
|
924
|
+
} from "./server-w7x9wgm0.js";
|
|
925
925
|
import {
|
|
926
926
|
compareSemverCore
|
|
927
927
|
} from "./server-84w6rvvf.js";
|
|
@@ -7448,7 +7448,8 @@ function measureLkgReplayRequest(args) {
|
|
|
7448
7448
|
systemPromptTokens: args.systemPromptTokens,
|
|
7449
7449
|
providerID: args.model?.providerID,
|
|
7450
7450
|
modelID: args.model?.modelID,
|
|
7451
|
-
agentName: args.agentName
|
|
7451
|
+
agentName: args.agentName,
|
|
7452
|
+
sessionId: args.sessionId
|
|
7452
7453
|
})
|
|
7453
7454
|
});
|
|
7454
7455
|
}
|
|
@@ -8288,6 +8289,23 @@ function applyCompressedText(target, tagNumber, originalText, depth, state) {
|
|
|
8288
8289
|
target.setContent(`${target.textPrefix ?? ""}${compressed}`, { keepReasoning: true });
|
|
8289
8290
|
return target.getContent ? target.getContent() !== before : true;
|
|
8290
8291
|
}
|
|
8292
|
+
function cavemanReplayText(tagNumber, originalText, depth, state, textPrefix) {
|
|
8293
|
+
const level = DEPTH_TO_LEVEL[depth];
|
|
8294
|
+
if (!level)
|
|
8295
|
+
return null;
|
|
8296
|
+
let served = null;
|
|
8297
|
+
if (!state.currentRules || state.legacyReasoningTags.has(tagNumber)) {
|
|
8298
|
+
const legacy = cavemanCompress(originalText, level, "ascii-v1");
|
|
8299
|
+
if (legacy.length > 0)
|
|
8300
|
+
served = { text: legacy, dropsReasoning: true };
|
|
8301
|
+
if (!state.currentRules)
|
|
8302
|
+
return served;
|
|
8303
|
+
}
|
|
8304
|
+
const compressed = cavemanCompress(originalText, level, CURRENT_CAVEMAN_RULES, wordRulesFor(state));
|
|
8305
|
+
if (compressed.length === 0)
|
|
8306
|
+
return served;
|
|
8307
|
+
return { text: `${textPrefix}${compressed}`, dropsReasoning: served?.dropsReasoning ?? false };
|
|
8308
|
+
}
|
|
8291
8309
|
function replayCavemanCompression(sessionId, db, targets, tags) {
|
|
8292
8310
|
const compressedTags = tags.filter((tag) => tag.type === "message" && tag.status === "active" && tag.cavemanDepth > 0 && targets.has(tag.tagNumber));
|
|
8293
8311
|
if (compressedTags.length === 0)
|
|
@@ -8996,6 +9014,42 @@ function stripStructuralNoise(messages) {
|
|
|
8996
9014
|
}
|
|
8997
9015
|
return strippedParts;
|
|
8998
9016
|
}
|
|
9017
|
+
// src/hooks/magic-context/foreign-text-parts.ts
|
|
9018
|
+
function hasStringId(part) {
|
|
9019
|
+
return part !== null && typeof part === "object" && typeof part.id === "string";
|
|
9020
|
+
}
|
|
9021
|
+
function lastStoredPartIndex(parts) {
|
|
9022
|
+
for (let index = parts.length - 1;index >= 0; index -= 1) {
|
|
9023
|
+
if (hasStringId(parts[index]))
|
|
9024
|
+
return index;
|
|
9025
|
+
}
|
|
9026
|
+
return -1;
|
|
9027
|
+
}
|
|
9028
|
+
var legacyForeignTextTags = new Map;
|
|
9029
|
+
function rememberLegacyForeignTextTags(sessionId, tagNumbers) {
|
|
9030
|
+
for (const tagNumber of tagNumbers) {
|
|
9031
|
+
let known = legacyForeignTextTags.get(sessionId);
|
|
9032
|
+
if (!known) {
|
|
9033
|
+
known = new Set;
|
|
9034
|
+
legacyForeignTextTags.set(sessionId, known);
|
|
9035
|
+
}
|
|
9036
|
+
known.add(tagNumber);
|
|
9037
|
+
}
|
|
9038
|
+
}
|
|
9039
|
+
function isLegacyForeignTextTag(sessionId, tagNumber) {
|
|
9040
|
+
return legacyForeignTextTags.get(sessionId)?.has(tagNumber) ?? false;
|
|
9041
|
+
}
|
|
9042
|
+
var pendingOpForTagStatements = new WeakMap;
|
|
9043
|
+
function discardPendingOpForForeignTag(db, sessionId, tagNumber) {
|
|
9044
|
+
let statement = pendingOpForTagStatements.get(db);
|
|
9045
|
+
if (!statement) {
|
|
9046
|
+
statement = db.prepare("SELECT 1 AS present FROM pending_ops WHERE session_id = ? AND tag_id = ? LIMIT 1");
|
|
9047
|
+
pendingOpForTagStatements.set(db, statement);
|
|
9048
|
+
}
|
|
9049
|
+
if (statement.get(sessionId, tagNumber))
|
|
9050
|
+
removePendingOp(db, sessionId, tagNumber);
|
|
9051
|
+
}
|
|
9052
|
+
|
|
8999
9053
|
// src/hooks/magic-context/tag-id-fallback.ts
|
|
9000
9054
|
function parseScopedContentId(contentId) {
|
|
9001
9055
|
const match = /^(.*):(p|file)(\d+)$/.exec(contentId);
|
|
@@ -9187,6 +9241,62 @@ function deriveToolOwnerMessageId(sessionId, db, message, obs, unpaired, cache,
|
|
|
9187
9241
|
}
|
|
9188
9242
|
return obs.callId;
|
|
9189
9243
|
}
|
|
9244
|
+
function serveLegacyForeignText(legacy, current, options) {
|
|
9245
|
+
const prefixed = options.skipPrefixInjection ? current : prependTag(legacy.tagNumber, current);
|
|
9246
|
+
if (options.pastPartialEnd)
|
|
9247
|
+
return { text: prefixed, dropsReasoning: false };
|
|
9248
|
+
if (legacy.status === "dropped") {
|
|
9249
|
+
return { text: buildReplacementContent(legacy.tagNumber), dropsReasoning: true };
|
|
9250
|
+
}
|
|
9251
|
+
const unchanged = legacy.savedText !== undefined && stripTagPrefix(current) === legacy.savedText;
|
|
9252
|
+
if (legacy.status === "active" && legacy.cavemanDepth > 0 && options.caveman && unchanged && legacy.savedText) {
|
|
9253
|
+
const replayed = cavemanReplayText(legacy.tagNumber, legacy.savedText, legacy.cavemanDepth, options.caveman, options.skipPrefixInjection ? "" : prependTag(legacy.tagNumber, ""));
|
|
9254
|
+
if (replayed)
|
|
9255
|
+
return replayed;
|
|
9256
|
+
}
|
|
9257
|
+
return { text: prefixed, dropsReasoning: false };
|
|
9258
|
+
}
|
|
9259
|
+
function findLegacyForeignTextTags(sessionId, messages, assignments, db, isForeignTextPart, inertWhitespaceTagNumbers) {
|
|
9260
|
+
const legacy = new Map;
|
|
9261
|
+
for (const message of messages) {
|
|
9262
|
+
const messageId = typeof message.info.id === "string" ? message.info.id : null;
|
|
9263
|
+
if (!messageId)
|
|
9264
|
+
continue;
|
|
9265
|
+
const firstTrailingIndex = lastStoredPartIndex(message.parts) + 1;
|
|
9266
|
+
for (let partIndex = firstTrailingIndex;partIndex < message.parts.length; partIndex += 1) {
|
|
9267
|
+
const part = message.parts[partIndex];
|
|
9268
|
+
if (!isTextPart(part) || !isForeignTextPart(part))
|
|
9269
|
+
continue;
|
|
9270
|
+
const contentId = `${messageId}:p${partIndex}`;
|
|
9271
|
+
const tagNumber = assignments.get(contentId) ?? getTagNumberByMessageId2(db, sessionId, contentId);
|
|
9272
|
+
if (tagNumber === null || tagNumber === undefined)
|
|
9273
|
+
continue;
|
|
9274
|
+
if (inertWhitespaceTagNumbers.has(tagNumber))
|
|
9275
|
+
continue;
|
|
9276
|
+
const tag = getTagById2(db, sessionId, tagNumber);
|
|
9277
|
+
if (tag?.type !== "message")
|
|
9278
|
+
continue;
|
|
9279
|
+
legacy.set(part, {
|
|
9280
|
+
tagNumber,
|
|
9281
|
+
status: tag.status,
|
|
9282
|
+
cavemanDepth: tag.cavemanDepth
|
|
9283
|
+
});
|
|
9284
|
+
}
|
|
9285
|
+
}
|
|
9286
|
+
if (legacy.size > 0) {
|
|
9287
|
+
const tagNumbers = [...legacy.values()].map((entry) => entry.tagNumber);
|
|
9288
|
+
rememberLegacyForeignTextTags(sessionId, tagNumbers);
|
|
9289
|
+
for (const tagNumber of tagNumbers)
|
|
9290
|
+
discardPendingOpForForeignTag(db, sessionId, tagNumber);
|
|
9291
|
+
const compressed = [...legacy.values()].filter((entry) => entry.status === "active" && entry.cavemanDepth > 0);
|
|
9292
|
+
if (compressed.length > 0) {
|
|
9293
|
+
const saved = getSourceContents(db, sessionId, compressed.map((entry) => entry.tagNumber));
|
|
9294
|
+
for (const entry of compressed)
|
|
9295
|
+
entry.savedText = saved.get(entry.tagNumber);
|
|
9296
|
+
}
|
|
9297
|
+
}
|
|
9298
|
+
return legacy;
|
|
9299
|
+
}
|
|
9190
9300
|
function collectRelevantSourceTagIds(messages, assignments) {
|
|
9191
9301
|
const currentMessageIds = new Set(messages.flatMap((message) => typeof message.info.id === "string" ? [message.info.id] : []));
|
|
9192
9302
|
const relevantTagIds = new Set;
|
|
@@ -9309,8 +9419,17 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9309
9419
|
logTransformTiming(sessionId, "tag.inertWhitespace", tInertWhitespace);
|
|
9310
9420
|
const assignments = tagger.getAssignments(sessionId);
|
|
9311
9421
|
const resolver = createExistingTagResolver(sessionId, tagger, db);
|
|
9422
|
+
const foreignTextParts = options.foreignTextParts;
|
|
9423
|
+
const isForeignTextPart = (part) => foreignTextParts !== undefined && part !== null && typeof part === "object" && foreignTextParts.has(part);
|
|
9424
|
+
const legacyForeignTags = findLegacyForeignTextTags(sessionId, messages, assignments, db, isForeignTextPart, inertWhitespaceTagNumbers);
|
|
9425
|
+
const legacyForeignTagNumbers = new Set([...legacyForeignTags.values()].map((legacy) => legacy.tagNumber));
|
|
9426
|
+
let cavemanState;
|
|
9427
|
+
const legacyCavemanState = () => {
|
|
9428
|
+
cavemanState ??= options.replaysCaveman ? getCavemanReplayState(db, sessionId) : null;
|
|
9429
|
+
return cavemanState;
|
|
9430
|
+
};
|
|
9312
9431
|
const tGetSourceContents = performance.now();
|
|
9313
|
-
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments));
|
|
9432
|
+
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments).filter((tagNumber) => !legacyForeignTagNumbers.has(tagNumber)));
|
|
9314
9433
|
logTransformTiming(sessionId, "tag.getSourceContents", tGetSourceContents);
|
|
9315
9434
|
let partialEndsCache;
|
|
9316
9435
|
const loadPartialEnds = () => {
|
|
@@ -9404,6 +9523,28 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9404
9523
|
}
|
|
9405
9524
|
ownerByPartKey.set(part, { ownerMsgId, callId: toolObservation.callId });
|
|
9406
9525
|
}
|
|
9526
|
+
if (messageId && isTextPart(part) && isForeignTextPart(part)) {
|
|
9527
|
+
const legacy = legacyForeignTags.get(part);
|
|
9528
|
+
if (legacy) {
|
|
9529
|
+
const partialEnd = getPartialEnds().get(messageId);
|
|
9530
|
+
const served = serveLegacyForeignText(legacy, part.text, {
|
|
9531
|
+
skipPrefixInjection,
|
|
9532
|
+
pastPartialEnd: partialEnd !== undefined && partIndex > partialEnd,
|
|
9533
|
+
caveman: legacy.cavemanDepth > 0 ? legacyCavemanState() : null
|
|
9534
|
+
});
|
|
9535
|
+
part.text = served.text;
|
|
9536
|
+
if (served.dropsReasoning) {
|
|
9537
|
+
for (const thinkingPart of messageThinkingParts) {
|
|
9538
|
+
if (protectedThinkingParts.has(thinkingPart))
|
|
9539
|
+
continue;
|
|
9540
|
+
if (partialEnd !== undefined && message.parts.indexOf(thinkingPart) > partialEnd)
|
|
9541
|
+
continue;
|
|
9542
|
+
neutralizeDroppedReasoningPart(thinkingPart);
|
|
9543
|
+
}
|
|
9544
|
+
}
|
|
9545
|
+
}
|
|
9546
|
+
continue;
|
|
9547
|
+
}
|
|
9407
9548
|
if (messageId && isTextPart(part)) {
|
|
9408
9549
|
const textPart = part;
|
|
9409
9550
|
const thinkingParts = messageThinkingParts;
|
|
@@ -9445,7 +9586,7 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9445
9586
|
}
|
|
9446
9587
|
} else {
|
|
9447
9588
|
existingTagId = resolver.resolve(messageId, "message", contentId, textOrdinal, {
|
|
9448
|
-
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber)
|
|
9589
|
+
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber) && !legacyForeignTagNumbers.has(tagNumber)
|
|
9449
9590
|
});
|
|
9450
9591
|
if (existingTagId === undefined && inertWhitespaceTagNumbers.has(tagger.getTag(sessionId, contentId, "message") ?? -1)) {
|
|
9451
9592
|
tagger.unbindTag(sessionId, contentId);
|
|
@@ -16920,7 +17061,8 @@ function createRustModeTransform(deps, options) {
|
|
|
16920
17061
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
16921
17062
|
providerID: model?.providerID,
|
|
16922
17063
|
modelID: model?.modelID,
|
|
16923
|
-
agentName: deps.getNotificationParams?.(sessionId)?.agent
|
|
17064
|
+
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
17065
|
+
sessionId
|
|
16924
17066
|
})
|
|
16925
17067
|
});
|
|
16926
17068
|
if (measure.fit !== "under") {
|
|
@@ -17491,7 +17633,8 @@ function createRustModeTransform(deps, options) {
|
|
|
17491
17633
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
17492
17634
|
providerID: model?.providerID,
|
|
17493
17635
|
modelID: model?.modelID,
|
|
17494
|
-
agentName: deps.getNotificationParams?.(sessionId)?.agent
|
|
17636
|
+
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
17637
|
+
sessionId
|
|
17495
17638
|
}) : undefined;
|
|
17496
17639
|
const renderIdentityFields = {
|
|
17497
17640
|
modelKey: modelKey ?? null,
|
|
@@ -18023,6 +18166,7 @@ function createRustModeTransform(deps, options) {
|
|
|
18023
18166
|
providerID: model?.providerID,
|
|
18024
18167
|
modelID: model?.modelID,
|
|
18025
18168
|
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
18169
|
+
sessionId,
|
|
18026
18170
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
18027
18171
|
}, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit);
|
|
18028
18172
|
const refusal = outgoingContextRefusal(servedFinalWireEstimate, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit, protectedToolTokenCount(getActiveTagsBySession2(deps.db, sessionId), deps.protectedTools, resolveDecisionCalibration(model?.providerID, model?.modelID))) ?? (signedThinkingReset ? signedTurnContextRefusal(servedFinalWireEstimate, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit) : undefined);
|
|
@@ -18258,6 +18402,7 @@ function createRustModeTransform(deps, options) {
|
|
|
18258
18402
|
providerID: model?.providerID,
|
|
18259
18403
|
modelID: model?.modelID,
|
|
18260
18404
|
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
18405
|
+
sessionId,
|
|
18261
18406
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
18262
18407
|
});
|
|
18263
18408
|
captureOpencodeReasoningBudgetStatus(sessionId, output.messages, resolveKeepReasoningTokens(deps.keepReasoningTokens, modelKey ?? undefined), isPrefixBoundThinkingModel(model?.providerID, model?.modelID));
|
|
@@ -18521,6 +18666,27 @@ function createRustModeTransform(deps, options) {
|
|
|
18521
18666
|
return adapter;
|
|
18522
18667
|
}
|
|
18523
18668
|
|
|
18669
|
+
// src/hooks/magic-context/signed-thinking-fit-snapshot.ts
|
|
18670
|
+
function takeSignedThinkingFitSnapshot(args) {
|
|
18671
|
+
let snapshot = null;
|
|
18672
|
+
if (args.held && !args.compactionOff) {
|
|
18673
|
+
try {
|
|
18674
|
+
snapshot = cloneKeepingCoveredInstructionMarks(args.entryOrder);
|
|
18675
|
+
} catch (error) {
|
|
18676
|
+
sessionLog2(args.sessionId, `signed thinking fit: could not copy the pass input (${error instanceof Error ? error.message : String(error)}); an over-window held request will be refused rather than retried`);
|
|
18677
|
+
}
|
|
18678
|
+
}
|
|
18679
|
+
snapshotObserver?.({
|
|
18680
|
+
sessionId: args.sessionId,
|
|
18681
|
+
held: args.held,
|
|
18682
|
+
activeAnthropicThinkingTurn: args.activeAnthropicThinkingTurn,
|
|
18683
|
+
compactionOff: args.compactionOff,
|
|
18684
|
+
snapshot
|
|
18685
|
+
});
|
|
18686
|
+
return snapshot;
|
|
18687
|
+
}
|
|
18688
|
+
var snapshotObserver;
|
|
18689
|
+
|
|
18524
18690
|
// src/hooks/magic-context/signed-thinking-hold.ts
|
|
18525
18691
|
var HEAVY_REASONING_TOKENS = 1500;
|
|
18526
18692
|
var HEAVY_REASONING_WINDOW_STEPS = 15;
|
|
@@ -19132,7 +19298,8 @@ function createTransform(deps) {
|
|
|
19132
19298
|
const startTime = performance.now();
|
|
19133
19299
|
const historianRun = deps.resolveHistorianRun?.();
|
|
19134
19300
|
const messages = output.messages;
|
|
19135
|
-
const
|
|
19301
|
+
const foreignTextParts = deps.transformMode === "rust" ? undefined : deps.collectForeignTextParts?.(messages);
|
|
19302
|
+
const entryOrderForThinkingFit = messages.slice();
|
|
19136
19303
|
const coveredHostInstructions = takeCoveredInstructionRows(messages);
|
|
19137
19304
|
const passOutcome = createPassOutcome();
|
|
19138
19305
|
const tSessionId = performance.now();
|
|
@@ -19486,7 +19653,8 @@ function createTransform(deps) {
|
|
|
19486
19653
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
19487
19654
|
providerID: modelForBudget?.providerID,
|
|
19488
19655
|
modelID: modelForBudget?.modelID,
|
|
19489
|
-
agentName: runNotificationParams(sessionId)?.agent
|
|
19656
|
+
agentName: runNotificationParams(sessionId)?.agent,
|
|
19657
|
+
sessionId
|
|
19490
19658
|
});
|
|
19491
19659
|
const incomingTokens = incoming.messageTokens.conversation + incoming.messageTokens.toolCall;
|
|
19492
19660
|
if (unmanagedOverWindowCarried || isClearlyOverWindow(incomingTokens, resolvedContextLimit)) {
|
|
@@ -19532,6 +19700,13 @@ function createTransform(deps) {
|
|
|
19532
19700
|
}) : null;
|
|
19533
19701
|
activeThinkingPrefixHold = signedThinkingPrefixBound && (compactionOff || signedThinkingHold?.held === true);
|
|
19534
19702
|
freezeM0M1 ||= activeThinkingPrefixHold;
|
|
19703
|
+
const originalForThinkingFit = takeSignedThinkingFitSnapshot({
|
|
19704
|
+
sessionId,
|
|
19705
|
+
entryOrder: entryOrderForThinkingFit,
|
|
19706
|
+
held: activeThinkingPrefixHold,
|
|
19707
|
+
activeAnthropicThinkingTurn: activeThinkingTurn,
|
|
19708
|
+
compactionOff
|
|
19709
|
+
});
|
|
19535
19710
|
const prefixHoldLogKey = signedThinkingHold ? `${currentTurnId}:${signedThinkingHold.reason}:${signedThinkingHold.heavyStepsBack ?? "none"}` : freezeM0M1 ? `${currentTurnId}:directory` : null;
|
|
19536
19711
|
if (prefixHoldLogKey !== null && prefixHoldLogTurnIds.get(sessionId) !== prefixHoldLogKey) {
|
|
19537
19712
|
prefixHoldLogTurnIds.set(sessionId, prefixHoldLogKey);
|
|
@@ -19788,6 +19963,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19788
19963
|
}
|
|
19789
19964
|
logTransformTiming(sessionId, "injectTemporalMarkers", tTemporal);
|
|
19790
19965
|
}
|
|
19966
|
+
const replaysCaveman = !reducedMode && !compactionOff && deps.cavemanTextCompression?.enabled === true;
|
|
19791
19967
|
let taggingSucceeded = false;
|
|
19792
19968
|
let recoveryBatch = null;
|
|
19793
19969
|
let recoveryNormalized = false;
|
|
@@ -19800,7 +19976,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19800
19976
|
skipPrefixInjection: !ctxReduceCallable,
|
|
19801
19977
|
servedMessages: messages,
|
|
19802
19978
|
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
19803
|
-
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
19979
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId),
|
|
19980
|
+
foreignTextParts,
|
|
19981
|
+
replaysCaveman
|
|
19804
19982
|
});
|
|
19805
19983
|
for (const [number, target] of tagged.targets)
|
|
19806
19984
|
targets.set(number, target);
|
|
@@ -19826,7 +20004,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19826
20004
|
scopedToolSweep,
|
|
19827
20005
|
servedMessages: messages,
|
|
19828
20006
|
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
19829
|
-
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
20007
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId),
|
|
20008
|
+
foreignTextParts,
|
|
20009
|
+
replaysCaveman
|
|
19830
20010
|
});
|
|
19831
20011
|
targets = result.targets;
|
|
19832
20012
|
if (thinkingRecovery.restore)
|
|
@@ -19882,7 +20062,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19882
20062
|
const t3 = performance.now();
|
|
19883
20063
|
const strippedStructuralNoise = canUseEmptySentinels && !compactionOff ? stripStructuralNoise(messages) : 0;
|
|
19884
20064
|
logTransformTiming(sessionId, "stripStructuralNoise", t3, `strippedParts=${strippedStructuralNoise}`);
|
|
19885
|
-
if (
|
|
20065
|
+
if (replaysCaveman) {
|
|
19886
20066
|
const tCavemanReplay = performance.now();
|
|
19887
20067
|
const replayedCaveman = replayCavemanCompression(sessionId, db, targets, activeTags);
|
|
19888
20068
|
if (replayedCaveman > 0) {
|
|
@@ -20023,7 +20203,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20023
20203
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
20024
20204
|
providerID: modelForBudget?.providerID,
|
|
20025
20205
|
modelID: modelForBudget?.modelID,
|
|
20026
|
-
agentName: notificationParams.agent
|
|
20206
|
+
agentName: notificationParams.agent,
|
|
20207
|
+
sessionId
|
|
20027
20208
|
});
|
|
20028
20209
|
} catch (error) {
|
|
20029
20210
|
sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
|
|
@@ -20191,6 +20372,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20191
20372
|
providerID: modelForBudget?.providerID,
|
|
20192
20373
|
modelID: modelForBudget?.modelID,
|
|
20193
20374
|
agentName: notificationParams.agent,
|
|
20375
|
+
sessionId,
|
|
20194
20376
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
20195
20377
|
}, boundaryContextLimit);
|
|
20196
20378
|
} catch {
|
|
@@ -20205,13 +20387,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20205
20387
|
providerID: modelForBudget?.providerID,
|
|
20206
20388
|
modelID: modelForBudget?.modelID,
|
|
20207
20389
|
agentName: notificationParams.agent,
|
|
20390
|
+
sessionId,
|
|
20208
20391
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
20209
20392
|
}, boundaryContextLimit) : undefined);
|
|
20210
20393
|
if (finalWireEstimate) {
|
|
20211
20394
|
sessionLog2(sessionId, `transform: final-wire telemetry estimate=${finalWireEstimate.tokens} trusted=${finalWireEstimate.trusted} conversation=${finalWireEstimate.messageTokens.conversation} tools=${finalWireEstimate.messageTokens.toolCall} system=${finalWireEstimate.systemTokens} toolDefinitions=${finalWireEstimate.toolDefinitionTokens ?? "unknown"} tail=${finalWireTail}`);
|
|
20212
20395
|
}
|
|
20213
20396
|
if ((finalWireEstimate?.refusalGrade || finalWireEstimate?.refusalBasis === "byte-bound" && finalWireEstimate.refusalTokens !== undefined) && boundaryContextLimit > 0 && (finalWireEstimate.refusalTokens ?? finalWireEstimate.tokens) > boundaryContextLimit) {
|
|
20214
|
-
|
|
20397
|
+
const signedFitRetryWanted = !thinkingFitRetries.has(sessionId) && activeThinkingPrefixHold && hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
20398
|
+
if (signedFitRetryWanted && originalForThinkingFit) {
|
|
20215
20399
|
thinkingFitRetries.add(sessionId);
|
|
20216
20400
|
requestPendingMaterialization(deps.pendingMaterializationSessions, sessionId, "fit_retry");
|
|
20217
20401
|
messages.splice(0, messages.length, ...originalForThinkingFit);
|
|
@@ -20222,7 +20406,10 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20222
20406
|
}
|
|
20223
20407
|
return;
|
|
20224
20408
|
}
|
|
20225
|
-
if (
|
|
20409
|
+
if (signedFitRetryWanted) {
|
|
20410
|
+
sessionLog2(sessionId, "signed thinking fit: the held request is over the window and no copy of the pass input exists to retry from; refusing it");
|
|
20411
|
+
}
|
|
20412
|
+
if (signedFitRetryWanted || thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit || signedFitPreviouslyRefused) {
|
|
20226
20413
|
if (!signedFitPreviouslyRefused && !addMergedReasoningStrippedIds(db, sessionId, [SIGNED_FIT_REFUSED_MARKER]))
|
|
20227
20414
|
throw contextRefusalError("Cannot persist the signed-fit refusal");
|
|
20228
20415
|
throw contextRefusalError("The request remains over the model window after stripping signed thinking and reclaiming context");
|
|
@@ -20234,7 +20421,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20234
20421
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
20235
20422
|
providerID: modelForBudget?.providerID,
|
|
20236
20423
|
modelID: modelForBudget?.modelID,
|
|
20237
|
-
agentName: notificationParams.agent
|
|
20424
|
+
agentName: notificationParams.agent,
|
|
20425
|
+
sessionId
|
|
20238
20426
|
});
|
|
20239
20427
|
if (untrimmed.tokens > boundaryContextLimit) {
|
|
20240
20428
|
sessionLog2(sessionId, `history boundary unresolved: prefix trim refused and the untrimmed request estimate ${untrimmed.tokens} (trusted=${untrimmed.trusted}) exceeds the context limit ${boundaryContextLimit}; not sending it`);
|
|
@@ -20247,7 +20435,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20247
20435
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
20248
20436
|
providerID: modelForBudget?.providerID,
|
|
20249
20437
|
modelID: modelForBudget?.modelID,
|
|
20250
|
-
agentName: notificationParams.agent
|
|
20438
|
+
agentName: notificationParams.agent,
|
|
20439
|
+
sessionId
|
|
20251
20440
|
});
|
|
20252
20441
|
const servedTokens = served.toolDefinitionsMeasured ? served.rawTokens ?? served.tokens : Math.max(0, sessionMeta.systemPromptTokens) + served.messageTokens.conversation + served.messageTokens.toolCall;
|
|
20253
20442
|
if (!Number.isFinite(servedTokens) || servedTokens > unmanagedOverWindowPass.limit) {
|
|
@@ -20325,7 +20514,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20325
20514
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
20326
20515
|
providerID: modelForBudget?.providerID,
|
|
20327
20516
|
modelID: modelForBudget?.modelID,
|
|
20328
|
-
agentName: notificationParams.agent
|
|
20517
|
+
agentName: notificationParams.agent,
|
|
20518
|
+
sessionId
|
|
20329
20519
|
});
|
|
20330
20520
|
} catch (error) {
|
|
20331
20521
|
sessionLog2(sessionId, "degraded pass size guard could not estimate:", error);
|
|
@@ -20541,6 +20731,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
20541
20731
|
providerID: modelForBudget?.providerID,
|
|
20542
20732
|
modelID: modelForBudget?.modelID,
|
|
20543
20733
|
agentName: notificationParams.agent,
|
|
20734
|
+
sessionId,
|
|
20544
20735
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
20545
20736
|
});
|
|
20546
20737
|
};
|
|
@@ -23066,7 +23257,7 @@ function buildSidebarSnapshot(db, sessionId, directory, liveSessionState, inject
|
|
|
23066
23257
|
if (model) {
|
|
23067
23258
|
activeProviderID = model.providerID;
|
|
23068
23259
|
activeModelID = model.modelID;
|
|
23069
|
-
measuredToolDefTokens = getMeasuredToolDefinitionTokens(model.providerID, model.modelID, agent) ?? 0;
|
|
23260
|
+
measuredToolDefTokens = getMeasuredToolDefinitionTokens(model.providerID, model.modelID, agent, sessionId) ?? 0;
|
|
23070
23261
|
}
|
|
23071
23262
|
}
|
|
23072
23263
|
const contextLimit = typeof moduleContextLimit === "number" && moduleContextLimit > 0 ? moduleContextLimit : activeProviderID && activeModelID ? resolveContextLimit(activeProviderID, activeModelID, {
|
|
@@ -23780,8 +23971,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
23780
23971
|
const db = readDatabase();
|
|
23781
23972
|
if (!db)
|
|
23782
23973
|
return { ok: false, error: "db unavailable" };
|
|
23783
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
23784
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
23974
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-b44s2snm.js"));
|
|
23975
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-gd21f5rq.js"));
|
|
23785
23976
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
23786
23977
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
23787
23978
|
return {
|
|
@@ -23865,7 +24056,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
23865
24056
|
const db = readDatabase();
|
|
23866
24057
|
if (!db)
|
|
23867
24058
|
return { ok: false, error: "db unavailable" };
|
|
23868
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
24059
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-gwww44st.js"));
|
|
23869
24060
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
23870
24061
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
23871
24062
|
const ctx = {
|
|
@@ -52155,23 +52346,26 @@ function createCtxReduceTool(deps) {
|
|
|
52155
52346
|
dropIds = dropIds.filter((id) => !ctxReduceSelfStampIds.has(id));
|
|
52156
52347
|
const tagStatusMap = new Map(allTags.map((tag) => [tag.tagNumber, tag.status]));
|
|
52157
52348
|
const inertWhitespaceTagNumbers = new Set(getInertWhitespaceAssistantTagsByNumbers2(deps.db, sessionId, dropIds).map((tag) => tag.tagNumber));
|
|
52158
|
-
const
|
|
52159
|
-
|
|
52160
|
-
|
|
52161
|
-
|
|
52349
|
+
const foreignTextTagNumbers = new Set(dropIds.filter((id) => isLegacyForeignTextTag(sessionId, id)));
|
|
52350
|
+
const skippedTagNumbers = new Set([
|
|
52351
|
+
...inertWhitespaceTagNumbers,
|
|
52352
|
+
...foreignTextTagNumbers
|
|
52353
|
+
]);
|
|
52354
|
+
const skippedDropIds = [...new Set(dropIds.filter((id) => skippedTagNumbers.has(id)))];
|
|
52355
|
+
const inertNote = skippedDropIds.length > 0 ? `Skipped: ${skippedDropIds.map((id) => inertWhitespaceTagNumbers.has(id) ? `§${id}§ is provider framing, nothing to reclaim` : `§${id}§ is another plugin's text, nothing to reclaim`).join("; ")}.` : "";
|
|
52162
52356
|
const pendingOps = getPendingOps(deps.db, sessionId);
|
|
52163
52357
|
const pendingMap = new Map(pendingOps.map((op) => [op.tagId, op.operation]));
|
|
52164
52358
|
const conflicts = [];
|
|
52165
52359
|
for (const id of dropIds) {
|
|
52166
|
-
if (tagStatusMap.get(id) === "compacted" && !
|
|
52360
|
+
if (tagStatusMap.get(id) === "compacted" && !skippedTagNumbers.has(id)) {
|
|
52167
52361
|
conflicts.push(`§${id}§ is from before compaction`);
|
|
52168
52362
|
}
|
|
52169
52363
|
}
|
|
52170
52364
|
if (conflicts.length > 0) {
|
|
52171
52365
|
return `Error: Conflicting operations — ${conflicts.join("; ")}.`;
|
|
52172
52366
|
}
|
|
52173
|
-
const stampedCount = new Set(dropIds.filter((id) => !
|
|
52174
|
-
dropIds = dropIds.filter((id) => !
|
|
52367
|
+
const stampedCount = new Set(dropIds.filter((id) => !skippedTagNumbers.has(id))).size;
|
|
52368
|
+
dropIds = dropIds.filter((id) => !skippedTagNumbers.has(id) && tagStatusMap.get(id) !== "dropped" && pendingMap.get(id) !== "drop");
|
|
52175
52369
|
if (dropIds.length === 0) {
|
|
52176
52370
|
const reply = formatCtxReduceReply(stampedCount, ctxReduceSelfStampCount);
|
|
52177
52371
|
if (reply)
|
|
@@ -52903,12 +53097,18 @@ function applyV2PromptSurfaceTools(draft, runtime, config, smartNotesEnabled = t
|
|
|
52903
53097
|
function recordV2ToolDefinitions(draft) {
|
|
52904
53098
|
if (!draft.tools)
|
|
52905
53099
|
return;
|
|
53100
|
+
const tools = [];
|
|
52906
53101
|
for (const [id, tool] of Object.entries(draft.tools)) {
|
|
52907
53102
|
if (!tool)
|
|
52908
53103
|
continue;
|
|
52909
53104
|
recordToolParameters(id, tool.input);
|
|
52910
|
-
|
|
53105
|
+
tools.push({
|
|
53106
|
+
id,
|
|
53107
|
+
description: typeof tool.description === "string" ? tool.description : "",
|
|
53108
|
+
parameters: tool.input
|
|
53109
|
+
});
|
|
52911
53110
|
}
|
|
53111
|
+
recordToolDefinitionSet(draft.model.providerID, draft.model.id, draft.agent, tools, draft.sessionID);
|
|
52912
53112
|
}
|
|
52913
53113
|
async function applyV2SystemPrompt(systemPrompt, draft) {
|
|
52914
53114
|
resolveCtxReduceAvailabilityFromMessages(draft.sessionID, draft.messages.map((message) => ({
|
|
@@ -53561,7 +53761,7 @@ async function registerContext(context) {
|
|
|
53561
53761
|
projectDirectory: directory,
|
|
53562
53762
|
hardSignals: {
|
|
53563
53763
|
systemHash: state.systemPromptHash ?? "",
|
|
53564
|
-
toolSetHash: getCurrentToolSetHash(draft.model.providerID, draft.model.id, draft.agent),
|
|
53764
|
+
toolSetHash: getCurrentToolSetHash(draft.model.providerID, draft.model.id, draft.agent, draft.sessionID),
|
|
53565
53765
|
modelKey: `${draft.model.providerID}/${draft.model.id}`,
|
|
53566
53766
|
cacheExpired: false,
|
|
53567
53767
|
lastResponseTime: state.lastResponseTime
|
|
@@ -53949,7 +54149,7 @@ async function registerContext(context) {
|
|
|
53949
54149
|
const model = liveModels.get(sessionId);
|
|
53950
54150
|
if (!model)
|
|
53951
54151
|
return "";
|
|
53952
|
-
return getCurrentToolSetHash(model.providerID, model.modelID, agents.get(sessionId));
|
|
54152
|
+
return getCurrentToolSetHash(model.providerID, model.modelID, agents.get(sessionId), sessionId);
|
|
53953
54153
|
},
|
|
53954
54154
|
channel1StateBySession: channel1,
|
|
53955
54155
|
historyRefreshSessions,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureMemoryEmbeddings2
|
|
3
|
-
} from "./server-
|
|
4
|
-
import"./server-
|
|
3
|
+
} from "./server-wj8h2q21.js";
|
|
4
|
+
import"./server-hnmm8yzq.js";
|
|
5
5
|
import"./server-4dhv7mqz.js";
|
|
6
6
|
import"./server-qt1qqasc.js";
|
|
7
7
|
import"./server-vr4szghm.js";
|
|
8
8
|
import"./server-24g8r2d0.js";
|
|
9
9
|
import"./server-bsgd4dk1.js";
|
|
10
|
-
import"./server-
|
|
10
|
+
import"./server-7dpnt0ys.js";
|
|
11
11
|
import"./server-ab1g0wn9.js";
|
|
12
12
|
import"./server-qjvk4a9t.js";
|
|
13
|
-
import"./server-
|
|
14
|
-
import"./server-
|
|
13
|
+
import"./server-4frtg2z1.js";
|
|
14
|
+
import"./server-erk2bvdf.js";
|
|
15
15
|
import"./server-51779zs2.js";
|
|
16
16
|
import"./server-gyy4k6mf.js";
|
|
17
17
|
import"./server-3mz2qh5a.js";
|
|
@@ -72,6 +72,10 @@ export declare function applyV2PromptSurfaceTools(draft: SessionContext, runtime
|
|
|
72
72
|
* the wire, and it is keyed by the same {provider, model, agent} triple the status and sidebar
|
|
73
73
|
* handlers look the measurement up by.
|
|
74
74
|
*
|
|
75
|
+
* The draft is the request's exact tool set, so it replaces the route's measured set and becomes
|
|
76
|
+
* this session's figure: a tool an earlier request carried, or another session's request carried,
|
|
77
|
+
* does not count toward this request's size.
|
|
78
|
+
*
|
|
75
79
|
* Measuring changes no served byte: the resulting tool-set hash is an attribution marker that the
|
|
76
80
|
* m[0] materialization decision records but never folds on.
|
|
77
81
|
*/
|