cozo-memory 1.0.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.
Files changed (49) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +533 -0
  3. package/dist/api_bridge.js +266 -0
  4. package/dist/benchmark-gpu-cpu.js +188 -0
  5. package/dist/benchmark-heavy.js +230 -0
  6. package/dist/benchmark.js +160 -0
  7. package/dist/clear-cache.js +29 -0
  8. package/dist/db-service.js +228 -0
  9. package/dist/download-model.js +48 -0
  10. package/dist/embedding-service.js +249 -0
  11. package/dist/full-system-test.js +45 -0
  12. package/dist/hybrid-search.js +337 -0
  13. package/dist/index.js +3106 -0
  14. package/dist/inference-engine.js +348 -0
  15. package/dist/memory-service.js +215 -0
  16. package/dist/test-advanced-filters.js +64 -0
  17. package/dist/test-advanced-search.js +82 -0
  18. package/dist/test-advanced-time.js +47 -0
  19. package/dist/test-embedding.js +22 -0
  20. package/dist/test-filter-expr.js +84 -0
  21. package/dist/test-fts.js +58 -0
  22. package/dist/test-functions.js +25 -0
  23. package/dist/test-gpu-check.js +16 -0
  24. package/dist/test-graph-algs-final.js +76 -0
  25. package/dist/test-graph-filters.js +88 -0
  26. package/dist/test-graph-rag.js +124 -0
  27. package/dist/test-graph-walking.js +138 -0
  28. package/dist/test-index.js +35 -0
  29. package/dist/test-int-filter.js +48 -0
  30. package/dist/test-integration.js +69 -0
  31. package/dist/test-lower.js +35 -0
  32. package/dist/test-lsh.js +67 -0
  33. package/dist/test-mcp-tool.js +40 -0
  34. package/dist/test-pagerank.js +31 -0
  35. package/dist/test-semantic-walk.js +145 -0
  36. package/dist/test-time-filter.js +66 -0
  37. package/dist/test-time-functions.js +38 -0
  38. package/dist/test-triggers.js +60 -0
  39. package/dist/test-ts-ort.js +48 -0
  40. package/dist/test-validity-access.js +35 -0
  41. package/dist/test-validity-body.js +42 -0
  42. package/dist/test-validity-decomp.js +37 -0
  43. package/dist/test-validity-extraction.js +45 -0
  44. package/dist/test-validity-json.js +35 -0
  45. package/dist/test-validity.js +38 -0
  46. package/dist/types.js +3 -0
  47. package/dist/verify-gpu.js +30 -0
  48. package/dist/verify_transaction_tool.js +46 -0
  49. package/package.json +75 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testTimeFilter() {
9
+ const dbPath = "test-time.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ const EMBEDDING_DIM = 4;
18
+ try {
19
+ console.log("Creating table with Validity...");
20
+ await db.run(`{:create test_time {id: String, created_at: Validity => type: String, embedding: <F32; ${EMBEDDING_DIM}>}}`);
21
+ await db.run(`{::hnsw create test_time:semantic {dim: ${EMBEDDING_DIM}, m: 16, dtype: F32, fields: [embedding], distance: Cosine, ef_construction: 200}}`);
22
+ const now = Date.now();
23
+ const vec = [0.1, 0.2, 0.3, 0.4];
24
+ // CozoDB uses microseconds for timestamps if they are integers?
25
+ // Or ISO strings? Let's use integers for now.
26
+ // Actually CozoDB Validity often uses integers as unix timestamps in milliseconds or microseconds.
27
+ const data = [
28
+ ['old', [now - 10000000, true], 'old_type', vec],
29
+ ['new', [now, true], 'new_type', vec]
30
+ ];
31
+ await db.run(`
32
+ ?[id, created_at, type, embedding] <- $data
33
+ :put test_time {id, created_at => type, embedding}
34
+ `, { data });
35
+ console.log("--- Test 1: Validity lower() in body ---");
36
+ try {
37
+ const min_ts = now - 5000000;
38
+ const res = await db.run(`
39
+ ?[id, start_ts] := *test_time{id, created_at, @ "NOW"}, start_ts = lower(created_at), start_ts > $min_ts
40
+ `, { min_ts });
41
+ console.log("Results body filter:", res.rows);
42
+ }
43
+ catch (e) {
44
+ console.error("Error body filter:", e.message || e);
45
+ }
46
+ console.log("--- Test 3: Direct Validity comparison in HNSW filter ---");
47
+ try {
48
+ const min_ts = now - 5000000;
49
+ const res = await db.run(`
50
+ ?[id] := ~test_time:semantic{id, created_at | query: vec($vec), k: 10, ef: 100, filter: created_at > $min_ts}
51
+ `, { vec, min_ts });
52
+ console.log("Results direct HNSW filter:", res.rows);
53
+ }
54
+ catch (e) {
55
+ console.error("Error direct HNSW filter:", e.message || e);
56
+ }
57
+ }
58
+ catch (e) {
59
+ console.error("Global error:", e.message || e);
60
+ }
61
+ finally {
62
+ // Cleanup
63
+ // db.close(); // Cozo-node doesn't have close()?
64
+ }
65
+ }
66
+ testTimeFilter();
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testTimeFunctions() {
9
+ const dbPath = "test-time-funcs.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ try {
18
+ await db.run(`{:create test_v {id: String, v: Validity => t: String}}`);
19
+ const now = Date.now();
20
+ const data = [['id1', [now - 1000, true], 'typeA']];
21
+ await db.run(`?[id, v, t] <- $data :put test_v {id, v => t}`, { data });
22
+ const functionsToTest = ['valid_from', 'start', 'beginning', 'lower_bound'];
23
+ for (const fn of functionsToTest) {
24
+ console.log(`--- Testing ${fn}(v) ---`);
25
+ try {
26
+ const res = await db.run(`?[id, val] := *test_v{id, v}, val = ${fn}(v)`);
27
+ console.log(`${fn}(v) success:`, res.rows);
28
+ }
29
+ catch (e) {
30
+ console.log(`${fn}(v) failed:`, e.message || e);
31
+ }
32
+ }
33
+ }
34
+ catch (e) {
35
+ console.error("Global error:", e.message || e);
36
+ }
37
+ }
38
+ testTimeFunctions();
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ async function testTriggers() {
5
+ console.log('--- Testing CozoDB Triggers ---');
6
+ const server = new index_1.MemoryServer();
7
+ await server.initPromise;
8
+ try {
9
+ // 1. Test Self-Loop Trigger
10
+ console.log('\nTesting self-loop trigger...');
11
+ const selfLoopRes = await server.createRelation({
12
+ from_id: 'entity_1',
13
+ to_id: 'entity_1', // Self-loop
14
+ relation_type: 'self_reference'
15
+ });
16
+ if (selfLoopRes && selfLoopRes.error) {
17
+ console.log('✅ Success: Self-loop trigger blocked the operation:', selfLoopRes.error);
18
+ }
19
+ else {
20
+ console.error('❌ Error: Self-loop trigger failed (allowed self-loop)');
21
+ }
22
+ // 2. Test Metadata Conflict Trigger
23
+ console.log('\nTesting metadata conflict trigger...');
24
+ const conflictRes = await server.createEntity({
25
+ name: 'Conflict Entity ' + Math.random(),
26
+ type: 'Test',
27
+ metadata: {
28
+ status: 'active',
29
+ archived: true // Should conflict with status: 'active'
30
+ }
31
+ });
32
+ if (conflictRes && conflictRes.error) {
33
+ console.log('✅ Success: Metadata conflict trigger blocked the operation:', conflictRes.error);
34
+ }
35
+ else {
36
+ console.error('❌ Error: Metadata conflict trigger failed (allowed conflicting metadata)');
37
+ }
38
+ // 3. Test Valid Entity
39
+ console.log('\nTesting valid entity...');
40
+ try {
41
+ const valid = await server.createEntity({
42
+ name: 'Valid Entity',
43
+ type: 'Test',
44
+ metadata: {
45
+ status: 'active',
46
+ archived: false
47
+ }
48
+ });
49
+ console.log('✅ Success: Valid entity created');
50
+ }
51
+ catch (e) {
52
+ console.error('❌ Error: Valid entity was blocked:', e.message);
53
+ }
54
+ }
55
+ finally {
56
+ // Clean up or close if needed
57
+ process.exit(0);
58
+ }
59
+ }
60
+ testTriggers().catch(console.error);
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ // @ts-ignore
37
+ const ort = __importStar(require("onnxruntime-node"));
38
+ async function test() {
39
+ console.log("TS-Node ONNX Test");
40
+ try {
41
+ // @ts-ignore
42
+ await ort.InferenceSession.create("non-existent.onnx");
43
+ }
44
+ catch (e) {
45
+ console.log("Error:", e.message);
46
+ }
47
+ }
48
+ test();
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testValidityAccess() {
9
+ const dbPath = "test-validity-access.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ try {
18
+ await db.run(`{:create test_v {id: String, v: Validity => t: String}}`);
19
+ const now = Date.now();
20
+ const data = [['id1', [now - 1000, true], 'typeA']];
21
+ await db.run(`?[id, v, t] <- $data :put test_v {id, v => t}`, { data });
22
+ console.log("--- Test get(v, 0) ---");
23
+ try {
24
+ const res = await db.run(`?[id, start] := *test_v{id, v}, start = get(v, 0)`);
25
+ console.log("get(v, 0) results:", res.rows);
26
+ }
27
+ catch (e) {
28
+ console.error("get(v, 0) error:", e.message || e);
29
+ }
30
+ }
31
+ catch (e) {
32
+ console.error("Global error:", e.message || e);
33
+ }
34
+ }
35
+ testValidityAccess();
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testValidityBody() {
9
+ const dbPath = "test-validity-body.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ try {
18
+ await db.run(`{:create test_v {id: String, created_at: Validity => t: String}}`);
19
+ const now = Date.now();
20
+ const data = [['id1', [now - 1000, true], 'typeA']];
21
+ await db.run(`?[id, created_at, t] <- $data :put test_v {id, created_at => t}`, { data });
22
+ console.log("--- Querying with Validity in body ---");
23
+ try {
24
+ const res = await db.run(`?[id] := *test_v{id, created_at: c}, c <- [[ts, _]], ts > 0`);
25
+ console.log("c <- [[ts, _]] results:", res.rows);
26
+ }
27
+ catch (e) {
28
+ console.log("c <- [[ts, _]] failed:", e.message || e);
29
+ }
30
+ try {
31
+ const res = await db.run(`?[id] := *test_v{id, created_at: c}, [ts, _] = c, ts > 0`);
32
+ console.log("Explicit decomposition results:", res.rows);
33
+ }
34
+ catch (e) {
35
+ console.log("Explicit decomposition failed:", e.message || e);
36
+ }
37
+ }
38
+ catch (e) {
39
+ console.error("Global error:", e.message || e);
40
+ }
41
+ }
42
+ testValidityBody();
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testValidityDecomposition() {
9
+ const dbPath = "test-validity-decomp.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ try {
18
+ await db.run(`{:create test_v {id: String, v: Validity => t: String}}`);
19
+ const now = Date.now();
20
+ const data = [['id1', [now - 1000, true], 'typeA']];
21
+ await db.run(`?[id, v, t] <- $data :put test_v {id, v => t}`, { data });
22
+ console.log("--- Testing v as a list/array ---");
23
+ try {
24
+ // In CozoDB, Validity is often handled via special temporal joins (@)
25
+ // But let's see if we can just treat it as a list if we don't use @
26
+ const res = await db.run(`?[id, v_start] := *test_v{id, v}, [v_start, _] = v`);
27
+ console.log("Decomposition results:", res.rows);
28
+ }
29
+ catch (e) {
30
+ console.log("Decomposition failed:", e.message || e);
31
+ }
32
+ }
33
+ catch (e) {
34
+ console.error("Global error:", e.message || e);
35
+ }
36
+ }
37
+ testValidityDecomposition();
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testValidityExtraction() {
9
+ const dbPath = "test-validity-extraction.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ try {
18
+ await db.run(`{:create test_v {id: String, v: Validity => t: String}}`);
19
+ const now = Date.now();
20
+ const data = [['id1', [now - 1000, true], 'typeA']];
21
+ await db.run(`?[id, v, t] <- $data :put test_v {id, v => t}`, { data });
22
+ const methods = [
23
+ 'val = v.0',
24
+ 'val = v[0]',
25
+ '[val, _] = v',
26
+ 'val = get(v, 0)',
27
+ '[[val, _]] <- [v]',
28
+ '[val, _] <- [v]'
29
+ ];
30
+ for (const method of methods) {
31
+ console.log(`--- Testing: ${method} ---`);
32
+ try {
33
+ const res = await db.run(`?[id, val] := *test_v{id, v}, ${method}`);
34
+ console.log(`Success:`, res.rows);
35
+ }
36
+ catch (e) {
37
+ console.log(`Failed:`, e.message || e);
38
+ }
39
+ }
40
+ }
41
+ catch (e) {
42
+ console.error("Global error:", e.message || e);
43
+ }
44
+ }
45
+ testValidityExtraction();
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testValidityToJson() {
9
+ const dbPath = "test-validity-json.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ try {
18
+ await db.run(`{:create test_v {id: String, v: Validity => t: String}}`);
19
+ const now = Date.now();
20
+ const data = [['id1', [now - 1000, true], 'typeA']];
21
+ await db.run(`?[id, v, t] <- $data :put test_v {id, v => t}`, { data });
22
+ console.log("--- Testing: start = get(to_json(v), 0) ---");
23
+ try {
24
+ const res = await db.run(`?[id, val] := *test_v{id, v}, val = get(to_json(v), 0)`);
25
+ console.log(`Success:`, res.rows);
26
+ }
27
+ catch (e) {
28
+ console.log(`Failed:`, e.message || e);
29
+ }
30
+ }
31
+ catch (e) {
32
+ console.error("Global error:", e.message || e);
33
+ }
34
+ }
35
+ testValidityToJson();
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cozo_node_1 = require("cozo-node");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ async function testValidity() {
9
+ const dbPath = "test-validity.db";
10
+ if (fs_1.default.existsSync(dbPath)) {
11
+ try {
12
+ fs_1.default.unlinkSync(dbPath);
13
+ }
14
+ catch (e) { }
15
+ }
16
+ const db = new cozo_node_1.CozoDb("sqlite", dbPath);
17
+ const EMBEDDING_DIM = 4;
18
+ try {
19
+ console.log("Creating table with Validity...");
20
+ await db.run(`{:create test_v {id: String, v: Validity => t: String}}`);
21
+ const now = Date.now();
22
+ const data = [
23
+ ['id1', [now - 1000, true], 'typeA'],
24
+ ['id2', [now, true], 'typeB']
25
+ ];
26
+ await db.run(`
27
+ ?[id, v, t] <- $data
28
+ :put test_v {id, v => t}
29
+ `, { data });
30
+ console.log("--- Querying Validity directly ---");
31
+ const res = await db.run(`?[id, v] := *test_v{id, v}`);
32
+ console.log("Raw results:", JSON.stringify(res.rows));
33
+ }
34
+ catch (e) {
35
+ console.error("Global error:", e.message || e);
36
+ }
37
+ }
38
+ testValidity();
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Core types for CozoDB Memory MCP Server
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const embedding_service_1 = require("./embedding-service");
4
+ async function verifyGpu() {
5
+ console.log("Starting GPU Verification for EmbeddingService...");
6
+ try {
7
+ const service = new embedding_service_1.EmbeddingService();
8
+ console.log("Service created. Generating embedding (Run 1)...");
9
+ let start = performance.now();
10
+ let embedding = await service.embed("This is a test sentence to verify GPU usage.");
11
+ let end = performance.now();
12
+ console.log(`Run 1: Embedding generated in ${(end - start).toFixed(2)}ms`);
13
+ console.log("Generating embedding (Run 2)...");
14
+ start = performance.now();
15
+ embedding = await service.embed("This is a second test sentence.");
16
+ end = performance.now();
17
+ console.log(`Run 2: Embedding generated in ${(end - start).toFixed(2)}ms`);
18
+ console.log(`Embedding length: ${embedding.length}`);
19
+ if (embedding.length > 0 && embedding.some(v => v !== 0)) {
20
+ console.log("Embedding contains non-zero values (Success).");
21
+ }
22
+ else {
23
+ console.log("Embedding contains all zeros (Failure/Fallback triggered).");
24
+ }
25
+ }
26
+ catch (error) {
27
+ console.error("Verification failed:", error);
28
+ }
29
+ }
30
+ verifyGpu();
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("./index");
4
+ async function testTransaction() {
5
+ console.log("Starting Transaction Test...");
6
+ const server = new index_1.MemoryServer(index_1.DB_PATH);
7
+ await server.initPromise;
8
+ const testEntityName = "Transaction-Test-Entity-" + Date.now();
9
+ const ops = [
10
+ {
11
+ action: "create_entity",
12
+ params: {
13
+ name: testEntityName,
14
+ type: "Test",
15
+ metadata: { source: "test-script" }
16
+ }
17
+ },
18
+ {
19
+ action: "add_observation",
20
+ params: {
21
+ entity_name: testEntityName,
22
+ text: "Dies ist eine Test-Beobachtung aus einer Transaktion.",
23
+ metadata: { priority: "low" }
24
+ }
25
+ }
26
+ ];
27
+ try {
28
+ console.log("Executing Transaction...");
29
+ const result = await server.runTransaction({ operations: ops });
30
+ console.log("Transaction Result:", JSON.stringify(result, null, 2));
31
+ if (result.error) {
32
+ console.error("FAILED: Transaction returned an error.");
33
+ }
34
+ else {
35
+ console.log("SUCCESS: Transaction completed successfully.");
36
+ }
37
+ }
38
+ catch (e) {
39
+ console.error("CRITICAL ERROR:", e.message);
40
+ }
41
+ finally {
42
+ // Cozo might keep the file locked if we don't close it, but MemoryServer doesn't have a close() method.
43
+ // In a real test, we would handle this.
44
+ }
45
+ }
46
+ testTransaction().catch(console.error);
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "cozo-memory",
3
+ "version": "1.0.0",
4
+ "description": "Local-first persistent memory system for AI agents with hybrid search, graph reasoning, and MCP integration",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "cozo-memory": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/tobs-code/cozo-memory.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/tobs-code/cozo-memory/issues"
21
+ },
22
+ "homepage": "https://github.com/tobs-code/cozo-memory#readme",
23
+ "scripts": {
24
+ "build": "tsc",
25
+ "prepublishOnly": "npm run build",
26
+ "start": "node dist/index.js",
27
+ "bridge": "tsc && node dist/api_bridge.js",
28
+ "dev": "ts-node src/index.ts",
29
+ "clean": "rm -rf dist",
30
+ "rebuild": "npm run clean && npm run build",
31
+ "test": "echo \"Error: no test specified\" && exit 1",
32
+ "benchmark": "ts-node src/benchmark.ts",
33
+ "download-model": "ts-node src/download-model.ts"
34
+ },
35
+ "keywords": [
36
+ "mcp",
37
+ "memory",
38
+ "ai",
39
+ "agent",
40
+ "cozodb",
41
+ "graph-database",
42
+ "vector-search",
43
+ "hybrid-search",
44
+ "embeddings",
45
+ "knowledge-graph"
46
+ ],
47
+ "author": "tobs <tobsgo1@gmail.com>",
48
+ "license": "Apache-2.0",
49
+ "type": "commonjs",
50
+ "dependencies": {
51
+ "@types/cors": "^2.8.19",
52
+ "@types/express": "^5.0.6",
53
+ "@xenova/transformers": "^2.17.2",
54
+ "cors": "^2.8.6",
55
+ "cozo-node": "^0.7.6",
56
+ "express": "^5.2.1",
57
+ "fastmcp": "^3.31.0",
58
+ "ollama": "^0.6.3",
59
+ "onnxruntime-node": "^1.24.2",
60
+ "uuid": "^13.0.0",
61
+ "zod": "^4.3.6"
62
+ },
63
+ "overrides": {
64
+ "onnxruntime-node": "$onnxruntime-node"
65
+ },
66
+ "devDependencies": {
67
+ "@types/jest": "^30.0.0",
68
+ "@types/node": "^25.2.0",
69
+ "@types/uuid": "^10.0.0",
70
+ "jest": "^30.2.0",
71
+ "ts-jest": "^29.4.6",
72
+ "ts-node": "^10.9.2",
73
+ "typescript": "^5.9.3"
74
+ }
75
+ }