Compare commits

..
Author SHA1 Message Date
kartik-mem0 d5b041e942 fix(memory): handle block-list content in remove_code_blocks
A custom LangChain LLM passed to AsyncMemory._create_procedural_memory
returns AIMessage.content, which is str | list[str | dict]. Providers
that emit content blocks hit content.strip() on a list and raised
AttributeError.

remove_code_blocks already normalized None, so the list case is handled
in the same guard rather than at the single call site.

Closes #6150
2026-08-13 17:23:37 +05:30
KartikandGitHub 96d45b78c7 fix(mem0-plugin): drop unused pytest import breaking make lint on main (#6937) 2026-08-13 16:51:01 +05:30
HimanshuandGitHub ba2fb9f4c3 feat(kimi): Mem0 plugin for Kimi Code (MCP + skills + auto-capture) (#6919) 2026-08-13 16:15:04 +05:30
KartikandGitHub 14c431735b fix(cli): surface agent_custom_instructions on add in both CLIs (#6910) 2026-08-12 20:08:34 +05:30
Anas KhanandGitHub d70cc00ab3 docs(components): point config links to provider overviews (#6126)
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
2026-08-12 16:11:46 +05:30
KartikandGitHub c427a453a8 docs(changelog): backfill Python v2.0.18 and TypeScript v3.1.6 SDK entries (#6918) 2026-08-12 00:25:18 +05:30
KartikandGitHub f5b4300449 docs: redirect deprecated OSS graph memory page to platform graph memory (#6914) 2026-08-12 00:25:02 +05:30
KartikandGitHub 71f2ebefa3 fix(memory): escape delimiters when building the session scope key (#6892) 2026-08-11 23:23:55 +05:30
Hrushikesh YadavandGitHub 35a125585e fix(pgvector): raise ValueError when 'in'/'nin' filter value is not a list (#6879) 2026-08-11 20:15:07 +05:30
Harsh Vardhan GuptaandGitHub 4debc58a83 fix(security): patch 8 HIGH + 18 MEDIUM Vanta vulnerabilities across 4 pnpm workspaces (#6847) 2026-08-07 19:04:33 +05:30
mintlify[bot]GitHubmintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
b42cfdd5c8 Fix broken links: unblock link check in oracledb.mdx (#6849)
Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
2026-08-07 18:16:06 +05:30
Elif Sema BalciogluandGitHub 6fe6140dba fix(vector-stores/oracledb): Fix accuracy bug (#6848) 2026-08-07 18:07:12 +05:30
Diwakar Ray YadavandGitHub b05dc2740f docs(memory): note filters-based scoping for search/get_all on add() (#6758) 2026-08-07 14:03:09 +05:30
KartikandGitHub 4a0a9a92a6 fix(ts-oss, py): release Oracle client on init failure, validate insert batches (#6839) 2026-08-06 18:16:25 +05:30
KartikandGitHub beea626f0a perf(ts-oss): cut Oracle vector store round trips per review feedback (#6835) 2026-08-06 15:12:14 +05:30
69 changed files with 1516 additions and 165 deletions
+15
View File
@@ -0,0 +1,15 @@
{
"name": "mem0-plugins",
"version": "1",
"plugins": [
{
"id": "mem0",
"displayName": "Mem0",
"version": "0.1.0",
"description": "Persistent memory for Kimi Code. Remembers decisions, patterns, and preferences across sessions.",
"homepage": "https://mem0.ai",
"keywords": ["memory", "personalization", "mcp", "semantic-search"],
"source": "https://github.com/mem0ai/mem0/tree/main/integrations/mem0-plugin"
}
]
}
+41
View File
@@ -0,0 +1,41 @@
# Node CLI (`cli/node/`)
The `@mem0/cli` package on npm. Commander-based, entry point `mem0`.
## Commands
```bash
pnpm install
pnpm run build # tsup (ESM)
pnpm run lint # biome check src/
pnpm run lint:fix # biome check --write src/
pnpm run typecheck # tsc --noEmit
pnpm run test # vitest run
pnpm run test:watch
pnpm run dev # tsx src/index.ts
```
pnpm only. Never npm, never yarn.
## Conventions
> **Biome, not ESLint. vitest, not jest.** `mem0-ts/` uses Prettier + jest and
> `integrations/vercel-ai-sdk/` uses ESLint + jest. Running those tools here produces
> spurious diffs. Every toolchain in this repo is per-package.
- **Node 18+** required.
- **Build:** tsup, ESM output only.
- **Linter and formatter:** Biome, configured in `biome.json`.
- **Tests:** vitest.
- **TypeScript strict mode.** ES module `import` syntax only, never `require()`.
Run `pnpm run typecheck` after every change.
## Dependencies
Commander + Chalk + ora + cli-table3, and `mem0ai` (npm) for API calls.
## CI and release
- CI: `cli-node-ci.yml`, Biome + tsc + vitest + tsup build on Node 20 and 22.
- Release: tag prefix `cli-node-v*` dispatches `cli-node-cd.yml`, publishing to npm over OIDC.
+1
View File
@@ -0,0 +1 @@
AGENTS.md
+1
View File
@@ -15,6 +15,7 @@ export interface AddOptions {
infer?: boolean;
expires?: string;
customInstructions?: string;
agentCustomInstructions?: string;
customCategories?: Record<string, string>[];
structuredDataSchema?: Record<string, unknown>;
timestamp?: number;
+2
View File
@@ -153,6 +153,8 @@ export class PlatformBackend implements Backend {
if (opts.expires) payload.expiration_date = opts.expires;
if (opts.customInstructions)
payload.custom_instructions = opts.customInstructions;
if (opts.agentCustomInstructions)
payload.agent_custom_instructions = opts.agentCustomInstructions;
if (opts.customCategories)
payload.custom_categories = opts.customCategories;
if (opts.structuredDataSchema)
+2
View File
@@ -53,6 +53,7 @@ export async function cmdAdd(
expires?: string;
categories?: string;
customInstructions?: string;
agentCustomInstructions?: string;
customCategories?: string;
structuredDataSchema?: string;
timestamp?: number;
@@ -153,6 +154,7 @@ export async function cmdAdd(
infer: opts.infer !== false,
expires: opts.expires,
customInstructions: opts.customInstructions,
agentCustomInstructions: opts.agentCustomInstructions,
customCategories: customCats,
structuredDataSchema: schema,
timestamp: opts.timestamp,
+4
View File
@@ -328,6 +328,10 @@ program
"--custom-instructions <text>",
"Custom instructions for fact extraction.",
)
.option(
"--agent-custom-instructions <text>",
"Extraction instructions for agent-scoped memories, overriding the project setting.",
)
.option(
"--custom-categories <json>",
"Custom categories as a JSON array of {name: description} objects.",
+1
View File
@@ -50,6 +50,7 @@ const ADD_MAPPING: Record<string, string[]> = {
metadata: ["--metadata"],
expiration_date: ["--expires"],
custom_instructions: ["--custom-instructions"],
agent_custom_instructions: ["--agent-custom-instructions"],
custom_categories: ["--custom-categories"],
infer: ["--no-infer"],
immutable: ["--immutable"],
+5
View File
@@ -84,6 +84,7 @@ describe("PlatformBackend option-parity payloads (MEM-5893)", () => {
metadata: { source: "test" },
expires: "2099-01-01",
customInstructions: "Extract only preferences.",
agentCustomInstructions: "Extract only tool outcomes.",
customCategories: [{ prefs: "user preferences" }],
structuredDataSchema: { type: "object" },
timestamp: 1700000000,
@@ -91,6 +92,9 @@ describe("PlatformBackend option-parity payloads (MEM-5893)", () => {
const payload = spy.mock.calls[0][2].json;
expect(payload.custom_instructions).toBe("Extract only preferences.");
expect(payload.agent_custom_instructions).toBe(
"Extract only tool outcomes.",
);
expect(payload.custom_categories).toEqual([{ prefs: "user preferences" }]);
expect(payload.structured_data_schema).toEqual({ type: "object" });
expect(payload.timestamp).toBe(1700000000);
@@ -109,6 +113,7 @@ describe("PlatformBackend option-parity payloads (MEM-5893)", () => {
const payload = spy.mock.calls[0][2].json;
expect(payload).not.toHaveProperty("custom_instructions");
expect(payload).not.toHaveProperty("agent_custom_instructions");
expect(payload).not.toHaveProperty("custom_categories");
expect(payload).not.toHaveProperty("structured_data_schema");
expect(payload).not.toHaveProperty("timestamp");
+47
View File
@@ -0,0 +1,47 @@
# Python CLI (`cli/python/`)
The `mem0-cli` package on PyPI. Typer-based, entry point `mem0`.
## Commands
```bash
pip install -e ".[dev]" # dev install: ruff + pytest
ruff check . # lint
ruff format . # format
pytest # test
hatch build # build
```
## Conventions
> **Line length is 100 here, not 120.** The root Python SDK uses 120. Running the root
> `make format` over this directory reformats every file and fails CI. Use the local
> `ruff` invocations above.
- **Python 3.10+.** Not 3.9, unlike the root SDK.
- **Ruff** with an extended rule set: `E`, `F`, `I`, `W`, `UP`, `B`, `SIM`, `RUF`.
Ignores `E501` (formatter handles it), `B008` (required by Typer's argument defaults),
and `SIM108`.
- **Ruff format:** double quotes, space indent, `docstring-code-format = true`.
- **isort** first-party is `mem0_cli` only.
- **pytest** for tests.
- Target version pinned to `py310`.
## Layout
```
cli/python/
├── src/mem0_cli/ package source (src layout)
└── tests/
```
Entry point: `mem0 = "mem0_cli.app:main"`.
## Dependencies
Typer + Rich + httpx. `mem0ai` is **optional**, exposed through the `[oss]` extra for OSS mode. Do not promote it to a required dependency.
## CI and release
- CI: `cli-python-ci.yml`, ruff + pytest + `hatch build` on Python 3.10, 3.11, 3.12.
- Release: tag prefix `cli-v*` dispatches `cli-python-cd.yml`, publishing to PyPI over OIDC.
+1
View File
@@ -0,0 +1 @@
AGENTS.md
+7
View File
@@ -278,6 +278,11 @@ def add(
custom_instructions: str | None = typer.Option(
None, "--custom-instructions", help="Custom instructions for fact extraction."
),
agent_custom_instructions: str | None = typer.Option(
None,
"--agent-custom-instructions",
help="Extraction instructions for agent-scoped memories, overriding the project setting.",
),
custom_categories: str | None = typer.Option(
None,
"--custom-categories",
@@ -327,6 +332,7 @@ def add(
expires=expires,
categories=categories,
custom_instructions=custom_instructions,
agent_custom_instructions=agent_custom_instructions,
custom_categories=custom_categories,
structured_data_schema=structured_data_schema,
timestamp=timestamp,
@@ -1139,6 +1145,7 @@ def _build_help_json() -> dict:
"--expires": "Expiration date (YYYY-MM-DD).",
"--categories": "Not supported on add, use --custom-categories instead.",
"--custom-instructions": "Custom instructions for fact extraction.",
"--agent-custom-instructions": "Extraction instructions for agent-scoped memories, overriding the project setting.",
"--custom-categories": "Custom categories as a JSON array of {name: description} objects.",
"--structured-data-schema": "Schema for structured data extraction, as JSON.",
"--timestamp": "Unix timestamp for the memory.",
+1
View File
@@ -26,6 +26,7 @@ class Backend(ABC):
infer: bool = True,
expires: str | None = None,
custom_instructions: str | None = None,
agent_custom_instructions: str | None = None,
custom_categories: list[dict] | None = None,
structured_data_schema: dict | None = None,
timestamp: int | None = None,
@@ -88,6 +88,7 @@ class PlatformBackend(Backend):
infer: bool = True,
expires: str | None = None,
custom_instructions: str | None = None,
agent_custom_instructions: str | None = None,
custom_categories: list[dict] | None = None,
structured_data_schema: dict | None = None,
timestamp: int | None = None,
@@ -117,6 +118,8 @@ class PlatformBackend(Backend):
payload["expiration_date"] = expires
if custom_instructions:
payload["custom_instructions"] = custom_instructions
if agent_custom_instructions:
payload["agent_custom_instructions"] = agent_custom_instructions
if custom_categories:
payload["custom_categories"] = custom_categories
if structured_data_schema:
@@ -77,6 +77,7 @@ def cmd_add(
expires: str | None,
categories: str | None,
custom_instructions: str | None = None,
agent_custom_instructions: str | None = None,
custom_categories: str | None = None,
structured_data_schema: str | None = None,
timestamp: int | None = None,
@@ -166,6 +167,7 @@ def cmd_add(
infer=not no_infer,
expires=expires,
custom_instructions=custom_instructions,
agent_custom_instructions=agent_custom_instructions,
custom_categories=custom_cats,
structured_data_schema=schema,
timestamp=timestamp,
+1
View File
@@ -38,6 +38,7 @@ ADD_MAPPING: dict[str, list[str]] = {
"metadata": ["metadata"],
"expiration_date": ["expires"],
"custom_instructions": ["custom_instructions"],
"agent_custom_instructions": ["agent_custom_instructions"],
"custom_categories": ["custom_categories"],
"infer": ["no_infer"],
"immutable": ["immutable"],
@@ -22,12 +22,14 @@ class TestAddOptions:
metadata={"source": "test"},
expires="2099-01-01",
custom_instructions="Extract only preferences.",
agent_custom_instructions="Extract only tool outcomes.",
custom_categories=[{"prefs": "user preferences"}],
structured_data_schema={"type": "object"},
timestamp=1700000000,
)
payload = mock_request.call_args.kwargs["json"]
assert payload["custom_instructions"] == "Extract only preferences."
assert payload["agent_custom_instructions"] == "Extract only tool outcomes."
assert payload["custom_categories"] == [{"prefs": "user preferences"}]
assert payload["structured_data_schema"] == {"type": "object"}
assert payload["timestamp"] == 1700000000
@@ -40,6 +42,7 @@ class TestAddOptions:
backend.add(content="hello", user_id="alice")
payload = mock_request.call_args.kwargs["json"]
assert "custom_instructions" not in payload
assert "agent_custom_instructions" not in payload
assert "custom_categories" not in payload
assert "structured_data_schema" not in payload
assert "timestamp" not in payload
+28
View File
@@ -7,6 +7,16 @@ mode: "wide"
<Tabs>
<Tab title="Python">
<Update label="2026-08-11" description="v2.0.18">
**Bug Fixes:**
- **Core:** Percent-escape `%`, `&`, and `=` in `user_id`, `agent_id`, and `run_id` when building the session scope key for the recent-conversation buffer, so the key stays unambiguous for ids containing those characters. Ordinary ids keep their existing key; an id already containing `%`, `&`, or `=` maps to a new key, so its buffer starts empty once and refills on the next `add()`. Stored memories are unaffected ([#6892](https://github.com/mem0ai/mem0/pull/6892))
- **Vector Stores:** Raise `ValueError` when a PGVector `in`/`nin` filter value is not a list. A string value was previously iterated character by character into the generated `= ANY(...)` array (so `{"user_id": {"in": "alice"}}` matched `a`, `l`, `i`, `c`, `e`), and a non-iterable value raised a bare `TypeError` from deep inside filter building ([#6879](https://github.com/mem0ai/mem0/pull/6879))
- **Vector Stores:** Reject `index_accuracy=0` in the Oracle AI Vector Search config. The range check sat behind a truthiness test, so `0` skipped validation entirely and was passed through to `WITH TARGET ACCURACY 0` instead of raising ([#6848](https://github.com/mem0ai/mem0/pull/6848))
- **Vector Stores:** Close the Oracle connection or pool that Mem0 opened when initialization fails. A client version check, a database version check, or a `create_col()` error previously propagated with the connection still open, leaking it for the life of the process. A caller-supplied `client` is left untouched ([#6839](https://github.com/mem0ai/mem0/pull/6839))
</Update>
<Update label="2026-08-05" description="v2.0.17">
**New Features:**
@@ -1196,6 +1206,24 @@ See the [OSS v2 to v3 migration guide](https://docs.mem0.ai/migration/oss-v2-to-
<Tab title="TypeScript">
<Update label="2026-08-11" description="v3.1.6">
**New Features:**
- **Vector Stores:** Add an Oracle AI Vector Search vector store (`oracledb`) to the OSS SDK, with pooled connections, `HNSW`/`IVF` indexes, an optional `indexAccuracy` target, JSON payload filtering, and six selectable distance metrics ([#6690](https://github.com/mem0ai/mem0/pull/6690))
**Bug Fixes:**
- **Core:** Percent-escape `%`, `&`, and `=` in `userId`, `agentId`, and `runId` when building the session scope key for the recent-conversation buffer, so the key stays unambiguous for ids containing those characters. Ordinary ids keep their existing key; an id already containing `%`, `&`, or `=` maps to a new key, so its buffer starts empty once and refills on the next `add()`. Stored memories are unaffected ([#6892](https://github.com/mem0ai/mem0/pull/6892))
- **Vector Stores:** Close and clear the Oracle pool that Mem0 created when `initialize()` fails, and reset the cached init promise so the next call retries instead of replaying the rejection forever. A caller-supplied `client` is left untouched ([#6839](https://github.com/mem0ai/mem0/pull/6839))
- **Vector Stores:** Validate Oracle `insert()` batches before touching the database: `ids` and `payloads` must match `vectors` in length, so a short array can no longer write rows with `undefined` ids or silently drop payloads ([#6839](https://github.com/mem0ai/mem0/pull/6839))
**Improvements:**
- **Vector Stores:** Cut Oracle round trips. `insert()` now sends the whole batch through one `executeMany()` with explicit `bindDefs` instead of one `INSERT` per vector, `list()` reads the total from a `COUNT(*) OVER ()` window in the same statement instead of issuing a second count query, and an unfiltered `search()` adds the `VECTOR_INDEX_TRANSFORM` hint so the vector index is used ([#6835](https://github.com/mem0ai/mem0/pull/6835))
**Security:**
- **Dependencies:** Patched 8 high and 18 medium severity dependency vulnerabilities across the pnpm workspace via `pnpm.overrides` (`undici`, `brace-expansion`, `ip-address`) ([#6847](https://github.com/mem0ai/mem0/pull/6847))
</Update>
<Update label="2026-08-05" description="v3.1.5">
**New Features:**
+1 -1
View File
@@ -97,4 +97,4 @@ Here's a comprehensive list of all parameters that can be used across different
## Supported Embedding Models
For detailed information on configuring specific embedders, please visit the [Embedding Models](./models) section. There you'll find information for each supported embedder with provider-specific usage examples and configuration details.
For detailed information on configuring specific embedders, please visit the [Embedding Models](./overview) section. There you'll find information for each supported embedder with provider-specific usage examples and configuration details.
+1 -1
View File
@@ -133,4 +133,4 @@ Here's a comprehensive list of all parameters that can be used across different
## Supported LLMs
For detailed information on configuring specific LLMs, please visit the [LLMs](./models) section. There you'll find information for each supported LLM with provider-specific usage examples and configuration details.
For detailed information on configuring specific LLMs, please visit the [LLMs](./overview) section. There you'll find information for each supported LLM with provider-specific usage examples and configuration details.
+2 -2
View File
@@ -123,10 +123,10 @@ Here's a comprehensive list of all parameters that can be used across different
Each vector database has its own specific configuration requirements. To customize the config for your chosen vector store:
1. Identify the vector database you want to use from [supported vector databases](./dbs).
1. Identify the vector database you want to use from [supported vector databases](./overview).
2. Refer to the `Config` section in the respective vector database's documentation.
3. Include only the relevant parameters for your chosen database in the `config` dictionary.
## Supported Vector Databases
For detailed information on configuring specific vector databases, please visit the [Supported Vector Databases](./dbs) section. There you'll find individual pages for each supported vector store with provider-specific usage examples and configuration details.
For detailed information on configuring specific vector databases, please visit the [Supported Vector Databases](./overview) section. There you'll find individual pages for each supported vector store with provider-specific usage examples and configuration details.
@@ -3,6 +3,8 @@ title: "Oracle AI Vector Search"
description: "Use Oracle Database AI Vector Search as a vector store in Mem0 for semantic and relational queries."
---
{/* Copyright (c) 2026, Oracle and/or its affiliates. */}
[Oracle AI Vector Search](https://www.oracle.com/database/ai-vector-search/) stores embeddings in an Oracle table using the native `VECTOR` data type, so you can combine semantic search over unstructured data with relational queries over business data in a single database.
### Requirements
+1 -1
View File
@@ -10,7 +10,7 @@ Mem0 includes built-in support for various popular databases. Memory can utilize
See the list of supported vector databases below.
<Note>
The following vector databases are supported in the Python implementation. The TypeScript implementation currently supports Qdrant, Redis, PGVector, Supabase, LangChain, Azure AI Search, Vectorize, Amazon S3 Vectors, Milvus, Neptune Analytics, and an in-memory store.
The following vector databases are supported in the Python implementation. The TypeScript implementation currently supports Qdrant, Redis, PGVector, Supabase, LangChain, Oracle AI Vector Search, Azure AI Search, Vectorize, Amazon S3 Vectors, Milvus, Neptune Analytics, and an in-memory store.
</Note>
<CardGroup cols={3}>
+4
View File
@@ -1035,6 +1035,10 @@
"source": "/features/graph-memory",
"destination": "/platform/features/graph-memory"
},
{
"source": "/open-source/features/graph-memory",
"destination": "/platform/features/graph-memory"
},
{
"source": "/features/:slug",
"destination": "/platform/features/:slug"
@@ -0,0 +1,86 @@
{
"name": "mem0",
"version": "0.1.0",
"description": "Persistent memory for Kimi Code. Remembers decisions, patterns, and preferences across sessions.",
"author": {
"name": "Mem0",
"email": "support@mem0.ai",
"url": "https://mem0.ai"
},
"homepage": "https://mem0.ai",
"repository": "https://github.com/mem0ai/mem0",
"license": "Apache-2.0",
"keywords": ["memory", "personalization", "mcp", "semantic-search"],
"skills": "./skills/",
"sessionStart": {
"skill": "context-loader"
},
"hooks": [
{
"event": "SessionStart",
"matcher": "^(startup|resume)$",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_session_start.sh",
"timeout": 30
},
{
"event": "UserPromptSubmit",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_user_prompt.sh",
"timeout": 12
},
{
"event": "PreToolUse",
"matcher": "^(Write|Edit|MultiEdit)$",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" block_memory_write.sh",
"timeout": 5
},
{
"event": "PreToolUse",
"matcher": "^mcp__.*mem0.*__(add_memory|search_memories|get_memories|delete_all_memories)$",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" enforce_metadata_defaults.sh",
"timeout": 5
},
{
"event": "PreToolUse",
"matcher": "^Read$",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_file_read.sh",
"timeout": 5
},
{
"event": "PostToolUse",
"matcher": "^mcp__.*mem0.*__",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_post_tool_use.sh",
"timeout": 5
},
{
"event": "PostToolUse",
"matcher": "^Bash$",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_bash_output.sh",
"timeout": 12
},
{
"event": "Stop",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_stop.sh",
"timeout": 30
},
{
"event": "PreCompact",
"command": "\"$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh\" on_pre_compact.sh",
"timeout": 30
}
],
"mcpServers": {
"mem0": {
"transport": "http",
"url": "https://mcp.mem0.ai/mcp/",
"bearerTokenEnvVar": "MEM0_API_KEY"
}
},
"interface": {
"displayName": "Mem0",
"shortDescription": "Persistent memory layer for AI coding workflows",
"longDescription": "Mem0 adds long-term memory to Kimi Code. Store decisions, user preferences, project context, and session state across conversations. Memories are automatically retrieved via semantic search so Kimi always has the right context available.",
"developerName": "Mem0",
"websiteURL": "https://mem0.ai",
"logo": "./logo.svg"
}
}
@@ -0,0 +1,51 @@
"""Resolve the project's mem0 extraction policy from ``mem0.md``.
A repo's ``mem0.md`` can carry two prose sections that steer what Mem0 extracts:
## Instructions
Remember architecture decisions and conventions. Ignore debug noise and secrets.
## Agent Instructions
For agent-scoped memories, focus on the tools and task outcomes.
``## Instructions`` maps to Mem0's ``custom_instructions`` (user/project-scoped
extraction) and ``## Agent Instructions`` to ``agent_custom_instructions``
(agent-scoped extraction). Both are passed verbatim on memory writes, so the
policy lives in the repo, travels with it, and is shared by the whole team.
The hook writers call :func:`load_instructions` and merge the result into their
``/v3/memories/add`` body. Returns only the keys that are actually set, so a
project with no policy adds nothing.
"""
from __future__ import annotations
import os
from parse_mem0_config import load_full_config
def load_instructions(cwd: str | None = None) -> dict[str, str]:
"""Return the extraction policy for the project at *cwd* (defaults to the
``MEM0_CWD`` env var, then the process cwd).
Keys (present only when non-empty):
- ``custom_instructions`` from ``## Instructions``
- ``agent_custom_instructions`` from ``## Agent Instructions``
"""
if cwd is None:
cwd = os.environ.get("MEM0_CWD") or os.getcwd()
try:
config = load_full_config(cwd)
except Exception:
return {}
out: dict[str, str] = {}
custom = config.get("instructions")
if isinstance(custom, str) and custom.strip():
out["custom_instructions"] = custom.strip()
agent = config.get("agent_instructions")
if isinstance(agent, str) and agent.strip():
out["agent_custom_instructions"] = agent.strip()
return out
@@ -21,6 +21,7 @@ import urllib.request
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _identity import resolve_api_key, resolve_user_id
from _instructions import load_instructions
from _project import resolve_branch, resolve_project_id
log = logging.getLogger("mem0-auto-capture")
@@ -126,6 +127,8 @@ def store_exchange(api_key: str, messages: list[dict], user_id: str,
"metadata": metadata,
"infer": True,
}
# Apply the project's mem0.md extraction policy (custom/agent instructions).
body.update(load_instructions())
data = json.dumps(body).encode("utf-8")
req = urllib.request.Request(
@@ -26,6 +26,7 @@ from datetime import date, timedelta
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _identity import resolve_api_key, resolve_user_id
from _instructions import load_instructions
from _project import resolve_branch, resolve_project_id
log = logging.getLogger("mem0-compact-summary")
@@ -95,7 +96,7 @@ def find_compact_summary(lines: list[str]) -> str:
return ""
def store_summary(api_key: str, summary: str, user_id: str, session_id: str, project_id: str = "", branch: str = "") -> bool:
def store_summary(api_key: str, summary: str, user_id: str, session_id: str, project_id: str = "", branch: str = "", cwd: str | None = None) -> bool:
expires = (date.today() + timedelta(days=COMPACT_SUMMARY_EXPIRY_DAYS)).isoformat()
metadata = {
"type": "compact_summary",
@@ -115,6 +116,8 @@ def store_summary(api_key: str, summary: str, user_id: str, session_id: str, pro
"infer": True,
"expiration_date": expires,
}
# Apply the project's mem0.md extraction policy (custom/agent instructions).
body.update(load_instructions(cwd))
data = json.dumps(body).encode("utf-8")
req = urllib.request.Request(
@@ -182,7 +185,7 @@ def main():
return
log.info("Capturing compact summary (%d chars)", len(summary))
if store_summary(api_key, summary, user_id, session_id, project_id, branch):
if store_summary(api_key, summary, user_id, session_id, project_id, branch, cwd):
if session_id:
try:
os.makedirs(marker_dir, exist_ok=True)
@@ -24,6 +24,7 @@ from datetime import date, timedelta
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _identity import resolve_api_key, resolve_user_id
from _instructions import load_instructions
from _project import resolve_branch, resolve_project_id
log = logging.getLogger("mem0-session-summary")
@@ -163,6 +164,7 @@ def store_summary(
project_id: str,
branch: str,
files: list[str],
cwd: str | None = None,
) -> bool:
expires = (date.today() + timedelta(days=SUMMARY_EXPIRY_DAYS)).isoformat()
metadata = {
@@ -188,6 +190,8 @@ def store_summary(
"infer": True,
"expiration_date": expires,
}
# Apply the project's mem0.md extraction policy (custom/agent instructions).
body.update(load_instructions(cwd))
data = json.dumps(body).encode("utf-8")
req = urllib.request.Request(
@@ -257,7 +261,7 @@ def main():
summary_prompt = build_summary_prompt(assistant_msg, files)
log.info("Capturing session summary (%d chars, %d files)", len(assistant_msg), len(files))
store_summary(api_key, summary_prompt, user_id, session_id, project_id, branch, files)
store_summary(api_key, summary_prompt, user_id, session_id, project_id, branch, files, cwd)
if __name__ == "__main__":
+120
View File
@@ -0,0 +1,120 @@
#!/usr/bin/env bash
# Kimi Code hook adapter.
#
# Kimi Code's hook contract is close to Claude Code's but differs in four ways
# that the mem0 hook scripts care about. Rather than fork nine scripts, every
# Kimi hook entry in .kimi-plugin/plugin.json routes through this shim.
#
# 1. cwd Kimi runs hook commands with cwd forced to the PLUGIN root
# (agent-core-v2 src/app/plugin/manager.ts -> enabledHooks() sets
# `cwd: record.root`). The real project directory only arrives as
# the payload's `cwd` field. _project.sh resolves MEM0_PROJECT_ID
# from $PWD/`git remote`, so we chdir into the payload cwd first.
#
# 2. stdin Kimi sends snake_case JSON like Claude, but:
# - `prompt` is a ContentPart[] array, not a string
# - PostToolUse sends `tool_output`, not `tool_response`
# - file tools use `tool_input.path`, not `tool_input.file_path`
# - plugin MCP tools are `mcp__plugin-mem0_mem0__*` (hyphen),
# not Claude's `mcp__plugin_mem0_mem0__*`
# - there is NO `transcript_path` (no equivalent exists)
# We normalise the first four into the Claude shape.
#
# 3. stdout Kimi's hook stdout parser (agent-core-v2
# src/agent/externalHooks/runner.ts -> HookJsonOutputSchema) only
# understands top-level `message`, `hookSpecificOutput.message`,
# `hookSpecificOutput.permissionDecision` and
# `hookSpecificOutput.permissionDecisionReason`.
# `additionalContext` and `updatedInput` are NOT recognised.
# Raw (non-JSON) stdout IS appended to context for UserPromptSubmit
# (user-prompt.ts -> userPromptHookMessage falls back to stdout), so
# we unwrap additionalContext into plain text.
#
# 4. exit Same as Claude: 0 = allow, 2 = block (stderr is the reason),
# any other code / timeout = fail-open.
#
# Usage: kimi_hook_shim.sh <script-name.sh> [args...]
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
[ $# -ge 1 ] || exit 0
TARGET_NAME="$1"
shift
TARGET="$SCRIPT_DIR/$TARGET_NAME"
[ -f "$TARGET" ] || exit 0
# Telemetry attribution (telemetry.py::detect_platform honours MEM0_PLATFORM).
export MEM0_PLATFORM="${MEM0_PLATFORM:-kimi}"
RAW=$(cat)
_TMP_BASE="${TMPDIR:-/tmp}"
IN_FILE="$_TMP_BASE/mem0_kimi_in_$$"
OUT_FILE="$_TMP_BASE/mem0_kimi_out_$$"
trap 'rm -f "$IN_FILE" "$OUT_FILE"' EXIT
HAVE_JQ=""
command -v jq >/dev/null 2>&1 && HAVE_JQ="true"
# ---------------------------------------------------------------- stdin shape
NORM=""
if [ -n "$HAVE_JQ" ]; then
NORM=$(printf '%s' "$RAW" | jq -c '
def flat_prompt:
if type == "array" then
[ .[]? | if type == "object" then (.text // "") elif type == "string" then . else "" end ]
| map(select(. != "")) | join("\n")
elif type == "string" then .
else "" end;
. as $in
| (if has("prompt") then .prompt = ($in.prompt | flat_prompt) else . end)
| (if (has("tool_response") | not) and (.tool_output != null)
then .tool_response = .tool_output else . end)
| (if ((.tool_input | type) == "object") and (.tool_input.file_path == null) and (.tool_input.path != null)
then .tool_input.file_path = .tool_input.path else . end)
| (if ((.tool_name | type) == "string") and (.tool_name | startswith("mcp__")) and (.tool_name | test("mem0"))
then .tool_name = (.tool_name | gsub("-"; "_")) else . end)
' 2>/dev/null)
fi
[ -n "$NORM" ] || NORM="$RAW"
printf '%s' "$NORM" >"$IN_FILE" 2>/dev/null || exit 0
# ------------------------------------------------------------------- real cwd
if [ -n "$HAVE_JQ" ]; then
PROJECT_CWD=$(printf '%s' "$NORM" | jq -r '.cwd // ""' 2>/dev/null || printf '')
if [ -n "$PROJECT_CWD" ] && [ -d "$PROJECT_CWD" ]; then
cd "$PROJECT_CWD" 2>/dev/null || true
fi
fi
# ------------------------------------------------------------------- dispatch
# Redirect (not pipe) stdout so backgrounded children inside the hook scripts
# cannot hold the shim open until Kimi's timeout fires.
bash "$TARGET" "$@" <"$IN_FILE" >"$OUT_FILE"
CODE=$?
OUT=$(cat "$OUT_FILE" 2>/dev/null || printf '')
# --------------------------------------------------------------- stdout shape
if [ -n "$OUT" ] && [ -n "$HAVE_JQ" ] && printf '%s' "$OUT" | jq -e 'type == "object"' >/dev/null 2>&1; then
if printf '%s' "$OUT" | jq -e '.hookSpecificOutput.permissionDecision == "deny"' >/dev/null 2>&1; then
# Kimi understands deny natively — pass the envelope straight through.
printf '%s' "$OUT"
else
CTX=$(printf '%s' "$OUT" | jq -r '
(.hookSpecificOutput.additionalContext
// .additionalContext
// .message
// .hookSpecificOutput.message
// "")
| gsub("\\\\n"; "\n")' 2>/dev/null || printf '')
[ -n "$CTX" ] && printf '%s\n' "$CTX"
fi
elif [ -n "$OUT" ]; then
printf '%s' "$OUT"
fi
exit $CODE
@@ -148,6 +148,14 @@ if command -v python3 >/dev/null 2>&1; then
if [ -n "$MEM0_PROJECT_CONFIG" ] && [ "$MEM0_PROJECT_CONFIG" != "{}" ]; then
_CONFIG_KEYS=$(echo "$MEM0_PROJECT_CONFIG" | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d))" 2>/dev/null || echo "?")
echo "mem0.md loaded (${_CONFIG_KEYS} sections configured)."
# Surface the project's memory policy so the model applies it when choosing
# what to store via add_memory (the hook writes also send it as an
# extraction param — see _instructions.py).
_INSTR=$(echo "$MEM0_PROJECT_CONFIG" | python3 -c "import sys,json; print(json.load(sys.stdin).get('instructions',''))" 2>/dev/null || echo "")
if [ -n "$_INSTR" ]; then
echo ""
echo "Project memory policy (from mem0.md): ${_INSTR}"
fi
fi
fi
@@ -132,6 +132,28 @@ def parse_section_list(content: str, heading: str) -> list[str]:
return items
def parse_section_text(content: str, heading: str) -> str:
"""Parse a free-text prose section from mem0.md.
Looks for ``## <heading>`` (case-insensitive) and returns the prose beneath
it (up to the next ``##`` heading) collapsed to a single line. Blank lines and
full-line ``#`` comments are dropped; inline ``#`` is preserved (prose may
reference e.g. issue ``#123``).
"""
pattern = rf"^##\s+{re.escape(heading)}[^\n]*\n(.*?)(?=^##\s|\Z)"
match = re.search(pattern, content, flags=re.MULTILINE | re.DOTALL | re.IGNORECASE)
if not match:
return ""
lines: list[str] = []
for line in match.group(1).splitlines():
stripped = line.strip()
if not stripped or stripped.startswith("#"):
continue
lines.append(stripped)
return " ".join(lines).strip()
def parse_ignore_patterns(content: str) -> list[str]:
"""Parse the ``## Ignore`` section of *content*.
@@ -203,6 +225,16 @@ def load_full_config(cwd: str | None = None) -> dict:
if settings:
config["settings"] = settings
# Extraction policy: `## Instructions` -> custom_instructions (user/project
# scope), `## Agent Instructions` -> agent_custom_instructions (agent scope).
instructions = parse_section_text(content, "Instructions")
if instructions:
config["instructions"] = instructions
agent_instructions = parse_section_text(content, "Agent Instructions")
if agent_instructions:
config["agent_instructions"] = agent_instructions
return config
@@ -34,6 +34,7 @@ _PLATFORM_MANIFESTS = {
"claude-code": ("..", ".claude-plugin", "plugin.json"),
"cursor": ("..", ".cursor-plugin", "plugin.json"),
"codex": ("..", ".codex-plugin", "plugin.json"),
"kimi": ("..", ".kimi-plugin", "plugin.json"),
}
_DEFAULT_MANIFEST = ("..", ".claude-plugin", "plugin.json")
@@ -74,6 +75,8 @@ def detect_platform() -> str:
return explicit
if os.environ.get("ANTIGRAVITY_PLUGIN_ROOT"):
return "antigravity"
if os.environ.get("KIMI_PLUGIN_ROOT"):
return "kimi"
if os.environ.get("PLUGIN_ROOT"):
return "codex"
if os.environ.get("CLAUDECODE") or os.environ.get("CLAUDE_PLUGIN_ROOT"):
@@ -0,0 +1,71 @@
---
name: policy
description: Views or sets the project's memory-extraction policy (what Mem0 remembers vs ignores) stored in mem0.md. Use when the user says set a memory policy, custom instructions, what should mem0 remember, tell mem0 to ignore X, or asks to see/change the current instructions.
---
# Mem0 Policy
The project's memory policy lives in a `## Instructions` section of `mem0.md` at
the repo root. It is version-controlled and shared by the whole team, and it maps
to Mem0's `custom_instructions` (what to extract / ignore). An optional
`## Agent Instructions` section maps to `agent_custom_instructions` (guidance for
agent-scoped memories only).
The policy takes effect on the **next session** (mem0.md is re-parsed on
SessionStart) and is applied automatically on the plugin's memory writes.
## Execution
### Step 1: Determine intent from the argument
`/mem0:policy` is invoked as `/mem0:policy [<subcommand>] <text>`:
| Argument | Action |
|---|---|
| _(none)_ or `show` | Show the current policy |
| `set <text>` or free text | Set/replace the `## Instructions` (custom) policy |
| `agent <text>` | Set/replace the `## Agent Instructions` policy |
| `clear` | Remove both policy sections |
### Step 2: Locate mem0.md
`mem0.md` sits at the repo root (the current working directory). If it does not
exist yet and the user is setting a policy, you will create it.
### Step 3a: Show
Run `python3 "$CLAUDE_PLUGIN_ROOT/scripts/parse_mem0_config.py" --key instructions .`
and `--key agent_instructions .` (or read `mem0.md` directly). Print:
```
Memory policy for this project (mem0.md):
Instructions: <text, or "(none)">
Agent Instructions: <text, or "(none)">
```
If `mem0.md` is absent, say there is no policy yet and offer to set one.
### Step 3b: Set / clear
Edit `mem0.md`, adding or replacing the target section. Keep the instruction a
short prose paragraph (what to remember, what to ignore). Example:
```markdown
## Instructions
Remember architecture decisions, API contracts, and team conventions.
Ignore transient debugging output, stack traces, and anything resembling a secret.
```
- Preserve any other existing sections (`## Retention`, `## Categories`, etc.).
- If the section already exists, replace its body; otherwise append the section.
- For `clear`, delete the `## Instructions` and `## Agent Instructions` sections.
### Step 4: Confirm
```
Updated memory policy in mem0.md.
Takes effect next session. Commit mem0.md to share it with your team.
```
Remind the user that `## Agent Instructions` only affects agent-scoped memories,
so it is a no-op unless memories are written with an `agent_id`.
@@ -0,0 +1,126 @@
"""Tests for the mem0.md extraction-policy feature.
Covers the parser (`parse_section_text` + the Instructions sections in
`load_full_config`) and the `_instructions.load_instructions` helper that the
hook writers use to attach `custom_instructions` / `agent_custom_instructions`
to a memory write.
"""
from __future__ import annotations
MEM0_MD = """\
# mem0.md
## Categories
- architecture_decisions
## Instructions
Remember architecture decisions and conventions.
Ignore transient debug output and secrets (issue #123 refs are fine).
## Agent Instructions
For agent memories, focus on tools and task outcomes.
"""
# ---------------------------------------------------------------------------
# parse_section_text
# ---------------------------------------------------------------------------
def test_parse_section_text_collapses_prose():
from parse_mem0_config import parse_section_text
text = parse_section_text(MEM0_MD, "Instructions")
assert text == (
"Remember architecture decisions and conventions. "
"Ignore transient debug output and secrets (issue #123 refs are fine)."
)
def test_parse_section_text_preserves_inline_hash():
"""Inline '#' (e.g. issue refs) is kept; only full-line comments are dropped."""
from parse_mem0_config import parse_section_text
assert "#123" in parse_section_text(MEM0_MD, "Instructions")
def test_instructions_and_agent_instructions_are_distinct():
"""'## Instructions' must not swallow '## Agent Instructions'."""
from parse_mem0_config import parse_section_text
assert parse_section_text(MEM0_MD, "Instructions").startswith("Remember architecture")
assert parse_section_text(MEM0_MD, "Agent Instructions") == (
"For agent memories, focus on tools and task outcomes."
)
def test_parse_section_text_missing_returns_empty():
from parse_mem0_config import parse_section_text
assert parse_section_text("## Retention\nx: 1d\n", "Instructions") == ""
def test_load_full_config_includes_instructions(tmp_path):
from parse_mem0_config import load_full_config
(tmp_path / "mem0.md").write_text(MEM0_MD)
config = load_full_config(str(tmp_path))
assert config["instructions"].startswith("Remember architecture")
assert config["agent_instructions"].startswith("For agent memories")
# ---------------------------------------------------------------------------
# load_instructions (the helper the hook writers call)
# ---------------------------------------------------------------------------
def test_load_instructions_maps_to_api_field_names(tmp_path):
from _instructions import load_instructions
(tmp_path / "mem0.md").write_text(MEM0_MD)
out = load_instructions(str(tmp_path))
assert out == {
"custom_instructions": (
"Remember architecture decisions and conventions. "
"Ignore transient debug output and secrets (issue #123 refs are fine)."
),
"agent_custom_instructions": "For agent memories, focus on tools and task outcomes.",
}
def test_load_instructions_no_config_is_empty(tmp_path):
"""No mem0.md -> empty dict, so a write body gains nothing."""
from _instructions import load_instructions
assert load_instructions(str(tmp_path)) == {}
def test_load_instructions_only_custom(tmp_path):
"""A project with only '## Instructions' omits the agent key entirely."""
from _instructions import load_instructions
(tmp_path / "mem0.md").write_text("## Instructions\nRemember decisions.\n")
out = load_instructions(str(tmp_path))
assert out == {"custom_instructions": "Remember decisions."}
def test_load_instructions_defaults_cwd_to_env(tmp_path, monkeypatch):
"""With no arg, cwd falls back to MEM0_CWD."""
from _instructions import load_instructions
(tmp_path / "mem0.md").write_text("## Instructions\nRemember decisions.\n")
monkeypatch.setenv("MEM0_CWD", str(tmp_path))
assert load_instructions() == {"custom_instructions": "Remember decisions."}
def test_load_instructions_body_merge_shape(tmp_path):
"""The result merges cleanly into an add body without clobbering other keys."""
from _instructions import load_instructions
(tmp_path / "mem0.md").write_text("## Instructions\nRemember decisions.\n")
body = {"messages": [], "user_id": "u", "infer": True}
body.update(load_instructions(str(tmp_path)))
assert body["user_id"] == "u" and body["infer"] is True
assert body["custom_instructions"] == "Remember decisions."
assert "agent_custom_instructions" not in body
@@ -0,0 +1,80 @@
"""Validate the Kimi Code plugin manifests and hook wiring.
Kimi Code loads a plugin from `.kimi-plugin/plugin.json`. This test locks down
the structural contract so a stray edit cannot silently break the plugin:
- both manifests parse and carry the required Kimi fields
- the MCP server uses Kimi's supported auth (transport/url/bearerTokenEnvVar)
- every hook command routes through kimi_hook_shim.sh and targets a script
that actually exists in scripts/
- the sessionStart skill and skills/ path resolve on disk
"""
import json
import os
PLUGIN_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
REPO_ROOT = os.path.dirname(os.path.dirname(PLUGIN_DIR))
SUBDIR_MANIFEST = os.path.join(PLUGIN_DIR, ".kimi-plugin", "plugin.json")
ROOT_MARKETPLACE = os.path.join(REPO_ROOT, ".kimi-plugin", "marketplace.json")
SHIM = os.path.join(PLUGIN_DIR, "scripts", "kimi_hook_shim.sh")
def _load(path):
with open(path) as fh:
return json.load(fh)
def test_manifest_parses_and_has_required_fields():
m = _load(SUBDIR_MANIFEST)
assert m["name"] == "mem0"
for field in ("version", "description", "skills", "mcpServers", "interface", "hooks"):
assert field in m, f"manifest missing {field}"
def test_mcp_uses_kimi_supported_auth():
srv = _load(SUBDIR_MANIFEST)["mcpServers"]["mem0"]
assert srv["transport"] == "http"
assert srv["url"] == "https://mcp.mem0.ai/mcp/" # trailing slash avoids the 307 redirect
# Kimi reads the named env var and sends Authorization: Bearer <value>.
assert srv["bearerTokenEnvVar"] == "MEM0_API_KEY"
assert "headers" not in srv # Kimi does not interpolate ${env:...} inside headers
def test_sessionstart_skill_and_skills_dir_resolve():
m = _load(SUBDIR_MANIFEST)
assert m["skills"] == "./skills/"
assert os.path.isdir(os.path.join(PLUGIN_DIR, "skills"))
start_skill = m["sessionStart"]["skill"]
assert os.path.isdir(os.path.join(PLUGIN_DIR, "skills", start_skill))
def test_shim_exists_and_is_executable():
assert os.path.isfile(SHIM)
assert os.access(SHIM, os.X_OK), "kimi_hook_shim.sh must be executable"
def test_every_hook_routes_through_shim_to_a_real_script():
hooks = _load(SUBDIR_MANIFEST)["hooks"]
assert hooks, "no hooks declared"
valid_events = {
"SessionStart", "UserPromptSubmit", "PreToolUse",
"PostToolUse", "Stop", "PreCompact",
}
for hook in hooks:
assert hook["event"] in valid_events, f"unknown event {hook['event']}"
cmd = hook["command"]
assert "kimi_hook_shim.sh" in cmd, f"hook must route through the shim: {cmd}"
assert "$KIMI_PLUGIN_ROOT/scripts/kimi_hook_shim.sh" in cmd
target = cmd.rsplit('"', 1)[-1].strip() # the script name after the shim
assert target.endswith(".sh")
assert os.path.isfile(os.path.join(PLUGIN_DIR, "scripts", target)), \
f"hook target script missing: {target}"
def test_root_marketplace_catalog():
cat = _load(ROOT_MARKETPLACE)
entry = cat["plugins"][0]
assert entry["id"] == "mem0" # Kimi marketplace entries key on id
assert entry["source"].startswith("https://github.com/mem0ai/mem0")
@@ -157,6 +157,22 @@ def test_platform_codex(monkeypatch):
assert telemetry.detect_platform() == "codex"
def test_platform_kimi(monkeypatch):
"""Kimi Code usage must be attributed to its own platform so it can be
counted distinctly. The shim also pins MEM0_PLATFORM=kimi; this covers the
KIMI_PLUGIN_ROOT auto-detection fallback."""
import telemetry
monkeypatch.delenv("MEM0_PLATFORM", raising=False)
monkeypatch.delenv("ANTIGRAVITY_PLUGIN_ROOT", raising=False)
monkeypatch.delenv("CLAUDECODE", raising=False)
monkeypatch.delenv("CLAUDE_PLUGIN_ROOT", raising=False)
monkeypatch.delenv("CURSOR_PLUGIN_ROOT", raising=False)
monkeypatch.delenv("PLUGIN_ROOT", raising=False)
monkeypatch.setenv("KIMI_PLUGIN_ROOT", "/path")
assert telemetry.detect_platform() == "kimi"
def test_platform_explicit_override(monkeypatch):
"""MEM0_PLATFORM wins over auto-detection so each editor can label
itself reliably even when host env vars are ambiguous or absent."""
@@ -190,6 +206,7 @@ def test_plugin_version_is_per_editor(monkeypatch):
"claude-code": os.path.join(".claude-plugin", "plugin.json"),
"cursor": os.path.join(".cursor-plugin", "plugin.json"),
"codex": os.path.join(".codex-plugin", "plugin.json"),
"kimi": os.path.join(".kimi-plugin", "plugin.json"),
}
for plat, rel in manifests.items():
monkeypatch.setenv("MEM0_PLATFORM", plat)
@@ -11,7 +11,7 @@ export class Mem0Api implements ICredentialType {
displayName = 'Mem0 API';
icon: Icon = { light: 'file:mem0-light.svg', dark: 'file:mem0.svg' };
icon: Icon = { light: 'file:mem0.svg', dark: 'file:mem0.svg' };
documentationUrl = 'https://docs.mem0.ai/platform/quickstart';
@@ -1,19 +0,0 @@
<svg width="307" height="307" viewBox="0 0 307 307" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M162.496 25.3505C165.003 25.3505 167.453 24.6071 169.538 23.2144C171.622 21.8216 173.247 19.8419 174.206 17.5258C175.165 15.2097 175.416 12.6612 174.927 10.2024C174.438 7.74365 173.231 5.48516 171.458 3.71249C169.686 1.93983 167.427 0.73263 164.968 0.243552C162.51 -0.245525 159.961 0.00550576 157.645 0.964866C155.329 1.92423 153.349 3.54885 151.956 5.63328C150.564 7.71772 149.82 10.1683 149.82 12.6753C149.818 14.3404 150.145 15.9895 150.781 17.5283C151.417 19.0671 152.351 20.4653 153.528 21.6427C154.706 22.8201 156.104 23.7537 157.643 24.39C159.181 25.0262 160.83 25.3526 162.496 25.3505Z" fill="#8F74E0"/>
<path d="M69.3342 56.559C71.1066 54.7862 72.3135 52.5277 72.8024 50.069C73.2913 47.6103 73.0401 45.0619 72.0807 42.7459C71.1213 40.43 69.4967 38.4505 67.4123 37.0579C65.3279 35.6652 62.8774 34.9219 60.3706 34.9219C57.8637 34.9219 55.4132 35.6652 53.3288 37.0579C51.2444 38.4505 49.6198 40.43 48.6604 42.7459C47.701 45.0619 47.4498 47.6103 47.9387 50.069C48.4276 52.5277 49.6345 54.7862 51.4069 56.559C52.5839 57.7363 53.9813 58.6701 55.5193 59.3073C57.0573 59.9444 58.7058 60.2724 60.3706 60.2724C62.0353 60.2724 63.6838 59.9444 65.2218 59.3073C66.7598 58.6701 68.1572 57.7363 69.3342 56.559Z" fill="#8F74E0"/>
<path d="M25.3505 144.504C25.3505 141.997 24.6071 139.547 23.2143 137.462C21.8216 135.378 19.842 133.753 17.5259 132.794C15.2098 131.835 12.6612 131.584 10.2024 132.073C7.74368 132.562 5.48513 133.769 3.71247 135.542C1.9398 137.314 0.732655 139.573 0.243578 142.032C-0.2455 144.49 0.00543354 147.039 0.964793 149.355C1.92415 151.671 3.54877 153.651 5.63321 155.044C7.71764 156.436 10.1683 157.18 12.6752 157.18C16.0369 157.18 19.261 155.844 21.638 153.467C24.0151 151.09 25.3505 147.866 25.3505 144.504Z" fill="#8F74E0"/>
<path d="M56.5589 237.749C54.7862 235.976 52.5277 234.769 50.069 234.28C47.6103 233.792 45.0619 234.043 42.7459 235.002C40.43 235.962 38.4505 237.586 37.0579 239.671C35.6652 241.755 34.9219 244.206 34.9219 246.712C34.9219 249.219 35.6652 251.67 37.0579 253.754C38.4505 255.838 40.43 257.463 42.7459 258.423C45.0619 259.382 47.6103 259.633 50.069 259.144C52.5277 258.655 54.7862 257.448 56.5589 255.676C57.7362 254.499 58.6701 253.102 59.3073 251.564C59.9444 250.026 60.2724 248.377 60.2724 246.712C60.2724 245.048 59.9444 243.399 59.3073 241.861C58.6701 240.323 57.7362 238.926 56.5589 237.749Z" fill="#8F74E0"/>
<path d="M144.488 281.648C141.981 281.648 139.53 282.392 137.446 283.785C135.361 285.177 133.737 287.157 132.777 289.473C131.818 291.789 131.567 294.338 132.056 296.797C132.545 299.255 133.752 301.514 135.525 303.286C137.298 305.059 139.556 306.266 142.015 306.755C144.474 307.244 147.022 306.993 149.338 306.034C151.655 305.075 153.634 303.45 155.027 301.366C156.42 299.281 157.163 296.831 157.163 294.324C157.159 290.963 155.822 287.742 153.446 285.366C151.07 282.989 147.848 281.653 144.488 281.648Z" fill="#8F74E0"/>
<path d="M237.751 250.487C235.978 252.26 234.771 254.518 234.282 256.977C233.794 259.435 234.045 261.984 235.004 264.3C235.964 266.616 237.588 268.595 239.673 269.988C241.757 271.381 244.207 272.124 246.714 272.124C249.221 272.124 251.672 271.381 253.756 269.988C255.84 268.595 257.465 266.616 258.424 264.3C259.384 261.984 259.635 259.435 259.146 256.977C258.657 254.518 257.45 252.26 255.678 250.487C254.501 249.31 253.104 248.376 251.566 247.739C250.028 247.101 248.379 246.773 246.714 246.773C245.05 246.773 243.401 247.101 241.863 247.739C240.325 248.376 238.928 249.31 237.751 250.487Z" fill="#8F74E0"/>
<path d="M281.648 162.512C281.648 165.019 282.392 167.469 283.785 169.554C285.177 171.638 287.157 173.263 289.473 174.222C291.789 175.181 294.338 175.432 296.797 174.943C299.255 174.454 301.514 173.247 303.286 171.474C305.059 169.702 306.266 167.443 306.755 164.984C307.244 162.526 306.993 159.977 306.034 157.661C305.075 155.345 303.45 153.365 301.366 151.973C299.281 150.58 296.831 149.836 294.324 149.836C290.962 149.836 287.738 151.172 285.361 153.549C282.984 155.926 281.648 159.15 281.648 162.512Z" fill="#8F74E0"/>
<path d="M250.471 69.3303C252.244 71.1027 254.503 72.3097 256.961 72.7985C259.42 73.2874 261.968 73.0363 264.284 72.0768C266.6 71.1174 268.58 69.4928 269.972 67.4084C271.365 65.324 272.108 62.8735 272.108 60.3667C272.108 57.8599 271.365 55.4093 269.972 53.3249C268.58 51.2406 266.6 49.616 264.284 48.6565C261.968 47.6971 259.42 47.4459 256.961 47.9348C254.503 48.4236 252.244 49.6306 250.471 51.403C249.294 52.58 248.36 53.9775 247.723 55.5155C247.086 57.0535 246.758 58.7019 246.758 60.3667C246.758 62.0314 247.086 63.6799 247.723 65.2179C248.36 66.7559 249.294 68.1533 250.471 69.3303Z" fill="#8F74E0"/>
<path d="M184.782 60.8054C180.168 63.4713 178.3 69.0427 177.63 74.3267C177.047 78.9358 175.033 83.2457 171.87 86.6488C168.707 90.052 164.556 92.3766 160.002 93.2951C155.448 94.2136 150.721 93.6796 146.487 91.7683C142.252 89.857 138.724 86.6649 136.401 82.642C134.077 78.6192 133.075 73.9684 133.535 69.3455C133.995 64.7226 135.895 60.3607 138.966 56.8748C142.037 53.389 146.125 50.9549 150.653 49.9159C155.181 48.8768 159.921 49.2852 164.204 51.0834C169.121 53.1428 174.884 54.2762 179.514 51.6422C184.143 49.0082 185.995 43.4049 186.665 38.1208C187.245 33.5107 189.257 29.1987 192.418 25.7931C195.579 22.3876 199.73 20.0603 204.284 19.1394C208.838 18.2185 213.567 18.7505 217.803 20.6605C222.039 22.5704 225.568 25.7618 227.893 29.7846C230.218 33.8075 231.222 38.4587 230.763 43.0824C230.303 47.7062 228.404 52.0691 225.333 55.5559C222.262 59.0426 218.173 61.4773 213.645 62.5165C209.116 63.5557 204.375 63.147 200.091 61.3481C195.174 59.3048 189.411 58.1554 184.782 60.8054Z" fill="#8F74E0"/>
<path d="M110.073 65.8178C108.7 70.9742 111.318 76.2422 114.575 80.4567C117.417 84.1261 119.036 88.595 119.204 93.2335C119.372 97.872 118.08 102.446 115.51 106.311C112.941 110.177 109.223 113.138 104.881 114.778C100.538 116.419 95.7912 116.655 91.3077 115.454C86.8242 114.253 82.8306 111.675 79.8898 108.084C76.9489 104.493 75.2091 100.07 74.9155 95.4379C74.6219 90.8057 75.7894 86.1981 78.2533 82.2645C80.7173 78.331 84.3534 75.2698 88.6494 73.5124C93.5822 71.485 98.4991 68.2444 99.8241 63.0881C101.149 57.9317 98.579 52.6637 95.3224 48.4493C92.4827 44.7781 90.8665 40.3083 90.7018 35.6699C90.537 31.0315 91.8319 26.4583 94.4039 22.5949C96.976 18.7314 100.695 15.7724 105.038 14.1349C109.381 12.4974 114.128 12.2639 118.611 13.4673C123.094 14.6708 127.085 17.2505 130.024 20.8429C132.963 24.4354 134.7 28.8594 134.991 33.4916C135.283 38.1237 134.113 42.7305 131.647 46.6627C129.182 50.5948 125.544 53.6541 121.248 55.4095C116.363 57.4209 111.462 60.6775 110.073 65.8178Z" fill="#8F74E0"/>
<path d="M60.7892 122.218C63.4552 126.831 69.0425 128.699 74.3265 129.37C78.9361 129.955 83.2455 131.973 86.6471 135.138C90.0487 138.304 92.3707 142.457 93.2857 147.013C94.2006 151.569 93.6625 156.296 91.747 160.53C89.8314 164.763 86.6353 168.288 82.6093 170.608C78.5833 172.928 73.9305 173.926 69.3073 173.46C64.6841 172.995 60.3236 171.09 56.841 168.014C53.3583 164.938 50.9292 160.846 49.8962 156.316C48.8631 151.785 49.2783 147.045 51.0832 142.763C53.1426 137.846 54.2759 132.083 51.6419 127.454C49.0079 122.824 43.4046 120.973 38.1047 120.302C33.4951 119.717 29.1856 117.699 25.7841 114.533C22.3825 111.368 20.0604 107.214 19.1454 102.659C18.2304 98.1032 18.7687 93.3752 20.6842 89.1418C22.5997 84.9084 25.7959 81.3832 29.8219 79.0632C33.8479 76.7433 38.5006 75.7457 43.1238 76.2113C47.7471 76.6768 52.1075 78.582 55.5902 81.658C59.0728 84.7341 61.502 88.8258 62.535 93.3561C63.568 97.8865 63.1528 102.627 61.3479 106.908C59.2886 111.825 58.1552 117.588 60.7892 122.218Z" fill="#8F74E0"/>
<path d="M65.8204 196.93C70.9767 198.303 76.2287 195.685 80.4592 192.428C84.1286 189.586 88.5975 187.967 93.236 187.799C97.8745 187.631 102.449 188.923 106.314 191.493C110.179 194.062 113.141 197.78 114.781 202.122C116.421 206.464 116.657 211.212 115.457 215.695C114.256 220.179 111.678 224.172 108.087 227.113C104.496 230.054 100.073 231.794 95.4404 232.087C90.8082 232.381 86.2006 231.214 82.2671 228.75C78.3335 226.286 75.2723 222.649 73.5149 218.353C71.4875 213.421 68.231 208.504 63.0906 207.179C57.9503 205.854 52.6662 208.424 48.4518 211.681C44.7804 214.528 40.308 216.151 35.6652 216.32C31.0224 216.49 26.4435 215.199 22.5738 212.628C18.7042 210.057 15.7391 206.336 14.0968 201.99C12.4544 197.644 12.2176 192.892 13.4197 188.404C14.6218 183.917 17.2021 179.919 20.7969 176.976C24.3917 174.033 28.8195 172.293 33.4562 172C38.0929 171.708 42.7045 172.878 46.6407 175.345C50.577 177.813 53.6394 181.454 55.3961 185.755C57.4235 190.656 60.6641 195.541 65.8204 196.93Z" fill="#8F74E0"/>
<path d="M122.205 246.21C126.818 243.544 128.686 237.956 129.373 232.672C129.96 228.068 131.978 223.763 135.142 220.366C138.306 216.969 142.456 214.651 147.008 213.738C151.559 212.825 156.283 213.364 160.512 215.278C164.741 217.192 168.263 220.385 170.58 224.408C172.898 228.43 173.895 233.078 173.43 237.697C172.966 242.316 171.064 246.673 167.991 250.153C164.919 253.633 160.832 256.061 156.306 257.095C151.781 258.129 147.045 257.717 142.766 255.916C137.833 253.856 132.07 252.723 127.457 255.357C122.843 257.991 120.96 263.594 120.289 268.894C119.7 273.498 117.681 277.8 114.517 281.196C111.353 284.591 107.204 286.908 102.653 287.821C98.1027 288.733 93.3808 288.194 89.1525 286.281C84.9243 284.367 81.4031 281.175 79.085 277.154C76.767 273.134 75.7689 268.487 76.2316 263.869C76.6942 259.251 78.5942 254.895 81.6638 251.414C84.7334 247.933 88.8179 245.503 93.3417 244.466C97.8655 243.429 102.601 243.838 106.88 245.635C111.828 247.694 117.591 248.876 122.205 246.21Z" fill="#8F74E0"/>
<path d="M196.915 241.18C198.304 236.024 195.686 230.756 192.414 226.542C189.567 222.87 187.944 218.398 187.774 213.755C187.604 209.112 188.896 204.533 191.467 200.664C194.038 196.794 197.759 193.829 202.104 192.187C206.45 190.544 211.202 190.307 215.69 191.509C220.178 192.712 224.175 195.292 227.118 198.887C230.061 202.481 231.802 206.909 232.094 211.546C232.387 216.183 231.217 220.794 228.749 224.731C226.281 228.667 222.64 231.729 218.339 233.486C213.406 235.513 208.505 238.77 207.164 243.91C205.823 249.051 208.393 254.335 211.666 258.549C214.513 262.22 216.136 266.693 216.306 271.335C216.476 275.978 215.184 280.557 212.613 284.427C210.042 288.297 206.321 291.262 201.975 292.904C197.629 294.546 192.877 294.783 188.39 293.581C183.902 292.379 179.905 289.799 176.962 286.204C174.019 282.609 172.278 278.181 171.985 273.545C171.693 268.908 172.863 264.296 175.331 260.36C177.799 256.424 181.44 253.361 185.741 251.605C190.658 249.577 195.543 246.337 196.915 241.18Z" fill="#8F74E0"/>
<path d="M246.195 184.797C243.529 180.184 237.957 178.316 232.673 177.629C228.069 177.045 223.764 175.03 220.365 171.869C216.967 168.708 214.646 164.56 213.729 160.01C212.813 155.46 213.348 150.737 215.258 146.507C217.168 142.277 220.357 138.753 224.376 136.431C228.395 134.11 233.041 133.108 237.66 133.567C242.279 134.026 246.637 135.923 250.12 138.991C253.604 142.058 256.037 146.141 257.077 150.664C258.117 155.188 257.711 159.923 255.917 164.204C253.857 169.137 252.724 174.9 255.342 179.513C257.96 184.127 263.595 186.01 268.879 186.681C273.484 187.267 277.789 189.283 281.186 192.446C284.584 195.608 286.904 199.757 287.819 204.308C288.733 208.859 288.197 213.582 286.285 217.811C284.372 222.041 281.181 225.564 277.16 227.884C273.14 230.203 268.492 231.203 263.874 230.741C259.255 230.279 254.897 228.379 251.416 225.31C247.934 222.24 245.503 218.155 244.466 213.63C243.429 209.106 243.838 204.37 245.636 200.09C247.695 195.173 248.861 189.411 246.195 184.797Z" fill="#8F74E0"/>
<path d="M241.18 110.07C236.024 108.697 230.756 111.315 226.542 114.588C222.87 117.435 218.398 119.058 213.755 119.228C209.112 119.398 204.533 118.106 200.664 115.535C196.794 112.964 193.829 109.243 192.187 104.897C190.544 100.551 190.307 95.7994 191.509 91.3117C192.712 86.824 195.292 82.8268 198.887 79.8837C202.481 76.9405 206.909 75.2 211.546 74.9073C216.183 74.6147 220.794 75.7849 224.731 78.2527C228.667 80.7206 231.729 84.3617 233.486 88.6627C235.513 93.5955 238.754 98.4964 243.91 99.8374C249.066 101.178 254.335 98.6082 258.549 95.3356C262.22 92.4959 266.69 90.8798 271.328 90.7151C275.967 90.5503 280.54 91.8452 284.403 94.4172C288.267 96.9892 291.226 100.709 292.863 105.052C294.501 109.394 294.734 114.142 293.531 118.624C292.327 123.107 289.748 127.099 286.155 130.037C282.563 132.976 278.139 134.714 273.507 135.005C268.875 135.296 264.268 134.126 260.336 131.661C256.403 129.195 253.344 125.557 251.589 121.261C249.577 116.36 246.321 111.459 241.18 110.07Z" fill="#8F74E0"/>
<path d="M153.491 191.533C174.501 191.533 191.533 174.501 191.533 153.491C191.533 132.482 174.501 115.45 153.491 115.45C132.481 115.45 115.449 132.482 115.449 153.491C115.449 174.501 132.481 191.533 153.491 191.533Z" fill="#8F74E0"/>
</svg>

Before

Width:  |  Height:  |  Size: 13 KiB

@@ -21,7 +21,7 @@ export class Mem0 implements INodeType {
description: INodeTypeDescription = {
displayName: 'Mem0',
name: 'mem0',
icon: { light: 'file:mem0-light.svg', dark: 'file:mem0.svg' },
icon: { light: 'file:mem0.svg', dark: 'file:mem0.svg' },
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
@@ -1,19 +0,0 @@
<svg width="307" height="307" viewBox="0 0 307 307" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M162.496 25.3505C165.003 25.3505 167.453 24.6071 169.538 23.2144C171.622 21.8216 173.247 19.8419 174.206 17.5258C175.165 15.2097 175.416 12.6612 174.927 10.2024C174.438 7.74365 173.231 5.48516 171.458 3.71249C169.686 1.93983 167.427 0.73263 164.968 0.243552C162.51 -0.245525 159.961 0.00550576 157.645 0.964866C155.329 1.92423 153.349 3.54885 151.956 5.63328C150.564 7.71772 149.82 10.1683 149.82 12.6753C149.818 14.3404 150.145 15.9895 150.781 17.5283C151.417 19.0671 152.351 20.4653 153.528 21.6427C154.706 22.8201 156.104 23.7537 157.643 24.39C159.181 25.0262 160.83 25.3526 162.496 25.3505Z" fill="#8F74E0"/>
<path d="M69.3342 56.559C71.1066 54.7862 72.3135 52.5277 72.8024 50.069C73.2913 47.6103 73.0401 45.0619 72.0807 42.7459C71.1213 40.43 69.4967 38.4505 67.4123 37.0579C65.3279 35.6652 62.8774 34.9219 60.3706 34.9219C57.8637 34.9219 55.4132 35.6652 53.3288 37.0579C51.2444 38.4505 49.6198 40.43 48.6604 42.7459C47.701 45.0619 47.4498 47.6103 47.9387 50.069C48.4276 52.5277 49.6345 54.7862 51.4069 56.559C52.5839 57.7363 53.9813 58.6701 55.5193 59.3073C57.0573 59.9444 58.7058 60.2724 60.3706 60.2724C62.0353 60.2724 63.6838 59.9444 65.2218 59.3073C66.7598 58.6701 68.1572 57.7363 69.3342 56.559Z" fill="#8F74E0"/>
<path d="M25.3505 144.504C25.3505 141.997 24.6071 139.547 23.2143 137.462C21.8216 135.378 19.842 133.753 17.5259 132.794C15.2098 131.835 12.6612 131.584 10.2024 132.073C7.74368 132.562 5.48513 133.769 3.71247 135.542C1.9398 137.314 0.732655 139.573 0.243578 142.032C-0.2455 144.49 0.00543354 147.039 0.964793 149.355C1.92415 151.671 3.54877 153.651 5.63321 155.044C7.71764 156.436 10.1683 157.18 12.6752 157.18C16.0369 157.18 19.261 155.844 21.638 153.467C24.0151 151.09 25.3505 147.866 25.3505 144.504Z" fill="#8F74E0"/>
<path d="M56.5589 237.749C54.7862 235.976 52.5277 234.769 50.069 234.28C47.6103 233.792 45.0619 234.043 42.7459 235.002C40.43 235.962 38.4505 237.586 37.0579 239.671C35.6652 241.755 34.9219 244.206 34.9219 246.712C34.9219 249.219 35.6652 251.67 37.0579 253.754C38.4505 255.838 40.43 257.463 42.7459 258.423C45.0619 259.382 47.6103 259.633 50.069 259.144C52.5277 258.655 54.7862 257.448 56.5589 255.676C57.7362 254.499 58.6701 253.102 59.3073 251.564C59.9444 250.026 60.2724 248.377 60.2724 246.712C60.2724 245.048 59.9444 243.399 59.3073 241.861C58.6701 240.323 57.7362 238.926 56.5589 237.749Z" fill="#8F74E0"/>
<path d="M144.488 281.648C141.981 281.648 139.53 282.392 137.446 283.785C135.361 285.177 133.737 287.157 132.777 289.473C131.818 291.789 131.567 294.338 132.056 296.797C132.545 299.255 133.752 301.514 135.525 303.286C137.298 305.059 139.556 306.266 142.015 306.755C144.474 307.244 147.022 306.993 149.338 306.034C151.655 305.075 153.634 303.45 155.027 301.366C156.42 299.281 157.163 296.831 157.163 294.324C157.159 290.963 155.822 287.742 153.446 285.366C151.07 282.989 147.848 281.653 144.488 281.648Z" fill="#8F74E0"/>
<path d="M237.751 250.487C235.978 252.26 234.771 254.518 234.282 256.977C233.794 259.435 234.045 261.984 235.004 264.3C235.964 266.616 237.588 268.595 239.673 269.988C241.757 271.381 244.207 272.124 246.714 272.124C249.221 272.124 251.672 271.381 253.756 269.988C255.84 268.595 257.465 266.616 258.424 264.3C259.384 261.984 259.635 259.435 259.146 256.977C258.657 254.518 257.45 252.26 255.678 250.487C254.501 249.31 253.104 248.376 251.566 247.739C250.028 247.101 248.379 246.773 246.714 246.773C245.05 246.773 243.401 247.101 241.863 247.739C240.325 248.376 238.928 249.31 237.751 250.487Z" fill="#8F74E0"/>
<path d="M281.648 162.512C281.648 165.019 282.392 167.469 283.785 169.554C285.177 171.638 287.157 173.263 289.473 174.222C291.789 175.181 294.338 175.432 296.797 174.943C299.255 174.454 301.514 173.247 303.286 171.474C305.059 169.702 306.266 167.443 306.755 164.984C307.244 162.526 306.993 159.977 306.034 157.661C305.075 155.345 303.45 153.365 301.366 151.973C299.281 150.58 296.831 149.836 294.324 149.836C290.962 149.836 287.738 151.172 285.361 153.549C282.984 155.926 281.648 159.15 281.648 162.512Z" fill="#8F74E0"/>
<path d="M250.471 69.3303C252.244 71.1027 254.503 72.3097 256.961 72.7985C259.42 73.2874 261.968 73.0363 264.284 72.0768C266.6 71.1174 268.58 69.4928 269.972 67.4084C271.365 65.324 272.108 62.8735 272.108 60.3667C272.108 57.8599 271.365 55.4093 269.972 53.3249C268.58 51.2406 266.6 49.616 264.284 48.6565C261.968 47.6971 259.42 47.4459 256.961 47.9348C254.503 48.4236 252.244 49.6306 250.471 51.403C249.294 52.58 248.36 53.9775 247.723 55.5155C247.086 57.0535 246.758 58.7019 246.758 60.3667C246.758 62.0314 247.086 63.6799 247.723 65.2179C248.36 66.7559 249.294 68.1533 250.471 69.3303Z" fill="#8F74E0"/>
<path d="M184.782 60.8054C180.168 63.4713 178.3 69.0427 177.63 74.3267C177.047 78.9358 175.033 83.2457 171.87 86.6488C168.707 90.052 164.556 92.3766 160.002 93.2951C155.448 94.2136 150.721 93.6796 146.487 91.7683C142.252 89.857 138.724 86.6649 136.401 82.642C134.077 78.6192 133.075 73.9684 133.535 69.3455C133.995 64.7226 135.895 60.3607 138.966 56.8748C142.037 53.389 146.125 50.9549 150.653 49.9159C155.181 48.8768 159.921 49.2852 164.204 51.0834C169.121 53.1428 174.884 54.2762 179.514 51.6422C184.143 49.0082 185.995 43.4049 186.665 38.1208C187.245 33.5107 189.257 29.1987 192.418 25.7931C195.579 22.3876 199.73 20.0603 204.284 19.1394C208.838 18.2185 213.567 18.7505 217.803 20.6605C222.039 22.5704 225.568 25.7618 227.893 29.7846C230.218 33.8075 231.222 38.4587 230.763 43.0824C230.303 47.7062 228.404 52.0691 225.333 55.5559C222.262 59.0426 218.173 61.4773 213.645 62.5165C209.116 63.5557 204.375 63.147 200.091 61.3481C195.174 59.3048 189.411 58.1554 184.782 60.8054Z" fill="#8F74E0"/>
<path d="M110.073 65.8178C108.7 70.9742 111.318 76.2422 114.575 80.4567C117.417 84.1261 119.036 88.595 119.204 93.2335C119.372 97.872 118.08 102.446 115.51 106.311C112.941 110.177 109.223 113.138 104.881 114.778C100.538 116.419 95.7912 116.655 91.3077 115.454C86.8242 114.253 82.8306 111.675 79.8898 108.084C76.9489 104.493 75.2091 100.07 74.9155 95.4379C74.6219 90.8057 75.7894 86.1981 78.2533 82.2645C80.7173 78.331 84.3534 75.2698 88.6494 73.5124C93.5822 71.485 98.4991 68.2444 99.8241 63.0881C101.149 57.9317 98.579 52.6637 95.3224 48.4493C92.4827 44.7781 90.8665 40.3083 90.7018 35.6699C90.537 31.0315 91.8319 26.4583 94.4039 22.5949C96.976 18.7314 100.695 15.7724 105.038 14.1349C109.381 12.4974 114.128 12.2639 118.611 13.4673C123.094 14.6708 127.085 17.2505 130.024 20.8429C132.963 24.4354 134.7 28.8594 134.991 33.4916C135.283 38.1237 134.113 42.7305 131.647 46.6627C129.182 50.5948 125.544 53.6541 121.248 55.4095C116.363 57.4209 111.462 60.6775 110.073 65.8178Z" fill="#8F74E0"/>
<path d="M60.7892 122.218C63.4552 126.831 69.0425 128.699 74.3265 129.37C78.9361 129.955 83.2455 131.973 86.6471 135.138C90.0487 138.304 92.3707 142.457 93.2857 147.013C94.2006 151.569 93.6625 156.296 91.747 160.53C89.8314 164.763 86.6353 168.288 82.6093 170.608C78.5833 172.928 73.9305 173.926 69.3073 173.46C64.6841 172.995 60.3236 171.09 56.841 168.014C53.3583 164.938 50.9292 160.846 49.8962 156.316C48.8631 151.785 49.2783 147.045 51.0832 142.763C53.1426 137.846 54.2759 132.083 51.6419 127.454C49.0079 122.824 43.4046 120.973 38.1047 120.302C33.4951 119.717 29.1856 117.699 25.7841 114.533C22.3825 111.368 20.0604 107.214 19.1454 102.659C18.2304 98.1032 18.7687 93.3752 20.6842 89.1418C22.5997 84.9084 25.7959 81.3832 29.8219 79.0632C33.8479 76.7433 38.5006 75.7457 43.1238 76.2113C47.7471 76.6768 52.1075 78.582 55.5902 81.658C59.0728 84.7341 61.502 88.8258 62.535 93.3561C63.568 97.8865 63.1528 102.627 61.3479 106.908C59.2886 111.825 58.1552 117.588 60.7892 122.218Z" fill="#8F74E0"/>
<path d="M65.8204 196.93C70.9767 198.303 76.2287 195.685 80.4592 192.428C84.1286 189.586 88.5975 187.967 93.236 187.799C97.8745 187.631 102.449 188.923 106.314 191.493C110.179 194.062 113.141 197.78 114.781 202.122C116.421 206.464 116.657 211.212 115.457 215.695C114.256 220.179 111.678 224.172 108.087 227.113C104.496 230.054 100.073 231.794 95.4404 232.087C90.8082 232.381 86.2006 231.214 82.2671 228.75C78.3335 226.286 75.2723 222.649 73.5149 218.353C71.4875 213.421 68.231 208.504 63.0906 207.179C57.9503 205.854 52.6662 208.424 48.4518 211.681C44.7804 214.528 40.308 216.151 35.6652 216.32C31.0224 216.49 26.4435 215.199 22.5738 212.628C18.7042 210.057 15.7391 206.336 14.0968 201.99C12.4544 197.644 12.2176 192.892 13.4197 188.404C14.6218 183.917 17.2021 179.919 20.7969 176.976C24.3917 174.033 28.8195 172.293 33.4562 172C38.0929 171.708 42.7045 172.878 46.6407 175.345C50.577 177.813 53.6394 181.454 55.3961 185.755C57.4235 190.656 60.6641 195.541 65.8204 196.93Z" fill="#8F74E0"/>
<path d="M122.205 246.21C126.818 243.544 128.686 237.956 129.373 232.672C129.96 228.068 131.978 223.763 135.142 220.366C138.306 216.969 142.456 214.651 147.008 213.738C151.559 212.825 156.283 213.364 160.512 215.278C164.741 217.192 168.263 220.385 170.58 224.408C172.898 228.43 173.895 233.078 173.43 237.697C172.966 242.316 171.064 246.673 167.991 250.153C164.919 253.633 160.832 256.061 156.306 257.095C151.781 258.129 147.045 257.717 142.766 255.916C137.833 253.856 132.07 252.723 127.457 255.357C122.843 257.991 120.96 263.594 120.289 268.894C119.7 273.498 117.681 277.8 114.517 281.196C111.353 284.591 107.204 286.908 102.653 287.821C98.1027 288.733 93.3808 288.194 89.1525 286.281C84.9243 284.367 81.4031 281.175 79.085 277.154C76.767 273.134 75.7689 268.487 76.2316 263.869C76.6942 259.251 78.5942 254.895 81.6638 251.414C84.7334 247.933 88.8179 245.503 93.3417 244.466C97.8655 243.429 102.601 243.838 106.88 245.635C111.828 247.694 117.591 248.876 122.205 246.21Z" fill="#8F74E0"/>
<path d="M196.915 241.18C198.304 236.024 195.686 230.756 192.414 226.542C189.567 222.87 187.944 218.398 187.774 213.755C187.604 209.112 188.896 204.533 191.467 200.664C194.038 196.794 197.759 193.829 202.104 192.187C206.45 190.544 211.202 190.307 215.69 191.509C220.178 192.712 224.175 195.292 227.118 198.887C230.061 202.481 231.802 206.909 232.094 211.546C232.387 216.183 231.217 220.794 228.749 224.731C226.281 228.667 222.64 231.729 218.339 233.486C213.406 235.513 208.505 238.77 207.164 243.91C205.823 249.051 208.393 254.335 211.666 258.549C214.513 262.22 216.136 266.693 216.306 271.335C216.476 275.978 215.184 280.557 212.613 284.427C210.042 288.297 206.321 291.262 201.975 292.904C197.629 294.546 192.877 294.783 188.39 293.581C183.902 292.379 179.905 289.799 176.962 286.204C174.019 282.609 172.278 278.181 171.985 273.545C171.693 268.908 172.863 264.296 175.331 260.36C177.799 256.424 181.44 253.361 185.741 251.605C190.658 249.577 195.543 246.337 196.915 241.18Z" fill="#8F74E0"/>
<path d="M246.195 184.797C243.529 180.184 237.957 178.316 232.673 177.629C228.069 177.045 223.764 175.03 220.365 171.869C216.967 168.708 214.646 164.56 213.729 160.01C212.813 155.46 213.348 150.737 215.258 146.507C217.168 142.277 220.357 138.753 224.376 136.431C228.395 134.11 233.041 133.108 237.66 133.567C242.279 134.026 246.637 135.923 250.12 138.991C253.604 142.058 256.037 146.141 257.077 150.664C258.117 155.188 257.711 159.923 255.917 164.204C253.857 169.137 252.724 174.9 255.342 179.513C257.96 184.127 263.595 186.01 268.879 186.681C273.484 187.267 277.789 189.283 281.186 192.446C284.584 195.608 286.904 199.757 287.819 204.308C288.733 208.859 288.197 213.582 286.285 217.811C284.372 222.041 281.181 225.564 277.16 227.884C273.14 230.203 268.492 231.203 263.874 230.741C259.255 230.279 254.897 228.379 251.416 225.31C247.934 222.24 245.503 218.155 244.466 213.63C243.429 209.106 243.838 204.37 245.636 200.09C247.695 195.173 248.861 189.411 246.195 184.797Z" fill="#8F74E0"/>
<path d="M241.18 110.07C236.024 108.697 230.756 111.315 226.542 114.588C222.87 117.435 218.398 119.058 213.755 119.228C209.112 119.398 204.533 118.106 200.664 115.535C196.794 112.964 193.829 109.243 192.187 104.897C190.544 100.551 190.307 95.7994 191.509 91.3117C192.712 86.824 195.292 82.8268 198.887 79.8837C202.481 76.9405 206.909 75.2 211.546 74.9073C216.183 74.6147 220.794 75.7849 224.731 78.2527C228.667 80.7206 231.729 84.3617 233.486 88.6627C235.513 93.5955 238.754 98.4964 243.91 99.8374C249.066 101.178 254.335 98.6082 258.549 95.3356C262.22 92.4959 266.69 90.8798 271.328 90.7151C275.967 90.5503 280.54 91.8452 284.403 94.4172C288.267 96.9892 291.226 100.709 292.863 105.052C294.501 109.394 294.734 114.142 293.531 118.624C292.327 123.107 289.748 127.099 286.155 130.037C282.563 132.976 278.139 134.714 273.507 135.005C268.875 135.296 264.268 134.126 260.336 131.661C256.403 129.195 253.344 125.557 251.589 121.261C249.577 116.36 246.321 111.459 241.18 110.07Z" fill="#8F74E0"/>
<path d="M153.491 191.533C174.501 191.533 191.533 174.501 191.533 153.491C191.533 132.482 174.501 115.45 153.491 115.45C132.481 115.45 115.449 132.482 115.449 153.491C115.449 174.501 132.481 191.533 153.491 191.533Z" fill="#8F74E0"/>
</svg>

Before

Width:  |  Height:  |  Size: 13 KiB

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@mem0/n8n-nodes-mem0",
"version": "0.1.4",
"version": "0.1.3",
"description": "n8n community node for Mem0 — the memory layer for AI agents. Add, search, get, update, and delete long-term memories.",
"keywords": [
"n8n-community-node-package",
+1 -1
View File
@@ -72,7 +72,7 @@
"@qdrant/js-client-rest": "^1.18.0",
"uuid@<11.1.1": ">=11.1.1",
"esbuild": ">=0.28.1",
"undici@<6.27.0": ">=6.27.0 <8.0.0",
"undici@<7.29.0": ">=7.29.0 <8.0.0",
"axios@<1.18.0": ">=1.18.0 <2.0.0",
"postcss@<8.5.18": ">=8.5.18 <9.0.0",
"mongoose@>=9.0.0 <9.7.2": ">=9.7.2 <10.0.0"
+5 -5
View File
@@ -13,7 +13,7 @@ overrides:
'@qdrant/js-client-rest': ^1.18.0
uuid@<11.1.1: '>=11.1.1'
esbuild: '>=0.28.1'
undici@<6.27.0: '>=6.27.0 <8.0.0'
undici@<7.29.0: '>=7.29.0 <8.0.0'
axios@<1.18.0: '>=1.18.0 <2.0.0'
postcss@<8.5.18: '>=8.5.18 <9.0.0'
mongoose@>=9.0.0 <9.7.2: '>=9.7.2 <10.0.0'
@@ -2036,8 +2036,8 @@ packages:
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
undici@7.28.0:
resolution: {integrity: sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==}
undici@7.29.0:
resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==}
engines: {node: '>=20.18.1'}
util-deprecate@1.0.2:
@@ -2547,7 +2547,7 @@ snapshots:
dependencies:
'@qdrant/openapi-typescript-fetch': 1.2.6
typescript: 5.9.3
undici: 7.28.0
undici: 7.29.0
'@qdrant/openapi-typescript-fetch@1.2.6': {}
@@ -4121,7 +4121,7 @@ snapshots:
undici-types@6.21.0: {}
undici@7.28.0: {}
undici@7.29.0: {}
util-deprecate@1.0.2: {}
+1 -1
View File
@@ -21,7 +21,7 @@ overrides:
"@qdrant/js-client-rest": "^1.18.0"
"uuid@<11.1.1": ">=11.1.1"
"esbuild": ">=0.28.1"
"undici@<6.27.0": ">=6.27.0 <8.0.0"
"undici@<7.29.0": ">=7.29.0 <8.0.0"
"axios@<1.18.0": ">=1.18.0 <2.0.0"
"postcss@<8.5.18": ">=8.5.18 <9.0.0"
"mongoose@>=9.0.0 <9.7.2": ">=9.7.2 <10.0.0"
+2 -2
View File
@@ -73,8 +73,8 @@
"form-data@<4.0.6": ">=4.0.6",
"uuid@<11.1.1": ">=11.1.1",
"esbuild": ">=0.28.1",
"undici@<6.27.0": ">=6.27.0 <8.0.0",
"undici@>=8.0.0 <8.5.0": ">=8.5.0",
"undici@<7.29.0": ">=7.29.0 <8.0.0",
"undici@>=8.0.0 <8.9.0": ">=8.9.0 <9.0.0",
"axios@<1.18.0": ">=1.18.0 <2.0.0",
"brace-expansion@>=3.0.0 <5.0.8": ">=5.0.8 <6.0.0",
"postcss@<8.5.18": ">=8.5.18 <9.0.0",
+10 -10
View File
@@ -8,8 +8,8 @@ overrides:
form-data@<4.0.6: '>=4.0.6'
uuid@<11.1.1: '>=11.1.1'
esbuild: '>=0.28.1'
undici@<6.27.0: '>=6.27.0 <8.0.0'
undici@>=8.0.0 <8.5.0: '>=8.5.0'
undici@<7.29.0: '>=7.29.0 <8.0.0'
undici@>=8.0.0 <8.9.0: '>=8.9.0 <9.0.0'
axios@<1.18.0: '>=1.18.0 <2.0.0'
brace-expansion@>=3.0.0 <5.0.8: '>=5.0.8 <6.0.0'
postcss@<8.5.18: '>=8.5.18 <9.0.0'
@@ -2354,12 +2354,12 @@ packages:
undici-types@7.24.6:
resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==}
undici@7.28.0:
resolution: {integrity: sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==}
undici@7.29.0:
resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==}
engines: {node: '>=20.18.1'}
undici@8.5.0:
resolution: {integrity: sha512-xamtWoB1EshgjpmlXd7GGm2VfdDtw1+rD8uhry8pSNW3If6S8E0m2T2+orSKeZXEn/aPJMviCpDBA65WJt8zhg==}
undici@8.10.0:
resolution: {integrity: sha512-HvltHd7avK13QIw/oLe4qoOLyoVSoafqJ2jYOrtMRBkbYT31eiBQ8O0ehRKZiEZCMEyLFQNIADpgCWC5fALvYQ==}
engines: {node: '>=22.19.0'}
util-deprecate@1.0.2:
@@ -2942,7 +2942,7 @@ snapshots:
minimatch: 10.2.5
proper-lockfile: 4.1.2
typebox: 1.1.38
undici: 8.5.0
undici: 8.10.0
yaml: 2.9.0
optionalDependencies:
'@mariozechner/clipboard': 0.3.9
@@ -3203,7 +3203,7 @@ snapshots:
dependencies:
'@qdrant/openapi-typescript-fetch': 1.2.6
typescript: 6.0.3
undici: 7.28.0
undici: 7.29.0
'@qdrant/openapi-typescript-fetch@1.2.6': {}
@@ -4895,9 +4895,9 @@ snapshots:
undici-types@7.24.6: {}
undici@7.28.0: {}
undici@7.29.0: {}
undici@8.5.0: {}
undici@8.10.0: {}
util-deprecate@1.0.2: {}
@@ -5,8 +5,8 @@ overrides:
"form-data@<4.0.6": ">=4.0.6"
"uuid@<11.1.1": ">=11.1.1"
"esbuild": ">=0.28.1"
"undici@<6.27.0": ">=6.27.0 <8.0.0"
"undici@>=8.0.0 <8.5.0": ">=8.5.0"
"undici@<7.29.0": ">=7.29.0 <8.0.0"
"undici@>=8.0.0 <8.9.0": ">=8.9.0 <9.0.0"
"axios@<1.18.0": ">=1.18.0 <2.0.0"
"brace-expansion@>=3.0.0 <5.0.8": ">=5.0.8 <6.0.0"
"postcss@<8.5.18": ">=8.5.18 <9.0.0"
+13 -5
View File
@@ -41,10 +41,17 @@
],
"jest": {
"testEnvironment": "node",
"testMatch": ["**/test/**/*.test.ts"],
"setupFiles": ["<rootDir>/test/setup.ts"],
"testMatch": [
"**/test/**/*.test.ts"
],
"setupFiles": [
"<rootDir>/test/setup.ts"
],
"transform": {
"^.+\\.tsx?$": ["ts-jest", {}]
"^.+\\.tsx?$": [
"ts-jest",
{}
]
}
},
"dependencies": {
@@ -62,8 +69,9 @@
"form-data@<4.0.6": ">=4.0.6",
"uuid@<11.1.1": ">=11.1.1",
"esbuild": ">=0.28.1",
"undici@<6.27.0": ">=6.27.0 <8.0.0",
"undici@>=8.0.0 <8.5.0": ">=8.5.0"
"undici@<7.29.0": ">=7.29.0 <8.0.0",
"undici@>=8.0.0 <8.9.0": ">=8.9.0 <9.0.0",
"brace-expansion@<1.1.16": ">=1.1.16 <2.0.0"
}
}
}
+8 -6
View File
@@ -8,8 +8,9 @@ overrides:
form-data@<4.0.6: '>=4.0.6'
uuid@<11.1.1: '>=11.1.1'
esbuild: '>=0.28.1'
undici@<6.27.0: '>=6.27.0 <8.0.0'
undici@>=8.0.0 <8.5.0: '>=8.5.0'
undici@<7.29.0: '>=7.29.0 <8.0.0'
undici@>=8.0.0 <8.9.0: '>=8.9.0 <9.0.0'
brace-expansion@<1.1.16: '>=1.1.16 <2.0.0'
importers:
@@ -413,8 +414,8 @@ packages:
engines: {node: '>=6.0.0'}
hasBin: true
brace-expansion@1.1.15:
resolution: {integrity: sha512-EwOCDEex4quD37XhqM3omwtMoJjr//isUZz1JopUNWms+4Z2ViyM/k1YIRePpoVNnQhENnxtFjLaxNHrT7xIUg==}
brace-expansion@1.1.18:
resolution: {integrity: sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==}
braces@3.0.3:
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
@@ -530,6 +531,7 @@ packages:
crypto-js@4.2.0:
resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
deprecated: Active development of CryptoJS has been discontinued. This library is no longer maintained.
debug@4.4.3:
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
@@ -1995,7 +1997,7 @@ snapshots:
baseline-browser-mapping@2.10.41: {}
brace-expansion@1.1.15:
brace-expansion@1.1.18:
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
@@ -2792,7 +2794,7 @@ snapshots:
minimatch@3.1.5:
dependencies:
brace-expansion: 1.1.15
brace-expansion: 1.1.18
minimist@1.2.8: {}
+3 -2
View File
@@ -5,5 +5,6 @@ overrides:
"form-data@<4.0.6": ">=4.0.6"
"uuid@<11.1.1": ">=11.1.1"
"esbuild": ">=0.28.1"
"undici@<6.27.0": ">=6.27.0 <8.0.0"
"undici@>=8.0.0 <8.5.0": ">=8.5.0"
"undici@<7.29.0": ">=7.29.0 <8.0.0"
"undici@>=8.0.0 <8.9.0": ">=8.9.0 <9.0.0"
"brace-expansion@<1.1.16": ">=1.1.16 <2.0.0"
+5 -4
View File
@@ -1,6 +1,6 @@
{
"name": "mem0ai",
"version": "3.1.5",
"version": "3.1.6",
"description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
@@ -292,18 +292,19 @@
"glob@>=10.2.0 <10.5.0": "^10.5.0",
"@modelcontextprotocol/sdk": "^1.25.4",
"esbuild": ">=0.28.1",
"undici@<6.27.0": ">=6.27.0 <8.0.0",
"undici@<7.29.0": ">=7.29.0 <8.0.0",
"@aws-sdk/client-bedrock-runtime": "3.967.0",
"@aws-sdk/client-neptune-graph": "3.966.0",
"axios@<1.18.0": ">=1.18.0 <2.0.0",
"brace-expansion@<1.1.16": ">=1.1.16 <2.0.0",
"brace-expansion@>=2.0.0 <2.1.2": ">=2.1.2 <3.0.0",
"brace-expansion@>=2.0.0 <2.1.4": ">=2.1.4 <3.0.0",
"brace-expansion@>=3.0.0 <5.0.8": ">=5.0.8 <6.0.0",
"fast-xml-parser@>=5.0.0 <5.10.1": ">=5.10.1 <6.0.0",
"tar@>=7.0.0 <7.5.21": ">=7.5.21 <8.0.0",
"thrift@<0.23.0": "^0.23.0",
"mongoose@>=9.0.0 <9.7.2": ">=9.7.2 <10.0.0",
"protobufjs@<7.6.5": ">=7.6.5 <8.0.0"
"protobufjs@<7.6.5": ">=7.6.5 <8.0.0",
"ip-address@<10.3.1": ">=10.3.1 <11.0.0"
}
}
}
+17 -16
View File
@@ -25,18 +25,19 @@ overrides:
glob@>=10.2.0 <10.5.0: ^10.5.0
'@modelcontextprotocol/sdk': ^1.25.4
esbuild: '>=0.28.1'
undici@<6.27.0: '>=6.27.0 <8.0.0'
undici@<7.29.0: '>=7.29.0 <8.0.0'
'@aws-sdk/client-bedrock-runtime': 3.967.0
'@aws-sdk/client-neptune-graph': 3.966.0
axios@<1.18.0: '>=1.18.0 <2.0.0'
brace-expansion@<1.1.16: '>=1.1.16 <2.0.0'
brace-expansion@>=2.0.0 <2.1.2: '>=2.1.2 <3.0.0'
brace-expansion@>=2.0.0 <2.1.4: '>=2.1.4 <3.0.0'
brace-expansion@>=3.0.0 <5.0.8: '>=5.0.8 <6.0.0'
fast-xml-parser@>=5.0.0 <5.10.1: '>=5.10.1 <6.0.0'
tar@>=7.0.0 <7.5.21: '>=7.5.21 <8.0.0'
thrift@<0.23.0: ^0.23.0
mongoose@>=9.0.0 <9.7.2: '>=9.7.2 <10.0.0'
protobufjs@<7.6.5: '>=7.6.5 <8.0.0'
ip-address@<10.3.1: '>=10.3.1 <11.0.0'
importers:
@@ -2165,8 +2166,8 @@ packages:
brace-expansion@1.1.16:
resolution: {integrity: sha512-IDw48K2/2kRkg9LdJxurvq3lV3aBgq0REY89duEqFRthjlPdXHKMj7EnQOXVckxzgisinf3nHfrcE2FufFLXMw==}
brace-expansion@2.1.2:
resolution: {integrity: sha512-w5JZcKgdhDOgOwm8H+KgbosopHMuGcl6qbulwjtz3SM7I7P3yW1eAjzMPLrIE+NQ9vjgANKHWeMHnrT0OXW1oA==}
brace-expansion@2.1.4:
resolution: {integrity: sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==}
brace-expansion@5.0.8:
resolution: {integrity: sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==}
@@ -3027,8 +3028,8 @@ packages:
resolution: {integrity: sha512-4rTJX6Q5wTYEvxboXi8DsEiUo+OvqJGtLYOSGm37KpdRXsG5XJjbVtYKGJpPSWP+QT7rWscA4vsrdmzbEbenpw==}
engines: {node: '>=18.12.0'}
ip-address@10.2.0:
resolution: {integrity: sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==}
ip-address@10.4.0:
resolution: {integrity: sha512-oSK96Grm3aP6OrS263xVxbNDGVL7rzBtYdpGqlDG8iQdoenDoTs/nkki+DflYbAEE8Xl6o5YxhxlrKvI3nqKXQ==}
engines: {node: '>= 12'}
is-arrayish@0.2.1:
@@ -4626,8 +4627,8 @@ packages:
undici-types@7.24.6:
resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==}
undici@7.28.0:
resolution: {integrity: sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==}
undici@7.29.0:
resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==}
engines: {node: '>=20.18.1'}
update-browserslist-db@1.2.3:
@@ -6155,7 +6156,7 @@ snapshots:
ms: 2.1.3
secure-json-parse: 4.1.0
tslib: 2.8.1
undici: 7.28.0
undici: 7.29.0
transitivePeerDependencies:
- supports-color
@@ -6711,7 +6712,7 @@ snapshots:
dependencies:
'@qdrant/openapi-typescript-fetch': 1.2.6
typescript: 5.5.4
undici: 7.28.0
undici: 7.29.0
'@qdrant/openapi-typescript-fetch@1.2.6': {}
@@ -7183,7 +7184,7 @@ snapshots:
'@turbopuffer/turbopuffer@2.5.0':
dependencies:
pako: 2.2.0
undici: 7.28.0
undici: 7.29.0
'@types/babel__core@7.20.5':
dependencies:
@@ -7542,7 +7543,7 @@ snapshots:
balanced-match: 1.0.2
concat-map: 0.0.1
brace-expansion@2.1.2:
brace-expansion@2.1.4:
dependencies:
balanced-match: 1.0.2
@@ -8448,7 +8449,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
ip-address@10.2.0: {}
ip-address@10.4.0: {}
is-arrayish@0.2.1: {}
@@ -9076,7 +9077,7 @@ snapshots:
minimatch@9.0.9:
dependencies:
brace-expansion: 2.1.2
brace-expansion: 2.1.4
minimist@1.2.8: {}
@@ -9886,7 +9887,7 @@ snapshots:
socks@2.8.9:
dependencies:
ip-address: 10.2.0
ip-address: 10.4.0
smart-buffer: 4.2.0
source-map-support@0.5.13:
@@ -10232,7 +10233,7 @@ snapshots:
undici-types@7.24.6: {}
undici@7.28.0: {}
undici@7.29.0: {}
update-browserslist-db@1.2.3(browserslist@4.28.2):
dependencies:
+3 -2
View File
@@ -25,13 +25,14 @@ overrides:
"glob@>=10.2.0 <10.5.0": "^10.5.0"
"@modelcontextprotocol/sdk": "^1.25.4"
"esbuild": ">=0.28.1"
"undici@<6.27.0": ">=6.27.0 <8.0.0"
"undici@<7.29.0": ">=7.29.0 <8.0.0"
"axios@<1.18.0": ">=1.18.0 <2.0.0"
"brace-expansion@<1.1.16": ">=1.1.16 <2.0.0"
"brace-expansion@>=2.0.0 <2.1.2": ">=2.1.2 <3.0.0"
"brace-expansion@>=2.0.0 <2.1.4": ">=2.1.4 <3.0.0"
"brace-expansion@>=3.0.0 <5.0.8": ">=5.0.8 <6.0.0"
"fast-xml-parser@>=5.0.0 <5.10.1": ">=5.10.1 <6.0.0"
"tar@>=7.0.0 <7.5.21": ">=7.5.21 <8.0.0"
"thrift@<0.23.0": "^0.23.0"
"mongoose@>=9.0.0 <9.7.2": ">=9.7.2 <10.0.0"
"protobufjs@<7.6.5": ">=7.6.5 <8.0.0"
"ip-address@<10.3.1": ">=10.3.1 <11.0.0"
+8 -1
View File
@@ -556,11 +556,18 @@ export class Memory {
}
}
private escapeScopeValue(val: unknown): string {
return String(val)
.replace(/%/g, "%25")
.replace(/&/g, "%26")
.replace(/=/g, "%3D");
}
private buildSessionScope(filters: SearchFilters): string {
const parts: string[] = [];
for (const key of ["agent_id", "run_id", "user_id"].sort()) {
const val = (filters as any)[key];
if (val) parts.push(`${key}=${val}`);
if (val) parts.push(`${key}=${this.escapeScopeValue(val)}`);
}
return parts.join("&");
}
+42 -19
View File
@@ -1,4 +1,4 @@
import type { Connection, Pool } from "oracledb";
import type { BindParameters, Connection, Pool } from "oracledb";
import { v4 as uuidv4 } from "uuid";
import { VectorStore } from "./base";
import { SearchFilters, VectorStoreConfig, VectorStoreResult } from "../types";
@@ -401,7 +401,15 @@ export class OracleAIVectorSearch implements VectorStore {
async initialize(): Promise<void> {
if (!this._initPromise) {
this._initPromise = this._doInitialize();
this._initPromise = this._doInitialize().catch(async (error) => {
if (this.ownsClient && this.client) {
await Promise.resolve(this.client.close()).catch(() => {});
this.client = undefined;
this.ownsClient = false;
}
this._initPromise = undefined;
throw error;
});
}
return this._initPromise;
}
@@ -565,19 +573,33 @@ export class OracleAIVectorSearch implements VectorStore {
ids: string[],
payloads: Record<string, any>[],
): Promise<void> {
if (ids.length !== vectors.length) {
throw new Error("ids and vectors must have the same length");
}
if (payloads.length !== vectors.length) {
throw new Error("payloads and vectors must have the same length");
}
if (vectors.length === 0) return;
await this.initialize();
await this.withConnection(async (connection) => {
for (let i = 0; i < vectors.length; i++) {
await connection.execute(
`INSERT INTO ${this.collectionName} (id, vector, payload) VALUES (:id, :vector, :payload)`,
{
id: ids[i],
vector: this.vectorBind(vectors[i]),
payload: this.payloadBind(payloads[i] ?? {}),
await connection.executeMany(
`INSERT INTO ${this.collectionName} (id, vector, payload) VALUES (:id, :vector, :payload)`,
vectors.map((vector, i) => ({
id: ids[i],
vector: new Float32Array(vector),
payload: payloads[i] ?? {},
})) as BindParameters[],
{
bindDefs: {
id: { type: this.oracledb.DB_TYPE_VARCHAR, maxSize: 36 },
vector: { type: this.oracledb.DB_TYPE_VECTOR },
payload: { type: this.oracledb.DB_TYPE_JSON },
},
);
}
},
);
}, true);
}
@@ -589,8 +611,12 @@ export class OracleAIVectorSearch implements VectorStore {
await this.initialize();
const [whereClause, filterBinds] = buildWhereClause(filters);
const hasFilter = whereClause.length > 0;
const selectClause = hasFilter
? "SELECT"
: `SELECT /*+ VECTOR_INDEX_TRANSFORM(${this.collectionName}) */`;
const sql =
`SELECT id, payload, VECTOR_DISTANCE(vector, :query_vec, ${this.distanceMetric}) distance ` +
`${selectClause} id, payload, VECTOR_DISTANCE(vector, :query_vec, ${this.distanceMetric}) distance ` +
`FROM ${this.collectionName} ${whereClause} ORDER BY distance FETCH APPROX FIRST :max_rows ROWS ONLY`;
const rows = await this.withConnection(async (connection) => {
@@ -687,20 +713,17 @@ export class OracleAIVectorSearch implements VectorStore {
return this.withConnection(async (connection) => {
const listResult = await connection.execute<any[]>(
`SELECT id, payload FROM ${this.collectionName} ${whereClause} FETCH FIRST :max_rows ROWS ONLY`,
`SELECT id, payload, COUNT(*) OVER () total FROM ${this.collectionName} ${whereClause} FETCH FIRST :max_rows ROWS ONLY`,
{ ...filterBinds, max_rows: topK },
);
const countResult = await connection.execute<any[]>(
`SELECT COUNT(*) FROM ${this.collectionName} ${whereClause}`,
filterBinds,
);
const results = (listResult.rows ?? []).map((row) => ({
const rows = listResult.rows ?? [];
const results = rows.map((row) => ({
id: row[0],
payload: this.loadPayload(row[1]),
}));
return [results, Number(countResult.rows?.[0]?.[0] ?? 0)];
return [results, Number(rows[0]?.[2] ?? 0)];
});
}
+162 -15
View File
@@ -2,10 +2,21 @@
/** Oracle AI Vector Search filter, config and SQL tests. The driver is mocked, so no database is needed. */
const DB_TYPE_VECTOR = { name: "DB_TYPE_VECTOR" };
const DB_TYPE_JSON = { name: "DB_TYPE_JSON" };
const DB_TYPE_VARCHAR = { name: "DB_TYPE_VARCHAR" };
jest.mock("oracledb", () => ({ thin: true, DB_TYPE_VECTOR, DB_TYPE_JSON }), {
virtual: true,
});
const mockCreatePool = jest.fn();
jest.mock(
"oracledb",
() => ({
thin: true,
DB_TYPE_VECTOR,
DB_TYPE_JSON,
DB_TYPE_VARCHAR,
createPool: mockCreatePool,
}),
{ virtual: true },
);
import {
OracleAIVectorSearch,
@@ -13,7 +24,7 @@ import {
quoteIdentifier,
} from "../src/vector_stores/oracledb";
type Call = { sql: string; binds: any };
type Call = { sql: string; binds: any; options?: any };
function fakeConnection(calls: Call[], resultsBySql: Array<any[][]>) {
let selectIndex = 0;
@@ -26,6 +37,10 @@ function fakeConnection(calls: Call[], resultsBySql: Array<any[][]>) {
}
return { rows: [] };
},
async executeMany(sql: string, binds: any[], options: any = {}) {
calls.push({ sql: sql.replace(/\s+/g, " ").trim(), binds, options });
return { rows: [] };
},
async commit() {},
async rollback() {},
async close() {},
@@ -249,13 +264,56 @@ describe("OracleAIVectorSearch SQL", () => {
await makeStore(calls).insert([[1, 2, 3]], ["id-1"], [{ data: "hello" }]);
const insert = calls.find((c) => c.sql.startsWith("INSERT INTO"))!;
expect(insert.binds.id).toBe("id-1");
expect(insert.binds.vector.type).toBe(DB_TYPE_VECTOR);
expect(insert.binds.vector.val).toEqual(new Float32Array([1, 2, 3]));
expect(insert.binds.payload).toEqual({
type: DB_TYPE_JSON,
val: { data: "hello" },
expect(insert.binds).toEqual([
{
id: "id-1",
vector: new Float32Array([1, 2, 3]),
payload: { data: "hello" },
},
]);
expect(insert.options.bindDefs.id).toEqual({
type: DB_TYPE_VARCHAR,
maxSize: 36,
});
expect(insert.options.bindDefs.vector.type).toBe(DB_TYPE_VECTOR);
expect(insert.options.bindDefs.payload.type).toBe(DB_TYPE_JSON);
});
it("issues a single executeMany call with one bind row per vector on a multi-row insert", async () => {
const calls: Call[] = [];
await makeStore(calls).insert(
[
[1, 2, 3],
[4, 5, 6],
],
["id-1", "id-2"],
[{ a: 1 }, { b: 2 }],
);
const inserts = calls.filter((c) => c.sql.startsWith("INSERT INTO"));
expect(inserts).toHaveLength(1);
expect(inserts[0].binds).toHaveLength(2);
expect(inserts[0].binds[0].id).toBe("id-1");
expect(inserts[0].binds[1].id).toBe("id-2");
});
it("issues no insert statement when inserting an empty batch", async () => {
const calls: Call[] = [];
await makeStore(calls).insert([], [], []);
expect(calls.filter((c) => c.sql.startsWith("INSERT INTO"))).toHaveLength(
0,
);
});
it("rejects insert batches whose IDs or payloads do not match vectors", async () => {
const store = makeStore([]);
await expect(store.insert([[1, 2, 3]], [], [{}])).rejects.toThrow(
"ids and vectors must have the same length",
);
await expect(store.insert([[1, 2, 3]], ["id-1"], [])).rejects.toThrow(
"payloads and vectors must have the same length",
);
});
it("converts cosine distance to a similarity score", async () => {
@@ -266,7 +324,7 @@ describe("OracleAIVectorSearch SQL", () => {
expect(results).toEqual([
{ id: "id-1", payload: { data: "hello" }, score: 0.75 },
]);
const select = calls.find((c) => c.sql.startsWith("SELECT id, payload,"))!;
const select = calls.find((c) => c.sql.includes("VECTOR_DISTANCE"))!;
expect(select.sql).toContain(
"VECTOR_DISTANCE(vector, :query_vec, COSINE) distance",
);
@@ -282,6 +340,24 @@ describe("OracleAIVectorSearch SQL", () => {
expect(result.score).toBeCloseTo(0.4);
});
it("adds the VECTOR_INDEX_TRANSFORM hint when searching without filters", async () => {
const calls: Call[] = [];
const store = makeStore(calls, [[["id-1", {}, 0.1]]]);
await store.search([1, 2, 3], 5);
const select = calls.find((c) => c.sql.includes("VECTOR_DISTANCE"))!;
expect(select.sql).toContain('/*+ VECTOR_INDEX_TRANSFORM("mem0") */');
});
it("omits the VECTOR_INDEX_TRANSFORM hint when searching with filters", async () => {
const calls: Call[] = [];
const store = makeStore(calls, [[["id-1", {}, 0.1]]]);
await store.search([1, 2, 3], 5, { user_id: "alice" });
const select = calls.find((c) => c.sql.includes("VECTOR_DISTANCE"))!;
expect(select.sql).not.toContain("VECTOR_INDEX_TRANSFORM");
});
it("parses a payload returned as a JSON string", async () => {
const store = makeStore([], [[["id-1", '{"data":"hello"}']]]);
expect(await store.get("id-1")).toEqual({
@@ -313,16 +389,87 @@ describe("OracleAIVectorSearch SQL", () => {
it("returns rows and the total count from list", async () => {
const calls: Call[] = [];
const store = makeStore(calls, [[["id-1", { data: "hello" }]], [[7]]]);
const store = makeStore(calls, [[["id-1", { data: "hello" }, 7]]]);
const [results, count] = await store.list({ user_id: "alice" }, 10);
expect(results).toEqual([{ id: "id-1", payload: { data: "hello" } }]);
expect(count).toBe(7);
const list = calls.find((c) =>
c.sql.startsWith("SELECT id, payload FROM"),
)!;
const selects = calls.filter((c) => /^SELECT/i.test(c.sql));
expect(selects).toHaveLength(1);
const [list] = selects;
expect(list.sql).toContain(
"SELECT id, payload, COUNT(*) OVER () total FROM",
);
expect(list.sql).toContain("WHERE JSON_EXISTS(payload,");
expect(list.binds).toEqual({ f_0: "alice", max_rows: 10 });
});
it("returns a total of 0 from list when no rows match", async () => {
const store = makeStore([], [[]]);
const [results, count] = await store.list();
expect(results).toEqual([]);
expect(count).toBe(0);
});
});
describe("OracleAIVectorSearch initialization failure", () => {
beforeEach(() => mockCreatePool.mockReset());
function fakePool(serverVersion: string) {
const connection = {
...fakeConnection([], []),
oracleServerVersionString: serverVersion,
};
return {
close: jest.fn(async () => {}),
getConnection: jest.fn(async () => connection),
};
}
function makePoolStore() {
return new OracleAIVectorSearch({
connectionParams: { user: "u", password: "p", connectString: "d" },
collectionName: "mem0",
embeddingModelDims: 3,
} as any);
}
it("closes the pool it owns when initialization fails", async () => {
const pool = fakePool("23.3.0.24.05");
mockCreatePool.mockResolvedValue(pool);
await expect(makePoolStore().initialize()).rejects.toThrow(
"Oracle DB version 23.3.0.24.05 not supported",
);
expect(pool.close).toHaveBeenCalledTimes(1);
});
it("does not cache the rejection, so a later attempt can succeed", async () => {
const failing = fakePool("23.3.0.24.05");
const working = fakePool("23.4.0.24.05");
mockCreatePool
.mockResolvedValueOnce(failing)
.mockResolvedValueOnce(working);
const store = makePoolStore();
await expect(store.initialize()).rejects.toThrow("not supported");
await expect(store.initialize()).resolves.toBeUndefined();
expect(mockCreatePool).toHaveBeenCalledTimes(2);
});
it("leaves a caller-supplied client open when initialization fails", async () => {
const client = fakeConnection([], []);
client.oracleServerVersionString = "23.3.0.24.05";
const close = jest.spyOn(client, "close");
const store = new OracleAIVectorSearch({
client: client as any,
collectionName: "mem0",
embeddingModelDims: 3,
} as any);
await expect(store.initialize()).rejects.toThrow("not supported");
expect(close).not.toHaveBeenCalled();
});
});
@@ -0,0 +1,152 @@
/**
* Unit tests for Memory.buildSessionScope. The recent-conversation buffer key
* derived from user_id/agent_id/run_id must be unique per id combination.
*/
/// <reference types="jest" />
jest.mock("../src/utils/factory", () => {
const { MemoryVectorStore } = jest.requireActual(
"../src/vector_stores/memory",
);
const { SQLiteManager } = jest.requireActual("../src/storage/SQLiteManager");
const testEmbedding = new Array(1536).fill(0.1);
class MockEmbedder {
embeddingDims = 1536;
async embed(): Promise<number[]> {
return testEmbedding;
}
async embedBatch(texts: string[]): Promise<number[][]> {
return texts.map(() => testEmbedding);
}
}
class MockLLM {
async generateResponse() {
return JSON.stringify({ memory: [] });
}
}
return {
__esModule: true,
EmbedderFactory: { create: jest.fn(() => new MockEmbedder()) },
LLMFactory: { create: jest.fn(() => new MockLLM()) },
VectorStoreFactory: {
create: jest.fn(
() => new MemoryVectorStore({ collectionName: "t", dimension: 1536 }),
),
},
HistoryManagerFactory: {
create: jest.fn(() => new SQLiteManager(":memory:")),
},
};
});
import { Memory } from "../src/memory";
import { SearchFilters } from "../src/types";
function scopeOf(memory: Memory, filters: SearchFilters): string {
return (memory as any).buildSessionScope(filters);
}
function cartesian(values: string[], length: number): string[][] {
if (length === 0) return [[]];
const rest = cartesian(values, length - 1);
const result: string[][] = [];
for (const value of values) {
for (const tail of rest) {
result.push([value, ...tail]);
}
}
return result;
}
describe("Memory session scope key", () => {
let memory: Memory;
beforeAll(async () => {
memory = new Memory();
await (memory as any)._initPromise;
});
it("keeps the unchanged key format for ids without delimiter characters", () => {
expect(
scopeOf(memory, { user_id: "550e8400-e29b-41d4-a716-446655440000" }),
).toBe("user_id=550e8400-e29b-41d4-a716-446655440000");
expect(scopeOf(memory, { agent_id: "agent.assistant:v2" })).toBe(
"agent_id=agent.assistant:v2",
);
expect(scopeOf(memory, { run_id: "12345" })).toBe("run_id=12345");
expect(
scopeOf(memory, { user_id: "user@example.com", agent_id: "support-bot" }),
).toBe("agent_id=support-bot&user_id=user@example.com");
});
it("no longer collides an id embedding the join syntax with the equivalent split filters", () => {
const collapsedRun = scopeOf(memory, { run_id: "proj-x&user_id=u1" });
const splitRun = scopeOf(memory, { user_id: "u1", run_id: "proj-x" });
expect(collapsedRun).not.toBe(splitRun);
const collapsedAgent = scopeOf(memory, { run_id: "proj-y&agent_id=a1" });
const splitAgent = scopeOf(memory, { agent_id: "a1", run_id: "proj-y" });
expect(collapsedAgent).not.toBe(splitAgent);
});
it("maps every distinct filter combination of delimiter-heavy ids to a distinct key", () => {
const keys: string[] = ["user_id", "agent_id", "run_id"];
const values = [
"u1",
"r1",
"a1",
"%",
"&",
"=",
"a==",
"a1&run_id=r1",
"a1&user_id=u1",
"r1&user_id=u1",
"a1&run_id=r1&user_id=u1",
];
const seen = new Map<string, SearchFilters>();
for (let mask = 1; mask < 1 << keys.length; mask++) {
const subset = keys.filter((_key, i) => mask & (1 << i));
for (const combo of cartesian(values, subset.length)) {
const filters: SearchFilters = {};
subset.forEach((key, i) => (filters[key] = combo[i]));
const scope = scopeOf(memory, filters);
if (seen.has(scope)) {
expect(seen.get(scope)).toEqual(filters);
} else {
seen.set(scope, filters);
}
}
}
});
it("gives ids containing delimiter characters a new key format", () => {
expect(scopeOf(memory, { user_id: "dXNlcl9pZDE=" })).toBe(
"user_id=dXNlcl9pZDE%3D",
);
expect(scopeOf(memory, { agent_id: "x&y" })).toBe("agent_id=x%26y");
expect(scopeOf(memory, { run_id: "50% off" })).toBe("run_id=50%25 off");
});
it("routes the add pipeline through the builder", async () => {
const db = (memory as any).db;
const spy = jest.spyOn(db, "getLastMessages");
await memory.add([{ role: "user", content: "hello" }], {
runId: "proj-x&user_id=u1",
});
expect(spy).toHaveBeenCalledWith("run_id=proj-x%26user_id%3Du1", 10);
spy.mockRestore();
});
it("pins the exact key strings shared with the Python test suite", () => {
expect(
scopeOf(memory, { user_id: "550e8400-e29b-41d4-a716-446655440000" }),
).toBe("user_id=550e8400-e29b-41d4-a716-446655440000");
expect(
scopeOf(memory, { user_id: "u1", agent_id: "a1", run_id: "r1" }),
).toBe("agent_id=a1&run_id=r1&user_id=u1");
expect(scopeOf(memory, { run_id: "proj-x&user_id=u1" })).toBe(
"run_id=proj-x%26user_id%3Du1",
);
});
});
+4 -2
View File
@@ -1,3 +1,4 @@
# Copyright (c) 2026, Oracle and/or its affiliates.
"""Pydantic configuration for the Oracle AI Vector Search integration."""
import re
@@ -91,8 +92,9 @@ class OracleAIVectorSearchConfig(BaseModel):
exclude_none=True,
)
if self.index_accuracy and not (0 < self.index_accuracy <= 100):
raise ValueError("`index_accuracy` must be between 1 and 100")
if self.index_accuracy is not None:
if not (0 < self.index_accuracy <= 100):
raise ValueError("`index_accuracy` must be between 1 and 100")
if not (0 < self.embedding_model_dims):
raise ValueError("`embedding_model_dims` must be bigger than 0")
+17 -1
View File
@@ -404,13 +404,18 @@ def _build_filters_and_metadata(
return base_metadata_template, effective_query_filters
def _escape_scope_value(val: Any) -> str:
"""Escape the structural delimiters of the session scope key."""
return str(val).replace("%", "%25").replace("&", "%26").replace("=", "%3D")
def _build_session_scope(filters):
"""Build deterministic session scope string from entity IDs."""
parts = []
for key in sorted(["user_id", "agent_id", "run_id"]):
val = filters.get(key)
if val:
parts.append(f"{key}={val}")
parts.append(f"{key}={_escape_scope_value(val)}")
return "&".join(parts)
@@ -791,6 +796,11 @@ class Memory(MemoryBase):
are treated as general conversational/factual memories.
prompt (str, optional): Prompt to use for the memory creation. Defaults to None.
Note:
`search()` and `get_all()` scope queries via `filters={"user_id": "...", "agent_id": "...", "run_id": "..."}` —
they reject top-level `user_id`/`agent_id`/`run_id` arguments. `add()` accepts them top-level, but passing
the same arguments to `search()`/`get_all()` raises a `ValueError`; use the `filters` form there instead.
Returns:
dict: A dictionary containing the result of the memory addition operation, typically
@@ -2447,6 +2457,12 @@ class AsyncMemory(MemoryBase):
Pass "procedural_memory" to create procedural memories.
prompt (str, optional): Prompt to use for the memory creation. Defaults to None.
llm (BaseChatModel, optional): LLM class to use for generating procedural memories. Defaults to None. Useful when user is using LangChain ChatModel.
Note:
`search()` and `get_all()` scope queries via `filters={"user_id": "...", "agent_id": "...", "run_id": "..."}` —
they reject top-level `user_id`/`agent_id`/`run_id` arguments. `add()` accepts them top-level, but passing
the same arguments to `search()`/`get_all()` raises a `ValueError`; use the `filters` form there instead.
Returns:
dict: A dictionary containing the result of the memory addition operation.
"""
+8 -2
View File
@@ -1,7 +1,7 @@
import hashlib
import logging
import re
from typing import Any, Dict, List
from typing import Any, Dict, List, Union
from mem0.configs.prompts import (
AGENT_MEMORY_EXTRACTION_PROMPT,
@@ -112,7 +112,7 @@ def normalize_facts(raw_facts):
return normalized
def remove_code_blocks(content: str) -> str:
def remove_code_blocks(content: Union[str, List[Union[str, Dict[str, Any]]], None]) -> str:
"""
Removes enclosing code block markers ```[language] and ``` from a given string.
@@ -120,9 +120,15 @@ def remove_code_blocks(content: str) -> str:
- The function uses a regex pattern to match code blocks that may start with ``` followed by an optional language tag (letters or numbers) and end with ```.
- If a code block is detected, it returns only the inner content, stripping out the markers.
- If no code block markers are found, the original content is returned as-is.
- Block-style content (a LangChain message whose `.content` is a list of text
blocks) is flattened to its concatenated text before matching.
"""
if content is None:
return ""
if isinstance(content, list):
content = "".join(
part if isinstance(part, str) else part.get("text", "") for part in content if isinstance(part, (str, dict))
)
pattern = r"^```[a-zA-Z0-9]*\n([\s\S]*?)\n```$"
match = re.match(pattern, content.strip())
match_res=match.group(1).strip() if match else content.strip()
+27 -17
View File
@@ -1,3 +1,4 @@
# Copyright (c) 2026, Oracle and/or its affiliates.
"""Oracle AI Vector Search vector store integration for mem0."""
import array
@@ -245,25 +246,34 @@ class OracleAIVectorSearch(VectorStoreBase):
self.client = oracledb.connect(**self.config.connection_params)
self._owns_client = True
if not (hasattr(self.client, "thin") and self.client.thin):
if oracledb.clientversion()[:2] < (23, 4):
raise RuntimeError(
f"Oracle DB client driver version {'.'.join(map(str, oracledb.clientversion()))} "
"not supported, must be >=23.4 for vector support"
try:
if not (hasattr(self.client, "thin") and self.client.thin):
if oracledb.clientversion()[:2] < (23, 4):
raise RuntimeError(
f"Oracle DB client driver version {'.'.join(map(str, oracledb.clientversion()))} "
"not supported, must be >=23.4 for vector support"
)
if isinstance(self.client, oracledb.Connection):
db_version = tuple([int(v) for v in self.client.version.split(".")])
else:
with self.client.acquire() as conn:
db_version = tuple([int(v) for v in conn.version.split(".")])
if db_version < (23, 4):
raise ValueError(
f"Oracle DB version {'.'.join(map(str, db_version))} not supported, "
"must be >=23.4 for vector support"
)
if isinstance(self.client, oracledb.Connection):
db_version = tuple([int(v) for v in self.client.version.split(".")])
else:
with self.client.acquire() as conn:
db_version = tuple([int(v) for v in conn.version.split(".")])
if db_version < (23, 4):
raise ValueError(
f"Oracle DB version {'.'.join(map(str, db_version))} not supported, must be >=23.4 for vector support"
)
self.create_col()
self.create_col()
except Exception:
if self._owns_client:
try:
self.client.close()
except Exception:
pass
raise
@contextmanager
def _get_cursor(self, commit: bool = False):
+4
View File
@@ -89,6 +89,10 @@ def _build_filter_conditions(filters):
raise ValueError(f"Unsupported filter operator: {op}")
template, is_numeric = OPERATOR_SQL_MAP[op]
if op in ("in", "nin"):
if not isinstance(op_value, list):
raise ValueError(
f"Filter operator {op!r} for key {key!r} requires a list value, got {type(op_value).__name__}"
)
str_list = [str(v) for v in op_value]
conditions.append(template)
params.extend([key, str_list])
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "mem0ai"
version = "2.0.17"
version = "2.0.18"
description = "Long-term memory for AI Agents"
authors = [
{ name = "Mem0", email = "support@mem0.ai" }
+18
View File
@@ -192,3 +192,21 @@ class TestProcessTelemetryFilters:
class TestRemoveCodeBlocks:
def test_none_content_returns_empty_string(self):
assert remove_code_blocks(None) == ""
def test_block_list_content_is_flattened(self):
assert remove_code_blocks([{"type": "text", "text": "step one"}]) == "step one"
def test_block_list_content_strips_code_fences(self):
content = [{"type": "text", "text": '```json\n{"a": 1}\n```'}]
assert remove_code_blocks(content) == '{"a": 1}'
def test_block_list_content_joins_multiple_blocks(self):
content = [{"type": "text", "text": "step one. "}, {"type": "text", "text": "step two"}]
assert remove_code_blocks(content) == "step one. step two"
def test_block_list_content_ignores_non_text_blocks(self):
content = [{"type": "thinking", "thinking": "hmm"}, {"type": "text", "text": "answer"}]
assert remove_code_blocks(content) == "answer"
def test_plain_string_blocks_are_supported(self):
assert remove_code_blocks(["step one. ", "step two"]) == "step one. step two"
+131
View File
@@ -0,0 +1,131 @@
import itertools
import pytest
from mem0.memory.main import Memory, _build_session_scope, _escape_scope_value
DELIMITER_VALUES = [
"u1",
"r1",
"a1",
"%",
"&",
"=",
"%25",
"%26",
"%3D",
"a==",
"a1&run_id=r1",
"a1&user_id=u1",
"r1&user_id=u1",
"a1&run_id=r1&user_id=u1",
]
class TestBuildSessionScope:
"""Tests that _build_session_scope produces a unique key per id combination."""
def test_ordinary_ids_produce_unchanged_scope_keys(self):
"""Ids without delimiter characters keep producing the pre-fix key format."""
cases = [
({"user_id": "550e8400-e29b-41d4-a716-446655440000"}, "user_id=550e8400-e29b-41d4-a716-446655440000"),
({"agent_id": "agent.assistant:v2"}, "agent_id=agent.assistant:v2"),
({"run_id": "12345"}, "run_id=12345"),
(
{"user_id": "user@example.com", "agent_id": "support-bot"},
"agent_id=support-bot&user_id=user@example.com",
),
(
{"user_id": "u1", "agent_id": "a1", "run_id": "r1"},
"agent_id=a1&run_id=r1&user_id=u1",
),
]
for filters, expected in cases:
assert _build_session_scope(filters) == expected
def test_ids_containing_delimiters_do_not_collide(self):
"""A value that embeds the join syntax no longer maps to the same key as the equivalent split filters."""
collapsed_run = {"run_id": "proj-x&user_id=u1"}
split_run = {"user_id": "u1", "run_id": "proj-x"}
assert _build_session_scope(collapsed_run) != _build_session_scope(split_run)
assert _build_session_scope(collapsed_run) == "run_id=proj-x%26user_id%3Du1"
collapsed_agent = {"run_id": "proj-y&agent_id=a1"}
split_agent = {"agent_id": "a1", "run_id": "proj-y"}
assert _build_session_scope(collapsed_agent) != _build_session_scope(split_agent)
def test_ids_containing_delimiters_get_a_new_key_format(self):
"""Ids holding a delimiter character map to a new key, so their buffer starts empty once after upgrade."""
assert _build_session_scope({"user_id": "dXNlcl9pZDE="}) == "user_id=dXNlcl9pZDE%3D"
assert _build_session_scope({"agent_id": "x&y"}) == "agent_id=x%26y"
assert _build_session_scope({"run_id": "50% off"}) == "run_id=50%25 off"
def test_scope_keys_are_unique_per_filter_combination(self):
"""Every distinct filter dict built from delimiter-heavy id values maps to a distinct scope key."""
keys = ["user_id", "agent_id", "run_id"]
seen = {}
for size in range(1, len(keys) + 1):
for key_subset in itertools.combinations(keys, size):
for combo in itertools.product(DELIMITER_VALUES, repeat=size):
filters = dict(zip(key_subset, combo))
scope = _build_session_scope(filters)
if scope in seen:
assert seen[scope] == filters, f"{seen[scope]} and {filters} both map to {scope!r}"
else:
seen[scope] = filters
class TestEscapeScopeValue:
"""Tests for the low-level per-value escaping helper."""
def test_non_string_input_is_stringified(self):
assert _escape_scope_value(42) == "42"
def test_percent_is_escaped_before_other_delimiters(self):
assert _escape_scope_value("%26") == "%2526"
assert _escape_scope_value("%26") != "%26"
def test_each_delimiter_is_escaped(self):
assert _escape_scope_value("%") == "%25"
assert _escape_scope_value("&") == "%26"
assert _escape_scope_value("=") == "%3D"
class TestSessionScopeWiring:
"""Tests that the add pipeline keys the conversation buffer through the builder."""
@pytest.fixture
def memory(self, mocker):
mocker.patch("mem0.memory.main.capture_event")
mock_embedder = mocker.MagicMock()
mock_embedder.return_value.embed.return_value = [0.1, 0.2, 0.3]
mocker.patch("mem0.utils.factory.EmbedderFactory.create", mock_embedder)
mock_vector_store = mocker.MagicMock()
mock_vector_store.return_value.search.return_value = []
mocker.patch(
"mem0.utils.factory.VectorStoreFactory.create",
side_effect=[mock_vector_store.return_value, mocker.MagicMock()],
)
mocker.patch("mem0.utils.factory.LlmFactory.create", mocker.MagicMock())
mocker.patch("mem0.memory.storage.SQLiteManager", mocker.MagicMock())
memory = Memory()
memory.config = mocker.MagicMock()
memory.config.custom_instructions = None
memory.custom_instructions = None
memory.api_version = "v1.1"
memory.db.get_last_messages = mocker.MagicMock(return_value=[])
memory.db.save_messages = mocker.MagicMock()
memory.llm.generate_response.return_value = '{"memory": []}'
return memory
def test_add_pipeline_uses_the_escaped_key(self, memory):
"""The pipeline must route through the builder, not assemble the key inline."""
memory._add_to_vector_store(
messages=[{"role": "user", "content": "hello"}],
metadata={},
filters={"run_id": "proj-x&user_id=u1"},
infer=True,
)
assert memory.db.get_last_messages.call_args[0][0] == "run_id=proj-x%26user_id%3Du1"
assert memory.db.save_messages.call_args[0][1] == "run_id=proj-x%26user_id%3Du1"
+37 -2
View File
@@ -1235,9 +1235,10 @@ class TestHybridSearchWarning:
def test_warning_for_store_without_keyword_search(
self, mock_vs_factory, mock_emb, mock_llm, mock_sqlite, _cap, caplog
):
from mem0.vector_stores.base import VectorStoreBase
import logging
from mem0.vector_stores.base import VectorStoreBase
class StoreWithoutKeywordSearch(VectorStoreBase):
def create_col(self, *a, **kw): pass
def insert(self, *a, **kw): pass
@@ -1271,9 +1272,10 @@ class TestHybridSearchWarning:
def test_no_warning_for_store_with_keyword_search(
self, mock_vs_factory, mock_emb, mock_llm, mock_sqlite, _cap, caplog
):
from mem0.vector_stores.base import VectorStoreBase
import logging
from mem0.vector_stores.base import VectorStoreBase
class StoreWithKeywordSearch(VectorStoreBase):
def keyword_search(self, query, top_k=5, filters=None):
return []
@@ -1536,6 +1538,39 @@ async def test_async_procedural_memory_langchain_strips_code_blocks(mock_llm_fac
assert "```" not in stored_data
@pytest.mark.asyncio
@patch("mem0.memory.main.VectorStoreFactory")
@patch("mem0.memory.main.EmbedderFactory")
@patch("mem0.memory.main.LlmFactory")
async def test_async_procedural_memory_langchain_block_list_content(mock_llm_factory, mock_emb, mock_vs):
"""Regression #6150: block-list message content must not raise AttributeError."""
mock_vs.return_value = MagicMock()
mock_emb.return_value = MagicMock()
mock_emb.return_value.embed.return_value = [0.1] * 1536
mock_llm_factory.return_value = MagicMock()
from mem0.memory.main import AsyncMemory
config = MemoryConfig()
memory = AsyncMemory(config)
memory.vector_store = MagicMock()
memory.vector_store.insert = MagicMock()
mock_langchain_llm = MagicMock()
mock_response = MagicMock()
mock_response.content = [{"type": "text", "text": '```json\n{"key": "value"}\n```'}]
mock_langchain_llm.invoke.return_value = mock_response
messages = [{"role": "user", "content": "test"}]
metadata = {"user_id": "test_user"}
await memory._create_procedural_memory(messages, metadata=metadata, llm=mock_langchain_llm)
insert_call = memory.vector_store.insert.call_args
stored_data = insert_call[1]["payloads"][0]["data"]
assert stored_data == '{"key": "value"}'
@pytest.mark.asyncio
@patch("mem0.memory.main.VectorStoreFactory")
@patch("mem0.memory.main.EmbedderFactory")
+32
View File
@@ -1,3 +1,4 @@
# Copyright (c) 2026, Oracle and/or its affiliates.
import os
import uuid
from contextlib import nullcontext
@@ -267,6 +268,16 @@ def test_index_parameters_reject_non_string_keys():
)
def test_index_accuracy_rejects_zero():
with pytest.raises(ValueError, match="index_accuracy.*between 1 and 100"):
OracleAIVectorSearchConfig(
collection_name=_unique_collection_name(),
embedding_model_dims=DIM,
client=object(),
index_accuracy=0,
)
def test_index_parameters_canonicalize_int_subclasses():
class FormattedInt(int):
def __format__(self, format_spec):
@@ -331,6 +342,27 @@ def test_config_rejects_none_for_non_optional_fields(field, value):
OracleAIVectorSearchConfig(client=object(), **{field: value})
def test_init_closes_owned_client_when_post_connect_setup_fails(monkeypatch):
fake_connection = MagicMock(spec=oracledb.Connection)
fake_connection.thin = True
fake_connection.version = "23.4.0.0"
monkeypatch.setattr(oracledb, "connect", MagicMock(return_value=fake_connection))
monkeypatch.setattr(OracleAIVectorSearch, "create_col", MagicMock(side_effect=RuntimeError("boom")))
monkeypatch.setattr(OracleAIVectorSearch, "__del__", lambda self: None)
with pytest.raises(RuntimeError, match="boom"):
OracleAIVectorSearch(
collection_name=_unique_collection_name(),
embedding_model_dims=DIM,
connection_params={"user": "u", "password": "p", "dsn": "d"},
use_connection_pool=False,
do_create_index=False,
)
fake_connection.close.assert_called_once()
@pytest.mark.parametrize(
("metric", "distance", "expected_score"),
[
+17
View File
@@ -2508,3 +2508,20 @@ class TestBuildFilterConditions(unittest.TestCase):
def test_numeric_scalar_becomes_string(self):
conditions, params = _build_filter_conditions({"priority": 42})
self.assertEqual(params, ["priority", "42"])
def test_in_rejects_string_value(self):
"""Passing a string to 'in' would iterate characters and produce a misleading ANY() clause."""
with self.assertRaises(ValueError, msg="Expected ValueError for non-list 'in' value"):
_build_filter_conditions({"user_id": {"in": "alice"}})
def test_in_rejects_dict_value(self):
with self.assertRaises(ValueError):
_build_filter_conditions({"user_id": {"in": {"$gt": 0}}})
def test_nin_rejects_string_value(self):
with self.assertRaises(ValueError):
_build_filter_conditions({"user_id": {"nin": "alice"}})
def test_in_accepts_list_value(self):
conditions, params = _build_filter_conditions({"user_id": {"in": ["alice", "bob"]}})
self.assertEqual(params, ["user_id", ["alice", "bob"]])