@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
|
@@ -169,7 +169,7 @@ import {
|
|
|
169
169
|
buildInMemoryTailRawMessages2,
|
|
170
170
|
RawOrdinalsNotReady2,
|
|
171
171
|
runSessionWarmupWorker
|
|
172
|
-
} from "./index-
|
|
172
|
+
} from "./index-m8va3mma.js";
|
|
173
173
|
import {
|
|
174
174
|
openCodeDbExists,
|
|
175
175
|
withReadOnlySessionDb,
|
|
@@ -177,7 +177,7 @@ import {
|
|
|
177
177
|
latestPersistedMessageForRecovery,
|
|
178
178
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
179
179
|
findLastAssistantModelFromOpenCodeDb
|
|
180
|
-
} from "./index-
|
|
180
|
+
} from "./index-j43m40zd.js";
|
|
181
181
|
import {
|
|
182
182
|
expandToolPart,
|
|
183
183
|
askAnswerLines,
|
|
@@ -302,10 +302,11 @@ import {
|
|
|
302
302
|
readRawSessionMessageById2,
|
|
303
303
|
readSessionChunk2,
|
|
304
304
|
readRawSessionSeedTail2
|
|
305
|
-
} from "./index-
|
|
305
|
+
} from "./index-dn2ke3b9.js";
|
|
306
306
|
import {
|
|
307
|
+
BoundedSessionMap,
|
|
307
308
|
getMeasuredToolDefinitionTokens
|
|
308
|
-
} from "./index-
|
|
309
|
+
} from "./index-cfaet9cg.js";
|
|
309
310
|
import {
|
|
310
311
|
isFailClosedBlockingError,
|
|
311
312
|
shouldBypassFailClosedBlock,
|
|
@@ -319,7 +320,7 @@ import {
|
|
|
319
320
|
runSqliteOptimize,
|
|
320
321
|
openDatabase,
|
|
321
322
|
openCurrentDatabase
|
|
322
|
-
} from "./index-
|
|
323
|
+
} from "./index-6g1zq1sk.js";
|
|
323
324
|
import {
|
|
324
325
|
registerOwnRpcServerInstance,
|
|
325
326
|
rpcPortDir,
|
|
@@ -514,7 +515,7 @@ import {
|
|
|
514
515
|
snapRangeToCompartments,
|
|
515
516
|
getActiveCompartmentRun,
|
|
516
517
|
startCompartmentAgent
|
|
517
|
-
} from "./index-
|
|
518
|
+
} from "./index-hjnrp6vy.js";
|
|
518
519
|
import {
|
|
519
520
|
embedPauseBySession,
|
|
520
521
|
embedRunStateBySession,
|
|
@@ -542,7 +543,7 @@ import {
|
|
|
542
543
|
embedSessionCompartmentChunks2,
|
|
543
544
|
getEmbeddingCoverageStatus2,
|
|
544
545
|
getAutoEmbeddingSessionCoverage2
|
|
545
|
-
} from "./index-
|
|
546
|
+
} from "./index-sgchhbvy.js";
|
|
546
547
|
import {
|
|
547
548
|
SubcClient,
|
|
548
549
|
connectionFileExists,
|
|
@@ -552,7 +553,6 @@ import {
|
|
|
552
553
|
SynapseEmbeddingProvider
|
|
553
554
|
} from "./index-wfybj1dw.js";
|
|
554
555
|
import {
|
|
555
|
-
BoundedSessionMap,
|
|
556
556
|
LkgRecoveryFenceError,
|
|
557
557
|
lkgServedArrayDigest,
|
|
558
558
|
takeLkgRecoveryLockSweepPage,
|
|
@@ -573,7 +573,7 @@ import {
|
|
|
573
573
|
indexSingleMessage2,
|
|
574
574
|
indexMessagesAfterOrdinal2,
|
|
575
575
|
sweepOrphanedOpenCodeMessageIndexesCooperatively2
|
|
576
|
-
} from "./index-
|
|
576
|
+
} from "./index-40ma8m0c.js";
|
|
577
577
|
import {
|
|
578
578
|
renderUserFacingFailure,
|
|
579
579
|
userFacingFailureCode,
|
|
@@ -617,7 +617,7 @@ import {
|
|
|
617
617
|
readGitFileChangeTimesSince,
|
|
618
618
|
verificationFileExists,
|
|
619
619
|
normalizeVerificationFiles
|
|
620
|
-
} from "./index-
|
|
620
|
+
} from "./index-mphkpyap.js";
|
|
621
621
|
import {
|
|
622
622
|
registerNotificationSink2,
|
|
623
623
|
pushNotification2,
|
|
@@ -637,7 +637,7 @@ import {
|
|
|
637
637
|
} from "./index-4dhv7mqz.js";
|
|
638
638
|
import {
|
|
639
639
|
cosineSimilarity
|
|
640
|
-
} from "./index-
|
|
640
|
+
} from "./index-e5b61ty6.js";
|
|
641
641
|
import {
|
|
642
642
|
computeCueContentHash,
|
|
643
643
|
hasMuralCueColumns,
|
|
@@ -683,17 +683,17 @@ import {
|
|
|
683
683
|
resolveMemoriesByIdsForSearch2,
|
|
684
684
|
unifiedSearch2,
|
|
685
685
|
formatSearchResults2
|
|
686
|
-
} from "./index-
|
|
686
|
+
} from "./index-r3bteyev.js";
|
|
687
687
|
import {
|
|
688
688
|
flushIgnoredMessages2,
|
|
689
689
|
clearIgnoredMessages2,
|
|
690
690
|
observeIgnoredNotificationEvent2,
|
|
691
691
|
sendStatusNotification2
|
|
692
|
-
} from "./index-
|
|
692
|
+
} from "./index-w55zp7kf.js";
|
|
693
693
|
import {
|
|
694
694
|
setRecompStarting2,
|
|
695
695
|
setRecompTerminal2
|
|
696
|
-
} from "./index-
|
|
696
|
+
} from "./index-va2g2q57.js";
|
|
697
697
|
import {
|
|
698
698
|
makeToolCompositeKey,
|
|
699
699
|
searchMessageHistoryOffThread,
|
|
@@ -741,6 +741,7 @@ import {
|
|
|
741
741
|
prewarmTagOwners,
|
|
742
742
|
waitForTagOwners,
|
|
743
743
|
stripStructuralNoise,
|
|
744
|
+
isLegacyForeignTextTag,
|
|
744
745
|
withTransformTimingSummary,
|
|
745
746
|
logTransformTiming,
|
|
746
747
|
hasRecentAssistantCommit,
|
|
@@ -754,7 +755,7 @@ import {
|
|
|
754
755
|
abortSessionFailClosed2,
|
|
755
756
|
evaluateEmergencyFailClosed2,
|
|
756
757
|
runPostTransformPhase2
|
|
757
|
-
} from "./index-
|
|
758
|
+
} from "./index-rp78nqvr.js";
|
|
758
759
|
import {
|
|
759
760
|
ANNOUNCEMENT_VERSION2,
|
|
760
761
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -767,7 +768,7 @@ import {
|
|
|
767
768
|
} from "./index-fmsr7v69.js";
|
|
768
769
|
import {
|
|
769
770
|
renderSearchArchiveOffThread2
|
|
770
|
-
} from "./index-
|
|
771
|
+
} from "./index-zn2n24yr.js";
|
|
771
772
|
import {
|
|
772
773
|
COMPACTION_ENABLED_PATH,
|
|
773
774
|
isDreamerRunnable,
|
|
@@ -15766,7 +15767,7 @@ function buildSidebarSnapshot(db, sessionId, directory, liveSessionState, inject
|
|
|
15766
15767
|
if (model) {
|
|
15767
15768
|
activeProviderID = model.providerID;
|
|
15768
15769
|
activeModelID = model.modelID;
|
|
15769
|
-
measuredToolDefTokens = getMeasuredToolDefinitionTokens(model.providerID, model.modelID, agent) ?? 0;
|
|
15770
|
+
measuredToolDefTokens = getMeasuredToolDefinitionTokens(model.providerID, model.modelID, agent, sessionId) ?? 0;
|
|
15770
15771
|
}
|
|
15771
15772
|
}
|
|
15772
15773
|
const contextLimit = typeof moduleContextLimit === "number" && moduleContextLimit > 0 ? moduleContextLimit : activeProviderID && activeModelID ? resolveContextLimit(activeProviderID, activeModelID, {
|
|
@@ -16480,8 +16481,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16480
16481
|
const db = readDatabase();
|
|
16481
16482
|
if (!db)
|
|
16482
16483
|
return { ok: false, error: "db unavailable" };
|
|
16483
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16484
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16484
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-qwcz86r1.js"));
|
|
16485
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-kzazs7fy.js"));
|
|
16485
16486
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16486
16487
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16487
16488
|
return {
|
|
@@ -16565,7 +16566,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16565
16566
|
const db = readDatabase();
|
|
16566
16567
|
if (!db)
|
|
16567
16568
|
return { ok: false, error: "db unavailable" };
|
|
16568
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16569
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-a9r8r4sk.js"));
|
|
16569
16570
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16570
16571
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16571
16572
|
const ctx = {
|
|
@@ -18264,7 +18265,8 @@ function measureLkgReplayRequest(args) {
|
|
|
18264
18265
|
systemPromptTokens: args.systemPromptTokens,
|
|
18265
18266
|
providerID: args.model?.providerID,
|
|
18266
18267
|
modelID: args.model?.modelID,
|
|
18267
|
-
agentName: args.agentName
|
|
18268
|
+
agentName: args.agentName,
|
|
18269
|
+
sessionId: args.sessionId
|
|
18268
18270
|
})
|
|
18269
18271
|
});
|
|
18270
18272
|
}
|
|
@@ -22153,7 +22155,8 @@ function createRustModeTransform(deps, options) {
|
|
|
22153
22155
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
22154
22156
|
providerID: model?.providerID,
|
|
22155
22157
|
modelID: model?.modelID,
|
|
22156
|
-
agentName: deps.getNotificationParams?.(sessionId)?.agent
|
|
22158
|
+
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
22159
|
+
sessionId
|
|
22157
22160
|
})
|
|
22158
22161
|
});
|
|
22159
22162
|
if (measure.fit !== "under") {
|
|
@@ -22724,7 +22727,8 @@ function createRustModeTransform(deps, options) {
|
|
|
22724
22727
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
22725
22728
|
providerID: model?.providerID,
|
|
22726
22729
|
modelID: model?.modelID,
|
|
22727
|
-
agentName: deps.getNotificationParams?.(sessionId)?.agent
|
|
22730
|
+
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
22731
|
+
sessionId
|
|
22728
22732
|
}) : undefined;
|
|
22729
22733
|
const renderIdentityFields = {
|
|
22730
22734
|
modelKey: modelKey ?? null,
|
|
@@ -23256,6 +23260,7 @@ function createRustModeTransform(deps, options) {
|
|
|
23256
23260
|
providerID: model?.providerID,
|
|
23257
23261
|
modelID: model?.modelID,
|
|
23258
23262
|
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
23263
|
+
sessionId,
|
|
23259
23264
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
23260
23265
|
}, resolvedWindowGeometry?.usableHard ?? resolvedContextLimit);
|
|
23261
23266
|
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);
|
|
@@ -23491,6 +23496,7 @@ function createRustModeTransform(deps, options) {
|
|
|
23491
23496
|
providerID: model?.providerID,
|
|
23492
23497
|
modelID: model?.modelID,
|
|
23493
23498
|
agentName: deps.getNotificationParams?.(sessionId)?.agent,
|
|
23499
|
+
sessionId,
|
|
23494
23500
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
23495
23501
|
});
|
|
23496
23502
|
captureOpencodeReasoningBudgetStatus(sessionId, output.messages, resolveKeepReasoningTokens(deps.keepReasoningTokens, modelKey ?? undefined), isPrefixBoundThinkingModel(model?.providerID, model?.modelID));
|
|
@@ -23754,6 +23760,27 @@ function createRustModeTransform(deps, options) {
|
|
|
23754
23760
|
return adapter;
|
|
23755
23761
|
}
|
|
23756
23762
|
|
|
23763
|
+
// src/hooks/magic-context/signed-thinking-fit-snapshot.ts
|
|
23764
|
+
function takeSignedThinkingFitSnapshot(args) {
|
|
23765
|
+
let snapshot = null;
|
|
23766
|
+
if (args.held && !args.compactionOff) {
|
|
23767
|
+
try {
|
|
23768
|
+
snapshot = cloneKeepingCoveredInstructionMarks(args.entryOrder);
|
|
23769
|
+
} catch (error) {
|
|
23770
|
+
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`);
|
|
23771
|
+
}
|
|
23772
|
+
}
|
|
23773
|
+
snapshotObserver?.({
|
|
23774
|
+
sessionId: args.sessionId,
|
|
23775
|
+
held: args.held,
|
|
23776
|
+
activeAnthropicThinkingTurn: args.activeAnthropicThinkingTurn,
|
|
23777
|
+
compactionOff: args.compactionOff,
|
|
23778
|
+
snapshot
|
|
23779
|
+
});
|
|
23780
|
+
return snapshot;
|
|
23781
|
+
}
|
|
23782
|
+
var snapshotObserver;
|
|
23783
|
+
|
|
23757
23784
|
// src/hooks/magic-context/signed-thinking-hold.ts
|
|
23758
23785
|
var HEAVY_REASONING_TOKENS = 1500;
|
|
23759
23786
|
var HEAVY_REASONING_WINDOW_STEPS = 15;
|
|
@@ -24374,7 +24401,8 @@ function createTransform(deps) {
|
|
|
24374
24401
|
const startTime = performance.now();
|
|
24375
24402
|
const historianRun = deps.resolveHistorianRun?.();
|
|
24376
24403
|
const messages = output.messages;
|
|
24377
|
-
const
|
|
24404
|
+
const foreignTextParts = deps.transformMode === "rust" ? undefined : deps.collectForeignTextParts?.(messages);
|
|
24405
|
+
const entryOrderForThinkingFit = messages.slice();
|
|
24378
24406
|
const coveredHostInstructions = takeCoveredInstructionRows(messages);
|
|
24379
24407
|
const passOutcome = createPassOutcome();
|
|
24380
24408
|
const tSessionId = performance.now();
|
|
@@ -24728,7 +24756,8 @@ function createTransform(deps) {
|
|
|
24728
24756
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
24729
24757
|
providerID: modelForBudget?.providerID,
|
|
24730
24758
|
modelID: modelForBudget?.modelID,
|
|
24731
|
-
agentName: runNotificationParams(sessionId)?.agent
|
|
24759
|
+
agentName: runNotificationParams(sessionId)?.agent,
|
|
24760
|
+
sessionId
|
|
24732
24761
|
});
|
|
24733
24762
|
const incomingTokens = incoming.messageTokens.conversation + incoming.messageTokens.toolCall;
|
|
24734
24763
|
if (unmanagedOverWindowCarried || isClearlyOverWindow(incomingTokens, resolvedContextLimit)) {
|
|
@@ -24774,6 +24803,13 @@ function createTransform(deps) {
|
|
|
24774
24803
|
}) : null;
|
|
24775
24804
|
activeThinkingPrefixHold = signedThinkingPrefixBound && (compactionOff || signedThinkingHold?.held === true);
|
|
24776
24805
|
freezeM0M1 ||= activeThinkingPrefixHold;
|
|
24806
|
+
const originalForThinkingFit = takeSignedThinkingFitSnapshot({
|
|
24807
|
+
sessionId,
|
|
24808
|
+
entryOrder: entryOrderForThinkingFit,
|
|
24809
|
+
held: activeThinkingPrefixHold,
|
|
24810
|
+
activeAnthropicThinkingTurn: activeThinkingTurn,
|
|
24811
|
+
compactionOff
|
|
24812
|
+
});
|
|
24777
24813
|
const prefixHoldLogKey = signedThinkingHold ? `${currentTurnId}:${signedThinkingHold.reason}:${signedThinkingHold.heavyStepsBack ?? "none"}` : freezeM0M1 ? `${currentTurnId}:directory` : null;
|
|
24778
24814
|
if (prefixHoldLogKey !== null && prefixHoldLogTurnIds.get(sessionId) !== prefixHoldLogKey) {
|
|
24779
24815
|
prefixHoldLogTurnIds.set(sessionId, prefixHoldLogKey);
|
|
@@ -25030,6 +25066,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25030
25066
|
}
|
|
25031
25067
|
logTransformTiming(sessionId, "injectTemporalMarkers", tTemporal);
|
|
25032
25068
|
}
|
|
25069
|
+
const replaysCaveman = !reducedMode && !compactionOff && deps.cavemanTextCompression?.enabled === true;
|
|
25033
25070
|
let taggingSucceeded = false;
|
|
25034
25071
|
let recoveryBatch = null;
|
|
25035
25072
|
let recoveryNormalized = false;
|
|
@@ -25042,7 +25079,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25042
25079
|
skipPrefixInjection: !ctxReduceCallable,
|
|
25043
25080
|
servedMessages: messages,
|
|
25044
25081
|
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
25045
|
-
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
25082
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId),
|
|
25083
|
+
foreignTextParts,
|
|
25084
|
+
replaysCaveman
|
|
25046
25085
|
});
|
|
25047
25086
|
for (const [number, target] of tagged.targets)
|
|
25048
25087
|
targets.set(number, target);
|
|
@@ -25068,7 +25107,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25068
25107
|
scopedToolSweep,
|
|
25069
25108
|
servedMessages: messages,
|
|
25070
25109
|
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
25071
|
-
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
25110
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId),
|
|
25111
|
+
foreignTextParts,
|
|
25112
|
+
replaysCaveman
|
|
25072
25113
|
});
|
|
25073
25114
|
targets = result.targets;
|
|
25074
25115
|
if (thinkingRecovery.restore)
|
|
@@ -25124,7 +25165,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25124
25165
|
const t3 = performance.now();
|
|
25125
25166
|
const strippedStructuralNoise = canUseEmptySentinels && !compactionOff ? stripStructuralNoise(messages) : 0;
|
|
25126
25167
|
logTransformTiming(sessionId, "stripStructuralNoise", t3, `strippedParts=${strippedStructuralNoise}`);
|
|
25127
|
-
if (
|
|
25168
|
+
if (replaysCaveman) {
|
|
25128
25169
|
const tCavemanReplay = performance.now();
|
|
25129
25170
|
const replayedCaveman = replayCavemanCompression(sessionId, db, targets, activeTags);
|
|
25130
25171
|
if (replayedCaveman > 0) {
|
|
@@ -25265,7 +25306,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25265
25306
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25266
25307
|
providerID: modelForBudget?.providerID,
|
|
25267
25308
|
modelID: modelForBudget?.modelID,
|
|
25268
|
-
agentName: notificationParams.agent
|
|
25309
|
+
agentName: notificationParams.agent,
|
|
25310
|
+
sessionId
|
|
25269
25311
|
});
|
|
25270
25312
|
} catch (error) {
|
|
25271
25313
|
sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
|
|
@@ -25433,6 +25475,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25433
25475
|
providerID: modelForBudget?.providerID,
|
|
25434
25476
|
modelID: modelForBudget?.modelID,
|
|
25435
25477
|
agentName: notificationParams.agent,
|
|
25478
|
+
sessionId,
|
|
25436
25479
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
25437
25480
|
}, boundaryContextLimit);
|
|
25438
25481
|
} catch {
|
|
@@ -25447,13 +25490,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25447
25490
|
providerID: modelForBudget?.providerID,
|
|
25448
25491
|
modelID: modelForBudget?.modelID,
|
|
25449
25492
|
agentName: notificationParams.agent,
|
|
25493
|
+
sessionId,
|
|
25450
25494
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
25451
25495
|
}, boundaryContextLimit) : undefined);
|
|
25452
25496
|
if (finalWireEstimate) {
|
|
25453
25497
|
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}`);
|
|
25454
25498
|
}
|
|
25455
25499
|
if ((finalWireEstimate?.refusalGrade || finalWireEstimate?.refusalBasis === "byte-bound" && finalWireEstimate.refusalTokens !== undefined) && boundaryContextLimit > 0 && (finalWireEstimate.refusalTokens ?? finalWireEstimate.tokens) > boundaryContextLimit) {
|
|
25456
|
-
|
|
25500
|
+
const signedFitRetryWanted = !thinkingFitRetries.has(sessionId) && activeThinkingPrefixHold && hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
25501
|
+
if (signedFitRetryWanted && originalForThinkingFit) {
|
|
25457
25502
|
thinkingFitRetries.add(sessionId);
|
|
25458
25503
|
requestPendingMaterialization(deps.pendingMaterializationSessions, sessionId, "fit_retry");
|
|
25459
25504
|
messages.splice(0, messages.length, ...originalForThinkingFit);
|
|
@@ -25464,7 +25509,10 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25464
25509
|
}
|
|
25465
25510
|
return;
|
|
25466
25511
|
}
|
|
25467
|
-
if (
|
|
25512
|
+
if (signedFitRetryWanted) {
|
|
25513
|
+
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");
|
|
25514
|
+
}
|
|
25515
|
+
if (signedFitRetryWanted || thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit || signedFitPreviouslyRefused) {
|
|
25468
25516
|
if (!signedFitPreviouslyRefused && !addMergedReasoningStrippedIds(db, sessionId, [SIGNED_FIT_REFUSED_MARKER]))
|
|
25469
25517
|
throw contextRefusalError("Cannot persist the signed-fit refusal");
|
|
25470
25518
|
throw contextRefusalError("The request remains over the model window after stripping signed thinking and reclaiming context");
|
|
@@ -25476,7 +25524,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25476
25524
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25477
25525
|
providerID: modelForBudget?.providerID,
|
|
25478
25526
|
modelID: modelForBudget?.modelID,
|
|
25479
|
-
agentName: notificationParams.agent
|
|
25527
|
+
agentName: notificationParams.agent,
|
|
25528
|
+
sessionId
|
|
25480
25529
|
});
|
|
25481
25530
|
if (untrimmed.tokens > boundaryContextLimit) {
|
|
25482
25531
|
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`);
|
|
@@ -25489,7 +25538,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25489
25538
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25490
25539
|
providerID: modelForBudget?.providerID,
|
|
25491
25540
|
modelID: modelForBudget?.modelID,
|
|
25492
|
-
agentName: notificationParams.agent
|
|
25541
|
+
agentName: notificationParams.agent,
|
|
25542
|
+
sessionId
|
|
25493
25543
|
});
|
|
25494
25544
|
const servedTokens = served.toolDefinitionsMeasured ? served.rawTokens ?? served.tokens : Math.max(0, sessionMeta.systemPromptTokens) + served.messageTokens.conversation + served.messageTokens.toolCall;
|
|
25495
25545
|
if (!Number.isFinite(servedTokens) || servedTokens > unmanagedOverWindowPass.limit) {
|
|
@@ -25567,7 +25617,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25567
25617
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25568
25618
|
providerID: modelForBudget?.providerID,
|
|
25569
25619
|
modelID: modelForBudget?.modelID,
|
|
25570
|
-
agentName: notificationParams.agent
|
|
25620
|
+
agentName: notificationParams.agent,
|
|
25621
|
+
sessionId
|
|
25571
25622
|
});
|
|
25572
25623
|
} catch (error) {
|
|
25573
25624
|
sessionLog2(sessionId, "degraded pass size guard could not estimate:", error);
|
|
@@ -25783,6 +25834,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25783
25834
|
providerID: modelForBudget?.providerID,
|
|
25784
25835
|
modelID: modelForBudget?.modelID,
|
|
25785
25836
|
agentName: notificationParams.agent,
|
|
25837
|
+
sessionId,
|
|
25786
25838
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
25787
25839
|
});
|
|
25788
25840
|
};
|
|
@@ -28960,23 +29012,26 @@ function createCtxReduceTool(deps) {
|
|
|
28960
29012
|
dropIds = dropIds.filter((id) => !ctxReduceSelfStampIds.has(id));
|
|
28961
29013
|
const tagStatusMap = new Map(allTags.map((tag) => [tag.tagNumber, tag.status]));
|
|
28962
29014
|
const inertWhitespaceTagNumbers = new Set(getInertWhitespaceAssistantTagsByNumbers2(deps.db, sessionId, dropIds).map((tag) => tag.tagNumber));
|
|
28963
|
-
const
|
|
28964
|
-
|
|
28965
|
-
|
|
28966
|
-
|
|
29015
|
+
const foreignTextTagNumbers = new Set(dropIds.filter((id) => isLegacyForeignTextTag(sessionId, id)));
|
|
29016
|
+
const skippedTagNumbers = new Set([
|
|
29017
|
+
...inertWhitespaceTagNumbers,
|
|
29018
|
+
...foreignTextTagNumbers
|
|
29019
|
+
]);
|
|
29020
|
+
const skippedDropIds = [...new Set(dropIds.filter((id) => skippedTagNumbers.has(id)))];
|
|
29021
|
+
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("; ")}.` : "";
|
|
28967
29022
|
const pendingOps = getPendingOps(deps.db, sessionId);
|
|
28968
29023
|
const pendingMap = new Map(pendingOps.map((op) => [op.tagId, op.operation]));
|
|
28969
29024
|
const conflicts = [];
|
|
28970
29025
|
for (const id of dropIds) {
|
|
28971
|
-
if (tagStatusMap.get(id) === "compacted" && !
|
|
29026
|
+
if (tagStatusMap.get(id) === "compacted" && !skippedTagNumbers.has(id)) {
|
|
28972
29027
|
conflicts.push(`§${id}§ is from before compaction`);
|
|
28973
29028
|
}
|
|
28974
29029
|
}
|
|
28975
29030
|
if (conflicts.length > 0) {
|
|
28976
29031
|
return `Error: Conflicting operations — ${conflicts.join("; ")}.`;
|
|
28977
29032
|
}
|
|
28978
|
-
const stampedCount = new Set(dropIds.filter((id) => !
|
|
28979
|
-
dropIds = dropIds.filter((id) => !
|
|
29033
|
+
const stampedCount = new Set(dropIds.filter((id) => !skippedTagNumbers.has(id))).size;
|
|
29034
|
+
dropIds = dropIds.filter((id) => !skippedTagNumbers.has(id) && tagStatusMap.get(id) !== "dropped" && pendingMap.get(id) !== "drop");
|
|
28980
29035
|
if (dropIds.length === 0) {
|
|
28981
29036
|
const reply = formatCtxReduceReply(stampedCount, ctxReduceSelfStampCount);
|
|
28982
29037
|
if (reply)
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
} from "./index-fb3zxn06.js";
|
|
45
45
|
import {
|
|
46
46
|
startMessageFtsRowidMapBackfill2
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-xbbgcwd2.js";
|
|
48
48
|
import {
|
|
49
49
|
LKG_SLOT_CHUNKS_DDL,
|
|
50
50
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
import {
|
|
68
68
|
setDatabase,
|
|
69
69
|
loadToolDefinitionMeasurements
|
|
70
|
-
} from "./index-
|
|
70
|
+
} from "./index-cfaet9cg.js";
|
|
71
71
|
import {
|
|
72
72
|
getErrorMessage
|
|
73
73
|
} from "./index-y8v6yerm.js";
|
|
@@ -1279,7 +1279,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1279
1279
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1280
1280
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1281
1281
|
return;
|
|
1282
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1282
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-mqmkgdx0.js"));
|
|
1283
1283
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-4qva0b4f.js"));
|
|
1284
1284
|
if (signal.aborted)
|
|
1285
1285
|
return;
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./index-wfybj1dw.js";
|
|
14
14
|
import {
|
|
15
15
|
messageFtsOrdinalRangeIsMapped2
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-xbbgcwd2.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|