@cortexkit/pi-magic-context 0.49.72 → 0.49.74
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/{index-dw9x7k2b.js → index-6t4m64m1.js} +1 -1
- package/dist/{index-r4qt07th.js → index-mtpsqxev.js} +2 -2
- package/dist/{index-kqekqrzw.js → index-tygcydj7.js} +23 -1
- package/dist/index.js +72 -36
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{render-bsdcxgaq.js → render-cm4572er.js} +1 -1
- package/dist/{search-archive-3hh7ycvm.js → search-archive-8kcsmnzt.js} +1 -1
- package/dist/subagent-entry.js +3 -3
- package/dist/{v2-archive-reader-b7spmyqa.js → v2-archive-reader-ycw2nxf1.js} +1 -1
- package/package.json +1 -1
|
@@ -140,8 +140,8 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
140
140
|
import("./store-reader-mmfw2h48.js"),
|
|
141
141
|
import("./store-grcwn6hs.js"),
|
|
142
142
|
import("./read-session-chunk-ygwyfvtr.js"),
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
143
|
+
import("./render-cm4572er.js"),
|
|
144
|
+
import("./search-archive-8kcsmnzt.js"),
|
|
145
145
|
import("./expand-attachments-8sxeyj26.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -1505,11 +1505,33 @@ function pendingMaterializationOrigin(sessions, sessionId) {
|
|
|
1505
1505
|
function hasPendingMaterializationOrigin(sessions, sessionId, origin) {
|
|
1506
1506
|
return sessions.has(sessionId) && causes.get(sessions)?.get(sessionId)?.has(origin) === true;
|
|
1507
1507
|
}
|
|
1508
|
+
function hasExplicitRefreshRequest(sessions, sessionId) {
|
|
1509
|
+
return hasPendingMaterializationOrigin(sessions, sessionId, "user_flush") || hasPendingMaterializationOrigin(sessions, sessionId, "user_wrapup");
|
|
1510
|
+
}
|
|
1508
1511
|
function clearPendingMaterialization(sessions, sessionId) {
|
|
1509
1512
|
sessions.delete(sessionId);
|
|
1510
1513
|
origins.get(sessions)?.delete(sessionId);
|
|
1511
1514
|
causes.get(sessions)?.delete(sessionId);
|
|
1512
1515
|
}
|
|
1516
|
+
function clearReclaimedMaterialization(sessions, sessionId) {
|
|
1517
|
+
const wrapupPending = hasPendingMaterializationOrigin(sessions, sessionId, "user_wrapup");
|
|
1518
|
+
clearPendingMaterialization(sessions, sessionId);
|
|
1519
|
+
if (wrapupPending)
|
|
1520
|
+
requestPendingMaterialization(sessions, sessionId, "user_wrapup");
|
|
1521
|
+
}
|
|
1522
|
+
function clearPendingMaterializationOrigin(sessions, sessionId, origin) {
|
|
1523
|
+
const pendingCauses = causes.get(sessions)?.get(sessionId);
|
|
1524
|
+
if (!sessions.has(sessionId) || !pendingCauses?.has(origin))
|
|
1525
|
+
return;
|
|
1526
|
+
pendingCauses.delete(origin);
|
|
1527
|
+
const [next] = pendingCauses;
|
|
1528
|
+
if (next === undefined) {
|
|
1529
|
+
clearPendingMaterialization(sessions, sessionId);
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (origins.get(sessions)?.get(sessionId) === origin)
|
|
1533
|
+
origins.get(sessions)?.set(sessionId, next);
|
|
1534
|
+
}
|
|
1513
1535
|
function hasOnlySystemHashMaterialization(sessions, sessionId) {
|
|
1514
1536
|
const pendingCauses = causes.get(sessions)?.get(sessionId);
|
|
1515
1537
|
return sessions.has(sessionId) && pendingCauses?.size === 1 && pendingCauses.has("system_hash");
|
|
@@ -4703,4 +4725,4 @@ function renderItemByTag2(db, sessionId, number, textIndexDomain = "part", attac
|
|
|
4703
4725
|
return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
|
|
4704
4726
|
}
|
|
4705
4727
|
|
|
4706
|
-
export { LkgRecoveryFenceError, clearLkgFenceProcessState, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, PI_IDENTITY_FOLD_GUARD_LIMIT, readPiIdentityFoldGuards, writePiIdentityFoldGuards, readSessionActivity, observeSessionActivity, backfillSessionActivity, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, getUncoveredCompartmentEndsThrough, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, beginServedRequest, noteServedPassPermission, noteServedReplay, countServedRefusal, dropServedRecord, commitServedRequest, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, withNativeReplayWriteBarrier, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, renderMessageByOrdinal2, renderVerboseRange2, renderVerboseRangeForTool2, renderItemByTag2 };
|
|
4728
|
+
export { LkgRecoveryFenceError, clearLkgFenceProcessState, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, PI_IDENTITY_FOLD_GUARD_LIMIT, readPiIdentityFoldGuards, writePiIdentityFoldGuards, readSessionActivity, observeSessionActivity, backfillSessionActivity, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, getUncoveredCompartmentEndsThrough, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, hasExplicitRefreshRequest, clearPendingMaterialization, clearReclaimedMaterialization, clearPendingMaterializationOrigin, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, beginServedRequest, noteServedPassPermission, noteServedReplay, countServedRefusal, dropServedRecord, commitServedRequest, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, withNativeReplayWriteBarrier, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, renderMessageByOrdinal2, renderVerboseRange2, renderVerboseRangeForTool2, renderItemByTag2 };
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
registerTodoStateLifecycle,
|
|
159
159
|
syncCtxMemoryToolEnabled,
|
|
160
160
|
registerMagicContextTools
|
|
161
|
-
} from "./index-
|
|
161
|
+
} from "./index-6t4m64m1.js";
|
|
162
162
|
import"./index-4knyh1kt.js";
|
|
163
163
|
import {
|
|
164
164
|
canonicalModelIdentity,
|
|
@@ -516,7 +516,10 @@ import {
|
|
|
516
516
|
requestPendingMaterialization,
|
|
517
517
|
pendingMaterializationOrigin,
|
|
518
518
|
hasPendingMaterializationOrigin,
|
|
519
|
+
hasExplicitRefreshRequest,
|
|
519
520
|
clearPendingMaterialization,
|
|
521
|
+
clearReclaimedMaterialization,
|
|
522
|
+
clearPendingMaterializationOrigin,
|
|
520
523
|
recordSystemRefreshOwnership,
|
|
521
524
|
recordSystemPromptForRequest,
|
|
522
525
|
recordHeldHeadForRequest,
|
|
@@ -587,7 +590,7 @@ import {
|
|
|
587
590
|
getSourceContents,
|
|
588
591
|
recordSubagentInvocation,
|
|
589
592
|
getLatestHistorianInvocationId
|
|
590
|
-
} from "./index-
|
|
593
|
+
} from "./index-tygcydj7.js";
|
|
591
594
|
import {
|
|
592
595
|
resolveOpenCodeDbPath,
|
|
593
596
|
assertOpenCodeStoreGeneration,
|
|
@@ -854,7 +857,7 @@ import {
|
|
|
854
857
|
} from "./index-wmkkxwvf.js";
|
|
855
858
|
import"./index-71rg8j43.js";
|
|
856
859
|
import"./index-8d2z6503.js";
|
|
857
|
-
import"./index-
|
|
860
|
+
import"./index-mtpsqxev.js";
|
|
858
861
|
import"./index-cyzsn2hb.js";
|
|
859
862
|
import {
|
|
860
863
|
__toESM
|
|
@@ -3607,7 +3610,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3607
3610
|
// package.json
|
|
3608
3611
|
var package_default = {
|
|
3609
3612
|
name: "@cortexkit/pi-magic-context",
|
|
3610
|
-
version: "0.49.
|
|
3613
|
+
version: "0.49.74",
|
|
3611
3614
|
type: "module",
|
|
3612
3615
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3613
3616
|
main: "dist/index.js",
|
|
@@ -17874,7 +17877,7 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
17874
17877
|
const verifiedHead = headAtPrompt === undefined ? await readGitHead(args.sessionDirectory) : headAtPrompt;
|
|
17875
17878
|
const writes = [];
|
|
17876
17879
|
let refused = 0;
|
|
17877
|
-
|
|
17880
|
+
let skipped = valid.skipped.length;
|
|
17878
17881
|
for (const v of valid.verified) {
|
|
17879
17882
|
const files = await normalizeFiles(args, v.files);
|
|
17880
17883
|
writes.push({ kind: "verify", id: v.id, files });
|
|
@@ -17988,6 +17991,12 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
17988
17991
|
const memory = getMemoryById2(args.db, w.id);
|
|
17989
17992
|
if (!isPrimaryMutable(memory))
|
|
17990
17993
|
continue;
|
|
17994
|
+
if (memory.content !== batchById.get(w.id)?.content) {
|
|
17995
|
+
log2(`[dreamer] verify skipped: memory_id=${w.id} verdict=${w.kind} reason=content-changed-since-prompt`);
|
|
17996
|
+
if (w.kind === "skip")
|
|
17997
|
+
skipped -= 1;
|
|
17998
|
+
continue;
|
|
17999
|
+
}
|
|
17991
18000
|
if (w.kind === "verify") {
|
|
17992
18001
|
recordMemoryVerifications(args.db, w.id, w.files, now);
|
|
17993
18002
|
updateMemoryVerification2(args.db, w.id, "verified");
|
|
@@ -17997,8 +18006,6 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
17997
18006
|
recordVerifiedCommit(args.db, verifiedMemory, now, verifiedHead);
|
|
17998
18007
|
verified += 1;
|
|
17999
18008
|
} else if (w.kind === "skip") {
|
|
18000
|
-
if (memory.content !== batchById.get(w.id)?.content)
|
|
18001
|
-
continue;
|
|
18002
18009
|
updateMemoryVerification2(args.db, w.id, "unverified");
|
|
18003
18010
|
recordVerificationVerdict(args.db, memory, "skip", now, w.fingerprint);
|
|
18004
18011
|
} else if (w.kind === "update") {
|
|
@@ -24248,6 +24255,15 @@ import * as crypto3 from "node:crypto";
|
|
|
24248
24255
|
|
|
24249
24256
|
// ../plugin/src/hooks/magic-context/event-resolvers.ts
|
|
24250
24257
|
var DEFAULT_CONTEXT_LIMIT = 200000;
|
|
24258
|
+
var WRAPUP_WINDOW_UNAVAILABLE = "Cannot run /ctx-wrapup: the model's context window is unknown. Select a model with a configured context window or send a message with that model, then retry.";
|
|
24259
|
+
function readPersistedWrapupWindow(db, sessionId, modelKey) {
|
|
24260
|
+
const { lastUsageContextLimit, lastObservedModelKey } = getOrCreateSessionMeta(db, sessionId);
|
|
24261
|
+
if (!isSaneLimit(lastUsageContextLimit) || !lastObservedModelKey)
|
|
24262
|
+
return;
|
|
24263
|
+
if (modelKey && piModelRefToCanonical(modelKey) !== piModelRefToCanonical(lastObservedModelKey))
|
|
24264
|
+
return;
|
|
24265
|
+
return { contextLimit: lastUsageContextLimit, modelKey: lastObservedModelKey };
|
|
24266
|
+
}
|
|
24251
24267
|
var clampWarnSeen = new Set;
|
|
24252
24268
|
function isFinitePositive(v) {
|
|
24253
24269
|
return typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
@@ -24799,6 +24815,7 @@ var canonicalReasons = new Set([
|
|
|
24799
24815
|
"ttl_idle",
|
|
24800
24816
|
"explicit_flush",
|
|
24801
24817
|
"user_flush",
|
|
24818
|
+
"user_wrapup",
|
|
24802
24819
|
"fit_retry",
|
|
24803
24820
|
"pending_materialization",
|
|
24804
24821
|
"variant_change",
|
|
@@ -36568,7 +36585,7 @@ function injectM0M1Pi(state, db, piMessages, entryIds, recomputeM1ThisPass = fal
|
|
|
36568
36585
|
const m1HasContent = m1 !== PI_M1_PLACEHOLDER;
|
|
36569
36586
|
const { m0Tokens, m1Tokens } = cachedInjectionTokenCounts(state.sessionId, m0, m1);
|
|
36570
36587
|
const m1OverAbsoluteCap = m1HasContent && m1Tokens > m1AbsoluteBudget;
|
|
36571
|
-
if (!materialized && !contentionExhausted && m1Recomputed && recomputeM1ThisPass && (memoryUpdateCount > 40 || m1OverAbsoluteCap || m1HasContent && m0Tokens >= M0_DRIFT_RATIO_FLOOR_TOKENS && m1Tokens > m0Tokens * M1_DRIFT_RATIO)) {
|
|
36588
|
+
if (!materialized && !contentionExhausted && m1Recomputed && recomputeM1ThisPass && !state.skipPressureRefold && (memoryUpdateCount > 40 || m1OverAbsoluteCap || m1HasContent && m0Tokens >= M0_DRIFT_RATIO_FLOOR_TOKENS && m1Tokens > m0Tokens * M1_DRIFT_RATIO)) {
|
|
36572
36589
|
decision = { value: true, reason: "drift" };
|
|
36573
36590
|
try {
|
|
36574
36591
|
const result = materializeM0PiWithRetry(state, db, 3, snapshot);
|
|
@@ -48761,11 +48778,6 @@ function clearSystemPromptRefresh(sessionId) {
|
|
|
48761
48778
|
function hasPendingMaterialization(sessionId) {
|
|
48762
48779
|
return pendingMaterializationSessions.has(sessionId);
|
|
48763
48780
|
}
|
|
48764
|
-
function consumePendingMaterialization(sessionId) {
|
|
48765
|
-
const wasSet = pendingMaterializationSessions.has(sessionId);
|
|
48766
|
-
clearPendingMaterialization(pendingMaterializationSessions, sessionId);
|
|
48767
|
-
return wasSet;
|
|
48768
|
-
}
|
|
48769
48781
|
function resolveSessionId2(ctx) {
|
|
48770
48782
|
const sm = ctx.sessionManager;
|
|
48771
48783
|
if (sm === undefined)
|
|
@@ -50907,7 +50919,7 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
50907
50919
|
inputTokens: usageInputTokens
|
|
50908
50920
|
},
|
|
50909
50921
|
isCacheBusting,
|
|
50910
|
-
userFlushOrigin:
|
|
50922
|
+
userFlushOrigin: hasExplicitRefreshRequest(pendingMaterializationSessions, sessionId),
|
|
50911
50923
|
reasoningClearing: {
|
|
50912
50924
|
keepReasoningTokens: resolveKeepReasoningTokens(options.heuristics?.keepReasoningTokens, resolvePiContextModelKey(ctx)),
|
|
50913
50925
|
nativeReasoningMayClear: canClearNativeReasoning(ctx.model),
|
|
@@ -52323,7 +52335,7 @@ Historian previously failed ${failureCount} time(s), so Magic Context is retryin
|
|
|
52323
52335
|
const trigger = checkCompartmentTrigger(db, sessionId, sessionMeta, usage, 0, triggerInputs.executeThresholdPercentage, triggerInputs.triggerBudget, triggerInputs.keepReasoningTokens, triggerInputs.commitClusterTrigger, args.activeTags, boundaryContextLimit, () => readPiHistorianTail(db, sessionId, provider), args.taggerFloor, { canClearReasoning: true }, {
|
|
52324
52336
|
hardFold: false,
|
|
52325
52337
|
force: usage.percentage >= historianForceMaterializationPercentage && (usage.percentage >= 95 || getEmergencyInputSample(db, sessionId) === 0),
|
|
52326
|
-
explicitFlush:
|
|
52338
|
+
explicitFlush: hasExplicitRefreshRequest(pendingMaterializationSessions, sessionId),
|
|
52327
52339
|
publishedHistory: args.publishedHistoryRide,
|
|
52328
52340
|
permission: {
|
|
52329
52341
|
signedThinkingHold: args.signedThinkingHeld === true,
|
|
@@ -52771,6 +52783,9 @@ async function runPipeline(args) {
|
|
|
52771
52783
|
let publishedM1RefreshedThisPass = false;
|
|
52772
52784
|
let prefixPreflightContended = false;
|
|
52773
52785
|
const softRefreshOpportunity = args.schedulerDecision === "execute";
|
|
52786
|
+
const wrapupPending = hasPendingMaterializationOrigin(pendingMaterializationSessions, args.sessionId, "user_wrapup");
|
|
52787
|
+
if (piM0State)
|
|
52788
|
+
piM0State.skipPressureRefold = wrapupPending;
|
|
52774
52789
|
const cachedPrefixBeforePreflight = piM0State && (foldDueDecision.value || softRefreshOpportunity) && !emergencyDropEligible ? prepareCachedM0M1PiReplay(piM0State, args.db, injectionPassSnapshot?.cachedRow) : undefined;
|
|
52775
52790
|
let preFoldInjectionResult = null;
|
|
52776
52791
|
const persistedM0BeforeFold = injectionPassSnapshot?.sessionMeta ?? args.sessionMeta;
|
|
@@ -52940,7 +52955,7 @@ async function runPipeline(args) {
|
|
|
52940
52955
|
subagentExecute: args.sessionMeta.isSubagent && args.schedulerDecision === "execute",
|
|
52941
52956
|
hardFold: foldBustsServedPrefixThisPass || systemPrefixChangedThisPass || requestToolListChanged || firstRenderBust || isCacheBustingPass,
|
|
52942
52957
|
force: (args.forceMaterialization === true || emergencyDropEligible) && (args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
52943
|
-
explicitFlush: !protectedSignedPrefix && (args.userFlushOrigin === true ||
|
|
52958
|
+
explicitFlush: !protectedSignedPrefix && (args.userFlushOrigin === true || hasExplicitRefreshRequest(pendingMaterializationSessions, args.sessionId)),
|
|
52944
52959
|
publishedHistory: !prefixPreflightContended && publishedM1RefreshedThisPass
|
|
52945
52960
|
};
|
|
52946
52961
|
const ridePermissionGate = {
|
|
@@ -53386,7 +53401,7 @@ async function runPipeline(args) {
|
|
|
53386
53401
|
if (hasPendingMaterializeSignal) {
|
|
53387
53402
|
if (args.heuristics === undefined) {
|
|
53388
53403
|
if (!pendingOps.some((op) => newTargets.get(op.tagId)?.thinkingDropProtected))
|
|
53389
|
-
|
|
53404
|
+
clearReclaimedMaterialization(pendingMaterializationSessions, args.sessionId);
|
|
53390
53405
|
}
|
|
53391
53406
|
}
|
|
53392
53407
|
} catch (err) {
|
|
@@ -53558,7 +53573,7 @@ async function runPipeline(args) {
|
|
|
53558
53573
|
executedWorkThisPass = true;
|
|
53559
53574
|
if (hasPendingMaterializeSignal) {
|
|
53560
53575
|
if (!pendingOps.some((op) => newTargets.get(op.tagId)?.thinkingDropProtected))
|
|
53561
|
-
|
|
53576
|
+
clearReclaimedMaterialization(pendingMaterializationSessions, args.sessionId);
|
|
53562
53577
|
}
|
|
53563
53578
|
if (currentTurnId !== null) {
|
|
53564
53579
|
lastHeuristicsTurnIdBySession.set(args.sessionId, currentTurnId);
|
|
@@ -53884,6 +53899,10 @@ async function runPipeline(args) {
|
|
|
53884
53899
|
}
|
|
53885
53900
|
}
|
|
53886
53901
|
if (!heldHeadReleasedForSystemChange) {
|
|
53902
|
+
if (wrapupPending && isCacheBustingPass && !protectedSignedPrefix && wireInjectionResult.injected && !wireInjectionResult.contentionExhausted) {
|
|
53903
|
+
clearPendingMaterializationOrigin(pendingMaterializationSessions, args.sessionId, "user_wrapup");
|
|
53904
|
+
historyWasConsumedThisPass = true;
|
|
53905
|
+
}
|
|
53887
53906
|
if (args.isCacheBusting && prefixMutationAllowed) {
|
|
53888
53907
|
historyRefreshSessions.delete(args.sessionId);
|
|
53889
53908
|
historyWasConsumedThisPass = true;
|
|
@@ -57058,8 +57077,12 @@ The stored history boundaries no longer match this session branch (${ordinalAlig
|
|
|
57058
57077
|
const unregister = setRawMessageProvider2(sessionId, provider);
|
|
57059
57078
|
let holderId = "";
|
|
57060
57079
|
try {
|
|
57061
|
-
const
|
|
57062
|
-
|
|
57080
|
+
const window = resolvePiWrapupWindow(ctx, deps.db, sessionId);
|
|
57081
|
+
if (!window)
|
|
57082
|
+
return `## Magic Wrapup — Skipped
|
|
57083
|
+
|
|
57084
|
+
${WRAPUP_WINDOW_UNAVAILABLE}`;
|
|
57085
|
+
const { contextLimit, modelKey } = window;
|
|
57063
57086
|
const executeThresholdPercentage = resolveExecuteThreshold(deps.executeThresholdPercentage ?? 65, modelKey, 65, {
|
|
57064
57087
|
tokensConfig: deps.executeThresholdTokens,
|
|
57065
57088
|
contextLimit,
|
|
@@ -57289,9 +57312,14 @@ Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments;
|
|
|
57289
57312
|
try {
|
|
57290
57313
|
clearEmergencyRecovery(deps.db, sessionId);
|
|
57291
57314
|
} catch {}
|
|
57292
|
-
|
|
57315
|
+
let message = `## Magic Wrapup
|
|
57293
57316
|
|
|
57294
|
-
Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments
|
|
57317
|
+
Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments.`;
|
|
57318
|
+
if (compartmentsCreated > 0) {
|
|
57319
|
+
signalPiPendingMaterialization(sessionId, "user_wrapup");
|
|
57320
|
+
message += " The compacted history applies on your next message, or on the next rebuild if the host restarts first.";
|
|
57321
|
+
}
|
|
57322
|
+
return message;
|
|
57295
57323
|
} finally {
|
|
57296
57324
|
clearInterval(renewal);
|
|
57297
57325
|
deps.shutdownSignal?.removeEventListener("abort", stopRenewal);
|
|
@@ -57301,20 +57329,28 @@ Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments.
|
|
|
57301
57329
|
unregister();
|
|
57302
57330
|
}
|
|
57303
57331
|
}
|
|
57304
|
-
function
|
|
57305
|
-
const
|
|
57306
|
-
|
|
57307
|
-
|
|
57308
|
-
|
|
57309
|
-
|
|
57310
|
-
|
|
57311
|
-
|
|
57312
|
-
|
|
57313
|
-
|
|
57314
|
-
|
|
57315
|
-
|
|
57316
|
-
|
|
57317
|
-
|
|
57332
|
+
function resolvePiWrapupWindow(ctx, db, sessionId) {
|
|
57333
|
+
const model = ctx.model;
|
|
57334
|
+
if (!model)
|
|
57335
|
+
return readPersistedWrapupWindow(db, sessionId);
|
|
57336
|
+
const modelKey = `${model.provider}/${model.id}`;
|
|
57337
|
+
const overflow = getOverflowState(db, sessionId, modelKey);
|
|
57338
|
+
const window = {
|
|
57339
|
+
model,
|
|
57340
|
+
detectedContextLimit: overflow.detectedContextLimit
|
|
57341
|
+
};
|
|
57342
|
+
const provenInputTokens = resolvePiProvenInputFloor({
|
|
57343
|
+
db,
|
|
57344
|
+
sessionId,
|
|
57345
|
+
modelKey,
|
|
57346
|
+
readBranch: () => ctx.sessionManager.getBranch(),
|
|
57347
|
+
providerInputLimit: piPressureEvidenceLimit(resolvePiWindowGeometry(window))
|
|
57348
|
+
});
|
|
57349
|
+
const contextLimit = resolvePiUsableContextLimit({
|
|
57350
|
+
...window,
|
|
57351
|
+
provenInputTokens: provenInputTokens || undefined
|
|
57352
|
+
});
|
|
57353
|
+
return contextLimit === undefined ? readPersistedWrapupWindow(db, sessionId, modelKey) : { contextLimit, modelKey };
|
|
57318
57354
|
}
|
|
57319
57355
|
async function acquireCompartmentLeaseEventually(db, sessionId, renewWrapupMarker, maxWaitMs, signal) {
|
|
57320
57356
|
const waitStartedAt = Date.now();
|
|
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
19
19
|
await main();
|
|
20
20
|
async function main() {
|
|
21
21
|
if (input.v2ArchiveReader) {
|
|
22
|
-
const { serveV2ArchiveReads } = await import("./v2-archive-reader-
|
|
22
|
+
const { serveV2ArchiveReads } = await import("./v2-archive-reader-ycw2nxf1.js");
|
|
23
23
|
await serveV2ArchiveReads(port, openConnections);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
51
51
|
await runMessageFtsRowidMapBackfill(db);
|
|
52
52
|
reply = { kind: "fts-rowid-backfill" };
|
|
53
53
|
} else if (input.searchArchive) {
|
|
54
|
-
const { renderSearchArchive } = await import("./search-archive-
|
|
54
|
+
const { renderSearchArchive } = await import("./search-archive-8kcsmnzt.js");
|
|
55
55
|
const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-0tytrjye.js");
|
|
56
56
|
const archive = input.searchArchive;
|
|
57
57
|
let raw;
|
package/dist/subagent-entry.js
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
resolvePiHarnessKind,
|
|
35
35
|
reportSubagentStartupError,
|
|
36
36
|
registerMagicContextTools
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-6t4m64m1.js";
|
|
38
38
|
import"./index-vcegxfwg.js";
|
|
39
39
|
import"./index-5rcjs14a.js";
|
|
40
40
|
import"./index-cxczethe.js";
|
|
@@ -45,14 +45,14 @@ import"./index-9p40dgkm.js";
|
|
|
45
45
|
import"./index-79xfn84y.js";
|
|
46
46
|
import"./index-yhzhdp3m.js";
|
|
47
47
|
import"./index-cevw58nn.js";
|
|
48
|
-
import"./index-
|
|
48
|
+
import"./index-tygcydj7.js";
|
|
49
49
|
import"./index-mm9y1m77.js";
|
|
50
50
|
import"./index-6gwasf0v.js";
|
|
51
51
|
import"./index-6x556c2q.js";
|
|
52
52
|
import"./index-nvh6d3bz.js";
|
|
53
53
|
import"./index-k7a8x7ba.js";
|
|
54
54
|
import"./index-8d2z6503.js";
|
|
55
|
-
import"./index-
|
|
55
|
+
import"./index-mtpsqxev.js";
|
|
56
56
|
import"./index-cyzsn2hb.js";
|
|
57
57
|
import"./index-w2snpk0j.js";
|
|
58
58
|
import"./index-29nw7n1r.js";
|
package/package.json
CHANGED