Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

Version Bump/Formatting (#2923)

Saket Aryan9a12ea7b3cc3
diff --git a/docs/changelog.mdx b/docs/changelog.mdx
index ebe9d49a5..7686c381b 100644
--- a/docs/changelog.mdx
+++ b/docs/changelog.mdx
@@ -288,6 +288,14 @@ mode: "wide"
<Tab title="TypeScript">
+<Update label="2025-06-06" description="v2.1.30">
+**New Features:**
+- **OSS:** Added Cloudflare support
+
+**Improvements:**
+- **OSS:** Fixed baseURL param in LLM Config.
+</Update>
+
<Update label="2025-05-30" description="v2.1.29">
**Improvements:**
- **Client:** Added Async Mode Param for `add` method.
diff --git a/mem0-ts/package.json b/mem0-ts/package.json
index d0e4e42dc..f6d045bbe 100644
--- a/mem0-ts/package.json
+++ b/mem0-ts/package.json
@@ -1,6 +1,6 @@
{
"name": "mem0ai",
- "version": "2.1.29",
+ "version": "2.1.30",
"description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@@ -107,6 +107,8 @@
"@types/sqlite3": "3.1.11",
"groq-sdk": "0.3.0",
"@langchain/core": "^0.3.44",
+ "cloudflare": "^4.2.0",
+ "@cloudflare/workers-types": "^4.20250504.0",
"neo4j-driver": "^5.28.1",
"ollama": "^0.5.14",
"pg": "8.11.3",
diff --git a/mem0-ts/pnpm-lock.yaml b/mem0-ts/pnpm-lock.yaml
index fc2227169..a07a99316 100644
--- a/mem0-ts/pnpm-lock.yaml
+++ b/mem0-ts/pnpm-lock.yaml
@@ -10,6 +10,9 @@ importers:
"@anthropic-ai/sdk":
specifier: ^0.40.1
version: 0.40.1([email protected])
+ "@cloudflare/workers-types":
+ specifier: ^4.20250504.0
+ version: 4.20250606.0
"@google/genai":
specifier: ^1.2.0
version: 1.2.0(@modelcontextprotocol/[email protected])([email protected])
@@ -37,6 +40,9 @@ importers:
axios:
specifier: 1.7.7
version: 1.7.7
+ cloudflare:
+ specifier: ^4.2.0
+ version: 4.3.0([email protected])
groq-sdk:
specifier: 0.3.0
version: 0.3.0([email protected])
@@ -385,6 +391,12 @@ packages:
integrity: sha512-gAmrUZSGtKc3AiBL71iNWxDsyUC5uMaKKGdvzYsBoTW/xi42JQHl7eKV2OYzCUqvc+D2RCcf7EXY2iCyFIk6og==,
}
+ "@cloudflare/[email protected]":
+ resolution:
+ {
+ integrity: sha512-9T/Y/Mxe57UVzqgfjJKheiMplnStj/3CmCHlgoZNLU8JW2waRbXvpY3EEeliiYAJfeHZTjeAaKO2pCabxAoyCw==,
+ }
+
"@cspotcode/[email protected]":
resolution:
{
@@ -1811,6 +1823,12 @@ packages:
}
engines: { node: ">=12" }
+ resolution:
+ {
+ integrity: sha512-C+4Jhsl/OY4V5sykRB1yJxComDld5BkKW1xd3s0MDJ1yYamT2sFAoC2FEUQg5zipyxMaaGU4N7hZ6il+gfJxZg==,
+ }
+
resolution:
{
@@ -5465,6 +5483,8 @@ snapshots:
"@cfworker/[email protected]": {}
+ "@cloudflare/[email protected]": {}
+
"@cspotcode/[email protected]":
dependencies:
"@jridgewell/trace-mapping": 0.3.9
@@ -6397,6 +6417,18 @@ snapshots:
strip-ansi: 6.0.1
wrap-ansi: 7.0.0
+ dependencies:
+ "@types/node": 18.19.76
+ "@types/node-fetch": 2.6.12
+ abort-controller: 3.0.0
+ agentkeepalive: 4.6.0
+ form-data-encoder: 1.7.2
+ formdata-node: 4.4.1
+ node-fetch: 2.7.0([email protected])
+ transitivePeerDependencies:
+ - encoding
+
diff --git a/mem0-ts/src/oss/src/types/index.ts b/mem0-ts/src/oss/src/types/index.ts
index b2bdc0a82..dbc0fa123 100644
--- a/mem0-ts/src/oss/src/types/index.ts
+++ b/mem0-ts/src/oss/src/types/index.ts
@@ -117,6 +117,7 @@ export const MemoryConfigSchema = z.object({
modelProperties: z.record(z.string(), z.any()).optional(),
apiKey: z.string().optional(),
model: z.union([z.string(), z.any()]).optional(),
+ baseURL: z.string().optional(),
}),
}),
vectorStore: z.object({
@@ -135,6 +136,7 @@ export const MemoryConfigSchema = z.object({
apiKey: z.string().optional(),
model: z.union([z.string(), z.any()]).optional(),
modelProperties: z.record(z.string(), z.any()).optional(),
+ baseURL: z.string().optional(),
}),
}),
historyDbPath: z.string().optional(),
diff --git a/mem0-ts/src/oss/src/vector_stores/vectorize.ts b/mem0-ts/src/oss/src/vector_stores/vectorize.ts
index d2b63563e..2a1caeaa4 100644
--- a/mem0-ts/src/oss/src/vector_stores/vectorize.ts
+++ b/mem0-ts/src/oss/src/vector_stores/vectorize.ts
@@ -32,7 +32,7 @@ export class VectorizeDB implements VectorStore {
async insert(
vectors: number[][],
ids: string[],
- payloads: Record<string, any>[]
+ payloads: Record<string, any>[],
): Promise<void> {
try {
const vectorObjects: CloudflareVector[] = vectors.map(
@@ -40,7 +40,7 @@ export class VectorizeDB implements VectorStore {
id: ids[index],
values: vector,
metadata: payloads[index] || {},
- })
+ }),
);
const ndjsonPayload = vectorObjects
@@ -56,19 +56,19 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: ndjsonPayload,
- }
+ },
);
if (!response.ok) {
const errorText = await response.text();
throw new Error(
- `Failed to insert vectors: ${response.status} ${errorText}`
+ `Failed to insert vectors: ${response.status} ${errorText}`,
);
}
} catch (error) {
console.error("Error inserting vectors:", error);
throw new Error(
- `Failed to insert vectors: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to insert vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -76,7 +76,7 @@ export class VectorizeDB implements VectorStore {
async search(
query: number[],
limit: number = 5,
- filters?: SearchFilters
+ filters?: SearchFilters,
): Promise<VectorStoreResult[]> {
try {
const result = await this.client?.vectorize.indexes.query(
@@ -87,7 +87,7 @@ export class VectorizeDB implements VectorStore {
filter: filters,
returnMetadata: "all",
topK: limit,
- }
+ },
);
return (
@@ -100,7 +100,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error searching vectors:", error);
throw new Error(
- `Failed to search vectors: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to search vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -112,7 +112,7 @@ export class VectorizeDB implements VectorStore {
{
account_id: this.accountId,
ids: [vectorId],
- }
+ },
)) as any;
if (!result?.length) return null;
@@ -124,7 +124,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error getting vector:", error);
throw new Error(
- `Failed to get vector: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to get vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -132,7 +132,7 @@ export class VectorizeDB implements VectorStore {
async update(
vectorId: string,
vector: number[],
- payload: Record<string, any>
+ payload: Record<string, any>,
): Promise<void> {
try {
const data: VectorizeVector = {
@@ -150,19 +150,19 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: JSON.stringify(data) + "\n", // ndjson format
- }
+ },
);
if (!response.ok) {
const errorText = await response.text();
throw new Error(
- `Failed to update vector: ${response.status} ${errorText}`
+ `Failed to update vector: ${response.status} ${errorText}`,
);
}
} catch (error) {
console.error("Error updating vector:", error);
throw new Error(
- `Failed to update vector: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to update vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -176,7 +176,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error deleting vector:", error);
throw new Error(
- `Failed to delete vector: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to delete vector: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -189,14 +189,14 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error deleting collection:", error);
throw new Error(
- `Failed to delete collection: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to delete collection: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
async list(
filters?: SearchFilters,
- limit: number = 20
+ limit: number = 20,
): Promise<[VectorStoreResult[], number]> {
try {
const result = await this.client?.vectorize.indexes.query(
@@ -207,7 +207,7 @@ export class VectorizeDB implements VectorStore {
filter: filters,
topK: limit,
returnMetadata: "all",
- }
+ },
);
const matches =
@@ -221,7 +221,7 @@ export class VectorizeDB implements VectorStore {
} catch (error) {
console.error("Error listing vectors:", error);
throw new Error(
- `Failed to list vectors: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to list vectors: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -233,7 +233,7 @@ export class VectorizeDB implements VectorStore {
const r = (Math.random() * 16) | 0;
const v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
- }
+ },
);
}
@@ -267,7 +267,7 @@ export class VectorizeDB implements VectorStore {
vector: [0],
topK: 1,
returnMetadata: "all",
- }
+ },
);
if (result.matches.length > 0) {
return result.matches[0].metadata.userId as string;
@@ -292,13 +292,13 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: JSON.stringify(data) + "\n", // ndjson format
- }
+ },
);
return randomUserId;
} catch (error) {
console.error("Error getting user ID:", error);
throw new Error(
- `Failed to get user ID: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to get user ID: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -313,7 +313,7 @@ export class VectorizeDB implements VectorStore {
vector: [0],
topK: 1,
returnMetadata: "all",
- }
+ },
);
const pointId =
result.matches.length > 0 ? result.matches[0].id : this.generateUUID();
@@ -332,12 +332,12 @@ export class VectorizeDB implements VectorStore {
Authorization: `Bearer ${this.client?.apiToken}`,
},
body: JSON.stringify(data) + "\n", // ndjson format
- }
+ },
);
} catch (error) {
console.error("Error setting user ID:", error);
throw new Error(
- `Failed to set user ID: ${error instanceof Error ? error.message : String(error)}`
+ `Failed to set user ID: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
@@ -375,7 +375,7 @@ export class VectorizeDB implements VectorStore {
account_id: this.accountId,
indexType: "string",
propertyName,
- }
+ },
);
}
} catch (err: any) {
@@ -389,7 +389,7 @@ export class VectorizeDB implements VectorStore {
this.indexName,
{
account_id: this.accountId,
- }
+ },
);
const existingMetadataIndexes = new Set<string>();
for (const metadataIndex of metadataIndexes?.metadataIndexes || []) {
@@ -404,7 +404,7 @@ export class VectorizeDB implements VectorStore {
account_id: this.accountId,
indexType: "string",
propertyName,
- }
+ },
);
}
}