@cortexkit/opencode-magic-context 0.49.71 → 0.49.73
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/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-npk0e0aj.js → context-641fmxg4.js} +25 -18
- package/dist/{embedding-backfill-sk7agn5v.js → embedding-backfill-exnyad7d.js} +2 -2
- package/dist/features/magic-context/memory/embedding-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +2 -2
- package/dist/features/magic-context/project-embedding-registry.d.ts +1 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts +4 -0
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +12 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +4 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-materialization.d.ts +4 -1
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts +0 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-d0mb17q4.js → index-238xbkhk.js} +2 -2
- package/dist/{index-fcrp1k8s.js → index-3mx8math.js} +1 -1
- package/dist/{index-gq1g9a3a.js → index-9swgykdd.js} +4 -3
- package/dist/{index-mxjdj2cz.js → index-bdnak4d0.js} +17 -3
- package/dist/{index-rzxzap49.js → index-cpmqvc1c.js} +17 -15
- package/dist/{index-5hc4kjg0.js → index-etm62gd7.js} +1 -1
- package/dist/{index-cdyhpdqx.js → index-h2w3kzkt.js} +4 -4
- package/dist/{index-51anehwt.js → index-jeckjrh0.js} +13 -13
- package/dist/{index-gvnt9yka.js → index-k2rk6z1y.js} +8 -8
- package/dist/{index-y664y8kq.js → index-ne2awfqp.js} +11 -2
- package/dist/index-q9ywd8b2.js +65 -0
- package/dist/{index-33bfewqe.js → index-t74kawez.js} +77 -48
- package/dist/{index-n6aye6ny.js → index-ve863q40.js} +98 -2
- package/dist/{index-mey1nc1v.js → index-xha0yxhy.js} +1 -1
- package/dist/{index-fm0bpxc6.js → index-yhz1w3ss.js} +1 -1
- package/dist/{index-0dbc9rxd.js → index-ypm4aa3h.js} +3 -3
- package/dist/{index-n19pqsnh.js → index-zt6d9fag.js} +2 -2
- package/dist/{index-mejvnav7.js → index-ztjgymb9.js} +23 -14
- package/dist/index.js +40 -37
- package/dist/{message-index-bounded-n2j33x8n.js → message-index-bounded-vf70t44t.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +4 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-c2sfnamh.js → project-embedding-registry-n50fbax6.js} +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-6kdtfa7k.js → read-session-chunk-9jtq1swq.js} +2 -2
- package/dist/{recomp-orchestrator-t9670x13.js → recomp-orchestrator-z0m2vgbe.js} +10 -10
- package/dist/{render-re3akx9j.js → render-rf6dmb9v.js} +6 -6
- package/dist/{search-rppmngr5.js → search-0v2v9yd5.js} +8 -8
- package/dist/{search-archive-0q8rdnrd.js → search-archive-myb6n35b.js} +4 -4
- package/dist/{storage-tags-rptkad9p.js → storage-tags-d3nqrva7.js} +1 -1
- package/dist/{transform-postprocess-phase-qtd2wr52.js → transform-postprocess-phase-r6t8m6qq.js} +11 -11
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-vehx9ha8.js → context-4rmbpek8.js} +85 -44
- package/dist/v2/{embedding-backfill-j2xj86zn.js → embedding-backfill-jhmn81cz.js} +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-hfnsznj0.js → message-index-bounded-ev9sarf6.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-k0hjqt11.js → project-embedding-registry-07nz4qas.js} +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-qzd376gb.js → read-session-chunk-eb49qfzz.js} +2 -2
- package/dist/v2/{recomp-orchestrator-rrsbcsmc.js → recomp-orchestrator-14bek576.js} +9 -9
- package/dist/v2/{render-qwy9ydnb.js → render-rw6tk2fj.js} +6 -6
- package/dist/v2/{search-q3xcyyq8.js → search-03pzsd5w.js} +7 -7
- package/dist/v2/{search-archive-gewpafej.js → search-archive-w33x2z9z.js} +4 -4
- package/dist/v2/{server-vzrj39bj.js → server-11rbew2r.js} +11 -2
- package/dist/v2/{server-fczyr89c.js → server-ar3awhcy.js} +11 -11
- package/dist/v2/{server-vqkqv7ze.js → server-cxkb9725.js} +17 -3
- package/dist/v2/{server-07z334y6.js → server-d0ec5f7b.js} +1 -1
- package/dist/v2/{server-xxy28mq5.js → server-ds7y8nmk.js} +2 -2
- package/dist/v2/{server-axmk8rr2.js → server-k8mj4ccb.js} +1 -1
- package/dist/v2/{server-ssdfdrpv.js → server-kya7jvx5.js} +13 -13
- package/dist/v2/{server-d07yxksx.js → server-ndkzagjz.js} +98 -2
- package/dist/v2/server-rd7v8c8y.js +65 -0
- package/dist/v2/{server-nc4qrjde.js → server-rpdbmk63.js} +1 -1
- package/dist/v2/{server-0c7egkzr.js → server-sk08dem3.js} +2 -2
- package/dist/v2/{server-z5255w05.js → server-t091cjj4.js} +4 -3
- package/dist/v2/{server-h8y2948e.js → server-yspcz6v9.js} +3 -3
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-tags-msa1qvk8.js → storage-tags-j4he6hwe.js} +1 -1
- package/dist/v2/{v2-archive-reader-nwaw9qph.js → v2-archive-reader-cw9fm88j.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-xyd3r2t1.js → wrapup-orchestrator-sk2zx55m.js} +21 -19
- package/dist/{v2-archive-reader-dv00gb2a.js → v2-archive-reader-42chk89p.js} +1 -1
- package/dist/{wrapup-orchestrator-fzygp85w.js → wrapup-orchestrator-4sfkj8z4.js} +11 -11
- package/package.json +1 -1
- package/dist/index-zxj39ba2.js +0 -155
- package/dist/v2/server-d9aayyxk.js +0 -155
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-yhz1w3ss.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-ypm4aa3h.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
|
@@ -1021,7 +1021,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1021
1021
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1022
1022
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1023
1023
|
return;
|
|
1024
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1024
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-9jtq1swq.js"));
|
|
1025
1025
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-pz5981mf.js"));
|
|
1026
1026
|
if (signal.aborted)
|
|
1027
1027
|
return;
|
|
@@ -2574,14 +2574,15 @@ async function embedItemsForProject2(projectIdentity, items, signal, db, session
|
|
|
2574
2574
|
return { vectors, modelId, generation };
|
|
2575
2575
|
}
|
|
2576
2576
|
async function embedItemsWindowBounded2(projectIdentity, items, signal, db, sessionId = projectIdentity, options = {}) {
|
|
2577
|
-
|
|
2577
|
+
const maxItemsPerCall = options.maxItemsPerCall ?? MAX_WINDOWS_PER_EMBED_CALL;
|
|
2578
|
+
if (items.length <= maxItemsPerCall) {
|
|
2578
2579
|
return embedItemsForProject2(projectIdentity, items, signal, db, sessionId);
|
|
2579
2580
|
}
|
|
2580
2581
|
const vectors = new Map;
|
|
2581
2582
|
let modelId = null;
|
|
2582
2583
|
let generation = null;
|
|
2583
|
-
for (let start = 0;start < items.length; start +=
|
|
2584
|
-
const slice = items.slice(start, start +
|
|
2584
|
+
for (let start = 0;start < items.length; start += maxItemsPerCall) {
|
|
2585
|
+
const slice = items.slice(start, start + maxItemsPerCall);
|
|
2585
2586
|
const result = await embedItemsForProject2(projectIdentity, slice, signal, db, sessionId);
|
|
2586
2587
|
if (!result)
|
|
2587
2588
|
return null;
|
|
@@ -5423,16 +5423,30 @@ function neutralizedReasoningSource(part) {
|
|
|
5423
5423
|
return isRecord(part) ? NEUTRALIZED_ORIGINALS.get(part) ?? part : part;
|
|
5424
5424
|
}
|
|
5425
5425
|
var VARIANT_CACHE_PRESERVING_MODELS = {
|
|
5426
|
-
"anthropic/claude-fable-5-1": "2026-09-02",
|
|
5427
|
-
"openai/gpt-6-astra": "2026-09-05",
|
|
5428
|
-
"anthropic/claude-opus-5-5": "2026-09-23"
|
|
5426
|
+
"anthropic/claude-fable-5-1": ["2026-09-02"],
|
|
5427
|
+
"openai/gpt-6-astra": ["2026-09-05"],
|
|
5428
|
+
"anthropic/claude-opus-5-5": ["2026-09-23", true],
|
|
5429
|
+
"anthropic/claude-sonnet-5-5": ["2026-11-23", true],
|
|
5430
|
+
"anthropic/claude-haiku-5-5": ["2026-11-23", true],
|
|
5431
|
+
"anthropic/claude-fable-5-2": ["2026-11-23", true],
|
|
5432
|
+
"anthropic/claude-mythos-5-1": ["2026-11-23", true],
|
|
5433
|
+
"anthropic/claude-mythos-5-2": ["2026-11-23", true]
|
|
5429
5434
|
};
|
|
5435
|
+
var CLAUDE_VARIANT_ALIAS = /^(?:(?:[a-z0-9-]+\.)?anthropic\.)?(?:claude-)?([a-z]+)[-_.]?([0-9]+)[-_.]([0-9]+)(?:[-@][0-9]{8})?(?:-v[0-9]+:[0-9]+)?$/i;
|
|
5430
5436
|
function canonicalVariantModelIdentity(providerID, modelID) {
|
|
5431
5437
|
const normalizedProviderID = providerID.toLowerCase();
|
|
5432
5438
|
const isAnthropicFamily = normalizedProviderID === "anthropic" || normalizedProviderID === "google-vertex-anthropic" || normalizedProviderID.includes("bedrock");
|
|
5433
5439
|
if (isAnthropicFamily && isFable51ThinkingBindingModel("anthropic", modelID)) {
|
|
5434
5440
|
return "anthropic/claude-fable-5-1";
|
|
5435
5441
|
}
|
|
5442
|
+
if (isAnthropicFamily) {
|
|
5443
|
+
const alias = CLAUDE_VARIANT_ALIAS.exec(modelID.split("/").at(-1) ?? "");
|
|
5444
|
+
if (alias) {
|
|
5445
|
+
const identity = `anthropic/claude-${alias[1].toLowerCase()}-${alias[2]}-${alias[3]}`;
|
|
5446
|
+
if (VARIANT_CACHE_PRESERVING_MODELS[identity]?.[1])
|
|
5447
|
+
return identity;
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5436
5450
|
return canonicalModelIdentity(`${providerID}/${modelID}`).toLowerCase();
|
|
5437
5451
|
}
|
|
5438
5452
|
function variantChangeBustsProviderCache(providerID, modelID) {
|
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
renewCompartmentLease,
|
|
8
8
|
releaseCompartmentLeaseBestEffort,
|
|
9
9
|
getCompartments,
|
|
10
|
-
getLastCompartmentEndMessage
|
|
11
|
-
|
|
10
|
+
getLastCompartmentEndMessage,
|
|
11
|
+
requestPendingMaterialization
|
|
12
|
+
} from "./index-ne2awfqp.js";
|
|
12
13
|
import {
|
|
13
14
|
inRootAsyncContext2
|
|
14
15
|
} from "./index-gzy5w8ya.js";
|
|
@@ -19,10 +20,10 @@ import {
|
|
|
19
20
|
releaseWrapupInProgress,
|
|
20
21
|
getHistorianFailureState,
|
|
21
22
|
clearEmergencyRecovery
|
|
22
|
-
} from "./index-
|
|
23
|
+
} from "./index-bdnak4d0.js";
|
|
23
24
|
import {
|
|
24
25
|
prepareRawSessionOrdinals2
|
|
25
|
-
} from "./index-
|
|
26
|
+
} from "./index-yhz1w3ss.js";
|
|
26
27
|
import {
|
|
27
28
|
pushNotification2
|
|
28
29
|
} from "./index-x8a7jmkh.js";
|
|
@@ -34,14 +35,14 @@ import {
|
|
|
34
35
|
getActiveCompartmentRun,
|
|
35
36
|
markActiveCompartmentRunPublished,
|
|
36
37
|
registerActiveCompartmentRun
|
|
37
|
-
} from "./index-
|
|
38
|
+
} from "./index-k2rk6z1y.js";
|
|
38
39
|
import {
|
|
39
40
|
sendStatusNotification2
|
|
40
41
|
} from "./index-1sq1krqw.js";
|
|
41
42
|
import {
|
|
42
43
|
setRecompStarting2,
|
|
43
44
|
setRecompTerminal2
|
|
44
|
-
} from "./index-
|
|
45
|
+
} from "./index-h2w3kzkt.js";
|
|
45
46
|
|
|
46
47
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
47
48
|
import * as crypto from "node:crypto";
|
|
@@ -80,11 +81,6 @@ function formatAlreadyRunningMessage(state) {
|
|
|
80
81
|
const through = state.lastCompartmentEnd > 0 ? ` through message ${state.lastCompartmentEnd}` : "";
|
|
81
82
|
return `/ctx-wrapup is already running for this session${chunk}${through}. Wait for it to finish, then run /ctx-wrapup again if more history remains.`;
|
|
82
83
|
}
|
|
83
|
-
function appendFlushHint(ctx, sessionId, message) {
|
|
84
|
-
if (ctx.hasPendingNaturalBust?.(sessionId))
|
|
85
|
-
return message;
|
|
86
|
-
return `${message} If you want it applied on the very next message, run /ctx-flush first.`;
|
|
87
|
-
}
|
|
88
84
|
function buildPlan(ctx, sessionId, messagesToKeep, anchorRawMessageCount) {
|
|
89
85
|
return resolveWrapupProtectedTailBoundary({
|
|
90
86
|
db: ctx.db,
|
|
@@ -270,8 +266,8 @@ ${message}`;
|
|
|
270
266
|
|
|
271
267
|
${message}`;
|
|
272
268
|
}
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
let startLastEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
|
|
270
|
+
let startCompartmentCount = getCompartments(ctx.db, sessionId).length;
|
|
275
271
|
let chunkIndex = 0;
|
|
276
272
|
let lastEnd = startLastEnd;
|
|
277
273
|
let stoppedForFailure = false;
|
|
@@ -315,6 +311,9 @@ ${message}`;
|
|
|
315
311
|
if (activeAtStart === "timeout") {
|
|
316
312
|
stoppedForFailure = true;
|
|
317
313
|
stoppedReason = "Timed out waiting for the active historian run.";
|
|
314
|
+
} else {
|
|
315
|
+
startLastEnd = lastEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
|
|
316
|
+
startCompartmentCount = getCompartments(ctx.db, sessionId).length;
|
|
318
317
|
}
|
|
319
318
|
if (!stoppedForFailure) {
|
|
320
319
|
try {
|
|
@@ -422,8 +421,11 @@ ${message}`;
|
|
|
422
421
|
try {
|
|
423
422
|
clearEmergencyRecovery(ctx.db, sessionId);
|
|
424
423
|
} catch {}
|
|
425
|
-
|
|
426
|
-
|
|
424
|
+
let message = `Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments.`;
|
|
425
|
+
if (compartmentsCreated > 0) {
|
|
426
|
+
requestPendingMaterialization(ctx.liveSessionState.pendingMaterializationSessions, sessionId, "user_wrapup");
|
|
427
|
+
message += " The compacted history applies on your next message, or on the next rebuild if the host restarts first.";
|
|
428
|
+
}
|
|
427
429
|
setRecompTerminal2(ctx.liveSessionState, sessionId, "done", message);
|
|
428
430
|
return message;
|
|
429
431
|
}
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
} from "./index-ywrz4wy2.js";
|
|
4
4
|
import {
|
|
5
5
|
clearEmergencyRecovery
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-bdnak4d0.js";
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-ne2awfqp.js";
|
|
11
11
|
import {
|
|
12
12
|
executeContextRecomp
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-k2rk6z1y.js";
|
|
14
14
|
import {
|
|
15
15
|
renderUserFacingFailure,
|
|
16
16
|
userFacingFailureCode
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-ve863q40.js";
|
|
18
18
|
|
|
19
19
|
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
20
20
|
function resolveLiveModelKey(liveSessionState, sessionId) {
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
enqueueShadowEmbeddingItems2,
|
|
39
39
|
getProjectEmbeddingSnapshot2,
|
|
40
40
|
embedItemsForProject2
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-9swgykdd.js";
|
|
42
42
|
import {
|
|
43
43
|
recordEmbeddingMeasurement
|
|
44
44
|
} from "./index-2amn2s73.js";
|
|
@@ -46,42 +46,42 @@ import {
|
|
|
46
46
|
getProjectEmbeddings2
|
|
47
47
|
} from "./index-4dhv7mqz.js";
|
|
48
48
|
import {
|
|
49
|
+
USER_FACING_FAILURES,
|
|
49
50
|
cosineSimilarity,
|
|
50
51
|
isEmbeddingEnabled,
|
|
51
52
|
embedText,
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
relaxedFtsQuery,
|
|
54
|
+
sanitizeFtsQuery,
|
|
55
|
+
searchMemoriesFTS,
|
|
56
|
+
searchMemoriesFTSUnion
|
|
57
|
+
} from "./index-ve863q40.js";
|
|
54
58
|
import {
|
|
55
59
|
ModuleMemoryAuthorityError2,
|
|
56
60
|
getMemoriesByProject2,
|
|
57
61
|
getMemoriesByProjects2,
|
|
58
62
|
updateMemoryRetrievalCount2
|
|
59
63
|
} from "./index-jjvbk92s.js";
|
|
60
|
-
import {
|
|
61
|
-
USER_FACING_FAILURES,
|
|
62
|
-
relaxedFtsQuery,
|
|
63
|
-
sanitizeFtsQuery,
|
|
64
|
-
searchMemoriesFTS,
|
|
65
|
-
searchMemoriesFTSUnion
|
|
66
|
-
} from "./index-n6aye6ny.js";
|
|
67
64
|
import {
|
|
68
65
|
matchedSearchSnippet,
|
|
69
66
|
getIndexedMessageCorpusSize
|
|
70
|
-
} from "./index-
|
|
67
|
+
} from "./index-etm62gd7.js";
|
|
71
68
|
import {
|
|
72
69
|
getMessageIndexEpoch,
|
|
73
70
|
isMessageIndexSearchable,
|
|
74
71
|
withMemoryHintContent,
|
|
75
72
|
autoSearchRelevance,
|
|
76
73
|
recordAutoSearchLane
|
|
77
|
-
} from "./index-
|
|
74
|
+
} from "./index-xha0yxhy.js";
|
|
75
|
+
import {
|
|
76
|
+
ensureMemoryEmbeddings2
|
|
77
|
+
} from "./index-q9ywd8b2.js";
|
|
78
78
|
import {
|
|
79
79
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
80
80
|
withMessageFtsSessionFilter
|
|
81
81
|
} from "./index-52x68mj4.js";
|
|
82
82
|
import {
|
|
83
83
|
isRecord
|
|
84
|
-
} from "./index-
|
|
84
|
+
} from "./index-bdnak4d0.js";
|
|
85
85
|
import {
|
|
86
86
|
resolveWorkspaceShareCategories,
|
|
87
87
|
resolveWorkspaceIdentitySet,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
getRawSessionTagKeysThrough2,
|
|
36
36
|
getLegacyProtectedTailStartOrdinal2,
|
|
37
37
|
readSessionChunk2
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-yhz1w3ss.js";
|
|
39
39
|
import {
|
|
40
40
|
getHarness2,
|
|
41
41
|
harnessOwnsOpenCodeStore2
|
|
@@ -113,7 +113,7 @@ import {
|
|
|
113
113
|
LATEST_SUPPORTED_VERSION,
|
|
114
114
|
getPersistedSchemaVersion,
|
|
115
115
|
openDatabase
|
|
116
|
-
} from "./index-
|
|
116
|
+
} from "./index-3mx8math.js";
|
|
117
117
|
import {
|
|
118
118
|
areRustHistorianSyntheticParts2,
|
|
119
119
|
isStrictGapHealingMessage2,
|
|
@@ -201,14 +201,14 @@ import {
|
|
|
201
201
|
getProjectState,
|
|
202
202
|
recordSubagentInvocation,
|
|
203
203
|
getLatestHistorianInvocationId
|
|
204
|
-
} from "./index-
|
|
204
|
+
} from "./index-ne2awfqp.js";
|
|
205
205
|
import {
|
|
206
206
|
clearCompressionDepth,
|
|
207
207
|
clearCompressionDepthRange,
|
|
208
208
|
toMessageIndexSource,
|
|
209
209
|
clearIndexedMessagesInTransaction,
|
|
210
210
|
indexSourcesAfterOrdinal
|
|
211
|
-
} from "./index-
|
|
211
|
+
} from "./index-etm62gd7.js";
|
|
212
212
|
import {
|
|
213
213
|
stripWellFormedLeadingTagPrefix,
|
|
214
214
|
peelLeadingMcTagNotation,
|
|
@@ -258,7 +258,7 @@ import {
|
|
|
258
258
|
foldShrunkPartTags2,
|
|
259
259
|
getTagNumberByMessageId2,
|
|
260
260
|
getActiveTagsBySession2
|
|
261
|
-
} from "./index-
|
|
261
|
+
} from "./index-bdnak4d0.js";
|
|
262
262
|
import {
|
|
263
263
|
openCodeDbExists,
|
|
264
264
|
withReadOnlySessionDb,
|
|
@@ -286,13 +286,13 @@ import {
|
|
|
286
286
|
getProjectChunkEmbeddingModelId2,
|
|
287
287
|
getProjectEmbeddingMaxInputTokens2,
|
|
288
288
|
embedItemsWindowBounded2
|
|
289
|
-
} from "./index-
|
|
289
|
+
} from "./index-9swgykdd.js";
|
|
290
290
|
import {
|
|
291
291
|
renderUserFacingFailure,
|
|
292
292
|
userFacingFailureCode,
|
|
293
293
|
promoteSessionFactsDurable,
|
|
294
294
|
embedPromotedFacts
|
|
295
|
-
} from "./index-
|
|
295
|
+
} from "./index-ve863q40.js";
|
|
296
296
|
import {
|
|
297
297
|
isMarkerCandidateBasisCurrent2,
|
|
298
298
|
invalidateMarkerCandidateBasis2,
|
|
@@ -12587,7 +12587,7 @@ function injectM0M1(options) {
|
|
|
12587
12587
|
const M1_ABSOLUTE_CAP_RATIO = 0.2;
|
|
12588
12588
|
const m1AbsoluteBudget = (options.historyBudgetTokens ?? DEFAULT_HISTORY_BUDGET_TOKENS) * M1_ABSOLUTE_CAP_RATIO;
|
|
12589
12589
|
let driftNeedsRefold = false;
|
|
12590
|
-
if (!rematerialized && !contentionExhausted && m1Recomputed && options.isCacheBustingPass) {
|
|
12590
|
+
if (!rematerialized && !contentionExhausted && m1Recomputed && options.isCacheBustingPass && !options.skipPressureRefold) {
|
|
12591
12591
|
driftNeedsRefold = memoryUpdateCount > 40;
|
|
12592
12592
|
if (!driftNeedsRefold && m1Text !== M1_EMPTY_PLACEHOLDER) {
|
|
12593
12593
|
const m1Tokens = estimateTokens(m1Text);
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
getPendingPiCompactionMarkerState,
|
|
69
69
|
logPiCompactionMarkerClear,
|
|
70
70
|
isPrefixBoundThinkingModel
|
|
71
|
-
} from "./index-
|
|
71
|
+
} from "./index-bdnak4d0.js";
|
|
72
72
|
import {
|
|
73
73
|
withReadOnlySessionDb
|
|
74
74
|
} from "./index-x40zr813.js";
|
|
@@ -1630,11 +1630,20 @@ function pendingMaterializationOrigin(sessions, sessionId) {
|
|
|
1630
1630
|
function hasPendingMaterializationOrigin(sessions, sessionId, origin) {
|
|
1631
1631
|
return sessions.has(sessionId) && causes.get(sessions)?.get(sessionId)?.has(origin) === true;
|
|
1632
1632
|
}
|
|
1633
|
+
function hasExplicitRefreshRequest(sessions, sessionId) {
|
|
1634
|
+
return hasPendingMaterializationOrigin(sessions, sessionId, "user_flush") || hasPendingMaterializationOrigin(sessions, sessionId, "user_wrapup");
|
|
1635
|
+
}
|
|
1633
1636
|
function clearPendingMaterialization(sessions, sessionId) {
|
|
1634
1637
|
sessions.delete(sessionId);
|
|
1635
1638
|
origins.get(sessions)?.delete(sessionId);
|
|
1636
1639
|
causes.get(sessions)?.delete(sessionId);
|
|
1637
1640
|
}
|
|
1641
|
+
function clearReclaimedMaterialization(sessions, sessionId) {
|
|
1642
|
+
const wrapupPending = hasPendingMaterializationOrigin(sessions, sessionId, "user_wrapup");
|
|
1643
|
+
clearPendingMaterialization(sessions, sessionId);
|
|
1644
|
+
if (wrapupPending)
|
|
1645
|
+
requestPendingMaterialization(sessions, sessionId, "user_wrapup");
|
|
1646
|
+
}
|
|
1638
1647
|
function clearPendingMaterializationOrigin(sessions, sessionId, origin) {
|
|
1639
1648
|
const pendingCauses = causes.get(sessions)?.get(sessionId);
|
|
1640
1649
|
if (!sessions.has(sessionId) || !pendingCauses?.has(origin))
|
|
@@ -5187,4 +5196,4 @@ var ERROR_CLASSES = new Set([
|
|
|
5187
5196
|
"permission_denied",
|
|
5188
5197
|
"unknown"
|
|
5189
5198
|
]);
|
|
5190
|
-
export { advanceSessionActivity, observeSessionActivity, backfillSessionActivity, COMPARTMENT_LEASE_RENEWAL_MS, getCompartmentLeaseBlocker, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, queueM0Mutation, getMaxM0MutationId, getCompartments, getNewestCompartmentIds, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, buildCompartmentBlock, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, readServerFallbackUsage, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, clearPendingMaterializationOrigin, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginServedRequest, noteServedPassPermission, noteServedModel, noteServedReplay, noteServedHostInput, noteServedRefusal, countServedRefusal, dropServedRecord, forgetServedRecord, commitServedRequest, lkgInputIdentity, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, externalHistorianFailureReason, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, MEMORY_VISIBILITY_MUTATION_CATEGORY, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId };
|
|
5199
|
+
export { advanceSessionActivity, observeSessionActivity, backfillSessionActivity, COMPARTMENT_LEASE_RENEWAL_MS, getCompartmentLeaseBlocker, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, queueM0Mutation, getMaxM0MutationId, getCompartments, getNewestCompartmentIds, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, buildCompartmentBlock, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, readServerFallbackUsage, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, hasExplicitRefreshRequest, clearPendingMaterialization, clearReclaimedMaterialization, clearPendingMaterializationOrigin, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, beginServedRequest, noteServedPassPermission, noteServedModel, noteServedReplay, noteServedHostInput, noteServedRefusal, countServedRefusal, dropServedRecord, forgetServedRecord, commitServedRequest, lkgInputIdentity, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgContentDigest, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, externalHistorianFailureReason, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, MEMORY_VISIBILITY_MUTATION_CATEGORY, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEmbeddingHostBusy2
|
|
3
|
+
} from "./index-qt1qqasc.js";
|
|
4
|
+
import {
|
|
5
|
+
log2
|
|
6
|
+
} from "./index-ywrz4wy2.js";
|
|
7
|
+
import {
|
|
8
|
+
contentSha2562,
|
|
9
|
+
getProjectEmbeddingSnapshot2,
|
|
10
|
+
embedItemsWindowBounded2
|
|
11
|
+
} from "./index-9swgykdd.js";
|
|
12
|
+
import {
|
|
13
|
+
saveEmbeddingIfHashMatches
|
|
14
|
+
} from "./index-4dhv7mqz.js";
|
|
15
|
+
|
|
16
|
+
// src/features/magic-context/memory/embedding-backfill.ts
|
|
17
|
+
var SEARCH_BACKFILL_LIMIT = 50;
|
|
18
|
+
var SEARCH_BACKFILL_REQUEST_SIZE = 10;
|
|
19
|
+
async function ensureMemoryEmbeddings2(args) {
|
|
20
|
+
if (isEmbeddingHostBusy2())
|
|
21
|
+
return args.existingEmbeddings;
|
|
22
|
+
const snapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
23
|
+
if (!snapshot?.enabled) {
|
|
24
|
+
return args.existingEmbeddings;
|
|
25
|
+
}
|
|
26
|
+
const missingMemories = args.memories.filter((memory) => !args.existingEmbeddings.has(memory.id)).sort((a, b) => a.id - b.id).slice(0, SEARCH_BACKFILL_LIMIT);
|
|
27
|
+
if (missingMemories.length === 0) {
|
|
28
|
+
return args.existingEmbeddings;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const result = await embedItemsWindowBounded2(args.projectIdentity, missingMemories.map((memory) => ({
|
|
32
|
+
id: `memory:${memory.id}`,
|
|
33
|
+
text: memory.content,
|
|
34
|
+
contentSha256: contentSha2562(memory.content)
|
|
35
|
+
})), undefined, args.db, args.projectIdentity, { maxItemsPerCall: SEARCH_BACKFILL_REQUEST_SIZE });
|
|
36
|
+
if (!result) {
|
|
37
|
+
return args.existingEmbeddings;
|
|
38
|
+
}
|
|
39
|
+
const staged = new Map;
|
|
40
|
+
args.db.transaction(() => {
|
|
41
|
+
for (const memory of missingMemories) {
|
|
42
|
+
const embedding = result.vectors.get(`memory:${memory.id}`);
|
|
43
|
+
if (!embedding) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const saved = saveEmbeddingIfHashMatches(args.db, memory.id, embedding, result.modelId, memory.normalizedHash);
|
|
47
|
+
if (saved) {
|
|
48
|
+
staged.set(memory.id, { embedding, modelId: result.modelId });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}).immediate();
|
|
52
|
+
const currentSnapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
53
|
+
if (!currentSnapshot || currentSnapshot.generation !== result.generation) {
|
|
54
|
+
return args.existingEmbeddings;
|
|
55
|
+
}
|
|
56
|
+
for (const [id, embedding] of staged) {
|
|
57
|
+
args.existingEmbeddings.set(id, embedding);
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
log2("[magic-context] failed to backfill memory embeddings:", error);
|
|
61
|
+
}
|
|
62
|
+
return args.existingEmbeddings;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { ensureMemoryEmbeddings2 };
|