mem0ai 2.0.2 → 2.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client/mem0.ts","../src/client/telemetry.browser.ts","../src/client/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n AllUsers,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryOptions,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n} from \"./mem0.types\";\nimport { captureClientEvent, generateHash } from \"./telemetry\";\n\nclass APIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"APIError\";\n }\n}\n\ninterface ClientOptions {\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n organizationId?: string;\n projectId?: string;\n}\n\nexport default class MemoryClient {\n apiKey: string;\n host: string;\n organizationName: string | null;\n projectName: string | null;\n organizationId: string | number | null;\n projectId: string | number | null;\n headers: Record<string, string>;\n client: any;\n telemetryId: string;\n\n _validateApiKey(): any {\n if (!this.apiKey) {\n throw new Error(\"Mem0 API key is required\");\n }\n if (typeof this.apiKey !== \"string\") {\n throw new Error(\"Mem0 API key must be a string\");\n }\n if (this.apiKey.trim() === \"\") {\n throw new Error(\"Mem0 API key cannot be empty\");\n }\n }\n\n _validateOrgProject(): void {\n // Check for organizationName/projectName pair\n if (\n (this.organizationName === null && this.projectName !== null) ||\n (this.organizationName !== null && this.projectName === null)\n ) {\n console.warn(\n \"Warning: Both organizationName and projectName must be provided together when using either. This will be removedfrom the version 1.0.40. Note that organizationName/projectName are being deprecated in favor of organizationId/projectId.\",\n );\n }\n\n // Check for organizationId/projectId pair\n if (\n (this.organizationId === null && this.projectId !== null) ||\n (this.organizationId !== null && this.projectId === null)\n ) {\n console.warn(\n \"Warning: Both organizationId and projectId must be provided together when using either. This will be removedfrom the version 1.0.40.\",\n );\n }\n }\n\n constructor(options: ClientOptions) {\n this.apiKey = options.apiKey;\n this.host = options.host || \"https://api.mem0.ai\";\n this.organizationName = options.organizationName || null;\n this.projectName = options.projectName || null;\n this.organizationId = options.organizationId || null;\n this.projectId = options.projectId || null;\n\n this.headers = {\n Authorization: `Token ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n };\n\n this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n this._validateOrgProject();\n\n // Initialize with a temporary ID that will be updated\n this.telemetryId = \"\";\n\n // Initialize the client\n this._initializeClient();\n }\n\n private async _initializeClient() {\n try {\n // do this only in browser\n if (typeof window !== \"undefined\") {\n this.telemetryId = await generateHash(this.apiKey);\n await captureClientEvent(\"init\", this);\n }\n\n // Wrap methods after initialization\n this.add = this.wrapMethod(\"add\", this.add);\n this.get = this.wrapMethod(\"get\", this.get);\n this.getAll = this.wrapMethod(\"get_all\", this.getAll);\n this.search = this.wrapMethod(\"search\", this.search);\n this.delete = this.wrapMethod(\"delete\", this.delete);\n this.deleteAll = this.wrapMethod(\"delete_all\", this.deleteAll);\n this.history = this.wrapMethod(\"history\", this.history);\n this.users = this.wrapMethod(\"users\", this.users);\n this.deleteUser = this.wrapMethod(\"delete_user\", this.deleteUser);\n this.deleteUsers = this.wrapMethod(\"delete_users\", this.deleteUsers);\n this.batchUpdate = this.wrapMethod(\"batch_update\", this.batchUpdate);\n this.batchDelete = this.wrapMethod(\"batch_delete\", this.batchDelete);\n this.getProject = this.wrapMethod(\"get_project\", this.getProject);\n this.updateProject = this.wrapMethod(\n \"update_project\",\n this.updateProject,\n );\n this.getWebhooks = this.wrapMethod(\"get_webhook\", this.getWebhooks);\n this.createWebhook = this.wrapMethod(\n \"create_webhook\",\n this.createWebhook,\n );\n this.updateWebhook = this.wrapMethod(\n \"update_webhook\",\n this.updateWebhook,\n );\n this.deleteWebhook = this.wrapMethod(\n \"delete_webhook\",\n this.deleteWebhook,\n );\n } catch (error) {\n console.error(\"Failed to initialize client:\", error);\n }\n }\n\n wrapMethod(methodName: any, method: any) {\n return async function (...args: any) {\n // @ts-ignore\n await captureClientEvent(methodName, this);\n // @ts-ignore\n return method.apply(this, args);\n }.bind(this);\n }\n\n async _fetchWithErrorHandling(url: string, options: any): Promise<any> {\n const response = await fetch(url, options);\n if (!response.ok) {\n const errorData = await response.text();\n throw new APIError(`API request failed: ${errorData}`);\n }\n const jsonResponse = await response.json();\n return jsonResponse;\n }\n\n _preparePayload(\n messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions,\n ): object {\n const payload: any = {};\n if (typeof messages === \"string\") {\n payload.messages = [{ role: \"user\", content: messages }];\n } else if (Array.isArray(messages)) {\n payload.messages = messages;\n }\n return { ...payload, ...options };\n }\n\n _prepareParams(options: MemoryOptions): object {\n return Object.fromEntries(\n Object.entries(options).filter(([_, v]) => v != null),\n );\n }\n\n async add(\n messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions = {},\n ): Promise<Array<Memory>> {\n this._validateOrgProject();\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n\n const payload = this._preparePayload(messages, options);\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async update(memoryId: string, message: string): Promise<Array<Memory>> {\n this._validateOrgProject();\n const payload = {\n text: message,\n };\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async get(memoryId: string): Promise<Memory> {\n return this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n headers: this.headers,\n },\n );\n }\n\n async getAll(options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\n const { api_version, page, page_size, ...otherOptions } = options!;\n if (this.organizationName != null && this.projectName != null) {\n otherOptions.org_name = this.organizationName;\n otherOptions.project_name = this.projectName;\n }\n\n let appendedParams = \"\";\n let paginated_response = false;\n\n if (page && page_size) {\n appendedParams += `page=${page}&page_size=${page_size}`;\n paginated_response = true;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n otherOptions.org_id = this.organizationId;\n otherOptions.project_id = this.projectId;\n\n if (otherOptions.org_name) delete otherOptions.org_name;\n if (otherOptions.project_name) delete otherOptions.project_name;\n }\n\n if (api_version === \"v2\") {\n let url = paginated_response\n ? `${this.host}/v2/memories/?${appendedParams}`\n : `${this.host}/v2/memories/`;\n return this._fetchWithErrorHandling(url, {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(otherOptions),\n });\n } else {\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(otherOptions));\n const url = paginated_response\n ? `${this.host}/v1/memories/?${params}&${appendedParams}`\n : `${this.host}/v1/memories/?${params}`;\n return this._fetchWithErrorHandling(url, {\n headers: this.headers,\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\n const { api_version, ...otherOptions } = options!;\n const payload = { query, ...otherOptions };\n if (this.organizationName != null && this.projectName != null) {\n payload.org_name = this.organizationName;\n payload.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n payload.org_id = this.organizationId;\n payload.project_id = this.projectId;\n\n if (payload.org_name) delete payload.org_name;\n if (payload.project_name) delete payload.project_name;\n }\n const endpoint =\n api_version === \"v2\" ? \"/v2/memories/search/\" : \"/v1/memories/search/\";\n const response = await this._fetchWithErrorHandling(\n `${this.host}${endpoint}`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n this._validateOrgProject();\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(options));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/?${params}`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/history/`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async users(): Promise<AllUsers> {\n this._validateOrgProject();\n const options: MemoryOptions = {};\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(options);\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/entities/?${params}`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async deleteUser(\n entityId: string,\n entity: { type: string } = { type: \"user\" },\n ): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/entities/${entity.type}/${entityId}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n this._validateOrgProject();\n const entities = await this.users();\n\n for (const entity of entities.results) {\n let options: MemoryOptions = {};\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, {\n params: options,\n });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n async batchUpdate(memories: Array<MemoryUpdateBody>): Promise<string> {\n const memoriesBody = memories.map((memory) => ({\n memory_id: memory.memoryId,\n text: memory.text,\n }));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/batch/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify({ memories: memoriesBody }),\n },\n );\n return response;\n }\n\n async batchDelete(memories: Array<string>): Promise<string> {\n const memoriesBody = memories.map((memory) => ({\n memory_id: memory,\n }));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/batch/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n body: JSON.stringify({ memories: memoriesBody }),\n },\n );\n return response;\n }\n\n async getProject(options: ProjectOptions): Promise<ProjectResponse> {\n this._validateOrgProject();\n\n const { fields } = options;\n\n if (!(this.organizationId && this.projectId)) {\n throw new Error(\n \"organizationId and projectId must be set to access instructions or categories\",\n );\n }\n\n const params = new URLSearchParams();\n fields?.forEach((field) => params.append(\"fields\", field));\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/?${params.toString()}`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async updateProject(\n prompts: PromptUpdatePayload,\n ): Promise<Record<string, any>> {\n this._validateOrgProject();\n\n if (!(this.organizationId && this.projectId)) {\n throw new Error(\n \"organizationId and projectId must be set to update instructions or categories\",\n );\n }\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/`,\n {\n method: \"PATCH\",\n headers: this.headers,\n body: JSON.stringify(prompts),\n },\n );\n return response;\n }\n\n // WebHooks\n async getWebhooks(data?: { projectId?: string }): Promise<Array<Webhook>> {\n const project_id = data?.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/projects/${project_id}/`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async createWebhook(webhook: WebhookPayload): Promise<Webhook> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/projects/${this.projectId}/`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(webhook),\n },\n );\n return response;\n }\n\n async updateWebhook(webhook: WebhookPayload): Promise<{ message: string }> {\n const project_id = webhook.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/${webhook.webhookId}/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify({\n ...webhook,\n projectId: project_id,\n }),\n },\n );\n return response;\n }\n\n async deleteWebhook(data: {\n webhookId: string;\n }): Promise<{ message: string }> {\n const webhook_id = data.webhookId || data;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/${webhook_id}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n}\n\nexport { MemoryClient };\n","// @ts-nocheck\nimport type { PostHog } from \"posthog-js\";\nimport type { TelemetryClient } from \"./telemetry.types\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\nconst POSTHOG_API_KEY = \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\";\nconst POSTHOG_HOST = \"https://us.i.posthog.com\";\n\n// Browser-specific hash function using Web Crypto API\nasync function generateHash(input: string): Promise<string> {\n const msgBuffer = new TextEncoder().encode(input);\n const hashBuffer = await window.crypto.subtle.digest(\"SHA-256\", msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nclass BrowserTelemetry implements TelemetryClient {\n client: PostHog | null = null;\n\n constructor(projectApiKey: string, host: string) {\n if (MEM0_TELEMETRY) {\n this.initializeClient(projectApiKey, host);\n }\n }\n\n private async initializeClient(projectApiKey: string, host: string) {\n try {\n const posthog = await import(\"posthog-js\").catch(() => null);\n if (posthog) {\n posthog.init(projectApiKey, { api_host: host });\n this.client = posthog;\n }\n } catch (error) {\n // Silently fail if posthog-js is not available\n this.client = null;\n }\n }\n\n async captureEvent(distinctId: string, eventName: string, properties = {}) {\n if (!this.client || !MEM0_TELEMETRY) return;\n\n const eventProperties = {\n client_source: \"browser\",\n client_version: getVersion(),\n browser: window.navigator.userAgent,\n ...properties,\n };\n\n try {\n this.client.capture(eventName, eventProperties);\n } catch (error) {\n // Silently fail if telemetry fails\n }\n }\n\n async shutdown() {\n // No shutdown needed for browser client\n }\n}\n\nfunction getVersion() {\n return version;\n}\n\nconst telemetry = new BrowserTelemetry(POSTHOG_API_KEY, POSTHOG_HOST);\n\nasync function captureClientEvent(\n eventName: string,\n instance: any,\n additionalData = {},\n) {\n const eventData = {\n function: `${instance.constructor.name}`,\n ...additionalData,\n };\n await telemetry.captureEvent(\n instance.telemetryId,\n `client.${eventName}`,\n eventData,\n );\n}\n\nexport { telemetry, captureClientEvent, generateHash };\n","import { MemoryClient } from \"./mem0\";\nimport type { TelemetryClient, TelemetryInstance } from \"./telemetry.types\";\nimport {\n telemetry,\n captureClientEvent,\n generateHash,\n} from \"./telemetry.browser\";\nimport type * as MemoryTypes from \"./mem0.types\";\n\n// Re-export all types from mem0.types\nexport type {\n MemoryOptions,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n Messages,\n Message,\n AllUsers,\n User,\n} from \"./mem0.types\";\n\n// Export telemetry types\nexport type { TelemetryClient, TelemetryInstance };\n\n// Export telemetry implementation\nexport { telemetry, captureClientEvent, generateH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AAAA,MACjD;AAAA,QACE,QAAQ;AAAA,QACR,SAAS,KAAK;AAAA,QACd,MAAM,KAAK,UAAU;AAAA,UACnB,GAAG;AAAA,UACH,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAAc,MAEa;AAC/B,UAAM,aAAa,KAAK,aAAa;AACrC,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B,GAAG,KAAK,IAAI,oBAAoB,UAAU;AAAA,MAC1C;AAAA,QACE,QAAQ;AAAA,QACR,SAAS,KAAK;AAAA,MAChB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;;;AE1gBA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/client/mem0.ts","../src/client/telemetry.browser.ts","../src/client/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n AllUsers,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryOptions,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n Message,\n} from \"./mem0.types\";\nimport { captureClientEvent, generateHash } from \"./telemetry\";\n\nclass APIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"APIError\";\n }\n}\n\ninterface ClientOptions {\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n organizationId?: string;\n projectId?: string;\n}\n\nexport default class MemoryClient {\n apiKey: string;\n host: string;\n organizationName: string | null;\n projectName: string | null;\n organizationId: string | number | null;\n projectId: string | number | null;\n headers: Record<string, string>;\n client: any;\n telemetryId: string;\n\n _validateApiKey(): any {\n if (!this.apiKey) {\n throw new Error(\"Mem0 API key is required\");\n }\n if (typeof this.apiKey !== \"string\") {\n throw new Error(\"Mem0 API key must be a string\");\n }\n if (this.apiKey.trim() === \"\") {\n throw new Error(\"Mem0 API key cannot be empty\");\n }\n }\n\n _validateOrgProject(): void {\n // Check for organizationName/projectName pair\n if (\n (this.organizationName === null && this.projectName !== null) ||\n (this.organizationName !== null && this.projectName === null)\n ) {\n console.warn(\n \"Warning: Both organizationName and projectName must be provided together when using either. This will be removedfrom the version 1.0.40. Note that organizationName/projectName are being deprecated in favor of organizationId/projectId.\",\n );\n }\n\n // Check for organizationId/projectId pair\n if (\n (this.organizationId === null && this.projectId !== null) ||\n (this.organizationId !== null && this.projectId === null)\n ) {\n console.warn(\n \"Warning: Both organizationId and projectId must be provided together when using either. This will be removedfrom the version 1.0.40.\",\n );\n }\n }\n\n constructor(options: ClientOptions) {\n this.apiKey = options.apiKey;\n this.host = options.host || \"https://api.mem0.ai\";\n this.organizationName = options.organizationName || null;\n this.projectName = options.projectName || null;\n this.organizationId = options.organizationId || null;\n this.projectId = options.projectId || null;\n\n this.headers = {\n Authorization: `Token ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n };\n\n this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n this._validateOrgProject();\n\n // Initialize with a temporary ID that will be updated\n this.telemetryId = \"\";\n\n // Initialize the client\n this._initializeClient();\n }\n\n private async _initializeClient() {\n try {\n // do this only in browser\n if (typeof window !== \"undefined\") {\n this.telemetryId = await generateHash(this.apiKey);\n await captureClientEvent(\"init\", this);\n }\n\n // Wrap methods after initialization\n this.add = this.wrapMethod(\"add\", this.add);\n this.get = this.wrapMethod(\"get\", this.get);\n this.getAll = this.wrapMethod(\"get_all\", this.getAll);\n this.search = this.wrapMethod(\"search\", this.search);\n this.delete = this.wrapMethod(\"delete\", this.delete);\n this.deleteAll = this.wrapMethod(\"delete_all\", this.deleteAll);\n this.history = this.wrapMethod(\"history\", this.history);\n this.users = this.wrapMethod(\"users\", this.users);\n this.deleteUser = this.wrapMethod(\"delete_user\", this.deleteUser);\n this.deleteUsers = this.wrapMethod(\"delete_users\", this.deleteUsers);\n this.batchUpdate = this.wrapMethod(\"batch_update\", this.batchUpdate);\n this.batchDelete = this.wrapMethod(\"batch_delete\", this.batchDelete);\n this.getProject = this.wrapMethod(\"get_project\", this.getProject);\n this.updateProject = this.wrapMethod(\n \"update_project\",\n this.updateProject,\n );\n this.getWebhooks = this.wrapMethod(\"get_webhook\", this.getWebhooks);\n this.createWebhook = this.wrapMethod(\n \"create_webhook\",\n this.createWebhook,\n );\n this.updateWebhook = this.wrapMethod(\n \"update_webhook\",\n this.updateWebhook,\n );\n this.deleteWebhook = this.wrapMethod(\n \"delete_webhook\",\n this.deleteWebhook,\n );\n } catch (error) {\n console.error(\"Failed to initialize client:\", error);\n }\n }\n\n wrapMethod(methodName: any, method: any) {\n return async function (...args: any) {\n // @ts-ignore\n await captureClientEvent(methodName, this);\n // @ts-ignore\n return method.apply(this, args);\n }.bind(this);\n }\n\n async _fetchWithErrorHandling(url: string, options: any): Promise<any> {\n const response = await fetch(url, options);\n if (!response.ok) {\n const errorData = await response.text();\n throw new APIError(`API request failed: ${errorData}`);\n }\n const jsonResponse = await response.json();\n return jsonResponse;\n }\n\n _preparePayload(\n messages: string | Array<Message>,\n options: MemoryOptions,\n ): object {\n const payload: any = {};\n if (typeof messages === \"string\") {\n payload.messages = [{ role: \"user\", content: messages }];\n } else if (Array.isArray(messages)) {\n payload.messages = messages;\n }\n return { ...payload, ...options };\n }\n\n _prepareParams(options: MemoryOptions): object {\n return Object.fromEntries(\n Object.entries(options).filter(([_, v]) => v != null),\n );\n }\n\n async add(\n messages: string | Array<Message>,\n options: MemoryOptions = {},\n ): Promise<Array<Memory>> {\n this._validateOrgProject();\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n\n const payload = this._preparePayload(messages, options);\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async update(memoryId: string, message: string): Promise<Array<Memory>> {\n this._validateOrgProject();\n const payload = {\n text: message,\n };\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async get(memoryId: string): Promise<Memory> {\n return this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n headers: this.headers,\n },\n );\n }\n\n async getAll(options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\n const { api_version, page, page_size, ...otherOptions } = options!;\n if (this.organizationName != null && this.projectName != null) {\n otherOptions.org_name = this.organizationName;\n otherOptions.project_name = this.projectName;\n }\n\n let appendedParams = \"\";\n let paginated_response = false;\n\n if (page && page_size) {\n appendedParams += `page=${page}&page_size=${page_size}`;\n paginated_response = true;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n otherOptions.org_id = this.organizationId;\n otherOptions.project_id = this.projectId;\n\n if (otherOptions.org_name) delete otherOptions.org_name;\n if (otherOptions.project_name) delete otherOptions.project_name;\n }\n\n if (api_version === \"v2\") {\n let url = paginated_response\n ? `${this.host}/v2/memories/?${appendedParams}`\n : `${this.host}/v2/memories/`;\n return this._fetchWithErrorHandling(url, {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(otherOptions),\n });\n } else {\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(otherOptions));\n const url = paginated_response\n ? `${this.host}/v1/memories/?${params}&${appendedParams}`\n : `${this.host}/v1/memories/?${params}`;\n return this._fetchWithErrorHandling(url, {\n headers: this.headers,\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\n const { api_version, ...otherOptions } = options!;\n const payload = { query, ...otherOptions };\n if (this.organizationName != null && this.projectName != null) {\n payload.org_name = this.organizationName;\n payload.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n payload.org_id = this.organizationId;\n payload.project_id = this.projectId;\n\n if (payload.org_name) delete payload.org_name;\n if (payload.project_name) delete payload.project_name;\n }\n const endpoint =\n api_version === \"v2\" ? \"/v2/memories/search/\" : \"/v1/memories/search/\";\n const response = await this._fetchWithErrorHandling(\n `${this.host}${endpoint}`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n this._validateOrgProject();\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(options));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/?${params}`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/history/`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async users(): Promise<AllUsers> {\n this._validateOrgProject();\n const options: MemoryOptions = {};\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(options);\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/entities/?${params}`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async deleteUser(\n entityId: string,\n entity: { type: string } = { type: \"user\" },\n ): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/entities/${entity.type}/${entityId}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n this._validateOrgProject();\n const entities = await this.users();\n\n for (const entity of entities.results) {\n let options: MemoryOptions = {};\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n\n if (this.organizationId != null && this.projectId != null) {\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if (options.project_name) delete options.project_name;\n }\n await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, {\n params: options,\n });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n async batchUpdate(memories: Array<MemoryUpdateBody>): Promise<string> {\n const memoriesBody = memories.map((memory) => ({\n memory_id: memory.memoryId,\n text: memory.text,\n }));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/batch/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify({ memories: memoriesBody }),\n },\n );\n return response;\n }\n\n async batchDelete(memories: Array<string>): Promise<string> {\n const memoriesBody = memories.map((memory) => ({\n memory_id: memory,\n }));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/batch/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n body: JSON.stringify({ memories: memoriesBody }),\n },\n );\n return response;\n }\n\n async getProject(options: ProjectOptions): Promise<ProjectResponse> {\n this._validateOrgProject();\n\n const { fields } = options;\n\n if (!(this.organizationId && this.projectId)) {\n throw new Error(\n \"organizationId and projectId must be set to access instructions or categories\",\n );\n }\n\n const params = new URLSearchParams();\n fields?.forEach((field) => params.append(\"fields\", field));\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/?${params.toString()}`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async updateProject(\n prompts: PromptUpdatePayload,\n ): Promise<Record<string, any>> {\n this._validateOrgProject();\n\n if (!(this.organizationId && this.projectId)) {\n throw new Error(\n \"organizationId and projectId must be set to update instructions or categories\",\n );\n }\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/`,\n {\n method: \"PATCH\",\n headers: this.headers,\n body: JSON.stringify(prompts),\n },\n );\n return response;\n }\n\n // WebHooks\n async getWebhooks(data?: { projectId?: string }): Promise<Array<Webhook>> {\n const project_id = data?.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/projects/${project_id}/`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async createWebhook(webhook: WebhookPayload): Promise<Webhook> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/projects/${this.projectId}/`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(webhook),\n },\n );\n return response;\n }\n\n async updateWebhook(webhook: WebhookPayload): Promise<{ message: string }> {\n const project_id = webhook.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/${webhook.webhookId}/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify({\n ...webhook,\n projectId: project_id,\n }),\n },\n );\n return response;\n }\n\n async deleteWebhook(data: {\n webhookId: string;\n }): Promise<{ message: string }> {\n const webhook_id = data.webhookId || data;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/${webhook_id}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n}\n\nexport { MemoryClient };\n","// @ts-nocheck\nimport type { PostHog } from \"posthog-js\";\nimport type { TelemetryClient } from \"./telemetry.types\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\nconst POSTHOG_API_KEY = \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\";\nconst POSTHOG_HOST = \"https://us.i.posthog.com\";\n\n// Browser-specific hash function using Web Crypto API\nasync function generateHash(input: string): Promise<string> {\n const msgBuffer = new TextEncoder().encode(input);\n const hashBuffer = await window.crypto.subtle.digest(\"SHA-256\", msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nclass BrowserTelemetry implements TelemetryClient {\n client: PostHog | null = null;\n\n constructor(projectApiKey: string, host: string) {\n if (MEM0_TELEMETRY) {\n this.initializeClient(projectApiKey, host);\n }\n }\n\n private async initializeClient(projectApiKey: string, host: string) {\n try {\n const posthog = await import(\"posthog-js\").catch(() => null);\n if (posthog) {\n posthog.init(projectApiKey, { api_host: host });\n this.client = posthog;\n }\n } catch (error) {\n // Silently fail if posthog-js is not available\n this.client = null;\n }\n }\n\n async captureEvent(distinctId: string, eventName: string, properties = {}) {\n if (!this.client || !MEM0_TELEMETRY) return;\n\n const eventProperties = {\n client_source: \"browser\",\n client_version: getVersion(),\n browser: window.navigator.userAgent,\n ...properties,\n };\n\n try {\n this.client.capture(eventName, eventProperties);\n } catch (error) {\n // Silently fail if telemetry fails\n }\n }\n\n async shutdown() {\n // No shutdown needed for browser client\n }\n}\n\nfunction getVersion() {\n return version;\n}\n\nconst telemetry = new BrowserTelemetry(POSTHOG_API_KEY, POSTHOG_HOST);\n\nasync function captureClientEvent(\n eventName: string,\n instance: any,\n additionalData = {},\n) {\n const eventData = {\n function: `${instance.constructor.name}`,\n ...additionalData,\n };\n await telemetry.captureEvent(\n instance.telemetryId,\n `client.${eventName}`,\n eventData,\n );\n}\n\nexport { telemetry, captureClientEvent, generateHash };\n","import { MemoryClient } from \"./mem0\";\nimport type { TelemetryClient, TelemetryInstance } from \"./telemetry.types\";\nimport {\n telemetry,\n captureClientEvent,\n generateHash,\n} from \"./telemetry.browser\";\nimport type * as MemoryTypes from \"./mem0.types\";\n\n// Re-export all types from mem0.types\nexport type {\n MemoryOptions,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n Messages,\n Message,\n AllUsers,\n User,\n} from \"./mem0.types\";\n\n// Export telemetry types\nexport type { TelemetryClient, TelemetryInstance };\n\n// Export telemetry implementation\nexport { telemetry, captureClientEvent, generateHash };\n\n// Export the main client\nexport { MemoryClient };\nexport default MemoryClient;\n"],"mappings":";AAAA,OAAO,WAAW;;;ACIlB,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AACtD,IAAM,kBAAkB;AACxB,IAAM,eAAe;AAGrB,eAAe,aAAa,OAAgC;AAC1D,QAAM,YAAY,IAAI,YAAY,EAAE,OAAO,KAAK;AAChD,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,OAAO,WAAW,SAAS;AACzE,QAAM,YAAY,MAAM,KAAK,IAAI,WAAW,UAAU,CAAC;AACvD,SAAO,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACtE;AAEA,IAAM,mBAAN,MAAkD;AAAA,EAGhD,YAAY,eAAuB,MAAc;AAFjD,kBAAyB;AAGvB,QAAI,gBAAgB;AAClB,WAAK,iBAAiB,eAAe,IAAI;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAc,iBAAiB,eAAuB,MAAc;AAClE,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,uBAAY,EAAE,MAAM,MAAM,IAAI;AAC3D,UAAI,SAAS;AACX,gBAAQ,KAAK,eAAe,EAAE,UAAU,KAAK,CAAC;AAC9C,aAAK,SAAS;AAAA,MAChB;AAAA,IACF,SAAS,OAAO;AAEd,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,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AAK,IAAI,6BAA6B,KAAK,SAAS;AAAA,MACvD;AAAA,QACE,QAAQ;AAAA,QACR,SAAS,KAAK;AAAA,QACd,MAAM,KAAK,UAAU,OAAO;AAAA,MAC9B;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAAc,SAAuD;AACzE,UAAM,aAAa,QAAQ,aAAa,KAAK;AAC7C,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B,GAAG,KAAK,IAAI,oBAAoB,QAAQ,SAAS;AAAA,MACjD;AAAA,QACE,QAAQ;AAAA,QACR,SAAS,KAAK;AAAA,QACd,MAAM,KAAK,UAAU;AAAA,UACnB,GAAG;AAAA,UACH,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAAc,MAEa;AAC/B,UAAM,aAAa,KAAK,aAAa;AACrC,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B,GAAG,KAAK,IAAI,oBAAoB,UAAU;AAAA,MAC1C;AAAA,QACE,QAAQ;AAAA,QACR,SAAS,KAAK;AAAA,MAChB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;;;AE3gBA,IAAO,gBAAQ;","names":[]}
@@ -1,9 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  import { QdrantClient } from '@qdrant/js-client-rest';
3
3
 
