@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
|
@@ -5358,16 +5358,30 @@ function neutralizedReasoningSource(part) {
|
|
|
5358
5358
|
return isRecord(part) ? NEUTRALIZED_ORIGINALS.get(part) ?? part : part;
|
|
5359
5359
|
}
|
|
5360
5360
|
var VARIANT_CACHE_PRESERVING_MODELS = {
|
|
5361
|
-
"anthropic/claude-fable-5-1": "2026-09-02",
|
|
5362
|
-
"openai/gpt-6-astra": "2026-09-05",
|
|
5363
|
-
"anthropic/claude-opus-5-5": "2026-09-23"
|
|
5361
|
+
"anthropic/claude-fable-5-1": ["2026-09-02"],
|
|
5362
|
+
"openai/gpt-6-astra": ["2026-09-05"],
|
|
5363
|
+
"anthropic/claude-opus-5-5": ["2026-09-23", true],
|
|
5364
|
+
"anthropic/claude-sonnet-5-5": ["2026-11-23", true],
|
|
5365
|
+
"anthropic/claude-haiku-5-5": ["2026-11-23", true],
|
|
5366
|
+
"anthropic/claude-fable-5-2": ["2026-11-23", true],
|
|
5367
|
+
"anthropic/claude-mythos-5-1": ["2026-11-23", true],
|
|
5368
|
+
"anthropic/claude-mythos-5-2": ["2026-11-23", true]
|
|
5364
5369
|
};
|
|
5370
|
+
var CLAUDE_VARIANT_ALIAS = /^(?:(?:[a-z0-9-]+\.)?anthropic\.)?(?:claude-)?([a-z]+)[-_.]?([0-9]+)[-_.]([0-9]+)(?:[-@][0-9]{8})?(?:-v[0-9]+:[0-9]+)?$/i;
|
|
5365
5371
|
function canonicalVariantModelIdentity(providerID, modelID) {
|
|
5366
5372
|
const normalizedProviderID = providerID.toLowerCase();
|
|
5367
5373
|
const isAnthropicFamily = normalizedProviderID === "anthropic" || normalizedProviderID === "google-vertex-anthropic" || normalizedProviderID.includes("bedrock");
|
|
5368
5374
|
if (isAnthropicFamily && isFable51ThinkingBindingModel("anthropic", modelID)) {
|
|
5369
5375
|
return "anthropic/claude-fable-5-1";
|
|
5370
5376
|
}
|
|
5377
|
+
if (isAnthropicFamily) {
|
|
5378
|
+
const alias = CLAUDE_VARIANT_ALIAS.exec(modelID.split("/").at(-1) ?? "");
|
|
5379
|
+
if (alias) {
|
|
5380
|
+
const identity = `anthropic/claude-${alias[1].toLowerCase()}-${alias[2]}-${alias[3]}`;
|
|
5381
|
+
if (VARIANT_CACHE_PRESERVING_MODELS[identity]?.[1])
|
|
5382
|
+
return identity;
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5371
5385
|
return canonicalModelIdentity(`${providerID}/${modelID}`).toLowerCase();
|
|
5372
5386
|
}
|
|
5373
5387
|
function variantChangeBustsProviderCache(providerID, modelID) {
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./server-
|
|
22
|
+
} from "./server-k8mj4ccb.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./server-
|
|
25
|
+
} from "./server-yspcz6v9.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
|
@@ -101,7 +101,7 @@ import {
|
|
|
101
101
|
foldShrunkPartTags2,
|
|
102
102
|
getTagNumberByMessageId2,
|
|
103
103
|
getActiveTagsBySession2
|
|
104
|
-
} from "./server-
|
|
104
|
+
} from "./server-cxkb9725.js";
|
|
105
105
|
import {
|
|
106
106
|
hasMeaningfulUserText2,
|
|
107
107
|
estimateTokens,
|
|
@@ -156,14 +156,14 @@ import {
|
|
|
156
156
|
getRawSessionTagKeysThrough2,
|
|
157
157
|
getLegacyProtectedTailStartOrdinal2,
|
|
158
158
|
readSessionChunk2
|
|
159
|
-
} from "./server-
|
|
159
|
+
} from "./server-k8mj4ccb.js";
|
|
160
160
|
import {
|
|
161
161
|
clearCompressionDepth,
|
|
162
162
|
clearCompressionDepthRange,
|
|
163
163
|
toMessageIndexSource,
|
|
164
164
|
clearIndexedMessagesInTransaction,
|
|
165
165
|
indexSourcesAfterOrdinal
|
|
166
|
-
} from "./server-
|
|
166
|
+
} from "./server-d0ec5f7b.js";
|
|
167
167
|
import {
|
|
168
168
|
COMPARTMENT_LEASE_RENEWAL_MS,
|
|
169
169
|
getCompartmentLeaseBlocker,
|
|
@@ -209,7 +209,7 @@ import {
|
|
|
209
209
|
getProjectState,
|
|
210
210
|
recordSubagentInvocation,
|
|
211
211
|
getLatestHistorianInvocationId
|
|
212
|
-
} from "./server-
|
|
212
|
+
} from "./server-11rbew2r.js";
|
|
213
213
|
import {
|
|
214
214
|
invalidateAutoEmbedSession
|
|
215
215
|
} from "./server-2amn2s73.js";
|
|
@@ -244,12 +244,18 @@ import {
|
|
|
244
244
|
getProjectChunkEmbeddingModelId2,
|
|
245
245
|
getProjectEmbeddingMaxInputTokens2,
|
|
246
246
|
embedItemsWindowBounded2
|
|
247
|
-
} from "./server-
|
|
247
|
+
} from "./server-t091cjj4.js";
|
|
248
248
|
import {
|
|
249
249
|
V2_MEMORY_CATEGORIES,
|
|
250
250
|
CATEGORY_PRIORITY,
|
|
251
251
|
getMemoryCategoryOrder
|
|
252
252
|
} from "./server-fr0wbhdn.js";
|
|
253
|
+
import {
|
|
254
|
+
renderUserFacingFailure,
|
|
255
|
+
userFacingFailureCode,
|
|
256
|
+
promoteSessionFactsDurable,
|
|
257
|
+
embedPromotedFacts
|
|
258
|
+
} from "./server-ndkzagjz.js";
|
|
253
259
|
import {
|
|
254
260
|
computeCueContentHash,
|
|
255
261
|
getMuralCueState,
|
|
@@ -258,18 +264,12 @@ import {
|
|
|
258
264
|
getMemoriesByProjects2,
|
|
259
265
|
getMaxMemoryIdForProjects2
|
|
260
266
|
} from "./server-jjvbk92s.js";
|
|
261
|
-
import {
|
|
262
|
-
renderUserFacingFailure,
|
|
263
|
-
userFacingFailureCode,
|
|
264
|
-
promoteSessionFactsDurable,
|
|
265
|
-
embedPromotedFacts
|
|
266
|
-
} from "./server-d07yxksx.js";
|
|
267
267
|
import {
|
|
268
268
|
getSchemaFenceRejection,
|
|
269
269
|
LATEST_SUPPORTED_VERSION,
|
|
270
270
|
getPersistedSchemaVersion,
|
|
271
271
|
openDatabase
|
|
272
|
-
} from "./server-
|
|
272
|
+
} from "./server-rpdbmk63.js";
|
|
273
273
|
import {
|
|
274
274
|
parseCompartmentOutput,
|
|
275
275
|
resolveWorkspaceShareCategories,
|
|
@@ -10448,7 +10448,7 @@ function injectM0M1(options) {
|
|
|
10448
10448
|
const M1_ABSOLUTE_CAP_RATIO = 0.2;
|
|
10449
10449
|
const m1AbsoluteBudget = (options.historyBudgetTokens ?? DEFAULT_HISTORY_BUDGET_TOKENS) * M1_ABSOLUTE_CAP_RATIO;
|
|
10450
10450
|
let driftNeedsRefold = false;
|
|
10451
|
-
if (!rematerialized && !contentionExhausted && m1Recomputed && options.isCacheBustingPass) {
|
|
10451
|
+
if (!rematerialized && !contentionExhausted && m1Recomputed && options.isCacheBustingPass && !options.skipPressureRefold) {
|
|
10452
10452
|
driftNeedsRefold = memoryUpdateCount > 40;
|
|
10453
10453
|
if (!driftNeedsRefold && m1Text !== M1_EMPTY_PLACEHOLDER) {
|
|
10454
10454
|
const m1Tokens = estimateTokens(m1Text);
|
|
@@ -5,12 +5,23 @@ import {
|
|
|
5
5
|
PROMOTABLE_CATEGORIES,
|
|
6
6
|
CATEGORY_DEFAULT_TTL
|
|
7
7
|
} from "./server-fr0wbhdn.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
10
|
+
} from "./server-rz6g5xne.js";
|
|
8
11
|
import {
|
|
9
12
|
sessionLog2
|
|
10
13
|
} from "./server-j8376q08.js";
|
|
11
14
|
import {
|
|
15
|
+
isSynapseEmbeddingTruncated,
|
|
16
|
+
SynapseEmbeddingProvider
|
|
17
|
+
} from "./server-x6fn9x8q.js";
|
|
18
|
+
import {
|
|
19
|
+
LocalEmbeddingProvider
|
|
20
|
+
} from "./server-d706s5xn.js";
|
|
21
|
+
import {
|
|
22
|
+
OpenAICompatibleEmbeddingProvider,
|
|
12
23
|
embedTextForProject2
|
|
13
|
-
} from "./server-
|
|
24
|
+
} from "./server-t091cjj4.js";
|
|
14
25
|
import {
|
|
15
26
|
saveEmbeddingIfHashMatches
|
|
16
27
|
} from "./server-4dhv7mqz.js";
|
|
@@ -358,6 +369,91 @@ function dreamFailureCode(failureClass) {
|
|
|
358
369
|
function renderEmbeddingFailure(failureClass, style = "markdown") {
|
|
359
370
|
return renderUserFacingFailure(EMBEDDING_FAILURE_KEYS[failureClass], style);
|
|
360
371
|
}
|
|
372
|
+
// src/features/magic-context/memory/cosine-similarity.ts
|
|
373
|
+
function cosineSimilarity(a, b) {
|
|
374
|
+
if (a.length !== b.length) {
|
|
375
|
+
return 0;
|
|
376
|
+
}
|
|
377
|
+
let dotProduct = 0;
|
|
378
|
+
let normA = 0;
|
|
379
|
+
let normB = 0;
|
|
380
|
+
for (let index = 0;index < a.length; index++) {
|
|
381
|
+
dotProduct += a[index] * b[index];
|
|
382
|
+
normA += a[index] * a[index];
|
|
383
|
+
normB += b[index] * b[index];
|
|
384
|
+
}
|
|
385
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
386
|
+
return denominator === 0 ? 0 : dotProduct / denominator;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/features/magic-context/memory/embedding.ts
|
|
390
|
+
var DEFAULT_EMBEDDING_CONFIG = {
|
|
391
|
+
provider: "local",
|
|
392
|
+
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
393
|
+
local_runtime: "auto"
|
|
394
|
+
};
|
|
395
|
+
var embeddingConfig = DEFAULT_EMBEDDING_CONFIG;
|
|
396
|
+
var provider = null;
|
|
397
|
+
function createProvider(config) {
|
|
398
|
+
if (config.provider === "off") {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
if (config.provider === "openai-compatible") {
|
|
402
|
+
return new OpenAICompatibleEmbeddingProvider({
|
|
403
|
+
endpoint: config.endpoint,
|
|
404
|
+
model: config.model,
|
|
405
|
+
apiKey: config.api_key,
|
|
406
|
+
inputType: config.input_type,
|
|
407
|
+
queryInputType: config.query_input_type,
|
|
408
|
+
queryInstruction: config.query_instruction,
|
|
409
|
+
documentPrefix: config.document_prefix,
|
|
410
|
+
truncate: config.truncate,
|
|
411
|
+
dimensions: config.dimensions,
|
|
412
|
+
maxInputTokens: config.max_input_tokens
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
if (config.provider === "local") {
|
|
416
|
+
return new LocalEmbeddingProvider(config.model, config.max_input_tokens, config.local_dtype, config.local_runtime);
|
|
417
|
+
}
|
|
418
|
+
if (config.provider === "synapse") {
|
|
419
|
+
const synapse = config;
|
|
420
|
+
return new SynapseEmbeddingProvider({
|
|
421
|
+
connectionFile: synapse.synapse_connection_file ?? "",
|
|
422
|
+
projectRoot: "",
|
|
423
|
+
session: "embedding",
|
|
424
|
+
model: synapse.model,
|
|
425
|
+
fingerprint: synapse.synapse_fingerprint,
|
|
426
|
+
tableEpoch: synapse.synapse_table_epoch,
|
|
427
|
+
dims: synapse.synapse_dims,
|
|
428
|
+
recommendedBatch: synapse.synapse_recommended_batch,
|
|
429
|
+
recommendedTokenBudget: synapse.synapse_recommended_token_budget,
|
|
430
|
+
descriptor: synapse.synapse_descriptor,
|
|
431
|
+
provenance: synapse.synapse_provenance
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
throw new Error("Unknown embedding provider");
|
|
435
|
+
}
|
|
436
|
+
function getOrCreateProvider() {
|
|
437
|
+
if (provider) {
|
|
438
|
+
return provider;
|
|
439
|
+
}
|
|
440
|
+
provider = createProvider(embeddingConfig);
|
|
441
|
+
return provider;
|
|
442
|
+
}
|
|
443
|
+
function isEmbeddingEnabled() {
|
|
444
|
+
return embeddingConfig.provider !== "off";
|
|
445
|
+
}
|
|
446
|
+
async function embedText(text, signal) {
|
|
447
|
+
const currentProvider = getOrCreateProvider();
|
|
448
|
+
if (!currentProvider) {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
if (!await currentProvider.initialize()) {
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
const vector = await currentProvider.embed(text, signal);
|
|
455
|
+
return vector && !isSynapseEmbeddingTruncated(vector) ? vector : null;
|
|
456
|
+
}
|
|
361
457
|
// src/features/magic-context/memory/promotion.ts
|
|
362
458
|
function isPromotableCategory(category) {
|
|
363
459
|
return PROMOTABLE_CATEGORIES.some((promotableCategory) => promotableCategory === category);
|
|
@@ -788,4 +884,4 @@ async function normalizeVerificationFiles(args) {
|
|
|
788
884
|
gitRoot
|
|
789
885
|
};
|
|
790
886
|
}
|
|
791
|
-
export { USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, promoteSessionFactsDurable, embedPromotedFacts, relaxedFtsQuery, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles };
|
|
887
|
+
export { USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, cosineSimilarity, isEmbeddingEnabled, embedText, promoteSessionFactsDurable, embedPromotedFacts, relaxedFtsQuery, sanitizeFtsQuery, searchMemoriesFTS, searchMemoriesFTSUnion, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEmbeddingHostBusy2
|
|
3
|
+
} from "./server-qt1qqasc.js";
|
|
4
|
+
import {
|
|
5
|
+
log2
|
|
6
|
+
} from "./server-j8376q08.js";
|
|
7
|
+
import {
|
|
8
|
+
contentSha2562,
|
|
9
|
+
getProjectEmbeddingSnapshot2,
|
|
10
|
+
embedItemsWindowBounded2
|
|
11
|
+
} from "./server-t091cjj4.js";
|
|
12
|
+
import {
|
|
13
|
+
saveEmbeddingIfHashMatches
|
|
14
|
+
} from "./server-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 };
|
|
@@ -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-eb49qfzz.js"));
|
|
1025
1025
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-ynb3vg6r.js"));
|
|
1026
1026
|
if (signal.aborted)
|
|
1027
1027
|
return;
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
} from "./server-y8xjr8rx.js";
|
|
4
4
|
import {
|
|
5
5
|
getTagById2
|
|
6
|
-
} from "./server-
|
|
6
|
+
} from "./server-cxkb9725.js";
|
|
7
7
|
import {
|
|
8
8
|
expandToolPart,
|
|
9
9
|
visitRawSessionMessages2,
|
|
10
10
|
readRawSessionMessageById2
|
|
11
|
-
} from "./server-
|
|
11
|
+
} from "./server-k8mj4ccb.js";
|
|
12
12
|
|
|
13
13
|
// src/tools/ctx-expand/render.ts
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
@@ -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;
|
|
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
140
|
import("./store-reader-yaxtdy6f.js"),
|
|
141
141
|
import("./store-4se2a0n0.js"),
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
142
|
+
import("./read-session-chunk-eb49qfzz.js"),
|
|
143
|
+
import("./render-rw6tk2fj.js"),
|
|
144
|
+
import("./search-archive-w33x2z9z.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
package/dist/v2/server.js
CHANGED
|
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7875
7875
|
// package.json
|
|
7876
7876
|
var package_default = {
|
|
7877
7877
|
name: "@cortexkit/opencode-magic-context",
|
|
7878
|
-
version: "0.49.
|
|
7878
|
+
version: "0.49.73",
|
|
7879
7879
|
type: "module",
|
|
7880
7880
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7881
7881
|
main: "dist/index.js",
|
|
@@ -8196,7 +8196,7 @@ async function setup(context) {
|
|
|
8196
8196
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8197
8197
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
8198
8198
|
}
|
|
8199
|
-
const { registerContext } = await import("./context-
|
|
8199
|
+
const { registerContext } = await import("./context-4rmbpek8.js");
|
|
8200
8200
|
setHarness2("opencode2");
|
|
8201
8201
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8202
8202
|
const duties = await registerContext(context);
|
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
renewCompartmentLease,
|
|
11
11
|
releaseCompartmentLeaseBestEffort,
|
|
12
12
|
getCompartments,
|
|
13
|
-
getLastCompartmentEndMessage
|
|
14
|
-
|
|
13
|
+
getLastCompartmentEndMessage,
|
|
14
|
+
requestPendingMaterialization
|
|
15
|
+
} from "./server-11rbew2r.js";
|
|
15
16
|
import"./server-2amn2s73.js";
|
|
16
17
|
import"./server-y8xjr8rx.js";
|
|
17
18
|
import"./server-x6fn9x8q.js";
|
|
@@ -24,7 +25,7 @@ import"./server-1d042x6w.js";
|
|
|
24
25
|
import"./server-6ash6z8z.js";
|
|
25
26
|
import"./server-ds8vpfkr.js";
|
|
26
27
|
import"./server-8pdfmc27.js";
|
|
27
|
-
import"./server-
|
|
28
|
+
import"./server-d0ec5f7b.js";
|
|
28
29
|
import {
|
|
29
30
|
getWrapupInProgressState,
|
|
30
31
|
acquireWrapupInProgress,
|
|
@@ -32,16 +33,16 @@ import {
|
|
|
32
33
|
releaseWrapupInProgress,
|
|
33
34
|
getHistorianFailureState,
|
|
34
35
|
clearEmergencyRecovery
|
|
35
|
-
} from "./server-
|
|
36
|
+
} from "./server-cxkb9725.js";
|
|
36
37
|
import"./server-xepx8t43.js";
|
|
37
|
-
import"./server-
|
|
38
|
+
import"./server-rpdbmk63.js";
|
|
38
39
|
import"./server-1zx87sdm.js";
|
|
39
40
|
import"./server-rz6g5xne.js";
|
|
40
41
|
import"./server-2ra6pwf3.js";
|
|
41
42
|
import"./server-3ap5dmhc.js";
|
|
42
43
|
import {
|
|
43
44
|
prepareRawSessionOrdinals2
|
|
44
|
-
} from "./server-
|
|
45
|
+
} from "./server-k8mj4ccb.js";
|
|
45
46
|
import"./server-fr0wbhdn.js";
|
|
46
47
|
import"./server-jn4pktdk.js";
|
|
47
48
|
import"./server-afsz3cmx.js";
|
|
@@ -63,15 +64,15 @@ import {
|
|
|
63
64
|
registerActiveCompartmentRun,
|
|
64
65
|
setRecompStarting2,
|
|
65
66
|
setRecompTerminal2
|
|
66
|
-
} from "./server-
|
|
67
|
+
} from "./server-kya7jvx5.js";
|
|
67
68
|
import"./server-qt1qqasc.js";
|
|
68
|
-
import"./server-
|
|
69
|
+
import"./server-t091cjj4.js";
|
|
69
70
|
import"./server-jtq03rkb.js";
|
|
70
71
|
import"./server-4dhv7mqz.js";
|
|
71
72
|
import"./server-d706s5xn.js";
|
|
72
|
-
import"./server-
|
|
73
|
+
import"./server-ndkzagjz.js";
|
|
74
|
+
import"./server-rd7v8c8y.js";
|
|
73
75
|
import"./server-jjvbk92s.js";
|
|
74
|
-
import"./server-d07yxksx.js";
|
|
75
76
|
import"./server-9sf3qp02.js";
|
|
76
77
|
import"./server-2adwe0be.js";
|
|
77
78
|
import"./server-aewxmvnf.js";
|
|
@@ -118,11 +119,6 @@ function formatAlreadyRunningMessage(state) {
|
|
|
118
119
|
const through = state.lastCompartmentEnd > 0 ? ` through message ${state.lastCompartmentEnd}` : "";
|
|
119
120
|
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.`;
|
|
120
121
|
}
|
|
121
|
-
function appendFlushHint(ctx, sessionId, message) {
|
|
122
|
-
if (ctx.hasPendingNaturalBust?.(sessionId))
|
|
123
|
-
return message;
|
|
124
|
-
return `${message} If you want it applied on the very next message, run /ctx-flush first.`;
|
|
125
|
-
}
|
|
126
122
|
function buildPlan(ctx, sessionId, messagesToKeep, anchorRawMessageCount) {
|
|
127
123
|
return resolveWrapupProtectedTailBoundary({
|
|
128
124
|
db: ctx.db,
|
|
@@ -308,8 +304,8 @@ ${message}`;
|
|
|
308
304
|
|
|
309
305
|
${message}`;
|
|
310
306
|
}
|
|
311
|
-
|
|
312
|
-
|
|
307
|
+
let startLastEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
|
|
308
|
+
let startCompartmentCount = getCompartments(ctx.db, sessionId).length;
|
|
313
309
|
let chunkIndex = 0;
|
|
314
310
|
let lastEnd = startLastEnd;
|
|
315
311
|
let stoppedForFailure = false;
|
|
@@ -353,6 +349,9 @@ ${message}`;
|
|
|
353
349
|
if (activeAtStart === "timeout") {
|
|
354
350
|
stoppedForFailure = true;
|
|
355
351
|
stoppedReason = "Timed out waiting for the active historian run.";
|
|
352
|
+
} else {
|
|
353
|
+
startLastEnd = lastEnd = getLastCompartmentEndMessage(ctx.db, sessionId);
|
|
354
|
+
startCompartmentCount = getCompartments(ctx.db, sessionId).length;
|
|
356
355
|
}
|
|
357
356
|
if (!stoppedForFailure) {
|
|
358
357
|
try {
|
|
@@ -460,8 +459,11 @@ ${message}`;
|
|
|
460
459
|
try {
|
|
461
460
|
clearEmergencyRecovery(ctx.db, sessionId);
|
|
462
461
|
} catch {}
|
|
463
|
-
|
|
464
|
-
|
|
462
|
+
let message = `Wrapped up ${messagesWrapped} messages into ${compartmentsCreated} compartments.`;
|
|
463
|
+
if (compartmentsCreated > 0) {
|
|
464
|
+
requestPendingMaterialization(ctx.liveSessionState.pendingMaterializationSessions, sessionId, "user_wrapup");
|
|
465
|
+
message += " The compacted history applies on your next message, or on the next rebuild if the host restarts first.";
|
|
466
|
+
}
|
|
465
467
|
setRecompTerminal2(ctx.liveSessionState, sessionId, "done", message);
|
|
466
468
|
return message;
|
|
467
469
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runManagedWrapup2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-cpmqvc1c.js";
|
|
4
|
+
import"./index-h2w3kzkt.js";
|
|
5
|
+
import"./index-k2rk6z1y.js";
|
|
6
6
|
import"./index-832w615x.js";
|
|
7
7
|
import"./index-sd3egckz.js";
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
8
|
+
import"./index-ve863q40.js";
|
|
9
|
+
import"./index-q9ywd8b2.js";
|
|
10
10
|
import"./index-jjvbk92s.js";
|
|
11
|
-
import"./index-
|
|
11
|
+
import"./index-9swgykdd.js";
|
|
12
12
|
import"./index-4dhv7mqz.js";
|
|
13
|
-
import"./index-
|
|
13
|
+
import"./index-ne2awfqp.js";
|
|
14
14
|
import"./index-tebcx987.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-etm62gd7.js";
|
|
16
16
|
import"./index-2amn2s73.js";
|
|
17
17
|
import"./index-6athgjba.js";
|
|
18
18
|
import"./index-ngwmx6nt.js";
|
|
19
19
|
import"./index-1sq1krqw.js";
|
|
20
20
|
import"./index-qt1qqasc.js";
|
|
21
|
-
import"./index-
|
|
22
|
-
import"./index-
|
|
21
|
+
import"./index-yhz1w3ss.js";
|
|
22
|
+
import"./index-bdnak4d0.js";
|
|
23
23
|
import"./index-1zx87sdm.js";
|
|
24
24
|
import"./index-x40zr813.js";
|
|
25
25
|
import"./index-x8a7jmkh.js";
|
|
@@ -29,7 +29,7 @@ import"./index-6nqz8hsz.js";
|
|
|
29
29
|
import"./index-jg7sbt3v.js";
|
|
30
30
|
import"./index-snbpdpa3.js";
|
|
31
31
|
import"./index-pxnzyvjc.js";
|
|
32
|
-
import"./index-
|
|
32
|
+
import"./index-3mx8math.js";
|
|
33
33
|
import"./index-fb3zxn06.js";
|
|
34
34
|
import"./index-xx05vta0.js";
|
|
35
35
|
import"./index-fr0wbhdn.js";
|
package/package.json
CHANGED