heady-vector-memory 3.2.0

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/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @heady/vector-memory
2
+
3
+ > 3D vector memory store with cosine-similarity search for the Heady™ AI Platform.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @heady/vector-memory
9
+ ```
10
+
11
+ ## API
12
+
13
+ ```js
14
+ const { VectorMemoryStore } = require('@heady/vector-memory');
15
+
16
+ const store = new VectorMemoryStore();
17
+
18
+ // Store a 3D vector with embedding
19
+ store.store('user-1', {
20
+ x: 0.5, y: 1.2, z: -0.3,
21
+ embedding: [0.1, 0.2, 0.3],
22
+ metadata: { topic: 'ai' },
23
+ timestamp: Date.now()
24
+ });
25
+
26
+ // Query by cosine similarity
27
+ const results = store.query('user-1', [0.1, 0.2, 0.3], 5);
28
+
29
+ // Get stats
30
+ const stats = store.getStats('user-1');
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - **3D spatial indexing** with x/y/z coordinates
36
+ - **Cosine similarity** search across embeddings
37
+ - **Per-user memory isolation**
38
+ - **Octant-based statistics**
39
+
40
+ ## License
41
+
42
+ Proprietary — © 2026 HeadySystems Inc.
@@ -0,0 +1,19 @@
1
+ export interface Vector3D {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ embedding: number[];
6
+ metadata: Record<string, any>;
7
+ timestamp: number;
8
+ }
9
+ export declare class VectorMemoryStore {
10
+ private memories;
11
+ store(userId: string, memory: Vector3D): void;
12
+ query(userId: string, embedding: number[], limit?: number): Vector3D[];
13
+ private cosineSimilarity;
14
+ getStats(userId: string): {
15
+ count: number;
16
+ octants: number;
17
+ };
18
+ }
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAsC;IAEtD,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAU7C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,SAAK,GAAG,QAAQ,EAAE;IASlE,OAAO,CAAC,gBAAgB;IAOxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAI7D"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VectorMemoryStore = void 0;
4
+ const core_1 = require("@heady/core");
5
+ class VectorMemoryStore {
6
+ memories = new Map();
7
+ store(userId, memory) {
8
+ if (!(0, core_1.validateUserId)(userId)) {
9
+ throw new core_1.HeadyError('Invalid userId', 'INVALID_USER');
10
+ }
11
+ if (!this.memories.has(userId)) {
12
+ this.memories.set(userId, []);
13
+ }
14
+ this.memories.get(userId).push(memory);
15
+ }
16
+ query(userId, embedding, limit = 10) {
17
+ const userMemories = this.memories.get(userId) || [];
18
+ return userMemories
19
+ .map(m => ({ memory: m, similarity: this.cosineSimilarity(embedding, m.embedding) }))
20
+ .sort((a, b) => b.similarity - a.similarity)
21
+ .slice(0, limit)
22
+ .map(r => r.memory);
23
+ }
24
+ cosineSimilarity(a, b) {
25
+ const dot = a.reduce((sum, val, i) => sum + val * b[i], 0);
26
+ const magA = Math.sqrt(a.reduce((sum, val) => sum + val * val, 0));
27
+ const magB = Math.sqrt(b.reduce((sum, val) => sum + val * val, 0));
28
+ return dot / (magA * magB);
29
+ }
30
+ getStats(userId) {
31
+ const userMemories = this.memories.get(userId) || [];
32
+ return { count: userMemories.length, octants: Math.ceil(userMemories.length / 8) };
33
+ }
34
+ }
35
+ exports.VectorMemoryStore = VectorMemoryStore;
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAyD;AAWzD,MAAa,iBAAiB;IACpB,QAAQ,GAA4B,IAAI,GAAG,EAAE,CAAC;IAEtD,KAAK,CAAC,MAAc,EAAE,MAAgB;QACpC,IAAI,CAAC,IAAA,qBAAc,EAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,iBAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,MAAc,EAAE,SAAmB,EAAE,KAAK,GAAG,EAAE;QACnD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrD,OAAO,YAAY;aAChB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;aACpF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;aAC3C,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;aACf,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IAEO,gBAAgB,CAAC,CAAW,EAAE,CAAW;QAC/C,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACnE,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ,CAAC,MAAc;QACrB,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrD,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;IACrF,CAAC;CACF;AAjCD,8CAiCC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "heady-vector-memory",
3
+ "version": "3.2.0",
4
+ "description": "3D vector memory store with cosine-similarity search and octree indexing for the Heady AI Platform.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist/",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "clean": "rm -rf dist",
20
+ "prepublishOnly": "npm run clean && npm run build"
21
+ },
22
+ "dependencies": {
23
+ "heady-core": "^3.2.0"
24
+ },
25
+ "license": "UNLICENSED",
26
+ "author": {
27
+ "name": "HeadySystems Inc.",
28
+ "email": "eric@headyconnection.org",
29
+ "url": "https://headyme.com"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/HeadyMe/heady-production.git",
34
+ "directory": "packages/vector-memory"
35
+ },
36
+ "homepage": "https://headysystems.com",
37
+ "bugs": {
38
+ "url": "https://github.com/HeadyMe/heady-production/issues"
39
+ },
40
+ "keywords": [
41
+ "heady",
42
+ "ai",
43
+ "vector-memory",
44
+ "3d-vector",
45
+ "cosine-similarity",
46
+ "embedding",
47
+ "octree"
48
+ ],
49
+ "engines": {
50
+ "node": ">=20.0.0"
51
+ }
52
+ }