@cortexkit/pi-magic-context 0.49.71 → 0.49.72
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/{embedding-backfill-3g3cm51d.js → embedding-backfill-p0qszhx7.js} +2 -2
- package/dist/{index-73fw4cd4.js → index-6gwasf0v.js} +17 -3
- package/dist/{index-sg6tdkqh.js → index-9a92hc6c.js} +1 -1
- package/dist/{index-2kb65n0s.js → index-apff8dej.js} +1 -1
- package/dist/{index-2bavnrw8.js → index-cevw58nn.js} +99 -8
- package/dist/{index-4dqwxb7k.js → index-cyzsn2hb.js} +1 -1
- package/dist/{index-bcwy4wm1.js → index-dw9x7k2b.js} +8 -8
- package/dist/{index-tcrd11cb.js → index-kqekqrzw.js} +3 -3
- package/dist/{index-d7yx4ymd.js → index-mm9y1m77.js} +1 -1
- package/dist/{index-zgj2mxrn.js → index-r4qt07th.js} +3 -3
- package/dist/index-w2snpk0j.js +65 -0
- package/dist/{index-51xr6g7s.js → index-wmkkxwvf.js} +1 -1
- package/dist/{index-e9wkbh8y.js → index-yk0ve8hn.js} +4 -3
- package/dist/index.js +14 -15
- package/dist/{message-index-bounded-fqeqp76p.js → message-index-bounded-cv87994v.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-63wsm3a8.js → project-embedding-registry-2natnvdf.js} +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-tjj2wzxs.js → read-session-chunk-ygwyfvtr.js} +2 -2
- package/dist/{render-793jtz3r.js → render-bsdcxgaq.js} +5 -5
- package/dist/{search-archive-gmyvkadj.js → search-archive-3hh7ycvm.js} +4 -4
- package/dist/{search-7tpgsnbs.js → search-hm8dc1e8.js} +6 -6
- package/dist/{storage-tags-wq8p5wrh.js → storage-tags-zzttnzn6.js} +1 -1
- package/dist/subagent-entry.js +11 -11
- package/dist/tag-snapshot-worker-pi.js +3 -3
- package/dist/{v2-archive-reader-99stcer0.js → v2-archive-reader-b7spmyqa.js} +1 -1
- package/package.json +1 -1
- package/dist/index-qdy49kwk.js +0 -155
|
@@ -27,11 +27,11 @@ serveWorkerJobs(async (initial, port) => {
|
|
|
27
27
|
{ Database, registerSqliteDiagnosticSink },
|
|
28
28
|
{ log }
|
|
29
29
|
] = await Promise.all([
|
|
30
|
-
import("./embedding-backfill-
|
|
30
|
+
import("./embedding-backfill-p0qszhx7.js"),
|
|
31
31
|
import("./embedding-cache-7rp4gqzr.js"),
|
|
32
32
|
import("./storage-memory-0ndn65fm.js"),
|
|
33
|
-
import("./project-embedding-registry-
|
|
34
|
-
import("./search-
|
|
33
|
+
import("./project-embedding-registry-2natnvdf.js"),
|
|
34
|
+
import("./search-hm8dc1e8.js"),
|
|
35
35
|
import("./compartment-chunk-embedding-avkyp2df.js"),
|
|
36
36
|
import("./embedding-activity-ew6dshfd.js"),
|
|
37
37
|
import("./harness-9872e0ym.js"),
|
|
@@ -2770,16 +2770,30 @@ function isAnthropicFamilyRoute(providerID, modelID) {
|
|
|
2770
2770
|
var REMOVED_REASONING_MARK = Symbol.for("magic-context.removed-reasoning");
|
|
2771
2771
|
var NEUTRALIZED_ORIGINALS = new WeakMap;
|
|
2772
2772
|
var VARIANT_CACHE_PRESERVING_MODELS = {
|
|
2773
|
-
"anthropic/claude-fable-5-1": "2026-09-02",
|
|
2774
|
-
"openai/gpt-6-astra": "2026-09-05",
|
|
2775
|
-
"anthropic/claude-opus-5-5": "2026-09-23"
|
|
2773
|
+
"anthropic/claude-fable-5-1": ["2026-09-02"],
|
|
2774
|
+
"openai/gpt-6-astra": ["2026-09-05"],
|
|
2775
|
+
"anthropic/claude-opus-5-5": ["2026-09-23", true],
|
|
2776
|
+
"anthropic/claude-sonnet-5-5": ["2026-11-23", true],
|
|
2777
|
+
"anthropic/claude-haiku-5-5": ["2026-11-23", true],
|
|
2778
|
+
"anthropic/claude-fable-5-2": ["2026-11-23", true],
|
|
2779
|
+
"anthropic/claude-mythos-5-1": ["2026-11-23", true],
|
|
2780
|
+
"anthropic/claude-mythos-5-2": ["2026-11-23", true]
|
|
2776
2781
|
};
|
|
2782
|
+
var CLAUDE_VARIANT_ALIAS = /^(?:(?:[a-z0-9-]+\.)?anthropic\.)?(?:claude-)?([a-z]+)[-_.]?([0-9]+)[-_.]([0-9]+)(?:[-@][0-9]{8})?(?:-v[0-9]+:[0-9]+)?$/i;
|
|
2777
2783
|
function canonicalVariantModelIdentity(providerID, modelID) {
|
|
2778
2784
|
const normalizedProviderID = providerID.toLowerCase();
|
|
2779
2785
|
const isAnthropicFamily = normalizedProviderID === "anthropic" || normalizedProviderID === "google-vertex-anthropic" || normalizedProviderID.includes("bedrock");
|
|
2780
2786
|
if (isAnthropicFamily && isFable51ThinkingBindingModel("anthropic", modelID)) {
|
|
2781
2787
|
return "anthropic/claude-fable-5-1";
|
|
2782
2788
|
}
|
|
2789
|
+
if (isAnthropicFamily) {
|
|
2790
|
+
const alias = CLAUDE_VARIANT_ALIAS.exec(modelID.split("/").at(-1) ?? "");
|
|
2791
|
+
if (alias) {
|
|
2792
|
+
const identity = `anthropic/claude-${alias[1].toLowerCase()}-${alias[2]}-${alias[3]}`;
|
|
2793
|
+
if (VARIANT_CACHE_PRESERVING_MODELS[identity]?.[1])
|
|
2794
|
+
return identity;
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2783
2797
|
return canonicalModelIdentity(`${providerID}/${modelID}`).toLowerCase();
|
|
2784
2798
|
}
|
|
2785
2799
|
function variantChangeBustsProviderCache(providerID, modelID) {
|
|
@@ -1787,7 +1787,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1787
1787
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1788
1788
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1789
1789
|
return;
|
|
1790
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1790
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-ygwyfvtr.js"));
|
|
1791
1791
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-8zwv9byv.js"));
|
|
1792
1792
|
if (signal.aborted)
|
|
1793
1793
|
return;
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
PROMOTABLE_CATEGORIES,
|
|
6
6
|
CATEGORY_DEFAULT_TTL
|
|
7
7
|
} from "./index-135e8hvg.js";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
10
|
+
} from "./index-vcegxfwg.js";
|
|
8
11
|
import {
|
|
9
12
|
getHarness2
|
|
10
13
|
} from "./index-0h2mkab2.js";
|
|
@@ -14,7 +17,9 @@ import {
|
|
|
14
17
|
sessionLog2
|
|
15
18
|
} from "./index-tm11k42a.js";
|
|
16
19
|
import {
|
|
17
|
-
SubcClient
|
|
20
|
+
SubcClient,
|
|
21
|
+
isSynapseEmbeddingTruncated,
|
|
22
|
+
SynapseEmbeddingProvider
|
|
18
23
|
} from "./index-5rcjs14a.js";
|
|
19
24
|
import {
|
|
20
25
|
inRootAsyncContext2,
|
|
@@ -32,6 +37,10 @@ import {
|
|
|
32
37
|
warmCompartmentChunkSearchPool2
|
|
33
38
|
} from "./index-cxczethe.js";
|
|
34
39
|
import {
|
|
40
|
+
LocalEmbeddingProvider
|
|
41
|
+
} from "./index-txcs0vnj.js";
|
|
42
|
+
import {
|
|
43
|
+
OpenAICompatibleEmbeddingProvider,
|
|
35
44
|
saveCommitEmbedding,
|
|
36
45
|
loadProjectCommitEmbeddings,
|
|
37
46
|
loadUnembeddedCommits,
|
|
@@ -47,7 +56,7 @@ import {
|
|
|
47
56
|
getProjectEmbeddingSnapshot2,
|
|
48
57
|
embedTextForProject2,
|
|
49
58
|
embedItemsForProject2
|
|
50
|
-
} from "./index-
|
|
59
|
+
} from "./index-yk0ve8hn.js";
|
|
51
60
|
import {
|
|
52
61
|
recordEmbeddingMeasurement
|
|
53
62
|
} from "./index-hgd00nas.js";
|
|
@@ -59,11 +68,8 @@ import {
|
|
|
59
68
|
getProjectEmbeddings2
|
|
60
69
|
} from "./index-yhzhdp3m.js";
|
|
61
70
|
import {
|
|
62
|
-
cosineSimilarity,
|
|
63
|
-
isEmbeddingEnabled,
|
|
64
|
-
embedText,
|
|
65
71
|
ensureMemoryEmbeddings2
|
|
66
|
-
} from "./index-
|
|
72
|
+
} from "./index-w2snpk0j.js";
|
|
67
73
|
import {
|
|
68
74
|
getMemorySelectColumns2,
|
|
69
75
|
isMemoryRow2,
|
|
@@ -91,7 +97,7 @@ import {
|
|
|
91
97
|
clearIndexedMessages,
|
|
92
98
|
indexSingleMessage,
|
|
93
99
|
indexMessagesAfterOrdinal
|
|
94
|
-
} from "./index-
|
|
100
|
+
} from "./index-mm9y1m77.js";
|
|
95
101
|
import {
|
|
96
102
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
97
103
|
withMessageFtsSessionFilter
|
|
@@ -463,6 +469,91 @@ function projectNeedsSingleStoreMigration(db, projectPath) {
|
|
|
463
469
|
const table = db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'authority_managed'").get();
|
|
464
470
|
return Boolean(table && db.prepare("SELECT 1 FROM authority_managed WHERE project_path = ?").get(projectPath));
|
|
465
471
|
}
|
|
472
|
+
// ../plugin/src/features/magic-context/memory/cosine-similarity.ts
|
|
473
|
+
function cosineSimilarity(a, b) {
|
|
474
|
+
if (a.length !== b.length) {
|
|
475
|
+
return 0;
|
|
476
|
+
}
|
|
477
|
+
let dotProduct = 0;
|
|
478
|
+
let normA = 0;
|
|
479
|
+
let normB = 0;
|
|
480
|
+
for (let index = 0;index < a.length; index++) {
|
|
481
|
+
dotProduct += a[index] * b[index];
|
|
482
|
+
normA += a[index] * a[index];
|
|
483
|
+
normB += b[index] * b[index];
|
|
484
|
+
}
|
|
485
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
486
|
+
return denominator === 0 ? 0 : dotProduct / denominator;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// ../plugin/src/features/magic-context/memory/embedding.ts
|
|
490
|
+
var DEFAULT_EMBEDDING_CONFIG = {
|
|
491
|
+
provider: "local",
|
|
492
|
+
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
493
|
+
local_runtime: "auto"
|
|
494
|
+
};
|
|
495
|
+
var embeddingConfig = DEFAULT_EMBEDDING_CONFIG;
|
|
496
|
+
var provider = null;
|
|
497
|
+
function createProvider(config) {
|
|
498
|
+
if (config.provider === "off") {
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
if (config.provider === "openai-compatible") {
|
|
502
|
+
return new OpenAICompatibleEmbeddingProvider({
|
|
503
|
+
endpoint: config.endpoint,
|
|
504
|
+
model: config.model,
|
|
505
|
+
apiKey: config.api_key,
|
|
506
|
+
inputType: config.input_type,
|
|
507
|
+
queryInputType: config.query_input_type,
|
|
508
|
+
queryInstruction: config.query_instruction,
|
|
509
|
+
documentPrefix: config.document_prefix,
|
|
510
|
+
truncate: config.truncate,
|
|
511
|
+
dimensions: config.dimensions,
|
|
512
|
+
maxInputTokens: config.max_input_tokens
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
if (config.provider === "local") {
|
|
516
|
+
return new LocalEmbeddingProvider(config.model, config.max_input_tokens, config.local_dtype, config.local_runtime);
|
|
517
|
+
}
|
|
518
|
+
if (config.provider === "synapse") {
|
|
519
|
+
const synapse = config;
|
|
520
|
+
return new SynapseEmbeddingProvider({
|
|
521
|
+
connectionFile: synapse.synapse_connection_file ?? "",
|
|
522
|
+
projectRoot: "",
|
|
523
|
+
session: "embedding",
|
|
524
|
+
model: synapse.model,
|
|
525
|
+
fingerprint: synapse.synapse_fingerprint,
|
|
526
|
+
tableEpoch: synapse.synapse_table_epoch,
|
|
527
|
+
dims: synapse.synapse_dims,
|
|
528
|
+
recommendedBatch: synapse.synapse_recommended_batch,
|
|
529
|
+
recommendedTokenBudget: synapse.synapse_recommended_token_budget,
|
|
530
|
+
descriptor: synapse.synapse_descriptor,
|
|
531
|
+
provenance: synapse.synapse_provenance
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
throw new Error("Unknown embedding provider");
|
|
535
|
+
}
|
|
536
|
+
function getOrCreateProvider() {
|
|
537
|
+
if (provider) {
|
|
538
|
+
return provider;
|
|
539
|
+
}
|
|
540
|
+
provider = createProvider(embeddingConfig);
|
|
541
|
+
return provider;
|
|
542
|
+
}
|
|
543
|
+
function isEmbeddingEnabled() {
|
|
544
|
+
return embeddingConfig.provider !== "off";
|
|
545
|
+
}
|
|
546
|
+
async function embedText(text, signal) {
|
|
547
|
+
const currentProvider = getOrCreateProvider();
|
|
548
|
+
if (!currentProvider) {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
if (!await currentProvider.initialize()) {
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
const vector = await currentProvider.embed(text, signal);
|
|
555
|
+
return vector && !isSynapseEmbeddingTruncated(vector) ? vector : null;
|
|
556
|
+
}
|
|
466
557
|
// ../plugin/src/features/magic-context/memory/promotion.ts
|
|
467
558
|
function isPromotableCategory(category) {
|
|
468
559
|
return PROMOTABLE_CATEGORIES.some((promotableCategory) => promotableCategory === category);
|
|
@@ -3891,4 +3982,4 @@ ${bodyParts.join(`
|
|
|
3891
3982
|
`)}`;
|
|
3892
3983
|
}
|
|
3893
3984
|
|
|
3894
|
-
export { USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits, getMessageIndexEpoch, isMessageIndexSearchable, scheduleReconciliation, scheduleIncrementalIndex, scheduleClearAndReindex, clearSessionTracking, createAutoSearchDiagnostics, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
3985
|
+
export { USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, cosineSimilarity, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits, getMessageIndexEpoch, isMessageIndexSearchable, scheduleReconciliation, scheduleIncrementalIndex, scheduleClearAndReindex, clearSessionTracking, createAutoSearchDiagnostics, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
import {
|
|
57
57
|
piHarnessKindFromExecutable,
|
|
58
58
|
getErrorMessage
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-9a92hc6c.js";
|
|
60
60
|
import {
|
|
61
61
|
getOrCreateSessionMeta,
|
|
62
62
|
updateSessionMeta,
|
|
@@ -70,10 +70,10 @@ import {
|
|
|
70
70
|
renderMessageByOrdinal2,
|
|
71
71
|
renderVerboseRange2,
|
|
72
72
|
renderItemByTag2
|
|
73
|
-
} from "./index-
|
|
73
|
+
} from "./index-kqekqrzw.js";
|
|
74
74
|
import {
|
|
75
75
|
getLastIndexedOrdinal
|
|
76
|
-
} from "./index-
|
|
76
|
+
} from "./index-mm9y1m77.js";
|
|
77
77
|
import {
|
|
78
78
|
TODO_STATUSES,
|
|
79
79
|
TODO_PRIORITIES,
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
getCompactionMarkerPublicationState,
|
|
90
90
|
compareAndSetCompactionMarkerPublicationState,
|
|
91
91
|
getDeferredClearedCompactionMarkerState
|
|
92
|
-
} from "./index-
|
|
92
|
+
} from "./index-6gwasf0v.js";
|
|
93
93
|
import {
|
|
94
94
|
stableStringify,
|
|
95
95
|
BoundedSessionMap
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
unregisterProjectEmbedding2,
|
|
130
130
|
getProjectEmbeddingSnapshot2,
|
|
131
131
|
embedTextForProject2
|
|
132
|
-
} from "./index-
|
|
132
|
+
} from "./index-yk0ve8hn.js";
|
|
133
133
|
import {
|
|
134
134
|
directoryHasGitMetadata,
|
|
135
135
|
resolveProjectIdentityForSession,
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
resolveMemoriesByIdsForSearch2,
|
|
143
143
|
unifiedSearch2,
|
|
144
144
|
formatSearchResults2
|
|
145
|
-
} from "./index-
|
|
145
|
+
} from "./index-cevw58nn.js";
|
|
146
146
|
import {
|
|
147
147
|
resolveOpenCodeDbPath,
|
|
148
148
|
assertOpenCodeStoreGeneration
|
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
hasRawMessageProvider2,
|
|
152
152
|
setRawMessageProvider2,
|
|
153
153
|
readSessionChunk2
|
|
154
|
-
} from "./index-
|
|
154
|
+
} from "./index-apff8dej.js";
|
|
155
155
|
import {
|
|
156
156
|
resolveWorkspaceShareCategories,
|
|
157
157
|
resolveWorkspaceIdentitySet,
|
|
@@ -184,7 +184,7 @@ import {
|
|
|
184
184
|
} from "./index-3s39a1md.js";
|
|
185
185
|
import {
|
|
186
186
|
renderSearchArchive2
|
|
187
|
-
} from "./index-
|
|
187
|
+
} from "./index-cyzsn2hb.js";
|
|
188
188
|
import {
|
|
189
189
|
computeNormalizedHash
|
|
190
190
|
} from "./index-9x1f96r8.js";
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
serializeProcessedImageMarkers,
|
|
41
41
|
getPendingPiCompactionMarkerState,
|
|
42
42
|
logPiCompactionMarkerClear
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-6gwasf0v.js";
|
|
44
44
|
import {
|
|
45
45
|
estimateTokens
|
|
46
46
|
} from "./index-pefn1gt5.js";
|
|
@@ -61,13 +61,13 @@ import {
|
|
|
61
61
|
import {
|
|
62
62
|
isPidAlive,
|
|
63
63
|
readProcessStartTime
|
|
64
|
-
} from "./index-
|
|
64
|
+
} from "./index-9a92hc6c.js";
|
|
65
65
|
import {
|
|
66
66
|
withReadOnlySessionDb,
|
|
67
67
|
expandToolPart,
|
|
68
68
|
visitRawSessionMessages2,
|
|
69
69
|
readRawSessionMessageById2
|
|
70
|
-
} from "./index-
|
|
70
|
+
} from "./index-apff8dej.js";
|
|
71
71
|
import {
|
|
72
72
|
gaDatabasePath2,
|
|
73
73
|
V2StoreReader2
|
|
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
139
139
|
import("./sqlite-v89bj0yy.js"),
|
|
140
140
|
import("./store-reader-mmfw2h48.js"),
|
|
141
141
|
import("./store-grcwn6hs.js"),
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
142
|
+
import("./read-session-chunk-ygwyfvtr.js"),
|
|
143
|
+
import("./render-bsdcxgaq.js"),
|
|
144
|
+
import("./search-archive-3hh7ycvm.js"),
|
|
145
145
|
import("./expand-attachments-8sxeyj26.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isEmbeddingHostBusy2
|
|
3
|
+
} from "./index-9p40dgkm.js";
|
|
4
|
+
import {
|
|
5
|
+
log2
|
|
6
|
+
} from "./index-tm11k42a.js";
|
|
7
|
+
import {
|
|
8
|
+
contentSha2562,
|
|
9
|
+
getProjectEmbeddingSnapshot2,
|
|
10
|
+
embedItemsWindowBounded2
|
|
11
|
+
} from "./index-yk0ve8hn.js";
|
|
12
|
+
import {
|
|
13
|
+
saveEmbeddingIfHashMatches
|
|
14
|
+
} from "./index-yhzhdp3m.js";
|
|
15
|
+
|
|
16
|
+
// ../plugin/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 };
|
|
@@ -2558,14 +2558,15 @@ async function embedItemsForProject2(projectIdentity, items, signal, db, session
|
|
|
2558
2558
|
return { vectors, modelId, generation };
|
|
2559
2559
|
}
|
|
2560
2560
|
async function embedItemsWindowBounded2(projectIdentity, items, signal, db, sessionId = projectIdentity, options = {}) {
|
|
2561
|
-
|
|
2561
|
+
const maxItemsPerCall = options.maxItemsPerCall ?? MAX_WINDOWS_PER_EMBED_CALL;
|
|
2562
|
+
if (items.length <= maxItemsPerCall) {
|
|
2562
2563
|
return embedItemsForProject2(projectIdentity, items, signal, db, sessionId);
|
|
2563
2564
|
}
|
|
2564
2565
|
const vectors = new Map;
|
|
2565
2566
|
let modelId = null;
|
|
2566
2567
|
let generation = null;
|
|
2567
|
-
for (let start = 0;start < items.length; start +=
|
|
2568
|
-
const slice = items.slice(start, start +
|
|
2568
|
+
for (let start = 0;start < items.length; start += maxItemsPerCall) {
|
|
2569
|
+
const slice = items.slice(start, start + maxItemsPerCall);
|
|
2569
2570
|
const result = await embedItemsForProject2(projectIdentity, slice, signal, db, sessionId);
|
|
2570
2571
|
if (!result)
|
|
2571
2572
|
return null;
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
registerTodoStateLifecycle,
|
|
159
159
|
syncCtxMemoryToolEnabled,
|
|
160
160
|
registerMagicContextTools
|
|
161
|
-
} from "./index-
|
|
161
|
+
} from "./index-dw9x7k2b.js";
|
|
162
162
|
import"./index-4knyh1kt.js";
|
|
163
163
|
import {
|
|
164
164
|
canonicalModelIdentity,
|
|
@@ -410,7 +410,7 @@ import {
|
|
|
410
410
|
setSessionWorkMetrics,
|
|
411
411
|
getSessionWorkMetrics,
|
|
412
412
|
resolveEpochFloorForPass
|
|
413
|
-
} from "./index-
|
|
413
|
+
} from "./index-6gwasf0v.js";
|
|
414
414
|
import {
|
|
415
415
|
textMentionsRecentCommit,
|
|
416
416
|
hasMeaningfulUserText2,
|
|
@@ -461,7 +461,7 @@ import {
|
|
|
461
461
|
openCurrentDatabase,
|
|
462
462
|
openDatabaseAsync,
|
|
463
463
|
closeDatabase
|
|
464
|
-
} from "./index-
|
|
464
|
+
} from "./index-9a92hc6c.js";
|
|
465
465
|
import {
|
|
466
466
|
LkgRecoveryFenceError,
|
|
467
467
|
clearLkgFenceProcessState,
|
|
@@ -587,7 +587,7 @@ import {
|
|
|
587
587
|
getSourceContents,
|
|
588
588
|
recordSubagentInvocation,
|
|
589
589
|
getLatestHistorianInvocationId
|
|
590
|
-
} from "./index-
|
|
590
|
+
} from "./index-kqekqrzw.js";
|
|
591
591
|
import {
|
|
592
592
|
resolveOpenCodeDbPath,
|
|
593
593
|
assertOpenCodeStoreGeneration,
|
|
@@ -653,7 +653,7 @@ import {
|
|
|
653
653
|
getRawSessionTagKeysThrough2,
|
|
654
654
|
getLegacyProtectedTailStartOrdinal2,
|
|
655
655
|
readSessionChunk2
|
|
656
|
-
} from "./index-
|
|
656
|
+
} from "./index-apff8dej.js";
|
|
657
657
|
import"./index-nvh6d3bz.js";
|
|
658
658
|
import {
|
|
659
659
|
formatSynapseLaneDescriptor
|
|
@@ -693,7 +693,7 @@ import {
|
|
|
693
693
|
clearCompressionDepthRange,
|
|
694
694
|
cleanSearchText,
|
|
695
695
|
matchedSearchSnippet
|
|
696
|
-
} from "./index-
|
|
696
|
+
} from "./index-mm9y1m77.js";
|
|
697
697
|
import {
|
|
698
698
|
rememberV1HiddenRun
|
|
699
699
|
} from "./index-6x556c2q.js";
|
|
@@ -785,10 +785,7 @@ import {
|
|
|
785
785
|
embedSessionCompartmentChunks2,
|
|
786
786
|
getEmbeddingCoverageStatus2,
|
|
787
787
|
getAutoEmbeddingSessionCoverage2
|
|
788
|
-
} from "./index-
|
|
789
|
-
import {
|
|
790
|
-
cosineSimilarity
|
|
791
|
-
} from "./index-qdy49kwk.js";
|
|
788
|
+
} from "./index-yk0ve8hn.js";
|
|
792
789
|
import {
|
|
793
790
|
USER_FACING_FAILURES,
|
|
794
791
|
renderUserFacingFailure,
|
|
@@ -800,6 +797,7 @@ import {
|
|
|
800
797
|
renderSingleStoreMigrationRequiredRefusal,
|
|
801
798
|
SingleStoreMigrationRequiredError,
|
|
802
799
|
projectNeedsSingleStoreMigration,
|
|
800
|
+
cosineSimilarity,
|
|
803
801
|
promoteSessionFactsDurable,
|
|
804
802
|
embedPromotedFacts,
|
|
805
803
|
recordMemoryMapping,
|
|
@@ -822,7 +820,8 @@ import {
|
|
|
822
820
|
scheduleClearAndReindex,
|
|
823
821
|
clearSessionTracking,
|
|
824
822
|
createAutoSearchDiagnostics
|
|
825
|
-
} from "./index-
|
|
823
|
+
} from "./index-cevw58nn.js";
|
|
824
|
+
import"./index-w2snpk0j.js";
|
|
826
825
|
import"./index-3s39a1md.js";
|
|
827
826
|
import {
|
|
828
827
|
DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
|
|
@@ -852,11 +851,11 @@ import {
|
|
|
852
851
|
drainPiTagSnapshotSession,
|
|
853
852
|
assertPiTagSnapshotReady,
|
|
854
853
|
ensurePiTagSnapshotReady
|
|
855
|
-
} from "./index-
|
|
854
|
+
} from "./index-wmkkxwvf.js";
|
|
856
855
|
import"./index-71rg8j43.js";
|
|
857
856
|
import"./index-8d2z6503.js";
|
|
858
|
-
import"./index-
|
|
859
|
-
import"./index-
|
|
857
|
+
import"./index-r4qt07th.js";
|
|
858
|
+
import"./index-cyzsn2hb.js";
|
|
860
859
|
import {
|
|
861
860
|
__toESM
|
|
862
861
|
} from "./index-22jkk6wg.js";
|
|
@@ -3608,7 +3607,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3608
3607
|
// package.json
|
|
3609
3608
|
var package_default = {
|
|
3610
3609
|
name: "@cortexkit/pi-magic-context",
|
|
3611
|
-
version: "0.49.
|
|
3610
|
+
version: "0.49.72",
|
|
3612
3611
|
type: "module",
|
|
3613
3612
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3614
3613
|
main: "dist/index.js",
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
withIndexChunk2,
|
|
4
4
|
yieldIndexChunk2
|
|
5
5
|
} from "./index-2qtx0q6h.js";
|
|
6
|
-
import"./index-
|
|
6
|
+
import"./index-6gwasf0v.js";
|
|
7
7
|
import"./index-pefn1gt5.js";
|
|
8
8
|
import"./index-0h2mkab2.js";
|
|
9
9
|
import"./index-tm11k42a.js";
|
|
@@ -15,7 +15,7 @@ import"./index-wfqysrwq.js";
|
|
|
15
15
|
import"./index-x2n261wp.js";
|
|
16
16
|
import"./index-xjhq27z9.js";
|
|
17
17
|
import"./index-n0zjvs3h.js";
|
|
18
|
-
import"./index-
|
|
18
|
+
import"./index-apff8dej.js";
|
|
19
19
|
import"./index-6x556c2q.js";
|
|
20
20
|
import {
|
|
21
21
|
MESSAGE_INDEX_MAX_FTS_BYTES,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
markMessageIndexDirty,
|
|
25
25
|
getIndexableContent,
|
|
26
26
|
indexSingleMessage
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-mm9y1m77.js";
|
|
28
28
|
import"./index-ghp32f9m.js";
|
|
29
29
|
import"./index-1ts77n1b.js";
|
|
30
30
|
|
package/dist/migration-worker.js
CHANGED
package/dist/{project-embedding-registry-63wsm3a8.js → project-embedding-registry-2natnvdf.js}
RENAMED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
sweepAllRegisteredProjects2,
|
|
35
35
|
_setTestProviderFactoryForProject2,
|
|
36
36
|
_resetProjectEmbeddingRegistryForTests2
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-yk0ve8hn.js";
|
|
38
38
|
import"./index-9p40dgkm.js";
|
|
39
39
|
import"./index-hgd00nas.js";
|
|
40
40
|
import"./index-yhzhdp3m.js";
|
|
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
19
19
|
await main();
|
|
20
20
|
async function main() {
|
|
21
21
|
if (input.v2ArchiveReader) {
|
|
22
|
-
const { serveV2ArchiveReads } = await import("./v2-archive-reader-
|
|
22
|
+
const { serveV2ArchiveReads } = await import("./v2-archive-reader-b7spmyqa.js");
|
|
23
23
|
await serveV2ArchiveReads(port, openConnections);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
51
51
|
await runMessageFtsRowidMapBackfill(db);
|
|
52
52
|
reply = { kind: "fts-rowid-backfill" };
|
|
53
53
|
} else if (input.searchArchive) {
|
|
54
|
-
const { renderSearchArchive } = await import("./search-archive-
|
|
54
|
+
const { renderSearchArchive } = await import("./search-archive-3hh7ycvm.js");
|
|
55
55
|
const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-0tytrjye.js");
|
|
56
56
|
const archive = input.searchArchive;
|
|
57
57
|
let raw;
|
|
@@ -81,7 +81,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
81
81
|
const { setHarness } = await import("./harness-9872e0ym.js");
|
|
82
82
|
setHarness(input.harness ?? "opencode");
|
|
83
83
|
const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
|
|
84
|
-
import("./message-index-bounded-
|
|
84
|
+
import("./message-index-bounded-cv87994v.js"),
|
|
85
85
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
86
86
|
]);
|
|
87
87
|
configureContextDatabasePragmas(db);
|
|
@@ -95,7 +95,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
95
95
|
measurements: result.measurements
|
|
96
96
|
};
|
|
97
97
|
} else if (input.tagRatio !== undefined) {
|
|
98
|
-
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-
|
|
98
|
+
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-zzttnzn6.js");
|
|
99
99
|
const delta = input.tagState ? scanTagOwnerDelta(db, input.sessionId, input.tagState) : null;
|
|
100
100
|
if (delta)
|
|
101
101
|
reply = { kind: "tag-delta", delta };
|
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
readSessionChunk2,
|
|
39
39
|
getRawSessionMessageIdsThrough2,
|
|
40
40
|
readRawSessionSeedTail2
|
|
41
|
-
} from "./index-
|
|
42
|
-
import"./index-
|
|
41
|
+
} from "./index-apff8dej.js";
|
|
42
|
+
import"./index-6gwasf0v.js";
|
|
43
43
|
import"./index-6x556c2q.js";
|
|
44
44
|
import"./index-vcegxfwg.js";
|
|
45
45
|
import"./index-jhmz9tgv.js";
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
renderVerboseRange2,
|
|
4
4
|
renderVerboseRangeForTool2,
|
|
5
5
|
renderItemByTag2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-kqekqrzw.js";
|
|
7
7
|
import"./index-k7a8x7ba.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-mm9y1m77.js";
|
|
9
9
|
import"./index-hgd00nas.js";
|
|
10
10
|
import"./index-nvh6d3bz.js";
|
|
11
11
|
import"./index-cxczethe.js";
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
12
|
+
import"./index-apff8dej.js";
|
|
13
|
+
import"./index-6gwasf0v.js";
|
|
14
14
|
import"./index-6x556c2q.js";
|
|
15
15
|
import"./index-5rcjs14a.js";
|
|
16
16
|
import"./index-vcegxfwg.js";
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-9a92hc6c.js";
|
|
18
18
|
import"./index-fapenpch.js";
|
|
19
19
|
import"./index-gavj3e6h.js";
|
|
20
20
|
import"./index-135e8hvg.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderSearchArchive2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
3
|
+
} from "./index-cyzsn2hb.js";
|
|
4
|
+
import"./index-r4qt07th.js";
|
|
5
5
|
import"./index-8d2z6503.js";
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
6
|
+
import"./index-apff8dej.js";
|
|
7
|
+
import"./index-6gwasf0v.js";
|
|
8
8
|
import"./index-6x556c2q.js";
|
|
9
9
|
import"./index-vcegxfwg.js";
|
|
10
10
|
import"./index-jhmz9tgv.js";
|
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
resolveMemoriesByIdsForSearch2,
|
|
6
6
|
unifiedSearch2,
|
|
7
7
|
formatSearchResults2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-cevw58nn.js";
|
|
9
9
|
import"./index-k7a8x7ba.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-mm9y1m77.js";
|
|
11
11
|
import"./index-8d2z6503.js";
|
|
12
|
-
import"./index-
|
|
12
|
+
import"./index-w2snpk0j.js";
|
|
13
13
|
import"./index-29nw7n1r.js";
|
|
14
|
-
import"./index-
|
|
14
|
+
import"./index-yk0ve8hn.js";
|
|
15
15
|
import"./index-9p40dgkm.js";
|
|
16
16
|
import"./index-hgd00nas.js";
|
|
17
17
|
import"./index-yhzhdp3m.js";
|
|
18
18
|
import"./index-79xfn84y.js";
|
|
19
19
|
import"./index-cxczethe.js";
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
20
|
+
import"./index-apff8dej.js";
|
|
21
|
+
import"./index-6gwasf0v.js";
|
|
22
22
|
import"./index-6x556c2q.js";
|
|
23
23
|
import"./index-txcs0vnj.js";
|
|
24
24
|
import"./index-5rcjs14a.js";
|
package/dist/subagent-entry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TOKEN_BUDGET_TOOL_REFUSAL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-apff8dej.js";
|
|
4
4
|
import {
|
|
5
5
|
setHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import"./index-2qtx0q6h.js";
|
|
15
15
|
import {
|
|
16
16
|
openDatabase
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-9a92hc6c.js";
|
|
18
18
|
import"./index-fapenpch.js";
|
|
19
19
|
import"./index-3bb24eb6.js";
|
|
20
20
|
import"./index-8sqebjzk.js";
|
|
@@ -34,28 +34,28 @@ import {
|
|
|
34
34
|
resolvePiHarnessKind,
|
|
35
35
|
reportSubagentStartupError,
|
|
36
36
|
registerMagicContextTools
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-dw9x7k2b.js";
|
|
38
38
|
import"./index-vcegxfwg.js";
|
|
39
39
|
import"./index-5rcjs14a.js";
|
|
40
40
|
import"./index-cxczethe.js";
|
|
41
41
|
import"./index-txcs0vnj.js";
|
|
42
|
-
import"./index-
|
|
42
|
+
import"./index-yk0ve8hn.js";
|
|
43
43
|
import"./index-hgd00nas.js";
|
|
44
44
|
import"./index-9p40dgkm.js";
|
|
45
45
|
import"./index-79xfn84y.js";
|
|
46
46
|
import"./index-yhzhdp3m.js";
|
|
47
|
-
import"./index-
|
|
48
|
-
import"./index-
|
|
49
|
-
import"./index-
|
|
50
|
-
import"./index-
|
|
47
|
+
import"./index-cevw58nn.js";
|
|
48
|
+
import"./index-kqekqrzw.js";
|
|
49
|
+
import"./index-mm9y1m77.js";
|
|
50
|
+
import"./index-6gwasf0v.js";
|
|
51
51
|
import"./index-6x556c2q.js";
|
|
52
52
|
import"./index-nvh6d3bz.js";
|
|
53
53
|
import"./index-k7a8x7ba.js";
|
|
54
54
|
import"./index-8d2z6503.js";
|
|
55
|
-
import"./index-
|
|
56
|
-
import"./index-
|
|
55
|
+
import"./index-r4qt07th.js";
|
|
56
|
+
import"./index-cyzsn2hb.js";
|
|
57
|
+
import"./index-w2snpk0j.js";
|
|
57
58
|
import"./index-29nw7n1r.js";
|
|
58
|
-
import"./index-2bavnrw8.js";
|
|
59
59
|
import"./index-3s39a1md.js";
|
|
60
60
|
import"./index-1ts77n1b.js";
|
|
61
61
|
import {
|
|
@@ -8,7 +8,7 @@ import"./index-tm11k42a.js";
|
|
|
8
8
|
import {
|
|
9
9
|
LATEST_SUPPORTED_VERSION,
|
|
10
10
|
getPersistedSchemaVersion
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-9a92hc6c.js";
|
|
12
12
|
import"./index-fapenpch.js";
|
|
13
13
|
import"./index-3bb24eb6.js";
|
|
14
14
|
import"./index-8sqebjzk.js";
|
|
@@ -28,14 +28,14 @@ import"./index-pefn1gt5.js";
|
|
|
28
28
|
import {
|
|
29
29
|
normalizeTagSnapshotRow2,
|
|
30
30
|
TAG_SELECT_COLUMNS2
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-6gwasf0v.js";
|
|
32
32
|
import"./index-vcegxfwg.js";
|
|
33
33
|
import {
|
|
34
34
|
encodePiHydrationOperation,
|
|
35
35
|
projectPiPassTag,
|
|
36
36
|
PI_FALLBACK_ROW_COLUMNS,
|
|
37
37
|
PI_FALLBACK_ROW_PREDICATE
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-wmkkxwvf.js";
|
|
39
39
|
import"./index-1ts77n1b.js";
|
|
40
40
|
import {
|
|
41
41
|
serveWorkerJobs
|
package/package.json
CHANGED
package/dist/index-qdy49kwk.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./index-vcegxfwg.js";
|
|
4
|
-
import {
|
|
5
|
-
log2
|
|
6
|
-
} from "./index-tm11k42a.js";
|
|
7
|
-
import {
|
|
8
|
-
isSynapseEmbeddingTruncated,
|
|
9
|
-
SynapseEmbeddingProvider
|
|
10
|
-
} from "./index-5rcjs14a.js";
|
|
11
|
-
import {
|
|
12
|
-
LocalEmbeddingProvider
|
|
13
|
-
} from "./index-txcs0vnj.js";
|
|
14
|
-
import {
|
|
15
|
-
OpenAICompatibleEmbeddingProvider,
|
|
16
|
-
getProjectEmbeddingSnapshot2,
|
|
17
|
-
embedBatchForProject2
|
|
18
|
-
} from "./index-e9wkbh8y.js";
|
|
19
|
-
import {
|
|
20
|
-
isEmbeddingHostBusy2
|
|
21
|
-
} from "./index-9p40dgkm.js";
|
|
22
|
-
import {
|
|
23
|
-
saveEmbeddingIfHashMatches
|
|
24
|
-
} from "./index-yhzhdp3m.js";
|
|
25
|
-
|
|
26
|
-
// ../plugin/src/features/magic-context/memory/cosine-similarity.ts
|
|
27
|
-
function cosineSimilarity(a, b) {
|
|
28
|
-
if (a.length !== b.length) {
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
let dotProduct = 0;
|
|
32
|
-
let normA = 0;
|
|
33
|
-
let normB = 0;
|
|
34
|
-
for (let index = 0;index < a.length; index++) {
|
|
35
|
-
dotProduct += a[index] * b[index];
|
|
36
|
-
normA += a[index] * a[index];
|
|
37
|
-
normB += b[index] * b[index];
|
|
38
|
-
}
|
|
39
|
-
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
40
|
-
return denominator === 0 ? 0 : dotProduct / denominator;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ../plugin/src/features/magic-context/memory/embedding.ts
|
|
44
|
-
var DEFAULT_EMBEDDING_CONFIG = {
|
|
45
|
-
provider: "local",
|
|
46
|
-
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
47
|
-
local_runtime: "auto"
|
|
48
|
-
};
|
|
49
|
-
var embeddingConfig = DEFAULT_EMBEDDING_CONFIG;
|
|
50
|
-
var provider = null;
|
|
51
|
-
function createProvider(config) {
|
|
52
|
-
if (config.provider === "off") {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
if (config.provider === "openai-compatible") {
|
|
56
|
-
return new OpenAICompatibleEmbeddingProvider({
|
|
57
|
-
endpoint: config.endpoint,
|
|
58
|
-
model: config.model,
|
|
59
|
-
apiKey: config.api_key,
|
|
60
|
-
inputType: config.input_type,
|
|
61
|
-
queryInputType: config.query_input_type,
|
|
62
|
-
queryInstruction: config.query_instruction,
|
|
63
|
-
documentPrefix: config.document_prefix,
|
|
64
|
-
truncate: config.truncate,
|
|
65
|
-
dimensions: config.dimensions,
|
|
66
|
-
maxInputTokens: config.max_input_tokens
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (config.provider === "local") {
|
|
70
|
-
return new LocalEmbeddingProvider(config.model, config.max_input_tokens, config.local_dtype, config.local_runtime);
|
|
71
|
-
}
|
|
72
|
-
if (config.provider === "synapse") {
|
|
73
|
-
const synapse = config;
|
|
74
|
-
return new SynapseEmbeddingProvider({
|
|
75
|
-
connectionFile: synapse.synapse_connection_file ?? "",
|
|
76
|
-
projectRoot: "",
|
|
77
|
-
session: "embedding",
|
|
78
|
-
model: synapse.model,
|
|
79
|
-
fingerprint: synapse.synapse_fingerprint,
|
|
80
|
-
tableEpoch: synapse.synapse_table_epoch,
|
|
81
|
-
dims: synapse.synapse_dims,
|
|
82
|
-
recommendedBatch: synapse.synapse_recommended_batch,
|
|
83
|
-
recommendedTokenBudget: synapse.synapse_recommended_token_budget,
|
|
84
|
-
descriptor: synapse.synapse_descriptor,
|
|
85
|
-
provenance: synapse.synapse_provenance
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
throw new Error("Unknown embedding provider");
|
|
89
|
-
}
|
|
90
|
-
function getOrCreateProvider() {
|
|
91
|
-
if (provider) {
|
|
92
|
-
return provider;
|
|
93
|
-
}
|
|
94
|
-
provider = createProvider(embeddingConfig);
|
|
95
|
-
return provider;
|
|
96
|
-
}
|
|
97
|
-
function isEmbeddingEnabled() {
|
|
98
|
-
return embeddingConfig.provider !== "off";
|
|
99
|
-
}
|
|
100
|
-
async function embedText(text, signal) {
|
|
101
|
-
const currentProvider = getOrCreateProvider();
|
|
102
|
-
if (!currentProvider) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
if (!await currentProvider.initialize()) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
const vector = await currentProvider.embed(text, signal);
|
|
109
|
-
return vector && !isSynapseEmbeddingTruncated(vector) ? vector : null;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ../plugin/src/features/magic-context/memory/embedding-backfill.ts
|
|
113
|
-
async function ensureMemoryEmbeddings2(args) {
|
|
114
|
-
if (isEmbeddingHostBusy2())
|
|
115
|
-
return args.existingEmbeddings;
|
|
116
|
-
const snapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
117
|
-
if (!snapshot?.enabled) {
|
|
118
|
-
return args.existingEmbeddings;
|
|
119
|
-
}
|
|
120
|
-
const missingMemories = args.memories.filter((memory) => !args.existingEmbeddings.has(memory.id));
|
|
121
|
-
if (missingMemories.length === 0) {
|
|
122
|
-
return args.existingEmbeddings;
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
const result = await embedBatchForProject2(args.projectIdentity, missingMemories.map((memory) => memory.content));
|
|
126
|
-
if (!result) {
|
|
127
|
-
return args.existingEmbeddings;
|
|
128
|
-
}
|
|
129
|
-
const staged = new Map;
|
|
130
|
-
args.db.transaction(() => {
|
|
131
|
-
for (const [index, memory] of missingMemories.entries()) {
|
|
132
|
-
const embedding = result.vectors[index];
|
|
133
|
-
if (!embedding) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
const saved = saveEmbeddingIfHashMatches(args.db, memory.id, embedding, result.modelId, memory.normalizedHash);
|
|
137
|
-
if (saved) {
|
|
138
|
-
staged.set(memory.id, { embedding, modelId: result.modelId });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}).immediate();
|
|
142
|
-
const currentSnapshot = getProjectEmbeddingSnapshot2(args.projectIdentity);
|
|
143
|
-
if (!currentSnapshot || currentSnapshot.generation !== result.generation) {
|
|
144
|
-
return args.existingEmbeddings;
|
|
145
|
-
}
|
|
146
|
-
for (const [id, embedding] of staged) {
|
|
147
|
-
args.existingEmbeddings.set(id, embedding);
|
|
148
|
-
}
|
|
149
|
-
} catch (error) {
|
|
150
|
-
log2("[magic-context] failed to backfill memory embeddings:", error);
|
|
151
|
-
}
|
|
152
|
-
return args.existingEmbeddings;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export { cosineSimilarity, isEmbeddingEnabled, embedText, ensureMemoryEmbeddings2 };
|