4
+ interface MultiModalMessages {
5
+ type: "image_url";
6
+ image_url: {
7
+ url: string;
8
+ };
9
+ }
4
10
  interface Message {
5
11
  role: string;
6
- content: string;
12
+ content: string | MultiModalMessages;
7
13
  }
8
14
  interface EmbeddingConfig {
9
15
  apiKey: string;
@@ -15,11 +21,21 @@ interface VectorStoreConfig {
15
21
  [key: string]: any;
16
22
  }
17
23
  interface LLMConfig {
18
- apiKey: string;
24
+ provider?: string;
25
+ config?: Record<string, any>;
26
+ apiKey?: string;
19
27
  model?: string;
20
28
  }
29
+ interface Neo4jConfig {
30
+ url: string;
31
+ username: string;
32
+ password: string;
33
+ }
21
34
  interface GraphStoreConfig {
22
- config?: any;
35
+ provider: string;
36
+ config: Neo4jConfig;
37
+ llm?: LLMConfig;
38
+ customPrompt?: string;
23
39
  }
24
40
  interface MemoryConfig {
25
41
  version?: string;
@@ -38,6 +54,7 @@ interface MemoryConfig {
38
54
  historyDbPath?: string;
39
55
  customPrompt?: string;
40
56
  graphStore?: GraphStoreConfig;
57
+ enableGraph?: boolean;
41
58
  }
42
59
  interface MemoryItem {
43
60
  id: string;
@@ -146,12 +163,57 @@ declare const MemoryConfigSchema: z.ZodObject<{
146
163
  }>;
147
164
  historyDbPath: z.ZodOptional<z.ZodString>;
148
165
  customPrompt: z.ZodOptional<z.ZodString>;
166
+ enableGraph: z.ZodOptional<z.ZodBoolean>;
149
167
  graphStore: z.ZodOptional<z.ZodObject<{
150
- config: z.ZodOptional<z.ZodAny>;
168
+ provider: z.ZodString;
169
+ config: z.ZodObject<{
170
+ url: z.ZodString;
171
+ username: z.ZodString;
172
+ password: z.ZodString;
173
+ }, "strip", z.ZodTypeAny, {
174
+ url: string;
175
+ username: string;
176
+ password: string;
177
+ }, {
178
+ url: string;
179
+ username: string;
180
+ password: string;
181
+ }>;
182
+ llm: z.ZodOptional<z.ZodObject<{
183
+ provider: z.ZodString;
184
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ provider: string;
187
+ config: Record<string, any>;
188
+ }, {
189
+ provider: string;
190
+ config: Record<string, any>;
191
+ }>>;
192
+ customPrompt: z.ZodOptional<z.ZodString>;
151
193
  }, "strip", z.ZodTypeAny, {
152
- config?: any;
194
+ provider: string;
195
+ config: {
196
+ url: string;
197
+ username: string;
198
+ password: string;
199
+ };
200
+ llm?: {
201
+ provider: string;
202
+ config: Record<string, any>;
203
+ } | undefined;
204
+ customPrompt?: string | undefined;
153
205
  }, {
154
- config?: any;
206
+ provider: string;
207
+ config: {
208
+ url: string;
209
+ username: string;
210
+ password: string;
211
+ };
212
+ llm?: {
213
+ provider: string;
214
+ config: Record<string, any>;
215
+ } | undefined;
216
+ customPrompt?: string | undefined;
155
217
  }>>;
156
218
  }, "strip", z.ZodTypeAny, {
157
219
  embedder: {
@@ -180,8 +242,19 @@ declare const MemoryConfigSchema: z.ZodObject<{
180
242
  version?: string | undefined;
181
243
  historyDbPath?: string | undefined;
182
244
  customPrompt?: string | undefined;
245
+ enableGraph?: boolean | undefined;
183
246
  graphStore?: {
184
- config?: any;
247
+ provider: string;
248
+ config: {
249
+ url: string;
250
+ username: string;
251
+ password: string;
252
+ };
253
+ llm?: {
254
+ provider: string;
255
+ config: Record<string, any>;
256
+ } | undefined;
257
+ customPrompt?: string | undefined;
185
258
  } | undefined;
186
259
  }, {
187
260
  embedder: {
@@ -210,8 +283,19 @@ declare const MemoryConfigSchema: z.ZodObject<{
210
283
  version?: string | undefined;
211
284
  historyDbPath?: string | undefined;
212
285
  customPrompt?: string | undefined;
286
+ enableGraph?: boolean | undefined;
213
287
  graphStore?: {
214
- config?: any;
288
+ provider: string;
289
+ config: {
290
+ url: string;
291
+ username: string;
292
+ password: string;
293
+ };
294
+ llm?: {
295
+ provider: string;
296
+ config: Record<string, any>;
297
+ } | undefined;
298
+ customPrompt?: string | undefined;
215
299
  } | undefined;
216
300
  }>;
217
301
 
@@ -244,6 +328,8 @@ declare class Memory {
244
328
  private db;
245
329
  private collectionName;
246
330
  private apiVersion;
331
+ private graphMemory?;
332
+ private enableGraph;
247
333
  constructor(config?: Partial<MemoryConfig>);
248
334
  static fromConfig(configDict: Record<string, any>): Memory;
249
335
  add(messages: string | Message[], config: AddMemoryOptions): Promise<SearchResult>;
@@ -283,11 +369,18 @@ declare class OpenAIEmbedder implements Embedder {
283
369
  interface LLMResponse {
284
370
  content: string;
285
371
  role: string;
372
+ toolCalls?: Array<{
373
+ name: string;
374
+ arguments: string;
375
+ }>;
286
376
  }
287
377
  interface LLM {
288
- generateResponse(messages: Message[], responseFormat?: {
378
+ generateResponse(messages: Array<{
379
+ role: string;
380
+ content: string;
381
+ }>, response_format: {
289
382
  type: string;
290
- }): Promise<string>;
383
+ }, tools?: any[]): Promise<any>;
291
384
  generateChat(messages: Message[]): Promise<LLMResponse>;
292
385
  }
293
386
 
@@ -297,17 +390,17 @@ declare class OpenAILLM implements LLM {
297
390
  constructor(config: LLMConfig);
298
391
  generateResponse(messages: Message[], responseFormat?: {
299
392
  type: string;
300
- }): Promise<string>;
393
+ }, tools?: any[]): Promise<string | LLMResponse>;
301
394
  generateChat(messages: Message[]): Promise<LLMResponse>;
302
395
  }
303
396
 
304
397
  declare class OpenAIStructuredLLM implements LLM {
305
- private client;
398
+ private openai;
306
399
  private model;
307
400
  constructor(config: LLMConfig);
308
401
  generateResponse(messages: Message[], responseFormat?: {
309
402
  type: string;
310
- }): Promise<string>;
403
+ } | null, tools?: any[]): Promise<string | LLMResponse>;
311
404
  generateChat(messages: Message[]): Promise<LLMResponse>;
312
405
  }
313
406
 
@@ -422,4 +515,4 @@ declare class VectorStoreFactory {
422
515
  static create(provider: string, config: VectorStoreConfig): VectorStore;
423
516
  }
424
517
 
425
- export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };
518
+ export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, type MultiModalMessages, type Neo4jConfig, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };
@@ -1,9 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  import { QdrantClient } from '@qdrant/js-client-rest';
3
3
 
4
+ interface MultiModalMessages {
5
+ type: "image_url";
6
+ image_url: {
7
+ url: string;
8
+ };
9
+ }
4
10
  interface Message {
5
11
  role: string;
6
- content: string;
12
+ content: string | MultiModalMessages;
7
13
  }
8
14
  interface EmbeddingConfig {
9
15
  apiKey: string;
@@ -15,11 +21,21 @@ interface VectorStoreConfig {
15
21
  [key: string]: any;
16
22
  }
17
23
  interface LLMConfig {
18
- apiKey: string;
24
+ provider?: string;
25
+ config?: Record<string, any>;
26
+ apiKey?: string;
19
27
  model?: string;
20
28
  }
29
+ interface Neo4jConfig {
30
+ url: string;
31
+ username: string;
32
+ password: string;
33
+ }
21
34
  interface GraphStoreConfig {
22
- config?: any;
35
+ provider: string;
36
+ config: Neo4jConfig;
37
+ llm?: LLMConfig;
38
+ customPrompt?: string;
23
39
  }
24
40
  interface MemoryConfig {
25
41
  version?: string;
@@ -38,6 +54,7 @@ interface MemoryConfig {
38
54
  historyDbPath?: string;
39
55
  customPrompt?: string;
40
56
  graphStore?: GraphStoreConfig;
57
+ enableGraph?: boolean;
41
58
  }
42
59
  interface MemoryItem {
43
60
  id: string;
@@ -146,12 +163,57 @@ declare const MemoryConfigSchema: z.ZodObject<{
146
163
  }>;
147
164
  historyDbPath: z.ZodOptional<z.ZodString>;
148
165
  customPrompt: z.ZodOptional<z.ZodString>;
166
+ enableGraph: z.ZodOptional<z.ZodBoolean>;
149
167
  graphStore: z.ZodOptional<z.ZodObject<{
150
- config: z.ZodOptional<z.ZodAny>;
168
+ provider: z.ZodString;
169
+ config: z.ZodObject<{
170
+ url: z.ZodString;
171
+ username: z.ZodString;
172
+ password: z.ZodString;
173
+ }, "strip", z.ZodTypeAny, {
174
+ url: string;
175
+ username: string;
176
+ password: string;
177
+ }, {
178
+ url: string;
179
+ username: string;
180
+ password: string;
181
+ }>;
182
+ llm: z.ZodOptional<z.ZodObject<{
183
+ provider: z.ZodString;
184
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ provider: string;
187
+ config: Record<string, any>;
188
+ }, {
189
+ provider: string;
190
+ config: Record<string, any>;
191
+ }>>;
192
+ customPrompt: z.ZodOptional<z.ZodString>;
151
193
  }, "strip", z.ZodTypeAny, {
152
- config?: any;
194
+ provider: string;
195
+ config: {
196
+ url: string;
197
+ username: string;
198
+ password: string;
199
+ };
200
+ llm?: {
201
+ provider: string;
202
+ config: Record<string, any>;
203
+ } | undefined;
204
+ customPrompt?: string | undefined;
153
205
  }, {
154
- config?: any;
206
+ provider: string;
207
+ config: {
208
+ url: string;
209
+ username: string;
210
+ password: string;
211
+ };
212
+ llm?: {
213
+ provider: string;
214
+ config: Record<string, any>;
215
+ } | undefined;
216
+ customPrompt?: string | undefined;
155
217
  }>>;
156
218
  }, "strip", z.ZodTypeAny, {
157
219
  embedder: {
@@ -180,8 +242,19 @@ declare const MemoryConfigSchema: z.ZodObject<{
180
242
  version?: string | undefined;
181
243
  historyDbPath?: string | undefined;
182
244
  customPrompt?: string | undefined;
245
+ enableGraph?: boolean | undefined;
183
246
  graphStore?: {
184
- config?: any;
247
+ provider: string;
248
+ config: {
249
+ url: string;
250
+ username: string;
251
+ password: string;
252
+ };
253
+ llm?: {
254
+ provider: string;
255
+ config: Record<string, any>;
256
+ } | undefined;
257
+ customPrompt?: string | undefined;
185
258
  } | undefined;
186
259
  }, {
187
260
  embedder: {
@@ -210,8 +283,19 @@ declare const MemoryConfigSchema: z.ZodObject<{
210
283
  version?: string | undefined;
211
284
  historyDbPath?: string | undefined;
212
285
  customPrompt?: string | undefined;
286
+ enableGraph?: boolean | undefined;
213
287
  graphStore?: {
214
- config?: any;
288
+ provider: string;
289
+ config: {
290
+ url: string;
291
+ username: string;
292
+ password: string;
293
+ };
294
+ llm?: {
295
+ provider: string;
296
+ config: Record<string, any>;
297
+ } | undefined;
298
+ customPrompt?: string | undefined;
215
299
  } | undefined;
216
300
  }>;
217
301
 
@@ -244,6 +328,8 @@ declare class Memory {
244
328
  private db;
245
329
  private collectionName;
246
330
  private apiVersion;
331
+ private graphMemory?;
332
+ private enableGraph;
247
333
  constructor(config?: Partial<MemoryConfig>);
248
334
  static fromConfig(configDict: Record<string, any>): Memory;
249
335
  add(messages: string | Message[], config: AddMemoryOptions): Promise<SearchResult>;
@@ -283,11 +369,18 @@ declare class OpenAIEmbedder implements Embedder {
283
369
  interface LLMResponse {
284
370
  content: string;
285
371
  role: string;
372
+ toolCalls?: Array<{
373
+ name: string;
374
+ arguments: string;
375
+ }>;
286
376
  }
287
377
  interface LLM {
288
- generateResponse(messages: Message[], responseFormat?: {
378
+ generateResponse(messages: Array<{
379
+ role: string;
380
+ content: string;
381
+ }>, response_format: {
289
382
  type: string;
290
- }): Promise<string>;
383
+ }, tools?: any[]): Promise<any>;
291
384
  generateChat(messages: Message[]): Promise<LLMResponse>;
292
385
  }
293
386
 
@@ -297,17 +390,17 @@ declare class OpenAILLM implements LLM {
297
390
  constructor(config: LLMConfig);
298
391
  generateResponse(messages: Message[], responseFormat?: {
299
392
  type: string;
300
- }): Promise<string>;
393
+ }, tools?: any[]): Promise<string | LLMResponse>;
301
394
  generateChat(messages: Message[]): Promise<LLMResponse>;
302
395
  }
303
396
 
304
397
  declare class OpenAIStructuredLLM implements LLM {
305
- private client;
398
+ private openai;
306
399
  private model;
307
400
  constructor(config: LLMConfig);
308
401
  generateResponse(messages: Message[], responseFormat?: {
309
402
  type: string;
310
- }): Promise<string>;
403
+ } | null, tools?: any[]): Promise<string | LLMResponse>;
311
404
  generateChat(messages: Message[]): Promise<LLMResponse>;
312
405
  }
313
406
 
@@ -422,4 +515,4 @@ declare class VectorStoreFactory {
422
515
  static create(provider: string, config: VectorStoreConfig): VectorStore;
423
516
  }
424
517
 
425
- export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };
518
+ export { type AddMemoryOptions, AnthropicLLM, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, type GraphStoreConfig, GroqLLM, type LLM, type LLMConfig, LLMFactory, type LLMResponse, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, type MultiModalMessages, type Neo4jConfig, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult };