@cortexkit/pi-magic-context 0.49.70 → 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.
Files changed (30) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/{embedding-backfill-3g3cm51d.js → embedding-backfill-p0qszhx7.js} +2 -2
  4. package/dist/{index-73fw4cd4.js → index-6gwasf0v.js} +17 -3
  5. package/dist/{index-sg6tdkqh.js → index-9a92hc6c.js} +1 -1
  6. package/dist/{index-2kb65n0s.js → index-apff8dej.js} +1 -1
  7. package/dist/{index-2bavnrw8.js → index-cevw58nn.js} +99 -8
  8. package/dist/{index-4dqwxb7k.js → index-cyzsn2hb.js} +1 -1
  9. package/dist/{index-bcwy4wm1.js → index-dw9x7k2b.js} +8 -8
  10. package/dist/{index-tcrd11cb.js → index-kqekqrzw.js} +3 -3
  11. package/dist/{index-d7yx4ymd.js → index-mm9y1m77.js} +1 -1
  12. package/dist/{index-zgj2mxrn.js → index-r4qt07th.js} +3 -3
  13. package/dist/index-w2snpk0j.js +65 -0
  14. package/dist/{index-51xr6g7s.js → index-wmkkxwvf.js} +1 -1
  15. package/dist/{index-e9wkbh8y.js → index-yk0ve8hn.js} +4 -3
  16. package/dist/index.js +169 -98
  17. package/dist/{message-index-bounded-fqeqp76p.js → message-index-bounded-cv87994v.js} +3 -3
  18. package/dist/migration-worker.js +1 -1
  19. package/dist/{project-embedding-registry-63wsm3a8.js → project-embedding-registry-2natnvdf.js} +1 -1
  20. package/dist/raw-ordinal-warmup-worker.js +4 -4
  21. package/dist/{read-session-chunk-tjj2wzxs.js → read-session-chunk-ygwyfvtr.js} +2 -2
  22. package/dist/{render-793jtz3r.js → render-bsdcxgaq.js} +5 -5
  23. package/dist/{search-archive-gmyvkadj.js → search-archive-3hh7ycvm.js} +4 -4
  24. package/dist/{search-7tpgsnbs.js → search-hm8dc1e8.js} +6 -6
  25. package/dist/{storage-tags-wq8p5wrh.js → storage-tags-zzttnzn6.js} +1 -1
  26. package/dist/subagent-entry.js +11 -11
  27. package/dist/tag-snapshot-worker-pi.js +3 -3
  28. package/dist/{v2-archive-reader-99stcer0.js → v2-archive-reader-b7spmyqa.js} +1 -1
  29. package/package.json +1 -1
  30. package/dist/index-qdy49kwk.js +0 -155
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./index-zgj2mxrn.js";
4
+ } from "./index-r4qt07th.js";
5
5
  import"./index-8sqebjzk.js";
6
6
  import"./index-2qtx0q6h.js";
7
7
  import"./index-x2n261wp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.49.70",
3
+ "version": "0.49.72",
4
4
  "type": "module",
5
5
  "description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -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 };