agentdb 2.0.0-alpha.2.13 → 2.0.0-alpha.2.15
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/agentdb.browser.js +4 -197
- package/dist/agentdb.browser.js.map +4 -4
- package/dist/agentdb.browser.min.js +2 -2
- package/dist/agentdb.browser.min.js.map +4 -4
- package/dist/src/browser/AttentionBrowser.d.ts.map +1 -1
- package/dist/src/browser/AttentionBrowser.js +1 -0
- package/dist/src/browser/AttentionBrowser.js.map +1 -1
- package/dist/src/cli/agentdb-cli.js +0 -0
- package/dist/src/core/AgentDB.d.ts +2 -1
- package/dist/src/core/AgentDB.d.ts.map +1 -1
- package/dist/src/core/AgentDB.js.map +1 -1
- package/dist/src/wrappers/agentdb-fast.d.ts +1 -0
- package/dist/src/wrappers/agentdb-fast.d.ts.map +1 -1
- package/dist/src/wrappers/agentdb-fast.js +65 -57
- package/dist/src/wrappers/agentdb-fast.js.map +1 -1
- package/dist/src/wrappers/attention-native.d.ts +111 -0
- package/dist/src/wrappers/attention-native.d.ts.map +1 -0
- package/dist/src/wrappers/attention-native.js +273 -0
- package/dist/src/wrappers/attention-native.js.map +1 -0
- package/package.json +20 -11
- package/src/browser/AttentionBrowser.ts +1 -0
- package/src/core/AgentDB.ts +1 -1
- package/src/wrappers/agentdb-fast.ts +74 -42
- package/src/wrappers/attention-native.ts +348 -0
- package/dist/agentdb.min.js +0 -582
- package/dist/src/core/backends/GraphBackend.d.ts +0 -195
- package/dist/src/core/backends/GraphBackend.js +0 -32
- package/dist/src/core/backends/LearningBackend.d.ts +0 -147
- package/dist/src/core/backends/LearningBackend.js +0 -26
- package/dist/src/core/backends/VectorBackend.d.ts +0 -120
- package/dist/src/core/backends/VectorBackend.js +0 -13
- package/dist/src/core/backends/factory.d.ts +0 -49
- package/dist/src/core/backends/factory.js +0 -160
- package/dist/src/core/backends/graph/GraphDatabaseAdapter.d.ts +0 -150
- package/dist/src/core/backends/graph/GraphDatabaseAdapter.js +0 -220
- package/dist/src/core/backends/hnswlib/HNSWLibBackend.d.ts +0 -91
- package/dist/src/core/backends/hnswlib/HNSWLibBackend.js +0 -314
- package/dist/src/core/backends/ruvector/RuVectorBackend.d.ts +0 -74
- package/dist/src/core/backends/ruvector/RuVectorBackend.js +0 -211
- package/dist/src/core/controllers/CausalMemoryGraph.d.ts +0 -178
- package/dist/src/core/controllers/CausalMemoryGraph.js +0 -521
- package/dist/src/core/controllers/EmbeddingService.d.ts +0 -36
- package/dist/src/core/controllers/EmbeddingService.js +0 -138
- package/dist/src/core/controllers/ReflexionMemory.d.ts +0 -124
- package/dist/src/core/controllers/ReflexionMemory.js +0 -648
- package/dist/src/core/controllers/SkillLibrary.d.ts +0 -149
- package/dist/src/core/controllers/SkillLibrary.js +0 -603
- package/dist/src/core/core/AgentDB.d.ts +0 -27
- package/dist/src/core/core/AgentDB.js +0 -83
- package/dist/src/core/services/AttentionService.d.ts +0 -235
- package/dist/src/core/services/AttentionService.js +0 -402
- package/dist/src/core/utils/NodeIdMapper.d.ts +0 -37
- package/dist/src/core/utils/NodeIdMapper.js +0 -56
package/dist/agentdb.browser.js
CHANGED
|
@@ -1,197 +1,4 @@
|
|
|
1
|
-
/*! AgentDB Browser Bundle v2.0.0-alpha.2.
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __esm = (fn, res) => function __init() {
|
|
5
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
-
};
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// dist/agentdb.wasm-loader.js
|
|
13
|
-
var agentdb_wasm_loader_exports = {};
|
|
14
|
-
__export(agentdb_wasm_loader_exports, {
|
|
15
|
-
initWASM: () => initWASM,
|
|
16
|
-
wasmLoadError: () => wasmLoadError,
|
|
17
|
-
wasmModule: () => wasmModule
|
|
18
|
-
});
|
|
19
|
-
async function initWASM() {
|
|
20
|
-
if (wasmModule) return wasmModule;
|
|
21
|
-
if (wasmLoading) return wasmLoading;
|
|
22
|
-
wasmLoading = (async () => {
|
|
23
|
-
try {
|
|
24
|
-
if (typeof WebAssembly === "undefined") {
|
|
25
|
-
throw new Error("WebAssembly not supported in this browser");
|
|
26
|
-
}
|
|
27
|
-
const simdSupported = await detectWasmSIMD();
|
|
28
|
-
console.log(`WASM SIMD support: ${simdSupported}`);
|
|
29
|
-
wasmModule = {
|
|
30
|
-
flashAttention: createFlashAttentionMock(),
|
|
31
|
-
hyperbolicAttention: createHyperbolicAttentionMock(),
|
|
32
|
-
memoryConsolidation: createMemoryConsolidationMock(),
|
|
33
|
-
simdSupported
|
|
34
|
-
};
|
|
35
|
-
console.log("\u2705 WASM attention module loaded");
|
|
36
|
-
return wasmModule;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
wasmLoadError = error;
|
|
39
|
-
console.warn("\u26A0\uFE0F WASM loading failed, using fallback:", error.message);
|
|
40
|
-
wasmModule = {
|
|
41
|
-
flashAttention: createFlashAttentionMock(),
|
|
42
|
-
hyperbolicAttention: createHyperbolicAttentionMock(),
|
|
43
|
-
memoryConsolidation: createMemoryConsolidationMock(),
|
|
44
|
-
simdSupported: false
|
|
45
|
-
};
|
|
46
|
-
return wasmModule;
|
|
47
|
-
} finally {
|
|
48
|
-
wasmLoading = null;
|
|
49
|
-
}
|
|
50
|
-
})();
|
|
51
|
-
return wasmLoading;
|
|
52
|
-
}
|
|
53
|
-
async function detectWasmSIMD() {
|
|
54
|
-
try {
|
|
55
|
-
const simdTest = new Uint8Array([
|
|
56
|
-
0,
|
|
57
|
-
97,
|
|
58
|
-
115,
|
|
59
|
-
109,
|
|
60
|
-
1,
|
|
61
|
-
0,
|
|
62
|
-
0,
|
|
63
|
-
0,
|
|
64
|
-
1,
|
|
65
|
-
5,
|
|
66
|
-
1,
|
|
67
|
-
96,
|
|
68
|
-
0,
|
|
69
|
-
1,
|
|
70
|
-
123,
|
|
71
|
-
3,
|
|
72
|
-
2,
|
|
73
|
-
1,
|
|
74
|
-
0,
|
|
75
|
-
10,
|
|
76
|
-
10,
|
|
77
|
-
1,
|
|
78
|
-
8,
|
|
79
|
-
0,
|
|
80
|
-
253,
|
|
81
|
-
12,
|
|
82
|
-
253,
|
|
83
|
-
12,
|
|
84
|
-
253,
|
|
85
|
-
84,
|
|
86
|
-
11
|
|
87
|
-
]);
|
|
88
|
-
const module = await WebAssembly.instantiate(simdTest);
|
|
89
|
-
return module instanceof WebAssembly.Instance;
|
|
90
|
-
} catch {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function createFlashAttentionMock() {
|
|
95
|
-
return (query, keys, values, options = {}) => {
|
|
96
|
-
const { dim = 384, numHeads = 4, blockSize = 64 } = options;
|
|
97
|
-
const seqLen = keys.length / dim;
|
|
98
|
-
const output = new Float32Array(query.length);
|
|
99
|
-
for (let i = 0; i < query.length; i += dim) {
|
|
100
|
-
const q = query.slice(i, i + dim);
|
|
101
|
-
let sumWeights = 0;
|
|
102
|
-
const weights = new Float32Array(seqLen);
|
|
103
|
-
for (let j = 0; j < seqLen; j++) {
|
|
104
|
-
const k = keys.slice(j * dim, (j + 1) * dim);
|
|
105
|
-
let dot = 0;
|
|
106
|
-
for (let d = 0; d < dim; d++) {
|
|
107
|
-
dot += q[d] * k[d];
|
|
108
|
-
}
|
|
109
|
-
weights[j] = Math.exp(dot / Math.sqrt(dim));
|
|
110
|
-
sumWeights += weights[j];
|
|
111
|
-
}
|
|
112
|
-
for (let j = 0; j < seqLen; j++) {
|
|
113
|
-
weights[j] /= sumWeights;
|
|
114
|
-
const v = values.slice(j * dim, (j + 1) * dim);
|
|
115
|
-
for (let d = 0; d < dim; d++) {
|
|
116
|
-
output[i + d] += weights[j] * v[d];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return output;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function createHyperbolicAttentionMock() {
|
|
124
|
-
return (query, keys, options = {}) => {
|
|
125
|
-
const { curvature = -1 } = options;
|
|
126
|
-
const k = Math.abs(curvature);
|
|
127
|
-
const similarities = new Float32Array(keys.length / query.length);
|
|
128
|
-
for (let i = 0; i < similarities.length; i++) {
|
|
129
|
-
const offset = i * query.length;
|
|
130
|
-
let dotProduct = 0;
|
|
131
|
-
let normQ = 0;
|
|
132
|
-
let normK = 0;
|
|
133
|
-
for (let j = 0; j < query.length; j++) {
|
|
134
|
-
dotProduct += query[j] * keys[offset + j];
|
|
135
|
-
normQ += query[j] * query[j];
|
|
136
|
-
normK += keys[offset + j] * keys[offset + j];
|
|
137
|
-
}
|
|
138
|
-
const euclidean = Math.sqrt(normQ + normK - 2 * dotProduct);
|
|
139
|
-
const poincare = Math.acosh(1 + 2 * k * euclidean * euclidean);
|
|
140
|
-
similarities[i] = 1 / (1 + poincare);
|
|
141
|
-
}
|
|
142
|
-
return similarities;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function createMemoryConsolidationMock() {
|
|
146
|
-
return (memories, options = {}) => {
|
|
147
|
-
const { threshold = 0.8, maxClusters = 10 } = options;
|
|
148
|
-
const consolidated = [];
|
|
149
|
-
const used = /* @__PURE__ */ new Set();
|
|
150
|
-
for (let i = 0; i < memories.length; i++) {
|
|
151
|
-
if (used.has(i)) continue;
|
|
152
|
-
const cluster = [memories[i]];
|
|
153
|
-
used.add(i);
|
|
154
|
-
for (let j = i + 1; j < memories.length; j++) {
|
|
155
|
-
if (used.has(j)) continue;
|
|
156
|
-
let dot = 0;
|
|
157
|
-
let norm1 = 0;
|
|
158
|
-
let norm2 = 0;
|
|
159
|
-
for (let k = 0; k < memories[i].length; k++) {
|
|
160
|
-
dot += memories[i][k] * memories[j][k];
|
|
161
|
-
norm1 += memories[i][k] * memories[i][k];
|
|
162
|
-
norm2 += memories[j][k] * memories[j][k];
|
|
163
|
-
}
|
|
164
|
-
const similarity = dot / (Math.sqrt(norm1 * norm2) || 1);
|
|
165
|
-
if (similarity > threshold) {
|
|
166
|
-
cluster.push(memories[j]);
|
|
167
|
-
used.add(j);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const avg = new Float32Array(memories[i].length);
|
|
171
|
-
for (const mem of cluster) {
|
|
172
|
-
for (let k = 0; k < avg.length; k++) {
|
|
173
|
-
avg[k] += mem[k] / cluster.length;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
consolidated.push({
|
|
177
|
-
memory: avg,
|
|
178
|
-
count: cluster.size,
|
|
179
|
-
members: cluster
|
|
180
|
-
});
|
|
181
|
-
if (consolidated.length >= maxClusters) break;
|
|
182
|
-
}
|
|
183
|
-
return consolidated;
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
var wasmModule, wasmLoading, wasmLoadError;
|
|
187
|
-
var init_agentdb_wasm_loader = __esm({
|
|
188
|
-
"dist/agentdb.wasm-loader.js"() {
|
|
189
|
-
"use strict";
|
|
190
|
-
wasmModule = null;
|
|
191
|
-
wasmLoading = null;
|
|
192
|
-
wasmLoadError = null;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
1
|
+
/*! AgentDB Browser Bundle v2.0.0-alpha.2.15 | MIT License | https://agentdb.ruv.io */
|
|
195
2
|
|
|
196
3
|
// src/browser/ProductQuantization.ts
|
|
197
4
|
var ProductQuantization = class {
|
|
@@ -1261,7 +1068,7 @@ var AttentionBrowser = class {
|
|
|
1261
1068
|
this.loadingState = "loaded";
|
|
1262
1069
|
return;
|
|
1263
1070
|
}
|
|
1264
|
-
const wasmLoader = await
|
|
1071
|
+
const wasmLoader = await import("../../dist/agentdb.wasm-loader.js");
|
|
1265
1072
|
this.wasmModule = await wasmLoader.initWASM();
|
|
1266
1073
|
this.loadingState = "loaded";
|
|
1267
1074
|
} catch (error) {
|
|
@@ -1476,11 +1283,11 @@ function detectFeatures() {
|
|
|
1476
1283
|
indexedDB: "indexedDB" in globalThis,
|
|
1477
1284
|
broadcastChannel: "BroadcastChannel" in globalThis,
|
|
1478
1285
|
webWorkers: typeof globalThis.Worker !== "undefined",
|
|
1479
|
-
wasmSIMD:
|
|
1286
|
+
wasmSIMD: detectWasmSIMD(),
|
|
1480
1287
|
sharedArrayBuffer: typeof SharedArrayBuffer !== "undefined"
|
|
1481
1288
|
};
|
|
1482
1289
|
}
|
|
1483
|
-
async function
|
|
1290
|
+
async function detectWasmSIMD() {
|
|
1484
1291
|
try {
|
|
1485
1292
|
if (typeof globalThis.WebAssembly === "undefined") {
|
|
1486
1293
|
return false;
|