agentdb 2.0.0-alpha.3.5 → 2.0.0-alpha.3.7
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 +1 -1
- package/dist/agentdb.browser.min.js +1 -1
- package/dist/src/cli/agentdb-cli.d.ts.map +1 -1
- package/dist/src/cli/agentdb-cli.js +78 -0
- package/dist/src/cli/agentdb-cli.js.map +1 -1
- package/dist/src/cli/commands/hyperbolic.d.ts +11 -0
- package/dist/src/cli/commands/hyperbolic.d.ts.map +1 -0
- package/dist/src/cli/commands/hyperbolic.js +428 -0
- package/dist/src/cli/commands/hyperbolic.js.map +1 -0
- package/dist/src/cli/commands/learn.d.ts +11 -0
- package/dist/src/cli/commands/learn.d.ts.map +1 -0
- package/dist/src/cli/commands/learn.js +404 -0
- package/dist/src/cli/commands/learn.js.map +1 -0
- package/dist/src/cli/commands/route.d.ts +11 -0
- package/dist/src/cli/commands/route.d.ts.map +1 -0
- package/dist/src/cli/commands/route.js +413 -0
- package/dist/src/cli/commands/route.js.map +1 -0
- package/package.json +3 -3
- package/src/cli/agentdb-cli.ts +83 -0
- package/src/cli/commands/hyperbolic.ts +529 -0
- package/src/cli/commands/learn.ts +507 -0
- package/src/cli/commands/route.ts +506 -0
package/dist/agentdb.browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AgentDB Browser Bundle v2.0.0-alpha.3.
|
|
1
|
+
/*! AgentDB Browser Bundle v2.0.0-alpha.3.6 | MIT License | https://agentdb.ruv.io */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __esm = (fn, res) => function __init() {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! AgentDB Browser Bundle v2.0.0-alpha.3.
|
|
1
|
+
/*! AgentDB Browser Bundle v2.0.0-alpha.3.6 | MIT | https://agentdb.ruv.io */
|
|
2
2
|
var L=Object.defineProperty;var z=(h,t)=>()=>(h&&(t=h(h=0)),t);var H=(h,t)=>{for(var e in t)L(h,e,{get:t[e],enumerable:!0})};var I={};H(I,{initWASM:()=>j,wasmLoadError:()=>P,wasmModule:()=>p});async function j(){return p||M||(M=(async()=>{try{if(typeof WebAssembly>"u")throw new Error("WebAssembly not supported in this browser");let h=await _();return console.log(`WASM SIMD support: ${h}`),p={flashAttention:N(),hyperbolicAttention:D(),memoryConsolidation:k(),simdSupported:h},console.log("\u2705 WASM attention module loaded"),p}catch(h){return P=h,console.warn("\u26A0\uFE0F WASM loading failed, using fallback:",h.message),p={flashAttention:N(),hyperbolicAttention:D(),memoryConsolidation:k(),simdSupported:!1},p}finally{M=null}})(),M)}async function _(){try{let h=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,253,12,253,12,253,84,11]);return await WebAssembly.instantiate(h)instanceof WebAssembly.Instance}catch{return!1}}function N(){return(h,t,e,o={})=>{let{dim:n=384,numHeads:r=4,blockSize:s=64}=o,i=t.length/n,a=new Float32Array(h.length);for(let c=0;c<h.length;c+=n){let u=h.slice(c,c+n),m=0,d=new Float32Array(i);for(let l=0;l<i;l++){let f=t.slice(l*n,(l+1)*n),b=0;for(let g=0;g<n;g++)b+=u[g]*f[g];d[l]=Math.exp(b/Math.sqrt(n)),m+=d[l]}for(let l=0;l<i;l++){d[l]/=m;let f=e.slice(l*n,(l+1)*n);for(let b=0;b<n;b++)a[c+b]+=d[l]*f[b]}}return a}}function D(){return(h,t,e={})=>{let{curvature:o=-1}=e,n=Math.abs(o),r=new Float32Array(t.length/h.length);for(let s=0;s<r.length;s++){let i=s*h.length,a=0,c=0,u=0;for(let l=0;l<h.length;l++)a+=h[l]*t[i+l],c+=h[l]*h[l],u+=t[i+l]*t[i+l];let m=Math.sqrt(c+u-2*a),d=Math.acosh(1+2*n*m*m);r[s]=1/(1+d)}return r}}function k(){return(h,t={})=>{let{threshold:e=.8,maxClusters:o=10}=t,n=[],r=new Set;for(let s=0;s<h.length;s++){if(r.has(s))continue;let i=[h[s]];r.add(s);for(let c=s+1;c<h.length;c++){if(r.has(c))continue;let u=0,m=0,d=0;for(let f=0;f<h[s].length;f++)u+=h[s][f]*h[c][f],m+=h[s][f]*h[s][f],d+=h[c][f]*h[c][f];u/(Math.sqrt(m*d)||1)>e&&(i.push(h[c]),r.add(c))}let a=new Float32Array(h[s].length);for(let c of i)for(let u=0;u<a.length;u++)a[u]+=c[u]/i.length;if(n.push({memory:a,count:i.size,members:i}),n.length>=o)break}return n}}var p,M,P,W=z(()=>{"use strict";p=null,M=null,P=null});var y=class{config;codebook=null;trained=!1;constructor(t){if(this.config={dimension:t.dimension,numSubvectors:t.numSubvectors,numCentroids:t.numCentroids,maxIterations:t.maxIterations||50,convergenceThreshold:t.convergenceThreshold||1e-4},this.config.dimension%this.config.numSubvectors!==0)throw new Error(`Dimension ${this.config.dimension} must be divisible by numSubvectors ${this.config.numSubvectors}`)}async train(t){if(t.length===0)throw new Error("Training requires at least one vector");let e=this.config.dimension/this.config.numSubvectors,o=[];console.log(`[PQ] Training ${this.config.numSubvectors} subvectors with ${this.config.numCentroids} centroids each...`);for(let n=0;n<this.config.numSubvectors;n++){let r=n*e,s=r+e,i=t.map(c=>c.slice(r,s)),a=await this.kMeans(i,this.config.numCentroids);o.push(...a),((n+1)%4===0||n===this.config.numSubvectors-1)&&console.log(`[PQ] Trained ${n+1}/${this.config.numSubvectors} subvectors`)}this.codebook={subvectorDim:e,numSubvectors:this.config.numSubvectors,numCentroids:this.config.numCentroids,centroids:o},this.trained=!0,console.log("[PQ] Training complete")}async kMeans(t,e){let o=t[0].length,n=t.length,r=this.kMeansPlusPlus(t,e),s=new Uint32Array(n),i=1/0;for(let a=0;a<this.config.maxIterations;a++){let c=0;for(let d=0;d<n;d++){let l=1/0,f=0;for(let b=0;b<e;b++){let g=this.squaredDistance(t[d],r[b]);g<l&&(l=g,f=b)}s[d]=f,c+=l}if(Math.abs(i-c)<this.config.convergenceThreshold)break;i=c;let u=new Uint32Array(e),m=Array.from({length:e},()=>new Float32Array(o));for(let d=0;d<n;d++){let l=s[d];u[l]++;for(let f=0;f<o;f++)m[l][f]+=t[d][f]}for(let d=0;d<e;d++)if(u[d]>0)for(let l=0;l<o;l++)r[d][l]=m[d][l]/u[d]}return r}kMeansPlusPlus(t,e){let o=t.length,n=t[0].length,r=[],s=Math.floor(Math.random()*o);r.push(new Float32Array(t[s]));for(let i=1;i<e;i++){let a=new Float32Array(o),c=0;for(let m=0;m<o;m++){let d=1/0;for(let l of r){let f=this.squaredDistance(t[m],l);d=Math.min(d,f)}a[m]=d,c+=d}let u=Math.random()*c;for(let m=0;m<o;m++)if(u-=a[m],u<=0){r.push(new Float32Array(t[m]));break}}return r}compress(t){if(!this.trained||!this.codebook)throw new Error("Codebook must be trained before compression");let e=new Uint8Array(this.config.numSubvectors),o=this.codebook.subvectorDim,n=0;for(let r=0;r<t.length;r++)n+=t[r]*t[r];n=Math.sqrt(n);for(let r=0;r<this.config.numSubvectors;r++){let s=r*o,i=t.slice(s,s+o),a=1/0,c=0,u=r*this.config.numCentroids;for(let m=0;m<this.config.numCentroids;m++){let d=this.codebook.centroids[u+m],l=this.squaredDistance(i,d);l<a&&(a=l,c=m)}e[r]=c}return{codes:e,norm:n}}decompress(t){if(!this.codebook)throw new Error("Codebook not available");let e=new Float32Array(this.config.dimension),o=this.codebook.subvectorDim;for(let n=0;n<this.config.numSubvectors;n++){let r=t.codes[n],s=n*this.config.numCentroids,i=this.codebook.centroids[s+r],a=n*o;for(let c=0;c<o;c++)e[a+c]=i[c]}return e}asymmetricDistance(t,e){if(!this.codebook)throw new Error("Codebook not available");let o=0,n=this.codebook.subvectorDim;for(let r=0;r<this.config.numSubvectors;r++){let s=e.codes[r],i=r*this.config.numCentroids,a=this.codebook.centroids[i+s],c=r*n,u=t.slice(c,c+n);o+=this.squaredDistance(u,a)}return Math.sqrt(o)}batchCompress(t){return t.map(e=>this.compress(e))}getCompressionRatio(){let t=this.config.dimension*4,e=this.config.numSubvectors+4;return t/e}exportCodebook(){if(!this.codebook)throw new Error("No codebook to export");return JSON.stringify({config:this.config,codebook:{subvectorDim:this.codebook.subvectorDim,numSubvectors:this.codebook.numSubvectors,numCentroids:this.codebook.numCentroids,centroids:this.codebook.centroids.map(t=>Array.from(t))}})}importCodebook(t){let e=JSON.parse(t);this.config=e.config,this.codebook={subvectorDim:e.codebook.subvectorDim,numSubvectors:e.codebook.numSubvectors,numCentroids:e.codebook.numCentroids,centroids:e.codebook.centroids.map(o=>new Float32Array(o))},this.trained=!0}squaredDistance(t,e){let o=0;for(let n=0;n<t.length;n++){let r=t[n]-e[n];o+=r*r}return o}getStats(){let t=this.getCompressionRatio(),e=this.config.numSubvectors+4,o=this.codebook?this.config.numSubvectors*this.config.numCentroids*(this.config.dimension/this.config.numSubvectors)*4:0;return{trained:this.trained,compressionRatio:t,memoryPerVector:e,codebookSize:o}}};function B(h){return new y({dimension:h,numSubvectors:8,numCentroids:256,maxIterations:50})}function Q(h){return new y({dimension:h,numSubvectors:16,numCentroids:256,maxIterations:50})}function R(h){return new y({dimension:h,numSubvectors:32,numCentroids:256,maxIterations:50})}var S=class{items=[];push(t,e){this.items.push({item:t,priority:e}),this.bubbleUp(this.items.length-1)}pop(){if(this.items.length===0)return;let t=this.items[0].item,e=this.items.pop();return this.items.length>0&&(this.items[0]=e,this.bubbleDown(0)),t}peek(){var t;return(t=this.items[0])==null?void 0:t.item}size(){return this.items.length}bubbleUp(t){for(;t>0;){let e=Math.floor((t-1)/2);if(this.items[t].priority>=this.items[e].priority)break;[this.items[t],this.items[e]]=[this.items[e],this.items[t]],t=e}}bubbleDown(t){for(;;){let e=2*t+1,o=2*t+2,n=t;if(e<this.items.length&&this.items[e].priority<this.items[n].priority&&(n=e),o<this.items.length&&this.items[o].priority<this.items[n].priority&&(n=o),n===t)break;[this.items[t],this.items[n]]=[this.items[n],this.items[t]],t=n}}},A=class{config;nodes=new Map;entryPoint=null;currentId=0;ml;constructor(t={}){this.config={dimension:t.dimension||384,M:t.M||16,efConstruction:t.efConstruction||200,efSearch:t.efSearch||50,ml:t.ml||1/Math.log(2),maxLayers:t.maxLayers||16,distanceFunction:t.distanceFunction||"cosine"},this.ml=this.config.ml}add(t,e){let o=e!==void 0?e:this.currentId++,n=this.randomLevel(),r={id:o,vector:t,level:n,connections:new Map};for(let a=0;a<=n;a++)r.connections.set(a,[]);if(this.entryPoint===null)return this.entryPoint=o,this.nodes.set(o,r),o;let s=this.entryPoint,i=s;for(let a=this.nodes.get(s).level;a>n;a--)i=this.searchLayer(t,i,1,a)[0];for(let a=Math.min(n,this.nodes.get(s).level);a>=0;a--){let c=this.searchLayer(t,i,this.config.efConstruction,a),u=a===0?this.config.M*2:this.config.M,m=this.selectNeighbors(t,c,u);for(let d of m){this.connect(o,d,a),this.connect(d,o,a);let l=this.nodes.get(d),f=l.connections.get(a);if(f.length>u){let b=this.selectNeighbors(l.vector,f,u);l.connections.set(a,b)}}i=c[0]}return n>this.nodes.get(this.entryPoint).level&&(this.entryPoint=o),this.nodes.set(o,r),o}search(t,e,o){if(this.entryPoint===null)return[];o=o||Math.max(this.config.efSearch,e);let n=this.entryPoint,r=n;for(let i=this.nodes.get(n).level;i>0;i--)r=this.searchLayer(t,r,1,i)[0];return this.searchLayer(t,r,o,0).slice(0,e).map(i=>({id:i,distance:this.distance(t,this.nodes.get(i).vector),vector:this.nodes.get(i).vector}))}searchLayer(t,e,o,n){let r=new Set,s=new S,i=new S,a=this.distance(t,this.nodes.get(e).vector);for(s.push(e,a),i.push(e,-a),r.add(e);s.size()>0;){let u=s.pop(),m=-i.peek();if(this.distance(t,this.nodes.get(u).vector)>m)break;let l=this.nodes.get(u).connections.get(n)||[];for(let f of l){if(r.has(f))continue;r.add(f);let b=this.distance(t,this.nodes.get(f).vector),g=-i.peek();(b<g||i.size()<o)&&(s.push(f,b),i.push(f,-b),i.size()>o&&i.pop())}}let c=[];for(;i.size()>0;)c.unshift(i.pop());return c}selectNeighbors(t,e,o){return e.length<=o?e:e.map(r=>({id:r,distance:this.distance(t,this.nodes.get(r).vector)})).sort((r,s)=>r.distance-s.distance).slice(0,o).map(r=>r.id)}connect(t,e,o){let r=this.nodes.get(t).connections.get(o);r.includes(e)||r.push(e)}randomLevel(){let t=0;for(;Math.random()<this.ml&&t<this.config.maxLayers-1;)t++;return t}distance(t,e){switch(this.config.distanceFunction){case"cosine":return 1-this.cosineSimilarity(t,e);case"euclidean":return this.euclideanDistance(t,e);case"manhattan":return this.manhattanDistance(t,e);default:return 1-this.cosineSimilarity(t,e)}}cosineSimilarity(t,e){let o=0,n=0,r=0;for(let s=0;s<t.length;s++)o+=t[s]*e[s],n+=t[s]*t[s],r+=e[s]*e[s];return o/(Math.sqrt(n)*Math.sqrt(r))}euclideanDistance(t,e){let o=0;for(let n=0;n<t.length;n++){let r=t[n]-e[n];o+=r*r}return Math.sqrt(o)}manhattanDistance(t,e){let o=0;for(let n=0;n<t.length;n++)o+=Math.abs(t[n]-e[n]);return o}getStats(){if(this.nodes.size===0)return{numNodes:0,numLayers:0,avgConnections:0,entryPointLevel:0,memoryBytes:0};let t=Math.max(...Array.from(this.nodes.values()).map(a=>a.level)),e=0;for(let a of this.nodes.values())for(let c of a.connections.values())e+=c.length;let o=e/this.nodes.size,n=this.config.dimension*4,r=o*4,i=this.nodes.size*(n+r+100);return{numNodes:this.nodes.size,numLayers:t+1,avgConnections:o,entryPointLevel:this.entryPoint?this.nodes.get(this.entryPoint).level:0,memoryBytes:i}}export(){let t={config:this.config,entryPoint:this.entryPoint,currentId:this.currentId,nodes:Array.from(this.nodes.entries()).map(([e,o])=>({id:e,vector:Array.from(o.vector),level:o.level,connections:Array.from(o.connections.entries())}))};return JSON.stringify(t)}import(t){let e=JSON.parse(t);this.config=e.config,this.entryPoint=e.entryPoint,this.currentId=e.currentId,this.nodes.clear();for(let o of e.nodes){let n={id:o.id,vector:new Float32Array(o.vector),level:o.level,connections:new Map(o.connections)};this.nodes.set(o.id,n)}}clear(){this.nodes.clear(),this.entryPoint=null,this.currentId=0}size(){return this.nodes.size}};function q(h){return new A({dimension:h,M:16,efConstruction:200,efSearch:50})}function G(h){return new A({dimension:h,M:8,efConstruction:100,efSearch:30})}function O(h){return new A({dimension:h,M:32,efConstruction:400,efSearch:100})}var w=class{config;nodes=new Map;edges=[];attentionWeights=new Map;constructor(t={}){this.config={hiddenDim:t.hiddenDim||64,numHeads:t.numHeads||4,dropout:t.dropout||.1,learningRate:t.learningRate||.01,attentionType:t.attentionType||"gat"}}addNode(t,e){this.nodes.set(t,{id:t,features:e,neighbors:[]})}addEdge(t,e,o=1){this.edges.push({from:t,to:e,weight:o});let n=this.nodes.get(t),r=this.nodes.get(e);n&&!n.neighbors.includes(e)&&n.neighbors.push(e),r&&!r.neighbors.includes(t)&&r.neighbors.push(t)}graphAttention(t){let e=this.nodes.get(t);if(!e)throw new Error(`Node ${t} not found`);let o=e.neighbors;if(o.length===0)return e.features;let n=Math.floor(this.config.hiddenDim/this.config.numHeads),r=new Float32Array(this.config.hiddenDim);for(let s=0;s<this.config.numHeads;s++){let i=0,a=new Float32Array(n);for(let u of o){let m=this.nodes.get(u),d=this.computeAttentionScore(e.features,m.features,s);i+=d;for(let l=0;l<n&&l<m.features.length;l++)a[l]+=d*m.features[l]}if(i>0)for(let u=0;u<n;u++)a[u]/=i;let c=s*n;for(let u=0;u<n;u++)r[c+u]=a[u]}for(let s=0;s<r.length;s++)r[s]=r[s]>0?r[s]:.01*r[s];return r}computeAttentionScore(t,e,o){let n=0,r=Math.min(t.length,e.length);for(let s=0;s<r;s++)n+=t[s]*e[s];return Math.exp(n/Math.sqrt(r))}messagePass(){let t=new Map;for(let[e]of this.nodes)t.set(e,this.graphAttention(e));return t}update(t){for(let[e,o]of t){let n=this.nodes.get(e);n&&(n.features=o)}}computeGraphEmbedding(t,e=2){new Map().set(t,this.nodes.get(t).features);for(let n=0;n<e;n++){let r=this.messagePass();this.update(r)}return this.nodes.get(t).features}getStats(){return{numNodes:this.nodes.size,numEdges:this.edges.length,avgDegree:this.edges.length/Math.max(this.nodes.size,1),config:this.config}}},x=class{config;constructor(t={}){this.config={lambda:t.lambda||.7,metric:t.metric||"cosine"}}rerank(t,e,o){if(e.length===0)return[];let n=[],r=new Set(e.map((a,c)=>c)),s=0,i=-1/0;for(let a=0;a<e.length;a++)e[a].score>i&&(i=e[a].score,s=a);for(n.push(e[s].id),r.delete(s);n.length<o&&r.size>0;){let a=-1/0,c=-1;for(let u of r){let m=e[u],d=this.similarity(t,m.vector),l=-1/0;for(let b of n){let g=e.find(E=>E.id===b),T=this.similarity(m.vector,g.vector);l=Math.max(l,T)}let f=this.config.lambda*d-(1-this.config.lambda)*l;f>a&&(a=f,c=u)}if(c!==-1)n.push(e[c].id),r.delete(c);else break}return n}similarity(t,e){return this.config.metric==="cosine"?this.cosineSimilarity(t,e):1/(1+this.euclideanDistance(t,e))}cosineSimilarity(t,e){let o=0,n=0,r=0;for(let s=0;s<t.length;s++)o+=t[s]*e[s],n+=t[s]*t[s],r+=e[s]*e[s];return o/(Math.sqrt(n)*Math.sqrt(r))}euclideanDistance(t,e){let o=0;for(let n=0;n<t.length;n++){let r=t[n]-e[n];o+=r*r}return Math.sqrt(o)}setLambda(t){this.config.lambda=Math.max(0,Math.min(1,t))}},F=class{static compress(t,e){if(t.length===0)return[];let o=t[0].length;if(e>=o)return t;let n=t.map(u=>Array.from(u)),r=this.computeMean(n),s=n.map(u=>u.map((m,d)=>m-r[d])),i=this.computeCovariance(s),a=this.powerIteration(i,e);return s.map(u=>{let m=new Float32Array(e);for(let d=0;d<e;d++){let l=0;for(let f=0;f<o;f++)l+=u[f]*a[d][f];m[d]=l}return m})}static computeMean(t){let e=t.length,o=t[0].length,n=new Array(o).fill(0);for(let r of t)for(let s=0;s<o;s++)n[s]+=r[s];return n.map(r=>r/e)}static computeCovariance(t){let e=t.length,o=t[0].length,n=Array.from({length:o},()=>new Array(o).fill(0));for(let r=0;r<o;r++)for(let s=0;s<=r;s++){let i=0;for(let a of t)i+=a[r]*a[s];n[r][s]=n[s][r]=i/e}return n}static powerIteration(t,e,o=100){let n=t.length,r=[];for(let s=0;s<e;s++){let i=new Array(n).fill(0).map(()=>Math.random()-.5);for(let a=0;a<o;a++){let c=new Array(n).fill(0);for(let m=0;m<n;m++)for(let d=0;d<n;d++)c[m]+=t[m][d]*i[d];for(let m of r){let d=0;for(let l=0;l<n;l++)d+=c[l]*m[l];for(let l=0;l<n;l++)c[l]-=d*m[l]}let u=0;for(let m of c)u+=m*m;if(u=Math.sqrt(u),u<1e-10)break;i=c.map(m=>m/u)}r.push(i)}return r}},C=class{static batchCosineSimilarity(t,e){let o=new Float32Array(e.length),n=0;for(let r=0;r<t.length;r++)n+=t[r]*t[r];n=Math.sqrt(n);for(let r=0;r<e.length;r++){let s=e[r],i=0,a=0;for(let c=0;c<t.length;c++)i+=t[c]*s[c],a+=s[c]*s[c];a=Math.sqrt(a),o[r]=i/(n*a)}return o}static batchNormalize(t){return t.map(e=>{let o=0;for(let r=0;r<e.length;r++)o+=e[r]*e[r];o=Math.sqrt(o);let n=new Float32Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]/o;return n})}};var v=class{wasmModule=null;loadingState="idle";loadError=null;config;constructor(t={}){this.config={dimension:384,numHeads:4,blockSize:64,curvature:-1,useWASM:!0,...t}}getLoadingState(){return this.loadingState}getError(){return this.loadError}async initialize(){if(this.loadingState!=="loaded"){if(this.loadingState==="loading"){for(;this.loadingState==="loading";)await new Promise(t=>setTimeout(t,50));return}this.loadingState="loading";try{if(!this.config.useWASM){this.loadingState="loaded";return}let t=await Promise.resolve().then(()=>(W(),I));this.wasmModule=await t.initWASM(),this.loadingState="loaded"}catch(t){this.loadError=t instanceof Error?t:new Error(String(t)),this.loadingState="error",console.warn("WASM initialization failed, using fallback:",this.loadError.message)}}}async flashAttention(t,e,o){var n;if(await this.initialize(),(n=this.wasmModule)!=null&&n.flashAttention)try{return this.wasmModule.flashAttention(t,e,o,this.config)}catch(r){console.warn("WASM flash attention failed, using fallback:",r)}return this.flashAttentionFallback(t,e,o)}async hyperbolicAttention(t,e){var o;if(await this.initialize(),(o=this.wasmModule)!=null&&o.hyperbolicAttention)try{return this.wasmModule.hyperbolicAttention(t,e,this.config)}catch(n){console.warn("WASM hyperbolic attention failed, using fallback:",n)}return this.hyperbolicAttentionFallback(t,e)}async consolidateMemories(t,e={}){var n;await this.initialize();let o={threshold:.8,maxClusters:10,minClusterSize:1,...e};if((n=this.wasmModule)!=null&&n.memoryConsolidation)try{return this.wasmModule.memoryConsolidation(t,o)}catch(r){console.warn("WASM memory consolidation failed, using fallback:",r)}return this.consolidateMemoriesFallback(t,o)}dispose(){this.wasmModule=null,this.loadingState="idle",this.loadError=null}flashAttentionFallback(t,e,o){let{dimension:n=384}=this.config,r=e.length/n,s=new Float32Array(t.length);for(let i=0;i<t.length;i+=n){let a=t.slice(i,i+n),c=0,u=new Float32Array(r);for(let m=0;m<r;m++){let d=e.slice(m*n,(m+1)*n),l=0;for(let f=0;f<n;f++)l+=a[f]*d[f];u[m]=Math.exp(l/Math.sqrt(n)),c+=u[m]}for(let m=0;m<r;m++){u[m]/=c||1;let d=o.slice(m*n,(m+1)*n);for(let l=0;l<n;l++)s[i+l]+=u[m]*d[l]}}return s}hyperbolicAttentionFallback(t,e){let{curvature:o=-1}=this.config,n=Math.abs(o),r=new Float32Array(e.length/t.length);for(let s=0;s<r.length;s++){let i=s*t.length,a=0,c=0,u=0;for(let l=0;l<t.length;l++)a+=t[l]*e[i+l],c+=t[l]*t[l],u+=e[i+l]*e[i+l];let m=Math.sqrt(c+u-2*a),d=Math.acosh(1+2*n*m*m);r[s]=1/(1+d)}return r}consolidateMemoriesFallback(t,e){let{threshold:o=.8,maxClusters:n=10,minClusterSize:r=1}=e,s=[],i=new Set;for(let a=0;a<t.length;a++){if(i.has(a))continue;let c=[t[a]];i.add(a);for(let u=a+1;u<t.length;u++){if(i.has(u))continue;this.cosineSimilarity(t[a],t[u])>o&&(c.push(t[u]),i.add(u))}if(c.length>=r){let u=new Float32Array(t[a].length);for(let d of c)for(let l=0;l<u.length;l++)u[l]+=d[l]/c.length;let m=0;for(let d=0;d<u.length;d++)m+=u[d]*u[d];if(m=Math.sqrt(m),m>0)for(let d=0;d<u.length;d++)u[d]/=m;s.push({memory:u,count:c.length,members:c})}if(s.length>=n)break}return s}cosineSimilarity(t,e){let o=0,n=0,r=0;for(let i=0;i<t.length;i++)o+=t[i]*e[i],n+=t[i]*t[i],r+=e[i]*e[i];let s=Math.sqrt(n*r);return s>0?o/s:0}};function U(h){return new v(h)}function $(){return new v({dimension:256,numHeads:2,blockSize:32,useWASM:!0})}function V(){return new v({dimension:768,numHeads:8,blockSize:128,useWASM:!0})}function ot(){return{indexedDB:"indexedDB"in globalThis,broadcastChannel:"BroadcastChannel"in globalThis,webWorkers:typeof globalThis.Worker<"u",wasmSIMD:J(),sharedArrayBuffer:typeof SharedArrayBuffer<"u"}}async function J(){try{if(typeof globalThis.WebAssembly>"u")return!1;let h=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,253,12,253,12,253,84,11]),t=globalThis.WebAssembly;return await t.instantiate(h)instanceof t.Instance}catch{return!1}}var Z={pq:{enabled:!1},hnsw:{enabled:!1},gnn:{enabled:!0,numHeads:2},mmr:{enabled:!0,lambda:.7},svd:{enabled:!1}},K={pq:{enabled:!0,subvectors:8},hnsw:{enabled:!0,M:16},gnn:{enabled:!0,numHeads:4},mmr:{enabled:!0,lambda:.7},svd:{enabled:!1}},Y={pq:{enabled:!0,subvectors:16},hnsw:{enabled:!0,M:32},gnn:{enabled:!0,numHeads:4},mmr:{enabled:!0,lambda:.7},svd:{enabled:!0,targetDim:128}},st={pq:{enabled:!0,subvectors:32},hnsw:{enabled:!0,M:8},gnn:{enabled:!1},mmr:{enabled:!1},svd:{enabled:!0,targetDim:64}},it={pq:{enabled:!1},hnsw:{enabled:!0,M:32,efSearch:100},gnn:{enabled:!1},mmr:{enabled:!1},svd:{enabled:!1}},at={pq:{enabled:!1},hnsw:{enabled:!0,M:48,efConstruction:400},gnn:{enabled:!0,numHeads:8},mmr:{enabled:!0,lambda:.8},svd:{enabled:!1}},ct={major:2,minor:0,patch:0,prerelease:"alpha.2",features:"advanced",full:"2.0.0-alpha.2+advanced"};function lt(h,t,e){var s,i,a;let o=h*t*4;if((s=e.pq)!=null&&s.enabled){let c=e.pq.subvectors||8;o=h*(c+4)}if((i=e.svd)!=null&&i.enabled){let c=e.svd.targetDim||t/2;o=h*c*4}let n=0;if((a=e.hnsw)!=null&&a.enabled){let u=(e.hnsw.M||16)*1.5;n=h*u*4}let r=o+n;return{vectors:o,index:n,total:r,totalMB:r/(1024*1024)}}function ut(h,t){return h<1e3?{name:"SMALL_DATASET",config:Z,reason:"Small dataset, linear search is fast enough"}:h<1e4?{name:"MEDIUM_DATASET",config:K,reason:"Medium dataset, HNSW + PQ8 recommended"}:{name:"LARGE_DATASET",config:Y,reason:"Large dataset, aggressive compression + HNSW recommended"}}async function mt(h,t=100,e=10,o=384){let n=[];for(let r=0;r<t;r++){let s=new Float32Array(o);for(let c=0;c<o;c++)s[c]=Math.random()-.5;let i=performance.now();h(s,e);let a=performance.now();n.push(a-i)}return n.sort((r,s)=>r-s),{avgTimeMs:n.reduce((r,s)=>r+s,0)/n.length,minTimeMs:n[0],maxTimeMs:n[n.length-1],p50Ms:n[Math.floor(n.length*.5)],p95Ms:n[Math.floor(n.length*.95)],p99Ms:n[Math.floor(n.length*.99)]}}export{v as AttentionBrowser,C as BatchProcessor,w as GraphNeuralNetwork,A as HNSWIndex,Y as LARGE_DATASET_CONFIG,K as MEDIUM_DATASET_CONFIG,st as MEMORY_OPTIMIZED_CONFIG,x as MaximalMarginalRelevance,y as ProductQuantization,at as QUALITY_OPTIMIZED_CONFIG,Z as SMALL_DATASET_CONFIG,it as SPEED_OPTIMIZED_CONFIG,F as TensorCompression,ct as VERSION,mt as benchmarkSearch,V as createAccurateAttention,O as createAccurateHNSW,U as createAttention,$ as createFastAttention,G as createFastHNSW,q as createHNSW,Q as createPQ16,R as createPQ32,B as createPQ8,ot as detectFeatures,lt as estimateMemoryUsage,ut as recommendConfig};
|
|
3
3
|
//# sourceMappingURL=agentdb.browser.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentdb-cli.d.ts","sourceRoot":"","sources":["../../../src/cli/agentdb-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"agentdb-cli.d.ts","sourceRoot":"","sources":["../../../src/cli/agentdb-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AAwHH,cAAM,UAAU;IACP,EAAE,CAAC,EAAE,GAAG,CAAC;IAChB,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,YAAY,CAAC,CAAe;IACpC,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,SAAS,CAAC,CAAkB;IACpC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAAmB;IAGpC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,eAAe,CAAC,CAAkB;IAEpC,UAAU,CAAC,MAAM,GAAE,MAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqF1D,aAAa,CAAC,MAAM,EAAE;QAC1B,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBX,sBAAsB,CAAC,MAAM,EAAE;QACnC,IAAI,EAAE,MA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AAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0FX,QAAQ,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyHjB,OAAO,CAAC,yBAAyB;IAiF3B,QAAQ,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,gBAAgB,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;KACjE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4IjB,OAAO,CAAC,sBAAsB;IAqCxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA4GjC,OAAO,CAAC,qBAAqB;IAsD7B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,OAAO;IAcT,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAmB/B;AAmxDD,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -27,6 +27,10 @@ import { statusCommand } from './commands/status.js';
|
|
|
27
27
|
import { installEmbeddingsCommand } from './commands/install-embeddings.js';
|
|
28
28
|
import { migrateCommand } from './commands/migrate.js';
|
|
29
29
|
import { doctorCommand } from './commands/doctor.js';
|
|
30
|
+
import { attentionCommand } from './commands/attention.js';
|
|
31
|
+
import { learnCommand } from './commands/learn.js';
|
|
32
|
+
import { routeCommand } from './commands/route.js';
|
|
33
|
+
import { hyperbolicCommand } from './commands/hyperbolic.js';
|
|
30
34
|
import * as fs from 'fs';
|
|
31
35
|
import * as path from 'path';
|
|
32
36
|
import * as zlib from 'zlib';
|
|
@@ -1337,6 +1341,14 @@ class AgentDBCLI {
|
|
|
1337
1341
|
// ============================================================================
|
|
1338
1342
|
// CLI Entry Point
|
|
1339
1343
|
// ============================================================================
|
|
1344
|
+
/**
|
|
1345
|
+
* Helper function to execute Commander-based commands
|
|
1346
|
+
*/
|
|
1347
|
+
async function handleCommanderCommand(command, args) {
|
|
1348
|
+
// Parse directly using the command instance without wrapping in a parent program
|
|
1349
|
+
// This avoids issues with subcommand routing
|
|
1350
|
+
await command.parseAsync(['node', command.name(), ...args], { from: 'user' });
|
|
1351
|
+
}
|
|
1340
1352
|
async function main() {
|
|
1341
1353
|
const args = process.argv.slice(2);
|
|
1342
1354
|
// Handle version flag
|
|
@@ -1507,6 +1519,23 @@ async function main() {
|
|
|
1507
1519
|
await handleStatsCommand(args.slice(1));
|
|
1508
1520
|
return;
|
|
1509
1521
|
}
|
|
1522
|
+
// Handle advanced neural commands (WASM-accelerated when available)
|
|
1523
|
+
if (command === 'attention') {
|
|
1524
|
+
await handleCommanderCommand(attentionCommand, args.slice(1));
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
if (command === 'learn') {
|
|
1528
|
+
await handleCommanderCommand(learnCommand, args.slice(1));
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
if (command === 'route') {
|
|
1532
|
+
await handleCommanderCommand(routeCommand, args.slice(1));
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
if (command === 'hyperbolic') {
|
|
1536
|
+
await handleCommanderCommand(hyperbolicCommand, args.slice(1));
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1510
1539
|
// Handle simulate command - run simulation CLI
|
|
1511
1540
|
if (command === 'simulate') {
|
|
1512
1541
|
// Use pathToFileURL for proper ESM module resolution
|
|
@@ -2874,6 +2903,55 @@ ${colors.bright}QUIC SYNC COMMANDS:${colors.reset}
|
|
|
2874
2903
|
Show synchronization status, pending changes, and connected servers
|
|
2875
2904
|
Example: agentdb sync status
|
|
2876
2905
|
|
|
2906
|
+
${colors.bright}ADVANCED NEURAL COMMANDS (WASM-ACCELERATED):${colors.reset}
|
|
2907
|
+
agentdb attention <subcommand> [options]
|
|
2908
|
+
Attention mechanism operations: flash, hyperbolic, sparse, MoE
|
|
2909
|
+
Subcommands:
|
|
2910
|
+
init --mechanism <type> Initialize attention configuration
|
|
2911
|
+
compute --query <text> Compute attention for query-key-value
|
|
2912
|
+
benchmark --all Benchmark all mechanisms
|
|
2913
|
+
optimize --mechanism <type> Optimize parameters
|
|
2914
|
+
Example: agentdb attention benchmark --all --iterations 100
|
|
2915
|
+
|
|
2916
|
+
agentdb learn --mode <type> --data <file> [options]
|
|
2917
|
+
Advanced learning: curriculum, contrastive loss, hard negative mining
|
|
2918
|
+
Modes:
|
|
2919
|
+
curriculum Progressive difficulty training with cosine/linear schedules
|
|
2920
|
+
contrastive InfoNCE and local contrastive loss training
|
|
2921
|
+
hard-negatives Hard negative mining for contrastive learning
|
|
2922
|
+
Options:
|
|
2923
|
+
--schedule <type> Difficulty schedule: linear|cosine|exponential
|
|
2924
|
+
--temperature <n> InfoNCE temperature (default: 0.07)
|
|
2925
|
+
--strategy <type> Mining strategy: hard|semi-hard|distance-based
|
|
2926
|
+
Example: agentdb learn --mode curriculum --data train.json --schedule cosine
|
|
2927
|
+
Example: agentdb learn --mode contrastive --data pairs.json --epochs 15
|
|
2928
|
+
|
|
2929
|
+
agentdb route --prompt <text> [options]
|
|
2930
|
+
LLM routing with FastGRNN model selection (haiku/sonnet/opus)
|
|
2931
|
+
Options:
|
|
2932
|
+
--prompt <text> Prompt to route
|
|
2933
|
+
--prompt-file <path> File containing prompt
|
|
2934
|
+
--context <json> Conversation context (JSON)
|
|
2935
|
+
--explain Explain routing decision
|
|
2936
|
+
Subcommands:
|
|
2937
|
+
feedback --model <type> --outcome <result> Record feedback for learning
|
|
2938
|
+
stats View routing statistics
|
|
2939
|
+
Example: agentdb route --prompt "Explain quantum computing" --explain
|
|
2940
|
+
Example: agentdb route feedback --model sonnet --outcome success
|
|
2941
|
+
|
|
2942
|
+
agentdb hyperbolic --op <type> [options]
|
|
2943
|
+
Hyperbolic space operations: Poincaré ball geometry
|
|
2944
|
+
Operations:
|
|
2945
|
+
expmap Exponential map (tangent -> manifold)
|
|
2946
|
+
logmap Logarithmic map (manifold -> tangent)
|
|
2947
|
+
mobius-add Möbius addition (hyperbolic addition)
|
|
2948
|
+
distance Poincaré distance between points
|
|
2949
|
+
project Project point to Poincaré ball
|
|
2950
|
+
centroid Compute hyperbolic centroid
|
|
2951
|
+
dual-search Hybrid Euclidean + Hyperbolic search
|
|
2952
|
+
Example: agentdb hyperbolic --op distance --point-a "[0.3,0.4]" --point-b "[0.6,0.2]"
|
|
2953
|
+
Example: agentdb hyperbolic --op dual-search --query "[0.5,0.5]" --points vectors.json
|
|
2954
|
+
|
|
2877
2955
|
${colors.bright}CAUSAL COMMANDS:${colors.reset}
|
|
2878
2956
|
agentdb causal add-edge <cause> <effect> <uplift> [confidence] [sample-size]
|
|
2879
2957
|
Add a causal edge manually
|