> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myrmagent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory API

> 以编程方式访问与管理 Agent 记忆。

# Memory API

## 列出记忆条目

```bash theme={null}
GET /api/memory?type=semantic&page=1&page_size=20&sort_by=created_at&sort_order=desc&tag=python
```

| 参数           | 类型     | 默认值          | 说明                                                                          |
| ------------ | ------ | ------------ | --------------------------------------------------------------------------- |
| `type`       | string | 全部           | 记忆类型过滤: `semantic`, `episodic`, `procedural`, `conversation`, `task_digest` |
| `page`       | int    | 1            | 页码（从 1 开始）                                                                  |
| `page_size`  | int    | 20           | 每页条数（最大 100）                                                                |
| `sort_by`    | string | `created_at` | 排序字段: `created_at`, `updated_at`, `importance`                              |
| `sort_order` | string | `desc`       | 排序方向: `asc` 或 `desc`                                                        |
| `tag`        | string | —            | 按标签过滤（不区分大小写）                                                               |
| `search`     | string | —            | 语义搜索查询（使用向量相似度）                                                             |

响应：

```json theme={null}
{
  "items": [...],
  "total": 91,
  "page": 1,
  "page_size": 20,
  "has_next": true,
  "has_prev": false
}
```

## 获取记忆标签

```bash theme={null}
GET /api/memory/tags?limit=20
```

返回所有记忆类型中最常用的标签及其计数。

## 搜索记忆

```bash theme={null}
POST /api/memory/search
```

```json theme={null}
{
  "query": "user preferences for coding style",
  "limit": 10
}
```

## 创建记忆条目

```bash theme={null}
POST /api/memory
```

```json theme={null}
{
  "type": "semantic",
  "content": "User prefers TypeScript with strict mode",
  "importance": 0.8
}
```

## 删除记忆条目

```bash theme={null}
DELETE /api/memory/:id
```

## 记忆指挥中心

获取完整的记忆系统健康状态和诊断快照，用于设置页面展示。

```bash theme={null}
GET /api/v1/memory/command-center?project_id=<可选>
```

| 参数           | 类型     | 默认值 | 说明                           |
| ------------ | ------ | --- | ---------------------------- |
| `project_id` | string | —   | 可选的项目 ID，用于将快照范围限定为单个项目的记忆空间 |

响应包含：概览统计、记忆空间、治理项、健康诊断、时间线事件、迁移状态、运行时配置等。

提供 `project_id` 时，`spaces`、`governance` 和 `timeline` 部分仅显示与该项目 SharedContext 绑定相关的数据。空字符串会被自动归一化为全局视图。
