feat: 导入 MemRelay 初始源码

This commit is contained in:
Nixevol
2026-09-23 21:40:46 +08:00
commit 0ade3bb318
167 changed files with 53511 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import asyncio
import pytest
from memrelay.basic_memory import BasicMemoryClient
from memrelay.errors import AppError
def test_write_note_maps_conflict_response_to_stable_error() -> None:
client = BasicMemoryClient("http://basic-memory.test/mcp", 1)
async def conflict_call(_name: str, _arguments: dict) -> dict:
return {
"action": "conflict",
"error": "A note with this title already exists",
"permalink": "global/existing-note",
}
client.call = conflict_call # type: ignore[method-assign]
with pytest.raises(AppError) as exc_info:
asyncio.run(
client.write_note(
title="Existing note",
content="content",
directory="global",
tags=[],
note_type="fact",
metadata={},
overwrite=False,
)
)
assert exc_info.value.code == "BASIC_MEMORY_CONFLICT"
assert exc_info.value.status_code == 409