@cortexkit/opencode-magic-context 0.49.9 → 0.49.11
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 +3 -3
- package/dist/{conflict-warning-hook-w3crzrar.js → conflict-warning-hook-xwkfncav.js} +3 -3
- package/dist/{context-ey3ap3cc.js → context-twz3s0cg.js} +220 -43
- package/dist/{embedding-backfill-3h2m5n0q.js → embedding-backfill-fjbfh1dt.js} +3 -3
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +12 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/memory-enabled.d.ts +5 -0
- package/dist/features/magic-context/memory-enabled.d.ts.map +1 -0
- package/dist/features/magic-context/search-pool-fixture.d.ts +39 -0
- package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +57 -2
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +12 -2
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +5 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/render-options.d.ts +21 -0
- package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +4 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -7
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-pgy3h49n.js → index-0abg88h2.js} +1 -1
- package/dist/{index-0x9cn9w1.js → index-0j6crjgh.js} +2 -2
- package/dist/{index-a43xq1pg.js → index-4ccdr7yw.js} +1 -1
- package/dist/{index-4hb8nt93.js → index-4jkhhpn1.js} +1 -1
- package/dist/{index-ffa8x2as.js → index-84j7jq8a.js} +13 -8
- package/dist/{index-7bjgyaj1.js → index-9159kk15.js} +238 -130
- package/dist/{index-q76br5zn.js → index-bzp9s8z2.js} +24 -19
- package/dist/{index-21919gcq.js → index-g40wgxxt.js} +3 -3
- package/dist/{index-x57ep4fp.js → index-hqnggmxn.js} +215 -75
- package/dist/{index-6k86es2p.js → index-kkvxnbt8.js} +6 -6
- package/dist/{index-nenz4gpb.js → index-q3qck7j2.js} +4 -4
- package/dist/{index-wpwpn7nj.js → index-qr1mkc2y.js} +1 -1
- package/dist/{index-rg1cezmj.js → index-se1w3v2m.js} +1 -1
- package/dist/{index-swgpe402.js → index-xztdf9t7.js} +1 -1
- package/dist/{index-16vwdyy5.js → index-yhrrx7qa.js} +1 -1
- package/dist/{index-3403gbzj.js → index-z7avx6rw.js} +100 -38
- package/dist/index.js +27 -34
- package/dist/{message-index-bounded-fskdyc81.js → message-index-bounded-0rbbg9rd.js} +4 -4
- package/dist/{message-index-6r1x9cqh.js → message-index-ct5x2kwa.js} +4 -4
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-vy7sv9jt.js → project-embedding-registry-ft9gh2e2.js} +2 -2
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{read-session-chunk-zgpvs423.js → read-session-chunk-y3hhsbzw.js} +2 -2
- package/dist/{recomp-orchestrator-77xc8wpe.js → recomp-orchestrator-67k45s0b.js} +11 -11
- package/dist/{search-72fkjwk2.js → search-jd8xh721.js} +8 -8
- package/dist/{send-session-notification-q8ngbap3.js → send-session-notification-vzhj8bsg.js} +2 -2
- package/dist/shared/prompt-surface-runtime.d.ts +5 -0
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-r8d406j0.js → transform-postprocess-phase-pmqxfq4q.js} +11 -11
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/{context-z2yagwy4.js → context-p1zfcw41.js} +599 -225
- package/dist/v2/{embedding-backfill-vr7wdtrf.js → embedding-backfill-xcw3t6hp.js} +5 -5
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-manual.d.ts +1 -0
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +3 -1
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +5 -0
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/transform-decision-binding.d.ts +15 -0
- package/dist/v2/hooks/transform-decision-binding.d.ts.map +1 -0
- package/dist/v2/hooks/transform-features.d.ts +39 -0
- package/dist/v2/hooks/transform-features.d.ts.map +1 -0
- package/dist/v2/{message-index-bounded-rqc603f2.js → message-index-bounded-7wcbp975.js} +5 -5
- package/dist/v2/{message-index-9ezq6wze.js → message-index-cjhv92m2.js} +5 -5
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-ja23aygk.js → project-embedding-registry-g34gcf74.js} +6 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
- package/dist/v2/{read-session-chunk-7f87tg2q.js → read-session-chunk-8d3v87vr.js} +3 -3
- package/dist/v2/{recomp-orchestrator-s5tdpsbs.js → recomp-orchestrator-n0pq36f0.js} +13 -13
- package/dist/v2/{search-2td1b1wy.js → search-a1acjwf8.js} +10 -10
- package/dist/v2/{send-session-notification-6n7chhyp.js → send-session-notification-z5mcjdea.js} +2 -2
- package/dist/v2/{server-4qr18rfg.js → server-5x7kmyz8.js} +1 -1
- package/dist/v2/{server-c9w52qss.js → server-7fvmt15t.js} +109 -38
- package/dist/v2/{server-44ryn9rb.js → server-83d71zab.js} +1 -1
- package/dist/v2/{server-z0rjemg1.js → server-d3f4g62c.js} +2 -2
- package/dist/v2/{server-zrwaj29a.js → server-d6t16r89.js} +24 -19
- package/dist/v2/{server-23znwjqk.js → server-erfp0xb6.js} +5 -2
- package/dist/v2/{server-9a6bwc12.js → server-ewqshbs8.js} +251 -131
- package/dist/v2/{server-ak7w74j9.js → server-h3wc20sv.js} +1 -1
- package/dist/v2/{server-7e087rvk.js → server-jc8v585p.js} +1 -1
- package/dist/v2/{server-4zwx20yg.js → server-kn7skz9r.js} +1 -1
- package/dist/v2/{server-2hxypdx5.js → server-pbpp8r8h.js} +13 -8
- package/dist/v2/{server-4rs8sm06.js → server-rxcq4t50.js} +3 -3
- package/dist/v2/{server-4easnf78.js → server-sg68np13.js} +13 -4
- package/dist/v2/{server-gc8x2xdb.js → server-wkhfyzpg.js} +2 -2
- package/dist/v2/server.js +4 -4
- package/dist/v2/store-reader.d.ts +4 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-wg8dmmm9.js → wrapup-orchestrator-87q9d5e2.js} +13 -13
- package/dist/{wrapup-orchestrator-b1z99yg5.js → wrapup-orchestrator-jqapepw0.js} +12 -12
- package/package.json +1 -1
- package/src/shared/chunk-vector-writer-guard.test.ts +72 -0
- package/src/shared/prompt-surface-runtime.test.ts +15 -0
- package/src/shared/prompt-surface-runtime.ts +12 -0
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
drainCommitBacklogForProject2,
|
|
82
82
|
embedSessionCompartmentChunks2,
|
|
83
83
|
getEmbeddingCoverageStatus2
|
|
84
|
-
} from "./index-
|
|
84
|
+
} from "./index-se1w3v2m.js";
|
|
85
85
|
import {
|
|
86
86
|
hasTrustedAbsoluteWall,
|
|
87
87
|
applyProvenInputFloor,
|
|
@@ -175,7 +175,7 @@ import {
|
|
|
175
175
|
latestPersistedMessageForRecovery,
|
|
176
176
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
177
177
|
findLastAssistantModelFromOpenCodeDb
|
|
178
|
-
} from "./index-
|
|
178
|
+
} from "./index-bzp9s8z2.js";
|
|
179
179
|
import {
|
|
180
180
|
expandToolPart,
|
|
181
181
|
estimateTrueRawMessageTokens,
|
|
@@ -296,7 +296,7 @@ import {
|
|
|
296
296
|
readRawSessionMessageById2,
|
|
297
297
|
readSessionChunk2,
|
|
298
298
|
readRawSessionSeedTail2
|
|
299
|
-
} from "./index-
|
|
299
|
+
} from "./index-qr1mkc2y.js";
|
|
300
300
|
import {
|
|
301
301
|
getMeasuredToolDefinitionTokens
|
|
302
302
|
} from "./index-9jvab89d.js";
|
|
@@ -327,7 +327,7 @@ import {
|
|
|
327
327
|
runSqliteOptimize,
|
|
328
328
|
openDatabase,
|
|
329
329
|
openCurrentDatabase
|
|
330
|
-
} from "./index-
|
|
330
|
+
} from "./index-xztdf9t7.js";
|
|
331
331
|
import {
|
|
332
332
|
registerOwnRpcServerInstance,
|
|
333
333
|
rpcPortDir,
|
|
@@ -362,6 +362,7 @@ import {
|
|
|
362
362
|
loadPluginConfigDetailed,
|
|
363
363
|
historianRunConfig,
|
|
364
364
|
currentPluginConfigReader,
|
|
365
|
+
isProjectMemoryEnabled,
|
|
365
366
|
clampProducerAtomChars,
|
|
366
367
|
producerInputTokenLimit,
|
|
367
368
|
historianProducerReserve,
|
|
@@ -457,7 +458,7 @@ import {
|
|
|
457
458
|
failedInvocationStatus,
|
|
458
459
|
recordChildInvocation,
|
|
459
460
|
createPromptAsyncTransport,
|
|
460
|
-
|
|
461
|
+
systemPromptFingerprint,
|
|
461
462
|
createPromptSurfaceRuntime,
|
|
462
463
|
createPromptSurfaceGuidanceEpochCache,
|
|
463
464
|
teardownChildSession,
|
|
@@ -520,7 +521,7 @@ import {
|
|
|
520
521
|
snapRangeToCompartments,
|
|
521
522
|
getActiveCompartmentRun,
|
|
522
523
|
startCompartmentAgent
|
|
523
|
-
} from "./index-
|
|
524
|
+
} from "./index-z7avx6rw.js";
|
|
524
525
|
import {
|
|
525
526
|
SubcClient,
|
|
526
527
|
connectionFileExists,
|
|
@@ -549,7 +550,7 @@ import {
|
|
|
549
550
|
indexSingleMessage2,
|
|
550
551
|
indexMessagesAfterOrdinal2,
|
|
551
552
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
552
|
-
} from "./index-
|
|
553
|
+
} from "./index-0j6crjgh.js";
|
|
553
554
|
import {
|
|
554
555
|
renderUserFacingFailure,
|
|
555
556
|
userFacingFailureCode,
|
|
@@ -593,7 +594,7 @@ import {
|
|
|
593
594
|
readGitFileChangeTimesSince,
|
|
594
595
|
verificationFileExists,
|
|
595
596
|
normalizeVerificationFiles
|
|
596
|
-
} from "./index-
|
|
597
|
+
} from "./index-yhrrx7qa.js";
|
|
597
598
|
import {
|
|
598
599
|
registerNotificationSink2,
|
|
599
600
|
pushNotification2,
|
|
@@ -611,7 +612,7 @@ import {
|
|
|
611
612
|
} from "./index-4dhv7mqz.js";
|
|
612
613
|
import {
|
|
613
614
|
cosineSimilarity
|
|
614
|
-
} from "./index-
|
|
615
|
+
} from "./index-4ccdr7yw.js";
|
|
615
616
|
import {
|
|
616
617
|
computeCueContentHash,
|
|
617
618
|
hasMuralCueColumns,
|
|
@@ -658,17 +659,17 @@ import {
|
|
|
658
659
|
resolveMemoriesByIdsForSearch2,
|
|
659
660
|
unifiedSearch2,
|
|
660
661
|
formatSearchResults2
|
|
661
|
-
} from "./index-
|
|
662
|
+
} from "./index-84j7jq8a.js";
|
|
662
663
|
import {
|
|
663
664
|
flushIgnoredMessages2,
|
|
664
665
|
clearIgnoredMessages2,
|
|
665
666
|
observeIgnoredNotificationEvent2,
|
|
666
667
|
sendStatusNotification2
|
|
667
|
-
} from "./index-
|
|
668
|
+
} from "./index-0abg88h2.js";
|
|
668
669
|
import {
|
|
669
670
|
setRecompStarting2,
|
|
670
671
|
setRecompTerminal2
|
|
671
|
-
} from "./index-
|
|
672
|
+
} from "./index-g40wgxxt.js";
|
|
672
673
|
import {
|
|
673
674
|
makeToolCompositeKey,
|
|
674
675
|
searchMessageHistoryOffThread,
|
|
@@ -719,7 +720,7 @@ import {
|
|
|
719
720
|
abortSessionFailClosed2,
|
|
720
721
|
evaluateEmergencyFailClosed2,
|
|
721
722
|
runPostTransformPhase2
|
|
722
|
-
} from "./index-
|
|
723
|
+
} from "./index-kkvxnbt8.js";
|
|
723
724
|
import {
|
|
724
725
|
ANNOUNCEMENT_VERSION2,
|
|
725
726
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -10950,6 +10951,8 @@ async function runManualDream(deps) {
|
|
|
10950
10951
|
} else {
|
|
10951
10952
|
selected = deps.tasks.filter((t) => t.schedule.trim() !== "");
|
|
10952
10953
|
}
|
|
10954
|
+
if (!isProjectMemoryEnabled(deps.projectMemoryEnabled))
|
|
10955
|
+
selected = selected.filter((config) => config.task === "evaluate-smart-notes");
|
|
10953
10956
|
if (selected.length === 0)
|
|
10954
10957
|
return result;
|
|
10955
10958
|
const selectedTaskNames = selected.map((config) => config.task);
|
|
@@ -11015,7 +11018,7 @@ async function runManualDream(deps) {
|
|
|
11015
11018
|
async function runDueTasksForProject(deps) {
|
|
11016
11019
|
if (!isUsableProjectIdentity(deps.projectIdentity))
|
|
11017
11020
|
return 0;
|
|
11018
|
-
if (deps.projectMemoryEnabled
|
|
11021
|
+
if (!isProjectMemoryEnabled(deps.projectMemoryEnabled))
|
|
11019
11022
|
return 0;
|
|
11020
11023
|
const now = deps.now ?? Date.now();
|
|
11021
11024
|
const due = planDueTasks(deps.db, deps.projectIdentity, deps.tasks, now);
|
|
@@ -11648,7 +11651,7 @@ function scheduleInitialProjectRun(reg, db) {
|
|
|
11648
11651
|
async function runProjectMaintenance(reg, origin, db) {
|
|
11649
11652
|
const sampled = reg.sampleDreamRun?.();
|
|
11650
11653
|
const current = sampled ? { ...reg, ...sampled } : reg;
|
|
11651
|
-
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true ||
|
|
11654
|
+
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || current.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
11652
11655
|
if (!projectMaintenanceEnabled)
|
|
11653
11656
|
return;
|
|
11654
11657
|
await reg.ensureRegistered(reg.directory, db);
|
|
@@ -11659,7 +11662,7 @@ async function runProjectMaintenance(reg, origin, db) {
|
|
|
11659
11662
|
log2(`[magic-context] proactively embedded ${embeddedCount} ${embeddedCount === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
|
|
11660
11663
|
}
|
|
11661
11664
|
}
|
|
11662
|
-
await sweepProject(current, origin, db);
|
|
11665
|
+
await sweepProject(current, origin, db, current.gitCommitIndexing?.enabled === true);
|
|
11663
11666
|
}
|
|
11664
11667
|
async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
11665
11668
|
if (!directoryStillExists(reg.directory)) {
|
|
@@ -11864,6 +11867,15 @@ async function sweepGitCommits(args) {
|
|
|
11864
11867
|
}
|
|
11865
11868
|
}
|
|
11866
11869
|
|
|
11870
|
+
// src/plugin/dream-timer-module-client.ts
|
|
11871
|
+
function createDreamTimerModuleClient(moduleClient) {
|
|
11872
|
+
if (!moduleClient)
|
|
11873
|
+
return;
|
|
11874
|
+
return {
|
|
11875
|
+
call: (args) => moduleClient.call(args)
|
|
11876
|
+
};
|
|
11877
|
+
}
|
|
11878
|
+
|
|
11867
11879
|
// src/plugin/embedding-bootstrap.ts
|
|
11868
11880
|
import { readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
|
|
11869
11881
|
|
|
@@ -15972,8 +15984,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
15972
15984
|
const db = readDatabase();
|
|
15973
15985
|
if (!db)
|
|
15974
15986
|
return { ok: false, error: "db unavailable" };
|
|
15975
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
15976
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
15987
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-67k45s0b.js"));
|
|
15988
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-vzhj8bsg.js"));
|
|
15977
15989
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
15978
15990
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
15979
15991
|
return {
|
|
@@ -16057,7 +16069,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16057
16069
|
const db = readDatabase();
|
|
16058
16070
|
if (!db)
|
|
16059
16071
|
return { ok: false, error: "db unavailable" };
|
|
16060
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16072
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-jqapepw0.js"));
|
|
16061
16073
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16062
16074
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16063
16075
|
const ctx = {
|
|
@@ -16178,6 +16190,11 @@ var pendingDecisionBySession = new Map;
|
|
|
16178
16190
|
var pendingPiDecisionBySession = new Map;
|
|
16179
16191
|
var lastBoundMessageIdBySession = new Map;
|
|
16180
16192
|
var scheduledWriteTokensBySession = new Map;
|
|
16193
|
+
var systemHashChangedSessions = new Set;
|
|
16194
|
+
var piSystemHashChangedSessions = new Set;
|
|
16195
|
+
var unbustedPassBySession = new Map;
|
|
16196
|
+
var newestInputAssistantBySession = new Map;
|
|
16197
|
+
var stagedV2DecisionBySession = new Map;
|
|
16181
16198
|
var writerOverrideForTests = null;
|
|
16182
16199
|
var retentionOverrideForTests = null;
|
|
16183
16200
|
function normalizeMaterializeReason(harness, reason, rematerialized) {
|
|
@@ -16219,14 +16236,73 @@ function writeRustTransformDecision(args) {
|
|
|
16219
16236
|
lkgFrozenReleaseReason: args.lkgFrozenReleaseReason
|
|
16220
16237
|
});
|
|
16221
16238
|
}
|
|
16222
|
-
function clearOpenCodePendingTransformDecision(sessionId) {
|
|
16239
|
+
function clearOpenCodePendingTransformDecision(sessionId, inputMessages) {
|
|
16223
16240
|
pendingDecisionBySession.delete(sessionId);
|
|
16241
|
+
unbustedPassBySession.delete(sessionId);
|
|
16242
|
+
if (!inputMessages)
|
|
16243
|
+
return;
|
|
16244
|
+
let newestAssistant = "";
|
|
16245
|
+
for (const message of inputMessages) {
|
|
16246
|
+
const id = message.info?.id;
|
|
16247
|
+
if (message.info?.role !== "assistant" || typeof id !== "string")
|
|
16248
|
+
continue;
|
|
16249
|
+
if (id > newestAssistant)
|
|
16250
|
+
newestAssistant = id;
|
|
16251
|
+
}
|
|
16252
|
+
newestInputAssistantBySession.set(sessionId, newestAssistant);
|
|
16224
16253
|
}
|
|
16225
16254
|
function clearTransformDecisionSession(sessionId) {
|
|
16226
16255
|
pendingDecisionBySession.delete(sessionId);
|
|
16227
16256
|
pendingPiDecisionBySession.delete(sessionId);
|
|
16228
16257
|
lastBoundMessageIdBySession.delete(sessionId);
|
|
16229
16258
|
scheduledWriteTokensBySession.delete(sessionId);
|
|
16259
|
+
systemHashChangedSessions.delete(sessionId);
|
|
16260
|
+
piSystemHashChangedSessions.delete(sessionId);
|
|
16261
|
+
unbustedPassBySession.delete(sessionId);
|
|
16262
|
+
newestInputAssistantBySession.delete(sessionId);
|
|
16263
|
+
stagedV2DecisionBySession.delete(sessionId);
|
|
16264
|
+
}
|
|
16265
|
+
function noteSystemPromptHashChange(sessionId) {
|
|
16266
|
+
systemHashChangedSessions.add(sessionId);
|
|
16267
|
+
}
|
|
16268
|
+
function noteOpenCodeUnbustedPass(sessionId, decision) {
|
|
16269
|
+
unbustedPassBySession.set(sessionId, decision);
|
|
16270
|
+
}
|
|
16271
|
+
var IDLE_EXPIRY_REASONS = new Set([
|
|
16272
|
+
"ttl_idle",
|
|
16273
|
+
"ttl_expiry"
|
|
16274
|
+
]);
|
|
16275
|
+
function withSystemHashReason(decision) {
|
|
16276
|
+
if (IDLE_EXPIRY_REASONS.has(decision.materializeReason))
|
|
16277
|
+
return decision;
|
|
16278
|
+
return { ...decision, materializeReason: "system_hash" };
|
|
16279
|
+
}
|
|
16280
|
+
function unknownPassDecision() {
|
|
16281
|
+
return {
|
|
16282
|
+
tsMs: Date.now(),
|
|
16283
|
+
decision: "unknown",
|
|
16284
|
+
materialized: false,
|
|
16285
|
+
materializeReason: null,
|
|
16286
|
+
systemHashPrev: null,
|
|
16287
|
+
systemHashNew: null,
|
|
16288
|
+
m0ModelKeyPrev: null,
|
|
16289
|
+
m0ModelKeyNew: null,
|
|
16290
|
+
emergency: false,
|
|
16291
|
+
droppedTokens: 0,
|
|
16292
|
+
droppedCount: 0,
|
|
16293
|
+
inputTokens: 0,
|
|
16294
|
+
bustedThisPass: false
|
|
16295
|
+
};
|
|
16296
|
+
}
|
|
16297
|
+
function takeOpenCodeDecisionForBinding(sessionId, applySystemHashChange) {
|
|
16298
|
+
const pending = pendingDecisionBySession.get(sessionId);
|
|
16299
|
+
const unbusted = unbustedPassBySession.get(sessionId);
|
|
16300
|
+
pendingDecisionBySession.delete(sessionId);
|
|
16301
|
+
unbustedPassBySession.delete(sessionId);
|
|
16302
|
+
if (!applySystemHashChange || !systemHashChangedSessions.has(sessionId))
|
|
16303
|
+
return pending;
|
|
16304
|
+
systemHashChangedSessions.delete(sessionId);
|
|
16305
|
+
return withSystemHashReason(pending ?? unbusted ?? unknownPassDecision());
|
|
16230
16306
|
}
|
|
16231
16307
|
function recordPendingTransformDecision(sessionId, decision) {
|
|
16232
16308
|
if (!decision.bustedThisPass) {
|
|
@@ -16236,8 +16312,9 @@ function recordPendingTransformDecision(sessionId, decision) {
|
|
|
16236
16312
|
pendingDecisionBySession.set(sessionId, decision);
|
|
16237
16313
|
}
|
|
16238
16314
|
function scheduleOpenCodeTransformDecisionWrite(args) {
|
|
16239
|
-
const
|
|
16240
|
-
|
|
16315
|
+
const newestInput = newestInputAssistantBySession.get(args.sessionId) ?? "";
|
|
16316
|
+
const systemHashChanged = args.messageId > newestInput && systemHashChangedSessions.has(args.sessionId);
|
|
16317
|
+
if (!pendingDecisionBySession.has(args.sessionId) && !systemHashChanged)
|
|
16241
16318
|
return false;
|
|
16242
16319
|
if (lastBoundMessageIdBySession.get(args.sessionId) === args.messageId) {
|
|
16243
16320
|
return false;
|
|
@@ -16245,8 +16322,10 @@ function scheduleOpenCodeTransformDecisionWrite(args) {
|
|
|
16245
16322
|
const dbPath = getDatabasePath(args.db);
|
|
16246
16323
|
if (!dbPath)
|
|
16247
16324
|
return false;
|
|
16325
|
+
const pending = takeOpenCodeDecisionForBinding(args.sessionId, systemHashChanged);
|
|
16326
|
+
if (!pending)
|
|
16327
|
+
return false;
|
|
16248
16328
|
lastBoundMessageIdBySession.set(args.sessionId, args.messageId);
|
|
16249
|
-
pendingDecisionBySession.delete(args.sessionId);
|
|
16250
16329
|
const token = addScheduledWriteToken(args.sessionId);
|
|
16251
16330
|
inRootAsyncContext2(() => setTimeout(() => {
|
|
16252
16331
|
try {
|
|
@@ -16265,6 +16344,54 @@ function scheduleOpenCodeTransformDecisionWrite(args) {
|
|
|
16265
16344
|
}, 0));
|
|
16266
16345
|
return true;
|
|
16267
16346
|
}
|
|
16347
|
+
function stageOpenCodeV2TransformDecision(args) {
|
|
16348
|
+
const systemHashChanged = systemHashChangedSessions.has(args.sessionId);
|
|
16349
|
+
const decision = takeOpenCodeDecisionForBinding(args.sessionId, true);
|
|
16350
|
+
stagedV2DecisionBySession.delete(args.sessionId);
|
|
16351
|
+
if (!decision || args.responseAfterSequence === undefined)
|
|
16352
|
+
return false;
|
|
16353
|
+
if (!decision.bustedThisPass && !systemHashChanged)
|
|
16354
|
+
return false;
|
|
16355
|
+
stagedV2DecisionBySession.set(args.sessionId, {
|
|
16356
|
+
decision,
|
|
16357
|
+
responseAfterSequence: args.responseAfterSequence
|
|
16358
|
+
});
|
|
16359
|
+
return true;
|
|
16360
|
+
}
|
|
16361
|
+
function bindOpenCodeV2TransformDecision(args) {
|
|
16362
|
+
const staged = stagedV2DecisionBySession.get(args.sessionId);
|
|
16363
|
+
if (!staged)
|
|
16364
|
+
return false;
|
|
16365
|
+
const reply = args.firstAssistantAfter(staged.responseAfterSequence);
|
|
16366
|
+
if (!reply || reply.state === "running") {
|
|
16367
|
+
if (args.passStarting)
|
|
16368
|
+
stagedV2DecisionBySession.delete(args.sessionId);
|
|
16369
|
+
return false;
|
|
16370
|
+
}
|
|
16371
|
+
stagedV2DecisionBySession.delete(args.sessionId);
|
|
16372
|
+
if (reply.state === "failed")
|
|
16373
|
+
return false;
|
|
16374
|
+
const dbPath = getDatabasePath(args.db);
|
|
16375
|
+
if (!dbPath)
|
|
16376
|
+
return false;
|
|
16377
|
+
const token = addScheduledWriteToken(args.sessionId);
|
|
16378
|
+
inRootAsyncContext2(() => setTimeout(() => {
|
|
16379
|
+
try {
|
|
16380
|
+
if (!hasScheduledWriteToken(args.sessionId, token))
|
|
16381
|
+
return;
|
|
16382
|
+
writeTransformDecisionBestEffort(dbPath, {
|
|
16383
|
+
...staged.decision,
|
|
16384
|
+
sessionId: args.sessionId,
|
|
16385
|
+
harness: "opencode2",
|
|
16386
|
+
messageId: reply.id,
|
|
16387
|
+
inputTokens: Number.isFinite(reply.inputTokens) ? reply.inputTokens : staged.decision.inputTokens
|
|
16388
|
+
});
|
|
16389
|
+
} finally {
|
|
16390
|
+
deleteScheduledWriteToken(args.sessionId, token);
|
|
16391
|
+
}
|
|
16392
|
+
}, 0));
|
|
16393
|
+
return true;
|
|
16394
|
+
}
|
|
16268
16395
|
function addScheduledWriteToken(sessionId) {
|
|
16269
16396
|
const token = Symbol(sessionId);
|
|
16270
16397
|
let tokens = scheduledWriteTokensBySession.get(sessionId);
|
|
@@ -16807,6 +16934,36 @@ function createPassOutcome() {
|
|
|
16807
16934
|
};
|
|
16808
16935
|
}
|
|
16809
16936
|
|
|
16937
|
+
// src/hooks/magic-context/render-options.ts
|
|
16938
|
+
function createM0RenderOptions(controls, contextUsage, modelKey, resolvedContextLimit, projectPath) {
|
|
16939
|
+
return {
|
|
16940
|
+
projectPath: controls.memoryConfig?.enabled ? projectPath : undefined,
|
|
16941
|
+
memoryEnabled: controls.memoryConfig?.enabled,
|
|
16942
|
+
memoryInjectionBudgetTokens: controls.memoryConfig?.injectionBudgetTokens,
|
|
16943
|
+
injectDocs: controls.injectDocs,
|
|
16944
|
+
muralEnabled: controls.muralEnabled,
|
|
16945
|
+
temporalAwareness: controls.experimentalTemporalAwareness,
|
|
16946
|
+
historyBudgetTokens: resolveHistoryBudgetTokens(controls.historyBudgetPercentage, contextUsage, controls.executeThresholdPercentage, modelKey, controls.executeThresholdTokens, resolvedContextLimit),
|
|
16947
|
+
historyBudgetPolicyIdentity: historyBudgetPolicyIdentity(controls.historyBudgetPercentage, controls.executeThresholdPercentage, modelKey, controls.executeThresholdTokens)
|
|
16948
|
+
};
|
|
16949
|
+
}
|
|
16950
|
+
function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, executeThresholdPercentage, modelKey, executeThresholdTokens, resolvedContextLimit) {
|
|
16951
|
+
if (!historyBudgetPercentage)
|
|
16952
|
+
return;
|
|
16953
|
+
let contextLimit = resolvedContextLimit && resolvedContextLimit > 0 ? resolvedContextLimit : 0;
|
|
16954
|
+
if (contextLimit <= 0) {
|
|
16955
|
+
if (contextUsage.percentage <= 0)
|
|
16956
|
+
return;
|
|
16957
|
+
contextLimit = contextUsage.inputTokens / (contextUsage.percentage / 100);
|
|
16958
|
+
}
|
|
16959
|
+
if (!Number.isFinite(contextLimit) || contextLimit <= 0)
|
|
16960
|
+
return;
|
|
16961
|
+
return Math.floor(contextLimit * (resolveExecuteThreshold(executeThresholdPercentage ?? 65, modelKey, 65, {
|
|
16962
|
+
tokensConfig: executeThresholdTokens,
|
|
16963
|
+
contextLimit
|
|
16964
|
+
}) / 100) * historyBudgetPercentage);
|
|
16965
|
+
}
|
|
16966
|
+
|
|
16810
16967
|
// src/hooks/magic-context/rust-mode-transform.ts
|
|
16811
16968
|
import { createHash as createHash12, randomUUID as randomUUID6 } from "node:crypto";
|
|
16812
16969
|
|
|
@@ -23504,7 +23661,7 @@ function createTransform(deps) {
|
|
|
23504
23661
|
return historianRun?.toastDurationMs === undefined ? params : { ...params, toastDurationMs: historianRun.toastDurationMs };
|
|
23505
23662
|
};
|
|
23506
23663
|
beginLkgPass(sessionId);
|
|
23507
|
-
clearOpenCodePendingTransformDecision(sessionId);
|
|
23664
|
+
clearOpenCodePendingTransformDecision(sessionId, messages);
|
|
23508
23665
|
const db = deps.db;
|
|
23509
23666
|
try {
|
|
23510
23667
|
const tPrepare = performance.now();
|
|
@@ -23871,9 +24028,10 @@ function createTransform(deps) {
|
|
|
23871
24028
|
const persistedUsageFreshForBoundary = persistedUsageBeforeResets && Date.now() - persistedUsageBeforeResets.updatedAt <= 10 * 60 * 1000 && (persistedUsageBeforeResets.lastObservedModelKey === null || currentModelKeyForBoundary === undefined || piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) === piModelRefToCanonical(currentModelKeyForBoundary)) && (resolvedContextLimit === undefined || persistedUsageBeforeResets.lastUsageContextLimit === 0 || persistedUsageBeforeResets.lastUsageContextLimit === resolvedContextLimit) ? persistedUsageBeforeResets.usage : null;
|
|
23872
24029
|
const boundaryUsageForProtectedTail = persistedUsageFreshForBoundary ?? contextUsageEarly;
|
|
23873
24030
|
const boundaryUsageSource = persistedUsageFreshForBoundary ? "persisted" : "live";
|
|
23874
|
-
const historyPolicyIdentity = historyBudgetPolicyIdentity(deps.historyBudgetPercentage, deps.executeThresholdPercentage, currentModelKeyForBoundary, deps.executeThresholdTokens);
|
|
23875
24031
|
const historyContextLimit = resolvedContextLimit ?? (currentModelKeyForBoundary && persistedUsageBeforeResets?.lastObservedModelKey && piModelRefToCanonical(currentModelKeyForBoundary) === piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) && persistedUsageBeforeResets.lastUsageContextLimit > 0 ? persistedUsageBeforeResets.lastUsageContextLimit : undefined);
|
|
23876
|
-
const
|
|
24032
|
+
const memoryProjectDirectory = compartmentDirectory || process.cwd();
|
|
24033
|
+
const renderOptions = createM0RenderOptions(deps, contextUsageEarly, currentModelKeyForBoundary, historyContextLimit, deps.memoryConfig?.enabled ? resolveProjectIdentityForSession(memoryProjectDirectory, deps.allowHomeProject) : undefined);
|
|
24034
|
+
const { historyBudgetTokens, projectPath: projectIdentity } = renderOptions;
|
|
23877
24035
|
const emergencyCeilingLimit = thresholdContextLimit ?? 0;
|
|
23878
24036
|
const emergencyCeilingTokens = Number.isFinite(emergencyCeilingLimit) && emergencyCeilingLimit > 0 ? Math.floor(emergencyCeilingLimit * (effectiveExecuteThresholdPercentage / 100)) : undefined;
|
|
23879
24037
|
const schedulerDecision = compactionOff ? "defer" : resolveSchedulerDecision(deps.scheduler, sessionMeta, contextUsageEarly, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit);
|
|
@@ -24007,8 +24165,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24007
24165
|
});
|
|
24008
24166
|
}
|
|
24009
24167
|
logTransformTiming(sessionId, "emergencyRecoveryBlock", tFirstPass);
|
|
24010
|
-
const memoryProjectDirectory = compartmentDirectory || process.cwd();
|
|
24011
|
-
const projectIdentity = deps.memoryConfig?.enabled ? resolveProjectIdentityForSession(memoryProjectDirectory, deps.allowHomeProject) : undefined;
|
|
24012
24168
|
if (deps.memoryConfig?.enabled) {
|
|
24013
24169
|
maybeSendProjectIdentityWarning(deps, sessionId, memoryProjectDirectory, notificationParams);
|
|
24014
24170
|
}
|
|
@@ -24293,14 +24449,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24293
24449
|
db,
|
|
24294
24450
|
sessionId,
|
|
24295
24451
|
state: sessionMeta,
|
|
24296
|
-
projectPath: projectIdentity,
|
|
24297
24452
|
projectDirectory: sessionDirectory,
|
|
24298
|
-
|
|
24299
|
-
memoryEnabled: deps.memoryConfig?.enabled,
|
|
24300
|
-
muralEnabled: deps.muralEnabled,
|
|
24301
|
-
memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
|
|
24302
|
-
historyBudgetTokens,
|
|
24303
|
-
historyBudgetPolicyIdentity: historyPolicyIdentity,
|
|
24453
|
+
...renderOptions,
|
|
24304
24454
|
hardSignals: m0HardSignals
|
|
24305
24455
|
}).value;
|
|
24306
24456
|
const protectionCacheBustingPass = !compactionOff && (schedulerDecision === "execute" || isCacheBusting || contextUsage.percentage >= forceMaterializationPercentage || deps.pendingMaterializationSessions.has(sessionId) || canConsumeDeferredLate && deferredMaterializationSessions.has(sessionId) || protectionFoldWillBust);
|
|
@@ -24441,16 +24591,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24441
24591
|
passOutcome,
|
|
24442
24592
|
historyRefreshSessions: deps.historyRefreshSessions,
|
|
24443
24593
|
m0M1: {
|
|
24444
|
-
projectPath: projectIdentity,
|
|
24445
24594
|
projectDirectory: sessionDirectory,
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
|
|
24449
|
-
historyBudgetTokens,
|
|
24450
|
-
historyBudgetPolicyIdentity: historyPolicyIdentity,
|
|
24451
|
-
temporalAwareness: deps.experimentalTemporalAwareness,
|
|
24452
|
-
hardSignals: m0HardSignals,
|
|
24453
|
-
muralEnabled: deps.muralEnabled
|
|
24595
|
+
...renderOptions,
|
|
24596
|
+
hardSignals: m0HardSignals
|
|
24454
24597
|
}
|
|
24455
24598
|
});
|
|
24456
24599
|
if (recovery.prefix && !recoveryNormalized) {
|
|
@@ -24694,6 +24837,24 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24694
24837
|
bustedThisPass: true,
|
|
24695
24838
|
lkgFrozenReleaseReason: recoveryReleaseReason
|
|
24696
24839
|
});
|
|
24840
|
+
} else {
|
|
24841
|
+
noteOpenCodeUnbustedPass(sessionId, {
|
|
24842
|
+
tsMs: Date.now(),
|
|
24843
|
+
decision: schedulerDecision,
|
|
24844
|
+
materialized: postTransformResult.materialized,
|
|
24845
|
+
materializeReason: normalizeMaterializeReason("opencode", postTransformResult.materializeReason, postTransformResult.materialized),
|
|
24846
|
+
systemHashPrev: postTransformResult.systemHashPrev,
|
|
24847
|
+
systemHashNew: postTransformResult.systemHashNew,
|
|
24848
|
+
m0ToolSetHashPrev: postTransformResult.m0ToolSetHashPrev,
|
|
24849
|
+
m0ToolSetHashNew: postTransformResult.m0ToolSetHashNew,
|
|
24850
|
+
m0ModelKeyPrev: postTransformResult.m0ModelKeyPrev,
|
|
24851
|
+
m0ModelKeyNew: postTransformResult.m0ModelKeyNew,
|
|
24852
|
+
emergency: postTransformResult.emergency,
|
|
24853
|
+
droppedTokens: postTransformResult.droppedTokens,
|
|
24854
|
+
droppedCount: postTransformResult.droppedCount,
|
|
24855
|
+
inputTokens: contextUsage.inputTokens,
|
|
24856
|
+
bustedThisPass: false
|
|
24857
|
+
});
|
|
24697
24858
|
}
|
|
24698
24859
|
logTransformTiming(sessionId, "postTransformPhase", tPostProcess);
|
|
24699
24860
|
const msgTokens = getMessageTokensCache(sessionId);
|
|
@@ -24824,25 +24985,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24824
24985
|
}
|
|
24825
24986
|
});
|
|
24826
24987
|
}
|
|
24827
|
-
function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, executeThresholdPercentage, modelKey, executeThresholdTokens, resolvedContextLimit) {
|
|
24828
|
-
if (!historyBudgetPercentage) {
|
|
24829
|
-
return;
|
|
24830
|
-
}
|
|
24831
|
-
let contextLimit = resolvedContextLimit && resolvedContextLimit > 0 ? resolvedContextLimit : 0;
|
|
24832
|
-
if (contextLimit <= 0) {
|
|
24833
|
-
if (contextUsage.percentage <= 0) {
|
|
24834
|
-
return;
|
|
24835
|
-
}
|
|
24836
|
-
contextLimit = contextUsage.inputTokens / (contextUsage.percentage / 100);
|
|
24837
|
-
}
|
|
24838
|
-
if (!Number.isFinite(contextLimit) || contextLimit <= 0) {
|
|
24839
|
-
return;
|
|
24840
|
-
}
|
|
24841
|
-
return Math.floor(contextLimit * (resolveExecuteThreshold(executeThresholdPercentage ?? 65, modelKey, 65, {
|
|
24842
|
-
tokensConfig: executeThresholdTokens,
|
|
24843
|
-
contextLimit
|
|
24844
|
-
}) / 100) * historyBudgetPercentage);
|
|
24845
|
-
}
|
|
24846
24988
|
|
|
24847
24989
|
// src/hooks/magic-context/module-client.ts
|
|
24848
24990
|
function createSubcModuleClient(options) {
|
|
@@ -25022,9 +25164,6 @@ function createRustRefusalRecovery(options) {
|
|
|
25022
25164
|
};
|
|
25023
25165
|
}
|
|
25024
25166
|
|
|
25025
|
-
// src/hooks/magic-context/system-prompt-hash.ts
|
|
25026
|
-
import { createHash as createHash13 } from "node:crypto";
|
|
25027
|
-
|
|
25028
25167
|
// src/hooks/magic-context/system-prompt-dates.ts
|
|
25029
25168
|
function replaceHostDates(prompt, replace) {
|
|
25030
25169
|
const fields = /<(plugin-env|environment|env)>[\s\S]*?<\/\1>|Today's date: [^\r\n<]+/g;
|
|
@@ -25136,7 +25275,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25136
25275
|
const dates = systemPromptDates(liveSystemContent, stickyDate);
|
|
25137
25276
|
const currentDate = dates.live;
|
|
25138
25277
|
const stableCandidate = dates.stable;
|
|
25139
|
-
const stableCandidateHash =
|
|
25278
|
+
const stableCandidateHash = systemPromptFingerprint(stableCandidate, promptSurface.preset);
|
|
25140
25279
|
const contentOrPresetChanged = hasPersistedHash && stableCandidateHash !== previousHash;
|
|
25141
25280
|
const rewritePermission = systemDateRefreshPermission(deps.historyRefreshSessions, dateRequest);
|
|
25142
25281
|
let deferredDateRefresh = false;
|
|
@@ -25150,7 +25289,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25150
25289
|
try {
|
|
25151
25290
|
const content = liveElements.join(`
|
|
25152
25291
|
`);
|
|
25153
|
-
const hash =
|
|
25292
|
+
const hash = systemPromptFingerprint(content, promptSurface.preset);
|
|
25154
25293
|
updateSessionMeta(deps.db, sessionId, {
|
|
25155
25294
|
systemPromptHash: hash,
|
|
25156
25295
|
cachedM0SystemHash: hash,
|
|
@@ -25190,7 +25329,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25190
25329
|
`);
|
|
25191
25330
|
if (!availability.frozen || !modelKey)
|
|
25192
25331
|
return;
|
|
25193
|
-
const currentHash =
|
|
25332
|
+
const currentHash = systemPromptFingerprint(systemContent, promptSurface.preset);
|
|
25194
25333
|
recordSystemPromptForRequest(sessionId, currentLkgRequestIdentity(sessionId), currentHash, deps.db, previousHash !== currentHash ? !deps.historyRefreshSessions.has(sessionId) : undefined, deps.historyRefreshSessions, deps.pendingMaterializationSessions);
|
|
25195
25334
|
if (!sessionMetaEarly) {
|
|
25196
25335
|
return;
|
|
@@ -25198,6 +25337,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25198
25337
|
const sessionMeta = sessionMetaEarly;
|
|
25199
25338
|
if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
|
|
25200
25339
|
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${idleCacheExpired ? "adopting on idle-expired request" : requestMessagesFinal ? "adopting on the request whose messages are already final" : "triggering flush"}`);
|
|
25340
|
+
noteSystemPromptHashChange(sessionId);
|
|
25201
25341
|
if (!adoptSystemChange) {
|
|
25202
25342
|
deps.historyRefreshSessions.add(sessionId);
|
|
25203
25343
|
deps.systemPromptRefreshSessions.add(sessionId);
|
|
@@ -25968,7 +26108,7 @@ function resolveCtxExpandMode(args, domain) {
|
|
|
25968
26108
|
}
|
|
25969
26109
|
|
|
25970
26110
|
// src/tools/ctx-expand/render.ts
|
|
25971
|
-
import { createHash as
|
|
26111
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
25972
26112
|
function isRecord4(value) {
|
|
25973
26113
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
25974
26114
|
}
|
|
@@ -26192,7 +26332,7 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
|
|
|
26192
26332
|
const index = scoped ? Number(scoped[2]) : 0;
|
|
26193
26333
|
const piText = message.parts.filter((part) => isRecord4(part) && part.type === "text");
|
|
26194
26334
|
const part = message.parts[index];
|
|
26195
|
-
const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" &&
|
|
26335
|
+
const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" && createHash13("sha256").update(part.text).digest("hex") === derived[3]) : [];
|
|
26196
26336
|
const selected = derived ? matching[Number(derived[4])] : textIndexDomain === "text" ? piText[index] : part;
|
|
26197
26337
|
return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
|
|
26198
26338
|
}
|
|
@@ -27797,7 +27937,7 @@ function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
|
27797
27937
|
return parts.join(" ");
|
|
27798
27938
|
}
|
|
27799
27939
|
// src/tools/ctx-reduce/tools.ts
|
|
27800
|
-
import { createHash as
|
|
27940
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
27801
27941
|
import { tool as tool4 } from "@opencode-ai/plugin";
|
|
27802
27942
|
|
|
27803
27943
|
// src/features/magic-context/range-parser.ts
|
|
@@ -27861,11 +28001,11 @@ function createCtxReduceTool(deps) {
|
|
|
27861
28001
|
const stableId = `oc-${sessionId}-${callId}`;
|
|
27862
28002
|
if (Buffer.byteLength(stableId) <= 128)
|
|
27863
28003
|
return stableId;
|
|
27864
|
-
return `oc-${
|
|
28004
|
+
return `oc-${createHash14("sha256").update(stableId).digest("hex")}`;
|
|
27865
28005
|
}
|
|
27866
28006
|
fallbackCommandSequence += 1;
|
|
27867
28007
|
const monotonicId = `oc-${sessionId}-${fallbackCommandSequence}`;
|
|
27868
|
-
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${
|
|
28008
|
+
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash14("sha256").update(monotonicId).digest("hex")}`;
|
|
27869
28009
|
};
|
|
27870
28010
|
return tool4({
|
|
27871
28011
|
description: CTX_REDUCE_DESCRIPTION,
|
|
@@ -28643,4 +28783,4 @@ function applyHiddenSubagentTemperature(input, output, log) {
|
|
|
28643
28783
|
output.temperature = temperature;
|
|
28644
28784
|
}
|
|
28645
28785
|
|
|
28646
|
-
export { openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, scheduleClearAndReindex, startDreamScheduleTimer, ensureProjectRegisteredFromOpenCodeDirectory, recordOpenCodeProvenInputFloor, resolveOpenCodeProvenInputFloor, resolveContextWindowGeometry, resolveContextLimit, resolveExecuteThresholdDetail, resolveModelKey, resolveSessionId, createScheduler, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, maybeDeliverChannel2, armLatestThinkingRecovery, armBindingRecoverySafely, armLatestThinkingRecoveryFromError, lkgReplayLimit, measureLkgReplay, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, createCtxExpandTools, CTX_MEMORY_LIST_TOOL_NAME, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createCtxMemoryListTools, CTX_NOTE_DESCRIPTION, withoutSmartNoteText, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer, subagentTemperature, applyHiddenSubagentTemperature };
|
|
28786
|
+
export { openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, scheduleClearAndReindex, startDreamScheduleTimer, createDreamTimerModuleClient, ensureProjectRegisteredFromOpenCodeDirectory, recordOpenCodeProvenInputFloor, resolveOpenCodeProvenInputFloor, resolveContextWindowGeometry, resolveContextLimit, resolveExecuteThresholdDetail, resolveModelKey, resolveSessionId, createScheduler, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, stageOpenCodeV2TransformDecision, bindOpenCodeV2TransformDecision, maybeDeliverChannel2, armLatestThinkingRecovery, armBindingRecoverySafely, armLatestThinkingRecoveryFromError, createM0RenderOptions, lkgReplayLimit, measureLkgReplay, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, createCtxExpandTools, CTX_MEMORY_LIST_TOOL_NAME, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createCtxMemoryListTools, CTX_NOTE_DESCRIPTION, withoutSmartNoteText, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer, subagentTemperature, applyHiddenSubagentTemperature };
|
|
@@ -93,7 +93,7 @@ import {
|
|
|
93
93
|
getProjectEmbeddingSnapshot2,
|
|
94
94
|
embedTextForProject2,
|
|
95
95
|
embedBatchForProject2
|
|
96
|
-
} from "./index-
|
|
96
|
+
} from "./index-se1w3v2m.js";
|
|
97
97
|
import {
|
|
98
98
|
isEmbeddingHostBusy2
|
|
99
99
|
} from "./index-qt1qqasc.js";
|
|
@@ -189,7 +189,7 @@ import {
|
|
|
189
189
|
extractToolCallObservation,
|
|
190
190
|
ToolMutationBatch,
|
|
191
191
|
createToolDropTarget
|
|
192
|
-
} from "./index-
|
|
192
|
+
} from "./index-qr1mkc2y.js";
|
|
193
193
|
import {
|
|
194
194
|
getMaxM0MutationId,
|
|
195
195
|
rememberUnpublishedAutoSearchNoHint,
|
|
@@ -223,7 +223,7 @@ import {
|
|
|
223
223
|
peekNoteNudgeText,
|
|
224
224
|
markNoteNudgeDelivered,
|
|
225
225
|
getActiveCompartmentRun
|
|
226
|
-
} from "./index-
|
|
226
|
+
} from "./index-z7avx6rw.js";
|
|
227
227
|
import {
|
|
228
228
|
runSessionWarmupWorker
|
|
229
229
|
} from "./index-angx1s0k.js";
|
|
@@ -231,13 +231,13 @@ import {
|
|
|
231
231
|
openCodeDbExists,
|
|
232
232
|
withReadOnlySessionDb,
|
|
233
233
|
getMessageTimesFromOpenCodeDb
|
|
234
|
-
} from "./index-
|
|
234
|
+
} from "./index-bzp9s8z2.js";
|
|
235
235
|
import {
|
|
236
236
|
BoundedSessionMap
|
|
237
|
-
} from "./index-
|
|
237
|
+
} from "./index-0j6crjgh.js";
|
|
238
238
|
import {
|
|
239
239
|
renderUserFacingFailure
|
|
240
|
-
} from "./index-
|
|
240
|
+
} from "./index-yhrrx7qa.js";
|
|
241
241
|
import {
|
|
242
242
|
getErrorMessage
|
|
243
243
|
} from "./index-y8v6yerm.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getActiveCompartmentRun,
|
|
16
16
|
markActiveCompartmentRunPublished,
|
|
17
17
|
registerActiveCompartmentRun
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-z7avx6rw.js";
|
|
19
19
|
import {
|
|
20
20
|
inRootAsyncContext2
|
|
21
21
|
} from "./index-wafzvyhg.js";
|
|
@@ -27,17 +27,17 @@ import {
|
|
|
27
27
|
getHistorianFailureState,
|
|
28
28
|
clearEmergencyRecovery,
|
|
29
29
|
prepareRawSessionOrdinals2
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-qr1mkc2y.js";
|
|
31
31
|
import {
|
|
32
32
|
pushNotification2
|
|
33
33
|
} from "./index-x8a7jmkh.js";
|
|
34
34
|
import {
|
|
35
35
|
sendStatusNotification2
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-0abg88h2.js";
|
|
37
37
|
import {
|
|
38
38
|
setRecompStarting2,
|
|
39
39
|
setRecompTerminal2
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-g40wgxxt.js";
|
|
41
41
|
|
|
42
42
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
43
43
|
import * as crypto from "node:crypto";
|